| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686 |
- function dle(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 Qw=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function rc(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var AM={exports:{}},Yx={};var BU;function ule(){if(BU)return Yx;BU=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 Yx.Fragment=e,Yx.jsx=n,Yx.jsxs=n,Yx}var HU;function hle(){return HU||(HU=1,AM.exports=ule()),AM.exports}var a=hle(),TM={exports:{}},kn={};var $U;function mle(){if($U)return kn;$U=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),s=Symbol.for("react.consumer"),o=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),d=Symbol.for("react.memo"),u=Symbol.for("react.lazy"),h=Symbol.for("react.activity"),f=Symbol.iterator;function p(H){return H===null||typeof H!="object"?null:(H=f&&H[f]||H["@@iterator"],typeof H=="function"?H:null)}var x={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},v=Object.assign,g={};function y(H,X,Z){this.props=H,this.context=X,this.refs=g,this.updater=Z||x}y.prototype.isReactComponent={},y.prototype.setState=function(H,X){if(typeof H!="object"&&typeof H!="function"&&H!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,H,X,"setState")},y.prototype.forceUpdate=function(H){this.updater.enqueueForceUpdate(this,H,"forceUpdate")};function _(){}_.prototype=y.prototype;function N(H,X,Z){this.props=H,this.context=X,this.refs=g,this.updater=Z||x}var A=N.prototype=new _;A.constructor=N,v(A,y.prototype),A.isPureReactComponent=!0;var k=Array.isArray;function P(){}var C={H:null,A:null,T:null,S:null},j=Object.prototype.hasOwnProperty;function M(H,X,Z){var ee=Z.ref;return{$$typeof:t,type:H,key:X,ref:ee!==void 0?ee:null,props:Z}}function E(H,X){return M(H.type,X,H.props)}function B(H){return typeof H=="object"&&H!==null&&H.$$typeof===t}function L(H){var X={"=":"=0",":":"=2"};return"$"+H.replace(/[=:]/g,function(Z){return X[Z]})}var U=/\/+/g;function D(H,X){return typeof H=="object"&&H!==null&&H.key!=null?L(""+H.key):X.toString(36)}function $(H){switch(H.status){case"fulfilled":return H.value;case"rejected":throw H.reason;default:switch(typeof H.status=="string"?H.then(P,P):(H.status="pending",H.then(function(X){H.status==="pending"&&(H.status="fulfilled",H.value=X)},function(X){H.status==="pending"&&(H.status="rejected",H.reason=X)})),H.status){case"fulfilled":return H.value;case"rejected":throw H.reason}}throw H}function q(H,X,Z,ee,Se){var oe=typeof H;(oe==="undefined"||oe==="boolean")&&(H=null);var ie=!1;if(H===null)ie=!0;else switch(oe){case"bigint":case"string":case"number":ie=!0;break;case"object":switch(H.$$typeof){case t:case e:ie=!0;break;case u:return ie=H._init,q(ie(H._payload),X,Z,ee,Se)}}if(ie)return Se=Se(H),ie=ee===""?"."+D(H,0):ee,k(Se)?(Z="",ie!=null&&(Z=ie.replace(U,"$&/")+"/"),q(Se,X,Z,"",function(ce){return ce})):Se!=null&&(B(Se)&&(Se=E(Se,Z+(Se.key==null||H&&H.key===Se.key?"":(""+Se.key).replace(U,"$&/")+"/")+ie)),X.push(Se)),1;ie=0;var me=ee===""?".":ee+":";if(k(H))for(var se=0;se<H.length;se++)ee=H[se],oe=me+D(ee,se),ie+=q(ee,X,Z,oe,Se);else if(se=p(H),typeof se=="function")for(H=se.call(H),se=0;!(ee=H.next()).done;)ee=ee.value,oe=me+D(ee,se++),ie+=q(ee,X,Z,oe,Se);else if(oe==="object"){if(typeof H.then=="function")return q($(H),X,Z,ee,Se);throw X=String(H),Error("Objects are not valid as a React child (found: "+(X==="[object Object]"?"object with keys {"+Object.keys(H).join(", ")+"}":X)+"). If you meant to render a collection of children, use an array instead.")}return ie}function z(H,X,Z){if(H==null)return H;var ee=[],Se=0;return q(H,ee,"","",function(oe){return X.call(Z,oe,Se++)}),ee}function W(H){if(H._status===-1){var X=H._result;X=X(),X.then(function(Z){(H._status===0||H._status===-1)&&(H._status=1,H._result=Z)},function(Z){(H._status===0||H._status===-1)&&(H._status=2,H._result=Z)}),H._status===-1&&(H._status=0,H._result=X)}if(H._status===1)return H._result.default;throw H._result}var Q=typeof reportError=="function"?reportError:function(H){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var X=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof H=="object"&&H!==null&&typeof H.message=="string"?String(H.message):String(H),error:H});if(!window.dispatchEvent(X))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",H);return}console.error(H)},te={map:z,forEach:function(H,X,Z){z(H,function(){X.apply(this,arguments)},Z)},count:function(H){var X=0;return z(H,function(){X++}),X},toArray:function(H){return z(H,function(X){return X})||[]},only:function(H){if(!B(H))throw Error("React.Children.only expected to receive a single React element child.");return H}};return kn.Activity=h,kn.Children=te,kn.Component=y,kn.Fragment=n,kn.Profiler=i,kn.PureComponent=N,kn.StrictMode=r,kn.Suspense=c,kn.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=C,kn.__COMPILER_RUNTIME={__proto__:null,c:function(H){return C.H.useMemoCache(H)}},kn.cache=function(H){return function(){return H.apply(null,arguments)}},kn.cacheSignal=function(){return null},kn.cloneElement=function(H,X,Z){if(H==null)throw Error("The argument must be a React element, but you passed "+H+".");var ee=v({},H.props),Se=H.key;if(X!=null)for(oe in X.key!==void 0&&(Se=""+X.key),X)!j.call(X,oe)||oe==="key"||oe==="__self"||oe==="__source"||oe==="ref"&&X.ref===void 0||(ee[oe]=X[oe]);var oe=arguments.length-2;if(oe===1)ee.children=Z;else if(1<oe){for(var ie=Array(oe),me=0;me<oe;me++)ie[me]=arguments[me+2];ee.children=ie}return M(H.type,Se,ee)},kn.createContext=function(H){return H={$$typeof:o,_currentValue:H,_currentValue2:H,_threadCount:0,Provider:null,Consumer:null},H.Provider=H,H.Consumer={$$typeof:s,_context:H},H},kn.createElement=function(H,X,Z){var ee,Se={},oe=null;if(X!=null)for(ee in X.key!==void 0&&(oe=""+X.key),X)j.call(X,ee)&&ee!=="key"&&ee!=="__self"&&ee!=="__source"&&(Se[ee]=X[ee]);var ie=arguments.length-2;if(ie===1)Se.children=Z;else if(1<ie){for(var me=Array(ie),se=0;se<ie;se++)me[se]=arguments[se+2];Se.children=me}if(H&&H.defaultProps)for(ee in ie=H.defaultProps,ie)Se[ee]===void 0&&(Se[ee]=ie[ee]);return M(H,oe,Se)},kn.createRef=function(){return{current:null}},kn.forwardRef=function(H){return{$$typeof:l,render:H}},kn.isValidElement=B,kn.lazy=function(H){return{$$typeof:u,_payload:{_status:-1,_result:H},_init:W}},kn.memo=function(H,X){return{$$typeof:d,type:H,compare:X===void 0?null:X}},kn.startTransition=function(H){var X=C.T,Z={};C.T=Z;try{var ee=H(),Se=C.S;Se!==null&&Se(Z,ee),typeof ee=="object"&&ee!==null&&typeof ee.then=="function"&&ee.then(P,Q)}catch(oe){Q(oe)}finally{X!==null&&Z.types!==null&&(X.types=Z.types),C.T=X}},kn.unstable_useCacheRefresh=function(){return C.H.useCacheRefresh()},kn.use=function(H){return C.H.use(H)},kn.useActionState=function(H,X,Z){return C.H.useActionState(H,X,Z)},kn.useCallback=function(H,X){return C.H.useCallback(H,X)},kn.useContext=function(H){return C.H.useContext(H)},kn.useDebugValue=function(){},kn.useDeferredValue=function(H,X){return C.H.useDeferredValue(H,X)},kn.useEffect=function(H,X){return C.H.useEffect(H,X)},kn.useEffectEvent=function(H){return C.H.useEffectEvent(H)},kn.useId=function(){return C.H.useId()},kn.useImperativeHandle=function(H,X,Z){return C.H.useImperativeHandle(H,X,Z)},kn.useInsertionEffect=function(H,X){return C.H.useInsertionEffect(H,X)},kn.useLayoutEffect=function(H,X){return C.H.useLayoutEffect(H,X)},kn.useMemo=function(H,X){return C.H.useMemo(H,X)},kn.useOptimistic=function(H,X){return C.H.useOptimistic(H,X)},kn.useReducer=function(H,X,Z){return C.H.useReducer(H,X,Z)},kn.useRef=function(H){return C.H.useRef(H)},kn.useState=function(H){return C.H.useState(H)},kn.useSyncExternalStore=function(H,X,Z){return C.H.useSyncExternalStore(H,X,Z)},kn.useTransition=function(){return C.H.useTransition()},kn.version="19.2.4",kn}var VU;function zb(){return VU||(VU=1,TM.exports=mle()),TM.exports}var w=zb();const Wr=rc(w),fle=dle({__proto__:null,default:Wr},[w]);var MM={exports:{}},Qx={},PM={exports:{}},EM={};var qU;function ple(){return qU||(qU=1,(function(t){function e(q,z){var W=q.length;q.push(z);e:for(;0<W;){var Q=W-1>>>1,te=q[Q];if(0<i(te,z))q[Q]=z,q[W]=te,W=Q;else break e}}function n(q){return q.length===0?null:q[0]}function r(q){if(q.length===0)return null;var z=q[0],W=q.pop();if(W!==z){q[0]=W;e:for(var Q=0,te=q.length,H=te>>>1;Q<H;){var X=2*(Q+1)-1,Z=q[X],ee=X+1,Se=q[ee];if(0>i(Z,W))ee<te&&0>i(Se,Z)?(q[Q]=Se,q[ee]=W,Q=ee):(q[Q]=Z,q[X]=W,Q=X);else if(ee<te&&0>i(Se,W))q[Q]=Se,q[ee]=W,Q=ee;else break e}}return z}function i(q,z){var W=q.sortIndex-z.sortIndex;return W!==0?W:q.id-z.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=[],d=[],u=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(q){for(var z=n(d);z!==null;){if(z.callback===null)r(d);else if(z.startTime<=q)r(d),z.sortIndex=z.expirationTime,e(c,z);else break;z=n(d)}}function k(q){if(v=!1,A(q),!x)if(n(c)!==null)x=!0,P||(P=!0,L());else{var z=n(d);z!==null&&$(k,z.startTime-q)}}var P=!1,C=-1,j=5,M=-1;function E(){return g?!0:!(t.unstable_now()-M<j)}function B(){if(g=!1,P){var q=t.unstable_now();M=q;var z=!0;try{e:{x=!1,v&&(v=!1,_(C),C=-1),p=!0;var W=f;try{t:{for(A(q),h=n(c);h!==null&&!(h.expirationTime>q&&E());){var Q=h.callback;if(typeof Q=="function"){h.callback=null,f=h.priorityLevel;var te=Q(h.expirationTime<=q);if(q=t.unstable_now(),typeof te=="function"){h.callback=te,A(q),z=!0;break t}h===n(c)&&r(c),A(q)}else r(c);h=n(c)}if(h!==null)z=!0;else{var H=n(d);H!==null&&$(k,H.startTime-q),z=!1}}break e}finally{h=null,f=W,p=!1}z=void 0}}finally{z?L():P=!1}}}var L;if(typeof N=="function")L=function(){N(B)};else if(typeof MessageChannel<"u"){var U=new MessageChannel,D=U.port2;U.port1.onmessage=B,L=function(){D.postMessage(null)}}else L=function(){y(B,0)};function $(q,z){C=y(function(){q(t.unstable_now())},z)}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(q){q.callback=null},t.unstable_forceFrameRate=function(q){0>q||125<q?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):j=0<q?Math.floor(1e3/q):5},t.unstable_getCurrentPriorityLevel=function(){return f},t.unstable_next=function(q){switch(f){case 1:case 2:case 3:var z=3;break;default:z=f}var W=f;f=z;try{return q()}finally{f=W}},t.unstable_requestPaint=function(){g=!0},t.unstable_runWithPriority=function(q,z){switch(q){case 1:case 2:case 3:case 4:case 5:break;default:q=3}var W=f;f=q;try{return z()}finally{f=W}},t.unstable_scheduleCallback=function(q,z,W){var Q=t.unstable_now();switch(typeof W=="object"&&W!==null?(W=W.delay,W=typeof W=="number"&&0<W?Q+W:Q):W=Q,q){case 1:var te=-1;break;case 2:te=250;break;case 5:te=1073741823;break;case 4:te=1e4;break;default:te=5e3}return te=W+te,q={id:u++,callback:z,priorityLevel:q,startTime:W,expirationTime:te,sortIndex:-1},W>Q?(q.sortIndex=W,e(d,q),n(c)===null&&q===n(d)&&(v?(_(C),C=-1):v=!0,$(k,W-Q))):(q.sortIndex=te,e(c,q),x||p||(x=!0,P||(P=!0,L()))),q},t.unstable_shouldYield=E,t.unstable_wrapCallback=function(q){var z=f;return function(){var W=f;f=z;try{return q.apply(this,arguments)}finally{f=W}}}})(EM)),EM}var GU;function gle(){return GU||(GU=1,PM.exports=ple()),PM.exports}var jM={exports:{}},ss={};var WU;function ble(){if(WU)return ss;WU=1;var t=zb();function e(c){var d="https://react.dev/errors/"+c;if(1<arguments.length){d+="?args[]="+encodeURIComponent(arguments[1]);for(var u=2;u<arguments.length;u++)d+="&args[]="+encodeURIComponent(arguments[u])}return"Minified React error #"+c+"; visit "+d+" 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,d,u){var h=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:i,key:h==null?null:""+h,children:c,containerInfo:d,implementation:u}}var o=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function l(c,d){if(c==="font")return"";if(typeof d=="string")return d==="use-credentials"?d:""}return ss.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,ss.createPortal=function(c,d){var u=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!d||d.nodeType!==1&&d.nodeType!==9&&d.nodeType!==11)throw Error(e(299));return s(c,d,null,u)},ss.flushSync=function(c){var d=o.T,u=r.p;try{if(o.T=null,r.p=2,c)return c()}finally{o.T=d,r.p=u,r.d.f()}},ss.preconnect=function(c,d){typeof c=="string"&&(d?(d=d.crossOrigin,d=typeof d=="string"?d==="use-credentials"?d:"":void 0):d=null,r.d.C(c,d))},ss.prefetchDNS=function(c){typeof c=="string"&&r.d.D(c)},ss.preinit=function(c,d){if(typeof c=="string"&&d&&typeof d.as=="string"){var u=d.as,h=l(u,d.crossOrigin),f=typeof d.integrity=="string"?d.integrity:void 0,p=typeof d.fetchPriority=="string"?d.fetchPriority:void 0;u==="style"?r.d.S(c,typeof d.precedence=="string"?d.precedence:void 0,{crossOrigin:h,integrity:f,fetchPriority:p}):u==="script"&&r.d.X(c,{crossOrigin:h,integrity:f,fetchPriority:p,nonce:typeof d.nonce=="string"?d.nonce:void 0})}},ss.preinitModule=function(c,d){if(typeof c=="string")if(typeof d=="object"&&d!==null){if(d.as==null||d.as==="script"){var u=l(d.as,d.crossOrigin);r.d.M(c,{crossOrigin:u,integrity:typeof d.integrity=="string"?d.integrity:void 0,nonce:typeof d.nonce=="string"?d.nonce:void 0})}}else d==null&&r.d.M(c)},ss.preload=function(c,d){if(typeof c=="string"&&typeof d=="object"&&d!==null&&typeof d.as=="string"){var u=d.as,h=l(u,d.crossOrigin);r.d.L(c,u,{crossOrigin:h,integrity:typeof d.integrity=="string"?d.integrity:void 0,nonce:typeof d.nonce=="string"?d.nonce:void 0,type:typeof d.type=="string"?d.type:void 0,fetchPriority:typeof d.fetchPriority=="string"?d.fetchPriority:void 0,referrerPolicy:typeof d.referrerPolicy=="string"?d.referrerPolicy:void 0,imageSrcSet:typeof d.imageSrcSet=="string"?d.imageSrcSet:void 0,imageSizes:typeof d.imageSizes=="string"?d.imageSizes:void 0,media:typeof d.media=="string"?d.media:void 0})}},ss.preloadModule=function(c,d){if(typeof c=="string")if(d){var u=l(d.as,d.crossOrigin);r.d.m(c,{as:typeof d.as=="string"&&d.as!=="script"?d.as:void 0,crossOrigin:u,integrity:typeof d.integrity=="string"?d.integrity:void 0})}else r.d.m(c)},ss.requestFormReset=function(c){r.d.r(c)},ss.unstable_batchedUpdates=function(c,d){return c(d)},ss.useFormState=function(c,d,u){return o.H.useFormState(c,d,u)},ss.useFormStatus=function(){return o.H.useHostTransitionStatus()},ss.version="19.2.4",ss}var KU;function _K(){if(KU)return jM.exports;KU=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(),jM.exports=ble(),jM.exports}var XU;function xle(){if(XU)return Qx;XU=1;var t=gle(),e=zb(),n=_K();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 d(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,T=b;;){var F=S.return;if(F===null)break;var I=F.alternate;if(I===null){if(T=F.return,T!==null){S=T;continue}break}if(F.child===I.child){for(I=F.child;I;){if(I===S)return c(F),m;if(I===T)return c(F),b;I=I.sibling}throw Error(r(188))}if(S.return!==T.return)S=F,T=I;else{for(var ne=!1,Ee=F.child;Ee;){if(Ee===S){ne=!0,S=F,T=I;break}if(Ee===T){ne=!0,T=F,S=I;break}Ee=Ee.sibling}if(!ne){for(Ee=I.child;Ee;){if(Ee===S){ne=!0,S=I,T=F;break}if(Ee===T){ne=!0,T=I,S=F;break}Ee=Ee.sibling}if(!ne)throw Error(r(189))}}if(S.alternate!==T)throw Error(r(190))}if(S.tag!==3)throw Error(r(188));return S.stateNode.current===S?m:b}function u(m){var b=m.tag;if(b===5||b===26||b===27||b===6)return m;for(m=m.child;m!==null;){if(b=u(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"),k=Symbol.for("react.suspense"),P=Symbol.for("react.suspense_list"),C=Symbol.for("react.memo"),j=Symbol.for("react.lazy"),M=Symbol.for("react.activity"),E=Symbol.for("react.memo_cache_sentinel"),B=Symbol.iterator;function L(m){return m===null||typeof m!="object"?null:(m=B&&m[B]||m["@@iterator"],typeof m=="function"?m:null)}var U=Symbol.for("react.client.reference");function D(m){if(m==null)return null;if(typeof m=="function")return m.$$typeof===U?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 k:return"Suspense";case P: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 C:return b=m.displayName||null,b!==null?b:D(m.type)||"Memo";case j:b=m._payload,m=m._init;try{return D(m(b))}catch{}}return null}var $=Array.isArray,q=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,z=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,W={pending:!1,data:null,method:null,action:null},Q=[],te=-1;function H(m){return{current:m}}function X(m){0>te||(m.current=Q[te],Q[te]=null,te--)}function Z(m,b){te++,Q[te]=m.current,m.current=b}var ee=H(null),Se=H(null),oe=H(null),ie=H(null);function me(m,b){switch(Z(oe,b),Z(Se,m),Z(ee,null),b.nodeType){case 9:case 11:m=(m=b.documentElement)&&(m=m.namespaceURI)?dU(m):0;break;default:if(m=b.tagName,b=b.namespaceURI)b=dU(b),m=uU(b,m);else switch(m){case"svg":m=1;break;case"math":m=2;break;default:m=0}}X(ee),Z(ee,m)}function se(){X(ee),X(Se),X(oe)}function ce(m){m.memoizedState!==null&&Z(ie,m);var b=ee.current,S=uU(b,m.type);b!==S&&(Z(Se,m),Z(ee,S))}function Ce(m){Se.current===m&&(X(ee),X(Se)),ie.current===m&&(X(ie),Gx._currentValue=W)}var le,Le;function V(m){if(le===void 0)try{throw Error()}catch(S){var b=S.stack.trim().match(/\n( *(at )?)/);le=b&&b[1]||"",Le=-1<S.stack.indexOf(`
- at`)?" (<anonymous>)":-1<S.stack.indexOf("@")?"@unknown:0:0":""}return`
- `+le+m+Le}var K=!1;function fe(m,b){if(!m||K)return"";K=!0;var S=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var T={DetermineComponentFrameRoot:function(){try{if(b){var Ct=function(){throw Error()};if(Object.defineProperty(Ct.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Ct,[])}catch(xt){var ft=xt}Reflect.construct(m,[],Ct)}else{try{Ct.call()}catch(xt){ft=xt}m.call(Ct.prototype)}}else{try{throw Error()}catch(xt){ft=xt}(Ct=m())&&typeof Ct.catch=="function"&&Ct.catch(function(){})}}catch(xt){if(xt&&ft&&typeof xt.stack=="string")return[xt.stack,ft.stack]}return[null,null]}};T.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var F=Object.getOwnPropertyDescriptor(T.DetermineComponentFrameRoot,"name");F&&F.configurable&&Object.defineProperty(T.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var I=T.DetermineComponentFrameRoot(),ne=I[0],Ee=I[1];if(ne&&Ee){var Ge=ne.split(`
- `),ht=Ee.split(`
- `);for(F=T=0;T<Ge.length&&!Ge[T].includes("DetermineComponentFrameRoot");)T++;for(;F<ht.length&&!ht[F].includes("DetermineComponentFrameRoot");)F++;if(T===Ge.length||F===ht.length)for(T=Ge.length-1,F=ht.length-1;1<=T&&0<=F&&Ge[T]!==ht[F];)F--;for(;1<=T&&0<=F;T--,F--)if(Ge[T]!==ht[F]){if(T!==1||F!==1)do if(T--,F--,0>F||Ge[T]!==ht[F]){var wt=`
- `+Ge[T].replace(" at new "," at ");return m.displayName&&wt.includes("<anonymous>")&&(wt=wt.replace("<anonymous>",m.displayName)),wt}while(1<=T&&0<=F);break}}}finally{K=!1,Error.prepareStackTrace=S}return(S=m?m.displayName||m.name:"")?V(S):""}function Y(m,b){switch(m.tag){case 26:case 27:case 5:return V(m.type);case 16:return V("Lazy");case 13:return m.child!==b&&b!==null?V("Suspense Fallback"):V("Suspense");case 19:return V("SuspenseList");case 0:case 15:return fe(m.type,!1);case 11:return fe(m.type.render,!1);case 1:return fe(m.type,!0);case 31:return V("Activity");default:return""}}function re(m){try{var b="",S=null;do b+=Y(m,S),S=m,m=m.return;while(m);return b}catch(T){return`
- Error generating stack: `+T.message+`
- `+T.stack}}var ue=Object.prototype.hasOwnProperty,Fe=t.unstable_scheduleCallback,Pe=t.unstable_cancelCallback,be=t.unstable_shouldYield,O=t.unstable_requestPaint,R=t.unstable_now,G=t.unstable_getCurrentPriorityLevel,de=t.unstable_ImmediatePriority,ge=t.unstable_UserBlockingPriority,ae=t.unstable_NormalPriority,Ue=t.unstable_LowPriority,ze=t.unstable_IdlePriority,$e=t.log,Re=t.unstable_setDisableYieldValue,pe=null,ve=null;function Ne(m){if(typeof $e=="function"&&Re(m),ve&&typeof ve.setStrictMode=="function")try{ve.setStrictMode(pe,m)}catch{}}var xe=Math.clz32?Math.clz32:ke,we=Math.log,qe=Math.LN2;function ke(m){return m>>>=0,m===0?32:31-(we(m)/qe|0)|0}var nt=256,De=262144,We=4194304;function Oe(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 je(m,b,S){var T=m.pendingLanes;if(T===0)return 0;var F=0,I=m.suspendedLanes,ne=m.pingedLanes;m=m.warmLanes;var Ee=T&134217727;return Ee!==0?(T=Ee&~I,T!==0?F=Oe(T):(ne&=Ee,ne!==0?F=Oe(ne):S||(S=Ee&~m,S!==0&&(F=Oe(S))))):(Ee=T&~I,Ee!==0?F=Oe(Ee):ne!==0?F=Oe(ne):S||(S=T&~m,S!==0&&(F=Oe(S)))),F===0?0:b!==0&&b!==F&&(b&I)===0&&(I=F&-F,S=b&-b,I>=S||I===32&&(S&4194048)!==0)?b:F}function Ve(m,b){return(m.pendingLanes&~(m.suspendedLanes&~m.pingedLanes)&b)===0}function ot(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 kt(){var m=We;return We<<=1,(We&62914560)===0&&(We=4194304),m}function Ft(m){for(var b=[],S=0;31>S;S++)b.push(m);return b}function Vt(m,b){m.pendingLanes|=b,b!==268435456&&(m.suspendedLanes=0,m.pingedLanes=0,m.warmLanes=0)}function At(m,b,S,T,F,I){var ne=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 Ee=m.entanglements,Ge=m.expirationTimes,ht=m.hiddenUpdates;for(S=ne&~S;0<S;){var wt=31-xe(S),Ct=1<<wt;Ee[wt]=0,Ge[wt]=-1;var ft=ht[wt];if(ft!==null)for(ht[wt]=null,wt=0;wt<ft.length;wt++){var xt=ft[wt];xt!==null&&(xt.lane&=-536870913)}S&=~Ct}T!==0&&Be(m,T,0),I!==0&&F===0&&m.tag!==0&&(m.suspendedLanes|=I&~(ne&~b))}function Be(m,b,S){m.pendingLanes|=b,m.suspendedLanes&=~b;var T=31-xe(b);m.entangledLanes|=b,m.entanglements[T]=m.entanglements[T]|1073741824|S&261930}function mt(m,b){var S=m.entangledLanes|=b;for(m=m.entanglements;S;){var T=31-xe(S),F=1<<T;F&b|m[T]&b&&(m[T]|=b),S&=~F}}function yt(m,b){var S=b&-b;return S=(S&42)!==0?1:zt(S),(S&(m.suspendedLanes|b))!==0?0:S}function zt(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 yn(m){return m&=-m,2<m?8<m?(m&134217727)!==0?32:268435456:8:2}function gr(){var m=z.p;return m!==0?m:(m=window.event,m===void 0?32:RU(m.type))}function sr(m,b){var S=z.p;try{return z.p=m,b()}finally{z.p=S}}var nr=Math.random().toString(36).slice(2),Gn="__reactFiber$"+nr,br="__reactProps$"+nr,or="__reactContainer$"+nr,oi="__reactEvents$"+nr,Ie="__reactListeners$"+nr,_e="__reactHandles$"+nr,tt="__reactResources$"+nr,it="__reactMarker$"+nr;function Ke(m){delete m[Gn],delete m[br],delete m[oi],delete m[Ie],delete m[_e]}function Lt(m){var b=m[Gn];if(b)return b;for(var S=m.parentNode;S;){if(b=S[or]||S[Gn]){if(S=b.alternate,b.child!==null||S!==null&&S.child!==null)for(m=xU(m);m!==null;){if(S=m[Gn])return S;m=xU(m)}return b}m=S,S=m.parentNode}return null}function ye(m){if(m=m[Gn]||m[or]){var b=m.tag;if(b===5||b===6||b===13||b===31||b===26||b===27||b===3)return m}return null}function He(m){var b=m.tag;if(b===5||b===26||b===27||b===6)return m.stateNode;throw Error(r(33))}function Ye(m){var b=m[tt];return b||(b=m[tt]={hoistableStyles:new Map,hoistableScripts:new Map}),b}function Xe(m){m[it]=!0}var Te=new Set,ct={};function gt(m,b){lt(m,b),lt(m+"Capture",b)}function lt(m,b){for(ct[m]=b,m=0;m<b.length;m++)Te.add(b[m])}var Tt=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),Bt={},It={};function Pt(m){return ue.call(It,m)?!0:ue.call(Bt,m)?!1:Tt.test(m)?It[m]=!0:(Bt[m]=!0,!1)}function tn(m,b,S){if(Pt(b))if(S===null)m.removeAttribute(b);else{switch(typeof S){case"undefined":case"function":case"symbol":m.removeAttribute(b);return;case"boolean":var T=b.toLowerCase().slice(0,5);if(T!=="data-"&&T!=="aria-"){m.removeAttribute(b);return}}m.setAttribute(b,""+S)}}function en(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 on(m,b,S,T){if(T===null)m.removeAttribute(S);else{switch(typeof T){case"undefined":case"function":case"symbol":case"boolean":m.removeAttribute(S);return}m.setAttributeNS(b,S,""+T)}}function gn(m){switch(typeof m){case"bigint":case"boolean":case"number":case"string":case"undefined":return m;case"object":return m;default:return""}}function Tn(m){var b=m.type;return(m=m.nodeName)&&m.toLowerCase()==="input"&&(b==="checkbox"||b==="radio")}function Zt(m,b,S){var T=Object.getOwnPropertyDescriptor(m.constructor.prototype,b);if(!m.hasOwnProperty(b)&&typeof T<"u"&&typeof T.get=="function"&&typeof T.set=="function"){var F=T.get,I=T.set;return Object.defineProperty(m,b,{configurable:!0,get:function(){return F.call(this)},set:function(ne){S=""+ne,I.call(this,ne)}}),Object.defineProperty(m,b,{enumerable:T.enumerable}),{getValue:function(){return S},setValue:function(ne){S=""+ne},stopTracking:function(){m._valueTracker=null,delete m[b]}}}}function fn(m){if(!m._valueTracker){var b=Tn(m)?"checked":"value";m._valueTracker=Zt(m,b,""+m[b])}}function un(m){if(!m)return!1;var b=m._valueTracker;if(!b)return!0;var S=b.getValue(),T="";return m&&(T=Tn(m)?m.checked?"true":"false":m.value),m=T,m!==S?(b.setValue(m),!0):!1}function qr(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 pn=/[\n"\\]/g;function lr(m){return m.replace(pn,function(b){return"\\"+b.charCodeAt(0).toString(16)+" "})}function as(m,b,S,T,F,I,ne,Ee){m.name="",ne!=null&&typeof ne!="function"&&typeof ne!="symbol"&&typeof ne!="boolean"?m.type=ne:m.removeAttribute("type"),b!=null?ne==="number"?(b===0&&m.value===""||m.value!=b)&&(m.value=""+gn(b)):m.value!==""+gn(b)&&(m.value=""+gn(b)):ne!=="submit"&&ne!=="reset"||m.removeAttribute("value"),b!=null?vr(m,ne,gn(b)):S!=null?vr(m,ne,gn(S)):T!=null&&m.removeAttribute("value"),F==null&&I!=null&&(m.defaultChecked=!!I),F!=null&&(m.checked=F&&typeof F!="function"&&typeof F!="symbol"),Ee!=null&&typeof Ee!="function"&&typeof Ee!="symbol"&&typeof Ee!="boolean"?m.name=""+gn(Ee):m.removeAttribute("name")}function bn(m,b,S,T,F,I,ne,Ee){if(I!=null&&typeof I!="function"&&typeof I!="symbol"&&typeof I!="boolean"&&(m.type=I),b!=null||S!=null){if(!(I!=="submit"&&I!=="reset"||b!=null)){fn(m);return}S=S!=null?""+gn(S):"",b=b!=null?""+gn(b):S,Ee||b===m.value||(m.value=b),m.defaultValue=b}T=T??F,T=typeof T!="function"&&typeof T!="symbol"&&!!T,m.checked=Ee?m.checked:!!T,m.defaultChecked=!!T,ne!=null&&typeof ne!="function"&&typeof ne!="symbol"&&typeof ne!="boolean"&&(m.name=ne),fn(m)}function vr(m,b,S){b==="number"&&qr(m.ownerDocument)===m||m.defaultValue===""+S||(m.defaultValue=""+S)}function Qn(m,b,S,T){if(m=m.options,b){b={};for(var F=0;F<S.length;F++)b["$"+S[F]]=!0;for(S=0;S<m.length;S++)F=b.hasOwnProperty("$"+m[S].value),m[S].selected!==F&&(m[S].selected=F),F&&T&&(m[S].defaultSelected=!0)}else{for(S=""+gn(S),b=null,F=0;F<m.length;F++){if(m[F].value===S){m[F].selected=!0,T&&(m[F].defaultSelected=!0);return}b!==null||m[F].disabled||(b=m[F])}b!==null&&(b.selected=!0)}}function xa(m,b,S){if(b!=null&&(b=""+gn(b),b!==m.value&&(m.value=b),S==null)){m.defaultValue!==b&&(m.defaultValue=b);return}m.defaultValue=S!=null?""+gn(S):""}function Ua(m,b,S,T){if(b==null){if(T!=null){if(S!=null)throw Error(r(92));if($(T)){if(1<T.length)throw Error(r(93));T=T[0]}S=T}S==null&&(S=""),b=S}S=gn(b),m.defaultValue=S,T=m.textContent,T===S&&T!==""&&T!==null&&(m.value=T),fn(m)}function aa(m,b){if(b){var S=m.firstChild;if(S&&S===m.lastChild&&S.nodeType===3){S.nodeValue=b;return}}m.textContent=b}var bt=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 Ot(m,b,S){var T=b.indexOf("--")===0;S==null||typeof S=="boolean"||S===""?T?m.setProperty(b,""):b==="float"?m.cssFloat="":m[b]="":T?m.setProperty(b,S):typeof S!="number"||S===0||bt.has(b)?b==="float"?m.cssFloat=S:m[b]=(""+S).trim():m[b]=S+"px"}function vn(m,b,S){if(b!=null&&typeof b!="object")throw Error(r(62));if(m=m.style,S!=null){for(var T in S)!S.hasOwnProperty(T)||b!=null&&b.hasOwnProperty(T)||(T.indexOf("--")===0?m.setProperty(T,""):T==="float"?m.cssFloat="":m[T]="");for(var F in b)T=b[F],b.hasOwnProperty(F)&&S[F]!==T&&Ot(m,F,T)}else for(var I in b)b.hasOwnProperty(I)&&Ot(m,I,b[I])}function vt(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 Un=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"]]),Qr=/^[\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 Zn(m){return Qr.test(""+m)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":m}function dr(){}var li=null;function rn(m){return m=m.target||m.srcElement||window,m.correspondingUseElement&&(m=m.correspondingUseElement),m.nodeType===3?m.parentNode:m}var Pn=null,Ci=null;function Bs(m){var b=ye(m);if(b&&(m=b.stateNode)){var S=m[br]||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="'+lr(""+b)+'"][type="radio"]'),b=0;b<S.length;b++){var T=S[b];if(T!==m&&T.form===m.form){var F=T[br]||null;if(!F)throw Error(r(90));as(T,F.value,F.defaultValue,F.defaultValue,F.checked,F.defaultChecked,F.type,F.name)}}for(b=0;b<S.length;b++)T=S[b],T.form===m.form&&un(T)}break e;case"textarea":xa(m,S.value,S.defaultValue);break e;case"select":b=S.value,b!=null&&Qn(m,!!S.multiple,b,!1)}}}var zo=!1;function Uo(m,b,S){if(zo)return m(b,S);zo=!0;try{var T=m(b);return T}finally{if(zo=!1,(Pn!==null||Ci!==null)&&(Mw(),Pn&&(b=Pn,m=Ci,Ci=Pn=null,Bs(b),m)))for(b=0;b<m.length;b++)Bs(m[b])}}function zi(m,b){var S=m.stateNode;if(S===null)return null;var T=S[br]||null;if(T===null)return null;S=T[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":(T=!T.disabled)||(m=m.type,T=!(m==="button"||m==="input"||m==="select"||m==="textarea")),m=!T;break e;default:m=!1}if(m)return null;if(S&&typeof S!="function")throw Error(r(231,b,typeof S));return S}var Dr=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Hs=!1;if(Dr)try{var Ca={};Object.defineProperty(Ca,"passive",{get:function(){Hs=!0}}),window.addEventListener("test",Ca,Ca),window.removeEventListener("test",Ca,Ca)}catch{Hs=!1}var Zr=null,is=null,ur=null;function Ui(){if(ur)return ur;var m,b=is,S=b.length,T,F="value"in Zr?Zr.value:Zr.textContent,I=F.length;for(m=0;m<S&&b[m]===F[m];m++);var ne=S-m;for(T=1;T<=ne&&b[S-T]===F[I-T];T++);return ur=F.slice(m,1<T?1-T:void 0)}function Pl(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 Cr(){return!0}function Xt(){return!1}function ya(m){function b(S,T,F,I,ne){this._reactName=S,this._targetInst=F,this.type=T,this.nativeEvent=I,this.target=ne,this.currentTarget=null;for(var Ee in m)m.hasOwnProperty(Ee)&&(S=m[Ee],this[Ee]=S?S(I):I[Ee]);return this.isDefaultPrevented=(I.defaultPrevented!=null?I.defaultPrevented:I.returnValue===!1)?Cr:Xt,this.isPropagationStopped=Xt,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=Cr)},stopPropagation:function(){var S=this.nativeEvent;S&&(S.stopPropagation?S.stopPropagation():typeof S.cancelBubble!="unknown"&&(S.cancelBubble=!0),this.isPropagationStopped=Cr)},persist:function(){},isPersistent:Cr}),b}var $n={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(m){return m.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},kr=ya($n),Yc=h({},$n,{view:0,detail:0}),Wv=ya(Yc),hx,op,he,Et=h({},Yc,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:jA,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!==he&&(he&&m.type==="mousemove"?(hx=m.screenX-he.screenX,op=m.screenY-he.screenY):op=hx=0,he=m),hx)},movementY:function(m){return"movementY"in m?m.movementY:op}}),ua=ya(Et),Jr=h({},Et,{dataTransfer:0}),Qc=ya(Jr),lp=h({},Yc,{relatedTarget:0}),fo=ya(lp),Ns=h({},$n,{animationName:0,elapsedTime:0,pseudoElement:0}),EA=ya(Ns),mI=h({},$n,{clipboardData:function(m){return"clipboardData"in m?m.clipboardData:window.clipboardData}}),pse=ya(mI),gse=h({},$n,{data:0}),fI=ya(gse),bse={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},xse={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"},yse={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function vse(m){var b=this.nativeEvent;return b.getModifierState?b.getModifierState(m):(m=yse[m])?!!b[m]:!1}function jA(){return vse}var wse=h({},Yc,{key:function(m){if(m.key){var b=bse[m.key]||m.key;if(b!=="Unidentified")return b}return m.type==="keypress"?(m=Pl(m),m===13?"Enter":String.fromCharCode(m)):m.type==="keydown"||m.type==="keyup"?xse[m.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:jA,charCode:function(m){return m.type==="keypress"?Pl(m):0},keyCode:function(m){return m.type==="keydown"||m.type==="keyup"?m.keyCode:0},which:function(m){return m.type==="keypress"?Pl(m):m.type==="keydown"||m.type==="keyup"?m.keyCode:0}}),Sse=ya(wse),_se=h({},Et,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),pI=ya(_se),Nse=h({},Yc,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:jA}),Cse=ya(Nse),kse=h({},$n,{propertyName:0,elapsedTime:0,pseudoElement:0}),Ase=ya(kse),Tse=h({},Et,{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}),Mse=ya(Tse),Pse=h({},$n,{newState:0,oldState:0}),Ese=ya(Pse),jse=[9,13,27,32],DA=Dr&&"CompositionEvent"in window,mx=null;Dr&&"documentMode"in document&&(mx=document.documentMode);var Dse=Dr&&"TextEvent"in window&&!mx,gI=Dr&&(!DA||mx&&8<mx&&11>=mx),bI=" ",xI=!1;function yI(m,b){switch(m){case"keyup":return jse.indexOf(b.keyCode)!==-1;case"keydown":return b.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function vI(m){return m=m.detail,typeof m=="object"&&"data"in m?m.data:null}var cp=!1;function Rse(m,b){switch(m){case"compositionend":return vI(b);case"keypress":return b.which!==32?null:(xI=!0,bI);case"textInput":return m=b.data,m===bI&&xI?null:m;default:return null}}function Fse(m,b){if(cp)return m==="compositionend"||!DA&&yI(m,b)?(m=Ui(),ur=is=Zr=null,cp=!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 gI&&b.locale!=="ko"?null:b.data;default:return null}}var Lse={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 wI(m){var b=m&&m.nodeName&&m.nodeName.toLowerCase();return b==="input"?!!Lse[m.type]:b==="textarea"}function SI(m,b,S,T){Pn?Ci?Ci.push(T):Ci=[T]:Pn=T,b=Lw(b,"onChange"),0<b.length&&(S=new kr("onChange","change",null,S,T),m.push({event:S,listeners:b}))}var fx=null,px=null;function Ose(m){aU(m,0)}function Kv(m){var b=He(m);if(un(b))return m}function _I(m,b){if(m==="change")return b}var NI=!1;if(Dr){var RA;if(Dr){var FA="oninput"in document;if(!FA){var CI=document.createElement("div");CI.setAttribute("oninput","return;"),FA=typeof CI.oninput=="function"}RA=FA}else RA=!1;NI=RA&&(!document.documentMode||9<document.documentMode)}function kI(){fx&&(fx.detachEvent("onpropertychange",AI),px=fx=null)}function AI(m){if(m.propertyName==="value"&&Kv(px)){var b=[];SI(b,px,m,rn(m)),Uo(Ose,b)}}function Ise(m,b,S){m==="focusin"?(kI(),fx=b,px=S,fx.attachEvent("onpropertychange",AI)):m==="focusout"&&kI()}function zse(m){if(m==="selectionchange"||m==="keyup"||m==="keydown")return Kv(px)}function Use(m,b){if(m==="click")return Kv(b)}function Bse(m,b){if(m==="input"||m==="change")return Kv(b)}function Hse(m,b){return m===b&&(m!==0||1/m===1/b)||m!==m&&b!==b}var po=typeof Object.is=="function"?Object.is:Hse;function gx(m,b){if(po(m,b))return!0;if(typeof m!="object"||m===null||typeof b!="object"||b===null)return!1;var S=Object.keys(m),T=Object.keys(b);if(S.length!==T.length)return!1;for(T=0;T<S.length;T++){var F=S[T];if(!ue.call(b,F)||!po(m[F],b[F]))return!1}return!0}function TI(m){for(;m&&m.firstChild;)m=m.firstChild;return m}function MI(m,b){var S=TI(m);m=0;for(var T;S;){if(S.nodeType===3){if(T=m+S.textContent.length,m<=b&&T>=b)return{node:S,offset:b-m};m=T}e:{for(;S;){if(S.nextSibling){S=S.nextSibling;break e}S=S.parentNode}S=void 0}S=TI(S)}}function PI(m,b){return m&&b?m===b?!0:m&&m.nodeType===3?!1:b&&b.nodeType===3?PI(m,b.parentNode):"contains"in m?m.contains(b):m.compareDocumentPosition?!!(m.compareDocumentPosition(b)&16):!1:!1}function EI(m){m=m!=null&&m.ownerDocument!=null&&m.ownerDocument.defaultView!=null?m.ownerDocument.defaultView:window;for(var b=qr(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=qr(m.document)}return b}function LA(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 $se=Dr&&"documentMode"in document&&11>=document.documentMode,dp=null,OA=null,bx=null,IA=!1;function jI(m,b,S){var T=S.window===S?S.document:S.nodeType===9?S:S.ownerDocument;IA||dp==null||dp!==qr(T)||(T=dp,"selectionStart"in T&&LA(T)?T={start:T.selectionStart,end:T.selectionEnd}:(T=(T.ownerDocument&&T.ownerDocument.defaultView||window).getSelection(),T={anchorNode:T.anchorNode,anchorOffset:T.anchorOffset,focusNode:T.focusNode,focusOffset:T.focusOffset}),bx&&gx(bx,T)||(bx=T,T=Lw(OA,"onSelect"),0<T.length&&(b=new kr("onSelect","select",null,b,S),m.push({event:b,listeners:T}),b.target=dp)))}function hm(m,b){var S={};return S[m.toLowerCase()]=b.toLowerCase(),S["Webkit"+m]="webkit"+b,S["Moz"+m]="moz"+b,S}var up={animationend:hm("Animation","AnimationEnd"),animationiteration:hm("Animation","AnimationIteration"),animationstart:hm("Animation","AnimationStart"),transitionrun:hm("Transition","TransitionRun"),transitionstart:hm("Transition","TransitionStart"),transitioncancel:hm("Transition","TransitionCancel"),transitionend:hm("Transition","TransitionEnd")},zA={},DI={};Dr&&(DI=document.createElement("div").style,"AnimationEvent"in window||(delete up.animationend.animation,delete up.animationiteration.animation,delete up.animationstart.animation),"TransitionEvent"in window||delete up.transitionend.transition);function mm(m){if(zA[m])return zA[m];if(!up[m])return m;var b=up[m],S;for(S in b)if(b.hasOwnProperty(S)&&S in DI)return zA[m]=b[S];return m}var RI=mm("animationend"),FI=mm("animationiteration"),LI=mm("animationstart"),Vse=mm("transitionrun"),qse=mm("transitionstart"),Gse=mm("transitioncancel"),OI=mm("transitionend"),II=new Map,UA="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(" ");UA.push("scrollEnd");function El(m,b){II.set(m,b),gt(b,[m])}var Xv=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)},Bo=[],hp=0,BA=0;function Yv(){for(var m=hp,b=BA=hp=0;b<m;){var S=Bo[b];Bo[b++]=null;var T=Bo[b];Bo[b++]=null;var F=Bo[b];Bo[b++]=null;var I=Bo[b];if(Bo[b++]=null,T!==null&&F!==null){var ne=T.pending;ne===null?F.next=F:(F.next=ne.next,ne.next=F),T.pending=F}I!==0&&zI(S,F,I)}}function Qv(m,b,S,T){Bo[hp++]=m,Bo[hp++]=b,Bo[hp++]=S,Bo[hp++]=T,BA|=T,m.lanes|=T,m=m.alternate,m!==null&&(m.lanes|=T)}function HA(m,b,S,T){return Qv(m,b,S,T),Zv(m)}function fm(m,b){return Qv(m,null,null,b),Zv(m)}function zI(m,b,S){m.lanes|=S;var T=m.alternate;T!==null&&(T.lanes|=S);for(var F=!1,I=m.return;I!==null;)I.childLanes|=S,T=I.alternate,T!==null&&(T.childLanes|=S),I.tag===22&&(m=I.stateNode,m===null||m._visibility&1||(F=!0)),m=I,I=I.return;return m.tag===3?(I=m.stateNode,F&&b!==null&&(F=31-xe(S),m=I.hiddenUpdates,T=m[F],T===null?m[F]=[b]:T.push(b),b.lane=S|536870912),I):null}function Zv(m){if(50<zx)throw zx=0,QT=null,Error(r(185));for(var b=m.return;b!==null;)m=b,b=m.return;return m.tag===3?m.stateNode:null}var mp={};function Wse(m,b,S,T){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=T,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function go(m,b,S,T){return new Wse(m,b,S,T)}function $A(m){return m=m.prototype,!(!m||!m.isReactComponent)}function Zc(m,b){var S=m.alternate;return S===null?(S=go(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 UI(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 Jv(m,b,S,T,F,I){var ne=0;if(T=m,typeof m=="function")$A(m)&&(ne=1);else if(typeof m=="string")ne=Zoe(m,S,ee.current)?26:m==="html"||m==="head"||m==="body"?27:5;else e:switch(m){case M:return m=go(31,S,b,F),m.elementType=M,m.lanes=I,m;case v:return pm(S.children,F,I,b);case g:ne=8,F|=24;break;case y:return m=go(12,S,b,F|2),m.elementType=y,m.lanes=I,m;case k:return m=go(13,S,b,F),m.elementType=k,m.lanes=I,m;case P:return m=go(19,S,b,F),m.elementType=P,m.lanes=I,m;default:if(typeof m=="object"&&m!==null)switch(m.$$typeof){case N:ne=10;break e;case _:ne=9;break e;case A:ne=11;break e;case C:ne=14;break e;case j:ne=16,T=null;break e}ne=29,S=Error(r(130,m===null?"null":typeof m,"")),T=null}return b=go(ne,S,b,F),b.elementType=m,b.type=T,b.lanes=I,b}function pm(m,b,S,T){return m=go(7,m,T,b),m.lanes=S,m}function VA(m,b,S){return m=go(6,m,null,b),m.lanes=S,m}function BI(m){var b=go(18,null,null,0);return b.stateNode=m,b}function qA(m,b,S){return b=go(4,m.children!==null?m.children:[],m.key,b),b.lanes=S,b.stateNode={containerInfo:m.containerInfo,pendingChildren:null,implementation:m.implementation},b}var HI=new WeakMap;function Ho(m,b){if(typeof m=="object"&&m!==null){var S=HI.get(m);return S!==void 0?S:(b={value:m,source:b,stack:re(b)},HI.set(m,b),b)}return{value:m,source:b,stack:re(b)}}var fp=[],pp=0,ew=null,xx=0,$o=[],Vo=0,wu=null,lc=1,cc="";function Jc(m,b){fp[pp++]=xx,fp[pp++]=ew,ew=m,xx=b}function $I(m,b,S){$o[Vo++]=lc,$o[Vo++]=cc,$o[Vo++]=wu,wu=m;var T=lc;m=cc;var F=32-xe(T)-1;T&=~(1<<F),S+=1;var I=32-xe(b)+F;if(30<I){var ne=F-F%5;I=(T&(1<<ne)-1).toString(32),T>>=ne,F-=ne,lc=1<<32-xe(b)+F|S<<F|T,cc=I+m}else lc=1<<I|S<<F|T,cc=m}function GA(m){m.return!==null&&(Jc(m,1),$I(m,1,0))}function WA(m){for(;m===ew;)ew=fp[--pp],fp[pp]=null,xx=fp[--pp],fp[pp]=null;for(;m===wu;)wu=$o[--Vo],$o[Vo]=null,cc=$o[--Vo],$o[Vo]=null,lc=$o[--Vo],$o[Vo]=null}function VI(m,b){$o[Vo++]=lc,$o[Vo++]=cc,$o[Vo++]=wu,lc=b.id,cc=b.overflow,wu=m}var Bi=null,ia=null,rr=!1,Su=null,qo=!1,KA=Error(r(519));function _u(m){var b=Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw yx(Ho(b,m)),KA}function qI(m){var b=m.stateNode,S=m.type,T=m.memoizedProps;switch(b[Gn]=m,b[br]=T,S){case"dialog":Kn("cancel",b),Kn("close",b);break;case"iframe":case"object":case"embed":Kn("load",b);break;case"video":case"audio":for(S=0;S<Bx.length;S++)Kn(Bx[S],b);break;case"source":Kn("error",b);break;case"img":case"image":case"link":Kn("error",b),Kn("load",b);break;case"details":Kn("toggle",b);break;case"input":Kn("invalid",b),bn(b,T.value,T.defaultValue,T.checked,T.defaultChecked,T.type,T.name,!0);break;case"select":Kn("invalid",b);break;case"textarea":Kn("invalid",b),Ua(b,T.value,T.defaultValue,T.children)}S=T.children,typeof S!="string"&&typeof S!="number"&&typeof S!="bigint"||b.textContent===""+S||T.suppressHydrationWarning===!0||lU(b.textContent,S)?(T.popover!=null&&(Kn("beforetoggle",b),Kn("toggle",b)),T.onScroll!=null&&Kn("scroll",b),T.onScrollEnd!=null&&Kn("scrollend",b),T.onClick!=null&&(b.onclick=dr),b=!0):b=!1,b||_u(m,!0)}function GI(m){for(Bi=m.return;Bi;)switch(Bi.tag){case 5:case 31:case 13:qo=!1;return;case 27:case 3:qo=!0;return;default:Bi=Bi.return}}function gp(m){if(m!==Bi)return!1;if(!rr)return GI(m),rr=!0,!1;var b=m.tag,S;if((S=b!==3&&b!==27)&&((S=b===5)&&(S=m.type,S=!(S!=="form"&&S!=="button")||hM(m.type,m.memoizedProps)),S=!S),S&&ia&&_u(m),GI(m),b===13){if(m=m.memoizedState,m=m!==null?m.dehydrated:null,!m)throw Error(r(317));ia=bU(m)}else if(b===31){if(m=m.memoizedState,m=m!==null?m.dehydrated:null,!m)throw Error(r(317));ia=bU(m)}else b===27?(b=ia,Ou(m.type)?(m=bM,bM=null,ia=m):ia=b):ia=Bi?Wo(m.stateNode.nextSibling):null;return!0}function gm(){ia=Bi=null,rr=!1}function XA(){var m=Su;return m!==null&&(Gs===null?Gs=m:Gs.push.apply(Gs,m),Su=null),m}function yx(m){Su===null?Su=[m]:Su.push(m)}var YA=H(null),bm=null,ed=null;function Nu(m,b,S){Z(YA,b._currentValue),b._currentValue=S}function td(m){m._currentValue=YA.current,X(YA)}function QA(m,b,S){for(;m!==null;){var T=m.alternate;if((m.childLanes&b)!==b?(m.childLanes|=b,T!==null&&(T.childLanes|=b)):T!==null&&(T.childLanes&b)!==b&&(T.childLanes|=b),m===S)break;m=m.return}}function ZA(m,b,S,T){var F=m.child;for(F!==null&&(F.return=m);F!==null;){var I=F.dependencies;if(I!==null){var ne=F.child;I=I.firstContext;e:for(;I!==null;){var Ee=I;I=F;for(var Ge=0;Ge<b.length;Ge++)if(Ee.context===b[Ge]){I.lanes|=S,Ee=I.alternate,Ee!==null&&(Ee.lanes|=S),QA(I.return,S,m),T||(ne=null);break e}I=Ee.next}}else if(F.tag===18){if(ne=F.return,ne===null)throw Error(r(341));ne.lanes|=S,I=ne.alternate,I!==null&&(I.lanes|=S),QA(ne,S,m),ne=null}else ne=F.child;if(ne!==null)ne.return=F;else for(ne=F;ne!==null;){if(ne===m){ne=null;break}if(F=ne.sibling,F!==null){F.return=ne.return,ne=F;break}ne=ne.return}F=ne}}function bp(m,b,S,T){m=null;for(var F=b,I=!1;F!==null;){if(!I){if((F.flags&524288)!==0)I=!0;else if((F.flags&262144)!==0)break}if(F.tag===10){var ne=F.alternate;if(ne===null)throw Error(r(387));if(ne=ne.memoizedProps,ne!==null){var Ee=F.type;po(F.pendingProps.value,ne.value)||(m!==null?m.push(Ee):m=[Ee])}}else if(F===ie.current){if(ne=F.alternate,ne===null)throw Error(r(387));ne.memoizedState.memoizedState!==F.memoizedState.memoizedState&&(m!==null?m.push(Gx):m=[Gx])}F=F.return}m!==null&&ZA(b,m,S,T),b.flags|=262144}function tw(m){for(m=m.firstContext;m!==null;){if(!po(m.context._currentValue,m.memoizedValue))return!0;m=m.next}return!1}function xm(m){bm=m,ed=null,m=m.dependencies,m!==null&&(m.firstContext=null)}function Hi(m){return WI(bm,m)}function nw(m,b){return bm===null&&xm(m),WI(m,b)}function WI(m,b){var S=b._currentValue;if(b={context:b,memoizedValue:S,next:null},ed===null){if(m===null)throw Error(r(308));ed=b,m.dependencies={lanes:0,firstContext:b},m.flags|=524288}else ed=ed.next=b;return S}var Kse=typeof AbortController<"u"?AbortController:function(){var m=[],b=this.signal={aborted:!1,addEventListener:function(S,T){m.push(T)}};this.abort=function(){b.aborted=!0,m.forEach(function(S){return S()})}},Xse=t.unstable_scheduleCallback,Yse=t.unstable_NormalPriority,Wa={$$typeof:N,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function JA(){return{controller:new Kse,data:new Map,refCount:0}}function vx(m){m.refCount--,m.refCount===0&&Xse(Yse,function(){m.controller.abort()})}var wx=null,eT=0,xp=0,yp=null;function Qse(m,b){if(wx===null){var S=wx=[];eT=0,xp=rM(),yp={status:"pending",value:void 0,then:function(T){S.push(T)}}}return eT++,b.then(KI,KI),b}function KI(){if(--eT===0&&wx!==null){yp!==null&&(yp.status="fulfilled");var m=wx;wx=null,xp=0,yp=null;for(var b=0;b<m.length;b++)(0,m[b])()}}function Zse(m,b){var S=[],T={status:"pending",value:null,reason:null,then:function(F){S.push(F)}};return m.then(function(){T.status="fulfilled",T.value=b;for(var F=0;F<S.length;F++)(0,S[F])(b)},function(F){for(T.status="rejected",T.reason=F,F=0;F<S.length;F++)(0,S[F])(void 0)}),T}var XI=q.S;q.S=function(m,b){jz=R(),typeof b=="object"&&b!==null&&typeof b.then=="function"&&Qse(m,b),XI!==null&&XI(m,b)};var ym=H(null);function tT(){var m=ym.current;return m!==null?m:Gr.pooledCache}function rw(m,b){b===null?Z(ym,ym.current):Z(ym,b.pool)}function YI(){var m=tT();return m===null?null:{parent:Wa._currentValue,pool:m}}var vp=Error(r(460)),nT=Error(r(474)),aw=Error(r(542)),iw={then:function(){}};function QI(m){return m=m.status,m==="fulfilled"||m==="rejected"}function ZI(m,b,S){switch(S=m[S],S===void 0?m.push(b):S!==b&&(b.then(dr,dr),b=S),b.status){case"fulfilled":return b.value;case"rejected":throw m=b.reason,e5(m),m;default:if(typeof b.status=="string")b.then(dr,dr);else{if(m=Gr,m!==null&&100<m.shellSuspendCounter)throw Error(r(482));m=b,m.status="pending",m.then(function(T){if(b.status==="pending"){var F=b;F.status="fulfilled",F.value=T}},function(T){if(b.status==="pending"){var F=b;F.status="rejected",F.reason=T}})}switch(b.status){case"fulfilled":return b.value;case"rejected":throw m=b.reason,e5(m),m}throw wm=b,vp}}function vm(m){try{var b=m._init;return b(m._payload)}catch(S){throw S!==null&&typeof S=="object"&&typeof S.then=="function"?(wm=S,vp):S}}var wm=null;function JI(){if(wm===null)throw Error(r(459));var m=wm;return wm=null,m}function e5(m){if(m===vp||m===aw)throw Error(r(483))}var wp=null,Sx=0;function sw(m){var b=Sx;return Sx+=1,wp===null&&(wp=[]),ZI(wp,m,b)}function _x(m,b){b=b.props.ref,m.ref=b!==void 0?b:null}function ow(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 t5(m){function b(rt,Qe){if(m){var ut=rt.deletions;ut===null?(rt.deletions=[Qe],rt.flags|=16):ut.push(Qe)}}function S(rt,Qe){if(!m)return null;for(;Qe!==null;)b(rt,Qe),Qe=Qe.sibling;return null}function T(rt){for(var Qe=new Map;rt!==null;)rt.key!==null?Qe.set(rt.key,rt):Qe.set(rt.index,rt),rt=rt.sibling;return Qe}function F(rt,Qe){return rt=Zc(rt,Qe),rt.index=0,rt.sibling=null,rt}function I(rt,Qe,ut){return rt.index=ut,m?(ut=rt.alternate,ut!==null?(ut=ut.index,ut<Qe?(rt.flags|=67108866,Qe):ut):(rt.flags|=67108866,Qe)):(rt.flags|=1048576,Qe)}function ne(rt){return m&&rt.alternate===null&&(rt.flags|=67108866),rt}function Ee(rt,Qe,ut,_t){return Qe===null||Qe.tag!==6?(Qe=VA(ut,rt.mode,_t),Qe.return=rt,Qe):(Qe=F(Qe,ut),Qe.return=rt,Qe)}function Ge(rt,Qe,ut,_t){var sn=ut.type;return sn===v?wt(rt,Qe,ut.props.children,_t,ut.key):Qe!==null&&(Qe.elementType===sn||typeof sn=="object"&&sn!==null&&sn.$$typeof===j&&vm(sn)===Qe.type)?(Qe=F(Qe,ut.props),_x(Qe,ut),Qe.return=rt,Qe):(Qe=Jv(ut.type,ut.key,ut.props,null,rt.mode,_t),_x(Qe,ut),Qe.return=rt,Qe)}function ht(rt,Qe,ut,_t){return Qe===null||Qe.tag!==4||Qe.stateNode.containerInfo!==ut.containerInfo||Qe.stateNode.implementation!==ut.implementation?(Qe=qA(ut,rt.mode,_t),Qe.return=rt,Qe):(Qe=F(Qe,ut.children||[]),Qe.return=rt,Qe)}function wt(rt,Qe,ut,_t,sn){return Qe===null||Qe.tag!==7?(Qe=pm(ut,rt.mode,_t,sn),Qe.return=rt,Qe):(Qe=F(Qe,ut),Qe.return=rt,Qe)}function Ct(rt,Qe,ut){if(typeof Qe=="string"&&Qe!==""||typeof Qe=="number"||typeof Qe=="bigint")return Qe=VA(""+Qe,rt.mode,ut),Qe.return=rt,Qe;if(typeof Qe=="object"&&Qe!==null){switch(Qe.$$typeof){case p:return ut=Jv(Qe.type,Qe.key,Qe.props,null,rt.mode,ut),_x(ut,Qe),ut.return=rt,ut;case x:return Qe=qA(Qe,rt.mode,ut),Qe.return=rt,Qe;case j:return Qe=vm(Qe),Ct(rt,Qe,ut)}if($(Qe)||L(Qe))return Qe=pm(Qe,rt.mode,ut,null),Qe.return=rt,Qe;if(typeof Qe.then=="function")return Ct(rt,sw(Qe),ut);if(Qe.$$typeof===N)return Ct(rt,nw(rt,Qe),ut);ow(rt,Qe)}return null}function ft(rt,Qe,ut,_t){var sn=Qe!==null?Qe.key:null;if(typeof ut=="string"&&ut!==""||typeof ut=="number"||typeof ut=="bigint")return sn!==null?null:Ee(rt,Qe,""+ut,_t);if(typeof ut=="object"&&ut!==null){switch(ut.$$typeof){case p:return ut.key===sn?Ge(rt,Qe,ut,_t):null;case x:return ut.key===sn?ht(rt,Qe,ut,_t):null;case j:return ut=vm(ut),ft(rt,Qe,ut,_t)}if($(ut)||L(ut))return sn!==null?null:wt(rt,Qe,ut,_t,null);if(typeof ut.then=="function")return ft(rt,Qe,sw(ut),_t);if(ut.$$typeof===N)return ft(rt,Qe,nw(rt,ut),_t);ow(rt,ut)}return null}function xt(rt,Qe,ut,_t,sn){if(typeof _t=="string"&&_t!==""||typeof _t=="number"||typeof _t=="bigint")return rt=rt.get(ut)||null,Ee(Qe,rt,""+_t,sn);if(typeof _t=="object"&&_t!==null){switch(_t.$$typeof){case p:return rt=rt.get(_t.key===null?ut:_t.key)||null,Ge(Qe,rt,_t,sn);case x:return rt=rt.get(_t.key===null?ut:_t.key)||null,ht(Qe,rt,_t,sn);case j:return _t=vm(_t),xt(rt,Qe,ut,_t,sn)}if($(_t)||L(_t))return rt=rt.get(ut)||null,wt(Qe,rt,_t,sn,null);if(typeof _t.then=="function")return xt(rt,Qe,ut,sw(_t),sn);if(_t.$$typeof===N)return xt(rt,Qe,ut,nw(Qe,_t),sn);ow(Qe,_t)}return null}function Kt(rt,Qe,ut,_t){for(var sn=null,hr=null,Jt=Qe,jn=Qe=0,er=null;Jt!==null&&jn<ut.length;jn++){Jt.index>jn?(er=Jt,Jt=null):er=Jt.sibling;var mr=ft(rt,Jt,ut[jn],_t);if(mr===null){Jt===null&&(Jt=er);break}m&&Jt&&mr.alternate===null&&b(rt,Jt),Qe=I(mr,Qe,jn),hr===null?sn=mr:hr.sibling=mr,hr=mr,Jt=er}if(jn===ut.length)return S(rt,Jt),rr&&Jc(rt,jn),sn;if(Jt===null){for(;jn<ut.length;jn++)Jt=Ct(rt,ut[jn],_t),Jt!==null&&(Qe=I(Jt,Qe,jn),hr===null?sn=Jt:hr.sibling=Jt,hr=Jt);return rr&&Jc(rt,jn),sn}for(Jt=T(Jt);jn<ut.length;jn++)er=xt(Jt,rt,jn,ut[jn],_t),er!==null&&(m&&er.alternate!==null&&Jt.delete(er.key===null?jn:er.key),Qe=I(er,Qe,jn),hr===null?sn=er:hr.sibling=er,hr=er);return m&&Jt.forEach(function(Hu){return b(rt,Hu)}),rr&&Jc(rt,jn),sn}function mn(rt,Qe,ut,_t){if(ut==null)throw Error(r(151));for(var sn=null,hr=null,Jt=Qe,jn=Qe=0,er=null,mr=ut.next();Jt!==null&&!mr.done;jn++,mr=ut.next()){Jt.index>jn?(er=Jt,Jt=null):er=Jt.sibling;var Hu=ft(rt,Jt,mr.value,_t);if(Hu===null){Jt===null&&(Jt=er);break}m&&Jt&&Hu.alternate===null&&b(rt,Jt),Qe=I(Hu,Qe,jn),hr===null?sn=Hu:hr.sibling=Hu,hr=Hu,Jt=er}if(mr.done)return S(rt,Jt),rr&&Jc(rt,jn),sn;if(Jt===null){for(;!mr.done;jn++,mr=ut.next())mr=Ct(rt,mr.value,_t),mr!==null&&(Qe=I(mr,Qe,jn),hr===null?sn=mr:hr.sibling=mr,hr=mr);return rr&&Jc(rt,jn),sn}for(Jt=T(Jt);!mr.done;jn++,mr=ut.next())mr=xt(Jt,rt,jn,mr.value,_t),mr!==null&&(m&&mr.alternate!==null&&Jt.delete(mr.key===null?jn:mr.key),Qe=I(mr,Qe,jn),hr===null?sn=mr:hr.sibling=mr,hr=mr);return m&&Jt.forEach(function(cle){return b(rt,cle)}),rr&&Jc(rt,jn),sn}function Lr(rt,Qe,ut,_t){if(typeof ut=="object"&&ut!==null&&ut.type===v&&ut.key===null&&(ut=ut.props.children),typeof ut=="object"&&ut!==null){switch(ut.$$typeof){case p:e:{for(var sn=ut.key;Qe!==null;){if(Qe.key===sn){if(sn=ut.type,sn===v){if(Qe.tag===7){S(rt,Qe.sibling),_t=F(Qe,ut.props.children),_t.return=rt,rt=_t;break e}}else if(Qe.elementType===sn||typeof sn=="object"&&sn!==null&&sn.$$typeof===j&&vm(sn)===Qe.type){S(rt,Qe.sibling),_t=F(Qe,ut.props),_x(_t,ut),_t.return=rt,rt=_t;break e}S(rt,Qe);break}else b(rt,Qe);Qe=Qe.sibling}ut.type===v?(_t=pm(ut.props.children,rt.mode,_t,ut.key),_t.return=rt,rt=_t):(_t=Jv(ut.type,ut.key,ut.props,null,rt.mode,_t),_x(_t,ut),_t.return=rt,rt=_t)}return ne(rt);case x:e:{for(sn=ut.key;Qe!==null;){if(Qe.key===sn)if(Qe.tag===4&&Qe.stateNode.containerInfo===ut.containerInfo&&Qe.stateNode.implementation===ut.implementation){S(rt,Qe.sibling),_t=F(Qe,ut.children||[]),_t.return=rt,rt=_t;break e}else{S(rt,Qe);break}else b(rt,Qe);Qe=Qe.sibling}_t=qA(ut,rt.mode,_t),_t.return=rt,rt=_t}return ne(rt);case j:return ut=vm(ut),Lr(rt,Qe,ut,_t)}if($(ut))return Kt(rt,Qe,ut,_t);if(L(ut)){if(sn=L(ut),typeof sn!="function")throw Error(r(150));return ut=sn.call(ut),mn(rt,Qe,ut,_t)}if(typeof ut.then=="function")return Lr(rt,Qe,sw(ut),_t);if(ut.$$typeof===N)return Lr(rt,Qe,nw(rt,ut),_t);ow(rt,ut)}return typeof ut=="string"&&ut!==""||typeof ut=="number"||typeof ut=="bigint"?(ut=""+ut,Qe!==null&&Qe.tag===6?(S(rt,Qe.sibling),_t=F(Qe,ut),_t.return=rt,rt=_t):(S(rt,Qe),_t=VA(ut,rt.mode,_t),_t.return=rt,rt=_t),ne(rt)):S(rt,Qe)}return function(rt,Qe,ut,_t){try{Sx=0;var sn=Lr(rt,Qe,ut,_t);return wp=null,sn}catch(Jt){if(Jt===vp||Jt===aw)throw Jt;var hr=go(29,Jt,null,rt.mode);return hr.lanes=_t,hr.return=rt,hr}}}var Sm=t5(!0),n5=t5(!1),Cu=!1;function rT(m){m.updateQueue={baseState:m.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function aT(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 ku(m){return{lane:m,tag:0,payload:null,callback:null,next:null}}function Au(m,b,S){var T=m.updateQueue;if(T===null)return null;if(T=T.shared,(xr&2)!==0){var F=T.pending;return F===null?b.next=b:(b.next=F.next,F.next=b),T.pending=b,b=Zv(m),zI(m,null,S),b}return Qv(m,T,b,S),Zv(m)}function Nx(m,b,S){if(b=b.updateQueue,b!==null&&(b=b.shared,(S&4194048)!==0)){var T=b.lanes;T&=m.pendingLanes,S|=T,b.lanes=S,mt(m,S)}}function iT(m,b){var S=m.updateQueue,T=m.alternate;if(T!==null&&(T=T.updateQueue,S===T)){var F=null,I=null;if(S=S.firstBaseUpdate,S!==null){do{var ne={lane:S.lane,tag:S.tag,payload:S.payload,callback:null,next:null};I===null?F=I=ne:I=I.next=ne,S=S.next}while(S!==null);I===null?F=I=b:I=I.next=b}else F=I=b;S={baseState:T.baseState,firstBaseUpdate:F,lastBaseUpdate:I,shared:T.shared,callbacks:T.callbacks},m.updateQueue=S;return}m=S.lastBaseUpdate,m===null?S.firstBaseUpdate=b:m.next=b,S.lastBaseUpdate=b}var sT=!1;function Cx(){if(sT){var m=yp;if(m!==null)throw m}}function kx(m,b,S,T){sT=!1;var F=m.updateQueue;Cu=!1;var I=F.firstBaseUpdate,ne=F.lastBaseUpdate,Ee=F.shared.pending;if(Ee!==null){F.shared.pending=null;var Ge=Ee,ht=Ge.next;Ge.next=null,ne===null?I=ht:ne.next=ht,ne=Ge;var wt=m.alternate;wt!==null&&(wt=wt.updateQueue,Ee=wt.lastBaseUpdate,Ee!==ne&&(Ee===null?wt.firstBaseUpdate=ht:Ee.next=ht,wt.lastBaseUpdate=Ge))}if(I!==null){var Ct=F.baseState;ne=0,wt=ht=Ge=null,Ee=I;do{var ft=Ee.lane&-536870913,xt=ft!==Ee.lane;if(xt?(Jn&ft)===ft:(T&ft)===ft){ft!==0&&ft===xp&&(sT=!0),wt!==null&&(wt=wt.next={lane:0,tag:Ee.tag,payload:Ee.payload,callback:null,next:null});e:{var Kt=m,mn=Ee;ft=b;var Lr=S;switch(mn.tag){case 1:if(Kt=mn.payload,typeof Kt=="function"){Ct=Kt.call(Lr,Ct,ft);break e}Ct=Kt;break e;case 3:Kt.flags=Kt.flags&-65537|128;case 0:if(Kt=mn.payload,ft=typeof Kt=="function"?Kt.call(Lr,Ct,ft):Kt,ft==null)break e;Ct=h({},Ct,ft);break e;case 2:Cu=!0}}ft=Ee.callback,ft!==null&&(m.flags|=64,xt&&(m.flags|=8192),xt=F.callbacks,xt===null?F.callbacks=[ft]:xt.push(ft))}else xt={lane:ft,tag:Ee.tag,payload:Ee.payload,callback:Ee.callback,next:null},wt===null?(ht=wt=xt,Ge=Ct):wt=wt.next=xt,ne|=ft;if(Ee=Ee.next,Ee===null){if(Ee=F.shared.pending,Ee===null)break;xt=Ee,Ee=xt.next,xt.next=null,F.lastBaseUpdate=xt,F.shared.pending=null}}while(!0);wt===null&&(Ge=Ct),F.baseState=Ge,F.firstBaseUpdate=ht,F.lastBaseUpdate=wt,I===null&&(F.shared.lanes=0),ju|=ne,m.lanes=ne,m.memoizedState=Ct}}function r5(m,b){if(typeof m!="function")throw Error(r(191,m));m.call(b)}function a5(m,b){var S=m.callbacks;if(S!==null)for(m.callbacks=null,m=0;m<S.length;m++)r5(S[m],b)}var Sp=H(null),lw=H(0);function i5(m,b){m=dd,Z(lw,m),Z(Sp,b),dd=m|b.baseLanes}function oT(){Z(lw,dd),Z(Sp,Sp.current)}function lT(){dd=lw.current,X(Sp),X(lw)}var bo=H(null),Go=null;function Tu(m){var b=m.alternate;Z(Ba,Ba.current&1),Z(bo,m),Go===null&&(b===null||Sp.current!==null||b.memoizedState!==null)&&(Go=m)}function cT(m){Z(Ba,Ba.current),Z(bo,m),Go===null&&(Go=m)}function s5(m){m.tag===22?(Z(Ba,Ba.current),Z(bo,m),Go===null&&(Go=m)):Mu()}function Mu(){Z(Ba,Ba.current),Z(bo,bo.current)}function xo(m){X(bo),Go===m&&(Go=null),X(Ba)}var Ba=H(0);function cw(m){for(var b=m;b!==null;){if(b.tag===13){var S=b.memoizedState;if(S!==null&&(S=S.dehydrated,S===null||pM(S)||gM(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 nd=0,En=null,Rr=null,Ka=null,dw=!1,_p=!1,_m=!1,uw=0,Ax=0,Np=null,Jse=0;function ka(){throw Error(r(321))}function dT(m,b){if(b===null)return!1;for(var S=0;S<b.length&&S<m.length;S++)if(!po(m[S],b[S]))return!1;return!0}function uT(m,b,S,T,F,I){return nd=I,En=b,b.memoizedState=null,b.updateQueue=null,b.lanes=0,q.H=m===null||m.memoizedState===null?$5:kT,_m=!1,I=S(T,F),_m=!1,_p&&(I=l5(b,S,T,F)),o5(m),I}function o5(m){q.H=Px;var b=Rr!==null&&Rr.next!==null;if(nd=0,Ka=Rr=En=null,dw=!1,Ax=0,Np=null,b)throw Error(r(300));m===null||Xa||(m=m.dependencies,m!==null&&tw(m)&&(Xa=!0))}function l5(m,b,S,T){En=m;var F=0;do{if(_p&&(Np=null),Ax=0,_p=!1,25<=F)throw Error(r(301));if(F+=1,Ka=Rr=null,m.updateQueue!=null){var I=m.updateQueue;I.lastEffect=null,I.events=null,I.stores=null,I.memoCache!=null&&(I.memoCache.index=0)}q.H=V5,I=b(S,T)}while(_p);return I}function eoe(){var m=q.H,b=m.useState()[0];return b=typeof b.then=="function"?Tx(b):b,m=m.useState()[0],(Rr!==null?Rr.memoizedState:null)!==m&&(En.flags|=1024),b}function hT(){var m=uw!==0;return uw=0,m}function mT(m,b,S){b.updateQueue=m.updateQueue,b.flags&=-2053,m.lanes&=~S}function fT(m){if(dw){for(m=m.memoizedState;m!==null;){var b=m.queue;b!==null&&(b.pending=null),m=m.next}dw=!1}nd=0,Ka=Rr=En=null,_p=!1,Ax=uw=0,Np=null}function Cs(){var m={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Ka===null?En.memoizedState=Ka=m:Ka=Ka.next=m,Ka}function Ha(){if(Rr===null){var m=En.alternate;m=m!==null?m.memoizedState:null}else m=Rr.next;var b=Ka===null?En.memoizedState:Ka.next;if(b!==null)Ka=b,Rr=m;else{if(m===null)throw En.alternate===null?Error(r(467)):Error(r(310));Rr=m,m={memoizedState:Rr.memoizedState,baseState:Rr.baseState,baseQueue:Rr.baseQueue,queue:Rr.queue,next:null},Ka===null?En.memoizedState=Ka=m:Ka=Ka.next=m}return Ka}function hw(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Tx(m){var b=Ax;return Ax+=1,Np===null&&(Np=[]),m=ZI(Np,m,b),b=En,(Ka===null?b.memoizedState:Ka.next)===null&&(b=b.alternate,q.H=b===null||b.memoizedState===null?$5:kT),m}function mw(m){if(m!==null&&typeof m=="object"){if(typeof m.then=="function")return Tx(m);if(m.$$typeof===N)return Hi(m)}throw Error(r(438,String(m)))}function pT(m){var b=null,S=En.updateQueue;if(S!==null&&(b=S.memoCache),b==null){var T=En.alternate;T!==null&&(T=T.updateQueue,T!==null&&(T=T.memoCache,T!=null&&(b={data:T.data.map(function(F){return F.slice()}),index:0})))}if(b==null&&(b={data:[],index:0}),S===null&&(S=hw(),En.updateQueue=S),S.memoCache=b,S=b.data[b.index],S===void 0)for(S=b.data[b.index]=Array(m),T=0;T<m;T++)S[T]=E;return b.index++,S}function rd(m,b){return typeof b=="function"?b(m):b}function fw(m){var b=Ha();return gT(b,Rr,m)}function gT(m,b,S){var T=m.queue;if(T===null)throw Error(r(311));T.lastRenderedReducer=S;var F=m.baseQueue,I=T.pending;if(I!==null){if(F!==null){var ne=F.next;F.next=I.next,I.next=ne}b.baseQueue=F=I,T.pending=null}if(I=m.baseState,F===null)m.memoizedState=I;else{b=F.next;var Ee=ne=null,Ge=null,ht=b,wt=!1;do{var Ct=ht.lane&-536870913;if(Ct!==ht.lane?(Jn&Ct)===Ct:(nd&Ct)===Ct){var ft=ht.revertLane;if(ft===0)Ge!==null&&(Ge=Ge.next={lane:0,revertLane:0,gesture:null,action:ht.action,hasEagerState:ht.hasEagerState,eagerState:ht.eagerState,next:null}),Ct===xp&&(wt=!0);else if((nd&ft)===ft){ht=ht.next,ft===xp&&(wt=!0);continue}else Ct={lane:0,revertLane:ht.revertLane,gesture:null,action:ht.action,hasEagerState:ht.hasEagerState,eagerState:ht.eagerState,next:null},Ge===null?(Ee=Ge=Ct,ne=I):Ge=Ge.next=Ct,En.lanes|=ft,ju|=ft;Ct=ht.action,_m&&S(I,Ct),I=ht.hasEagerState?ht.eagerState:S(I,Ct)}else ft={lane:Ct,revertLane:ht.revertLane,gesture:ht.gesture,action:ht.action,hasEagerState:ht.hasEagerState,eagerState:ht.eagerState,next:null},Ge===null?(Ee=Ge=ft,ne=I):Ge=Ge.next=ft,En.lanes|=Ct,ju|=Ct;ht=ht.next}while(ht!==null&&ht!==b);if(Ge===null?ne=I:Ge.next=Ee,!po(I,m.memoizedState)&&(Xa=!0,wt&&(S=yp,S!==null)))throw S;m.memoizedState=I,m.baseState=ne,m.baseQueue=Ge,T.lastRenderedState=I}return F===null&&(T.lanes=0),[m.memoizedState,T.dispatch]}function bT(m){var b=Ha(),S=b.queue;if(S===null)throw Error(r(311));S.lastRenderedReducer=m;var T=S.dispatch,F=S.pending,I=b.memoizedState;if(F!==null){S.pending=null;var ne=F=F.next;do I=m(I,ne.action),ne=ne.next;while(ne!==F);po(I,b.memoizedState)||(Xa=!0),b.memoizedState=I,b.baseQueue===null&&(b.baseState=I),S.lastRenderedState=I}return[I,T]}function c5(m,b,S){var T=En,F=Ha(),I=rr;if(I){if(S===void 0)throw Error(r(407));S=S()}else S=b();var ne=!po((Rr||F).memoizedState,S);if(ne&&(F.memoizedState=S,Xa=!0),F=F.queue,vT(h5.bind(null,T,F,m),[m]),F.getSnapshot!==b||ne||Ka!==null&&Ka.memoizedState.tag&1){if(T.flags|=2048,Cp(9,{destroy:void 0},u5.bind(null,T,F,S,b),null),Gr===null)throw Error(r(349));I||(nd&127)!==0||d5(T,b,S)}return S}function d5(m,b,S){m.flags|=16384,m={getSnapshot:b,value:S},b=En.updateQueue,b===null?(b=hw(),En.updateQueue=b,b.stores=[m]):(S=b.stores,S===null?b.stores=[m]:S.push(m))}function u5(m,b,S,T){b.value=S,b.getSnapshot=T,m5(b)&&f5(m)}function h5(m,b,S){return S(function(){m5(b)&&f5(m)})}function m5(m){var b=m.getSnapshot;m=m.value;try{var S=b();return!po(m,S)}catch{return!0}}function f5(m){var b=fm(m,2);b!==null&&Ws(b,m,2)}function xT(m){var b=Cs();if(typeof m=="function"){var S=m;if(m=S(),_m){Ne(!0);try{S()}finally{Ne(!1)}}}return b.memoizedState=b.baseState=m,b.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:rd,lastRenderedState:m},b}function p5(m,b,S,T){return m.baseState=S,gT(m,Rr,typeof T=="function"?T:rd)}function toe(m,b,S,T,F){if(bw(m))throw Error(r(485));if(m=b.action,m!==null){var I={payload:F,action:m,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(ne){I.listeners.push(ne)}};q.T!==null?S(!0):I.isTransition=!1,T(I),S=b.pending,S===null?(I.next=b.pending=I,g5(b,I)):(I.next=S.next,b.pending=S.next=I)}}function g5(m,b){var S=b.action,T=b.payload,F=m.state;if(b.isTransition){var I=q.T,ne={};q.T=ne;try{var Ee=S(F,T),Ge=q.S;Ge!==null&&Ge(ne,Ee),b5(m,b,Ee)}catch(ht){yT(m,b,ht)}finally{I!==null&&ne.types!==null&&(I.types=ne.types),q.T=I}}else try{I=S(F,T),b5(m,b,I)}catch(ht){yT(m,b,ht)}}function b5(m,b,S){S!==null&&typeof S=="object"&&typeof S.then=="function"?S.then(function(T){x5(m,b,T)},function(T){return yT(m,b,T)}):x5(m,b,S)}function x5(m,b,S){b.status="fulfilled",b.value=S,y5(b),m.state=S,b=m.pending,b!==null&&(S=b.next,S===b?m.pending=null:(S=S.next,b.next=S,g5(m,S)))}function yT(m,b,S){var T=m.pending;if(m.pending=null,T!==null){T=T.next;do b.status="rejected",b.reason=S,y5(b),b=b.next;while(b!==T)}m.action=null}function y5(m){m=m.listeners;for(var b=0;b<m.length;b++)(0,m[b])()}function v5(m,b){return b}function w5(m,b){if(rr){var S=Gr.formState;if(S!==null){e:{var T=En;if(rr){if(ia){t:{for(var F=ia,I=qo;F.nodeType!==8;){if(!I){F=null;break t}if(F=Wo(F.nextSibling),F===null){F=null;break t}}I=F.data,F=I==="F!"||I==="F"?F:null}if(F){ia=Wo(F.nextSibling),T=F.data==="F!";break e}}_u(T)}T=!1}T&&(b=S[0])}}return S=Cs(),S.memoizedState=S.baseState=b,T={pending:null,lanes:0,dispatch:null,lastRenderedReducer:v5,lastRenderedState:b},S.queue=T,S=U5.bind(null,En,T),T.dispatch=S,T=xT(!1),I=CT.bind(null,En,!1,T.queue),T=Cs(),F={state:b,dispatch:null,action:m,pending:null},T.queue=F,S=toe.bind(null,En,F,I,S),F.dispatch=S,T.memoizedState=m,[b,S,!1]}function S5(m){var b=Ha();return _5(b,Rr,m)}function _5(m,b,S){if(b=gT(m,b,v5)[0],m=fw(rd)[0],typeof b=="object"&&b!==null&&typeof b.then=="function")try{var T=Tx(b)}catch(ne){throw ne===vp?aw:ne}else T=b;b=Ha();var F=b.queue,I=F.dispatch;return S!==b.memoizedState&&(En.flags|=2048,Cp(9,{destroy:void 0},noe.bind(null,F,S),null)),[T,I,m]}function noe(m,b){m.action=b}function N5(m){var b=Ha(),S=Rr;if(S!==null)return _5(b,S,m);Ha(),b=b.memoizedState,S=Ha();var T=S.queue.dispatch;return S.memoizedState=m,[b,T,!1]}function Cp(m,b,S,T){return m={tag:m,create:S,deps:T,inst:b,next:null},b=En.updateQueue,b===null&&(b=hw(),En.updateQueue=b),S=b.lastEffect,S===null?b.lastEffect=m.next=m:(T=S.next,S.next=m,m.next=T,b.lastEffect=m),m}function C5(){return Ha().memoizedState}function pw(m,b,S,T){var F=Cs();En.flags|=m,F.memoizedState=Cp(1|b,{destroy:void 0},S,T===void 0?null:T)}function gw(m,b,S,T){var F=Ha();T=T===void 0?null:T;var I=F.memoizedState.inst;Rr!==null&&T!==null&&dT(T,Rr.memoizedState.deps)?F.memoizedState=Cp(b,I,S,T):(En.flags|=m,F.memoizedState=Cp(1|b,I,S,T))}function k5(m,b){pw(8390656,8,m,b)}function vT(m,b){gw(2048,8,m,b)}function roe(m){En.flags|=4;var b=En.updateQueue;if(b===null)b=hw(),En.updateQueue=b,b.events=[m];else{var S=b.events;S===null?b.events=[m]:S.push(m)}}function A5(m){var b=Ha().memoizedState;return roe({ref:b,nextImpl:m}),function(){if((xr&2)!==0)throw Error(r(440));return b.impl.apply(void 0,arguments)}}function T5(m,b){return gw(4,2,m,b)}function M5(m,b){return gw(4,4,m,b)}function P5(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 E5(m,b,S){S=S!=null?S.concat([m]):null,gw(4,4,P5.bind(null,b,m),S)}function wT(){}function j5(m,b){var S=Ha();b=b===void 0?null:b;var T=S.memoizedState;return b!==null&&dT(b,T[1])?T[0]:(S.memoizedState=[m,b],m)}function D5(m,b){var S=Ha();b=b===void 0?null:b;var T=S.memoizedState;if(b!==null&&dT(b,T[1]))return T[0];if(T=m(),_m){Ne(!0);try{m()}finally{Ne(!1)}}return S.memoizedState=[T,b],T}function ST(m,b,S){return S===void 0||(nd&1073741824)!==0&&(Jn&261930)===0?m.memoizedState=b:(m.memoizedState=S,m=Rz(),En.lanes|=m,ju|=m,S)}function R5(m,b,S,T){return po(S,b)?S:Sp.current!==null?(m=ST(m,S,T),po(m,b)||(Xa=!0),m):(nd&42)===0||(nd&1073741824)!==0&&(Jn&261930)===0?(Xa=!0,m.memoizedState=S):(m=Rz(),En.lanes|=m,ju|=m,b)}function F5(m,b,S,T,F){var I=z.p;z.p=I!==0&&8>I?I:8;var ne=q.T,Ee={};q.T=Ee,CT(m,!1,b,S);try{var Ge=F(),ht=q.S;if(ht!==null&&ht(Ee,Ge),Ge!==null&&typeof Ge=="object"&&typeof Ge.then=="function"){var wt=Zse(Ge,T);Mx(m,b,wt,wo(m))}else Mx(m,b,T,wo(m))}catch(Ct){Mx(m,b,{then:function(){},status:"rejected",reason:Ct},wo())}finally{z.p=I,ne!==null&&Ee.types!==null&&(ne.types=Ee.types),q.T=ne}}function aoe(){}function _T(m,b,S,T){if(m.tag!==5)throw Error(r(476));var F=L5(m).queue;F5(m,F,b,W,S===null?aoe:function(){return O5(m),S(T)})}function L5(m){var b=m.memoizedState;if(b!==null)return b;b={memoizedState:W,baseState:W,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:rd,lastRenderedState:W},next:null};var S={};return b.next={memoizedState:S,baseState:S,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:rd,lastRenderedState:S},next:null},m.memoizedState=b,m=m.alternate,m!==null&&(m.memoizedState=b),b}function O5(m){var b=L5(m);b.next===null&&(b=m.alternate.memoizedState),Mx(m,b.next.queue,{},wo())}function NT(){return Hi(Gx)}function I5(){return Ha().memoizedState}function z5(){return Ha().memoizedState}function ioe(m){for(var b=m.return;b!==null;){switch(b.tag){case 24:case 3:var S=wo();m=ku(S);var T=Au(b,m,S);T!==null&&(Ws(T,b,S),Nx(T,b,S)),b={cache:JA()},m.payload=b;return}b=b.return}}function soe(m,b,S){var T=wo();S={lane:T,revertLane:0,gesture:null,action:S,hasEagerState:!1,eagerState:null,next:null},bw(m)?B5(b,S):(S=HA(m,b,S,T),S!==null&&(Ws(S,m,T),H5(S,b,T)))}function U5(m,b,S){var T=wo();Mx(m,b,S,T)}function Mx(m,b,S,T){var F={lane:T,revertLane:0,gesture:null,action:S,hasEagerState:!1,eagerState:null,next:null};if(bw(m))B5(b,F);else{var I=m.alternate;if(m.lanes===0&&(I===null||I.lanes===0)&&(I=b.lastRenderedReducer,I!==null))try{var ne=b.lastRenderedState,Ee=I(ne,S);if(F.hasEagerState=!0,F.eagerState=Ee,po(Ee,ne))return Qv(m,b,F,0),Gr===null&&Yv(),!1}catch{}if(S=HA(m,b,F,T),S!==null)return Ws(S,m,T),H5(S,b,T),!0}return!1}function CT(m,b,S,T){if(T={lane:2,revertLane:rM(),gesture:null,action:T,hasEagerState:!1,eagerState:null,next:null},bw(m)){if(b)throw Error(r(479))}else b=HA(m,S,T,2),b!==null&&Ws(b,m,2)}function bw(m){var b=m.alternate;return m===En||b!==null&&b===En}function B5(m,b){_p=dw=!0;var S=m.pending;S===null?b.next=b:(b.next=S.next,S.next=b),m.pending=b}function H5(m,b,S){if((S&4194048)!==0){var T=b.lanes;T&=m.pendingLanes,S|=T,b.lanes=S,mt(m,S)}}var Px={readContext:Hi,use:mw,useCallback:ka,useContext:ka,useEffect:ka,useImperativeHandle:ka,useLayoutEffect:ka,useInsertionEffect:ka,useMemo:ka,useReducer:ka,useRef:ka,useState:ka,useDebugValue:ka,useDeferredValue:ka,useTransition:ka,useSyncExternalStore:ka,useId:ka,useHostTransitionStatus:ka,useFormState:ka,useActionState:ka,useOptimistic:ka,useMemoCache:ka,useCacheRefresh:ka};Px.useEffectEvent=ka;var $5={readContext:Hi,use:mw,useCallback:function(m,b){return Cs().memoizedState=[m,b===void 0?null:b],m},useContext:Hi,useEffect:k5,useImperativeHandle:function(m,b,S){S=S!=null?S.concat([m]):null,pw(4194308,4,P5.bind(null,b,m),S)},useLayoutEffect:function(m,b){return pw(4194308,4,m,b)},useInsertionEffect:function(m,b){pw(4,2,m,b)},useMemo:function(m,b){var S=Cs();b=b===void 0?null:b;var T=m();if(_m){Ne(!0);try{m()}finally{Ne(!1)}}return S.memoizedState=[T,b],T},useReducer:function(m,b,S){var T=Cs();if(S!==void 0){var F=S(b);if(_m){Ne(!0);try{S(b)}finally{Ne(!1)}}}else F=b;return T.memoizedState=T.baseState=F,m={pending:null,lanes:0,dispatch:null,lastRenderedReducer:m,lastRenderedState:F},T.queue=m,m=m.dispatch=soe.bind(null,En,m),[T.memoizedState,m]},useRef:function(m){var b=Cs();return m={current:m},b.memoizedState=m},useState:function(m){m=xT(m);var b=m.queue,S=U5.bind(null,En,b);return b.dispatch=S,[m.memoizedState,S]},useDebugValue:wT,useDeferredValue:function(m,b){var S=Cs();return ST(S,m,b)},useTransition:function(){var m=xT(!1);return m=F5.bind(null,En,m.queue,!0,!1),Cs().memoizedState=m,[!1,m]},useSyncExternalStore:function(m,b,S){var T=En,F=Cs();if(rr){if(S===void 0)throw Error(r(407));S=S()}else{if(S=b(),Gr===null)throw Error(r(349));(Jn&127)!==0||d5(T,b,S)}F.memoizedState=S;var I={value:S,getSnapshot:b};return F.queue=I,k5(h5.bind(null,T,I,m),[m]),T.flags|=2048,Cp(9,{destroy:void 0},u5.bind(null,T,I,S,b),null),S},useId:function(){var m=Cs(),b=Gr.identifierPrefix;if(rr){var S=cc,T=lc;S=(T&~(1<<32-xe(T)-1)).toString(32)+S,b="_"+b+"R_"+S,S=uw++,0<S&&(b+="H"+S.toString(32)),b+="_"}else S=Jse++,b="_"+b+"r_"+S.toString(32)+"_";return m.memoizedState=b},useHostTransitionStatus:NT,useFormState:w5,useActionState:w5,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=CT.bind(null,En,!0,S),S.dispatch=b,[m,b]},useMemoCache:pT,useCacheRefresh:function(){return Cs().memoizedState=ioe.bind(null,En)},useEffectEvent:function(m){var b=Cs(),S={impl:m};return b.memoizedState=S,function(){if((xr&2)!==0)throw Error(r(440));return S.impl.apply(void 0,arguments)}}},kT={readContext:Hi,use:mw,useCallback:j5,useContext:Hi,useEffect:vT,useImperativeHandle:E5,useInsertionEffect:T5,useLayoutEffect:M5,useMemo:D5,useReducer:fw,useRef:C5,useState:function(){return fw(rd)},useDebugValue:wT,useDeferredValue:function(m,b){var S=Ha();return R5(S,Rr.memoizedState,m,b)},useTransition:function(){var m=fw(rd)[0],b=Ha().memoizedState;return[typeof m=="boolean"?m:Tx(m),b]},useSyncExternalStore:c5,useId:I5,useHostTransitionStatus:NT,useFormState:S5,useActionState:S5,useOptimistic:function(m,b){var S=Ha();return p5(S,Rr,m,b)},useMemoCache:pT,useCacheRefresh:z5};kT.useEffectEvent=A5;var V5={readContext:Hi,use:mw,useCallback:j5,useContext:Hi,useEffect:vT,useImperativeHandle:E5,useInsertionEffect:T5,useLayoutEffect:M5,useMemo:D5,useReducer:bT,useRef:C5,useState:function(){return bT(rd)},useDebugValue:wT,useDeferredValue:function(m,b){var S=Ha();return Rr===null?ST(S,m,b):R5(S,Rr.memoizedState,m,b)},useTransition:function(){var m=bT(rd)[0],b=Ha().memoizedState;return[typeof m=="boolean"?m:Tx(m),b]},useSyncExternalStore:c5,useId:I5,useHostTransitionStatus:NT,useFormState:N5,useActionState:N5,useOptimistic:function(m,b){var S=Ha();return Rr!==null?p5(S,Rr,m,b):(S.baseState=m,[m,S.queue.dispatch])},useMemoCache:pT,useCacheRefresh:z5};V5.useEffectEvent=A5;function AT(m,b,S,T){b=m.memoizedState,S=S(T,b),S=S==null?b:h({},b,S),m.memoizedState=S,m.lanes===0&&(m.updateQueue.baseState=S)}var TT={enqueueSetState:function(m,b,S){m=m._reactInternals;var T=wo(),F=ku(T);F.payload=b,S!=null&&(F.callback=S),b=Au(m,F,T),b!==null&&(Ws(b,m,T),Nx(b,m,T))},enqueueReplaceState:function(m,b,S){m=m._reactInternals;var T=wo(),F=ku(T);F.tag=1,F.payload=b,S!=null&&(F.callback=S),b=Au(m,F,T),b!==null&&(Ws(b,m,T),Nx(b,m,T))},enqueueForceUpdate:function(m,b){m=m._reactInternals;var S=wo(),T=ku(S);T.tag=2,b!=null&&(T.callback=b),b=Au(m,T,S),b!==null&&(Ws(b,m,S),Nx(b,m,S))}};function q5(m,b,S,T,F,I,ne){return m=m.stateNode,typeof m.shouldComponentUpdate=="function"?m.shouldComponentUpdate(T,I,ne):b.prototype&&b.prototype.isPureReactComponent?!gx(S,T)||!gx(F,I):!0}function G5(m,b,S,T){m=b.state,typeof b.componentWillReceiveProps=="function"&&b.componentWillReceiveProps(S,T),typeof b.UNSAFE_componentWillReceiveProps=="function"&&b.UNSAFE_componentWillReceiveProps(S,T),b.state!==m&&TT.enqueueReplaceState(b,b.state,null)}function Nm(m,b){var S=b;if("ref"in b){S={};for(var T in b)T!=="ref"&&(S[T]=b[T])}if(m=m.defaultProps){S===b&&(S=h({},S));for(var F in m)S[F]===void 0&&(S[F]=m[F])}return S}function W5(m){Xv(m)}function K5(m){console.error(m)}function X5(m){Xv(m)}function xw(m,b){try{var S=m.onUncaughtError;S(b.value,{componentStack:b.stack})}catch(T){setTimeout(function(){throw T})}}function Y5(m,b,S){try{var T=m.onCaughtError;T(S.value,{componentStack:S.stack,errorBoundary:b.tag===1?b.stateNode:null})}catch(F){setTimeout(function(){throw F})}}function MT(m,b,S){return S=ku(S),S.tag=3,S.payload={element:null},S.callback=function(){xw(m,b)},S}function Q5(m){return m=ku(m),m.tag=3,m}function Z5(m,b,S,T){var F=S.type.getDerivedStateFromError;if(typeof F=="function"){var I=T.value;m.payload=function(){return F(I)},m.callback=function(){Y5(b,S,T)}}var ne=S.stateNode;ne!==null&&typeof ne.componentDidCatch=="function"&&(m.callback=function(){Y5(b,S,T),typeof F!="function"&&(Du===null?Du=new Set([this]):Du.add(this));var Ee=T.stack;this.componentDidCatch(T.value,{componentStack:Ee!==null?Ee:""})})}function ooe(m,b,S,T,F){if(S.flags|=32768,T!==null&&typeof T=="object"&&typeof T.then=="function"){if(b=S.alternate,b!==null&&bp(b,S,F,!0),S=bo.current,S!==null){switch(S.tag){case 31:case 13:return Go===null?Pw():S.alternate===null&&Aa===0&&(Aa=3),S.flags&=-257,S.flags|=65536,S.lanes=F,T===iw?S.flags|=16384:(b=S.updateQueue,b===null?S.updateQueue=new Set([T]):b.add(T),eM(m,T,F)),!1;case 22:return S.flags|=65536,T===iw?S.flags|=16384:(b=S.updateQueue,b===null?(b={transitions:null,markerInstances:null,retryQueue:new Set([T])},S.updateQueue=b):(S=b.retryQueue,S===null?b.retryQueue=new Set([T]):S.add(T)),eM(m,T,F)),!1}throw Error(r(435,S.tag))}return eM(m,T,F),Pw(),!1}if(rr)return b=bo.current,b!==null?((b.flags&65536)===0&&(b.flags|=256),b.flags|=65536,b.lanes=F,T!==KA&&(m=Error(r(422),{cause:T}),yx(Ho(m,S)))):(T!==KA&&(b=Error(r(423),{cause:T}),yx(Ho(b,S))),m=m.current.alternate,m.flags|=65536,F&=-F,m.lanes|=F,T=Ho(T,S),F=MT(m.stateNode,T,F),iT(m,F),Aa!==4&&(Aa=2)),!1;var I=Error(r(520),{cause:T});if(I=Ho(I,S),Ix===null?Ix=[I]:Ix.push(I),Aa!==4&&(Aa=2),b===null)return!0;T=Ho(T,S),S=b;do{switch(S.tag){case 3:return S.flags|=65536,m=F&-F,S.lanes|=m,m=MT(S.stateNode,T,m),iT(S,m),!1;case 1:if(b=S.type,I=S.stateNode,(S.flags&128)===0&&(typeof b.getDerivedStateFromError=="function"||I!==null&&typeof I.componentDidCatch=="function"&&(Du===null||!Du.has(I))))return S.flags|=65536,F&=-F,S.lanes|=F,F=Q5(F),Z5(F,m,S,T),iT(S,F),!1}S=S.return}while(S!==null);return!1}var PT=Error(r(461)),Xa=!1;function $i(m,b,S,T){b.child=m===null?n5(b,null,S,T):Sm(b,m.child,S,T)}function J5(m,b,S,T,F){S=S.render;var I=b.ref;if("ref"in T){var ne={};for(var Ee in T)Ee!=="ref"&&(ne[Ee]=T[Ee])}else ne=T;return xm(b),T=uT(m,b,S,ne,I,F),Ee=hT(),m!==null&&!Xa?(mT(m,b,F),ad(m,b,F)):(rr&&Ee&&GA(b),b.flags|=1,$i(m,b,T,F),b.child)}function ez(m,b,S,T,F){if(m===null){var I=S.type;return typeof I=="function"&&!$A(I)&&I.defaultProps===void 0&&S.compare===null?(b.tag=15,b.type=I,tz(m,b,I,T,F)):(m=Jv(S.type,null,T,b,b.mode,F),m.ref=b.ref,m.return=b,b.child=m)}if(I=m.child,!IT(m,F)){var ne=I.memoizedProps;if(S=S.compare,S=S!==null?S:gx,S(ne,T)&&m.ref===b.ref)return ad(m,b,F)}return b.flags|=1,m=Zc(I,T),m.ref=b.ref,m.return=b,b.child=m}function tz(m,b,S,T,F){if(m!==null){var I=m.memoizedProps;if(gx(I,T)&&m.ref===b.ref)if(Xa=!1,b.pendingProps=T=I,IT(m,F))(m.flags&131072)!==0&&(Xa=!0);else return b.lanes=m.lanes,ad(m,b,F)}return ET(m,b,S,T,F)}function nz(m,b,S,T){var F=T.children,I=m!==null?m.memoizedState:null;if(m===null&&b.stateNode===null&&(b.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),T.mode==="hidden"){if((b.flags&128)!==0){if(I=I!==null?I.baseLanes|S:S,m!==null){for(T=b.child=m.child,F=0;T!==null;)F=F|T.lanes|T.childLanes,T=T.sibling;T=F&~I}else T=0,b.child=null;return rz(m,b,I,S,T)}if((S&536870912)!==0)b.memoizedState={baseLanes:0,cachePool:null},m!==null&&rw(b,I!==null?I.cachePool:null),I!==null?i5(b,I):oT(),s5(b);else return T=b.lanes=536870912,rz(m,b,I!==null?I.baseLanes|S:S,S,T)}else I!==null?(rw(b,I.cachePool),i5(b,I),Mu(),b.memoizedState=null):(m!==null&&rw(b,null),oT(),Mu());return $i(m,b,F,S),b.child}function Ex(m,b){return m!==null&&m.tag===22||b.stateNode!==null||(b.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),b.sibling}function rz(m,b,S,T,F){var I=tT();return I=I===null?null:{parent:Wa._currentValue,pool:I},b.memoizedState={baseLanes:S,cachePool:I},m!==null&&rw(b,null),oT(),s5(b),m!==null&&bp(m,b,T,!0),b.childLanes=F,null}function yw(m,b){return b=ww({mode:b.mode,children:b.children},m.mode),b.ref=m.ref,m.child=b,b.return=m,b}function az(m,b,S){return Sm(b,m.child,null,S),m=yw(b,b.pendingProps),m.flags|=2,xo(b),b.memoizedState=null,m}function loe(m,b,S){var T=b.pendingProps,F=(b.flags&128)!==0;if(b.flags&=-129,m===null){if(rr){if(T.mode==="hidden")return m=yw(b,T),b.lanes=536870912,Ex(null,m);if(cT(b),(m=ia)?(m=gU(m,qo),m=m!==null&&m.data==="&"?m:null,m!==null&&(b.memoizedState={dehydrated:m,treeContext:wu!==null?{id:lc,overflow:cc}:null,retryLane:536870912,hydrationErrors:null},S=BI(m),S.return=b,b.child=S,Bi=b,ia=null)):m=null,m===null)throw _u(b);return b.lanes=536870912,null}return yw(b,T)}var I=m.memoizedState;if(I!==null){var ne=I.dehydrated;if(cT(b),F)if(b.flags&256)b.flags&=-257,b=az(m,b,S);else if(b.memoizedState!==null)b.child=m.child,b.flags|=128,b=null;else throw Error(r(558));else if(Xa||bp(m,b,S,!1),F=(S&m.childLanes)!==0,Xa||F){if(T=Gr,T!==null&&(ne=yt(T,S),ne!==0&&ne!==I.retryLane))throw I.retryLane=ne,fm(m,ne),Ws(T,m,ne),PT;Pw(),b=az(m,b,S)}else m=I.treeContext,ia=Wo(ne.nextSibling),Bi=b,rr=!0,Su=null,qo=!1,m!==null&&VI(b,m),b=yw(b,T),b.flags|=4096;return b}return m=Zc(m.child,{mode:T.mode,children:T.children}),m.ref=b.ref,b.child=m,m.return=b,m}function vw(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 ET(m,b,S,T,F){return xm(b),S=uT(m,b,S,T,void 0,F),T=hT(),m!==null&&!Xa?(mT(m,b,F),ad(m,b,F)):(rr&&T&&GA(b),b.flags|=1,$i(m,b,S,F),b.child)}function iz(m,b,S,T,F,I){return xm(b),b.updateQueue=null,S=l5(b,T,S,F),o5(m),T=hT(),m!==null&&!Xa?(mT(m,b,I),ad(m,b,I)):(rr&&T&&GA(b),b.flags|=1,$i(m,b,S,I),b.child)}function sz(m,b,S,T,F){if(xm(b),b.stateNode===null){var I=mp,ne=S.contextType;typeof ne=="object"&&ne!==null&&(I=Hi(ne)),I=new S(T,I),b.memoizedState=I.state!==null&&I.state!==void 0?I.state:null,I.updater=TT,b.stateNode=I,I._reactInternals=b,I=b.stateNode,I.props=T,I.state=b.memoizedState,I.refs={},rT(b),ne=S.contextType,I.context=typeof ne=="object"&&ne!==null?Hi(ne):mp,I.state=b.memoizedState,ne=S.getDerivedStateFromProps,typeof ne=="function"&&(AT(b,S,ne,T),I.state=b.memoizedState),typeof S.getDerivedStateFromProps=="function"||typeof I.getSnapshotBeforeUpdate=="function"||typeof I.UNSAFE_componentWillMount!="function"&&typeof I.componentWillMount!="function"||(ne=I.state,typeof I.componentWillMount=="function"&&I.componentWillMount(),typeof I.UNSAFE_componentWillMount=="function"&&I.UNSAFE_componentWillMount(),ne!==I.state&&TT.enqueueReplaceState(I,I.state,null),kx(b,T,I,F),Cx(),I.state=b.memoizedState),typeof I.componentDidMount=="function"&&(b.flags|=4194308),T=!0}else if(m===null){I=b.stateNode;var Ee=b.memoizedProps,Ge=Nm(S,Ee);I.props=Ge;var ht=I.context,wt=S.contextType;ne=mp,typeof wt=="object"&&wt!==null&&(ne=Hi(wt));var Ct=S.getDerivedStateFromProps;wt=typeof Ct=="function"||typeof I.getSnapshotBeforeUpdate=="function",Ee=b.pendingProps!==Ee,wt||typeof I.UNSAFE_componentWillReceiveProps!="function"&&typeof I.componentWillReceiveProps!="function"||(Ee||ht!==ne)&&G5(b,I,T,ne),Cu=!1;var ft=b.memoizedState;I.state=ft,kx(b,T,I,F),Cx(),ht=b.memoizedState,Ee||ft!==ht||Cu?(typeof Ct=="function"&&(AT(b,S,Ct,T),ht=b.memoizedState),(Ge=Cu||q5(b,S,Ge,T,ft,ht,ne))?(wt||typeof I.UNSAFE_componentWillMount!="function"&&typeof I.componentWillMount!="function"||(typeof I.componentWillMount=="function"&&I.componentWillMount(),typeof I.UNSAFE_componentWillMount=="function"&&I.UNSAFE_componentWillMount()),typeof I.componentDidMount=="function"&&(b.flags|=4194308)):(typeof I.componentDidMount=="function"&&(b.flags|=4194308),b.memoizedProps=T,b.memoizedState=ht),I.props=T,I.state=ht,I.context=ne,T=Ge):(typeof I.componentDidMount=="function"&&(b.flags|=4194308),T=!1)}else{I=b.stateNode,aT(m,b),ne=b.memoizedProps,wt=Nm(S,ne),I.props=wt,Ct=b.pendingProps,ft=I.context,ht=S.contextType,Ge=mp,typeof ht=="object"&&ht!==null&&(Ge=Hi(ht)),Ee=S.getDerivedStateFromProps,(ht=typeof Ee=="function"||typeof I.getSnapshotBeforeUpdate=="function")||typeof I.UNSAFE_componentWillReceiveProps!="function"&&typeof I.componentWillReceiveProps!="function"||(ne!==Ct||ft!==Ge)&&G5(b,I,T,Ge),Cu=!1,ft=b.memoizedState,I.state=ft,kx(b,T,I,F),Cx();var xt=b.memoizedState;ne!==Ct||ft!==xt||Cu||m!==null&&m.dependencies!==null&&tw(m.dependencies)?(typeof Ee=="function"&&(AT(b,S,Ee,T),xt=b.memoizedState),(wt=Cu||q5(b,S,wt,T,ft,xt,Ge)||m!==null&&m.dependencies!==null&&tw(m.dependencies))?(ht||typeof I.UNSAFE_componentWillUpdate!="function"&&typeof I.componentWillUpdate!="function"||(typeof I.componentWillUpdate=="function"&&I.componentWillUpdate(T,xt,Ge),typeof I.UNSAFE_componentWillUpdate=="function"&&I.UNSAFE_componentWillUpdate(T,xt,Ge)),typeof I.componentDidUpdate=="function"&&(b.flags|=4),typeof I.getSnapshotBeforeUpdate=="function"&&(b.flags|=1024)):(typeof I.componentDidUpdate!="function"||ne===m.memoizedProps&&ft===m.memoizedState||(b.flags|=4),typeof I.getSnapshotBeforeUpdate!="function"||ne===m.memoizedProps&&ft===m.memoizedState||(b.flags|=1024),b.memoizedProps=T,b.memoizedState=xt),I.props=T,I.state=xt,I.context=Ge,T=wt):(typeof I.componentDidUpdate!="function"||ne===m.memoizedProps&&ft===m.memoizedState||(b.flags|=4),typeof I.getSnapshotBeforeUpdate!="function"||ne===m.memoizedProps&&ft===m.memoizedState||(b.flags|=1024),T=!1)}return I=T,vw(m,b),T=(b.flags&128)!==0,I||T?(I=b.stateNode,S=T&&typeof S.getDerivedStateFromError!="function"?null:I.render(),b.flags|=1,m!==null&&T?(b.child=Sm(b,m.child,null,F),b.child=Sm(b,null,S,F)):$i(m,b,S,F),b.memoizedState=I.state,m=b.child):m=ad(m,b,F),m}function oz(m,b,S,T){return gm(),b.flags|=256,$i(m,b,S,T),b.child}var jT={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function DT(m){return{baseLanes:m,cachePool:YI()}}function RT(m,b,S){return m=m!==null?m.childLanes&~S:0,b&&(m|=vo),m}function lz(m,b,S){var T=b.pendingProps,F=!1,I=(b.flags&128)!==0,ne;if((ne=I)||(ne=m!==null&&m.memoizedState===null?!1:(Ba.current&2)!==0),ne&&(F=!0,b.flags&=-129),ne=(b.flags&32)!==0,b.flags&=-33,m===null){if(rr){if(F?Tu(b):Mu(),(m=ia)?(m=gU(m,qo),m=m!==null&&m.data!=="&"?m:null,m!==null&&(b.memoizedState={dehydrated:m,treeContext:wu!==null?{id:lc,overflow:cc}:null,retryLane:536870912,hydrationErrors:null},S=BI(m),S.return=b,b.child=S,Bi=b,ia=null)):m=null,m===null)throw _u(b);return gM(m)?b.lanes=32:b.lanes=536870912,null}var Ee=T.children;return T=T.fallback,F?(Mu(),F=b.mode,Ee=ww({mode:"hidden",children:Ee},F),T=pm(T,F,S,null),Ee.return=b,T.return=b,Ee.sibling=T,b.child=Ee,T=b.child,T.memoizedState=DT(S),T.childLanes=RT(m,ne,S),b.memoizedState=jT,Ex(null,T)):(Tu(b),FT(b,Ee))}var Ge=m.memoizedState;if(Ge!==null&&(Ee=Ge.dehydrated,Ee!==null)){if(I)b.flags&256?(Tu(b),b.flags&=-257,b=LT(m,b,S)):b.memoizedState!==null?(Mu(),b.child=m.child,b.flags|=128,b=null):(Mu(),Ee=T.fallback,F=b.mode,T=ww({mode:"visible",children:T.children},F),Ee=pm(Ee,F,S,null),Ee.flags|=2,T.return=b,Ee.return=b,T.sibling=Ee,b.child=T,Sm(b,m.child,null,S),T=b.child,T.memoizedState=DT(S),T.childLanes=RT(m,ne,S),b.memoizedState=jT,b=Ex(null,T));else if(Tu(b),gM(Ee)){if(ne=Ee.nextSibling&&Ee.nextSibling.dataset,ne)var ht=ne.dgst;ne=ht,T=Error(r(419)),T.stack="",T.digest=ne,yx({value:T,source:null,stack:null}),b=LT(m,b,S)}else if(Xa||bp(m,b,S,!1),ne=(S&m.childLanes)!==0,Xa||ne){if(ne=Gr,ne!==null&&(T=yt(ne,S),T!==0&&T!==Ge.retryLane))throw Ge.retryLane=T,fm(m,T),Ws(ne,m,T),PT;pM(Ee)||Pw(),b=LT(m,b,S)}else pM(Ee)?(b.flags|=192,b.child=m.child,b=null):(m=Ge.treeContext,ia=Wo(Ee.nextSibling),Bi=b,rr=!0,Su=null,qo=!1,m!==null&&VI(b,m),b=FT(b,T.children),b.flags|=4096);return b}return F?(Mu(),Ee=T.fallback,F=b.mode,Ge=m.child,ht=Ge.sibling,T=Zc(Ge,{mode:"hidden",children:T.children}),T.subtreeFlags=Ge.subtreeFlags&65011712,ht!==null?Ee=Zc(ht,Ee):(Ee=pm(Ee,F,S,null),Ee.flags|=2),Ee.return=b,T.return=b,T.sibling=Ee,b.child=T,Ex(null,T),T=b.child,Ee=m.child.memoizedState,Ee===null?Ee=DT(S):(F=Ee.cachePool,F!==null?(Ge=Wa._currentValue,F=F.parent!==Ge?{parent:Ge,pool:Ge}:F):F=YI(),Ee={baseLanes:Ee.baseLanes|S,cachePool:F}),T.memoizedState=Ee,T.childLanes=RT(m,ne,S),b.memoizedState=jT,Ex(m.child,T)):(Tu(b),S=m.child,m=S.sibling,S=Zc(S,{mode:"visible",children:T.children}),S.return=b,S.sibling=null,m!==null&&(ne=b.deletions,ne===null?(b.deletions=[m],b.flags|=16):ne.push(m)),b.child=S,b.memoizedState=null,S)}function FT(m,b){return b=ww({mode:"visible",children:b},m.mode),b.return=m,m.child=b}function ww(m,b){return m=go(22,m,null,b),m.lanes=0,m}function LT(m,b,S){return Sm(b,m.child,null,S),m=FT(b,b.pendingProps.children),m.flags|=2,b.memoizedState=null,m}function cz(m,b,S){m.lanes|=b;var T=m.alternate;T!==null&&(T.lanes|=b),QA(m.return,b,S)}function OT(m,b,S,T,F,I){var ne=m.memoizedState;ne===null?m.memoizedState={isBackwards:b,rendering:null,renderingStartTime:0,last:T,tail:S,tailMode:F,treeForkCount:I}:(ne.isBackwards=b,ne.rendering=null,ne.renderingStartTime=0,ne.last=T,ne.tail=S,ne.tailMode=F,ne.treeForkCount=I)}function dz(m,b,S){var T=b.pendingProps,F=T.revealOrder,I=T.tail;T=T.children;var ne=Ba.current,Ee=(ne&2)!==0;if(Ee?(ne=ne&1|2,b.flags|=128):ne&=1,Z(Ba,ne),$i(m,b,T,S),T=rr?xx:0,!Ee&&m!==null&&(m.flags&128)!==0)e:for(m=b.child;m!==null;){if(m.tag===13)m.memoizedState!==null&&cz(m,S,b);else if(m.tag===19)cz(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(F){case"forwards":for(S=b.child,F=null;S!==null;)m=S.alternate,m!==null&&cw(m)===null&&(F=S),S=S.sibling;S=F,S===null?(F=b.child,b.child=null):(F=S.sibling,S.sibling=null),OT(b,!1,F,S,I,T);break;case"backwards":case"unstable_legacy-backwards":for(S=null,F=b.child,b.child=null;F!==null;){if(m=F.alternate,m!==null&&cw(m)===null){b.child=F;break}m=F.sibling,F.sibling=S,S=F,F=m}OT(b,!0,S,null,I,T);break;case"together":OT(b,!1,null,null,void 0,T);break;default:b.memoizedState=null}return b.child}function ad(m,b,S){if(m!==null&&(b.dependencies=m.dependencies),ju|=b.lanes,(S&b.childLanes)===0)if(m!==null){if(bp(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=Zc(m,m.pendingProps),b.child=S,S.return=b;m.sibling!==null;)m=m.sibling,S=S.sibling=Zc(m,m.pendingProps),S.return=b;S.sibling=null}return b.child}function IT(m,b){return(m.lanes&b)!==0?!0:(m=m.dependencies,!!(m!==null&&tw(m)))}function coe(m,b,S){switch(b.tag){case 3:me(b,b.stateNode.containerInfo),Nu(b,Wa,m.memoizedState.cache),gm();break;case 27:case 5:ce(b);break;case 4:me(b,b.stateNode.containerInfo);break;case 10:Nu(b,b.type,b.memoizedProps.value);break;case 31:if(b.memoizedState!==null)return b.flags|=128,cT(b),null;break;case 13:var T=b.memoizedState;if(T!==null)return T.dehydrated!==null?(Tu(b),b.flags|=128,null):(S&b.child.childLanes)!==0?lz(m,b,S):(Tu(b),m=ad(m,b,S),m!==null?m.sibling:null);Tu(b);break;case 19:var F=(m.flags&128)!==0;if(T=(S&b.childLanes)!==0,T||(bp(m,b,S,!1),T=(S&b.childLanes)!==0),F){if(T)return dz(m,b,S);b.flags|=128}if(F=b.memoizedState,F!==null&&(F.rendering=null,F.tail=null,F.lastEffect=null),Z(Ba,Ba.current),T)break;return null;case 22:return b.lanes=0,nz(m,b,S,b.pendingProps);case 24:Nu(b,Wa,m.memoizedState.cache)}return ad(m,b,S)}function uz(m,b,S){if(m!==null)if(m.memoizedProps!==b.pendingProps)Xa=!0;else{if(!IT(m,S)&&(b.flags&128)===0)return Xa=!1,coe(m,b,S);Xa=(m.flags&131072)!==0}else Xa=!1,rr&&(b.flags&1048576)!==0&&$I(b,xx,b.index);switch(b.lanes=0,b.tag){case 16:e:{var T=b.pendingProps;if(m=vm(b.elementType),b.type=m,typeof m=="function")$A(m)?(T=Nm(m,T),b.tag=1,b=sz(null,b,m,T,S)):(b.tag=0,b=ET(null,b,m,T,S));else{if(m!=null){var F=m.$$typeof;if(F===A){b.tag=11,b=J5(null,b,m,T,S);break e}else if(F===C){b.tag=14,b=ez(null,b,m,T,S);break e}}throw b=D(m)||m,Error(r(306,b,""))}}return b;case 0:return ET(m,b,b.type,b.pendingProps,S);case 1:return T=b.type,F=Nm(T,b.pendingProps),sz(m,b,T,F,S);case 3:e:{if(me(b,b.stateNode.containerInfo),m===null)throw Error(r(387));T=b.pendingProps;var I=b.memoizedState;F=I.element,aT(m,b),kx(b,T,null,S);var ne=b.memoizedState;if(T=ne.cache,Nu(b,Wa,T),T!==I.cache&&ZA(b,[Wa],S,!0),Cx(),T=ne.element,I.isDehydrated)if(I={element:T,isDehydrated:!1,cache:ne.cache},b.updateQueue.baseState=I,b.memoizedState=I,b.flags&256){b=oz(m,b,T,S);break e}else if(T!==F){F=Ho(Error(r(424)),b),yx(F),b=oz(m,b,T,S);break e}else for(m=b.stateNode.containerInfo,m.nodeType===9?m=m.body:m=m.nodeName==="HTML"?m.ownerDocument.body:m,ia=Wo(m.firstChild),Bi=b,rr=!0,Su=null,qo=!0,S=n5(b,null,T,S),b.child=S;S;)S.flags=S.flags&-3|4096,S=S.sibling;else{if(gm(),T===F){b=ad(m,b,S);break e}$i(m,b,T,S)}b=b.child}return b;case 26:return vw(m,b),m===null?(S=SU(b.type,null,b.pendingProps,null))?b.memoizedState=S:rr||(S=b.type,m=b.pendingProps,T=Ow(oe.current).createElement(S),T[Gn]=b,T[br]=m,Vi(T,S,m),Xe(T),b.stateNode=T):b.memoizedState=SU(b.type,m.memoizedProps,b.pendingProps,m.memoizedState),null;case 27:return ce(b),m===null&&rr&&(T=b.stateNode=yU(b.type,b.pendingProps,oe.current),Bi=b,qo=!0,F=ia,Ou(b.type)?(bM=F,ia=Wo(T.firstChild)):ia=F),$i(m,b,b.pendingProps.children,S),vw(m,b),m===null&&(b.flags|=4194304),b.child;case 5:return m===null&&rr&&((F=T=ia)&&(T=zoe(T,b.type,b.pendingProps,qo),T!==null?(b.stateNode=T,Bi=b,ia=Wo(T.firstChild),qo=!1,F=!0):F=!1),F||_u(b)),ce(b),F=b.type,I=b.pendingProps,ne=m!==null?m.memoizedProps:null,T=I.children,hM(F,I)?T=null:ne!==null&&hM(F,ne)&&(b.flags|=32),b.memoizedState!==null&&(F=uT(m,b,eoe,null,null,S),Gx._currentValue=F),vw(m,b),$i(m,b,T,S),b.child;case 6:return m===null&&rr&&((m=S=ia)&&(S=Uoe(S,b.pendingProps,qo),S!==null?(b.stateNode=S,Bi=b,ia=null,m=!0):m=!1),m||_u(b)),null;case 13:return lz(m,b,S);case 4:return me(b,b.stateNode.containerInfo),T=b.pendingProps,m===null?b.child=Sm(b,null,T,S):$i(m,b,T,S),b.child;case 11:return J5(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 T=b.pendingProps,Nu(b,b.type,T.value),$i(m,b,T.children,S),b.child;case 9:return F=b.type._context,T=b.pendingProps.children,xm(b),F=Hi(F),T=T(F),b.flags|=1,$i(m,b,T,S),b.child;case 14:return ez(m,b,b.type,b.pendingProps,S);case 15:return tz(m,b,b.type,b.pendingProps,S);case 19:return dz(m,b,S);case 31:return loe(m,b,S);case 22:return nz(m,b,S,b.pendingProps);case 24:return xm(b),T=Hi(Wa),m===null?(F=tT(),F===null&&(F=Gr,I=JA(),F.pooledCache=I,I.refCount++,I!==null&&(F.pooledCacheLanes|=S),F=I),b.memoizedState={parent:T,cache:F},rT(b),Nu(b,Wa,F)):((m.lanes&S)!==0&&(aT(m,b),kx(b,null,null,S),Cx()),F=m.memoizedState,I=b.memoizedState,F.parent!==T?(F={parent:T,cache:T},b.memoizedState=F,b.lanes===0&&(b.memoizedState=b.updateQueue.baseState=F),Nu(b,Wa,T)):(T=I.cache,Nu(b,Wa,T),T!==F.cache&&ZA(b,[Wa],S,!0))),$i(m,b,b.pendingProps.children,S),b.child;case 29:throw b.pendingProps}throw Error(r(156,b.tag))}function id(m){m.flags|=4}function zT(m,b,S,T,F){if((b=(m.mode&32)!==0)&&(b=!1),b){if(m.flags|=16777216,(F&335544128)===F)if(m.stateNode.complete)m.flags|=8192;else if(Iz())m.flags|=8192;else throw wm=iw,nT}else m.flags&=-16777217}function hz(m,b){if(b.type!=="stylesheet"||(b.state.loading&4)!==0)m.flags&=-16777217;else if(m.flags|=16777216,!AU(b))if(Iz())m.flags|=8192;else throw wm=iw,nT}function Sw(m,b){b!==null&&(m.flags|=4),m.flags&16384&&(b=m.tag!==22?kt():536870912,m.lanes|=b,Mp|=b)}function jx(m,b){if(!rr)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 T=null;S!==null;)S.alternate!==null&&(T=S),S=S.sibling;T===null?b||m.tail===null?m.tail=null:m.tail.sibling=null:T.sibling=null}}function sa(m){var b=m.alternate!==null&&m.alternate.child===m.child,S=0,T=0;if(b)for(var F=m.child;F!==null;)S|=F.lanes|F.childLanes,T|=F.subtreeFlags&65011712,T|=F.flags&65011712,F.return=m,F=F.sibling;else for(F=m.child;F!==null;)S|=F.lanes|F.childLanes,T|=F.subtreeFlags,T|=F.flags,F.return=m,F=F.sibling;return m.subtreeFlags|=T,m.childLanes=S,b}function doe(m,b,S){var T=b.pendingProps;switch(WA(b),b.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return sa(b),null;case 1:return sa(b),null;case 3:return S=b.stateNode,T=null,m!==null&&(T=m.memoizedState.cache),b.memoizedState.cache!==T&&(b.flags|=2048),td(Wa),se(),S.pendingContext&&(S.context=S.pendingContext,S.pendingContext=null),(m===null||m.child===null)&&(gp(b)?id(b):m===null||m.memoizedState.isDehydrated&&(b.flags&256)===0||(b.flags|=1024,XA())),sa(b),null;case 26:var F=b.type,I=b.memoizedState;return m===null?(id(b),I!==null?(sa(b),hz(b,I)):(sa(b),zT(b,F,null,T,S))):I?I!==m.memoizedState?(id(b),sa(b),hz(b,I)):(sa(b),b.flags&=-16777217):(m=m.memoizedProps,m!==T&&id(b),sa(b),zT(b,F,m,T,S)),null;case 27:if(Ce(b),S=oe.current,F=b.type,m!==null&&b.stateNode!=null)m.memoizedProps!==T&&id(b);else{if(!T){if(b.stateNode===null)throw Error(r(166));return sa(b),null}m=ee.current,gp(b)?qI(b):(m=yU(F,T,S),b.stateNode=m,id(b))}return sa(b),null;case 5:if(Ce(b),F=b.type,m!==null&&b.stateNode!=null)m.memoizedProps!==T&&id(b);else{if(!T){if(b.stateNode===null)throw Error(r(166));return sa(b),null}if(I=ee.current,gp(b))qI(b);else{var ne=Ow(oe.current);switch(I){case 1:I=ne.createElementNS("http://www.w3.org/2000/svg",F);break;case 2:I=ne.createElementNS("http://www.w3.org/1998/Math/MathML",F);break;default:switch(F){case"svg":I=ne.createElementNS("http://www.w3.org/2000/svg",F);break;case"math":I=ne.createElementNS("http://www.w3.org/1998/Math/MathML",F);break;case"script":I=ne.createElement("div"),I.innerHTML="<script><\/script>",I=I.removeChild(I.firstChild);break;case"select":I=typeof T.is=="string"?ne.createElement("select",{is:T.is}):ne.createElement("select"),T.multiple?I.multiple=!0:T.size&&(I.size=T.size);break;default:I=typeof T.is=="string"?ne.createElement(F,{is:T.is}):ne.createElement(F)}}I[Gn]=b,I[br]=T;e:for(ne=b.child;ne!==null;){if(ne.tag===5||ne.tag===6)I.appendChild(ne.stateNode);else if(ne.tag!==4&&ne.tag!==27&&ne.child!==null){ne.child.return=ne,ne=ne.child;continue}if(ne===b)break e;for(;ne.sibling===null;){if(ne.return===null||ne.return===b)break e;ne=ne.return}ne.sibling.return=ne.return,ne=ne.sibling}b.stateNode=I;e:switch(Vi(I,F,T),F){case"button":case"input":case"select":case"textarea":T=!!T.autoFocus;break e;case"img":T=!0;break e;default:T=!1}T&&id(b)}}return sa(b),zT(b,b.type,m===null?null:m.memoizedProps,b.pendingProps,S),null;case 6:if(m&&b.stateNode!=null)m.memoizedProps!==T&&id(b);else{if(typeof T!="string"&&b.stateNode===null)throw Error(r(166));if(m=oe.current,gp(b)){if(m=b.stateNode,S=b.memoizedProps,T=null,F=Bi,F!==null)switch(F.tag){case 27:case 5:T=F.memoizedProps}m[Gn]=b,m=!!(m.nodeValue===S||T!==null&&T.suppressHydrationWarning===!0||lU(m.nodeValue,S)),m||_u(b,!0)}else m=Ow(m).createTextNode(T),m[Gn]=b,b.stateNode=m}return sa(b),null;case 31:if(S=b.memoizedState,m===null||m.memoizedState!==null){if(T=gp(b),S!==null){if(m===null){if(!T)throw Error(r(318));if(m=b.memoizedState,m=m!==null?m.dehydrated:null,!m)throw Error(r(557));m[Gn]=b}else gm(),(b.flags&128)===0&&(b.memoizedState=null),b.flags|=4;sa(b),m=!1}else S=XA(),m!==null&&m.memoizedState!==null&&(m.memoizedState.hydrationErrors=S),m=!0;if(!m)return b.flags&256?(xo(b),b):(xo(b),null);if((b.flags&128)!==0)throw Error(r(558))}return sa(b),null;case 13:if(T=b.memoizedState,m===null||m.memoizedState!==null&&m.memoizedState.dehydrated!==null){if(F=gp(b),T!==null&&T.dehydrated!==null){if(m===null){if(!F)throw Error(r(318));if(F=b.memoizedState,F=F!==null?F.dehydrated:null,!F)throw Error(r(317));F[Gn]=b}else gm(),(b.flags&128)===0&&(b.memoizedState=null),b.flags|=4;sa(b),F=!1}else F=XA(),m!==null&&m.memoizedState!==null&&(m.memoizedState.hydrationErrors=F),F=!0;if(!F)return b.flags&256?(xo(b),b):(xo(b),null)}return xo(b),(b.flags&128)!==0?(b.lanes=S,b):(S=T!==null,m=m!==null&&m.memoizedState!==null,S&&(T=b.child,F=null,T.alternate!==null&&T.alternate.memoizedState!==null&&T.alternate.memoizedState.cachePool!==null&&(F=T.alternate.memoizedState.cachePool.pool),I=null,T.memoizedState!==null&&T.memoizedState.cachePool!==null&&(I=T.memoizedState.cachePool.pool),I!==F&&(T.flags|=2048)),S!==m&&S&&(b.child.flags|=8192),Sw(b,b.updateQueue),sa(b),null);case 4:return se(),m===null&&oM(b.stateNode.containerInfo),sa(b),null;case 10:return td(b.type),sa(b),null;case 19:if(X(Ba),T=b.memoizedState,T===null)return sa(b),null;if(F=(b.flags&128)!==0,I=T.rendering,I===null)if(F)jx(T,!1);else{if(Aa!==0||m!==null&&(m.flags&128)!==0)for(m=b.child;m!==null;){if(I=cw(m),I!==null){for(b.flags|=128,jx(T,!1),m=I.updateQueue,b.updateQueue=m,Sw(b,m),b.subtreeFlags=0,m=S,S=b.child;S!==null;)UI(S,m),S=S.sibling;return Z(Ba,Ba.current&1|2),rr&&Jc(b,T.treeForkCount),b.child}m=m.sibling}T.tail!==null&&R()>Aw&&(b.flags|=128,F=!0,jx(T,!1),b.lanes=4194304)}else{if(!F)if(m=cw(I),m!==null){if(b.flags|=128,F=!0,m=m.updateQueue,b.updateQueue=m,Sw(b,m),jx(T,!0),T.tail===null&&T.tailMode==="hidden"&&!I.alternate&&!rr)return sa(b),null}else 2*R()-T.renderingStartTime>Aw&&S!==536870912&&(b.flags|=128,F=!0,jx(T,!1),b.lanes=4194304);T.isBackwards?(I.sibling=b.child,b.child=I):(m=T.last,m!==null?m.sibling=I:b.child=I,T.last=I)}return T.tail!==null?(m=T.tail,T.rendering=m,T.tail=m.sibling,T.renderingStartTime=R(),m.sibling=null,S=Ba.current,Z(Ba,F?S&1|2:S&1),rr&&Jc(b,T.treeForkCount),m):(sa(b),null);case 22:case 23:return xo(b),lT(),T=b.memoizedState!==null,m!==null?m.memoizedState!==null!==T&&(b.flags|=8192):T&&(b.flags|=8192),T?(S&536870912)!==0&&(b.flags&128)===0&&(sa(b),b.subtreeFlags&6&&(b.flags|=8192)):sa(b),S=b.updateQueue,S!==null&&Sw(b,S.retryQueue),S=null,m!==null&&m.memoizedState!==null&&m.memoizedState.cachePool!==null&&(S=m.memoizedState.cachePool.pool),T=null,b.memoizedState!==null&&b.memoizedState.cachePool!==null&&(T=b.memoizedState.cachePool.pool),T!==S&&(b.flags|=2048),m!==null&&X(ym),null;case 24:return S=null,m!==null&&(S=m.memoizedState.cache),b.memoizedState.cache!==S&&(b.flags|=2048),td(Wa),sa(b),null;case 25:return null;case 30:return null}throw Error(r(156,b.tag))}function uoe(m,b){switch(WA(b),b.tag){case 1:return m=b.flags,m&65536?(b.flags=m&-65537|128,b):null;case 3:return td(Wa),se(),m=b.flags,(m&65536)!==0&&(m&128)===0?(b.flags=m&-65537|128,b):null;case 26:case 27:case 5:return Ce(b),null;case 31:if(b.memoizedState!==null){if(xo(b),b.alternate===null)throw Error(r(340));gm()}return m=b.flags,m&65536?(b.flags=m&-65537|128,b):null;case 13:if(xo(b),m=b.memoizedState,m!==null&&m.dehydrated!==null){if(b.alternate===null)throw Error(r(340));gm()}return m=b.flags,m&65536?(b.flags=m&-65537|128,b):null;case 19:return X(Ba),null;case 4:return se(),null;case 10:return td(b.type),null;case 22:case 23:return xo(b),lT(),m!==null&&X(ym),m=b.flags,m&65536?(b.flags=m&-65537|128,b):null;case 24:return td(Wa),null;case 25:return null;default:return null}}function mz(m,b){switch(WA(b),b.tag){case 3:td(Wa),se();break;case 26:case 27:case 5:Ce(b);break;case 4:se();break;case 31:b.memoizedState!==null&&xo(b);break;case 13:xo(b);break;case 19:X(Ba);break;case 10:td(b.type);break;case 22:case 23:xo(b),lT(),m!==null&&X(ym);break;case 24:td(Wa)}}function Dx(m,b){try{var S=b.updateQueue,T=S!==null?S.lastEffect:null;if(T!==null){var F=T.next;S=F;do{if((S.tag&m)===m){T=void 0;var I=S.create,ne=S.inst;T=I(),ne.destroy=T}S=S.next}while(S!==F)}}catch(Ee){Tr(b,b.return,Ee)}}function Pu(m,b,S){try{var T=b.updateQueue,F=T!==null?T.lastEffect:null;if(F!==null){var I=F.next;T=I;do{if((T.tag&m)===m){var ne=T.inst,Ee=ne.destroy;if(Ee!==void 0){ne.destroy=void 0,F=b;var Ge=S,ht=Ee;try{ht()}catch(wt){Tr(F,Ge,wt)}}}T=T.next}while(T!==I)}}catch(wt){Tr(b,b.return,wt)}}function fz(m){var b=m.updateQueue;if(b!==null){var S=m.stateNode;try{a5(b,S)}catch(T){Tr(m,m.return,T)}}}function pz(m,b,S){S.props=Nm(m.type,m.memoizedProps),S.state=m.memoizedState;try{S.componentWillUnmount()}catch(T){Tr(m,b,T)}}function Rx(m,b){try{var S=m.ref;if(S!==null){switch(m.tag){case 26:case 27:case 5:var T=m.stateNode;break;case 30:T=m.stateNode;break;default:T=m.stateNode}typeof S=="function"?m.refCleanup=S(T):S.current=T}}catch(F){Tr(m,b,F)}}function dc(m,b){var S=m.ref,T=m.refCleanup;if(S!==null)if(typeof T=="function")try{T()}catch(F){Tr(m,b,F)}finally{m.refCleanup=null,m=m.alternate,m!=null&&(m.refCleanup=null)}else if(typeof S=="function")try{S(null)}catch(F){Tr(m,b,F)}else S.current=null}function gz(m){var b=m.type,S=m.memoizedProps,T=m.stateNode;try{e:switch(b){case"button":case"input":case"select":case"textarea":S.autoFocus&&T.focus();break e;case"img":S.src?T.src=S.src:S.srcSet&&(T.srcset=S.srcSet)}}catch(F){Tr(m,m.return,F)}}function UT(m,b,S){try{var T=m.stateNode;Doe(T,m.type,S,b),T[br]=b}catch(F){Tr(m,m.return,F)}}function bz(m){return m.tag===5||m.tag===3||m.tag===26||m.tag===27&&Ou(m.type)||m.tag===4}function BT(m){e:for(;;){for(;m.sibling===null;){if(m.return===null||bz(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&&Ou(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 HT(m,b,S){var T=m.tag;if(T===5||T===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=dr));else if(T!==4&&(T===27&&Ou(m.type)&&(S=m.stateNode,b=null),m=m.child,m!==null))for(HT(m,b,S),m=m.sibling;m!==null;)HT(m,b,S),m=m.sibling}function _w(m,b,S){var T=m.tag;if(T===5||T===6)m=m.stateNode,b?S.insertBefore(m,b):S.appendChild(m);else if(T!==4&&(T===27&&Ou(m.type)&&(S=m.stateNode),m=m.child,m!==null))for(_w(m,b,S),m=m.sibling;m!==null;)_w(m,b,S),m=m.sibling}function xz(m){var b=m.stateNode,S=m.memoizedProps;try{for(var T=m.type,F=b.attributes;F.length;)b.removeAttributeNode(F[0]);Vi(b,T,S),b[Gn]=m,b[br]=S}catch(I){Tr(m,m.return,I)}}var sd=!1,Ya=!1,$T=!1,yz=typeof WeakSet=="function"?WeakSet:Set,ki=null;function hoe(m,b){if(m=m.containerInfo,dM=Vw,m=EI(m),LA(m)){if("selectionStart"in m)var S={start:m.selectionStart,end:m.selectionEnd};else e:{S=(S=m.ownerDocument)&&S.defaultView||window;var T=S.getSelection&&S.getSelection();if(T&&T.rangeCount!==0){S=T.anchorNode;var F=T.anchorOffset,I=T.focusNode;T=T.focusOffset;try{S.nodeType,I.nodeType}catch{S=null;break e}var ne=0,Ee=-1,Ge=-1,ht=0,wt=0,Ct=m,ft=null;t:for(;;){for(var xt;Ct!==S||F!==0&&Ct.nodeType!==3||(Ee=ne+F),Ct!==I||T!==0&&Ct.nodeType!==3||(Ge=ne+T),Ct.nodeType===3&&(ne+=Ct.nodeValue.length),(xt=Ct.firstChild)!==null;)ft=Ct,Ct=xt;for(;;){if(Ct===m)break t;if(ft===S&&++ht===F&&(Ee=ne),ft===I&&++wt===T&&(Ge=ne),(xt=Ct.nextSibling)!==null)break;Ct=ft,ft=Ct.parentNode}Ct=xt}S=Ee===-1||Ge===-1?null:{start:Ee,end:Ge}}else S=null}S=S||{start:0,end:0}}else S=null;for(uM={focusedElem:m,selectionRange:S},Vw=!1,ki=b;ki!==null;)if(b=ki,m=b.child,(b.subtreeFlags&1028)!==0&&m!==null)m.return=b,ki=m;else for(;ki!==null;){switch(b=ki,I=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++)F=m[S],F.ref.impl=F.nextImpl;break;case 11:case 15:break;case 1:if((m&1024)!==0&&I!==null){m=void 0,S=b,F=I.memoizedProps,I=I.memoizedState,T=S.stateNode;try{var Kt=Nm(S.type,F);m=T.getSnapshotBeforeUpdate(Kt,I),T.__reactInternalSnapshotBeforeUpdate=m}catch(mn){Tr(S,S.return,mn)}}break;case 3:if((m&1024)!==0){if(m=b.stateNode.containerInfo,S=m.nodeType,S===9)fM(m);else if(S===1)switch(m.nodeName){case"HEAD":case"HTML":case"BODY":fM(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,ki=m;break}ki=b.return}}function vz(m,b,S){var T=S.flags;switch(S.tag){case 0:case 11:case 15:ld(m,S),T&4&&Dx(5,S);break;case 1:if(ld(m,S),T&4)if(m=S.stateNode,b===null)try{m.componentDidMount()}catch(ne){Tr(S,S.return,ne)}else{var F=Nm(S.type,b.memoizedProps);b=b.memoizedState;try{m.componentDidUpdate(F,b,m.__reactInternalSnapshotBeforeUpdate)}catch(ne){Tr(S,S.return,ne)}}T&64&&fz(S),T&512&&Rx(S,S.return);break;case 3:if(ld(m,S),T&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{a5(m,b)}catch(ne){Tr(S,S.return,ne)}}break;case 27:b===null&&T&4&&xz(S);case 26:case 5:ld(m,S),b===null&&T&4&&gz(S),T&512&&Rx(S,S.return);break;case 12:ld(m,S);break;case 31:ld(m,S),T&4&&_z(m,S);break;case 13:ld(m,S),T&4&&Nz(m,S),T&64&&(m=S.memoizedState,m!==null&&(m=m.dehydrated,m!==null&&(S=woe.bind(null,S),Boe(m,S))));break;case 22:if(T=S.memoizedState!==null||sd,!T){b=b!==null&&b.memoizedState!==null||Ya,F=sd;var I=Ya;sd=T,(Ya=b)&&!I?cd(m,S,(S.subtreeFlags&8772)!==0):ld(m,S),sd=F,Ya=I}break;case 30:break;default:ld(m,S)}}function wz(m){var b=m.alternate;b!==null&&(m.alternate=null,wz(b)),m.child=null,m.deletions=null,m.sibling=null,m.tag===5&&(b=m.stateNode,b!==null&&Ke(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 ha=null,$s=!1;function od(m,b,S){for(S=S.child;S!==null;)Sz(m,b,S),S=S.sibling}function Sz(m,b,S){if(ve&&typeof ve.onCommitFiberUnmount=="function")try{ve.onCommitFiberUnmount(pe,S)}catch{}switch(S.tag){case 26:Ya||dc(S,b),od(m,b,S),S.memoizedState?S.memoizedState.count--:S.stateNode&&(S=S.stateNode,S.parentNode.removeChild(S));break;case 27:Ya||dc(S,b);var T=ha,F=$s;Ou(S.type)&&(ha=S.stateNode,$s=!1),od(m,b,S),$x(S.stateNode),ha=T,$s=F;break;case 5:Ya||dc(S,b);case 6:if(T=ha,F=$s,ha=null,od(m,b,S),ha=T,$s=F,ha!==null)if($s)try{(ha.nodeType===9?ha.body:ha.nodeName==="HTML"?ha.ownerDocument.body:ha).removeChild(S.stateNode)}catch(I){Tr(S,b,I)}else try{ha.removeChild(S.stateNode)}catch(I){Tr(S,b,I)}break;case 18:ha!==null&&($s?(m=ha,fU(m.nodeType===9?m.body:m.nodeName==="HTML"?m.ownerDocument.body:m,S.stateNode),Op(m)):fU(ha,S.stateNode));break;case 4:T=ha,F=$s,ha=S.stateNode.containerInfo,$s=!0,od(m,b,S),ha=T,$s=F;break;case 0:case 11:case 14:case 15:Pu(2,S,b),Ya||Pu(4,S,b),od(m,b,S);break;case 1:Ya||(dc(S,b),T=S.stateNode,typeof T.componentWillUnmount=="function"&&pz(S,b,T)),od(m,b,S);break;case 21:od(m,b,S);break;case 22:Ya=(T=Ya)||S.memoizedState!==null,od(m,b,S),Ya=T;break;default:od(m,b,S)}}function _z(m,b){if(b.memoizedState===null&&(m=b.alternate,m!==null&&(m=m.memoizedState,m!==null))){m=m.dehydrated;try{Op(m)}catch(S){Tr(b,b.return,S)}}}function Nz(m,b){if(b.memoizedState===null&&(m=b.alternate,m!==null&&(m=m.memoizedState,m!==null&&(m=m.dehydrated,m!==null))))try{Op(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 yz),b;case 22:return m=m.stateNode,b=m._retryCache,b===null&&(b=m._retryCache=new yz),b;default:throw Error(r(435,m.tag))}}function Nw(m,b){var S=moe(m);b.forEach(function(T){if(!S.has(T)){S.add(T);var F=Soe.bind(null,m,T);T.then(F,F)}})}function Vs(m,b){var S=b.deletions;if(S!==null)for(var T=0;T<S.length;T++){var F=S[T],I=m,ne=b,Ee=ne;e:for(;Ee!==null;){switch(Ee.tag){case 27:if(Ou(Ee.type)){ha=Ee.stateNode,$s=!1;break e}break;case 5:ha=Ee.stateNode,$s=!1;break e;case 3:case 4:ha=Ee.stateNode.containerInfo,$s=!0;break e}Ee=Ee.return}if(ha===null)throw Error(r(160));Sz(I,ne,F),ha=null,$s=!1,I=F.alternate,I!==null&&(I.return=null),F.return=null}if(b.subtreeFlags&13886)for(b=b.child;b!==null;)Cz(b,m),b=b.sibling}var jl=null;function Cz(m,b){var S=m.alternate,T=m.flags;switch(m.tag){case 0:case 11:case 14:case 15:Vs(b,m),qs(m),T&4&&(Pu(3,m,m.return),Dx(3,m),Pu(5,m,m.return));break;case 1:Vs(b,m),qs(m),T&512&&(Ya||S===null||dc(S,S.return)),T&64&&sd&&(m=m.updateQueue,m!==null&&(T=m.callbacks,T!==null&&(S=m.shared.hiddenCallbacks,m.shared.hiddenCallbacks=S===null?T:S.concat(T))));break;case 26:var F=jl;if(Vs(b,m),qs(m),T&512&&(Ya||S===null||dc(S,S.return)),T&4){var I=S!==null?S.memoizedState:null;if(T=m.memoizedState,S===null)if(T===null)if(m.stateNode===null){e:{T=m.type,S=m.memoizedProps,F=F.ownerDocument||F;t:switch(T){case"title":I=F.getElementsByTagName("title")[0],(!I||I[it]||I[Gn]||I.namespaceURI==="http://www.w3.org/2000/svg"||I.hasAttribute("itemprop"))&&(I=F.createElement(T),F.head.insertBefore(I,F.querySelector("head > title"))),Vi(I,T,S),I[Gn]=m,Xe(I),T=I;break e;case"link":var ne=CU("link","href",F).get(T+(S.href||""));if(ne){for(var Ee=0;Ee<ne.length;Ee++)if(I=ne[Ee],I.getAttribute("href")===(S.href==null||S.href===""?null:S.href)&&I.getAttribute("rel")===(S.rel==null?null:S.rel)&&I.getAttribute("title")===(S.title==null?null:S.title)&&I.getAttribute("crossorigin")===(S.crossOrigin==null?null:S.crossOrigin)){ne.splice(Ee,1);break t}}I=F.createElement(T),Vi(I,T,S),F.head.appendChild(I);break;case"meta":if(ne=CU("meta","content",F).get(T+(S.content||""))){for(Ee=0;Ee<ne.length;Ee++)if(I=ne[Ee],I.getAttribute("content")===(S.content==null?null:""+S.content)&&I.getAttribute("name")===(S.name==null?null:S.name)&&I.getAttribute("property")===(S.property==null?null:S.property)&&I.getAttribute("http-equiv")===(S.httpEquiv==null?null:S.httpEquiv)&&I.getAttribute("charset")===(S.charSet==null?null:S.charSet)){ne.splice(Ee,1);break t}}I=F.createElement(T),Vi(I,T,S),F.head.appendChild(I);break;default:throw Error(r(468,T))}I[Gn]=m,Xe(I),T=I}m.stateNode=T}else kU(F,m.type,m.stateNode);else m.stateNode=NU(F,T,m.memoizedProps);else I!==T?(I===null?S.stateNode!==null&&(S=S.stateNode,S.parentNode.removeChild(S)):I.count--,T===null?kU(F,m.type,m.stateNode):NU(F,T,m.memoizedProps)):T===null&&m.stateNode!==null&&UT(m,m.memoizedProps,S.memoizedProps)}break;case 27:Vs(b,m),qs(m),T&512&&(Ya||S===null||dc(S,S.return)),S!==null&&T&4&&UT(m,m.memoizedProps,S.memoizedProps);break;case 5:if(Vs(b,m),qs(m),T&512&&(Ya||S===null||dc(S,S.return)),m.flags&32){F=m.stateNode;try{aa(F,"")}catch(Kt){Tr(m,m.return,Kt)}}T&4&&m.stateNode!=null&&(F=m.memoizedProps,UT(m,F,S!==null?S.memoizedProps:F)),T&1024&&($T=!0);break;case 6:if(Vs(b,m),qs(m),T&4){if(m.stateNode===null)throw Error(r(162));T=m.memoizedProps,S=m.stateNode;try{S.nodeValue=T}catch(Kt){Tr(m,m.return,Kt)}}break;case 3:if(Uw=null,F=jl,jl=Iw(b.containerInfo),Vs(b,m),jl=F,qs(m),T&4&&S!==null&&S.memoizedState.isDehydrated)try{Op(b.containerInfo)}catch(Kt){Tr(m,m.return,Kt)}$T&&($T=!1,kz(m));break;case 4:T=jl,jl=Iw(m.stateNode.containerInfo),Vs(b,m),qs(m),jl=T;break;case 12:Vs(b,m),qs(m);break;case 31:Vs(b,m),qs(m),T&4&&(T=m.updateQueue,T!==null&&(m.updateQueue=null,Nw(m,T)));break;case 13:Vs(b,m),qs(m),m.child.flags&8192&&m.memoizedState!==null!=(S!==null&&S.memoizedState!==null)&&(kw=R()),T&4&&(T=m.updateQueue,T!==null&&(m.updateQueue=null,Nw(m,T)));break;case 22:F=m.memoizedState!==null;var Ge=S!==null&&S.memoizedState!==null,ht=sd,wt=Ya;if(sd=ht||F,Ya=wt||Ge,Vs(b,m),Ya=wt,sd=ht,qs(m),T&8192)e:for(b=m.stateNode,b._visibility=F?b._visibility&-2:b._visibility|1,F&&(S===null||Ge||sd||Ya||Cm(m)),S=null,b=m;;){if(b.tag===5||b.tag===26){if(S===null){Ge=S=b;try{if(I=Ge.stateNode,F)ne=I.style,typeof ne.setProperty=="function"?ne.setProperty("display","none","important"):ne.display="none";else{Ee=Ge.stateNode;var Ct=Ge.memoizedProps.style,ft=Ct!=null&&Ct.hasOwnProperty("display")?Ct.display:null;Ee.style.display=ft==null||typeof ft=="boolean"?"":(""+ft).trim()}}catch(Kt){Tr(Ge,Ge.return,Kt)}}}else if(b.tag===6){if(S===null){Ge=b;try{Ge.stateNode.nodeValue=F?"":Ge.memoizedProps}catch(Kt){Tr(Ge,Ge.return,Kt)}}}else if(b.tag===18){if(S===null){Ge=b;try{var xt=Ge.stateNode;F?pU(xt,!0):pU(Ge.stateNode,!1)}catch(Kt){Tr(Ge,Ge.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}T&4&&(T=m.updateQueue,T!==null&&(S=T.retryQueue,S!==null&&(T.retryQueue=null,Nw(m,S))));break;case 19:Vs(b,m),qs(m),T&4&&(T=m.updateQueue,T!==null&&(m.updateQueue=null,Nw(m,T)));break;case 30:break;case 21:break;default:Vs(b,m),qs(m)}}function qs(m){var b=m.flags;if(b&2){try{for(var S,T=m.return;T!==null;){if(bz(T)){S=T;break}T=T.return}if(S==null)throw Error(r(160));switch(S.tag){case 27:var F=S.stateNode,I=BT(m);_w(m,I,F);break;case 5:var ne=S.stateNode;S.flags&32&&(aa(ne,""),S.flags&=-33);var Ee=BT(m);_w(m,Ee,ne);break;case 3:case 4:var Ge=S.stateNode.containerInfo,ht=BT(m);HT(m,ht,Ge);break;default:throw Error(r(161))}}catch(wt){Tr(m,m.return,wt)}m.flags&=-3}b&4096&&(m.flags&=-4097)}function kz(m){if(m.subtreeFlags&1024)for(m=m.child;m!==null;){var b=m;kz(b),b.tag===5&&b.flags&1024&&b.stateNode.reset(),m=m.sibling}}function ld(m,b){if(b.subtreeFlags&8772)for(b=b.child;b!==null;)vz(m,b.alternate,b),b=b.sibling}function Cm(m){for(m=m.child;m!==null;){var b=m;switch(b.tag){case 0:case 11:case 14:case 15:Pu(4,b,b.return),Cm(b);break;case 1:dc(b,b.return);var S=b.stateNode;typeof S.componentWillUnmount=="function"&&pz(b,b.return,S),Cm(b);break;case 27:$x(b.stateNode);case 26:case 5:dc(b,b.return),Cm(b);break;case 22:b.memoizedState===null&&Cm(b);break;case 30:Cm(b);break;default:Cm(b)}m=m.sibling}}function cd(m,b,S){for(S=S&&(b.subtreeFlags&8772)!==0,b=b.child;b!==null;){var T=b.alternate,F=m,I=b,ne=I.flags;switch(I.tag){case 0:case 11:case 15:cd(F,I,S),Dx(4,I);break;case 1:if(cd(F,I,S),T=I,F=T.stateNode,typeof F.componentDidMount=="function")try{F.componentDidMount()}catch(ht){Tr(T,T.return,ht)}if(T=I,F=T.updateQueue,F!==null){var Ee=T.stateNode;try{var Ge=F.shared.hiddenCallbacks;if(Ge!==null)for(F.shared.hiddenCallbacks=null,F=0;F<Ge.length;F++)r5(Ge[F],Ee)}catch(ht){Tr(T,T.return,ht)}}S&&ne&64&&fz(I),Rx(I,I.return);break;case 27:xz(I);case 26:case 5:cd(F,I,S),S&&T===null&&ne&4&&gz(I),Rx(I,I.return);break;case 12:cd(F,I,S);break;case 31:cd(F,I,S),S&&ne&4&&_z(F,I);break;case 13:cd(F,I,S),S&&ne&4&&Nz(F,I);break;case 22:I.memoizedState===null&&cd(F,I,S),Rx(I,I.return);break;case 30:break;default:cd(F,I,S)}b=b.sibling}}function VT(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&&vx(S))}function qT(m,b){m=null,b.alternate!==null&&(m=b.alternate.memoizedState.cache),b=b.memoizedState.cache,b!==m&&(b.refCount++,m!=null&&vx(m))}function Dl(m,b,S,T){if(b.subtreeFlags&10256)for(b=b.child;b!==null;)Az(m,b,S,T),b=b.sibling}function Az(m,b,S,T){var F=b.flags;switch(b.tag){case 0:case 11:case 15:Dl(m,b,S,T),F&2048&&Dx(9,b);break;case 1:Dl(m,b,S,T);break;case 3:Dl(m,b,S,T),F&2048&&(m=null,b.alternate!==null&&(m=b.alternate.memoizedState.cache),b=b.memoizedState.cache,b!==m&&(b.refCount++,m!=null&&vx(m)));break;case 12:if(F&2048){Dl(m,b,S,T),m=b.stateNode;try{var I=b.memoizedProps,ne=I.id,Ee=I.onPostCommit;typeof Ee=="function"&&Ee(ne,b.alternate===null?"mount":"update",m.passiveEffectDuration,-0)}catch(Ge){Tr(b,b.return,Ge)}}else Dl(m,b,S,T);break;case 31:Dl(m,b,S,T);break;case 13:Dl(m,b,S,T);break;case 23:break;case 22:I=b.stateNode,ne=b.alternate,b.memoizedState!==null?I._visibility&2?Dl(m,b,S,T):Fx(m,b):I._visibility&2?Dl(m,b,S,T):(I._visibility|=2,kp(m,b,S,T,(b.subtreeFlags&10256)!==0||!1)),F&2048&&VT(ne,b);break;case 24:Dl(m,b,S,T),F&2048&&qT(b.alternate,b);break;default:Dl(m,b,S,T)}}function kp(m,b,S,T,F){for(F=F&&((b.subtreeFlags&10256)!==0||!1),b=b.child;b!==null;){var I=m,ne=b,Ee=S,Ge=T,ht=ne.flags;switch(ne.tag){case 0:case 11:case 15:kp(I,ne,Ee,Ge,F),Dx(8,ne);break;case 23:break;case 22:var wt=ne.stateNode;ne.memoizedState!==null?wt._visibility&2?kp(I,ne,Ee,Ge,F):Fx(I,ne):(wt._visibility|=2,kp(I,ne,Ee,Ge,F)),F&&ht&2048&&VT(ne.alternate,ne);break;case 24:kp(I,ne,Ee,Ge,F),F&&ht&2048&&qT(ne.alternate,ne);break;default:kp(I,ne,Ee,Ge,F)}b=b.sibling}}function Fx(m,b){if(b.subtreeFlags&10256)for(b=b.child;b!==null;){var S=m,T=b,F=T.flags;switch(T.tag){case 22:Fx(S,T),F&2048&&VT(T.alternate,T);break;case 24:Fx(S,T),F&2048&&qT(T.alternate,T);break;default:Fx(S,T)}b=b.sibling}}var Lx=8192;function Ap(m,b,S){if(m.subtreeFlags&Lx)for(m=m.child;m!==null;)Tz(m,b,S),m=m.sibling}function Tz(m,b,S){switch(m.tag){case 26:Ap(m,b,S),m.flags&Lx&&m.memoizedState!==null&&Joe(S,jl,m.memoizedState,m.memoizedProps);break;case 5:Ap(m,b,S);break;case 3:case 4:var T=jl;jl=Iw(m.stateNode.containerInfo),Ap(m,b,S),jl=T;break;case 22:m.memoizedState===null&&(T=m.alternate,T!==null&&T.memoizedState!==null?(T=Lx,Lx=16777216,Ap(m,b,S),Lx=T):Ap(m,b,S));break;default:Ap(m,b,S)}}function Mz(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 Ox(m){var b=m.deletions;if((m.flags&16)!==0){if(b!==null)for(var S=0;S<b.length;S++){var T=b[S];ki=T,Ez(T,m)}Mz(m)}if(m.subtreeFlags&10256)for(m=m.child;m!==null;)Pz(m),m=m.sibling}function Pz(m){switch(m.tag){case 0:case 11:case 15:Ox(m),m.flags&2048&&Pu(9,m,m.return);break;case 3:Ox(m);break;case 12:Ox(m);break;case 22:var b=m.stateNode;m.memoizedState!==null&&b._visibility&2&&(m.return===null||m.return.tag!==13)?(b._visibility&=-3,Cw(m)):Ox(m);break;default:Ox(m)}}function Cw(m){var b=m.deletions;if((m.flags&16)!==0){if(b!==null)for(var S=0;S<b.length;S++){var T=b[S];ki=T,Ez(T,m)}Mz(m)}for(m=m.child;m!==null;){switch(b=m,b.tag){case 0:case 11:case 15:Pu(8,b,b.return),Cw(b);break;case 22:S=b.stateNode,S._visibility&2&&(S._visibility&=-3,Cw(b));break;default:Cw(b)}m=m.sibling}}function Ez(m,b){for(;ki!==null;){var S=ki;switch(S.tag){case 0:case 11:case 15:Pu(8,S,b);break;case 23:case 22:if(S.memoizedState!==null&&S.memoizedState.cachePool!==null){var T=S.memoizedState.cachePool.pool;T!=null&&T.refCount++}break;case 24:vx(S.memoizedState.cache)}if(T=S.child,T!==null)T.return=S,ki=T;else e:for(S=m;ki!==null;){T=ki;var F=T.sibling,I=T.return;if(wz(T),T===S){ki=null;break e}if(F!==null){F.return=I,ki=F;break e}ki=I}}}var foe={getCacheForType:function(m){var b=Hi(Wa),S=b.data.get(m);return S===void 0&&(S=m(),b.data.set(m,S)),S},cacheSignal:function(){return Hi(Wa).controller.signal}},poe=typeof WeakMap=="function"?WeakMap:Map,xr=0,Gr=null,Wn=null,Jn=0,Ar=0,yo=null,Eu=!1,Tp=!1,GT=!1,dd=0,Aa=0,ju=0,km=0,WT=0,vo=0,Mp=0,Ix=null,Gs=null,KT=!1,kw=0,jz=0,Aw=1/0,Tw=null,Du=null,ci=0,Ru=null,Pp=null,ud=0,XT=0,YT=null,Dz=null,zx=0,QT=null;function wo(){return(xr&2)!==0&&Jn!==0?Jn&-Jn:q.T!==null?rM():gr()}function Rz(){if(vo===0)if((Jn&536870912)===0||rr){var m=De;De<<=1,(De&3932160)===0&&(De=262144),vo=m}else vo=536870912;return m=bo.current,m!==null&&(m.flags|=32),vo}function Ws(m,b,S){(m===Gr&&(Ar===2||Ar===9)||m.cancelPendingCommit!==null)&&(Ep(m,0),Fu(m,Jn,vo,!1)),Vt(m,S),((xr&2)===0||m!==Gr)&&(m===Gr&&((xr&2)===0&&(km|=S),Aa===4&&Fu(m,Jn,vo,!1)),uc(m))}function Fz(m,b,S){if((xr&6)!==0)throw Error(r(327));var T=!S&&(b&127)===0&&(b&m.expiredLanes)===0||Ve(m,b),F=T?xoe(m,b):JT(m,b,!0),I=T;do{if(F===0){Tp&&!T&&Fu(m,b,0,!1);break}else{if(S=m.current.alternate,I&&!goe(S)){F=JT(m,b,!1),I=!1;continue}if(F===2){if(I=b,m.errorRecoveryDisabledLanes&I)var ne=0;else ne=m.pendingLanes&-536870913,ne=ne!==0?ne:ne&536870912?536870912:0;if(ne!==0){b=ne;e:{var Ee=m;F=Ix;var Ge=Ee.current.memoizedState.isDehydrated;if(Ge&&(Ep(Ee,ne).flags|=256),ne=JT(Ee,ne,!1),ne!==2){if(GT&&!Ge){Ee.errorRecoveryDisabledLanes|=I,km|=I,F=4;break e}I=Gs,Gs=F,I!==null&&(Gs===null?Gs=I:Gs.push.apply(Gs,I))}F=ne}if(I=!1,F!==2)continue}}if(F===1){Ep(m,0),Fu(m,b,0,!0);break}e:{switch(T=m,I=F,I){case 0:case 1:throw Error(r(345));case 4:if((b&4194048)!==b)break;case 6:Fu(T,b,vo,!Eu);break e;case 2:Gs=null;break;case 3:case 5:break;default:throw Error(r(329))}if((b&62914560)===b&&(F=kw+300-R(),10<F)){if(Fu(T,b,vo,!Eu),je(T,0,!0)!==0)break e;ud=b,T.timeoutHandle=hU(Lz.bind(null,T,S,Gs,Tw,KT,b,vo,km,Mp,Eu,I,"Throttled",-0,0),F);break e}Lz(T,S,Gs,Tw,KT,b,vo,km,Mp,Eu,I,null,-0,0)}}break}while(!0);uc(m)}function Lz(m,b,S,T,F,I,ne,Ee,Ge,ht,wt,Ct,ft,xt){if(m.timeoutHandle=-1,Ct=b.subtreeFlags,Ct&8192||(Ct&16785408)===16785408){Ct={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:dr},Tz(b,I,Ct);var Kt=(I&62914560)===I?kw-R():(I&4194048)===I?jz-R():0;if(Kt=ele(Ct,Kt),Kt!==null){ud=I,m.cancelPendingCommit=Kt(Vz.bind(null,m,b,I,S,T,F,ne,Ee,Ge,wt,Ct,null,ft,xt)),Fu(m,I,ne,!ht);return}}Vz(m,b,I,S,T,F,ne,Ee,Ge)}function goe(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 T=0;T<S.length;T++){var F=S[T],I=F.getSnapshot;F=F.value;try{if(!po(I(),F))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 Fu(m,b,S,T){b&=~WT,b&=~km,m.suspendedLanes|=b,m.pingedLanes&=~b,T&&(m.warmLanes|=b),T=m.expirationTimes;for(var F=b;0<F;){var I=31-xe(F),ne=1<<I;T[I]=-1,F&=~ne}S!==0&&Be(m,S,b)}function Mw(){return(xr&6)===0?(Ux(0),!1):!0}function ZT(){if(Wn!==null){if(Ar===0)var m=Wn.return;else m=Wn,ed=bm=null,fT(m),wp=null,Sx=0,m=Wn;for(;m!==null;)mz(m.alternate,m),m=m.return;Wn=null}}function Ep(m,b){var S=m.timeoutHandle;S!==-1&&(m.timeoutHandle=-1,Loe(S)),S=m.cancelPendingCommit,S!==null&&(m.cancelPendingCommit=null,S()),ud=0,ZT(),Gr=m,Wn=S=Zc(m.current,null),Jn=b,Ar=0,yo=null,Eu=!1,Tp=Ve(m,b),GT=!1,Mp=vo=WT=km=ju=Aa=0,Gs=Ix=null,KT=!1,(b&8)!==0&&(b|=b&32);var T=m.entangledLanes;if(T!==0)for(m=m.entanglements,T&=b;0<T;){var F=31-xe(T),I=1<<F;b|=m[F],T&=~I}return dd=b,Yv(),S}function Oz(m,b){En=null,q.H=Px,b===vp||b===aw?(b=JI(),Ar=3):b===nT?(b=JI(),Ar=4):Ar=b===PT?8:b!==null&&typeof b=="object"&&typeof b.then=="function"?6:1,yo=b,Wn===null&&(Aa=1,xw(m,Ho(b,m.current)))}function Iz(){var m=bo.current;return m===null?!0:(Jn&4194048)===Jn?Go===null:(Jn&62914560)===Jn||(Jn&536870912)!==0?m===Go:!1}function zz(){var m=q.H;return q.H=Px,m===null?Px:m}function Uz(){var m=q.A;return q.A=foe,m}function Pw(){Aa=4,Eu||(Jn&4194048)!==Jn&&bo.current!==null||(Tp=!0),(ju&134217727)===0&&(km&134217727)===0||Gr===null||Fu(Gr,Jn,vo,!1)}function JT(m,b,S){var T=xr;xr|=2;var F=zz(),I=Uz();(Gr!==m||Jn!==b)&&(Tw=null,Ep(m,b)),b=!1;var ne=Aa;e:do try{if(Ar!==0&&Wn!==null){var Ee=Wn,Ge=yo;switch(Ar){case 8:ZT(),ne=6;break e;case 3:case 2:case 9:case 6:bo.current===null&&(b=!0);var ht=Ar;if(Ar=0,yo=null,jp(m,Ee,Ge,ht),S&&Tp){ne=0;break e}break;default:ht=Ar,Ar=0,yo=null,jp(m,Ee,Ge,ht)}}boe(),ne=Aa;break}catch(wt){Oz(m,wt)}while(!0);return b&&m.shellSuspendCounter++,ed=bm=null,xr=T,q.H=F,q.A=I,Wn===null&&(Gr=null,Jn=0,Yv()),ne}function boe(){for(;Wn!==null;)Bz(Wn)}function xoe(m,b){var S=xr;xr|=2;var T=zz(),F=Uz();Gr!==m||Jn!==b?(Tw=null,Aw=R()+500,Ep(m,b)):Tp=Ve(m,b);e:do try{if(Ar!==0&&Wn!==null){b=Wn;var I=yo;t:switch(Ar){case 1:Ar=0,yo=null,jp(m,b,I,1);break;case 2:case 9:if(QI(I)){Ar=0,yo=null,Hz(b);break}b=function(){Ar!==2&&Ar!==9||Gr!==m||(Ar=7),uc(m)},I.then(b,b);break e;case 3:Ar=7;break e;case 4:Ar=5;break e;case 7:QI(I)?(Ar=0,yo=null,Hz(b)):(Ar=0,yo=null,jp(m,b,I,7));break;case 5:var ne=null;switch(Wn.tag){case 26:ne=Wn.memoizedState;case 5:case 27:var Ee=Wn;if(ne?AU(ne):Ee.stateNode.complete){Ar=0,yo=null;var Ge=Ee.sibling;if(Ge!==null)Wn=Ge;else{var ht=Ee.return;ht!==null?(Wn=ht,Ew(ht)):Wn=null}break t}}Ar=0,yo=null,jp(m,b,I,5);break;case 6:Ar=0,yo=null,jp(m,b,I,6);break;case 8:ZT(),Aa=6;break e;default:throw Error(r(462))}}yoe();break}catch(wt){Oz(m,wt)}while(!0);return ed=bm=null,q.H=T,q.A=F,xr=S,Wn!==null?0:(Gr=null,Jn=0,Yv(),Aa)}function yoe(){for(;Wn!==null&&!be();)Bz(Wn)}function Bz(m){var b=uz(m.alternate,m,dd);m.memoizedProps=m.pendingProps,b===null?Ew(m):Wn=b}function Hz(m){var b=m,S=b.alternate;switch(b.tag){case 15:case 0:b=iz(S,b,b.pendingProps,b.type,void 0,Jn);break;case 11:b=iz(S,b,b.pendingProps,b.type.render,b.ref,Jn);break;case 5:fT(b);default:mz(S,b),b=Wn=UI(b,dd),b=uz(S,b,dd)}m.memoizedProps=m.pendingProps,b===null?Ew(m):Wn=b}function jp(m,b,S,T){ed=bm=null,fT(b),wp=null,Sx=0;var F=b.return;try{if(ooe(m,F,b,S,Jn)){Aa=1,xw(m,Ho(S,m.current)),Wn=null;return}}catch(I){if(F!==null)throw Wn=F,I;Aa=1,xw(m,Ho(S,m.current)),Wn=null;return}b.flags&32768?(rr||T===1?m=!0:Tp||(Jn&536870912)!==0?m=!1:(Eu=m=!0,(T===2||T===9||T===3||T===6)&&(T=bo.current,T!==null&&T.tag===13&&(T.flags|=16384))),$z(b,m)):Ew(b)}function Ew(m){var b=m;do{if((b.flags&32768)!==0){$z(b,Eu);return}m=b.return;var S=doe(b.alternate,b,dd);if(S!==null){Wn=S;return}if(b=b.sibling,b!==null){Wn=b;return}Wn=b=m}while(b!==null);Aa===0&&(Aa=5)}function $z(m,b){do{var S=uoe(m.alternate,m);if(S!==null){S.flags&=32767,Wn=S;return}if(S=m.return,S!==null&&(S.flags|=32768,S.subtreeFlags=0,S.deletions=null),!b&&(m=m.sibling,m!==null)){Wn=m;return}Wn=m=S}while(m!==null);Aa=6,Wn=null}function Vz(m,b,S,T,F,I,ne,Ee,Ge){m.cancelPendingCommit=null;do jw();while(ci!==0);if((xr&6)!==0)throw Error(r(327));if(b!==null){if(b===m.current)throw Error(r(177));if(I=b.lanes|b.childLanes,I|=BA,At(m,S,I,ne,Ee,Ge),m===Gr&&(Wn=Gr=null,Jn=0),Pp=b,Ru=m,ud=S,XT=I,YT=F,Dz=T,(b.subtreeFlags&10256)!==0||(b.flags&10256)!==0?(m.callbackNode=null,m.callbackPriority=0,_oe(ae,function(){return Xz(),null})):(m.callbackNode=null,m.callbackPriority=0),T=(b.flags&13878)!==0,(b.subtreeFlags&13878)!==0||T){T=q.T,q.T=null,F=z.p,z.p=2,ne=xr,xr|=4;try{hoe(m,b,S)}finally{xr=ne,z.p=F,q.T=T}}ci=1,qz(),Gz(),Wz()}}function qz(){if(ci===1){ci=0;var m=Ru,b=Pp,S=(b.flags&13878)!==0;if((b.subtreeFlags&13878)!==0||S){S=q.T,q.T=null;var T=z.p;z.p=2;var F=xr;xr|=4;try{Cz(b,m);var I=uM,ne=EI(m.containerInfo),Ee=I.focusedElem,Ge=I.selectionRange;if(ne!==Ee&&Ee&&Ee.ownerDocument&&PI(Ee.ownerDocument.documentElement,Ee)){if(Ge!==null&&LA(Ee)){var ht=Ge.start,wt=Ge.end;if(wt===void 0&&(wt=ht),"selectionStart"in Ee)Ee.selectionStart=ht,Ee.selectionEnd=Math.min(wt,Ee.value.length);else{var Ct=Ee.ownerDocument||document,ft=Ct&&Ct.defaultView||window;if(ft.getSelection){var xt=ft.getSelection(),Kt=Ee.textContent.length,mn=Math.min(Ge.start,Kt),Lr=Ge.end===void 0?mn:Math.min(Ge.end,Kt);!xt.extend&&mn>Lr&&(ne=Lr,Lr=mn,mn=ne);var rt=MI(Ee,mn),Qe=MI(Ee,Lr);if(rt&&Qe&&(xt.rangeCount!==1||xt.anchorNode!==rt.node||xt.anchorOffset!==rt.offset||xt.focusNode!==Qe.node||xt.focusOffset!==Qe.offset)){var ut=Ct.createRange();ut.setStart(rt.node,rt.offset),xt.removeAllRanges(),mn>Lr?(xt.addRange(ut),xt.extend(Qe.node,Qe.offset)):(ut.setEnd(Qe.node,Qe.offset),xt.addRange(ut))}}}}for(Ct=[],xt=Ee;xt=xt.parentNode;)xt.nodeType===1&&Ct.push({element:xt,left:xt.scrollLeft,top:xt.scrollTop});for(typeof Ee.focus=="function"&&Ee.focus(),Ee=0;Ee<Ct.length;Ee++){var _t=Ct[Ee];_t.element.scrollLeft=_t.left,_t.element.scrollTop=_t.top}}Vw=!!dM,uM=dM=null}finally{xr=F,z.p=T,q.T=S}}m.current=b,ci=2}}function Gz(){if(ci===2){ci=0;var m=Ru,b=Pp,S=(b.flags&8772)!==0;if((b.subtreeFlags&8772)!==0||S){S=q.T,q.T=null;var T=z.p;z.p=2;var F=xr;xr|=4;try{vz(m,b.alternate,b)}finally{xr=F,z.p=T,q.T=S}}ci=3}}function Wz(){if(ci===4||ci===3){ci=0,O();var m=Ru,b=Pp,S=ud,T=Dz;(b.subtreeFlags&10256)!==0||(b.flags&10256)!==0?ci=5:(ci=0,Pp=Ru=null,Kz(m,m.pendingLanes));var F=m.pendingLanes;if(F===0&&(Du=null),yn(S),b=b.stateNode,ve&&typeof ve.onCommitFiberRoot=="function")try{ve.onCommitFiberRoot(pe,b,void 0,(b.current.flags&128)===128)}catch{}if(T!==null){b=q.T,F=z.p,z.p=2,q.T=null;try{for(var I=m.onRecoverableError,ne=0;ne<T.length;ne++){var Ee=T[ne];I(Ee.value,{componentStack:Ee.stack})}}finally{q.T=b,z.p=F}}(ud&3)!==0&&jw(),uc(m),F=m.pendingLanes,(S&261930)!==0&&(F&42)!==0?m===QT?zx++:(zx=0,QT=m):zx=0,Ux(0)}}function Kz(m,b){(m.pooledCacheLanes&=b)===0&&(b=m.pooledCache,b!=null&&(m.pooledCache=null,vx(b)))}function jw(){return qz(),Gz(),Wz(),Xz()}function Xz(){if(ci!==5)return!1;var m=Ru,b=XT;XT=0;var S=yn(ud),T=q.T,F=z.p;try{z.p=32>S?32:S,q.T=null,S=YT,YT=null;var I=Ru,ne=ud;if(ci=0,Pp=Ru=null,ud=0,(xr&6)!==0)throw Error(r(331));var Ee=xr;if(xr|=4,Pz(I.current),Az(I,I.current,ne,S),xr=Ee,Ux(0,!1),ve&&typeof ve.onPostCommitFiberRoot=="function")try{ve.onPostCommitFiberRoot(pe,I)}catch{}return!0}finally{z.p=F,q.T=T,Kz(m,b)}}function Yz(m,b,S){b=Ho(S,b),b=MT(m.stateNode,b,2),m=Au(m,b,2),m!==null&&(Vt(m,2),uc(m))}function Tr(m,b,S){if(m.tag===3)Yz(m,m,S);else for(;b!==null;){if(b.tag===3){Yz(b,m,S);break}else if(b.tag===1){var T=b.stateNode;if(typeof b.type.getDerivedStateFromError=="function"||typeof T.componentDidCatch=="function"&&(Du===null||!Du.has(T))){m=Ho(S,m),S=Q5(2),T=Au(b,S,2),T!==null&&(Z5(S,T,b,m),Vt(T,2),uc(T));break}}b=b.return}}function eM(m,b,S){var T=m.pingCache;if(T===null){T=m.pingCache=new poe;var F=new Set;T.set(b,F)}else F=T.get(b),F===void 0&&(F=new Set,T.set(b,F));F.has(S)||(GT=!0,F.add(S),m=voe.bind(null,m,b,S),b.then(m,m))}function voe(m,b,S){var T=m.pingCache;T!==null&&T.delete(b),m.pingedLanes|=m.suspendedLanes&S,m.warmLanes&=~S,Gr===m&&(Jn&S)===S&&(Aa===4||Aa===3&&(Jn&62914560)===Jn&&300>R()-kw?(xr&2)===0&&Ep(m,0):WT|=S,Mp===Jn&&(Mp=0)),uc(m)}function Qz(m,b){b===0&&(b=kt()),m=fm(m,b),m!==null&&(Vt(m,b),uc(m))}function woe(m){var b=m.memoizedState,S=0;b!==null&&(S=b.retryLane),Qz(m,S)}function Soe(m,b){var S=0;switch(m.tag){case 31:case 13:var T=m.stateNode,F=m.memoizedState;F!==null&&(S=F.retryLane);break;case 19:T=m.stateNode;break;case 22:T=m.stateNode._retryCache;break;default:throw Error(r(314))}T!==null&&T.delete(b),Qz(m,S)}function _oe(m,b){return Fe(m,b)}var Dw=null,Dp=null,tM=!1,Rw=!1,nM=!1,Lu=0;function uc(m){m!==Dp&&m.next===null&&(Dp===null?Dw=Dp=m:Dp=Dp.next=m),Rw=!0,tM||(tM=!0,Coe())}function Ux(m,b){if(!nM&&Rw){nM=!0;do for(var S=!1,T=Dw;T!==null;){if(m!==0){var F=T.pendingLanes;if(F===0)var I=0;else{var ne=T.suspendedLanes,Ee=T.pingedLanes;I=(1<<31-xe(42|m)+1)-1,I&=F&~(ne&~Ee),I=I&201326741?I&201326741|1:I?I|2:0}I!==0&&(S=!0,tU(T,I))}else I=Jn,I=je(T,T===Gr?I:0,T.cancelPendingCommit!==null||T.timeoutHandle!==-1),(I&3)===0||Ve(T,I)||(S=!0,tU(T,I));T=T.next}while(S);nM=!1}}function Noe(){Zz()}function Zz(){Rw=tM=!1;var m=0;Lu!==0&&Foe()&&(m=Lu);for(var b=R(),S=null,T=Dw;T!==null;){var F=T.next,I=Jz(T,b);I===0?(T.next=null,S===null?Dw=F:S.next=F,F===null&&(Dp=S)):(S=T,(m!==0||(I&3)!==0)&&(Rw=!0)),T=F}ci!==0&&ci!==5||Ux(m),Lu!==0&&(Lu=0)}function Jz(m,b){for(var S=m.suspendedLanes,T=m.pingedLanes,F=m.expirationTimes,I=m.pendingLanes&-62914561;0<I;){var ne=31-xe(I),Ee=1<<ne,Ge=F[ne];Ge===-1?((Ee&S)===0||(Ee&T)!==0)&&(F[ne]=ot(Ee,b)):Ge<=b&&(m.expiredLanes|=Ee),I&=~Ee}if(b=Gr,S=Jn,S=je(m,m===b?S:0,m.cancelPendingCommit!==null||m.timeoutHandle!==-1),T=m.callbackNode,S===0||m===b&&(Ar===2||Ar===9)||m.cancelPendingCommit!==null)return T!==null&&T!==null&&Pe(T),m.callbackNode=null,m.callbackPriority=0;if((S&3)===0||Ve(m,S)){if(b=S&-S,b===m.callbackPriority)return b;switch(T!==null&&Pe(T),yn(S)){case 2:case 8:S=ge;break;case 32:S=ae;break;case 268435456:S=ze;break;default:S=ae}return T=eU.bind(null,m),S=Fe(S,T),m.callbackPriority=b,m.callbackNode=S,b}return T!==null&&T!==null&&Pe(T),m.callbackPriority=2,m.callbackNode=null,2}function eU(m,b){if(ci!==0&&ci!==5)return m.callbackNode=null,m.callbackPriority=0,null;var S=m.callbackNode;if(jw()&&m.callbackNode!==S)return null;var T=Jn;return T=je(m,m===Gr?T:0,m.cancelPendingCommit!==null||m.timeoutHandle!==-1),T===0?null:(Fz(m,T,b),Jz(m,R()),m.callbackNode!=null&&m.callbackNode===S?eU.bind(null,m):null)}function tU(m,b){if(jw())return null;Fz(m,b,!0)}function Coe(){Ooe(function(){(xr&6)!==0?Fe(de,Noe):Zz()})}function rM(){if(Lu===0){var m=xp;m===0&&(m=nt,nt<<=1,(nt&261888)===0&&(nt=256)),Lu=m}return Lu}function nU(m){return m==null||typeof m=="symbol"||typeof m=="boolean"?null:typeof m=="function"?m:Zn(""+m)}function rU(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 koe(m,b,S,T,F){if(b==="submit"&&S&&S.stateNode===F){var I=nU((F[br]||null).action),ne=T.submitter;ne&&(b=(b=ne[br]||null)?nU(b.formAction):ne.getAttribute("formAction"),b!==null&&(I=b,ne=null));var Ee=new kr("action","action",null,T,F);m.push({event:Ee,listeners:[{instance:null,listener:function(){if(T.defaultPrevented){if(Lu!==0){var Ge=ne?rU(F,ne):new FormData(F);_T(S,{pending:!0,data:Ge,method:F.method,action:I},null,Ge)}}else typeof I=="function"&&(Ee.preventDefault(),Ge=ne?rU(F,ne):new FormData(F),_T(S,{pending:!0,data:Ge,method:F.method,action:I},I,Ge))},currentTarget:F}]})}}for(var aM=0;aM<UA.length;aM++){var iM=UA[aM],Aoe=iM.toLowerCase(),Toe=iM[0].toUpperCase()+iM.slice(1);El(Aoe,"on"+Toe)}El(RI,"onAnimationEnd"),El(FI,"onAnimationIteration"),El(LI,"onAnimationStart"),El("dblclick","onDoubleClick"),El("focusin","onFocus"),El("focusout","onBlur"),El(Vse,"onTransitionRun"),El(qse,"onTransitionStart"),El(Gse,"onTransitionCancel"),El(OI,"onTransitionEnd"),lt("onMouseEnter",["mouseout","mouseover"]),lt("onMouseLeave",["mouseout","mouseover"]),lt("onPointerEnter",["pointerout","pointerover"]),lt("onPointerLeave",["pointerout","pointerover"]),gt("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),gt("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),gt("onBeforeInput",["compositionend","keypress","textInput","paste"]),gt("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),gt("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),gt("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Bx="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(" "),Moe=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Bx));function aU(m,b){b=(b&4)!==0;for(var S=0;S<m.length;S++){var T=m[S],F=T.event;T=T.listeners;e:{var I=void 0;if(b)for(var ne=T.length-1;0<=ne;ne--){var Ee=T[ne],Ge=Ee.instance,ht=Ee.currentTarget;if(Ee=Ee.listener,Ge!==I&&F.isPropagationStopped())break e;I=Ee,F.currentTarget=ht;try{I(F)}catch(wt){Xv(wt)}F.currentTarget=null,I=Ge}else for(ne=0;ne<T.length;ne++){if(Ee=T[ne],Ge=Ee.instance,ht=Ee.currentTarget,Ee=Ee.listener,Ge!==I&&F.isPropagationStopped())break e;I=Ee,F.currentTarget=ht;try{I(F)}catch(wt){Xv(wt)}F.currentTarget=null,I=Ge}}}}function Kn(m,b){var S=b[oi];S===void 0&&(S=b[oi]=new Set);var T=m+"__bubble";S.has(T)||(iU(b,m,2,!1),S.add(T))}function sM(m,b,S){var T=0;b&&(T|=4),iU(S,m,T,b)}var Fw="_reactListening"+Math.random().toString(36).slice(2);function oM(m){if(!m[Fw]){m[Fw]=!0,Te.forEach(function(S){S!=="selectionchange"&&(Moe.has(S)||sM(S,!1,m),sM(S,!0,m))});var b=m.nodeType===9?m:m.ownerDocument;b===null||b[Fw]||(b[Fw]=!0,sM("selectionchange",!1,b))}}function iU(m,b,S,T){switch(RU(b)){case 2:var F=rle;break;case 8:F=ale;break;default:F=SM}S=F.bind(null,b,S,m),F=void 0,!Hs||b!=="touchstart"&&b!=="touchmove"&&b!=="wheel"||(F=!0),T?F!==void 0?m.addEventListener(b,S,{capture:!0,passive:F}):m.addEventListener(b,S,!0):F!==void 0?m.addEventListener(b,S,{passive:F}):m.addEventListener(b,S,!1)}function lM(m,b,S,T,F){var I=T;if((b&1)===0&&(b&2)===0&&T!==null)e:for(;;){if(T===null)return;var ne=T.tag;if(ne===3||ne===4){var Ee=T.stateNode.containerInfo;if(Ee===F)break;if(ne===4)for(ne=T.return;ne!==null;){var Ge=ne.tag;if((Ge===3||Ge===4)&&ne.stateNode.containerInfo===F)return;ne=ne.return}for(;Ee!==null;){if(ne=Lt(Ee),ne===null)return;if(Ge=ne.tag,Ge===5||Ge===6||Ge===26||Ge===27){T=I=ne;continue e}Ee=Ee.parentNode}}T=T.return}Uo(function(){var ht=I,wt=rn(S),Ct=[];e:{var ft=II.get(m);if(ft!==void 0){var xt=kr,Kt=m;switch(m){case"keypress":if(Pl(S)===0)break e;case"keydown":case"keyup":xt=Sse;break;case"focusin":Kt="focus",xt=fo;break;case"focusout":Kt="blur",xt=fo;break;case"beforeblur":case"afterblur":xt=fo;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":xt=ua;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":xt=Qc;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":xt=Cse;break;case RI:case FI:case LI:xt=EA;break;case OI:xt=Ase;break;case"scroll":case"scrollend":xt=Wv;break;case"wheel":xt=Mse;break;case"copy":case"cut":case"paste":xt=pse;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":xt=pI;break;case"toggle":case"beforetoggle":xt=Ese}var mn=(b&4)!==0,Lr=!mn&&(m==="scroll"||m==="scrollend"),rt=mn?ft!==null?ft+"Capture":null:ft;mn=[];for(var Qe=ht,ut;Qe!==null;){var _t=Qe;if(ut=_t.stateNode,_t=_t.tag,_t!==5&&_t!==26&&_t!==27||ut===null||rt===null||(_t=zi(Qe,rt),_t!=null&&mn.push(Hx(Qe,_t,ut))),Lr)break;Qe=Qe.return}0<mn.length&&(ft=new xt(ft,Kt,null,S,wt),Ct.push({event:ft,listeners:mn}))}}if((b&7)===0){e:{if(ft=m==="mouseover"||m==="pointerover",xt=m==="mouseout"||m==="pointerout",ft&&S!==li&&(Kt=S.relatedTarget||S.fromElement)&&(Lt(Kt)||Kt[or]))break e;if((xt||ft)&&(ft=wt.window===wt?wt:(ft=wt.ownerDocument)?ft.defaultView||ft.parentWindow:window,xt?(Kt=S.relatedTarget||S.toElement,xt=ht,Kt=Kt?Lt(Kt):null,Kt!==null&&(Lr=s(Kt),mn=Kt.tag,Kt!==Lr||mn!==5&&mn!==27&&mn!==6)&&(Kt=null)):(xt=null,Kt=ht),xt!==Kt)){if(mn=ua,_t="onMouseLeave",rt="onMouseEnter",Qe="mouse",(m==="pointerout"||m==="pointerover")&&(mn=pI,_t="onPointerLeave",rt="onPointerEnter",Qe="pointer"),Lr=xt==null?ft:He(xt),ut=Kt==null?ft:He(Kt),ft=new mn(_t,Qe+"leave",xt,S,wt),ft.target=Lr,ft.relatedTarget=ut,_t=null,Lt(wt)===ht&&(mn=new mn(rt,Qe+"enter",Kt,S,wt),mn.target=ut,mn.relatedTarget=Lr,_t=mn),Lr=_t,xt&&Kt)t:{for(mn=Poe,rt=xt,Qe=Kt,ut=0,_t=rt;_t;_t=mn(_t))ut++;_t=0;for(var sn=Qe;sn;sn=mn(sn))_t++;for(;0<ut-_t;)rt=mn(rt),ut--;for(;0<_t-ut;)Qe=mn(Qe),_t--;for(;ut--;){if(rt===Qe||Qe!==null&&rt===Qe.alternate){mn=rt;break t}rt=mn(rt),Qe=mn(Qe)}mn=null}else mn=null;xt!==null&&sU(Ct,ft,xt,mn,!1),Kt!==null&&Lr!==null&&sU(Ct,Lr,Kt,mn,!0)}}e:{if(ft=ht?He(ht):window,xt=ft.nodeName&&ft.nodeName.toLowerCase(),xt==="select"||xt==="input"&&ft.type==="file")var hr=_I;else if(wI(ft))if(NI)hr=Bse;else{hr=zse;var Jt=Ise}else xt=ft.nodeName,!xt||xt.toLowerCase()!=="input"||ft.type!=="checkbox"&&ft.type!=="radio"?ht&&vt(ht.elementType)&&(hr=_I):hr=Use;if(hr&&(hr=hr(m,ht))){SI(Ct,hr,S,wt);break e}Jt&&Jt(m,ft,ht),m==="focusout"&&ht&&ft.type==="number"&&ht.memoizedProps.value!=null&&vr(ft,"number",ft.value)}switch(Jt=ht?He(ht):window,m){case"focusin":(wI(Jt)||Jt.contentEditable==="true")&&(dp=Jt,OA=ht,bx=null);break;case"focusout":bx=OA=dp=null;break;case"mousedown":IA=!0;break;case"contextmenu":case"mouseup":case"dragend":IA=!1,jI(Ct,S,wt);break;case"selectionchange":if($se)break;case"keydown":case"keyup":jI(Ct,S,wt)}var jn;if(DA)e:{switch(m){case"compositionstart":var er="onCompositionStart";break e;case"compositionend":er="onCompositionEnd";break e;case"compositionupdate":er="onCompositionUpdate";break e}er=void 0}else cp?yI(m,S)&&(er="onCompositionEnd"):m==="keydown"&&S.keyCode===229&&(er="onCompositionStart");er&&(gI&&S.locale!=="ko"&&(cp||er!=="onCompositionStart"?er==="onCompositionEnd"&&cp&&(jn=Ui()):(Zr=wt,is="value"in Zr?Zr.value:Zr.textContent,cp=!0)),Jt=Lw(ht,er),0<Jt.length&&(er=new fI(er,m,null,S,wt),Ct.push({event:er,listeners:Jt}),jn?er.data=jn:(jn=vI(S),jn!==null&&(er.data=jn)))),(jn=Dse?Rse(m,S):Fse(m,S))&&(er=Lw(ht,"onBeforeInput"),0<er.length&&(Jt=new fI("onBeforeInput","beforeinput",null,S,wt),Ct.push({event:Jt,listeners:er}),Jt.data=jn)),koe(Ct,m,ht,S,wt)}aU(Ct,b)})}function Hx(m,b,S){return{instance:m,listener:b,currentTarget:S}}function Lw(m,b){for(var S=b+"Capture",T=[];m!==null;){var F=m,I=F.stateNode;if(F=F.tag,F!==5&&F!==26&&F!==27||I===null||(F=zi(m,S),F!=null&&T.unshift(Hx(m,F,I)),F=zi(m,b),F!=null&&T.push(Hx(m,F,I))),m.tag===3)return T;m=m.return}return[]}function Poe(m){if(m===null)return null;do m=m.return;while(m&&m.tag!==5&&m.tag!==27);return m||null}function sU(m,b,S,T,F){for(var I=b._reactName,ne=[];S!==null&&S!==T;){var Ee=S,Ge=Ee.alternate,ht=Ee.stateNode;if(Ee=Ee.tag,Ge!==null&&Ge===T)break;Ee!==5&&Ee!==26&&Ee!==27||ht===null||(Ge=ht,F?(ht=zi(S,I),ht!=null&&ne.unshift(Hx(S,ht,Ge))):F||(ht=zi(S,I),ht!=null&&ne.push(Hx(S,ht,Ge)))),S=S.return}ne.length!==0&&m.push({event:b,listeners:ne})}var Eoe=/\r\n?/g,joe=/\u0000|\uFFFD/g;function oU(m){return(typeof m=="string"?m:""+m).replace(Eoe,`
- `).replace(joe,"")}function lU(m,b){return b=oU(b),oU(m)===b}function Fr(m,b,S,T,F,I){switch(S){case"children":typeof T=="string"?b==="body"||b==="textarea"&&T===""||aa(m,T):(typeof T=="number"||typeof T=="bigint")&&b!=="body"&&aa(m,""+T);break;case"className":en(m,"class",T);break;case"tabIndex":en(m,"tabindex",T);break;case"dir":case"role":case"viewBox":case"width":case"height":en(m,S,T);break;case"style":vn(m,T,I);break;case"data":if(b!=="object"){en(m,"data",T);break}case"src":case"href":if(T===""&&(b!=="a"||S!=="href")){m.removeAttribute(S);break}if(T==null||typeof T=="function"||typeof T=="symbol"||typeof T=="boolean"){m.removeAttribute(S);break}T=Zn(""+T),m.setAttribute(S,T);break;case"action":case"formAction":if(typeof T=="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 I=="function"&&(S==="formAction"?(b!=="input"&&Fr(m,b,"name",F.name,F,null),Fr(m,b,"formEncType",F.formEncType,F,null),Fr(m,b,"formMethod",F.formMethod,F,null),Fr(m,b,"formTarget",F.formTarget,F,null)):(Fr(m,b,"encType",F.encType,F,null),Fr(m,b,"method",F.method,F,null),Fr(m,b,"target",F.target,F,null)));if(T==null||typeof T=="symbol"||typeof T=="boolean"){m.removeAttribute(S);break}T=Zn(""+T),m.setAttribute(S,T);break;case"onClick":T!=null&&(m.onclick=dr);break;case"onScroll":T!=null&&Kn("scroll",m);break;case"onScrollEnd":T!=null&&Kn("scrollend",m);break;case"dangerouslySetInnerHTML":if(T!=null){if(typeof T!="object"||!("__html"in T))throw Error(r(61));if(S=T.__html,S!=null){if(F.children!=null)throw Error(r(60));m.innerHTML=S}}break;case"multiple":m.multiple=T&&typeof T!="function"&&typeof T!="symbol";break;case"muted":m.muted=T&&typeof T!="function"&&typeof T!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(T==null||typeof T=="function"||typeof T=="boolean"||typeof T=="symbol"){m.removeAttribute("xlink:href");break}S=Zn(""+T),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":T!=null&&typeof T!="function"&&typeof T!="symbol"?m.setAttribute(S,""+T):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":T&&typeof T!="function"&&typeof T!="symbol"?m.setAttribute(S,""):m.removeAttribute(S);break;case"capture":case"download":T===!0?m.setAttribute(S,""):T!==!1&&T!=null&&typeof T!="function"&&typeof T!="symbol"?m.setAttribute(S,T):m.removeAttribute(S);break;case"cols":case"rows":case"size":case"span":T!=null&&typeof T!="function"&&typeof T!="symbol"&&!isNaN(T)&&1<=T?m.setAttribute(S,T):m.removeAttribute(S);break;case"rowSpan":case"start":T==null||typeof T=="function"||typeof T=="symbol"||isNaN(T)?m.removeAttribute(S):m.setAttribute(S,T);break;case"popover":Kn("beforetoggle",m),Kn("toggle",m),tn(m,"popover",T);break;case"xlinkActuate":on(m,"http://www.w3.org/1999/xlink","xlink:actuate",T);break;case"xlinkArcrole":on(m,"http://www.w3.org/1999/xlink","xlink:arcrole",T);break;case"xlinkRole":on(m,"http://www.w3.org/1999/xlink","xlink:role",T);break;case"xlinkShow":on(m,"http://www.w3.org/1999/xlink","xlink:show",T);break;case"xlinkTitle":on(m,"http://www.w3.org/1999/xlink","xlink:title",T);break;case"xlinkType":on(m,"http://www.w3.org/1999/xlink","xlink:type",T);break;case"xmlBase":on(m,"http://www.w3.org/XML/1998/namespace","xml:base",T);break;case"xmlLang":on(m,"http://www.w3.org/XML/1998/namespace","xml:lang",T);break;case"xmlSpace":on(m,"http://www.w3.org/XML/1998/namespace","xml:space",T);break;case"is":tn(m,"is",T);break;case"innerText":case"textContent":break;default:(!(2<S.length)||S[0]!=="o"&&S[0]!=="O"||S[1]!=="n"&&S[1]!=="N")&&(S=Un.get(S)||S,tn(m,S,T))}}function cM(m,b,S,T,F,I){switch(S){case"style":vn(m,T,I);break;case"dangerouslySetInnerHTML":if(T!=null){if(typeof T!="object"||!("__html"in T))throw Error(r(61));if(S=T.__html,S!=null){if(F.children!=null)throw Error(r(60));m.innerHTML=S}}break;case"children":typeof T=="string"?aa(m,T):(typeof T=="number"||typeof T=="bigint")&&aa(m,""+T);break;case"onScroll":T!=null&&Kn("scroll",m);break;case"onScrollEnd":T!=null&&Kn("scrollend",m);break;case"onClick":T!=null&&(m.onclick=dr);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!ct.hasOwnProperty(S))e:{if(S[0]==="o"&&S[1]==="n"&&(F=S.endsWith("Capture"),b=S.slice(2,F?S.length-7:void 0),I=m[br]||null,I=I!=null?I[S]:null,typeof I=="function"&&m.removeEventListener(b,I,F),typeof T=="function")){typeof I!="function"&&I!==null&&(S in m?m[S]=null:m.hasAttribute(S)&&m.removeAttribute(S)),m.addEventListener(b,T,F);break e}S in m?m[S]=T:T===!0?m.setAttribute(S,""):tn(m,S,T)}}}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":Kn("error",m),Kn("load",m);var T=!1,F=!1,I;for(I in S)if(S.hasOwnProperty(I)){var ne=S[I];if(ne!=null)switch(I){case"src":T=!0;break;case"srcSet":F=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,b));default:Fr(m,b,I,ne,S,null)}}F&&Fr(m,b,"srcSet",S.srcSet,S,null),T&&Fr(m,b,"src",S.src,S,null);return;case"input":Kn("invalid",m);var Ee=I=ne=F=null,Ge=null,ht=null;for(T in S)if(S.hasOwnProperty(T)){var wt=S[T];if(wt!=null)switch(T){case"name":F=wt;break;case"type":ne=wt;break;case"checked":Ge=wt;break;case"defaultChecked":ht=wt;break;case"value":I=wt;break;case"defaultValue":Ee=wt;break;case"children":case"dangerouslySetInnerHTML":if(wt!=null)throw Error(r(137,b));break;default:Fr(m,b,T,wt,S,null)}}bn(m,I,Ee,Ge,ht,ne,F,!1);return;case"select":Kn("invalid",m),T=ne=I=null;for(F in S)if(S.hasOwnProperty(F)&&(Ee=S[F],Ee!=null))switch(F){case"value":I=Ee;break;case"defaultValue":ne=Ee;break;case"multiple":T=Ee;default:Fr(m,b,F,Ee,S,null)}b=I,S=ne,m.multiple=!!T,b!=null?Qn(m,!!T,b,!1):S!=null&&Qn(m,!!T,S,!0);return;case"textarea":Kn("invalid",m),I=F=T=null;for(ne in S)if(S.hasOwnProperty(ne)&&(Ee=S[ne],Ee!=null))switch(ne){case"value":T=Ee;break;case"defaultValue":F=Ee;break;case"children":I=Ee;break;case"dangerouslySetInnerHTML":if(Ee!=null)throw Error(r(91));break;default:Fr(m,b,ne,Ee,S,null)}Ua(m,T,F,I);return;case"option":for(Ge in S)S.hasOwnProperty(Ge)&&(T=S[Ge],T!=null)&&(Ge==="selected"?m.selected=T&&typeof T!="function"&&typeof T!="symbol":Fr(m,b,Ge,T,S,null));return;case"dialog":Kn("beforetoggle",m),Kn("toggle",m),Kn("cancel",m),Kn("close",m);break;case"iframe":case"object":Kn("load",m);break;case"video":case"audio":for(T=0;T<Bx.length;T++)Kn(Bx[T],m);break;case"image":Kn("error",m),Kn("load",m);break;case"details":Kn("toggle",m);break;case"embed":case"source":case"link":Kn("error",m),Kn("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(ht in S)if(S.hasOwnProperty(ht)&&(T=S[ht],T!=null))switch(ht){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,b));default:Fr(m,b,ht,T,S,null)}return;default:if(vt(b)){for(wt in S)S.hasOwnProperty(wt)&&(T=S[wt],T!==void 0&&cM(m,b,wt,T,S,void 0));return}}for(Ee in S)S.hasOwnProperty(Ee)&&(T=S[Ee],T!=null&&Fr(m,b,Ee,T,S,null))}function Doe(m,b,S,T){switch(b){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var F=null,I=null,ne=null,Ee=null,Ge=null,ht=null,wt=null;for(xt in S){var Ct=S[xt];if(S.hasOwnProperty(xt)&&Ct!=null)switch(xt){case"checked":break;case"value":break;case"defaultValue":Ge=Ct;default:T.hasOwnProperty(xt)||Fr(m,b,xt,null,T,Ct)}}for(var ft in T){var xt=T[ft];if(Ct=S[ft],T.hasOwnProperty(ft)&&(xt!=null||Ct!=null))switch(ft){case"type":I=xt;break;case"name":F=xt;break;case"checked":ht=xt;break;case"defaultChecked":wt=xt;break;case"value":ne=xt;break;case"defaultValue":Ee=xt;break;case"children":case"dangerouslySetInnerHTML":if(xt!=null)throw Error(r(137,b));break;default:xt!==Ct&&Fr(m,b,ft,xt,T,Ct)}}as(m,ne,Ee,Ge,ht,wt,I,F);return;case"select":xt=ne=Ee=ft=null;for(I in S)if(Ge=S[I],S.hasOwnProperty(I)&&Ge!=null)switch(I){case"value":break;case"multiple":xt=Ge;default:T.hasOwnProperty(I)||Fr(m,b,I,null,T,Ge)}for(F in T)if(I=T[F],Ge=S[F],T.hasOwnProperty(F)&&(I!=null||Ge!=null))switch(F){case"value":ft=I;break;case"defaultValue":Ee=I;break;case"multiple":ne=I;default:I!==Ge&&Fr(m,b,F,I,T,Ge)}b=Ee,S=ne,T=xt,ft!=null?Qn(m,!!S,ft,!1):!!T!=!!S&&(b!=null?Qn(m,!!S,b,!0):Qn(m,!!S,S?[]:"",!1));return;case"textarea":xt=ft=null;for(Ee in S)if(F=S[Ee],S.hasOwnProperty(Ee)&&F!=null&&!T.hasOwnProperty(Ee))switch(Ee){case"value":break;case"children":break;default:Fr(m,b,Ee,null,T,F)}for(ne in T)if(F=T[ne],I=S[ne],T.hasOwnProperty(ne)&&(F!=null||I!=null))switch(ne){case"value":ft=F;break;case"defaultValue":xt=F;break;case"children":break;case"dangerouslySetInnerHTML":if(F!=null)throw Error(r(91));break;default:F!==I&&Fr(m,b,ne,F,T,I)}xa(m,ft,xt);return;case"option":for(var Kt in S)ft=S[Kt],S.hasOwnProperty(Kt)&&ft!=null&&!T.hasOwnProperty(Kt)&&(Kt==="selected"?m.selected=!1:Fr(m,b,Kt,null,T,ft));for(Ge in T)ft=T[Ge],xt=S[Ge],T.hasOwnProperty(Ge)&&ft!==xt&&(ft!=null||xt!=null)&&(Ge==="selected"?m.selected=ft&&typeof ft!="function"&&typeof ft!="symbol":Fr(m,b,Ge,ft,T,xt));return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var mn in S)ft=S[mn],S.hasOwnProperty(mn)&&ft!=null&&!T.hasOwnProperty(mn)&&Fr(m,b,mn,null,T,ft);for(ht in T)if(ft=T[ht],xt=S[ht],T.hasOwnProperty(ht)&&ft!==xt&&(ft!=null||xt!=null))switch(ht){case"children":case"dangerouslySetInnerHTML":if(ft!=null)throw Error(r(137,b));break;default:Fr(m,b,ht,ft,T,xt)}return;default:if(vt(b)){for(var Lr in S)ft=S[Lr],S.hasOwnProperty(Lr)&&ft!==void 0&&!T.hasOwnProperty(Lr)&&cM(m,b,Lr,void 0,T,ft);for(wt in T)ft=T[wt],xt=S[wt],!T.hasOwnProperty(wt)||ft===xt||ft===void 0&&xt===void 0||cM(m,b,wt,ft,T,xt);return}}for(var rt in S)ft=S[rt],S.hasOwnProperty(rt)&&ft!=null&&!T.hasOwnProperty(rt)&&Fr(m,b,rt,null,T,ft);for(Ct in T)ft=T[Ct],xt=S[Ct],!T.hasOwnProperty(Ct)||ft===xt||ft==null&&xt==null||Fr(m,b,Ct,ft,T,xt)}function cU(m){switch(m){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function Roe(){if(typeof performance.getEntriesByType=="function"){for(var m=0,b=0,S=performance.getEntriesByType("resource"),T=0;T<S.length;T++){var F=S[T],I=F.transferSize,ne=F.initiatorType,Ee=F.duration;if(I&&Ee&&cU(ne)){for(ne=0,Ee=F.responseEnd,T+=1;T<S.length;T++){var Ge=S[T],ht=Ge.startTime;if(ht>Ee)break;var wt=Ge.transferSize,Ct=Ge.initiatorType;wt&&cU(Ct)&&(Ge=Ge.responseEnd,ne+=wt*(Ge<Ee?1:(Ee-ht)/(Ge-ht)))}if(--T,b+=8*(I+ne)/(F.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 dM=null,uM=null;function Ow(m){return m.nodeType===9?m:m.ownerDocument}function dU(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 uU(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 hM(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 mM=null;function Foe(){var m=window.event;return m&&m.type==="popstate"?m===mM?!1:(mM=m,!0):(mM=null,!1)}var hU=typeof setTimeout=="function"?setTimeout:void 0,Loe=typeof clearTimeout=="function"?clearTimeout:void 0,mU=typeof Promise=="function"?Promise:void 0,Ooe=typeof queueMicrotask=="function"?queueMicrotask:typeof mU<"u"?function(m){return mU.resolve(null).then(m).catch(Ioe)}:hU;function Ioe(m){setTimeout(function(){throw m})}function Ou(m){return m==="head"}function fU(m,b){var S=b,T=0;do{var F=S.nextSibling;if(m.removeChild(S),F&&F.nodeType===8)if(S=F.data,S==="/$"||S==="/&"){if(T===0){m.removeChild(F),Op(b);return}T--}else if(S==="$"||S==="$?"||S==="$~"||S==="$!"||S==="&")T++;else if(S==="html")$x(m.ownerDocument.documentElement);else if(S==="head"){S=m.ownerDocument.head,$x(S);for(var I=S.firstChild;I;){var ne=I.nextSibling,Ee=I.nodeName;I[it]||Ee==="SCRIPT"||Ee==="STYLE"||Ee==="LINK"&&I.rel.toLowerCase()==="stylesheet"||S.removeChild(I),I=ne}}else S==="body"&&$x(m.ownerDocument.body);S=F}while(S);Op(b)}function pU(m,b){var S=m;m=0;do{var T=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||""),T&&T.nodeType===8)if(S=T.data,S==="/$"){if(m===0)break;m--}else S!=="$"&&S!=="$?"&&S!=="$~"&&S!=="$!"||m++;S=T}while(S)}function fM(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":fM(S),Ke(S);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(S.rel.toLowerCase()==="stylesheet")continue}m.removeChild(S)}}function zoe(m,b,S,T){for(;m.nodeType===1;){var F=S;if(m.nodeName.toLowerCase()!==b.toLowerCase()){if(!T&&(m.nodeName!=="INPUT"||m.type!=="hidden"))break}else if(T){if(!m[it])switch(b){case"meta":if(!m.hasAttribute("itemprop"))break;return m;case"link":if(I=m.getAttribute("rel"),I==="stylesheet"&&m.hasAttribute("data-precedence"))break;if(I!==F.rel||m.getAttribute("href")!==(F.href==null||F.href===""?null:F.href)||m.getAttribute("crossorigin")!==(F.crossOrigin==null?null:F.crossOrigin)||m.getAttribute("title")!==(F.title==null?null:F.title))break;return m;case"style":if(m.hasAttribute("data-precedence"))break;return m;case"script":if(I=m.getAttribute("src"),(I!==(F.src==null?null:F.src)||m.getAttribute("type")!==(F.type==null?null:F.type)||m.getAttribute("crossorigin")!==(F.crossOrigin==null?null:F.crossOrigin))&&I&&m.hasAttribute("async")&&!m.hasAttribute("itemprop"))break;return m;default:return m}}else if(b==="input"&&m.type==="hidden"){var I=F.name==null?null:""+F.name;if(F.type==="hidden"&&m.getAttribute("name")===I)return m}else return m;if(m=Wo(m.nextSibling),m===null)break}return null}function Uoe(m,b,S){if(b==="")return null;for(;m.nodeType!==3;)if((m.nodeType!==1||m.nodeName!=="INPUT"||m.type!=="hidden")&&!S||(m=Wo(m.nextSibling),m===null))return null;return m}function gU(m,b){for(;m.nodeType!==8;)if((m.nodeType!==1||m.nodeName!=="INPUT"||m.type!=="hidden")&&!b||(m=Wo(m.nextSibling),m===null))return null;return m}function pM(m){return m.data==="$?"||m.data==="$~"}function gM(m){return m.data==="$!"||m.data==="$?"&&m.ownerDocument.readyState!=="loading"}function Boe(m,b){var S=m.ownerDocument;if(m.data==="$~")m._reactRetry=b;else if(m.data!=="$?"||S.readyState!=="loading")b();else{var T=function(){b(),S.removeEventListener("DOMContentLoaded",T)};S.addEventListener("DOMContentLoaded",T),m._reactRetry=T}}function Wo(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 bM=null;function bU(m){m=m.nextSibling;for(var b=0;m;){if(m.nodeType===8){var S=m.data;if(S==="/$"||S==="/&"){if(b===0)return Wo(m.nextSibling);b--}else S!=="$"&&S!=="$!"&&S!=="$?"&&S!=="$~"&&S!=="&"||b++}m=m.nextSibling}return null}function xU(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 yU(m,b,S){switch(b=Ow(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 $x(m){for(var b=m.attributes;b.length;)m.removeAttributeNode(b[0]);Ke(m)}var Ko=new Map,vU=new Set;function Iw(m){return typeof m.getRootNode=="function"?m.getRootNode():m.nodeType===9?m:m.ownerDocument}var hd=z.d;z.d={f:Hoe,r:$oe,D:Voe,C:qoe,L:Goe,m:Woe,X:Xoe,S:Koe,M:Yoe};function Hoe(){var m=hd.f(),b=Mw();return m||b}function $oe(m){var b=ye(m);b!==null&&b.tag===5&&b.type==="form"?O5(b):hd.r(m)}var Rp=typeof document>"u"?null:document;function wU(m,b,S){var T=Rp;if(T&&typeof b=="string"&&b){var F=lr(b);F='link[rel="'+m+'"][href="'+F+'"]',typeof S=="string"&&(F+='[crossorigin="'+S+'"]'),vU.has(F)||(vU.add(F),m={rel:m,crossOrigin:S,href:b},T.querySelector(F)===null&&(b=T.createElement("link"),Vi(b,"link",m),Xe(b),T.head.appendChild(b)))}}function Voe(m){hd.D(m),wU("dns-prefetch",m,null)}function qoe(m,b){hd.C(m,b),wU("preconnect",m,b)}function Goe(m,b,S){hd.L(m,b,S);var T=Rp;if(T&&m&&b){var F='link[rel="preload"][as="'+lr(b)+'"]';b==="image"&&S&&S.imageSrcSet?(F+='[imagesrcset="'+lr(S.imageSrcSet)+'"]',typeof S.imageSizes=="string"&&(F+='[imagesizes="'+lr(S.imageSizes)+'"]')):F+='[href="'+lr(m)+'"]';var I=F;switch(b){case"style":I=Fp(m);break;case"script":I=Lp(m)}Ko.has(I)||(m=h({rel:"preload",href:b==="image"&&S&&S.imageSrcSet?void 0:m,as:b},S),Ko.set(I,m),T.querySelector(F)!==null||b==="style"&&T.querySelector(Vx(I))||b==="script"&&T.querySelector(qx(I))||(b=T.createElement("link"),Vi(b,"link",m),Xe(b),T.head.appendChild(b)))}}function Woe(m,b){hd.m(m,b);var S=Rp;if(S&&m){var T=b&&typeof b.as=="string"?b.as:"script",F='link[rel="modulepreload"][as="'+lr(T)+'"][href="'+lr(m)+'"]',I=F;switch(T){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":I=Lp(m)}if(!Ko.has(I)&&(m=h({rel:"modulepreload",href:m},b),Ko.set(I,m),S.querySelector(F)===null)){switch(T){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(S.querySelector(qx(I)))return}T=S.createElement("link"),Vi(T,"link",m),Xe(T),S.head.appendChild(T)}}}function Koe(m,b,S){hd.S(m,b,S);var T=Rp;if(T&&m){var F=Ye(T).hoistableStyles,I=Fp(m);b=b||"default";var ne=F.get(I);if(!ne){var Ee={loading:0,preload:null};if(ne=T.querySelector(Vx(I)))Ee.loading=5;else{m=h({rel:"stylesheet",href:m,"data-precedence":b},S),(S=Ko.get(I))&&xM(m,S);var Ge=ne=T.createElement("link");Xe(Ge),Vi(Ge,"link",m),Ge._p=new Promise(function(ht,wt){Ge.onload=ht,Ge.onerror=wt}),Ge.addEventListener("load",function(){Ee.loading|=1}),Ge.addEventListener("error",function(){Ee.loading|=2}),Ee.loading|=4,zw(ne,b,T)}ne={type:"stylesheet",instance:ne,count:1,state:Ee},F.set(I,ne)}}}function Xoe(m,b){hd.X(m,b);var S=Rp;if(S&&m){var T=Ye(S).hoistableScripts,F=Lp(m),I=T.get(F);I||(I=S.querySelector(qx(F)),I||(m=h({src:m,async:!0},b),(b=Ko.get(F))&&yM(m,b),I=S.createElement("script"),Xe(I),Vi(I,"link",m),S.head.appendChild(I)),I={type:"script",instance:I,count:1,state:null},T.set(F,I))}}function Yoe(m,b){hd.M(m,b);var S=Rp;if(S&&m){var T=Ye(S).hoistableScripts,F=Lp(m),I=T.get(F);I||(I=S.querySelector(qx(F)),I||(m=h({src:m,async:!0,type:"module"},b),(b=Ko.get(F))&&yM(m,b),I=S.createElement("script"),Xe(I),Vi(I,"link",m),S.head.appendChild(I)),I={type:"script",instance:I,count:1,state:null},T.set(F,I))}}function SU(m,b,S,T){var F=(F=oe.current)?Iw(F):null;if(!F)throw Error(r(446));switch(m){case"meta":case"title":return null;case"style":return typeof S.precedence=="string"&&typeof S.href=="string"?(b=Fp(S.href),S=Ye(F).hoistableStyles,T=S.get(b),T||(T={type:"style",instance:null,count:0,state:null},S.set(b,T)),T):{type:"void",instance:null,count:0,state:null};case"link":if(S.rel==="stylesheet"&&typeof S.href=="string"&&typeof S.precedence=="string"){m=Fp(S.href);var I=Ye(F).hoistableStyles,ne=I.get(m);if(ne||(F=F.ownerDocument||F,ne={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},I.set(m,ne),(I=F.querySelector(Vx(m)))&&!I._p&&(ne.instance=I,ne.state.loading=5),Ko.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},Ko.set(m,S),I||Qoe(F,m,S,ne.state))),b&&T===null)throw Error(r(528,""));return ne}if(b&&T!==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=Lp(S),S=Ye(F).hoistableScripts,T=S.get(b),T||(T={type:"script",instance:null,count:0,state:null},S.set(b,T)),T):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,m))}}function Fp(m){return'href="'+lr(m)+'"'}function Vx(m){return'link[rel="stylesheet"]['+m+"]"}function _U(m){return h({},m,{"data-precedence":m.precedence,precedence:null})}function Qoe(m,b,S,T){m.querySelector('link[rel="preload"][as="style"]['+b+"]")?T.loading=1:(b=m.createElement("link"),T.preload=b,b.addEventListener("load",function(){return T.loading|=1}),b.addEventListener("error",function(){return T.loading|=2}),Vi(b,"link",S),Xe(b),m.head.appendChild(b))}function Lp(m){return'[src="'+lr(m)+'"]'}function qx(m){return"script[async]"+m}function NU(m,b,S){if(b.count++,b.instance===null)switch(b.type){case"style":var T=m.querySelector('style[data-href~="'+lr(S.href)+'"]');if(T)return b.instance=T,Xe(T),T;var F=h({},S,{"data-href":S.href,"data-precedence":S.precedence,href:null,precedence:null});return T=(m.ownerDocument||m).createElement("style"),Xe(T),Vi(T,"style",F),zw(T,S.precedence,m),b.instance=T;case"stylesheet":F=Fp(S.href);var I=m.querySelector(Vx(F));if(I)return b.state.loading|=4,b.instance=I,Xe(I),I;T=_U(S),(F=Ko.get(F))&&xM(T,F),I=(m.ownerDocument||m).createElement("link"),Xe(I);var ne=I;return ne._p=new Promise(function(Ee,Ge){ne.onload=Ee,ne.onerror=Ge}),Vi(I,"link",T),b.state.loading|=4,zw(I,S.precedence,m),b.instance=I;case"script":return I=Lp(S.src),(F=m.querySelector(qx(I)))?(b.instance=F,Xe(F),F):(T=S,(F=Ko.get(I))&&(T=h({},S),yM(T,F)),m=m.ownerDocument||m,F=m.createElement("script"),Xe(F),Vi(F,"link",T),m.head.appendChild(F),b.instance=F);case"void":return null;default:throw Error(r(443,b.type))}else b.type==="stylesheet"&&(b.state.loading&4)===0&&(T=b.instance,b.state.loading|=4,zw(T,S.precedence,m));return b.instance}function zw(m,b,S){for(var T=S.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),F=T.length?T[T.length-1]:null,I=F,ne=0;ne<T.length;ne++){var Ee=T[ne];if(Ee.dataset.precedence===b)I=Ee;else if(I!==F)break}I?I.parentNode.insertBefore(m,I.nextSibling):(b=S.nodeType===9?S.head:S,b.insertBefore(m,b.firstChild))}function xM(m,b){m.crossOrigin==null&&(m.crossOrigin=b.crossOrigin),m.referrerPolicy==null&&(m.referrerPolicy=b.referrerPolicy),m.title==null&&(m.title=b.title)}function yM(m,b){m.crossOrigin==null&&(m.crossOrigin=b.crossOrigin),m.referrerPolicy==null&&(m.referrerPolicy=b.referrerPolicy),m.integrity==null&&(m.integrity=b.integrity)}var Uw=null;function CU(m,b,S){if(Uw===null){var T=new Map,F=Uw=new Map;F.set(S,T)}else F=Uw,T=F.get(S),T||(T=new Map,F.set(S,T));if(T.has(m))return T;for(T.set(m,null),S=S.getElementsByTagName(m),F=0;F<S.length;F++){var I=S[F];if(!(I[it]||I[Gn]||m==="link"&&I.getAttribute("rel")==="stylesheet")&&I.namespaceURI!=="http://www.w3.org/2000/svg"){var ne=I.getAttribute(b)||"";ne=m+ne;var Ee=T.get(ne);Ee?Ee.push(I):T.set(ne,[I])}}return T}function kU(m,b,S){m=m.ownerDocument||m,m.head.insertBefore(S,b==="title"?m.querySelector("head > title"):null)}function Zoe(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 AU(m){return!(m.type==="stylesheet"&&(m.state.loading&3)===0)}function Joe(m,b,S,T){if(S.type==="stylesheet"&&(typeof T.media!="string"||matchMedia(T.media).matches!==!1)&&(S.state.loading&4)===0){if(S.instance===null){var F=Fp(T.href),I=b.querySelector(Vx(F));if(I){b=I._p,b!==null&&typeof b=="object"&&typeof b.then=="function"&&(m.count++,m=Bw.bind(m),b.then(m,m)),S.state.loading|=4,S.instance=I,Xe(I);return}I=b.ownerDocument||b,T=_U(T),(F=Ko.get(F))&&xM(T,F),I=I.createElement("link"),Xe(I);var ne=I;ne._p=new Promise(function(Ee,Ge){ne.onload=Ee,ne.onerror=Ge}),Vi(I,"link",T),S.instance=I}m.stylesheets===null&&(m.stylesheets=new Map),m.stylesheets.set(S,b),(b=S.state.preload)&&(S.state.loading&3)===0&&(m.count++,S=Bw.bind(m),b.addEventListener("load",S),b.addEventListener("error",S))}}var vM=0;function ele(m,b){return m.stylesheets&&m.count===0&&$w(m,m.stylesheets),0<m.count||0<m.imgCount?function(S){var T=setTimeout(function(){if(m.stylesheets&&$w(m,m.stylesheets),m.unsuspend){var I=m.unsuspend;m.unsuspend=null,I()}},6e4+b);0<m.imgBytes&&vM===0&&(vM=62500*Roe());var F=setTimeout(function(){if(m.waitingForImages=!1,m.count===0&&(m.stylesheets&&$w(m,m.stylesheets),m.unsuspend)){var I=m.unsuspend;m.unsuspend=null,I()}},(m.imgBytes>vM?50:800)+b);return m.unsuspend=S,function(){m.unsuspend=null,clearTimeout(T),clearTimeout(F)}}:null}function Bw(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)$w(this,this.stylesheets);else if(this.unsuspend){var m=this.unsuspend;this.unsuspend=null,m()}}}var Hw=null;function $w(m,b){m.stylesheets=null,m.unsuspend!==null&&(m.count++,Hw=new Map,b.forEach(tle,m),Hw=null,Bw.call(m))}function tle(m,b){if(!(b.state.loading&4)){var S=Hw.get(m);if(S)var T=S.get(null);else{S=new Map,Hw.set(m,S);for(var F=m.querySelectorAll("link[data-precedence],style[data-precedence]"),I=0;I<F.length;I++){var ne=F[I];(ne.nodeName==="LINK"||ne.getAttribute("media")!=="not all")&&(S.set(ne.dataset.precedence,ne),T=ne)}T&&S.set(null,T)}F=b.instance,ne=F.getAttribute("data-precedence"),I=S.get(ne)||T,I===T&&S.set(null,F),S.set(ne,F),this.count++,T=Bw.bind(this),F.addEventListener("load",T),F.addEventListener("error",T),I?I.parentNode.insertBefore(F,I.nextSibling):(m=m.nodeType===9?m.head:m,m.insertBefore(F,m.firstChild)),b.state.loading|=4}}var Gx={$$typeof:N,Provider:null,Consumer:null,_currentValue:W,_currentValue2:W,_threadCount:0};function nle(m,b,S,T,F,I,ne,Ee,Ge){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=Ft(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ft(0),this.hiddenUpdates=Ft(null),this.identifierPrefix=T,this.onUncaughtError=F,this.onCaughtError=I,this.onRecoverableError=ne,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=Ge,this.incompleteTransitions=new Map}function TU(m,b,S,T,F,I,ne,Ee,Ge,ht,wt,Ct){return m=new nle(m,b,S,ne,Ge,ht,wt,Ct,Ee),b=1,I===!0&&(b|=24),I=go(3,null,null,b),m.current=I,I.stateNode=m,b=JA(),b.refCount++,m.pooledCache=b,b.refCount++,I.memoizedState={element:T,isDehydrated:S,cache:b},rT(I),m}function MU(m){return m?(m=mp,m):mp}function PU(m,b,S,T,F,I){F=MU(F),T.context===null?T.context=F:T.pendingContext=F,T=ku(b),T.payload={element:S},I=I===void 0?null:I,I!==null&&(T.callback=I),S=Au(m,T,b),S!==null&&(Ws(S,m,b),Nx(S,m,b))}function EU(m,b){if(m=m.memoizedState,m!==null&&m.dehydrated!==null){var S=m.retryLane;m.retryLane=S!==0&&S<b?S:b}}function wM(m,b){EU(m,b),(m=m.alternate)&&EU(m,b)}function jU(m){if(m.tag===13||m.tag===31){var b=fm(m,67108864);b!==null&&Ws(b,m,67108864),wM(m,67108864)}}function DU(m){if(m.tag===13||m.tag===31){var b=wo();b=zt(b);var S=fm(m,b);S!==null&&Ws(S,m,b),wM(m,b)}}var Vw=!0;function rle(m,b,S,T){var F=q.T;q.T=null;var I=z.p;try{z.p=2,SM(m,b,S,T)}finally{z.p=I,q.T=F}}function ale(m,b,S,T){var F=q.T;q.T=null;var I=z.p;try{z.p=8,SM(m,b,S,T)}finally{z.p=I,q.T=F}}function SM(m,b,S,T){if(Vw){var F=_M(T);if(F===null)lM(m,b,T,qw,S),FU(m,T);else if(sle(F,m,b,S,T))T.stopPropagation();else if(FU(m,T),b&4&&-1<ile.indexOf(m)){for(;F!==null;){var I=ye(F);if(I!==null)switch(I.tag){case 3:if(I=I.stateNode,I.current.memoizedState.isDehydrated){var ne=Oe(I.pendingLanes);if(ne!==0){var Ee=I;for(Ee.pendingLanes|=2,Ee.entangledLanes|=2;ne;){var Ge=1<<31-xe(ne);Ee.entanglements[1]|=Ge,ne&=~Ge}uc(I),(xr&6)===0&&(Aw=R()+500,Ux(0))}}break;case 31:case 13:Ee=fm(I,2),Ee!==null&&Ws(Ee,I,2),Mw(),wM(I,2)}if(I=_M(T),I===null&&lM(m,b,T,qw,S),I===F)break;F=I}F!==null&&T.stopPropagation()}else lM(m,b,T,null,S)}}function _M(m){return m=rn(m),NM(m)}var qw=null;function NM(m){if(qw=null,m=Lt(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 qw=m,null}function RU(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(G()){case de:return 2;case ge:return 8;case ae:case Ue:return 32;case ze:return 268435456;default:return 32}default:return 32}}var CM=!1,Iu=null,zu=null,Uu=null,Wx=new Map,Kx=new Map,Bu=[],ile="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 FU(m,b){switch(m){case"focusin":case"focusout":Iu=null;break;case"dragenter":case"dragleave":zu=null;break;case"mouseover":case"mouseout":Uu=null;break;case"pointerover":case"pointerout":Wx.delete(b.pointerId);break;case"gotpointercapture":case"lostpointercapture":Kx.delete(b.pointerId)}}function Xx(m,b,S,T,F,I){return m===null||m.nativeEvent!==I?(m={blockedOn:b,domEventName:S,eventSystemFlags:T,nativeEvent:I,targetContainers:[F]},b!==null&&(b=ye(b),b!==null&&jU(b)),m):(m.eventSystemFlags|=T,b=m.targetContainers,F!==null&&b.indexOf(F)===-1&&b.push(F),m)}function sle(m,b,S,T,F){switch(b){case"focusin":return Iu=Xx(Iu,m,b,S,T,F),!0;case"dragenter":return zu=Xx(zu,m,b,S,T,F),!0;case"mouseover":return Uu=Xx(Uu,m,b,S,T,F),!0;case"pointerover":var I=F.pointerId;return Wx.set(I,Xx(Wx.get(I)||null,m,b,S,T,F)),!0;case"gotpointercapture":return I=F.pointerId,Kx.set(I,Xx(Kx.get(I)||null,m,b,S,T,F)),!0}return!1}function LU(m){var b=Lt(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,sr(m.priority,function(){DU(S)});return}}else if(b===31){if(b=l(S),b!==null){m.blockedOn=b,sr(m.priority,function(){DU(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 Gw(m){if(m.blockedOn!==null)return!1;for(var b=m.targetContainers;0<b.length;){var S=_M(m.nativeEvent);if(S===null){S=m.nativeEvent;var T=new S.constructor(S.type,S);li=T,S.target.dispatchEvent(T),li=null}else return b=ye(S),b!==null&&jU(b),m.blockedOn=S,!1;b.shift()}return!0}function OU(m,b,S){Gw(m)&&S.delete(b)}function ole(){CM=!1,Iu!==null&&Gw(Iu)&&(Iu=null),zu!==null&&Gw(zu)&&(zu=null),Uu!==null&&Gw(Uu)&&(Uu=null),Wx.forEach(OU),Kx.forEach(OU)}function Ww(m,b){m.blockedOn===b&&(m.blockedOn=null,CM||(CM=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,ole)))}var Kw=null;function IU(m){Kw!==m&&(Kw=m,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){Kw===m&&(Kw=null);for(var b=0;b<m.length;b+=3){var S=m[b],T=m[b+1],F=m[b+2];if(typeof T!="function"){if(NM(T||S)===null)continue;break}var I=ye(S);I!==null&&(m.splice(b,3),b-=3,_T(I,{pending:!0,data:F,method:S.method,action:T},T,F))}}))}function Op(m){function b(Ge){return Ww(Ge,m)}Iu!==null&&Ww(Iu,m),zu!==null&&Ww(zu,m),Uu!==null&&Ww(Uu,m),Wx.forEach(b),Kx.forEach(b);for(var S=0;S<Bu.length;S++){var T=Bu[S];T.blockedOn===m&&(T.blockedOn=null)}for(;0<Bu.length&&(S=Bu[0],S.blockedOn===null);)LU(S),S.blockedOn===null&&Bu.shift();if(S=(m.ownerDocument||m).$$reactFormReplay,S!=null)for(T=0;T<S.length;T+=3){var F=S[T],I=S[T+1],ne=F[br]||null;if(typeof I=="function")ne||IU(S);else if(ne){var Ee=null;if(I&&I.hasAttribute("formAction")){if(F=I,ne=I[br]||null)Ee=ne.formAction;else if(NM(F)!==null)continue}else Ee=ne.action;typeof Ee=="function"?S[T+1]=Ee:(S.splice(T,3),T-=3),IU(S)}}}function zU(){function m(I){I.canIntercept&&I.info==="react-transition"&&I.intercept({handler:function(){return new Promise(function(ne){return F=ne})},focusReset:"manual",scroll:"manual"})}function b(){F!==null&&(F(),F=null),T||setTimeout(S,20)}function S(){if(!T&&!navigation.transition){var I=navigation.currentEntry;I&&I.url!=null&&navigation.navigate(I.url,{state:I.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var T=!1,F=null;return navigation.addEventListener("navigate",m),navigation.addEventListener("navigatesuccess",b),navigation.addEventListener("navigateerror",b),setTimeout(S,100),function(){T=!0,navigation.removeEventListener("navigate",m),navigation.removeEventListener("navigatesuccess",b),navigation.removeEventListener("navigateerror",b),F!==null&&(F(),F=null)}}}function kM(m){this._internalRoot=m}Xw.prototype.render=kM.prototype.render=function(m){var b=this._internalRoot;if(b===null)throw Error(r(409));var S=b.current,T=wo();PU(S,T,m,b,null,null)},Xw.prototype.unmount=kM.prototype.unmount=function(){var m=this._internalRoot;if(m!==null){this._internalRoot=null;var b=m.containerInfo;PU(m.current,2,null,m,null,null),Mw(),b[or]=null}};function Xw(m){this._internalRoot=m}Xw.prototype.unstable_scheduleHydration=function(m){if(m){var b=gr();m={blockedOn:null,target:m,priority:b};for(var S=0;S<Bu.length&&b!==0&&b<Bu[S].priority;S++);Bu.splice(S,0,m),S===0&&LU(m)}};var UU=e.version;if(UU!=="19.2.4")throw Error(r(527,UU,"19.2.4"));z.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=d(b),m=m!==null?u(m):null,m=m===null?null:m.stateNode,m};var lle={bundleType:0,version:"19.2.4",rendererPackageName:"react-dom",currentDispatcherRef:q,reconcilerVersion:"19.2.4"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Yw=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Yw.isDisabled&&Yw.supportsFiber)try{pe=Yw.inject(lle),ve=Yw}catch{}}return Qx.createRoot=function(m,b){if(!i(m))throw Error(r(299));var S=!1,T="",F=W5,I=K5,ne=X5;return b!=null&&(b.unstable_strictMode===!0&&(S=!0),b.identifierPrefix!==void 0&&(T=b.identifierPrefix),b.onUncaughtError!==void 0&&(F=b.onUncaughtError),b.onCaughtError!==void 0&&(I=b.onCaughtError),b.onRecoverableError!==void 0&&(ne=b.onRecoverableError)),b=TU(m,1,!1,null,null,S,T,null,F,I,ne,zU),m[or]=b.current,oM(m),new kM(b)},Qx.hydrateRoot=function(m,b,S){if(!i(m))throw Error(r(299));var T=!1,F="",I=W5,ne=K5,Ee=X5,Ge=null;return S!=null&&(S.unstable_strictMode===!0&&(T=!0),S.identifierPrefix!==void 0&&(F=S.identifierPrefix),S.onUncaughtError!==void 0&&(I=S.onUncaughtError),S.onCaughtError!==void 0&&(ne=S.onCaughtError),S.onRecoverableError!==void 0&&(Ee=S.onRecoverableError),S.formState!==void 0&&(Ge=S.formState)),b=TU(m,1,!0,b,S??null,T,F,Ge,I,ne,Ee,zU),b.context=MU(null),S=b.current,T=wo(),T=zt(T),F=ku(T),F.callback=null,Au(S,F,T),S=T,b.current.lanes=S,Vt(b,S),uc(b),m[or]=b.current,oM(m),new Xw(b)},Qx.version="19.2.4",Qx}var YU;function yle(){if(YU)return MM.exports;YU=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(),MM.exports=xle(),MM.exports}var vle=yle();const wn=t=>typeof t=="string",Zx=()=>{let t,e;const n=new Promise((r,i)=>{t=r,e=i});return n.resolve=t,n.reject=e,n},QU=t=>t==null?"":""+t,wle=(t,e,n)=>{t.forEach(r=>{e[r]&&(n[r]=e[r])})},Sle=/###/g,ZU=t=>t&&t.indexOf("###")>-1?t.replace(Sle,"."):t,JU=t=>!t||wn(t),Uy=(t,e,n)=>{const r=wn(e)?e.split("."):e;let i=0;for(;i<r.length-1;){if(JU(t))return{};const s=ZU(r[i]);!t[s]&&n&&(t[s]=new n),Object.prototype.hasOwnProperty.call(t,s)?t=t[s]:t={},++i}return JU(t)?{}:{obj:t,k:ZU(r[i])}},eB=(t,e,n)=>{const{obj:r,k:i}=Uy(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=Uy(t,o,Object);for(;l.obj===void 0&&o.length;)s=`${o[o.length-1]}.${s}`,o=o.slice(0,o.length-1),l=Uy(t,o,Object),l?.obj&&typeof l.obj[`${l.k}.${s}`]<"u"&&(l.obj=void 0);l.obj[`${l.k}.${s}`]=n},_le=(t,e,n,r)=>{const{obj:i,k:s}=Uy(t,e,Object);i[s]=i[s]||[],i[s].push(n)},h1=(t,e)=>{const{obj:n,k:r}=Uy(t,e);if(n&&Object.prototype.hasOwnProperty.call(n,r))return n[r]},Nle=(t,e,n)=>{const r=h1(t,n);return r!==void 0?r:h1(e,n)},NK=(t,e,n)=>{for(const r in e)r!=="__proto__"&&r!=="constructor"&&(r in t?wn(t[r])||t[r]instanceof String||wn(e[r])||e[r]instanceof String?n&&(t[r]=e[r]):NK(t[r],e[r],n):t[r]=e[r]);return t},Ip=t=>t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var Cle={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};const kle=t=>wn(t)?t.replace(/[&<>"'\/]/g,e=>Cle[e]):t;class Ale{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 Tle=[" ",",","?","!",";"],Mle=new Ale(20),Ple=(t,e,n)=>{e=e||"",n=n||"";const r=Tle.filter(o=>e.indexOf(o)<0&&n.indexOf(o)<0);if(r.length===0)return!0;const i=Mle.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},Hj=(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},d0=t=>t?.replace("_","-"),Ele={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 m1{constructor(e,n={}){this.init(e,n)}init(e,n={}){this.prefix=n.prefix||"i18next:",this.logger=e||Ele,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:(wn(e[0])&&(e[0]=`${r}${this.prefix} ${e[0]}`),this.logger[n](e))}create(e){return new m1(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new m1(this.logger,e)}}var kc=new m1;let IC=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 tB extends IC{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):wn(r)&&s?l.push(...r.split(s)):l.push(r)));const c=h1(this.data,l);return!c&&!n&&!r&&e.indexOf(".")>-1&&(e=l[0],n=l[1],r=l.slice(2).join(".")),c||!o||!wn(r)?c:Hj(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),eB(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)(wn(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=h1(this.data,l)||{};o.skipCopy||(r=JSON.parse(JSON.stringify(r))),i?NK(c,r,s):c={...c,...r},eB(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 CK={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 kK=Symbol("i18next/PATH_KEY");function jle(){const t=[],e=Object.create(null);let n;return e.get=(r,i)=>(n?.revoke?.(),i===kK?t:(t.push(i),n=Proxy.revocable(r,e),n.proxy)),Proxy.revocable(Object.create(null),e).proxy}function $j(t,e){const{[kK]:n}=t(jle());return n.join(e?.keySeparator??".")}const nB={},DM=t=>!wn(t)&&typeof t!="boolean"&&typeof t!="number";class f1 extends IC{constructor(e,n={}){super(),wle(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=kc.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=DM(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&&!Ple(e,r,i);if(o&&!l){const c=e.match(this.interpolator.nestingRegexp);if(c&&c.length>0)return{key:e,namespaces:wn(s)?[s]:s};const d=e.split(r);(r!==i||r===i&&this.options.ns.indexOf(d[0])>-1)&&(s=d.shift()),e=d.join(i)}return{key:e,namespaces:wn(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=$j(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),d=c[c.length-1];let u=i.nsSeparator!==void 0?i.nsSeparator:this.options.nsSeparator;u===void 0&&(u=":");const h=i.lng||this.language,f=i.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(h?.toLowerCase()==="cimode")return f?s?{res:`${d}${u}${l}`,usedKey:l,exactUsedKey:l,usedLng:h,usedNS:d,usedParams:this.getUsedParamsDetails(i)}:`${d}${u}${l}`:s?{res:l,usedKey:l,exactUsedKey:l,usedLng:h,usedNS:d,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&&!wn(i.count),k=f1.hasDefaultValue(i),P=A?this.pluralResolver.getSuffix(h,i.count,i):"",C=i.ordinal&&A?this.pluralResolver.getSuffix(h,i.count,{ordinal:!1}):"",j=A&&!i.ordinal&&i.count===0,M=j&&i[`defaultValue${this.options.pluralSeparator}zero`]||i[`defaultValue${P}`]||i[`defaultValue${C}`]||i.defaultValue;let E=x;N&&!x&&k&&(E=M);const B=DM(E),L=Object.prototype.toString.apply(E);if(N&&E&&B&&y.indexOf(L)<0&&!(wn(_)&&Array.isArray(E))){if(!i.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const U=this.options.returnedObjectHandler?this.options.returnedObjectHandler(v,E,{...i,ns:c}):`key '${l} (${this.language})' returned an object instead of string.`;return s?(p.res=U,p.usedParams=this.getUsedParamsDetails(i),p):U}if(o){const U=Array.isArray(E),D=U?[]:{},$=U?g:v;for(const q in E)if(Object.prototype.hasOwnProperty.call(E,q)){const z=`${$}${o}${q}`;k&&!x?D[q]=this.translate(z,{...i,defaultValue:DM(M)?M[q]:void 0,joinArrays:!1,ns:c}):D[q]=this.translate(z,{...i,joinArrays:!1,ns:c}),D[q]===z&&(D[q]=E[q])}x=D}}else if(N&&wn(_)&&Array.isArray(x))x=x.join(_),x&&(x=this.extendTranslation(x,e,i,r));else{let U=!1,D=!1;!this.isValidLookup(x)&&k&&(U=!0,x=M),this.isValidLookup(x)||(D=!0,x=l);const q=(i.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&D?void 0:x,z=k&&M!==x&&this.options.updateMissing;if(D||U||z){if(this.logger.log(z?"updateKey":"missingKey",h,d,l,z?M:x),o){const H=this.resolve(l,{...i,keySeparator:!1});H&&H.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let W=[];const Q=this.languageUtils.getFallbackCodes(this.options.fallbackLng,i.lng||this.language);if(this.options.saveMissingTo==="fallback"&&Q&&Q[0])for(let H=0;H<Q.length;H++)W.push(Q[H]);else this.options.saveMissingTo==="all"?W=this.languageUtils.toResolveHierarchy(i.lng||this.language):W.push(i.lng||this.language);const te=(H,X,Z)=>{const ee=k&&Z!==x?Z:q;this.options.missingKeyHandler?this.options.missingKeyHandler(H,d,X,ee,z,i):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(H,d,X,ee,z,i),this.emit("missingKey",H,d,X,x)};this.options.saveMissing&&(this.options.saveMissingPlurals&&A?W.forEach(H=>{const X=this.pluralResolver.getSuffixes(H,i);j&&i[`defaultValue${this.options.pluralSeparator}zero`]&&X.indexOf(`${this.options.pluralSeparator}zero`)<0&&X.push(`${this.options.pluralSeparator}zero`),X.forEach(Z=>{te([H],l+Z,i[`defaultValue${Z}`]||M)})}):te(W,l,M))}x=this.extendTranslation(x,e,i,p,r),D&&x===l&&this.options.appendNamespaceToMissingKey&&(x=`${d}${u}${l}`),(D||U)&&this.options.parseMissingKeyHandler&&(x=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${d}${u}${l}`:l,U?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=wn(e)&&(r?.interpolation?.skipOnVariables!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let d;if(c){const h=e.match(this.interpolator.nestingRegexp);d=h&&h.length}let u=r.replace&&!wn(r.replace)?r.replace:r;if(this.options.interpolation.defaultVariables&&(u={...this.options.interpolation.defaultVariables,...u}),e=this.interpolator.interpolate(e,u,r.lng||this.language||i.usedLng,r),c){const h=e.match(this.interpolator.nestingRegexp),f=h&&h.length;d<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=wn(o)?[o]:o;return e!=null&&l?.length&&r.applyPostProcessor!==!1&&(e=CK.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 wn(e)&&(e=[e]),e.forEach(c=>{if(this.isValidLookup(r))return;const d=this.extractFromKey(c,n),u=d.key;i=u;let h=d.namespaces;this.options.fallbackNS&&(h=h.concat(this.options.fallbackNS));const f=n.count!==void 0&&!wn(n.count),p=f&&!n.ordinal&&n.count===0,x=n.context!==void 0&&(wn(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,!nB[`${v[0]}-${g}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(l)&&(nB[`${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 _=[u];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(_,u,y,g,n);else{let A;f&&(A=this.pluralResolver.getSuffix(y,n.count,n));const k=`${this.options.pluralSeparator}zero`,P=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(f&&(n.ordinal&&A.indexOf(P)===0&&_.push(u+A.replace(P,this.options.pluralSeparator)),_.push(u+A),p&&_.push(u+k)),x){const C=`${u}${this.options.contextSeparator||"_"}${n.context}`;_.push(C),f&&(n.ordinal&&A.indexOf(P)===0&&_.push(C+A.replace(P,this.options.pluralSeparator)),_.push(C+A),p&&_.push(C+k))}}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&&!wn(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 rB{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=kc.create("languageUtils")}getScriptPartFromCode(e){if(e=d0(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=d0(e),!e||e.indexOf("-")<0)return e;const n=e.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(e){if(wn(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)),wn(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 wn(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))):wn(e)&&s(this.formatLanguageCode(e)),r.forEach(o=>{i.indexOf(o)<0&&s(this.formatLanguageCode(o))}),i}}const aB={zero:0,one:1,two:2,few:3,many:4,other:5},iB={select:t=>t===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class Dle{constructor(e,n={}){this.languageUtils=e,this.options=n,this.logger=kc.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,n){this.rules[e]=n}clearCache(){this.pluralRulesCache={}}getRule(e,n={}){const r=d0(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!"),iB;if(!e.match(/-|_/))return iB;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)=>aB[i]-aB[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 sB=(t,e,n,r=".",i=!0)=>{let s=Nle(t,e,n);return!s&&i&&wn(n)&&(s=Hj(t,n,r),s===void 0&&(s=Hj(e,n,r))),s},RM=t=>t.replace(/\$/g,"$$$$");class Rle{constructor(e={}){this.logger=kc.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:d,unescapeSuffix:u,unescapePrefix:h,nestingPrefix:f,nestingPrefixEscaped:p,nestingSuffix:x,nestingSuffixEscaped:v,nestingOptionsSeparator:g,maxReplaces:y,alwaysFormat:_}=e.interpolation;this.escape=n!==void 0?n:kle,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=i!==void 0?i:!1,this.prefix=s?Ip(s):o||"{{",this.suffix=l?Ip(l):c||"}}",this.formatSeparator=d||",",this.unescapePrefix=u?"":h||"-",this.unescapeSuffix=this.unescapePrefix?"":u||"",this.nestingPrefix=f?Ip(f):p||Ip("$t("),this.nestingSuffix=x?Ip(x):v||Ip(")"),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||{},d=p=>{if(p.indexOf(this.formatSeparator)<0){const y=sB(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(sB(n,c,v,this.options.keySeparator,this.options.ignoreJSONStructure),g,r,{...i,...n,interpolationkey:v})};this.resetRegExp();const u=i?.missingInterpolationHandler||this.options.missingInterpolationHandler,h=i?.interpolation?.skipOnVariables!==void 0?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:p=>RM(p)},{regex:this.regexp,safeValue:p=>this.escapeValue?RM(this.escape(p)):RM(p)}].forEach(p=>{for(l=0;s=p.regex.exec(e);){const x=s[1].trim();if(o=d(x),o===void 0)if(typeof u=="function"){const g=u(e,s,i);o=wn(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!wn(o)&&!this.useRawValueToEscape&&(o=QU(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,d)=>{const u=this.nestingOptionsSeparator;if(c.indexOf(u)<0)return c;const h=c.split(new RegExp(`${u}[ ]*{`));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),d&&(o={...d,...o})}catch(v){return this.logger.warn(`failed parsing options string in nesting for key ${c}`,v),`${c}${u}${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&&!wn(o.replace)?o.replace:o,o.applyPostProcessor=!1,delete o.defaultValue;const d=/{.*}/.test(i[1])?i[1].lastIndexOf("}")+1:i[1].indexOf(this.formatSeparator);if(d!==-1&&(c=i[1].slice(d).split(this.formatSeparator).map(u=>u.trim()).filter(Boolean),i[1]=i[1].slice(0,d)),s=n(l.call(this,i[1].trim(),o),o),s&&i[0]===e&&!wn(s))return s;wn(s)||(s=QU(s)),s||(this.logger.warn(`missed to resolve ${i[1]} for nesting ${e}`),s=""),c.length&&(s=c.reduce((u,h)=>this.format(u,h,r.lng,{...r,interpolationkey:i[1].trim()}),s.trim())),e=e.replace(i[0],s),this.regexp.lastIndex=0}return e}}const Fle=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(":"),d=c.join(":").trim().replace(/^'+|'+$/g,""),u=l.trim();n[u]||(n[u]=d),d==="false"&&(n[u]=!1),d==="true"&&(n[u]=!0),isNaN(d)||(n[u]=parseInt(d,10))}})}return{formatName:e,formatOptions:n}},oB=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(d0(r),i),e[o]=l),l(n)}},Lle=t=>(e,n,r)=>t(d0(n),r)(e);class Ole{constructor(e={}){this.logger=kc.create("formatter"),this.options=e,this.init(e)}init(e,n={interpolation:{}}){this.formatSeparator=n.interpolation.formatSeparator||",";const r=n.cacheInBuiltFormats?oB:Lle;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()]=oB(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:d,formatOptions:u}=Fle(c);if(this.formats[d]){let h=l;try{const f=i?.formatParams?.[i.interpolationkey]||{},p=f.locale||f.lng||i.locale||i.lng||r;h=this.formats[d](l,p,{...u,...i,...f})}catch(f){this.logger.warn(f)}return h}else this.logger.warn(`there was no format function for ${d}`);return l},e)}}const Ile=(t,e)=>{t.pending[e]!==void 0&&(delete t.pending[e],t.pendingCount--)};class zle extends IC{constructor(e,n,r,i={}){super(),this.backend=e,this.store=n,this.services=r,this.languageUtils=r.languageUtils,this.options=i,this.logger=kc.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(d=>{let u=!0;n.forEach(h=>{const f=`${d}|${h}`;!r.reload&&this.store.hasResourceBundle(d,h)?this.state[f]=2:this.state[f]<0||(this.state[f]===1?o[f]===void 0&&(o[f]=!0):(this.state[f]=1,u=!1,o[f]===void 0&&(o[f]=!0),s[f]===void 0&&(s[f]=!0),c[h]===void 0&&(c[h]=!0)))}),u||(l[d]=!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=>{_le(c.loaded,[s],o),Ile(c,e),n&&c.errors.push(n),c.pendingCount===0&&!c.done&&(Object.keys(c.loaded).forEach(d=>{l[d]||(l[d]={});const u=c.loaded[d];u.length&&u.forEach(h=>{l[d][h]===void 0&&(l[d][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=(d,u)=>{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(d&&u&&i<this.maxRetries){setTimeout(()=>{this.read.call(this,e,n,r,i+1,s*2,o)},s);return}o(d,u)},c=this.backend[r].bind(this.backend);if(c.length===2){try{const d=c(e,n);d&&typeof d.then=="function"?d.then(u=>l(null,u)).catch(l):l(null,d)}catch(d){l(d)}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();wn(e)&&(e=this.languageUtils.toResolveHierarchy(e)),wn(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},d=this.backend.create.bind(this.backend);if(d.length<6)try{let u;d.length===5?u=d(e,n,r,i,c):u=d(e,n,r,i),u&&typeof u.then=="function"?u.then(h=>l(null,h)).catch(l):l(null,u)}catch(u){l(u)}else d(e,n,r,i,l,c)}!e||!e[0]||this.store.addResource(e[0],n,r,i)}}}const lB=()=>({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]),wn(t[1])&&(e.defaultValue=t[1]),wn(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}),cB=t=>(wn(t.ns)&&(t.ns=[t.ns]),wn(t.fallbackLng)&&(t.fallbackLng=[t.fallbackLng]),wn(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),Zw=()=>{},Ule=t=>{Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(n=>{typeof t[n]=="function"&&(t[n]=t[n].bind(t))})};class By extends IC{constructor(e={},n){if(super(),this.options=cB(e),this.services={},this.logger=kc,this.modules={external:[]},Ule(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&&(wn(e.ns)?e.defaultNS=e.ns:e.ns.indexOf("translation")<0&&(e.defaultNS=e.ns[0]));const r=lB();this.options={...r,...this.options,...cB(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=d=>d?typeof d=="function"?new d:d:null;if(!this.options.isClone){this.modules.logger?kc.init(i(this.modules.logger),this.options):kc.init(null,this.options);let d;this.modules.formatter?d=this.modules.formatter:d=Ole;const u=new rB(this.options);this.store=new tB(this.options.resources,this.options);const h=this.services;h.logger=kc,h.resourceStore=this.store,h.languageUtils=u,h.pluralResolver=new Dle(u,{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"),d&&(!this.options.interpolation.format||this.options.interpolation.format===r.interpolation.format)&&(h.formatter=i(d),h.formatter.init&&h.formatter.init(h,this.options),this.options.interpolation.format=h.formatter.format.bind(h.formatter)),h.interpolator=new Rle(this.options),h.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},h.backendConnector=new zle(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 f1(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=Zw),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const d=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);d.length>0&&d[0]!=="dev"&&(this.options.lng=d[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(d=>{this[d]=(...u)=>this.store[d](...u)}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(d=>{this[d]=(...u)=>(this.store[d](...u),this)});const l=Zx(),c=()=>{const d=(u,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(u,h)};if(this.languages&&!this.isInitialized)return d(null,this.t.bind(this));this.changeLanguage(this.options.lng,d)};return this.options.resources||!this.options.initAsync?c():setTimeout(c,0),l}loadResources(e,n=Zw){let r=n;const i=wn(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(d=>{d!=="cimode"&&s.indexOf(d)<0&&s.push(d)})};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=Zx();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=Zw),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"&&CK.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=Zx();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((...d)=>this.t(...d)),n&&n(l,(...d)=>this.t(...d))},o=l=>{!e&&!l&&this.services.languageDetector&&(l=[]);const c=wn(l)?l:l&&l[0],d=this.store.hasLanguageSomeTranslations(c)?c:this.services.languageUtils.getBestMatchFromCodes(wn(l)?[l]:l);d&&(this.language||i(d),this.translator.language||this.translator.changeLanguage(d),this.services.languageDetector?.cacheUserLanguage?.(d)),this.loadResources(d,u=>{s(u,d)})};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 d=this.options.keySeparator||".";let u;return c.keyPrefix&&Array.isArray(s)?u=s.map(h=>(typeof h=="function"&&(h=$j(h,{...this.options,...o})),`${c.keyPrefix}${d}${h}`)):(typeof s=="function"&&(s=$j(s,{...this.options,...o})),u=c.keyPrefix?`${c.keyPrefix}${d}${s}`:s),this.t(u,c)};return wn(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 d=this.services.backendConnector.state[`${l}|${c}`];return d===-1||d===0||d===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=Zx();return this.options.ns?(wn(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=Zx();wn(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 rB(lB());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 By(e,n);return r.createInstance=By.createInstance,r}cloneInstance(e={},n=Zw){const r=e.forkResourceStore;r&&delete e.forkResourceStore;const i={...this.options,...e,isClone:!0},s=new By(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,d)=>(c[d]={...this.store.data[d]},c[d]=Object.keys(c[d]).reduce((u,h)=>(u[h]={...c[d][h]},u),c[d]),c),{});s.store=new tB(l,i),s.services.resourceStore=s.store}return s.translator=new f1(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 Us=By.createInstance();Us.createInstance;Us.dir;Us.init;Us.loadResources;Us.reloadResources;Us.use;Us.changeLanguage;Us.getFixedT;Us.t;Us.exists;Us.setDefaultNamespace;Us.hasLoadedNamespace;Us.loadNamespaces;Us.loadLanguages;const Ble=(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);kf(i[0])&&(i[0]=`react-i18next:: ${i[0]}`),t?.services?.logger?.warn?t.services.logger.warn(...i):console?.warn&&console.warn(...i)},dB={},AK=(t,e,n,r)=>{kf(n)&&dB[n]||(kf(n)&&(dB[n]=new Date),Ble(t,e,n,r))},TK=(t,e)=>()=>{if(t.isInitialized)e();else{const n=()=>{setTimeout(()=>{t.off("initialized",n)},0),e()};t.on("initialized",n)}},Vj=(t,e,n)=>{t.loadNamespaces(e,TK(t,n))},uB=(t,e,n,r)=>{if(kf(n)&&(n=[n]),t.options.preload&&t.options.preload.indexOf(e)>-1)return Vj(t,n,r);n.forEach(i=>{t.options.ns.indexOf(i)<0&&t.options.ns.push(i)}),t.loadLanguages(e,TK(t,r))},Hle=(t,e,n={})=>!e.languages||!e.languages.length?(AK(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}}),kf=t=>typeof t=="string",$le=t=>typeof t=="object"&&t!==null,Vle=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,qle={"&":"&","&":"&","<":"<","<":"<",">":">",">":">","'":"'","'":"'",""":'"',""":'"'," ":" "," ":" ","©":"©","©":"©","®":"®","®":"®","…":"…","…":"…","/":"/","/":"/"},Gle=t=>qle[t],Wle=t=>t.replace(Vle,Gle);let qj={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:Wle,transDefaultProps:void 0};const Kle=(t={})=>{qj={...qj,...t}},Xle=()=>qj;let MK;const Yle=t=>{MK=t},Qle=()=>MK,Zle={type:"3rdParty",init(t){Kle(t.options.react),Yle(t)}},Jle=w.createContext();class ece{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach(n=>{this.usedNamespaces[n]||(this.usedNamespaces[n]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}var FM={exports:{}},LM={};var hB;function tce(){if(hB)return LM;hB=1;var t=zb();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 d(h,f){return f()}var u=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?d:l;return LM.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:u,LM}var mB;function PK(){return mB||(mB=1,FM.exports=tce()),FM.exports}var cF=PK();const nce=(t,e)=>kf(e)?e:$le(e)&&kf(e.defaultValue)?e.defaultValue:Array.isArray(t)?t[t.length-1]:t,rce={t:nce,ready:!1},ace=()=>()=>{},Dt=(t,e={})=>{const{i18n:n}=e,{i18n:r,defaultNS:i}=w.useContext(Jle)||{},s=n||r||Qle();s&&!s.reportNamespaces&&(s.reportNamespaces=new ece),s||AK(s,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const o=w.useMemo(()=>({...Xle(),...s?.options?.react,...e}),[s,e]),{useSuspense:l,keyPrefix:c}=o,d=i||s?.options?.defaultNS,u=kf(d)?[d]:d||["translation"],h=w.useMemo(()=>u,u);s?.reportNamespaces?.addUsedNamespaces?.(h);const f=w.useRef(0),p=w.useCallback(M=>{if(!s)return ace;const{bindI18n:E,bindI18nStore:B}=o,L=()=>{f.current+=1,M()};return E&&s.on(E,L),B&&s.store.on(B,L),()=>{E&&E.split(" ").forEach(U=>s.off(U,L)),B&&B.split(" ").forEach(U=>s.store.off(U,L))}},[s,o]),x=w.useRef(),v=w.useCallback(()=>{if(!s)return rce;const M=!!(s.isInitialized||s.initializedStoreOnce)&&h.every($=>Hle($,s,o)),E=e.lng||s.language,B=f.current,L=x.current;if(L&&L.ready===M&&L.lng===E&&L.keyPrefix===c&&L.revision===B)return L;const D={t:s.getFixedT(E,o.nsMode==="fallback"?h:h[0],c),ready:M,lng:E,keyPrefix:c,revision:B};return x.current=D,D},[s,h,c,o,e.lng]),[g,y]=w.useState(0),{t:_,ready:N}=cF.useSyncExternalStore(p,v,v);w.useEffect(()=>{if(s&&!N&&!l){const M=()=>y(E=>E+1);e.lng?uB(s,e.lng,h,M):Vj(s,h,M)}},[s,e.lng,h,N,l,g]);const A=s||{},k=w.useRef(null),P=w.useRef(),C=M=>{const E=Object.getOwnPropertyDescriptors(M);E.__original&&delete E.__original;const B=Object.create(Object.getPrototypeOf(M),E);if(!Object.prototype.hasOwnProperty.call(B,"__original"))try{Object.defineProperty(B,"__original",{value:M,writable:!1,enumerable:!1,configurable:!1})}catch{}return B},j=w.useMemo(()=>{const M=A,E=M?.language;let B=M;M&&(k.current&&k.current.__original===M?P.current!==E?(B=C(M),k.current=B,P.current=E):B=k.current:(B=C(M),k.current=B,P.current=E));const L=[_,B,N];return L.t=_,L.i18n=B,L.ready=N,L},[_,A,N,A.resolvedLanguage,A.language,A.languages]);if(s&&l&&!N)throw new Promise(M=>{const E=()=>M();e.lng?uB(s,e.lng,h,E):Vj(s,h,E)});return j},{slice:ice,forEach:sce}=[];function oce(t){return sce.call(ice.call(arguments,1),e=>{if(e)for(const n in e)t[n]===void 0&&(t[n]=e[n])}),t}function lce(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 fB=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,cce=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(!fB.test(r.domain))throw new TypeError("option domain is invalid");s+=`; Domain=${r.domain}`}if(r.path){if(!fB.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},pB={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=cce(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 dce={name:"cookie",lookup(t){let{lookupCookie:e}=t;if(e&&typeof document<"u")return pB.read(e)||void 0},cacheUserLanguage(t,e){let{lookupCookie:n,cookieMinutes:r,cookieDomain:i,cookieOptions:s}=e;n&&typeof document<"u"&&pB.create(n,t,r,i,s)}},uce={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}},hce={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 zp=null;const gB=()=>{if(zp!==null)return zp;try{if(zp=typeof window<"u"&&window.localStorage!==null,!zp)return!1;const t="i18next.translate.boo";window.localStorage.setItem(t,"foo"),window.localStorage.removeItem(t)}catch{zp=!1}return zp};var mce={name:"localStorage",lookup(t){let{lookupLocalStorage:e}=t;if(e&&gB())return window.localStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupLocalStorage:n}=e;n&&gB()&&window.localStorage.setItem(n,t)}};let Up=null;const bB=()=>{if(Up!==null)return Up;try{if(Up=typeof window<"u"&&window.sessionStorage!==null,!Up)return!1;const t="i18next.translate.boo";window.sessionStorage.setItem(t,"foo"),window.sessionStorage.removeItem(t)}catch{Up=!1}return Up};var fce={name:"sessionStorage",lookup(t){let{lookupSessionStorage:e}=t;if(e&&bB())return window.sessionStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupSessionStorage:n}=e;n&&bB()&&window.sessionStorage.setItem(n,t)}},pce={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}},gce={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}},bce={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}},xce={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 EK=!1;try{document.cookie,EK=!0}catch{}const jK=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];EK||jK.splice(1,1);const yce=()=>({order:jK,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:t=>t});class DK{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=oce(n,this.options||{},yce()),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(dce),this.addDetector(uce),this.addDetector(mce),this.addDetector(fce),this.addDetector(pce),this.addDetector(gce),this.addDetector(bce),this.addDetector(xce),this.addDetector(hce)}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&&!lce(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)}))}}DK.type="languageDetector";const vce={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"},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"},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",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",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"},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:{scaleCalibration:"Scale Calibration",currentWeight:"Current weight",tareOffset:"Tare offset",calFactor:"Cal. factor",knownWeight:"Known weight (g)",calStep1:"Step 1: Remove all items from the scale",calStep2:"Step 2: Place known weight on scale",setZero:"Set Zero",calibrateNow:"Calibrate",calibrated:"Calibrated",deviceInfo:"Device Info",hostname:"Hostname",firmware:"Firmware",scale:"Scale",uptime:"Uptime",noDevice:"No SpoolBuddy device found"}}},wce={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"},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"},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",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",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"},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:{scaleCalibration:"Waagen-Kalibrierung",currentWeight:"Aktuelles Gewicht",tareOffset:"Tara-Offset",calFactor:"Kal.-Faktor",knownWeight:"Bekanntes Gewicht (g)",calStep1:"Schritt 1: Alle Gegenstände von der Waage entfernen",calStep2:"Schritt 2: Bekanntes Gewicht auf die Waage legen",setZero:"Nullpunkt setzen",calibrateNow:"Kalibrieren",calibrated:"Kalibriert",deviceInfo:"Geräteinfo",hostname:"Hostname",firmware:"Firmware",scale:"Waage",uptime:"Betriebszeit",noDevice:"Kein SpoolBuddy-Gerät gefunden"}}},Sce={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"},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"},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",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",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:{scaleCalibration:"Calibration de la balance",currentWeight:"Poids actuel",tareOffset:"Décalage tare",calFactor:"Facteur cal.",knownWeight:"Poids connu (g)",calStep1:"Étape 1 : Retirez tout de la balance",calStep2:"Étape 2 : Placez le poids connu sur la balance",setZero:"Mettre à zéro",calibrateNow:"Calibrer",calibrated:"Calibré",deviceInfo:"Info appareil",hostname:"Nom d'hôte",firmware:"Firmware",scale:"Balance",uptime:"Temps de fonctionnement",noDevice:"Aucun appareil SpoolBuddy trouvé"}}},_ce={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:"スマートプラグを制御する権限がありません"},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:"統計を読み込み中..."},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%未満",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:"インベントリ",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:"閉じる"},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:{scaleCalibration:"計量キャリブレーション",currentWeight:"現在の重量",tareOffset:"風袋オフセット",calFactor:"キャリブレーション係数",knownWeight:"既知の重量 (g)",calStep1:"ステップ1:計量台からすべてのアイテムを取り除く",calStep2:"ステップ2:既知の重量を計量台に置く",setZero:"ゼロ設定",calibrateNow:"キャリブレーション",calibrated:"キャリブレーション済み",deviceInfo:"デバイス情報",hostname:"ホスト名",firmware:"ファームウェア",scale:"計量",uptime:"稼働時間",noDevice:"SpoolBuddyデバイスが見つかりません"}}},Nce={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"},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"},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"},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",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:{scaleCalibration:"Calibrazione bilancia",currentWeight:"Peso attuale",tareOffset:"Offset tara",calFactor:"Fattore cal.",knownWeight:"Peso noto (g)",calStep1:"Passaggio 1: Rimuovere tutto dalla bilancia",calStep2:"Passaggio 2: Posizionare il peso noto sulla bilancia",setZero:"Imposta zero",calibrateNow:"Calibra",calibrated:"Calibrato",deviceInfo:"Info dispositivo",hostname:"Hostname",firmware:"Firmware",scale:"Bilancia",uptime:"Tempo di attività",noDevice:"Nessun dispositivo SpoolBuddy trovato"}}},Cce={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"},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"},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",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",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:{scaleCalibration:"Calibração da balança",currentWeight:"Peso atual",tareOffset:"Offset de tara",calFactor:"Fator de cal.",knownWeight:"Peso conhecido (g)",calStep1:"Passo 1: Remova todos os itens da balança",calStep2:"Passo 2: Coloque o peso conhecido na balança",setZero:"Definir zero",calibrateNow:"Calibrar",calibrated:"Calibrado",deviceInfo:"Info do dispositivo",hostname:"Hostname",firmware:"Firmware",scale:"Balança",uptime:"Tempo de atividade",noDevice:"Nenhum dispositivo SpoolBuddy encontrado"}}},kce={en:{translation:vce},de:{translation:wce},fr:{translation:Sce},ja:{translation:_ce},it:{translation:Nce},"pt-BR":{translation:Cce}};Us.use(DK).use(Zle).init({resources:kce,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 xB=[{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 yB="popstate";function Ace(t={}){function e(r,i){let{pathname:s,search:o,hash:l}=r.location;return Gj("",{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:u0(i)}return Mce(e,n,null,t)}function pa(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function vl(t,e){if(!t){typeof console<"u"&&console.warn(e);try{throw new Error(e)}catch{}}}function Tce(){return Math.random().toString(36).substring(2,10)}function vB(t,e){return{usr:t.state,key:t.key,idx:e}}function Gj(t,e,n=null,r){return{pathname:typeof t=="string"?t:t.pathname,search:"",hash:"",...typeof e=="string"?Ub(e):e,state:n,key:e&&e.key||r||Tce()}}function u0({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 Ub(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 Mce(t,e,n,r={}){let{window:i=document.defaultView,v5Compat:s=!1}=r,o=i.history,l="POP",c=null,d=u();d==null&&(d=0,o.replaceState({...o.state,idx:d},""));function u(){return(o.state||{idx:null}).idx}function h(){l="POP";let g=u(),y=g==null?null:g-d;d=g,c&&c({action:l,location:v.location,delta:y})}function f(g,y){l="PUSH";let _=Gj(v.location,g,y);d=u()+1;let N=vB(_,d),A=v.createHref(_);try{o.pushState(N,"",A)}catch(k){if(k instanceof DOMException&&k.name==="DataCloneError")throw k;i.location.assign(A)}s&&c&&c({action:l,location:v.location,delta:1})}function p(g,y){l="REPLACE";let _=Gj(v.location,g,y);d=u();let N=vB(_,d),A=v.createHref(_);o.replaceState(N,"",A),s&&c&&c({action:l,location:v.location,delta:0})}function x(g){return Pce(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(yB,h),c=g,()=>{i.removeEventListener(yB,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 Pce(t,e=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),pa(n,"No window.location.(origin|href) available to create URL");let r=typeof t=="string"?t:u0(t);return r=r.replace(/ $/,"%20"),!e&&r.startsWith("//")&&(r=n+r),new URL(r,n)}function RK(t,e,n="/"){return Ece(t,e,n,!1)}function Ece(t,e,n,r){let i=typeof e=="string"?Ub(e):e,s=Jd(i.pathname||"/",n);if(s==null)return null;let o=FK(t);jce(o);let l=null;for(let c=0;l==null&&c<o.length;++c){let d=$ce(s);l=Bce(o[c],d,r)}return l}function FK(t,e=[],n=[],r="",i=!1){let s=(o,l,c=i,d)=>{let u={relativePath:d===void 0?o.path||"":d,caseSensitive:o.caseSensitive===!0,childrenIndex:l,route:o};if(u.relativePath.startsWith("/")){if(!u.relativePath.startsWith(r)&&c)return;pa(u.relativePath.startsWith(r),`Absolute route path "${u.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),u.relativePath=u.relativePath.slice(r.length)}let h=Vd([r,u.relativePath]),f=n.concat(u);o.children&&o.children.length>0&&(pa(o.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${h}".`),FK(o.children,e,f,h,c)),!(o.path==null&&!o.index)&&e.push({path:h,score:zce(h,o.index),routesMeta:f})};return t.forEach((o,l)=>{if(o.path===""||!o.path?.includes("?"))s(o,l);else for(let c of LK(o.path))s(o,l,!0,c)}),e}function LK(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=LK(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 jce(t){t.sort((e,n)=>e.score!==n.score?n.score-e.score:Uce(e.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var Dce=/^:[\w-]+$/,Rce=3,Fce=2,Lce=1,Oce=10,Ice=-2,wB=t=>t==="*";function zce(t,e){let n=t.split("/"),r=n.length;return n.some(wB)&&(r+=Ice),e&&(r+=Fce),n.filter(i=>!wB(i)).reduce((i,s)=>i+(Dce.test(s)?Rce:s===""?Lce:Oce),r)}function Uce(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 Bce(t,e,n=!1){let{routesMeta:r}=t,i={},s="/",o=[];for(let l=0;l<r.length;++l){let c=r[l],d=l===r.length-1,u=s==="/"?e:e.slice(s.length)||"/",h=p1({path:c.relativePath,caseSensitive:c.caseSensitive,end:d},u),f=c.route;if(!h&&d&&n&&!r[r.length-1].route.index&&(h=p1({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},u)),!h)return null;Object.assign(i,h.params),o.push({params:i,pathname:Vd([s,h.pathname]),pathnameBase:Wce(Vd([s,h.pathnameBase])),route:f}),h.pathnameBase!=="/"&&(s=Vd([s,h.pathnameBase]))}return o}function p1(t,e){typeof t=="string"&&(t={path:t,caseSensitive:!1,end:!0});let[n,r]=Hce(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((d,{paramName:u,isOptional:h},f)=>{if(u==="*"){let x=l[f]||"";o=s.slice(0,s.length-x.length).replace(/(.)\/+$/,"$1")}const p=l[f];return h&&!p?d[u]=void 0:d[u]=(p||"").replace(/%2F/g,"/"),d},{}),pathname:s,pathnameBase:o,pattern:t}}function Hce(t,e=!1,n=!0){vl(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 $ce(t){try{return t.split("/").map(e=>decodeURIComponent(e).replace(/\//g,"%2F")).join("/")}catch(e){return vl(!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 Jd(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 Vce=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function qce(t,e="/"){let{pathname:n,search:r="",hash:i=""}=typeof t=="string"?Ub(t):t,s;return n?(n=n.replace(/\/\/+/g,"/"),n.startsWith("/")?s=SB(n.substring(1),"/"):s=SB(n,e)):s=e,{pathname:s,search:Kce(r),hash:Xce(i)}}function SB(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 OM(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 Gce(t){return t.filter((e,n)=>n===0||e.route.path&&e.route.path.length>0)}function dF(t){let e=Gce(t);return e.map((n,r)=>r===e.length-1?n.pathname:n.pathnameBase)}function uF(t,e,n,r=!1){let i;typeof t=="string"?i=Ub(t):(i={...t},pa(!i.pathname||!i.pathname.includes("?"),OM("?","pathname","search",i)),pa(!i.pathname||!i.pathname.includes("#"),OM("#","pathname","hash",i)),pa(!i.search||!i.search.includes("#"),OM("#","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=qce(i,l),d=o&&o!=="/"&&o.endsWith("/"),u=(s||o===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(d||u)&&(c.pathname+="/"),c}var Vd=t=>t.join("/").replace(/\/\/+/g,"/"),Wce=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),Kce=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,Xce=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t,Yce=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 Qce(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}function Zce(t){return t.map(e=>e.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var OK=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function IK(t,e){let n=t;if(typeof n!="string"||!Vce.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,i=!1;if(OK)try{let s=new URL(window.location.href),o=n.startsWith("//")?new URL(s.protocol+n):new URL(n),l=Jd(o.pathname,e);o.origin===s.origin&&l!=null?n=l+o.search+o.hash:i=!0}catch{vl(!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 zK=["POST","PUT","PATCH","DELETE"];new Set(zK);var Jce=["GET",...zK];new Set(Jce);var Bb=w.createContext(null);Bb.displayName="DataRouter";var zC=w.createContext(null);zC.displayName="DataRouterState";var ede=w.createContext(!1),UK=w.createContext({isTransitioning:!1});UK.displayName="ViewTransition";var tde=w.createContext(new Map);tde.displayName="Fetchers";var nde=w.createContext(null);nde.displayName="Await";var Io=w.createContext(null);Io.displayName="Navigation";var iv=w.createContext(null);iv.displayName="Location";var Tl=w.createContext({outlet:null,matches:[],isDataRoute:!1});Tl.displayName="Route";var hF=w.createContext(null);hF.displayName="RouteError";var BK="REACT_ROUTER_ERROR",rde="REDIRECT",ade="ROUTE_ERROR_RESPONSE";function ide(t){if(t.startsWith(`${BK}:${rde}:{`))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 sde(t){if(t.startsWith(`${BK}:${ade}:{`))try{let e=JSON.parse(t.slice(40));if(typeof e=="object"&&e&&typeof e.status=="number"&&typeof e.statusText=="string")return new Yce(e.status,e.statusText,e.data)}catch{}}function ode(t,{relative:e}={}){pa(Hb(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:r}=w.useContext(Io),{hash:i,pathname:s,search:o}=ov(t,{relative:e}),l=s;return n!=="/"&&(l=s==="/"?n:Vd([n,s])),r.createHref({pathname:l,search:o,hash:i})}function Hb(){return w.useContext(iv)!=null}function qc(){return pa(Hb(),"useLocation() may be used only in the context of a <Router> component."),w.useContext(iv).location}var HK="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function $K(t){w.useContext(Io).static||w.useLayoutEffect(t)}function ac(){let{isDataRoute:t}=w.useContext(Tl);return t?wde():lde()}function lde(){pa(Hb(),"useNavigate() may be used only in the context of a <Router> component.");let t=w.useContext(Bb),{basename:e,navigator:n}=w.useContext(Io),{matches:r}=w.useContext(Tl),{pathname:i}=qc(),s=JSON.stringify(dF(r)),o=w.useRef(!1);return $K(()=>{o.current=!0}),w.useCallback((c,d={})=>{if(vl(o.current,HK),!o.current)return;if(typeof c=="number"){n.go(c);return}let u=uF(c,JSON.parse(s),i,d.relative==="path");t==null&&e!=="/"&&(u.pathname=u.pathname==="/"?e:Vd([e,u.pathname])),(d.replace?n.replace:n.push)(u,d.state,d)},[e,n,s,i,t])}var VK=w.createContext(null);function mF(){return w.useContext(VK)}function cde(t){let e=w.useContext(Tl).outlet;return w.useMemo(()=>e&&w.createElement(VK.Provider,{value:t},e),[e,t])}function sv(){let{matches:t}=w.useContext(Tl),e=t[t.length-1];return e?e.params:{}}function ov(t,{relative:e}={}){let{matches:n}=w.useContext(Tl),{pathname:r}=qc(),i=JSON.stringify(dF(n));return w.useMemo(()=>uF(t,JSON.parse(i),r,e==="path"),[t,i,r,e])}function dde(t,e){return qK(t,e)}function qK(t,e,n,r,i){pa(Hb(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:s}=w.useContext(Io),{matches:o}=w.useContext(Tl),l=o[o.length-1],c=l?l.params:{},d=l?l.pathname:"/",u=l?l.pathnameBase:"/",h=l&&l.route;{let _=h&&h.path||"";WK(d,!h||_.endsWith("*")||_.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${d}" (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.
- Please change the parent <Route path="${_}"> to <Route path="${_==="/"?"*":`${_}/*`}">.`)}let f=qc(),p;if(e){let _=typeof e=="string"?Ub(e):e;pa(u==="/"||_.pathname?.startsWith(u),`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 "${u}" but pathname "${_.pathname}" was given in the \`location\` prop.`),p=_}else p=f;let x=p.pathname||"/",v=x;if(u!=="/"){let _=u.replace(/^\//,"").split("/");v="/"+x.replace(/^\//,"").split("/").slice(_.length).join("/")}let g=RK(t,{pathname:v});vl(h||g!=null,`No routes matched location "${p.pathname}${p.search}${p.hash}" `),vl(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=pde(g&&g.map(_=>Object.assign({},_,{params:Object.assign({},c,_.params),pathname:Vd([u,s.encodeLocation?s.encodeLocation(_.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:_.pathname]),pathnameBase:_.pathnameBase==="/"?u:Vd([u,s.encodeLocation?s.encodeLocation(_.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:_.pathnameBase])})),o,n,r,i);return e&&y?w.createElement(iv.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...p},navigationType:"POP"}},y):y}function ude(){let t=vde(),e=Qce(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 hde=w.createElement(ude,null),GK=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=sde(t.digest);n&&(t=n)}let e=t!==void 0?w.createElement(Tl.Provider,{value:this.props.routeContext},w.createElement(hF.Provider,{value:t,children:this.props.component})):this.props.children;return this.context?w.createElement(mde,{error:t},e):e}};GK.contextType=ede;var IM=new WeakMap;function mde({children:t,error:e}){let{basename:n}=w.useContext(Io);if(typeof e=="object"&&e&&"digest"in e&&typeof e.digest=="string"){let r=ide(e.digest);if(r){let i=IM.get(e);if(i)throw i;let s=IK(r.location,n);if(OK&&!IM.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 IM.set(e,o),o}return w.createElement("meta",{httpEquiv:"refresh",content:`0;url=${s.absoluteURL||s.to}`})}}return t}function fde({routeContext:t,match:e,children:n}){let r=w.useContext(Bb);return r&&r.static&&r.staticContext&&(e.route.errorElement||e.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=e.route.id),w.createElement(Tl.Provider,{value:t},n)}function pde(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 u=s.findIndex(h=>h.route.id&&o?.[h.route.id]!==void 0);pa(u>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(o).join(",")}`),s=s.slice(0,Math.min(s.length,u+1))}let l=!1,c=-1;if(n)for(let u=0;u<s.length;u++){let h=s[u];if((h.route.HydrateFallback||h.route.hydrateFallbackElement)&&(c=u),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 d=n&&r?(u,h)=>{r(u,{location:n.location,params:n.matches?.[0]?.params??{},unstable_pattern:Zce(n.matches),errorInfo:h})}:void 0;return s.reduceRight((u,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||hde,l&&(c<0&&f===0?(WK("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=u,w.createElement(fde,{match:h,routeContext:{outlet:u,matches:y,isDataRoute:n!=null},children:N})};return n&&(h.route.ErrorBoundary||h.route.errorElement||f===0)?w.createElement(GK,{location:n.location,revalidation:n.revalidation,component:v,error:p,children:_(),routeContext:{outlet:null,matches:y,isDataRoute:!0},onError:d}):_()},null)}function fF(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function gde(t){let e=w.useContext(Bb);return pa(e,fF(t)),e}function bde(t){let e=w.useContext(zC);return pa(e,fF(t)),e}function xde(t){let e=w.useContext(Tl);return pa(e,fF(t)),e}function pF(t){let e=xde(t),n=e.matches[e.matches.length-1];return pa(n.route.id,`${t} can only be used on routes that contain a unique "id"`),n.route.id}function yde(){return pF("useRouteId")}function vde(){let t=w.useContext(hF),e=bde("useRouteError"),n=pF("useRouteError");return t!==void 0?t:e.errors?.[n]}function wde(){let{router:t}=gde("useNavigate"),e=pF("useNavigate"),n=w.useRef(!1);return $K(()=>{n.current=!0}),w.useCallback(async(i,s={})=>{vl(n.current,HK),n.current&&(typeof i=="number"?await t.navigate(i):await t.navigate(i,{fromRouteId:e,...s}))},[t,e])}var _B={};function WK(t,e,n){!e&&!_B[t]&&(_B[t]=!0,vl(!1,n))}w.memo(Sde);function Sde({routes:t,future:e,state:n,onError:r}){return qK(t,void 0,n,r,e)}function lb({to:t,replace:e,state:n,relative:r}){pa(Hb(),"<Navigate> may be used only in the context of a <Router> component.");let{static:i}=w.useContext(Io);vl(!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(Tl),{pathname:o}=qc(),l=ac(),c=uF(t,dF(s),o,r==="path"),d=JSON.stringify(c);return w.useEffect(()=>{l(JSON.parse(d),{replace:e,state:n,relative:r})},[l,d,r,e,n]),null}function KK(t){return cde(t.context)}function Ir(t){pa(!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 _de({basename:t="/",children:e=null,location:n,navigationType:r="POP",navigator:i,static:s=!1,unstable_useTransitions:o}){pa(!Hb(),"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=Ub(n));let{pathname:d="/",search:u="",hash:h="",state:f=null,key:p="default"}=n,x=w.useMemo(()=>{let v=Jd(d,l);return v==null?null:{location:{pathname:v,search:u,hash:h,state:f,key:p},navigationType:r}},[l,d,u,h,f,p,r]);return vl(x!=null,`<Router basename="${l}"> is not able to match the URL "${d}${u}${h}" because it does not start with the basename, so the <Router> won't render anything.`),x==null?null:w.createElement(Io.Provider,{value:c},w.createElement(iv.Provider,{children:e,value:x}))}function Nde({children:t,location:e}){return dde(Wj(t),e)}function Wj(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,Wj(r.props.children,s));return}pa(r.type===Ir,`[${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>`),pa(!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=Wj(r.props.children,s)),n.push(o)}),n}var I_="get",z_="application/x-www-form-urlencoded";function UC(t){return typeof HTMLElement<"u"&&t instanceof HTMLElement}function Cde(t){return UC(t)&&t.tagName.toLowerCase()==="button"}function kde(t){return UC(t)&&t.tagName.toLowerCase()==="form"}function Ade(t){return UC(t)&&t.tagName.toLowerCase()==="input"}function Tde(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function Mde(t,e){return t.button===0&&(!e||e==="_self")&&!Tde(t)}function Kj(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 Pde(t,e){let n=Kj(t);return e&&e.forEach((r,i)=>{n.has(i)||e.getAll(i).forEach(s=>{n.append(i,s)})}),n}var Jw=null;function Ede(){if(Jw===null)try{new FormData(document.createElement("form"),0),Jw=!1}catch{Jw=!0}return Jw}var jde=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function zM(t){return t!=null&&!jde.has(t)?(vl(!1,`"${t}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${z_}"`),null):t}function Dde(t,e){let n,r,i,s,o;if(kde(t)){let l=t.getAttribute("action");r=l?Jd(l,e):null,n=t.getAttribute("method")||I_,i=zM(t.getAttribute("enctype"))||z_,s=new FormData(t)}else if(Cde(t)||Ade(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?Jd(c,e):null,n=t.getAttribute("formmethod")||l.getAttribute("method")||I_,i=zM(t.getAttribute("formenctype"))||zM(l.getAttribute("enctype"))||z_,s=new FormData(l,t),!Ede()){let{name:d,type:u,value:h}=t;if(u==="image"){let f=d?`${d}.`:"";s.append(`${f}x`,"0"),s.append(`${f}y`,"0")}else d&&s.append(d,h)}}else{if(UC(t))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=I_,r=null,i=z_,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 gF(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function Rde(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&&Jd(i.pathname,e)==="/"?i.pathname=`${e.replace(/\/$/,"")}/_root.${r}`:i.pathname=`${i.pathname.replace(/\/$/,"")}.${r}`,i}async function Fde(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 Lde(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 Ode(t,e,n){let r=await Promise.all(t.map(async i=>{let s=e.routes[i.route.id];if(s){let o=await Fde(s,n);return o.links?o.links():[]}return[]}));return Bde(r.flat(1).filter(Lde).filter(i=>i.rel==="stylesheet"||i.rel==="preload").map(i=>i.rel==="stylesheet"?{...i,rel:"prefetch",as:"style"}:{...i,rel:"prefetch"}))}function NB(t,e,n,r,i,s){let o=(c,d)=>n[d]?c.route.id!==n[d].route.id:!0,l=(c,d)=>n[d].pathname!==c.pathname||n[d].route.path?.endsWith("*")&&n[d].params["*"]!==c.params["*"];return s==="assets"?e.filter((c,d)=>o(c,d)||l(c,d)):s==="data"?e.filter((c,d)=>{let u=r.routes[c.route.id];if(!u||!u.hasLoader)return!1;if(o(c,d)||l(c,d))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 Ide(t,e,{includeHydrateFallback:n}={}){return zde(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 zde(t){return[...new Set(t)]}function Ude(t){let e={},n=Object.keys(t).sort();for(let r of n)e[r]=t[r];return e}function Bde(t,e){let n=new Set;return new Set(e),t.reduce((r,i)=>{let s=JSON.stringify(Ude(i));return n.has(s)||(n.add(s),r.push({key:s,link:i})),r},[])}function XK(){let t=w.useContext(Bb);return gF(t,"You must render this element inside a <DataRouterContext.Provider> element"),t}function Hde(){let t=w.useContext(zC);return gF(t,"You must render this element inside a <DataRouterStateContext.Provider> element"),t}var bF=w.createContext(void 0);bF.displayName="FrameworkContext";function YK(){let t=w.useContext(bF);return gF(t,"You must render this element inside a <HydratedRouter> element"),t}function $de(t,e){let n=w.useContext(bF),[r,i]=w.useState(!1),[s,o]=w.useState(!1),{onFocus:l,onBlur:c,onMouseEnter:d,onMouseLeave:u,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:Jx(l,p),onBlur:Jx(c,x),onMouseEnter:Jx(d,p),onMouseLeave:Jx(u,x),onTouchStart:Jx(h,p)}]:[!1,f,{}]}function Jx(t,e){return n=>{t&&t(n),n.defaultPrevented||e(n)}}function Vde({page:t,...e}){let{router:n}=XK(),r=w.useMemo(()=>RK(n.routes,t,n.basename),[n.routes,t,n.basename]);return r?w.createElement(Gde,{page:t,matches:r,...e}):null}function qde(t){let{manifest:e,routeModules:n}=YK(),[r,i]=w.useState([]);return w.useEffect(()=>{let s=!1;return Ode(t,e,n).then(o=>{s||i(o)}),()=>{s=!0}},[t,e,n]),r}function Gde({page:t,matches:e,...n}){let r=qc(),{future:i,manifest:s,routeModules:o}=YK(),{basename:l}=XK(),{loaderData:c,matches:d}=Hde(),u=w.useMemo(()=>NB(t,e,d,s,r,"data"),[t,e,d,s,r]),h=w.useMemo(()=>NB(t,e,d,s,r,"assets"),[t,e,d,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||(!u.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=Rde(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,u,e,t,o]),p=w.useMemo(()=>Ide(h,s),[h,s]),x=qde(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 Wde(...t){return e=>{t.forEach(n=>{typeof n=="function"?n(e):n!=null&&(n.current=e)})}}var Kde=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{Kde&&(window.__reactRouterVersion="7.13.0")}catch{}function Xde({basename:t,children:e,unstable_useTransitions:n,window:r}){let i=w.useRef();i.current==null&&(i.current=Ace({window:r,v5Compat:!0}));let s=i.current,[o,l]=w.useState({action:s.action,location:s.location}),c=w.useCallback(d=>{n===!1?l(d):w.startTransition(()=>l(d))},[n]);return w.useLayoutEffect(()=>s.listen(c),[s,c]),w.createElement(_de,{basename:t,children:e,location:o.location,navigationType:o.action,navigator:s,unstable_useTransitions:n})}var QK=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Ys=w.forwardRef(function({onClick:e,discover:n="render",prefetch:r="none",relative:i,reloadDocument:s,replace:o,state:l,target:c,to:d,preventScrollReset:u,viewTransition:h,unstable_defaultShouldRevalidate:f,...p},x){let{basename:v,unstable_useTransitions:g}=w.useContext(Io),y=typeof d=="string"&&QK.test(d),_=IK(d,v);d=_.to;let N=ode(d,{relative:i}),[A,k,P]=$de(r,p),C=Zde(d,{replace:o,state:l,target:c,preventScrollReset:u,relative:i,viewTransition:h,unstable_defaultShouldRevalidate:f,unstable_useTransitions:g});function j(E){e&&e(E),E.defaultPrevented||C(E)}let M=w.createElement("a",{...p,...P,href:_.absoluteURL||N,onClick:_.isExternal||s?e:j,ref:Wde(x,k),target:c,"data-discover":!y&&n==="render"?"true":void 0});return A&&!y?w.createElement(w.Fragment,null,M,w.createElement(Vde,{page:N})):M});Ys.displayName="Link";var Og=w.forwardRef(function({"aria-current":e="page",caseSensitive:n=!1,className:r="",end:i=!1,style:s,to:o,viewTransition:l,children:c,...d},u){let h=ov(o,{relative:d.relative}),f=qc(),p=w.useContext(zC),{navigator:x,basename:v}=w.useContext(Io),g=p!=null&&rue(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=Jd(N,v)||N);const A=y!=="/"&&y.endsWith("/")?y.length-1:y.length;let k=_===y||!i&&_.startsWith(y)&&_.charAt(A)==="/",P=N!=null&&(N===y||!i&&N.startsWith(y)&&N.charAt(y.length)==="/"),C={isActive:k,isPending:P,isTransitioning:g},j=k?e:void 0,M;typeof r=="function"?M=r(C):M=[r,k?"active":null,P?"pending":null,g?"transitioning":null].filter(Boolean).join(" ");let E=typeof s=="function"?s(C):s;return w.createElement(Ys,{...d,"aria-current":j,className:M,ref:u,style:E,to:o,viewTransition:l},typeof c=="function"?c(C):c)});Og.displayName="NavLink";var Yde=w.forwardRef(({discover:t="render",fetcherKey:e,navigate:n,reloadDocument:r,replace:i,state:s,method:o=I_,action:l,onSubmit:c,relative:d,preventScrollReset:u,viewTransition:h,unstable_defaultShouldRevalidate:f,...p},x)=>{let{unstable_useTransitions:v}=w.useContext(Io),g=tue(),y=nue(l,{relative:d}),_=o.toLowerCase()==="get"?"get":"post",N=typeof l=="string"&&QK.test(l),A=k=>{if(c&&c(k),k.defaultPrevented)return;k.preventDefault();let P=k.nativeEvent.submitter,C=P?.getAttribute("formmethod")||o,j=()=>g(P||k.currentTarget,{fetcherKey:e,method:C,navigate:n,replace:i,state:s,relative:d,preventScrollReset:u,viewTransition:h,unstable_defaultShouldRevalidate:f});v&&n!==!1?w.startTransition(()=>j()):j()};return w.createElement("form",{ref:x,method:_,action:y,onSubmit:r?c:A,...p,"data-discover":!N&&t==="render"?"true":void 0})});Yde.displayName="Form";function Qde(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function ZK(t){let e=w.useContext(Bb);return pa(e,Qde(t)),e}function Zde(t,{target:e,replace:n,state:r,preventScrollReset:i,relative:s,viewTransition:o,unstable_defaultShouldRevalidate:l,unstable_useTransitions:c}={}){let d=ac(),u=qc(),h=ov(t,{relative:s});return w.useCallback(f=>{if(Mde(f,e)){f.preventDefault();let p=n!==void 0?n:u0(u)===u0(h),x=()=>d(t,{replace:p,state:r,preventScrollReset:i,relative:s,viewTransition:o,unstable_defaultShouldRevalidate:l});c?w.startTransition(()=>x()):x()}},[u,d,h,n,r,e,t,i,s,o,l,c])}function xF(t){vl(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(Kj(t)),n=w.useRef(!1),r=qc(),i=w.useMemo(()=>Pde(r.search,n.current?null:e.current),[r.search]),s=ac(),o=w.useCallback((l,c)=>{const d=Kj(typeof l=="function"?l(new URLSearchParams(i)):l);n.current=!0,s("?"+d,c)},[s,i]);return[i,o]}var Jde=0,eue=()=>`__${String(++Jde)}__`;function tue(){let{router:t}=ZK("useSubmit"),{basename:e}=w.useContext(Io),n=yde(),r=t.fetch,i=t.navigate;return w.useCallback(async(s,o={})=>{let{action:l,method:c,encType:d,formData:u,body:h}=Dde(s,e);if(o.navigate===!1){let f=o.fetcherKey||eue();await r(f,n,o.action||l,{unstable_defaultShouldRevalidate:o.unstable_defaultShouldRevalidate,preventScrollReset:o.preventScrollReset,formData:u,body:h,formMethod:o.method||c,formEncType:o.encType||d,flushSync:o.flushSync})}else await i(o.action||l,{unstable_defaultShouldRevalidate:o.unstable_defaultShouldRevalidate,preventScrollReset:o.preventScrollReset,formData:u,body:h,formMethod:o.method||c,formEncType:o.encType||d,replace:o.replace,state:o.state,fromRouteId:n,flushSync:o.flushSync,viewTransition:o.viewTransition})},[r,i,e,n])}function nue(t,{relative:e}={}){let{basename:n}=w.useContext(Io),r=w.useContext(Tl);pa(r,"useFormAction must be used inside a RouteContext");let[i]=r.matches.slice(-1),s={...ov(t||".",{relative:e})},o=qc();if(t==null){s.search=o.search;let l=new URLSearchParams(s.search),c=l.getAll("index");if(c.some(u=>u==="")){l.delete("index"),c.filter(h=>h).forEach(h=>l.append("index",h));let u=l.toString();s.search=u?`?${u}`:""}}return(!t||t===".")&&i.route.index&&(s.search=s.search?s.search.replace(/^\?/,"?index&"):"?index"),n!=="/"&&(s.pathname=s.pathname==="/"?n:Vd([n,s.pathname])),u0(s)}function rue(t,{relative:e}={}){let n=w.useContext(UK);pa(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=ZK("useViewTransitionState"),i=ov(t,{relative:e});if(!n.isTransitioning)return!1;let s=Jd(n.currentLocation.pathname,r)||n.currentLocation.pathname,o=Jd(n.nextLocation.pathname,r)||n.nextLocation.pathname;return p1(i.pathname,o)!=null||p1(i.pathname,s)!=null}var Ld=_K();const aue=rc(Ld);var Jf=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(){}},iue={setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},sue=class{#t=iue;#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)}},Jm=new sue;function oue(t){setTimeout(t,0)}var Af=typeof window>"u"||"Deno"in globalThis;function ps(){}function lue(t,e){return typeof t=="function"?t(e):t}function Xj(t){return typeof t=="number"&&t>=0&&t!==1/0}function JK(t,e){return Math.max(t+(e||0)-Date.now(),0)}function Th(t,e){return typeof t=="function"?t(e):t}function rl(t,e){return typeof t=="function"?t(e):t}function CB(t,e){const{type:n="all",exact:r,fetchStatus:i,predicate:s,queryKey:o,stale:l}=t;if(o){if(r){if(e.queryHash!==yF(o,e.options))return!1}else if(!h0(e.queryKey,o))return!1}if(n!=="all"){const c=e.isActive();if(n==="active"&&!c||n==="inactive"&&c)return!1}return!(typeof l=="boolean"&&e.isStale()!==l||i&&i!==e.state.fetchStatus||s&&!s(e))}function kB(t,e){const{exact:n,status:r,predicate:i,mutationKey:s}=t;if(s){if(!e.options.mutationKey)return!1;if(n){if(Tf(e.options.mutationKey)!==Tf(s))return!1}else if(!h0(e.options.mutationKey,s))return!1}return!(r&&e.state.status!==r||i&&!i(e))}function yF(t,e){return(e?.queryKeyHashFn||Tf)(t)}function Tf(t){return JSON.stringify(t,(e,n)=>Yj(n)?Object.keys(n).sort().reduce((r,i)=>(r[i]=n[i],r),{}):n)}function h0(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?Object.keys(e).every(n=>h0(t[n],e[n])):!1}var cue=Object.prototype.hasOwnProperty;function vF(t,e,n=0){if(t===e)return t;if(n>500)return e;const r=AB(t)&&AB(e);if(!r&&!(Yj(t)&&Yj(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 d=0;for(let u=0;u<l;u++){const h=r?u:o[u],f=t[h],p=e[h];if(f===p){c[h]=f,(r?u<s:cue.call(t,h))&&d++;continue}if(f===null||p===null||typeof f!="object"||typeof p!="object"){c[h]=p;continue}const x=vF(f,p,n+1);c[h]=x,x===f&&d++}return s===l&&d===s?t:c}function m0(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 AB(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function Yj(t){if(!TB(t))return!1;const e=t.constructor;if(e===void 0)return!0;const n=e.prototype;return!(!TB(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}function TB(t){return Object.prototype.toString.call(t)==="[object Object]"}function due(t){return new Promise(e=>{Jm.setTimeout(e,t)})}function Qj(t,e,n){return typeof n.structuralSharing=="function"?n.structuralSharing(t,e):n.structuralSharing!==!1?vF(t,e):e}function uue(t,e,n=0){const r=[...t,e];return n&&r.length>n?r.slice(1):r}function hue(t,e,n=0){const r=[e,...t];return n&&r.length>n?r.slice(0,-1):r}var wF=Symbol();function eX(t,e){return!t.queryFn&&e?.initialPromise?()=>e.initialPromise:!t.queryFn||t.queryFn===wF?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function SF(t,e){return typeof t=="function"?t(...e):!!t}function mue(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 fue=class extends Jf{#t;#e;#n;constructor(){super(),this.#n=t=>{if(!Af&&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"}},_F=new fue;function Zj(){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 pue=oue;function gue(){let t=[],e=0,n=l=>{l()},r=l=>{l()},i=pue;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 Ra=gue(),bue=class extends Jf{#t=!0;#e;#n;constructor(){super(),this.#n=t=>{if(!Af&&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}},g1=new bue;function xue(t){return Math.min(1e3*2**t,3e4)}function tX(t){return(t??"online")==="online"?g1.isOnline():!0}var Jj=class extends Error{constructor(t){super("CancelledError"),this.revert=t?.revert,this.silent=t?.silent}};function nX(t){let e=!1,n=0,r;const i=Zj(),s=()=>i.status!=="pending",o=v=>{if(!s()){const g=new Jj(v);f(g),t.onCancel?.(g)}},l=()=>{e=!0},c=()=>{e=!1},d=()=>_F.isFocused()&&(t.networkMode==="always"||g1.isOnline())&&t.canRun(),u=()=>tX(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()||d())&&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??(Af?0:3),N=t.retryDelay??xue,A=typeof N=="function"?N(n,y):N,k=_===!0||typeof _=="number"&&n<_||typeof _=="function"&&_(n,y);if(e||!k){f(y);return}n++,t.onFail?.(n,y),due(A).then(()=>d()?void 0:p()).then(()=>{e?f(y):x()})})};return{promise:i,status:()=>i.status,cancel:o,continue:()=>(r?.(),i),cancelRetry:l,continueRetry:c,canStart:u,start:()=>(u()?x():p().then(x),i)}}var rX=class{#t;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Xj(this.gcTime)&&(this.#t=Jm.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(Af?1/0:300*1e3))}clearGcTimeout(){this.#t&&(Jm.clearTimeout(this.#t),this.#t=void 0)}},yue=class extends rX{#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=PB(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=PB(this.options);e.data!==void 0&&(this.setState(MB(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#n.remove(this)}setData(t,e){const n=Qj(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=>rl(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===wF||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>Th(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:!JK(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=eX(this.options,e),d=(()=>{const u={client:this.#a,queryKey:this.queryKey,meta:this.meta};return r(u),u})();return this.#o=!1,this.options.persister?this.options.persister(l,d,this):l(d)},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=nX({initialPromise:e?.initialPromise,fn:o.fetchFn,onCancel:l=>{l instanceof Jj&&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 Jj){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,...aX(n.data,this.options),fetchMeta:t.meta??null};case"success":const r={...n,...MB(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),Ra.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),this.#n.notify({query:this,type:"updated",action:t})})}};function aX(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:tX(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function MB(t,e){return{data:t,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}function PB(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 NF=class extends Jf{constructor(t,e){super(),this.options=e,this.#t=t,this.#s=null,this.#o=Zj(),this.bindMethods(),this.setOptions(e)}#t;#e=void 0;#n=void 0;#a=void 0;#r;#i;#o;#s;#f;#u;#h;#c;#d;#l;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#e.addObserver(this),EB(this.#e,this.options)?this.#p():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return e3(this.#e,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return e3(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 rl(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&&!m0(this.options,e)&&this.#t.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#e,observer:this});const r=this.hasListeners();r&&jB(this.#e,n,this.options,e)&&this.#p(),this.updateResult(),r&&(this.#e!==n||rl(this.options.enabled,this.#e)!==rl(e.enabled,this.#e)||Th(this.options.staleTime,this.#e)!==Th(e.staleTime,this.#e))&&this.#g();const i=this.#b();r&&(this.#e!==n||rl(this.options.enabled,this.#e)!==rl(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 wue(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=Th(this.options.staleTime,this.#e);if(Af||this.#a.isStale||!Xj(t))return;const n=JK(this.#a.dataUpdatedAt,t)+1;this.#c=Jm.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,!(Af||rl(this.options.enabled,this.#e)===!1||!Xj(this.#l)||this.#l===0)&&(this.#d=Jm.setInterval(()=>{(this.options.refetchIntervalInBackground||_F.isFocused())&&this.#p()},this.#l))}#y(){this.#g(),this.#x(this.#b())}#v(){this.#c&&(Jm.clearTimeout(this.#c),this.#c=void 0)}#w(){this.#d&&(Jm.clearInterval(this.#d),this.#d=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:d}=t;let u={...d},h=!1,f;if(e._optimisticResults){const j=this.hasListeners(),M=!j&&EB(t,e),E=j&&jB(t,n,e,r);(M||E)&&(u={...u,...aX(d.data,t.options)}),e._optimisticResults==="isRestoring"&&(u.fetchStatus="idle")}let{error:p,errorUpdatedAt:x,status:v}=u;f=u.data;let g=!1;if(e.placeholderData!==void 0&&f===void 0&&v==="pending"){let j;i?.isPlaceholderData&&e.placeholderData===o?.placeholderData?(j=i.data,g=!0):j=typeof e.placeholderData=="function"?e.placeholderData(this.#h?.state.data,this.#h):e.placeholderData,j!==void 0&&(v="success",f=Qj(i?.data,j,e),h=!0)}if(e.select&&f!==void 0&&!g)if(i&&f===s?.data&&e.select===this.#f)f=this.#u;else try{this.#f=e.select,f=e.select(f),f=Qj(i?.data,f,e),this.#u=f,this.#s=null}catch(j){this.#s=j}this.#s&&(p=this.#s,f=this.#u,x=Date.now(),v="error");const y=u.fetchStatus==="fetching",_=v==="pending",N=v==="error",A=_&&y,k=f!==void 0,C={status:v,fetchStatus:u.fetchStatus,isPending:_,isSuccess:v==="success",isError:N,isInitialLoading:A,isLoading:A,data:f,dataUpdatedAt:u.dataUpdatedAt,error:p,errorUpdatedAt:x,failureCount:u.fetchFailureCount,failureReason:u.fetchFailureReason,errorUpdateCount:u.errorUpdateCount,isFetched:u.dataUpdateCount>0||u.errorUpdateCount>0,isFetchedAfterMount:u.dataUpdateCount>c.dataUpdateCount||u.errorUpdateCount>c.errorUpdateCount,isFetching:y,isRefetching:y&&!_,isLoadingError:N&&!k,isPaused:u.fetchStatus==="paused",isPlaceholderData:h,isRefetchError:N&&k,isStale:CF(t,e),refetch:this.refetch,promise:this.#o,isEnabled:rl(e.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const j=C.data!==void 0,M=C.status==="error"&&!j,E=U=>{M?U.reject(C.error):j&&U.resolve(C.data)},B=()=>{const U=this.#o=C.promise=Zj();E(U)},L=this.#o;switch(L.status){case"pending":t.queryHash===n.queryHash&&E(L);break;case"fulfilled":(M||C.data!==L.value)&&B();break;case"rejected":(!M||C.error!==L.reason)&&B();break}}return C}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),m0(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){Ra.batch(()=>{t.listeners&&this.listeners.forEach(e=>{e(this.#a)}),this.#t.getQueryCache().notify({query:this.#e,type:"observerResultsUpdated"})})}};function vue(t,e){return rl(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&e.retryOnMount===!1)}function EB(t,e){return vue(t,e)||t.state.data!==void 0&&e3(t,e,e.refetchOnMount)}function e3(t,e,n){if(rl(e.enabled,t)!==!1&&Th(e.staleTime,t)!=="static"){const r=typeof n=="function"?n(t):n;return r==="always"||r!==!1&&CF(t,e)}return!1}function jB(t,e,n,r){return(t!==e||rl(r.enabled,t)===!1)&&(!n.suspense||t.state.status!=="error")&&CF(t,n)}function CF(t,e){return rl(e.enabled,t)!==!1&&t.isStaleByTime(Th(e.staleTime,t))}function wue(t,e){return!m0(t.getCurrentResult(),e)}function DB(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 d=async()=>{let u=!1;const h=x=>{mue(x,()=>e.signal,()=>u=!0)},f=eX(e.options,e.fetchOptions),p=async(x,v,g)=>{if(u)return Promise.reject();if(v==null&&x.pages.length)return Promise.resolve(x);const _=(()=>{const P={client:e.client,queryKey:e.queryKey,pageParam:v,direction:g?"backward":"forward",meta:e.options.meta};return h(P),P})(),N=await f(_),{maxPages:A}=e.options,k=g?hue:uue;return{pages:k(x.pages,N,A),pageParams:k(x.pageParams,v,A)}};if(i&&s.length){const x=i==="backward",v=x?Sue:RB,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:RB(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?.(d,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},n):e.fetchFn=d}}}function RB(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 Sue(t,{pages:e,pageParams:n}){return e.length>0?t.getPreviousPageParam?.(e[0],e,n[0],n):void 0}var _ue=class extends rX{#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||iX(),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=nX({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),Ra.batch(()=>{this.#e.forEach(n=>{n.onMutationUpdate(t)}),this.#n.notify({mutation:this,type:"updated",action:t})})}};function iX(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Nue=class extends Jf{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 _ue({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=eS(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=eS(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=eS(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=eS(t);return typeof e=="string"?this.#e.get(e)?.find(r=>r!==t&&r.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){Ra.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=>kB(e,n))}findAll(t={}){return this.getAll().filter(e=>kB(t,e))}notify(t){Ra.batch(()=>{this.listeners.forEach(e=>{e(t)})})}resumePausedMutations(){const t=this.getAll().filter(e=>e.state.isPaused);return Ra.batch(()=>Promise.all(t.map(e=>e.continue().catch(ps))))}};function eS(t){return t.options.scope?.id}var Cue=class extends Jf{#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),m0(this.options,n)||this.#t.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#n,observer:this}),n?.mutationKey&&this.options.mutationKey&&Tf(n.mutationKey)!==Tf(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??iX();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){Ra.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 FB(t,e){const n=new Set(e);return t.filter(r=>!n.has(r))}function kue(t,e,n){const r=t.slice(0);return r[e]=n,r}var Aue=class extends Jf{#t;#e;#n;#a;#r;#i;#o;#s;#f;#u=[];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,Ra.batch(()=>{const n=this.#r,r=this.#d(this.#n);r.forEach(u=>u.observer.setOptions(u.defaultedQueryOptions));const i=r.map(u=>u.observer),s=i.map(u=>u.getCurrentResult()),o=n.length!==i.length,l=i.some((u,h)=>u!==n[h]),c=o||l,d=c?!0:s.some((u,h)=>{const f=this.#e[h];return!f||!m0(u,f)});!c&&!d||(c&&(this.#u=r,this.#r=i),this.#e=s,this.hasListeners()&&(c&&(FB(n,i).forEach(u=>{u.destroy()}),FB(i,n).forEach(u=>{u.subscribe(h=>{this.#l(u,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.#d(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=vF(this.#i,e(t))),this.#i}return t}#d(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 NF(this.#t,i);n.push({defaultedQueryOptions:i,observer:o})}),n}#l(t,e){const n=this.#r.indexOf(t);n!==-1&&(this.#e=kue(this.#e,n,e),this.#m())}#m(){if(this.hasListeners()){const t=this.#i,e=this.#h(this.#e,this.#u),n=this.#c(e,this.#a?.combine);t!==n&&Ra.batch(()=>{this.listeners.forEach(r=>{r(this.#e)})})}}},Tue=class extends Jf{constructor(t={}){super(),this.config=t,this.#t=new Map}#t;build(t,e,n){const r=e.queryKey,i=e.queryHash??yF(r,e);let s=this.get(i);return s||(s=new yue({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(){Ra.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=>CB(e,n))}findAll(t={}){const e=this.getAll();return Object.keys(t).length>0?e.filter(n=>CB(t,n)):e}notify(t){Ra.batch(()=>{this.listeners.forEach(e=>{e(t)})})}onFocus(){Ra.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){Ra.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Mue=class{#t;#e;#n;#a;#r;#i;#o;#s;constructor(t={}){this.#t=t.queryCache||new Tue,this.#e=t.mutationCache||new Nue,this.#n=t.defaultOptions||{},this.#a=new Map,this.#r=new Map,this.#i=0}mount(){this.#i++,this.#i===1&&(this.#o=_F.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#t.onFocus())}),this.#s=g1.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(Th(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=lue(e,s);if(o!==void 0)return this.#t.build(this,r).setData(o,{...n,manual:!0})}setQueriesData(t,e,n){return Ra.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;Ra.batch(()=>{e.findAll(t).forEach(n=>{e.remove(n)})})}resetQueries(t,e){const n=this.#t;return Ra.batch(()=>(n.findAll(t).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){const n={revert:!0,...e},r=Ra.batch(()=>this.#t.findAll(t).map(i=>i.cancel(n)));return Promise.all(r).then(ps).catch(ps)}invalidateQueries(t,e={}){return Ra.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=Ra.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(Th(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=DB(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(ps).catch(ps)}ensureInfiniteQueryData(t){return t.behavior=DB(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return g1.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(Tf(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...this.#a.values()],n={};return e.forEach(r=>{h0(t,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(t,e){this.#r.set(Tf(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...this.#r.values()],n={};return e.forEach(r=>{h0(t,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(t){if(t._defaulted)return t;const e={...this.#n.queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return e.queryHash||(e.queryHash=yF(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===wF&&(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()}},sX=w.createContext(void 0),Qt=t=>{const e=w.useContext(sX);if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},Pue=({client:t,children:e})=>(w.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),a.jsx(sX.Provider,{value:t,children:e})),oX=w.createContext(!1),lX=()=>w.useContext(oX);oX.Provider;function Eue(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var jue=w.createContext(Eue()),cX=()=>w.useContext(jue),dX=(t,e,n)=>{const r=n?.state.error&&typeof t.throwOnError=="function"?SF(t.throwOnError,[n.state.error,n]):t.throwOnError;(t.suspense||t.experimental_prefetchInRender||r)&&(e.isReset()||(t.retryOnMount=!1))},uX=t=>{w.useEffect(()=>{t.clearReset()},[t])},hX=({result:t,errorResetBoundary:e,throwOnError:n,query:r,suspense:i})=>t.isError&&!e.isReset()&&!t.isFetching&&r&&(i&&t.data===void 0||SF(n,[t.error,r])),mX=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))}},fX=(t,e)=>t.isLoading&&t.isFetching&&!e,t3=(t,e)=>t?.suspense&&e.isPending,b1=(t,e,n)=>e.fetchOptimistic(t).catch(()=>{n.clearReset()});function lv({queries:t,...e},n){const r=Qt(),i=lX(),s=cX(),o=w.useMemo(()=>t.map(v=>{const g=r.defaultQueryOptions(v);return g._optimisticResults=i?"isRestoring":"optimistic",g}),[t,r,i]);o.forEach(v=>{mX(v);const g=r.getQueryCache().get(v.queryHash);dX(v,s,g)}),uX(s);const[l]=w.useState(()=>new Aue(r,o,e)),[c,d,u]=l.getOptimisticResult(o,e.combine),h=!i&&e.subscribed!==!1;w.useSyncExternalStore(w.useCallback(v=>h?l.subscribe(Ra.batchCalls(v)):ps,[l,h]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),w.useEffect(()=>{l.setQueries(o,e)},[o,e,l]);const p=c.some((v,g)=>t3(o[g],v))?c.flatMap((v,g)=>{const y=o[g];if(y){const _=new NF(r,y);if(t3(y,v))return b1(y,_,s);fX(v,i)&&b1(y,_,s)}return[]}):[];if(p.length>0)throw Promise.all(p);const x=c.find((v,g)=>{const y=o[g];return y&&hX({result:v,errorResetBoundary:s,throwOnError:y.throwOnError,query:r.getQueryCache().get(y.queryHash),suspense:y.suspense})});if(x?.error)throw x.error;return d(u())}function Due(t,e,n){const r=lX(),i=cX(),s=Qt(),o=s.defaultQueryOptions(t);s.getDefaultOptions().queries?._experimental_beforeQuery?.(o);const l=s.getQueryCache().get(o.queryHash);o._optimisticResults=r?"isRestoring":"optimistic",mX(o),dX(o,i,l),uX(i);const c=!s.getQueryCache().get(o.queryHash),[d]=w.useState(()=>new e(s,o)),u=d.getOptimisticResult(o),h=!r&&t.subscribed!==!1;if(w.useSyncExternalStore(w.useCallback(f=>{const p=h?d.subscribe(Ra.batchCalls(f)):ps;return d.updateResult(),p},[d,h]),()=>d.getCurrentResult(),()=>d.getCurrentResult()),w.useEffect(()=>{d.setOptions(o)},[o,d]),t3(o,u))throw b1(o,d,i);if(hX({result:u,errorResetBoundary:i,throwOnError:o.throwOnError,query:l,suspense:o.suspense}))throw u.error;return s.getDefaultOptions().queries?._experimental_afterQuery?.(o,u),o.experimental_prefetchInRender&&!Af&&fX(u,r)&&(c?b1(o,d,i):l?.promise)?.catch(ps).finally(()=>{d.updateResult()}),o.notifyOnChangeProps?u:d.trackResult(u)}function Ze(t,e){return Due(t,NF)}function st(t,e){const n=Qt(),[r]=w.useState(()=>new Cue(n,t));w.useEffect(()=>{r.setOptions(t)},[r,t]);const i=w.useSyncExternalStore(w.useCallback(o=>r.subscribe(Ra.batchCalls(o)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),s=w.useCallback((o,l)=>{r.mutate(o,l).catch(ps)},[r]);if(i.error&&SF(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:s,mutateAsync:i.mutate}}const Rue=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Fue=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase()),LB=t=>{const e=Fue(t);return e.charAt(0).toUpperCase()+e.slice(1)},pX=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim(),Lue=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var Oue={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 Iue=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,...Oue,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:pX("lucide",i),...!s&&!Lue(l)&&{"aria-hidden":"true"},...l},[...o.map(([d,u])=>w.createElement(d,u)),...Array.isArray(s)?s:[s]]));const et=(t,e)=>{const n=w.forwardRef(({className:r,...i},s)=>w.createElement(Iue,{ref:s,iconNode:e,className:pX(`lucide-${Rue(LB(t))}`,`lucide-${t}`,r),...i}));return n.displayName=LB(t),n};const zue=[["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"}]],Uue=et("air-vent",zue);const Bue=[["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"}]],Ds=et("archive",Bue);const Hue=[["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"}]],$ue=et("arrow-down-wide-narrow",Hue);const Vue=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],cb=et("arrow-down",Vue);const que=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],gX=et("arrow-left",que);const Gue=[["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"}]],n3=et("arrow-right-left",Gue);const Wue=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],r3=et("arrow-right",Wue);const Kue=[["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"}]],kF=et("arrow-up-down",Kue);const Xue=[["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"}]],Yue=et("arrow-up-narrow-wide",Xue);const Que=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Mf=et("arrow-up",Que);const Zue=[["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"}]],Jue=et("beaker",Zue);const ehe=[["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"}]],qg=et("bell",ehe);const the=[["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"}]],nhe=et("bold",the);const rhe=[["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"}]],ahe=et("book",rhe);const ihe=[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z",key:"1fy3hk"}]],she=et("bookmark",ihe);const ohe=[["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"}]],ei=et("box",ohe);const lhe=[["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"}]],bX=et("briefcase",lhe);const che=[["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"}]],BC=et("bug",che);const dhe=[["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"}]],uhe=et("cable",dhe);const hhe=[["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=et("calculator",hhe);const fhe=[["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"}]],phe=et("calendar-days",fhe);const ghe=[["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"}]],da=et("calendar",ghe);const bhe=[["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"}]],db=et("camera",bhe);const xhe=[["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"}]],yhe=et("chart-column",xhe);const vhe=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],na=et("check",vhe);const whe=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Mn=et("chevron-down",whe);const She=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],pi=et("chevron-right",She);const _he=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Yl=et("chevron-left",_he);const Nhe=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],wl=et("chevron-up",Nhe);const Che=[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]],xX=et("chevrons-left",Che);const khe=[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]],yX=et("chevrons-right",khe);const Ahe=[["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"}]],Va=et("circle-alert",Ahe);const The=[["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"}]],UM=et("circle-arrow-up",The);const Mhe=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],yr=et("circle-check-big",Mhe);const Phe=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],ub=et("circle-check",Phe);const Ehe=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],jhe=et("circle-dot",Ehe);const Dhe=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]],Rhe=et("circle-stop",Dhe);const Fhe=[["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"}]],mi=et("circle-x",Fhe);const Lhe=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],x1=et("circle",Lhe);const Ohe=[["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"}]],Ihe=et("clipboard-list",Ohe);const zhe=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],qn=et("clock",zhe);const Uhe=[["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"}]],Bhe=et("cloud-off",Uhe);const Hhe=[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]],$b=et("cloud",Hhe);const $he=[["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"}]],Vhe=et("code-xml",$he);const qhe=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],vX=et("code",qhe);const Ghe=[["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"}]],Whe=et("coffee",Ghe);const Khe=[["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"}]],Xhe=et("coins",Khe);const Yhe=[["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"}]],Qhe=et("cog",Yhe);const Zhe=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],Jhe=et("columns-2",Zhe);const eme=[["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"}]],tme=et("compass",eme);const nme=[["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"}]],Ql=et("copy",nme);const rme=[["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"}]],tS=et("cpu",rme);const ame=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5v14a9 3 0 0 0 18 0V5",key:"aqi0yr"}]],ime=et("cylinder",ame);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"}]],jc=et("database",sme);const ome=[["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"}]],lme=et("disc-3",ome);const cme=[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]],a3=et("dollar-sign",cme);const dme=[["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"}]],ga=et("download",dme);const ume=[["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"}]],HC=et("droplet",ume);const hme=[["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"}]],AF=et("droplets",hme);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"}]],Mh=et("ellipsis-vertical",mme);const fme=[["line",{x1:"5",x2:"19",y1:"9",y2:"9",key:"1nwqeh"}],["line",{x1:"5",x2:"19",y1:"15",y2:"15",key:"g8yjpy"}]],BM=et("equal",fme);const pme=[["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"}]],ta=et("external-link",pme);const gme=[["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"}]],cv=et("eye-off",gme);const bme=[["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"}]],Zl=et("eye",bme);const xme=[["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"}]],wX=et("fan",xme);const yme=[["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"}]],hf=et("file-box",yme);const vme=[["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"}]],y1=et("file-code",vme);const wme=[["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"}]],Sme=et("file-exclamation-point",wme);const _me=[["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"}]],v1=et("file-spreadsheet",_me);const Nme=[["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"}]],Ps=et("file-text",Nme);const Cme=[["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"}]],$C=et("file",Cme);const kme=[["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"}]],Ph=et("film",kme);const Ame=[["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"}]],Tme=et("flame",Ame);const Mme=[["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=et("folder-kanban",Mme);const Pme=[["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"}]],Jl=et("folder-open",Pme);const Eme=[["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"}]],jme=et("folder-plus",Eme);const Dme=[["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"}]],Rme=et("folder-tree",Dme);const Fme=[["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"}]],SX=et("folder",Fme);const Lme=[["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"}]],Ome=et("fullscreen",Lme);const Ime=[["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"}]],VC=et("funnel",Ime);const zme=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],qC=et("gauge",zme);const Ume=[["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"}]],Bme=et("gift",Ume);const Hme=[["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"}]],Gg=et("git-compare",Hme);const $me=[["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"}]],i3=et("github",$me);const Vme=[["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"}]],Eh=et("globe",Vme);const qme=[["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"}]],jh=et("grip-vertical",qme);const Gme=[["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"}]],Wme=et("group",Gme);const Kme=[["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"}]],_X=et("hand",Kme);const Xme=[["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"}]],Vb=et("hard-drive",Xme);const Yme=[["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"}]],Qme=et("hash",Yme);const Zme=[["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"}]],Jme=et("headphones",Zme);const efe=[["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"}]],tfe=et("heart",efe);const nfe=[["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"}]],f0=et("history",nfe);const rfe=[["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"}]],dv=et("house",rfe);const afe=[["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"}]],eu=et("image",afe);const ife=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],eo=et("info",ife);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"}]],ofe=et("italic",sfe);const lfe=[["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"}]],al=et("key",lfe);const cfe=[["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"}]],s3=et("keyboard",cfe);const dfe=[["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"}]],ri=et("layers",dfe);const ufe=[["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"}]],uv=et("layout-grid",ufe);const hfe=[["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=et("link-2-off",hfe);const ffe=[["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"}]],Dh=et("link-2",ffe);const pfe=[["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"}]],qb=et("link",pfe);const gfe=[["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"}]],NX=et("list-ordered",gfe);const bfe=[["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"}]],o3=et("list-todo",bfe);const xfe=[["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"}]],GC=et("list",xfe);const yfe=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],at=et("loader-circle",yfe);const vfe=[["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"}]],U_=et("lock-open",vfe);const wfe=[["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"}]],Um=et("lock",wfe);const Sfe=[["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"}]],OB=et("log-in",Sfe);const _fe=[["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"}]],l3=et("log-out",_fe);const Nfe=[["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"}]],p0=et("mail",Nfe);const Cfe=[["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"}]],kfe=et("map",Cfe);const Afe=[["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"}]],WC=et("maximize-2",Afe);const Tfe=[["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"}]],Mfe=et("maximize",Tfe);const Pfe=[["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"}]],Efe=et("memory-stick",Pfe);const jfe=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],Dfe=et("menu",jfe);const Rfe=[["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"}]],TF=et("minimize-2",Rfe);const Ffe=[["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"}]],CX=et("minimize",Ffe);const Lfe=[["path",{d:"M5 12h14",key:"1ays0h"}]],w1=et("minus",Lfe);const Ofe=[["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"}]],Ife=et("monitor",Ofe);const zfe=[["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"}]],S1=et("moon",zfe);const Ufe=[["path",{d:"M18 8L22 12L18 16",key:"1r0oui"}],["path",{d:"M2 12H22",key:"1m8cig"}]],Bfe=et("move-right",Ufe);const Hfe=[["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"}]],c3=et("music",Hfe);const $fe=[["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"}]],fi=et("package",$fe);const Vfe=[["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"}]],KC=et("palette",Vfe);const qfe=[["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"}]],XC=et("pause",qfe);const Gfe=[["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"}]],Pf=et("pen-line",Gfe);const Wfe=[["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"}]],ef=et("pen",Wfe);const Kfe=[["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"}]],Ga=et("pencil",Kfe);const Xfe=[["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"}]],Yfe=et("phone",Xfe);const Qfe=[["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"}]],oo=et("play",Qfe);const Zfe=[["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"}]],gl=et("plug",Zfe);const Jfe=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Xn=et("plus",Jfe);const epe=[["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"}]],YC=et("power-off",epe);const tpe=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],fu=et("power",tpe);const npe=[["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"}]],Nr=et("printer",npe);const rpe=[["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"}]],kX=et("qr-code",rpe);const ape=[["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"}]],MF=et("radio",ape);const ipe=[["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"}]],Sr=et("refresh-cw",ipe);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"}]],lo=et("rotate-ccw",spe);const ope=[["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"}]],lpe=et("ruler",ope);const cpe=[["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=et("save",cpe);const dpe=[["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"}]],upe=et("scale",dpe);const hpe=[["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"}]],_1=et("scan-search",hpe);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"}]],fpe=et("scissors",mpe);const ppe=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Er=et("search",ppe);const gpe=[["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"}]],QC=et("send",gpe);const bpe=[["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"}]],Bm=et("server",bpe);const xpe=[["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"}]],tu=et("settings-2",xpe);const ype=[["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"}]],ZC=et("settings",ype);const vpe=[["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"}]],wpe=et("shield-alert",vpe);const Spe=[["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"}]],d3=et("shield",Spe);const _pe=[["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"}]],AX=et("shopping-cart",_pe);const Npe=[["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"}]],Cpe=et("signal",Npe);const kpe=[["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"}]],Ape=et("skip-back",kpe);const Tpe=[["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"}]],PF=et("skip-forward",Tpe);const Mpe=[["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"}]],IB=et("sliders-vertical",Mpe);const Ppe=[["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"}]],hb=et("sparkles",Ppe);const Epe=[["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"}]],co=et("square-check-big",Epe);const jpe=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 12h8",key:"1wcyev"}]],Dpe=et("square-minus",jpe);const Rpe=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],Sl=et("square",Rpe);const Fpe=[["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"}]],Ef=et("star",Fpe);const Lpe=[["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"}]],TX=et("sticky-note",Lpe);const Ope=[["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"}]],zB=et("sun",Ope);const Ipe=[["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"}]],zpe=et("table-properties",Ipe);const Upe=[["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"}]],qh=et("tag",Upe);const Bpe=[["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"}]],MX=et("target",Bpe);const Hpe=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],PX=et("terminal",Hpe);const $pe=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 19H5",key:"vjpgq2"}]],Vpe=et("text-align-center",$pe);const qpe=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 19H7",key:"4cu937"}]],Gpe=et("text-align-end",qpe);const Wpe=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]],Kpe=et("text-align-start",Wpe);const Xpe=[["path",{d:"M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"17jzev"}]],JC=et("thermometer",Xpe);const Ype=[["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"}]],Od=et("timer",Ype);const Qpe=[["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"}]],Yt=et("trash-2",Qpe);const Zpe=[["path",{d:"M16 17h6v-6",key:"t6n2it"}],["path",{d:"m22 17-8.5-8.5-5 5L2 7",key:"x473p"}]],EF=et("trending-down",Zpe);const Jpe=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],u3=et("trending-up",Jpe);const ege=[["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"}]],An=et("triangle-alert",ege);const tge=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],nge=et("underline",tge);const rge=[["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"}]],ek=et("unlink",rge);const age=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],Oa=et("upload",age);const ige=[["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"}]],nu=et("user",ige);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"}]],fh=et("users",sge);const oge=[["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"}]],jF=et("video",oge);const lge=[["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"}]],cge=et("volume-2",lge);const dge=[["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"}]],uge=et("volume-x",dge);const hge=[["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=et("wand-sparkles",hge);const fge=[["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"}]],EX=et("weight",fge);const pge=[["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"}]],Gh=et("wifi-off",pge);const gge=[["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"}]],Wg=et("wifi",gge);const bge=[["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"}]],jX=et("wind",bge);const xge=[["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"}]],jf=et("wrench",xge);const yge=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Rt=et("x",yge);const vge=[["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"}]],DF=et("zoom-in",vge);const wge=[["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"}]],ru=et("zap",wge);const Sge=[["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"}]],RF=et("zoom-out",Sge),nn="/api/v1";let ln=localStorage.getItem("auth_token");function Pg(t){ln=t,t?localStorage.setItem("auth_token",t):localStorage.removeItem("auth_token")}function au(){return ln}function Hm(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 Ae(t,e={}){const n={"Content-Type":"application/json",...e.headers};ln&&(n.Authorization=`Bearer ${ln}`);const r=await fetch(`${nn}${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(d=>l.includes(d))&&Pg(null),new Error(l)}const i=r.headers.get("content-length");if(!(r.status===204||i==="0"))return await r.json()}const J={getAuthStatus:()=>Ae("/auth/status"),setupAuth:t=>Ae("/auth/setup",{method:"POST",body:JSON.stringify(t)}),login:t=>Ae("/auth/login",{method:"POST",body:JSON.stringify(t)}),logout:()=>Ae("/auth/logout",{method:"POST"}),getCurrentUser:()=>Ae("/auth/me"),disableAuth:()=>Ae("/auth/disable",{method:"POST"}),testSMTP:t=>Ae("/auth/smtp/test",{method:"POST",body:JSON.stringify(t)}),getSMTPSettings:()=>Ae("/auth/smtp"),saveSMTPSettings:t=>Ae("/auth/smtp",{method:"POST",body:JSON.stringify(t)}),enableAdvancedAuth:()=>Ae("/auth/advanced-auth/enable",{method:"POST"}),disableAdvancedAuth:()=>Ae("/auth/advanced-auth/disable",{method:"POST"}),getAdvancedAuthStatus:()=>Ae("/auth/advanced-auth/status"),forgotPassword:t=>Ae("/auth/forgot-password",{method:"POST",body:JSON.stringify(t)}),resetUserPassword:t=>Ae("/auth/reset-password",{method:"POST",body:JSON.stringify(t)}),getUsers:()=>Ae("/users/"),getUser:t=>Ae(`/users/${t}`),createUser:t=>Ae("/users/",{method:"POST",body:JSON.stringify(t)}),updateUser:(t,e)=>Ae(`/users/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteUser:(t,e=!1)=>Ae(`/users/${t}?delete_items=${e}`,{method:"DELETE"}),getUserItemsCount:t=>Ae(`/users/${t}/items-count`),changePassword:(t,e)=>Ae("/users/me/change-password",{method:"POST",body:JSON.stringify({current_password:t,new_password:e})}),getPermissions:()=>Ae("/groups/permissions"),getGroups:()=>Ae("/groups/"),getGroup:t=>Ae(`/groups/${t}`),createGroup:t=>Ae("/groups/",{method:"POST",body:JSON.stringify(t)}),updateGroup:(t,e)=>Ae(`/groups/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteGroup:t=>Ae(`/groups/${t}`,{method:"DELETE"}),addUserToGroup:(t,e)=>Ae(`/groups/${t}/users/${e}`,{method:"POST"}),removeUserFromGroup:(t,e)=>Ae(`/groups/${t}/users/${e}`,{method:"DELETE"}),getPrinters:()=>Ae("/printers/"),getPrinter:t=>Ae(`/printers/${t}`),createPrinter:t=>Ae("/printers/",{method:"POST",body:JSON.stringify(t)}),updatePrinter:(t,e)=>Ae(`/printers/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deletePrinter:(t,e=!0)=>Ae(`/printers/${t}?delete_archives=${e}`,{method:"DELETE"}),getDeveloperModeWarnings:()=>Ae("/printers/developer-mode-warnings"),getAvailableFilaments:(t,e)=>{const n=new URLSearchParams({model:t});return e&&n.set("location",e),Ae(`/printers/available-filaments?${n}`)},getPrinterStatus:t=>Ae(`/printers/${t}/status`),refreshPrinterStatus:t=>Ae(`/printers/${t}/refresh-status`,{method:"POST"}),connectPrinter:t=>Ae(`/printers/${t}/connect`,{method:"POST"}),disconnectPrinter:t=>Ae(`/printers/${t}/disconnect`,{method:"POST"}),testExternalCamera:(t,e,n)=>Ae(`/printers/${t}/camera/external/test?url=${encodeURIComponent(e)}&camera_type=${encodeURIComponent(n)}`,{method:"POST"}),stopPrint:t=>Ae(`/printers/${t}/print/stop`,{method:"POST"}),pausePrint:t=>Ae(`/printers/${t}/print/pause`,{method:"POST"}),resumePrint:t=>Ae(`/printers/${t}/print/resume`,{method:"POST"}),clearPlate:t=>Ae(`/printers/${t}/clear-plate`,{method:"POST"}),getCurrentPrintUser:t=>Ae(`/printers/${t}/current-print-user`),setChamberLight:(t,e)=>Ae(`/printers/${t}/chamber-light?on=${e}`,{method:"POST"}),getPrintableObjects:t=>Ae(`/printers/${t}/print/objects`),skipObjects:(t,e)=>Ae(`/printers/${t}/print/skip-objects`,{method:"POST",body:JSON.stringify(e)}),clearHMSErrors:t=>Ae(`/printers/${t}/hms/clear`,{method:"POST"}),refreshAmsSlot:(t,e,n)=>Ae(`/printers/${t}/ams/${e}/slot/${n}/refresh`,{method:"POST"}),enableMQTTLogging:t=>Ae(`/printers/${t}/logging/enable`,{method:"POST"}),disableMQTTLogging:t=>Ae(`/printers/${t}/logging/disable`,{method:"POST"}),getMQTTLogs:t=>Ae(`/printers/${t}/logging`),clearMQTTLogs:t=>Ae(`/printers/${t}/logging`,{method:"DELETE"}),getPrinterFiles:(t,e="/")=>Ae(`/printers/${t}/files?path=${encodeURIComponent(e)}`),getPrinterFileDownloadUrl:(t,e)=>`${nn}/printers/${t}/files/download?path=${encodeURIComponent(e)}`,getPrinterFileGcodeUrl:(t,e)=>`${nn}/printers/${t}/files/gcode?path=${encodeURIComponent(e)}`,getPrinterFilePlates:(t,e)=>Ae(`/printers/${t}/files/plates?path=${encodeURIComponent(e)}`),getPrinterFilePlateThumbnail:(t,e,n)=>`${nn}/printers/${t}/files/plate-thumbnail/${e}?path=${encodeURIComponent(n)}`,downloadPrinterFile:async(t,e)=>{const n={};ln&&(n.Authorization=`Bearer ${ln}`);const r=await fetch(`${nn}/printers/${t}/files/download?path=${encodeURIComponent(e)}`,{headers:n});if(!r.ok){const d=await r.json().catch(()=>({}));throw new Error(d.detail||`HTTP ${r.status}`)}const i=r.headers.get("Content-Disposition"),s=Hm(i)||e.split("/").pop()||"download",o=await r.blob(),l=window.URL.createObjectURL(o),c=document.createElement("a");c.href=l,c.download=s,document.body.appendChild(c),c.click(),document.body.removeChild(c),window.URL.revokeObjectURL(l)},downloadPrinterFilesAsZip:async(t,e)=>{const n={"Content-Type":"application/json"};ln&&(n.Authorization=`Bearer ${ln}`);const r=await fetch(`${nn}/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)=>Ae(`/printers/${t}/files?path=${encodeURIComponent(e)}`,{method:"DELETE"}),getPrinterStorage:t=>Ae(`/printers/${t}/storage`),getArchives:(t,e,n=50,r=0)=>{const i=new URLSearchParams;return t&&i.set("printer_id",String(t)),e&&i.set("project_id",String(e)),i.set("limit",String(n)),i.set("offset",String(r)),Ae(`/archives/?${i}`)},getArchive:t=>Ae(`/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)),Ae(`/archives/search?${n}`)},rebuildSearchIndex:()=>Ae("/archives/search/rebuild-index",{method:"POST"}),updateArchive:(t,e)=>Ae(`/archives/${t}`,{method:"PATCH",body:JSON.stringify(e)}),toggleFavorite:t=>Ae(`/archives/${t}/favorite`,{method:"POST"}),deleteArchive:t=>Ae(`/archives/${t}`,{method:"DELETE"}),getArchiveStats:()=>Ae("/archives/stats"),getTags:()=>Ae("/archives/tags"),renameTag:(t,e)=>Ae(`/archives/tags/${encodeURIComponent(t)}`,{method:"PUT",body:JSON.stringify({new_name:e})}),deleteTag:t=>Ae(`/archives/tags/${encodeURIComponent(t)}`,{method:"DELETE"}),recalculateCosts:()=>Ae("/archives/recalculate-costs",{method:"POST"}),getFailureAnalysis:t=>{const e=new URLSearchParams;return t?.days&&e.set("days",String(t.days)),t?.printerId&&e.set("printer_id",String(t.printerId)),t?.projectId&&e.set("project_id",String(t.projectId)),Ae(`/archives/analysis/failures?${e}`)},compareArchives:t=>Ae(`/archives/compare?archive_ids=${t.join(",")}`),findSimilarArchives:(t,e=10)=>Ae(`/archives/${t}/similar?limit=${e}`),exportArchives:async t=>{const e=new URLSearchParams;t?.format&&e.set("format",t.format),t?.fields&&e.set("fields",t.fields.join(",")),t?.printerId&&e.set("printer_id",String(t.printerId)),t?.projectId&&e.set("project_id",String(t.projectId)),t?.status&&e.set("status",t.status),t?.dateFrom&&e.set("date_from",t.dateFrom),t?.dateTo&&e.set("date_to",t.dateTo),t?.search&&e.set("search",t.search);const n={};ln&&(n.Authorization=`Bearer ${ln}`);const r=await fetch(`${nn}/archives/export?${e}`,{headers:n});if(!r.ok){const l=await r.json().catch(()=>({}));throw new Error(l.detail||`HTTP ${r.status}`)}const i=r.headers.get("Content-Disposition");let s=t?.format==="xlsx"?"archives_export.xlsx":"archives_export.csv";if(i){const l=i.match(/filename="?([^"]+)"?/);l&&(s=l[1])}return{blob:await r.blob(),filename:s}},exportStats:async t=>{const e=new URLSearchParams;t?.format&&e.set("format",t.format),t?.days&&e.set("days",String(t.days)),t?.printerId&&e.set("printer_id",String(t.printerId)),t?.projectId&&e.set("project_id",String(t.projectId));const n={};ln&&(n.Authorization=`Bearer ${ln}`);const r=await fetch(`${nn}/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=>Ae(`/archives/${t}/duplicates`),backfillContentHashes:()=>Ae("/archives/backfill-hashes",{method:"POST"}),getArchiveThumbnail:t=>`${nn}/archives/${t}/thumbnail?v=${Date.now()}`,getArchivePlateThumbnail:(t,e)=>`${nn}/archives/${t}/plate-thumbnail/${e}`,getArchiveDownload:t=>`${nn}/archives/${t}/download`,downloadArchive:async(t,e)=>{const n={};ln&&(n.Authorization=`Bearer ${ln}`);const r=await fetch(`${nn}/archives/${t}/download`,{headers:n});if(!r.ok){const d=await r.json().catch(()=>({}));throw new Error(d.detail||`HTTP ${r.status}`)}const i=r.headers.get("Content-Disposition"),s=Hm(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=>`${nn}/archives/${t}/gcode`,getArchivePlatePreview:t=>`${nn}/archives/${t}/plate-preview`,getArchiveTimelapse:t=>`${nn}/archives/${t}/timelapse?v=${Date.now()}`,scanArchiveTimelapse:t=>Ae(`/archives/${t}/timelapse/scan`,{method:"POST"}),selectArchiveTimelapse:(t,e)=>Ae(`/archives/${t}/timelapse/select?filename=${encodeURIComponent(e)}`,{method:"POST"}),deleteArchiveTimelapse:t=>Ae(`/archives/${t}/timelapse`,{method:"DELETE"}),uploadArchiveTimelapse:async(t,e)=>{const n=new FormData;n.append("file",e);const r={};ln&&(r.Authorization=`Bearer ${ln}`);const i=await fetch(`${nn}/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=>Ae(`/archives/${t}/timelapse/info`),getTimelapseThumbnails:(t,e=10)=>Ae(`/archives/${t}/timelapse/thumbnails?count=${e}`),processTimelapse:async(t,e,n)=>{const r=new FormData;r.append("trim_start",String(e.trimStart??0)),e.trimEnd!==void 0&&r.append("trim_end",String(e.trimEnd)),r.append("speed",String(e.speed??1)),r.append("save_mode",e.saveMode),e.outputFilename&&r.append("output_filename",e.outputFilename),n&&r.append("audio",n);const i={};ln&&(i.Authorization=`Bearer ${ln}`);const s=await fetch(`${nn}/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)=>`${nn}/archives/${t}/photos/${encodeURIComponent(e)}`,uploadArchivePhoto:async(t,e)=>{const n=new FormData;n.append("file",e);const r={};ln&&(r.Authorization=`Bearer ${ln}`);const i=await fetch(`${nn}/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)=>Ae(`/archives/${t}/photos/${encodeURIComponent(e)}`,{method:"DELETE"}),getSource3mfDownloadUrl:t=>`${nn}/archives/${t}/source`,downloadSource3mf:async t=>{const e={};ln&&(e.Authorization=`Bearer ${ln}`);const n=await fetch(`${nn}/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=Hm(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`${nn}/archives/${t}/source/${encodeURIComponent(n.endsWith(".3mf")?n:n+".3mf")}`},createSourceSlicerToken:t=>Ae(`/archives/${t}/source-slicer-token`,{method:"POST"}),getSourceSlicerDownloadUrl:(t,e,n)=>{const r=n.replace(/[/\\?#]/g,"_");return`${nn}/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={};ln&&(r.Authorization=`Bearer ${ln}`);const i=await fetch(`${nn}/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=>Ae(`/archives/${t}/source`,{method:"DELETE"}),getF3dDownloadUrl:t=>`${nn}/archives/${t}/f3d`,downloadF3d:async t=>{const e={};ln&&(e.Authorization=`Bearer ${ln}`);const n=await fetch(`${nn}/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=Hm(r)||`archive_${t}.f3d`,s=await n.blob(),o=window.URL.createObjectURL(s),l=document.createElement("a");l.href=o,l.download=i,document.body.appendChild(l),l.click(),document.body.removeChild(l),window.URL.revokeObjectURL(o)},uploadF3d:async(t,e)=>{const n=new FormData;n.append("file",e);const r={};ln&&(r.Authorization=`Bearer ${ln}`);const i=await fetch(`${nn}/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=>Ae(`/archives/${t}/f3d`,{method:"DELETE"}),getArchiveQRCodeUrl:(t,e=200)=>`${nn}/archives/${t}/qrcode?size=${e}`,getArchiveCapabilities:t=>Ae(`/archives/${t}/capabilities`),getArchiveProjectPage:t=>Ae(`/archives/${t}/project-page`),updateArchiveProjectPage:(t,e)=>Ae(`/archives/${t}/project-page`,{method:"PATCH",body:JSON.stringify(e)}),getArchiveProjectImageUrl:(t,e)=>`${nn}/archives/${t}/project-image/${encodeURIComponent(e)}`,getArchiveForSlicer:(t,e)=>{const n=e.replace(/[/\\?#]/g,"_");return`${nn}/archives/${t}/file/${encodeURIComponent(n.endsWith(".3mf")?n:n+".3mf")}`},createArchiveSlicerToken:t=>Ae(`/archives/${t}/slicer-token`,{method:"POST"}),getArchiveSlicerDownloadUrl:(t,e,n)=>{const r=n.replace(/[/\\?#]/g,"_");return`${nn}/archives/${t}/dl/${e}/${encodeURIComponent(r.endsWith(".3mf")?r:r+".3mf")}`},getArchivePlates:t=>Ae(`/archives/${t}/plates`),getArchiveFilamentRequirements:(t,e)=>Ae(`/archives/${t}/filament-requirements${e!==void 0?`?plate_id=${e}`:""}`),reprintArchive:(t,e,n)=>Ae(`/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?`${nn}/archives/upload?printer_id=${e}`:`${nn}/archives/upload`,i={};ln&&(i.Authorization=`Bearer ${ln}`);const s=await fetch(r,{method:"POST",headers:i,body:n});if(!s.ok){const o=await s.json().catch(()=>({}));throw new Error(o.detail||`HTTP ${s.status}`)}return s.json()},uploadArchivesBulk:async(t,e)=>{const n=new FormData;t.forEach(o=>n.append("files",o));const r=e?`${nn}/archives/upload-bulk?printer_id=${e}`:`${nn}/archives/upload-bulk`,i={};ln&&(i.Authorization=`Bearer ${ln}`);const s=await fetch(r,{method:"POST",headers:i,body:n});if(!s.ok){const o=await s.json().catch(()=>({}));throw new Error(o.detail||`HTTP ${s.status}`)}return s.json()},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)),Ae(`/print-log/?${e}`)},getPrintLogThumbnail:t=>`${nn}/print-log/${t}/thumbnail`,clearPrintLog:()=>Ae("/print-log/",{method:"DELETE"}),getSettings:()=>Ae("/settings/"),updateSettings:t=>Ae("/settings/",{method:"PUT",body:JSON.stringify(t)}),getMQTTStatus:()=>Ae("/settings/mqtt/status"),resetSettings:()=>Ae("/settings/reset",{method:"POST"}),exportBackup:async()=>{const t=`${nn}/settings/backup`,e={};ln&&(e.Authorization=`Bearer ${ln}`);const n=await fetch(t,{headers:e});if(!n.ok){const o=await n.text();throw new Error(o||`Backup failed with status ${n.status}`)}const r=n.headers.get("Content-Disposition");let i="bambuddy-backup.zip";if(r){const o=r.match(/filename=([^;]+)/);o&&(i=o[1].trim())}return{blob:await n.blob(),filename:i}},importBackup:async t=>{const e=new FormData;e.append("file",t);const n=`${nn}/settings/restore`,r={};return ln&&(r.Authorization=`Bearer ${ln}`),(await fetch(n,{method:"POST",headers:r,body:e})).json()},checkFfmpeg:()=>Ae("/settings/check-ffmpeg"),getNetworkInterfaces:()=>Ae("/settings/network-interfaces"),getCloudStatus:()=>Ae("/cloud/status"),cloudLogin:(t,e,n="global")=>Ae("/cloud/login",{method:"POST",body:JSON.stringify({email:t,password:e,region:n})}),cloudVerify:(t,e,n)=>Ae("/cloud/verify",{method:"POST",body:JSON.stringify({email:t,code:e,tfa_key:n})}),cloudSetToken:t=>Ae("/cloud/token",{method:"POST",body:JSON.stringify({access_token:t})}),cloudLogout:()=>Ae("/cloud/logout",{method:"POST"}),getCloudSettings:(t="02.04.00.70")=>Ae(`/cloud/settings?version=${t}`),getBuiltinFilaments:()=>Ae("/cloud/builtin-filaments"),getFilamentIdMap:()=>Ae("/cloud/filament-id-map"),getCloudSettingDetail:t=>Ae(`/cloud/settings/${t}`),createCloudSetting:t=>Ae("/cloud/settings",{method:"POST",body:JSON.stringify(t)}),updateCloudSetting:(t,e)=>Ae(`/cloud/settings/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteCloudSetting:t=>Ae(`/cloud/settings/${t}`,{method:"DELETE"}),getCloudDevices:()=>Ae("/cloud/devices"),getCloudFields:t=>Ae(`/cloud/fields/${t}`),getAllCloudFields:()=>Ae("/cloud/fields"),getFilamentInfo:t=>Ae("/cloud/filament-info",{method:"POST",body:JSON.stringify(t)}),getSmartPlugs:()=>Ae("/smart-plugs/"),getSmartPlug:t=>Ae(`/smart-plugs/${t}`),getSmartPlugByPrinter:t=>Ae(`/smart-plugs/by-printer/${t}`),getScriptPlugsByPrinter:t=>Ae(`/smart-plugs/by-printer/${t}/scripts`),createSmartPlug:t=>Ae("/smart-plugs/",{method:"POST",body:JSON.stringify(t)}),updateSmartPlug:(t,e)=>Ae(`/smart-plugs/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteSmartPlug:t=>Ae(`/smart-plugs/${t}`,{method:"DELETE"}),controlSmartPlug:(t,e)=>Ae(`/smart-plugs/${t}/control`,{method:"POST",body:JSON.stringify({action:e})}),getSmartPlugStatus:t=>Ae(`/smart-plugs/${t}/status`),testSmartPlugConnection:(t,e,n)=>Ae("/smart-plugs/test-connection",{method:"POST",body:JSON.stringify({ip_address:t,username:e,password:n})}),startTasmotaScan:()=>Ae("/smart-plugs/discover/scan",{method:"POST"}),getTasmotaScanStatus:()=>Ae("/smart-plugs/discover/status"),stopTasmotaScan:()=>Ae("/smart-plugs/discover/stop",{method:"POST"}),getDiscoveredTasmotaDevices:()=>Ae("/smart-plugs/discover/devices"),testHAConnection:(t,e)=>Ae("/smart-plugs/ha/test-connection",{method:"POST",body:JSON.stringify({url:t,token:e})}),getHAEntities:t=>{const e=t?`?search=${encodeURIComponent(t)}`:"";return Ae(`/smart-plugs/ha/entities${e}`)},getHASensorEntities:()=>Ae("/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),Ae(`/queue/?${r}`)},getQueueItem:t=>Ae(`/queue/${t}`),addToQueue:t=>Ae("/queue/",{method:"POST",body:JSON.stringify(t)}),updateQueueItem:(t,e)=>Ae(`/queue/${t}`,{method:"PATCH",body:JSON.stringify(e)}),removeFromQueue:t=>Ae(`/queue/${t}`,{method:"DELETE"}),reorderQueue:t=>Ae("/queue/reorder",{method:"POST",body:JSON.stringify({items:t})}),cancelQueueItem:t=>Ae(`/queue/${t}/cancel`,{method:"POST"}),stopQueueItem:t=>Ae(`/queue/${t}/stop`,{method:"POST"}),startQueueItem:t=>Ae(`/queue/${t}/start`,{method:"POST"}),bulkUpdateQueue:t=>Ae("/queue/bulk",{method:"PATCH",body:JSON.stringify(t)}),getKProfiles:(t,e="0.4")=>Ae(`/printers/${t}/kprofiles/?nozzle_diameter=${e}`),setKProfile:(t,e)=>Ae(`/printers/${t}/kprofiles/`,{method:"POST",body:JSON.stringify(e)}),deleteKProfile:(t,e)=>Ae(`/printers/${t}/kprofiles/`,{method:"DELETE",body:JSON.stringify(e)}),setKProfilesBatch:(t,e)=>Ae(`/printers/${t}/kprofiles/batch`,{method:"POST",body:JSON.stringify(e)}),getKProfileNotes:t=>Ae(`/printers/${t}/kprofiles/notes`),setKProfileNote:(t,e,n)=>Ae(`/printers/${t}/kprofiles/notes`,{method:"PUT",body:JSON.stringify({setting_id:e,note:n})}),deleteKProfileNote:(t,e)=>Ae(`/printers/${t}/kprofiles/notes/${encodeURIComponent(e)}`,{method:"DELETE"}),getSlotPresets:t=>Ae(`/printers/${t}/slot-presets`),getSlotPreset:(t,e,n)=>Ae(`/printers/${t}/slot-presets/${e}/${n}`),saveSlotPreset:(t,e,n,r,i,s="cloud")=>Ae(`/printers/${t}/slot-presets/${e}/${n}?preset_id=${encodeURIComponent(r)}&preset_name=${encodeURIComponent(i)}&preset_source=${encodeURIComponent(s)}`,{method:"PUT"}),deleteSlotPreset:(t,e,n)=>Ae(`/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()),Ae(`/printers/${t}/slots/${e}/${n}/configure?${i}`,{method:"POST"})},resetAmsSlot:(t,e,n)=>Ae(`/printers/${t}/ams/${e}/tray/${n}/reset`,{method:"POST"}),listFilaments:()=>Ae("/filament-catalog/"),getFilament:t=>Ae(`/filament-catalog/${t}`),getFilamentsByType:t=>Ae(`/filament-catalog/by-type/${t}`),getNotificationProviders:()=>Ae("/notifications/"),getNotificationProvider:t=>Ae(`/notifications/${t}`),createNotificationProvider:t=>Ae("/notifications/",{method:"POST",body:JSON.stringify(t)}),updateNotificationProvider:(t,e)=>Ae(`/notifications/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteNotificationProvider:t=>Ae(`/notifications/${t}`,{method:"DELETE"}),testNotificationProvider:t=>Ae(`/notifications/${t}/test`,{method:"POST"}),testNotificationConfig:t=>Ae("/notifications/test-config",{method:"POST",body:JSON.stringify(t)}),testAllNotificationProviders:()=>Ae("/notifications/test-all",{method:"POST"}),getNotificationTemplates:()=>Ae("/notification-templates"),getNotificationTemplate:t=>Ae(`/notification-templates/${t}`),updateNotificationTemplate:(t,e)=>Ae(`/notification-templates/${t}`,{method:"PUT",body:JSON.stringify(e)}),resetNotificationTemplate:t=>Ae(`/notification-templates/${t}/reset`,{method:"POST"}),getTemplateVariables:()=>Ae("/notification-templates/variables"),previewTemplate:t=>Ae("/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)),Ae(`/notifications/logs?${e}`)},getNotificationLogStats:(t=7)=>Ae(`/notifications/logs/stats?days=${t}`),clearNotificationLogs:(t=30)=>Ae(`/notifications/logs?older_than_days=${t}`,{method:"DELETE"}),getSpoolmanStatus:()=>Ae("/spoolman/status"),connectSpoolman:()=>Ae("/spoolman/connect",{method:"POST"}),disconnectSpoolman:()=>Ae("/spoolman/disconnect",{method:"POST"}),syncPrinterAms:t=>Ae(`/spoolman/sync/${t}`,{method:"POST"}),syncAllPrintersAms:()=>Ae("/spoolman/sync-all",{method:"POST"}),getSpoolmanSpools:()=>Ae("/spoolman/spools"),getSpoolmanFilaments:()=>Ae("/spoolman/filaments"),getUnlinkedSpools:()=>Ae("/spoolman/spools/unlinked"),getLinkedSpools:()=>Ae("/spoolman/spools/linked"),linkSpool:(t,e)=>Ae(`/spoolman/spools/${t}/link`,{method:"POST",body:JSON.stringify({tray_uuid:e})}),getSpoolmanSettings:()=>Ae("/settings/spoolman"),updateSpoolmanSettings:t=>Ae("/settings/spoolman",{method:"PUT",body:JSON.stringify(t)}),getSpools:(t=!1)=>Ae(`/inventory/spools?include_archived=${t}`),getSpool:t=>Ae(`/inventory/spools/${t}`),createSpool:t=>Ae("/inventory/spools",{method:"POST",body:JSON.stringify(t)}),bulkCreateSpools:(t,e)=>Ae("/inventory/spools/bulk",{method:"POST",body:JSON.stringify({spool:t,quantity:e})}),updateSpool:(t,e)=>Ae(`/inventory/spools/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteSpool:t=>Ae(`/inventory/spools/${t}`,{method:"DELETE"}),archiveSpool:t=>Ae(`/inventory/spools/${t}/archive`,{method:"POST"}),restoreSpool:t=>Ae(`/inventory/spools/${t}/restore`,{method:"POST"}),getSpoolKProfiles:t=>Ae(`/inventory/spools/${t}/k-profiles`),saveSpoolKProfiles:(t,e)=>Ae(`/inventory/spools/${t}/k-profiles`,{method:"PUT",body:JSON.stringify(e)}),getAssignments:t=>Ae(`/inventory/assignments${t?`?printer_id=${t}`:""}`),assignSpool:t=>Ae("/inventory/assignments",{method:"POST",body:JSON.stringify(t)}),unassignSpool:(t,e,n)=>Ae(`/inventory/assignments/${t}/${e}/${n}`,{method:"DELETE"}),getSpoolCatalog:()=>Ae("/inventory/catalog"),addCatalogEntry:t=>Ae("/inventory/catalog",{method:"POST",body:JSON.stringify(t)}),updateCatalogEntry:(t,e)=>Ae(`/inventory/catalog/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteCatalogEntry:t=>Ae(`/inventory/catalog/${t}`,{method:"DELETE"}),resetSpoolCatalog:()=>Ae("/inventory/catalog/reset",{method:"POST"}),getColorCatalog:()=>Ae("/inventory/colors"),addColorEntry:t=>Ae("/inventory/colors",{method:"POST",body:JSON.stringify(t)}),updateColorEntry:(t,e)=>Ae(`/inventory/colors/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteColorEntry:t=>Ae(`/inventory/colors/${t}`,{method:"DELETE"}),resetColorCatalog:()=>Ae("/inventory/colors/reset",{method:"POST"}),lookupColor:(t,e,n)=>Ae(`/inventory/colors/lookup?manufacturer=${encodeURIComponent(t)}&color_name=${encodeURIComponent(e)}${n?`&material=${encodeURIComponent(n)}`:""}`),searchColors:(t,e)=>Ae(`/inventory/colors/search?${t?`manufacturer=${encodeURIComponent(t)}`:""}${t&&e?"&":""}${e?`material=${encodeURIComponent(e)}`:""}`),linkTagToSpool:(t,e)=>Ae(`/inventory/spools/${t}/link-tag`,{method:"PATCH",body:JSON.stringify(e)}),getSpoolUsageHistory:(t,e=50)=>Ae(`/inventory/spools/${t}/usage?limit=${e}`),getAllUsageHistory:(t=100,e)=>Ae(`/inventory/usage?limit=${t}${e?`&printer_id=${e}`:""}`),clearSpoolUsageHistory:t=>Ae(`/inventory/spools/${t}/usage`,{method:"DELETE"}),syncWeightsFromAms:()=>Ae("/inventory/sync-ams-weights",{method:"POST"}),getFilamentPresets:()=>Ae("/cloud/filaments"),getVersion:()=>Ae("/updates/version"),checkForUpdates:()=>Ae("/updates/check"),applyUpdate:()=>Ae("/updates/apply",{method:"POST"}),getUpdateStatus:()=>Ae("/updates/status"),getMaintenanceTypes:()=>Ae("/maintenance/types"),createMaintenanceType:t=>Ae("/maintenance/types",{method:"POST",body:JSON.stringify(t)}),updateMaintenanceType:(t,e)=>Ae(`/maintenance/types/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteMaintenanceType:t=>Ae(`/maintenance/types/${t}`,{method:"DELETE"}),restoreDefaultMaintenanceTypes:()=>Ae("/maintenance/types/restore-defaults",{method:"POST"}),getMaintenanceOverview:()=>Ae("/maintenance/overview"),getPrinterMaintenance:t=>Ae(`/maintenance/printers/${t}`),updateMaintenanceItem:(t,e)=>Ae(`/maintenance/items/${t}`,{method:"PATCH",body:JSON.stringify(e)}),performMaintenance:(t,e)=>Ae(`/maintenance/items/${t}/perform`,{method:"POST",body:JSON.stringify({notes:e})}),getMaintenanceHistory:t=>Ae(`/maintenance/items/${t}/history`),getMaintenanceSummary:()=>Ae("/maintenance/summary"),setPrinterHours:(t,e)=>Ae(`/maintenance/printers/${t}/hours?total_hours=${e}`,{method:"PATCH"}),assignMaintenanceType:(t,e)=>Ae(`/maintenance/printers/${t}/assign/${e}`,{method:"POST"}),removeMaintenanceItem:t=>Ae(`/maintenance/items/${t}`,{method:"DELETE"}),getCameraStreamUrl:(t,e=10)=>`${nn}/printers/${t}/camera/stream?fps=${e}`,getCameraSnapshotUrl:t=>`${nn}/printers/${t}/camera/snapshot`,testCameraConnection:t=>Ae(`/printers/${t}/camera/test`),getCameraStatus:t=>Ae(`/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)),Ae(`/printers/${t}/camera/check-plate?${n.toString()}`)},getPlateDetectionStatus:t=>Ae(`/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)),Ae(`/printers/${t}/camera/plate-detection/calibrate?${n.toString()}`,{method:"POST"})},deletePlateCalibration:t=>Ae(`/printers/${t}/camera/plate-detection/calibrate`,{method:"DELETE"}),getPlateReferences:t=>Ae(`/printers/${t}/camera/plate-detection/references`),getPlateReferenceThumbnailUrl:(t,e)=>`${nn}/printers/${t}/camera/plate-detection/references/${e}/thumbnail`,updatePlateReferenceLabel:(t,e,n)=>{const r=new URLSearchParams;return r.set("label",n),Ae(`/printers/${t}/camera/plate-detection/references/${e}?${r.toString()}`,{method:"PUT"})},deletePlateReference:(t,e)=>Ae(`/printers/${t}/camera/plate-detection/references/${e}`,{method:"DELETE"}),getExternalLinks:()=>Ae("/external-links/"),getExternalLink:t=>Ae(`/external-links/${t}`),createExternalLink:t=>Ae("/external-links/",{method:"POST",body:JSON.stringify(t)}),updateExternalLink:(t,e)=>Ae(`/external-links/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteExternalLink:t=>Ae(`/external-links/${t}`,{method:"DELETE"}),reorderExternalLinks:t=>Ae("/external-links/reorder",{method:"PUT",body:JSON.stringify({ids:t})}),uploadExternalLinkIcon:async(t,e)=>{const n=new FormData;n.append("file",e);const r={};ln&&(r.Authorization=`Bearer ${ln}`);const i=await fetch(`${nn}/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=>Ae(`/external-links/${t}/icon`,{method:"DELETE"}),getExternalLinkIconUrl:t=>`${nn}/external-links/${t}/icon`,getProjects:t=>{const e=new URLSearchParams;return t&&e.set("status",t),Ae(`/projects/?${e}`)},getProject:t=>Ae(`/projects/${t}`),createProject:t=>Ae("/projects/",{method:"POST",body:JSON.stringify(t)}),updateProject:(t,e)=>Ae(`/projects/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteProject:t=>Ae(`/projects/${t}`,{method:"DELETE"}),getProjectArchives:(t,e=100,n=0)=>Ae(`/projects/${t}/archives?limit=${e}&offset=${n}`),addArchivesToProject:(t,e)=>Ae(`/projects/${t}/add-archives`,{method:"POST",body:JSON.stringify({archive_ids:e})}),removeArchivesFromProject:(t,e)=>Ae(`/projects/${t}/remove-archives`,{method:"POST",body:JSON.stringify({archive_ids:e})}),addQueueItemsToProject:(t,e)=>Ae(`/projects/${t}/add-queue`,{method:"POST",body:JSON.stringify({queue_item_ids:e})}),uploadProjectAttachment:async(t,e)=>{const n=new FormData;n.append("file",e);const r={};ln&&(r.Authorization=`Bearer ${ln}`);const i=await fetch(`${nn}/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)=>`${nn}/projects/${t}/attachments/${encodeURIComponent(e)}`,deleteProjectAttachment:(t,e)=>Ae(`/projects/${t}/attachments/${encodeURIComponent(e)}`,{method:"DELETE"}),getProjectBOM:t=>Ae(`/projects/${t}/bom`),createBOMItem:(t,e)=>Ae(`/projects/${t}/bom`,{method:"POST",body:JSON.stringify(e)}),updateBOMItem:(t,e,n)=>Ae(`/projects/${t}/bom/${e}`,{method:"PATCH",body:JSON.stringify(n)}),deleteBOMItem:(t,e)=>Ae(`/projects/${t}/bom/${e}`,{method:"DELETE"}),getTemplates:()=>Ae("/projects/templates/"),createTemplateFromProject:t=>Ae(`/projects/${t}/create-template`,{method:"POST"}),createProjectFromTemplate:(t,e)=>Ae(`/projects/from-template/${t}${e?`?name=${encodeURIComponent(e)}`:""}`,{method:"POST"}),getProjectTimeline:(t,e=50)=>Ae(`/projects/${t}/timeline?limit=${e}`),exportProjectJson:t=>Ae(`/projects/${t}/export?format=json`),importProject:t=>Ae("/projects/import",{method:"POST",body:JSON.stringify(t)}),importProjectFile:async t=>{const e=new FormData;e.append("file",t);const n={};ln&&(n.Authorization=`Bearer ${ln}`);const r=await fetch(`${nn}/projects/import/file`,{method:"POST",headers:n,body:e});if(!r.ok){const i=await r.json().catch(()=>({}));throw new Error(i.detail||`HTTP ${r.status}`)}return r.json()},exportProjectZip:async t=>{const e={};ln&&(e.Authorization=`Bearer ${ln}`);const n=await fetch(`${nn}/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=Hm(r)||`project_${t}.zip`;return{blob:await n.blob(),filename:i}},getAPIKeys:()=>Ae("/api-keys/"),createAPIKey:t=>Ae("/api-keys/",{method:"POST",body:JSON.stringify(t)}),updateAPIKey:(t,e)=>Ae(`/api-keys/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteAPIKey:t=>Ae(`/api-keys/${t}`,{method:"DELETE"}),getAMSHistory:(t,e,n=24)=>Ae(`/ams-history/${t}/${e}?hours=${n}`),getSystemInfo:()=>Ae("/system/info"),getStorageUsage:t=>{const e=new URLSearchParams;t?.refresh&&e.set("refresh","true");const n=e.toString();return Ae(`/system/storage-usage${n?`?${n}`:""}`)},getLibraryFolders:()=>Ae("/library/folders"),createLibraryFolder:t=>Ae("/library/folders",{method:"POST",body:JSON.stringify(t)}),updateLibraryFolder:(t,e)=>Ae(`/library/folders/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteLibraryFolder:t=>Ae(`/library/folders/${t}`,{method:"DELETE"}),getLibraryFoldersByProject:t=>Ae(`/library/folders/by-project/${t}`),getLibraryFoldersByArchive:t=>Ae(`/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)),Ae(`/library/files?${n}`)},getLibraryFile:t=>Ae(`/library/files/${t}`),uploadLibraryFile:async(t,e,n=!0)=>{const r=new FormData;r.append("file",t);const i=new URLSearchParams;e&&i.set("folder_id",String(e)),i.set("generate_stl_thumbnails",String(n));const s={};ln&&(s.Authorization=`Bearer ${ln}`);const o=await fetch(`${nn}/library/files?${i}`,{method:"POST",headers:s,body:r});if(!o.ok){const l=await o.json().catch(()=>({}));throw new Error(l.detail||`HTTP ${o.status}`)}return o.json()},extractZipFile:async(t,e,n=!0,r=!1,i=!0)=>{const s=new FormData;s.append("file",t);const o=new URLSearchParams;e&&o.set("folder_id",String(e)),o.set("preserve_structure",String(n)),o.set("create_folder_from_zip",String(r)),o.set("generate_stl_thumbnails",String(i));const l={};ln&&(l.Authorization=`Bearer ${ln}`);const c=await fetch(`${nn}/library/files/extract-zip?${o}`,{method:"POST",headers:l,body:s});if(!c.ok){const d=await c.json().catch(()=>({}));throw new Error(d.detail||`HTTP ${c.status}`)}return c.json()},updateLibraryFile:(t,e)=>Ae(`/library/files/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteLibraryFile:t=>Ae(`/library/files/${t}`,{method:"DELETE"}),getLibraryFileDownloadUrl:t=>`${nn}/library/files/${t}/download`,createLibrarySlicerToken:t=>Ae(`/library/files/${t}/slicer-token`,{method:"POST"}),getLibrarySlicerDownloadUrl:(t,e,n)=>`${nn}/library/files/${t}/dl/${e}/${encodeURIComponent(n)}`,downloadLibraryFile:async(t,e)=>{const n={};ln&&(n.Authorization=`Bearer ${ln}`);const r=await fetch(`${nn}/library/files/${t}/download`,{headers:n});if(!r.ok){const d=await r.json().catch(()=>({}));throw new Error(d.detail||`HTTP ${r.status}`)}const i=r.headers.get("Content-Disposition"),s=Hm(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=>`${nn}/library/files/${t}/thumbnail`,getLibraryFilePlateThumbnail:(t,e)=>`${nn}/library/files/${t}/plate-thumbnail/${e}`,getLibraryFileGcodeUrl:t=>`${nn}/library/files/${t}/gcode`,moveLibraryFiles:(t,e)=>Ae("/library/files/move",{method:"POST",body:JSON.stringify({file_ids:t,folder_id:e})}),bulkDeleteLibrary:(t,e)=>Ae("/library/bulk-delete",{method:"POST",body:JSON.stringify({file_ids:t,folder_ids:e})}),getLibraryStats:()=>Ae("/library/stats"),batchGenerateStlThumbnails:t=>Ae("/library/generate-stl-thumbnails",{method:"POST",body:JSON.stringify(t)}),addLibraryFilesToQueue:t=>Ae("/library/files/add-to-queue",{method:"POST",body:JSON.stringify({file_ids:t})}),printLibraryFile:(t,e,n)=>Ae(`/library/files/${t}/print?printer_id=${e}`,{method:"POST",body:n?JSON.stringify(n):void 0}),cancelBackgroundDispatchJob:t=>Ae(`/background-dispatch/${t}`,{method:"DELETE"}),getLibraryFilePlates:t=>Ae(`/library/files/${t}/plates`),getLibraryFileFilamentRequirements:(t,e)=>Ae(`/library/files/${t}/filament-requirements${e!==void 0?`?plate_id=${e}`:""}`),getGitHubBackupConfig:()=>Ae("/github-backup/config"),saveGitHubBackupConfig:t=>Ae("/github-backup/config",{method:"POST",body:JSON.stringify(t)}),updateGitHubBackupConfig:t=>Ae("/github-backup/config",{method:"PATCH",body:JSON.stringify(t)}),deleteGitHubBackupConfig:()=>Ae("/github-backup/config",{method:"DELETE"}),testGitHubConnection:(t,e)=>Ae(`/github-backup/test?repo_url=${encodeURIComponent(t)}&token=${encodeURIComponent(e)}`,{method:"POST"}),testGitHubStoredConnection:()=>Ae("/github-backup/test-stored",{method:"POST"}),triggerGitHubBackup:()=>Ae("/github-backup/run",{method:"POST"}),getGitHubBackupStatus:()=>Ae("/github-backup/status"),getGitHubBackupLogs:(t=50)=>Ae(`/github-backup/logs?limit=${t}`),clearGitHubBackupLogs:(t=10)=>Ae(`/github-backup/logs?keep_last=${t}`,{method:"DELETE"}),getLocalPresets:()=>Ae("/local-presets/"),getLocalPresetDetail:t=>Ae(`/local-presets/${t}`),importLocalPresets:t=>fetch(`${nn}/local-presets/import`,{method:"POST",headers:ln?{Authorization:`Bearer ${ln}`}:{},body:t}).then(async e=>{if(!e.ok){const n=await e.json().catch(()=>({}));throw new Error(n.detail||`HTTP ${e.status}`)}return e.json()}),createLocalPreset:t=>Ae("/local-presets/",{method:"POST",body:JSON.stringify(t)}),updateLocalPreset:(t,e)=>Ae(`/local-presets/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteLocalPreset:t=>Ae(`/local-presets/${t}`,{method:"DELETE"}),refreshBaseProfileCache:()=>Ae("/local-presets/base-cache/refresh",{method:"POST"})},hc={getInfo:()=>Ae("/discovery/info"),getStatus:()=>Ae("/discovery/status"),startDiscovery:(t=10)=>Ae(`/discovery/start?duration=${t}`,{method:"POST"}),stopDiscovery:()=>Ae("/discovery/stop",{method:"POST"}),getDiscoveredPrinters:()=>Ae("/discovery/printers"),startSubnetScan:(t,e=1)=>Ae("/discovery/scan",{method:"POST",body:JSON.stringify({subnet:t,timeout:e})}),getScanStatus:()=>Ae("/discovery/scan/status"),stopSubnetScan:()=>Ae("/discovery/scan/stop",{method:"POST"})},_ge={getSettings:()=>Ae("/settings/virtual-printer")},N1={list:()=>Ae("/virtual-printers"),get:t=>Ae(`/virtual-printers/${t}`),create:t=>Ae("/virtual-printers",{method:"POST",body:JSON.stringify(t)}),update:(t,e)=>Ae(`/virtual-printers/${t}`,{method:"PUT",body:JSON.stringify(e)}),remove:t=>Ae(`/virtual-printers/${t}`,{method:"DELETE"})},Eg={list:()=>Ae("/pending-uploads/"),getCount:()=>Ae("/pending-uploads/count"),get:t=>Ae(`/pending-uploads/${t}`),archive:(t,e)=>Ae(`/pending-uploads/${t}/archive`,{method:"POST",body:JSON.stringify(e||{})}),discard:t=>Ae(`/pending-uploads/${t}`,{method:"DELETE"}),archiveAll:()=>Ae("/pending-uploads/archive-all",{method:"POST"}),discardAll:()=>Ae("/pending-uploads/discard-all",{method:"DELETE"})},B_={checkUpdates:()=>Ae("/firmware/updates"),checkPrinterUpdate:t=>Ae(`/firmware/updates/${t}`),prepareUpload:t=>Ae(`/firmware/updates/${t}/prepare`),startUpload:t=>Ae(`/firmware/updates/${t}/upload`,{method:"POST"}),getUploadStatus:t=>Ae(`/firmware/updates/${t}/upload/status`)},Kg={getDebugLoggingState:()=>Ae("/support/debug-logging"),setDebugLogging:t=>Ae("/support/debug-logging",{method:"POST",body:JSON.stringify({enabled:t})}),downloadSupportBundle:async()=>{const t={};ln&&(t.Authorization=`Bearer ${ln}`);const e=await fetch(`${nn}/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=Hm(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 Ae(`/support/logs${n?`?${n}`:""}`)},clearLogs:()=>Ae("/support/logs",{method:"DELETE"})},Xg={getDevices:()=>Ae("/spoolbuddy/devices"),tare:t=>Ae(`/spoolbuddy/devices/${t}/calibration/tare`,{method:"POST",body:"{}"}),getCalibration:t=>Ae(`/spoolbuddy/devices/${t}/calibration`),setCalibrationFactor:(t,e,n)=>Ae(`/spoolbuddy/devices/${t}/calibration/set-factor`,{method:"POST",body:JSON.stringify({known_weight_grams:e,raw_adc:n})}),updateSpoolWeight:(t,e)=>Ae("/spoolbuddy/scale/update-spool-weight",{method:"POST",body:JSON.stringify({spool_id:t,weight_grams:e})})},DX=w.createContext(void 0);function Nge({children:t}){const[e,n]=w.useState(()=>{const C=localStorage.getItem("theme-mode"),j=localStorage.getItem("theme");return C||j||"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"),[d,u]=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(()=>{J.getSettings().then(C=>{C.dark_style&&(i(C.dark_style),localStorage.setItem("dark-style",C.dark_style)),C.dark_background&&(o(C.dark_background),localStorage.setItem("dark-background",C.dark_background)),C.dark_accent&&(c(C.dark_accent),localStorage.setItem("dark-accent",C.dark_accent)),C.light_style&&(u(C.light_style),localStorage.setItem("light-style",C.light_style)),C.light_background&&(f(C.light_background),localStorage.setItem("light-background",C.light_background)),C.light_accent&&(x(C.light_accent),localStorage.setItem("light-accent",C.light_accent))}).catch(()=>{})},[]),w.useEffect(()=>{const C=document.documentElement;C.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"?(C.classList.add("dark"),C.classList.add(`style-${r}`),C.classList.add(`bg-${s}`),C.classList.add(`accent-${l}`)):(C.classList.add(`style-${d}`),C.classList.add(`bg-${h}`),C.classList.add(`accent-${p}`)),localStorage.setItem("theme-mode",e),localStorage.removeItem("theme")},[e,r,s,l,d,h,p]);const v=()=>n(C=>C==="dark"?"light":"dark"),g=C=>n(C),y=C=>{i(C),localStorage.setItem("dark-style",C),J.updateSettings({dark_style:C}).catch(()=>{})},_=C=>{o(C),localStorage.setItem("dark-background",C),J.updateSettings({dark_background:C}).catch(()=>{})},N=C=>{c(C),localStorage.setItem("dark-accent",C),J.updateSettings({dark_accent:C}).catch(()=>{})},A=C=>{u(C),localStorage.setItem("light-style",C),J.updateSettings({light_style:C}).catch(()=>{})},k=C=>{f(C),localStorage.setItem("light-background",C),J.updateSettings({light_background:C}).catch(()=>{})},P=C=>{x(C),localStorage.setItem("light-accent",C),J.updateSettings({light_accent:C}).catch(()=>{})};return a.jsx(DX.Provider,{value:{mode:e,darkStyle:r,darkBackground:s,darkAccent:l,lightStyle:d,lightBackground:h,lightAccent:p,toggleMode:v,setMode:g,setDarkStyle:y,setDarkBackground:_,setDarkAccent:N,setLightStyle:A,setLightBackground:k,setLightAccent:P},children:t})}function ep(){const t=w.useContext(DX);if(!t)throw new Error("useTheme must be used within ThemeProvider");return t}function St({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 On({children:t,className:e=""}){return a.jsx("div",{className:`px-6 py-4 border-b border-bambu-dark-tertiary ${e}`,children:t})}function Nt({children:t,className:e=""}){return a.jsx("div",{className:`p-6 ${e}`,children:t})}function Cge(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 UB({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 kge({onClose:t,navItems:e,sidebarItems:n}){const{t:r}=Dt(),i=Cge(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(St,{className:"w-full max-w-md",onClick:s=>s.stopPropagation(),children:a.jsxs(Nt,{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(s3,{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(Rt,{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(ta,{className:"w-3 h-3 text-bambu-gray"})]}),a.jsx("div",{className:"flex gap-1",children:o.keys.map(l=>a.jsx(UB,{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(UB,{children:"Esc"})," or click outside to close"]})})]})})})}function Me({variant:t="primary",size:e="md",className:n="",children:r,...i}){const s="inline-flex items-center justify-center font-medium rounded-lg transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-bambu-dark disabled:opacity-50 disabled:cursor-not-allowed",o={primary:"bg-bambu-green hover:bg-bambu-green-light text-white focus:ring-bambu-green",secondary:"bg-bambu-dark-tertiary hover:bg-bambu-gray-dark text-white focus:ring-bambu-gray",danger:"bg-red-600 hover:bg-red-700 text-white focus:ring-red-500",ghost:"bg-transparent hover:bg-bambu-dark-tertiary text-bambu-gray-light hover:text-white"},l={sm:"px-3 py-1.5 text-sm gap-1.5 min-h-[44px] md:min-h-0",md:"px-4 py-2 text-sm gap-2 min-h-[44px] md:min-h-0",lg:"px-6 py-3 text-base gap-2 min-h-[48px] md:min-h-0"};return a.jsx("button",{className:`${s} ${o[t]} ${l[e]} ${n}`,...i,children:r})}function xn({title:t,message:e,confirmText:n,cancelText:r,cancelVariant:i,cardClassName:s,variant:o="default",isLoading:l=!1,loadingText:c,onConfirm:d,onCancel:u}){const{t:h}=Dt(),f=n??h("common.confirm"),p=r??h("common.cancel"),x=c??h("common.loading");w.useEffect(()=>{const y=_=>{_.key==="Escape"&&!l&&u()};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[u,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:u,children:a.jsx(St,{className:`w-full max-w-md ${s??""}`,onClick:y=>y.stopPropagation(),children:a.jsxs(Nt,{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(An,{className:"w-6 h-6"})}),a.jsxs("div",{className:"flex-1",children:[a.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:t}),a.jsx("p",{className:"text-bambu-gray text-sm",children:e})]})]}),a.jsxs("div",{className:"flex gap-3 mt-6",children:[a.jsx(Me,{variant:i??"secondary",onClick:u,className:"flex-1",disabled:l,children:p}),a.jsx(Me,{onClick:d,className:`flex-1 ${g.button}`,disabled:l,children:l?a.jsxs(a.Fragment,{children:[a.jsx(at,{className:"w-4 h-4 mr-2 animate-spin"}),x]}):f})]})]})})})}function Age({plug:t}){const e=Qt(),[n,r]=w.useState(null),{data:i,isLoading:s}=Ze({queryKey:["smart-plug-status",t.id],queryFn:()=>J.getSmartPlugStatus(t.id),refetchInterval:1e4}),o=st({mutationFn:p=>J.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,d=(i?.reachable??!1)||c,u=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?d?"bg-teal-500/20":"bg-red-500/20":d?l?"bg-bambu-green/20":"bg-bambu-dark":"bg-red-500/20"}`,children:h?a.jsx(MF,{className:`w-4 h-4 ${d?"text-teal-400":"text-red-400"}`}):a.jsx(gl,{className:`w-4 h-4 ${d?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(at,{className:"w-3 h-3 text-bambu-gray animate-spin"}):h?d?a.jsxs(a.Fragment,{children:[a.jsx(ru,{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(Zl,{className:"w-3 h-3 text-bambu-gray"}),a.jsx("span",{className:"text-bambu-gray",children:"Monitor"})]}):a.jsxs(a.Fragment,{children:[a.jsx(Gh,{className:"w-3 h-3 text-status-error"}),a.jsx("span",{className:"text-status-error",children:"Waiting"})]}):d?a.jsxs(a.Fragment,{children:[a.jsx(Wg,{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(ru,{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(Gh,{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:!d||u,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:u?a.jsx(at,{className:"w-4 h-4 animate-spin"}):a.jsx(fu,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>r("off"),disabled:!d||u,className:`p-1.5 rounded transition-colors ${!l&&d?"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:u?a.jsx(at,{className:"w-4 h-4 animate-spin"}):a.jsx(YC,{className:"w-4 h-4"})})]})]}),n&&a.jsx(xn,{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 BB({onClose:t}){const{data:e,isLoading:n}=Ze({queryKey:["smart-plugs"],queryFn:J.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(gl,{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(at,{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(gl,{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(Age,{plug:i},i.id))})})]})}const RX=[{name:"globe",icon:Eh},{name:"link",icon:qb},{name:"external-link",icon:ta},{name:"book",icon:ahe},{name:"file-text",icon:Ps},{name:"home",icon:dv},{name:"star",icon:Ef},{name:"heart",icon:tfe},{name:"bookmark",icon:she},{name:"shopping-cart",icon:AX},{name:"music",icon:c3},{name:"video",icon:jF},{name:"image",icon:eu},{name:"camera",icon:db},{name:"map",icon:kfe},{name:"compass",icon:tme},{name:"coffee",icon:Whe},{name:"gift",icon:Bme},{name:"wrench",icon:jf},{name:"zap",icon:ru},{name:"cloud",icon:$b},{name:"database",icon:jc},{name:"folder",icon:SX},{name:"mail",icon:p0},{name:"phone",icon:Yfe},{name:"user",icon:nu},{name:"users",icon:fh},{name:"server",icon:Bm},{name:"terminal",icon:PX},{name:"code",icon:vX}];function tk(t){return RX.find(n=>n.name===t)?.icon||qb}function Tge({value:t,onChange:e}){const[n,r]=w.useState(!1),i=tk(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:RX.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 HB=1144;function Mge(){const[t,e]=w.useState(()=>typeof window<"u"?window.innerWidth<HB:!1);return w.useEffect(()=>{const n=window.matchMedia(`(max-width: ${HB-1}px)`),r=i=>{e(i.matches)};return e(n.matches),n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[]),t}const FX=w.createContext(void 0);function Pge({children:t}){const[e,n]=w.useState(null),[r,i]=w.useState(!1),[s,o]=w.useState(!1),[l,c]=w.useState(!0),d=w.useRef(!1),u=w.useRef(!0),h=async()=>{try{const P=new URLSearchParams(window.location.search),C=P.get("token");if(C){Pg(C),P.delete("token");const M=P.toString(),E=window.location.pathname+(M?`?${M}`:"")+window.location.hash;window.history.replaceState({},"",E)}const j=await J.getAuthStatus();if(!u.current)return;if(i(j.auth_enabled),o(j.requires_setup),j.auth_enabled)if(au())try{const E=await J.getCurrentUser();if(!u.current)return;n(E)}catch{if(Pg(null),!u.current)return;n(null)}else n(null);else n(null)}catch{if(!u.current)return;i(!1),n(null)}finally{u.current&&c(!1)}};w.useEffect(()=>(u.current=!0,h(),()=>{u.current=!1}),[]),w.useEffect(()=>{if(!l&&s&&!r){const P=window.location.pathname;P!=="/setup"&&!P.startsWith("/camera/")&&!d.current&&(d.current=!0,window.location.href="/setup")}else s||(d.current=!1)},[l,s,r]);const f=async(P,C)=>{const j=await J.login({username:P,password:C});Pg(j.access_token),await h()},p=()=>{Pg(null),n(null),J.logout().catch(()=>{}),window.location.href="/login"},x=async()=>{if(r&&au())try{const P=await J.getCurrentUser();u.current&&n(P)}catch{Pg(null),u.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(P=>!r||y?!0:g.has(P),[r,y,g]),N=w.useCallback((...P)=>!r||y?!0:P.some(C=>g.has(C)),[r,y,g]),A=w.useCallback((...P)=>!r||y?!0:P.every(C=>g.has(C)),[r,y,g]),k=w.useCallback((P,C,j)=>{if(!r||y)return!0;const M=`${P}:${C}_all`,E=`${P}:${C}_own`;return g.has(M)?!0:g.has(E)?j==null?!1:j===e?.id:!1},[r,y,g,e?.id]);return a.jsx(FX.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:k},children:t})}function jr(){const t=w.useContext(FX);if(t===void 0)throw new Error("useAuth must be used within an AuthProvider");return t}const LX=w.createContext(void 0);function dn(){const t=w.useContext(LX);if(!t)throw new Error("useToast must be used within a ToastProvider");return t}const $B={success:a.jsx(yr,{className:"w-5 h-5 text-green-400"}),error:a.jsx(mi,{className:"w-5 h-5 text-red-400"}),warning:a.jsx(Va,{className:"w-5 h-5 text-yellow-400"}),info:a.jsx(eo,{className:"w-5 h-5 text-blue-400"}),loading:a.jsx(at,{className:"w-5 h-5 text-bambu-green animate-spin"})},Ege={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 jge({children:t}){const{t:e}=Dt(),[n,r]=w.useState([]),[i,s]=w.useState(!1),[o,l]=w.useState(new Set),c=w.useRef(new Map),d="background-dispatch",u=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(k=>k.id!==_)),c.current.delete(_)},3e3);c.current.set(_,N)},[]),p=w.useCallback((g,y,_="info")=>{r(N=>N.find(k=>k.id===g)?N.map(k=>k.id===g?{...k,message:y,type:_,persistent:!0}:k):[...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 J.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,k)=>{const P=N.findIndex(j=>j.jobId===A);if(P===-1)return[...N,{jobId:A,...k}];const C=[...N];return C[P]={...C[P],...k},C},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||{},k=A.total??0,P=A.dispatched??0,C=A.processing??0,j=A.completed??0,M=A.failed??0,E=P+C>0,B=k>0&&j+M>=k&&!E;if(E){r(U=>{const $=U.find(ee=>ee.id===d)?.dispatchData?.jobs||[],q=(A.dispatched_jobs||[]).map(ee=>({jobId:ee.job_id,sourceName:ee.source_name||e("backgroundDispatch.unknownFile"),printerName:ee.printer_name||e("backgroundDispatch.unknownPrinter"),status:"dispatched"})),W=(A.active_jobs&&A.active_jobs.length>0?A.active_jobs:A.active_job?.job_id?[A.active_job]:[]).filter(ee=>typeof ee.job_id=="number").map(ee=>({jobId:ee.job_id,sourceName:ee.source_name||e("backgroundDispatch.unknownFile"),printerName:ee.printer_name||e("backgroundDispatch.unknownPrinter"),status:"processing",message:ee.message,uploadBytes:ee.upload_bytes,uploadTotalBytes:ee.upload_total_bytes,uploadProgressPct:ee.upload_progress_pct})),Q=new Set([...q,...W].map(ee=>ee.jobId)),te=$.filter(ee=>!Q.has(ee.jobId)&&["completed","failed","cancelled"].includes(ee.status));let H=[...q,...W,...te];if(A.recent_event?.job_id&&A.recent_event?.status){const ee=A.recent_event.status,Se=ee==="cancelled"?"cancelled":ee==="cancelling"?"processing":ee,oe=A.recent_event.source_name||e("backgroundDispatch.unknownFile"),ie=A.recent_event.printer_name||e("backgroundDispatch.unknownPrinter");H=g(H,A.recent_event.job_id,{status:Se,sourceName:oe,printerName:ie,message:A.recent_event.message})}W.forEach(ee=>{H=g(H,ee.jobId,{status:"processing",sourceName:ee.sourceName,printerName:ee.printerName,message:ee.message,uploadBytes:ee.uploadBytes,uploadTotalBytes:ee.uploadTotalBytes,uploadProgressPct:ee.uploadProgressPct})});const X={total:k,dispatched:P,processing:C,completed:j,failed:M,jobs:[...H].sort((ee,Se)=>{const oe=y(ee.status)-y(Se.status);return oe!==0?oe:ee.jobId-Se.jobId})};return U.find(ee=>ee.id===d)?U.map(ee=>ee.id===d?{...ee,message:e("backgroundDispatch.startingPrints"),type:"loading",persistent:!0,dispatchData:X}:ee):[...U,{id:d,message:e("backgroundDispatch.startingPrints"),type:"loading",persistent:!0,dispatchData:X}]});return}const L=A.recent_event?.status;if(!E&&L&&["cancelled","failed","completed","idle"].includes(L)&&r(U=>U.filter(D=>D.id!==d)),B){const U=`${j}:${M}`;if(u.current===U)return;u.current=U,r(z=>z.filter(W=>W.id!==d));const D=M>0?e("backgroundDispatch.toast.completeWithFailures",{completed:j,failed:M}):e("backgroundDispatch.toast.completeSuccess",{completed:j}),$=Math.random().toString(36).substr(2,9);r(z=>[...z,{id:$,message:D,type:M>0?"warning":"success"}]);const q=setTimeout(()=>{r(z=>z.filter(W=>W.id!==$)),c.current.delete($)},4e3);c.current.set($,q)}if(A.recent_event?.status==="idle"&&!E&&r(U=>U.filter(D=>D.id!==d)),E||l(new Set),A.dispatched_jobs){const U=new Set(A.dispatched_jobs.map(D=>D.job_id));l(D=>{const $=new Set;return D.forEach(q=>{U.has(q)&&$.add(q)}),$})}};return window.addEventListener("background-dispatch",_),()=>window.removeEventListener("background-dispatch",_)},[e]),a.jsxs(LX.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 ${Ege[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:[$B[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(wl,{className:"w-4 h-4"}):a.jsx(Mn,{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(Rt,{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:[$B[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(Rt,{className:"w-4 h-4"})})]})},g.id))})]})}function Dge(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 Rge(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 h3(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 VB(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 nS(t){for(const e of["/",".","-"]){const n=t.split(e);if(n.length===3)return n}return null}function Fge(t,e="system"){if(!t)return null;let n,r,i;try{switch(e){case"us":{const s=nS(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=nS(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=nS(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=nS(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 Lge(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 m3(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 C1(t,e="system"){return e==="12h"?t.hour12=!0:e==="24h"&&(t.hour12=!1),t}function tr(t){return t?t.endsWith("Z")||/[+-]\d{2}:\d{2}$/.test(t)?new Date(t):new Date(t+"Z"):null}function mb(t,e){const n=tr(t);if(!n)return"";const r={year:"numeric",month:"short",day:"numeric"};return n.toLocaleDateString(void 0,e??r)}function Df(t,e="system",n){const r=tr(t);if(!r)return"";const s=C1(n??{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"},e);return r.toLocaleString(void 0,s)}function Oge(t,e="system",n){const i=C1({...{hour:"2-digit",minute:"2-digit"},...n},e);return t.toLocaleTimeString([],i)}function FF(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),d=Math.floor((o.getTime()-s.getTime())/864e5);return d===0?c:d===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 g0(t,e="system",n){if(!t)return n?.("time.unknown")??"-";const r=tr(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),d=Math.floor(l/36e5),u=Math.floor(l/864e5);return c<1?o?n?.("time.justNow")??"Just now":n?.("time.now")??"Now":d<1?o?n?.("time.minsAgo",{count:c})??`${c}m ago`:n?.("time.inMins",{count:c})??`in ${c}m`:u<1?o?n?.("time.hoursAgo",{count:d})??`${d}h ago`:n?.("time.inHours",{count:d})??`in ${d}h`:u<7?o?n?.("time.daysAgo",{count:u})??`${u}d ago`:n?.("time.inDays",{count:u})??`in ${u}d`:Df(t,e)}const b0=[{id:"printers",to:"/",icon:Nr,labelKey:"nav.printers"},{id:"archives",to:"/archives",icon:Ds,labelKey:"nav.archives"},{id:"queue",to:"/queue",icon:da,labelKey:"nav.queue"},{id:"stats",to:"/stats",icon:yhe,labelKey:"nav.stats"},{id:"profiles",to:"/profiles",icon:$b,labelKey:"nav.profiles"},{id:"maintenance",to:"/maintenance",icon:jf,labelKey:"nav.maintenance"},{id:"projects",to:"/projects",icon:xs,labelKey:"nav.projects"},{id:"inventory",to:"/inventory",icon:lme,labelKey:"nav.inventory"},{id:"files",to:"/files",icon:Jl,labelKey:"nav.files"},{id:"settings",to:"/settings",icon:ZC,labelKey:"nav.settings"}];function Ige(){const t=localStorage.getItem("sidebarOrder");if(t)try{return JSON.parse(t)}catch{return b0.map(e=>e.id)}return b0.map(e=>e.id)}function zge(t){localStorage.setItem("sidebarOrder",JSON.stringify(t))}function HM(t){return t.startsWith("ext-")}function OX(){return localStorage.getItem("defaultView")||"/"}function Uge(t){localStorage.setItem("defaultView",t)}function Bge(){const t=ac(),e=qc(),{mode:n,toggleMode:r}=ep(),{t:i}=Dt(),s=Mge(),{user:o,authEnabled:l,logout:c,hasPermission:d}=jr(),{showToast:u}=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),[k,P]=w.useState(!1),[C,j]=w.useState(!1),[M,E]=w.useState(Ige),[B,L]=w.useState(null),[U,D]=w.useState(null),$=w.useRef(!1),[q,z]=w.useState(()=>sessionStorage.getItem("dismissedUpdateVersion")),[W,Q]=w.useState(null),{data:te}=Ze({queryKey:["version"],queryFn:J.getVersion,staleTime:1/0}),{data:H}=Ze({queryKey:["settings"],queryFn:J.getSettings,staleTime:300*1e3}),{data:X}=Ze({queryKey:["updateCheck"],queryFn:J.checkForUpdates,enabled:H?.check_updates!==!1,staleTime:3600*1e3,refetchInterval:3600*1e3}),{data:Z}=Ze({queryKey:["external-links"],queryFn:J.getExternalLinks}),{data:ee}=Ze({queryKey:["smart-plugs"],queryFn:J.getSmartPlugs,staleTime:30*1e3}),Se=ee?.some(ae=>ae.show_in_switchbar)??!1,{data:oe}=Ze({queryKey:["debugLogging"],queryFn:Kg.getDebugLoggingState,staleTime:60*1e3,refetchInterval:60*1e3}),{data:ie}=Ze({queryKey:["developer-mode-warnings"],queryFn:J.getDeveloperModeWarnings,staleTime:10*1e3,refetchInterval:30*1e3,refetchOnWindowFocus:!0}),{data:me}=Ze({queryKey:["queue","pending"],queryFn:()=>J.getQueue(void 0,"pending"),staleTime:5*1e3,refetchInterval:5*1e3,refetchOnWindowFocus:!0}),se=me?.length??0,{data:ce}=Ze({queryKey:["pending-uploads","count"],queryFn:Eg.getCount,staleTime:5*1e3,refetchInterval:5*1e3,refetchOnWindowFocus:!0}),Ce=ce?.count??0,le=w.useMemo(()=>{const ae=new Set;return me?.forEach(Ue=>{Ue.printer_id&&ae.add(Ue.printer_id)}),Array.from(ae)},[me]),V=lv({queries:le.map(ae=>({queryKey:["printerStatus",ae],queryFn:()=>J.getPrinterStatus(ae),staleTime:30*1e3}))}).some(ae=>{const Ue=ae.data;return Ue?(Ue.state==="FINISH"||Ue.state==="FAILED")&&!Ue.plate_cleared:!1}),[K,fe]=w.useState(null);w.useEffect(()=>{if(!oe?.enabled||!oe.enabled_at){fe(null);return}const ae=tr(oe.enabled_at)?.getTime()??Date.now(),Ue=()=>{fe(Math.floor((Date.now()-ae)/1e3))};Ue();const ze=setInterval(Ue,1e3);return()=>clearInterval(ze)},[oe?.enabled,oe?.enabled_at]);const Y=w.useMemo(()=>new Map(b0.map(ae=>[ae.id,ae])),[]),re=w.useMemo(()=>new Map((Z||[]).map(ae=>[`ext-${ae.id}`,ae])),[Z]),ue=(()=>{const ae=[],Ue=new Set,ze=l&&!d("settings:read");for(const $e of M)ze&&$e==="settings"||(Y.has($e)||re.has($e))&&(ae.push($e),Ue.add($e));for(const $e of b0)ze&&$e.id==="settings"||Ue.has($e.id)||(ae.push($e.id),Ue.add($e.id));for(const $e of Z||[]){const Re=`ext-${$e.id}`;Ue.has(Re)||(ae.push(Re),Ue.add(Re))}return ae})(),Fe=(ae,Ue)=>{L(Ue),ae.dataTransfer.effectAllowed="move",ae.dataTransfer.setData("text/plain",Ue)},Pe=(ae,Ue)=>{ae.preventDefault(),ae.dataTransfer.dropEffect="move",D(Ue)},be=()=>{D(null)},O=(ae,Ue)=>{if(ae.preventDefault(),B===null||B===Ue){L(null),D(null);return}const ze=[...ue],$e=ze.indexOf(B),Re=ze.indexOf(Ue);if($e===-1||Re===-1){L(null),D(null);return}ze.splice($e,1),ze.splice(Re,0,B),E(ze),zge(ze),L(null),D(null)},R=()=>{L(null),D(null)},G=X?.update_available&&X.latest_version&&X.latest_version!==q,de=()=>{X?.latest_version&&(sessionStorage.setItem("dismissedUpdateVersion",X.latest_version),z(X.latest_version))};w.useEffect(()=>{if(!$.current&&e.pathname==="/"){const ae=OX();ae!=="/"&&($.current=!0,t(ae,{replace:!0}))}},[e.pathname,t]),w.useEffect(()=>{localStorage.setItem("sidebarExpanded",String(y))},[y]),w.useEffect(()=>{s&&A(!1)},[e.pathname,s]),w.useEffect(()=>{const ae=Ue=>{if(!d("printers:control"))return;const ze=Ue.detail;Q({printer_id:ze.printer_id,printer_name:ze.printer_name,message:ze.message})};return window.addEventListener("plate-not-empty",ae),()=>window.removeEventListener("plate-not-empty",ae)},[d]);const ge=w.useCallback(ae=>{const Ue=ae.target;if(!(Ue.tagName==="INPUT"||Ue.tagName==="TEXTAREA"||Ue.isContentEditable)&&!ae.metaKey&&!ae.ctrlKey&&!ae.altKey){const ze=parseInt(ae.key);if(ze>=1&&ze<=ue.length&&ze<=9){const $e=ue[ze-1];if(ae.preventDefault(),HM($e)){const Re=re.get($e);if(Re?.open_in_new_tab)window.open(Re.url,"_blank","noopener,noreferrer");else{const pe=$e.replace("ext-","");t(`/external/${pe}`)}}else{const Re=Y.get($e);Re&&t(Re.to)}return}switch(ae.key){case"?":ae.preventDefault(),P(!0);break;case"Escape":P(!1);break}}},[t,ue,Y,re]);return w.useEffect(()=>(document.addEventListener("keydown",ge),()=>document.removeEventListener("keydown",ge)),[ge]),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(Dfe,{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:ue.map(ae=>{if(HM(ae)){const ze=re.get(ae);if(!ze)return null;const $e=ze.custom_icon?null:tk(ze.icon);return a.jsx("li",{draggable:!0,onDragStart:Re=>Fe(Re,ae),onDragOver:Re=>Pe(Re,ae),onDragLeave:be,onDrop:Re=>O(Re,ae),onDragEnd:R,className:`relative ${B===ae?"opacity-50":""} ${U===ae&&B!==ae?"before:absolute before:left-0 before:right-0 before:top-0 before:h-0.5 before:bg-bambu-green":""}`,children:ze.open_in_new_tab?a.jsxs("a",{href:ze.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?ze.name:void 0,children:[y&&!s&&a.jsx(jh,{className:"w-4 h-4 flex-shrink-0 opacity-0 group-hover:opacity-50 cursor-grab active:cursor-grabbing -ml-1"}),ze.custom_icon?a.jsx("img",{src:`/api/v1/external-links/${ze.id}/icon`,alt:"",className:"w-5 h-5 flex-shrink-0"}):$e&&a.jsx($e,{className:"w-5 h-5 flex-shrink-0"}),(s||y)&&a.jsx("span",{children:ze.name})]}):a.jsxs(Og,{to:`/external/${ze.id}`,className:({isActive:Re})=>`flex items-center ${s||y?"gap-3 px-4":"justify-center px-2"} py-3 rounded-lg transition-colors group ${Re?"bg-bambu-green text-white":"text-bambu-gray-light hover:bg-bambu-dark-tertiary hover:text-white"}`,title:!s&&!y?ze.name:void 0,children:[y&&!s&&a.jsx(jh,{className:"w-4 h-4 flex-shrink-0 opacity-0 group-hover:opacity-50 cursor-grab active:cursor-grabbing -ml-1"}),ze.custom_icon?a.jsx("img",{src:`/api/v1/external-links/${ze.id}/icon`,alt:"",className:"w-5 h-5 flex-shrink-0"}):$e&&a.jsx($e,{className:"w-5 h-5 flex-shrink-0"}),(s||y)&&a.jsx("span",{children:ze.name})]})},ae)}else{const ze=Y.get(ae);if(!ze)return null;const{to:$e,icon:Re,labelKey:pe}=ze,ve=ae==="queue"&&se>0,Ne=ae==="archives"&&Ce>0,xe=ve?se:Ne?Ce:0,we=ve||Ne,qe=ae==="printers"&&V;return a.jsx("li",{draggable:!0,onDragStart:ke=>Fe(ke,ae),onDragOver:ke=>Pe(ke,ae),onDragLeave:be,onDrop:ke=>O(ke,ae),onDragEnd:R,className:`relative ${B===ae?"opacity-50":""} ${U===ae&&B!==ae?"before:absolute before:left-0 before:right-0 before:top-0 before:h-0.5 before:bg-bambu-green":""}`,children:a.jsxs(Og,{to:$e,className:({isActive:ke})=>`flex items-center ${s||y?"gap-3 px-4":"justify-center px-2"} py-3 rounded-lg transition-colors group ${ke?"bg-bambu-green text-white":"text-bambu-gray-light hover:bg-bambu-dark-tertiary hover:text-white"}`,title:!s&&!y?i(pe):void 0,children:[y&&!s&&a.jsx(jh,{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(Re,{className:"w-5 h-5 flex-shrink-0"}),qe&&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"}),we&&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 ${Ne?"bg-blue-500 text-white":"bg-yellow-500 text-black"}`,children:xe>99?"99+":xe})]}),(s||y)&&a.jsx("span",{children:i(pe)})]})},ae)}})})}),!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(Yl,{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:[Se&&a.jsxs("div",{className:"relative",children:[a.jsx("button",{onMouseEnter:()=>j(!0),className:`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${C?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.smartSwitches",{defaultValue:"Smart Switches"}),children:a.jsx(gl,{className:"w-5 h-5"})}),C&&a.jsx(BB,{onClose:()=>j(!1)})]}),d("system:read")?a.jsx(Og,{to:"/system",className:({isActive:ae})=>`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${ae?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.system"),children:a.jsx(eo,{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(eo,{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(i3,{className:"w-5 h-5"})}),a.jsx("button",{onClick:()=>P(!0),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("nav.keyboardShortcuts"),children:a.jsx(s3,{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(zB,{className:"w-5 h-5"}):a.jsx(S1,{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(al,{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(l3,{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",te?.version||"..."]}),X?.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:X.latest_version}),children:[a.jsx(UM,{className:"w-4 h-4"}),a.jsx("span",{children:i("nav.update")})]})]})]}):a.jsxs("div",{className:"flex flex-col items-center gap-1",children:[X?.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:X.latest_version}),children:a.jsx(UM,{className:"w-5 h-5"})}),Se&&a.jsxs("div",{className:"relative",children:[a.jsx("button",{onMouseEnter:()=>j(!0),className:`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${C?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.smartSwitches",{defaultValue:"Smart Switches"}),children:a.jsx(gl,{className:"w-5 h-5"})}),C&&a.jsx(BB,{onClose:()=>j(!1)})]}),d("system:read")?a.jsx(Og,{to:"/system",className:({isActive:ae})=>`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${ae?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.system"),children:a.jsx(eo,{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(eo,{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(i3,{className:"w-5 h-5"})}),a.jsx("button",{onClick:()=>P(!0),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("nav.keyboardShortcuts"),children:a.jsx(s3,{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(zB,{className:"w-5 h-5"}):a.jsx(S1,{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(al,{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(l3,{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:[oe?.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(BC,{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"}),K!==null&&a.jsxs("span",{className:"text-amber-300/70 ml-2",children:["(",Math.floor(K/60),"m ",K%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"})})]})}),ie&&ie.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(wpe,{className:"w-4 h-4 text-orange-500"}),a.jsx("span",{className:"text-orange-200",children:i("printers.developerModeWarning",{names:ie.map(ae=>ae.name).join(", "),defaultValue:`Developer LAN mode is not enabled on: ${ie.map(ae=>ae.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"})})]})}),G&&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(UM,{className:"w-4 h-4 text-bambu-green"}),a.jsx("span",{children:i("nav.updateAvailableBanner",{version:X?.latest_version,defaultValue:`Version ${X?.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:de,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:i("common.dismiss",{defaultValue:"Dismiss"}),children:a.jsx(Rt,{className:"w-4 h-4"})})]}),a.jsx(KK,{})]}),k&&a.jsx(kge,{onClose:()=>P(!1),sidebarItems:ue.map(ae=>{if(HM(ae)){const Ue=re.get(ae);return Ue?{type:"external",label:Ue.name}:null}else{const Ue=Y.get(ae);return Ue?{type:"nav",label:Ue.labelKey,labelKey:Ue.labelKey}:null}}).filter(Boolean)}),W&&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:W.printer_name}),a.jsx("p",{className:"text-bambu-gray mb-6",children:i("plateAlert.message")}),a.jsx("button",{onClick:()=>Q(null),className:"w-full py-3 px-6 bg-yellow-500 hover:bg-yellow-600 text-black font-semibold rounded-lg transition-colors",children:i("plateAlert.understand")})]})})}),h&&a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:()=>{f(!1),x({currentPassword:"",newPassword:"",confirmPassword:""})},children:a.jsxs(St,{className:"w-full max-w-md",onClick:ae=>ae.stopPropagation(),children:[a.jsx(On,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(al,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:i("changePassword.title")})]}),a.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>{f(!1),x({currentPassword:"",newPassword:"",confirmPassword:""})},children:a.jsx(Rt,{className:"w-5 h-5"})})]})}),a.jsxs(Nt,{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:ae=>x({...p,currentPassword:ae.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:ae=>x({...p,newPassword:ae.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:ae=>x({...p,confirmPassword:ae.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(Me,{variant:"secondary",onClick:()=>{f(!1),x({currentPassword:"",newPassword:"",confirmPassword:""})},children:i("common.cancel")}),a.jsx(Me,{onClick:async()=>{if(p.newPassword!==p.confirmPassword){u(i("changePassword.passwordsDoNotMatch"),"error");return}if(p.newPassword.length<6){u(i("changePassword.passwordTooShort"),"error");return}g(!0);try{await J.changePassword(p.currentPassword,p.newPassword),u(i("changePassword.success"),"success"),f(!1),x({currentPassword:"",newPassword:"",confirmPassword:""})}catch(ae){const Ue=ae instanceof Error?ae.message:i("changePassword.failed");u(Ue,"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(at,{className:"w-4 h-4 animate-spin"}),i("changePassword.changing")]}):a.jsxs(a.Fragment,{children:[a.jsx(al,{className:"w-4 h-4"}),i("changePassword.title")]})})]})]})]})})]})}const LF="181",Yg={ROTATE:0,DOLLY:1,PAN:2},Ig={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},Hge=0,qB=1,$ge=2,IX=1,Vge=2,Md=3,Wh=0,ro=1,Nc=2,qd=0,Qg=1,GB=2,WB=3,KB=4,qge=5,Wm=100,Gge=101,Wge=102,Kge=103,Xge=104,Yge=200,Qge=201,Zge=202,Jge=203,f3=204,p3=205,ebe=206,tbe=207,nbe=208,rbe=209,abe=210,ibe=211,sbe=212,obe=213,lbe=214,g3=0,b3=1,x3=2,fb=3,y3=4,v3=5,w3=6,S3=7,OF=0,cbe=1,dbe=2,Rh=0,ube=1,hbe=2,mbe=3,fbe=4,pbe=5,gbe=6,bbe=7,zX=300,pb=301,gb=302,_3=303,N3=304,nk=306,C3=1e3,Id=1001,k3=1002,Eo=1003,xbe=1004,rS=1005,fl=1006,$M=1007,tf=1008,Oc=1009,UX=1010,BX=1011,x0=1012,IF=1013,Rf=1014,zd=1015,Gb=1016,zF=1017,UF=1018,y0=1020,HX=35902,$X=35899,VX=1021,qX=1022,Gl=1023,v0=1026,w0=1027,GX=1028,BF=1029,HF=1030,$F=1031,VF=1033,H_=33776,$_=33777,V_=33778,q_=33779,A3=35840,T3=35841,M3=35842,P3=35843,E3=36196,j3=37492,D3=37496,R3=37808,F3=37809,L3=37810,O3=37811,I3=37812,z3=37813,U3=37814,B3=37815,H3=37816,$3=37817,V3=37818,q3=37819,G3=37820,W3=37821,K3=36492,X3=36494,Y3=36495,Q3=36283,Z3=36284,J3=36285,eD=36286,ybe=3200,vbe=3201,WX=0,wbe=1,ph="",ko="srgb",bb="srgb-linear",k1="linear",zr="srgb",Bp=7680,XB=519,Sbe=512,_be=513,Nbe=514,KX=515,Cbe=516,kbe=517,Abe=518,Tbe=519,YB=35044,QB="300 es",Ac=2e3,A1=2001;function XX(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function T1(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function Mbe(){const t=T1("canvas");return t.style.display="block",t}const ZB={};function JB(...t){const e="THREE."+t.shift();console.log(e,...t)}function Sn(...t){const e="THREE."+t.shift();console.warn(e,...t)}function $a(...t){const e="THREE."+t.shift();console.error(e,...t)}function S0(...t){const e=t.join(" ");e in ZB||(ZB[e]=!0,Sn(...t))}function Pbe(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 tp=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"],G_=Math.PI/180,tD=180/Math.PI;function hv(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(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 Yn(t,e,n){return Math.max(e,Math.min(n,t))}function Ebe(t,e){return(t%e+e)%e}function VM(t,e,n){return(1-n)*t+n*e}function ey(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 Ks(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 jbe={DEG2RAD:G_};let In=class YX{constructor(e=0,n=0){YX.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=Yn(this.x,e.x,n.x),this.y=Yn(this.y,e.y,n.y),this}clampScalar(e,n){return this.x=Yn(this.x,e,n),this.y=Yn(this.y,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Yn(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(Yn(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}},Ff=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],d=r[i+1],u=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]=d,e[n+2]=u,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||d!==p||u!==x){let g=c*f+d*p+u*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,d=d*y+p*l,u=u*y+x*l,h=h*y+v*l}else{c=c*y+f*l,d=d*y+p*l,u=u*y+x*l,h=h*y+v*l;const _=1/Math.sqrt(c*c+d*d+u*u+h*h);c*=_,d*=_,u*=_,h*=_}}e[n]=c,e[n+1]=d,e[n+2]=u,e[n+3]=h}static multiplyQuaternionsFlat(e,n,r,i,s,o){const l=r[i],c=r[i+1],d=r[i+2],u=r[i+3],h=s[o],f=s[o+1],p=s[o+2],x=s[o+3];return e[n]=l*x+u*h+c*p-d*f,e[n+1]=c*x+u*f+d*h-l*p,e[n+2]=d*x+u*p+l*f-c*h,e[n+3]=u*x-l*h-c*f-d*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,d=l(r/2),u=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*u*h+d*p*x,this._y=d*p*h-f*u*x,this._z=d*u*x+f*p*h,this._w=d*u*h-f*p*x;break;case"YXZ":this._x=f*u*h+d*p*x,this._y=d*p*h-f*u*x,this._z=d*u*x-f*p*h,this._w=d*u*h+f*p*x;break;case"ZXY":this._x=f*u*h-d*p*x,this._y=d*p*h+f*u*x,this._z=d*u*x+f*p*h,this._w=d*u*h-f*p*x;break;case"ZYX":this._x=f*u*h-d*p*x,this._y=d*p*h+f*u*x,this._z=d*u*x-f*p*h,this._w=d*u*h+f*p*x;break;case"YZX":this._x=f*u*h+d*p*x,this._y=d*p*h+f*u*x,this._z=d*u*x-f*p*h,this._w=d*u*h-f*p*x;break;case"XZY":this._x=f*u*h-d*p*x,this._y=d*p*h-f*u*x,this._z=d*u*x+f*p*h,this._w=d*u*h+f*p*x;break;default:Sn("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],d=n[2],u=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=(u-c)*p,this._y=(s-d)*p,this._z=(o-i)*p}else if(r>l&&r>h){const p=2*Math.sqrt(1+r-l-h);this._w=(u-c)/p,this._x=.25*p,this._y=(i+o)/p,this._z=(s+d)/p}else if(l>h){const p=2*Math.sqrt(1+l-r-h);this._w=(s-d)/p,this._x=(i+o)/p,this._y=.25*p,this._z=(c+u)/p}else{const p=2*Math.sqrt(1+h-r-l);this._w=(o-i)/p,this._x=(s+d)/p,this._y=(c+u)/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(Yn(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,d=n._z,u=n._w;return this._x=r*u+o*l+i*d-s*c,this._y=i*u+o*c+s*l-r*d,this._z=s*u+o*d+r*c-i*l,this._w=o*u-r*l-i*c-s*d,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 d=Math.acos(l),u=Math.sin(d);c=Math.sin(c*d)/u,n=Math.sin(n*d)/u,this._x=this._x*c+r*n,this._y=this._y*c+i*n,this._z=this._z*c+s*n,this._w=this._w*c+o*n,this._onChangeCallback()}else this._x=this._x*c+r*n,this._y=this._y*c+i*n,this._z=this._z*c+s*n,this._w=this._w*c+o*n,this.normalize();return this}slerpQuaternions(e,n,r){return this.copy(e).slerp(n,r)}random(){const e=2*Math.PI*Math.random(),n=2*Math.PI*Math.random(),r=Math.random(),i=Math.sqrt(1-r),s=Math.sqrt(r);return this.set(i*Math.sin(e),i*Math.cos(e),s*Math.sin(n),s*Math.cos(n))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,n=0){return this._x=e[n],this._y=e[n+1],this._z=e[n+2],this._w=e[n+3],this._onChangeCallback(),this}toArray(e=[],n=0){return e[n]=this._x,e[n+1]=this._y,e[n+2]=this._z,e[n+3]=this._w,e}fromBufferAttribute(e,n){return this._x=e.getX(n),this._y=e.getY(n),this._z=e.getZ(n),this._w=e.getW(n),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},pt=class QX{constructor(e=0,n=0,r=0){QX.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(e8.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(e8.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,d=2*(o*i-l*r),u=2*(l*n-s*i),h=2*(s*r-o*n);return this.x=n+c*d+o*h-l*u,this.y=r+c*u+l*d-s*h,this.z=i+c*h+s*u-o*d,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=Yn(this.x,e.x,n.x),this.y=Yn(this.y,e.y,n.y),this.z=Yn(this.z,e.z,n.z),this}clampScalar(e,n){return this.x=Yn(this.x,e,n),this.y=Yn(this.y,e,n),this.z=Yn(this.z,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Yn(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 qM.copy(this).projectOnVector(e),this.sub(qM)}reflect(e){return this.sub(qM.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(Yn(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 qM=new pt,e8=new Ff;let Bn=class ZX{constructor(e,n,r,i,s,o,l,c,d){ZX.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,d)}set(e,n,r,i,s,o,l,c,d){const u=this.elements;return u[0]=e,u[1]=i,u[2]=l,u[3]=n,u[4]=s,u[5]=c,u[6]=r,u[7]=o,u[8]=d,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],d=r[1],u=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],k=i[2],P=i[5],C=i[8];return s[0]=o*v+l*_+c*k,s[3]=o*g+l*N+c*P,s[6]=o*y+l*A+c*C,s[1]=d*v+u*_+h*k,s[4]=d*g+u*N+h*P,s[7]=d*y+u*A+h*C,s[2]=f*v+p*_+x*k,s[5]=f*g+p*N+x*P,s[8]=f*y+p*A+x*C,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[3]*=e,n[6]*=e,n[1]*=e,n[4]*=e,n[7]*=e,n[2]*=e,n[5]*=e,n[8]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[1],i=e[2],s=e[3],o=e[4],l=e[5],c=e[6],d=e[7],u=e[8];return n*o*u-n*l*d-r*s*u+r*l*c+i*s*d-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],d=e[7],u=e[8],h=u*o-l*d,f=l*c-u*s,p=d*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*d-u*r)*v,e[2]=(l*r-i*o)*v,e[3]=f*v,e[4]=(u*n-i*c)*v,e[5]=(i*s-l*n)*v,e[6]=p*v,e[7]=(r*c-d*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),d=Math.sin(s);return this.set(r*c,r*d,-r*(c*o+d*l)+o+e,-i*d,i*c,-i*(-d*o+c*l)+l+n,0,0,1),this}scale(e,n){return this.premultiply(GM.makeScale(e,n)),this}rotate(e){return this.premultiply(GM.makeRotation(-e)),this}translate(e,n){return this.premultiply(GM.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 GM=new Bn,t8=new Bn().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),n8=new Bn().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Dbe(){const t={enabled:!0,workingColorSpace:bb,spaces:{},convert:function(i,s,o){return this.enabled===!1||s===o||!s||!o||(this.spaces[s].transfer===zr&&(i.r=Gd(i.r),i.g=Gd(i.g),i.b=Gd(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===zr&&(i.r=Zg(i.r),i.g=Zg(i.g),i.b=Zg(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===ph?k1: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 S0("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),t.workingToColorSpace(i,s)},toWorkingColorSpace:function(i,s){return S0("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({[bb]:{primaries:e,whitePoint:r,transfer:k1,toXYZ:t8,fromXYZ:n8,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:ko},outputColorSpaceConfig:{drawingBufferColorSpace:ko}},[ko]:{primaries:e,whitePoint:r,transfer:zr,toXYZ:t8,fromXYZ:n8,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:ko}}}),t}const fr=Dbe();function Gd(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function Zg(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let Hp,Rbe=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{Hp===void 0&&(Hp=T1("canvas")),Hp.width=e.width,Hp.height=e.height;const i=Hp.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),r=Hp}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=T1("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]=Gd(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(Gd(n[r]/255)*255):n[r]=Gd(n[r]);return{data:n,width:e.width,height:e.height}}else return Sn("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},Fbe=0,qF=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Fbe++}),this.uuid=hv(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const n=this.data;return typeof HTMLVideoElement<"u"&&n instanceof HTMLVideoElement?e.set(n.videoWidth,n.videoHeight,0):n instanceof VideoFrame?e.set(n.displayHeight,n.displayWidth,0):n!==null?e.set(n.width,n.height,n.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const n=e===void 0||typeof e=="string";if(!n&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const r={uuid:this.uuid,url:""},i=this.data;if(i!==null){let s;if(Array.isArray(i)){s=[];for(let o=0,l=i.length;o<l;o++)i[o].isDataTexture?s.push(WM(i[o].image)):s.push(WM(i[o]))}else s=WM(i);r.url=s}return n||(e.images[this.uuid]=r),r}};function WM(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?Rbe.getDataURL(t):t.data?{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(Sn("Texture: Unable to serialize Texture."),{})}let Lbe=0;const KM=new pt;let ic=class W_ extends tp{constructor(e=W_.DEFAULT_IMAGE,n=W_.DEFAULT_MAPPING,r=Id,i=Id,s=fl,o=tf,l=Gl,c=Oc,d=W_.DEFAULT_ANISOTROPY,u=ph){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Lbe++}),this.uuid=hv(),this.name="",this.source=new qF(e),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=s,this.minFilter=o,this.anisotropy=d,this.format=l,this.internalFormat=null,this.type=c,this.offset=new In(0,0),this.repeat=new In(1,1),this.center=new In(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Bn,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=u,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(KM).x}get height(){return this.source.getSize(KM).y}get depth(){return this.source.getSize(KM).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){Sn(`Texture.setValues(): parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){Sn(`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!==zX)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case C3:e.x=e.x-Math.floor(e.x);break;case Id:e.x=e.x<0?0:1;break;case k3: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 C3:e.y=e.y-Math.floor(e.y);break;case Id:e.y=e.y<0?0:1;break;case k3: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++}};ic.DEFAULT_IMAGE=null;ic.DEFAULT_MAPPING=zX;ic.DEFAULT_ANISOTROPY=1;let Ja=class JX{constructor(e=0,n=0,r=0,i=1){JX.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,d=c[0],u=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(u-f)<.01&&Math.abs(h-v)<.01&&Math.abs(x-g)<.01){if(Math.abs(u+f)<.1&&Math.abs(h+v)<.1&&Math.abs(x+g)<.1&&Math.abs(d+p+y-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const N=(d+1)/2,A=(p+1)/2,k=(y+1)/2,P=(u+f)/4,C=(h+v)/4,j=(x+g)/4;return N>A&&N>k?N<.01?(r=0,i=.707106781,s=.707106781):(r=Math.sqrt(N),i=P/r,s=C/r):A>k?A<.01?(r=.707106781,i=0,s=.707106781):(i=Math.sqrt(A),r=P/i,s=j/i):k<.01?(r=.707106781,i=.707106781,s=0):(s=Math.sqrt(k),r=C/s,i=j/s),this.set(r,i,s,n),this}let _=Math.sqrt((g-x)*(g-x)+(h-v)*(h-v)+(f-u)*(f-u));return Math.abs(_)<.001&&(_=1),this.x=(g-x)/_,this.y=(h-v)/_,this.z=(f-u)/_,this.w=Math.acos((d+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=Yn(this.x,e.x,n.x),this.y=Yn(this.y,e.y,n.y),this.z=Yn(this.z,e.z,n.z),this.w=Yn(this.w,e.w,n.w),this}clampScalar(e,n){return this.x=Yn(this.x,e,n),this.y=Yn(this.y,e,n),this.z=Yn(this.z,e,n),this.w=Yn(this.w,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Yn(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}},Obe=class extends tp{constructor(e=1,n=1,r={}){super(),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:fl,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 Ja(0,0,e,n),this.scissorTest=!1,this.viewport=new Ja(0,0,e,n);const i={width:e,height:n,depth:r.depth},s=new ic(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:fl,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 qF(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"})}},Lf=class extends Obe{constructor(e=1,n=1,r={}){super(e,n,r),this.isWebGLRenderTarget=!0}},eY=class extends ic{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=Id,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},Ibe=class extends ic{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=Id,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},Fh=class{constructor(e=new pt(1/0,1/0,1/0),n=new pt(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=n}set(e,n){return this.min.copy(e),this.max.copy(n),this}setFromArray(e){this.makeEmpty();for(let n=0,r=e.length;n<r;n+=3)this.expandByPoint(Rl.fromArray(e,n));return this}setFromBufferAttribute(e){this.makeEmpty();for(let n=0,r=e.count;n<r;n++)this.expandByPoint(Rl.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=Rl.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,Rl):Rl.fromBufferAttribute(s,o),Rl.applyMatrix4(e.matrixWorld),this.expandByPoint(Rl);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),aS.copy(e.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),aS.copy(r.boundingBox)),aS.applyMatrix4(e.matrixWorld),this.union(aS)}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,Rl),Rl.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(ty),iS.subVectors(this.max,ty),$p.subVectors(e.a,ty),Vp.subVectors(e.b,ty),qp.subVectors(e.c,ty),$u.subVectors(Vp,$p),Vu.subVectors(qp,Vp),Am.subVectors($p,qp);let n=[0,-$u.z,$u.y,0,-Vu.z,Vu.y,0,-Am.z,Am.y,$u.z,0,-$u.x,Vu.z,0,-Vu.x,Am.z,0,-Am.x,-$u.y,$u.x,0,-Vu.y,Vu.x,0,-Am.y,Am.x,0];return!XM(n,$p,Vp,qp,iS)||(n=[1,0,0,0,1,0,0,0,1],!XM(n,$p,Vp,qp,iS))?!1:(sS.crossVectors($u,Vu),n=[sS.x,sS.y,sS.z],XM(n,$p,Vp,qp,iS))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Rl).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Rl).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:(md[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),md[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),md[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),md[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),md[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),md[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),md[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),md[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(md),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 md=[new pt,new pt,new pt,new pt,new pt,new pt,new pt,new pt],Rl=new pt,aS=new Fh,$p=new pt,Vp=new pt,qp=new pt,$u=new pt,Vu=new pt,Am=new pt,ty=new pt,iS=new pt,sS=new pt,Tm=new pt;function XM(t,e,n,r,i){for(let s=0,o=t.length-3;s<=o;s+=3){Tm.fromArray(t,s);const l=i.x*Math.abs(Tm.x)+i.y*Math.abs(Tm.y)+i.z*Math.abs(Tm.z),c=e.dot(Tm),d=n.dot(Tm),u=r.dot(Tm);if(Math.max(-Math.max(c,d,u),Math.min(c,d,u))>l)return!1}return!0}const zbe=new Fh,ny=new pt,YM=new pt;let rk=class{constructor(e=new pt,n=-1){this.isSphere=!0,this.center=e,this.radius=n}set(e,n){return this.center.copy(e),this.radius=n,this}setFromPoints(e,n){const r=this.center;n!==void 0?r.copy(n):zbe.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;ny.subVectors(e,this.center);const n=ny.lengthSq();if(n>this.radius*this.radius){const r=Math.sqrt(n),i=(r-this.radius)*.5;this.center.addScaledVector(ny,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):(YM.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(ny.copy(e.center).add(YM)),this.expandByPoint(ny.copy(e.center).sub(YM))),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 fd=new pt,QM=new pt,oS=new pt,qu=new pt,ZM=new pt,lS=new pt,JM=new pt;let GF=class{constructor(e=new pt,n=new pt(0,0,-1)){this.origin=e,this.direction=n}set(e,n){return this.origin.copy(e),this.direction.copy(n),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,n){return n.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,fd)),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=fd.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(fd.copy(this.origin).addScaledVector(this.direction,n),fd.distanceToSquared(e))}distanceSqToSegment(e,n,r,i){QM.copy(e).add(n).multiplyScalar(.5),oS.copy(n).sub(e).normalize(),qu.copy(this.origin).sub(QM);const s=e.distanceTo(n)*.5,o=-this.direction.dot(oS),l=qu.dot(this.direction),c=-qu.dot(oS),d=qu.lengthSq(),u=Math.abs(1-o*o);let h,f,p,x;if(u>0)if(h=o*c-l,f=o*l-c,x=s*u,h>=0)if(f>=-x)if(f<=x){const v=1/u;h*=v,f*=v,p=h*(h+o*f+2*l)+f*(o*h+f+2*c)+d}else f=s,h=Math.max(0,-(o*f+l)),p=-h*h+f*(f+2*c)+d;else f=-s,h=Math.max(0,-(o*f+l)),p=-h*h+f*(f+2*c)+d;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)+d):f<=x?(h=0,f=Math.min(Math.max(-s,-c),s),p=f*(f+2*c)+d):(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)+d);else f=o>0?-s:s,h=Math.max(0,-(o*f+l)),p=-h*h+f*(f+2*c)+d;return r&&r.copy(this.origin).addScaledVector(this.direction,h),i&&i.copy(QM).addScaledVector(oS,f),p}intersectSphere(e,n){fd.subVectors(e.center,this.origin);const r=fd.dot(this.direction),i=fd.dot(fd)-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 d=1/this.direction.x,u=1/this.direction.y,h=1/this.direction.z,f=this.origin;return d>=0?(r=(e.min.x-f.x)*d,i=(e.max.x-f.x)*d):(r=(e.max.x-f.x)*d,i=(e.min.x-f.x)*d),u>=0?(s=(e.min.y-f.y)*u,o=(e.max.y-f.y)*u):(s=(e.max.y-f.y)*u,o=(e.min.y-f.y)*u),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,fd)!==null}intersectTriangle(e,n,r,i,s){ZM.subVectors(n,e),lS.subVectors(r,e),JM.crossVectors(ZM,lS);let o=this.direction.dot(JM),l;if(o>0){if(i)return null;l=1}else if(o<0)l=-1,o=-o;else return null;qu.subVectors(this.origin,e);const c=l*this.direction.dot(lS.crossVectors(qu,lS));if(c<0)return null;const d=l*this.direction.dot(ZM.cross(qu));if(d<0||c+d>o)return null;const u=-l*qu.dot(JM);return u<0?null:this.at(u/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)}},ai=class nD{constructor(e,n,r,i,s,o,l,c,d,u,h,f,p,x,v,g){nD.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,d,u,h,f,p,x,v,g)}set(e,n,r,i,s,o,l,c,d,u,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]=d,y[6]=u,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 nD().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/Gp.setFromMatrixColumn(e,0).length(),s=1/Gp.setFromMatrixColumn(e,1).length(),o=1/Gp.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),d=Math.sin(i),u=Math.cos(s),h=Math.sin(s);if(e.order==="XYZ"){const f=o*u,p=o*h,x=l*u,v=l*h;n[0]=c*u,n[4]=-c*h,n[8]=d,n[1]=p+x*d,n[5]=f-v*d,n[9]=-l*c,n[2]=v-f*d,n[6]=x+p*d,n[10]=o*c}else if(e.order==="YXZ"){const f=c*u,p=c*h,x=d*u,v=d*h;n[0]=f+v*l,n[4]=x*l-p,n[8]=o*d,n[1]=o*h,n[5]=o*u,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*u,p=c*h,x=d*u,v=d*h;n[0]=f-v*l,n[4]=-o*h,n[8]=x+p*l,n[1]=p+x*l,n[5]=o*u,n[9]=v-f*l,n[2]=-o*d,n[6]=l,n[10]=o*c}else if(e.order==="ZYX"){const f=o*u,p=o*h,x=l*u,v=l*h;n[0]=c*u,n[4]=x*d-p,n[8]=f*d+v,n[1]=c*h,n[5]=v*d+f,n[9]=p*d-x,n[2]=-d,n[6]=l*c,n[10]=o*c}else if(e.order==="YZX"){const f=o*c,p=o*d,x=l*c,v=l*d;n[0]=c*u,n[4]=v-f*h,n[8]=x*h+p,n[1]=h,n[5]=o*u,n[9]=-l*u,n[2]=-d*u,n[6]=p*h+x,n[10]=f-v*h}else if(e.order==="XZY"){const f=o*c,p=o*d,x=l*c,v=l*d;n[0]=c*u,n[4]=-h,n[8]=d*u,n[1]=f*h+v,n[5]=o*u,n[9]=p*h-x,n[2]=x*h-p,n[6]=l*u,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(Ube,e,Bbe)}lookAt(e,n,r){const i=this.elements;return So.subVectors(e,n),So.lengthSq()===0&&(So.z=1),So.normalize(),Gu.crossVectors(r,So),Gu.lengthSq()===0&&(Math.abs(r.z)===1?So.x+=1e-4:So.z+=1e-4,So.normalize(),Gu.crossVectors(r,So)),Gu.normalize(),cS.crossVectors(So,Gu),i[0]=Gu.x,i[4]=cS.x,i[8]=So.x,i[1]=Gu.y,i[5]=cS.y,i[9]=So.y,i[2]=Gu.z,i[6]=cS.z,i[10]=So.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],d=r[12],u=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],k=r[15],P=i[0],C=i[4],j=i[8],M=i[12],E=i[1],B=i[5],L=i[9],U=i[13],D=i[2],$=i[6],q=i[10],z=i[14],W=i[3],Q=i[7],te=i[11],H=i[15];return s[0]=o*P+l*E+c*D+d*W,s[4]=o*C+l*B+c*$+d*Q,s[8]=o*j+l*L+c*q+d*te,s[12]=o*M+l*U+c*z+d*H,s[1]=u*P+h*E+f*D+p*W,s[5]=u*C+h*B+f*$+p*Q,s[9]=u*j+h*L+f*q+p*te,s[13]=u*M+h*U+f*z+p*H,s[2]=x*P+v*E+g*D+y*W,s[6]=x*C+v*B+g*$+y*Q,s[10]=x*j+v*L+g*q+y*te,s[14]=x*M+v*U+g*z+y*H,s[3]=_*P+N*E+A*D+k*W,s[7]=_*C+N*B+A*$+k*Q,s[11]=_*j+N*L+A*q+k*te,s[15]=_*M+N*U+A*z+k*H,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[4]*=e,n[8]*=e,n[12]*=e,n[1]*=e,n[5]*=e,n[9]*=e,n[13]*=e,n[2]*=e,n[6]*=e,n[10]*=e,n[14]*=e,n[3]*=e,n[7]*=e,n[11]*=e,n[15]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[4],i=e[8],s=e[12],o=e[1],l=e[5],c=e[9],d=e[13],u=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*d*h-s*l*f+r*d*f+i*l*p-r*c*p)+v*(+n*c*p-n*d*f+s*o*f-i*o*p+i*d*u-s*c*u)+g*(+n*d*h-n*l*p-s*o*h+r*o*p+s*l*u-r*d*u)+y*(-i*l*u-n*c*h+n*l*f+i*o*h-r*o*f+r*c*u)}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],d=e[7],u=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*d-v*f*d+v*c*p-l*g*p-h*c*y+l*f*y,N=x*f*d-u*g*d-x*c*p+o*g*p+u*c*y-o*f*y,A=u*v*d-x*h*d+x*l*p-o*v*p-u*l*y+o*h*y,k=x*h*c-u*v*c-x*l*f+o*v*f+u*l*g-o*h*g,P=n*_+r*N+i*A+s*k;if(P===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const C=1/P;return e[0]=_*C,e[1]=(v*f*s-h*g*s-v*i*p+r*g*p+h*i*y-r*f*y)*C,e[2]=(l*g*s-v*c*s+v*i*d-r*g*d-l*i*y+r*c*y)*C,e[3]=(h*c*s-l*f*s-h*i*d+r*f*d+l*i*p-r*c*p)*C,e[4]=N*C,e[5]=(u*g*s-x*f*s+x*i*p-n*g*p-u*i*y+n*f*y)*C,e[6]=(x*c*s-o*g*s-x*i*d+n*g*d+o*i*y-n*c*y)*C,e[7]=(o*f*s-u*c*s+u*i*d-n*f*d-o*i*p+n*c*p)*C,e[8]=A*C,e[9]=(x*h*s-u*v*s-x*r*p+n*v*p+u*r*y-n*h*y)*C,e[10]=(o*v*s-x*l*s+x*r*d-n*v*d-o*r*y+n*l*y)*C,e[11]=(u*l*s-o*h*s-u*r*d+n*h*d+o*r*p-n*l*p)*C,e[12]=k*C,e[13]=(u*v*i-x*h*i+x*r*f-n*v*f-u*r*g+n*h*g)*C,e[14]=(x*l*i-o*v*i-x*r*c+n*v*c+o*r*g-n*l*g)*C,e[15]=(o*h*i-u*l*i+u*r*c-n*h*c-o*r*f+n*l*f)*C,this}scale(e){const n=this.elements,r=e.x,i=e.y,s=e.z;return n[0]*=r,n[4]*=i,n[8]*=s,n[1]*=r,n[5]*=i,n[9]*=s,n[2]*=r,n[6]*=i,n[10]*=s,n[3]*=r,n[7]*=i,n[11]*=s,this}getMaxScaleOnAxis(){const e=this.elements,n=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],r=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(n,r,i))}makeTranslation(e,n,r){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,n,0,0,1,r,0,0,0,1),this}makeRotationX(e){const n=Math.cos(e),r=Math.sin(e);return this.set(1,0,0,0,0,n,-r,0,0,r,n,0,0,0,0,1),this}makeRotationY(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,0,r,0,0,1,0,0,-r,0,n,0,0,0,0,1),this}makeRotationZ(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,-r,0,0,r,n,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,n){const r=Math.cos(n),i=Math.sin(n),s=1-r,o=e.x,l=e.y,c=e.z,d=s*o,u=s*l;return this.set(d*o+r,d*l-i*c,d*c+i*l,0,d*l+i*c,u*l+r,u*c-i*o,0,d*c-i*l,u*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,d=s+s,u=o+o,h=l+l,f=s*d,p=s*u,x=s*h,v=o*u,g=o*h,y=l*h,_=c*d,N=c*u,A=c*h,k=r.x,P=r.y,C=r.z;return i[0]=(1-(v+y))*k,i[1]=(p+A)*k,i[2]=(x-N)*k,i[3]=0,i[4]=(p-A)*P,i[5]=(1-(f+y))*P,i[6]=(g+_)*P,i[7]=0,i[8]=(x+N)*C,i[9]=(g-_)*C,i[10]=(1-(f+v))*C,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,n,r){const i=this.elements;let s=Gp.set(i[0],i[1],i[2]).length();const o=Gp.set(i[4],i[5],i[6]).length(),l=Gp.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],Fl.copy(this);const d=1/s,u=1/o,h=1/l;return Fl.elements[0]*=d,Fl.elements[1]*=d,Fl.elements[2]*=d,Fl.elements[4]*=u,Fl.elements[5]*=u,Fl.elements[6]*=u,Fl.elements[8]*=h,Fl.elements[9]*=h,Fl.elements[10]*=h,n.setFromRotationMatrix(Fl),r.x=s,r.y=o,r.z=l,this}makePerspective(e,n,r,i,s,o,l=Ac,c=!1){const d=this.elements,u=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===Ac)x=-(o+s)/(o-s),v=-2*o*s/(o-s);else if(l===A1)x=-o/(o-s),v=-o*s/(o-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+l);return d[0]=u,d[4]=0,d[8]=f,d[12]=0,d[1]=0,d[5]=h,d[9]=p,d[13]=0,d[2]=0,d[6]=0,d[10]=x,d[14]=v,d[3]=0,d[7]=0,d[11]=-1,d[15]=0,this}makeOrthographic(e,n,r,i,s,o,l=Ac,c=!1){const d=this.elements,u=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===Ac)x=-2/(o-s),v=-(o+s)/(o-s);else if(l===A1)x=-1/(o-s),v=-s/(o-s);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+l);return d[0]=u,d[4]=0,d[8]=0,d[12]=f,d[1]=0,d[5]=h,d[9]=0,d[13]=p,d[2]=0,d[6]=0,d[10]=x,d[14]=v,d[3]=0,d[7]=0,d[11]=0,d[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 Gp=new pt,Fl=new ai,Ube=new pt(0,0,0),Bbe=new pt(1,1,1),Gu=new pt,cS=new pt,So=new pt,r8=new ai,a8=new Ff;let Kh=class tY{constructor(e=0,n=0,r=0,i=tY.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],d=i[5],u=i[9],h=i[2],f=i[6],p=i[10];switch(n){case"XYZ":this._y=Math.asin(Yn(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-u,p),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(f,d),this._z=0);break;case"YXZ":this._x=Math.asin(-Yn(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(l,p),this._z=Math.atan2(c,d)):(this._y=Math.atan2(-h,s),this._z=0);break;case"ZXY":this._x=Math.asin(Yn(f,-1,1)),Math.abs(f)<.9999999?(this._y=Math.atan2(-h,p),this._z=Math.atan2(-o,d)):(this._y=0,this._z=Math.atan2(c,s));break;case"ZYX":this._y=Math.asin(-Yn(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,d));break;case"YZX":this._z=Math.asin(Yn(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-u,d),this._y=Math.atan2(-h,s)):(this._x=0,this._y=Math.atan2(l,p));break;case"XZY":this._z=Math.asin(-Yn(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(f,d),this._y=Math.atan2(l,s)):(this._x=Math.atan2(-u,p),this._y=0);break;default:Sn("Euler: .setFromRotationMatrix() encountered an unknown order: "+n)}return this._order=n,r===!0&&this._onChangeCallback(),this}setFromQuaternion(e,n,r){return r8.makeRotationFromQuaternion(e),this.setFromRotationMatrix(r8,n,r)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return a8.setFromEuler(this),this.setFromQuaternion(a8,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],n=0){return e[n]=this._x,e[n+1]=this._y,e[n+2]=this._z,e[n+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};Kh.DEFAULT_ORDER="XYZ";let nY=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}},Hbe=0;const i8=new pt,Wp=new Ff,pd=new ai,dS=new pt,ry=new pt,$be=new pt,Vbe=new Ff,s8=new pt(1,0,0),o8=new pt(0,1,0),l8=new pt(0,0,1),c8={type:"added"},qbe={type:"removed"},Kp={type:"childadded",child:null},eP={type:"childremoved",child:null};let Lo=class K_ extends tp{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Hbe++}),this.uuid=hv(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=K_.DEFAULT_UP.clone();const e=new pt,n=new Kh,r=new Ff,i=new pt(1,1,1);function s(){r.setFromEuler(n,!1)}function o(){n.setFromQuaternion(r,void 0,!1)}n._onChange(s),r._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:n},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new ai},normalMatrix:{value:new Bn}}),this.matrix=new ai,this.matrixWorld=new ai,this.matrixAutoUpdate=K_.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=K_.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new nY,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,n){this.quaternion.setFromAxisAngle(e,n)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,n){return Wp.setFromAxisAngle(e,n),this.quaternion.multiply(Wp),this}rotateOnWorldAxis(e,n){return Wp.setFromAxisAngle(e,n),this.quaternion.premultiply(Wp),this}rotateX(e){return this.rotateOnAxis(s8,e)}rotateY(e){return this.rotateOnAxis(o8,e)}rotateZ(e){return this.rotateOnAxis(l8,e)}translateOnAxis(e,n){return i8.copy(e).applyQuaternion(this.quaternion),this.position.add(i8.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(s8,e)}translateY(e){return this.translateOnAxis(o8,e)}translateZ(e){return this.translateOnAxis(l8,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(pd.copy(this.matrixWorld).invert())}lookAt(e,n,r){e.isVector3?dS.copy(e):dS.set(e,n,r);const i=this.parent;this.updateWorldMatrix(!0,!1),ry.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?pd.lookAt(ry,dS,this.up):pd.lookAt(dS,ry,this.up),this.quaternion.setFromRotationMatrix(pd),i&&(pd.extractRotation(i.matrixWorld),Wp.setFromRotationMatrix(pd),this.quaternion.premultiply(Wp.invert()))}add(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.add(arguments[n]);return this}return e===this?($a("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(c8),Kp.child=e,this.dispatchEvent(Kp),Kp.child=null):$a("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(qbe),eP.child=e,this.dispatchEvent(eP),eP.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),pd.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),pd.multiply(e.parent.matrixWorld)),e.applyMatrix4(pd),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(c8),Kp.child=e,this.dispatchEvent(Kp),Kp.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,n){if(this[e]===n)return this;for(let r=0,i=this.children.length;r<i;r++){const o=this.children[r].getObjectByProperty(e,n);if(o!==void 0)return o}}getObjectsByProperty(e,n,r=[]){this[e]===n&&r.push(this);const i=this.children;for(let 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(ry,e,$be),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(ry,Vbe,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 d=0,u=c.length;d<u;d++){const h=c[d];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,d=this.material.length;c<d;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),d=o(e.textures),u=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),d.length>0&&(r.textures=d),u.length>0&&(r.images=u),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 d in l){const u=l[d];delete u.metadata,c.push(u)}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}};Lo.DEFAULT_UP=new pt(0,1,0);Lo.DEFAULT_MATRIX_AUTO_UPDATE=!0;Lo.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Ll=new pt,gd=new pt,tP=new pt,bd=new pt,Xp=new pt,Yp=new pt,d8=new pt,nP=new pt,rP=new pt,aP=new pt,iP=new Ja,sP=new Ja,oP=new Ja;let ay=class jg{constructor(e=new pt,n=new pt,r=new pt){this.a=e,this.b=n,this.c=r}static getNormal(e,n,r,i){i.subVectors(r,n),Ll.subVectors(e,n),i.cross(Ll);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){Ll.subVectors(i,n),gd.subVectors(r,n),tP.subVectors(e,n);const o=Ll.dot(Ll),l=Ll.dot(gd),c=Ll.dot(tP),d=gd.dot(gd),u=gd.dot(tP),h=o*d-l*l;if(h===0)return s.set(0,0,0),null;const f=1/h,p=(d*c-l*u)*f,x=(o*u-l*c)*f;return s.set(1-p-x,x,p)}static containsPoint(e,n,r,i){return this.getBarycoord(e,n,r,i,bd)===null?!1:bd.x>=0&&bd.y>=0&&bd.x+bd.y<=1}static getInterpolation(e,n,r,i,s,o,l,c){return this.getBarycoord(e,n,r,i,bd)===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,bd.x),c.addScaledVector(o,bd.y),c.addScaledVector(l,bd.z),c)}static getInterpolatedAttribute(e,n,r,i,s,o){return iP.setScalar(0),sP.setScalar(0),oP.setScalar(0),iP.fromBufferAttribute(e,n),sP.fromBufferAttribute(e,r),oP.fromBufferAttribute(e,i),o.setScalar(0),o.addScaledVector(iP,s.x),o.addScaledVector(sP,s.y),o.addScaledVector(oP,s.z),o}static isFrontFacing(e,n,r,i){return Ll.subVectors(r,n),gd.subVectors(e,n),Ll.cross(gd).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 Ll.subVectors(this.c,this.b),gd.subVectors(this.a,this.b),Ll.cross(gd).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return jg.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return jg.getBarycoord(e,this.a,this.b,this.c,n)}getInterpolation(e,n,r,i,s){return jg.getInterpolation(e,this.a,this.b,this.c,n,r,i,s)}containsPoint(e){return jg.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return jg.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;Xp.subVectors(i,r),Yp.subVectors(s,r),nP.subVectors(e,r);const c=Xp.dot(nP),d=Yp.dot(nP);if(c<=0&&d<=0)return n.copy(r);rP.subVectors(e,i);const u=Xp.dot(rP),h=Yp.dot(rP);if(u>=0&&h<=u)return n.copy(i);const f=c*h-u*d;if(f<=0&&c>=0&&u<=0)return o=c/(c-u),n.copy(r).addScaledVector(Xp,o);aP.subVectors(e,s);const p=Xp.dot(aP),x=Yp.dot(aP);if(x>=0&&p<=x)return n.copy(s);const v=p*d-c*x;if(v<=0&&d>=0&&x<=0)return l=d/(d-x),n.copy(r).addScaledVector(Yp,l);const g=u*x-p*h;if(g<=0&&h-u>=0&&p-x>=0)return d8.subVectors(s,i),l=(h-u)/(h-u+(p-x)),n.copy(i).addScaledVector(d8,l);const y=1/(g+v+f);return o=v*y,l=f*y,n.copy(r).addScaledVector(Xp,o).addScaledVector(Yp,l)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}};const rY={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},Wu={h:0,s:0,l:0},uS={h:0,s:0,l:0};function lP(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 Hn=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=ko){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,fr.colorSpaceToWorking(this,n),this}setRGB(e,n,r,i=fr.workingColorSpace){return this.r=e,this.g=n,this.b=r,fr.colorSpaceToWorking(this,i),this}setHSL(e,n,r,i=fr.workingColorSpace){if(e=Ebe(e,1),n=Yn(n,0,1),r=Yn(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=lP(o,s,e+1/3),this.g=lP(o,s,e),this.b=lP(o,s,e-1/3)}return fr.colorSpaceToWorking(this,i),this}setStyle(e,n=ko){function r(s){s!==void 0&&parseFloat(s)<1&&Sn("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:Sn("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);Sn("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,n);return this}setColorName(e,n=ko){const r=rY[e.toLowerCase()];return r!==void 0?this.setHex(r,n):Sn("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=Gd(e.r),this.g=Gd(e.g),this.b=Gd(e.b),this}copyLinearToSRGB(e){return this.r=Zg(e.r),this.g=Zg(e.g),this.b=Zg(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=ko){return fr.workingToColorSpace(cs.copy(this),e),Math.round(Yn(cs.r*255,0,255))*65536+Math.round(Yn(cs.g*255,0,255))*256+Math.round(Yn(cs.b*255,0,255))}getHexString(e=ko){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=fr.workingColorSpace){fr.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,d;const u=(l+o)/2;if(l===o)c=0,d=0;else{const h=o-l;switch(d=u<=.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=d,e.l=u,e}getRGB(e,n=fr.workingColorSpace){return fr.workingToColorSpace(cs.copy(this),n),e.r=cs.r,e.g=cs.g,e.b=cs.b,e}getStyle(e=ko){fr.workingToColorSpace(cs.copy(this),e);const n=cs.r,r=cs.g,i=cs.b;return e!==ko?`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(Wu),this.setHSL(Wu.h+e,Wu.s+n,Wu.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(Wu),e.getHSL(uS);const r=VM(Wu.h,uS.h,n),i=VM(Wu.s,uS.s,n),s=VM(Wu.l,uS.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 Hn;Hn.NAMES=rY;let Gbe=0,Wb=class extends tp{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Gbe++}),this.uuid=hv(),this.name="",this.type="Material",this.blending=Qg,this.side=Wh,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=f3,this.blendDst=p3,this.blendEquation=Wm,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Hn(0,0,0),this.blendAlpha=0,this.depthFunc=fb,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=XB,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Bp,this.stencilZFail=Bp,this.stencilZPass=Bp,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.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){Sn(`Material: parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){Sn(`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!==Qg&&(r.blending=this.blending),this.side!==Wh&&(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!==f3&&(r.blendSrc=this.blendSrc),this.blendDst!==p3&&(r.blendDst=this.blendDst),this.blendEquation!==Wm&&(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!==fb&&(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!==XB&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Bp&&(r.stencilFail=this.stencilFail),this.stencilZFail!==Bp&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==Bp&&(r.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(r.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(r.rotation=this.rotation),this.polygonOffset===!0&&(r.polygonOffset=!0),this.polygonOffsetFactor!==0&&(r.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(r.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(r.linewidth=this.linewidth),this.dashSize!==void 0&&(r.dashSize=this.dashSize),this.gapSize!==void 0&&(r.gapSize=this.gapSize),this.scale!==void 0&&(r.scale=this.scale),this.dithering===!0&&(r.dithering=!0),this.alphaTest>0&&(r.alphaTest=this.alphaTest),this.alphaHash===!0&&(r.alphaHash=!0),this.alphaToCoverage===!0&&(r.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(r.premultipliedAlpha=!0),this.forceSinglePass===!0&&(r.forceSinglePass=!0),this.wireframe===!0&&(r.wireframe=!0),this.wireframeLinewidth>1&&(r.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(r.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(r.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(r.flatShading=!0),this.visible===!1&&(r.visible=!1),this.toneMapped===!1&&(r.toneMapped=!1),this.fog===!1&&(r.fog=!1),Object.keys(this.userData).length>0&&(r.userData=this.userData);function i(s){const o=[];for(const l in s){const c=s[l];delete c.metadata,o.push(c)}return o}if(n){const s=i(e.textures),o=i(e.images);s.length>0&&(r.textures=s),o.length>0&&(r.images=o)}return r}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const n=e.clippingPlanes;let r=null;if(n!==null){const i=n.length;r=new Array(i);for(let s=0;s!==i;++s)r[s]=n[s].clone()}return this.clippingPlanes=r,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}},WF=class extends Wb{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Hn(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Kh,this.combine=OF,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 Qa=new pt,hS=new In;let Wbe=0,Rs=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:Wbe++}),this.name="",this.array=e,this.itemSize=n,this.count=e!==void 0?e.length/n:0,this.normalized=r,this.usage=YB,this.updateRanges=[],this.gpuType=zd,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++)hS.fromBufferAttribute(this,n),hS.applyMatrix3(e),this.setXY(n,hS.x,hS.y);else if(this.itemSize===3)for(let n=0,r=this.count;n<r;n++)Qa.fromBufferAttribute(this,n),Qa.applyMatrix3(e),this.setXYZ(n,Qa.x,Qa.y,Qa.z);return this}applyMatrix4(e){for(let n=0,r=this.count;n<r;n++)Qa.fromBufferAttribute(this,n),Qa.applyMatrix4(e),this.setXYZ(n,Qa.x,Qa.y,Qa.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)Qa.fromBufferAttribute(this,n),Qa.applyNormalMatrix(e),this.setXYZ(n,Qa.x,Qa.y,Qa.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)Qa.fromBufferAttribute(this,n),Qa.transformDirection(e),this.setXYZ(n,Qa.x,Qa.y,Qa.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=ey(r,this.array)),r}setComponent(e,n,r){return this.normalized&&(r=Ks(r,this.array)),this.array[e*this.itemSize+n]=r,this}getX(e){let n=this.array[e*this.itemSize];return this.normalized&&(n=ey(n,this.array)),n}setX(e,n){return this.normalized&&(n=Ks(n,this.array)),this.array[e*this.itemSize]=n,this}getY(e){let n=this.array[e*this.itemSize+1];return this.normalized&&(n=ey(n,this.array)),n}setY(e,n){return this.normalized&&(n=Ks(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=ey(n,this.array)),n}setZ(e,n){return this.normalized&&(n=Ks(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=ey(n,this.array)),n}setW(e,n){return this.normalized&&(n=Ks(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,r){return e*=this.itemSize,this.normalized&&(n=Ks(n,this.array),r=Ks(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=Ks(n,this.array),r=Ks(r,this.array),i=Ks(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=Ks(n,this.array),r=Ks(r,this.array),i=Ks(i,this.array),s=Ks(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!==YB&&(e.usage=this.usage),e}},aY=class extends Rs{constructor(e,n,r){super(new Uint16Array(e),n,r)}},iY=class extends Rs{constructor(e,n,r){super(new Uint32Array(e),n,r)}},jo=class extends Rs{constructor(e,n,r){super(new Float32Array(e),n,r)}},Kbe=0;const Xo=new ai,cP=new Lo,Qp=new pt,_o=new Fh,iy=new Fh,Ai=new pt;let _l=class sY extends tp{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Kbe++}),this.uuid=hv(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(XX(e)?iY:aY)(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 Bn().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 cP.lookAt(e),cP.updateMatrix(),this.applyMatrix4(cP.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Qp).negate(),this.translate(Qp.x,Qp.y,Qp.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 jo(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&&Sn("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),n.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Fh);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){$a("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new pt(-1/0,-1/0,-1/0),new pt(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),n)for(let r=0,i=n.length;r<i;r++){const s=n[r];_o.setFromBufferAttribute(s),this.morphTargetsRelative?(Ai.addVectors(this.boundingBox.min,_o.min),this.boundingBox.expandByPoint(Ai),Ai.addVectors(this.boundingBox.max,_o.max),this.boundingBox.expandByPoint(Ai)):(this.boundingBox.expandByPoint(_o.min),this.boundingBox.expandByPoint(_o.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&$a('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 rk);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){$a("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new pt,1/0);return}if(e){const r=this.boundingSphere.center;if(_o.setFromBufferAttribute(e),n)for(let s=0,o=n.length;s<o;s++){const l=n[s];iy.setFromBufferAttribute(l),this.morphTargetsRelative?(Ai.addVectors(_o.min,iy.min),_o.expandByPoint(Ai),Ai.addVectors(_o.max,iy.max),_o.expandByPoint(Ai)):(_o.expandByPoint(iy.min),_o.expandByPoint(iy.max))}_o.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 d=0,u=l.count;d<u;d++)Ai.fromBufferAttribute(l,d),c&&(Qp.fromBufferAttribute(e,d),Ai.add(Qp)),i=Math.max(i,r.distanceToSquared(Ai))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&$a('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){$a("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 Rs(new Float32Array(4*r.count),4));const o=this.getAttribute("tangent"),l=[],c=[];for(let j=0;j<r.count;j++)l[j]=new pt,c[j]=new pt;const d=new pt,u=new pt,h=new pt,f=new In,p=new In,x=new In,v=new pt,g=new pt;function y(j,M,E){d.fromBufferAttribute(r,j),u.fromBufferAttribute(r,M),h.fromBufferAttribute(r,E),f.fromBufferAttribute(s,j),p.fromBufferAttribute(s,M),x.fromBufferAttribute(s,E),u.sub(d),h.sub(d),p.sub(f),x.sub(f);const B=1/(p.x*x.y-x.x*p.y);isFinite(B)&&(v.copy(u).multiplyScalar(x.y).addScaledVector(h,-p.y).multiplyScalar(B),g.copy(h).multiplyScalar(p.x).addScaledVector(u,-x.x).multiplyScalar(B),l[j].add(v),l[M].add(v),l[E].add(v),c[j].add(g),c[M].add(g),c[E].add(g))}let _=this.groups;_.length===0&&(_=[{start:0,count:e.count}]);for(let j=0,M=_.length;j<M;++j){const E=_[j],B=E.start,L=E.count;for(let U=B,D=B+L;U<D;U+=3)y(e.getX(U+0),e.getX(U+1),e.getX(U+2))}const N=new pt,A=new pt,k=new pt,P=new pt;function C(j){k.fromBufferAttribute(i,j),P.copy(k);const M=l[j];N.copy(M),N.sub(k.multiplyScalar(k.dot(M))).normalize(),A.crossVectors(P,M);const B=A.dot(c[j])<0?-1:1;o.setXYZW(j,N.x,N.y,N.z,B)}for(let j=0,M=_.length;j<M;++j){const E=_[j],B=E.start,L=E.count;for(let U=B,D=B+L;U<D;U+=3)C(e.getX(U+0)),C(e.getX(U+1)),C(e.getX(U+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 Rs(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 pt,s=new pt,o=new pt,l=new pt,c=new pt,d=new pt,u=new pt,h=new pt;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),u.subVectors(o,s),h.subVectors(i,s),u.cross(h),l.fromBufferAttribute(r,x),c.fromBufferAttribute(r,v),d.fromBufferAttribute(r,g),l.add(u),c.add(u),d.add(u),r.setXYZ(x,l.x,l.y,l.z),r.setXYZ(v,c.x,c.y,c.z),r.setXYZ(g,d.x,d.y,d.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),u.subVectors(o,s),h.subVectors(i,s),u.cross(h),r.setXYZ(f+0,u.x,u.y,u.z),r.setXYZ(f+1,u.x,u.y,u.z),r.setXYZ(f+2,u.x,u.y,u.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 d=l.array,u=l.itemSize,h=l.normalized,f=new d.constructor(c.length*u);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]*u;for(let y=0;y<u;y++)f[x++]=d[p++]}return new Rs(f,u,h)}if(this.index===null)return Sn("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new sY,r=this.index.array,i=this.attributes;for(const l in i){const c=i[l],d=e(c,r);n.setAttribute(l,d)}const s=this.morphAttributes;for(const l in s){const c=[],d=s[l];for(let u=0,h=d.length;u<h;u++){const f=d[u],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 d=o[l];n.addGroup(d.start,d.count,d.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 d in c)c[d]!==void 0&&(e[d]=c[d]);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 d=r[c];e.data.attributes[c]=d.toJSON(e.data)}const i={};let s=!1;for(const c in this.morphAttributes){const d=this.morphAttributes[c],u=[];for(let h=0,f=d.length;h<f;h++){const p=d[h];u.push(p.toJSON(e.data))}u.length>0&&(i[c]=u,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 d in i){const u=i[d];this.setAttribute(d,u.clone(n))}const s=e.morphAttributes;for(const d in s){const u=[],h=s[d];for(let f=0,p=h.length;f<p;f++)u.push(h[f].clone(n));this.morphAttributes[d]=u}this.morphTargetsRelative=e.morphTargetsRelative;const o=e.groups;for(let d=0,u=o.length;d<u;d++){const h=o[d];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 u8=new ai,Mm=new GF,mS=new rk,h8=new pt,fS=new pt,pS=new pt,gS=new pt,dP=new pt,bS=new pt,m8=new pt,xS=new pt;let Nl=class extends Lo{constructor(e=new _l,n=new WF){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){bS.set(0,0,0);for(let c=0,d=s.length;c<d;c++){const u=l[c],h=s[c];u!==0&&(dP.fromBufferAttribute(h,e),o?bS.addScaledVector(dP,u):bS.addScaledVector(dP.sub(n),u))}n.add(bS)}return n}raycast(e,n){const r=this.geometry,i=this.material,s=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),mS.copy(r.boundingSphere),mS.applyMatrix4(s),Mm.copy(e.ray).recast(e.near),!(mS.containsPoint(Mm.origin)===!1&&(Mm.intersectSphere(mS,h8)===null||Mm.origin.distanceToSquared(h8)>(e.far-e.near)**2))&&(u8.copy(s).invert(),Mm.copy(e.ray).applyMatrix4(u8),!(r.boundingBox!==null&&Mm.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,n,Mm)))}_computeIntersections(e,n,r){let i;const s=this.geometry,o=this.material,l=s.index,c=s.attributes.position,d=s.attributes.uv,u=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=_,k=N;A<k;A+=3){const P=l.getX(A),C=l.getX(A+1),j=l.getX(A+2);i=yS(this,y,e,r,d,u,h,P,C,j),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=yS(this,o,e,r,d,u,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=_,k=N;A<k;A+=3){const P=A,C=A+1,j=A+2;i=yS(this,y,e,r,d,u,h,P,C,j),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=yS(this,o,e,r,d,u,h,_,N,A),i&&(i.faceIndex=Math.floor(g/3),n.push(i))}}}};function Xbe(t,e,n,r,i,s,o,l){let c;if(e.side===ro?c=r.intersectTriangle(o,s,i,!0,l):c=r.intersectTriangle(i,s,o,e.side===Wh,l),c===null)return null;xS.copy(l),xS.applyMatrix4(t.matrixWorld);const d=n.ray.origin.distanceTo(xS);return d<n.near||d>n.far?null:{distance:d,point:xS.clone(),object:t}}function yS(t,e,n,r,i,s,o,l,c,d){t.getVertexPosition(l,fS),t.getVertexPosition(c,pS),t.getVertexPosition(d,gS);const u=Xbe(t,e,n,r,fS,pS,gS,m8);if(u){const h=new pt;ay.getBarycoord(m8,fS,pS,gS,h),i&&(u.uv=ay.getInterpolatedAttribute(i,l,c,d,h,new In)),s&&(u.uv1=ay.getInterpolatedAttribute(s,l,c,d,h,new In)),o&&(u.normal=ay.getInterpolatedAttribute(o,l,c,d,h,new pt),u.normal.dot(r.direction)>0&&u.normal.multiplyScalar(-1));const f={a:l,b:c,c:d,normal:new pt,materialIndex:0};ay.getNormal(fS,pS,gS,f.normal),u.face=f,u.barycoord=h}return u}let KF=class oY extends _l{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=[],d=[],u=[],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 jo(d,3)),this.setAttribute("normal",new jo(u,3)),this.setAttribute("uv",new jo(h,2));function x(v,g,y,_,N,A,k,P,C,j,M){const E=A/C,B=k/j,L=A/2,U=k/2,D=P/2,$=C+1,q=j+1;let z=0,W=0;const Q=new pt;for(let te=0;te<q;te++){const H=te*B-U;for(let X=0;X<$;X++){const Z=X*E-L;Q[v]=Z*_,Q[g]=H*N,Q[y]=D,d.push(Q.x,Q.y,Q.z),Q[v]=0,Q[g]=0,Q[y]=P>0?1:-1,u.push(Q.x,Q.y,Q.z),h.push(X/C),h.push(1-te/j),z+=1}}for(let te=0;te<j;te++)for(let H=0;H<C;H++){const X=f+H+$*te,Z=f+H+$*(te+1),ee=f+(H+1)+$*(te+1),Se=f+(H+1)+$*te;c.push(X,Z,Se),c.push(Z,ee,Se),W+=6}l.addGroup(p,W,M),p+=W,f+=z}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new oY(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};function xb(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?(Sn("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 As(t){const e={};for(let n=0;n<t.length;n++){const r=xb(t[n]);for(const i in r)e[i]=r[i]}return e}function Ybe(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function lY(t){const e=t.getRenderTarget();return e===null?t.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:fr.workingColorSpace}const Qbe={clone:xb,merge:As};var Zbe=`void main() {
- gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
- }`,Jbe=`void main() {
- gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
- }`;let iu=class extends Wb{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Zbe,this.fragmentShader=Jbe,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=xb(e.uniforms),this.uniformsGroups=Ybe(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}},cY=class extends Lo{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new ai,this.projectionMatrix=new ai,this.projectionMatrixInverse=new ai,this.coordinateSystem=Ac,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 Ku=new pt,f8=new In,p8=new In;let ll=class extends cY{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=tD*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(G_*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return tD*2*Math.atan(Math.tan(G_*.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){Ku.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(Ku.x,Ku.y).multiplyScalar(-e/Ku.z),Ku.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),r.set(Ku.x,Ku.y).multiplyScalar(-e/Ku.z)}getViewSize(e,n){return this.getViewBounds(e,f8,p8),n.subVectors(p8,f8)}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(G_*.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,d=o.fullHeight;s+=o.offsetX*i/c,n-=o.offsetY*r/d,i*=o.width/c,r*=o.height/d}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 Zp=-90,Jp=1;let exe=class extends Lo{constructor(e,n,r){super(),this.type="CubeCamera",this.renderTarget=r,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new ll(Zp,Jp,e,n);i.layers=this.layers,this.add(i);const s=new ll(Zp,Jp,e,n);s.layers=this.layers,this.add(s);const o=new ll(Zp,Jp,e,n);o.layers=this.layers,this.add(o);const l=new ll(Zp,Jp,e,n);l.layers=this.layers,this.add(l);const c=new ll(Zp,Jp,e,n);c.layers=this.layers,this.add(c);const d=new ll(Zp,Jp,e,n);d.layers=this.layers,this.add(d)}updateCoordinateSystem(){const e=this.coordinateSystem,n=this.children.concat(),[r,i,s,o,l,c]=n;for(const d of n)this.remove(d);if(e===Ac)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===A1)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 d of n)this.add(d),d.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,d,u]=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,d),r.texture.generateMipmaps=v,e.setRenderTarget(r,5,i),e.render(n,u),e.setRenderTarget(h,f,p),e.xr.enabled=x,r.texture.needsPMREMUpdate=!0}},dY=class extends ic{constructor(e=[],n=pb,r,i,s,o,l,c,d,u){super(e,n,r,i,s,o,l,c,d,u),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},txe=class extends Lf{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 dY(i),this._setTextureOptions(n),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,n){this.texture.type=n.type,this.texture.colorSpace=n.colorSpace,this.texture.generateMipmaps=n.generateMipmaps,this.texture.minFilter=n.minFilter,this.texture.magFilter=n.magFilter;const r={uniforms:{tEquirect:{value:null}},vertexShader:`
- varying vec3 vWorldDirection;
- vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
- return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
- }
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- }
- `,fragmentShader:`
- uniform sampler2D tEquirect;
- varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vec3 direction = normalize( vWorldDirection );
- vec2 sampleUV = equirectUv( direction );
- gl_FragColor = texture2D( tEquirect, sampleUV );
- }
- `},i=new KF(5,5,5),s=new iu({name:"CubemapFromEquirect",uniforms:xb(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:ro,blending:qd});s.uniforms.tEquirect.value=n;const o=new Nl(i,s),l=n.minFilter;return n.minFilter===tf&&(n.minFilter=fl),new exe(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)}},zg=class extends Lo{constructor(){super(),this.isGroup=!0,this.type="Group"}};const nxe={type:"move"};let uP=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new zg,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 zg,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new pt,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new pt),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new zg,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new pt,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new pt),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const n=this._hand;if(n)for(const r of e.hand.values())this._getHandJoint(n,r)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,n,r){let i=null,s=null,o=null;const l=this._targetRay,c=this._grip,d=this._hand;if(e&&n.session.visibilityState!=="visible-blurred"){if(d&&e.hand){o=!0;for(const v of e.hand.values()){const g=n.getJointPose(v,r),y=this._getHandJoint(d,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 u=d.joints["index-finger-tip"],h=d.joints["thumb-tip"],f=u.position.distanceTo(h.position),p=.02,x=.005;d.inputState.pinching&&f>p+x?(d.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!d.inputState.pinching&&f<=p-x&&(d.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(nxe)))}return l!==null&&(l.visible=i!==null),c!==null&&(c.visible=s!==null),d!==null&&(d.visible=o!==null),this}_getHandJoint(e,n){if(e.joints[n.jointName]===void 0){const r=new zg;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[n.jointName]=r,e.add(r)}return e.joints[n.jointName]}},rxe=class extends Lo{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new Kh,this.environmentIntensity=1,this.environmentRotation=new Kh,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,n){return super.copy(e,n),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const n=super.toJSON(e);return this.fog!==null&&(n.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(n.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(n.object.backgroundIntensity=this.backgroundIntensity),n.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(n.object.environmentIntensity=this.environmentIntensity),n.object.environmentRotation=this.environmentRotation.toArray(),n}},axe=class extends ic{constructor(e=null,n=1,r=1,i,s,o,l,c,d=Eo,u=Eo,h,f){super(null,o,l,c,d,u,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 hP=new pt,ixe=new pt,sxe=new Bn;let sh=class{constructor(e=new pt(1,0,0),n=0){this.isPlane=!0,this.normal=e,this.constant=n}set(e,n){return this.normal.copy(e),this.constant=n,this}setComponents(e,n,r,i){return this.normal.set(e,n,r),this.constant=i,this}setFromNormalAndCoplanarPoint(e,n){return this.normal.copy(e),this.constant=-n.dot(this.normal),this}setFromCoplanarPoints(e,n,r){const i=hP.subVectors(r,n).cross(ixe.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(hP),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||sxe.getNormalMatrix(e),i=this.coplanarPoint(hP).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 Pm=new rk,oxe=new In(.5,.5),vS=new pt;let XF=class{constructor(e=new sh,n=new sh,r=new sh,i=new sh,s=new sh,o=new sh){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=Ac,r=!1){const i=this.planes,s=e.elements,o=s[0],l=s[1],c=s[2],d=s[3],u=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],k=s[15];if(i[0].setComponents(d-o,p-u,y-x,k-_).normalize(),i[1].setComponents(d+o,p+u,y+x,k+_).normalize(),i[2].setComponents(d+l,p+h,y+v,k+N).normalize(),i[3].setComponents(d-l,p-h,y-v,k-N).normalize(),r)i[4].setComponents(c,f,g,A).normalize(),i[5].setComponents(d-c,p-f,y-g,k-A).normalize();else if(i[4].setComponents(d-c,p-f,y-g,k-A).normalize(),n===Ac)i[5].setComponents(d+c,p+f,y+g,k+A).normalize();else if(n===A1)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(),Pm.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),Pm.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Pm)}intersectsSprite(e){Pm.center.set(0,0,0);const n=oxe.distanceTo(e.center);return Pm.radius=.7071067811865476+n,Pm.applyMatrix4(e.matrixWorld),this.intersectsSphere(Pm)}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(vS.x=i.normal.x>0?e.max.x:e.min.x,vS.y=i.normal.y>0?e.max.y:e.min.y,vS.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(vS)<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)}},uY=class extends Wb{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Hn(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 M1=new pt,P1=new pt,g8=new ai,sy=new GF,wS=new rk,mP=new pt,b8=new pt;let lxe=class extends Lo{constructor(e=new _l,n=new uY){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++)M1.fromBufferAttribute(n,i-1),P1.fromBufferAttribute(n,i),r[i]=r[i-1],r[i]+=M1.distanceTo(P1);e.setAttribute("lineDistance",new jo(r,1))}else Sn("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(),wS.copy(r.boundingSphere),wS.applyMatrix4(i),wS.radius+=s,e.ray.intersectsSphere(wS)===!1)return;g8.copy(i).invert(),sy.copy(e.ray).applyMatrix4(g8);const l=s/((this.scale.x+this.scale.y+this.scale.z)/3),c=l*l,d=this.isLineSegments?2:1,u=r.index,f=r.attributes.position;if(u!==null){const p=Math.max(0,o.start),x=Math.min(u.count,o.start+o.count);for(let v=p,g=x-1;v<g;v+=d){const y=u.getX(v),_=u.getX(v+1),N=SS(this,e,sy,c,y,_,v);N&&n.push(N)}if(this.isLineLoop){const v=u.getX(x-1),g=u.getX(p),y=SS(this,e,sy,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+=d){const y=SS(this,e,sy,c,v,v+1,v);y&&n.push(y)}if(this.isLineLoop){const v=SS(this,e,sy,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 SS(t,e,n,r,i,s,o){const l=t.geometry.attributes.position;if(M1.fromBufferAttribute(l,i),P1.fromBufferAttribute(l,s),n.distanceSqToSegment(M1,P1,mP,b8)>r)return;mP.applyMatrix4(t.matrixWorld);const d=e.ray.origin.distanceTo(mP);if(!(d<e.near||d>e.far))return{distance:d,point:b8.clone().applyMatrix4(t.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:t}}const x8=new pt,y8=new pt;let cxe=class extends lxe{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)x8.fromBufferAttribute(n,i),y8.fromBufferAttribute(n,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+x8.distanceTo(y8);e.setAttribute("lineDistance",new jo(r,1))}else Sn("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},hY=class extends ic{constructor(e,n,r=Rf,i,s,o,l=Eo,c=Eo,d,u=v0,h=1){if(u!==v0&&u!==w0)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,u,r,d),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new qF(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 mY extends ic{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}let YF=class fY extends _l{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),d=l+1,u=c+1,h=e/l,f=n/c,p=[],x=[],v=[],g=[];for(let y=0;y<u;y++){const _=y*f-o;for(let N=0;N<d;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=_+d*y,A=_+d*(y+1),k=_+1+d*(y+1),P=_+1+d*y;p.push(N,A,P),p.push(A,k,P)}this.setIndex(p),this.setAttribute("position",new jo(x,3)),this.setAttribute("normal",new jo(v,3)),this.setAttribute("uv",new jo(g,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new fY(e.width,e.height,e.widthSegments,e.heightSegments)}};class pY extends Wb{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Hn(16777215),this.specular=new Hn(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Hn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=WX,this.normalScale=new In(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Kh,this.combine=OF,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 dxe=class extends Wb{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=ybe,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}},uxe=class extends Wb{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 v8={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 hxe{constructor(e,n,r){const i=this;let s=!1,o=0,l=0,c;const d=[];this.onStart=void 0,this.onLoad=e,this.onProgress=n,this.onError=r,this._abortController=null,this.itemStart=function(u){l++,s===!1&&i.onStart!==void 0&&i.onStart(u,o,l),s=!0},this.itemEnd=function(u){o++,i.onProgress!==void 0&&i.onProgress(u,o,l),o===l&&(s=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(u){i.onError!==void 0&&i.onError(u)},this.resolveURL=function(u){return c?c(u):u},this.setURLModifier=function(u){return c=u,this},this.addHandler=function(u,h){return d.push(u,h),this},this.removeHandler=function(u){const h=d.indexOf(u);return h!==-1&&d.splice(h,2),this},this.getHandler=function(u){for(let h=0,f=d.length;h<f;h+=2){const p=d[h],x=d[h+1];if(p.global&&(p.lastIndex=0),p.test(u))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 mxe=new hxe;class QF{constructor(e){this.manager=e!==void 0?e:mxe,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}}QF.DEFAULT_MATERIAL_NAME="__DEFAULT";const xd={};class fxe extends Error{constructor(e,n){super(e),this.response=n}}class pxe extends QF{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=v8.get(`file:${e}`);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{n&&n(s),this.manager.itemEnd(e)},0),s;if(xd[e]!==void 0){xd[e].push({onLoad:n,onProgress:r,onError:i});return}xd[e]=[],xd[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(d=>{if(d.status===200||d.status===0){if(d.status===0&&Sn("FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||d.body===void 0||d.body.getReader===void 0)return d;const u=xd[e],h=d.body.getReader(),f=d.headers.get("X-File-Size")||d.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 k=new ProgressEvent("progress",{lengthComputable:x,loaded:v,total:p});for(let P=0,C=u.length;P<C;P++){const j=u[P];j.onProgress&&j.onProgress(k)}y.enqueue(A),_()}},N=>{y.error(N)})}}});return new Response(g)}else throw new fxe(`fetch for "${d.url}" responded with ${d.status}: ${d.statusText}`,d)}).then(d=>{switch(c){case"arraybuffer":return d.arrayBuffer();case"blob":return d.blob();case"document":return d.text().then(u=>new DOMParser().parseFromString(u,l));case"json":return d.json();default:if(l==="")return d.text();{const h=/charset="?([^;"\s]*)"?/i.exec(l),f=h&&h[1]?h[1].toLowerCase():void 0,p=new TextDecoder(f);return d.arrayBuffer().then(x=>p.decode(x))}}}).then(d=>{v8.add(`file:${e}`,d);const u=xd[e];delete xd[e];for(let h=0,f=u.length;h<f;h++){const p=u[h];p.onLoad&&p.onLoad(d)}}).catch(d=>{const u=xd[e];if(u===void 0)throw this.manager.itemError(e),d;delete xd[e];for(let h=0,f=u.length;h<f;h++){const p=u[h];p.onError&&p.onError(d)}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 gY=class extends Lo{constructor(e,n=1){super(),this.isLight=!0,this.type="Light",this.color=new Hn(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 fP=new ai,w8=new pt,S8=new pt;let gxe=class{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new In(512,512),this.mapType=Oc,this.map=null,this.mapPass=null,this.matrix=new ai,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new XF,this._frameExtents=new In(1,1),this._viewportCount=1,this._viewports=[new Ja(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const n=this.camera,r=this.matrix;w8.setFromMatrixPosition(e.matrixWorld),n.position.copy(w8),S8.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(S8),n.updateMatrixWorld(),fP.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(fP,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(fP)}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}},bY=class extends cY{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 d=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=d*this.view.offsetX,o=s+d*this.view.width,l-=u*this.view.offsetY,c=l-u*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 bxe extends gxe{constructor(){super(new bY(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class _8 extends gY{constructor(e,n){super(e,n),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Lo.DEFAULT_UP),this.updateMatrix(),this.target=new Lo,this.shadow=new bxe}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}let xxe=class extends gY{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}},yxe=class extends ll{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}},N8=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=Yn(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(Yn(n/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};class vxe extends cxe{constructor(e=10,n=10,r=4473924,i=8947848){r=new Hn(r),i=new Hn(i);const s=n/2,o=e/n,l=e/2,c=[],d=[];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(d,p),p+=3,v.toArray(d,p),p+=3,v.toArray(d,p),p+=3,v.toArray(d,p),p+=3}const u=new _l;u.setAttribute("position",new jo(c,3)),u.setAttribute("color",new jo(d,3));const h=new uY({vertexColors:!0,toneMapped:!1});super(u,h),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class wxe extends tp{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){Sn("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function C8(t,e,n,r){const i=Sxe(r);switch(n){case VX:return t*e;case GX:return t*e/i.components*i.byteLength;case BF:return t*e/i.components*i.byteLength;case HF:return t*e*2/i.components*i.byteLength;case $F:return t*e*2/i.components*i.byteLength;case qX:return t*e*3/i.components*i.byteLength;case Gl:return t*e*4/i.components*i.byteLength;case VF:return t*e*4/i.components*i.byteLength;case H_:case $_:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case V_:case q_:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case T3:case P3:return Math.max(t,16)*Math.max(e,8)/4;case A3:case M3:return Math.max(t,8)*Math.max(e,8)/2;case E3:case j3:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case D3:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case R3:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case F3:return Math.floor((t+4)/5)*Math.floor((e+3)/4)*16;case L3:return Math.floor((t+4)/5)*Math.floor((e+4)/5)*16;case O3:return Math.floor((t+5)/6)*Math.floor((e+4)/5)*16;case I3:return Math.floor((t+5)/6)*Math.floor((e+5)/6)*16;case z3:return Math.floor((t+7)/8)*Math.floor((e+4)/5)*16;case U3:return Math.floor((t+7)/8)*Math.floor((e+5)/6)*16;case B3:return Math.floor((t+7)/8)*Math.floor((e+7)/8)*16;case H3:return Math.floor((t+9)/10)*Math.floor((e+4)/5)*16;case $3:return Math.floor((t+9)/10)*Math.floor((e+5)/6)*16;case V3:return Math.floor((t+9)/10)*Math.floor((e+7)/8)*16;case q3:return Math.floor((t+9)/10)*Math.floor((e+9)/10)*16;case G3:return Math.floor((t+11)/12)*Math.floor((e+9)/10)*16;case W3:return Math.floor((t+11)/12)*Math.floor((e+11)/12)*16;case K3:case X3:case Y3:return Math.ceil(t/4)*Math.ceil(e/4)*16;case Q3:case Z3:return Math.ceil(t/4)*Math.ceil(e/4)*8;case J3:case eD:return Math.ceil(t/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${n} format.`)}function Sxe(t){switch(t){case Oc:case UX:return{byteLength:1,components:1};case x0:case BX:case Gb:return{byteLength:2,components:1};case zF:case UF:return{byteLength:2,components:4};case Rf:case IF:case zd:return{byteLength:4,components:1};case HX:case $X:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${t}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:LF}}));typeof window<"u"&&(window.__THREE__?Sn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=LF);function xY(){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 _xe(t){const e=new WeakMap;function n(l,c){const d=l.array,u=l.usage,h=d.byteLength,f=t.createBuffer();t.bindBuffer(c,f),t.bufferData(c,d,u),l.onUploadCallback();let p;if(d instanceof Float32Array)p=t.FLOAT;else if(typeof Float16Array<"u"&&d instanceof Float16Array)p=t.HALF_FLOAT;else if(d instanceof Uint16Array)l.isFloat16BufferAttribute?p=t.HALF_FLOAT:p=t.UNSIGNED_SHORT;else if(d instanceof Int16Array)p=t.SHORT;else if(d instanceof Uint32Array)p=t.UNSIGNED_INT;else if(d instanceof Int32Array)p=t.INT;else if(d instanceof Int8Array)p=t.BYTE;else if(d instanceof Uint8Array)p=t.UNSIGNED_BYTE;else if(d instanceof Uint8ClampedArray)p=t.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+d);return{buffer:f,type:p,bytesPerElement:d.BYTES_PER_ELEMENT,version:l.version,size:h}}function r(l,c,d){const u=c.array,h=c.updateRanges;if(t.bindBuffer(d,l),h.length===0)t.bufferSubData(d,0,u);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(d,v.start*u.BYTES_PER_ELEMENT,u,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 u=e.get(l);(!u||u.version<l.version)&&e.set(l,{buffer:l.buffer,type:l.type,bytesPerElement:l.elementSize,version:l.version});return}const d=e.get(l);if(d===void 0)e.set(l,n(l,c));else if(d.version<l.version){if(d.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(d.buffer,l,c),d.version=l.version}}return{get:i,remove:s,update:o}}var Nxe=`#ifdef USE_ALPHAHASH
- if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
- #endif`,Cxe=`#ifdef USE_ALPHAHASH
- const float ALPHA_HASH_SCALE = 0.05;
- float hash2D( vec2 value ) {
- return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
- }
- float hash3D( vec3 value ) {
- return hash2D( vec2( hash2D( value.xy ), value.z ) );
- }
- float getAlphaHashThreshold( vec3 position ) {
- float maxDeriv = max(
- length( dFdx( position.xyz ) ),
- length( dFdy( position.xyz ) )
- );
- float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
- vec2 pixScales = vec2(
- exp2( floor( log2( pixScale ) ) ),
- exp2( ceil( log2( pixScale ) ) )
- );
- vec2 alpha = vec2(
- hash3D( floor( pixScales.x * position.xyz ) ),
- hash3D( floor( pixScales.y * position.xyz ) )
- );
- float lerpFactor = fract( log2( pixScale ) );
- float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
- float a = min( lerpFactor, 1.0 - lerpFactor );
- vec3 cases = vec3(
- x * x / ( 2.0 * a * ( 1.0 - a ) ),
- ( x - 0.5 * a ) / ( 1.0 - a ),
- 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
- );
- float threshold = ( x < ( 1.0 - a ) )
- ? ( ( x < a ) ? cases.x : cases.y )
- : cases.z;
- return clamp( threshold , 1.0e-6, 1.0 );
- }
- #endif`,kxe=`#ifdef USE_ALPHAMAP
- diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
- #endif`,Axe=`#ifdef USE_ALPHAMAP
- uniform sampler2D alphaMap;
- #endif`,Txe=`#ifdef USE_ALPHATEST
- #ifdef ALPHA_TO_COVERAGE
- diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
- if ( diffuseColor.a == 0.0 ) discard;
- #else
- if ( diffuseColor.a < alphaTest ) discard;
- #endif
- #endif`,Mxe=`#ifdef USE_ALPHATEST
- uniform float alphaTest;
- #endif`,Pxe=`#ifdef USE_AOMAP
- float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
- reflectedLight.indirectDiffuse *= ambientOcclusion;
- #if defined( USE_CLEARCOAT )
- clearcoatSpecularIndirect *= ambientOcclusion;
- #endif
- #if defined( USE_SHEEN )
- sheenSpecularIndirect *= ambientOcclusion;
- #endif
- #if defined( USE_ENVMAP ) && defined( STANDARD )
- float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
- reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
- #endif
- #endif`,Exe=`#ifdef USE_AOMAP
- uniform sampler2D aoMap;
- uniform float aoMapIntensity;
- #endif`,jxe=`#ifdef USE_BATCHING
- #if ! defined( GL_ANGLE_multi_draw )
- #define gl_DrawID _gl_DrawID
- uniform int _gl_DrawID;
- #endif
- uniform highp sampler2D batchingTexture;
- uniform highp usampler2D batchingIdTexture;
- mat4 getBatchingMatrix( const in float i ) {
- int size = textureSize( batchingTexture, 0 ).x;
- int j = int( i ) * 4;
- int x = j % size;
- int y = j / size;
- vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
- vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
- vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
- vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
- return mat4( v1, v2, v3, v4 );
- }
- float getIndirectIndex( const in int i ) {
- int size = textureSize( batchingIdTexture, 0 ).x;
- int x = i % size;
- int y = i / size;
- return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );
- }
- #endif
- #ifdef USE_BATCHING_COLOR
- uniform sampler2D batchingColorTexture;
- vec3 getBatchingColor( const in float i ) {
- int size = textureSize( batchingColorTexture, 0 ).x;
- int j = int( i );
- int x = j % size;
- int y = j / size;
- return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;
- }
- #endif`,Dxe=`#ifdef USE_BATCHING
- mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
- #endif`,Rxe=`vec3 transformed = vec3( position );
- #ifdef USE_ALPHAHASH
- vPosition = vec3( position );
- #endif`,Fxe=`vec3 objectNormal = vec3( normal );
- #ifdef USE_TANGENT
- vec3 objectTangent = vec3( tangent.xyz );
- #endif`,Lxe=`float G_BlinnPhong_Implicit( ) {
- return 0.25;
- }
- float D_BlinnPhong( const in float shininess, const in float dotNH ) {
- return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
- }
- vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNH = saturate( dot( normal, halfDir ) );
- float dotVH = saturate( dot( viewDir, halfDir ) );
- vec3 F = F_Schlick( specularColor, 1.0, dotVH );
- float G = G_BlinnPhong_Implicit( );
- float D = D_BlinnPhong( shininess, dotNH );
- return F * ( G * D );
- } // validated`,Oxe=`#ifdef USE_IRIDESCENCE
- const mat3 XYZ_TO_REC709 = mat3(
- 3.2404542, -0.9692660, 0.0556434,
- -1.5371385, 1.8760108, -0.2040259,
- -0.4985314, 0.0415560, 1.0572252
- );
- vec3 Fresnel0ToIor( vec3 fresnel0 ) {
- vec3 sqrtF0 = sqrt( fresnel0 );
- return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
- }
- vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
- return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
- }
- float IorToFresnel0( float transmittedIor, float incidentIor ) {
- return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
- }
- vec3 evalSensitivity( float OPD, vec3 shift ) {
- float phase = 2.0 * PI * OPD * 1.0e-9;
- vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
- vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
- vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
- vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
- xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );
- xyz /= 1.0685e-7;
- vec3 rgb = XYZ_TO_REC709 * xyz;
- return rgb;
- }
- vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
- vec3 I;
- float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
- float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
- float cosTheta2Sq = 1.0 - sinTheta2Sq;
- if ( cosTheta2Sq < 0.0 ) {
- return vec3( 1.0 );
- }
- float cosTheta2 = sqrt( cosTheta2Sq );
- float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
- float R12 = F_Schlick( R0, 1.0, cosTheta1 );
- float T121 = 1.0 - R12;
- float phi12 = 0.0;
- if ( iridescenceIOR < outsideIOR ) phi12 = PI;
- float phi21 = PI - phi12;
- vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
- vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
- vec3 phi23 = vec3( 0.0 );
- if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
- if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
- if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
- float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
- vec3 phi = vec3( phi21 ) + phi23;
- vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
- vec3 r123 = sqrt( R123 );
- vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
- vec3 C0 = R12 + Rs;
- I = C0;
- vec3 Cm = Rs - T121;
- for ( int m = 1; m <= 2; ++ m ) {
- Cm *= r123;
- vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
- I += Cm * Sm;
- }
- return max( I, vec3( 0.0 ) );
- }
- #endif`,Ixe=`#ifdef USE_BUMPMAP
- uniform sampler2D bumpMap;
- uniform float bumpScale;
- vec2 dHdxy_fwd() {
- vec2 dSTdx = dFdx( vBumpMapUv );
- vec2 dSTdy = dFdy( vBumpMapUv );
- float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
- float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
- float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
- return vec2( dBx, dBy );
- }
- vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
- vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
- vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
- vec3 vN = surf_norm;
- vec3 R1 = cross( vSigmaY, vN );
- vec3 R2 = cross( vN, vSigmaX );
- float fDet = dot( vSigmaX, R1 ) * faceDirection;
- vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
- return normalize( abs( fDet ) * surf_norm - vGrad );
- }
- #endif`,zxe=`#if NUM_CLIPPING_PLANES > 0
- vec4 plane;
- #ifdef ALPHA_TO_COVERAGE
- float distanceToPlane, distanceGradient;
- float clipOpacity = 1.0;
- #pragma unroll_loop_start
- for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
- plane = clippingPlanes[ i ];
- distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
- distanceGradient = fwidth( distanceToPlane ) / 2.0;
- clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
- if ( clipOpacity == 0.0 ) discard;
- }
- #pragma unroll_loop_end
- #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
- float unionClipOpacity = 1.0;
- #pragma unroll_loop_start
- for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
- plane = clippingPlanes[ i ];
- distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
- distanceGradient = fwidth( distanceToPlane ) / 2.0;
- unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
- }
- #pragma unroll_loop_end
- clipOpacity *= 1.0 - unionClipOpacity;
- #endif
- diffuseColor.a *= clipOpacity;
- if ( diffuseColor.a == 0.0 ) discard;
- #else
- #pragma unroll_loop_start
- for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
- plane = clippingPlanes[ i ];
- if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
- }
- #pragma unroll_loop_end
- #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
- bool clipped = true;
- #pragma unroll_loop_start
- for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
- plane = clippingPlanes[ i ];
- clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
- }
- #pragma unroll_loop_end
- if ( clipped ) discard;
- #endif
- #endif
- #endif`,Uxe=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
- #endif`,Bxe=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- #endif`,Hxe=`#if NUM_CLIPPING_PLANES > 0
- vClipPosition = - mvPosition.xyz;
- #endif`,$xe=`#if defined( USE_COLOR_ALPHA )
- diffuseColor *= vColor;
- #elif defined( USE_COLOR )
- diffuseColor.rgb *= vColor;
- #endif`,Vxe=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR )
- varying vec3 vColor;
- #endif`,qxe=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
- varying vec3 vColor;
- #endif`,Gxe=`#if defined( USE_COLOR_ALPHA )
- vColor = vec4( 1.0 );
- #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
- vColor = vec3( 1.0 );
- #endif
- #ifdef USE_COLOR
- vColor *= color;
- #endif
- #ifdef USE_INSTANCING_COLOR
- vColor.xyz *= instanceColor.xyz;
- #endif
- #ifdef USE_BATCHING_COLOR
- vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );
- vColor.xyz *= batchingColor.xyz;
- #endif`,Wxe=`#define PI 3.141592653589793
- #define PI2 6.283185307179586
- #define PI_HALF 1.5707963267948966
- #define RECIPROCAL_PI 0.3183098861837907
- #define RECIPROCAL_PI2 0.15915494309189535
- #define EPSILON 1e-6
- #ifndef saturate
- #define saturate( a ) clamp( a, 0.0, 1.0 )
- #endif
- #define whiteComplement( a ) ( 1.0 - saturate( a ) )
- float pow2( const in float x ) { return x*x; }
- vec3 pow2( const in vec3 x ) { return x*x; }
- float pow3( const in float x ) { return x*x*x; }
- float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
- float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
- float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
- highp float rand( const in vec2 uv ) {
- const highp float a = 12.9898, b = 78.233, c = 43758.5453;
- highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
- return fract( sin( sn ) * c );
- }
- #ifdef HIGH_PRECISION
- float precisionSafeLength( vec3 v ) { return length( v ); }
- #else
- float precisionSafeLength( vec3 v ) {
- float maxComponent = max3( abs( v ) );
- return length( v / maxComponent ) * maxComponent;
- }
- #endif
- struct IncidentLight {
- vec3 color;
- vec3 direction;
- bool visible;
- };
- struct ReflectedLight {
- vec3 directDiffuse;
- vec3 directSpecular;
- vec3 indirectDiffuse;
- vec3 indirectSpecular;
- };
- #ifdef USE_ALPHAHASH
- varying vec3 vPosition;
- #endif
- vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
- return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
- }
- vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
- return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
- }
- bool isPerspectiveMatrix( mat4 m ) {
- return m[ 2 ][ 3 ] == - 1.0;
- }
- vec2 equirectUv( in vec3 dir ) {
- float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
- float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
- return vec2( u, v );
- }
- vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
- return RECIPROCAL_PI * diffuseColor;
- }
- vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
- float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
- return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
- }
- float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
- float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
- return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
- } // validated`,Kxe=`#ifdef ENVMAP_TYPE_CUBE_UV
- #define cubeUV_minMipLevel 4.0
- #define cubeUV_minTileSize 16.0
- float getFace( vec3 direction ) {
- vec3 absDirection = abs( direction );
- float face = - 1.0;
- if ( absDirection.x > absDirection.z ) {
- if ( absDirection.x > absDirection.y )
- face = direction.x > 0.0 ? 0.0 : 3.0;
- else
- face = direction.y > 0.0 ? 1.0 : 4.0;
- } else {
- if ( absDirection.z > absDirection.y )
- face = direction.z > 0.0 ? 2.0 : 5.0;
- else
- face = direction.y > 0.0 ? 1.0 : 4.0;
- }
- return face;
- }
- vec2 getUV( vec3 direction, float face ) {
- vec2 uv;
- if ( face == 0.0 ) {
- uv = vec2( direction.z, direction.y ) / abs( direction.x );
- } else if ( face == 1.0 ) {
- uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
- } else if ( face == 2.0 ) {
- uv = vec2( - direction.x, direction.y ) / abs( direction.z );
- } else if ( face == 3.0 ) {
- uv = vec2( - direction.z, direction.y ) / abs( direction.x );
- } else if ( face == 4.0 ) {
- uv = vec2( - direction.x, direction.z ) / abs( direction.y );
- } else {
- uv = vec2( direction.x, direction.y ) / abs( direction.z );
- }
- return 0.5 * ( uv + 1.0 );
- }
- vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
- float face = getFace( direction );
- float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
- mipInt = max( mipInt, cubeUV_minMipLevel );
- float faceSize = exp2( mipInt );
- highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
- if ( face > 2.0 ) {
- uv.y += faceSize;
- face -= 3.0;
- }
- uv.x += face * faceSize;
- uv.x += filterInt * 3.0 * cubeUV_minTileSize;
- uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
- uv.x *= CUBEUV_TEXEL_WIDTH;
- uv.y *= CUBEUV_TEXEL_HEIGHT;
- #ifdef texture2DGradEXT
- return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
- #else
- return texture2D( envMap, uv ).rgb;
- #endif
- }
- #define cubeUV_r0 1.0
- #define cubeUV_m0 - 2.0
- #define cubeUV_r1 0.8
- #define cubeUV_m1 - 1.0
- #define cubeUV_r4 0.4
- #define cubeUV_m4 2.0
- #define cubeUV_r5 0.305
- #define cubeUV_m5 3.0
- #define cubeUV_r6 0.21
- #define cubeUV_m6 4.0
- float roughnessToMip( float roughness ) {
- float mip = 0.0;
- if ( roughness >= cubeUV_r1 ) {
- mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
- } else if ( roughness >= cubeUV_r4 ) {
- mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
- } else if ( roughness >= cubeUV_r5 ) {
- mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
- } else if ( roughness >= cubeUV_r6 ) {
- mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
- } else {
- mip = - 2.0 * log2( 1.16 * roughness ); }
- return mip;
- }
- vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
- float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
- float mipF = fract( mip );
- float mipInt = floor( mip );
- vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
- if ( mipF == 0.0 ) {
- return vec4( color0, 1.0 );
- } else {
- vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
- return vec4( mix( color0, color1, mipF ), 1.0 );
- }
- }
- #endif`,Xxe=`vec3 transformedNormal = objectNormal;
- #ifdef USE_TANGENT
- vec3 transformedTangent = objectTangent;
- #endif
- #ifdef USE_BATCHING
- mat3 bm = mat3( batchingMatrix );
- transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
- transformedNormal = bm * transformedNormal;
- #ifdef USE_TANGENT
- transformedTangent = bm * transformedTangent;
- #endif
- #endif
- #ifdef USE_INSTANCING
- mat3 im = mat3( instanceMatrix );
- transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
- transformedNormal = im * transformedNormal;
- #ifdef USE_TANGENT
- transformedTangent = im * transformedTangent;
- #endif
- #endif
- transformedNormal = normalMatrix * transformedNormal;
- #ifdef FLIP_SIDED
- transformedNormal = - transformedNormal;
- #endif
- #ifdef USE_TANGENT
- transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
- #ifdef FLIP_SIDED
- transformedTangent = - transformedTangent;
- #endif
- #endif`,Yxe=`#ifdef USE_DISPLACEMENTMAP
- uniform sampler2D displacementMap;
- uniform float displacementScale;
- uniform float displacementBias;
- #endif`,Qxe=`#ifdef USE_DISPLACEMENTMAP
- transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
- #endif`,Zxe=`#ifdef USE_EMISSIVEMAP
- vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
- #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
- emissiveColor = sRGBTransferEOTF( emissiveColor );
- #endif
- totalEmissiveRadiance *= emissiveColor.rgb;
- #endif`,Jxe=`#ifdef USE_EMISSIVEMAP
- uniform sampler2D emissiveMap;
- #endif`,eye="gl_FragColor = linearToOutputTexel( gl_FragColor );",tye=`vec4 LinearTransferOETF( in vec4 value ) {
- return value;
- }
- vec4 sRGBTransferEOTF( in vec4 value ) {
- return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );
- }
- vec4 sRGBTransferOETF( in vec4 value ) {
- return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
- }`,nye=`#ifdef USE_ENVMAP
- #ifdef ENV_WORLDPOS
- vec3 cameraToFrag;
- if ( isOrthographic ) {
- cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
- } else {
- cameraToFrag = normalize( vWorldPosition - cameraPosition );
- }
- vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
- #ifdef ENVMAP_MODE_REFLECTION
- vec3 reflectVec = reflect( cameraToFrag, worldNormal );
- #else
- vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
- #endif
- #else
- vec3 reflectVec = vReflect;
- #endif
- #ifdef ENVMAP_TYPE_CUBE
- vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
- #else
- vec4 envColor = vec4( 0.0 );
- #endif
- #ifdef ENVMAP_BLENDING_MULTIPLY
- outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
- #elif defined( ENVMAP_BLENDING_MIX )
- outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
- #elif defined( ENVMAP_BLENDING_ADD )
- outgoingLight += envColor.xyz * specularStrength * reflectivity;
- #endif
- #endif`,rye=`#ifdef USE_ENVMAP
- uniform float envMapIntensity;
- uniform float flipEnvMap;
- uniform mat3 envMapRotation;
- #ifdef ENVMAP_TYPE_CUBE
- uniform samplerCube envMap;
- #else
- uniform sampler2D envMap;
- #endif
- #endif`,aye=`#ifdef USE_ENVMAP
- uniform float reflectivity;
- #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
- #define ENV_WORLDPOS
- #endif
- #ifdef ENV_WORLDPOS
- varying vec3 vWorldPosition;
- uniform float refractionRatio;
- #else
- varying vec3 vReflect;
- #endif
- #endif`,iye=`#ifdef USE_ENVMAP
- #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
- #define ENV_WORLDPOS
- #endif
- #ifdef ENV_WORLDPOS
-
- varying vec3 vWorldPosition;
- #else
- varying vec3 vReflect;
- uniform float refractionRatio;
- #endif
- #endif`,sye=`#ifdef USE_ENVMAP
- #ifdef ENV_WORLDPOS
- vWorldPosition = worldPosition.xyz;
- #else
- vec3 cameraToVertex;
- if ( isOrthographic ) {
- cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
- } else {
- cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
- }
- vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
- #ifdef ENVMAP_MODE_REFLECTION
- vReflect = reflect( cameraToVertex, worldNormal );
- #else
- vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
- #endif
- #endif
- #endif`,oye=`#ifdef USE_FOG
- vFogDepth = - mvPosition.z;
- #endif`,lye=`#ifdef USE_FOG
- varying float vFogDepth;
- #endif`,cye=`#ifdef USE_FOG
- #ifdef FOG_EXP2
- float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
- #else
- float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
- #endif
- gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
- #endif`,dye=`#ifdef USE_FOG
- uniform vec3 fogColor;
- varying float vFogDepth;
- #ifdef FOG_EXP2
- uniform float fogDensity;
- #else
- uniform float fogNear;
- uniform float fogFar;
- #endif
- #endif`,uye=`#ifdef USE_GRADIENTMAP
- uniform sampler2D gradientMap;
- #endif
- vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
- float dotNL = dot( normal, lightDirection );
- vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
- #ifdef USE_GRADIENTMAP
- return vec3( texture2D( gradientMap, coord ).r );
- #else
- vec2 fw = fwidth( coord ) * 0.5;
- return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
- #endif
- }`,hye=`#ifdef USE_LIGHTMAP
- uniform sampler2D lightMap;
- uniform float lightMapIntensity;
- #endif`,mye=`LambertMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularStrength = specularStrength;`,fye=`varying vec3 vViewPosition;
- struct LambertMaterial {
- vec3 diffuseColor;
- float specularStrength;
- };
- void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
- float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
- vec3 irradiance = dotNL * directLight.color;
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- #define RE_Direct RE_Direct_Lambert
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,pye=`uniform bool receiveShadow;
- uniform vec3 ambientLightColor;
- #if defined( USE_LIGHT_PROBES )
- uniform vec3 lightProbe[ 9 ];
- #endif
- vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
- float x = normal.x, y = normal.y, z = normal.z;
- vec3 result = shCoefficients[ 0 ] * 0.886227;
- result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
- result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
- result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
- result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
- result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
- result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
- result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
- result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
- return result;
- }
- vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
- vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
- vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
- return irradiance;
- }
- vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
- vec3 irradiance = ambientLightColor;
- return irradiance;
- }
- float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
- float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
- if ( cutoffDistance > 0.0 ) {
- distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
- }
- return distanceFalloff;
- }
- float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
- return smoothstep( coneCosine, penumbraCosine, angleCosine );
- }
- #if NUM_DIR_LIGHTS > 0
- struct DirectionalLight {
- vec3 direction;
- vec3 color;
- };
- uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
- void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
- light.color = directionalLight.color;
- light.direction = directionalLight.direction;
- light.visible = true;
- }
- #endif
- #if NUM_POINT_LIGHTS > 0
- struct PointLight {
- vec3 position;
- vec3 color;
- float distance;
- float decay;
- };
- uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
- void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
- vec3 lVector = pointLight.position - geometryPosition;
- light.direction = normalize( lVector );
- float lightDistance = length( lVector );
- light.color = pointLight.color;
- light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
- light.visible = ( light.color != vec3( 0.0 ) );
- }
- #endif
- #if NUM_SPOT_LIGHTS > 0
- struct SpotLight {
- vec3 position;
- vec3 direction;
- vec3 color;
- float distance;
- float decay;
- float coneCos;
- float penumbraCos;
- };
- uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
- void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
- vec3 lVector = spotLight.position - geometryPosition;
- light.direction = normalize( lVector );
- float angleCos = dot( light.direction, spotLight.direction );
- float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
- if ( spotAttenuation > 0.0 ) {
- float lightDistance = length( lVector );
- light.color = spotLight.color * spotAttenuation;
- light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
- light.visible = ( light.color != vec3( 0.0 ) );
- } else {
- light.color = vec3( 0.0 );
- light.visible = false;
- }
- }
- #endif
- #if NUM_RECT_AREA_LIGHTS > 0
- struct RectAreaLight {
- vec3 color;
- vec3 position;
- vec3 halfWidth;
- vec3 halfHeight;
- };
- uniform sampler2D ltc_1; uniform sampler2D ltc_2;
- uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
- #endif
- #if NUM_HEMI_LIGHTS > 0
- struct HemisphereLight {
- vec3 direction;
- vec3 skyColor;
- vec3 groundColor;
- };
- uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
- vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
- float dotNL = dot( normal, hemiLight.direction );
- float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
- vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
- return irradiance;
- }
- #endif`,gye=`#ifdef USE_ENVMAP
- vec3 getIBLIrradiance( const in vec3 normal ) {
- #ifdef ENVMAP_TYPE_CUBE_UV
- vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
- vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );
- return PI * envMapColor.rgb * envMapIntensity;
- #else
- return vec3( 0.0 );
- #endif
- }
- vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
- #ifdef ENVMAP_TYPE_CUBE_UV
- vec3 reflectVec = reflect( - viewDir, normal );
- reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) );
- reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
- vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );
- return envMapColor.rgb * envMapIntensity;
- #else
- return vec3( 0.0 );
- #endif
- }
- #ifdef USE_ANISOTROPY
- vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
- #ifdef ENVMAP_TYPE_CUBE_UV
- vec3 bentNormal = cross( bitangent, viewDir );
- bentNormal = normalize( cross( bentNormal, bitangent ) );
- bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
- return getIBLRadiance( viewDir, bentNormal, roughness );
- #else
- return vec3( 0.0 );
- #endif
- }
- #endif
- #endif`,bye=`ToonMaterial material;
- material.diffuseColor = diffuseColor.rgb;`,xye=`varying vec3 vViewPosition;
- struct ToonMaterial {
- vec3 diffuseColor;
- };
- void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
- vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- #define RE_Direct RE_Direct_Toon
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,yye=`BlinnPhongMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularColor = specular;
- material.specularShininess = shininess;
- material.specularStrength = specularStrength;`,vye=`varying vec3 vViewPosition;
- struct BlinnPhongMaterial {
- vec3 diffuseColor;
- vec3 specularColor;
- float specularShininess;
- float specularStrength;
- };
- void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
- float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
- vec3 irradiance = dotNL * directLight.color;
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
- }
- void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- #define RE_Direct RE_Direct_BlinnPhong
- #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,wye=`PhysicalMaterial material;
- material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
- vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
- float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
- material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
- material.roughness = min( material.roughness, 1.0 );
- #ifdef IOR
- material.ior = ior;
- #ifdef USE_SPECULAR
- float specularIntensityFactor = specularIntensity;
- vec3 specularColorFactor = specularColor;
- #ifdef USE_SPECULAR_COLORMAP
- specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
- #endif
- material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
- #else
- float specularIntensityFactor = 1.0;
- vec3 specularColorFactor = vec3( 1.0 );
- material.specularF90 = 1.0;
- #endif
- material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
- #else
- material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
- material.specularF90 = 1.0;
- #endif
- #ifdef USE_CLEARCOAT
- material.clearcoat = clearcoat;
- material.clearcoatRoughness = clearcoatRoughness;
- material.clearcoatF0 = vec3( 0.04 );
- material.clearcoatF90 = 1.0;
- #ifdef USE_CLEARCOATMAP
- material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
- #endif
- material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
- material.clearcoatRoughness += geometryRoughness;
- material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
- #endif
- #ifdef USE_DISPERSION
- material.dispersion = dispersion;
- #endif
- #ifdef USE_IRIDESCENCE
- material.iridescence = iridescence;
- material.iridescenceIOR = iridescenceIOR;
- #ifdef USE_IRIDESCENCEMAP
- material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
- #else
- material.iridescenceThickness = iridescenceThicknessMaximum;
- #endif
- #endif
- #ifdef USE_SHEEN
- material.sheenColor = sheenColor;
- #ifdef USE_SHEEN_COLORMAP
- material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
- #endif
- material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
- #ifdef USE_SHEEN_ROUGHNESSMAP
- material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
- #endif
- #endif
- #ifdef USE_ANISOTROPY
- #ifdef USE_ANISOTROPYMAP
- mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
- vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
- vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
- #else
- vec2 anisotropyV = anisotropyVector;
- #endif
- material.anisotropy = length( anisotropyV );
- if( material.anisotropy == 0.0 ) {
- anisotropyV = vec2( 1.0, 0.0 );
- } else {
- anisotropyV /= material.anisotropy;
- material.anisotropy = saturate( material.anisotropy );
- }
- material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
- material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
- material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
- #endif`,Sye=`uniform sampler2D dfgLUT;
- struct PhysicalMaterial {
- vec3 diffuseColor;
- float roughness;
- vec3 specularColor;
- float specularF90;
- float dispersion;
- #ifdef USE_CLEARCOAT
- float clearcoat;
- float clearcoatRoughness;
- vec3 clearcoatF0;
- float clearcoatF90;
- #endif
- #ifdef USE_IRIDESCENCE
- float iridescence;
- float iridescenceIOR;
- float iridescenceThickness;
- vec3 iridescenceFresnel;
- vec3 iridescenceF0;
- #endif
- #ifdef USE_SHEEN
- vec3 sheenColor;
- float sheenRoughness;
- #endif
- #ifdef IOR
- float ior;
- #endif
- #ifdef USE_TRANSMISSION
- float transmission;
- float transmissionAlpha;
- float thickness;
- float attenuationDistance;
- vec3 attenuationColor;
- #endif
- #ifdef USE_ANISOTROPY
- float anisotropy;
- float alphaT;
- vec3 anisotropyT;
- vec3 anisotropyB;
- #endif
- };
- vec3 clearcoatSpecularDirect = vec3( 0.0 );
- vec3 clearcoatSpecularIndirect = vec3( 0.0 );
- vec3 sheenSpecularDirect = vec3( 0.0 );
- vec3 sheenSpecularIndirect = vec3(0.0 );
- vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
- float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
- float x2 = x * x;
- float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
- return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
- }
- float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
- float a2 = pow2( alpha );
- float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
- float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
- return 0.5 / max( gv + gl, EPSILON );
- }
- float D_GGX( const in float alpha, const in float dotNH ) {
- float a2 = pow2( alpha );
- float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
- return RECIPROCAL_PI * a2 / pow2( denom );
- }
- #ifdef USE_ANISOTROPY
- float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {
- float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
- float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
- float v = 0.5 / ( gv + gl );
- return saturate(v);
- }
- float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
- float a2 = alphaT * alphaB;
- highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
- highp float v2 = dot( v, v );
- float w2 = a2 / v2;
- return RECIPROCAL_PI * a2 * pow2 ( w2 );
- }
- #endif
- #ifdef USE_CLEARCOAT
- vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
- vec3 f0 = material.clearcoatF0;
- float f90 = material.clearcoatF90;
- float roughness = material.clearcoatRoughness;
- float alpha = pow2( roughness );
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNL = saturate( dot( normal, lightDir ) );
- float dotNV = saturate( dot( normal, viewDir ) );
- float dotNH = saturate( dot( normal, halfDir ) );
- float dotVH = saturate( dot( viewDir, halfDir ) );
- vec3 F = F_Schlick( f0, f90, dotVH );
- float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
- float D = D_GGX( alpha, dotNH );
- return F * ( V * D );
- }
- #endif
- vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
- vec3 f0 = material.specularColor;
- float f90 = material.specularF90;
- float roughness = material.roughness;
- float alpha = pow2( roughness );
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNL = saturate( dot( normal, lightDir ) );
- float dotNV = saturate( dot( normal, viewDir ) );
- float dotNH = saturate( dot( normal, halfDir ) );
- float dotVH = saturate( dot( viewDir, halfDir ) );
- vec3 F = F_Schlick( f0, f90, dotVH );
- #ifdef USE_IRIDESCENCE
- F = mix( F, material.iridescenceFresnel, material.iridescence );
- #endif
- #ifdef USE_ANISOTROPY
- float dotTL = dot( material.anisotropyT, lightDir );
- float dotTV = dot( material.anisotropyT, viewDir );
- float dotTH = dot( material.anisotropyT, halfDir );
- float dotBL = dot( material.anisotropyB, lightDir );
- float dotBV = dot( material.anisotropyB, viewDir );
- float dotBH = dot( material.anisotropyB, halfDir );
- float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
- float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
- #else
- float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
- float D = D_GGX( alpha, dotNH );
- #endif
- return F * ( V * D );
- }
- vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
- const float LUT_SIZE = 64.0;
- const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
- const float LUT_BIAS = 0.5 / LUT_SIZE;
- float dotNV = saturate( dot( N, V ) );
- vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
- uv = uv * LUT_SCALE + LUT_BIAS;
- return uv;
- }
- float LTC_ClippedSphereFormFactor( const in vec3 f ) {
- float l = length( f );
- return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
- }
- vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
- float x = dot( v1, v2 );
- float y = abs( x );
- float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
- float b = 3.4175940 + ( 4.1616724 + y ) * y;
- float v = a / b;
- float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
- return cross( v1, v2 ) * theta_sintheta;
- }
- vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
- vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
- vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
- vec3 lightNormal = cross( v1, v2 );
- if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
- vec3 T1, T2;
- T1 = normalize( V - N * dot( V, N ) );
- T2 = - cross( N, T1 );
- mat3 mat = mInv * transpose( mat3( T1, T2, N ) );
- vec3 coords[ 4 ];
- coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
- coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
- coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
- coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
- coords[ 0 ] = normalize( coords[ 0 ] );
- coords[ 1 ] = normalize( coords[ 1 ] );
- coords[ 2 ] = normalize( coords[ 2 ] );
- coords[ 3 ] = normalize( coords[ 3 ] );
- vec3 vectorFormFactor = vec3( 0.0 );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
- float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
- return vec3( result );
- }
- #if defined( USE_SHEEN )
- float D_Charlie( float roughness, float dotNH ) {
- float alpha = pow2( roughness );
- float invAlpha = 1.0 / alpha;
- float cos2h = dotNH * dotNH;
- float sin2h = max( 1.0 - cos2h, 0.0078125 );
- return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
- }
- float V_Neubelt( float dotNV, float dotNL ) {
- return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
- }
- vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNL = saturate( dot( normal, lightDir ) );
- float dotNV = saturate( dot( normal, viewDir ) );
- float dotNH = saturate( dot( normal, halfDir ) );
- float D = D_Charlie( sheenRoughness, dotNH );
- float V = V_Neubelt( dotNV, dotNL );
- return sheenColor * ( D * V );
- }
- #endif
- float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
- float dotNV = saturate( dot( normal, viewDir ) );
- float r2 = roughness * roughness;
- float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
- float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
- float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
- return saturate( DG * RECIPROCAL_PI );
- }
- vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
- float dotNV = saturate( dot( normal, viewDir ) );
- vec2 uv = vec2( roughness, dotNV );
- return texture2D( dfgLUT, uv ).rg;
- }
- vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
- vec2 fab = DFGApprox( normal, viewDir, roughness );
- return specularColor * fab.x + specularF90 * fab.y;
- }
- #ifdef USE_IRIDESCENCE
- void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
- #else
- void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
- #endif
- vec2 fab = DFGApprox( normal, viewDir, roughness );
- #ifdef USE_IRIDESCENCE
- vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
- #else
- vec3 Fr = specularColor;
- #endif
- vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
- float Ess = fab.x + fab.y;
- float Ems = 1.0 - Ess;
- vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
- singleScatter += FssEss;
- multiScatter += Fms * Ems;
- }
- vec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
- vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material );
- float dotNL = saturate( dot( normal, lightDir ) );
- float dotNV = saturate( dot( normal, viewDir ) );
- vec2 dfgV = DFGApprox( vec3(0.0, 0.0, 1.0), vec3(sqrt(1.0 - dotNV * dotNV), 0.0, dotNV), material.roughness );
- vec2 dfgL = DFGApprox( vec3(0.0, 0.0, 1.0), vec3(sqrt(1.0 - dotNL * dotNL), 0.0, dotNL), material.roughness );
- vec3 FssEss_V = material.specularColor * dfgV.x + material.specularF90 * dfgV.y;
- vec3 FssEss_L = material.specularColor * dfgL.x + material.specularF90 * dfgL.y;
- float Ess_V = dfgV.x + dfgV.y;
- float Ess_L = dfgL.x + dfgL.y;
- float Ems_V = 1.0 - Ess_V;
- float Ems_L = 1.0 - Ess_L;
- vec3 Favg = material.specularColor + ( 1.0 - material.specularColor ) * 0.047619;
- vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg * Favg + EPSILON );
- float compensationFactor = Ems_V * Ems_L;
- vec3 multiScatter = Fms * compensationFactor;
- return singleScatter + multiScatter;
- }
- #if NUM_RECT_AREA_LIGHTS > 0
- void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
- vec3 normal = geometryNormal;
- vec3 viewDir = geometryViewDir;
- vec3 position = geometryPosition;
- vec3 lightPos = rectAreaLight.position;
- vec3 halfWidth = rectAreaLight.halfWidth;
- vec3 halfHeight = rectAreaLight.halfHeight;
- vec3 lightColor = rectAreaLight.color;
- float roughness = material.roughness;
- vec3 rectCoords[ 4 ];
- rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
- rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
- rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
- vec2 uv = LTC_Uv( normal, viewDir, roughness );
- vec4 t1 = texture2D( ltc_1, uv );
- vec4 t2 = texture2D( ltc_2, uv );
- mat3 mInv = mat3(
- vec3( t1.x, 0, t1.y ),
- vec3( 0, 1, 0 ),
- vec3( t1.z, 0, t1.w )
- );
- vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
- reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
- reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
- }
- #endif
- void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
- float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
- vec3 irradiance = dotNL * directLight.color;
- #ifdef USE_CLEARCOAT
- float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
- vec3 ccIrradiance = dotNLcc * directLight.color;
- clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
- #endif
- #ifdef USE_SHEEN
- sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
- #endif
- reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material );
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
- #ifdef USE_CLEARCOAT
- clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
- #endif
- #ifdef USE_SHEEN
- sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
- #endif
- vec3 singleScattering = vec3( 0.0 );
- vec3 multiScattering = vec3( 0.0 );
- vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
- #ifdef USE_IRIDESCENCE
- computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
- #else
- computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
- #endif
- vec3 totalScattering = singleScattering + multiScattering;
- vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
- reflectedLight.indirectSpecular += radiance * singleScattering;
- reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
- reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
- }
- #define RE_Direct RE_Direct_Physical
- #define RE_Direct_RectArea RE_Direct_RectArea_Physical
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
- #define RE_IndirectSpecular RE_IndirectSpecular_Physical
- float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
- return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
- }`,_ye=`
- vec3 geometryPosition = - vViewPosition;
- vec3 geometryNormal = normal;
- vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
- vec3 geometryClearcoatNormal = vec3( 0.0 );
- #ifdef USE_CLEARCOAT
- geometryClearcoatNormal = clearcoatNormal;
- #endif
- #ifdef USE_IRIDESCENCE
- float dotNVi = saturate( dot( normal, geometryViewDir ) );
- if ( material.iridescenceThickness == 0.0 ) {
- material.iridescence = 0.0;
- } else {
- material.iridescence = saturate( material.iridescence );
- }
- if ( material.iridescence > 0.0 ) {
- material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
- material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
- }
- #endif
- IncidentLight directLight;
- #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
- PointLight pointLight;
- #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
- PointLightShadow pointLightShadow;
- #endif
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
- pointLight = pointLights[ i ];
- getPointLightInfo( pointLight, geometryPosition, directLight );
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
- pointLightShadow = pointLightShadows[ i ];
- directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
- #endif
- RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
- SpotLight spotLight;
- vec4 spotColor;
- vec3 spotLightCoord;
- bool inSpotLightMap;
- #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
- SpotLightShadow spotLightShadow;
- #endif
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
- spotLight = spotLights[ i ];
- getSpotLightInfo( spotLight, geometryPosition, directLight );
- #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
- #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
- #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
- #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
- #else
- #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
- #endif
- #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
- spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
- inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
- spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
- directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
- #endif
- #undef SPOT_LIGHT_MAP_INDEX
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
- spotLightShadow = spotLightShadows[ i ];
- directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
- #endif
- RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
- DirectionalLight directionalLight;
- #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
- DirectionalLightShadow directionalLightShadow;
- #endif
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
- directionalLight = directionalLights[ i ];
- getDirectionalLightInfo( directionalLight, directLight );
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
- directionalLightShadow = directionalLightShadows[ i ];
- directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
- #endif
- RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
- RectAreaLight rectAreaLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
- rectAreaLight = rectAreaLights[ i ];
- RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if defined( RE_IndirectDiffuse )
- vec3 iblIrradiance = vec3( 0.0 );
- vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
- #if defined( USE_LIGHT_PROBES )
- irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
- #endif
- #if ( NUM_HEMI_LIGHTS > 0 )
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
- irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
- }
- #pragma unroll_loop_end
- #endif
- #endif
- #if defined( RE_IndirectSpecular )
- vec3 radiance = vec3( 0.0 );
- vec3 clearcoatRadiance = vec3( 0.0 );
- #endif`,Nye=`#if defined( RE_IndirectDiffuse )
- #ifdef USE_LIGHTMAP
- vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
- vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
- irradiance += lightMapIrradiance;
- #endif
- #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
- iblIrradiance += getIBLIrradiance( geometryNormal );
- #endif
- #endif
- #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
- #ifdef USE_ANISOTROPY
- radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
- #else
- radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
- #endif
- #ifdef USE_CLEARCOAT
- clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
- #endif
- #endif`,Cye=`#if defined( RE_IndirectDiffuse )
- RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- #endif
- #if defined( RE_IndirectSpecular )
- RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- #endif`,kye=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
- gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
- #endif`,Aye=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
- uniform float logDepthBufFC;
- varying float vFragDepth;
- varying float vIsPerspective;
- #endif`,Tye=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
- varying float vFragDepth;
- varying float vIsPerspective;
- #endif`,Mye=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
- vFragDepth = 1.0 + gl_Position.w;
- vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
- #endif`,Pye=`#ifdef USE_MAP
- vec4 sampledDiffuseColor = texture2D( map, vMapUv );
- #ifdef DECODE_VIDEO_TEXTURE
- sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
- #endif
- diffuseColor *= sampledDiffuseColor;
- #endif`,Eye=`#ifdef USE_MAP
- uniform sampler2D map;
- #endif`,jye=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
- #if defined( USE_POINTS_UV )
- vec2 uv = vUv;
- #else
- vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
- #endif
- #endif
- #ifdef USE_MAP
- diffuseColor *= texture2D( map, uv );
- #endif
- #ifdef USE_ALPHAMAP
- diffuseColor.a *= texture2D( alphaMap, uv ).g;
- #endif`,Dye=`#if defined( USE_POINTS_UV )
- varying vec2 vUv;
- #else
- #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
- uniform mat3 uvTransform;
- #endif
- #endif
- #ifdef USE_MAP
- uniform sampler2D map;
- #endif
- #ifdef USE_ALPHAMAP
- uniform sampler2D alphaMap;
- #endif`,Rye=`float metalnessFactor = metalness;
- #ifdef USE_METALNESSMAP
- vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
- metalnessFactor *= texelMetalness.b;
- #endif`,Fye=`#ifdef USE_METALNESSMAP
- uniform sampler2D metalnessMap;
- #endif`,Lye=`#ifdef USE_INSTANCING_MORPH
- float morphTargetInfluences[ MORPHTARGETS_COUNT ];
- float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
- morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
- }
- #endif`,Oye=`#if defined( USE_MORPHCOLORS )
- vColor *= morphTargetBaseInfluence;
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
- #if defined( USE_COLOR_ALPHA )
- if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
- #elif defined( USE_COLOR )
- if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
- #endif
- }
- #endif`,Iye=`#ifdef USE_MORPHNORMALS
- objectNormal *= morphTargetBaseInfluence;
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
- if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
- }
- #endif`,zye=`#ifdef USE_MORPHTARGETS
- #ifndef USE_INSTANCING_MORPH
- uniform float morphTargetBaseInfluence;
- uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
- #endif
- uniform sampler2DArray morphTargetsTexture;
- uniform ivec2 morphTargetsTextureSize;
- vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
- int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
- int y = texelIndex / morphTargetsTextureSize.x;
- int x = texelIndex - y * morphTargetsTextureSize.x;
- ivec3 morphUV = ivec3( x, y, morphTargetIndex );
- return texelFetch( morphTargetsTexture, morphUV, 0 );
- }
- #endif`,Uye=`#ifdef USE_MORPHTARGETS
- transformed *= morphTargetBaseInfluence;
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
- if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
- }
- #endif`,Bye=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
- #ifdef FLAT_SHADED
- vec3 fdx = dFdx( vViewPosition );
- vec3 fdy = dFdy( vViewPosition );
- vec3 normal = normalize( cross( fdx, fdy ) );
- #else
- vec3 normal = normalize( vNormal );
- #ifdef DOUBLE_SIDED
- normal *= faceDirection;
- #endif
- #endif
- #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
- #ifdef USE_TANGENT
- mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
- #else
- mat3 tbn = getTangentFrame( - vViewPosition, normal,
- #if defined( USE_NORMALMAP )
- vNormalMapUv
- #elif defined( USE_CLEARCOAT_NORMALMAP )
- vClearcoatNormalMapUv
- #else
- vUv
- #endif
- );
- #endif
- #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
- tbn[0] *= faceDirection;
- tbn[1] *= faceDirection;
- #endif
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- #ifdef USE_TANGENT
- mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
- #else
- mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
- #endif
- #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
- tbn2[0] *= faceDirection;
- tbn2[1] *= faceDirection;
- #endif
- #endif
- vec3 nonPerturbedNormal = normal;`,Hye=`#ifdef USE_NORMALMAP_OBJECTSPACE
- normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
- #ifdef FLIP_SIDED
- normal = - normal;
- #endif
- #ifdef DOUBLE_SIDED
- normal = normal * faceDirection;
- #endif
- normal = normalize( normalMatrix * normal );
- #elif defined( USE_NORMALMAP_TANGENTSPACE )
- vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
- mapN.xy *= normalScale;
- normal = normalize( tbn * mapN );
- #elif defined( USE_BUMPMAP )
- normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
- #endif`,$ye=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,Vye=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,qye=`#ifndef FLAT_SHADED
- vNormal = normalize( transformedNormal );
- #ifdef USE_TANGENT
- vTangent = normalize( transformedTangent );
- vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
- #endif
- #endif`,Gye=`#ifdef USE_NORMALMAP
- uniform sampler2D normalMap;
- uniform vec2 normalScale;
- #endif
- #ifdef USE_NORMALMAP_OBJECTSPACE
- uniform mat3 normalMatrix;
- #endif
- #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
- mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
- vec3 q0 = dFdx( eye_pos.xyz );
- vec3 q1 = dFdy( eye_pos.xyz );
- vec2 st0 = dFdx( uv.st );
- vec2 st1 = dFdy( uv.st );
- vec3 N = surf_norm;
- vec3 q1perp = cross( q1, N );
- vec3 q0perp = cross( N, q0 );
- vec3 T = q1perp * st0.x + q0perp * st1.x;
- vec3 B = q1perp * st0.y + q0perp * st1.y;
- float det = max( dot( T, T ), dot( B, B ) );
- float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
- return mat3( T * scale, B * scale, N );
- }
- #endif`,Wye=`#ifdef USE_CLEARCOAT
- vec3 clearcoatNormal = nonPerturbedNormal;
- #endif`,Kye=`#ifdef USE_CLEARCOAT_NORMALMAP
- vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
- clearcoatMapN.xy *= clearcoatNormalScale;
- clearcoatNormal = normalize( tbn2 * clearcoatMapN );
- #endif`,Xye=`#ifdef USE_CLEARCOATMAP
- uniform sampler2D clearcoatMap;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- uniform sampler2D clearcoatNormalMap;
- uniform vec2 clearcoatNormalScale;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- uniform sampler2D clearcoatRoughnessMap;
- #endif`,Yye=`#ifdef USE_IRIDESCENCEMAP
- uniform sampler2D iridescenceMap;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- uniform sampler2D iridescenceThicknessMap;
- #endif`,Qye=`#ifdef OPAQUE
- diffuseColor.a = 1.0;
- #endif
- #ifdef USE_TRANSMISSION
- diffuseColor.a *= material.transmissionAlpha;
- #endif
- gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Zye=`vec3 packNormalToRGB( const in vec3 normal ) {
- return normalize( normal ) * 0.5 + 0.5;
- }
- vec3 unpackRGBToNormal( const in vec3 rgb ) {
- return 2.0 * rgb.xyz - 1.0;
- }
- const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;
- const float Inv255 = 1. / 255.;
- const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );
- const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );
- const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );
- const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );
- vec4 packDepthToRGBA( const in float v ) {
- if( v <= 0.0 )
- return vec4( 0., 0., 0., 0. );
- if( v >= 1.0 )
- return vec4( 1., 1., 1., 1. );
- float vuf;
- float af = modf( v * PackFactors.a, vuf );
- float bf = modf( vuf * ShiftRight8, vuf );
- float gf = modf( vuf * ShiftRight8, vuf );
- return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );
- }
- vec3 packDepthToRGB( const in float v ) {
- if( v <= 0.0 )
- return vec3( 0., 0., 0. );
- if( v >= 1.0 )
- return vec3( 1., 1., 1. );
- float vuf;
- float bf = modf( v * PackFactors.b, vuf );
- float gf = modf( vuf * ShiftRight8, vuf );
- return vec3( vuf * Inv255, gf * PackUpscale, bf );
- }
- vec2 packDepthToRG( const in float v ) {
- if( v <= 0.0 )
- return vec2( 0., 0. );
- if( v >= 1.0 )
- return vec2( 1., 1. );
- float vuf;
- float gf = modf( v * 256., vuf );
- return vec2( vuf * Inv255, gf );
- }
- float unpackRGBAToDepth( const in vec4 v ) {
- return dot( v, UnpackFactors4 );
- }
- float unpackRGBToDepth( const in vec3 v ) {
- return dot( v, UnpackFactors3 );
- }
- float unpackRGToDepth( const in vec2 v ) {
- return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;
- }
- vec4 pack2HalfToRGBA( const in vec2 v ) {
- vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
- return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
- }
- vec2 unpackRGBATo2Half( const in vec4 v ) {
- return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
- }
- float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
- return ( viewZ + near ) / ( near - far );
- }
- float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
- return depth * ( near - far ) - near;
- }
- float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
- return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
- }
- float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
- return ( near * far ) / ( ( far - near ) * depth - far );
- }`,Jye=`#ifdef PREMULTIPLIED_ALPHA
- gl_FragColor.rgb *= gl_FragColor.a;
- #endif`,e0e=`vec4 mvPosition = vec4( transformed, 1.0 );
- #ifdef USE_BATCHING
- mvPosition = batchingMatrix * mvPosition;
- #endif
- #ifdef USE_INSTANCING
- mvPosition = instanceMatrix * mvPosition;
- #endif
- mvPosition = modelViewMatrix * mvPosition;
- gl_Position = projectionMatrix * mvPosition;`,t0e=`#ifdef DITHERING
- gl_FragColor.rgb = dithering( gl_FragColor.rgb );
- #endif`,n0e=`#ifdef DITHERING
- vec3 dithering( vec3 color ) {
- float grid_position = rand( gl_FragCoord.xy );
- vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
- dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
- return color + dither_shift_RGB;
- }
- #endif`,r0e=`float roughnessFactor = roughness;
- #ifdef USE_ROUGHNESSMAP
- vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
- roughnessFactor *= texelRoughness.g;
- #endif`,a0e=`#ifdef USE_ROUGHNESSMAP
- uniform sampler2D roughnessMap;
- #endif`,i0e=`#if NUM_SPOT_LIGHT_COORDS > 0
- varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
- #endif
- #if NUM_SPOT_LIGHT_MAPS > 0
- uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
- #endif
- #ifdef USE_SHADOWMAP
- #if NUM_DIR_LIGHT_SHADOWS > 0
- uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
- varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
- struct DirectionalLightShadow {
- float shadowIntensity;
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
- #endif
- #if NUM_SPOT_LIGHT_SHADOWS > 0
- uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
- struct SpotLightShadow {
- float shadowIntensity;
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
- varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
- struct PointLightShadow {
- float shadowIntensity;
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- float shadowCameraNear;
- float shadowCameraFar;
- };
- uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
- #endif
- float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
- float depth = unpackRGBAToDepth( texture2D( depths, uv ) );
- #ifdef USE_REVERSED_DEPTH_BUFFER
- return step( depth, compare );
- #else
- return step( compare, depth );
- #endif
- }
- vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
- return unpackRGBATo2Half( texture2D( shadow, uv ) );
- }
- float VSMShadow( sampler2D shadow, vec2 uv, float compare ) {
- float occlusion = 1.0;
- vec2 distribution = texture2DDistribution( shadow, uv );
- #ifdef USE_REVERSED_DEPTH_BUFFER
- float hard_shadow = step( distribution.x, compare );
- #else
- float hard_shadow = step( compare, distribution.x );
- #endif
- if ( hard_shadow != 1.0 ) {
- float distance = compare - distribution.x;
- float variance = max( 0.00000, distribution.y * distribution.y );
- float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );
- }
- return occlusion;
- }
- float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
- float shadow = 1.0;
- shadowCoord.xyz /= shadowCoord.w;
- shadowCoord.z += shadowBias;
- bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
- bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
- if ( frustumTest ) {
- #if defined( SHADOWMAP_TYPE_PCF )
- vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
- float dx0 = - texelSize.x * shadowRadius;
- float dy0 = - texelSize.y * shadowRadius;
- float dx1 = + texelSize.x * shadowRadius;
- float dy1 = + texelSize.y * shadowRadius;
- float dx2 = dx0 / 2.0;
- float dy2 = dy0 / 2.0;
- float dx3 = dx1 / 2.0;
- float dy3 = dy1 / 2.0;
- shadow = (
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
- ) * ( 1.0 / 17.0 );
- #elif defined( SHADOWMAP_TYPE_PCF_SOFT )
- vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
- float dx = texelSize.x;
- float dy = texelSize.y;
- vec2 uv = shadowCoord.xy;
- vec2 f = fract( uv * shadowMapSize + 0.5 );
- uv -= f * texelSize;
- shadow = (
- texture2DCompare( shadowMap, uv, shadowCoord.z ) +
- texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
- texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
- mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
- f.x ) +
- mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
- f.x ) +
- mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
- f.y ) +
- mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
- f.y ) +
- mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
- f.x ),
- mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
- f.x ),
- f.y )
- ) * ( 1.0 / 9.0 );
- #elif defined( SHADOWMAP_TYPE_VSM )
- shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
- #else
- shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
- #endif
- }
- return mix( 1.0, shadow, shadowIntensity );
- }
- vec2 cubeToUV( vec3 v, float texelSizeY ) {
- vec3 absV = abs( v );
- float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
- absV *= scaleToCube;
- v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
- vec2 planar = v.xy;
- float almostATexel = 1.5 * texelSizeY;
- float almostOne = 1.0 - almostATexel;
- if ( absV.z >= almostOne ) {
- if ( v.z > 0.0 )
- planar.x = 4.0 - v.x;
- } else if ( absV.x >= almostOne ) {
- float signX = sign( v.x );
- planar.x = v.z * signX + 2.0 * signX;
- } else if ( absV.y >= almostOne ) {
- float signY = sign( v.y );
- planar.x = v.x + 2.0 * signY + 2.0;
- planar.y = v.z * signY - 2.0;
- }
- return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
- }
- float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
- float shadow = 1.0;
- vec3 lightToPosition = shadowCoord.xyz;
-
- float lightToPositionLength = length( lightToPosition );
- if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {
- float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
- vec3 bd3D = normalize( lightToPosition );
- vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
- #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
- vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
- shadow = (
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
- ) * ( 1.0 / 9.0 );
- #else
- shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
- #endif
- }
- return mix( 1.0, shadow, shadowIntensity );
- }
- #endif`,s0e=`#if NUM_SPOT_LIGHT_COORDS > 0
- uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
- varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
- #endif
- #ifdef USE_SHADOWMAP
- #if NUM_DIR_LIGHT_SHADOWS > 0
- uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
- varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
- struct DirectionalLightShadow {
- float shadowIntensity;
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
- #endif
- #if NUM_SPOT_LIGHT_SHADOWS > 0
- struct SpotLightShadow {
- float shadowIntensity;
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
- varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
- struct PointLightShadow {
- float shadowIntensity;
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- float shadowCameraNear;
- float shadowCameraFar;
- };
- uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
- #endif
- #endif`,o0e=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
- vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
- vec4 shadowWorldPosition;
- #endif
- #if defined( USE_SHADOWMAP )
- #if NUM_DIR_LIGHT_SHADOWS > 0
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
- shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
- vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
- }
- #pragma unroll_loop_end
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
- shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
- vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
- }
- #pragma unroll_loop_end
- #endif
- #endif
- #if NUM_SPOT_LIGHT_COORDS > 0
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
- shadowWorldPosition = worldPosition;
- #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
- shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
- #endif
- vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
- }
- #pragma unroll_loop_end
- #endif`,l0e=`float getShadowMask() {
- float shadow = 1.0;
- #ifdef USE_SHADOWMAP
- #if NUM_DIR_LIGHT_SHADOWS > 0
- DirectionalLightShadow directionalLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
- directionalLight = directionalLightShadows[ i ];
- shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
- }
- #pragma unroll_loop_end
- #endif
- #if NUM_SPOT_LIGHT_SHADOWS > 0
- SpotLightShadow spotLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
- spotLight = spotLightShadows[ i ];
- shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
- }
- #pragma unroll_loop_end
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- PointLightShadow pointLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
- pointLight = pointLightShadows[ i ];
- shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
- }
- #pragma unroll_loop_end
- #endif
- #endif
- return shadow;
- }`,c0e=`#ifdef USE_SKINNING
- mat4 boneMatX = getBoneMatrix( skinIndex.x );
- mat4 boneMatY = getBoneMatrix( skinIndex.y );
- mat4 boneMatZ = getBoneMatrix( skinIndex.z );
- mat4 boneMatW = getBoneMatrix( skinIndex.w );
- #endif`,d0e=`#ifdef USE_SKINNING
- uniform mat4 bindMatrix;
- uniform mat4 bindMatrixInverse;
- uniform highp sampler2D boneTexture;
- mat4 getBoneMatrix( const in float i ) {
- int size = textureSize( boneTexture, 0 ).x;
- int j = int( i ) * 4;
- int x = j % size;
- int y = j / size;
- vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
- vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
- vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
- vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
- return mat4( v1, v2, v3, v4 );
- }
- #endif`,u0e=`#ifdef USE_SKINNING
- vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
- vec4 skinned = vec4( 0.0 );
- skinned += boneMatX * skinVertex * skinWeight.x;
- skinned += boneMatY * skinVertex * skinWeight.y;
- skinned += boneMatZ * skinVertex * skinWeight.z;
- skinned += boneMatW * skinVertex * skinWeight.w;
- transformed = ( bindMatrixInverse * skinned ).xyz;
- #endif`,h0e=`#ifdef USE_SKINNING
- mat4 skinMatrix = mat4( 0.0 );
- skinMatrix += skinWeight.x * boneMatX;
- skinMatrix += skinWeight.y * boneMatY;
- skinMatrix += skinWeight.z * boneMatZ;
- skinMatrix += skinWeight.w * boneMatW;
- skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
- objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
- #ifdef USE_TANGENT
- objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
- #endif
- #endif`,m0e=`float specularStrength;
- #ifdef USE_SPECULARMAP
- vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
- specularStrength = texelSpecular.r;
- #else
- specularStrength = 1.0;
- #endif`,f0e=`#ifdef USE_SPECULARMAP
- uniform sampler2D specularMap;
- #endif`,p0e=`#if defined( TONE_MAPPING )
- gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
- #endif`,g0e=`#ifndef saturate
- #define saturate( a ) clamp( a, 0.0, 1.0 )
- #endif
- uniform float toneMappingExposure;
- vec3 LinearToneMapping( vec3 color ) {
- return saturate( toneMappingExposure * color );
- }
- vec3 ReinhardToneMapping( vec3 color ) {
- color *= toneMappingExposure;
- return saturate( color / ( vec3( 1.0 ) + color ) );
- }
- vec3 CineonToneMapping( vec3 color ) {
- color *= toneMappingExposure;
- color = max( vec3( 0.0 ), color - 0.004 );
- return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
- }
- vec3 RRTAndODTFit( vec3 v ) {
- vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
- vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
- return a / b;
- }
- vec3 ACESFilmicToneMapping( vec3 color ) {
- const mat3 ACESInputMat = mat3(
- vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
- vec3( 0.04823, 0.01566, 0.83777 )
- );
- const mat3 ACESOutputMat = mat3(
- vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
- vec3( -0.07367, -0.00605, 1.07602 )
- );
- color *= toneMappingExposure / 0.6;
- color = ACESInputMat * color;
- color = RRTAndODTFit( color );
- color = ACESOutputMat * color;
- return saturate( color );
- }
- const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(
- vec3( 1.6605, - 0.1246, - 0.0182 ),
- vec3( - 0.5876, 1.1329, - 0.1006 ),
- vec3( - 0.0728, - 0.0083, 1.1187 )
- );
- const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(
- vec3( 0.6274, 0.0691, 0.0164 ),
- vec3( 0.3293, 0.9195, 0.0880 ),
- vec3( 0.0433, 0.0113, 0.8956 )
- );
- vec3 agxDefaultContrastApprox( vec3 x ) {
- vec3 x2 = x * x;
- vec3 x4 = x2 * x2;
- return + 15.5 * x4 * x2
- - 40.14 * x4 * x
- + 31.96 * x4
- - 6.868 * x2 * x
- + 0.4298 * x2
- + 0.1191 * x
- - 0.00232;
- }
- vec3 AgXToneMapping( vec3 color ) {
- const mat3 AgXInsetMatrix = mat3(
- vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),
- vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),
- vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )
- );
- const mat3 AgXOutsetMatrix = mat3(
- vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),
- vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),
- vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )
- );
- const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069;
- color *= toneMappingExposure;
- color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;
- color = AgXInsetMatrix * color;
- color = max( color, 1e-10 ); color = log2( color );
- color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );
- color = clamp( color, 0.0, 1.0 );
- color = agxDefaultContrastApprox( color );
- color = AgXOutsetMatrix * color;
- color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );
- color = LINEAR_REC2020_TO_LINEAR_SRGB * color;
- color = clamp( color, 0.0, 1.0 );
- return color;
- }
- vec3 NeutralToneMapping( vec3 color ) {
- const float StartCompression = 0.8 - 0.04;
- const float Desaturation = 0.15;
- color *= toneMappingExposure;
- float x = min( color.r, min( color.g, color.b ) );
- float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;
- color -= offset;
- float peak = max( color.r, max( color.g, color.b ) );
- if ( peak < StartCompression ) return color;
- float d = 1. - StartCompression;
- float newPeak = 1. - d * d / ( peak + d - StartCompression );
- color *= newPeak / peak;
- float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
- return mix( color, vec3( newPeak ), g );
- }
- vec3 CustomToneMapping( vec3 color ) { return color; }`,b0e=`#ifdef USE_TRANSMISSION
- material.transmission = transmission;
- material.transmissionAlpha = 1.0;
- material.thickness = thickness;
- material.attenuationDistance = attenuationDistance;
- material.attenuationColor = attenuationColor;
- #ifdef USE_TRANSMISSIONMAP
- material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
- #endif
- #ifdef USE_THICKNESSMAP
- material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
- #endif
- vec3 pos = vWorldPosition;
- vec3 v = normalize( cameraPosition - pos );
- vec3 n = inverseTransformDirection( normal, viewMatrix );
- vec4 transmitted = getIBLVolumeRefraction(
- n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
- pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,
- material.attenuationColor, material.attenuationDistance );
- material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
- totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
- #endif`,x0e=`#ifdef USE_TRANSMISSION
- uniform float transmission;
- uniform float thickness;
- uniform float attenuationDistance;
- uniform vec3 attenuationColor;
- #ifdef USE_TRANSMISSIONMAP
- uniform sampler2D transmissionMap;
- #endif
- #ifdef USE_THICKNESSMAP
- uniform sampler2D thicknessMap;
- #endif
- uniform vec2 transmissionSamplerSize;
- uniform sampler2D transmissionSamplerMap;
- uniform mat4 modelMatrix;
- uniform mat4 projectionMatrix;
- varying vec3 vWorldPosition;
- float w0( float a ) {
- return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
- }
- float w1( float a ) {
- return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
- }
- float w2( float a ){
- return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
- }
- float w3( float a ) {
- return ( 1.0 / 6.0 ) * ( a * a * a );
- }
- float g0( float a ) {
- return w0( a ) + w1( a );
- }
- float g1( float a ) {
- return w2( a ) + w3( a );
- }
- float h0( float a ) {
- return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
- }
- float h1( float a ) {
- return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
- }
- vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
- uv = uv * texelSize.zw + 0.5;
- vec2 iuv = floor( uv );
- vec2 fuv = fract( uv );
- float g0x = g0( fuv.x );
- float g1x = g1( fuv.x );
- float h0x = h0( fuv.x );
- float h1x = h1( fuv.x );
- float h0y = h0( fuv.y );
- float h1y = h1( fuv.y );
- vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
- vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
- vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
- vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
- return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
- g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
- }
- vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
- vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
- vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
- vec2 fLodSizeInv = 1.0 / fLodSize;
- vec2 cLodSizeInv = 1.0 / cLodSize;
- vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
- vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
- return mix( fSample, cSample, fract( lod ) );
- }
- vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
- vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
- vec3 modelScale;
- modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
- modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
- modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
- return normalize( refractionVector ) * thickness * modelScale;
- }
- float applyIorToRoughness( const in float roughness, const in float ior ) {
- return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
- }
- vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
- float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
- return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
- }
- vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
- if ( isinf( attenuationDistance ) ) {
- return vec3( 1.0 );
- } else {
- vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
- vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
- }
- }
- vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
- const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
- const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,
- const in vec3 attenuationColor, const in float attenuationDistance ) {
- vec4 transmittedLight;
- vec3 transmittance;
- #ifdef USE_DISPERSION
- float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;
- vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );
- for ( int i = 0; i < 3; i ++ ) {
- vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );
- vec3 refractedRayExit = position + transmissionRay;
- vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
- vec2 refractionCoords = ndcPos.xy / ndcPos.w;
- refractionCoords += 1.0;
- refractionCoords /= 2.0;
- vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );
- transmittedLight[ i ] = transmissionSample[ i ];
- transmittedLight.a += transmissionSample.a;
- transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];
- }
- transmittedLight.a /= 3.0;
- #else
- vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
- vec3 refractedRayExit = position + transmissionRay;
- vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
- vec2 refractionCoords = ndcPos.xy / ndcPos.w;
- refractionCoords += 1.0;
- refractionCoords /= 2.0;
- transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
- transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
- #endif
- vec3 attenuatedColor = transmittance * transmittedLight.rgb;
- vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
- float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
- return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
- }
- #endif`,y0e=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
- varying vec2 vUv;
- #endif
- #ifdef USE_MAP
- varying vec2 vMapUv;
- #endif
- #ifdef USE_ALPHAMAP
- varying vec2 vAlphaMapUv;
- #endif
- #ifdef USE_LIGHTMAP
- varying vec2 vLightMapUv;
- #endif
- #ifdef USE_AOMAP
- varying vec2 vAoMapUv;
- #endif
- #ifdef USE_BUMPMAP
- varying vec2 vBumpMapUv;
- #endif
- #ifdef USE_NORMALMAP
- varying vec2 vNormalMapUv;
- #endif
- #ifdef USE_EMISSIVEMAP
- varying vec2 vEmissiveMapUv;
- #endif
- #ifdef USE_METALNESSMAP
- varying vec2 vMetalnessMapUv;
- #endif
- #ifdef USE_ROUGHNESSMAP
- varying vec2 vRoughnessMapUv;
- #endif
- #ifdef USE_ANISOTROPYMAP
- varying vec2 vAnisotropyMapUv;
- #endif
- #ifdef USE_CLEARCOATMAP
- varying vec2 vClearcoatMapUv;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- varying vec2 vClearcoatNormalMapUv;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- varying vec2 vClearcoatRoughnessMapUv;
- #endif
- #ifdef USE_IRIDESCENCEMAP
- varying vec2 vIridescenceMapUv;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- varying vec2 vIridescenceThicknessMapUv;
- #endif
- #ifdef USE_SHEEN_COLORMAP
- varying vec2 vSheenColorMapUv;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- varying vec2 vSheenRoughnessMapUv;
- #endif
- #ifdef USE_SPECULARMAP
- varying vec2 vSpecularMapUv;
- #endif
- #ifdef USE_SPECULAR_COLORMAP
- varying vec2 vSpecularColorMapUv;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- varying vec2 vSpecularIntensityMapUv;
- #endif
- #ifdef USE_TRANSMISSIONMAP
- uniform mat3 transmissionMapTransform;
- varying vec2 vTransmissionMapUv;
- #endif
- #ifdef USE_THICKNESSMAP
- uniform mat3 thicknessMapTransform;
- varying vec2 vThicknessMapUv;
- #endif`,v0e=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
- varying vec2 vUv;
- #endif
- #ifdef USE_MAP
- uniform mat3 mapTransform;
- varying vec2 vMapUv;
- #endif
- #ifdef USE_ALPHAMAP
- uniform mat3 alphaMapTransform;
- varying vec2 vAlphaMapUv;
- #endif
- #ifdef USE_LIGHTMAP
- uniform mat3 lightMapTransform;
- varying vec2 vLightMapUv;
- #endif
- #ifdef USE_AOMAP
- uniform mat3 aoMapTransform;
- varying vec2 vAoMapUv;
- #endif
- #ifdef USE_BUMPMAP
- uniform mat3 bumpMapTransform;
- varying vec2 vBumpMapUv;
- #endif
- #ifdef USE_NORMALMAP
- uniform mat3 normalMapTransform;
- varying vec2 vNormalMapUv;
- #endif
- #ifdef USE_DISPLACEMENTMAP
- uniform mat3 displacementMapTransform;
- varying vec2 vDisplacementMapUv;
- #endif
- #ifdef USE_EMISSIVEMAP
- uniform mat3 emissiveMapTransform;
- varying vec2 vEmissiveMapUv;
- #endif
- #ifdef USE_METALNESSMAP
- uniform mat3 metalnessMapTransform;
- varying vec2 vMetalnessMapUv;
- #endif
- #ifdef USE_ROUGHNESSMAP
- uniform mat3 roughnessMapTransform;
- varying vec2 vRoughnessMapUv;
- #endif
- #ifdef USE_ANISOTROPYMAP
- uniform mat3 anisotropyMapTransform;
- varying vec2 vAnisotropyMapUv;
- #endif
- #ifdef USE_CLEARCOATMAP
- uniform mat3 clearcoatMapTransform;
- varying vec2 vClearcoatMapUv;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- uniform mat3 clearcoatNormalMapTransform;
- varying vec2 vClearcoatNormalMapUv;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- uniform mat3 clearcoatRoughnessMapTransform;
- varying vec2 vClearcoatRoughnessMapUv;
- #endif
- #ifdef USE_SHEEN_COLORMAP
- uniform mat3 sheenColorMapTransform;
- varying vec2 vSheenColorMapUv;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- uniform mat3 sheenRoughnessMapTransform;
- varying vec2 vSheenRoughnessMapUv;
- #endif
- #ifdef USE_IRIDESCENCEMAP
- uniform mat3 iridescenceMapTransform;
- varying vec2 vIridescenceMapUv;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- uniform mat3 iridescenceThicknessMapTransform;
- varying vec2 vIridescenceThicknessMapUv;
- #endif
- #ifdef USE_SPECULARMAP
- uniform mat3 specularMapTransform;
- varying vec2 vSpecularMapUv;
- #endif
- #ifdef USE_SPECULAR_COLORMAP
- uniform mat3 specularColorMapTransform;
- varying vec2 vSpecularColorMapUv;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- uniform mat3 specularIntensityMapTransform;
- varying vec2 vSpecularIntensityMapUv;
- #endif
- #ifdef USE_TRANSMISSIONMAP
- uniform mat3 transmissionMapTransform;
- varying vec2 vTransmissionMapUv;
- #endif
- #ifdef USE_THICKNESSMAP
- uniform mat3 thicknessMapTransform;
- varying vec2 vThicknessMapUv;
- #endif`,w0e=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
- vUv = vec3( uv, 1 ).xy;
- #endif
- #ifdef USE_MAP
- vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_ALPHAMAP
- vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_LIGHTMAP
- vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_AOMAP
- vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_BUMPMAP
- vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_NORMALMAP
- vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_DISPLACEMENTMAP
- vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_EMISSIVEMAP
- vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_METALNESSMAP
- vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_ROUGHNESSMAP
- vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_ANISOTROPYMAP
- vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_CLEARCOATMAP
- vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_IRIDESCENCEMAP
- vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SHEEN_COLORMAP
- vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SPECULARMAP
- vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SPECULAR_COLORMAP
- vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_TRANSMISSIONMAP
- vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_THICKNESSMAP
- vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
- #endif`,S0e=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
- vec4 worldPosition = vec4( transformed, 1.0 );
- #ifdef USE_BATCHING
- worldPosition = batchingMatrix * worldPosition;
- #endif
- #ifdef USE_INSTANCING
- worldPosition = instanceMatrix * worldPosition;
- #endif
- worldPosition = modelMatrix * worldPosition;
- #endif`;const _0e=`varying vec2 vUv;
- uniform mat3 uvTransform;
- void main() {
- vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
- gl_Position = vec4( position.xy, 1.0, 1.0 );
- }`,N0e=`uniform sampler2D t2D;
- uniform float backgroundIntensity;
- varying vec2 vUv;
- void main() {
- vec4 texColor = texture2D( t2D, vUv );
- #ifdef DECODE_VIDEO_TEXTURE
- texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );
- #endif
- texColor.rgb *= backgroundIntensity;
- gl_FragColor = texColor;
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,C0e=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,k0e=`#ifdef ENVMAP_TYPE_CUBE
- uniform samplerCube envMap;
- #elif defined( ENVMAP_TYPE_CUBE_UV )
- uniform sampler2D envMap;
- #endif
- uniform float flipEnvMap;
- uniform float backgroundBlurriness;
- uniform float backgroundIntensity;
- uniform mat3 backgroundRotation;
- varying vec3 vWorldDirection;
- #include <cube_uv_reflection_fragment>
- void main() {
- #ifdef ENVMAP_TYPE_CUBE
- vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
- #elif defined( ENVMAP_TYPE_CUBE_UV )
- vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );
- #else
- vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
- #endif
- texColor.rgb *= backgroundIntensity;
- gl_FragColor = texColor;
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,A0e=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,T0e=`uniform samplerCube tCube;
- uniform float tFlip;
- uniform float opacity;
- varying vec3 vWorldDirection;
- void main() {
- vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
- gl_FragColor = texColor;
- gl_FragColor.a *= opacity;
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,M0e=`#include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- varying vec2 vHighPrecisionZW;
- void main() {
- #include <uv_vertex>
- #include <batching_vertex>
- #include <skinbase_vertex>
- #include <morphinstance_vertex>
- #ifdef USE_DISPLACEMENTMAP
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinnormal_vertex>
- #endif
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vHighPrecisionZW = gl_Position.zw;
- }`,P0e=`#if DEPTH_PACKING == 3200
- uniform float opacity;
- #endif
- #include <common>
- #include <packing>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- varying vec2 vHighPrecisionZW;
- void main() {
- vec4 diffuseColor = vec4( 1.0 );
- #include <clipping_planes_fragment>
- #if DEPTH_PACKING == 3200
- diffuseColor.a = opacity;
- #endif
- #include <map_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <logdepthbuf_fragment>
- #ifdef USE_REVERSED_DEPTH_BUFFER
- float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ];
- #else
- float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5;
- #endif
- #if DEPTH_PACKING == 3200
- gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
- #elif DEPTH_PACKING == 3201
- gl_FragColor = packDepthToRGBA( fragCoordZ );
- #elif DEPTH_PACKING == 3202
- gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );
- #elif DEPTH_PACKING == 3203
- gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
- #endif
- }`,E0e=`#define DISTANCE
- varying vec3 vWorldPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <batching_vertex>
- #include <skinbase_vertex>
- #include <morphinstance_vertex>
- #ifdef USE_DISPLACEMENTMAP
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinnormal_vertex>
- #endif
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <worldpos_vertex>
- #include <clipping_planes_vertex>
- vWorldPosition = worldPosition.xyz;
- }`,j0e=`#define DISTANCE
- uniform vec3 referencePosition;
- uniform float nearDistance;
- uniform float farDistance;
- varying vec3 vWorldPosition;
- #include <common>
- #include <packing>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main () {
- vec4 diffuseColor = vec4( 1.0 );
- #include <clipping_planes_fragment>
- #include <map_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- float dist = length( vWorldPosition - referencePosition );
- dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
- dist = saturate( dist );
- gl_FragColor = packDepthToRGBA( dist );
- }`,D0e=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- }`,R0e=`uniform sampler2D tEquirect;
- varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vec3 direction = normalize( vWorldDirection );
- vec2 sampleUV = equirectUv( direction );
- gl_FragColor = texture2D( tEquirect, sampleUV );
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,F0e=`uniform float scale;
- attribute float lineDistance;
- varying float vLineDistance;
- #include <common>
- #include <uv_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- vLineDistance = scale * lineDistance;
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphinstance_vertex>
- #include <morphcolor_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <fog_vertex>
- }`,L0e=`uniform vec3 diffuse;
- uniform float opacity;
- uniform float dashSize;
- uniform float totalSize;
- varying float vLineDistance;
- #include <common>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- if ( mod( vLineDistance, totalSize ) > dashSize ) {
- discard;
- }
- vec3 outgoingLight = vec3( 0.0 );
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- outgoingLight = diffuseColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- }`,O0e=`#include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <envmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphinstance_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #endif
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <worldpos_vertex>
- #include <envmap_vertex>
- #include <fog_vertex>
- }`,I0e=`uniform vec3 diffuse;
- uniform float opacity;
- #ifndef FLAT_SHADED
- varying vec3 vNormal;
- #endif
- #include <common>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <specularmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <specularmap_fragment>
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- #ifdef USE_LIGHTMAP
- vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
- reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
- #else
- reflectedLight.indirectDiffuse += vec3( 1.0 );
- #endif
- #include <aomap_fragment>
- reflectedLight.indirectDiffuse *= diffuseColor.rgb;
- vec3 outgoingLight = reflectedLight.indirectDiffuse;
- #include <envmap_fragment>
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,z0e=`#define LAMBERT
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <envmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphinstance_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <envmap_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,U0e=`#define LAMBERT
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_lambert_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <specularmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <specularmap_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_lambert_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
- #include <envmap_fragment>
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,B0e=`#define MATCAP
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <color_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphinstance_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <fog_vertex>
- vViewPosition = - mvPosition.xyz;
- }`,H0e=`#define MATCAP
- uniform vec3 diffuse;
- uniform float opacity;
- uniform sampler2D matcap;
- varying vec3 vViewPosition;
- #include <common>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <fog_pars_fragment>
- #include <normal_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- vec3 viewDir = normalize( vViewPosition );
- vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
- vec3 y = cross( viewDir, x );
- vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
- #ifdef USE_MATCAP
- vec4 matcapColor = texture2D( matcap, uv );
- #else
- vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
- #endif
- vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,$0e=`#define NORMAL
- #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
- varying vec3 vViewPosition;
- #endif
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphinstance_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
- vViewPosition = - mvPosition.xyz;
- #endif
- }`,V0e=`#define NORMAL
- uniform float opacity;
- #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
- varying vec3 vViewPosition;
- #endif
- #include <packing>
- #include <uv_pars_fragment>
- #include <normal_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );
- #include <clipping_planes_fragment>
- #include <logdepthbuf_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );
- #ifdef OPAQUE
- gl_FragColor.a = 1.0;
- #endif
- }`,q0e=`#define PHONG
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <envmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphinstance_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <envmap_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,G0e=`#define PHONG
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform vec3 specular;
- uniform float shininess;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_phong_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <specularmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <specularmap_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_phong_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
- #include <envmap_fragment>
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,W0e=`#define STANDARD
- varying vec3 vViewPosition;
- #ifdef USE_TRANSMISSION
- varying vec3 vWorldPosition;
- #endif
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphinstance_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- #ifdef USE_TRANSMISSION
- vWorldPosition = worldPosition.xyz;
- #endif
- }`,K0e=`#define STANDARD
- #ifdef PHYSICAL
- #define IOR
- #define USE_SPECULAR
- #endif
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform float roughness;
- uniform float metalness;
- uniform float opacity;
- #ifdef IOR
- uniform float ior;
- #endif
- #ifdef USE_SPECULAR
- uniform float specularIntensity;
- uniform vec3 specularColor;
- #ifdef USE_SPECULAR_COLORMAP
- uniform sampler2D specularColorMap;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- uniform sampler2D specularIntensityMap;
- #endif
- #endif
- #ifdef USE_CLEARCOAT
- uniform float clearcoat;
- uniform float clearcoatRoughness;
- #endif
- #ifdef USE_DISPERSION
- uniform float dispersion;
- #endif
- #ifdef USE_IRIDESCENCE
- uniform float iridescence;
- uniform float iridescenceIOR;
- uniform float iridescenceThicknessMinimum;
- uniform float iridescenceThicknessMaximum;
- #endif
- #ifdef USE_SHEEN
- uniform vec3 sheenColor;
- uniform float sheenRoughness;
- #ifdef USE_SHEEN_COLORMAP
- uniform sampler2D sheenColorMap;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- uniform sampler2D sheenRoughnessMap;
- #endif
- #endif
- #ifdef USE_ANISOTROPY
- uniform vec2 anisotropyVector;
- #ifdef USE_ANISOTROPYMAP
- uniform sampler2D anisotropyMap;
- #endif
- #endif
- varying vec3 vViewPosition;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <iridescence_fragment>
- #include <cube_uv_reflection_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_physical_pars_fragment>
- #include <fog_pars_fragment>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_physical_pars_fragment>
- #include <transmission_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <clearcoat_pars_fragment>
- #include <iridescence_pars_fragment>
- #include <roughnessmap_pars_fragment>
- #include <metalnessmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <roughnessmap_fragment>
- #include <metalnessmap_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <clearcoat_normal_fragment_begin>
- #include <clearcoat_normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_physical_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
- vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
- #include <transmission_fragment>
- vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
- #ifdef USE_SHEEN
- float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
- outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
- #endif
- #ifdef USE_CLEARCOAT
- float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
- vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
- outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
- #endif
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,X0e=`#define TOON
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphinstance_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,Y0e=`#define TOON
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <gradientmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_toon_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_toon_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,Q0e=`uniform float size;
- uniform float scale;
- #include <common>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- #ifdef USE_POINTS_UV
- varying vec2 vUv;
- uniform mat3 uvTransform;
- #endif
- void main() {
- #ifdef USE_POINTS_UV
- vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
- #endif
- #include <color_vertex>
- #include <morphinstance_vertex>
- #include <morphcolor_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <project_vertex>
- gl_PointSize = size;
- #ifdef USE_SIZEATTENUATION
- bool isPerspective = isPerspectiveMatrix( projectionMatrix );
- if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
- #endif
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <worldpos_vertex>
- #include <fog_vertex>
- }`,Z0e=`uniform vec3 diffuse;
- uniform float opacity;
- #include <common>
- #include <color_pars_fragment>
- #include <map_particle_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- vec3 outgoingLight = vec3( 0.0 );
- #include <logdepthbuf_fragment>
- #include <map_particle_fragment>
- #include <color_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- outgoingLight = diffuseColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- }`,J0e=`#include <common>
- #include <batching_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <shadowmap_pars_vertex>
- void main() {
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphinstance_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <worldpos_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,eve=`uniform vec3 color;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <logdepthbuf_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <shadowmask_pars_fragment>
- void main() {
- #include <logdepthbuf_fragment>
- gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- }`,tve=`uniform float rotation;
- uniform vec2 center;
- #include <common>
- #include <uv_pars_vertex>
- #include <fog_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- vec4 mvPosition = modelViewMatrix[ 3 ];
- vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );
- #ifndef USE_SIZEATTENUATION
- bool isPerspective = isPerspectiveMatrix( projectionMatrix );
- if ( isPerspective ) scale *= - mvPosition.z;
- #endif
- vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
- vec2 rotatedPosition;
- rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
- rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
- mvPosition.xy += rotatedPosition;
- gl_Position = projectionMatrix * mvPosition;
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <fog_vertex>
- }`,nve=`uniform vec3 diffuse;
- uniform float opacity;
- #include <common>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- vec3 outgoingLight = vec3( 0.0 );
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- outgoingLight = diffuseColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- }`,Rn={alphahash_fragment:Nxe,alphahash_pars_fragment:Cxe,alphamap_fragment:kxe,alphamap_pars_fragment:Axe,alphatest_fragment:Txe,alphatest_pars_fragment:Mxe,aomap_fragment:Pxe,aomap_pars_fragment:Exe,batching_pars_vertex:jxe,batching_vertex:Dxe,begin_vertex:Rxe,beginnormal_vertex:Fxe,bsdfs:Lxe,iridescence_fragment:Oxe,bumpmap_pars_fragment:Ixe,clipping_planes_fragment:zxe,clipping_planes_pars_fragment:Uxe,clipping_planes_pars_vertex:Bxe,clipping_planes_vertex:Hxe,color_fragment:$xe,color_pars_fragment:Vxe,color_pars_vertex:qxe,color_vertex:Gxe,common:Wxe,cube_uv_reflection_fragment:Kxe,defaultnormal_vertex:Xxe,displacementmap_pars_vertex:Yxe,displacementmap_vertex:Qxe,emissivemap_fragment:Zxe,emissivemap_pars_fragment:Jxe,colorspace_fragment:eye,colorspace_pars_fragment:tye,envmap_fragment:nye,envmap_common_pars_fragment:rye,envmap_pars_fragment:aye,envmap_pars_vertex:iye,envmap_physical_pars_fragment:gye,envmap_vertex:sye,fog_vertex:oye,fog_pars_vertex:lye,fog_fragment:cye,fog_pars_fragment:dye,gradientmap_pars_fragment:uye,lightmap_pars_fragment:hye,lights_lambert_fragment:mye,lights_lambert_pars_fragment:fye,lights_pars_begin:pye,lights_toon_fragment:bye,lights_toon_pars_fragment:xye,lights_phong_fragment:yye,lights_phong_pars_fragment:vye,lights_physical_fragment:wye,lights_physical_pars_fragment:Sye,lights_fragment_begin:_ye,lights_fragment_maps:Nye,lights_fragment_end:Cye,logdepthbuf_fragment:kye,logdepthbuf_pars_fragment:Aye,logdepthbuf_pars_vertex:Tye,logdepthbuf_vertex:Mye,map_fragment:Pye,map_pars_fragment:Eye,map_particle_fragment:jye,map_particle_pars_fragment:Dye,metalnessmap_fragment:Rye,metalnessmap_pars_fragment:Fye,morphinstance_vertex:Lye,morphcolor_vertex:Oye,morphnormal_vertex:Iye,morphtarget_pars_vertex:zye,morphtarget_vertex:Uye,normal_fragment_begin:Bye,normal_fragment_maps:Hye,normal_pars_fragment:$ye,normal_pars_vertex:Vye,normal_vertex:qye,normalmap_pars_fragment:Gye,clearcoat_normal_fragment_begin:Wye,clearcoat_normal_fragment_maps:Kye,clearcoat_pars_fragment:Xye,iridescence_pars_fragment:Yye,opaque_fragment:Qye,packing:Zye,premultiplied_alpha_fragment:Jye,project_vertex:e0e,dithering_fragment:t0e,dithering_pars_fragment:n0e,roughnessmap_fragment:r0e,roughnessmap_pars_fragment:a0e,shadowmap_pars_fragment:i0e,shadowmap_pars_vertex:s0e,shadowmap_vertex:o0e,shadowmask_pars_fragment:l0e,skinbase_vertex:c0e,skinning_pars_vertex:d0e,skinning_vertex:u0e,skinnormal_vertex:h0e,specularmap_fragment:m0e,specularmap_pars_fragment:f0e,tonemapping_fragment:p0e,tonemapping_pars_fragment:g0e,transmission_fragment:b0e,transmission_pars_fragment:x0e,uv_pars_fragment:y0e,uv_pars_vertex:v0e,uv_vertex:w0e,worldpos_vertex:S0e,background_vert:_0e,background_frag:N0e,backgroundCube_vert:C0e,backgroundCube_frag:k0e,cube_vert:A0e,cube_frag:T0e,depth_vert:M0e,depth_frag:P0e,distanceRGBA_vert:E0e,distanceRGBA_frag:j0e,equirect_vert:D0e,equirect_frag:R0e,linedashed_vert:F0e,linedashed_frag:L0e,meshbasic_vert:O0e,meshbasic_frag:I0e,meshlambert_vert:z0e,meshlambert_frag:U0e,meshmatcap_vert:B0e,meshmatcap_frag:H0e,meshnormal_vert:$0e,meshnormal_frag:V0e,meshphong_vert:q0e,meshphong_frag:G0e,meshphysical_vert:W0e,meshphysical_frag:K0e,meshtoon_vert:X0e,meshtoon_frag:Y0e,points_vert:Q0e,points_frag:Z0e,shadow_vert:J0e,shadow_frag:eve,sprite_vert:tve,sprite_frag:nve},Ht={common:{diffuse:{value:new Hn(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Bn},alphaMap:{value:null},alphaMapTransform:{value:new Bn},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Bn}},envmap:{envMap:{value:null},envMapRotation:{value:new Bn},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 Bn}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Bn}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Bn},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Bn},normalScale:{value:new In(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Bn},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Bn}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Bn}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Bn}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Hn(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 Hn(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Bn},alphaTest:{value:0},uvTransform:{value:new Bn}},sprite:{diffuse:{value:new Hn(16777215)},opacity:{value:1},center:{value:new In(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Bn},alphaMap:{value:null},alphaMapTransform:{value:new Bn},alphaTest:{value:0}}},Sc={basic:{uniforms:As([Ht.common,Ht.specularmap,Ht.envmap,Ht.aomap,Ht.lightmap,Ht.fog]),vertexShader:Rn.meshbasic_vert,fragmentShader:Rn.meshbasic_frag},lambert:{uniforms:As([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 Hn(0)}}]),vertexShader:Rn.meshlambert_vert,fragmentShader:Rn.meshlambert_frag},phong:{uniforms:As([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 Hn(0)},specular:{value:new Hn(1118481)},shininess:{value:30}}]),vertexShader:Rn.meshphong_vert,fragmentShader:Rn.meshphong_frag},standard:{uniforms:As([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 Hn(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Rn.meshphysical_vert,fragmentShader:Rn.meshphysical_frag},toon:{uniforms:As([Ht.common,Ht.aomap,Ht.lightmap,Ht.emissivemap,Ht.bumpmap,Ht.normalmap,Ht.displacementmap,Ht.gradientmap,Ht.fog,Ht.lights,{emissive:{value:new Hn(0)}}]),vertexShader:Rn.meshtoon_vert,fragmentShader:Rn.meshtoon_frag},matcap:{uniforms:As([Ht.common,Ht.bumpmap,Ht.normalmap,Ht.displacementmap,Ht.fog,{matcap:{value:null}}]),vertexShader:Rn.meshmatcap_vert,fragmentShader:Rn.meshmatcap_frag},points:{uniforms:As([Ht.points,Ht.fog]),vertexShader:Rn.points_vert,fragmentShader:Rn.points_frag},dashed:{uniforms:As([Ht.common,Ht.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Rn.linedashed_vert,fragmentShader:Rn.linedashed_frag},depth:{uniforms:As([Ht.common,Ht.displacementmap]),vertexShader:Rn.depth_vert,fragmentShader:Rn.depth_frag},normal:{uniforms:As([Ht.common,Ht.bumpmap,Ht.normalmap,Ht.displacementmap,{opacity:{value:1}}]),vertexShader:Rn.meshnormal_vert,fragmentShader:Rn.meshnormal_frag},sprite:{uniforms:As([Ht.sprite,Ht.fog]),vertexShader:Rn.sprite_vert,fragmentShader:Rn.sprite_frag},background:{uniforms:{uvTransform:{value:new Bn},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Rn.background_vert,fragmentShader:Rn.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Bn}},vertexShader:Rn.backgroundCube_vert,fragmentShader:Rn.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Rn.cube_vert,fragmentShader:Rn.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Rn.equirect_vert,fragmentShader:Rn.equirect_frag},distanceRGBA:{uniforms:As([Ht.common,Ht.displacementmap,{referencePosition:{value:new pt},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Rn.distanceRGBA_vert,fragmentShader:Rn.distanceRGBA_frag},shadow:{uniforms:As([Ht.lights,Ht.fog,{color:{value:new Hn(0)},opacity:{value:1}}]),vertexShader:Rn.shadow_vert,fragmentShader:Rn.shadow_frag}};Sc.physical={uniforms:As([Sc.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Bn},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Bn},clearcoatNormalScale:{value:new In(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Bn},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Bn},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Bn},sheen:{value:0},sheenColor:{value:new Hn(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Bn},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Bn},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Bn},transmissionSamplerSize:{value:new In},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Bn},attenuationDistance:{value:0},attenuationColor:{value:new Hn(0)},specularColor:{value:new Hn(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Bn},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Bn},anisotropyVector:{value:new In},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Bn}}]),vertexShader:Rn.meshphysical_vert,fragmentShader:Rn.meshphysical_frag};const _S={r:0,b:0,g:0},Em=new Kh,rve=new ai;function ave(t,e,n,r,i,s,o){const l=new Hn(0);let c=s===!0?0:1,d,u,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 k=x(N);k===null?y(l,c):k&&k.isColor&&(y(k,1),A=!0);const P=t.xr.getEnvironmentBlendMode();P==="additive"?r.buffers.color.setClear(0,0,0,1,o):P==="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 k=x(A);k&&(k.isCubeTexture||k.mapping===nk)?(u===void 0&&(u=new Nl(new KF(1,1,1),new iu({name:"BackgroundCubeMaterial",uniforms:xb(Sc.backgroundCube.uniforms),vertexShader:Sc.backgroundCube.vertexShader,fragmentShader:Sc.backgroundCube.fragmentShader,side:ro,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),u.geometry.deleteAttribute("normal"),u.geometry.deleteAttribute("uv"),u.onBeforeRender=function(P,C,j){this.matrixWorld.copyPosition(j.matrixWorld)},Object.defineProperty(u.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(u)),Em.copy(A.backgroundRotation),Em.x*=-1,Em.y*=-1,Em.z*=-1,k.isCubeTexture&&k.isRenderTargetTexture===!1&&(Em.y*=-1,Em.z*=-1),u.material.uniforms.envMap.value=k,u.material.uniforms.flipEnvMap.value=k.isCubeTexture&&k.isRenderTargetTexture===!1?-1:1,u.material.uniforms.backgroundBlurriness.value=A.backgroundBlurriness,u.material.uniforms.backgroundIntensity.value=A.backgroundIntensity,u.material.uniforms.backgroundRotation.value.setFromMatrix4(rve.makeRotationFromEuler(Em)),u.material.toneMapped=fr.getTransfer(k.colorSpace)!==zr,(h!==k||f!==k.version||p!==t.toneMapping)&&(u.material.needsUpdate=!0,h=k,f=k.version,p=t.toneMapping),u.layers.enableAll(),N.unshift(u,u.geometry,u.material,0,0,null)):k&&k.isTexture&&(d===void 0&&(d=new Nl(new YF(2,2),new iu({name:"BackgroundMaterial",uniforms:xb(Sc.background.uniforms),vertexShader:Sc.background.vertexShader,fragmentShader:Sc.background.fragmentShader,side:Wh,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),d.geometry.deleteAttribute("normal"),Object.defineProperty(d.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(d)),d.material.uniforms.t2D.value=k,d.material.uniforms.backgroundIntensity.value=A.backgroundIntensity,d.material.toneMapped=fr.getTransfer(k.colorSpace)!==zr,k.matrixAutoUpdate===!0&&k.updateMatrix(),d.material.uniforms.uvTransform.value.copy(k.matrix),(h!==k||f!==k.version||p!==t.toneMapping)&&(d.material.needsUpdate=!0,h=k,f=k.version,p=t.toneMapping),d.layers.enableAll(),N.unshift(d,d.geometry,d.material,0,0,null))}function y(N,A){N.getRGB(_S,lY(t)),r.buffers.color.setClear(_S.r,_S.g,_S.b,A,o)}function _(){u!==void 0&&(u.geometry.dispose(),u.material.dispose(),u=void 0),d!==void 0&&(d.geometry.dispose(),d.material.dispose(),d=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 ive(t,e){const n=t.getParameter(t.MAX_VERTEX_ATTRIBS),r={},i=f(null);let s=i,o=!1;function l(E,B,L,U,D){let $=!1;const q=h(U,L,B);s!==q&&(s=q,d(s.object)),$=p(E,U,L,D),$&&x(E,U,L,D),D!==null&&e.update(D,t.ELEMENT_ARRAY_BUFFER),($||o)&&(o=!1,A(E,B,L,U),D!==null&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e.get(D).buffer))}function c(){return t.createVertexArray()}function d(E){return t.bindVertexArray(E)}function u(E){return t.deleteVertexArray(E)}function h(E,B,L){const U=L.wireframe===!0;let D=r[E.id];D===void 0&&(D={},r[E.id]=D);let $=D[B.id];$===void 0&&($={},D[B.id]=$);let q=$[U];return q===void 0&&(q=f(c()),$[U]=q),q}function f(E){const B=[],L=[],U=[];for(let D=0;D<n;D++)B[D]=0,L[D]=0,U[D]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:B,enabledAttributes:L,attributeDivisors:U,object:E,attributes:{},index:null}}function p(E,B,L,U){const D=s.attributes,$=B.attributes;let q=0;const z=L.getAttributes();for(const W in z)if(z[W].location>=0){const te=D[W];let H=$[W];if(H===void 0&&(W==="instanceMatrix"&&E.instanceMatrix&&(H=E.instanceMatrix),W==="instanceColor"&&E.instanceColor&&(H=E.instanceColor)),te===void 0||te.attribute!==H||H&&te.data!==H.data)return!0;q++}return s.attributesNum!==q||s.index!==U}function x(E,B,L,U){const D={},$=B.attributes;let q=0;const z=L.getAttributes();for(const W in z)if(z[W].location>=0){let te=$[W];te===void 0&&(W==="instanceMatrix"&&E.instanceMatrix&&(te=E.instanceMatrix),W==="instanceColor"&&E.instanceColor&&(te=E.instanceColor));const H={};H.attribute=te,te&&te.data&&(H.data=te.data),D[W]=H,q++}s.attributes=D,s.attributesNum=q,s.index=U}function v(){const E=s.newAttributes;for(let B=0,L=E.length;B<L;B++)E[B]=0}function g(E){y(E,0)}function y(E,B){const L=s.newAttributes,U=s.enabledAttributes,D=s.attributeDivisors;L[E]=1,U[E]===0&&(t.enableVertexAttribArray(E),U[E]=1),D[E]!==B&&(t.vertexAttribDivisor(E,B),D[E]=B)}function _(){const E=s.newAttributes,B=s.enabledAttributes;for(let L=0,U=B.length;L<U;L++)B[L]!==E[L]&&(t.disableVertexAttribArray(L),B[L]=0)}function N(E,B,L,U,D,$,q){q===!0?t.vertexAttribIPointer(E,B,L,D,$):t.vertexAttribPointer(E,B,L,U,D,$)}function A(E,B,L,U){v();const D=U.attributes,$=L.getAttributes(),q=B.defaultAttributeValues;for(const z in $){const W=$[z];if(W.location>=0){let Q=D[z];if(Q===void 0&&(z==="instanceMatrix"&&E.instanceMatrix&&(Q=E.instanceMatrix),z==="instanceColor"&&E.instanceColor&&(Q=E.instanceColor)),Q!==void 0){const te=Q.normalized,H=Q.itemSize,X=e.get(Q);if(X===void 0)continue;const Z=X.buffer,ee=X.type,Se=X.bytesPerElement,oe=ee===t.INT||ee===t.UNSIGNED_INT||Q.gpuType===IF;if(Q.isInterleavedBufferAttribute){const ie=Q.data,me=ie.stride,se=Q.offset;if(ie.isInstancedInterleavedBuffer){for(let ce=0;ce<W.locationSize;ce++)y(W.location+ce,ie.meshPerAttribute);E.isInstancedMesh!==!0&&U._maxInstanceCount===void 0&&(U._maxInstanceCount=ie.meshPerAttribute*ie.count)}else for(let ce=0;ce<W.locationSize;ce++)g(W.location+ce);t.bindBuffer(t.ARRAY_BUFFER,Z);for(let ce=0;ce<W.locationSize;ce++)N(W.location+ce,H/W.locationSize,ee,te,me*Se,(se+H/W.locationSize*ce)*Se,oe)}else{if(Q.isInstancedBufferAttribute){for(let ie=0;ie<W.locationSize;ie++)y(W.location+ie,Q.meshPerAttribute);E.isInstancedMesh!==!0&&U._maxInstanceCount===void 0&&(U._maxInstanceCount=Q.meshPerAttribute*Q.count)}else for(let ie=0;ie<W.locationSize;ie++)g(W.location+ie);t.bindBuffer(t.ARRAY_BUFFER,Z);for(let ie=0;ie<W.locationSize;ie++)N(W.location+ie,H/W.locationSize,ee,te,H*Se,H/W.locationSize*ie*Se,oe)}}else if(q!==void 0){const te=q[z];if(te!==void 0)switch(te.length){case 2:t.vertexAttrib2fv(W.location,te);break;case 3:t.vertexAttrib3fv(W.location,te);break;case 4:t.vertexAttrib4fv(W.location,te);break;default:t.vertexAttrib1fv(W.location,te)}}}}_()}function k(){j();for(const E in r){const B=r[E];for(const L in B){const U=B[L];for(const D in U)u(U[D].object),delete U[D];delete B[L]}delete r[E]}}function P(E){if(r[E.id]===void 0)return;const B=r[E.id];for(const L in B){const U=B[L];for(const D in U)u(U[D].object),delete U[D];delete B[L]}delete r[E.id]}function C(E){for(const B in r){const L=r[B];if(L[E.id]===void 0)continue;const U=L[E.id];for(const D in U)u(U[D].object),delete U[D];delete L[E.id]}}function j(){M(),o=!0,s!==i&&(s=i,d(s.object))}function M(){i.geometry=null,i.program=null,i.wireframe=!1}return{setup:l,reset:j,resetDefaultState:M,dispose:k,releaseStatesOfGeometry:P,releaseStatesOfProgram:C,initAttributes:v,enableAttribute:g,disableUnusedAttributes:_}}function sve(t,e,n){let r;function i(d){r=d}function s(d,u){t.drawArrays(r,d,u),n.update(u,r,1)}function o(d,u,h){h!==0&&(t.drawArraysInstanced(r,d,u,h),n.update(u,r,h))}function l(d,u,h){if(h===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(r,d,0,u,0,h);let p=0;for(let x=0;x<h;x++)p+=u[x];n.update(p,r,1)}function c(d,u,h,f){if(h===0)return;const p=e.get("WEBGL_multi_draw");if(p===null)for(let x=0;x<d.length;x++)o(d[x],u[x],f[x]);else{p.multiDrawArraysInstancedWEBGL(r,d,0,u,0,f,0,h);let x=0;for(let v=0;v<h;v++)x+=u[v]*f[v];n.update(x,r,1)}}this.setMode=i,this.render=s,this.renderInstances=o,this.renderMultiDraw=l,this.renderMultiDrawInstances=c}function ove(t,e,n,r){let i;function s(){if(i!==void 0)return i;if(e.has("EXT_texture_filter_anisotropic")===!0){const C=e.get("EXT_texture_filter_anisotropic");i=t.getParameter(C.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i}function o(C){return!(C!==Gl&&r.convert(C)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_FORMAT))}function l(C){const j=C===Gb&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(C!==Oc&&r.convert(C)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_TYPE)&&C!==zd&&!j)}function c(C){if(C==="highp"){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";C="mediump"}return C==="mediump"&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let d=n.precision!==void 0?n.precision:"highp";const u=c(d);u!==d&&(Sn("WebGLRenderer:",d,"not supported, using",u,"instead."),d=u);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),k=x>0,P=t.getParameter(t.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:c,textureFormatReadable:o,textureTypeReadable:l,precision:d,logarithmicDepthBuffer:h,reversedDepthBuffer:f,maxTextures:p,maxVertexTextures:x,maxTextureSize:v,maxCubemapSize:g,maxAttributes:y,maxVertexUniforms:_,maxVaryings:N,maxFragmentUniforms:A,vertexTextures:k,maxSamples:P}}function lve(t){const e=this;let n=null,r=0,i=!1,s=!1;const o=new sh,l=new Bn,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,u(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(h,f){n=u(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?u(null):d();else{const _=s?0:r,N=_*4;let A=y.clippingState||null;c.value=A,A=u(x,f,N,p);for(let k=0;k!==N;++k)A[k]=n[k];y.clippingState=A,this.numIntersection=v?this.numPlanes:0,this.numPlanes+=_}};function d(){c.value!==n&&(c.value=n,c.needsUpdate=r>0),e.numPlanes=r,e.numIntersection=0}function u(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 cve(t){let e=new WeakMap;function n(o,l){return l===_3?o.mapping=pb:l===N3&&(o.mapping=gb),o}function r(o){if(o&&o.isTexture){const l=o.mapping;if(l===_3||l===N3)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 d=new txe(c.height);return d.fromEquirectangularTexture(t,o),e.set(o,d),o.addEventListener("dispose",i),n(d.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 wh=4,k8=[.125,.215,.35,.446,.526,.582],Km=20,dve=256,oy=new bY,A8=new Hn;let pP=null,gP=0,bP=0,xP=!1;const uve=new pt;let T8=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=uve}=s;pP=this._renderer.getRenderTarget(),gP=this._renderer.getActiveCubeFace(),bP=this._renderer.getActiveMipmapLevel(),xP=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=E8(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=P8(),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(pP,gP,bP),this._renderer.xr.enabled=xP,e.scissorTest=!1,eg(e,0,0,e.width,e.height)}_fromTexture(e,n){e.mapping===pb||e.mapping===gb?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),pP=this._renderer.getRenderTarget(),gP=this._renderer.getActiveCubeFace(),bP=this._renderer.getActiveMipmapLevel(),xP=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:fl,minFilter:fl,generateMipmaps:!1,type:Gb,format:Gl,colorSpace:bb,depthBuffer:!1},i=M8(e,n,r);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==n){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=M8(e,n,r);const{_lodMax:s}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=hve(s)),this._blurMaterial=fve(s,e,n),this._ggxMaterial=mve(s,e,n)}return i}_compileMaterial(e){const n=new Nl(new _l,e);this._renderer.compile(n,oy)}_sceneToCubeUV(e,n,r,i,s){const c=new ll(90,1,n,r),d=[1,-1,1,1,1,1],u=[1,1,1,-1,-1,-1],h=this._renderer,f=h.autoClear,p=h.toneMapping;h.getClearColor(A8),h.toneMapping=Rh,h.autoClear=!1,h.state.buffers.depth.getReversed()&&(h.setRenderTarget(i),h.clearDepth(),h.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new Nl(new KF,new WF({name:"PMREM.Background",side:ro,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(A8),y=!0);for(let N=0;N<6;N++){const A=N%3;A===0?(c.up.set(0,d[N],0),c.position.set(s.x,s.y,s.z),c.lookAt(s.x+u[N],s.y,s.z)):A===1?(c.up.set(0,0,d[N]),c.position.set(s.x,s.y,s.z),c.lookAt(s.x,s.y+u[N],s.z)):(c.up.set(0,d[N],0),c.position.set(s.x,s.y,s.z),c.lookAt(s.x,s.y,s.z+u[N]));const k=this._cubeSize;eg(i,A*k,N>2?k:0,k,k),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===pb||e.mapping===gb;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=E8()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=P8());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;eg(n,0,0,3*c,2*c),r.setRenderTarget(n),r.render(o,oy)}_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,d=r/(this._lodMeshes.length-1),u=n/(this._lodMeshes.length-1),h=Math.sqrt(d*d-u*u),f=.05+d*.95,p=h*f,{_lodMax:x}=this,v=this._sizeLods[r],g=3*v*(r>x-wh?r-x+wh:0),y=4*(this._cubeSize-v);c.envMap.value=e.texture,c.roughness.value=p,c.mipInt.value=x-n,eg(s,g,y,3*v,2*v),i.setRenderTarget(s),i.render(l,oy),c.envMap.value=s.texture,c.roughness.value=0,c.mipInt.value=x-r,eg(e,g,y,3*v,2*v),i.setRenderTarget(e),i.render(l,oy)}_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,d=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&$a("blur direction must be either latitudinal or longitudinal!");const u=3,h=this._lodMeshes[i];h.material=d;const f=d.uniforms,p=this._sizeLods[r]-1,x=isFinite(s)?Math.PI/(2*p):2*Math.PI/(2*Km-1),v=s/x,g=isFinite(s)?1+Math.floor(u*v):Km;g>Km&&Sn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${g} samples when the maximum is set to ${Km}`);const y=[];let _=0;for(let C=0;C<Km;++C){const j=C/v,M=Math.exp(-j*j/2);y.push(M),C===0?_+=M:C<g&&(_+=2*M)}for(let C=0;C<y.length;C++)y[C]=y[C]/_;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],k=3*A*(i>N-wh?i-N+wh:0),P=4*(this._cubeSize-A);eg(n,k,P,3*A,2*A),c.setRenderTarget(n),c.render(h,oy)}};function hve(t){const e=[],n=[],r=[];let i=t;const s=t-wh+1+k8.length;for(let o=0;o<s;o++){const l=Math.pow(2,i);e.push(l);let c=1/l;o>t-wh?c=k8[o-t+wh-1]:o===0&&(c=0),n.push(c);const d=1/(l-2),u=-d,h=1+d,f=[u,u,h,u,h,h,u,u,h,h,u,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 P=0;P<p;P++){const C=P%3*2/3-1,j=P>2?0:-1,M=[C,j,0,C+2/3,j,0,C+2/3,j+1,0,C,j,0,C+2/3,j+1,0,C,j+1,0];_.set(M,v*x*P),N.set(f,g*x*P);const E=[P,P,P,P,P,P];A.set(E,y*x*P)}const k=new _l;k.setAttribute("position",new Rs(_,v)),k.setAttribute("uv",new Rs(N,g)),k.setAttribute("faceIndex",new Rs(A,y)),r.push(new Nl(k,null)),i>wh&&i--}return{lodMeshes:r,sizeLods:e,sigmas:n}}function M8(t,e,n){const r=new Lf(t,e,n);return r.texture.mapping=nk,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function eg(t,e,n,r,i){t.viewport.set(e,n,r,i),t.scissor.set(e,n,r,i)}function mve(t,e,n){return new iu({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:dve,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:ak(),fragmentShader:`
- precision highp float;
- precision highp int;
- varying vec3 vOutputDirection;
- uniform sampler2D envMap;
- uniform float roughness;
- uniform float mipInt;
- #define ENVMAP_TYPE_CUBE_UV
- #include <cube_uv_reflection_fragment>
- #define PI 3.14159265359
- // Van der Corput radical inverse
- float radicalInverse_VdC(uint bits) {
- bits = (bits << 16u) | (bits >> 16u);
- bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);
- bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);
- bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);
- bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);
- return float(bits) * 2.3283064365386963e-10; // / 0x100000000
- }
- // Hammersley sequence
- vec2 hammersley(uint i, uint N) {
- return vec2(float(i) / float(N), radicalInverse_VdC(i));
- }
- // GGX VNDF importance sampling (Eric Heitz 2018)
- // "Sampling the GGX Distribution of Visible Normals"
- // https://jcgt.org/published/0007/04/01/
- vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) {
- float alpha = roughness * roughness;
- // Section 3.2: Transform view direction to hemisphere configuration
- vec3 Vh = normalize(vec3(alpha * V.x, alpha * V.y, V.z));
- // Section 4.1: Orthonormal basis
- float lensq = Vh.x * Vh.x + Vh.y * Vh.y;
- vec3 T1 = lensq > 0.0 ? vec3(-Vh.y, Vh.x, 0.0) / sqrt(lensq) : vec3(1.0, 0.0, 0.0);
- vec3 T2 = cross(Vh, T1);
- // Section 4.2: Parameterization of projected area
- float r = sqrt(Xi.x);
- float phi = 2.0 * PI * Xi.y;
- float t1 = r * cos(phi);
- float t2 = r * sin(phi);
- float s = 0.5 * (1.0 + Vh.z);
- t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2;
- // Section 4.3: Reprojection onto hemisphere
- vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * Vh;
- // Section 3.4: Transform back to ellipsoid configuration
- return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z)));
- }
- void main() {
- vec3 N = normalize(vOutputDirection);
- vec3 V = N; // Assume view direction equals normal for pre-filtering
- vec3 prefilteredColor = vec3(0.0);
- float totalWeight = 0.0;
- // For very low roughness, just sample the environment directly
- if (roughness < 0.001) {
- gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0);
- return;
- }
- // Tangent space basis for VNDF sampling
- vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);
- vec3 tangent = normalize(cross(up, N));
- vec3 bitangent = cross(N, tangent);
- for(uint i = 0u; i < uint(GGX_SAMPLES); i++) {
- vec2 Xi = hammersley(i, uint(GGX_SAMPLES));
- // For PMREM, V = N, so in tangent space V is always (0, 0, 1)
- vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness);
- // Transform H back to world space
- vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z);
- vec3 L = normalize(2.0 * dot(V, H) * H - V);
- float NdotL = max(dot(N, L), 0.0);
- if(NdotL > 0.0) {
- // Sample environment at fixed mip level
- // VNDF importance sampling handles the distribution filtering
- vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt);
- // Weight by NdotL for the split-sum approximation
- // VNDF PDF naturally accounts for the visible microfacet distribution
- prefilteredColor += sampleColor * NdotL;
- totalWeight += NdotL;
- }
- }
- if (totalWeight > 0.0) {
- prefilteredColor = prefilteredColor / totalWeight;
- }
- gl_FragColor = vec4(prefilteredColor, 1.0);
- }
- `,blending:qd,depthTest:!1,depthWrite:!1})}function fve(t,e,n){const r=new Float32Array(Km),i=new pt(0,1,0);return new iu({name:"SphericalGaussianBlur",defines:{n:Km,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:ak(),fragmentShader:`
- precision mediump float;
- precision mediump int;
- varying vec3 vOutputDirection;
- uniform sampler2D envMap;
- uniform int samples;
- uniform float weights[ n ];
- uniform bool latitudinal;
- uniform float dTheta;
- uniform float mipInt;
- uniform vec3 poleAxis;
- #define ENVMAP_TYPE_CUBE_UV
- #include <cube_uv_reflection_fragment>
- vec3 getSample( float theta, vec3 axis ) {
- float cosTheta = cos( theta );
- // Rodrigues' axis-angle rotation
- vec3 sampleDirection = vOutputDirection * cosTheta
- + cross( axis, vOutputDirection ) * sin( theta )
- + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
- return bilinearCubeUV( envMap, sampleDirection, mipInt );
- }
- void main() {
- vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
- if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
- axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
- }
- axis = normalize( axis );
- gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
- gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
- for ( int i = 1; i < n; i++ ) {
- if ( i >= samples ) {
- break;
- }
- float theta = dTheta * float( i );
- gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
- gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
- }
- }
- `,blending:qd,depthTest:!1,depthWrite:!1})}function P8(){return new iu({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:ak(),fragmentShader:`
- precision mediump float;
- precision mediump int;
- varying vec3 vOutputDirection;
- uniform sampler2D envMap;
- #include <common>
- void main() {
- vec3 outputDirection = normalize( vOutputDirection );
- vec2 uv = equirectUv( outputDirection );
- gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
- }
- `,blending:qd,depthTest:!1,depthWrite:!1})}function E8(){return new iu({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:ak(),fragmentShader:`
- precision mediump float;
- precision mediump int;
- uniform float flipEnvMap;
- varying vec3 vOutputDirection;
- uniform samplerCube envMap;
- void main() {
- gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
- }
- `,blending:qd,depthTest:!1,depthWrite:!1})}function ak(){return`
- precision mediump float;
- precision mediump int;
- attribute float faceIndex;
- varying vec3 vOutputDirection;
- // RH coordinate system; PMREM face-indexing convention
- vec3 getDirection( vec2 uv, float face ) {
- uv = 2.0 * uv - 1.0;
- vec3 direction = vec3( uv, 1.0 );
- if ( face == 0.0 ) {
- direction = direction.zyx; // ( 1, v, u ) pos x
- } else if ( face == 1.0 ) {
- direction = direction.xzy;
- direction.xz *= -1.0; // ( -u, 1, -v ) pos y
- } else if ( face == 2.0 ) {
- direction.x *= -1.0; // ( -u, v, 1 ) pos z
- } else if ( face == 3.0 ) {
- direction = direction.zyx;
- direction.xz *= -1.0; // ( -1, v, -u ) neg x
- } else if ( face == 4.0 ) {
- direction = direction.xzy;
- direction.xy *= -1.0; // ( -u, -1, v ) neg y
- } else if ( face == 5.0 ) {
- direction.z *= -1.0; // ( u, v, -1 ) neg z
- }
- return direction;
- }
- void main() {
- vOutputDirection = getDirection( uv, faceIndex );
- gl_Position = vec4( position, 1.0 );
- }
- `}function pve(t){let e=new WeakMap,n=null;function r(l){if(l&&l.isTexture){const c=l.mapping,d=c===_3||c===N3,u=c===pb||c===gb;if(d||u){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 T8(t)),h=d?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 d&&p&&p.height>0||u&&p&&i(p)?(n===null&&(n=new T8(t)),h=d?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 d=6;for(let u=0;u<d;u++)l[u]!==void 0&&c++;return c===d}function s(l){const c=l.target;c.removeEventListener("dispose",s);const d=e.get(c);d!==void 0&&(e.delete(c),d.dispose())}function o(){e=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:r,dispose:o}}function gve(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&&S0("WebGLRenderer: "+r+" extension not supported."),i}}}function bve(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 d(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 k=_[N+0],P=_[N+1],C=_[N+2];f.push(k,P,P,C,C,k)}}else if(x!==void 0){const _=x.array;v=x.version;for(let N=0,A=_.length/3-1;N<A;N+=3){const k=N+0,P=N+1,C=N+2;f.push(k,P,P,C,C,k)}}else return;const g=new(XX(f)?iY:aY)(f,1);g.version=v;const y=s.get(h);y&&e.remove(y),s.set(h,g)}function u(h){const f=s.get(h);if(f){const p=h.index;p!==null&&f.version<p.version&&d(h)}else d(h);return s.get(h)}return{get:l,update:c,getWireframeAttribute:u}}function xve(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 d(f,p,x){x!==0&&(t.drawElementsInstanced(r,p,s,f*o,x),n.update(p,r,x))}function u(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++)d(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=d,this.renderMultiDraw=u,this.renderMultiDrawInstances=h}function yve(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:$a("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 vve(t,e,n){const r=new WeakMap,i=new Ja;function s(o,l,c){const d=o.morphTargetInfluences,u=l.morphAttributes.position||l.morphAttributes.normal||l.morphAttributes.color,h=u!==void 0?u.length:0;let f=r.get(l);if(f===void 0||f.count!==h){let E=function(){j.dispose(),r.delete(l),l.removeEventListener("dispose",E)};var p=E;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 k=l.attributes.position.count*A,P=1;k>e.maxTextureSize&&(P=Math.ceil(k/e.maxTextureSize),k=e.maxTextureSize);const C=new Float32Array(k*P*4*h),j=new eY(C,k,P,h);j.type=zd,j.needsUpdate=!0;const M=A*4;for(let B=0;B<h;B++){const L=y[B],U=_[B],D=N[B],$=k*P*4*B;for(let q=0;q<L.count;q++){const z=q*M;x===!0&&(i.fromBufferAttribute(L,q),C[$+z+0]=i.x,C[$+z+1]=i.y,C[$+z+2]=i.z,C[$+z+3]=0),v===!0&&(i.fromBufferAttribute(U,q),C[$+z+4]=i.x,C[$+z+5]=i.y,C[$+z+6]=i.z,C[$+z+7]=0),g===!0&&(i.fromBufferAttribute(D,q),C[$+z+8]=i.x,C[$+z+9]=i.y,C[$+z+10]=i.z,C[$+z+11]=D.itemSize===4?i.w:1)}}f={count:h,texture:j,size:new In(k,P)},r.set(l,f),l.addEventListener("dispose",E)}if(o.isInstancedMesh===!0&&o.morphTexture!==null)c.getUniforms().setValue(t,"morphTexture",o.morphTexture,n);else{let x=0;for(let g=0;g<d.length;g++)x+=d[g];const v=l.morphTargetsRelative?1:1-x;c.getUniforms().setValue(t,"morphTargetBaseInfluence",v),c.getUniforms().setValue(t,"morphTargetInfluences",d)}c.getUniforms().setValue(t,"morphTargetsTexture",f.texture,n),c.getUniforms().setValue(t,"morphTargetsTextureSize",f.size)}return{update:s}}function wve(t,e,n,r){let i=new WeakMap;function s(c){const d=r.render.frame,u=c.geometry,h=e.get(c,u);if(i.get(h)!==d&&(e.update(h),i.set(h,d)),c.isInstancedMesh&&(c.hasEventListener("dispose",l)===!1&&c.addEventListener("dispose",l),i.get(c)!==d&&(n.update(c.instanceMatrix,t.ARRAY_BUFFER),c.instanceColor!==null&&n.update(c.instanceColor,t.ARRAY_BUFFER),i.set(c,d))),c.isSkinnedMesh){const f=c.skeleton;i.get(f)!==d&&(f.update(),i.set(f,d))}return h}function o(){i=new WeakMap}function l(c){const d=c.target;d.removeEventListener("dispose",l),n.remove(d.instanceMatrix),d.instanceColor!==null&&n.remove(d.instanceColor)}return{update:s,dispose:o}}const yY=new ic,j8=new hY(1,1),vY=new eY,wY=new Ibe,SY=new dY,D8=[],R8=[],F8=new Float32Array(16),L8=new Float32Array(9),O8=new Float32Array(4);function Kb(t,e,n){const r=t[0];if(r<=0||r>0)return t;const i=e*n;let s=D8[i];if(s===void 0&&(s=new Float32Array(i),D8[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 ik(t,e){let n=R8[e];n===void 0&&(n=new Int32Array(e),R8[e]=n);for(let r=0;r!==e;++r)n[r]=t.allocateTextureUnit();return n}function Sve(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function _ve(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 Nve(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 Cve(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 kve(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;O8.set(r),t.uniformMatrix2fv(this.addr,!1,O8),bi(n,r)}}function Ave(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;L8.set(r),t.uniformMatrix3fv(this.addr,!1,L8),bi(n,r)}}function Tve(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;F8.set(r),t.uniformMatrix4fv(this.addr,!1,F8),bi(n,r)}}function Mve(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function Pve(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 Eve(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 jve(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 Dve(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function Rve(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 Fve(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 Lve(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 Ove(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?(j8.compareFunction=KX,s=j8):s=yY,n.setTexture2D(e||s,i)}function Ive(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(e||wY,i)}function zve(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTextureCube(e||SY,i)}function Uve(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(e||vY,i)}function Bve(t){switch(t){case 5126:return Sve;case 35664:return _ve;case 35665:return Nve;case 35666:return Cve;case 35674:return kve;case 35675:return Ave;case 35676:return Tve;case 5124:case 35670:return Mve;case 35667:case 35671:return Pve;case 35668:case 35672:return Eve;case 35669:case 35673:return jve;case 5125:return Dve;case 36294:return Rve;case 36295:return Fve;case 36296:return Lve;case 35678:case 36198:case 36298:case 36306:case 35682:return Ove;case 35679:case 36299:case 36307:return Ive;case 35680:case 36300:case 36308:case 36293:return zve;case 36289:case 36303:case 36311:case 36292:return Uve}}function Hve(t,e){t.uniform1fv(this.addr,e)}function $ve(t,e){const n=Kb(e,this.size,2);t.uniform2fv(this.addr,n)}function Vve(t,e){const n=Kb(e,this.size,3);t.uniform3fv(this.addr,n)}function qve(t,e){const n=Kb(e,this.size,4);t.uniform4fv(this.addr,n)}function Gve(t,e){const n=Kb(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function Wve(t,e){const n=Kb(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function Kve(t,e){const n=Kb(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function Xve(t,e){t.uniform1iv(this.addr,e)}function Yve(t,e){t.uniform2iv(this.addr,e)}function Qve(t,e){t.uniform3iv(this.addr,e)}function Zve(t,e){t.uniform4iv(this.addr,e)}function Jve(t,e){t.uniform1uiv(this.addr,e)}function ewe(t,e){t.uniform2uiv(this.addr,e)}function twe(t,e){t.uniform3uiv(this.addr,e)}function nwe(t,e){t.uniform4uiv(this.addr,e)}function rwe(t,e,n){const r=this.cache,i=e.length,s=ik(n,i);gi(r,s)||(t.uniform1iv(this.addr,s),bi(r,s));for(let o=0;o!==i;++o)n.setTexture2D(e[o]||yY,s[o])}function awe(t,e,n){const r=this.cache,i=e.length,s=ik(n,i);gi(r,s)||(t.uniform1iv(this.addr,s),bi(r,s));for(let o=0;o!==i;++o)n.setTexture3D(e[o]||wY,s[o])}function iwe(t,e,n){const r=this.cache,i=e.length,s=ik(n,i);gi(r,s)||(t.uniform1iv(this.addr,s),bi(r,s));for(let o=0;o!==i;++o)n.setTextureCube(e[o]||SY,s[o])}function swe(t,e,n){const r=this.cache,i=e.length,s=ik(n,i);gi(r,s)||(t.uniform1iv(this.addr,s),bi(r,s));for(let o=0;o!==i;++o)n.setTexture2DArray(e[o]||vY,s[o])}function owe(t){switch(t){case 5126:return Hve;case 35664:return $ve;case 35665:return Vve;case 35666:return qve;case 35674:return Gve;case 35675:return Wve;case 35676:return Kve;case 5124:case 35670:return Xve;case 35667:case 35671:return Yve;case 35668:case 35672:return Qve;case 35669:case 35673:return Zve;case 5125:return Jve;case 36294:return ewe;case 36295:return twe;case 36296:return nwe;case 35678:case 36198:case 36298:case 36306:case 35682:return rwe;case 35679:case 36299:case 36307:return awe;case 35680:case 36300:case 36308:case 36293:return iwe;case 36289:case 36303:case 36311:case 36292:return swe}}let lwe=class{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.setValue=Bve(n.type)}},cwe=class{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.size=n.size,this.setValue=owe(n.type)}},dwe=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 yP=/(\w+)(\])?(\[|\.)?/g;function I8(t,e){t.seq.push(e),t.map[e.id]=e}function uwe(t,e,n){const r=t.name,i=r.length;for(yP.lastIndex=0;;){const s=yP.exec(r),o=yP.lastIndex;let l=s[1];const c=s[2]==="]",d=s[3];if(c&&(l=l|0),d===void 0||d==="["&&o+2===i){I8(n,d===void 0?new lwe(l,t,e):new cwe(l,t,e));break}else{let h=n.map[l];h===void 0&&(h=new dwe(l),I8(n,h)),n=h}}}let X_=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);uwe(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 z8(t,e,n){const r=t.createShader(e);return t.shaderSource(r,n),t.compileShader(r),r}const hwe=37297;let mwe=0;function fwe(t,e){const n=t.split(`
- `),r=[],i=Math.max(e-6,0),s=Math.min(e+6,n.length);for(let o=i;o<s;o++){const l=o+1;r.push(`${l===e?">":" "} ${l}: ${n[o]}`)}return r.join(`
- `)}const U8=new Bn;function pwe(t){fr._getMatrix(U8,fr.workingColorSpace,t);const e=`mat3( ${U8.elements.map(n=>n.toFixed(4))} )`;switch(fr.getTransfer(t)){case k1:return[e,"LinearTransferOETF"];case zr:return[e,"sRGBTransferOETF"];default:return Sn("WebGLProgram: Unsupported color space: ",t),[e,"LinearTransferOETF"]}}function B8(t,e,n){const r=t.getShaderParameter(e,t.COMPILE_STATUS),s=(t.getShaderInfoLog(e)||"").trim();if(r&&s==="")return"";const o=/ERROR: 0:(\d+)/.exec(s);if(o){const l=parseInt(o[1]);return n.toUpperCase()+`
- `+s+`
- `+fwe(t.getShaderSource(e),l)}else return s}function gwe(t,e){const n=pwe(e);return[`vec4 ${t}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join(`
- `)}function bwe(t,e){let n;switch(e){case ube:n="Linear";break;case hbe:n="Reinhard";break;case mbe:n="Cineon";break;case fbe:n="ACESFilmic";break;case gbe:n="AgX";break;case bbe:n="Neutral";break;case pbe:n="Custom";break;default:Sn("WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}const NS=new pt;function xwe(){fr.getLuminanceCoefficients(NS);const t=NS.x.toFixed(4),e=NS.y.toFixed(4),n=NS.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${t}, ${e}, ${n} );`," return dot( weights, rgb );","}"].join(`
- `)}function ywe(t){return[t.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",t.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(ky).join(`
- `)}function vwe(t){const e=[];for(const n in t){const r=t[n];r!==!1&&e.push("#define "+n+" "+r)}return e.join(`
- `)}function wwe(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 ky(t){return t!==""}function H8(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 $8(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const Swe=/^[ \t]*#include +<([\w\d./]+)>/gm;function rD(t){return t.replace(Swe,Nwe)}const _we=new Map;function Nwe(t,e){let n=Rn[e];if(n===void 0){const r=_we.get(e);if(r!==void 0)n=Rn[r],Sn('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,r);else throw new Error("Can not resolve #include <"+e+">")}return rD(n)}const Cwe=/#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 V8(t){return t.replace(Cwe,kwe)}function kwe(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 q8(t){let e=`precision ${t.precision} float;
- precision ${t.precision} int;
- precision ${t.precision} sampler2D;
- precision ${t.precision} samplerCube;
- precision ${t.precision} sampler3D;
- precision ${t.precision} sampler2DArray;
- precision ${t.precision} sampler2DShadow;
- precision ${t.precision} samplerCubeShadow;
- precision ${t.precision} sampler2DArrayShadow;
- precision ${t.precision} isampler2D;
- precision ${t.precision} isampler3D;
- precision ${t.precision} isamplerCube;
- precision ${t.precision} isampler2DArray;
- precision ${t.precision} usampler2D;
- precision ${t.precision} usampler3D;
- precision ${t.precision} usamplerCube;
- precision ${t.precision} usampler2DArray;
- `;return t.precision==="highp"?e+=`
- #define HIGH_PRECISION`:t.precision==="mediump"?e+=`
- #define MEDIUM_PRECISION`:t.precision==="lowp"&&(e+=`
- #define LOW_PRECISION`),e}function Awe(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===IX?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===Vge?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===Md&&(e="SHADOWMAP_TYPE_VSM"),e}function Twe(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case pb:case gb:e="ENVMAP_TYPE_CUBE";break;case nk:e="ENVMAP_TYPE_CUBE_UV";break}return e}function Mwe(t){let e="ENVMAP_MODE_REFLECTION";return t.envMap&&t.envMapMode===gb&&(e="ENVMAP_MODE_REFRACTION"),e}function Pwe(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case OF:e="ENVMAP_BLENDING_MULTIPLY";break;case cbe:e="ENVMAP_BLENDING_MIX";break;case dbe:e="ENVMAP_BLENDING_ADD";break}return e}function Ewe(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 jwe(t,e,n,r){const i=t.getContext(),s=n.defines;let o=n.vertexShader,l=n.fragmentShader;const c=Awe(n),d=Twe(n),u=Mwe(n),h=Pwe(n),f=Ewe(n),p=ywe(n),x=vwe(s),v=i.createProgram();let g,y,_=n.glslVersion?"#version "+n.glslVersion+`
- `:"";n.isRawShaderMaterial?(g=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(ky).join(`
- `),g.length>0&&(g+=`
- `),y=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(ky).join(`
- `),y.length>0&&(y+=`
- `)):(g=[q8(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 "+u:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&n.flatShading===!1?"#define USE_MORPHNORMALS":"",n.morphColors?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
- `].filter(ky).join(`
- `),y=[q8(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 "+d:"",n.envMap?"#define "+u:"",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!==Rh?"#define TONE_MAPPING":"",n.toneMapping!==Rh?Rn.tonemapping_pars_fragment:"",n.toneMapping!==Rh?bwe("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",Rn.colorspace_pars_fragment,gwe("linearToOutputTexel",n.outputColorSpace),xwe(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
- `].filter(ky).join(`
- `)),o=rD(o),o=H8(o,n),o=$8(o,n),l=rD(l),l=H8(l,n),l=$8(l,n),o=V8(o),l=V8(l),n.isRawShaderMaterial!==!0&&(_=`#version 300 es
- `,g=[p,"#define attribute in","#define varying out","#define texture2D texture"].join(`
- `)+`
- `+g,y=["#define varying in",n.glslVersion===QB?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===QB?"":"#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(`
- `)+`
- `+y);const N=_+g+o,A=_+y+l,k=z8(i,i.VERTEX_SHADER,N),P=z8(i,i.FRAGMENT_SHADER,A);i.attachShader(v,k),i.attachShader(v,P),n.index0AttributeName!==void 0?i.bindAttribLocation(v,0,n.index0AttributeName):n.morphTargets===!0&&i.bindAttribLocation(v,0,"position"),i.linkProgram(v);function C(B){if(t.debug.checkShaderErrors){const L=i.getProgramInfoLog(v)||"",U=i.getShaderInfoLog(k)||"",D=i.getShaderInfoLog(P)||"",$=L.trim(),q=U.trim(),z=D.trim();let W=!0,Q=!0;if(i.getProgramParameter(v,i.LINK_STATUS)===!1)if(W=!1,typeof t.debug.onShaderError=="function")t.debug.onShaderError(i,v,k,P);else{const te=B8(i,k,"vertex"),H=B8(i,P,"fragment");$a("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(v,i.VALIDATE_STATUS)+`
- Material Name: `+B.name+`
- Material Type: `+B.type+`
- Program Info Log: `+$+`
- `+te+`
- `+H)}else $!==""?Sn("WebGLProgram: Program Info Log:",$):(q===""||z==="")&&(Q=!1);Q&&(B.diagnostics={runnable:W,programLog:$,vertexShader:{log:q,prefix:g},fragmentShader:{log:z,prefix:y}})}i.deleteShader(k),i.deleteShader(P),j=new X_(i,v),M=wwe(i,v)}let j;this.getUniforms=function(){return j===void 0&&C(this),j};let M;this.getAttributes=function(){return M===void 0&&C(this),M};let E=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return E===!1&&(E=i.getProgramParameter(v,hwe)),E},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(v),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=mwe++,this.cacheKey=e,this.usedTimes=1,this.program=v,this.vertexShader=k,this.fragmentShader=P,this}let Dwe=0,Rwe=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 Fwe(e),n.set(e,r)),r}},Fwe=class{constructor(e){this.id=Dwe++,this.code=e,this.usedTimes=0}};function Lwe(t,e,n,r,i,s,o){const l=new nY,c=new Rwe,d=new Set,u=[],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 d.add(M),M===0?"uv":`uv${M}`}function g(M,E,B,L,U){const D=L.fog,$=U.geometry,q=M.isMeshStandardMaterial?L.environment:null,z=(M.isMeshStandardMaterial?n:e).get(M.envMap||q),W=z&&z.mapping===nk?z.image.height:null,Q=x[M.type];M.precision!==null&&(p=i.getMaxPrecision(M.precision),p!==M.precision&&Sn("WebGLProgram.getParameters:",M.precision,"not supported, using",p,"instead."));const te=$.morphAttributes.position||$.morphAttributes.normal||$.morphAttributes.color,H=te!==void 0?te.length:0;let X=0;$.morphAttributes.position!==void 0&&(X=1),$.morphAttributes.normal!==void 0&&(X=2),$.morphAttributes.color!==void 0&&(X=3);let Z,ee,Se,oe;if(Q){const Ft=Sc[Q];Z=Ft.vertexShader,ee=Ft.fragmentShader}else Z=M.vertexShader,ee=M.fragmentShader,c.update(M),Se=c.getVertexShaderID(M),oe=c.getFragmentShaderID(M);const ie=t.getRenderTarget(),me=t.state.buffers.depth.getReversed(),se=U.isInstancedMesh===!0,ce=U.isBatchedMesh===!0,Ce=!!M.map,le=!!M.matcap,Le=!!z,V=!!M.aoMap,K=!!M.lightMap,fe=!!M.bumpMap,Y=!!M.normalMap,re=!!M.displacementMap,ue=!!M.emissiveMap,Fe=!!M.metalnessMap,Pe=!!M.roughnessMap,be=M.anisotropy>0,O=M.clearcoat>0,R=M.dispersion>0,G=M.iridescence>0,de=M.sheen>0,ge=M.transmission>0,ae=be&&!!M.anisotropyMap,Ue=O&&!!M.clearcoatMap,ze=O&&!!M.clearcoatNormalMap,$e=O&&!!M.clearcoatRoughnessMap,Re=G&&!!M.iridescenceMap,pe=G&&!!M.iridescenceThicknessMap,ve=de&&!!M.sheenColorMap,Ne=de&&!!M.sheenRoughnessMap,xe=!!M.specularMap,we=!!M.specularColorMap,qe=!!M.specularIntensityMap,ke=ge&&!!M.transmissionMap,nt=ge&&!!M.thicknessMap,De=!!M.gradientMap,We=!!M.alphaMap,Oe=M.alphaTest>0,je=!!M.alphaHash,Ve=!!M.extensions;let ot=Rh;M.toneMapped&&(ie===null||ie.isXRRenderTarget===!0)&&(ot=t.toneMapping);const kt={shaderID:Q,shaderType:M.type,shaderName:M.name,vertexShader:Z,fragmentShader:ee,defines:M.defines,customVertexShaderID:Se,customFragmentShaderID:oe,isRawShaderMaterial:M.isRawShaderMaterial===!0,glslVersion:M.glslVersion,precision:p,batching:ce,batchingColor:ce&&U._colorsTexture!==null,instancing:se,instancingColor:se&&U.instanceColor!==null,instancingMorph:se&&U.morphTexture!==null,supportsVertexTextures:f,outputColorSpace:ie===null?t.outputColorSpace:ie.isXRRenderTarget===!0?ie.texture.colorSpace:bb,alphaToCoverage:!!M.alphaToCoverage,map:Ce,matcap:le,envMap:Le,envMapMode:Le&&z.mapping,envMapCubeUVHeight:W,aoMap:V,lightMap:K,bumpMap:fe,normalMap:Y,displacementMap:f&&re,emissiveMap:ue,normalMapObjectSpace:Y&&M.normalMapType===wbe,normalMapTangentSpace:Y&&M.normalMapType===WX,metalnessMap:Fe,roughnessMap:Pe,anisotropy:be,anisotropyMap:ae,clearcoat:O,clearcoatMap:Ue,clearcoatNormalMap:ze,clearcoatRoughnessMap:$e,dispersion:R,iridescence:G,iridescenceMap:Re,iridescenceThicknessMap:pe,sheen:de,sheenColorMap:ve,sheenRoughnessMap:Ne,specularMap:xe,specularColorMap:we,specularIntensityMap:qe,transmission:ge,transmissionMap:ke,thicknessMap:nt,gradientMap:De,opaque:M.transparent===!1&&M.blending===Qg&&M.alphaToCoverage===!1,alphaMap:We,alphaTest:Oe,alphaHash:je,combine:M.combine,mapUv:Ce&&v(M.map.channel),aoMapUv:V&&v(M.aoMap.channel),lightMapUv:K&&v(M.lightMap.channel),bumpMapUv:fe&&v(M.bumpMap.channel),normalMapUv:Y&&v(M.normalMap.channel),displacementMapUv:re&&v(M.displacementMap.channel),emissiveMapUv:ue&&v(M.emissiveMap.channel),metalnessMapUv:Fe&&v(M.metalnessMap.channel),roughnessMapUv:Pe&&v(M.roughnessMap.channel),anisotropyMapUv:ae&&v(M.anisotropyMap.channel),clearcoatMapUv:Ue&&v(M.clearcoatMap.channel),clearcoatNormalMapUv:ze&&v(M.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:$e&&v(M.clearcoatRoughnessMap.channel),iridescenceMapUv:Re&&v(M.iridescenceMap.channel),iridescenceThicknessMapUv:pe&&v(M.iridescenceThicknessMap.channel),sheenColorMapUv:ve&&v(M.sheenColorMap.channel),sheenRoughnessMapUv:Ne&&v(M.sheenRoughnessMap.channel),specularMapUv:xe&&v(M.specularMap.channel),specularColorMapUv:we&&v(M.specularColorMap.channel),specularIntensityMapUv:qe&&v(M.specularIntensityMap.channel),transmissionMapUv:ke&&v(M.transmissionMap.channel),thicknessMapUv:nt&&v(M.thicknessMap.channel),alphaMapUv:We&&v(M.alphaMap.channel),vertexTangents:!!$.attributes.tangent&&(Y||be),vertexColors:M.vertexColors,vertexAlphas:M.vertexColors===!0&&!!$.attributes.color&&$.attributes.color.itemSize===4,pointsUvs:U.isPoints===!0&&!!$.attributes.uv&&(Ce||We),fog:!!D,useFog:M.fog===!0,fogExp2:!!D&&D.isFogExp2,flatShading:M.flatShading===!0&&M.wireframe===!1,sizeAttenuation:M.sizeAttenuation===!0,logarithmicDepthBuffer:h,reversedDepthBuffer:me,skinning:U.isSkinnedMesh===!0,morphTargets:$.morphAttributes.position!==void 0,morphNormals:$.morphAttributes.normal!==void 0,morphColors:$.morphAttributes.color!==void 0,morphTargetsCount:H,morphTextureStride:X,numDirLights:E.directional.length,numPointLights:E.point.length,numSpotLights:E.spot.length,numSpotLightMaps:E.spotLightMap.length,numRectAreaLights:E.rectArea.length,numHemiLights:E.hemi.length,numDirLightShadows:E.directionalShadowMap.length,numPointLightShadows:E.pointShadowMap.length,numSpotLightShadows:E.spotShadowMap.length,numSpotLightShadowsWithMaps:E.numSpotLightShadowsWithMaps,numLightProbes:E.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:M.dithering,shadowMapEnabled:t.shadowMap.enabled&&B.length>0,shadowMapType:t.shadowMap.type,toneMapping:ot,decodeVideoTexture:Ce&&M.map.isVideoTexture===!0&&fr.getTransfer(M.map.colorSpace)===zr,decodeVideoTextureEmissive:ue&&M.emissiveMap.isVideoTexture===!0&&fr.getTransfer(M.emissiveMap.colorSpace)===zr,premultipliedAlpha:M.premultipliedAlpha,doubleSided:M.side===Nc,flipSided:M.side===ro,useDepthPacking:M.depthPacking>=0,depthPacking:M.depthPacking||0,index0AttributeName:M.index0AttributeName,extensionClipCullDistance:Ve&&M.extensions.clipCullDistance===!0&&r.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(Ve&&M.extensions.multiDraw===!0||ce)&&r.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:r.has("KHR_parallel_shader_compile"),customProgramCacheKey:M.customProgramCacheKey()};return kt.vertexUv1s=d.has(1),kt.vertexUv2s=d.has(2),kt.vertexUv3s=d.has(3),d.clear(),kt}function y(M){const E=[];if(M.shaderID?E.push(M.shaderID):(E.push(M.customVertexShaderID),E.push(M.customFragmentShaderID)),M.defines!==void 0)for(const B in M.defines)E.push(B),E.push(M.defines[B]);return M.isRawShaderMaterial===!1&&(_(E,M),N(E,M),E.push(t.outputColorSpace)),E.push(M.customProgramCacheKey),E.join()}function _(M,E){M.push(E.precision),M.push(E.outputColorSpace),M.push(E.envMapMode),M.push(E.envMapCubeUVHeight),M.push(E.mapUv),M.push(E.alphaMapUv),M.push(E.lightMapUv),M.push(E.aoMapUv),M.push(E.bumpMapUv),M.push(E.normalMapUv),M.push(E.displacementMapUv),M.push(E.emissiveMapUv),M.push(E.metalnessMapUv),M.push(E.roughnessMapUv),M.push(E.anisotropyMapUv),M.push(E.clearcoatMapUv),M.push(E.clearcoatNormalMapUv),M.push(E.clearcoatRoughnessMapUv),M.push(E.iridescenceMapUv),M.push(E.iridescenceThicknessMapUv),M.push(E.sheenColorMapUv),M.push(E.sheenRoughnessMapUv),M.push(E.specularMapUv),M.push(E.specularColorMapUv),M.push(E.specularIntensityMapUv),M.push(E.transmissionMapUv),M.push(E.thicknessMapUv),M.push(E.combine),M.push(E.fogExp2),M.push(E.sizeAttenuation),M.push(E.morphTargetsCount),M.push(E.morphAttributeCount),M.push(E.numDirLights),M.push(E.numPointLights),M.push(E.numSpotLights),M.push(E.numSpotLightMaps),M.push(E.numHemiLights),M.push(E.numRectAreaLights),M.push(E.numDirLightShadows),M.push(E.numPointLightShadows),M.push(E.numSpotLightShadows),M.push(E.numSpotLightShadowsWithMaps),M.push(E.numLightProbes),M.push(E.shadowMapType),M.push(E.toneMapping),M.push(E.numClippingPlanes),M.push(E.numClipIntersection),M.push(E.depthPacking)}function N(M,E){l.disableAll(),E.supportsVertexTextures&&l.enable(0),E.instancing&&l.enable(1),E.instancingColor&&l.enable(2),E.instancingMorph&&l.enable(3),E.matcap&&l.enable(4),E.envMap&&l.enable(5),E.normalMapObjectSpace&&l.enable(6),E.normalMapTangentSpace&&l.enable(7),E.clearcoat&&l.enable(8),E.iridescence&&l.enable(9),E.alphaTest&&l.enable(10),E.vertexColors&&l.enable(11),E.vertexAlphas&&l.enable(12),E.vertexUv1s&&l.enable(13),E.vertexUv2s&&l.enable(14),E.vertexUv3s&&l.enable(15),E.vertexTangents&&l.enable(16),E.anisotropy&&l.enable(17),E.alphaHash&&l.enable(18),E.batching&&l.enable(19),E.dispersion&&l.enable(20),E.batchingColor&&l.enable(21),E.gradientMap&&l.enable(22),M.push(l.mask),l.disableAll(),E.fog&&l.enable(0),E.useFog&&l.enable(1),E.flatShading&&l.enable(2),E.logarithmicDepthBuffer&&l.enable(3),E.reversedDepthBuffer&&l.enable(4),E.skinning&&l.enable(5),E.morphTargets&&l.enable(6),E.morphNormals&&l.enable(7),E.morphColors&&l.enable(8),E.premultipliedAlpha&&l.enable(9),E.shadowMapEnabled&&l.enable(10),E.doubleSided&&l.enable(11),E.flipSided&&l.enable(12),E.useDepthPacking&&l.enable(13),E.dithering&&l.enable(14),E.transmission&&l.enable(15),E.sheen&&l.enable(16),E.opaque&&l.enable(17),E.pointsUvs&&l.enable(18),E.decodeVideoTexture&&l.enable(19),E.decodeVideoTextureEmissive&&l.enable(20),E.alphaToCoverage&&l.enable(21),M.push(l.mask)}function A(M){const E=x[M.type];let B;if(E){const L=Sc[E];B=Qbe.clone(L.uniforms)}else B=M.uniforms;return B}function k(M,E){let B;for(let L=0,U=u.length;L<U;L++){const D=u[L];if(D.cacheKey===E){B=D,++B.usedTimes;break}}return B===void 0&&(B=new jwe(t,E,M,s),u.push(B)),B}function P(M){if(--M.usedTimes===0){const E=u.indexOf(M);u[E]=u[u.length-1],u.pop(),M.destroy()}}function C(M){c.remove(M)}function j(){c.dispose()}return{getParameters:g,getProgramCacheKey:y,getUniforms:A,acquireProgram:k,releaseProgram:P,releaseShaderCache:C,programs:u,dispose:j}}function Owe(){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 Iwe(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 G8(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 W8(){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 d(h,f){n.length>1&&n.sort(h||Iwe),r.length>1&&r.sort(f||G8),i.length>1&&i.sort(f||G8)}function u(){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:u,sort:d}}function zwe(){let t=new WeakMap;function e(r,i){const s=t.get(r);let o;return s===void 0?(o=new W8,t.set(r,[o])):i>=s.length?(o=new W8,s.push(o)):o=s[i],o}function n(){t=new WeakMap}return{get:e,dispose:n}}function Uwe(){const t={};return{get:function(e){if(t[e.id]!==void 0)return t[e.id];let n;switch(e.type){case"DirectionalLight":n={direction:new pt,color:new Hn};break;case"SpotLight":n={position:new pt,direction:new pt,color:new Hn,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new pt,color:new Hn,distance:0,decay:0};break;case"HemisphereLight":n={direction:new pt,skyColor:new Hn,groundColor:new Hn};break;case"RectAreaLight":n={color:new Hn,position:new pt,halfWidth:new pt,halfHeight:new pt};break}return t[e.id]=n,n}}}function Bwe(){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 In};break;case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new In};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new In,shadowCameraNear:1,shadowCameraFar:1e3};break}return t[e.id]=n,n}}}let Hwe=0;function $we(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function Vwe(t){const e=new Uwe,n=Bwe(),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 d=0;d<9;d++)r.probe.push(new pt);const i=new pt,s=new ai,o=new ai;function l(d){let u=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,k=0,P=0,C=0;d.sort($we);for(let M=0,E=d.length;M<E;M++){const B=d[M],L=B.color,U=B.intensity,D=B.distance,$=B.shadow&&B.shadow.map?B.shadow.map.texture:null;if(B.isAmbientLight)u+=L.r*U,h+=L.g*U,f+=L.b*U;else if(B.isLightProbe){for(let q=0;q<9;q++)r.probe[q].addScaledVector(B.sh.coefficients[q],U);C++}else if(B.isDirectionalLight){const q=e.get(B);if(q.color.copy(B.color).multiplyScalar(B.intensity),B.castShadow){const z=B.shadow,W=n.get(B);W.shadowIntensity=z.intensity,W.shadowBias=z.bias,W.shadowNormalBias=z.normalBias,W.shadowRadius=z.radius,W.shadowMapSize=z.mapSize,r.directionalShadow[p]=W,r.directionalShadowMap[p]=$,r.directionalShadowMatrix[p]=B.shadow.matrix,_++}r.directional[p]=q,p++}else if(B.isSpotLight){const q=e.get(B);q.position.setFromMatrixPosition(B.matrixWorld),q.color.copy(L).multiplyScalar(U),q.distance=D,q.coneCos=Math.cos(B.angle),q.penumbraCos=Math.cos(B.angle*(1-B.penumbra)),q.decay=B.decay,r.spot[v]=q;const z=B.shadow;if(B.map&&(r.spotLightMap[k]=B.map,k++,z.updateMatrices(B),B.castShadow&&P++),r.spotLightMatrix[v]=z.matrix,B.castShadow){const W=n.get(B);W.shadowIntensity=z.intensity,W.shadowBias=z.bias,W.shadowNormalBias=z.normalBias,W.shadowRadius=z.radius,W.shadowMapSize=z.mapSize,r.spotShadow[v]=W,r.spotShadowMap[v]=$,A++}v++}else if(B.isRectAreaLight){const q=e.get(B);q.color.copy(L).multiplyScalar(U),q.halfWidth.set(B.width*.5,0,0),q.halfHeight.set(0,B.height*.5,0),r.rectArea[g]=q,g++}else if(B.isPointLight){const q=e.get(B);if(q.color.copy(B.color).multiplyScalar(B.intensity),q.distance=B.distance,q.decay=B.decay,B.castShadow){const z=B.shadow,W=n.get(B);W.shadowIntensity=z.intensity,W.shadowBias=z.bias,W.shadowNormalBias=z.normalBias,W.shadowRadius=z.radius,W.shadowMapSize=z.mapSize,W.shadowCameraNear=z.camera.near,W.shadowCameraFar=z.camera.far,r.pointShadow[x]=W,r.pointShadowMap[x]=$,r.pointShadowMatrix[x]=B.shadow.matrix,N++}r.point[x]=q,x++}else if(B.isHemisphereLight){const q=e.get(B);q.skyColor.copy(B.color).multiplyScalar(U),q.groundColor.copy(B.groundColor).multiplyScalar(U),r.hemi[y]=q,y++}}g>0&&(t.has("OES_texture_float_linear")===!0?(r.rectAreaLTC1=Ht.LTC_FLOAT_1,r.rectAreaLTC2=Ht.LTC_FLOAT_2):(r.rectAreaLTC1=Ht.LTC_HALF_1,r.rectAreaLTC2=Ht.LTC_HALF_2)),r.ambient[0]=u,r.ambient[1]=h,r.ambient[2]=f;const j=r.hash;(j.directionalLength!==p||j.pointLength!==x||j.spotLength!==v||j.rectAreaLength!==g||j.hemiLength!==y||j.numDirectionalShadows!==_||j.numPointShadows!==N||j.numSpotShadows!==A||j.numSpotMaps!==k||j.numLightProbes!==C)&&(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+k-P,r.spotLightMap.length=k,r.numSpotLightShadowsWithMaps=P,r.numLightProbes=C,j.directionalLength=p,j.pointLength=x,j.spotLength=v,j.rectAreaLength=g,j.hemiLength=y,j.numDirectionalShadows=_,j.numPointShadows=N,j.numSpotShadows=A,j.numSpotMaps=k,j.numLightProbes=C,r.version=Hwe++)}function c(d,u){let h=0,f=0,p=0,x=0,v=0;const g=u.matrixWorldInverse;for(let y=0,_=d.length;y<_;y++){const N=d[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 K8(t){const e=new Vwe(t),n=[],r=[];function i(u){d.camera=u,n.length=0,r.length=0}function s(u){n.push(u)}function o(u){r.push(u)}function l(){e.setup(n)}function c(u){e.setupView(n,u)}const d={lightsArray:n,shadowsArray:r,camera:null,lights:e,transmissionRenderTarget:{}};return{init:i,state:d,setupLights:l,setupLightsView:c,pushLight:s,pushShadow:o}}function qwe(t){let e=new WeakMap;function n(i,s=0){const o=e.get(i);let l;return o===void 0?(l=new K8(t),e.set(i,[l])):s>=o.length?(l=new K8(t),o.push(l)):l=o[s],l}function r(){e=new WeakMap}return{get:n,dispose:r}}const Gwe=`void main() {
- gl_Position = vec4( position, 1.0 );
- }`,Wwe=`uniform sampler2D shadow_pass;
- uniform vec2 resolution;
- uniform float radius;
- #include <packing>
- void main() {
- const float samples = float( VSM_SAMPLES );
- float mean = 0.0;
- float squared_mean = 0.0;
- float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
- float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
- for ( float i = 0.0; i < samples; i ++ ) {
- float uvOffset = uvStart + i * uvStride;
- #ifdef HORIZONTAL_PASS
- vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
- mean += distribution.x;
- squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
- #else
- float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
- mean += depth;
- squared_mean += depth * depth;
- #endif
- }
- mean = mean / samples;
- squared_mean = squared_mean / samples;
- float std_dev = sqrt( squared_mean - mean * mean );
- gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
- }`;function Kwe(t,e,n){let r=new XF;const i=new In,s=new In,o=new Ja,l=new dxe({depthPacking:vbe}),c=new uxe,d={},u=n.maxTextureSize,h={[Wh]:ro,[ro]:Wh,[Nc]:Nc},f=new iu({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new In},radius:{value:4}},vertexShader:Gwe,fragmentShader:Wwe}),p=f.clone();p.defines.HORIZONTAL_PASS=1;const x=new _l;x.setAttribute("position",new Rs(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const v=new Nl(x,f),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=IX;let y=this.type;this.render=function(P,C,j){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||P.length===0)return;const M=t.getRenderTarget(),E=t.getActiveCubeFace(),B=t.getActiveMipmapLevel(),L=t.state;L.setBlending(qd),L.buffers.depth.getReversed()===!0?L.buffers.color.setClear(0,0,0,0):L.buffers.color.setClear(1,1,1,1),L.buffers.depth.setTest(!0),L.setScissorTest(!1);const U=y!==Md&&this.type===Md,D=y===Md&&this.type!==Md;for(let $=0,q=P.length;$<q;$++){const z=P[$],W=z.shadow;if(W===void 0){Sn("WebGLShadowMap:",z,"has no shadow.");continue}if(W.autoUpdate===!1&&W.needsUpdate===!1)continue;i.copy(W.mapSize);const Q=W.getFrameExtents();if(i.multiply(Q),s.copy(W.mapSize),(i.x>u||i.y>u)&&(i.x>u&&(s.x=Math.floor(u/Q.x),i.x=s.x*Q.x,W.mapSize.x=s.x),i.y>u&&(s.y=Math.floor(u/Q.y),i.y=s.y*Q.y,W.mapSize.y=s.y)),W.map===null||U===!0||D===!0){const H=this.type!==Md?{minFilter:Eo,magFilter:Eo}:{};W.map!==null&&W.map.dispose(),W.map=new Lf(i.x,i.y,H),W.map.texture.name=z.name+".shadowMap",W.camera.updateProjectionMatrix()}t.setRenderTarget(W.map),t.clear();const te=W.getViewportCount();for(let H=0;H<te;H++){const X=W.getViewport(H);o.set(s.x*X.x,s.y*X.y,s.x*X.z,s.y*X.w),L.viewport(o),W.updateMatrices(z,H),r=W.getFrustum(),A(C,j,W.camera,z,this.type)}W.isPointLightShadow!==!0&&this.type===Md&&_(W,j),W.needsUpdate=!1}y=this.type,g.needsUpdate=!1,t.setRenderTarget(M,E,B)};function _(P,C){const j=e.update(v);f.defines.VSM_SAMPLES!==P.blurSamples&&(f.defines.VSM_SAMPLES=P.blurSamples,p.defines.VSM_SAMPLES=P.blurSamples,f.needsUpdate=!0,p.needsUpdate=!0),P.mapPass===null&&(P.mapPass=new Lf(i.x,i.y)),f.uniforms.shadow_pass.value=P.map.texture,f.uniforms.resolution.value=P.mapSize,f.uniforms.radius.value=P.radius,t.setRenderTarget(P.mapPass),t.clear(),t.renderBufferDirect(C,null,j,f,v,null),p.uniforms.shadow_pass.value=P.mapPass.texture,p.uniforms.resolution.value=P.mapSize,p.uniforms.radius.value=P.radius,t.setRenderTarget(P.map),t.clear(),t.renderBufferDirect(C,null,j,p,v,null)}function N(P,C,j,M){let E=null;const B=j.isPointLight===!0?P.customDistanceMaterial:P.customDepthMaterial;if(B!==void 0)E=B;else if(E=j.isPointLight===!0?c:l,t.localClippingEnabled&&C.clipShadows===!0&&Array.isArray(C.clippingPlanes)&&C.clippingPlanes.length!==0||C.displacementMap&&C.displacementScale!==0||C.alphaMap&&C.alphaTest>0||C.map&&C.alphaTest>0||C.alphaToCoverage===!0){const L=E.uuid,U=C.uuid;let D=d[L];D===void 0&&(D={},d[L]=D);let $=D[U];$===void 0&&($=E.clone(),D[U]=$,C.addEventListener("dispose",k)),E=$}if(E.visible=C.visible,E.wireframe=C.wireframe,M===Md?E.side=C.shadowSide!==null?C.shadowSide:C.side:E.side=C.shadowSide!==null?C.shadowSide:h[C.side],E.alphaMap=C.alphaMap,E.alphaTest=C.alphaToCoverage===!0?.5:C.alphaTest,E.map=C.map,E.clipShadows=C.clipShadows,E.clippingPlanes=C.clippingPlanes,E.clipIntersection=C.clipIntersection,E.displacementMap=C.displacementMap,E.displacementScale=C.displacementScale,E.displacementBias=C.displacementBias,E.wireframeLinewidth=C.wireframeLinewidth,E.linewidth=C.linewidth,j.isPointLight===!0&&E.isMeshDistanceMaterial===!0){const L=t.properties.get(E);L.light=j}return E}function A(P,C,j,M,E){if(P.visible===!1)return;if(P.layers.test(C.layers)&&(P.isMesh||P.isLine||P.isPoints)&&(P.castShadow||P.receiveShadow&&E===Md)&&(!P.frustumCulled||r.intersectsObject(P))){P.modelViewMatrix.multiplyMatrices(j.matrixWorldInverse,P.matrixWorld);const U=e.update(P),D=P.material;if(Array.isArray(D)){const $=U.groups;for(let q=0,z=$.length;q<z;q++){const W=$[q],Q=D[W.materialIndex];if(Q&&Q.visible){const te=N(P,Q,M,E);P.onBeforeShadow(t,P,C,j,U,te,W),t.renderBufferDirect(j,null,U,te,P,W),P.onAfterShadow(t,P,C,j,U,te,W)}}}else if(D.visible){const $=N(P,D,M,E);P.onBeforeShadow(t,P,C,j,U,$,null),t.renderBufferDirect(j,null,U,$,P,null),P.onAfterShadow(t,P,C,j,U,$,null)}}const L=P.children;for(let U=0,D=L.length;U<D;U++)A(L[U],C,j,M,E)}function k(P){P.target.removeEventListener("dispose",k);for(const j in d){const M=d[j],E=P.target.uuid;E in M&&(M[E].dispose(),delete M[E])}}}const Xwe={[g3]:b3,[x3]:w3,[y3]:S3,[fb]:v3,[b3]:g3,[w3]:x3,[S3]:y3,[v3]:fb};function Ywe(t,e){function n(){let ke=!1;const nt=new Ja;let De=null;const We=new Ja(0,0,0,0);return{setMask:function(Oe){De!==Oe&&!ke&&(t.colorMask(Oe,Oe,Oe,Oe),De=Oe)},setLocked:function(Oe){ke=Oe},setClear:function(Oe,je,Ve,ot,kt){kt===!0&&(Oe*=ot,je*=ot,Ve*=ot),nt.set(Oe,je,Ve,ot),We.equals(nt)===!1&&(t.clearColor(Oe,je,Ve,ot),We.copy(nt))},reset:function(){ke=!1,De=null,We.set(-1,0,0,0)}}}function r(){let ke=!1,nt=!1,De=null,We=null,Oe=null;return{setReversed:function(je){if(nt!==je){const Ve=e.get("EXT_clip_control");je?Ve.clipControlEXT(Ve.LOWER_LEFT_EXT,Ve.ZERO_TO_ONE_EXT):Ve.clipControlEXT(Ve.LOWER_LEFT_EXT,Ve.NEGATIVE_ONE_TO_ONE_EXT),nt=je;const ot=Oe;Oe=null,this.setClear(ot)}},getReversed:function(){return nt},setTest:function(je){je?ie(t.DEPTH_TEST):me(t.DEPTH_TEST)},setMask:function(je){De!==je&&!ke&&(t.depthMask(je),De=je)},setFunc:function(je){if(nt&&(je=Xwe[je]),We!==je){switch(je){case g3:t.depthFunc(t.NEVER);break;case b3:t.depthFunc(t.ALWAYS);break;case x3:t.depthFunc(t.LESS);break;case fb:t.depthFunc(t.LEQUAL);break;case y3:t.depthFunc(t.EQUAL);break;case v3:t.depthFunc(t.GEQUAL);break;case w3:t.depthFunc(t.GREATER);break;case S3:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}We=je}},setLocked:function(je){ke=je},setClear:function(je){Oe!==je&&(nt&&(je=1-je),t.clearDepth(je),Oe=je)},reset:function(){ke=!1,De=null,We=null,Oe=null,nt=!1}}}function i(){let ke=!1,nt=null,De=null,We=null,Oe=null,je=null,Ve=null,ot=null,kt=null;return{setTest:function(Ft){ke||(Ft?ie(t.STENCIL_TEST):me(t.STENCIL_TEST))},setMask:function(Ft){nt!==Ft&&!ke&&(t.stencilMask(Ft),nt=Ft)},setFunc:function(Ft,Vt,At){(De!==Ft||We!==Vt||Oe!==At)&&(t.stencilFunc(Ft,Vt,At),De=Ft,We=Vt,Oe=At)},setOp:function(Ft,Vt,At){(je!==Ft||Ve!==Vt||ot!==At)&&(t.stencilOp(Ft,Vt,At),je=Ft,Ve=Vt,ot=At)},setLocked:function(Ft){ke=Ft},setClear:function(Ft){kt!==Ft&&(t.clearStencil(Ft),kt=Ft)},reset:function(){ke=!1,nt=null,De=null,We=null,Oe=null,je=null,Ve=null,ot=null,kt=null}}}const s=new n,o=new r,l=new i,c=new WeakMap,d=new WeakMap;let u={},h={},f=new WeakMap,p=[],x=null,v=!1,g=null,y=null,_=null,N=null,A=null,k=null,P=null,C=new Hn(0,0,0),j=0,M=!1,E=null,B=null,L=null,U=null,D=null;const $=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let q=!1,z=0;const W=t.getParameter(t.VERSION);W.indexOf("WebGL")!==-1?(z=parseFloat(/^WebGL (\d)/.exec(W)[1]),q=z>=1):W.indexOf("OpenGL ES")!==-1&&(z=parseFloat(/^OpenGL ES (\d)/.exec(W)[1]),q=z>=2);let Q=null,te={};const H=t.getParameter(t.SCISSOR_BOX),X=t.getParameter(t.VIEWPORT),Z=new Ja().fromArray(H),ee=new Ja().fromArray(X);function Se(ke,nt,De,We){const Oe=new Uint8Array(4),je=t.createTexture();t.bindTexture(ke,je),t.texParameteri(ke,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(ke,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let Ve=0;Ve<De;Ve++)ke===t.TEXTURE_3D||ke===t.TEXTURE_2D_ARRAY?t.texImage3D(nt,0,t.RGBA,1,1,We,0,t.RGBA,t.UNSIGNED_BYTE,Oe):t.texImage2D(nt+Ve,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,Oe);return je}const oe={};oe[t.TEXTURE_2D]=Se(t.TEXTURE_2D,t.TEXTURE_2D,1),oe[t.TEXTURE_CUBE_MAP]=Se(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),oe[t.TEXTURE_2D_ARRAY]=Se(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),oe[t.TEXTURE_3D]=Se(t.TEXTURE_3D,t.TEXTURE_3D,1,1),s.setClear(0,0,0,1),o.setClear(1),l.setClear(0),ie(t.DEPTH_TEST),o.setFunc(fb),fe(!1),Y(qB),ie(t.CULL_FACE),V(qd);function ie(ke){u[ke]!==!0&&(t.enable(ke),u[ke]=!0)}function me(ke){u[ke]!==!1&&(t.disable(ke),u[ke]=!1)}function se(ke,nt){return h[ke]!==nt?(t.bindFramebuffer(ke,nt),h[ke]=nt,ke===t.DRAW_FRAMEBUFFER&&(h[t.FRAMEBUFFER]=nt),ke===t.FRAMEBUFFER&&(h[t.DRAW_FRAMEBUFFER]=nt),!0):!1}function ce(ke,nt){let De=p,We=!1;if(ke){De=f.get(nt),De===void 0&&(De=[],f.set(nt,De));const Oe=ke.textures;if(De.length!==Oe.length||De[0]!==t.COLOR_ATTACHMENT0){for(let je=0,Ve=Oe.length;je<Ve;je++)De[je]=t.COLOR_ATTACHMENT0+je;De.length=Oe.length,We=!0}}else De[0]!==t.BACK&&(De[0]=t.BACK,We=!0);We&&t.drawBuffers(De)}function Ce(ke){return x!==ke?(t.useProgram(ke),x=ke,!0):!1}const le={[Wm]:t.FUNC_ADD,[Gge]:t.FUNC_SUBTRACT,[Wge]:t.FUNC_REVERSE_SUBTRACT};le[Kge]=t.MIN,le[Xge]=t.MAX;const Le={[Yge]:t.ZERO,[Qge]:t.ONE,[Zge]:t.SRC_COLOR,[f3]:t.SRC_ALPHA,[abe]:t.SRC_ALPHA_SATURATE,[nbe]:t.DST_COLOR,[ebe]:t.DST_ALPHA,[Jge]:t.ONE_MINUS_SRC_COLOR,[p3]:t.ONE_MINUS_SRC_ALPHA,[rbe]:t.ONE_MINUS_DST_COLOR,[tbe]:t.ONE_MINUS_DST_ALPHA,[ibe]:t.CONSTANT_COLOR,[sbe]:t.ONE_MINUS_CONSTANT_COLOR,[obe]:t.CONSTANT_ALPHA,[lbe]:t.ONE_MINUS_CONSTANT_ALPHA};function V(ke,nt,De,We,Oe,je,Ve,ot,kt,Ft){if(ke===qd){v===!0&&(me(t.BLEND),v=!1);return}if(v===!1&&(ie(t.BLEND),v=!0),ke!==qge){if(ke!==g||Ft!==M){if((y!==Wm||A!==Wm)&&(t.blendEquation(t.FUNC_ADD),y=Wm,A=Wm),Ft)switch(ke){case Qg:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case GB:t.blendFunc(t.ONE,t.ONE);break;case WB:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case KB:t.blendFuncSeparate(t.DST_COLOR,t.ONE_MINUS_SRC_ALPHA,t.ZERO,t.ONE);break;default:$a("WebGLState: Invalid blending: ",ke);break}else switch(ke){case Qg:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case GB:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE,t.ONE,t.ONE);break;case WB:$a("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case KB:$a("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:$a("WebGLState: Invalid blending: ",ke);break}_=null,N=null,k=null,P=null,C.set(0,0,0),j=0,g=ke,M=Ft}return}Oe=Oe||nt,je=je||De,Ve=Ve||We,(nt!==y||Oe!==A)&&(t.blendEquationSeparate(le[nt],le[Oe]),y=nt,A=Oe),(De!==_||We!==N||je!==k||Ve!==P)&&(t.blendFuncSeparate(Le[De],Le[We],Le[je],Le[Ve]),_=De,N=We,k=je,P=Ve),(ot.equals(C)===!1||kt!==j)&&(t.blendColor(ot.r,ot.g,ot.b,kt),C.copy(ot),j=kt),g=ke,M=!1}function K(ke,nt){ke.side===Nc?me(t.CULL_FACE):ie(t.CULL_FACE);let De=ke.side===ro;nt&&(De=!De),fe(De),ke.blending===Qg&&ke.transparent===!1?V(qd):V(ke.blending,ke.blendEquation,ke.blendSrc,ke.blendDst,ke.blendEquationAlpha,ke.blendSrcAlpha,ke.blendDstAlpha,ke.blendColor,ke.blendAlpha,ke.premultipliedAlpha),o.setFunc(ke.depthFunc),o.setTest(ke.depthTest),o.setMask(ke.depthWrite),s.setMask(ke.colorWrite);const We=ke.stencilWrite;l.setTest(We),We&&(l.setMask(ke.stencilWriteMask),l.setFunc(ke.stencilFunc,ke.stencilRef,ke.stencilFuncMask),l.setOp(ke.stencilFail,ke.stencilZFail,ke.stencilZPass)),ue(ke.polygonOffset,ke.polygonOffsetFactor,ke.polygonOffsetUnits),ke.alphaToCoverage===!0?ie(t.SAMPLE_ALPHA_TO_COVERAGE):me(t.SAMPLE_ALPHA_TO_COVERAGE)}function fe(ke){E!==ke&&(ke?t.frontFace(t.CW):t.frontFace(t.CCW),E=ke)}function Y(ke){ke!==Hge?(ie(t.CULL_FACE),ke!==B&&(ke===qB?t.cullFace(t.BACK):ke===$ge?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):me(t.CULL_FACE),B=ke}function re(ke){ke!==L&&(q&&t.lineWidth(ke),L=ke)}function ue(ke,nt,De){ke?(ie(t.POLYGON_OFFSET_FILL),(U!==nt||D!==De)&&(t.polygonOffset(nt,De),U=nt,D=De)):me(t.POLYGON_OFFSET_FILL)}function Fe(ke){ke?ie(t.SCISSOR_TEST):me(t.SCISSOR_TEST)}function Pe(ke){ke===void 0&&(ke=t.TEXTURE0+$-1),Q!==ke&&(t.activeTexture(ke),Q=ke)}function be(ke,nt,De){De===void 0&&(Q===null?De=t.TEXTURE0+$-1:De=Q);let We=te[De];We===void 0&&(We={type:void 0,texture:void 0},te[De]=We),(We.type!==ke||We.texture!==nt)&&(Q!==De&&(t.activeTexture(De),Q=De),t.bindTexture(ke,nt||oe[ke]),We.type=ke,We.texture=nt)}function O(){const ke=te[Q];ke!==void 0&&ke.type!==void 0&&(t.bindTexture(ke.type,null),ke.type=void 0,ke.texture=void 0)}function R(){try{t.compressedTexImage2D(...arguments)}catch(ke){ke("WebGLState:",ke)}}function G(){try{t.compressedTexImage3D(...arguments)}catch(ke){ke("WebGLState:",ke)}}function de(){try{t.texSubImage2D(...arguments)}catch(ke){ke("WebGLState:",ke)}}function ge(){try{t.texSubImage3D(...arguments)}catch(ke){ke("WebGLState:",ke)}}function ae(){try{t.compressedTexSubImage2D(...arguments)}catch(ke){ke("WebGLState:",ke)}}function Ue(){try{t.compressedTexSubImage3D(...arguments)}catch(ke){ke("WebGLState:",ke)}}function ze(){try{t.texStorage2D(...arguments)}catch(ke){ke("WebGLState:",ke)}}function $e(){try{t.texStorage3D(...arguments)}catch(ke){ke("WebGLState:",ke)}}function Re(){try{t.texImage2D(...arguments)}catch(ke){ke("WebGLState:",ke)}}function pe(){try{t.texImage3D(...arguments)}catch(ke){ke("WebGLState:",ke)}}function ve(ke){Z.equals(ke)===!1&&(t.scissor(ke.x,ke.y,ke.z,ke.w),Z.copy(ke))}function Ne(ke){ee.equals(ke)===!1&&(t.viewport(ke.x,ke.y,ke.z,ke.w),ee.copy(ke))}function xe(ke,nt){let De=d.get(nt);De===void 0&&(De=new WeakMap,d.set(nt,De));let We=De.get(ke);We===void 0&&(We=t.getUniformBlockIndex(nt,ke.name),De.set(ke,We))}function we(ke,nt){const We=d.get(nt).get(ke);c.get(nt)!==We&&(t.uniformBlockBinding(nt,We,ke.__bindingPointIndex),c.set(nt,We))}function qe(){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),u={},Q=null,te={},h={},f=new WeakMap,p=[],x=null,v=!1,g=null,y=null,_=null,N=null,A=null,k=null,P=null,C=new Hn(0,0,0),j=0,M=!1,E=null,B=null,L=null,U=null,D=null,Z.set(0,0,t.canvas.width,t.canvas.height),ee.set(0,0,t.canvas.width,t.canvas.height),s.reset(),o.reset(),l.reset()}return{buffers:{color:s,depth:o,stencil:l},enable:ie,disable:me,bindFramebuffer:se,drawBuffers:ce,useProgram:Ce,setBlending:V,setMaterial:K,setFlipSided:fe,setCullFace:Y,setLineWidth:re,setPolygonOffset:ue,setScissorTest:Fe,activeTexture:Pe,bindTexture:be,unbindTexture:O,compressedTexImage2D:R,compressedTexImage3D:G,texImage2D:Re,texImage3D:pe,updateUBOMapping:xe,uniformBlockBinding:we,texStorage2D:ze,texStorage3D:$e,texSubImage2D:de,texSubImage3D:ge,compressedTexSubImage2D:ae,compressedTexSubImage3D:Ue,scissor:ve,viewport:Ne,reset:qe}}function Qwe(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),d=new In,u=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(O,R){return p?new OffscreenCanvas(O,R):T1("canvas")}function v(O,R,G){let de=1;const ge=be(O);if((ge.width>G||ge.height>G)&&(de=G/Math.max(ge.width,ge.height)),de<1)if(typeof HTMLImageElement<"u"&&O instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&O instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&O instanceof ImageBitmap||typeof VideoFrame<"u"&&O instanceof VideoFrame){const ae=Math.floor(de*ge.width),Ue=Math.floor(de*ge.height);h===void 0&&(h=x(ae,Ue));const ze=R?x(ae,Ue):h;return ze.width=ae,ze.height=Ue,ze.getContext("2d").drawImage(O,0,0,ae,Ue),Sn("WebGLRenderer: Texture has been resized from ("+ge.width+"x"+ge.height+") to ("+ae+"x"+Ue+")."),ze}else return"data"in O&&Sn("WebGLRenderer: Image in DataTexture is too big ("+ge.width+"x"+ge.height+")."),O;return O}function g(O){return O.generateMipmaps}function y(O){t.generateMipmap(O)}function _(O){return O.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:O.isWebGL3DRenderTarget?t.TEXTURE_3D:O.isWebGLArrayRenderTarget||O.isCompressedArrayTexture?t.TEXTURE_2D_ARRAY:t.TEXTURE_2D}function N(O,R,G,de,ge=!1){if(O!==null){if(t[O]!==void 0)return t[O];Sn("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+O+"'")}let ae=R;if(R===t.RED&&(G===t.FLOAT&&(ae=t.R32F),G===t.HALF_FLOAT&&(ae=t.R16F),G===t.UNSIGNED_BYTE&&(ae=t.R8)),R===t.RED_INTEGER&&(G===t.UNSIGNED_BYTE&&(ae=t.R8UI),G===t.UNSIGNED_SHORT&&(ae=t.R16UI),G===t.UNSIGNED_INT&&(ae=t.R32UI),G===t.BYTE&&(ae=t.R8I),G===t.SHORT&&(ae=t.R16I),G===t.INT&&(ae=t.R32I)),R===t.RG&&(G===t.FLOAT&&(ae=t.RG32F),G===t.HALF_FLOAT&&(ae=t.RG16F),G===t.UNSIGNED_BYTE&&(ae=t.RG8)),R===t.RG_INTEGER&&(G===t.UNSIGNED_BYTE&&(ae=t.RG8UI),G===t.UNSIGNED_SHORT&&(ae=t.RG16UI),G===t.UNSIGNED_INT&&(ae=t.RG32UI),G===t.BYTE&&(ae=t.RG8I),G===t.SHORT&&(ae=t.RG16I),G===t.INT&&(ae=t.RG32I)),R===t.RGB_INTEGER&&(G===t.UNSIGNED_BYTE&&(ae=t.RGB8UI),G===t.UNSIGNED_SHORT&&(ae=t.RGB16UI),G===t.UNSIGNED_INT&&(ae=t.RGB32UI),G===t.BYTE&&(ae=t.RGB8I),G===t.SHORT&&(ae=t.RGB16I),G===t.INT&&(ae=t.RGB32I)),R===t.RGBA_INTEGER&&(G===t.UNSIGNED_BYTE&&(ae=t.RGBA8UI),G===t.UNSIGNED_SHORT&&(ae=t.RGBA16UI),G===t.UNSIGNED_INT&&(ae=t.RGBA32UI),G===t.BYTE&&(ae=t.RGBA8I),G===t.SHORT&&(ae=t.RGBA16I),G===t.INT&&(ae=t.RGBA32I)),R===t.RGB&&(G===t.UNSIGNED_INT_5_9_9_9_REV&&(ae=t.RGB9_E5),G===t.UNSIGNED_INT_10F_11F_11F_REV&&(ae=t.R11F_G11F_B10F)),R===t.RGBA){const Ue=ge?k1:fr.getTransfer(de);G===t.FLOAT&&(ae=t.RGBA32F),G===t.HALF_FLOAT&&(ae=t.RGBA16F),G===t.UNSIGNED_BYTE&&(ae=Ue===zr?t.SRGB8_ALPHA8:t.RGBA8),G===t.UNSIGNED_SHORT_4_4_4_4&&(ae=t.RGBA4),G===t.UNSIGNED_SHORT_5_5_5_1&&(ae=t.RGB5_A1)}return(ae===t.R16F||ae===t.R32F||ae===t.RG16F||ae===t.RG32F||ae===t.RGBA16F||ae===t.RGBA32F)&&e.get("EXT_color_buffer_float"),ae}function A(O,R){let G;return O?R===null||R===Rf||R===y0?G=t.DEPTH24_STENCIL8:R===zd?G=t.DEPTH32F_STENCIL8:R===x0&&(G=t.DEPTH24_STENCIL8,Sn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):R===null||R===Rf||R===y0?G=t.DEPTH_COMPONENT24:R===zd?G=t.DEPTH_COMPONENT32F:R===x0&&(G=t.DEPTH_COMPONENT16),G}function k(O,R){return g(O)===!0||O.isFramebufferTexture&&O.minFilter!==Eo&&O.minFilter!==fl?Math.log2(Math.max(R.width,R.height))+1:O.mipmaps!==void 0&&O.mipmaps.length>0?O.mipmaps.length:O.isCompressedTexture&&Array.isArray(O.image)?R.mipmaps.length:1}function P(O){const R=O.target;R.removeEventListener("dispose",P),j(R),R.isVideoTexture&&u.delete(R)}function C(O){const R=O.target;R.removeEventListener("dispose",C),E(R)}function j(O){const R=r.get(O);if(R.__webglInit===void 0)return;const G=O.source,de=f.get(G);if(de){const ge=de[R.__cacheKey];ge.usedTimes--,ge.usedTimes===0&&M(O),Object.keys(de).length===0&&f.delete(G)}r.remove(O)}function M(O){const R=r.get(O);t.deleteTexture(R.__webglTexture);const G=O.source,de=f.get(G);delete de[R.__cacheKey],o.memory.textures--}function E(O){const R=r.get(O);if(O.depthTexture&&(O.depthTexture.dispose(),r.remove(O.depthTexture)),O.isWebGLCubeRenderTarget)for(let de=0;de<6;de++){if(Array.isArray(R.__webglFramebuffer[de]))for(let ge=0;ge<R.__webglFramebuffer[de].length;ge++)t.deleteFramebuffer(R.__webglFramebuffer[de][ge]);else t.deleteFramebuffer(R.__webglFramebuffer[de]);R.__webglDepthbuffer&&t.deleteRenderbuffer(R.__webglDepthbuffer[de])}else{if(Array.isArray(R.__webglFramebuffer))for(let de=0;de<R.__webglFramebuffer.length;de++)t.deleteFramebuffer(R.__webglFramebuffer[de]);else t.deleteFramebuffer(R.__webglFramebuffer);if(R.__webglDepthbuffer&&t.deleteRenderbuffer(R.__webglDepthbuffer),R.__webglMultisampledFramebuffer&&t.deleteFramebuffer(R.__webglMultisampledFramebuffer),R.__webglColorRenderbuffer)for(let de=0;de<R.__webglColorRenderbuffer.length;de++)R.__webglColorRenderbuffer[de]&&t.deleteRenderbuffer(R.__webglColorRenderbuffer[de]);R.__webglDepthRenderbuffer&&t.deleteRenderbuffer(R.__webglDepthRenderbuffer)}const G=O.textures;for(let de=0,ge=G.length;de<ge;de++){const ae=r.get(G[de]);ae.__webglTexture&&(t.deleteTexture(ae.__webglTexture),o.memory.textures--),r.remove(G[de])}r.remove(O)}let B=0;function L(){B=0}function U(){const O=B;return O>=i.maxTextures&&Sn("WebGLTextures: Trying to use "+O+" texture units while this GPU supports only "+i.maxTextures),B+=1,O}function D(O){const R=[];return R.push(O.wrapS),R.push(O.wrapT),R.push(O.wrapR||0),R.push(O.magFilter),R.push(O.minFilter),R.push(O.anisotropy),R.push(O.internalFormat),R.push(O.format),R.push(O.type),R.push(O.generateMipmaps),R.push(O.premultiplyAlpha),R.push(O.flipY),R.push(O.unpackAlignment),R.push(O.colorSpace),R.join()}function $(O,R){const G=r.get(O);if(O.isVideoTexture&&Fe(O),O.isRenderTargetTexture===!1&&O.isExternalTexture!==!0&&O.version>0&&G.__version!==O.version){const de=O.image;if(de===null)Sn("WebGLRenderer: Texture marked for update but no image data found.");else if(de.complete===!1)Sn("WebGLRenderer: Texture marked for update but image is incomplete");else{oe(G,O,R);return}}else O.isExternalTexture&&(G.__webglTexture=O.sourceTexture?O.sourceTexture:null);n.bindTexture(t.TEXTURE_2D,G.__webglTexture,t.TEXTURE0+R)}function q(O,R){const G=r.get(O);if(O.isRenderTargetTexture===!1&&O.version>0&&G.__version!==O.version){oe(G,O,R);return}else O.isExternalTexture&&(G.__webglTexture=O.sourceTexture?O.sourceTexture:null);n.bindTexture(t.TEXTURE_2D_ARRAY,G.__webglTexture,t.TEXTURE0+R)}function z(O,R){const G=r.get(O);if(O.isRenderTargetTexture===!1&&O.version>0&&G.__version!==O.version){oe(G,O,R);return}n.bindTexture(t.TEXTURE_3D,G.__webglTexture,t.TEXTURE0+R)}function W(O,R){const G=r.get(O);if(O.version>0&&G.__version!==O.version){ie(G,O,R);return}n.bindTexture(t.TEXTURE_CUBE_MAP,G.__webglTexture,t.TEXTURE0+R)}const Q={[C3]:t.REPEAT,[Id]:t.CLAMP_TO_EDGE,[k3]:t.MIRRORED_REPEAT},te={[Eo]:t.NEAREST,[xbe]:t.NEAREST_MIPMAP_NEAREST,[rS]:t.NEAREST_MIPMAP_LINEAR,[fl]:t.LINEAR,[$M]:t.LINEAR_MIPMAP_NEAREST,[tf]:t.LINEAR_MIPMAP_LINEAR},H={[Sbe]:t.NEVER,[Tbe]:t.ALWAYS,[_be]:t.LESS,[KX]:t.LEQUAL,[Nbe]:t.EQUAL,[Abe]:t.GEQUAL,[Cbe]:t.GREATER,[kbe]:t.NOTEQUAL};function X(O,R){if(R.type===zd&&e.has("OES_texture_float_linear")===!1&&(R.magFilter===fl||R.magFilter===$M||R.magFilter===rS||R.magFilter===tf||R.minFilter===fl||R.minFilter===$M||R.minFilter===rS||R.minFilter===tf)&&Sn("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),t.texParameteri(O,t.TEXTURE_WRAP_S,Q[R.wrapS]),t.texParameteri(O,t.TEXTURE_WRAP_T,Q[R.wrapT]),(O===t.TEXTURE_3D||O===t.TEXTURE_2D_ARRAY)&&t.texParameteri(O,t.TEXTURE_WRAP_R,Q[R.wrapR]),t.texParameteri(O,t.TEXTURE_MAG_FILTER,te[R.magFilter]),t.texParameteri(O,t.TEXTURE_MIN_FILTER,te[R.minFilter]),R.compareFunction&&(t.texParameteri(O,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(O,t.TEXTURE_COMPARE_FUNC,H[R.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(R.magFilter===Eo||R.minFilter!==rS&&R.minFilter!==tf||R.type===zd&&e.has("OES_texture_float_linear")===!1)return;if(R.anisotropy>1||r.get(R).__currentAnisotropy){const G=e.get("EXT_texture_filter_anisotropic");t.texParameterf(O,G.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(R.anisotropy,i.getMaxAnisotropy())),r.get(R).__currentAnisotropy=R.anisotropy}}}function Z(O,R){let G=!1;O.__webglInit===void 0&&(O.__webglInit=!0,R.addEventListener("dispose",P));const de=R.source;let ge=f.get(de);ge===void 0&&(ge={},f.set(de,ge));const ae=D(R);if(ae!==O.__cacheKey){ge[ae]===void 0&&(ge[ae]={texture:t.createTexture(),usedTimes:0},o.memory.textures++,G=!0),ge[ae].usedTimes++;const Ue=ge[O.__cacheKey];Ue!==void 0&&(ge[O.__cacheKey].usedTimes--,Ue.usedTimes===0&&M(R)),O.__cacheKey=ae,O.__webglTexture=ge[ae].texture}return G}function ee(O,R,G){return Math.floor(Math.floor(O/G)/R)}function Se(O,R,G,de){const ae=O.updateRanges;if(ae.length===0)n.texSubImage2D(t.TEXTURE_2D,0,0,0,R.width,R.height,G,de,R.data);else{ae.sort((pe,ve)=>pe.start-ve.start);let Ue=0;for(let pe=1;pe<ae.length;pe++){const ve=ae[Ue],Ne=ae[pe],xe=ve.start+ve.count,we=ee(Ne.start,R.width,4),qe=ee(ve.start,R.width,4);Ne.start<=xe+1&&we===qe&&ee(Ne.start+Ne.count-1,R.width,4)===we?ve.count=Math.max(ve.count,Ne.start+Ne.count-ve.start):(++Ue,ae[Ue]=Ne)}ae.length=Ue+1;const ze=t.getParameter(t.UNPACK_ROW_LENGTH),$e=t.getParameter(t.UNPACK_SKIP_PIXELS),Re=t.getParameter(t.UNPACK_SKIP_ROWS);t.pixelStorei(t.UNPACK_ROW_LENGTH,R.width);for(let pe=0,ve=ae.length;pe<ve;pe++){const Ne=ae[pe],xe=Math.floor(Ne.start/4),we=Math.ceil(Ne.count/4),qe=xe%R.width,ke=Math.floor(xe/R.width),nt=we,De=1;t.pixelStorei(t.UNPACK_SKIP_PIXELS,qe),t.pixelStorei(t.UNPACK_SKIP_ROWS,ke),n.texSubImage2D(t.TEXTURE_2D,0,qe,ke,nt,De,G,de,R.data)}O.clearUpdateRanges(),t.pixelStorei(t.UNPACK_ROW_LENGTH,ze),t.pixelStorei(t.UNPACK_SKIP_PIXELS,$e),t.pixelStorei(t.UNPACK_SKIP_ROWS,Re)}}function oe(O,R,G){let de=t.TEXTURE_2D;(R.isDataArrayTexture||R.isCompressedArrayTexture)&&(de=t.TEXTURE_2D_ARRAY),R.isData3DTexture&&(de=t.TEXTURE_3D);const ge=Z(O,R),ae=R.source;n.bindTexture(de,O.__webglTexture,t.TEXTURE0+G);const Ue=r.get(ae);if(ae.version!==Ue.__version||ge===!0){n.activeTexture(t.TEXTURE0+G);const ze=fr.getPrimaries(fr.workingColorSpace),$e=R.colorSpace===ph?null:fr.getPrimaries(R.colorSpace),Re=R.colorSpace===ph||ze===$e?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,R.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,R.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,R.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,Re);let pe=v(R.image,!1,i.maxTextureSize);pe=Pe(R,pe);const ve=s.convert(R.format,R.colorSpace),Ne=s.convert(R.type);let xe=N(R.internalFormat,ve,Ne,R.colorSpace,R.isVideoTexture);X(de,R);let we;const qe=R.mipmaps,ke=R.isVideoTexture!==!0,nt=Ue.__version===void 0||ge===!0,De=ae.dataReady,We=k(R,pe);if(R.isDepthTexture)xe=A(R.format===w0,R.type),nt&&(ke?n.texStorage2D(t.TEXTURE_2D,1,xe,pe.width,pe.height):n.texImage2D(t.TEXTURE_2D,0,xe,pe.width,pe.height,0,ve,Ne,null));else if(R.isDataTexture)if(qe.length>0){ke&&nt&&n.texStorage2D(t.TEXTURE_2D,We,xe,qe[0].width,qe[0].height);for(let Oe=0,je=qe.length;Oe<je;Oe++)we=qe[Oe],ke?De&&n.texSubImage2D(t.TEXTURE_2D,Oe,0,0,we.width,we.height,ve,Ne,we.data):n.texImage2D(t.TEXTURE_2D,Oe,xe,we.width,we.height,0,ve,Ne,we.data);R.generateMipmaps=!1}else ke?(nt&&n.texStorage2D(t.TEXTURE_2D,We,xe,pe.width,pe.height),De&&Se(R,pe,ve,Ne)):n.texImage2D(t.TEXTURE_2D,0,xe,pe.width,pe.height,0,ve,Ne,pe.data);else if(R.isCompressedTexture)if(R.isCompressedArrayTexture){ke&&nt&&n.texStorage3D(t.TEXTURE_2D_ARRAY,We,xe,qe[0].width,qe[0].height,pe.depth);for(let Oe=0,je=qe.length;Oe<je;Oe++)if(we=qe[Oe],R.format!==Gl)if(ve!==null)if(ke){if(De)if(R.layerUpdates.size>0){const Ve=C8(we.width,we.height,R.format,R.type);for(const ot of R.layerUpdates){const kt=we.data.subarray(ot*Ve/we.data.BYTES_PER_ELEMENT,(ot+1)*Ve/we.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,Oe,0,0,ot,we.width,we.height,1,ve,kt)}R.clearLayerUpdates()}else n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,Oe,0,0,0,we.width,we.height,pe.depth,ve,we.data)}else n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,Oe,xe,we.width,we.height,pe.depth,0,we.data,0,0);else Sn("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else ke?De&&n.texSubImage3D(t.TEXTURE_2D_ARRAY,Oe,0,0,0,we.width,we.height,pe.depth,ve,Ne,we.data):n.texImage3D(t.TEXTURE_2D_ARRAY,Oe,xe,we.width,we.height,pe.depth,0,ve,Ne,we.data)}else{ke&&nt&&n.texStorage2D(t.TEXTURE_2D,We,xe,qe[0].width,qe[0].height);for(let Oe=0,je=qe.length;Oe<je;Oe++)we=qe[Oe],R.format!==Gl?ve!==null?ke?De&&n.compressedTexSubImage2D(t.TEXTURE_2D,Oe,0,0,we.width,we.height,ve,we.data):n.compressedTexImage2D(t.TEXTURE_2D,Oe,xe,we.width,we.height,0,we.data):Sn("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):ke?De&&n.texSubImage2D(t.TEXTURE_2D,Oe,0,0,we.width,we.height,ve,Ne,we.data):n.texImage2D(t.TEXTURE_2D,Oe,xe,we.width,we.height,0,ve,Ne,we.data)}else if(R.isDataArrayTexture)if(ke){if(nt&&n.texStorage3D(t.TEXTURE_2D_ARRAY,We,xe,pe.width,pe.height,pe.depth),De)if(R.layerUpdates.size>0){const Oe=C8(pe.width,pe.height,R.format,R.type);for(const je of R.layerUpdates){const Ve=pe.data.subarray(je*Oe/pe.data.BYTES_PER_ELEMENT,(je+1)*Oe/pe.data.BYTES_PER_ELEMENT);n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,je,pe.width,pe.height,1,ve,Ne,Ve)}R.clearLayerUpdates()}else n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,pe.width,pe.height,pe.depth,ve,Ne,pe.data)}else n.texImage3D(t.TEXTURE_2D_ARRAY,0,xe,pe.width,pe.height,pe.depth,0,ve,Ne,pe.data);else if(R.isData3DTexture)ke?(nt&&n.texStorage3D(t.TEXTURE_3D,We,xe,pe.width,pe.height,pe.depth),De&&n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,pe.width,pe.height,pe.depth,ve,Ne,pe.data)):n.texImage3D(t.TEXTURE_3D,0,xe,pe.width,pe.height,pe.depth,0,ve,Ne,pe.data);else if(R.isFramebufferTexture){if(nt)if(ke)n.texStorage2D(t.TEXTURE_2D,We,xe,pe.width,pe.height);else{let Oe=pe.width,je=pe.height;for(let Ve=0;Ve<We;Ve++)n.texImage2D(t.TEXTURE_2D,Ve,xe,Oe,je,0,ve,Ne,null),Oe>>=1,je>>=1}}else if(qe.length>0){if(ke&&nt){const Oe=be(qe[0]);n.texStorage2D(t.TEXTURE_2D,We,xe,Oe.width,Oe.height)}for(let Oe=0,je=qe.length;Oe<je;Oe++)we=qe[Oe],ke?De&&n.texSubImage2D(t.TEXTURE_2D,Oe,0,0,ve,Ne,we):n.texImage2D(t.TEXTURE_2D,Oe,xe,ve,Ne,we);R.generateMipmaps=!1}else if(ke){if(nt){const Oe=be(pe);n.texStorage2D(t.TEXTURE_2D,We,xe,Oe.width,Oe.height)}De&&n.texSubImage2D(t.TEXTURE_2D,0,0,0,ve,Ne,pe)}else n.texImage2D(t.TEXTURE_2D,0,xe,ve,Ne,pe);g(R)&&y(de),Ue.__version=ae.version,R.onUpdate&&R.onUpdate(R)}O.__version=R.version}function ie(O,R,G){if(R.image.length!==6)return;const de=Z(O,R),ge=R.source;n.bindTexture(t.TEXTURE_CUBE_MAP,O.__webglTexture,t.TEXTURE0+G);const ae=r.get(ge);if(ge.version!==ae.__version||de===!0){n.activeTexture(t.TEXTURE0+G);const Ue=fr.getPrimaries(fr.workingColorSpace),ze=R.colorSpace===ph?null:fr.getPrimaries(R.colorSpace),$e=R.colorSpace===ph||Ue===ze?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,R.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,R.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,R.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,$e);const Re=R.isCompressedTexture||R.image[0].isCompressedTexture,pe=R.image[0]&&R.image[0].isDataTexture,ve=[];for(let je=0;je<6;je++)!Re&&!pe?ve[je]=v(R.image[je],!0,i.maxCubemapSize):ve[je]=pe?R.image[je].image:R.image[je],ve[je]=Pe(R,ve[je]);const Ne=ve[0],xe=s.convert(R.format,R.colorSpace),we=s.convert(R.type),qe=N(R.internalFormat,xe,we,R.colorSpace),ke=R.isVideoTexture!==!0,nt=ae.__version===void 0||de===!0,De=ge.dataReady;let We=k(R,Ne);X(t.TEXTURE_CUBE_MAP,R);let Oe;if(Re){ke&&nt&&n.texStorage2D(t.TEXTURE_CUBE_MAP,We,qe,Ne.width,Ne.height);for(let je=0;je<6;je++){Oe=ve[je].mipmaps;for(let Ve=0;Ve<Oe.length;Ve++){const ot=Oe[Ve];R.format!==Gl?xe!==null?ke?De&&n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+je,Ve,0,0,ot.width,ot.height,xe,ot.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+je,Ve,qe,ot.width,ot.height,0,ot.data):Sn("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):ke?De&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+je,Ve,0,0,ot.width,ot.height,xe,we,ot.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+je,Ve,qe,ot.width,ot.height,0,xe,we,ot.data)}}}else{if(Oe=R.mipmaps,ke&&nt){Oe.length>0&&We++;const je=be(ve[0]);n.texStorage2D(t.TEXTURE_CUBE_MAP,We,qe,je.width,je.height)}for(let je=0;je<6;je++)if(pe){ke?De&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+je,0,0,0,ve[je].width,ve[je].height,xe,we,ve[je].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+je,0,qe,ve[je].width,ve[je].height,0,xe,we,ve[je].data);for(let Ve=0;Ve<Oe.length;Ve++){const kt=Oe[Ve].image[je].image;ke?De&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+je,Ve+1,0,0,kt.width,kt.height,xe,we,kt.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+je,Ve+1,qe,kt.width,kt.height,0,xe,we,kt.data)}}else{ke?De&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+je,0,0,0,xe,we,ve[je]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+je,0,qe,xe,we,ve[je]);for(let Ve=0;Ve<Oe.length;Ve++){const ot=Oe[Ve];ke?De&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+je,Ve+1,0,0,xe,we,ot.image[je]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+je,Ve+1,qe,xe,we,ot.image[je])}}}g(R)&&y(t.TEXTURE_CUBE_MAP),ae.__version=ge.version,R.onUpdate&&R.onUpdate(R)}O.__version=R.version}function me(O,R,G,de,ge,ae){const Ue=s.convert(G.format,G.colorSpace),ze=s.convert(G.type),$e=N(G.internalFormat,Ue,ze,G.colorSpace),Re=r.get(R),pe=r.get(G);if(pe.__renderTarget=R,!Re.__hasExternalTextures){const ve=Math.max(1,R.width>>ae),Ne=Math.max(1,R.height>>ae);ge===t.TEXTURE_3D||ge===t.TEXTURE_2D_ARRAY?n.texImage3D(ge,ae,$e,ve,Ne,R.depth,0,Ue,ze,null):n.texImage2D(ge,ae,$e,ve,Ne,0,Ue,ze,null)}n.bindFramebuffer(t.FRAMEBUFFER,O),ue(R)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,de,ge,pe.__webglTexture,0,re(R)):(ge===t.TEXTURE_2D||ge>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&ge<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,de,ge,pe.__webglTexture,ae),n.bindFramebuffer(t.FRAMEBUFFER,null)}function se(O,R,G){if(t.bindRenderbuffer(t.RENDERBUFFER,O),R.depthBuffer){const de=R.depthTexture,ge=de&&de.isDepthTexture?de.type:null,ae=A(R.stencilBuffer,ge),Ue=R.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,ze=re(R);ue(R)?l.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,ze,ae,R.width,R.height):G?t.renderbufferStorageMultisample(t.RENDERBUFFER,ze,ae,R.width,R.height):t.renderbufferStorage(t.RENDERBUFFER,ae,R.width,R.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,Ue,t.RENDERBUFFER,O)}else{const de=R.textures;for(let ge=0;ge<de.length;ge++){const ae=de[ge],Ue=s.convert(ae.format,ae.colorSpace),ze=s.convert(ae.type),$e=N(ae.internalFormat,Ue,ze,ae.colorSpace),Re=re(R);G&&ue(R)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,Re,$e,R.width,R.height):ue(R)?l.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,Re,$e,R.width,R.height):t.renderbufferStorage(t.RENDERBUFFER,$e,R.width,R.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function ce(O,R){if(R&&R.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(t.FRAMEBUFFER,O),!(R.depthTexture&&R.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const de=r.get(R.depthTexture);de.__renderTarget=R,(!de.__webglTexture||R.depthTexture.image.width!==R.width||R.depthTexture.image.height!==R.height)&&(R.depthTexture.image.width=R.width,R.depthTexture.image.height=R.height,R.depthTexture.needsUpdate=!0),$(R.depthTexture,0);const ge=de.__webglTexture,ae=re(R);if(R.depthTexture.format===v0)ue(R)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,ge,0,ae):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,ge,0);else if(R.depthTexture.format===w0)ue(R)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,ge,0,ae):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,ge,0);else throw new Error("Unknown depthTexture format")}function Ce(O){const R=r.get(O),G=O.isWebGLCubeRenderTarget===!0;if(R.__boundDepthTexture!==O.depthTexture){const de=O.depthTexture;if(R.__depthDisposeCallback&&R.__depthDisposeCallback(),de){const ge=()=>{delete R.__boundDepthTexture,delete R.__depthDisposeCallback,de.removeEventListener("dispose",ge)};de.addEventListener("dispose",ge),R.__depthDisposeCallback=ge}R.__boundDepthTexture=de}if(O.depthTexture&&!R.__autoAllocateDepthBuffer){if(G)throw new Error("target.depthTexture not supported in Cube render targets");const de=O.texture.mipmaps;de&&de.length>0?ce(R.__webglFramebuffer[0],O):ce(R.__webglFramebuffer,O)}else if(G){R.__webglDepthbuffer=[];for(let de=0;de<6;de++)if(n.bindFramebuffer(t.FRAMEBUFFER,R.__webglFramebuffer[de]),R.__webglDepthbuffer[de]===void 0)R.__webglDepthbuffer[de]=t.createRenderbuffer(),se(R.__webglDepthbuffer[de],O,!1);else{const ge=O.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,ae=R.__webglDepthbuffer[de];t.bindRenderbuffer(t.RENDERBUFFER,ae),t.framebufferRenderbuffer(t.FRAMEBUFFER,ge,t.RENDERBUFFER,ae)}}else{const de=O.texture.mipmaps;if(de&&de.length>0?n.bindFramebuffer(t.FRAMEBUFFER,R.__webglFramebuffer[0]):n.bindFramebuffer(t.FRAMEBUFFER,R.__webglFramebuffer),R.__webglDepthbuffer===void 0)R.__webglDepthbuffer=t.createRenderbuffer(),se(R.__webglDepthbuffer,O,!1);else{const ge=O.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,ae=R.__webglDepthbuffer;t.bindRenderbuffer(t.RENDERBUFFER,ae),t.framebufferRenderbuffer(t.FRAMEBUFFER,ge,t.RENDERBUFFER,ae)}}n.bindFramebuffer(t.FRAMEBUFFER,null)}function le(O,R,G){const de=r.get(O);R!==void 0&&me(de.__webglFramebuffer,O,O.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),G!==void 0&&Ce(O)}function Le(O){const R=O.texture,G=r.get(O),de=r.get(R);O.addEventListener("dispose",C);const ge=O.textures,ae=O.isWebGLCubeRenderTarget===!0,Ue=ge.length>1;if(Ue||(de.__webglTexture===void 0&&(de.__webglTexture=t.createTexture()),de.__version=R.version,o.memory.textures++),ae){G.__webglFramebuffer=[];for(let ze=0;ze<6;ze++)if(R.mipmaps&&R.mipmaps.length>0){G.__webglFramebuffer[ze]=[];for(let $e=0;$e<R.mipmaps.length;$e++)G.__webglFramebuffer[ze][$e]=t.createFramebuffer()}else G.__webglFramebuffer[ze]=t.createFramebuffer()}else{if(R.mipmaps&&R.mipmaps.length>0){G.__webglFramebuffer=[];for(let ze=0;ze<R.mipmaps.length;ze++)G.__webglFramebuffer[ze]=t.createFramebuffer()}else G.__webglFramebuffer=t.createFramebuffer();if(Ue)for(let ze=0,$e=ge.length;ze<$e;ze++){const Re=r.get(ge[ze]);Re.__webglTexture===void 0&&(Re.__webglTexture=t.createTexture(),o.memory.textures++)}if(O.samples>0&&ue(O)===!1){G.__webglMultisampledFramebuffer=t.createFramebuffer(),G.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,G.__webglMultisampledFramebuffer);for(let ze=0;ze<ge.length;ze++){const $e=ge[ze];G.__webglColorRenderbuffer[ze]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,G.__webglColorRenderbuffer[ze]);const Re=s.convert($e.format,$e.colorSpace),pe=s.convert($e.type),ve=N($e.internalFormat,Re,pe,$e.colorSpace,O.isXRRenderTarget===!0),Ne=re(O);t.renderbufferStorageMultisample(t.RENDERBUFFER,Ne,ve,O.width,O.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+ze,t.RENDERBUFFER,G.__webglColorRenderbuffer[ze])}t.bindRenderbuffer(t.RENDERBUFFER,null),O.depthBuffer&&(G.__webglDepthRenderbuffer=t.createRenderbuffer(),se(G.__webglDepthRenderbuffer,O,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(ae){n.bindTexture(t.TEXTURE_CUBE_MAP,de.__webglTexture),X(t.TEXTURE_CUBE_MAP,R);for(let ze=0;ze<6;ze++)if(R.mipmaps&&R.mipmaps.length>0)for(let $e=0;$e<R.mipmaps.length;$e++)me(G.__webglFramebuffer[ze][$e],O,R,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+ze,$e);else me(G.__webglFramebuffer[ze],O,R,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+ze,0);g(R)&&y(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(Ue){for(let ze=0,$e=ge.length;ze<$e;ze++){const Re=ge[ze],pe=r.get(Re);let ve=t.TEXTURE_2D;(O.isWebGL3DRenderTarget||O.isWebGLArrayRenderTarget)&&(ve=O.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(ve,pe.__webglTexture),X(ve,Re),me(G.__webglFramebuffer,O,Re,t.COLOR_ATTACHMENT0+ze,ve,0),g(Re)&&y(ve)}n.unbindTexture()}else{let ze=t.TEXTURE_2D;if((O.isWebGL3DRenderTarget||O.isWebGLArrayRenderTarget)&&(ze=O.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(ze,de.__webglTexture),X(ze,R),R.mipmaps&&R.mipmaps.length>0)for(let $e=0;$e<R.mipmaps.length;$e++)me(G.__webglFramebuffer[$e],O,R,t.COLOR_ATTACHMENT0,ze,$e);else me(G.__webglFramebuffer,O,R,t.COLOR_ATTACHMENT0,ze,0);g(R)&&y(ze),n.unbindTexture()}O.depthBuffer&&Ce(O)}function V(O){const R=O.textures;for(let G=0,de=R.length;G<de;G++){const ge=R[G];if(g(ge)){const ae=_(O),Ue=r.get(ge).__webglTexture;n.bindTexture(ae,Ue),y(ae),n.unbindTexture()}}}const K=[],fe=[];function Y(O){if(O.samples>0){if(ue(O)===!1){const R=O.textures,G=O.width,de=O.height;let ge=t.COLOR_BUFFER_BIT;const ae=O.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,Ue=r.get(O),ze=R.length>1;if(ze)for(let Re=0;Re<R.length;Re++)n.bindFramebuffer(t.FRAMEBUFFER,Ue.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Re,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,Ue.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+Re,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,Ue.__webglMultisampledFramebuffer);const $e=O.texture.mipmaps;$e&&$e.length>0?n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Ue.__webglFramebuffer[0]):n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Ue.__webglFramebuffer);for(let Re=0;Re<R.length;Re++){if(O.resolveDepthBuffer&&(O.depthBuffer&&(ge|=t.DEPTH_BUFFER_BIT),O.stencilBuffer&&O.resolveStencilBuffer&&(ge|=t.STENCIL_BUFFER_BIT)),ze){t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,Ue.__webglColorRenderbuffer[Re]);const pe=r.get(R[Re]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,pe,0)}t.blitFramebuffer(0,0,G,de,0,0,G,de,ge,t.NEAREST),c===!0&&(K.length=0,fe.length=0,K.push(t.COLOR_ATTACHMENT0+Re),O.depthBuffer&&O.resolveDepthBuffer===!1&&(K.push(ae),fe.push(ae),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,fe)),t.invalidateFramebuffer(t.READ_FRAMEBUFFER,K))}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),ze)for(let Re=0;Re<R.length;Re++){n.bindFramebuffer(t.FRAMEBUFFER,Ue.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Re,t.RENDERBUFFER,Ue.__webglColorRenderbuffer[Re]);const pe=r.get(R[Re]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,Ue.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+Re,t.TEXTURE_2D,pe,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Ue.__webglMultisampledFramebuffer)}else if(O.depthBuffer&&O.resolveDepthBuffer===!1&&c){const R=O.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[R])}}}function re(O){return Math.min(i.maxSamples,O.samples)}function ue(O){const R=r.get(O);return O.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&R.__useRenderToTexture!==!1}function Fe(O){const R=o.render.frame;u.get(O)!==R&&(u.set(O,R),O.update())}function Pe(O,R){const G=O.colorSpace,de=O.format,ge=O.type;return O.isCompressedTexture===!0||O.isVideoTexture===!0||G!==bb&&G!==ph&&(fr.getTransfer(G)===zr?(de!==Gl||ge!==Oc)&&Sn("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):$a("WebGLTextures: Unsupported texture color space:",G)),R}function be(O){return typeof HTMLImageElement<"u"&&O instanceof HTMLImageElement?(d.width=O.naturalWidth||O.width,d.height=O.naturalHeight||O.height):typeof VideoFrame<"u"&&O instanceof VideoFrame?(d.width=O.displayWidth,d.height=O.displayHeight):(d.width=O.width,d.height=O.height),d}this.allocateTextureUnit=U,this.resetTextureUnits=L,this.setTexture2D=$,this.setTexture2DArray=q,this.setTexture3D=z,this.setTextureCube=W,this.rebindTextures=le,this.setupRenderTarget=Le,this.updateRenderTargetMipmap=V,this.updateMultisampleRenderTarget=Y,this.setupDepthRenderbuffer=Ce,this.setupFrameBufferTexture=me,this.useMultisampledRTT=ue}function Zwe(t,e){function n(r,i=ph){let s;const o=fr.getTransfer(i);if(r===Oc)return t.UNSIGNED_BYTE;if(r===zF)return t.UNSIGNED_SHORT_4_4_4_4;if(r===UF)return t.UNSIGNED_SHORT_5_5_5_1;if(r===HX)return t.UNSIGNED_INT_5_9_9_9_REV;if(r===$X)return t.UNSIGNED_INT_10F_11F_11F_REV;if(r===UX)return t.BYTE;if(r===BX)return t.SHORT;if(r===x0)return t.UNSIGNED_SHORT;if(r===IF)return t.INT;if(r===Rf)return t.UNSIGNED_INT;if(r===zd)return t.FLOAT;if(r===Gb)return t.HALF_FLOAT;if(r===VX)return t.ALPHA;if(r===qX)return t.RGB;if(r===Gl)return t.RGBA;if(r===v0)return t.DEPTH_COMPONENT;if(r===w0)return t.DEPTH_STENCIL;if(r===GX)return t.RED;if(r===BF)return t.RED_INTEGER;if(r===HF)return t.RG;if(r===$F)return t.RG_INTEGER;if(r===VF)return t.RGBA_INTEGER;if(r===H_||r===$_||r===V_||r===q_)if(o===zr)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(r===H_)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(r===$_)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(r===V_)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(r===q_)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(r===H_)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(r===$_)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(r===V_)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(r===q_)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(r===A3||r===T3||r===M3||r===P3)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(r===A3)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(r===T3)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(r===M3)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(r===P3)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(r===E3||r===j3||r===D3)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(r===E3||r===j3)return o===zr?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(r===D3)return o===zr?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(r===R3||r===F3||r===L3||r===O3||r===I3||r===z3||r===U3||r===B3||r===H3||r===$3||r===V3||r===q3||r===G3||r===W3)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(r===R3)return o===zr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(r===F3)return o===zr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(r===L3)return o===zr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(r===O3)return o===zr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(r===I3)return o===zr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(r===z3)return o===zr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(r===U3)return o===zr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(r===B3)return o===zr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(r===H3)return o===zr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(r===$3)return o===zr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(r===V3)return o===zr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(r===q3)return o===zr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(r===G3)return o===zr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(r===W3)return o===zr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(r===K3||r===X3||r===Y3)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(r===K3)return o===zr?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(r===X3)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(r===Y3)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(r===Q3||r===Z3||r===J3||r===eD)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(r===Q3)return s.COMPRESSED_RED_RGTC1_EXT;if(r===Z3)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(r===J3)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(r===eD)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return r===y0?t.UNSIGNED_INT_24_8:t[r]!==void 0?t[r]:null}return{convert:n}}const Jwe=`
- void main() {
- gl_Position = vec4( position, 1.0 );
- }`,eSe=`
- uniform sampler2DArray depthColor;
- uniform float depthWidth;
- uniform float depthHeight;
- void main() {
- vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );
- if ( coord.x >= 1.0 ) {
- gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;
- } else {
- gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;
- }
- }`;class tSe{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,n){if(this.texture===null){const r=new mY(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 iu({vertexShader:Jwe,fragmentShader:eSe,uniforms:{depthColor:{value:this.texture},depthWidth:{value:n.z},depthHeight:{value:n.w}}});this.mesh=new Nl(new YF(20,20),r)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}let nSe=class extends tp{constructor(e,n){super();const r=this;let i=null,s=1,o=null,l="local-floor",c=1,d=null,u=null,h=null,f=null,p=null,x=null;const v=typeof XRWebGLBinding<"u",g=new tSe,y={},_=n.getContextAttributes();let N=null,A=null;const k=[],P=[],C=new In;let j=null;const M=new ll;M.viewport=new Ja;const E=new ll;E.viewport=new Ja;const B=[M,E],L=new yxe;let U=null,D=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(oe){let ie=k[oe];return ie===void 0&&(ie=new uP,k[oe]=ie),ie.getTargetRaySpace()},this.getControllerGrip=function(oe){let ie=k[oe];return ie===void 0&&(ie=new uP,k[oe]=ie),ie.getGripSpace()},this.getHand=function(oe){let ie=k[oe];return ie===void 0&&(ie=new uP,k[oe]=ie),ie.getHandSpace()};function $(oe){const ie=P.indexOf(oe.inputSource);if(ie===-1)return;const me=k[ie];me!==void 0&&(me.update(oe.inputSource,oe.frame,d||o),me.dispatchEvent({type:oe.type,data:oe.inputSource}))}function q(){i.removeEventListener("select",$),i.removeEventListener("selectstart",$),i.removeEventListener("selectend",$),i.removeEventListener("squeeze",$),i.removeEventListener("squeezestart",$),i.removeEventListener("squeezeend",$),i.removeEventListener("end",q),i.removeEventListener("inputsourceschange",z);for(let oe=0;oe<k.length;oe++){const ie=P[oe];ie!==null&&(P[oe]=null,k[oe].disconnect(ie))}U=null,D=null,g.reset();for(const oe in y)delete y[oe];e.setRenderTarget(N),p=null,f=null,h=null,i=null,A=null,Se.stop(),r.isPresenting=!1,e.setPixelRatio(j),e.setSize(C.width,C.height,!1),r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(oe){s=oe,r.isPresenting===!0&&Sn("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(oe){l=oe,r.isPresenting===!0&&Sn("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return d||o},this.setReferenceSpace=function(oe){d=oe},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(oe){if(i=oe,i!==null){if(N=e.getRenderTarget(),i.addEventListener("select",$),i.addEventListener("selectstart",$),i.addEventListener("selectend",$),i.addEventListener("squeeze",$),i.addEventListener("squeezestart",$),i.addEventListener("squeezeend",$),i.addEventListener("end",q),i.addEventListener("inputsourceschange",z),_.xrCompatible!==!0&&await n.makeXRCompatible(),j=e.getPixelRatio(),e.getSize(C),v&&"createProjectionLayer"in XRWebGLBinding.prototype){let me=null,se=null,ce=null;_.depth&&(ce=_.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,me=_.stencil?w0:v0,se=_.stencil?y0:Rf);const Ce={colorFormat:n.RGBA8,depthFormat:ce,scaleFactor:s};h=this.getBinding(),f=h.createProjectionLayer(Ce),i.updateRenderState({layers:[f]}),e.setPixelRatio(1),e.setSize(f.textureWidth,f.textureHeight,!1),A=new Lf(f.textureWidth,f.textureHeight,{format:Gl,type:Oc,depthTexture:new hY(f.textureWidth,f.textureHeight,se,void 0,void 0,void 0,void 0,void 0,void 0,me),stencilBuffer:_.stencil,colorSpace:e.outputColorSpace,samples:_.antialias?4:0,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1})}else{const me={antialias:_.antialias,alpha:!0,depth:_.depth,stencil:_.stencil,framebufferScaleFactor:s};p=new XRWebGLLayer(i,n,me),i.updateRenderState({baseLayer:p}),e.setPixelRatio(1),e.setSize(p.framebufferWidth,p.framebufferHeight,!1),A=new Lf(p.framebufferWidth,p.framebufferHeight,{format:Gl,type:Oc,colorSpace:e.outputColorSpace,stencilBuffer:_.stencil,resolveDepthBuffer:p.ignoreDepthValues===!1,resolveStencilBuffer:p.ignoreDepthValues===!1})}A.isXRRenderTarget=!0,this.setFoveation(c),d=null,o=await i.requestReferenceSpace(l),Se.setContext(i),Se.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return g.getDepthTexture()};function z(oe){for(let ie=0;ie<oe.removed.length;ie++){const me=oe.removed[ie],se=P.indexOf(me);se>=0&&(P[se]=null,k[se].disconnect(me))}for(let ie=0;ie<oe.added.length;ie++){const me=oe.added[ie];let se=P.indexOf(me);if(se===-1){for(let Ce=0;Ce<k.length;Ce++)if(Ce>=P.length){P.push(me),se=Ce;break}else if(P[Ce]===null){P[Ce]=me,se=Ce;break}if(se===-1)break}const ce=k[se];ce&&ce.connect(me)}}const W=new pt,Q=new pt;function te(oe,ie,me){W.setFromMatrixPosition(ie.matrixWorld),Q.setFromMatrixPosition(me.matrixWorld);const se=W.distanceTo(Q),ce=ie.projectionMatrix.elements,Ce=me.projectionMatrix.elements,le=ce[14]/(ce[10]-1),Le=ce[14]/(ce[10]+1),V=(ce[9]+1)/ce[5],K=(ce[9]-1)/ce[5],fe=(ce[8]-1)/ce[0],Y=(Ce[8]+1)/Ce[0],re=le*fe,ue=le*Y,Fe=se/(-fe+Y),Pe=Fe*-fe;if(ie.matrixWorld.decompose(oe.position,oe.quaternion,oe.scale),oe.translateX(Pe),oe.translateZ(Fe),oe.matrixWorld.compose(oe.position,oe.quaternion,oe.scale),oe.matrixWorldInverse.copy(oe.matrixWorld).invert(),ce[10]===-1)oe.projectionMatrix.copy(ie.projectionMatrix),oe.projectionMatrixInverse.copy(ie.projectionMatrixInverse);else{const be=le+Fe,O=Le+Fe,R=re-Pe,G=ue+(se-Pe),de=V*Le/O*be,ge=K*Le/O*be;oe.projectionMatrix.makePerspective(R,G,de,ge,be,O),oe.projectionMatrixInverse.copy(oe.projectionMatrix).invert()}}function H(oe,ie){ie===null?oe.matrixWorld.copy(oe.matrix):oe.matrixWorld.multiplyMatrices(ie.matrixWorld,oe.matrix),oe.matrixWorldInverse.copy(oe.matrixWorld).invert()}this.updateCamera=function(oe){if(i===null)return;let ie=oe.near,me=oe.far;g.texture!==null&&(g.depthNear>0&&(ie=g.depthNear),g.depthFar>0&&(me=g.depthFar)),L.near=E.near=M.near=ie,L.far=E.far=M.far=me,(U!==L.near||D!==L.far)&&(i.updateRenderState({depthNear:L.near,depthFar:L.far}),U=L.near,D=L.far),L.layers.mask=oe.layers.mask|6,M.layers.mask=L.layers.mask&3,E.layers.mask=L.layers.mask&5;const se=oe.parent,ce=L.cameras;H(L,se);for(let Ce=0;Ce<ce.length;Ce++)H(ce[Ce],se);ce.length===2?te(L,M,E):L.projectionMatrix.copy(M.projectionMatrix),X(oe,L,se)};function X(oe,ie,me){me===null?oe.matrix.copy(ie.matrixWorld):(oe.matrix.copy(me.matrixWorld),oe.matrix.invert(),oe.matrix.multiply(ie.matrixWorld)),oe.matrix.decompose(oe.position,oe.quaternion,oe.scale),oe.updateMatrixWorld(!0),oe.projectionMatrix.copy(ie.projectionMatrix),oe.projectionMatrixInverse.copy(ie.projectionMatrixInverse),oe.isPerspectiveCamera&&(oe.fov=tD*2*Math.atan(1/oe.projectionMatrix.elements[5]),oe.zoom=1)}this.getCamera=function(){return L},this.getFoveation=function(){if(!(f===null&&p===null))return c},this.setFoveation=function(oe){c=oe,f!==null&&(f.fixedFoveation=oe),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=oe)},this.hasDepthSensing=function(){return g.texture!==null},this.getDepthSensingMesh=function(){return g.getMesh(L)},this.getCameraTexture=function(oe){return y[oe]};let Z=null;function ee(oe,ie){if(u=ie.getViewerPose(d||o),x=ie,u!==null){const me=u.views;p!==null&&(e.setRenderTargetFramebuffer(A,p.framebuffer),e.setRenderTarget(A));let se=!1;me.length!==L.cameras.length&&(L.cameras.length=0,se=!0);for(let Le=0;Le<me.length;Le++){const V=me[Le];let K=null;if(p!==null)K=p.getViewport(V);else{const Y=h.getViewSubImage(f,V);K=Y.viewport,Le===0&&(e.setRenderTargetTextures(A,Y.colorTexture,Y.depthStencilTexture),e.setRenderTarget(A))}let fe=B[Le];fe===void 0&&(fe=new ll,fe.layers.enable(Le),fe.viewport=new Ja,B[Le]=fe),fe.matrix.fromArray(V.transform.matrix),fe.matrix.decompose(fe.position,fe.quaternion,fe.scale),fe.projectionMatrix.fromArray(V.projectionMatrix),fe.projectionMatrixInverse.copy(fe.projectionMatrix).invert(),fe.viewport.set(K.x,K.y,K.width,K.height),Le===0&&(L.matrix.copy(fe.matrix),L.matrix.decompose(L.position,L.quaternion,L.scale)),se===!0&&L.cameras.push(fe)}const ce=i.enabledFeatures;if(ce&&ce.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&v){h=r.getBinding();const Le=h.getDepthInformation(me[0]);Le&&Le.isValid&&Le.texture&&g.init(Le,i.renderState)}if(ce&&ce.includes("camera-access")&&v){e.state.unbindTexture(),h=r.getBinding();for(let Le=0;Le<me.length;Le++){const V=me[Le].camera;if(V){let K=y[V];K||(K=new mY,y[V]=K);const fe=h.getCameraImage(V);K.sourceTexture=fe}}}}for(let me=0;me<k.length;me++){const se=P[me],ce=k[me];se!==null&&ce!==void 0&&ce.update(se,ie,d||o)}Z&&Z(oe,ie),ie.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:ie}),x=null}const Se=new xY;Se.setAnimationLoop(ee),this.setAnimationLoop=function(oe){Z=oe},this.dispose=function(){}}};const jm=new Kh,rSe=new ai;function aSe(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,lY(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),u(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?d(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===ro&&(g.bumpScale.value*=-1)),y.normalMap&&(g.normalMap.value=y.normalMap,n(y.normalMap,g.normalMapTransform),g.normalScale.value.copy(y.normalScale),y.side===ro&&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,jm.copy(A),jm.x*=-1,jm.y*=-1,jm.z*=-1,N.isCubeTexture&&N.isRenderTargetTexture===!1&&(jm.y*=-1,jm.z*=-1),g.envMapRotation.value.setFromMatrix4(rSe.makeRotationFromEuler(jm)),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 d(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 u(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===ro&&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 iSe(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 d(_,N){let A=i[_.id];A===void 0&&(x(_),A=u(_),i[_.id]=A,_.addEventListener("dispose",g));const k=N.program;r.updateUBOMapping(_,k);const P=e.render.frame;s[_.id]!==P&&(f(_),s[_.id]=P)}function u(_){const N=h();_.__bindingPointIndex=N;const A=t.createBuffer(),k=_.__size,P=_.usage;return t.bindBuffer(t.UNIFORM_BUFFER,A),t.bufferData(t.UNIFORM_BUFFER,k,P),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 $a("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function f(_){const N=i[_.id],A=_.uniforms,k=_.__cache;t.bindBuffer(t.UNIFORM_BUFFER,N);for(let P=0,C=A.length;P<C;P++){const j=Array.isArray(A[P])?A[P]:[A[P]];for(let M=0,E=j.length;M<E;M++){const B=j[M];if(p(B,P,M,k)===!0){const L=B.__offset,U=Array.isArray(B.value)?B.value:[B.value];let D=0;for(let $=0;$<U.length;$++){const q=U[$],z=v(q);typeof q=="number"||typeof q=="boolean"?(B.__data[0]=q,t.bufferSubData(t.UNIFORM_BUFFER,L+D,B.__data)):q.isMatrix3?(B.__data[0]=q.elements[0],B.__data[1]=q.elements[1],B.__data[2]=q.elements[2],B.__data[3]=0,B.__data[4]=q.elements[3],B.__data[5]=q.elements[4],B.__data[6]=q.elements[5],B.__data[7]=0,B.__data[8]=q.elements[6],B.__data[9]=q.elements[7],B.__data[10]=q.elements[8],B.__data[11]=0):(q.toArray(B.__data,D),D+=z.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,L,B.__data)}}}t.bindBuffer(t.UNIFORM_BUFFER,null)}function p(_,N,A,k){const P=_.value,C=N+"_"+A;if(k[C]===void 0)return typeof P=="number"||typeof P=="boolean"?k[C]=P:k[C]=P.clone(),!0;{const j=k[C];if(typeof P=="number"||typeof P=="boolean"){if(j!==P)return k[C]=P,!0}else if(j.equals(P)===!1)return j.copy(P),!0}return!1}function x(_){const N=_.uniforms;let A=0;const k=16;for(let C=0,j=N.length;C<j;C++){const M=Array.isArray(N[C])?N[C]:[N[C]];for(let E=0,B=M.length;E<B;E++){const L=M[E],U=Array.isArray(L.value)?L.value:[L.value];for(let D=0,$=U.length;D<$;D++){const q=U[D],z=v(q),W=A%k,Q=W%z.boundary,te=W+Q;A+=Q,te!==0&&k-te<z.storage&&(A+=k-te),L.__data=new Float32Array(z.storage/Float32Array.BYTES_PER_ELEMENT),L.__offset=A,A+=z.storage}}}const P=A%k;return P>0&&(A+=k-P),_.__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?Sn("WebGLRenderer: Texture samplers can not be part of an uniforms group."):Sn("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:d,dispose:y}}const sSe=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 yd=null;function oSe(){return yd===null&&(yd=new axe(sSe,32,32,HF,Gb),yd.minFilter=fl,yd.magFilter=fl,yd.wrapS=Id,yd.wrapT=Id,yd.generateMipmaps=!1,yd.needsUpdate=!0),yd}let lSe=class{constructor(e={}){const{canvas:n=Mbe(),context:r=null,depth:i=!0,stencil:s=!1,alpha:o=!1,antialias:l=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:d=!1,powerPreference:u="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([VF,$F,BF]),v=new Set([Oc,Rf,x0,y0,zF,UF]),g=new Uint32Array(4),y=new Int32Array(4);let _=null,N=null;const A=[],k=[];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=Rh,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const P=this;let C=!1;this._outputColorSpace=ko;let j=0,M=0,E=null,B=-1,L=null;const U=new Ja,D=new Ja;let $=null;const q=new Hn(0);let z=0,W=n.width,Q=n.height,te=1,H=null,X=null;const Z=new Ja(0,0,W,Q),ee=new Ja(0,0,W,Q);let Se=!1;const oe=new XF;let ie=!1,me=!1;const se=new ai,ce=new pt,Ce=new Ja,le={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Le=!1;function V(){return E===null?te:1}let K=r;function fe(ye,He){return n.getContext(ye,He)}try{const ye={alpha:!0,depth:i,stencil:s,antialias:l,premultipliedAlpha:c,preserveDrawingBuffer:d,powerPreference:u,failIfMajorPerformanceCaveat:h};if("setAttribute"in n&&n.setAttribute("data-engine",`three.js r${LF}`),n.addEventListener("webglcontextlost",Oe,!1),n.addEventListener("webglcontextrestored",je,!1),n.addEventListener("webglcontextcreationerror",Ve,!1),K===null){const He="webgl2";if(K=fe(He,ye),K===null)throw fe(He)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(ye){throw ye("WebGLRenderer: "+ye.message),ye}let Y,re,ue,Fe,Pe,be,O,R,G,de,ge,ae,Ue,ze,$e,Re,pe,ve,Ne,xe,we,qe,ke,nt;function De(){Y=new gve(K),Y.init(),qe=new Zwe(K,Y),re=new ove(K,Y,e,qe),ue=new Ywe(K,Y),re.reversedDepthBuffer&&f&&ue.buffers.depth.setReversed(!0),Fe=new yve(K),Pe=new Owe,be=new Qwe(K,Y,ue,Pe,re,qe,Fe),O=new cve(P),R=new pve(P),G=new _xe(K),ke=new ive(K,G),de=new bve(K,G,Fe,ke),ge=new wve(K,de,G,Fe),Ne=new vve(K,re,be),Re=new lve(Pe),ae=new Lwe(P,O,R,Y,re,ke,Re),Ue=new aSe(P,Pe),ze=new zwe,$e=new qwe(Y),ve=new ave(P,O,R,ue,ge,p,c),pe=new Kwe(P,ge,re),nt=new iSe(K,Fe,re,ue),xe=new sve(K,Y,Fe),we=new xve(K,Y,Fe),Fe.programs=ae.programs,P.capabilities=re,P.extensions=Y,P.properties=Pe,P.renderLists=ze,P.shadowMap=pe,P.state=ue,P.info=Fe}De();const We=new nSe(P,K);this.xr=We,this.getContext=function(){return K},this.getContextAttributes=function(){return K.getContextAttributes()},this.forceContextLoss=function(){const ye=Y.get("WEBGL_lose_context");ye&&ye.loseContext()},this.forceContextRestore=function(){const ye=Y.get("WEBGL_lose_context");ye&&ye.restoreContext()},this.getPixelRatio=function(){return te},this.setPixelRatio=function(ye){ye!==void 0&&(te=ye,this.setSize(W,Q,!1))},this.getSize=function(ye){return ye.set(W,Q)},this.setSize=function(ye,He,Ye=!0){if(We.isPresenting){Sn("WebGLRenderer: Can't change size while VR device is presenting.");return}W=ye,Q=He,n.width=Math.floor(ye*te),n.height=Math.floor(He*te),Ye===!0&&(n.style.width=ye+"px",n.style.height=He+"px"),this.setViewport(0,0,ye,He)},this.getDrawingBufferSize=function(ye){return ye.set(W*te,Q*te).floor()},this.setDrawingBufferSize=function(ye,He,Ye){W=ye,Q=He,te=Ye,n.width=Math.floor(ye*Ye),n.height=Math.floor(He*Ye),this.setViewport(0,0,ye,He)},this.getCurrentViewport=function(ye){return ye.copy(U)},this.getViewport=function(ye){return ye.copy(Z)},this.setViewport=function(ye,He,Ye,Xe){ye.isVector4?Z.set(ye.x,ye.y,ye.z,ye.w):Z.set(ye,He,Ye,Xe),ue.viewport(U.copy(Z).multiplyScalar(te).round())},this.getScissor=function(ye){return ye.copy(ee)},this.setScissor=function(ye,He,Ye,Xe){ye.isVector4?ee.set(ye.x,ye.y,ye.z,ye.w):ee.set(ye,He,Ye,Xe),ue.scissor(D.copy(ee).multiplyScalar(te).round())},this.getScissorTest=function(){return Se},this.setScissorTest=function(ye){ue.setScissorTest(Se=ye)},this.setOpaqueSort=function(ye){H=ye},this.setTransparentSort=function(ye){X=ye},this.getClearColor=function(ye){return ye.copy(ve.getClearColor())},this.setClearColor=function(){ve.setClearColor(...arguments)},this.getClearAlpha=function(){return ve.getClearAlpha()},this.setClearAlpha=function(){ve.setClearAlpha(...arguments)},this.clear=function(ye=!0,He=!0,Ye=!0){let Xe=0;if(ye){let Te=!1;if(E!==null){const ct=E.texture.format;Te=x.has(ct)}if(Te){const ct=E.texture.type,gt=v.has(ct),lt=ve.getClearColor(),Tt=ve.getClearAlpha(),Bt=lt.r,It=lt.g,Pt=lt.b;gt?(g[0]=Bt,g[1]=It,g[2]=Pt,g[3]=Tt,K.clearBufferuiv(K.COLOR,0,g)):(y[0]=Bt,y[1]=It,y[2]=Pt,y[3]=Tt,K.clearBufferiv(K.COLOR,0,y))}else Xe|=K.COLOR_BUFFER_BIT}He&&(Xe|=K.DEPTH_BUFFER_BIT),Ye&&(Xe|=K.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),K.clear(Xe)},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",Oe,!1),n.removeEventListener("webglcontextrestored",je,!1),n.removeEventListener("webglcontextcreationerror",Ve,!1),ve.dispose(),ze.dispose(),$e.dispose(),Pe.dispose(),O.dispose(),R.dispose(),ge.dispose(),ke.dispose(),nt.dispose(),ae.dispose(),We.dispose(),We.removeEventListener("sessionstart",mt),We.removeEventListener("sessionend",yt),zt.stop()};function Oe(ye){ye.preventDefault(),JB("WebGLRenderer: Context Lost."),C=!0}function je(){JB("WebGLRenderer: Context Restored."),C=!1;const ye=Fe.autoReset,He=pe.enabled,Ye=pe.autoUpdate,Xe=pe.needsUpdate,Te=pe.type;De(),Fe.autoReset=ye,pe.enabled=He,pe.autoUpdate=Ye,pe.needsUpdate=Xe,pe.type=Te}function Ve(ye){$a("WebGLRenderer: A WebGL context could not be created. Reason: ",ye.statusMessage)}function ot(ye){const He=ye.target;He.removeEventListener("dispose",ot),kt(He)}function kt(ye){Ft(ye),Pe.remove(ye)}function Ft(ye){const He=Pe.get(ye).programs;He!==void 0&&(He.forEach(function(Ye){ae.releaseProgram(Ye)}),ye.isShaderMaterial&&ae.releaseShaderCache(ye))}this.renderBufferDirect=function(ye,He,Ye,Xe,Te,ct){He===null&&(He=le);const gt=Te.isMesh&&Te.matrixWorld.determinant()<0,lt=Ie(ye,He,Ye,Xe,Te);ue.setMaterial(Xe,gt);let Tt=Ye.index,Bt=1;if(Xe.wireframe===!0){if(Tt=de.getWireframeAttribute(Ye),Tt===void 0)return;Bt=2}const It=Ye.drawRange,Pt=Ye.attributes.position;let tn=It.start*Bt,en=(It.start+It.count)*Bt;ct!==null&&(tn=Math.max(tn,ct.start*Bt),en=Math.min(en,(ct.start+ct.count)*Bt)),Tt!==null?(tn=Math.max(tn,0),en=Math.min(en,Tt.count)):Pt!=null&&(tn=Math.max(tn,0),en=Math.min(en,Pt.count));const on=en-tn;if(on<0||on===1/0)return;ke.setup(Te,Xe,lt,Ye,Tt);let gn,Tn=xe;if(Tt!==null&&(gn=G.get(Tt),Tn=we,Tn.setIndex(gn)),Te.isMesh)Xe.wireframe===!0?(ue.setLineWidth(Xe.wireframeLinewidth*V()),Tn.setMode(K.LINES)):Tn.setMode(K.TRIANGLES);else if(Te.isLine){let Zt=Xe.linewidth;Zt===void 0&&(Zt=1),ue.setLineWidth(Zt*V()),Te.isLineSegments?Tn.setMode(K.LINES):Te.isLineLoop?Tn.setMode(K.LINE_LOOP):Tn.setMode(K.LINE_STRIP)}else Te.isPoints?Tn.setMode(K.POINTS):Te.isSprite&&Tn.setMode(K.TRIANGLES);if(Te.isBatchedMesh)if(Te._multiDrawInstances!==null)S0("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),Tn.renderMultiDrawInstances(Te._multiDrawStarts,Te._multiDrawCounts,Te._multiDrawCount,Te._multiDrawInstances);else if(Y.get("WEBGL_multi_draw"))Tn.renderMultiDraw(Te._multiDrawStarts,Te._multiDrawCounts,Te._multiDrawCount);else{const Zt=Te._multiDrawStarts,fn=Te._multiDrawCounts,un=Te._multiDrawCount,qr=Tt?G.get(Tt).bytesPerElement:1,pn=Pe.get(Xe).currentProgram.getUniforms();for(let lr=0;lr<un;lr++)pn.setValue(K,"_gl_DrawID",lr),Tn.render(Zt[lr]/qr,fn[lr])}else if(Te.isInstancedMesh)Tn.renderInstances(tn,on,Te.count);else if(Ye.isInstancedBufferGeometry){const Zt=Ye._maxInstanceCount!==void 0?Ye._maxInstanceCount:1/0,fn=Math.min(Ye.instanceCount,Zt);Tn.renderInstances(tn,on,fn)}else Tn.render(tn,on)};function Vt(ye,He,Ye){ye.transparent===!0&&ye.side===Nc&&ye.forceSinglePass===!1?(ye.side=ro,ye.needsUpdate=!0,br(ye,He,Ye),ye.side=Wh,ye.needsUpdate=!0,br(ye,He,Ye),ye.side=Nc):br(ye,He,Ye)}this.compile=function(ye,He,Ye=null){Ye===null&&(Ye=ye),N=$e.get(Ye),N.init(He),k.push(N),Ye.traverseVisible(function(Te){Te.isLight&&Te.layers.test(He.layers)&&(N.pushLight(Te),Te.castShadow&&N.pushShadow(Te))}),ye!==Ye&&ye.traverseVisible(function(Te){Te.isLight&&Te.layers.test(He.layers)&&(N.pushLight(Te),Te.castShadow&&N.pushShadow(Te))}),N.setupLights();const Xe=new Set;return ye.traverse(function(Te){if(!(Te.isMesh||Te.isPoints||Te.isLine||Te.isSprite))return;const ct=Te.material;if(ct)if(Array.isArray(ct))for(let gt=0;gt<ct.length;gt++){const lt=ct[gt];Vt(lt,Ye,Te),Xe.add(lt)}else Vt(ct,Ye,Te),Xe.add(ct)}),N=k.pop(),Xe},this.compileAsync=function(ye,He,Ye=null){const Xe=this.compile(ye,He,Ye);return new Promise(Te=>{function ct(){if(Xe.forEach(function(gt){Pe.get(gt).currentProgram.isReady()&&Xe.delete(gt)}),Xe.size===0){Te(ye);return}setTimeout(ct,10)}Y.get("KHR_parallel_shader_compile")!==null?ct():setTimeout(ct,10)})};let At=null;function Be(ye){At&&At(ye)}function mt(){zt.stop()}function yt(){zt.start()}const zt=new xY;zt.setAnimationLoop(Be),typeof self<"u"&&zt.setContext(self),this.setAnimationLoop=function(ye){At=ye,We.setAnimationLoop(ye),ye===null?zt.stop():zt.start()},We.addEventListener("sessionstart",mt),We.addEventListener("sessionend",yt),this.render=function(ye,He){if(He!==void 0&&He.isCamera!==!0){$a("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(C===!0)return;if(ye.matrixWorldAutoUpdate===!0&&ye.updateMatrixWorld(),He.parent===null&&He.matrixWorldAutoUpdate===!0&&He.updateMatrixWorld(),We.enabled===!0&&We.isPresenting===!0&&(We.cameraAutoUpdate===!0&&We.updateCamera(He),He=We.getCamera()),ye.isScene===!0&&ye.onBeforeRender(P,ye,He,E),N=$e.get(ye,k.length),N.init(He),k.push(N),se.multiplyMatrices(He.projectionMatrix,He.matrixWorldInverse),oe.setFromProjectionMatrix(se,Ac,He.reversedDepth),me=this.localClippingEnabled,ie=Re.init(this.clippingPlanes,me),_=ze.get(ye,A.length),_.init(),A.push(_),We.enabled===!0&&We.isPresenting===!0){const ct=P.xr.getDepthSensingMesh();ct!==null&&yn(ct,He,-1/0,P.sortObjects)}yn(ye,He,0,P.sortObjects),_.finish(),P.sortObjects===!0&&_.sort(H,X),Le=We.enabled===!1||We.isPresenting===!1||We.hasDepthSensing()===!1,Le&&ve.addToRenderList(_,ye),this.info.render.frame++,ie===!0&&Re.beginShadows();const Ye=N.state.shadowsArray;pe.render(Ye,ye,He),ie===!0&&Re.endShadows(),this.info.autoReset===!0&&this.info.reset();const Xe=_.opaque,Te=_.transmissive;if(N.setupLights(),He.isArrayCamera){const ct=He.cameras;if(Te.length>0)for(let gt=0,lt=ct.length;gt<lt;gt++){const Tt=ct[gt];sr(Xe,Te,ye,Tt)}Le&&ve.render(ye);for(let gt=0,lt=ct.length;gt<lt;gt++){const Tt=ct[gt];gr(_,ye,Tt,Tt.viewport)}}else Te.length>0&&sr(Xe,Te,ye,He),Le&&ve.render(ye),gr(_,ye,He);E!==null&&M===0&&(be.updateMultisampleRenderTarget(E),be.updateRenderTargetMipmap(E)),ye.isScene===!0&&ye.onAfterRender(P,ye,He),ke.resetDefaultState(),B=-1,L=null,k.pop(),k.length>0?(N=k[k.length-1],ie===!0&&Re.setGlobalState(P.clippingPlanes,N.state.camera)):N=null,A.pop(),A.length>0?_=A[A.length-1]:_=null};function yn(ye,He,Ye,Xe){if(ye.visible===!1)return;if(ye.layers.test(He.layers)){if(ye.isGroup)Ye=ye.renderOrder;else if(ye.isLOD)ye.autoUpdate===!0&&ye.update(He);else if(ye.isLight)N.pushLight(ye),ye.castShadow&&N.pushShadow(ye);else if(ye.isSprite){if(!ye.frustumCulled||oe.intersectsSprite(ye)){Xe&&Ce.setFromMatrixPosition(ye.matrixWorld).applyMatrix4(se);const gt=ge.update(ye),lt=ye.material;lt.visible&&_.push(ye,gt,lt,Ye,Ce.z,null)}}else if((ye.isMesh||ye.isLine||ye.isPoints)&&(!ye.frustumCulled||oe.intersectsObject(ye))){const gt=ge.update(ye),lt=ye.material;if(Xe&&(ye.boundingSphere!==void 0?(ye.boundingSphere===null&&ye.computeBoundingSphere(),Ce.copy(ye.boundingSphere.center)):(gt.boundingSphere===null&>.computeBoundingSphere(),Ce.copy(gt.boundingSphere.center)),Ce.applyMatrix4(ye.matrixWorld).applyMatrix4(se)),Array.isArray(lt)){const Tt=gt.groups;for(let Bt=0,It=Tt.length;Bt<It;Bt++){const Pt=Tt[Bt],tn=lt[Pt.materialIndex];tn&&tn.visible&&_.push(ye,gt,tn,Ye,Ce.z,Pt)}}else lt.visible&&_.push(ye,gt,lt,Ye,Ce.z,null)}}const ct=ye.children;for(let gt=0,lt=ct.length;gt<lt;gt++)yn(ct[gt],He,Ye,Xe)}function gr(ye,He,Ye,Xe){const{opaque:Te,transmissive:ct,transparent:gt}=ye;N.setupLightsView(Ye),ie===!0&&Re.setGlobalState(P.clippingPlanes,Ye),Xe&&ue.viewport(U.copy(Xe)),Te.length>0&&nr(Te,He,Ye),ct.length>0&&nr(ct,He,Ye),gt.length>0&&nr(gt,He,Ye),ue.buffers.depth.setTest(!0),ue.buffers.depth.setMask(!0),ue.buffers.color.setMask(!0),ue.setPolygonOffset(!1)}function sr(ye,He,Ye,Xe){if((Ye.isScene===!0?Ye.overrideMaterial:null)!==null)return;N.state.transmissionRenderTarget[Xe.id]===void 0&&(N.state.transmissionRenderTarget[Xe.id]=new Lf(1,1,{generateMipmaps:!0,type:Y.has("EXT_color_buffer_half_float")||Y.has("EXT_color_buffer_float")?Gb:Oc,minFilter:tf,samples:4,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:fr.workingColorSpace}));const ct=N.state.transmissionRenderTarget[Xe.id],gt=Xe.viewport||U;ct.setSize(gt.z*P.transmissionResolutionScale,gt.w*P.transmissionResolutionScale);const lt=P.getRenderTarget(),Tt=P.getActiveCubeFace(),Bt=P.getActiveMipmapLevel();P.setRenderTarget(ct),P.getClearColor(q),z=P.getClearAlpha(),z<1&&P.setClearColor(16777215,.5),P.clear(),Le&&ve.render(Ye);const It=P.toneMapping;P.toneMapping=Rh;const Pt=Xe.viewport;if(Xe.viewport!==void 0&&(Xe.viewport=void 0),N.setupLightsView(Xe),ie===!0&&Re.setGlobalState(P.clippingPlanes,Xe),nr(ye,Ye,Xe),be.updateMultisampleRenderTarget(ct),be.updateRenderTargetMipmap(ct),Y.has("WEBGL_multisampled_render_to_texture")===!1){let tn=!1;for(let en=0,on=He.length;en<on;en++){const gn=He[en],{object:Tn,geometry:Zt,material:fn,group:un}=gn;if(fn.side===Nc&&Tn.layers.test(Xe.layers)){const qr=fn.side;fn.side=ro,fn.needsUpdate=!0,Gn(Tn,Ye,Xe,Zt,fn,un),fn.side=qr,fn.needsUpdate=!0,tn=!0}}tn===!0&&(be.updateMultisampleRenderTarget(ct),be.updateRenderTargetMipmap(ct))}P.setRenderTarget(lt,Tt,Bt),P.setClearColor(q,z),Pt!==void 0&&(Xe.viewport=Pt),P.toneMapping=It}function nr(ye,He,Ye){const Xe=He.isScene===!0?He.overrideMaterial:null;for(let Te=0,ct=ye.length;Te<ct;Te++){const gt=ye[Te],{object:lt,geometry:Tt,group:Bt}=gt;let It=gt.material;It.allowOverride===!0&&Xe!==null&&(It=Xe),lt.layers.test(Ye.layers)&&Gn(lt,He,Ye,Tt,It,Bt)}}function Gn(ye,He,Ye,Xe,Te,ct){ye.onBeforeRender(P,He,Ye,Xe,Te,ct),ye.modelViewMatrix.multiplyMatrices(Ye.matrixWorldInverse,ye.matrixWorld),ye.normalMatrix.getNormalMatrix(ye.modelViewMatrix),Te.onBeforeRender(P,He,Ye,Xe,ye,ct),Te.transparent===!0&&Te.side===Nc&&Te.forceSinglePass===!1?(Te.side=ro,Te.needsUpdate=!0,P.renderBufferDirect(Ye,He,Xe,Te,ye,ct),Te.side=Wh,Te.needsUpdate=!0,P.renderBufferDirect(Ye,He,Xe,Te,ye,ct),Te.side=Nc):P.renderBufferDirect(Ye,He,Xe,Te,ye,ct),ye.onAfterRender(P,He,Ye,Xe,Te,ct)}function br(ye,He,Ye){He.isScene!==!0&&(He=le);const Xe=Pe.get(ye),Te=N.state.lights,ct=N.state.shadowsArray,gt=Te.state.version,lt=ae.getParameters(ye,Te.state,ct,He,Ye),Tt=ae.getProgramCacheKey(lt);let Bt=Xe.programs;Xe.environment=ye.isMeshStandardMaterial?He.environment:null,Xe.fog=He.fog,Xe.envMap=(ye.isMeshStandardMaterial?R:O).get(ye.envMap||Xe.environment),Xe.envMapRotation=Xe.environment!==null&&ye.envMap===null?He.environmentRotation:ye.envMapRotation,Bt===void 0&&(ye.addEventListener("dispose",ot),Bt=new Map,Xe.programs=Bt);let It=Bt.get(Tt);if(It!==void 0){if(Xe.currentProgram===It&&Xe.lightsStateVersion===gt)return oi(ye,lt),It}else lt.uniforms=ae.getUniforms(ye),ye.onBeforeCompile(lt,P),It=ae.acquireProgram(lt,Tt),Bt.set(Tt,It),Xe.uniforms=lt.uniforms;const Pt=Xe.uniforms;return(!ye.isShaderMaterial&&!ye.isRawShaderMaterial||ye.clipping===!0)&&(Pt.clippingPlanes=Re.uniform),oi(ye,lt),Xe.needsLights=tt(ye),Xe.lightsStateVersion=gt,Xe.needsLights&&(Pt.ambientLightColor.value=Te.state.ambient,Pt.lightProbe.value=Te.state.probe,Pt.directionalLights.value=Te.state.directional,Pt.directionalLightShadows.value=Te.state.directionalShadow,Pt.spotLights.value=Te.state.spot,Pt.spotLightShadows.value=Te.state.spotShadow,Pt.rectAreaLights.value=Te.state.rectArea,Pt.ltc_1.value=Te.state.rectAreaLTC1,Pt.ltc_2.value=Te.state.rectAreaLTC2,Pt.pointLights.value=Te.state.point,Pt.pointLightShadows.value=Te.state.pointShadow,Pt.hemisphereLights.value=Te.state.hemi,Pt.directionalShadowMap.value=Te.state.directionalShadowMap,Pt.directionalShadowMatrix.value=Te.state.directionalShadowMatrix,Pt.spotShadowMap.value=Te.state.spotShadowMap,Pt.spotLightMatrix.value=Te.state.spotLightMatrix,Pt.spotLightMap.value=Te.state.spotLightMap,Pt.pointShadowMap.value=Te.state.pointShadowMap,Pt.pointShadowMatrix.value=Te.state.pointShadowMatrix),Xe.currentProgram=It,Xe.uniformsList=null,It}function or(ye){if(ye.uniformsList===null){const He=ye.currentProgram.getUniforms();ye.uniformsList=X_.seqWithValue(He.seq,ye.uniforms)}return ye.uniformsList}function oi(ye,He){const Ye=Pe.get(ye);Ye.outputColorSpace=He.outputColorSpace,Ye.batching=He.batching,Ye.batchingColor=He.batchingColor,Ye.instancing=He.instancing,Ye.instancingColor=He.instancingColor,Ye.instancingMorph=He.instancingMorph,Ye.skinning=He.skinning,Ye.morphTargets=He.morphTargets,Ye.morphNormals=He.morphNormals,Ye.morphColors=He.morphColors,Ye.morphTargetsCount=He.morphTargetsCount,Ye.numClippingPlanes=He.numClippingPlanes,Ye.numIntersection=He.numClipIntersection,Ye.vertexAlphas=He.vertexAlphas,Ye.vertexTangents=He.vertexTangents,Ye.toneMapping=He.toneMapping}function Ie(ye,He,Ye,Xe,Te){He.isScene!==!0&&(He=le),be.resetTextureUnits();const ct=He.fog,gt=Xe.isMeshStandardMaterial?He.environment:null,lt=E===null?P.outputColorSpace:E.isXRRenderTarget===!0?E.texture.colorSpace:bb,Tt=(Xe.isMeshStandardMaterial?R:O).get(Xe.envMap||gt),Bt=Xe.vertexColors===!0&&!!Ye.attributes.color&&Ye.attributes.color.itemSize===4,It=!!Ye.attributes.tangent&&(!!Xe.normalMap||Xe.anisotropy>0),Pt=!!Ye.morphAttributes.position,tn=!!Ye.morphAttributes.normal,en=!!Ye.morphAttributes.color;let on=Rh;Xe.toneMapped&&(E===null||E.isXRRenderTarget===!0)&&(on=P.toneMapping);const gn=Ye.morphAttributes.position||Ye.morphAttributes.normal||Ye.morphAttributes.color,Tn=gn!==void 0?gn.length:0,Zt=Pe.get(Xe),fn=N.state.lights;if(ie===!0&&(me===!0||ye!==L)){const xa=ye===L&&Xe.id===B;Re.setState(Xe,ye,xa)}let un=!1;Xe.version===Zt.__version?(Zt.needsLights&&Zt.lightsStateVersion!==fn.state.version||Zt.outputColorSpace!==lt||Te.isBatchedMesh&&Zt.batching===!1||!Te.isBatchedMesh&&Zt.batching===!0||Te.isBatchedMesh&&Zt.batchingColor===!0&&Te.colorTexture===null||Te.isBatchedMesh&&Zt.batchingColor===!1&&Te.colorTexture!==null||Te.isInstancedMesh&&Zt.instancing===!1||!Te.isInstancedMesh&&Zt.instancing===!0||Te.isSkinnedMesh&&Zt.skinning===!1||!Te.isSkinnedMesh&&Zt.skinning===!0||Te.isInstancedMesh&&Zt.instancingColor===!0&&Te.instanceColor===null||Te.isInstancedMesh&&Zt.instancingColor===!1&&Te.instanceColor!==null||Te.isInstancedMesh&&Zt.instancingMorph===!0&&Te.morphTexture===null||Te.isInstancedMesh&&Zt.instancingMorph===!1&&Te.morphTexture!==null||Zt.envMap!==Tt||Xe.fog===!0&&Zt.fog!==ct||Zt.numClippingPlanes!==void 0&&(Zt.numClippingPlanes!==Re.numPlanes||Zt.numIntersection!==Re.numIntersection)||Zt.vertexAlphas!==Bt||Zt.vertexTangents!==It||Zt.morphTargets!==Pt||Zt.morphNormals!==tn||Zt.morphColors!==en||Zt.toneMapping!==on||Zt.morphTargetsCount!==Tn)&&(un=!0):(un=!0,Zt.__version=Xe.version);let qr=Zt.currentProgram;un===!0&&(qr=br(Xe,He,Te));let pn=!1,lr=!1,as=!1;const bn=qr.getUniforms(),vr=Zt.uniforms;if(ue.useProgram(qr.program)&&(pn=!0,lr=!0,as=!0),Xe.id!==B&&(B=Xe.id,lr=!0),pn||L!==ye){ue.buffers.depth.getReversed()&&ye.reversedDepth!==!0&&(ye._reversedDepth=!0,ye.updateProjectionMatrix()),bn.setValue(K,"projectionMatrix",ye.projectionMatrix),bn.setValue(K,"viewMatrix",ye.matrixWorldInverse);const Ua=bn.map.cameraPosition;Ua!==void 0&&Ua.setValue(K,ce.setFromMatrixPosition(ye.matrixWorld)),re.logarithmicDepthBuffer&&bn.setValue(K,"logDepthBufFC",2/(Math.log(ye.far+1)/Math.LN2)),(Xe.isMeshPhongMaterial||Xe.isMeshToonMaterial||Xe.isMeshLambertMaterial||Xe.isMeshBasicMaterial||Xe.isMeshStandardMaterial||Xe.isShaderMaterial)&&bn.setValue(K,"isOrthographic",ye.isOrthographicCamera===!0),L!==ye&&(L=ye,lr=!0,as=!0)}if(Te.isSkinnedMesh){bn.setOptional(K,Te,"bindMatrix"),bn.setOptional(K,Te,"bindMatrixInverse");const xa=Te.skeleton;xa&&(xa.boneTexture===null&&xa.computeBoneTexture(),bn.setValue(K,"boneTexture",xa.boneTexture,be))}Te.isBatchedMesh&&(bn.setOptional(K,Te,"batchingTexture"),bn.setValue(K,"batchingTexture",Te._matricesTexture,be),bn.setOptional(K,Te,"batchingIdTexture"),bn.setValue(K,"batchingIdTexture",Te._indirectTexture,be),bn.setOptional(K,Te,"batchingColorTexture"),Te._colorsTexture!==null&&bn.setValue(K,"batchingColorTexture",Te._colorsTexture,be));const Qn=Ye.morphAttributes;if((Qn.position!==void 0||Qn.normal!==void 0||Qn.color!==void 0)&&Ne.update(Te,Ye,qr),(lr||Zt.receiveShadow!==Te.receiveShadow)&&(Zt.receiveShadow=Te.receiveShadow,bn.setValue(K,"receiveShadow",Te.receiveShadow)),Xe.isMeshGouraudMaterial&&Xe.envMap!==null&&(vr.envMap.value=Tt,vr.flipEnvMap.value=Tt.isCubeTexture&&Tt.isRenderTargetTexture===!1?-1:1),Xe.isMeshStandardMaterial&&Xe.envMap===null&&He.environment!==null&&(vr.envMapIntensity.value=He.environmentIntensity),vr.dfgLUT!==void 0&&(vr.dfgLUT.value=oSe()),lr&&(bn.setValue(K,"toneMappingExposure",P.toneMappingExposure),Zt.needsLights&&_e(vr,as),ct&&Xe.fog===!0&&Ue.refreshFogUniforms(vr,ct),Ue.refreshMaterialUniforms(vr,Xe,te,Q,N.state.transmissionRenderTarget[ye.id]),X_.upload(K,or(Zt),vr,be)),Xe.isShaderMaterial&&Xe.uniformsNeedUpdate===!0&&(X_.upload(K,or(Zt),vr,be),Xe.uniformsNeedUpdate=!1),Xe.isSpriteMaterial&&bn.setValue(K,"center",Te.center),bn.setValue(K,"modelViewMatrix",Te.modelViewMatrix),bn.setValue(K,"normalMatrix",Te.normalMatrix),bn.setValue(K,"modelMatrix",Te.matrixWorld),Xe.isShaderMaterial||Xe.isRawShaderMaterial){const xa=Xe.uniformsGroups;for(let Ua=0,aa=xa.length;Ua<aa;Ua++){const bt=xa[Ua];nt.update(bt,qr),nt.bind(bt,qr)}}return qr}function _e(ye,He){ye.ambientLightColor.needsUpdate=He,ye.lightProbe.needsUpdate=He,ye.directionalLights.needsUpdate=He,ye.directionalLightShadows.needsUpdate=He,ye.pointLights.needsUpdate=He,ye.pointLightShadows.needsUpdate=He,ye.spotLights.needsUpdate=He,ye.spotLightShadows.needsUpdate=He,ye.rectAreaLights.needsUpdate=He,ye.hemisphereLights.needsUpdate=He}function tt(ye){return ye.isMeshLambertMaterial||ye.isMeshToonMaterial||ye.isMeshPhongMaterial||ye.isMeshStandardMaterial||ye.isShadowMaterial||ye.isShaderMaterial&&ye.lights===!0}this.getActiveCubeFace=function(){return j},this.getActiveMipmapLevel=function(){return M},this.getRenderTarget=function(){return E},this.setRenderTargetTextures=function(ye,He,Ye){const Xe=Pe.get(ye);Xe.__autoAllocateDepthBuffer=ye.resolveDepthBuffer===!1,Xe.__autoAllocateDepthBuffer===!1&&(Xe.__useRenderToTexture=!1),Pe.get(ye.texture).__webglTexture=He,Pe.get(ye.depthTexture).__webglTexture=Xe.__autoAllocateDepthBuffer?void 0:Ye,Xe.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(ye,He){const Ye=Pe.get(ye);Ye.__webglFramebuffer=He,Ye.__useDefaultFramebuffer=He===void 0};const it=K.createFramebuffer();this.setRenderTarget=function(ye,He=0,Ye=0){E=ye,j=He,M=Ye;let Xe=!0,Te=null,ct=!1,gt=!1;if(ye){const Tt=Pe.get(ye);if(Tt.__useDefaultFramebuffer!==void 0)ue.bindFramebuffer(K.FRAMEBUFFER,null),Xe=!1;else if(Tt.__webglFramebuffer===void 0)be.setupRenderTarget(ye);else if(Tt.__hasExternalTextures)be.rebindTextures(ye,Pe.get(ye.texture).__webglTexture,Pe.get(ye.depthTexture).__webglTexture);else if(ye.depthBuffer){const Pt=ye.depthTexture;if(Tt.__boundDepthTexture!==Pt){if(Pt!==null&&Pe.has(Pt)&&(ye.width!==Pt.image.width||ye.height!==Pt.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");be.setupDepthRenderbuffer(ye)}}const Bt=ye.texture;(Bt.isData3DTexture||Bt.isDataArrayTexture||Bt.isCompressedArrayTexture)&&(gt=!0);const It=Pe.get(ye).__webglFramebuffer;ye.isWebGLCubeRenderTarget?(Array.isArray(It[He])?Te=It[He][Ye]:Te=It[He],ct=!0):ye.samples>0&&be.useMultisampledRTT(ye)===!1?Te=Pe.get(ye).__webglMultisampledFramebuffer:Array.isArray(It)?Te=It[Ye]:Te=It,U.copy(ye.viewport),D.copy(ye.scissor),$=ye.scissorTest}else U.copy(Z).multiplyScalar(te).floor(),D.copy(ee).multiplyScalar(te).floor(),$=Se;if(Ye!==0&&(Te=it),ue.bindFramebuffer(K.FRAMEBUFFER,Te)&&Xe&&ue.drawBuffers(ye,Te),ue.viewport(U),ue.scissor(D),ue.setScissorTest($),ct){const Tt=Pe.get(ye.texture);K.framebufferTexture2D(K.FRAMEBUFFER,K.COLOR_ATTACHMENT0,K.TEXTURE_CUBE_MAP_POSITIVE_X+He,Tt.__webglTexture,Ye)}else if(gt){const Tt=He;for(let Bt=0;Bt<ye.textures.length;Bt++){const It=Pe.get(ye.textures[Bt]);K.framebufferTextureLayer(K.FRAMEBUFFER,K.COLOR_ATTACHMENT0+Bt,It.__webglTexture,Ye,Tt)}}else if(ye!==null&&Ye!==0){const Tt=Pe.get(ye.texture);K.framebufferTexture2D(K.FRAMEBUFFER,K.COLOR_ATTACHMENT0,K.TEXTURE_2D,Tt.__webglTexture,Ye)}B=-1},this.readRenderTargetPixels=function(ye,He,Ye,Xe,Te,ct,gt,lt=0){if(!(ye&&ye.isWebGLRenderTarget)){$a("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Tt=Pe.get(ye).__webglFramebuffer;if(ye.isWebGLCubeRenderTarget&>!==void 0&&(Tt=Tt[gt]),Tt){ue.bindFramebuffer(K.FRAMEBUFFER,Tt);try{const Bt=ye.textures[lt],It=Bt.format,Pt=Bt.type;if(!re.textureFormatReadable(It)){$a("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!re.textureTypeReadable(Pt)){$a("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}He>=0&&He<=ye.width-Xe&&Ye>=0&&Ye<=ye.height-Te&&(ye.textures.length>1&&K.readBuffer(K.COLOR_ATTACHMENT0+lt),K.readPixels(He,Ye,Xe,Te,qe.convert(It),qe.convert(Pt),ct))}finally{const Bt=E!==null?Pe.get(E).__webglFramebuffer:null;ue.bindFramebuffer(K.FRAMEBUFFER,Bt)}}},this.readRenderTargetPixelsAsync=async function(ye,He,Ye,Xe,Te,ct,gt,lt=0){if(!(ye&&ye.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Tt=Pe.get(ye).__webglFramebuffer;if(ye.isWebGLCubeRenderTarget&>!==void 0&&(Tt=Tt[gt]),Tt)if(He>=0&&He<=ye.width-Xe&&Ye>=0&&Ye<=ye.height-Te){ue.bindFramebuffer(K.FRAMEBUFFER,Tt);const Bt=ye.textures[lt],It=Bt.format,Pt=Bt.type;if(!re.textureFormatReadable(It))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!re.textureTypeReadable(Pt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const tn=K.createBuffer();K.bindBuffer(K.PIXEL_PACK_BUFFER,tn),K.bufferData(K.PIXEL_PACK_BUFFER,ct.byteLength,K.STREAM_READ),ye.textures.length>1&&K.readBuffer(K.COLOR_ATTACHMENT0+lt),K.readPixels(He,Ye,Xe,Te,qe.convert(It),qe.convert(Pt),0);const en=E!==null?Pe.get(E).__webglFramebuffer:null;ue.bindFramebuffer(K.FRAMEBUFFER,en);const on=K.fenceSync(K.SYNC_GPU_COMMANDS_COMPLETE,0);return K.flush(),await Pbe(K,on,4),K.bindBuffer(K.PIXEL_PACK_BUFFER,tn),K.getBufferSubData(K.PIXEL_PACK_BUFFER,0,ct),K.deleteBuffer(tn),K.deleteSync(on),ct}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(ye,He=null,Ye=0){const Xe=Math.pow(2,-Ye),Te=Math.floor(ye.image.width*Xe),ct=Math.floor(ye.image.height*Xe),gt=He!==null?He.x:0,lt=He!==null?He.y:0;be.setTexture2D(ye,0),K.copyTexSubImage2D(K.TEXTURE_2D,Ye,0,0,gt,lt,Te,ct),ue.unbindTexture()};const Ke=K.createFramebuffer(),Lt=K.createFramebuffer();this.copyTextureToTexture=function(ye,He,Ye=null,Xe=null,Te=0,ct=null){ct===null&&(Te!==0?(S0("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),ct=Te,Te=0):ct=0);let gt,lt,Tt,Bt,It,Pt,tn,en,on;const gn=ye.isCompressedTexture?ye.mipmaps[ct]:ye.image;if(Ye!==null)gt=Ye.max.x-Ye.min.x,lt=Ye.max.y-Ye.min.y,Tt=Ye.isBox3?Ye.max.z-Ye.min.z:1,Bt=Ye.min.x,It=Ye.min.y,Pt=Ye.isBox3?Ye.min.z:0;else{const Qn=Math.pow(2,-Te);gt=Math.floor(gn.width*Qn),lt=Math.floor(gn.height*Qn),ye.isDataArrayTexture?Tt=gn.depth:ye.isData3DTexture?Tt=Math.floor(gn.depth*Qn):Tt=1,Bt=0,It=0,Pt=0}Xe!==null?(tn=Xe.x,en=Xe.y,on=Xe.z):(tn=0,en=0,on=0);const Tn=qe.convert(He.format),Zt=qe.convert(He.type);let fn;He.isData3DTexture?(be.setTexture3D(He,0),fn=K.TEXTURE_3D):He.isDataArrayTexture||He.isCompressedArrayTexture?(be.setTexture2DArray(He,0),fn=K.TEXTURE_2D_ARRAY):(be.setTexture2D(He,0),fn=K.TEXTURE_2D),K.pixelStorei(K.UNPACK_FLIP_Y_WEBGL,He.flipY),K.pixelStorei(K.UNPACK_PREMULTIPLY_ALPHA_WEBGL,He.premultiplyAlpha),K.pixelStorei(K.UNPACK_ALIGNMENT,He.unpackAlignment);const un=K.getParameter(K.UNPACK_ROW_LENGTH),qr=K.getParameter(K.UNPACK_IMAGE_HEIGHT),pn=K.getParameter(K.UNPACK_SKIP_PIXELS),lr=K.getParameter(K.UNPACK_SKIP_ROWS),as=K.getParameter(K.UNPACK_SKIP_IMAGES);K.pixelStorei(K.UNPACK_ROW_LENGTH,gn.width),K.pixelStorei(K.UNPACK_IMAGE_HEIGHT,gn.height),K.pixelStorei(K.UNPACK_SKIP_PIXELS,Bt),K.pixelStorei(K.UNPACK_SKIP_ROWS,It),K.pixelStorei(K.UNPACK_SKIP_IMAGES,Pt);const bn=ye.isDataArrayTexture||ye.isData3DTexture,vr=He.isDataArrayTexture||He.isData3DTexture;if(ye.isDepthTexture){const Qn=Pe.get(ye),xa=Pe.get(He),Ua=Pe.get(Qn.__renderTarget),aa=Pe.get(xa.__renderTarget);ue.bindFramebuffer(K.READ_FRAMEBUFFER,Ua.__webglFramebuffer),ue.bindFramebuffer(K.DRAW_FRAMEBUFFER,aa.__webglFramebuffer);for(let bt=0;bt<Tt;bt++)bn&&(K.framebufferTextureLayer(K.READ_FRAMEBUFFER,K.COLOR_ATTACHMENT0,Pe.get(ye).__webglTexture,Te,Pt+bt),K.framebufferTextureLayer(K.DRAW_FRAMEBUFFER,K.COLOR_ATTACHMENT0,Pe.get(He).__webglTexture,ct,on+bt)),K.blitFramebuffer(Bt,It,gt,lt,tn,en,gt,lt,K.DEPTH_BUFFER_BIT,K.NEAREST);ue.bindFramebuffer(K.READ_FRAMEBUFFER,null),ue.bindFramebuffer(K.DRAW_FRAMEBUFFER,null)}else if(Te!==0||ye.isRenderTargetTexture||Pe.has(ye)){const Qn=Pe.get(ye),xa=Pe.get(He);ue.bindFramebuffer(K.READ_FRAMEBUFFER,Ke),ue.bindFramebuffer(K.DRAW_FRAMEBUFFER,Lt);for(let Ua=0;Ua<Tt;Ua++)bn?K.framebufferTextureLayer(K.READ_FRAMEBUFFER,K.COLOR_ATTACHMENT0,Qn.__webglTexture,Te,Pt+Ua):K.framebufferTexture2D(K.READ_FRAMEBUFFER,K.COLOR_ATTACHMENT0,K.TEXTURE_2D,Qn.__webglTexture,Te),vr?K.framebufferTextureLayer(K.DRAW_FRAMEBUFFER,K.COLOR_ATTACHMENT0,xa.__webglTexture,ct,on+Ua):K.framebufferTexture2D(K.DRAW_FRAMEBUFFER,K.COLOR_ATTACHMENT0,K.TEXTURE_2D,xa.__webglTexture,ct),Te!==0?K.blitFramebuffer(Bt,It,gt,lt,tn,en,gt,lt,K.COLOR_BUFFER_BIT,K.NEAREST):vr?K.copyTexSubImage3D(fn,ct,tn,en,on+Ua,Bt,It,gt,lt):K.copyTexSubImage2D(fn,ct,tn,en,Bt,It,gt,lt);ue.bindFramebuffer(K.READ_FRAMEBUFFER,null),ue.bindFramebuffer(K.DRAW_FRAMEBUFFER,null)}else vr?ye.isDataTexture||ye.isData3DTexture?K.texSubImage3D(fn,ct,tn,en,on,gt,lt,Tt,Tn,Zt,gn.data):He.isCompressedArrayTexture?K.compressedTexSubImage3D(fn,ct,tn,en,on,gt,lt,Tt,Tn,gn.data):K.texSubImage3D(fn,ct,tn,en,on,gt,lt,Tt,Tn,Zt,gn):ye.isDataTexture?K.texSubImage2D(K.TEXTURE_2D,ct,tn,en,gt,lt,Tn,Zt,gn.data):ye.isCompressedTexture?K.compressedTexSubImage2D(K.TEXTURE_2D,ct,tn,en,gn.width,gn.height,Tn,gn.data):K.texSubImage2D(K.TEXTURE_2D,ct,tn,en,gt,lt,Tn,Zt,gn);K.pixelStorei(K.UNPACK_ROW_LENGTH,un),K.pixelStorei(K.UNPACK_IMAGE_HEIGHT,qr),K.pixelStorei(K.UNPACK_SKIP_PIXELS,pn),K.pixelStorei(K.UNPACK_SKIP_ROWS,lr),K.pixelStorei(K.UNPACK_SKIP_IMAGES,as),ct===0&&He.generateMipmaps&&K.generateMipmap(fn),ue.unbindTexture()},this.initRenderTarget=function(ye){Pe.get(ye).__webglFramebuffer===void 0&&be.setupRenderTarget(ye)},this.initTexture=function(ye){ye.isCubeTexture?be.setTextureCube(ye,0):ye.isData3DTexture?be.setTexture3D(ye,0):ye.isDataArrayTexture||ye.isCompressedArrayTexture?be.setTexture2DArray(ye,0):be.setTexture2D(ye,0),ue.unbindTexture()},this.resetState=function(){j=0,M=0,E=null,ue.reset(),ke.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Ac}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const n=this.getContext();n.drawingBufferColorSpace=fr._getDrawingBufferColorSpace(e),n.unpackColorSpace=fr._getUnpackColorSpace()}};const X8={type:"change"},ZF={type:"start"},_Y={type:"end"},CS=new GF,Y8=new sh,cSe=Math.cos(70*jbe.DEG2RAD),di=new pt,Xs=2*Math.PI,Hr={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},vP=1e-6;class dSe extends wxe{constructor(e,n=null){super(e,n),this.state=Hr.NONE,this.target=new pt,this.cursor=new pt,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:Yg.ROTATE,MIDDLE:Yg.DOLLY,RIGHT:Yg.PAN},this.touches={ONE:Ig.ROTATE,TWO:Ig.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new pt,this._lastQuaternion=new Ff,this._lastTargetPosition=new pt,this._quat=new Ff().setFromUnitVectors(e.up,new pt(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new N8,this._sphericalDelta=new N8,this._scale=1,this._panOffset=new pt,this._rotateStart=new In,this._rotateEnd=new In,this._rotateDelta=new In,this._panStart=new In,this._panEnd=new In,this._panDelta=new In,this._dollyStart=new In,this._dollyEnd=new In,this._dollyDelta=new In,this._dollyDirection=new pt,this._mouse=new In,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=hSe.bind(this),this._onPointerDown=uSe.bind(this),this._onPointerUp=mSe.bind(this),this._onContextMenu=vSe.bind(this),this._onMouseWheel=gSe.bind(this),this._onKeyDown=bSe.bind(this),this._onTouchStart=xSe.bind(this),this._onTouchMove=ySe.bind(this),this._onMouseDown=fSe.bind(this),this._onMouseMove=pSe.bind(this),this._interceptControlDown=wSe.bind(this),this._interceptControlUp=SSe.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(X8),this.update(),this.state=Hr.NONE}update(e=null){const n=this.object.position;di.copy(n).sub(this.target),di.applyQuaternion(this._quat),this._spherical.setFromVector3(di),this.autoRotate&&this.state===Hr.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+=Xs:r>Math.PI&&(r-=Xs),i<-Math.PI?i+=Xs:i>Math.PI&&(i-=Xs),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(di.setFromSpherical(this._spherical),di.applyQuaternion(this._quatInverse),n.copy(this.target).add(di),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=di.length();o=this._clampDistance(l*this._scale);const c=l-o;this.object.position.addScaledVector(this._dollyDirection,c),this.object.updateMatrixWorld(),s=!!c}else if(this.object.isOrthographicCamera){const l=new pt(this._mouse.x,this._mouse.y,0);l.unproject(this.object);const c=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),s=c!==this.object.zoom;const d=new pt(this._mouse.x,this._mouse.y,0);d.unproject(this.object),this.object.position.sub(d).add(l),this.object.updateMatrixWorld(),o=di.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):(CS.origin.copy(this.object.position),CS.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(CS.direction))<cSe?this.object.lookAt(this.target):(Y8.setFromNormalAndCoplanarPoint(this.object.up,this.target),CS.intersectPlane(Y8,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)>vP||8*(1-this._lastQuaternion.dot(this.object.quaternion))>vP||this._lastTargetPosition.distanceToSquared(this.target)>vP?(this.dispatchEvent(X8),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?Xs/60*this.autoRotateSpeed*e:Xs/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){di.setFromMatrixColumn(n,0),di.multiplyScalar(-e),this._panOffset.add(di)}_panUp(e,n){this.screenSpacePanning===!0?di.setFromMatrixColumn(n,1):(di.setFromMatrixColumn(n,0),di.crossVectors(this.object.up,di)),di.multiplyScalar(e),this._panOffset.add(di)}_pan(e,n){const r=this.domElement;if(this.object.isPerspectiveCamera){const i=this.object.position;di.copy(i).sub(this.target);let s=di.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(Xs*this._rotateDelta.x/n.clientHeight),this._rotateUp(Xs*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(Xs*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(-Xs*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(Xs*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(-Xs*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(Xs*this._rotateDelta.x/n.clientHeight),this._rotateUp(Xs*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 In,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 uSe(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 hSe(t){this.enabled!==!1&&(t.pointerType==="touch"?this._onTouchMove(t):this._onMouseMove(t))}function mSe(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(_Y),this.state=Hr.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 fSe(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 Yg.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(t),this.state=Hr.DOLLY;break;case Yg.ROTATE:if(t.ctrlKey||t.metaKey||t.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(t),this.state=Hr.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(t),this.state=Hr.ROTATE}break;case Yg.PAN:if(t.ctrlKey||t.metaKey||t.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(t),this.state=Hr.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(t),this.state=Hr.PAN}break;default:this.state=Hr.NONE}this.state!==Hr.NONE&&this.dispatchEvent(ZF)}function pSe(t){switch(this.state){case Hr.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(t);break;case Hr.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(t);break;case Hr.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(t);break}}function gSe(t){this.enabled===!1||this.enableZoom===!1||this.state!==Hr.NONE||(t.preventDefault(),this.dispatchEvent(ZF),this._handleMouseWheel(this._customWheelEvent(t)),this.dispatchEvent(_Y))}function bSe(t){this.enabled!==!1&&this._handleKeyDown(t)}function xSe(t){switch(this._trackPointer(t),this._pointers.length){case 1:switch(this.touches.ONE){case Ig.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(t),this.state=Hr.TOUCH_ROTATE;break;case Ig.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(t),this.state=Hr.TOUCH_PAN;break;default:this.state=Hr.NONE}break;case 2:switch(this.touches.TWO){case Ig.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(t),this.state=Hr.TOUCH_DOLLY_PAN;break;case Ig.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(t),this.state=Hr.TOUCH_DOLLY_ROTATE;break;default:this.state=Hr.NONE}break;default:this.state=Hr.NONE}this.state!==Hr.NONE&&this.dispatchEvent(ZF)}function ySe(t){switch(this._trackPointer(t),this.state){case Hr.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(t),this.update();break;case Hr.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(t),this.update();break;case Hr.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(t),this.update();break;case Hr.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(t),this.update();break;default:this.state=Hr.NONE}}function vSe(t){this.enabled!==!1&&t.preventDefault()}function wSe(t){t.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function SSe(t){t.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function _Se(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 _l;let d=0;for(let u=0;u<t.length;++u){const h=t[u];let f=0;if(n!==(h.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". 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 "+u+'. 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 "+u+". 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 "+u+". .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 "+u+". .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 "+u+". The geometry must have either an index or a position attribute"),null;c.addGroup(d,p,u),d+=p}}if(n){let u=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)+u);u+=t[f].attributes.position.count}c.setIndex(h)}for(const u in s){const h=Q8(s[u]);if(!h)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+u+" attribute."),null;c.setAttribute(u,h)}for(const u in o){const h=o[u][0].length;if(h===0)break;c.morphAttributes=c.morphAttributes||{},c.morphAttributes[u]=[];for(let f=0;f<h;++f){const p=[];for(let v=0;v<o[u].length;++v)p.push(o[u][v][f]);const x=Q8(p);if(!x)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+u+" morphAttribute."),null;c.morphAttributes[u].push(x)}}return c}function Q8(t){let e,n,r,i=-1,s=0;for(let d=0;d<t.length;++d){const u=t[d];if(e===void 0&&(e=u.array.constructor),e!==u.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=u.itemSize),n!==u.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(r===void 0&&(r=u.normalized),r!==u.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(i===-1&&(i=u.gpuType),i!==u.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;s+=u.count*n}const o=new e(s),l=new Rs(o,n,r);let c=0;for(let d=0;d<t.length;++d){const u=t[d];if(u.isInterleavedBufferAttribute){const h=c/n;for(let f=0,p=u.count;f<p;f++)for(let x=0;x<n;x++){const v=u.getComponent(f,x);l.setComponent(f+h,x,v)}}else o.set(u.array,c);c+=u.count*n}return i!==void 0&&(l.gpuType=i),l}class NSe extends QF{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(d){const u=new DataView(d),h=32/8*3+32/8*3*3+16/8,f=u.getUint32(80,!0);if(80+32/8+f*h===u.byteLength)return!0;const x=[115,111,108,105,100];for(let v=0;v<5;v++)if(r(x,u,v))return!1;return!0}function r(d,u,h){for(let f=0,p=d.length;f<p;f++)if(d[f]!==u.getUint8(h+f))return!1;return!0}function i(d){const u=new DataView(d),h=u.getUint32(80,!0);let f,p,x,v=!1,g,y,_,N,A;for(let B=0;B<70;B++)u.getUint32(B,!1)==1129270351&&u.getUint8(B+4)==82&&u.getUint8(B+5)==61&&(v=!0,g=new Float32Array(h*3*3),y=u.getUint8(B+6)/255,_=u.getUint8(B+7)/255,N=u.getUint8(B+8)/255,A=u.getUint8(B+9)/255);const k=84,P=50,C=new _l,j=new Float32Array(h*3*3),M=new Float32Array(h*3*3),E=new Hn;for(let B=0;B<h;B++){const L=k+B*P,U=u.getFloat32(L,!0),D=u.getFloat32(L+4,!0),$=u.getFloat32(L+8,!0);if(v){const q=u.getUint16(L+48,!0);(q&32768)===0?(f=(q&31)/31,p=(q>>5&31)/31,x=(q>>10&31)/31):(f=y,p=_,x=N)}for(let q=1;q<=3;q++){const z=L+q*12,W=B*3*3+(q-1)*3;j[W]=u.getFloat32(z,!0),j[W+1]=u.getFloat32(z+4,!0),j[W+2]=u.getFloat32(z+8,!0),M[W]=U,M[W+1]=D,M[W+2]=$,v&&(E.setRGB(f,p,x,ko),g[W]=E.r,g[W+1]=E.g,g[W+2]=E.b)}}return C.setAttribute("position",new Rs(j,3)),C.setAttribute("normal",new Rs(M,3)),v&&(C.setAttribute("color",new Rs(g,3)),C.hasColors=!0,C.alpha=A),C}function s(d){const u=new _l,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=[],k=new pt;let P,C=0,j=0,M=0;for(;(P=h.exec(d))!==null;){j=M;const E=P[0],B=(P=p.exec(E))!==null?P[1]:"";for(A.push(B);(P=f.exec(E))!==null;){let D=0,$=0;const q=P[0];for(;(P=y.exec(q))!==null;)k.x=parseFloat(P[1]),k.y=parseFloat(P[2]),k.z=parseFloat(P[3]),$++;for(;(P=g.exec(q))!==null;)_.push(parseFloat(P[1]),parseFloat(P[2]),parseFloat(P[3])),N.push(k.x,k.y,k.z),D++,M++;$!==1&&console.error("THREE.STLLoader: Something isn't right with the normal of face number "+x),D!==3&&console.error("THREE.STLLoader: Something isn't right with the vertices of face number "+x),x++}const L=j,U=M-j;u.userData.groupNames=A,u.addGroup(L,U,C),C++}return u.setAttribute("position",new jo(_,3)),u.setAttribute("normal",new jo(N,3)),u}function o(d){return typeof d!="string"?new TextDecoder().decode(d):d}function l(d){if(typeof d=="string"){const u=new Uint8Array(d.length);for(let h=0;h<d.length;h++)u[h]=d.charCodeAt(h)&255;return u.buffer||u}else return d}const c=l(e);return n(c)?i(c):s(o(e))}}function kS(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 wP={exports:{}};var Z8;function CSe(){return Z8||(Z8=1,(function(t,e){(function(n){t.exports=n()})(function(){return(function n(r,i,s){function o(d,u){if(!i[d]){if(!r[d]){var h=typeof kS=="function"&&kS;if(!u&&h)return h(d,!0);if(l)return l(d,!0);var f=new Error("Cannot find module '"+d+"'");throw f.code="MODULE_NOT_FOUND",f}var p=i[d]={exports:{}};r[d][0].call(p.exports,function(x){var v=r[d][1][x];return o(v||x)},p,p.exports,n,r,i,s)}return i[d].exports}for(var l=typeof kS=="function"&&kS,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 d,u,h,f,p,x,v,g=[],y=0,_=c.length,N=_,A=s.getTypeOf(c)!=="string";y<c.length;)N=_-y,h=A?(d=c[y++],u=y<_?c[y++]:0,y<_?c[y++]:0):(d=c.charCodeAt(y++),u=y<_?c.charCodeAt(y++):0,y<_?c.charCodeAt(y++):0),f=d>>2,p=(3&d)<<4|u>>4,x=1<N?(15&u)<<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 d,u,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;)d=l.indexOf(c.charAt(v++))<<2|(f=l.indexOf(c.charAt(v++)))>>4,u=(15&f)<<4|(p=l.indexOf(c.charAt(v++)))>>2,h=(3&p)<<6|(x=l.indexOf(c.charAt(v++))),_[g++]=d,p!==64&&(_[g++]=u),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 d(u,h,f,p,x){this.compressedSize=u,this.uncompressedSize=h,this.crc32=f,this.compression=p,this.compressedContent=x}d.prototype={getContentWorker:function(){var u=new o(s.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new c("data_length")),h=this;return u.on("end",function(){if(this.streamInfo.data_length!==h.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),u},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)}},d.createWorkerFrom=function(u,h,f){return u.pipe(new l).pipe(new c("uncompressedSize")).pipe(h.compressWorker(f)).pipe(new c("compressedSize")).withStreamInfo("compression",h)},r.exports=d},{"./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=[],d=0;d<256;d++){l=d;for(var u=0;u<8;u++)l=1&l?3988292384^l>>>1:l>>>1;c[d]=l}return c})();r.exports=function(l,c){return l!==void 0&&l.length?s.getTypeOf(l)!=="string"?(function(d,u,h,f){var p=o,x=f+h;d^=-1;for(var v=f;v<x;v++)d=d>>>8^p[255&(d^u[v])];return-1^d})(0|c,l,l.length,0):(function(d,u,h,f){var p=o,x=f+h;d^=-1;for(var v=f;v<x;v++)d=d>>>8^p[255&(d^u.charCodeAt(v))];return-1^d})(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"),d=s?"uint8array":"array";function u(h,f){c.call(this,"FlateWorker/"+h),this._pako=null,this._pakoAction=h,this._pakoOptions=f,this.meta={}}i.magic="\b\0",l.inherits(u,c),u.prototype.processChunk=function(h){this.meta=h.meta,this._pako===null&&this._createPako(),this._pako.push(l.transformTo(d,h.data),!1)},u.prototype.flush=function(){c.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},u.prototype.cleanUp=function(){c.prototype.cleanUp.call(this),this._pako=null},u.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 u("Deflate",h)},i.uncompressWorker=function(){return new u("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,k=p.file,P=p.compression,C=_!==d.utf8encode,j=l.transformTo("string",_(k.name)),M=l.transformTo("string",d.utf8encode(k.name)),E=k.comment,B=l.transformTo("string",_(E)),L=l.transformTo("string",d.utf8encode(E)),U=M.length!==k.name.length,D=L.length!==E.length,$="",q="",z="",W=k.dir,Q=k.date,te={crc32:0,compressedSize:0,uncompressedSize:0};x&&!v||(te.crc32=p.crc32,te.compressedSize=p.compressedSize,te.uncompressedSize=p.uncompressedSize);var H=0;x&&(H|=8),C||!U&&!D||(H|=2048);var X=0,Z=0;W&&(X|=16),y==="UNIX"?(Z=798,X|=(function(Se,oe){var ie=Se;return Se||(ie=oe?16893:33204),(65535&ie)<<16})(k.unixPermissions,W)):(Z=20,X|=(function(Se){return 63&(Se||0)})(k.dosPermissions)),N=Q.getUTCHours(),N<<=6,N|=Q.getUTCMinutes(),N<<=5,N|=Q.getUTCSeconds()/2,A=Q.getUTCFullYear()-1980,A<<=4,A|=Q.getUTCMonth()+1,A<<=5,A|=Q.getUTCDate(),U&&(q=s(1,1)+s(u(j),4)+M,$+="up"+s(q.length,2)+q),D&&(z=s(1,1)+s(u(B),4)+L,$+="uc"+s(z.length,2)+z);var ee="";return ee+=`
- \0`,ee+=s(H,2),ee+=P.magic,ee+=s(N,2),ee+=s(A,2),ee+=s(te.crc32,4),ee+=s(te.compressedSize,4),ee+=s(te.uncompressedSize,4),ee+=s(j.length,2),ee+=s($.length,2),{fileRecord:h.LOCAL_FILE_HEADER+ee+j+$,dirRecord:h.CENTRAL_FILE_HEADER+s(Z,2)+ee+s(B.length,2)+"\0\0\0\0"+s(X,4)+s(g,4)+j+$+B}}var l=n("../utils"),c=n("../stream/GenericWorker"),d=n("../utf8"),u=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,k){var P=l.transformTo("string",k(A));return h.CENTRAL_DIRECTORY_END+"\0\0\0\0"+s(y,2)+s(y,2)+s(_,4)+s(N,4)+s(P.length,2)+P})(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,d){var u=new o(c.streamFiles,d,c.platform,c.encodeFileName),h=0;try{l.forEach(function(f,p){h++;var x=(function(_,N){var A=_||N,k=s[A];if(!k)throw new Error(A+" is not a valid compression method !");return k})(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(u)}),u.entriesCount=h}catch(f){u.error(f)}return u}},{"../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"),d=n("./stream/Crc32Probe"),u=n("./nodejsUtils");function h(f){return new o.Promise(function(p,x){var v=f.decompressed.getContentWorker().pipe(new d);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}),u.isNode&&u.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,k=s.resolve(N.fileNameStr);x.file(k,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(k).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,d){o.call(this,"Nodejs stream input adapter for "+c),this._upstreamEnded=!1,this._bindStream(d)}s.inherits(l,o),l.prototype._bindStream=function(c){var d=this;(this._stream=c).pause(),c.on("data",function(u){d.push({data:u,meta:{percent:0}})}).on("error",function(u){d.isPaused?this.generatedError=u:d.error(u)}).on("end",function(){d.isPaused?d._upstreamEnded=!0:d.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,d){s.call(this,c),this._helper=l;var u=this;l.on("data",function(h,f){u.push(h)||u._helper.pause(),d&&d(f)}).on("error",function(h){u.emit("error",h)}).on("end",function(){u.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(k,P,C){var j,M=l.getTypeOf(P),E=l.extend(C||{},u);E.date=E.date||new Date,E.compression!==null&&(E.compression=E.compression.toUpperCase()),typeof E.unixPermissions=="string"&&(E.unixPermissions=parseInt(E.unixPermissions,8)),E.unixPermissions&&16384&E.unixPermissions&&(E.dir=!0),E.dosPermissions&&16&E.dosPermissions&&(E.dir=!0),E.dir&&(k=y(k)),E.createFolders&&(j=g(k))&&_.call(this,j,!0);var B=M==="string"&&E.binary===!1&&E.base64===!1;C&&C.binary!==void 0||(E.binary=!B),(P instanceof h&&P.uncompressedSize===0||E.dir||!P||P.length===0)&&(E.base64=!1,E.binary=!0,P="",E.compression="STORE",M="string");var L=null;L=P instanceof h||P instanceof c?P:x.isNode&&x.isStream(P)?new v(k,P):l.prepareContent(k,P,E.binary,E.optimizedBinaryString,E.base64);var U=new f(k,L,E);this.files[k]=U}var o=n("./utf8"),l=n("./utils"),c=n("./stream/GenericWorker"),d=n("./stream/StreamHelper"),u=n("./defaults"),h=n("./compressedObject"),f=n("./zipObject"),p=n("./generate"),x=n("./nodejsUtils"),v=n("./nodejs/NodejsStreamInputAdapter"),g=function(k){k.slice(-1)==="/"&&(k=k.substring(0,k.length-1));var P=k.lastIndexOf("/");return 0<P?k.substring(0,P):""},y=function(k){return k.slice(-1)!=="/"&&(k+="/"),k},_=function(k,P){return P=P!==void 0?P:u.createFolders,k=y(k),this.files[k]||s.call(this,k,null,{dir:!0,createFolders:P}),this.files[k]};function N(k){return Object.prototype.toString.call(k)==="[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(k){var P,C,j;for(P in this.files)j=this.files[P],(C=P.slice(this.root.length,P.length))&&P.slice(0,this.root.length)===this.root&&k(C,j)},filter:function(k){var P=[];return this.forEach(function(C,j){k(C,j)&&P.push(j)}),P},file:function(k,P,C){if(arguments.length!==1)return k=this.root+k,s.call(this,k,P,C),this;if(N(k)){var j=k;return this.filter(function(E,B){return!B.dir&&j.test(E)})}var M=this.files[this.root+k];return M&&!M.dir?M:null},folder:function(k){if(!k)return this;if(N(k))return this.filter(function(M,E){return E.dir&&k.test(M)});var P=this.root+k,C=_.call(this,P),j=this.clone();return j.root=C.name,j},remove:function(k){k=this.root+k;var P=this.files[k];if(P||(k.slice(-1)!=="/"&&(k+="/"),P=this.files[k]),P&&!P.dir)delete this.files[k];else for(var C=this.filter(function(M,E){return E.name.slice(0,k.length)===k}),j=0;j<C.length;j++)delete this.files[C[j].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(k){var P,C={};try{if((C=l.extend(k||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:o.utf8encode})).type=C.type.toLowerCase(),C.compression=C.compression.toUpperCase(),C.type==="binarystring"&&(C.type="string"),!C.type)throw new Error("No output type specified.");l.checkSupport(C.type),C.platform!=="darwin"&&C.platform!=="freebsd"&&C.platform!=="linux"&&C.platform!=="sunos"||(C.platform="UNIX"),C.platform==="win32"&&(C.platform="DOS");var j=C.comment||this.comment||"";P=p.generateWorker(this,C,j)}catch(M){(P=new c("error")).error(M)}return new d(P,C.type||"string",C.mimeType)},generateAsync:function(k,P){return this.generateInternalStream(k).accumulate(P)},generateNodeStream:function(k,P){return(k=k||{}).type||(k.type="nodebuffer"),this.generateInternalStream(k).toNodejsStream(P)}};r.exports=A},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(n,r,i){r.exports=n("stream")},{stream:void 0}],17:[function(n,r,i){var s=n("./DataReader");function 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),d=l.charCodeAt(1),u=l.charCodeAt(2),h=l.charCodeAt(3),f=this.length-4;0<=f;--f)if(this.data[f]===c&&this.data[f+1]===d&&this.data[f+2]===u&&this.data[f+3]===h)return f-this.zero;return-1},o.prototype.readAndCheckSignature=function(l){var c=l.charCodeAt(0),d=l.charCodeAt(1),u=l.charCodeAt(2),h=l.charCodeAt(3),f=this.readData(4);return c===f[0]&&d===f[1]&&u===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,d=0;for(this.checkOffset(l),c=this.index+l-1;c>=this.index;c--)d=(d<<8)+this.byteAt(c);return this.index+=l,d},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"),d=n("./NodeBufferReader"),u=n("./Uint8ArrayReader");r.exports=function(h){var f=s.getTypeOf(h);return s.checkSupport(f),f!=="string"||o.uint8array?f==="nodebuffer"?new d(h):o.uint8array?new u(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 d=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=d+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 d=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,c.then(function(u){d.dataIsReady=!0,d.data=u,d.max=u&&u.length||0,d.type=s.getTypeOf(u),d.isPaused||d._tickAndRepeat()},function(u){d.error(u)})}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,d=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,d);break;case"uint8array":c=this.data.subarray(this.index,d);break;case"array":case"nodebuffer":c=this.data.slice(this.index,d)}return this.index=d,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"),d=n("../support"),u=n("../external"),h=null;if(d.nodestream)try{h=n("../nodejs/NodejsStreamOutputAdapter")}catch{}function f(x,v){return new u.Promise(function(g,y){var _=[],N=x._internalType,A=x._outputType,k=x._mimeType;x.on("data",function(P,C){_.push(P),v&&v(C)}).on("error",function(P){_=[],y(P)}).on("end",function(){try{var P=(function(C,j,M){switch(C){case"blob":return s.newBlob(s.transformTo("arraybuffer",j),M);case"base64":return c.encode(j);default:return s.transformTo(C,j)}})(A,(function(C,j){var M,E=0,B=null,L=0;for(M=0;M<j.length;M++)L+=j[M].length;switch(C){case"string":return j.join("");case"array":return Array.prototype.concat.apply([],j);case"uint8array":for(B=new Uint8Array(L),M=0;M<j.length;M++)B.set(j[M],E),E+=j[M].length;return B;case"nodebuffer":return Buffer.concat(j);default:throw new Error("concat : unsupported type '"+C+"'")}})(N,_),k);g(P)}catch(C){y(C)}_=[]}).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"),d=new Array(256),u=0;u<256;u++)d[u]=252<=u?6:248<=u?5:240<=u?4:224<=u?3:192<=u?2:1;d[254]=d[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,k=0;for(_=0;_<A;_++)(64512&(g=x.charCodeAt(_)))==55296&&_+1<A&&(64512&(y=x.charCodeAt(_+1)))==56320&&(g=65536+(g-55296<<10)+(y-56320),_++),k+=g<128?1:g<2048?2:g<65536?3:4;for(v=o.uint8array?new Uint8Array(k):new Array(k),_=N=0;N<k;_++)(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<(_=d[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+d[_[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 d(v){return v}function u(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:d,array:function(v){return u(v,new Array(v.length))},arraybuffer:function(v){return x.string.uint8array(v).buffer},uint8array:function(v){return u(v,new Uint8Array(v.length))},nodebuffer:function(v){return u(v,l.allocBuffer(v.length))}},x.array={string:f,array:d,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:d,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:d,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:d},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(k,P){var C=new FileReader;C.onload=function(j){k(j.target.result)},C.onerror=function(j){P(j.target.error)},C.readAsArrayBuffer(A)}):A}).then(function(A){var k=i.getTypeOf(A);return k?(k==="arraybuffer"?A=i.transformTo("uint8array",A):k==="string"&&(N?A=o.decode(A):y&&_!==!0&&(A=(function(P){return u(P,s.uint8array?new Uint8Array(P.length):new Array(P.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"),d=n("./support");function u(h){this.files=[],this.loadOptions=h}u.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=d.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=u},{"./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"),d=n("./utf8"),u=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 u)if(Object.prototype.hasOwnProperty.call(u,y)&&u[y].magic===g)return u[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=d.utf8decode(this.fileName),this.fileCommentStr=d.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:d.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:d.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"),d=n("./compressedObject"),u=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 u("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 d&&this._data.compression.magic===x.magic)return this._data.getCompressedWorker();var g=this._decompressWorker();return this._dataBinary||(g=g.pipe(new c.Utf8EncodeWorker)),d.createWorkerFrom(g,x,v)},_decompressWorker:function(){return this._data instanceof d?this._data.getContentWorker():this._data instanceof u?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 d=0,u=new c(x),h=s.document.createTextNode("");u.observe(h,{characterData:!0}),o=function(){h.data=d=++d%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 Qw<"u"?Qw:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(n,r,i){var s=n("immediate");function o(){}var l={},c=["REJECTED"],d=["FULFILLED"],u=["PENDING"];function h(y){if(typeof y!="function")throw new TypeError("resolver must be a function");this.state=u,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(k){return l.reject(y,k)}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(C){N||(N=!0,l.reject(y,C))}function k(C){N||(N=!0,l.resolve(y,C))}var P=g(function(){_(k,A)});P.status==="error"&&A(P.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===d||typeof _!="function"&&this.state===c)return this;var N=new this.constructor(o);return this.state!==u?p(N,this.state===d?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=d,y.outcome=_;for(var k=-1,P=y.queue.length;++k<P;)y.queue[k].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 k=new Array(N),P=0,C=-1,j=new this(o);++C<N;)M(y[C],C);return j;function M(E,B){_.resolve(E).then(function(L){k[B]=L,++P!==N||A||(A=!0,l.resolve(j,k))},function(L){A||(A=!0,l.reject(j,L))})}},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 k=-1,P=new this(o);++k<N;)C=y[k],_.resolve(C).then(function(j){A||(A=!0,l.resolve(P,j))},function(j){A||(A=!0,l.reject(P,j))});var C;return P}},{immediate:36}],38:[function(n,r,i){var s={};(0,n("./lib/utils/common").assign)(s,n("./lib/deflate"),n("./lib/inflate"),n("./lib/zlib/constants")),r.exports=s},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(n,r,i){var s=n("./zlib/deflate"),o=n("./utils/common"),l=n("./utils/strings"),c=n("./zlib/messages"),d=n("./zlib/zstream"),u=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 d,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):u.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,k=this.strm,P=this.options.chunkSize;if(this.ended)return!1;A=_===~~_?_:_===!0?4:0,typeof y=="string"?k.input=l.string2buf(y):u.call(y)==="[object ArrayBuffer]"?k.input=new Uint8Array(y):k.input=y,k.next_in=0,k.avail_in=k.input.length;do{if(k.avail_out===0&&(k.output=new o.Buf8(P),k.next_out=0,k.avail_out=P),(N=s.deflate(k,A))!==1&&N!==h)return this.onEnd(N),!(this.ended=!0);k.avail_out!==0&&(k.avail_in!==0||A!==4&&A!==2)||(this.options.to==="string"?this.onData(l.buf2binstring(o.shrinkBuf(k.output,k.next_out))):this.onData(o.shrinkBuf(k.output,k.next_out)))}while((0<k.avail_in||k.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),!(k.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"),d=n("./zlib/messages"),u=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 u,this.strm.avail_out=0;var y=s.inflateInit2(this.strm,g.windowBits);if(y!==c.Z_OK)throw new Error(d[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||d[y.err];return y.result}p.prototype.push=function(v,g){var y,_,N,A,k,P,C=this.strm,j=this.options.chunkSize,M=this.options.dictionary,E=!1;if(this.ended)return!1;_=g===~~g?g:g===!0?c.Z_FINISH:c.Z_NO_FLUSH,typeof v=="string"?C.input=l.binstring2buf(v):f.call(v)==="[object ArrayBuffer]"?C.input=new Uint8Array(v):C.input=v,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),(y=s.inflate(C,c.Z_NO_FLUSH))===c.Z_NEED_DICT&&M&&(P=typeof M=="string"?l.string2buf(M):f.call(M)==="[object ArrayBuffer]"?new Uint8Array(M):M,y=s.inflateSetDictionary(this.strm,P)),y===c.Z_BUF_ERROR&&E===!0&&(y=c.Z_OK,E=!1),y!==c.Z_STREAM_END&&y!==c.Z_OK)return this.onEnd(y),!(this.ended=!0);C.next_out&&(C.avail_out!==0&&y!==c.Z_STREAM_END&&(C.avail_in!==0||_!==c.Z_FINISH&&_!==c.Z_SYNC_FLUSH)||(this.options.to==="string"?(N=l.utf8border(C.output,C.next_out),A=C.next_out-N,k=l.buf2string(C.output,N),C.next_out=A,C.avail_out=j-A,A&&o.arraySet(C.output,C.output,N,A,0),this.onData(k)):this.onData(o.shrinkBuf(C.output,C.next_out)))),C.avail_in===0&&C.avail_out===0&&(E=!0)}while((0<C.avail_in||C.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),!(C.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 d=Array.prototype.slice.call(arguments,1);d.length;){var u=d.shift();if(u){if(typeof u!="object")throw new TypeError(u+"must be non-object");for(var h in u)u.hasOwnProperty(h)&&(c[h]=u[h])}}return c},i.shrinkBuf=function(c,d){return c.length===d?c:c.subarray?c.subarray(0,d):(c.length=d,c)};var o={arraySet:function(c,d,u,h,f){if(d.subarray&&c.subarray)c.set(d.subarray(u,u+h),f);else for(var p=0;p<h;p++)c[f+p]=d[u+p]},flattenChunks:function(c){var d,u,h,f,p,x;for(d=h=0,u=c.length;d<u;d++)h+=c[d].length;for(x=new Uint8Array(h),d=f=0,u=c.length;d<u;d++)p=c[d],x.set(p,f),f+=p.length;return x}},l={arraySet:function(c,d,u,h,f){for(var p=0;p<h;p++)c[f+p]=d[u+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),d=0;d<256;d++)c[d]=252<=d?6:248<=d?5:240<=d?4:224<=d?3:192<=d?2:1;function u(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 u(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 u(_,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 d=65535&s|0,u=s>>>16&65535|0,h=0;l!==0;){for(l-=h=2e3<l?2e3:l;u=u+(d=d+o[c++]|0)|0,--h;);d%=65521,u%=65521}return d|u<<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 d=0;d<8;d++)o=1&o?3988292384^o>>>1:o>>>1;l[c]=o}return l})();r.exports=function(o,l,c,d){var u=s,h=d+c;o^=-1;for(var f=d;f<h;f++)o=o>>>8^u[255&(o^l[f])];return-1^o}},{}],46:[function(n,r,i){var s,o=n("../utils/common"),l=n("./trees"),c=n("./adler32"),d=n("./crc32"),u=n("./messages"),h=0,f=4,p=0,x=-2,v=-1,g=4,y=2,_=8,N=9,A=286,k=30,P=19,C=2*A+1,j=15,M=3,E=258,B=E+M+1,L=42,U=113,D=1,$=2,q=3,z=4;function W(V,K){return V.msg=u[K],K}function Q(V){return(V<<1)-(4<V?9:0)}function te(V){for(var K=V.length;0<=--K;)V[K]=0}function H(V){var K=V.state,fe=K.pending;fe>V.avail_out&&(fe=V.avail_out),fe!==0&&(o.arraySet(V.output,K.pending_buf,K.pending_out,fe,V.next_out),V.next_out+=fe,K.pending_out+=fe,V.total_out+=fe,V.avail_out-=fe,K.pending-=fe,K.pending===0&&(K.pending_out=0))}function X(V,K){l._tr_flush_block(V,0<=V.block_start?V.block_start:-1,V.strstart-V.block_start,K),V.block_start=V.strstart,H(V.strm)}function Z(V,K){V.pending_buf[V.pending++]=K}function ee(V,K){V.pending_buf[V.pending++]=K>>>8&255,V.pending_buf[V.pending++]=255&K}function Se(V,K){var fe,Y,re=V.max_chain_length,ue=V.strstart,Fe=V.prev_length,Pe=V.nice_match,be=V.strstart>V.w_size-B?V.strstart-(V.w_size-B):0,O=V.window,R=V.w_mask,G=V.prev,de=V.strstart+E,ge=O[ue+Fe-1],ae=O[ue+Fe];V.prev_length>=V.good_match&&(re>>=2),Pe>V.lookahead&&(Pe=V.lookahead);do if(O[(fe=K)+Fe]===ae&&O[fe+Fe-1]===ge&&O[fe]===O[ue]&&O[++fe]===O[ue+1]){ue+=2,fe++;do;while(O[++ue]===O[++fe]&&O[++ue]===O[++fe]&&O[++ue]===O[++fe]&&O[++ue]===O[++fe]&&O[++ue]===O[++fe]&&O[++ue]===O[++fe]&&O[++ue]===O[++fe]&&O[++ue]===O[++fe]&&ue<de);if(Y=E-(de-ue),ue=de-E,Fe<Y){if(V.match_start=K,Pe<=(Fe=Y))break;ge=O[ue+Fe-1],ae=O[ue+Fe]}}while((K=G[K&R])>be&&--re!=0);return Fe<=V.lookahead?Fe:V.lookahead}function oe(V){var K,fe,Y,re,ue,Fe,Pe,be,O,R,G=V.w_size;do{if(re=V.window_size-V.lookahead-V.strstart,V.strstart>=G+(G-B)){for(o.arraySet(V.window,V.window,G,G,0),V.match_start-=G,V.strstart-=G,V.block_start-=G,K=fe=V.hash_size;Y=V.head[--K],V.head[K]=G<=Y?Y-G:0,--fe;);for(K=fe=G;Y=V.prev[--K],V.prev[K]=G<=Y?Y-G:0,--fe;);re+=G}if(V.strm.avail_in===0)break;if(Fe=V.strm,Pe=V.window,be=V.strstart+V.lookahead,O=re,R=void 0,R=Fe.avail_in,O<R&&(R=O),fe=R===0?0:(Fe.avail_in-=R,o.arraySet(Pe,Fe.input,Fe.next_in,R,be),Fe.state.wrap===1?Fe.adler=c(Fe.adler,Pe,R,be):Fe.state.wrap===2&&(Fe.adler=d(Fe.adler,Pe,R,be)),Fe.next_in+=R,Fe.total_in+=R,R),V.lookahead+=fe,V.lookahead+V.insert>=M)for(ue=V.strstart-V.insert,V.ins_h=V.window[ue],V.ins_h=(V.ins_h<<V.hash_shift^V.window[ue+1])&V.hash_mask;V.insert&&(V.ins_h=(V.ins_h<<V.hash_shift^V.window[ue+M-1])&V.hash_mask,V.prev[ue&V.w_mask]=V.head[V.ins_h],V.head[V.ins_h]=ue,ue++,V.insert--,!(V.lookahead+V.insert<M)););}while(V.lookahead<B&&V.strm.avail_in!==0)}function ie(V,K){for(var fe,Y;;){if(V.lookahead<B){if(oe(V),V.lookahead<B&&K===h)return D;if(V.lookahead===0)break}if(fe=0,V.lookahead>=M&&(V.ins_h=(V.ins_h<<V.hash_shift^V.window[V.strstart+M-1])&V.hash_mask,fe=V.prev[V.strstart&V.w_mask]=V.head[V.ins_h],V.head[V.ins_h]=V.strstart),fe!==0&&V.strstart-fe<=V.w_size-B&&(V.match_length=Se(V,fe)),V.match_length>=M)if(Y=l._tr_tally(V,V.strstart-V.match_start,V.match_length-M),V.lookahead-=V.match_length,V.match_length<=V.max_lazy_match&&V.lookahead>=M){for(V.match_length--;V.strstart++,V.ins_h=(V.ins_h<<V.hash_shift^V.window[V.strstart+M-1])&V.hash_mask,fe=V.prev[V.strstart&V.w_mask]=V.head[V.ins_h],V.head[V.ins_h]=V.strstart,--V.match_length!=0;);V.strstart++}else V.strstart+=V.match_length,V.match_length=0,V.ins_h=V.window[V.strstart],V.ins_h=(V.ins_h<<V.hash_shift^V.window[V.strstart+1])&V.hash_mask;else Y=l._tr_tally(V,0,V.window[V.strstart]),V.lookahead--,V.strstart++;if(Y&&(X(V,!1),V.strm.avail_out===0))return D}return V.insert=V.strstart<M-1?V.strstart:M-1,K===f?(X(V,!0),V.strm.avail_out===0?q:z):V.last_lit&&(X(V,!1),V.strm.avail_out===0)?D:$}function me(V,K){for(var fe,Y,re;;){if(V.lookahead<B){if(oe(V),V.lookahead<B&&K===h)return D;if(V.lookahead===0)break}if(fe=0,V.lookahead>=M&&(V.ins_h=(V.ins_h<<V.hash_shift^V.window[V.strstart+M-1])&V.hash_mask,fe=V.prev[V.strstart&V.w_mask]=V.head[V.ins_h],V.head[V.ins_h]=V.strstart),V.prev_length=V.match_length,V.prev_match=V.match_start,V.match_length=M-1,fe!==0&&V.prev_length<V.max_lazy_match&&V.strstart-fe<=V.w_size-B&&(V.match_length=Se(V,fe),V.match_length<=5&&(V.strategy===1||V.match_length===M&&4096<V.strstart-V.match_start)&&(V.match_length=M-1)),V.prev_length>=M&&V.match_length<=V.prev_length){for(re=V.strstart+V.lookahead-M,Y=l._tr_tally(V,V.strstart-1-V.prev_match,V.prev_length-M),V.lookahead-=V.prev_length-1,V.prev_length-=2;++V.strstart<=re&&(V.ins_h=(V.ins_h<<V.hash_shift^V.window[V.strstart+M-1])&V.hash_mask,fe=V.prev[V.strstart&V.w_mask]=V.head[V.ins_h],V.head[V.ins_h]=V.strstart),--V.prev_length!=0;);if(V.match_available=0,V.match_length=M-1,V.strstart++,Y&&(X(V,!1),V.strm.avail_out===0))return D}else if(V.match_available){if((Y=l._tr_tally(V,0,V.window[V.strstart-1]))&&X(V,!1),V.strstart++,V.lookahead--,V.strm.avail_out===0)return D}else V.match_available=1,V.strstart++,V.lookahead--}return V.match_available&&(Y=l._tr_tally(V,0,V.window[V.strstart-1]),V.match_available=0),V.insert=V.strstart<M-1?V.strstart:M-1,K===f?(X(V,!0),V.strm.avail_out===0?q:z):V.last_lit&&(X(V,!1),V.strm.avail_out===0)?D:$}function se(V,K,fe,Y,re){this.good_length=V,this.max_lazy=K,this.nice_length=fe,this.max_chain=Y,this.func=re}function ce(){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*C),this.dyn_dtree=new o.Buf16(2*(2*k+1)),this.bl_tree=new o.Buf16(2*(2*P+1)),te(this.dyn_ltree),te(this.dyn_dtree),te(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new o.Buf16(j+1),this.heap=new o.Buf16(2*A+1),te(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new o.Buf16(2*A+1),te(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 Ce(V){var K;return V&&V.state?(V.total_in=V.total_out=0,V.data_type=y,(K=V.state).pending=0,K.pending_out=0,K.wrap<0&&(K.wrap=-K.wrap),K.status=K.wrap?L:U,V.adler=K.wrap===2?0:1,K.last_flush=h,l._tr_init(K),p):W(V,x)}function le(V){var K=Ce(V);return K===p&&(function(fe){fe.window_size=2*fe.w_size,te(fe.head),fe.max_lazy_match=s[fe.level].max_lazy,fe.good_match=s[fe.level].good_length,fe.nice_match=s[fe.level].nice_length,fe.max_chain_length=s[fe.level].max_chain,fe.strstart=0,fe.block_start=0,fe.lookahead=0,fe.insert=0,fe.match_length=fe.prev_length=M-1,fe.match_available=0,fe.ins_h=0})(V.state),K}function Le(V,K,fe,Y,re,ue){if(!V)return x;var Fe=1;if(K===v&&(K=6),Y<0?(Fe=0,Y=-Y):15<Y&&(Fe=2,Y-=16),re<1||N<re||fe!==_||Y<8||15<Y||K<0||9<K||ue<0||g<ue)return W(V,x);Y===8&&(Y=9);var Pe=new ce;return(V.state=Pe).strm=V,Pe.wrap=Fe,Pe.gzhead=null,Pe.w_bits=Y,Pe.w_size=1<<Pe.w_bits,Pe.w_mask=Pe.w_size-1,Pe.hash_bits=re+7,Pe.hash_size=1<<Pe.hash_bits,Pe.hash_mask=Pe.hash_size-1,Pe.hash_shift=~~((Pe.hash_bits+M-1)/M),Pe.window=new o.Buf8(2*Pe.w_size),Pe.head=new o.Buf16(Pe.hash_size),Pe.prev=new o.Buf16(Pe.w_size),Pe.lit_bufsize=1<<re+6,Pe.pending_buf_size=4*Pe.lit_bufsize,Pe.pending_buf=new o.Buf8(Pe.pending_buf_size),Pe.d_buf=1*Pe.lit_bufsize,Pe.l_buf=3*Pe.lit_bufsize,Pe.level=K,Pe.strategy=ue,Pe.method=fe,le(V)}s=[new se(0,0,0,0,function(V,K){var fe=65535;for(fe>V.pending_buf_size-5&&(fe=V.pending_buf_size-5);;){if(V.lookahead<=1){if(oe(V),V.lookahead===0&&K===h)return D;if(V.lookahead===0)break}V.strstart+=V.lookahead,V.lookahead=0;var Y=V.block_start+fe;if((V.strstart===0||V.strstart>=Y)&&(V.lookahead=V.strstart-Y,V.strstart=Y,X(V,!1),V.strm.avail_out===0)||V.strstart-V.block_start>=V.w_size-B&&(X(V,!1),V.strm.avail_out===0))return D}return V.insert=0,K===f?(X(V,!0),V.strm.avail_out===0?q:z):(V.strstart>V.block_start&&(X(V,!1),V.strm.avail_out),D)}),new se(4,4,8,4,ie),new se(4,5,16,8,ie),new se(4,6,32,32,ie),new se(4,4,16,16,me),new se(8,16,32,32,me),new se(8,16,128,128,me),new se(8,32,128,256,me),new se(32,128,258,1024,me),new se(32,258,258,4096,me)],i.deflateInit=function(V,K){return Le(V,K,_,15,8,0)},i.deflateInit2=Le,i.deflateReset=le,i.deflateResetKeep=Ce,i.deflateSetHeader=function(V,K){return V&&V.state?V.state.wrap!==2?x:(V.state.gzhead=K,p):x},i.deflate=function(V,K){var fe,Y,re,ue;if(!V||!V.state||5<K||K<0)return V?W(V,x):x;if(Y=V.state,!V.output||!V.input&&V.avail_in!==0||Y.status===666&&K!==f)return W(V,V.avail_out===0?-5:x);if(Y.strm=V,fe=Y.last_flush,Y.last_flush=K,Y.status===L)if(Y.wrap===2)V.adler=0,Z(Y,31),Z(Y,139),Z(Y,8),Y.gzhead?(Z(Y,(Y.gzhead.text?1:0)+(Y.gzhead.hcrc?2:0)+(Y.gzhead.extra?4:0)+(Y.gzhead.name?8:0)+(Y.gzhead.comment?16:0)),Z(Y,255&Y.gzhead.time),Z(Y,Y.gzhead.time>>8&255),Z(Y,Y.gzhead.time>>16&255),Z(Y,Y.gzhead.time>>24&255),Z(Y,Y.level===9?2:2<=Y.strategy||Y.level<2?4:0),Z(Y,255&Y.gzhead.os),Y.gzhead.extra&&Y.gzhead.extra.length&&(Z(Y,255&Y.gzhead.extra.length),Z(Y,Y.gzhead.extra.length>>8&255)),Y.gzhead.hcrc&&(V.adler=d(V.adler,Y.pending_buf,Y.pending,0)),Y.gzindex=0,Y.status=69):(Z(Y,0),Z(Y,0),Z(Y,0),Z(Y,0),Z(Y,0),Z(Y,Y.level===9?2:2<=Y.strategy||Y.level<2?4:0),Z(Y,3),Y.status=U);else{var Fe=_+(Y.w_bits-8<<4)<<8;Fe|=(2<=Y.strategy||Y.level<2?0:Y.level<6?1:Y.level===6?2:3)<<6,Y.strstart!==0&&(Fe|=32),Fe+=31-Fe%31,Y.status=U,ee(Y,Fe),Y.strstart!==0&&(ee(Y,V.adler>>>16),ee(Y,65535&V.adler)),V.adler=1}if(Y.status===69)if(Y.gzhead.extra){for(re=Y.pending;Y.gzindex<(65535&Y.gzhead.extra.length)&&(Y.pending!==Y.pending_buf_size||(Y.gzhead.hcrc&&Y.pending>re&&(V.adler=d(V.adler,Y.pending_buf,Y.pending-re,re)),H(V),re=Y.pending,Y.pending!==Y.pending_buf_size));)Z(Y,255&Y.gzhead.extra[Y.gzindex]),Y.gzindex++;Y.gzhead.hcrc&&Y.pending>re&&(V.adler=d(V.adler,Y.pending_buf,Y.pending-re,re)),Y.gzindex===Y.gzhead.extra.length&&(Y.gzindex=0,Y.status=73)}else Y.status=73;if(Y.status===73)if(Y.gzhead.name){re=Y.pending;do{if(Y.pending===Y.pending_buf_size&&(Y.gzhead.hcrc&&Y.pending>re&&(V.adler=d(V.adler,Y.pending_buf,Y.pending-re,re)),H(V),re=Y.pending,Y.pending===Y.pending_buf_size)){ue=1;break}ue=Y.gzindex<Y.gzhead.name.length?255&Y.gzhead.name.charCodeAt(Y.gzindex++):0,Z(Y,ue)}while(ue!==0);Y.gzhead.hcrc&&Y.pending>re&&(V.adler=d(V.adler,Y.pending_buf,Y.pending-re,re)),ue===0&&(Y.gzindex=0,Y.status=91)}else Y.status=91;if(Y.status===91)if(Y.gzhead.comment){re=Y.pending;do{if(Y.pending===Y.pending_buf_size&&(Y.gzhead.hcrc&&Y.pending>re&&(V.adler=d(V.adler,Y.pending_buf,Y.pending-re,re)),H(V),re=Y.pending,Y.pending===Y.pending_buf_size)){ue=1;break}ue=Y.gzindex<Y.gzhead.comment.length?255&Y.gzhead.comment.charCodeAt(Y.gzindex++):0,Z(Y,ue)}while(ue!==0);Y.gzhead.hcrc&&Y.pending>re&&(V.adler=d(V.adler,Y.pending_buf,Y.pending-re,re)),ue===0&&(Y.status=103)}else Y.status=103;if(Y.status===103&&(Y.gzhead.hcrc?(Y.pending+2>Y.pending_buf_size&&H(V),Y.pending+2<=Y.pending_buf_size&&(Z(Y,255&V.adler),Z(Y,V.adler>>8&255),V.adler=0,Y.status=U)):Y.status=U),Y.pending!==0){if(H(V),V.avail_out===0)return Y.last_flush=-1,p}else if(V.avail_in===0&&Q(K)<=Q(fe)&&K!==f)return W(V,-5);if(Y.status===666&&V.avail_in!==0)return W(V,-5);if(V.avail_in!==0||Y.lookahead!==0||K!==h&&Y.status!==666){var Pe=Y.strategy===2?(function(be,O){for(var R;;){if(be.lookahead===0&&(oe(be),be.lookahead===0)){if(O===h)return D;break}if(be.match_length=0,R=l._tr_tally(be,0,be.window[be.strstart]),be.lookahead--,be.strstart++,R&&(X(be,!1),be.strm.avail_out===0))return D}return be.insert=0,O===f?(X(be,!0),be.strm.avail_out===0?q:z):be.last_lit&&(X(be,!1),be.strm.avail_out===0)?D:$})(Y,K):Y.strategy===3?(function(be,O){for(var R,G,de,ge,ae=be.window;;){if(be.lookahead<=E){if(oe(be),be.lookahead<=E&&O===h)return D;if(be.lookahead===0)break}if(be.match_length=0,be.lookahead>=M&&0<be.strstart&&(G=ae[de=be.strstart-1])===ae[++de]&&G===ae[++de]&&G===ae[++de]){ge=be.strstart+E;do;while(G===ae[++de]&&G===ae[++de]&&G===ae[++de]&&G===ae[++de]&&G===ae[++de]&&G===ae[++de]&&G===ae[++de]&&G===ae[++de]&&de<ge);be.match_length=E-(ge-de),be.match_length>be.lookahead&&(be.match_length=be.lookahead)}if(be.match_length>=M?(R=l._tr_tally(be,1,be.match_length-M),be.lookahead-=be.match_length,be.strstart+=be.match_length,be.match_length=0):(R=l._tr_tally(be,0,be.window[be.strstart]),be.lookahead--,be.strstart++),R&&(X(be,!1),be.strm.avail_out===0))return D}return be.insert=0,O===f?(X(be,!0),be.strm.avail_out===0?q:z):be.last_lit&&(X(be,!1),be.strm.avail_out===0)?D:$})(Y,K):s[Y.level].func(Y,K);if(Pe!==q&&Pe!==z||(Y.status=666),Pe===D||Pe===q)return V.avail_out===0&&(Y.last_flush=-1),p;if(Pe===$&&(K===1?l._tr_align(Y):K!==5&&(l._tr_stored_block(Y,0,0,!1),K===3&&(te(Y.head),Y.lookahead===0&&(Y.strstart=0,Y.block_start=0,Y.insert=0))),H(V),V.avail_out===0))return Y.last_flush=-1,p}return K!==f?p:Y.wrap<=0?1:(Y.wrap===2?(Z(Y,255&V.adler),Z(Y,V.adler>>8&255),Z(Y,V.adler>>16&255),Z(Y,V.adler>>24&255),Z(Y,255&V.total_in),Z(Y,V.total_in>>8&255),Z(Y,V.total_in>>16&255),Z(Y,V.total_in>>24&255)):(ee(Y,V.adler>>>16),ee(Y,65535&V.adler)),H(V),0<Y.wrap&&(Y.wrap=-Y.wrap),Y.pending!==0?p:1)},i.deflateEnd=function(V){var K;return V&&V.state?(K=V.state.status)!==L&&K!==69&&K!==73&&K!==91&&K!==103&&K!==U&&K!==666?W(V,x):(V.state=null,K===U?W(V,-3):p):x},i.deflateSetDictionary=function(V,K){var fe,Y,re,ue,Fe,Pe,be,O,R=K.length;if(!V||!V.state||(ue=(fe=V.state).wrap)===2||ue===1&&fe.status!==L||fe.lookahead)return x;for(ue===1&&(V.adler=c(V.adler,K,R,0)),fe.wrap=0,R>=fe.w_size&&(ue===0&&(te(fe.head),fe.strstart=0,fe.block_start=0,fe.insert=0),O=new o.Buf8(fe.w_size),o.arraySet(O,K,R-fe.w_size,fe.w_size,0),K=O,R=fe.w_size),Fe=V.avail_in,Pe=V.next_in,be=V.input,V.avail_in=R,V.next_in=0,V.input=K,oe(fe);fe.lookahead>=M;){for(Y=fe.strstart,re=fe.lookahead-(M-1);fe.ins_h=(fe.ins_h<<fe.hash_shift^fe.window[Y+M-1])&fe.hash_mask,fe.prev[Y&fe.w_mask]=fe.head[fe.ins_h],fe.head[fe.ins_h]=Y,Y++,--re;);fe.strstart=Y,fe.lookahead=M-1,oe(fe)}return fe.strstart+=fe.lookahead,fe.block_start=fe.strstart,fe.insert=fe.lookahead,fe.lookahead=0,fe.match_length=fe.prev_length=M-1,fe.match_available=0,V.next_in=Pe,V.input=be,V.avail_in=Fe,fe.wrap=ue,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,d,u,h,f,p,x,v,g,y,_,N,A,k,P,C,j,M,E,B,L,U,D,$;l=s.state,c=s.next_in,D=s.input,d=c+(s.avail_in-5),u=s.next_out,$=s.output,h=u-(o-s.avail_out),f=u+(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,k=l.distcode,P=(1<<l.lenbits)-1,C=(1<<l.distbits)-1;e:do{N<15&&(_+=D[c++]<<N,N+=8,_+=D[c++]<<N,N+=8),j=A[_&P];t:for(;;){if(_>>>=M=j>>>24,N-=M,(M=j>>>16&255)===0)$[u++]=65535&j;else{if(!(16&M)){if((64&M)==0){j=A[(65535&j)+(_&(1<<M)-1)];continue t}if(32&M){l.mode=12;break e}s.msg="invalid literal/length code",l.mode=30;break e}E=65535&j,(M&=15)&&(N<M&&(_+=D[c++]<<N,N+=8),E+=_&(1<<M)-1,_>>>=M,N-=M),N<15&&(_+=D[c++]<<N,N+=8,_+=D[c++]<<N,N+=8),j=k[_&C];n:for(;;){if(_>>>=M=j>>>24,N-=M,!(16&(M=j>>>16&255))){if((64&M)==0){j=k[(65535&j)+(_&(1<<M)-1)];continue n}s.msg="invalid distance code",l.mode=30;break e}if(B=65535&j,N<(M&=15)&&(_+=D[c++]<<N,(N+=8)<M&&(_+=D[c++]<<N,N+=8)),p<(B+=_&(1<<M)-1)){s.msg="invalid distance too far back",l.mode=30;break e}if(_>>>=M,N-=M,(M=u-h)<B){if(v<(M=B-M)&&l.sane){s.msg="invalid distance too far back",l.mode=30;break e}if(U=y,(L=0)===g){if(L+=x-M,M<E){for(E-=M;$[u++]=y[L++],--M;);L=u-B,U=$}}else if(g<M){if(L+=x+g-M,(M-=g)<E){for(E-=M;$[u++]=y[L++],--M;);if(L=0,g<E){for(E-=M=g;$[u++]=y[L++],--M;);L=u-B,U=$}}}else if(L+=g-M,M<E){for(E-=M;$[u++]=y[L++],--M;);L=u-B,U=$}for(;2<E;)$[u++]=U[L++],$[u++]=U[L++],$[u++]=U[L++],E-=3;E&&($[u++]=U[L++],1<E&&($[u++]=U[L++]))}else{for(L=u-B;$[u++]=$[L++],$[u++]=$[L++],$[u++]=$[L++],2<(E-=3););E&&($[u++]=$[L++],1<E&&($[u++]=$[L++]))}break}}break}}while(c<d&&u<f);c-=E=N>>3,_&=(1<<(N-=E<<3))-1,s.next_in=c,s.next_out=u,s.avail_in=c<d?d-c+5:5-(c-d),s.avail_out=u<f?f-u+257:257-(u-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"),d=n("./inftrees"),u=1,h=2,f=0,p=-2,x=1,v=852,g=592;function y(L){return(L>>>24&255)+(L>>>8&65280)+((65280&L)<<8)+((255&L)<<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(L){var U;return L&&L.state?(U=L.state,L.total_in=L.total_out=U.total=0,L.msg="",U.wrap&&(L.adler=1&U.wrap),U.mode=x,U.last=0,U.havedict=0,U.dmax=32768,U.head=null,U.hold=0,U.bits=0,U.lencode=U.lendyn=new s.Buf32(v),U.distcode=U.distdyn=new s.Buf32(g),U.sane=1,U.back=-1,f):p}function A(L){var U;return L&&L.state?((U=L.state).wsize=0,U.whave=0,U.wnext=0,N(L)):p}function k(L,U){var D,$;return L&&L.state?($=L.state,U<0?(D=0,U=-U):(D=1+(U>>4),U<48&&(U&=15)),U&&(U<8||15<U)?p:($.window!==null&&$.wbits!==U&&($.window=null),$.wrap=D,$.wbits=U,A(L))):p}function P(L,U){var D,$;return L?($=new _,(L.state=$).window=null,(D=k(L,U))!==f&&(L.state=null),D):p}var C,j,M=!0;function E(L){if(M){var U;for(C=new s.Buf32(512),j=new s.Buf32(32),U=0;U<144;)L.lens[U++]=8;for(;U<256;)L.lens[U++]=9;for(;U<280;)L.lens[U++]=7;for(;U<288;)L.lens[U++]=8;for(d(u,L.lens,0,288,C,0,L.work,{bits:9}),U=0;U<32;)L.lens[U++]=5;d(h,L.lens,0,32,j,0,L.work,{bits:5}),M=!1}L.lencode=C,L.lenbits=9,L.distcode=j,L.distbits=5}function B(L,U,D,$){var q,z=L.state;return z.window===null&&(z.wsize=1<<z.wbits,z.wnext=0,z.whave=0,z.window=new s.Buf8(z.wsize)),$>=z.wsize?(s.arraySet(z.window,U,D-z.wsize,z.wsize,0),z.wnext=0,z.whave=z.wsize):($<(q=z.wsize-z.wnext)&&(q=$),s.arraySet(z.window,U,D-$,q,z.wnext),($-=q)?(s.arraySet(z.window,U,D-$,$,0),z.wnext=$,z.whave=z.wsize):(z.wnext+=q,z.wnext===z.wsize&&(z.wnext=0),z.whave<z.wsize&&(z.whave+=q))),0}i.inflateReset=A,i.inflateReset2=k,i.inflateResetKeep=N,i.inflateInit=function(L){return P(L,15)},i.inflateInit2=P,i.inflate=function(L,U){var D,$,q,z,W,Q,te,H,X,Z,ee,Se,oe,ie,me,se,ce,Ce,le,Le,V,K,fe,Y,re=0,ue=new s.Buf8(4),Fe=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!L||!L.state||!L.output||!L.input&&L.avail_in!==0)return p;(D=L.state).mode===12&&(D.mode=13),W=L.next_out,q=L.output,te=L.avail_out,z=L.next_in,$=L.input,Q=L.avail_in,H=D.hold,X=D.bits,Z=Q,ee=te,K=f;e:for(;;)switch(D.mode){case x:if(D.wrap===0){D.mode=13;break}for(;X<16;){if(Q===0)break e;Q--,H+=$[z++]<<X,X+=8}if(2&D.wrap&&H===35615){ue[D.check=0]=255&H,ue[1]=H>>>8&255,D.check=l(D.check,ue,2,0),X=H=0,D.mode=2;break}if(D.flags=0,D.head&&(D.head.done=!1),!(1&D.wrap)||(((255&H)<<8)+(H>>8))%31){L.msg="incorrect header check",D.mode=30;break}if((15&H)!=8){L.msg="unknown compression method",D.mode=30;break}if(X-=4,V=8+(15&(H>>>=4)),D.wbits===0)D.wbits=V;else if(V>D.wbits){L.msg="invalid window size",D.mode=30;break}D.dmax=1<<V,L.adler=D.check=1,D.mode=512&H?10:12,X=H=0;break;case 2:for(;X<16;){if(Q===0)break e;Q--,H+=$[z++]<<X,X+=8}if(D.flags=H,(255&D.flags)!=8){L.msg="unknown compression method",D.mode=30;break}if(57344&D.flags){L.msg="unknown header flags set",D.mode=30;break}D.head&&(D.head.text=H>>8&1),512&D.flags&&(ue[0]=255&H,ue[1]=H>>>8&255,D.check=l(D.check,ue,2,0)),X=H=0,D.mode=3;case 3:for(;X<32;){if(Q===0)break e;Q--,H+=$[z++]<<X,X+=8}D.head&&(D.head.time=H),512&D.flags&&(ue[0]=255&H,ue[1]=H>>>8&255,ue[2]=H>>>16&255,ue[3]=H>>>24&255,D.check=l(D.check,ue,4,0)),X=H=0,D.mode=4;case 4:for(;X<16;){if(Q===0)break e;Q--,H+=$[z++]<<X,X+=8}D.head&&(D.head.xflags=255&H,D.head.os=H>>8),512&D.flags&&(ue[0]=255&H,ue[1]=H>>>8&255,D.check=l(D.check,ue,2,0)),X=H=0,D.mode=5;case 5:if(1024&D.flags){for(;X<16;){if(Q===0)break e;Q--,H+=$[z++]<<X,X+=8}D.length=H,D.head&&(D.head.extra_len=H),512&D.flags&&(ue[0]=255&H,ue[1]=H>>>8&255,D.check=l(D.check,ue,2,0)),X=H=0}else D.head&&(D.head.extra=null);D.mode=6;case 6:if(1024&D.flags&&(Q<(Se=D.length)&&(Se=Q),Se&&(D.head&&(V=D.head.extra_len-D.length,D.head.extra||(D.head.extra=new Array(D.head.extra_len)),s.arraySet(D.head.extra,$,z,Se,V)),512&D.flags&&(D.check=l(D.check,$,Se,z)),Q-=Se,z+=Se,D.length-=Se),D.length))break e;D.length=0,D.mode=7;case 7:if(2048&D.flags){if(Q===0)break e;for(Se=0;V=$[z+Se++],D.head&&V&&D.length<65536&&(D.head.name+=String.fromCharCode(V)),V&&Se<Q;);if(512&D.flags&&(D.check=l(D.check,$,Se,z)),Q-=Se,z+=Se,V)break e}else D.head&&(D.head.name=null);D.length=0,D.mode=8;case 8:if(4096&D.flags){if(Q===0)break e;for(Se=0;V=$[z+Se++],D.head&&V&&D.length<65536&&(D.head.comment+=String.fromCharCode(V)),V&&Se<Q;);if(512&D.flags&&(D.check=l(D.check,$,Se,z)),Q-=Se,z+=Se,V)break e}else D.head&&(D.head.comment=null);D.mode=9;case 9:if(512&D.flags){for(;X<16;){if(Q===0)break e;Q--,H+=$[z++]<<X,X+=8}if(H!==(65535&D.check)){L.msg="header crc mismatch",D.mode=30;break}X=H=0}D.head&&(D.head.hcrc=D.flags>>9&1,D.head.done=!0),L.adler=D.check=0,D.mode=12;break;case 10:for(;X<32;){if(Q===0)break e;Q--,H+=$[z++]<<X,X+=8}L.adler=D.check=y(H),X=H=0,D.mode=11;case 11:if(D.havedict===0)return L.next_out=W,L.avail_out=te,L.next_in=z,L.avail_in=Q,D.hold=H,D.bits=X,2;L.adler=D.check=1,D.mode=12;case 12:if(U===5||U===6)break e;case 13:if(D.last){H>>>=7&X,X-=7&X,D.mode=27;break}for(;X<3;){if(Q===0)break e;Q--,H+=$[z++]<<X,X+=8}switch(D.last=1&H,X-=1,3&(H>>>=1)){case 0:D.mode=14;break;case 1:if(E(D),D.mode=20,U!==6)break;H>>>=2,X-=2;break e;case 2:D.mode=17;break;case 3:L.msg="invalid block type",D.mode=30}H>>>=2,X-=2;break;case 14:for(H>>>=7&X,X-=7&X;X<32;){if(Q===0)break e;Q--,H+=$[z++]<<X,X+=8}if((65535&H)!=(H>>>16^65535)){L.msg="invalid stored block lengths",D.mode=30;break}if(D.length=65535&H,X=H=0,D.mode=15,U===6)break e;case 15:D.mode=16;case 16:if(Se=D.length){if(Q<Se&&(Se=Q),te<Se&&(Se=te),Se===0)break e;s.arraySet(q,$,z,Se,W),Q-=Se,z+=Se,te-=Se,W+=Se,D.length-=Se;break}D.mode=12;break;case 17:for(;X<14;){if(Q===0)break e;Q--,H+=$[z++]<<X,X+=8}if(D.nlen=257+(31&H),H>>>=5,X-=5,D.ndist=1+(31&H),H>>>=5,X-=5,D.ncode=4+(15&H),H>>>=4,X-=4,286<D.nlen||30<D.ndist){L.msg="too many length or distance symbols",D.mode=30;break}D.have=0,D.mode=18;case 18:for(;D.have<D.ncode;){for(;X<3;){if(Q===0)break e;Q--,H+=$[z++]<<X,X+=8}D.lens[Fe[D.have++]]=7&H,H>>>=3,X-=3}for(;D.have<19;)D.lens[Fe[D.have++]]=0;if(D.lencode=D.lendyn,D.lenbits=7,fe={bits:D.lenbits},K=d(0,D.lens,0,19,D.lencode,0,D.work,fe),D.lenbits=fe.bits,K){L.msg="invalid code lengths set",D.mode=30;break}D.have=0,D.mode=19;case 19:for(;D.have<D.nlen+D.ndist;){for(;se=(re=D.lencode[H&(1<<D.lenbits)-1])>>>16&255,ce=65535&re,!((me=re>>>24)<=X);){if(Q===0)break e;Q--,H+=$[z++]<<X,X+=8}if(ce<16)H>>>=me,X-=me,D.lens[D.have++]=ce;else{if(ce===16){for(Y=me+2;X<Y;){if(Q===0)break e;Q--,H+=$[z++]<<X,X+=8}if(H>>>=me,X-=me,D.have===0){L.msg="invalid bit length repeat",D.mode=30;break}V=D.lens[D.have-1],Se=3+(3&H),H>>>=2,X-=2}else if(ce===17){for(Y=me+3;X<Y;){if(Q===0)break e;Q--,H+=$[z++]<<X,X+=8}X-=me,V=0,Se=3+(7&(H>>>=me)),H>>>=3,X-=3}else{for(Y=me+7;X<Y;){if(Q===0)break e;Q--,H+=$[z++]<<X,X+=8}X-=me,V=0,Se=11+(127&(H>>>=me)),H>>>=7,X-=7}if(D.have+Se>D.nlen+D.ndist){L.msg="invalid bit length repeat",D.mode=30;break}for(;Se--;)D.lens[D.have++]=V}}if(D.mode===30)break;if(D.lens[256]===0){L.msg="invalid code -- missing end-of-block",D.mode=30;break}if(D.lenbits=9,fe={bits:D.lenbits},K=d(u,D.lens,0,D.nlen,D.lencode,0,D.work,fe),D.lenbits=fe.bits,K){L.msg="invalid literal/lengths set",D.mode=30;break}if(D.distbits=6,D.distcode=D.distdyn,fe={bits:D.distbits},K=d(h,D.lens,D.nlen,D.ndist,D.distcode,0,D.work,fe),D.distbits=fe.bits,K){L.msg="invalid distances set",D.mode=30;break}if(D.mode=20,U===6)break e;case 20:D.mode=21;case 21:if(6<=Q&&258<=te){L.next_out=W,L.avail_out=te,L.next_in=z,L.avail_in=Q,D.hold=H,D.bits=X,c(L,ee),W=L.next_out,q=L.output,te=L.avail_out,z=L.next_in,$=L.input,Q=L.avail_in,H=D.hold,X=D.bits,D.mode===12&&(D.back=-1);break}for(D.back=0;se=(re=D.lencode[H&(1<<D.lenbits)-1])>>>16&255,ce=65535&re,!((me=re>>>24)<=X);){if(Q===0)break e;Q--,H+=$[z++]<<X,X+=8}if(se&&(240&se)==0){for(Ce=me,le=se,Le=ce;se=(re=D.lencode[Le+((H&(1<<Ce+le)-1)>>Ce)])>>>16&255,ce=65535&re,!(Ce+(me=re>>>24)<=X);){if(Q===0)break e;Q--,H+=$[z++]<<X,X+=8}H>>>=Ce,X-=Ce,D.back+=Ce}if(H>>>=me,X-=me,D.back+=me,D.length=ce,se===0){D.mode=26;break}if(32&se){D.back=-1,D.mode=12;break}if(64&se){L.msg="invalid literal/length code",D.mode=30;break}D.extra=15&se,D.mode=22;case 22:if(D.extra){for(Y=D.extra;X<Y;){if(Q===0)break e;Q--,H+=$[z++]<<X,X+=8}D.length+=H&(1<<D.extra)-1,H>>>=D.extra,X-=D.extra,D.back+=D.extra}D.was=D.length,D.mode=23;case 23:for(;se=(re=D.distcode[H&(1<<D.distbits)-1])>>>16&255,ce=65535&re,!((me=re>>>24)<=X);){if(Q===0)break e;Q--,H+=$[z++]<<X,X+=8}if((240&se)==0){for(Ce=me,le=se,Le=ce;se=(re=D.distcode[Le+((H&(1<<Ce+le)-1)>>Ce)])>>>16&255,ce=65535&re,!(Ce+(me=re>>>24)<=X);){if(Q===0)break e;Q--,H+=$[z++]<<X,X+=8}H>>>=Ce,X-=Ce,D.back+=Ce}if(H>>>=me,X-=me,D.back+=me,64&se){L.msg="invalid distance code",D.mode=30;break}D.offset=ce,D.extra=15&se,D.mode=24;case 24:if(D.extra){for(Y=D.extra;X<Y;){if(Q===0)break e;Q--,H+=$[z++]<<X,X+=8}D.offset+=H&(1<<D.extra)-1,H>>>=D.extra,X-=D.extra,D.back+=D.extra}if(D.offset>D.dmax){L.msg="invalid distance too far back",D.mode=30;break}D.mode=25;case 25:if(te===0)break e;if(Se=ee-te,D.offset>Se){if((Se=D.offset-Se)>D.whave&&D.sane){L.msg="invalid distance too far back",D.mode=30;break}oe=Se>D.wnext?(Se-=D.wnext,D.wsize-Se):D.wnext-Se,Se>D.length&&(Se=D.length),ie=D.window}else ie=q,oe=W-D.offset,Se=D.length;for(te<Se&&(Se=te),te-=Se,D.length-=Se;q[W++]=ie[oe++],--Se;);D.length===0&&(D.mode=21);break;case 26:if(te===0)break e;q[W++]=D.length,te--,D.mode=21;break;case 27:if(D.wrap){for(;X<32;){if(Q===0)break e;Q--,H|=$[z++]<<X,X+=8}if(ee-=te,L.total_out+=ee,D.total+=ee,ee&&(L.adler=D.check=D.flags?l(D.check,q,ee,W-ee):o(D.check,q,ee,W-ee)),ee=te,(D.flags?H:y(H))!==D.check){L.msg="incorrect data check",D.mode=30;break}X=H=0}D.mode=28;case 28:if(D.wrap&&D.flags){for(;X<32;){if(Q===0)break e;Q--,H+=$[z++]<<X,X+=8}if(H!==(4294967295&D.total)){L.msg="incorrect length check",D.mode=30;break}X=H=0}D.mode=29;case 29:K=1;break e;case 30:K=-3;break e;case 31:return-4;default:return p}return L.next_out=W,L.avail_out=te,L.next_in=z,L.avail_in=Q,D.hold=H,D.bits=X,(D.wsize||ee!==L.avail_out&&D.mode<30&&(D.mode<27||U!==4))&&B(L,L.output,L.next_out,ee-L.avail_out)?(D.mode=31,-4):(Z-=L.avail_in,ee-=L.avail_out,L.total_in+=Z,L.total_out+=ee,D.total+=ee,D.wrap&&ee&&(L.adler=D.check=D.flags?l(D.check,q,ee,L.next_out-ee):o(D.check,q,ee,L.next_out-ee)),L.data_type=D.bits+(D.last?64:0)+(D.mode===12?128:0)+(D.mode===20||D.mode===15?256:0),(Z==0&&ee===0||U===4)&&K===f&&(K=-5),K)},i.inflateEnd=function(L){if(!L||!L.state)return p;var U=L.state;return U.window&&(U.window=null),L.state=null,f},i.inflateGetHeader=function(L,U){var D;return L&&L.state?(2&(D=L.state).wrap)==0?p:((D.head=U).done=!1,f):p},i.inflateSetDictionary=function(L,U){var D,$=U.length;return L&&L.state?(D=L.state).wrap!==0&&D.mode!==11?p:D.mode===11&&o(1,U,$,0)!==D.check?-3:B(L,U,$,$)?(D.mode=31,-4):(D.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],d=[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(u,h,f,p,x,v,g,y){var _,N,A,k,P,C,j,M,E,B=y.bits,L=0,U=0,D=0,$=0,q=0,z=0,W=0,Q=0,te=0,H=0,X=null,Z=0,ee=new s.Buf16(16),Se=new s.Buf16(16),oe=null,ie=0;for(L=0;L<=15;L++)ee[L]=0;for(U=0;U<p;U++)ee[h[f+U]]++;for(q=B,$=15;1<=$&&ee[$]===0;$--);if($<q&&(q=$),$===0)return x[v++]=20971520,x[v++]=20971520,y.bits=1,0;for(D=1;D<$&&ee[D]===0;D++);for(q<D&&(q=D),L=Q=1;L<=15;L++)if(Q<<=1,(Q-=ee[L])<0)return-1;if(0<Q&&(u===0||$!==1))return-1;for(Se[1]=0,L=1;L<15;L++)Se[L+1]=Se[L]+ee[L];for(U=0;U<p;U++)h[f+U]!==0&&(g[Se[h[f+U]]++]=U);if(C=u===0?(X=oe=g,19):u===1?(X=o,Z-=257,oe=l,ie-=257,256):(X=c,oe=d,-1),L=D,P=v,W=U=H=0,A=-1,k=(te=1<<(z=q))-1,u===1&&852<te||u===2&&592<te)return 1;for(;;){for(j=L-W,E=g[U]<C?(M=0,g[U]):g[U]>C?(M=oe[ie+g[U]],X[Z+g[U]]):(M=96,0),_=1<<L-W,D=N=1<<z;x[P+(H>>W)+(N-=_)]=j<<24|M<<16|E|0,N!==0;);for(_=1<<L-1;H&_;)_>>=1;if(_!==0?(H&=_-1,H+=_):H=0,U++,--ee[L]==0){if(L===$)break;L=h[f+g[U]]}if(q<L&&(H&k)!==A){for(W===0&&(W=q),P+=D,Q=1<<(z=L-W);z+W<$&&!((Q-=ee[z+W])<=0);)z++,Q<<=1;if(te+=1<<z,u===1&&852<te||u===2&&592<te)return 1;x[A=H&k]=q<<24|z<<16|P-v|0}}return H!==0&&(x[P+H]=L-W<<24|64<<16|0),y.bits=q,0}},{"../utils/common":41}],51:[function(n,r,i){r.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(n,r,i){var s=n("../utils/common"),o=0,l=1;function c(re){for(var ue=re.length;0<=--ue;)re[ue]=0}var d=0,u=29,h=256,f=h+1+u,p=30,x=19,v=2*f+1,g=15,y=16,_=7,N=256,A=16,k=17,P=18,C=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],j=[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],E=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],B=new Array(2*(f+2));c(B);var L=new Array(2*p);c(L);var U=new Array(512);c(U);var D=new Array(256);c(D);var $=new Array(u);c($);var q,z,W,Q=new Array(p);function te(re,ue,Fe,Pe,be){this.static_tree=re,this.extra_bits=ue,this.extra_base=Fe,this.elems=Pe,this.max_length=be,this.has_stree=re&&re.length}function H(re,ue){this.dyn_tree=re,this.max_code=0,this.stat_desc=ue}function X(re){return re<256?U[re]:U[256+(re>>>7)]}function Z(re,ue){re.pending_buf[re.pending++]=255&ue,re.pending_buf[re.pending++]=ue>>>8&255}function ee(re,ue,Fe){re.bi_valid>y-Fe?(re.bi_buf|=ue<<re.bi_valid&65535,Z(re,re.bi_buf),re.bi_buf=ue>>y-re.bi_valid,re.bi_valid+=Fe-y):(re.bi_buf|=ue<<re.bi_valid&65535,re.bi_valid+=Fe)}function Se(re,ue,Fe){ee(re,Fe[2*ue],Fe[2*ue+1])}function oe(re,ue){for(var Fe=0;Fe|=1&re,re>>>=1,Fe<<=1,0<--ue;);return Fe>>>1}function ie(re,ue,Fe){var Pe,be,O=new Array(g+1),R=0;for(Pe=1;Pe<=g;Pe++)O[Pe]=R=R+Fe[Pe-1]<<1;for(be=0;be<=ue;be++){var G=re[2*be+1];G!==0&&(re[2*be]=oe(O[G]++,G))}}function me(re){var ue;for(ue=0;ue<f;ue++)re.dyn_ltree[2*ue]=0;for(ue=0;ue<p;ue++)re.dyn_dtree[2*ue]=0;for(ue=0;ue<x;ue++)re.bl_tree[2*ue]=0;re.dyn_ltree[2*N]=1,re.opt_len=re.static_len=0,re.last_lit=re.matches=0}function se(re){8<re.bi_valid?Z(re,re.bi_buf):0<re.bi_valid&&(re.pending_buf[re.pending++]=re.bi_buf),re.bi_buf=0,re.bi_valid=0}function ce(re,ue,Fe,Pe){var be=2*ue,O=2*Fe;return re[be]<re[O]||re[be]===re[O]&&Pe[ue]<=Pe[Fe]}function Ce(re,ue,Fe){for(var Pe=re.heap[Fe],be=Fe<<1;be<=re.heap_len&&(be<re.heap_len&&ce(ue,re.heap[be+1],re.heap[be],re.depth)&&be++,!ce(ue,Pe,re.heap[be],re.depth));)re.heap[Fe]=re.heap[be],Fe=be,be<<=1;re.heap[Fe]=Pe}function le(re,ue,Fe){var Pe,be,O,R,G=0;if(re.last_lit!==0)for(;Pe=re.pending_buf[re.d_buf+2*G]<<8|re.pending_buf[re.d_buf+2*G+1],be=re.pending_buf[re.l_buf+G],G++,Pe===0?Se(re,be,ue):(Se(re,(O=D[be])+h+1,ue),(R=C[O])!==0&&ee(re,be-=$[O],R),Se(re,O=X(--Pe),Fe),(R=j[O])!==0&&ee(re,Pe-=Q[O],R)),G<re.last_lit;);Se(re,N,ue)}function Le(re,ue){var Fe,Pe,be,O=ue.dyn_tree,R=ue.stat_desc.static_tree,G=ue.stat_desc.has_stree,de=ue.stat_desc.elems,ge=-1;for(re.heap_len=0,re.heap_max=v,Fe=0;Fe<de;Fe++)O[2*Fe]!==0?(re.heap[++re.heap_len]=ge=Fe,re.depth[Fe]=0):O[2*Fe+1]=0;for(;re.heap_len<2;)O[2*(be=re.heap[++re.heap_len]=ge<2?++ge:0)]=1,re.depth[be]=0,re.opt_len--,G&&(re.static_len-=R[2*be+1]);for(ue.max_code=ge,Fe=re.heap_len>>1;1<=Fe;Fe--)Ce(re,O,Fe);for(be=de;Fe=re.heap[1],re.heap[1]=re.heap[re.heap_len--],Ce(re,O,1),Pe=re.heap[1],re.heap[--re.heap_max]=Fe,re.heap[--re.heap_max]=Pe,O[2*be]=O[2*Fe]+O[2*Pe],re.depth[be]=(re.depth[Fe]>=re.depth[Pe]?re.depth[Fe]:re.depth[Pe])+1,O[2*Fe+1]=O[2*Pe+1]=be,re.heap[1]=be++,Ce(re,O,1),2<=re.heap_len;);re.heap[--re.heap_max]=re.heap[1],(function(ae,Ue){var ze,$e,Re,pe,ve,Ne,xe=Ue.dyn_tree,we=Ue.max_code,qe=Ue.stat_desc.static_tree,ke=Ue.stat_desc.has_stree,nt=Ue.stat_desc.extra_bits,De=Ue.stat_desc.extra_base,We=Ue.stat_desc.max_length,Oe=0;for(pe=0;pe<=g;pe++)ae.bl_count[pe]=0;for(xe[2*ae.heap[ae.heap_max]+1]=0,ze=ae.heap_max+1;ze<v;ze++)We<(pe=xe[2*xe[2*($e=ae.heap[ze])+1]+1]+1)&&(pe=We,Oe++),xe[2*$e+1]=pe,we<$e||(ae.bl_count[pe]++,ve=0,De<=$e&&(ve=nt[$e-De]),Ne=xe[2*$e],ae.opt_len+=Ne*(pe+ve),ke&&(ae.static_len+=Ne*(qe[2*$e+1]+ve)));if(Oe!==0){do{for(pe=We-1;ae.bl_count[pe]===0;)pe--;ae.bl_count[pe]--,ae.bl_count[pe+1]+=2,ae.bl_count[We]--,Oe-=2}while(0<Oe);for(pe=We;pe!==0;pe--)for($e=ae.bl_count[pe];$e!==0;)we<(Re=ae.heap[--ze])||(xe[2*Re+1]!==pe&&(ae.opt_len+=(pe-xe[2*Re+1])*xe[2*Re],xe[2*Re+1]=pe),$e--)}})(re,ue),ie(O,ge,re.bl_count)}function V(re,ue,Fe){var Pe,be,O=-1,R=ue[1],G=0,de=7,ge=4;for(R===0&&(de=138,ge=3),ue[2*(Fe+1)+1]=65535,Pe=0;Pe<=Fe;Pe++)be=R,R=ue[2*(Pe+1)+1],++G<de&&be===R||(G<ge?re.bl_tree[2*be]+=G:be!==0?(be!==O&&re.bl_tree[2*be]++,re.bl_tree[2*A]++):G<=10?re.bl_tree[2*k]++:re.bl_tree[2*P]++,O=be,ge=(G=0)===R?(de=138,3):be===R?(de=6,3):(de=7,4))}function K(re,ue,Fe){var Pe,be,O=-1,R=ue[1],G=0,de=7,ge=4;for(R===0&&(de=138,ge=3),Pe=0;Pe<=Fe;Pe++)if(be=R,R=ue[2*(Pe+1)+1],!(++G<de&&be===R)){if(G<ge)for(;Se(re,be,re.bl_tree),--G!=0;);else be!==0?(be!==O&&(Se(re,be,re.bl_tree),G--),Se(re,A,re.bl_tree),ee(re,G-3,2)):G<=10?(Se(re,k,re.bl_tree),ee(re,G-3,3)):(Se(re,P,re.bl_tree),ee(re,G-11,7));O=be,ge=(G=0)===R?(de=138,3):be===R?(de=6,3):(de=7,4)}}c(Q);var fe=!1;function Y(re,ue,Fe,Pe){ee(re,(d<<1)+(Pe?1:0),3),(function(be,O,R,G){se(be),Z(be,R),Z(be,~R),s.arraySet(be.pending_buf,be.window,O,R,be.pending),be.pending+=R})(re,ue,Fe)}i._tr_init=function(re){fe||((function(){var ue,Fe,Pe,be,O,R=new Array(g+1);for(be=Pe=0;be<u-1;be++)for($[be]=Pe,ue=0;ue<1<<C[be];ue++)D[Pe++]=be;for(D[Pe-1]=be,be=O=0;be<16;be++)for(Q[be]=O,ue=0;ue<1<<j[be];ue++)U[O++]=be;for(O>>=7;be<p;be++)for(Q[be]=O<<7,ue=0;ue<1<<j[be]-7;ue++)U[256+O++]=be;for(Fe=0;Fe<=g;Fe++)R[Fe]=0;for(ue=0;ue<=143;)B[2*ue+1]=8,ue++,R[8]++;for(;ue<=255;)B[2*ue+1]=9,ue++,R[9]++;for(;ue<=279;)B[2*ue+1]=7,ue++,R[7]++;for(;ue<=287;)B[2*ue+1]=8,ue++,R[8]++;for(ie(B,f+1,R),ue=0;ue<p;ue++)L[2*ue+1]=5,L[2*ue]=oe(ue,5);q=new te(B,C,h+1,f,g),z=new te(L,j,0,p,g),W=new te(new Array(0),M,0,x,_)})(),fe=!0),re.l_desc=new H(re.dyn_ltree,q),re.d_desc=new H(re.dyn_dtree,z),re.bl_desc=new H(re.bl_tree,W),re.bi_buf=0,re.bi_valid=0,me(re)},i._tr_stored_block=Y,i._tr_flush_block=function(re,ue,Fe,Pe){var be,O,R=0;0<re.level?(re.strm.data_type===2&&(re.strm.data_type=(function(G){var de,ge=4093624447;for(de=0;de<=31;de++,ge>>>=1)if(1&ge&&G.dyn_ltree[2*de]!==0)return o;if(G.dyn_ltree[18]!==0||G.dyn_ltree[20]!==0||G.dyn_ltree[26]!==0)return l;for(de=32;de<h;de++)if(G.dyn_ltree[2*de]!==0)return l;return o})(re)),Le(re,re.l_desc),Le(re,re.d_desc),R=(function(G){var de;for(V(G,G.dyn_ltree,G.l_desc.max_code),V(G,G.dyn_dtree,G.d_desc.max_code),Le(G,G.bl_desc),de=x-1;3<=de&&G.bl_tree[2*E[de]+1]===0;de--);return G.opt_len+=3*(de+1)+5+5+4,de})(re),be=re.opt_len+3+7>>>3,(O=re.static_len+3+7>>>3)<=be&&(be=O)):be=O=Fe+5,Fe+4<=be&&ue!==-1?Y(re,ue,Fe,Pe):re.strategy===4||O===be?(ee(re,2+(Pe?1:0),3),le(re,B,L)):(ee(re,4+(Pe?1:0),3),(function(G,de,ge,ae){var Ue;for(ee(G,de-257,5),ee(G,ge-1,5),ee(G,ae-4,4),Ue=0;Ue<ae;Ue++)ee(G,G.bl_tree[2*E[Ue]+1],3);K(G,G.dyn_ltree,de-1),K(G,G.dyn_dtree,ge-1)})(re,re.l_desc.max_code+1,re.d_desc.max_code+1,R+1),le(re,re.dyn_ltree,re.dyn_dtree)),me(re),Pe&&se(re)},i._tr_tally=function(re,ue,Fe){return re.pending_buf[re.d_buf+2*re.last_lit]=ue>>>8&255,re.pending_buf[re.d_buf+2*re.last_lit+1]=255&ue,re.pending_buf[re.l_buf+re.last_lit]=255&Fe,re.last_lit++,ue===0?re.dyn_ltree[2*Fe]++:(re.matches++,ue--,re.dyn_ltree[2*(D[Fe]+h+1)]++,re.dyn_dtree[2*X(ue)]++),re.last_lit===re.lit_bufsize-1},i._tr_align=function(re){ee(re,2,3),Se(re,N,B),(function(ue){ue.bi_valid===16?(Z(ue,ue.bi_buf),ue.bi_buf=0,ue.bi_valid=0):8<=ue.bi_valid&&(ue.pending_buf[ue.pending++]=255&ue.bi_buf,ue.bi_buf>>=8,ue.bi_valid-=8)})(re)}},{"../utils/common":41}],53:[function(n,r,i){r.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(n,r,i){(function(s){(function(o,l){if(!o.setImmediate){var c,d,u,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,k=o.onmessage;return o.onmessage=function(){A=!1},o.postMessage("","*"),o.onmessage=k,A}})()?(h="setImmediate$"+Math.random()+"$",o.addEventListener?o.addEventListener("message",N,!1):o.attachEvent("onmessage",N),function(A){o.postMessage(h+A,"*")}):o.MessageChannel?((u=new MessageChannel).port1.onmessage=function(A){_(A.data)},function(A){u.port2.postMessage(A)}):v&&"onreadystatechange"in v.createElement("script")?(d=v.documentElement,function(A){var k=v.createElement("script");k.onreadystatechange=function(){_(A),k.onreadystatechange=null,d.removeChild(k),k=null},d.appendChild(k)}):function(A){setTimeout(_,0,A)},g.setImmediate=function(A){typeof A!="function"&&(A=new Function(""+A));for(var k=new Array(arguments.length-1),P=0;P<k.length;P++)k[P]=arguments[P+1];var C={callback:A,args:k};return p[f]=C,c(f),f++},g.clearImmediate=y}function y(A){delete p[A]}function _(A){if(x)setTimeout(_,0,A);else{var k=p[A];if(k){x=!0;try{(function(P){var C=P.callback,j=P.args;switch(j.length){case 0:C();break;case 1:C(j[0]);break;case 2:C(j[0],j[1]);break;case 3:C(j[0],j[1],j[2]);break;default:C.apply(l,j)}})(k)}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 Qw<"u"?Qw:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(wP)),wP.exports}var kSe=CSe();const ASe=rc(kSe);function TSe(t){const e=new ai;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 J8=TSe;async function e6(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 u=0;u<c.length;u++){const h=c[u];o.push(parseFloat(h.getAttribute("x")||"0"),parseFloat(h.getAttribute("y")||"0"),parseFloat(h.getAttribute("z")||"0"))}const d=s.getElementsByTagName("triangle");for(let u=0;u<d.length;u++){const h=d[u];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 t6(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 MSe(t){let e;try{e=await ASe.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,k=e.files[A];if(!k)return null;const P=await k.async("string");return o.parseFromString(P,"application/xml")}const c=new Map,d=new Map,u=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"),k=A.getElementsByTagName("object");for(let C=0;C<k.length;C++){const j=k[C],M=j.getAttribute("id");if(!M)continue;const E=Array.from(j.children).filter(D=>D.tagName==="metadata"&&D.getAttribute("key")==="extruder");if(E.length>0){const D=E[0].getAttribute("value");D&&c.set(M,Math.max(0,parseInt(D,10)-1))}const L=Array.from(j.children).find(D=>D.tagName==="metadata"&&D.getAttribute("key")==="name")?.getAttribute("value");L&&u.set(M,L);const U=j.getElementsByTagName("part");for(let D=0;D<U.length;D++){const $=U[D],q=$.getAttribute("id");if(!q)continue;const z=Array.from($.children).filter(W=>W.tagName==="metadata"&&W.getAttribute("key")==="extruder");if(z.length>0){const W=z[0].getAttribute("value");W&&d.set(`${M}:${q}`,Math.max(0,parseInt(W,10)-1))}}}const P=A.getElementsByTagName("plate");for(let C=0;C<P.length;C++){const j=P[C];let M=null;const E=j.getElementsByTagName("metadata");let B=0,L=0;for(let D=0;D<E.length;D++){const $=E[D],q=$.getAttribute("key");if(q==="plater_id"||q==="plate_id"){const z=$.getAttribute("value");if(z){const W=Number.parseInt(z,10);Number.isFinite(W)&&(M=W)}}else if(q==="pos_x"){const z=$.getAttribute("value"),W=z?Number.parseFloat(z):Number.NaN;Number.isFinite(W)&&(B=W)}else if(q==="pos_y"){const z=$.getAttribute("value"),W=z?Number.parseFloat(z):Number.NaN;Number.isFinite(W)&&(L=W)}}if(M==null)continue;(B!==0||L!==0)&&s.set(M,{offsetX:B,offsetY:L});const U=j.getElementsByTagName("model_instance");for(let D=0;D<U.length;D++){const q=U[D].getElementsByTagName("metadata");for(let z=0;z<q.length;z++){const W=q[z];if(W.getAttribute("key")==="object_id"){const Q=W.getAttribute("value");Q&&h.set(Q,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 k=Number.parseInt(A[1],10);if(Number.isFinite(k))try{const P=await e.files[N].async("string"),C=JSON.parse(P),j=C.bbox_objects??[];for(const M of j)M?.name&&p.set(M.name,k);if(Array.isArray(C.bbox_all)&&C.bbox_all.length>=4){const[M,E,B,L]=C.bbox_all;[M,E,B,L].every(U=>Number.isFinite(U))&&i.set(k,{minX:M,minY:E,maxX:B,maxY:L})}}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 k=await e6(A,0);k.length>0&&n.set("1",{id:"1",meshes:k,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],k=A.getAttribute("id");if(!k)continue;const P=t6(A)??h.get(k)??null;let C=c.get(k)??-1;if(C<0){const B=A.getAttribute("p:extruder")||A.getAttributeNS("http://schemas.microsoft.com/3dmanufacturing/production/2015/06","extruder")||"1";C=Math.max(0,parseInt(B,10)-1)}const j=[],M=A.getElementsByTagName("mesh");for(let B=0;B<M.length;B++){const L=M[B],U=[],D=[],$=L.getElementsByTagName("vertex");for(let z=0;z<$.length;z++){const W=$[z];U.push(parseFloat(W.getAttribute("x")||"0"),parseFloat(W.getAttribute("y")||"0"),parseFloat(W.getAttribute("z")||"0"))}const q=L.getElementsByTagName("triangle");for(let z=0;z<q.length;z++){const W=q[z];D.push(parseInt(W.getAttribute("v1")||"0"),parseInt(W.getAttribute("v2")||"0"),parseInt(W.getAttribute("v3")||"0"))}U.length>0&&D.length>0&&j.push({vertices:U,triangles:D,extruder:C})}const E=A.getElementsByTagName("component");for(let B=0;B<E.length;B++){const L=E[B],U=L.getAttribute("p:path")||L.getAttributeNS("http://schemas.microsoft.com/3dmanufacturing/production/2015/06","path"),D=L.getAttribute("objectid");if(U){const $=await l(U);if($){const q=D?`${k}:${D}`:null,z=q?d.get(q)??C:C,W=await e6($,z),Q=L.getAttribute("transform"),te=J8(Q);for(const H of W)if(Q){const X=[];for(let Z=0;Z<H.vertices.length;Z+=3){const ee=new pt(H.vertices[Z],H.vertices[Z+1],H.vertices[Z+2]);ee.applyMatrix4(te),X.push(ee.x,ee.y,ee.z)}j.push({vertices:X,triangles:H.triangles,extruder:H.extruder})}else j.push(H)}}}j.length>0&&n.set(k,{id:k,meshes:j,defaultExtruder:C,plateId:P})}const _=g.getElementsByTagName("build");if(_.length>0){const N=_[0].getElementsByTagName("item");for(let A=0;A<N.length;A++){const k=N[A],P=k.getAttribute("objectid");if(!P)continue;const C=J8(k.getAttribute("transform")),j=t6(k),M=n.get(P)?.plateId??null,E=u.get(P),B=E?p.get(E)??null:null;r.push({objectId:P,transform:C,plateId:j??M??B??null})}}return{objects:n,buildItems:r,plateBounds:i,plateOffsets:s}}function n6(t){const e=new _l,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 Rs(n,3)),e.setIndex(t.triangles),e.computeVertexNormals(),e}function PSe(t){t.traverse(e=>{if(e instanceof Nl)if(e.geometry.dispose(),Array.isArray(e.material))for(const n of e.material)n.dispose();else e.material.dispose()})}function ESe(t,e,n){const{objects:r,buildItems:i}=t,s=new zg,o=h=>{const p=n?.[h]||"#00ae42",x=new Hn(p);return new pY({color:x,shininess:30,flatShading:!1})},l=new Map,c=i.some(h=>h.plateId!=null),d=e==null||!c?i:i.filter(h=>h.plateId===e),u=d.length>0?d:i;if(u.length>0)for(const h of u){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 pt(p.vertices[y],p.vertices[y+1],p.vertices[y+2]);_.applyMatrix4(h.transform),v.push(_.x,_.y,_.z)}const g=n6({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=n6(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]:_Se(f,!1);if(p){const x=o(h),v=new Nl(p,x);s.add(v)}if(f.length>1)for(const x of f)x.dispose()}return s}function NY({url:t,fileType:e,buildVolume:n={x:256,y:256,z:256},filamentColors:r,selectedPlateId:i=null,className:s=""}){const{t:o}=Dt(),l=w.useRef(null),c=w.useRef(null),d=w.useRef(null),u=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),[k,P]=w.useState(null);w.useEffect(()=>{if(!l.current)return;const M=l.current,E=M.clientWidth,B=M.clientHeight,L=new rxe;L.background=new Hn(1710618),d.current=L;const U=new ll(45,E/B,.1,1e4);U.position.set(150,150,150),u.current=U;const D=new lSe({antialias:!0});D.setSize(E,B),D.setPixelRatio(window.devicePixelRatio),M.appendChild(D.domElement),c.current=D;const $=new dSe(U,D.domElement);$.enableDamping=!0,$.dampingFactor=.05,h.current=$;const q=new xxe(16777215,.6);L.add(q);const z=new _8(16777215,.8);z.position.set(100,100,100),L.add(z);const W=new _8(16777215,.4);W.position.set(-100,50,-100),L.add(W);const Q=Math.max(n.x,n.y),te=Math.ceil(Q/16),H=new vxe(Q,te,4473924,3355443);L.add(H),x.current=H;const X=new YF(n.x,n.y),Z=new WF({color:44610,transparent:!0,opacity:.15,side:Nc}),ee=new Nl(X,Z);ee.rotation.x=-Math.PI/2,ee.position.y=-.5,L.add(ee),p.current=ee;let Se;const oe=()=>{Se=requestAnimationFrame(oe),$.update(),D.render(L,U)};oe(),g(!0),_(null),A(null),P(null);const ie=(e||t.split("?")[0].split(".").pop()||"").toLowerCase(),me={},se=au();se&&(me.Authorization=`Bearer ${se}`),ie==="stl"?fetch(t,{headers:me}).then(le=>{if(!le.ok)throw new Error(o("modelViewer.errors.failedToLoad"));return le.arrayBuffer()}).then(le=>{const V=new NSe().parse(le);V.computeVertexNormals(),V.rotateX(-Math.PI/2),P(V)}).catch(le=>{_(le.message),g(!1)}):ie==="3mf"?fetch(t,{headers:me}).then(le=>{if(!le.ok)throw new Error(o("modelViewer.errors.failedToLoad"));return le.arrayBuffer()}).then(MSe).then(le=>{if(le.objects.size===0)throw new Error(o("modelViewer.errors.noMeshes"));A(le)}).catch(le=>{_(le.message),g(!1)}):(_(o("modelViewer.errors.unsupportedFormat")),g(!1));const ce=()=>{if(!M)return;const le=M.clientWidth,Le=M.clientHeight;le===0||Le===0||(U.aspect=le/Le,U.updateProjectionMatrix(),D.setSize(le,Le))};window.addEventListener("resize",ce);const Ce=new ResizeObserver(()=>{ce()});return Ce.observe(M),()=>{window.removeEventListener("resize",ce),Ce.disconnect(),cancelAnimationFrame(Se),$.dispose(),D.dispose(),M.removeChild(D.domElement),f.current=null,p.current=null,x.current=null}},[t,n,e,o]),w.useEffect(()=>{if(!d.current||!u.current||!h.current||!N&&!k)return;f.current&&(d.current.remove(f.current),PSe(f.current));const M=!!k,E=M?(()=>{const ie=r?.[0]||"#00ae42",me=new pY({color:new Hn(ie),shininess:30}),se=new Nl(k,me),ce=new zg;return ce.add(se),ce})():ESe(N,i??null,r);f.current=E,d.current.add(E);const B=new Fh().setFromObject(E),L=B.getCenter(new pt);E.position.y=-B.min.y;const U=!M&&i!=null&&N.buildItems.length>0?N.plateBounds.get(i):void 0,D=!M&&i!=null?N.plateOffsets.get(i):void 0,$=M||N.buildItems.length===0||i!=null&&!U&&!D,q=$?-L.x:0,z=$?-L.z:0;let W=0,Q=0;if(!M&&i!=null&&N.buildItems.length>0&&U){const ie=new Fh().setFromObject(E);W=ie.min.x-U.minX,Q=ie.min.z-U.minY}const te=n.x/2,H=n.y/2;!M&&i!=null&&N.buildItems.length>0&&U?(E.position.x=q-W,E.position.z=z-Q):!M&&i!=null&&D?(E.position.x=q+(te-D.offsetX),E.position.z=z+(H-D.offsetY)):$?(E.position.x=q+te,E.position.z=z+H):(E.position.x=q,E.position.z=z),p.current&&(p.current.position.x=te,p.current.position.z=H),x.current&&(x.current.position.x=te,x.current.position.z=H);const X=new Fh().setFromObject(E),Z=X.getCenter(new pt),ee=X.getSize(new pt),oe=Math.max(ee.x,ee.y,ee.z)*1.8;u.current.position.set(Z.x+oe*.7,Z.y+oe*.5,Z.z+oe*.7),h.current.target.copy(Z),h.current.update(),g(!1)},[N,k,i,r,n]);const C=()=>{u.current&&h.current&&(u.current.position.set(150,150,150),h.current.target.set(0,50,0),h.current.update())},j=M=>{u.current&&u.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(at,{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(Me,{variant:"secondary",size:"sm",onClick:()=>j(.8),children:a.jsx(DF,{className:"w-4 h-4"})}),a.jsx(Me,{variant:"secondary",size:"sm",onClick:()=>j(1.25),children:a.jsx(RF,{className:"w-4 h-4"})}),a.jsx(Me,{variant:"secondary",size:"sm",onClick:C,children:a.jsx(lo,{className:"w-4 h-4"})})]})]})}const sk="159",tg={ROTATE:0,DOLLY:1,PAN:2},ng={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},jSe=0,r6=1,DSe=2,CY=1,RSe=2,Pd=3,Xh=0,ao=1,Rd=2,Lh=0,Jg=1,a6=2,i6=3,s6=4,FSe=5,Xm=100,LSe=101,OSe=102,o6=103,l6=104,ISe=200,zSe=201,USe=202,BSe=203,aD=204,iD=205,HSe=206,$Se=207,VSe=208,qSe=209,GSe=210,WSe=211,KSe=212,XSe=213,YSe=214,QSe=0,ZSe=1,JSe=2,E1=3,e_e=4,t_e=5,n_e=6,r_e=7,JF=0,a_e=1,i_e=2,Oh=0,s_e=1,o_e=2,l_e=3,c_e=4,d_e=5,kY=300,yb=301,vb=302,sD=303,oD=304,ok=306,lD=1e3,Bl=1001,cD=1002,Qi=1003,c6=1004,SP=1005,cl=1006,u_e=1007,_0=1008,Ih=1009,h_e=1010,m_e=1011,eL=1012,AY=1013,Sh=1014,Ud=1015,N0=1016,TY=1017,MY=1018,mf=1020,f_e=1021,dl=1023,p_e=1024,g_e=1025,ff=1026,wb=1027,b_e=1028,PY=1029,x_e=1030,EY=1031,jY=1033,_P=33776,NP=33777,CP=33778,kP=33779,d6=35840,u6=35841,h6=35842,m6=35843,DY=36196,f6=37492,p6=37496,g6=37808,b6=37809,x6=37810,y6=37811,v6=37812,w6=37813,S6=37814,_6=37815,N6=37816,C6=37817,k6=37818,A6=37819,T6=37820,M6=37821,AP=36492,P6=36494,E6=36495,y_e=36283,j6=36284,D6=36285,R6=36286,RY=3e3,pf=3001,v_e=3200,w_e=3201,FY=0,S_e=1,ul="",Zi="srgb",su="srgb-linear",tL="display-p3",lk="display-p3-linear",j1="linear",oa="srgb",D1="rec709",R1="p3",rg=7680,F6=519,__e=512,N_e=513,C_e=514,LY=515,k_e=516,A_e=517,T_e=518,M_e=519,dD=35044,L6="300 es",uD=1035,Tc=2e3,C0=2001;class np{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 ds=["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 O6=1234567;const Hy=Math.PI/180,k0=180/Math.PI;function Wd(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(ds[t&255]+ds[t>>8&255]+ds[t>>16&255]+ds[t>>24&255]+"-"+ds[e&255]+ds[e>>8&255]+"-"+ds[e>>16&15|64]+ds[e>>24&255]+"-"+ds[n&63|128]+ds[n>>8&255]+"-"+ds[n>>16&255]+ds[n>>24&255]+ds[r&255]+ds[r>>8&255]+ds[r>>16&255]+ds[r>>24&255]).toLowerCase()}function Ji(t,e,n){return Math.max(e,Math.min(n,t))}function nL(t,e){return(t%e+e)%e}function P_e(t,e,n,r,i){return r+(t-e)*(i-r)/(n-e)}function E_e(t,e,n){return t!==e?(n-t)/(e-t):0}function $y(t,e,n){return(1-n)*t+n*e}function j_e(t,e,n,r){return $y(t,e,1-Math.exp(-n*r))}function D_e(t,e=1){return e-Math.abs(nL(t,e*2)-e)}function R_e(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*(3-2*t))}function F_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 L_e(t,e){return t+Math.floor(Math.random()*(e-t+1))}function O_e(t,e){return t+Math.random()*(e-t)}function I_e(t){return t*(.5-Math.random())}function z_e(t){t!==void 0&&(O6=t);let e=O6+=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 U_e(t){return t*Hy}function B_e(t){return t*k0}function hD(t){return(t&t-1)===0&&t!==0}function H_e(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}function F1(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function $_e(t,e,n,r,i){const s=Math.cos,o=Math.sin,l=s(n/2),c=o(n/2),d=s((e+r)/2),u=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*u,c*h,c*f,l*d);break;case"YZY":t.set(c*f,l*u,c*h,l*d);break;case"ZXZ":t.set(c*h,c*f,l*u,l*d);break;case"XZX":t.set(l*u,c*x,c*p,l*d);break;case"YXY":t.set(c*p,l*u,c*x,l*d);break;case"ZYZ":t.set(c*x,c*p,l*u,l*d);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 Ur(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 OY={DEG2RAD:Hy,RAD2DEG:k0,generateUUID:Wd,clamp:Ji,euclideanModulo:nL,mapLinear:P_e,inverseLerp:E_e,lerp:$y,damp:j_e,pingpong:D_e,smoothstep:R_e,smootherstep:F_e,randInt:L_e,randFloat:O_e,randFloatSpread:I_e,seededRandom:z_e,degToRad:U_e,radToDeg:B_e,isPowerOfTwo:hD,ceilPowerOfTwo:H_e,floorPowerOfTwo:F1,setQuaternionFromProperEuler:$_e,normalize:Ur,denormalize:Cc};class Nn{constructor(e=0,n=0){Nn.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 Vn{constructor(e,n,r,i,s,o,l,c,d){Vn.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,d)}set(e,n,r,i,s,o,l,c,d){const u=this.elements;return u[0]=e,u[1]=i,u[2]=l,u[3]=n,u[4]=s,u[5]=c,u[6]=r,u[7]=o,u[8]=d,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],d=r[1],u=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],k=i[2],P=i[5],C=i[8];return s[0]=o*v+l*_+c*k,s[3]=o*g+l*N+c*P,s[6]=o*y+l*A+c*C,s[1]=d*v+u*_+h*k,s[4]=d*g+u*N+h*P,s[7]=d*y+u*A+h*C,s[2]=f*v+p*_+x*k,s[5]=f*g+p*N+x*P,s[8]=f*y+p*A+x*C,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[3]*=e,n[6]*=e,n[1]*=e,n[4]*=e,n[7]*=e,n[2]*=e,n[5]*=e,n[8]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[1],i=e[2],s=e[3],o=e[4],l=e[5],c=e[6],d=e[7],u=e[8];return n*o*u-n*l*d-r*s*u+r*l*c+i*s*d-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],d=e[7],u=e[8],h=u*o-l*d,f=l*c-u*s,p=d*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*d-u*r)*v,e[2]=(l*r-i*o)*v,e[3]=f*v,e[4]=(u*n-i*c)*v,e[5]=(i*s-l*n)*v,e[6]=p*v,e[7]=(r*c-d*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),d=Math.sin(s);return this.set(r*c,r*d,-r*(c*o+d*l)+o+e,-i*d,i*c,-i*(-d*o+c*l)+l+n,0,0,1),this}scale(e,n){return this.premultiply(TP.makeScale(e,n)),this}rotate(e){return this.premultiply(TP.makeRotation(-e)),this}translate(e,n){return this.premultiply(TP.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 TP=new Vn;function IY(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function L1(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function V_e(){const t=L1("canvas");return t.style.display="block",t}const I6={};function Vy(t){t in I6||(I6[t]=!0,console.warn(t))}const z6=new Vn().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),U6=new Vn().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),AS={[su]:{transfer:j1,primaries:D1,toReference:t=>t,fromReference:t=>t},[Zi]:{transfer:oa,primaries:D1,toReference:t=>t.convertSRGBToLinear(),fromReference:t=>t.convertLinearToSRGB()},[lk]:{transfer:j1,primaries:R1,toReference:t=>t.applyMatrix3(U6),fromReference:t=>t.applyMatrix3(z6)},[tL]:{transfer:oa,primaries:R1,toReference:t=>t.convertSRGBToLinear().applyMatrix3(U6),fromReference:t=>t.applyMatrix3(z6).convertLinearToSRGB()}},q_e=new Set([su,lk]),Br={enabled:!0,_workingColorSpace:su,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(!q_e.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=AS[e].toReference,i=AS[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 AS[t].primaries},getTransfer:function(t){return t===ul?j1:AS[t].transfer}};function eb(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function MP(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let ag;class zY{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{ag===void 0&&(ag=L1("canvas")),ag.width=e.width,ag.height=e.height;const r=ag.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),n=ag}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=L1("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]=eb(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(eb(n[r]/255)*255):n[r]=eb(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 G_e=0;class UY{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:G_e++}),this.uuid=Wd(),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(PP(i[o].image)):s.push(PP(i[o]))}else s=PP(i);r.url=s}return n||(e.images[this.uuid]=r),r}}function PP(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?zY.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 W_e=0;class io extends np{constructor(e=io.DEFAULT_IMAGE,n=io.DEFAULT_MAPPING,r=Bl,i=Bl,s=cl,o=_0,l=dl,c=Ih,d=io.DEFAULT_ANISOTROPY,u=ul){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:W_e++}),this.uuid=Wd(),this.name="",this.source=new UY(e),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=s,this.minFilter=o,this.anisotropy=d,this.format=l,this.internalFormat=null,this.type=c,this.offset=new Nn(0,0),this.repeat=new Nn(1,1),this.center=new Nn(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Vn,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,typeof u=="string"?this.colorSpace=u:(Vy("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=u===pf?Zi:ul),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!==kY)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case lD:e.x=e.x-Math.floor(e.x);break;case Bl:e.x=e.x<0?0:1;break;case cD: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 lD:e.y=e.y-Math.floor(e.y);break;case Bl:e.y=e.y<0?0:1;break;case cD: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 Vy("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===Zi?pf:RY}set encoding(e){Vy("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=e===pf?Zi:ul}}io.DEFAULT_IMAGE=null;io.DEFAULT_MAPPING=kY;io.DEFAULT_ANISOTROPY=1;class $r{constructor(e=0,n=0,r=0,i=1){$r.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,d=c[0],u=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(u-f)<.01&&Math.abs(h-v)<.01&&Math.abs(x-g)<.01){if(Math.abs(u+f)<.1&&Math.abs(h+v)<.1&&Math.abs(x+g)<.1&&Math.abs(d+p+y-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const N=(d+1)/2,A=(p+1)/2,k=(y+1)/2,P=(u+f)/4,C=(h+v)/4,j=(x+g)/4;return N>A&&N>k?N<.01?(r=0,i=.707106781,s=.707106781):(r=Math.sqrt(N),i=P/r,s=C/r):A>k?A<.01?(r=.707106781,i=0,s=.707106781):(i=Math.sqrt(A),r=P/i,s=j/i):k<.01?(r=.707106781,i=.707106781,s=0):(s=Math.sqrt(k),r=C/s,i=j/s),this.set(r,i,s,n),this}let _=Math.sqrt((g-x)*(g-x)+(h-v)*(h-v)+(f-u)*(f-u));return Math.abs(_)<.001&&(_=1),this.x=(g-x)/_,this.y=(h-v)/_,this.z=(f-u)/_,this.w=Math.acos((d+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 K_e extends np{constructor(e=1,n=1,r={}){super(),this.isRenderTarget=!0,this.width=e,this.height=n,this.depth=1,this.scissor=new $r(0,0,e,n),this.scissorTest=!1,this.viewport=new $r(0,0,e,n);const i={width:e,height:n,depth:1};r.encoding!==void 0&&(Vy("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),r.colorSpace=r.encoding===pf?Zi:ul),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:cl,depthBuffer:!0,stencilBuffer:!1,depthTexture:null,samples:0},r),this.texture=new io(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 UY(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 Of extends K_e{constructor(e=1,n=1,r={}){super(e,n,r),this.isWebGLRenderTarget=!0}}class BY extends io{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=Bl,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class X_e extends io{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=Bl,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class If{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],d=r[i+1],u=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]=d,e[n+2]=u,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||d!==p||u!==x){let g=1-l;const y=c*f+d*p+u*x+h*v,_=y>=0?1:-1,N=1-y*y;if(N>Number.EPSILON){const k=Math.sqrt(N),P=Math.atan2(k,y*_);g=Math.sin(g*P)/k,l=Math.sin(l*P)/k}const A=l*_;if(c=c*g+f*A,d=d*g+p*A,u=u*g+x*A,h=h*g+v*A,g===1-l){const k=1/Math.sqrt(c*c+d*d+u*u+h*h);c*=k,d*=k,u*=k,h*=k}}e[n]=c,e[n+1]=d,e[n+2]=u,e[n+3]=h}static multiplyQuaternionsFlat(e,n,r,i,s,o){const l=r[i],c=r[i+1],d=r[i+2],u=r[i+3],h=s[o],f=s[o+1],p=s[o+2],x=s[o+3];return e[n]=l*x+u*h+c*p-d*f,e[n+1]=c*x+u*f+d*h-l*p,e[n+2]=d*x+u*p+l*f-c*h,e[n+3]=u*x-l*h-c*f-d*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,d=l(r/2),u=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*u*h+d*p*x,this._y=d*p*h-f*u*x,this._z=d*u*x+f*p*h,this._w=d*u*h-f*p*x;break;case"YXZ":this._x=f*u*h+d*p*x,this._y=d*p*h-f*u*x,this._z=d*u*x-f*p*h,this._w=d*u*h+f*p*x;break;case"ZXY":this._x=f*u*h-d*p*x,this._y=d*p*h+f*u*x,this._z=d*u*x+f*p*h,this._w=d*u*h-f*p*x;break;case"ZYX":this._x=f*u*h-d*p*x,this._y=d*p*h+f*u*x,this._z=d*u*x-f*p*h,this._w=d*u*h+f*p*x;break;case"YZX":this._x=f*u*h+d*p*x,this._y=d*p*h+f*u*x,this._z=d*u*x-f*p*h,this._w=d*u*h-f*p*x;break;case"XZY":this._x=f*u*h-d*p*x,this._y=d*p*h-f*u*x,this._z=d*u*x+f*p*h,this._w=d*u*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],d=n[2],u=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=(u-c)*p,this._y=(s-d)*p,this._z=(o-i)*p}else if(r>l&&r>h){const p=2*Math.sqrt(1+r-l-h);this._w=(u-c)/p,this._x=.25*p,this._y=(i+o)/p,this._z=(s+d)/p}else if(l>h){const p=2*Math.sqrt(1+l-r-h);this._w=(s-d)/p,this._x=(i+o)/p,this._y=.25*p,this._z=(c+u)/p}else{const p=2*Math.sqrt(1+h-r-l);this._w=(o-i)/p,this._x=(s+d)/p,this._y=(c+u)/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,d=n._z,u=n._w;return this._x=r*u+o*l+i*d-s*c,this._y=i*u+o*c+s*l-r*d,this._z=s*u+o*d+r*c-i*l,this._w=o*u-r*l-i*c-s*d,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 d=Math.sqrt(c),u=Math.atan2(d,l),h=Math.sin((1-n)*u)/d,f=Math.sin(n*u)/d;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 Je{constructor(e=0,n=0,r=0){Je.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(B6.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(B6.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,d=2*(o*i-l*r),u=2*(l*n-s*i),h=2*(s*r-o*n);return this.x=n+c*d+o*h-l*u,this.y=r+c*u+l*d-s*h,this.z=i+c*h+s*u-o*d,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 EP.copy(this).projectOnVector(e),this.sub(EP)}reflect(e){return this.sub(EP.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 EP=new Je,B6=new If;class bl{constructor(e=new Je(1/0,1/0,1/0),n=new Je(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=n}set(e,n){return this.min.copy(e),this.max.copy(n),this}setFromArray(e){this.makeEmpty();for(let n=0,r=e.length;n<r;n+=3)this.expandByPoint(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(),TS.copy(e.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),TS.copy(r.boundingBox)),TS.applyMatrix4(e.matrixWorld),this.union(TS)}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(ly),MS.subVectors(this.max,ly),ig.subVectors(e.a,ly),sg.subVectors(e.b,ly),og.subVectors(e.c,ly),Xu.subVectors(sg,ig),Yu.subVectors(og,sg),Dm.subVectors(ig,og);let n=[0,-Xu.z,Xu.y,0,-Yu.z,Yu.y,0,-Dm.z,Dm.y,Xu.z,0,-Xu.x,Yu.z,0,-Yu.x,Dm.z,0,-Dm.x,-Xu.y,Xu.x,0,-Yu.y,Yu.x,0,-Dm.y,Dm.x,0];return!jP(n,ig,sg,og,MS)||(n=[1,0,0,0,1,0,0,0,1],!jP(n,ig,sg,og,MS))?!1:(PS.crossVectors(Xu,Yu),n=[PS.x,PS.y,PS.z],jP(n,ig,sg,og,MS))}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:(vd[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),vd[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),vd[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),vd[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),vd[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),vd[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),vd[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),vd[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(vd),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 vd=[new Je,new Je,new Je,new Je,new Je,new Je,new Je,new Je],Ol=new Je,TS=new bl,ig=new Je,sg=new Je,og=new Je,Xu=new Je,Yu=new Je,Dm=new Je,ly=new Je,MS=new Je,PS=new Je,Rm=new Je;function jP(t,e,n,r,i){for(let s=0,o=t.length-3;s<=o;s+=3){Rm.fromArray(t,s);const l=i.x*Math.abs(Rm.x)+i.y*Math.abs(Rm.y)+i.z*Math.abs(Rm.z),c=e.dot(Rm),d=n.dot(Rm),u=r.dot(Rm);if(Math.max(-Math.max(c,d,u),Math.min(c,d,u))>l)return!1}return!0}const Y_e=new bl,cy=new Je,DP=new Je;class Dc{constructor(e=new Je,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):Y_e.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;cy.subVectors(e,this.center);const n=cy.lengthSq();if(n>this.radius*this.radius){const r=Math.sqrt(n),i=(r-this.radius)*.5;this.center.addScaledVector(cy,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):(DP.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(cy.copy(e.center).add(DP)),this.expandByPoint(cy.copy(e.center).sub(DP))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const wd=new Je,RP=new Je,ES=new Je,Qu=new Je,FP=new Je,jS=new Je,LP=new Je;class rL{constructor(e=new Je,n=new Je(0,0,-1)){this.origin=e,this.direction=n}set(e,n){return this.origin.copy(e),this.direction.copy(n),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,n){return n.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,wd)),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=wd.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(wd.copy(this.origin).addScaledVector(this.direction,n),wd.distanceToSquared(e))}distanceSqToSegment(e,n,r,i){RP.copy(e).add(n).multiplyScalar(.5),ES.copy(n).sub(e).normalize(),Qu.copy(this.origin).sub(RP);const s=e.distanceTo(n)*.5,o=-this.direction.dot(ES),l=Qu.dot(this.direction),c=-Qu.dot(ES),d=Qu.lengthSq(),u=Math.abs(1-o*o);let h,f,p,x;if(u>0)if(h=o*c-l,f=o*l-c,x=s*u,h>=0)if(f>=-x)if(f<=x){const v=1/u;h*=v,f*=v,p=h*(h+o*f+2*l)+f*(o*h+f+2*c)+d}else f=s,h=Math.max(0,-(o*f+l)),p=-h*h+f*(f+2*c)+d;else f=-s,h=Math.max(0,-(o*f+l)),p=-h*h+f*(f+2*c)+d;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)+d):f<=x?(h=0,f=Math.min(Math.max(-s,-c),s),p=f*(f+2*c)+d):(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)+d);else f=o>0?-s:s,h=Math.max(0,-(o*f+l)),p=-h*h+f*(f+2*c)+d;return r&&r.copy(this.origin).addScaledVector(this.direction,h),i&&i.copy(RP).addScaledVector(ES,f),p}intersectSphere(e,n){wd.subVectors(e.center,this.origin);const r=wd.dot(this.direction),i=wd.dot(wd)-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 d=1/this.direction.x,u=1/this.direction.y,h=1/this.direction.z,f=this.origin;return d>=0?(r=(e.min.x-f.x)*d,i=(e.max.x-f.x)*d):(r=(e.max.x-f.x)*d,i=(e.min.x-f.x)*d),u>=0?(s=(e.min.y-f.y)*u,o=(e.max.y-f.y)*u):(s=(e.max.y-f.y)*u,o=(e.min.y-f.y)*u),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,wd)!==null}intersectTriangle(e,n,r,i,s){FP.subVectors(n,e),jS.subVectors(r,e),LP.crossVectors(FP,jS);let o=this.direction.dot(LP),l;if(o>0){if(i)return null;l=1}else if(o<0)l=-1,o=-o;else return null;Qu.subVectors(this.origin,e);const c=l*this.direction.dot(jS.crossVectors(Qu,jS));if(c<0)return null;const d=l*this.direction.dot(FP.cross(Qu));if(d<0||c+d>o)return null;const u=-l*Qu.dot(LP);return u<0?null:this.at(u/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 ra{constructor(e,n,r,i,s,o,l,c,d,u,h,f,p,x,v,g){ra.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,d,u,h,f,p,x,v,g)}set(e,n,r,i,s,o,l,c,d,u,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]=d,y[6]=u,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 ra().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/lg.setFromMatrixColumn(e,0).length(),s=1/lg.setFromMatrixColumn(e,1).length(),o=1/lg.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),d=Math.sin(i),u=Math.cos(s),h=Math.sin(s);if(e.order==="XYZ"){const f=o*u,p=o*h,x=l*u,v=l*h;n[0]=c*u,n[4]=-c*h,n[8]=d,n[1]=p+x*d,n[5]=f-v*d,n[9]=-l*c,n[2]=v-f*d,n[6]=x+p*d,n[10]=o*c}else if(e.order==="YXZ"){const f=c*u,p=c*h,x=d*u,v=d*h;n[0]=f+v*l,n[4]=x*l-p,n[8]=o*d,n[1]=o*h,n[5]=o*u,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*u,p=c*h,x=d*u,v=d*h;n[0]=f-v*l,n[4]=-o*h,n[8]=x+p*l,n[1]=p+x*l,n[5]=o*u,n[9]=v-f*l,n[2]=-o*d,n[6]=l,n[10]=o*c}else if(e.order==="ZYX"){const f=o*u,p=o*h,x=l*u,v=l*h;n[0]=c*u,n[4]=x*d-p,n[8]=f*d+v,n[1]=c*h,n[5]=v*d+f,n[9]=p*d-x,n[2]=-d,n[6]=l*c,n[10]=o*c}else if(e.order==="YZX"){const f=o*c,p=o*d,x=l*c,v=l*d;n[0]=c*u,n[4]=v-f*h,n[8]=x*h+p,n[1]=h,n[5]=o*u,n[9]=-l*u,n[2]=-d*u,n[6]=p*h+x,n[10]=f-v*h}else if(e.order==="XZY"){const f=o*c,p=o*d,x=l*c,v=l*d;n[0]=c*u,n[4]=-h,n[8]=d*u,n[1]=f*h+v,n[5]=o*u,n[9]=p*h-x,n[2]=x*h-p,n[6]=l*u,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(Q_e,e,Z_e)}lookAt(e,n,r){const i=this.elements;return No.subVectors(e,n),No.lengthSq()===0&&(No.z=1),No.normalize(),Zu.crossVectors(r,No),Zu.lengthSq()===0&&(Math.abs(r.z)===1?No.x+=1e-4:No.z+=1e-4,No.normalize(),Zu.crossVectors(r,No)),Zu.normalize(),DS.crossVectors(No,Zu),i[0]=Zu.x,i[4]=DS.x,i[8]=No.x,i[1]=Zu.y,i[5]=DS.y,i[9]=No.y,i[2]=Zu.z,i[6]=DS.z,i[10]=No.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){const r=e.elements,i=n.elements,s=this.elements,o=r[0],l=r[4],c=r[8],d=r[12],u=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],k=r[15],P=i[0],C=i[4],j=i[8],M=i[12],E=i[1],B=i[5],L=i[9],U=i[13],D=i[2],$=i[6],q=i[10],z=i[14],W=i[3],Q=i[7],te=i[11],H=i[15];return s[0]=o*P+l*E+c*D+d*W,s[4]=o*C+l*B+c*$+d*Q,s[8]=o*j+l*L+c*q+d*te,s[12]=o*M+l*U+c*z+d*H,s[1]=u*P+h*E+f*D+p*W,s[5]=u*C+h*B+f*$+p*Q,s[9]=u*j+h*L+f*q+p*te,s[13]=u*M+h*U+f*z+p*H,s[2]=x*P+v*E+g*D+y*W,s[6]=x*C+v*B+g*$+y*Q,s[10]=x*j+v*L+g*q+y*te,s[14]=x*M+v*U+g*z+y*H,s[3]=_*P+N*E+A*D+k*W,s[7]=_*C+N*B+A*$+k*Q,s[11]=_*j+N*L+A*q+k*te,s[15]=_*M+N*U+A*z+k*H,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[4]*=e,n[8]*=e,n[12]*=e,n[1]*=e,n[5]*=e,n[9]*=e,n[13]*=e,n[2]*=e,n[6]*=e,n[10]*=e,n[14]*=e,n[3]*=e,n[7]*=e,n[11]*=e,n[15]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[4],i=e[8],s=e[12],o=e[1],l=e[5],c=e[9],d=e[13],u=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*d*h-s*l*f+r*d*f+i*l*p-r*c*p)+v*(+n*c*p-n*d*f+s*o*f-i*o*p+i*d*u-s*c*u)+g*(+n*d*h-n*l*p-s*o*h+r*o*p+s*l*u-r*d*u)+y*(-i*l*u-n*c*h+n*l*f+i*o*h-r*o*f+r*c*u)}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],d=e[7],u=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*d-v*f*d+v*c*p-l*g*p-h*c*y+l*f*y,N=x*f*d-u*g*d-x*c*p+o*g*p+u*c*y-o*f*y,A=u*v*d-x*h*d+x*l*p-o*v*p-u*l*y+o*h*y,k=x*h*c-u*v*c-x*l*f+o*v*f+u*l*g-o*h*g,P=n*_+r*N+i*A+s*k;if(P===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const C=1/P;return e[0]=_*C,e[1]=(v*f*s-h*g*s-v*i*p+r*g*p+h*i*y-r*f*y)*C,e[2]=(l*g*s-v*c*s+v*i*d-r*g*d-l*i*y+r*c*y)*C,e[3]=(h*c*s-l*f*s-h*i*d+r*f*d+l*i*p-r*c*p)*C,e[4]=N*C,e[5]=(u*g*s-x*f*s+x*i*p-n*g*p-u*i*y+n*f*y)*C,e[6]=(x*c*s-o*g*s-x*i*d+n*g*d+o*i*y-n*c*y)*C,e[7]=(o*f*s-u*c*s+u*i*d-n*f*d-o*i*p+n*c*p)*C,e[8]=A*C,e[9]=(x*h*s-u*v*s-x*r*p+n*v*p+u*r*y-n*h*y)*C,e[10]=(o*v*s-x*l*s+x*r*d-n*v*d-o*r*y+n*l*y)*C,e[11]=(u*l*s-o*h*s-u*r*d+n*h*d+o*r*p-n*l*p)*C,e[12]=k*C,e[13]=(u*v*i-x*h*i+x*r*f-n*v*f-u*r*g+n*h*g)*C,e[14]=(x*l*i-o*v*i-x*r*c+n*v*c+o*r*g-n*l*g)*C,e[15]=(o*h*i-u*l*i+u*r*c-n*h*c-o*r*f+n*l*f)*C,this}scale(e){const n=this.elements,r=e.x,i=e.y,s=e.z;return n[0]*=r,n[4]*=i,n[8]*=s,n[1]*=r,n[5]*=i,n[9]*=s,n[2]*=r,n[6]*=i,n[10]*=s,n[3]*=r,n[7]*=i,n[11]*=s,this}getMaxScaleOnAxis(){const e=this.elements,n=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],r=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(n,r,i))}makeTranslation(e,n,r){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,n,0,0,1,r,0,0,0,1),this}makeRotationX(e){const n=Math.cos(e),r=Math.sin(e);return this.set(1,0,0,0,0,n,-r,0,0,r,n,0,0,0,0,1),this}makeRotationY(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,0,r,0,0,1,0,0,-r,0,n,0,0,0,0,1),this}makeRotationZ(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,-r,0,0,r,n,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,n){const r=Math.cos(n),i=Math.sin(n),s=1-r,o=e.x,l=e.y,c=e.z,d=s*o,u=s*l;return this.set(d*o+r,d*l-i*c,d*c+i*l,0,d*l+i*c,u*l+r,u*c-i*o,0,d*c-i*l,u*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,d=s+s,u=o+o,h=l+l,f=s*d,p=s*u,x=s*h,v=o*u,g=o*h,y=l*h,_=c*d,N=c*u,A=c*h,k=r.x,P=r.y,C=r.z;return i[0]=(1-(v+y))*k,i[1]=(p+A)*k,i[2]=(x-N)*k,i[3]=0,i[4]=(p-A)*P,i[5]=(1-(f+y))*P,i[6]=(g+_)*P,i[7]=0,i[8]=(x+N)*C,i[9]=(g-_)*C,i[10]=(1-(f+v))*C,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,n,r){const i=this.elements;let s=lg.set(i[0],i[1],i[2]).length();const o=lg.set(i[4],i[5],i[6]).length(),l=lg.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 d=1/s,u=1/o,h=1/l;return Il.elements[0]*=d,Il.elements[1]*=d,Il.elements[2]*=d,Il.elements[4]*=u,Il.elements[5]*=u,Il.elements[6]*=u,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){const c=this.elements,d=2*s/(n-e),u=2*s/(r-i),h=(n+e)/(n-e),f=(r+i)/(r-i);let p,x;if(l===Tc)p=-(o+s)/(o-s),x=-2*o*s/(o-s);else if(l===C0)p=-o/(o-s),x=-o*s/(o-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+l);return c[0]=d,c[4]=0,c[8]=h,c[12]=0,c[1]=0,c[5]=u,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=Tc){const c=this.elements,d=1/(n-e),u=1/(r-i),h=1/(o-s),f=(n+e)*d,p=(r+i)*u;let x,v;if(l===Tc)x=(o+s)*h,v=-2*h;else if(l===C0)x=s*h,v=-1*h;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+l);return c[0]=2*d,c[4]=0,c[8]=0,c[12]=-f,c[1]=0,c[5]=2*u,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 lg=new Je,Il=new ra,Q_e=new Je(0,0,0),Z_e=new Je(1,1,1),Zu=new Je,DS=new Je,No=new Je,H6=new ra,$6=new If;class mv{constructor(e=0,n=0,r=0,i=mv.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],d=i[5],u=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(-u,p),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(f,d),this._z=0);break;case"YXZ":this._x=Math.asin(-Ji(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(l,p),this._z=Math.atan2(c,d)):(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,d)):(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,d));break;case"YZX":this._z=Math.asin(Ji(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-u,d),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,d),this._y=Math.atan2(l,s)):(this._x=Math.atan2(-u,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 H6.makeRotationFromQuaternion(e),this.setFromRotationMatrix(H6,n,r)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return $6.setFromEuler(this),this.setFromQuaternion($6,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}}mv.DEFAULT_ORDER="XYZ";class HY{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 J_e=0;const V6=new Je,cg=new If,Sd=new ra,RS=new Je,dy=new Je,e1e=new Je,t1e=new If,q6=new Je(1,0,0),G6=new Je(0,1,0),W6=new Je(0,0,1),n1e={type:"added"},r1e={type:"removed"};class Fs extends np{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:J_e++}),this.uuid=Wd(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Fs.DEFAULT_UP.clone();const e=new Je,n=new mv,r=new If,i=new Je(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 ra},normalMatrix:{value:new Vn}}),this.matrix=new ra,this.matrixWorld=new ra,this.matrixAutoUpdate=Fs.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Fs.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new HY,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 cg.setFromAxisAngle(e,n),this.quaternion.multiply(cg),this}rotateOnWorldAxis(e,n){return cg.setFromAxisAngle(e,n),this.quaternion.premultiply(cg),this}rotateX(e){return this.rotateOnAxis(q6,e)}rotateY(e){return this.rotateOnAxis(G6,e)}rotateZ(e){return this.rotateOnAxis(W6,e)}translateOnAxis(e,n){return V6.copy(e).applyQuaternion(this.quaternion),this.position.add(V6.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(q6,e)}translateY(e){return this.translateOnAxis(G6,e)}translateZ(e){return this.translateOnAxis(W6,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Sd.copy(this.matrixWorld).invert())}lookAt(e,n,r){e.isVector3?RS.copy(e):RS.set(e,n,r);const i=this.parent;this.updateWorldMatrix(!0,!1),dy.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Sd.lookAt(dy,RS,this.up):Sd.lookAt(RS,dy,this.up),this.quaternion.setFromRotationMatrix(Sd),i&&(Sd.extractRotation(i.matrixWorld),cg.setFromRotationMatrix(Sd),this.quaternion.premultiply(cg.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(n1e)):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(r1e)),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),Sd.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Sd.multiply(e.parent.matrixWorld)),e.applyMatrix4(Sd),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(dy,e,e1e),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(dy,t1e,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 d=0,u=c.length;d<u;d++){const h=c[d];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,d=this.material.length;c<d;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),d=o(e.textures),u=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),d.length>0&&(r.textures=d),u.length>0&&(r.images=u),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 d in l){const u=l[d];delete u.metadata,c.push(u)}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}}Fs.DEFAULT_UP=new Je(0,1,0);Fs.DEFAULT_MATRIX_AUTO_UPDATE=!0;Fs.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const zl=new Je,_d=new Je,OP=new Je,Nd=new Je,dg=new Je,ug=new Je,K6=new Je,IP=new Je,zP=new Je,UP=new Je;let FS=!1;class Ul{constructor(e=new Je,n=new Je,r=new Je){this.a=e,this.b=n,this.c=r}static getNormal(e,n,r,i){i.subVectors(r,n),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),_d.subVectors(r,n),OP.subVectors(e,n);const o=zl.dot(zl),l=zl.dot(_d),c=zl.dot(OP),d=_d.dot(_d),u=_d.dot(OP),h=o*d-l*l;if(h===0)return s.set(-2,-1,-1);const f=1/h,p=(d*c-l*u)*f,x=(o*u-l*c)*f;return s.set(1-p-x,x,p)}static containsPoint(e,n,r,i){return this.getBarycoord(e,n,r,i,Nd),Nd.x>=0&&Nd.y>=0&&Nd.x+Nd.y<=1}static getUV(e,n,r,i,s,o,l,c){return FS===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),FS=!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,Nd),c.setScalar(0),c.addScaledVector(s,Nd.x),c.addScaledVector(o,Nd.y),c.addScaledVector(l,Nd.z),c}static isFrontFacing(e,n,r,i){return zl.subVectors(r,n),_d.subVectors(e,n),zl.cross(_d).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),_d.subVectors(this.a,this.b),zl.cross(_d).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Ul.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return Ul.getBarycoord(e,this.a,this.b,this.c,n)}getUV(e,n,r,i,s){return FS===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),FS=!0),Ul.getInterpolation(e,this.a,this.b,this.c,n,r,i,s)}getInterpolation(e,n,r,i,s){return Ul.getInterpolation(e,this.a,this.b,this.c,n,r,i,s)}containsPoint(e){return Ul.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Ul.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;dg.subVectors(i,r),ug.subVectors(s,r),IP.subVectors(e,r);const c=dg.dot(IP),d=ug.dot(IP);if(c<=0&&d<=0)return n.copy(r);zP.subVectors(e,i);const u=dg.dot(zP),h=ug.dot(zP);if(u>=0&&h<=u)return n.copy(i);const f=c*h-u*d;if(f<=0&&c>=0&&u<=0)return o=c/(c-u),n.copy(r).addScaledVector(dg,o);UP.subVectors(e,s);const p=dg.dot(UP),x=ug.dot(UP);if(x>=0&&p<=x)return n.copy(s);const v=p*d-c*x;if(v<=0&&d>=0&&x<=0)return l=d/(d-x),n.copy(r).addScaledVector(ug,l);const g=u*x-p*h;if(g<=0&&h-u>=0&&p-x>=0)return K6.subVectors(s,i),l=(h-u)/(h-u+(p-x)),n.copy(i).addScaledVector(K6,l);const y=1/(g+v+f);return o=v*y,l=f*y,n.copy(r).addScaledVector(dg,o).addScaledVector(ug,l)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const $Y={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},Ju={h:0,s:0,l:0},LS={h:0,s:0,l:0};function BP(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 hn=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,Br.toWorkingColorSpace(this,n),this}setRGB(e,n,r,i=Br.workingColorSpace){return this.r=e,this.g=n,this.b=r,Br.toWorkingColorSpace(this,i),this}setHSL(e,n,r,i=Br.workingColorSpace){if(e=nL(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=BP(o,s,e+1/3),this.g=BP(o,s,e),this.b=BP(o,s,e-1/3)}return Br.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=$Y[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=eb(e.r),this.g=eb(e.g),this.b=eb(e.b),this}copyLinearToSRGB(e){return this.r=MP(e.r),this.g=MP(e.g),this.b=MP(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Zi){return Br.fromWorkingColorSpace(us.copy(this),e),Math.round(Ji(us.r*255,0,255))*65536+Math.round(Ji(us.g*255,0,255))*256+Math.round(Ji(us.b*255,0,255))}getHexString(e=Zi){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=Br.workingColorSpace){Br.fromWorkingColorSpace(us.copy(this),n);const r=us.r,i=us.g,s=us.b,o=Math.max(r,i,s),l=Math.min(r,i,s);let c,d;const u=(l+o)/2;if(l===o)c=0,d=0;else{const h=o-l;switch(d=u<=.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=d,e.l=u,e}getRGB(e,n=Br.workingColorSpace){return Br.fromWorkingColorSpace(us.copy(this),n),e.r=us.r,e.g=us.g,e.b=us.b,e}getStyle(e=Zi){Br.fromWorkingColorSpace(us.copy(this),e);const n=us.r,r=us.g,i=us.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(Ju),this.setHSL(Ju.h+e,Ju.s+n,Ju.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(Ju),e.getHSL(LS);const r=$y(Ju.h,LS.h,n),i=$y(Ju.s,LS.s,n),s=$y(Ju.l,LS.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 us=new hn;hn.NAMES=$Y;let a1e=0;class Xb extends np{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:a1e++}),this.uuid=Wd(),this.name="",this.type="Material",this.blending=Jg,this.side=Xh,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=aD,this.blendDst=iD,this.blendEquation=Xm,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new hn(0,0,0),this.blendAlpha=0,this.depthFunc=E1,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=F6,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=rg,this.stencilZFail=rg,this.stencilZPass=rg,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const n in e){const r=e[n];if(r===void 0){console.warn(`THREE.Material: parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){console.warn(`THREE.Material: '${n}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(r):i&&i.isVector3&&r&&r.isVector3?i.copy(r):this[n]=r}}toJSON(e){const n=e===void 0||typeof e=="string";n&&(e={textures:{},images:{}});const r={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.color&&this.color.isColor&&(r.color=this.color.getHex()),this.roughness!==void 0&&(r.roughness=this.roughness),this.metalness!==void 0&&(r.metalness=this.metalness),this.sheen!==void 0&&(r.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(r.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(r.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(r.emissive=this.emissive.getHex()),this.emissiveIntensity&&this.emissiveIntensity!==1&&(r.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(r.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(r.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(r.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(r.shininess=this.shininess),this.clearcoat!==void 0&&(r.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(r.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(r.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(r.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(r.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,r.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.iridescence!==void 0&&(r.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(r.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(r.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(r.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(r.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(r.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(r.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(r.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(r.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(r.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(r.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(r.lightMap=this.lightMap.toJSON(e).uuid,r.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(r.aoMap=this.aoMap.toJSON(e).uuid,r.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(r.bumpMap=this.bumpMap.toJSON(e).uuid,r.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(r.normalMap=this.normalMap.toJSON(e).uuid,r.normalMapType=this.normalMapType,r.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(r.displacementMap=this.displacementMap.toJSON(e).uuid,r.displacementScale=this.displacementScale,r.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(r.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(r.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(r.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(r.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(r.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(r.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(r.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(r.combine=this.combine)),this.envMapIntensity!==void 0&&(r.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(r.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(r.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(r.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(r.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(r.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(r.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(r.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(r.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(r.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(r.size=this.size),this.shadowSide!==null&&(r.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(r.sizeAttenuation=this.sizeAttenuation),this.blending!==Jg&&(r.blending=this.blending),this.side!==Xh&&(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!==aD&&(r.blendSrc=this.blendSrc),this.blendDst!==iD&&(r.blendDst=this.blendDst),this.blendEquation!==Xm&&(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!==E1&&(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!==F6&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==rg&&(r.stencilFail=this.stencilFail),this.stencilZFail!==rg&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==rg&&(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 VY extends Xb{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new hn(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=JF,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 Za=new Je,OS=new Nn;class Do{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=dD,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=Ud,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++)OS.fromBufferAttribute(this,n),OS.applyMatrix3(e),this.setXY(n,OS.x,OS.y);else if(this.itemSize===3)for(let n=0,r=this.count;n<r;n++)Za.fromBufferAttribute(this,n),Za.applyMatrix3(e),this.setXYZ(n,Za.x,Za.y,Za.z);return this}applyMatrix4(e){for(let n=0,r=this.count;n<r;n++)Za.fromBufferAttribute(this,n),Za.applyMatrix4(e),this.setXYZ(n,Za.x,Za.y,Za.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)Za.fromBufferAttribute(this,n),Za.applyNormalMatrix(e),this.setXYZ(n,Za.x,Za.y,Za.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)Za.fromBufferAttribute(this,n),Za.transformDirection(e),this.setXYZ(n,Za.x,Za.y,Za.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=Ur(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=Ur(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=Ur(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=Ur(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=Ur(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,r){return e*=this.itemSize,this.normalized&&(n=Ur(n,this.array),r=Ur(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=Ur(n,this.array),r=Ur(r,this.array),i=Ur(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=Ur(n,this.array),r=Ur(r,this.array),i=Ur(i,this.array),s=Ur(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!==dD&&(e.usage=this.usage),e}}class qY extends Do{constructor(e,n,r){super(new Uint16Array(e),n,r)}}class GY extends Do{constructor(e,n,r){super(new Uint32Array(e),n,r)}}class qa extends Do{constructor(e,n,r){super(new Float32Array(e),n,r)}}let i1e=0;const Yo=new ra,HP=new Fs,hg=new Je,Co=new bl,uy=new bl,Ti=new Je;class ws extends np{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:i1e++}),this.uuid=Wd(),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(IY(e)?GY:qY)(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 Vn().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 Yo.makeRotationFromQuaternion(e),this.applyMatrix4(Yo),this}rotateX(e){return Yo.makeRotationX(e),this.applyMatrix4(Yo),this}rotateY(e){return Yo.makeRotationY(e),this.applyMatrix4(Yo),this}rotateZ(e){return Yo.makeRotationZ(e),this.applyMatrix4(Yo),this}translate(e,n,r){return Yo.makeTranslation(e,n,r),this.applyMatrix4(Yo),this}scale(e,n,r){return Yo.makeScale(e,n,r),this.applyMatrix4(Yo),this}lookAt(e){return HP.lookAt(e),HP.updateMatrix(),this.applyMatrix4(HP.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(hg).negate(),this.translate(hg.x,hg.y,hg.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 qa(n,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new bl);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 Je(-1/0,-1/0,-1/0),new Je(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),n)for(let r=0,i=n.length;r<i;r++){const s=n[r];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 Dc);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 Je,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];uy.setFromBufferAttribute(l),this.morphTargetsRelative?(Ti.addVectors(Co.min,uy.min),Co.expandByPoint(Ti),Ti.addVectors(Co.max,uy.max),Co.expandByPoint(Ti)):(Co.expandByPoint(uy.min),Co.expandByPoint(uy.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 d=0,u=l.count;d<u;d++)Ti.fromBufferAttribute(l,d),c&&(hg.fromBufferAttribute(e,d),Ti.add(hg)),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 Do(new Float32Array(4*l),4));const c=this.getAttribute("tangent").array,d=[],u=[];for(let E=0;E<l;E++)d[E]=new Je,u[E]=new Je;const h=new Je,f=new Je,p=new Je,x=new Nn,v=new Nn,g=new Nn,y=new Je,_=new Je;function N(E,B,L){h.fromArray(i,E*3),f.fromArray(i,B*3),p.fromArray(i,L*3),x.fromArray(o,E*2),v.fromArray(o,B*2),g.fromArray(o,L*2),f.sub(h),p.sub(h),v.sub(x),g.sub(x);const U=1/(v.x*g.y-g.x*v.y);isFinite(U)&&(y.copy(f).multiplyScalar(g.y).addScaledVector(p,-v.y).multiplyScalar(U),_.copy(p).multiplyScalar(v.x).addScaledVector(f,-g.x).multiplyScalar(U),d[E].add(y),d[B].add(y),d[L].add(y),u[E].add(_),u[B].add(_),u[L].add(_))}let A=this.groups;A.length===0&&(A=[{start:0,count:r.length}]);for(let E=0,B=A.length;E<B;++E){const L=A[E],U=L.start,D=L.count;for(let $=U,q=U+D;$<q;$+=3)N(r[$+0],r[$+1],r[$+2])}const k=new Je,P=new Je,C=new Je,j=new Je;function M(E){C.fromArray(s,E*3),j.copy(C);const B=d[E];k.copy(B),k.sub(C.multiplyScalar(C.dot(B))).normalize(),P.crossVectors(j,B);const U=P.dot(u[E])<0?-1:1;c[E*4]=k.x,c[E*4+1]=k.y,c[E*4+2]=k.z,c[E*4+3]=U}for(let E=0,B=A.length;E<B;++E){const L=A[E],U=L.start,D=L.count;for(let $=U,q=U+D;$<q;$+=3)M(r[$+0]),M(r[$+1]),M(r[$+2])}}computeVertexNormals(){const e=this.index,n=this.getAttribute("position");if(n!==void 0){let r=this.getAttribute("normal");if(r===void 0)r=new Do(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 Je,s=new Je,o=new Je,l=new Je,c=new Je,d=new Je,u=new Je,h=new Je;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),u.subVectors(o,s),h.subVectors(i,s),u.cross(h),l.fromBufferAttribute(r,x),c.fromBufferAttribute(r,v),d.fromBufferAttribute(r,g),l.add(u),c.add(u),d.add(u),r.setXYZ(x,l.x,l.y,l.z),r.setXYZ(v,c.x,c.y,c.z),r.setXYZ(g,d.x,d.y,d.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),u.subVectors(o,s),h.subVectors(i,s),u.cross(h),r.setXYZ(f+0,u.x,u.y,u.z),r.setXYZ(f+1,u.x,u.y,u.z),r.setXYZ(f+2,u.x,u.y,u.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 d=l.array,u=l.itemSize,h=l.normalized,f=new d.constructor(c.length*u);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]*u;for(let y=0;y<u;y++)f[x++]=d[p++]}return new Do(f,u,h)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new ws,r=this.index.array,i=this.attributes;for(const l in i){const c=i[l],d=e(c,r);n.setAttribute(l,d)}const s=this.morphAttributes;for(const l in s){const c=[],d=s[l];for(let u=0,h=d.length;u<h;u++){const f=d[u],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 d=o[l];n.addGroup(d.start,d.count,d.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 d in c)c[d]!==void 0&&(e[d]=c[d]);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 d=r[c];e.data.attributes[c]=d.toJSON(e.data)}const i={};let s=!1;for(const c in this.morphAttributes){const d=this.morphAttributes[c],u=[];for(let h=0,f=d.length;h<f;h++){const p=d[h];u.push(p.toJSON(e.data))}u.length>0&&(i[c]=u,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 d in i){const u=i[d];this.setAttribute(d,u.clone(n))}const s=e.morphAttributes;for(const d in s){const u=[],h=s[d];for(let f=0,p=h.length;f<p;f++)u.push(h[f].clone(n));this.morphAttributes[d]=u}this.morphTargetsRelative=e.morphTargetsRelative;const o=e.groups;for(let d=0,u=o.length;d<u;d++){const h=o[d];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 X6=new ra,Fm=new rL,IS=new Dc,Y6=new Je,mg=new Je,fg=new Je,pg=new Je,$P=new Je,zS=new Je,US=new Nn,BS=new Nn,HS=new Nn,Q6=new Je,Z6=new Je,J6=new Je,$S=new Je,VS=new Je;class Wl extends Fs{constructor(e=new ws,n=new VY){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){zS.set(0,0,0);for(let c=0,d=s.length;c<d;c++){const u=l[c],h=s[c];u!==0&&($P.fromBufferAttribute(h,e),o?zS.addScaledVector($P,u):zS.addScaledVector($P.sub(n),u))}n.add(zS)}return n}raycast(e,n){const r=this.geometry,i=this.material,s=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),IS.copy(r.boundingSphere),IS.applyMatrix4(s),Fm.copy(e.ray).recast(e.near),!(IS.containsPoint(Fm.origin)===!1&&(Fm.intersectSphere(IS,Y6)===null||Fm.origin.distanceToSquared(Y6)>(e.far-e.near)**2))&&(X6.copy(s).invert(),Fm.copy(e.ray).applyMatrix4(X6),!(r.boundingBox!==null&&Fm.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,n,Fm)))}_computeIntersections(e,n,r){let i;const s=this.geometry,o=this.material,l=s.index,c=s.attributes.position,d=s.attributes.uv,u=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=_,k=N;A<k;A+=3){const P=l.getX(A),C=l.getX(A+1),j=l.getX(A+2);i=qS(this,y,e,r,d,u,h,P,C,j),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=qS(this,o,e,r,d,u,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=_,k=N;A<k;A+=3){const P=A,C=A+1,j=A+2;i=qS(this,y,e,r,d,u,h,P,C,j),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=qS(this,o,e,r,d,u,h,_,N,A),i&&(i.faceIndex=Math.floor(g/3),n.push(i))}}}}function s1e(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===Xh,l),c===null)return null;VS.copy(l),VS.applyMatrix4(t.matrixWorld);const d=n.ray.origin.distanceTo(VS);return d<n.near||d>n.far?null:{distance:d,point:VS.clone(),object:t}}function qS(t,e,n,r,i,s,o,l,c,d){t.getVertexPosition(l,mg),t.getVertexPosition(c,fg),t.getVertexPosition(d,pg);const u=s1e(t,e,n,r,mg,fg,pg,$S);if(u){i&&(US.fromBufferAttribute(i,l),BS.fromBufferAttribute(i,c),HS.fromBufferAttribute(i,d),u.uv=Ul.getInterpolation($S,mg,fg,pg,US,BS,HS,new Nn)),s&&(US.fromBufferAttribute(s,l),BS.fromBufferAttribute(s,c),HS.fromBufferAttribute(s,d),u.uv1=Ul.getInterpolation($S,mg,fg,pg,US,BS,HS,new Nn),u.uv2=u.uv1),o&&(Q6.fromBufferAttribute(o,l),Z6.fromBufferAttribute(o,c),J6.fromBufferAttribute(o,d),u.normal=Ul.getInterpolation($S,mg,fg,pg,Q6,Z6,J6,new Je),u.normal.dot(r.direction)>0&&u.normal.multiplyScalar(-1));const h={a:l,b:c,c:d,normal:new Je,materialIndex:0};Ul.getNormal(mg,fg,pg,h.normal),u.face=h}return u}class fv extends ws{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=[],d=[],u=[],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 qa(d,3)),this.setAttribute("normal",new qa(u,3)),this.setAttribute("uv",new qa(h,2));function x(v,g,y,_,N,A,k,P,C,j,M){const E=A/C,B=k/j,L=A/2,U=k/2,D=P/2,$=C+1,q=j+1;let z=0,W=0;const Q=new Je;for(let te=0;te<q;te++){const H=te*B-U;for(let X=0;X<$;X++){const Z=X*E-L;Q[v]=Z*_,Q[g]=H*N,Q[y]=D,d.push(Q.x,Q.y,Q.z),Q[v]=0,Q[g]=0,Q[y]=P>0?1:-1,u.push(Q.x,Q.y,Q.z),h.push(X/C),h.push(1-te/j),z+=1}}for(let te=0;te<j;te++)for(let H=0;H<C;H++){const X=f+H+$*te,Z=f+H+$*(te+1),ee=f+(H+1)+$*(te+1),Se=f+(H+1)+$*te;c.push(X,Z,Se),c.push(Z,ee,Se),W+=6}l.addGroup(p,W,M),p+=W,f+=z}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new fv(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function Sb(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 Ts(t){const e={};for(let n=0;n<t.length;n++){const r=Sb(t[n]);for(const i in r)e[i]=r[i]}return e}function o1e(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function WY(t){return t.getRenderTarget()===null?t.outputColorSpace:Br.workingColorSpace}const aL={clone:Sb,merge:Ts};var l1e=`void main() {
- gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
- }`,c1e=`void main() {
- gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
- }`;class Yh extends Xb{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=l1e,this.fragmentShader=c1e,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=Sb(e.uniforms),this.uniformsGroups=o1e(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 KY extends Fs{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new ra,this.projectionMatrix=new ra,this.projectionMatrixInverse=new ra,this.coordinateSystem=Tc}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 Ao extends KY{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=k0*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Hy*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return k0*2*Math.atan(Math.tan(Hy*.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(Hy*.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,d=o.fullHeight;s+=o.offsetX*i/c,n-=o.offsetY*r/d,i*=o.width/c,r*=o.height/d}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 gg=-90,bg=1;class d1e extends Fs{constructor(e,n,r){super(),this.type="CubeCamera",this.renderTarget=r,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new Ao(gg,bg,e,n);i.layers=this.layers,this.add(i);const s=new Ao(gg,bg,e,n);s.layers=this.layers,this.add(s);const o=new Ao(gg,bg,e,n);o.layers=this.layers,this.add(o);const l=new Ao(gg,bg,e,n);l.layers=this.layers,this.add(l);const c=new Ao(gg,bg,e,n);c.layers=this.layers,this.add(c);const d=new Ao(gg,bg,e,n);d.layers=this.layers,this.add(d)}updateCoordinateSystem(){const e=this.coordinateSystem,n=this.children.concat(),[r,i,s,o,l,c]=n;for(const d of n)this.remove(d);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===C0)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 d of n)this.add(d),d.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,d,u]=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,d),r.texture.generateMipmaps=v,e.setRenderTarget(r,5,i),e.render(n,u),e.setRenderTarget(h,f,p),e.xr.enabled=x,r.texture.needsPMREMUpdate=!0}}class XY extends io{constructor(e,n,r,i,s,o,l,c,d,u){e=e!==void 0?e:[],n=n!==void 0?n:yb,super(e,n,r,i,s,o,l,c,d,u),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class u1e extends Of{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&&(Vy("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),n.colorSpace=n.encoding===pf?Zi:ul),this.texture=new XY(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:cl}fromEquirectangularTexture(e,n){this.texture.type=n.type,this.texture.colorSpace=n.colorSpace,this.texture.generateMipmaps=n.generateMipmaps,this.texture.minFilter=n.minFilter,this.texture.magFilter=n.magFilter;const r={uniforms:{tEquirect:{value:null}},vertexShader:`
- varying vec3 vWorldDirection;
- vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
- return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
- }
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- }
- `,fragmentShader:`
- uniform sampler2D tEquirect;
- varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vec3 direction = normalize( vWorldDirection );
- vec2 sampleUV = equirectUv( direction );
- gl_FragColor = texture2D( tEquirect, sampleUV );
- }
- `},i=new fv(5,5,5),s=new Yh({name:"CubemapFromEquirect",uniforms:Sb(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:ao,blending:Lh});s.uniforms.tEquirect.value=n;const o=new Wl(i,s),l=n.minFilter;return n.minFilter===_0&&(n.minFilter=cl),new d1e(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 VP=new Je,h1e=new Je,m1e=new Vn;class oh{constructor(e=new Je(1,0,0),n=0){this.isPlane=!0,this.normal=e,this.constant=n}set(e,n){return this.normal.copy(e),this.constant=n,this}setComponents(e,n,r,i){return this.normal.set(e,n,r),this.constant=i,this}setFromNormalAndCoplanarPoint(e,n){return this.normal.copy(e),this.constant=-n.dot(this.normal),this}setFromCoplanarPoints(e,n,r){const i=VP.subVectors(r,n).cross(h1e.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(VP),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||m1e.getNormalMatrix(e),i=this.coplanarPoint(VP).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 Lm=new Dc,GS=new Je;class ck{constructor(e=new oh,n=new oh,r=new oh,i=new oh,s=new oh,o=new oh){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){const r=this.planes,i=e.elements,s=i[0],o=i[1],l=i[2],c=i[3],d=i[4],u=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-d,g-p,A-y).normalize(),r[1].setComponents(c+s,f+d,g+p,A+y).normalize(),r[2].setComponents(c+o,f+u,g+x,A+_).normalize(),r[3].setComponents(c-o,f-u,g-x,A-_).normalize(),r[4].setComponents(c-l,f-h,g-v,A-N).normalize(),n===Tc)r[5].setComponents(c+l,f+h,g+v,A+N).normalize();else if(n===C0)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(),Lm.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),Lm.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Lm)}intersectsSprite(e){return Lm.center.set(0,0,0),Lm.radius=.7071067811865476,Lm.applyMatrix4(e.matrixWorld),this.intersectsSphere(Lm)}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(GS.x=i.normal.x>0?e.max.x:e.min.x,GS.y=i.normal.y>0?e.max.y:e.min.y,GS.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(GS)<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 YY(){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 f1e(t,e){const n=e.isWebGL2,r=new WeakMap;function i(d,u){const h=d.array,f=d.usage,p=h.byteLength,x=t.createBuffer();t.bindBuffer(u,x),t.bufferData(u,h,f),d.onUploadCallback();let v;if(h instanceof Float32Array)v=t.FLOAT;else if(h instanceof Uint16Array)if(d.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:d.version,size:p}}function s(d,u,h){const f=u.array,p=u._updateRange,x=u.updateRanges;if(t.bindBuffer(h,d),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))}u.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),u.onUploadCallback()}function o(d){return d.isInterleavedBufferAttribute&&(d=d.data),r.get(d)}function l(d){d.isInterleavedBufferAttribute&&(d=d.data);const u=r.get(d);u&&(t.deleteBuffer(u.buffer),r.delete(d))}function c(d,u){if(d.isGLBufferAttribute){const f=r.get(d);(!f||f.version<d.version)&&r.set(d,{buffer:d.buffer,type:d.type,bytesPerElement:d.elementSize,version:d.version});return}d.isInterleavedBufferAttribute&&(d=d.data);const h=r.get(d);if(h===void 0)r.set(d,i(d,u));else if(h.version<d.version){if(h.size!==d.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,d,u),h.version=d.version}}return{get:o,remove:l,update:c}}class iL extends ws{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),d=l+1,u=c+1,h=e/l,f=n/c,p=[],x=[],v=[],g=[];for(let y=0;y<u;y++){const _=y*f-o;for(let N=0;N<d;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=_+d*y,A=_+d*(y+1),k=_+1+d*(y+1),P=_+1+d*y;p.push(N,A,P),p.push(A,k,P)}this.setIndex(p),this.setAttribute("position",new qa(x,3)),this.setAttribute("normal",new qa(v,3)),this.setAttribute("uv",new qa(g,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new iL(e.width,e.height,e.widthSegments,e.heightSegments)}}var p1e=`#ifdef USE_ALPHAHASH
- if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
- #endif`,g1e=`#ifdef USE_ALPHAHASH
- const float ALPHA_HASH_SCALE = 0.05;
- float hash2D( vec2 value ) {
- return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
- }
- float hash3D( vec3 value ) {
- return hash2D( vec2( hash2D( value.xy ), value.z ) );
- }
- float getAlphaHashThreshold( vec3 position ) {
- float maxDeriv = max(
- length( dFdx( position.xyz ) ),
- length( dFdy( position.xyz ) )
- );
- float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
- vec2 pixScales = vec2(
- exp2( floor( log2( pixScale ) ) ),
- exp2( ceil( log2( pixScale ) ) )
- );
- vec2 alpha = vec2(
- hash3D( floor( pixScales.x * position.xyz ) ),
- hash3D( floor( pixScales.y * position.xyz ) )
- );
- float lerpFactor = fract( log2( pixScale ) );
- float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
- float a = min( lerpFactor, 1.0 - lerpFactor );
- vec3 cases = vec3(
- x * x / ( 2.0 * a * ( 1.0 - a ) ),
- ( x - 0.5 * a ) / ( 1.0 - a ),
- 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
- );
- float threshold = ( x < ( 1.0 - a ) )
- ? ( ( x < a ) ? cases.x : cases.y )
- : cases.z;
- return clamp( threshold , 1.0e-6, 1.0 );
- }
- #endif`,b1e=`#ifdef USE_ALPHAMAP
- diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
- #endif`,x1e=`#ifdef USE_ALPHAMAP
- uniform sampler2D alphaMap;
- #endif`,y1e=`#ifdef USE_ALPHATEST
- if ( diffuseColor.a < alphaTest ) discard;
- #endif`,v1e=`#ifdef USE_ALPHATEST
- uniform float alphaTest;
- #endif`,w1e=`#ifdef USE_AOMAP
- float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
- reflectedLight.indirectDiffuse *= ambientOcclusion;
- #if defined( USE_CLEARCOAT )
- clearcoatSpecularIndirect *= ambientOcclusion;
- #endif
- #if defined( USE_SHEEN )
- sheenSpecularIndirect *= ambientOcclusion;
- #endif
- #if defined( USE_ENVMAP ) && defined( STANDARD )
- float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
- reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
- #endif
- #endif`,S1e=`#ifdef USE_AOMAP
- uniform sampler2D aoMap;
- uniform float aoMapIntensity;
- #endif`,_1e=`#ifdef USE_BATCHING
- attribute float batchId;
- uniform highp sampler2D batchingTexture;
- mat4 getBatchingMatrix( const in float i ) {
- int size = textureSize( batchingTexture, 0 ).x;
- int j = int( i ) * 4;
- int x = j % size;
- int y = j / size;
- vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
- vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
- vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
- vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
- return mat4( v1, v2, v3, v4 );
- }
- #endif`,N1e=`#ifdef USE_BATCHING
- mat4 batchingMatrix = getBatchingMatrix( batchId );
- #endif`,C1e=`vec3 transformed = vec3( position );
- #ifdef USE_ALPHAHASH
- vPosition = vec3( position );
- #endif`,k1e=`vec3 objectNormal = vec3( normal );
- #ifdef USE_TANGENT
- vec3 objectTangent = vec3( tangent.xyz );
- #endif`,A1e=`float G_BlinnPhong_Implicit( ) {
- return 0.25;
- }
- float D_BlinnPhong( const in float shininess, const in float dotNH ) {
- return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
- }
- vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNH = saturate( dot( normal, halfDir ) );
- float dotVH = saturate( dot( viewDir, halfDir ) );
- vec3 F = F_Schlick( specularColor, 1.0, dotVH );
- float G = G_BlinnPhong_Implicit( );
- float D = D_BlinnPhong( shininess, dotNH );
- return F * ( G * D );
- } // validated`,T1e=`#ifdef USE_IRIDESCENCE
- const mat3 XYZ_TO_REC709 = mat3(
- 3.2404542, -0.9692660, 0.0556434,
- -1.5371385, 1.8760108, -0.2040259,
- -0.4985314, 0.0415560, 1.0572252
- );
- vec3 Fresnel0ToIor( vec3 fresnel0 ) {
- vec3 sqrtF0 = sqrt( fresnel0 );
- return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
- }
- vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
- return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
- }
- float IorToFresnel0( float transmittedIor, float incidentIor ) {
- return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
- }
- vec3 evalSensitivity( float OPD, vec3 shift ) {
- float phase = 2.0 * PI * OPD * 1.0e-9;
- vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
- vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
- vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
- vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
- xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );
- xyz /= 1.0685e-7;
- vec3 rgb = XYZ_TO_REC709 * xyz;
- return rgb;
- }
- vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
- vec3 I;
- float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
- float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
- float cosTheta2Sq = 1.0 - sinTheta2Sq;
- if ( cosTheta2Sq < 0.0 ) {
- return vec3( 1.0 );
- }
- float cosTheta2 = sqrt( cosTheta2Sq );
- float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
- float R12 = F_Schlick( R0, 1.0, cosTheta1 );
- float T121 = 1.0 - R12;
- float phi12 = 0.0;
- if ( iridescenceIOR < outsideIOR ) phi12 = PI;
- float phi21 = PI - phi12;
- vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
- vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
- vec3 phi23 = vec3( 0.0 );
- if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
- if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
- if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
- float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
- vec3 phi = vec3( phi21 ) + phi23;
- vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
- vec3 r123 = sqrt( R123 );
- vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
- vec3 C0 = R12 + Rs;
- I = C0;
- vec3 Cm = Rs - T121;
- for ( int m = 1; m <= 2; ++ m ) {
- Cm *= r123;
- vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
- I += Cm * Sm;
- }
- return max( I, vec3( 0.0 ) );
- }
- #endif`,M1e=`#ifdef USE_BUMPMAP
- uniform sampler2D bumpMap;
- uniform float bumpScale;
- vec2 dHdxy_fwd() {
- vec2 dSTdx = dFdx( vBumpMapUv );
- vec2 dSTdy = dFdy( vBumpMapUv );
- float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
- float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
- float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
- return vec2( dBx, dBy );
- }
- vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
- vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
- vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
- vec3 vN = surf_norm;
- vec3 R1 = cross( vSigmaY, vN );
- vec3 R2 = cross( vN, vSigmaX );
- float fDet = dot( vSigmaX, R1 ) * faceDirection;
- vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
- return normalize( abs( fDet ) * surf_norm - vGrad );
- }
- #endif`,P1e=`#if NUM_CLIPPING_PLANES > 0
- vec4 plane;
- #pragma unroll_loop_start
- for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
- plane = clippingPlanes[ i ];
- if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
- }
- #pragma unroll_loop_end
- #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
- bool clipped = true;
- #pragma unroll_loop_start
- for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
- plane = clippingPlanes[ i ];
- clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
- }
- #pragma unroll_loop_end
- if ( clipped ) discard;
- #endif
- #endif`,E1e=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
- #endif`,j1e=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- #endif`,D1e=`#if NUM_CLIPPING_PLANES > 0
- vClipPosition = - mvPosition.xyz;
- #endif`,R1e=`#if defined( USE_COLOR_ALPHA )
- diffuseColor *= vColor;
- #elif defined( USE_COLOR )
- diffuseColor.rgb *= vColor;
- #endif`,F1e=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR )
- varying vec3 vColor;
- #endif`,L1e=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
- varying vec3 vColor;
- #endif`,O1e=`#if defined( USE_COLOR_ALPHA )
- vColor = vec4( 1.0 );
- #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
- vColor = vec3( 1.0 );
- #endif
- #ifdef USE_COLOR
- vColor *= color;
- #endif
- #ifdef USE_INSTANCING_COLOR
- vColor.xyz *= instanceColor.xyz;
- #endif`,I1e=`#define PI 3.141592653589793
- #define PI2 6.283185307179586
- #define PI_HALF 1.5707963267948966
- #define RECIPROCAL_PI 0.3183098861837907
- #define RECIPROCAL_PI2 0.15915494309189535
- #define EPSILON 1e-6
- #ifndef saturate
- #define saturate( a ) clamp( a, 0.0, 1.0 )
- #endif
- #define whiteComplement( a ) ( 1.0 - saturate( a ) )
- float pow2( const in float x ) { return x*x; }
- vec3 pow2( const in vec3 x ) { return x*x; }
- float pow3( const in float x ) { return x*x*x; }
- float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
- float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
- float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
- highp float rand( const in vec2 uv ) {
- const highp float a = 12.9898, b = 78.233, c = 43758.5453;
- highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
- return fract( sin( sn ) * c );
- }
- #ifdef HIGH_PRECISION
- float precisionSafeLength( vec3 v ) { return length( v ); }
- #else
- float precisionSafeLength( vec3 v ) {
- float maxComponent = max3( abs( v ) );
- return length( v / maxComponent ) * maxComponent;
- }
- #endif
- struct IncidentLight {
- vec3 color;
- vec3 direction;
- bool visible;
- };
- struct ReflectedLight {
- vec3 directDiffuse;
- vec3 directSpecular;
- vec3 indirectDiffuse;
- vec3 indirectSpecular;
- };
- #ifdef USE_ALPHAHASH
- varying vec3 vPosition;
- #endif
- vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
- return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
- }
- vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
- return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
- }
- mat3 transposeMat3( const in mat3 m ) {
- mat3 tmp;
- tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
- tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
- tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
- return tmp;
- }
- float luminance( const in vec3 rgb ) {
- const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );
- return dot( weights, rgb );
- }
- bool isPerspectiveMatrix( mat4 m ) {
- return m[ 2 ][ 3 ] == - 1.0;
- }
- vec2 equirectUv( in vec3 dir ) {
- float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
- float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
- return vec2( u, v );
- }
- vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
- return RECIPROCAL_PI * diffuseColor;
- }
- vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
- float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
- return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
- }
- float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
- float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
- return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
- } // validated`,z1e=`#ifdef ENVMAP_TYPE_CUBE_UV
- #define cubeUV_minMipLevel 4.0
- #define cubeUV_minTileSize 16.0
- float getFace( vec3 direction ) {
- vec3 absDirection = abs( direction );
- float face = - 1.0;
- if ( absDirection.x > absDirection.z ) {
- if ( absDirection.x > absDirection.y )
- face = direction.x > 0.0 ? 0.0 : 3.0;
- else
- face = direction.y > 0.0 ? 1.0 : 4.0;
- } else {
- if ( absDirection.z > absDirection.y )
- face = direction.z > 0.0 ? 2.0 : 5.0;
- else
- face = direction.y > 0.0 ? 1.0 : 4.0;
- }
- return face;
- }
- vec2 getUV( vec3 direction, float face ) {
- vec2 uv;
- if ( face == 0.0 ) {
- uv = vec2( direction.z, direction.y ) / abs( direction.x );
- } else if ( face == 1.0 ) {
- uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
- } else if ( face == 2.0 ) {
- uv = vec2( - direction.x, direction.y ) / abs( direction.z );
- } else if ( face == 3.0 ) {
- uv = vec2( - direction.z, direction.y ) / abs( direction.x );
- } else if ( face == 4.0 ) {
- uv = vec2( - direction.x, direction.z ) / abs( direction.y );
- } else {
- uv = vec2( direction.x, direction.y ) / abs( direction.z );
- }
- return 0.5 * ( uv + 1.0 );
- }
- vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
- float face = getFace( direction );
- float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
- mipInt = max( mipInt, cubeUV_minMipLevel );
- float faceSize = exp2( mipInt );
- highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
- if ( face > 2.0 ) {
- uv.y += faceSize;
- face -= 3.0;
- }
- uv.x += face * faceSize;
- uv.x += filterInt * 3.0 * cubeUV_minTileSize;
- uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
- uv.x *= CUBEUV_TEXEL_WIDTH;
- uv.y *= CUBEUV_TEXEL_HEIGHT;
- #ifdef texture2DGradEXT
- return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
- #else
- return texture2D( envMap, uv ).rgb;
- #endif
- }
- #define cubeUV_r0 1.0
- #define cubeUV_v0 0.339
- #define cubeUV_m0 - 2.0
- #define cubeUV_r1 0.8
- #define cubeUV_v1 0.276
- #define cubeUV_m1 - 1.0
- #define cubeUV_r4 0.4
- #define cubeUV_v4 0.046
- #define cubeUV_m4 2.0
- #define cubeUV_r5 0.305
- #define cubeUV_v5 0.016
- #define cubeUV_m5 3.0
- #define cubeUV_r6 0.21
- #define cubeUV_v6 0.0038
- #define cubeUV_m6 4.0
- float roughnessToMip( float roughness ) {
- float mip = 0.0;
- if ( roughness >= cubeUV_r1 ) {
- mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
- } else if ( roughness >= cubeUV_r4 ) {
- mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
- } else if ( roughness >= cubeUV_r5 ) {
- mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
- } else if ( roughness >= cubeUV_r6 ) {
- mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
- } else {
- mip = - 2.0 * log2( 1.16 * roughness ); }
- return mip;
- }
- vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
- float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
- float mipF = fract( mip );
- float mipInt = floor( mip );
- vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
- if ( mipF == 0.0 ) {
- return vec4( color0, 1.0 );
- } else {
- vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
- return vec4( mix( color0, color1, mipF ), 1.0 );
- }
- }
- #endif`,U1e=`vec3 transformedNormal = objectNormal;
- #ifdef USE_TANGENT
- vec3 transformedTangent = objectTangent;
- #endif
- #ifdef USE_BATCHING
- mat3 bm = mat3( batchingMatrix );
- transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
- transformedNormal = bm * transformedNormal;
- #ifdef USE_TANGENT
- transformedTangent = bm * transformedTangent;
- #endif
- #endif
- #ifdef USE_INSTANCING
- mat3 im = mat3( instanceMatrix );
- transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
- transformedNormal = im * transformedNormal;
- #ifdef USE_TANGENT
- transformedTangent = im * transformedTangent;
- #endif
- #endif
- transformedNormal = normalMatrix * transformedNormal;
- #ifdef FLIP_SIDED
- transformedNormal = - transformedNormal;
- #endif
- #ifdef USE_TANGENT
- transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
- #ifdef FLIP_SIDED
- transformedTangent = - transformedTangent;
- #endif
- #endif`,B1e=`#ifdef USE_DISPLACEMENTMAP
- uniform sampler2D displacementMap;
- uniform float displacementScale;
- uniform float displacementBias;
- #endif`,H1e=`#ifdef USE_DISPLACEMENTMAP
- transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
- #endif`,$1e=`#ifdef USE_EMISSIVEMAP
- vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
- totalEmissiveRadiance *= emissiveColor.rgb;
- #endif`,V1e=`#ifdef USE_EMISSIVEMAP
- uniform sampler2D emissiveMap;
- #endif`,q1e="gl_FragColor = linearToOutputTexel( gl_FragColor );",G1e=`
- const mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3(
- vec3( 0.8224621, 0.177538, 0.0 ),
- vec3( 0.0331941, 0.9668058, 0.0 ),
- vec3( 0.0170827, 0.0723974, 0.9105199 )
- );
- const mat3 LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = mat3(
- vec3( 1.2249401, - 0.2249404, 0.0 ),
- vec3( - 0.0420569, 1.0420571, 0.0 ),
- vec3( - 0.0196376, - 0.0786361, 1.0982735 )
- );
- vec4 LinearSRGBToLinearDisplayP3( in vec4 value ) {
- return vec4( value.rgb * LINEAR_SRGB_TO_LINEAR_DISPLAY_P3, value.a );
- }
- vec4 LinearDisplayP3ToLinearSRGB( in vec4 value ) {
- return vec4( value.rgb * LINEAR_DISPLAY_P3_TO_LINEAR_SRGB, value.a );
- }
- vec4 LinearTransferOETF( in vec4 value ) {
- return value;
- }
- vec4 sRGBTransferOETF( in vec4 value ) {
- return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
- }
- vec4 LinearToLinear( in vec4 value ) {
- return value;
- }
- vec4 LinearTosRGB( in vec4 value ) {
- return sRGBTransferOETF( value );
- }`,W1e=`#ifdef USE_ENVMAP
- #ifdef ENV_WORLDPOS
- vec3 cameraToFrag;
- if ( isOrthographic ) {
- cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
- } else {
- cameraToFrag = normalize( vWorldPosition - cameraPosition );
- }
- vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
- #ifdef ENVMAP_MODE_REFLECTION
- vec3 reflectVec = reflect( cameraToFrag, worldNormal );
- #else
- vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
- #endif
- #else
- vec3 reflectVec = vReflect;
- #endif
- #ifdef ENVMAP_TYPE_CUBE
- vec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
- #else
- vec4 envColor = vec4( 0.0 );
- #endif
- #ifdef ENVMAP_BLENDING_MULTIPLY
- outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
- #elif defined( ENVMAP_BLENDING_MIX )
- outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
- #elif defined( ENVMAP_BLENDING_ADD )
- outgoingLight += envColor.xyz * specularStrength * reflectivity;
- #endif
- #endif`,K1e=`#ifdef USE_ENVMAP
- uniform float envMapIntensity;
- uniform float flipEnvMap;
- #ifdef ENVMAP_TYPE_CUBE
- uniform samplerCube envMap;
- #else
- uniform sampler2D envMap;
- #endif
-
- #endif`,X1e=`#ifdef USE_ENVMAP
- uniform float reflectivity;
- #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
- #define ENV_WORLDPOS
- #endif
- #ifdef ENV_WORLDPOS
- varying vec3 vWorldPosition;
- uniform float refractionRatio;
- #else
- varying vec3 vReflect;
- #endif
- #endif`,Y1e=`#ifdef USE_ENVMAP
- #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
- #define ENV_WORLDPOS
- #endif
- #ifdef ENV_WORLDPOS
-
- varying vec3 vWorldPosition;
- #else
- varying vec3 vReflect;
- uniform float refractionRatio;
- #endif
- #endif`,Q1e=`#ifdef USE_ENVMAP
- #ifdef ENV_WORLDPOS
- vWorldPosition = worldPosition.xyz;
- #else
- vec3 cameraToVertex;
- if ( isOrthographic ) {
- cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
- } else {
- cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
- }
- vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
- #ifdef ENVMAP_MODE_REFLECTION
- vReflect = reflect( cameraToVertex, worldNormal );
- #else
- vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
- #endif
- #endif
- #endif`,Z1e=`#ifdef USE_FOG
- vFogDepth = - mvPosition.z;
- #endif`,J1e=`#ifdef USE_FOG
- varying float vFogDepth;
- #endif`,eNe=`#ifdef USE_FOG
- #ifdef FOG_EXP2
- float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
- #else
- float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
- #endif
- gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
- #endif`,tNe=`#ifdef USE_FOG
- uniform vec3 fogColor;
- varying float vFogDepth;
- #ifdef FOG_EXP2
- uniform float fogDensity;
- #else
- uniform float fogNear;
- uniform float fogFar;
- #endif
- #endif`,nNe=`#ifdef USE_GRADIENTMAP
- uniform sampler2D gradientMap;
- #endif
- vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
- float dotNL = dot( normal, lightDirection );
- vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
- #ifdef USE_GRADIENTMAP
- return vec3( texture2D( gradientMap, coord ).r );
- #else
- vec2 fw = fwidth( coord ) * 0.5;
- return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
- #endif
- }`,rNe=`#ifdef USE_LIGHTMAP
- vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
- vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
- reflectedLight.indirectDiffuse += lightMapIrradiance;
- #endif`,aNe=`#ifdef USE_LIGHTMAP
- uniform sampler2D lightMap;
- uniform float lightMapIntensity;
- #endif`,iNe=`LambertMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularStrength = specularStrength;`,sNe=`varying vec3 vViewPosition;
- struct LambertMaterial {
- vec3 diffuseColor;
- float specularStrength;
- };
- void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
- float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
- vec3 irradiance = dotNL * directLight.color;
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- #define RE_Direct RE_Direct_Lambert
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,oNe=`uniform bool receiveShadow;
- uniform vec3 ambientLightColor;
- #if defined( USE_LIGHT_PROBES )
- uniform vec3 lightProbe[ 9 ];
- #endif
- vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
- float x = normal.x, y = normal.y, z = normal.z;
- vec3 result = shCoefficients[ 0 ] * 0.886227;
- result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
- result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
- result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
- result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
- result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
- result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
- result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
- result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
- return result;
- }
- vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
- vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
- vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
- return irradiance;
- }
- vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
- vec3 irradiance = ambientLightColor;
- return irradiance;
- }
- float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
- #if defined ( LEGACY_LIGHTS )
- if ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {
- return pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );
- }
- return 1.0;
- #else
- float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
- if ( cutoffDistance > 0.0 ) {
- distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
- }
- return distanceFalloff;
- #endif
- }
- float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
- return smoothstep( coneCosine, penumbraCosine, angleCosine );
- }
- #if NUM_DIR_LIGHTS > 0
- struct DirectionalLight {
- vec3 direction;
- vec3 color;
- };
- uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
- void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
- light.color = directionalLight.color;
- light.direction = directionalLight.direction;
- light.visible = true;
- }
- #endif
- #if NUM_POINT_LIGHTS > 0
- struct PointLight {
- vec3 position;
- vec3 color;
- float distance;
- float decay;
- };
- uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
- void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
- vec3 lVector = pointLight.position - geometryPosition;
- light.direction = normalize( lVector );
- float lightDistance = length( lVector );
- light.color = pointLight.color;
- light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
- light.visible = ( light.color != vec3( 0.0 ) );
- }
- #endif
- #if NUM_SPOT_LIGHTS > 0
- struct SpotLight {
- vec3 position;
- vec3 direction;
- vec3 color;
- float distance;
- float decay;
- float coneCos;
- float penumbraCos;
- };
- uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
- void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
- vec3 lVector = spotLight.position - geometryPosition;
- light.direction = normalize( lVector );
- float angleCos = dot( light.direction, spotLight.direction );
- float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
- if ( spotAttenuation > 0.0 ) {
- float lightDistance = length( lVector );
- light.color = spotLight.color * spotAttenuation;
- light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
- light.visible = ( light.color != vec3( 0.0 ) );
- } else {
- light.color = vec3( 0.0 );
- light.visible = false;
- }
- }
- #endif
- #if NUM_RECT_AREA_LIGHTS > 0
- struct RectAreaLight {
- vec3 color;
- vec3 position;
- vec3 halfWidth;
- vec3 halfHeight;
- };
- uniform sampler2D ltc_1; uniform sampler2D ltc_2;
- uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
- #endif
- #if NUM_HEMI_LIGHTS > 0
- struct HemisphereLight {
- vec3 direction;
- vec3 skyColor;
- vec3 groundColor;
- };
- uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
- vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
- float dotNL = dot( normal, hemiLight.direction );
- float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
- vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
- return irradiance;
- }
- #endif`,lNe=`#ifdef USE_ENVMAP
- vec3 getIBLIrradiance( const in vec3 normal ) {
- #ifdef ENVMAP_TYPE_CUBE_UV
- vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
- vec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );
- return PI * envMapColor.rgb * envMapIntensity;
- #else
- return vec3( 0.0 );
- #endif
- }
- vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
- #ifdef ENVMAP_TYPE_CUBE_UV
- vec3 reflectVec = reflect( - viewDir, normal );
- reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
- reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
- vec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );
- return envMapColor.rgb * envMapIntensity;
- #else
- return vec3( 0.0 );
- #endif
- }
- #ifdef USE_ANISOTROPY
- vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
- #ifdef ENVMAP_TYPE_CUBE_UV
- vec3 bentNormal = cross( bitangent, viewDir );
- bentNormal = normalize( cross( bentNormal, bitangent ) );
- bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
- return getIBLRadiance( viewDir, bentNormal, roughness );
- #else
- return vec3( 0.0 );
- #endif
- }
- #endif
- #endif`,cNe=`ToonMaterial material;
- material.diffuseColor = diffuseColor.rgb;`,dNe=`varying vec3 vViewPosition;
- struct ToonMaterial {
- vec3 diffuseColor;
- };
- void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
- vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- #define RE_Direct RE_Direct_Toon
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,uNe=`BlinnPhongMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularColor = specular;
- material.specularShininess = shininess;
- material.specularStrength = specularStrength;`,hNe=`varying vec3 vViewPosition;
- struct BlinnPhongMaterial {
- vec3 diffuseColor;
- vec3 specularColor;
- float specularShininess;
- float specularStrength;
- };
- void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
- float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
- vec3 irradiance = dotNL * directLight.color;
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
- }
- void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- #define RE_Direct RE_Direct_BlinnPhong
- #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,mNe=`PhysicalMaterial material;
- material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
- vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
- float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
- material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
- material.roughness = min( material.roughness, 1.0 );
- #ifdef IOR
- material.ior = ior;
- #ifdef USE_SPECULAR
- float specularIntensityFactor = specularIntensity;
- vec3 specularColorFactor = specularColor;
- #ifdef USE_SPECULAR_COLORMAP
- specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
- #endif
- material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
- #else
- float specularIntensityFactor = 1.0;
- vec3 specularColorFactor = vec3( 1.0 );
- material.specularF90 = 1.0;
- #endif
- material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
- #else
- material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
- material.specularF90 = 1.0;
- #endif
- #ifdef USE_CLEARCOAT
- material.clearcoat = clearcoat;
- material.clearcoatRoughness = clearcoatRoughness;
- material.clearcoatF0 = vec3( 0.04 );
- material.clearcoatF90 = 1.0;
- #ifdef USE_CLEARCOATMAP
- material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
- #endif
- material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
- material.clearcoatRoughness += geometryRoughness;
- material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
- #endif
- #ifdef USE_IRIDESCENCE
- material.iridescence = iridescence;
- material.iridescenceIOR = iridescenceIOR;
- #ifdef USE_IRIDESCENCEMAP
- material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
- #else
- material.iridescenceThickness = iridescenceThicknessMaximum;
- #endif
- #endif
- #ifdef USE_SHEEN
- material.sheenColor = sheenColor;
- #ifdef USE_SHEEN_COLORMAP
- material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
- #endif
- material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
- #ifdef USE_SHEEN_ROUGHNESSMAP
- material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
- #endif
- #endif
- #ifdef USE_ANISOTROPY
- #ifdef USE_ANISOTROPYMAP
- mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
- vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
- vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
- #else
- vec2 anisotropyV = anisotropyVector;
- #endif
- material.anisotropy = length( anisotropyV );
- if( material.anisotropy == 0.0 ) {
- anisotropyV = vec2( 1.0, 0.0 );
- } else {
- anisotropyV /= material.anisotropy;
- material.anisotropy = saturate( material.anisotropy );
- }
- material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
- material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
- material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
- #endif`,fNe=`struct PhysicalMaterial {
- vec3 diffuseColor;
- float roughness;
- vec3 specularColor;
- float specularF90;
- #ifdef USE_CLEARCOAT
- float clearcoat;
- float clearcoatRoughness;
- vec3 clearcoatF0;
- float clearcoatF90;
- #endif
- #ifdef USE_IRIDESCENCE
- float iridescence;
- float iridescenceIOR;
- float iridescenceThickness;
- vec3 iridescenceFresnel;
- vec3 iridescenceF0;
- #endif
- #ifdef USE_SHEEN
- vec3 sheenColor;
- float sheenRoughness;
- #endif
- #ifdef IOR
- float ior;
- #endif
- #ifdef USE_TRANSMISSION
- float transmission;
- float transmissionAlpha;
- float thickness;
- float attenuationDistance;
- vec3 attenuationColor;
- #endif
- #ifdef USE_ANISOTROPY
- float anisotropy;
- float alphaT;
- vec3 anisotropyT;
- vec3 anisotropyB;
- #endif
- };
- vec3 clearcoatSpecularDirect = vec3( 0.0 );
- vec3 clearcoatSpecularIndirect = vec3( 0.0 );
- vec3 sheenSpecularDirect = vec3( 0.0 );
- vec3 sheenSpecularIndirect = vec3(0.0 );
- vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
- float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
- float x2 = x * x;
- float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
- return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
- }
- float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
- float a2 = pow2( alpha );
- float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
- float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
- return 0.5 / max( gv + gl, EPSILON );
- }
- float D_GGX( const in float alpha, const in float dotNH ) {
- float a2 = pow2( alpha );
- float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
- return RECIPROCAL_PI * a2 / pow2( denom );
- }
- #ifdef USE_ANISOTROPY
- float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {
- float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
- float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
- float v = 0.5 / ( gv + gl );
- return saturate(v);
- }
- float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
- float a2 = alphaT * alphaB;
- highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
- highp float v2 = dot( v, v );
- float w2 = a2 / v2;
- return RECIPROCAL_PI * a2 * pow2 ( w2 );
- }
- #endif
- #ifdef USE_CLEARCOAT
- vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
- vec3 f0 = material.clearcoatF0;
- float f90 = material.clearcoatF90;
- float roughness = material.clearcoatRoughness;
- float alpha = pow2( roughness );
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNL = saturate( dot( normal, lightDir ) );
- float dotNV = saturate( dot( normal, viewDir ) );
- float dotNH = saturate( dot( normal, halfDir ) );
- float dotVH = saturate( dot( viewDir, halfDir ) );
- vec3 F = F_Schlick( f0, f90, dotVH );
- float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
- float D = D_GGX( alpha, dotNH );
- return F * ( V * D );
- }
- #endif
- vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
- vec3 f0 = material.specularColor;
- float f90 = material.specularF90;
- float roughness = material.roughness;
- float alpha = pow2( roughness );
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNL = saturate( dot( normal, lightDir ) );
- float dotNV = saturate( dot( normal, viewDir ) );
- float dotNH = saturate( dot( normal, halfDir ) );
- float dotVH = saturate( dot( viewDir, halfDir ) );
- vec3 F = F_Schlick( f0, f90, dotVH );
- #ifdef USE_IRIDESCENCE
- F = mix( F, material.iridescenceFresnel, material.iridescence );
- #endif
- #ifdef USE_ANISOTROPY
- float dotTL = dot( material.anisotropyT, lightDir );
- float dotTV = dot( material.anisotropyT, viewDir );
- float dotTH = dot( material.anisotropyT, halfDir );
- float dotBL = dot( material.anisotropyB, lightDir );
- float dotBV = dot( material.anisotropyB, viewDir );
- float dotBH = dot( material.anisotropyB, halfDir );
- float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
- float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
- #else
- float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
- float D = D_GGX( alpha, dotNH );
- #endif
- return F * ( V * D );
- }
- vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
- const float LUT_SIZE = 64.0;
- const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
- const float LUT_BIAS = 0.5 / LUT_SIZE;
- float dotNV = saturate( dot( N, V ) );
- vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
- uv = uv * LUT_SCALE + LUT_BIAS;
- return uv;
- }
- float LTC_ClippedSphereFormFactor( const in vec3 f ) {
- float l = length( f );
- return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
- }
- vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
- float x = dot( v1, v2 );
- float y = abs( x );
- float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
- float b = 3.4175940 + ( 4.1616724 + y ) * y;
- float v = a / b;
- float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
- return cross( v1, v2 ) * theta_sintheta;
- }
- vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
- vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
- vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
- vec3 lightNormal = cross( v1, v2 );
- if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
- vec3 T1, T2;
- T1 = normalize( V - N * dot( V, N ) );
- T2 = - cross( N, T1 );
- mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );
- vec3 coords[ 4 ];
- coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
- coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
- coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
- coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
- coords[ 0 ] = normalize( coords[ 0 ] );
- coords[ 1 ] = normalize( coords[ 1 ] );
- coords[ 2 ] = normalize( coords[ 2 ] );
- coords[ 3 ] = normalize( coords[ 3 ] );
- vec3 vectorFormFactor = vec3( 0.0 );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
- float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
- return vec3( result );
- }
- #if defined( USE_SHEEN )
- float D_Charlie( float roughness, float dotNH ) {
- float alpha = pow2( roughness );
- float invAlpha = 1.0 / alpha;
- float cos2h = dotNH * dotNH;
- float sin2h = max( 1.0 - cos2h, 0.0078125 );
- return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
- }
- float V_Neubelt( float dotNV, float dotNL ) {
- return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
- }
- vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNL = saturate( dot( normal, lightDir ) );
- float dotNV = saturate( dot( normal, viewDir ) );
- float dotNH = saturate( dot( normal, halfDir ) );
- float D = D_Charlie( sheenRoughness, dotNH );
- float V = V_Neubelt( dotNV, dotNL );
- return sheenColor * ( D * V );
- }
- #endif
- float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
- float dotNV = saturate( dot( normal, viewDir ) );
- float r2 = roughness * roughness;
- float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
- float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
- float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
- return saturate( DG * RECIPROCAL_PI );
- }
- vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
- float dotNV = saturate( dot( normal, viewDir ) );
- const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
- const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
- vec4 r = roughness * c0 + c1;
- float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
- vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;
- return fab;
- }
- vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
- vec2 fab = DFGApprox( normal, viewDir, roughness );
- return specularColor * fab.x + specularF90 * fab.y;
- }
- #ifdef USE_IRIDESCENCE
- void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
- #else
- void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
- #endif
- vec2 fab = DFGApprox( normal, viewDir, roughness );
- #ifdef USE_IRIDESCENCE
- vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
- #else
- vec3 Fr = specularColor;
- #endif
- vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
- float Ess = fab.x + fab.y;
- float Ems = 1.0 - Ess;
- vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
- singleScatter += FssEss;
- multiScatter += Fms * Ems;
- }
- #if NUM_RECT_AREA_LIGHTS > 0
- void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
- vec3 normal = geometryNormal;
- vec3 viewDir = geometryViewDir;
- vec3 position = geometryPosition;
- vec3 lightPos = rectAreaLight.position;
- vec3 halfWidth = rectAreaLight.halfWidth;
- vec3 halfHeight = rectAreaLight.halfHeight;
- vec3 lightColor = rectAreaLight.color;
- float roughness = material.roughness;
- vec3 rectCoords[ 4 ];
- rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
- rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
- rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
- vec2 uv = LTC_Uv( normal, viewDir, roughness );
- vec4 t1 = texture2D( ltc_1, uv );
- vec4 t2 = texture2D( ltc_2, uv );
- mat3 mInv = mat3(
- vec3( t1.x, 0, t1.y ),
- vec3( 0, 1, 0 ),
- vec3( t1.z, 0, t1.w )
- );
- vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
- reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
- reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
- }
- #endif
- void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
- float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
- vec3 irradiance = dotNL * directLight.color;
- #ifdef USE_CLEARCOAT
- float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
- vec3 ccIrradiance = dotNLcc * directLight.color;
- clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
- #endif
- #ifdef USE_SHEEN
- sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
- #endif
- reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
- #ifdef USE_CLEARCOAT
- clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
- #endif
- #ifdef USE_SHEEN
- sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
- #endif
- vec3 singleScattering = vec3( 0.0 );
- vec3 multiScattering = vec3( 0.0 );
- vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
- #ifdef USE_IRIDESCENCE
- computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
- #else
- computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
- #endif
- vec3 totalScattering = singleScattering + multiScattering;
- vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
- reflectedLight.indirectSpecular += radiance * singleScattering;
- reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
- reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
- }
- #define RE_Direct RE_Direct_Physical
- #define RE_Direct_RectArea RE_Direct_RectArea_Physical
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
- #define RE_IndirectSpecular RE_IndirectSpecular_Physical
- float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
- return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
- }`,pNe=`
- vec3 geometryPosition = - vViewPosition;
- vec3 geometryNormal = normal;
- vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
- vec3 geometryClearcoatNormal = vec3( 0.0 );
- #ifdef USE_CLEARCOAT
- geometryClearcoatNormal = clearcoatNormal;
- #endif
- #ifdef USE_IRIDESCENCE
- float dotNVi = saturate( dot( normal, geometryViewDir ) );
- if ( material.iridescenceThickness == 0.0 ) {
- material.iridescence = 0.0;
- } else {
- material.iridescence = saturate( material.iridescence );
- }
- if ( material.iridescence > 0.0 ) {
- material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
- material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
- }
- #endif
- IncidentLight directLight;
- #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
- PointLight pointLight;
- #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
- PointLightShadow pointLightShadow;
- #endif
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
- pointLight = pointLights[ i ];
- getPointLightInfo( pointLight, geometryPosition, directLight );
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
- pointLightShadow = pointLightShadows[ i ];
- directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
- #endif
- RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
- SpotLight spotLight;
- vec4 spotColor;
- vec3 spotLightCoord;
- bool inSpotLightMap;
- #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
- SpotLightShadow spotLightShadow;
- #endif
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
- spotLight = spotLights[ i ];
- getSpotLightInfo( spotLight, geometryPosition, directLight );
- #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
- #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
- #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
- #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
- #else
- #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
- #endif
- #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
- spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
- inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
- spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
- directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
- #endif
- #undef SPOT_LIGHT_MAP_INDEX
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
- spotLightShadow = spotLightShadows[ i ];
- directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
- #endif
- RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
- DirectionalLight directionalLight;
- #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
- DirectionalLightShadow directionalLightShadow;
- #endif
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
- directionalLight = directionalLights[ i ];
- getDirectionalLightInfo( directionalLight, directLight );
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
- directionalLightShadow = directionalLightShadows[ i ];
- directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
- #endif
- RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
- RectAreaLight rectAreaLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
- rectAreaLight = rectAreaLights[ i ];
- RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if defined( RE_IndirectDiffuse )
- vec3 iblIrradiance = vec3( 0.0 );
- vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
- #if defined( USE_LIGHT_PROBES )
- irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
- #endif
- #if ( NUM_HEMI_LIGHTS > 0 )
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
- irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
- }
- #pragma unroll_loop_end
- #endif
- #endif
- #if defined( RE_IndirectSpecular )
- vec3 radiance = vec3( 0.0 );
- vec3 clearcoatRadiance = vec3( 0.0 );
- #endif`,gNe=`#if defined( RE_IndirectDiffuse )
- #ifdef USE_LIGHTMAP
- vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
- vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
- irradiance += lightMapIrradiance;
- #endif
- #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
- iblIrradiance += getIBLIrradiance( geometryNormal );
- #endif
- #endif
- #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
- #ifdef USE_ANISOTROPY
- radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
- #else
- radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
- #endif
- #ifdef USE_CLEARCOAT
- clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
- #endif
- #endif`,bNe=`#if defined( RE_IndirectDiffuse )
- RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- #endif
- #if defined( RE_IndirectSpecular )
- RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- #endif`,xNe=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
- gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
- #endif`,yNe=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
- uniform float logDepthBufFC;
- varying float vFragDepth;
- varying float vIsPerspective;
- #endif`,vNe=`#ifdef USE_LOGDEPTHBUF
- #ifdef USE_LOGDEPTHBUF_EXT
- varying float vFragDepth;
- varying float vIsPerspective;
- #else
- uniform float logDepthBufFC;
- #endif
- #endif`,wNe=`#ifdef USE_LOGDEPTHBUF
- #ifdef USE_LOGDEPTHBUF_EXT
- vFragDepth = 1.0 + gl_Position.w;
- vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
- #else
- if ( isPerspectiveMatrix( projectionMatrix ) ) {
- gl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;
- gl_Position.z *= gl_Position.w;
- }
- #endif
- #endif`,SNe=`#ifdef USE_MAP
- vec4 sampledDiffuseColor = texture2D( map, vMapUv );
- #ifdef DECODE_VIDEO_TEXTURE
- sampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w );
-
- #endif
- diffuseColor *= sampledDiffuseColor;
- #endif`,_Ne=`#ifdef USE_MAP
- uniform sampler2D map;
- #endif`,NNe=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
- #if defined( USE_POINTS_UV )
- vec2 uv = vUv;
- #else
- vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
- #endif
- #endif
- #ifdef USE_MAP
- diffuseColor *= texture2D( map, uv );
- #endif
- #ifdef USE_ALPHAMAP
- diffuseColor.a *= texture2D( alphaMap, uv ).g;
- #endif`,CNe=`#if defined( USE_POINTS_UV )
- varying vec2 vUv;
- #else
- #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
- uniform mat3 uvTransform;
- #endif
- #endif
- #ifdef USE_MAP
- uniform sampler2D map;
- #endif
- #ifdef USE_ALPHAMAP
- uniform sampler2D alphaMap;
- #endif`,kNe=`float metalnessFactor = metalness;
- #ifdef USE_METALNESSMAP
- vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
- metalnessFactor *= texelMetalness.b;
- #endif`,ANe=`#ifdef USE_METALNESSMAP
- uniform sampler2D metalnessMap;
- #endif`,TNe=`#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )
- vColor *= morphTargetBaseInfluence;
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
- #if defined( USE_COLOR_ALPHA )
- if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
- #elif defined( USE_COLOR )
- if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
- #endif
- }
- #endif`,MNe=`#ifdef USE_MORPHNORMALS
- objectNormal *= morphTargetBaseInfluence;
- #ifdef MORPHTARGETS_TEXTURE
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
- if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
- }
- #else
- objectNormal += morphNormal0 * morphTargetInfluences[ 0 ];
- objectNormal += morphNormal1 * morphTargetInfluences[ 1 ];
- objectNormal += morphNormal2 * morphTargetInfluences[ 2 ];
- objectNormal += morphNormal3 * morphTargetInfluences[ 3 ];
- #endif
- #endif`,PNe=`#ifdef USE_MORPHTARGETS
- uniform float morphTargetBaseInfluence;
- #ifdef MORPHTARGETS_TEXTURE
- uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
- uniform sampler2DArray morphTargetsTexture;
- uniform ivec2 morphTargetsTextureSize;
- vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
- int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
- int y = texelIndex / morphTargetsTextureSize.x;
- int x = texelIndex - y * morphTargetsTextureSize.x;
- ivec3 morphUV = ivec3( x, y, morphTargetIndex );
- return texelFetch( morphTargetsTexture, morphUV, 0 );
- }
- #else
- #ifndef USE_MORPHNORMALS
- uniform float morphTargetInfluences[ 8 ];
- #else
- uniform float morphTargetInfluences[ 4 ];
- #endif
- #endif
- #endif`,ENe=`#ifdef USE_MORPHTARGETS
- transformed *= morphTargetBaseInfluence;
- #ifdef MORPHTARGETS_TEXTURE
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
- if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
- }
- #else
- transformed += morphTarget0 * morphTargetInfluences[ 0 ];
- transformed += morphTarget1 * morphTargetInfluences[ 1 ];
- transformed += morphTarget2 * morphTargetInfluences[ 2 ];
- transformed += morphTarget3 * morphTargetInfluences[ 3 ];
- #ifndef USE_MORPHNORMALS
- transformed += morphTarget4 * morphTargetInfluences[ 4 ];
- transformed += morphTarget5 * morphTargetInfluences[ 5 ];
- transformed += morphTarget6 * morphTargetInfluences[ 6 ];
- transformed += morphTarget7 * morphTargetInfluences[ 7 ];
- #endif
- #endif
- #endif`,jNe=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
- #ifdef FLAT_SHADED
- vec3 fdx = dFdx( vViewPosition );
- vec3 fdy = dFdy( vViewPosition );
- vec3 normal = normalize( cross( fdx, fdy ) );
- #else
- vec3 normal = normalize( vNormal );
- #ifdef DOUBLE_SIDED
- normal *= faceDirection;
- #endif
- #endif
- #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
- #ifdef USE_TANGENT
- mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
- #else
- mat3 tbn = getTangentFrame( - vViewPosition, normal,
- #if defined( USE_NORMALMAP )
- vNormalMapUv
- #elif defined( USE_CLEARCOAT_NORMALMAP )
- vClearcoatNormalMapUv
- #else
- vUv
- #endif
- );
- #endif
- #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
- tbn[0] *= faceDirection;
- tbn[1] *= faceDirection;
- #endif
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- #ifdef USE_TANGENT
- mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
- #else
- mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
- #endif
- #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
- tbn2[0] *= faceDirection;
- tbn2[1] *= faceDirection;
- #endif
- #endif
- vec3 nonPerturbedNormal = normal;`,DNe=`#ifdef USE_NORMALMAP_OBJECTSPACE
- normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
- #ifdef FLIP_SIDED
- normal = - normal;
- #endif
- #ifdef DOUBLE_SIDED
- normal = normal * faceDirection;
- #endif
- normal = normalize( normalMatrix * normal );
- #elif defined( USE_NORMALMAP_TANGENTSPACE )
- vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
- mapN.xy *= normalScale;
- normal = normalize( tbn * mapN );
- #elif defined( USE_BUMPMAP )
- normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
- #endif`,RNe=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,FNe=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,LNe=`#ifndef FLAT_SHADED
- vNormal = normalize( transformedNormal );
- #ifdef USE_TANGENT
- vTangent = normalize( transformedTangent );
- vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
- #endif
- #endif`,ONe=`#ifdef USE_NORMALMAP
- uniform sampler2D normalMap;
- uniform vec2 normalScale;
- #endif
- #ifdef USE_NORMALMAP_OBJECTSPACE
- uniform mat3 normalMatrix;
- #endif
- #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
- mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
- vec3 q0 = dFdx( eye_pos.xyz );
- vec3 q1 = dFdy( eye_pos.xyz );
- vec2 st0 = dFdx( uv.st );
- vec2 st1 = dFdy( uv.st );
- vec3 N = surf_norm;
- vec3 q1perp = cross( q1, N );
- vec3 q0perp = cross( N, q0 );
- vec3 T = q1perp * st0.x + q0perp * st1.x;
- vec3 B = q1perp * st0.y + q0perp * st1.y;
- float det = max( dot( T, T ), dot( B, B ) );
- float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
- return mat3( T * scale, B * scale, N );
- }
- #endif`,INe=`#ifdef USE_CLEARCOAT
- vec3 clearcoatNormal = nonPerturbedNormal;
- #endif`,zNe=`#ifdef USE_CLEARCOAT_NORMALMAP
- vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
- clearcoatMapN.xy *= clearcoatNormalScale;
- clearcoatNormal = normalize( tbn2 * clearcoatMapN );
- #endif`,UNe=`#ifdef USE_CLEARCOATMAP
- uniform sampler2D clearcoatMap;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- uniform sampler2D clearcoatNormalMap;
- uniform vec2 clearcoatNormalScale;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- uniform sampler2D clearcoatRoughnessMap;
- #endif`,BNe=`#ifdef USE_IRIDESCENCEMAP
- uniform sampler2D iridescenceMap;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- uniform sampler2D iridescenceThicknessMap;
- #endif`,HNe=`#ifdef OPAQUE
- diffuseColor.a = 1.0;
- #endif
- #ifdef USE_TRANSMISSION
- diffuseColor.a *= material.transmissionAlpha;
- #endif
- gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,$Ne=`vec3 packNormalToRGB( const in vec3 normal ) {
- return normalize( normal ) * 0.5 + 0.5;
- }
- vec3 unpackRGBToNormal( const in vec3 rgb ) {
- return 2.0 * rgb.xyz - 1.0;
- }
- const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;
- const vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );
- const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );
- const float ShiftRight8 = 1. / 256.;
- vec4 packDepthToRGBA( const in float v ) {
- vec4 r = vec4( fract( v * PackFactors ), v );
- r.yzw -= r.xyz * ShiftRight8; return r * PackUpscale;
- }
- float unpackRGBAToDepth( const in vec4 v ) {
- return dot( v, UnpackFactors );
- }
- vec2 packDepthToRG( in highp float v ) {
- return packDepthToRGBA( v ).yx;
- }
- float unpackRGToDepth( const in highp vec2 v ) {
- return unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );
- }
- vec4 pack2HalfToRGBA( vec2 v ) {
- vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
- return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
- }
- vec2 unpackRGBATo2Half( vec4 v ) {
- return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
- }
- float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
- return ( viewZ + near ) / ( near - far );
- }
- float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
- return depth * ( near - far ) - near;
- }
- float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
- return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
- }
- float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
- return ( near * far ) / ( ( far - near ) * depth - far );
- }`,VNe=`#ifdef PREMULTIPLIED_ALPHA
- gl_FragColor.rgb *= gl_FragColor.a;
- #endif`,qNe=`vec4 mvPosition = vec4( transformed, 1.0 );
- #ifdef USE_BATCHING
- mvPosition = batchingMatrix * mvPosition;
- #endif
- #ifdef USE_INSTANCING
- mvPosition = instanceMatrix * mvPosition;
- #endif
- mvPosition = modelViewMatrix * mvPosition;
- gl_Position = projectionMatrix * mvPosition;`,GNe=`#ifdef DITHERING
- gl_FragColor.rgb = dithering( gl_FragColor.rgb );
- #endif`,WNe=`#ifdef DITHERING
- vec3 dithering( vec3 color ) {
- float grid_position = rand( gl_FragCoord.xy );
- vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
- dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
- return color + dither_shift_RGB;
- }
- #endif`,KNe=`float roughnessFactor = roughness;
- #ifdef USE_ROUGHNESSMAP
- vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
- roughnessFactor *= texelRoughness.g;
- #endif`,XNe=`#ifdef USE_ROUGHNESSMAP
- uniform sampler2D roughnessMap;
- #endif`,YNe=`#if NUM_SPOT_LIGHT_COORDS > 0
- varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
- #endif
- #if NUM_SPOT_LIGHT_MAPS > 0
- uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
- #endif
- #ifdef USE_SHADOWMAP
- #if NUM_DIR_LIGHT_SHADOWS > 0
- uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
- varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
- struct DirectionalLightShadow {
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
- #endif
- #if NUM_SPOT_LIGHT_SHADOWS > 0
- uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
- struct SpotLightShadow {
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
- varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
- struct PointLightShadow {
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- float shadowCameraNear;
- float shadowCameraFar;
- };
- uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
- #endif
- float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
- return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );
- }
- vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
- return unpackRGBATo2Half( texture2D( shadow, uv ) );
- }
- float VSMShadow (sampler2D shadow, vec2 uv, float compare ){
- float occlusion = 1.0;
- vec2 distribution = texture2DDistribution( shadow, uv );
- float hard_shadow = step( compare , distribution.x );
- if (hard_shadow != 1.0 ) {
- float distance = compare - distribution.x ;
- float variance = max( 0.00000, distribution.y * distribution.y );
- float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );
- }
- return occlusion;
- }
- float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
- float shadow = 1.0;
- shadowCoord.xyz /= shadowCoord.w;
- shadowCoord.z += shadowBias;
- bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
- bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
- if ( frustumTest ) {
- #if defined( SHADOWMAP_TYPE_PCF )
- vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
- float dx0 = - texelSize.x * shadowRadius;
- float dy0 = - texelSize.y * shadowRadius;
- float dx1 = + texelSize.x * shadowRadius;
- float dy1 = + texelSize.y * shadowRadius;
- float dx2 = dx0 / 2.0;
- float dy2 = dy0 / 2.0;
- float dx3 = dx1 / 2.0;
- float dy3 = dy1 / 2.0;
- shadow = (
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
- ) * ( 1.0 / 17.0 );
- #elif defined( SHADOWMAP_TYPE_PCF_SOFT )
- vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
- float dx = texelSize.x;
- float dy = texelSize.y;
- vec2 uv = shadowCoord.xy;
- vec2 f = fract( uv * shadowMapSize + 0.5 );
- uv -= f * texelSize;
- shadow = (
- texture2DCompare( shadowMap, uv, shadowCoord.z ) +
- texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
- texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
- mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
- f.x ) +
- mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
- f.x ) +
- mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
- f.y ) +
- mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
- f.y ) +
- mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
- f.x ),
- mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
- f.x ),
- f.y )
- ) * ( 1.0 / 9.0 );
- #elif defined( SHADOWMAP_TYPE_VSM )
- shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
- #else
- shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
- #endif
- }
- return shadow;
- }
- vec2 cubeToUV( vec3 v, float texelSizeY ) {
- vec3 absV = abs( v );
- float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
- absV *= scaleToCube;
- v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
- vec2 planar = v.xy;
- float almostATexel = 1.5 * texelSizeY;
- float almostOne = 1.0 - almostATexel;
- if ( absV.z >= almostOne ) {
- if ( v.z > 0.0 )
- planar.x = 4.0 - v.x;
- } else if ( absV.x >= almostOne ) {
- float signX = sign( v.x );
- planar.x = v.z * signX + 2.0 * signX;
- } else if ( absV.y >= almostOne ) {
- float signY = sign( v.y );
- planar.x = v.x + 2.0 * signY + 2.0;
- planar.y = v.z * signY - 2.0;
- }
- return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
- }
- float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
- vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
- vec3 lightToPosition = shadowCoord.xyz;
- float dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
- vec3 bd3D = normalize( lightToPosition );
- #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
- vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
- return (
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
- ) * ( 1.0 / 9.0 );
- #else
- return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
- #endif
- }
- #endif`,QNe=`#if NUM_SPOT_LIGHT_COORDS > 0
- uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
- varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
- #endif
- #ifdef USE_SHADOWMAP
- #if NUM_DIR_LIGHT_SHADOWS > 0
- uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
- varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
- struct DirectionalLightShadow {
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
- #endif
- #if NUM_SPOT_LIGHT_SHADOWS > 0
- struct SpotLightShadow {
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
- varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
- struct PointLightShadow {
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- float shadowCameraNear;
- float shadowCameraFar;
- };
- uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
- #endif
- #endif`,ZNe=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
- vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
- vec4 shadowWorldPosition;
- #endif
- #if defined( USE_SHADOWMAP )
- #if NUM_DIR_LIGHT_SHADOWS > 0
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
- shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
- vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
- }
- #pragma unroll_loop_end
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
- shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
- vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
- }
- #pragma unroll_loop_end
- #endif
- #endif
- #if NUM_SPOT_LIGHT_COORDS > 0
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
- shadowWorldPosition = worldPosition;
- #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
- shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
- #endif
- vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
- }
- #pragma unroll_loop_end
- #endif`,JNe=`float getShadowMask() {
- float shadow = 1.0;
- #ifdef USE_SHADOWMAP
- #if NUM_DIR_LIGHT_SHADOWS > 0
- DirectionalLightShadow directionalLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
- directionalLight = directionalLightShadows[ i ];
- shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
- }
- #pragma unroll_loop_end
- #endif
- #if NUM_SPOT_LIGHT_SHADOWS > 0
- SpotLightShadow spotLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
- spotLight = spotLightShadows[ i ];
- shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
- }
- #pragma unroll_loop_end
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- PointLightShadow pointLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
- pointLight = pointLightShadows[ i ];
- shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
- }
- #pragma unroll_loop_end
- #endif
- #endif
- return shadow;
- }`,eCe=`#ifdef USE_SKINNING
- mat4 boneMatX = getBoneMatrix( skinIndex.x );
- mat4 boneMatY = getBoneMatrix( skinIndex.y );
- mat4 boneMatZ = getBoneMatrix( skinIndex.z );
- mat4 boneMatW = getBoneMatrix( skinIndex.w );
- #endif`,tCe=`#ifdef USE_SKINNING
- uniform mat4 bindMatrix;
- uniform mat4 bindMatrixInverse;
- uniform highp sampler2D boneTexture;
- mat4 getBoneMatrix( const in float i ) {
- int size = textureSize( boneTexture, 0 ).x;
- int j = int( i ) * 4;
- int x = j % size;
- int y = j / size;
- vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
- vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
- vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
- vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
- return mat4( v1, v2, v3, v4 );
- }
- #endif`,nCe=`#ifdef USE_SKINNING
- vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
- vec4 skinned = vec4( 0.0 );
- skinned += boneMatX * skinVertex * skinWeight.x;
- skinned += boneMatY * skinVertex * skinWeight.y;
- skinned += boneMatZ * skinVertex * skinWeight.z;
- skinned += boneMatW * skinVertex * skinWeight.w;
- transformed = ( bindMatrixInverse * skinned ).xyz;
- #endif`,rCe=`#ifdef USE_SKINNING
- mat4 skinMatrix = mat4( 0.0 );
- skinMatrix += skinWeight.x * boneMatX;
- skinMatrix += skinWeight.y * boneMatY;
- skinMatrix += skinWeight.z * boneMatZ;
- skinMatrix += skinWeight.w * boneMatW;
- skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
- objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
- #ifdef USE_TANGENT
- objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
- #endif
- #endif`,aCe=`float specularStrength;
- #ifdef USE_SPECULARMAP
- vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
- specularStrength = texelSpecular.r;
- #else
- specularStrength = 1.0;
- #endif`,iCe=`#ifdef USE_SPECULARMAP
- uniform sampler2D specularMap;
- #endif`,sCe=`#if defined( TONE_MAPPING )
- gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
- #endif`,oCe=`#ifndef saturate
- #define saturate( a ) clamp( a, 0.0, 1.0 )
- #endif
- uniform float toneMappingExposure;
- vec3 LinearToneMapping( vec3 color ) {
- return saturate( toneMappingExposure * color );
- }
- vec3 ReinhardToneMapping( vec3 color ) {
- color *= toneMappingExposure;
- return saturate( color / ( vec3( 1.0 ) + color ) );
- }
- vec3 OptimizedCineonToneMapping( vec3 color ) {
- color *= toneMappingExposure;
- color = max( vec3( 0.0 ), color - 0.004 );
- return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
- }
- vec3 RRTAndODTFit( vec3 v ) {
- vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
- vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
- return a / b;
- }
- vec3 ACESFilmicToneMapping( vec3 color ) {
- const mat3 ACESInputMat = mat3(
- vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
- vec3( 0.04823, 0.01566, 0.83777 )
- );
- const mat3 ACESOutputMat = mat3(
- vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
- vec3( -0.07367, -0.00605, 1.07602 )
- );
- color *= toneMappingExposure / 0.6;
- color = ACESInputMat * color;
- color = RRTAndODTFit( color );
- color = ACESOutputMat * color;
- return saturate( color );
- }
- vec3 CustomToneMapping( vec3 color ) { return color; }`,lCe=`#ifdef USE_TRANSMISSION
- material.transmission = transmission;
- material.transmissionAlpha = 1.0;
- material.thickness = thickness;
- material.attenuationDistance = attenuationDistance;
- material.attenuationColor = attenuationColor;
- #ifdef USE_TRANSMISSIONMAP
- material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
- #endif
- #ifdef USE_THICKNESSMAP
- material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
- #endif
- vec3 pos = vWorldPosition;
- vec3 v = normalize( cameraPosition - pos );
- vec3 n = inverseTransformDirection( normal, viewMatrix );
- vec4 transmitted = getIBLVolumeRefraction(
- n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
- pos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness,
- material.attenuationColor, material.attenuationDistance );
- material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
- totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
- #endif`,cCe=`#ifdef USE_TRANSMISSION
- uniform float transmission;
- uniform float thickness;
- uniform float attenuationDistance;
- uniform vec3 attenuationColor;
- #ifdef USE_TRANSMISSIONMAP
- uniform sampler2D transmissionMap;
- #endif
- #ifdef USE_THICKNESSMAP
- uniform sampler2D thicknessMap;
- #endif
- uniform vec2 transmissionSamplerSize;
- uniform sampler2D transmissionSamplerMap;
- uniform mat4 modelMatrix;
- uniform mat4 projectionMatrix;
- varying vec3 vWorldPosition;
- float w0( float a ) {
- return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
- }
- float w1( float a ) {
- return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
- }
- float w2( float a ){
- return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
- }
- float w3( float a ) {
- return ( 1.0 / 6.0 ) * ( a * a * a );
- }
- float g0( float a ) {
- return w0( a ) + w1( a );
- }
- float g1( float a ) {
- return w2( a ) + w3( a );
- }
- float h0( float a ) {
- return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
- }
- float h1( float a ) {
- return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
- }
- vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
- uv = uv * texelSize.zw + 0.5;
- vec2 iuv = floor( uv );
- vec2 fuv = fract( uv );
- float g0x = g0( fuv.x );
- float g1x = g1( fuv.x );
- float h0x = h0( fuv.x );
- float h1x = h1( fuv.x );
- float h0y = h0( fuv.y );
- float h1y = h1( fuv.y );
- vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
- vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
- vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
- vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
- return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
- g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
- }
- vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
- vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
- vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
- vec2 fLodSizeInv = 1.0 / fLodSize;
- vec2 cLodSizeInv = 1.0 / cLodSize;
- vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
- vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
- return mix( fSample, cSample, fract( lod ) );
- }
- vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
- vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
- vec3 modelScale;
- modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
- modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
- modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
- return normalize( refractionVector ) * thickness * modelScale;
- }
- float applyIorToRoughness( const in float roughness, const in float ior ) {
- return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
- }
- vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
- float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
- return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
- }
- vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
- if ( isinf( attenuationDistance ) ) {
- return vec3( 1.0 );
- } else {
- vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
- vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
- }
- }
- vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
- const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
- const in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,
- const in vec3 attenuationColor, const in float attenuationDistance ) {
- vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
- vec3 refractedRayExit = position + transmissionRay;
- vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
- vec2 refractionCoords = ndcPos.xy / ndcPos.w;
- refractionCoords += 1.0;
- refractionCoords /= 2.0;
- vec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
- vec3 transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
- vec3 attenuatedColor = transmittance * transmittedLight.rgb;
- vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
- float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
- return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
- }
- #endif`,dCe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
- varying vec2 vUv;
- #endif
- #ifdef USE_MAP
- varying vec2 vMapUv;
- #endif
- #ifdef USE_ALPHAMAP
- varying vec2 vAlphaMapUv;
- #endif
- #ifdef USE_LIGHTMAP
- varying vec2 vLightMapUv;
- #endif
- #ifdef USE_AOMAP
- varying vec2 vAoMapUv;
- #endif
- #ifdef USE_BUMPMAP
- varying vec2 vBumpMapUv;
- #endif
- #ifdef USE_NORMALMAP
- varying vec2 vNormalMapUv;
- #endif
- #ifdef USE_EMISSIVEMAP
- varying vec2 vEmissiveMapUv;
- #endif
- #ifdef USE_METALNESSMAP
- varying vec2 vMetalnessMapUv;
- #endif
- #ifdef USE_ROUGHNESSMAP
- varying vec2 vRoughnessMapUv;
- #endif
- #ifdef USE_ANISOTROPYMAP
- varying vec2 vAnisotropyMapUv;
- #endif
- #ifdef USE_CLEARCOATMAP
- varying vec2 vClearcoatMapUv;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- varying vec2 vClearcoatNormalMapUv;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- varying vec2 vClearcoatRoughnessMapUv;
- #endif
- #ifdef USE_IRIDESCENCEMAP
- varying vec2 vIridescenceMapUv;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- varying vec2 vIridescenceThicknessMapUv;
- #endif
- #ifdef USE_SHEEN_COLORMAP
- varying vec2 vSheenColorMapUv;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- varying vec2 vSheenRoughnessMapUv;
- #endif
- #ifdef USE_SPECULARMAP
- varying vec2 vSpecularMapUv;
- #endif
- #ifdef USE_SPECULAR_COLORMAP
- varying vec2 vSpecularColorMapUv;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- varying vec2 vSpecularIntensityMapUv;
- #endif
- #ifdef USE_TRANSMISSIONMAP
- uniform mat3 transmissionMapTransform;
- varying vec2 vTransmissionMapUv;
- #endif
- #ifdef USE_THICKNESSMAP
- uniform mat3 thicknessMapTransform;
- varying vec2 vThicknessMapUv;
- #endif`,uCe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
- varying vec2 vUv;
- #endif
- #ifdef USE_MAP
- uniform mat3 mapTransform;
- varying vec2 vMapUv;
- #endif
- #ifdef USE_ALPHAMAP
- uniform mat3 alphaMapTransform;
- varying vec2 vAlphaMapUv;
- #endif
- #ifdef USE_LIGHTMAP
- uniform mat3 lightMapTransform;
- varying vec2 vLightMapUv;
- #endif
- #ifdef USE_AOMAP
- uniform mat3 aoMapTransform;
- varying vec2 vAoMapUv;
- #endif
- #ifdef USE_BUMPMAP
- uniform mat3 bumpMapTransform;
- varying vec2 vBumpMapUv;
- #endif
- #ifdef USE_NORMALMAP
- uniform mat3 normalMapTransform;
- varying vec2 vNormalMapUv;
- #endif
- #ifdef USE_DISPLACEMENTMAP
- uniform mat3 displacementMapTransform;
- varying vec2 vDisplacementMapUv;
- #endif
- #ifdef USE_EMISSIVEMAP
- uniform mat3 emissiveMapTransform;
- varying vec2 vEmissiveMapUv;
- #endif
- #ifdef USE_METALNESSMAP
- uniform mat3 metalnessMapTransform;
- varying vec2 vMetalnessMapUv;
- #endif
- #ifdef USE_ROUGHNESSMAP
- uniform mat3 roughnessMapTransform;
- varying vec2 vRoughnessMapUv;
- #endif
- #ifdef USE_ANISOTROPYMAP
- uniform mat3 anisotropyMapTransform;
- varying vec2 vAnisotropyMapUv;
- #endif
- #ifdef USE_CLEARCOATMAP
- uniform mat3 clearcoatMapTransform;
- varying vec2 vClearcoatMapUv;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- uniform mat3 clearcoatNormalMapTransform;
- varying vec2 vClearcoatNormalMapUv;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- uniform mat3 clearcoatRoughnessMapTransform;
- varying vec2 vClearcoatRoughnessMapUv;
- #endif
- #ifdef USE_SHEEN_COLORMAP
- uniform mat3 sheenColorMapTransform;
- varying vec2 vSheenColorMapUv;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- uniform mat3 sheenRoughnessMapTransform;
- varying vec2 vSheenRoughnessMapUv;
- #endif
- #ifdef USE_IRIDESCENCEMAP
- uniform mat3 iridescenceMapTransform;
- varying vec2 vIridescenceMapUv;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- uniform mat3 iridescenceThicknessMapTransform;
- varying vec2 vIridescenceThicknessMapUv;
- #endif
- #ifdef USE_SPECULARMAP
- uniform mat3 specularMapTransform;
- varying vec2 vSpecularMapUv;
- #endif
- #ifdef USE_SPECULAR_COLORMAP
- uniform mat3 specularColorMapTransform;
- varying vec2 vSpecularColorMapUv;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- uniform mat3 specularIntensityMapTransform;
- varying vec2 vSpecularIntensityMapUv;
- #endif
- #ifdef USE_TRANSMISSIONMAP
- uniform mat3 transmissionMapTransform;
- varying vec2 vTransmissionMapUv;
- #endif
- #ifdef USE_THICKNESSMAP
- uniform mat3 thicknessMapTransform;
- varying vec2 vThicknessMapUv;
- #endif`,hCe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
- vUv = vec3( uv, 1 ).xy;
- #endif
- #ifdef USE_MAP
- vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_ALPHAMAP
- vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_LIGHTMAP
- vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_AOMAP
- vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_BUMPMAP
- vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_NORMALMAP
- vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_DISPLACEMENTMAP
- vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_EMISSIVEMAP
- vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_METALNESSMAP
- vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_ROUGHNESSMAP
- vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_ANISOTROPYMAP
- vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_CLEARCOATMAP
- vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_IRIDESCENCEMAP
- vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SHEEN_COLORMAP
- vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SPECULARMAP
- vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SPECULAR_COLORMAP
- vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_TRANSMISSIONMAP
- vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_THICKNESSMAP
- vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
- #endif`,mCe=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
- vec4 worldPosition = vec4( transformed, 1.0 );
- #ifdef USE_BATCHING
- worldPosition = batchingMatrix * worldPosition;
- #endif
- #ifdef USE_INSTANCING
- worldPosition = instanceMatrix * worldPosition;
- #endif
- worldPosition = modelMatrix * worldPosition;
- #endif`;const fCe=`varying vec2 vUv;
- uniform mat3 uvTransform;
- void main() {
- vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
- gl_Position = vec4( position.xy, 1.0, 1.0 );
- }`,pCe=`uniform sampler2D t2D;
- uniform float backgroundIntensity;
- varying vec2 vUv;
- void main() {
- vec4 texColor = texture2D( t2D, vUv );
- #ifdef DECODE_VIDEO_TEXTURE
- texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );
- #endif
- texColor.rgb *= backgroundIntensity;
- gl_FragColor = texColor;
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,gCe=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,bCe=`#ifdef ENVMAP_TYPE_CUBE
- uniform samplerCube envMap;
- #elif defined( ENVMAP_TYPE_CUBE_UV )
- uniform sampler2D envMap;
- #endif
- uniform float flipEnvMap;
- uniform float backgroundBlurriness;
- uniform float backgroundIntensity;
- varying vec3 vWorldDirection;
- #include <cube_uv_reflection_fragment>
- void main() {
- #ifdef ENVMAP_TYPE_CUBE
- vec4 texColor = textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
- #elif defined( ENVMAP_TYPE_CUBE_UV )
- vec4 texColor = textureCubeUV( envMap, vWorldDirection, backgroundBlurriness );
- #else
- vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
- #endif
- texColor.rgb *= backgroundIntensity;
- gl_FragColor = texColor;
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,xCe=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,yCe=`uniform samplerCube tCube;
- uniform float tFlip;
- uniform float opacity;
- varying vec3 vWorldDirection;
- void main() {
- vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
- gl_FragColor = texColor;
- gl_FragColor.a *= opacity;
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,vCe=`#include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- varying vec2 vHighPrecisionZW;
- void main() {
- #include <uv_vertex>
- #include <batching_vertex>
- #include <skinbase_vertex>
- #ifdef USE_DISPLACEMENTMAP
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinnormal_vertex>
- #endif
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vHighPrecisionZW = gl_Position.zw;
- }`,wCe=`#if DEPTH_PACKING == 3200
- uniform float opacity;
- #endif
- #include <common>
- #include <packing>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- varying vec2 vHighPrecisionZW;
- void main() {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( 1.0 );
- #if DEPTH_PACKING == 3200
- diffuseColor.a = opacity;
- #endif
- #include <map_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <logdepthbuf_fragment>
- float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;
- #if DEPTH_PACKING == 3200
- gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
- #elif DEPTH_PACKING == 3201
- gl_FragColor = packDepthToRGBA( fragCoordZ );
- #endif
- }`,SCe=`#define DISTANCE
- varying vec3 vWorldPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <batching_vertex>
- #include <skinbase_vertex>
- #ifdef USE_DISPLACEMENTMAP
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinnormal_vertex>
- #endif
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <worldpos_vertex>
- #include <clipping_planes_vertex>
- vWorldPosition = worldPosition.xyz;
- }`,_Ce=`#define DISTANCE
- uniform vec3 referencePosition;
- uniform float nearDistance;
- uniform float farDistance;
- varying vec3 vWorldPosition;
- #include <common>
- #include <packing>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main () {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( 1.0 );
- #include <map_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- float dist = length( vWorldPosition - referencePosition );
- dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
- dist = saturate( dist );
- gl_FragColor = packDepthToRGBA( dist );
- }`,NCe=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- }`,CCe=`uniform sampler2D tEquirect;
- varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vec3 direction = normalize( vWorldDirection );
- vec2 sampleUV = equirectUv( direction );
- gl_FragColor = texture2D( tEquirect, sampleUV );
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,kCe=`uniform float scale;
- attribute float lineDistance;
- varying float vLineDistance;
- #include <common>
- #include <uv_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- vLineDistance = scale * lineDistance;
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <fog_vertex>
- }`,ACe=`uniform vec3 diffuse;
- uniform float opacity;
- uniform float dashSize;
- uniform float totalSize;
- varying float vLineDistance;
- #include <common>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- if ( mod( vLineDistance, totalSize ) > dashSize ) {
- discard;
- }
- vec3 outgoingLight = vec3( 0.0 );
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- outgoingLight = diffuseColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- }`,TCe=`#include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <envmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #endif
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <worldpos_vertex>
- #include <envmap_vertex>
- #include <fog_vertex>
- }`,MCe=`uniform vec3 diffuse;
- uniform float opacity;
- #ifndef FLAT_SHADED
- varying vec3 vNormal;
- #endif
- #include <common>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <specularmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <specularmap_fragment>
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- #ifdef USE_LIGHTMAP
- vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
- reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
- #else
- reflectedLight.indirectDiffuse += vec3( 1.0 );
- #endif
- #include <aomap_fragment>
- reflectedLight.indirectDiffuse *= diffuseColor.rgb;
- vec3 outgoingLight = reflectedLight.indirectDiffuse;
- #include <envmap_fragment>
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,PCe=`#define LAMBERT
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <envmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <envmap_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,ECe=`#define LAMBERT
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_lambert_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <specularmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( diffuse, opacity );
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <specularmap_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_lambert_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
- #include <envmap_fragment>
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,jCe=`#define MATCAP
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <color_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <fog_vertex>
- vViewPosition = - mvPosition.xyz;
- }`,DCe=`#define MATCAP
- uniform vec3 diffuse;
- uniform float opacity;
- uniform sampler2D matcap;
- varying vec3 vViewPosition;
- #include <common>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <fog_pars_fragment>
- #include <normal_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- vec3 viewDir = normalize( vViewPosition );
- vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
- vec3 y = cross( viewDir, x );
- vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
- #ifdef USE_MATCAP
- vec4 matcapColor = texture2D( matcap, uv );
- #else
- vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
- #endif
- vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,RCe=`#define NORMAL
- #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
- varying vec3 vViewPosition;
- #endif
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
- vViewPosition = - mvPosition.xyz;
- #endif
- }`,FCe=`#define NORMAL
- uniform float opacity;
- #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
- varying vec3 vViewPosition;
- #endif
- #include <packing>
- #include <uv_pars_fragment>
- #include <normal_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- #include <logdepthbuf_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- gl_FragColor = vec4( packNormalToRGB( normal ), opacity );
- #ifdef OPAQUE
- gl_FragColor.a = 1.0;
- #endif
- }`,LCe=`#define PHONG
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <envmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <envmap_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,OCe=`#define PHONG
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform vec3 specular;
- uniform float shininess;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_phong_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <specularmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( diffuse, opacity );
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <specularmap_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_phong_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
- #include <envmap_fragment>
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,ICe=`#define STANDARD
- varying vec3 vViewPosition;
- #ifdef USE_TRANSMISSION
- varying vec3 vWorldPosition;
- #endif
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- #ifdef USE_TRANSMISSION
- vWorldPosition = worldPosition.xyz;
- #endif
- }`,zCe=`#define STANDARD
- #ifdef PHYSICAL
- #define IOR
- #define USE_SPECULAR
- #endif
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform float roughness;
- uniform float metalness;
- uniform float opacity;
- #ifdef IOR
- uniform float ior;
- #endif
- #ifdef USE_SPECULAR
- uniform float specularIntensity;
- uniform vec3 specularColor;
- #ifdef USE_SPECULAR_COLORMAP
- uniform sampler2D specularColorMap;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- uniform sampler2D specularIntensityMap;
- #endif
- #endif
- #ifdef USE_CLEARCOAT
- uniform float clearcoat;
- uniform float clearcoatRoughness;
- #endif
- #ifdef USE_IRIDESCENCE
- uniform float iridescence;
- uniform float iridescenceIOR;
- uniform float iridescenceThicknessMinimum;
- uniform float iridescenceThicknessMaximum;
- #endif
- #ifdef USE_SHEEN
- uniform vec3 sheenColor;
- uniform float sheenRoughness;
- #ifdef USE_SHEEN_COLORMAP
- uniform sampler2D sheenColorMap;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- uniform sampler2D sheenRoughnessMap;
- #endif
- #endif
- #ifdef USE_ANISOTROPY
- uniform vec2 anisotropyVector;
- #ifdef USE_ANISOTROPYMAP
- uniform sampler2D anisotropyMap;
- #endif
- #endif
- varying vec3 vViewPosition;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <iridescence_fragment>
- #include <cube_uv_reflection_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_physical_pars_fragment>
- #include <fog_pars_fragment>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_physical_pars_fragment>
- #include <transmission_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <clearcoat_pars_fragment>
- #include <iridescence_pars_fragment>
- #include <roughnessmap_pars_fragment>
- #include <metalnessmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( diffuse, opacity );
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <roughnessmap_fragment>
- #include <metalnessmap_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <clearcoat_normal_fragment_begin>
- #include <clearcoat_normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_physical_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
- vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
- #include <transmission_fragment>
- vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
- #ifdef USE_SHEEN
- float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
- outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
- #endif
- #ifdef USE_CLEARCOAT
- float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
- vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
- outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
- #endif
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,UCe=`#define TOON
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,BCe=`#define TOON
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <gradientmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_toon_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( diffuse, opacity );
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_toon_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,HCe=`uniform float size;
- uniform float scale;
- #include <common>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- #ifdef USE_POINTS_UV
- varying vec2 vUv;
- uniform mat3 uvTransform;
- #endif
- void main() {
- #ifdef USE_POINTS_UV
- vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
- #endif
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <project_vertex>
- gl_PointSize = size;
- #ifdef USE_SIZEATTENUATION
- bool isPerspective = isPerspectiveMatrix( projectionMatrix );
- if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
- #endif
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <worldpos_vertex>
- #include <fog_vertex>
- }`,$Ce=`uniform vec3 diffuse;
- uniform float opacity;
- #include <common>
- #include <color_pars_fragment>
- #include <map_particle_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec3 outgoingLight = vec3( 0.0 );
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <logdepthbuf_fragment>
- #include <map_particle_fragment>
- #include <color_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- outgoingLight = diffuseColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- }`,VCe=`#include <common>
- #include <batching_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <shadowmap_pars_vertex>
- void main() {
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <worldpos_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,qCe=`uniform vec3 color;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <logdepthbuf_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <shadowmask_pars_fragment>
- void main() {
- #include <logdepthbuf_fragment>
- gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- }`,GCe=`uniform float rotation;
- uniform vec2 center;
- #include <common>
- #include <uv_pars_vertex>
- #include <fog_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );
- vec2 scale;
- scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );
- scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );
- #ifndef USE_SIZEATTENUATION
- bool isPerspective = isPerspectiveMatrix( projectionMatrix );
- if ( isPerspective ) scale *= - mvPosition.z;
- #endif
- vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
- vec2 rotatedPosition;
- rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
- rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
- mvPosition.xy += rotatedPosition;
- gl_Position = projectionMatrix * mvPosition;
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <fog_vertex>
- }`,WCe=`uniform vec3 diffuse;
- uniform float opacity;
- #include <common>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec3 outgoingLight = vec3( 0.0 );
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- outgoingLight = diffuseColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- }`,Fn={alphahash_fragment:p1e,alphahash_pars_fragment:g1e,alphamap_fragment:b1e,alphamap_pars_fragment:x1e,alphatest_fragment:y1e,alphatest_pars_fragment:v1e,aomap_fragment:w1e,aomap_pars_fragment:S1e,batching_pars_vertex:_1e,batching_vertex:N1e,begin_vertex:C1e,beginnormal_vertex:k1e,bsdfs:A1e,iridescence_fragment:T1e,bumpmap_pars_fragment:M1e,clipping_planes_fragment:P1e,clipping_planes_pars_fragment:E1e,clipping_planes_pars_vertex:j1e,clipping_planes_vertex:D1e,color_fragment:R1e,color_pars_fragment:F1e,color_pars_vertex:L1e,color_vertex:O1e,common:I1e,cube_uv_reflection_fragment:z1e,defaultnormal_vertex:U1e,displacementmap_pars_vertex:B1e,displacementmap_vertex:H1e,emissivemap_fragment:$1e,emissivemap_pars_fragment:V1e,colorspace_fragment:q1e,colorspace_pars_fragment:G1e,envmap_fragment:W1e,envmap_common_pars_fragment:K1e,envmap_pars_fragment:X1e,envmap_pars_vertex:Y1e,envmap_physical_pars_fragment:lNe,envmap_vertex:Q1e,fog_vertex:Z1e,fog_pars_vertex:J1e,fog_fragment:eNe,fog_pars_fragment:tNe,gradientmap_pars_fragment:nNe,lightmap_fragment:rNe,lightmap_pars_fragment:aNe,lights_lambert_fragment:iNe,lights_lambert_pars_fragment:sNe,lights_pars_begin:oNe,lights_toon_fragment:cNe,lights_toon_pars_fragment:dNe,lights_phong_fragment:uNe,lights_phong_pars_fragment:hNe,lights_physical_fragment:mNe,lights_physical_pars_fragment:fNe,lights_fragment_begin:pNe,lights_fragment_maps:gNe,lights_fragment_end:bNe,logdepthbuf_fragment:xNe,logdepthbuf_pars_fragment:yNe,logdepthbuf_pars_vertex:vNe,logdepthbuf_vertex:wNe,map_fragment:SNe,map_pars_fragment:_Ne,map_particle_fragment:NNe,map_particle_pars_fragment:CNe,metalnessmap_fragment:kNe,metalnessmap_pars_fragment:ANe,morphcolor_vertex:TNe,morphnormal_vertex:MNe,morphtarget_pars_vertex:PNe,morphtarget_vertex:ENe,normal_fragment_begin:jNe,normal_fragment_maps:DNe,normal_pars_fragment:RNe,normal_pars_vertex:FNe,normal_vertex:LNe,normalmap_pars_fragment:ONe,clearcoat_normal_fragment_begin:INe,clearcoat_normal_fragment_maps:zNe,clearcoat_pars_fragment:UNe,iridescence_pars_fragment:BNe,opaque_fragment:HNe,packing:$Ne,premultiplied_alpha_fragment:VNe,project_vertex:qNe,dithering_fragment:GNe,dithering_pars_fragment:WNe,roughnessmap_fragment:KNe,roughnessmap_pars_fragment:XNe,shadowmap_pars_fragment:YNe,shadowmap_pars_vertex:QNe,shadowmap_vertex:ZNe,shadowmask_pars_fragment:JNe,skinbase_vertex:eCe,skinning_pars_vertex:tCe,skinning_vertex:nCe,skinnormal_vertex:rCe,specularmap_fragment:aCe,specularmap_pars_fragment:iCe,tonemapping_fragment:sCe,tonemapping_pars_fragment:oCe,transmission_fragment:lCe,transmission_pars_fragment:cCe,uv_pars_fragment:dCe,uv_pars_vertex:uCe,uv_vertex:hCe,worldpos_vertex:mCe,background_vert:fCe,background_frag:pCe,backgroundCube_vert:gCe,backgroundCube_frag:bCe,cube_vert:xCe,cube_frag:yCe,depth_vert:vCe,depth_frag:wCe,distanceRGBA_vert:SCe,distanceRGBA_frag:_Ce,equirect_vert:NCe,equirect_frag:CCe,linedashed_vert:kCe,linedashed_frag:ACe,meshbasic_vert:TCe,meshbasic_frag:MCe,meshlambert_vert:PCe,meshlambert_frag:ECe,meshmatcap_vert:jCe,meshmatcap_frag:DCe,meshnormal_vert:RCe,meshnormal_frag:FCe,meshphong_vert:LCe,meshphong_frag:OCe,meshphysical_vert:ICe,meshphysical_frag:zCe,meshtoon_vert:UCe,meshtoon_frag:BCe,points_vert:HCe,points_frag:$Ce,shadow_vert:VCe,shadow_frag:qCe,sprite_vert:GCe,sprite_frag:WCe},Ut={common:{diffuse:{value:new hn(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Vn},alphaMap:{value:null},alphaMapTransform:{value:new Vn},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Vn}},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 Vn}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Vn}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Vn},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Vn},normalScale:{value:new Nn(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Vn},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Vn}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Vn}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Vn}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new hn(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 hn(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Vn},alphaTest:{value:0},uvTransform:{value:new Vn}},sprite:{diffuse:{value:new hn(16777215)},opacity:{value:1},center:{value:new Nn(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Vn},alphaMap:{value:null},alphaMapTransform:{value:new Vn},alphaTest:{value:0}}},Qs={basic:{uniforms:Ts([Ut.common,Ut.specularmap,Ut.envmap,Ut.aomap,Ut.lightmap,Ut.fog]),vertexShader:Fn.meshbasic_vert,fragmentShader:Fn.meshbasic_frag},lambert:{uniforms:Ts([Ut.common,Ut.specularmap,Ut.envmap,Ut.aomap,Ut.lightmap,Ut.emissivemap,Ut.bumpmap,Ut.normalmap,Ut.displacementmap,Ut.fog,Ut.lights,{emissive:{value:new hn(0)}}]),vertexShader:Fn.meshlambert_vert,fragmentShader:Fn.meshlambert_frag},phong:{uniforms:Ts([Ut.common,Ut.specularmap,Ut.envmap,Ut.aomap,Ut.lightmap,Ut.emissivemap,Ut.bumpmap,Ut.normalmap,Ut.displacementmap,Ut.fog,Ut.lights,{emissive:{value:new hn(0)},specular:{value:new hn(1118481)},shininess:{value:30}}]),vertexShader:Fn.meshphong_vert,fragmentShader:Fn.meshphong_frag},standard:{uniforms:Ts([Ut.common,Ut.envmap,Ut.aomap,Ut.lightmap,Ut.emissivemap,Ut.bumpmap,Ut.normalmap,Ut.displacementmap,Ut.roughnessmap,Ut.metalnessmap,Ut.fog,Ut.lights,{emissive:{value:new hn(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Fn.meshphysical_vert,fragmentShader:Fn.meshphysical_frag},toon:{uniforms:Ts([Ut.common,Ut.aomap,Ut.lightmap,Ut.emissivemap,Ut.bumpmap,Ut.normalmap,Ut.displacementmap,Ut.gradientmap,Ut.fog,Ut.lights,{emissive:{value:new hn(0)}}]),vertexShader:Fn.meshtoon_vert,fragmentShader:Fn.meshtoon_frag},matcap:{uniforms:Ts([Ut.common,Ut.bumpmap,Ut.normalmap,Ut.displacementmap,Ut.fog,{matcap:{value:null}}]),vertexShader:Fn.meshmatcap_vert,fragmentShader:Fn.meshmatcap_frag},points:{uniforms:Ts([Ut.points,Ut.fog]),vertexShader:Fn.points_vert,fragmentShader:Fn.points_frag},dashed:{uniforms:Ts([Ut.common,Ut.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Fn.linedashed_vert,fragmentShader:Fn.linedashed_frag},depth:{uniforms:Ts([Ut.common,Ut.displacementmap]),vertexShader:Fn.depth_vert,fragmentShader:Fn.depth_frag},normal:{uniforms:Ts([Ut.common,Ut.bumpmap,Ut.normalmap,Ut.displacementmap,{opacity:{value:1}}]),vertexShader:Fn.meshnormal_vert,fragmentShader:Fn.meshnormal_frag},sprite:{uniforms:Ts([Ut.sprite,Ut.fog]),vertexShader:Fn.sprite_vert,fragmentShader:Fn.sprite_frag},background:{uniforms:{uvTransform:{value:new Vn},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Fn.background_vert,fragmentShader:Fn.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:Fn.backgroundCube_vert,fragmentShader:Fn.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Fn.cube_vert,fragmentShader:Fn.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Fn.equirect_vert,fragmentShader:Fn.equirect_frag},distanceRGBA:{uniforms:Ts([Ut.common,Ut.displacementmap,{referencePosition:{value:new Je},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Fn.distanceRGBA_vert,fragmentShader:Fn.distanceRGBA_frag},shadow:{uniforms:Ts([Ut.lights,Ut.fog,{color:{value:new hn(0)},opacity:{value:1}}]),vertexShader:Fn.shadow_vert,fragmentShader:Fn.shadow_frag}};Qs.physical={uniforms:Ts([Qs.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Vn},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Vn},clearcoatNormalScale:{value:new Nn(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Vn},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Vn},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Vn},sheen:{value:0},sheenColor:{value:new hn(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Vn},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Vn},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Vn},transmissionSamplerSize:{value:new Nn},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Vn},attenuationDistance:{value:0},attenuationColor:{value:new hn(0)},specularColor:{value:new hn(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Vn},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Vn},anisotropyVector:{value:new Nn},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Vn}}]),vertexShader:Fn.meshphysical_vert,fragmentShader:Fn.meshphysical_frag};const WS={r:0,b:0,g:0};function KCe(t,e,n,r,i,s,o){const l=new hn(0);let c=s===!0?0:1,d,u,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===ok)?(u===void 0&&(u=new Wl(new fv(1,1,1),new Yh({name:"BackgroundCubeMaterial",uniforms:Sb(Qs.backgroundCube.uniforms),vertexShader:Qs.backgroundCube.vertexShader,fragmentShader:Qs.backgroundCube.fragmentShader,side:ao,depthTest:!1,depthWrite:!1,fog:!1})),u.geometry.deleteAttribute("normal"),u.geometry.deleteAttribute("uv"),u.onBeforeRender=function(k,P,C){this.matrixWorld.copyPosition(C.matrixWorld)},Object.defineProperty(u.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(u)),u.material.uniforms.envMap.value=N,u.material.uniforms.flipEnvMap.value=N.isCubeTexture&&N.isRenderTargetTexture===!1?-1:1,u.material.uniforms.backgroundBlurriness.value=y.backgroundBlurriness,u.material.uniforms.backgroundIntensity.value=y.backgroundIntensity,u.material.toneMapped=Br.getTransfer(N.colorSpace)!==oa,(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)):N&&N.isTexture&&(d===void 0&&(d=new Wl(new iL(2,2),new Yh({name:"BackgroundMaterial",uniforms:Sb(Qs.background.uniforms),vertexShader:Qs.background.vertexShader,fragmentShader:Qs.background.fragmentShader,side:Xh,depthTest:!1,depthWrite:!1,fog:!1})),d.geometry.deleteAttribute("normal"),Object.defineProperty(d.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(d)),d.material.uniforms.t2D.value=N,d.material.uniforms.backgroundIntensity.value=y.backgroundIntensity,d.material.toneMapped=Br.getTransfer(N.colorSpace)!==oa,N.matrixAutoUpdate===!0&&N.updateMatrix(),d.material.uniforms.uvTransform.value.copy(N.matrix),(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))}function v(g,y){g.getRGB(WS,WY(t)),r.buffers.color.setClear(WS.r,WS.g,WS.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 XCe(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 d=c,u=!1;function h(D,$,q,z,W){let Q=!1;if(o){const te=v(z,q,$);d!==te&&(d=te,p(d.object)),Q=y(D,z,q,W),Q&&_(D,z,q,W)}else{const te=$.wireframe===!0;(d.geometry!==z.id||d.program!==q.id||d.wireframe!==te)&&(d.geometry=z.id,d.program=q.id,d.wireframe=te,Q=!0)}W!==null&&n.update(W,t.ELEMENT_ARRAY_BUFFER),(Q||u)&&(u=!1,j(D,$,q,z),W!==null&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,n.get(W).buffer))}function f(){return r.isWebGL2?t.createVertexArray():s.createVertexArrayOES()}function p(D){return r.isWebGL2?t.bindVertexArray(D):s.bindVertexArrayOES(D)}function x(D){return r.isWebGL2?t.deleteVertexArray(D):s.deleteVertexArrayOES(D)}function v(D,$,q){const z=q.wireframe===!0;let W=l[D.id];W===void 0&&(W={},l[D.id]=W);let Q=W[$.id];Q===void 0&&(Q={},W[$.id]=Q);let te=Q[z];return te===void 0&&(te=g(f()),Q[z]=te),te}function g(D){const $=[],q=[],z=[];for(let W=0;W<i;W++)$[W]=0,q[W]=0,z[W]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:$,enabledAttributes:q,attributeDivisors:z,object:D,attributes:{},index:null}}function y(D,$,q,z){const W=d.attributes,Q=$.attributes;let te=0;const H=q.getAttributes();for(const X in H)if(H[X].location>=0){const ee=W[X];let Se=Q[X];if(Se===void 0&&(X==="instanceMatrix"&&D.instanceMatrix&&(Se=D.instanceMatrix),X==="instanceColor"&&D.instanceColor&&(Se=D.instanceColor)),ee===void 0||ee.attribute!==Se||Se&&ee.data!==Se.data)return!0;te++}return d.attributesNum!==te||d.index!==z}function _(D,$,q,z){const W={},Q=$.attributes;let te=0;const H=q.getAttributes();for(const X in H)if(H[X].location>=0){let ee=Q[X];ee===void 0&&(X==="instanceMatrix"&&D.instanceMatrix&&(ee=D.instanceMatrix),X==="instanceColor"&&D.instanceColor&&(ee=D.instanceColor));const Se={};Se.attribute=ee,ee&&ee.data&&(Se.data=ee.data),W[X]=Se,te++}d.attributes=W,d.attributesNum=te,d.index=z}function N(){const D=d.newAttributes;for(let $=0,q=D.length;$<q;$++)D[$]=0}function A(D){k(D,0)}function k(D,$){const q=d.newAttributes,z=d.enabledAttributes,W=d.attributeDivisors;q[D]=1,z[D]===0&&(t.enableVertexAttribArray(D),z[D]=1),W[D]!==$&&((r.isWebGL2?t:e.get("ANGLE_instanced_arrays"))[r.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](D,$),W[D]=$)}function P(){const D=d.newAttributes,$=d.enabledAttributes;for(let q=0,z=$.length;q<z;q++)$[q]!==D[q]&&(t.disableVertexAttribArray(q),$[q]=0)}function C(D,$,q,z,W,Q,te){te===!0?t.vertexAttribIPointer(D,$,q,W,Q):t.vertexAttribPointer(D,$,q,z,W,Q)}function j(D,$,q,z){if(r.isWebGL2===!1&&(D.isInstancedMesh||z.isInstancedBufferGeometry)&&e.get("ANGLE_instanced_arrays")===null)return;N();const W=z.attributes,Q=q.getAttributes(),te=$.defaultAttributeValues;for(const H in Q){const X=Q[H];if(X.location>=0){let Z=W[H];if(Z===void 0&&(H==="instanceMatrix"&&D.instanceMatrix&&(Z=D.instanceMatrix),H==="instanceColor"&&D.instanceColor&&(Z=D.instanceColor)),Z!==void 0){const ee=Z.normalized,Se=Z.itemSize,oe=n.get(Z);if(oe===void 0)continue;const ie=oe.buffer,me=oe.type,se=oe.bytesPerElement,ce=r.isWebGL2===!0&&(me===t.INT||me===t.UNSIGNED_INT||Z.gpuType===AY);if(Z.isInterleavedBufferAttribute){const Ce=Z.data,le=Ce.stride,Le=Z.offset;if(Ce.isInstancedInterleavedBuffer){for(let V=0;V<X.locationSize;V++)k(X.location+V,Ce.meshPerAttribute);D.isInstancedMesh!==!0&&z._maxInstanceCount===void 0&&(z._maxInstanceCount=Ce.meshPerAttribute*Ce.count)}else for(let V=0;V<X.locationSize;V++)A(X.location+V);t.bindBuffer(t.ARRAY_BUFFER,ie);for(let V=0;V<X.locationSize;V++)C(X.location+V,Se/X.locationSize,me,ee,le*se,(Le+Se/X.locationSize*V)*se,ce)}else{if(Z.isInstancedBufferAttribute){for(let Ce=0;Ce<X.locationSize;Ce++)k(X.location+Ce,Z.meshPerAttribute);D.isInstancedMesh!==!0&&z._maxInstanceCount===void 0&&(z._maxInstanceCount=Z.meshPerAttribute*Z.count)}else for(let Ce=0;Ce<X.locationSize;Ce++)A(X.location+Ce);t.bindBuffer(t.ARRAY_BUFFER,ie);for(let Ce=0;Ce<X.locationSize;Ce++)C(X.location+Ce,Se/X.locationSize,me,ee,Se*se,Se/X.locationSize*Ce*se,ce)}}else if(te!==void 0){const ee=te[H];if(ee!==void 0)switch(ee.length){case 2:t.vertexAttrib2fv(X.location,ee);break;case 3:t.vertexAttrib3fv(X.location,ee);break;case 4:t.vertexAttrib4fv(X.location,ee);break;default:t.vertexAttrib1fv(X.location,ee)}}}}P()}function M(){L();for(const D in l){const $=l[D];for(const q in $){const z=$[q];for(const W in z)x(z[W].object),delete z[W];delete $[q]}delete l[D]}}function E(D){if(l[D.id]===void 0)return;const $=l[D.id];for(const q in $){const z=$[q];for(const W in z)x(z[W].object),delete z[W];delete $[q]}delete l[D.id]}function B(D){for(const $ in l){const q=l[$];if(q[D.id]===void 0)continue;const z=q[D.id];for(const W in z)x(z[W].object),delete z[W];delete q[D.id]}}function L(){U(),u=!0,d!==c&&(d=c,p(d.object))}function U(){c.geometry=null,c.program=null,c.wireframe=!1}return{setup:h,reset:L,resetDefaultState:U,dispose:M,releaseStatesOfGeometry:E,releaseStatesOfProgram:B,initAttributes:N,enableAttribute:A,disableUnusedAttributes:P}}function YCe(t,e,n,r){const i=r.isWebGL2;let s;function o(u){s=u}function l(u,h){t.drawArrays(s,u,h),n.update(h,s,1)}function c(u,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,u,h,f),n.update(h,s,f)}function d(u,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(u[x],h[x]);else{p.multiDrawArraysWEBGL(s,u,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=d}function QCe(t,e,n){let r;function i(){if(r!==void 0)return r;if(e.has("EXT_texture_filter_anisotropic")===!0){const C=e.get("EXT_texture_filter_anisotropic");r=t.getParameter(C.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function s(C){if(C==="highp"){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";C="mediump"}return C==="mediump"&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}const 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 d=o||e.has("WEBGL_draw_buffers"),u=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"),k=N&&A,P=o?t.getParameter(t.MAX_SAMPLES):0;return{isWebGL2:o,drawBuffers:d,getMaxAnisotropy:i,getMaxPrecision:s,precision:l,logarithmicDepthBuffer:u,maxTextures:h,maxVertexTextures:f,maxTextureSize:p,maxCubemapSize:x,maxAttributes:v,maxVertexUniforms:g,maxVaryings:y,maxFragmentUniforms:_,vertexTextures:N,floatFragmentTextures:A,floatVertexTextures:k,maxSamples:P}}function ZCe(t){const e=this;let n=null,r=0,i=!1,s=!1;const o=new oh,l=new Vn,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,u(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(h,f){n=u(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?u(null):d();else{const _=s?0:r,N=_*4;let A=y.clippingState||null;c.value=A,A=u(x,f,N,p);for(let k=0;k!==N;++k)A[k]=n[k];y.clippingState=A,this.numIntersection=v?this.numPlanes:0,this.numPlanes+=_}};function d(){c.value!==n&&(c.value=n,c.needsUpdate=r>0),e.numPlanes=r,e.numIntersection=0}function u(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 JCe(t){let e=new WeakMap;function n(o,l){return l===sD?o.mapping=yb:l===oD&&(o.mapping=vb),o}function r(o){if(o&&o.isTexture){const l=o.mapping;if(l===sD||l===oD)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 d=new u1e(c.height/2);return d.fromEquirectangularTexture(t,o),e.set(o,d),o.addEventListener("dispose",i),n(d.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 eke extends KY{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 d=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=d*this.view.offsetX,o=s+d*this.view.width,l-=u*this.view.offsetY,c=l-u*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 Ug=4,eH=[.125,.215,.35,.446,.526,.582],Ym=20,qP=new eke,tH=new hn;let GP=null,WP=0,KP=0;const $m=(1+Math.sqrt(5))/2,xg=1/$m,nH=[new Je(1,1,1),new Je(-1,1,1),new Je(1,1,-1),new Je(-1,1,-1),new Je(0,$m,xg),new Je(0,$m,-xg),new Je(xg,0,$m),new Je(-xg,0,$m),new Je($m,xg,0),new Je(-$m,xg,0)];class rH{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){GP=this._renderer.getRenderTarget(),WP=this._renderer.getActiveCubeFace(),KP=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=sH(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=iH(),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(GP,WP,KP),e.scissorTest=!1,KS(e,0,0,e.width,e.height)}_fromTexture(e,n){e.mapping===yb||e.mapping===vb?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),GP=this._renderer.getRenderTarget(),WP=this._renderer.getActiveCubeFace(),KP=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:cl,minFilter:cl,generateMipmaps:!1,type:N0,format:dl,colorSpace:su,depthBuffer:!1},i=aH(e,n,r);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==n){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=aH(e,n,r);const{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=tke(s)),this._blurMaterial=nke(s,e,n)}return i}_compileMaterial(e){const n=new Wl(this._lodPlanes[0],e);this._renderer.compile(n,qP)}_sceneToCubeUV(e,n,r,i){const l=new Ao(90,1,n,r),c=[1,-1,1,1,1,1],d=[1,1,1,-1,-1,-1],u=this._renderer,h=u.autoClear,f=u.toneMapping;u.getClearColor(tH),u.toneMapping=Oh,u.autoClear=!1;const p=new VY({name:"PMREM.Background",side:ao,depthWrite:!1,depthTest:!1}),x=new Wl(new fv,p);let v=!1;const g=e.background;g?g.isColor&&(p.color.copy(g),e.background=null,v=!0):(p.color.copy(tH),v=!0);for(let y=0;y<6;y++){const _=y%3;_===0?(l.up.set(0,c[y],0),l.lookAt(d[y],0,0)):_===1?(l.up.set(0,0,c[y]),l.lookAt(0,d[y],0)):(l.up.set(0,c[y],0),l.lookAt(0,0,d[y]));const N=this._cubeSize;KS(i,_*N,y>2?N:0,N,N),u.setRenderTarget(i),v&&u.render(x,l),u.render(e,l)}x.geometry.dispose(),x.material.dispose(),u.toneMapping=f,u.autoClear=h,e.background=g}_textureToCubeUV(e,n){const r=this._renderer,i=e.mapping===yb||e.mapping===vb;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=sH()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=iH());const s=i?this._cubemapMaterial:this._equirectMaterial,o=new Wl(this._lodPlanes[0],s),l=s.uniforms;l.envMap.value=e;const c=this._cubeSize;KS(n,0,0,3*c,2*c),r.setRenderTarget(n),r.render(o,qP)}_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=nH[(i-1)%nH.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,d=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const u=3,h=new Wl(this._lodPlanes[i],d),f=d.uniforms,p=this._sizeLods[r]-1,x=isFinite(s)?Math.PI/(2*p):2*Math.PI/(2*Ym-1),v=s/x,g=isFinite(s)?1+Math.floor(u*v):Ym;g>Ym&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${g} samples when the maximum is set to ${Ym}`);const y=[];let _=0;for(let C=0;C<Ym;++C){const j=C/v,M=Math.exp(-j*j/2);y.push(M),C===0?_+=M:C<g&&(_+=2*M)}for(let C=0;C<y.length;C++)y[C]=y[C]/_;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],k=3*A*(i>N-Ug?i-N+Ug:0),P=4*(this._cubeSize-A);KS(n,k,P,3*A,2*A),c.setRenderTarget(n),c.render(h,qP)}}function tke(t){const e=[],n=[],r=[];let i=t;const s=t-Ug+1+eH.length;for(let o=0;o<s;o++){const l=Math.pow(2,i);n.push(l);let c=1/l;o>t-Ug?c=eH[o-t+Ug-1]:o===0&&(c=0),r.push(c);const d=1/(l-2),u=-d,h=1+d,f=[u,u,h,u,h,h,u,u,h,h,u,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 P=0;P<p;P++){const C=P%3*2/3-1,j=P>2?0:-1,M=[C,j,0,C+2/3,j,0,C+2/3,j+1,0,C,j,0,C+2/3,j+1,0,C,j+1,0];_.set(M,v*x*P),N.set(f,g*x*P);const E=[P,P,P,P,P,P];A.set(E,y*x*P)}const k=new ws;k.setAttribute("position",new Do(_,v)),k.setAttribute("uv",new Do(N,g)),k.setAttribute("faceIndex",new Do(A,y)),e.push(k),i>Ug&&i--}return{lodPlanes:e,sizeLods:n,sigmas:r}}function aH(t,e,n){const r=new Of(t,e,n);return r.texture.mapping=ok,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function KS(t,e,n,r,i){t.viewport.set(e,n,r,i),t.scissor.set(e,n,r,i)}function nke(t,e,n){const r=new Float32Array(Ym),i=new Je(0,1,0);return new Yh({name:"SphericalGaussianBlur",defines:{n:Ym,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:sL(),fragmentShader:`
- precision mediump float;
- precision mediump int;
- varying vec3 vOutputDirection;
- uniform sampler2D envMap;
- uniform int samples;
- uniform float weights[ n ];
- uniform bool latitudinal;
- uniform float dTheta;
- uniform float mipInt;
- uniform vec3 poleAxis;
- #define ENVMAP_TYPE_CUBE_UV
- #include <cube_uv_reflection_fragment>
- vec3 getSample( float theta, vec3 axis ) {
- float cosTheta = cos( theta );
- // Rodrigues' axis-angle rotation
- vec3 sampleDirection = vOutputDirection * cosTheta
- + cross( axis, vOutputDirection ) * sin( theta )
- + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
- return bilinearCubeUV( envMap, sampleDirection, mipInt );
- }
- void main() {
- vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
- if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
- axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
- }
- axis = normalize( axis );
- gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
- gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
- for ( int i = 1; i < n; i++ ) {
- if ( i >= samples ) {
- break;
- }
- float theta = dTheta * float( i );
- gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
- gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
- }
- }
- `,blending:Lh,depthTest:!1,depthWrite:!1})}function iH(){return new Yh({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:sL(),fragmentShader:`
- precision mediump float;
- precision mediump int;
- varying vec3 vOutputDirection;
- uniform sampler2D envMap;
- #include <common>
- void main() {
- vec3 outputDirection = normalize( vOutputDirection );
- vec2 uv = equirectUv( outputDirection );
- gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
- }
- `,blending:Lh,depthTest:!1,depthWrite:!1})}function sH(){return new Yh({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:sL(),fragmentShader:`
- precision mediump float;
- precision mediump int;
- uniform float flipEnvMap;
- varying vec3 vOutputDirection;
- uniform samplerCube envMap;
- void main() {
- gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
- }
- `,blending:Lh,depthTest:!1,depthWrite:!1})}function sL(){return`
- precision mediump float;
- precision mediump int;
- attribute float faceIndex;
- varying vec3 vOutputDirection;
- // RH coordinate system; PMREM face-indexing convention
- vec3 getDirection( vec2 uv, float face ) {
- uv = 2.0 * uv - 1.0;
- vec3 direction = vec3( uv, 1.0 );
- if ( face == 0.0 ) {
- direction = direction.zyx; // ( 1, v, u ) pos x
- } else if ( face == 1.0 ) {
- direction = direction.xzy;
- direction.xz *= -1.0; // ( -u, 1, -v ) pos y
- } else if ( face == 2.0 ) {
- direction.x *= -1.0; // ( -u, v, 1 ) pos z
- } else if ( face == 3.0 ) {
- direction = direction.zyx;
- direction.xz *= -1.0; // ( -1, v, -u ) neg x
- } else if ( face == 4.0 ) {
- direction = direction.xzy;
- direction.xy *= -1.0; // ( -u, -1, v ) neg y
- } else if ( face == 5.0 ) {
- direction.z *= -1.0; // ( u, v, -1 ) neg z
- }
- return direction;
- }
- void main() {
- vOutputDirection = getDirection( uv, faceIndex );
- gl_Position = vec4( position, 1.0 );
- }
- `}function rke(t){let e=new WeakMap,n=null;function r(l){if(l&&l.isTexture){const c=l.mapping,d=c===sD||c===oD,u=c===yb||c===vb;if(d||u)if(l.isRenderTargetTexture&&l.needsPMREMUpdate===!0){l.needsPMREMUpdate=!1;let h=e.get(l);return n===null&&(n=new rH(t)),h=d?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(d&&h&&h.height>0||u&&h&&i(h)){n===null&&(n=new rH(t));const f=d?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 d=6;for(let u=0;u<d;u++)l[u]!==void 0&&c++;return c===d}function s(l){const c=l.target;c.removeEventListener("dispose",s);const d=e.get(c);d!==void 0&&(e.delete(c),d.dispose())}function o(){e=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:r,dispose:o}}function ake(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 ike(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 d(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 k=_[N+0],P=_[N+1],C=_[N+2];f.push(k,P,P,C,C,k)}}else if(x!==void 0){const _=x.array;v=x.version;for(let N=0,A=_.length/3-1;N<A;N+=3){const k=N+0,P=N+1,C=N+2;f.push(k,P,P,C,C,k)}}else return;const g=new(IY(f)?GY:qY)(f,1);g.version=v;const y=s.get(h);y&&e.remove(y),s.set(h,g)}function u(h){const f=s.get(h);if(f){const p=h.index;p!==null&&f.version<p.version&&d(h)}else d(h);return s.get(h)}return{get:l,update:c,getWireframeAttribute:u}}function ske(t,e,n,r){const i=r.isWebGL2;let s;function o(p){s=p}let l,c;function d(p){l=p.type,c=p.bytesPerElement}function u(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=d,this.render=u,this.renderInstances=h,this.renderMultiDraw=f}function oke(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 lke(t,e){return t[0]-e[0]}function cke(t,e){return Math.abs(e[1])-Math.abs(t[1])}function dke(t,e,n){const r={},i=new Float32Array(8),s=new WeakMap,o=new $r,l=[];for(let d=0;d<8;d++)l[d]=[d,0];function c(d,u,h){const f=d.morphTargetInfluences;if(e.isWebGL2===!0){const x=u.morphAttributes.position||u.morphAttributes.normal||u.morphAttributes.color,v=x!==void 0?x.length:0;let g=s.get(u);if(g===void 0||g.count!==v){let $=function(){U.dispose(),s.delete(u),u.removeEventListener("dispose",$)};var p=$;g!==void 0&&g.texture.dispose();const N=u.morphAttributes.position!==void 0,A=u.morphAttributes.normal!==void 0,k=u.morphAttributes.color!==void 0,P=u.morphAttributes.position||[],C=u.morphAttributes.normal||[],j=u.morphAttributes.color||[];let M=0;N===!0&&(M=1),A===!0&&(M=2),k===!0&&(M=3);let E=u.attributes.position.count*M,B=1;E>e.maxTextureSize&&(B=Math.ceil(E/e.maxTextureSize),E=e.maxTextureSize);const L=new Float32Array(E*B*4*v),U=new BY(L,E,B,v);U.type=Ud,U.needsUpdate=!0;const D=M*4;for(let q=0;q<v;q++){const z=P[q],W=C[q],Q=j[q],te=E*B*4*q;for(let H=0;H<z.count;H++){const X=H*D;N===!0&&(o.fromBufferAttribute(z,H),L[te+X+0]=o.x,L[te+X+1]=o.y,L[te+X+2]=o.z,L[te+X+3]=0),A===!0&&(o.fromBufferAttribute(W,H),L[te+X+4]=o.x,L[te+X+5]=o.y,L[te+X+6]=o.z,L[te+X+7]=0),k===!0&&(o.fromBufferAttribute(Q,H),L[te+X+8]=o.x,L[te+X+9]=o.y,L[te+X+10]=o.z,L[te+X+11]=Q.itemSize===4?o.w:1)}}g={count:v,texture:U,size:new Nn(E,B)},s.set(u,g),u.addEventListener("dispose",$)}let y=0;for(let N=0;N<f.length;N++)y+=f[N];const _=u.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[u.id];if(v===void 0||v.length!==x){v=[];for(let A=0;A<x;A++)v[A]=[A,0];r[u.id]=v}for(let A=0;A<x;A++){const k=v[A];k[0]=A,k[1]=f[A]}v.sort(cke);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(lke);const g=u.morphAttributes.position,y=u.morphAttributes.normal;let _=0;for(let A=0;A<8;A++){const k=l[A],P=k[0],C=k[1];P!==Number.MAX_SAFE_INTEGER&&C?(g&&u.getAttribute("morphTarget"+A)!==g[P]&&u.setAttribute("morphTarget"+A,g[P]),y&&u.getAttribute("morphNormal"+A)!==y[P]&&u.setAttribute("morphNormal"+A,y[P]),i[A]=C,_+=C):(g&&u.hasAttribute("morphTarget"+A)===!0&&u.deleteAttribute("morphTarget"+A),y&&u.hasAttribute("morphNormal"+A)===!0&&u.deleteAttribute("morphNormal"+A),i[A]=0)}const N=u.morphTargetsRelative?1:1-_;h.getUniforms().setValue(t,"morphTargetBaseInfluence",N),h.getUniforms().setValue(t,"morphTargetInfluences",i)}}return{update:c}}function uke(t,e,n,r){let i=new WeakMap;function s(c){const d=r.render.frame,u=c.geometry,h=e.get(c,u);if(i.get(h)!==d&&(e.update(h),i.set(h,d)),c.isInstancedMesh&&(c.hasEventListener("dispose",l)===!1&&c.addEventListener("dispose",l),i.get(c)!==d&&(n.update(c.instanceMatrix,t.ARRAY_BUFFER),c.instanceColor!==null&&n.update(c.instanceColor,t.ARRAY_BUFFER),i.set(c,d))),c.isSkinnedMesh){const f=c.skeleton;i.get(f)!==d&&(f.update(),i.set(f,d))}return h}function o(){i=new WeakMap}function l(c){const d=c.target;d.removeEventListener("dispose",l),n.remove(d.instanceMatrix),d.instanceColor!==null&&n.remove(d.instanceColor)}return{update:s,dispose:o}}class QY extends io{constructor(e,n,r,i,s,o,l,c,d,u){if(u=u!==void 0?u:ff,u!==ff&&u!==wb)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");r===void 0&&u===ff&&(r=Sh),r===void 0&&u===wb&&(r=mf),super(null,i,s,o,l,c,u,r,d),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 ZY=new io,JY=new QY(1,1);JY.compareFunction=LY;const eQ=new BY,tQ=new X_e,nQ=new XY,oH=[],lH=[],cH=new Float32Array(16),dH=new Float32Array(9),uH=new Float32Array(4);function Yb(t,e,n){const r=t[0];if(r<=0||r>0)return t;const i=e*n;let s=oH[i];if(s===void 0&&(s=new Float32Array(i),oH[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 dk(t,e){let n=lH[e];n===void 0&&(n=new Int32Array(e),lH[e]=n);for(let r=0;r!==e;++r)n[r]=t.allocateTextureUnit();return n}function hke(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function mke(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 fke(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 pke(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 gke(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;uH.set(r),t.uniformMatrix2fv(this.addr,!1,uH),yi(n,r)}}function bke(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;dH.set(r),t.uniformMatrix3fv(this.addr,!1,dH),yi(n,r)}}function xke(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;cH.set(r),t.uniformMatrix4fv(this.addr,!1,cH),yi(n,r)}}function yke(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function vke(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 wke(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 Ske(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 _ke(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function Nke(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 Cke(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 kke(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 Ake(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?JY:ZY;n.setTexture2D(e||s,i)}function Tke(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(e||tQ,i)}function Mke(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTextureCube(e||nQ,i)}function Pke(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(e||eQ,i)}function Eke(t){switch(t){case 5126:return hke;case 35664:return mke;case 35665:return fke;case 35666:return pke;case 35674:return gke;case 35675:return bke;case 35676:return xke;case 5124:case 35670:return yke;case 35667:case 35671:return vke;case 35668:case 35672:return wke;case 35669:case 35673:return Ske;case 5125:return _ke;case 36294:return Nke;case 36295:return Cke;case 36296:return kke;case 35678:case 36198:case 36298:case 36306:case 35682:return Ake;case 35679:case 36299:case 36307:return Tke;case 35680:case 36300:case 36308:case 36293:return Mke;case 36289:case 36303:case 36311:case 36292:return Pke}}function jke(t,e){t.uniform1fv(this.addr,e)}function Dke(t,e){const n=Yb(e,this.size,2);t.uniform2fv(this.addr,n)}function Rke(t,e){const n=Yb(e,this.size,3);t.uniform3fv(this.addr,n)}function Fke(t,e){const n=Yb(e,this.size,4);t.uniform4fv(this.addr,n)}function Lke(t,e){const n=Yb(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function Oke(t,e){const n=Yb(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function Ike(t,e){const n=Yb(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function zke(t,e){t.uniform1iv(this.addr,e)}function Uke(t,e){t.uniform2iv(this.addr,e)}function Bke(t,e){t.uniform3iv(this.addr,e)}function Hke(t,e){t.uniform4iv(this.addr,e)}function $ke(t,e){t.uniform1uiv(this.addr,e)}function Vke(t,e){t.uniform2uiv(this.addr,e)}function qke(t,e){t.uniform3uiv(this.addr,e)}function Gke(t,e){t.uniform4uiv(this.addr,e)}function Wke(t,e,n){const r=this.cache,i=e.length,s=dk(n,i);xi(r,s)||(t.uniform1iv(this.addr,s),yi(r,s));for(let o=0;o!==i;++o)n.setTexture2D(e[o]||ZY,s[o])}function Kke(t,e,n){const r=this.cache,i=e.length,s=dk(n,i);xi(r,s)||(t.uniform1iv(this.addr,s),yi(r,s));for(let o=0;o!==i;++o)n.setTexture3D(e[o]||tQ,s[o])}function Xke(t,e,n){const r=this.cache,i=e.length,s=dk(n,i);xi(r,s)||(t.uniform1iv(this.addr,s),yi(r,s));for(let o=0;o!==i;++o)n.setTextureCube(e[o]||nQ,s[o])}function Yke(t,e,n){const r=this.cache,i=e.length,s=dk(n,i);xi(r,s)||(t.uniform1iv(this.addr,s),yi(r,s));for(let o=0;o!==i;++o)n.setTexture2DArray(e[o]||eQ,s[o])}function Qke(t){switch(t){case 5126:return jke;case 35664:return Dke;case 35665:return Rke;case 35666:return Fke;case 35674:return Lke;case 35675:return Oke;case 35676:return Ike;case 5124:case 35670:return zke;case 35667:case 35671:return Uke;case 35668:case 35672:return Bke;case 35669:case 35673:return Hke;case 5125:return $ke;case 36294:return Vke;case 36295:return qke;case 36296:return Gke;case 35678:case 36198:case 36298:case 36306:case 35682:return Wke;case 35679:case 36299:case 36307:return Kke;case 35680:case 36300:case 36308:case 36293:return Xke;case 36289:case 36303:case 36311:case 36292:return Yke}}class Zke{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.setValue=Eke(n.type)}}class Jke{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.size=n.size,this.setValue=Qke(n.type)}}class eAe{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 XP=/(\w+)(\])?(\[|\.)?/g;function hH(t,e){t.seq.push(e),t.map[e.id]=e}function tAe(t,e,n){const r=t.name,i=r.length;for(XP.lastIndex=0;;){const s=XP.exec(r),o=XP.lastIndex;let l=s[1];const c=s[2]==="]",d=s[3];if(c&&(l=l|0),d===void 0||d==="["&&o+2===i){hH(n,d===void 0?new Zke(l,t,e):new Jke(l,t,e));break}else{let h=n.map[l];h===void 0&&(h=new eAe(l),hH(n,h)),n=h}}}class Y_{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);tAe(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 mH(t,e,n){const r=t.createShader(e);return t.shaderSource(r,n),t.compileShader(r),r}const nAe=37297;let rAe=0;function aAe(t,e){const n=t.split(`
- `),r=[],i=Math.max(e-6,0),s=Math.min(e+6,n.length);for(let o=i;o<s;o++){const l=o+1;r.push(`${l===e?">":" "} ${l}: ${n[o]}`)}return r.join(`
- `)}function iAe(t){const e=Br.getPrimaries(Br.workingColorSpace),n=Br.getPrimaries(t);let r;switch(e===n?r="":e===R1&&n===D1?r="LinearDisplayP3ToLinearSRGB":e===D1&&n===R1&&(r="LinearSRGBToLinearDisplayP3"),t){case su:case lk:return[r,"LinearTransferOETF"];case Zi:case tL:return[r,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",t),[r,"LinearTransferOETF"]}}function fH(t,e,n){const r=t.getShaderParameter(e,t.COMPILE_STATUS),i=t.getShaderInfoLog(e).trim();if(r&&i==="")return"";const s=/ERROR: 0:(\d+)/.exec(i);if(s){const o=parseInt(s[1]);return n.toUpperCase()+`
- `+i+`
- `+aAe(t.getShaderSource(e),o)}else return i}function sAe(t,e){const n=iAe(e);return`vec4 ${t}( vec4 value ) { return ${n[0]}( ${n[1]}( value ) ); }`}function oAe(t,e){let n;switch(e){case s_e:n="Linear";break;case o_e:n="Reinhard";break;case l_e:n="OptimizedCineon";break;case c_e:n="ACESFilmic";break;case d_e:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}function lAe(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(Ay).join(`
- `)}function cAe(t){const e=[];for(const n in t){const r=t[n];r!==!1&&e.push("#define "+n+" "+r)}return e.join(`
- `)}function dAe(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 Ay(t){return t!==""}function pH(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 gH(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const uAe=/^[ \t]*#include +<([\w\d./]+)>/gm;function mD(t){return t.replace(uAe,mAe)}const hAe=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function mAe(t,e){let n=Fn[e];if(n===void 0){const r=hAe.get(e);if(r!==void 0)n=Fn[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 mD(n)}const fAe=/#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 bH(t){return t.replace(fAe,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 xH(t){let e="precision "+t.precision+` float;
- precision `+t.precision+" int;";return t.precision==="highp"?e+=`
- #define HIGH_PRECISION`:t.precision==="mediump"?e+=`
- #define MEDIUM_PRECISION`:t.precision==="lowp"&&(e+=`
- #define LOW_PRECISION`),e}function gAe(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===CY?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===RSe?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===Pd&&(e="SHADOWMAP_TYPE_VSM"),e}function bAe(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case yb:case vb:e="ENVMAP_TYPE_CUBE";break;case ok:e="ENVMAP_TYPE_CUBE_UV";break}return e}function xAe(t){let e="ENVMAP_MODE_REFLECTION";return t.envMap&&t.envMapMode===vb&&(e="ENVMAP_MODE_REFRACTION"),e}function yAe(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case JF:e="ENVMAP_BLENDING_MULTIPLY";break;case a_e:e="ENVMAP_BLENDING_MIX";break;case i_e:e="ENVMAP_BLENDING_ADD";break}return e}function vAe(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 wAe(t,e,n,r){const i=t.getContext(),s=n.defines;let o=n.vertexShader,l=n.fragmentShader;const c=gAe(n),d=bAe(n),u=xAe(n),h=yAe(n),f=vAe(n),p=n.isWebGL2?"":lAe(n),x=cAe(s),v=i.createProgram();let g,y,_=n.glslVersion?"#version "+n.glslVersion+`
- `:"";n.isRawShaderMaterial?(g=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(Ay).join(`
- `),g.length>0&&(g+=`
- `),y=[p,"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(Ay).join(`
- `),y.length>0&&(y+=`
- `)):(g=[xH(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 "+u:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&n.flatShading===!1?"#define USE_MORPHNORMALS":"",n.morphColors&&n.isWebGL2?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.useLegacyLights?"#define LEGACY_LIGHTS":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )"," attribute vec3 morphTarget0;"," attribute vec3 morphTarget1;"," attribute vec3 morphTarget2;"," attribute vec3 morphTarget3;"," #ifdef USE_MORPHNORMALS"," attribute vec3 morphNormal0;"," attribute vec3 morphNormal1;"," attribute vec3 morphNormal2;"," attribute vec3 morphNormal3;"," #else"," attribute vec3 morphTarget4;"," attribute vec3 morphTarget5;"," attribute vec3 morphTarget6;"," attribute vec3 morphTarget7;"," #endif","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
- `].filter(Ay).join(`
- `),y=[p,xH(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 "+d:"",n.envMap?"#define "+u:"",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!==Oh?"#define TONE_MAPPING":"",n.toneMapping!==Oh?Fn.tonemapping_pars_fragment:"",n.toneMapping!==Oh?oAe("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",Fn.colorspace_pars_fragment,sAe("linearToOutputTexel",n.outputColorSpace),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
- `].filter(Ay).join(`
- `)),o=mD(o),o=pH(o,n),o=gH(o,n),l=mD(l),l=pH(l,n),l=gH(l,n),o=bH(o),l=bH(l),n.isWebGL2&&n.isRawShaderMaterial!==!0&&(_=`#version 300 es
- `,g=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join(`
- `)+`
- `+g,y=["precision mediump sampler2DArray;","#define varying in",n.glslVersion===L6?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===L6?"":"#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(`
- `)+`
- `+y);const N=_+g+o,A=_+y+l,k=mH(i,i.VERTEX_SHADER,N),P=mH(i,i.FRAGMENT_SHADER,A);i.attachShader(v,k),i.attachShader(v,P),n.index0AttributeName!==void 0?i.bindAttribLocation(v,0,n.index0AttributeName):n.morphTargets===!0&&i.bindAttribLocation(v,0,"position"),i.linkProgram(v);function C(B){if(t.debug.checkShaderErrors){const L=i.getProgramInfoLog(v).trim(),U=i.getShaderInfoLog(k).trim(),D=i.getShaderInfoLog(P).trim();let $=!0,q=!0;if(i.getProgramParameter(v,i.LINK_STATUS)===!1)if($=!1,typeof t.debug.onShaderError=="function")t.debug.onShaderError(i,v,k,P);else{const z=fH(i,k,"vertex"),W=fH(i,P,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(v,i.VALIDATE_STATUS)+`
- Program Info Log: `+L+`
- `+z+`
- `+W)}else L!==""?console.warn("THREE.WebGLProgram: Program Info Log:",L):(U===""||D==="")&&(q=!1);q&&(B.diagnostics={runnable:$,programLog:L,vertexShader:{log:U,prefix:g},fragmentShader:{log:D,prefix:y}})}i.deleteShader(k),i.deleteShader(P),j=new Y_(i,v),M=dAe(i,v)}let j;this.getUniforms=function(){return j===void 0&&C(this),j};let M;this.getAttributes=function(){return M===void 0&&C(this),M};let E=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return E===!1&&(E=i.getProgramParameter(v,nAe)),E},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(v),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=rAe++,this.cacheKey=e,this.usedTimes=1,this.program=v,this.vertexShader=k,this.fragmentShader=P,this}let SAe=0;class _Ae{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 NAe(e),n.set(e,r)),r}}class NAe{constructor(e){this.id=SAe++,this.code=e,this.usedTimes=0}}function CAe(t,e,n,r,i,s,o){const l=new HY,c=new _Ae,d=[],u=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,E,B,L,U){const D=L.fog,$=U.geometry,q=M.isMeshStandardMaterial?L.environment:null,z=(M.isMeshStandardMaterial?n:e).get(M.envMap||q),W=z&&z.mapping===ok?z.image.height:null,Q=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 te=$.morphAttributes.position||$.morphAttributes.normal||$.morphAttributes.color,H=te!==void 0?te.length:0;let X=0;$.morphAttributes.position!==void 0&&(X=1),$.morphAttributes.normal!==void 0&&(X=2),$.morphAttributes.color!==void 0&&(X=3);let Z,ee,Se,oe;if(Q){const Vt=Qs[Q];Z=Vt.vertexShader,ee=Vt.fragmentShader}else Z=M.vertexShader,ee=M.fragmentShader,c.update(M),Se=c.getVertexShaderID(M),oe=c.getFragmentShaderID(M);const ie=t.getRenderTarget(),me=U.isInstancedMesh===!0,se=U.isBatchedMesh===!0,ce=!!M.map,Ce=!!M.matcap,le=!!z,Le=!!M.aoMap,V=!!M.lightMap,K=!!M.bumpMap,fe=!!M.normalMap,Y=!!M.displacementMap,re=!!M.emissiveMap,ue=!!M.metalnessMap,Fe=!!M.roughnessMap,Pe=M.anisotropy>0,be=M.clearcoat>0,O=M.iridescence>0,R=M.sheen>0,G=M.transmission>0,de=Pe&&!!M.anisotropyMap,ge=be&&!!M.clearcoatMap,ae=be&&!!M.clearcoatNormalMap,Ue=be&&!!M.clearcoatRoughnessMap,ze=O&&!!M.iridescenceMap,$e=O&&!!M.iridescenceThicknessMap,Re=R&&!!M.sheenColorMap,pe=R&&!!M.sheenRoughnessMap,ve=!!M.specularMap,Ne=!!M.specularColorMap,xe=!!M.specularIntensityMap,we=G&&!!M.transmissionMap,qe=G&&!!M.thicknessMap,ke=!!M.gradientMap,nt=!!M.alphaMap,De=M.alphaTest>0,We=!!M.alphaHash,Oe=!!M.extensions,je=!!$.attributes.uv1,Ve=!!$.attributes.uv2,ot=!!$.attributes.uv3;let kt=Oh;return M.toneMapped&&(ie===null||ie.isXRRenderTarget===!0)&&(kt=t.toneMapping),{isWebGL2:u,shaderID:Q,shaderType:M.type,shaderName:M.name,vertexShader:Z,fragmentShader:ee,defines:M.defines,customVertexShaderID:Se,customFragmentShaderID:oe,isRawShaderMaterial:M.isRawShaderMaterial===!0,glslVersion:M.glslVersion,precision:p,batching:se,instancing:me,instancingColor:me&&U.instanceColor!==null,supportsVertexTextures:f,outputColorSpace:ie===null?t.outputColorSpace:ie.isXRRenderTarget===!0?ie.texture.colorSpace:su,map:ce,matcap:Ce,envMap:le,envMapMode:le&&z.mapping,envMapCubeUVHeight:W,aoMap:Le,lightMap:V,bumpMap:K,normalMap:fe,displacementMap:f&&Y,emissiveMap:re,normalMapObjectSpace:fe&&M.normalMapType===S_e,normalMapTangentSpace:fe&&M.normalMapType===FY,metalnessMap:ue,roughnessMap:Fe,anisotropy:Pe,anisotropyMap:de,clearcoat:be,clearcoatMap:ge,clearcoatNormalMap:ae,clearcoatRoughnessMap:Ue,iridescence:O,iridescenceMap:ze,iridescenceThicknessMap:$e,sheen:R,sheenColorMap:Re,sheenRoughnessMap:pe,specularMap:ve,specularColorMap:Ne,specularIntensityMap:xe,transmission:G,transmissionMap:we,thicknessMap:qe,gradientMap:ke,opaque:M.transparent===!1&&M.blending===Jg,alphaMap:nt,alphaTest:De,alphaHash:We,combine:M.combine,mapUv:ce&&v(M.map.channel),aoMapUv:Le&&v(M.aoMap.channel),lightMapUv:V&&v(M.lightMap.channel),bumpMapUv:K&&v(M.bumpMap.channel),normalMapUv:fe&&v(M.normalMap.channel),displacementMapUv:Y&&v(M.displacementMap.channel),emissiveMapUv:re&&v(M.emissiveMap.channel),metalnessMapUv:ue&&v(M.metalnessMap.channel),roughnessMapUv:Fe&&v(M.roughnessMap.channel),anisotropyMapUv:de&&v(M.anisotropyMap.channel),clearcoatMapUv:ge&&v(M.clearcoatMap.channel),clearcoatNormalMapUv:ae&&v(M.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Ue&&v(M.clearcoatRoughnessMap.channel),iridescenceMapUv:ze&&v(M.iridescenceMap.channel),iridescenceThicknessMapUv:$e&&v(M.iridescenceThicknessMap.channel),sheenColorMapUv:Re&&v(M.sheenColorMap.channel),sheenRoughnessMapUv:pe&&v(M.sheenRoughnessMap.channel),specularMapUv:ve&&v(M.specularMap.channel),specularColorMapUv:Ne&&v(M.specularColorMap.channel),specularIntensityMapUv:xe&&v(M.specularIntensityMap.channel),transmissionMapUv:we&&v(M.transmissionMap.channel),thicknessMapUv:qe&&v(M.thicknessMap.channel),alphaMapUv:nt&&v(M.alphaMap.channel),vertexTangents:!!$.attributes.tangent&&(fe||Pe),vertexColors:M.vertexColors,vertexAlphas:M.vertexColors===!0&&!!$.attributes.color&&$.attributes.color.itemSize===4,vertexUv1s:je,vertexUv2s:Ve,vertexUv3s:ot,pointsUvs:U.isPoints===!0&&!!$.attributes.uv&&(ce||nt),fog:!!D,useFog:M.fog===!0,fogExp2:D&&D.isFogExp2,flatShading:M.flatShading===!0,sizeAttenuation:M.sizeAttenuation===!0,logarithmicDepthBuffer:h,skinning:U.isSkinnedMesh===!0,morphTargets:$.morphAttributes.position!==void 0,morphNormals:$.morphAttributes.normal!==void 0,morphColors:$.morphAttributes.color!==void 0,morphTargetsCount:H,morphTextureStride:X,numDirLights:E.directional.length,numPointLights:E.point.length,numSpotLights:E.spot.length,numSpotLightMaps:E.spotLightMap.length,numRectAreaLights:E.rectArea.length,numHemiLights:E.hemi.length,numDirLightShadows:E.directionalShadowMap.length,numPointLightShadows:E.pointShadowMap.length,numSpotLightShadows:E.spotShadowMap.length,numSpotLightShadowsWithMaps:E.numSpotLightShadowsWithMaps,numLightProbes:E.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:M.dithering,shadowMapEnabled:t.shadowMap.enabled&&B.length>0,shadowMapType:t.shadowMap.type,toneMapping:kt,useLegacyLights:t._useLegacyLights,decodeVideoTexture:ce&&M.map.isVideoTexture===!0&&Br.getTransfer(M.map.colorSpace)===oa,premultipliedAlpha:M.premultipliedAlpha,doubleSided:M.side===Rd,flipSided:M.side===ao,useDepthPacking:M.depthPacking>=0,depthPacking:M.depthPacking||0,index0AttributeName:M.index0AttributeName,extensionDerivatives:Oe&&M.extensions.derivatives===!0,extensionFragDepth:Oe&&M.extensions.fragDepth===!0,extensionDrawBuffers:Oe&&M.extensions.drawBuffers===!0,extensionShaderTextureLOD:Oe&&M.extensions.shaderTextureLOD===!0,rendererExtensionFragDepth:u||r.has("EXT_frag_depth"),rendererExtensionDrawBuffers:u||r.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:u||r.has("EXT_shader_texture_lod"),rendererExtensionParallelShaderCompile:r.has("KHR_parallel_shader_compile"),customProgramCacheKey:M.customProgramCacheKey()}}function y(M){const E=[];if(M.shaderID?E.push(M.shaderID):(E.push(M.customVertexShaderID),E.push(M.customFragmentShaderID)),M.defines!==void 0)for(const B in M.defines)E.push(B),E.push(M.defines[B]);return M.isRawShaderMaterial===!1&&(_(E,M),N(E,M),E.push(t.outputColorSpace)),E.push(M.customProgramCacheKey),E.join()}function _(M,E){M.push(E.precision),M.push(E.outputColorSpace),M.push(E.envMapMode),M.push(E.envMapCubeUVHeight),M.push(E.mapUv),M.push(E.alphaMapUv),M.push(E.lightMapUv),M.push(E.aoMapUv),M.push(E.bumpMapUv),M.push(E.normalMapUv),M.push(E.displacementMapUv),M.push(E.emissiveMapUv),M.push(E.metalnessMapUv),M.push(E.roughnessMapUv),M.push(E.anisotropyMapUv),M.push(E.clearcoatMapUv),M.push(E.clearcoatNormalMapUv),M.push(E.clearcoatRoughnessMapUv),M.push(E.iridescenceMapUv),M.push(E.iridescenceThicknessMapUv),M.push(E.sheenColorMapUv),M.push(E.sheenRoughnessMapUv),M.push(E.specularMapUv),M.push(E.specularColorMapUv),M.push(E.specularIntensityMapUv),M.push(E.transmissionMapUv),M.push(E.thicknessMapUv),M.push(E.combine),M.push(E.fogExp2),M.push(E.sizeAttenuation),M.push(E.morphTargetsCount),M.push(E.morphAttributeCount),M.push(E.numDirLights),M.push(E.numPointLights),M.push(E.numSpotLights),M.push(E.numSpotLightMaps),M.push(E.numHemiLights),M.push(E.numRectAreaLights),M.push(E.numDirLightShadows),M.push(E.numPointLightShadows),M.push(E.numSpotLightShadows),M.push(E.numSpotLightShadowsWithMaps),M.push(E.numLightProbes),M.push(E.shadowMapType),M.push(E.toneMapping),M.push(E.numClippingPlanes),M.push(E.numClipIntersection),M.push(E.depthPacking)}function N(M,E){l.disableAll(),E.isWebGL2&&l.enable(0),E.supportsVertexTextures&&l.enable(1),E.instancing&&l.enable(2),E.instancingColor&&l.enable(3),E.matcap&&l.enable(4),E.envMap&&l.enable(5),E.normalMapObjectSpace&&l.enable(6),E.normalMapTangentSpace&&l.enable(7),E.clearcoat&&l.enable(8),E.iridescence&&l.enable(9),E.alphaTest&&l.enable(10),E.vertexColors&&l.enable(11),E.vertexAlphas&&l.enable(12),E.vertexUv1s&&l.enable(13),E.vertexUv2s&&l.enable(14),E.vertexUv3s&&l.enable(15),E.vertexTangents&&l.enable(16),E.anisotropy&&l.enable(17),E.alphaHash&&l.enable(18),E.batching&&l.enable(19),M.push(l.mask),l.disableAll(),E.fog&&l.enable(0),E.useFog&&l.enable(1),E.flatShading&&l.enable(2),E.logarithmicDepthBuffer&&l.enable(3),E.skinning&&l.enable(4),E.morphTargets&&l.enable(5),E.morphNormals&&l.enable(6),E.morphColors&&l.enable(7),E.premultipliedAlpha&&l.enable(8),E.shadowMapEnabled&&l.enable(9),E.useLegacyLights&&l.enable(10),E.doubleSided&&l.enable(11),E.flipSided&&l.enable(12),E.useDepthPacking&&l.enable(13),E.dithering&&l.enable(14),E.transmission&&l.enable(15),E.sheen&&l.enable(16),E.opaque&&l.enable(17),E.pointsUvs&&l.enable(18),E.decodeVideoTexture&&l.enable(19),M.push(l.mask)}function A(M){const E=x[M.type];let B;if(E){const L=Qs[E];B=aL.clone(L.uniforms)}else B=M.uniforms;return B}function k(M,E){let B;for(let L=0,U=d.length;L<U;L++){const D=d[L];if(D.cacheKey===E){B=D,++B.usedTimes;break}}return B===void 0&&(B=new wAe(t,E,M,s),d.push(B)),B}function P(M){if(--M.usedTimes===0){const E=d.indexOf(M);d[E]=d[d.length-1],d.pop(),M.destroy()}}function C(M){c.remove(M)}function j(){c.dispose()}return{getParameters:g,getProgramCacheKey:y,getUniforms:A,acquireProgram:k,releaseProgram:P,releaseShaderCache:C,programs:d,dispose:j}}function kAe(){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 AAe(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 yH(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 vH(){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 d(h,f){n.length>1&&n.sort(h||AAe),r.length>1&&r.sort(f||yH),i.length>1&&i.sort(f||yH)}function u(){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:u,sort:d}}function TAe(){let t=new WeakMap;function e(r,i){const s=t.get(r);let o;return s===void 0?(o=new vH,t.set(r,[o])):i>=s.length?(o=new vH,s.push(o)):o=s[i],o}function n(){t=new WeakMap}return{get:e,dispose:n}}function MAe(){const t={};return{get:function(e){if(t[e.id]!==void 0)return t[e.id];let n;switch(e.type){case"DirectionalLight":n={direction:new Je,color:new hn};break;case"SpotLight":n={position:new Je,direction:new Je,color:new hn,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new Je,color:new hn,distance:0,decay:0};break;case"HemisphereLight":n={direction:new Je,skyColor:new hn,groundColor:new hn};break;case"RectAreaLight":n={color:new hn,position:new Je,halfWidth:new Je,halfHeight:new Je};break}return t[e.id]=n,n}}}function PAe(){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 Nn};break;case"SpotLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Nn};break;case"PointLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Nn,shadowCameraNear:1,shadowCameraFar:1e3};break}return t[e.id]=n,n}}}let EAe=0;function jAe(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function DAe(t,e){const n=new MAe,r=PAe(),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 u=0;u<9;u++)i.probe.push(new Je);const s=new Je,o=new ra,l=new ra;function c(u,h){let f=0,p=0,x=0;for(let L=0;L<9;L++)i.probe[L].set(0,0,0);let v=0,g=0,y=0,_=0,N=0,A=0,k=0,P=0,C=0,j=0,M=0;u.sort(jAe);const E=h===!0?Math.PI:1;for(let L=0,U=u.length;L<U;L++){const D=u[L],$=D.color,q=D.intensity,z=D.distance,W=D.shadow&&D.shadow.map?D.shadow.map.texture:null;if(D.isAmbientLight)f+=$.r*q*E,p+=$.g*q*E,x+=$.b*q*E;else if(D.isLightProbe){for(let Q=0;Q<9;Q++)i.probe[Q].addScaledVector(D.sh.coefficients[Q],q);M++}else if(D.isDirectionalLight){const Q=n.get(D);if(Q.color.copy(D.color).multiplyScalar(D.intensity*E),D.castShadow){const te=D.shadow,H=r.get(D);H.shadowBias=te.bias,H.shadowNormalBias=te.normalBias,H.shadowRadius=te.radius,H.shadowMapSize=te.mapSize,i.directionalShadow[v]=H,i.directionalShadowMap[v]=W,i.directionalShadowMatrix[v]=D.shadow.matrix,A++}i.directional[v]=Q,v++}else if(D.isSpotLight){const Q=n.get(D);Q.position.setFromMatrixPosition(D.matrixWorld),Q.color.copy($).multiplyScalar(q*E),Q.distance=z,Q.coneCos=Math.cos(D.angle),Q.penumbraCos=Math.cos(D.angle*(1-D.penumbra)),Q.decay=D.decay,i.spot[y]=Q;const te=D.shadow;if(D.map&&(i.spotLightMap[C]=D.map,C++,te.updateMatrices(D),D.castShadow&&j++),i.spotLightMatrix[y]=te.matrix,D.castShadow){const H=r.get(D);H.shadowBias=te.bias,H.shadowNormalBias=te.normalBias,H.shadowRadius=te.radius,H.shadowMapSize=te.mapSize,i.spotShadow[y]=H,i.spotShadowMap[y]=W,P++}y++}else if(D.isRectAreaLight){const Q=n.get(D);Q.color.copy($).multiplyScalar(q),Q.halfWidth.set(D.width*.5,0,0),Q.halfHeight.set(0,D.height*.5,0),i.rectArea[_]=Q,_++}else if(D.isPointLight){const Q=n.get(D);if(Q.color.copy(D.color).multiplyScalar(D.intensity*E),Q.distance=D.distance,Q.decay=D.decay,D.castShadow){const te=D.shadow,H=r.get(D);H.shadowBias=te.bias,H.shadowNormalBias=te.normalBias,H.shadowRadius=te.radius,H.shadowMapSize=te.mapSize,H.shadowCameraNear=te.camera.near,H.shadowCameraFar=te.camera.far,i.pointShadow[g]=H,i.pointShadowMap[g]=W,i.pointShadowMatrix[g]=D.shadow.matrix,k++}i.point[g]=Q,g++}else if(D.isHemisphereLight){const Q=n.get(D);Q.skyColor.copy(D.color).multiplyScalar(q*E),Q.groundColor.copy(D.groundColor).multiplyScalar(q*E),i.hemi[N]=Q,N++}}_>0&&(e.isWebGL2||t.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=Ut.LTC_FLOAT_1,i.rectAreaLTC2=Ut.LTC_FLOAT_2):t.has("OES_texture_half_float_linear")===!0?(i.rectAreaLTC1=Ut.LTC_HALF_1,i.rectAreaLTC2=Ut.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 B=i.hash;(B.directionalLength!==v||B.pointLength!==g||B.spotLength!==y||B.rectAreaLength!==_||B.hemiLength!==N||B.numDirectionalShadows!==A||B.numPointShadows!==k||B.numSpotShadows!==P||B.numSpotMaps!==C||B.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=k,i.pointShadowMap.length=k,i.spotShadow.length=P,i.spotShadowMap.length=P,i.directionalShadowMatrix.length=A,i.pointShadowMatrix.length=k,i.spotLightMatrix.length=P+C-j,i.spotLightMap.length=C,i.numSpotLightShadowsWithMaps=j,i.numLightProbes=M,B.directionalLength=v,B.pointLength=g,B.spotLength=y,B.rectAreaLength=_,B.hemiLength=N,B.numDirectionalShadows=A,B.numPointShadows=k,B.numSpotShadows=P,B.numSpotMaps=C,B.numLightProbes=M,i.version=EAe++)}function d(u,h){let f=0,p=0,x=0,v=0,g=0;const y=h.matrixWorldInverse;for(let _=0,N=u.length;_<N;_++){const A=u[_];if(A.isDirectionalLight){const k=i.directional[f];k.direction.setFromMatrixPosition(A.matrixWorld),s.setFromMatrixPosition(A.target.matrixWorld),k.direction.sub(s),k.direction.transformDirection(y),f++}else if(A.isSpotLight){const k=i.spot[x];k.position.setFromMatrixPosition(A.matrixWorld),k.position.applyMatrix4(y),k.direction.setFromMatrixPosition(A.matrixWorld),s.setFromMatrixPosition(A.target.matrixWorld),k.direction.sub(s),k.direction.transformDirection(y),x++}else if(A.isRectAreaLight){const k=i.rectArea[v];k.position.setFromMatrixPosition(A.matrixWorld),k.position.applyMatrix4(y),l.identity(),o.copy(A.matrixWorld),o.premultiply(y),l.extractRotation(o),k.halfWidth.set(A.width*.5,0,0),k.halfHeight.set(0,A.height*.5,0),k.halfWidth.applyMatrix4(l),k.halfHeight.applyMatrix4(l),v++}else if(A.isPointLight){const k=i.point[p];k.position.setFromMatrixPosition(A.matrixWorld),k.position.applyMatrix4(y),p++}else if(A.isHemisphereLight){const k=i.hemi[g];k.direction.setFromMatrixPosition(A.matrixWorld),k.direction.transformDirection(y),g++}}}return{setup:c,setupView:d,state:i}}function wH(t,e){const n=new DAe(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 d(h){n.setupView(r,h)}return{init:s,state:{lightsArray:r,shadowsArray:i,lights:n},setupLights:c,setupLightsView:d,pushLight:o,pushShadow:l}}function RAe(t,e){let n=new WeakMap;function r(s,o=0){const l=n.get(s);let c;return l===void 0?(c=new wH(t,e),n.set(s,[c])):o>=l.length?(c=new wH(t,e),l.push(c)):c=l[o],c}function i(){n=new WeakMap}return{get:r,dispose:i}}class FAe extends Xb{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=v_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 LAe extends Xb{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 OAe=`void main() {
- gl_Position = vec4( position, 1.0 );
- }`,IAe=`uniform sampler2D shadow_pass;
- uniform vec2 resolution;
- uniform float radius;
- #include <packing>
- void main() {
- const float samples = float( VSM_SAMPLES );
- float mean = 0.0;
- float squared_mean = 0.0;
- float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
- float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
- for ( float i = 0.0; i < samples; i ++ ) {
- float uvOffset = uvStart + i * uvStride;
- #ifdef HORIZONTAL_PASS
- vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
- mean += distribution.x;
- squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
- #else
- float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
- mean += depth;
- squared_mean += depth * depth;
- #endif
- }
- mean = mean / samples;
- squared_mean = squared_mean / samples;
- float std_dev = sqrt( squared_mean - mean * mean );
- gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
- }`;function zAe(t,e,n){let r=new ck;const i=new Nn,s=new Nn,o=new $r,l=new FAe({depthPacking:w_e}),c=new LAe,d={},u=n.maxTextureSize,h={[Xh]:ao,[ao]:Xh,[Rd]:Rd},f=new Yh({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Nn},radius:{value:4}},vertexShader:OAe,fragmentShader:IAe}),p=f.clone();p.defines.HORIZONTAL_PASS=1;const x=new ws;x.setAttribute("position",new Do(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const v=new Wl(x,f),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=CY;let y=this.type;this.render=function(k,P,C){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||k.length===0)return;const j=t.getRenderTarget(),M=t.getActiveCubeFace(),E=t.getActiveMipmapLevel(),B=t.state;B.setBlending(Lh),B.buffers.color.setClear(1,1,1,1),B.buffers.depth.setTest(!0),B.setScissorTest(!1);const L=y!==Pd&&this.type===Pd,U=y===Pd&&this.type!==Pd;for(let D=0,$=k.length;D<$;D++){const q=k[D],z=q.shadow;if(z===void 0){console.warn("THREE.WebGLShadowMap:",q,"has no shadow.");continue}if(z.autoUpdate===!1&&z.needsUpdate===!1)continue;i.copy(z.mapSize);const W=z.getFrameExtents();if(i.multiply(W),s.copy(z.mapSize),(i.x>u||i.y>u)&&(i.x>u&&(s.x=Math.floor(u/W.x),i.x=s.x*W.x,z.mapSize.x=s.x),i.y>u&&(s.y=Math.floor(u/W.y),i.y=s.y*W.y,z.mapSize.y=s.y)),z.map===null||L===!0||U===!0){const te=this.type!==Pd?{minFilter:Qi,magFilter:Qi}:{};z.map!==null&&z.map.dispose(),z.map=new Of(i.x,i.y,te),z.map.texture.name=q.name+".shadowMap",z.camera.updateProjectionMatrix()}t.setRenderTarget(z.map),t.clear();const Q=z.getViewportCount();for(let te=0;te<Q;te++){const H=z.getViewport(te);o.set(s.x*H.x,s.y*H.y,s.x*H.z,s.y*H.w),B.viewport(o),z.updateMatrices(q,te),r=z.getFrustum(),A(P,C,z.camera,q,this.type)}z.isPointLightShadow!==!0&&this.type===Pd&&_(z,C),z.needsUpdate=!1}y=this.type,g.needsUpdate=!1,t.setRenderTarget(j,M,E)};function _(k,P){const C=e.update(v);f.defines.VSM_SAMPLES!==k.blurSamples&&(f.defines.VSM_SAMPLES=k.blurSamples,p.defines.VSM_SAMPLES=k.blurSamples,f.needsUpdate=!0,p.needsUpdate=!0),k.mapPass===null&&(k.mapPass=new Of(i.x,i.y)),f.uniforms.shadow_pass.value=k.map.texture,f.uniforms.resolution.value=k.mapSize,f.uniforms.radius.value=k.radius,t.setRenderTarget(k.mapPass),t.clear(),t.renderBufferDirect(P,null,C,f,v,null),p.uniforms.shadow_pass.value=k.mapPass.texture,p.uniforms.resolution.value=k.mapSize,p.uniforms.radius.value=k.radius,t.setRenderTarget(k.map),t.clear(),t.renderBufferDirect(P,null,C,p,v,null)}function N(k,P,C,j){let M=null;const E=C.isPointLight===!0?k.customDistanceMaterial:k.customDepthMaterial;if(E!==void 0)M=E;else if(M=C.isPointLight===!0?c:l,t.localClippingEnabled&&P.clipShadows===!0&&Array.isArray(P.clippingPlanes)&&P.clippingPlanes.length!==0||P.displacementMap&&P.displacementScale!==0||P.alphaMap&&P.alphaTest>0||P.map&&P.alphaTest>0){const B=M.uuid,L=P.uuid;let U=d[B];U===void 0&&(U={},d[B]=U);let D=U[L];D===void 0&&(D=M.clone(),U[L]=D),M=D}if(M.visible=P.visible,M.wireframe=P.wireframe,j===Pd?M.side=P.shadowSide!==null?P.shadowSide:P.side:M.side=P.shadowSide!==null?P.shadowSide:h[P.side],M.alphaMap=P.alphaMap,M.alphaTest=P.alphaTest,M.map=P.map,M.clipShadows=P.clipShadows,M.clippingPlanes=P.clippingPlanes,M.clipIntersection=P.clipIntersection,M.displacementMap=P.displacementMap,M.displacementScale=P.displacementScale,M.displacementBias=P.displacementBias,M.wireframeLinewidth=P.wireframeLinewidth,M.linewidth=P.linewidth,C.isPointLight===!0&&M.isMeshDistanceMaterial===!0){const B=t.properties.get(M);B.light=C}return M}function A(k,P,C,j,M){if(k.visible===!1)return;if(k.layers.test(P.layers)&&(k.isMesh||k.isLine||k.isPoints)&&(k.castShadow||k.receiveShadow&&M===Pd)&&(!k.frustumCulled||r.intersectsObject(k))){k.modelViewMatrix.multiplyMatrices(C.matrixWorldInverse,k.matrixWorld);const L=e.update(k),U=k.material;if(Array.isArray(U)){const D=L.groups;for(let $=0,q=D.length;$<q;$++){const z=D[$],W=U[z.materialIndex];if(W&&W.visible){const Q=N(k,W,j,M);k.onBeforeShadow(t,k,P,C,L,Q,z),t.renderBufferDirect(C,null,L,Q,k,z),k.onAfterShadow(t,k,P,C,L,Q,z)}}}else if(U.visible){const D=N(k,U,j,M);k.onBeforeShadow(t,k,P,C,L,D,null),t.renderBufferDirect(C,null,L,D,k,null),k.onAfterShadow(t,k,P,C,L,D,null)}}const B=k.children;for(let L=0,U=B.length;L<U;L++)A(B[L],P,C,j,M)}}function UAe(t,e,n){const r=n.isWebGL2;function i(){let De=!1;const We=new $r;let Oe=null;const je=new $r(0,0,0,0);return{setMask:function(Ve){Oe!==Ve&&!De&&(t.colorMask(Ve,Ve,Ve,Ve),Oe=Ve)},setLocked:function(Ve){De=Ve},setClear:function(Ve,ot,kt,Ft,Vt){Vt===!0&&(Ve*=Ft,ot*=Ft,kt*=Ft),We.set(Ve,ot,kt,Ft),je.equals(We)===!1&&(t.clearColor(Ve,ot,kt,Ft),je.copy(We))},reset:function(){De=!1,Oe=null,je.set(-1,0,0,0)}}}function s(){let De=!1,We=null,Oe=null,je=null;return{setTest:function(Ve){Ve?se(t.DEPTH_TEST):ce(t.DEPTH_TEST)},setMask:function(Ve){We!==Ve&&!De&&(t.depthMask(Ve),We=Ve)},setFunc:function(Ve){if(Oe!==Ve){switch(Ve){case QSe:t.depthFunc(t.NEVER);break;case ZSe:t.depthFunc(t.ALWAYS);break;case JSe:t.depthFunc(t.LESS);break;case E1:t.depthFunc(t.LEQUAL);break;case e_e:t.depthFunc(t.EQUAL);break;case t_e:t.depthFunc(t.GEQUAL);break;case n_e:t.depthFunc(t.GREATER);break;case r_e:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}Oe=Ve}},setLocked:function(Ve){De=Ve},setClear:function(Ve){je!==Ve&&(t.clearDepth(Ve),je=Ve)},reset:function(){De=!1,We=null,Oe=null,je=null}}}function o(){let De=!1,We=null,Oe=null,je=null,Ve=null,ot=null,kt=null,Ft=null,Vt=null;return{setTest:function(At){De||(At?se(t.STENCIL_TEST):ce(t.STENCIL_TEST))},setMask:function(At){We!==At&&!De&&(t.stencilMask(At),We=At)},setFunc:function(At,Be,mt){(Oe!==At||je!==Be||Ve!==mt)&&(t.stencilFunc(At,Be,mt),Oe=At,je=Be,Ve=mt)},setOp:function(At,Be,mt){(ot!==At||kt!==Be||Ft!==mt)&&(t.stencilOp(At,Be,mt),ot=At,kt=Be,Ft=mt)},setLocked:function(At){De=At},setClear:function(At){Vt!==At&&(t.clearStencil(At),Vt=At)},reset:function(){De=!1,We=null,Oe=null,je=null,Ve=null,ot=null,kt=null,Ft=null,Vt=null}}}const l=new i,c=new s,d=new o,u=new WeakMap,h=new WeakMap;let f={},p={},x=new WeakMap,v=[],g=null,y=!1,_=null,N=null,A=null,k=null,P=null,C=null,j=null,M=new hn(0,0,0),E=0,B=!1,L=null,U=null,D=null,$=null,q=null;const z=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let W=!1,Q=0;const te=t.getParameter(t.VERSION);te.indexOf("WebGL")!==-1?(Q=parseFloat(/^WebGL (\d)/.exec(te)[1]),W=Q>=1):te.indexOf("OpenGL ES")!==-1&&(Q=parseFloat(/^OpenGL ES (\d)/.exec(te)[1]),W=Q>=2);let H=null,X={};const Z=t.getParameter(t.SCISSOR_BOX),ee=t.getParameter(t.VIEWPORT),Se=new $r().fromArray(Z),oe=new $r().fromArray(ee);function ie(De,We,Oe,je){const Ve=new Uint8Array(4),ot=t.createTexture();t.bindTexture(De,ot),t.texParameteri(De,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(De,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let kt=0;kt<Oe;kt++)r&&(De===t.TEXTURE_3D||De===t.TEXTURE_2D_ARRAY)?t.texImage3D(We,0,t.RGBA,1,1,je,0,t.RGBA,t.UNSIGNED_BYTE,Ve):t.texImage2D(We+kt,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,Ve);return ot}const me={};me[t.TEXTURE_2D]=ie(t.TEXTURE_2D,t.TEXTURE_2D,1),me[t.TEXTURE_CUBE_MAP]=ie(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),r&&(me[t.TEXTURE_2D_ARRAY]=ie(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),me[t.TEXTURE_3D]=ie(t.TEXTURE_3D,t.TEXTURE_3D,1,1)),l.setClear(0,0,0,1),c.setClear(1),d.setClear(0),se(t.DEPTH_TEST),c.setFunc(E1),re(!1),ue(r6),se(t.CULL_FACE),fe(Lh);function se(De){f[De]!==!0&&(t.enable(De),f[De]=!0)}function ce(De){f[De]!==!1&&(t.disable(De),f[De]=!1)}function Ce(De,We){return p[De]!==We?(t.bindFramebuffer(De,We),p[De]=We,r&&(De===t.DRAW_FRAMEBUFFER&&(p[t.FRAMEBUFFER]=We),De===t.FRAMEBUFFER&&(p[t.DRAW_FRAMEBUFFER]=We)),!0):!1}function le(De,We){let Oe=v,je=!1;if(De)if(Oe=x.get(We),Oe===void 0&&(Oe=[],x.set(We,Oe)),De.isWebGLMultipleRenderTargets){const Ve=De.texture;if(Oe.length!==Ve.length||Oe[0]!==t.COLOR_ATTACHMENT0){for(let ot=0,kt=Ve.length;ot<kt;ot++)Oe[ot]=t.COLOR_ATTACHMENT0+ot;Oe.length=Ve.length,je=!0}}else Oe[0]!==t.COLOR_ATTACHMENT0&&(Oe[0]=t.COLOR_ATTACHMENT0,je=!0);else Oe[0]!==t.BACK&&(Oe[0]=t.BACK,je=!0);je&&(n.isWebGL2?t.drawBuffers(Oe):e.get("WEBGL_draw_buffers").drawBuffersWEBGL(Oe))}function Le(De){return g!==De?(t.useProgram(De),g=De,!0):!1}const V={[Xm]:t.FUNC_ADD,[LSe]:t.FUNC_SUBTRACT,[OSe]:t.FUNC_REVERSE_SUBTRACT};if(r)V[o6]=t.MIN,V[l6]=t.MAX;else{const De=e.get("EXT_blend_minmax");De!==null&&(V[o6]=De.MIN_EXT,V[l6]=De.MAX_EXT)}const K={[ISe]:t.ZERO,[zSe]:t.ONE,[USe]:t.SRC_COLOR,[aD]:t.SRC_ALPHA,[GSe]:t.SRC_ALPHA_SATURATE,[VSe]:t.DST_COLOR,[HSe]:t.DST_ALPHA,[BSe]:t.ONE_MINUS_SRC_COLOR,[iD]:t.ONE_MINUS_SRC_ALPHA,[qSe]:t.ONE_MINUS_DST_COLOR,[$Se]:t.ONE_MINUS_DST_ALPHA,[WSe]:t.CONSTANT_COLOR,[KSe]:t.ONE_MINUS_CONSTANT_COLOR,[XSe]:t.CONSTANT_ALPHA,[YSe]:t.ONE_MINUS_CONSTANT_ALPHA};function fe(De,We,Oe,je,Ve,ot,kt,Ft,Vt,At){if(De===Lh){y===!0&&(ce(t.BLEND),y=!1);return}if(y===!1&&(se(t.BLEND),y=!0),De!==FSe){if(De!==_||At!==B){if((N!==Xm||P!==Xm)&&(t.blendEquation(t.FUNC_ADD),N=Xm,P=Xm),At)switch(De){case Jg:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case a6:t.blendFunc(t.ONE,t.ONE);break;case i6:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case s6:t.blendFuncSeparate(t.ZERO,t.SRC_COLOR,t.ZERO,t.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",De);break}else switch(De){case Jg:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case a6:t.blendFunc(t.SRC_ALPHA,t.ONE);break;case i6:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case s6:t.blendFunc(t.ZERO,t.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",De);break}A=null,k=null,C=null,j=null,M.set(0,0,0),E=0,_=De,B=At}return}Ve=Ve||We,ot=ot||Oe,kt=kt||je,(We!==N||Ve!==P)&&(t.blendEquationSeparate(V[We],V[Ve]),N=We,P=Ve),(Oe!==A||je!==k||ot!==C||kt!==j)&&(t.blendFuncSeparate(K[Oe],K[je],K[ot],K[kt]),A=Oe,k=je,C=ot,j=kt),(Ft.equals(M)===!1||Vt!==E)&&(t.blendColor(Ft.r,Ft.g,Ft.b,Vt),M.copy(Ft),E=Vt),_=De,B=!1}function Y(De,We){De.side===Rd?ce(t.CULL_FACE):se(t.CULL_FACE);let Oe=De.side===ao;We&&(Oe=!Oe),re(Oe),De.blending===Jg&&De.transparent===!1?fe(Lh):fe(De.blending,De.blendEquation,De.blendSrc,De.blendDst,De.blendEquationAlpha,De.blendSrcAlpha,De.blendDstAlpha,De.blendColor,De.blendAlpha,De.premultipliedAlpha),c.setFunc(De.depthFunc),c.setTest(De.depthTest),c.setMask(De.depthWrite),l.setMask(De.colorWrite);const je=De.stencilWrite;d.setTest(je),je&&(d.setMask(De.stencilWriteMask),d.setFunc(De.stencilFunc,De.stencilRef,De.stencilFuncMask),d.setOp(De.stencilFail,De.stencilZFail,De.stencilZPass)),Pe(De.polygonOffset,De.polygonOffsetFactor,De.polygonOffsetUnits),De.alphaToCoverage===!0?se(t.SAMPLE_ALPHA_TO_COVERAGE):ce(t.SAMPLE_ALPHA_TO_COVERAGE)}function re(De){L!==De&&(De?t.frontFace(t.CW):t.frontFace(t.CCW),L=De)}function ue(De){De!==jSe?(se(t.CULL_FACE),De!==U&&(De===r6?t.cullFace(t.BACK):De===DSe?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):ce(t.CULL_FACE),U=De}function Fe(De){De!==D&&(W&&t.lineWidth(De),D=De)}function Pe(De,We,Oe){De?(se(t.POLYGON_OFFSET_FILL),($!==We||q!==Oe)&&(t.polygonOffset(We,Oe),$=We,q=Oe)):ce(t.POLYGON_OFFSET_FILL)}function be(De){De?se(t.SCISSOR_TEST):ce(t.SCISSOR_TEST)}function O(De){De===void 0&&(De=t.TEXTURE0+z-1),H!==De&&(t.activeTexture(De),H=De)}function R(De,We,Oe){Oe===void 0&&(H===null?Oe=t.TEXTURE0+z-1:Oe=H);let je=X[Oe];je===void 0&&(je={type:void 0,texture:void 0},X[Oe]=je),(je.type!==De||je.texture!==We)&&(H!==Oe&&(t.activeTexture(Oe),H=Oe),t.bindTexture(De,We||me[De]),je.type=De,je.texture=We)}function G(){const De=X[H];De!==void 0&&De.type!==void 0&&(t.bindTexture(De.type,null),De.type=void 0,De.texture=void 0)}function de(){try{t.compressedTexImage2D.apply(t,arguments)}catch(De){console.error("THREE.WebGLState:",De)}}function ge(){try{t.compressedTexImage3D.apply(t,arguments)}catch(De){console.error("THREE.WebGLState:",De)}}function ae(){try{t.texSubImage2D.apply(t,arguments)}catch(De){console.error("THREE.WebGLState:",De)}}function Ue(){try{t.texSubImage3D.apply(t,arguments)}catch(De){console.error("THREE.WebGLState:",De)}}function ze(){try{t.compressedTexSubImage2D.apply(t,arguments)}catch(De){console.error("THREE.WebGLState:",De)}}function $e(){try{t.compressedTexSubImage3D.apply(t,arguments)}catch(De){console.error("THREE.WebGLState:",De)}}function Re(){try{t.texStorage2D.apply(t,arguments)}catch(De){console.error("THREE.WebGLState:",De)}}function pe(){try{t.texStorage3D.apply(t,arguments)}catch(De){console.error("THREE.WebGLState:",De)}}function ve(){try{t.texImage2D.apply(t,arguments)}catch(De){console.error("THREE.WebGLState:",De)}}function Ne(){try{t.texImage3D.apply(t,arguments)}catch(De){console.error("THREE.WebGLState:",De)}}function xe(De){Se.equals(De)===!1&&(t.scissor(De.x,De.y,De.z,De.w),Se.copy(De))}function we(De){oe.equals(De)===!1&&(t.viewport(De.x,De.y,De.z,De.w),oe.copy(De))}function qe(De,We){let Oe=h.get(We);Oe===void 0&&(Oe=new WeakMap,h.set(We,Oe));let je=Oe.get(De);je===void 0&&(je=t.getUniformBlockIndex(We,De.name),Oe.set(De,je))}function ke(De,We){const je=h.get(We).get(De);u.get(We)!==je&&(t.uniformBlockBinding(We,je,De.__bindingPointIndex),u.set(We,je))}function nt(){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={},H=null,X={},p={},x=new WeakMap,v=[],g=null,y=!1,_=null,N=null,A=null,k=null,P=null,C=null,j=null,M=new hn(0,0,0),E=0,B=!1,L=null,U=null,D=null,$=null,q=null,Se.set(0,0,t.canvas.width,t.canvas.height),oe.set(0,0,t.canvas.width,t.canvas.height),l.reset(),c.reset(),d.reset()}return{buffers:{color:l,depth:c,stencil:d},enable:se,disable:ce,bindFramebuffer:Ce,drawBuffers:le,useProgram:Le,setBlending:fe,setMaterial:Y,setFlipSided:re,setCullFace:ue,setLineWidth:Fe,setPolygonOffset:Pe,setScissorTest:be,activeTexture:O,bindTexture:R,unbindTexture:G,compressedTexImage2D:de,compressedTexImage3D:ge,texImage2D:ve,texImage3D:Ne,updateUBOMapping:qe,uniformBlockBinding:ke,texStorage2D:Re,texStorage3D:pe,texSubImage2D:ae,texSubImage3D:Ue,compressedTexSubImage2D:ze,compressedTexSubImage3D:$e,scissor:xe,viewport:we,reset:nt}}function BAe(t,e,n,r,i,s,o){const l=i.isWebGL2,c=i.maxTextures,d=i.maxCubemapSize,u=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 _(O,R){return y?new OffscreenCanvas(O,R):L1("canvas")}function N(O,R,G,de){let ge=1;if((O.width>de||O.height>de)&&(ge=de/Math.max(O.width,O.height)),ge<1||R===!0)if(typeof HTMLImageElement<"u"&&O instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&O instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&O instanceof ImageBitmap){const ae=R?F1:Math.floor,Ue=ae(ge*O.width),ze=ae(ge*O.height);v===void 0&&(v=_(Ue,ze));const $e=G?_(Ue,ze):v;return $e.width=Ue,$e.height=ze,$e.getContext("2d").drawImage(O,0,0,Ue,ze),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+O.width+"x"+O.height+") to ("+Ue+"x"+ze+")."),$e}else return"data"in O&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+O.width+"x"+O.height+")."),O;return O}function A(O){return hD(O.width)&&hD(O.height)}function k(O){return l?!1:O.wrapS!==Bl||O.wrapT!==Bl||O.minFilter!==Qi&&O.minFilter!==cl}function P(O,R){return O.generateMipmaps&&R&&O.minFilter!==Qi&&O.minFilter!==cl}function C(O){t.generateMipmap(O)}function j(O,R,G,de,ge=!1){if(l===!1)return R;if(O!==null){if(t[O]!==void 0)return t[O];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+O+"'")}let ae=R;if(R===t.RED&&(G===t.FLOAT&&(ae=t.R32F),G===t.HALF_FLOAT&&(ae=t.R16F),G===t.UNSIGNED_BYTE&&(ae=t.R8)),R===t.RED_INTEGER&&(G===t.UNSIGNED_BYTE&&(ae=t.R8UI),G===t.UNSIGNED_SHORT&&(ae=t.R16UI),G===t.UNSIGNED_INT&&(ae=t.R32UI),G===t.BYTE&&(ae=t.R8I),G===t.SHORT&&(ae=t.R16I),G===t.INT&&(ae=t.R32I)),R===t.RG&&(G===t.FLOAT&&(ae=t.RG32F),G===t.HALF_FLOAT&&(ae=t.RG16F),G===t.UNSIGNED_BYTE&&(ae=t.RG8)),R===t.RGBA){const Ue=ge?j1:Br.getTransfer(de);G===t.FLOAT&&(ae=t.RGBA32F),G===t.HALF_FLOAT&&(ae=t.RGBA16F),G===t.UNSIGNED_BYTE&&(ae=Ue===oa?t.SRGB8_ALPHA8:t.RGBA8),G===t.UNSIGNED_SHORT_4_4_4_4&&(ae=t.RGBA4),G===t.UNSIGNED_SHORT_5_5_5_1&&(ae=t.RGB5_A1)}return(ae===t.R16F||ae===t.R32F||ae===t.RG16F||ae===t.RG32F||ae===t.RGBA16F||ae===t.RGBA32F)&&e.get("EXT_color_buffer_float"),ae}function M(O,R,G){return P(O,G)===!0||O.isFramebufferTexture&&O.minFilter!==Qi&&O.minFilter!==cl?Math.log2(Math.max(R.width,R.height))+1:O.mipmaps!==void 0&&O.mipmaps.length>0?O.mipmaps.length:O.isCompressedTexture&&Array.isArray(O.image)?R.mipmaps.length:1}function E(O){return O===Qi||O===c6||O===SP?t.NEAREST:t.LINEAR}function B(O){const R=O.target;R.removeEventListener("dispose",B),U(R),R.isVideoTexture&&x.delete(R)}function L(O){const R=O.target;R.removeEventListener("dispose",L),$(R)}function U(O){const R=r.get(O);if(R.__webglInit===void 0)return;const G=O.source,de=g.get(G);if(de){const ge=de[R.__cacheKey];ge.usedTimes--,ge.usedTimes===0&&D(O),Object.keys(de).length===0&&g.delete(G)}r.remove(O)}function D(O){const R=r.get(O);t.deleteTexture(R.__webglTexture);const G=O.source,de=g.get(G);delete de[R.__cacheKey],o.memory.textures--}function $(O){const R=O.texture,G=r.get(O),de=r.get(R);if(de.__webglTexture!==void 0&&(t.deleteTexture(de.__webglTexture),o.memory.textures--),O.depthTexture&&O.depthTexture.dispose(),O.isWebGLCubeRenderTarget)for(let ge=0;ge<6;ge++){if(Array.isArray(G.__webglFramebuffer[ge]))for(let ae=0;ae<G.__webglFramebuffer[ge].length;ae++)t.deleteFramebuffer(G.__webglFramebuffer[ge][ae]);else t.deleteFramebuffer(G.__webglFramebuffer[ge]);G.__webglDepthbuffer&&t.deleteRenderbuffer(G.__webglDepthbuffer[ge])}else{if(Array.isArray(G.__webglFramebuffer))for(let ge=0;ge<G.__webglFramebuffer.length;ge++)t.deleteFramebuffer(G.__webglFramebuffer[ge]);else t.deleteFramebuffer(G.__webglFramebuffer);if(G.__webglDepthbuffer&&t.deleteRenderbuffer(G.__webglDepthbuffer),G.__webglMultisampledFramebuffer&&t.deleteFramebuffer(G.__webglMultisampledFramebuffer),G.__webglColorRenderbuffer)for(let ge=0;ge<G.__webglColorRenderbuffer.length;ge++)G.__webglColorRenderbuffer[ge]&&t.deleteRenderbuffer(G.__webglColorRenderbuffer[ge]);G.__webglDepthRenderbuffer&&t.deleteRenderbuffer(G.__webglDepthRenderbuffer)}if(O.isWebGLMultipleRenderTargets)for(let ge=0,ae=R.length;ge<ae;ge++){const Ue=r.get(R[ge]);Ue.__webglTexture&&(t.deleteTexture(Ue.__webglTexture),o.memory.textures--),r.remove(R[ge])}r.remove(R),r.remove(O)}let q=0;function z(){q=0}function W(){const O=q;return O>=c&&console.warn("THREE.WebGLTextures: Trying to use "+O+" texture units while this GPU supports only "+c),q+=1,O}function Q(O){const R=[];return R.push(O.wrapS),R.push(O.wrapT),R.push(O.wrapR||0),R.push(O.magFilter),R.push(O.minFilter),R.push(O.anisotropy),R.push(O.internalFormat),R.push(O.format),R.push(O.type),R.push(O.generateMipmaps),R.push(O.premultiplyAlpha),R.push(O.flipY),R.push(O.unpackAlignment),R.push(O.colorSpace),R.join()}function te(O,R){const G=r.get(O);if(O.isVideoTexture&&Pe(O),O.isRenderTargetTexture===!1&&O.version>0&&G.__version!==O.version){const de=O.image;if(de===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(de.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{se(G,O,R);return}}n.bindTexture(t.TEXTURE_2D,G.__webglTexture,t.TEXTURE0+R)}function H(O,R){const G=r.get(O);if(O.version>0&&G.__version!==O.version){se(G,O,R);return}n.bindTexture(t.TEXTURE_2D_ARRAY,G.__webglTexture,t.TEXTURE0+R)}function X(O,R){const G=r.get(O);if(O.version>0&&G.__version!==O.version){se(G,O,R);return}n.bindTexture(t.TEXTURE_3D,G.__webglTexture,t.TEXTURE0+R)}function Z(O,R){const G=r.get(O);if(O.version>0&&G.__version!==O.version){ce(G,O,R);return}n.bindTexture(t.TEXTURE_CUBE_MAP,G.__webglTexture,t.TEXTURE0+R)}const ee={[lD]:t.REPEAT,[Bl]:t.CLAMP_TO_EDGE,[cD]:t.MIRRORED_REPEAT},Se={[Qi]:t.NEAREST,[c6]:t.NEAREST_MIPMAP_NEAREST,[SP]:t.NEAREST_MIPMAP_LINEAR,[cl]:t.LINEAR,[u_e]:t.LINEAR_MIPMAP_NEAREST,[_0]:t.LINEAR_MIPMAP_LINEAR},oe={[__e]:t.NEVER,[M_e]:t.ALWAYS,[N_e]:t.LESS,[LY]:t.LEQUAL,[C_e]:t.EQUAL,[T_e]:t.GEQUAL,[k_e]:t.GREATER,[A_e]:t.NOTEQUAL};function ie(O,R,G){if(G?(t.texParameteri(O,t.TEXTURE_WRAP_S,ee[R.wrapS]),t.texParameteri(O,t.TEXTURE_WRAP_T,ee[R.wrapT]),(O===t.TEXTURE_3D||O===t.TEXTURE_2D_ARRAY)&&t.texParameteri(O,t.TEXTURE_WRAP_R,ee[R.wrapR]),t.texParameteri(O,t.TEXTURE_MAG_FILTER,Se[R.magFilter]),t.texParameteri(O,t.TEXTURE_MIN_FILTER,Se[R.minFilter])):(t.texParameteri(O,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(O,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),(O===t.TEXTURE_3D||O===t.TEXTURE_2D_ARRAY)&&t.texParameteri(O,t.TEXTURE_WRAP_R,t.CLAMP_TO_EDGE),(R.wrapS!==Bl||R.wrapT!==Bl)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),t.texParameteri(O,t.TEXTURE_MAG_FILTER,E(R.magFilter)),t.texParameteri(O,t.TEXTURE_MIN_FILTER,E(R.minFilter)),R.minFilter!==Qi&&R.minFilter!==cl&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),R.compareFunction&&(t.texParameteri(O,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(O,t.TEXTURE_COMPARE_FUNC,oe[R.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){const de=e.get("EXT_texture_filter_anisotropic");if(R.magFilter===Qi||R.minFilter!==SP&&R.minFilter!==_0||R.type===Ud&&e.has("OES_texture_float_linear")===!1||l===!1&&R.type===N0&&e.has("OES_texture_half_float_linear")===!1)return;(R.anisotropy>1||r.get(R).__currentAnisotropy)&&(t.texParameterf(O,de.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(R.anisotropy,i.getMaxAnisotropy())),r.get(R).__currentAnisotropy=R.anisotropy)}}function me(O,R){let G=!1;O.__webglInit===void 0&&(O.__webglInit=!0,R.addEventListener("dispose",B));const de=R.source;let ge=g.get(de);ge===void 0&&(ge={},g.set(de,ge));const ae=Q(R);if(ae!==O.__cacheKey){ge[ae]===void 0&&(ge[ae]={texture:t.createTexture(),usedTimes:0},o.memory.textures++,G=!0),ge[ae].usedTimes++;const Ue=ge[O.__cacheKey];Ue!==void 0&&(ge[O.__cacheKey].usedTimes--,Ue.usedTimes===0&&D(R)),O.__cacheKey=ae,O.__webglTexture=ge[ae].texture}return G}function se(O,R,G){let de=t.TEXTURE_2D;(R.isDataArrayTexture||R.isCompressedArrayTexture)&&(de=t.TEXTURE_2D_ARRAY),R.isData3DTexture&&(de=t.TEXTURE_3D);const ge=me(O,R),ae=R.source;n.bindTexture(de,O.__webglTexture,t.TEXTURE0+G);const Ue=r.get(ae);if(ae.version!==Ue.__version||ge===!0){n.activeTexture(t.TEXTURE0+G);const ze=Br.getPrimaries(Br.workingColorSpace),$e=R.colorSpace===ul?null:Br.getPrimaries(R.colorSpace),Re=R.colorSpace===ul||ze===$e?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,R.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,R.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,R.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,Re);const pe=k(R)&&A(R.image)===!1;let ve=N(R.image,pe,!1,u);ve=be(R,ve);const Ne=A(ve)||l,xe=s.convert(R.format,R.colorSpace);let we=s.convert(R.type),qe=j(R.internalFormat,xe,we,R.colorSpace,R.isVideoTexture);ie(de,R,Ne);let ke;const nt=R.mipmaps,De=l&&R.isVideoTexture!==!0&&qe!==DY,We=Ue.__version===void 0||ge===!0,Oe=M(R,ve,Ne);if(R.isDepthTexture)qe=t.DEPTH_COMPONENT,l?R.type===Ud?qe=t.DEPTH_COMPONENT32F:R.type===Sh?qe=t.DEPTH_COMPONENT24:R.type===mf?qe=t.DEPTH24_STENCIL8:qe=t.DEPTH_COMPONENT16:R.type===Ud&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),R.format===ff&&qe===t.DEPTH_COMPONENT&&R.type!==eL&&R.type!==Sh&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),R.type=Sh,we=s.convert(R.type)),R.format===wb&&qe===t.DEPTH_COMPONENT&&(qe=t.DEPTH_STENCIL,R.type!==mf&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),R.type=mf,we=s.convert(R.type))),We&&(De?n.texStorage2D(t.TEXTURE_2D,1,qe,ve.width,ve.height):n.texImage2D(t.TEXTURE_2D,0,qe,ve.width,ve.height,0,xe,we,null));else if(R.isDataTexture)if(nt.length>0&&Ne){De&&We&&n.texStorage2D(t.TEXTURE_2D,Oe,qe,nt[0].width,nt[0].height);for(let je=0,Ve=nt.length;je<Ve;je++)ke=nt[je],De?n.texSubImage2D(t.TEXTURE_2D,je,0,0,ke.width,ke.height,xe,we,ke.data):n.texImage2D(t.TEXTURE_2D,je,qe,ke.width,ke.height,0,xe,we,ke.data);R.generateMipmaps=!1}else De?(We&&n.texStorage2D(t.TEXTURE_2D,Oe,qe,ve.width,ve.height),n.texSubImage2D(t.TEXTURE_2D,0,0,0,ve.width,ve.height,xe,we,ve.data)):n.texImage2D(t.TEXTURE_2D,0,qe,ve.width,ve.height,0,xe,we,ve.data);else if(R.isCompressedTexture)if(R.isCompressedArrayTexture){De&&We&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Oe,qe,nt[0].width,nt[0].height,ve.depth);for(let je=0,Ve=nt.length;je<Ve;je++)ke=nt[je],R.format!==dl?xe!==null?De?n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,je,0,0,0,ke.width,ke.height,ve.depth,xe,ke.data,0,0):n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,je,qe,ke.width,ke.height,ve.depth,0,ke.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):De?n.texSubImage3D(t.TEXTURE_2D_ARRAY,je,0,0,0,ke.width,ke.height,ve.depth,xe,we,ke.data):n.texImage3D(t.TEXTURE_2D_ARRAY,je,qe,ke.width,ke.height,ve.depth,0,xe,we,ke.data)}else{De&&We&&n.texStorage2D(t.TEXTURE_2D,Oe,qe,nt[0].width,nt[0].height);for(let je=0,Ve=nt.length;je<Ve;je++)ke=nt[je],R.format!==dl?xe!==null?De?n.compressedTexSubImage2D(t.TEXTURE_2D,je,0,0,ke.width,ke.height,xe,ke.data):n.compressedTexImage2D(t.TEXTURE_2D,je,qe,ke.width,ke.height,0,ke.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):De?n.texSubImage2D(t.TEXTURE_2D,je,0,0,ke.width,ke.height,xe,we,ke.data):n.texImage2D(t.TEXTURE_2D,je,qe,ke.width,ke.height,0,xe,we,ke.data)}else if(R.isDataArrayTexture)De?(We&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Oe,qe,ve.width,ve.height,ve.depth),n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,ve.width,ve.height,ve.depth,xe,we,ve.data)):n.texImage3D(t.TEXTURE_2D_ARRAY,0,qe,ve.width,ve.height,ve.depth,0,xe,we,ve.data);else if(R.isData3DTexture)De?(We&&n.texStorage3D(t.TEXTURE_3D,Oe,qe,ve.width,ve.height,ve.depth),n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,ve.width,ve.height,ve.depth,xe,we,ve.data)):n.texImage3D(t.TEXTURE_3D,0,qe,ve.width,ve.height,ve.depth,0,xe,we,ve.data);else if(R.isFramebufferTexture){if(We)if(De)n.texStorage2D(t.TEXTURE_2D,Oe,qe,ve.width,ve.height);else{let je=ve.width,Ve=ve.height;for(let ot=0;ot<Oe;ot++)n.texImage2D(t.TEXTURE_2D,ot,qe,je,Ve,0,xe,we,null),je>>=1,Ve>>=1}}else if(nt.length>0&&Ne){De&&We&&n.texStorage2D(t.TEXTURE_2D,Oe,qe,nt[0].width,nt[0].height);for(let je=0,Ve=nt.length;je<Ve;je++)ke=nt[je],De?n.texSubImage2D(t.TEXTURE_2D,je,0,0,xe,we,ke):n.texImage2D(t.TEXTURE_2D,je,qe,xe,we,ke);R.generateMipmaps=!1}else De?(We&&n.texStorage2D(t.TEXTURE_2D,Oe,qe,ve.width,ve.height),n.texSubImage2D(t.TEXTURE_2D,0,0,0,xe,we,ve)):n.texImage2D(t.TEXTURE_2D,0,qe,xe,we,ve);P(R,Ne)&&C(de),Ue.__version=ae.version,R.onUpdate&&R.onUpdate(R)}O.__version=R.version}function ce(O,R,G){if(R.image.length!==6)return;const de=me(O,R),ge=R.source;n.bindTexture(t.TEXTURE_CUBE_MAP,O.__webglTexture,t.TEXTURE0+G);const ae=r.get(ge);if(ge.version!==ae.__version||de===!0){n.activeTexture(t.TEXTURE0+G);const Ue=Br.getPrimaries(Br.workingColorSpace),ze=R.colorSpace===ul?null:Br.getPrimaries(R.colorSpace),$e=R.colorSpace===ul||Ue===ze?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,R.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,R.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,R.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,$e);const Re=R.isCompressedTexture||R.image[0].isCompressedTexture,pe=R.image[0]&&R.image[0].isDataTexture,ve=[];for(let je=0;je<6;je++)!Re&&!pe?ve[je]=N(R.image[je],!1,!0,d):ve[je]=pe?R.image[je].image:R.image[je],ve[je]=be(R,ve[je]);const Ne=ve[0],xe=A(Ne)||l,we=s.convert(R.format,R.colorSpace),qe=s.convert(R.type),ke=j(R.internalFormat,we,qe,R.colorSpace),nt=l&&R.isVideoTexture!==!0,De=ae.__version===void 0||de===!0;let We=M(R,Ne,xe);ie(t.TEXTURE_CUBE_MAP,R,xe);let Oe;if(Re){nt&&De&&n.texStorage2D(t.TEXTURE_CUBE_MAP,We,ke,Ne.width,Ne.height);for(let je=0;je<6;je++){Oe=ve[je].mipmaps;for(let Ve=0;Ve<Oe.length;Ve++){const ot=Oe[Ve];R.format!==dl?we!==null?nt?n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+je,Ve,0,0,ot.width,ot.height,we,ot.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+je,Ve,ke,ot.width,ot.height,0,ot.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):nt?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+je,Ve,0,0,ot.width,ot.height,we,qe,ot.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+je,Ve,ke,ot.width,ot.height,0,we,qe,ot.data)}}}else{Oe=R.mipmaps,nt&&De&&(Oe.length>0&&We++,n.texStorage2D(t.TEXTURE_CUBE_MAP,We,ke,ve[0].width,ve[0].height));for(let je=0;je<6;je++)if(pe){nt?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+je,0,0,0,ve[je].width,ve[je].height,we,qe,ve[je].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+je,0,ke,ve[je].width,ve[je].height,0,we,qe,ve[je].data);for(let Ve=0;Ve<Oe.length;Ve++){const kt=Oe[Ve].image[je].image;nt?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+je,Ve+1,0,0,kt.width,kt.height,we,qe,kt.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+je,Ve+1,ke,kt.width,kt.height,0,we,qe,kt.data)}}else{nt?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+je,0,0,0,we,qe,ve[je]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+je,0,ke,we,qe,ve[je]);for(let Ve=0;Ve<Oe.length;Ve++){const ot=Oe[Ve];nt?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+je,Ve+1,0,0,we,qe,ot.image[je]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+je,Ve+1,ke,we,qe,ot.image[je])}}}P(R,xe)&&C(t.TEXTURE_CUBE_MAP),ae.__version=ge.version,R.onUpdate&&R.onUpdate(R)}O.__version=R.version}function Ce(O,R,G,de,ge,ae){const Ue=s.convert(G.format,G.colorSpace),ze=s.convert(G.type),$e=j(G.internalFormat,Ue,ze,G.colorSpace);if(!r.get(R).__hasExternalTextures){const pe=Math.max(1,R.width>>ae),ve=Math.max(1,R.height>>ae);ge===t.TEXTURE_3D||ge===t.TEXTURE_2D_ARRAY?n.texImage3D(ge,ae,$e,pe,ve,R.depth,0,Ue,ze,null):n.texImage2D(ge,ae,$e,pe,ve,0,Ue,ze,null)}n.bindFramebuffer(t.FRAMEBUFFER,O),Fe(R)?f.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,de,ge,r.get(G).__webglTexture,0,ue(R)):(ge===t.TEXTURE_2D||ge>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&ge<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,de,ge,r.get(G).__webglTexture,ae),n.bindFramebuffer(t.FRAMEBUFFER,null)}function le(O,R,G){if(t.bindRenderbuffer(t.RENDERBUFFER,O),R.depthBuffer&&!R.stencilBuffer){let de=l===!0?t.DEPTH_COMPONENT24:t.DEPTH_COMPONENT16;if(G||Fe(R)){const ge=R.depthTexture;ge&&ge.isDepthTexture&&(ge.type===Ud?de=t.DEPTH_COMPONENT32F:ge.type===Sh&&(de=t.DEPTH_COMPONENT24));const ae=ue(R);Fe(R)?f.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,ae,de,R.width,R.height):t.renderbufferStorageMultisample(t.RENDERBUFFER,ae,de,R.width,R.height)}else t.renderbufferStorage(t.RENDERBUFFER,de,R.width,R.height);t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,O)}else if(R.depthBuffer&&R.stencilBuffer){const de=ue(R);G&&Fe(R)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,de,t.DEPTH24_STENCIL8,R.width,R.height):Fe(R)?f.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,de,t.DEPTH24_STENCIL8,R.width,R.height):t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_STENCIL,R.width,R.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,O)}else{const de=R.isWebGLMultipleRenderTargets===!0?R.texture:[R.texture];for(let ge=0;ge<de.length;ge++){const ae=de[ge],Ue=s.convert(ae.format,ae.colorSpace),ze=s.convert(ae.type),$e=j(ae.internalFormat,Ue,ze,ae.colorSpace),Re=ue(R);G&&Fe(R)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,Re,$e,R.width,R.height):Fe(R)?f.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,Re,$e,R.width,R.height):t.renderbufferStorage(t.RENDERBUFFER,$e,R.width,R.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function Le(O,R){if(R&&R.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(t.FRAMEBUFFER,O),!(R.depthTexture&&R.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!r.get(R.depthTexture).__webglTexture||R.depthTexture.image.width!==R.width||R.depthTexture.image.height!==R.height)&&(R.depthTexture.image.width=R.width,R.depthTexture.image.height=R.height,R.depthTexture.needsUpdate=!0),te(R.depthTexture,0);const de=r.get(R.depthTexture).__webglTexture,ge=ue(R);if(R.depthTexture.format===ff)Fe(R)?f.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,de,0,ge):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,de,0);else if(R.depthTexture.format===wb)Fe(R)?f.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,de,0,ge):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,de,0);else throw new Error("Unknown depthTexture format")}function V(O){const R=r.get(O),G=O.isWebGLCubeRenderTarget===!0;if(O.depthTexture&&!R.__autoAllocateDepthBuffer){if(G)throw new Error("target.depthTexture not supported in Cube render targets");Le(R.__webglFramebuffer,O)}else if(G){R.__webglDepthbuffer=[];for(let de=0;de<6;de++)n.bindFramebuffer(t.FRAMEBUFFER,R.__webglFramebuffer[de]),R.__webglDepthbuffer[de]=t.createRenderbuffer(),le(R.__webglDepthbuffer[de],O,!1)}else n.bindFramebuffer(t.FRAMEBUFFER,R.__webglFramebuffer),R.__webglDepthbuffer=t.createRenderbuffer(),le(R.__webglDepthbuffer,O,!1);n.bindFramebuffer(t.FRAMEBUFFER,null)}function K(O,R,G){const de=r.get(O);R!==void 0&&Ce(de.__webglFramebuffer,O,O.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),G!==void 0&&V(O)}function fe(O){const R=O.texture,G=r.get(O),de=r.get(R);O.addEventListener("dispose",L),O.isWebGLMultipleRenderTargets!==!0&&(de.__webglTexture===void 0&&(de.__webglTexture=t.createTexture()),de.__version=R.version,o.memory.textures++);const ge=O.isWebGLCubeRenderTarget===!0,ae=O.isWebGLMultipleRenderTargets===!0,Ue=A(O)||l;if(ge){G.__webglFramebuffer=[];for(let ze=0;ze<6;ze++)if(l&&R.mipmaps&&R.mipmaps.length>0){G.__webglFramebuffer[ze]=[];for(let $e=0;$e<R.mipmaps.length;$e++)G.__webglFramebuffer[ze][$e]=t.createFramebuffer()}else G.__webglFramebuffer[ze]=t.createFramebuffer()}else{if(l&&R.mipmaps&&R.mipmaps.length>0){G.__webglFramebuffer=[];for(let ze=0;ze<R.mipmaps.length;ze++)G.__webglFramebuffer[ze]=t.createFramebuffer()}else G.__webglFramebuffer=t.createFramebuffer();if(ae)if(i.drawBuffers){const ze=O.texture;for(let $e=0,Re=ze.length;$e<Re;$e++){const pe=r.get(ze[$e]);pe.__webglTexture===void 0&&(pe.__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&&O.samples>0&&Fe(O)===!1){const ze=ae?R:[R];G.__webglMultisampledFramebuffer=t.createFramebuffer(),G.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,G.__webglMultisampledFramebuffer);for(let $e=0;$e<ze.length;$e++){const Re=ze[$e];G.__webglColorRenderbuffer[$e]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,G.__webglColorRenderbuffer[$e]);const pe=s.convert(Re.format,Re.colorSpace),ve=s.convert(Re.type),Ne=j(Re.internalFormat,pe,ve,Re.colorSpace,O.isXRRenderTarget===!0),xe=ue(O);t.renderbufferStorageMultisample(t.RENDERBUFFER,xe,Ne,O.width,O.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+$e,t.RENDERBUFFER,G.__webglColorRenderbuffer[$e])}t.bindRenderbuffer(t.RENDERBUFFER,null),O.depthBuffer&&(G.__webglDepthRenderbuffer=t.createRenderbuffer(),le(G.__webglDepthRenderbuffer,O,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(ge){n.bindTexture(t.TEXTURE_CUBE_MAP,de.__webglTexture),ie(t.TEXTURE_CUBE_MAP,R,Ue);for(let ze=0;ze<6;ze++)if(l&&R.mipmaps&&R.mipmaps.length>0)for(let $e=0;$e<R.mipmaps.length;$e++)Ce(G.__webglFramebuffer[ze][$e],O,R,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+ze,$e);else Ce(G.__webglFramebuffer[ze],O,R,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+ze,0);P(R,Ue)&&C(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(ae){const ze=O.texture;for(let $e=0,Re=ze.length;$e<Re;$e++){const pe=ze[$e],ve=r.get(pe);n.bindTexture(t.TEXTURE_2D,ve.__webglTexture),ie(t.TEXTURE_2D,pe,Ue),Ce(G.__webglFramebuffer,O,pe,t.COLOR_ATTACHMENT0+$e,t.TEXTURE_2D,0),P(pe,Ue)&&C(t.TEXTURE_2D)}n.unbindTexture()}else{let ze=t.TEXTURE_2D;if((O.isWebGL3DRenderTarget||O.isWebGLArrayRenderTarget)&&(l?ze=O.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),n.bindTexture(ze,de.__webglTexture),ie(ze,R,Ue),l&&R.mipmaps&&R.mipmaps.length>0)for(let $e=0;$e<R.mipmaps.length;$e++)Ce(G.__webglFramebuffer[$e],O,R,t.COLOR_ATTACHMENT0,ze,$e);else Ce(G.__webglFramebuffer,O,R,t.COLOR_ATTACHMENT0,ze,0);P(R,Ue)&&C(ze),n.unbindTexture()}O.depthBuffer&&V(O)}function Y(O){const R=A(O)||l,G=O.isWebGLMultipleRenderTargets===!0?O.texture:[O.texture];for(let de=0,ge=G.length;de<ge;de++){const ae=G[de];if(P(ae,R)){const Ue=O.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:t.TEXTURE_2D,ze=r.get(ae).__webglTexture;n.bindTexture(Ue,ze),C(Ue),n.unbindTexture()}}}function re(O){if(l&&O.samples>0&&Fe(O)===!1){const R=O.isWebGLMultipleRenderTargets?O.texture:[O.texture],G=O.width,de=O.height;let ge=t.COLOR_BUFFER_BIT;const ae=[],Ue=O.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,ze=r.get(O),$e=O.isWebGLMultipleRenderTargets===!0;if($e)for(let Re=0;Re<R.length;Re++)n.bindFramebuffer(t.FRAMEBUFFER,ze.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Re,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,ze.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+Re,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,ze.__webglMultisampledFramebuffer),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,ze.__webglFramebuffer);for(let Re=0;Re<R.length;Re++){ae.push(t.COLOR_ATTACHMENT0+Re),O.depthBuffer&&ae.push(Ue);const pe=ze.__ignoreDepthValues!==void 0?ze.__ignoreDepthValues:!1;if(pe===!1&&(O.depthBuffer&&(ge|=t.DEPTH_BUFFER_BIT),O.stencilBuffer&&(ge|=t.STENCIL_BUFFER_BIT)),$e&&t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,ze.__webglColorRenderbuffer[Re]),pe===!0&&(t.invalidateFramebuffer(t.READ_FRAMEBUFFER,[Ue]),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[Ue])),$e){const ve=r.get(R[Re]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,ve,0)}t.blitFramebuffer(0,0,G,de,0,0,G,de,ge,t.NEAREST),p&&t.invalidateFramebuffer(t.READ_FRAMEBUFFER,ae)}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),$e)for(let Re=0;Re<R.length;Re++){n.bindFramebuffer(t.FRAMEBUFFER,ze.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Re,t.RENDERBUFFER,ze.__webglColorRenderbuffer[Re]);const pe=r.get(R[Re]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,ze.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+Re,t.TEXTURE_2D,pe,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,ze.__webglMultisampledFramebuffer)}}function ue(O){return Math.min(h,O.samples)}function Fe(O){const R=r.get(O);return l&&O.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&R.__useRenderToTexture!==!1}function Pe(O){const R=o.render.frame;x.get(O)!==R&&(x.set(O,R),O.update())}function be(O,R){const G=O.colorSpace,de=O.format,ge=O.type;return O.isCompressedTexture===!0||O.isVideoTexture===!0||O.format===uD||G!==su&&G!==ul&&(Br.getTransfer(G)===oa?l===!1?e.has("EXT_sRGB")===!0&&de===dl?(O.format=uD,O.minFilter=cl,O.generateMipmaps=!1):R=zY.sRGBToLinear(R):(de!==dl||ge!==Ih)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",G)),R}this.allocateTextureUnit=W,this.resetTextureUnits=z,this.setTexture2D=te,this.setTexture2DArray=H,this.setTexture3D=X,this.setTextureCube=Z,this.rebindTextures=K,this.setupRenderTarget=fe,this.updateRenderTargetMipmap=Y,this.updateMultisampleRenderTarget=re,this.setupDepthRenderbuffer=V,this.setupFrameBufferTexture=Ce,this.useMultisampledRTT=Fe}function HAe(t,e,n){const r=n.isWebGL2;function i(s,o=ul){let l;const c=Br.getTransfer(o);if(s===Ih)return t.UNSIGNED_BYTE;if(s===TY)return t.UNSIGNED_SHORT_4_4_4_4;if(s===MY)return t.UNSIGNED_SHORT_5_5_5_1;if(s===h_e)return t.BYTE;if(s===m_e)return t.SHORT;if(s===eL)return t.UNSIGNED_SHORT;if(s===AY)return t.INT;if(s===Sh)return t.UNSIGNED_INT;if(s===Ud)return t.FLOAT;if(s===N0)return r?t.HALF_FLOAT:(l=e.get("OES_texture_half_float"),l!==null?l.HALF_FLOAT_OES:null);if(s===f_e)return t.ALPHA;if(s===dl)return t.RGBA;if(s===p_e)return t.LUMINANCE;if(s===g_e)return t.LUMINANCE_ALPHA;if(s===ff)return t.DEPTH_COMPONENT;if(s===wb)return t.DEPTH_STENCIL;if(s===uD)return l=e.get("EXT_sRGB"),l!==null?l.SRGB_ALPHA_EXT:null;if(s===b_e)return t.RED;if(s===PY)return t.RED_INTEGER;if(s===x_e)return t.RG;if(s===EY)return t.RG_INTEGER;if(s===jY)return t.RGBA_INTEGER;if(s===_P||s===NP||s===CP||s===kP)if(c===oa)if(l=e.get("WEBGL_compressed_texture_s3tc_srgb"),l!==null){if(s===_P)return l.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===NP)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===CP)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===kP)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(l=e.get("WEBGL_compressed_texture_s3tc"),l!==null){if(s===_P)return l.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===NP)return l.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===CP)return l.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===kP)return l.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===d6||s===u6||s===h6||s===m6)if(l=e.get("WEBGL_compressed_texture_pvrtc"),l!==null){if(s===d6)return l.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===u6)return l.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===h6)return l.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===m6)return l.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===DY)return l=e.get("WEBGL_compressed_texture_etc1"),l!==null?l.COMPRESSED_RGB_ETC1_WEBGL:null;if(s===f6||s===p6)if(l=e.get("WEBGL_compressed_texture_etc"),l!==null){if(s===f6)return c===oa?l.COMPRESSED_SRGB8_ETC2:l.COMPRESSED_RGB8_ETC2;if(s===p6)return c===oa?l.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:l.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(s===g6||s===b6||s===x6||s===y6||s===v6||s===w6||s===S6||s===_6||s===N6||s===C6||s===k6||s===A6||s===T6||s===M6)if(l=e.get("WEBGL_compressed_texture_astc"),l!==null){if(s===g6)return c===oa?l.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:l.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===b6)return c===oa?l.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:l.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===x6)return c===oa?l.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:l.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===y6)return c===oa?l.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:l.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===v6)return c===oa?l.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:l.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===w6)return c===oa?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:l.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===S6)return c===oa?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:l.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===_6)return c===oa?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:l.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===N6)return c===oa?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:l.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===C6)return c===oa?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:l.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===k6)return c===oa?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:l.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===A6)return c===oa?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:l.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===T6)return c===oa?l.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:l.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===M6)return c===oa?l.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:l.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===AP||s===P6||s===E6)if(l=e.get("EXT_texture_compression_bptc"),l!==null){if(s===AP)return c===oa?l.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:l.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(s===P6)return l.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(s===E6)return l.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(s===y_e||s===j6||s===D6||s===R6)if(l=e.get("EXT_texture_compression_rgtc"),l!==null){if(s===AP)return l.COMPRESSED_RED_RGTC1_EXT;if(s===j6)return l.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(s===D6)return l.COMPRESSED_RED_GREEN_RGTC2_EXT;if(s===R6)return l.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return s===mf?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 $Ae extends Ao{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class Ty extends Fs{constructor(){super(),this.isGroup=!0,this.type="Group"}}const VAe={type:"move"};class YP{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Ty,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 Ty,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Je,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Je),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Ty,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Je,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Je),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const n=this._hand;if(n)for(const r of e.hand.values())this._getHandJoint(n,r)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,n,r){let i=null,s=null,o=null;const l=this._targetRay,c=this._grip,d=this._hand;if(e&&n.session.visibilityState!=="visible-blurred"){if(d&&e.hand){o=!0;for(const v of e.hand.values()){const g=n.getJointPose(v,r),y=this._getHandJoint(d,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 u=d.joints["index-finger-tip"],h=d.joints["thumb-tip"],f=u.position.distanceTo(h.position),p=.02,x=.005;d.inputState.pinching&&f>p+x?(d.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!d.inputState.pinching&&f<=p-x&&(d.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(VAe)))}return l!==null&&(l.visible=i!==null),c!==null&&(c.visible=s!==null),d!==null&&(d.visible=o!==null),this}_getHandJoint(e,n){if(e.joints[n.jointName]===void 0){const r=new Ty;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[n.jointName]=r,e.add(r)}return e.joints[n.jointName]}}class qAe extends np{constructor(e,n){super();const r=this;let i=null,s=1,o=null,l="local-floor",c=1,d=null,u=null,h=null,f=null,p=null,x=null;const v=n.getContextAttributes();let g=null,y=null;const _=[],N=[],A=new Nn;let k=null;const P=new Ao;P.layers.enable(1),P.viewport=new $r;const C=new Ao;C.layers.enable(2),C.viewport=new $r;const j=[P,C],M=new $Ae;M.layers.enable(1),M.layers.enable(2);let E=null,B=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Z){let ee=_[Z];return ee===void 0&&(ee=new YP,_[Z]=ee),ee.getTargetRaySpace()},this.getControllerGrip=function(Z){let ee=_[Z];return ee===void 0&&(ee=new YP,_[Z]=ee),ee.getGripSpace()},this.getHand=function(Z){let ee=_[Z];return ee===void 0&&(ee=new YP,_[Z]=ee),ee.getHandSpace()};function L(Z){const ee=N.indexOf(Z.inputSource);if(ee===-1)return;const Se=_[ee];Se!==void 0&&(Se.update(Z.inputSource,Z.frame,d||o),Se.dispatchEvent({type:Z.type,data:Z.inputSource}))}function U(){i.removeEventListener("select",L),i.removeEventListener("selectstart",L),i.removeEventListener("selectend",L),i.removeEventListener("squeeze",L),i.removeEventListener("squeezestart",L),i.removeEventListener("squeezeend",L),i.removeEventListener("end",U),i.removeEventListener("inputsourceschange",D);for(let Z=0;Z<_.length;Z++){const ee=N[Z];ee!==null&&(N[Z]=null,_[Z].disconnect(ee))}E=null,B=null,e.setRenderTarget(g),p=null,f=null,h=null,i=null,y=null,X.stop(),r.isPresenting=!1,e.setPixelRatio(k),e.setSize(A.width,A.height,!1),r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(Z){s=Z,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(Z){l=Z,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return d||o},this.setReferenceSpace=function(Z){d=Z},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(Z){if(i=Z,i!==null){if(g=e.getRenderTarget(),i.addEventListener("select",L),i.addEventListener("selectstart",L),i.addEventListener("selectend",L),i.addEventListener("squeeze",L),i.addEventListener("squeezestart",L),i.addEventListener("squeezeend",L),i.addEventListener("end",U),i.addEventListener("inputsourceschange",D),v.xrCompatible!==!0&&await n.makeXRCompatible(),k=e.getPixelRatio(),e.getSize(A),i.renderState.layers===void 0||e.capabilities.isWebGL2===!1){const ee={antialias:i.renderState.layers===void 0?v.antialias:!0,alpha:!0,depth:v.depth,stencil:v.stencil,framebufferScaleFactor:s};p=new XRWebGLLayer(i,n,ee),i.updateRenderState({baseLayer:p}),e.setPixelRatio(1),e.setSize(p.framebufferWidth,p.framebufferHeight,!1),y=new Of(p.framebufferWidth,p.framebufferHeight,{format:dl,type:Ih,colorSpace:e.outputColorSpace,stencilBuffer:v.stencil})}else{let ee=null,Se=null,oe=null;v.depth&&(oe=v.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,ee=v.stencil?wb:ff,Se=v.stencil?mf:Sh);const ie={colorFormat:n.RGBA8,depthFormat:oe,scaleFactor:s};h=new XRWebGLBinding(i,n),f=h.createProjectionLayer(ie),i.updateRenderState({layers:[f]}),e.setPixelRatio(1),e.setSize(f.textureWidth,f.textureHeight,!1),y=new Of(f.textureWidth,f.textureHeight,{format:dl,type:Ih,depthTexture:new QY(f.textureWidth,f.textureHeight,Se,void 0,void 0,void 0,void 0,void 0,void 0,ee),stencilBuffer:v.stencil,colorSpace:e.outputColorSpace,samples:v.antialias?4:0});const me=e.properties.get(y);me.__ignoreDepthValues=f.ignoreDepthValues}y.isXRRenderTarget=!0,this.setFoveation(c),d=null,o=await i.requestReferenceSpace(l),X.setContext(i),X.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode};function D(Z){for(let ee=0;ee<Z.removed.length;ee++){const Se=Z.removed[ee],oe=N.indexOf(Se);oe>=0&&(N[oe]=null,_[oe].disconnect(Se))}for(let ee=0;ee<Z.added.length;ee++){const Se=Z.added[ee];let oe=N.indexOf(Se);if(oe===-1){for(let me=0;me<_.length;me++)if(me>=N.length){N.push(Se),oe=me;break}else if(N[me]===null){N[me]=Se,oe=me;break}if(oe===-1)break}const ie=_[oe];ie&&ie.connect(Se)}}const $=new Je,q=new Je;function z(Z,ee,Se){$.setFromMatrixPosition(ee.matrixWorld),q.setFromMatrixPosition(Se.matrixWorld);const oe=$.distanceTo(q),ie=ee.projectionMatrix.elements,me=Se.projectionMatrix.elements,se=ie[14]/(ie[10]-1),ce=ie[14]/(ie[10]+1),Ce=(ie[9]+1)/ie[5],le=(ie[9]-1)/ie[5],Le=(ie[8]-1)/ie[0],V=(me[8]+1)/me[0],K=se*Le,fe=se*V,Y=oe/(-Le+V),re=Y*-Le;ee.matrixWorld.decompose(Z.position,Z.quaternion,Z.scale),Z.translateX(re),Z.translateZ(Y),Z.matrixWorld.compose(Z.position,Z.quaternion,Z.scale),Z.matrixWorldInverse.copy(Z.matrixWorld).invert();const ue=se+Y,Fe=ce+Y,Pe=K-re,be=fe+(oe-re),O=Ce*ce/Fe*ue,R=le*ce/Fe*ue;Z.projectionMatrix.makePerspective(Pe,be,O,R,ue,Fe),Z.projectionMatrixInverse.copy(Z.projectionMatrix).invert()}function W(Z,ee){ee===null?Z.matrixWorld.copy(Z.matrix):Z.matrixWorld.multiplyMatrices(ee.matrixWorld,Z.matrix),Z.matrixWorldInverse.copy(Z.matrixWorld).invert()}this.updateCamera=function(Z){if(i===null)return;M.near=C.near=P.near=Z.near,M.far=C.far=P.far=Z.far,(E!==M.near||B!==M.far)&&(i.updateRenderState({depthNear:M.near,depthFar:M.far}),E=M.near,B=M.far);const ee=Z.parent,Se=M.cameras;W(M,ee);for(let oe=0;oe<Se.length;oe++)W(Se[oe],ee);Se.length===2?z(M,P,C):M.projectionMatrix.copy(P.projectionMatrix),Q(Z,M,ee)};function Q(Z,ee,Se){Se===null?Z.matrix.copy(ee.matrixWorld):(Z.matrix.copy(Se.matrixWorld),Z.matrix.invert(),Z.matrix.multiply(ee.matrixWorld)),Z.matrix.decompose(Z.position,Z.quaternion,Z.scale),Z.updateMatrixWorld(!0),Z.projectionMatrix.copy(ee.projectionMatrix),Z.projectionMatrixInverse.copy(ee.projectionMatrixInverse),Z.isPerspectiveCamera&&(Z.fov=k0*2*Math.atan(1/Z.projectionMatrix.elements[5]),Z.zoom=1)}this.getCamera=function(){return M},this.getFoveation=function(){if(!(f===null&&p===null))return c},this.setFoveation=function(Z){c=Z,f!==null&&(f.fixedFoveation=Z),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=Z)};let te=null;function H(Z,ee){if(u=ee.getViewerPose(d||o),x=ee,u!==null){const Se=u.views;p!==null&&(e.setRenderTargetFramebuffer(y,p.framebuffer),e.setRenderTarget(y));let oe=!1;Se.length!==M.cameras.length&&(M.cameras.length=0,oe=!0);for(let ie=0;ie<Se.length;ie++){const me=Se[ie];let se=null;if(p!==null)se=p.getViewport(me);else{const Ce=h.getViewSubImage(f,me);se=Ce.viewport,ie===0&&(e.setRenderTargetTextures(y,Ce.colorTexture,f.ignoreDepthValues?void 0:Ce.depthStencilTexture),e.setRenderTarget(y))}let ce=j[ie];ce===void 0&&(ce=new Ao,ce.layers.enable(ie),ce.viewport=new $r,j[ie]=ce),ce.matrix.fromArray(me.transform.matrix),ce.matrix.decompose(ce.position,ce.quaternion,ce.scale),ce.projectionMatrix.fromArray(me.projectionMatrix),ce.projectionMatrixInverse.copy(ce.projectionMatrix).invert(),ce.viewport.set(se.x,se.y,se.width,se.height),ie===0&&(M.matrix.copy(ce.matrix),M.matrix.decompose(M.position,M.quaternion,M.scale)),oe===!0&&M.cameras.push(ce)}}for(let Se=0;Se<_.length;Se++){const oe=N[Se],ie=_[Se];oe!==null&&ie!==void 0&&ie.update(oe,ee,d||o)}te&&te(Z,ee),ee.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:ee}),x=null}const X=new YY;X.setAnimationLoop(H),this.setAnimationLoop=function(Z){te=Z},this.dispose=function(){}}}function GAe(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,WY(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),u(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?d(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).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 d(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 u(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===ao&&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 WAe(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 d(_,N){let A=i[_.id];A===void 0&&(x(_),A=u(_),i[_.id]=A,_.addEventListener("dispose",g));const k=N.program;r.updateUBOMapping(_,k);const P=e.render.frame;s[_.id]!==P&&(f(_),s[_.id]=P)}function u(_){const N=h();_.__bindingPointIndex=N;const A=t.createBuffer(),k=_.__size,P=_.usage;return t.bindBuffer(t.UNIFORM_BUFFER,A),t.bufferData(t.UNIFORM_BUFFER,k,P),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,k=_.__cache;t.bindBuffer(t.UNIFORM_BUFFER,N);for(let P=0,C=A.length;P<C;P++){const j=A[P];if(p(j,P,k)===!0){const M=j.__offset,E=Array.isArray(j.value)?j.value:[j.value];let B=0;for(let L=0;L<E.length;L++){const U=E[L],D=v(U);typeof U=="number"?(j.__data[0]=U,t.bufferSubData(t.UNIFORM_BUFFER,M+B,j.__data)):U.isMatrix3?(j.__data[0]=U.elements[0],j.__data[1]=U.elements[1],j.__data[2]=U.elements[2],j.__data[3]=U.elements[0],j.__data[4]=U.elements[3],j.__data[5]=U.elements[4],j.__data[6]=U.elements[5],j.__data[7]=U.elements[0],j.__data[8]=U.elements[6],j.__data[9]=U.elements[7],j.__data[10]=U.elements[8],j.__data[11]=U.elements[0]):(U.toArray(j.__data,B),B+=D.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,M,j.__data)}}t.bindBuffer(t.UNIFORM_BUFFER,null)}function p(_,N,A){const k=_.value;if(A[N]===void 0){if(typeof k=="number")A[N]=k;else{const P=Array.isArray(k)?k:[k],C=[];for(let j=0;j<P.length;j++)C.push(P[j].clone());A[N]=C}return!0}else if(typeof k=="number"){if(A[N]!==k)return A[N]=k,!0}else{const P=Array.isArray(A[N])?A[N]:[A[N]],C=Array.isArray(k)?k:[k];for(let j=0;j<P.length;j++){const M=P[j];if(M.equals(C[j])===!1)return M.copy(C[j]),!0}}return!1}function x(_){const N=_.uniforms;let A=0;const k=16;let P=0;for(let C=0,j=N.length;C<j;C++){const M=N[C],E={boundary:0,storage:0},B=Array.isArray(M.value)?M.value:[M.value];for(let L=0,U=B.length;L<U;L++){const D=B[L],$=v(D);E.boundary+=$.boundary,E.storage+=$.storage}if(M.__data=new Float32Array(E.storage/Float32Array.BYTES_PER_ELEMENT),M.__offset=A,C>0){P=A%k;const L=k-P;P!==0&&L-E.boundary<0&&(A+=k-P,M.__offset=A)}A+=E.storage}return P=A%k,P>0&&(A+=k-P),_.__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:d,dispose:y}}class fD{constructor(e={}){const{canvas:n=V_e(),context:r=null,depth:i=!0,stencil:s=!0,alpha:o=!1,antialias:l=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:d=!1,powerPreference:u="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=Oh,this.toneMappingExposure=1;const N=this;let A=!1,k=0,P=0,C=null,j=-1,M=null;const E=new $r,B=new $r;let L=null;const U=new hn(0);let D=0,$=n.width,q=n.height,z=1,W=null,Q=null;const te=new $r(0,0,$,q),H=new $r(0,0,$,q);let X=!1;const Z=new ck;let ee=!1,Se=!1,oe=null;const ie=new ra,me=new Nn,se=new Je,ce={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Ce(){return C===null?z:1}let le=r;function Le(Ie,_e){for(let tt=0;tt<Ie.length;tt++){const it=Ie[tt],Ke=n.getContext(it,_e);if(Ke!==null)return Ke}return null}try{const Ie={alpha:!0,depth:i,stencil:s,antialias:l,premultipliedAlpha:c,preserveDrawingBuffer:d,powerPreference:u,failIfMajorPerformanceCaveat:h};if("setAttribute"in n&&n.setAttribute("data-engine",`three.js r${sk}`),n.addEventListener("webglcontextlost",nt,!1),n.addEventListener("webglcontextrestored",De,!1),n.addEventListener("webglcontextcreationerror",We,!1),le===null){const _e=["webgl2","webgl","experimental-webgl"];if(N.isWebGL1Renderer===!0&&_e.shift(),le=Le(_e,Ie),le===null)throw Le(_e)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}typeof WebGLRenderingContext<"u"&&le instanceof WebGLRenderingContext&&console.warn("THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163."),le.getShaderPrecisionFormat===void 0&&(le.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(Ie){throw console.error("THREE.WebGLRenderer: "+Ie.message),Ie}let V,K,fe,Y,re,ue,Fe,Pe,be,O,R,G,de,ge,ae,Ue,ze,$e,Re,pe,ve,Ne,xe,we;function qe(){V=new ake(le),K=new QCe(le,V,e),V.init(K),Ne=new HAe(le,V,K),fe=new UAe(le,V,K),Y=new oke(le),re=new kAe,ue=new BAe(le,V,fe,re,K,Ne,Y),Fe=new JCe(N),Pe=new rke(N),be=new f1e(le,K),xe=new XCe(le,V,be,K),O=new ike(le,be,Y,xe),R=new uke(le,O,be,Y),Re=new dke(le,K,ue),Ue=new ZCe(re),G=new CAe(N,Fe,Pe,V,K,xe,Ue),de=new GAe(N,re),ge=new TAe,ae=new RAe(V,K),$e=new KCe(N,Fe,Pe,fe,R,f,c),ze=new zAe(N,R,K),we=new WAe(le,Y,K,fe),pe=new YCe(le,V,Y,K),ve=new ske(le,V,Y,K),Y.programs=G.programs,N.capabilities=K,N.extensions=V,N.properties=re,N.renderLists=ge,N.shadowMap=ze,N.state=fe,N.info=Y}qe();const ke=new qAe(N,le);this.xr=ke,this.getContext=function(){return le},this.getContextAttributes=function(){return le.getContextAttributes()},this.forceContextLoss=function(){const Ie=V.get("WEBGL_lose_context");Ie&&Ie.loseContext()},this.forceContextRestore=function(){const Ie=V.get("WEBGL_lose_context");Ie&&Ie.restoreContext()},this.getPixelRatio=function(){return z},this.setPixelRatio=function(Ie){Ie!==void 0&&(z=Ie,this.setSize($,q,!1))},this.getSize=function(Ie){return Ie.set($,q)},this.setSize=function(Ie,_e,tt=!0){if(ke.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}$=Ie,q=_e,n.width=Math.floor(Ie*z),n.height=Math.floor(_e*z),tt===!0&&(n.style.width=Ie+"px",n.style.height=_e+"px"),this.setViewport(0,0,Ie,_e)},this.getDrawingBufferSize=function(Ie){return Ie.set($*z,q*z).floor()},this.setDrawingBufferSize=function(Ie,_e,tt){$=Ie,q=_e,z=tt,n.width=Math.floor(Ie*tt),n.height=Math.floor(_e*tt),this.setViewport(0,0,Ie,_e)},this.getCurrentViewport=function(Ie){return Ie.copy(E)},this.getViewport=function(Ie){return Ie.copy(te)},this.setViewport=function(Ie,_e,tt,it){Ie.isVector4?te.set(Ie.x,Ie.y,Ie.z,Ie.w):te.set(Ie,_e,tt,it),fe.viewport(E.copy(te).multiplyScalar(z).floor())},this.getScissor=function(Ie){return Ie.copy(H)},this.setScissor=function(Ie,_e,tt,it){Ie.isVector4?H.set(Ie.x,Ie.y,Ie.z,Ie.w):H.set(Ie,_e,tt,it),fe.scissor(B.copy(H).multiplyScalar(z).floor())},this.getScissorTest=function(){return X},this.setScissorTest=function(Ie){fe.setScissorTest(X=Ie)},this.setOpaqueSort=function(Ie){W=Ie},this.setTransparentSort=function(Ie){Q=Ie},this.getClearColor=function(Ie){return Ie.copy($e.getClearColor())},this.setClearColor=function(){$e.setClearColor.apply($e,arguments)},this.getClearAlpha=function(){return $e.getClearAlpha()},this.setClearAlpha=function(){$e.setClearAlpha.apply($e,arguments)},this.clear=function(Ie=!0,_e=!0,tt=!0){let it=0;if(Ie){let Ke=!1;if(C!==null){const Lt=C.texture.format;Ke=Lt===jY||Lt===EY||Lt===PY}if(Ke){const Lt=C.texture.type,ye=Lt===Ih||Lt===Sh||Lt===eL||Lt===mf||Lt===TY||Lt===MY,He=$e.getClearColor(),Ye=$e.getClearAlpha(),Xe=He.r,Te=He.g,ct=He.b;ye?(p[0]=Xe,p[1]=Te,p[2]=ct,p[3]=Ye,le.clearBufferuiv(le.COLOR,0,p)):(x[0]=Xe,x[1]=Te,x[2]=ct,x[3]=Ye,le.clearBufferiv(le.COLOR,0,x))}else it|=le.COLOR_BUFFER_BIT}_e&&(it|=le.DEPTH_BUFFER_BIT),tt&&(it|=le.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),le.clear(it)},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",nt,!1),n.removeEventListener("webglcontextrestored",De,!1),n.removeEventListener("webglcontextcreationerror",We,!1),ge.dispose(),ae.dispose(),re.dispose(),Fe.dispose(),Pe.dispose(),R.dispose(),xe.dispose(),we.dispose(),G.dispose(),ke.dispose(),ke.removeEventListener("sessionstart",Vt),ke.removeEventListener("sessionend",At),oe&&(oe.dispose(),oe=null),Be.stop()};function nt(Ie){Ie.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),A=!0}function De(){console.log("THREE.WebGLRenderer: Context Restored."),A=!1;const Ie=Y.autoReset,_e=ze.enabled,tt=ze.autoUpdate,it=ze.needsUpdate,Ke=ze.type;qe(),Y.autoReset=Ie,ze.enabled=_e,ze.autoUpdate=tt,ze.needsUpdate=it,ze.type=Ke}function We(Ie){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",Ie.statusMessage)}function Oe(Ie){const _e=Ie.target;_e.removeEventListener("dispose",Oe),je(_e)}function je(Ie){Ve(Ie),re.remove(Ie)}function Ve(Ie){const _e=re.get(Ie).programs;_e!==void 0&&(_e.forEach(function(tt){G.releaseProgram(tt)}),Ie.isShaderMaterial&&G.releaseShaderCache(Ie))}this.renderBufferDirect=function(Ie,_e,tt,it,Ke,Lt){_e===null&&(_e=ce);const ye=Ke.isMesh&&Ke.matrixWorld.determinant()<0,He=br(Ie,_e,tt,it,Ke);fe.setMaterial(it,ye);let Ye=tt.index,Xe=1;if(it.wireframe===!0){if(Ye=O.getWireframeAttribute(tt),Ye===void 0)return;Xe=2}const Te=tt.drawRange,ct=tt.attributes.position;let gt=Te.start*Xe,lt=(Te.start+Te.count)*Xe;Lt!==null&&(gt=Math.max(gt,Lt.start*Xe),lt=Math.min(lt,(Lt.start+Lt.count)*Xe)),Ye!==null?(gt=Math.max(gt,0),lt=Math.min(lt,Ye.count)):ct!=null&&(gt=Math.max(gt,0),lt=Math.min(lt,ct.count));const Tt=lt-gt;if(Tt<0||Tt===1/0)return;xe.setup(Ke,it,He,tt,Ye);let Bt,It=pe;if(Ye!==null&&(Bt=be.get(Ye),It=ve,It.setIndex(Bt)),Ke.isMesh)it.wireframe===!0?(fe.setLineWidth(it.wireframeLinewidth*Ce()),It.setMode(le.LINES)):It.setMode(le.TRIANGLES);else if(Ke.isLine){let Pt=it.linewidth;Pt===void 0&&(Pt=1),fe.setLineWidth(Pt*Ce()),Ke.isLineSegments?It.setMode(le.LINES):Ke.isLineLoop?It.setMode(le.LINE_LOOP):It.setMode(le.LINE_STRIP)}else Ke.isPoints?It.setMode(le.POINTS):Ke.isSprite&&It.setMode(le.TRIANGLES);if(Ke.isBatchedMesh)It.renderMultiDraw(Ke._multiDrawStarts,Ke._multiDrawCounts,Ke._multiDrawCount);else if(Ke.isInstancedMesh)It.renderInstances(gt,Tt,Ke.count);else if(tt.isInstancedBufferGeometry){const Pt=tt._maxInstanceCount!==void 0?tt._maxInstanceCount:1/0,tn=Math.min(tt.instanceCount,Pt);It.renderInstances(gt,Tt,tn)}else It.render(gt,Tt)};function ot(Ie,_e,tt){Ie.transparent===!0&&Ie.side===Rd&&Ie.forceSinglePass===!1?(Ie.side=ao,Ie.needsUpdate=!0,sr(Ie,_e,tt),Ie.side=Xh,Ie.needsUpdate=!0,sr(Ie,_e,tt),Ie.side=Rd):sr(Ie,_e,tt)}this.compile=function(Ie,_e,tt=null){tt===null&&(tt=Ie),g=ae.get(tt),g.init(),_.push(g),tt.traverseVisible(function(Ke){Ke.isLight&&Ke.layers.test(_e.layers)&&(g.pushLight(Ke),Ke.castShadow&&g.pushShadow(Ke))}),Ie!==tt&&Ie.traverseVisible(function(Ke){Ke.isLight&&Ke.layers.test(_e.layers)&&(g.pushLight(Ke),Ke.castShadow&&g.pushShadow(Ke))}),g.setupLights(N._useLegacyLights);const it=new Set;return Ie.traverse(function(Ke){const Lt=Ke.material;if(Lt)if(Array.isArray(Lt))for(let ye=0;ye<Lt.length;ye++){const He=Lt[ye];ot(He,tt,Ke),it.add(He)}else ot(Lt,tt,Ke),it.add(Lt)}),_.pop(),g=null,it},this.compileAsync=function(Ie,_e,tt=null){const it=this.compile(Ie,_e,tt);return new Promise(Ke=>{function Lt(){if(it.forEach(function(ye){re.get(ye).currentProgram.isReady()&&it.delete(ye)}),it.size===0){Ke(Ie);return}setTimeout(Lt,10)}V.get("KHR_parallel_shader_compile")!==null?Lt():setTimeout(Lt,10)})};let kt=null;function Ft(Ie){kt&&kt(Ie)}function Vt(){Be.stop()}function At(){Be.start()}const Be=new YY;Be.setAnimationLoop(Ft),typeof self<"u"&&Be.setContext(self),this.setAnimationLoop=function(Ie){kt=Ie,ke.setAnimationLoop(Ie),Ie===null?Be.stop():Be.start()},ke.addEventListener("sessionstart",Vt),ke.addEventListener("sessionend",At),this.render=function(Ie,_e){if(_e!==void 0&&_e.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(A===!0)return;Ie.matrixWorldAutoUpdate===!0&&Ie.updateMatrixWorld(),_e.parent===null&&_e.matrixWorldAutoUpdate===!0&&_e.updateMatrixWorld(),ke.enabled===!0&&ke.isPresenting===!0&&(ke.cameraAutoUpdate===!0&&ke.updateCamera(_e),_e=ke.getCamera()),Ie.isScene===!0&&Ie.onBeforeRender(N,Ie,_e,C),g=ae.get(Ie,_.length),g.init(),_.push(g),ie.multiplyMatrices(_e.projectionMatrix,_e.matrixWorldInverse),Z.setFromProjectionMatrix(ie),Se=this.localClippingEnabled,ee=Ue.init(this.clippingPlanes,Se),v=ge.get(Ie,y.length),v.init(),y.push(v),mt(Ie,_e,0,N.sortObjects),v.finish(),N.sortObjects===!0&&v.sort(W,Q),this.info.render.frame++,ee===!0&&Ue.beginShadows();const tt=g.state.shadowsArray;if(ze.render(tt,Ie,_e),ee===!0&&Ue.endShadows(),this.info.autoReset===!0&&this.info.reset(),$e.render(v,Ie),g.setupLights(N._useLegacyLights),_e.isArrayCamera){const it=_e.cameras;for(let Ke=0,Lt=it.length;Ke<Lt;Ke++){const ye=it[Ke];yt(v,Ie,ye,ye.viewport)}}else yt(v,Ie,_e);C!==null&&(ue.updateMultisampleRenderTarget(C),ue.updateRenderTargetMipmap(C)),Ie.isScene===!0&&Ie.onAfterRender(N,Ie,_e),xe.resetDefaultState(),j=-1,M=null,_.pop(),_.length>0?g=_[_.length-1]:g=null,y.pop(),y.length>0?v=y[y.length-1]:v=null};function mt(Ie,_e,tt,it){if(Ie.visible===!1)return;if(Ie.layers.test(_e.layers)){if(Ie.isGroup)tt=Ie.renderOrder;else if(Ie.isLOD)Ie.autoUpdate===!0&&Ie.update(_e);else if(Ie.isLight)g.pushLight(Ie),Ie.castShadow&&g.pushShadow(Ie);else if(Ie.isSprite){if(!Ie.frustumCulled||Z.intersectsSprite(Ie)){it&&se.setFromMatrixPosition(Ie.matrixWorld).applyMatrix4(ie);const ye=R.update(Ie),He=Ie.material;He.visible&&v.push(Ie,ye,He,tt,se.z,null)}}else if((Ie.isMesh||Ie.isLine||Ie.isPoints)&&(!Ie.frustumCulled||Z.intersectsObject(Ie))){const ye=R.update(Ie),He=Ie.material;if(it&&(Ie.boundingSphere!==void 0?(Ie.boundingSphere===null&&Ie.computeBoundingSphere(),se.copy(Ie.boundingSphere.center)):(ye.boundingSphere===null&&ye.computeBoundingSphere(),se.copy(ye.boundingSphere.center)),se.applyMatrix4(Ie.matrixWorld).applyMatrix4(ie)),Array.isArray(He)){const Ye=ye.groups;for(let Xe=0,Te=Ye.length;Xe<Te;Xe++){const ct=Ye[Xe],gt=He[ct.materialIndex];gt&>.visible&&v.push(Ie,ye,gt,tt,se.z,ct)}}else He.visible&&v.push(Ie,ye,He,tt,se.z,null)}}const Lt=Ie.children;for(let ye=0,He=Lt.length;ye<He;ye++)mt(Lt[ye],_e,tt,it)}function yt(Ie,_e,tt,it){const Ke=Ie.opaque,Lt=Ie.transmissive,ye=Ie.transparent;g.setupLightsView(tt),ee===!0&&Ue.setGlobalState(N.clippingPlanes,tt),Lt.length>0&&zt(Ke,Lt,_e,tt),it&&fe.viewport(E.copy(it)),Ke.length>0&&yn(Ke,_e,tt),Lt.length>0&&yn(Lt,_e,tt),ye.length>0&&yn(ye,_e,tt),fe.buffers.depth.setTest(!0),fe.buffers.depth.setMask(!0),fe.buffers.color.setMask(!0),fe.setPolygonOffset(!1)}function zt(Ie,_e,tt,it){if((tt.isScene===!0?tt.overrideMaterial:null)!==null)return;const Lt=K.isWebGL2;oe===null&&(oe=new Of(1,1,{generateMipmaps:!0,type:V.has("EXT_color_buffer_half_float")?N0:Ih,minFilter:_0,samples:Lt?4:0})),N.getDrawingBufferSize(me),Lt?oe.setSize(me.x,me.y):oe.setSize(F1(me.x),F1(me.y));const ye=N.getRenderTarget();N.setRenderTarget(oe),N.getClearColor(U),D=N.getClearAlpha(),D<1&&N.setClearColor(16777215,.5),N.clear();const He=N.toneMapping;N.toneMapping=Oh,yn(Ie,tt,it),ue.updateMultisampleRenderTarget(oe),ue.updateRenderTargetMipmap(oe);let Ye=!1;for(let Xe=0,Te=_e.length;Xe<Te;Xe++){const ct=_e[Xe],gt=ct.object,lt=ct.geometry,Tt=ct.material,Bt=ct.group;if(Tt.side===Rd&>.layers.test(it.layers)){const It=Tt.side;Tt.side=ao,Tt.needsUpdate=!0,gr(gt,tt,it,lt,Tt,Bt),Tt.side=It,Tt.needsUpdate=!0,Ye=!0}}Ye===!0&&(ue.updateMultisampleRenderTarget(oe),ue.updateRenderTargetMipmap(oe)),N.setRenderTarget(ye),N.setClearColor(U,D),N.toneMapping=He}function yn(Ie,_e,tt){const it=_e.isScene===!0?_e.overrideMaterial:null;for(let Ke=0,Lt=Ie.length;Ke<Lt;Ke++){const ye=Ie[Ke],He=ye.object,Ye=ye.geometry,Xe=it===null?ye.material:it,Te=ye.group;He.layers.test(tt.layers)&&gr(He,_e,tt,Ye,Xe,Te)}}function gr(Ie,_e,tt,it,Ke,Lt){Ie.onBeforeRender(N,_e,tt,it,Ke,Lt),Ie.modelViewMatrix.multiplyMatrices(tt.matrixWorldInverse,Ie.matrixWorld),Ie.normalMatrix.getNormalMatrix(Ie.modelViewMatrix),Ke.onBeforeRender(N,_e,tt,it,Ie,Lt),Ke.transparent===!0&&Ke.side===Rd&&Ke.forceSinglePass===!1?(Ke.side=ao,Ke.needsUpdate=!0,N.renderBufferDirect(tt,_e,it,Ke,Ie,Lt),Ke.side=Xh,Ke.needsUpdate=!0,N.renderBufferDirect(tt,_e,it,Ke,Ie,Lt),Ke.side=Rd):N.renderBufferDirect(tt,_e,it,Ke,Ie,Lt),Ie.onAfterRender(N,_e,tt,it,Ke,Lt)}function sr(Ie,_e,tt){_e.isScene!==!0&&(_e=ce);const it=re.get(Ie),Ke=g.state.lights,Lt=g.state.shadowsArray,ye=Ke.state.version,He=G.getParameters(Ie,Ke.state,Lt,_e,tt),Ye=G.getProgramCacheKey(He);let Xe=it.programs;it.environment=Ie.isMeshStandardMaterial?_e.environment:null,it.fog=_e.fog,it.envMap=(Ie.isMeshStandardMaterial?Pe:Fe).get(Ie.envMap||it.environment),Xe===void 0&&(Ie.addEventListener("dispose",Oe),Xe=new Map,it.programs=Xe);let Te=Xe.get(Ye);if(Te!==void 0){if(it.currentProgram===Te&&it.lightsStateVersion===ye)return Gn(Ie,He),Te}else He.uniforms=G.getUniforms(Ie),Ie.onBuild(tt,He,N),Ie.onBeforeCompile(He,N),Te=G.acquireProgram(He,Ye),Xe.set(Ye,Te),it.uniforms=He.uniforms;const ct=it.uniforms;return(!Ie.isShaderMaterial&&!Ie.isRawShaderMaterial||Ie.clipping===!0)&&(ct.clippingPlanes=Ue.uniform),Gn(Ie,He),it.needsLights=oi(Ie),it.lightsStateVersion=ye,it.needsLights&&(ct.ambientLightColor.value=Ke.state.ambient,ct.lightProbe.value=Ke.state.probe,ct.directionalLights.value=Ke.state.directional,ct.directionalLightShadows.value=Ke.state.directionalShadow,ct.spotLights.value=Ke.state.spot,ct.spotLightShadows.value=Ke.state.spotShadow,ct.rectAreaLights.value=Ke.state.rectArea,ct.ltc_1.value=Ke.state.rectAreaLTC1,ct.ltc_2.value=Ke.state.rectAreaLTC2,ct.pointLights.value=Ke.state.point,ct.pointLightShadows.value=Ke.state.pointShadow,ct.hemisphereLights.value=Ke.state.hemi,ct.directionalShadowMap.value=Ke.state.directionalShadowMap,ct.directionalShadowMatrix.value=Ke.state.directionalShadowMatrix,ct.spotShadowMap.value=Ke.state.spotShadowMap,ct.spotLightMatrix.value=Ke.state.spotLightMatrix,ct.spotLightMap.value=Ke.state.spotLightMap,ct.pointShadowMap.value=Ke.state.pointShadowMap,ct.pointShadowMatrix.value=Ke.state.pointShadowMatrix),it.currentProgram=Te,it.uniformsList=null,Te}function nr(Ie){if(Ie.uniformsList===null){const _e=Ie.currentProgram.getUniforms();Ie.uniformsList=Y_.seqWithValue(_e.seq,Ie.uniforms)}return Ie.uniformsList}function Gn(Ie,_e){const tt=re.get(Ie);tt.outputColorSpace=_e.outputColorSpace,tt.batching=_e.batching,tt.instancing=_e.instancing,tt.instancingColor=_e.instancingColor,tt.skinning=_e.skinning,tt.morphTargets=_e.morphTargets,tt.morphNormals=_e.morphNormals,tt.morphColors=_e.morphColors,tt.morphTargetsCount=_e.morphTargetsCount,tt.numClippingPlanes=_e.numClippingPlanes,tt.numIntersection=_e.numClipIntersection,tt.vertexAlphas=_e.vertexAlphas,tt.vertexTangents=_e.vertexTangents,tt.toneMapping=_e.toneMapping}function br(Ie,_e,tt,it,Ke){_e.isScene!==!0&&(_e=ce),ue.resetTextureUnits();const Lt=_e.fog,ye=it.isMeshStandardMaterial?_e.environment:null,He=C===null?N.outputColorSpace:C.isXRRenderTarget===!0?C.texture.colorSpace:su,Ye=(it.isMeshStandardMaterial?Pe:Fe).get(it.envMap||ye),Xe=it.vertexColors===!0&&!!tt.attributes.color&&tt.attributes.color.itemSize===4,Te=!!tt.attributes.tangent&&(!!it.normalMap||it.anisotropy>0),ct=!!tt.morphAttributes.position,gt=!!tt.morphAttributes.normal,lt=!!tt.morphAttributes.color;let Tt=Oh;it.toneMapped&&(C===null||C.isXRRenderTarget===!0)&&(Tt=N.toneMapping);const Bt=tt.morphAttributes.position||tt.morphAttributes.normal||tt.morphAttributes.color,It=Bt!==void 0?Bt.length:0,Pt=re.get(it),tn=g.state.lights;if(ee===!0&&(Se===!0||Ie!==M)){const pn=Ie===M&&it.id===j;Ue.setState(it,Ie,pn)}let en=!1;it.version===Pt.__version?(Pt.needsLights&&Pt.lightsStateVersion!==tn.state.version||Pt.outputColorSpace!==He||Ke.isBatchedMesh&&Pt.batching===!1||!Ke.isBatchedMesh&&Pt.batching===!0||Ke.isInstancedMesh&&Pt.instancing===!1||!Ke.isInstancedMesh&&Pt.instancing===!0||Ke.isSkinnedMesh&&Pt.skinning===!1||!Ke.isSkinnedMesh&&Pt.skinning===!0||Ke.isInstancedMesh&&Pt.instancingColor===!0&&Ke.instanceColor===null||Ke.isInstancedMesh&&Pt.instancingColor===!1&&Ke.instanceColor!==null||Pt.envMap!==Ye||it.fog===!0&&Pt.fog!==Lt||Pt.numClippingPlanes!==void 0&&(Pt.numClippingPlanes!==Ue.numPlanes||Pt.numIntersection!==Ue.numIntersection)||Pt.vertexAlphas!==Xe||Pt.vertexTangents!==Te||Pt.morphTargets!==ct||Pt.morphNormals!==gt||Pt.morphColors!==lt||Pt.toneMapping!==Tt||K.isWebGL2===!0&&Pt.morphTargetsCount!==It)&&(en=!0):(en=!0,Pt.__version=it.version);let on=Pt.currentProgram;en===!0&&(on=sr(it,_e,Ke));let gn=!1,Tn=!1,Zt=!1;const fn=on.getUniforms(),un=Pt.uniforms;if(fe.useProgram(on.program)&&(gn=!0,Tn=!0,Zt=!0),it.id!==j&&(j=it.id,Tn=!0),gn||M!==Ie){fn.setValue(le,"projectionMatrix",Ie.projectionMatrix),fn.setValue(le,"viewMatrix",Ie.matrixWorldInverse);const pn=fn.map.cameraPosition;pn!==void 0&&pn.setValue(le,se.setFromMatrixPosition(Ie.matrixWorld)),K.logarithmicDepthBuffer&&fn.setValue(le,"logDepthBufFC",2/(Math.log(Ie.far+1)/Math.LN2)),(it.isMeshPhongMaterial||it.isMeshToonMaterial||it.isMeshLambertMaterial||it.isMeshBasicMaterial||it.isMeshStandardMaterial||it.isShaderMaterial)&&fn.setValue(le,"isOrthographic",Ie.isOrthographicCamera===!0),M!==Ie&&(M=Ie,Tn=!0,Zt=!0)}if(Ke.isSkinnedMesh){fn.setOptional(le,Ke,"bindMatrix"),fn.setOptional(le,Ke,"bindMatrixInverse");const pn=Ke.skeleton;pn&&(K.floatVertexTextures?(pn.boneTexture===null&&pn.computeBoneTexture(),fn.setValue(le,"boneTexture",pn.boneTexture,ue)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}Ke.isBatchedMesh&&(fn.setOptional(le,Ke,"batchingTexture"),fn.setValue(le,"batchingTexture",Ke._matricesTexture,ue));const qr=tt.morphAttributes;if((qr.position!==void 0||qr.normal!==void 0||qr.color!==void 0&&K.isWebGL2===!0)&&Re.update(Ke,tt,on),(Tn||Pt.receiveShadow!==Ke.receiveShadow)&&(Pt.receiveShadow=Ke.receiveShadow,fn.setValue(le,"receiveShadow",Ke.receiveShadow)),it.isMeshGouraudMaterial&&it.envMap!==null&&(un.envMap.value=Ye,un.flipEnvMap.value=Ye.isCubeTexture&&Ye.isRenderTargetTexture===!1?-1:1),Tn&&(fn.setValue(le,"toneMappingExposure",N.toneMappingExposure),Pt.needsLights&&or(un,Zt),Lt&&it.fog===!0&&de.refreshFogUniforms(un,Lt),de.refreshMaterialUniforms(un,it,z,q,oe),Y_.upload(le,nr(Pt),un,ue)),it.isShaderMaterial&&it.uniformsNeedUpdate===!0&&(Y_.upload(le,nr(Pt),un,ue),it.uniformsNeedUpdate=!1),it.isSpriteMaterial&&fn.setValue(le,"center",Ke.center),fn.setValue(le,"modelViewMatrix",Ke.modelViewMatrix),fn.setValue(le,"normalMatrix",Ke.normalMatrix),fn.setValue(le,"modelMatrix",Ke.matrixWorld),it.isShaderMaterial||it.isRawShaderMaterial){const pn=it.uniformsGroups;for(let lr=0,as=pn.length;lr<as;lr++)if(K.isWebGL2){const bn=pn[lr];we.update(bn,on),we.bind(bn,on)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return on}function or(Ie,_e){Ie.ambientLightColor.needsUpdate=_e,Ie.lightProbe.needsUpdate=_e,Ie.directionalLights.needsUpdate=_e,Ie.directionalLightShadows.needsUpdate=_e,Ie.pointLights.needsUpdate=_e,Ie.pointLightShadows.needsUpdate=_e,Ie.spotLights.needsUpdate=_e,Ie.spotLightShadows.needsUpdate=_e,Ie.rectAreaLights.needsUpdate=_e,Ie.hemisphereLights.needsUpdate=_e}function oi(Ie){return Ie.isMeshLambertMaterial||Ie.isMeshToonMaterial||Ie.isMeshPhongMaterial||Ie.isMeshStandardMaterial||Ie.isShadowMaterial||Ie.isShaderMaterial&&Ie.lights===!0}this.getActiveCubeFace=function(){return k},this.getActiveMipmapLevel=function(){return P},this.getRenderTarget=function(){return C},this.setRenderTargetTextures=function(Ie,_e,tt){re.get(Ie.texture).__webglTexture=_e,re.get(Ie.depthTexture).__webglTexture=tt;const it=re.get(Ie);it.__hasExternalTextures=!0,it.__hasExternalTextures&&(it.__autoAllocateDepthBuffer=tt===void 0,it.__autoAllocateDepthBuffer||V.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),it.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(Ie,_e){const tt=re.get(Ie);tt.__webglFramebuffer=_e,tt.__useDefaultFramebuffer=_e===void 0},this.setRenderTarget=function(Ie,_e=0,tt=0){C=Ie,k=_e,P=tt;let it=!0,Ke=null,Lt=!1,ye=!1;if(Ie){const Ye=re.get(Ie);Ye.__useDefaultFramebuffer!==void 0?(fe.bindFramebuffer(le.FRAMEBUFFER,null),it=!1):Ye.__webglFramebuffer===void 0?ue.setupRenderTarget(Ie):Ye.__hasExternalTextures&&ue.rebindTextures(Ie,re.get(Ie.texture).__webglTexture,re.get(Ie.depthTexture).__webglTexture);const Xe=Ie.texture;(Xe.isData3DTexture||Xe.isDataArrayTexture||Xe.isCompressedArrayTexture)&&(ye=!0);const Te=re.get(Ie).__webglFramebuffer;Ie.isWebGLCubeRenderTarget?(Array.isArray(Te[_e])?Ke=Te[_e][tt]:Ke=Te[_e],Lt=!0):K.isWebGL2&&Ie.samples>0&&ue.useMultisampledRTT(Ie)===!1?Ke=re.get(Ie).__webglMultisampledFramebuffer:Array.isArray(Te)?Ke=Te[tt]:Ke=Te,E.copy(Ie.viewport),B.copy(Ie.scissor),L=Ie.scissorTest}else E.copy(te).multiplyScalar(z).floor(),B.copy(H).multiplyScalar(z).floor(),L=X;if(fe.bindFramebuffer(le.FRAMEBUFFER,Ke)&&K.drawBuffers&&it&&fe.drawBuffers(Ie,Ke),fe.viewport(E),fe.scissor(B),fe.setScissorTest(L),Lt){const Ye=re.get(Ie.texture);le.framebufferTexture2D(le.FRAMEBUFFER,le.COLOR_ATTACHMENT0,le.TEXTURE_CUBE_MAP_POSITIVE_X+_e,Ye.__webglTexture,tt)}else if(ye){const Ye=re.get(Ie.texture),Xe=_e||0;le.framebufferTextureLayer(le.FRAMEBUFFER,le.COLOR_ATTACHMENT0,Ye.__webglTexture,tt||0,Xe)}j=-1},this.readRenderTargetPixels=function(Ie,_e,tt,it,Ke,Lt,ye){if(!(Ie&&Ie.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let He=re.get(Ie).__webglFramebuffer;if(Ie.isWebGLCubeRenderTarget&&ye!==void 0&&(He=He[ye]),He){fe.bindFramebuffer(le.FRAMEBUFFER,He);try{const Ye=Ie.texture,Xe=Ye.format,Te=Ye.type;if(Xe!==dl&&Ne.convert(Xe)!==le.getParameter(le.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const ct=Te===N0&&(V.has("EXT_color_buffer_half_float")||K.isWebGL2&&V.has("EXT_color_buffer_float"));if(Te!==Ih&&Ne.convert(Te)!==le.getParameter(le.IMPLEMENTATION_COLOR_READ_TYPE)&&!(Te===Ud&&(K.isWebGL2||V.has("OES_texture_float")||V.has("WEBGL_color_buffer_float")))&&!ct){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}_e>=0&&_e<=Ie.width-it&&tt>=0&&tt<=Ie.height-Ke&&le.readPixels(_e,tt,it,Ke,Ne.convert(Xe),Ne.convert(Te),Lt)}finally{const Ye=C!==null?re.get(C).__webglFramebuffer:null;fe.bindFramebuffer(le.FRAMEBUFFER,Ye)}}},this.copyFramebufferToTexture=function(Ie,_e,tt=0){const it=Math.pow(2,-tt),Ke=Math.floor(_e.image.width*it),Lt=Math.floor(_e.image.height*it);ue.setTexture2D(_e,0),le.copyTexSubImage2D(le.TEXTURE_2D,tt,0,0,Ie.x,Ie.y,Ke,Lt),fe.unbindTexture()},this.copyTextureToTexture=function(Ie,_e,tt,it=0){const Ke=_e.image.width,Lt=_e.image.height,ye=Ne.convert(tt.format),He=Ne.convert(tt.type);ue.setTexture2D(tt,0),le.pixelStorei(le.UNPACK_FLIP_Y_WEBGL,tt.flipY),le.pixelStorei(le.UNPACK_PREMULTIPLY_ALPHA_WEBGL,tt.premultiplyAlpha),le.pixelStorei(le.UNPACK_ALIGNMENT,tt.unpackAlignment),_e.isDataTexture?le.texSubImage2D(le.TEXTURE_2D,it,Ie.x,Ie.y,Ke,Lt,ye,He,_e.image.data):_e.isCompressedTexture?le.compressedTexSubImage2D(le.TEXTURE_2D,it,Ie.x,Ie.y,_e.mipmaps[0].width,_e.mipmaps[0].height,ye,_e.mipmaps[0].data):le.texSubImage2D(le.TEXTURE_2D,it,Ie.x,Ie.y,ye,He,_e.image),it===0&&tt.generateMipmaps&&le.generateMipmap(le.TEXTURE_2D),fe.unbindTexture()},this.copyTextureToTexture3D=function(Ie,_e,tt,it,Ke=0){if(N.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const Lt=Ie.max.x-Ie.min.x+1,ye=Ie.max.y-Ie.min.y+1,He=Ie.max.z-Ie.min.z+1,Ye=Ne.convert(it.format),Xe=Ne.convert(it.type);let Te;if(it.isData3DTexture)ue.setTexture3D(it,0),Te=le.TEXTURE_3D;else if(it.isDataArrayTexture)ue.setTexture2DArray(it,0),Te=le.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}le.pixelStorei(le.UNPACK_FLIP_Y_WEBGL,it.flipY),le.pixelStorei(le.UNPACK_PREMULTIPLY_ALPHA_WEBGL,it.premultiplyAlpha),le.pixelStorei(le.UNPACK_ALIGNMENT,it.unpackAlignment);const ct=le.getParameter(le.UNPACK_ROW_LENGTH),gt=le.getParameter(le.UNPACK_IMAGE_HEIGHT),lt=le.getParameter(le.UNPACK_SKIP_PIXELS),Tt=le.getParameter(le.UNPACK_SKIP_ROWS),Bt=le.getParameter(le.UNPACK_SKIP_IMAGES),It=tt.isCompressedTexture?tt.mipmaps[0]:tt.image;le.pixelStorei(le.UNPACK_ROW_LENGTH,It.width),le.pixelStorei(le.UNPACK_IMAGE_HEIGHT,It.height),le.pixelStorei(le.UNPACK_SKIP_PIXELS,Ie.min.x),le.pixelStorei(le.UNPACK_SKIP_ROWS,Ie.min.y),le.pixelStorei(le.UNPACK_SKIP_IMAGES,Ie.min.z),tt.isDataTexture||tt.isData3DTexture?le.texSubImage3D(Te,Ke,_e.x,_e.y,_e.z,Lt,ye,He,Ye,Xe,It.data):tt.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),le.compressedTexSubImage3D(Te,Ke,_e.x,_e.y,_e.z,Lt,ye,He,Ye,It.data)):le.texSubImage3D(Te,Ke,_e.x,_e.y,_e.z,Lt,ye,He,Ye,Xe,It),le.pixelStorei(le.UNPACK_ROW_LENGTH,ct),le.pixelStorei(le.UNPACK_IMAGE_HEIGHT,gt),le.pixelStorei(le.UNPACK_SKIP_PIXELS,lt),le.pixelStorei(le.UNPACK_SKIP_ROWS,Tt),le.pixelStorei(le.UNPACK_SKIP_IMAGES,Bt),Ke===0&&it.generateMipmaps&&le.generateMipmap(Te),fe.unbindTexture()},this.initTexture=function(Ie){Ie.isCubeTexture?ue.setTextureCube(Ie,0):Ie.isData3DTexture?ue.setTexture3D(Ie,0):Ie.isDataArrayTexture||Ie.isCompressedArrayTexture?ue.setTexture2DArray(Ie,0):ue.setTexture2D(Ie,0),fe.unbindTexture()},this.resetState=function(){k=0,P=0,C=null,fe.reset(),xe.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=e===tL?"display-p3":"srgb",n.unpackColorSpace=Br.workingColorSpace===lk?"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?pf:RY}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===pf?Zi:su}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 KAe extends fD{}KAe.prototype.isWebGL1Renderer=!0;class oL{constructor(e,n=1,r=1e3){this.isFog=!0,this.name="",this.color=new hn(e),this.near=n,this.far=r}clone(){return new oL(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class XAe extends Fs{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 YAe{constructor(e,n){this.isInterleavedBuffer=!0,this.array=e,this.stride=n,this.count=e!==void 0?e.length/n:0,this.usage=dD,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=Wd()}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=Wd()),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=Wd()),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 ks=new Je;class _h{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++)ks.fromBufferAttribute(this,n),ks.applyMatrix4(e),this.setXYZ(n,ks.x,ks.y,ks.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)ks.fromBufferAttribute(this,n),ks.applyNormalMatrix(e),this.setXYZ(n,ks.x,ks.y,ks.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)ks.fromBufferAttribute(this,n),ks.transformDirection(e),this.setXYZ(n,ks.x,ks.y,ks.z);return this}setX(e,n){return this.normalized&&(n=Ur(n,this.array)),this.data.array[e*this.data.stride+this.offset]=n,this}setY(e,n){return this.normalized&&(n=Ur(n,this.array)),this.data.array[e*this.data.stride+this.offset+1]=n,this}setZ(e,n){return this.normalized&&(n=Ur(n,this.array)),this.data.array[e*this.data.stride+this.offset+2]=n,this}setW(e,n){return this.normalized&&(n=Ur(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=Ur(n,this.array),r=Ur(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=Ur(n,this.array),r=Ur(r,this.array),i=Ur(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=Ur(n,this.array),r=Ur(r,this.array),i=Ur(i,this.array),s=Ur(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 Do(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 _h(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 QAe extends io{constructor(e=null,n=1,r=1,i,s,o,l,c,d=Qi,u=Qi,h,f){super(null,o,l,c,d,u,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 ZAe(t,e){return t.z-e.z}function JAe(t,e){return e.z-t.z}class eTe{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 yg="batchId",eh=new ra,SH=new ra,tTe=new ra,_H=new ra,QP=new ck,XS=new bl,Om=new Dc,hy=new Je,ZP=new eTe,hs=new Wl,YS=[];function nTe(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 rTe extends Wl{get maxGeometryCount(){return this._maxGeometryCount}constructor(e,n,r=n*2,i){super(new ws,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 QAe(n,e,e,dl,Ud);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:d,itemSize:u,normalized:h}=c,f=new d.constructor(r*u),p=new c.constructor(f,u,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 Do(l,1))}const o=i>65536?new Uint32Array(r):new Uint16Array(r);n.setAttribute(yg,new Do(o,1)),this._geometryInitialized=!0}}_validateGeometry(e){if(e.getAttribute(yg))throw new Error(`BatchedMesh: Geometry cannot use attribute "${yg}"`);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===yg)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 bl);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,eh),this.getBoundingBoxAt(i,XS).applyMatrix4(eh),n.union(XS))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Dc);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,eh),this.getBoundingSphereAt(i,Om).applyMatrix4(eh),n.union(Om))}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 d=e.getIndex(),u=d!==null;if(u&&(r===-1?i.indexCount=d.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++,tTe.toArray(x,v*16),p.needsUpdate=!0,o.push(i),l.push({start:u?i.indexStart:i.vertexStart,count:-1}),c.push({boxInitialized:!1,box:new bl,sphereInitialized:!1,sphere:new Dc});const g=this.geometry.getAttribute(yg);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,d=l.vertexCount;for(const p in r.attributes){if(p===yg)continue;const x=n.getAttribute(p),v=r.getAttribute(p);nTe(x,v,c);const g=x.itemSize;for(let y=x.count,_=d;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 u=this._bounds[e];n.boundingBox!==null?(u.box.copy(n.boundingBox),u.boxInitialized=!0):u.boxInitialized=!1,n.boundingSphere!==null?(u.sphere.copy(n.boundingSphere),u.sphereInitialized=!0):u.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,d=this._drawRanges[e];for(let u=d.start,h=d.start+d.count;u<h;u++){let f=u;l&&(f=l.getX(f)),s.expandByPoint(hy.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,XS),XS.getCenter(s.center);const l=o.index,c=o.attributes.position,d=this._drawRanges[e];let u=0;for(let h=d.start,f=d.start+d.count;h<f;h++){let p=h;l&&(p=l.getX(p)),hy.fromBufferAttribute(c,p),u=Math.max(u,s.center.distanceToSquared(hy))}s.radius=Math.sqrt(u),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 bl),hs.geometry.boundingSphere===null&&(hs.geometry.boundingSphere=new Dc);for(let d=0;d<o;d++){if(!r[d]||!i[d])continue;const u=s[d];hs.geometry.setDrawRange(u.start,u.count),this.getMatrixAt(d,hs.matrixWorld).premultiply(l),this.getBoundingBoxAt(d,hs.geometry.boundingBox),this.getBoundingSphereAt(d,hs.geometry.boundingSphere),hs.raycast(e,YS);for(let h=0,f=YS.length;h<f;h++){const p=YS[h];p.object=this,p.batchId=d,n.push(p)}YS.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,d=this._multiDrawStarts,u=this._multiDrawCounts,h=this._drawRanges,f=this.perObjectFrustumCulled;f&&(_H.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse).multiply(this.matrixWorld),QP.setFromProjectionMatrix(_H,e.isWebGPURenderer?C0:Tc));let p=0;if(this.sortObjects){SH.copy(this.matrixWorld).invert(),hy.setFromMatrixPosition(r.matrixWorld).applyMatrix4(SH);for(let g=0,y=c.length;g<y;g++)if(c[g]){this.getMatrixAt(g,eh),this.getBoundingSphereAt(g,Om).applyMatrix4(eh);let _=!1;if(f&&(_=!QP.intersectsSphere(Om)),!_){const N=hy.distanceTo(Om.center);ZP.push(h[g],N)}}const x=ZP.list,v=this.customSort;v===null?x.sort(s.transparent?JAe:ZAe):v.call(this,x,r);for(let g=0,y=x.length;g<y;g++){const _=x[g];d[p]=_.start*l,u[p]=_.count,p++}ZP.reset()}else for(let x=0,v=c.length;x<v;x++)if(c[x]){let g=!1;if(f&&(this.getMatrixAt(x,eh),this.getBoundingSphereAt(x,Om).applyMatrix4(eh),g=!QP.intersectsSphere(Om)),!g){const y=h[x];d[p]=y.start*l,u[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 pv extends Xb{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new hn(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 NH=new Je,CH=new Je,kH=new ra,JP=new rL,QS=new Dc;let aTe=class extends Fs{constructor(e=new ws,n=new pv){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=n,this.updateMorphTargets()}copy(e,n){return super.copy(e,n),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const n=e.attributes.position,r=[0];for(let i=1,s=n.count;i<s;i++)NH.fromBufferAttribute(n,i-1),CH.fromBufferAttribute(n,i),r[i]=r[i-1],r[i]+=NH.distanceTo(CH);e.setAttribute("lineDistance",new qa(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(),QS.copy(r.boundingSphere),QS.applyMatrix4(i),QS.radius+=s,e.ray.intersectsSphere(QS)===!1)return;kH.copy(i).invert(),JP.copy(e.ray).applyMatrix4(kH);const l=s/((this.scale.x+this.scale.y+this.scale.z)/3),c=l*l,d=new Je,u=new Je,h=new Je,f=new Je,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 k=x.getX(N),P=x.getX(N+1);if(d.fromBufferAttribute(g,k),u.fromBufferAttribute(g,P),JP.distanceSqToSegment(d,u,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})}}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(d.fromBufferAttribute(g,N),u.fromBufferAttribute(g,N+1),JP.distanceSqToSegment(d,u,f,h)>c)continue;f.applyMatrix4(this.matrixWorld);const P=e.ray.origin.distanceTo(f);P<e.near||P>e.far||n.push({distance:P,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 AH=new Je,TH=new Je;class uk extends aTe{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)AH.fromBufferAttribute(n,i),TH.fromBufferAttribute(n,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+AH.distanceTo(TH);e.setAttribute("lineDistance",new qa(r,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class iTe extends ws{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const n=[],r=new Set,i=new Je,s=new Je;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 d=0,u=c.length;d<u;++d){const h=c[d],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,_),MH(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 d=0;d<3;d++){const u=3*l+d,h=3*l+(d+1)%3;i.fromBufferAttribute(o,u),s.fromBufferAttribute(o,h),MH(i,s,r)===!0&&(n.push(i.x,i.y,i.z),n.push(s.x,s.y,s.z))}}this.setAttribute("position",new qa(n,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function MH(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 sTe extends Xb{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new hn(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new hn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=FY,this.normalScale=new Nn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=JF,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 oTe extends pv{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}class rQ extends Fs{constructor(e,n=1){super(),this.isLight=!0,this.type="Light",this.color=new hn(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 e2=new ra,PH=new Je,EH=new Je;class lTe{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Nn(512,512),this.map=null,this.mapPass=null,this.matrix=new ra,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new ck,this._frameExtents=new Nn(1,1),this._viewportCount=1,this._viewports=[new $r(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const n=this.camera,r=this.matrix;PH.setFromMatrixPosition(e.matrixWorld),n.position.copy(PH),EH.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(EH),n.updateMatrixWorld(),e2.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(e2),r.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),r.multiply(e2)}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 jH=new ra,my=new Je,t2=new Je;class cTe extends lTe{constructor(){super(new Ao(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new Nn(4,2),this._viewportCount=6,this._viewports=[new $r(2,1,1,1),new $r(0,1,1,1),new $r(3,1,1,1),new $r(1,1,1,1),new $r(3,0,1,1),new $r(1,0,1,1)],this._cubeDirections=[new Je(1,0,0),new Je(-1,0,0),new Je(0,0,1),new Je(0,0,-1),new Je(0,1,0),new Je(0,-1,0)],this._cubeUps=[new Je(0,1,0),new Je(0,1,0),new Je(0,1,0),new Je(0,1,0),new Je(0,0,1),new Je(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()),my.setFromMatrixPosition(e.matrixWorld),r.position.copy(my),t2.copy(r.position),t2.add(this._cubeDirections[n]),r.up.copy(this._cubeUps[n]),r.lookAt(t2),r.updateMatrixWorld(),i.makeTranslation(-my.x,-my.y,-my.z),jH.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),this._frustum.setFromProjectionMatrix(jH)}}class dTe extends rQ{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 cTe}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 uTe extends rQ{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}}class hTe extends ws{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 pD extends YAe{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 DH{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 RH=new Je,ZS=new Je;class mTe{constructor(e=new Je,n=new Je){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){RH.subVectors(e,this.start),ZS.subVectors(this.end,this.start);const r=ZS.dot(ZS);let s=ZS.dot(RH)/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 fTe extends uk{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 ws;i.setAttribute("position",new qa(n,3)),i.setAttribute("color",new qa(r,3));const s=new pv({vertexColors:!0,toneMapped:!1});super(i,s),this.type="AxesHelper"}setColors(e,n,r){const i=new hn,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:sk}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=sk);class Rc{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"),Rc.nextNameID=Rc.nextNameID||0,this.$name.id=`lil-gui-name-${++Rc.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 Rc{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 gD(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 gTe={isPrimitive:!0,match:t=>typeof t=="string",fromHexString:gD,toHexString:gD},A0={isPrimitive:!0,match:t=>typeof t=="number",fromHexString:t=>parseInt(t.substring(1),16),toHexString:t=>"#"+t.toString(16).padStart(6,0)},bTe={isPrimitive:!1,match:t=>Array.isArray(t),fromHexString(t,e,n=1){const r=A0.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 A0.toHexString(i)}},xTe={isPrimitive:!1,match:t=>Object(t)===t,fromHexString(t,e,n=1){const r=A0.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 A0.toHexString(i)}},yTe=[gTe,A0,bTe,xTe];function vTe(t){return yTe.find(e=>e.match(t))}class wTe extends Rc{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=vTe(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=gD(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 n2 extends Rc{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 STe extends Rc{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,d,u,h;const f=5,p=_=>{l=_.clientX,c=d=_.clientY,o=!0,u=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-d;h-=N*this._step*this._arrowKeyMultiplier(_),u+h>this._max?h=this._max-u:u+h<this._min&&(h=this._min-u),this._snapClampSetValue(u+h)}d=_.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,k)=>(y-_)/(N-_)*(k-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 d=y=>{y.preventDefault(),this._setDraggingStyle(!0),n(y.touches[0].clientX),o=!1},u=y=>{y.touches.length>1||(this._hasScrollBar?(l=y.touches[0].clientX,c=y.touches[0].clientY,o=!0):d(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)?d(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",u,{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 _Te extends Rc{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 NTe extends Rc{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 CTe=`.lil-gui {
- font-family: var(--font-family);
- font-size: var(--font-size);
- line-height: 1;
- font-weight: normal;
- font-style: normal;
- text-align: left;
- color: var(--text-color);
- user-select: none;
- -webkit-user-select: none;
- touch-action: manipulation;
- --background-color: #1f1f1f;
- --text-color: #ebebeb;
- --title-background-color: #111111;
- --title-text-color: #ebebeb;
- --widget-color: #424242;
- --hover-color: #4f4f4f;
- --focus-color: #595959;
- --number-color: #2cc9ff;
- --string-color: #a2db3c;
- --font-size: 11px;
- --input-font-size: 11px;
- --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
- --font-family-mono: Menlo, Monaco, Consolas, "Droid Sans Mono", monospace;
- --padding: 4px;
- --spacing: 4px;
- --widget-height: 20px;
- --title-height: calc(var(--widget-height) + var(--spacing) * 1.25);
- --name-width: 45%;
- --slider-knob-width: 2px;
- --slider-input-width: 27%;
- --color-input-width: 27%;
- --slider-input-min-width: 45px;
- --color-input-min-width: 45px;
- --folder-indent: 7px;
- --widget-padding: 0 0 0 3px;
- --widget-border-radius: 2px;
- --checkbox-size: calc(0.75 * var(--widget-height));
- --scrollbar-width: 5px;
- }
- .lil-gui, .lil-gui * {
- box-sizing: border-box;
- margin: 0;
- padding: 0;
- }
- .lil-gui.root {
- width: var(--width, 245px);
- display: flex;
- flex-direction: column;
- background: var(--background-color);
- }
- .lil-gui.root > .title {
- background: var(--title-background-color);
- color: var(--title-text-color);
- }
- .lil-gui.root > .children {
- overflow-x: hidden;
- overflow-y: auto;
- }
- .lil-gui.root > .children::-webkit-scrollbar {
- width: var(--scrollbar-width);
- height: var(--scrollbar-width);
- background: var(--background-color);
- }
- .lil-gui.root > .children::-webkit-scrollbar-thumb {
- border-radius: var(--scrollbar-width);
- background: var(--focus-color);
- }
- @media (pointer: coarse) {
- .lil-gui.allow-touch-styles, .lil-gui.allow-touch-styles .lil-gui {
- --widget-height: 28px;
- --padding: 6px;
- --spacing: 6px;
- --font-size: 13px;
- --input-font-size: 16px;
- --folder-indent: 10px;
- --scrollbar-width: 7px;
- --slider-input-min-width: 50px;
- --color-input-min-width: 65px;
- }
- }
- .lil-gui.force-touch-styles, .lil-gui.force-touch-styles .lil-gui {
- --widget-height: 28px;
- --padding: 6px;
- --spacing: 6px;
- --font-size: 13px;
- --input-font-size: 16px;
- --folder-indent: 10px;
- --scrollbar-width: 7px;
- --slider-input-min-width: 50px;
- --color-input-min-width: 65px;
- }
- .lil-gui.autoPlace {
- max-height: 100%;
- position: fixed;
- top: 0;
- right: 15px;
- z-index: 1001;
- }
- .lil-gui .controller {
- display: flex;
- align-items: center;
- padding: 0 var(--padding);
- margin: var(--spacing) 0;
- }
- .lil-gui .controller.disabled {
- opacity: 0.5;
- }
- .lil-gui .controller.disabled, .lil-gui .controller.disabled * {
- pointer-events: none !important;
- }
- .lil-gui .controller > .name {
- min-width: var(--name-width);
- flex-shrink: 0;
- white-space: pre;
- padding-right: var(--spacing);
- line-height: var(--widget-height);
- }
- .lil-gui .controller .widget {
- position: relative;
- display: flex;
- align-items: center;
- width: 100%;
- min-height: var(--widget-height);
- }
- .lil-gui .controller.string input {
- color: var(--string-color);
- }
- .lil-gui .controller.boolean {
- cursor: pointer;
- }
- .lil-gui .controller.color .display {
- width: 100%;
- height: var(--widget-height);
- border-radius: var(--widget-border-radius);
- position: relative;
- }
- @media (hover: hover) {
- .lil-gui .controller.color .display:hover:before {
- content: " ";
- display: block;
- position: absolute;
- border-radius: var(--widget-border-radius);
- border: 1px solid #fff9;
- top: 0;
- right: 0;
- bottom: 0;
- left: 0;
- }
- }
- .lil-gui .controller.color input[type=color] {
- opacity: 0;
- width: 100%;
- height: 100%;
- cursor: pointer;
- }
- .lil-gui .controller.color input[type=text] {
- margin-left: var(--spacing);
- font-family: var(--font-family-mono);
- min-width: var(--color-input-min-width);
- width: var(--color-input-width);
- flex-shrink: 0;
- }
- .lil-gui .controller.option select {
- opacity: 0;
- position: absolute;
- width: 100%;
- max-width: 100%;
- }
- .lil-gui .controller.option .display {
- position: relative;
- pointer-events: none;
- border-radius: var(--widget-border-radius);
- height: var(--widget-height);
- line-height: var(--widget-height);
- max-width: 100%;
- overflow: hidden;
- word-break: break-all;
- padding-left: 0.55em;
- padding-right: 1.75em;
- background: var(--widget-color);
- }
- @media (hover: hover) {
- .lil-gui .controller.option .display.focus {
- background: var(--focus-color);
- }
- }
- .lil-gui .controller.option .display.active {
- background: var(--focus-color);
- }
- .lil-gui .controller.option .display:after {
- font-family: "lil-gui";
- content: "↕";
- position: absolute;
- top: 0;
- right: 0;
- bottom: 0;
- padding-right: 0.375em;
- }
- .lil-gui .controller.option .widget,
- .lil-gui .controller.option select {
- cursor: pointer;
- }
- @media (hover: hover) {
- .lil-gui .controller.option .widget:hover .display {
- background: var(--hover-color);
- }
- }
- .lil-gui .controller.number input {
- color: var(--number-color);
- }
- .lil-gui .controller.number.hasSlider input {
- margin-left: var(--spacing);
- width: var(--slider-input-width);
- min-width: var(--slider-input-min-width);
- flex-shrink: 0;
- }
- .lil-gui .controller.number .slider {
- width: 100%;
- height: var(--widget-height);
- background: var(--widget-color);
- border-radius: var(--widget-border-radius);
- padding-right: var(--slider-knob-width);
- overflow: hidden;
- cursor: ew-resize;
- touch-action: pan-y;
- }
- @media (hover: hover) {
- .lil-gui .controller.number .slider:hover {
- background: var(--hover-color);
- }
- }
- .lil-gui .controller.number .slider.active {
- background: var(--focus-color);
- }
- .lil-gui .controller.number .slider.active .fill {
- opacity: 0.95;
- }
- .lil-gui .controller.number .fill {
- height: 100%;
- border-right: var(--slider-knob-width) solid var(--number-color);
- box-sizing: content-box;
- }
- .lil-gui-dragging .lil-gui {
- --hover-color: var(--widget-color);
- }
- .lil-gui-dragging * {
- cursor: ew-resize !important;
- }
- .lil-gui-dragging.lil-gui-vertical * {
- cursor: ns-resize !important;
- }
- .lil-gui .title {
- height: var(--title-height);
- line-height: calc(var(--title-height) - 4px);
- font-weight: 600;
- padding: 0 var(--padding);
- -webkit-tap-highlight-color: transparent;
- cursor: pointer;
- outline: none;
- text-decoration-skip: objects;
- }
- .lil-gui .title:before {
- font-family: "lil-gui";
- content: "▾";
- padding-right: 2px;
- display: inline-block;
- }
- .lil-gui .title:active {
- background: var(--title-background-color);
- opacity: 0.75;
- }
- @media (hover: hover) {
- body:not(.lil-gui-dragging) .lil-gui .title:hover {
- background: var(--title-background-color);
- opacity: 0.85;
- }
- .lil-gui .title:focus {
- text-decoration: underline var(--focus-color);
- }
- }
- .lil-gui.root > .title:focus {
- text-decoration: none !important;
- }
- .lil-gui.closed > .title:before {
- content: "▸";
- }
- .lil-gui.closed > .children {
- transform: translateY(-7px);
- opacity: 0;
- }
- .lil-gui.closed:not(.transition) > .children {
- display: none;
- }
- .lil-gui.transition > .children {
- transition-duration: 300ms;
- transition-property: height, opacity, transform;
- transition-timing-function: cubic-bezier(0.2, 0.6, 0.35, 1);
- overflow: hidden;
- pointer-events: none;
- }
- .lil-gui .children:empty:before {
- content: "Empty";
- padding: 0 var(--padding);
- margin: var(--spacing) 0;
- display: block;
- height: var(--widget-height);
- font-style: italic;
- line-height: var(--widget-height);
- opacity: 0.5;
- }
- .lil-gui.root > .children > .lil-gui > .title {
- border: 0 solid var(--widget-color);
- border-width: 1px 0;
- transition: border-color 300ms;
- }
- .lil-gui.root > .children > .lil-gui.closed > .title {
- border-bottom-color: transparent;
- }
- .lil-gui + .controller {
- border-top: 1px solid var(--widget-color);
- margin-top: 0;
- padding-top: var(--spacing);
- }
- .lil-gui .lil-gui .lil-gui > .title {
- border: none;
- }
- .lil-gui .lil-gui .lil-gui > .children {
- border: none;
- margin-left: var(--folder-indent);
- border-left: 2px solid var(--widget-color);
- }
- .lil-gui .lil-gui .controller {
- border: none;
- }
- .lil-gui label, .lil-gui input, .lil-gui button {
- -webkit-tap-highlight-color: transparent;
- }
- .lil-gui input {
- border: 0;
- outline: none;
- font-family: var(--font-family);
- font-size: var(--input-font-size);
- border-radius: var(--widget-border-radius);
- height: var(--widget-height);
- background: var(--widget-color);
- color: var(--text-color);
- width: 100%;
- }
- @media (hover: hover) {
- .lil-gui input:hover {
- background: var(--hover-color);
- }
- .lil-gui input:active {
- background: var(--focus-color);
- }
- }
- .lil-gui input:disabled {
- opacity: 1;
- }
- .lil-gui input[type=text],
- .lil-gui input[type=number] {
- padding: var(--widget-padding);
- -moz-appearance: textfield;
- }
- .lil-gui input[type=text]:focus,
- .lil-gui input[type=number]:focus {
- background: var(--focus-color);
- }
- .lil-gui input[type=checkbox] {
- appearance: none;
- width: var(--checkbox-size);
- height: var(--checkbox-size);
- border-radius: var(--widget-border-radius);
- text-align: center;
- cursor: pointer;
- }
- .lil-gui input[type=checkbox]:checked:before {
- font-family: "lil-gui";
- content: "✓";
- font-size: var(--checkbox-size);
- line-height: var(--checkbox-size);
- }
- @media (hover: hover) {
- .lil-gui input[type=checkbox]:focus {
- box-shadow: inset 0 0 0 1px var(--focus-color);
- }
- }
- .lil-gui button {
- outline: none;
- cursor: pointer;
- font-family: var(--font-family);
- font-size: var(--font-size);
- color: var(--text-color);
- width: 100%;
- height: var(--widget-height);
- text-transform: none;
- background: var(--widget-color);
- border-radius: var(--widget-border-radius);
- border: none;
- }
- @media (hover: hover) {
- .lil-gui button:hover {
- background: var(--hover-color);
- }
- .lil-gui button:focus {
- box-shadow: inset 0 0 0 1px var(--focus-color);
- }
- }
- .lil-gui button:active {
- background: var(--focus-color);
- }
- @font-face {
- font-family: "lil-gui";
- src: url("data:application/font-woff;charset=utf-8;base64,d09GRgABAAAAAAUsAAsAAAAACJwAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABHU1VCAAABCAAAAH4AAADAImwmYE9TLzIAAAGIAAAAPwAAAGBKqH5SY21hcAAAAcgAAAD0AAACrukyyJBnbHlmAAACvAAAAF8AAACEIZpWH2hlYWQAAAMcAAAAJwAAADZfcj2zaGhlYQAAA0QAAAAYAAAAJAC5AHhobXR4AAADXAAAABAAAABMAZAAAGxvY2EAAANsAAAAFAAAACgCEgIybWF4cAAAA4AAAAAeAAAAIAEfABJuYW1lAAADoAAAASIAAAIK9SUU/XBvc3QAAATEAAAAZgAAAJCTcMc2eJxVjbEOgjAURU+hFRBK1dGRL+ALnAiToyMLEzFpnPz/eAshwSa97517c/MwwJmeB9kwPl+0cf5+uGPZXsqPu4nvZabcSZldZ6kfyWnomFY/eScKqZNWupKJO6kXN3K9uCVoL7iInPr1X5baXs3tjuMqCtzEuagm/AAlzQgPAAB4nGNgYRBlnMDAysDAYM/gBiT5oLQBAwuDJAMDEwMrMwNWEJDmmsJwgCFeXZghBcjlZMgFCzOiKOIFAB71Bb8AeJy1kjFuwkAQRZ+DwRAwBtNQRUGKQ8OdKCAWUhAgKLhIuAsVSpWz5Bbkj3dEgYiUIszqWdpZe+Z7/wB1oCYmIoboiwiLT2WjKl/jscrHfGg/pKdMkyklC5Zs2LEfHYpjcRoPzme9MWWmk3dWbK9ObkWkikOetJ554fWyoEsmdSlt+uR0pCJR34b6t/TVg1SY3sYvdf8vuiKrpyaDXDISiegp17p7579Gp3p++y7HPAiY9pmTibljrr85qSidtlg4+l25GLCaS8e6rRxNBmsnERunKbaOObRz7N72ju5vdAjYpBXHgJylOAVsMseDAPEP8LYoUHicY2BiAAEfhiAGJgZWBgZ7RnFRdnVJELCQlBSRlATJMoLV2DK4glSYs6ubq5vbKrJLSbGrgEmovDuDJVhe3VzcXFwNLCOILB/C4IuQ1xTn5FPilBTj5FPmBAB4WwoqAHicY2BkYGAA4sk1sR/j+W2+MnAzpDBgAyEMQUCSg4EJxAEAwUgFHgB4nGNgZGBgSGFggJMhDIwMqEAYAByHATJ4nGNgAIIUNEwmAABl3AGReJxjYAACIQYlBiMGJ3wQAEcQBEV4nGNgZGBgEGZgY2BiAAEQyQWEDAz/wXwGAAsPATIAAHicXdBNSsNAHAXwl35iA0UQXYnMShfS9GPZA7T7LgIu03SSpkwzYTIt1BN4Ak/gKTyAeCxfw39jZkjymzcvAwmAW/wgwHUEGDb36+jQQ3GXGot79L24jxCP4gHzF/EIr4jEIe7wxhOC3g2TMYy4Q7+Lu/SHuEd/ivt4wJd4wPxbPEKMX3GI5+DJFGaSn4qNzk8mcbKSR6xdXdhSzaOZJGtdapd4vVPbi6rP+cL7TGXOHtXKll4bY1Xl7EGnPtp7Xy2n00zyKLVHfkHBa4IcJ2oD3cgggWvt/V/FbDrUlEUJhTn/0azVWbNTNr0Ens8de1tceK9xZmfB1CPjOmPH4kitmvOubcNpmVTN3oFJyjzCvnmrwhJTzqzVj9jiSX911FjeAAB4nG3HMRKCMBBA0f0giiKi4DU8k0V2GWbIZDOh4PoWWvq6J5V8If9NVNQcaDhyouXMhY4rPTcG7jwYmXhKq8Wz+p762aNaeYXom2n3m2dLTVgsrCgFJ7OTmIkYbwIbC6vIB7WmFfAAAA==") format("woff");
- }`;function kTe(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 FH=!1;class O1{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",d=>{(d.code==="Enter"||d.code==="Space")&&(d.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"),!FH&&l&&(kTe(CTe),FH=!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 _Te(this,e,n,r);const o=e[n];switch(typeof o){case"number":return new STe(this,e,n,r,i,s);case"boolean":return new pTe(this,e,n);case"string":return new NTe(this,e,n);case"function":return new n2(this,e,n)}console.error(`gui.add failed
- property:`,n,`
- object:`,e,`
- value:`,o)}addColor(e,n,r=1){return new wTe(this,e,n,r)}addFolder(e){const n=new O1({parent:this,title:e});return this.root._closeFolders&&n.close(),n}load(e,n=!0){return e.controllers&&this.controllers.forEach(r=>{r instanceof n2||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 n2)){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 r2(t,e,n,r){return new(n||(n=Promise))((function(i,s){function o(d){try{c(r.next(d))}catch(u){s(u)}}function l(d){try{c(r.throw(d))}catch(u){s(u)}}function c(d){var u;d.done?i(d.value):(u=d.value,u instanceof n?u:new n((function(h){h(u)}))).then(o,l)}c((r=r.apply(t,[])).next())}))}class lL{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 lL(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 cL{constructor(e,n,r,i){this.src=e,this.gcode=n,this.params=r,this.comment=i}}class LH extends cL{constructor(e,n,r,i){super(e,n,r,i),this.params=r}}class th extends cL{constructor(e,n,r,i){super(e,n,void 0,r),this.toolIndex=i}}class OH{constructor(e,n,r,i=0){this.layer=e,this.commands=n,this.lineNumber=r,this.height=i}}class I1{constructor(e){this.lines=[],this.preamble=new OH(-1,[],0),this.layers=[],this.curZ=0,this.maxZ=0,this.metadata={thumbnails:{}},this.tolerance=0,this.tolerance=e??this.tolerance}parseGCode(e){const n=Array.isArray(e)?e:e.split(`
- `);this.lines=this.lines.concat(n);const r=this.lines2commands(n);this.groupIntoLayers(r);const i=this.parseMetadata(r.filter((s=>s.comment))).thumbnails;for(const[s,o]of Object.entries(i))this.metadata.thumbnails[s]=o;return{layers:this.layers,metadata:this.metadata}}lines2commands(e){return e.map((n=>this.parseCommand(n)))}parseCommand(e,n=!0){var r;const i=e.trim().split(";"),s=i[0],o=n&&i[1]||void 0,l=s.split(/([a-zA-Z])/g).slice(1).map((u=>u.trim())),c=l.length?`${(r=l[0])===null||r===void 0?void 0:r.toLowerCase()}${l[1]}`:"",d=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 LH(e,c,d,o);case"t0":return new th(e,c,o,0);case"t1":return new th(e,c,o,1);case"t2":return new th(e,c,o,2);case"t3":return new th(e,c,o,3);case"t4":return new th(e,c,o,4);case"t5":return new th(e,c,o,5);case"t6":return new th(e,c,o,6);case"t7":return new th(e,c,o,7);default:return new cL(e,c,d,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 LH){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 OH(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=lL.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}}}I1.prototype.parseGcode=I1.prototype.parseGCode;const IH={type:"change"},a2={type:"start"},zH={type:"end"},JS=new rL,UH=new oh,ATe=Math.cos(70*OY.DEG2RAD);class TTe extends np{constructor(e,n){super(),this.object=e,this.domElement=n,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new Je,this.cursor=new Je,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:tg.ROTATE,MIDDLE:tg.DOLLY,RIGHT:tg.PAN},this.touches={ONE:ng.ROTATE,TWO:ng.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this.getPolarAngle=function(){return l.phi},this.getAzimuthalAngle=function(){return l.theta},this.getDistance=function(){return this.object.position.distanceTo(this.target)},this.listenToKeyEvents=function(K){K.addEventListener("keydown",Ce),this._domElementKeyEvents=K},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",Ce),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(IH),r.update(),s=i.NONE},this.update=(function(){const K=new Je,fe=new If().setFromUnitVectors(e.up,new Je(0,1,0)),Y=fe.clone().invert(),re=new Je,ue=new If,Fe=new Je,Pe=2*Math.PI;return function(be=null){const O=r.object.position;K.copy(O).sub(r.target),K.applyQuaternion(fe),l.setFromVector3(K),r.autoRotate&&s===i.NONE&&E((function(ge){return ge!==null?2*Math.PI/60*r.autoRotateSpeed*ge:2*Math.PI/60/60*r.autoRotateSpeed})(be)),r.enableDamping?(l.theta+=c.theta*r.dampingFactor,l.phi+=c.phi*r.dampingFactor):(l.theta+=c.theta,l.phi+=c.phi);let R=r.minAzimuthAngle,G=r.maxAzimuthAngle;isFinite(R)&&isFinite(G)&&(R<-Math.PI?R+=Pe:R>Math.PI&&(R-=Pe),G<-Math.PI?G+=Pe:G>Math.PI&&(G-=Pe),l.theta=R<=G?Math.max(R,Math.min(G,l.theta)):l.theta>(R+G)/2?Math.max(R,l.theta):Math.min(G,l.theta)),l.phi=Math.max(r.minPolarAngle,Math.min(r.maxPolarAngle,l.phi)),l.makeSafe(),r.enableDamping===!0?r.target.addScaledVector(u,r.dampingFactor):r.target.add(u),r.target.sub(r.cursor),r.target.clampLength(r.minTargetRadius,r.maxTargetRadius),r.target.add(r.cursor),r.zoomToCursor&&P||r.object.isOrthographicCamera?l.radius=W(l.radius):l.radius=W(l.radius*d),K.setFromSpherical(l),K.applyQuaternion(Y),O.copy(r.target).add(K),r.object.lookAt(r.target),r.enableDamping===!0?(c.theta*=1-r.dampingFactor,c.phi*=1-r.dampingFactor,u.multiplyScalar(1-r.dampingFactor)):(c.set(0,0,0),u.set(0,0,0));let de=!1;if(r.zoomToCursor&&P){let ge=null;if(r.object.isPerspectiveCamera){const ae=K.length();ge=W(ae*d);const Ue=ae-ge;r.object.position.addScaledVector(A,Ue),r.object.updateMatrixWorld()}else if(r.object.isOrthographicCamera){const ae=new Je(k.x,k.y,0);ae.unproject(r.object),r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom/d)),r.object.updateProjectionMatrix(),de=!0;const Ue=new Je(k.x,k.y,0);Ue.unproject(r.object),r.object.position.sub(Ue).add(ae),r.object.updateMatrixWorld(),ge=K.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),r.zoomToCursor=!1;ge!==null&&(this.screenSpacePanning?r.target.set(0,0,-1).transformDirection(r.object.matrix).multiplyScalar(ge).add(r.object.position):(JS.origin.copy(r.object.position),JS.direction.set(0,0,-1).transformDirection(r.object.matrix),Math.abs(r.object.up.dot(JS.direction))<ATe?e.lookAt(r.target):(UH.setFromNormalAndCoplanarPoint(r.object.up,r.target),JS.intersectPlane(UH,r.target))))}else r.object.isOrthographicCamera&&(r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom/d)),r.object.updateProjectionMatrix(),de=!0);return d=1,P=!1,!!(de||re.distanceToSquared(r.object.position)>o||8*(1-ue.dot(r.object.quaternion))>o||Fe.distanceToSquared(r.target)>0)&&(r.dispatchEvent(IH),re.copy(r.object.position),ue.copy(r.object.quaternion),Fe.copy(r.target),!0)}})(),this.dispose=function(){r.domElement.removeEventListener("contextmenu",le),r.domElement.removeEventListener("pointerdown",ie),r.domElement.removeEventListener("pointercancel",se),r.domElement.removeEventListener("wheel",ce),r.domElement.removeEventListener("pointermove",me),r.domElement.removeEventListener("pointerup",se),r._domElementKeyEvents!==null&&(r._domElementKeyEvents.removeEventListener("keydown",Ce),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 DH,c=new DH;let d=1;const u=new Je,h=new Nn,f=new Nn,p=new Nn,x=new Nn,v=new Nn,g=new Nn,y=new Nn,_=new Nn,N=new Nn,A=new Je,k=new Nn;let P=!1;const C=[],j={};function M(){return Math.pow(.95,r.zoomSpeed)}function E(K){c.theta-=K}function B(K){c.phi-=K}const L=(function(){const K=new Je;return function(fe,Y){K.setFromMatrixColumn(Y,0),K.multiplyScalar(-fe),u.add(K)}})(),U=(function(){const K=new Je;return function(fe,Y){r.screenSpacePanning===!0?K.setFromMatrixColumn(Y,1):(K.setFromMatrixColumn(Y,0),K.crossVectors(r.object.up,K)),K.multiplyScalar(fe),u.add(K)}})(),D=(function(){const K=new Je;return function(fe,Y){const re=r.domElement;if(r.object.isPerspectiveCamera){const ue=r.object.position;K.copy(ue).sub(r.target);let Fe=K.length();Fe*=Math.tan(r.object.fov/2*Math.PI/180),L(2*fe*Fe/re.clientHeight,r.object.matrix),U(2*Y*Fe/re.clientHeight,r.object.matrix)}else r.object.isOrthographicCamera?(L(fe*(r.object.right-r.object.left)/r.object.zoom/re.clientWidth,r.object.matrix),U(Y*(r.object.top-r.object.bottom)/r.object.zoom/re.clientHeight,r.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),r.enablePan=!1)}})();function $(K){r.object.isPerspectiveCamera||r.object.isOrthographicCamera?d/=K:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),r.enableZoom=!1)}function q(K){r.object.isPerspectiveCamera||r.object.isOrthographicCamera?d*=K:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),r.enableZoom=!1)}function z(K){if(!r.zoomToCursor)return;P=!0;const fe=r.domElement.getBoundingClientRect(),Y=K.clientX-fe.left,re=K.clientY-fe.top,ue=fe.width,Fe=fe.height;k.x=Y/ue*2-1,k.y=-re/Fe*2+1,A.set(k.x,k.y,1).unproject(r.object).sub(r.object.position).normalize()}function W(K){return Math.max(r.minDistance,Math.min(r.maxDistance,K))}function Q(K){h.set(K.clientX,K.clientY)}function te(K){x.set(K.clientX,K.clientY)}function H(){if(C.length===1)h.set(C[0].pageX,C[0].pageY);else{const K=.5*(C[0].pageX+C[1].pageX),fe=.5*(C[0].pageY+C[1].pageY);h.set(K,fe)}}function X(){if(C.length===1)x.set(C[0].pageX,C[0].pageY);else{const K=.5*(C[0].pageX+C[1].pageX),fe=.5*(C[0].pageY+C[1].pageY);x.set(K,fe)}}function Z(){const K=C[0].pageX-C[1].pageX,fe=C[0].pageY-C[1].pageY,Y=Math.sqrt(K*K+fe*fe);y.set(0,Y)}function ee(K){if(C.length==1)f.set(K.pageX,K.pageY);else{const Y=V(K),re=.5*(K.pageX+Y.x),ue=.5*(K.pageY+Y.y);f.set(re,ue)}p.subVectors(f,h).multiplyScalar(r.rotateSpeed);const fe=r.domElement;E(2*Math.PI*p.x/fe.clientHeight),B(2*Math.PI*p.y/fe.clientHeight),h.copy(f)}function Se(K){if(C.length===1)v.set(K.pageX,K.pageY);else{const fe=V(K),Y=.5*(K.pageX+fe.x),re=.5*(K.pageY+fe.y);v.set(Y,re)}g.subVectors(v,x).multiplyScalar(r.panSpeed),D(g.x,g.y),x.copy(v)}function oe(K){const fe=V(K),Y=K.pageX-fe.x,re=K.pageY-fe.y,ue=Math.sqrt(Y*Y+re*re);_.set(0,ue),N.set(0,Math.pow(_.y/y.y,r.zoomSpeed)),$(N.y),y.copy(_)}function ie(K){r.enabled!==!1&&(C.length===0&&(r.domElement.setPointerCapture(K.pointerId),r.domElement.addEventListener("pointermove",me),r.domElement.addEventListener("pointerup",se)),(function(fe){C.push(fe)})(K),K.pointerType==="touch"?(function(fe){switch(Le(fe),C.length){case 1:switch(r.touches.ONE){case ng.ROTATE:if(r.enableRotate===!1)return;H(),s=i.TOUCH_ROTATE;break;case ng.PAN:if(r.enablePan===!1)return;X(),s=i.TOUCH_PAN;break;default:s=i.NONE}break;case 2:switch(r.touches.TWO){case ng.DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;r.enableZoom&&Z(),r.enablePan&&X(),s=i.TOUCH_DOLLY_PAN;break;case ng.DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;r.enableZoom&&Z(),r.enableRotate&&H(),s=i.TOUCH_DOLLY_ROTATE;break;default:s=i.NONE}break;default:s=i.NONE}s!==i.NONE&&r.dispatchEvent(a2)})(K):(function(fe){let Y;switch(fe.button){case 0:Y=r.mouseButtons.LEFT;break;case 1:Y=r.mouseButtons.MIDDLE;break;case 2:Y=r.mouseButtons.RIGHT;break;default:Y=-1}switch(Y){case tg.DOLLY:if(r.enableZoom===!1)return;(function(re){z(re),y.set(re.clientX,re.clientY)})(fe),s=i.DOLLY;break;case tg.ROTATE:if(fe.ctrlKey||fe.metaKey||fe.shiftKey){if(r.enablePan===!1)return;te(fe),s=i.PAN}else{if(r.enableRotate===!1)return;Q(fe),s=i.ROTATE}break;case tg.PAN:if(fe.ctrlKey||fe.metaKey||fe.shiftKey){if(r.enableRotate===!1)return;Q(fe),s=i.ROTATE}else{if(r.enablePan===!1)return;te(fe),s=i.PAN}break;default:s=i.NONE}s!==i.NONE&&r.dispatchEvent(a2)})(K))}function me(K){r.enabled!==!1&&(K.pointerType==="touch"?(function(fe){switch(Le(fe),s){case i.TOUCH_ROTATE:if(r.enableRotate===!1)return;ee(fe),r.update();break;case i.TOUCH_PAN:if(r.enablePan===!1)return;Se(fe),r.update();break;case i.TOUCH_DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;(function(Y){r.enableZoom&&oe(Y),r.enablePan&&Se(Y)})(fe),r.update();break;case i.TOUCH_DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;(function(Y){r.enableZoom&&oe(Y),r.enableRotate&&ee(Y)})(fe),r.update();break;default:s=i.NONE}})(K):(function(fe){switch(s){case i.ROTATE:if(r.enableRotate===!1)return;(function(Y){f.set(Y.clientX,Y.clientY),p.subVectors(f,h).multiplyScalar(r.rotateSpeed);const re=r.domElement;E(2*Math.PI*p.x/re.clientHeight),B(2*Math.PI*p.y/re.clientHeight),h.copy(f),r.update()})(fe);break;case i.DOLLY:if(r.enableZoom===!1)return;(function(Y){_.set(Y.clientX,Y.clientY),N.subVectors(_,y),N.y>0?$(M()):N.y<0&&q(M()),y.copy(_),r.update()})(fe);break;case i.PAN:if(r.enablePan===!1)return;(function(Y){v.set(Y.clientX,Y.clientY),g.subVectors(v,x).multiplyScalar(r.panSpeed),D(g.x,g.y),x.copy(v),r.update()})(fe)}})(K))}function se(K){(function(fe){delete j[fe.pointerId];for(let Y=0;Y<C.length;Y++)if(C[Y].pointerId==fe.pointerId)return void C.splice(Y,1)})(K),C.length===0&&(r.domElement.releasePointerCapture(K.pointerId),r.domElement.removeEventListener("pointermove",me),r.domElement.removeEventListener("pointerup",se)),r.dispatchEvent(zH),s=i.NONE}function ce(K){r.enabled!==!1&&r.enableZoom!==!1&&s===i.NONE&&(K.preventDefault(),r.dispatchEvent(a2),(function(fe){z(fe),fe.deltaY<0?q(M()):fe.deltaY>0&&$(M()),r.update()})(K),r.dispatchEvent(zH))}function Ce(K){r.enabled!==!1&&r.enablePan!==!1&&(function(fe){let Y=!1;switch(fe.code){case r.keys.UP:fe.ctrlKey||fe.metaKey||fe.shiftKey?B(2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):D(0,r.keyPanSpeed),Y=!0;break;case r.keys.BOTTOM:fe.ctrlKey||fe.metaKey||fe.shiftKey?B(-2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):D(0,-r.keyPanSpeed),Y=!0;break;case r.keys.LEFT:fe.ctrlKey||fe.metaKey||fe.shiftKey?E(2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):D(r.keyPanSpeed,0),Y=!0;break;case r.keys.RIGHT:fe.ctrlKey||fe.metaKey||fe.shiftKey?E(-2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):D(-r.keyPanSpeed,0),Y=!0}Y&&(fe.preventDefault(),r.update())})(K)}function le(K){r.enabled!==!1&&K.preventDefault()}function Le(K){let fe=j[K.pointerId];fe===void 0&&(fe=new Nn,j[K.pointerId]=fe),fe.set(K.pageX,K.pageY)}function V(K){const fe=K.pointerId===C[0].pointerId?C[1]:C[0];return j[fe.pointerId]}r.domElement.addEventListener("contextmenu",le),r.domElement.addEventListener("pointerdown",ie),r.domElement.addEventListener("pointercancel",se),r.domElement.addEventListener("wheel",ce,{passive:!1}),this.update()}}Ut.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new Nn(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},Qs.line={uniforms:aL.merge([Ut.common,Ut.fog,Ut.line]),vertexShader:`
- #include <common>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- uniform float linewidth;
- uniform vec2 resolution;
- attribute vec3 instanceStart;
- attribute vec3 instanceEnd;
- attribute vec3 instanceColorStart;
- attribute vec3 instanceColorEnd;
- #ifdef WORLD_UNITS
- varying vec4 worldPos;
- varying vec3 worldStart;
- varying vec3 worldEnd;
- #ifdef USE_DASH
- varying vec2 vUv;
- #endif
- #else
- varying vec2 vUv;
- #endif
- #ifdef USE_DASH
- uniform float dashScale;
- attribute float instanceDistanceStart;
- attribute float instanceDistanceEnd;
- varying float vLineDistance;
- #endif
- void trimSegment( const in vec4 start, inout vec4 end ) {
- // trim end segment so it terminates between the camera plane and the near plane
- // conservative estimate of the near plane
- float a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column
- float b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column
- float nearEstimate = - 0.5 * b / a;
- float alpha = ( nearEstimate - start.z ) / ( end.z - start.z );
- end.xyz = mix( start.xyz, end.xyz, alpha );
- }
- void main() {
- #ifdef USE_COLOR
- vColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;
- #endif
- #ifdef USE_DASH
- vLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;
- vUv = uv;
- #endif
- float aspect = resolution.x / resolution.y;
- // camera space
- vec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );
- vec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );
- #ifdef WORLD_UNITS
- worldStart = start.xyz;
- worldEnd = end.xyz;
- #else
- vUv = uv;
- #endif
- // special case for perspective projection, and segments that terminate either in, or behind, the camera plane
- // clearly the gpu firmware has a way of addressing this issue when projecting into ndc space
- // but we need to perform ndc-space calculations in the shader, so we must address this issue directly
- // perhaps there is a more elegant solution -- WestLangley
- bool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column
- if ( perspective ) {
- if ( start.z < 0.0 && end.z >= 0.0 ) {
- trimSegment( start, end );
- } else if ( end.z < 0.0 && start.z >= 0.0 ) {
- trimSegment( end, start );
- }
- }
- // clip space
- vec4 clipStart = projectionMatrix * start;
- vec4 clipEnd = projectionMatrix * end;
- // ndc space
- vec3 ndcStart = clipStart.xyz / clipStart.w;
- vec3 ndcEnd = clipEnd.xyz / clipEnd.w;
- // direction
- vec2 dir = ndcEnd.xy - ndcStart.xy;
- // account for clip-space aspect ratio
- dir.x *= aspect;
- dir = normalize( dir );
- #ifdef WORLD_UNITS
- // get the offset direction as perpendicular to the view vector
- vec3 worldDir = normalize( end.xyz - start.xyz );
- vec3 offset;
- if ( position.y < 0.5 ) {
- offset = normalize( cross( start.xyz, worldDir ) );
- } else {
- offset = normalize( cross( end.xyz, worldDir ) );
- }
- // sign flip
- if ( position.x < 0.0 ) offset *= - 1.0;
- float forwardOffset = dot( worldDir, vec3( 0.0, 0.0, 1.0 ) );
- // don't extend the line if we're rendering dashes because we
- // won't be rendering the endcaps
- #ifndef USE_DASH
- // extend the line bounds to encompass endcaps
- start.xyz += - worldDir * linewidth * 0.5;
- end.xyz += worldDir * linewidth * 0.5;
- // shift the position of the quad so it hugs the forward edge of the line
- offset.xy -= dir * forwardOffset;
- offset.z += 0.5;
- #endif
- // endcaps
- if ( position.y > 1.0 || position.y < 0.0 ) {
- offset.xy += dir * 2.0 * forwardOffset;
- }
- // adjust for linewidth
- offset *= linewidth * 0.5;
- // set the world position
- worldPos = ( position.y < 0.5 ) ? start : end;
- worldPos.xyz += offset;
- // project the worldpos
- vec4 clip = projectionMatrix * worldPos;
- // shift the depth of the projected points so the line
- // segments overlap neatly
- vec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd;
- clip.z = clipPose.z * clip.w;
- #else
- vec2 offset = vec2( dir.y, - dir.x );
- // undo aspect ratio adjustment
- dir.x /= aspect;
- offset.x /= aspect;
- // sign flip
- if ( position.x < 0.0 ) offset *= - 1.0;
- // endcaps
- if ( position.y < 0.0 ) {
- offset += - dir;
- } else if ( position.y > 1.0 ) {
- offset += dir;
- }
- // adjust for linewidth
- offset *= linewidth;
- // adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...
- offset /= resolution.y;
- // select end
- vec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;
- // back to clip space
- offset *= clip.w;
- clip.xy += offset;
- #endif
- gl_Position = clip;
- vec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <fog_vertex>
- }
- `,fragmentShader:`
- uniform vec3 diffuse;
- uniform float opacity;
- uniform float linewidth;
- #ifdef USE_DASH
- uniform float dashOffset;
- uniform float dashSize;
- uniform float gapSize;
- #endif
- varying float vLineDistance;
- #ifdef WORLD_UNITS
- varying vec4 worldPos;
- varying vec3 worldStart;
- varying vec3 worldEnd;
- #ifdef USE_DASH
- varying vec2 vUv;
- #endif
- #else
- varying vec2 vUv;
- #endif
- #include <common>
- #include <color_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- vec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {
- float mua;
- float mub;
- vec3 p13 = p1 - p3;
- vec3 p43 = p4 - p3;
- vec3 p21 = p2 - p1;
- float d1343 = dot( p13, p43 );
- float d4321 = dot( p43, p21 );
- float d1321 = dot( p13, p21 );
- float d4343 = dot( p43, p43 );
- float d2121 = dot( p21, p21 );
- float denom = d2121 * d4343 - d4321 * d4321;
- float numer = d1343 * d4321 - d1321 * d4343;
- mua = numer / denom;
- mua = clamp( mua, 0.0, 1.0 );
- mub = ( d1343 + d4321 * ( mua ) ) / d4343;
- mub = clamp( mub, 0.0, 1.0 );
- return vec2( mua, mub );
- }
- void main() {
- #include <clipping_planes_fragment>
- #ifdef USE_DASH
- if ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps
- if ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX
- #endif
- float alpha = opacity;
- #ifdef WORLD_UNITS
- // Find the closest points on the view ray and the line segment
- vec3 rayEnd = normalize( worldPos.xyz ) * 1e5;
- vec3 lineDir = worldEnd - worldStart;
- vec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd );
- vec3 p1 = worldStart + lineDir * params.x;
- vec3 p2 = rayEnd * params.y;
- vec3 delta = p1 - p2;
- float len = length( delta );
- float norm = len / linewidth;
- #ifndef USE_DASH
- #ifdef USE_ALPHA_TO_COVERAGE
- float dnorm = fwidth( norm );
- alpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm );
- #else
- if ( norm > 0.5 ) {
- discard;
- }
- #endif
- #endif
- #else
- #ifdef USE_ALPHA_TO_COVERAGE
- // artifacts appear on some hardware if a derivative is taken within a conditional
- float a = vUv.x;
- float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
- float len2 = a * a + b * b;
- float dlen = fwidth( len2 );
- if ( abs( vUv.y ) > 1.0 ) {
- alpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );
- }
- #else
- if ( abs( vUv.y ) > 1.0 ) {
- float a = vUv.x;
- float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
- float len2 = a * a + b * b;
- if ( len2 > 1.0 ) discard;
- }
- #endif
- #endif
- vec4 diffuseColor = vec4( diffuse, alpha );
- #include <logdepthbuf_fragment>
- #include <color_fragment>
- gl_FragColor = vec4( diffuseColor.rgb, alpha );
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- }
- `};class aQ extends Yh{constructor(e){super({type:"LineMaterial",uniforms:aL.clone(Qs.line.uniforms),vertexShader:Qs.line.vertexShader,fragmentShader:Qs.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 BH=new bl,e_=new Je;class iQ extends hTe{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 qa([-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 qa([-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 pD(n,6,1);return this.setAttribute("instanceStart",new _h(r,3,0)),this.setAttribute("instanceEnd",new _h(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 pD(n,6,1);return this.setAttribute("instanceColorStart",new _h(r,3,0)),this.setAttribute("instanceColorEnd",new _h(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 iTe(e.geometry)),this}fromLineSegments(e){const n=e.geometry;return this.setPositions(n.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new bl);const e=this.attributes.instanceStart,n=this.attributes.instanceEnd;e!==void 0&&n!==void 0&&(this.boundingBox.setFromBufferAttribute(e),BH.setFromBufferAttribute(n),this.boundingBox.union(BH))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Dc),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++)e_.fromBufferAttribute(e,s),i=Math.max(i,r.distanceToSquared(e_)),e_.fromBufferAttribute(n,s),i=Math.max(i,r.distanceToSquared(e_));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 HH=new Je,$H=new Je,qi=new $r,Gi=new $r,mc=new $r,i2=new Je,s2=new ra,Wi=new mTe,VH=new Je,t_=new bl,n_=new Dc,fc=new $r;let pc,Qm;function qH(t,e,n){return fc.set(0,0,-e,1).applyMatrix4(t.projectionMatrix),fc.multiplyScalar(1/fc.w),fc.x=Qm/n.width,fc.y=Qm/n.height,fc.applyMatrix4(t.projectionMatrixInverse),fc.multiplyScalar(1/fc.w),Math.abs(Math.max(fc.x,fc.y))}class MTe extends Wl{constructor(e=new iQ,n=new aQ({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)HH.fromBufferAttribute(n,o),$H.fromBufferAttribute(r,o),i[l]=l===0?0:i[l-1],i[l+1]=i[l]+HH.distanceTo($H);const s=new pD(i,2,1);return e.setAttribute("instanceDistanceStart",new _h(s,1,0)),e.setAttribute("instanceDistanceEnd",new _h(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;pc=e.ray;const o=this.matrixWorld,l=this.geometry,c=this.material;let d,u;Qm=c.linewidth+s,l.boundingSphere===null&&l.computeBoundingSphere(),n_.copy(l.boundingSphere).applyMatrix4(o),r?d=.5*Qm:d=qH(i,Math.max(i.near,n_.distanceToPoint(pc.origin)),c.resolution),n_.radius+=d,pc.intersectsSphere(n_)!==!1&&(l.boundingBox===null&&l.computeBoundingBox(),t_.copy(l.boundingBox).applyMatrix4(o),r?u=.5*Qm:u=qH(i,Math.max(i.near,t_.distanceToPoint(pc.origin)),c.resolution),t_.expandByScalar(u),pc.intersectsBox(t_)!==!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 Je,A=new Je;pc.distanceSqToSegment(Wi.start,Wi.end,A,N),A.distanceTo(N)<.5*Qm&&f.push({point:A,pointOnLine:N,distance:pc.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),k=-f.near;pc.at(1,mc),mc.w=1,mc.applyMatrix4(f.matrixWorldInverse),mc.applyMatrix4(x),mc.multiplyScalar(1/mc.w),mc.x*=v.x/2,mc.y*=v.y/2,mc.z=0,i2.copy(mc),s2.multiplyMatrices(f.matrixWorldInverse,g);for(let P=0,C=A;P<C;P++){if(qi.fromBufferAttribute(_,P),Gi.fromBufferAttribute(N,P),qi.w=1,Gi.w=1,qi.applyMatrix4(s2),Gi.applyMatrix4(s2),qi.z>k&&Gi.z>k)continue;if(qi.z>k){const L=qi.z-Gi.z,U=(qi.z-k)/L;qi.lerp(Gi,U)}else if(Gi.z>k){const L=Gi.z-qi.z,U=(Gi.z-k)/L;Gi.lerp(qi,U)}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 j=Wi.closestPointToPointParameter(i2,!0);Wi.at(j,VH);const M=OY.lerp(qi.z,Gi.z,j),E=M>=-1&&M<=1,B=i2.distanceTo(VH)<.5*Qm;if(E&&B){Wi.start.fromBufferAttribute(_,P),Wi.end.fromBufferAttribute(N,P),Wi.start.applyMatrix4(g),Wi.end.applyMatrix4(g);const L=new Je,U=new Je;pc.distanceSqToSegment(Wi.start,Wi.end,U,L),p.push({point:U,pointOnLine:L,distance:pc.origin.distanceTo(U),object:h,face:null,faceIndex:P,uv:null,uv1:null})}}})(this,i,n)))}}class PTe extends uk{constructor(e,n,r,i,s=4473924,o=8947848){s=new hn(s),o=new hn(o);const l=Math.round(e/n);r=Math.round(r/i)*i/2;const c=[],d=[];let u=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(d,u),u+=3,p.toArray(d,u),u+=3,p.toArray(d,u),u+=3,p.toArray(d,u),u+=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(d,u),u+=3,p.toArray(d,u),u+=3,p.toArray(d,u),u+=3,p.toArray(d,u),u+=3}const h=new ws;h.setAttribute("position",new qa(c,3)),h.setAttribute("color",new qa(d,3)),super(h,new pv({vertexColors:!0,toneMapped:!1}))}}function ETe(t,e,n,r){const i=(function(o,l,c){o*=.5,l*=.5,c*=.5;const d=new ws,u=[];return u.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),d.setAttribute("position",new qa(u,3)),d})(t,e,n),s=new uk(i,new oTe({color:new hn(r),dashSize:3,gapSize:1}));return s.computeLineDistances(),s}var qy=function(){var t=0,e=document.createElement("div");function n(u){return e.appendChild(u.dom),u}function r(u){for(var h=0;h<e.children.length;h++)e.children[h].style.display=h===u?"block":"none";t=u}e.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",e.addEventListener("click",(function(u){u.preventDefault(),r(++t%e.children.length)}),!1);var i=(performance||Date).now(),s=i,o=0,l=n(new qy.Panel("FPS","#0ff","#002")),c=n(new qy.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var d=n(new qy.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 u=(performance||Date).now();if(c.update(u-i,200),u>=s+1e3&&(l.update(1e3*o/(u-s),100),s=u,o=0,d)){var h=performance.memory;d.update(h.usedJSHeapSize/1048576,h.jsHeapSizeLimit/1048576)}return u},update:function(){i=this.end()},domElement:e,setMode:r}};qy.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,d=3*o,u=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,d,u),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)+")",d,u),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 jTe=qy;class GH{constructor(e,n){this.openFolders=[],this.watchedObject=e,this.options=n,this.gui=new O1,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 O1,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 DTe extends ws{constructor(e=[new Je],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 Je,o=new Je,l=new Nn,c=[],d=[],u=[],h=[];function f(p){const[x,v,g]=(function(y){const _=e[y],N=new Je,A=new Je,k=new Je,P=new Je;N.copy(_).sub(e[y-1]||_).normalize().add((e[y+1]||_).clone().sub(_).normalize()).normalize();let C=Number.MAX_VALUE;const j=Math.abs(N.x),M=Math.abs(N.y),E=Math.abs(N.z);return j<=C&&(C=j,A.set(1,0,0)),M<=C&&(C=M,A.set(0,1,0)),E<=C&&A.set(0,0,1),P.crossVectors(N,A).normalize(),A.crossVectors(N,P),k.crossVectors(N,A),[_,A,k]})(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(),d.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,u.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 qa(c,3)),this.setAttribute("normal",new qa(d,3)),this.setAttribute("uv",new qa(u,2))}}class Gy{static get initial(){const e=new Gy;return Object.assign(e,{x:0,y:0,z:0,r:0,e:0,i:0,j:0,t:0}),e}}const o2={h:0,s:0,l:0};class tb{constructor(e){var n,r,i,s,o,l,c,d,u;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=Gy.initial,this.beyondFirstMove=!1,this.disposables=[],this._extrusionColor=tb.defaultExtrusionColor,this.renderLayerIndex=0,this._geometries={},this._backgroundColor=new hn(14737632),this._travelColor=new hn(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 I1(this.minLayerThreshold),this.scene=new XAe,this.scene.background=this._backgroundColor,e.backgroundColor!==void 0&&(this.backgroundColor=new hn(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=(d=e.extrusionWidth)!==null&&d!==void 0?d:this.extrusionWidth,this.devMode=(u=e.devMode)!==null&&u!==void 0?u:this.devMode,this.stats=this.devMode?new jTe:void 0,e.extrusionColor!==void 0&&(this.extrusionColor=e.extrusionColor),e.travelColor!==void 0&&(this.travelColor=new hn(e.travelColor)),e.topLayerColor!==void 0&&(this.topLayerColor=new hn(e.topLayerColor)),e.lastSegmentColor!==void 0&&(this.lastSegmentColor=new hn(e.lastSegmentColor)),e.toolColors){this._toolColors={};for(const[p,x]of Object.entries(e.toolColors))this._toolColors[parseInt(p)]=new hn(x)}if(e.disableGradient!==void 0&&(this.disableGradient=e.disableGradient),console.info("Using THREE r"+sk),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 fD({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 fD({preserveDrawingBuffer:!0}),this.canvas=this.renderer.domElement,p.appendChild(this.canvas)}this.camera=new Ao(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 oL(this._backgroundColor,f,h),this.resize(),this.controls=new TTe(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 hn(r)}else this._extrusionColor=new hn(e)}get currentToolColor(){var e;return this._extrusionColor===void 0?tb.defaultExtrusionColor:this._extrusionColor instanceof hn?this._extrusionColor:(e=this._extrusionColor[this.state.t])!==null&&e!==void 0?e:tb.defaultExtrusionColor}get backgroundColor(){return this._backgroundColor}set backgroundColor(e){this._backgroundColor=new hn(e),this.scene.background=this._backgroundColor}get travelColor(){return this._travelColor}set travelColor(e){this._travelColor=new hn(e)}get topLayerColor(){return this._topLayerColor}set topLayerColor(e){this._topLayerColor=e!==void 0?new hn(e):void 0}get lastSegmentColor(){return this._lastSegmentColor}set lastSegmentColor(e){this._lastSegmentColor=e!==void 0?new hn(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 fTe(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 uTe(13421772,.3*Math.PI),n=new dTe(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 Ty;return n.name=e,n.quaternion.setFromEuler(new mv(-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=Gy.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 r2(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,d;if(e>this.maxLayerIndex)return;const u=this.layers[e],h={extrusion:[],travel:[],z:this.state.z,height:u.height};for(const f of u.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=((d=p.params.e)!==null&&d!==void 0?d: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(o2),s=new hn().setHSL(o2.h,o2.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),d=e.extrusion.splice(-3);this.renderTubes?(this.addTubeLine(e.extrusion,o.getHex(),e.height),this.addTubeLine([...d,...c],l.getHex(),e.height)):(this.addLine(e.extrusion,o.getHex()),this.addLine([...d,...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 PTe(this.buildVolume.x,10,this.buildVolume.y,10));const e=ETe(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 I1(this.minLayerThreshold)}resetState(){var e;this.startLayer=1,this.endLayer=1/0,this.singleLayerMode=!1,this.beyondFirstMove=!1,this.state=Gy.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,d=n.z,u=r.x,h=r.y,f=r.z;let p=r.r,x=r.i,v=r.j;if(p){const $=u-l,q=h-c,z=Math.sqrt(Math.pow($/2,2)+Math.pow(q/2,2));p=Math.max(p,z);const W=Math.pow($,2)+Math.pow(q,2),Q=Math.pow(p,2)-W/4;let te=Math.sqrt(Q/W);(s&&p<0||!s&&p>0)&&(te=-te),x=$/2+q*te,v=q/2-$*te}const g=l==u&&c==h,y=l+x,_=c+v,N=Math.sqrt(x*x+v*v),A=Math.atan2(-v,-x),k=Math.atan2(h-_,u-y);let P;g?P=2*Math.PI:(P=s?A-k:k-A,P<0&&(P+=2*Math.PI));let C=N*P/1.8;this.inches&&(C*=25),C<1&&(C=1);let j=P/C;j*=s?-1:1;const M=[];M.push({x:l,y:c,z:d});const E=(d-f)/C;let B=l,L=c,U=d,D=A;for(let $=0;$<C-1;$++)D+=j,B=y+N*Math.cos(D),L=_+N*Math.sin(D),U+=E,M.push({x:B,y:L,z:U});M.push({x:r.x,y:r.y,z:r.z});for(let $=0;$<M.length-1;$++)o.push(M[$].x,M[$].y,M[$].z,M[$+1].x,M[$+1].y,M[$+1].z)}addLine(e,n){var r;if(typeof this.lineWidth=="number"&&this.lineWidth>0)return void this.addThickLine(e,n);const i=new ws;i.setAttribute("position",new qa(e,3)),this.disposables.push(i);const s=new pv({color:n});this.disposables.push(s);const o=new uk(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 Je(l[0],l[1],l[2]),d=new Je(l[3],l[4],l[5]),u=new Je(l[6],l[7],l[8]);i.push(c),d.equals(u)||(i.push(d),s.push(i),i=[])}s.forEach((o=>{var l;const c=new DTe(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 iQ;this.disposables.push(i);const s=new aQ({color:n,linewidth:this.lineWidth/(1e3*window.devicePixelRatio)});this.disposables.push(s),i.setPositions(e);const o=new MTe(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=>r2(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 sTe({color:e,wireframe:this._wireframe});this.disposables.push(i);const s=r.reduce(((l,c)=>3*c.attributes.position.count+l),0),o=new rTe(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 r2(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 d=(c=s.value,new TextDecoder("utf-8").decode(c)),u=d.lastIndexOf(`
- `),h=d.slice(0,u);this.parser.parseGCode(o+h),o=d.slice(u)}while(!s.done);var c;console.debug("read from stream",l)}))}initGui(){typeof this.devMode=="boolean"&&this.devMode===!0?this.devGui=new GH(this):typeof this.devMode=="object"&&(this.devGui=new GH(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())}}tb.defaultExtrusionColor=new hn("hotpink");function sQ({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,d]=w.useState(!0),[u,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 k=i.current,P=k.parentElement?.getBoundingClientRect();P&&(k.width=P.width,k.height=P.height);const C=n&&n.length>1,j=n?.[0]||"#00ae42",M=new tb({canvas:k,buildVolume:e,backgroundColor:1710618,extrusionColor:C?n:j,disableGradient:!0,lineHeight:.2,lineWidth:2,renderTravel:!1,renderExtrusion:!0});s.current=M;const E={},B=au();B&&(E.Authorization=`Bearer ${B}`),fetch(t,{headers:E}).then(async U=>{if(!U.ok)throw U.status===404&&(await U.json().catch(()=>({}))).detail?.includes("sliced")?(p(!0),new Error("not_sliced")):new Error("Failed to load G-code");return U.text()}).then(U=>{const D=new Set,$=/^(\s*)T(\d+)(\s*;.*)?$/gim;let q;for(;(q=$.exec(U))!==null;){const X=parseInt(q[2],10);X<=15&&D.add(X)}const z=new Map,W=Array.from(D).sort((X,Z)=>X-Z);W.forEach((X,Z)=>{z.set(X,Z%8)});const Q=[];W.forEach((X,Z)=>{const ee=n?.[X]||"#00ae42";Q[Z%8]=ee});const te=U.split(`
- `).map(X=>{const Z=X.match(/^(\s*)T(\d+)(\s*;.*)?$/i);if(Z){const ee=parseInt(Z[2],10);if(ee>15)return`; FILTERED: ${X.trim()}`;const Se=z.get(ee)??0;return`${Z[1]}T${Se}${Z[3]||""}`}return X}).join(`
- `);Q.length>0&&(M.extrusionColor=Q),M.processGCode(te);const H=M.layers?.length||0;y(H),v(H),M.render(),d(!1)}).catch(U=>{U.message!=="not_sliced"&&h(U.message),d(!1)});const L=()=>{if(k.parentElement&&s.current){const U=k.parentElement.getBoundingClientRect();k.width=U.width,k.height=U.height,s.current.resize()}};return window.addEventListener("resize",L),()=>{window.removeEventListener("resize",L),o.current&&cancelAnimationFrame(o.current),s.current&&(s.current.dispose(),s.current=null),l.current=!1}},[t,_]);const N=w.useCallback(k=>{if(!s.current)return;const P=Math.max(1,Math.min(k,g));v(P),o.current&&cancelAnimationFrame(o.current),o.current=requestAnimationFrame(()=>{s.current&&(s.current.endLayer=P,s.current.render())})},[g]),A=k=>{N(parseInt(k.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(at,{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(Sme,{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."})]})}),u&&!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:u})})})]}),!c&&!u&&!f&&g>0&&a.jsx("div",{className:"mt-4 px-2",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(ri,{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(Yl,{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 hl(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 RTe({printerId:t,filePath:e,filename:n,onClose:r}){const[i,s]=w.useState(null),[o,l]=w.useState([]),[c,d]=w.useState(!1),[u,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&&(d(!0),J.getPrinterFilePlates(t,e).then(y=>l(y.plates||[])).catch(()=>l([])).finally(()=>d(!1)))},[e,p,t]);const v=o.length>1,g=u==null?null:o.find(y=>y.index===u)??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(Me,{variant:"ghost",size:"sm",onClick:r,children:a.jsx(Rt,{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(ei,{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(Ps,{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(ei,{className:"w-4 h-4"}),"Plates",c&&a.jsx(at,{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 ${u==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(ei,{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":""]})]}),u==null&&a.jsx(co,{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 ${u===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:J.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(ei,{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":""}`})]}),u===y.index&&a.jsx(co,{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(NY,{url:J.getPrinterFileDownloadUrl(t,e),fileType:f,selectedPlateId:u,className:"w-full h-full"})})]}):i==="gcode"&&x?a.jsx(sQ,{gcodeUrl:J.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 WH(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 FTe(t,e){if(e)return SX;switch(t.toLowerCase().split(".").pop()||""){case"3mf":return hf;case"gcode":return Ps;case"mp4":case"avi":return Ph;case"png":case"jpg":case"jpeg":return eu;default:return $C}}const LTe=[{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 OTe({printerId:t,printerName:e,onClose:n}){const{t:r}=Dt(),{showToast:i}=dn(),s=Qt(),[o,l]=w.useState("/"),[c,d]=w.useState(new Set),[u,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 z=W=>{W.key==="Escape"&&n()};return window.addEventListener("keydown",z),()=>window.removeEventListener("keydown",z)},[n]);const{data:A,isLoading:k,refetch:P}=Ze({queryKey:["printerFiles",t,o],queryFn:()=>J.getPrinterFiles(t,o)}),{data:C}=Ze({queryKey:["printerStorage",t],queryFn:()=>J.getPrinterStorage(t),staleTime:3e4}),j=st({mutationFn:async z=>{for(const W of z)await J.deletePrinterFile(t,W)},onSuccess:()=>{i(r("printerFiles.toast.filesDeleted",{count:f.length})),s.invalidateQueries({queryKey:["printerFiles",t]}),d(new Set),p([])},onError:z=>{i(r("printerFiles.toast.deleteFailed",{error:z.message}),"error")}}),M=z=>{l(z),d(new Set)},E=()=>{if(o==="/")return;const z=o.split("/").filter(Boolean);z.pop(),l(z.length?"/"+z.join("/"):"/"),d(new Set)},B=(z,W)=>{W.stopPropagation(),d(Q=>{const te=new Set(Q);return te.has(z)?te.delete(z):te.add(z),te})},L=()=>{if(!A?.files)return;const z=A.files.filter(W=>!W.is_directory&&(!u||W.name.toLowerCase().includes(u.toLowerCase()))).map(W=>W.path);d(new Set(z))},U=()=>{d(new Set)},D=async()=>{if(c.size===0)return;const z=Array.from(c);if(z.length===1){J.downloadPrinterFile(t,z[0]).catch(W=>{console.error("Printer file download failed:",W)}),d(new Set);return}y({current:0,total:z.length});try{const W=await J.downloadPrinterFilesAsZip(t,z),Q=URL.createObjectURL(W),te=document.createElement("a");te.href=Q,te.download=`${e.replace(/[^a-zA-Z0-9]/g,"_")}-files.zip`,document.body.appendChild(te),te.click(),document.body.removeChild(te),URL.revokeObjectURL(Q),i(`Downloaded ${z.length} files as ZIP`),d(new Set)}catch(W){i(`Download failed: ${W instanceof Error?W.message:"Unknown error"}`,"error")}finally{y(null)}},$=()=>{c.size!==0&&p(Array.from(c))},q=[{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:z=>z.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(Vb,{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:[C&&(C.used_bytes!=null||C.free_bytes!=null)&&a.jsxs("div",{className:"text-sm text-bambu-gray flex items-center gap-2",children:[C.used_bytes!=null&&a.jsxs("span",{children:[r("printerFiles.storageUsed")," ",WH(C.used_bytes)]}),C.used_bytes!=null&&C.free_bytes!=null&&a.jsx("span",{className:"text-bambu-dark-tertiary",children:"|"}),C.free_bytes!=null&&a.jsxs("span",{children:[r("printerFiles.storageFree")," ",WH(C.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(Rt,{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:[q.map(z=>a.jsx("button",{onClick:()=>{M(z.path),h("")},className:`px-3 py-1 text-sm rounded-full transition-colors ${o===z.path?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,children:z.label},z.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:u,onChange:z=>h(z.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(kF,{className:"w-4 h-4 text-bambu-gray"}),a.jsx("select",{value:x,onChange:z=>v(z.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:LTe.map(z=>a.jsx("option",{value:z.value,children:z.label},z.value))})]}),a.jsx(Me,{variant:"secondary",size:"sm",onClick:()=>P(),disabled:k,children:a.jsx(Sr,{className:`w-4 h-4 ${k?"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:E,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(Yl,{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:k?a.jsx("div",{className:"flex items-center justify-center py-12",children:a.jsx(at,{className:"w-8 h-8 text-bambu-green animate-spin"})}):A?.files?.length?a.jsx("div",{className:"space-y-1",children:[...A.files].filter(z=>!u||z.name.toLowerCase().includes(u.toLowerCase())).sort((z,W)=>{if(z.is_directory&&!W.is_directory)return-1;if(!z.is_directory&&W.is_directory)return 1;switch(x){case"name-asc":return z.name.localeCompare(W.name);case"name-desc":return W.name.localeCompare(z.name);case"size-asc":return z.size-W.size;case"size-desc":return W.size-z.size;case"date-asc":{const Q=z.mtime?tr(z.mtime)?.getTime()??0:0,te=W.mtime?tr(W.mtime)?.getTime()??0:0;return Q-te}case"date-desc":{const Q=z.mtime?tr(z.mtime)?.getTime()??0:0;return(W.mtime?tr(W.mtime)?.getTime()??0:0)-Q}default:return z.name.localeCompare(W.name)}}).map(z=>{const W=FTe(z.name,z.is_directory),Q=c.has(z.path);return a.jsxs("div",{className:`flex items-center gap-3 p-2 rounded-lg cursor-pointer transition-colors ${Q?"bg-bambu-green/20 border border-bambu-green/50":"hover:bg-bambu-dark-tertiary"}`,onClick:()=>{z.is_directory&&M(z.path)},children:[z.is_directory?null:a.jsx("button",{onClick:te=>B(z.path,te),className:"flex-shrink-0 text-bambu-gray hover:text-white",children:Q?a.jsx(co,{className:"w-5 h-5 text-bambu-green"}):a.jsx(Sl,{className:"w-5 h-5"})}),a.jsx(W,{className:`w-5 h-5 flex-shrink-0 ${z.is_directory?"text-bambu-green":"text-bambu-gray"}`}),a.jsx("span",{className:"flex-1 text-white truncate",children:z.name}),!z.is_directory&&a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("span",{className:"text-sm text-bambu-gray",children:hl(z.size)}),(z.name.toLowerCase().endsWith(".3mf")||z.name.toLowerCase().endsWith(".gcode")||z.name.toLowerCase().endsWith(".stl"))&&a.jsx("button",{onClick:te=>{te.stopPropagation(),N({path:z.path,name:z.name})},className:"p-1 rounded hover:bg-bambu-dark text-bambu-gray hover:text-bambu-green",title:"3D View",children:a.jsx(ei,{className:"w-4 h-4"})})]}),z.is_directory&&a.jsx(Yl,{className:"w-4 h-4 text-bambu-gray rotate-180"})]},z.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`:u?`${A?.files?.filter(z=>z.name.toLowerCase().includes(u.toLowerCase())).length||0} of ${A?.files?.length||0} items`:`${A?.files?.length||0} items`}),A?.files?.some(z=>!z.is_directory)&&a.jsx("div",{className:"flex items-center gap-2",children:c.size>0?a.jsxs("button",{onClick:U,className:"flex items-center gap-1 text-xs text-bambu-gray hover:text-white transition-colors",children:[a.jsx(Dpe,{className:"w-4 h-4"}),"Deselect All"]}):a.jsxs("button",{onClick:L,className:"flex items-center gap-1 text-xs text-bambu-gray hover:text-white transition-colors",children:[a.jsx(co,{className:"w-4 h-4"}),"Select All"]})})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Me,{variant:"secondary",disabled:c.size===0||g!==null,onClick:D,children:g?a.jsxs(a.Fragment,{children:[a.jsx(at,{className:"w-4 h-4 animate-spin"}),g.current,"/",g.total]}):a.jsxs(a.Fragment,{children:[a.jsx(ga,{className:"w-4 h-4"}),"Download",c.size>1?` (${c.size})`:""]})}),a.jsxs(Me,{variant:"secondary",disabled:c.size===0||j.isPending,onClick:$,className:"text-red-400 hover:text-red-300",children:[j.isPending?a.jsx(at,{className:"w-4 h-4 animate-spin"}):a.jsx(Yt,{className:"w-4 h-4"}),r("printerFiles.deleteButton"),c.size>1?` (${c.size})`:""]})]})]})]}),f.length>0&&a.jsx(xn,{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:()=>{j.mutate(f)},onCancel:()=>p([])}),_&&a.jsx(RTe,{printerId:t,filePath:_.path,filename:_.name,onClose:()=>N(null)})]})}function dL({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 hk=({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 uL({printerId:t,isOpen:e,onClose:n}){const{t:r}=Dt(),{showToast:i}=dn(),{hasPermission:s}=jr(),[o,l]=w.useState(null),[c,d]=w.useState(!1),{data:u}=Ze({queryKey:["printerStatus",t],queryFn:()=>J.getPrinterStatus(t),refetchInterval:3e4,enabled:e}),{data:h,refetch:f}=Ze({queryKey:["printableObjects",t],queryFn:()=>J.getPrintableObjects(t),enabled:e,refetchInterval:e?5e3:!1}),p=st({mutationFn:x=>J.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?d(!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(hk,{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(Rt,{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(Ife,{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")]})]}),(u?.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(Va,{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:u?.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:()=>d(!0),children:[u?.cover_url?a.jsx("img",{src:`${u.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(ei,{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(WC,{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,k]=h.bbox_all,P=A-_,C=k-N,j=8,M=100-j*2;g=j+(x.x-_)/P*M,y=j+(k-x.y)/C*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%_,k=Math.ceil(h.objects.length/_);g=15+A*(70/_)+35/_,y=15+N*(70/k)+35/k}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:`
- flex items-center gap-3 px-4 py-3 border-b border-gray-200 dark:border-bambu-dark-tertiary/50 last:border-0
- ${x.skipped?"bg-red-50 dark:bg-red-500/10":"hover:bg-gray-50 dark:hover:bg-bambu-dark/50"}
- `,children:[a.jsxs("div",{className:`
- w-12 h-12 flex-shrink-0 rounded-lg flex flex-col items-center justify-center
- ${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"}
- `,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||(u?.layer_num??0)<=1||!s("printers:control"),className:`px-4 py-2 text-xs font-medium rounded-lg transition-colors ${(u?.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")?(u?.layer_num??0)<=1?r("printers.skipObjects.waitForLayer",{layer:u?.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(at,{className:"w-5 h-5 animate-spin text-bambu-gray"})})]})]}),o&&a.jsx(xn,{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:()=>d(!1),children:[a.jsx("button",{onClick:()=>d(!1),className:"absolute top-4 right-4 p-2 text-white/70 hover:text-white transition-colors",children:a.jsx(Rt,{className:"w-6 h-6"})}),a.jsxs("div",{className:"relative max-w-[600px] max-h-[80vh] aspect-square",onClick:x=>x.stopPropagation(),children:[u?.cover_url?a.jsx("img",{src:`${u.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(ei,{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,k]=h.bbox_all,P=A-_,C=k-N,j=8,M=100-j*2;g=j+(x.x-_)/P*M,y=j+(k-x.y)/C*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%_,k=Math.ceil(h.objects.length/_);g=15+A*(70/_)+35/_,y=15+N*(70/k)+35/k}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 ITe="embeddedCameraState_",KH=5,zTe=2e3,UTe=3e4,BTe=5e3,l2={x:window.innerWidth-420,y:20,width:400,height:300};function HTe({printerId:t,printerName:e,viewerIndex:n=0,onClose:r}){const{t:i}=Dt(),s=Qt(),{showToast:o}=dn(),{hasPermission:l}=jr(),c=`${ITe}${t}`,d=()=>{try{const je=localStorage.getItem(c);if(je){const Ve=JSON.parse(je);return{x:Math.min(Math.max(0,Ve.x),window.innerWidth-100),y:Math.min(Math.max(0,Ve.y),window.innerHeight-100),width:Math.max(200,Math.min(Ve.width,window.innerWidth-20)),height:Math.max(150,Math.min(Ve.height,window.innerHeight-20))}}}catch{}const Oe=n*30;return{...l2,x:Math.max(0,l2.x-Oe),y:Math.max(0,l2.y+Oe)}},[u,h]=w.useState(d),[f,p]=w.useState(!1),[x,v]=w.useState(!1),[g,y]=w.useState({x:0,y:0}),[_,N]=w.useState(!1),[A,k]=w.useState(!1),[P,C]=w.useState(1),[j,M]=w.useState({x:0,y:0}),[E,B]=w.useState(!1),[L,U]=w.useState({x:0,y:0}),[D,$]=w.useState(null),[q,z]=w.useState(null),[W,Q]=w.useState(!1),[te,H]=w.useState(!0),[X,Z]=w.useState(Date.now()),[ee,Se]=w.useState(0),[oe,ie]=w.useState(!1),[me,se]=w.useState(0),ce=w.useRef(null),Ce=w.useRef(null),le=w.useRef(null),Le=w.useRef(null),V=w.useRef(null),[K,fe]=w.useState(!1),{data:Y}=Ze({queryKey:["printer",t],queryFn:()=>J.getPrinter(t),enabled:t>0}),{data:re}=Ze({queryKey:["printerStatus",t],queryFn:()=>J.getPrinterStatus(t),refetchInterval:3e4,enabled:t>0}),ue=st({mutationFn:Oe=>J.setChamberLight(t,Oe),onMutate:async Oe=>{await s.cancelQueries({queryKey:["printerStatus",t]});const je=s.getQueryData(["printerStatus",t]);return s.setQueryData(["printerStatus",t],Ve=>({...Ve,chamber_light:Oe})),{previousStatus:je}},onSuccess:(Oe,je)=>{o(`Chamber light ${je?"on":"off"}`)},onError:(Oe,je,Ve)=>{Ve?.previousStatus&&s.setQueryData(["printerStatus",t],Ve.previousStatus),o(Oe.message||i("printers.toast.failedToControlChamberLight"),"error")}}),Fe=(re?.state==="RUNNING"||re?.state==="PAUSE")&&(re?.printable_objects_count??0)>=2;w.useEffect(()=>{const Oe=setTimeout(()=>{localStorage.setItem(c,JSON.stringify(u))},500);return()=>clearTimeout(Oe)},[u,c]);const Pe=w.useRef(!1);w.useEffect(()=>{Pe.current=!1;const Oe=`/api/v1/printers/${t}/camera/stop`,je=()=>{if(t>0&&!Pe.current){Pe.current=!0;const ot={},kt=au();kt&&(ot.Authorization=`Bearer ${kt}`),fetch(Oe,{method:"POST",keepalive:!0,headers:ot}).catch(()=>{})}},Ve=Ce.current;return()=>{Ve&&(Ve.src=""),je(),le.current&&clearTimeout(le.current),Le.current&&clearInterval(Le.current),V.current&&clearInterval(V.current)}},[t]),w.useEffect(()=>{if(te){const Oe=setTimeout(()=>H(!1),3e3);return()=>clearTimeout(Oe)}},[te,X]);const be=w.useCallback(()=>{if(ee>=KH){ie(!1),Q(!0);return}const Oe=Math.min(zTe*Math.pow(2,ee),UTe);ie(!0),se(Math.ceil(Oe/1e3)),Le.current=setInterval(()=>{se(je=>je<=1?(Le.current&&clearInterval(Le.current),0):je-1)},1e3),le.current=setTimeout(()=>{Se(je=>je+1),ie(!1),H(!0),Q(!1),Ce.current&&(Ce.current.src=""),Z(Date.now())},Oe)},[ee]);w.useEffect(()=>{if(te||oe||_){V.current&&(clearInterval(V.current),V.current=null);return}return V.current=setInterval(async()=>{try{const Oe=await J.getCameraStatus(t);(Oe.stalled||!Oe.active&&!W)&&(V.current&&(clearInterval(V.current),V.current=null),H(!1),be())}catch{}},BTe),()=>{V.current&&(clearInterval(V.current),V.current=null)}},[te,W,oe,_,t,be]),w.useEffect(()=>{const Oe=()=>{const je=!!document.fullscreenElement;k(je),je||(C(1),M({x:0,y:0}))};return document.addEventListener("fullscreenchange",Oe),()=>document.removeEventListener("fullscreenchange",Oe)},[]);const O=()=>{ce.current&&(document.fullscreenElement?document.exitFullscreen():ce.current.requestFullscreen())},R=()=>{C(Oe=>Math.min(Oe+.5,4))},G=()=>{C(Oe=>{const je=Math.max(Oe-.5,1);return je===1&&M({x:0,y:0}),je})},de=Oe=>{Oe.preventDefault(),Oe.deltaY<0?R():G()},ge=Oe=>{P>1&&(Oe.preventDefault(),B(!0),U({x:Oe.clientX-j.x,y:Oe.clientY-j.y}))},ae=w.useCallback(()=>{if(!ce.current||!Ce.current)return{x:200,y:150};const Oe=ce.current.getBoundingClientRect(),je=Oe.width*(P-1)/2,Ve=Oe.height*(P-1)/2;return{x:Math.max(50,je),y:Math.max(50,Ve)}},[P]),Ue=Oe=>{if(E&&P>1){const je=Oe.clientX-L.x,Ve=Oe.clientY-L.y,ot=ae();M({x:Math.max(-ot.x,Math.min(ot.x,je)),y:Math.max(-ot.y,Math.min(ot.y,Ve))})}},ze=()=>{B(!1)},$e=Oe=>{if(Oe.length<2)return 0;const je=Oe[0].clientX-Oe[1].clientX,Ve=Oe[0].clientY-Oe[1].clientY;return Math.sqrt(je*je+Ve*Ve)},Re=Oe=>Oe.length<2?{x:Oe[0].clientX,y:Oe[0].clientY}:{x:(Oe[0].clientX+Oe[1].clientX)/2,y:(Oe[0].clientY+Oe[1].clientY)/2},pe=Oe=>{Oe.touches.length===2?(Oe.preventDefault(),$($e(Oe.touches)),z(Re(Oe.touches))):Oe.touches.length===1&&P>1&&(Oe.preventDefault(),B(!0),U({x:Oe.touches[0].clientX-j.x,y:Oe.touches[0].clientY-j.y}))},ve=Oe=>{if(Oe.touches.length===2&&D!==null){Oe.preventDefault();const je=$e(Oe.touches),Ve=je/D;C(kt=>{const Ft=Math.max(1,Math.min(4,kt*Ve));return Ft===1&&M({x:0,y:0}),Ft}),$(je);const ot=Re(Oe.touches);if(q){const kt=ae();M(Ft=>({x:Math.max(-kt.x,Math.min(kt.x,Ft.x+(ot.x-q.x))),y:Math.max(-kt.y,Math.min(kt.y,Ft.y+(ot.y-q.y)))}))}z(ot)}else if(Oe.touches.length===1&&E&&P>1){Oe.preventDefault();const je=Oe.touches[0].clientX-L.x,Ve=Oe.touches[0].clientY-L.y,ot=ae();M({x:Math.max(-ot.x,Math.min(ot.x,je)),y:Math.max(-ot.y,Math.min(ot.y,Ve))})}},Ne=Oe=>{Oe.touches.length<2&&($(null),z(null)),Oe.touches.length===0&&B(!1)},xe=()=>{C(1),M({x:0,y:0})},we=()=>{H(!1),ee<KH?be():Q(!0)},qe=()=>{H(!1),Q(!1),Se(0),ie(!1),le.current&&clearTimeout(le.current),Le.current&&clearInterval(Le.current)},ke=()=>{H(!0),Q(!1),Se(0),ie(!1),le.current&&clearTimeout(le.current),Le.current&&clearInterval(Le.current);const Oe={},je=au();je&&(Oe.Authorization=`Bearer ${je}`),fetch(`/api/v1/printers/${t}/camera/stop`,{method:"POST",headers:Oe}).catch(()=>{}),Ce.current&&(Ce.current.src=""),setTimeout(()=>Z(Date.now()),100)},nt=Oe=>{Oe.target.closest(".no-drag")||(p(!0),y({x:Oe.clientX-u.x,y:Oe.clientY-u.y}))},De=Oe=>{Oe.stopPropagation(),v(!0)};w.useEffect(()=>{const Oe=Ve=>{if(f)h(ot=>({...ot,x:Math.max(0,Math.min(Ve.clientX-g.x,window.innerWidth-ot.width)),y:Math.max(0,Math.min(Ve.clientY-g.y,window.innerHeight-ot.height))}));else if(x&&ce.current){const ot=ce.current.getBoundingClientRect();h(kt=>({...kt,width:Math.max(200,Math.min(Ve.clientX-ot.left,window.innerWidth-kt.x-10)),height:Math.max(150,Math.min(Ve.clientY-ot.top,window.innerHeight-kt.y-10))}))}},je=()=>{p(!1),v(!1)};if(f||x)return document.addEventListener("mousemove",Oe),document.addEventListener("mouseup",je),()=>{document.removeEventListener("mousemove",Oe),document.removeEventListener("mouseup",je)}},[f,x,g]);const We=`/api/v1/printers/${t}/camera/stream?fps=15&t=${X}`;return a.jsxs("div",{ref:ce,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:u.x,top:u.y,width:_?200:u.width,height:_?40:u.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:nt,children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm text-white truncate",children:[a.jsx(jh,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),a.jsx("span",{className:"truncate",children:Y?.name||e})]}),a.jsxs("div",{className:"flex items-center gap-1 no-drag",children:[a.jsx("button",{onClick:()=>ue.mutate(!re?.chamber_light),disabled:!re?.connected||ue.isPending||!l("printers:control"),className:`p-1 rounded disabled:opacity-50 ${re?.chamber_light?"bg-yellow-500/20 hover:bg-yellow-500/30":"hover:bg-bambu-dark-tertiary"}`,title:l("printers:control")?i("camera.chamberLight"):i("printers.permission.noControl"),children:a.jsx(dL,{on:re?.chamber_light??!1,className:"w-3.5 h-3.5"})}),a.jsx("button",{onClick:()=>fe(!0),disabled:!Fe||!l("printers:control"),className:`p-1 rounded disabled:opacity-50 ${Fe&&l("printers:control")?"hover:bg-bambu-dark-tertiary":""}`,title:l("printers:control")?i(Fe?"printers.skipObjects.tooltip":"printers.skipObjects.onlyWhilePrinting"):i("printers.permission.noControl"),children:a.jsx(hk,{className:"w-3.5 h-3.5 text-bambu-gray"})}),a.jsx("button",{onClick:ke,disabled:te||oe,className:"p-1 hover:bg-bambu-dark-tertiary rounded disabled:opacity-50",title:"Refresh stream",children:a.jsx(Sr,{className:`w-3.5 h-3.5 text-bambu-gray ${te?"animate-spin":""}`})}),a.jsx("button",{onClick:O,className:"p-1 hover:bg-bambu-dark-tertiary rounded",title:A?"Exit fullscreen":"Fullscreen",children:A?a.jsx(CX,{className:"w-3.5 h-3.5 text-bambu-gray"}):a.jsx(Ome,{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(WC,{className:"w-3.5 h-3.5 text-bambu-gray"}):a.jsx(TF,{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(Rt,{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:de,onMouseMove:Ue,onMouseUp:ze,onMouseLeave:ze,onTouchStart:pe,onTouchMove:ve,onTouchEnd:Ne,style:{touchAction:"none"},children:[te&&!oe&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50 z-10",children:a.jsx(Sr,{className:"w-6 h-6 text-bambu-gray animate-spin"})}),oe&&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(Gh,{className:"w-6 h-6 text-orange-400 mx-auto mb-2"}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:["Reconnecting in ",me,"s..."]})]})}),W&&!oe&&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(An,{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:ke,className:"px-2 py-1 text-xs bg-bambu-green text-white rounded hover:bg-bambu-green/80",children:"Retry"})]})}),a.jsx("img",{ref:Ce,src:We,alt:"Camera stream",className:"max-w-full max-h-full object-contain select-none",style:{transform:`scale(${P}) translate(${j.x/P}px, ${j.y/P}px)`,cursor:P>1?E?"grabbing":"grab":"default"},onError:we,onLoad:qe,onMouseDown:ge,draggable:!1},X),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:G,disabled:P<=1,className:"p-1 hover:bg-white/10 rounded disabled:opacity-30",title:"Zoom out",children:a.jsx(RF,{className:"w-3.5 h-3.5 text-white"})}),a.jsxs("button",{onClick:xe,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(P*100),"%"]}),a.jsx("button",{onClick:R,disabled:P>=4,className:"p-1 hover:bg-white/10 rounded disabled:opacity-30",title:"Zoom in",children:a.jsx(DF,{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:De,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(uL,{printerId:t,isOpen:K,onClose:()=>fe(!1)})]})}function $Te({printerId:t,printerName:e,onClose:n}){const{t:r}=Dt(),i=Qt(),[s,o]=w.useState(!0),[l,c]=w.useState(new Set),[d,u]=w.useState(""),[h,f]=w.useState("all"),p=w.useRef(null),{data:x,isLoading:v,refetch:g}=Ze({queryKey:["mqtt-logs",t],queryFn:()=>J.getMQTTLogs(t),refetchInterval:1e3}),y=st({mutationFn:()=>J.enableMQTTLogging(t),onSuccess:()=>{i.invalidateQueries({queryKey:["mqtt-logs",t]})}}),_=st({mutationFn:()=>J.disableMQTTLogging(t),onSuccess:()=>{i.invalidateQueries({queryKey:["mqtt-logs",t]})}}),N=st({mutationFn:()=>J.clearMQTTLogs(t),onSuccess:()=>{i.invalidateQueries({queryKey:["mqtt-logs",t]})}});w.useEffect(()=>{const E=B=>{B.key==="Escape"&&n()};return window.addEventListener("keydown",E),()=>window.removeEventListener("keydown",E)},[n]),w.useEffect(()=>{s&&p.current&&(p.current.scrollTop=p.current.scrollHeight)},[x?.logs,s]);const A=E=>{c(B=>{const L=new Set(B);return L.has(E)?L.delete(E):L.add(E),L})},k=E=>new Date(E).toLocaleTimeString("en-US",{hour12:!1,fractionalSecondDigits:3}),P=(E,B)=>{if(E==null)return"<empty>";const L=typeof E=="string"?JSON.parse(E):E,U=JSON.stringify(L,null,B?2:0);return!B&&U.length>100?U.substring(0,100)+"...":U},C=x?.logging_enabled??!1,j=w.useMemo(()=>x?.logs??[],[x?.logs]),M=w.useMemo(()=>j.filter(E=>{if(h!=="all"&&E.direction!==h)return!1;if(d.trim()){const B=d.toLowerCase(),L=E.topic.toLowerCase().includes(B),D=JSON.stringify(E.payload).toLowerCase().includes(B);return L||D}return!0}),[j,d,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(Rt,{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:[C?a.jsxs(Me,{size:"sm",variant:"secondary",onClick:()=>_.mutate(),disabled:_.isPending,children:[a.jsx(Sl,{className:"w-4 h-4"}),r("mqttDebug.stopLogging")]}):a.jsxs(Me,{size:"sm",onClick:()=>y.mutate(),disabled:y.isPending,children:[a.jsx(oo,{className:"w-4 h-4"}),r("mqttDebug.startLogging")]}),a.jsxs(Me,{size:"sm",variant:"secondary",onClick:()=>N.mutate(),disabled:N.isPending||j.length===0,children:[a.jsx(Yt,{className:"w-4 h-4"}),r("mqttDebug.clearLog")]}),a.jsx(Me,{size:"sm",variant:"secondary",onClick:()=>g(),disabled:v,children:a.jsx(Sr,{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:E=>o(E.target.checked),className:"rounded border-bambu-dark-tertiary"}),"Auto-scroll"]}),a.jsxs("span",{className:"text-sm text-bambu-gray",children:[M.length,"/",j.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:d,onChange:E=>u(E.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"}),d&&a.jsx("button",{onClick:()=>u(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",children:a.jsx(Rt,{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(cb,{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(Mf,{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:j.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")}),!C&&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((E,B)=>{const L=l.has(B),U=E.direction==="in";return a.jsxs("div",{className:`p-2 rounded cursor-pointer hover:bg-bambu-dark-secondary transition-colors ${L?"bg-bambu-dark-secondary":""}`,onClick:()=>A(B),children:[a.jsxs("div",{className:"flex items-start gap-2",children:[a.jsx("span",{className:"text-bambu-gray shrink-0",children:k(E.timestamp)}),a.jsx("span",{className:`shrink-0 ${U?"text-blue-400":"text-green-400"}`,title:r(U?"mqttDebug.incoming":"mqttDebug.outgoing"),children:U?a.jsx(cb,{className:"w-3 h-3"}):a.jsx(Mf,{className:"w-3 h-3"})}),a.jsx("span",{className:"text-purple-400 shrink-0",children:E.topic})]}),L?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:P(E.payload,!0)}):a.jsx("pre",{className:"mt-1 text-white/80 truncate",children:P(E.payload,!1)})]},B)})})}),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:C?a.jsxs("span",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"}),r("mqttDebug.loggingActive")]}):a.jsx("span",{children:r("mqttDebug.loggingStopped")})}),a.jsx(Me,{variant:"secondary",onClick:n,children:r("common.close")})]})]})})}const bD={"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 VTe(t){switch(t){case 1:return{label:"Fatal",color:"text-red-500",bgColor:"bg-red-500/20",Icon:An};case 2:return{label:"Serious",color:"text-red-400",bgColor:"bg-red-500/15",Icon:An};case 3:return{label:"Warning",color:"text-orange-400",bgColor:"bg-orange-500/20",Icon:Va};default:return{label:"Info",color:"text-blue-400",bgColor:"bg-blue-500/20",Icon:eo}}}function xD(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 qTe(t){return t.filter(e=>{const n=parseInt(e.code.replace("0x",""),16)||0,r=xD(e.attr,n);return bD[r]!==void 0})}function GTe(){return"https://wiki.bambulab.com/en/hms/home"}function WTe({printerName:t,errors:e,onClose:n,printerId:r,hasPermission:i}){const{t:s}=Dt(),{showToast:o}=dn(),l=st({mutationFn:()=>J.clearHMSErrors(r),onSuccess:()=>{o(s("hmsErrors.clearSuccess"),"success"),n()},onError:()=>{o(s("hmsErrors.clearFailed"),"error")}}),c=e.filter(d=>{const u=parseInt(d.code.replace("0x",""),16)||0,h=xD(d.attr,u);return bD[h]!==void 0});return w.useEffect(()=>{const d=u=>{u.key==="Escape"&&n()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[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(An,{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(Rt,{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(Va,{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((d,u)=>{const{label:h,color:f,bgColor:p,Icon:x}=VTe(d.severity),v=parseInt(d.code.replace("0x",""),16)||0,g=xD(d.attr,v),y=bD[g],_=GTe(),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(ta,{className:"w-3 h-3"}),s("hmsErrors.viewOnWiki")]})]})]})},`${d.code}-${u}`)})})}),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(at,{className:"w-4 h-4 animate-spin"}):a.jsx(Yt,{className:"w-4 h-4"}),s("hmsErrors.clearErrors")]})]})]})})}function KTe({printerId:t,printerModel:e,printerState:n,plateCleared:r,loadedFilamentTypes:i,loadedFilaments:s}){const{t:o}=Dt(),l=Qt(),{showToast:c}=dn(),{hasPermission:d}=jr(),{data:u}=Ze({queryKey:["queue",t,"pending",e],queryFn:()=>J.getQueue(t,"pending",e||void 0),refetchInterval:3e4}),h=st({mutationFn:()=>J.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=u?.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(da,{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(ub,{className:"w-4 h-4"}),o("queue.plateReady")]}):a.jsxs("button",{onClick:()=>h.mutate(),disabled:h.isPending||!d("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(at,{className:"w-4 h-4 animate-spin"}):a.jsx(ub,{className:"w-4 h-4"}),o("queue.clearPlate")]})]}):a.jsx(Ys,{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(da,{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(qn,{className:"w-3 h-3"}),p?.scheduled_time?g0(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 oQ(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=oQ(t[e]))&&(r&&(r+=" "),r+=n)}else for(n in t)t[n]&&(r&&(r+=" "),r+=n);return r}function cr(){for(var t,e,n=0,r="",i=arguments.length;n<i;n++)(t=arguments[n])&&(e=oQ(t))&&(r&&(r+=" "),r+=e);return r}var XTe=["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 hL(t){if(typeof t!="string")return!1;var e=XTe;return e.includes(t)}var YTe=["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"],QTe=new Set(YTe);function lQ(t){return typeof t!="string"?!1:QTe.has(t)}function cQ(t){return typeof t=="string"&&t.startsWith("data-")}function Ls(t){if(typeof t!="object"||t===null)return{};var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(lQ(n)||cQ(n))&&(e[n]=t[n]);return e}function zf(t){if(t==null)return null;if(w.isValidElement(t)&&typeof t.props=="object"&&t.props!==null){var e=t.props;return Ls(e)}return typeof t=="object"&&!Array.isArray(t)?Ls(t):null}function rs(t){var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(lQ(n)||cQ(n)||hL(n))&&(e[n]=t[n]);return e}function ZTe(t){return t==null?null:w.isValidElement(t)?rs(t.props):typeof t=="object"&&!Array.isArray(t)?rs(t):null}var JTe=["children","width","height","viewBox","className","style","title","desc"];function yD(){return yD=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},yD.apply(null,arguments)}function eMe(t,e){if(t==null)return{};var n,r,i=tMe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function tMe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var mL=w.forwardRef((t,e)=>{var{children:n,width:r,height:i,viewBox:s,className:o,style:l,title:c,desc:d}=t,u=eMe(t,JTe),h=s||{width:r,height:i,x:0,y:0},f=cr("recharts-surface",o);return w.createElement("svg",yD({},rs(u),{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,d),n)}),nMe=["children","className"];function vD(){return vD=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},vD.apply(null,arguments)}function rMe(t,e){if(t==null)return{};var n,r,i=aMe(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 aMe(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 wa=w.forwardRef((t,e)=>{var{children:n,className:r}=t,i=rMe(t,nMe),s=cr("recharts-layer",r);return w.createElement("g",vD({className:s},rs(i),{ref:e}),n)}),dQ=w.createContext(null),iMe=()=>w.useContext(dQ);function ea(t){return function(){return t}}const uQ=Math.cos,z1=Math.sin,sc=Math.sqrt,U1=Math.PI,mk=2*U1,wD=Math.PI,SD=2*wD,Vm=1e-6,sMe=SD-Vm;function hQ(t){this._+=t[0];for(let e=1,n=t.length;e<n;++e)this._+=arguments[e]+t[e]}function oMe(t){let e=Math.floor(t);if(!(e>=0))throw new Error(`invalid digits: ${t}`);if(e>15)return hQ;const n=10**e;return function(r){this._+=r[0];for(let i=1,s=r.length;i<s;++i)this._+=Math.round(arguments[i]*n)/n+r[i]}}class lMe{constructor(e){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=e==null?hQ:oMe(e)}moveTo(e,n){this._append`M${this._x0=this._x1=+e},${this._y0=this._y1=+n}`}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._append`Z`)}lineTo(e,n){this._append`L${this._x1=+e},${this._y1=+n}`}quadraticCurveTo(e,n,r,i){this._append`Q${+e},${+n},${this._x1=+r},${this._y1=+i}`}bezierCurveTo(e,n,r,i,s,o){this._append`C${+e},${+n},${+r},${+i},${this._x1=+s},${this._y1=+o}`}arcTo(e,n,r,i,s){if(e=+e,n=+n,r=+r,i=+i,s=+s,s<0)throw new Error(`negative radius: ${s}`);let o=this._x1,l=this._y1,c=r-e,d=i-n,u=o-e,h=l-n,f=u*u+h*h;if(this._x1===null)this._append`M${this._x1=e},${this._y1=n}`;else if(f>Vm)if(!(Math.abs(h*c-d*u)>Vm)||!s)this._append`L${this._x1=e},${this._y1=n}`;else{let p=r-o,x=i-l,v=c*c+d*d,g=p*p+x*x,y=Math.sqrt(v),_=Math.sqrt(f),N=s*Math.tan((wD-Math.acos((v+f-g)/(2*y*_)))/2),A=N/_,k=N/y;Math.abs(A-1)>Vm&&this._append`L${e+A*u},${n+A*h}`,this._append`A${s},${s},0,0,${+(h*p>u*x)},${this._x1=e+k*c},${this._y1=n+k*d}`}}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),d=e+l,u=n+c,h=1^o,f=o?i-s:s-i;this._x1===null?this._append`M${d},${u}`:(Math.abs(this._x1-d)>Vm||Math.abs(this._y1-u)>Vm)&&this._append`L${d},${u}`,r&&(f<0&&(f=f%SD+SD),f>sMe?this._append`A${r},${r},0,1,${h},${e-l},${n-c}A${r},${r},0,1,${h},${this._x1=d},${this._y1=u}`:f>Vm&&this._append`A${r},${r},0,${+(f>=wD)},${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 fL(t){let e=3;return t.digits=function(n){if(!arguments.length)return e;if(n==null)e=null;else{const r=Math.floor(n);if(!(r>=0))throw new RangeError(`invalid digits: ${n}`);e=r}return t},()=>new lMe(e)}function pL(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function mQ(t){this._context=t}mQ.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 fk(t){return new mQ(t)}function fQ(t){return t[0]}function pQ(t){return t[1]}function gQ(t,e){var n=ea(!0),r=null,i=fk,s=null,o=fL(l);t=typeof t=="function"?t:t===void 0?fQ:ea(t),e=typeof e=="function"?e:e===void 0?pQ:ea(e);function l(c){var d,u=(c=pL(c)).length,h,f=!1,p;for(r==null&&(s=i(p=o())),d=0;d<=u;++d)!(d<u&&n(h=c[d],d,c))===f&&((f=!f)?s.lineStart():s.lineEnd()),f&&s.point(+t(h,d,c),+e(h,d,c));if(p)return s=null,p+""||null}return l.x=function(c){return arguments.length?(t=typeof c=="function"?c:ea(+c),l):t},l.y=function(c){return arguments.length?(e=typeof c=="function"?c:ea(+c),l):e},l.defined=function(c){return arguments.length?(n=typeof c=="function"?c:ea(!!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 r_(t,e,n){var r=null,i=ea(!0),s=null,o=fk,l=null,c=fL(d);t=typeof t=="function"?t:t===void 0?fQ:ea(+t),e=typeof e=="function"?e:ea(e===void 0?0:+e),n=typeof n=="function"?n:n===void 0?pQ:ea(+n);function d(h){var f,p,x,v=(h=pL(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 u(){return gQ().defined(i).curve(o).context(s)}return d.x=function(h){return arguments.length?(t=typeof h=="function"?h:ea(+h),r=null,d):t},d.x0=function(h){return arguments.length?(t=typeof h=="function"?h:ea(+h),d):t},d.x1=function(h){return arguments.length?(r=h==null?null:typeof h=="function"?h:ea(+h),d):r},d.y=function(h){return arguments.length?(e=typeof h=="function"?h:ea(+h),n=null,d):e},d.y0=function(h){return arguments.length?(e=typeof h=="function"?h:ea(+h),d):e},d.y1=function(h){return arguments.length?(n=h==null?null:typeof h=="function"?h:ea(+h),d):n},d.lineX0=d.lineY0=function(){return u().x(t).y(e)},d.lineY1=function(){return u().x(t).y(n)},d.lineX1=function(){return u().x(r).y(e)},d.defined=function(h){return arguments.length?(i=typeof h=="function"?h:ea(!!h),d):i},d.curve=function(h){return arguments.length?(o=h,s!=null&&(l=o(s)),d):o},d.context=function(h){return arguments.length?(h==null?s=l=null:l=o(s=h),d):s},d}class bQ{constructor(e,n){this._context=e,this._x=n}areaStart(){this._line=0}areaEnd(){this._line=NaN}lineStart(){this._point=0}lineEnd(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line}point(e,n){switch(e=+e,n=+n,this._point){case 0:{this._point=1,this._line?this._context.lineTo(e,n):this._context.moveTo(e,n);break}case 1:this._point=2;default:{this._x?this._context.bezierCurveTo(this._x0=(this._x0+e)/2,this._y0,this._x0,n,e,n):this._context.bezierCurveTo(this._x0,this._y0=(this._y0+n)/2,e,this._y0,e,n);break}}this._x0=e,this._y0=n}}function cMe(t){return new bQ(t,!0)}function dMe(t){return new bQ(t,!1)}const gL={draw(t,e){const n=sc(e/U1);t.moveTo(n,0),t.arc(0,0,n,0,mk)}},uMe={draw(t,e){const n=sc(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()}},xQ=sc(1/3),hMe=xQ*2,mMe={draw(t,e){const n=sc(e/hMe),r=n*xQ;t.moveTo(0,-n),t.lineTo(r,0),t.lineTo(0,n),t.lineTo(-r,0),t.closePath()}},fMe={draw(t,e){const n=sc(e),r=-n/2;t.rect(r,r,n,n)}},pMe=.8908130915292852,yQ=z1(U1/10)/z1(7*U1/10),gMe=z1(mk/10)*yQ,bMe=-uQ(mk/10)*yQ,xMe={draw(t,e){const n=sc(e*pMe),r=gMe*n,i=bMe*n;t.moveTo(0,-n),t.lineTo(r,i);for(let s=1;s<5;++s){const o=mk*s/5,l=uQ(o),c=z1(o);t.lineTo(c*n,-l*n),t.lineTo(l*r-c*i,c*r+l*i)}t.closePath()}},c2=sc(3),yMe={draw(t,e){const n=-sc(e/(c2*3));t.moveTo(0,n*2),t.lineTo(-c2*n,-n),t.lineTo(c2*n,-n),t.closePath()}},Qo=-.5,Zo=sc(3)/2,_D=1/sc(12),vMe=(_D/2+1)*3,wMe={draw(t,e){const n=sc(e/vMe),r=n/2,i=n*_D,s=r,o=n*_D+n,l=-s,c=o;t.moveTo(r,i),t.lineTo(s,o),t.lineTo(l,c),t.lineTo(Qo*r-Zo*i,Zo*r+Qo*i),t.lineTo(Qo*s-Zo*o,Zo*s+Qo*o),t.lineTo(Qo*l-Zo*c,Zo*l+Qo*c),t.lineTo(Qo*r+Zo*i,Qo*i-Zo*r),t.lineTo(Qo*s+Zo*o,Qo*o-Zo*s),t.lineTo(Qo*l+Zo*c,Qo*c-Zo*l),t.closePath()}};function SMe(t,e){let n=null,r=fL(i);t=typeof t=="function"?t:ea(t||gL),e=typeof e=="function"?e:ea(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:ea(s),i):t},i.size=function(s){return arguments.length?(e=typeof s=="function"?s:ea(+s),i):e},i.context=function(s){return arguments.length?(n=s??null,i):n},i}function B1(){}function H1(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 vQ(t){this._context=t}vQ.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:H1(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:H1(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function _Me(t){return new vQ(t)}function wQ(t){this._context=t}wQ.prototype={areaStart:B1,areaEnd:B1,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:H1(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function NMe(t){return new wQ(t)}function SQ(t){this._context=t}SQ.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:H1(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function CMe(t){return new SQ(t)}function _Q(t){this._context=t}_Q.prototype={areaStart:B1,areaEnd:B1,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 kMe(t){return new _Q(t)}function XH(t){return t<0?-1:1}function YH(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(XH(s)+XH(o))*Math.min(Math.abs(s),Math.abs(o),.5*Math.abs(l))||0}function QH(t,e){var n=t._x1-t._x0;return n?(3*(t._y1-t._y0)/n-e)/2:e}function d2(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 $1(t){this._context=t}$1.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:d2(this,this._t0,QH(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,d2(this,QH(this,n=YH(this,t,e)),n);break;default:d2(this,this._t0,n=YH(this,t,e));break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e,this._t0=n}}};function NQ(t){this._context=new CQ(t)}(NQ.prototype=Object.create($1.prototype)).point=function(t,e){$1.prototype.point.call(this,e,t)};function CQ(t){this._context=t}CQ.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 AMe(t){return new $1(t)}function TMe(t){return new NQ(t)}function kQ(t){this._context=t}kQ.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=ZH(t),i=ZH(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 ZH(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 MMe(t){return new kQ(t)}function pk(t,e){this._context=t,this._t=e}pk.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 PMe(t){return new pk(t,.5)}function EMe(t){return new pk(t,0)}function jMe(t){return new pk(t,1)}function Uf(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 ND(t){for(var e=t.length,n=new Array(e);--e>=0;)n[e]=e;return n}function DMe(t,e){return t[e]}function RMe(t){const e=[];return e.key=t,e}function FMe(){var t=ea([]),e=ND,n=Uf,r=DMe;function i(s){var o=Array.from(t.apply(this,arguments),RMe),l,c=o.length,d=-1,u;for(const h of s)for(l=0,++d;l<c;++l)(o[l][d]=[0,+r(h,o[l].key,d,s)]).data=h;for(l=0,u=pL(e(o));l<c;++l)o[u[l]].index=l;return n(o,u),o}return i.keys=function(s){return arguments.length?(t=typeof s=="function"?s:ea(Array.from(s)),i):t},i.value=function(s){return arguments.length?(r=typeof s=="function"?s:ea(+s),i):r},i.order=function(s){return arguments.length?(e=s==null?ND:typeof s=="function"?s:ea(Array.from(s)),i):e},i.offset=function(s){return arguments.length?(n=s??Uf,i):n},i}function LMe(t,e){if((r=t.length)>0){for(var n,r,i=0,s=t[0].length,o;i<s;++i){for(o=n=0;n<r;++n)o+=t[n][i][1]||0;if(o)for(n=0;n<r;++n)t[n][i][1]/=o}Uf(t,e)}}function OMe(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}Uf(t,e)}}function IMe(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,d=0;l<o;++l){for(var u=t[e[l]],h=u[r][1]||0,f=u[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,d+=p*h}i[r-1][1]+=i[r-1][0]=n,c&&(n-=d/c)}i[r-1][1]+=i[r-1][0]=n,Uf(t,e)}}var u2={},h2={},JH;function zMe(){return JH||(JH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n==="__proto__"}t.isUnsafeProperty=e})(h2)),h2}var m2={},e$;function AQ(){return e$||(e$=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})(m2)),m2}var f2={},t$;function bL(){return t$||(t$=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})(f2)),f2}var p2={},g2={},n$;function UMe(){return n$||(n$=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})(g2)),g2}var r$;function xL(){return r$||(r$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=UMe(),n=bL();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="",d="",u=!1;for(i.charCodeAt(0)===46&&(s.push(""),l++);l<o;){const h=i[l];d?h==="\\"&&l+1<o?(l++,c+=i[l]):h===d?d="":c+=h:u?h==='"'||h==="'"?d=h:h==="]"?(u=!1,s.push(c),c=""):c+=h:h==="["?(u=!0,c&&(s.push(c),c="")):h==="."?c&&(s.push(c),c=""):c+=h,l++}return c&&s.push(c),s}t.toPath=r})(p2)),p2}var a$;function yL(){return a$||(a$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=zMe(),n=AQ(),r=bL(),i=xL();function s(l,c,d){if(l==null)return d;switch(typeof c){case"string":{if(e.isUnsafeProperty(c))return d;const u=l[c];return u===void 0?n.isDeepKey(c)?s(l,i.toPath(c),d):d:u}case"number":case"symbol":{typeof c=="number"&&(c=r.toKey(c));const u=l[c];return u===void 0?d:u}default:{if(Array.isArray(c))return o(l,c,d);if(Object.is(c?.valueOf(),-0)?c="-0":c=String(c),e.isUnsafeProperty(c))return d;const u=l[c];return u===void 0?d:u}}}function o(l,c,d){if(c.length===0)return d;let u=l;for(let h=0;h<c.length;h++){if(u==null||e.isUnsafeProperty(c[h]))return d;u=u[c[h]]}return u===void 0?d:u}t.get=s})(u2)),u2}var b2,i$;function BMe(){return i$||(i$=1,b2=yL().get),b2}var HMe=BMe();const Bf=rc(HMe);var $Me=4;function Nh(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:$Me,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+Nh(l)+s:i+s},"")}var Ri=t=>t===0?0:t>0?1:-1,ec=t=>typeof t=="number"&&t!=+t,Hf=t=>typeof t=="string"&&t.indexOf("%")===t.length-1,$t=t=>(typeof t=="number"||t instanceof Number)&&!ec(t),Cl=t=>$t(t)||typeof t=="string",VMe=0,T0=t=>{var e=++VMe;return"".concat(t||"").concat(e)},ys=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(!$t(e)&&typeof e!="string")return r;var s;if(Hf(e)){if(n==null)return r;var o=e.indexOf("%");s=n*parseFloat(e.slice(0,o))/100}else s=+e;return ec(s)&&(s=r),i&&n!=null&&s>n&&(s=n),s},TQ=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 wr(t,e,n){return $t(t)&&$t(e)?Nh(t+n*(e-t)):e}function MQ(t,e,n){if(!(!t||!t.length))return t.find(r=>r&&(typeof e=="function"?e(r):Bf(r,e))===n)}var ba=t=>t===null||typeof t>"u",gv=t=>ba(t)?t:"".concat(t.charAt(0).toUpperCase()).concat(t.slice(1));function to(t){return t!=null}function nm(){}var qMe=["type","size","sizeType"];function CD(){return CD=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},CD.apply(null,arguments)}function s$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function o$(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?s$(Object(n),!0).forEach(function(r){GMe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):s$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function GMe(t,e,n){return(e=WMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function WMe(t){var e=KMe(t,"string");return typeof e=="symbol"?e:e+""}function KMe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function XMe(t,e){if(t==null)return{};var n,r,i=YMe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function YMe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var PQ={symbolCircle:gL,symbolCross:uMe,symbolDiamond:mMe,symbolSquare:fMe,symbolStar:xMe,symbolTriangle:yMe,symbolWye:wMe},QMe=Math.PI/180,ZMe=t=>{var e="symbol".concat(gv(t));return PQ[e]||gL},JMe=(t,e,n)=>{if(e==="area")return t;switch(n){case"cross":return 5*t*t/9;case"diamond":return .5*t*t/Math.sqrt(3);case"square":return t*t;case"star":{var r=18*QMe;return 1.25*t*t*(Math.tan(r)-Math.tan(r*2)*Math.tan(r)**2)}case"triangle":return Math.sqrt(3)*t*t/4;case"wye":return(21-10*Math.sqrt(3))*t*t/8;default:return Math.PI*t*t/4}},ePe=(t,e)=>{PQ["symbol".concat(gv(t))]=e},vL=t=>{var{type:e="circle",size:n=64,sizeType:r="area"}=t,i=XMe(t,qMe),s=o$(o$({},i),{},{type:e,size:n,sizeType:r}),o="circle";typeof e=="string"&&(o=e);var l=()=>{var f=ZMe(o),p=SMe().type(f).size(JMe(n,r,o)),x=p();if(x!==null)return x},{className:c,cx:d,cy:u}=s,h=rs(s);return $t(d)&&$t(u)&&$t(n)?w.createElement("path",CD({},h,{className:cr("recharts-symbols",c),transform:"translate(".concat(d,", ").concat(u,")"),d:l()})):null};vL.registerSymbol=ePe;var EQ=t=>"radius"in t&&"startAngle"in t&&"endAngle"in t,wL=(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=>{hL(i)&&(r[i]=(s=>n[i](n,s)))}),r},tPe=(t,e,n)=>r=>(t(e,n,r),null),bv=(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];hL(i)&&typeof s=="function"&&(r||(r={}),r[i]=tPe(s,e,n))}),r};function l$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function nPe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?l$(Object(n),!0).forEach(function(r){rPe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):l$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function rPe(t,e,n){return(e=aPe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function aPe(t){var e=iPe(t,"string");return typeof e=="symbol"?e:e+""}function iPe(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 Sa(t,e){var n=nPe({},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 V1(){return V1=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},V1.apply(null,arguments)}function c$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function sPe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?c$(Object(n),!0).forEach(function(r){oPe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):c$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function oPe(t,e,n){return(e=lPe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function lPe(t){var e=cPe(t,"string");return typeof e=="symbol"?e:e+""}function cPe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var tl=32,dPe={align:"center",iconSize:14,inactiveColor:"#ccc",layout:"horizontal",verticalAlign:"middle"};function uPe(t){var{data:e,iconType:n,inactiveColor:r}=t,i=tl/2,s=tl/6,o=tl/3,l=e.inactive?r:e.color,c=n??e.type;if(c==="none")return null;if(c==="plainline"){var d;return w.createElement("line",{strokeWidth:4,fill:"none",stroke:l,strokeDasharray:(d=e.payload)===null||d===void 0?void 0:d.strokeDasharray,x1:0,y1:i,x2:tl,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,`
- A`).concat(s,",").concat(s,",0,1,1,").concat(2*o,",").concat(i,`
- H`).concat(tl,"M").concat(2*o,",").concat(i,`
- A`).concat(s,",").concat(s,",0,1,1,").concat(o,",").concat(i),className:"recharts-legend-icon"});if(c==="rect")return w.createElement("path",{stroke:"none",fill:l,d:"M0,".concat(tl/8,"h").concat(tl,"v").concat(tl*3/4,"h").concat(-tl,"z"),className:"recharts-legend-icon"});if(w.isValidElement(e.legendIcon)){var u=sPe({},e);return delete u.legendIcon,w.cloneElement(e.legendIcon,u)}return w.createElement(vL,{fill:l,cx:i,cy:i,size:tl,sizeType:"diameter",type:c})}function hPe(t){var{payload:e,iconSize:n,layout:r,formatter:i,inactiveColor:s,iconType:o}=t,l={x:0,y:0,width:tl,height:tl},c={display:r==="horizontal"?"inline-block":"block",marginRight:10},d={display:"inline-block",verticalAlign:"middle",marginRight:4};return e.map((u,h)=>{var f=u.formatter||i,p=cr({"recharts-legend-item":!0,["legend-item-".concat(h)]:!0,inactive:u.inactive});if(u.type==="none")return null;var x=u.inactive?s:u.color,v=f?f(u.value,u,h):u.value;return w.createElement("li",V1({className:p,style:c,key:"legend-item-".concat(h)},bv(t,u,h)),w.createElement(mL,{width:n,height:n,viewBox:l,style:d,"aria-label":"".concat(v," legend icon")},w.createElement(uPe,{data:u,iconType:o,inactiveColor:s})),w.createElement("span",{className:"recharts-legend-item-text",style:{color:x}},v))})}var mPe=t=>{var e=Sa(t,dPe),{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(hPe,V1({},e,{payload:n})))},x2={},y2={},d$;function fPe(){return d$||(d$=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})(y2)),y2}var v2={},u$;function pPe(){return u$||(u$=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})(v2)),v2}var w2={},h$;function jQ(){return h$||(h$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n}t.identity=e})(w2)),w2}var S2={},_2={},N2={},m$;function gPe(){return m$||(m$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Number.isSafeInteger(n)&&n>=0}t.isLength=e})(N2)),N2}var f$;function SL(){return f$||(f$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=gPe();function n(r){return r!=null&&typeof r!="function"&&e.isLength(r.length)}t.isArrayLike=n})(_2)),_2}var C2={},p$;function bPe(){return p$||(p$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return typeof n=="object"&&n!==null}t.isObjectLike=e})(C2)),C2}var g$;function xPe(){return g$||(g$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=SL(),n=bPe();function r(i){return n.isObjectLike(i)&&e.isArrayLike(i)}t.isArrayLikeObject=r})(S2)),S2}var k2={},A2={},b$;function yPe(){return b$||(b$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=yL();function n(r){return function(i){return e.get(i,r)}}t.property=n})(A2)),A2}var T2={},M2={},P2={},E2={},x$;function DQ(){return x$||(x$=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})(E2)),E2}var j2={},y$;function RQ(){return y$||(y$=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})(j2)),j2}var D2={},v$;function FQ(){return v$||(v$=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})(D2)),D2}var w$;function vPe(){return w$||(w$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=DQ(),n=RQ(),r=FQ();function i(u,h,f){return typeof f!="function"?i(u,h,()=>{}):s(u,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(u,h,f,p){if(h===u)return!0;switch(typeof h){case"object":return o(u,h,f,p);case"function":return Object.keys(h).length>0?s(u,{...h},f,p):r.isEqualsSameValueZero(u,h);default:return e.isObject(u)?typeof h=="string"?h==="":!0:r.isEqualsSameValueZero(u,h)}}function o(u,h,f,p){if(h==null)return!0;if(Array.isArray(h))return c(u,h,f,p);if(h instanceof Map)return l(u,h,f,p);if(h instanceof Set)return d(u,h,f,p);const x=Object.keys(h);if(u==null||n.isPrimitive(u))return x.length===0;if(x.length===0)return!0;if(p?.has(h))return p.get(h)===u;p?.set(h,u);try{for(let v=0;v<x.length;v++){const g=x[v];if(!n.isPrimitive(u)&&!(g in u)||h[g]===void 0&&u[g]!==void 0||h[g]===null&&u[g]!==null||!f(u[g],h[g],g,u,h,p))return!1}return!0}finally{p?.delete(h)}}function l(u,h,f,p){if(h.size===0)return!0;if(!(u instanceof Map))return!1;for(const[x,v]of h.entries()){const g=u.get(x);if(f(g,v,x,u,h,p)===!1)return!1}return!0}function c(u,h,f,p){if(h.length===0)return!0;if(!Array.isArray(u))return!1;const x=new Set;for(let v=0;v<h.length;v++){const g=h[v];let y=!1;for(let _=0;_<u.length;_++){if(x.has(_))continue;const N=u[_];let A=!1;if(f(N,g,v,u,h,p)&&(A=!0),A){x.add(_),y=!0;break}}if(!y)return!1}return!0}function d(u,h,f,p){return h.size===0?!0:u instanceof Set?c([...u],[...h],f,p):!1}t.isMatchWith=i,t.isSetMatch=d})(P2)),P2}var S$;function LQ(){return S$||(S$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=vPe();function n(r,i){return e.isMatchWith(r,i,()=>{})}t.isMatch=n})(M2)),M2}var R2={},F2={},L2={},_$;function wPe(){return _$||(_$=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})(L2)),L2}var O2={},N$;function _L(){return N$||(N$=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})(O2)),O2}var I2={},C$;function OQ(){return C$||(C$=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]",d="[object Set]",u="[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]",k="[object Int8Array]",P="[object Int16Array]",C="[object Int32Array]",j="[object BigInt64Array]",M="[object Float32Array]",E="[object Float64Array]";t.argumentsTag=s,t.arrayBufferTag=f,t.arrayTag=u,t.bigInt64ArrayTag=j,t.bigUint64ArrayTag=A,t.booleanTag=i,t.dataViewTag=v,t.dateTag=l,t.errorTag=x,t.float32ArrayTag=M,t.float64ArrayTag=E,t.functionTag=h,t.int16ArrayTag=P,t.int32ArrayTag=C,t.int8ArrayTag=k,t.mapTag=c,t.numberTag=r,t.objectTag=p,t.regexpTag=e,t.setTag=d,t.stringTag=n,t.symbolTag=o,t.uint16ArrayTag=_,t.uint32ArrayTag=N,t.uint8ArrayTag=g,t.uint8ClampedArrayTag=y})(I2)),I2}var z2={},k$;function SPe(){return k$||(k$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}t.isTypedArray=e})(z2)),z2}var A$;function IQ(){return A$||(A$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=wPe(),n=_L(),r=OQ(),i=RQ(),s=SPe();function o(u,h){return l(u,void 0,u,new Map,h)}function l(u,h,f,p=new Map,x=void 0){const v=x?.(u,h,f,p);if(v!==void 0)return v;if(i.isPrimitive(u))return u;if(p.has(u))return p.get(u);if(Array.isArray(u)){const g=new Array(u.length);p.set(u,g);for(let y=0;y<u.length;y++)g[y]=l(u[y],y,f,p,x);return Object.hasOwn(u,"index")&&(g.index=u.index),Object.hasOwn(u,"input")&&(g.input=u.input),g}if(u instanceof Date)return new Date(u.getTime());if(u instanceof RegExp){const g=new RegExp(u.source,u.flags);return g.lastIndex=u.lastIndex,g}if(u instanceof Map){const g=new Map;p.set(u,g);for(const[y,_]of u)g.set(y,l(_,y,f,p,x));return g}if(u instanceof Set){const g=new Set;p.set(u,g);for(const y of u)g.add(l(y,void 0,f,p,x));return g}if(typeof Buffer<"u"&&Buffer.isBuffer(u))return u.subarray();if(s.isTypedArray(u)){const g=new(Object.getPrototypeOf(u)).constructor(u.length);p.set(u,g);for(let y=0;y<u.length;y++)g[y]=l(u[y],y,f,p,x);return g}if(u instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&u instanceof SharedArrayBuffer)return u.slice(0);if(u instanceof DataView){const g=new DataView(u.buffer.slice(0),u.byteOffset,u.byteLength);return p.set(u,g),c(g,u,f,p,x),g}if(typeof File<"u"&&u instanceof File){const g=new File([u],u.name,{type:u.type});return p.set(u,g),c(g,u,f,p,x),g}if(typeof Blob<"u"&&u instanceof Blob){const g=new Blob([u],{type:u.type});return p.set(u,g),c(g,u,f,p,x),g}if(u instanceof Error){const g=new u.constructor;return p.set(u,g),g.message=u.message,g.name=u.name,g.stack=u.stack,g.cause=u.cause,c(g,u,f,p,x),g}if(u instanceof Boolean){const g=new Boolean(u.valueOf());return p.set(u,g),c(g,u,f,p,x),g}if(u instanceof Number){const g=new Number(u.valueOf());return p.set(u,g),c(g,u,f,p,x),g}if(u instanceof String){const g=new String(u.valueOf());return p.set(u,g),c(g,u,f,p,x),g}if(typeof u=="object"&&d(u)){const g=Object.create(Object.getPrototypeOf(u));return p.set(u,g),c(g,u,f,p,x),g}return u}function c(u,h,f=u,p,x){const v=[...Object.keys(h),...e.getSymbols(h)];for(let g=0;g<v.length;g++){const y=v[g],_=Object.getOwnPropertyDescriptor(u,y);(_==null||_.writable)&&(u[y]=l(h[y],y,f,p,x))}}function d(u){switch(n.getTag(u)){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})(F2)),F2}var T$;function _Pe(){return T$||(T$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=IQ();function n(r){return e.cloneDeepWithImpl(r,void 0,r,new Map,void 0)}t.cloneDeep=n})(R2)),R2}var M$;function NPe(){return M$||(M$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=LQ(),n=_Pe();function r(i){return i=n.cloneDeep(i),s=>e.isMatch(s,i)}t.matches=r})(T2)),T2}var U2={},B2={},H2={},P$;function CPe(){return P$||(P$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=IQ(),n=_L(),r=OQ();function i(s,o){return e.cloneDeepWith(s,(l,c,d,u)=>{const h=o?.(l,c,d,u);if(h!==void 0)return h;if(typeof s=="object"){if(n.getTag(s)===r.objectTag&&typeof s.constructor!="function"){const f={};return u.set(s,f),e.copyProperties(f,s,d,u),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})(H2)),H2}var E$;function kPe(){return E$||(E$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=CPe();function n(r){return e.cloneDeepWith(r)}t.cloneDeep=n})(B2)),B2}var $2={},V2={},j$;function zQ(){return j$||(j$=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})(V2)),V2}var q2={},D$;function APe(){return D$||(D$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=_L();function n(r){return r!==null&&typeof r=="object"&&e.getTag(r)==="[object Arguments]"}t.isArguments=n})(q2)),q2}var R$;function TPe(){return R$||(R$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=AQ(),n=zQ(),r=APe(),i=xL();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 d=o;for(let u=0;u<c.length;u++){const h=c[u];if((d==null||!Object.hasOwn(d,h))&&!((Array.isArray(d)||r.isArguments(d))&&n.isIndex(h)&&h<d.length))return!1;d=d[h]}return!0}t.has=s})($2)),$2}var F$;function MPe(){return F$||(F$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=LQ(),n=bL(),r=kPe(),i=yL(),s=TPe();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(d){const u=i.get(d,l);return u===void 0?s.has(d,l):c===void 0?u===void 0:e.isMatch(u,c)}}t.matchesProperty=o})(U2)),U2}var L$;function PPe(){return L$||(L$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=jQ(),n=yPe(),r=NPe(),i=MPe();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})(k2)),k2}var O$;function EPe(){return O$||(O$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=fPe(),n=pPe(),r=jQ(),i=xPe(),s=PPe();function o(l,c=r.identity){return i.isArrayLikeObject(l)?e.uniqBy(Array.from(l),n.ary(s.iteratee(c),1)):[]}t.uniqBy=o})(x2)),x2}var G2,I$;function jPe(){return I$||(I$=1,G2=EPe().uniqBy),G2}var DPe=jPe();const z$=rc(DPe);function UQ(t,e,n){return e===!0?z$(t,n):typeof e=="function"?z$(t,e):t}var W2={exports:{}},K2={};var U$;function RPe(){if(U$)return K2;U$=1;var t=zb(),e=PK();function n(d,u){return d===u&&(d!==0||1/d===1/u)||d!==d&&u!==u}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 K2.useSyncExternalStoreWithSelector=function(d,u,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(P){if(!_){if(_=!0,N=P,P=f(P),p!==void 0&&v.hasValue){var C=v.value;if(p(C,P))return A=C}return A=P}if(C=A,r(N,P))return C;var j=f(P);return p!==void 0&&p(C,j)?(N=P,C):(N=P,A=j)}var _=!1,N,A,k=h===void 0?null:h;return[function(){return y(u())},k===null?void 0:function(){return y(k())}]},[u,h,f,p]);var g=i(d,x[0],x[1]);return o(function(){v.hasValue=!0,v.value=g},[g]),c(g),g},K2}var B$;function FPe(){return B$||(B$=1,W2.exports=RPe()),W2.exports}var BQ=FPe(),NL=w.createContext(null),LPe=t=>t,Yr=()=>{var t=w.useContext(NL);return t?t.store.dispatch:LPe},Q_=()=>{},OPe=()=>Q_,IPe=(t,e)=>t===e;function Gt(t){var e=w.useContext(NL),n=w.useMemo(()=>e?r=>{if(r!=null)return t(r)}:Q_,[e,t]);return BQ.useSyncExternalStoreWithSelector(e?e.subscription.addNestedSub:OPe,e?e.store.getState:Q_,e?e.store.getState:Q_,n,IPe)}function zPe(t,e=`expected a function, instead received ${typeof t}`){if(typeof t!="function")throw new TypeError(e)}function UPe(t,e=`expected an object, instead received ${typeof t}`){if(typeof t!="object")throw new TypeError(e)}function BPe(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 H$=t=>Array.isArray(t)?t:[t];function HPe(t){const e=Array.isArray(t[0])?t[0]:t;return BPe(e,"createSelector expects all input-selectors to be functions, but received the following types: "),e}function $Pe(t,e){const n=[],{length:r}=t;for(let i=0;i<r;i++)n.push(t[i].apply(null,e));return n}var VPe=class{constructor(t){this.value=t}deref(){return this.value}},qPe=typeof WeakRef<"u"?WeakRef:VPe,GPe=0,$$=1;function a_(){return{s:GPe,v:void 0,o:null,p:null}}function HQ(t,e={}){let n=a_();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=a_(),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=a_(),x.set(p,l)):l=v}}const d=l;let u;if(l.s===$$)u=l.v;else if(u=t.apply(null,arguments),s++,r){const h=i?.deref?.()??i;h!=null&&r(h,u)&&(u=h,s!==0&&s--),i=typeof u=="object"&&u!==null||typeof u=="function"?new qPe(u):u}return d.s=$$,d.v=u,u}return o.clearCache=()=>{n=a_(),o.resetResultsCount()},o.resultsCount=()=>s,o.resetResultsCount=()=>{s=0},o}function WPe(t,...e){const n=typeof t=="function"?{memoize:t,memoizeOptions:e}:t,r=(...i)=>{let s=0,o=0,l,c={},d=i.pop();typeof d=="object"&&(c=d,d=i.pop()),zPe(d,`createSelector expects an output function after the inputs, but received: [${typeof d}]`);const u={...n,...c},{memoize:h,memoizeOptions:f=[],argsMemoize:p=HQ,argsMemoizeOptions:x=[]}=u,v=H$(f),g=H$(x),y=HPe(i),_=h(function(){return s++,d.apply(null,arguments)},...v),N=p(function(){o++;const k=$Pe(y,arguments);return l=_.apply(null,k),l},...g);return Object.assign(N,{resultFunc:d,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 dt=WPe(HQ),KPe=Object.assign((t,e=dt)=>{UPe(t,`createStructuredSelector expects first argument to be an object where each property is a selector, instead received a ${typeof t}`);const n=Object.keys(t),r=n.map(s=>t[s]);return e(r,(...s)=>s.reduce((o,l,c)=>(o[n[c]]=l,o),{}))},{withTypes:()=>KPe}),X2={},Y2={},Q2={},V$;function XPe(){return V$||(V$=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})(Q2)),Q2}var Z2={},J2={},q$;function $Q(){return q$||(q$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return typeof n=="symbol"||n instanceof Symbol}t.isSymbol=e})(J2)),J2}var G$;function YPe(){return G$||(G$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=$Q(),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})(Z2)),Z2}var W$;function QPe(){return W$||(W$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=XPe(),n=YPe(),r=xL();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 d=(p,x)=>{let v=p;for(let g=0;g<x.length&&v!=null;++g)v=v[x[g]];return v},u=(p,x)=>x==null||p==null?x:typeof p=="object"&&"key"in p?Object.hasOwn(x,p.key)?x[p.key]:d(x,p.path):typeof p=="function"?p(x):Array.isArray(p)?d(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=>u(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})(Y2)),Y2}var eE={},K$;function ZPe(){return K$||(K$=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 d=0;d<l.length;d++){const u=l[d];Array.isArray(u)&&c<s?o(u,c+1):i.push(u)}};return o(n,0),i}t.flatten=e})(eE)),eE}var tE={},X$;function VQ(){return X$||(X$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=zQ(),n=SL(),r=DQ(),i=FQ();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})(tE)),tE}var Y$;function JPe(){return Y$||(Y$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=QPe(),n=ZPe(),r=VQ();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})(X2)),X2}var nE,Q$;function e2e(){return Q$||(Q$=1,nE=JPe().sortBy),nE}var t2e=e2e();const gk=rc(t2e);var qQ=t=>t.legend.settings,n2e=t=>t.legend.size,r2e=t=>t.legend.payload,a2e=dt([r2e,qQ],(t,e)=>{var{itemSorter:n}=e,r=t.flat(1);return n?gk(r,n):r});function i2e(){return Gt(a2e)}var i_=1;function GQ(){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)>i_||Math.abs(o.left-e.left)>i_||Math.abs(o.top-e.top)>i_||Math.abs(o.width-e.width)>i_)&&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 s2e=typeof Symbol=="function"&&Symbol.observable||"@@observable",Z$=s2e,rE=()=>Math.random().toString(36).substring(7).split("").join("."),o2e={INIT:`@@redux/INIT${rE()}`,REPLACE:`@@redux/REPLACE${rE()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${rE()}`},q1=o2e;function CL(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 WQ(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(WQ)(t,e)}let r=t,i=e,s=new Map,o=s,l=0,c=!1;function d(){o===s&&(o=new Map,s.forEach((g,y)=>{o.set(y,g)}))}function u(){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;d();const _=l++;return o.set(_,g),function(){if(y){if(c)throw new Error(Ki(6));y=!1,d(),o.delete(_),s=null}}}function f(g){if(!CL(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:q1.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(u())}return _(),{unsubscribe:g(_)}},[Z$](){return this}}}return f({type:q1.INIT}),{dispatch:f,subscribe:h,getState:u,replaceReducer:p,[Z$]:x}}function l2e(t){Object.keys(t).forEach(e=>{const n=t[e];if(typeof n(void 0,{type:q1.INIT})>"u")throw new Error(Ki(12));if(typeof n(void 0,{type:q1.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(Ki(13))})}function KQ(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{l2e(n)}catch(s){i=s}return function(o={},l){if(i)throw i;let c=!1;const d={};for(let u=0;u<r.length;u++){const h=r[u],f=n[h],p=o[h],x=f(p,l);if(typeof x>"u")throw l&&l.type,new Error(Ki(14));d[h]=x,c=c||x!==p}return c=c||r.length!==Object.keys(o).length,c?d:o}}function G1(...t){return t.length===0?e=>e:t.length===1?t[0]:t.reduce((e,n)=>(...r)=>e(n(...r)))}function c2e(...t){return e=>(n,r)=>{const i=e(n,r);let s=()=>{throw new Error(Ki(15))};const o={getState:i.getState,dispatch:(c,...d)=>s(c,...d)},l=t.map(c=>c(o));return s=G1(...l)(i.dispatch),{...i,dispatch:s}}}function XQ(t){return CL(t)&&"type"in t&&typeof t.type=="string"}var YQ=Symbol.for("immer-nothing"),J$=Symbol.for("immer-draftable"),Os=Symbol.for("immer-state");function Hl(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var Po=Object,_b=Po.getPrototypeOf,W1="constructor",bk="prototype",kD="configurable",K1="enumerable",Z_="writable",M0="value",ou=t=>!!t&&!!t[Os];function tc(t){return t?QQ(t)||yk(t)||!!t[J$]||!!t[W1]?.[J$]||vk(t)||wk(t):!1}var d2e=Po[bk][W1].toString(),eV=new WeakMap;function QQ(t){if(!t||!kL(t))return!1;const e=_b(t);if(e===null||e===Po[bk])return!0;const n=Po.hasOwnProperty.call(e,W1)&&e[W1];if(n===Object)return!0;if(!Dg(n))return!1;let r=eV.get(n);return r===void 0&&(r=Function.toString.call(n),eV.set(n,r)),r===d2e}function xk(t,e,n=!0){xv(t)===0?(n?Reflect.ownKeys(t):Po.keys(t)).forEach(i=>{e(i,t[i],t)}):t.forEach((r,i)=>e(i,r,t))}function xv(t){const e=t[Os];return e?e.type_:yk(t)?1:vk(t)?2:wk(t)?3:0}var tV=(t,e,n=xv(t))=>n===2?t.has(e):Po[bk].hasOwnProperty.call(t,e),AD=(t,e,n=xv(t))=>n===2?t.get(e):t[e],X1=(t,e,n,r=xv(t))=>{r===2?t.set(e,n):r===3?t.add(n):t[e]=n};function u2e(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}var yk=Array.isArray,vk=t=>t instanceof Map,wk=t=>t instanceof Set,kL=t=>typeof t=="object",Dg=t=>typeof t=="function",aE=t=>typeof t=="boolean";function h2e(t){const e=+t;return Number.isInteger(e)&&String(e)===t}var Dd=t=>t.copy_||t.base_,AL=t=>t.modified_?t.copy_:t.base_;function TD(t,e){if(vk(t))return new Map(t);if(wk(t))return new Set(t);if(yk(t))return Array[bk].slice.call(t);const n=QQ(t);if(e===!0||e==="class_only"&&!n){const r=Po.getOwnPropertyDescriptors(t);delete r[Os];let i=Reflect.ownKeys(r);for(let s=0;s<i.length;s++){const o=i[s],l=r[o];l[Z_]===!1&&(l[Z_]=!0,l[kD]=!0),(l.get||l.set)&&(r[o]={[kD]:!0,[Z_]:!0,[K1]:l[K1],[M0]:t[o]})}return Po.create(_b(t),r)}else{const r=_b(t);if(r!==null&&n)return{...t};const i=Po.create(r);return Po.assign(i,t)}}function TL(t,e=!1){return Sk(t)||ou(t)||!tc(t)||(xv(t)>1&&Po.defineProperties(t,{set:s_,add:s_,clear:s_,delete:s_}),Po.freeze(t),e&&xk(t,(n,r)=>{TL(r,!0)},!1)),t}function m2e(){Hl(2)}var s_={[M0]:m2e};function Sk(t){return t===null||!kL(t)?!0:Po.isFrozen(t)}var Y1="MapSet",MD="Patches",nV="ArrayMethods",ZQ={};function $f(t){const e=ZQ[t];return e||Hl(0,t),e}var rV=t=>!!ZQ[t],P0,JQ=()=>P0,f2e=(t,e)=>({drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:rV(Y1)?$f(Y1):void 0,arrayMethodsPlugin_:rV(nV)?$f(nV):void 0});function aV(t,e){e&&(t.patchPlugin_=$f(MD),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function PD(t){ED(t),t.drafts_.forEach(p2e),t.drafts_=null}function ED(t){t===P0&&(P0=t.parent_)}var iV=t=>P0=f2e(P0,t);function p2e(t){const e=t[Os];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function sV(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];if(t!==void 0&&t!==n){n[Os].modified_&&(PD(e),Hl(4)),tc(t)&&(t=oV(e,t));const{patchPlugin_:i}=e;i&&i.generateReplacementPatches_(n[Os].base_,t,e)}else t=oV(e,n);return g2e(e,t,!0),PD(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==YQ?t:void 0}function oV(t,e){if(Sk(e))return e;const n=e[Os];if(!n)return Q1(e,t.handledSet_,t);if(!_k(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);nZ(n,t)}return n.copy_}function g2e(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&TL(e,n)}function eZ(t){t.finalized_=!0,t.scope_.unfinalizedDrafts_--}var _k=(t,e)=>t.scope_===e,b2e=[];function tZ(t,e,n,r){const i=Dd(t),s=t.type_;if(r!==void 0&&AD(i,r,s)===e){X1(i,r,n,s);return}if(!t.draftLocations_){const l=t.draftLocations_=new Map;xk(i,(c,d)=>{if(ou(d)){const u=l.get(d)||[];u.push(c),l.set(d,u)}})}const o=t.draftLocations_.get(e)??b2e;for(const l of o)X1(i,l,n,s)}function x2e(t,e,n){t.callbacks_.push(function(i){const s=e;if(!s||!_k(s,i))return;i.mapSetPlugin_?.fixSetContents(s);const o=AL(s);tZ(t,s.draft_??s,o,n),nZ(s,i)})}function nZ(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)}eZ(t)}}function y2e(t,e,n){const{scope_:r}=t;if(ou(n)){const i=n[Os];_k(i,r)&&i.callbacks_.push(function(){J_(t);const o=AL(i);tZ(t,n,o,e)})}else tc(n)&&t.callbacks_.push(function(){const s=Dd(t);t.type_===3?s.has(n)&&Q1(n,r.handledSet_,r):AD(s,e,t.type_)===n&&r.drafts_.length>1&&(t.assigned_.get(e)??!1)===!0&&t.copy_&&Q1(AD(t.copy_,e,t.type_),r.handledSet_,r)})}function Q1(t,e,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||ou(t)||e.has(t)||!tc(t)||Sk(t)||(e.add(t),xk(t,(r,i)=>{if(ou(i)){const s=i[Os];if(_k(s,n)){const o=AL(s);X1(t,r,o,t.type_),eZ(s)}}else tc(i)&&Q1(i,e,n)})),t}function v2e(t,e){const n=yk(t),r={type_:n?1:0,scope_:e?e.scope_:JQ(),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=Z1;n&&(i=[r],s=E0);const{revoke:o,proxy:l}=Proxy.revocable(i,s);return r.draft_=l,r.revoke_=o,[l,r]}var Z1={get(t,e){if(e===Os)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=Dd(t);if(!tV(i,e,t.type_))return w2e(t,i,e);const s=i[e];if(t.finalized_||!tc(s)||r&&t.operationMethod&&n?.isMutatingArrayMethod(t.operationMethod)&&h2e(e))return s;if(s===iE(t.base_,e)){J_(t);const o=t.type_===1?+e:e,l=DD(t.scope_,s,t,o);return t.copy_[o]=l}return s},has(t,e){return e in Dd(t)},ownKeys(t){return Reflect.ownKeys(Dd(t))},set(t,e,n){const r=rZ(Dd(t),e);if(r?.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const i=iE(Dd(t),e),s=i?.[Os];if(s&&s.base_===n)return t.copy_[e]=n,t.assigned_.set(e,!1),!0;if(u2e(n,i)&&(n!==void 0||tV(t.base_,e,t.type_)))return!0;J_(t),jD(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),y2e(t,e,n)),!0},deleteProperty(t,e){return J_(t),iE(t.base_,e)!==void 0||e in t.base_?(t.assigned_.set(e,!1),jD(t)):t.assigned_.delete(e),t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const n=Dd(t),r=Reflect.getOwnPropertyDescriptor(n,e);return r&&{[Z_]:!0,[kD]:t.type_!==1||e!=="length",[K1]:r[K1],[M0]:n[e]}},defineProperty(){Hl(11)},getPrototypeOf(t){return _b(t.base_)},setPrototypeOf(){Hl(12)}},E0={};for(let t in Z1){let e=Z1[t];E0[t]=function(){const n=arguments;return n[0]=n[0][0],e.apply(this,n)}}E0.deleteProperty=function(t,e){return E0.set.call(this,t,e,void 0)};E0.set=function(t,e,n){return Z1.set.call(this,t[0],e,n,t[0])};function iE(t,e){const n=t[Os];return(n?Dd(n):t)[e]}function w2e(t,e,n){const r=rZ(e,n);return r?M0 in r?r[M0]:r.get?.call(t.draft_):void 0}function rZ(t,e){if(!(e in t))return;let n=_b(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,e);if(r)return r;n=_b(n)}}function jD(t){t.modified_||(t.modified_=!0,t.parent_&&jD(t.parent_))}function J_(t){t.copy_||(t.assigned_=new Map,t.copy_=TD(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var S2e=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(n,r,i)=>{if(Dg(n)&&!Dg(r)){const o=r;r=n;const l=this;return function(d=o,...u){return l.produce(d,h=>r.call(this,h,...u))}}Dg(r)||Hl(6),i!==void 0&&!Dg(i)&&Hl(7);let s;if(tc(n)){const o=iV(this),l=DD(o,n,void 0);let c=!0;try{s=r(l),c=!1}finally{c?PD(o):ED(o)}return aV(o,i),sV(s,o)}else if(!n||!kL(n)){if(s=r(n),s===void 0&&(s=n),s===YQ&&(s=void 0),this.autoFreeze_&&TL(s,!0),i){const o=[],l=[];$f(MD).generateReplacementPatches_(n,s,{patches_:o,inversePatches_:l}),i(o,l)}return s}else Hl(1,n)},this.produceWithPatches=(n,r)=>{if(Dg(n))return(l,...c)=>this.produceWithPatches(l,d=>n(d,...c));let i,s;return[this.produce(n,r,(l,c)=>{i=l,s=c}),i,s]},aE(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),aE(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),aE(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){tc(e)||Hl(8),ou(e)&&(e=Xl(e));const n=iV(this),r=DD(n,e,void 0);return r[Os].isManual_=!0,ED(n),r}finishDraft(e,n){const r=e&&e[Os];(!r||!r.isManual_)&&Hl(9);const{scope_:i}=r;return aV(i,n),sV(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=$f(MD).applyPatches_;return ou(e)?i(e,n):this.produce(e,s=>i(s,n))}};function DD(t,e,n,r){const[i,s]=vk(e)?$f(Y1).proxyMap_(e,n):wk(e)?$f(Y1).proxySet_(e,n):v2e(e,n);return(n?.scope_??JQ()).drafts_.push(i),s.callbacks_=n?.callbacks_??[],s.key_=r,n&&r!==void 0?x2e(n,s,r):s.callbacks_.push(function(c){c.mapSetPlugin_?.fixSetContents(s);const{patchPlugin_:d}=c;s.modified_&&d&&d.generatePatches_(s,[],c)}),i}function Xl(t){return ou(t)||Hl(10,t),aZ(t)}function aZ(t){if(!tc(t)||Sk(t))return t;const e=t[Os];let n,r=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=TD(t,e.scope_.immer_.useStrictShallowCopy_),r=e.scope_.immer_.shouldUseStrictIteration()}else n=TD(t,!0);return xk(n,(i,s)=>{X1(n,i,aZ(s))},r),e&&(e.finalized_=!1),n}var _2e=new S2e,iZ=_2e.produce;function sZ(t){return({dispatch:n,getState:r})=>i=>s=>typeof s=="function"?s(n,r,t):i(s)}var N2e=sZ(),C2e=sZ,k2e=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?G1:G1.apply(null,arguments)};function kl(t,e){function n(...r){if(e){let i=e(...r);if(!i)throw new Error(Ro(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=>XQ(r)&&r.type===t,n}var oZ=class My extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,My.prototype)}static get[Symbol.species](){return My}concat(...e){return super.concat.apply(this,e)}prepend(...e){return e.length===1&&Array.isArray(e[0])?new My(...e[0].concat(this)):new My(...e.concat(this))}};function lV(t){return tc(t)?iZ(t,()=>{}):t}function o_(t,e,n){return t.has(e)?t.get(e):t.set(e,n(e)).get(e)}function A2e(t){return typeof t=="boolean"}var T2e=()=>function(e){const{thunk:n=!0,immutableCheck:r=!0,serializableCheck:i=!0,actionCreatorCheck:s=!0}=e??{};let o=new oZ;return n&&(A2e(n)?o.push(N2e):o.push(C2e(n.extraArgument))),o},lZ="RTK_autoBatch",ma=()=>t=>({payload:t,meta:{[lZ]:!0}}),cV=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:cV(10):t.type==="callback"?t.queueNotification:cV(t.timeout),d=()=>{o=!1,s&&(s=!1,l.forEach(u=>u()))};return Object.assign({},r,{subscribe(u){const h=()=>i&&u(),f=r.subscribe(h);return l.add(u),()=>{f(),l.delete(u)}},dispatch(u){try{return i=!u?.meta?.[lZ],s=!i,s&&(o||(o=!0,c(d))),r.dispatch(u)}finally{i=!0}}})},M2e=t=>function(n){const{autoBatch:r=!0}=n??{};let i=new oZ(t);return r&&i.push(cZ(typeof r=="object"?r:void 0)),i};function P2e(t){const e=T2e(),{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(CL(n))l=KQ(n);else throw new Error(Ro(1));let c;typeof r=="function"?c=r(e):c=e();let d=G1;i&&(d=k2e({trace:!1,...typeof i=="object"&&i}));const u=c2e(...c),h=M2e(u);let f=typeof o=="function"?o(h):h();const p=d(...f);return WQ(l,s,p)}function dZ(t){const e={},n=[];let r;const i={addCase(s,o){const l=typeof s=="string"?s:s.type;if(!l)throw new Error(Ro(28));if(l in e)throw new Error(Ro(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 E2e(t){return typeof t=="function"}function j2e(t,e){let[n,r,i]=dZ(e),s;if(E2e(t))s=()=>lV(t());else{const l=lV(t);s=()=>l}function o(l=s(),c){let d=[n[c.type],...r.filter(({matcher:u})=>u(c)).map(({reducer:u})=>u)];return d.filter(u=>!!u).length===0&&(d=[i]),d.reduce((u,h)=>{if(h)if(ou(u)){const p=h(u,c);return p===void 0?u:p}else{if(tc(u))return iZ(u,f=>h(f,c));{const f=h(u,c);if(f===void 0){if(u===null)return u;throw Error("A case reducer on a non-draftable value must not return undefined")}return f}}return u},l)}return o.getInitialState=s,o}var D2e="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",R2e=(t=21)=>{let e="",n=t;for(;n--;)e+=D2e[Math.random()*64|0];return e},F2e=Symbol.for("rtk-slice-createasyncthunk");function L2e(t,e){return`${t}/${e}`}function O2e({creators:t}={}){const e=t?.asyncThunk?.[F2e];return function(r){const{name:i,reducerPath:s=i}=r;if(!i)throw new Error(Ro(11));const o=(typeof r.reducers=="function"?r.reducers(z2e()):r.reducers)||{},l=Object.keys(o),c={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},d={addCase(N,A){const k=typeof N=="string"?N:N.type;if(!k)throw new Error(Ro(12));if(k in c.sliceCaseReducersByType)throw new Error(Ro(13));return c.sliceCaseReducersByType[k]=A,d},addMatcher(N,A){return c.sliceMatchers.push({matcher:N,reducer:A}),d},exposeAction(N,A){return c.actionCreators[N]=A,d},exposeCaseReducer(N,A){return c.sliceCaseReducersByName[N]=A,d}};l.forEach(N=>{const A=o[N],k={reducerName:N,type:L2e(i,N),createNotation:typeof r.reducers=="function"};B2e(A)?$2e(k,A,d,e):U2e(k,A,d)});function u(){const[N={},A=[],k=void 0]=typeof r.extraReducers=="function"?dZ(r.extraReducers):[r.extraReducers],P={...N,...c.sliceCaseReducersByType};return j2e(r.initialState,C=>{for(let j in P)C.addCase(j,P[j]);for(let j of c.sliceMatchers)C.addMatcher(j.matcher,j.reducer);for(let j of A)C.addMatcher(j.matcher,j.reducer);k&&C.addDefaultCase(k)})}const h=N=>N,f=new Map,p=new WeakMap;let x;function v(N,A){return x||(x=u()),x(N,A)}function g(){return x||(x=u()),x.getInitialState()}function y(N,A=!1){function k(C){let j=C[N];return typeof j>"u"&&A&&(j=o_(p,k,g)),j}function P(C=h){const j=o_(f,A,()=>new WeakMap);return o_(j,C,()=>{const M={};for(const[E,B]of Object.entries(r.selectors??{}))M[E]=I2e(B,C,()=>o_(p,C,g),A);return M})}return{reducerPath:N,getSelectors:P,get selectors(){return P(k)},selectSlice:k}}const _={name:i,reducer:v,actions:c.actionCreators,caseReducers:c.sliceCaseReducersByName,getInitialState:g,...y(s),injectInto(N,{reducerPath:A,...k}={}){const P=A??s;return N.inject({reducerPath:P,reducer:v},k),{..._,...y(P,!0)}}};return _}}function I2e(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 uo=O2e();function z2e(){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 U2e({type:t,reducerName:e,createNotation:n},r,i){let s,o;if("reducer"in r){if(n&&!H2e(r))throw new Error(Ro(17));s=r.reducer,o=r.prepare}else s=r;i.addCase(t,s).exposeCaseReducer(e,s).exposeAction(e,o?kl(t,o):kl(t))}function B2e(t){return t._reducerDefinitionType==="asyncThunk"}function H2e(t){return t._reducerDefinitionType==="reducerWithPrepare"}function $2e({type:t,reducerName:e},n,r,i){if(!i)throw new Error(Ro(18));const{payloadCreator:s,fulfilled:o,pending:l,rejected:c,settled:d,options:u}=n,h=i(t,s,u);r.exposeAction(e,h),o&&r.addCase(h.fulfilled,o),l&&r.addCase(h.pending,l),c&&r.addCase(h.rejected,c),d&&r.addMatcher(h.settled,d),r.exposeCaseReducer(e,{fulfilled:o||l_,pending:l||l_,rejected:c||l_,settled:d||l_})}function l_(){}var V2e="task",uZ="listener",hZ="completed",ML="cancelled",q2e=`task-${ML}`,G2e=`task-${hZ}`,RD=`${uZ}-${ML}`,W2e=`${uZ}-${hZ}`,Nk=class{constructor(t){this.code=t,this.message=`${V2e} ${ML} (reason: ${t})`}name="TaskAbortError";message},PL=(t,e)=>{if(typeof t!="function")throw new TypeError(Ro(32))},J1=()=>{},mZ=(t,e=J1)=>(t.catch(e),t),fZ=(t,e)=>(t.addEventListener("abort",e,{once:!0}),()=>t.removeEventListener("abort",e)),gf=t=>{if(t.aborted)throw new Nk(t.reason)};function pZ(t,e){let n=J1;return new Promise((r,i)=>{const s=()=>i(new Nk(t.reason));if(t.aborted){s();return}n=fZ(t,s),e.finally(()=>n()).then(r,i)}).finally(()=>{n=J1})}var K2e=async(t,e)=>{try{return await Promise.resolve(),{status:"ok",value:await t()}}catch(n){return{status:n instanceof Nk?"cancelled":"rejected",error:n}}finally{e?.()}},eN=t=>e=>mZ(pZ(t,e).then(n=>(gf(t),n))),gZ=t=>{const e=eN(t);return n=>e(new Promise(r=>setTimeout(r,n)))},{assign:nb}=Object,dV={},Ck="listenerMiddleware",X2e=(t,e)=>{const n=r=>fZ(t,()=>r.abort(t.reason));return(r,i)=>{PL(r);const s=new AbortController;n(s);const o=K2e(async()=>{gf(t),gf(s.signal);const l=await r({pause:eN(s.signal),delay:gZ(s.signal),signal:s.signal});return gf(s.signal),l},()=>s.abort(G2e));return i?.autoJoin&&e.push(o.catch(J1)),{result:eN(t)(o),cancel(){s.abort(q2e)}}}},Y2e=(t,e)=>{const n=async(r,i)=>{gf(e);let s=()=>{};const l=[new Promise((c,d)=>{let u=t({predicate:r,effect:(h,f)=>{f.unsubscribe(),c([h,f.getState(),f.getOriginalState()])}});s=()=>{u(),d()}})];i!=null&&l.push(new Promise(c=>setTimeout(c,i,null)));try{const c=await pZ(e,Promise.race(l));return gf(e),c}finally{s()}};return(r,i)=>mZ(n(r,i))},bZ=t=>{let{type:e,actionCreator:n,matcher:r,predicate:i,effect:s}=t;if(e)i=kl(e).match;else if(n)e=n.type,i=n.match;else if(r)i=r;else if(!i)throw new Error(Ro(21));return PL(s),{predicate:i,type:e,effect:s}},xZ=nb(t=>{const{type:e,predicate:n,effect:r}=bZ(t);return{id:R2e(),effect:r,type:e,predicate:n,pending:new Set,unsubscribe:()=>{throw new Error(Ro(22))}}},{withTypes:()=>xZ}),uV=(t,e)=>{const{type:n,effect:r,predicate:i}=bZ(e);return Array.from(t.values()).find(s=>(typeof n=="string"?s.type===n:s.predicate===i)&&s.effect===r)},FD=t=>{t.pending.forEach(e=>{e.abort(RD)})},Q2e=(t,e)=>()=>{for(const n of e.keys())FD(n);t.clear()},hV=(t,e,n)=>{try{t(e,n)}catch(r){setTimeout(()=>{throw r},0)}},yZ=nb(kl(`${Ck}/add`),{withTypes:()=>yZ}),Z2e=kl(`${Ck}/removeAll`),vZ=nb(kl(`${Ck}/remove`),{withTypes:()=>vZ}),J2e=(...t)=>{console.error(`${Ck}/error`,...t)},yv=(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=J2e}=t;PL(o);const l=p=>(p.unsubscribe=()=>e.delete(p.id),e.set(p.id,p),x=>{p.unsubscribe(),x?.cancelActive&&FD(p)}),c=p=>{const x=uV(e,p)??xZ(p);return l(x)};nb(c,{withTypes:()=>c});const d=p=>{const x=uV(e,p);return x&&(x.unsubscribe(),p.cancelActive&&FD(x)),!!x};nb(d,{withTypes:()=>d});const u=async(p,x,v,g)=>{const y=new AbortController,_=Y2e(c,y.signal),N=[];try{p.pending.add(y),r(p),await Promise.resolve(p.effect(x,nb({},v,{getOriginalState:g,condition:(A,k)=>_(A,k).then(Boolean),take:_,delay:gZ(y.signal),pause:eN(y.signal),extra:s,signal:y.signal,fork:X2e(y.signal,N),unsubscribe:p.unsubscribe,subscribe:()=>{e.set(p.id,p)},cancelActiveListeners:()=>{p.pending.forEach((A,k,P)=>{A!==y&&(A.abort(RD),P.delete(A))})},cancel:()=>{y.abort(RD),p.pending.delete(y)},throwIfCancelled:()=>{gf(y.signal)}})))}catch(A){A instanceof Nk||hV(o,A,{raisedBy:"effect"})}finally{await Promise.all(N),y.abort(W2e),i(p),p.pending.delete(y)}},h=Q2e(e,n);return{middleware:p=>x=>v=>{if(!XQ(v))return x(v);if(yZ.match(v))return c(v.payload);if(Z2e.match(v)){h();return}if(vZ.match(v))return d(v.payload);let g=p.getState();const y=()=>{if(g===dV)throw new Error(Ro(23));return g};let _;try{if(_=x(v),e.size>0){const N=p.getState(),A=Array.from(e.values());for(const k of A){let P=!1;try{P=k.predicate(v,N,g)}catch(C){P=!1,hV(o,C,{raisedBy:"predicate"})}P&&u(k,v,p,y)}}}finally{g=dV}return _},startListening:c,stopListening:d,clearListeners:h}};function Ro(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 eEe={layoutType:"horizontal",width:0,height:0,margin:{top:5,right:5,bottom:5,left:5},scale:1},wZ=uo({name:"chartLayout",initialState:eEe,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:tEe,setLayout:nEe,setChartSize:rEe,setScale:aEe}=wZ.actions,iEe=wZ.reducer;function SZ(t,e,n){return Array.isArray(t)&&t&&e+n!==0?t.slice(e,n+1):t}function Cn(t){return Number.isFinite(t)}function Ic(t){return typeof t=="number"&&t>0&&Number.isFinite(t)}function mV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Bg(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?mV(Object(n),!0).forEach(function(r){sEe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):mV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function sEe(t,e,n){return(e=oEe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function oEe(t){var e=lEe(t,"string");return typeof e=="symbol"?e:e+""}function lEe(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 _r(t,e,n){return ba(t)||ba(e)?n:Cl(e)?Bf(t,e,n):typeof e=="function"?e(t):n}var cEe=(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"&&$t(t[s]))return Bg(Bg({},t),{},{[s]:t[s]+(r||0)});if((l==="horizontal"||l==="vertical"&&s==="center")&&o!=="middle"&&$t(t[o]))return Bg(Bg({},t),{},{[o]:t[o]+(i||0)})}return t},oc=(t,e)=>t==="horizontal"&&e==="xAxis"||t==="vertical"&&e==="yAxis"||t==="centric"&&e==="angleAxis"||t==="radial"&&e==="radiusAxis",_Z=(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},NZ=(t,e,n)=>{if(!t)return null;var{duplicateDomain:r,type:i,range:s,scale:o,realScaleType:l,isCategorical:c,categoricalDomain:d,tickCount:u,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 Cn(A)?{coordinate:A+v,value:y,offset:v,index:_}:null}).filter(to);return g}return c&&d?d.map((y,_)=>{var N=o.map(y);return Cn(N)?{coordinate:N+v,value:y,index:_,offset:v}:null}).filter(to):o.ticks&&u!=null?o.ticks(u).map((y,_)=>{var N=o.map(y);return Cn(N)?{coordinate:N+v,value:y,index:_,offset:v}:null}).filter(to):o.domain().map((y,_)=>{var N=o.map(y);return Cn(N)?{coordinate:N+v,value:r?r[y]:y,index:_,offset:v}:null}).filter(to)},dEe=(t,e)=>{if(!e||e.length!==2||!$t(e[0])||!$t(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(!$t(t[0])||t[0]<n)&&(i[0]=n),(!$t(t[1])||t[1]>r)&&(i[1]=r),i[0]>r&&(i[0]=r),i[1]<n&&(i[1]=n),i},uEe=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],d=c?.[i];if(d!=null){var u=d[1],h=d[0],f=ec(u)?h:u;f>=0?(d[0]=s,s+=f,d[1]=s):(d[0]=o,o+=f,d[1]=o)}}}},hEe=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 d=ec(c[1])?c[0]:c[1];d>=0?(c[0]=s,s+=d,c[1]=s):(c[0]=0,c[1]=0)}}}},mEe={sign:uEe,expand:LMe,none:Uf,silhouette:OMe,wiggle:IMe,positive:hEe},fEe=(t,e,n)=>{var r,i=(r=mEe[n])!==null&&r!==void 0?r:Uf,s=FMe().keys(e).value((l,c)=>Number(_r(l,c,0))).order(ND).offset(i),o=s(t);return o.forEach((l,c)=>{l.forEach((d,u)=>{var h=_r(t[u],e[c],0);Array.isArray(h)&&h.length===2&&$t(h[0])&&$t(h[1])&&(d[0]=h[0],d[1]=h[1])})}),o};function CZ(t){return t==null?void 0:String(t)}function tN(t){var{axis:e,ticks:n,bandSize:r,entry:i,index:s,dataKey:o}=t;if(e.type==="category"){if(!e.allowDuplicatedCategory&&e.dataKey&&!ba(i[e.dataKey])){var l=MQ(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=_r(i,ba(o)?e.dataKey:o),d=e.scale.map(c);return $t(d)?d:null}var fV=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=_r(s,e.dataKey,e.scale.domain()[o]);if(ba(l))return null;var c=e.scale.map(l);return $t(c)?c-i/2+r:null},pEe=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]},gEe=t=>{var e=t.flat(2).filter($t);return[Math.min(...e),Math.max(...e)]},bEe=t=>[t[0]===1/0?0:t[0],t[1]===-1/0?0:t[1]],xEe=(t,e,n)=>{if(t!=null)return bEe(Object.keys(t).reduce((r,i)=>{var s=t[i];if(!s)return r;var{stackedData:o}=s,l=o.reduce((c,d)=>{var u=SZ(d,e,n),h=gEe(u);return!Cn(h[0])||!Cn(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]))},pV=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,gV=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,Qh=(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=gk(e,u=>u.coordinate),s=1/0,o=1,l=i.length;o<l;o++){var c=i[o],d=i[o-1];s=Math.min((c?.coordinate||0)-(d?.coordinate||0),s)}return s===1/0?0:s}return n?void 0:0};function bV(t){var{tooltipEntrySettings:e,dataKey:n,payload:r,value:i,name:s}=t;return Bg(Bg({},e),{},{dataKey:n,payload:r,value:i,name:s})}function rm(t,e){if(t)return String(t);if(typeof e=="string")return e}var yEe=(t,e)=>{if(e==="horizontal")return t.chartX;if(e==="vertical")return t.chartY},vEe=(t,e)=>e==="centric"?t.angle:t.radius,pu=t=>t.layout.width,gu=t=>t.layout.height,wEe=t=>t.layout.scale,kZ=t=>t.layout.margin,kk=dt(t=>t.cartesianAxis.xAxis,t=>Object.values(t)),Ak=dt(t=>t.cartesianAxis.yAxis,t=>Object.values(t)),AZ="data-recharts-item-index",TZ="data-recharts-item-id",vv=60;function xV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function c_(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?xV(Object(n),!0).forEach(function(r){SEe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):xV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function SEe(t,e,n){return(e=_Ee(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function _Ee(t){var e=NEe(t,"string");return typeof e=="symbol"?e:e+""}function NEe(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 CEe=t=>t.brush.height;function kEe(t){var e=Ak(t);return e.reduce((n,r)=>{if(r.orientation==="left"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:vv;return n+i}return n},0)}function AEe(t){var e=Ak(t);return e.reduce((n,r)=>{if(r.orientation==="right"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:vv;return n+i}return n},0)}function TEe(t){var e=kk(t);return e.reduce((n,r)=>r.orientation==="top"&&!r.mirror&&!r.hide?n+r.height:n,0)}function MEe(t){var e=kk(t);return e.reduce((n,r)=>r.orientation==="bottom"&&!r.mirror&&!r.hide?n+r.height:n,0)}var vi=dt([pu,gu,kZ,CEe,kEe,AEe,TEe,MEe,qQ,n2e],(t,e,n,r,i,s,o,l,c,d)=>{var u={left:(n.left||0)+i,right:(n.right||0)+s},h={top:(n.top||0)+o,bottom:(n.bottom||0)+l},f=c_(c_({},h),u),p=f.bottom;f.bottom+=r,f=cEe(f,c,d);var x=t-f.left-f.right,v=e-f.top-f.bottom;return c_(c_({brushBottom:p},f),{},{width:Math.max(x,0),height:Math.max(v,0)})}),PEe=dt(vi,t=>({x:t.left,y:t.top,width:t.width,height:t.height})),EL=dt(pu,gu,(t,e)=>({x:0,y:0,width:t,height:e})),EEe=w.createContext(null),wi=()=>w.useContext(EEe)!=null,Tk=t=>t.brush,Mk=dt([Tk,vi,kZ],(t,e,n)=>({height:t.height,x:$t(t.x)?t.x:e.left,y:$t(t.y)?t.y:e.top+e.height+e.brushBottom-(n?.bottom||0),width:$t(t.width)?t.width:e.width})),sE={},oE={},lE={},yV;function jEe(){return yV||(yV=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"),d=s==null||s.includes("trailing"),u=()=>{l!==null&&(n.apply(o,l),o=void 0,l=null)},h=()=>{d&&u(),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=()=>{u()},y=function(..._){if(i?.aborted)return;o=this,l=_;const N=f==null;p(),c&&N&&u()};return y.schedule=p,y.cancel=v,y.flush=g,i?.addEventListener("abort",v,{once:!0}),y}t.debounce=e})(lE)),lE}var vV;function DEe(){return vV||(vV=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=jEe();function n(r,i=0,s={}){typeof s!="object"&&(s={});const{leading:o=!1,trailing:l=!0,maxWait:c}=s,d=Array(2);o&&(d[0]="leading"),l&&(d[1]="trailing");let u,h=null;const f=e.debounce(function(...v){u=r.apply(this,v),h=null},i,{edges:d}),p=function(...v){return c!=null&&(h===null&&(h=Date.now()),Date.now()-h>=c)?(u=r.apply(this,v),h=Date.now(),f.cancel(),f.schedule(),u):(f.apply(this,v),u)},x=()=>(f.flush(),u);return p.cancel=f.cancel,p.flush=x,p}t.debounce=n})(oE)),oE}var wV;function REe(){return wV||(wV=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=DEe();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})(sE)),sE}var cE,SV;function FEe(){return SV||(SV=1,cE=REe().throttle),cE}var LEe=FEe();const OEe=rc(LEe);var nN=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++]))}},Mc={width:"100%",height:"100%",debounce:0,minWidth:0,initialDimension:{width:-1,height:-1}},MZ=(t,e,n)=>{var{width:r=Mc.width,height:i=Mc.height,aspect:s,maxHeight:o}=n,l=Hf(r)?t:Number(r),c=Hf(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}},IEe={width:0,height:0,overflow:"visible"},zEe={width:0,overflowX:"visible"},UEe={height:0,overflowY:"visible"},BEe={},HEe=t=>{var{width:e,height:n}=t,r=Hf(e),i=Hf(n);return r&&i?IEe:r?zEe:i?UEe:BEe};function $Ee(t){var{width:e,height:n,aspect:r}=t,i=e,s=n;return i===void 0&&s===void 0?(i=Mc.width,s=Mc.height):i===void 0?i=r&&r>0?void 0:Mc.width:s===void 0&&(s=r&&r>0?void 0:Mc.height),{width:i,height:s}}function LD(){return LD=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},LD.apply(null,arguments)}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 NV(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){VEe(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 VEe(t,e,n){return(e=qEe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function qEe(t){var e=GEe(t,"string");return typeof e=="symbol"?e:e+""}function GEe(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 PZ=w.createContext(Mc.initialDimension);function WEe(t){return Ic(t.width)&&Ic(t.height)}function EZ(t){var{children:e,width:n,height:r}=t,i=w.useMemo(()=>({width:n,height:r}),[n,r]);return WEe(i)?w.createElement(PZ.Provider,{value:i},e):null}var jL=()=>w.useContext(PZ),KEe=w.forwardRef((t,e)=>{var{aspect:n,initialDimension:r=Mc.initialDimension,width:i,height:s,minWidth:o=Mc.minWidth,minHeight:l,maxHeight:c,children:d,debounce:u=Mc.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((j,M)=>{_(E=>{var B=Math.round(j),L=Math.round(M);return E.containerWidth===B&&E.containerHeight===L?E:{containerWidth:B,containerHeight:L}})},[]);w.useEffect(()=>{if(v.current==null||typeof ResizeObserver>"u")return nm;var j=L=>{var U,D=L[0];if(D!=null){var{width:$,height:q}=D.contentRect;N($,q),(U=g.current)===null||U===void 0||U.call(g,$,q)}};u>0&&(j=OEe(j,u,{trailing:!0,leading:!1}));var M=new ResizeObserver(j),{width:E,height:B}=v.current.getBoundingClientRect();return N(E,B),M.observe(v.current),()=>{M.disconnect()}},[N,u]);var{containerWidth:A,containerHeight:k}=y;nN(!n||n>0,"The aspect(%s) must be greater than zero.",n);var{calculatedWidth:P,calculatedHeight:C}=MZ(A,k,{width:i,height:s,aspect:n,maxHeight:c});return nN(P!=null&&P>0||C!=null&&C>0,`The width(%s) and height(%s) of chart should be greater than 0,
- please check the style of container, or the props width(%s) and height(%s),
- or add a minWidth(%s) or minHeight(%s) or use aspect(%s) to control the
- height and width.`,P,C,i,s,o,l,n),w.createElement("div",{id:h?"".concat(h):void 0,className:cr("recharts-responsive-container",f),style:NV(NV({},x),{},{width:i,height:s,minWidth:o,minHeight:l,maxHeight:c}),ref:v},w.createElement("div",{style:HEe({width:i,height:s})},w.createElement(EZ,{width:P,height:C},d)))}),e1=w.forwardRef((t,e)=>{var n=jL();if(Ic(n.width)&&Ic(n.height))return t.children;var{width:r,height:i}=$Ee({width:t.width,height:t.height,aspect:t.aspect}),{calculatedWidth:s,calculatedHeight:o}=MZ(void 0,void 0,{width:r,height:i,aspect:t.aspect,maxHeight:t.maxHeight});return $t(s)&&$t(o)?w.createElement(EZ,{width:s,height:o},t.children):w.createElement(KEe,LD({},t,{width:r,height:i,ref:e}))});function DL(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 wv=()=>{var t,e=wi(),n=Gt(PEe),r=Gt(Mk),i=(t=Gt(Tk))===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}},XEe={top:0,bottom:0,left:0,right:0,width:0,height:0,brushBottom:0},jZ=()=>{var t;return(t=Gt(vi))!==null&&t!==void 0?t:XEe},RL=()=>Gt(pu),FL=()=>Gt(gu),YEe=()=>Gt(t=>t.layout.margin),ir=t=>t.layout.layoutType,am=()=>Gt(ir),LL=()=>{var t=am();if(t==="horizontal"||t==="vertical")return t},DZ=t=>{var e=t.layout.layoutType;if(e==="centric"||e==="radial")return e},QEe=()=>{var t=am();return t!==void 0},Sv=t=>{var e=Yr(),n=wi(),{width:r,height:i}=t,s=jL(),o=r,l=i;return s&&(o=s.width>0?s.width:r,l=s.height>0?s.height:i),w.useEffect(()=>{!n&&Ic(o)&&Ic(l)&&e(rEe({width:o,height:l}))},[e,n,o,l]),null},RZ=Symbol.for("immer-nothing"),CV=Symbol.for("immer-draftable"),Oo=Symbol.for("immer-state");function $l(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var j0=Object.getPrototypeOf;function Nb(t){return!!t&&!!t[Oo]}function Vf(t){return t?FZ(t)||Array.isArray(t)||!!t[CV]||!!t.constructor?.[CV]||_v(t)||Ek(t):!1}var ZEe=Object.prototype.constructor.toString(),kV=new WeakMap;function FZ(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=kV.get(n);return r===void 0&&(r=Function.toString.call(n),kV.set(n,r)),r===ZEe}function rN(t,e,n=!0){Pk(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 Pk(t){const e=t[Oo];return e?e.type_:Array.isArray(t)?1:_v(t)?2:Ek(t)?3:0}function OD(t,e){return Pk(t)===2?t.has(e):Object.prototype.hasOwnProperty.call(t,e)}function LZ(t,e,n){const r=Pk(t);r===2?t.set(e,n):r===3?t.add(n):t[e]=n}function JEe(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}function _v(t){return t instanceof Map}function Ek(t){return t instanceof Set}function qm(t){return t.copy_||t.base_}function ID(t,e){if(_v(t))return new Map(t);if(Ek(t))return new Set(t);if(Array.isArray(t))return Array.prototype.slice.call(t);const n=FZ(t);if(e===!0||e==="class_only"&&!n){const r=Object.getOwnPropertyDescriptors(t);delete r[Oo];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(j0(t),r)}else{const r=j0(t);if(r!==null&&n)return{...t};const i=Object.create(r);return Object.assign(i,t)}}function OL(t,e=!1){return jk(t)||Nb(t)||!Vf(t)||(Pk(t)>1&&Object.defineProperties(t,{set:d_,add:d_,clear:d_,delete:d_}),Object.freeze(t),e&&Object.values(t).forEach(n=>OL(n,!0))),t}function eje(){$l(2)}var d_={value:eje};function jk(t){return t===null||typeof t!="object"?!0:Object.isFrozen(t)}var tje={};function qf(t){const e=tje[t];return e||$l(0,t),e}var D0;function OZ(){return D0}function nje(t,e){return{drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function AV(t,e){e&&(qf("Patches"),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function zD(t){UD(t),t.drafts_.forEach(rje),t.drafts_=null}function UD(t){t===D0&&(D0=t.parent_)}function TV(t){return D0=nje(D0,t)}function rje(t){const e=t[Oo];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function MV(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];return t!==void 0&&t!==n?(n[Oo].modified_&&(zD(e),$l(4)),Vf(t)&&(t=aN(e,t),e.parent_||iN(e,t)),e.patches_&&qf("Patches").generateReplacementPatches_(n[Oo].base_,t,e.patches_,e.inversePatches_)):t=aN(e,n,[]),zD(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==RZ?t:void 0}function aN(t,e,n){if(jk(e))return e;const r=t.immer_.shouldUseStrictIteration(),i=e[Oo];if(!i)return rN(e,(s,o)=>PV(t,i,e,s,o,n),r),e;if(i.scope_!==t)return e;if(!i.modified_)return iN(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),rN(o,(c,d)=>PV(t,i,s,c,d,n,l),r),iN(t,s,!1),n&&t.patches_&&qf("Patches").generatePatches_(i,n,t.patches_,t.inversePatches_)}return i.copy_}function PV(t,e,n,r,i,s,o){if(i==null||typeof i!="object"&&!o)return;const l=jk(i);if(!(l&&!o)){if(Nb(i)){const c=s&&e&&e.type_!==3&&!OD(e.assigned_,r)?s.concat(r):void 0,d=aN(t,i,c);if(LZ(n,r,d),Nb(d))t.canAutoFreeze_=!1;else return}else o&&n.add(i);if(Vf(i)&&!l){if(!t.immer_.autoFreeze_&&t.unfinalizedDrafts_<1||e&&e.base_&&e.base_[r]===i&&l)return;aN(t,i),(!e||!e.scope_.parent_)&&typeof r!="symbol"&&(_v(n)?n.has(r):Object.prototype.propertyIsEnumerable.call(n,r))&&iN(t,i)}}}function iN(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&OL(e,n)}function aje(t,e){const n=Array.isArray(t),r={type_:n?1:0,scope_:e?e.scope_:OZ(),modified_:!1,finalized_:!1,assigned_:{},parent_:e,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=r,s=IL;n&&(i=[r],s=R0);const{revoke:o,proxy:l}=Proxy.revocable(i,s);return r.draft_=l,r.revoke_=o,l}var IL={get(t,e){if(e===Oo)return t;const n=qm(t);if(!OD(n,e))return ije(t,n,e);const r=n[e];return t.finalized_||!Vf(r)?r:r===dE(t.base_,e)?(uE(t),t.copy_[e]=HD(r,t)):r},has(t,e){return e in qm(t)},ownKeys(t){return Reflect.ownKeys(qm(t))},set(t,e,n){const r=IZ(qm(t),e);if(r?.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const i=dE(qm(t),e),s=i?.[Oo];if(s&&s.base_===n)return t.copy_[e]=n,t.assigned_[e]=!1,!0;if(JEe(n,i)&&(n!==void 0||OD(t.base_,e)))return!0;uE(t),BD(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 dE(t.base_,e)!==void 0||e in t.base_?(t.assigned_[e]=!1,uE(t),BD(t)):delete t.assigned_[e],t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const n=qm(t),r=Reflect.getOwnPropertyDescriptor(n,e);return r&&{writable:!0,configurable:t.type_!==1||e!=="length",enumerable:r.enumerable,value:n[e]}},defineProperty(){$l(11)},getPrototypeOf(t){return j0(t.base_)},setPrototypeOf(){$l(12)}},R0={};rN(IL,(t,e)=>{R0[t]=function(){return arguments[0]=arguments[0][0],e.apply(this,arguments)}});R0.deleteProperty=function(t,e){return R0.set.call(this,t,e,void 0)};R0.set=function(t,e,n){return IL.set.call(this,t[0],e,n,t[0])};function dE(t,e){const n=t[Oo];return(n?qm(n):t)[e]}function ije(t,e,n){const r=IZ(e,n);return r?"value"in r?r.value:r.get?.call(t.draft_):void 0}function IZ(t,e){if(!(e in t))return;let n=j0(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,e);if(r)return r;n=j0(n)}}function BD(t){t.modified_||(t.modified_=!0,t.parent_&&BD(t.parent_))}function uE(t){t.copy_||(t.copy_=ID(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var sje=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,...d){return o.produce(c,u=>n.call(this,u,...d))}}typeof n!="function"&&$l(6),r!==void 0&&typeof r!="function"&&$l(7);let i;if(Vf(e)){const s=TV(this),o=HD(e,void 0);let l=!0;try{i=n(o),l=!1}finally{l?zD(s):UD(s)}return AV(s,r),MV(i,s)}else if(!e||typeof e!="object"){if(i=n(e),i===void 0&&(i=e),i===RZ&&(i=void 0),this.autoFreeze_&&OL(i,!0),r){const s=[],o=[];qf("Patches").generateReplacementPatches_(e,i,s,o),r(s,o)}return i}else $l(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){Vf(t)||$l(8),Nb(t)&&(t=oje(t));const e=TV(this),n=HD(t,void 0);return n[Oo].isManual_=!0,UD(e),n}finishDraft(t,e){const n=t&&t[Oo];(!n||!n.isManual_)&&$l(9);const{scope_:r}=n;return AV(r,e),MV(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=qf("Patches").applyPatches_;return Nb(t)?r(t,e):this.produce(t,i=>r(i,e))}};function HD(t,e){const n=_v(t)?qf("MapSet").proxyMap_(t,e):Ek(t)?qf("MapSet").proxySet_(t,e):aje(t,e);return(e?e.scope_:OZ()).drafts_.push(n),n}function oje(t){return Nb(t)||$l(10,t),zZ(t)}function zZ(t){if(!Vf(t)||jk(t))return t;const e=t[Oo];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 rN(n,(i,s)=>{LZ(n,i,zZ(s))},r),e&&(e.finalized_=!1),n}var lje=new sje;lje.produce;var cje={settings:{layout:"horizontal",align:"center",verticalAlign:"middle",itemSorter:"value"},size:{width:0,height:0},payload:[]},UZ=uo({name:"legend",initialState:cje,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:ma()},replaceLegendPayload:{reducer(t,e){var{prev:n,next:r}=e.payload,i=Xl(t).payload.indexOf(n);i>-1&&(t.payload[i]=r)},prepare:ma()},removeLegendPayload:{reducer(t,e){var n=Xl(t).payload.indexOf(e.payload);n>-1&&t.payload.splice(n,1)},prepare:ma()}}}),{setLegendSize:EV,setLegendSettings:dje,addLegendPayload:BZ,replaceLegendPayload:HZ,removeLegendPayload:$Z}=UZ.actions,uje=UZ.reducer,hje=["contextPayload"];function $D(){return $D=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},$D.apply(null,arguments)}function jV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Cb(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?jV(Object(n),!0).forEach(function(r){mje(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):jV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function mje(t,e,n){return(e=fje(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function fje(t){var e=pje(t,"string");return typeof e=="symbol"?e:e+""}function pje(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 gje(t,e){if(t==null)return{};var n,r,i=bje(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 bje(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 xje(t){return t.value}function yje(t){var{contextPayload:e}=t,n=gje(t,hje),r=UQ(e,t.payloadUniqBy,xje),i=Cb(Cb({},n),{},{payload:r});return w.isValidElement(t.content)?w.cloneElement(t.content,i):typeof t.content=="function"?w.createElement(t.content,i):w.createElement(mPe,i)}function vje(t,e,n,r,i,s){var{layout:o,align:l,verticalAlign:c}=e,d,u;return(!t||(t.left===void 0||t.left===null)&&(t.right===void 0||t.right===null))&&(l==="center"&&o==="vertical"?d={left:((r||0)-s.width)/2}:d=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"?u={top:((i||0)-s.height)/2}:u=c==="bottom"?{bottom:n&&n.bottom||0}:{top:n&&n.top||0}),Cb(Cb({},d),u)}function wje(t){var e=Yr();return w.useEffect(()=>{e(dje(t))},[e,t]),null}function Sje(t){var e=Yr();return w.useEffect(()=>(e(EV(t)),()=>{e(EV({width:0,height:0}))}),[e,t]),null}function _je(t,e,n,r){return t==="vertical"&&e!=null?{height:e}:t==="horizontal"?{width:n||r}:null}var Nje={align:"center",iconSize:14,inactiveColor:"#ccc",itemSorter:"value",layout:"horizontal",verticalAlign:"bottom"};function zL(t){var e=Sa(t,Nje),n=i2e(),r=iMe(),i=YEe(),{width:s,height:o,wrapperStyle:l,portal:c}=e,[d,u]=GQ([n]),h=RL(),f=FL();if(h==null||f==null)return null;var p=h-(i?.left||0)-(i?.right||0),x=_je(e.layout,o,s,p),v=c?l:Cb(Cb({position:"absolute",width:x?.width||s||"auto",height:x?.height||o||"auto"},vje(l,e,i,h,f,d)),l),g=c??r;if(g==null||n==null)return null;var y=w.createElement("div",{className:"recharts-legend-wrapper",style:v,ref:u},w.createElement(wje,{layout:e.layout,align:e.align,verticalAlign:e.verticalAlign,itemSorter:e.itemSorter}),!c&&w.createElement(Sje,{width:d.width,height:d.height}),w.createElement(yje,$D({},e,x,{margin:i,chartWidth:h,chartHeight:f,contextPayload:n})));return Ld.createPortal(y,g)}zL.displayName="Legend";function VD(){return VD=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},VD.apply(null,arguments)}function DV(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 fy(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?DV(Object(n),!0).forEach(function(r){Cje(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):DV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Cje(t,e,n){return(e=kje(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function kje(t){var e=Aje(t,"string");return typeof e=="symbol"?e:e+""}function Aje(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 Tje(t){return Array.isArray(t)&&Cl(t[0])&&Cl(t[1])?t.join(" ~ "):t}var vg={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},Mje=t=>{var{separator:e=vg.separator,contentStyle:n,itemStyle:r,labelStyle:i=vg.labelStyle,payload:s,formatter:o,itemSorter:l,wrapperClassName:c,labelClassName:d,label:u,labelFormatter:h,accessibilityLayer:f=vg.accessibilityLayer}=t,p=()=>{if(s&&s.length){var k={padding:0,margin:0},P=(l?gk(s,l):s).map((C,j)=>{if(C.type==="none")return null;var M=C.formatter||o||Tje,{value:E,name:B}=C,L=E,U=B;if(M){var D=M(E,B,C,j,s);if(Array.isArray(D))[L,U]=D;else if(D!=null)L=D;else return null}var $=fy(fy({},vg.itemStyle),{},{color:C.color||vg.itemStyle.color},r);return w.createElement("li",{className:"recharts-tooltip-item",key:"tooltip-item-".concat(j),style:$},Cl(U)?w.createElement("span",{className:"recharts-tooltip-item-name"},U):null,Cl(U)?w.createElement("span",{className:"recharts-tooltip-item-separator"},e):null,w.createElement("span",{className:"recharts-tooltip-item-value"},L),w.createElement("span",{className:"recharts-tooltip-item-unit"},C.unit||""))});return w.createElement("ul",{className:"recharts-tooltip-item-list",style:k},P)}return null},x=fy(fy({},vg.contentStyle),n),v=fy({margin:0},i),g=!ba(u),y=g?u:"",_=cr("recharts-default-tooltip",c),N=cr("recharts-tooltip-label",d);g&&h&&s!==void 0&&s!==null&&(y=h(u,s));var A=f?{role:"status","aria-live":"assertive"}:{};return w.createElement("div",VD({className:_,style:x},A),w.createElement("p",{className:N,style:v},w.isValidElement(y)?y:"".concat(y)),p())},py="recharts-tooltip-wrapper",Pje={visibility:"hidden"};function Eje(t){var{coordinate:e,translateX:n,translateY:r}=t;return cr(py,{["".concat(py,"-right")]:$t(n)&&e&&$t(e.x)&&n>=e.x,["".concat(py,"-left")]:$t(n)&&e&&$t(e.x)&&n<e.x,["".concat(py,"-bottom")]:$t(r)&&e&&$t(e.y)&&r>=e.y,["".concat(py,"-top")]:$t(r)&&e&&$t(e.y)&&r<e.y})}function RV(t){var{allowEscapeViewBox:e,coordinate:n,key:r,offset:i,position:s,reverseDirection:o,tooltipDimension:l,viewBox:c,viewBoxDimension:d}=t;if(s&&$t(s[r]))return s[r];var u=n[r]-l-(i>0?i:0),h=n[r]+i;if(e[r])return o[r]?u:h;var f=c[r];if(f==null)return 0;if(o[r]){var p=u,x=f;return p<x?Math.max(h,f):Math.max(u,f)}if(d==null)return 0;var v=h+l,g=f+d;return v>g?Math.max(u,f):Math.max(h,f)}function jje(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 Dje(t){var{allowEscapeViewBox:e,coordinate:n,offsetTop:r,offsetLeft:i,position:s,reverseDirection:o,tooltipBox:l,useTranslate3d:c,viewBox:d}=t,u,h,f;return l.height>0&&l.width>0&&n?(h=RV({allowEscapeViewBox:e,coordinate:n,key:"x",offset:i,position:s,reverseDirection:o,tooltipDimension:l.width,viewBox:d,viewBoxDimension:d.width}),f=RV({allowEscapeViewBox:e,coordinate:n,key:"y",offset:r,position:s,reverseDirection:o,tooltipDimension:l.height,viewBox:d,viewBoxDimension:d.height}),u=jje({translateX:h,translateY:f,useTranslate3d:c})):u=Pje,{cssProperties:u,cssClasses:Eje({translateX:h,translateY:f,coordinate:n})}}function FV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function u_(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?FV(Object(n),!0).forEach(function(r){qD(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):FV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function qD(t,e,n){return(e=Rje(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Rje(t){var e=Fje(t,"string");return typeof e=="symbol"?e:e+""}function Fje(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 Lje extends w.PureComponent{constructor(){super(...arguments),qD(this,"state",{dismissed:!1,dismissedAtCoordinate:{x:0,y:0}}),qD(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:d,position:u,reverseDirection:h,useTranslate3d:f,viewBox:p,wrapperStyle:x,lastBoundingBox:v,innerRef:g,hasPortalFromProps:y}=this.props,_=typeof d=="number"?d:d.x,N=typeof d=="number"?d:d.y,{cssClasses:A,cssProperties:k}=Dje({allowEscapeViewBox:n,coordinate:o,offsetLeft:_,offsetTop:N,position:u,reverseDirection:h,tooltipBox:{height:v.height,width:v.width},useTranslate3d:f,viewBox:p}),P=y?{}:u_(u_({transition:c&&e?"transform ".concat(r,"ms ").concat(i):void 0},k),{},{pointerEvents:"none",visibility:!this.state.dismissed&&e&&l?"visible":"hidden",position:"absolute",top:0,left:0}),C=u_(u_({},P),{},{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:C,ref:g},s)}}var VZ=()=>{var t;return(t=Gt(e=>e.rootProps.accessibilityLayer))!==null&&t!==void 0?t:!0};function GD(){return GD=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},GD.apply(null,arguments)}function LV(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 OV(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?LV(Object(n),!0).forEach(function(r){Oje(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):LV(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 IV={curveBasisClosed:NMe,curveBasisOpen:CMe,curveBasis:_Me,curveBumpX:cMe,curveBumpY:dMe,curveLinearClosed:kMe,curveLinear:fk,curveMonotoneX:AMe,curveMonotoneY:TMe,curveNatural:MMe,curveStep:PMe,curveStepAfter:jMe,curveStepBefore:EMe},sN=t=>Cn(t.x)&&Cn(t.y),zV=t=>t.base!=null&&sN(t.base)&&sN(t),gy=t=>t.x,by=t=>t.y,Uje=(t,e)=>{if(typeof t=="function")return t;var n="curve".concat(gv(t));if((n==="curveMonotone"||n==="curveBump")&&e){var r=IV["".concat(n).concat(e==="vertical"?"Y":"X")];if(r)return r}return IV[n]||fk},UV={connectNulls:!1,type:"linear"},Bje=t=>{var{type:e=UV.type,points:n=[],baseLine:r,layout:i,connectNulls:s=UV.connectNulls}=t,o=Uje(e,i),l=s?n.filter(sN):n;if(Array.isArray(r)){var c,d=n.map((x,v)=>OV(OV({},x),{},{base:r[v]}));i==="vertical"?c=r_().y(by).x1(gy).x0(x=>x.base.x):c=r_().x(gy).y1(by).y0(x=>x.base.y);var u=c.defined(zV).curve(o),h=s?d.filter(zV):d;return u(h)}var f;i==="vertical"&&$t(r)?f=r_().y(by).x1(gy).x0(r):$t(r)?f=r_().x(gy).y1(by).y0(r):f=gQ().x(gy).y(by);var p=f.defined(sN).curve(o);return p(l)},rb=t=>{var{className:e,points:n,path:r,pathRef:i}=t,s=am();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?Bje(o):r;return w.createElement("path",GD({},Ls(t),wL(t),{className:cr("recharts-curve",e),d:l===null?void 0:l,ref:i}))},Hje=["x","y","top","left","width","height","className"];function WD(){return WD=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},WD.apply(null,arguments)}function BV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function $je(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?BV(Object(n),!0).forEach(function(r){Vje(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):BV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Vje(t,e,n){return(e=qje(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function qje(t){var e=Gje(t,"string");return typeof e=="symbol"?e:e+""}function Gje(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Wje(t,e){if(t==null)return{};var n,r,i=Kje(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 Kje(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 Xje=(t,e,n,r,i,s)=>"M".concat(t,",").concat(i,"v").concat(r,"M").concat(s,",").concat(e,"h").concat(n),Yje=t=>{var{x:e=0,y:n=0,top:r=0,left:i=0,width:s=0,height:o=0,className:l}=t,c=Wje(t,Hje),d=$je({x:e,y:n,top:r,left:i,width:s,height:o},c);return!$t(e)||!$t(n)||!$t(s)||!$t(o)||!$t(r)||!$t(i)?null:w.createElement("path",WD({},rs(d),{className:cr("recharts-cross",l),d:Xje(e,n,s,o,r,i)}))};function Qje(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 HV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function $V(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?HV(Object(n),!0).forEach(function(r){Zje(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):HV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Zje(t,e,n){return(e=Jje(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Jje(t){var e=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 t3e=t=>t.replace(/([A-Z])/g,e=>"-".concat(e.toLowerCase())),qZ=(t,e,n)=>t.map(r=>"".concat(t3e(r)," ").concat(e,"ms ").concat(n)).join(","),n3e=(t,e)=>[Object.keys(t),Object.keys(e)].reduce((n,r)=>n.filter(i=>r.includes(i))),F0=(t,e)=>Object.keys(e).reduce((n,r)=>$V($V({},n),{},{[r]:t(r,e[r])}),{});function VV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function ui(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?VV(Object(n),!0).forEach(function(r){r3e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):VV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function r3e(t,e,n){return(e=a3e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function a3e(t){var e=i3e(t,"string");return typeof e=="symbol"?e:e+""}function i3e(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 oN=(t,e,n)=>t+(e-t)*n,KD=t=>{var{from:e,to:n}=t;return e!==n},GZ=(t,e,n)=>{var r=F0((i,s)=>{if(KD(s)){var[o,l]=t(s.from,s.to,s.velocity);return ui(ui({},s),{},{from:o,velocity:l})}return s},e);return n<1?F0((i,s)=>KD(s)&&r[i]!=null?ui(ui({},s),{},{velocity:oN(s.velocity,r[i].velocity,n),from:oN(s.from,r[i].from,n)}):s,e):GZ(t,r,n-1)};function s3e(t,e,n,r,i,s){var o,l=r.reduce((f,p)=>ui(ui({},f),{},{[p]:{from:t[p],velocity:0,to:e[p]}}),{}),c=()=>F0((f,p)=>p.from,l),d=()=>!Object.values(l).filter(KD).length,u=null,h=f=>{o||(o=f);var p=f-o,x=p/n.dt;l=GZ(n,l,x),i(ui(ui(ui({},t),e),c())),o=f,d()||(u=s.setTimeout(h))};return()=>(u=s.setTimeout(h),()=>{var f;(f=u)===null||f===void 0||f()})}function o3e(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:ui(ui({},h),{},{[f]:[p,x]})},{}),d,u=h=>{d||(d=h);var f=(h-d)/r,p=F0((v,g)=>oN(...g,n(f)),c);if(s(ui(ui(ui({},t),e),p)),f<1)l=o.setTimeout(u);else{var x=F0((v,g)=>oN(...g,n(1)),c);s(ui(ui(ui({},t),e),x))}};return()=>(l=o.setTimeout(u),()=>{var h;(h=l)===null||h===void 0||h()})}const l3e=(t,e,n,r,i,s)=>{var o=n3e(t,e);return n==null?()=>(i(ui(ui({},t),e)),()=>{}):n.isStepper===!0?s3e(t,e,n,o,i,s):o3e(t,e,n,r,o,i,s)};var lN=1e-4,WZ=(t,e)=>[0,3*t,3*e-6*t,3*t-3*e+1],KZ=(t,e)=>t.map((n,r)=>n*e**r).reduce((n,r)=>n+r),qV=(t,e)=>n=>{var r=WZ(t,e);return KZ(r,n)},c3e=(t,e)=>n=>{var r=WZ(t,e),i=[...r.map((s,o)=>s*o).slice(1),0];return KZ(i,n)},d3e=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]]},u3e=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=d3e(n[0]);if(i)return i}}return n.length===4?n:[0,0,1,1]},h3e=(t,e,n,r)=>{var i=qV(t,n),s=qV(e,r),o=c3e(t,n),l=d=>d>1?1:d<0?0:d,c=d=>{for(var u=d>1?1:d,h=u,f=0;f<8;++f){var p=i(h)-u,x=o(h);if(Math.abs(p-u)<lN||x<lN)return s(h);h=l(h-p/x)}return s(h)};return c.isStepper=!1,c},GV=function(){return h3e(...u3e(...arguments))},m3e=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 d=-(o-l)*n,u=c*r,h=c+(d-u)*i/1e3,f=c*i/1e3+o;return Math.abs(f-l)<lN&&Math.abs(h)<lN?[l,0]:[f,h]};return s.isStepper=!0,s.dt=i,s},f3e=t=>{if(typeof t=="string")switch(t){case"ease":case"ease-in-out":case"ease-out":case"ease-in":case"linear":return GV(t);case"spring":return m3e();default:if(t.split("(")[0]==="cubic-bezier")return GV(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,...d]=l;if(typeof c=="number"){i=t.setTimeout(s.bind(null,d),c);return}s(c),i=t.setTimeout(s.bind(null,d));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 g3e{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 b3e(){return p3e(new g3e)}var x3e=w.createContext(b3e);function y3e(t,e){var n=w.useContext(x3e);return w.useMemo(()=>e??n(t),[t,e,n])}var v3e=()=>!(typeof window<"u"&&window.document&&window.document.createElement&&window.setTimeout),Nv={isSsr:v3e()},w3e={begin:0,duration:1e3,easing:"ease",isActive:!0,canBegin:!0,onAnimationEnd:()=>{},onAnimationStart:()=>{}},WV={t:0},hE={t:1};function Qb(t){var e=Sa(t,w3e),{isActive:n,canBegin:r,duration:i,easing:s,begin:o,onAnimationEnd:l,onAnimationStart:c,children:d}=e,u=n==="auto"?!Nv.isSsr:n,h=y3e(e.animationId,e.animationManager),[f,p]=w.useState(u?WV:hE),x=w.useRef(null);return w.useEffect(()=>{u||p(hE)},[u]),w.useEffect(()=>{if(!u||!r)return nm;var v=l3e(WV,hE,f3e(s),i,p,h.getTimeoutController()),g=()=>{x.current=v()};return h.start([c,o,g,i,l]),()=>{h.stop(),x.current&&x.current(),l()}},[u,r,i,s,o,c,l,h]),d(f.t)}function Zb(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"animation-",n=w.useRef(T0(e)),r=w.useRef(t);return r.current!==t&&(n.current=T0(e),r.current=t),n.current}var S3e=["radius"],_3e=["radius"],KV,XV,YV,QV,ZV,JV,eq,tq,nq,rq;function aq(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function iq(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?aq(Object(n),!0).forEach(function(r){N3e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):aq(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function N3e(t,e,n){return(e=C3e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function C3e(t){var e=k3e(t,"string");return typeof e=="symbol"?e:e+""}function k3e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function cN(){return cN=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},cN.apply(null,arguments)}function sq(t,e){if(t==null)return{};var n,r,i=A3e(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 A3e(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 gc(t,e){return e||(e=t.slice(0)),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(e)}}))}var oq=(t,e,n,r,i)=>{var s=Nh(n),o=Nh(r),l=Math.min(Math.abs(s)/2,Math.abs(o)/2),c=o>=0?1:-1,d=s>=0?1:-1,u=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(KV||(KV=gc(["M",",",""])),t,e+c*f[0]),f[0]>0&&(h+=Ea(XV||(XV=gc(["A ",",",",0,0,",",",",",""])),f[0],f[0],u,t+d*f[0],e)),h+=Ea(YV||(YV=gc(["L ",",",""])),t+n-d*f[1],e),f[1]>0&&(h+=Ea(QV||(QV=gc(["A ",",",",0,0,",`,
- `,",",""])),f[1],f[1],u,t+n,e+c*f[1])),h+=Ea(ZV||(ZV=gc(["L ",",",""])),t+n,e+r-c*f[2]),f[2]>0&&(h+=Ea(JV||(JV=gc(["A ",",",",0,0,",`,
- `,",",""])),f[2],f[2],u,t+n-d*f[2],e+r)),h+=Ea(eq||(eq=gc(["L ",",",""])),t+d*f[3],e+r),f[3]>0&&(h+=Ea(tq||(tq=gc(["A ",",",",0,0,",`,
- `,",",""])),f[3],f[3],u,t,e+r-c*f[3])),h+="Z"}else if(l>0&&i===+i&&i>0){var y=Math.min(l,i);h=Ea(nq||(nq=gc(["M ",",",`
- A `,",",",0,0,",",",",",`
- L `,",",`
- A `,",",",0,0,",",",",",`
- L `,",",`
- A `,",",",0,0,",",",",",`
- L `,",",`
- A `,",",",0,0,",",",","," Z"])),t,e+c*y,y,y,u,t+d*y,e,t+n-d*y,e,y,y,u,t+n,e+c*y,t+n,e+r-c*y,y,y,u,t+n-d*y,e+r,t+d*y,e+r,y,y,u,t,e+r-c*y)}else h=Ea(rq||(rq=gc(["M ",","," h "," v "," h "," Z"])),t,e,n,r,-n);return h},lq={x:0,y:0,width:0,height:0,radius:0,isAnimationActive:!1,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},XZ=t=>{var e=Sa(t,lq),n=w.useRef(null),[r,i]=w.useState(-1);w.useEffect(()=>{if(n.current&&n.current.getTotalLength)try{var z=n.current.getTotalLength();z&&i(z)}catch{}},[]);var{x:s,y:o,width:l,height:c,radius:d,className:u}=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:d}),[s,o,l,c,d]),k=Zb(A,"rectangle-");if(s!==+s||o!==+o||l!==+l||c!==+c||l===0||c===0)return null;var P=cr("recharts-rectangle",u);if(!v){var C=rs(e),{radius:j}=C,M=sq(C,S3e);return w.createElement("path",cN({},M,{x:Nh(s),y:Nh(o),width:Nh(l),height:Nh(c),radius:typeof d=="number"?d:void 0,className:P,d:oq(s,o,l,c,d)}))}var E=g.current,B=y.current,L=_.current,U=N.current,D="0px ".concat(r===-1?1:r,"px"),$="".concat(r,"px 0px"),q=qZ(["strokeDasharray"],f,typeof h=="string"?h:lq.animationEasing);return w.createElement(Qb,{animationId:k,key:k,canBegin:r>0,duration:f,easing:h,isActive:v,begin:p},z=>{var W=wr(E,l,z),Q=wr(B,c,z),te=wr(L,s,z),H=wr(U,o,z);n.current&&(g.current=W,y.current=Q,_.current=te,N.current=H);var X;x?z>0?X={transition:q,strokeDasharray:$}:X={strokeDasharray:D}:X={strokeDasharray:$};var Z=rs(e),{radius:ee}=Z,Se=sq(Z,_3e);return w.createElement("path",cN({},Se,{radius:typeof d=="number"?d:void 0,className:P,d:oq(te,H,W,Q,d),ref:n,style:iq(iq({},X),e.style)}))})};function cq(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?cq(Object(n),!0).forEach(function(r){T3e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):cq(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function T3e(t,e,n){return(e=M3e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function M3e(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 dN=Math.PI/180,E3e=t=>t*180/Math.PI,ti=(t,e,n,r)=>({x:t+Math.cos(-dN*r)*n,y:e+Math.sin(-dN*r)*n}),YZ=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},j3e=(t,e)=>{var{x:n,y:r}=t,{x:i,y:s}=e;return Math.sqrt((n-i)**2+(r-s)**2)},D3e=(t,e)=>{var{x:n,y:r}=t,{cx:i,cy:s}=e,o=j3e({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:E3e(c),angleInRadian:c}},R3e=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}},F3e=(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},L3e=(t,e)=>{var{chartX:n,chartY:r}=t,{radius:i,angle:s}=D3e({x:n,y:r},e),{innerRadius:o,outerRadius:l}=e;if(i<o||i>l||i===0)return null;var{startAngle:c,endAngle:d}=R3e(e),u=s,h;if(c<=d){for(;u>d;)u-=360;for(;u<c;)u+=360;h=u>=c&&u<=d}else{for(;u>c;)u-=360;for(;u<d;)u+=360;h=u>=d&&u<=c}return h?dq(dq({},e),{},{radius:i,angle:F3e(u,e)}):null};function QZ(t){var{cx:e,cy:n,radius:r,startAngle:i,endAngle:s}=t,o=ti(e,n,r,i),l=ti(e,n,r,s);return{points:[o,l],cx:e,cy:n,radius:r,startAngle:i,endAngle:s}}var uq,hq,mq,fq,pq,gq,bq;function XD(){return XD=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},XD.apply(null,arguments)}function nf(t,e){return e||(e=t.slice(0)),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(e)}}))}var O3e=(t,e)=>{var n=Ri(e-t),r=Math.min(Math.abs(e-t),359.999);return n*r},h_=t=>{var{cx:e,cy:n,radius:r,angle:i,sign:s,isExternal:o,cornerRadius:l,cornerIsExternal:c}=t,d=l*(o?1:-1)+r,u=Math.asin(l/d)/dN,h=c?i:i+s*u,f=ti(e,n,d,h),p=ti(e,n,r,h),x=c?i-s*u:i,v=ti(e,n,d*Math.cos(u*dN),x);return{center:f,circleTangency:p,lineTangency:v,theta:u}},ZZ=t=>{var{cx:e,cy:n,innerRadius:r,outerRadius:i,startAngle:s,endAngle:o}=t,l=O3e(s,o),c=s+l,d=ti(e,n,i,s),u=ti(e,n,i,c),h=Ea(uq||(uq=nf(["M ",",",`
- A `,",",`,0,
- `,",",`,
- `,",",`
- `])),d.x,d.y,i,i,+(Math.abs(l)>180),+(s>c),u.x,u.y);if(r>0){var f=ti(e,n,r,s),p=ti(e,n,r,c);h+=Ea(hq||(hq=nf(["L ",",",`
- A `,",",`,0,
- `,",",`,
- `,","," Z"])),p.x,p.y,r,r,+(Math.abs(l)>180),+(s<=c),f.x,f.y)}else h+=Ea(mq||(mq=nf(["L ",","," Z"])),e,n);return h},I3e=t=>{var{cx:e,cy:n,innerRadius:r,outerRadius:i,cornerRadius:s,forceCornerRadius:o,cornerIsExternal:l,startAngle:c,endAngle:d}=t,u=Ri(d-c),{circleTangency:h,lineTangency:f,theta:p}=h_({cx:e,cy:n,radius:i,angle:c,sign:u,cornerRadius:s,cornerIsExternal:l}),{circleTangency:x,lineTangency:v,theta:g}=h_({cx:e,cy:n,radius:i,angle:d,sign:-u,cornerRadius:s,cornerIsExternal:l}),y=l?Math.abs(c-d):Math.abs(c-d)-p-g;if(y<0)return o?Ea(fq||(fq=nf(["M ",",",`
- a`,",",",0,0,1,",`,0
- a`,",",",0,0,1,",`,0
- `])),f.x,f.y,s,s,s*2,s,s,-s*2):ZZ({cx:e,cy:n,innerRadius:r,outerRadius:i,startAngle:c,endAngle:d});var _=Ea(pq||(pq=nf(["M ",",",`
- A`,",",",0,0,",",",",",`
- A`,",",",0,",",",",",",",`
- A`,",",",0,0,",",",",",`
- `])),f.x,f.y,s,s,+(u<0),h.x,h.y,i,i,+(y>180),+(u<0),x.x,x.y,s,s,+(u<0),v.x,v.y);if(r>0){var{circleTangency:N,lineTangency:A,theta:k}=h_({cx:e,cy:n,radius:r,angle:c,sign:u,isExternal:!0,cornerRadius:s,cornerIsExternal:l}),{circleTangency:P,lineTangency:C,theta:j}=h_({cx:e,cy:n,radius:r,angle:d,sign:-u,isExternal:!0,cornerRadius:s,cornerIsExternal:l}),M=l?Math.abs(c-d):Math.abs(c-d)-k-j;if(M<0&&s===0)return"".concat(_,"L").concat(e,",").concat(n,"Z");_+=Ea(gq||(gq=nf(["L",",",`
- A`,",",",0,0,",",",",",`
- A`,",",",0,",",",",",",",`
- A`,",",",0,0,",",",",","Z"])),C.x,C.y,s,s,+(u<0),P.x,P.y,r,r,+(M>180),+(u>0),N.x,N.y,s,s,+(u<0),A.x,A.y)}else _+=Ea(bq||(bq=nf(["L",",","Z"])),e,n);return _},z3e={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},JZ=t=>{var e=Sa(t,z3e),{cx:n,cy:r,innerRadius:i,outerRadius:s,cornerRadius:o,forceCornerRadius:l,cornerIsExternal:c,startAngle:d,endAngle:u,className:h}=e;if(s<i||d===u)return null;var f=cr("recharts-sector",h),p=s-i,x=ys(o,p,0,!0),v;return x>0&&Math.abs(d-u)<360?v=I3e({cx:n,cy:r,innerRadius:i,outerRadius:s,cornerRadius:Math.min(x,p/2),forceCornerRadius:l,cornerIsExternal:c,startAngle:d,endAngle:u}):v=ZZ({cx:n,cy:r,innerRadius:i,outerRadius:s,startAngle:d,endAngle:u}),w.createElement("path",XD({},rs(e),{className:f,d:v}))};function U3e(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(EQ(e)){if(t==="centric"){var{cx:r,cy:i,innerRadius:s,outerRadius:o,angle:l}=e,c=ti(r,i,s,l),d=ti(r,i,o,l);return[{x:c.x,y:c.y},{x:d.x,y:d.y}]}return QZ(e)}}var mE={},fE={},pE={},xq;function B3e(){return xq||(xq=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=$Q();function n(r){return e.isSymbol(r)?NaN:Number(r)}t.toNumber=n})(pE)),pE}var yq;function H3e(){return yq||(yq=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=B3e();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})(fE)),fE}var vq;function $3e(){return vq||(vq=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=VQ(),n=H3e();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 d=0;d<l;d++)c[d]=i,i+=o;return c}t.range=r})(mE)),mE}var gE,wq;function V3e(){return wq||(wq=1,gE=$3e().range),gE}var q3e=V3e();const eJ=rc(q3e);function zh(t,e){return t==null||e==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function G3e(t,e){return t==null||e==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function UL(t){let e,n,r;t.length!==2?(e=zh,n=(l,c)=>zh(t(l),c),r=(l,c)=>t(l)-c):(e=t===zh||t===G3e?t:W3e,n=t,r=t);function i(l,c,d=0,u=l.length){if(d<u){if(e(c,c)!==0)return u;do{const h=d+u>>>1;n(l[h],c)<0?d=h+1:u=h}while(d<u)}return d}function s(l,c,d=0,u=l.length){if(d<u){if(e(c,c)!==0)return u;do{const h=d+u>>>1;n(l[h],c)<=0?d=h+1:u=h}while(d<u)}return d}function o(l,c,d=0,u=l.length){const h=i(l,c,d,u-1);return h>d&&r(l[h-1],c)>-r(l[h],c)?h-1:h}return{left:i,center:o,right:s}}function W3e(){return 0}function tJ(t){return t===null?NaN:+t}function*K3e(t,e){for(let n of t)n!=null&&(n=+n)>=n&&(yield n)}const X3e=UL(zh),Cv=X3e.right;UL(tJ).center;class Sq extends Map{constructor(e,n=Z3e){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(_q(this,e))}has(e){return super.has(_q(this,e))}set(e,n){return super.set(Y3e(this,e),n)}delete(e){return super.delete(Q3e(this,e))}}function _q({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):n}function Y3e({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):(t.set(r,n),n)}function Q3e({_intern:t,_key:e},n){const r=e(n);return t.has(r)&&(n=t.get(r),t.delete(r)),n}function Z3e(t){return t!==null&&typeof t=="object"?t.valueOf():t}function J3e(t=zh){if(t===zh)return nJ;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 nJ(t,e){return(t==null||!(t>=t))-(e==null||!(e>=e))||(t<e?-1:t>e?1:0)}const eDe=Math.sqrt(50),tDe=Math.sqrt(10),nDe=Math.sqrt(2);function uN(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>=eDe?10:s>=tDe?5:s>=nDe?2:1;let l,c,d;return i<0?(d=Math.pow(10,-i)/o,l=Math.round(t*d),c=Math.round(e*d),l/d<t&&++l,c/d>e&&--c,d=-d):(d=Math.pow(10,i)*o,l=Math.round(t/d),c=Math.round(e/d),l*d<t&&++l,c*d>e&&--c),c<l&&.5<=n&&n<2?uN(t,e,n*2):[l,c,d]}function YD(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?uN(e,t,n):uN(t,e,n);if(!(s>=i))return[];const l=s-i+1,c=new Array(l);if(r)if(o<0)for(let d=0;d<l;++d)c[d]=(s-d)/-o;else for(let d=0;d<l;++d)c[d]=(s-d)*o;else if(o<0)for(let d=0;d<l;++d)c[d]=(i+d)/-o;else for(let d=0;d<l;++d)c[d]=(i+d)*o;return c}function QD(t,e,n){return e=+e,t=+t,n=+n,uN(t,e,n)[2]}function ZD(t,e,n){e=+e,t=+t,n=+n;const r=e<t,i=r?QD(e,t,n):QD(t,e,n);return(r?-1:1)*(i<0?1/-i:i)}function Nq(t,e){let n;for(const r of t)r!=null&&(n<r||n===void 0&&r>=r)&&(n=r);return n}function Cq(t,e){let n;for(const r of t)r!=null&&(n>r||n===void 0&&r>=r)&&(n=r);return n}function rJ(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?nJ:J3e(i);r>n;){if(r-n>600){const c=r-n+1,d=e-n+1,u=Math.log(c),h=.5*Math.exp(2*u/3),f=.5*Math.sqrt(u*h*(c-h)/c)*(d-c/2<0?-1:1),p=Math.max(n,Math.floor(e-d*h/c+f)),x=Math.min(r,Math.floor(e+(c-d)*h/c+f));rJ(t,e,p,x,i)}const s=t[e];let o=n,l=r;for(xy(t,n,e),i(t[r],s)>0&&xy(t,n,r);o<l;){for(xy(t,o,l),++o,--l;i(t[o],s)<0;)++o;for(;i(t[l],s)>0;)--l}i(t[n],s)===0?xy(t,n,l):(++l,xy(t,l,r)),l<=e&&(n=l+1),e<=l&&(r=l-1)}return t}function xy(t,e,n){const r=t[e];t[e]=t[n],t[n]=r}function rDe(t,e,n){if(t=Float64Array.from(K3e(t)),!(!(r=t.length)||isNaN(e=+e))){if(e<=0||r<2)return Cq(t);if(e>=1)return Nq(t);var r,i=(r-1)*e,s=Math.floor(i),o=Nq(rJ(t,s).subarray(0,s+1)),l=Cq(t.subarray(s+1));return o+(l-o)*(i-s)}}function aDe(t,e,n=tJ){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 iDe(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 Ml(t,e){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(e).domain(t);break}return this}function bu(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 JD=Symbol("implicit");function BL(){var t=new Sq,e=[],n=[],r=JD;function i(s){let o=t.get(s);if(o===void 0){if(r!==JD)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 Sq;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 BL(e,n).unknown(r)},Ml.apply(i,arguments),i}function HL(){var t=BL().unknown(void 0),e=t.domain,n=t.range,r=0,i=1,s,o,l=!1,c=0,d=0,u=.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+d*2),l&&(s=Math.floor(s)),x+=(v-x-s*(f-c))*u,o=s*(1-c),l&&(x=Math.round(x),o=Math.round(o));var g=iDe(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,d=+f),h()):c},t.paddingInner=function(f){return arguments.length?(c=Math.min(1,f),h()):c},t.paddingOuter=function(f){return arguments.length?(d=+f,h()):d},t.align=function(f){return arguments.length?(u=Math.max(0,Math.min(1,f)),h()):u},t.copy=function(){return HL(e(),[r,i]).round(l).paddingInner(c).paddingOuter(d).align(u)},Ml.apply(h(),arguments)}function aJ(t){var e=t.copy;return t.padding=t.paddingOuter,delete t.paddingInner,delete t.paddingOuter,t.copy=function(){return aJ(e())},t}function sDe(){return aJ(HL.apply(null,arguments).paddingInner(1))}function $L(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function iJ(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function kv(){}var L0=.7,hN=1/L0,ab="\\s*([+-]?\\d+)\\s*",O0="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Fc="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",oDe=/^#([0-9a-f]{3,8})$/,lDe=new RegExp(`^rgb\\(${ab},${ab},${ab}\\)$`),cDe=new RegExp(`^rgb\\(${Fc},${Fc},${Fc}\\)$`),dDe=new RegExp(`^rgba\\(${ab},${ab},${ab},${O0}\\)$`),uDe=new RegExp(`^rgba\\(${Fc},${Fc},${Fc},${O0}\\)$`),hDe=new RegExp(`^hsl\\(${O0},${Fc},${Fc}\\)$`),mDe=new RegExp(`^hsla\\(${O0},${Fc},${Fc},${O0}\\)$`),kq={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};$L(kv,I0,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:Aq,formatHex:Aq,formatHex8:fDe,formatHsl:pDe,formatRgb:Tq,toString:Tq});function Aq(){return this.rgb().formatHex()}function fDe(){return this.rgb().formatHex8()}function pDe(){return sJ(this).formatHsl()}function Tq(){return this.rgb().formatRgb()}function I0(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=oDe.exec(t))?(n=e[1].length,e=parseInt(e[1],16),n===6?Mq(e):n===3?new no(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):n===8?m_(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):n===4?m_(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=lDe.exec(t))?new no(e[1],e[2],e[3],1):(e=cDe.exec(t))?new no(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=dDe.exec(t))?m_(e[1],e[2],e[3],e[4]):(e=uDe.exec(t))?m_(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=hDe.exec(t))?jq(e[1],e[2]/100,e[3]/100,1):(e=mDe.exec(t))?jq(e[1],e[2]/100,e[3]/100,e[4]):kq.hasOwnProperty(t)?Mq(kq[t]):t==="transparent"?new no(NaN,NaN,NaN,0):null}function Mq(t){return new no(t>>16&255,t>>8&255,t&255,1)}function m_(t,e,n,r){return r<=0&&(t=e=n=NaN),new no(t,e,n,r)}function gDe(t){return t instanceof kv||(t=I0(t)),t?(t=t.rgb(),new no(t.r,t.g,t.b,t.opacity)):new no}function eR(t,e,n,r){return arguments.length===1?gDe(t):new no(t,e,n,r??1)}function no(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}$L(no,eR,iJ(kv,{brighter(t){return t=t==null?hN:Math.pow(hN,t),new no(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?L0:Math.pow(L0,t),new no(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new no(bf(this.r),bf(this.g),bf(this.b),mN(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:Pq,formatHex:Pq,formatHex8:bDe,formatRgb:Eq,toString:Eq}));function Pq(){return`#${rf(this.r)}${rf(this.g)}${rf(this.b)}`}function bDe(){return`#${rf(this.r)}${rf(this.g)}${rf(this.b)}${rf((isNaN(this.opacity)?1:this.opacity)*255)}`}function Eq(){const t=mN(this.opacity);return`${t===1?"rgb(":"rgba("}${bf(this.r)}, ${bf(this.g)}, ${bf(this.b)}${t===1?")":`, ${t})`}`}function mN(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function bf(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function rf(t){return t=bf(t),(t<16?"0":"")+t.toString(16)}function jq(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new Vl(t,e,n,r)}function sJ(t){if(t instanceof Vl)return new Vl(t.h,t.s,t.l,t.opacity);if(t instanceof kv||(t=I0(t)),!t)return new Vl;if(t instanceof Vl)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 Vl(o,l,c,t.opacity)}function xDe(t,e,n,r){return arguments.length===1?sJ(t):new Vl(t,e,n,r??1)}function Vl(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}$L(Vl,xDe,iJ(kv,{brighter(t){return t=t==null?hN:Math.pow(hN,t),new Vl(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?L0:Math.pow(L0,t),new Vl(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 no(bE(t>=240?t-240:t+120,i,r),bE(t,i,r),bE(t<120?t+240:t-120,i,r),this.opacity)},clamp(){return new Vl(Dq(this.h),f_(this.s),f_(this.l),mN(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=mN(this.opacity);return`${t===1?"hsl(":"hsla("}${Dq(this.h)}, ${f_(this.s)*100}%, ${f_(this.l)*100}%${t===1?")":`, ${t})`}`}}));function Dq(t){return t=(t||0)%360,t<0?t+360:t}function f_(t){return Math.max(0,Math.min(1,t||0))}function bE(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 VL=t=>()=>t;function yDe(t,e){return function(n){return t+n*e}}function vDe(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 wDe(t){return(t=+t)==1?oJ:function(e,n){return n-e?vDe(e,n,t):VL(isNaN(e)?n:e)}}function oJ(t,e){var n=e-t;return n?yDe(t,n):VL(isNaN(t)?e:t)}const Rq=(function t(e){var n=wDe(e);function r(i,s){var o=n((i=eR(i)).r,(s=eR(s)).r),l=n(i.g,s.g),c=n(i.b,s.b),d=oJ(i.opacity,s.opacity);return function(u){return i.r=o(u),i.g=l(u),i.b=c(u),i.opacity=d(u),i+""}}return r.gamma=t,r})(1);function SDe(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 _De(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function NDe(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]=Jb(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 CDe(t,e){var n=new Date;return t=+t,e=+e,function(r){return n.setTime(t*(1-r)+e*r),n}}function fN(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}function kDe(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]=Jb(t[i],e[i]):r[i]=e[i];return function(s){for(i in n)r[i]=n[i](s);return r}}var tR=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,xE=new RegExp(tR.source,"g");function ADe(t){return function(){return t}}function TDe(t){return function(e){return t(e)+""}}function MDe(t,e){var n=tR.lastIndex=xE.lastIndex=0,r,i,s,o=-1,l=[],c=[];for(t=t+"",e=e+"";(r=tR.exec(t))&&(i=xE.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:fN(r,i)})),n=xE.lastIndex;return n<e.length&&(s=e.slice(n),l[o]?l[o]+=s:l[++o]=s),l.length<2?c[0]?TDe(c[0].x):ADe(e):(e=c.length,function(d){for(var u=0,h;u<e;++u)l[(h=c[u]).i]=h.x(d);return l.join("")})}function Jb(t,e){var n=typeof e,r;return e==null||n==="boolean"?VL(e):(n==="number"?fN:n==="string"?(r=I0(e))?(e=r,Rq):MDe:e instanceof I0?Rq:e instanceof Date?CDe:_De(e)?SDe:Array.isArray(e)?NDe:typeof e.valueOf!="function"&&typeof e.toString!="function"||isNaN(e)?kDe:fN)(t,e)}function qL(t,e){return t=+t,e=+e,function(n){return Math.round(t*(1-n)+e*n)}}function PDe(t,e){e===void 0&&(e=t,t=Jb);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 EDe(t){return function(){return t}}function pN(t){return+t}var Fq=[0,1];function Es(t){return t}function nR(t,e){return(e-=t=+t)?function(n){return(n-t)/e}:EDe(isNaN(e)?NaN:.5)}function jDe(t,e){var n;return t>e&&(n=t,t=e,e=n),function(r){return Math.max(t,Math.min(e,r))}}function DDe(t,e,n){var r=t[0],i=t[1],s=e[0],o=e[1];return i<r?(r=nR(i,r),s=n(o,s)):(r=nR(r,i),s=n(s,o)),function(l){return s(r(l))}}function RDe(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]=nR(t[o],t[o+1]),s[o]=n(e[o],e[o+1]);return function(l){var c=Cv(t,l,1,r)-1;return s[c](i[c](l))}}function Av(t,e){return e.domain(t.domain()).range(t.range()).interpolate(t.interpolate()).clamp(t.clamp()).unknown(t.unknown())}function Dk(){var t=Fq,e=Fq,n=Jb,r,i,s,o=Es,l,c,d;function u(){var f=Math.min(t.length,e.length);return o!==Es&&(o=jDe(t[0],t[f-1])),l=f>2?RDe:DDe,c=d=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((d||(d=l(e,t.map(r),fN)))(f)))},h.domain=function(f){return arguments.length?(t=Array.from(f,pN),u()):t.slice()},h.range=function(f){return arguments.length?(e=Array.from(f),u()):e.slice()},h.rangeRound=function(f){return e=Array.from(f),n=qL,u()},h.clamp=function(f){return arguments.length?(o=f?!0:Es,u()):o!==Es},h.interpolate=function(f){return arguments.length?(n=f,u()):n},h.unknown=function(f){return arguments.length?(s=f,h):s},function(f,p){return r=f,i=p,u()}}function GL(){return Dk()(Es,Es)}function FDe(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)}function gN(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 kb(t){return t=gN(Math.abs(t)),t?t[1]:NaN}function LDe(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 ODe(t){return function(e){return e.replace(/[0-9]/g,function(n){return t[+n]})}}var IDe=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function z0(t){if(!(e=IDe.exec(t)))throw new Error("invalid format: "+t);var e;return new WL({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]})}z0.prototype=WL.prototype;function WL(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+""}WL.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 zDe(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 bN;function UDe(t,e){var n=gN(t,e);if(!n)return bN=void 0,t.toPrecision(e);var r=n[0],i=n[1],s=i-(bN=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")+gN(t,Math.max(0,e+s-1))[0]}function Lq(t,e){var n=gN(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 Oq={"%":(t,e)=>(t*100).toFixed(e),b:t=>Math.round(t).toString(2),c:t=>t+"",d:FDe,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)=>Lq(t*100,e),r:Lq,s:UDe,X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function Iq(t){return t}var zq=Array.prototype.map,Uq=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function BDe(t){var e=t.grouping===void 0||t.thousands===void 0?Iq:LDe(zq.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?Iq:ODe(zq.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 d(h,f){h=z0(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,k=h.trim,P=h.type;P==="n"?(N=!0,P="g"):Oq[P]||(A===void 0&&(A=12),k=!0,P="g"),(y||p==="0"&&x==="=")&&(y=!0,p="0",x="=");var C=(f&&f.prefix!==void 0?f.prefix:"")+(g==="$"?n:g==="#"&&/[boxX]/.test(P)?"0"+P.toLowerCase():""),j=(g==="$"?r:/[%p]/.test(P)?o:"")+(f&&f.suffix!==void 0?f.suffix:""),M=Oq[P],E=/[defgprs%]/.test(P);A=A===void 0?6:/[gprs]/.test(P)?Math.max(1,Math.min(21,A)):Math.max(0,Math.min(20,A));function B(L){var U=C,D=j,$,q,z;if(P==="c")D=M(L)+D,L="";else{L=+L;var W=L<0||1/L<0;if(L=isNaN(L)?c:M(Math.abs(L),A),k&&(L=zDe(L)),W&&+L==0&&v!=="+"&&(W=!1),U=(W?v==="("?v:l:v==="-"||v==="("?"":v)+U,D=(P==="s"&&!isNaN(L)&&bN!==void 0?Uq[8+bN/3]:"")+D+(W&&v==="("?")":""),E){for($=-1,q=L.length;++$<q;)if(z=L.charCodeAt($),48>z||z>57){D=(z===46?i+L.slice($+1):L.slice($))+D,L=L.slice(0,$);break}}}N&&!y&&(L=e(L,1/0));var Q=U.length+L.length+D.length,te=Q<_?new Array(_-Q+1).join(p):"";switch(N&&y&&(L=e(te+L,te.length?_-D.length:1/0),te=""),x){case"<":L=U+L+D+te;break;case"=":L=U+te+L+D;break;case"^":L=te.slice(0,Q=te.length>>1)+U+L+D+te.slice(Q);break;default:L=te+U+L+D;break}return s(L)}return B.toString=function(){return h+""},B}function u(h,f){var p=Math.max(-8,Math.min(8,Math.floor(kb(f)/3)))*3,x=Math.pow(10,-p),v=d((h=z0(h),h.type="f",h),{suffix:Uq[8+p/3]});return function(g){return v(x*g)}}return{format:d,formatPrefix:u}}var p_,KL,lJ;HDe({thousands:",",grouping:[3],currency:["$",""]});function HDe(t){return p_=BDe(t),KL=p_.format,lJ=p_.formatPrefix,p_}function $De(t){return Math.max(0,-kb(Math.abs(t)))}function VDe(t,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(kb(e)/3)))*3-kb(Math.abs(t)))}function qDe(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,kb(e)-kb(t))+1}function cJ(t,e,n,r){var i=ZD(t,e,n),s;switch(r=z0(r??",f"),r.type){case"s":{var o=Math.max(Math.abs(t),Math.abs(e));return r.precision==null&&!isNaN(s=VDe(i,o))&&(r.precision=s),lJ(r,o)}case"":case"e":case"g":case"p":case"r":{r.precision==null&&!isNaN(s=qDe(i,Math.max(Math.abs(t),Math.abs(e))))&&(r.precision=s-(r.type==="e"));break}case"f":case"%":{r.precision==null&&!isNaN(s=$De(i))&&(r.precision=s-(r.type==="%")*2);break}}return KL(r)}function im(t){var e=t.domain;return t.ticks=function(n){var r=e();return YD(r[0],r[r.length-1],n??10)},t.tickFormat=function(n,r){var i=e();return cJ(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,d,u=10;for(l<o&&(d=o,o=l,l=d,d=i,i=s,s=d);u-- >0;){if(d=QD(o,l,n),d===c)return r[i]=o,r[s]=l,e(r);if(d>0)o=Math.floor(o/d)*d,l=Math.ceil(l/d)*d;else if(d<0)o=Math.ceil(o*d)/d,l=Math.floor(l*d)/d;else break;c=d}return t},t}function dJ(){var t=GL();return t.copy=function(){return Av(t,dJ())},Ml.apply(t,arguments),im(t)}function uJ(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,pN),n):t.slice()},n.unknown=function(r){return arguments.length?(e=r,n):e},n.copy=function(){return uJ(t).unknown(e)},t=arguments.length?Array.from(t,pN):[0,1],im(n)}function hJ(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 Bq(t){return Math.log(t)}function Hq(t){return Math.exp(t)}function GDe(t){return-Math.log(-t)}function WDe(t){return-Math.exp(-t)}function KDe(t){return isFinite(t)?+("1e"+t):t<0?0:t}function XDe(t){return t===10?KDe:t===Math.E?Math.exp:e=>Math.pow(t,e)}function YDe(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 $q(t){return(e,n)=>-t(-e,n)}function XL(t){const e=t(Bq,Hq),n=e.domain;let r=10,i,s;function o(){return i=YDe(r),s=XDe(r),n()[0]<0?(i=$q(i),s=$q(s),t(GDe,WDe)):t(Bq,Hq),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 d=c[0],u=c[c.length-1];const h=u<d;h&&([d,u]=[u,d]);let f=i(d),p=i(u),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),d>0){for(;f<=p;++f)for(x=1;x<r;++x)if(v=f<0?x/s(-f):x*s(f),!(v<d)){if(v>u)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<d)){if(v>u)break;y.push(v)}y.length*2<g&&(y=YD(d,u,g))}else y=YD(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=z0(c)).precision==null&&(c.trim=!0),c=KL(c)),l===1/0)return c;const d=Math.max(1,r*l/e.ticks().length);return u=>{let h=u/s(Math.round(i(u)));return h*r<r-.5&&(h*=r),h<=d?c(u):""}},e.nice=()=>n(hJ(n(),{floor:l=>s(Math.floor(i(l))),ceil:l=>s(Math.ceil(i(l)))})),e}function mJ(){const t=XL(Dk()).domain([1,10]);return t.copy=()=>Av(t,mJ()).base(t.base()),Ml.apply(t,arguments),t}function Vq(t){return function(e){return Math.sign(e)*Math.log1p(Math.abs(e/t))}}function qq(t){return function(e){return Math.sign(e)*Math.expm1(Math.abs(e))*t}}function YL(t){var e=1,n=t(Vq(e),qq(e));return n.constant=function(r){return arguments.length?t(Vq(e=+r),qq(e)):e},im(n)}function fJ(){var t=YL(Dk());return t.copy=function(){return Av(t,fJ()).constant(t.constant())},Ml.apply(t,arguments)}function Gq(t){return function(e){return e<0?-Math.pow(-e,t):Math.pow(e,t)}}function QDe(t){return t<0?-Math.sqrt(-t):Math.sqrt(t)}function ZDe(t){return t<0?-t*t:t*t}function QL(t){var e=t(Es,Es),n=1;function r(){return n===1?t(Es,Es):n===.5?t(QDe,ZDe):t(Gq(n),Gq(1/n))}return e.exponent=function(i){return arguments.length?(n=+i,r()):n},im(e)}function ZL(){var t=QL(Dk());return t.copy=function(){return Av(t,ZL()).exponent(t.exponent())},Ml.apply(t,arguments),t}function JDe(){return ZL.apply(null,arguments).exponent(.5)}function Wq(t){return Math.sign(t)*t*t}function eRe(t){return Math.sign(t)*Math.sqrt(Math.abs(t))}function pJ(){var t=GL(),e=[0,1],n=!1,r;function i(s){var o=eRe(t(s));return isNaN(o)?r:n?Math.round(o):o}return i.invert=function(s){return t.invert(Wq(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,pN)).map(Wq)),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 pJ(t.domain(),e).round(n).clamp(t.clamp()).unknown(r)},Ml.apply(i,arguments),im(i)}function gJ(){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]=aDe(t,o/l);return s}function s(o){return o==null||isNaN(o=+o)?r:e[Cv(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(zh),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 gJ().domain(t).range(e).unknown(r)},Ml.apply(s,arguments)}function bJ(){var t=0,e=1,n=1,r=[.5],i=[0,1],s;function o(c){return c!=null&&c<=c?i[Cv(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 d=i.indexOf(c);return d<0?[NaN,NaN]:d<1?[t,r[0]]:d>=n?[r[n-1],e]:[r[d-1],r[d]]},o.unknown=function(c){return arguments.length&&(s=c),o},o.thresholds=function(){return r.slice()},o.copy=function(){return bJ().domain([t,e]).range(i).unknown(s)},Ml.apply(im(o),arguments)}function xJ(){var t=[.5],e=[0,1],n,r=1;function i(s){return s!=null&&s<=s?e[Cv(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 xJ().domain(t).range(e).unknown(n)},Ml.apply(i,arguments)}const yE=new Date,vE=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 d;do c.push(d=new Date(+s)),e(s,l),t(s);while(d<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)=>(yE.setTime(+s),vE.setTime(+o),t(yE),t(vE),Math.floor(n(yE,vE))),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 xN=Si(()=>{},(t,e)=>{t.setTime(+t+e)},(t,e)=>e-t);xN.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):xN);xN.range;const Bd=1e3,pl=Bd*60,Hd=pl*60,lu=Hd*24,JL=lu*7,Kq=lu*30,wE=lu*365,af=Si(t=>{t.setTime(t-t.getMilliseconds())},(t,e)=>{t.setTime(+t+e*Bd)},(t,e)=>(e-t)/Bd,t=>t.getUTCSeconds());af.range;const e4=Si(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*Bd)},(t,e)=>{t.setTime(+t+e*pl)},(t,e)=>(e-t)/pl,t=>t.getMinutes());e4.range;const t4=Si(t=>{t.setUTCSeconds(0,0)},(t,e)=>{t.setTime(+t+e*pl)},(t,e)=>(e-t)/pl,t=>t.getUTCMinutes());t4.range;const n4=Si(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*Bd-t.getMinutes()*pl)},(t,e)=>{t.setTime(+t+e*Hd)},(t,e)=>(e-t)/Hd,t=>t.getHours());n4.range;const r4=Si(t=>{t.setUTCMinutes(0,0,0)},(t,e)=>{t.setTime(+t+e*Hd)},(t,e)=>(e-t)/Hd,t=>t.getUTCHours());r4.range;const Tv=Si(t=>t.setHours(0,0,0,0),(t,e)=>t.setDate(t.getDate()+e),(t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*pl)/lu,t=>t.getDate()-1);Tv.range;const Rk=Si(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/lu,t=>t.getUTCDate()-1);Rk.range;const yJ=Si(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/lu,t=>Math.floor(t/lu));yJ.range;function rp(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())*pl)/JL)}const Fk=rp(0),yN=rp(1),tRe=rp(2),nRe=rp(3),Ab=rp(4),rRe=rp(5),aRe=rp(6);Fk.range;yN.range;tRe.range;nRe.range;Ab.range;rRe.range;aRe.range;function ap(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)/JL)}const Lk=ap(0),vN=ap(1),iRe=ap(2),sRe=ap(3),Tb=ap(4),oRe=ap(5),lRe=ap(6);Lk.range;vN.range;iRe.range;sRe.range;Tb.range;oRe.range;lRe.range;const a4=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());a4.range;const i4=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());i4.range;const cu=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());cu.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)});cu.range;const du=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());du.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)});du.range;function vJ(t,e,n,r,i,s){const o=[[af,1,Bd],[af,5,5*Bd],[af,15,15*Bd],[af,30,30*Bd],[s,1,pl],[s,5,5*pl],[s,15,15*pl],[s,30,30*pl],[i,1,Hd],[i,3,3*Hd],[i,6,6*Hd],[i,12,12*Hd],[r,1,lu],[r,2,2*lu],[n,1,JL],[e,1,Kq],[e,3,3*Kq],[t,1,wE]];function l(d,u,h){const f=u<d;f&&([d,u]=[u,d]);const p=h&&typeof h.range=="function"?h:c(d,u,h),x=p?p.range(d,+u+1):[];return f?x.reverse():x}function c(d,u,h){const f=Math.abs(u-d)/h,p=UL(([,,g])=>g).right(o,f);if(p===o.length)return t.every(ZD(d/wE,u/wE,h));if(p===0)return xN.every(Math.max(ZD(d,u,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[cRe,dRe]=vJ(du,i4,Lk,yJ,r4,t4),[uRe,hRe]=vJ(cu,a4,Fk,Tv,n4,e4);function SE(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 _E(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 yy(t,e,n){return{y:t,m:e,d:n,H:0,M:0,S:0,L:0}}function mRe(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,d=vy(i),u=wy(i),h=vy(s),f=wy(s),p=vy(o),x=wy(o),v=vy(l),g=wy(l),y=vy(c),_=wy(c),N={a:z,A:W,b:Q,B:te,c:null,d:eG,e:eG,f:LRe,g:GRe,G:KRe,H:DRe,I:RRe,j:FRe,L:wJ,m:ORe,M:IRe,p:H,q:X,Q:rG,s:aG,S:zRe,u:URe,U:BRe,V:HRe,w:$Re,W:VRe,x:null,X:null,y:qRe,Y:WRe,Z:XRe,"%":nG},A={a:Z,A:ee,b:Se,B:oe,c:null,d:tG,e:tG,f:JRe,g:cFe,G:uFe,H:YRe,I:QRe,j:ZRe,L:_J,m:eFe,M:tFe,p:ie,q:me,Q:rG,s:aG,S:nFe,u:rFe,U:aFe,V:iFe,w:sFe,W:oFe,x:null,X:null,y:lFe,Y:dFe,Z:hFe,"%":nG},k={a:E,A:B,b:L,B:U,c:D,d:Zq,e:Zq,f:MRe,g:Qq,G:Yq,H:Jq,I:Jq,j:CRe,L:TRe,m:NRe,M:kRe,p:M,q:_Re,Q:ERe,s:jRe,S:ARe,u:xRe,U:yRe,V:vRe,w:bRe,W:wRe,x:$,X:q,y:Qq,Y:Yq,Z:SRe,"%":PRe};N.x=P(n,N),N.X=P(r,N),N.c=P(e,N),A.x=P(n,A),A.X=P(r,A),A.c=P(e,A);function P(se,ce){return function(Ce){var le=[],Le=-1,V=0,K=se.length,fe,Y,re;for(Ce instanceof Date||(Ce=new Date(+Ce));++Le<K;)se.charCodeAt(Le)===37&&(le.push(se.slice(V,Le)),(Y=Xq[fe=se.charAt(++Le)])!=null?fe=se.charAt(++Le):Y=fe==="e"?" ":"0",(re=ce[fe])&&(fe=re(Ce,Y)),le.push(fe),V=Le+1);return le.push(se.slice(V,Le)),le.join("")}}function C(se,ce){return function(Ce){var le=yy(1900,void 0,1),Le=j(le,se,Ce+="",0),V,K;if(Le!=Ce.length)return null;if("Q"in le)return new Date(le.Q);if("s"in le)return new Date(le.s*1e3+("L"in le?le.L:0));if(ce&&!("Z"in le)&&(le.Z=0),"p"in le&&(le.H=le.H%12+le.p*12),le.m===void 0&&(le.m="q"in le?le.q:0),"V"in le){if(le.V<1||le.V>53)return null;"w"in le||(le.w=1),"Z"in le?(V=_E(yy(le.y,0,1)),K=V.getUTCDay(),V=K>4||K===0?vN.ceil(V):vN(V),V=Rk.offset(V,(le.V-1)*7),le.y=V.getUTCFullYear(),le.m=V.getUTCMonth(),le.d=V.getUTCDate()+(le.w+6)%7):(V=SE(yy(le.y,0,1)),K=V.getDay(),V=K>4||K===0?yN.ceil(V):yN(V),V=Tv.offset(V,(le.V-1)*7),le.y=V.getFullYear(),le.m=V.getMonth(),le.d=V.getDate()+(le.w+6)%7)}else("W"in le||"U"in le)&&("w"in le||(le.w="u"in le?le.u%7:"W"in le?1:0),K="Z"in le?_E(yy(le.y,0,1)).getUTCDay():SE(yy(le.y,0,1)).getDay(),le.m=0,le.d="W"in le?(le.w+6)%7+le.W*7-(K+5)%7:le.w+le.U*7-(K+6)%7);return"Z"in le?(le.H+=le.Z/100|0,le.M+=le.Z%100,_E(le)):SE(le)}}function j(se,ce,Ce,le){for(var Le=0,V=ce.length,K=Ce.length,fe,Y;Le<V;){if(le>=K)return-1;if(fe=ce.charCodeAt(Le++),fe===37){if(fe=ce.charAt(Le++),Y=k[fe in Xq?ce.charAt(Le++):fe],!Y||(le=Y(se,Ce,le))<0)return-1}else if(fe!=Ce.charCodeAt(le++))return-1}return le}function M(se,ce,Ce){var le=d.exec(ce.slice(Ce));return le?(se.p=u.get(le[0].toLowerCase()),Ce+le[0].length):-1}function E(se,ce,Ce){var le=p.exec(ce.slice(Ce));return le?(se.w=x.get(le[0].toLowerCase()),Ce+le[0].length):-1}function B(se,ce,Ce){var le=h.exec(ce.slice(Ce));return le?(se.w=f.get(le[0].toLowerCase()),Ce+le[0].length):-1}function L(se,ce,Ce){var le=y.exec(ce.slice(Ce));return le?(se.m=_.get(le[0].toLowerCase()),Ce+le[0].length):-1}function U(se,ce,Ce){var le=v.exec(ce.slice(Ce));return le?(se.m=g.get(le[0].toLowerCase()),Ce+le[0].length):-1}function D(se,ce,Ce){return j(se,e,ce,Ce)}function $(se,ce,Ce){return j(se,n,ce,Ce)}function q(se,ce,Ce){return j(se,r,ce,Ce)}function z(se){return o[se.getDay()]}function W(se){return s[se.getDay()]}function Q(se){return c[se.getMonth()]}function te(se){return l[se.getMonth()]}function H(se){return i[+(se.getHours()>=12)]}function X(se){return 1+~~(se.getMonth()/3)}function Z(se){return o[se.getUTCDay()]}function ee(se){return s[se.getUTCDay()]}function Se(se){return c[se.getUTCMonth()]}function oe(se){return l[se.getUTCMonth()]}function ie(se){return i[+(se.getUTCHours()>=12)]}function me(se){return 1+~~(se.getUTCMonth()/3)}return{format:function(se){var ce=P(se+="",N);return ce.toString=function(){return se},ce},parse:function(se){var ce=C(se+="",!1);return ce.toString=function(){return se},ce},utcFormat:function(se){var ce=P(se+="",A);return ce.toString=function(){return se},ce},utcParse:function(se){var ce=C(se+="",!0);return ce.toString=function(){return se},ce}}}var Xq={"-":"",_:" ",0:"0"},Oi=/^\s*\d+/,fRe=/^%/,pRe=/[\\^$*+?|[\]().{}]/g;function pr(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 gRe(t){return t.replace(pRe,"\\$&")}function vy(t){return new RegExp("^(?:"+t.map(gRe).join("|")+")","i")}function wy(t){return new Map(t.map((e,n)=>[e.toLowerCase(),n]))}function bRe(t,e,n){var r=Oi.exec(e.slice(n,n+1));return r?(t.w=+r[0],n+r[0].length):-1}function xRe(t,e,n){var r=Oi.exec(e.slice(n,n+1));return r?(t.u=+r[0],n+r[0].length):-1}function yRe(t,e,n){var r=Oi.exec(e.slice(n,n+2));return r?(t.U=+r[0],n+r[0].length):-1}function vRe(t,e,n){var r=Oi.exec(e.slice(n,n+2));return r?(t.V=+r[0],n+r[0].length):-1}function wRe(t,e,n){var r=Oi.exec(e.slice(n,n+2));return r?(t.W=+r[0],n+r[0].length):-1}function Yq(t,e,n){var r=Oi.exec(e.slice(n,n+4));return r?(t.y=+r[0],n+r[0].length):-1}function Qq(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 SRe(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 _Re(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 NRe(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 Zq(t,e,n){var r=Oi.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1}function CRe(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 Jq(t,e,n){var r=Oi.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1}function kRe(t,e,n){var r=Oi.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1}function ARe(t,e,n){var r=Oi.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1}function TRe(t,e,n){var r=Oi.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1}function MRe(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 PRe(t,e,n){var r=fRe.exec(e.slice(n,n+1));return r?n+r[0].length:-1}function ERe(t,e,n){var r=Oi.exec(e.slice(n));return r?(t.Q=+r[0],n+r[0].length):-1}function jRe(t,e,n){var r=Oi.exec(e.slice(n));return r?(t.s=+r[0],n+r[0].length):-1}function eG(t,e){return pr(t.getDate(),e,2)}function DRe(t,e){return pr(t.getHours(),e,2)}function RRe(t,e){return pr(t.getHours()%12||12,e,2)}function FRe(t,e){return pr(1+Tv.count(cu(t),t),e,3)}function wJ(t,e){return pr(t.getMilliseconds(),e,3)}function LRe(t,e){return wJ(t,e)+"000"}function ORe(t,e){return pr(t.getMonth()+1,e,2)}function IRe(t,e){return pr(t.getMinutes(),e,2)}function zRe(t,e){return pr(t.getSeconds(),e,2)}function URe(t){var e=t.getDay();return e===0?7:e}function BRe(t,e){return pr(Fk.count(cu(t)-1,t),e,2)}function SJ(t){var e=t.getDay();return e>=4||e===0?Ab(t):Ab.ceil(t)}function HRe(t,e){return t=SJ(t),pr(Ab.count(cu(t),t)+(cu(t).getDay()===4),e,2)}function $Re(t){return t.getDay()}function VRe(t,e){return pr(yN.count(cu(t)-1,t),e,2)}function qRe(t,e){return pr(t.getFullYear()%100,e,2)}function GRe(t,e){return t=SJ(t),pr(t.getFullYear()%100,e,2)}function WRe(t,e){return pr(t.getFullYear()%1e4,e,4)}function KRe(t,e){var n=t.getDay();return t=n>=4||n===0?Ab(t):Ab.ceil(t),pr(t.getFullYear()%1e4,e,4)}function XRe(t){var e=t.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+pr(e/60|0,"0",2)+pr(e%60,"0",2)}function tG(t,e){return pr(t.getUTCDate(),e,2)}function YRe(t,e){return pr(t.getUTCHours(),e,2)}function QRe(t,e){return pr(t.getUTCHours()%12||12,e,2)}function ZRe(t,e){return pr(1+Rk.count(du(t),t),e,3)}function _J(t,e){return pr(t.getUTCMilliseconds(),e,3)}function JRe(t,e){return _J(t,e)+"000"}function eFe(t,e){return pr(t.getUTCMonth()+1,e,2)}function tFe(t,e){return pr(t.getUTCMinutes(),e,2)}function nFe(t,e){return pr(t.getUTCSeconds(),e,2)}function rFe(t){var e=t.getUTCDay();return e===0?7:e}function aFe(t,e){return pr(Lk.count(du(t)-1,t),e,2)}function NJ(t){var e=t.getUTCDay();return e>=4||e===0?Tb(t):Tb.ceil(t)}function iFe(t,e){return t=NJ(t),pr(Tb.count(du(t),t)+(du(t).getUTCDay()===4),e,2)}function sFe(t){return t.getUTCDay()}function oFe(t,e){return pr(vN.count(du(t)-1,t),e,2)}function lFe(t,e){return pr(t.getUTCFullYear()%100,e,2)}function cFe(t,e){return t=NJ(t),pr(t.getUTCFullYear()%100,e,2)}function dFe(t,e){return pr(t.getUTCFullYear()%1e4,e,4)}function uFe(t,e){var n=t.getUTCDay();return t=n>=4||n===0?Tb(t):Tb.ceil(t),pr(t.getUTCFullYear()%1e4,e,4)}function hFe(){return"+0000"}function nG(){return"%"}function rG(t){return+t}function aG(t){return Math.floor(+t/1e3)}var wg,CJ,kJ;mFe({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 mFe(t){return wg=mRe(t),CJ=wg.format,wg.parse,kJ=wg.utcFormat,wg.utcParse,wg}function fFe(t){return new Date(t)}function pFe(t){return t instanceof Date?+t:+new Date(+t)}function s4(t,e,n,r,i,s,o,l,c,d){var u=GL(),h=u.invert,f=u.domain,p=d(".%L"),x=d(":%S"),v=d("%I:%M"),g=d("%I %p"),y=d("%a %d"),_=d("%b %d"),N=d("%B"),A=d("%Y");function k(P){return(c(P)<P?p:l(P)<P?x:o(P)<P?v:s(P)<P?g:r(P)<P?i(P)<P?y:_:n(P)<P?N:A)(P)}return u.invert=function(P){return new Date(h(P))},u.domain=function(P){return arguments.length?f(Array.from(P,pFe)):f().map(fFe)},u.ticks=function(P){var C=f();return t(C[0],C[C.length-1],P??10)},u.tickFormat=function(P,C){return C==null?k:d(C)},u.nice=function(P){var C=f();return(!P||typeof P.range!="function")&&(P=e(C[0],C[C.length-1],P??10)),P?f(hJ(C,P)):u},u.copy=function(){return Av(u,s4(t,e,n,r,i,s,o,l,c,d))},u}function gFe(){return Ml.apply(s4(uRe,hRe,cu,a4,Fk,Tv,n4,e4,af,CJ).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)}function bFe(){return Ml.apply(s4(cRe,dRe,du,i4,Lk,Rk,r4,t4,af,kJ).domain([Date.UTC(2e3,0,1),Date.UTC(2e3,0,2)]),arguments)}function Ok(){var t=0,e=1,n,r,i,s,o=Es,l=!1,c;function d(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))}d.domain=function(h){return arguments.length?([t,e]=h,n=s(t=+t),r=s(e=+e),i=n===r?0:1/(r-n),d):[t,e]},d.clamp=function(h){return arguments.length?(l=!!h,d):l},d.interpolator=function(h){return arguments.length?(o=h,d):o};function u(h){return function(f){var p,x;return arguments.length?([p,x]=f,o=h(p,x),d):[o(0),o(1)]}}return d.range=u(Jb),d.rangeRound=u(qL),d.unknown=function(h){return arguments.length?(c=h,d):c},function(h){return s=h,n=h(t),r=h(e),i=n===r?0:1/(r-n),d}}function sm(t,e){return e.domain(t.domain()).interpolator(t.interpolator()).clamp(t.clamp()).unknown(t.unknown())}function AJ(){var t=im(Ok()(Es));return t.copy=function(){return sm(t,AJ())},bu.apply(t,arguments)}function TJ(){var t=XL(Ok()).domain([1,10]);return t.copy=function(){return sm(t,TJ()).base(t.base())},bu.apply(t,arguments)}function MJ(){var t=YL(Ok());return t.copy=function(){return sm(t,MJ()).constant(t.constant())},bu.apply(t,arguments)}function o4(){var t=QL(Ok());return t.copy=function(){return sm(t,o4()).exponent(t.exponent())},bu.apply(t,arguments)}function xFe(){return o4.apply(null,arguments).exponent(.5)}function PJ(){var t=[],e=Es;function n(r){if(r!=null&&!isNaN(r=+r))return e((Cv(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(zh),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)=>rDe(t,s/r))},n.copy=function(){return PJ(e).domain(t)},bu.apply(n,arguments)}function Ik(){var t=0,e=.5,n=1,r=1,i,s,o,l,c,d=Es,u,h=!1,f;function p(v){return isNaN(v=+v)?f:(v=.5+((v=+u(v))-s)*(r*v<r*s?l:c),d(h?Math.max(0,Math.min(1,v)):v))}p.domain=function(v){return arguments.length?([t,e,n]=v,i=u(t=+t),s=u(e=+e),o=u(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?(d=v,p):d};function x(v){return function(g){var y,_,N;return arguments.length?([y,_,N]=g,d=PDe(v,[y,_,N]),p):[d(0),d(.5),d(1)]}}return p.range=x(Jb),p.rangeRound=x(qL),p.unknown=function(v){return arguments.length?(f=v,p):f},function(v){return u=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 EJ(){var t=im(Ik()(Es));return t.copy=function(){return sm(t,EJ())},bu.apply(t,arguments)}function jJ(){var t=XL(Ik()).domain([.1,1,10]);return t.copy=function(){return sm(t,jJ()).base(t.base())},bu.apply(t,arguments)}function DJ(){var t=YL(Ik());return t.copy=function(){return sm(t,DJ()).constant(t.constant())},bu.apply(t,arguments)}function l4(){var t=QL(Ik());return t.copy=function(){return sm(t,l4()).exponent(t.exponent())},bu.apply(t,arguments)}function yFe(){return l4.apply(null,arguments).exponent(.5)}const Py=Object.freeze(Object.defineProperty({__proto__:null,scaleBand:HL,scaleDiverging:EJ,scaleDivergingLog:jJ,scaleDivergingPow:l4,scaleDivergingSqrt:yFe,scaleDivergingSymlog:DJ,scaleIdentity:uJ,scaleImplicit:JD,scaleLinear:dJ,scaleLog:mJ,scaleOrdinal:BL,scalePoint:sDe,scalePow:ZL,scaleQuantile:gJ,scaleQuantize:bJ,scaleRadial:pJ,scaleSequential:AJ,scaleSequentialLog:TJ,scaleSequentialPow:o4,scaleSequentialQuantile:PJ,scaleSequentialSqrt:xFe,scaleSequentialSymlog:MJ,scaleSqrt:JDe,scaleSymlog:fJ,scaleThreshold:xJ,scaleTime:gFe,scaleUtc:bFe,tickFormat:cJ},Symbol.toStringTag,{value:"Module"}));var xu=t=>t.chartData,zk=dt([xu],t=>{var e=t.chartData!=null?t.chartData.length-1:0;return{chartData:t.chartData,computedData:t.computedData,dataEndIndex:e,dataStartIndex:0}}),c4=(t,e,n,r)=>r?zk(t):xu(t),RJ=(t,e,n)=>n?zk(t):xu(t);function uu(t){if(Array.isArray(t)&&t.length===2){var[e,n]=t;if(Cn(e)&&Cn(n))return!0}return!1}function iG(t,e,n){return n?t:[Math.min(t[0],e[0]),Math.max(t[1],e[1])]}function FJ(t,e){if(e&&typeof t!="function"&&Array.isArray(t)&&t.length===2){var[n,r]=t,i,s;if(Cn(n))i=n;else if(typeof n=="function")return;if(Cn(r))s=r;else if(typeof r=="function")return;var o=[i,s];if(uu(o))return o}}function vFe(t,e,n){if(!(!n&&e==null)){if(typeof t=="function"&&e!=null)try{var r=t(e,n);if(uu(r))return iG(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($t(i))o=i;else if(typeof i=="function")try{e!=null&&(o=i(e?.[0]))}catch{}else if(typeof i=="string"&&pV.test(i)){var c=pV.exec(i);if(c==null||c[1]==null||e==null)o=void 0;else{var d=+c[1];o=e[0]-d}}else o=e?.[0];if(s==="auto")e!=null&&(l=Math.max(...e));else if($t(s))l=s;else if(typeof s=="function")try{e!=null&&(l=s(e?.[1]))}catch{}else if(typeof s=="string"&&gV.test(s)){var u=gV.exec(s);if(u==null||u[1]==null||e==null)l=void 0;else{var h=+u[1];l=e[1]+h}}else l=e?.[1];var f=[o,l];if(uu(f))return e==null?f:iG(f,e,n)}}}var ex=1e9,wFe={precision:20,rounding:4,toExpNeg:-7,toExpPos:21,LN10:"2.302585092994045684017991454684364207601101488628772976033327900967572609677352480235997205089598298341967784042286"},u4,fa=!0,Al="[DecimalError] ",xf=Al+"Invalid argument: ",d4=Al+"Exponent out of range: ",tx=Math.floor,Gm=Math.pow,SFe=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,To,Ei=1e7,ca=7,LJ=9007199254740991,wN=tx(LJ/ca),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)*ca;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 Kd(this,new this.constructor(t))};Wt.dividedToIntegerBy=Wt.idiv=function(t){var e=this,n=e.constructor;return Xr(Kd(e,new n(t),0,1),n.precision)};Wt.equals=Wt.eq=function(t){return!this.cmp(t)};Wt.exponent=function(){return ii(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(To))throw Error(Al+"NaN");if(n.s<1)throw Error(Al+(n.s?"NaN":"-Infinity"));return n.eq(To)?new r(0):(fa=!1,e=Kd(U0(n,s),U0(t,s),s),fa=!0,Xr(e,i))};Wt.minus=Wt.sub=function(t){var e=this;return t=new e.constructor(t),e.s==t.s?zJ(e,t):OJ(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(Al+"NaN");return n.s?(fa=!1,e=Kd(n,t,0,1).times(t),fa=!0,n.minus(e)):Xr(new r(n),i)};Wt.naturalExponential=Wt.exp=function(){return IJ(this)};Wt.naturalLogarithm=Wt.ln=function(){return U0(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?OJ(e,t):zJ(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(xf+t);if(e=ii(i)+1,r=i.d.length-1,n=r*ca+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(Al+"NaN")}for(t=ii(l),fa=!1,i=Math.sqrt(+l),i==0||i==1/0?(e=Pc(l.d),(e.length+t)%2==0&&(e+="0"),i=Math.sqrt(e),t=tx((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(Kd(l,s,o+2)).times(.5),Pc(s.d).slice(0,o)===(e=Pc(r.d)).slice(0,o)){if(e=e.slice(o-3,o+1),i==o&&e=="4999"){if(Xr(s,n+1,0),s.times(s).eq(l)){r=s;break}}else if(e!="9999")break;o+=4}return fa=!0,Xr(r,n)};Wt.times=Wt.mul=function(t){var e,n,r,i,s,o,l,c,d,u=this,h=u.constructor,f=u.d,p=(t=new h(t)).d;if(!u.s||!t.s)return new h(0);for(t.s*=u.s,n=u.e+t.e,c=f.length,d=p.length,c<d&&(s=f,f=p,p=s,o=c,c=d,d=o),s=[],o=c+d,r=o;r--;)s.push(0);for(r=d;--r>=0;){for(e=0,i=c+r;i>r;)l=s[i]+p[r]*f[i-r-1]+e,s[i--]=l%Ei|0,e=l/Ei|0;s[i]=(s[i]+e)%Ei|0}for(;!s[--o];)s.pop();return e?++n:s.shift(),t.d=s,t.e=n,fa?Xr(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:(zc(t,0,ex),e===void 0?e=r.rounding:zc(e,0,8),Xr(n,t+ii(n)+1,e))};Wt.toExponential=function(t,e){var n,r=this,i=r.constructor;return t===void 0?n=Gf(r,!0):(zc(t,0,ex),e===void 0?e=i.rounding:zc(e,0,8),r=Xr(new i(r),t+1,e),n=Gf(r,!0,t+1)),n};Wt.toFixed=function(t,e){var n,r,i=this,s=i.constructor;return t===void 0?Gf(i):(zc(t,0,ex),e===void 0?e=s.rounding:zc(e,0,8),r=Xr(new s(i),t+ii(i)+1,e),n=Gf(r.abs(),!1,t+ii(r)+1),i.isneg()&&!i.isZero()?"-"+n:n)};Wt.toInteger=Wt.toint=function(){var t=this,e=t.constructor;return Xr(new e(t),ii(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,d=12,u=+(t=new c(t));if(!t.s)return new c(To);if(l=new c(l),!l.s){if(t.s<1)throw Error(Al+"Infinity");return l}if(l.eq(To))return l;if(r=c.precision,t.eq(To))return Xr(l,r);if(e=t.e,n=t.d.length-1,o=e>=n,s=l.s,o){if((n=u<0?-u:u)<=LJ){for(i=new c(To),e=Math.ceil(r/ca+4),fa=!1;n%2&&(i=i.times(l),oG(i.d,e)),n=tx(n/2),n!==0;)l=l.times(l),oG(l.d,e);return fa=!0,t.s<0?new c(To).div(i):Xr(i,r)}}else if(s<0)throw Error(Al+"NaN");return s=s<0&&t.d[Math.max(e,n)]&1?-1:1,l.s=1,fa=!1,i=t.times(U0(l,r+d)),fa=!0,i=IJ(i),i.s=s,i};Wt.toPrecision=function(t,e){var n,r,i=this,s=i.constructor;return t===void 0?(n=ii(i),r=Gf(i,n<=s.toExpNeg||n>=s.toExpPos)):(zc(t,1,ex),e===void 0?e=s.rounding:zc(e,0,8),i=Xr(new s(i),t,e),n=ii(i),r=Gf(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):(zc(t,1,ex),e===void 0?e=r.rounding:zc(e,0,8)),Xr(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=ii(t),n=t.constructor;return Gf(t,e<=n.toExpNeg||e>=n.toExpPos)};function OJ(t,e){var n,r,i,s,o,l,c,d,u=t.constructor,h=u.precision;if(!t.s||!e.s)return e.s||(e=new u(t)),fa?Xr(e,h):e;if(c=t.d,d=e.d,o=t.e,i=e.e,c=c.slice(),s=o-i,s){for(s<0?(r=c,s=-s,l=d.length):(r=d,i=o,l=c.length),o=Math.ceil(h/ca),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=d.length,l-s<0&&(s=l,r=d,d=c,c=r),n=0;s;)n=(c[--s]=c[s]+d[s]+n)/Ei|0,c[s]%=Ei;for(n&&(c.unshift(n),++i),l=c.length;c[--l]==0;)c.pop();return e.d=c,e.e=i,fa?Xr(e,h):e}function zc(t,e,n){if(t!==~~t||t<e||t>n)throw Error(xf+t)}function Pc(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=ca-r.length,n&&(s+=lh(n)),s+=r;o=t[e],r=o+"",n=ca-r.length,n&&(s+=lh(n))}else if(o===0)return"0";for(;o%10===0;)o/=10;return s+o}var Kd=(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%Ei|0,o=s/Ei|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*Ei+r[s]-i[s];for(;!r[0]&&r.length>1;)r.shift()}return function(r,i,s,o){var l,c,d,u,h,f,p,x,v,g,y,_,N,A,k,P,C,j,M=r.constructor,E=r.s==i.s?1:-1,B=r.d,L=i.d;if(!r.s)return new M(r);if(!i.s)throw Error(Al+"Division by zero");for(c=r.e-i.e,C=L.length,k=B.length,p=new M(E),x=p.d=[],d=0;L[d]==(B[d]||0);)++d;if(L[d]>(B[d]||0)&&--c,s==null?_=s=M.precision:o?_=s+(ii(r)-ii(i))+1:_=s,_<0)return new M(0);if(_=_/ca+2|0,d=0,C==1)for(u=0,L=L[0],_++;(d<k||u)&&_--;d++)N=u*Ei+(B[d]||0),x[d]=N/L|0,u=N%L|0;else{for(u=Ei/(L[0]+1)|0,u>1&&(L=t(L,u),B=t(B,u),C=L.length,k=B.length),A=C,v=B.slice(0,C),g=v.length;g<C;)v[g++]=0;j=L.slice(),j.unshift(0),P=L[0],L[1]>=Ei/2&&++P;do u=0,l=e(L,v,C,g),l<0?(y=v[0],C!=g&&(y=y*Ei+(v[1]||0)),u=y/P|0,u>1?(u>=Ei&&(u=Ei-1),h=t(L,u),f=h.length,g=v.length,l=e(h,v,f,g),l==1&&(u--,n(h,C<f?j:L,f))):(u==0&&(l=u=1),h=L.slice()),f=h.length,f<g&&h.unshift(0),n(v,h,g),l==-1&&(g=v.length,l=e(L,v,C,g),l<1&&(u++,n(v,C<g?j:L,g))),g=v.length):l===0&&(u++,v=[0]),x[d++]=u,l&&v[0]?v[g++]=B[A]||0:(v=[B[A]],g=1);while((A++<k||v[0]!==void 0)&&_--)}return x[0]||x.shift(),p.e=c,Xr(p,o?s+ii(p)+1:s)}})();function IJ(t,e){var n,r,i,s,o,l,c=0,d=0,u=t.constructor,h=u.precision;if(ii(t)>16)throw Error(d4+ii(t));if(!t.s)return new u(To);for(fa=!1,l=h,o=new u(.03125);t.abs().gte(.1);)t=t.times(o),d+=5;for(r=Math.log(Gm(2,d))/Math.LN10*2+5|0,l+=r,n=i=s=new u(To),u.precision=l;;){if(i=Xr(i.times(t),l),n=n.times(++c),o=s.plus(Kd(i,n,l)),Pc(o.d).slice(0,l)===Pc(s.d).slice(0,l)){for(;d--;)s=Xr(s.times(s),l);return u.precision=h,e==null?(fa=!0,Xr(s,h)):s}s=o}}function ii(t){for(var e=t.e*ca,n=t.d[0];n>=10;n/=10)e++;return e}function NE(t,e,n){if(e>t.LN10.sd())throw fa=!0,n&&(t.precision=n),Error(Al+"LN10 precision limit exceeded");return Xr(new t(t.LN10),e)}function lh(t){for(var e="";t--;)e+="0";return e}function U0(t,e){var n,r,i,s,o,l,c,d,u,h=1,f=10,p=t,x=p.d,v=p.constructor,g=v.precision;if(p.s<1)throw Error(Al+(p.s?"NaN":"-Infinity"));if(p.eq(To))return new v(0);if(e==null?(fa=!1,d=g):d=e,p.eq(10))return e==null&&(fa=!0),NE(v,d);if(d+=f,v.precision=d,n=Pc(x),r=n.charAt(0),s=ii(p),Math.abs(s)<15e14){for(;r<7&&r!=1||r==1&&n.charAt(1)>3;)p=p.times(t),n=Pc(p.d),r=n.charAt(0),h++;s=ii(p),r>1?(p=new v("0."+n),s++):p=new v(r+"."+n.slice(1))}else return c=NE(v,d+2,g).times(s+""),p=U0(new v(r+"."+n.slice(1)),d-f).plus(c),v.precision=g,e==null?(fa=!0,Xr(p,g)):p;for(l=o=p=Kd(p.minus(To),p.plus(To),d),u=Xr(p.times(p),d),i=3;;){if(o=Xr(o.times(u),d),c=l.plus(Kd(o,new v(i),d)),Pc(c.d).slice(0,d)===Pc(l.d).slice(0,d))return l=l.times(2),s!==0&&(l=l.plus(NE(v,d+2,g).times(s+""))),l=Kd(l,new v(h),d),v.precision=g,e==null?(fa=!0,Xr(l,g)):l;l=c,i+=2}}function sG(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=tx(n/ca),t.d=[],r=(n+1)%ca,n<0&&(r+=ca),r<i){for(r&&t.d.push(+e.slice(0,r)),i-=ca;r<i;)t.d.push(+e.slice(r,r+=ca));e=e.slice(r),r=ca-e.length}else r-=i;for(;r--;)e+="0";if(t.d.push(+e),fa&&(t.e>wN||t.e<-wN))throw Error(d4+n)}else t.s=0,t.e=0,t.d=[0];return t}function Xr(t,e,n){var r,i,s,o,l,c,d,u,h=t.d;for(o=1,s=h[0];s>=10;s/=10)o++;if(r=e-o,r<0)r+=ca,i=e,d=h[u=0];else{if(u=Math.ceil((r+1)/ca),s=h.length,u>=s)return t;for(d=s=h[u],o=1;s>=10;s/=10)o++;r%=ca,i=r-ca+o}if(n!==void 0&&(s=Gm(10,o-i-1),l=d/s%10|0,c=e<0||h[u+1]!==void 0||d%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?d/Gm(10,o-i):0:h[u-1])%10&1||n==(t.s<0?8:7))),e<1||!h[0])return c?(s=ii(t),h.length=1,e=e-s-1,h[0]=Gm(10,(ca-e%ca)%ca),t.e=tx(-e/ca)||0):(h.length=1,h[0]=t.e=t.s=0),t;if(r==0?(h.length=u,s=1,u--):(h.length=u+1,s=Gm(10,ca-r),h[u]=i>0?(d/Gm(10,o-i)%Gm(10,i)|0)*s:0),c)for(;;)if(u==0){(h[0]+=s)==Ei&&(h[0]=1,++t.e);break}else{if(h[u]+=s,h[u]!=Ei)break;h[u--]=0,s=1}for(r=h.length;h[--r]===0;)h.pop();if(fa&&(t.e>wN||t.e<-wN))throw Error(d4+ii(t));return t}function zJ(t,e){var n,r,i,s,o,l,c,d,u,h,f=t.constructor,p=f.precision;if(!t.s||!e.s)return e.s?e.s=-e.s:e=new f(t),fa?Xr(e,p):e;if(c=t.d,h=e.d,r=e.e,d=t.e,c=c.slice(),o=d-r,o){for(u=o<0,u?(n=c,o=-o,l=h.length):(n=h,r=d,l=c.length),i=Math.max(Math.ceil(p/ca),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,u=i<l,u&&(l=i),i=0;i<l;i++)if(c[i]!=h[i]){u=c[i]<h[i];break}o=0}for(u&&(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]=Ei-1;--c[s],c[i]+=Ei}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,fa?Xr(e,p):e):new f(0)}function Gf(t,e,n){var r,i=ii(t),s=Pc(t.d),o=s.length;return e?(n&&(r=n-o)>0?s=s.charAt(0)+"."+s.slice(1)+lh(r):o>1&&(s=s.charAt(0)+"."+s.slice(1)),s=s+(i<0?"e":"e+")+i):i<0?(s="0."+lh(-i-1)+s,n&&(r=n-o)>0&&(s+=lh(r))):i>=o?(s+=lh(i+1-o),n&&(r=n-i-1)>0&&(s=s+"."+lh(r))):((r=i+1)<o&&(s=s.slice(0,r)+"."+s.slice(r)),n&&(r=n-o)>0&&(i+1===o&&(s+="."),s+=lh(r))),t.s<0?"-"+s:s}function oG(t,e){if(t.length>e)return t.length=e,!0}function UJ(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(xf+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 sG(o,s.toString())}else if(typeof s!="string")throw Error(xf+s);if(s.charCodeAt(0)===45?(s=s.slice(1),o.s=-1):o.s=1,SFe.test(s))sG(o,s);else throw Error(xf+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=UJ,i.config=i.set=_Fe,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 _Fe(t){if(!t||typeof t!="object")throw Error(Al+"Object expected");var e,n,r,i=["precision",1,ex,"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(tx(r)===r&&r>=i[e+1]&&r<=i[e+2])this[n]=r;else throw Error(xf+n+": "+r);if((r=t[n="LN10"])!==void 0)if(r==Math.LN10)this[n]=new this(r);else throw Error(xf+n+": "+r);return this}var u4=UJ(wFe);To=new u4(1);const Pr=u4;function BJ(t){var e;return t===0?e=1:e=Math.floor(new Pr(t).abs().log(10).toNumber())+1,e}function HJ(t,e,n){for(var r=new Pr(t),i=0,s=[];r.lt(e)&&i<1e5;)s.push(r.toNumber()),r=r.add(n),i++;return s}var $J=t=>{var[e,n]=t,[r,i]=[e,n];return e>n&&([r,i]=[n,e]),[r,i]},VJ=(t,e,n)=>{if(t.lte(0))return new Pr(0);var r=BJ(t.toNumber()),i=new Pr(10).pow(r),s=t.div(i),o=r!==1?.05:.1,l=new Pr(Math.ceil(s.div(o).toNumber())).add(n).mul(o),c=l.mul(i);return e?new Pr(c.toNumber()):new Pr(Math.ceil(c.toNumber()))},NFe=(t,e,n)=>{var r=new Pr(1),i=new Pr(t);if(!i.isint()&&n){var s=Math.abs(t);s<1?(r=new Pr(10).pow(BJ(t)-1),i=new Pr(Math.floor(i.div(r).toNumber())).mul(r)):s>1&&(i=new Pr(Math.floor(t)))}else t===0?i=new Pr(Math.floor((e-1)/2)):n||(i=new Pr(Math.floor(t)));for(var o=Math.floor((e-1)/2),l=[],c=0;c<e;c++)l.push(i.add(new Pr(c-o).mul(r)).toNumber());return l},qJ=function(e,n,r,i){var s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:0;if(!Number.isFinite((n-e)/(r-1)))return{step:new Pr(0),tickMin:new Pr(0),tickMax:new Pr(0)};var o=VJ(new Pr(n).sub(e).div(r-1),i,s),l;e<=0&&n>=0?l=new Pr(0):(l=new Pr(e).add(n).div(2),l=l.sub(new Pr(l).mod(o)));var c=Math.ceil(l.sub(e).div(o).toNumber()),d=Math.ceil(new Pr(n).sub(l).div(o).toNumber()),u=c+d+1;return u>r?qJ(e,n,r,i,s+1):(u<r&&(d=n>0?d+(r-u):d,c=n>0?c:c+(r-u)),{step:o,tickMin:l.sub(new Pr(c).mul(o)),tickMax:l.add(new Pr(d).mul(o))})},CFe=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]=$J([n,r]);if(l===-1/0||c===1/0){var d=c===1/0?[l,...Array(i-1).fill(1/0)]:[...Array(i-1).fill(-1/0),c];return n>r?d.reverse():d}if(l===c)return NFe(l,i,s);var{step:u,tickMin:h,tickMax:f}=qJ(l,c,o,s,0),p=HJ(h,f.add(new Pr(.1).mul(u)),u);return n>r?p.reverse():p},kFe=function(e,n){var[r,i]=e,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,[o,l]=$J([r,i]);if(o===-1/0||l===1/0)return[r,i];if(o===l)return[o];var c=Math.max(n,2),d=VJ(new Pr(l).sub(o).div(c-1),s,0),u=[...HJ(new Pr(o),new Pr(l),d),l];return s===!1&&(u=u.map(h=>Math.round(h))),r>i?u.reverse():u},GJ=t=>t.rootProps.maxBarSize,AFe=t=>t.rootProps.barGap,WJ=t=>t.rootProps.barCategoryGap,TFe=t=>t.rootProps.barSize,Mv=t=>t.rootProps.stackOffset,KJ=t=>t.rootProps.reverseStackOrder,h4=t=>t.options.chartName,m4=t=>t.rootProps.syncId,XJ=t=>t.rootProps.syncMethod,f4=t=>t.options.eventEmitter,MFe=t=>t.rootProps.baseValue,La={grid:-100,barBackground:-50,area:100,cursorRectangle:200,bar:300,line:400,axis:500,scatter:600,activeBar:1e3,cursorLine:1100,activeDot:1200,label:2e3},Im={allowDecimals:!1,allowDataOverflow:!1,angleAxisId:0,reversed:!1,scale:"auto",tick:!0,type:"auto"},bc={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:!0,includeHidden:!1,radiusAxisId:0,reversed:!1,scale:"auto",tick:!0,tickCount:5,type:"auto"},Uk=(t,e)=>{if(!(!t||!e))return t!=null&&t.reversed?[e[1],e[0]]:e};function Bk(t,e,n){if(n!=="auto")return n;if(t!=null)return oc(t,e)?"category":"number"}function lG(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 SN(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?lG(Object(n),!0).forEach(function(r){PFe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):lG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function PFe(t,e,n){return(e=EFe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function EFe(t){var e=jFe(t,"string");return typeof e=="symbol"?e:e+""}function jFe(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 cG={allowDataOverflow:Im.allowDataOverflow,allowDecimals:Im.allowDecimals,allowDuplicatedCategory:!1,dataKey:void 0,domain:void 0,id:Im.angleAxisId,includeHidden:!1,name:void 0,reversed:Im.reversed,scale:Im.scale,tick:Im.tick,tickCount:void 0,ticks:void 0,type:Im.type,unit:void 0},dG={allowDataOverflow:bc.allowDataOverflow,allowDecimals:bc.allowDecimals,allowDuplicatedCategory:bc.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:bc.radiusAxisId,includeHidden:bc.includeHidden,name:void 0,reversed:bc.reversed,scale:bc.scale,tick:bc.tick,tickCount:bc.tickCount,ticks:void 0,type:bc.type,unit:void 0},DFe=(t,e)=>{if(e!=null)return t.polarAxis.angleAxis[e]},p4=dt([DFe,DZ],(t,e)=>{var n;if(t!=null)return t;var r=(n=Bk(e,"angleAxis",cG.type))!==null&&n!==void 0?n:"category";return SN(SN({},cG),{},{type:r})}),RFe=(t,e)=>t.polarAxis.radiusAxis[e],g4=dt([RFe,DZ],(t,e)=>{var n;if(t!=null)return t;var r=(n=Bk(e,"radiusAxis",dG.type))!==null&&n!==void 0?n:"category";return SN(SN({},dG),{},{type:r})}),Hk=t=>t.polarOptions,b4=dt([pu,gu,vi],YZ),YJ=dt([Hk,b4],(t,e)=>{if(t!=null)return ys(t.innerRadius,e,0)}),QJ=dt([Hk,b4],(t,e)=>{if(t!=null)return ys(t.outerRadius,e,e*.8)}),FFe=t=>{if(t==null)return[0,0];var{startAngle:e,endAngle:n}=t;return[e,n]},ZJ=dt([Hk],FFe);dt([p4,ZJ],Uk);var JJ=dt([b4,YJ,QJ],(t,e,n)=>{if(!(t==null||e==null||n==null))return[e,n]});dt([g4,JJ],Uk);var eee=dt([ir,Hk,YJ,QJ,pu,gu],(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:d}=e;return{cx:ys(o,i,i/2),cy:ys(l,s,s/2),innerRadius:n,outerRadius:r,startAngle:c,endAngle:d,clockWise:!1}}}),_a=(t,e)=>e,Pv=(t,e,n)=>n;function $k(t){return t?.id}function tee(t,e,n){var{chartData:r=[]}=e,{allowDuplicatedCategory:i,dataKey:s}=n,o=new Map;return t.forEach(l=>{var c,d=(c=l.data)!==null&&c!==void 0?c:r;if(!(d==null||d.length===0)){var u=$k(l);d.forEach((h,f)=>{var p=s==null||i?f:String(_r(h,s,null)),x=_r(h,l.dataKey,0),v;o.has(p)?v=o.get(p):v={},Object.assign(v,{[u]:x}),o.set(p,v)})}}),Array.from(o.values())}function Vk(t){return"stackId"in t&&t.stackId!=null&&t.dataKey!=null}var qk=(t,e)=>t===e?!0:t==null||e==null?!1:t[0]===e[0]&&t[1]===e[1];function Gk(t,e){return Array.isArray(t)&&Array.isArray(e)&&t.length===0&&e.length===0?!0:t===e}function LFe(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=ir(t);return e==="horizontal"?"xAxis":e==="vertical"?"yAxis":e==="centric"?"angleAxis":"radiusAxis"},nx=t=>t.tooltip.settings.axisId;function OFe(t){if(t in Py)return Py[t]();var e="scale".concat(gv(t));if(e in Py)return Py[e]()}function uG(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 hG(t,e,n){if(typeof t=="function")return uG(t.copy().domain(e).range(n));if(t!=null){var r=OFe(t);if(r!=null)return r.domain(e).range(n),uG(r)}}var nee=(t,e)=>{if(e!=null)switch(t){case"linear":{if(!uu(e)){for(var n,r,i=0;i<e.length;i++){var s=e[i];Cn(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 mG(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function _N(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?mG(Object(n),!0).forEach(function(r){IFe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):mG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function IFe(t,e,n){return(e=zFe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function zFe(t){var e=UFe(t,"string");return typeof e=="symbol"?e:e+""}function UFe(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 rR=[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},ree=(t,e)=>t.cartesianAxis.xAxis[e],Gc=(t,e)=>{var n=ree(t,e);return n??Mi},Pi={allowDataOverflow:!1,allowDecimals:!0,allowDuplicatedCategory:!0,angle:0,dataKey:void 0,domain:rR,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:vv},aee=(t,e)=>t.cartesianAxis.yAxis[e],Wc=(t,e)=>{var n=aee(t,e);return n??Pi},BFe={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:""},x4=(t,e)=>{var n=t.cartesianAxis.zAxis[e];return n??BFe},za=(t,e,n)=>{switch(e){case"xAxis":return Gc(t,n);case"yAxis":return Wc(t,n);case"zAxis":return x4(t,n);case"angleAxis":return p4(t,n);case"radiusAxis":return g4(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},HFe=(t,e,n)=>{switch(e){case"xAxis":return Gc(t,n);case"yAxis":return Wc(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},rx=(t,e,n)=>{switch(e){case"xAxis":return Gc(t,n);case"yAxis":return Wc(t,n);case"angleAxis":return p4(t,n);case"radiusAxis":return g4(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},iee=t=>t.graphicalItems.cartesianItems.some(e=>e.type==="bar")||t.graphicalItems.polarItems.some(e=>e.type==="radialBar");function y4(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 Ev=t=>t.graphicalItems.cartesianItems,$Fe=dt([_a,Pv],y4),v4=(t,e,n)=>t.filter(n).filter(r=>e?.includeHidden===!0?!0:!r.hide),jv=dt([Ev,za,$Fe],v4,{memoizeOptions:{resultEqualityCheck:Gk}}),see=dt([jv],t=>t.filter(e=>e.type==="area"||e.type==="bar").filter(Vk)),oee=t=>t.filter(e=>!("stackId"in e)||e.stackId===void 0),VFe=dt([jv],oee),w4=t=>t.map(e=>e.data).filter(Boolean).flat(1),qFe=dt([jv],w4,{memoizeOptions:{resultEqualityCheck:Gk}}),S4=(t,e)=>{var{chartData:n=[],dataStartIndex:r,dataEndIndex:i}=e;return t.length>0?t:n.slice(r,i+1)},_4=dt([qFe,c4],S4),N4=(t,e,n)=>e?.dataKey!=null?t.map(r=>({value:_r(r,e.dataKey)})):n.length>0?n.map(r=>r.dataKey).flatMap(r=>t.map(i=>({value:_r(i,r)}))):t.map(r=>({value:r})),Wk=dt([_4,za,jv],N4);function lee(t,e){switch(t){case"xAxis":return e.direction==="x";case"yAxis":return e.direction==="y";default:return!1}}function t1(t){if(Cl(t)||t instanceof Date){var e=Number(t);if(Cn(e))return e}}function fG(t){if(Array.isArray(t)){var e=[t1(t[0]),t1(t[1])];return uu(e)?e:void 0}var n=t1(t);if(n!=null)return[n,n]}function hu(t){return t.map(t1).filter(to)}function GFe(t,e,n){return!n||typeof e!="number"||ec(e)?[]:n.length?hu(n.flatMap(r=>{var i=_r(t,r.dataKey),s,o;if(Array.isArray(i)?[s,o]=i:s=o=i,!(!Cn(s)||!Cn(o)))return[e-s,e+o]})):[]}var _i=t=>{var e=Ii(t),n=nx(t);return rx(t,e,n)},Dv=dt([_i],t=>t?.dataKey),WFe=dt([see,c4,_i],tee),cee=(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,d=r?[...c].reverse():c,u=d.map($k);return[l,{stackedData:fEe(t,u,n),graphicalItems:d}]}))},NN=dt([WFe,see,Mv,KJ],cee),dee=(t,e,n,r)=>{var{dataStartIndex:i,dataEndIndex:s}=e;if(r==null&&n!=="zAxis"){var o=xEe(t,i,s);if(!(o!=null&&o[0]===0&&o[1]===0))return o}},KFe=dt([za],t=>t.allowDataOverflow),C4=t=>{var e;if(t==null||!("domain"in t))return rR;if(t.domain!=null)return t.domain;if("ticks"in t&&t.ticks!=null){if(t.type==="number"){var n=hu(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:rR},k4=dt([za],C4),A4=dt([k4,KFe],FJ),XFe=dt([NN,xu,_a,A4],dee,{memoizeOptions:{resultEqualityCheck:qk}}),Kk=t=>t.errorBars,YFe=(t,e,n)=>t.flatMap(r=>e[r.id]).filter(Boolean).filter(r=>lee(n,r)),CN=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]}},T4=(t,e,n,r,i)=>{var s,o;if(n.length>0&&t.forEach(l=>{n.forEach(c=>{var d,u,h=(d=r[c.id])===null||d===void 0?void 0:d.filter(y=>lee(i,y)),f=_r(l,(u=e.dataKey)!==null&&u!==void 0?u:c.dataKey),p=GFe(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=fG(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=fG(_r(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]))}),Cn(s)&&Cn(o))return[s,o]},QFe=dt([_4,za,VFe,Kk,_a],T4,{memoizeOptions:{resultEqualityCheck:qk}});function ZFe(t){var{value:e}=t;if(Cl(e)||e instanceof Date)return e}var JFe=(t,e,n)=>{var r=t.map(ZFe).filter(i=>i!=null);return n&&(e.dataKey==null||e.allowDuplicatedCategory&&TQ(r))?eJ(0,t.length):e.allowDuplicatedCategory?r:Array.from(new Set(r))},uee=t=>t.referenceElements.dots,ax=(t,e,n)=>t.filter(r=>r.ifOverflow==="extendDomain").filter(r=>e==="xAxis"?r.xAxisId===n:r.yAxisId===n),eLe=dt([uee,_a,Pv],ax),hee=t=>t.referenceElements.areas,tLe=dt([hee,_a,Pv],ax),mee=t=>t.referenceElements.lines,nLe=dt([mee,_a,Pv],ax),fee=(t,e)=>{if(t!=null){var n=hu(t.map(r=>e==="xAxis"?r.x:r.y));if(n.length!==0)return[Math.min(...n),Math.max(...n)]}},rLe=dt(eLe,_a,fee),pee=(t,e)=>{if(t!=null){var n=hu(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)]}},aLe=dt([tLe,_a],pee);function iLe(t){var e;if(t.x!=null)return hu([t.x]);var n=(e=t.segment)===null||e===void 0?void 0:e.map(r=>r.x);return n==null||n.length===0?[]:hu(n)}function sLe(t){var e;if(t.y!=null)return hu([t.y]);var n=(e=t.segment)===null||e===void 0?void 0:e.map(r=>r.y);return n==null||n.length===0?[]:hu(n)}var gee=(t,e)=>{if(t!=null){var n=t.flatMap(r=>e==="xAxis"?iLe(r):sLe(r));if(n.length!==0)return[Math.min(...n),Math.max(...n)]}},oLe=dt([nLe,_a],gee),lLe=dt(rLe,oLe,aLe,(t,e,n)=>CN(t,n,e)),M4=(t,e,n,r,i,s,o,l)=>{if(n!=null)return n;var c=o==="vertical"&&l==="xAxis"||o==="horizontal"&&l==="yAxis",d=c?CN(r,s,i):CN(s,i);return vFe(e,d,t.allowDataOverflow)},cLe=dt([za,k4,A4,XFe,QFe,lLe,ir,_a],M4,{memoizeOptions:{resultEqualityCheck:qk}}),dLe=[0,1],P4=(t,e,n,r,i,s,o)=>{if(!((t==null||n==null||n.length===0)&&o===void 0)){var{dataKey:l,type:c}=t,d=oc(e,s);if(d&&l==null){var u;return eJ(0,(u=n?.length)!==null&&u!==void 0?u:0)}return c==="category"?JFe(r,t,d):i==="expand"?dLe:o}},E4=dt([za,ir,_4,Wk,Mv,_a,cLe],P4);function uLe(t){return t in Py}var bee=(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(gv(r));return uLe(s)?s:"point"}}},om=dt([za,iee,h4],bee);function j4(t,e,n,r){if(!(n==null||r==null))return typeof t.scale=="function"?hG(t.scale,n,r):hG(e,n,r)}var D4=(t,e,n)=>{var r=C4(e);if(!(n!=="auto"&&n!=="linear")){if(e!=null&&e.tickCount&&Array.isArray(r)&&(r[0]==="auto"||r[1]==="auto")&&uu(t))return CFe(t,e.tickCount,e.allowDecimals);if(e!=null&&e.tickCount&&e.type==="number"&&uu(t))return kFe(t,e.tickCount,e.allowDecimals)}},R4=dt([E4,rx,om],D4),F4=(t,e,n,r)=>{if(r!=="angleAxis"&&t?.type==="number"&&uu(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],d=(s=n[n.length-1])!==null&&s!==void 0?s:0;return[Math.min(o,l),Math.max(c,d)]}return e},hLe=dt([za,E4,R4,_a],F4),mLe=dt(Wk,za,(t,e)=>{if(!(!e||e.type!=="number")){var n=1/0,r=Array.from(hu(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],d=r[l+1];if(!(c==null||d==null)){var u=d-c;n=Math.min(n,u)}}return n/o}}),xee=dt(mLe,ir,WJ,vi,(t,e,n,r,i)=>i,(t,e,n,r,i)=>{if(!Cn(t))return 0;var s=e==="vertical"?r.height:r.width;if(i==="gap")return t*s/2;if(i==="no-gap"){var o=ys(n,t*s),l=t*s/2;return l-o-(l-o)/s*o}return 0}),fLe=(t,e,n)=>{var r=Gc(t,e);return r==null||typeof r.padding!="string"?0:xee(t,"xAxis",e,n,r.padding)},pLe=(t,e,n)=>{var r=Wc(t,e);return r==null||typeof r.padding!="string"?0:xee(t,"yAxis",e,n,r.padding)},gLe=dt(Gc,fLe,(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}}),bLe=dt(Wc,pLe,(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}}),xLe=dt([vi,gLe,Mk,Tk,(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]}),yLe=dt([vi,ir,bLe,Mk,Tk,(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]}),Rv=(t,e,n,r)=>{var i;switch(e){case"xAxis":return xLe(t,n,r);case"yAxis":return yLe(t,n,r);case"zAxis":return(i=x4(t,n))===null||i===void 0?void 0:i.range;case"angleAxis":return ZJ(t);case"radiusAxis":return JJ(t,n);default:return}},yee=dt([za,Rv],Uk),vLe=dt([om,hLe],nee),Mb=dt([za,om,vLe,yee],j4);dt([jv,Kk,_a],YFe);function vee(t,e){return t.id<e.id?-1:t.id>e.id?1:0}var Xk=(t,e)=>e,Yk=(t,e,n)=>n,wLe=dt(kk,Xk,Yk,(t,e,n)=>t.filter(r=>r.orientation===e).filter(r=>r.mirror===n).sort(vee)),SLe=dt(Ak,Xk,Yk,(t,e,n)=>t.filter(r=>r.orientation===e).filter(r=>r.mirror===n).sort(vee)),wee=(t,e)=>({width:t.width,height:e.height}),_Le=(t,e)=>{var n=typeof e.width=="number"?e.width:vv;return{width:n,height:t.height}},See=dt(vi,Gc,wee),NLe=(t,e,n)=>{switch(e){case"top":return t.top;case"bottom":return n-t.bottom;default:return 0}},CLe=(t,e,n)=>{switch(e){case"left":return t.left;case"right":return n-t.right;default:return 0}},kLe=dt(gu,vi,wLe,Xk,Yk,(t,e,n,r,i)=>{var s={},o;return n.forEach(l=>{var c=wee(e,l);o==null&&(o=NLe(e,r,t));var d=r==="top"&&!i||r==="bottom"&&i;s[l.id]=o-Number(d)*c.height,o+=(d?-1:1)*c.height}),s}),ALe=dt(pu,vi,SLe,Xk,Yk,(t,e,n,r,i)=>{var s={},o;return n.forEach(l=>{var c=_Le(e,l);o==null&&(o=CLe(e,r,t));var d=r==="left"&&!i||r==="right"&&i;s[l.id]=o-Number(d)*c.width,o+=(d?-1:1)*c.width}),s}),TLe=(t,e)=>{var n=Gc(t,e);if(n!=null)return kLe(t,n.orientation,n.mirror)},MLe=dt([vi,Gc,TLe,(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}}}),PLe=(t,e)=>{var n=Wc(t,e);if(n!=null)return ALe(t,n.orientation,n.mirror)},ELe=dt([vi,Wc,PLe,(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}}}),_ee=dt(vi,Wc,(t,e)=>{var n=typeof e.width=="number"?e.width:vv;return{width:n,height:t.height}}),pG=(t,e,n)=>{switch(e){case"xAxis":return See(t,n).width;case"yAxis":return _ee(t,n).height;default:return}},Nee=(t,e,n,r)=>{if(n!=null){var{allowDuplicatedCategory:i,type:s,dataKey:o}=n,l=oc(t,r),c=e.map(d=>d.value);if(o&&l&&s==="category"&&i&&TQ(c))return c}},L4=dt([ir,Wk,za,_a],Nee),Cee=(t,e,n,r)=>{if(!(n==null||n.dataKey==null)){var{type:i,scale:s}=n,o=oc(t,r);if(o&&(i==="number"||s!=="auto"))return e.map(l=>l.value)}},O4=dt([ir,Wk,rx,_a],Cee),gG=dt([ir,HFe,om,Mb,L4,O4,Rv,R4,_a],(t,e,n,r,i,s,o,l,c)=>{if(e!=null){var d=oc(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:d,niceTicks:l,range:o,realScaleType:n,scale:r}}}),jLe=(t,e,n,r,i,s,o,l,c)=>{if(!(e==null||r==null)){var d=oc(t,c),{type:u,ticks:h,tickCount:f}=e,p=n==="scaleBand"&&typeof r.bandwidth=="function"?r.bandwidth()/2:2,x=u==="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 Cn(N)?{index:y,coordinate:N+x,value:g,offset:x}:null}).filter(to):d&&l?l.map((g,y)=>{var _=r.map(g);return Cn(_)?{coordinate:_+x,value:g,index:y,offset:x}:null}).filter(to):r.ticks?r.ticks(f).map((g,y)=>{var _=r.map(g);return Cn(_)?{coordinate:_+x,value:g,index:y,offset:x}:null}).filter(to):r.domain().map((g,y)=>{var _=r.map(g);return Cn(_)?{coordinate:_+x,value:o?o[g]:g,index:y,offset:x}:null}).filter(to)}},kee=dt([ir,rx,om,Mb,R4,Rv,L4,O4,_a],jLe),DLe=(t,e,n,r,i,s,o)=>{if(!(e==null||n==null||r==null||r[0]===r[1])){var l=oc(t,o),{tickCount:c}=e,d=0;return d=o==="angleAxis"&&r?.length>=2?Ri(r[0]-r[1])*2*d:d,l&&s?s.map((u,h)=>{var f=n.map(u);return Cn(f)?{coordinate:f+d,value:u,index:h,offset:d}:null}).filter(to):n.ticks?n.ticks(c).map((u,h)=>{var f=n.map(u);return Cn(f)?{coordinate:f+d,value:u,index:h,offset:d}:null}).filter(to):n.domain().map((u,h)=>{var f=n.map(u);return Cn(f)?{coordinate:f+d,value:i?i[u]:u,index:h,offset:d}:null}).filter(to)}},Uc=dt([ir,rx,Mb,Rv,L4,O4,_a],DLe),Bc=dt(za,Mb,(t,e)=>{if(!(t==null||e==null))return _N(_N({},t),{},{scale:e})}),RLe=dt([za,om,E4,yee],j4);dt((t,e,n)=>x4(t,n),RLe,(t,e)=>{if(!(t==null||e==null))return _N(_N({},t),{},{scale:e})});var FLe=dt([ir,kk,Ak],(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}}),Aee=t=>t.options.defaultTooltipEventType,Tee=t=>t.options.validateTooltipEventTypes;function Mee(t,e,n){if(t==null)return e;var r=t?"axis":"item";return n==null?e:n.includes(r)?r:e}function I4(t,e){var n=Aee(t),r=Tee(t);return Mee(e,n,r)}function LLe(t){return Gt(e=>I4(e,t))}var Pee=(t,e)=>{var n,r=Number(e);if(!(ec(r)||e==null))return r>=0?t==null||(n=t[r])===null||n===void 0?void 0:n.value:void 0},OLe=t=>t.tooltip.settings,gh={active:!1,index:null,dataKey:void 0,graphicalItemId:void 0,coordinate:void 0},ILe={itemInteraction:{click:gh,hover:gh},axisInteraction:{click:gh,hover:gh},keyboardInteraction:gh,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}},Eee=uo({name:"tooltip",initialState:ILe,reducers:{addTooltipEntrySettings:{reducer(t,e){t.tooltipItemPayloads.push(e.payload)},prepare:ma()},replaceTooltipEntrySettings:{reducer(t,e){var{prev:n,next:r}=e.payload,i=Xl(t).tooltipItemPayloads.indexOf(n);i>-1&&(t.tooltipItemPayloads[i]=r)},prepare:ma()},removeTooltipEntrySettings:{reducer(t,e){var n=Xl(t).tooltipItemPayloads.indexOf(e.payload);n>-1&&t.tooltipItemPayloads.splice(n,1)},prepare:ma()},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:zLe,replaceTooltipEntrySettings:ULe,removeTooltipEntrySettings:BLe,setTooltipSettingsState:HLe,setActiveMouseOverItemIndex:jee,mouseLeaveItem:$Le,mouseLeaveChart:Dee,setActiveClickItemIndex:VLe,setMouseOverAxisIndex:Ree,setMouseClickAxisIndex:qLe,setSyncInteraction:aR,setKeyboardInteraction:iR}=Eee.actions,GLe=Eee.reducer;function bG(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function g_(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?bG(Object(n),!0).forEach(function(r){WLe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):bG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function WLe(t,e,n){return(e=KLe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function KLe(t){var e=XLe(t,"string");return typeof e=="symbol"?e:e+""}function XLe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function YLe(t,e,n){return e==="axis"?n==="click"?t.axisInteraction.click:t.axisInteraction.hover:n==="click"?t.itemInteraction.click:t.itemInteraction.hover}function QLe(t){return t.index!=null}var Fee=(t,e,n,r)=>{if(e==null)return gh;var i=YLe(t,e,n);if(i==null)return gh;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(QLe(i)){if(s)return g_(g_({},i),{},{active:!0})}else if(r!=null)return{active:!0,coordinate:void 0,dataKey:void 0,index:r,graphicalItemId:void 0};return g_(g_({},gh),{},{coordinate:i.coordinate})};function ZLe(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 JLe(t,e){var n=ZLe(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 e4e(t,e,n){if(n==null||e==null)return!0;var r=_r(t,e);return r==null||!uu(n)?!0:JLe(r,n)}var z4=(t,e,n,r)=>{var i=t?.index;if(i==null)return null;var s=Number(i);if(!Cn(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)),d=e[c];return d==null||e4e(d,n,r)?String(c):null},Lee=(t,e,n,r,i,s,o)=>{if(s!=null){var l=o[0],c=l?.getPosition(s);if(c!=null)return c;var d=i?.[Number(s)];if(d)return n==="horizontal"?{x:d.coordinate,y:(r.top+e)/2}:{x:(r.left+t)/2,y:d.coordinate}}},Oee=(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})},Iee=t=>t.options.tooltipPayloadSearcher,ix=t=>t.tooltip;function xG(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function yG(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?xG(Object(n),!0).forEach(function(r){t4e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):xG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function t4e(t,e,n){return(e=n4e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function n4e(t){var e=r4e(t,"string");return typeof e=="symbol"?e:e+""}function r4e(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 a4e(t,e){return t??e}var zee=(t,e,n,r,i,s,o)=>{if(!(e==null||s==null)){var{chartData:l,computedData:c,dataStartIndex:d,dataEndIndex:u}=n,h=[];return t.reduce((f,p)=>{var x,{dataDefinedOnItem:v,settings:g}=p,y=a4e(v,l),_=Array.isArray(y)?SZ(y,d,u):y,N=(x=g?.dataKey)!==null&&x!==void 0?x:r,A=g?.nameKey,k;if(r&&Array.isArray(_)&&!Array.isArray(_[0])&&o==="axis"?k=MQ(_,r,i):k=s(_,e,c,A),Array.isArray(k))k.forEach(C=>{var j=yG(yG({},g),{},{name:C.name,unit:C.unit,color:void 0,fill:void 0});f.push(bV({tooltipEntrySettings:j,dataKey:C.dataKey,payload:C.payload,value:_r(C.payload,C.dataKey),name:C.name}))});else{var P;f.push(bV({tooltipEntrySettings:g,dataKey:N,payload:k,value:_r(k,N),name:(P=_r(k,A))!==null&&P!==void 0?P:g?.name}))}return f},h)}},U4=dt([_i,iee,h4],bee),i4e=dt([t=>t.graphicalItems.cartesianItems,t=>t.graphicalItems.polarItems],(t,e)=>[...t,...e]),s4e=dt([Ii,nx],y4),sx=dt([i4e,_i,s4e],v4,{memoizeOptions:{resultEqualityCheck:Gk}}),o4e=dt([sx],t=>t.filter(Vk)),l4e=dt([sx],w4,{memoizeOptions:{resultEqualityCheck:Gk}}),ox=dt([l4e,xu],S4),c4e=dt([o4e,xu,_i],tee),B4=dt([ox,_i,sx],N4),Uee=dt([_i],C4),d4e=dt([_i],t=>t.allowDataOverflow),Bee=dt([Uee,d4e],FJ),u4e=dt([sx],t=>t.filter(Vk)),h4e=dt([c4e,u4e,Mv,KJ],cee),m4e=dt([h4e,xu,Ii,Bee],dee),f4e=dt([sx],oee),p4e=dt([ox,_i,f4e,Kk,Ii],T4,{memoizeOptions:{resultEqualityCheck:qk}}),g4e=dt([uee,Ii,nx],ax),b4e=dt([g4e,Ii],fee),x4e=dt([hee,Ii,nx],ax),y4e=dt([x4e,Ii],pee),v4e=dt([mee,Ii,nx],ax),w4e=dt([v4e,Ii],gee),S4e=dt([b4e,w4e,y4e],CN),_4e=dt([_i,Uee,Bee,m4e,p4e,S4e,ir,Ii],M4),Fv=dt([_i,ir,ox,B4,Mv,Ii,_4e],P4),N4e=dt([Fv,_i,U4],D4),C4e=dt([_i,Fv,N4e,Ii],F4),Hee=t=>{var e=Ii(t),n=nx(t),r=!1;return Rv(t,e,n,r)},$ee=dt([_i,Hee],Uk),Vee=dt([_i,U4,C4e,$ee],j4),k4e=dt([ir,B4,_i,Ii],Nee),A4e=dt([ir,B4,_i,Ii],Cee),T4e=(t,e,n,r,i,s,o,l)=>{if(e){var{type:c}=e,d=oc(t,l);if(r){var u=n==="scaleBand"&&r.bandwidth?r.bandwidth()/2:2,h=c==="category"&&r.bandwidth?r.bandwidth()/u:0;return h=l==="angleAxis"&&i!=null&&i?.length>=2?Ri(i[0]-i[1])*2*h:h,d&&o?o.map((f,p)=>{var x=r.map(f);return Cn(x)?{coordinate:x+h,value:f,index:p,offset:h}:null}).filter(to):r.domain().map((f,p)=>{var x=r.map(f);return Cn(x)?{coordinate:x+h,value:s?s[f]:f,index:p,offset:h}:null}).filter(to)}}},yu=dt([ir,_i,U4,Vee,Hee,k4e,A4e,Ii],T4e),H4=dt([Aee,Tee,OLe],(t,e,n)=>Mee(n.shared,t,e)),qee=t=>t.tooltip.settings.trigger,$4=t=>t.tooltip.settings.defaultIndex,Lv=dt([ix,H4,qee,$4],Fee),Zh=dt([Lv,ox,Dv,Fv],z4),Gee=dt([yu,Zh],Pee),V4=dt([Lv],t=>{if(t)return t.dataKey}),M4e=dt([Lv],t=>{if(t)return t.graphicalItemId}),Wee=dt([ix,H4,qee,$4],Oee),P4e=dt([pu,gu,ir,vi,yu,$4,Wee],Lee),E4e=dt([Lv,P4e],(t,e)=>t!=null&&t.coordinate?t.coordinate:e),j4e=dt([Lv],t=>{var e;return(e=t?.active)!==null&&e!==void 0?e:!1}),D4e=dt([Wee,Zh,xu,Dv,Gee,Iee,H4],zee),R4e=dt([D4e],t=>{if(t!=null){var e=t.map(n=>n.payload).filter(n=>n!=null);return Array.from(new Set(e))}});function vG(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function wG(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?vG(Object(n),!0).forEach(function(r){F4e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):vG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function F4e(t,e,n){return(e=L4e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function L4e(t){var e=O4e(t,"string");return typeof e=="symbol"?e:e+""}function O4e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var I4e=()=>Gt(_i),z4e=()=>{var t=I4e(),e=Gt(yu),n=Gt(Vee);return Qh(!t||!n?void 0:wG(wG({},t),{},{scale:n}),e)};function SG(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Sg(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?SG(Object(n),!0).forEach(function(r){U4e(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 U4e(t,e,n){return(e=B4e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function B4e(t){var e=H4e(t,"string");return typeof e=="symbol"?e:e+""}function H4e(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 $4e=(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}},V4e=(t,e,n,r)=>{var i=e.find(d=>d&&d.index===n);if(i){if(t==="centric"){var s=i.coordinate,{radius:o}=r;return Sg(Sg(Sg({},r),ti(r.cx,r.cy,o,s)),{},{angle:s,radius:o})}var l=i.coordinate,{angle:c}=r;return Sg(Sg(Sg({},r),ti(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 q4e(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 Kee=(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,d,u,h,f,p=l>0?(c=n[l-1])===null||c===void 0?void 0:c.coordinate:(d=n[o-1])===null||d===void 0?void 0:d.coordinate,x=(u=n[l])===null||u===void 0?void 0:u.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 k;return(k=n[l])===null||k===void 0?void 0:k.index}}else{var P=Math.min(p,v),C=Math.max(p,v);if(t>(P+x)/2&&t<=(C+x)/2){var j;return(j=n[l])===null||j===void 0?void 0:j.index}}}else if(e)for(var M=0;M<o;M++){var E=e[M];if(E!=null){var B=e[M+1],L=e[M-1];if(M===0&&B!=null&&t<=(E.coordinate+B.coordinate)/2||M===o-1&&L!=null&&t>(E.coordinate+L.coordinate)/2||M>0&&M<o-1&&L!=null&&B!=null&&t>(E.coordinate+L.coordinate)/2&&t<=(E.coordinate+B.coordinate)/2)return E.index}}return-1},Xee=()=>Gt(h4),q4=(t,e)=>e,Yee=(t,e,n)=>n,G4=(t,e,n,r)=>r,G4e=dt(yu,t=>gk(t,e=>e.coordinate)),W4=dt([ix,q4,Yee,G4],Fee),K4=dt([W4,ox,Dv,Fv],z4),W4e=(t,e,n)=>{if(e!=null){var r=ix(t);return e==="axis"?n==="hover"?r.axisInteraction.hover.dataKey:r.axisInteraction.click.dataKey:n==="hover"?r.itemInteraction.hover.dataKey:r.itemInteraction.click.dataKey}},Qee=dt([ix,q4,Yee,G4],Oee),kN=dt([pu,gu,ir,vi,yu,G4,Qee],Lee),K4e=dt([W4,kN],(t,e)=>{var n;return(n=t.coordinate)!==null&&n!==void 0?n:e}),Zee=dt([yu,K4],Pee),X4e=dt([Qee,K4,xu,Dv,Zee,Iee,q4],zee),Y4e=dt([W4,K4],(t,e)=>({isActive:t.active&&e!=null,activeIndex:e})),Q4e=(t,e,n,r,i,s,o)=>{if(!(!t||!n||!r||!i)&&q4e(t,o)){var l=yEe(t,e),c=Kee(l,s,i,n,r),d=$4e(e,i,c,t);return{activeIndex:String(c),activeCoordinate:d}}},Z4e=(t,e,n,r,i,s,o)=>{if(!(!t||!r||!i||!s||!n)){var l=L3e(t,n);if(l){var c=vEe(l,e),d=Kee(c,o,s,r,i),u=V4e(e,s,d,l);return{activeIndex:String(d),activeCoordinate:u}}}},J4e=(t,e,n,r,i,s,o,l)=>{if(!(!t||!e||!r||!i||!s))return e==="horizontal"||e==="vertical"?Q4e(t,e,r,i,s,o,l):Z4e(t,e,n,r,i,s,o)},eOe=dt(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}}),tOe=dt(t=>t.zIndex.zIndexMap,t=>{var e=Object.keys(t).map(r=>parseInt(r,10)).concat(Object.values(La)),n=Array.from(new Set(e));return n.sort((r,i)=>r-i)},{memoizeOptions:{resultEqualityCheck:LFe}});function _G(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 NG(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?_G(Object(n),!0).forEach(function(r){nOe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):_G(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function nOe(t,e,n){return(e=rOe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function rOe(t){var e=aOe(t,"string");return typeof e=="symbol"?e:e+""}function aOe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var iOe={},sOe={zIndexMap:Object.values(La).reduce((t,e)=>NG(NG({},t),{},{[e]:{element:void 0,panoramaElement:void 0,consumers:0}}),iOe)},oOe=new Set(Object.values(La));function lOe(t){return oOe.has(t)}var Jee=uo({name:"zIndex",initialState:sOe,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:ma()},unregisterZIndexPortal:{reducer:(t,e)=>{var{zIndex:n}=e.payload;t.zIndexMap[n]&&(t.zIndexMap[n].consumers-=1,t.zIndexMap[n].consumers<=0&&!lOe(n)&&delete t.zIndexMap[n])},prepare:ma()},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:ma()},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:ma()}}}),{registerZIndexPortal:cOe,unregisterZIndexPortal:dOe,registerZIndexPortalElement:uOe,unregisterZIndexPortalElement:hOe}=Jee.actions,mOe=Jee.reducer;function Ss(t){var{zIndex:e,children:n}=t,r=QEe(),i=r&&e!==void 0&&e!==0,s=wi(),o=Yr();w.useLayoutEffect(()=>i?(o(cOe({zIndex:e})),()=>{o(dOe({zIndex:e}))}):nm,[o,e,i]);var l=Gt(c=>eOe(c,e,s));return i?l?Ld.createPortal(n,l):null:n}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 CG(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 b_(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?CG(Object(n),!0).forEach(function(r){fOe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):CG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function fOe(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=gOe(t,"string");return typeof e=="symbol"?e:e+""}function gOe(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 bOe(t){var{cursor:e,cursorComp:n,cursorProps:r}=t;return w.isValidElement(e)?w.cloneElement(e,r):w.createElement(n,r)}function xOe(t){var e,{coordinate:n,payload:r,index:i,offset:s,tooltipAxisBandSize:o,layout:l,cursor:c,tooltipEventType:d,chartName:u}=t,h=n,f=r,p=i;if(!c||!h||u!=="ScatterChart"&&d!=="axis")return null;var x,v,g;if(u==="ScatterChart")x=h,v=Yje,g=La.cursorLine;else if(u==="BarChart")x=Qje(l,h,s,o),v=XZ,g=La.cursorRectangle;else if(l==="radial"&&EQ(h)){var{cx:y,cy:_,radius:N,startAngle:A,endAngle:k}=QZ(h);x={cx:y,cy:_,startAngle:A,endAngle:k,innerRadius:N,outerRadius:N},v=JZ,g=La.cursorLine}else x={points:U3e(l,h,s)},v=rb,g=La.cursorLine;var P=typeof c=="object"&&"className"in c?c.className:void 0,C=b_(b_(b_(b_({stroke:"#ccc",pointerEvents:"none"},s),x),zf(c)),{},{payload:f,payloadIndex:p,className:cr("recharts-tooltip-cursor",P)});return w.createElement(Ss,{zIndex:(e=t.zIndex)!==null&&e!==void 0?e:g},w.createElement(bOe,{cursor:c,cursorComp:v,cursorProps:C}))}function yOe(t){var e=z4e(),n=jZ(),r=am(),i=Xee();return e==null||n==null||r==null||i==null?null:w.createElement(xOe,sR({},t,{offset:n,layout:r,tooltipAxisBandSize:e,chartName:i}))}var ete=w.createContext(null),vOe=()=>w.useContext(ete),CE={exports:{}},kG;function wOe(){return kG||(kG=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,d,u){this.fn=c,this.context=d,this.once=u||!1}function s(c,d,u,h,f){if(typeof u!="function")throw new TypeError("The listener must be a function");var p=new i(u,h||c,f),x=n?n+d:d;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,d){--c._eventsCount===0?c._events=new r:delete c._events[d]}function l(){this._events=new r,this._eventsCount=0}l.prototype.eventNames=function(){var d=[],u,h;if(this._eventsCount===0)return d;for(h in u=this._events)e.call(u,h)&&d.push(n?h.slice(1):h);return Object.getOwnPropertySymbols?d.concat(Object.getOwnPropertySymbols(u)):d},l.prototype.listeners=function(d){var u=n?n+d:d,h=this._events[u];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(d){var u=n?n+d:d,h=this._events[u];return h?h.fn?1:h.length:0},l.prototype.emit=function(d,u,h,f,p,x){var v=n?n+d:d;if(!this._events[v])return!1;var g=this._events[v],y=arguments.length,_,N;if(g.fn){switch(g.once&&this.removeListener(d,g.fn,void 0,!0),y){case 1:return g.fn.call(g.context),!0;case 2:return g.fn.call(g.context,u),!0;case 3:return g.fn.call(g.context,u,h),!0;case 4:return g.fn.call(g.context,u,h,f),!0;case 5:return g.fn.call(g.context,u,h,f,p),!0;case 6:return g.fn.call(g.context,u,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,k;for(N=0;N<A;N++)switch(g[N].once&&this.removeListener(d,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,u);break;case 3:g[N].fn.call(g[N].context,u,h);break;case 4:g[N].fn.call(g[N].context,u,h,f);break;default:if(!_)for(k=1,_=new Array(y-1);k<y;k++)_[k-1]=arguments[k];g[N].fn.apply(g[N].context,_)}}return!0},l.prototype.on=function(d,u,h){return s(this,d,u,h,!1)},l.prototype.once=function(d,u,h){return s(this,d,u,h,!0)},l.prototype.removeListener=function(d,u,h,f){var p=n?n+d:d;if(!this._events[p])return this;if(!u)return o(this,p),this;var x=this._events[p];if(x.fn)x.fn===u&&(!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!==u||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(d){var u;return d?(u=n?n+d:d,this._events[u]&&o(this,u)):(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})(CE)),CE.exports}var SOe=wOe();const _Oe=rc(SOe);var B0=new _Oe,oR="recharts.syncEvent.tooltip",AG="recharts.syncEvent.brush",Qk=(t,e)=>{if(e&&Array.isArray(t)){var n=Number.parseInt(e,10);if(!ec(n))return t[n]}},NOe={chartName:"",tooltipPayloadSearcher:()=>{},eventEmitter:void 0,defaultTooltipEventType:"axis"},tte=uo({name:"options",initialState:NOe,reducers:{createEventEmitter:t=>{t.eventEmitter==null&&(t.eventEmitter=Symbol("rechartsEventEmitter"))}}}),COe=tte.reducer,{createEventEmitter:kOe}=tte.actions;function AOe(t){return t.tooltip.syncInteraction}var TOe={chartData:void 0,computedData:void 0,dataStartIndex:0,dataEndIndex:0},nte=uo({name:"chartData",initialState:TOe,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:TG,setDataStartEndIndexes:MOe,setComputedData:hnt}=nte.actions,POe=nte.reducer,EOe=["x","y"];function MG(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function _g(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?MG(Object(n),!0).forEach(function(r){jOe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):MG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function jOe(t,e,n){return(e=DOe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function DOe(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)}function FOe(t,e){if(t==null)return{};var n,r,i=LOe(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 LOe(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 OOe(){var t=Gt(m4),e=Gt(f4),n=Yr(),r=Gt(XJ),i=Gt(yu),s=am(),o=wv(),l=Gt(c=>c.rootProps.className);w.useEffect(()=>{if(t==null)return nm;var c=(d,u,h)=>{if(e!==h&&t===d){if(r==="index"){var f;if(o&&u!==null&&u!==void 0&&(f=u.payload)!==null&&f!==void 0&&f.coordinate&&u.payload.sourceViewBox){var p=u.payload.coordinate,{x,y:v}=p,g=FOe(p,EOe),{x:y,y:_,width:N,height:A}=u.payload.sourceViewBox,k=_g(_g({},g),{},{x:o.x+(N?(x-y)/N:0)*o.width,y:o.y+(A?(v-_)/A:0)*o.height});n(_g(_g({},u),{},{payload:_g(_g({},u.payload),{},{coordinate:k})}))}else n(u);return}if(i!=null){var P;if(typeof r=="function"){var C={activeTooltipIndex:u.payload.index==null?void 0:Number(u.payload.index),isTooltipActive:u.payload.active,activeIndex:u.payload.index==null?void 0:Number(u.payload.index),activeLabel:u.payload.label,activeDataKey:u.payload.dataKey,activeCoordinate:u.payload.coordinate},j=r(i,C);P=i[j]}else r==="value"&&(P=i.find(q=>String(q.value)===u.payload.label));var{coordinate:M}=u.payload;if(P==null||u.payload.active===!1||M==null||o==null){n(aR({active:!1,coordinate:void 0,dataKey:void 0,index:null,label:void 0,sourceViewBox:void 0,graphicalItemId:void 0}));return}var{x:E,y:B}=M,L=Math.min(E,o.x+o.width),U=Math.min(B,o.y+o.height),D={x:s==="horizontal"?P.coordinate:L,y:s==="horizontal"?U:P.coordinate},$=aR({active:u.payload.active,coordinate:D,dataKey:u.payload.dataKey,index:String(P.index),label:u.payload.label,sourceViewBox:u.payload.sourceViewBox,graphicalItemId:u.payload.graphicalItemId});n($)}}};return B0.on(oR,c),()=>{B0.off(oR,c)}},[l,n,e,t,r,i,s,o])}function IOe(){var t=Gt(m4),e=Gt(f4),n=Yr();w.useEffect(()=>{if(t==null)return nm;var r=(i,s,o)=>{e!==o&&t===i&&n(MOe(s))};return B0.on(AG,r),()=>{B0.off(AG,r)}},[n,e,t])}function zOe(){var t=Yr();w.useEffect(()=>{t(kOe())},[t]),OOe(),IOe()}function UOe(t,e,n,r,i,s){var o=Gt(p=>W4e(p,t,e)),l=Gt(f4),c=Gt(m4),d=Gt(XJ),u=Gt(AOe),h=u?.active,f=wv();w.useEffect(()=>{if(!h&&c!=null&&l!=null){var p=aR({active:s,coordinate:n,dataKey:o,index:i,label:typeof r=="number"?String(r):r,sourceViewBox:f,graphicalItemId:void 0});B0.emit(oR,c,p,l)}},[h,n,o,i,r,l,c,d,s,f])}function PG(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function EG(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?PG(Object(n),!0).forEach(function(r){BOe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):PG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function BOe(t,e,n){return(e=HOe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function HOe(t){var e=$Oe(t,"string");return typeof e=="symbol"?e:e+""}function $Oe(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 VOe(t){return t.dataKey}function qOe(t,e){return w.isValidElement(t)?w.cloneElement(t,e):typeof t=="function"?w.createElement(t,e):w.createElement(Mje,e)}var jG=[],GOe={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 n1(t){var e,n,r=Sa(t,GOe),{active:i,allowEscapeViewBox:s,animationDuration:o,animationEasing:l,content:c,filterNull:d,isAnimationActive:u,offset:h,payloadUniqBy:f,position:p,reverseDirection:x,useTranslate3d:v,wrapperStyle:g,cursor:y,shared:_,trigger:N,defaultIndex:A,portal:k,axisId:P}=r,C=Yr(),j=typeof A=="number"?String(A):A;w.useEffect(()=>{C(HLe({shared:_,trigger:N,axisId:P,active:i,defaultIndex:j}))},[C,_,N,P,i,j]);var M=wv(),E=VZ(),B=LLe(_),{activeIndex:L,isActive:U}=(e=Gt(ie=>Y4e(ie,B,N,j)))!==null&&e!==void 0?e:{},D=Gt(ie=>X4e(ie,B,N,j)),$=Gt(ie=>Zee(ie,B,N,j)),q=Gt(ie=>K4e(ie,B,N,j)),z=D,W=vOe(),Q=(n=i??U)!==null&&n!==void 0?n:!1,[te,H]=GQ([z,Q]),X=B==="axis"?$:void 0;UOe(B,N,q,X,L,Q);var Z=k??W;if(Z==null||M==null||B==null)return null;var ee=z??jG;Q||(ee=jG),d&&ee.length&&(ee=UQ(ee.filter(ie=>ie.value!=null&&(ie.hide!==!0||r.includeHidden)),f,VOe));var Se=ee.length>0,oe=w.createElement(Lje,{allowEscapeViewBox:s,animationDuration:o,animationEasing:l,isAnimationActive:u,active:Q,coordinate:q,hasPayload:Se,offset:h,position:p,reverseDirection:x,useTranslate3d:v,viewBox:M,wrapperStyle:g,lastBoundingBox:te,innerRef:H,hasPortalFromProps:!!k},qOe(c,EG(EG({},r),{},{payload:ee,label:X,active:Q,activeIndex:L,coordinate:q,accessibilityLayer:E})));return w.createElement(w.Fragment,null,Ld.createPortal(oe,Z),Q&&w.createElement(yOe,{cursor:y,tooltipEventType:B,coordinate:q,payload:ee,index:L}))}var Ov=t=>null;Ov.displayName="Cell";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=XOe(t,"string");return typeof e=="symbol"?e:e+""}function XOe(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 YOe{constructor(e){WOe(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 DG(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function QOe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?DG(Object(n),!0).forEach(function(r){ZOe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):DG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function ZOe(t,e,n){return(e=JOe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function JOe(t){var e=eIe(t,"string");return typeof e=="symbol"?e:e+""}function eIe(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 tIe={cacheSize:2e3,enableCache:!0},rte=QOe({},tIe),RG=new YOe(rte.cacheSize),nIe={position:"absolute",top:"-20000px",left:0,padding:0,margin:0,border:"none",whiteSpace:"pre"},FG="recharts_measurement_span";function rIe(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 LG=(t,e)=>{try{var n=document.getElementById(FG);n||(n=document.createElement("span"),n.setAttribute("id",FG),n.setAttribute("aria-hidden","true"),document.body.appendChild(n)),Object.assign(n.style,nIe,e),n.textContent="".concat(t);var r=n.getBoundingClientRect();return{width:r.width,height:r.height}}catch{return{width:0,height:0}}},Wy=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(e==null||Nv.isSsr)return{width:0,height:0};if(!rte.enableCache)return LG(e,n);var r=rIe(e,n),i=RG.get(r);if(i)return i;var s=LG(e,n);return RG.set(r,s),s},ate;function aIe(t,e,n){return(e=iIe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function iIe(t){var e=sIe(t,"string");return typeof e=="symbol"?e:e+""}function sIe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var OG=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([*/])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,IG=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([+-])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,oIe=/^px|cm|vh|vw|em|rem|%|mm|in|pt|pc|ex|ch|vmin|vmax|Q$/,lIe=/(-?\d+(?:\.\d+)?)([a-zA-Z%]+)?/,cIe={cm:96/2.54,mm:96/25.4,pt:96/72,pc:96/6,in:96,Q:96/(2.54*40),px:1},dIe=["cm","mm","pt","pc","in","Q","px"];function uIe(t){return dIe.includes(t)}var Hg="NaN";function hIe(t,e){return t*cIe[e]}class Yi{static parse(e){var n,[,r,i]=(n=lIe.exec(e))!==null&&n!==void 0?n:[];return r==null?Yi.NaN:new Yi(parseFloat(r),i??"")}constructor(e,n){this.num=e,this.unit=n,this.num=e,this.unit=n,ec(e)&&(this.unit=""),n!==""&&!oIe.test(n)&&(this.num=NaN,this.unit=""),uIe(n)&&(this.num=hIe(e,n),this.unit="px")}add(e){return this.unit!==e.unit?new Yi(NaN,""):new Yi(this.num+e.num,this.unit)}subtract(e){return this.unit!==e.unit?new Yi(NaN,""):new Yi(this.num-e.num,this.unit)}multiply(e){return this.unit!==""&&e.unit!==""&&this.unit!==e.unit?new Yi(NaN,""):new Yi(this.num*e.num,this.unit||e.unit)}divide(e){return this.unit!==""&&e.unit!==""&&this.unit!==e.unit?new Yi(NaN,""):new Yi(this.num/e.num,this.unit||e.unit)}toString(){return"".concat(this.num).concat(this.unit)}isNaN(){return ec(this.num)}}ate=Yi;aIe(Yi,"NaN",new ate(NaN,""));function ite(t){if(t==null||t.includes(Hg))return Hg;for(var e=t;e.includes("*")||e.includes("/");){var n,[,r,i,s]=(n=OG.exec(e))!==null&&n!==void 0?n:[],o=Yi.parse(r??""),l=Yi.parse(s??""),c=i==="*"?o.multiply(l):o.divide(l);if(c.isNaN())return Hg;e=e.replace(OG,c.toString())}for(;e.includes("+")||/.-\d+(?:\.\d+)?/.test(e);){var d,[,u,h,f]=(d=IG.exec(e))!==null&&d!==void 0?d:[],p=Yi.parse(u??""),x=Yi.parse(f??""),v=h==="+"?p.add(x):p.subtract(x);if(v.isNaN())return Hg;e=e.replace(IG,v.toString())}return e}var zG=/\(([^()]*)\)/;function mIe(t){for(var e=t,n;(n=zG.exec(e))!=null;){var[,r]=n;e=e.replace(zG,ite(r))}return e}function fIe(t){var e=t.replace(/\s+/g,"");return e=mIe(e),e=ite(e),e}function pIe(t){try{return fIe(t)}catch{return Hg}}function kE(t){var e=pIe(t.slice(5,-1));return e===Hg?"":e}var gIe=["x","y","lineHeight","capHeight","fill","scaleToFit","textAnchor","verticalAnchor"],bIe=["dx","dy","angle","className","breakAll"];function lR(){return lR=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},lR.apply(null,arguments)}function UG(t,e){if(t==null)return{};var n,r,i=xIe(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 xIe(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 ste=/[ \f\n\r\t\v\u2028\u2029]+/,ote=t=>{var{children:e,breakAll:n,style:r}=t;try{var i=[];ba(e)||(n?i=e.toString().split(""):i=e.toString().split(ste));var s=i.map(l=>({word:l,width:Wy(l,r).width})),o=n?0:Wy(" ",r).width;return{wordsWithComputedWidth:s,spaceWidth:o}}catch{return null}};function yIe(t){return t==="start"||t==="middle"||t==="end"||t==="inherit"}var lte=(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 d={words:[o],width:l};i.push(d)}return i},[]),cte=t=>t.reduce((e,n)=>e.width>n.width?e:n),vIe="…",BG=(t,e,n,r,i,s,o,l)=>{var c=t.slice(0,e),d=ote({breakAll:n,style:r,children:c+vIe});if(!d)return[!1,[]];var u=lte(d.wordsWithComputedWidth,s,o,l),h=u.length>i||cte(u).width>Number(s);return[h,u]},wIe=(t,e,n,r,i)=>{var{maxLines:s,children:o,style:l,breakAll:c}=t,d=$t(s),u=String(o),h=lte(e,r,n,i);if(!d||i)return h;var f=h.length>s||cte(h).width>Number(r);if(!f)return h;for(var p=0,x=u.length-1,v=0,g;p<=x&&v<=u.length-1;){var y=Math.floor((p+x)/2),_=y-1,[N,A]=BG(u,_,c,l,s,r,n,i),[k]=BG(u,y,c,l,s,r,n,i);if(!N&&!k&&(p=y+1),N&&k&&(x=y-1),!N&&k){g=A;break}v++}return g||h},HG=t=>{var e=ba(t)?[]:t.toString().split(ste);return[{words:e,width:void 0}]},SIe=t=>{var{width:e,scaleToFit:n,children:r,style:i,breakAll:s,maxLines:o}=t;if((e||n)&&!Nv.isSsr){var l,c,d=ote({breakAll:s,children:r,style:i});if(d){var{wordsWithComputedWidth:u,spaceWidth:h}=d;l=u,c=h}else return HG(r);return wIe({breakAll:s,children:r,maxLines:o,style:i},l,c,e,!!n)}return HG(r)},dte="#808080",_Ie={angle:0,breakAll:!1,capHeight:"0.71em",fill:dte,lineHeight:"1em",scaleToFit:!1,textAnchor:"start",verticalAnchor:"end",x:0,y:0},Zk=w.forwardRef((t,e)=>{var n=Sa(t,_Ie),{x:r,y:i,lineHeight:s,capHeight:o,fill:l,scaleToFit:c,textAnchor:d,verticalAnchor:u}=n,h=UG(n,gIe),f=w.useMemo(()=>SIe({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,_=UG(h,bIe);if(!Cl(r)||!Cl(i)||f.length===0)return null;var N=Number(r)+($t(p)?p:0),A=Number(i)+($t(x)?x:0);if(!Cn(N)||!Cn(A))return null;var k;switch(u){case"start":k=kE("calc(".concat(o,")"));break;case"middle":k=kE("calc(".concat((f.length-1)/2," * -").concat(s," + (").concat(o," / 2))"));break;default:k=kE("calc(".concat(f.length-1," * -").concat(s,")"));break}var P=[],C=f[0];if(c&&C!=null){var j=C.width,{width:M}=h;P.push("scale(".concat($t(M)&&$t(j)?M/j:1,")"))}return v&&P.push("rotate(".concat(v,", ").concat(N,", ").concat(A,")")),P.length&&(_.transform=P.join(" ")),w.createElement("text",lR({},rs(_),{ref:e,x:N,y:A,className:cr("recharts-text",g),textAnchor:d,fill:l.includes("url")?dte:l}),f.map((E,B)=>{var L=E.words.join(y?"":" ");return w.createElement("tspan",{x:N,dy:B===0?k:s,key:"".concat(L,"-").concat(B)},L)}))});Zk.displayName="Text";function $G(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 xc(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?$G(Object(n),!0).forEach(function(r){NIe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):$G(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function NIe(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=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)}var AIe=t=>{var{viewBox:e,position:n,offset:r=0,parentViewBox:i}=t,{x:s,y:o,height:l,upperWidth:c,lowerWidth:d}=DL(e),u=s,h=s+(c-d)/2,f=(u+h)/2,p=(c+d)/2,x=u+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,k=N>0?"end":"start",P=N>0?"start":"end",C=i;if(n==="top"){var j={x:u+c/2,y:o-g,horizontalAnchor:"middle",verticalAnchor:y};return C&&(j.height=Math.max(o-C.y,0),j.width=c),j}if(n==="bottom"){var M={x:h+d/2,y:o+l+g,horizontalAnchor:"middle",verticalAnchor:_};return C&&(M.height=Math.max(C.y+C.height-(o+l),0),M.width=d),M}if(n==="left"){var E={x:f-A,y:o+l/2,horizontalAnchor:k,verticalAnchor:"middle"};return C&&(E.width=Math.max(E.x-C.x,0),E.height=l),E}if(n==="right"){var B={x:f+p+A,y:o+l/2,horizontalAnchor:P,verticalAnchor:"middle"};return C&&(B.width=Math.max(C.x+C.width-B.x,0),B.height=l),B}var L=C?{width:p,height:l}:{};return n==="insideLeft"?xc({x:f+A,y:o+l/2,horizontalAnchor:P,verticalAnchor:"middle"},L):n==="insideRight"?xc({x:f+p-A,y:o+l/2,horizontalAnchor:k,verticalAnchor:"middle"},L):n==="insideTop"?xc({x:u+c/2,y:o+g,horizontalAnchor:"middle",verticalAnchor:_},L):n==="insideBottom"?xc({x:h+d/2,y:o+l-g,horizontalAnchor:"middle",verticalAnchor:y},L):n==="insideTopLeft"?xc({x:u+A,y:o+g,horizontalAnchor:P,verticalAnchor:_},L):n==="insideTopRight"?xc({x:u+c-A,y:o+g,horizontalAnchor:k,verticalAnchor:_},L):n==="insideBottomLeft"?xc({x:h+A,y:o+l-g,horizontalAnchor:P,verticalAnchor:y},L):n==="insideBottomRight"?xc({x:h+d-A,y:o+l-g,horizontalAnchor:k,verticalAnchor:y},L):n&&typeof n=="object"&&($t(n.x)||Hf(n.x))&&($t(n.y)||Hf(n.y))?xc({x:s+ys(n.x,p),y:o+ys(n.y,l),horizontalAnchor:"end",verticalAnchor:"end"},L):xc({x,y:o+l/2,horizontalAnchor:"middle",verticalAnchor:"middle"},L)},TIe=["labelRef"],MIe=["content"];function VG(t,e){if(t==null)return{};var n,r,i=PIe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function PIe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function qG(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 Ey(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?qG(Object(n),!0).forEach(function(r){EIe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):qG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function EIe(t,e,n){return(e=jIe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function jIe(t){var e=DIe(t,"string");return typeof e=="symbol"?e:e+""}function DIe(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 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)}var ute=w.createContext(null),hte=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(ute.Provider,{value:c},l)},mte=()=>{var t=w.useContext(ute),e=wv();return t||(e?DL(e):void 0)},RIe=w.createContext(null),FIe=()=>{var t=w.useContext(RIe),e=Gt(eee);return t||e},LIe=t=>{var{value:e,formatter:n}=t,r=ba(t.children)?e:t.children;return typeof n=="function"?n(r):r},X4=t=>t!=null&&typeof t=="function",OIe=(t,e)=>{var n=Ri(e-t),r=Math.min(Math.abs(e-t),360);return n*r},IIe=(t,e,n,r,i)=>{var{offset:s,className:o}=t,{cx:l,cy:c,innerRadius:d,outerRadius:u,startAngle:h,endAngle:f,clockWise:p}=i,x=(d+u)/2,v=OIe(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=ti(l,c,x,y),A=ti(l,c,x,y+(_?1:-1)*359),k="M".concat(N.x,",").concat(N.y,`
- A`).concat(x,",").concat(x,",0,1,").concat(_?0:1,`,
- `).concat(A.x,",").concat(A.y),P=ba(t.id)?T0("recharts-radial-line-"):t.id;return w.createElement("text",Fd({},r,{dominantBaseline:"central",className:cr("recharts-radial-bar-label",o)}),w.createElement("defs",null,w.createElement("path",{id:P,d:k})),w.createElement("textPath",{xlinkHref:"#".concat(P)},n))},zIe=(t,e,n)=>{var{cx:r,cy:i,innerRadius:s,outerRadius:o,startAngle:l,endAngle:c}=t,d=(l+c)/2;if(n==="outside"){var{x:u,y:h}=ti(r,i,o+e,d);return{x:u,y:h,textAnchor:u>=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}=ti(r,i,f,d);return{x:p,y:x,textAnchor:"middle",verticalAnchor:"middle"}},r1=t=>t!=null&&"cx"in t&&$t(t.cx),UIe={angle:0,offset:5,zIndex:La.label,position:"middle",textBreakAll:!1};function BIe(t){if(!r1(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 ch(t){var e=Sa(t,UIe),{viewBox:n,parentViewBox:r,position:i,value:s,children:o,content:l,className:c="",textBreakAll:d,labelRef:u}=e,h=FIe(),f=mte(),p=i==="center"?f:h??f,x,v,g;n==null?x=p:r1(n)?x=n:x=DL(n);var y=BIe(x);if(!x||ba(s)&&ba(o)&&!w.isValidElement(l)&&typeof l!="function")return null;var _=Ey(Ey({},e),{},{viewBox:x});if(w.isValidElement(l)){var{labelRef:N}=_,A=VG(_,TIe);return w.cloneElement(l,A)}if(typeof l=="function"){var{content:k}=_,P=VG(_,MIe);if(v=w.createElement(l,P),w.isValidElement(v))return v}else v=LIe(e);var C=rs(e);if(r1(x)){if(i==="insideStart"||i==="insideEnd"||i==="end")return IIe(e,i,v,C,x);g=zIe(x,e.offset,e.position)}else{if(!y)return null;var j=AIe({viewBox:y,position:i,offset:e.offset,parentViewBox:r1(r)?void 0:r});g=Ey(Ey({x:j.x,y:j.y,textAnchor:j.horizontalAnchor,verticalAnchor:j.verticalAnchor},j.width!==void 0?{width:j.width}:{}),j.height!==void 0?{height:j.height}:{})}return w.createElement(Ss,{zIndex:e.zIndex},w.createElement(Zk,Fd({ref:u,className:cr("recharts-label",c)},C,g,{textAnchor:yIe(C.textAnchor)?C.textAnchor:g.textAnchor,breakAll:d}),v))}ch.displayName="Label";var HIe=(t,e,n)=>{if(!t)return null;var r={viewBox:e,labelRef:n};return t===!0?w.createElement(ch,Fd({key:"label-implicit"},r)):Cl(t)?w.createElement(ch,Fd({key:"label-implicit",value:t},r)):w.isValidElement(t)?t.type===ch?w.cloneElement(t,Ey({key:"label-implicit"},r)):w.createElement(ch,Fd({key:"label-implicit",content:t},r)):X4(t)?w.createElement(ch,Fd({key:"label-implicit",content:t},r)):t&&typeof t=="object"?w.createElement(ch,Fd({},t,{key:"label-implicit"},r)):null};function fte(t){var{label:e,labelRef:n}=t,r=mte();return HIe(e,r,n)||null}var AE={},TE={},GG;function $Ie(){return GG||(GG=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n[n.length-1]}t.last=e})(TE)),TE}var ME={},WG;function VIe(){return WG||(WG=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Array.isArray(n)?n:Array.from(n)}t.toArray=e})(ME)),ME}var KG;function qIe(){return KG||(KG=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=$Ie(),n=VIe(),r=SL();function i(s){if(r.isArrayLike(s))return e.last(n.toArray(s))}t.last=i})(AE)),AE}var PE,XG;function GIe(){return XG||(XG=1,PE=qIe().last),PE}var WIe=GIe();const KIe=rc(WIe);var XIe=["valueAccessor"],YIe=["dataKey","clockWise","id","textBreakAll","zIndex"];function AN(){return AN=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},AN.apply(null,arguments)}function YG(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}var ZIe=t=>Array.isArray(t.value)?KIe(t.value):t.value,pte=w.createContext(void 0),Y4=pte.Provider,gte=w.createContext(void 0),JIe=gte.Provider;function e5e(){return w.useContext(pte)}function t5e(){return w.useContext(gte)}function a1(t){var{valueAccessor:e=ZIe}=t,n=YG(t,XIe),{dataKey:r,clockWise:i,id:s,textBreakAll:o,zIndex:l}=n,c=YG(n,YIe),d=e5e(),u=t5e(),h=d||u;return!h||!h.length?null:w.createElement(Ss,{zIndex:l??La.label},w.createElement(wa,{className:"recharts-label-list"},h.map((f,p)=>{var x,v=ba(r)?e(f,p):_r(f.payload,r),g=ba(s)?{}:{id:"".concat(s,"-").concat(p)};return w.createElement(ch,AN({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}))})))}a1.displayName="LabelList";function Jk(t){var{label:e}=t;return e?e===!0?w.createElement(a1,{key:"labelList-implicit"}):w.isValidElement(e)||X4(e)?w.createElement(a1,{key:"labelList-implicit",content:e}):typeof e=="object"?w.createElement(a1,AN({key:"labelList-implicit"},e,{type:String(e.type)})):null:null}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)}var bte=t=>{var{cx:e,cy:n,r,className:i}=t,s=cr("recharts-dot",i);return $t(e)&&$t(n)&&$t(r)?w.createElement("circle",cR({},Ls(t),wL(t),{className:s,cx:e,cy:n,r})):null},xte=t=>t.graphicalItems.polarItems,n5e=dt([_a,Pv],y4),eA=dt([xte,za,n5e],v4),r5e=dt([eA],w4),tA=dt([r5e,zk],S4),a5e=dt([tA,za,eA],N4);dt([tA,za,eA],(t,e,n)=>n.length>0?t.flatMap(r=>n.flatMap(i=>{var s,o=_r(r,(s=e.dataKey)!==null&&s!==void 0?s:i.dataKey);return{value:o,errorDomain:[]}})).filter(Boolean):e?.dataKey!=null?t.map(r=>({value:_r(r,e.dataKey),errorDomain:[]})):t.map(r=>({value:r,errorDomain:[]})));var QG=()=>{},i5e=dt([tA,za,eA,Kk,_a],T4),s5e=dt([za,k4,A4,QG,i5e,QG,ir,_a],M4),yte=dt([za,ir,tA,a5e,Mv,_a,s5e],P4),o5e=dt([yte,rx,om],D4),l5e=dt([za,yte,o5e,_a],F4);dt([om,l5e],nee);var c5e={radiusAxis:{},angleAxis:{}},vte=uo({name:"polarAxis",initialState:c5e,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:mnt,removeRadiusAxis:fnt,addAngleAxis:pnt,removeAngleAxis:gnt}=vte.actions,d5e=vte.reducer;function wte(t){return t&&typeof t=="object"&&"className"in t&&typeof t.className=="string"?t.className:""}function ZG(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function JG(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?ZG(Object(n),!0).forEach(function(r){u5e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ZG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function u5e(t,e,n){return(e=h5e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function h5e(t){var e=m5e(t,"string");return typeof e=="symbol"?e:e+""}function m5e(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 f5e=(t,e)=>e,Q4=dt([xte,f5e],(t,e)=>t.filter(n=>n.type==="pie").find(n=>n.id===e)),p5e=[],Z4=(t,e,n)=>n?.length===0?p5e:n,Ste=dt([zk,Q4,Z4],(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=>JG(JG({},e.presentationProps),s.props))),i!=null)return i}}),g5e=dt([Ste,Q4,Z4],(t,e,n)=>{if(!(t==null||e==null))return t.map((r,i)=>{var s,o=_r(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:rm(o,e.dataKey),color:l,payload:r,type:e.legendType}})}),b5e=dt([Ste,Q4,Z4,vi],(t,e,n,r)=>{if(!(e==null||t==null))return xze({offset:r,pieSettings:e,displayedData:t,cells:n})}),EE={exports:{}},Or={};var e7;function x5e(){if(e7)return Or;e7=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),s=Symbol.for("react.consumer"),o=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),u=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 d:case f:return v;default:switch(v=v&&v.$$typeof,v){case o:case l:case h:case u:return v;case s:return v;default:return g}}case e:return g}}}return Or.ContextConsumer=s,Or.ContextProvider=o,Or.Element=t,Or.ForwardRef=l,Or.Fragment=n,Or.Lazy=h,Or.Memo=u,Or.Portal=e,Or.Profiler=i,Or.StrictMode=r,Or.Suspense=c,Or.SuspenseList=d,Or.isContextConsumer=function(v){return x(v)===s},Or.isContextProvider=function(v){return x(v)===o},Or.isElement=function(v){return typeof v=="object"&&v!==null&&v.$$typeof===t},Or.isForwardRef=function(v){return x(v)===l},Or.isFragment=function(v){return x(v)===n},Or.isLazy=function(v){return x(v)===h},Or.isMemo=function(v){return x(v)===u},Or.isPortal=function(v){return x(v)===e},Or.isProfiler=function(v){return x(v)===i},Or.isStrictMode=function(v){return x(v)===r},Or.isSuspense=function(v){return x(v)===c},Or.isSuspenseList=function(v){return x(v)===d},Or.isValidElementType=function(v){return typeof v=="string"||typeof v=="function"||v===n||v===i||v===r||v===c||v===d||typeof v=="object"&&v!==null&&(v.$$typeof===h||v.$$typeof===u||v.$$typeof===o||v.$$typeof===s||v.$$typeof===l||v.$$typeof===p||v.getModuleId!==void 0)},Or.typeOf=x,Or}var t7;function y5e(){return t7||(t7=1,EE.exports=x5e()),EE.exports}var v5e=y5e(),n7=t=>typeof t=="string"?t:t?t.displayName||t.name||"Component":"",r7=null,jE=null,_te=t=>{if(t===r7&&Array.isArray(jE))return jE;var e=[];return w.Children.forEach(t,n=>{ba(n)||(v5e.isFragment(n)?e=e.concat(_te(n.props.children)):e.push(n))}),jE=e,r7=t,e};function J4(t,e){var n=[],r=[];return Array.isArray(e)?r=e.map(i=>n7(i)):r=[n7(e)],_te(t).forEach(i=>{var s=Bf(i,"type.displayName")||Bf(i,"type.name");s&&r.indexOf(s)!==-1&&n.push(i)}),n}var eO=t=>t&&typeof t=="object"&&"clipDot"in t?!!t.clipDot:!0,DE={},a7;function w5e(){return a7||(a7=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})(DE)),DE}var RE,i7;function S5e(){return i7||(i7=1,RE=w5e().isPlainObject),RE}var _5e=S5e();const N5e=rc(_5e);var s7,o7,l7,c7,d7;function u7(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function h7(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?u7(Object(n),!0).forEach(function(r){C5e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):u7(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function C5e(t,e,n){return(e=k5e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function k5e(t){var e=A5e(t,"string");return typeof e=="symbol"?e:e+""}function A5e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function 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 Sy(t,e){return e||(e=t.slice(0)),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(e)}}))}var m7=(t,e,n,r,i)=>{var s=n-r,o;return o=Ea(s7||(s7=Sy(["M ",",",""])),t,e),o+=Ea(o7||(o7=Sy(["L ",",",""])),t+n,e),o+=Ea(l7||(l7=Sy(["L ",",",""])),t+n-s/2,e+i),o+=Ea(c7||(c7=Sy(["L ",",",""])),t+n-s/2-r,e+i),o+=Ea(d7||(d7=Sy(["L ",","," Z"])),t,e),o},T5e={x:0,y:0,upperWidth:0,lowerWidth:0,height:0,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},M5e=t=>{var e=Sa(t,T5e),{x:n,y:r,upperWidth:i,lowerWidth:s,height:o,className:l}=e,{animationEasing:c,animationDuration:d,animationBegin:u,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=Zb(t,"trapezoid-");if(w.useEffect(()=>{if(f.current&&f.current.getTotalLength)try{var D=f.current.getTotalLength();D&&x(D)}catch{}},[]),n!==+n||r!==+r||i!==+i||s!==+s||o!==+o||i===0&&s===0||o===0)return null;var k=cr("recharts-trapezoid",l);if(!h)return w.createElement("g",null,w.createElement("path",TN({},rs(e),{className:k,d:m7(n,r,i,s,o)})));var P=v.current,C=g.current,j=y.current,M=_.current,E=N.current,B="0px ".concat(p===-1?1:p,"px"),L="".concat(p,"px 0px"),U=qZ(["strokeDasharray"],d,c);return w.createElement(Qb,{animationId:A,key:A,canBegin:p>0,duration:d,easing:c,isActive:h,begin:u},D=>{var $=wr(P,i,D),q=wr(C,s,D),z=wr(j,o,D),W=wr(M,n,D),Q=wr(E,r,D);f.current&&(v.current=$,g.current=q,y.current=z,_.current=W,N.current=Q);var te=D>0?{transition:U,strokeDasharray:L}:{strokeDasharray:B};return w.createElement("path",TN({},rs(e),{className:k,d:m7(W,Q,$,q,z),ref:f,style:h7(h7({},te),e.style)}))})},P5e=["option","shapeType","activeClassName"];function E5e(t,e){if(t==null)return{};var n,r,i=j5e(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 j5e(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 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 MN(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){D5e(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 D5e(t,e,n){return(e=R5e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function R5e(t){var e=F5e(t,"string");return typeof e=="symbol"?e:e+""}function F5e(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 L5e(t,e){return MN(MN({},e),t)}function O5e(t,e){return t==="symbols"}function p7(t){var{shapeType:e,elementProps:n}=t;switch(e){case"rectangle":return w.createElement(XZ,n);case"trapezoid":return w.createElement(M5e,n);case"sector":return w.createElement(JZ,n);case"symbols":if(O5e(e))return w.createElement(vL,n);break;case"curve":return w.createElement(rb,n);default:return null}}function I5e(t){return w.isValidElement(t)?t.props:t}function tO(t){var{option:e,shapeType:n,activeClassName:r="recharts-active-shape"}=t,i=E5e(t,P5e),s;if(w.isValidElement(e))s=w.cloneElement(e,MN(MN({},i),I5e(e)));else if(typeof e=="function")s=e(i,i.index);else if(N5e(e)&&typeof e!="boolean"){var o=L5e(e,i);s=w.createElement(p7,{shapeType:n,elementProps:o})}else{var l=i;s=w.createElement(p7,{shapeType:n,elementProps:l})}return i.isActive?w.createElement(wa,{className:r},s):s}var nO=(t,e,n)=>{var r=Yr();return(i,s)=>o=>{t?.(i,s,o),r(jee({activeIndex:String(s),activeDataKey:e,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}},rO=t=>{var e=Yr();return(n,r)=>i=>{t?.(n,r,i),e($Le())}},aO=(t,e,n)=>{var r=Yr();return(i,s)=>o=>{t?.(i,s,o),r(VLe({activeIndex:String(s),activeDataKey:e,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}};function nA(t){var{tooltipEntrySettings:e}=t,n=Yr(),r=wi(),i=w.useRef(null);return w.useLayoutEffect(()=>{r||(i.current===null?n(zLe(e)):i.current!==e&&n(ULe({prev:i.current,next:e})),i.current=e)},[e,n,r]),w.useLayoutEffect(()=>()=>{i.current&&(n(BLe(i.current)),i.current=null)},[n]),null}function iO(t){var{legendPayload:e}=t,n=Yr(),r=wi(),i=w.useRef(null);return w.useLayoutEffect(()=>{r||(i.current===null?n(BZ(e)):i.current!==e&&n(HZ({prev:i.current,next:e})),i.current=e)},[n,r,e]),w.useLayoutEffect(()=>()=>{i.current&&(n($Z(i.current)),i.current=null)},[n]),null}function z5e(t){var{legendPayload:e}=t,n=Yr(),r=Gt(ir),i=w.useRef(null);return w.useLayoutEffect(()=>{r!=="centric"&&r!=="radial"||(i.current===null?n(BZ(e)):i.current!==e&&n(HZ({prev:i.current,next:e})),i.current=e)},[n,r,e]),w.useLayoutEffect(()=>()=>{i.current&&(n($Z(i.current)),i.current=null)},[n]),null}var FE,U5e=()=>{var[t]=w.useState(()=>T0("uid-"));return t},B5e=(FE=fle.useId)!==null&&FE!==void 0?FE:U5e;function H5e(t,e){var n=B5e();return e||(t?"".concat(t,"-").concat(n):n)}var $5e=w.createContext(void 0),rA=t=>{var{id:e,type:n,children:r}=t,i=H5e("recharts-".concat(n),e);return w.createElement($5e.Provider,{value:i},r(i))},V5e={cartesianItems:[],polarItems:[]},Nte=uo({name:"graphicalItems",initialState:V5e,reducers:{addCartesianGraphicalItem:{reducer(t,e){t.cartesianItems.push(e.payload)},prepare:ma()},replaceCartesianGraphicalItem:{reducer(t,e){var{prev:n,next:r}=e.payload,i=Xl(t).cartesianItems.indexOf(n);i>-1&&(t.cartesianItems[i]=r)},prepare:ma()},removeCartesianGraphicalItem:{reducer(t,e){var n=Xl(t).cartesianItems.indexOf(e.payload);n>-1&&t.cartesianItems.splice(n,1)},prepare:ma()},addPolarGraphicalItem:{reducer(t,e){t.polarItems.push(e.payload)},prepare:ma()},removePolarGraphicalItem:{reducer(t,e){var n=Xl(t).polarItems.indexOf(e.payload);n>-1&&t.polarItems.splice(n,1)},prepare:ma()}}}),{addCartesianGraphicalItem:q5e,replaceCartesianGraphicalItem:G5e,removeCartesianGraphicalItem:W5e,addPolarGraphicalItem:K5e,removePolarGraphicalItem:X5e}=Nte.actions,Y5e=Nte.reducer,Q5e=t=>{var e=Yr(),n=w.useRef(null);return w.useLayoutEffect(()=>{n.current===null?e(q5e(t)):n.current!==t&&e(G5e({prev:n.current,next:t})),n.current=t},[e,t]),w.useLayoutEffect(()=>()=>{n.current&&(e(W5e(n.current)),n.current=null)},[e]),null},sO=w.memo(Q5e);function Z5e(t){var e=Yr();return w.useLayoutEffect(()=>(e(K5e(t)),()=>{e(X5e(t))}),[e,t]),null}var J5e=["key"],eze=["onMouseEnter","onClick","onMouseLeave"],tze=["id"],nze=["id"];function g7(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?g7(Object(n),!0).forEach(function(r){rze(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):g7(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function rze(t,e,n){return(e=aze(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function aze(t){var e=ize(t,"string");return typeof e=="symbol"?e:e+""}function ize(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Jh(){return Jh=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Jh.apply(null,arguments)}function aA(t,e){if(t==null)return{};var n,r,i=sze(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 sze(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 oze(t){var e=w.useMemo(()=>J4(t.children,Ov),[t.children]),n=Gt(r=>g5e(r,t.id,e));return n==null?null:w.createElement(z5e,{legendPayload:n})}var lze=w.memo(t=>{var{dataKey:e,nameKey:n,sectors:r,stroke:i,strokeWidth:s,fill:o,name:l,hide:c,tooltipType:d,id:u}=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:rm(l,e),hide:c,type:d,color:o,unit:"",graphicalItemId:u}};return w.createElement(nA,{tooltipEntrySettings:h})}),cze=(t,e)=>t>e?"start":t<e?"end":"middle",dze=(t,e,n)=>ys(typeof e=="function"?e(t):e,n,n*.8),uze=(t,e,n)=>{var{top:r,left:i,width:s,height:o}=e,l=YZ(s,o),c=i+ys(t.cx,s,s/2),d=r+ys(t.cy,o,o/2),u=ys(t.innerRadius,l,0),h=dze(n,t.outerRadius,l),f=t.maxRadius||Math.sqrt(s*s+o*o)/2;return{cx:c,cy:d,innerRadius:u,outerRadius:h,maxRadius:f}},hze=(t,e)=>{var n=Ri(e-t),r=Math.min(Math.abs(e-t),360);return n*r},mze=(t,e)=>{if(w.isValidElement(t))return w.cloneElement(t,e);if(typeof t=="function")return t(e);var n=cr("recharts-pie-label-line",typeof t!="boolean"?t.className:""),{key:r}=e,i=aA(e,J5e);return w.createElement(rb,Jh({},i,{type:"linear",className:n}))},fze=(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=cr("recharts-pie-label-text",wte(t));return w.createElement(Zk,Jh({},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=Ls(n),c=zf(i),d=zf(s),u=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=ti(f.cx,f.cy,f.outerRadius+u,x),g=ja(ja(ja(ja({},l),f),{},{stroke:"none"},c),{},{index:p,textAnchor:cze(v.x,f.cx)},v),y=ja(ja(ja(ja({},l),f),{},{fill:"none",stroke:f.fill},d),{},{index:p,points:[ti(f.cx,f.cy,f.outerRadius,x),v],key:"line"});return w.createElement(Ss,{zIndex:La.label,key:"label-".concat(f.startAngle,"-").concat(f.endAngle,"-").concat(f.midAngle,"-").concat(p)},w.createElement(wa,null,s&&mze(s,y),fze(i,g,_r(f,o))))});return w.createElement(wa,{className:"recharts-pie-labels"},h)}function gze(t){var{sectors:e,props:n,showLabels:r}=t,{label:i}=n;return typeof i=="object"&&i!=null&&"position"in i?w.createElement(Jk,{label:i}):w.createElement(pze,{sectors:e,props:n,showLabels:r})}function bze(t){var{sectors:e,activeShape:n,inactiveShape:r,allOtherPieProps:i,shape:s,id:o}=t,l=Gt(Zh),c=Gt(V4),d=Gt(M4e),{onMouseEnter:u,onClick:h,onMouseLeave:f}=i,p=aA(i,eze),x=nO(u,i.dataKey,o),v=rO(f),g=aO(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=d==null||d===o,A=String(_)===l&&(c==null||i.dataKey===c)&&N,k=l?r:null,P=n&&A?n:k,C=ja(ja({},y),{},{stroke:y.stroke,tabIndex:-1,[AZ]:_,[TZ]:o});return w.createElement(wa,Jh({key:"sector-".concat(y?.startAngle,"-").concat(y?.endAngle,"-").concat(y.midAngle,"-").concat(_),tabIndex:-1,className:"recharts-pie-sector"},bv(p,y,_),{onMouseEnter:x(y,_),onMouseLeave:v(y,_),onClick:g(y,_)}),w.createElement(tO,Jh({option:s??P,index:_,shapeType:"sector",isActive:A},C)))}))}function xze(t){var e,{pieSettings:n,displayedData:r,cells:i,offset:s}=t,{cornerRadius:o,startAngle:l,endAngle:c,dataKey:d,nameKey:u,tooltipType:h}=n,f=Math.abs(n.minAngle),p=hze(l,c),x=Math.abs(p),v=r.length<=1?0:(e=n.paddingAngle)!==null&&e!==void 0?e:0,g=r.filter(P=>_r(P,d,0)!==0).length,y=(x>=360?g:g-1)*v,_=x-g*f-y,N=r.reduce((P,C)=>{var j=_r(C,d,0);return P+($t(j)?j:0)},0),A;if(N>0){var k;A=r.map((P,C)=>{var j=_r(P,d,0),M=_r(P,u,C),E=uze(n,s,P),B=($t(j)?j:0)/N,L,U=ja(ja({},P),i&&i[C]&&i[C].props);C?L=k.endAngle+Ri(p)*v*(j!==0?1:0):L=l;var D=L+Ri(p)*((j!==0?f:0)+B*_),$=(L+D)/2,q=(E.innerRadius+E.outerRadius)/2,z=[{name:M,value:j,payload:U,dataKey:d,type:h,graphicalItemId:n.id}],W=ti(E.cx,E.cy,q,$);return k=ja(ja(ja(ja({},n.presentationProps),{},{percent:B,cornerRadius:typeof o=="string"?parseFloat(o):o,name:M,tooltipPayload:z,midAngle:$,middleRadius:q,tooltipPosition:W},U),E),{},{value:j,dataKey:d,startAngle:L,endAngle:D,payload:U,paddingAngle:Ri(p)*v}),k})}return A}function yze(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(JIe,{value:e?i:void 0},r)}function vze(t){var{props:e,previousSectorsRef:n,id:r}=t,{sectors:i,isAnimationActive:s,animationBegin:o,animationDuration:l,animationEasing:c,activeShape:d,inactiveShape:u,onAnimationStart:h,onAnimationEnd:f}=e,p=Zb(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(yze,{showLabels:!v,sectors:i},w.createElement(Qb,{animationId:p,begin:o,duration:l,isActive:s,easing:c,onAnimationStart:_,onAnimationEnd:y,key:p},N=>{var A,k=[],P=i&&i[0],C=(A=P?.startAngle)!==null&&A!==void 0?A:0;return i?.forEach((j,M)=>{var E=x&&x[M],B=M>0?Bf(j,"paddingAngle",0):0;if(E){var L=wr(E.endAngle-E.startAngle,j.endAngle-j.startAngle,N),U=ja(ja({},j),{},{startAngle:C+B,endAngle:C+L+B});k.push(U),C=U.endAngle}else{var{endAngle:D,startAngle:$}=j,q=wr(0,D-$,N),z=ja(ja({},j),{},{startAngle:C+B,endAngle:C+q+B});k.push(z),C=z.endAngle}}),n.current=k,w.createElement(wa,null,w.createElement(bze,{sectors:k,activeShape:d,inactiveShape:u,allOtherPieProps:e,shape:e.shape,id:r}))}),w.createElement(gze,{showLabels:!v,sectors:i,props:e}),e.children)}var wze={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:La.area};function Sze(t){var{id:e}=t,n=aA(t,tze),{hide:r,className:i,rootTabIndex:s}=t,o=w.useMemo(()=>J4(t.children,Ov),[t.children]),l=Gt(u=>b5e(u,e,o)),c=w.useRef(null),d=cr("recharts-pie",i);return r||l==null?(c.current=null,w.createElement(wa,{tabIndex:s,className:d})):w.createElement(Ss,{zIndex:t.zIndex},w.createElement(lze,{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(wa,{tabIndex:s,className:d},w.createElement(vze,{props:ja(ja({},n),{},{sectors:l}),previousSectorsRef:c,id:e})))}function Cte(t){var e=Sa(t,wze),{id:n}=e,r=aA(e,nze),i=Ls(r);return w.createElement(rA,{id:n,type:"pie"},s=>w.createElement(w.Fragment,null,w.createElement(Z5e,{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(oze,Jh({},r,{id:s})),w.createElement(Sze,Jh({},r,{id:s}))))}Cte.displayName="Pie";var _ze=["points"];function b7(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function LE(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?b7(Object(n),!0).forEach(function(r){Nze(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):b7(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Nze(t,e,n){return(e=Cze(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Cze(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)}function PN(){return PN=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},PN.apply(null,arguments)}function Aze(t,e){if(t==null)return{};var n,r,i=Tze(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function Tze(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function Mze(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=cr(r,typeof e!="boolean"?e.className:""),s=n??{},{points:o}=s,l=Aze(s,_ze);return w.createElement(bte,PN({},l,{className:i}))}function Pze(t,e){return t==null?!1:e?!0:t.length===1}function kte(t){var{points:e,dot:n,className:r,dotClassName:i,dataKey:s,baseProps:o,needClip:l,clipPathId:c,zIndex:d=La.scatter}=t;if(!Pze(e,n))return null;var u=eO(n),h=ZTe(n),f=e.map((x,v)=>{var g,y,_=LE(LE(LE({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(Mze,{key:"dot-".concat(v),option:n,dotProps:_,className:i})}),p={};return l&&c!=null&&(p.clipPath="url(#clipPath-".concat(u?"":"dots-").concat(c,")")),w.createElement(Ss,{zIndex:d},w.createElement(wa,PN({className:r},p),f))}function x7(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function y7(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?x7(Object(n),!0).forEach(function(r){Eze(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):x7(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Eze(t,e,n){return(e=jze(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function jze(t){var e=Dze(t,"string");return typeof e=="symbol"?e:e+""}function Dze(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var Ate=0,Rze={xAxis:{},yAxis:{},zAxis:{}},Tte=uo({name:"cartesianAxis",initialState:Rze,reducers:{addXAxis:{reducer(t,e){t.xAxis[e.payload.id]=e.payload},prepare:ma()},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:ma()},removeXAxis:{reducer(t,e){delete t.xAxis[e.payload.id]},prepare:ma()},addYAxis:{reducer(t,e){t.yAxis[e.payload.id]=e.payload},prepare:ma()},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:ma()},removeYAxis:{reducer(t,e){delete t.yAxis[e.payload.id]},prepare:ma()},addZAxis:{reducer(t,e){t.zAxis[e.payload.id]=e.payload},prepare:ma()},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:ma()},removeZAxis:{reducer(t,e){delete t.zAxis[e.payload.id]},prepare:ma()},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]=y7(y7({},i),{},{width:r,widthHistory:l})}}}}),{addXAxis:Fze,replaceXAxis:Lze,removeXAxis:Oze,addYAxis:Ize,replaceYAxis:zze,removeYAxis:Uze,addZAxis:bnt,replaceZAxis:xnt,removeZAxis:ynt,updateYAxisWidth:Bze}=Tte.actions,Hze=Tte.reducer,$ze=dt([vi],t=>({top:t.top,bottom:t.bottom,left:t.left,right:t.right})),Vze=dt([$ze,pu,gu],(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)}}),iA=()=>Gt(Vze),qze=()=>Gt(R4e);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 OE(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){Gze(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 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 Xze=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=OE(OE(OE({},l),zf(i)),wL(i)),d;return w.isValidElement(i)?d=w.cloneElement(i,c):typeof i=="function"?d=i(c):d=w.createElement(bte,c),w.createElement(wa,{className:"recharts-active-dot",clipPath:o},d)};function dR(t){var{points:e,mainColor:n,activeDot:r,itemDataKey:i,clipPath:s,zIndex:o=La.activeDot}=t,l=Gt(Zh),c=qze();if(e==null||c==null)return null;var d=e.find(u=>c.includes(u.payload));return ba(d)?null:w.createElement(Ss,{zIndex:o},w.createElement(Xze,{point:d,childIndex:Number(l),mainColor:n,dataKey:i,activeDot:r,clipPath:s}))}var w7=(t,e,n)=>{var r=n??t;if(!ba(r))return ys(r,e,0)},Yze=(t,e,n)=>{var r={},i=t.filter(Vk),s=t.filter(d=>d.stackId==null),o=i.reduce((d,u)=>{var h=d[u.stackId];return h==null&&(h=[]),h.push(u),d[u.stackId]=h,d},r),l=Object.entries(o).map(d=>{var u,[h,f]=d,p=f.map(v=>v.dataKey),x=w7(e,n,(u=f[0])===null||u===void 0?void 0:u.barSize);return{stackId:h,dataKeys:p,barSize:x}}),c=s.map(d=>{var u=[d.dataKey].filter(f=>f!=null),h=w7(e,n,d.barSize);return{stackId:void 0,dataKeys:u,barSize:h}});return[...l,...c]};function S7(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?S7(Object(n),!0).forEach(function(r){Qze(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):S7(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Qze(t,e,n){return(e=Zze(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Zze(t){var e=Jze(t,"string");return typeof e=="symbol"?e:e+""}function Jze(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function eUe(t,e,n,r,i){var s,o=r.length;if(!(o<1)){var l=ys(t,n,0,!0),c,d=[];if(Cn((s=r[0])===null||s===void 0?void 0:s.barSize)){var u=!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&&(u=!0,h*=.9,f=o*h);var p=(n-f)/2>>0,x={offset:p-l,size:0};c=r.reduce((_,N)=>{var A,k={stackId:N.stackId,dataKeys:N.dataKeys,position:{offset:x.offset+x.size+l,size:u?h:(A=N.barSize)!==null&&A!==void 0?A:0}},P=[..._,k];return x=k.position,P},d)}else{var v=ys(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=Cn(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}}],d)}return c}}var tUe=(t,e,n,r,i,s,o)=>{var l=ba(o)?e:o,c=eUe(n,r,i!==s?i:s,t,l);return i!==s&&c!=null&&(c=c.map(d=>x_(x_({},d),{},{position:x_(x_({},d.position),{},{offset:d.position.offset-i/2})}))),c},nUe=(t,e)=>{var n=$k(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)}}}},rUe=(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 aUe(t,e){return t&&typeof t=="object"&&"zIndex"in t&&typeof t.zIndex=="number"&&Cn(t.zIndex)?t.zIndex:e}var Mte=t=>{var{chartData:e}=t,n=Yr(),r=wi();return w.useEffect(()=>r?()=>{}:(n(TG(e)),()=>{n(TG(void 0))}),[e,n,r]),null},_7={x:0,y:0,width:0,height:0,padding:{top:0,right:0,bottom:0,left:0}},Pte=uo({name:"brush",initialState:_7,reducers:{setBrushSettings(t,e){return e.payload==null?_7:e.payload}}}),{setBrushSettings:vnt}=Pte.actions,iUe=Pte.reducer,sUe=(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)}},oUe=t=>{var{x1:e,y1:n,x2:r,y2:i}=t;return sUe({x:e,y:n},{x:r,y:i})};function lUe(t){return(t%180+180)%180}var cUe=function(e){var{width:n,height:r}=e,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,s=lUe(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)},dUe={dots:[],areas:[],lines:[]},Ete=uo({name:"referenceElements",initialState:dUe,reducers:{addDot:(t,e)=>{t.dots.push(e.payload)},removeDot:(t,e)=>{var n=Xl(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=Xl(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=Xl(t).lines.findIndex(r=>r===e.payload);n!==-1&&t.lines.splice(n,1)}}}),{addDot:wnt,removeDot:Snt,addArea:_nt,removeArea:Nnt,addLine:uUe,removeLine:hUe}=Ete.actions,mUe=Ete.reducer,jte=w.createContext(void 0),fUe=t=>{var{children:e}=t,[n]=w.useState("".concat(T0("recharts"),"-clip")),r=iA();if(r==null)return null;var{x:i,y:s,width:o,height:l}=r;return w.createElement(jte.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(jte);class gUe{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 N7(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function C7(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?N7(Object(n),!0).forEach(function(r){bUe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):N7(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function bUe(t,e,n){return(e=xUe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function xUe(t){var e=yUe(t,"string");return typeof e=="symbol"?e:e+""}function yUe(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 EN(){return EN=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},EN.apply(null,arguments)}var vUe=(t,e)=>{var n;if(w.isValidElement(t))n=w.cloneElement(t,e);else if(typeof t=="function")n=t(e);else{if(!Cn(e.x1)||!Cn(e.y1)||!Cn(e.x2)||!Cn(e.y2))return null;n=w.createElement("line",EN({},e,{className:"recharts-reference-line-line"}))}return n},wUe=(t,e,n,r,i,s)=>{var{x:o,width:l}=s,c=i.map(t,{position:n});if(!Cn(c)||e==="discard"&&!i.isInRange(c))return null;var d=[{x:o+l,y:c},{x:o,y:c}];return r==="left"?d.reverse():d},SUe=(t,e,n,r,i,s)=>{var{y:o,height:l}=s,c=i.map(t,{position:n});if(!Cn(c)||e==="discard"&&!i.isInRange(c))return null;var d=[{x:c,y:o+l},{x:c,y:o}];return r==="top"?d.reverse():d},_Ue=(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},NUe=(t,e,n,r,i,s,o)=>{var{x:l,y:c,segment:d,ifOverflow:u}=o,h=Cl(l),f=Cl(c);return f?wUe(c,u,r,s,e,n):h?SUe(l,u,r,i,t,n):d!=null&&d.length===2?_Ue(d,u,r,new gUe({x:t,y:e})):null};function CUe(t){var e=Yr();return w.useEffect(()=>(e(uUe(t)),()=>{e(hUe(t))})),null}function kUe(t){var{xAxisId:e,yAxisId:n,shape:r,className:i,ifOverflow:s}=t,o=wi(),l=pUe(),c=Gt(C=>Gc(C,e)),d=Gt(C=>Wc(C,n)),u=Gt(C=>Mb(C,"xAxis",e,o)),h=Gt(C=>Mb(C,"yAxis",n,o)),f=wv();if(!l||!f||c==null||d==null||u==null||h==null)return null;var p=NUe(u,h,f,t.position,c.orientation,d.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,k=C7(C7({clipPath:A},rs(t)),{},{x1:g,y1:y,x2:_,y2:N}),P=oUe({x1:g,y1:y,x2:_,y2:N});return w.createElement(Ss,{zIndex:t.zIndex},w.createElement(wa,{className:cr("recharts-reference-line",i)},vUe(r,k),w.createElement(hte,EN({},P,{lowerWidth:P.width,upperWidth:P.width}),w.createElement(fte,{label:t.label}),t.children)))}var AUe={ifOverflow:"discard",xAxisId:0,yAxisId:0,fill:"none",label:!1,stroke:"#ccc",fillOpacity:1,strokeWidth:1,position:"middle",zIndex:La.line};function jy(t){var e=Sa(t,AUe);return w.createElement(w.Fragment,null,w.createElement(CUe,{yAxisId:e.yAxisId,xAxisId:e.xAxisId,ifOverflow:e.ifOverflow,x:e.x,y:e.y,segment:e.segment}),w.createElement(kUe,e))}jy.displayName="ReferenceLine";function Dte(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 TUe(t,e,n){var r={width:t.width+e.width,height:t.height+e.height};return cUe(r,n)}function MUe(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 H0(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 PUe(t,e){return Dte(t,e+1)}function EUe(t,e,n,r,i){for(var s=(r||[]).slice(),{start:o,end:l}=e,c=0,d=1,u=o,h=function(){var x=r?.[c];if(x===void 0)return{v:Dte(r,d)};var v=c,g,y=()=>(g===void 0&&(g=n(x,v)),g),_=x.coordinate,N=c===0||H0(t,_,y,u,l);N||(c=0,u=o,d+=1),N&&(u=_+t*(y()/2+i),c+=d)},f;d<=s.length;)if(f=h(),f)return f.v;return[]}function jUe(t,e,n,r,i){var s=(r||[]).slice(),o=s.length;if(o===0)return[];for(var{start:l,end:c}=e,d=1;d<=o;d++){for(var u=(o-1)%d,h=l,f=!0,p=function(){var A=r[v];if(A==null)return 0;var k=v,P,C=()=>(P===void 0&&(P=n(A,k)),P),j=A.coordinate,M=v===u||H0(t,j,C,h,c);if(!M)return f=!1,1;M&&(h=j+t*(C()/2+i))},x,v=u;v<o&&(x=p(),!(x!==0&&x===1));v+=d);if(f){for(var g=[],y=u;y<o;y+=d){var _=r[y];_!=null&&g.push(_)}return g}}return[]}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 ms(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){DUe(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 DUe(t,e,n){return(e=RUe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function RUe(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 LUe(t,e,n,r,i){for(var s=(r||[]).slice(),o=s.length,{start:l}=e,{end:c}=e,d=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 _=H0(t,x.tickCoord,g,l,c);_&&(c=x.tickCoord-t*(g()/2+i),s[f]=ms(ms({},x),{},{isShow:!0}))}},u=o-1;u>=0;u--)d(u);return s}function OUe(t,e,n,r,i,s){var o=(r||[]).slice(),l=o.length,{start:c,end:d}=e;if(s){var u=r[l-1];if(u!=null){var h=n(u,l-1),f=t*(u.coordinate+t*h/2-d);if(o[l-1]=u=ms(ms({},u),{},{tickCoord:f>0?u.coordinate-f*t:u.coordinate}),u.tickCoord!=null){var p=H0(t,u.tickCoord,()=>h,c,d);p&&(d=u.tickCoord-t*(h/2+i),o[l-1]=ms(ms({},u),{},{isShow:!0}))}}}for(var x=s?l-1:l,v=function(_){var N=o[_];if(N==null)return 1;var A=N,k,P=()=>(k===void 0&&(k=n(N,_)),k);if(_===0){var C=t*(A.coordinate-t*P()/2-c);o[_]=A=ms(ms({},A),{},{tickCoord:C<0?A.coordinate-C*t:A.coordinate})}else o[_]=A=ms(ms({},A),{},{tickCoord:A.coordinate});if(A.tickCoord!=null){var j=H0(t,A.tickCoord,P,c,d);j&&(c=A.tickCoord+t*(P()/2+i),o[_]=ms(ms({},A),{},{isShow:!0}))}},g=0;g<x;g++)v(g);return o}function oO(t,e,n){var{tick:r,ticks:i,viewBox:s,minTickGap:o,orientation:l,interval:c,tickFormatter:d,unit:u,angle:h}=t;if(!i||!i.length||!r)return[];if($t(c)||Nv.isSsr){var f;return(f=PUe(i,$t(c)?c:0))!==null&&f!==void 0?f:[]}var p=[],x=l==="top"||l==="bottom"?"width":"height",v=u&&x==="width"?Wy(u,{fontSize:e,letterSpacing:n}):{width:0,height:0},g=(k,P)=>{var C=typeof d=="function"?d(k.value,P):k.value;return x==="width"?TUe(Wy(C,{fontSize:e,letterSpacing:n}),v,h):Wy(C,{fontSize:e,letterSpacing:n})[x]},y=i[0],_=i[1],N=i.length>=2&&y!=null&&_!=null?Ri(_.coordinate-y.coordinate):1,A=MUe(s,N,x);return c==="equidistantPreserveStart"?EUe(N,A,g,i,o):c==="equidistantPreserveEnd"?jUe(N,A,g,i,o):(c==="preserveStart"||c==="preserveStartEnd"?p=OUe(N,A,g,i,o,c==="preserveStartEnd"):p=LUe(N,A,g,i,o),p.filter(k=>k.isShow))}var IUe=t=>{var{ticks:e,label:n,labelGapWithTick:r=5,tickSize:i=0,tickMargin:s=0}=t,o=0;if(e){Array.from(e).forEach(u=>{if(u){var h=u.getBoundingClientRect();h.width>o&&(o=h.width)}});var l=n?n.getBoundingClientRect().width:0,c=i+s,d=o+c+l+(n?r:0);return Math.round(d)}return 0},zUe=["axisLine","width","height","className","hide","ticks","axisType"];function UUe(t,e){if(t==null)return{};var n,r,i=BUe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function BUe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function Wf(){return Wf=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},Wf.apply(null,arguments)}function A7(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 Pa(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?A7(Object(n),!0).forEach(function(r){HUe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):A7(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function HUe(t,e,n){return(e=$Ue(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function $Ue(t){var e=VUe(t,"string");return typeof e=="symbol"?e:e+""}function VUe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var Xd={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:La.axis};function qUe(t){var{x:e,y:n,width:r,height:i,orientation:s,mirror:o,axisLine:l,otherSvgProps:c}=t;if(!l)return null;var d=Pa(Pa(Pa({},c),Ls(l)),{},{fill:"none"});if(s==="top"||s==="bottom"){var u=+(s==="top"&&!o||s==="bottom"&&o);d=Pa(Pa({},d),{},{x1:e,y1:n+u*i,x2:e+r,y2:n+u*i})}else{var h=+(s==="left"&&!o||s==="right"&&o);d=Pa(Pa({},d),{},{x1:e+h*r,y1:n,x2:e+h*r,y2:n+i})}return w.createElement("line",Wf({},d,{className:cr("recharts-cartesian-axis-line",Bf(l,"className"))}))}function GUe(t,e,n,r,i,s,o,l,c){var d,u,h,f,p,x,v=l?-1:1,g=t.tickSize||o,y=$t(t.tickCoord)?t.tickCoord:t.coordinate;switch(s){case"top":d=u=t.coordinate,f=n+ +!l*i,h=f-v*g,x=h-v*c,p=y;break;case"left":h=f=t.coordinate,u=e+ +!l*r,d=u-v*g,p=d-v*c,x=y;break;case"right":h=f=t.coordinate,u=e+ +l*r,d=u+v*g,p=d+v*c,x=y;break;default:d=u=t.coordinate,f=n+ +l*i,h=f+v*g,x=h+v*c,p=y;break}return{line:{x1:d,y1:h,x2:u,y2:f},tick:{x:p,y:x}}}function WUe(t,e){switch(t){case"left":return e?"start":"end";case"right":return e?"end":"start";default:return"middle"}}function KUe(t,e){switch(t){case"left":case"right":return"middle";case"top":return e?"start":"end";default:return e?"end":"start"}}function XUe(t){var{option:e,tickProps:n,value:r}=t,i,s=cr(n.className,"recharts-cartesian-axis-tick-value");if(w.isValidElement(e))i=w.cloneElement(e,Pa(Pa({},n),{},{className:s}));else if(typeof e=="function")i=e(Pa(Pa({},n),{},{className:s}));else{var o="recharts-cartesian-axis-tick-value";typeof e!="boolean"&&(o=cr(o,wte(e))),i=w.createElement(Zk,Wf({},n,{className:o}),r)}return i}var YUe=w.forwardRef((t,e)=>{var{ticks:n=[],tick:r,tickLine:i,stroke:s,tickFormatter:o,unit:l,padding:c,tickTextProps:d,orientation:u,mirror:h,x:f,y:p,width:x,height:v,tickSize:g,tickMargin:y,fontSize:_,letterSpacing:N,getTicksConfig:A,events:k,axisType:P}=t,C=oO(Pa(Pa({},A),{},{ticks:n}),_,N),j=WUe(u,h),M=KUe(u,h),E=Ls(A),B=zf(r),L={};typeof i=="object"&&(L=i);var U=Pa(Pa({},E),{},{fill:"none"},L),D=C.map(z=>Pa({entry:z},GUe(z,f,p,x,v,u,g,h,y))),$=D.map(z=>{var{entry:W,line:Q}=z;return w.createElement(wa,{className:"recharts-cartesian-axis-tick",key:"tick-".concat(W.value,"-").concat(W.coordinate,"-").concat(W.tickCoord)},i&&w.createElement("line",Wf({},U,Q,{className:cr("recharts-cartesian-axis-tick-line",Bf(i,"className"))})))}),q=D.map((z,W)=>{var Q,te,{entry:H,tick:X}=z,Z=Pa(Pa(Pa(Pa({verticalAnchor:M},E),{},{textAnchor:j,stroke:"none",fill:s},X),{},{index:W,payload:H,visibleTicksCount:C.length,tickFormatter:o,padding:c},d),{},{angle:(Q=(te=d?.angle)!==null&&te!==void 0?te:E.angle)!==null&&Q!==void 0?Q:0}),ee=Pa(Pa({},Z),B);return w.createElement(wa,Wf({className:"recharts-cartesian-axis-tick-label",key:"tick-label-".concat(H.value,"-").concat(H.coordinate,"-").concat(H.tickCoord)},bv(k,H,W)),r&&w.createElement(XUe,{option:r,tickProps:ee,value:"".concat(typeof o=="function"?o(H.value,W):H.value).concat(l||"")}))});return w.createElement("g",{className:"recharts-cartesian-axis-ticks recharts-".concat(P,"-ticks")},q.length>0&&w.createElement(Ss,{zIndex:La.label},w.createElement("g",{className:"recharts-cartesian-axis-tick-labels recharts-".concat(P,"-tick-labels"),ref:e},q)),$.length>0&&w.createElement("g",{className:"recharts-cartesian-axis-tick-lines recharts-".concat(P,"-tick-lines")},$))}),QUe=w.forwardRef((t,e)=>{var{axisLine:n,width:r,height:i,className:s,hide:o,ticks:l,axisType:c}=t,d=UUe(t,zUe),[u,h]=w.useState(""),[f,p]=w.useState(""),x=w.useRef(null);w.useImperativeHandle(e,()=>({getCalculatedWidth:()=>{var g;return IUe({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,k=N.letterSpacing;(A!==u||k!==f)&&(h(A),p(k))}}},[u,f]);return o||r!=null&&r<=0||i!=null&&i<=0?null:w.createElement(Ss,{zIndex:t.zIndex},w.createElement(wa,{className:cr("recharts-cartesian-axis",s)},w.createElement(qUe,{x:t.x,y:t.y,width:r,height:i,orientation:t.orientation,mirror:t.mirror,axisLine:n,otherSvgProps:Ls(t)}),w.createElement(YUe,{ref:v,axisType:c,events:d,fontSize:u,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(hte,{x:t.x,y:t.y,width:t.width,height:t.height,lowerWidth:t.width,upperWidth:t.width},w.createElement(fte,{label:t.label,labelRef:t.labelRef}),t.children)))}),lO=w.forwardRef((t,e)=>{var n=Sa(t,Xd);return w.createElement(QUe,Wf({},n,{ref:e}))});lO.displayName="CartesianAxis";var ZUe=["x1","y1","x2","y2","key"],JUe=["offset"],eBe=["xAxisId","yAxisId"],tBe=["xAxisId","yAxisId"];function T7(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?T7(Object(n),!0).forEach(function(r){nBe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):T7(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function nBe(t,e,n){return(e=rBe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function rBe(t){var e=aBe(t,"string");return typeof e=="symbol"?e:e+""}function aBe(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 sf(){return sf=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},sf.apply(null,arguments)}function jN(t,e){if(t==null)return{};var n,r,i=iBe(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 iBe(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 sBe=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 Rte(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:d}=n,u=jN(n,ZUe),h=(i=Ls(u))!==null&&i!==void 0?i:{},{offset:f}=h,p=jN(h,JUe);r=w.createElement("line",sf({},p,{x1:s,y1:o,x2:l,y2:c,fill:"none",key:d}))}return r}function oBe(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=jN(t,eBe),c=i.map((d,u)=>{var h=gs(gs({},l),{},{x1:e,y1:d,x2:e+n,y2:d,key:"line-".concat(u),index:u});return w.createElement(Rte,{key:"line-".concat(u),option:r,lineItemProps:h})});return w.createElement("g",{className:"recharts-cartesian-grid-horizontal"},c)}function lBe(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=jN(t,tBe),c=i.map((d,u)=>{var h=gs(gs({},l),{},{x1:d,y1:e,x2:d,y2:e+n,key:"line-".concat(u),index:u});return w.createElement(Rte,{option:r,lineItemProps:h,key:"line-".concat(u)})});return w.createElement("g",{className:"recharts-cartesian-grid-vertical"},c)}function cBe(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 d=l.map(h=>Math.round(h+i-i)).sort((h,f)=>h-f);i!==d[0]&&d.unshift(0);var u=d.map((h,f)=>{var p=d[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"},u)}function dBe(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 d=c.map(h=>Math.round(h+i-i)).sort((h,f)=>h-f);i!==d[0]&&d.unshift(0);var u=d.map((h,f)=>{var p=d[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"},u)}var uBe=(t,e)=>{var{xAxis:n,width:r,height:i,offset:s}=t;return _Z(oO(gs(gs(gs({},Xd),n),{},{ticks:NZ(n),viewBox:{x:0,y:0,width:r,height:i}})),s.left,s.left+s.width,e)},hBe=(t,e)=>{var{yAxis:n,width:r,height:i,offset:s}=t;return _Z(oO(gs(gs(gs({},Xd),n),{},{ticks:NZ(n),viewBox:{x:0,y:0,width:r,height:i}})),s.top,s.top+s.height,e)},mBe={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[],xAxisId:0,yAxisId:0,syncWithTicks:!1,zIndex:La.grid};function DN(t){var e=RL(),n=FL(),r=jZ(),i=gs(gs({},Sa(t,mBe)),{},{x:$t(t.x)?t.x:r.left,y:$t(t.y)?t.y:r.top,width:$t(t.width)?t.width:r.width,height:$t(t.height)?t.height:r.height}),{xAxisId:s,yAxisId:o,x:l,y:c,width:d,height:u,syncWithTicks:h,horizontalValues:f,verticalValues:p}=i,x=wi(),v=Gt(M=>gG(M,"xAxis",s,x)),g=Gt(M=>gG(M,"yAxis",o,x));if(!Ic(d)||!Ic(u)||!$t(l)||!$t(c))return null;var y=i.verticalCoordinatesGenerator||uBe,_=i.horizontalCoordinatesGenerator||hBe,{horizontalPoints:N,verticalPoints:A}=i;if((!N||!N.length)&&typeof _=="function"){var k=f&&f.length,P=_({yAxis:g?gs(gs({},g),{},{ticks:k?f:g.ticks}):void 0,width:e??d,height:n??u,offset:r},k?!0:h);nN(Array.isArray(P),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(typeof P,"]")),Array.isArray(P)&&(N=P)}if((!A||!A.length)&&typeof y=="function"){var C=p&&p.length,j=y({xAxis:v?gs(gs({},v),{},{ticks:C?p:v.ticks}):void 0,width:e??d,height:n??u,offset:r},C?!0:h);nN(Array.isArray(j),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(typeof j,"]")),Array.isArray(j)&&(A=j)}return w.createElement(Ss,{zIndex:i.zIndex},w.createElement("g",{className:"recharts-cartesian-grid"},w.createElement(sBe,{fill:i.fill,fillOpacity:i.fillOpacity,x:i.x,y:i.y,width:i.width,height:i.height,ry:i.ry}),w.createElement(cBe,sf({},i,{horizontalPoints:N})),w.createElement(dBe,sf({},i,{verticalPoints:A})),w.createElement(oBe,sf({},i,{offset:r,horizontalPoints:N,xAxis:v,yAxis:g})),w.createElement(lBe,sf({},i,{offset:r,verticalPoints:A,xAxis:v,yAxis:g}))))}DN.displayName="CartesianGrid";var fBe={},Fte=uo({name:"errorBars",initialState:fBe,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:Cnt,replaceErrorBar:knt,removeErrorBar:Ant}=Fte.actions,pBe=Fte.reducer,gBe=["children"];function bBe(t,e){if(t==null)return{};var n,r,i=xBe(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 xBe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var yBe={data:[],xAxisId:"xAxis-0",yAxisId:"yAxis-0",dataPointFormatter:()=>({x:0,y:0,value:0}),errorBarOffset:0},vBe=w.createContext(yBe);function Lte(t){var{children:e}=t,n=bBe(t,gBe);return w.createElement(vBe.Provider,{value:n},e)}function sA(t,e){var n,r,i=Gt(d=>Gc(d,t)),s=Gt(d=>Wc(d,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 cO(t){var{xAxisId:e,yAxisId:n,clipPathId:r}=t,i=iA(),{needClipX:s,needClipY:o,needClip:l}=sA(e,n);if(!l||!i)return null;var{x:c,y:d,width:u,height:h}=i;return w.createElement("clipPath",{id:"clipPath-".concat(r)},w.createElement("rect",{x:s?c:c-u/2,y:o?d:d-h/2,width:s?u:u*2,height:o?h:h*2}))}var Ote=(t,e,n,r)=>Bc(t,"xAxis",e,r),Ite=(t,e,n,r)=>Uc(t,"xAxis",e,r),zte=(t,e,n,r)=>Bc(t,"yAxis",n,r),Ute=(t,e,n,r)=>Uc(t,"yAxis",n,r),wBe=dt([ir,Ote,zte,Ite,Ute],(t,e,n,r,i)=>oc(t,"xAxis")?Qh(e,r,!1):Qh(n,i,!1)),SBe=(t,e,n,r,i)=>i;function _Be(t){return t.type==="line"}var NBe=dt([Ev,SBe],(t,e)=>t.filter(_Be).find(n=>n.id===e)),CBe=dt([ir,Ote,zte,Ite,Ute,NBe,wBe,c4],(t,e,n,r,i,s,o,l)=>{var{chartData:c,dataStartIndex:d,dataEndIndex:u}=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(d,u+1),p!=null)return u8e({layout:t,xAxis:e,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataKey:h,bandSize:o,displayedData:p})}});function Bte(t){var e=zf(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 IE={exports:{}},zE={};var M7;function kBe(){if(M7)return zE;M7=1;var t=zb();function e(c,d){return c===d&&(c!==0||1/c===1/d)||c!==c&&d!==d}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 zE.useSyncExternalStoreWithSelector=function(c,d,u,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(k){if(!y){if(y=!0,_=k,k=h(k),f!==void 0&&x.hasValue){var P=x.value;if(f(P,k))return N=P}return N=k}if(P=N,n(_,k))return P;var C=h(k);return f!==void 0&&f(P,C)?(_=k,P):(_=k,N=C)}var y=!1,_,N,A=u===void 0?null:u;return[function(){return g(d())},A===null?void 0:function(){return g(A())}]},[d,u,h,f]);var v=r(c,p[0],p[1]);return s(function(){x.hasValue=!0,x.value=v},[v]),l(v),v},zE}var P7;function ABe(){return P7||(P7=1,IE.exports=kBe()),IE.exports}ABe();function TBe(t){t()}function MBe(){let t=null,e=null;return{clear(){t=null,e=null},notify(){TBe(()=>{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 E7={notify(){},get:()=>[]};function PBe(t,e){let n,r=E7,i=0,s=!1;function o(v){u();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 d(){return s}function u(){i++,n||(n=t.subscribe(c),r=MBe())}function h(){i--,n&&i===0&&(n(),n=void 0,r.clear(),r=E7)}function f(){s||(s=!0,u())}function p(){s&&(s=!1,h())}const x={addNestedSub:o,notifyNestedSubs:l,handleChangeWrapper:c,isSubscribed:d,trySubscribe:f,tryUnsubscribe:p,getListeners:()=>r};return x}var EBe=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",jBe=EBe(),DBe=()=>typeof navigator<"u"&&navigator.product==="ReactNative",RBe=DBe(),FBe=()=>jBe||RBe?w.useLayoutEffect:w.useEffect,LBe=FBe();function j7(t,e){return t===e?t!==0||e!==0||1/t===1/e:t!==t&&e!==e}function OBe(t,e){if(j7(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])||!j7(t[n[i]],e[n[i]]))return!1;return!0}var IBe=Symbol.for("react-redux-context"),zBe=typeof globalThis<"u"?globalThis:{};function UBe(){if(!w.createContext)return{};const t=zBe[IBe]??=new Map;let e=t.get(w.createContext);return e||(e=w.createContext(null),t.set(w.createContext,e)),e}var BBe=UBe();function HBe(t){const{children:e,context:n,serverState:r,store:i}=t,s=w.useMemo(()=>{const c=PBe(i);return{store:i,subscription:c,getServerState:r?()=>r:void 0}},[i,r]),o=w.useMemo(()=>i.getState(),[i]);LBe(()=>{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||BBe;return w.createElement(l.Provider,{value:s},e)}var $Be=HBe,VBe=new Set(["axisLine","tickLine","activeBar","activeDot","activeLabel","activeShape","allowEscapeViewBox","background","cursor","dot","label","line","margin","padding","position","shape","style","tick","wrapperStyle","radius"]);function qBe(t,e){return t==null&&e==null?!0:typeof t=="number"&&typeof e=="number"?t===e||t!==t&&e!==e:t===e}function Iv(t,e){var n=new Set([...Object.keys(t),...Object.keys(e)]);for(var r of n)if(VBe.has(r)){if(t[r]==null&&e[r]==null)continue;if(!OBe(t[r],e[r]))return!1}else if(!qBe(t[r],e[r]))return!1;return!0}var GBe=["id"],WBe=["type","layout","connectNulls","needClip","shape"],KBe=["activeDot","animateNewValues","animationBegin","animationDuration","animationEasing","connectNulls","dot","hide","isAnimationActive","label","legendType","xAxisId","yAxisId","id"];function $0(){return $0=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},$0.apply(null,arguments)}function D7(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?D7(Object(n),!0).forEach(function(r){XBe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):D7(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function XBe(t,e,n){return(e=YBe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function YBe(t){var e=QBe(t,"string");return typeof e=="symbol"?e:e+""}function QBe(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 dO(t,e){if(t==null)return{};var n,r,i=ZBe(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 ZBe(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 JBe=t=>{var{dataKey:e,name:n,stroke:r,legendType:i,hide:s}=t;return[{inactive:s,dataKey:e,type:i,color:r,value:rm(n,e),payload:t}]},e8e=w.memo(t=>{var{dataKey:e,data:n,stroke:r,strokeWidth:i,fill:s,name:o,hide:l,unit:c,tooltipType:d,id:u}=t,h={dataDefinedOnItem:n,getPosition:nm,settings:{stroke:r,strokeWidth:i,fill:s,dataKey:e,nameKey:void 0,name:rm(o,e),hide:l,type:d,color:r,unit:c,graphicalItemId:u}};return w.createElement(nA,{tooltipEntrySettings:h})}),Hte=(t,e)=>"".concat(e,"px ").concat(t-e,"px");function t8e(t,e){for(var n=t.length%2!==0?[...t,0]:t,r=[],i=0;i<e;++i)r=[...r,...n];return r}var n8e=(t,e,n)=>{var r=n.reduce((p,x)=>p+x);if(!r)return Hte(e,t);for(var i=Math.floor(t/r),s=t%r,o=e-t,l=[],c=0,d=0;c<n.length;d+=(u=n[c])!==null&&u!==void 0?u:0,++c){var u,h=n[c];if(h!=null&&d+h>s){l=[...n.slice(0,c),s-d];break}}var f=l.length%2===0?[0,o]:[o];return[...t8e(n,i),...l,...f].map(p=>"".concat(p,"px")).join(", ")};function r8e(t){var{clipPathId:e,points:n,props:r}=t,{dot:i,dataKey:s,needClip:o}=r,{id:l}=r,c=dO(r,GBe),d=Ls(c);return w.createElement(kte,{points:n,dot:i,className:"recharts-line-dots",dotClassName:"recharts-line-dot",dataKey:s,baseProps:d,needClip:o,clipPathId:e})}function a8e(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 _c(_c({},c),{},{value:s.value,payload:s.payload,viewBox:c,parentViewBox:void 0,fill:void 0})}),[r]);return w.createElement(Y4,{value:e?i:void 0},n)}function R7(t){var{clipPathId:e,pathRef:n,points:r,strokeDasharray:i,props:s}=t,{type:o,layout:l,connectNulls:c,needClip:d,shape:u}=s,h=dO(s,WBe),f=_c(_c({},rs(h)),{},{fill:"none",className:"recharts-line-curve",clipPath:d?"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(tO,$0({shapeType:"curve",option:u},f,{pathRef:n})),w.createElement(r8e,{points:r,clipPathId:e,props:s}))}function i8e(t){try{return t&&t.getTotalLength&&t.getTotalLength()||0}catch{return 0}}function s8e(t){var{clipPathId:e,props:n,pathRef:r,previousPointsRef:i,longestAnimatedLengthRef:s}=t,{points:o,strokeDasharray:l,isAnimationActive:c,animationBegin:d,animationDuration:u,animationEasing:h,animateNewValues:f,width:p,height:x,onAnimationEnd:v,onAnimationStart:g}=n,y=i.current,_=Zb(o,"recharts-line-"),N=w.useRef(_),[A,k]=w.useState(!1),P=!A,C=w.useCallback(()=>{typeof v=="function"&&v(),k(!1)},[v]),j=w.useCallback(()=>{typeof g=="function"&&g(),k(!0)},[g]),M=i8e(r.current),E=w.useRef(0);N.current!==_&&(E.current=s.current,N.current=_);var B=E.current;return w.createElement(a8e,{points:o,showLabels:P},n.children,w.createElement(Qb,{animationId:_,begin:d,duration:u,isActive:c,easing:h,onAnimationEnd:C,onAnimationStart:j,key:_},L=>{var U=wr(B,M+B,L),D=Math.min(U,M),$;if(c)if(l){var q="".concat(l).split(/[,\s]+/gim).map(Q=>parseFloat(Q));$=n8e(D,M,q)}else $=Hte(M,D);else $=l==null?void 0:String(l);if(L>0&&M>0&&(i.current=o,s.current=Math.max(s.current,D)),y){var z=y.length/o.length,W=L===1?o:o.map((Q,te)=>{var H=Math.floor(te*z);if(y[H]){var X=y[H];return _c(_c({},Q),{},{x:wr(X.x,Q.x,L),y:wr(X.y,Q.y,L)})}return f?_c(_c({},Q),{},{x:wr(p*2,Q.x,L),y:wr(x/2,Q.y,L)}):_c(_c({},Q),{},{x:Q.x,y:Q.y})});return i.current=W,w.createElement(R7,{props:n,points:W,clipPathId:e,pathRef:r,strokeDasharray:$})}return w.createElement(R7,{props:n,points:o,clipPathId:e,pathRef:r,strokeDasharray:$})}),w.createElement(Jk,{label:n.label}))}function o8e(t){var{clipPathId:e,props:n}=t,r=w.useRef(null),i=w.useRef(0),s=w.useRef(null);return w.createElement(s8e,{props:n,clipPathId:e,previousPointsRef:r,longestAnimatedLengthRef:i,pathRef:s})}var l8e=(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:_r(t.payload,e)}};class c8e extends w.Component{render(){var{hide:e,dot:n,points:r,className:i,xAxisId:s,yAxisId:o,top:l,left:c,width:d,height:u,id:h,needClip:f,zIndex:p}=this.props;if(e)return null;var x=cr("recharts-line",i),v=h,{r:g,strokeWidth:y}=Bte(n),_=eO(n),N=g*2+y,A=f?"url(#clipPath-".concat(_?"":"dots-").concat(v,")"):void 0;return w.createElement(Ss,{zIndex:p},w.createElement(wa,{className:x},f&&w.createElement("defs",null,w.createElement(cO,{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:d+N,height:u+N}))),w.createElement(Lte,{xAxisId:s,yAxisId:o,data:r,dataPointFormatter:l8e,errorBarOffset:0},w.createElement(o8e,{props:this.props,clipPathId:v}))),w.createElement(dR,{activeDot:this.props.activeDot,points:r,mainColor:this.props.stroke,itemDataKey:this.props.dataKey,clipPath:A}))}}var $te={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:La.line,type:"linear"};function d8e(t){var e=Sa(t,$te),{activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:s,animationEasing:o,connectNulls:l,dot:c,hide:d,isAnimationActive:u,label:h,legendType:f,xAxisId:p,yAxisId:x,id:v}=e,g=dO(e,KBe),{needClip:y}=sA(p,x),_=iA(),N=am(),A=wi(),k=Gt(E=>CBe(E,p,x,A,v));if(N!=="horizontal"&&N!=="vertical"||k==null||_==null)return null;var{height:P,width:C,x:j,y:M}=_;return w.createElement(c8e,$0({},g,{id:v,connectNulls:l,dot:c,activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:s,animationEasing:o,isAnimationActive:u,hide:d,label:h,legendType:f,xAxisId:p,yAxisId:x,points:k,layout:N,height:P,width:C,left:j,top:M,needClip:y}))}function u8e(t){var{layout:e,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:s,dataKey:o,bandSize:l,displayedData:c}=t;return c.map((d,u)=>{var h=_r(d,o);if(e==="horizontal"){var f=tN({axis:n,ticks:i,bandSize:l,entry:d,index:u}),p=ba(h)?null:r.scale.map(h);return{x:f,y:p??null,value:h,payload:d}}var x=ba(h)?null:n.scale.map(h),v=tN({axis:r,ticks:s,bandSize:l,entry:d,index:u});return x==null||v==null?null:{x,y:v,value:h,payload:d}}).filter(Boolean)}function h8e(t){var e=Sa(t,$te),n=wi();return w.createElement(rA,{id:e.id,type:"line"},r=>w.createElement(w.Fragment,null,w.createElement(iO,{legendPayload:JBe(e)}),w.createElement(e8e,{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(sO,{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(d8e,$0({},e,{id:r}))))}var Vte=w.memo(h8e,Iv);Vte.displayName="Line";function Kc(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:Ate}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.yAxisId)!==null&&n!==void 0?n:Ate}var qte=(t,e,n)=>Bc(t,"xAxis",Kc(t,e),n),Gte=(t,e,n)=>Uc(t,"xAxis",Kc(t,e),n),Wte=(t,e,n)=>Bc(t,"yAxis",Xc(t,e),n),Kte=(t,e,n)=>Uc(t,"yAxis",Xc(t,e),n),m8e=dt([ir,qte,Wte,Gte,Kte],(t,e,n,r,i)=>oc(t,"xAxis")?Qh(e,r,!1):Qh(n,i,!1)),f8e=(t,e)=>e,Xte=dt([Ev,f8e],(t,e)=>t.filter(n=>n.type==="area").find(n=>n.id===e)),Yte=t=>{var e=ir(t),n=oc(e,"xAxis");return n?"yAxis":"xAxis"},p8e=(t,e)=>{var n=Yte(t);return n==="yAxis"?Xc(t,e):Kc(t,e)},g8e=(t,e,n)=>NN(t,Yte(t),p8e(t,e),n),b8e=dt([Xte,g8e],(t,e)=>{var n;if(!(t==null||e==null)){var{stackId:r}=t,i=$k(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]])}}}),x8e=dt([ir,qte,Wte,Gte,Kte,b8e,RJ,m8e,Xte,MFe],(t,e,n,r,i,s,o,l,c,d)=>{var{chartData:u,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=u?.slice(h,f+1),x!=null)return O8e({layout:t,xAxis:e,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataStartIndex:h,areaSettings:c,stackedData:s,displayedData:x,chartBaseValue:d,bandSize:l})}}),y8e=["id"],v8e=["activeDot","animationBegin","animationDuration","animationEasing","connectNulls","dot","fill","fillOpacity","hide","isAnimationActive","legendType","stroke","xAxisId","yAxisId"];function yf(){return yf=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},yf.apply(null,arguments)}function Qte(t,e){if(t==null)return{};var n,r,i=w8e(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function w8e(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}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 $g(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){S8e(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 S8e(t,e,n){return(e=_8e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function _8e(t){var e=N8e(t,"string");return typeof e=="symbol"?e:e+""}function N8e(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 RN(t,e){return t&&t!=="none"?t:e}var C8e=t=>{var{dataKey:e,name:n,stroke:r,fill:i,legendType:s,hide:o}=t;return[{inactive:o,dataKey:e,type:s,color:RN(r,i),value:rm(n,e),payload:t}]},k8e=w.memo(t=>{var{dataKey:e,data:n,stroke:r,strokeWidth:i,fill:s,name:o,hide:l,unit:c,tooltipType:d,id:u}=t,h={dataDefinedOnItem:n,getPosition:nm,settings:{stroke:r,strokeWidth:i,fill:s,dataKey:e,nameKey:void 0,name:rm(o,e),hide:l,type:d,color:RN(r,s),unit:c,graphicalItemId:u}};return w.createElement(nA,{tooltipEntrySettings:h})});function A8e(t){var{clipPathId:e,points:n,props:r}=t,{needClip:i,dot:s,dataKey:o}=r,l=Ls(r);return w.createElement(kte,{points:n,dot:s,className:"recharts-area-dots",dotClassName:"recharts-area-dot",dataKey:o,baseProps:l,needClip:i,clipPathId:e})}function T8e(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 $g($g({},c),{},{value:s.value,payload:s.payload,parentViewBox:void 0,viewBox:c,fill:void 0})});return w.createElement(Y4,{value:e?i:void 0},n)}function L7(t){var{points:e,baseLine:n,needClip:r,clipPathId:i,props:s}=t,{layout:o,type:l,stroke:c,connectNulls:d,isRange:u}=s,{id:h}=s,f=Qte(s,y8e),p=Ls(f),x=rs(f);return w.createElement(w.Fragment,null,e?.length>1&&w.createElement(wa,{clipPath:r?"url(#clipPath-".concat(i,")"):void 0},w.createElement(rb,yf({},x,{id:h,points:e,connectNulls:d,type:l,baseLine:n,layout:o,stroke:"none",className:"recharts-area-area"})),c!=="none"&&w.createElement(rb,yf({},p,{className:"recharts-area-curve",layout:o,type:l,connectNulls:d,fill:"none",points:e})),c!=="none"&&u&&w.createElement(rb,yf({},p,{className:"recharts-area-curve",layout:o,type:l,connectNulls:d,fill:"none",points:n}))),w.createElement(A8e,{points:e,props:f,clipPathId:i}))}function M8e(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(!Cn(l)||!Cn(c))return null;var d=r*Math.abs(l-c),u=Math.max(...s.map(h=>h.x||0));return $t(i)?u=Math.max(i,u):i&&Array.isArray(i)&&i.length&&(u=Math.max(...i.map(h=>h.x||0),u)),$t(u)?w.createElement("rect",{x:0,y:l<c?l:l-d,width:u+(o?parseInt("".concat(o),10):1),height:Math.floor(d)}):null}function P8e(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(!Cn(l)||!Cn(c))return null;var d=r*Math.abs(l-c),u=Math.max(...s.map(h=>h.y||0));return $t(i)?u=Math.max(i,u):i&&Array.isArray(i)&&i.length&&(u=Math.max(...i.map(h=>h.y||0),u)),$t(u)?w.createElement("rect",{x:l<c?l:l-d,y:0,width:d,height:Math.floor(u+(o?parseInt("".concat(o),10):1))}):null}function E8e(t){var{alpha:e,layout:n,points:r,baseLine:i,strokeWidth:s}=t;return n==="vertical"?w.createElement(M8e,{alpha:e,points:r,baseLine:i,strokeWidth:s}):w.createElement(P8e,{alpha:e,points:r,baseLine:i,strokeWidth:s})}function j8e(t){var{needClip:e,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:s}=t,{points:o,baseLine:l,isAnimationActive:c,animationBegin:d,animationDuration:u,animationEasing:h,onAnimationStart:f,onAnimationEnd:p}=r,x=w.useMemo(()=>({points:o,baseLine:l}),[o,l]),v=Zb(x,"recharts-area-"),g=LL(),[y,_]=w.useState(!1),N=!y,A=w.useCallback(()=>{typeof p=="function"&&p(),_(!1)},[p]),k=w.useCallback(()=>{typeof f=="function"&&f(),_(!0)},[f]);if(g==null)return null;var P=i.current,C=s.current;return w.createElement(T8e,{showLabels:N,points:o},r.children,w.createElement(Qb,{animationId:v,begin:d,duration:u,isActive:c,easing:h,onAnimationEnd:A,onAnimationStart:k,key:v},j=>{if(P){var M=P.length/o.length,E=j===1?o:o.map((L,U)=>{var D=Math.floor(U*M);if(P[D]){var $=P[D];return $g($g({},L),{},{x:wr($.x,L.x,j),y:wr($.y,L.y,j)})}return L}),B;return $t(l)?B=wr(C,l,j):ba(l)||ec(l)?B=wr(C,0,j):B=l.map((L,U)=>{var D=Math.floor(U*M);if(Array.isArray(C)&&C[D]){var $=C[D];return $g($g({},L),{},{x:wr($.x,L.x,j),y:wr($.y,L.y,j)})}return L}),j>0&&(i.current=E,s.current=B),w.createElement(L7,{points:E,baseLine:B,needClip:e,clipPathId:n,props:r})}return j>0&&(i.current=o,s.current=l),w.createElement(wa,null,c&&w.createElement("defs",null,w.createElement("clipPath",{id:"animationClipPath-".concat(n)},w.createElement(E8e,{alpha:j,points:o,baseLine:l,layout:g,strokeWidth:r.strokeWidth}))),w.createElement(wa,{clipPath:"url(#animationClipPath-".concat(n,")")},w.createElement(L7,{points:o,baseLine:l,needClip:e,clipPathId:n,props:r})))}),w.createElement(Jk,{label:r.label}))}function D8e(t){var{needClip:e,clipPathId:n,props:r}=t,i=w.useRef(null),s=w.useRef();return w.createElement(j8e,{needClip:e,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:s})}class R8e extends w.PureComponent{render(){var{hide:e,dot:n,points:r,className:i,top:s,left:o,needClip:l,xAxisId:c,yAxisId:d,width:u,height:h,id:f,baseLine:p,zIndex:x}=this.props;if(e)return null;var v=cr("recharts-area",i),g=f,{r:y,strokeWidth:_}=Bte(n),N=eO(n),A=y*2+_,k=l?"url(#clipPath-".concat(N?"":"dots-").concat(g,")"):void 0;return w.createElement(Ss,{zIndex:x},w.createElement(wa,{className:v},l&&w.createElement("defs",null,w.createElement(cO,{clipPathId:g,xAxisId:c,yAxisId:d}),!N&&w.createElement("clipPath",{id:"clipPath-dots-".concat(g)},w.createElement("rect",{x:o-A/2,y:s-A/2,width:u+A,height:h+A}))),w.createElement(D8e,{needClip:l,clipPathId:g,props:this.props})),w.createElement(dR,{points:r,mainColor:RN(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:k}),this.props.isRange&&Array.isArray(p)&&w.createElement(dR,{points:p,mainColor:RN(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:k}))}}var Zte={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:La.area};function F8e(t){var e,n=Sa(t,Zte),{activeDot:r,animationBegin:i,animationDuration:s,animationEasing:o,connectNulls:l,dot:c,fill:d,fillOpacity:u,hide:h,isAnimationActive:f,legendType:p,stroke:x,xAxisId:v,yAxisId:g}=n,y=Qte(n,v8e),_=am(),N=Xee(),{needClip:A}=sA(v,g),k=wi(),{points:P,isRange:C,baseLine:j}=(e=Gt(D=>x8e(D,t.id,k)))!==null&&e!==void 0?e:{},M=iA();if(_!=="horizontal"&&_!=="vertical"||M==null||N!=="AreaChart"&&N!=="ComposedChart")return null;var{height:E,width:B,x:L,y:U}=M;return!P||!P.length?null:w.createElement(R8e,yf({},y,{activeDot:r,animationBegin:i,animationDuration:s,animationEasing:o,baseLine:j,connectNulls:l,dot:c,fill:d,fillOpacity:u,height:E,hide:h,layout:_,isAnimationActive:f==="auto"?!Nv.isSsr:f,isRange:C,legendType:p,needClip:A,points:P,stroke:x,width:B,left:L,top:U,xAxisId:v,yAxisId:g}))}var L8e=(t,e,n,r,i)=>{var s=n??e;if($t(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]),d=Math.min(l[0],l[1]);return s==="dataMin"?d: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 O8e(t){var{areaSettings:{connectNulls:e,baseValue:n,dataKey:r},stackedData:i,layout:s,chartBaseValue:o,xAxis:l,yAxis:c,displayedData:d,dataStartIndex:u,xAxisTicks:h,yAxisTicks:f,bandSize:p}=t,x=i&&i.length,v=L8e(s,o,n,l,c),g=s==="horizontal",y=!1,_=d.map((A,k)=>{var P,C,j,M;if(x)M=i[u+k];else{var E=_r(A,r);Array.isArray(E)?(M=E,y=!0):M=[v,E]}var B=(P=(C=M)===null||C===void 0?void 0:C[1])!==null&&P!==void 0?P:null,L=B==null||x&&!e&&_r(A,r)==null;if(g){var U;return{x:tN({axis:l,ticks:h,bandSize:p,entry:A,index:k}),y:L?null:(U=c.scale.map(B))!==null&&U!==void 0?U:null,value:M,payload:A}}return{x:L?null:(j=l.scale.map(B))!==null&&j!==void 0?j:null,y:tN({axis:c,ticks:f,bandSize:p,entry:A,index:k}),value:M,payload:A}}),N;return x||y?N=_.map(A=>{var k,P=Array.isArray(A.value)?A.value[0]:null;if(g){var C;return{x:A.x,y:P!=null&&A.y!=null&&(C=c.scale.map(P))!==null&&C!==void 0?C:null,payload:A.payload}}return{x:P!=null&&(k=l.scale.map(P))!==null&&k!==void 0?k:null,y:A.y,payload:A.payload}}):N=g?c.scale.map(v):l.scale.map(v),{points:_,baseLine:N??0,isRange:y}}function I8e(t){var e=Sa(t,Zte),n=wi();return w.createElement(rA,{id:e.id,type:"area"},r=>w.createElement(w.Fragment,null,w.createElement(iO,{legendPayload:C8e(e)}),w.createElement(k8e,{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(sO,{type:"area",id:r,data:e.data,dataKey:e.dataKey,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,stackId:CZ(e.stackId),hide:e.hide,barSize:void 0,baseValue:e.baseValue,isPanorama:n,connectNulls:e.connectNulls}),w.createElement(F8e,yf({},e,{id:r}))))}var Jte=w.memo(I8e,Iv);Jte.displayName="Area";var z8e="Invariant failed";function U8e(t,e){throw new Error(z8e)}function uR(){return uR=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},uR.apply(null,arguments)}function FN(t){return w.createElement(tO,uR({shapeType:"rectangle",activeClassName:"recharts-active-bar"},t))}var B8e=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return(r,i)=>{if($t(e))return e;var s=$t(r)||ba(r);return s?e(r,i):(s||U8e(),n)}},H8e=(t,e,n)=>n,$8e=(t,e)=>e,zv=dt([Ev,$8e],(t,e)=>t.filter(n=>n.type==="bar").find(n=>n.id===e)),V8e=dt([zv],t=>t?.maxBarSize),q8e=(t,e,n,r)=>r,G8e=dt([ir,Ev,Kc,Xc,H8e],(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")),W8e=(t,e,n)=>{var r=ir(t),i=Kc(t,e),s=Xc(t,e);if(!(i==null||s==null))return r==="horizontal"?NN(t,"yAxis",s,n):NN(t,"xAxis",i,n)},K8e=(t,e)=>{var n=ir(t),r=Kc(t,e),i=Xc(t,e);if(!(r==null||i==null))return n==="horizontal"?pG(t,"xAxis",r):pG(t,"yAxis",i)},X8e=dt([G8e,TFe,K8e],Yze),Y8e=(t,e,n)=>{var r,i,s=zv(t,e);if(s==null)return 0;var o=Kc(t,e),l=Xc(t,e);if(o==null||l==null)return 0;var c=ir(t),d=GJ(t),{maxBarSize:u}=s,h=ba(u)?d:u,f,p;return c==="horizontal"?(f=Bc(t,"xAxis",o,n),p=Uc(t,"xAxis",o,n)):(f=Bc(t,"yAxis",l,n),p=Uc(t,"yAxis",l,n)),(r=(i=Qh(f,p,!0))!==null&&i!==void 0?i:h)!==null&&r!==void 0?r:0},ene=(t,e,n)=>{var r=ir(t),i=Kc(t,e),s=Xc(t,e);if(!(i==null||s==null)){var o,l;return r==="horizontal"?(o=Bc(t,"xAxis",i,n),l=Uc(t,"xAxis",i,n)):(o=Bc(t,"yAxis",s,n),l=Uc(t,"yAxis",s,n)),Qh(o,l)}},Q8e=dt([X8e,GJ,AFe,WJ,Y8e,ene,V8e],tUe),Z8e=(t,e,n)=>{var r=Kc(t,e);if(r!=null)return Bc(t,"xAxis",r,n)},J8e=(t,e,n)=>{var r=Xc(t,e);if(r!=null)return Bc(t,"yAxis",r,n)},e6e=(t,e,n)=>{var r=Kc(t,e);if(r!=null)return Uc(t,"xAxis",r,n)},t6e=(t,e,n)=>{var r=Xc(t,e);if(r!=null)return Uc(t,"yAxis",r,n)},n6e=dt([Q8e,zv],rUe),r6e=dt([W8e,zv],nUe),a6e=dt([vi,EL,Z8e,J8e,e6e,t6e,n6e,ir,RJ,ene,r6e,zv,q8e],(t,e,n,r,i,s,o,l,c,d,u,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||d==null)){var{data:g}=h,y;if(g!=null&&g.length>0?y=g:y=p?.slice(x,v+1),y!=null)return j6e({layout:l,barSettings:h,pos:o,parentViewBox:e,bandSize:d,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:s,stackedData:u,displayedData:y,offset:t,cells:f,dataStartIndex:x})}}),i6e=["index"];function hR(){return hR=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},hR.apply(null,arguments)}function s6e(t,e){if(t==null)return{};var n,r,i=o6e(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 o6e(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 tne=w.createContext(void 0),l6e=t=>{var e=w.useContext(tne);if(e!=null)return e.stackId;if(t!=null)return CZ(t)},c6e=(t,e)=>"recharts-bar-stack-clip-path-".concat(t,"-").concat(e),d6e=t=>{var e=w.useContext(tne);if(e!=null){var{stackId:n}=e;return"url(#".concat(c6e(n,t),")")}},nne=t=>{var{index:e}=t,n=s6e(t,i6e),r=d6e(e);return w.createElement(wa,hR({className:"recharts-bar-stack-layer",clipPath:r},n))},u6e=["onMouseEnter","onMouseLeave","onClick"],h6e=["value","background","tooltipPosition"],m6e=["id"],f6e=["onMouseEnter","onClick","onMouseLeave"];function mu(){return mu=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},mu.apply(null,arguments)}function O7(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Ms(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?O7(Object(n),!0).forEach(function(r){p6e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):O7(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function p6e(t,e,n){return(e=g6e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function g6e(t){var e=b6e(t,"string");return typeof e=="symbol"?e:e+""}function b6e(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 LN(t,e){if(t==null)return{};var n,r,i=x6e(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 x6e(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 y6e=t=>{var{dataKey:e,name:n,fill:r,legendType:i,hide:s}=t;return[{inactive:s,dataKey:e,type:i,color:r,value:rm(n,e),payload:t}]},v6e=w.memo(t=>{var{dataKey:e,stroke:n,strokeWidth:r,fill:i,name:s,hide:o,unit:l,tooltipType:c,id:d}=t,u={dataDefinedOnItem:void 0,getPosition:nm,settings:{stroke:n,strokeWidth:r,fill:i,dataKey:e,nameKey:void 0,name:rm(s,e),hide:o,type:c,color:i,unit:l,graphicalItemId:d}};return w.createElement(nA,{tooltipEntrySettings:u})});function w6e(t){var e=Gt(Zh),{data:n,dataKey:r,background:i,allOtherBarProps:s}=t,{onMouseEnter:o,onMouseLeave:l,onClick:c}=s,d=LN(s,u6e),u=nO(o,r,s.id),h=rO(l),f=aO(c,r,s.id);if(!i||n==null)return null;var p=zf(i);return w.createElement(Ss,{zIndex:aUe(i,La.barBackground)},n.map((x,v)=>{var{value:g,background:y,tooltipPosition:_}=x,N=LN(x,h6e);if(!y)return null;var A=u(x,v),k=h(x,v),P=f(x,v),C=Ms(Ms(Ms(Ms(Ms({option:i,isActive:String(v)===e},N),{},{fill:"#eee"},y),p),bv(d,x,v)),{},{onMouseEnter:A,onMouseLeave:k,onClick:P,dataKey:r,index:v,className:"recharts-bar-background-rectangle"});return w.createElement(FN,mu({key:"background-bar-".concat(v)},C))}))}function S6e(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 Ms(Ms({},o),{},{value:s.value,payload:s.payload,parentViewBox:s.parentViewBox,viewBox:o,fill:s.fill})});return w.createElement(Y4,{value:e?i:void 0},n)}function _6e(t){var{shape:e,activeBar:n,baseProps:r,entry:i,index:s,dataKey:o}=t,l=Gt(Zh),c=Gt(V4),d=n&&String(s)===l&&(c==null||o===c),u=d?n:e;return d?w.createElement(Ss,{zIndex:La.activeBar},w.createElement(nne,{index:s},w.createElement(FN,mu({},r,{name:String(r.name)},i,{isActive:d,option:u,index:s,dataKey:o})))):w.createElement(FN,mu({},r,{name:String(r.name)},i,{isActive:d,option:u,index:s,dataKey:o}))}function N6e(t){var{shape:e,baseProps:n,entry:r,index:i,dataKey:s}=t;return w.createElement(FN,mu({},n,{name:String(n.name)},r,{isActive:!1,option:e,index:i,dataKey:s}))}function C6e(t){var e,{data:n,props:r}=t,i=(e=Ls(r))!==null&&e!==void 0?e:{},{id:s}=i,o=LN(i,m6e),{shape:l,dataKey:c,activeBar:d}=r,{onMouseEnter:u,onClick:h,onMouseLeave:f}=r,p=LN(r,f6e),x=nO(u,c,s),v=rO(f),g=aO(h,c,s);return n?w.createElement(w.Fragment,null,n.map((y,_)=>w.createElement(nne,mu({index:_,key:"rectangle-".concat(y?.x,"-").concat(y?.y,"-").concat(y?.value,"-").concat(_),className:"recharts-bar-rectangle"},bv(p,y,_),{onMouseEnter:x(y,_),onMouseLeave:v(y,_),onClick:g(y,_)}),d?w.createElement(_6e,{shape:l,activeBar:d,baseProps:o,entry:y,index:_,dataKey:c}):w.createElement(N6e,{shape:l,baseProps:o,entry:y,index:_,dataKey:c})))):null}function k6e(t){var{props:e,previousRectanglesRef:n}=t,{data:r,layout:i,isAnimationActive:s,animationBegin:o,animationDuration:l,animationEasing:c,onAnimationEnd:d,onAnimationStart:u}=e,h=n.current,f=Zb(e,"recharts-bar-"),[p,x]=w.useState(!1),v=!p,g=w.useCallback(()=>{typeof d=="function"&&d(),x(!1)},[d]),y=w.useCallback(()=>{typeof u=="function"&&u(),x(!0)},[u]);return w.createElement(S6e,{showLabels:v,rects:r},w.createElement(Qb,{animationId:f,begin:o,duration:l,isActive:s,easing:c,onAnimationEnd:g,onAnimationStart:y,key:f},_=>{var N=_===1?r:r?.map((A,k)=>{var P=h&&h[k];if(P)return Ms(Ms({},A),{},{x:wr(P.x,A.x,_),y:wr(P.y,A.y,_),width:wr(P.width,A.width,_),height:wr(P.height,A.height,_)});if(i==="horizontal"){var C=wr(0,A.height,_),j=wr(A.stackedBarStart,A.y,_);return Ms(Ms({},A),{},{y:j,height:C})}var M=wr(0,A.width,_),E=wr(A.stackedBarStart,A.x,_);return Ms(Ms({},A),{},{width:M,x:E})});return _>0&&(n.current=N??null),N==null?null:w.createElement(wa,null,w.createElement(C6e,{props:e,data:N}))}),w.createElement(Jk,{label:e.label}),e.children)}function A6e(t){var e=w.useRef(null);return w.createElement(k6e,{previousRectanglesRef:e,props:t})}var rne=0,T6e=(t,e)=>{var n=Array.isArray(t.value)?t.value[1]:t.value;return{x:t.x,y:t.y,value:n,errorVal:_r(t,e)}};class M6e extends w.PureComponent{render(){var{hide:e,data:n,dataKey:r,className:i,xAxisId:s,yAxisId:o,needClip:l,background:c,id:d}=this.props;if(e||n==null)return null;var u=cr("recharts-bar",i),h=d;return w.createElement(wa,{className:u,id:d},l&&w.createElement("defs",null,w.createElement(cO,{clipPathId:h,xAxisId:s,yAxisId:o})),w.createElement(wa,{className:"recharts-bar-rectangles",clipPath:l?"url(#clipPath-".concat(h,")"):void 0},w.createElement(w6e,{data:n,dataKey:r,background:c,allOtherBarProps:this.props}),w.createElement(A6e,this.props)))}}var P6e={activeBar:!1,animationBegin:0,animationDuration:400,animationEasing:"ease",background:!1,hide:!1,isAnimationActive:"auto",label:!1,legendType:"rect",minPointSize:rne,xAxisId:0,yAxisId:0,zIndex:La.bar};function E6e(t){var{xAxisId:e,yAxisId:n,hide:r,legendType:i,minPointSize:s,activeBar:o,animationBegin:l,animationDuration:c,animationEasing:d,isAnimationActive:u}=t,{needClip:h}=sA(e,n),f=am(),p=wi(),x=J4(t.children,Ov),v=Gt(_=>a6e(_,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(Lte,{xAxisId:e,yAxisId:n,data:v,dataPointFormatter:T6e,errorBarOffset:g},w.createElement(M6e,mu({},t,{layout:f,needClip:h,data:v,xAxisId:e,yAxisId:n,hide:r,legendType:i,minPointSize:s,activeBar:o,animationBegin:l,animationDuration:c,animationEasing:d,isAnimationActive:u})))}function j6e(t){var{layout:e,barSettings:{dataKey:n,minPointSize:r},pos:i,bandSize:s,xAxis:o,yAxis:l,xAxisTicks:c,yAxisTicks:d,stackedData:u,displayedData:h,offset:f,cells:p,parentViewBox:x,dataStartIndex:v}=t,g=e==="horizontal"?l:o,y=u?g.scale.domain():null,_=pEe({numericAxis:g}),N=g.scale.map(_);return h.map((A,k)=>{var P,C,j,M,E,B;if(u){var L=u[k+v];if(L==null)return null;P=dEe(L,y)}else P=_r(A,n),Array.isArray(P)||(P=[_,P]);var U=B8e(r,rne)(P[1],k);if(e==="horizontal"){var D,$=l.scale.map(P[0]),q=l.scale.map(P[1]);if($==null||q==null)return null;C=fV({axis:o,ticks:c,bandSize:s,offset:i.offset,entry:A,index:k}),j=(D=q??$)!==null&&D!==void 0?D:void 0,M=i.size;var z=$-q;if(E=ec(z)?0:z,B={x:C,y:f.top,width:M,height:f.height},Math.abs(U)>0&&Math.abs(E)<Math.abs(U)){var W=Ri(E||U)*(Math.abs(U)-Math.abs(E));j-=W,E+=W}}else{var Q=o.scale.map(P[0]),te=o.scale.map(P[1]);if(Q==null||te==null)return null;if(C=Q,j=fV({axis:l,ticks:d,bandSize:s,offset:i.offset,entry:A,index:k}),M=te-Q,E=i.size,B={x:f.left,y:j,width:f.width,height:E},Math.abs(U)>0&&Math.abs(M)<Math.abs(U)){var H=Ri(M||U)*(Math.abs(U)-Math.abs(M));M+=H}}if(C==null||j==null||M==null||E==null)return null;var X=Ms(Ms({},A),{},{stackedBarStart:N,x:C,y:j,width:M,height:E,value:u?P:P[1],payload:A,background:B,tooltipPosition:{x:C+M/2,y:j+E/2},parentViewBox:x},p&&p[k]&&p[k].props);return X}).filter(Boolean)}function D6e(t){var e=Sa(t,P6e),n=l6e(e.stackId),r=wi();return w.createElement(rA,{id:e.id,type:"bar"},i=>w.createElement(w.Fragment,null,w.createElement(iO,{legendPayload:y6e(e)}),w.createElement(v6e,{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(sO,{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(Ss,{zIndex:e.zIndex},w.createElement(E6e,mu({},e,{id:i})))))}var ane=w.memo(D6e,Iv);ane.displayName="Bar";var R6e=["domain","range"],F6e=["domain","range"];function I7(t,e){if(t==null)return{};var n,r,i=L6e(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function L6e(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function z7(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 ine(t,e){if(t===e)return!0;var{domain:n,range:r}=t,i=I7(t,R6e),{domain:s,range:o}=e,l=I7(e,F6e);return!z7(n,s)||!z7(r,o)?!1:Iv(i,l)}var O6e=["type"],I6e=["dangerouslySetInnerHTML","ticks","scale"],z6e=["id","scale"];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)}function U7(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function B7(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?U7(Object(n),!0).forEach(function(r){U6e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):U7(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function U6e(t,e,n){return(e=B6e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function B6e(t){var e=H6e(t,"string");return typeof e=="symbol"?e:e+""}function H6e(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 fR(t,e){if(t==null)return{};var n,r,i=$6e(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 $6e(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 V6e(t){var e=Yr(),n=w.useRef(null),r=LL(),{type:i}=t,s=fR(t,O6e),o=Bk(r,"xAxis",i),l=w.useMemo(()=>{if(o!=null)return B7(B7({},s),{},{type:o})},[s,o]);return w.useLayoutEffect(()=>{l!=null&&(n.current===null?e(Fze(l)):n.current!==l&&e(Lze({prev:n.current,next:l})),n.current=l)},[l,e]),w.useLayoutEffect(()=>()=>{n.current&&(e(Oze(n.current)),n.current=null)},[e]),null}var q6e=t=>{var{xAxisId:e,className:n}=t,r=Gt(EL),i=wi(),s="xAxis",o=Gt(y=>kee(y,s,e,i)),l=Gt(y=>See(y,e)),c=Gt(y=>MLe(y,e)),d=Gt(y=>ree(y,e));if(l==null||c==null||d==null)return null;var{dangerouslySetInnerHTML:u,ticks:h,scale:f}=t,p=fR(t,I6e),{id:x,scale:v}=d,g=fR(d,z6e);return w.createElement(lO,mR({},p,g,{x:c.x,y:c.y,width:l.width,height:l.height,className:cr("recharts-".concat(s," ").concat(s),n),viewBox:r,ticks:o,axisType:s}))},G6e={allowDataOverflow:Mi.allowDataOverflow,allowDecimals:Mi.allowDecimals,allowDuplicatedCategory:Mi.allowDuplicatedCategory,angle:Mi.angle,axisLine:Xd.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:Xd.tickLine,tickSize:Xd.tickSize,type:Mi.type,xAxisId:0},W6e=t=>{var e=Sa(t,G6e);return w.createElement(w.Fragment,null,w.createElement(V6e,{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(q6e,e))},ON=w.memo(W6e,ine);ON.displayName="XAxis";var K6e=["type"],X6e=["dangerouslySetInnerHTML","ticks","scale"],Y6e=["id","scale"];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 H7(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 $7(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?H7(Object(n),!0).forEach(function(r){Q6e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):H7(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Q6e(t,e,n){return(e=Z6e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Z6e(t){var e=J6e(t,"string");return typeof e=="symbol"?e:e+""}function J6e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function gR(t,e){if(t==null)return{};var n,r,i=eHe(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 eHe(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 tHe(t){var e=Yr(),n=w.useRef(null),r=LL(),{type:i}=t,s=gR(t,K6e),o=Bk(r,"yAxis",i),l=w.useMemo(()=>{if(o!=null)return $7($7({},s),{},{type:o})},[o,s]);return w.useLayoutEffect(()=>{l!=null&&(n.current===null?e(Ize(l)):n.current!==l&&e(zze({prev:n.current,next:l})),n.current=l)},[l,e]),w.useLayoutEffect(()=>()=>{n.current&&(e(Uze(n.current)),n.current=null)},[e]),null}function nHe(t){var{yAxisId:e,className:n,width:r,label:i}=t,s=w.useRef(null),o=w.useRef(null),l=Gt(EL),c=wi(),d=Yr(),u="yAxis",h=Gt(P=>_ee(P,e)),f=Gt(P=>ELe(P,e)),p=Gt(P=>kee(P,u,e,c)),x=Gt(P=>aee(P,e));if(w.useLayoutEffect(()=>{if(!(r!=="auto"||!h||X4(i)||w.isValidElement(i)||x==null)){var P=s.current;if(P){var C=P.getCalculatedWidth();Math.round(h.width)!==Math.round(C)&&d(Bze({id:e,width:C}))}}},[p,h,d,i,e,r,x]),h==null||f==null||x==null)return null;var{dangerouslySetInnerHTML:v,ticks:g,scale:y}=t,_=gR(t,X6e),{id:N,scale:A}=x,k=gR(x,Y6e);return w.createElement(lO,pR({},_,k,{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:cr("recharts-".concat(u," ").concat(u),n),viewBox:l,ticks:p,axisType:u}))}var rHe={allowDataOverflow:Pi.allowDataOverflow,allowDecimals:Pi.allowDecimals,allowDuplicatedCategory:Pi.allowDuplicatedCategory,angle:Pi.angle,axisLine:Xd.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:Xd.tickLine,tickSize:Xd.tickSize,type:Pi.type,width:Pi.width,yAxisId:0},aHe=t=>{var e=Sa(t,rHe);return w.createElement(w.Fragment,null,w.createElement(tHe,{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(nHe,e))},IN=w.memo(aHe,ine);IN.displayName="YAxis";var iHe=(t,e)=>e,uO=dt([iHe,ir,eee,Ii,$ee,yu,G4e,vi],J4e),hO=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=kl("mouseClick"),one=yv();one.startListening({actionCreator:sne,effect:(t,e)=>{var n=t.payload,r=uO(e.getState(),hO(n));r?.activeIndex!=null&&e.dispatch(qLe({activeIndex:r.activeIndex,activeDataKey:void 0,activeCoordinate:r.activeCoordinate}))}});var bR=kl("mouseMove"),lne=yv(),y_=null;lne.startListening({actionCreator:bR,effect:(t,e)=>{var n=t.payload;y_!==null&&cancelAnimationFrame(y_);var r=hO(n);y_=requestAnimationFrame(()=>{var i=e.getState(),s=I4(i,i.tooltip.settings.shared);if(s==="axis"){var o=uO(i,r);o?.activeIndex!=null?e.dispatch(Ree({activeIndex:o.activeIndex,activeDataKey:void 0,activeCoordinate:o.activeCoordinate})):e.dispatch(Dee())}y_=null})}});function sHe(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 V7={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},cne=uo({name:"rootProps",initialState:V7,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:V7.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}}}),oHe=cne.reducer,{updateOptions:lHe}=cne.actions,cHe=null,dHe={updatePolarOptions:(t,e)=>e.payload},dne=uo({name:"polarOptions",initialState:cHe,reducers:dHe}),{updatePolarOptions:uHe}=dne.actions,hHe=dne.reducer,une=kl("keyDown"),hne=kl("focus"),mO=yv();mO.startListening({actionCreator:une,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=z4(i,ox(n),Dv(n),Fv(n)),l=o==null?-1:Number(o);if(!(!Number.isFinite(l)||l<0)){var c=yu(n);if(s==="Enter"){var d=kN(n,"axis","hover",String(i.index));e.dispatch(iR({active:!i.active,activeIndex:i.index,activeCoordinate:d}));return}var u=FLe(n),h=u==="left-to-right"?1:-1,f=s==="ArrowRight"?1:-1,p=l+f*h;if(!(c==null||p>=c.length||p<0)){var x=kN(n,"axis","hover",String(p));e.dispatch(iR({active:!0,activeIndex:p.toString(),activeCoordinate:x}))}}}}}});mO.startListening({actionCreator:hne,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=kN(n,"axis","hover",String(s));e.dispatch(iR({active:!0,activeIndex:s,activeCoordinate:o}))}}}});var el=kl("externalEvent"),mne=yv(),UE=new Map;mne.startListening({actionCreator:el,effect:(t,e)=>{var{handler:n,reactEvent:r}=t.payload;if(n!=null){r.persist();var i=r.type,s=UE.get(i);s!==void 0&&cancelAnimationFrame(s);var o=requestAnimationFrame(()=>{try{var l=e.getState(),c={activeCoordinate:E4e(l),activeDataKey:V4(l),activeIndex:Zh(l),activeLabel:Gee(l),activeTooltipIndex:Zh(l),isTooltipActive:j4e(l)};n(c,r)}finally{UE.delete(i)}});UE.set(i,o)}}});var mHe=dt([ix],t=>t.tooltipItemPayloads),fHe=dt([mHe,(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)}}}),fne=kl("touchMove"),pne=yv();pne.startListening({actionCreator:fne,effect:(t,e)=>{var n=t.payload;if(!(n.touches==null||n.touches.length===0)){var r=e.getState(),i=I4(r,r.tooltip.settings.shared);if(i==="axis"){var s=n.touches[0];if(s==null)return;var o=uO(r,hO({clientX:s.clientX,clientY:s.clientY,currentTarget:n.currentTarget}));o?.activeIndex!=null&&e.dispatch(Ree({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 d=document.elementFromPoint(c.clientX,c.clientY);if(!d||!d.getAttribute)return;var u=d.getAttribute(AZ),h=(l=d.getAttribute(TZ))!==null&&l!==void 0?l:void 0,f=sx(r).find(v=>v.id===h);if(u==null||f==null||h==null)return;var{dataKey:p}=f,x=fHe(r,u,h);e.dispatch(jee({activeDataKey:p,activeIndex:u,activeCoordinate:x,activeGraphicalItemId:h}))}}}});var pHe=KQ({brush:iUe,cartesianAxis:Hze,chartData:POe,errorBars:pBe,graphicalItems:Y5e,layout:iEe,legend:uje,options:COe,polarAxis:d5e,polarOptions:hHe,referenceElements:mUe,rootProps:oHe,tooltip:GLe,zIndex:mOe}),gHe=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"Chart";return P2e({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([one.middleware,lne.middleware,mO.middleware,mne.middleware,pne.middleware])},enhancers:r=>{var i=r;return typeof r=="function"&&(i=r()),i.concat(cZ({type:"raf"}))},devTools:{serialize:{replacer:sHe},name:"recharts-".concat(n)}})};function gne(t){var{preloadedState:e,children:n,reduxStoreName:r}=t,i=wi(),s=w.useRef(null);if(i)return n;s.current==null&&(s.current=gHe(e,r));var o=NL;return w.createElement($Be,{context:o,store:s.current},n)}function bHe(t){var{layout:e,margin:n}=t,r=Yr(),i=wi();return w.useEffect(()=>{i||(r(nEe(e)),r(tEe(n)))},[r,i,e,n]),null}var bne=w.memo(bHe,Iv);function xne(t){var e=Yr();return w.useEffect(()=>{e(lHe(t))},[e,t]),null}function q7(t){var{zIndex:e,isPanorama:n}=t,r=w.useRef(null),i=Yr();return w.useLayoutEffect(()=>(r.current&&i(uOe({zIndex:e,element:r.current,isPanorama:n})),()=>{i(hOe({zIndex:e,isPanorama:n}))}),[i,e,n]),w.createElement("g",{tabIndex:-1,ref:r})}function G7(t){var{children:e,isPanorama:n}=t,r=Gt(tOe);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(q7,{key:o,zIndex:o,isPanorama:n})),e,s.map(o=>w.createElement(q7,{key:o,zIndex:o,isPanorama:n})))}var xHe=["children"];function yHe(t,e){if(t==null)return{};var n,r,i=vHe(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 vHe(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 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)}var wHe={width:"100%",height:"100%",display:"block"},SHe=w.forwardRef((t,e)=>{var n=RL(),r=FL(),i=VZ();if(!Ic(n)||!Ic(r))return null;var{children:s,otherAttributes:o,title:l,desc:c}=t,d,u;return o!=null&&(typeof o.tabIndex=="number"?d=o.tabIndex:d=i?0:void 0,typeof o.role=="string"?u=o.role:u=i?"application":void 0),w.createElement(mL,zN({},o,{title:l,desc:c,role:u,tabIndex:d,width:n,height:r,style:wHe,ref:e}),s)}),_He=t=>{var{children:e}=t,n=Gt(Mk);if(!n)return null;var{width:r,height:i,y:s,x:o}=n;return w.createElement(mL,{width:r,height:i,x:o,y:s},e)},W7=w.forwardRef((t,e)=>{var{children:n}=t,r=yHe(t,xHe),i=wi();return i?w.createElement(_He,null,w.createElement(G7,{isPanorama:!0},n)):w.createElement(SHe,zN({ref:e},r),w.createElement(G7,{isPanorama:!1},n))});function NHe(){var t=Yr(),[e,n]=w.useState(null),r=Gt(wEe);return w.useEffect(()=>{if(e!=null){var i=e.getBoundingClientRect(),s=i.width/e.offsetWidth;Cn(s)&&s!==r&&t(aEe(s))}},[e,t,r]),n}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 CHe(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){kHe(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 kHe(t,e,n){return(e=AHe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function AHe(t){var e=THe(t,"string");return typeof e=="symbol"?e:e+""}function THe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Uh(){return Uh=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Uh.apply(null,arguments)}var MHe=()=>(zOe(),null);function UN(t){if(typeof t=="number")return t;if(typeof t=="string"){var e=parseFloat(t);if(!Number.isNaN(e))return e}return 0}var PHe=w.forwardRef((t,e)=>{var n,r,i=w.useRef(null),[s,o]=w.useState({containerWidth:UN((n=t.style)===null||n===void 0?void 0:n.width),containerHeight:UN((r=t.style)===null||r===void 0?void 0:r.height)}),l=w.useCallback((d,u)=>{o(h=>{var f=Math.round(d),p=Math.round(u);return h.containerWidth===f&&h.containerHeight===p?h:{containerWidth:f,containerHeight:p}})},[]),c=w.useCallback(d=>{if(typeof e=="function"&&e(d),d!=null&&typeof ResizeObserver<"u"){var{width:u,height:h}=d.getBoundingClientRect();l(u,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(d),i.current=p}},[e,l]);return w.useEffect(()=>()=>{var d=i.current;d?.disconnect()},[l]),w.createElement(w.Fragment,null,w.createElement(Sv,{width:s.containerWidth,height:s.containerHeight}),w.createElement("div",Uh({ref:c},t)))}),EHe=w.forwardRef((t,e)=>{var{width:n,height:r}=t,[i,s]=w.useState({containerWidth:UN(n),containerHeight:UN(r)}),o=w.useCallback((c,d)=>{s(u=>{var h=Math.round(c),f=Math.round(d);return u.containerWidth===h&&u.containerHeight===f?u:{containerWidth:h,containerHeight:f}})},[]),l=w.useCallback(c=>{if(typeof e=="function"&&e(c),c!=null){var{width:d,height:u}=c.getBoundingClientRect();o(d,u)}},[e,o]);return w.createElement(w.Fragment,null,w.createElement(Sv,{width:i.containerWidth,height:i.containerHeight}),w.createElement("div",Uh({ref:l},t)))}),jHe=w.forwardRef((t,e)=>{var{width:n,height:r}=t;return w.createElement(w.Fragment,null,w.createElement(Sv,{width:n,height:r}),w.createElement("div",Uh({ref:e},t)))}),DHe=w.forwardRef((t,e)=>{var{width:n,height:r}=t;return typeof n=="string"||typeof r=="string"?w.createElement(EHe,Uh({},t,{ref:e})):typeof n=="number"&&typeof r=="number"?w.createElement(jHe,Uh({},t,{width:n,height:r,ref:e})):w.createElement(w.Fragment,null,w.createElement(Sv,{width:n,height:r}),w.createElement("div",Uh({ref:e},t)))});function RHe(t){return t?PHe:DHe}var FHe=w.forwardRef((t,e)=>{var{children:n,className:r,height:i,onClick:s,onContextMenu:o,onDoubleClick:l,onMouseDown:c,onMouseEnter:d,onMouseLeave:u,onMouseMove:h,onMouseUp:f,onTouchEnd:p,onTouchMove:x,onTouchStart:v,style:g,width:y,responsive:_,dispatchTouchEvents:N=!0}=t,A=w.useRef(null),k=Yr(),[P,C]=w.useState(null),[j,M]=w.useState(null),E=NHe(),B=jL(),L=B?.width>0?B.width:y,U=B?.height>0?B.height:i,D=w.useCallback(se=>{E(se),typeof e=="function"&&e(se),C(se),M(se),se!=null&&(A.current=se)},[E,e,C,M]),$=w.useCallback(se=>{k(sne(se)),k(el({handler:s,reactEvent:se}))},[k,s]),q=w.useCallback(se=>{k(bR(se)),k(el({handler:d,reactEvent:se}))},[k,d]),z=w.useCallback(se=>{k(Dee()),k(el({handler:u,reactEvent:se}))},[k,u]),W=w.useCallback(se=>{k(bR(se)),k(el({handler:h,reactEvent:se}))},[k,h]),Q=w.useCallback(()=>{k(hne())},[k]),te=w.useCallback(se=>{k(une(se.key))},[k]),H=w.useCallback(se=>{k(el({handler:o,reactEvent:se}))},[k,o]),X=w.useCallback(se=>{k(el({handler:l,reactEvent:se}))},[k,l]),Z=w.useCallback(se=>{k(el({handler:c,reactEvent:se}))},[k,c]),ee=w.useCallback(se=>{k(el({handler:f,reactEvent:se}))},[k,f]),Se=w.useCallback(se=>{k(el({handler:v,reactEvent:se}))},[k,v]),oe=w.useCallback(se=>{N&&k(fne(se)),k(el({handler:x,reactEvent:se}))},[k,N,x]),ie=w.useCallback(se=>{k(el({handler:p,reactEvent:se}))},[k,p]),me=RHe(_);return w.createElement(ete.Provider,{value:P},w.createElement(dQ.Provider,{value:j},w.createElement(me,{width:L??g?.width,height:U??g?.height,className:cr("recharts-wrapper",r),style:CHe({position:"relative",cursor:"default",width:L,height:U},g),onClick:$,onContextMenu:H,onDoubleClick:X,onFocus:Q,onKeyDown:te,onMouseDown:Z,onMouseEnter:q,onMouseLeave:z,onMouseMove:W,onMouseUp:ee,onTouchEnd:ie,onTouchMove:oe,onTouchStart:Se,ref:D},w.createElement(MHe,null),n)))}),LHe=["width","height","responsive","children","className","style","compact","title","desc"];function OHe(t,e){if(t==null)return{};var n,r,i=IHe(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 IHe(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 yne=w.forwardRef((t,e)=>{var{width:n,height:r,responsive:i,children:s,className:o,style:l,compact:c,title:d,desc:u}=t,h=OHe(t,LHe),f=Ls(h);return c?w.createElement(w.Fragment,null,w.createElement(Sv,{width:n,height:r}),w.createElement(W7,{otherAttributes:f,title:d,desc:u},s)):w.createElement(FHe,{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(W7,{otherAttributes:f,title:d,desc:u,ref:e},w.createElement(fUe,null,s)))});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)}var zHe={top:5,right:5,bottom:5,left:5},UHe={accessibilityLayer:!0,barCategoryGap:"10%",barGap:4,layout:"horizontal",margin:zHe,responsive:!1,reverseStackOrder:!1,stackOffset:"none",syncMethod:"index"},fO=w.forwardRef(function(e,n){var r,i=Sa(e.categoricalChartProps,UHe),{chartName:s,defaultTooltipEventType:o,validateTooltipEventTypes:l,tooltipPayloadSearcher:c,categoricalChartProps:d}=e,u={chartName:s,defaultTooltipEventType:o,validateTooltipEventTypes:l,tooltipPayloadSearcher:c,eventEmitter:void 0};return w.createElement(gne,{preloadedState:{options:u},reduxStoreName:(r=d.id)!==null&&r!==void 0?r:s},w.createElement(Mte,{chartData:d.data}),w.createElement(bne,{layout:i.layout,margin:i.margin}),w.createElement(xne,{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(yne,xR({},i,{ref:n})))}),BHe=["axis"],HHe=w.forwardRef((t,e)=>w.createElement(fO,{chartName:"LineChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:BHe,tooltipPayloadSearcher:Qk,categoricalChartProps:t,ref:e})),$He=["axis","item"],VHe=w.forwardRef((t,e)=>w.createElement(fO,{chartName:"BarChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:$He,tooltipPayloadSearcher:Qk,categoricalChartProps:t,ref:e}));function qHe(t){var e=Yr();return w.useEffect(()=>{e(uHe(t))},[e,t]),null}var GHe=["layout"];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)}function WHe(t,e){if(t==null)return{};var n,r,i=KHe(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 KHe(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 XHe={top:5,right:5,bottom:5,left:5},vne={accessibilityLayer:!0,stackOffset:"none",barCategoryGap:"10%",barGap:4,margin:XHe,reverseStackOrder:!1,syncMethod:"index",layout:"radial",responsive:!1,cx:"50%",cy:"50%",innerRadius:0,outerRadius:"80%"},YHe=w.forwardRef(function(e,n){var r,i=Sa(e.categoricalChartProps,vne),{layout:s}=i,o=WHe(i,GHe),{chartName:l,defaultTooltipEventType:c,validateTooltipEventTypes:d,tooltipPayloadSearcher:u}=e,h={chartName:l,defaultTooltipEventType:c,validateTooltipEventTypes:d,tooltipPayloadSearcher:u,eventEmitter:void 0};return w.createElement(gne,{preloadedState:{options:h},reduxStoreName:(r=i.id)!==null&&r!==void 0?r:l},w.createElement(Mte,{chartData:i.data}),w.createElement(bne,{layout:s,margin:i.margin}),w.createElement(xne,{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(qHe,{cx:i.cx,cy:i.cy,startAngle:i.startAngle,endAngle:i.endAngle,innerRadius:i.innerRadius,outerRadius:i.outerRadius}),w.createElement(yne,yR({},o,{ref:n})))});function X7(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Y7(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?X7(Object(n),!0).forEach(function(r){QHe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):X7(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function QHe(t,e,n){return(e=ZHe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function ZHe(t){var e=JHe(t,"string");return typeof e=="symbol"?e:e+""}function JHe(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 e$e=["item"],t$e=Y7(Y7({},vne),{},{layout:"centric",startAngle:0,endAngle:360}),n$e=w.forwardRef((t,e)=>{var n=Sa(t,t$e);return w.createElement(YHe,{chartName:"PieChart",defaultTooltipEventType:"item",validateTooltipEventTypes:e$e,tooltipPayloadSearcher:Qk,categoricalChartProps:n,ref:e})}),r$e=["axis"],a$e=w.forwardRef((t,e)=>w.createElement(fO,{chartName:"AreaChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:r$e,tooltipPayloadSearcher:Qk,categoricalChartProps:t,ref:e}));const Q7=[{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 i$e({isOpen:t,onClose:e,printerId:n,printerName:r,amsId:i,amsLabel:s,initialMode:o="humidity",thresholds:l}){const{t:c}=Dt(),{mode:d}=ep(),[u,h]=w.useState("24h"),[f,p]=w.useState(o),x=d==="dark",{data:v}=Ze({queryKey:["settings"],queryFn:J.getSettings}),g=v?.time_format||"system";w.useEffect(()=>{if(!t)return;const ie=me=>{me.key==="Escape"&&e()};return window.addEventListener("keydown",ie),()=>window.removeEventListener("keydown",ie)},[t,e]);const y=Q7.find(ie=>ie.value===u)?.hours||24,{data:_,isLoading:N,error:A}=Ze({queryKey:["ams-history",n,i,y],queryFn:()=>J.getAMSHistory(n,i,y),enabled:t,refetchInterval:6e4});if(!t)return null;const k=_?.data.map(ie=>({time:(tr(ie.recorded_at)||new Date).getTime(),humidity:ie.humidity,temperature:ie.temperature}))||[],P=Date.now()-y*60*60*1e3,C=Date.now(),j=[...k];if(j.length>0){const ie=j[0];ie.time>P&&j.unshift({...ie,time:P});const me=j[j.length-1];me.time<C&&j.push({...me,time:C})}const M=l?.humidityGood||40,E=l?.humidityFair||60,B=l?.tempGood||30,L=l?.tempFair||35,U=j[j.length-1],D=U?.humidity,$=U?.temperature,q=ie=>{const me=ie.filter(V=>V!=null);if(me.length<4)return"stable";const se=me.slice(0,Math.floor(me.length/4)),ce=me.slice(-Math.floor(me.length/4)),Ce=se.reduce((V,K)=>V+K,0)/se.length,Le=ce.reduce((V,K)=>V+K,0)/ce.length-Ce;return Math.abs(Le)<2?"stable":Le>0?"up":"down"},z=q(j.map(ie=>ie.humidity)),W=q(j.map(ie=>ie.temperature)),Q=({trend:ie})=>ie==="up"?a.jsx(u3,{className:"w-4 h-4 text-red-400"}):ie==="down"?a.jsx(EF,{className:"w-4 h-4 text-green-400"}):a.jsx(w1,{className:"w-4 h-4 text-gray-400 dark:text-bambu-gray"}),te=ie=>ie==null?"#9ca3af":ie<=M?"#22a352":ie<=E?"#d4a017":"#c62828",H=ie=>ie==null?"#9ca3af":ie<=B?"#22a352":ie<=L?"#d4a017":"#c62828",X=x?"#2d2d2d":"#ffffff",Z=x?"#1d1d1d":"#f3f4f6",ee=x?"#3d3d3d":"#e5e7eb",Se=x?"#ffffff":"#111827",oe=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:X},onClick:ie=>ie.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b",style:{borderColor:ee},children:[a.jsxs("div",{children:[a.jsxs("h2",{className:"text-lg font-semibold",style:{color:Se},children:[s," ",c("common.history","History")]}),a.jsx("p",{className:"text-sm",style:{color:oe},children:r})]}),a.jsx("button",{onClick:e,className:"p-2 rounded-lg transition-colors",style:{color:oe},children:a.jsx(Rt,{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:Z},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:oe}:void 0,children:[a.jsx(AF,{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:oe}:void 0,children:[a.jsx(JC,{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:Z},children:Q7.map(ie=>a.jsx("button",{onClick:()=>h(ie.value),className:`px-3 py-1 text-sm rounded-md transition-colors ${u===ie.value?"bg-bambu-green text-white":""}`,style:u!==ie.value?{color:oe}:void 0,children:ie.label},ie.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:Z},children:[a.jsx("p",{className:"text-xs",style:{color:oe},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:te(D)},children:D!=null?`${D}%`:"—"}),a.jsx(Q,{trend:z})]})]}),a.jsxs("div",{className:"rounded-lg p-4 max-[550px]:order-4",style:{backgroundColor:Z},children:[a.jsx("p",{className:"text-xs",style:{color:oe},children:c("common.average","Average")}),a.jsx("p",{className:"text-2xl font-bold",style:{color:Se},children:_?.avg_humidity!=null?`${_.avg_humidity}%`:"—"})]}),a.jsxs("div",{className:"rounded-lg p-4 max-[550px]:order-1",style:{backgroundColor:Z},children:[a.jsx("p",{className:"text-xs",style:{color:oe},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:Z},children:[a.jsx("p",{className:"text-xs",style:{color:oe},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:Z},children:[a.jsx("p",{className:"text-xs",style:{color:oe},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:H($)},children:$!=null?`${$}°C`:"—"}),a.jsx(Q,{trend:W})]})]}),a.jsxs("div",{className:"rounded-lg p-4 max-[550px]:order-4",style:{backgroundColor:Z},children:[a.jsx("p",{className:"text-xs",style:{color:oe},children:c("common.average","Average")}),a.jsx("p",{className:"text-2xl font-bold",style:{color:Se},children:_?.avg_temperature!=null?`${_.avg_temperature}°C`:"—"})]}),a.jsxs("div",{className:"rounded-lg p-4 max-[550px]:order-1",style:{backgroundColor:Z},children:[a.jsx("p",{className:"text-xs",style:{color:oe},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:Z},children:[a.jsx("p",{className:"text-xs",style:{color:oe},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:Z},children:N?a.jsx("div",{className:"h-[300px] flex items-center justify-center",style:{color:oe},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")}):j.length===0?a.jsx("div",{className:"h-[300px] flex items-center justify-center",style:{color:oe},children:c("common.noData","No data available for this time range")}):a.jsx(e1,{width:"100%",height:300,children:a.jsxs(HHe,{data:j,children:[a.jsx(DN,{strokeDasharray:"3 3",stroke:x?"#3d3d3d":"#e5e7eb"}),a.jsx(ON,{dataKey:"time",type:"number",domain:[Date.now()-y*60*60*1e3,Date.now()],tickFormatter:ie=>{const me=new Date(ie);return y>24?me.toLocaleDateString([],{day:"numeric",month:"short"}):me.toLocaleTimeString([],C1({hour:"2-digit",minute:"2-digit"},g))},stroke:x?"#9ca3af":"#6b7280",tick:{fontSize:12}}),a.jsx(IN,{stroke:x?"#9ca3af":"#6b7280",tick:{fontSize:12},domain:f==="humidity"?[0,100]:["auto","auto"],tickFormatter:ie=>f==="humidity"?`${ie}%`:`${ie}°C`}),a.jsx(n1,{contentStyle:{backgroundColor:x?"#2d2d2d":"#ffffff",border:`1px solid ${x?"#3d3d3d":"#e5e7eb"}`,borderRadius:"8px",color:x?"#fff":"#000"},labelFormatter:ie=>new Date(ie).toLocaleString(void 0,C1({year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"},g)),formatter:ie=>[f==="humidity"?`${ie??0}%`:`${ie??0}°C`,f==="humidity"?"Humidity":"Temperature"]}),a.jsx(zL,{}),f==="humidity"?a.jsxs(a.Fragment,{children:[a.jsx(jy,{y:M,stroke:"#22a352",strokeDasharray:"5 5",label:{value:"Good",fill:"#22a352",fontSize:10}}),a.jsx(jy,{y:E,stroke:"#d4a017",strokeDasharray:"5 5",label:{value:"Fair",fill:"#d4a017",fontSize:10}})]}):a.jsxs(a.Fragment,{children:[a.jsx(jy,{y:B,stroke:"#22a352",strokeDasharray:"5 5",label:{value:"Good",fill:"#22a352",fontSize:10}}),a.jsx(jy,{y:L,stroke:"#d4a017",strokeDasharray:"5 5",label:{value:"Fair",fill:"#d4a017",fontSize:10}})]}),a.jsx(Vte,{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:oe},children:c("amsHistory.recordingInfo","Data is recorded every 5 minutes while the printer is connected")})]})]})})}function BE({data:t,children:e,disabled:n,className:r="",spoolman:i,inventory:s,configureSlot:o}){const{t:l}=Dt(),[c,d]=w.useState(!1),[u,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 E=document.createElement("textarea");E.value=M,E.style.position="fixed",E.style.opacity="0",document.body.appendChild(E),E.select();try{document.execCommand("copy"),p(!0),setTimeout(()=>p(!1),2e3)}catch{console.error("Failed to copy to clipboard")}document.body.removeChild(E)};w.useEffect(()=>{if(c&&x.current&&v.current){const M=x.current.getBoundingClientRect(),E=v.current.offsetHeight,L=M.top-56,U=window.innerHeight-M.bottom;L<E+12&&U>L?h("bottom"):h("top")}},[c]);const N=()=>{n||(g.current&&clearTimeout(g.current),g.current=setTimeout(()=>d(!0),80))},A=()=>{g.current&&clearTimeout(g.current),g.current=setTimeout(()=>d(!1),100)};w.useEffect(()=>()=>{g.current&&clearTimeout(g.current)},[]);const k=M=>M<=15?"#ef4444":M<=30?"#f97316":M<=50?"#eab308":"#22c55e",P=M=>{if(!M)return!1;const E=M.replace("#",""),B=parseInt(E.slice(0,2),16),L=parseInt(E.slice(2,4),16),U=parseInt(E.slice(4,6),16);return(.299*B+.587*L+.114*U)/255>.6},C=t.colorHex?`#${t.colorHex.replace("#","")}`:null,j=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:`
- absolute left-1/2 -translate-x-1/2 z-50
- ${u==="top"?"bottom-full mb-2":"top-full mt-2"}
- animate-in fade-in-0 zoom-in-95 duration-150
- `,style:{maxWidth:"calc(100vw - 24px)"},children:[a.jsxs("div",{className:`
- w-52 bg-bambu-dark-secondary border border-bambu-dark-tertiary
- rounded-lg shadow-xl overflow-hidden
- backdrop-blur-sm
- `,children:[a.jsxs("div",{className:"h-12 relative overflow-hidden",style:{backgroundColor:C||"#3d3d3d"},children:[a.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-white/10 to-transparent"}),a.jsx("div",{className:`
- absolute inset-0 flex items-center justify-center
- font-semibold text-sm tracking-wide
- ${P(C)?"text-black/80":"text-white/90"}
- `,children:t.colorName}),a.jsx("div",{className:`
- absolute top-1.5 right-1.5 px-1.5 py-0.5 rounded text-[9px] font-bold uppercase tracking-wider
- ${t.vendor==="Bambu Lab"?"bg-black/60 text-white":"bg-black/50 text-white/90"}
- `,children:t.vendor==="Bambu Lab"?"BBL":"GEN"})]}),a.jsxs("div",{className:"p-3 space-y-2.5",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children: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(AF,{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}%`:"—"}),j!==null&&t.fillLevel!==null&&a.jsxs("span",{className:"text-[9px] text-bambu-gray font-normal",children:["• ",j,"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:k(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(na,{className:"w-3 h-3 text-bambu-green"}):a.jsx(Ql,{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(ta,{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(Dh,{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(fi,{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(ek,{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(fi,{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(tu,{className:"w-3.5 h-3.5"}),l("ams.configure")]})})]})]}),a.jsx("div",{className:`
- absolute left-1/2 -translate-x-1/2 w-0 h-0
- border-l-[6px] border-l-transparent
- border-r-[6px] border-r-transparent
- ${u==="top"?"top-full border-t-[6px] border-t-bambu-dark-tertiary":"bottom-full border-b-[6px] border-b-bambu-dark-tertiary"}
- `})]})]})}function HE({children:t,className:e="",configureSlot:n}){const{t:r}=Dt(),[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:`
- absolute left-1/2 -translate-x-1/2 bottom-full mb-2 z-50
- animate-in fade-in-0 zoom-in-95 duration-150
- `,children:[a.jsxs("div",{className:`
- bg-bambu-dark-secondary border border-bambu-dark-tertiary
- rounded-md shadow-lg overflow-hidden
- `,children:[a.jsx("div",{className:"px-3 py-1.5 text-xs text-bambu-gray whitespace-nowrap",children:r("ams.emptySlot")}),n?.enabled&&a.jsx("div",{className:"px-2 pb-2",children:a.jsxs("button",{onClick:d=>{d.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(tu,{className:"w-3.5 h-3.5"}),r("ams.configure")]})})]}),a.jsx("div",{className:`
- absolute left-1/2 -translate-x-1/2 top-full w-0 h-0
- border-l-[5px] border-l-transparent
- border-r-[5px] border-r-transparent
- border-t-[5px] border-t-bambu-dark-tertiary
- `})]})]})}function s$e({isOpen:t,onClose:e,tagUid:n,trayUuid:r,printerId:i,amsId:s,trayId:o}){const{t:l}=Dt(),c=Qt(),{showToast:d}=dn(),[u,h]=w.useState(""),{data:f,isLoading:p}=Ze({queryKey:["inventory-spools"],queryFn:()=>J.getSpools(!1),enabled:t}),x=w.useMemo(()=>f?f.filter(g=>{if(g.tag_uid||g.tray_uuid)return!1;if(!u)return!0;const y=u.toLowerCase();return g.material.toLowerCase().includes(y)||g.brand&&g.brand.toLowerCase().includes(y)||g.color_name&&g.color_name.toLowerCase().includes(y)}):[],[f,u]),v=st({mutationFn:g=>J.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"]}),d(l("inventory.tagLinked"),"success"),e()},onError:g=>{d(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(qb,{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(Rt,{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:u,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(at,{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(Me,{variant:"ghost",onClick:e,children:l("inventory.cancel")||"Cancel"})})]})]}):null}function o$e({isOpen:t,onClose:e,printerId:n,amsId:r,trayId:i,trayInfo:s}){const{t:o}=Dt(),l=Qt(),{showToast:c}=dn(),[d,u]=w.useState(null),[h,f]=w.useState(""),{data:p,isLoading:x}=Ze({queryKey:["inventory-spools"],queryFn:()=>J.getSpools(),enabled:t}),{data:v}=Ze({queryKey:["spool-assignments"],queryFn:()=>J.getAssignments(),enabled:t}),g=st({mutationFn:P=>J.assignSpool({spool_id:P,printer_id:n,ams_id:r,tray_id:i}),onSuccess:P=>{l.setQueryData(["spool-assignments"],C=>{const j=(C||[]).filter(M=>!(M.printer_id===n&&M.ams_id===r&&M.tray_id===i));return j.push(P),j}),l.invalidateQueries({queryKey:["spool-assignments"]}),c(o("inventory.assignSuccess"),"success"),e()},onError:P=>{c(`${o("inventory.assignFailed")}: ${P.message}`,"error")}});if(!t)return null;const y=new Set((v||[]).filter(P=>!(P.printer_id===n&&P.ams_id===r&&P.tray_id===i)).map(P=>P.spool_id)),_=r===254||r===255,N=p?.filter(P=>!y.has(P.id)&&(_||!P.tag_uid&&!P.tray_uuid)),A=N?.filter(P=>{if(!h)return!0;const C=h.toLowerCase();return P.material.toLowerCase().includes(C)||(P.brand?.toLowerCase().includes(C)??!1)||(P.color_name?.toLowerCase().includes(C)??!1)||(P.subtype?.toLowerCase().includes(C)??!1)}),k=()=>{d&&g.mutate(d)};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(fi,{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(Rt,{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:P=>f(P.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(at,{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(P=>a.jsx("button",{onClick:()=>u(P.id),className:`w-full p-3 rounded-lg border text-left transition-colors ${d===P.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:[P.rgba&&a.jsx("span",{className:"w-4 h-4 rounded-full border border-white/20 flex-shrink-0",style:{backgroundColor:`#${P.rgba.substring(0,6)}`}}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("p",{className:"text-white font-medium truncate",children:[P.brand?`${P.brand} `:"",P.material,P.subtype?` ${P.subtype}`:""]}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:[P.color_name||"",P.label_weight?` - ${P.label_weight}g`:"",P.label_weight?` (${Math.max(0,Math.round(P.label_weight-P.weight_used))}g ${o("ams.remainingUnit")})`:""]})]}),d===P.id&&a.jsx(na,{className:"w-4 h-4 text-bambu-green flex-shrink-0"})]})},P.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(Me,{variant:"secondary",onClick:e,children:o("common.cancel")}),a.jsx(Me,{onClick:k,disabled:!d||g.isPending,children:g.isPending?a.jsxs(a.Fragment,{children:[a.jsx(at,{className:"w-4 h-4 animate-spin"}),o("inventory.assigning")]}):a.jsxs(a.Fragment,{children:[a.jsx(fi,{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 Z7(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 v_(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 l$e=["PLA","PETG","PCTG","ABS","ASA","TPU","PC","PA","NYLON","PVA","HIPS","PP","PET"];function J7(t){const e=t.replace(/@.+$/,"").trim(),n=e.toUpperCase();for(const i of l$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 c$e(t){return!t.startsWith("GF")&&!t.startsWith("P1")}const d$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"},e9=[{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"}],t9=[{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 n9(t){const e=t.toLowerCase().trim();return d$e[e]||null}function u$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 wne({isOpen:t,onClose:e,printerId:n,slotInfo:r,nozzleDiameter:i="0.4",printerModel:s,onSuccess:o,fullScreen:l}){const{t:c}=Dt(),[d,u]=w.useState(""),[h,f]=w.useState(null),[p,x]=w.useState(""),[v,g]=w.useState(""),[y,_]=w.useState(""),[N,A]=w.useState(!1),[k,P]=w.useState(!1),{data:C,isLoading:j,isError:M}=Ze({queryKey:["cloudSettings"],queryFn:()=>J.getCloudSettings(),enabled:t,retry:!1}),{data:E,isLoading:B}=Ze({queryKey:["localPresets"],queryFn:()=>J.getLocalPresets(),enabled:t}),{data:L,isLoading:U}=Ze({queryKey:["builtinFilaments"],queryFn:()=>J.getBuiltinFilaments(),enabled:t,staleTime:1/0}),{data:D,isLoading:$}=Ze({queryKey:["kprofiles",n,i],queryFn:()=>J.getKProfiles(n,i),enabled:t&&!!n}),{data:q}=Ze({queryKey:["colorCatalog"],queryFn:()=>J.getColorCatalog(),enabled:t,staleTime:1/0}),z=st({mutationFn:async()=>{if(!d)throw new Error("No filament preset selected");const me=d.startsWith("local_"),se=d.startsWith("builtin_"),ce=me?parseInt(d.replace("local_",""),10):null,Ce=se?d.replace("builtin_",""):null,le=me?E?.filament.find(Ue=>Ue.id===ce):null,Le=se?L?.find(Ue=>Ue.filament_id===Ce):null,V=!me&&!se?C?.filament.find(Ue=>Ue.setting_id===d):null;if(!me&&!se&&!V)throw new Error("Selected preset not found");if(me&&!le)throw new Error("Selected local preset not found");if(se&&!Le)throw new Error("Selected builtin preset not found");const K=me?le.name:se?Le.name:V.name,fe=J7(K),Y=h?.slot_id??-1,re=p||r.trayColor?.slice(0,6)||"FFFFFF",ue=K.replace(/@.+$/,"").trim();let Fe,Pe;if(me){const Ue=(le?.filament_type||fe.material||"").toUpperCase(),ze={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"};Fe=ze[Ue]||ze[Ue.replace(/[-\s]?CF$/,"")]||ze[Ue.replace(/\+$/,"")]||ze[Ue.split(/[-\s]/)[0]]||"",Pe=""}else if(se)Fe=Ce,Pe="";else if(Fe=v_(d),Pe=d,!d.startsWith("GFS"))try{const Ue=await J.getCloudSettingDetail(d);Ue.filament_id?Fe=Ue.filament_id:Ue.base_id&&(Fe=v_(Ue.base_id),console.log(`Derived tray_info_idx from base_id: ${Ue.base_id} -> ${Fe}`))}catch(Ue){console.warn("Failed to fetch preset detail for filament_id:",Ue)}let be=me&&le?.nozzle_temp_min?le.nozzle_temp_min:190,O=me&&le?.nozzle_temp_max?le.nozzle_temp_max:230;if(!me||se||!le?.nozzle_temp_min&&!le?.nozzle_temp_max){const Ue=(me&&le?.filament_type||fe.material).toUpperCase();Ue.includes("PLA")?(be=190,O=230):Ue.includes("PETG")?(be=220,O=260):Ue.includes("ABS")||Ue.includes("ASA")?(be=240,O=280):Ue.includes("TPU")?(be=200,O=240):Ue==="PCTG"?(be=220,O=260):Ue.includes("PC")?(be=260,O=300):(Ue.includes("PA")||Ue.includes("NYLON"))&&(be=250,O=290)}const R=h?.k_value?parseFloat(h.k_value):0,G=me?le?.filament_type||fe.material||"PLA":fe.material||"PLA",de=await J.configureAmsSlot(n,r.amsId,r.trayId,{tray_info_idx:Fe,tray_type:G,tray_sub_brands:ue,tray_color:re+"FF",nozzle_temp_min:be,nozzle_temp_max:O,cali_idx:Y,nozzle_diameter:i,setting_id:Pe,kprofile_filament_id:h?.filament_id,kprofile_setting_id:h?.setting_id||void 0,k_value:R}),ge=me?`local_${ce}`:se?`builtin_${Ce}`:d,ae=me?"local":se?"builtin":"cloud";try{await J.saveSlotPreset(n,r.amsId,r.trayId,ge,ue,ae)}catch(Ue){console.warn("Failed to save slot preset mapping:",Ue)}return de},onSuccess:()=>{A(!0),o?.(),setTimeout(()=>{A(!1),e()},1500)}}),W=st({mutationFn:async()=>J.resetAmsSlot(n,r.amsId,r.trayId),onSuccess:()=>{A(!0),o?.(),setTimeout(()=>{A(!1),e()},1500)}}),Q=w.useMemo(()=>{const me=y.toLowerCase(),se=[],ce=new Set,Ce=r.savedPresetId,le=r.trayInfoIdx;if(C?.filament)for(const Le of C.filament){ce.add(Le.setting_id);const V=Ce===Le.setting_id||le&&(Le.setting_id===le||v_(Le.setting_id)===le);if(!(!V&&me&&!Le.name.toLowerCase().includes(me))){if(!V&&s){const K=u$e(Le.name);if(K&&K.toUpperCase()!==s.toUpperCase())continue}se.push({id:Le.setting_id,name:Le.name,source:"cloud",isUser:c$e(Le.setting_id)})}}if(E?.filament)for(const Le of E.filament){const V=`local_${Le.id}`,K=Ce===V;if(!(!K&&me&&!Le.name.toLowerCase().includes(me))){if(!K&&s&&Le.compatible_printers){const fe=Le.compatible_printers.split(";").map(Y=>{const re=Y.trim(),ue=re.match(/^BBL\s+(.+)/i);return ue?ue[1].trim().toUpperCase():re.toUpperCase()}).filter(Boolean);if(fe.length>0&&!fe.includes(s.toUpperCase()))continue}se.push({id:V,name:Le.name,source:"local",isUser:!1})}}if(L)for(const Le of L){if(ce.has(Le.filament_id))continue;const V=Le.filament_id.startsWith("GF")?"GFS"+Le.filament_id.slice(2):Le.filament_id;ce.has(V)||(!me||Le.name.toLowerCase().includes(me))&&se.push({id:`builtin_${Le.filament_id}`,name:Le.name,source:"builtin",isUser:!1})}return se.sort((Le,V)=>{const K={cloud:0,local:1,builtin:2};return Le.source!==V.source?K[Le.source]-K[V.source]:Le.isUser&&!V.isUser?-1:!Le.isUser&&V.isUser?1:Le.name.localeCompare(V.name)})},[C?.filament,E?.filament,L,y,s,r.savedPresetId,r.trayInfoIdx]),te=w.useMemo(()=>{if(!d)return null;let me=null;if(d.startsWith("local_")){const Ce=parseInt(d.replace("local_",""),10);me=E?.filament.find(Le=>Le.id===Ce)?.name||null}else if(d.startsWith("builtin_")){const Ce=d.replace("builtin_","");me=L?.find(Le=>Le.filament_id===Ce)?.name||null}else C?.filament&&(me=C.filament.find(le=>le.setting_id===d)?.name||null);if(!me)return null;let se=me.replace(/@.+$/,"").trim();se.startsWith("# ")&&(se=se.slice(2).trim());const ce=J7(se);return{fullName:se,material:ce.material,brand:ce.brand}},[d,C?.filament,E?.filament,L]),H=te?.fullName||"",X=w.useMemo(()=>{if(!q||!te)return[];const{fullName:me,brand:se}=te,ce=me.replace(/^(Bambu\s*(Lab)?|eSUN|Polymaker|Overture|Sunlu|Hatchbox)\s*/i,"").trim();return q.filter(Ce=>{const le=(Ce.material||"").toUpperCase(),Le=Ce.manufacturer.toUpperCase();if(!(le===ce.toUpperCase()||le.includes(ce.toUpperCase())||ce.toUpperCase().includes(le)))return!1;if(se){const K=se.toUpperCase();if(!Le.includes(K)&&!K.includes(Le))return!1}return!0})},[q,te]),Z=w.useMemo(()=>{if(!D?.profiles||!te)return[];const{fullName:me,material:se,brand:ce}=te,Ce=me.toUpperCase(),le=se.toUpperCase(),Le=ce.toUpperCase();if(!le||le.length<2)return[];const V=D.profiles.filter(fe=>{const Y=fe.name.toUpperCase();if(Le)return!(!Y.includes(Le)||!Y.includes(le));if(Y.includes(Ce)||Y.includes(le))return!0;const ue={NYLON:["PA","PA-CF","PA6"],PA:["NYLON"]}[le]||[];for(const Fe of ue)if(Y.includes(Fe))return!0;return!1}),K=new Map;for(const fe of V){const Y=`${fe.name}|${fe.k_value}`,re=K.get(Y);re?r.extruderId!==void 0&&fe.extruder_id===r.extruderId&&re.extruder_id!==r.extruderId&&K.set(Y,fe):K.set(Y,fe)}return Array.from(K.values())},[D?.profiles,te,r.extruderId]);w.useEffect(()=>{if(t){if(r.savedPresetId)u(r.savedPresetId);else if(r.trayInfoIdx&&C?.filament){let me=C.filament.find(se=>se.setting_id===r.trayInfoIdx);me||(me=C.filament.find(se=>v_(se.setting_id)===r.trayInfoIdx)),me&&u(me.setting_id)}if(r.trayColor){const me=r.trayColor.slice(0,6);me&&x(me)}}else u(""),f(null),x(""),g(""),_(""),A(!1)},[t,r.savedPresetId,r.trayInfoIdx,r.trayColor,C?.filament]),w.useEffect(()=>{if(Z.length>0){if(r.caliIdx!=null&&r.caliIdx>0){const me=Z.find(se=>se.slot_id===r.caliIdx);if(me){f(me);return}}f(Z[0])}else f(null)},[d,Z,r.caliIdx]);const ee=w.useCallback(me=>{me.key==="Escape"&&e()},[e]);if(w.useEffect(()=>{if(t)return document.addEventListener("keydown",ee),()=>document.removeEventListener("keydown",ee)},[t,ee]),!t)return null;const Se=j&&!M||B||U||$,oe=d&&!z.isPending,ie=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(tu,{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:Z7(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(Rt,{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(ub,{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:Z7(r.amsId,r.trayCount),slot:r.trayId+1})}),r.traySubBrands&&a.jsxs("span",{className:"text-bambu-gray",children:["(",r.traySubBrands,")"]})]})]}),Se?a.jsx("div",{className:"flex justify-center py-8",children:a.jsx(at,{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:me=>_(me.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:Q.length===0?a.jsx("p",{className:"text-center py-4 text-bambu-gray",children:C?.filament?.length===0&&!E?.filament?.length?c("configureAmsSlot.noPresetsAvailable"):c("configureAmsSlot.noMatchingPresets")}):Q.map(me=>a.jsx("button",{ref:d===me.id?se=>{se?.scrollIntoView({block:"nearest"})}:void 0,onClick:()=>u(me.id),className:`w-full p-2 rounded-lg border text-left transition-colors ${d===me.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:me.name}),a.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[me.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")}),me.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")}),me.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")})]})]})},me.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"),H&&a.jsx("span",{className:"ml-2 text-xs text-bambu-blue",children:c("configureAmsSlot.filteringFor",{material:H})})]}),Z.length>0?a.jsxs("div",{className:"relative",children:[a.jsxs("select",{value:h?.name||"",onChange:me=>{const se=Z.find(ce=>ce.name===me.target.value);f(se||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")}),Z.map(me=>a.jsxs("option",{value:me.name,children:[me.name," (K=",me.k_value,")"]},`${me.name}-${me.extruder_id}`))]}),a.jsx(Mn,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}):d?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")}),X.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:te?.fullName})}),a.jsx("div",{className:"flex flex-wrap gap-1.5",children:X.map(me=>a.jsxs("button",{onClick:()=>{const se=me.hex_color.replace("#","").toUpperCase();x(se),g(me.color_name)},className:`h-7 px-2 rounded-md border-2 transition-all flex items-center gap-1.5 ${p===me.hex_color.replace("#","").toUpperCase()?"border-bambu-green scale-105":"border-white/20 hover:border-white/40"}`,title:me.color_name,children:[a.jsx("span",{className:"w-4 h-4 rounded-full border border-white/30 flex-shrink-0",style:{backgroundColor:me.hex_color}}),a.jsx("span",{className:"text-xs text-white/80 whitespace-nowrap",children:me.color_name})]},me.id))})]}),a.jsxs("div",{className:"flex flex-wrap gap-1.5 mb-2",children:[e9.map(me=>a.jsx("button",{onClick:()=>{x(me.hex),g(me.name)},className:`w-7 h-7 rounded-md border-2 transition-all ${p===me.hex?"border-bambu-green scale-110":"border-white/20 hover:border-white/40"}`,style:{backgroundColor:`#${me.hex}`},title:me.name},me.hex)),a.jsx("button",{onClick:()=>P(!k),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(k?"configureAmsSlot.showLessColors":"configureAmsSlot.showMoreColors"),children:k?"−":"+"})]}),k&&a.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:t9.map(me=>a.jsx("button",{onClick:()=>{x(me.hex),g(me.name)},className:`w-7 h-7 rounded-md border-2 transition-all ${p===me.hex?"border-bambu-green scale-110":"border-white/20 hover:border-white/40"}`,style:{backgroundColor:`#${me.hex}`},title:me.name},me.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:`#${ie}`}}),a.jsx("input",{type:"text",placeholder:c("configureAmsSlot.colorPlaceholder"),value:v,onChange:me=>{const se=me.target.value;g(se);const ce=n9(se);if(ce)x(ce);else{const Ce=se.replace(/[^0-9A-Fa-f]/g,"").toUpperCase();Ce.length===6?x(Ce):Ce.length===3&&x(Ce.split("").map(le=>le+le).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:me=>_(me.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:Q.length===0?a.jsx("p",{className:"text-center py-4 text-bambu-gray",children:C?.filament?.length===0&&!E?.filament?.length?c("configureAmsSlot.noPresetsAvailable"):c("configureAmsSlot.noMatchingPresets")}):Q.map(me=>a.jsx("button",{ref:d===me.id?se=>{se?.scrollIntoView({block:"nearest"})}:void 0,onClick:()=>u(me.id),className:`w-full p-2 rounded-lg border text-left transition-colors ${d===me.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:me.name}),a.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[me.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")}),me.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")}),me.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")})]})]})},me.id))})]})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-2",children:[c("configureAmsSlot.kProfileLabel"),H&&a.jsx("span",{className:"ml-2 text-xs text-bambu-blue",children:c("configureAmsSlot.filteringFor",{material:H})})]}),Z.length>0?a.jsxs("div",{className:"relative",children:[a.jsxs("select",{value:h?.name||"",onChange:me=>{const se=Z.find(ce=>ce.name===me.target.value);f(se||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")}),Z.map(me=>a.jsxs("option",{value:me.name,children:[me.name," (K=",me.k_value,")"]},`${me.name}-${me.extruder_id}`))]}),a.jsx(Mn,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}):d?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")}),X.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:te?.fullName})}),a.jsx("div",{className:"flex flex-wrap gap-1.5",children:X.map(me=>a.jsxs("button",{onClick:()=>{const se=me.hex_color.replace("#","").toUpperCase();x(se),g(me.color_name)},className:`h-7 px-2 rounded-md border-2 transition-all flex items-center gap-1.5 ${p===me.hex_color.replace("#","").toUpperCase()?"border-bambu-green scale-105":"border-white/20 hover:border-white/40"}`,title:me.color_name,children:[a.jsx("span",{className:"w-4 h-4 rounded-full border border-white/30 flex-shrink-0",style:{backgroundColor:me.hex_color}}),a.jsx("span",{className:"text-xs text-white/80 whitespace-nowrap",children:me.color_name})]},me.id))})]}),a.jsxs("div",{className:"flex flex-wrap gap-1.5 mb-2",children:[e9.map(me=>a.jsx("button",{onClick:()=>{x(me.hex),g(me.name)},className:`w-7 h-7 rounded-md border-2 transition-all ${p===me.hex?"border-bambu-green scale-110":"border-white/20 hover:border-white/40"}`,style:{backgroundColor:`#${me.hex}`},title:me.name},me.hex)),a.jsx("button",{onClick:()=>P(!k),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(k?"configureAmsSlot.showLessColors":"configureAmsSlot.showMoreColors"),children:k?"−":"+"})]}),k&&a.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:t9.map(me=>a.jsx("button",{onClick:()=>{x(me.hex),g(me.name)},className:`w-7 h-7 rounded-md border-2 transition-all ${p===me.hex?"border-bambu-green scale-110":"border-white/20 hover:border-white/40"}`,style:{backgroundColor:`#${me.hex}`},title:me.name},me.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:`#${ie}`}}),a.jsx("input",{type:"text",placeholder:c("configureAmsSlot.colorPlaceholder"),value:v,onChange:me=>{const se=me.target.value;g(se);const ce=n9(se);if(ce)x(ce);else{const Ce=se.replace(/[^0-9A-Fa-f]/g,"").toUpperCase();Ce.length===6?x(Ce):Ce.length===3&&x(Ce.split("").map(le=>le+le).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(Me,{variant:"secondary",onClick:()=>W.mutate(),disabled:W.isPending||z.isPending,className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:W.isPending?a.jsxs(a.Fragment,{children:[a.jsx(at,{className:"w-4 h-4 animate-spin"}),c("configureAmsSlot.resetting")]}):a.jsxs(a.Fragment,{children:[a.jsx(lo,{className:"w-4 h-4"}),c("configureAmsSlot.resetSlot")]})}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Me,{variant:"secondary",onClick:e,children:c("configureAmsSlot.cancel")}),a.jsx(Me,{onClick:()=>z.mutate(),disabled:!oe,children:z.isPending?a.jsxs(a.Fragment,{children:[a.jsx(at,{className:"w-4 h-4 animate-spin"}),c("configureAmsSlot.configuring")]}):a.jsxs(a.Fragment,{children:[a.jsx(tu,{className:"w-4 h-4"}),c("configureAmsSlot.configureSlot")]})})]})]}),(z.isError||W.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:z.error?.message||W.error?.message})]})]})}function r9(t){return t?`#${t.replace("#","").substring(0,6)}`:"#808080"}function Fa(t){return t?t.replace("#","").toLowerCase().substring(0,6):""}function Lc(t,e,n=40){const r=Fa(t),i=Fa(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),d=parseInt(i.substring(2,4),16),u=parseInt(i.substring(4,6),16);return Math.abs(s-c)<=n&&Math.abs(o-d)<=n&&Math.abs(l-u)<=n}function pO(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 BN(t,e,n){return n?254+e:t>=128?t:t*4+e}function a9(t){if(!t)return!1;const e=Date.now()+4320*60*60*1e3;return(tr(t)?.getTime()??0)>e}const i9={"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"},h$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 $E(t){if(!t)return null;if(i9[t])return i9[t];const e=t.split("-");if(e.length<2)return null;const n=e[1];return h$e[n]||null}function VE(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 d=i-s;c=o>.5?d/(2-i-s):d/(i+s);const u=e/255,h=n/255,f=r/255;i===u?l=((h-f)/d+(h<f?6:0))/6:i===h?l=((f-u)/d+2)/6:l=((u-h)/d+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 qE(t){return(t??.02).toFixed(3)}function s9({side:t}){const{mode:e}=ep(),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 gO(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 m$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 Sne(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 _ne(t,e){return t?t.startsWith("HH")?e("printers.nozzleHighFlow"):t.startsWith("HS")?e("printers.nozzleStandardFlow"):"":""}function Nne({slot:t,index:e,activeStatus:n,filamentName:r,children:i}){const{t:s}=Dt(),[o,l]=w.useState(!1),[c,d]=w.useState("top"),u=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&&u.current&&h.current){const A=u.current.getBoundingClientRect(),k=h.current.offsetHeight,C=A.top-56,j=window.innerHeight-A.bottom;C<k+12&&j>C?d("bottom"):d("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=gO(t.filament_color),_=Sne(t.nozzle_type,s),N=_ne(t.nozzle_type,s);return a.jsxs("div",{ref:u,className:"relative",onMouseEnter:v,onMouseLeave:g,children:[i,o&&a.jsxs("div",{ref:h,className:`
- absolute left-1/2 -translate-x-1/2 z-50
- ${c==="top"?"bottom-full mb-2":"top-full mt-2"}
- animate-in fade-in-0 zoom-in-95 duration-150
- `,style:{maxWidth:"calc(100vw - 24px)"},children:[a.jsx("div",{className:"w-44 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl overflow-hidden backdrop-blur-sm",children: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:`
- absolute left-1/2 -translate-x-1/2 w-0 h-0
- border-l-[6px] border-l-transparent
- border-r-[6px] border-r-transparent
- ${c==="top"?"top-full border-t-[6px] border-t-bambu-dark-tertiary":"bottom-full border-b-[6px] border-b-bambu-dark-tertiary"}
- `})]})]})}function f$e({leftSlot:t,rightSlot:e,activeNozzle:n,filamentInfo:r,children:i}){const{t:s}=Dt(),[o,l]=w.useState(!1),[c,d]=w.useState("top"),u=w.useRef(null),h=w.useRef(null),f=w.useRef(null);w.useEffect(()=>{if(o&&u.current&&h.current){const g=u.current.getBoundingClientRect(),y=h.current.offsetHeight,N=g.top-56,A=window.innerHeight-g.bottom;N<y+12&&A>N?d("bottom"):d("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=Sne(g.nozzle_type,s),A=_ne(g.nozzle_type,s),k=gO(g.filament_color),P=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})]}),(k||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:[k&&a.jsx("div",{className:"w-3 h-3 rounded-sm border border-white/20",style:{backgroundColor:k}}),a.jsx("span",{className:"text-[10px] text-white font-semibold truncate max-w-[100px]",children:P||g.filament_type||g.filament_id||""})]})]})]})};return a.jsxs("div",{ref:u,className:"relative flex-1",onMouseEnter:p,onMouseLeave:x,children:[i,o&&a.jsxs("div",{ref:h,className:`
- absolute left-1/2 -translate-x-1/2 z-50
- ${c==="top"?"bottom-full mb-2":"top-full mt-2"}
- animate-in fade-in-0 zoom-in-95 duration-150
- `,style:{maxWidth:"calc(100vw - 24px)"},children:[a.jsx("div",{className:"w-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:`
- absolute left-1/2 -translate-x-1/2 w-0 h-0
- border-l-[6px] border-l-transparent
- border-r-[6px] border-r-transparent
- ${c==="top"?"top-full border-t-[6px] border-t-bambu-dark-tertiary":"bottom-full border-b-[6px] border-b-bambu-dark-tertiary"}
- `})]})]})}function p$e({slots:t,filamentInfo:e}){const{t:n}=Dt(),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(d=>d.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 d=!l.nozzle_diameter&&!l.nozzle_type,u=d?null:gO(l.filament_color),h=u?m$e(l.filament_color):!1;return a.jsx(Nne,{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 ${d?"bg-bambu-dark-tertiary/20 border-bambu-dark-tertiary/20":"bg-bambu-dark-tertiary/40 border-bambu-dark-tertiary/40"}`,style:u?{backgroundColor:u}:void 0,children:a.jsx("span",{className:`text-[10px] font-semibold ${d?"text-bambu-gray/30":h?"text-black/80":"text-white"}`,style:u&&!h?{textShadow:"0 1px 3px rgba(0,0,0,0.9)"}:void 0,children:d?"—":l.nozzle_diameter||"?"})})},l.id>=0?l.id:`empty-${c}`)})})]})}function o9({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 g$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 b$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 x$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 y$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 v$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 GE({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 l9({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,d;isNaN(s)?(c="#C3C2C1",d="Unknown"):s<=o?(c="#22a352",d="Good"):s<=l?(c="#d4a017",d="Fair"):(c="#c62828",d="Bad");let u;return isNaN(s)||s<=o?u=o9:s<=l?u=g$e:u=b$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}% - ${d}${r?" (click for history)":""}`,children:[a.jsx(u,{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 c9({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,d;return t<=s?(l="#22a352",c="Good",d=x$e):t<=o?(l="#d4a017",c="Fair",d=y$e):(l="#c62828",c="Bad",d=v$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(d,{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 nh(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 WE(t){return t>50?"#00ae42":t>=15?"#f59e0b":"#ef4444"}function KE(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 w$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 S$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 XE(t){return t?!!(t.tray_uuid&&t.tray_uuid!=="00000000000000000000000000000000"||t.tag_uid&&t.tag_uid!=="0000000000000000"):!1}function _$e({url:t,printName:e}){const{t:n}=Dt(),[r,i]=w.useState(!1),[s,o]=w.useState(!1),[l,c]=w.useState(!1),d=w.useMemo(()=>{if(!t)return null;const u=t.includes("?")?"&":"?";return`${t}${u}v=${encodeURIComponent(e||Date.now().toString())}`},[t,e]);return w.useEffect(()=>{i(!1),o(!1)},[d]),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 ${d&&r?"cursor-pointer":""}`,onClick:()=>d&&r&&c(!0),children:d&&!s?a.jsxs(a.Fragment,{children:[a.jsx("img",{src:d,alt:n("printers.printPreview"),className:`w-full h-full object-cover ${r?"block":"hidden"}`,onLoad:()=>i(!0),onError:()=>o(!0)}),!r&&a.jsx(ei,{className:"w-8 h-8 text-bambu-gray"})]}):a.jsx(ei,{className:"w-8 h-8 text-bambu-gray"})}),l&&d&&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:d,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 N$e({printers:t}){const{t:e}=Dt(),n=Qt(),[r,i]=w.useState(0);w.useEffect(()=>{let l=!1;const c=n.getQueryCache().subscribe(()=>{l||(l=!0,requestAnimationFrame(()=>{i(d=>d+1),l=!1}))});return()=>c()},[n]);const{counts:s,nextFinish:o}=w.useMemo(()=>{let l=0,c=0,d=0,u=0,h=null,f=null,p=0;return t?.forEach(x=>{const v=n.getQueryData(["printerStatus",x.id]);v===void 0?u++: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++:d++}),{counts:{printing:l,idle:c,offline:d,loading:u,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 d9(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 vR(t){return t?{O1D:"H2D",O1E:"H2D Pro",O2D:"H2D Pro",O1C:"H2C",O1S:"H2S","BL-P001":"X1C","BL-P002":"X1","BL-P003":"X1E",C11:"P1S",C12:"P1P",C13:"P2S",N2S:"A1",N1:"A1 Mini",X1C:"X1C",X1:"X1",X1E:"X1E",P1S:"P1S",P1P:"P1P",P2S:"P2S",A1:"A1","A1 Mini":"A1 Mini",H2D:"H2D","H2D Pro":"H2D Pro",H2C:"H2C",H2S:"H2S"}[t]||t:""}function u9({printer:t,hideIfDisconnected:e,maintenanceInfo:n,viewMode:r="expanded",cardSize:i=2,amsThresholds:s,spoolmanEnabled:o=!1,hasUnlinkedSpools:l=!1,linkedSpools:c,spoolmanUrl:d,onGetAssignment:u,onUnassignSpool:h,timeFormat:f="system",cameraViewMode:p="window",onOpenEmbeddedCamera:x,checkPrinterFirmware:v=!0}){const{t:g}=Dt(),y=Qt(),_=ac(),{showToast:N}=dn(),{hasPermission:A}=jr(),[k,P]=w.useState(!1),[C,j]=w.useState(!1),[M,E]=w.useState(!0),[B,L]=w.useState(!1),[U,D]=w.useState(!1),[$,q]=w.useState(!1),[z,W]=w.useState(!1),[Q,te]=w.useState(!1),[H,X]=w.useState(!1),[Z,ee]=w.useState(!1),[Se,oe]=w.useState(!1),[ie,me]=w.useState(!1),[se,ce]=w.useState(!1),[Ce,le]=w.useState(null),[Le,V]=w.useState(null),[K,fe]=w.useState(null),[Y,re]=w.useState(null),[ue,Fe]=w.useState(!1),[Pe,be]=w.useState(null),[O,R]=w.useState(!1),[G,de]=w.useState(!1),[ge,ae]=w.useState(null),[Ue,ze]=w.useState(!1),[$e,Re]=w.useState(!1),{data:pe}=Ze({queryKey:["printerStatus",t.id],queryFn:()=>J.getPrinterStatus(t.id),refetchInterval:3e4}),{data:ve}=Ze({queryKey:["firmwareUpdate",t.id],queryFn:()=>B_.checkPrinterUpdate(t.id),staleTime:300*1e3,refetchInterval:300*1e3,enabled:v&&A("firmware:read")}),Ne=w.useMemo(()=>{const bt=new Set;if(pe?.ams)for(const Ot of pe.ams)for(const vn of Ot.tray||[])vn.tray_info_idx&&bt.add(vn.tray_info_idx);for(const Ot of pe?.vt_tray??[])Ot.tray_info_idx&&bt.add(Ot.tray_info_idx);if(pe?.nozzle_rack)for(const Ot of pe.nozzle_rack)Ot.filament_id&&bt.add(Ot.filament_id);return Array.from(bt)},[pe?.ams,pe?.vt_tray,pe?.nozzle_rack]),xe=w.useMemo(()=>{const bt=new Set;if(pe?.ams)for(const Ot of pe.ams)for(const vn of Ot.tray||[])vn.tray_type&&bt.add(vn.tray_type.toUpperCase());for(const Ot of pe?.vt_tray??[])Ot.tray_type&&bt.add(Ot.tray_type.toUpperCase());return bt},[pe?.ams,pe?.vt_tray]),we=w.useMemo(()=>{const bt=new Set;if(pe?.ams){for(const Ot of pe.ams)for(const vn of Ot.tray||[])if(vn.tray_type&&vn.tray_color){const vt=vn.tray_color.replace("#","").toLowerCase().slice(0,6);bt.add(`${vn.tray_type.toUpperCase()}:${vt}`)}}for(const Ot of pe?.vt_tray??[])if(Ot.tray_type&&Ot.tray_color){const vn=Ot.tray_color.replace("#","").toLowerCase().slice(0,6);bt.add(`${Ot.tray_type.toUpperCase()}:${vn}`)}return bt},[pe?.ams,pe?.vt_tray]),{data:qe}=Ze({queryKey:["filamentInfo",Ne],queryFn:()=>J.getFilamentInfo(Ne),enabled:Ne.length>0,staleTime:300*1e3}),{data:ke}=Ze({queryKey:["slotPresets",t.id],queryFn:()=>J.getSlotPresets(t.id),staleTime:120*1e3}),[nt,De]=w.useState(null);w.useEffect(()=>{pe?.wifi_signal!=null&&De(pe.wifi_signal)},[pe?.wifi_signal]);const We=pe?.wifi_signal??nt,Oe=w.useRef(void 0);w.useEffect(()=>{pe?.connected!==void 0&&(Oe.current=pe.connected)},[pe?.connected]);const je=pe?.connected??Oe.current,Ve=w.useRef({});w.useEffect(()=>{pe?.ams_extruder_map&&Object.keys(pe.ams_extruder_map).length>0&&(Ve.current=pe.ams_extruder_map)},[pe?.ams_extruder_map]);const ot=pe?.ams_extruder_map&&Object.keys(pe.ams_extruder_map).length>0?pe.ams_extruder_map:Ve.current,kt=w.useRef([]);w.useEffect(()=>{pe?.ams&&pe.ams.length>0&&(kt.current=pe.ams)},[pe?.ams]);const Ft=pe?.ams&&pe.ams.length>0?pe.ams:kt.current,Vt=w.useRef(void 0),At=pe?.tray_now;At!==void 0&&At!==255?Vt.current=At:At===255&&(Vt.current=void 0);const Be=At!==void 0&&At!==255?At:Vt.current,{data:mt}=Ze({queryKey:["smartPlugByPrinter",t.id],queryFn:()=>J.getSmartPlugByPrinter(t.id)}),{data:yt}=Ze({queryKey:["scriptPlugsByPrinter",t.id],queryFn:()=>J.getScriptPlugsByPrinter(t.id)}),{data:zt}=Ze({queryKey:["smartPlugStatus",mt?.id],queryFn:()=>mt?J.getSmartPlugStatus(mt.id):null,enabled:!!mt,refetchInterval:1e4}),{data:yn}=Ze({queryKey:["queue",t.id,"pending"],queryFn:()=>J.getQueue(t.id,"pending")}),gr=w.useMemo(()=>yn?.length?yn.filter(bt=>!(bt.required_filament_types?.length&&xe?.size&&!bt.required_filament_types.every(Ot=>xe.has(Ot.toUpperCase()))||bt.filament_overrides?.length&&we?.size&&!bt.filament_overrides.some(vn=>{const vt=(vn.type||"").toUpperCase(),Un=(vn.color||"").replace("#","").toLowerCase().slice(0,6);return we.has(`${vt}:${Un}`)}))).length:0,[yn,xe,we]),{data:sr}=Ze({queryKey:["queue",t.id,"printing"],queryFn:()=>J.getQueue(t.id,"printing"),enabled:pe?.state==="RUNNING"}),{data:nr}=Ze({queryKey:["currentPrintUser",t.id],queryFn:()=>J.getCurrentPrintUser(t.id),enabled:pe?.state==="RUNNING"}),Gn=sr?.[0]?.created_by_username||nr?.username,{data:br}=Ze({queryKey:["archives",t.id,"last"],queryFn:()=>J.getArchives(t.id,1,0),enabled:pe?.connected&&pe?.state!=="RUNNING"}),or=br?.[0],oi=e&&je===!1,Ie=st({mutationFn:bt=>J.deletePrinter(t.id,bt.deleteArchives),onSuccess:()=>{y.invalidateQueries({queryKey:["printers"]}),y.invalidateQueries({queryKey:["archives"]}),y.invalidateQueries({queryKey:["maintenanceOverview"]})},onError:bt=>N(bt.message||g("printers.toast.failedToDelete"),"error")}),_e=st({mutationFn:()=>J.connectPrinter(t.id),onSuccess:()=>{y.invalidateQueries({queryKey:["printerStatus",t.id]})}}),tt=st({mutationFn:bt=>mt?J.controlSmartPlug(mt.id,bt):Promise.reject("No plug"),onSuccess:()=>{y.invalidateQueries({queryKey:["smartPlugStatus",mt?.id]})}}),it=st({mutationFn:bt=>mt?J.updateSmartPlug(mt.id,{auto_off:bt}):Promise.reject("No plug"),onSuccess:()=>{y.invalidateQueries({queryKey:["smartPlugByPrinter",t.id]}),y.invalidateQueries({queryKey:["smart-plugs"]})}}),Ke=st({mutationFn:bt=>J.controlSmartPlug(bt,"on"),onSuccess:()=>{N(g("printers.toast.scriptTriggered"))},onError:bt=>N(bt.message||g("printers.toast.failedToRunScript"),"error")}),Lt=st({mutationFn:()=>J.stopPrint(t.id),onSuccess:()=>{N(g("printers.toast.printStopped")),y.invalidateQueries({queryKey:["printerStatus",t.id]})},onError:bt=>N(bt.message||g("printers.toast.failedToStopPrint"),"error")}),ye=st({mutationFn:()=>J.pausePrint(t.id),onSuccess:()=>{N(g("printers.toast.printPaused")),y.invalidateQueries({queryKey:["printerStatus",t.id]})},onError:bt=>N(bt.message||g("printers.toast.failedToPausePrint"),"error")}),He=st({mutationFn:()=>J.resumePrint(t.id),onSuccess:()=>{N(g("printers.toast.printResumed")),y.invalidateQueries({queryKey:["printerStatus",t.id]})},onError:bt=>N(bt.message||g("printers.toast.failedToResumePrint"),"error")}),Ye=st({mutationFn:bt=>J.setChamberLight(t.id,bt),onMutate:async bt=>{await y.cancelQueries({queryKey:["printerStatus",t.id]});const Ot=y.getQueryData(["printerStatus",t.id]);return y.setQueryData(["printerStatus",t.id],vn=>({...vn,chamber_light:bt})),{previousStatus:Ot}},onSuccess:(bt,Ot)=>{N(`Chamber light ${Ot?"on":"off"}`)},onError:(bt,Ot,vn)=>{vn?.previousStatus&&y.setQueryData(["printerStatus",t.id],vn.previousStatus),N(bt.message||g("printers.toast.failedToControlChamberLight"),"error")}}),Xe=st({mutationFn:bt=>J.updatePrinter(t.id,{plate_detection_enabled:bt}),onSuccess:()=>{y.invalidateQueries({queryKey:["printers"]}),N(Xe.variables?g("printers.toast.plateCheckEnabled"):g("printers.toast.plateCheckDisabled"))},onError:bt=>N(bt.message||g("printers.toast.failedToUpdateSetting"),"error")}),Te=(pe?.state==="RUNNING"||pe?.state==="PAUSE")&&(pe?.printable_objects_count??0)>=2,{data:ct}=Ze({queryKey:["printableObjects",t.id],queryFn:()=>J.getPrintableObjects(t.id),enabled:se||Te,refetchInterval:se?5e3:Te?3e4:!1}),[gt,lt]=w.useState(null),Tt=w.useRef(!1),Bt=w.useRef(null),It=w.useRef(!1),Pt=st({mutationFn:({amsId:bt,slotId:Ot})=>J.refreshAmsSlot(t.id,bt,Ot),onMutate:({amsId:bt,slotId:Ot})=>{Bt.current&&clearTimeout(Bt.current),Tt.current=!1,It.current=!1,lt({amsId:bt,slotId:Ot}),setTimeout(()=>{It.current=!0},2e3),Bt.current=setTimeout(()=>{lt(null)},3e4)},onSuccess:bt=>{N(bt.message||g("printers.toast.rfidRereadInitiated"))},onError:bt=>{N(bt.message||g("printers.toast.failedToRereadRfid"),"error"),Bt.current&&clearTimeout(Bt.current),lt(null)}}),[tn,en]=w.useState(null),[on,gn]=w.useState(null),Tn=async()=>{try{const bt=await J.getPlateReferences(t.id);en(bt)}catch{}},Zt=()=>{Xe.mutate(!t.plate_detection_enabled)},fn=async()=>{R(!0),be(null);const bt=pe?.chamber_light===!1;Re(bt),bt&&(await J.setChamberLight(t.id,!0),await new Promise(Ot=>setTimeout(Ot,2500)));try{const Ot=await J.checkPlateEmpty(t.id,{includeDebugImage:!0});be(Ot),Tn()}catch(Ot){N(Ot instanceof Error?Ot.message:g("printers.toast.failedToCheckPlate"),"error"),bt&&(await J.setChamberLight(t.id,!1),Re(!1))}finally{R(!1)}},un=w.useCallback(async()=>{be(null),$e&&(await J.setChamberLight(t.id,!1),Re(!1))},[$e,t.id]),qr=async bt=>{de(!0);try{const Ot=await J.calibratePlateDetection(t.id,{label:bt});if(Ot.success){N(Ot.message||g("printers.toast.calibrationSaved"),"success"),Tn();const vn=await J.checkPlateEmpty(t.id,{includeDebugImage:!0});be(vn)}else N(Ot.message||g("printers.toast.calibrationFailed"),"error")}catch(Ot){N(Ot instanceof Error?Ot.message:g("printers.toast.calibrationFailed"),"error")}finally{de(!1)}},pn=async(bt,Ot)=>{try{await J.updatePlateReferenceLabel(t.id,bt,Ot),gn(null),Tn()}catch(vn){N(vn instanceof Error?vn.message:g("printers.toast.failedToUpdateLabel"),"error")}},lr=async bt=>{try{await J.deletePlateReference(t.id,bt),N(g("printers.toast.referenceDeleted"),"success"),Tn();const Ot=await J.checkPlateEmpty(t.id,{includeDebugImage:!0});be(Ot)}catch(Ot){N(Ot instanceof Error?Ot.message:g("printers.toast.failedToDeleteReference"),"error")}},as=async()=>{if(ge){ze(!0);try{await J.updatePrinter(t.id,{plate_detection_roi:ge}),N(g("printers.toast.detectionAreaSaved"),"success"),ae(null);const bt=await J.checkPlateEmpty(t.id,{includeDebugImage:!0});be(bt)}catch(bt){N(bt instanceof Error?bt.message:g("printers.toast.failedToSaveDetectionArea"),"error")}finally{ze(!1)}}};w.useEffect(()=>{const bt=Ot=>{Ot.key==="Escape"&&Pe&&un()};return window.addEventListener("keydown",bt),()=>window.removeEventListener("keydown",bt)},[Pe,un]);const bn=w.useRef(null);w.useEffect(()=>{if(!gt)return;const bt=pe?.ams_status_main??0;return bt!==0&&(Tt.current=!0,bn.current&&(clearTimeout(bn.current),bn.current=null)),Tt.current&&bt===0&&(It.current?(Bt.current&&clearTimeout(Bt.current),lt(null)):bn.current||(bn.current=setTimeout(()=>{Bt.current&&clearTimeout(Bt.current),lt(null)},2e3))),()=>{bn.current&&clearTimeout(bn.current)}},[pe?.ams_status_main,gt]);const[vr,Qn]=w.useState(null);if(oi)return null;const xa=()=>{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"}},Ua=()=>{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"}},aa=()=>{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(St,{className:"relative",children:[a.jsxs(Nt,{className:i>=3?"p-5":"",children:[a.jsxs("div",{className:aa(),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:w$e(t.model),alt:t.model||g("common.printer"),className:`object-contain rounded-lg bg-bambu-dark flex-shrink-0 ${xa()}`}),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 ${Ua()}`,children:t.name}),r==="compact"&&a.jsx("div",{className:`w-2 h-2 rounded-full flex-shrink-0 ${pe?.connected?"bg-status-ok":"bg-status-error"}`,title:pe?.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"&&pe?.nozzles&&pe.nozzles[0]?.nozzle_diameter&&a.jsxs("span",{className:"ml-1.5 text-bambu-gray",title:pe.nozzles[0].nozzle_type||"Nozzle",children:["• ",pe.nozzles[0].nozzle_diameter,"mm"]}),r==="expanded"&&n&&n.total_print_hours>0&&a.jsxs("span",{className:"ml-2 text-bambu-gray",children:[a.jsx(qn,{className:"w-3 h-3 inline-block mr-1"}),Math.round(n.total_print_hours),"h"]})]})]})]}),a.jsxs("div",{className:"relative flex-shrink-0",children:[a.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>P(!k),children:a.jsx(Mh,{className:"w-4 h-4"})}),k&&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")&&(L(!0),P(!1))},title:A("printers:update")?void 0:g("printers.permission.noEdit"),children:[a.jsx(Ga,{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:()=>{_e.mutate(),P(!1)},children:[a.jsx(Sr,{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:()=>{q(!0),P(!1)},children:[a.jsx(PX,{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")&&(j(!0),P(!1))},title:A("printers:delete")?void 0:g("printers.permission.noDelete"),children:[a.jsx(Yt,{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 ${pe?.connected?"bg-status-ok/20 text-status-ok":"bg-status-error/20 text-status-error"}`,children:[pe?.connected?a.jsx(qb,{className:"w-3 h-3"}):a.jsx(ek,{className:"w-3 h-3"}),pe?.connected?g("printers.connection.connected"):g("printers.connection.offline")]}),pe?.connected&&We!=null&&a.jsxs("span",{className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs ${We>=-50||We>=-60?"bg-status-ok/20 text-status-ok":We>=-70?"bg-status-warning/20 text-status-warning":We>=-80?"bg-orange-500/20 text-orange-600":"bg-status-error/20 text-status-error"}`,title:`WiFi: ${We} dBm - ${g(S$e(We).labelKey)}`,children:[a.jsx(Cpe,{className:"w-3 h-3"}),We,"dBm"]}),pe?.connected&&(()=>{const bt=pe.hms_errors?qTe(pe.hms_errors):[];return a.jsxs("button",{onClick:()=>X(!0),className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs cursor-pointer hover:opacity-80 transition-opacity ${bt.length>0?bt.some(Ot=>Ot.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(An,{className:"w-3 h-3"}),bt.length>0?bt.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(jf,{className:"w-3 h-3"}),n.due_count>0||n.warning_count>0?n.due_count+n.warning_count:"OK"]}),gr>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:gr}),children:[a.jsx(ri,{className:"w-3 h-3"}),gr]}),v&&ve?.current_version&&ve?.latest_version?a.jsxs("button",{onClick:()=>Fe(!0),className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs hover:opacity-80 transition-opacity ${ve.update_available?"bg-orange-500/20 text-orange-400":"bg-status-ok/20 text-status-ok"}`,title:ve.update_available?g("printers.firmwareUpdateAvailable",{current:ve.current_version,latest:ve.latest_version}):g("printers.firmwareUpToDate",{version:ve.current_version}),children:[ve.update_available?a.jsx(ga,{className:"w-3 h-3"}):a.jsx(yr,{className:"w-3 h-3"}),ve.current_version]}):pe?.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:pe.firmware_version}):null]})]}),C&&a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:a.jsx(St,{className:"w-full max-w-md mx-4",children:a.jsxs(Nt,{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(An,{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:bt=>E(bt.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(Me,{variant:"secondary",onClick:()=>{j(!1),E(!0)},children:g("common.cancel")}),a.jsx(Me,{variant:"danger",onClick:()=>{Ie.mutate({deleteArchives:M}),j(!1),E(!0)},children:"Delete"})]})]})})}),pe?.connected&&a.jsxs(a.Fragment,{children:[r==="compact"?a.jsx("div",{className:"mt-2",children:pe.state==="RUNNING"?a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-1.5",children:a.jsx("div",{className:"bg-bambu-green h-1.5 rounded-full transition-all",style:{width:`${pe.progress||0}%`}})}),a.jsxs("span",{className:"text-xs text-white",children:[Math.round(pe.progress||0),"%"]})]}):a.jsx("p",{className:"text-xs text-bambu-gray",children:d9(pe.state,pe.stg_cur_name)})}):a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"mb-4 p-3 bg-bambu-dark rounded-lg relative",children:[a.jsxs("button",{onClick:()=>ce(!0),disabled:!(pe.state==="RUNNING"||pe.state==="PAUSE")||(pe.printable_objects_count??0)<2||!A("printers:control"),className:`absolute top-2 right-2 p-1.5 rounded transition-colors z-10 ${(pe.state==="RUNNING"||pe.state==="PAUSE")&&(pe.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")?pe.state==="RUNNING"||pe.state==="PAUSE"?(pe.printable_objects_count??0)>=2?g("printers.skipObjects.tooltip"):g("printers.skipObjects.requiresMultiple"):g("printers.skipObjects.onlyWhilePrinting"):g("printers.permission.noControl"),children:[a.jsx(hk,{className:"w-4 h-4"}),ct&&ct.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:ct.skipped_count})]}),a.jsxs("div",{className:"flex gap-3",children:[a.jsx(_$e,{url:pe.state==="RUNNING"?pe.cover_url:null,printName:pe.state==="RUNNING"&&(pe.subtask_name||pe.current_print)||void 0}),a.jsx("div",{className:"flex-1 min-w-0",children:pe.current_print&&pe.state==="RUNNING"?a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"text-sm text-bambu-gray mb-1",children:pe.stg_cur_name||"Printing"}),a.jsx("p",{className:"text-white text-sm mb-2 truncate",children:pe.subtask_name||pe.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:`${pe.progress||0}%`}})}),a.jsxs("span",{className:"text-white",children:[Math.round(pe.progress||0),"%"]})]}),a.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-bambu-gray",children:[pe.remaining_time!=null&&pe.remaining_time>0&&a.jsxs(a.Fragment,{children:[a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(qn,{className:"w-3 h-3"}),Js(pe.remaining_time*60)]}),a.jsxs("span",{className:"text-bambu-green font-medium",title:g("printers.estimatedCompletion"),children:["ETA ",FF(pe.remaining_time,f,g)]})]}),pe.layer_num!=null&&pe.total_layers!=null&&pe.total_layers>0&&a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(ri,{className:"w-3 h-3"}),pe.layer_num,"/",pe.total_layers]}),Gn&&a.jsxs("span",{className:"flex items-center gap-1",title:`Started by ${Gn}`,children:[a.jsx(nu,{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:d9(pe.state,pe.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:"—"})]}),or?a.jsxs("p",{className:"text-xs text-bambu-gray mt-2 truncate",title:or.print_name||or.filename,children:["Last: ",or.print_name||or.filename,or.completed_at&&a.jsxs("span",{className:"ml-1 text-bambu-gray/60",children:["• ",mb(or.completed_at,{month:"short",day:"numeric"})]})]}):a.jsx("p",{className:"text-xs text-bambu-gray mt-2",children:g("printers.readyToPrint")})]})})]})]}),a.jsx(KTe,{printerId:t.id,printerModel:t.model,printerState:pe.state,plateCleared:pe.plate_cleared,loadedFilamentTypes:xe,loadedFilaments:we})]}),pe.temperatures&&r==="expanded"&&(()=>{const bt=pe.temperatures.nozzle_heating||pe.temperatures.nozzle_2_heating||!1,Ot=pe.temperatures.bed_heating||!1,vn=pe.temperatures.chamber_heating||!1,vt=t.nozzle_count===2||pe.temperatures.nozzle_2!==void 0,Un=pe.active_extruder===1?"L":"R",Qr=pe.nozzle_rack?.find(li=>li.id===1),Zn=pe.nozzle_rack?.find(li=>li.id===0),dr=Zn||Qr;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(GE,{className:"w-3.5 h-3.5 mb-0.5",color:"text-orange-400",isHeating:bt}),pe.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(pe.temperatures.nozzle||0),"° / ",Math.round(pe.temperatures.nozzle_2||0),"°"]})]}):dr?a.jsx(Nne,{slot:dr,index:0,activeStatus:!0,filamentName:dr.filament_id?qe?.[dr.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(pe.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(pe.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(GE,{className:"w-3.5 h-3.5 mb-0.5",color:"text-blue-400",isHeating:Ot}),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(pe.temperatures.bed||0),"°C"]})]}),pe.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(GE,{className:"w-3.5 h-3.5 mb-0.5",color:"text-green-400",isHeating:vn}),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(pe.temperatures.chamber||0),"°C"]})]}),vt&&a.jsx(f$e,{leftSlot:Qr,rightSlot:Zn,activeNozzle:Un,filamentInfo:qe,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(Un==="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 ${Un==="L"?"text-amber-400":"text-gray-500"}`,children:["L",Qr?.nozzle_diameter?` ${Qr.nozzle_diameter}`:""]}),a.jsx("span",{className:"text-[9px] text-bambu-gray/40",children:"·"}),a.jsxs("span",{className:`text-[11px] font-bold ${Un==="R"?"text-amber-400":"text-gray-500"}`,children:["R",Zn?.nozzle_diameter?` ${Zn.nozzle_diameter}`:""]})]}),a.jsx("p",{className:"text-[9px] text-bambu-gray",children:g("printers.temperatures.nozzle")})]})}),pe.nozzle_rack&&pe.nozzle_rack.some(li=>li.id>=2)&&a.jsx(p$e,{slots:pe.nozzle_rack,filamentInfo:qe})]})})(),r==="expanded"&&(()=>{const bt=pe.state==="RUNNING",Ot=pe.state==="PAUSE",vn=bt||Ot,vt=Lt.isPending||ye.isPending||He.isPending,Un=pe.cooling_fan_speed,Qr=pe.big_fan1_speed,Zn=pe.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 ${Un&&Un>0?"bg-cyan-500/10":"bg-bambu-dark"}`,title:g("printers.fans.partCooling"),children:[a.jsx(wX,{className:`w-3.5 h-3.5 ${Un&&Un>0?"text-cyan-400":"text-bambu-gray/50"}`}),a.jsxs("span",{className:`text-[10px] ${Un&&Un>0?"text-cyan-400":"text-bambu-gray/50"}`,children:[Un??0,"%"]})]}),a.jsxs("div",{className:`flex items-center gap-1 px-1.5 py-1 rounded ${Qr&&Qr>0?"bg-blue-500/10":"bg-bambu-dark"}`,title:g("printers.fans.auxiliary"),children:[a.jsx(jX,{className:`w-3.5 h-3.5 ${Qr&&Qr>0?"text-blue-400":"text-bambu-gray/50"}`}),a.jsxs("span",{className:`text-[10px] ${Qr&&Qr>0?"text-blue-400":"text-bambu-gray/50"}`,children:[Qr??0,"%"]})]}),a.jsxs("div",{className:`flex items-center gap-1 px-1.5 py-1 rounded ${Zn&&Zn>0?"bg-green-500/10":"bg-bambu-dark"}`,title:g("printers.fans.chamber"),children:[a.jsx(Uue,{className:`w-3.5 h-3.5 ${Zn&&Zn>0?"text-green-400":"text-bambu-gray/50"}`}),a.jsxs("span",{className:`text-[10px] ${Zn&&Zn>0?"text-green-400":"text-bambu-gray/50"}`,children:[Zn??0,"%"]})]})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0 max-[550px]:self-start",children:[a.jsxs("button",{onClick:()=>ee(!0),disabled:!vn||vt||!A("printers:control"),className:`
- flex items-center justify-center gap-1 px-3 py-1.5 rounded-lg text-xs font-medium
- transition-colors
- ${vn&&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"}
- `,title:A("printers:control")?g("printers.stop"):g("printers.permission.noControl"),children:[a.jsx(Sl,{className:"w-3 h-3"}),g("printers.stop")]}),a.jsxs("button",{onClick:()=>Ot?me(!0):oe(!0),disabled:!vn||vt||!A("printers:control"),className:`
- flex items-center justify-center gap-1 px-3 py-1.5 rounded-lg text-xs font-medium
- transition-colors
- ${vn&&A("printers:control")?Ot?"bg-bambu-green/20 text-bambu-green hover:bg-bambu-green/30":"bg-yellow-500/20 text-yellow-400 hover:bg-yellow-500/30":"bg-bambu-dark text-bambu-gray/50 cursor-not-allowed"}
- `,title:A("printers:control")?g(Ot?"printers.resume":"printers.pause"):g("printers.permission.noControl"),children:[Ot?a.jsx(oo,{className:"w-3 h-3"}):a.jsx(XC,{className:"w-3 h-3"}),g(Ot?"printers.resume":"printers.pause")]})]})]})]})})(),(Ft?.length>0||pe.vt_tray.length>0)&&r==="expanded"&&(()=>{const bt=Ft.filter(vt=>vt.tray.length>1),Ot=Ft.filter(vt=>vt.tray.length===1),vn=t.nozzle_count===2||pe?.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:[bt.length>0&&a.jsx("div",{className:"grid grid-cols-2 gap-3",children:bt.map(vt=>{const Un=ot[String(vt.id)],Qr=vt.id>=128?vt.id-128:vt.id,Zn=Un!==void 0?Un:Qr,dr=Zn===1,li=Zn===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:nh(vt.id,vt.tray.length)}),vn&&(dr||li)&&a.jsx(s9,{side:dr?"L":"R"})]}),(vt.humidity!=null||vt.temp!=null)&&a.jsxs("div",{className:"flex items-center gap-1.5 max-[550px]:flex-col max-[550px]:items-start",children:[vt.humidity!=null&&a.jsx(l9,{humidity:vt.humidity,goodThreshold:s?.humidityGood,fairThreshold:s?.humidityFair,onClick:()=>le({amsId:vt.id,amsLabel:nh(vt.id,vt.tray.length),mode:"humidity"}),compact:!0}),vt.temp!=null&&a.jsx(c9,{temp:vt.temp,goodThreshold:s?.tempGood,fairThreshold:s?.tempFair,onClick:()=>le({amsId:vt.id,amsLabel:nh(vt.id,vt.tray.length),mode:"temperature"}),compact:!0})]})]}),a.jsx("div",{className:"grid grid-cols-4 gap-1.5",children:[0,1,2,3].map(rn=>{const Pn=vt.tray[rn]||vt.tray.find($n=>$n.id===rn),Ci=Pn?.tray_type&&Pn.remain>=0,Bs=!Pn?.tray_type,zo=vt.id*4+rn,Uo=Be===zo,zi=Pn?.tray_info_idx?qe?.[Pn.tray_info_idx]:null,Dr=ke?.[zo],Hs=Pn?.tray_uuid?.toUpperCase(),Ca=Hs?c?.[Hs]:void 0,Zr=KE(Ca),is=u?.(t.id,vt.id,rn),ur=(()=>{const $n=is?.spool;return $n&&$n.label_weight>0&&$n.weight_used!=null?Math.round(Math.max(0,$n.label_weight-$n.weight_used)/$n.label_weight*100):null})(),Ui=Zr??ur??(Ci?Pn.remain:null),Pl=Zr!==null?"spoolman":ur!==null?"inventory":Ci?"ams":void 0,Cr=Pn?.tray_type?{vendor:XE(Pn)?"Bambu Lab":"Generic",profile:zi?.name||Dr?.preset_name||Pn.tray_sub_brands||Pn.tray_type,colorName:$E(Pn.tray_id_name)||VE(Pn.tray_color),colorHex:Pn.tray_color||null,kFactor:qE(Pn.k),fillLevel:Ui,trayUuid:Pn.tray_uuid||null,tagUid:Pn.tag_uid||null,fillSource:Pl}:null,Xt=gt?.amsId===vt.id&>?.slotId===rn,ya=a.jsxs("div",{className:`bg-bambu-dark-tertiary rounded p-1 text-center ${Bs?"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:Pn?.tray_color?`#${Pn.tray_color}`:Pn?.tray_type?"#333":"transparent",borderColor:Bs?"#666":"rgba(255,255,255,0.1)",borderStyle:Bs?"dashed":"solid"}}),a.jsx("div",{className:"text-[9px] text-white font-bold truncate",children:Pn?.tray_type||"—"}),a.jsx("div",{className:"mt-1 h-1.5 bg-black/30 rounded-full overflow-hidden",children:Ui!==null&&Ui>=0&&Pn&&a.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${Ui}%`,backgroundColor:WE(Ui)}})})]});return a.jsxs("div",{className:"relative group",children:[Xt&&a.jsx("div",{className:"absolute inset-0 bg-bambu-dark-tertiary/80 rounded flex items-center justify-center z-20",children:a.jsx(Sr,{className:"w-4 h-4 text-bambu-green animate-spin"})}),pe?.state!=="RUNNING"&&a.jsx("button",{onClick:$n=>{$n.stopPropagation(),Qn(vr?.amsId===vt.id&&vr?.slotId===rn?null:{amsId:vt.id,slotId:rn})},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(Mh,{className:"w-2.5 h-2.5 text-bambu-gray"})}),pe?.state!=="RUNNING"&&vr?.amsId===vt.id&&vr?.slotId===rn&&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:$n=>{$n.stopPropagation(),A("printers:ams_rfid")&&(Pt.mutate({amsId:vt.id,slotId:rn}),Qn(null))},disabled:Xt||!A("printers:ams_rfid"),title:A("printers:ams_rfid")?void 0:g("printers.permission.noAmsRfid"),children:[a.jsx(Sr,{className:`w-3 h-3 ${Xt?"animate-spin":""}`}),g("printers.rfid.reread")]})}),Cr?a.jsx(BE,{data:Cr,spoolman:{enabled:o,hasUnlinkedSpools:l,linkedSpoolId:Cr.trayUuid?c?.[Cr.trayUuid.toUpperCase()]?.id:void 0,spoolmanUrl:d,onLinkSpool:o&&Cr.trayUuid?$n=>{V({tagUid:Cr.tagUid||"",trayUuid:$n,printerId:t.id,amsId:vt.id,trayId:rn})}:void 0},inventory:o?void 0:(()=>{const $n=u?.(t.id,vt.id,rn);return{assignedSpool:$n?.spool?{id:$n.spool.id,material:$n.spool.material,brand:$n.spool.brand,color_name:$n.spool.color_name,remainingWeightGrams:Math.max(0,Math.round($n.spool.label_weight-$n.spool.weight_used))}:null,onAssignSpool:Cr.vendor!=="Bambu Lab"?()=>fe({printerId:t.id,amsId:vt.id,trayId:rn,trayInfo:{type:Cr.profile,color:Cr.colorHex||"",location:`${nh(vt.id,vt.tray.length)} Slot ${rn+1}`}}):void 0,onUnassignSpool:$n&&Cr.vendor!=="Bambu Lab"?()=>h?.(t.id,vt.id,rn):void 0}})(),configureSlot:{enabled:A("printers:control"),onConfigure:()=>re({amsId:vt.id,trayId:rn,trayCount:vt.tray.length,trayType:Pn?.tray_type||void 0,trayColor:Pn?.tray_color||void 0,traySubBrands:Pn?.tray_sub_brands||void 0,trayInfoIdx:Pn?.tray_info_idx||void 0,extruderId:Un,caliIdx:Pn?.cali_idx,savedPresetId:Dr?.preset_id})},children:ya}):a.jsx(HE,{configureSlot:{enabled:A("printers:control"),onConfigure:()=>re({amsId:vt.id,trayId:rn,trayCount:vt.tray.length,extruderId:Un})},children:ya})]},rn)})})]},vt.id)})}),(Ot.length>0||pe.vt_tray.length>0)&&a.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[Ot.map(vt=>{const Un=ot[String(vt.id)],Qr=vt.id>=128?vt.id-128:vt.id,Zn=Un!==void 0?Un:Qr,dr=Zn===1,li=Zn===0,rn=vt.tray[0],Pn=rn?.tray_type&&rn.remain>=0,Ci=!rn?.tray_type,Bs=BN(vt.id,rn?.id??0,!1),zo=Be===Bs,Uo=rn?.tray_info_idx?qe?.[rn.tray_info_idx]:null,zi=ke?.[Bs],Dr=rn?.tray_uuid?.toUpperCase(),Hs=Dr?c?.[Dr]:void 0,Ca=KE(Hs),Zr=rn?.id??0,is=u?.(t.id,vt.id,Zr),ur=(()=>{const kr=is?.spool;return kr&&kr.label_weight>0&&kr.weight_used!=null?Math.round(Math.max(0,kr.label_weight-kr.weight_used)/kr.label_weight*100):null})(),Ui=Ca??ur??(Pn?rn.remain:null),Pl=Ca!==null?"spoolman":ur!==null?"inventory":Pn?"ams":void 0,Cr=rn?.tray_type?{vendor:XE(rn)?"Bambu Lab":"Generic",profile:Uo?.name||zi?.preset_name||rn.tray_sub_brands||rn.tray_type,colorName:$E(rn.tray_id_name)||VE(rn.tray_color),colorHex:rn.tray_color||null,kFactor:qE(rn.k),fillLevel:Ui,trayUuid:rn.tray_uuid||null,tagUid:rn.tag_uid||null,fillSource:Pl}:null,Xt=rn?.id??0,ya=gt?.amsId===vt.id&>?.slotId===Xt,$n=a.jsxs("div",{className:`bg-bambu-dark-tertiary rounded p-1 text-center ${Ci?"opacity-50":""} ${zo?"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:rn?.tray_color?`#${rn.tray_color}`:rn?.tray_type?"#333":"transparent",borderColor:Ci?"#666":"rgba(255,255,255,0.1)",borderStyle:Ci?"dashed":"solid"}}),a.jsx("div",{className:"text-[9px] text-white font-bold truncate",children:rn?.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:WE(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:nh(vt.id,vt.tray.length)}),vn&&(dr||li)&&a.jsx(s9,{side:dr?"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:[ya&&a.jsx("div",{className:"absolute inset-0 bg-bambu-dark-tertiary/80 rounded flex items-center justify-center z-20",children:a.jsx(Sr,{className:"w-4 h-4 text-bambu-green animate-spin"})}),pe?.state!=="RUNNING"&&a.jsx("button",{onClick:kr=>{kr.stopPropagation(),Qn(vr?.amsId===vt.id&&vr?.slotId===Xt?null:{amsId:vt.id,slotId:Xt})},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(Mh,{className:"w-2.5 h-2.5 text-bambu-gray"})}),pe?.state!=="RUNNING"&&vr?.amsId===vt.id&&vr?.slotId===Xt&&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:kr=>{kr.stopPropagation(),A("printers:ams_rfid")&&(Pt.mutate({amsId:vt.id,slotId:Xt}),Qn(null))},disabled:ya||!A("printers:ams_rfid"),title:A("printers:ams_rfid")?void 0:g("printers.permission.noAmsRfid"),children:[a.jsx(Sr,{className:`w-3 h-3 ${ya?"animate-spin":""}`}),g("printers.rfid.reread")]})}),Cr?a.jsx(BE,{data:Cr,spoolman:{enabled:o,hasUnlinkedSpools:l,linkedSpoolId:Cr.trayUuid?c?.[Cr.trayUuid.toUpperCase()]?.id:void 0,spoolmanUrl:d,onLinkSpool:o&&Cr.trayUuid?kr=>{V({tagUid:Cr.tagUid||"",trayUuid:kr,printerId:t.id,amsId:vt.id,trayId:Xt})}:void 0},inventory:o?void 0:(()=>{const kr=u?.(t.id,vt.id,Xt);return{assignedSpool:kr?.spool?{id:kr.spool.id,material:kr.spool.material,brand:kr.spool.brand,color_name:kr.spool.color_name,remainingWeightGrams:Math.max(0,Math.round(kr.spool.label_weight-kr.spool.weight_used))}:null,onAssignSpool:Cr.vendor!=="Bambu Lab"?()=>fe({printerId:t.id,amsId:vt.id,trayId:Xt,trayInfo:{type:Cr.profile,color:Cr.colorHex||"",location:nh(vt.id,vt.tray.length)}}):void 0,onUnassignSpool:kr&&Cr.vendor!=="Bambu Lab"?()=>h?.(t.id,vt.id,Xt):void 0}})(),configureSlot:{enabled:A("printers:control"),onConfigure:()=>re({amsId:vt.id,trayId:Xt,trayCount:vt.tray.length,trayType:rn?.tray_type||void 0,trayColor:rn?.tray_color||void 0,traySubBrands:rn?.tray_sub_brands||void 0,trayInfoIdx:rn?.tray_info_idx||void 0,extruderId:Un,caliIdx:rn?.cali_idx,savedPresetId:zi?.preset_id})},children:$n}):a.jsx(HE,{configureSlot:{enabled:A("printers:control"),onConfigure:()=>re({amsId:vt.id,trayId:Xt,trayCount:vt.tray.length,extruderId:Un})},children:$n})]}),(vt.humidity!=null||vt.temp!=null)&&a.jsxs("div",{className:"flex flex-col justify-center gap-1 shrink-0 max-[550px]:w-full",children:[vt.temp!=null&&a.jsx(c9,{temp:vt.temp,goodThreshold:s?.tempGood,fairThreshold:s?.tempFair,onClick:()=>le({amsId:vt.id,amsLabel:nh(vt.id,vt.tray.length),mode:"temperature"}),compact:!0}),vt.humidity!=null&&a.jsx(l9,{humidity:vt.humidity,goodThreshold:s?.humidityGood,fairThreshold:s?.humidityFair,onClick:()=>le({amsId:vt.id,amsLabel:nh(vt.id,vt.tray.length),mode:"humidity"}),compact:!0})]})]})]},vt.id)}),pe.vt_tray.length>0&&a.jsxs("div",{className:`p-2.5 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary/30 ${pe.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 ${pe.vt_tray.length>1?"grid-cols-2":"grid-cols-1"} gap-1.5`,children:[...pe.vt_tray].sort((vt,Un)=>(vt.id??254)-(Un.id??254)).map(vt=>{const Un=vt.id??254,Qr=vn&&Be===254?Un===254&&pe.active_extruder===1||Un===255&&pe.active_extruder===0:Be===Un,Zn=Un-254,dr=vn?g(Un===254?"printers.extL":"printers.extR"):"",li=vt.tray_info_idx?qe?.[vt.tray_info_idx]:null,rn=ke?.[1020+Zn],Pn=vt.tray_uuid?.toUpperCase(),Ci=Pn?c?.[Pn]:void 0,Bs=KE(Ci),zo=u?.(t.id,255,Zn),Uo=(()=>{const ur=zo?.spool;return ur&&ur.label_weight>0&&ur.weight_used!=null?Math.round(Math.max(0,ur.label_weight-ur.weight_used)/ur.label_weight*100):null})(),zi=vt.tray_type&&vt.remain>=0,Dr=Bs??Uo??(zi?vt.remain:null),Hs=Bs!==null?"spoolman":Uo!==null?"inventory":zi?"ams":void 0,Ca={vendor:XE(vt)?"Bambu Lab":"Generic",profile:li?.name||rn?.preset_name||vt.tray_sub_brands||vt.tray_type||"Unknown",colorName:$E(vt.tray_id_name)||VE(vt.tray_color),colorHex:vt.tray_color||null,kFactor:qE(vt.k),fillLevel:Dr,trayUuid:vt.tray_uuid||null,tagUid:vt.tag_uid||null,fillSource:Hs},Zr=!vt.tray_type,is=a.jsxs("div",{className:`bg-bambu-dark-tertiary rounded p-1 text-center ${Zr?"opacity-50":""} ${Qr?"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:vt.tray_color?`#${vt.tray_color}`:vt.tray_type?"#333":"transparent",borderColor:Zr?"#666":"rgba(255,255,255,0.1)",borderStyle:Zr?"dashed":"solid"}}),a.jsx("div",{className:`text-[9px] font-bold truncate ${Zr?"text-white/40":"text-white"}`,children:vt.tray_type||"—"}),a.jsx("div",{className:"mt-1 h-1.5 bg-black/30 rounded-full overflow-hidden",children:Dr!==null&&Dr>=0&&!Zr&&a.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${Dr}%`,backgroundColor:WE(Dr)}})}),dr&&a.jsx("div",{className:"text-[7px] text-white/40 mt-0.5 truncate",children:dr})]});return a.jsx("div",{className:"relative group",children:Zr?a.jsx(HE,{configureSlot:{enabled:A("printers:control"),onConfigure:()=>re({amsId:255,trayId:Zn,trayCount:1,extruderId:vn?Un===254?1:0:void 0})},children:is}):a.jsx(BE,{data:Ca,spoolman:{enabled:o,hasUnlinkedSpools:l,linkedSpoolId:Ca.trayUuid?c?.[Ca.trayUuid.toUpperCase()]?.id:void 0,spoolmanUrl:d,onLinkSpool:o&&Ca.trayUuid?ur=>{V({tagUid:Ca.tagUid||"",trayUuid:ur,printerId:t.id,amsId:255,trayId:Zn})}:void 0},inventory:o?void 0:(()=>{const ur=u?.(t.id,255,Zn);return{assignedSpool:ur?.spool?{id:ur.spool.id,material:ur.spool.material,brand:ur.spool.brand,color_name:ur.spool.color_name,remainingWeightGrams:Math.max(0,Math.round(ur.spool.label_weight-ur.spool.weight_used))}:null,onAssignSpool:()=>fe({printerId:t.id,amsId:255,trayId:Zn,trayInfo:{type:Ca.profile,color:Ca.colorHex||"",location:dr||g("printers.external")}}),onUnassignSpool:ur?()=>h?.(t.id,255,Zn):void 0}})(),configureSlot:{enabled:A("printers:control"),onConfigure:()=>re({amsId:255,trayId:Zn,trayCount:1,trayType:vt.tray_type||void 0,trayColor:vt.tray_color||void 0,traySubBrands:vt.tray_sub_brands||void 0,trayInfoIdx:vt.tray_info_idx||void 0,extruderId:vn?Un===254?1:0:void 0,caliIdx:vt.cali_idx,savedPresetId:rn?.preset_id})},children:is})},Un)})})]})]})]})]})})()]}),mt&&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(ru,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),a.jsx("span",{className:"text-sm text-white truncate",children:mt.name}),zt&&a.jsxs("span",{className:`text-xs px-1.5 py-0.5 rounded flex-shrink-0 ${zt.state==="ON"?"bg-bambu-green/20 text-bambu-green":zt.state==="OFF"?"bg-red-500/20 text-red-400":"bg-bambu-gray/20 text-bambu-gray"}`,children:[zt.state||"?",zt.state==="ON"&&zt.energy?.power!=null&&a.jsxs("span",{className:"text-yellow-400 ml-1.5",children:["· ",zt.energy.power,"W"]})]})]}),a.jsx("div",{className:"flex-1"}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsxs("button",{onClick:()=>W(!0),disabled:tt.isPending||zt?.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")?zt?.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(fu,{className:"w-3 h-3"}),"On"]}),a.jsxs("button",{onClick:()=>te(!0),disabled:tt.isPending||zt?.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")?zt?.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(YC,{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 ${mt.auto_off_executed?"text-bambu-green":"text-bambu-gray"}`,children:mt.auto_off_executed?"Auto-off done":"Auto-off"}),a.jsx("button",{onClick:()=>it.mutate(!mt.auto_off),disabled:it.isPending||mt.auto_off_executed||!A("smart_plugs:control"),title:A("smart_plugs:control")?mt.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")?mt.auto_off_executed?"bg-bambu-green/50 cursor-not-allowed":mt.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 ${mt.auto_off||mt.auto_off_executed?"translate-x-4":"translate-x-0"}`})})]})]}),yt&&yt.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(dv,{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:yt.map(bt=>a.jsxs("button",{onClick:()=>Ke.mutate(bt.id),disabled:Ke.isPending,title:`Run ${bt.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(oo,{className:"w-2.5 h-2.5"}),bt.name]},bt.id))})]})]}),r==="expanded"&&a.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3",children:[a.jsxs("div",{className:"text-xs text-bambu-gray",children:[a.jsx("p",{children:t.ip_address}),a.jsx("p",{className:"truncate",children:t.serial_number})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[a.jsx(Me,{variant:"secondary",size:"sm",onClick:()=>Ye.mutate(!pe?.chamber_light),disabled:!pe?.connected||Ye.isPending||!A("printers:control"),title:A("printers:control")?pe?.chamber_light?g("printers.chamberLightOff"):g("printers.chamberLightOn"):g("printers.permission.noControl"),className:pe?.chamber_light?"bg-yellow-500/20 hover:bg-yellow-500/30 border-yellow-500/30":"",children:a.jsx(dL,{on:pe?.chamber_light??!1,className:"w-4 h-4"})}),a.jsx(Me,{variant:"secondary",size:"sm",onClick:()=>{if(p==="embedded"&&x)x(t.id,t.name);else{const bt=localStorage.getItem("cameraWindowState"),Ot=bt?JSON.parse(bt):{width:640,height:400},vn=[`width=${Ot.width}`,`height=${Ot.height}`,Ot.left!==void 0?`left=${Ot.left}`:"",Ot.top!==void 0?`top=${Ot.top}`:"","menubar=no,toolbar=no,location=no,status=no,noopener"].filter(Boolean).join(",");window.open(`/camera/${t.id}`,`camera-${t.id}`,vn)}},disabled:!pe?.connected,title:g(p==="embedded"?"printers.openCameraOverlay":"printers.openCameraWindow"),children:a.jsx(jF,{className:"w-4 h-4"})}),a.jsxs("div",{className:`inline-flex rounded-md ${t.plate_detection_enabled?"ring-1 ring-green-500":""}`,children:[a.jsx(Me,{variant:"secondary",size:"sm",onClick:Zt,disabled:!pe?.connected||Xe.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:Xe.isPending?a.jsx(at,{className:"w-4 h-4 animate-spin"}):a.jsx(_1,{className:"w-4 h-4"})}),a.jsx(Me,{variant:"secondary",size:"sm",onClick:fn,disabled:!pe?.connected||O||!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:O?a.jsx(at,{className:"w-3 h-3 animate-spin"}):a.jsx(Mn,{className:"w-3 h-3"})})]}),a.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>D(!0),disabled:!A("printers:files"),title:A("printers:files")?g("printers.browseFiles"):g("printers.permission.noFiles"),children:[a.jsx(Vb,{className:"w-4 h-4"}),"Files"]})]})]})]}),U&&a.jsx(OTe,{printerId:t.id,printerName:t.name,onClose:()=>D(!1)}),$&&a.jsx($Te,{printerId:t.id,printerName:t.name,onClose:()=>q(!1)}),Pe&&a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:()=>un(),children:a.jsxs("div",{className:"bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl shadow-2xl max-w-lg w-full",onClick:bt=>bt.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:[Pe.needs_calibration?a.jsx(_1,{className:"w-5 h-5 text-blue-500"}):Pe.is_empty?a.jsx(yr,{className:"w-5 h-5 text-green-500"}):a.jsx(mi,{className:"w-5 h-5 text-yellow-500"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:"Build Plate Check"}),Pe.reference_count!==void 0&&Pe.max_references&&a.jsxs("span",{className:"text-xs text-bambu-gray bg-bambu-dark-tertiary px-2 py-1 rounded",children:[Pe.reference_count,"/",Pe.max_references," refs"]})]}),a.jsx("button",{onClick:()=>un(),className:"p-1 text-bambu-gray hover:text-white rounded transition-colors",children:a.jsx(Rt,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"p-4 space-y-4",children:[Pe.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 ${Pe.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 ${Pe.is_empty?"text-green-400":"text-yellow-400"}`,children:Pe.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(Pe.confidence*100),"% | ",g("printers.plateDetection.difference"),": ",Pe.difference_percent.toFixed(1),"%"]})]}),Pe.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:Pe.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:Pe.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(bt=>a.jsxs("div",{className:"relative group",children:[a.jsx("img",{src:J.getPlateReferenceThumbnailUrl(t.id,bt.index),alt:bt.label||`Reference ${bt.index+1}`,className:"w-full aspect-video object-cover rounded border border-bambu-dark-tertiary"}),a.jsx("button",{onClick:()=>lr(bt.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(Rt,{className:"w-3 h-3 text-white"})}),on?.index===bt.index?a.jsx("input",{type:"text",value:on.label,onChange:Ot=>gn({...on,label:Ot.target.value}),onBlur:()=>pn(bt.index,on.label),onKeyDown:Ot=>{Ot.key==="Enter"&&pn(bt.index,on.label),Ot.key==="Escape"&&gn(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:()=>gn({index:bt.index,label:bt.label}),title:bt.label?g("printers.plateDetection.clickToEdit",{label:bt.label}):g("printers.plateDetection.clickToAddLabel"),children:bt.label||a.jsx("span",{className:"italic opacity-50",children:g("printers.noLabel")})}),a.jsx("p",{className:"text-[10px] text-bambu-gray/60",children:bt.timestamp?tr(bt.timestamp)?.toLocaleDateString()??"":""})]},bt.index))})]}),!Pe.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")}),ge?a.jsxs("div",{className:"flex gap-1",children:[a.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>ae(null),disabled:Ue,children:g("common.cancel")}),a.jsx(Me,{size:"sm",onClick:as,disabled:Ue,children:Ue?a.jsx(at,{className:"w-3 h-3 animate-spin"}):g("common.save")})]}):a.jsxs(Me,{variant:"ghost",size:"sm",onClick:()=>ae(Pe.roi||{x:.15,y:.35,w:.7,h:.55}),children:[a.jsx(Ga,{className:"w-3 h-3 mr-1"}),g("common.edit")]})]}),ge?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:ge.x,onChange:bt=>ae({...ge,x:parseFloat(bt.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(ge.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:ge.y,onChange:bt=>ae({...ge,y:parseFloat(bt.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(ge.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:ge.w,onChange:bt=>ae({...ge,w:parseFloat(bt.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(ge.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:ge.h,onChange:bt=>ae({...ge,h:parseFloat(bt.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(ge.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((Pe.roi?.x||.15)*100),"%, Y=",Math.round((Pe.roi?.y||.35)*100),"%, W=",Math.round((Pe.roi?.w||.7)*100),"%, H=",Math.round((Pe.roi?.h||.55)*100),"%"]})]})]}),a.jsx("div",{className:"flex justify-end gap-2 p-4 border-t border-bambu-dark-tertiary",children:Pe.needs_calibration?a.jsxs(a.Fragment,{children:[a.jsx(Me,{variant:"ghost",onClick:()=>un(),children:g("common.cancel")}),a.jsx(Me,{onClick:()=>qr(),disabled:G,children:G?a.jsxs(a.Fragment,{children:[a.jsx(at,{className:"w-4 h-4 mr-2 animate-spin"}),"Calibrating..."]}):"Calibrate Empty Plate"})]}):a.jsxs(a.Fragment,{children:[a.jsx(Me,{variant:"ghost",onClick:()=>qr(),disabled:G,children:G?"Adding...":`Add Reference (${tn?.references.length||0}/${tn?.max_references||5})`}),a.jsx(Me,{onClick:()=>un(),children:"Close"})]})})]})}),z&&mt&&a.jsx(xn,{title:g("printers.confirm.powerOnTitle"),message:g("printers.confirm.powerOnMessage",{name:t.name}),confirmText:g("printers.confirm.powerOnButton"),variant:"default",onConfirm:()=>{tt.mutate("on"),W(!1)},onCancel:()=>W(!1)}),Q&&mt&&a.jsx(xn,{title:g("printers.confirm.powerOffTitle"),message:pe?.state==="RUNNING"?g("printers.confirm.powerOffWarning",{name:t.name}):g("printers.confirm.powerOffMessage",{name:t.name}),confirmText:g("printers.confirm.powerOffButton"),variant:"danger",onConfirm:()=>{tt.mutate("off"),te(!1)},onCancel:()=>te(!1)}),Z&&a.jsx(xn,{title:g("printers.confirm.stopTitle"),message:g("printers.confirm.stopMessage",{name:t.name}),confirmText:g("printers.confirm.stopButton"),variant:"danger",onConfirm:()=>{Lt.mutate(),ee(!1)},onCancel:()=>ee(!1)}),Se&&a.jsx(xn,{title:g("printers.confirm.pauseTitle"),message:g("printers.confirm.pauseMessage",{name:t.name}),confirmText:g("printers.confirm.pauseButton"),variant:"default",onConfirm:()=>{ye.mutate(),oe(!1)},onCancel:()=>oe(!1)}),ie&&a.jsx(xn,{title:g("printers.confirm.resumeTitle"),message:g("printers.confirm.resumeMessage",{name:t.name}),confirmText:g("printers.confirm.resumeButton"),variant:"default",onConfirm:()=>{He.mutate(),me(!1)},onCancel:()=>me(!1)}),a.jsx(uL,{printerId:t.id,isOpen:se,onClose:()=>ce(!1)}),H&&a.jsx(WTe,{printerName:t.name,errors:pe?.hms_errors||[],onClose:()=>X(!1),printerId:t.id,hasPermission:A}),Ce&&a.jsx(i$e,{isOpen:!!Ce,onClose:()=>le(null),printerId:t.id,printerName:t.name,amsId:Ce.amsId,amsLabel:Ce.amsLabel,initialMode:Ce.mode,thresholds:s}),Le&&a.jsx(s$e,{isOpen:!!Le,onClose:()=>V(null),tagUid:Le.tagUid,trayUuid:Le.trayUuid,printerId:Le.printerId,amsId:Le.amsId,trayId:Le.trayId}),K&&a.jsx(o$e,{isOpen:!!K,onClose:()=>fe(null),printerId:K.printerId,amsId:K.amsId,trayId:K.trayId,trayInfo:K.trayInfo}),Y&&a.jsx(wne,{isOpen:!!Y,onClose:()=>re(null),printerId:t.id,slotInfo:Y,printerModel:vR(t.model)||void 0,onSuccess:()=>{y.invalidateQueries({queryKey:["slotPresets",t.id]}),y.invalidateQueries({queryKey:["printerStatus",t.id]})}}),B&&a.jsx(A$e,{printer:t,onClose:()=>L(!1)}),ue&&ve&&a.jsx(k$e,{printer:t,firmwareInfo:ve,onClose:()=>Fe(!1)}),vr&&a.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>Qn(null)})]})}function C$e({onClose:t,onAdd:e,existingSerials:n}){const{t:r}=Dt(),[i,s]=w.useState({name:"",serial_number:"",ip_address:"",access_code:"",model:"",location:"",auto_archive:!0}),[o,l]=w.useState(!1),[c,d]=w.useState([]),[u,h]=w.useState(""),[f,p]=w.useState(!1),[x,v]=w.useState(!1),[g,y]=w.useState([]),[_,N]=w.useState(""),[A,k]=w.useState({scanned:0,total:0});w.useEffect(()=>{hc.getInfo().then(M=>{v(M.is_docker),M.subnets.length>0&&(y(M.subnets),N(M.subnets[0]))}).catch(()=>{})},[]);const P=c.filter(M=>!n.includes(M.serial)),C=async()=>{h(""),d([]),l(!0),p(!1),k({scanned:0,total:0});try{if(x){await hc.startSubnetScan(_);const M=setInterval(async()=>{try{const E=await hc.getScanStatus();k({scanned:E.scanned,total:E.total});const B=await hc.getDiscoveredPrinters();d(B),E.running||(clearInterval(M),l(!1),p(!0))}catch(E){console.error("Failed to get scan status:",E)}},500)}else{await hc.startDiscovery(10);const M=setInterval(async()=>{try{const E=await hc.getDiscoveredPrinters();d(E)}catch(E){console.error("Failed to get discovered printers:",E)}},1e3);setTimeout(async()=>{clearInterval(M);try{await hc.stopDiscovery()}catch{}l(!1),p(!0);try{const E=await hc.getDiscoveredPrinters();d(E)}catch(E){console.error("Failed to get final discovered printers:",E)}},1e4)}}catch(M){console.error("Failed to start discovery:",M),h(M instanceof Error?M.message:r("printers.discovery.failedToStart")),l(!1),p(!0)}},j=M=>{const E=M.serial.startsWith("unknown-")?"":M.serial;s({...i,name:M.name||"",serial_number:E,ip_address:M.ip_address,model:vR(M.model)}),d([])};return w.useEffect(()=>()=>{hc.stopDiscovery().catch(()=>{}),hc.stopSubnetScan().catch(()=>{})},[]),w.useEffect(()=>{const M=E=>{E.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(St,{className:"w-full max-w-md",onClick:M=>M.stopPropagation(),children:a.jsxs(Nt,{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(Me,{type:"button",variant:"secondary",onClick:C,disabled:o,className:"w-full",children:o?a.jsxs(a.Fragment,{children:[a.jsx(at,{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")]})}),u&&a.jsx("div",{className:"mt-2 text-sm text-red-400",children:u}),P.length>0&&a.jsx("div",{className:"mt-3 space-y-2 max-h-40 overflow-y-auto",children:P.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:()=>j(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:[vR(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(Mn,{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&&P.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(Me,{type:"button",variant:"secondary",onClick:t,className:"flex-1",children:r("common.cancel")}),a.jsx(Me,{type:"submit",className:"flex-1",children:r("printers.addPrinter")})]})]})]})})})}function k$e({printer:t,firmwareInfo:e,onClose:n}){const{t:r}=Dt(),i=Qt(),{showToast:s}=dn(),{hasPermission:o}=jr(),l=o("firmware:update"),[c,d]=w.useState(null),[u,h]=w.useState(!1),[f,p]=w.useState(null),{data:x,isLoading:v}=Ze({queryKey:["firmwarePrepare",t.id],queryFn:()=>B_.prepareUpload(t.id),staleTime:3e4,enabled:e.update_available&&l}),g=st({mutationFn:()=>B_.startUpload(t.id),onSuccess:()=>{h(!0);const _=setInterval(async()=>{try{const N=await B_.getUploadStatus(t.id);d(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=()=>{d(null),g.mutate()};return a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:a.jsx(St,{className:"w-full max-w-md mx-4",children:a.jsxs(Nt,{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(ga,{className:"w-5 h-5 text-orange-400"}):a.jsx(yr,{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(at,{className:"w-4 h-4 animate-spin"}),r("printers.firmwareModal.checkingPrereqs")]}):x&&!u&&!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(ei,{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(Va,{className:"w-4 h-4 flex-shrink-0"}),_]},N))})}):null:null,(u||c)&&c&&a.jsxs("div",{className:"mb-4",children:[a.jsxs("div",{className:"flex items-center justify-between text-sm mb-1",children:[a.jsx("span",{className:"text-bambu-gray capitalize",children:c.status}),a.jsxs("span",{className:"text-white",children:[c.progress,"%"]})]}),a.jsx("div",{className:"w-full bg-bambu-dark-tertiary rounded-full h-2",children:a.jsx("div",{className:`h-2 rounded-full transition-all ${c.status==="error"?"bg-status-error":c.status==="complete"?"bg-status-ok":"bg-orange-500"} ${c.status==="uploading"?"animate-pulse":""}`,style:{width:`${c.progress}%`}})}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:c.message}),c.error&&a.jsx("p",{className:"text-xs text-red-400 mt-1",children:c.error})]}),c?.status==="complete"&&a.jsxs("div",{className:"bg-bambu-green/10 border border-bambu-green/30 rounded-lg p-3 mb-4",children:[a.jsx("p",{className:"text-sm text-bambu-green font-medium mb-2",children:r("printers.firmwareModal.uploadedSuccess")}),a.jsx("p",{className:"text-xs text-bambu-gray",children:r("printers.firmwareModal.applyInstructions")}),a.jsxs("ol",{className:"text-xs text-bambu-gray mt-1 list-decimal list-inside space-y-1",children:[a.jsx("li",{dangerouslySetInnerHTML:{__html:r("printers.firmwareModal.step1")}}),a.jsx("li",{dangerouslySetInnerHTML:{__html:r("printers.firmwareModal.step2")}}),a.jsx("li",{dangerouslySetInnerHTML:{__html:r("printers.firmwareModal.step3")}}),a.jsx("li",{children:r("printers.firmwareModal.step4")})]})]}),a.jsxs("div",{className:"flex gap-2 justify-end",children:[a.jsx(Me,{variant:"secondary",onClick:n,children:c?.status==="complete"?r("printers.firmwareModal.done"):r("common.cancel")}),x?.can_proceed&&!u&&c?.status!=="complete"&&l&&a.jsx(Me,{onClick:y,disabled:g.isPending,children:g.isPending?a.jsxs(a.Fragment,{children:[a.jsx(at,{className:"w-4 h-4 animate-spin mr-2"}),r("printers.firmwareModal.starting")]}):a.jsxs(a.Fragment,{children:[a.jsx(ga,{className:"w-4 h-4 mr-2"}),r("printers.firmwareModal.uploadFirmware")]})})]})]})})})}function A$e({printer:t,onClose:e}){const{t:n}=Dt(),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=st({mutationFn:d=>J.updatePrinter(t.id,d),onSuccess:()=>{r.invalidateQueries({queryKey:["printers"]}),r.invalidateQueries({queryKey:["printerStatus",t.id]}),e()},onError:d=>i(d.message||n("printers.toast.failedToUpdate"),"error")});w.useEffect(()=>{const d=u=>{u.key==="Escape"&&e()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[e]);const c=d=>{d.preventDefault();const u={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&&(u.access_code=s.access_code),l.mutate(u)};return a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:e,children:a.jsx(St,{className:"w-full max-w-md",onClick:d=>d.stopPropagation(),children:a.jsxs(Nt,{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:d=>o({...s,name:d.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:d=>o({...s,ip_address:d.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:d=>o({...s,access_code:d.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:d=>o({...s,model:d.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:d=>o({...s,location:d.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:d=>o({...s,auto_archive:d.target.checked}),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),a.jsx("label",{htmlFor:"edit_auto_archive",className:"text-sm text-bambu-gray",children:n("printers.modal.autoArchiveLabel")})]}),a.jsxs("div",{className:"flex gap-3 pt-4",children:[a.jsx(Me,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:n("common.cancel")}),a.jsx(Me,{type:"submit",className:"flex-1",disabled:l.isPending,children:l.isPending?n("common.saving"):n("printers.modal.saveChanges")})]})]})]})})})}function T$e(t){const{data:e}=Ze({queryKey:["printerStatus",t],queryFn:()=>J.getPrinterStatus(t),refetchInterval:3e4});return!e?.connected}function M$e({printer:t,plug:e,onPowerOn:n,isPowering:r}){const i=T$e(t.id),{data:s}=Ze({queryKey:["smartPlugStatus",e.id],queryFn:()=>J.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(fu,{className:"w-3 h-3"}),r?"...":"On"]})]}):null}function P$e(){const{t}=Dt(),[e,n]=w.useState(!1),[r,i]=w.useState(()=>localStorage.getItem("hideDisconnectedPrinters")==="true"),[s,o]=w.useState(!1),[l,c]=w.useState(null),[d,u]=w.useState(()=>localStorage.getItem("printerSortBy")||"name"),[h,f]=w.useState(()=>localStorage.getItem("printerSortAsc")!=="false"),[p,x]=w.useState(()=>{const ce=localStorage.getItem("printerCardSize");return ce?parseInt(ce,10):2}),v=p===1?"compact":"expanded",g=Qt(),{showToast:y}=dn(),{hasPermission:_}=jr(),[N,A]=w.useState(()=>{const ce=localStorage.getItem("openEmbeddedCameras");if(ce)try{const Ce=JSON.parse(ce);return new Map(Ce.map(le=>[le.id,le]))}catch{return new Map}return new Map});w.useEffect(()=>{const ce=Array.from(N.values());ce.length>0?localStorage.setItem("openEmbeddedCameras",JSON.stringify(ce)):localStorage.removeItem("openEmbeddedCameras")},[N]);const{data:k,isLoading:P}=Ze({queryKey:["printers"],queryFn:J.getPrinters}),{data:C}=Ze({queryKey:["settings"],queryFn:J.getSettings});w.useEffect(()=>{C?.camera_view_mode==="window"&&N.size>0&&A(new Map)},[C?.camera_view_mode,N.size]);const{data:j}=Ze({queryKey:["smart-plugs"],queryFn:J.getSmartPlugs}),{data:M}=Ze({queryKey:["maintenanceOverview"],queryFn:J.getMaintenanceOverview,staleTime:60*1e3}),{data:E}=Ze({queryKey:["spoolman-status"],queryFn:J.getSpoolmanStatus,staleTime:60*1e3}),B=E?.enabled&&E?.connected,{data:L}=Ze({queryKey:["unlinked-spools"],queryFn:J.getUnlinkedSpools,enabled:!!B,staleTime:30*1e3}),U=L&&L.length>0,{data:D}=Ze({queryKey:["linked-spools"],queryFn:J.getLinkedSpools,enabled:!!B,staleTime:30*1e3}),$=D?.linked,{data:q}=Ze({queryKey:["spool-assignments"],queryFn:()=>J.getAssignments(),staleTime:30*1e3}),z=st({mutationFn:({printerId:ce,amsId:Ce,trayId:le})=>J.unassignSpool(ce,Ce,le),onSuccess:()=>{g.invalidateQueries({queryKey:["spool-assignments"]})}}),W=(ce,Ce,le)=>q?.find(Le=>Le.printer_id===ce&&Le.ams_id===Number(Ce)&&Le.tray_id===Number(le)),Q=M?.reduce((ce,Ce)=>(ce[Ce.printer_id]={due_count:Ce.due_count,warning_count:Ce.warning_count,total_print_hours:Ce.total_print_hours},ce),{})||{},te=j?.reduce((ce,Ce)=>(Ce.printer_id&&(ce[Ce.printer_id]=Ce),ce),{})||{},H=st({mutationFn:J.createPrinter,onSuccess:()=>{g.invalidateQueries({queryKey:["printers"]}),g.invalidateQueries({queryKey:["maintenanceOverview"]}),n(!1)},onError:ce=>y(ce.message||t("printers.toast.failedToAdd"),"error")}),X=st({mutationFn:ce=>J.controlSmartPlug(ce,"on"),onSuccess:()=>{g.invalidateQueries({queryKey:["smart-plugs"]}),c(null)},onError:()=>{c(null)}}),Z=()=>{const ce=!r;i(ce),localStorage.setItem("hideDisconnectedPrinters",String(ce))},ee=ce=>{u(ce),localStorage.setItem("printerSortBy",ce)},Se=()=>{const ce=!h;f(ce),localStorage.setItem("printerSortAsc",String(ce))},oe=()=>{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"}},ie=["S","M","L","XL"],me=w.useMemo(()=>{if(!k)return[];const ce=[...k];switch(d){case"name":ce.sort((Ce,le)=>Ce.name.localeCompare(le.name));break;case"model":ce.sort((Ce,le)=>(Ce.model||"").localeCompare(le.model||""));break;case"location":ce.sort((Ce,le)=>{const Le=Ce.location||"",V=le.location||"";return!Le&&V?1:Le&&!V?-1:Le.localeCompare(V)||Ce.name.localeCompare(le.name)});break;case"status":ce.sort((Ce,le)=>{const Le=g.getQueryData(["printerStatus",Ce.id]),V=g.getQueryData(["printerStatus",le.id]),K=fe=>fe?.connected?fe.state==="RUNNING"?0:1:2;return K(Le)-K(V)});break}return h||ce.reverse(),ce},[k,d,h,g]),se=w.useMemo(()=>{if(d!=="location")return null;const ce={};return me.forEach(Ce=>{const le=Ce.location||"Ungrouped";ce[le]||(ce[le]=[]),ce[le].push(Ce)}),ce},[d,me]);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(N$e,{printers:k})]}),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:d,onChange:ce=>ee(ce.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:Se,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(Mf,{className:"w-4 h-4 text-bambu-gray"}):a.jsx(cb,{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:ie.map((ce,Ce)=>{const le=Ce+1,Le=p===le;return a.jsx("button",{onClick:()=>{x(le),localStorage.setItem("printerCardSize",String(le))},className:`px-2 py-1.5 text-xs font-medium transition-colors ${Ce===0?"rounded-l-lg":""} ${Ce===ie.length-1?"rounded-r-lg":""} ${Le?"bg-bambu-green text-white":"text-bambu-gray hover:bg-bambu-dark-tertiary hover:text-white"}`,title:t(ce==="S"?"printers.cardSize.small":ce==="M"?"printers.cardSize.medium":ce==="L"?"printers.cardSize.large":"printers.cardSize.extraLarge"),children:ce},ce)})}),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:Z,className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),t("printers.hideOffline")]}),r&&Object.keys(te).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(fu,{className:"w-4 h-4"}),t("printers.powerOn"),a.jsx(Mn,{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")}),k?.filter(ce=>te[ce.id]).map(ce=>a.jsx(M$e,{printer:ce,plug:te[ce.id],onPowerOn:Ce=>{c(Ce),X.mutate(Ce)},isPowering:l===te[ce.id]?.id},ce.id)),k?.filter(ce=>te[ce.id]).length===0&&a.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No printers with smart plugs"})]})]})]}),a.jsxs(Me,{onClick:()=>n(!0),disabled:!_("printers:create"),title:_("printers:create")?void 0:t("printers.permission.noAdd"),children:[a.jsx(Xn,{className:"w-4 h-4"}),t("printers.addPrinter")]})]})]}),P?a.jsx("div",{className:"text-center py-12 text-bambu-gray",children:t("common.loading")}):k?.length===0?a.jsx(St,{children:a.jsxs(Nt,{className:"text-center py-12",children:[a.jsx("p",{className:"text-bambu-gray mb-4",children:t("printers.noPrintersConfigured")}),a.jsxs(Me,{onClick:()=>n(!0),disabled:!_("printers:create"),title:_("printers:create")?void 0:t("printers.permission.noAdd"),children:[a.jsx(Xn,{className:"w-4 h-4"}),t("printers.addPrinter")]})]})}):se?a.jsx("div",{className:"space-y-6",children:Object.entries(se).map(([ce,Ce])=>a.jsxs("div",{children:[a.jsxs("h2",{className:"text-lg font-semibold text-white mb-3 flex items-center gap-2",children:[a.jsx("span",{className:"w-2 h-2 rounded-full bg-bambu-green"}),ce,a.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",Ce.length,")"]})]}),a.jsx("div",{className:`grid gap-4 ${p>=3?"gap-6":""} ${oe()}`,children:Ce.map(le=>a.jsx(u9,{printer:le,hideIfDisconnected:r,maintenanceInfo:Q[le.id],viewMode:v,cardSize:p,amsThresholds:C?{humidityGood:Number(C.ams_humidity_good)||40,humidityFair:Number(C.ams_humidity_fair)||60,tempGood:Number(C.ams_temp_good)||28,tempFair:Number(C.ams_temp_fair)||35}:void 0,spoolmanEnabled:B,hasUnlinkedSpools:U,linkedSpools:$,spoolmanUrl:E?.url,onGetAssignment:W,onUnassignSpool:(Le,V,K)=>z.mutate({printerId:Le,amsId:V,trayId:K}),timeFormat:C?.time_format||"system",cameraViewMode:C?.camera_view_mode||"window",onOpenEmbeddedCamera:(Le,V)=>A(K=>new Map(K).set(Le,{id:Le,name:V})),checkPrinterFirmware:C?.check_printer_firmware!==!1},le.id))})]},ce))}):a.jsx("div",{className:`grid gap-4 ${p>=3?"gap-6":""} ${oe()}`,children:me.map(ce=>a.jsx(u9,{printer:ce,hideIfDisconnected:r,maintenanceInfo:Q[ce.id],viewMode:v,cardSize:p,spoolmanEnabled:B,hasUnlinkedSpools:U,linkedSpools:$,spoolmanUrl:E?.url,onGetAssignment:W,onUnassignSpool:(Ce,le,Le)=>z.mutate({printerId:Ce,amsId:le,trayId:Le}),amsThresholds:C?{humidityGood:Number(C.ams_humidity_good)||40,humidityFair:Number(C.ams_humidity_fair)||60,tempGood:Number(C.ams_temp_good)||28,tempFair:Number(C.ams_temp_fair)||35}:void 0,timeFormat:C?.time_format||"system",cameraViewMode:C?.camera_view_mode||"window",onOpenEmbeddedCamera:(Ce,le)=>A(Le=>new Map(Le).set(Ce,{id:Ce,name:le})),checkPrinterFirmware:C?.check_printer_firmware!==!1},ce.id))}),e&&a.jsx(C$e,{onClose:()=>n(!1),onAdd:ce=>H.mutate(ce),existingSerials:k?.map(ce=>ce.serial_number)||[]}),Array.from(N.values()).map((ce,Ce)=>a.jsx(HTe,{printerId:ce.id,printerName:ce.name,viewerIndex:Ce,onClose:()=>A(le=>{const Le=new Map(le);return Le.delete(ce.id),Le})},ce.id))]})}function E$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 of(t,e="bambu_studio"){let n;e==="orcaslicer"?n=`orcaslicer://open?file=${t}`:E$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 j$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 il(t){return j$e[t.toUpperCase()]||t}const D$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 (₽)"}],h9=768;function Cne(){const[t,e]=w.useState(()=>typeof window<"u"?window.innerWidth<h9:!1);return w.useEffect(()=>{const n=window.matchMedia(`(max-width: ${h9-1}px)`),r=i=>{e(i.matches)};return e(n.matches),n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[]),t}function bO({archiveId:t,libraryFileId:e,title:n,fileType:r,onClose:i}){const{t:s}=Dt(),{data:o}=Ze({queryKey:["settings"],queryFn:J.getSettings}),l=o?.preferred_slicer||"bambu_studio",c=e!=null,[d,u]=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),[k,P]=w.useState(0),[C,j]=w.useState(!1),[M,E]=w.useState(null),[B,L]=w.useState(!1),[U,D]=w.useState(!1),$=w.useRef(null),q=w.useRef(null),z=10,W=160,Q=240,te=.35;w.useEffect(()=>{const Pe=be=>{be.key==="Escape"&&i()};return window.addEventListener("keydown",Pe),()=>window.removeEventListener("keydown",Pe)},[i]),w.useEffect(()=>{if(x(!0),c){const Pe=(r||"").toLowerCase(),be=Pe==="3mf"||Pe==="stl",O=Pe==="gcode"||Pe==="3mf";f({has_model:be,has_gcode:O,has_source:!1,build_volume:{x:256,y:256,z:256},filament_colors:[]}),u(be?"3d":O?"gcode":null),x(!1);return}if(!t){f(null),u(null),x(!1);return}J.getArchiveCapabilities(t).then(Pe=>{f(Pe),Pe.has_model?u("3d"):Pe.has_gcode&&u("gcode"),x(!1)}).catch(()=>{f({has_model:!0,has_gcode:!1,has_source:!1,build_volume:{x:256,y:256,z:256},filament_colors:[]}),u("3d"),x(!1)})},[t,r,c]),w.useEffect(()=>{if(_(!0),A(null),P(0),c){const Pe=(r||"").toLowerCase();if(!e||Pe!=="3mf"){g(null),_(!1);return}J.getLibraryFilePlates(e).then(be=>g(be)).catch(()=>g(null)).finally(()=>_(!1));return}if(!t){g(null),_(!1);return}J.getArchivePlates(t).then(Pe=>g(Pe)).catch(()=>g(null)).finally(()=>_(!1))},[t,r,c,e]);const H=w.useMemo(()=>v?.plates??[],[v]),X=(v?.is_multi_plate??!1)&&H.length>1,Z=C&&X,ee=N==null?null:H.find(Pe=>Pe.index===N)??null,Se=Pe=>Pe.object_count??Pe.objects?.length??0,oe=H.reduce((Pe,be)=>Pe+Se(be),0),ie=ee?Se(ee):oe,me=ee?s("modelViewer.plateNumber",{number:ee.index}):s("modelViewer.allPlates"),se=H.length>0,ce=w.useRef(null),Ce=w.useRef(null),[le,Le]=w.useState(10),[V,K]=w.useState(3),fe=H.length>le,Y=Math.max(1,Math.ceil(H.length/le)),re=fe?H.slice(k*le,(k+1)*le):H;w.useEffect(()=>{if(!Z){Le(10),K(3);return}const Pe=ce.current,be=Ce.current;if(!Pe||!be)return;let O=0;const R=()=>{const ge=be.clientWidth,Ue=Math.floor(ge/210),ze=Math.max(3,Math.min(5,Ue||3));K(ke=>ke===ze?ke:ze);const $e=window.getComputedStyle(Pe),Re=Number.parseFloat($e.rowGap||"0"),ve=Pe.querySelector("button")?.getBoundingClientRect().height??44,Ne=be.clientHeight,we=Math.max(1,Math.floor((Ne+Re)/(ve+Re)))*ze,qe=Math.max(1,we-1);Le(ke=>ke===qe?ke:qe)},G=()=>{O&&cancelAnimationFrame(O),O=requestAnimationFrame(R)};G();const de=new ResizeObserver(G);return de.observe(be),de.observe(Pe),()=>{O&&cancelAnimationFrame(O),de.disconnect()}},[Z,H.length]),w.useEffect(()=>{if(!fe){P(0);return}P(Pe=>Math.min(Pe,Y-1))},[H.length,fe,Y]),w.useEffect(()=>{if(!fe||N==null)return;const Pe=H.findIndex(O=>O.index===N);if(Pe<0)return;const be=Math.floor(Pe/le);P(O=>O===be?O:be)},[H,le,N,fe]),w.useEffect(()=>{if(!Z){E(null),D(!1);return}if(U)return;const Pe=$.current,be=q.current;if(!Pe||!be)return;const O=Pe.clientHeight;if(!O)return;const R=Math.max(Q,O*te),G=Math.max(W,O-z-R),de=Math.min(be.scrollHeight,G);E(Math.max(W,de))},[Z,U,H.length,k,z,W,Q,te]),w.useEffect(()=>{if(!B)return;const Pe=O=>{const R=$.current;if(!R)return;const G=R.getBoundingClientRect(),de=G.height;if(!de)return;const ge=Math.max(Q,de*te),ae=Math.max(W,de-z-ge),Ue=Math.min(ae,Math.max(W,O.clientY-G.top));E(Ue)},be=()=>{L(!1),D(!0)};return document.addEventListener("mousemove",Pe),document.addEventListener("mouseup",be),document.body.style.cursor="row-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",Pe),document.removeEventListener("mouseup",be),document.body.style.cursor="",document.body.style.userSelect=""}},[B,z,W,Q,te]);const ue=c?(r||"").toLowerCase()==="3mf":!0,Fe=async()=>{if(!ue)return;const Pe=n||"model";try{if(c){const{token:be}=await J.createLibrarySlicerToken(e),O=J.getLibrarySlicerDownloadUrl(e,be,Pe);of(`${window.location.origin}${O}`,l)}else{const{token:be}=await J.createArchiveSlicerToken(t),O=J.getArchiveSlicerDownloadUrl(t,be,Pe);of(`${window.location.origin}${O}`,l)}}catch{if(c){const be=`${window.location.origin}${J.getLibraryFileDownloadUrl(e)}`;of(be,l)}else{const be=`${window.location.origin}${J.getArchiveForSlicer(t,Pe)}`;of(be,l)}}};return a.jsx("div",{className:`fixed inset-0 bg-black/70 flex items-center justify-center z-50 ${C?"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 ${C?"h-full max-w-none rounded-none":"h-[80vh] max-w-4xl rounded-xl"}`,onClick:Pe=>Pe.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1 mr-4",children:[a.jsx("h2",{className:"text-lg font-semibold text-white truncate",children:n}),se&&a.jsxs("span",{className:"text-xs text-bambu-gray bg-bambu-dark-tertiary/70 px-2 py-1 rounded whitespace-nowrap",children:[me,": ",s("modelViewer.objectCount",{count:ie})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs(Me,{variant:"secondary",size:"sm",onClick:Fe,disabled:!ue,children:[a.jsx(ta,{className:"w-4 h-4"}),s("modelViewer.openInSlicer")]}),a.jsx(Me,{variant:"secondary",size:"sm",onClick:()=>j(Pe=>!Pe),title:C?"Exit fullscreen":"Enter fullscreen",children:C?a.jsx(TF,{className:"w-4 h-4"}):a.jsx(WC,{className:"w-4 h-4"})}),a.jsx(Me,{variant:"ghost",size:"sm",onClick:i,children:a.jsx(Rt,{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&&u("3d"),disabled:!h.has_model,className:`flex items-center gap-2 px-6 py-3 text-sm font-medium transition-colors ${d==="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(ei,{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&&u("gcode"),disabled:!h.has_gcode,className:`flex items-center gap-2 px-6 py-3 text-sm font-medium transition-colors ${d==="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(Vhe,{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(at,{className:"w-8 h-8 animate-spin text-bambu-green"})}):d==="3d"&&h?a.jsxs("div",{ref:$,className:`w-full h-full flex flex-col ${Z?"gap-0 min-h-0":"gap-3"}`,children:[X&&a.jsxs("div",{ref:q,style:Z&&M!=null?{height:M}:void 0,className:`rounded-lg border border-bambu-dark-tertiary bg-bambu-dark p-3 ${Z?"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(ri,{className:"w-4 h-4"}),s("modelViewer.plates"),y&&a.jsx(at,{className:"w-3 h-3 animate-spin"})]}),a.jsxs("div",{className:Z?"flex flex-col min-h-0 flex-1":void 0,children:[a.jsx("div",{ref:Ce,className:Z?"min-h-0 overflow-hidden pr-1 flex-1":void 0,children:a.jsxs("div",{ref:ce,className:Z?"grid gap-2":"grid grid-cols-2 md:grid-cols-3 gap-2",style:Z?{gridTemplateColumns:`repeat(${V}, 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 ${Z?"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 ${Z?"w-8 h-8":"w-10 h-10"}`,children:a.jsx(ri,{className:`${Z?"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:`${Z?"text-xs":"text-sm"} text-white font-medium truncate`,children:s("modelViewer.allPlates")}),a.jsx("p",{className:`${Z?"text-[10px]":"text-xs"} text-bambu-gray truncate`,children:s("modelViewer.plateCount",{count:H.length})})]}),N==null&&a.jsx(na,{className:`${Z?"w-3.5 h-3.5":"w-4 h-4"} text-bambu-green flex-shrink-0`})]}),re.map(Pe=>a.jsxs("button",{type:"button",onClick:()=>A(Pe.index),className:`flex items-center rounded-lg border text-left transition-colors ${Z?"gap-1.5 p-1.5 w-full":"gap-2 p-2"} ${N===Pe.index?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary bg-bambu-dark-secondary hover:border-bambu-gray"}`,children:[Pe.has_thumbnail&&Pe.thumbnail_url?a.jsx("img",{src:Pe.thumbnail_url,alt:`Plate ${Pe.index}`,className:`${Z?"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 ${Z?"w-8 h-8":"w-10 h-10"}`,children:a.jsx(ri,{className:`${Z?"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:`${Z?"text-xs":"text-sm"} text-white font-medium truncate`,children:Pe.name||s("modelViewer.plateNumber",{number:Pe.index})}),a.jsx("p",{className:`${Z?"text-[10px]":"text-xs"} text-bambu-gray truncate`,children:s("modelViewer.objectCount",{count:Pe.object_count??Pe.objects?.length??0})})]}),N===Pe.index&&a.jsx(na,{className:`${Z?"w-3.5 h-3.5":"w-4 h-4"} text-bambu-green flex-shrink-0`})]},Pe.index))]})}),(ee||fe)&&a.jsxs("div",{className:"mt-auto pt-3 flex items-center gap-4 text-xs text-bambu-gray overflow-x-auto",children:[ee&&a.jsxs("div",{className:"flex items-center gap-3 whitespace-nowrap",children:[a.jsx("span",{children:s("modelViewer.plateNumber",{number:ee.index})}),ee.print_time_seconds!=null&&a.jsx("span",{children:s("modelViewer.eta",{minutes:Math.round(ee.print_time_seconds/60)})}),ee.filament_used_grams!=null&&a.jsxs("span",{children:[ee.filament_used_grams.toFixed(1)," g"]}),ee.filaments.length>0&&a.jsx("span",{children:s("modelViewer.filamentCount",{count:ee.filaments.length})})]}),fe&&a.jsxs("div",{className:`flex items-center gap-2 whitespace-nowrap ${ee?"ml-auto":""}`,children:[a.jsx("span",{children:s("modelViewer.pagination.pageOf",{current:k+1,total:Y})}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("button",{type:"button",onClick:()=>P(Pe=>Math.max(Pe-1,0)),disabled:k===0,className:`px-2 py-1 rounded border text-xs ${k===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 be=Math.max(0,k-Math.floor(2.5));const O=Math.min(Y,be+5);O-be<5&&(be=Math.max(0,O-5));const R=Array.from({length:O-be},(G,de)=>be+de);return a.jsxs(a.Fragment,{children:[be>0&&a.jsx("button",{type:"button",onClick:()=>P(0),className:`px-2 py-1 rounded border text-xs ${k===0?"border-bambu-green text-bambu-green":"border-bambu-dark-tertiary text-bambu-gray hover:text-white hover:border-bambu-gray"}`,children:"1"}),be>1&&a.jsx("span",{className:"px-1",children:"…"}),R.map(G=>a.jsx("button",{type:"button",onClick:()=>P(G),className:`px-2 py-1 rounded border text-xs ${k===G?"border-bambu-green text-bambu-green":"border-bambu-dark-tertiary text-bambu-gray hover:text-white hover:border-bambu-gray"}`,children:G+1},G)),O<Y-1&&a.jsx("span",{className:"px-1",children:"…"}),O<Y&&a.jsx("button",{type:"button",onClick:()=>P(Y-1),className:`px-2 py-1 rounded border text-xs ${k===Y-1?"border-bambu-green text-bambu-green":"border-bambu-dark-tertiary text-bambu-gray hover:text-white hover:border-bambu-gray"}`,children:Y})]})})(),a.jsx("button",{type:"button",onClick:()=>P(Pe=>Math.min(Pe+1,Y-1)),disabled:k>=Y-1,className:`px-2 py-1 rounded border text-xs ${k>=Y-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")})]})]})]})]})]}),Z&&a.jsx("div",{role:"separator","aria-orientation":"horizontal",onMouseDown:Pe=>{Pe.preventDefault(),L(!0),D(!0)},className:`h-2 cursor-row-resize flex items-center justify-center ${B?"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 ${Z?"min-h-0":""}`,children:a.jsx(NY,{url:c?J.getLibraryFileDownloadUrl(e):h.has_source?J.getSource3mfDownloadUrl(t):J.getArchiveDownload(t),fileType:r,buildVolume:h.build_volume,filamentColors:h.filament_colors,selectedPlateId:N,className:"w-full h-full"})})]}):d==="gcode"&&h?a.jsx(sQ,{gcodeUrl:c?J.getLibraryFileGcodeUrl(e):J.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 HN={"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 R$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,d=0;if(s!==o){const u=s-o;d=l>.5?u/(2-s-o):u/(s+o);const h=n/255,f=r/255,p=i/255;s===h?c=((f-p)/u+(f<p?6:0))/6:s===f?c=((p-h)/u+2)/6:c=((h-f)/u+4)/6}return c=c*360,l<.15?"Black":l>.85?"White":d<.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 vf(t){const e=t.replace("#","").toLowerCase().substring(0,6);return HN[e]?HN[e]:R$e(t)}function xO(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(HN[n])return HN[n]}return null}function oA(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=r9(o.tray_color);e.push({type:o.tray_type,color:l,colorName:vf(l),amsId:i.id,trayId:o.id,isHt:s,isExternal:!1,label:pO(i.id,o.id,s,!1),globalTrayId:BN(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=r9(i.tray_color),o=i.id??254,l=(t?.vt_tray?.length??0)>1;e.push({type:i.tray_type,color:s,colorName:vf(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 m9(t,e){if(!t?.filaments||t.filaments.length===0)return;const n=oA(e);if(n.length===0)return;const r=new Set,i=t.filaments.map(l=>{const c=l.tray_info_idx||"";let d=n.filter(v=>!r.has(v.globalTrayId));l.nozzle_id!=null&&(d=d.filter(v=>v.extruderId===l.nozzle_id));let u,h,f,p;if(c){const v=d.filter(g=>g.trayInfoIdx===c);v.length===1?u=v[0]:v.length>1&&(h=v.find(g=>g.type?.toUpperCase()===l.type?.toUpperCase()&&Fa(g.color)===Fa(l.color)),h||(f=v.find(g=>g.type?.toUpperCase()===l.type?.toUpperCase()&&Lc(g.color,l.color))),!h&&!f&&(p=v.find(g=>g.type?.toUpperCase()===l.type?.toUpperCase())))}!u&&!h&&!f&&!p&&(h=d.find(v=>v.type?.toUpperCase()===l.type?.toUpperCase()&&Fa(v.color)===Fa(l.color)),h||(f=d.find(v=>v.type?.toUpperCase()===l.type?.toUpperCase()&&Lc(v.color,l.color))),!h&&!f&&(p=d.find(v=>v.type?.toUpperCase()===l.type?.toUpperCase())));const x=u||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 F$e(t){return w.useMemo(()=>oA(t),[t])}function kne(t,e,n){const r=F$e(e),i=w.useMemo(()=>{if(!t?.filaments||t.filaments.length===0)return[];const c=new Set(Object.values(n));return t.filaments.map(d=>{const u=d.slot_id||0;if(u>0&&n[u]!==void 0){const P=n[u],C=r.find(j=>j.globalTrayId===P);if(C){const j=C.type?.toUpperCase()===d.type?.toUpperCase(),M=Fa(C.color)===Fa(d.color)||Lc(C.color,d.color);let E;return j&&M?E="match":j?E="type_only":E="mismatch",{...d,loaded:C,hasFilament:!0,typeMatch:j,colorMatch:M,status:E,isManual:!0}}}const h=d.tray_info_idx||"";let f=r.filter(P=>!c.has(P.globalTrayId));d.nozzle_id!=null&&(f=f.filter(P=>P.extruderId===d.nozzle_id));let p,x,v,g;if(h){const P=f.filter(C=>C.trayInfoIdx===h);P.length===1?p=P[0]:P.length>1&&(x=P.find(C=>C.type?.toUpperCase()===d.type?.toUpperCase()&&Fa(C.color)===Fa(d.color)),x||(v=P.find(C=>C.type?.toUpperCase()===d.type?.toUpperCase()&&Lc(C.color,d.color))),!x&&!v&&(g=P.find(C=>C.type?.toUpperCase()===d.type?.toUpperCase())))}!p&&!x&&!v&&!g&&(x=f.find(P=>P.type?.toUpperCase()===d.type?.toUpperCase()&&Fa(P.color)===Fa(d.color)),x||(v=f.find(P=>P.type?.toUpperCase()===d.type?.toUpperCase()&&Lc(P.color,d.color))),!x&&!v&&(g=f.find(P=>P.type?.toUpperCase()===d.type?.toUpperCase())));const y=p||x||v||g||void 0;y&&c.add(y.globalTrayId);const _=!!y,N=_,A=!!p||!!x||!!v;let k;return p||x||v?k="match":g?k="type_only":k="mismatch",{...d,loaded:y,hasFilament:_,typeMatch:N,colorMatch:A,status:k,isManual:!1}})},[t,r,n]),s=w.useMemo(()=>{if(i.length===0)return;const c=Math.max(...i.map(u=>u.slot_id||0));if(c<=0)return;const d=new Array(c).fill(-1);return i.forEach(u=>{u.slot_id&&u.slot_id>0&&(d[u.slot_id-1]=u.loaded?.globalTrayId??-1)}),d},[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 L$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 d of t){const u=d.slot_id||0;if(u>0&&n[u]!==void 0){const g=n[u],y=e.find(_=>_.globalTrayId===g);if(y){const _=y.type?.toUpperCase()===d.type?.toUpperCase(),N=Fa(y.color)===Fa(d.color)||Lc(y.color,d.color);_&&N?r++:_?i++:s++;continue}}let h=e.filter(g=>!o.has(g.globalTrayId));if(d.nozzle_id!=null){const g=h.filter(y=>y.extruderId===d.nozzle_id);g.length>0&&(h=g)}const f=h.find(g=>g.type?.toUpperCase()===d.type?.toUpperCase()&&Fa(g.color)===Fa(d.color)),p=f?void 0:h.find(g=>g.type?.toUpperCase()===d.type?.toUpperCase()&&Lc(g.color,d.color)),x=f||p?void 0:h.find(g=>g.type?.toUpperCase()===d.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 O$e(t,e,n){if(!t?.filaments||t.filaments.length===0)return;const r=oA(e);if(r.length===0)return;const i=new Set(Object.values(n)),s=[];for(const c of t.filaments){const d=c.slot_id||0;if(d>0&&n[d]!==void 0){s.push({slot_id:d,globalTrayId:n[d]});continue}let u=r.filter(v=>!i.has(v.globalTrayId));if(c.nozzle_id!=null){const v=u.filter(g=>g.extruderId===c.nozzle_id);v.length>0&&(u=v)}const h=u.find(v=>v.type?.toUpperCase()===c.type?.toUpperCase()&&Fa(v.color)===Fa(c.color)),f=h?void 0:u.find(v=>v.type?.toUpperCase()===c.type?.toUpperCase()&&Lc(v.color,c.color)),p=h||f?void 0:u.find(v=>v.type?.toUpperCase()===c.type?.toUpperCase()),x=h??f??p;x&&i.add(x.globalTrayId),s.push({slot_id:d,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 f9={useDefault:!0,manualMappings:{},autoConfigured:!1};function I$e(t,e,n,r,i,s){const o=lv({queries:t.map(x=>({queryKey:["printer-status",x],queryFn:()=>J.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(E=>E.id===x)?.name||`Printer ${x}`,A=oA(y),k=i[x]||f9,P=m9(n,y),C=k.useDefault?r:k.manualMappings,j=O$e(n,y,C),M=L$e(n?.filaments,A,C);return{printerId:x,printerName:N,status:y,isLoading:g?.isLoading??!1,loadedFilaments:A,autoMapping:P,finalMapping:j,matchStatus:M.status,exactMatches:M.exactMatches,typeOnlyMatches:M.typeOnlyMatches,missingTypes:M.missingTypes,totalSlots:M.totalSlots,config:k}}),[t,o,e,n,i,r]),c=o.some(x=>x.isLoading),d=(x,v)=>{s(g=>({...g,[x]:{...g[x]||f9,...v}}))},u=x=>{const v=l.find(_=>_.printerId===x);if(!v||!v.status||!n?.filaments)return;const g=m9(n,v.status);if(!g)return;const y={};g.forEach((_,N)=>{_!==-1&&(y[N+1]=_)}),d(x,{useDefault:!1,manualMappings:y,autoConfigured:!0})},h=()=>{for(const x of t)u(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:d,autoConfigureAll:h,autoConfigurePrinter:u,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}=Dt(),c=Qt(),[d,u]=w.useState(!1),[h,f]=w.useState(o),{data:p}=Ze({queryKey:["printer-status",t],queryFn:()=>J.getPrinterStatus(t),enabled:!!t}),{data:x}=Ze({queryKey:["spool-assignments",t],queryFn:()=>J.getAssignments(t),enabled:!!t}),{loadedFilaments:v,filamentComparison:g,hasTypeMismatch:y,hasColorMismatch:_}=kne(e,p,n),N=w.useMemo(()=>{const L=new Map;for(const U of x||[]){const D=U.ams_id===255,$=BN(U.ams_id,U.tray_id,D);L.set($,U.spool?.cost_per_kg??null)}return L},[x]),A=w.useMemo(()=>{const L=new Map;for(const U of x||[]){const D=U.ams_id===255,$=BN(U.ams_id,U.tray_id,D),q=U.spool;if(!q){L.set($,null);continue}L.set($,Math.max(0,Math.round((q.label_weight??0)-(q.weight_used??0))))}return L},[x]),k=w.useMemo(()=>{let L=0;for(const U of g){const D=U.loaded?.globalTrayId;if(D==null)continue;const q=N.get(D)??null??s;q>0&&(L+=U.used_grams/1e3*q)}return L},[g,N,s]),P=w.useMemo(()=>Array.from(N.values()).some(L=>L!=null&&L>0),[N]),C=e?.filaments&&e.filaments.length>0,j=e?.filaments?.some(L=>L.nozzle_id!=null)??!1;if(!C||!p)return null;const M=y?"#f97316":_?"#facc15":"#00ae42",E=(L,U)=>{if(L>0)if(U===""){const D={...n};delete D[L],r(D)}else r({...n,[L]:parseInt(U,10)})},B=async()=>{u(!0);try{await J.refreshPrinterStatus(t),await new Promise(L=>setTimeout(L,500)),await c.refetchQueries({queryKey:["printer-status",t]})}finally{u(!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(x1,{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(wl,{className:"w-4 h-4 ml-auto"}):a.jsx(Mn,{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:B,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:d,children:[a.jsx(Sr,{className:`w-3 h-3 ${d?"animate-spin":""}`}),a.jsx("span",{children:"Re-read"})]})]}),g.map((L,U)=>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: ${L.type} - ${vf(L.color)}`,children:a.jsx(x1,{className:"w-3 h-3",fill:L.color,stroke:L.color})}),a.jsxs("span",{className:"text-white truncate flex items-center gap-1",children:[j&&L.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:L.nozzle_id===1?l("printModal.leftNozzleTooltip"):l("printModal.rightNozzleTooltip"),children:L.nozzle_id===1?l("printModal.leftNozzle"):l("printModal.rightNozzle")}),L.type," ",a.jsxs("span",{className:"text-bambu-gray",children:["(",L.used_grams,"g)"]})]}),a.jsx("span",{className:"text-bambu-gray",children:"→"}),a.jsxs("select",{value:L.loaded?.globalTrayId??"",onChange:D=>E(L.slot_id||0,D.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 ${L.status==="match"?"border-bambu-green/50 text-bambu-green":L.status==="type_only"?"border-yellow-400/50 text-yellow-400":"border-orange-400/50 text-orange-400"} ${L.isManual?"ring-1 ring-blue-400/50":""}`,title:L.isManual?"Manually selected":"Auto-matched",children:[a.jsx("option",{value:"",className:"bg-bambu-dark text-bambu-gray",children:"-- Select slot --"}),v.filter(D=>L.nozzle_id==null||D.extruderId===L.nozzle_id).map(D=>{const $=A.get(D.globalTrayId),q=$!=null?l("printModal.slotRemainingShort",{grams:$,defaultValue:` - ${$}g left`}):"";return a.jsxs("option",{value:D.globalTrayId,className:"bg-bambu-dark text-white",children:[D.label,": ",D.type," (",D.colorName,")",q]},D.globalTrayId)})]}),L.status==="match"?a.jsx(na,{className:"w-3 h-3 text-bambu-green"}):L.status==="type_only"?a.jsx("span",{title:"Same type, different color",children:a.jsx(An,{className:"w-3 h-3 text-yellow-400"})}):a.jsx("span",{title:"Filament type not loaded",children:a.jsx(An,{className:"w-3 h-3 text-orange-400"})})]},U)),a.jsxs("div",{className:"text-xs text-bambu-gray",children:[l("printModal.totalCost")," ",a.jsx("span",{className:"text-white",children:k>0||P?`${i}${k.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 U$e({filamentReqs:t,availableFilaments:e,overrides:n,onChange:r}){const{t:i}=Dt(),s=w.useMemo(()=>{const c={};for(const d of e){const u=d.type.toUpperCase();c[u]||(c[u]=[]),c[u].push(d)}return c},[e]),o=t?.filaments;if(!o||o.length===0||e.length===0)return null;const l=(c,d)=>{if(d===""){const u={...n};delete u[c],r(u)}else{const[u,h]=d.split("|");r({...n,[c]:{type:u,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 d=n[c.slot_id],u=!!d,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} - ${vf(c.color)}`,children:a.jsx(x1,{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:u?`${d.type}|${d.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 ${u?"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," (",vf(c.color),")"]}),f.map((p,x)=>a.jsxs("option",{value:`${p.type}|${p.color}`,className:"bg-bambu-dark text-white",children:[p.type," (",vf(p.color),")"]},`${p.type}-${p.color}-${x}`))]}),u?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(lo,{className:"w-3 h-3"})}):a.jsx("span",{className:"w-3"})]},c.slot_id)})})]})}function B$e({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(ri,{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(An,{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(ri,{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(na,{className:"w-4 h-4 text-bambu-green flex-shrink-0"})]},i.index))})]})}function H$e({printerResult:t,filamentReqs:e,onUpdateConfig:n}){const r=Qt(),[i,s]=w.useState(!1),o=(d,u)=>{if(d<=0)return;const h={...t.config.manualMappings};u===""?delete h[d]:h[d]=parseInt(u,10),n({useDefault:!1,manualMappings:h,autoConfigured:!1})},l=async()=>{s(!0);try{await J.refreshPrinterStatus(t.printerId),await new Promise(d=>setTimeout(d,500)),await r.refetchQueries({queryKey:["printer-status",t.printerId]})}finally{s(!1)}},c=e.map(d=>{const u=d.slot_id||0,h=t.config.manualMappings[u];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()===d.type?.toUpperCase()&&Fa(N.color)===Fa(d.color)),y=g?void 0:t.loadedFilaments.find(N=>!v.has(N.globalTrayId)&&N.type?.toUpperCase()===d.type?.toUpperCase()&&Lc(N.color,d.color)),_=g||y?void 0:t.loadedFilaments.find(N=>!v.has(N.globalTrayId)&&N.type?.toUpperCase()===d.type?.toUpperCase());f=g??y??_}let x="mismatch";if(f){const v=f.type?.toUpperCase()===d.type?.toUpperCase(),g=Fa(f.color)===Fa(d.color)||Lc(f.color,d.color);v&&g?x="match":v&&(x="type_only")}return{req:d,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(Sr,{className:`w-3 h-3 ${i?"animate-spin":""}`}),a.jsx("span",{children:"Re-read"})]})]}),c.map(({req:d,loaded:u,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: ${d.type} - ${vf(d.color)}`,children:a.jsx(x1,{className:"w-3 h-3",fill:d.color,stroke:d.color})}),a.jsxs("span",{className:"text-white truncate",children:[d.type," ",a.jsxs("span",{className:"text-bambu-gray",children:["(",d.used_grams,"g)"]})]}),a.jsx("span",{className:"text-bambu-gray",children:"→"}),a.jsxs("select",{value:u?.globalTrayId??"",onChange:x=>o(d.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(na,{className:"w-3 h-3 text-bambu-green"}):h==="type_only"?a.jsx("span",{title:"Same type, different color",children:a.jsx(An,{className:"w-3 h-3 text-yellow-400"})}):a.jsx("span",{title:"Filament type not loaded",children:a.jsx(An,{className:"w-3 h-3 text-orange-400"})})]},p))]})}function $$e({printers:t,selectedPrinterIds:e,onMultiSelect:n,isLoading:r=!1,allowMultiple:i=!1,showInactive:s=!1,printerMappingResults:o,filamentReqs:l,onAutoConfigurePrinter:c,onUpdatePrinterConfig:d,assignmentMode:u="printer",onAssignmentModeChange:h,targetModel:f,onTargetModelChange:p,targetLocation:x,onTargetLocationChange:v,slicedForModel:g}){const[y,_]=w.useState(!1),N=s?t:t.filter(z=>z.is_active),A=w.useMemo(()=>{if(u!=="printer"||!g||y)return N;const z=N.filter(W=>W.model===g);return z.length>0?z:N},[N,u,g,y]),k=N.length-A.length,P=w.useMemo(()=>{const z=N.map(W=>W.model).filter(W=>!!W);return[...new Set(z)].sort()},[N]),C=w.useMemo(()=>{if(!f)return[];const z=N.filter(W=>W.model===f&&W.location).map(W=>W.location).filter(W=>!!W);return[...new Set(z)].sort()},[N,f]),j=h&&p&&P.length>0,M=i&&e.length>1&&o&&l?.filaments&&l.filaments.length>0&&c&&d;if(r)return a.jsx("div",{className:"flex justify-center py-8",children:a.jsx(at,{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(Va,{className:"w-4 h-4"}),"No ",s?"":"active ","printers available"]});const E=z=>{i?e.includes(z)?n(e.filter(W=>W!==z)):n([...e,z]):n([z])},B=()=>{n(A.map(z=>z.id))},L=()=>{n([])},U=(z,W,Q)=>{Q.stopPropagation(),!(!c||!d)&&(W?c(z):d(z,{useDefault:!0,manualMappings:{},autoConfigured:!1}))},D=z=>e.includes(z),$=e.length,q=z=>o?.find(W=>W.printerId===z);return a.jsxs("div",{className:"space-y-2 mb-6",children:[j&&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 ${u==="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(Nr,{className:"w-4 h-4"}),a.jsx("span",{className:"text-sm",children:"Specific Printer"})]}),a.jsxs("button",{type:"button",onClick:()=>{h("model"),n([]);const z=g&&P.includes(g)?g:P[0];p(z)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg border transition-colors ${u==="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(fh,{className:"w-4 h-4"}),a.jsxs("span",{className:"text-sm",children:["Any ",g||"Model"]})]})]}),u==="model"&&j&&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:z=>{p(z.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..."}),P.map(z=>a.jsx("option",{value:z,children:z},z))]})]}),f&&C.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:z=>v(z.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"}),C.map(z=>a.jsx("option",{value:z,children:z},z))]})]}),f&&a.jsxs("p",{className:"text-xs text-bambu-gray",children:["Scheduler will assign to first available idle ",f," printer",x?` in ${x}`:""]})]}),u==="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:$===0?"Select printers":`${$} printer${$!==1?"s":""} selected`}),a.jsxs("div",{className:"flex gap-2",children:[$<A.length&&a.jsx("button",{type:"button",onClick:B,className:"text-bambu-green hover:text-bambu-green/80 transition-colors",children:"Select all"}),$>0&&a.jsx("button",{type:"button",onClick:L,className:"text-bambu-gray hover:text-white transition-colors",children:"Clear"})]})]}),u==="printer"&&A.map(z=>{const W=D(z.id),Q=q(z.id),te=Q&&!Q.config.useDefault;return a.jsxs("div",{children:[a.jsxs("button",{type:"button",onClick:()=>E(z.id),className:`w-full flex items-center gap-3 p-3 rounded-lg border transition-colors ${W?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary bg-bambu-dark hover:border-bambu-gray"} ${z.is_active?"":"opacity-60"}`,children:[a.jsx("div",{className:`p-2 rounded-lg ${W?"bg-bambu-green/20":"bg-bambu-dark-tertiary"}`,children:a.jsx(Nr,{className:`w-5 h-5 ${W?"text-bambu-green":"text-bambu-gray"}`})}),a.jsxs("div",{className:"text-left flex-1",children:[a.jsxs("p",{className:"text-white font-medium",children:[z.name,!z.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:[z.model||"Unknown model"," • ",z.ip_address]})]}),i&&a.jsx("div",{className:`w-5 h-5 rounded border-2 flex items-center justify-center transition-colors ${W?"bg-bambu-green border-bambu-green":"border-bambu-gray/50"}`,children:W&&a.jsx(na,{className:"w-3 h-3 text-white"})})]}),W&&M&&Q&&a.jsxs("div",{className:"ml-4 mt-2 mb-3",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",onClick:H=>H.stopPropagation(),children:[a.jsx("input",{type:"checkbox",checked:te,onChange:H=>U(z.id,H.target.checked,H),className:"w-3.5 h-3.5 rounded border-bambu-gray/30 bg-bambu-dark-secondary text-bambu-green focus:ring-bambu-green focus:ring-offset-0"}),a.jsx("span",{className:"text-xs text-bambu-gray",children:"Custom mapping"})]}),a.jsxs("span",{className:`text-xs ml-2 ${Q.matchStatus==="full"?"text-bambu-green":Q.matchStatus==="partial"?"text-yellow-400":"text-orange-400"}`,children:["(",Q.exactMatches,"/",Q.totalSlots," matched)"]}),Q.isLoading&&a.jsx(Sr,{className:"w-3 h-3 text-bambu-gray animate-spin"}),te&&a.jsxs("button",{type:"button",onClick:H=>{H.stopPropagation(),c(z.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"]})]}),te&&a.jsx(H$e,{printerResult:Q,filamentReqs:l.filaments,onUpdateConfig:H=>d(z.id,H)})]})]},z.id)}),u==="printer"&&k>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(An,{className:"w-3 h-3 text-yellow-400"}),k," other printer",k>1?"s":""," hidden (different model) —",a.jsx("span",{className:"underline",children:"show all"})]}),u==="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"]})}),u==="printer"&&$===0&&a.jsxs("p",{className:"text-xs text-orange-400 mt-1 flex items-center gap-1",children:[a.jsx(Va,{className:"w-3 h-3"}),"Select at least one printer"]}),u==="model"&&!f&&a.jsxs("p",{className:"text-xs text-orange-400 mt-1 flex items-center gap-1",children:[a.jsx(Va,{className:"w-3 h-3"}),"Select a target printer model"]})]})}const V$e=[{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 q$e({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(ZC,{className:"w-4 h-4"}),a.jsx("span",{children:"Print Options"}),r?a.jsx(wl,{className:"w-4 h-4 ml-auto"}):a.jsx(Mn,{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:V$e.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 G$e({options:t,onChange:e,dateFormat:n="system",timeFormat:r="system",canControlPrinter:i=!0}){const[s,o]=w.useState(""),[l,c]=w.useState(""),[d,u]=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 k;t.scheduledTime?(k=new Date(t.scheduledTime),isNaN(k.getTime())&&(k=new Date,k.setHours(k.getHours()+1,0,0,0))):(k=new Date,k.setHours(k.getHours()+1,0,0,0),e({...t,scheduledTime:m3(k)})),o(h3(k,n)),c(VB(k,r)),u(!0),f(!0)}},[t.scheduleType,t.scheduledTime,n,r,e,t]);const v=k=>{e({...t,scheduleType:k})},g=(k,P)=>{const C=Fge(k,n),j=Lge(P);u(!!C),f(!!j),C&&j&&(C.setHours(j.hours,j.minutes,0,0),C>new Date&&e({...t,scheduledTime:m3(C)}))},y=k=>{o(k),g(k,l)},_=k=>{c(k),g(s,k)},N=k=>{const P=k.target.value;if(P){const C=new Date(P);isNaN(C.getTime())||(o(h3(C,n)),c(VB(C,r)),u(!0),f(!0),e({...t,scheduledTime:P}))}},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(qn,{className:"w-4 h-4"}),"ASAP"]}),a.jsxs("button",{type:"button",className:`flex-1 px-2 py-2 rounded-lg border text-sm flex items-center justify-center gap-1.5 transition-colors ${t.scheduleType==="scheduled"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>v("scheduled"),children:[a.jsx(da,{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(_X,{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 ${d?"border-bambu-dark-tertiary focus:border-bambu-green":"border-red-500"}`,value:s,onChange:k=>y(k.target.value),placeholder:Dge(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(da,{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:k=>_(k.target.value),placeholder:Rge(r)})})]}),a.jsx("input",{ref:p,type:"datetime-local",className:"sr-only",value:t.scheduledTime,onChange:N,tabIndex:-1}),(!d||!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:k=>e({...t,requirePreviousSuccess:k.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:k=>e({...t,autoOffAfter:k.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(fu,{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 Ng={bed_levelling:!0,flow_cali:!1,vibration_cali:!0,layer_inspect:!1,timelapse:!1},W$e={scheduleType:"asap",scheduledTime:"",requirePreviousSuccess:!1,autoOffAfter:!1};function Yd({mode:t,archiveId:e,libraryFileId:n,archiveName:r,queueItem:i,onClose:s,onSuccess:o}){const{t:l}=Dt(),c=Qt(),{showToast:d}=dn(),{hasPermission:u}=jr(),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??Ng.bed_levelling,flow_cali:i.flow_cali??Ng.flow_cali,vibration_cali:i.vibration_cali??Ng.vibration_cali,layer_inspect:i.layer_inspect??Ng.layer_inspect,timelapse:i.timelapse??Ng.timelapse}:Ng),[_,N]=w.useState(()=>{if(t==="edit-queue-item"&&i){let je="asap";i.manual_start?je="manual":i.scheduled_time&&!a9(i.scheduled_time)&&(je="scheduled");let Ve="";if(i.scheduled_time&&!a9(i.scheduled_time)){const ot=tr(i.scheduled_time)??new Date;Ve=m3(ot)}return{scheduleType:je,scheduledTime:Ve,requirePreviousSuccess:i.require_previous_success,autoOffAfter:i.auto_off_after}}return W$e}),[A,k]=w.useState(()=>{if(t==="edit-queue-item"&&i?.ams_mapping&&Array.isArray(i.ams_mapping)){const je={};return i.ams_mapping.forEach((Ve,ot)=>{Ve!==-1&&(je[ot+1]=Ve)}),je}return{}}),[P,C]=w.useState({}),[j,M]=w.useState(()=>t==="edit-queue-item"&&i?.target_model?"model":"printer"),[E,B]=w.useState(()=>t==="edit-queue-item"&&i?.target_model?i.target_model:null),[L,U]=w.useState(()=>t==="edit-queue-item"&&i?.target_location?i.target_location:null),[D,$]=w.useState(()=>{if(t==="edit-queue-item"&&i?.filament_overrides){const je={};for(const Ve of i.filament_overrides)je[Ve.slot_id]={type:Ve.type,color:Ve.color};return je}return{}}),[q]=w.useState(()=>t==="edit-queue-item"&&i?.printer_id?[i.printer_id]:[]),[z]=w.useState(()=>t==="edit-queue-item"&&i?i.plate_id:null),[W,Q]=w.useState(!1),[te,H]=w.useState({current:0,total:0}),[X,Z]=w.useState(new Set),ee=f.length,Se=f.length>0?f[0]:null,{data:oe}=Ze({queryKey:["settings"],queryFn:J.getSettings}),ie=il(oe?.currency||"USD"),me=oe?.default_filament_cost??0,{data:se,isLoading:ce}=Ze({queryKey:["printers"],queryFn:J.getPrinters}),{data:Ce}=Ze({queryKey:["archive",e],queryFn:()=>J.getArchive(e),enabled:!!e&&!h}),{data:le}=Ze({queryKey:["library-file",n],queryFn:()=>J.getLibraryFile(n),enabled:h&&!!n}),Le=Ce?.sliced_for_model||le?.sliced_for_model||null,{data:V,isError:K}=Ze({queryKey:["archive-plates",e],queryFn:()=>J.getArchivePlates(e),enabled:!!e&&!h,retry:!1}),{data:fe}=Ze({queryKey:["library-file-plates",n],queryFn:()=>J.getLibraryFilePlates(n),enabled:h&&!!n}),Y=h?fe:V,{data:re,isError:ue}=Ze({queryKey:["archive-filaments",e,x],queryFn:()=>J.getArchiveFilamentRequirements(e,x??void 0),enabled:!!e&&!h&&(x!==null||!Y?.is_multi_plate),retry:!1}),{data:Fe}=Ze({queryKey:["library-file-filaments",n,x],queryFn:()=>J.getLibraryFileFilamentRequirements(n,x??void 0),enabled:h&&!!n&&(x!==null||!Y?.is_multi_plate)}),Pe=!h&&(K||ue),be=h?Fe:re,O=w.useMemo(()=>{if(!(x===null||!Y?.plates?.length))return Y.plates.find(je=>je.index===x)?.name||void 0},[Y,x]),{data:R}=Ze({queryKey:["available-filaments",E,L],queryFn:()=>J.getAvailableFilaments(E,L??void 0),enabled:j==="model"&&!!E}),{data:G}=Ze({queryKey:["printer-status",Se],queryFn:()=>J.getPrinterStatus(Se),enabled:!!Se}),{amsMapping:de}=kne(be,G,A),ge=I$e(f,se,be,A,P,C);w.useEffect(()=>{Y?.plates&&Y.plates.length>=1&&!x&&v(Y.plates[0].index)},[Y,x]),w.useEffect(()=>{if(t==="edit-queue-item")return;const je=se?.filter(Ve=>Ve.is_active)||[];je.length===1&&f.length===0&&p([je[0].id])},[t,se,f.length]),w.useEffect(()=>{t==="edit-queue-item"?(JSON.stringify(f.sort())!==JSON.stringify(q.sort())||x!==z)&&(k({}),C({}),Z(new Set)):(k({}),C({}),Z(new Set))},[t,f,x,q,z]);const[ae,Ue]=w.useState(E),[ze,$e]=w.useState(x);w.useEffect(()=>{(E!==ae||x!==ze)&&(Ue(E),$e(x),(t!=="edit-queue-item"||ae!==null)&&$({}))},[E,x,ae,ze,t]),w.useEffect(()=>{if(!oe?.per_printer_mapping_expanded||f.length<=1)return;const je=f.filter(Ve=>{if(X.has(Ve))return!1;const ot=ge.printerResults.find(kt=>kt.printerId===Ve);return ot&&ot.status&&!ot.isLoading});je.length>0&&(Z(Ve=>{const ot=new Set(Ve);return je.forEach(kt=>ot.add(kt)),ot}),je.forEach(Ve=>{ge.autoConfigurePrinter(Ve)}))},[oe?.per_printer_mapping_expanded,f,X,ge]),w.useEffect(()=>{const je=Ve=>{Ve.key==="Escape"&&!W&&s()};return window.addEventListener("keydown",je),()=>window.removeEventListener("keydown",je)},[s,W]);const Re=Y?.is_multi_plate??!1,pe=Y?.plates??[],ve=st({mutationFn:je=>J.addToQueue(je)}),Ne=st({mutationFn:je=>J.updateQueueItem(i.id,je),onSuccess:()=>{c.invalidateQueries({queryKey:["queue"]}),d("Queue item updated"),o?.(),s()},onError:je=>{d(je.message||"Failed to update queue item","error")}}),xe=async je=>{if(je?.preventDefault(),j==="printer"&&f.length===0){d("Please select at least one printer","error");return}if(j==="model"&&!E){d("Please select a target printer model","error");return}Q(!0);const Ve=j==="model"?1:f.length;H({current:0,total:Ve});const ot={success:0,failed:0,errors:[]},kt=At=>{if(f.length>1){const Be=P[At];if(Be&&!Be.useDefault)return ge.getFinalMapping(At)}return de},Ft=Object.keys(D).length>0?Object.entries(D).map(([At,{type:Be,color:mt}])=>({slot_id:parseInt(At,10),type:Be,color:mt})):void 0,Vt=At=>({printer_id:j==="printer"?At:null,target_model:j==="model"?E:null,target_location:j==="model"?L:null,filament_overrides:j==="model"?Ft: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:At?kt(At):void 0,plate_id:x,scheduled_time:_.scheduleType==="scheduled"&&_.scheduledTime?new Date(_.scheduledTime).toISOString():void 0,...g});if(j==="model"){H({current:1,total:1});try{if(t==="reprint"){d("Model-based assignment only works with queue mode","error"),Q(!1);return}else if(t==="edit-queue-item"){const At={printer_id:null,target_model:E,target_location:L,filament_overrides:Ft||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 Ne.mutateAsync(At)}else await ve.mutateAsync(Vt(null));ot.success++}catch(At){ot.failed++,ot.errors.push(At.message)}}else for(let At=0;At<f.length;At++){const Be=f[At];H({current:At+1,total:f.length});try{if(t==="reprint"){const mt=kt(Be);h?await J.printLibraryFile(n,Be,{plate_id:x??void 0,plate_name:O,ams_mapping:mt,...g}):await J.reprintArchive(e,Be,{plate_id:x??void 0,plate_name:O,ams_mapping:mt,...g})}else if(t==="edit-queue-item"&&At===0){const mt=kt(Be),yt={printer_id:Be,target_model:null,target_location:null,require_previous_success:_.requirePreviousSuccess,auto_off_after:_.autoOffAfter,manual_start:_.scheduleType==="manual",ams_mapping:mt,plate_id:x,scheduled_time:_.scheduleType==="scheduled"&&_.scheduledTime?new Date(_.scheduledTime).toISOString():null,...g};await Ne.mutateAsync(yt)}else await ve.mutateAsync(Vt(Be));ot.success++}catch(mt){ot.failed++;const yt=se?.find(zt=>zt.id===Be)?.name||`Printer ${Be}`;ot.errors.push(`${yt}: ${mt.message}`)}}Q(!1),ot.failed===0?(t!=="reprint"&&(j==="model"?d(t==="edit-queue-item"?"Queue item updated":`Queued for any ${E}`):t==="edit-queue-item"?d("Queue item updated"):ot.success===1?d("Print queued for printer"):d(`Print queued for ${ot.success} printers`)),c.invalidateQueries({queryKey:["queue"]}),o?.(),s()):ot.success===0?d(`Failed: ${ot.errors[0]}`,"error"):(d(`${ot.success} succeeded, ${ot.failed} failed`,"error"),c.invalidateQueries({queryKey:["queue"]}))},we=W||Ne.isPending,qe=w.useMemo(()=>!(we||j==="printer"&&f.length===0||j==="model"&&!E||j==="model"&&t==="reprint"||Re&&!x),[f.length,j,E,t,Re,x,we]),nt=(()=>{const je=f.length;return t==="reprint"?{title:l(h?"queue.print":"queue.reprint"),icon:Nr,submitText:je>1?l("queue.printToPrinters",{count:je}):l("queue.print"),submitIcon:Nr,loadingText:te.total>1?l("queue.sendingProgress",{current:te.current,total:te.total}):l("queue.sending")}:t==="add-to-queue"?{title:l("queue.schedulePrint"),icon:da,submitText:je>1?l("queue.queueToPrinters",{count:je}):l("queue.addToQueue"),submitIcon:da,loadingText:te.total>1?l("queue.addingProgress",{current:te.current,total:te.total}):l("queue.adding")}:{title:l("queue.editQueueItem"),icon:Ga,submitText:l("common.save"),submitIcon:Ga,loadingText:te.total>1?l("queue.savingProgress",{current:te.current,total:te.total}):l("common.saving")}})(),De=nt.icon,We=nt.submitIcon,Oe=Se&&(h||(Re?x!==null:!0));return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:W?void 0:s,children:a.jsx(St,{className:"w-full max-w-lg max-h-[90vh] overflow-y-auto",onClick:je=>je.stopPropagation(),children:a.jsxs(Nt,{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(De,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:nt.title})]}),a.jsx(Me,{variant:"ghost",size:"sm",onClick:s,disabled:W,children:a.jsx(Rt,{className:"w-5 h-5"})})]}),a.jsxs("form",{onSubmit:xe,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(B$e,{plates:pe,isMultiPlate:Re,selectedPlate:x,onSelect:v}),a.jsx($$e,{printers:se||[],selectedPrinterIds:f,onMultiSelect:p,isLoading:ce,allowMultiple:!0,showInactive:t==="edit-queue-item",printerMappingResults:ge.printerResults,filamentReqs:be,onAutoConfigurePrinter:ge.autoConfigurePrinter,onUpdatePrinterConfig:ge.updatePrinterConfig,assignmentMode:t==="reprint"?"printer":j,onAssignmentModeChange:t!=="reprint"?M:void 0,targetModel:E,onTargetModelChange:t!=="reprint"?B:void 0,targetLocation:L,onTargetLocationChange:t!=="reprint"?U:void 0,slicedForModel:Le}),j==="model"&&E&&be&&R&&R.length>0&&a.jsx(U$e,{filamentReqs:be,availableFilaments:R,overrides:D,onChange:$}),Le&&j==="printer"&&f.length===1&&(()=>{const je=se?.find(Ve=>Ve.id===f[0]);return je&&je.model&&Le!==je.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(An,{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 ",Le,", but printing on ",je.model]})]}):null})(),Pe&&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(Va,{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."})]}),Oe&&!Pe&&f.length===1&&a.jsx(z$e,{printerId:Se,filamentReqs:be,manualMappings:A,onManualMappingChange:k,defaultExpanded:oe?.per_printer_mapping_expanded??!1,currencySymbol:ie,defaultCostPerKg:me}),(t==="reprint"||ee>0||j==="model"&&E)&&a.jsx(q$e,{options:g,onChange:y}),t!=="reprint"&&a.jsx(G$e,{options:_,onChange:N,dateFormat:oe?.date_format||"system",timeFormat:oe?.time_format||"system",canControlPrinter:u("printers:control")}),Ne.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:Ne.error?.message||"Failed to complete operation"}),a.jsxs("div",{className:`flex gap-3 ${t==="reprint"?"":"pt-2"}`,children:[a.jsx(Me,{type:"button",variant:"secondary",onClick:s,className:"flex-1",disabled:W,children:"Cancel"}),a.jsx(Me,{type:"submit",disabled:!qe,className:"flex-1",children:we?a.jsxs(a.Fragment,{children:[a.jsx(at,{className:"w-4 h-4 animate-spin"}),nt.loadingText]}):a.jsxs(a.Fragment,{children:[a.jsx(We,{className:"w-4 h-4"}),nt.submitText]})})]})]})]})})})}function K$e({onClose:t,initialFiles:e}){const{t:n}=Dt(),r=Qt(),{showToast:i}=dn(),s=w.useRef(null),[o,l]=w.useState(()=>e?.filter(k=>k.name.endsWith(".3mf")).map(k=>({file:k,status:"pending"}))||[]),[c,d]=w.useState(!1),[u,h]=w.useState(null);w.useEffect(()=>{const k=P=>{P.key==="Escape"&&t()};return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[t]);const f=st({mutationFn:k=>J.uploadArchivesBulk(k),onSuccess:k=>{h(k),r.invalidateQueries({queryKey:["archives"]}),r.invalidateQueries({queryKey:["archiveStats"]}),l(P=>P.map(C=>{const j=k.results.find(E=>E.filename===C.file.name),M=k.errors.find(E=>E.filename===C.file.name);return j?{...C,status:"success",archiveId:j.id}:M?{...C,status:"error",error:M.error}:C})),k.failed===0?i(`${k.uploaded} file${k.uploaded!==1?"s":""} uploaded`):k.uploaded===0?i(`Failed to upload ${k.failed} file${k.failed!==1?"s":""}`,"error"):i(`${k.uploaded} uploaded, ${k.failed} failed`,"warning")},onError:()=>{l(k=>k.map(P=>({...P,status:"error",error:"Upload failed"}))),i("Upload failed","error")}}),p=w.useCallback(k=>{k.preventDefault(),d(!0)},[]),x=w.useCallback(k=>{k.preventDefault(),d(!1)},[]),v=w.useCallback(k=>{k.preventDefault(),d(!1);const P=Array.from(k.dataTransfer.files).filter(C=>C.name.endsWith(".3mf"));P.length>0&&l(C=>[...C,...P.map(j=>({file:j,status:"pending"}))])},[]),g=w.useCallback(k=>{const P=Array.from(k.target.files||[]).filter(C=>C.name.endsWith(".3mf"));P.length>0&&l(C=>[...C,...P.map(j=>({file:j,status:"pending"}))]),s.current&&(s.current.value="")},[]),y=w.useCallback(k=>{l(P=>P.filter((C,j)=>j!==k))},[]),_=()=>{if(o.length===0)return;const k=o.filter(P=>P.status==="pending");k.length!==0&&(l(P=>P.map(C=>C.status==="pending"?{...C,status:"uploading"}:C)),f.mutate(k.map(P=>P.file)))},N=o.filter(k=>k.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(St,{className:"w-full max-w-2xl max-h-[90vh] flex flex-col",children:a.jsxs(Nt,{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(Rt,{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(Oa,{className:"w-12 h-12 mx-auto mb-4 text-bambu-gray"}),a.jsx("p",{className:"text-white mb-2",children:n("uploadModal.dragDrop")}),a.jsx("p",{className:"text-bambu-gray text-sm mb-4",children:n("uploadModal.or")}),a.jsx(Me,{variant:"secondary",onClick:()=>s.current?.click(),disabled: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((k,P)=>a.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[a.jsx($C,{className:"w-5 h-5 text-bambu-gray flex-shrink-0"}),a.jsx("span",{className:"flex-1 text-white text-sm truncate",children:k.file.name}),a.jsxs("span",{className:"text-xs text-bambu-gray",children:[(k.file.size/(1024*1024)).toFixed(1)," MB"]}),k.status==="pending"&&a.jsx("button",{onClick:()=>y(P),className:"text-bambu-gray hover:text-red-400 transition-colors",disabled:A,children:a.jsx(Rt,{className:"w-4 h-4"})}),k.status==="uploading"&&a.jsx(at,{className:"w-4 h-4 text-bambu-green animate-spin"}),k.status==="success"&&a.jsx(yr,{className:"w-4 h-4 text-bambu-green"}),k.status==="error"&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-xs text-red-400",children:k.error}),a.jsx(Va,{className:"w-4 h-4 text-red-400"})]})]},`${k.file.name}-${P}`))})}),u&&a.jsx("div",{className:"px-4 pb-4",children:a.jsx("div",{className:"p-3 bg-bambu-dark rounded-lg",children:a.jsxs("p",{className:"text-sm text-white",children:[a.jsx("span",{className:"text-bambu-green",children:u.uploaded})," ",n("uploadModal.uploaded"),u.failed>0&&a.jsxs(a.Fragment,{children:[", ",a.jsx("span",{className:"text-red-400",children:u.failed})," ",n("uploadModal.failed")]})]})})}),a.jsxs("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary",children:[a.jsx(Me,{variant:"secondary",onClick:t,className:"flex-1",children:n(u?"common.close":"common.cancel")}),!u&&a.jsx(Me,{onClick:_,disabled:N===0||A,className:"flex-1",children:A?a.jsxs(a.Fragment,{children:[a.jsx(at,{className:"w-4 h-4 animate-spin"}),n("uploadModal.uploading")]}):a.jsxs(a.Fragment,{children:[a.jsx(Oa,{className:"w-4 h-4"}),n("uploadModal.upload")," ",N>0&&`(${N})`]})})]})]})})})}const X$e=["adhesionFailure","spaghettiDetached","layerShift","cloggedNozzle","filamentRunout","warping","stringing","underExtrusion","powerFailure","userCancelled","other"],Y$e=["completed","failed","aborted","printing"];function Ane({archive:t,onClose:e,existingTags:n=[]}){const{t:r}=Dt();w.useEffect(()=>{const se=ce=>{ce.key==="Escape"&&e()};return window.addEventListener("keydown",se),()=>window.removeEventListener("keydown",se)},[e]);const i=Qt(),[s,o]=w.useState(t.print_name||""),[l,c]=w.useState(t.printer_id),[d,u]=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),[k,P]=w.useState(t.photos||[]),[C,j]=w.useState(t.external_url||""),[M,E]=w.useState(!1),[B,L]=w.useState(!1),U=w.useRef(null),D=w.useRef(null),$=w.useRef(null),{data:q}=Ze({queryKey:["printers"],queryFn:J.getPrinters}),{data:z}=Ze({queryKey:["projects"],queryFn:()=>J.getProjects()}),{data:W}=Ze({queryKey:["tags"],queryFn:J.getTags,enabled:n.length===0}),Q=n.length>0?n:W?.map(se=>se.name)||[],te=p.split(",").map(se=>se.trim()).filter(Boolean),H=p.includes(",")?p.substring(p.lastIndexOf(",")+1).trim().toLowerCase():p.trim().toLowerCase(),X=Q.filter(se=>!te.includes(se)&&(H===""||se.toLowerCase().includes(H))),Z=se=>{let ce;if(H&&!Q.includes(H)?ce=p.includes(",")?p.substring(0,p.lastIndexOf(",")).split(",").map(Ce=>Ce.trim()).filter(Boolean):[]:ce=te,!ce.includes(se)){const Ce=[...ce,se].join(", ");x(Ce)}$.current!==null&&clearTimeout($.current),U.current?.focus()},ee=se=>{const ce=te.filter(Ce=>Ce!==se).join(", ");x(ce)},Se=st({mutationFn:se=>J.updateArchive(t.id,se),onSuccess:()=>{i.invalidateQueries({queryKey:["archives"]}),i.invalidateQueries({queryKey:["projects"]}),e()}}),oe=async se=>{const ce=se.target.files?.[0];if(ce){E(!0);try{const Ce=await J.uploadArchivePhoto(t.id,ce);P(Ce.photos),i.invalidateQueries({queryKey:["archives"]})}catch(Ce){console.error("Failed to upload photo:",Ce)}finally{E(!1),D.current&&(D.current.value="")}}},ie=async se=>{try{const ce=await J.deleteArchivePhoto(t.id,se);P(ce.photos||[]),i.invalidateQueries({queryKey:["archives"]})}catch(ce){console.error("Failed to delete photo:",ce)}},me=se=>{se.preventDefault();const ce={print_name:s||void 0,printer_id:l,project_id:d,notes:h||void 0,tags:p||void 0,quantity:N,external_url:C||null};y!==t.status&&(ce.status=y),y==="failed"||y==="aborted"?ce.failure_reason=v||void 0:(t.status==="failed"||t.status==="aborted")&&(ce.failure_reason=null),Se.mutate(ce)};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:se=>se.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(Rt,{className:"w-5 h-5"})})]}),a.jsxs("form",{onSubmit:me,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:se=>o(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",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:se=>c(se.target.value?Number(se.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")}),q?.map(se=>a.jsx("option",{value:se.id,children:se.name},se.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:d??"",onChange:se=>u(se.target.value?Number(se.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")}),z?.map(se=>a.jsx("option",{value:se.id,children:se.name},se.id))]})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[a.jsx(Qme,{className:"w-4 h-4 inline mr-1"}),r("editArchive.itemsPrinted")]}),a.jsx("input",{type:"number",min:1,value:N,onChange:se=>A(Math.max(1,parseInt(se.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:se=>f(se.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(qb,{className:"w-4 h-4 inline mr-1"}),r("editArchive.externalLink")]}),a.jsx("input",{type:"url",value:C,onChange:se=>j(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",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")}),te.length>0&&a.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:te.map(se=>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(qh,{className:"w-3 h-3"}),se,a.jsx("button",{type:"button",onClick:()=>ee(se),className:"ml-0.5 text-bambu-gray hover:text-white",children:a.jsx(Rt,{className:"w-3 h-3"})})]},se))}),a.jsxs("div",{className:"relative",children:[a.jsx("input",{ref:U,type:"text",value:p,onChange:se=>x(se.target.value),onFocus:()=>{$.current!==null&&clearTimeout($.current),L(!0)},onBlur:()=>{$.current=window.setTimeout(()=>L(!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:te.length>0?r("editArchive.addMoreTags"):r("editArchive.tagsPlaceholder")}),B&&X.length>0&&a.jsxs("div",{className:"absolute top-full left-0 right-0 mt-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg z-10 max-h-40 overflow-y-auto",children:[a.jsxs("div",{className:"p-2 text-xs text-bambu-gray border-b border-bambu-dark-tertiary",children:[H?r("editArchive.matchingTags",{query:H}):r("editArchive.existingTags")," ",r("editArchive.clickToAdd")]}),a.jsx("div",{className:"p-2 flex flex-wrap gap-1.5",children:X.map(se=>a.jsx("button",{type:"button",onClick:()=>Z(se),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:se},se))})]})]})]}),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:se=>{_(se.target.value),se.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:Y$e.map(se=>a.jsx("option",{value:se,children:r(`editArchive.statuses.${se}`)},se))})]}),(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:se=>g(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:"",children:r("editArchive.selectReason")}),X$e.map(se=>a.jsx("option",{value:r(`editArchive.failureReasons.${se}`),children:r(`editArchive.failureReasons.${se}`)},se))]})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[a.jsx(db,{className:"w-4 h-4 inline mr-1"}),r("editArchive.photos")]}),a.jsxs("div",{className:"flex flex-wrap gap-2 mb-2",children:[k.map(se=>a.jsxs("div",{className:"relative group",children:[a.jsx("img",{src:J.getArchivePhotoUrl(t.id,se),alt:r("editArchive.printResult"),className:"w-20 h-20 object-cover rounded-lg border border-bambu-dark-tertiary"}),a.jsx("button",{type:"button",onClick:()=>ie(se),className:"absolute -top-1 -right-1 p-1 bg-red-500 rounded-full opacity-0 group-hover:opacity-100 transition-opacity",children:a.jsx(Yt,{className:"w-3 h-3 text-white"})})]},se)),a.jsxs("label",{className:"w-20 h-20 flex items-center justify-center border-2 border-dashed border-bambu-dark-tertiary rounded-lg cursor-pointer hover:border-bambu-green transition-colors",children:[a.jsx("input",{ref:D,type:"file",accept:"image/jpeg,image/png,image/webp",onChange:oe,className:"hidden",disabled:M}),M?a.jsx(at,{className:"w-6 h-6 text-bambu-gray animate-spin"}):a.jsx(Xn,{className:"w-6 h-6 text-bambu-gray"})]})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:r("editArchive.photosHelp")})]}),a.jsxs("div",{className:"flex gap-3 pt-2",children:[a.jsx(Me,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:r("common.cancel")}),a.jsxs(Me,{type:"submit",disabled:Se.isPending,className:"flex-1",children:[a.jsx(bs,{className:"w-4 h-4"}),Se.isPending?r("common.saving"):r("common.save")]})]})]})]})})}function Tne({x:t,y:e,items:n,onClose:r}){const i=w.useRef(null),[s,o]=w.useState(null),l=w.useRef(null),[c,d]=w.useState({x:t,y:e,visible:!1}),[u,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,k=e;t+g.width>y-N&&(A=Math.max(N,y-g.width-N)),A<N&&(A=N),e+g.height>_-N&&(k=Math.max(N,_-g.height-N)),k<N&&(k=N);const P=180,C=y-A-g.width,j=A;h(C<P&&j>P),d({x:A,y:k,visible:!0})}},[t,e]);const x=(g,y)=>{l.current&&(clearTimeout(l.current),l.current=null);const _=y.getBoundingClientRect(),N=window.innerHeight,A=300,C=N-_.top-8<A&&_.top>A;p(j=>({...j,[g]:C?"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] ${u?"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 Q$e({selectedIds:t,existingTags:e,onClose:n}){const r=Qt(),{showToast:i}=dn(),[s,o]=w.useState(""),[l,c]=w.useState(new Set),[d,u]=w.useState("add");w.useEffect(()=>{const v=g=>{g.key==="Escape"&&n()};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[n]);const h=st({mutationFn:async()=>{const v=Array.from(l);let g=0;for(const y of t)try{const _=await J.getArchive(y),N=_.tags?_.tags.split(",").map(k=>k.trim()).filter(Boolean):[];let A;d==="add"?A=[...new Set([...N,...v])]:A=N.filter(k=>!l.has(k)),await J.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:d,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(St,{className:"w-full max-w-md",children:a.jsxs(Nt,{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(qh,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-xl font-semibold text-white",children:d==="add"?"Add Tags":"Remove Tags"})]}),a.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:a.jsx(Rt,{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:[d==="add"?"Add":"Remove"," tags for ",t.length," selected archive",t.length!==1?"s":""]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Me,{size:"sm",variant:d==="add"?"primary":"secondary",onClick:()=>u("add"),children:"Add Tags"}),a.jsx(Me,{size:"sm",variant:d==="remove"?"primary":"secondary",onClick:()=>u("remove"),children:"Remove Tags"})]}),d==="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(Me,{size:"sm",variant:"secondary",onClick:p,disabled:!s.trim(),children:a.jsx(Xn,{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 ",d==="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 ${d==="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(Rt,{className:"w-3 h-3"})})]},v))})]})]}),a.jsxs("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary",children:[a.jsx(Me,{variant:"secondary",onClick:n,className:"flex-1",children:"Cancel"}),a.jsx(Me,{onClick:()=>h.mutate(),disabled:l.size===0||h.isPending,className:"flex-1",children:h.isPending?a.jsxs(a.Fragment,{children:[a.jsx(at,{className:"w-4 h-4 animate-spin"}),"Processing..."]}):a.jsxs(a.Fragment,{children:[a.jsx(qh,{className:"w-4 h-4"}),d==="add"?"Add Tags":"Remove Tags"]})})]})]})})})}function Z$e({selectedIds:t,onClose:e}){const n=Qt(),{showToast:r}=dn(),{data:i,isLoading:s}=Ze({queryKey:["projects"],queryFn:()=>J.getProjects()});w.useEffect(()=>{const u=h=>{h.key==="Escape"&&e()};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[e]);const o=()=>{n.invalidateQueries({queryKey:["archives"]}),n.invalidateQueries({queryKey:["projects"]}),n.invalidateQueries({queryKey:["project"]}),n.invalidateQueries({queryKey:["project-archives"]})},l=st({mutationFn:async u=>(await J.addArchivesToProject(u,t),u),onSuccess:u=>{const h=i?.find(f=>f.id===u);o(),r(`Added ${t.length} archive${t.length!==1?"s":""} to "${h?.name}"`),e()},onError:()=>{r("Failed to assign project","error")}}),c=st({mutationFn:async()=>{for(const u of t)await J.updateArchive(u,{project_id:null});return t.length},onSuccess:u=>{o(),r(`Removed ${u} archive${u!==1?"s":""} from project`),e()},onError:()=>{r("Failed to remove from project","error")}}),d=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(St,{className:"w-full max-w-md max-h-[80vh] flex flex-col",children:a.jsxs(Nt,{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:d,children:a.jsx(Rt,{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(at,{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:d,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(mi,{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(at,{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(u=>a.jsxs("button",{onClick:()=>l.mutate(u.id),disabled:d,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:u.color?`${u.color}20`:"rgb(var(--bambu-green) / 0.2)"},children:a.jsx(xs,{className:"w-4 h-4",style:{color:u.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:u.name}),a.jsxs("p",{className:"text-sm text-bambu-gray truncate",children:[u.archive_count," archive",u.archive_count!==1?"s":"",u.status&&` • ${u.status}`]})]}),l.isPending&&l.variables===u.id&&a.jsx(at,{className:"w-4 h-4 animate-spin text-bambu-gray shrink-0"})]},u.id)),(!i||i.length===0)&&a.jsx("p",{className:"text-center text-bambu-gray py-4",children:"No projects yet. Create one from the Projects page."})]})]}),a.jsx("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary shrink-0",children:a.jsx(Me,{variant:"secondary",onClick:e,className:"flex-1",disabled:d,children:"Cancel"})})]})})})}function J$e(t,e){return new Date(t,e+1,0).getDate()}function eVe(t,e){return new Date(t,e,1).getDay()}const tVe=["January","February","March","April","May","June","July","August","September","October","November","December"],nVe=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function rVe({archives:t,onArchiveClick:e,highlightedArchiveId:n}){const r=new Date,[i,s]=w.useState(r.getMonth()),[o,l]=w.useState(r.getFullYear()),[c,d]=w.useState(null),[u,h]=w.useState(null),f=w.useMemo(()=>{const k=new Map;return t.forEach(P=>{const C=tr(P.completed_at||P.created_at)||new Date,j=`${C.getFullYear()}-${String(C.getMonth()+1).padStart(2,"0")}-${String(C.getDate()).padStart(2,"0")}`,M=k.get(j)||[];M.push(P),k.set(j,M)}),k},[t]),p=J$e(o,i),x=eVe(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 k=0;k<x;k++)_.push(null);for(let k=1;k<=p;k++)_.push(k);const N=c?f.get(c)||[]:[],A=k=>{k!==c&&h(null),d(k)};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(Yl,{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:[tVe[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:nVe.map(k=>a.jsx("div",{className:"text-center text-xs text-bambu-gray py-2",children:k},k))}),a.jsx("div",{className:"grid grid-cols-7 gap-1",children:_.map((k,P)=>{if(k===null)return a.jsx("div",{className:"aspect-square"},`empty-${P}`);const C=`${o}-${String(i+1).padStart(2,"0")}-${String(k).padStart(2,"0")}`,j=f.get(C)||[],M=j.length>0,E=k===r.getDate()&&i===r.getMonth()&&o===r.getFullYear(),B=C===c,L=j.filter(D=>D.status==="completed").length,U=j.filter(D=>D.status==="failed").length;return a.jsxs("button",{onClick:()=>A(B?null:C),className:`aspect-square rounded-lg p-1 flex flex-col items-center justify-center transition-colors relative ${B?"bg-bambu-green text-white":E?"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 ${E&&!B?"text-bambu-green":""}`,children:k}),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 ${U>0&&L===0?"bg-red-400":U>0?"bg-yellow-400":"bg-green-400"}`}),a.jsx("span",{className:"text-xs font-medium",children:j.length})]})]},k)})}),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(k=>{const P=tr(k.completed_at||k.created_at)||new Date;return P.getMonth()===i&&P.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(k=>{const P=tr(k.completed_at||k.created_at)||new Date;return P.getMonth()===i&&P.getFullYear()===o&&k.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(k=>{const P=tr(k.completed_at||k.created_at)||new Date;return P.getMonth()===i&&P.getFullYear()===o&&k.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(k=>{const P=k.id===u||k.id===n;return a.jsxs("button",{onClick:()=>{h(k.id),e?.(k)},className:`w-full flex items-center gap-3 p-2 rounded-lg transition-colors text-left ${P?"":"hover:bg-bambu-dark-tertiary"}`,style:P?{outline:"4px solid #facc15",outlineOffset:"2px"}:void 0,children:[k.thumbnail_path?a.jsx("img",{src:J.getArchiveThumbnail(k.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:k.print_name||k.filename}),a.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[a.jsx("span",{className:k.status==="failed"?"text-red-400":"text-green-400",children:k.status==="failed"?"Failed":"Completed"}),k.filament_color&&a.jsx("div",{className:"flex gap-0.5",children:k.filament_color.split(",").map((C,j)=>a.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:C}},j))})]})]})]},k.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 Mne({archiveId:t,archiveName:e,onClose:n}){const r=J.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(Rt,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"p-6 flex flex-col items-center",children:[a.jsx("p",{className:"text-sm text-bambu-gray mb-4 text-center truncate max-w-full",children:e}),a.jsx("div",{className:"bg-white p-4 rounded-lg mb-4",children:a.jsx("img",{src:r,alt:"QR Code",className:"w-64 h-64"})}),a.jsx("p",{className:"text-xs text-bambu-gray mb-4 text-center",children:"Scan to open this archive"}),a.jsxs(Me,{onClick:i,className:"w-full",children:[a.jsx(ga,{className:"w-4 h-4"}),"Download QR Code"]})]})]})})}function Pne({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 d=n[s],u=J.getArchivePhotoUrl(t,d),h=()=>{const p=document.createElement("a");p.href=u,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(Me,{variant:"secondary",size:"sm",onClick:h,children:[a.jsx(ga,{className:"w-4 h-4"}),"Download"]}),i&&a.jsx(Me,{variant:"secondary",size:"sm",onClick:f,className:"text-red-400 hover:text-red-300",children:a.jsx(Yt,{className:"w-4 h-4"})}),a.jsx("button",{onClick:r,className:"p-2 text-bambu-gray hover:text-white transition-colors",children:a.jsx(Rt,{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(Yl,{className:"w-8 h-8 text-white"})}),a.jsx("img",{src:u,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:J.getArchivePhotoUrl(t,p),alt:`Thumbnail ${x+1}`,className:"w-full h-full object-cover"})},p))})]}),l&&a.jsx(xn,{title:"Delete Photo",message:"Delete this photo? This cannot be undone.",confirmText:"Delete",variant:"danger",onConfirm:()=>{i?.(d),c(!1)},onCancel:()=>c(!1)})]})}function Xi(t){this.content=t}Xi.prototype={constructor:Xi,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 Xi(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 Xi(n)},addToStart:function(t,e){return new Xi([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new Xi(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 Xi(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=Xi.from(t),t.size?new Xi(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=Xi.from(t),t.size?new Xi(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=Xi.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}};Xi.from=function(t){if(t instanceof Xi)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new Xi(e)};function Ene(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=Ene(i.content,s.content,n+1);if(o!=null)return o}n+=i.nodeSize}}function jne(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 d=0,u=Math.min(o.text.length,l.text.length);for(;d<u&&o.text[o.text.length-d-1]==l.text[l.text.length-d-1];)d++,n--,r--;return{a:n,b:r}}if(o.content.size||l.content.size){let d=jne(o.content,l.content,n-1,r-1);if(d)return d}n-=c,r-=c}}class Mt{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],d=l+c.nodeSize;if(d>e&&r(c,i+l,s||null,o)!==!1&&c.content.size){let u=l+1;c.nodesBetween(Math.max(0,e-u),Math.min(c.content.size,n-u),r,i+u)}l=d}}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 d=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&&d||l.isTextblock)&&r&&(o?o=!1:s+=r),s+=d},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 Mt(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 Mt(r,i)}cutByIndex(e,n){return e==n?Mt.empty:e==0&&n==this.content.length?this:new Mt(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 Mt(i,s)}addToStart(e){return new Mt([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new Mt(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 Ene(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return jne(this,e,n,r)}findIndex(e){if(e==0)return w_(0,e);if(e==this.size)return w_(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?w_(n+1,s):w_(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 Mt.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new Mt(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return Mt.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 Mt(n||e,r)}static from(e){if(!e)return Mt.empty;if(e instanceof Mt)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new Mt([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}Mt.empty=new Mt([],0);const YE={index:0,offset:0};function w_(t,e){return YE.index=t,YE.offset=e,YE}function $N(t,e){if(t===e)return!0;if(!(t&&typeof t=="object")||!(e&&typeof e=="object"))return!1;let n=Array.isArray(t);if(Array.isArray(e)!=n)return!1;if(n){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!$N(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!$N(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let Kr=class wR{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,r=!1;for(let i=0;i<e.length;i++){let s=e[i];if(this.eq(s))return e;if(this.type.excludes(s.type))n||(n=e.slice(0,i));else{if(s.type.excludes(this.type))return e;!r&&s.type.rank>this.type.rank&&(n||(n=e.slice(0,i)),n.push(this),r=!0),n&&n.push(s)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return e.slice(0,n).concat(e.slice(n+1));return e}isInSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return!0;return!1}eq(e){return this==e||this.type==e.type&&$N(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[n.type];if(!r)throw new RangeError(`There is no mark type ${n.type} in this schema`);let i=r.create(n.attrs);return r.checkAttrs(i.attrs),i}static sameSet(e,n){if(e==n)return!0;if(e.length!=n.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(n[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return wR.none;if(e instanceof wR)return[e];let n=e.slice();return n.sort((r,i)=>r.type.rank-i.type.rank),n}};Kr.none=[];class VN 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=Rne(this.content,e+this.openStart,n);return r&&new qt(r,this.openStart,this.openEnd)}removeBetween(e,n){return new qt(Dne(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(Mt.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(Mt.empty,0,0);function Dne(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(Dne(s.content,e-i-1,n-i-1)))}function Rne(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=Rne(o.content,e-s-1,n,o);return l&&t.replaceChild(i,o.copy(l))}function aVe(t,e,n){if(n.openStart>t.depth)throw new VN("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new VN("Inconsistent open depths");return Fne(t,e,n,0)}function Fne(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=Fne(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 Sf(o,l.cut(0,t.parentOffset).append(n.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=iVe(n,t);return Sf(s,One(t,o,l,e,r))}else return Sf(s,qN(t,e,r))}function Lne(t,e){if(!e.type.compatibleContent(t.type))throw new VN("Cannot join "+e.type.name+" onto "+t.type.name)}function SR(t,e,n){let r=t.node(n);return Lne(r,e.node(n)),r}function wf(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 Ky(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&&(wf(t.nodeAfter,r),s++));for(let l=s;l<o;l++)wf(i.child(l),r);e&&e.depth==n&&e.textOffset&&wf(e.nodeBefore,r)}function Sf(t,e){return t.type.checkContent(e),t.copy(e)}function One(t,e,n,r,i){let s=t.depth>i&&SR(t,e,i+1),o=r.depth>i&&SR(n,r,i+1),l=[];return Ky(null,t,i,l),s&&o&&e.index(i)==n.index(i)?(Lne(s,o),wf(Sf(s,One(t,e,n,r,i+1)),l)):(s&&wf(Sf(s,qN(t,e,i+1)),l),Ky(e,n,i,l),o&&wf(Sf(o,qN(n,r,i+1)),l)),Ky(r,null,i,l),new Mt(l)}function qN(t,e,n){let r=[];if(Ky(null,t,n,r),t.depth>n){let i=SR(t,e,n+1);wf(Sf(i,qN(t,e,n+1)),r)}return Ky(e,null,n,r),new Mt(r)}function iVe(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(Mt.from(i));return{start:i.resolveNoCache(t.openStart+n),end:i.resolveNoCache(i.content.size-t.openEnd-n)}}class V0{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 Kr.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 GN(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),d=s-c;if(r.push(o,l,i+c),!d||(o=o.child(l),o.isText))break;s=d-1,i+=c+1}return new V0(n,r,s)}static resolveCached(e,n){let r=p9.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 p9.set(e,r=new sVe);let i=r.elts[r.i]=V0.resolve(e,n);return r.i=(r.i+1)%oVe,i}}class sVe{constructor(){this.elts=[],this.i=0}}const oVe=12,p9=new WeakMap;class GN{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 lVe=Object.create(null);let Bh=class _R{constructor(e,n,r,i=Kr.none){this.type=e,this.attrs=n,this.marks=i,this.content=r||Mt.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,n,r,i=0){this.content.nodesBetween(e,n,r,i,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,n,r,i){return this.content.textBetween(e,n,r,i)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,n,r){return this.type==e&&$N(this.attrs,n||e.defaultAttrs||lVe)&&Kr.sameSet(this.marks,r||Kr.none)}copy(e=null){return e==this.content?this:new _R(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new _R(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),d=i.node(o).content.cut(i.pos-l,s.pos-l);return new qt(d,i.depth-o,s.depth-o)}replace(e,n,r){return aVe(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 V0.resolveCached(this,e)}resolveNoCache(e){return V0.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()+")"),Ine(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=Mt.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=Kr.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(!Kr.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=Mt.fromJSON(e,n.content),s=e.nodeType(n.type).create(n.attrs,i,r);return s.type.checkAttrs(s.attrs),s}};Bh.prototype.text=void 0;class WN extends Bh{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):Ine(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 WN(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new WN(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 Ine(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class Kf{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new cVe(e,n);if(r.next==null)return Kf.empty;let i=zne(r);r.next&&r.err("Unexpected trailing text");let s=gVe(pVe(i));return bVe(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 Mt.from(l.map(d=>d.createAndFill()));for(let d=0;d<o.next.length;d++){let{type:u,next:h}=o.next[d];if(!(u.isText||u.hasRequiredAttrs())&&i.indexOf(h)==-1){i.push(h);let f=s(h,l.concat(u));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(`
- `)}}Kf.empty=new Kf(!0);class cVe{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 zne(t){let e=[];do e.push(dVe(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function dVe(t){let e=[];do e.push(uVe(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function uVe(t){let e=fVe(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=hVe(t,e);else break;return e}function g9(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function hVe(t,e){let n=g9(t),r=n;return t.eat(",")&&(t.next!="}"?r=g9(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function mVe(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 fVe(t){if(t.eat("(")){let e=zne(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=mVe(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 pVe(t){let e=[[]];return i(s(t,0),n()),e;function n(){return e.push([])-1}function r(o,l,c){let d={term:c,to:l};return e[o].push(d),d}function i(o,l){o.forEach(c=>c.to=l)}function s(o,l){if(o.type=="choice")return o.exprs.reduce((c,d)=>c.concat(s(d,l)),[]);if(o.type=="seq")for(let c=0;;c++){let d=s(o.exprs[c],l);if(c==o.exprs.length-1)return d;i(d,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 d=0;d<o.min;d++){let u=n();i(s(o.expr,c),u),c=u}if(o.max==-1)i(s(o.expr,c),c);else for(let d=o.min;d<o.max;d++){let u=n();r(c,u),i(s(o.expr,c),u),c=u}return[r(c)]}else{if(o.type=="name")return[r(l,void 0,o.value)];throw new Error("Unknown expr type")}}}}function Une(t,e){return e-t}function b9(t,e){let n=[];return r(e),n.sort(Une);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 gVe(t){let e=Object.create(null);return n(b9(t,0));function n(r){let i=[];r.forEach(o=>{t[o].forEach(({term:l,to:c})=>{if(!l)return;let d;for(let u=0;u<i.length;u++)i[u][0]==l&&(d=i[u][1]);b9(t,c).forEach(u=>{d||i.push([l,d=[]]),d.indexOf(u)==-1&&d.push(u)})})});let s=e[r.join(",")]=new Kf(r.indexOf(t.length-1)>-1);for(let o=0;o<i.length;o++){let l=i[o][1].sort(Une);s.next.push({type:i[o][0],next:e[l.join(",")]||n(l)})}return s}}function bVe(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:d}=i.next[l];o.push(c.name),s&&!(c.isText||c.hasRequiredAttrs())&&(s=!1),r.indexOf(d)==-1&&r.push(d)}s&&e.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Bne(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 Hne(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 $ne(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 Vne(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new yVe(t,r,e[r]);return n}let x9=class qne{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=Vne(e,r.attrs),this.defaultAttrs=Bne(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==Kf.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:Hne(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Bh(this,this.computeAttrs(e),Mt.from(n),Kr.setFrom(r))}createChecked(e=null,n,r){return n=Mt.from(n),this.checkContent(n),new Bh(this,this.computeAttrs(e),n,Kr.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=Mt.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(Mt.empty,!0);return s?new Bh(this,e,n.append(s),Kr.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){$ne(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:Kr.none:e}static compile(e,n){let r=Object.create(null);e.forEach((s,o)=>r[s]=new qne(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 xVe(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 yVe{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?xVe(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class lA{constructor(e,n,r,i){this.name=e,this.rank=n,this.schema=r,this.spec=i,this.attrs=Vne(e,i.attrs),this.excluded=null;let s=Bne(this.attrs);this.instance=s?new Kr(this,s):null}create(e=null){return!e&&this.instance?this.instance:new Kr(this,Hne(this.attrs,e))}static compile(e,n){let r=Object.create(null),i=0;return e.forEach((s,o)=>r[s]=new lA(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){$ne(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class Gne{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=Xi.from(e.nodes),n.marks=Xi.from(e.marks||{}),this.nodes=x9.compile(this.spec.nodes,this),this.marks=lA.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]=Kf.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?y9(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==""?[]:y9(this,o.split(" "))}this.nodeFromJSON=i=>Bh.fromJSON(this,i),this.markFromJSON=i=>Kr.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 x9){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 WN(r,r.defaultAttrs,e,Kr.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 y9(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 vVe(t){return t.tag!=null}function wVe(t){return t.style!=null}let Xy=class NR{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(i=>{if(vVe(i))this.tags.push(i);else if(wVe(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 w9(this,n,!1);return r.addAll(e,Kr.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new w9(this,n,!0);return r.addAll(e,Kr.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(NVe(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=S9(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=S9(o)),o.node||o.ignore||o.mark||(o.node=i)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new NR(e,NR.schemaRules(e)))}};const Wne={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},SVe={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Kne={ol:!0,ul:!0},q0=1,CR=2,Yy=4;function v9(t,e,n){return e!=null?(e?q0:0)|(e==="full"?CR:0):t&&t.whitespace=="pre"?q0|CR:n&~Yy}class S_{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=Kr.none,this.match=s||(o&Yy?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(Mt.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&q0)){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=Mt.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(Mt.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&&!Wne.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class w9{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=v9(null,n.preserveWhitespace,0)|(r?Yy:0);i?s=new S_(i.type,i.attrs,Kr.none,!0,n.topMatch||i.type.contentMatch,o):r?s=new S_(null,null,Kr.none,!0,null,o):s=new S_(e.schema.topNodeType,null,Kr.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&CR?"full":this.localPreserveWS||(i.options&q0)>0,{schema:o}=this.parser;if(s==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(s)if(s==="full")r=r.replace(/\r\n?/g,`
- `);else if(o.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(o.linebreakReplacement.create())){let l=r.split(/\r?\n|\r/);for(let c=0;c<l.length;c++)c&&this.insertNode(o.linebreakReplacement.create(),n,!0),l[c]&&this.insertNode(o.text(l[c]),n,!/\S/.test(l[c]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let l=i.content[i.content.length-1],c=e.previousSibling;(!l||c&&c.nodeName=="BR"||l.isText&&/[ \t\r\n\u000c]$/.test(l.text))&&(r=r.slice(1))}r&&this.insertNode(o.text(r),n,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,n,r){let i=this.localPreserveWS,s=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let o=e.nodeName.toLowerCase(),l;Kne.hasOwnProperty(o)&&this.parser.normalizeLists&&_Ve(e);let c=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(c?c.ignore:SVe.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 d,u=this.needsBlock;if(Wne.hasOwnProperty(o))s.content.length&&s.content[0].isInline&&this.open&&(this.open--,s=this.top),d=!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),d&&this.sync(s),this.needsBlock=u}else{let d=this.readStyles(e,n);d&&this.addElementByRule(e,c,d,c.consuming===!1?l:void 0)}this.localPreserveWS=i}leafFallback(e,n){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
- `),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(e,n){let r=e.style;if(r&&r.length)for(let i=0;i<this.parser.matchedStyles.length;i++){let s=this.parser.matchedStyles[i],o=r.getPropertyValue(s);if(o)for(let l=void 0;;){let c=this.parser.matchStyle(s,o,this,l);if(!c)break;if(c.ignore)return null;if(c.clearMark?n=n.filter(d=>!c.clearMark(d)):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],d=c.findWrapping(e);if(d&&(!i||i.length>d.length+l)&&(i=d,s=c,!d.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=Kr.none;for(let l of i.concat(e.marks))(s.type?s.type.allowsMarkType(l.type):_9(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=v9(e,s,o.options);o.options&Yy&&o.content.length==0&&(l|=Yy);let c=Kr.none;return r=r.filter(d=>(o.type?o.type.allowsMarkType(d.type):_9(d.type,e))?(c=d.addToSet(c),!1):!0),this.nodes.push(new S_(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|=q0)}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 d=n[l];if(d==""){if(l==n.length-1||l==0)continue;for(;c>=s;c--)if(o(l-1,c))return!0;return!1}else{let u=c>0||c==0&&i?this.nodes[c].type:r&&c>=s?r.node(c-s).type:null;if(!u||u.name!=d&&!u.isInGroup(d))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 _Ve(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Kne.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function NVe(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function S9(t){let e={};for(let n in t)e[n]=t[n];return e}function _9(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:d,next:u}=l.edge(c);if(d==e||s.indexOf(u)<0&&o(u))return!0}};if(o(i.contentMatch))return!0}}class ip{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=QE(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 d=o.marks[c];if(!this.marks[d.type.name]){c++;continue}if(!d.eq(s[l][0])||d.type.spec.spanning===!1)break;l++,c++}for(;l<s.length;)i=s.pop()[1];for(;c<o.marks.length;){let d=o.marks[c++],u=this.serializeMark(d,o.isInline,n);u&&(s.push([d,i]),i.appendChild(u.dom),i=u.contentDOM||u.dom)}}i.appendChild(this.serializeNodeInner(o,n))}),r}serializeNodeInner(e,n){let{dom:r,contentDOM:i}=i1(QE(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&&i1(QE(r),i(e,n),null,e.attrs)}static renderSpec(e,n,r=null,i){return i1(e,n,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new ip(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=N9(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return N9(e.marks)}}function N9(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function QE(t){return t.document||window.document}const C9=new WeakMap;function CVe(t){let e=C9.get(t);return e===void 0&&C9.set(t,e=kVe(t)),e}function kVe(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 i1(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=CVe(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),d=e[1],u=1;if(d&&typeof d=="object"&&d.nodeType==null&&!Array.isArray(d)){u=2;for(let h in d)if(d[h]!=null){let f=h.indexOf(" ");f>0?c.setAttributeNS(h.slice(0,f),h.slice(f+1),d[h]):h=="style"&&c.style?c.style.cssText=d[h]:c.setAttribute(h,d[h])}}for(let h=u;h<e.length;h++){let f=e[h];if(f===0){if(h<e.length-1||h>u)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}=i1(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 Xne=65535,Yne=Math.pow(2,16);function AVe(t,e){return t+e*Yne}function k9(t){return t&Xne}function TVe(t){return(t-(t&Xne))/Yne}const Qne=1,Zne=2,s1=4,Jne=8;class kR{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&Jne)>0}get deletedBefore(){return(this.delInfo&(Qne|s1))>0}get deletedAfter(){return(this.delInfo&(Zne|s1))>0}get deletedAcross(){return(this.delInfo&s1)>0}}class Mo{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&Mo.empty)return Mo.empty}recover(e){let n=0,r=k9(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+TVe(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 d=this.ranges[l+s],u=this.ranges[l+o],h=c+d;if(e<=h){let f=d?e==c?-1:e==h?1:n:n,p=c+i+(f<0?0:u);if(r)return p;let x=e==(n<0?c:h)?null:AVe(l/3,e-c),v=e==c?Zne:e==h?Qne:s1;return(n<0?e!=c:e!=h)&&(v|=Jne),new kR(p,v,x)}i+=u-d}return r?e+i:new kR(e+i,0,null)}touches(e,n){let r=0,i=k9(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 d=this.ranges[l+s],u=c+d;if(e<=u&&l==i*3)return!0;r+=this.ranges[l+o]-d}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),d=this.ranges[i+n],u=this.ranges[i+r];e(l,l+d,c,c+u),s+=u-d}}invert(){return new Mo(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Mo.empty:new Mo(e<0?[0,-e,0]:[0,0,e])}}Mo.empty=new Mo([]);class G0{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 G0(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 G0;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 kR(e,i,null)}}const ZE=Object.create(null);class _s{getMap(){return Mo.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=ZE[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 ZE)throw new RangeError("Duplicate use of step JSON ID "+e);return ZE[e]=n,n.prototype.jsonID=e,n}}class ni{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new ni(e,null)}static fail(e){return new ni(null,e)}static fromReplace(e,n,r,i){try{return ni.ok(e.replace(n,r,i))}catch(s){if(s instanceof VN)return ni.fail(s.message);throw s}}}function yO(t,e,n){let r=[];for(let i=0;i<t.childCount;i++){let s=t.child(i);s.content.size&&(s=s.copy(yO(s.content,e,s))),s.isInline&&(s=e(s,n,i)),r.push(s)}return Mt.fromArray(r)}class Ch extends _s{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(yO(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 ni.fromReplace(e,this.from,this.to,s)}invert(){return new Kl(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 Ch(n.pos,r.pos,this.mark)}merge(e){return e instanceof Ch&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ch(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 Ch(n.from,n.to,e.markFromJSON(n.mark))}}_s.jsonID("addMark",Ch);class Kl extends _s{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(yO(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),n.openStart,n.openEnd);return ni.fromReplace(e,this.from,this.to,r)}invert(){return new Ch(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 Kl(n.pos,r.pos,this.mark)}merge(e){return e instanceof Kl&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Kl(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 Kl(n.from,n.to,e.markFromJSON(n.mark))}}_s.jsonID("removeMark",Kl);class kh extends _s{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return ni.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return ni.fromReplace(e,this.pos,this.pos+1,new qt(Mt.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 kh(this.pos,n.marks[i]);return new kh(this.pos,this.mark)}}return new Xf(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new kh(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 kh(n.pos,e.markFromJSON(n.mark))}}_s.jsonID("addNodeMark",kh);class Xf extends _s{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return ni.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return ni.fromReplace(e,this.pos,this.pos+1,new qt(Mt.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new kh(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Xf(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 Xf(n.pos,e.markFromJSON(n.mark))}}_s.jsonID("removeNodeMark",Xf);class Di extends _s{constructor(e,n,r,i=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=i}apply(e){return this.structure&&AR(e,this.from,this.to)?ni.fail("Structure replace would overwrite content"):ni.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Mo([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)}}_s.jsonID("replace",Di);class Fi extends _s{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&&(AR(e,this.from,this.gapFrom)||AR(e,this.gapTo,this.to)))return ni.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return ni.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?ni.fromReplace(e,this.from,this.to,r):ni.fail("Content does not fit in gap")}getMap(){return new Mo([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)}}_s.jsonID("replaceAround",Fi);function AR(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 MVe(t,e,n,r){let i=[],s=[],o,l;t.doc.nodesBetween(e,n,(c,d,u)=>{if(!c.isInline)return;let h=c.marks;if(!r.isInSet(h)&&u.type.allowsMarkType(r.type)){let f=Math.max(d,e),p=Math.min(d+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 Kl(f,p,h[v])));l&&l.to==f?l.to=p:s.push(l=new Ch(f,p,r))}}),i.forEach(c=>t.step(c)),s.forEach(c=>t.step(c))}function PVe(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 lA){let d=o.marks,u;for(;u=r.isInSet(d);)(c||(c=[])).push(u),d=u.removeFromSet(d)}else r?r.isInSet(o.marks)&&(c=[r]):c=o.marks;if(c&&c.length){let d=Math.min(l+o.nodeSize,n);for(let u=0;u<c.length;u++){let h=c[u],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=d,f.step=s):i.push({style:h,from:Math.max(l,e),to:d,step:s})}}}),i.forEach(o=>t.step(new Kl(o.from,o.to,o.style)))}function vO(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 d=s.child(c),u=l+d.nodeSize,h=r.matchType(d.type);if(!h)o.push(new Di(l,u,qt.empty));else{r=h;for(let f=0;f<d.marks.length;f++)n.allowsMarkType(d.marks[f].type)||t.step(new Kl(l,u,d.marks[f]));if(i&&d.isText&&n.whitespace!="pre"){let f,p=/\r?\n|\r/g,x;for(;f=p.exec(d.text);)x||(x=new qt(Mt.from(n.schema.text(" ",n.allowedMarks(d.marks))),0,0)),o.push(new Di(l+f.index,l+f.index+f[0].length,x))}}l=u}if(!r.validEnd){let c=r.fillBefore(Mt.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 EVe(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function lx(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||!EVe(o,l,c))break;l&&(i=1),c<o.childCount&&(s=1)}return null}function jVe(t,e,n){let{$from:r,$to:i,depth:s}=e,o=r.before(s+1),l=i.after(s+1),c=o,d=l,u=Mt.empty,h=0;for(let x=s,v=!1;x>n;x--)v||r.index(x)>0?(v=!0,u=Mt.from(r.node(x).copy(u)),h++):c--;let f=Mt.empty,p=0;for(let x=s,v=!1;x>n;x--)v||i.after(x+1)<i.end(x)?(v=!0,f=Mt.from(i.node(x).copy(f)),p++):d++;t.step(new Fi(c,d,o,l,new qt(u.append(f),h,p),u.size-h,!0))}function wO(t,e,n=null,r=t){let i=DVe(t,e),s=i&&RVe(r,e);return s?i.map(A9).concat({type:e,attrs:n}).concat(s.map(A9)):null}function A9(t){return{type:t,attrs:null}}function DVe(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 RVe(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 d=r;c&&d<i;d++)c=c.matchType(n.child(d).type);return!c||!c.validEnd?null:o}function FVe(t,e,n){let r=Mt.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=Mt.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 LVe(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)&&OVe(t.doc,t.mapping.slice(s).map(l),r)){let d=null;if(r.schema.linebreakReplacement){let p=r.whitespace=="pre",x=!!r.contentMatch.matchType(r.schema.linebreakReplacement);p&&!x?d=!1:!p&&x&&(d=!0)}d===!1&&tre(t,o,l,s),vO(t,t.mapping.slice(s).map(l,1),r,void 0,d===null);let u=t.mapping.slice(s),h=u.map(l,1),f=u.map(l+o.nodeSize,1);return t.step(new Fi(h,f,h+1,f-1,new qt(Mt.from(r.create(c,null,o.marks)),0,0),1,!0)),d===!0&&ere(t,o,l,s),!1}})}function ere(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 tre(t,e,n,r){e.forEach((i,s)=>{if(i.type==i.type.schema.linebreakReplacement){let o=t.mapping.slice(r).map(n+1+s);t.replaceWith(o,o+1,e.type.schema.text(`
- `))}})}function OVe(t,e,n){let r=t.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function IVe(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(Mt.from(o),0,0),1,!0))}function Qd(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 d=i.depth-1,u=n-2;d>s;d--,u--){let h=i.node(d),f=i.index(d);if(h.type.spec.isolating)return!1;let p=h.content.cutByIndex(f,h.childCount),x=r&&r[u+1];x&&(p=p.replaceChild(0,x.type.create(x.attrs)));let v=r&&r[u]||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 zVe(t,e,n=1,r){let i=t.doc.resolve(e),s=Mt.empty,o=Mt.empty;for(let l=i.depth,c=i.depth-n,d=n-1;l>c;l--,d--){s=Mt.from(i.node(l).copy(s));let u=r&&r[d];o=Mt.from(u?u.type.create(u.attrs,o):i.node(l).copy(o))}t.step(new Di(e,e,new qt(s.append(o),n,n),!0))}function lm(t,e){let n=t.resolve(e),r=n.index();return nre(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function UVe(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 nre(t,e){return!!(t&&e&&!t.isLeaf&&UVe(t,e))}function cA(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&&nre(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 BVe(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 u=o.whitespace=="pre",h=!!o.contentMatch.matchType(i);u&&!h?r=!1:!u&&h&&(r=!0)}let l=t.steps.length;if(r===!1){let u=t.doc.resolve(e+n);tre(t,u.node(),u.before(),l)}o.inlineContent&&vO(t,e+n-1,o,s.node().contentMatchAt(s.index()),r==null);let c=t.mapping.slice(l),d=c.map(e-n);if(t.step(new Di(d,c.map(e+n,-1),qt.empty,!0)),r===!0){let u=t.doc.resolve(d);ere(t,u.node(),u.before(),t.steps.length)}return t}function HVe(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 rre(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),d=r.node(o),u=!1;if(s==1)u=d.canReplace(c,c,i);else{let h=d.contentMatchAt(c).findWrapping(i.firstChild.type);u=h&&d.canReplaceWith(c,c,h[0])}if(u)return l==0?r.pos:l<0?r.before(o+1):r.after(o+1)}return null}function dA(t,e,n=e,r=qt.empty){if(e==n&&!r.size)return null;let i=t.resolve(e),s=t.resolve(n);return are(i,s,r)?new Di(e,n,r):new $Ve(i,s,r).fit()}function are(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class $Ve{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=Mt.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=Mt.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let d=this.findFittable();d?this.placeNodes(d):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=JE(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:d}=this.frontier[l],u,h=null;if(n==1&&(o?d.matchType(o.type)||(h=d.fillBefore(Mt.from(o),!1)):s&&c.compatibleContent(s.type)))return{sliceDepth:r,frontierDepth:l,parent:s,inject:h};if(n==2&&o&&(u=d.findWrapping(o.type)))return{sliceDepth:r,frontierDepth:l,parent:s,wrap:u};if(s&&d.matchType(s.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=JE(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=JE(e,n);if(i.childCount<=1&&n>0){let s=e.size-n<=n+i.size;this.unplaced=new qt(Dy(e,n-1,1),n-1,s?n-1:r)}else this.unplaced=new qt(Dy(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,d=0,u=[],{match:h,type:f}=this.frontier[n];if(i){for(let v=0;v<i.childCount;v++)u.push(i.child(v));h=h.matchFragment(i)}let p=l.size+e-(o.content.size-o.openEnd);for(;d<l.childCount;){let v=l.child(d),g=h.matchType(v.type);if(!g)break;d++,(d>1||c==0||v.content.size)&&(h=g,u.push(ire(v.mark(f.allowedMarks(v.marks)),d==1?c:0,d==l.childCount?p:-1)))}let x=d==l.childCount;x||(p=-1),this.placed=Ry(this.placed,n,Mt.from(u)),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(Dy(o.content,e-1,1),e-1,p<0?o.openEnd:e-1):new qt(Dy(o.content,e,d),o.openStart,o.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],n;if(!e.type.isTextblock||!ej(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=ej(e,n,i,r,s);if(o){for(let l=n-1;l>=0;l--){let{match:c,type:d}=this.frontier[l],u=ej(e,l,d,c,!0);if(!u||u.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=Ry(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=Ry(this.placed,this.depth,Mt.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(Mt.empty,!0);n.childCount&&(this.placed=Ry(this.placed,this.frontier.length,n))}}function Dy(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(Dy(t.firstChild.content,e-1,n)))}function Ry(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(Ry(t.lastChild.content,e-1,n)))}function JE(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function ire(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,ire(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(Mt.empty,!0)))),t.copy(r)}function ej(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&&!VVe(n,s.content,o)?l:null}function VVe(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function qVe(t){return t.spec.defining||t.spec.definingForContent}function GVe(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let i=t.doc.resolve(e),s=t.doc.resolve(n);if(are(i,s,r))return t.step(new Di(e,n,r));let o=ore(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),d=[],u=r.openStart;for(let f=r.content,p=0;;p++){let x=f.firstChild;if(d.push(x),p==r.openStart)break;f=x.content}for(let f=u-1;f>=0;f--){let p=d[f],x=qVe(p.type);if(x&&!p.sameMarkup(i.node(Math.abs(l)-1)))u=f;else if(x||!p.type.isTextblock)break}for(let f=r.openStart;f>=0;f--){let p=(f+u+1)%(r.openStart+1),x=d[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(Mt.empty,!0))}return t}function WVe(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let i=HVe(t.doc,e,r.type);i!=null&&(e=n=i)}t.replaceRange(e,n,new qt(Mt.from(r),0,0))}function KVe(t,e,n){let r=t.doc.resolve(e),i=t.doc.resolve(n),s=ore(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 ore(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 ib extends _s{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 ni.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 ni.fromReplace(e,this.pos,this.pos+1,new qt(Mt.from(i),0,n.isLeaf?0:1))}getMap(){return Mo.empty}invert(e){return new ib(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 ib(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 ib(n.pos,n.attr,n.value)}}_s.jsonID("attr",ib);class W0 extends _s{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 ni.ok(r)}getMap(){return Mo.empty}invert(e){return new W0(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 W0(n.attr,n.value)}}_s.jsonID("docAttr",W0);let Pb=class extends Error{};Pb=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};Pb.prototype=Object.create(Error.prototype);Pb.prototype.constructor=Pb;Pb.prototype.name="TransformError";class lre{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new G0}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new Pb(n.failed);return this}maybeStep(e){let n=e.apply(this.doc);return n.failed||this.addStep(e,n.doc),n}get docChanged(){return this.steps.length>0}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=dA(this.doc,e,n,r);return i&&this.step(i),this}replaceWith(e,n,r){return this.replace(e,n,new qt(Mt.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 GVe(this,e,n,r),this}replaceRangeWith(e,n,r){return WVe(this,e,n,r),this}deleteRange(e,n){return KVe(this,e,n),this}lift(e,n){return jVe(this,e,n),this}join(e,n=1){return BVe(this,e,n),this}wrap(e,n){return FVe(this,e,n),this}setBlockType(e,n=e,r,i=null){return LVe(this,e,n,r,i),this}setNodeMarkup(e,n,r=null,i){return IVe(this,e,n,r,i),this}setNodeAttribute(e,n,r){return this.step(new ib(e,n,r)),this}setDocAttribute(e,n){return this.step(new W0(e,n)),this}addNodeMark(e,n){return this.step(new kh(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 Kr)n.isInSet(r.marks)&&this.step(new Xf(e,n));else{let i=r.marks,s,o=[];for(;s=n.isInSet(i);)o.push(new Xf(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 zVe(this,e,n,r),this}addMark(e,n,r){return MVe(this,e,n,r),this}removeMark(e,n,r){return PVe(this,e,n,r),this}clearIncompatible(e,n,r){return vO(this,e,n,r),this}}const tj=Object.create(null);class zn{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new XVe(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:d}=o[l],u=e.mapping.slice(s);e.replaceRange(u.map(c.pos),u.map(d.pos),l?qt.empty:n),l==0&&P9(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),d=c.map(o.pos),u=c.map(l.pos);s?e.deleteRange(d,u):(e.replaceRangeWith(d,u,n),P9(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let i=e.parent.inlineContent?new _n(e):Rg(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?Rg(e.node(0),e.node(s),e.before(s+1),e.index(s),n,r):Rg(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 Fo(e.node(0))}static atStart(e){return Rg(e,e,0,0,1)||new Fo(e)}static atEnd(e){return Rg(e,e,e.content.size,e.childCount,-1)||new Fo(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=tj[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 tj)throw new RangeError("Duplicate use of selection JSON ID "+e);return tj[e]=n,n.prototype.jsonID=e,n}getBookmark(){return _n.between(this.$anchor,this.$head).getBookmark()}}zn.prototype.visible=!0;class XVe{constructor(e,n){this.$from=e,this.$to=n}}let T9=!1;function M9(t){!T9&&!t.parent.inlineContent&&(T9=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class _n extends zn{constructor(e,n=e){M9(e),M9(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 zn.near(r);let i=e.resolve(n.map(this.anchor));return new _n(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 _n&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new uA(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 _n(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=zn.findFrom(n,r,!0)||zn.findFrom(n,-r,!0);if(s)n=s.$head;else return zn.near(n,r)}return e.parent.inlineContent||(i==0?e=n:(e=(zn.findFrom(e,-r,!0)||zn.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=i<0&&(e=n))),new _n(e,n)}}zn.jsonID("text",_n);class uA{constructor(e,n){this.anchor=e,this.head=n}map(e){return new uA(e.map(this.anchor),e.map(this.head))}resolve(e){return _n.between(e.resolve(this.anchor),e.resolve(this.head))}}class cn extends zn{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?zn.near(s):new cn(s)}content(){return new qt(Mt.from(this.node),0,0)}eq(e){return e instanceof cn&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new SO(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new cn(e.resolve(n.anchor))}static create(e,n){return new cn(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}cn.prototype.visible=!1;zn.jsonID("node",cn);class SO{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new uA(r,r):new SO(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&cn.isSelectable(r)?new cn(n):zn.near(n)}}class Fo extends zn{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=zn.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new Fo(e)}map(e){return new Fo(e)}eq(e){return e instanceof Fo}getBookmark(){return YVe}}zn.jsonID("all",Fo);const YVe={map(){return this},resolve(t){return new Fo(t)}};function Rg(t,e,n,r,i,s=!1){if(e.inlineContent)return _n.create(t,n);for(let o=r-(i>0?0:1);i>0?o<e.childCount:o>=0;o+=i){let l=e.child(o);if(l.isAtom){if(!s&&cn.isSelectable(l))return cn.create(t,n-(i<0?l.nodeSize:0))}else{let c=Rg(t,l,n+i,i<0?l.childCount:0,i,s);if(c)return c}n+=l.nodeSize*i}return null}function P9(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,d,u)=>{o==null&&(o=u)}),t.setSelection(zn.near(t.doc.resolve(o),n))}const E9=1,__=2,j9=4;class QVe extends lre{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|E9)&~__,this.storedMarks=null,this}get selectionSet(){return(this.updated&E9)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=__,this}ensureMarks(e){return Kr.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&__)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~__,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)||Kr.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(zn.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|=j9,this}get scrolledIntoView(){return(this.updated&j9)>0}}function D9(t,e){return!e||!t?t:t.bind(e)}class Fy{constructor(e,n,r){this.name=e,this.init=D9(n.init,r),this.apply=D9(n.apply,r)}}const ZVe=[new Fy("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Fy("selection",{init(t,e){return t.selection||zn.atStart(e.doc)},apply(t){return t.selection}}),new Fy("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Fy("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class nj{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=ZVe.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 Fy(r.key,r.spec.state,r))})}}class Vg{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,n=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=n){let i=this.config.plugins[r];if(i.spec.filterTransaction&&!i.spec.filterTransaction.call(i,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let n=[e],r=this.applyInner(e),i=null;for(;;){let s=!1;for(let o=0;o<this.config.plugins.length;o++){let l=this.config.plugins[o];if(l.spec.appendTransaction){let c=i?i[o].n:0,d=i?i[o].state:this,u=c<n.length&&l.spec.appendTransaction.call(l,c?n.slice(c):n,d,r);if(u&&r.filterTransaction(u,o)){if(u.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(u),r=r.applyInner(u),s=!0}i&&(i[o]={state:r,n:n.length})}}if(!s)return{state:r,transactions:n}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let n=new Vg(this.config),r=this.config.fields;for(let i=0;i<r.length;i++){let s=r[i];n[s.name]=s.apply(e,this[s.name],this,n)}return n}get tr(){return new QVe(this)}static create(e){let n=new nj(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new Vg(n);for(let i=0;i<n.fields.length;i++)r[n.fields[i].name]=n.fields[i].init(e,r);return r}reconfigure(e){let n=new nj(this.schema,e.plugins),r=n.fields,i=new Vg(n);for(let s=0;s<r.length;s++){let o=r[s].name;i[o]=this.hasOwnProperty(o)?this[o]:r[s].init(e,i)}return i}toJSON(e){let n={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(n.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[r],s=i.spec.state;s&&s.toJSON&&(n[r]=s.toJSON.call(i,this[i.key]))}return n}static fromJSON(e,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new nj(e.schema,e.plugins),s=new Vg(i);return i.fields.forEach(o=>{if(o.name=="doc")s.doc=Bh.fromJSON(e.schema,n.doc);else if(o.name=="selection")s.selection=zn.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],d=c.spec.state;if(c.key==o.name&&d&&d.fromJSON&&Object.prototype.hasOwnProperty.call(n,l)){s[o.name]=d.fromJSON.call(c,e,n[l],s);return}}s[o.name]=o.init(e,s)}}),s}}function cre(t,e,n){for(let r in t){let i=t[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=cre(i,e,{})),n[r]=i}return n}class Na{constructor(e){this.spec=e,this.props={},e.props&&cre(e.props,this,this.props),this.key=e.key?e.key.key:dre("plugin")}getState(e){return e[this.key]}}const rj=Object.create(null);function dre(t){return t in rj?t+"$"+ ++rj[t]:(rj[t]=0,t+"$")}class Ni{constructor(e="key"){this.key=dre(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const _O=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function ure(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const hre=(t,e,n)=>{let r=ure(t,n);if(!r)return!1;let i=NO(r);if(!i){let o=r.blockRange(),l=o&&lx(o);return l==null?!1:(e&&e(t.tr.lift(o,l).scrollIntoView()),!0)}let s=i.nodeBefore;if(wre(t,i,e,-1))return!0;if(r.parent.content.size==0&&(Eb(s,"end")||cn.isSelectable(s)))for(let o=r.depth;;o--){let l=dA(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(Eb(s,"end")?zn.findFrom(c.doc.resolve(c.mapping.map(i.pos,-1)),-1):cn.create(c.doc,i.pos-s.nodeSize)),e(c.scrollIntoView())}return!0}if(o==1||r.node(o-1).childCount>1)break}return s.isAtom&&i.depth==r.depth-1?(e&&e(t.tr.delete(i.pos-s.nodeSize,i.pos).scrollIntoView()),!0):!1},JVe=(t,e,n)=>{let r=ure(t,n);if(!r)return!1;let i=NO(r);return i?mre(t,i,e):!1},eqe=(t,e,n)=>{let r=pre(t,n);if(!r)return!1;let i=CO(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 u=i.lastChild;if(!u)return!1;i=u}let o=e.nodeAfter,l=o,c=e.pos+1;for(;!l.isTextblock;c++){if(l.type.spec.isolating)return!1;let u=l.firstChild;if(!u)return!1;l=u}let d=dA(t.doc,s,c,qt.empty);if(!d||d.from!=s||d instanceof Di&&d.slice.size>=c-s)return!1;if(n){let u=t.tr.step(d);u.setSelection(_n.create(u.doc,s)),n(u.scrollIntoView())}return!0}function Eb(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 fre=(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=NO(r)}let o=s&&s.nodeBefore;return!o||!cn.isSelectable(o)?!1:(e&&e(t.tr.setSelection(cn.create(t.doc,s.pos-o.nodeSize)).scrollIntoView()),!0)};function NO(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 pre(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const gre=(t,e,n)=>{let r=pre(t,n);if(!r)return!1;let i=CO(r);if(!i)return!1;let s=i.nodeAfter;if(wre(t,i,e,1))return!0;if(r.parent.content.size==0&&(Eb(s,"start")||cn.isSelectable(s))){let o=dA(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(Eb(s,"start")?zn.findFrom(l.doc.resolve(l.mapping.map(i.pos)),1):cn.create(l.doc,l.mapping.map(i.pos))),e(l.scrollIntoView())}return!0}}return s.isAtom&&i.depth==r.depth-1?(e&&e(t.tr.delete(i.pos,i.pos+s.nodeSize).scrollIntoView()),!0):!1},bre=(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=CO(r)}let o=s&&s.nodeAfter;return!o||!cn.isSelectable(o)?!1:(e&&e(t.tr.setSelection(cn.create(t.doc,s.pos)).scrollIntoView()),!0)};function CO(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 tqe=(t,e)=>{let n=t.selection,r=n instanceof cn,i;if(r){if(n.node.isTextblock||!lm(t.doc,n.from))return!1;i=n.from}else if(i=cA(t.doc,n.from,-1),i==null)return!1;if(e){let s=t.tr.join(i);r&&s.setSelection(cn.create(s.doc,i-t.doc.resolve(i).nodeBefore.nodeSize)),e(s.scrollIntoView())}return!0},nqe=(t,e)=>{let n=t.selection,r;if(n instanceof cn){if(n.node.isTextblock||!lm(t.doc,n.to))return!1;r=n.to}else if(r=cA(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},rqe=(t,e)=>{let{$from:n,$to:r}=t.selection,i=n.blockRange(r),s=i&&lx(i);return s==null?!1:(e&&e(t.tr.lift(i,s).scrollIntoView()),!0)},xre=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(`
- `).scrollIntoView()),!0)};function kO(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 aqe=(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=kO(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(zn.near(c.doc.resolve(l),1)),e(c.scrollIntoView())}return!0},yre=(t,e)=>{let n=t.selection,{$from:r,$to:i}=n;if(n instanceof Fo||r.parent.inlineContent||i.parent.inlineContent)return!1;let s=kO(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(_n.create(l.doc,o+1)),e(l.scrollIntoView())}return!0},vre=(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(Qd(t.doc,s))return e&&e(t.tr.split(s).scrollIntoView()),!0}let r=n.blockRange(),i=r&&lx(r);return i==null?!1:(e&&e(t.tr.lift(r,i).scrollIntoView()),!0)};function iqe(t){return(e,n)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof cn&&e.selection.node.isBlock)return!r.parentOffset||!Qd(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,d=!1;for(let p=r.depth;;p--)if(r.node(p).isBlock){c=r.end(p)==r.pos+(r.depth-p),d=r.start(p)==r.pos-(r.depth-p),l=kO(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 u=e.tr;(e.selection instanceof _n||e.selection instanceof Fo)&&u.deleteSelection();let h=u.mapping.map(r.pos),f=Qd(u.doc,h,s.length,s);if(f||(s[0]=l?{type:l}:null,f=Qd(u.doc,h,s.length,s)),!f)return!1;if(u.split(h,s.length,s),!c&&d&&r.node(o).type!=l){let p=u.mapping.map(r.before(o)),x=u.doc.resolve(p);l&&r.node(o-1).canReplaceWith(x.index(),x.index()+1,l)&&u.setNodeMarkup(u.mapping.map(r.before(o)),l)}return n&&n(u.scrollIntoView()),!0}}const sqe=iqe(),oqe=(t,e)=>{let{$from:n,to:r}=t.selection,i,s=n.sharedDepth(r);return s==0?!1:(i=n.before(s),e&&e(t.tr.setSelection(cn.create(t.doc,i))),!0)};function lqe(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||lm(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function wre(t,e,n,r){let i=e.nodeBefore,s=e.nodeAfter,o,l,c=i.type.spec.isolating||s.type.spec.isolating;if(!c&&lqe(t,e,n))return!0;let d=!c&&e.parent.canReplace(e.index(),e.index()+1);if(d&&(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=Mt.empty;for(let y=o.length-1;y>=0;y--)x=Mt.from(o[y].create(null,x));x=Mt.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&&lm(v.doc,g.pos)&&v.join(g.pos),n(v.scrollIntoView())}return!0}let u=s.type.spec.isolating||r>0&&c?null:zn.findFrom(e,1),h=u&&u.$from.blockRange(u.$to),f=h&&lx(h);if(f!=null&&f>=e.depth)return n&&n(t.tr.lift(h,f).scrollIntoView()),!0;if(d&&Eb(s,"start",!0)&&Eb(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=Mt.empty;for(let N=x.length-1;N>=0;N--)y=Mt.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 Sre(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(_n.create(e.doc,t<0?i.start(s):i.end(s)))),!0):!1}}const cqe=Sre(-1),dqe=Sre(1);function uqe(t,e=null){return function(n,r){let{$from:i,$to:s}=n.selection,o=i.blockRange(s),l=o&&wO(o,t,e);return l?(r&&r(n.tr.wrap(o,l).scrollIntoView()),!0):!1}}function R9(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,d)=>{if(i)return!1;if(!(!c.isTextblock||c.hasMarkup(t,e)))if(c.type==t)i=!0;else{let u=n.doc.resolve(d),h=u.index();i=u.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 AO(...t){return function(e,n,r){for(let i=0;i<t.length;i++)if(t[i](e,n,r))return!0;return!1}}AO(_O,hre,fre);AO(_O,gre,bre);AO(xre,yre,vre,sqe);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function hqe(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 mqe(l,o,t,e)?(r&&r(l.scrollIntoView()),!0):!1}}function mqe(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 GN(c,c,e.depth),e.endIndex<e.parent.childCount&&(e=new GN(e.$from,o.resolve(e.$to.end(e.depth)),e.depth)),i=!0}let l=wO(s,n,r,e);return l?(t&&fqe(t,e,l,i,n),!0):!1}function fqe(t,e,n,r,i){let s=Mt.empty;for(let u=n.length-1;u>=0;u--)s=Mt.from(n[u].type.create(n[u].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 u=0;u<n.length;u++)n[u].type==i&&(o=u+1);let l=n.length-o,c=e.start+n.length-(r?2:0),d=e.parent;for(let u=e.startIndex,h=e.endIndex,f=!0;u<h;u++,f=!1)!f&&Qd(t.doc,c,l)&&(t.split(c,l),c+=2*l),c+=d.child(u).nodeSize;return t}function pqe(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?gqe(e,n,t,s):bqe(e,n,s):!0:!1}}function gqe(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(Mt.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new GN(i.doc.resolve(r.$from.pos),i.doc.resolve(o),r.depth));const l=lx(r);if(l==null)return!1;i.lift(r,l);let c=i.doc.resolve(i.mapping.map(s,-1)-1);return lm(i.doc,c.pos)&&c.nodeBefore.type==c.nodeAfter.type&&i.join(c.pos),e(i.scrollIntoView()),!0}function bqe(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,d=s.node(-1),u=s.index(-1);if(!d.canReplace(u+(l?0:1),u+1,o.content.append(c?Mt.empty:Mt.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?Mt.empty:Mt.from(i.copy(Mt.empty))).append(c?Mt.empty:Mt.from(i.copy(Mt.empty))),l?0:1,c?0:1),l?0:1)),e(r.scrollIntoView()),!0}function xqe(t){return function(e,n){let{$from:r,$to:i}=e.selection,s=r.blockRange(i,d=>d.childCount>0&&d.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 d=c.lastChild&&c.lastChild.type==l.type,u=Mt.from(d?t.create():null),h=new qt(Mt.from(t.create(null,Mt.from(l.type.create(null,u)))),d?3:1,0),f=s.start,p=s.end;n(e.tr.step(new Fi(f-(d?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},jb=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let TR=null;const jd=function(t,e,n){let r=TR||(TR=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},yqe=function(){TR=null},Yf=function(t,e,n,r){return n&&(F9(t,e,n,r,-1)||F9(t,e,n,r,1))},vqe=/^(img|br|input|textarea|hr)$/i;function F9(t,e,n,r,i){for(var s;;){if(t==n&&e==r)return!0;if(e==(i<0?0:ml(t))){let o=t.parentNode;if(!o||o.nodeType!=1||Uv(t)||vqe.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?ml(t):0}else return!1}}function ml(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function wqe(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=ml(t)}else if(t.parentNode&&!Uv(t))e=es(t),t=t.parentNode;else return null}}function Sqe(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&&!Uv(t))e=es(t)+1,t=t.parentNode;else return null}}function _qe(t,e,n){for(let r=e==0,i=e==ml(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==ml(t)}}function Uv(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 hA=function(t){return t.focusNode&&Yf(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function Zm(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function Nqe(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function Cqe(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(ml(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(ml(r.startContainer),r.startOffset)}}}const Hc=typeof navigator<"u"?navigator:null,L9=typeof document<"u"?document:null,cm=Hc&&Hc.userAgent||"",MR=/Edge\/(\d+)/.exec(cm),_re=/MSIE \d/.exec(cm),PR=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(cm),so=!!(_re||PR||MR),Hh=_re?document.documentMode:PR?+PR[1]:MR?+MR[1]:0,xl=!so&&/gecko\/(\d+)/i.test(cm);xl&&+(/Firefox\/(\d+)/.exec(cm)||[0,0])[1];const ER=!so&&/Chrome\/(\d+)/.exec(cm),ns=!!ER,Nre=ER?+ER[1]:0,vs=!so&&!!Hc&&/Apple Computer/.test(Hc.vendor),Db=vs&&(/Mobile\/\w+/.test(cm)||!!Hc&&Hc.maxTouchPoints>2),sl=Db||(Hc?/Mac/.test(Hc.platform):!1),Cre=Hc?/Win/.test(Hc.platform):!1,$d=/Android \d/.test(cm),Bv=!!L9&&"webkitFontSmoothing"in L9.documentElement.style,kqe=Bv?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Aqe(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 Cd(t,e){return typeof t=="number"?t:t[e]}function Tqe(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 O9(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=jb(o);continue}let l=o,c=l==s.body,d=c?Aqe(s):Tqe(l),u=0,h=0;if(e.top<d.top+Cd(r,"top")?h=-(d.top-e.top+Cd(i,"top")):e.bottom>d.bottom-Cd(r,"bottom")&&(h=e.bottom-e.top>d.bottom-d.top?e.top+Cd(i,"top")-d.top:e.bottom-d.bottom+Cd(i,"bottom")),e.left<d.left+Cd(r,"left")?u=-(d.left-e.left+Cd(i,"left")):e.right>d.right-Cd(r,"right")&&(u=e.right-d.right+Cd(i,"right")),u||h)if(c)s.defaultView.scrollBy(u,h);else{let p=l.scrollLeft,x=l.scrollTop;h&&(l.scrollTop+=h),u&&(l.scrollLeft+=u);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:jb(o)}}function Mqe(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:kre(t.dom)}}function kre(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=jb(r));return e}function Pqe({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;Are(n,r==0?0:r-e)}function Are(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 Cg=null;function Eqe(t){if(t.setActive)return t.setActive();if(Cg)return t.focus(Cg);let e=kre(t);t.focus(Cg==null?{get preventScroll(){return Cg={preventScroll:!0},!0}}:void 0),Cg||(Cg=!1,Are(e,0))}function Tre(t,e){let n,r=2e8,i,s=0,o=e.top,l=e.top,c,d;for(let u=t.firstChild,h=0;u;u=u.nextSibling,h++){let f;if(u.nodeType==1)f=u.getClientRects();else if(u.nodeType==3)f=jd(u).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=u,r=v,i=v&&n.nodeType==3?{left:x.right<e.left?x.right:x.left,top:e.top}:e,u.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=u,d={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=d,r=0),n&&n.nodeType==3?jqe(n,i):!n||r&&n.nodeType==1?{node:t,offset:s}:Tre(n,i)}function jqe(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=ih(r,1);if(o.top!=o.bottom&&TO(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 TO(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function Dqe(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function Rqe(t,e,n){let{node:r,offset:i}=Tre(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 Fqe(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 Mre(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 d=l[c];if(TO(e,d))return Mre(o,e,d)}}if((s=(s+1)%r)==i)break}return t}function Lqe(t,e){let n=t.dom.ownerDocument,r,i=0,s=Cqe(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 d=t.dom.getBoundingClientRect();if(!TO(e,d)||(o=Mre(t.dom,e,d),!o))return null}if(vs)for(let d=o;r&&d;d=jb(d))d.draggable&&(r=void 0);if(o=Dqe(o,e),r){if(xl&&r.nodeType==1&&(i=Math.min(i,r.childNodes.length),i<r.childNodes.length)){let u=r.childNodes[i],h;u.nodeName=="IMG"&&(h=u.getBoundingClientRect()).right<=e.left&&h.bottom>e.top&&i++}let d;Bv&&i&&r.nodeType==1&&(d=r.childNodes[i-1]).nodeType==1&&d.contentEditable=="false"&&d.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=Fqe(t,r,i,e))}l==null&&(l=Rqe(t,o,e));let c=t.docView.nearestDesc(o,!0);return{pos:l,inside:c?c.posAtStart-c.border:-1}}function I9(t){return t.top<t.bottom||t.left<t.right}function ih(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(I9(r))return r}return Array.prototype.find.call(n,I9)||t.getBoundingClientRect()}const Oqe=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Pre(t,e,n){let{node:r,offset:i,atom:s}=t.docView.domFromPos(e,n<0?-1:1),o=Bv||xl;if(r.nodeType==3)if(o&&(Oqe.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let c=ih(jd(r,i,i),n);if(xl&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let d=ih(jd(r,i-1,i-1),-1);if(d.top==c.top){let u=ih(jd(r,i,i+1),-1);if(u.top!=c.top)return _y(u,u.left<d.left)}}return c}else{let c=i,d=i,u=n<0?1:-1;return n<0&&!i?(d++,u=-1):n>=0&&i==r.nodeValue.length?(c--,u=1):n<0?c--:d++,_y(ih(jd(r,c,d),u),u<0)}if(!t.state.doc.resolve(e-(s||0)).parent.inlineContent){if(s==null&&i&&(n<0||i==ml(r))){let c=r.childNodes[i-1];if(c.nodeType==1)return aj(c.getBoundingClientRect(),!1)}if(s==null&&i<ml(r)){let c=r.childNodes[i];if(c.nodeType==1)return aj(c.getBoundingClientRect(),!0)}return aj(r.getBoundingClientRect(),n>=0)}if(s==null&&i&&(n<0||i==ml(r))){let c=r.childNodes[i-1],d=c.nodeType==3?jd(c,ml(c)-(o?0:1)):c.nodeType==1&&(c.nodeName!="BR"||!c.nextSibling)?c:null;if(d)return _y(ih(d,1),!1)}if(s==null&&i<ml(r)){let c=r.childNodes[i];for(;c.pmViewDesc&&c.pmViewDesc.ignoreForCoords;)c=c.nextSibling;let d=c?c.nodeType==3?jd(c,0,o?0:1):c.nodeType==1?c:null:null;if(d)return _y(ih(d,-1),!0)}return _y(ih(r.nodeType==3?jd(r):r,-n),n>=0)}function _y(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 aj(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 Ere(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 Iqe(t,e,n){let r=e.selection,i=n=="up"?r.$from:r.$to;return Ere(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=Pre(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=jd(l,0,l.nodeValue.length).getClientRects();else continue;for(let d=0;d<c.length;d++){let u=c[d];if(u.bottom>u.top+1&&(n=="up"?o.top-u.top>(u.bottom-o.top)*2:u.bottom-o.bottom>(o.bottom-u.top)*2))return!1}}return!0})}const zqe=/[\u0590-\u08ac]/;function Uqe(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?!zqe.test(r.parent.textContent)||!l.modify?n=="left"||n=="backward"?s:o:Ere(t,e,()=>{let{focusNode:c,focusOffset:d,anchorNode:u,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&&d==v;try{l.collapse(u,h),c&&(c!=u||d!=h)&&l.extend&&l.extend(c,d)}catch{}return f!=null&&(l.caretBidiLevel=f),g}):r.pos==r.start()||r.pos==r.end()}let z9=null,U9=null,B9=!1;function Bqe(t,e,n){return z9==e&&U9==n?B9:(z9=e,U9=n,B9=n=="up"||n=="down"?Iqe(t,e,n):Uqe(t,e,n))}const yl=0,H9=1,lf=2,$c=3;class Hv{constructor(e,n,r,i){this.parent=e,this.children=n,this.dom=r,this.contentDOM=i,this.dirty=yl,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 Dre){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 jre&&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],d=o+c.size;if(i==-1&&e<=d){let u=o+c.border;if(e>=u&&n<=d-c.border&&c.node&&c.contentDOM&&this.contentDOM.contains(c.contentDOM))return c.parseRange(e,n,u);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&&(d>n||l==this.children.length-1)){n=d;for(let u=l+1;u<this.children.length;u++){let h=this.children[u];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=d}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),d=r.root.getSelection(),u=r.domSelectionRange(),h=!1;if((xl||vs)&&e==n){let{node:p,offset:x}=l;if(p.nodeType==3){if(h=!!(x&&p.nodeValue[x-1]==`
- `),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(xl&&u.focusNode&&u.focusNode!=c.node&&u.focusNode.nodeType==1){let p=u.focusNode.childNodes[u.focusOffset];p&&p.contentEditable=="false"&&(i=!0)}if(!(i||h&&vs)&&Yf(l.node,l.offset,u.anchorNode,u.anchorOffset)&&Yf(c.node,c.offset,u.focusNode,u.focusOffset))return;let f=!1;if((d.extend||e==n)&&!(h&&xl)){d.collapse(l.node,l.offset);try{e!=n&&d.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),d.removeAllRanges(),d.addRange(p)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let r=0,i=0;i<this.children.length;i++){let s=this.children[i],o=r+s.size;if(r==o?e<=o&&n>=r:e<o&&n>r){let l=r+s.border,c=o-s.border;if(e>=l&&n<=c){this.dirty=e==r||n==o?lf:H9,e==l&&n==c&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=$c:s.markDirty(e-l,n-l);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?lf:$c}r=o}this.dirty=lf}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?lf:H9;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class jre extends Hv{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==yl&&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 Hqe extends Hv{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 Qf extends Hv{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=ip.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new Qf(e,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&$c||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=$c&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=yl){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=yl}}slice(e,n,r){let i=Qf.create(this.parent,this.mark,!0,r),s=this.children,o=this.size;n<o&&(s=DR(s,n,o,r)),e>0&&(s=DR(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 $h extends Hv{constructor(e,n,r,i,s,o,l,c,d){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,d=l&&l(n,s,()=>{if(!c)return o;if(c.parent)return c.parent.posBeforeChild(c)},r,i),u=d&&d.dom,h=d&&d.contentDOM;if(n.isText){if(!u)u=document.createTextNode(n.text);else if(u.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:h}=ip.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!h&&!n.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),n.type.spec.draggable&&(u.draggable=!0));let f=u;return u=Lre(u,r,n),d?c=new $qe(e,n,r,i,u,h||null,f,d,s,o+1):n.isText?new mA(e,n,r,i,u,f,s):new $h(e,n,r,i,u,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=()=>Mt.empty)}return e}matchesNode(e,n,r){return this.dirty==yl&&e.eq(this.node)&&KN(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 qqe(this,o&&o.node,e);Kqe(this.node,this.innerDeco,(d,u,h)=>{d.spec.marks?c.syncToMarks(d.spec.marks,r,e,u):d.type.side>=0&&!h&&c.syncToMarks(u==this.node.childCount?Kr.none:this.node.child(u).marks,r,e,u),c.placeWidget(d,e,i)},(d,u,h,f)=>{c.syncToMarks(d.marks,r,e,f);let p;c.findNodeMatch(d,u,h,f)||l&&e.state.selection.from>i&&e.state.selection.to<i+d.nodeSize&&(p=c.findIndexWithChild(s.node))>-1&&c.updateNodeAt(d,u,h,p,e)||c.updateNextNode(d,u,h,e,f,i)||c.addNode(d,u,h,e,i),i+=d.nodeSize}),c.syncToMarks([],r,e,0),this.node.isTextblock&&c.addTextblockHacks(),c.destroyRest(),(c.changed||this.dirty==lf)&&(o&&this.protectLocalComposition(e,o),Rre(this.contentDOM,this.children,e),Db&&Xqe(this.dom))}localCompositionInfo(e,n){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof _n)||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=Yqe(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 Hqe(this,s,n,i);e.input.compositionNodes.push(o),this.children=DR(this.children,r,r+i.length,e,o)}update(e,n,r,i){return this.dirty==$c||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,r,i),!0)}updateInner(e,n,r,i){this.updateOuterDeco(n),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=yl}updateOuterDeco(e){if(KN(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=Fre(this.dom,this.nodeDOM,jR(this.outerDeco,this.node,n),jR(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 $9(t,e,n,r,i){Lre(r,e,t);let s=new $h(void 0,t,e,n,r,r,r,i,0);return s.contentDOM&&s.updateChildren(i,0),s}class mA extends $h{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==$c||this.dirty!=yl&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=yl||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=yl,!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 mA(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=$c)}get domAtom(){return!1}isText(e){return this.node.text==e}}class Dre extends Hv{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==yl&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class $qe extends $h{constructor(e,n,r,i,s,o,l,c,d,u){super(e,n,r,i,s,o,l,d,u),this.spec=c}update(e,n,r,i){if(this.dirty==$c)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let 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 Rre(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=V9(r),i=!0;r=r.nextSibling}else i=!0,t.insertBefore(l,r);if(o instanceof Qf){let c=r?r.previousSibling:t.lastChild;Rre(o.contentDOM,o.children,n),r=c?c.nextSibling:t.firstChild}}for(;r;)r=V9(r),i=!0;i&&n.trackWrites==t&&(n.trackWrites=null)}const Qy=function(t){t&&(this.nodeName=t)};Qy.prototype=Object.create(null);const cf=[new Qy];function jR(t,e,n){if(t.length==0)return cf;let r=n?cf[0]:new Qy,i=[r];for(let s=0;s<t.length;s++){let o=t[s].type.attrs;if(o){o.nodeName&&i.push(r=new Qy(o.nodeName));for(let l in o){let c=o[l];c!=null&&(n&&i.length==1&&i.push(r=new Qy(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 Fre(t,e,n,r){if(n==cf&&r==cf)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=cf[0]),i=c}Vqe(i,l||cf[0],o)}return i}function Vqe(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 Lre(t,e,n){return Fre(t,t,cf,jR(e,n,t.nodeType!=1))}function KN(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 V9(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class qqe{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=Gqe(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=yl,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,d=this.top.children.length;i<this.preMatch.index&&(d=Math.min(this.index+3,d));for(let u=this.index;u<d;u++){let h=this.top.children[u];if(h.matchesMark(e[o])&&!this.isLocked(h.dom)){c=u;break}}if(c>-1)c>this.index&&(this.changed=!0,this.destroyBetween(this.index,c)),this.top=this.top.children[this.index];else{let u=Qf.create(this.top,e[o],n,r);this.top.children.splice(this.index,0,u),this.top=u,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 d=this.top.children[l];if(d.matchesNode(e,n,r)&&!this.preMatch.matched.has(d)){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==$c&&o.dom==o.contentDOM&&(o.dirty=lf),o.update(e,n,r,s)?(this.destroyBetween(this.index,i),this.index++,!0):!1}findIndexWithChild(e){for(;;){let n=e.parentNode;if(!n)return-1;if(n==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let i=this.index;i<this.top.children.length;i++)if(this.top.children[i]==r)return i}return-1}e=n}}updateNextNode(e,n,r,i,s,o){for(let l=this.index;l<this.top.children.length;l++){let c=this.top.children[l];if(c instanceof $h){let d=this.preMatch.matched.get(c);if(d!=null&&d!=s)return!1;let u=c.dom,h,f=this.isLocked(u)&&!(e.isText&&c.node&&c.node.isText&&c.nodeDOM.nodeValue==e.text&&c.dirty!=$c&&KN(n,c.outerDeco));if(!f&&c.update(e,n,r,i))return this.destroyBetween(this.index,l),c.dom!=u&&(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=lf,h.updateChildren(i,o+1),h.dirty=yl),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)||!KN(r,e.outerDeco)||!i.eq(e.innerDeco))return null;let l=$h.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=$h.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 jre(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 Qf;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof mA)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((vs||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 Dre(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 Gqe(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 d=n.children[r-1];if(d instanceof Qf)n=d,r=d.children.length;else{l=d,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 Wqe(t,e){return t.type.side-e.type.side}function Kqe(t,e,n,r){let i=e.locals(t),s=0;if(i.length==0){for(let d=0;d<t.childCount;d++){let u=t.child(d);r(u,i,e.forChild(s,u),d),s+=u.nodeSize}return}let o=0,l=[],c=null;for(let d=0;;){let u,h;for(;o<i.length&&i[o].to==s;){let g=i[o++];g.widget&&(u?(h||(h=[u])).push(g):u=g)}if(u)if(h){h.sort(Wqe);for(let g=0;g<h.length;g++)n(h[g],d,!!c)}else n(u,d,!!c);let f,p;if(c)p=-1,f=c,c=null;else if(d<t.childCount)p=d,f=t.child(d++);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 Xqe(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 Yqe(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 d=t.child(i++);if(s+=d.nodeSize,!d.isText)break;c+=d.text}if(s>=n){if(s>=r&&c.slice(r-e.length-l,r-l)==e)return r-e.length;let d=l<r?c.lastIndexOf(e,r-l-1):-1;if(d>=0&&d+e.length+l>=n)return l+d;if(n==r&&c.length>=r+e.length-l&&c.slice(r-l,r-l+e.length)==e)return r}}return-1}function DR(t,e,n,r,i){let s=[];for(let o=0,l=0;o<t.length;o++){let c=t[o],d=l,u=l+=c.size;d>=n||u<=e?s.push(c):(d<e&&s.push(c.slice(0,e-d,r)),i&&(s.push(i),i=void 0),u>n&&s.push(c.slice(n-d,c.size,r)))}return s}function MO(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,d;if(hA(n)){for(c=o;i&&!i.node;)i=i.parent;let h=i.node;if(i&&h.isAtom&&cn.isSelectable(h)&&i.parent&&!(h.isInline&&_qe(n.focusNode,n.focusOffset,i.dom))){let f=i.posBefore;d=new cn(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 u=r.resolve(c);if(!d){let h=e=="pointer"||t.state.selection.head<l.pos&&!s?1:-1;d=PO(t,u,l,h)}return d}function Ore(t){return t.editable?t.hasFocus():zre(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function Zd(t,e=!1){let n=t.state.selection;if(Ire(t,n),!!Ore(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&ns){let r=t.domSelectionRange(),i=t.domObserver.currentSelection;if(r.anchorNode&&i.anchorNode&&Yf(r.anchorNode,r.anchorOffset,i.anchorNode,i.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)Zqe(t);else{let{anchor:r,head:i}=n,s,o;q9&&!(n instanceof _n)&&(n.$from.parent.inlineContent||(s=G9(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(o=G9(t,n.to))),t.docView.setSelection(r,i,t,e),q9&&(s&&W9(s),o&&W9(o)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Qqe(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const q9=vs||ns&&Nre<63;function G9(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(vs&&i&&i.contentEditable=="false")return ij(i);if((!i||i.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(i)return ij(i);if(s)return ij(s)}}function ij(t){return t.contentEditable="true",vs&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function W9(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function Qqe(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(()=>{(!Ore(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function Zqe(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&&so&&Hh<=11&&(n.disabled=!0,n.disabled=!1)}function Ire(t,e){if(e instanceof cn){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(K9(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else K9(t)}function K9(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function PO(t,e,n,r){return t.someProp("createSelectionBetween",i=>i(t,e,n))||_n.between(e,n,r)}function X9(t){return t.editable&&!t.hasFocus()?!1:zre(t)}function zre(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 Jqe(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return Yf(e.node,e.offset,n.anchorNode,n.anchorOffset)}function RR(t,e){let{$anchor:n,$head:r}=t.selection,i=e>0?n.max(r):n.min(r),s=i.parent.inlineContent?i.depth?t.doc.resolve(e>0?i.after():i.before()):null:i;return s&&zn.findFrom(s,e)}function dh(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function Y9(t,e,n){let r=t.state.selection;if(r instanceof _n)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 dh(t,new _n(r.$anchor,o))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let i=RR(t.state,e);return i&&i instanceof cn?dh(t,i):!1}else if(!(sl&&n.indexOf("m")>-1)){let i=r.$head,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,o;if(!s||s.isText)return!1;let l=e<0?i.pos-s.nodeSize:i.pos;return s.isAtom||(o=t.docView.descAt(l))&&!o.contentDOM?cn.isSelectable(s)?dh(t,new cn(e<0?t.state.doc.resolve(i.pos-s.nodeSize):i)):Bv?dh(t,new _n(t.state.doc.resolve(e<0?l:l+s.nodeSize))):!1:!1}}else return!1;else{if(r instanceof cn&&r.node.isInline)return dh(t,new _n(e>0?r.$to:r.$from));{let i=RR(t.state,e);return i?dh(t,i):!1}}}function XN(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Zy(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function kg(t,e){return e<0?eGe(t):tGe(t)}function eGe(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i,s,o=!1;for(xl&&n.nodeType==1&&r<XN(n)&&Zy(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(n.nodeType!=1)break;{let l=n.childNodes[r-1];if(Zy(l,-1))i=n,s=--r;else if(l.nodeType==3)n=l,r=n.nodeValue.length;else break}}else{if(Ure(n))break;{let l=n.previousSibling;for(;l&&Zy(l,-1);)i=n.parentNode,s=es(l),l=l.previousSibling;if(l)n=l,r=XN(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}o?FR(t,n,r):i&&FR(t,i,s)}function tGe(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i=XN(n),s,o;for(;;)if(r<i){if(n.nodeType!=1)break;let l=n.childNodes[r];if(Zy(l,1))s=n,o=++r;else break}else{if(Ure(n))break;{let l=n.nextSibling;for(;l&&Zy(l,1);)s=l.parentNode,o=es(l)+1,l=l.nextSibling;if(l)n=l,r=0,i=XN(n);else{if(n=n.parentNode,n==t.dom)break;r=i=0}}}s&&FR(t,s,o)}function Ure(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function nGe(t,e){for(;t&&e==t.childNodes.length&&!Uv(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 rGe(t,e){for(;t&&!e&&!Uv(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 FR(t,e,n){if(e.nodeType!=3){let s,o;(o=nGe(e,n))?(e=o,n=0):(s=rGe(e,n))&&(e=s,n=s.nodeValue.length)}let r=t.domSelection();if(!r)return;if(hA(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&&Zd(t)},50)}function Q9(t,e){let n=t.state.doc.resolve(e);if(!(ns||Cre)&&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 Z9(t,e,n){let r=t.state.selection;if(r instanceof _n&&!r.empty||n.indexOf("s")>-1||sl&&n.indexOf("m")>-1)return!1;let{$from:i,$to:s}=r;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let o=RR(t.state,e);if(o&&o instanceof cn)return dh(t,o)}if(!i.parent.inlineContent){let o=e<0?i:s,l=r instanceof Fo?zn.near(o,e):zn.findFrom(o,e);return l?dh(t,l):!1}return!1}function J9(t,e){if(!(t.state.selection instanceof _n))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 eW(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function aGe(t){if(!vs||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;eW(t,r,"true"),setTimeout(()=>eW(t,r,"false"),20)}return!1}function iGe(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function sGe(t,e){let n=e.keyCode,r=iGe(e);if(n==8||sl&&n==72&&r=="c")return J9(t,-1)||kg(t,-1);if(n==46&&!e.shiftKey||sl&&n==68&&r=="c")return J9(t,1)||kg(t,1);if(n==13||n==27)return!0;if(n==37||sl&&n==66&&r=="c"){let i=n==37?Q9(t,t.state.selection.from)=="ltr"?-1:1:-1;return Y9(t,i,r)||kg(t,i)}else if(n==39||sl&&n==70&&r=="c"){let i=n==39?Q9(t,t.state.selection.from)=="ltr"?1:-1:1;return Y9(t,i,r)||kg(t,i)}else{if(n==38||sl&&n==80&&r=="c")return Z9(t,-1,r)||kg(t,-1);if(n==40||sl&&n==78&&r=="c")return aGe(t)||Z9(t,1,r)||kg(t,1);if(r==(sl?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function EO(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")||ip.fromSchema(t.state.schema),l=Gre(),c=l.createElement("div");c.appendChild(o.serializeFragment(r,{document:l}));let d=c.firstChild,u,h=0;for(;d&&d.nodeType==1&&(u=qre[d.nodeName.toLowerCase()]);){for(let p=u.length-1;p>=0;p--){let x=l.createElement(u[p]);for(;c.firstChild;)x.appendChild(c.firstChild);c.appendChild(x),h++}d=c.firstChild}d&&d.nodeType==1&&d.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,`
- `);return{dom:c,text:f,slice:e}}function Bre(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(Mt.from(t.state.schema.text(e.replace(/\r\n?/g,`
- `))),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=ip.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=dGe(n),Bv&&uGe(o);let d=o&&o.querySelector("[data-pm-slice]"),u=d&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(d.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let h=+u[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")||Xy.fromSchema(t.state.schema)).parseSlice(o,{preserveWhitespace:!!(c||u),context:i,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!oGe.test(f.parentNode.nodeName)?{ignore:!0}:null}})),u)l=hGe(tW(l,+u[1],+u[2]),u[4]);else if(l=qt.maxOpen(lGe(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=tW(l,h,f)}return t.someProp("transformPasted",h=>{l=h(l,t,c)}),l}const oGe=/^(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 lGe(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),d;if(!c)return o=null;if(d=o.length&&s.length&&$re(c,s,l,o[o.length-1],0))o[o.length-1]=d;else{o.length&&(o[o.length-1]=Vre(o[o.length-1],s.length));let u=Hre(l,c);o.push(u),i=i.matchType(u.type),s=c}}),o)return Mt.from(o)}return t}function Hre(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,Mt.from(t));return t}function $re(t,e,n,r,i){if(i<t.length&&i<e.length&&t[i]==e[i]){let s=$re(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(Mt.from(Hre(n,t,i+1))))}}function Vre(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,Vre(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(Mt.empty,!0);return t.copy(n.append(r))}function LR(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=LR(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(Mt.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,o.copy(l))}function tW(t,e,n){return e<t.openStart&&(t=new qt(LR(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new qt(LR(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const qre={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 nW=null;function Gre(){return nW||(nW=document.implementation.createHTMLDocument("title"))}let sj=null;function cGe(t){let e=window.trustedTypes;return e?(sj||(sj=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),sj.createHTML(t)):t}function dGe(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=Gre().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),i;if((i=r&&qre[r[1].toLowerCase()])&&(t=i.map(s=>"<"+s+">").join("")+t+i.map(s=>"</"+s+">").reverse().join("")),n.innerHTML=cGe(t),i)for(let s=0;s<i.length;s++)n=n.querySelector(i[s])||n;return n}function uGe(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 hGe(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=Mt.from(c.create(r[l+1],i)),s++,o++}return new qt(i,s,o)}const Is={},zs={},mGe={touchstart:!0,touchmove:!0};class fGe{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 pGe(t){for(let e in Is){let n=Is[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{bGe(t,r)&&!jO(t,r)&&(t.editable||!(r.type in zs))&&n(t,r)},mGe[e]?{passive:!0}:void 0)}vs&&t.dom.addEventListener("input",()=>null),OR(t)}function Ah(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function gGe(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 OR(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>jO(t,r))})}function jO(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function bGe(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 xGe(t,e){!jO(t,e)&&Is[e.type]&&(t.editable||!(e.type in zs))&&Is[e.type](t,e)}zs.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!Kre(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!($d&&ns&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),Db&&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,Zm(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||sGe(t,n)?n.preventDefault():Ah(t,"key")};zs.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};zs.keypress=(t,e)=>{let n=e;if(Kre(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||sl&&n.metaKey)return;if(t.someProp("handleKeyPress",i=>i(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof _n)||!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 fA(t){return{left:t.clientX,top:t.clientY}}function yGe(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function DO(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 sb(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 vGe(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&cn.isSelectable(r)?(sb(t,new cn(n)),!0):!1}function wGe(t,e){if(e==-1)return!1;let n=t.state.selection,r,i;n instanceof cn&&(r=n.node);let s=t.state.doc.resolve(e);for(let o=s.depth+1;o>0;o--){let l=o>s.depth?s.nodeAfter:s.node(o);if(cn.isSelectable(l)){r&&n.$from.depth>0&&o>=n.$from.depth&&s.before(n.$from.depth+1)==n.$from.pos?i=s.before(n.$from.depth):i=s.before(o);break}}return i!=null?(sb(t,cn.create(t.state.doc,i)),!0):!1}function SGe(t,e,n,r,i){return DO(t,"handleClickOn",e,n,r)||t.someProp("handleClick",s=>s(t,e,r))||(i?wGe(t,n):vGe(t,n))}function _Ge(t,e,n,r){return DO(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",i=>i(t,e,r))}function NGe(t,e,n,r){return DO(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",i=>i(t,e,r))||CGe(t,n,r)}function CGe(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(sb(t,_n.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)sb(t,_n.create(r,l+1,l+1+o.content.size));else if(cn.isSelectable(o))sb(t,cn.create(r,l));else continue;return!0}}function RO(t){return YN(t)}const Wre=sl?"metaKey":"ctrlKey";Is.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=RO(t),i=Date.now(),s="singleClick";i-t.input.lastClick.time<500&&yGe(n,t.input.lastClick)&&!n[Wre]&&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(fA(n));o&&(s=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new kGe(t,o,n,!!r)):(s=="doubleClick"?_Ge:NGe)(t,o.pos,o.inside,n)?n.preventDefault():Ah(t,"pointer"))};class kGe{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[Wre],this.allowDefault=r.shiftKey;let s,o;if(n.inside>-1)s=e.state.doc.nodeAt(n.inside),o=n.inside;else{let u=e.state.doc.resolve(n.pos);s=u.parent,o=u.depth?u.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:d}=e.state;(r.button==0&&s.type.spec.draggable&&s.type.spec.selectable!==!1||d instanceof cn&&d.from<=o&&d.to>o)&&(this.mightDrag={node:s,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&xl&&!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)),Ah(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(()=>Zd(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(fA(e))),this.updateAllowDefault(e),this.allowDefault||!n?Ah(this.view,"pointer"):SGe(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||vs&&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)?(sb(this.view,zn.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):Ah(this.view,"pointer")}move(e){this.updateAllowDefault(e),Ah(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)}}Is.touchstart=t=>{t.input.lastTouch=Date.now(),RO(t),Ah(t,"pointer")};Is.touchmove=t=>{t.input.lastTouch=Date.now(),Ah(t,"pointer")};Is.contextmenu=t=>RO(t);function Kre(t,e){return t.composing?!0:vs&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const AGe=$d?5e3:-1;zs.compositionstart=zs.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof _n&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||ns&&Cre&&TGe(t)))t.markCursor=t.state.storedMarks||n.marks(),YN(t,!0),t.markCursor=null;else if(YN(t,!e.selection.empty),xl&&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}Xre(t,AGe)};function TGe(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"}zs.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++,Xre(t,20))};function Xre(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>YN(t),e))}function Yre(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=PGe());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function MGe(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=wqe(e.focusNode,e.focusOffset),r=Sqe(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 PGe(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function YN(t,e=!1){if(!($d&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),Yre(t),e||t.docView&&t.docView.dirty){let n=MO(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 EGe(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 K0=so&&Hh<15||Db&&kqe<604;Is.copy=zs.cut=(t,e)=>{let n=e,r=t.state.selection,i=n.type=="cut";if(r.empty)return;let s=K0?null:n.clipboardData,o=r.content(),{dom:l,text:c}=EO(t,o);s?(n.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",c)):EGe(t,l),i&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function jGe(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function DGe(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?X0(t,r.value,null,i,e):X0(t,r.textContent,r.innerHTML,i,e)},50)}function X0(t,e,n,r,i){let s=Bre(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=jGe(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 Qre(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," "):""}zs.paste=(t,e)=>{let n=e;if(t.composing&&!$d)return;let r=K0?null:n.clipboardData,i=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&X0(t,Qre(r),r.getData("text/html"),i,n)?n.preventDefault():DGe(t,n)};class Zre{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const RGe=sl?"altKey":"ctrlKey";function Jre(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[RGe]}Is.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(fA(n)),o;if(!(s&&s.pos>=i.from&&s.pos<=(i instanceof cn?i.to-1:i.to))){if(r&&r.mightDrag)o=cn.create(t.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let h=t.docView.nearestDesc(n.target,!0);h&&h.node.type.spec.draggable&&h!=t.docView&&(o=cn.create(t.state.doc,h.posBefore))}}let l=(o||t.state.selection).content(),{dom:c,text:d,slice:u}=EO(t,l);(!n.dataTransfer.files.length||!ns||Nre>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(K0?"Text":"text/html",c.innerHTML),n.dataTransfer.effectAllowed="copyMove",K0||n.dataTransfer.setData("text/plain",d),t.dragging=new Zre(u,Jre(t,n),o)};Is.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};zs.dragover=zs.dragenter=(t,e)=>e.preventDefault();zs.drop=(t,e)=>{try{FGe(t,e,t.dragging)}finally{t.dragging=null}};function FGe(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(fA(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=Bre(t,Qre(e.dataTransfer),K0?null:e.dataTransfer.getData("text/html"),!1,i);let o=!!(n&&Jre(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?rre(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 d=c.mapping.map(l),u=s.openStart==0&&s.openEnd==0&&s.content.childCount==1,h=c.doc;if(u?c.replaceRangeWith(d,d,s.content.firstChild):c.replaceRange(d,d,s),c.doc.eq(h))return;let f=c.doc.resolve(d);if(u&&cn.isSelectable(s.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(s.content.firstChild))c.setSelection(new cn(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(PO(t,f,c.doc.resolve(p)))}t.focus(),t.dispatch(c.setMeta("uiEvent","drop"))}Is.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())&&Zd(t)},20))};Is.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)};Is.beforeinput=(t,e)=>{if(ns&&$d&&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,Zm(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 zs)Is[t]=zs[t];function Y0(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 QN{constructor(e,n){this.toDOM=e,this.spec=n||_f,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 js(s-r,s-r,this)}valid(){return!0}eq(e){return this==e||e instanceof QN&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Y0(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Vh{constructor(e,n){this.attrs=e,this.spec=n||_f}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 js(s,o,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof Vh&&Y0(this.attrs,e.attrs)&&Y0(this.spec,e.spec)}static is(e){return e.type instanceof Vh}destroy(){}}class FO{constructor(e,n){this.attrs=e,this.spec=n||_f}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 js(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 FO&&Y0(this.attrs,e.attrs)&&Y0(this.spec,e.spec)}destroy(){}}class js{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new js(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 js(e,e,new QN(n,r))}static inline(e,n,r,i){return new js(e,n,new Vh(r,i))}static node(e,n,r,i){return new js(e,n,new FO(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof Vh}get widget(){return this.type instanceof QN}}const Fg=[],_f={};class va{constructor(e,n){this.local=e.length?e:Fg,this.children=n.length?n:Fg}static create(e,n){return n.length?ZN(n,e,0,_f):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||_f)}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?LGe(this.children,o||[],e,n,r,i,s):o?new va(o.sort(Nf),Fg):fs}add(e,n){return n.length?this==fs?va.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let i,s=0;e.forEach((l,c)=>{let d=c+r,u;if(u=tae(n,l,d)){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,u,d+1):i.splice(s,0,c,c+l.nodeSize,ZN(u,l,d+1,_f)),s+=3}});let o=eae(s?nae(n):n,-r);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||o.splice(l--,1);return new va(o.length?this.local.concat(o).sort(Nf):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 u=0,h;u<e.length;u++)(h=e[u])&&h.from>l&&h.to<c&&(e[u]=null,(o||(o=[])).push(h));if(!o)continue;r==this.children&&(r=this.children.slice());let d=r[s+2].removeInner(o,l+1);d!=fs?r[s+2]=d:(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 va(i,r):fs}forChild(e,n){if(this==fs)return this;if(n.isLeaf)return va.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 Vh){let d=Math.max(s,c.from)-s,u=Math.min(o,c.to)-s;d<u&&(i||(i=[])).push(c.copy(d,u))}}if(i){let l=new va(i.sort(Nf),Fg);return r?new bh([l,r]):l}return r||fs}eq(e){if(this==e)return!0;if(!(e instanceof va)||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 LO(this.localsInner(e))}localsInner(e){if(this==fs)return Fg;if(e.inlineContent||!this.local.some(Vh.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Vh||n.push(this.local[r]);return n}forEachSet(e){e(this)}}va.empty=new va([],[]);va.removeOverlap=LO;const fs=va.empty;class bh{constructor(e){this.members=e}map(e,n){const r=this.members.map(i=>i.map(e,n,_f));return bh.from(r)}forChild(e,n){if(n.isLeaf)return va.empty;let r=[];for(let i=0;i<this.members.length;i++){let s=this.members[i].forChild(e,n);s!=fs&&(s instanceof bh?r=r.concat(s.members):r.push(s))}return bh.from(r)}eq(e){if(!(e instanceof bh)||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?LO(r?n:n.sort(Nf)):Fg}static from(e){switch(e.length){case 0:return fs;case 1:return e[0];default:return new bh(e.every(n=>n instanceof va)?e:e.reduce((n,r)=>n.concat(r instanceof va?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function LGe(t,e,n,r,i,s,o){let l=t.slice();for(let d=0,u=s;d<n.maps.length;d++){let h=0;n.maps[d].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>_+u-h)continue;let N=l[y]+u-h;p>=N?l[y+1]=f<=N?-2:-1:f>=u&&g&&(l[y]+=g,l[y+1]+=g)}h+=g}),u=n.maps[d].map(u,-1)}let c=!1;for(let d=0;d<l.length;d+=3)if(l[d+1]<0){if(l[d+1]==-2){c=!0,l[d+1]=-1;continue}let u=n.map(t[d]+s),h=u-i;if(h<0||h>=r.content.size){c=!0;continue}let f=n.map(t[d+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[d+2].mapInner(n,g,u+1,t[d]+s+1,o);y!=fs?(l[d]=h,l[d+1]=p,l[d+2]=y):(l[d+1]=-2,c=!0)}else c=!0}if(c){let d=OGe(l,t,e,n,i,s,o),u=ZN(d,r,0,o);e=u.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<u.children.length;h+=3){let p=u.children[h];for(;f<l.length&&l[f]<p;)f+=3;l.splice(f,0,u.children[h],u.children[h+1],u.children[h+2])}}return new va(e.sort(Nf),l)}function eae(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 js(i.from+e,i.to+e,i.type))}return n}function OGe(t,e,n,r,i,s,o){function l(c,d){for(let u=0;u<c.local.length;u++){let h=c.local[u].map(r,i,d);h?n.push(h):o.onRemove&&o.onRemove(c.local[u].spec)}for(let u=0;u<c.children.length;u+=3)l(c.children[u+2],c.children[u]+d+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 tae(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 nae(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function ZN(t,e,n,r){let i=[],s=!1;e.forEach((l,c)=>{let d=tae(t,l,c+n);if(d){s=!0;let u=ZN(d,l,n+c+1,r);u!=fs&&i.push(c,c+l.nodeSize,u)}});let o=eae(s?nae(t):t,-n).sort(Nf);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 va(o,i):fs}function Nf(t,e){return t.from-e.from||t.to-e.to}function LO(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),rW(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),rW(e,i,r.copy(s.from,r.to)));break}}}return e}function rW(t,e,n){for(;e<t.length&&Nf(n,t[e])>0;)e++;t.splice(e,0,n)}function oj(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=fs&&e.push(r)}),t.cursorWrapper&&e.push(va.create(t.state.doc,[t.cursorWrapper.deco])),bh.from(e)}const IGe={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},zGe=so&&Hh<=11;class UGe{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 BGe{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new UGe,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]);so&&Hh<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():vs&&e.composing&&r.some(i=>i.type=="childList"&&i.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),zGe&&(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,IGe)),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(X9(this.view)){if(this.suppressingSelectionUpdates)return Zd(this.view);if(so&&Hh<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Yf(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=jb(s))n.add(s);for(let s=e.anchorNode;s;s=jb(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)&&X9(e)&&!this.ignoreSelectionChange(r),s=-1,o=-1,l=!1,c=[];if(e.editable)for(let u=0;u<n.length;u++){let h=this.registerMutation(n[u],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(u=>u.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let u of c)if(u.nodeName=="BR"&&u.parentNode){let h=u.nextSibling;h&&h.nodeType==1&&h.contentEditable=="false"&&u.parentNode.removeChild(u)}}else if(xl&&c.length){let u=c.filter(h=>h.nodeName=="BR");if(u.length==2){let[h,f]=u;h.parentNode&&h.parentNode.parentNode==f.parentNode?f.remove():h.remove()}else{let{focusNode:h}=this.currentSelection;for(let f of u){let p=f.parentNode;p&&p.nodeName=="LI"&&(!h||VGe(e,h)!=p)&&f.remove()}}}let d=null;s<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&hA(r)&&(d=MO(e))&&d.eq(zn.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Zd(e),this.currentSelection.set(r),e.scrollToSelection()):(s>-1||i)&&(s>-1&&(e.docView.markDirty(s,o),HGe(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,qGe(e,c)),this.handleDOMChange(s,o,l,c),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Zd(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 u=0;u<e.addedNodes.length;u++){let h=e.addedNodes[u];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(so&&Hh<=11&&e.addedNodes.length)for(let u=0;u<e.addedNodes.length;u++){let{previousSibling:h,nextSibling:f}=e.addedNodes[u];(!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,d=r.localPosFromDOM(e.target,c,1);return{from:l,to:d}}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 aW=new WeakMap,iW=!1;function HGe(t){if(!aW.has(t)&&(aW.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=xl,iW)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."),iW=!0}}function sW(t,e){let n=e.startContainer,r=e.startOffset,i=e.endContainer,s=e.endOffset,o=t.domAtPos(t.state.selection.anchor);return Yf(o.node,o.offset,i,s)&&([n,r,i,s]=[i,s,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:s}}function $Ge(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return sW(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?sW(t,n):null}function VGe(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 qGe(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 GGe(t,e,n){let{node:r,fromOffset:i,toOffset:s,from:o,to:l}=t.docView.parseRange(e,n),c=t.domSelectionRange(),d,u=c.anchorNode;if(u&&t.dom.contains(u.nodeType==1?u:u.parentNode)&&(d=[{node:u,offset:c.anchorOffset}],hA(c)||d.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")||Xy.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:d,ruleFromNode:WGe,context:p});if(d&&d[0].pos!=null){let g=d[0].pos,y=d[1]&&d[1].pos;y==null&&(y=g),x={anchor:g+o,head:y+o}}return{doc:v,sel:x,from:o,to:l}}function WGe(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(vs&&/^(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||vs&&/^(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 KGe=/^(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 XGe(t,e,n,r,i){let s=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let C=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,j=MO(t,C);if(j&&!t.state.selection.eq(j)){if(ns&&$d&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",E=>E(t,Zm(13,"Enter"))))return;let M=t.state.tr.setSelection(j);C=="pointer"?M.setMeta("pointer",!0):C=="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,d=GGe(t,e,n),u=t.state.doc,h=u.slice(d.from,d.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=ZGe(h.content,d.doc.content,d.from,f,p);if(x&&t.input.domChangeCount++,(Db&&t.input.lastIOSEnter>Date.now()-225||$d)&&i.some(C=>C.nodeType==1&&!KGe.test(C.nodeName))&&(!x||x.endA>=x.endB)&&t.someProp("handleKeyDown",C=>C(t,Zm(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!x)if(r&&c instanceof _n&&!c.empty&&c.$head.sameParent(c.$anchor)&&!t.composing&&!(d.sel&&d.sel.anchor!=d.sel.head))x={start:c.from,endA:c.to,endB:c.to};else{if(d.sel){let C=oW(t,t.state.doc,d.sel);if(C&&!C.eq(t.state.selection)){let j=t.state.tr.setSelection(C);s&&j.setMeta("composition",s),t.dispatch(j)}}return}t.state.selection.from<t.state.selection.to&&x.start==x.endB&&t.state.selection instanceof _n&&(x.start>t.state.selection.from&&x.start<=t.state.selection.from+2&&t.state.selection.from>=d.from?x.start=t.state.selection.from:x.endA<t.state.selection.to&&x.endA>=t.state.selection.to-2&&t.state.selection.to<=d.to&&(x.endB+=t.state.selection.to-x.endA,x.endA=t.state.selection.to)),so&&Hh<=11&&x.endB==x.start+1&&x.endA==x.start&&x.start>d.from&&d.doc.textBetween(x.start-d.from-1,x.start-d.from+1)==" "&&(x.start--,x.endA--,x.endB--);let v=d.doc.resolveNoCache(x.start-d.from),g=d.doc.resolveNoCache(x.endB-d.from),y=u.resolve(x.start),_=v.sameParent(g)&&v.parent.inlineContent&&y.end()>=x.endA;if((Db&&t.input.lastIOSEnter>Date.now()-225&&(!_||i.some(C=>C.nodeName=="DIV"||C.nodeName=="P"))||!_&&v.pos<d.doc.content.size&&(!v.sameParent(g)||!v.parent.inlineContent)&&v.pos<g.pos&&!/\S/.test(d.doc.textBetween(v.pos,g.pos,"","")))&&t.someProp("handleKeyDown",C=>C(t,Zm(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>x.start&&QGe(u,x.start,x.endA,v,g)&&t.someProp("handleKeyDown",C=>C(t,Zm(8,"Backspace")))){$d&&ns&&t.domObserver.suppressSelectionUpdates();return}ns&&x.endB==x.start&&(t.input.lastChromeDelete=Date.now()),$d&&!_&&v.start()!=g.start()&&g.parentOffset==0&&v.depth==g.depth&&d.sel&&d.sel.anchor==d.sel.head&&d.sel.head==x.endA&&(x.endB-=2,g=d.doc.resolveNoCache(x.endB-d.from),setTimeout(()=>{t.someProp("handleKeyDown",function(C){return C(t,Zm(13,"Enter"))})},20));let N=x.start,A=x.endA,k=C=>{let j=C||t.state.tr.replace(N,A,d.doc.slice(x.start-d.from,x.endB-d.from));if(d.sel){let M=oW(t,j.doc,d.sel);M&&!(ns&&t.composing&&M.empty&&(x.start!=x.endB||t.input.lastChromeDelete<Date.now()-100)&&(M.head==N||M.head==j.mapping.map(A)-1)||so&&M.empty&&M.head==N)&&j.setSelection(M)}return s&&j.setMeta("composition",s),j.scrollIntoView()},P;if(_)if(v.pos==g.pos){so&&Hh<=11&&v.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>Zd(t),20));let C=k(t.state.tr.delete(N,A)),j=u.resolve(x.start).marksAcross(u.resolve(x.endA));j&&C.ensureMarks(j),t.dispatch(C)}else if(x.endA==x.endB&&(P=YGe(v.parent.content.cut(v.parentOffset,g.parentOffset),y.parent.content.cut(y.parentOffset,x.endA-y.start())))){let C=k(t.state.tr);P.type=="add"?C.addMark(N,A,P.mark):C.removeMark(N,A,P.mark),t.dispatch(C)}else if(v.parent.child(v.index()).isText&&v.index()==g.index()-(g.textOffset?0:1)){let C=v.parent.textBetween(v.parentOffset,g.parentOffset),j=()=>k(t.state.tr.insertText(C,N,A));t.someProp("handleTextInput",M=>M(t,N,A,C,j))||t.dispatch(j())}else t.dispatch(k());else t.dispatch(k())}function oW(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:PO(t,e.resolve(n.anchor),e.resolve(n.head))}function YGe(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,i=n,s=r,o,l,c;for(let u=0;u<r.length;u++)i=r[u].removeFromSet(i);for(let u=0;u<n.length;u++)s=n[u].removeFromSet(s);if(i.length==1&&s.length==0)l=i[0],o="add",c=u=>u.mark(l.addToSet(u.marks));else if(i.length==0&&s.length==1)l=s[0],o="remove",c=u=>u.mark(l.removeFromSet(u.marks));else return null;let d=[];for(let u=0;u<e.childCount;u++)d.push(c(e.child(u)));if(Mt.from(d).eq(t))return{mark:l,type:o}}function QGe(t,e,n,r,i){if(n-e<=i.pos-r.pos||lj(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(lj(s,!0,!0));return!o.parent.isTextblock||o.pos>n||lj(o,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function lj(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 ZGe(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&&lW(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&&lW(t.textBetween(s-1,s+1))&&(s+=c?1:-1),o=s+(o-l),l=s}return{start:s,endA:o,endB:l}}function lW(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 rae{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 fGe,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(mW),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=uW(this),dW(this),this.nodeViews=hW(this),this.docView=$9(this.state.doc,cW(this),oj(this),this.dom,this),this.domObserver=new BGe(this,(r,i,s,o)=>XGe(this,r,i,s,o)),this.domObserver.start(),pGe(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&&OR(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(mW),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&&(Yre(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=hW(this);e7e(p,this.nodeViews)&&(this.nodeViews=p,s=!0)}(l||n.handleDOMEvents!=this._props.handleDOMEvents)&&OR(this),this.editable=uW(this),dW(this);let c=oj(this),d=cW(this),u=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",h=s||!this.docView.matchesNode(e.doc,d,c);(h||!e.selection.eq(i.selection))&&(o=!0);let f=u=="preserve"&&o&&this.dom.style.overflowAnchor==null&&Mqe(this);if(o){this.domObserver.stop();let p=h&&(so||ns)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&JGe(i.selection,e.selection);if(h){let x=ns?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=MGe(this)),(s||!this.docView.update(e.doc,d,c,this))&&(this.docView.updateOuterDeco(d),this.docView.destroy(),this.docView=$9(e.doc,d,c,this.dom,this)),x&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(p=!0)}p||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Jqe(this))?Zd(this,p):(Ire(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),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():f&&Pqe(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 cn){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&O9(this,n.getBoundingClientRect(),e)}else O9(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 Zre(e.slice,e.move,i<0?void 0:cn.create(this.state.doc,i))}someProp(e,n){let r=this._props&&this._props[e],i;if(r!=null&&(i=n?n(r):r))return i;for(let o=0;o<this.directPlugins.length;o++){let l=this.directPlugins[o].props[e];if(l!=null&&(i=n?n(l):l))return i}let s=this.state.plugins;if(s)for(let o=0;o<s.length;o++){let l=s[o].props[e];if(l!=null&&(i=n?n(l):l))return i}}hasFocus(){if(so){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&&Eqe(this.dom),Zd(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 Lqe(this,e)}coordsAtPos(e,n=1){return Pre(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 Bqe(this,n||this.state,e)}pasteHTML(e,n){return X0(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return X0(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return EO(this,e)}destroy(){this.docView&&(gGe(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],oj(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,yqe())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return xGe(this,e)}domSelectionRange(){let e=this.domSelection();return e?vs&&this.root.nodeType===11&&Nqe(this.dom.ownerDocument)==this.dom&&$Ge(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}rae.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function cW(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"),[js.node(0,t.state.doc.content.size,e)]}function dW(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:js.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function uW(t){return!t.someProp("editable",e=>e(t.state)===!1)}function JGe(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 hW(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 e7e(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 mW(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 em={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},JN={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},t7e=typeof navigator<"u"&&/Mac/.test(navigator.platform),n7e=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var ts=0;ts<10;ts++)em[48+ts]=em[96+ts]=String(ts);for(var ts=1;ts<=24;ts++)em[ts+111]="F"+ts;for(var ts=65;ts<=90;ts++)em[ts]=String.fromCharCode(ts+32),JN[ts]=String.fromCharCode(ts);for(var cj in em)JN.hasOwnProperty(cj)||(JN[cj]=em[cj]);function r7e(t){var e=t7e&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||n7e&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?JN:em)[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 a7e=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),i7e=typeof navigator<"u"&&/Win/.test(navigator.platform);function s7e(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))a7e?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 o7e(t){let e=Object.create(null);for(let n in t)e[s7e(n)]=t[n];return e}function dj(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 l7e(t){return new Na({props:{handleKeyDown:aae(t)}})}function aae(t){let e=o7e(t);return function(n,r){let i=r7e(r),s,o=e[dj(i,r)];if(o&&o(n.state,n.dispatch,n))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let l=e[dj(i,r,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(i7e&&r.ctrlKey&&r.altKey)&&(s=em[r.keyCode])&&s!=i){let l=e[dj(s,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}var c7e=Object.defineProperty,OO=(t,e)=>{for(var n in e)c7e(t,n,{get:e[n],enumerable:!0})};function pA(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 gA=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,(...d)=>{const u=l(...d)(s);return!i.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(i),u}]))}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,d=()=>(!l&&e&&!c.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(c),o.every(h=>h===!0)),u={...Object.fromEntries(Object.entries(n).map(([h,f])=>[h,(...x)=>{const v=this.buildProps(c,e),g=f(...x)(v);return o.push(g),u}])),run:d};return u}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,(...d)=>c(...d)({...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:pA({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,(...d)=>c(...d)(o)]))}};return o}},iae={};OO(iae,{blur:()=>d7e,clearContent:()=>u7e,clearNodes:()=>h7e,command:()=>m7e,createParagraphNear:()=>f7e,cut:()=>p7e,deleteCurrentNode:()=>g7e,deleteNode:()=>b7e,deleteRange:()=>x7e,deleteSelection:()=>y7e,enter:()=>v7e,exitCode:()=>w7e,extendMarkRange:()=>S7e,first:()=>_7e,focus:()=>C7e,forEach:()=>k7e,insertContent:()=>A7e,insertContentAt:()=>P7e,joinBackward:()=>D7e,joinDown:()=>j7e,joinForward:()=>R7e,joinItemBackward:()=>F7e,joinItemForward:()=>L7e,joinTextblockBackward:()=>O7e,joinTextblockForward:()=>I7e,joinUp:()=>E7e,keyboardShortcut:()=>U7e,lift:()=>B7e,liftEmptyBlock:()=>H7e,liftListItem:()=>$7e,newlineInCode:()=>V7e,resetAttributes:()=>q7e,scrollIntoView:()=>G7e,selectAll:()=>W7e,selectNodeBackward:()=>K7e,selectNodeForward:()=>X7e,selectParentNode:()=>Y7e,selectTextblockEnd:()=>Q7e,selectTextblockStart:()=>Z7e,setContent:()=>J7e,setMark:()=>y9e,setMeta:()=>v9e,setNode:()=>w9e,setNodeSelection:()=>S9e,setTextDirection:()=>_9e,setTextSelection:()=>N9e,sinkListItem:()=>C9e,splitBlock:()=>k9e,splitListItem:()=>A9e,toggleList:()=>T9e,toggleMark:()=>M9e,toggleNode:()=>P9e,toggleWrap:()=>E9e,undoInputRule:()=>j9e,unsetAllMarks:()=>D9e,unsetMark:()=>R9e,unsetTextDirection:()=>F9e,updateAttributes:()=>L9e,wrapIn:()=>O9e,wrapInList:()=>I9e});var d7e=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window?.getSelection())==null||n.removeAllRanges())}),!0),u7e=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),h7e=()=>({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:d,mapping:u}=e,h=d.resolve(u.map(c)),f=d.resolve(u.map(c+l.nodeSize)),p=h.blockRange(f);if(!p)return;const x=lx(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},m7e=t=>e=>t(e),f7e=()=>({state:t,dispatch:e})=>yre(t,e),p7e=(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 _n(r.doc.resolve(Math.max(o-1,0)))),!0},g7e=()=>({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 si(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 b7e=t=>({tr:e,state:n,dispatch:r})=>{const i=si(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),d=s.after(o);e.delete(c,d).scrollIntoView()}return!0}return!1},x7e=t=>({tr:e,dispatch:n})=>{const{from:r,to:i}=t;return n&&e.delete(r,i),!0},y7e=()=>({state:t,dispatch:e})=>_O(t,e),v7e=()=>({commands:t})=>t.keyboardShortcut("Enter"),w7e=()=>({state:t,dispatch:e})=>aqe(t,e);function IO(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function eC(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(i=>n.strict?e[i]===t[i]:IO(e[i])?e[i].test(t[i]):e[i]===t[i]):!0}function sae(t,e,n={}){return t.find(r=>r.type===e&&eC(Object.fromEntries(Object.keys(n).map(i=>[i,r.attrs[i]])),n))}function fW(t,e,n={}){return!!sae(t,e,n)}function zO(t,e,n){var r;if(!t||!e)return;let i=t.parent.childAfter(t.parentOffset);if((!i.node||!i.node.marks.some(u=>u.type===e))&&(i=t.parent.childBefore(t.parentOffset)),!i.node||!i.node.marks.some(u=>u.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,d=l+i.node.nodeSize;for(;o>0&&fW([...t.parent.child(o-1).marks],e,n);)o-=1,l-=t.parent.child(o).nodeSize;for(;c<t.parent.childCount&&fW([...t.parent.child(c).marks],e,n);)d+=t.parent.child(c).nodeSize,c+=1;return{from:l,to:d}}function vu(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 S7e=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const s=vu(t,r.schema),{doc:o,selection:l}=n,{$from:c,from:d,to:u}=l;if(i){const h=zO(c,s,e);if(h&&h.from<=d&&h.to>=u){const f=_n.create(o,h.from,h.to);n.setSelection(f)}}return!0},_7e=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 oae(t){return t instanceof _n}function df(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function lae(t,e=null){if(!e)return null;const n=zn.atStart(t),r=zn.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;const i=n.from,s=r.to;return e==="all"?_n.create(t,df(0,i,s),df(t.content.size,i,s)):_n.create(t,df(e,i,s),df(e,i,s))}function pW(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function tC(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function N7e(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}var C7e=(t=null,e={})=>({editor:n,view:r,tr:i,dispatch:s})=>{e={scrollIntoView:!0,...e};const o=()=>{(tC()||pW())&&r.dom.focus(),N7e()&&!tC()&&!pW()&&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&&!oae(n.state.selection))return o(),!0;const l=lae(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},k7e=(t,e)=>n=>t.every((r,i)=>e(r,{...n,index:i})),A7e=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),cae=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&&cae(r)}return t};function N_(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 cae(n)}function Q0(t,e,n){if(t instanceof Bh||t instanceof Mt)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 Mt.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),Q0("",e,n)}if(i){if(n.errorOnInvalidContent){let o=!1,l="";const c=new Gne({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:d=>(o=!0,l=typeof d=="string"?d:d.outerHTML,null)}]}})});if(n.slice?Xy.fromSchema(c).parseSlice(N_(t),n.parseOptions):Xy.fromSchema(c).parse(N_(t),n.parseOptions),n.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const s=Xy.fromSchema(e);return n.slice?s.parseSlice(N_(t),n.parseOptions).content:s.parse(N_(t),n.parseOptions)}return Q0("",e,n)}function T7e(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,d,u)=>{o===0&&(o=u)}),t.setSelection(zn.near(t.doc.resolve(o),n))}var M7e=t=>!("type"in t),P7e=(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)}})},d={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!s.options.enableContentCheck&&s.options.emitContentError)try{Q0(e,s.schema,{parseOptions:d,errorOnInvalidContent:!0})}catch(g){c(g)}try{l=Q0(e,s.schema,{parseOptions:d,errorOnInvalidContent:(o=n.errorOnInvalidContent)!=null?o:s.options.enableContentCheck})}catch(g){return c(g),!1}let{from:u,to:h}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},f=!0,p=!0;if((M7e(l)?l:[l]).forEach(g=>{g.check(),f=f?g.isText&&g.marks.length===0:!1,p=p?g.isBlock:!1}),u===h&&p){const{parent:g}=r.doc.resolve(u);g.isTextblock&&!g.type.spec.code&&!g.childCount&&(u-=1,h+=1)}let v;if(f){if(Array.isArray(e))v=e.map(g=>g.text||"").join("");else if(e instanceof Mt){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,u,h)}else{v=l;const g=r.doc.resolve(u),y=g.node(),_=g.parentOffset===0,N=y.isText||y.isTextblock,A=y.content.size>0;_&&N&&A&&(u=Math.max(0,u-1)),r.replaceWith(u,h,v)}n.updateSelection&&T7e(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:u,text:v}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:u,text:v})}return!0},E7e=()=>({state:t,dispatch:e})=>tqe(t,e),j7e=()=>({state:t,dispatch:e})=>nqe(t,e),D7e=()=>({state:t,dispatch:e})=>hre(t,e),R7e=()=>({state:t,dispatch:e})=>gre(t,e),F7e=()=>({state:t,dispatch:e,tr:n})=>{try{const r=cA(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},L7e=()=>({state:t,dispatch:e,tr:n})=>{try{const r=cA(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},O7e=()=>({state:t,dispatch:e})=>JVe(t,e),I7e=()=>({state:t,dispatch:e})=>eqe(t,e);function dae(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function z7e(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))tC()||dae()?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 U7e=t=>({editor:e,view:n,tr:r,dispatch:i})=>{const s=z7e(t).split(/-(?!$)/),o=s.find(d=>!["Alt","Ctrl","Meta","Shift"].includes(d)),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",d=>d(n,l))});return c?.steps.forEach(d=>{const u=d.map(r.mapping);u&&i&&r.maybeStep(u)}),!0};function tm(t,e,n={}){const{from:r,to:i,empty:s}=t.selection,o=e?si(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,d=l.filter(h=>o?o.name===h.node.type.name:!0).filter(h=>eC(h.node.attrs,n,{strict:!1}));return s?!!d.length:d.reduce((h,f)=>h+f.to-f.from,0)>=c}var B7e=(t,e={})=>({state:n,dispatch:r})=>{const i=si(t,n.schema);return tm(n,i,e)?rqe(n,r):!1},H7e=()=>({state:t,dispatch:e})=>vre(t,e),$7e=t=>({state:e,dispatch:n})=>{const r=si(t,e.schema);return pqe(r)(e,n)},V7e=()=>({state:t,dispatch:e})=>xre(t,e);function bA(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function gW(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 q7e=(t,e)=>({tr:n,state:r,dispatch:i})=>{let s=null,o=null;const l=bA(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(s=si(t,r.schema)),l==="mark"&&(o=vu(t,r.schema));let c=!1;return n.selection.ranges.forEach(d=>{r.doc.nodesBetween(d.$from.pos,d.$to.pos,(u,h)=>{s&&s===u.type&&(c=!0,i&&n.setNodeMarkup(h,void 0,gW(u.attrs,e))),o&&u.marks.length&&u.marks.forEach(f=>{o===f.type&&(c=!0,i&&n.addMark(h,h+u.nodeSize,o.create(gW(f.attrs,e))))})})}),c},G7e=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),W7e=()=>({tr:t,dispatch:e})=>{if(e){const n=new Fo(t.doc);t.setSelection(n)}return!0},K7e=()=>({state:t,dispatch:e})=>fre(t,e),X7e=()=>({state:t,dispatch:e})=>bre(t,e),Y7e=()=>({state:t,dispatch:e})=>oqe(t,e),Q7e=()=>({state:t,dispatch:e})=>dqe(t,e),Z7e=()=>({state:t,dispatch:e})=>cqe(t,e);function IR(t,e,n={},r={}){return Q0(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var J7e=(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 d=IR(t,i.schema,r,{errorOnInvalidContent:e??i.options.enableContentCheck});return o&&s.replaceWith(0,c.content.size,d).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 uae(t,e){const n=vu(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 hae(t,e){const n=new lre(t);return e.forEach(r=>{r.steps.forEach(i=>{n.step(i)})}),n}function e9e(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 t9e(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(i,s)=>{n(i)&&r.push({node:i,pos:s})}),r}function n9e(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 xA(t){return e=>n9e(e.$from,t)}function an(t,e,n){return t.config[e]===void 0&&t.parent?an(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?an(t.parent,e,n):null}):t.config[e]}function UO(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=an(e,"addExtensions",n);return r?[e,...UO(r())]:e}).flat(10)}function BO(t,e){const n=ip.fromSchema(e).serializeFragment(t),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(n),i.innerHTML}function mae(t){return typeof t=="function"}function Mr(t,e=void 0,...n){return mae(t)?e?t.bind(e)(...n):t(...n):t}function r9e(t={}){return Object.keys(t).length===0&&t.constructor===Object}function Rb(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 fae(t){const e=[],{nodeExtensions:n,markExtensions:r}=Rb(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=an(o,"addGlobalAttributes",l);if(!c)return;c().forEach(u=>{u.types.forEach(h=>{Object.entries(u.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=an(o,"addAttributes",l);if(!c)return;const d=c();Object.entries(d).forEach(([u,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:u,attribute:f})})}),e}function Ia(...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(" "):[],d=l.filter(u=>!c.includes(u));r[i]=[...c,...d].join(" ")}else if(i==="style"){const l=s?s.split(";").map(u=>u.trim()).filter(Boolean):[],c=r[i]?r[i].split(";").map(u=>u.trim()).filter(Boolean):[],d=new Map;c.forEach(u=>{const[h,f]=u.split(":").map(p=>p.trim());d.set(h,f)}),l.forEach(u=>{const[h,f]=u.split(":").map(p=>p.trim());d.set(h,f)}),r[i]=Array.from(d.entries()).map(([u,h])=>`${u}: ${h}`).join("; ")}else r[i]=s}),r},{})}function Z0(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)=>Ia(n,r),{})}function a9e(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function bW(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):a9e(n.getAttribute(o.name));return l==null?s:{...s,[o.name]:l}},{});return{...r,...i}}}}function xW(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&r9e(n)?!1:n!=null))}function yW(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 i9e(t,e){var n;const r=fae(t),{nodeExtensions:i,markExtensions:s}=Rb(t),o=(n=i.find(d=>an(d,"topNode")))==null?void 0:n.name,l=Object.fromEntries(i.map(d=>{const u=r.filter(y=>y.type===d.name),h={name:d.name,options:d.options,storage:d.storage,editor:e},f=t.reduce((y,_)=>{const N=an(_,"extendNodeSchema",h);return{...y,...N?N(d):{}}},{}),p=xW({...f,content:Mr(an(d,"content",h)),marks:Mr(an(d,"marks",h)),group:Mr(an(d,"group",h)),inline:Mr(an(d,"inline",h)),atom:Mr(an(d,"atom",h)),selectable:Mr(an(d,"selectable",h)),draggable:Mr(an(d,"draggable",h)),code:Mr(an(d,"code",h)),whitespace:Mr(an(d,"whitespace",h)),linebreakReplacement:Mr(an(d,"linebreakReplacement",h)),defining:Mr(an(d,"defining",h)),isolating:Mr(an(d,"isolating",h)),attrs:Object.fromEntries(u.map(yW))}),x=Mr(an(d,"parseHTML",h));x&&(p.parseDOM=x.map(y=>bW(y,u)));const v=an(d,"renderHTML",h);v&&(p.toDOM=y=>v({node:y,HTMLAttributes:Z0(y,u)}));const g=an(d,"renderText",h);return g&&(p.toText=g),[d.name,p]})),c=Object.fromEntries(s.map(d=>{const u=r.filter(g=>g.type===d.name),h={name:d.name,options:d.options,storage:d.storage,editor:e},f=t.reduce((g,y)=>{const _=an(y,"extendMarkSchema",h);return{...g,..._?_(d):{}}},{}),p=xW({...f,inclusive:Mr(an(d,"inclusive",h)),excludes:Mr(an(d,"excludes",h)),group:Mr(an(d,"group",h)),spanning:Mr(an(d,"spanning",h)),code:Mr(an(d,"code",h)),attrs:Object.fromEntries(u.map(yW))}),x=Mr(an(d,"parseHTML",h));x&&(p.parseDOM=x.map(g=>bW(g,u)));const v=an(d,"renderHTML",h);return v&&(p.toDOM=g=>v({mark:g,HTMLAttributes:Z0(g,u)})),[d.name,p]}));return new Gne({topNode:o,nodes:l,marks:c})}function s9e(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function nC(t){return t.sort((n,r)=>{const i=an(n,"priority")||100,s=an(r,"priority")||100;return i>s?-1:i<s?1:0})}function pae(t){const e=nC(UO(t)),n=s9e(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 gae(t,e,n){const{from:r,to:i}=e,{blockSeparator:s=`
- `,textSerializers:o={}}=n||{};let l="";return t.nodesBetween(r,i,(c,d,u,h)=>{var f;c.isBlock&&d>r&&(l+=s);const p=o?.[c.type.name];if(p)return u&&(l+=p({node:c,pos:d,parent:u,index:h,range:e})),!1;c.isText&&(l+=(f=c?.text)==null?void 0:f.slice(Math.max(r,d)-d,i-d))}),l}function o9e(t,e){const n={from:0,to:t.content.size};return gae(t,n,e)}function bae(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function l9e(t,e){const n=si(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 xae(t,e){const n=bA(typeof e=="string"?e:e.name,t.schema);return n==="node"?l9e(t,e):n==="mark"?uae(t,e):{}}function c9e(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 d9e(t){const e=c9e(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 yae(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 d=e.slice(s).map(l,-1),u=e.slice(s).map(c),h=e.invert().map(d,-1),f=e.invert().map(u);r.push({oldRange:{from:h,to:f},newRange:{from:d,to:u}})})}),d9e(r)}function HO(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(i=>{const s=n.resolve(t),o=zO(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 u9e=(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 C_(t,e){return e.nodes[t]||e.marks[t]||null}function o1(t,e,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{const i=t.find(s=>s.type===e&&s.name===r);return i?i.attribute.keepOnSplit:!1}))}var h9e=(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,d;const u=((d=(c=i.type.spec).toText)==null?void 0:d.call(c,{node:i,pos:s,parent:o,index:l}))||i.textContent||"%leaf%";n+=i.isAtom&&!i.isText?u:u.slice(0,Math.max(0,r-s))}),n};function zR(t,e,n={}){const{empty:r,ranges:i}=t.selection,s=e?vu(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(h=>s?s.name===h.type.name:!0).find(h=>eC(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=>eC(h.mark.attrs,n,{strict:!1})).reduce((h,f)=>h+f.to-f.from,0),d=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+d:c)>=o}function m9e(t,e,n={}){if(!e)return tm(t,null,n)||zR(t,null,n);const r=bA(e,t.schema);return r==="node"?tm(t,e,n):r==="mark"?zR(t,e,n):!1}var f9e=(t,e)=>{const{$from:n,$to:r,$anchor:i}=t.selection;if(e){const s=xA(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)},p9e=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function vW(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function wW(t,e){const{nodeExtensions:n}=Rb(e),r=n.find(o=>o.name===t);if(!r)return!1;const i={name:r.name,options:r.options,storage:r.storage},s=Mr(an(r,"group",i));return typeof s!="string"?!1:s.split(" ").includes("list")}function yA(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&&(yA(s,{ignoreWhitespace:n,checkChildren:e})||(i=!1))}),i}return!1}function vae(t){return t instanceof cn}var wae=class Sae{constructor(e){this.position=e}static fromJSON(e){return new Sae(e.position)}toJSON(){return{position:this.position}}};function g9e(t,e){const n=e.mapping.mapResult(t.position);return{position:new wae(n.pos),mapResult:n}}function b9e(t){return new wae(t)}function x9e(t,e,n){var r;const{selection:i}=e;let s=null;if(oae(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(d=>d.type.excludes(n)))}const{ranges:o}=i;return o.some(({$from:l,$to:c})=>{let d=l.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(l.pos,c.pos,(u,h,f)=>{if(d)return!1;if(u.isInline){const p=!f||f.type.allowsMarkType(n),x=!!n.isInSet(u.marks)||!u.marks.some(v=>v.type.excludes(n));d=p&&x}return!d}),d})}var y9e=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const{selection:s}=n,{empty:o,ranges:l}=s,c=vu(t,r.schema);if(i)if(o){const d=uae(r,c);n.addStoredMark(c.create({...d,...e}))}else l.forEach(d=>{const u=d.$from.pos,h=d.$to.pos;r.doc.nodesBetween(u,h,(f,p)=>{const x=Math.max(p,u),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 x9e(r,n,c)},v9e=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),w9e=(t,e={})=>({state:n,dispatch:r,chain:i})=>{const s=si(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})=>R9(s,{...o,...e})(n)?!0:l.clearNodes()).command(({state:l})=>R9(s,{...o,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},S9e=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,i=df(t,0,r.content.size),s=cn.create(r,i);e.setSelection(s)}return!0},_9e=(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,d)=>{c.isText||n.setNodeMarkup(d,void 0,{...c.attrs,dir:t})}),!0},N9e=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:i,to:s}=typeof t=="number"?{from:t,to:t}:t,o=_n.atStart(r).from,l=_n.atEnd(r).to,c=df(i,o,l),d=df(s,o,l),u=_n.create(r,c,d);e.setSelection(u)}return!0},C9e=t=>({state:e,dispatch:n})=>{const r=si(t,e.schema);return xqe(r)(e,n)};function SW(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 k9e=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:i})=>{const{selection:s,doc:o}=e,{$from:l,$to:c}=s,d=i.extensionManager.attributes,u=o1(d,l.node().type.name,l.node().attrs);if(s instanceof cn&&s.node.isBlock)return!l.parentOffset||!Qd(o,l.pos)?!1:(r&&(t&&SW(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:e9e(l.node(-1).contentMatchAt(l.indexAfter(-1)));let p=h&&f?[{type:f,attrs:u}]:void 0,x=Qd(e.doc,e.mapping.map(l.pos),1,p);if(!p&&!x&&Qd(e.doc,e.mapping.map(l.pos),1,f?[{type:f}]:void 0)&&(x=!0,p=f?[{type:f,attrs:u}]:void 0),r){if(x&&(s instanceof _n&&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&&SW(n,i.extensionManager.splittableMarks),e.scrollIntoView()}return x},A9e=(t,e={})=>({tr:n,state:r,dispatch:i,editor:s})=>{var o;const l=si(t,r.schema),{$from:c,$to:d}=r.selection,u=r.selection.node;if(u&&u.isBlock||c.depth<2||!c.sameParent(d))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=Mt.empty;const _=c.index(-1)?1:c.index(-2)?2:3;for(let j=c.depth-_;j>=c.depth-3;j-=1)y=Mt.from(c.node(j).copy(y));const N=c.indexAfter(-1)<c.node(-2).childCount?1:c.indexAfter(-2)<c.node(-3).childCount?2:3,A={...o1(f,c.node().type.name,c.node().attrs),...e},k=((o=l.contentMatch.defaultType)==null?void 0:o.createAndFill(A))||void 0;y=y.append(Mt.from(l.createAndFill(null,k)||void 0));const P=c.before(c.depth-(_-1));n.replace(P,c.after(-N),new qt(y,4-_,0));let C=-1;n.doc.nodesBetween(P,n.doc.content.size,(j,M)=>{if(C>-1)return!1;j.isTextblock&&j.content.size===0&&(C=M+1)}),C>-1&&n.setSelection(_n.near(n.doc.resolve(C))),n.scrollIntoView()}return!0}const p=d.pos===c.end()?h.contentMatchAt(0).defaultType:null,x={...o1(f,h.type.name,h.attrs),...e},v={...o1(f,c.node().type.name,c.node().attrs),...e};n.delete(c.pos,d.pos);const g=p?[{type:l,attrs:x},{type:p,attrs:v}]:[{type:l,attrs:x}];if(!Qd(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 k=A.filter(P=>N.includes(P.type.name));n.ensureMarks(k)}return!0},uj=(t,e)=>{const n=xA(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&&lm(t.doc,n.pos)&&t.join(n.pos),!0},hj=(t,e)=>{const n=xA(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&&lm(t.doc,r)&&t.join(r),!0},T9e=(t,e,n,r={})=>({editor:i,tr:s,state:o,dispatch:l,chain:c,commands:d,can:u})=>{const{extensions:h,splittableMarks:f}=i.extensionManager,p=si(t,o.schema),x=si(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 k=xA(P=>wW(P.type.name,h))(v);if(N.depth>=1&&k&&N.depth-k.depth<=1){if(k.node.type===p)return d.liftListItem(x);if(wW(k.node.type.name,h)&&p.validContent(k.node.content)&&l)return c().command(()=>(s.setNodeMarkup(k.pos,p),!0)).command(()=>uj(s,p)).command(()=>hj(s,p)).run()}return!n||!A||!l?c().command(()=>u().wrapInList(p,r)?!0:d.clearNodes()).wrapInList(p,r).command(()=>uj(s,p)).command(()=>hj(s,p)).run():c().command(()=>{const P=u().wrapInList(p,r),C=A.filter(j=>f.includes(j.type.name));return s.ensureMarks(C),P?!0:d.clearNodes()}).wrapInList(p,r).command(()=>uj(s,p)).command(()=>hj(s,p)).run()},M9e=(t,e={},n={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:s=!1}=n,o=vu(t,r.schema);return zR(r,o,e)?i.unsetMark(o,{extendEmptyMarkRange:s}):i.setMark(o,e)},P9e=(t,e,n={})=>({state:r,commands:i})=>{const s=si(t,r.schema),o=si(e,r.schema),l=tm(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})},E9e=(t,e={})=>({state:n,commands:r})=>{const i=si(t,n.schema);return tm(n,i,e)?r.lift(i):r.wrapIn(i,e)},j9e=()=>({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},D9e=()=>({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},R9e=(t,e={})=>({tr:n,state:r,dispatch:i})=>{var s;const{extendEmptyMarkRange:o=!1}=e,{selection:l}=n,c=vu(t,r.schema),{$from:d,empty:u,ranges:h}=l;if(!i)return!0;if(u&&o){let{from:f,to:p}=l;const x=(s=d.marks().find(g=>g.type===c))==null?void 0:s.attrs,v=zO(d,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},F9e=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 d={...l.attrs};delete d.dir,e.setNodeMarkup(c,void 0,d)}),!0},L9e=(t,e={})=>({tr:n,state:r,dispatch:i})=>{let s=null,o=null;const l=bA(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(s=si(t,r.schema)),l==="mark"&&(o=vu(t,r.schema));let c=!1;return n.selection.ranges.forEach(d=>{const u=d.$from.pos,h=d.$to.pos;let f,p,x,v;n.selection.empty?r.doc.nodesBetween(u,h,(g,y)=>{s&&s===g.type&&(c=!0,x=Math.max(y,u),v=Math.min(y+g.nodeSize,h),f=y,p=g)}):r.doc.nodesBetween(u,h,(g,y)=>{y<u&&s&&s===g.type&&(c=!0,x=Math.max(y,u),v=Math.min(y+g.nodeSize,h),f=y,p=g),y>=u&&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,u),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},O9e=(t,e={})=>({state:n,dispatch:r})=>{const i=si(t,n.schema);return uqe(i,e)(n,r)},I9e=(t,e={})=>({state:n,dispatch:r})=>{const i=si(t,n.schema);return hqe(i,e)(n,r)},z9e=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={}}},vA=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},U9e=(t,e)=>{if(IO(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 k_(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 d=c.state.doc.resolve(r);if(d.parent.type.spec.code||(e=d.nodeBefore||d.nodeAfter)!=null&&e.marks.find(f=>f.type.spec.code))return!1;let u=!1;const h=h9e(d)+s;return o.forEach(f=>{if(u)return;const p=U9e(h,f.find);if(!p)return;const x=c.state.tr,v=pA({state:c.state,transaction:x}),g={from:r-(p[0].length-s.length),to:i},{commands:y,chain:_,can:N}=new gA({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),u=!0)}),u}function B9e(t){const{editor:e,rules:n}=t,r=new Na({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:u}=c;typeof u=="string"?u=u:u=BO(Mt.from(u),o.schema);const{from:h}=c,f=h+u.length;k_({editor:e,from:h,to:f,text:u,rules:n,plugin:r})}),i.selectionSet||i.docChanged?null:s}},props:{handleTextInput(i,s,o,l){return k_({editor:e,from:s,to:o,text:l,rules:n,plugin:r})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:s}=i.state.selection;s&&k_({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?k_({editor:e,from:o.pos,to:o.pos,text:`
- `,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function H9e(t){return Object.prototype.toString.call(t).slice(8,-1)}function A_(t){return H9e(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function _ae(t,e){const n={...t};return A_(t)&&A_(e)&&Object.keys(e).forEach(r=>{A_(e[r])&&A_(t[r])?n[r]=_ae(t[r],e[r]):n[r]=e[r]}),n}var $O=class{constructor(t={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...t},this.name=this.config.name}get options(){return{...Mr(an(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...Mr(an(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>_ae(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}},dm=class Nae extends $O{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new Nae(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(d=>d?.type.name===n.name))return!1;const c=o.find(d=>d?.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 $9e(t){return typeof t=="number"}var V9e=class{constructor(t){this.find=t.find,this.handler=t.handler}},q9e=(t,e,n)=>{if(IO(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 G9e(t){const{editor:e,state:n,from:r,to:i,rule:s,pasteEvent:o,dropEvent:l}=t,{commands:c,chain:d,can:u}=new gA({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,k=Math.max(r,x),P=Math.min(i,x+A);if(k>=P)return;const C=p.isText?p.text||"":p.textBetween(k-x,P-x,void 0,"");q9e(C,s.find,o).forEach(M=>{if(M.index===void 0)return;const E=k+M.index+1,B=E+M[0].length,L={from:n.tr.mapping.map(E),to:n.tr.mapping.map(B)},U=s.handler({state:n,range:L,match:M,commands:c,chain:d,can:u,pasteEvent:o,dropEvent:l});h.push(U)})}),h.every(p=>p!==null)}var T_=null,W9e=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function K9e(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:u,from:h,to:f,rule:p,pasteEvt:x})=>{const v=u.tr,g=pA({state:u,transaction:v});if(!(!G9e({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(u=>new Na({view(h){const f=x=>{var v;r=(v=h.dom.parentElement)!=null&&v.contains(x.target)?h.dom.parentElement:null,r&&(T_=e)},p=()=>{T_&&(T_=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=T_;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:k}=y;typeof k=="string"?k=k:k=BO(Mt.from(k),p.schema);const{from:P}=y,C=P+k.length,j=W9e(k);return c({rule:u,state:p,from:P,to:{b:C},pasteEvt:j})}const N=f.doc.content.findDiffStart(p.doc.content),A=f.doc.content.findDiffEnd(p.doc.content);if(!(!$9e(N)||!A||N===A.b))return c({rule:u,state:p,from:N,to:A,pasteEvt:o})}}))}var wA=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=pae(t),this.schema=i9e(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:C_(e.name,this.schema)},r=an(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return nC([...this.extensions].reverse()).flatMap(r=>{const i={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:C_(r.name,this.schema)},s=[],o=an(r,"addKeyboardShortcuts",i);let l={};if(r.type==="mark"&&an(r,"exitable",i)&&(l.ArrowRight=()=>dm.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=l7e(l);s.push(c);const d=an(r,"addInputRules",i);if(vW(r,t.options.enableInputRules)&&d){const f=d();if(f&&f.length){const p=B9e({editor:t,rules:f}),x=Array.isArray(p)?p:[p];s.push(...x)}}const u=an(r,"addPasteRules",i);if(vW(r,t.options.enablePasteRules)&&u){const f=u();if(f&&f.length){const p=K9e({editor:t,rules:f});s.push(...p)}}const h=an(r,"addProseMirrorPlugins",i);if(h){const f=h();s.push(...f)}return s})}get attributes(){return fae(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=Rb(this.extensions);return Object.fromEntries(e.filter(n=>!!an(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:si(n.name,this.schema)},s=an(n,"addNodeView",i);if(!s)return[];const o=s();if(!o)return[];const l=(c,d,u,h,f)=>{const p=Z0(c,r);return o({node:c,view:d,getPos:u,decorations:h,innerDecorations:f,editor:t,extension:n,HTMLAttributes:p})};return[n.name,l]}))}dispatchTransaction(t){const{editor:e}=this;return nC([...this.extensions].reverse()).reduceRight((r,i)=>{const s={name:i.name,options:i.options,storage:this.editor.extensionStorage[i.name],editor:e,type:C_(i.name,this.schema)},o=an(i,"dispatchTransaction",s);return o?l=>{o.call(s,{transaction:l,next:r})}:r},t)}get markViews(){const{editor:t}=this,{markExtensions:e}=Rb(this.extensions);return Object.fromEntries(e.filter(n=>!!an(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:vu(n.name,this.schema)},s=an(n,"addMarkView",i);if(!s)return[];const o=(l,c,d)=>{const u=Z0(l,r);return s()({mark:l,view:c,inline:d,editor:t,extension:n,HTMLAttributes:u,updateAttributes:h=>{cWe(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:C_(e.name,this.schema)};e.type==="mark"&&((n=Mr(an(e,"keepOnSplit",r)))==null||n)&&this.splittableMarks.push(e.name);const i=an(e,"onBeforeCreate",r),s=an(e,"onCreate",r),o=an(e,"onUpdate",r),l=an(e,"onSelectionUpdate",r),c=an(e,"onTransaction",r),d=an(e,"onFocus",r),u=an(e,"onBlur",r),h=an(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),d&&this.editor.on("focus",d),u&&this.editor.on("blur",u),h&&this.editor.on("destroy",h)})}};wA.resolve=pae;wA.sort=nC;wA.flatten=UO;var X9e={};OO(X9e,{ClipboardTextSerializer:()=>kae,Commands:()=>Aae,Delete:()=>Tae,Drop:()=>Mae,Editable:()=>Pae,FocusEvents:()=>jae,Keymap:()=>Dae,Paste:()=>Rae,Tabindex:()=>Fae,TextDirection:()=>Lae,focusEventsPluginKey:()=>Eae});var Vr=class Cae extends $O{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new Cae(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},kae=Vr.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new Na({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(u=>u.$from.pos)),l=Math.max(...s.map(u=>u.$to.pos)),c=bae(n);return gae(r,{from:o,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:c})}}})]}}),Aae=Vr.create({name:"commands",addCommands(){return{...iae}}}),Tae=Vr.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,r,i;const s=()=>{var o,l,c,d;if((d=(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?d:t.getMeta("y-sync$"))return;const u=hae(t.before,[t,...e]);yae(u).forEach(p=>{u.mapping.mapResult(p.oldRange.from).deletedAfter&&u.mapping.mapResult(p.oldRange.to).deletedBefore&&u.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:u.mapping.map(v),newTo:u.mapping.map(g),deletedRange:p.oldRange,newRange:p.newRange,partial:!y,editor:this.editor,transaction:t,combinedTransform:u})})});const f=u.mapping;u.steps.forEach((p,x)=>{var v,g;if(p instanceof Kl){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(_),k=(v=u.doc.nodeAt(y-1))==null?void 0:v.marks.some(C=>C.eq(p.mark)),P=(g=u.doc.nodeAt(_))==null?void 0:g.marks.some(C=>C.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:!!(P||k),editor:this.editor,transaction:t,combinedTransform:u})}})};(i=(r=(n=this.editor.options.coreExtensionOptions)==null?void 0:n.delete)==null?void 0:r.async)==null||i?setTimeout(s,0):s()}}),Mae=Vr.create({name:"drop",addProseMirrorPlugins(){return[new Na({key:new Ni("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),Pae=Vr.create({name:"editable",addProseMirrorPlugins(){return[new Na({key:new Ni("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Eae=new Ni("focusEvents"),jae=Vr.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new Na({key:Eae,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}}}})]}}),Dae=Vr.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:o})=>[()=>o.undoInputRule(),()=>o.command(({tr:l})=>{const{selection:c,doc:d}=l,{empty:u,$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:zn.atStart(d).from===f;return!u||!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 tC()||dae()?s:i},addProseMirrorPlugins(){return[new Na({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=zn.atStart(e.doc).from,d=zn.atEnd(e.doc).to;if(s||!(o===c&&l===d)||!yA(n.doc))return;const f=n.tr,p=pA({state:n,transaction:f}),{commands:x}=new gA({editor:this.editor,state:p});if(x.clearNodes(),!!f.steps.length)return f}})]}}),Rae=Vr.create({name:"paste",addProseMirrorPlugins(){return[new Na({key:new Ni("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),Fae=Vr.create({name:"tabindex",addProseMirrorPlugins(){return[new Na({key:new Ni("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),Lae=Vr.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=Rb(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 Na({key:new Ni("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),Y9e=class Ly{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 Ly(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 Ly(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 Ly(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 d=new Ly(c,this.editor,i,i||o?n:null);i&&(d.actualDepth=this.depth+1),e.push(d)}),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)}},Q9e=`.ProseMirror {
- position: relative;
- }
- .ProseMirror {
- word-wrap: break-word;
- white-space: pre-wrap;
- white-space: break-spaces;
- -webkit-font-variant-ligatures: none;
- font-variant-ligatures: none;
- font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
- }
- .ProseMirror [contenteditable="false"] {
- white-space: normal;
- }
- .ProseMirror [contenteditable="false"] [contenteditable="true"] {
- white-space: pre-wrap;
- }
- .ProseMirror pre {
- white-space: pre-wrap;
- }
- img.ProseMirror-separator {
- display: inline !important;
- border: none !important;
- margin: 0 !important;
- width: 0 !important;
- height: 0 !important;
- }
- .ProseMirror-gapcursor {
- display: none;
- pointer-events: none;
- position: absolute;
- margin: 0;
- }
- .ProseMirror-gapcursor:after {
- content: "";
- display: block;
- position: absolute;
- top: -2px;
- width: 20px;
- border-top: 1px solid black;
- animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
- }
- @keyframes ProseMirror-cursor-blink {
- to {
- visibility: hidden;
- }
- }
- .ProseMirror-hideselection *::selection {
- background: transparent;
- }
- .ProseMirror-hideselection *::-moz-selection {
- background: transparent;
- }
- .ProseMirror-hideselection * {
- caret-color: transparent;
- }
- .ProseMirror-focused .ProseMirror-gapcursor {
- display: block;
- }`;function Z9e(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 J9e=class extends z9e{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:g9e,createMappablePosition:b9e},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=lae(e,this.options.autofocus);this.editorState=Vg.create({doc:e,schema:this.schema,selection:n||void 0}),this.options.element&&this.mount(this.options.element)}mount(t){if(typeof document>"u")throw new Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");this.createView(t),this.emit("mount",{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(()=>{this.isDestroyed||(this.options.autofocus!==!1&&this.options.autofocus!==null&&this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){const t=this.editorView.dom;t?.editor&&delete t.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{typeof this.css.remove=="function"?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(t){console.warn("Failed to remove CSS element:",t)}this.css=null,this.emit("unmount",{editor:this})}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&typeof document<"u"&&(this.css=Z9e(Q9e,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?[Pae,kae.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),Aae,jae,Dae,Fae,Mae,Rae,Tae,Lae.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 wA(r,this)}createCommandManager(){this.commandManager=new gA({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=IR(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=IR(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 rae(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(d=>{var u;return(u=this.capturedTransaction)==null?void 0:u.step(d)});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(d=>d.getMeta("focus")||d.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(d=>d.docChanged)||s.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:t,appendedTransactions:n.slice(1)})}getAttributes(t){return xae(this.state,t)}isActive(t,e){const n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return m9e(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return BO(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=`
- `,textSerializers:n={}}=t||{};return o9e(this.state.doc,{blockSeparator:e,textSerializers:{...bae(this.schema),...n}})}get isEmpty(){return yA(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 Y9e(e,this)}get $doc(){return this.$pos(0)}};function Fb(t){return new vA({find:t.find,handler:({state:e,range:n,match:r})=>{const i=Mr(t.getAttributes,void 0,r);if(i===!1||i===null)return null;const{tr:s}=e,o=r[r.length-1],l=r[0];if(o){const c=l.search(/\S/),d=n.from+l.indexOf(o),u=d+o.length;if(HO(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>d).length)return null;u<n.to&&s.delete(u,n.to),d>n.from&&s.delete(n.from+c,d);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 Oae(t){return new vA({find:t.find,handler:({state:e,range:n,match:r})=>{const i=Mr(t.getAttributes,void 0,r)||{},{tr:s}=e,o=n.from;let l=n.to;const c=t.type.create(i);if(r[1]){const d=r[0].lastIndexOf(r[1]);let u=o+d;u>l?u=l:l=u+r[1].length;const h=r[0][r[0].length-1];s.insertText(h,o+r[0].length-1),s.replaceWith(u,l,c)}else if(r[0]){const d=t.type.isInline?o:o-1;s.insert(d,t.type.create(i)).delete(s.mapping.map(o),s.mapping.map(l))}s.scrollIntoView()},undoable:t.undoable})}function UR(t){return new vA({find:t.find,handler:({state:e,range:n,match:r})=>{const i=e.doc.resolve(n.from),s=Mr(t.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,s)},undoable:t.undoable})}function Lb(t){return new vA({find:t.find,handler:({state:e,range:n,match:r,chain:i})=>{const s=Mr(t.getAttributes,void 0,r)||{},o=e.tr.delete(n.from,n.to),c=o.doc.resolve(n.from).blockRange(),d=c&&wO(c,t.type,s);if(!d)return null;if(o.wrap(c,d),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 u=o.doc.resolve(n.from-1).nodeBefore;u&&u.type===t.type&&lm(o.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,u))&&o.join(n.from-1)},undoable:t.undoable})}var eWe=t=>"touches"in t,tWe=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,d=l.clientY-this.startY;this.handleResize(c,d)},this.handleTouchMove=l=>{if(!this.isResizing||!this.activeHandle)return;const c=l.touches[0];if(!c)return;const d=c.clientX-this.startX,u=c.clientY-this.startY;this.handleResize(d,u)},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,eWe(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 d=Math.max(this.minSize.width,t),u=Math.max(this.minSize.height,e);return(r=this.maxSize)!=null&&r.width&&(d=Math.min(this.maxSize.width,d)),(i=this.maxSize)!=null&&i.height&&(u=Math.min(this.maxSize.height,u)),{width:d,height:u}}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 nWe(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof cn){const s=r.index();return r.parent.canReplaceWith(s,s+1,e)}let i=r.depth;for(;i>=0;){const s=r.index(i);if(r.node(i).contentMatchAt(s).matchType(e))return!0;i-=1}return!1}var rWe={};OO(rWe,{createAtomBlockMarkdownSpec:()=>aWe,createBlockMarkdownSpec:()=>iWe,createInlineMarkdownSpec:()=>lWe,parseAttributes:()=>VO,parseIndentedBlocks:()=>BR,renderNestedMarkdownContent:()=>GO,serializeAttributes:()=>qO});function VO(t){if(!t?.trim())return{};const e={},n=[],r=t.replace(/["']([^"']*)["']/g,d=>(n.push(d),`__QUOTED_${n.length-1}__`)),i=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(i){const d=i.map(u=>u.trim().slice(1));e.class=d.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(([,d,u])=>{var h;const f=parseInt(((h=u.match(/__QUOTED_(\d+)__/))==null?void 0:h[1])||"0",10),p=n[f];p&&(e[d]=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(u=>{u.match(/^[a-zA-Z][\w-]*$/)&&(e[u]=!0)}),e}function qO(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 aWe(t){const{nodeName:e,name:n,parseAttributes:r=VO,serializeAttributes:i=qO,defaultAttributes:s={},requiredAttributes:o=[],allowedAttributes:l}=t,c=n||e,d=u=>{if(!l)return u;const h={};return l.forEach(f=>{f in u&&(h[f]=u[f])}),h};return{parseMarkdown:(u,h)=>{const f={...s,...u.attributes};return h.createNode(e,f,[])},markdownTokenizer:{name:e,level:"block",start(u){var h;const f=new RegExp(`^:::${c}(?:\\s|$)`,"m"),p=(h=u.match(f))==null?void 0:h.index;return p!==void 0?p:-1},tokenize(u,h,f){const p=new RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),x=u.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:u=>{const h=d(u.attrs||{}),f=i(h),p=f?` {${f}}`:"";return`:::${c}${p} :::`}}}function iWe(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=VO,serializeAttributes:s=qO,defaultAttributes:o={},content:l="block",allowedAttributes:c}=t,d=n||e,u=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(`^:::${d}`,"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(`^:::${d}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),g=h.match(v);if(!g)return;const[y,_=""]=g,N=i(_);let A=1;const k=y.length;let P="";const C=/^:::([\w-]*)(\s.*)?/gm,j=h.slice(k);for(C.lastIndex=0;;){const M=C.exec(j);if(M===null)break;const E=M.index,B=M[1];if(!((x=M[2])!=null&&x.endsWith(":::"))){if(B)A+=1;else if(A-=1,A===0){const L=j.slice(0,E);P=L.trim();const U=h.slice(0,k+E+M[0].length);let D=[];if(P)if(l==="block")for(D=p.blockTokens(L),D.forEach($=>{$.text&&(!$.tokens||$.tokens.length===0)&&($.tokens=p.inlineTokens($.text))});D.length>0;){const $=D[D.length-1];if($.type==="paragraph"&&(!$.text||$.text.trim()===""))D.pop();else break}else D=p.inlineTokens(P);return{type:e,raw:U,attributes:N,content:P,tokens:D}}}}}},renderMarkdown:(h,f)=>{const p=u(h.attrs||{}),x=s(p),v=x?` {${x}}`:"",g=f.renderChildren(h.content||[],`
- `);return`:::${d}${v}
- ${g}
- :::`}}}function sWe(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 oWe(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function lWe(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=sWe,serializeAttributes:s=oWe,defaultAttributes:o={},selfClosing:l=!1,allowedAttributes:c}=t,d=n||e,u=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=d.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,k]=g;_=A,y=k||""}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=u(f.attrs||{}),v=s(x),g=v?` ${v}`:"";return l?`[${d}${g}]`:`[${d}${g}]${p}[/${d}]`}}}function BR(t,e,n){var r,i,s,o;const l=t.split(`
- `),c=[];let d="",u=0;const h=e.baseIndentSize||2;for(;u<l.length;){const f=l[u],p=f.match(e.itemPattern);if(!p){if(c.length>0)break;if(f.trim()===""){u+=1,d=`${d}${f}
- `;continue}else return}const x=e.extractItemData(p),{indentLevel:v,mainContent:g}=x;d=`${d}${f}
- `;const y=[g];for(u+=1;u<l.length;){const k=l[u];if(k.trim()===""){const C=l.slice(u+1).findIndex(E=>E.trim()!=="");if(C===-1)break;if((((i=(r=l[u+1+C].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:i.length)||0)>v){y.push(k),d=`${d}${k}
- `,u+=1;continue}else break}if((((o=(s=k.match(/^(\s*)/))==null?void 0:s[1])==null?void 0:o.length)||0)>v)y.push(k),d=`${d}${k}
- `,u+=1;else break}let _;const N=y.slice(1);if(N.length>0){const k=N.map(P=>P.slice(v+h)).join(`
- `);k.trim()&&(e.customNestedParser?_=e.customNestedParser(k):_=n.blockTokens(k))}const A=e.createToken(x,_);c.push(A)}if(c.length!==0)return{items:c,raw:d}}function GO(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(d=>{const u=e.renderChildren([d]);if(u){const h=u.split(`
- `).map(f=>f?e.indent(f):"").join(`
- `);c.push(h)}}),c.join(`
- `)}function cWe(t,e,n={}){const{state:r}=e,{doc:i,tr:s}=r,o=t;i.descendants((l,c)=>{const d=s.mapping.map(c),u=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(d,u,t.type),s.addMark(d,u,p)}}),s.docChanged&&e.view.dispatch(s)}var ho=class Iae extends $O{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new Iae(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function Zf(t){return new V9e({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:i})=>{const s=Mr(t.getAttributes,void 0,r,i);if(s===!1||s===null)return null;const{tr:o}=e,l=r[r.length-1],c=r[0];let d=n.to;if(l){const u=c.search(/\S/),h=n.from+c.indexOf(l),f=h+l.length;if(HO(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+u,h),d=n.from+u+l.length,o.addMark(n.from+u,d,t.type.create(s||{})),o.removeStoredMark(t.type)}}})}const{getOwnPropertyNames:dWe,getOwnPropertySymbols:uWe}=Object,{hasOwnProperty:hWe}=Object.prototype;function mj(t,e){return function(r,i,s){return t(r,i,s)&&e(r,i,s)}}function M_(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 mWe(t){return t?.[Symbol.toStringTag]}function _W(t){return dWe(t).concat(uWe(t))}const fWe=Object.hasOwn||((t,e)=>hWe.call(t,e));function sp(t,e){return t===e||!t&&!e&&t!==t&&e!==e}const pWe="__v",gWe="__o",bWe="_owner",{getOwnPropertyDescriptor:NW,keys:CW}=Object;function xWe(t,e){return t.byteLength===e.byteLength&&rC(new Uint8Array(t),new Uint8Array(e))}function yWe(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 vWe(t,e){return t.byteLength===e.byteLength&&rC(new Uint8Array(t.buffer,t.byteOffset,t.byteLength),new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}function wWe(t,e){return sp(t.getTime(),e.getTime())}function SWe(t,e){return t.name===e.name&&t.message===e.message&&t.cause===e.cause&&t.stack===e.stack}function _We(t,e){return t===e}function kW(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 d=e.entries();let u=!1,h=0;for(;(l=d.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)){u=i[h]=!0;break}h++}if(!u)return!1;c++}return!0}const NWe=sp;function CWe(t,e,n){const r=CW(t);let i=r.length;if(CW(e).length!==i)return!1;for(;i-- >0;)if(!zae(t,e,n,r[i]))return!1;return!0}function Ny(t,e,n){const r=_W(t);let i=r.length;if(_W(e).length!==i)return!1;let s,o,l;for(;i-- >0;)if(s=r[i],!zae(t,e,n,s)||(o=NW(t,s),l=NW(e,s),(o||l)&&(!o||!l||o.configurable!==l.configurable||o.enumerable!==l.enumerable||o.writable!==l.writable)))return!1;return!0}function kWe(t,e){return sp(t.valueOf(),e.valueOf())}function AWe(t,e){return t.source===e.source&&t.flags===e.flags}function AW(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 d=!1,u=0;for(;(l=c.next())&&!l.done;){if(!i[u]&&n.equals(o.value,l.value,o.value,l.value,t,e,n)){d=i[u]=!0;break}u++}if(!d)return!1}return!0}function rC(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 TWe(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 zae(t,e,n,r){return(r===bWe||r===gWe||r===pWe)&&(t.$$typeof||e.$$typeof)?!0:fWe(e,r)&&n.equals(t[r],e[r],r,r,t,e,n)}const MWe="[object ArrayBuffer]",PWe="[object Arguments]",EWe="[object Boolean]",jWe="[object DataView]",DWe="[object Date]",RWe="[object Error]",FWe="[object Map]",LWe="[object Number]",OWe="[object Object]",IWe="[object RegExp]",zWe="[object Set]",UWe="[object String]",BWe={"[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},HWe="[object URL]",$We=Object.prototype.toString;function VWe({areArrayBuffersEqual:t,areArraysEqual:e,areDataViewsEqual:n,areDatesEqual:r,areErrorsEqual:i,areFunctionsEqual:s,areMapsEqual:o,areNumbersEqual:l,areObjectsEqual:c,arePrimitiveWrappersEqual:d,areRegExpsEqual:u,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 u(g,y,_);if(A===Map)return o(g,y,_);if(A===Set)return h(g,y,_);const k=$We.call(g);if(k===DWe)return r(g,y,_);if(k===IWe)return u(g,y,_);if(k===FWe)return o(g,y,_);if(k===zWe)return h(g,y,_);if(k===OWe)return typeof g.then!="function"&&typeof y.then!="function"&&c(g,y,_);if(k===HWe)return p(g,y,_);if(k===RWe)return i(g,y,_);if(k===PWe)return c(g,y,_);if(BWe[k])return f(g,y,_);if(k===MWe)return t(g,y,_);if(k===jWe)return n(g,y,_);if(k===EWe||k===LWe||k===UWe)return d(g,y,_);if(x){let P=x[k];if(!P){const C=mWe(g);C&&(P=x[C])}if(P)return P(g,y,_)}return!1}}function qWe({circular:t,createCustomConfig:e,strict:n}){let r={areArrayBuffersEqual:xWe,areArraysEqual:n?Ny:yWe,areDataViewsEqual:vWe,areDatesEqual:wWe,areErrorsEqual:SWe,areFunctionsEqual:_We,areMapsEqual:n?mj(kW,Ny):kW,areNumbersEqual:NWe,areObjectsEqual:n?Ny:CWe,arePrimitiveWrappersEqual:kWe,areRegExpsEqual:AWe,areSetsEqual:n?mj(AW,Ny):AW,areTypedArraysEqual:n?mj(rC,Ny):rC,areUrlsEqual:TWe,unknownTagComparators:void 0};if(e&&(r=Object.assign({},r,e(r))),t){const i=M_(r.areArraysEqual),s=M_(r.areMapsEqual),o=M_(r.areObjectsEqual),l=M_(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:i,areMapsEqual:s,areObjectsEqual:o,areSetsEqual:l})}return r}function GWe(t){return function(e,n,r,i,s,o,l){return t(e,n,l)}}function WWe({circular:t,comparator:e,createState:n,equals:r,strict:i}){if(n)return function(l,c){const{cache:d=t?new WeakMap:void 0,meta:u}=n();return e(l,c,{cache:d,equals:r,meta:u,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 KWe=um();um({strict:!0});um({circular:!0});um({circular:!0,strict:!0});um({createInternalComparator:()=>sp});um({strict:!0,createInternalComparator:()=>sp});um({circular:!0,createInternalComparator:()=>sp});um({circular:!0,createInternalComparator:()=>sp,strict:!0});function um(t={}){const{circular:e=!1,createInternalComparator:n,createState:r,strict:i=!1}=t,s=qWe(t),o=VWe(s),l=n?n(o):GWe(o);return WWe({circular:e,comparator:o,createState:r,equals:l,strict:i})}var XWe=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},YWe=({contentComponent:t})=>{const e=cF.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return a.jsx(a.Fragment,{children:Object.values(e)})};function QWe(){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]:aue.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 ZWe=class extends Wr.Component{constructor(t){var e;super(t),this.editorContentRef=Wr.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=QWe(),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:XWe(e,this.editorContentRef),...n}),t?.contentComponent&&a.jsx(YWe,{contentComponent:t.contentComponent})]})}},JWe=w.forwardRef((t,e)=>{const n=Wr.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return Wr.createElement(ZWe,{key:n,innerRef:e,...t})}),Uae=Wr.memo(JWe),eKe=typeof window<"u"?w.useLayoutEffect:w.useEffect,tKe=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 nKe(t){var e;const[n]=w.useState(()=>new tKe(t.editor)),r=BQ.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:KWe);return eKe(()=>n.watch(t.editor),[t.editor,n]),w.useDebugValue(r),r}var rKe=!1,HR=typeof window>"u",aKe=HR||!!(typeof window<"u"&&window.next),iKe=class Bae{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?HR||aKe?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 J9e(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?Bae.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 sKe(t={},e=[]){const n=w.useRef(t);n.current=t;const[r]=w.useState(()=>new iKe(n)),i=cF.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return w.useDebugValue(i),w.useEffect(r.onRender(e)),nKe({editor:i,selector:({transactionNumber:s})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&s===0?0:s+1}),i}var Hae=w.createContext({editor:null});Hae.Consumer;var oKe=w.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),lKe=()=>w.useContext(oKe);Wr.forwardRef((t,e)=>{const{onDragStart:n}=lKe(),r=t.as||"div";return a.jsx(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});Wr.createContext({markViewContentRef:()=>{}});var WO=w.createContext({get editor(){throw new Error("useTiptap must be used within a <Tiptap> provider")}});WO.displayName="TiptapContext";var cKe=()=>w.useContext(WO);function $ae({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(Hae.Provider,{value:s,children:a.jsx(WO.Provider,{value:i,children:n})})}$ae.displayName="Tiptap";function Vae({...t}){const{editor:e}=cKe();return a.jsx(Uae,{editor:e,...t})}Vae.displayName="Tiptap.Content";Object.assign($ae,{Content:Vae});var aC=(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]},dKe=/^\s*>\s$/,uKe=ho.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return aC("blockquote",{...Ia(this.options.HTMLAttributes,t),children:aC("slot",{})})},parseMarkdown:(t,e)=>e.createNode("blockquote",void 0,e.parseChildren(t.tokens||[])),renderMarkdown:(t,e)=>{if(!t.content)return"";const n=">",r=[];return t.content.forEach(i=>{const l=e.renderChildren([i]).split(`
- `).map(c=>c.trim()===""?n:`${n} ${c}`);r.push(l.join(`
- `))}),r.join(`
- ${n}
- `)},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[Lb({find:dKe,type:this.type})]}}),hKe=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,mKe=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,fKe=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,pKe=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,gKe=dm.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 aC("strong",{...Ia(this.options.HTMLAttributes,t),children:aC("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[Fb({find:hKe,type:this.type}),Fb({find:fKe,type:this.type})]},addPasteRules(){return[Zf({find:mKe,type:this.type}),Zf({find:pKe,type:this.type})]}}),bKe=/(^|[^`])`([^`]+)`(?!`)$/,xKe=/(^|[^`])`([^`]+)`(?!`)/g,yKe=dm.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",Ia(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[Fb({find:bKe,type:this.type})]},addPasteRules(){return[Zf({find:xKe,type:this.type})]}}),fj=4,vKe=/^```([a-z]+)?[\s\n]$/,wKe=/^~~~([a-z]+)?[\s\n]$/,SKe=ho.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:fj,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",Ia(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(t,e)=>{var n;return((n=t.raw)==null?void 0:n.startsWith("```"))===!1&&t.codeBlockStyle!=="indented"?[]:e.createNode("codeBlock",{language:t.lang||null},t.text?[e.createTextNode(t.text)]:[])},renderMarkdown:(t,e)=>{var n;let r="";const i=((n=t.attrs)==null?void 0:n.language)||"";return t.content?r=[`\`\`\`${i}`,e.renderChildren(t.content),"```"].join(`
- `):r=`\`\`\`${i}
- \`\`\``,r},addCommands(){return{setCodeBlock:t=>({commands:e})=>e.setNode(this.name,t),toggleCodeBlock:t=>({commands:e})=>e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:t,$anchor:e}=this.editor.state.selection,n=e.pos===1;return!t||e.parent.type.name!==this.name?!1:n||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:fj,{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:d,to:u}=i,p=r.doc.textBetween(d,u,`
- `,`
- `).split(`
- `).map(x=>l+x).join(`
- `);return c.replaceWith(d,u,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:fj,{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:d}=s,u=s.start(),h=s.end(),p=r.doc.textBetween(u,h,`
- `,`
- `).split(`
- `);let x=0,v=0;const g=d-u;for(let P=0;P<p.length;P+=1){if(v+p[P].length>=g){x=P;break}v+=p[P].length+1}const _=((c=p[x].match(/^ */))==null?void 0:c[0])||"",N=Math.min(_.length,n);if(N===0)return!0;let A=u;for(let P=0;P<x;P+=1)A+=p[P].length+1;return l.delete(A,A+N),d-A<=N&&l.setSelection(_n.create(l.doc,A)),!0}):t.commands.command(({tr:l})=>{const{from:c,to:d}=i,f=r.doc.textBetween(c,d,`
- `,`
- `).split(`
- `).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(`
- `);return l.replaceWith(c,d,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(`
- `);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:d})=>(d.setSelection(zn.near(r.resolve(l))),!0)):t.commands.exitCode()}}},addInputRules(){return[UR({find:vKe,type:this.type,getAttributes:t=>({language:t[1]})}),UR({find:wKe,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new Na({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,`
- `));return o.replaceSelectionWith(this.type.create({language:s},c)),o.selection.$from.parent.type!==this.type&&o.setSelection(_n.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),t.dispatch(o),!0}}})]}}),_Ke=ho.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
- `):""}),NKe=ho.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",Ia(this.options.HTMLAttributes,t)]},renderText(){return`
- `},renderMarkdown:()=>`
- `,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:i,storedMarks:s}=n;if(i.$from.parent.type.spec.isolating)return!1;const{keepMarks:o}=this.options,{splittableMarks:l}=r.extensionManager,c=s||i.$to.parentOffset&&i.$from.marks();return e().insertContent({type:this.name}).command(({tr:d,dispatch:u})=>{if(u&&c&&o){const h=c.filter(f=>l.includes(f.type.name));d.ensureMarks(h)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),CKe=ho.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]}`,Ia(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=>UR({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),kKe=ho.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",Ia(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!nWe(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,i=t();return vae(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,d=c.end();if(c.nodeAfter)c.nodeAfter.isTextblock?o.setSelection(_n.create(o.doc,c.pos+1)):c.nodeAfter.isBlock?o.setSelection(cn.create(o.doc,c.pos)):o.setSelection(_n.create(o.doc,c.pos));else{const u=s.schema.nodes[this.options.nextNodeType]||c.parent.type.contentMatch.defaultType,h=u?.create();h&&(o.insert(d,h),o.setSelection(_n.create(o.doc,d+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[Oae({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),AKe=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,TKe=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,MKe=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,PKe=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,EKe=dm.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",Ia(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[Fb({find:AKe,type:this.type}),Fb({find:MKe,type:this.type})]},addPasteRules(){return[Zf({find:TKe,type:this.type}),Zf({find:PKe,type:this.type})]}});const jKe="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",DKe="ελ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",$R="numeric",VR="ascii",qR="alpha",Jy="asciinumeric",Oy="alphanumeric",GR="domain",qae="emoji",RKe="scheme",FKe="slashscheme",pj="whitespace";function LKe(t,e){return t in e||(e[t]=[]),e[t]}function uf(t,e,n){e[$R]&&(e[Jy]=!0,e[Oy]=!0),e[VR]&&(e[Jy]=!0,e[qR]=!0),e[Jy]&&(e[Oy]=!0),e[qR]&&(e[Oy]=!0),e[Oy]&&(e[GR]=!0),e[qae]&&(e[GR]=!0);for(const r in e){const i=LKe(r,n);i.indexOf(t)<0&&i.push(t)}}function OKe(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function Zs(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}Zs.groups={};Zs.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||Zs.groups;let i;return e&&e.j?i=e:(i=new Zs(e),n&&r&&uf(e,n,r)),this.jr.push([t,i]),i},ts(t,e,n,r){let i=this;const s=t.length;if(!s)return i;for(let o=0;o<s-1;o++)i=i.tt(t[o]);return i.tt(t[s-1],e,n,r)},tt(t,e,n,r){r=r||Zs.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 Zs,Object.assign(o.j,l.j),o.jr.push.apply(o.jr,l.jr),o.jd=l.jd,o.t=l.t):o=new Zs,s){if(r)if(o.t&&typeof o.t=="string"){const c=Object.assign(OKe(o.t,r),n);uf(s,c,r)}else n&&uf(s,n,r);o.t=s}return i.j[t]=o,o}};const Dn=(t,e,n,r,i)=>t.ta(e,n,r,i),Ta=(t,e,n,r,i)=>t.tr(e,n,r,i),TW=(t,e,n,r,i)=>t.ts(e,n,r,i),jt=(t,e,n,r,i)=>t.tt(e,n,r,i),Ed="WORD",WR="UWORD",Gae="ASCIINUMERICAL",Wae="ALPHANUMERICAL",J0="LOCALHOST",KR="TLD",XR="UTLD",l1="SCHEME",Lg="SLASH_SCHEME",KO="NUM",YR="WS",XO="NL",e0="OPENBRACE",t0="CLOSEBRACE",iC="OPENBRACKET",sC="CLOSEBRACKET",oC="OPENPAREN",lC="CLOSEPAREN",cC="OPENANGLEBRACKET",dC="CLOSEANGLEBRACKET",uC="FULLWIDTHLEFTPAREN",hC="FULLWIDTHRIGHTPAREN",mC="LEFTCORNERBRACKET",fC="RIGHTCORNERBRACKET",pC="LEFTWHITECORNERBRACKET",gC="RIGHTWHITECORNERBRACKET",bC="FULLWIDTHLESSTHAN",xC="FULLWIDTHGREATERTHAN",yC="AMPERSAND",vC="APOSTROPHE",wC="ASTERISK",uh="AT",SC="BACKSLASH",_C="BACKTICK",NC="CARET",xh="COLON",YO="COMMA",CC="DOLLAR",yc="DOT",kC="EQUALS",QO="EXCLAMATION",nl="HYPHEN",n0="PERCENT",AC="PIPE",TC="PLUS",MC="POUND",r0="QUERY",ZO="QUOTE",Kae="FULLWIDTHMIDDLEDOT",JO="SEMI",vc="SLASH",a0="TILDE",PC="UNDERSCORE",Xae="EMOJI",EC="SYM";var Yae=Object.freeze({__proto__:null,ALPHANUMERICAL:Wae,AMPERSAND:yC,APOSTROPHE:vC,ASCIINUMERICAL:Gae,ASTERISK:wC,AT:uh,BACKSLASH:SC,BACKTICK:_C,CARET:NC,CLOSEANGLEBRACKET:dC,CLOSEBRACE:t0,CLOSEBRACKET:sC,CLOSEPAREN:lC,COLON:xh,COMMA:YO,DOLLAR:CC,DOT:yc,EMOJI:Xae,EQUALS:kC,EXCLAMATION:QO,FULLWIDTHGREATERTHAN:xC,FULLWIDTHLEFTPAREN:uC,FULLWIDTHLESSTHAN:bC,FULLWIDTHMIDDLEDOT:Kae,FULLWIDTHRIGHTPAREN:hC,HYPHEN:nl,LEFTCORNERBRACKET:mC,LEFTWHITECORNERBRACKET:pC,LOCALHOST:J0,NL:XO,NUM:KO,OPENANGLEBRACKET:cC,OPENBRACE:e0,OPENBRACKET:iC,OPENPAREN:oC,PERCENT:n0,PIPE:AC,PLUS:TC,POUND:MC,QUERY:r0,QUOTE:ZO,RIGHTCORNERBRACKET:fC,RIGHTWHITECORNERBRACKET:gC,SCHEME:l1,SEMI:JO,SLASH:vc,SLASH_SCHEME:Lg,SYM:EC,TILDE:a0,TLD:KR,UNDERSCORE:PC,UTLD:XR,UWORD:WR,WORD:Ed,WS:YR});const kd=/[a-z]/,Cy=new RegExp("\\p{L}","u"),gj=new RegExp("\\p{Emoji}","u"),Ad=/\d/,bj=/\s/,MW="\r",xj=`
- `,IKe="️",zKe="",yj="";let P_=null,E_=null;function UKe(t=[]){const e={};Zs.groups=e;const n=new Zs;P_==null&&(P_=PW(jKe)),E_==null&&(E_=PW(DKe)),jt(n,"'",vC),jt(n,"{",e0),jt(n,"}",t0),jt(n,"[",iC),jt(n,"]",sC),jt(n,"(",oC),jt(n,")",lC),jt(n,"<",cC),jt(n,">",dC),jt(n,"(",uC),jt(n,")",hC),jt(n,"「",mC),jt(n,"」",fC),jt(n,"『",pC),jt(n,"』",gC),jt(n,"<",bC),jt(n,">",xC),jt(n,"&",yC),jt(n,"*",wC),jt(n,"@",uh),jt(n,"`",_C),jt(n,"^",NC),jt(n,":",xh),jt(n,",",YO),jt(n,"$",CC),jt(n,".",yc),jt(n,"=",kC),jt(n,"!",QO),jt(n,"-",nl),jt(n,"%",n0),jt(n,"|",AC),jt(n,"+",TC),jt(n,"#",MC),jt(n,"?",r0),jt(n,'"',ZO),jt(n,"/",vc),jt(n,";",JO),jt(n,"~",a0),jt(n,"_",PC),jt(n,"\\",SC),jt(n,"・",Kae);const r=Ta(n,Ad,KO,{[$R]:!0});Ta(r,Ad,r);const i=Ta(r,kd,Gae,{[Jy]:!0}),s=Ta(r,Cy,Wae,{[Oy]:!0}),o=Ta(n,kd,Ed,{[VR]:!0});Ta(o,Ad,i),Ta(o,kd,o),Ta(i,Ad,i),Ta(i,kd,i);const l=Ta(n,Cy,WR,{[qR]:!0});Ta(l,kd),Ta(l,Ad,s),Ta(l,Cy,l),Ta(s,Ad,s),Ta(s,kd),Ta(s,Cy,s);const c=jt(n,xj,XO,{[pj]:!0}),d=jt(n,MW,YR,{[pj]:!0}),u=Ta(n,bj,YR,{[pj]:!0});jt(n,yj,u),jt(d,xj,c),jt(d,yj,u),Ta(d,bj,u),jt(u,MW),jt(u,xj),Ta(u,bj,u),jt(u,yj,u);const h=Ta(n,gj,Xae,{[qae]:!0});jt(h,"#"),Ta(h,gj,h),jt(h,IKe,h);const f=jt(h,zKe);jt(f,"#"),Ta(f,gj,h);const p=[[kd,o],[Ad,i]],x=[[kd,null],[Cy,l],[Ad,s]];for(let v=0;v<P_.length;v++)rh(n,P_[v],KR,Ed,p);for(let v=0;v<E_.length;v++)rh(n,E_[v],XR,WR,x);uf(KR,{tld:!0,ascii:!0},e),uf(XR,{utld:!0,alpha:!0},e),rh(n,"file",l1,Ed,p),rh(n,"mailto",l1,Ed,p),rh(n,"http",Lg,Ed,p),rh(n,"https",Lg,Ed,p),rh(n,"ftp",Lg,Ed,p),rh(n,"ftps",Lg,Ed,p),uf(l1,{scheme:!0,ascii:!0},e),uf(Lg,{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]?{[RKe]:!0}:{[FKe]:!0};g.indexOf("-")>=0?_[GR]=!0:kd.test(g)?Ad.test(g)?_[Jy]=!0:_[VR]=!0:_[$R]=!0,TW(n,g,g,_)}return TW(n,"localhost",J0,{ascii:!0}),n.jd=new Zs(EC),{start:n,tokens:Object.assign({groups:e},Yae)}}function Qae(t,e){const n=BKe(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,d=0,u=null,h=-1,f=-1;for(;o<r&&(c=l.go(n[o]));)l=c,l.accepts()?(h=0,f=0,u=l):h>=0&&(h+=n[o].length,f++),d+=n[o].length,s+=n[o].length,o++;s-=h,o-=f,d-=h,i.push({t:u.t,v:e.slice(s-d,s),s:s-d,e:s})}return i}function BKe(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 rh(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 Zs(r),s.jr=i.slice(),t.j[c]=s),t=s}return s=new Zs(n),s.jr=i.slice(),t.j[e[o-1]]=s,s}function PW(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 ev={defaultProtocol:"http",events:null,format:EW,formatHref:EW,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function eI(t,e=null){let n=Object.assign({},ev);t&&(n=Object.assign(n,t instanceof eI?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}eI.prototype={o:ev,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]:ev[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 EW(t){return t}function Zae(t,e){this.t="token",this.v=t,this.tk=e}Zae.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=ev.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),d=t.get("rel",n,e),u=t.getObj("attributes",n,e),h=t.getObj("events",n,e);return o.href=r,l&&(o.class=l),c&&(o.target=c),d&&(o.rel=d),u&&Object.assign(o,u),{tagName:i,attributes:o,content:s,eventListeners:h}}};function SA(t,e){class n extends Zae{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 jW=SA("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),DW=SA("text"),HKe=SA("nl"),j_=SA("url",{isLink:!0,toHref(t=ev.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==J0&&t[1].t===xh}}),Jo=t=>new Zs(t);function $Ke({groups:t}){const e=t.domain.concat([yC,wC,uh,SC,_C,NC,CC,kC,nl,KO,n0,AC,TC,MC,vc,EC,a0,PC]),n=[vC,xh,YO,yc,QO,n0,r0,ZO,JO,cC,dC,e0,t0,sC,iC,oC,lC,uC,hC,mC,fC,pC,gC,bC,xC],r=[yC,vC,wC,SC,_C,NC,CC,kC,nl,e0,t0,n0,AC,TC,MC,r0,vc,EC,a0,PC],i=Jo(),s=jt(i,a0);Dn(s,r,s),Dn(s,t.domain,s);const o=Jo(),l=Jo(),c=Jo();Dn(i,t.domain,o),Dn(i,t.scheme,l),Dn(i,t.slashscheme,c),Dn(o,r,s),Dn(o,t.domain,o);const d=jt(o,uh);jt(s,uh,d),jt(l,uh,d),jt(c,uh,d);const u=jt(s,yc);Dn(u,r,s),Dn(u,t.domain,s);const h=Jo();Dn(d,t.domain,h),Dn(h,t.domain,h);const f=jt(h,yc);Dn(f,t.domain,h);const p=Jo(jW);Dn(f,t.tld,p),Dn(f,t.utld,p),jt(d,J0,p);const x=jt(h,nl);jt(x,nl,x),Dn(x,t.domain,h),Dn(p,t.domain,h),jt(p,yc,f),jt(p,nl,x);const v=jt(p,xh);Dn(v,t.numeric,jW);const g=jt(o,nl),y=jt(o,yc);jt(g,nl,g),Dn(g,t.domain,o),Dn(y,r,s),Dn(y,t.domain,o);const _=Jo(j_);Dn(y,t.tld,_),Dn(y,t.utld,_),Dn(_,t.domain,o),Dn(_,r,s),jt(_,yc,y),jt(_,nl,g),jt(_,uh,d);const N=jt(_,xh),A=Jo(j_);Dn(N,t.numeric,A);const k=Jo(j_),P=Jo();Dn(k,e,k),Dn(k,n,P),Dn(P,e,k),Dn(P,n,P),jt(_,vc,k),jt(A,vc,k);const C=jt(l,xh),j=jt(c,xh),M=jt(j,vc),E=jt(M,vc);Dn(l,t.domain,o),jt(l,yc,y),jt(l,nl,g),Dn(c,t.domain,o),jt(c,yc,y),jt(c,nl,g),Dn(C,t.domain,k),jt(C,vc,k),jt(C,r0,k),Dn(E,t.domain,k),Dn(E,e,k),jt(E,vc,k);const B=[[e0,t0],[iC,sC],[oC,lC],[cC,dC],[uC,hC],[mC,fC],[pC,gC],[bC,xC]];for(let L=0;L<B.length;L++){const[U,D]=B[L],$=jt(k,U);jt(P,U,$),jt($,D,k);const q=Jo(j_);Dn($,e,q);const z=Jo();Dn($,n),Dn(q,e,q),Dn(q,n,z),Dn(z,e,q),Dn(z,n,z),jt(q,D,k),jt(z,D,k)}return jt(i,J0,_),jt(i,XO,HKe),{start:i,tokens:Yae}}function VKe(t,e,n){let r=n.length,i=0,s=[],o=[];for(;i<r;){let l=t,c=null,d=null,u=0,h=null,f=-1;for(;i<r&&!(c=l.go(n[i].t));)o.push(n[i++]);for(;i<r&&(d=c||l.go(n[i].t));)c=null,l=d,l.accepts()?(f=0,h=l):f>=0&&f++,i++,u++;if(f<0)i-=u,i<r&&(o.push(n[i]),i++);else{o.length>0&&(s.push(vj(DW,e,o)),o=[]),i-=f,u-=f;const p=h.t,x=n.slice(i-u,i);s.push(vj(p,e,x))}}return o.length>0&&s.push(vj(DW,e,o)),s}function vj(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 qKe=typeof console<"u"&&console&&console.warn||(()=>{}),GKe="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",la={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function WKe(){return Zs.groups={},la.scanner=null,la.parser=null,la.tokenQueue=[],la.pluginQueue=[],la.customSchemes=[],la.initialized=!1,la}function RW(t,e=!1){if(la.initialized&&qKe(`linkifyjs: already initialized - will not register custom scheme "${t}" ${GKe}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error(`linkifyjs: incorrect scheme format.
- 1. Must only contain digits, lowercase ASCII letters or "-"
- 2. Cannot start or end with "-"
- 3. "-" cannot repeat`);la.customSchemes.push([t,e])}function KKe(){la.scanner=UKe(la.customSchemes);for(let t=0;t<la.tokenQueue.length;t++)la.tokenQueue[t][1]({scanner:la.scanner});la.parser=$Ke(la.scanner.tokens);for(let t=0;t<la.pluginQueue.length;t++)la.pluginQueue[t][1]({scanner:la.scanner,parser:la.parser});return la.initialized=!0,la}function tI(t){return la.initialized||KKe(),VKe(la.parser.start,t,Qae(la.scanner.start,t))}tI.scan=Qae;function Jae(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 eI(n),i=tI(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 nI="[\0- -\u2029 ]",XKe=new RegExp(nI),YKe=new RegExp(`${nI}$`),QKe=new RegExp(nI,"g");function ZKe(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function JKe(t){return new Na({key:new Ni("autolink"),appendTransaction:(e,n,r)=>{const i=e.some(d=>d.docChanged)&&!n.doc.eq(r.doc),s=e.some(d=>d.getMeta("preventAutolink"));if(!i||s)return;const{tr:o}=r,l=hae(n.doc,[...e]);if(yae(l).forEach(({newRange:d})=>{const u=t9e(r.doc,d,p=>p.isTextblock);let h,f;if(u.length>1)h=u[0],f=r.doc.textBetween(h.pos,h.pos+h.node.nodeSize,void 0," ");else if(u.length){const p=r.doc.textBetween(d.from,d.to," "," ");if(!YKe.test(p))return;h=u[0],f=r.doc.textBetween(h.pos,d.to,void 0," ")}if(h&&f){const p=f.split(XKe).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=tI(x).map(y=>y.toObject(t.defaultProtocol));if(!ZKe(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=>{HO(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 eXe(t){return new Na({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 d=t.editor.view.dom;o=c.closest("a"),o&&!d.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=xae(e.state,t.type.name),d=(i=o.href)!=null?i:c.href,u=(s=o.target)!=null?s:c.target;d&&(window.open(d,u),l=!0)}return l}}})}function tXe(t){return new Na({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(u=>{c+=u.textContent});const d=Jae(c,{defaultProtocol:t.defaultProtocol}).find(u=>u.isLink&&u.value===c);return!c||!d||i!==void 0&&!i(d.value)?!1:t.editor.commands.setMark(t.type,{href:d.href})}}})}function zm(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(QKe,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var eie=dm.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"){RW(t);return}RW(t.scheme,t.optionalSlashes)})},onDestroy(){WKe()},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)=>!!zm(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=>!!zm(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=>!!zm(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",Ia(this.options.HTMLAttributes,t),0]:["a",Ia(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=>!!zm(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=>!!zm(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[Zf({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options,i=Jae(t).filter(s=>s.isLink&&this.options.isAllowedUri(s.value,{defaultValidate:o=>!!zm(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(JKe({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:i=>!!zm(i,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),t.push(eXe({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(tXe({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),nXe=eie,rXe=Object.defineProperty,aXe=(t,e)=>{for(var n in e)rXe(t,n,{get:e[n],enumerable:!0})},iXe="listItem",FW="textStyle",LW=/^\s*([-+*])\s$/,tie=ho.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",Ia(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>t.type!=="list"||t.ordered?[]:{type:"bulletList",content:t.items?e.parseChildren(t.items):[]},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
- `):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(iXe,this.editor.getAttributes(FW)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=Lb({find:LW,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Lb({find:LW,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(FW),editor:this.editor})),[t]}}),nie=ho.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",Ia(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)=>GO(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)}}}),sXe={};aXe(sXe,{findListItemPos:()=>$v,getNextListDepth:()=>rI,handleBackspace:()=>QR,handleDelete:()=>ZR,hasListBefore:()=>rie,hasListItemAfter:()=>oXe,hasListItemBefore:()=>aie,listItemHasSubList:()=>iie,nextListIsDeeper:()=>sie,nextListIsHigher:()=>oie});var $v=(t,e)=>{const{$from:n}=e.selection,r=si(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}},rI=(t,e)=>{const n=$v(t,e);if(!n)return!1;const[,r]=u9e(e,t,n.$pos.pos+4);return r},rie=(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))},aie=(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)},iie=(t,e,n)=>{if(!n)return!1;const r=si(t,e.schema);let i=!1;return n.descendants(s=>{s.type===r&&(i=!0)}),i},QR=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!tm(t.state,e)&&rie(t.state,e,n)){const{$anchor:l}=t.state.selection,c=t.state.doc.resolve(l.before()-1),d=[];c.node().descendants((f,p)=>{f.type.name===e&&d.push({node:f,pos:p})});const u=d.at(-1);if(!u)return!1;const h=t.state.doc.resolve(c.start()+u.pos+1);return t.chain().cut({from:l.start()-1,to:l.end()+1},h.end()).joinForward().run()}if(!tm(t.state,e)||!p9e(t.state))return!1;const r=$v(e,t.state);if(!r)return!1;const s=t.state.doc.resolve(r.$pos.pos-2).node(r.depth),o=iie(e,t.state,s);return aie(e,t.state)&&!o?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},sie=(t,e)=>{const n=rI(t,e),r=$v(t,e);return!r||!n?!1:n>r.depth},oie=(t,e)=>{const n=rI(t,e),r=$v(t,e);return!r||!n?!1:n<r.depth},ZR=(t,e)=>{if(!tm(t.state,e)||!f9e(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():oie(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},oXe=(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)},lie=Vr.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&&ZR(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&&ZR(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&&QR(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&&QR(t,n,r)&&(e=!0)}),e}}}}),OW=/^(\s*)(\d+)\.\s+(.*)$/,lXe=/^\s/;function cXe(t){const e=[];let n=0,r=0;for(;n<t.length;){const i=t[n],s=i.match(OW);if(!s)break;const[,o,l,c]=s,d=o.length;let u=c,h=n+1;const f=[i];for(;h<t.length;){const p=t[h];if(p.match(OW))break;if(p.trim()==="")f.push(p),u+=`
- `,h+=1;else if(p.match(lXe))f.push(p),u+=`
- ${p.slice(d+2)}`,h+=1;else break}e.push({indent:d,number:parseInt(l,10),content:u.trim(),raw:f.join(`
- `)}),r=h,n=h}return[e,r]}function cie(t,e,n){var r;const i=[];let s=0;for(;s<t.length;){const o=t[s];if(o.indent===e){const l=o.content.split(`
- `),c=((r=l[0])==null?void 0:r.trim())||"",d=[];c&&d.push({type:"paragraph",raw:c,tokens:n.inlineTokens(c)});const u=l.slice(1).join(`
- `).trim();if(u){const p=n.blockTokens(u);d.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=cie(f,p,n);d.push({type:"list",ordered:!0,start:f[0].number,items:x,raw:f.map(v=>v.raw).join(`
- `)})}i.push({type:"list_item",raw:o.raw,tokens:d}),s=h}else s+=1}return i}function dXe(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 uXe="listItem",IW="textStyle",zW=/^(\d+)\.\s$/,die=ho.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",Ia(this.options.HTMLAttributes,n),0]:["ol",Ia(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?dXe(t.items,e):[];return n!==1?{type:"orderedList",attrs:{start:n},content:r}:{type:"orderedList",content:r}},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
- `):"",markdownTokenizer:{name:"orderedList",level:"block",start:t=>{const e=t.match(/^(\s*)(\d+)\.\s+/),n=e?.index;return n!==void 0?n:-1},tokenize:(t,e,n)=>{var r;const i=t.split(`
- `),[s,o]=cXe(i);if(s.length===0)return;const l=cie(s,0,n);return l.length===0?void 0:{type:"list",ordered:!0,start:((r=s[0])==null?void 0:r.number)||1,items:l,raw:i.slice(0,o).join(`
- `)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(uXe,this.editor.getAttributes(IW)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=Lb({find:zW,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=Lb({find:zW,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(IW)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),hXe=/^\s*(\[([( |x])?\])\s$/,mXe=ho.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",Ia(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 GO(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"),d=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"}`};d(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 u=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,d(h);const f=r.extensionManager.attributes,p=Z0(h,f),x=new Set(Object.keys(p)),v=this.options.HTMLAttributes;return u.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)}),u=x,!0}}}},addInputRules(){return[Lb({find:hXe,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),fXe=ho.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",Ia(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},parseMarkdown:(t,e)=>e.createNode("taskList",{},e.parseChildren(t.items||[])),renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
- `):"",markdownTokenizer:{name:"taskList",level:"block",start(t){var e;const n=(e=t.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:e.index;return n!==void 0?n:-1},tokenize(t,e,n){const r=s=>{const o=BR(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=BR(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()}}});Vr.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(tie.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(nie.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(lie.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(die.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(mXe.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(fXe.configure(this.options.taskList)),t}});var UW=" ",pXe=" ",gXe=ho.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",Ia(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===UW||r[0].text===pXe)?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?UW:e.renderChildren(n)},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),bXe=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,xXe=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,yXe=dm.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",Ia(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[Fb({find:bXe,type:this.type})]},addPasteRules(){return[Zf({find:xXe,type:this.type})]}}),vXe=ho.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),uie=dm.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",Ia(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()}}}),wXe=uie;function SXe(t={}){return new Na({view(e){return new _Xe(e,t)}})}class _Xe{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 d,u;if(!c||c==document.body&&getComputedStyle(c).position=="static")d=-pageXOffset,u=-pageYOffset;else{let h=c.getBoundingClientRect(),f=h.width/c.offsetWidth,p=h.height/c.offsetHeight;d=h.left-c.scrollLeft*f,u=h.top-c.scrollTop*p}this.element.style.left=(r.left-d)/o+"px",this.element.style.top=(r.top-u)/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=rre(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 Da extends zn{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return Da.valid(r)?new Da(r):zn.near(r)}content(){return qt.empty}eq(e){return e instanceof Da&&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 Da(e.resolve(n.pos))}getBookmark(){return new aI(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!NXe(e)||!CXe(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&&Da.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(Da.valid(c))return c}for(;;){let o=n>0?s.firstChild:s.lastChild;if(!o){if(s.isAtom&&!s.isText&&!cn.isSelectable(s)){e=e.doc.resolve(i+s.nodeSize*n),r=!1;continue e}break}s=o,i+=n;let l=e.doc.resolve(i);if(Da.valid(l))return l}return null}}}Da.prototype.visible=!1;Da.findFrom=Da.findGapCursorFrom;zn.jsonID("gapcursor",Da);class aI{constructor(e){this.pos=e}map(e){return new aI(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return Da.valid(n)?new Da(n):zn.near(n)}}function hie(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function NXe(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||hie(i.type))return!0;if(i.inlineContent)return!1}}return!0}function CXe(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||hie(i.type))return!0;if(i.inlineContent)return!1}}return!0}function kXe(){return new Na({props:{decorations:PXe,createSelectionBetween(t,e,n){return e.pos==n.pos&&Da.valid(n)?new Da(n):null},handleClick:TXe,handleKeyDown:AXe,handleDOMEvents:{beforeinput:MXe}}})}const AXe=aae({ArrowLeft:D_("horiz",-1),ArrowRight:D_("horiz",1),ArrowUp:D_("vert",-1),ArrowDown:D_("vert",1)});function D_(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 _n){if(!s.endOfTextblock(n)||l.depth==0)return!1;c=!1,l=r.doc.resolve(e>0?l.after():l.before())}let d=Da.findGapCursorFrom(l,e,c);return d?(i&&i(r.tr.setSelection(new Da(d))),!0):!1}}function TXe(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!Da.valid(r))return!1;let i=t.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&cn.isSelectable(t.state.doc.nodeAt(i.inside))?!1:(t.dispatch(t.state.tr.setSelection(new Da(r))),!0)}function MXe(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof Da))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=Mt.empty;for(let o=r.length-1;o>=0;o--)i=Mt.from(r[o].createAndFill(null,i));let s=t.state.tr.replace(n.pos,n.pos,new qt(i,0,0));return s.setSelection(_n.near(s.doc.resolve(n.pos+1))),t.dispatch(s),!1}function PXe(t){if(!(t.selection instanceof Da))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",va.create(t.doc,[js.widget(t.selection.head,e,{key:"gapcursor"})])}var jC=200,Li=function(){};Li.prototype.append=function(e){return e.length?(e=Li.from(e),!this.length&&e||e.length<jC&&this.leafAppend(e)||this.length<jC&&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 EXe(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<=jC)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=jC)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 EXe=(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 jXe=500;class ql{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,d=[],u=[];return this.items.forEach((h,f)=>{if(!h.step){i||(i=this.remapping(r,f+1),s=i.maps.length),s--,u.push(h);return}if(i){u.push(new wc(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],d.push(new wc(x,void 0,void 0,d.length+u.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 ql(this.items.slice(0,r).append(u.reverse().concat(d)),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 u=0;u<e.steps.length;u++){let h=e.steps[u].invert(e.docs[u]),f=new wc(e.mapping.maps[u],h,n),p;(p=c&&c.merge(f))&&(f=p,u?s.pop():l=l.slice(0,l.length-1)),s.push(f),n&&(o++,n=void 0),i||(c=f)}let d=o-r.depth;return d>RXe&&(l=DXe(l,d),o-=d),new ql(l.append(s),o)}remapping(e,n){let r=new G0;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 ql(this.items.append(e.map(n=>new wc(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 wc(x,v,g))}else r.push(new wc(x))},i);let d=[];for(let f=n;f<o;f++)d.push(new wc(s.maps[f]));let u=this.items.slice(0,i).append(d).append(r),h=new ql(u,l);return h.emptyItemCount()>jXe&&(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)),d=c&&c.getMap();if(r--,d&&n.appendMap(d,r),c){let u=o.selection&&o.selection.map(n.slice(r));u&&s++;let h=new wc(d.invert(),c,u),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 ql(Li.from(i.reverse()),s)}}ql.empty=new ql(Li.empty,0);function DXe(t,e){let n;return t.forEach((r,i)=>{if(r.selection&&e--==0)return n=i,!1}),t.slice(n)}class wc{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 wc(n.getMap().invert(),n,this.selection)}}}class hh{constructor(e,n,r,i,s){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=i,this.prevComposition=s}}const RXe=20;function FXe(t,e,n,r){let i=n.getMeta(Cf),s;if(i)return i.historyState;n.getMeta(IXe)&&(t=new hh(t.done,t.undone,null,0,-1));let o=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(o&&o.getMeta(Cf))return o.getMeta(Cf).redo?new hh(t.done.addTransform(n,void 0,r,c1(e)),t.undone,BW(n.mapping.maps),t.prevTime,t.prevComposition):new hh(t.done,t.undone.addTransform(n,void 0,r,c1(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||!LXe(n,t.prevRanges)),d=o?wj(t.prevRanges,n.mapping):BW(n.mapping.maps);return new hh(t.done.addTransform(n,c?e.selection.getBookmark():void 0,r,c1(e)),ql.empty,d,n.time,l??t.prevComposition)}else return(s=n.getMeta("rebased"))?new hh(t.done.rebased(n,s),t.undone.rebased(n,s),wj(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new hh(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),wj(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function LXe(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 BW(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 wj(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 OXe(t,e,n){let r=c1(e),i=Cf.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 hh(n?l:s.remaining,n?s.remaining:l,null,0,-1);return s.transform.setSelection(o).setMeta(Cf,{redo:n,historyState:c})}let Sj=!1,HW=null;function c1(t){let e=t.plugins;if(HW!=e){Sj=!1,HW=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){Sj=!0;break}}return Sj}const Cf=new Ni("history"),IXe=new Ni("closeHistory");function zXe(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new Na({key:Cf,state:{init(){return new hh(ql.empty,ql.empty,null,0,-1)},apply(e,n,r){return FXe(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,i=r=="historyUndo"?pie:r=="historyRedo"?gie:null;return!i||!e.editable?!1:(n.preventDefault(),i(e.state,e.dispatch))}}}})}function fie(t,e){return(n,r)=>{let i=Cf.getState(n);if(!i||(t?i.undone:i.done).eventCount==0)return!1;if(r){let s=OXe(i,n,t);s&&r(e?s.scrollIntoView():s)}return!0}}const pie=fie(!1,!0),gie=fie(!0,!0);Vr.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 Na({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 d=r.tr.deleteRange(l,c);return t=!0,d}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,d=l-c,u=l;return e.deleteRange(d,u),!(this.storage.characters({node:e.doc})>r)}})]}});var UXe=Vr.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[SXe(this.options)]}});Vr.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new Na({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 va.create(t,[]);let o=0;this.options.mode==="deepest"&&t.descendants((c,d)=>{if(c.isText)return;if(!(i>=d&&i<=d+c.nodeSize-1))return!1;o+=1});let l=0;return t.descendants((c,d)=>{if(c.isText||!(i>=d&&i<=d+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(js.node(d,d+c.nodeSize,{class:this.options.className}))}),va.create(t,s)}}})]}});var BXe=Vr.create({name:"gapCursor",addProseMirrorPlugins(){return[kXe()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=Mr(an(t,"allowGapCursor",n)))!=null?e:null}}}),$W="placeholder";function HXe(t){return t.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}Vr.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:$W,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){const t=this.options.dataAttribute?`data-${HXe(this.options.dataAttribute)}`:`data-${$W}`;return[new Na({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 d=i>=c&&i<=c+l.nodeSize,u=!l.isLeaf&&yA(l);if((d||!this.options.showOnlyCurrent)&&u){const h=[this.options.emptyNodeClass];o&&h.push(this.options.emptyEditorClass);const f=js.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:d}):this.options.placeholder});s.push(f)}return this.options.includeChildren}),va.create(e,s)}}})]}});Vr.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new Na({key:new Ni("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||vae(n.selection)||t.view.dragging?null:va.create(n.doc,[js.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function VW({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||e?.type===t}var $Xe=Vr.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 Na({key:e,appendTransaction:(i,s,o)=>{const{doc:l,tr:c,schema:d}=o,u=e.getState(o),h=l.content.size,f=d.nodes[n];if(u)return c.insert(h,f.create())},state:{init:(i,s)=>{const o=s.tr.doc.lastChild;return!VW({node:o,types:r})},apply:(i,s)=>{if(!i.docChanged||i.getMeta("__uniqueIDTransaction"))return s;const o=i.doc.lastChild;return!VW({node:o,types:r})}}})]}}),VXe=Vr.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>pie(t,e),redo:()=>({state:t,dispatch:e})=>gie(t,e)}},addProseMirrorPlugins(){return[zXe(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()}}}),qXe=Vr.create({name:"starterKit",addExtensions(){var t,e,n,r;const i=[];return this.options.bold!==!1&&i.push(gKe.configure(this.options.bold)),this.options.blockquote!==!1&&i.push(uKe.configure(this.options.blockquote)),this.options.bulletList!==!1&&i.push(tie.configure(this.options.bulletList)),this.options.code!==!1&&i.push(yKe.configure(this.options.code)),this.options.codeBlock!==!1&&i.push(SKe.configure(this.options.codeBlock)),this.options.document!==!1&&i.push(_Ke.configure(this.options.document)),this.options.dropcursor!==!1&&i.push(UXe.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&i.push(BXe.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&i.push(NKe.configure(this.options.hardBreak)),this.options.heading!==!1&&i.push(CKe.configure(this.options.heading)),this.options.undoRedo!==!1&&i.push(VXe.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&i.push(kKe.configure(this.options.horizontalRule)),this.options.italic!==!1&&i.push(EKe.configure(this.options.italic)),this.options.listItem!==!1&&i.push(nie.configure(this.options.listItem)),this.options.listKeymap!==!1&&i.push(lie.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&i.push(eie.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&i.push(die.configure(this.options.orderedList)),this.options.paragraph!==!1&&i.push(gXe.configure(this.options.paragraph)),this.options.strike!==!1&&i.push(yXe.configure(this.options.strike)),this.options.text!==!1&&i.push(vXe.configure(this.options.text)),this.options.underline!==!1&&i.push(uie.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&i.push($Xe.configure((r=this.options)==null?void 0:r.trailingNode)),i}}),GXe=qXe,WXe=Vr.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")}}}),KXe=WXe,XXe=20,bie=(t,e=0)=>{const n=[];return!t.children.length||e>XXe||Array.from(t.children).forEach(r=>{r.tagName==="SPAN"?n.push(r):r.children.length&&n.push(...bie(r,e+1))}),n},YXe=t=>{if(!t.children.length)return;const e=bie(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}`)})},xie=dm.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&YXe(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",Ia(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}}}}),QXe=Vr.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()}}}),yie=Vr.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()}}}),ZXe=Vr.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()}}}),JXe=Vr.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()}}}),eYe=Vr.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()}}});Vr.create({name:"textStyleKit",addExtensions(){const t=[];return this.options.backgroundColor!==!1&&t.push(QXe.configure(this.options.backgroundColor)),this.options.color!==!1&&t.push(yie.configure(this.options.color)),this.options.fontFamily!==!1&&t.push(ZXe.configure(this.options.fontFamily)),this.options.fontSize!==!1&&t.push(JXe.configure(this.options.fontSize)),this.options.lineHeight!==!1&&t.push(eYe.configure(this.options.lineHeight)),this.options.textStyle!==!1&&t.push(xie.configure(this.options.textStyle)),t}});var tYe=yie,nYe=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,rYe=ho.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",Ia(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:"",d=(o=(s=t.attrs)==null?void 0:s.title)!=null?o:"";return d?``:``},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 d=new tWe({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}}),u=d.dom;return u.style.visibility="hidden",u.style.pointerEvents="none",c.onload=()=>{u.style.visibility="",u.style.pointerEvents=""},d}},addCommands(){return{setImage:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}},addInputRules(){return[Oae({find:nYe,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}),aYe=rYe;function JR({content:t,onChange:e,placeholder:n}){const{t:r}=Dt(),i=sKe({extensions:[GXe.configure({heading:!1,codeBlock:!1,code:!1}),wXe,nXe.configure({openOnClick:!1,HTMLAttributes:{target:"_blank",rel:"noopener noreferrer"}}),KXe.configure({types:["paragraph"]}),xie,tYe,aYe.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:d,title:u})=>a.jsx("button",{type:"button",onClick:l,title:u,className:`p-1.5 rounded hover:bg-bambu-dark-tertiary transition-colors ${c?"bg-bambu-dark-tertiary text-bambu-green":"text-bambu-gray"}`,children:d}),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(nhe,{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(ofe,{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(nge,{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(GC,{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(NX,{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(Kpe,{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(Vpe,{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(Gpe,{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(qb,{className:"w-4 h-4"})}),i.isActive("link")&&a.jsx(s,{onClick:()=>i.chain().focus().unsetLink().run(),title:r("richTextEditor.removeLink"),children:a.jsx(ek,{className:"w-4 h-4"})})]}),a.jsx(Uae,{editor:i})]})}function vie({archiveId:t,archiveName:e,onClose:n}){const r=Qt(),[i,s]=w.useState(!1),[o,l]=w.useState(null),[c,d]=w.useState({}),{data:u,isLoading:h,error:f}=Ze({queryKey:["archive-project-page",t],queryFn:()=>J.getArchiveProjectPage(t)}),p=st({mutationFn:k=>J.updateArchiveProjectPage(t,k),onSuccess:()=>{r.invalidateQueries({queryKey:["archive-project-page",t]}),s(!1),d({})}});w.useEffect(()=>{const k=P=>{P.key==="Escape"&&(o!==null?l(null):i?y():n())};return document.addEventListener("keydown",k),()=>document.removeEventListener("keydown",k)},[o,i,n]);const x=[...u?.model_pictures||[],...u?.profile_pictures||[]],v=()=>{d({title:u?.title||"",description:u?.description||"",designer:u?.designer||"",license:u?.license||"",profile_title:u?.profile_title||"",profile_description:u?.profile_description||""}),s(!0)},g=()=>{p.mutate(c)},y=()=>{s(!1),d({})},_=k=>{const P=["p","br","b","strong","i","em","u","a","ul","ol","li","figure","img"],C=new DOMParser().parseFromString(k,"text/html"),j=M=>{if(M.nodeType===Node.TEXT_NODE)return M.textContent||"";if(M.nodeType===Node.ELEMENT_NODE){const E=M,B=E.tagName.toLowerCase();if(!P.includes(B))return Array.from(E.childNodes).map(j).join("");let L="";if(B==="a"&&E.getAttribute("href")){const D=E.getAttribute("href");D?.toLowerCase().startsWith("http")&&(L=` href="${D}" target="_blank" rel="noopener noreferrer"`)}if(B==="img"){const D=E.getAttribute("src");if(!D?.toLowerCase().startsWith("http"))return"";L=` src="${D}" style="max-width: 100%; height: auto;"`}const U=Array.from(E.childNodes).map(j).join("");return["br","img"].includes(B)?`<${B}${L} />`:`<${B}${L}>${U}</${B}>`}return""};return Array.from(C.body.childNodes).map(j).join("")},N=u&&(u.title||u.description||u.designer||u.profile_title||x.length>0),A=k=>{k.target===k.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(Ps,{className:"w-5 h-5 text-bambu-green"}),a.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Project Page",e&&a.jsxs("span",{className:"text-bambu-gray ml-2",children:["- ",e]})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[!i&&N&&a.jsxs(Me,{variant:"ghost",size:"sm",onClick:v,children:[a.jsx(Pf,{className:"w-4 h-4 mr-1"}),"Edit"]}),i&&a.jsxs(a.Fragment,{children:[a.jsx(Me,{variant:"ghost",size:"sm",onClick:y,children:"Cancel"}),a.jsxs(Me,{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(Rt,{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"}),u&&!N&&a.jsxs("div",{className:"text-bambu-gray text-center py-12",children:[a.jsx(Ps,{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."})]}),u&&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:k=>d({...c,title:k.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"}):u.title&&a.jsx("h3",{className:"text-xl font-semibold text-white",children:u.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(nu,{className:"w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",value:c.designer||"",onChange:k=>d({...c,designer:k.target.value}),placeholder:"Designer",className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1 text-white"})]}):u.designer&&a.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[a.jsx(nu,{className:"w-4 h-4"}),a.jsx("span",{children:u.designer}),u.designer_user_id&&a.jsx("a",{href:`https://makerworld.com/en/@${u.designer_user_id}`,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-green hover:underline",children:a.jsx(ta,{className:"w-3 h-3"})})]}),u.creation_date&&a.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[a.jsx(da,{className:"w-4 h-4"}),a.jsx("span",{children:u.creation_date})]}),i?a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Ps,{className:"w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",value:c.license||"",onChange:k=>d({...c,license:k.target.value}),placeholder:"License",className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1 text-white"})]}):u.license&&a.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[a.jsx(Ps,{className:"w-4 h-4"}),a.jsx("span",{children:u.license})]}),u.origin&&a.jsx("span",{className:"px-2 py-0.5 bg-bambu-dark rounded text-bambu-gray",children:u.origin})]})]}),(u.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(JR,{content:c.description||"",onChange:k=>d({...c,description:k}),placeholder:"Enter description..."}):a.jsx("div",{className:"prose prose-invert prose-sm max-w-none text-bambu-gray-light",dangerouslySetInnerHTML:{__html:_(u.description||"")}})]}),(u.profile_title||u.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:k=>d({...c,profile_title:k.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(JR,{content:c.profile_description||"",onChange:k=>d({...c,profile_description:k}),placeholder:"Profile description..."})]}):a.jsxs(a.Fragment,{children:[u.profile_title&&a.jsx("p",{className:"text-white font-medium",children:u.profile_title}),u.profile_description&&a.jsx("div",{className:"prose prose-invert prose-sm max-w-none text-bambu-gray-light",dangerouslySetInnerHTML:{__html:_(u.profile_description)}}),u.profile_user_name&&a.jsxs("p",{className:"text-sm text-bambu-gray",children:["by ",u.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(eu,{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((k,P)=>a.jsx("button",{onClick:()=>l(P),className:"aspect-square rounded-lg overflow-hidden border border-bambu-dark-tertiary hover:border-bambu-green transition-colors",children:a.jsx("img",{src:k.url,alt:k.name,className:"w-full h-full object-cover"})},k.path))})]}),u.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/${u.design_model_id}`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-bambu-green hover:underline",children:[a.jsx(ta,{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:k=>{k.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(Yl,{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:k=>k.stopPropagation()}),a.jsx("button",{onClick:k=>{k.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(Rt,{className:"w-6 h-6 text-white"})}),a.jsxs("div",{className:"absolute bottom-4 text-white text-sm",children:[o+1," / ",x.length]})]})]})}const iYe=[.25,.5,.75,1,1.5,2,3,4];function Ag(t){const e=Math.floor(t/60),n=Math.floor(t%60);return`${e}:${n.toString().padStart(2,"0")}`}function sYe({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),[d,u]=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),[k,P]=w.useState(null),[C,j]=w.useState(.8),[M,E]=w.useState(!1),{data:B,isLoading:L}=Ze({queryKey:["timelapse-info",t],queryFn:()=>J.getTimelapseInfo(t)}),{data:U}=Ze({queryKey:["timelapse-thumbnails",t],queryFn:()=>J.getTimelapseThumbnails(t,15)}),D=st({mutationFn:()=>J.processTimelapse(t,{trimStart:p,trimEnd:v,speed:y,saveMode:"replace"},N||void 0),onSuccess:H=>{i(H.message,"success"),r?.(),n()},onError:H=>{i(H.message||"Processing failed","error")}});w.useEffect(()=>{B?.duration&&v===0&&g(B.duration)},[B?.duration,v]),w.useEffect(()=>{const H=X=>{X.key==="Escape"&&n()};return window.addEventListener("keydown",H),()=>window.removeEventListener("keydown",H)},[n]),w.useEffect(()=>{const H=s.current;if(!H)return;const X=()=>{const oe=H.currentTime;u(oe),oe>=v&&(H.currentTime=p)},Z=()=>{f(H.duration),v===0&&g(H.duration)},ee=()=>c(!0),Se=()=>c(!1);return H.addEventListener("timeupdate",X),H.addEventListener("durationchange",Z),H.addEventListener("play",ee),H.addEventListener("pause",Se),()=>{H.removeEventListener("timeupdate",X),H.removeEventListener("durationchange",Z),H.removeEventListener("play",ee),H.removeEventListener("pause",Se)}},[p,v]),w.useEffect(()=>{const H=o.current,X=s.current;!H||!X||!k||(H.currentTime=X.currentTime,H.playbackRate=X.playbackRate,l&&!M?H.play().catch(()=>{}):H.pause())},[l,k,M]),w.useEffect(()=>{o.current&&(o.current.volume=M?0:C)},[C,M]),w.useEffect(()=>{s.current&&(s.current.playbackRate=y),o.current&&(o.current.playbackRate=y)},[y]);const $=w.useCallback(()=>{const H=s.current;H&&(l?H.pause():(H.currentTime<p&&(H.currentTime=p),H.play()))},[l,p]),q=H=>{const X=s.current;X&&(X.currentTime=Math.max(p,Math.min(v,H)))},z=H=>{const X=H.target.files?.[0];X&&(k&&URL.revokeObjectURL(k),A(X),P(URL.createObjectURL(X)))},W=()=>{k&&URL.revokeObjectURL(k),A(null),P(null)};w.useEffect(()=>()=>{k&&URL.revokeObjectURL(k)},[k]);const Q=v-p,te=Q/y;return L?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(at,{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(Ph,{className:"w-5 h-5 text-bambu-green"}),"Edit Timelapse"]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Me,{variant:"primary",size:"sm",onClick:()=>D.mutate(),disabled:D.isPending,children:D.isPending?a.jsxs(a.Fragment,{children:[a.jsx(at,{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(Rt,{className:"w-5 h-5 text-bambu-gray"})})]})]}),a.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-4",children:[a.jsxs("div",{className:"relative",children:[a.jsx("video",{ref:s,src:e,className:"w-full rounded-lg bg-black",onClick:$,muted:!!k}),!l&&a.jsx("button",{onClick:$,className:"absolute inset-0 flex items-center justify-center bg-black/30 hover:bg-black/40 transition-colors",children:a.jsx("div",{className:"p-4 bg-bambu-green rounded-full",children:a.jsx(oo,{className:"w-8 h-8 text-white"})})}),k&&a.jsx("audio",{ref:o,src:k,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(fpe,{className:"w-4 h-4"}),a.jsx("span",{children:"Trim"}),a.jsxs("span",{className:"ml-auto",children:[Ag(p)," - ",Ag(v)," (",Ag(Q),")"]})]}),a.jsxs("div",{className:"relative h-16 bg-bambu-dark rounded-lg overflow-hidden",children:[a.jsx("div",{className:"absolute inset-0 flex",children:U?.thumbnails.map((H,X)=>a.jsx("div",{className:"flex-1 bg-cover bg-center",style:{backgroundImage:`url(data:image/jpeg;base64,${H})`}},X))}),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:`${d/h*100}%`}}),a.jsx("input",{type:"range",min:0,max:h,step:.1,value:p,onChange:H=>{const X=parseFloat(H.target.value);X<v-1&&(x(X),s.current&&s.current.currentTime<X&&(s.current.currentTime=X))},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:H=>{const X=parseFloat(H.target.value);X>p+1&&g(X)},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:d,onChange:H=>q(parseFloat(H.target.value)),className:`w-full h-1 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer
- [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3
- [&::-webkit-slider-thumb]:bg-bambu-green [&::-webkit-slider-thumb]:rounded-full
- [&::-webkit-slider-thumb]:cursor-pointer`}),a.jsx("div",{className:"flex items-center justify-center gap-2",children:a.jsx("button",{onClick:$,className:"p-2 bg-bambu-green hover:bg-bambu-green-dark rounded-lg transition-colors",children:l?a.jsx(XC,{className:"w-5 h-5 text-white"}):a.jsx(oo,{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(qC,{className:"w-4 h-4"}),a.jsx("span",{children:"Speed"}),a.jsxs("span",{className:"ml-auto",children:[y,"x (output: ",Ag(te),")"]})]}),a.jsx("div",{className:"flex gap-1",children:iYe.map(H=>a.jsxs("button",{onClick:()=>_(H),className:`flex-1 px-2 py-2 text-sm rounded transition-colors ${y===H?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:[H,"x"]},H))})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[a.jsx(c3,{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(c3,{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:()=>E(!M),className:"p-2 hover:bg-bambu-dark-tertiary rounded transition-colors",children:M?a.jsx(uge,{className:"w-4 h-4 text-bambu-gray"}):a.jsx(cge,{className:"w-4 h-4 text-bambu-green"})}),a.jsx("input",{type:"range",min:0,max:1,step:.1,value:C,onChange:H=>j(parseFloat(H.target.value)),className:`w-20 h-1 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer
- [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3
- [&::-webkit-slider-thumb]:bg-bambu-green [&::-webkit-slider-thumb]:rounded-full`}),a.jsx("button",{onClick:W,className:"p-2 hover:bg-red-500/20 rounded transition-colors",children:a.jsx(Yt,{className:"w-4 h-4 text-red-400"})})]}):a.jsxs("label",{className:"flex flex-col items-center justify-center gap-2 p-6 border-2 border-dashed border-bambu-dark-tertiary rounded-lg cursor-pointer hover:border-bambu-green/50 transition-colors",children:[a.jsx(Oa,{className:"w-8 h-8 text-bambu-gray"}),a.jsx("span",{className:"text-sm text-bambu-gray",children:"Drop audio file or click to upload"}),a.jsx("span",{className:"text-xs text-bambu-gray/60",children:"MP3, WAV, M4A, AAC, OGG"}),a.jsx("input",{type:"file",accept:".mp3,.wav,.m4a,.aac,.ogg,audio/*",onChange:z,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:"})," ",Ag(h)," @ ",B?.width,"x",B?.height]}),a.jsxs("p",{className:"text-bambu-gray",children:[a.jsx("span",{className:"text-white",children:"Output:"})," ",Ag(te)," @ ",y,"x speed",N&&" + music overlay"]})]})]}),D.isPending&&a.jsxs("div",{className:"absolute inset-0 bg-black/80 flex flex-col items-center justify-center gap-4",children:[a.jsx(at,{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 oYe=[.25,.5,.75,1,1.5,2,3,4];function wie({src:t,title:e,downloadFilename:n,archiveId:r,onClose:i,onEdit:s}){const o=w.useRef(null),[l,c]=w.useState(!0),[d,u]=w.useState(1),[h,f]=w.useState(0),[p,x]=w.useState(0),[v,g]=w.useState(!1);w.useEffect(()=>{const C=o.current;C&&(C.playbackRate=d)},[d]),w.useEffect(()=>{const C=j=>{j.key==="Escape"&&i()};return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[i]),w.useEffect(()=>{const C=o.current;if(!C)return;const j=()=>f(C.currentTime),M=()=>x(C.duration),E=()=>c(!0),B=()=>c(!1);return C.addEventListener("timeupdate",j),C.addEventListener("durationchange",M),C.addEventListener("play",E),C.addEventListener("pause",B),()=>{C.removeEventListener("timeupdate",j),C.removeEventListener("durationchange",M),C.removeEventListener("play",E),C.removeEventListener("pause",B)}},[]);const y=()=>{const C=o.current;C&&(l?C.pause():C.play())},_=C=>{const j=o.current;j&&(j.currentTime=parseFloat(C.target.value))},N=()=>{const C=o.current;C&&(C.currentTime=Math.max(0,C.currentTime-5))},A=()=>{const C=o.current;C&&(C.currentTime=Math.min(p,C.currentTime+5))},k=C=>{const j=Math.floor(C/60),M=Math.floor(C%60);return`${j}:${M.toString().padStart(2,"0")}`},P=()=>{const C=document.createElement("a");C.href=t,C.download=n,C.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(Ph,{className:"w-5 h-5 text-bambu-green"}),e]}),a.jsxs("div",{className:"flex items-center gap-2",children:[r&&a.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>g(!0),children:[a.jsx(Ga,{className:"w-4 h-4"}),"Edit"]}),a.jsxs(Me,{variant:"secondary",size:"sm",onClick:P,children:[a.jsx(ga,{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(Rt,{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:k(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
- [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3
- [&::-webkit-slider-thumb]:bg-bambu-green [&::-webkit-slider-thumb]:rounded-full
- [&::-webkit-slider-thumb]:cursor-pointer`}),a.jsx("span",{className:"text-xs text-bambu-gray w-12",children:k(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(Ape,{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(XC,{className:"w-5 h-5 text-white"}):a.jsx(oo,{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(PF,{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:oYe.map(C=>a.jsxs("button",{onClick:()=>u(C),className:`px-2 py-1 text-xs rounded transition-colors ${d===C?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:bg-bambu-dark-tertiary/80"}`,children:[C,"x"]},C))})]})]})]})]})]}),v&&r&&a.jsx(sYe,{archiveId:r,timelapseSrc:t,onClose:()=>g(!1),onSave:s})]})}function lYe({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}=Ze({queryKey:["archive-comparison",t],queryFn:()=>J.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(Rt,{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(at,{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(An,{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(cYe,{comparison:n}):null}),a.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:a.jsx(Me,{variant:"secondary",onClick:e,className:"w-full",children:"Close"})})]})})}function cYe({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(An,{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(An,{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(na,{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 dYe(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 uYe({upload:t,projects:e,onArchive:n,onDiscard:r,isArchiving:i,isDiscarding:s}){const[o,l]=w.useState(!1),[c,d]=w.useState(t.tags||""),[u,h]=w.useState(t.notes||""),[f,p]=w.useState(t.project_id),[x,v]=w.useState(!1);return a.jsx(St,{children:a.jsxs(Nt,{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(hf,{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:hl(t.file_size)}),a.jsx("span",{children:"·"}),a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(qn,{className:"w-3 h-3"}),dYe(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(wl,{className:"w-5 h-5"}):a.jsx(Mn,{className:"w-5 h-5"})}),a.jsx(Me,{variant:"primary",size:"sm",onClick:()=>n(t.id,{tags:c,notes:u,project_id:f||void 0}),disabled:i,children:i?a.jsx(at,{className:"w-4 h-4 animate-spin"}):a.jsxs(a.Fragment,{children:[a.jsx(Ds,{className:"w-4 h-4"}),"Archive"]})}),a.jsx(Me,{variant:"secondary",size:"sm",onClick:()=>v(!0),disabled:s,children:s?a.jsx(at,{className:"w-4 h-4 animate-spin"}):a.jsx(Yt,{className:"w-4 h-4 text-red-400"})})]})]}),x&&a.jsx(xn,{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=>d(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:u,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 hYe(){const t=Qt(),{showToast:e}=dn(),[n,r]=w.useState(!1),[i,s]=w.useState(!1),[o,l]=w.useState(new Set),[c,d]=w.useState(new Set),{data:u,isLoading:h}=Ze({queryKey:["pending-uploads"],queryFn:Eg.list,refetchInterval:1e4}),{data:f}=Ze({queryKey:["projects"],queryFn:()=>J.getProjects()}),p=st({mutationFn:({id:y,data:_})=>Eg.archive(y,_),onMutate:({id:y})=>{l(_=>new Set(_).add(y))},onSettled:(y,_,{id:N})=>{l(A=>{const k=new Set(A);return k.delete(N),k})},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=st({mutationFn:y=>Eg.discard(y),onMutate:y=>{d(_=>new Set(_).add(y))},onSettled:(y,_,N)=>{d(A=>{const k=new Set(A);return k.delete(N),k})},onSuccess:()=>{t.invalidateQueries({queryKey:["pending-uploads"]}),e("Upload discarded")},onError:y=>{e(y.message||"Failed to discard","error")}}),v=st({mutationFn:Eg.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=st({mutationFn:Eg.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(St,{children:a.jsx(Nt,{className:"py-8 flex justify-center",children:a.jsx(at,{className:"w-6 h-6 animate-spin text-bambu-green"})})}):!u||u.length===0?null:a.jsxs("div",{className:"mb-6",children:[a.jsxs(St,{className:"border-l-4 border-l-yellow-500",children:[a.jsx(On,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Oa,{className:"w-5 h-5 text-yellow-500"}),a.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Pending Uploads (",u.length,")"]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Me,{variant:"primary",size:"sm",onClick:()=>r(!0),disabled:v.isPending,children:v.isPending?a.jsx(at,{className:"w-4 h-4 animate-spin"}):a.jsxs(a.Fragment,{children:[a.jsx(Ds,{className:"w-4 h-4"}),"Archive All"]})}),a.jsx(Me,{variant:"secondary",size:"sm",onClick:()=>s(!0),disabled:g.isPending,children:g.isPending?a.jsx(at,{className:"w-4 h-4 animate-spin"}):a.jsxs(a.Fragment,{children:[a.jsx(Yt,{className:"w-4 h-4"}),"Discard All"]})})]})]})}),a.jsxs(Nt,{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:u.map(y=>a.jsx(uYe,{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(xn,{title:"Archive All Uploads",message:`Are you sure you want to archive all ${u.length} pending uploads?`,confirmText:"Archive All",onConfirm:()=>{v.mutate(),r(!1)},onCancel:()=>r(!1)}),i&&a.jsx(xn,{title:"Discard All Uploads",message:`Are you sure you want to discard all ${u.length} pending uploads? This cannot be undone.`,confirmText:"Discard All",variant:"danger",onConfirm:()=>{g.mutate(),s(!1)},onCancel:()=>s(!1)})]})}function mYe({onClose:t}){const e=Qt(),{showToast:n}=dn(),[r,i]=w.useState(""),[s,o]=w.useState(null),[l,c]=w.useState(""),[d,u]=w.useState(null),[h,f]=w.useState("count");w.useEffect(()=>{const M=E=>{E.key==="Escape"&&(s?o(null):d?u(null):t())};return window.addEventListener("keydown",M),()=>window.removeEventListener("keydown",M)},[t,s,d]);const{data:p,isLoading:x}=Ze({queryKey:["tags"],queryFn:J.getTags}),v=st({mutationFn:({oldName:M,newName:E})=>J.renameTag(M,E),onSuccess:(M,{oldName:E,newName:B})=>{e.invalidateQueries({queryKey:["tags"]}),e.invalidateQueries({queryKey:["archives"]}),n(`Renamed "${E}" to "${B}" in ${M.affected} archive${M.affected!==1?"s":""}`),o(null)},onError:M=>{n(M.message||"Failed to rename tag","error")}}),g=st({mutationFn:M=>J.deleteTag(M),onSuccess:(M,E)=>{e.invalidateQueries({queryKey:["tags"]}),e.invalidateQueries({queryKey:["archives"]}),n(`Deleted "${E}" from ${M.affected} archive${M.affected!==1?"s":""}`),u(null)},onError:M=>{n(M.message||"Failed to delete tag","error")}}),y=M=>{o(M.name),c(M.name),u(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(),_())},k=M=>{u(M),o(null)},P=()=>{d&&g.mutate(d)},C=p?.filter(M=>M.name.toLowerCase().includes(r.toLowerCase())).sort((M,E)=>h==="count"&&E.count-M.count||M.name.localeCompare(E.name)),j=p?.reduce((M,E)=>M+E.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(St,{className:"w-full max-w-lg max-h-[80vh] flex flex-col",children:a.jsxs(Nt,{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(qh,{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(Rt,{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 ",j," usage",j!==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(at,{className:"w-6 h-6 animate-spin text-bambu-gray"})}):C?.length?a.jsx("div",{className:"space-y-2",children:C.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:E=>c(E.target.value),onKeyDown:A,autoFocus:!0}),a.jsx(Me,{size:"sm",variant:"primary",onClick:N,disabled:!l.trim()||v.isPending,className:"p-1.5",children:v.isPending?a.jsx(at,{className:"w-4 h-4 animate-spin"}):a.jsx(na,{className:"w-4 h-4"})}),a.jsx(Me,{size:"sm",variant:"ghost",onClick:_,className:"p-1.5",children:a.jsx(Rt,{className:"w-4 h-4"})})]}):d===M.name?a.jsxs("div",{className:"flex-1 flex items-center gap-2",children:[a.jsx(An,{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(Me,{size:"sm",variant:"danger",onClick:P,disabled:g.isPending,className:"p-1.5",children:g.isPending?a.jsx(at,{className:"w-4 h-4 animate-spin"}):a.jsx(Yt,{className:"w-4 h-4"})}),a.jsx(Me,{size:"sm",variant:"ghost",onClick:()=>u(null),className:"p-1.5",children:a.jsx(Rt,{className:"w-4 h-4"})})]}):a.jsxs(a.Fragment,{children:[a.jsx(qh,{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(Ga,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>k(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(Yt,{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(Me,{variant:"secondary",onClick:t,className:"flex-1",children:"Close"})})]})})})}function yh(t){if(!t)return!1;const e=t.toLowerCase();return e.endsWith(".gcode")||e.includes(".gcode.")}function Sie(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 vh(t,e,n,r){try{if(n==="source"){const{token:i}=await J.createSourceSlicerToken(t),s=J.getSourceSlicerDownloadUrl(t,i,e);of(`${window.location.origin}${s}`,r)}else{const{token:i}=await J.createArchiveSlicerToken(t),s=J.getArchiveSlicerDownloadUrl(t,i,e);of(`${window.location.origin}${s}`,r)}}catch{const i=n==="source"?J.getSource3mfForSlicer(t,e):J.getArchiveForSlicer(t,e);of(`${window.location.origin}${i}`,r)}}function fYe({archive:t,printerName:e,isSelected:n,onSelect:r,selectionMode:i,projects:s,isHighlighted:o,timeFormat:l="system",preferredSlicer:c="bambu_studio",currency:d,t:u}){o&&console.log("ArchiveCard isHighlighted=true for archive:",t.id);const h=Qt(),{showToast:f}=dn(),{hasPermission:p,canModify:x}=jr(),v=Cne(),[g,y]=w.useState(!1),[_,N]=w.useState(!1),[A,k]=w.useState(!1),[P,C]=w.useState(!1),[j,M]=w.useState(!1),[E,B]=w.useState(!1),[L,U]=w.useState([]),[D,$]=w.useState(!1),[q,z]=w.useState(!1),[W,Q]=w.useState(!1),[te,H]=w.useState(!1),[X,Z]=w.useState(!1),[ee,Se]=w.useState(!1),[oe,ie]=w.useState(!1),[me,se]=w.useState(null),[ce,Ce]=w.useState(null),[le,Le]=w.useState(!1),V=w.useRef(null),K=w.useRef(null),fe=w.useRef(null),{data:Y}=Ze({queryKey:["archive-plates",t.id],queryFn:()=>J.getArchivePlates(t.id),enabled:le,staleTime:300*1e3}),re=Y?.plates??[],ue=Y?.is_multi_plate??!1,Fe=ce??0,Pe=st({mutationFn:()=>J.deleteArchiveTimelapse(t.id),onSuccess:()=>{h.invalidateQueries({queryKey:["archives"]}),f(u("archives.toast.timelapseRemoved"))},onError:xe=>{f(xe.message||u("archives.toast.failedRemoveTimelapse"),"error")}}),be=st({mutationFn:xe=>J.uploadArchiveTimelapse(t.id,xe),onSuccess:xe=>{h.invalidateQueries({queryKey:["archives"]}),f(u("archives.toast.timelapseUploaded",{filename:xe.filename}))},onError:xe=>{f(xe.message||u("archives.toast.failedUploadTimelapse"),"error")}}),O=st({mutationFn:xe=>J.uploadSource3mf(t.id,xe),onSuccess:xe=>{h.invalidateQueries({queryKey:["archives"]}),f(u("archives.toast.source3mfAttached",{filename:xe.filename}))},onError:xe=>{f(xe.message||u("archives.toast.failedUploadSource3mf"),"error")}}),R=st({mutationFn:()=>J.deleteSource3mf(t.id),onSuccess:()=>{h.invalidateQueries({queryKey:["archives"]}),f(u("archives.toast.source3mfRemoved"))},onError:xe=>{f(xe.message||u("archives.toast.failedRemoveSource3mf"),"error")}}),G=st({mutationFn:xe=>J.uploadF3d(t.id,xe),onSuccess:xe=>{h.invalidateQueries({queryKey:["archives"]}),f(u("archives.toast.f3dAttached",{filename:xe.filename}))},onError:xe=>{f(xe.message||u("archives.toast.failedUploadF3d"),"error")}}),de=st({mutationFn:()=>J.deleteF3d(t.id),onSuccess:()=>{h.invalidateQueries({queryKey:["archives"]}),f(u("archives.toast.f3dRemoved"))},onError:xe=>{f(xe.message||u("archives.toast.failedRemoveF3d"),"error")}}),ge=st({mutationFn:()=>J.scanArchiveTimelapse(t.id),onSuccess:xe=>{xe.status==="attached"?(h.invalidateQueries({queryKey:["archives"]}),f(u("archives.toast.timelapseAttached",{filename:xe.filename}))):xe.status==="exists"?f(u("archives.toast.timelapseAlreadyAttached")):xe.status==="not_found"&&xe.available_files&&xe.available_files.length>0?(U(xe.available_files),B(!0)):f(xe.message||u("archives.toast.noMatchingTimelapse"),"warning")},onError:xe=>{f(xe.message||u("archives.toast.failedScanTimelapse"),"error")}}),ae=st({mutationFn:xe=>J.selectArchiveTimelapse(t.id,xe),onSuccess:xe=>{h.invalidateQueries({queryKey:["archives"]}),f(u("archives.toast.timelapseAttached",{filename:xe.filename})),B(!1),U([])},onError:xe=>{f(xe.message||u("archives.toast.failedAttachTimelapse"),"error")}}),Ue=st({mutationFn:()=>J.deleteArchive(t.id),onSuccess:()=>{h.invalidateQueries({queryKey:["archives"]}),f(u("archives.toast.archiveDeleted"))},onError:()=>{f(u("archives.toast.failedDeleteArchive"),"error")}}),ze=st({mutationFn:()=>J.toggleFavorite(t.id),onSuccess:xe=>{h.invalidateQueries({queryKey:["archives"]}),f(xe.is_favorite?u("archives.toast.addedToFavorites"):u("archives.toast.removedFromFavorites"))}}),{data:$e}=Ze({queryKey:["archive-folders",t.id],queryFn:()=>J.getLibraryFoldersByArchive(t.id)}),Re=st({mutationFn:xe=>J.updateArchive(t.id,{project_id:xe}),onSuccess:()=>{h.invalidateQueries({queryKey:["archives"]}),h.invalidateQueries({queryKey:["projects"]}),f(u("archives.toast.projectUpdated"))},onError:()=>{f(u("archives.toast.failedUpdateProject"),"error")}}),pe=xe=>{xe.preventDefault(),se({x:xe.clientX,y:xe.clientY})},Ne=[...yh(t.filename)?[{label:u("archives.menu.print"),icon:a.jsx(Nr,{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:u("archives.permission.noReprint"):u("archives.card.noFileForReprint")},{label:u("archives.menu.schedule"),icon:a.jsx(da,{className:"w-4 h-4"}),onClick:()=>H(!0),disabled:!t.file_path||!p("queue:create"),title:t.file_path?p("queue:create")?void 0:u("archives.permission.noAddToQueue"):u("archives.card.noFileForReprint")},{label:u("archives.menu.openInBambuStudio"),icon:a.jsx(ta,{className:"w-4 h-4"}),onClick:()=>{const xe=t.print_name||t.filename||"model";vh(t.id,xe,"file",c)},disabled:!t.file_path,title:t.file_path?void 0:u("archives.card.noFileForReprint")}]:[{label:u("archives.menu.slice"),icon:a.jsx(ta,{className:"w-4 h-4"}),onClick:()=>{const xe=t.print_name||t.filename||"model";vh(t.id,xe,"file",c)}}],{label:t.external_url?u("archives.menu.externalLink"):u("archives.menu.viewOnMakerWorld"),icon:a.jsx(Eh,{className:"w-4 h-4"}),onClick:()=>{const xe=t.external_url||t.makerworld_url;xe&&window.open(xe,"_blank")},disabled:!t.external_url&&!t.makerworld_url},{label:"",divider:!0,onClick:()=>{}},{label:u("archives.menu.preview3d"),icon:a.jsx(ei,{className:"w-4 h-4"}),onClick:()=>y(!0)},{label:u("archives.menu.viewTimelapse"),icon:a.jsx(Ph,{className:"w-4 h-4"}),onClick:()=>M(!0),disabled:!t.timelapse_path},{label:u("archives.menu.scanForTimelapse"),icon:a.jsx(_1,{className:"w-4 h-4"}),onClick:()=>ge.mutate(),disabled:!t.printer_id||!!t.timelapse_path||ge.isPending||!x("archives","update",t.created_by_id),title:x("archives","update",t.created_by_id)?void 0:u("archives.permission.noUpdateArchives")},{label:u("archives.menu.uploadTimelapse"),icon:a.jsx(Oa,{className:"w-4 h-4"}),onClick:()=>fe.current?.click(),disabled:!!t.timelapse_path||!x("archives","update",t.created_by_id),title:x("archives","update",t.created_by_id)?void 0:u("archives.permission.noUpdateArchives")},...t.timelapse_path?[{label:u("archives.menu.removeTimelapse"),icon:a.jsx(Yt,{className:"w-4 h-4"}),onClick:()=>ie(!0),danger:!0,disabled:!x("archives","update",t.created_by_id),title:x("archives","update",t.created_by_id)?void 0:u("archives.permission.noUpdateArchives")}]:[],{label:"",divider:!0,onClick:()=>{}},{label:t.source_3mf_path?u("archives.menu.downloadSource3mf"):u("archives.menu.uploadSource3mf"),icon:a.jsx(y1,{className:"w-4 h-4"}),onClick:()=>{t.source_3mf_path?J.downloadSource3mf(t.id).catch(xe=>{console.error("Source 3MF download failed:",xe)}):V.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)?u("archives.permission.noUploadFiles"):void 0},...t.source_3mf_path?[{label:u("archives.menu.replaceSource3mf"),icon:a.jsx(Oa,{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:u("archives.permission.noUpdateArchives")},{label:u("archives.menu.removeSource3mf"),icon:a.jsx(Yt,{className:"w-4 h-4"}),onClick:()=>Z(!0),danger:!0,disabled:!x("archives","update",t.created_by_id),title:x("archives","update",t.created_by_id)?void 0:u("archives.permission.noUpdateArchives")}]:[],{label:t.f3d_path?u("archives.menu.replaceF3d"):u("archives.menu.uploadF3d"),icon:a.jsx(ei,{className:"w-4 h-4"}),onClick:()=>K.current?.click(),disabled:!x("archives","update",t.created_by_id),title:x("archives","update",t.created_by_id)?void 0:u("archives.permission.noUpdateArchives")},...t.f3d_path?[{label:u("archives.menu.downloadF3d"),icon:a.jsx(ga,{className:"w-4 h-4"}),onClick:()=>{J.downloadF3d(t.id).catch(xe=>{console.error("F3D download failed:",xe)})}},{label:u("archives.menu.removeF3d"),icon:a.jsx(Yt,{className:"w-4 h-4"}),onClick:()=>Se(!0),danger:!0,disabled:!x("archives","update",t.created_by_id),title:x("archives","update",t.created_by_id)?void 0:u("archives.permission.noUpdateArchives")}]:[],{label:"",divider:!0,onClick:()=>{}},{label:u("archives.menu.download"),icon:a.jsx(ga,{className:"w-4 h-4"}),onClick:()=>{J.downloadArchive(t.id,`${t.print_name||t.filename}.3mf`).catch(xe=>{console.error("Archive download failed:",xe)})},disabled:!p("archives:read"),title:p("archives:read")?void 0:u("archives.permission.noDownload")},{label:u("archives.menu.copyDownloadLink"),icon:a.jsx(Ql,{className:"w-4 h-4"}),onClick:()=>{const xe=`${window.location.origin}${J.getArchiveDownload(t.id)}`;navigator.clipboard.writeText(xe).then(()=>{f(u("archives.toast.linkCopied"))}).catch(()=>{f(u("archives.toast.failedCopyLink"),"error")})},disabled:!p("archives:read"),title:p("archives:read")?void 0:u("archives.permission.noCopyLink")},{label:u("archives.menu.qrCode"),icon:a.jsx(kX,{className:"w-4 h-4"}),onClick:()=>$(!0)},{label:t.photos?.length?u("archives.menu.viewPhotosCount",{count:t.photos.length}):u("archives.menu.viewPhotos"),icon:a.jsx(db,{className:"w-4 h-4"}),onClick:()=>z(!0),disabled:!t.photos?.length},{label:u("archives.menu.projectPage"),icon:a.jsx(Ps,{className:"w-4 h-4"}),onClick:()=>Q(!0)},{label:"",divider:!0,onClick:()=>{}},{label:t.is_favorite?u("archives.menu.removeFromFavorites"):u("archives.menu.addToFavorites"),icon:a.jsx(Ef,{className:`w-4 h-4 ${t.is_favorite?"fill-yellow-400 text-yellow-400":""}`}),onClick:()=>ze.mutate(),disabled:!x("archives","update",t.created_by_id),title:x("archives","update",t.created_by_id)?void 0:u("archives.permission.noUpdateArchives")},{label:u("archives.menu.edit"),icon:a.jsx(Ga,{className:"w-4 h-4"}),onClick:()=>C(!0),disabled:!x("archives","update",t.created_by_id),title:x("archives","update",t.created_by_id)?void 0:u("archives.permission.noUpdateArchives")},...t.project_id&&t.project_name?[{label:u("archives.menu.goToProject",{name:t.project_name}),icon:a.jsx(xs,{className:"w-4 h-4 text-bambu-green"}),onClick:()=>window.location.href="/projects"}]:[],{label:u("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:u("archives.permission.noUpdateArchives"),submenu:(()=>{const xe=[];if(t.project_id&&xe.push({label:u("archives.menu.removeFromProject"),icon:a.jsx(Rt,{className:"w-4 h-4"}),onClick:()=>Re.mutate(null),disabled:!x("archives","update",t.created_by_id)}),!s)xe.push({label:u("archives.menu.loading"),icon:a.jsx(at,{className:"w-4 h-4 animate-spin"}),onClick:()=>{},disabled:!0});else{const we=s.filter(qe=>qe.status==="active");we.length===0?xe.push({label:u("archives.menu.noProjectsAvailable"),icon:a.jsx(xs,{className:"w-4 h-4 opacity-50"}),onClick:()=>{},disabled:!0}):we.forEach(qe=>{xe.push({label:qe.name,icon:a.jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:qe.color||"#888"}}),onClick:()=>Re.mutate(qe.id),disabled:t.project_id===qe.id||!x("archives","update",t.created_by_id)})})}return xe})()},{label:u(n?"archives.menu.deselect":"archives.menu.select"),icon:n?a.jsx(co,{className:"w-4 h-4"}):a.jsx(Sl,{className:"w-4 h-4"}),onClick:()=>r(t.id)},{label:"",divider:!0,onClick:()=>{}},{label:u("archives.menu.delete"),icon:a.jsx(Yt,{className:"w-4 h-4"}),onClick:()=>k(!0),danger:!0,disabled:!x("archives","delete",t.created_by_id),title:x("archives","delete",t.created_by_id)?void 0:u("archives.permission.noDelete")}];return a.jsxs(St,{"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:pe,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:xe=>{xe.stopPropagation(),r(t.id)},children:n?a.jsx(co,{className:"w-5 h-5 text-bambu-green"}):a.jsx(Sl,{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:()=>Le(!0),onMouseLeave:()=>Le(!1),children:[t.thumbnail_path?a.jsx("img",{src:ce!==null&&re.length>0?J.getArchivePlateThumbnail(t.id,re[Fe]?.index??0):J.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(eu,{className:"w-12 h-12 text-bambu-dark-tertiary"})}),ue&&re.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:xe=>{xe.stopPropagation(),Ce(we=>{const qe=we??0;return qe>0?qe-1:re.length-1})},title:u("archives.card.previousPlate"),children:a.jsx(Yl,{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:xe=>{xe.stopPropagation(),Ce(we=>{const qe=we??0;return qe<re.length-1?qe+1:0})},title:u("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:re.map((xe,we)=>a.jsx("button",{className:`w-2 h-2 rounded-full transition-colors ${we===Fe?"bg-bambu-green":"bg-white/50 hover:bg-white/80"}`,onClick:qe=>{qe.stopPropagation(),Ce(we)},title:xe.name||u("archives.card.plateNumber",{index:xe.index})},xe.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:xe=>{xe.stopPropagation();const we=xe.currentTarget.getBoundingClientRect();se({x:we.left,y:we.bottom+4})},title:u("archives.card.moreOptions"),children:a.jsx(Mh,{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:xe=>{xe.stopPropagation(),x("archives","update",t.created_by_id)&&ze.mutate()},disabled:!x("archives","update",t.created_by_id),title:x("archives","update",t.created_by_id)?t.is_favorite?u("archives.card.removeFromFavorites"):u("archives.card.addToFavorites"):u("archives.permission.noUpdateArchives"),children:a.jsx(Ef,{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"?u("archives.card.cancelled"):u("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:u("archives.card.duplicateTitle"),children:[a.jsx(Ql,{className:"w-3 h-3"}),u("archives.card.duplicate")]}),t.source_3mf_path&&a.jsx("button",{className:"absolute bottom-2 left-2 p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors",onClick:xe=>{xe.stopPropagation();const we=(t.print_name||t.filename||"source").replace(/\.gcode\.3mf$/i,"")+"_source";vh(t.id,we,"source",c)},title:u("archives.card.openSource3mf"),children:a.jsx(y1,{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:xe=>{xe.stopPropagation(),J.downloadF3d(t.id).catch(we=>{console.error("F3D download failed:",we)})},title:u("archives.card.downloadF3d"),children:a.jsx(ei,{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:xe=>{xe.stopPropagation(),y(!0)},title:u("archives.card.preview3d"),children:a.jsx(ri,{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:xe=>{xe.stopPropagation(),M(!0)},title:u("archives.card.viewTimelapse"),children:a.jsx(Ph,{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:xe=>{xe.stopPropagation(),z(!0)},title:t.photos.length===1?u("archives.card.viewPhoto"):u("archives.card.viewPhotos",{count:t.photos.length}),children:[a.jsx(db,{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})]}),$e&&$e.length>0&&a.jsx(Ys,{to:`/files?folder=${$e[0].id}`,className:"absolute bottom-2 p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors",onClick:xe=>xe.stopPropagation(),title:u("archives.card.openFolder",{name:$e[0].name}),style:{left:t.source_3mf_path?t.f3d_path?"5.5rem":"3rem":t.f3d_path?"3rem":"0.5rem"},children:a.jsx(Jl,{className:"w-4 h-4 text-yellow-400"})})]}),a.jsxs(Nt,{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(Me,{variant:"ghost",size:"sm",className:"p-1 sm:p-1.5 shrink-0",onClick:()=>C(!0),disabled:!x("archives","update",t.created_by_id),title:x("archives","update",t.created_by_id)?u("archives.card.edit"):u("archives.card.noPermissionEdit"),children:a.jsx(Ga,{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 ${yh(t.filename)?"bg-bambu-green/20 text-bambu-green":"bg-orange-500/20 text-orange-400"}`,title:yh(t.filename)?u("archives.card.slicedFile"):u("archives.card.sourceFile"),children:yh(t.filename)?u("archives.card.gcode"):u("archives.card.source")}),t.project_name&&a.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded-full truncate max-w-[120px]",style:{backgroundColor:`${s?.find(xe=>xe.id===t.project_id)?.color||"#6b7280"}20`,color:s?.find(xe=>xe.id===t.project_id)?.color||"#6b7280"},title:u("archives.card.project",{name:t.project_name}),children:t.project_name})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs mb-4 min-h-[48px]",children:[(t.print_time_seconds||t.actual_time_seconds)&&a.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",title:t.time_accuracy?`Estimated: ${Js(t.print_time_seconds||0)}
- Actual: ${Js(t.actual_time_seconds||0)}
- 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(qn,{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(fi,{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(Xhe,{className:"w-3 h-3"}),d,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(ri,{className:"w-3 h-3"}),t.total_layers&&a.jsx("span",{children:t.total_layers===1?u("archives.card.layer",{count:t.total_layers}):u("archives.card.layers",{count:t.total_layers})}),t.total_layers&&t.layer_height&&a.jsx("span",{className:"text-bambu-gray/50",children:"·"}),t.layer_height&&a.jsxs("span",{children:[t.layer_height,"mm"]})]}),t.object_count!=null&&t.object_count>0&&a.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",title:t.object_count===1?u("archives.card.object",{count:t.object_count}):u("archives.card.objects",{count:t.object_count}),children:[a.jsx(ei,{className:"w-3 h-3"}),t.object_count===1?u("archives.card.object",{count:t.object_count}):u("archives.card.objects",{count:t.object_count})]}),t.sliced_for_model&&a.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",title:u("archives.card.slicedFor",{model:t.sliced_for_model}),children:[a.jsx(Nr,{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((xe,we)=>a.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:xe},title:xe},we))})]})]}),(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(TX,{className:"w-3 h-3"})}),t.tags?.split(",").map((xe,we)=>a.jsx("span",{className:"px-1.5 py-0.5 bg-bambu-dark-tertiary text-bambu-gray-light rounded text-xs",children:xe.trim()},we))]}),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:Df(t.created_at,l)}),a.jsxs("div",{className:"flex items-center gap-2",children:[t.created_by_username&&a.jsxs("span",{className:"flex items-center gap-1",title:u("archives.card.uploadedBy",{name:t.created_by_username}),children:[a.jsx(nu,{className:"w-3 h-3"}),t.created_by_username]}),a.jsx("span",{children:hl(t.file_size)})]})]}),a.jsxs("div",{className:"flex gap-1 mt-3",children:[yh(t.filename)?a.jsxs(a.Fragment,{children:[a.jsxs(Me,{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:u("archives.card.noPermissionReprint"):u("archives.card.noFileForReprint"),children:[a.jsx(Nr,{className:"w-3 h-3 flex-shrink-0"}),a.jsx("span",{className:"hidden sm:inline",children:u("archives.card.reprint")})]}),a.jsxs(Me,{variant:"secondary",size:"sm",className:"flex-1 min-w-0",onClick:()=>H(!0),disabled:!t.file_path||!p("queue:create"),title:t.file_path?p("queue:create")?u("archives.card.schedulePrint"):u("archives.permission.noAddToQueue"):u("archives.card.noFileForReprint"),children:[a.jsx(da,{className:"w-3 h-3 flex-shrink-0"}),a.jsx("span",{className:"hidden sm:inline",children:u("archives.card.schedule")})]}),a.jsx(Me,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const xe=t.print_name||t.filename||"model";vh(t.id,xe,"file",c)},title:u("archives.card.openInBambuStudio"),children:a.jsx(ta,{className:"w-3 h-3 sm:w-4 sm:h-4"})})]}):a.jsxs(Me,{variant:"primary",size:"sm",className:"flex-1 min-w-0",onClick:()=>{const xe=t.print_name||t.filename||"model";vh(t.id,xe,"file",c)},title:u("archives.card.openInBambuStudioToSlice"),children:[a.jsx(ta,{className:"w-3 h-3 flex-shrink-0"}),a.jsx("span",{className:"hidden sm:inline",children:u("archives.card.slice")})]}),a.jsx(Me,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const xe=t.external_url||t.makerworld_url;xe&&window.open(xe,"_blank")},disabled:!t.external_url&&!t.makerworld_url,title:t.external_url?u("archives.card.externalLink"):t.makerworld_url?u("archives.card.makerWorld",{designer:t.designer||u("archives.card.viewProject")}):u("archives.card.noExternalLink"),children:a.jsx(Eh,{className:`w-3 h-3 sm:w-4 sm:h-4 ${!t.external_url&&!t.makerworld_url?"opacity-20":""}`})}),a.jsx(Me,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{J.downloadArchive(t.id,`${t.print_name||t.filename}.3mf`).catch(xe=>{console.error("Archive download failed:",xe)})},title:u("archives.card.download"),children:a.jsx(ga,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),a.jsx(Me,{variant:"ghost",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>k(!0),disabled:!x("archives","delete",t.created_by_id),title:x("archives","delete",t.created_by_id)?u("archives.card.delete"):u("archives.card.noPermissionDelete"),children:a.jsx(Yt,{className:"w-3 h-3 sm:w-4 sm:h-4 text-red-400"})})]})]}),P&&a.jsx(Ane,{archive:t,onClose:()=>C(!1)}),g&&a.jsx(bO,{archiveId:t.id,title:t.print_name||t.filename,fileType:Sie(t.filename),onClose:()=>y(!1)}),_&&a.jsx(Yd,{mode:"reprint",archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>N(!1)}),A&&a.jsx(xn,{title:u("archives.modal.deleteArchive"),message:u("archives.modal.deleteConfirm",{name:t.print_name||t.filename}),confirmText:u("archives.modal.deleteButton"),variant:"danger",onConfirm:()=>{Ue.mutate(),k(!1)},onCancel:()=>k(!1)}),X&&a.jsx(xn,{title:u("archives.modal.removeSource3mf"),message:u("archives.modal.removeSource3mfConfirm",{name:t.print_name||t.filename}),confirmText:u("archives.modal.removeButton"),variant:"danger",onConfirm:()=>{R.mutate(),Z(!1)},onCancel:()=>Z(!1)}),ee&&a.jsx(xn,{title:u("archives.modal.removeF3d"),message:u("archives.modal.removeF3dConfirm",{name:t.print_name||t.filename}),confirmText:u("archives.modal.removeButton"),variant:"danger",onConfirm:()=>{de.mutate(),Se(!1)},onCancel:()=>Se(!1)}),oe&&a.jsx(xn,{title:u("archives.modal.removeTimelapse"),message:u("archives.modal.removeTimelapseConfirm",{name:t.print_name||t.filename}),confirmText:u("archives.modal.removeButton"),variant:"danger",onConfirm:()=>{Pe.mutate(),ie(!1)},onCancel:()=>ie(!1)}),me&&a.jsx(Tne,{x:me.x,y:me.y,items:Ne,onClose:()=>se(null)}),j&&t.timelapse_path&&a.jsx(wie,{src:J.getArchiveTimelapse(t.id),title:u("archives.modal.timelapse",{name:t.print_name||t.filename}),downloadFilename:`${t.print_name||t.filename}_timelapse.mp4`,archiveId:t.id,onClose:()=>M(!1),onEdit:()=>{h.invalidateQueries({queryKey:["archives"]}),M(!1)}}),E&&L.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:u("archives.modal.selectTimelapse")}),a.jsx("p",{className:"text-sm text-gray-400 mt-1",children:u("archives.modal.selectTimelapseDesc")})]}),a.jsx("button",{onClick:()=>{B(!1),U([])},className:"text-gray-400 hover:text-white p-1",children:a.jsx(Rt,{className:"w-5 h-5"})})]}),a.jsx("div",{className:"overflow-y-auto flex-1 p-2",children:L.map(xe=>a.jsxs("button",{onClick:()=>ae.mutate(xe.name),disabled:ae.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(Ph,{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:xe.name}),a.jsxs("p",{className:"text-sm text-gray-400",children:[hl(xe.size),xe.mtime&&` • ${Df(xe.mtime,l)}`]})]})]},xe.name))}),a.jsx("div",{className:"p-4 border-t border-gray-700",children:a.jsx(Me,{variant:"secondary",onClick:()=>{B(!1),U([])},className:"w-full",children:"Cancel"})})]})}),D&&a.jsx(Mne,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>$(!1)}),q&&t.photos&&t.photos.length>0&&a.jsx(Pne,{archiveId:t.id,archiveName:t.print_name||t.filename,photos:t.photos,onClose:()=>z(!1),onDelete:async xe=>{try{await J.deleteArchivePhoto(t.id,xe),h.invalidateQueries({queryKey:["archives"]}),f(u("archives.toast.photoDeleted"))}catch{f(u("archives.toast.failedDeletePhoto"),"error")}}}),W&&a.jsx(vie,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>Q(!1)}),te&&a.jsx(Yd,{mode:"add-to-queue",archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>H(!1)}),a.jsx("input",{ref:V,type:"file",accept:".3mf",className:"hidden",onChange:xe=>{const we=xe.target.files?.[0];we&&O.mutate(we),xe.target.value=""}}),a.jsx("input",{ref:K,type:"file",accept:".f3d",className:"hidden",onChange:xe=>{const we=xe.target.files?.[0];we&&G.mutate(we),xe.target.value=""}}),a.jsx("input",{ref:fe,type:"file",accept:".mp4,.avi,.mkv",className:"hidden",onChange:xe=>{const we=xe.target.files?.[0];we&&be.mutate(we),xe.target.value=""}})]})}function pYe({archive:t,printerName:e,isSelected:n,onSelect:r,selectionMode:i,projects:s,isHighlighted:o,preferredSlicer:l="bambu_studio",t:c}){const d=Qt(),{showToast:u}=dn(),{hasPermission:h,canModify:f}=jr(),[p,x]=w.useState(!1),[v,g]=w.useState(!1),[y,_]=w.useState(!1),[N,A]=w.useState(!1),[k,P]=w.useState(!1),[C,j]=w.useState(!1),[M,E]=w.useState(!1),[B,L]=w.useState([]),[U,D]=w.useState(!1),[$,q]=w.useState(!1),[z,W]=w.useState(!1),[Q,te]=w.useState(!1),[H,X]=w.useState(!1),[Z,ee]=w.useState(!1),[Se,oe]=w.useState(null),ie=w.useRef(null),me=w.useRef(null),se=w.useRef(null),ce=st({mutationFn:()=>J.deleteArchiveTimelapse(t.id),onSuccess:()=>{d.invalidateQueries({queryKey:["archives"]}),u(c("archives.toast.timelapseRemoved"))},onError:G=>{u(G.message||c("archives.toast.failedRemoveTimelapse"),"error")}}),Ce=st({mutationFn:G=>J.uploadArchiveTimelapse(t.id,G),onSuccess:G=>{d.invalidateQueries({queryKey:["archives"]}),u(c("archives.toast.timelapseUploaded",{filename:G.filename}))},onError:G=>{u(G.message||c("archives.toast.failedUploadTimelapse"),"error")}}),le=st({mutationFn:G=>J.uploadSource3mf(t.id,G),onSuccess:G=>{d.invalidateQueries({queryKey:["archives"]}),u(c("archives.toast.source3mfAttached",{filename:G.filename}))},onError:G=>{u(G.message||c("archives.toast.failedUploadSource3mf"),"error")}}),Le=st({mutationFn:()=>J.deleteSource3mf(t.id),onSuccess:()=>{d.invalidateQueries({queryKey:["archives"]}),u(c("archives.toast.source3mfRemoved"))},onError:G=>{u(G.message||c("archives.toast.failedRemoveSource3mf"),"error")}}),V=st({mutationFn:G=>J.uploadF3d(t.id,G),onSuccess:G=>{d.invalidateQueries({queryKey:["archives"]}),u(c("archives.toast.f3dAttached",{filename:G.filename}))},onError:G=>{u(G.message||c("archives.toast.failedUploadF3d"),"error")}}),K=st({mutationFn:()=>J.deleteF3d(t.id),onSuccess:()=>{d.invalidateQueries({queryKey:["archives"]}),u(c("archives.toast.f3dRemoved"))},onError:G=>{u(G.message||c("archives.toast.failedRemoveF3d"),"error")}}),fe=st({mutationFn:()=>J.scanArchiveTimelapse(t.id),onSuccess:G=>{G.status==="attached"?(d.invalidateQueries({queryKey:["archives"]}),u(c("archives.toast.timelapseAttached",{filename:G.filename}))):G.status==="exists"?u(c("archives.toast.timelapseAlreadyAttached")):G.status==="not_found"&&G.available_files&&G.available_files.length>0?(L(G.available_files),E(!0)):u(G.message||c("archives.toast.noMatchingTimelapse"),"warning")},onError:G=>{u(G.message||c("archives.toast.failedScanTimelapse"),"error")}}),Y=st({mutationFn:G=>J.selectArchiveTimelapse(t.id,G),onSuccess:G=>{d.invalidateQueries({queryKey:["archives"]}),u(c("archives.toast.timelapseAttached",{filename:G.filename})),E(!1),L([])},onError:G=>{u(G.message||c("archives.toast.failedAttachTimelapse"),"error")}}),re=st({mutationFn:()=>J.deleteArchive(t.id),onSuccess:()=>{d.invalidateQueries({queryKey:["archives"]}),u(c("archives.toast.archiveDeleted"))},onError:()=>{u(c("archives.toast.failedDeleteArchive"),"error")}}),ue=st({mutationFn:()=>J.toggleFavorite(t.id),onSuccess:G=>{d.invalidateQueries({queryKey:["archives"]}),u(G.is_favorite?c("archives.toast.addedToFavorites"):c("archives.toast.removedFromFavorites"))}}),{data:Fe}=Ze({queryKey:["archive-folders",t.id],queryFn:()=>J.getLibraryFoldersByArchive(t.id)}),Pe=st({mutationFn:G=>J.updateArchive(t.id,{project_id:G}),onSuccess:()=>{d.invalidateQueries({queryKey:["archives"]}),d.invalidateQueries({queryKey:["projects"]}),u(c("archives.toast.projectUpdated"))},onError:()=>{u(c("archives.toast.failedUpdateProject"),"error")}}),be=G=>{G.preventDefault(),oe({x:G.clientX,y:G.clientY})},R=[...yh(t.filename)?[{label:c("archives.menu.print"),icon:a.jsx(Nr,{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(da,{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(ta,{className:"w-4 h-4"}),onClick:()=>{const G=t.print_name||t.filename||"model";vh(t.id,G,"file",l)},disabled:!t.file_path,title:t.file_path?void 0:c("archives.card.noFileForReprint")}]:[{label:c("archives.menu.slice"),icon:a.jsx(ta,{className:"w-4 h-4"}),onClick:()=>{const G=t.print_name||t.filename||"model";vh(t.id,G,"file",l)}}],{label:t.external_url?c("archives.menu.externalLink"):c("archives.menu.viewOnMakerWorld"),icon:a.jsx(Eh,{className:"w-4 h-4"}),onClick:()=>{const G=t.external_url||t.makerworld_url;G&&window.open(G,"_blank")},disabled:!t.external_url&&!t.makerworld_url},{label:"",divider:!0,onClick:()=>{}},{label:c("archives.menu.preview3d"),icon:a.jsx(ei,{className:"w-4 h-4"}),onClick:()=>P(!0)},{label:c("archives.menu.viewTimelapse"),icon:a.jsx(Ph,{className:"w-4 h-4"}),onClick:()=>j(!0),disabled:!t.timelapse_path},{label:c("archives.menu.scanForTimelapse"),icon:a.jsx(_1,{className:"w-4 h-4"}),onClick:()=>fe.mutate(),disabled:!t.printer_id||!!t.timelapse_path||fe.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(Oa,{className:"w-4 h-4"}),onClick:()=>se.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(Yt,{className:"w-4 h-4"}),onClick:()=>ee(!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(y1,{className:"w-4 h-4"}),onClick:()=>{t.source_3mf_path?J.downloadSource3mf(t.id).catch(G=>{console.error("Source 3MF download failed:",G)}):ie.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(Oa,{className:"w-4 h-4"}),onClick:()=>ie.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(Yt,{className:"w-4 h-4"}),onClick:()=>te(!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(ei,{className:"w-4 h-4"}),onClick:()=>me.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(ga,{className:"w-4 h-4"}),onClick:()=>{J.downloadF3d(t.id).catch(G=>{console.error("F3D download failed:",G)})}},{label:c("archives.menu.removeF3d"),icon:a.jsx(Yt,{className:"w-4 h-4"}),onClick:()=>X(!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(ga,{className:"w-4 h-4"}),onClick:()=>{J.downloadArchive(t.id,`${t.print_name||t.filename}.3mf`).catch(G=>{console.error("Archive download failed:",G)})},disabled:!h("archives:read"),title:h("archives:read")?void 0:c("archives.permission.noDownload")},{label:c("archives.menu.copyDownloadLink"),icon:a.jsx(Ql,{className:"w-4 h-4"}),onClick:()=>{const G=`${window.location.origin}${J.getArchiveDownload(t.id)}`;navigator.clipboard.writeText(G).then(()=>{u(c("archives.toast.linkCopied"))}).catch(()=>{u(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(kX,{className:"w-4 h-4"}),onClick:()=>D(!0)},{label:t.photos?.length?c("archives.menu.viewPhotosCount",{count:t.photos.length}):c("archives.menu.viewPhotos"),icon:a.jsx(db,{className:"w-4 h-4"}),onClick:()=>q(!0),disabled:!t.photos?.length},{label:c("archives.menu.projectPage"),icon:a.jsx(Ps,{className:"w-4 h-4"}),onClick:()=>W(!0)},{label:"",divider:!0,onClick:()=>{}},{label:t.is_favorite?c("archives.menu.removeFromFavorites"):c("archives.menu.addToFavorites"),icon:a.jsx(Ef,{className:`w-4 h-4 ${t.is_favorite?"fill-yellow-400 text-yellow-400":""}`}),onClick:()=>ue.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(Ga,{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 G=[];if(t.project_id&&G.push({label:c("archives.menu.removeFromProject"),icon:a.jsx(Rt,{className:"w-4 h-4"}),onClick:()=>Pe.mutate(null)}),!s)G.push({label:c("archives.menu.loading"),icon:a.jsx(at,{className:"w-4 h-4 animate-spin"}),onClick:()=>{},disabled:!0});else{const de=s.filter(ge=>ge.status==="active");de.length===0?G.push({label:c("archives.menu.noProjectsAvailable"),icon:a.jsx(xs,{className:"w-4 h-4 opacity-50"}),onClick:()=>{},disabled:!0}):de.forEach(ge=>{G.push({label:ge.name,icon:a.jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:ge.color||"#888"}}),onClick:()=>Pe.mutate(ge.id),disabled:t.project_id===ge.id})})}return G})()},{label:c(n?"archives.menu.deselect":"archives.menu.select"),icon:n?a.jsx(co,{className:"w-4 h-4"}):a.jsx(Sl,{className:"w-4 h-4"}),onClick:()=>r(t.id)},{label:"",divider:!0,onClick:()=>{}},{label:c("archives.menu.delete"),icon:a.jsx(Yt,{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:be,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(co,{className:"w-4 h-4 text-bambu-green"}):a.jsx(Sl,{className:"w-4 h-4 text-bambu-gray"})}),t.thumbnail_path?a.jsx("img",{src:J.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(eu,{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(Ph,{className:"w-3.5 h-3.5 text-bambu-green flex-shrink-0"})}),Fe&&Fe.length>0&&a.jsx(Ys,{to:`/files?folder=${Fe[0].id}`,className:"flex-shrink-0",title:c("archives.card.openFolder",{name:Fe[0].name}),onClick:G=>G.stopPropagation(),children:a.jsx(Jl,{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(Nr,{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((G,de)=>a.jsx("div",{className:"w-2.5 h-2.5 rounded-full border border-white/20",style:{backgroundColor:G},title:G},de))})]})]}),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:mb(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(nu,{className:"w-3 h-3"}),t.created_by_username]})]}),a.jsx("div",{className:"col-span-1 text-sm text-bambu-gray",children:hl(t.file_size)}),a.jsxs("div",{className:"col-span-2 flex justify-end gap-1",children:[yh(t.filename)&&a.jsx(Me,{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(oo,{className:"w-4 h-4"})}),a.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>{const G=t.print_name||t.filename||"model";vh(t.id,G,"file",l)},title:c("archives.card.openInBambuStudio"),children:a.jsx(ta,{className:"w-4 h-4"})}),(t.external_url||t.makerworld_url)&&a.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>window.open(t.external_url||t.makerworld_url,"_blank"),title:t.external_url?c("archives.card.externalLink"):"MakerWorld",children:a.jsx(Eh,{className:"w-4 h-4"})}),a.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>{J.downloadArchive(t.id,`${t.print_name||t.filename}.3mf`).catch(G=>{console.error("Archive download failed:",G)})},title:c("archives.card.download"),children:a.jsx(ga,{className:"w-4 h-4"})}),a.jsx(Me,{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(Ga,{className:"w-4 h-4"})}),a.jsx(Me,{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(Yt,{className:"w-4 h-4 text-red-400"})}),a.jsx(Me,{variant:"ghost",size:"sm",onClick:G=>{const de=G.currentTarget.getBoundingClientRect();oe({x:de.left,y:de.bottom+4})},title:c("archives.card.moreOptions"),children:a.jsx(Mh,{className:"w-4 h-4"})})]})]}),p&&a.jsx(Ane,{archive:t,onClose:()=>x(!1)}),k&&a.jsx(bO,{archiveId:t.id,title:t.print_name||t.filename,fileType:Sie(t.filename),onClose:()=>P(!1)}),y&&a.jsx(Yd,{mode:"reprint",archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>_(!1)}),v&&a.jsx(xn,{title:c("archives.modal.deleteArchive"),message:c("archives.modal.deleteConfirm",{name:t.print_name||t.filename}),confirmText:c("archives.modal.deleteButton"),variant:"danger",onConfirm:()=>{re.mutate(),g(!1)},onCancel:()=>g(!1)}),Q&&a.jsx(xn,{title:c("archives.modal.removeSource3mf"),message:c("archives.modal.removeSource3mfConfirm",{name:t.print_name||t.filename}),confirmText:c("archives.modal.removeButton"),variant:"danger",onConfirm:()=>{Le.mutate(),te(!1)},onCancel:()=>te(!1)}),H&&a.jsx(xn,{title:c("archives.modal.removeF3d"),message:c("archives.modal.removeF3dConfirm",{name:t.print_name||t.filename}),confirmText:c("archives.modal.removeButton"),variant:"danger",onConfirm:()=>{K.mutate(),X(!1)},onCancel:()=>X(!1)}),Z&&a.jsx(xn,{title:c("archives.modal.removeTimelapse"),message:c("archives.modal.removeTimelapseConfirm",{name:t.print_name||t.filename}),confirmText:c("archives.modal.removeButton"),variant:"danger",onConfirm:()=>{ce.mutate(),ee(!1)},onCancel:()=>ee(!1)}),Se&&a.jsx(Tne,{x:Se.x,y:Se.y,items:R,onClose:()=>oe(null)}),C&&t.timelapse_path&&a.jsx(wie,{src:J.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:()=>j(!1),onEdit:()=>{d.invalidateQueries({queryKey:["archives"]}),j(!1)}}),M&&B.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:()=>{E(!1),L([])},className:"text-gray-400 hover:text-white p-1",children:a.jsx(Rt,{className:"w-5 h-5"})})]}),a.jsx("div",{className:"overflow-y-auto flex-1 p-2",children:B.map(G=>a.jsxs("button",{onClick:()=>Y.mutate(G.name),disabled:Y.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:G.name}),a.jsxs("div",{className:"text-sm text-gray-400 flex gap-3",children:[a.jsx("span",{children:hl(G.size)}),G.mtime&&a.jsx("span",{children:mb(G.mtime)})]})]},G.name))})]})}),U&&a.jsx(Mne,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>D(!1)}),$&&t.photos&&a.jsx(Pne,{archiveId:t.id,archiveName:t.print_name||t.filename,photos:t.photos,onClose:()=>q(!1),onDelete:async G=>{try{await J.deleteArchivePhoto(t.id,G),d.invalidateQueries({queryKey:["archives"]}),u(c("archives.toast.photoDeleted"))}catch{u(c("archives.toast.failedDeletePhoto"),"error")}}}),z&&a.jsx(vie,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>W(!1)}),N&&a.jsx(Yd,{mode:"add-to-queue",archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>A(!1)}),a.jsx("input",{ref:ie,type:"file",accept:".3mf",className:"hidden",onChange:G=>{const de=G.target.files?.[0];de&&le.mutate(de),G.target.value=""}}),a.jsx("input",{ref:me,type:"file",accept:".f3d",className:"hidden",onChange:G=>{const de=G.target.files?.[0];de&&V.mutate(de),G.target.value=""}}),a.jsx("input",{ref:se,type:"file",accept:".mp4,.avi,.mkv",className:"hidden",onChange:G=>{const de=G.target.files?.[0];de&&Ce.mutate(de),G.target.value=""}})]})}const gYe=[{id:"all",label:"All Archives",icon:a.jsx(Jl,{className:"w-4 h-4"})},{id:"recent",label:"Last 24 Hours",icon:a.jsx(qn,{className:"w-4 h-4"})},{id:"this-week",label:"This Week",icon:a.jsx(da,{className:"w-4 h-4"})},{id:"this-month",label:"This Month",icon:a.jsx(da,{className:"w-4 h-4"})},{id:"favorites",label:"Favorites",icon:a.jsx(Ef,{className:"w-4 h-4"})},{id:"failed",label:"Failed Prints",icon:a.jsx(Va,{className:"w-4 h-4"})},{id:"duplicates",label:"Duplicates",icon:a.jsx(Ql,{className:"w-4 h-4"})}];function bYe(){const{t}=Dt(),e=Qt(),{showToast:n}=dn(),{hasPermission:r,hasAnyPermission:i}=jr(),s=w.useRef(null),[o,l]=w.useState(""),[c,d]=w.useState(()=>{const _e=localStorage.getItem("archiveFilterPrinter");return _e?Number(_e):null}),[u,h]=w.useState(()=>localStorage.getItem("archiveFilterMaterial")),[f,p]=w.useState(()=>{const _e=localStorage.getItem("archiveFilterColors");return _e?new Set(JSON.parse(_e)):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,k]=w.useState(()=>localStorage.getItem("archiveFilterTag")),[P,C]=w.useState(()=>localStorage.getItem("archiveFilterFileType")||"all"),[j,M]=w.useState(!1),[E,B]=w.useState([]),[L,U]=w.useState(!1),[D,$]=w.useState(new Set),[q,z]=w.useState(!1),[W,Q]=w.useState(!1),[te,H]=w.useState(!1),[X,Z]=w.useState(!1),[ee,Se]=w.useState(()=>localStorage.getItem("archiveViewMode")||"grid"),[oe,ie]=w.useState(()=>localStorage.getItem("archiveSortBy")||"date-desc"),[me,se]=w.useState(()=>localStorage.getItem("archiveCollection")||"all"),[ce,Ce]=w.useState(!1),[le,Le]=w.useState(!1),[V,K]=w.useState(!1),[fe,Y]=w.useState(!1),[re,ue]=w.useState(null),[Fe,Pe]=w.useState(()=>localStorage.getItem("logFilterUser")||null),[be,O]=w.useState(()=>localStorage.getItem("logFilterStatus")),[R,G]=w.useState(()=>localStorage.getItem("logFilterDateFrom")||""),[de,ge]=w.useState(()=>localStorage.getItem("logFilterDateTo")||""),[ae,Ue]=w.useState(()=>{const _e=localStorage.getItem("logOffset");return _e?Number(_e):0}),[ze,$e]=w.useState(!1),[Re,pe]=w.useState(()=>{const _e=localStorage.getItem("logPageSize");return _e?Number(_e):25});w.useEffect(()=>{if(re){const _e=setTimeout(()=>{const it=document.querySelector(`[data-archive-id="${re}"]`);it&&it.scrollIntoView({behavior:"smooth",block:"center"})},100),tt=setTimeout(()=>ue(null),5e3);return()=>{clearTimeout(_e),clearTimeout(tt)}}},[re]);const{data:ve,isLoading:Ne}=Ze({queryKey:["archives",c],queryFn:()=>J.getArchives(c||void 0)}),{data:xe}=Ze({queryKey:["printers"],queryFn:J.getPrinters}),{data:we}=Ze({queryKey:["projects"],queryFn:()=>J.getProjects()}),{data:qe}=Ze({queryKey:["settings"],queryFn:J.getSettings}),{data:ke}=Ze({queryKey:["users"],queryFn:J.getUsers,enabled:ee==="log"}),{data:nt,isLoading:De}=Ze({queryKey:["print-log",c,Fe,be,R,de,o,ae,Re],queryFn:()=>J.getPrintLog({search:o||void 0,printerId:c||void 0,username:Fe||void 0,status:be||void 0,dateFrom:R||void 0,dateTo:de||void 0,limit:Re,offset:ae}),enabled:ee==="log"}),We=qe?.time_format||"system",Oe=qe?.preferred_slicer||"bambu_studio",je=il(qe?.currency||"USD"),Ve=st({mutationFn:async _e=>(await Promise.all(_e.map(tt=>J.deleteArchive(tt))),_e.length),onSuccess:_e=>{e.invalidateQueries({queryKey:["archives"]}),$(new Set),n(`${_e} archive${_e!==1?"s":""} deleted`)},onError:()=>{n(t("archives.toast.failedDeleteArchives"),"error")}}),ot=st({mutationFn:()=>J.clearPrintLog(),onSuccess:_e=>{e.invalidateQueries({queryKey:["print-log"]}),Ue(0),n(t("archives.log.cleared",{count:_e.deleted}))},onError:()=>{n(t("archives.log.clearFailed"),"error")}});w.useEffect(()=>{c!==null?localStorage.setItem("archiveFilterPrinter",c.toString()):localStorage.removeItem("archiveFilterPrinter")},[c]),w.useEffect(()=>{u?localStorage.setItem("archiveFilterMaterial",u):localStorage.removeItem("archiveFilterMaterial")},[u]),w.useEffect(()=>{localStorage.setItem("archiveFilterColors",JSON.stringify([...f]))},[f]),w.useEffect(()=>{localStorage.setItem("archiveColorFilterMode",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",P)},[P]),w.useEffect(()=>{localStorage.setItem("archiveViewMode",ee)},[ee]),w.useEffect(()=>{localStorage.setItem("archiveSortBy",oe)},[oe]),w.useEffect(()=>{localStorage.setItem("archiveCollection",me)},[me]),w.useEffect(()=>{Fe?localStorage.setItem("logFilterUser",Fe):localStorage.removeItem("logFilterUser")},[Fe]),w.useEffect(()=>{be?localStorage.setItem("logFilterStatus",be):localStorage.removeItem("logFilterStatus")},[be]),w.useEffect(()=>{R?localStorage.setItem("logFilterDateFrom",R):localStorage.removeItem("logFilterDateFrom")},[R]),w.useEffect(()=>{de?localStorage.setItem("logFilterDateTo",de):localStorage.removeItem("logFilterDateTo")},[de]),w.useEffect(()=>{localStorage.setItem("logOffset",ae.toString())},[ae]),w.useEffect(()=>{localStorage.setItem("logPageSize",Re.toString())},[Re]);const kt=new Map(xe?.map(_e=>[_e.id,_e.name])||[]),Ft=[...new Set(ve?.flatMap(_e=>_e.filament_type?.split(", ")||[]).filter(Boolean)||[])].sort(),Vt=[...new Set(ve?.flatMap(_e=>_e.filament_color?.split(",")||[]).filter(Boolean)||[])],At=[...new Set(ve?.flatMap(_e=>_e.tags?.split(",").map(tt=>tt.trim())||[]).filter(Boolean)||[])].sort(),Be=ve?.filter(_e=>{const tt=new Date,it=tr(_e.created_at)||new Date(0);let Ke=!0;switch(me){case"recent":Ke=tt.getTime()-it.getTime()<1440*60*1e3;break;case"this-week":Ke=tt.getTime()-it.getTime()<10080*60*1e3;break;case"this-month":Ke=it.getMonth()===tt.getMonth()&&it.getFullYear()===tt.getFullYear();break;case"favorites":Ke=_e.is_favorite===!0;break;case"failed":Ke=_e.status==="failed"||_e.status==="aborted";break;case"duplicates":Ke=_e.duplicate_count>0;break}const Lt=(_e.print_name||_e.filename).toLowerCase().includes(o.toLowerCase()),ye=!u||_e.filament_type?.split(", ").includes(u),He=_e.filament_color?.split(",")||[],Ye=f.size===0||(x==="or"?He.some(Bt=>f.has(Bt)):[...f].every(Bt=>He.includes(Bt))),Xe=me==="favorites"||!g||_e.is_favorite,Te=me==="failed"||!_||_e.status!=="failed"&&_e.status!=="aborted",ct=_e.tags?.split(",").map(Bt=>Bt.trim())||[],gt=!A||ct.includes(A),lt=yh(_e.filename);return Ke&&Lt&&ye&&Ye&&Xe&&Te&>&&(P==="all"||P==="gcode"&<||P==="source"&&!lt)}).sort((_e,tt)=>{switch(oe){case"date-desc":return(tr(tt.created_at)?.getTime()||0)-(tr(_e.created_at)?.getTime()||0);case"date-asc":return(tr(_e.created_at)?.getTime()||0)-(tr(tt.created_at)?.getTime()||0);case"name-asc":return(_e.print_name||_e.filename).localeCompare(tt.print_name||tt.filename);case"name-desc":return(tt.print_name||tt.filename).localeCompare(_e.print_name||_e.filename);case"size-desc":return tt.file_size-_e.file_size;case"size-asc":return _e.file_size-tt.file_size;default:return 0}}),mt=q||D.size>0,yt=_e=>{$(tt=>{const it=new Set(tt);return it.has(_e)?it.delete(_e):it.add(_e),it})},zt=()=>{Be&&$(new Set(Be.map(_e=>_e.id)))},yn=()=>{$(new Set),z(!1)},gr=_e=>{p(tt=>{const it=new Set(tt);return it.has(_e)?it.delete(_e):it.add(_e),it})},sr=()=>{p(new Set)},nr=()=>{l(""),d(null),h(null),y(!1),N(!1),k(null),C("all")},Gn=o||c||u||g||_||A||P!=="all",br=w.useCallback(_e=>{_e.preventDefault(),_e.dataTransfer.types.includes("Files")&&U(!0)},[]),or=w.useCallback(_e=>{_e.preventDefault(),_e.currentTarget===_e.target&&U(!1)},[]),oi=w.useCallback(_e=>{_e.preventDefault(),U(!1);const tt=Array.from(_e.dataTransfer.files).filter(it=>it.name.endsWith(".3mf"));tt.length>0?(B(tt),M(!0)):_e.dataTransfer.files.length>0&&n(t("archives.page.only3mfSupported"),"warning")},[n,t]),Ie=w.useCallback(_e=>{const tt=_e.target;if(tt.tagName==="INPUT"||tt.tagName==="TEXTAREA"||tt.isContentEditable){_e.key==="Escape"&&tt.blur();return}switch(_e.key){case"/":_e.preventDefault(),s.current?.focus();break;case"u":case"U":!_e.metaKey&&!_e.ctrlKey&&(_e.preventDefault(),M(!0));break;case"Escape":mt&&yn();break}},[mt]);return w.useEffect(()=>(document.addEventListener("keydown",Ie),()=>document.removeEventListener("keydown",Ie)),[Ie]),a.jsxs("div",{className:"p-4 md:p-8 relative min-h-full",onDragOver:br,onDragLeave:or,onDrop:oi,children:[L&&a.jsx("div",{className:"fixed inset-0 z-50 bg-bambu-dark/90 flex items-center justify-center pointer-events-none",children:a.jsxs("div",{className:"border-4 border-dashed border-bambu-green rounded-xl p-12 text-center",children:[a.jsx(Oa,{className:"w-16 h-16 mx-auto mb-4 text-bambu-green"}),a.jsx("p",{className:"text-2xl font-semibold text-white mb-2",children:"Drop .3mf files here"}),a.jsx("p",{className:"text-bambu-gray",children:t("archives.releaseToUpload")})]})}),mt&&a.jsxs("div",{className:"fixed bottom-6 left-1/2 -translate-x-1/2 z-40 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl px-4 py-3 flex items-center gap-4",children:[a.jsxs(Me,{variant:"secondary",size:"sm",onClick:yn,children:[a.jsx(Rt,{className:"w-4 h-4"}),"Close"]}),a.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),a.jsxs("span",{className:"text-white font-medium",children:[D.size," selected"]}),a.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),a.jsx(Me,{variant:"secondary",size:"sm",onClick:zt,children:"Select All"}),a.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),a.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>H(!0),disabled:!i("archives:update_own","archives:update_all"),title:i("archives:update_own","archives:update_all")?void 0:t("archives.permission.noUpdateArchives"),children:[a.jsx(qh,{className:"w-4 h-4"}),"Tags"]}),a.jsxs(Me,{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(xs,{className:"w-4 h-4"}),"Project"]}),a.jsxs(Me,{variant:"secondary",size:"sm",disabled:!i("archives:update_own","archives:update_all"),title:i("archives:update_own","archives:update_all")?void 0:t("archives.permission.noUpdateArchives"),onClick:()=>{const _e=Array.from(D);Promise.all(_e.map(tt=>J.toggleFavorite(tt))).then(()=>{e.invalidateQueries({queryKey:["archives"]}),n(`Toggled favorites for ${_e.length} archive${_e.length!==1?"s":""}`)}).catch(()=>{n(t("archives.toast.failedUpdateFavorites"),"error")})},children:[a.jsx(Ef,{className:"w-4 h-4"}),"Favorite"]}),a.jsxs(Me,{size:"sm",className:"bg-red-500 hover:bg-red-600",onClick:()=>Q(!0),disabled:!i("archives:delete_own","archives:delete_all"),title:i("archives:delete_own","archives:delete_all")?void 0:t("archives.permission.noDelete"),children:[a.jsx(Yt,{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:me,onChange:_e=>se(_e.target.value),children:gYe.map(_e=>a.jsx("option",{value:_e.id,children:_e.label},_e.id))})]}),a.jsxs("p",{className:"text-bambu-gray",children:[Be?.length||0," of ",ve?.length||0," prints"]})]}),a.jsxs("div",{className:"flex items-center gap-2 sm:gap-3 flex-wrap",children:[a.jsxs("div",{className:"relative",children:[a.jsxs(Me,{variant:"secondary",onClick:()=>Ce(!ce),disabled:le,children:[le?a.jsx(at,{className:"w-4 h-4 animate-spin"}):a.jsx(v1,{className:"w-4 h-4"}),"Export"]}),ce&&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()=>{Ce(!1),Le(!0);try{const{blob:_e,filename:tt}=await J.exportArchives({format:"csv",printerId:c||void 0,status:me==="failed"?"failed":void 0,search:o||void 0}),it=URL.createObjectURL(_e),Ke=document.createElement("a");Ke.href=it,Ke.download=tt,Ke.click(),URL.revokeObjectURL(it),n(t("archives.toast.exportDownloaded"))}catch{n(t("archives.toast.exportFailed"),"error")}finally{Le(!1)}},children:[a.jsx(Ps,{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()=>{Ce(!1),Le(!0);try{const{blob:_e,filename:tt}=await J.exportArchives({format:"xlsx",printerId:c||void 0,status:me==="failed"?"failed":void 0,search:o||void 0}),it=URL.createObjectURL(_e),Ke=document.createElement("a");Ke.href=it,Ke.download=tt,Ke.click(),URL.revokeObjectURL(it),n(t("archives.toast.exportDownloaded"))}catch{n(t("archives.toast.exportFailed"),"error")}finally{Le(!1)}},children:[a.jsx(v1,{className:"w-4 h-4"}),"Export as Excel"]})]})]}),D.size>=2&&D.size<=5&&a.jsxs(Me,{variant:"secondary",onClick:()=>K(!0),children:[a.jsx(Gg,{className:"w-4 h-4"}),"Compare (",D.size,")"]}),!mt&&a.jsxs(Me,{variant:"secondary",onClick:()=>z(!0),children:[a.jsx(co,{className:"w-4 h-4"}),"Select"]}),a.jsxs(Me,{onClick:()=>M(!0),disabled:!r("archives:create"),title:r("archives:create")?void 0:t("archives.permission.noCreate"),children:[a.jsx(Oa,{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 ${ee==="grid"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>Se("grid"),title:t("archives.gridView"),children:a.jsx(uv,{className:"w-4 h-4"})}),a.jsx("button",{className:`p-2 ${ee==="list"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>Se("list"),title:t("archives.listView"),children:a.jsx(GC,{className:"w-4 h-4"})}),a.jsx("button",{className:`p-2 ${ee==="calendar"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>Se("calendar"),title:t("archives.calendarView"),children:a.jsx(phe,{className:"w-4 h-4"})}),a.jsx("button",{className:`p-2 ${ee==="log"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>Se("log"),title:t("archives.logView"),children:a.jsx(Ihe,{className:"w-4 h-4"})})]}),ee!=="log"&&a.jsx(St,{className:"mb-6",children:a.jsxs(Nt,{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:_e=>l(_e.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(VC,{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:_e=>d(_e.target.value?Number(_e.target.value):null),children:[a.jsx("option",{value:"",children:"All Printers"}),xe?.map(_e=>a.jsx("option",{value:_e.id,children:_e.name},_e.id))]})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[a.jsx(fi,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),a.jsxs("select",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:u||"",onChange:_e=>h(_e.target.value||null),children:[a.jsx("option",{value:"",children:"All Materials"}),Ft.map(_e=>a.jsx("option",{value:_e,children:_e},_e))]})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[a.jsx(y1,{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:P,onChange:_e=>C(_e.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(Ef,{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(Va,{className:"w-4 h-4 "}),a.jsx("span",{className:"text-sm hidden md:inline",children:"Hide Failed"})]}),At.length>0&&a.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[a.jsx(qh,{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:_e=>k(_e.target.value||null),children:[a.jsx("option",{value:"",children:"All Tags"}),At.map(_e=>a.jsx("option",{value:_e,children:_e},_e))]}),a.jsx("button",{onClick:()=>Y(!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(ZC,{className:"w-4 h-4"})})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[a.jsx(kF,{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:oe,onChange:_e=>ie(_e.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(Me,{variant:"ghost",size:"sm",onClick:nr,className:"text-bambu-gray hover:text-white",children:[a.jsx(Rt,{className:"w-4 h-4"}),"Reset"]})]}),Vt.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(_e=>_e==="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:Vt.map(_e=>a.jsx("button",{onClick:()=>gr(_e),className:`w-6 h-6 rounded-full border-2 transition-all ${f.has(_e)?"border-bambu-green scale-110":"border-white/20 hover:border-white/40"}`,style:{backgroundColor:_e},title:_e},_e))}),f.size>0&&a.jsxs("button",{onClick:sr,className:"text-xs text-bambu-gray hover:text-white flex items-center gap-1",children:[a.jsx(Rt,{className:"w-3 h-3"}),"Clear"]})]})]})}),a.jsx(hYe,{}),Ne?a.jsx("div",{className:"text-center py-12 text-bambu-gray",children:t("archives.loadingArchives")}):Be?.length===0?a.jsx(St,{children:a.jsxs(Nt,{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"})]})}):ee==="calendar"?a.jsx(St,{className:"p-6",children:a.jsx(rVe,{archives:Be||[],onArchiveClick:_e=>{l(""),Se("grid"),ue(_e.id)},highlightedArchiveId:re})}):ee==="grid"?a.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:Be?.map(_e=>a.jsx(fYe,{archive:_e,printerName:_e.printer_id?kt.get(_e.printer_id)||"Unknown":_e.sliced_for_model?`Sliced for ${_e.sliced_for_model}`:"No Printer",isSelected:D.has(_e.id),onSelect:yt,selectionMode:mt,projects:we,isHighlighted:_e.id===re,timeFormat:We,preferredSlicer:Oe,currency:je,t},_e.id))}):ee==="list"?a.jsx(St,{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"})]}),Be?.map(_e=>a.jsx(pYe,{archive:_e,printerName:_e.printer_id?kt.get(_e.printer_id)||"Unknown":_e.sliced_for_model?`Sliced for ${_e.sliced_for_model}`:"No Printer",isSelected:D.has(_e.id),onSelect:yt,selectionMode:mt,projects:we,isHighlighted:_e.id===re,preferredSlicer:Oe,t},_e.id))]})}):ee==="log"?a.jsxs("div",{className:"space-y-4",children:[a.jsx(St,{children:a.jsx(Nt,{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:_e=>{l(_e.target.value),Ue(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:_e=>{d(_e.target.value?Number(_e.target.value):null),Ue(0)},children:[a.jsx("option",{value:"",children:t("archives.log.allPrinters")}),xe?.map(_e=>a.jsx("option",{value:_e.id,children:_e.name},_e.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:Fe||"",onChange:_e=>{Pe(_e.target.value||null),Ue(0)},children:[a.jsx("option",{value:"",children:t("archives.log.allUsers")}),ke?.map(_e=>a.jsx("option",{value:_e.username,children:_e.username},_e.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:be||"",onChange:_e=>{O(_e.target.value||null),Ue(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:R,onChange:_e=>{G(_e.target.value),Ue(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:de,onChange:_e=>{ge(_e.target.value),Ue(0)}})]}),a.jsx("div",{className:"ml-auto",children:a.jsxs(Me,{variant:"danger",size:"sm",onClick:()=>$e(!0),disabled:!r("archives:delete_all")||ot.isPending,children:[a.jsx(Yt,{className:"w-4 h-4"}),t("archives.log.clearLog")]})})]})})}),a.jsx(St,{children:De?a.jsx("div",{className:"flex items-center justify-center py-12",children:a.jsx(at,{className:"w-6 h-6 animate-spin text-bambu-green"})}):nt?.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:nt.items.map(_e=>a.jsxs("tr",{className:"hover:bg-bambu-dark-secondary/50",children:[a.jsx("td",{className:"px-4 py-3 text-white whitespace-nowrap",children:Df(_e.started_at||_e.created_at,We)}),a.jsx("td",{className:"px-4 py-3",children:a.jsxs("div",{className:"flex items-center gap-2",children:[_e.thumbnail_path&&a.jsx("img",{src:J.getPrintLogThumbnail(_e.id),alt:"",className:"w-8 h-8 rounded object-cover flex-shrink-0",onError:tt=>{tt.target.style.display="none"}}),a.jsx("span",{className:"text-white truncate max-w-[200px]",children:_e.print_name||"—"})]})}),a.jsx("td",{className:"px-4 py-3 text-bambu-gray-light",children:_e.printer_name||"—"}),a.jsx("td",{className:"px-4 py-3 text-bambu-gray-light",children:_e.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 ${_e.status==="completed"?"bg-green-500/20 text-green-400":_e.status==="failed"?"bg-red-500/20 text-red-400":_e.status==="stopped"?"bg-yellow-500/20 text-yellow-400":_e.status==="cancelled"?"bg-orange-500/20 text-orange-400":_e.status==="skipped"?"bg-blue-500/20 text-blue-400":"bg-gray-500/20 text-gray-400"}`,children:_e.status})}),a.jsx("td",{className:"px-4 py-3 text-bambu-gray-light whitespace-nowrap",children:_e.duration_seconds?Js(_e.duration_seconds):"—"}),a.jsx("td",{className:"px-4 py-3",children:a.jsxs("div",{className:"flex items-center gap-1.5",children:[_e.filament_color&&a.jsx("span",{className:"w-3 h-3 rounded-full border border-white/20 flex-shrink-0",style:{backgroundColor:_e.filament_color.startsWith("#")?_e.filament_color:void 0}}),a.jsx("span",{className:"text-bambu-gray-light text-xs",children:_e.filament_type||"—"})]})})]},_e.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(ae+Re,nt.total),total:nt.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:Re,onChange:_e=>{pe(Number(_e.target.value)),Ue(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(ae/Re)+1," / ",Math.max(1,Math.ceil(nt.total/Re))]}),a.jsx(Me,{variant:"secondary",size:"sm",onClick:()=>Ue(Math.max(0,ae-Re)),disabled:ae===0,children:a.jsx(Yl,{className:"w-4 h-4"})}),a.jsx(Me,{variant:"secondary",size:"sm",onClick:()=>Ue(ae+Re),disabled:ae+Re>=nt.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,j&&a.jsx(K$e,{onClose:()=>{M(!1),B([])},initialFiles:E}),W&&a.jsx(xn,{title:t("archives.modal.deleteArchives"),message:t("archives.modal.deleteArchivesConfirm",{count:D.size}),confirmText:t("archives.modal.deleteCount",{count:D.size}),variant:"danger",onConfirm:()=>{Ve.mutate(Array.from(D)),Q(!1)},onCancel:()=>Q(!1)}),te&&a.jsx(Q$e,{selectedIds:Array.from(D),existingTags:At,onClose:()=>H(!1)}),X&&a.jsx(Z$e,{selectedIds:Array.from(D),onClose:()=>Z(!1)}),V&&D.size>=2&&D.size<=5&&a.jsx(lYe,{archiveIds:Array.from(D),onClose:()=>{K(!1),$(new Set),z(!1)}}),fe&&a.jsx(mYe,{onClose:()=>Y(!1)}),ze&&a.jsx(xn,{title:t("archives.log.clearLogTitle"),message:t("archives.log.clearLogConfirm"),confirmText:t("archives.log.clearLogButton"),variant:"danger",onConfirm:()=>{ot.mutate(),$e(!1)},onCancel:()=>$e(!1)})]})}function xYe(){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 _A=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function cx(t){const e=Object.prototype.toString.call(t);return e==="[object Window]"||e==="[object global]"}function iI(t){return"nodeType"in t}function mo(t){var e,n;return t?cx(t)?t:iI(t)&&(e=(n=t.ownerDocument)==null?void 0:n.defaultView)!=null?e:window:window}function sI(t){const{Document:e}=mo(t);return t instanceof e}function Vv(t){return cx(t)?!1:t instanceof mo(t).HTMLElement}function _ie(t){return t instanceof mo(t).SVGElement}function dx(t){return t?cx(t)?t.document:iI(t)?sI(t)?t:Vv(t)||_ie(t)?t.ownerDocument:document:document:document}const Vc=_A?w.useLayoutEffect:w.useEffect;function oI(t){const e=w.useRef(t);return Vc(()=>{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 yYe(){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 tv(t,e){e===void 0&&(e=[t]);const n=w.useRef(t);return Vc(()=>{n.current!==t&&(n.current=t)},e),n}function qv(t,e){const n=w.useRef();return w.useMemo(()=>{const r=t(n.current);return n.current=r,r},[...e])}function DC(t){const e=oI(t),n=w.useRef(null),r=w.useCallback(i=>{i!==n.current&&e?.(i,n.current),n.current=i},[]);return[n,r]}function eF(t){const e=w.useRef();return w.useEffect(()=>{e.current=t},[t]),e.current}let _j={};function Gv(t,e){return w.useMemo(()=>{if(e)return e;const n=_j[t]==null?0:_j[t]+1;return _j[t]=n,t+"-"+n},[t,e])}function Nie(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,d]of l){const u=s[c];u!=null&&(s[c]=u+t*d)}return s},{...e})}}const ob=Nie(1),nv=Nie(-1);function vYe(t){return"clientX"in t&&"clientY"in t}function lI(t){if(!t)return!1;const{KeyboardEvent:e}=mo(t.target);return e&&t instanceof e}function wYe(t){if(!t)return!1;const{TouchEvent:e}=mo(t.target);return e&&t instanceof e}function tF(t){if(wYe(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 vYe(t)?{x:t.clientX,y:t.clientY}:null}const Ob=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[Ob.Translate.toString(t),Ob.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:e,duration:n,easing:r}=t;return e+" "+n+"ms "+r}}}),qW="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function SYe(t){return t.matches(qW)?t:t.querySelector(qW)}const _Ye={display:"none"};function NYe(t){let{id:e,value:n}=t;return Wr.createElement("div",{id:e,style:_Ye},n)}function CYe(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 Wr.createElement("div",{id:e,style:i,role:"status","aria-live":r,"aria-atomic":!0},n)}function kYe(){const[t,e]=w.useState("");return{announce:w.useCallback(r=>{r!=null&&e(r)},[]),announcement:t}}const Cie=w.createContext(null);function AYe(t){const e=w.useContext(Cie);w.useEffect(()=>{if(!e)throw new Error("useDndMonitor must be used within a children of <DndContext>");return e(t)},[t,e])}function TYe(){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 MYe={draggable:`
- To pick up a draggable item, press the space bar.
- While dragging, use the arrow keys to move the item.
- Press space again to drop the item in its new position, or press escape to cancel.
- `},PYe={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 EYe(t){let{announcements:e=PYe,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=MYe}=t;const{announce:s,announcement:o}=kYe(),l=Gv("DndLiveRegion"),[c,d]=w.useState(!1);if(w.useEffect(()=>{d(!0)},[]),AYe(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 u=Wr.createElement(Wr.Fragment,null,Wr.createElement(NYe,{id:r,value:i.draggable}),Wr.createElement(CYe,{id:l,announcement:o}));return n?Ld.createPortal(u,n):u}var hi;(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"})(hi||(hi={}));function RC(){}function FC(t,e){return w.useMemo(()=>({sensor:t,options:e??{}}),[t,e])}function kie(){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 nc=Object.freeze({x:0,y:0});function Aie(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function Tie(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return n-r}function jYe(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return r-n}function GW(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 Mie(t,e){if(!t||t.length===0)return null;const[n]=t;return n[e]}function WW(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 Pie=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=WW(e,e.left,e.top),s=[];for(const o of r){const{id:l}=o,c=n.get(l);if(c){const d=Aie(WW(c),i);s.push({id:l,data:{droppableContainer:o,value:d}})}}return s.sort(Tie)},DYe=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=GW(e),s=[];for(const o of r){const{id:l}=o,c=n.get(l);if(c){const d=GW(c),u=i.reduce((f,p,x)=>f+Aie(d[x],p),0),h=Number((u/4).toFixed(4));s.push({id:l,data:{droppableContainer:o,value:h}})}}return s.sort(Tie)};function RYe(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,d=t.width*t.height,u=o*l,h=u/(c+d-u);return Number(h.toFixed(4))}return 0}const FYe=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=RYe(l,e);c>0&&i.push({id:o,data:{droppableContainer:s,value:c}})}}return i.sort(jYe)};function LYe(t,e,n){return{...t,scaleX:e&&n?e.width/n.width:1,scaleY:e&&n?e.height/n.height:1}}function Eie(t,e){return t&&e?{x:t.left-e.left,y:t.top-e.top}:nc}function OYe(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 IYe=OYe(1);function zYe(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 UYe(t,e,n){const r=zYe(e);if(!r)return t;const{scaleX:i,scaleY:s,x:o,y:l}=r,c=t.left-o-(1-i)*parseFloat(n),d=t.top-l-(1-s)*parseFloat(n.slice(n.indexOf(" ")+1)),u=i?t.width/i:t.width,h=s?t.height/s:t.height;return{width:u,height:h,top:d,right:c+u,bottom:d+h,left:c}}const BYe={ignoreTransform:!1};function ux(t,e){e===void 0&&(e=BYe);let n=t.getBoundingClientRect();if(e.ignoreTransform){const{transform:d,transformOrigin:u}=mo(t).getComputedStyle(t);d&&(n=UYe(n,d,u))}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 KW(t){return ux(t,{ignoreTransform:!0})}function HYe(t){const e=t.innerWidth,n=t.innerHeight;return{top:0,left:0,right:e,bottom:n,width:e,height:n}}function $Ye(t,e){return e===void 0&&(e=mo(t).getComputedStyle(t)),e.position==="fixed"}function VYe(t,e){e===void 0&&(e=mo(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 NA(t,e){const n=[];function r(i){if(e!=null&&n.length>=e||!i)return n;if(sI(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!Vv(i)||_ie(i)||n.includes(i))return n;const s=mo(t).getComputedStyle(i);return i!==t&&VYe(i,s)&&n.push(i),$Ye(i,s)?n:r(i.parentNode)}return t?r(t):n}function jie(t){const[e]=NA(t,1);return e??null}function Nj(t){return!_A||!t?null:cx(t)?t:iI(t)?sI(t)||t===dx(t).scrollingElement?window:Vv(t)?t:null:null}function Die(t){return cx(t)?t.scrollX:t.scrollLeft}function Rie(t){return cx(t)?t.scrollY:t.scrollTop}function nF(t){return{x:Die(t),y:Rie(t)}}var ji;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(ji||(ji={}));function Fie(t){return!_A||!t?!1:t===document.scrollingElement}function Lie(t){const e={x:0,y:0},n=Fie(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 qYe={x:.2,y:.2};function GYe(t,e,n,r,i){let{top:s,left:o,right:l,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=qYe);const{isTop:d,isBottom:u,isLeft:h,isRight:f}=Lie(t),p={x:0,y:0},x={x:0,y:0},v={height:e.height*i.y,width:e.width*i.x};return!d&&s<=e.top+v.height?(p.y=ji.Backward,x.y=r*Math.abs((e.top+v.height-s)/v.height)):!u&&c>=e.bottom-v.height&&(p.y=ji.Forward,x.y=r*Math.abs((e.bottom-v.height-c)/v.height)),!f&&l>=e.right-v.width?(p.x=ji.Forward,x.x=r*Math.abs((e.right-v.width-l)/v.width)):!h&&o<=e.left+v.width&&(p.x=ji.Backward,x.x=r*Math.abs((e.left+v.width-o)/v.width)),{direction:p,speed:x}}function WYe(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 Oie(t){return t.reduce((e,n)=>ob(e,nF(n)),nc)}function KYe(t){return t.reduce((e,n)=>e+Die(n),0)}function XYe(t){return t.reduce((e,n)=>e+Rie(n),0)}function YYe(t,e){if(e===void 0&&(e=ux),!t)return;const{top:n,left:r,bottom:i,right:s}=e(t);jie(t)&&(i<=0||s<=0||n>=window.innerHeight||r>=window.innerWidth)&&t.scrollIntoView({block:"center",inline:"center"})}const QYe=[["x",["left","right"],KYe],["y",["top","bottom"],XYe]];class cI{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=NA(n),i=Oie(r);this.rect={...e},this.width=e.width,this.height=e.height;for(const[s,o,l]of QYe)for(const c of o)Object.defineProperty(this,c,{get:()=>{const d=l(r),u=i[s]-d;return this.rect[c]+u},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class i0{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var r;return(r=this.target)==null?void 0:r.removeEventListener(...n)})},this.target=e}add(e,n,r){var i;(i=this.target)==null||i.addEventListener(e,n,r),this.listeners.push([e,n,r])}}function ZYe(t){const{EventTarget:e}=mo(t);return t instanceof e?t:dx(t)}function Cj(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 ol;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(ol||(ol={}));function XW(t){t.preventDefault()}function JYe(t){t.stopPropagation()}var ar;(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"})(ar||(ar={}));const Iie={start:[ar.Space,ar.Enter],cancel:[ar.Esc],end:[ar.Space,ar.Enter,ar.Tab]},eQe=(t,e)=>{let{currentCoordinates:n}=e;switch(t.code){case ar.Right:return{...n,x:n.x+25};case ar.Left:return{...n,x:n.x-25};case ar.Down:return{...n,y:n.y+25};case ar.Up:return{...n,y:n.y-25}}};class CA{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;const{event:{target:n}}=e;this.props=e,this.listeners=new i0(dx(n)),this.windowListeners=new i0(mo(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(ol.Resize,this.handleCancel),this.windowListeners.add(ol.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(ol.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:e,onStart:n}=this.props,r=e.node.current;r&&YYe(r),n(nc)}handleKeyDown(e){if(lI(e)){const{active:n,context:r,options:i}=this.props,{keyboardCodes:s=Iie,coordinateGetter:o=eQe,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:d}=r.current,u=d?{x:d.left,y:d.top}:nc;this.referenceCoordinates||(this.referenceCoordinates=u);const h=o(e,{active:n,context:r.current,currentCoordinates:u});if(h){const f=nv(h,u),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:k,minScroll:P}=Lie(v),C=WYe(v),j={x:Math.min(g===ar.Right?C.right-C.width/2:C.right,Math.max(g===ar.Right?C.left:C.left+C.width/2,h.x)),y:Math.min(g===ar.Down?C.bottom-C.height/2:C.bottom,Math.max(g===ar.Down?C.top:C.top+C.height/2,h.y))},M=g===ar.Right&&!_||g===ar.Left&&!N,E=g===ar.Down&&!A||g===ar.Up&&!y;if(M&&j.x!==h.x){const B=v.scrollLeft+f.x,L=g===ar.Right&&B<=k.x||g===ar.Left&&B>=P.x;if(L&&!f.y){v.scrollTo({left:B,behavior:l});return}L?p.x=v.scrollLeft-B:p.x=g===ar.Right?v.scrollLeft-k.x:v.scrollLeft-P.x,p.x&&v.scrollBy({left:-p.x,behavior:l});break}else if(E&&j.y!==h.y){const B=v.scrollTop+f.y,L=g===ar.Down&&B<=k.y||g===ar.Up&&B>=P.y;if(L&&!f.x){v.scrollTo({top:B,behavior:l});return}L?p.y=v.scrollTop-B:p.y=g===ar.Down?v.scrollTop-k.y:v.scrollTop-P.y,p.y&&v.scrollBy({top:-p.y,behavior:l});break}}this.handleMove(e,ob(nv(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()}}CA.activators=[{eventName:"onKeyDown",handler:(t,e,n)=>{let{keyboardCodes:r=Iie,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 YW(t){return!!(t&&"distance"in t)}function QW(t){return!!(t&&"delay"in t)}class dI{constructor(e,n,r){var i;r===void 0&&(r=ZYe(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=dx(o),this.documentListeners=new i0(this.document),this.listeners=new i0(r),this.windowListeners=new i0(mo(o)),this.initialCoordinates=(i=tF(s))!=null?i:nc,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(ol.Resize,this.handleCancel),this.windowListeners.add(ol.DragStart,XW),this.windowListeners.add(ol.VisibilityChange,this.handleCancel),this.windowListeners.add(ol.ContextMenu,XW),this.documentListeners.add(ol.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(QW(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(YW(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(ol.Click,JYe,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(ol.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=tF(e))!=null?n:nc,d=nv(i,c);if(!r&&l){if(YW(l)){if(l.tolerance!=null&&Cj(d,l.tolerance))return this.handleCancel();if(Cj(d,l.distance))return this.handleStart()}if(QW(l)&&Cj(d,l.tolerance))return this.handleCancel();this.handlePending(l,d);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===ar.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}}const tQe={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class kA extends dI{constructor(e){const{event:n}=e,r=dx(n.target);super(e,tQe,r)}}kA.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 nQe={move:{name:"mousemove"},end:{name:"mouseup"}};var rF;(function(t){t[t.RightClick=2]="RightClick"})(rF||(rF={}));class rQe extends dI{constructor(e){super(e,nQe,dx(e.event.target))}}rQe.activators=[{eventName:"onMouseDown",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:r}=e;return n.button===rF.RightClick?!1:(r?.({event:n}),!0)}}];const kj={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class aQe extends dI{constructor(e){super(e,kj)}static setup(){return window.addEventListener(kj.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(kj.move.name,e)};function e(){}}}aQe.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 s0;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(s0||(s0={}));var LC;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(LC||(LC={}));function iQe(t){let{acceleration:e,activator:n=s0.Pointer,canScroll:r,draggingRect:i,enabled:s,interval:o=5,order:l=LC.TreeOrder,pointerCoordinates:c,scrollableAncestors:d,scrollableAncestorRects:u,delta:h,threshold:f}=t;const p=oQe({delta:h,disabled:!s}),[x,v]=yYe(),g=w.useRef({x:0,y:0}),y=w.useRef({x:0,y:0}),_=w.useMemo(()=>{switch(n){case s0.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case s0.DraggableRect:return i}},[n,i,c]),N=w.useRef(null),A=w.useCallback(()=>{const P=N.current;if(!P)return;const C=g.current.x*y.current.x,j=g.current.y*y.current.y;P.scrollBy(C,j)},[]),k=w.useMemo(()=>l===LC.TreeOrder?[...d].reverse():d,[l,d]);w.useEffect(()=>{if(!s||!d.length||!_){v();return}for(const P of k){if(r?.(P)===!1)continue;const C=d.indexOf(P),j=u[C];if(!j)continue;const{direction:M,speed:E}=GYe(P,j,_,e,f);for(const B of["x","y"])p[B][M[B]]||(E[B]=0,M[B]=0);if(E.x>0||E.y>0){v(),N.current=P,x(A,o),g.current=E,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,d,k,u,JSON.stringify(f)])}const sQe={x:{[ji.Backward]:!1,[ji.Forward]:!1},y:{[ji.Backward]:!1,[ji.Forward]:!1}};function oQe(t){let{delta:e,disabled:n}=t;const r=eF(e);return qv(i=>{if(n||!r||!i)return sQe;const s={x:Math.sign(e.x-r.x),y:Math.sign(e.y-r.y)};return{x:{[ji.Backward]:i.x[ji.Backward]||s.x===-1,[ji.Forward]:i.x[ji.Forward]||s.x===1},y:{[ji.Backward]:i.y[ji.Backward]||s.y===-1,[ji.Forward]:i.y[ji.Forward]||s.y===1}}},[n,e,r])}function lQe(t,e){const n=e!=null?t.get(e):void 0,r=n?n.node.current:null;return qv(i=>{var s;return e==null?null:(s=r??i)!=null?s:null},[r,e])}function cQe(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 rv;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(rv||(rv={}));var aF;(function(t){t.Optimized="optimized"})(aF||(aF={}));const ZW=new Map;function dQe(t,e){let{dragging:n,dependencies:r,config:i}=e;const[s,o]=w.useState(null),{frequency:l,measure:c,strategy:d}=i,u=w.useRef(t),h=g(),f=tv(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=qv(y=>{if(h&&!n)return ZW;if(!y||y===ZW||u.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,k=A?new cI(c(A),A):null;N.rect.current=k,k&&_.set(N.id,k)}return _}return y},[t,s,n,h,c]);return w.useEffect(()=>{u.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(d){case rv.Always:return!1;case rv.BeforeDragging:return n;default:return!n}}}function zie(t,e){return qv(n=>t?n||(typeof e=="function"?e(t):t):null,[e,t])}function uQe(t,e){return zie(t,e)}function hQe(t){let{callback:e,disabled:n}=t;const r=oI(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 AA(t){let{callback:e,disabled:n}=t;const r=oI(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 mQe(t){return new cI(ux(t),t)}function JW(t,e,n){e===void 0&&(e=mQe);const[r,i]=w.useState(null);function s(){i(c=>{if(!t)return null;if(t.isConnected===!1){var d;return(d=c??n)!=null?d:null}const u=e(t);return JSON.stringify(c)===JSON.stringify(u)?c:u})}const o=hQe({callback(c){if(t)for(const d of c){const{type:u,target:h}=d;if(u==="childList"&&h instanceof HTMLElement&&h.contains(t)){s();break}}}}),l=AA({callback:s});return Vc(()=>{s(),t?(l?.observe(t),o?.observe(document.body,{childList:!0,subtree:!0})):(l?.disconnect(),o?.disconnect())},[t]),r}function fQe(t){const e=zie(t);return Eie(t,e)}const eK=[];function pQe(t){const e=w.useRef(t),n=qv(r=>t?r&&r!==eK&&t&&e.current&&t.parentNode===e.current.parentNode?r:NA(t):eK,[t]);return w.useEffect(()=>{e.current=t},[t]),n}function gQe(t){const[e,n]=w.useState(null),r=w.useRef(t),i=w.useCallback(s=>{const o=Nj(s.target);o&&n(l=>l?(l.set(o,nF(o)),new Map(l)):null)},[]);return w.useEffect(()=>{const s=r.current;if(t!==s){o(s);const l=t.map(c=>{const d=Nj(c);return d?(d.addEventListener("scroll",i,{passive:!0}),[d,nF(d)]):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 d=Nj(c);d?.removeEventListener("scroll",i)})}},[i,t]),w.useMemo(()=>t.length?e?Array.from(e.values()).reduce((s,o)=>ob(s,o),nc):Oie(t):nc,[t,e])}function tK(t,e){e===void 0&&(e=[]);const n=w.useRef(null);return w.useEffect(()=>{n.current=null},e),w.useEffect(()=>{const r=t!==nc;r&&!n.current&&(n.current=t),!r&&n.current&&(n.current=null)},[t]),n.current?nv(t,n.current):nc}function bQe(t){w.useEffect(()=>{if(!_A)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 xQe(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 Uie(t){return w.useMemo(()=>t?HYe(t):null,[t])}const nK=[];function yQe(t,e){e===void 0&&(e=ux);const[n]=t,r=Uie(n?mo(n):null),[i,s]=w.useState(nK);function o(){s(()=>t.length?t.map(c=>Fie(c)?r:new cI(e(c),c)):nK)}const l=AA({callback:o});return Vc(()=>{l?.disconnect(),o(),t.forEach(c=>l?.observe(c))},[t]),i}function vQe(t){if(!t)return null;if(t.children.length>1)return t;const e=t.children[0];return Vv(e)?e:t}function wQe(t){let{measure:e}=t;const[n,r]=w.useState(null),i=w.useCallback(d=>{for(const{target:u}of d)if(Vv(u)){r(h=>{const f=e(u);return h?{...h,width:f.width,height:f.height}:f});break}},[e]),s=AA({callback:i}),o=w.useCallback(d=>{const u=vQe(d);s?.disconnect(),u&&s?.observe(u),r(u?e(u):null)},[e,s]),[l,c]=DC(o);return w.useMemo(()=>({nodeRef:l,rect:n,setRef:c}),[n,l,c])}const SQe=[{sensor:kA,options:{}},{sensor:CA,options:{}}],_Qe={current:{}},d1={draggable:{measure:KW},droppable:{measure:KW,strategy:rv.WhileDragging,frequency:aF.Optimized},dragOverlay:{measure:ux}};class o0 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 NQe={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new o0,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:RC},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:d1,measureDroppableContainers:RC,windowRect:null,measuringScheduled:!1},CQe={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:RC,draggableNodes:new Map,over:null,measureDroppableContainers:RC},TA=w.createContext(CQe),Bie=w.createContext(NQe);function kQe(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new o0}}}function AQe(t,e){switch(e.type){case hi.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:e.initialCoordinates,active:e.active}};case hi.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 hi.DragEnd:case hi.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case hi.RegisterDroppable:{const{element:n}=e,{id:r}=n,i=new o0(t.droppable.containers);return i.set(r,n),{...t,droppable:{...t.droppable,containers:i}}}case hi.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 o0(t.droppable.containers);return o.set(n,{...s,disabled:i}),{...t,droppable:{...t.droppable,containers:o}}}case hi.UnregisterDroppable:{const{id:n,key:r}=e,i=t.droppable.containers.get(n);if(!i||r!==i.key)return t;const s=new o0(t.droppable.containers);return s.delete(n),{...t,droppable:{...t.droppable,containers:s}}}default:return t}}function TQe(t){let{disabled:e}=t;const{active:n,activatorEvent:r,draggableNodes:i}=w.useContext(TA),s=eF(r),o=eF(n?.id);return w.useEffect(()=>{if(!e&&!r&&s&&o!=null){if(!lI(s)||document.activeElement===s.target)return;const l=i.get(o);if(!l)return;const{activatorNode:c,node:d}=l;if(!c.current&&!d.current)return;requestAnimationFrame(()=>{for(const u of[c.current,d.current]){if(!u)continue;const h=SYe(u);if(h){h.focus();break}}})}},[r,e,i,o,s]),null}function MQe(t,e){let{transform:n,...r}=e;return t!=null&&t.length?t.reduce((i,s)=>s({transform:i,...r}),n):n}function PQe(t){return w.useMemo(()=>({draggable:{...d1.draggable,...t?.draggable},droppable:{...d1.droppable,...t?.droppable},dragOverlay:{...d1.dragOverlay,...t?.dragOverlay}}),[t?.draggable,t?.droppable,t?.dragOverlay])}function EQe(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;Vc(()=>{if(!o&&!l||!e){s.current=!1;return}if(s.current||!r)return;const d=e?.node.current;if(!d||d.isConnected===!1)return;const u=n(d),h=Eie(u,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=jie(d);f&&f.scrollBy({top:h.y,left:h.x})}},[e,o,l,r,n])}const Hie=w.createContext({...nc,scaleX:1,scaleY:1});var mh;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(mh||(mh={}));const $ie=w.memo(function(e){var n,r,i,s;let{id:o,accessibility:l,autoScroll:c=!0,children:d,sensors:u=SQe,collisionDetection:h=FYe,measuring:f,modifiers:p,...x}=e;const v=w.useReducer(AQe,void 0,kQe),[g,y]=v,[_,N]=TYe(),[A,k]=w.useState(mh.Uninitialized),P=A===mh.Initialized,{draggable:{active:C,nodes:j,translate:M},droppable:{containers:E}}=g,B=C!=null?j.get(C):null,L=w.useRef({initial:null,translated:null}),U=w.useMemo(()=>{var We;return C!=null?{id:C,data:(We=B?.data)!=null?We:_Qe,rect:L}:null},[C,B]),D=w.useRef(null),[$,q]=w.useState(null),[z,W]=w.useState(null),Q=tv(x,Object.values(x)),te=Gv("DndDescribedBy",o),H=w.useMemo(()=>E.getEnabled(),[E]),X=PQe(f),{droppableRects:Z,measureDroppableContainers:ee,measuringScheduled:Se}=dQe(H,{dragging:P,dependencies:[M.x,M.y],config:X.droppable}),oe=lQe(j,C),ie=w.useMemo(()=>z?tF(z):null,[z]),me=De(),se=uQe(oe,X.draggable.measure);EQe({activeNode:C!=null?j.get(C):null,config:me.layoutShiftCompensation,initialRect:se,measure:X.draggable.measure});const ce=JW(oe,X.draggable.measure,se),Ce=JW(oe?oe.parentElement:null),le=w.useRef({activatorEvent:null,active:null,activeNode:oe,collisionRect:null,collisions:null,droppableRects:Z,draggableNodes:j,draggingNode:null,draggingNodeRect:null,droppableContainers:E,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),Le=E.getNodeFor((n=le.current.over)==null?void 0:n.id),V=wQe({measure:X.dragOverlay.measure}),K=(r=V.nodeRef.current)!=null?r:oe,fe=P?(i=V.rect)!=null?i:ce:null,Y=!!(V.nodeRef.current&&V.rect),re=fQe(Y?null:ce),ue=Uie(K?mo(K):null),Fe=pQe(P?Le??oe:null),Pe=yQe(Fe),be=MQe(p,{transform:{x:M.x-re.x,y:M.y-re.y,scaleX:1,scaleY:1},activatorEvent:z,active:U,activeNodeRect:ce,containerNodeRect:Ce,draggingNodeRect:fe,over:le.current.over,overlayNodeRect:V.rect,scrollableAncestors:Fe,scrollableAncestorRects:Pe,windowRect:ue}),O=ie?ob(ie,M):null,R=gQe(Fe),G=tK(R),de=tK(R,[ce]),ge=ob(be,G),ae=fe?IYe(fe,be):null,Ue=U&&ae?h({active:U,collisionRect:ae,droppableRects:Z,droppableContainers:H,pointerCoordinates:O}):null,ze=Mie(Ue,"id"),[$e,Re]=w.useState(null),pe=Y?be:ob(be,de),ve=LYe(pe,(s=$e?.rect)!=null?s:null,ce),Ne=w.useRef(null),xe=w.useCallback((We,Oe)=>{let{sensor:je,options:Ve}=Oe;if(D.current==null)return;const ot=j.get(D.current);if(!ot)return;const kt=We.nativeEvent,Ft=new je({active:D.current,activeNode:ot,event:kt,options:Ve,context:le,onAbort(At){if(!j.get(At))return;const{onDragAbort:mt}=Q.current,yt={id:At};mt?.(yt),_({type:"onDragAbort",event:yt})},onPending(At,Be,mt,yt){if(!j.get(At))return;const{onDragPending:yn}=Q.current,gr={id:At,constraint:Be,initialCoordinates:mt,offset:yt};yn?.(gr),_({type:"onDragPending",event:gr})},onStart(At){const Be=D.current;if(Be==null)return;const mt=j.get(Be);if(!mt)return;const{onDragStart:yt}=Q.current,zt={activatorEvent:kt,active:{id:Be,data:mt.data,rect:L}};Ld.unstable_batchedUpdates(()=>{yt?.(zt),k(mh.Initializing),y({type:hi.DragStart,initialCoordinates:At,active:Be}),_({type:"onDragStart",event:zt}),q(Ne.current),W(kt)})},onMove(At){y({type:hi.DragMove,coordinates:At})},onEnd:Vt(hi.DragEnd),onCancel:Vt(hi.DragCancel)});Ne.current=Ft;function Vt(At){return async function(){const{active:mt,collisions:yt,over:zt,scrollAdjustedTranslate:yn}=le.current;let gr=null;if(mt&&yn){const{cancelDrop:sr}=Q.current;gr={activatorEvent:kt,active:mt,collisions:yt,delta:yn,over:zt},At===hi.DragEnd&&typeof sr=="function"&&await Promise.resolve(sr(gr))&&(At=hi.DragCancel)}D.current=null,Ld.unstable_batchedUpdates(()=>{y({type:At}),k(mh.Uninitialized),Re(null),q(null),W(null),Ne.current=null;const sr=At===hi.DragEnd?"onDragEnd":"onDragCancel";if(gr){const nr=Q.current[sr];nr?.(gr),_({type:sr,event:gr})}})}}},[j]),we=w.useCallback((We,Oe)=>(je,Ve)=>{const ot=je.nativeEvent,kt=j.get(Ve);if(D.current!==null||!kt||ot.dndKit||ot.defaultPrevented)return;const Ft={active:kt};We(je,Oe.options,Ft)===!0&&(ot.dndKit={capturedBy:Oe.sensor},D.current=Ve,xe(je,Oe))},[j,xe]),qe=cQe(u,we);bQe(u),Vc(()=>{ce&&A===mh.Initializing&&k(mh.Initialized)},[ce,A]),w.useEffect(()=>{const{onDragMove:We}=Q.current,{active:Oe,activatorEvent:je,collisions:Ve,over:ot}=le.current;if(!Oe||!je)return;const kt={active:Oe,activatorEvent:je,collisions:Ve,delta:{x:ge.x,y:ge.y},over:ot};Ld.unstable_batchedUpdates(()=>{We?.(kt),_({type:"onDragMove",event:kt})})},[ge.x,ge.y]),w.useEffect(()=>{const{active:We,activatorEvent:Oe,collisions:je,droppableContainers:Ve,scrollAdjustedTranslate:ot}=le.current;if(!We||D.current==null||!Oe||!ot)return;const{onDragOver:kt}=Q.current,Ft=Ve.get(ze),Vt=Ft&&Ft.rect.current?{id:Ft.id,rect:Ft.rect.current,data:Ft.data,disabled:Ft.disabled}:null,At={active:We,activatorEvent:Oe,collisions:je,delta:{x:ot.x,y:ot.y},over:Vt};Ld.unstable_batchedUpdates(()=>{Re(Vt),kt?.(At),_({type:"onDragOver",event:At})})},[ze]),Vc(()=>{le.current={activatorEvent:z,active:U,activeNode:oe,collisionRect:ae,collisions:Ue,droppableRects:Z,draggableNodes:j,draggingNode:K,draggingNodeRect:fe,droppableContainers:E,over:$e,scrollableAncestors:Fe,scrollAdjustedTranslate:ge},L.current={initial:fe,translated:ae}},[U,oe,Ue,ae,j,K,fe,Z,E,$e,Fe,ge]),iQe({...me,delta:M,draggingRect:ae,pointerCoordinates:O,scrollableAncestors:Fe,scrollableAncestorRects:Pe});const ke=w.useMemo(()=>({active:U,activeNode:oe,activeNodeRect:ce,activatorEvent:z,collisions:Ue,containerNodeRect:Ce,dragOverlay:V,draggableNodes:j,droppableContainers:E,droppableRects:Z,over:$e,measureDroppableContainers:ee,scrollableAncestors:Fe,scrollableAncestorRects:Pe,measuringConfiguration:X,measuringScheduled:Se,windowRect:ue}),[U,oe,ce,z,Ue,Ce,V,j,E,Z,$e,ee,Fe,Pe,X,Se,ue]),nt=w.useMemo(()=>({activatorEvent:z,activators:qe,active:U,activeNodeRect:ce,ariaDescribedById:{draggable:te},dispatch:y,draggableNodes:j,over:$e,measureDroppableContainers:ee}),[z,qe,U,ce,y,te,j,$e,ee]);return Wr.createElement(Cie.Provider,{value:N},Wr.createElement(TA.Provider,{value:nt},Wr.createElement(Bie.Provider,{value:ke},Wr.createElement(Hie.Provider,{value:ve},d)),Wr.createElement(TQe,{disabled:l?.restoreFocus===!1})),Wr.createElement(EYe,{...l,hiddenTextDescribedById:te}));function De(){const We=$?.autoScrollEnabled===!1,Oe=typeof c=="object"?c.enabled===!1:c===!1,je=P&&!We&&!Oe;return typeof c=="object"?{...c,enabled:je}:{enabled:je}}}),jQe=w.createContext(null),rK="button",DQe="Draggable";function RQe(t){let{id:e,data:n,disabled:r=!1,attributes:i}=t;const s=Gv(DQe),{activators:o,activatorEvent:l,active:c,activeNodeRect:d,ariaDescribedById:u,draggableNodes:h,over:f}=w.useContext(TA),{role:p=rK,roleDescription:x="draggable",tabIndex:v=0}=i??{},g=c?.id===e,y=w.useContext(g?Hie:jQe),[_,N]=DC(),[A,k]=DC(),P=xQe(o,e),C=tv(n);Vc(()=>(h.set(e,{id:e,key:s,node:_,activatorNode:A,data:C}),()=>{const M=h.get(e);M&&M.key===s&&h.delete(e)}),[h,e]);const j=w.useMemo(()=>({role:p,tabIndex:v,"aria-disabled":r,"aria-pressed":g&&p===rK?!0:void 0,"aria-roledescription":x,"aria-describedby":u.draggable}),[r,p,v,g,x,u.draggable]);return{active:c,activatorEvent:l,activeNodeRect:d,attributes:j,isDragging:g,listeners:r?void 0:P,node:_,over:f,setNodeRef:N,setActivatorNodeRef:k,transform:y}}function FQe(){return w.useContext(Bie)}const LQe="Droppable",OQe={timeout:25};function IQe(t){let{data:e,disabled:n=!1,id:r,resizeObserverConfig:i}=t;const s=Gv(LQe),{active:o,dispatch:l,over:c,measureDroppableContainers:d}=w.useContext(TA),u=w.useRef({disabled:n}),h=w.useRef(!1),f=w.useRef(null),p=w.useRef(null),{disabled:x,updateMeasurementsFor:v,timeout:g}={...OQe,...i},y=tv(v??r),_=w.useCallback(()=>{if(!h.current){h.current=!0;return}p.current!=null&&clearTimeout(p.current),p.current=setTimeout(()=>{d(Array.isArray(y.current)?y.current:[y.current]),p.current=null},g)},[g]),N=AA({callback:_,disabled:x||!o}),A=w.useCallback((j,M)=>{N&&(M&&(N.unobserve(M),h.current=!1),j&&N.observe(j))},[N]),[k,P]=DC(A),C=tv(e);return w.useEffect(()=>{!N||!k.current||(N.disconnect(),h.current=!1,N.observe(k.current))},[k,N]),w.useEffect(()=>(l({type:hi.RegisterDroppable,element:{id:r,key:s,disabled:n,node:k,rect:f,data:C}}),()=>l({type:hi.UnregisterDroppable,key:s,id:r})),[r]),w.useEffect(()=>{n!==u.current.disabled&&(l({type:hi.SetDroppableDisabled,id:r,key:s,disabled:n}),u.current.disabled=n)},[r,s,n,l]),{active:o,rect:f,isOver:c?.id===r,node:k,over:c,setNodeRef:P}}function MA(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 R_(t){return t!==null&&t>=0}function UQe(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 BQe(t){return typeof t=="boolean"?{draggable:t,droppable:t}:t}const uI=t=>{let{rects:e,activeIndex:n,overIndex:r,index:i}=t;const s=MA(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}},F_={scaleX:1,scaleY:1},HQe=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 d=s[o];return d?{x:0,y:n<o?d.top+d.height-(l.top+l.height):d.top-l.top,...F_}:null}const c=$Qe(s,i,n);return i>n&&i<=o?{x:0,y:-l.height-c,...F_}:i<n&&i>=o?{x:0,y:l.height+c,...F_}:{x:0,y:0,...F_}};function $Qe(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 Vie="Sortable",qie=Wr.createContext({activeIndex:-1,containerId:Vie,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:uI,disabled:{draggable:!1,droppable:!1}});function Gie(t){let{children:e,id:n,items:r,strategy:i=uI,disabled:s=!1}=t;const{active:o,dragOverlay:l,droppableRects:c,over:d,measureDroppableContainers:u}=FQe(),h=Gv(Vie,n),f=l.rect!==null,p=w.useMemo(()=>r.map(P=>typeof P=="object"&&"id"in P?P.id:P),[r]),x=o!=null,v=o?p.indexOf(o.id):-1,g=d?p.indexOf(d.id):-1,y=w.useRef(p),_=!UQe(p,y.current),N=g!==-1&&v===-1||_,A=BQe(s);Vc(()=>{_&&x&&u(p)},[_,p,x,u]),w.useEffect(()=>{y.current=p},[p]);const k=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 Wr.createElement(qie.Provider,{value:k},e)}const VQe=t=>{let{id:e,items:n,activeIndex:r,overIndex:i}=t;return MA(n,r,i).indexOf(e)},qQe=t=>{let{containerId:e,isSorting:n,wasDragging:r,index:i,items:s,newIndex:o,previousItems:l,previousContainerId:c,transition:d}=t;return!d||!r||l!==s&&i===o?!1:n?!0:o!==i&&e===c},GQe={duration:200,easing:"ease"},Wie="transform",WQe=Ob.Transition.toString({property:Wie,duration:0,easing:"linear"}),KQe={roleDescription:"sortable"};function XQe(t){let{disabled:e,index:n,node:r,rect:i}=t;const[s,o]=w.useState(null),l=w.useRef(n);return Vc(()=>{if(!e&&n!==l.current&&r.current){const c=i.current;if(c){const d=ux(r.current,{ignoreTransform:!0}),u={x:c.left-d.left,y:c.top-d.top,scaleX:c.width/d.width,scaleY:c.height/d.height};(u.x||u.y)&&o(u)}}n!==l.current&&(l.current=n)},[e,n,r,i]),w.useEffect(()=>{s&&o(null)},[s]),s}function Kie(t){let{animateLayoutChanges:e=qQe,attributes:n,disabled:r,data:i,getNewIndex:s=VQe,id:o,strategy:l,resizeObserverConfig:c,transition:d=GQe}=t;const{items:u,containerId:h,activeIndex:f,disabled:p,disableTransforms:x,sortedRects:v,overIndex:g,useDragOverlay:y,strategy:_}=w.useContext(qie),N=YQe(r,p),A=u.indexOf(o),k=w.useMemo(()=>({sortable:{containerId:h,index:A,items:u},...i}),[h,i,A,u]),P=w.useMemo(()=>u.slice(u.indexOf(o)),[u,o]),{rect:C,node:j,isOver:M,setNodeRef:E}=IQe({id:o,data:k,disabled:N.droppable,resizeObserverConfig:{updateMeasurementsFor:P,...c}}),{active:B,activatorEvent:L,activeNodeRect:U,attributes:D,setNodeRef:$,listeners:q,isDragging:z,over:W,setActivatorNodeRef:Q,transform:te}=RQe({id:o,data:k,attributes:{...KQe,...n},disabled:N.draggable}),H=xYe(E,$),X=!!B,Z=X&&!x&&R_(f)&&R_(g),ee=!y&&z,Se=ee&&Z?te:null,ie=Z?Se??(l??_)({rects:v,activeNodeRect:U,activeIndex:f,overIndex:g,index:A}):null,me=R_(f)&&R_(g)?s({id:o,items:u,activeIndex:f,overIndex:g}):A,se=B?.id,ce=w.useRef({activeId:se,items:u,newIndex:me,containerId:h}),Ce=u!==ce.current.items,le=e({active:B,containerId:h,isDragging:z,isSorting:X,id:o,index:A,items:u,newIndex:ce.current.newIndex,previousItems:ce.current.items,previousContainerId:ce.current.containerId,transition:d,wasDragging:ce.current.activeId!=null}),Le=XQe({disabled:!le,index:A,node:j,rect:C});return w.useEffect(()=>{X&&ce.current.newIndex!==me&&(ce.current.newIndex=me),h!==ce.current.containerId&&(ce.current.containerId=h),u!==ce.current.items&&(ce.current.items=u)},[X,me,h,u]),w.useEffect(()=>{if(se===ce.current.activeId)return;if(se!=null&&ce.current.activeId==null){ce.current.activeId=se;return}const K=setTimeout(()=>{ce.current.activeId=se},50);return()=>clearTimeout(K)},[se]),{active:B,activeIndex:f,attributes:D,data:k,rect:C,index:A,newIndex:me,items:u,isOver:M,isSorting:X,isDragging:z,listeners:q,node:j,overIndex:g,over:W,setNodeRef:H,setActivatorNodeRef:Q,setDroppableNodeRef:E,setDraggableNodeRef:$,transform:Le??ie,transition:V()};function V(){if(Le||Ce&&ce.current.newIndex===A)return WQe;if(!(ee&&!lI(L)||!d)&&(X||le))return Ob.Transition.toString({...d,property:Wie})}}function YQe(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 OC(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 QQe=[ar.Down,ar.Right,ar.Up,ar.Left],Xie=(t,e)=>{let{context:{active:n,collisionRect:r,droppableRects:i,droppableContainers:s,over:o,scrollableAncestors:l}}=e;if(QQe.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 ar.Down:r.top<f.top&&c.push(h);break;case ar.Up:r.top>f.top&&c.push(h);break;case ar.Left:r.left>f.left&&c.push(h);break;case ar.Right:r.left<f.left&&c.push(h);break}});const d=DYe({collisionRect:r,droppableRects:i,droppableContainers:c});let u=Mie(d,"id");if(u===o?.id&&d.length>1&&(u=d[1].id),u!=null){const h=s.get(n.id),f=s.get(u),p=f?i.get(f.id):null,x=f?.node.current;if(x&&p&&h&&f){const g=NA(x).some((P,C)=>l[C]!==P),y=Yie(h,f),_=ZQe(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:nv(A,N)}}}};function Yie(t,e){return!OC(t)||!OC(e)?!1:t.data.current.sortable.containerId===e.data.current.sortable.containerId}function ZQe(t,e){return!OC(t)||!OC(e)||!Yie(t,e)?!1:t.data.current.sortable.index<e.data.current.sortable.index}function Qie(t,e=!1){return e&&t>=1e3?`${(t/1e3).toFixed(1)}kg`:`${Math.round(t)}g`}function JQe({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(qn,{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(XC,{className:"w-3.5 h-3.5"}),r("queue.status.paused")]});const i={pending:{icon:qn,color:"text-status-warning bg-status-warning/10 border-status-warning/20",label:r("queue.status.pending")},printing:{icon:oo,color:"text-blue-400 bg-blue-400/10 border-blue-400/20",label:r("queue.status.printing")},completed:{icon:yr,color:"text-status-ok bg-status-ok/10 border-status-ok/20",label:r("queue.status.completed")},failed:{icon:mi,color:"text-status-error bg-status-error/10 border-status-error/20",label:r("queue.status.failed")},skipped:{icon:PF,color:"text-orange-400 bg-orange-400/10 border-orange-400/20",label:r("queue.status.skipped")},cancelled:{icon:Rt,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 eZe({selectedCount:t,printers:e,onSave:n,onClose:r,isSaving:i,canControlPrinter:s,t:o}){const[l,c]=w.useState("unchanged"),[d,u]=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"),[k,P]=w.useState("unchanged"),[C,j]=w.useState("unchanged"),[M,E]=w.useState("unchanged"),B=()=>{const U={};l!=="unchanged"&&(U.printer_id=l),d!=="unchanged"&&(U.manual_start=d),h!=="unchanged"&&(U.auto_off_after=h),p!=="unchanged"&&(U.require_previous_success=p),v!=="unchanged"&&(U.bed_levelling=v),y!=="unchanged"&&(U.flow_cali=y),N!=="unchanged"&&(U.vibration_cali=N),k!=="unchanged"&&(U.layer_inspect=k),C!=="unchanged"&&(U.timelapse=C),M!=="unchanged"&&(U.use_ams=M),n(U)},L=l!=="unchanged"||d!=="unchanged"||h!=="unchanged"||p!=="unchanged"||v!=="unchanged"||y!=="unchanged"||N!=="unchanged"||k!=="unchanged"||C!=="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(Rt,{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:U=>{const D=U.target.value;c(D==="unchanged"?"unchanged":D==="null"?null:Number(D))},className:"w-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(U=>a.jsx("option",{value:U.id,children:U.name},U.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(Td,{label:o("queue.bulkEdit.staged"),value:d,onChange:u,t:o}),a.jsx(Td,{label:o("queue.bulkEdit.autoPowerOff"),value:h,onChange:f,disabled:!s,t:o}),a.jsx(Td,{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(Td,{label:o("queue.bulkEdit.bedLevelling"),value:v,onChange:g,t:o}),a.jsx(Td,{label:o("queue.bulkEdit.flowCalibration"),value:y,onChange:_,t:o}),a.jsx(Td,{label:o("queue.bulkEdit.vibrationCalibration"),value:N,onChange:A,t:o}),a.jsx(Td,{label:o("queue.bulkEdit.layerInspection"),value:k,onChange:P,t:o}),a.jsx(Td,{label:o("queue.bulkEdit.timelapse"),value:C,onChange:j,t:o}),a.jsx(Td,{label:o("queue.bulkEdit.useAms"),value:M,onChange:E,t:o})]})]})]}),a.jsxs("div",{className:"flex justify-end gap-3 p-4 border-t border-bambu-dark-tertiary",children:[a.jsx(Me,{variant:"secondary",onClick:r,children:o("common.cancel")}),a.jsx(Me,{onClick:B,disabled:!L||i,children:o(i?"common.saving":"queue.bulkEdit.applyChanges")})]})]})})}function Td({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 Aj({item:t,position:e,onEdit:n,onCancel:r,onRemove:i,onStop:s,onRequeue:o,onStart:l,timeFormat:c="system",isSelected:d=!1,onToggleSelect:u,hasPermission:h,canModify:f,printerState:p,t:x}){const{data:v}=Ze({queryKey:["printerStatus",t.printer_id],queryFn:()=>J.getPrinterStatus(t.printer_id),refetchInterval:3e4,enabled:t.printer_id!=null&&p==="printing"}),g=!!t.library_file_id&&!t.archive_id,{data:y}=Ze({queryKey:["archive-plates",t.archive_id],queryFn:()=>J.getArchivePlates(t.archive_id),enabled:!!t.archive_id&&!g}),{data:_}=Ze({queryKey:["library-file-plates",t.library_file_id],queryFn:()=>J.getLibraryFilePlates(t.library_file_id),enabled:g&&!!t.library_file_id}),N=g?_:y,A=N?.plates??[],k=h("queue:reorder"),{attributes:P,listeners:C,setNodeRef:j,transform:M,transition:E,isDragging:B}=Kie({id:t.id,disabled:t.status!=="pending"||!k}),L={transform:Ob.Transform.toString(M),transition:E},U=t.status==="printing",D=t.status==="pending",$=["completed","failed","skipped","cancelled"].includes(t.status),q=D&&u;return a.jsxs("div",{ref:j,style:L,className:`
- group relative bg-bambu-dark-secondary rounded-xl border transition-all duration-200
- ${B?"opacity-50 scale-[1.02] shadow-xl z-50":""}
- ${U?"border-blue-500/30 bg-gradient-to-r from-blue-500/5 to-transparent":""}
- ${d&&q?"sm:border-bambu-dark-tertiary border-bambu-green/40":""}
- ${!d&&!U?"border-bambu-dark-tertiary hover:border-bambu-dark-tertiary/80":""}
- ${q?"sm:cursor-default":""}
- `,onClick:q?()=>{window.innerWidth<640&&u()}:void 0,children:[q&&d&&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:[D&&u&&a.jsx("button",{onClick:z=>{z.stopPropagation(),u()},className:`hidden sm:flex items-center justify-center w-6 h-6 rounded border transition-colors shrink-0 ${d?"bg-bambu-green border-bambu-green text-white":"border-white/30 bg-black/30 hover:border-bambu-green/50"}`,children:d&&a.jsx(na,{className:"w-4 h-4"})}),D?a.jsx("div",{...P,...C,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(jh,{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?J.getArchivePlateThumbnail(t.archive_id,t.plate_id):J.getArchiveThumbnail(t.archive_id),alt:"",className:"w-full h-full object-cover"}):t.library_file_thumbnail?a.jsx("img",{src:t.plate_id!=null?J.getLibraryFilePlateThumbnail(t.library_file_id,t.plate_id):J.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(ri,{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(z=>z.index===t.plate_id)?.name||x("queue.plateNumber",{index:t.plate_id})}`]}),t.archive_id?a.jsx(Ys,{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(ta,{className:"w-3.5 h-3.5"})}):t.library_file_id?a.jsx(Ys,{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(ta,{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(Nr,{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(Od,{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(EX,{className:"w-3 h-3 sm:w-3.5 sm:h-3.5"}),Qie(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(nu,{className:"w-3.5 h-3.5"}),t.created_by_username]}),D&&!t.manual_start&&a.jsxs("span",{className:"flex items-center gap-1.5",children:[a.jsx(qn,{className:"w-3.5 h-3.5"}),t.scheduled_time?(tr(t.scheduled_time)?.getTime()??0)-Date.now()<-6e4?x?.("queue.time.overdue")??"Overdue":g0(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(_X,{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(fu,{className:"w-2.5 h-2.5 sm:w-3 sm:h-3"}),x("queue.badges.autoPowerOff")]})]}),U&&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(qn,{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 ",FF(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(ri,{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(Va,{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(Va,{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:z=>z.stopPropagation(),children:[a.jsx(JQe,{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:[U&&a.jsx(Me,{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(Rhe,{className:"w-4 h-4"})}),D&&a.jsxs(a.Fragment,{children:[t.manual_start&&a.jsx(Me,{variant:"ghost",size:"sm",onClick:l,disabled:!h("printers:control"),title:h("printers:control")?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(oo,{className:"w-4 h-4"})}),a.jsx(Me,{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(Ga,{className:"w-4 h-4"})}),a.jsx(Me,{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(Rt,{className:"w-4 h-4"})})]}),$&&a.jsxs(a.Fragment,{children:[a.jsx(Me,{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(Sr,{className:"w-4 h-4"})}),a.jsx(Me,{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(Yt,{className:"w-4 h-4"})})]})]})]})]})]})}function tZe(){const{t}=Dt(),e=Qt(),{showToast:n}=dn(),{hasPermission:r,hasAnyPermission:i,canModify:s}=jr(),[o,l]=w.useState(null),[c,d]=w.useState(""),[u,h]=w.useState(""),[f,p]=w.useState(!1),[x,v]=w.useState(null),[g,y]=w.useState(null),[_,N]=w.useState(null),[A,k]=w.useState([]),[P,C]=w.useState(!1),[j,M]=w.useState(()=>localStorage.getItem("queue.historySortBy")||"date"),[E,B]=w.useState(()=>{const O=localStorage.getItem("queue.historySortAsc");return O!==null?O==="true":!1}),[L,U]=w.useState(()=>localStorage.getItem("queue.pendingSortBy")||"position"),[D,$]=w.useState(()=>{const O=localStorage.getItem("queue.pendingSortAsc");return O!==null?O==="true":!0});w.useEffect(()=>{localStorage.setItem("queue.historySortBy",j)},[j]),w.useEffect(()=>{localStorage.setItem("queue.historySortAsc",String(E))},[E]),w.useEffect(()=>{localStorage.setItem("queue.pendingSortBy",L)},[L]),w.useEffect(()=>{localStorage.setItem("queue.pendingSortAsc",String(D))},[D]);const q=kie(FC(kA,{activationConstraint:{distance:8}}),FC(CA,{coordinateGetter:Xie})),{data:z}=Ze({queryKey:["settings"],queryFn:J.getSettings}),W=z?.time_format||"system",{data:Q,isLoading:te}=Ze({queryKey:["queue",o,c],queryFn:()=>J.getQueue(o||void 0,c||void 0),refetchInterval:5e3}),{data:H}=Ze({queryKey:["printers"],queryFn:()=>J.getPrinters()}),X=st({mutationFn:O=>J.cancelQueueItem(O),onSuccess:()=>{e.invalidateQueries({queryKey:["queue"]}),n(t("queue.toast.cancelled"))},onError:()=>n(t("queue.toast.cancelFailed"),"error")}),Z=st({mutationFn:O=>J.removeFromQueue(O),onSuccess:()=>{e.invalidateQueries({queryKey:["queue"]}),n(t("queue.toast.removed"))},onError:()=>n(t("queue.toast.removeFailed"),"error")}),ee=st({mutationFn:O=>J.stopQueueItem(O),onSuccess:()=>{e.invalidateQueries({queryKey:["queue"]}),n(t("queue.toast.stopped"))},onError:()=>n(t("queue.toast.stopFailed"),"error")}),Se=st({mutationFn:O=>J.startQueueItem(O),onSuccess:()=>{e.invalidateQueries({queryKey:["queue"]}),n(t("queue.toast.released"))},onError:()=>n(t("queue.toast.startFailed"),"error")}),oe=st({mutationFn:O=>J.reorderQueue(O),onSuccess:()=>{e.invalidateQueries({queryKey:["queue"]})},onError:()=>n(t("queue.toast.reorderFailed"),"error")}),ie=st({mutationFn:async()=>{const O=Q?.filter(R=>["completed","failed","skipped","cancelled"].includes(R.status))||[];for(const R of O)await J.removeFromQueue(R.id);return O.length},onSuccess:O=>{e.invalidateQueries({queryKey:["queue"]}),n(t("queue.toast.historyCleared",{count:O}))},onError:()=>n(t("queue.toast.clearHistoryFailed"),"error")}),me=st({mutationFn:O=>J.bulkUpdateQueue(O),onSuccess:O=>{e.invalidateQueries({queryKey:["queue"]}),k([]),C(!1),n(O.message)},onError:()=>n(t("queue.toast.updateFailed"),"error")}),se=st({mutationFn:async O=>{for(const R of O)await J.cancelQueueItem(R);return O.length},onSuccess:O=>{e.invalidateQueries({queryKey:["queue"]}),k([]),n(t("queue.toast.bulkCancelled",{count:O}))},onError:()=>n(t("queue.toast.bulkCancelFailed"),"error")}),ce=O=>{k(R=>R.includes(O)?R.filter(G=>G!==O):[...R,O])},Ce=w.useMemo(()=>{const O=new Set;return H?.forEach(R=>{R.location&&O.add(R.location)}),Q?.forEach(R=>{R.target_location&&O.add(R.target_location)}),Array.from(O).sort()},[H,Q]),le=w.useCallback(O=>u?O.target_location?O.target_location===u:O.printer_id?H?.find(G=>G.id===O.printer_id)?.location===u:!1:!0,[u,H]),Le=w.useMemo(()=>{let O=Q?.filter(G=>G.status==="pending")||[];u&&(O=O.filter(le));const R=G=>{if(!G.scheduled_time)return 0;const de=tr(G.scheduled_time)?.getTime()??0,ge=Date.now()+4320*60*60*1e3;return de>ge?0:de};return[...O].sort((G,de)=>{let ge;if(L==="name"){const ae=G.archive_name||G.library_file_name||"",Ue=de.archive_name||de.library_file_name||"";ge=ae.localeCompare(Ue)}else L==="printer"?ge=(G.printer_name||"").localeCompare(de.printer_name||""):L==="time"?ge=R(G)-R(de):ge=G.position-de.position;return D?ge:-ge})},[Q,L,D,le,u]),V=()=>{const O=Le.map(R=>R.id);A.length===O.length?k([]):k(O)},K=w.useMemo(()=>{let O=Q?.filter(R=>R.status==="printing")||[];return u&&(O=O.filter(le)),O},[Q,u,le]),fe=w.useMemo(()=>{const O=new Set;return K.forEach(R=>{R.printer_id&&O.add(R.printer_id)}),Array.from(O)},[K]),Y=lv({queries:fe.map(O=>({queryKey:["printerStatus",O],queryFn:()=>J.getPrinterStatus(O),refetchInterval:5e3}))}),re=w.useMemo(()=>{const O={};return fe.forEach((R,G)=>{const de=Y[G];de?.data?.state&&(O[R]=de.data.state)}),O},[fe,Y]),ue=w.useMemo(()=>{let O=Q?.filter(R=>["completed","failed","skipped","cancelled"].includes(R.status))||[];return u&&(O=O.filter(le)),[...O].sort((R,G)=>{let de;if(j==="name"){const ge=R.archive_name||R.library_file_name||"",ae=G.archive_name||G.library_file_name||"";de=ge.localeCompare(ae)}else j==="printer"?de=(R.printer_name||"").localeCompare(G.printer_name||""):de=(tr(G.completed_at||G.created_at)?.getTime()??0)-(tr(R.completed_at||R.created_at)?.getTime()??0);return E?-de:de})},[Q,j,E,le,u]),Fe=w.useMemo(()=>Le.reduce((O,R)=>O+(R.print_time_seconds||0),0),[Le]),Pe=w.useMemo(()=>Le.reduce((O,R)=>O+(R.filament_used_grams||0),0),[Le]),be=O=>{const{active:R,over:G}=O;if(!G||R.id===G.id)return;const de=Le.findIndex(ae=>ae.id===R.id),ge=Le.findIndex(ae=>ae.id===G.id);if(de!==-1&&ge!==-1){const Ue=MA(Le,de,ge).map((ze,$e)=>({id:ze.id,position:$e+1}));oe.mutate(Ue)}};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(NX,{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(St,{className:"bg-gradient-to-br from-blue-500/10 to-transparent border-blue-500/20",children:a.jsx(Nt,{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(oo,{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:K.length}),a.jsx("p",{className:"text-xs sm:text-sm text-bambu-gray truncate",children:t("queue.summary.printing")})]})]})})}),a.jsx(St,{className:"bg-gradient-to-br from-yellow-500/10 to-transparent border-yellow-500/20",children:a.jsx(Nt,{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(qn,{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:Le.length}),a.jsx("p",{className:"text-xs sm:text-sm text-bambu-gray truncate",children:t("queue.summary.queued")})]})]})})}),a.jsx(St,{className:"bg-gradient-to-br from-bambu-green/10 to-transparent border-bambu-green/20",children:a.jsx(Nt,{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(Od,{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(Fe)}),a.jsx("p",{className:"text-xs sm:text-sm text-bambu-gray truncate",children:t("queue.summary.totalTime")})]})]})})}),a.jsx(St,{className:"bg-gradient-to-br from-purple-500/10 to-transparent border-purple-500/20",children:a.jsx(Nt,{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(EX,{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:Qie(Pe)}),a.jsx("p",{className:"text-xs sm:text-sm text-bambu-gray truncate",children:t("queue.summary.totalWeight")})]})]})})}),a.jsx(St,{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(Nt,{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(yr,{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:ue.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:O=>{const R=O.target.value;l(R==="unassigned"?-1:R===""?null:Number(R))},children:[a.jsx("option",{value:"",children:t("queue.filter.allPrinters")}),a.jsx("option",{value:"unassigned",children:t("queue.filter.unassigned")}),H?.map(O=>a.jsx("option",{value:O.id,children:O.name},O.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:O=>d(O.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")})]}),Ce.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:u,onChange:O=>h(O.target.value),children:[a.jsx("option",{value:"",children:t("queue.filter.allLocations")}),Ce.map(O=>a.jsx("option",{value:O,children:O},O))]}),a.jsx("div",{className:"hidden sm:block flex-1"}),ue.length>0&&a.jsxs(Me,{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(Yt,{className:"w-4 h-4"}),t("queue.clearHistory")]})]}),te?a.jsx("div",{className:"text-center py-12 text-bambu-gray",children:t("common.loading")}):Q?.length===0?a.jsxs(St,{className:"p-12 text-center border-dashed",children:[a.jsx(da,{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:[K.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:K.map(O=>a.jsx(Aj,{item:O,onEdit:()=>{},onCancel:()=>{},onRemove:()=>{},onStop:()=>N({type:"stop",item:O}),onRequeue:()=>{},onStart:()=>{},timeFormat:W,hasPermission:r,canModify:s,printerState:O.printer_id?re[O.printer_id]:null,t},O.id))})]}),Le.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(qn,{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:Le.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:L,onChange:O=>U(O.target.value),children:[a.jsx("option",{value:"position",children:t("queue.sort.byPosition")}),a.jsx("option",{value:"name",children:t("queue.sort.byName")}),a.jsx("option",{value:"printer",children:t("queue.sort.byPrinter")}),a.jsx("option",{value:"time",children:t("queue.sort.bySchedule")})]}),a.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>$(!D),title:t(D?"common.ascending":"common.descending"),className:"px-2",children:D?a.jsx(Mf,{className:"w-4 h-4"}):a.jsx(cb,{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(Me,{variant:"ghost",size:"sm",onClick:V,className:"flex items-center gap-1.5 sm:gap-2 text-xs sm:text-sm",children:[A.length===Le.length&&Le.length>0?a.jsx(co,{className:"w-4 h-4 text-bambu-green"}):a.jsx(Sl,{className:"w-4 h-4"}),A.length===Le.length&&Le.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(Me,{variant:"ghost",size:"sm",onClick:()=>C(!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(Ga,{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(Me,{variant:"ghost",size:"sm",onClick:()=>se.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:se.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(Rt,{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($ie,{sensors:q,collisionDetection:Pie,onDragEnd:be,children:a.jsx(Gie,{items:Le.map(O=>O.id),strategy:HQe,children:a.jsx("div",{className:"space-y-2 sm:space-y-3",children:Le.map((O,R)=>a.jsx(Aj,{item:O,position:R+1,onEdit:()=>v(O),onCancel:()=>N({type:"cancel",item:O}),onRemove:()=>{},onStop:()=>{},onRequeue:()=>{},onStart:()=>Se.mutate(O.id),timeFormat:W,isSelected:A.includes(O.id),onToggleSelect:()=>ce(O.id),hasPermission:r,canModify:s,t},O.id))})})})]}),ue.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(yr,{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:ue.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:j,onChange:O=>M(O.target.value),children:[a.jsx("option",{value:"date",children:t("queue.sort.byDate")}),a.jsx("option",{value:"name",children:t("queue.sort.byName")}),a.jsx("option",{value:"printer",children:t("queue.sort.byPrinter")})]}),a.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>B(!E),title:t(E?"queue.sort.ascendingOldest":"queue.sort.descendingNewest"),className:"px-2",children:E?a.jsx(Mf,{className:"w-4 h-4"}):a.jsx(cb,{className:"w-4 h-4"})})]})]}),a.jsx("div",{className:"space-y-2 sm:space-y-3",children:ue.slice(0,20).map((O,R)=>a.jsx(Aj,{item:O,position:R+1,onEdit:()=>{},onCancel:()=>{},onRemove:()=>N({type:"remove",item:O}),onStop:()=>{},onRequeue:()=>y(O),onStart:()=>{},timeFormat:W,hasPermission:r,canModify:s,t},O.id))})]})]}),x&&a.jsx(Yd,{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(Yd,{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(xn,{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"?X.mutate(_.item.id):_.type==="stop"?ee.mutate(_.item.id):Z.mutate(_.item.id),N(null)},onCancel:()=>N(null)}),f&&a.jsx(xn,{title:t("queue.confirm.clearHistoryTitle"),message:t("queue.confirm.clearHistoryMessage",{count:ue.length}),confirmText:t("queue.clearHistory"),variant:"danger",onConfirm:()=>{ie.mutate(),p(!1)},onCancel:()=>p(!1)}),P&&a.jsx(eZe,{selectedCount:A.length,printers:H?.map(O=>({id:O.id,name:O.name}))||[],onSave:O=>{Object.keys(O).length>0&&me.mutate({item_ids:A,...O})},onClose:()=>C(!1),isSaving:me.isPending,canControlPrinter:r("printers:control"),t})]})}function nZe({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 k=A[0]?.contentRect.width||0;i(k)});return N.observe(_),()=>N.disconnect()},[]);const{weeks:s,monthLabels:o,printCounts:l}=w.useMemo(()=>{const _={};t.forEach(B=>{const L=B.split("T")[0];_[L]=(_[L]||0)+1});const N=new Date,A=new Date(N);A.setMonth(A.getMonth()-e),A.setDate(A.getDate()-A.getDay());const k=[],P=[];let C=[],j=-1;const M=new Date(A);let E=0;for(;M<=N;)M.getDay()===0&&C.length>0&&(k.push(C),C=[],E++),M.getMonth()!==j&&(P.push({month:M.toLocaleDateString("en-US",{month:"short"}),weekIndex:E}),j=M.getMonth()),C.push(new Date(M)),M.setDate(M.getDate()+1);return C.length>0&&k.push(C),{weeks:k,monthLabels:P,printCounts:_}},[t,e]),c=Math.max(1,...Object.values(l)),d=_=>{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"},u=["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:u.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 k=_.find(M=>M.getDay()===A);if(!k)return a.jsx("div",{style:{width:g,height:g}},A);const P=k.toISOString().split("T")[0],C=l[P]||0,j=P===new Date().toISOString().split("T")[0];return a.jsx("div",{className:`rounded-sm ${d(C)} ${j?"ring-1 ring-white":""}`,style:{width:g,height:g},title:`${k.toLocaleDateString()}: ${C} print${C!==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 L_=["#00ae42","#3b82f6","#f59e0b","#ef4444","#8b5cf6","#ec4899","#14b8a6","#f97316"];function rZe(t){const e=new Date;switch(t){case"7d":return new Date(e.getTime()-10080*60*1e3);case"30d":return new Date(e.getTime()-720*60*60*1e3);case"90d":return new Date(e.getTime()-2160*60*60*1e3);case"365d":return new Date(e.getTime()-365*24*60*60*1e3);case"all":return new Date(0)}}function aZe({archives:t,currency:e="$"}){const[n,r]=w.useState("30d"),i=w.useMemo(()=>{const p=rZe(n);return t.filter(x=>(tr(x.completed_at||x.created_at)||new Date(0))>=p)},[t,n]),s=w.useMemo(()=>{const p=new Map;return i.forEach(x=>{const v=tr(x.completed_at||x.created_at)||new Date,g=`${v.getFullYear()}-${String(v.getMonth()+1).padStart(2,"0")}-${String(v.getDate()).padStart(2,"0")}`,y=p.get(g)||{date:g,filament:0,cost:0,prints:0};y.filament+=x.filament_used_grams||0,y.cost+=x.cost||0,y.prints+=x.quantity||1,p.set(g,y)}),Array.from(p.values()).sort((x,v)=>x.date.localeCompare(v.date)).map(x=>({...x,dateLabel:new Date(x.date).toLocaleDateString("en-US",{month:"short",day:"numeric"})}))},[i]),o=w.useMemo(()=>{if(n==="7d"||n==="30d")return s;const p=new Map;return i.forEach(x=>{const v=tr(x.completed_at||x.created_at)||new Date,g=new Date(v);g.setDate(v.getDate()-v.getDay());const y=`${g.getFullYear()}-${String(g.getMonth()+1).padStart(2,"0")}-${String(g.getDate()).padStart(2,"0")}`,_=p.get(y)||{week:y,filament:0,cost:0,prints:0};_.filament+=x.filament_used_grams||0,_.cost+=x.cost||0,_.prints+=x.quantity||1,p.set(y,_)}),Array.from(p.values()).sort((x,v)=>x.week.localeCompare(v.week)).map(x=>({date:x.week,dateLabel:`Week of ${new Date(x.week).toLocaleDateString("en-US",{month:"short",day:"numeric"})}`,...x}))},[i,s,n]),l=w.useMemo(()=>{const p=new Map;return i.forEach(x=>{const g=(x.filament_type||"Unknown").split(", ");g.forEach(y=>{const _=(x.filament_used_grams||0)/g.length;p.set(y,(p.get(y)||0)+_)})}),Array.from(p.entries()).map(([x,v])=>({name:x,value:Math.round(v)})).sort((x,v)=>v.value-x.value)},[i]),c=w.useMemo(()=>{const p=new Date,x=[];for(let v=5;v>=0;v--){const g=new Date(p.getFullYear(),p.getMonth()-v,1),y=new Date(p.getFullYear(),p.getMonth()-v+1,0),_=g.toLocaleDateString("en-US",{month:"short",year:"2-digit"}),N=t.filter(A=>{const k=tr(A.completed_at||A.created_at)||new Date(0);return k>=g&&k<=y});x.push({month:_,filament:Math.round(N.reduce((A,k)=>A+(k.filament_used_grams||0),0)),cost:N.reduce((A,k)=>A+(k.cost||0),0),prints:N.reduce((A,k)=>A+(k.quantity||1),0)})}return x},[t]),d=n==="7d"||n==="30d"?s:o,u=i.reduce((p,x)=>p+(x.filament_used_grams||0),0),h=i.reduce((p,x)=>p+(x.cost||0),0),f=i.reduce((p,x)=>p+(x.quantity||1),0);return a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"flex items-center justify-between max-[550px]:flex-col max-[550px]:items-start max-[550px]:gap-2",children:[a.jsx("h3",{className:"text-lg font-semibold text-white",children:"Filament Usage Trends"}),a.jsx("div",{className:"flex gap-1 bg-bambu-dark rounded-lg p-1",children:["7d","30d","90d","365d","all"].map(p=>a.jsx("button",{onClick:()=>r(p),className:`px-3 py-1 text-sm rounded-md transition-colors ${n===p?"bg-bambu-green text-white":"text-bambu-gray hover:text-white"}`,children:p==="all"?"All":p.replace("d","D")},p))})]}),a.jsxs("div",{className:"grid grid-cols-3 gap-4 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-3",children:[a.jsx("p",{className:"text-sm text-bambu-gray leading-none",children:"Period Filament"}),a.jsxs("p",{className:"text-2xl font-bold text-white leading-none",children:[(u/1e3).toFixed(2),"kg"]})]}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:[u.toFixed(0),"g total"]})]}),a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[a.jsxs("div",{className:"flex items-center justify-between gap-3",children:[a.jsx("p",{className:"text-sm text-bambu-gray leading-none",children:"Period Cost"}),a.jsxs("p",{className:"text-2xl font-bold text-white leading-none",children:[e,h.toFixed(2)]})]}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:[f," prints"]})]}),a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[a.jsxs("div",{className:"flex items-center justify-between gap-3",children:[a.jsx("p",{className:"text-sm text-bambu-gray leading-none",children:"Avg per Print"}),a.jsxs("p",{className:"text-2xl font-bold text-white leading-none",children:[f>0?(u/f).toFixed(0):0,"g"]})]}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:[e,f>0?(h/f).toFixed(2):"0.00"," avg"]})]})]}),d.length>0?a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[a.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"Usage Over Time"}),a.jsx(e1,{width:"100%",height:250,children:a.jsxs(a$e,{data:d,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(DN,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),a.jsx(ON,{dataKey:"dateLabel",stroke:"#9ca3af",tick:{fontSize:12},interval:"preserveStartEnd"}),a.jsx(IN,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:p=>`${p}g`}),a.jsx(n1,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},labelStyle:{color:"#fff"},formatter:p=>[`${Number(p??0).toFixed(0)}g`,"Filament"]}),a.jsx(Jte,{type:"monotone",dataKey:"filament",stroke:"#00ae42",strokeWidth:2,fillOpacity:1,fill:"url(#colorFilament)"})]})})]}):a.jsx("div",{className:"bg-bambu-dark rounded-lg p-8 text-center text-bambu-gray",children:"No data for selected time range"}),a.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[a.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"By Filament Type"}),l.length>0?a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsx(e1,{width:160,height:160,children:a.jsxs(n$e,{children:[a.jsx(Cte,{data:l,cx:"50%",cy:"50%",innerRadius:40,outerRadius:70,paddingAngle:2,dataKey:"value",children:l.map((p,x)=>a.jsx(Ov,{fill:L_[x%L_.length]},`cell-${x}`))}),a.jsx(n1,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},formatter:p=>[`${p??0}g`,"Usage"]})]})}),a.jsx("div",{className:"flex-1 space-y-2 overflow-hidden",children:l.map((p,x)=>{const v=l.reduce((y,_)=>y+_.value,0),g=v>0?(p.value/v*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:L_[x%L_.length]}}),a.jsx("span",{className:"text-white truncate flex-1",children:p.name}),a.jsxs("span",{className:"text-bambu-gray flex-shrink-0",children:[g,"%"]})]},p.name)})})]}):a.jsx("div",{className:"h-[160px] flex items-center justify-center text-bambu-gray",children:"No filament data"})]}),a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[a.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"Monthly Comparison"}),a.jsx(e1,{width:"100%",height:200,children:a.jsxs(VHe,{data:c,children:[a.jsx(DN,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),a.jsx(ON,{dataKey:"month",stroke:"#9ca3af",tick:{fontSize:12}}),a.jsx(IN,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:p=>`${p}g`}),a.jsx(n1,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},formatter:(p,x)=>[x==="filament"?`${p??0}g`:x==="cost"?`${e}${Number(p??0).toFixed(2)}`:p??0,x==="filament"?"Filament":x==="cost"?"Cost":"Prints"]}),a.jsx(zL,{}),a.jsx(ane,{dataKey:"filament",name:"Filament (g)",fill:"#00ae42",radius:[4,4,0,0]})]})})]})]})]})}function iZe({id:t,title:e,component:n,isHidden:r,size:i,columnSpan:s,onToggleVisibility:o,onToggleSize:l}){const{attributes:c,listeners:d,setNodeRef:u,transform:h,transition:f,isDragging:p}=Kie({id:t}),x={transform:Ob.Transform.toString(h),transition:f,opacity:p?.5:1};return r?null:a.jsxs("div",{ref:u,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,...d,className:"cursor-grab active:cursor-grabbing p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:"Drag to reorder",children:a.jsx(jh,{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(TF,{className:"w-4 h-4 text-bambu-gray hover:text-white"}):a.jsx(WC,{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(cv,{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 sZe({widgets:t,storageKey:e,columns:n=4,stackBelow:r,hideControls:i=!1,onResetLayout:s,renderControls:o}){const l=()=>{const j={};return t.forEach(M=>{j[M.id]=M.defaultSize||4}),j},[c,d]=w.useState(()=>{const j=localStorage.getItem(e);if(j)try{const M=JSON.parse(j);return M.sizes||(M.sizes=l()),M}catch{}return{order:t.map(M=>M.id),hidden:t.filter(M=>M.defaultVisible===!1).map(M=>M.id),sizes:l()}}),[u,h]=w.useState(!1),[f,p]=w.useState(!1);w.useEffect(()=>{if(!r)return;const j=window.matchMedia(`(max-width: ${r}px)`),M=B=>{p(B.matches)};M(j);const E=B=>M(B);return j.addEventListener?j.addEventListener("change",E):j.addListener(E),()=>{j.removeEventListener?j.removeEventListener("change",E):j.removeListener(E)}},[r]);const x=r&&f?1:n;w.useEffect(()=>{const j=()=>h(M=>!M);return window.addEventListener("toggle-hidden-panel",j),()=>window.removeEventListener("toggle-hidden-panel",j)},[]),w.useEffect(()=>{localStorage.setItem(e,JSON.stringify(c))},[c,e]),w.useEffect(()=>{const M=t.map(E=>E.id).filter(E=>!c.order.includes(E));M.length>0&&d(E=>({...E,order:[...E.order,...M]}))},[t,c.order]);const v=kie(FC(kA,{activationConstraint:{distance:8}}),FC(CA,{coordinateGetter:Xie})),g=j=>{const{active:M,over:E}=j;E&&M.id!==E.id&&d(B=>{const L=B.order.indexOf(M.id),U=B.order.indexOf(E.id);return{...B,order:MA(B.order,L,U)}})},y=j=>{d(M=>({...M,hidden:M.hidden.includes(j)?M.hidden.filter(E=>E!==j):[...M.hidden,j]}))},_=j=>{d(M=>{const E=M.sizes[j]||4,B=E===1?2:E===2?4:1;return{...M,sizes:{...M.sizes,[j]:B}}})},N=()=>{const j={order:t.map(M=>M.id),hidden:t.filter(M=>M.defaultVisible===!1).map(M=>M.id),sizes:l()};d(j),s?.()},A=c.order.map(j=>t.find(M=>M.id===j)).filter(Boolean),k=A.filter(j=>!c.hidden.includes(j.id)),P=A.filter(j=>c.hidden.includes(j.id)),C=o?.({hiddenCount:P.length,showHiddenPanel:u,setShowHiddenPanel:h,resetLayout:N});return a.jsxs("div",{className:"space-y-4",children:[C,!i&&!o&&a.jsxs("div",{className:"flex items-center justify-end gap-2",children:[a.jsxs(Me,{variant:"secondary",size:"sm",onClick:N,children:[a.jsx(lo,{className:"w-4 h-4"}),"Reset Layout"]}),P.length>0&&a.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>h(!u),children:[a.jsx(Zl,{className:"w-4 h-4"}),P.length," Hidden"]})]}),u&&P.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:P.map(j=>a.jsxs("button",{onClick:()=>y(j.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(Zl,{className:"w-3 h-3"}),j.title]},j.id))})]}),a.jsx($ie,{sensors:v,collisionDetection:Pie,onDragEnd:g,children:a.jsx(Gie,{items:k.map(j=>j.id),strategy:uI,children:a.jsx("div",{className:"grid gap-6",style:{gridTemplateColumns:`repeat(${x}, minmax(0, 1fr))`},children:k.map(j=>{const M=c.sizes[j.id]||2,E=Math.min(M,x);return a.jsx(iZe,{id:j.id,title:j.title,component:j.component,isHidden:c.hidden.includes(j.id),size:M,columnSpan:E,onToggleVisibility:()=>y(j.id),onToggleSize:()=>_(j.id)},j.id)})})})}),k.length===0&&a.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[a.jsx("p",{children:"All widgets are hidden."}),a.jsx(Me,{className:"mt-4",onClick:N,children:"Reset Layout"})]})]})}function oZe({stats:t,currency:e,t:n}){return a.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-4",children:[a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-bambu-green",children:a.jsx(fi,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray",children:n("stats.totalPrints")}),a.jsx("p",{className:"text-xl font-bold text-white",children:t?.total_prints||0})]})]}),a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-blue-400",children:a.jsx(qn,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray",children:n("stats.printTime")}),a.jsxs("p",{className:"text-xl font-bold text-white",children:[t?.total_print_time_hours.toFixed(1)||0,"h"]})]})]}),a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-orange-400",children:a.jsx(fi,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray",children:n("stats.filamentUsed")}),a.jsxs("p",{className:"text-xl font-bold text-white",children:[((t?.total_filament_grams||0)/1e3).toFixed(2),"kg"]})]})]}),a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-green-400",children:a.jsx(a3,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray",children:n("stats.filamentCost")}),a.jsxs("p",{className:"text-xl font-bold text-white",children:[e," ",t?.total_cost.toFixed(2)||"0.00"]})]})]}),a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-yellow-400",children:a.jsx(ru,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray",children:n("stats.energyUsed")}),a.jsxs("p",{className:"text-xl font-bold text-white",children:[t?.total_energy_kwh.toFixed(3)||"0.000"," kWh"]})]})]}),a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-yellow-500",children:a.jsx(a3,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray",children:n("stats.energyCost")}),a.jsxs("p",{className:"text-xl font-bold text-white",children:[e," ",t?.total_energy_cost.toFixed(2)||"0.00"]})]})]})]})}function lZe({stats:t,printerMap:e,size:n=1,t:r}){const i=t?.total_prints?Math.round(t.successful_prints/t.total_prints*100):0,s=n===1?112:n===2?128:144,o=s/2-8,l=o*2*Math.PI;return a.jsxs("div",{className:"flex items-center gap-6",children:[a.jsxs("div",{className:"relative flex-shrink-0",style:{width:s,height:s},children:[a.jsxs("svg",{className:"w-full h-full -rotate-90",children:[a.jsx("circle",{cx:s/2,cy:s/2,r:o,fill:"none",stroke:"#3d3d3d",strokeWidth:"10"}),a.jsx("circle",{cx:s/2,cy:s/2,r:o,fill:"none",stroke:"#00ae42",strokeWidth:"10",strokeLinecap:"round",strokeDasharray:`${i/100*l} ${l}`})]}),a.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:a.jsxs("span",{className:`font-bold text-white ${n>=2?"text-2xl":"text-xl"}`,children:[i,"%"]})})]}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(yr,{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(mi,{className:"w-4 h-4 text-status-error flex-shrink-0"}),a.jsx("span",{className:"text-sm text-bambu-gray",children:r("stats.failed")}),a.jsx("span",{className:"text-sm text-white font-medium",children:t?.failed_prints||0})]})]}),n>=2&&t?.prints_by_printer&&Object.keys(t.prints_by_printer).length>0&&a.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[a.jsx("p",{className:"text-xs text-bambu-gray font-medium mb-2",children:r("stats.printsByPrinter")}),a.jsx("div",{className:`grid gap-x-6 gap-y-1 ${n===4?"grid-cols-3":"grid-cols-2"}`,style:{width:"fit-content"},children:Object.entries(t.prints_by_printer).map(([c,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(c)||`${r("common.printer")} ${c}`}),a.jsx("span",{className:"text-white font-medium",children:d})]},c))})]})]})]})}function cZe({stats:t,printerMap:e,size:n=1,t:r}){const i=t?.average_time_accuracy;if(i==null)return a.jsx("div",{className:"flex items-center justify-center h-full",children:a.jsx("p",{className:"text-bambu-gray text-center py-4",children:r("stats.noTimeAccuracyData")})});const o=(Math.min(150,Math.max(50,i))-50)/100*100,c=(v=>v>=95&&v<=105?"#00ae42":v>105?"#3b82f6":"#f97316")(i),d=i-100,u=n===1?112:n===2?128:144,h=u/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:u,height:u},children:[a.jsxs("svg",{className:"w-full h-full -rotate-90",children:[a.jsx("circle",{cx:u/2,cy:u/2,r:h,fill:"none",stroke:"#3d3d3d",strokeWidth:"10"}),a.jsx("circle",{cx:u/2,cy:u/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 ${d>=0?"text-blue-400":"text-orange-400"}`,children:[d>=0?"+":"",d.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(MX,{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 dZe({stats:t,size:e=1,t:n}){if(!t?.prints_by_filament_type||Object.keys(t.prints_by_filament_type).length===0)return a.jsx("p",{className:"text-bambu-gray text-center py-4",children:n("stats.noFilamentData")});const r=Object.entries(t.prints_by_filament_type).sort(([,l],[,c])=>c-l),i=e===1?5:e===2?8:999,s=r.slice(0,i),o=r.length>i;return e===4&&s.length>4?a.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-3 gap-4",children:s.map(([l,c])=>{const d=Math.round(c/(t.total_prints||1)*100);return a.jsxs("div",{children:[a.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[a.jsx("span",{className:"text-white truncate max-w-[120px]",children:l}),a.jsx("span",{className:"text-bambu-gray",children:c})]}),a.jsx("div",{className:"h-2 bg-bambu-dark rounded-full",children:a.jsx("div",{className:"h-full bg-bambu-green rounded-full transition-all",style:{width:`${d}%`}})})]},l)})}):a.jsxs("div",{className:"space-y-3",children:[s.map(([l,c])=>{const d=Math.round(c/(t.total_prints||1)*100);return a.jsxs("div",{children:[a.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[a.jsx("span",{className:"text-white",children:l}),a.jsxs("span",{className:"text-bambu-gray",children:[c," ",n("common.prints")]})]}),a.jsx("div",{className:"h-2 bg-bambu-dark rounded-full",children:a.jsx("div",{className:"h-full bg-bambu-green rounded-full transition-all",style:{width:`${d}%`}})})]},l)}),o&&a.jsx("p",{className:"text-xs text-bambu-gray text-center pt-1",children:n("common.more",{count:r.length-i})})]})}function uZe({printDates:t,size:e=2}){const n=e===1?3:e===2?6:12;return a.jsx(nZe,{printDates:t,months:n})}function hZe({stats:t,printerMap:e,t:n}){return!t?.prints_by_printer||Object.keys(t.prints_by_printer).length===0?a.jsx("p",{className:"text-bambu-gray text-center py-4",children:n("stats.noPrinterData")}):a.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:Object.entries(t.prints_by_printer).map(([r,i])=>a.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[a.jsx("div",{className:"p-2 bg-bambu-dark-tertiary rounded-lg",children:a.jsx(Nr,{className:"w-4 h-4 text-bambu-green"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-white font-medium text-sm",children:e.get(r)||`${n("common.printer")} ${r}`}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:[i," ",n("common.prints")]})]})]},r))})}function mZe({archives:t,currency:e,t:n}){return!t||t.length===0?a.jsx("p",{className:"text-bambu-gray text-center py-4",children:n("stats.noPrintData")}):a.jsx(aZe,{archives:t,currency:e})}function fZe({size:t=1,t:e}){const{data:n,isLoading:r}=Ze({queryKey:["failureAnalysis"],queryFn:()=>J.getFailureAnalysis({days:30})});if(r)return a.jsx("div",{className:"flex justify-center py-4",children:a.jsx(at,{className:"w-6 h-6 text-bambu-green animate-spin"})});if(!n||n.total_prints===0)return a.jsx("p",{className:"text-bambu-gray text-center py-4",children:e("stats.noPrintDataLast30Days")});const i=t===1?5:t===2?8:999,s=Object.entries(n.failures_by_reason).sort(([,c],[,d])=>d-c),o=s.slice(0,i),l=s.length>i;return a.jsxs("div",{className:`${t>=2?"flex gap-8":"space-y-4"}`,children:[a.jsxs("div",{className:t>=2?"flex-shrink-0":"",children:[a.jsx("div",{className:"flex items-center gap-4",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(An,{className:`w-5 h-5 ${n.failure_rate>20?"text-status-error":n.failure_rate>10?"text-status-warning":"text-status-ok"}`}),a.jsxs("span",{className:`font-bold text-white ${t>=2?"text-3xl":"text-2xl"}`,children:[n.failure_rate.toFixed(1),"%"]})]})}),a.jsx("div",{className:"text-sm text-bambu-gray mt-1",children:e("stats.failedPrintsCount",{failed:n.failed_prints,total:n.total_prints})}),n.trend&&n.trend.length>=2&&a.jsx("div",{className:`${t>=2?"mt-4":"mt-2 pt-2 border-t border-bambu-dark-tertiary"}`,children:a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx(EF,{className:`w-4 h-4 ${n.trend[n.trend.length-1].failure_rate<n.trend[n.trend.length-2].failure_rate?"text-status-ok":"text-status-error"}`}),a.jsx("span",{className:"text-bambu-gray",children:e("stats.lastWeekRate",{rate:n.trend[n.trend.length-1].failure_rate.toFixed(1)})})]})})]}),o.length>0&&a.jsxs("div",{className:`flex-1 ${t>=2?"border-l border-bambu-dark-tertiary pl-8":"pt-2"}`,children:[a.jsx("p",{className:"text-xs text-bambu-gray font-medium mb-2",children:t>=2?e("stats.failureReasons"):e("stats.topFailureReasons")}),a.jsx("div",{className:`${t===4?"grid grid-cols-2 gap-x-6 gap-y-1":"space-y-1"}`,children:o.map(([c,d])=>a.jsxs("div",{className:"flex items-center justify-between text-sm",children:[a.jsx("span",{className:`text-white truncate ${t===4?"max-w-[200px]":"max-w-[160px]"}`,children:c||e("common.unknown")}),a.jsx("span",{className:"text-bambu-gray ml-2",children:d})]},c))}),l&&a.jsx("p",{className:"text-xs text-bambu-gray mt-2",children:e("common.more",{count:s.length-i})})]})]})}function pZe(){const{t}=Dt(),{showToast:e}=dn(),{hasPermission:n}=jr(),[r,i]=w.useState(!1),[s,o]=w.useState(!1),[l,c]=w.useState(0),[d,u]=w.useState(0),[h,f]=w.useState(!1);w.useEffect(()=>{const M=()=>{try{const B=localStorage.getItem("bambusy-dashboard-layout");if(B){const L=JSON.parse(B);u(L.hidden?.length||0)}}catch{u(0)}};M(),window.addEventListener("storage",M);const E=setInterval(M,500);return()=>{window.removeEventListener("storage",M),clearInterval(E)}},[l]);const{data:p,isLoading:x,refetch:v}=Ze({queryKey:["archiveStats"],queryFn:J.getArchiveStats}),{data:g}=Ze({queryKey:["printers"],queryFn:J.getPrinters}),{data:y}=Ze({queryKey:["archives"],queryFn:()=>J.getArchives(void 0,void 0,1e3,0)}),{data:_}=Ze({queryKey:["settings"],queryFn:J.getSettings}),N=async M=>{o(!1),i(!0);try{const{blob:E,filename:B}=await J.exportStats({format:M,days:90}),L=URL.createObjectURL(E),U=document.createElement("a");U.href=L,U.download=B,U.click(),URL.revokeObjectURL(L),e(t("stats.exportDownloaded"))}catch{e(t("stats.exportFailed"),"error")}finally{i(!1)}},A=async()=>{f(!0);try{const M=await J.recalculateCosts();await v(),e(t("stats.recalculatedCosts",{count:M.updated}))}catch{e(t("stats.recalculateFailed"),"error")}finally{f(!1)}},k=il(_?.currency||"USD"),P=new Map(g?.map(M=>[String(M.id),M.name])||[]),C=y?.map(M=>M.created_at)||[];if(x)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 j=[{id:"quick-stats",title:t("stats.quickStats"),component:a.jsx(oZe,{stats:p,currency:k,t}),defaultSize:2},{id:"success-rate",title:t("stats.successRate"),component:M=>a.jsx(lZe,{stats:p,printerMap:P,size:M,t}),defaultSize:1},{id:"time-accuracy",title:t("stats.timeAccuracy"),component:M=>a.jsx(cZe,{stats:p,printerMap:P,size:M,t}),defaultSize:1},{id:"filament-types",title:t("stats.filamentTypes"),component:M=>a.jsx(dZe,{stats:p,size:M,t}),defaultSize:1},{id:"failure-analysis",title:t("stats.failureAnalysis"),component:M=>a.jsx(fZe,{size:M,t}),defaultSize:1},{id:"print-activity",title:t("stats.printActivity"),component:M=>a.jsx(uZe,{printDates:C,size:M}),defaultSize:2},{id:"prints-by-printer",title:t("stats.printsByPrinter"),component:a.jsx(hZe,{stats:p,printerMap:P,t}),defaultSize:2},{id:"filament-trends",title:t("stats.filamentTrends"),component:a.jsx(mZe,{archives:y||[],currency:k,t}),defaultSize:4}];return a.jsxs("div",{className:"p-4 md:p-8",children:[a.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4 mb-6",children:[a.jsxs("div",{children:[a.jsx("h1",{className:"text-2xl font-bold text-white",children:t("stats.title")}),a.jsx("p",{className:"text-bambu-gray",children:t("stats.subtitle")})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[d>0&&a.jsxs(Me,{variant:"secondary",onClick:()=>{window.dispatchEvent(new CustomEvent("toggle-hidden-panel"))},children:[a.jsx(Zl,{className:"w-4 h-4"}),t("stats.hiddenCount",{count:d})]}),a.jsxs(Me,{variant:"secondary",onClick:()=>{localStorage.removeItem("bambusy-dashboard-layout"),c(M=>M+1),e(t("stats.layoutReset"))},disabled:!n("settings:update"),title:n("settings:update")?void 0:t("stats.noPermissionResetLayout"),children:[a.jsx(lo,{className:"w-4 h-4"}),t("stats.resetLayout")]}),a.jsxs(Me,{variant:"secondary",onClick:A,disabled:h||!n("archives:update_all"),title:n("archives:update_all")?t("stats.recalculateCostsHint"):t("stats.noPermissionRecalculate"),children:[h?a.jsx(at,{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(Me,{variant:"secondary",onClick:()=>o(!s),disabled:r,children:[r?a.jsx(at,{className:"w-4 h-4 animate-spin"}):a.jsx(v1,{className:"w-4 h-4"}),t("stats.exportStats")]}),s&&a.jsxs("div",{className:"absolute right-0 top-full mt-1 w-48 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl z-20",children:[a.jsxs("button",{className:"w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-t-lg",onClick:()=>N("csv"),children:[a.jsx(Ps,{className:"w-4 h-4"}),t("stats.exportAsCsv")]}),a.jsxs("button",{className:"w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-b-lg",onClick:()=>N("xlsx"),children:[a.jsx(v1,{className:"w-4 h-4"}),t("stats.exportAsExcel")]})]})]})]})]}),a.jsx(sZe,{widgets:j,storageKey:"bambusy-dashboard-layout",stackBelow:640,hideControls:!0},l)]})}function gZe({plug:t,onEdit:e}){const{t:n}=Dt(),r=Qt(),{showToast:i}=dn(),[s,o]=w.useState(!1),[l,c]=w.useState(!1),[d,u]=w.useState(!1),[h,f]=w.useState(!1),{data:p,isLoading:x}=Ze({queryKey:["smart-plug-status",t.id],queryFn:()=>J.getSmartPlugStatus(t.id),refetchInterval:3e4}),{data:v}=Ze({queryKey:["printers"],queryFn:J.getPrinters}),g=v?.find(E=>E.id===t.printer_id),y=st({mutationFn:E=>J.controlSmartPlug(t.id,E),onMutate:async E=>{await r.cancelQueries({queryKey:["smart-plug-status",t.id]});const B=r.getQueryData(["smart-plug-status",t.id]),L=E==="on"?"ON":E==="off"||p?.state==="ON"?"OFF":"ON";return r.setQueryData(["smart-plug-status",t.id],U=>({...U,state:L})),{previousStatus:B}},onError:(E,B,L)=>{L?.previousStatus&&r.setQueryData(["smart-plug-status",t.id],L.previousStatus),i(`Failed to turn ${B} "${t.name}"`,"error")},onSettled:()=>{setTimeout(()=>{r.invalidateQueries({queryKey:["smart-plug-status",t.id]}),r.invalidateQueries({queryKey:["smart-plugs"]})},1e3)}}),_=st({mutationFn:E=>J.updateSmartPlug(t.id,E),onSuccess:()=>{r.invalidateQueries({queryKey:["smart-plugs"]}),t.printer_id&&(r.invalidateQueries({queryKey:["smartPlugByPrinter",t.printer_id]}),r.invalidateQueries({queryKey:["scriptPlugsByPrinter",t.printer_id]}))}}),N=st({mutationFn:()=>J.deleteSmartPlug(t.id),onSuccess:()=>{r.invalidateQueries({queryKey:["smart-plugs"]}),t.printer_id&&r.invalidateQueries({queryKey:["scriptPlugsByPrinter",t.printer_id]})}}),A=p?.state==="ON",k=t.plug_type==="mqtt"&&p?.energy?.power!==null&&p?.energy?.power!==void 0,P=(p?.reachable??!1)||k,C=y.isPending,M=(()=>{if(t.plug_type!=="tasmota"||!t.ip_address)return null;const E=t.ip_address;return t.username&&t.password?`http://${encodeURIComponent(t.username)}:${encodeURIComponent(t.password)}@${E}/`:`http://${E}/`})();return a.jsxs(a.Fragment,{children:[a.jsx(St,{className:"relative",children:a.jsxs(Nt,{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"?P?"bg-teal-500/20":"bg-red-500/20":P?A?"bg-bambu-green/20":"bg-bambu-dark":"bg-red-500/20"}`,children:t.plug_type==="mqtt"?a.jsx(MF,{className:`w-5 h-5 ${P?"text-teal-400":"text-red-400"}`}):t.plug_type==="homeassistant"?a.jsx(dv,{className:`w-5 h-5 ${P?A?"text-bambu-green":"text-bambu-gray":"text-red-400"}`}):a.jsx(gl,{className:`w-5 h-5 ${P?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(at,{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"}),P&&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:P?A?"text-status-ok":"text-bambu-gray":"text-status-error",children:P?p?.state||"?":"Offline"})]}):P?a.jsxs("div",{className:"flex items-center gap-1 text-sm",children:[a.jsx(Wg,{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(Gh,{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(ta,{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(Zl,{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(qg,{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(da,{className:"w-3 h-3"}),t.schedule_on_time&&t.schedule_off_time?`${t.schedule_on_time} - ${t.schedule_off_time}`:t.schedule_on_time?`On ${t.schedule_on_time}`:`Off ${t.schedule_off_time}`]})]}),t.plug_type!=="mqtt"&&a.jsxs("div",{className:"flex gap-2 mb-3",children:[a.jsxs(Me,{size:"sm",variant:A?"primary":"secondary",disabled:!P||C,onClick:()=>c(!0),className:"flex-1",children:[C?a.jsx(at,{className:"w-4 h-4 animate-spin"}):a.jsx(fu,{className:"w-4 h-4"}),"On"]}),a.jsxs(Me,{size:"sm",variant:A?"secondary":"primary",disabled:!P||C,onClick:()=>u(!0),className:"flex-1",children:[C?a.jsx(at,{className:"w-4 h-4 animate-spin"}):a.jsx(YC,{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(tu,{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(uv,{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:E=>_.mutate({show_in_switchbar:E.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:E=>_.mutate({enabled:E.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:E=>_.mutate({auto_on:E.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:E=>_.mutate({auto_off:E.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(qn,{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(JC,{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:E=>_.mutate({off_delay_minutes:parseInt(E.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:E=>_.mutate({off_temp_threshold:parseInt(E.target.value)||70}),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Turns off when nozzle cools below this temperature"})]})]})]}),a.jsxs("div",{className:"flex gap-2 pt-2",children:[a.jsxs(Me,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[a.jsx(ef,{className:"w-4 h-4"}),"Edit"]}),a.jsx(Me,{size:"sm",variant:"secondary",onClick:()=>o(!0),className:"text-red-400 hover:text-red-300",children:a.jsx(Yt,{className:"w-4 h-4"})})]})]})]})}),s&&a.jsx(xn,{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(xn,{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)}),d&&a.jsx(xn,{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"),u(!1)},onCancel:()=>u(!1)})]})}function bZe({plug:t,onClose:e}){const{t:n}=Dt(),r=Qt(),i=!!t,[s,o]=w.useState(t?.plug_type||"tasmota"),[l,c]=w.useState(t?.name||""),[d,u]=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||""),[k,P]=w.useState((t?.mqtt_power_multiplier??t?.mqtt_multiplier??1).toString()),[C,j]=w.useState(t?.mqtt_energy_topic||""),[M,E]=w.useState(t?.mqtt_energy_path||""),[B,L]=w.useState((t?.mqtt_energy_multiplier??1).toString()),[U,D]=w.useState(t?.mqtt_state_topic||""),[$,q]=w.useState(t?.mqtt_state_path||""),[z,W]=w.useState(t?.mqtt_state_on_value||""),[Q,te]=w.useState(t?.ha_power_entity||""),[H,X]=w.useState(t?.ha_energy_today_entity||""),[Z,ee]=w.useState(t?.ha_energy_total_entity||""),[Se,oe]=w.useState(""),[ie,me]=w.useState(""),[se,ce]=w.useState(!1),Ce=w.useRef(null),[le,Le]=w.useState(""),[V,K]=w.useState(!1),fe=w.useRef(null),[Y,re]=w.useState(""),[ue,Fe]=w.useState(!1),Pe=w.useRef(null),[be,O]=w.useState(""),[R,G]=w.useState(!1),de=w.useRef(null),[ge,ae]=w.useState(t?.printer_id||null),[Ue,ze]=w.useState(null),[$e,Re]=w.useState(null),[pe,ve]=w.useState(t?.power_alert_enabled||!1),[Ne,xe]=w.useState(t?.power_alert_high?.toString()||""),[we,qe]=w.useState(t?.power_alert_low?.toString()||""),[ke,nt]=w.useState(t?.schedule_enabled||!1),[De,We]=w.useState(t?.schedule_on_time||""),[Oe,je]=w.useState(t?.schedule_off_time||""),[Ve,ot]=w.useState(t?.show_in_switchbar||!1),[kt,Ft]=w.useState(t?.show_on_printer_card??!0),[Vt,At]=w.useState(!1),[Be,mt]=w.useState({scanned:0,total:0}),[yt,zt]=w.useState([]),yn=w.useRef(null),{data:gr}=Ze({queryKey:["printers"],queryFn:J.getPrinters}),{data:sr}=Ze({queryKey:["smart-plugs"],queryFn:J.getSmartPlugs}),{data:nr}=Ze({queryKey:["settings"],queryFn:J.getSettings}),Gn=!!(nr?.ha_enabled&&nr?.ha_url&&nr?.ha_token);w.useEffect(()=>{const Te=setTimeout(()=>{me(Se)},300);return()=>clearTimeout(Te)},[Se]),w.useEffect(()=>{const Te=ct=>{Ce.current&&!Ce.current.contains(ct.target)&&ce(!1),fe.current&&!fe.current.contains(ct.target)&&K(!1),Pe.current&&!Pe.current.contains(ct.target)&&Fe(!1),de.current&&!de.current.contains(ct.target)&&G(!1)};return document.addEventListener("mousedown",Te),()=>document.removeEventListener("mousedown",Te)},[]);const{data:br,isLoading:or,error:oi}=Ze({queryKey:["ha-entities",ie],queryFn:()=>J.getHAEntities(ie||void 0),enabled:s==="homeassistant"&&Gn,retry:!1,staleTime:0}),{data:Ie}=Ze({queryKey:["ha-sensor-entities"],queryFn:J.getHASensorEntities,enabled:s==="homeassistant"&&Gn,retry:!1,staleTime:0});w.useEffect(()=>{const Te=ct=>{ct.key==="Escape"&&e()};return window.addEventListener("keydown",Te),()=>{window.removeEventListener("keydown",Te),yn.current&&clearInterval(yn.current)}},[e]);const _e=async()=>{At(!0),zt([]),mt({scanned:0,total:0}),Re(null);try{await J.startTasmotaScan();const Te=async()=>{try{const ct=await J.getTasmotaScanStatus();mt({scanned:ct.scanned,total:ct.total});const gt=await J.getDiscoveredTasmotaDevices();zt(gt),ct.running||(At(!1),yn.current&&(clearInterval(yn.current),yn.current=null))}catch(ct){console.error("Polling error:",ct)}};await Te(),yn.current=setInterval(Te,500)}catch(Te){At(!1);const ct=Te instanceof Error?Te.message:typeof Te=="string"?Te:JSON.stringify(Te);Re(ct||"Failed to start scan")}},tt=async()=>{try{await J.stopTasmotaScan()}catch{}At(!1),yn.current&&(clearInterval(yn.current),yn.current=null)},it=Te=>{u(Te.ip_address),c(Te.name),ze(null)},Ke=st({mutationFn:()=>J.testSmartPlugConnection(d,h||null,p||null),onSuccess:Te=>{ze(Te),Re(null),!l&&Te.device_name&&c(Te.device_name)},onError:Te=>{ze(null),Re(Te.message)}}),Lt=st({mutationFn:Te=>J.createSmartPlug(Te),onSuccess:()=>{r.invalidateQueries({queryKey:["smart-plugs"]}),r.invalidateQueries({queryKey:["scriptPlugsByPrinter"]}),e()},onError:Te=>{Re(Te.message)}}),ye=st({mutationFn:Te=>J.updateSmartPlug(t.id,Te),onSuccess:()=>{r.invalidateQueries({queryKey:["smart-plugs"]}),r.invalidateQueries({queryKey:["scriptPlugsByPrinter"]}),e()},onError:Te=>{Re(Te.message)}}),He=gr?.filter(Te=>s==="tasmota"?!sr?.some(gt=>gt.printer_id===Te.id&>.id!==t?.id&>.plug_type==="tasmota"):!0),Ye=Te=>{if(Te.preventDefault(),Re(null),!l.trim()){Re("Name is required");return}if(s==="tasmota"&&!d.trim()){Re("IP address is required for Tasmota plugs");return}if(s==="homeassistant"&&!v){Re("Entity is required for Home Assistant plugs");return}if(s==="mqtt"){const gt=y.trim(),lt=C.trim(),Tt=U.trim();if(!gt&&!lt&&!Tt){Re("At least one MQTT topic must be configured for power, energy, or state monitoring");return}}const ct={name:l.trim(),plug_type:s,ip_address:s==="tasmota"?d.trim():null,ha_entity_id:s==="homeassistant"?v:null,ha_power_entity:s==="homeassistant"&&Q||null,ha_energy_today_entity:s==="homeassistant"&&H||null,ha_energy_total_entity:s==="homeassistant"&&Z||null,mqtt_power_topic:s==="mqtt"&&y.trim()||null,mqtt_power_path:s==="mqtt"&&N.trim()||null,mqtt_power_multiplier:s==="mqtt"&&parseFloat(k)||1,mqtt_energy_topic:s==="mqtt"&&C.trim()||null,mqtt_energy_path:s==="mqtt"&&M.trim()||null,mqtt_energy_multiplier:s==="mqtt"&&parseFloat(B)||1,mqtt_state_topic:s==="mqtt"&&U.trim()||null,mqtt_state_path:s==="mqtt"&&$.trim()||null,mqtt_state_on_value:s==="mqtt"&&z.trim()||null,username:s==="tasmota"&&h.trim()||null,password:s==="tasmota"&&p.trim()||null,printer_id:ge,power_alert_enabled:pe,power_alert_high:Ne?parseFloat(Ne):null,power_alert_low:we?parseFloat(we):null,schedule_enabled:ke,schedule_on_time:De||null,schedule_off_time:Oe||null,show_in_switchbar:Ve,show_on_printer_card:kt};i?ye.mutate(ct):Lt.mutate(ct)},Xe=Lt.isPending||ye.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:Te=>Te.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(Rt,{className:"w-5 h-5"})})]}),a.jsxs("form",{onSubmit:Ye,className:"p-6 space-y-4 overflow-y-auto",children:[$e&&a.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:$e}),!i&&a.jsxs("div",{className:"flex gap-2 mb-2",children:[a.jsxs("button",{type:"button",onClick:()=>{o("tasmota"),ze(null),Re(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(gl,{className:"w-4 h-4"}),"Tasmota"]}),a.jsxs("button",{type:"button",onClick:()=>{o("homeassistant"),ze(null),Re(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(dv,{className:"w-4 h-4"}),"HA"]}),a.jsxs("button",{type:"button",onClick:()=>{o("mqtt"),ze(null),Re(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(MF,{className:"w-4 h-4"}),"MQTT"]})]}),!i&&s==="tasmota"&&a.jsxs("div",{className:"space-y-3",children:[Vt?a.jsxs(Me,{type:"button",variant:"secondary",onClick:tt,className:"w-full",children:[a.jsx(Rt,{className:"w-4 h-4"}),"Stop Scanning"]}):a.jsxs(Me,{type:"button",variant:"primary",onClick:_e,className:"w-full",children:[a.jsx(Er,{className:"w-4 h-4"}),"Discover Tasmota Devices"]}),Vt&&Be.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:[Be.scanned," / ",Be.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:`${Be.scanned/Be.total*100}%`}})})]}),yt.length>0&&a.jsxs("div",{className:"space-y-2",children:[a.jsxs("p",{className:"text-xs text-bambu-gray",children:["Found ",yt.length," device(s) - click to select:"]}),a.jsx("div",{className:"max-h-40 overflow-y-auto space-y-1",children:yt.map(Te=>a.jsxs("button",{type:"button",onClick:()=>it(Te),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(gl,{className:"w-4 h-4 text-bambu-green"}),a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:Te.name}),a.jsx("p",{className:"text-xs text-bambu-gray",children:Te.ip_address})]})]}),Te.state&&a.jsxs("span",{className:`flex items-center gap-1 text-xs ${Te.state==="ON"?"text-bambu-green":"text-bambu-gray"}`,children:[a.jsx(fu,{className:"w-3 h-3"}),Te.state]})]},Te.ip_address))})]}),!Vt&&yt.length===0&&Be.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:[or&&a.jsxs("div",{className:"flex items-center justify-center py-4 text-bambu-gray",children:[a.jsx(at,{className:"w-5 h-5 animate-spin mr-2"}),"Loading entities..."]}),oi&&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: ",oi.message]}),(()=>{const Te=sr?.filter(lt=>lt.ha_entity_id&<.id!==t?.id).map(lt=>lt.ha_entity_id)||[],ct=(br||[]).filter(lt=>!Te.includes(lt.entity_id)),gt=br?.find(lt=>lt.entity_id===v);return a.jsxs("div",{ref:Ce,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:se?Se:gt?`${gt.friendly_name} (${gt.entity_id})`:"",onChange:lt=>{oe(lt.target.value),se||ce(!0)},onFocus:()=>{ce(!0),oe("")},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&&!se&&a.jsx("button",{type:"button",onClick:()=>{g(""),oe("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:a.jsx(Rt,{className:"w-4 h-4 text-bambu-gray hover:text-white"})}),or&&a.jsx(at,{className:"absolute right-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray animate-spin"})]}),se&&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:[or&&a.jsxs("div",{className:"px-3 py-2 text-sm text-bambu-gray flex items-center gap-2",children:[a.jsx(at,{className:"w-4 h-4 animate-spin"}),"Loading..."]}),!or&&ct.length===0&&a.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:ie?`No entities found matching "${ie}"`:"No entities available"}),!or&&ct.map(lt=>a.jsxs("button",{type:"button",onClick:()=>{g(lt.entity_id),ce(!1),oe(""),l||c(lt.friendly_name)},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary transition-colors ${lt.entity_id===v?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[a.jsx("div",{className:"font-medium",children:lt.friendly_name}),a.jsxs("div",{className:"text-xs text-bambu-gray flex items-center justify-between",children:[a.jsx("span",{children:lt.entity_id}),a.jsx("span",{className:lt.state==="on"?"text-bambu-green":"",children:lt.state})]})]},lt.entity_id))]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:ie?`Searching all entities (${ct.length} found)`:`Showing switch, light, input_boolean (${ct.length} available)`})]})})(),v&&Ie&&Ie.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 Te=Ie.filter(lt=>lt.unit_of_measurement==="W"||lt.unit_of_measurement==="kW"||lt.unit_of_measurement==="mW"),ct=le?Te.filter(lt=>lt.entity_id.toLowerCase().includes(le.toLowerCase())||lt.friendly_name.toLowerCase().includes(le.toLowerCase())):Te,gt=Ie.find(lt=>lt.entity_id===Q);return a.jsxs("div",{ref:fe,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:V?le:gt?`${gt.friendly_name} (${gt.state} ${gt.unit_of_measurement})`:"",onChange:lt=>{Le(lt.target.value),V||K(!0)},onFocus:()=>{K(!0),Le("")},placeholder:n("smartPlugs.addSmartPlug.placeholders.searchPowerSensors"),className:"w-full pl-9 pr-8 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"}),Q&&!V&&a.jsx("button",{type:"button",onClick:()=>{te(""),Le("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:a.jsx(Rt,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]}),V&&a.jsxs("div",{className:"absolute z-50 w-full mt-1 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-48 overflow-y-auto",children:[a.jsx("button",{type:"button",onClick:()=>{te(""),K(!1),Le("")},className:"w-full px-3 py-2 text-left text-sm text-bambu-gray hover:bg-bambu-dark-tertiary",children:"None"}),ct.map(lt=>a.jsxs("button",{type:"button",onClick:()=>{te(lt.entity_id),K(!1),Le("")},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${lt.entity_id===Q?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[a.jsx("div",{className:"font-medium",children:lt.friendly_name}),a.jsxs("div",{className:"text-xs text-bambu-gray",children:[lt.entity_id," • ",lt.state," ",lt.unit_of_measurement]})]},lt.entity_id)),ct.length===0&&a.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No matching sensors"})]})]})})(),(()=>{const Te=Ie.filter(lt=>lt.unit_of_measurement==="kWh"||lt.unit_of_measurement==="Wh"||lt.unit_of_measurement==="MWh"),ct=Y?Te.filter(lt=>lt.entity_id.toLowerCase().includes(Y.toLowerCase())||lt.friendly_name.toLowerCase().includes(Y.toLowerCase())):Te,gt=Ie.find(lt=>lt.entity_id===H);return a.jsxs("div",{ref:Pe,className:"relative",children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Energy Today (kWh)"}),a.jsxs("div",{className:"relative",children:[a.jsx(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:ue?Y:gt?`${gt.friendly_name} (${gt.state} ${gt.unit_of_measurement})`:"",onChange:lt=>{re(lt.target.value),ue||Fe(!0)},onFocus:()=>{Fe(!0),re("")},placeholder:n("smartPlugs.addSmartPlug.placeholders.searchEnergySensors"),className:"w-full pl-9 pr-8 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"}),H&&!ue&&a.jsx("button",{type:"button",onClick:()=>{X(""),re("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:a.jsx(Rt,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]}),ue&&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:()=>{X(""),Fe(!1),re("")},className:"w-full px-3 py-2 text-left text-sm text-bambu-gray hover:bg-bambu-dark-tertiary",children:"None"}),ct.map(lt=>a.jsxs("button",{type:"button",onClick:()=>{X(lt.entity_id),Fe(!1),re("")},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${lt.entity_id===H?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[a.jsx("div",{className:"font-medium",children:lt.friendly_name}),a.jsxs("div",{className:"text-xs text-bambu-gray",children:[lt.entity_id," • ",lt.state," ",lt.unit_of_measurement]})]},lt.entity_id)),ct.length===0&&a.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No matching sensors"})]})]})})(),(()=>{const Te=Ie.filter(lt=>lt.unit_of_measurement==="kWh"||lt.unit_of_measurement==="Wh"||lt.unit_of_measurement==="MWh"),ct=be?Te.filter(lt=>lt.entity_id.toLowerCase().includes(be.toLowerCase())||lt.friendly_name.toLowerCase().includes(be.toLowerCase())):Te,gt=Ie.find(lt=>lt.entity_id===Z);return a.jsxs("div",{ref:de,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:R?be:gt?`${gt.friendly_name} (${gt.state} ${gt.unit_of_measurement})`:"",onChange:lt=>{O(lt.target.value),R||G(!0)},onFocus:()=>{G(!0),O("")},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&&!R&&a.jsx("button",{type:"button",onClick:()=>{ee(""),O("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:a.jsx(Rt,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]}),R&&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:()=>{ee(""),G(!1),O("")},className:"w-full px-3 py-2 text-left text-sm text-bambu-gray hover:bg-bambu-dark-tertiary",children:"None"}),ct.map(lt=>a.jsxs("button",{type:"button",onClick:()=>{ee(lt.entity_id),G(!1),O("")},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${lt.entity_id===Z?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[a.jsx("div",{className:"font-medium",children:lt.friendly_name}),a.jsxs("div",{className:"text-xs text-bambu-gray",children:[lt.entity_id," • ",lt.state," ",lt.unit_of_measurement]})]},lt.entity_id)),ct.length===0&&a.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No matching sensors"})]})]})})()]})]})]}),s==="mqtt"&&a.jsxs("div",{className:"space-y-3",children:[!nr?.mqtt_broker&&a.jsxs("div",{className:"p-3 bg-yellow-500/20 border border-yellow-500/50 rounded-lg text-sm text-yellow-400",children:["MQTT broker not configured. Set broker address in"," ",a.jsx("span",{className:"font-medium",children:"Settings → Network → MQTT Publishing"})," ","(you don't need to enable publishing, just fill in the broker details)."]}),nr?.mqtt_broker&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg text-sm text-blue-300",children:[a.jsx("p",{className:"font-medium mb-1",children:"Monitor Only"}),a.jsx("p",{className:"text-xs opacity-80",children:"MQTT plugs receive power/energy data via MQTT subscription. On/off control is not available - use your MQTT broker or home automation system."})]}),a.jsxs("div",{className:"space-y-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[a.jsx("p",{className:"text-white font-medium text-sm",children:"Power Monitoring"}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Topic"}),a.jsx("input",{type:"text",value:y,onChange:Te=>_(Te.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:Te=>A(Te.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:k,onChange:Te=>P(Te.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:C,onChange:Te=>j(Te.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:Te=>E(Te.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:B,onChange:Te=>L(Te.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:U,onChange:Te=>D(Te.target.value),placeholder:"Same as power topic, or different",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"JSON Path"}),a.jsx("input",{type:"text",value:$,onChange:Te=>q(Te.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:z,onChange:Te=>W(Te.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:d,onChange:Te=>{u(Te.target.value),ze(null)},placeholder:"192.168.1.100",className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),a.jsxs(Me,{type:"button",variant:"secondary",onClick:()=>Ke.mutate(),disabled:!d.trim()||Ke.isPending,children:[Ke.isPending?a.jsx(at,{className:"w-4 h-4 animate-spin"}):a.jsx(Wg,{className:"w-4 h-4"}),"Test"]})]})]}),s==="tasmota"&&Ue&&a.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${Ue.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:Ue.success?a.jsxs(a.Fragment,{children:[a.jsx(yr,{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:[Ue.device_name&&`Device: ${Ue.device_name} - `,"State: ",Ue.state]})]})]}):a.jsxs(a.Fragment,{children:[a.jsx(Gh,{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:Te=>c(Te.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:Te=>f(Te.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:Te=>x(Te.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:ge??"",onChange:Te=>ae(Te.target.value?Number(Te.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)"}),He?.map(Te=>a.jsx("option",{value:Te.id,children:Te.name},Te.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(qg,{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:pe,onChange:Te=>ve(Te.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"})]})]}),pe&&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:Ne,onChange:Te=>xe(Te.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:we,onChange:Te=>qe(Te.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(qn,{className:"w-4 h-4 text-bambu-green"}),a.jsx("span",{className:"text-white font-medium",children:"Daily Schedule"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:ke,onChange:Te=>nt(Te.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"})]})]}),ke&&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:De,onChange:Te=>We(Te.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:Oe,onChange:Te=>je(Te.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(uv,{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:Ve,onChange:Te=>ot(Te.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(Zl,{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:kt,onChange:Te=>Ft(Te.target.checked),className:"sr-only peer"}),a.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]})}),a.jsxs("div",{className:"flex gap-3 pt-2",children:[a.jsx(Me,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),a.jsxs(Me,{type:"submit",disabled:Xe,className:"flex-1",children:[Xe?a.jsx(at,{className:"w-4 h-4 animate-spin"}):a.jsx(bs,{className:"w-4 h-4"}),i?"Save":"Add"]})]})]})]})})}function Ln({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 xZe={callmebot:"CallMeBot/WhatsApp",ntfy:"ntfy",pushover:"Pushover",telegram:"Telegram",email:"Email",discord:"Discord",webhook:"Webhook"};function yZe({provider:t,onEdit:e}){const n=Qt(),[r,i]=w.useState(!1),[s,o]=w.useState(!1),[l,c]=w.useState(null),{data:d}=Ze({queryKey:["printers"],queryFn:J.getPrinters}),u=d?.find(v=>v.id===t.printer_id),h=st({mutationFn:v=>J.updateNotificationProvider(t.id,v),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),f=st({mutationFn:()=>J.deleteNotificationProvider(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),p=st({mutationFn:()=>J.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(St,{className:"relative",children:a.jsxs(Nt,{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(qg,{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:xZe[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: ",mb(t.last_success)]}),t.last_error&&t.last_error_at&&(!t.last_success||(tr(t.last_error_at)?.getTime()||0)>(tr(t.last_success)?.getTime()||0))&&a.jsx("span",{className:"text-xs text-status-error",title:t.last_error,children:"Error"}),a.jsx(Ln,{checked:t.enabled,onChange:v=>h.mutate({enabled:v})})]})]}),u&&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:u.name})]}),!u&&!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(S1,{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(da,{className:"w-3 h-3"}),"Digest ",t.daily_digest_time]})]}),a.jsx("div",{className:"mb-3",children:a.jsxs(Me,{size:"sm",variant:"secondary",disabled:p.isPending,onClick:()=>{c(null),p.mutate()},className:"w-full",children:[p.isPending?a.jsx(at,{className:"w-4 h-4 animate-spin"}):a.jsx(QC,{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(yr,{className:"w-4 h-4"}):a.jsx(mi,{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(tu,{className:"w-4 h-4"}),"Event Settings"]}),s?a.jsx(wl,{className:"w-4 h-4"}):a.jsx(Mn,{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(Ln,{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(Ln,{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(Ln,{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(Ln,{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(Ln,{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(Ln,{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(Ln,{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(Ln,{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(Ln,{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(Ln,{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(Ln,{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(Ln,{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(Ln,{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(Ln,{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(Ln,{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(Ln,{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(Ln,{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(Ln,{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(Ln,{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(Ln,{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(Ln,{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(Ln,{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(Ln,{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(S1,{className:"w-4 h-4 text-purple-400"}),a.jsx("p",{className:"text-sm text-white",children:"Quiet Hours"})]}),a.jsx(Ln,{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(qn,{className:"w-4 h-4 text-bambu-gray"}),a.jsxs("span",{className:"text-sm text-white",children:[x(t.quiet_hours_start)||"22:00"," - ",x(t.quiet_hours_end)||"07:00"]})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Edit provider to change quiet hours"})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(da,{className:"w-4 h-4 text-emerald-400"}),a.jsx("p",{className:"text-sm text-white",children:"Daily Digest"})]}),a.jsx(Ln,{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(qn,{className:"w-4 h-4 text-bambu-gray"}),a.jsxs("span",{className:"text-sm text-white",children:["Send at ",x(t.daily_digest_time)||"08:00"]})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Edit provider to change digest time"})]})]}),a.jsxs("div",{className:"flex gap-2 pt-2",children:[a.jsxs(Me,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[a.jsx(ef,{className:"w-4 h-4"}),"Edit"]}),a.jsx(Me,{size:"sm",variant:"secondary",onClick:()=>i(!0),className:"text-red-400 hover:text-red-300",children:a.jsx(Yt,{className:"w-4 h-4"})})]})]})]})}),r&&a.jsx(xn,{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 aK=[{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 vZe({provider:t,onClose:e}){const n=Qt(),r=!!t,[i,s]=w.useState(t?.name||""),[o,l]=w.useState(t?.provider_type||"email"),[c,d]=w.useState(t?.printer_id||null),[u,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,k]=w.useState(t?.on_print_start??!1),[P,C]=w.useState(t?.on_print_complete??!0),[j,M]=w.useState(t?.on_print_failed??!0),[E,B]=w.useState(t?.on_print_stopped??!0),[L,U]=w.useState(t?.on_print_progress??!1),[D,$]=w.useState(t?.on_printer_offline??!1),[q,z]=w.useState(t?.on_printer_error??!1),[W,Q]=w.useState(t?.on_filament_low??!1),[te,H]=w.useState(t?.on_maintenance_due??!1),[X,Z]=w.useState(t?.on_bed_cooled??!1),[ee,Se]=w.useState(t?.config?Object.fromEntries(Object.entries(t.config).map(([ue,Fe])=>[ue,String(Fe)])):{}),[oe,ie]=w.useState(null),[me,se]=w.useState(null),{data:ce}=Ze({queryKey:["printers"],queryFn:J.getPrinters});w.useEffect(()=>{const ue=Fe=>{Fe.key==="Escape"&&e()};return window.addEventListener("keydown",ue),()=>window.removeEventListener("keydown",ue)},[e]);const Ce=st({mutationFn:()=>J.testNotificationConfig({provider_type:o,config:ee}),onSuccess:ue=>{ie(ue),se(null)},onError:ue=>{ie({success:!1,message:ue.message})}}),le=st({mutationFn:ue=>J.createNotificationProvider(ue),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:ue=>{se(ue.message)}}),Le=st({mutationFn:ue=>J.updateNotificationProvider(t.id,ue),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:ue=>{se(ue.message)}}),V=ue=>{if(ue.preventDefault(),se(null),!i.trim()){se("Name is required");return}const Fe=Y(o);for(const be of Fe)if(!ee[be.key]?.trim()){se(`${be.label} is required`);return}const Pe={name:i.trim(),provider_type:o,config:ee,printer_id:c,quiet_hours_enabled:u,quiet_hours_start:u?f:null,quiet_hours_end:u?x:null,daily_digest_enabled:g,daily_digest_time:g?_:null,on_print_start:A,on_print_complete:P,on_print_failed:j,on_print_stopped:E,on_print_progress:L,on_printer_offline:D,on_printer_error:q,on_filament_low:W,on_maintenance_due:te,on_bed_cooled:X};r?Le.mutate(Pe):le.mutate(Pe)},K=le.isPending||Le.isPending,fe=ue=>{switch(ue){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:Fe=>Fe.payload_format!=="slack"},{key:"field_message",label:"Message Field Name",placeholder:"message",type:"text",required:!1,showIf:Fe=>Fe.payload_format!=="slack"}];default:return[]}},Y=ue=>fe(ue).filter(Fe=>Fe.required),re=fe(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:ue=>ue.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(Rt,{className:"w-5 h-5"})})]}),a.jsxs("form",{onSubmit:V,className:"p-6 space-y-4",children:[me&&a.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:me}),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:ue=>s(ue.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:ue=>{l(ue.target.value),Se({}),ie(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:aK.map(ue=>a.jsx("option",{value:ue.value,children:ue.label},ue.value))}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:aK.find(ue=>ue.value===o)?.description})]}),a.jsxs("div",{className:"space-y-3",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:"Configuration"}),re.filter(ue=>!("showIf"in ue)||ue.showIf?.(ee)!==!1).map(ue=>a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[ue.label," ",ue.required&&"*"]}),ue.type==="select"&&"options"in ue&&ue.options?a.jsx("select",{value:ee[ue.key]||ue.options[0]?.value||"",onChange:Fe=>{Se({...ee,[ue.key]:Fe.target.value}),ie(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:ue.options.map(Fe=>a.jsx("option",{value:Fe.value,children:Fe.label},Fe.value))}):a.jsx("input",{type:ue.type,value:ee[ue.key]||"",onChange:Fe=>{Se({...ee,[ue.key]:Fe.target.value}),ie(null)},placeholder:ue.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"})]},ue.key))]}),a.jsx("div",{className:"flex gap-2",children:a.jsxs(Me,{type:"button",variant:"secondary",onClick:()=>{ie(null),Ce.mutate()},disabled:Ce.isPending||!ee[Y(o)[0]?.key],className:"flex-1",children:[Ce.isPending?a.jsx(at,{className:"w-4 h-4 animate-spin"}):a.jsx(QC,{className:"w-4 h-4"}),"Test Configuration"]})}),oe&&a.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${oe.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:oe.success?a.jsxs(a.Fragment,{children:[a.jsx(yr,{className:"w-5 h-5"}),a.jsx("span",{children:oe.message})]}):a.jsxs(a.Fragment,{children:[a.jsx(mi,{className:"w-5 h-5"}),a.jsx("span",{children:oe.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:ue=>d(ue.target.value?Number(ue.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"}),ce?.map(ue=>a.jsx("option",{value:ue.id,children:ue.name},ue.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(Ln,{checked:u,onChange:h})]}),u&&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:ue=>p(ue.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:ue=>v(ue.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(Ln,{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:ue=>N(ue.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(Ln,{checked:A,onChange:k})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-white",children:"Complete"}),a.jsx(Ln,{checked:P,onChange:C})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-white",children:"Failed"}),a.jsx(Ln,{checked:j,onChange:M})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-white",children:"Stopped"}),a.jsx(Ln,{checked:E,onChange:B})]}),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(Ln,{checked:L,onChange:U})]}),a.jsxs("div",{className:"flex items-center justify-between col-span-2",children:[a.jsxs("div",{children:[a.jsx("span",{className:"text-sm text-white",children:"Bed Cooled"}),a.jsx("span",{className:"text-xs text-bambu-gray ml-1",children:"(after print completes)"})]}),a.jsx(Ln,{checked:X,onChange:Z})]})]})]}),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(Ln,{checked:D,onChange:$})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-white",children:"Error"}),a.jsx(Ln,{checked:q,onChange:z})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-white",children:"Low Filament"}),a.jsx(Ln,{checked:W,onChange:Q})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-white",children:"Maintenance"}),a.jsx(Ln,{checked:te,onChange:H})]})]})]})]}),a.jsxs("div",{className:"flex gap-3 pt-2",children:[a.jsx(Me,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),a.jsxs(Me,{type:"submit",disabled:K,className:"flex-1",children:[K?a.jsx(at,{className:"w-4 h-4 animate-spin"}):a.jsx(bs,{className:"w-4 h-4"}),r?"Save":"Add"]})]})]})]})})}function wZe({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,d]=w.useState(null),[u,h]=w.useState(!0),{data:f}=Ze({queryKey:["template-variables"],queryFn:J.getTemplateVariables}),p=f?.find(k=>k.event_type===t.event_type),{data:x,isLoading:v}=Ze({queryKey:["template-preview",t.event_type,i,o],queryFn:()=>J.previewTemplate({event_type:t.event_type,title_template:i,body_template:o}),enabled:u&&i.length>0&&o.length>0});w.useEffect(()=>{const k=P=>{P.key==="Escape"&&e()};return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[e]);const g=st({mutationFn:k=>J.updateNotificationTemplate(t.id,k),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-templates"]}),e()},onError:k=>{d(k.message)}}),y=st({mutationFn:()=>J.resetNotificationTemplate(t.id),onSuccess:k=>{s(k.title_template),l(k.body_template),n.invalidateQueries({queryKey:["notification-templates"]})},onError:k=>{d(k.message)}}),_=k=>{if(k.preventDefault(),d(null),!i.trim()){d("Title is required");return}if(!o.trim()){d("Body is required");return}g.mutate({title_template:i,body_template:o})},N=k=>{const P=r.current;if(!P)return;const C=P.selectionStart,j=P.selectionEnd,M=o,E=M.substring(0,C),B=M.substring(j),L=E+`{${k}}`+B;l(L),setTimeout(()=>{P.focus();const U=C+k.length+2;P.setSelectionRange(U,U)},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(Rt,{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:k=>s(k.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:k=>l(k.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(k=>a.jsxs("button",{type:"button",onClick:()=>N(k),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(Xn,{className:"w-3 h-3"}),k]},k))}),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(Zl,{className:"w-4 h-4"}),"Live Preview"]}),a.jsx("button",{type:"button",onClick:()=>h(!u),className:"text-xs text-bambu-green hover:text-bambu-green-light",children:u?"Hide":"Show"})]}),u&&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(at,{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(Me,{type:"button",variant:"ghost",onClick:()=>y.mutate(),disabled:y.isPending,className:"text-orange-400 hover:text-orange-300",children:[y.isPending?a.jsx(at,{className:"w-4 h-4 animate-spin mr-2"}):a.jsx(lo,{className:"w-4 h-4 mr-2"}),"Reset to Default"]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Me,{type:"button",variant:"secondary",onClick:e,children:"Cancel"}),a.jsxs(Me,{onClick:_,disabled:g.isPending||!A,children:[g.isPending?a.jsx(at,{className:"w-4 h-4 animate-spin mr-2"}):a.jsx(bs,{className:"w-4 h-4 mr-2"}),"Save"]})]})]})]})})}const SZe={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"},_Ze={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 NZe({onClose:t}){const e=Qt(),{showToast:n}=dn(),[r,i]=w.useState(7),[s,o]=w.useState(null),[l,c]=w.useState(!1),{data:d}=Ze({queryKey:["settings"],queryFn:J.getSettings}),u=d?.time_format||"system",{data:h,isLoading:f,refetch:p,isRefetching:x}=Ze({queryKey:["notification-logs",r,l],queryFn:()=>J.getNotificationLogs({days:r,limit:100,success:l?!1:void 0})}),{data:v}=Ze({queryKey:["notification-log-stats",r],queryFn:()=>J.getNotificationLogStats(r)}),g=st({mutationFn:()=>J.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=tr(_);if(!N)return"";const k=new Date().getTime()-N.getTime();return k<6e4?"Just now":k<36e5?`${Math.floor(k/6e4)}m ago`:k<864e5?`${Math.floor(k/36e5)}h ago`:N.toLocaleDateString()+" "+Oge(N,u)};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(f0,{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(yr,{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(mi,{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(Me,{size:"sm",variant:"secondary",onClick:()=>p(),disabled:x,children:[x?a.jsx(at,{className:"w-4 h-4 animate-spin"}):a.jsx(Sr,{className:"w-4 h-4"}),"Refresh"]}),a.jsxs(Me,{size:"sm",variant:"secondary",onClick:()=>g.mutate(),disabled:g.isPending,className:"text-red-400 hover:text-red-300",children:[g.isPending?a.jsx(at,{className:"w-4 h-4 animate-spin"}):a.jsx(Yt,{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(at,{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(CZe,{log:_,isExpanded:s===_.id,onToggle:()=>o(s===_.id?null:_.id),formatDate:y,formatFullDate:N=>Df(N,u)},_.id))}):a.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[a.jsx(f0,{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 CZe({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(yr,{className:"w-4 h-4 text-bambu-green shrink-0"}):a.jsx(mi,{className:"w-4 h-4 text-red-400 shrink-0"}),a.jsx("span",{className:`text-xs font-medium ${_Ze[t.event_type]||"text-bambu-gray"}`,children:SZe[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(wl,{className:"w-4 h-4 text-bambu-gray shrink-0"}):a.jsx(Mn,{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 kZe({formData:t,setFormData:e,groups:n,onClose:r,onCreate:i,isCreating:s,isCreateButtonDisabled:o}){const{t:l}=Dt();w.useEffect(()=>{const d=u=>{u.key==="Escape"&&r()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[r]);const c=d=>{e({...t,group_ids:t.group_ids.includes(d)?t.group_ids.filter(u=>u!==d):[...t.group_ids,d]})};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(St,{className:"w-full max-w-md",onClick:d=>d.stopPropagation(),children:[a.jsx(On,{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(fh,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:l("users.modal.createUser")})]}),a.jsx("p",{className:"text-sm text-bambu-gray ml-7",children:l("users.modal.advancedAuthSubtitle")||"with Advanced Authentication"})]}),a.jsx(Me,{variant:"ghost",size:"sm",onClick:r,children:a.jsx(Rt,{className:"w-5 h-5"})})]})}),a.jsxs(Nt,{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:d=>e({...t,username:d.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:d=>e({...t,email:d.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(d=>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(d.id),onChange:()=>c(d.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:d.name}),d.is_system&&a.jsxs("span",{className:"text-xs text-yellow-400",children:["(",l("users.system"),")"]})]},d.id)),n.length===0&&a.jsx("p",{className:"text-sm text-bambu-gray",children:l("users.noGroupsAvailable")})]})]})]}),a.jsxs("div",{className:"mt-6 flex justify-end gap-3",children:[a.jsx(Me,{variant:"secondary",onClick:r,children:l("users.modal.cancel")}),a.jsx(Me,{onClick:i,disabled:o,children:s?a.jsxs(a.Fragment,{children:[a.jsx(at,{className:"w-4 h-4 animate-spin"}),l("users.modal.creating")]}):a.jsxs(a.Fragment,{children:[a.jsx(Xn,{className:"w-4 h-4"}),l("users.modal.createUser")]})})]})]})]})})}function AZe(){const{t}=Dt(),e=Qt(),{showToast:n}=dn(),[r,i]=w.useState(!1),[s,o]=w.useState(""),[l,c]=w.useState("auto"),[d,u]=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:k,isLoading:P}=Ze({queryKey:["spoolman-settings"],queryFn:J.getSpoolmanSettings}),{data:C,isLoading:j,refetch:M}=Ze({queryKey:["spoolman-status"],queryFn:J.getSpoolmanStatus,refetchInterval:3e4}),{data:E}=Ze({queryKey:["printers"],queryFn:J.getPrinters});w.useEffect(()=>{k&&(i(k.spoolman_enabled==="true"),o(k.spoolman_url||""),c(k.spoolman_sync_mode||"auto"),u(k.spoolman_disable_weight_sync==="true"),f(k.spoolman_report_partial_usage!=="false"),g(!0))},[k]),w.useEffect(()=>{if(!v||!k)return;if(k.spoolman_enabled==="true"!==r||(k.spoolman_url||"")!==s||(k.spoolman_sync_mode||"auto")!==l||k.spoolman_disable_weight_sync==="true"!==d||k.spoolman_report_partial_usage!=="false"!==h){const X=setTimeout(()=>{B.mutate()},500);return()=>clearTimeout(X)}},[r,s,l,d,h,v]);const B=st({mutationFn:()=>J.updateSpoolmanSettings({spoolman_enabled:r?"true":"false",spoolman_url:s,spoolman_sync_mode:l,spoolman_disable_weight_sync:d?"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"))}}),L=st({mutationFn:J.connectSpoolman,onSuccess:()=>{M()}}),U=st({mutationFn:J.disconnectSpoolman,onSuccess:()=>{M()}}),D=st({mutationFn:J.syncAllPrintersAms,onSuccess:H=>{H.success}}),$=st({mutationFn:H=>J.syncPrinterAms(H),onSuccess:H=>{H.success}}),q=()=>{p==="all"?D.mutate():$.mutate(p)},z=st({mutationFn:J.syncWeightsFromAms,onSuccess:H=>{e.invalidateQueries({queryKey:["spools"]}),e.invalidateQueries({queryKey:["inventory-spools"]}),n(t("settings.amsSyncSuccess",{synced:H.synced,skipped:H.skipped}),"success"),A(!1)},onError:()=>{n(t("settings.amsSyncError"),"error"),A(!1)}}),W=D.isPending||$.isPending,Q=p==="all"?D.data:$.data,te=p==="all"?D.isSuccess:$.isSuccess;return P?a.jsxs(St,{children:[a.jsx(On,{children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(jc,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:t("settings.filamentTracking")})]})}),a.jsx(Nt,{children:a.jsx("div",{className:"flex justify-center py-8",children:a.jsx(at,{className:"w-6 h-6 text-bambu-green animate-spin"})})})]}):a.jsxs(St,{children:[a.jsx(On,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(jc,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:t("settings.filamentTracking")})]}),B.isPending&&a.jsx(at,{className:"w-4 h-4 text-bambu-green animate-spin"})]})}),a.jsxs(Nt,{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(fi,{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(na,{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(ta,{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(na,{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(eo,{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(Me,{variant:"secondary",size:"sm",onClick:()=>A(!0),disabled:z.isPending,children:[z.isPending?a.jsx(at,{className:"w-4 h-4 mr-2 animate-spin"}):a.jsx(Sr,{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(eo,{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:H=>o(H.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:H=>c(H.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:d,onChange:H=>u(H.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"})]})]}),d&&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:H=>f(H.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"),":"]}),j?a.jsx(at,{className:"w-4 h-4 text-bambu-gray animate-spin"}):C?.connected?a.jsxs("span",{className:"flex items-center gap-1 text-sm text-green-500",children:[a.jsx(na,{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(Rt,{className:"w-4 h-4"}),t("settings.spoolmanDisconnected")]})]}),a.jsx("div",{className:"flex gap-2",children:C?.connected?a.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>U.mutate(),disabled:U.isPending,children:[U.isPending?a.jsx(at,{className:"w-4 h-4 animate-spin"}):a.jsx(mfe,{className:"w-4 h-4"}),t("settings.disconnect")]}):a.jsxs(Me,{size:"sm",onClick:()=>L.mutate(),disabled:L.isPending||!s,children:[L.isPending?a.jsx(at,{className:"w-4 h-4 animate-spin"}):a.jsx(Dh,{className:"w-4 h-4"}),t("settings.connect")]})})]}),L.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:L.error.message}),C?.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:H=>x(H.target.value==="all"?"all":Number(H.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")}),E?.map(H=>a.jsx("option",{value:H.id,children:H.name},H.id))]}),a.jsx(Mn,{className:"absolute right-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),a.jsxs(Me,{variant:"secondary",size:"sm",onClick:q,disabled:W,children:[W?a.jsx(at,{className:"w-4 h-4 animate-spin"}):a.jsx(Sr,{className:"w-4 h-4"}),t("spoolman.sync")]})]})]}),te&&Q&&a.jsxs("div",{className:"mt-3 space-y-2",children:[a.jsx("div",{className:`p-2 rounded text-sm ${Q.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:Q.success?`Synced ${Q.synced_count} spool${Q.synced_count!==1?"s":""} successfully`:`Synced ${Q.synced_count} spool${Q.synced_count!==1?"s":""} with ${Q.errors.length} error${Q.errors.length!==1?"s":""}`}),Q.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(An,{className:"w-3.5 h-3.5"}),a.jsxs("span",{className:"font-medium",children:[Q.skipped_count," spool",Q.skipped_count!==1?"s":""," skipped"]})]}),Q.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?Q.skipped:Q.skipped.slice(0,5)).map((H,X)=>a.jsxs("li",{className:"flex items-center gap-2",children:[H.color&&a.jsx("span",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:`#${H.color}`}}),a.jsx("span",{children:H.location}),a.jsxs("span",{className:"text-amber-300/60",children:["- ",H.reason]})]},X)),!y&&Q.skipped_count>5&&a.jsxs("li",{className:"text-amber-300/60 italic",children:["...and ",Q.skipped_count-5," more"]})]})]}),Q.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:Q.errors.map((H,X)=>a.jsx("li",{children:H},X))})]})]})]})]})]}),N&&a.jsx(xn,{title:t("settings.amsSyncTitle"),message:t("settings.amsSyncMessage"),confirmText:t("settings.amsSyncButton"),variant:"warning",isLoading:z.isPending,loadingText:t("settings.amsSyncing"),onConfirm:()=>z.mutate(),onCancel:()=>A(!1)})]})}function TZe(){const{t}=Dt(),{showToast:e}=dn(),[n,r]=w.useState([]),[i,s]=w.useState(!0),[o,l]=w.useState(""),c=w.useRef(null),[d,u]=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),[k,P]=w.useState(!1),C=w.useCallback(async()=>{try{const z=await J.getSpoolCatalog();r(z)}catch{e(t("settings.catalog.loadFailed"),"error")}finally{s(!1)}},[e,t]);w.useEffect(()=>{C()},[C]);const j=n.filter(z=>z.name.toLowerCase().includes(o.toLowerCase())),M=async()=>{if(!p.trim()||!v){e(t("settings.catalog.nameWeightRequired"),"error");return}_(!0);try{const z=await J.addCatalogEntry({name:p.trim(),weight:parseInt(v)});r(W=>[...W,z].sort((Q,te)=>Q.name.localeCompare(te.name))),u(!1),x(""),g(""),e(t("settings.catalog.entryAdded"),"success")}catch{e(t("settings.catalog.addFailed"),"error")}finally{_(!1)}},E=z=>{f(z.id),x(z.name),g(z.weight.toString())},B=()=>{f(null),x(""),g("")},L=async z=>{if(!p.trim()||!v){e(t("settings.catalog.nameWeightRequired"),"error");return}_(!0);try{const W=await J.updateCatalogEntry(z,{name:p.trim(),weight:parseInt(v)});r(Q=>Q.map(te=>te.id===z?W:te).sort((te,H)=>te.name.localeCompare(H.name))),f(null),x(""),g(""),e(t("settings.catalog.entryUpdated"),"success")}catch{e(t("settings.catalog.updateFailed"),"error")}finally{_(!1)}},U=async()=>{if(N)try{await J.deleteCatalogEntry(N.id),r(z=>z.filter(W=>W.id!==N.id)),e(t("settings.catalog.entryDeleted"),"success")}catch{e(t("settings.catalog.deleteFailed"),"error")}finally{A(null)}},D=async()=>{P(!1),s(!0);try{await J.resetSpoolCatalog(),await C(),e(t("settings.catalog.resetSuccess"),"success")}catch{e(t("settings.catalog.resetFailed"),"error"),s(!1)}},$=()=>{const z=n.map(({name:H,weight:X})=>({name:H,weight:X})),W=new Blob([JSON.stringify(z,null,2)],{type:"application/json"}),Q=URL.createObjectURL(W),te=document.createElement("a");te.href=Q,te.download="spool-catalog.json",document.body.appendChild(te),te.click(),document.body.removeChild(te),URL.revokeObjectURL(Q),e(t("settings.catalog.exported",{count:n.length}),"success")},q=async z=>{const W=z.target.files?.[0];if(W){try{const Q=await W.text(),te=JSON.parse(Q);if(!Array.isArray(te))throw new Error("Invalid format");let H=0,X=0;for(const Z of te){if(!Z.name||typeof Z.weight!="number"){X++;continue}if(n.some(Se=>Se.name.toLowerCase()===Z.name.toLowerCase())){X++;continue}try{const Se=await J.addCatalogEntry({name:Z.name,weight:Z.weight});r(oe=>[...oe,Se].sort((ie,me)=>ie.name.localeCompare(me.name))),H++}catch{X++}}e(t("settings.catalog.imported",{added:H,skipped:X}),"success")}catch{e(t("settings.catalog.importFailed"),"error")}c.current&&(c.current.value="")}};return a.jsxs(St,{children:[a.jsxs(On,{children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[a.jsx(jc,{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:$,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(ga,{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(Oa,{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:q}),a.jsxs("button",{onClick:()=>P(!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(lo,{className:"w-4 h-4"}),a.jsx("span",{className:"hidden sm:inline",children:t("common.reset")})]}),a.jsxs("button",{onClick:()=>u(!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(Xn,{className:"w-4 h-4"}),a.jsx("span",{className:"hidden sm:inline",children:t("common.add")})]})]})]}),a.jsxs(Nt,{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:z=>l(z.target.value)})]}),d&&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:z=>x(z.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:z=>g(z.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(at,{className:"w-4 h-4 animate-spin"}):a.jsx(na,{className:"w-4 h-4"}),t("common.add")]}),a.jsx("button",{onClick:()=>{u(!1),x(""),g("")},className:"p-2 rounded-lg text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary",children:a.jsx(Rt,{className:"w-4 h-4"})})]})]}),i?a.jsxs("div",{className:"flex items-center justify-center py-8 text-bambu-gray",children:[a.jsx(at,{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:j.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")})}):j.map(z=>a.jsx("tr",{className:"border-t border-bambu-dark-tertiary hover:bg-bambu-dark",children:h===z.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:W=>x(W.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:W=>g(W.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:()=>L(z.id),disabled:y,className:"p-1.5 rounded hover:bg-green-500/20 text-green-500",children:y?a.jsx(at,{className:"w-4 h-4 animate-spin"}):a.jsx(na,{className:"w-4 h-4"})}),a.jsx("button",{onClick:B,className:"p-1.5 rounded hover:bg-bambu-dark-tertiary text-bambu-gray",children:a.jsx(Rt,{className:"w-4 h-4"})})]})})]}):a.jsxs(a.Fragment,{children:[a.jsx("td",{className:"px-4 py-2 text-white",children:z.name}),a.jsxs("td",{className:"px-4 py-2 text-right font-mono text-white",children:[z.weight,"g"]}),a.jsx("td",{className:"px-4 py-2 text-center",children:z.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:()=>E(z),className:"p-1.5 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white",children:a.jsx(Ga,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>A(z),className:"p-1.5 rounded bg-red-500/10 hover:bg-red-500/20 text-red-500",children:a.jsx(Yt,{className:"w-4 h-4"})})]})})]})},z.id))})]})})]}),N&&a.jsx(xn,{title:t("settings.catalog.deleteEntry"),message:t("settings.catalog.deleteConfirm",{name:N.name}),confirmText:t("common.delete"),variant:"danger",onConfirm:U,onCancel:()=>A(null)}),k&&a.jsx(xn,{title:t("settings.catalog.resetCatalog"),message:t("settings.catalog.resetConfirm"),confirmText:t("common.reset"),variant:"danger",onConfirm:D,onCancel:()=>P(!1)})]})}function MZe(){const{t}=Dt(),{showToast:e}=dn(),[n,r]=w.useState([]),[i,s]=w.useState(!0),[o,l]=w.useState(""),[c,d]=w.useState("Bambu Lab"),u=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"),[k,P]=w.useState(""),[C,j]=w.useState(!1),[M,E]=w.useState(!1),[B,L]=w.useState(null),[U,D]=w.useState(null),[$,q]=w.useState(!1),z=w.useCallback(async()=>{try{const ce=await J.getColorCatalog();r(ce)}catch{e(t("settings.colorCatalog.loadFailed"),"error")}finally{s(!1)}},[e,t]);w.useEffect(()=>{z()},[z]);const W=[...new Set(n.map(ce=>ce.manufacturer))].sort(),Q=n.filter(ce=>{const Ce=o===""||ce.manufacturer.toLowerCase().includes(o.toLowerCase())||ce.color_name.toLowerCase().includes(o.toLowerCase())||(ce.material?.toLowerCase().includes(o.toLowerCase())??!1),le=c===""||ce.manufacturer===c;return Ce&&le}),te=()=>{g(""),_(""),A("#FFFFFF"),P("")},H=async()=>{if(!v.trim()||!y.trim()||!N){e(t("settings.colorCatalog.fieldsRequired"),"error");return}j(!0);try{const ce=await J.addColorEntry({manufacturer:v.trim(),color_name:y.trim(),hex_color:N,material:k.trim()||null});r(Ce=>[...Ce,ce].sort((le,Le)=>le.manufacturer.localeCompare(Le.manufacturer)||(le.material||"").localeCompare(Le.material||"")||le.color_name.localeCompare(Le.color_name))),f(!1),te(),e(t("settings.colorCatalog.colorAdded"),"success")}catch{e(t("settings.colorCatalog.addFailed"),"error")}finally{j(!1)}},X=ce=>{x(ce.id),g(ce.manufacturer),_(ce.color_name),A(ce.hex_color),P(ce.material||"")},Z=()=>{x(null),te()},ee=async ce=>{if(!v.trim()||!y.trim()||!N){e(t("settings.colorCatalog.fieldsRequired"),"error");return}j(!0);try{const Ce=await J.updateColorEntry(ce,{manufacturer:v.trim(),color_name:y.trim(),hex_color:N,material:k.trim()||null});r(le=>le.map(Le=>Le.id===ce?Ce:Le).sort((Le,V)=>Le.manufacturer.localeCompare(V.manufacturer)||(Le.material||"").localeCompare(V.material||"")||Le.color_name.localeCompare(V.color_name))),x(null),te(),e(t("settings.colorCatalog.colorUpdated"),"success")}catch{e(t("settings.colorCatalog.updateFailed"),"error")}finally{j(!1)}},Se=async()=>{if(U)try{await J.deleteColorEntry(U.id),r(ce=>ce.filter(Ce=>Ce.id!==U.id)),e(t("settings.colorCatalog.colorDeleted"),"success")}catch{e(t("settings.colorCatalog.deleteFailed"),"error")}finally{D(null)}},oe=async()=>{q(!1),s(!0);try{await J.resetColorCatalog(),await z(),e(t("settings.colorCatalog.resetSuccess"),"success")}catch{e(t("settings.colorCatalog.resetFailed"),"error"),s(!1)}},ie=async()=>{E(!0),L(null);try{const ce={},Ce=au();Ce&&(ce.Authorization=`Bearer ${Ce}`);const le=await fetch("/api/v1/inventory/colors/sync",{method:"POST",headers:ce});if(!le.ok)throw new Error("Failed to start sync");const Le=le.body?.getReader();if(!Le)throw new Error("No response body");const V=new TextDecoder;let K="";for(;;){const{done:fe,value:Y}=await Le.read();if(fe)break;K+=V.decode(Y,{stream:!0});const re=K.split(`
- `);K=re.pop()||"";for(const ue of re)if(ue.startsWith("data: "))try{const Fe=JSON.parse(ue.slice(6));Fe.type==="progress"?L({fetched:Fe.total_fetched,total:Fe.total_available}):Fe.type==="complete"?Fe.added===0?e(t("settings.colorCatalog.syncUpToDate",{count:Fe.total_fetched}),"success"):e(t("settings.colorCatalog.syncComplete",{added:Fe.added,skipped:Fe.skipped}),"success"):Fe.type==="error"&&e(`${t("settings.colorCatalog.syncError")}: ${Fe.error}`,"error")}catch{}}await z()}catch{e(t("settings.colorCatalog.syncFailed"),"error")}finally{E(!1),L(null)}},me=()=>{const ce=n.map(({manufacturer:V,color_name:K,hex_color:fe,material:Y})=>({manufacturer:V,color_name:K,hex_color:fe,material:Y})),Ce=new Blob([JSON.stringify(ce,null,2)],{type:"application/json"}),le=URL.createObjectURL(Ce),Le=document.createElement("a");Le.href=le,Le.download="color-catalog.json",document.body.appendChild(Le),Le.click(),document.body.removeChild(Le),URL.revokeObjectURL(le),e(t("settings.colorCatalog.exported",{count:n.length}),"success")},se=async ce=>{const Ce=ce.target.files?.[0];if(Ce){try{const le=await Ce.text(),Le=JSON.parse(le);if(!Array.isArray(Le))throw new Error("Invalid format");let V=0,K=0;for(const fe of Le){if(!fe.manufacturer||!fe.color_name||!fe.hex_color){K++;continue}if(n.some(re=>re.manufacturer.toLowerCase()===fe.manufacturer.toLowerCase()&&re.color_name.toLowerCase()===fe.color_name.toLowerCase()&&(re.material||"").toLowerCase()===(fe.material||"").toLowerCase())){K++;continue}try{const re=await J.addColorEntry({manufacturer:fe.manufacturer,color_name:fe.color_name,hex_color:fe.hex_color,material:fe.material||null});r(ue=>[...ue,re].sort((Fe,Pe)=>Fe.manufacturer.localeCompare(Pe.manufacturer)||(Fe.material||"").localeCompare(Pe.material||"")||Fe.color_name.localeCompare(Pe.color_name))),V++}catch{K++}}e(t("settings.colorCatalog.imported",{added:V,skipped:K}),"success")}catch{e(t("settings.colorCatalog.importFailed"),"error")}u.current&&(u.current.value="")}};return a.jsxs(St,{children:[a.jsxs(On,{children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[a.jsx(KC,{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:me,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(ga,{className:"w-4 h-4"}),a.jsx("span",{className:"hidden sm:inline",children:t("common.export")})]}),a.jsxs("button",{onClick:()=>u.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(Oa,{className:"w-4 h-4"}),a.jsx("span",{className:"hidden sm:inline",children:t("common.import")})]}),a.jsx("input",{ref:u,type:"file",accept:".json",className:"hidden",onChange:se}),a.jsxs("button",{onClick:ie,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(at,{className:"w-4 h-4 animate-spin"}):a.jsx($b,{className:"w-4 h-4"}),a.jsx("span",{className:"hidden sm:inline",children:M?B?`${Math.min(B.fetched,B.total)} / ${B.total}`:t("settings.colorCatalog.starting"):t("settings.colorCatalog.sync")})]}),a.jsxs("button",{onClick:()=>q(!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(lo,{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(Xn,{className:"w-4 h-4"}),a.jsx("span",{className:"hidden sm:inline",children:t("common.add")})]})]})]}),a.jsxs(Nt,{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:ce=>l(ce.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:ce=>d(ce.target.value),children:[a.jsx("option",{value:"",children:t("settings.colorCatalog.allManufacturers")}),W.map(ce=>a.jsx("option",{value:ce,children:ce},ce))]})]}),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:ce=>g(ce.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:ce=>_(ce.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:ce=>A(ce.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:ce=>A(ce.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:k,onChange:ce=>P(ce.target.value)}),a.jsxs("button",{onClick:H,disabled:C,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:[C?a.jsx(at,{className:"w-4 h-4 animate-spin"}):a.jsx(na,{className:"w-4 h-4"}),t("common.add")]}),a.jsx("button",{onClick:()=>{f(!1),te()},className:"p-2 ml-2 rounded-lg text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary",children:a.jsx(Rt,{className:"w-4 h-4"})})]})]})]}),(o||c)&&a.jsx("div",{className:"text-xs text-bambu-gray",children:t("settings.colorCatalog.showing",{filtered:Q.length,total:n.length})}),i?a.jsxs("div",{className:"flex items-center justify-center py-8 text-bambu-gray",children:[a.jsx(at,{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:Q.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")})}):Q.map(ce=>a.jsx("tr",{className:"border-t border-bambu-dark-tertiary hover:bg-bambu-dark",children:p===ce.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:Ce=>A(Ce.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:Ce=>g(Ce.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:k,onChange:Ce=>P(Ce.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:Ce=>_(Ce.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:Ce=>A(Ce.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:()=>ee(ce.id),disabled:C,className:"p-1.5 rounded hover:bg-green-500/20 text-green-500",children:C?a.jsx(at,{className:"w-4 h-4 animate-spin"}):a.jsx(na,{className:"w-4 h-4"})}),a.jsx("button",{onClick:Z,className:"p-1.5 rounded hover:bg-bambu-dark-tertiary text-bambu-gray",children:a.jsx(Rt,{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:ce.hex_color},title:ce.hex_color})}),a.jsx("td",{className:"px-3 py-2 text-white",children:ce.manufacturer}),a.jsx("td",{className:"px-3 py-2 text-bambu-gray",children:ce.material||"-"}),a.jsx("td",{className:"px-3 py-2 text-white",children:ce.color_name}),a.jsx("td",{className:"px-3 py-2 font-mono text-xs text-bambu-gray",children:ce.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:()=>X(ce),className:"p-1.5 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white",children:a.jsx(Ga,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>D(ce),className:"p-1.5 rounded bg-red-500/10 hover:bg-red-500/20 text-red-500",children:a.jsx(Yt,{className:"w-4 h-4"})})]})})]})},ce.id))})]})})]}),U&&a.jsx(xn,{title:t("settings.colorCatalog.deleteColor"),message:t("settings.colorCatalog.deleteConfirm",{name:`${U.manufacturer} - ${U.color_name}`}),confirmText:t("common.delete"),variant:"danger",onConfirm:Se,onCancel:()=>D(null)}),$&&a.jsx(xn,{title:t("settings.colorCatalog.resetCatalog"),message:t("settings.colorCatalog.resetConfirm"),confirmText:t("common.reset"),variant:"danger",onConfirm:oe,onCancel:()=>q(!1)})]})}function PZe({link:t,onClose:e}){const{t:n}=Dt(),r=Qt(),i=!!t,s=w.useRef(null),[o,l]=w.useState(t?.name||""),[c,d]=w.useState(t?.url||""),[u,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?J.getExternalLinkIconUrl(t.id):null),[_,N]=w.useState(null),[A,k]=w.useState(null);w.useEffect(()=>{const U=D=>{D.key==="Escape"&&e()};return window.addEventListener("keydown",U),()=>window.removeEventListener("keydown",U)},[e]);const P=st({mutationFn:async U=>{const D=await J.createExternalLink(U);return _?await J.uploadExternalLinkIcon(D.id,_):D},onSuccess:()=>{r.invalidateQueries({queryKey:["external-links"]}),e()},onError:U=>{k(U.message)}}),C=st({mutationFn:async U=>{let D=await J.updateExternalLink(t.id,U);return _?D=await J.uploadExternalLinkIcon(t.id,_):!x&&t?.custom_icon&&(D=await J.deleteExternalLinkIcon(t.id)),D},onSuccess:()=>{r.invalidateQueries({queryKey:["external-links"]}),e()},onError:U=>{k(U.message)}}),j=U=>{const D=U.target.files?.[0];if(D){if(!["image/png","image/jpeg","image/gif","image/svg+xml","image/webp","image/x-icon"].includes(D.type)){k("Please select a valid image file (PNG, JPG, GIF, SVG, WebP, or ICO)");return}if(D.size>1024*1024){k("Image file must be less than 1MB");return}N(D),v(!0);const q=new FileReader;q.onload=z=>{y(z.target?.result)},q.readAsDataURL(D)}},M=()=>{N(null),y(null),v(!1),s.current&&(s.current.value="")},E=U=>{if(U.preventDefault(),k(null),!o.trim()){k("Name is required");return}if(!c.trim()){k("URL is required");return}if(!c.startsWith("http://")&&!c.startsWith("https://")){k("URL must start with http:// or https://");return}const D={name:o.trim(),url:c.trim(),icon:u,open_in_new_tab:f};i?C.mutate(D):P.mutate(D)},B=P.isPending||C.isPending,L=tk(u);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:U=>U.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(L,{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(Rt,{className:"w-5 h-5"})})]}),a.jsxs("form",{onSubmit:E,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:U=>l(U.target.value),placeholder:"My Link",maxLength:50,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),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:U=>d(U.target.value),placeholder:"https://example.com",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),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:j}),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(Yt,{className:"w-4 h-4"})})]}):a.jsxs(Me,{type:"button",variant:"secondary",size:"sm",onClick:()=>s.current?.click(),children:[a.jsx(Oa,{className:"w-4 h-4"}),"Upload"]})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"PNG, JPG, GIF, SVG, WebP, or ICO. Max 1MB."})]}),!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(Tge,{value:u,onChange:h})]})]}),a.jsxs("div",{className:"flex gap-3 pt-2",children:[a.jsx(Me,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),a.jsxs(Me,{type:"submit",disabled:B,className:"flex-1",children:[B?a.jsx(at,{className:"w-4 h-4 animate-spin"}):a.jsx(bs,{className:"w-4 h-4"}),i?"Save":"Add"]})]})]})]})})}function EZe(){const{t}=Dt(),e=Qt(),[n,r]=w.useState(!1),[i,s]=w.useState(null),[o,l]=w.useState(null),[c,d]=w.useState(null),{data:u,isLoading:h}=Ze({queryKey:["external-links"],queryFn:J.getExternalLinks}),f=st({mutationFn:N=>J.deleteExternalLink(N),onSuccess:()=>{e.invalidateQueries({queryKey:["external-links"]})}}),p=st({mutationFn:N=>J.reorderExternalLinks(N),onSuccess:()=>{e.invalidateQueries({queryKey:["external-links"]})}}),x=(N,A)=>{d(A),N.dataTransfer.effectAllowed="move"},v=N=>{N.preventDefault(),N.dataTransfer.dropEffect="move"},g=(N,A)=>{if(N.preventDefault(),c===null||c===A||!u)return;const k=u.map(M=>M.id),P=k.indexOf(c),C=k.indexOf(A);if(P===-1||C===-1)return;const j=[...k];j.splice(P,1),j.splice(C,0,c),p.mutate(j),d(null)},y=N=>{l(N)},_=()=>{o&&(f.mutate(o.id),l(null))};return a.jsxs(a.Fragment,{children:[a.jsxs(St,{children:[a.jsx(On,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Dh,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:"Sidebar Links"})]}),a.jsxs(Me,{size:"sm",onClick:()=>r(!0),children:[a.jsx(Xn,{className:"w-4 h-4"}),"Add Link"]})]})}),a.jsxs(Nt,{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(at,{className:"w-6 h-6 text-bambu-green animate-spin"})}):u&&u.length>0?a.jsx("div",{className:"space-y-2",children:u.map(N=>{const A=tk(N.icon);return a.jsxs("div",{draggable:!0,onDragStart:k=>x(k,N.id),onDragOver:v,onDrop:k=>g(k,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(jh,{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(ta,{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(Ga,{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(Yt,{className:"w-4 h-4"})})]})]},N.id)})}):a.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[a.jsx(Dh,{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(PZe,{link:i,onClose:()=>{r(!1),s(null)}}),o&&a.jsx(xn,{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 Tj={immediate:"archive",review:"review",print_queue:"queue",proxy:"proxy"};function jZe({printer:t,models:e}){const{t:n}=Dt(),r=Qt(),{showToast:i}=dn(),[s,o]=w.useState(!0),[l,c]=w.useState(t.enabled),[d,u]=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||""),[k,P]=w.useState(t.model||""),[C,j]=w.useState(!1),[M,E]=w.useState(null),[B,L]=w.useState(!1);w.useEffect(()=>{M||(c(t.enabled),x(t.mode==="queue"?"review":t.mode),u(t.name),g(t.target_printer_id),_(t.bind_ip||""),A(t.remote_interface_ip||""),P(t.model||""))},[t,M]);const{data:U}=Ze({queryKey:["printers"],queryFn:J.getPrinters}),{data:D}=Ze({queryKey:["network-interfaces"],queryFn:()=>J.getNetworkInterfaces().then(ie=>ie.interfaces)}),$=st({mutationFn:ie=>N1.update(t.id,ie),onSuccess:()=>{r.invalidateQueries({queryKey:["virtual-printers"]}),i(n("virtualPrinter.toast.updated")),E(null)},onError:ie=>{i(ie.message||n("virtualPrinter.toast.failedToUpdate"),"error"),c(t.enabled),x(t.mode==="queue"?"review":t.mode),g(t.target_printer_id),_(t.bind_ip||""),E(null)}}),q=st({mutationFn:()=>N1.remove(t.id),onSuccess:()=>{r.invalidateQueries({queryKey:["virtual-printers"]}),i(n("virtualPrinter.toast.deleted")),L(!1)},onError:ie=>{i(ie.message||n("virtualPrinter.toast.failedToDelete"),"error"),L(!1)}}),z=ie=>{ie.stopPropagation();const me=!l;if(me){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(me),E("toggle"),$.mutate({enabled:me})},W=()=>{d.trim()&&(E("name"),$.mutate({name:d.trim()}))},Q=()=>{if(!h){i(n("virtualPrinter.toast.accessCodeEmpty"),"error");return}if(h.length!==8){i(n("virtualPrinter.toast.accessCodeLength"),"error");return}E("accessCode"),$.mutate({access_code:h}),f("")},te=ie=>{x(ie),E("mode"),$.mutate({mode:ie})},H=ie=>{P(ie),E("model"),$.mutate({model:ie})},X=ie=>{g(ie),E("targetPrinter"),$.mutate({target_printer_id:ie})},Z=ie=>{A(ie),E("remoteInterface"),$.mutate({remote_interface_ip:ie})},ee=t.status?.running||!1,Se=n(`virtualPrinter.mode.${Tj[p]||"archive"}`),oe=U?.find(ie=>ie.id===v)?.name;return a.jsxs(a.Fragment,{children:[a.jsxs(St,{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(Mn,{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 ${ee?"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:Se}),t.model_name&&a.jsx("span",{className:"text-xs text-bambu-gray flex-shrink-0",children:t.model_name}),oe&&a.jsxs("span",{className:"text-xs text-bambu-gray flex-shrink-0 truncate",children:[p==="proxy"&&a.jsx(n3,{className:"w-3 h-3 inline mr-1"}),oe]}),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:ie=>ie.stopPropagation(),children:a.jsx("button",{onClick:z,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(Nt,{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:d,onChange:ie=>u(ie.target.value),onBlur:W,onKeyDown:ie=>ie.key==="Enter"&&W(),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:()=>L(!0),className:"p-1.5 text-bambu-gray hover:text-red-400 transition-colors",title:n("common.delete"),children:a.jsx(Yt,{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(ie=>a.jsxs("button",{onClick:()=>te(ie),disabled:M==="mode",className:`p-2 rounded-lg border text-left transition-colors ${p===ie?ie==="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:[ie==="proxy"&&a.jsx(n3,{className:"w-3 h-3"}),n(`virtualPrinter.mode.${Tj[ie]}`)]}),a.jsx("div",{className:"text-[10px] text-bambu-gray",children:n(`virtualPrinter.mode.${Tj[ie]}Desc`)})]},ie))})]}),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:k,onChange:ie=>H(ie.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(([ie,me])=>a.jsxs("option",{value:ie,children:[me," (",ie,")"]},ie))}),a.jsx(Mn,{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(eo,{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(na,{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(An,{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:C?"text":"password",value:h,onChange:ie=>f(ie.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:()=>j(!C),className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",children:C?a.jsx(cv,{className:"w-4 h-4"}):a.jsx(Zl,{className:"w-4 h-4"})})]}),a.jsx(Me,{onClick:Q,disabled:!h||M==="accessCode",variant:"primary",children:M==="accessCode"?a.jsx(at,{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:ie=>{const me=parseInt(ie.target.value,10);isNaN(me)||X(me)},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")}),U?.map(ie=>a.jsxs("option",{value:ie.id,children:[ie.name," (",ie.ip_address,")"]},ie.id))]}),a.jsx(Mn,{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:ie=>{_(ie.target.value),E("bindIp"),$.mutate({bind_ip:ie.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")}),D?.map(ie=>a.jsxs("option",{value:ie.ip,children:[ie.name," (",ie.ip,")",ie.is_alias?" [alias]":""," - ",ie.subnet]},ie.ip))]}),a.jsx(Mn,{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(na,{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(eo,{className:"w-3 h-3"})})]}),a.jsxs("div",{className:"relative",children:[a.jsxs("select",{value:N,onChange:ie=>Z(ie.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")}),D?.map(ie=>a.jsxs("option",{value:ie.ip,children:[ie.name," (",ie.ip,") - ",ie.subnet]},ie.ip))]}),a.jsx(Mn,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]})]})]})]}),B&&a.jsx(xn,{title:n("virtualPrinter.deleteConfirm.title"),message:n("virtualPrinter.deleteConfirm.message",{name:t.name}),variant:"danger",confirmText:n("common.delete"),isLoading:q.isPending,onConfirm:()=>q.mutate(),onCancel:()=>L(!1)})]})}const iK={immediate:"archive",review:"review",print_queue:"queue",proxy:"proxy"};function DZe({onClose:t}){const{t:e}=Dt(),n=Qt(),{showToast:r}=dn(),[i,s]=w.useState(""),[o,l]=w.useState("immediate"),[c,d]=w.useState(null),{data:u}=Ze({queryKey:["printers"],queryFn:J.getPrinters}),h=st({mutationFn:()=>N1.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(St,{className:"w-full max-w-md",onClick:f=>f.stopPropagation(),children:a.jsxs(Nt,{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(n3,{className:"w-3 h-3"}),e(`virtualPrinter.mode.${iK[f]}`)]}),a.jsx("div",{className:"text-[10px] text-bambu-gray",children:e(`virtualPrinter.mode.${iK[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);d(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")}),u?.map(f=>a.jsxs("option",{value:f.id,children:[f.name," (",f.ip_address,")"]},f.id))]}),a.jsx(Mn,{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(Me,{variant:"secondary",onClick:t,className:"flex-1",disabled:h.isPending,children:e("common.cancel")}),a.jsx(Me,{variant:"primary",onClick:()=>h.mutate(),className:"flex-1",disabled:h.isPending,children:h.isPending?a.jsx(at,{className:"w-4 h-4 animate-spin"}):e("virtualPrinter.addDialog.create")})]})]})})})}function RZe(){const{t}=Dt(),[e,n]=w.useState(!1),{data:r,isLoading:i}=Ze({queryKey:["virtual-printers"],queryFn:N1.list,refetchInterval:1e4});if(i)return a.jsx(St,{children:a.jsx(Nt,{className:"py-8 flex justify-center",children:a.jsx(at,{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(St,{className:"border-l-4 border-l-yellow-500",children:a.jsx(Nt,{className:"py-3 px-4",children:a.jsxs("div",{className:"flex items-start gap-2",children:[a.jsx(An,{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(ta,{className:"w-3 h-3"}),t("virtualPrinter.setupRequired.readGuide")]})]})]})})}),a.jsx(St,{className:"lg:col-span-3",children:a.jsx(Nt,{className:"py-3 px-4",children:a.jsxs("div",{className:"flex items-start gap-2",children:[a.jsx(eo,{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(Nr,{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(Me,{variant:"primary",onClick:()=>n(!0),children:[a.jsx(Xn,{className:"w-4 h-4 mr-1"}),t("virtualPrinter.list.add")]})]}),s.length===0?a.jsx(St,{children:a.jsxs(Nt,{className:"py-8 text-center",children:[a.jsx(Nr,{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(Me,{variant:"primary",onClick:()=>n(!0),children:[a.jsx(Xn,{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(jZe,{printer:l,models:o},l.id))}),e&&a.jsx(DZe,{onClose:()=>n(!1)})]})}function sK({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(yr,{className:"w-3 h-3"}),failed:a.jsx(mi,{className:"w-3 h-3"}),skipped:a.jsx(PF,{className:"w-3 h-3"}),running:a.jsx(at,{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 FZe(t){return t?new Date(t).toLocaleString():"-"}function LZe(){const t=Qt(),{showToast:e}=dn(),{t:n}=Dt(),[r,i]=w.useState(""),[s,o]=w.useState(""),[l,c]=w.useState("main"),[d,u]=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),[k,P]=w.useState(!1),[C,j]=w.useState(!1),[M,E]=w.useState(""),[B,L]=w.useState(!1),[U,D]=w.useState(null),[$,q]=w.useState(null),z=w.useRef(null);w.useEffect(()=>{if(k||C){const O=R=>(R.preventDefault(),R.returnValue="A backup operation is in progress. Are you sure you want to leave?",R.returnValue);return window.addEventListener("beforeunload",O),()=>window.removeEventListener("beforeunload",O)}},[k,C]);const[W,Q]=w.useState(!1),[te,H]=w.useState(null),X=w.useRef(null),Z=w.useRef(!1),{data:ee,isLoading:Se}=Ze({queryKey:["github-backup-config"],queryFn:J.getGitHubBackupConfig}),{data:oe}=Ze({queryKey:["github-backup-status"],queryFn:J.getGitHubBackupStatus,refetchInterval:be=>be.state.data?.is_running?500:1e4}),{data:ie}=Ze({queryKey:["github-backup-logs"],queryFn:()=>J.getGitHubBackupLogs(20)}),{data:me}=Ze({queryKey:["cloud-status"],queryFn:J.getCloudStatus}),{data:se}=Ze({queryKey:["printers"],queryFn:J.getPrinters}),ce=lv({queries:(se??[]).map(be=>({queryKey:["printerStatus",be.id],queryFn:()=>J.getPrinterStatus(be.id),staleTime:1e4,refetchInterval:3e4}))}),Ce=(se??[]).map((be,O)=>({printer:be,connected:ce[O]?.data?.connected??!1})),le=Ce.length,Le=Ce.filter(be=>be.connected).length,V=le>0&&Le===0,K=Le>0&&Le<le;w.useEffect(()=>{ee&&(i(ee.repository_url),c(ee.branch),u(ee.schedule_enabled),f(ee.schedule_type),x(ee.backup_kprofiles),g(ee.backup_cloud_profiles),_(ee.backup_settings),A(ee.enabled),o(""),setTimeout(()=>{Z.current=!0},100))},[ee]);const fe=w.useCallback(async(be=!1)=>{if(ee?.has_token)try{be&&s?(await J.saveGitHubBackupConfig({repository_url:r,access_token:s,branch:l,schedule_enabled:d,schedule_type:h,backup_kprofiles:p,backup_cloud_profiles:v,backup_settings:y,enabled:N}),o(""),e("Token updated")):(await J.updateGitHubBackupConfig({repository_url:r,branch:l,schedule_enabled:d,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(O){e(`Failed to save: ${O.message}`,"error")}},[ee?.has_token,r,s,l,d,h,p,v,y,N,t,e]);w.useEffect(()=>{if(!(!Z.current||!ee?.has_token))return X.current&&clearTimeout(X.current),X.current=setTimeout(()=>{fe(!1)},500),()=>{X.current&&clearTimeout(X.current)}},[r,l,d,h,p,v,y,N,fe,ee?.has_token]),w.useEffect(()=>{if(!(!Z.current||!ee?.has_token||!s))return X.current&&clearTimeout(X.current),X.current=setTimeout(()=>{fe(!0)},1e3),()=>{X.current&&clearTimeout(X.current)}},[s,fe,ee?.has_token]);const Y=st({mutationFn:be=>J.saveGitHubBackupConfig(be),onSuccess:()=>{t.invalidateQueries({queryKey:["github-backup-config"]}),t.invalidateQueries({queryKey:["github-backup-status"]}),e("GitHub backup enabled"),o(""),Z.current=!0},onError:be=>{e(`Failed to save: ${be.message}`,"error")}}),re=st({mutationFn:J.triggerGitHubBackup,onSuccess:be=>{t.invalidateQueries({queryKey:["github-backup-status"]}),t.invalidateQueries({queryKey:["github-backup-logs"]}),be.success?be.files_changed>0?e(`Backup complete - ${be.files_changed} files updated`):e("Backup skipped - no changes"):e(`Backup failed: ${be.message}`,"error")},onError:be=>{e(`Backup failed: ${be.message}`,"error")}}),ue=st({mutationFn:()=>J.clearGitHubBackupLogs(0),onSuccess:be=>{t.invalidateQueries({queryKey:["github-backup-logs"]}),e(`Cleared ${be.deleted} logs`)},onError:be=>{e(`Failed to clear logs: ${be.message}`,"error")}}),Fe=async()=>{Q(!0),H(null);try{let be;if(s){if(!r){e("Enter repository URL","error"),Q(!1);return}be=await J.testGitHubConnection(r,s)}else if(ee?.has_token)be=await J.testGitHubStoredConnection();else{e("Enter repository URL and access token","error"),Q(!1);return}H({success:be.success,message:be.message})}catch(be){H({success:!1,message:be.message})}finally{Q(!1)}},Pe=()=>{if(!r){e("Repository URL is required","error");return}if(!s){e("Access token is required","error");return}Y.mutate({repository_url:r,access_token:s,branch:l,schedule_enabled:d,schedule_type:h,backup_kprofiles:p,backup_cloud_profiles:v,backup_settings:y,enabled:N})};return Se?a.jsx("div",{className:"flex items-center justify-center py-12",children:a.jsx(at,{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(St,{children:[a.jsx(On,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(i3,{className:"w-5 h-5 text-gray-400"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:"GitHub Backup"})]}),ee&&me?.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(Ln,{checked:N,onChange:A})]})]})}),a.jsx(Nt,{className:"space-y-4",children:me?.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:be=>{i(be.target.value),H(null)},placeholder:"https://github.com/username/bambuddy-backup",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:["Personal Access Token ",ee?.has_token&&a.jsx("span",{className:"text-green-400",children:"(saved)"})]}),a.jsx("input",{type:"password",value:s,onChange:be=>{o(be.target.value),H(null)},placeholder:ee?.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:be=>c(be.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:d?h:"disabled",onChange:be=>{be.target.value==="disabled"?u(!1):(u(!0),f(be.target.value))},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"disabled",children:"Manual only"}),a.jsx("option",{value:"hourly",children:"Hourly"}),a.jsx("option",{value:"daily",children:"Daily"}),a.jsx("option",{value:"weekly",children:"Weekly"})]})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"Include in backup"}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("label",{className:`flex items-start gap-2 ${V?"cursor-not-allowed opacity-60":"cursor-pointer"}`,children:[a.jsx("input",{type:"checkbox",checked:p,onChange:be=>x(be.target.checked),className:"w-4 h-4 mt-0.5 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green",disabled:V}),a.jsxs("div",{className:"flex-1",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:`text-sm ${V?"text-bambu-gray":"text-white"}`,children:"K-Profiles"}),V&&a.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-xs bg-yellow-500/20 text-yellow-400",children:[a.jsx(An,{className:"w-3 h-3"}),"No printers connected"]}),K&&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(An,{className:"w-3 h-3"}),Le,"/",le," 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:be=>g(be.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:!me?.is_authenticated}),a.jsxs("div",{children:[a.jsx("span",{className:`text-sm ${me?.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:be=>_(be.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:[oe?.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:oe.last_backup_at?a.jsxs(a.Fragment,{children:[a.jsxs("span",{children:["Last backup: ",g0(oe.last_backup_at,"system",n)]}),a.jsx(sK,{status:oe.last_backup_status})]}):a.jsx("span",{children:"No backups yet"})}),oe.next_scheduled_run&&a.jsxs("span",{className:"text-bambu-gray",children:[a.jsx(qn,{className:"w-3 h-3 inline mr-1"}),"Next: ",g0(oe.next_scheduled_run,"system",n)]})]}),te&&a.jsxs("div",{className:`text-sm flex items-center gap-1 ${te.success?"text-green-400":"text-red-400"}`,children:[te.success?a.jsx(yr,{className:"w-4 h-4"}):a.jsx(mi,{className:"w-4 h-4"}),te.message]}),a.jsx("div",{className:"flex flex-wrap items-center gap-2",children:oe?.configured?a.jsx(a.Fragment,{children:re.isPending||oe.is_running?a.jsxs("div",{className:"flex items-center gap-2 text-bambu-green",children:[a.jsx(at,{className:"w-4 h-4 animate-spin"}),a.jsx("span",{className:"text-sm",children:oe.progress||"Starting backup..."})]}):a.jsxs(a.Fragment,{children:[a.jsxs(Me,{variant:"primary",size:"sm",onClick:()=>re.mutate(),disabled:!ee?.enabled,children:[a.jsx(oo,{className:"w-4 h-4"}),"Backup Now"]}),a.jsxs(Me,{variant:"secondary",size:"sm",onClick:Fe,disabled:W,children:[W?a.jsx(at,{className:"w-4 h-4 animate-spin"}):a.jsx(Sr,{className:"w-4 h-4"}),"Test"]})]})}):a.jsxs(a.Fragment,{children:[a.jsxs(Me,{variant:"primary",size:"sm",onClick:Pe,disabled:Y.isPending||!r||!s,children:[Y.isPending?a.jsx(at,{className:"w-4 h-4 animate-spin"}):a.jsx(yr,{className:"w-4 h-4"}),"Enable Backup"]}),a.jsxs(Me,{variant:"secondary",size:"sm",onClick:Fe,disabled:W||!r||!s,children:[W?a.jsx(at,{className:"w-4 h-4 animate-spin"}):a.jsx(Sr,{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(An,{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."})]})})]}),ie&&ie.length>0&&a.jsxs(St,{children:[a.jsx(On,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(f0,{className:"w-5 h-5 text-gray-400"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:"History"})]}),a.jsxs(Me,{variant:"ghost",size:"sm",onClick:()=>ue.mutate(),disabled:ue.isPending,children:[a.jsx(Yt,{className:"w-4 h-4"}),"Clear"]})]})}),a.jsx(Nt,{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:ie.slice(0,10).map(be=>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:FZe(be.started_at)}),a.jsx("td",{className:"py-2 px-2",children:a.jsx(sK,{status:be.status})}),a.jsx("td",{className:"py-2 px-2",children:be.commit_sha?a.jsxs("a",{href:`${ee?.repository_url}/commit/${be.commit_sha}`,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-green hover:underline inline-flex items-center gap-1",children:[be.commit_sha.substring(0,7),a.jsx(ta,{className:"w-3 h-3"})]}):a.jsx("span",{className:"text-bambu-gray",children:"-"})})]},be.id))})]})})})]})]}),a.jsx("div",{className:"space-y-6",children:a.jsxs(St,{children:[a.jsx(On,{children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(jc,{className:"w-5 h-5 text-gray-400"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:"Local Backup"})]})}),a.jsxs(Nt,{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:"Create a complete backup of your Bambuddy data including the database, archives, uploads, and all files."}),a.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:"Download Backup"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Complete backup: database + all files (ZIP)"})]}),a.jsxs(Me,{variant:"secondary",size:"sm",disabled:k||C,onClick:async()=>{P(!0),E("Preparing backup...");try{E("Creating backup archive... This may take a while for large archives.");const{blob:be,filename:O}=await J.exportBackup();E("Downloading backup file...");const R=URL.createObjectURL(be),G=document.createElement("a");G.href=R,G.download=O,G.click(),URL.revokeObjectURL(R),e("Backup downloaded successfully")}catch(be){e(`Failed to create backup: ${be instanceof Error?be.message:"Unknown error"}`,"error")}finally{P(!1),E("")}},children:[a.jsx(ga,{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:z,type:"file",accept:".zip",className:"hidden",onChange:be=>{const O=be.target.files?.[0];O&&(D(O),L(!0)),be.target.value=""}}),a.jsxs(Me,{variant:"secondary",size:"sm",disabled:C||k,onClick:()=>z.current?.click(),children:[a.jsx(Oa,{className:"w-4 h-4"}),"Restore"]})]}),$&&a.jsx("div",{className:`p-3 rounded-lg ${$.success?"bg-green-500/10 border border-green-500/30":"bg-red-500/10 border border-red-500/30"}`,children:a.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[$.success?a.jsx(yr,{className:"w-4 h-4 text-green-400 mt-0.5 flex-shrink-0"}):a.jsx(mi,{className:"w-4 h-4 text-red-400 mt-0.5 flex-shrink-0"}),a.jsxs("div",{className:$.success?"text-green-200":"text-red-200",children:[$.message,$.success&&a.jsx("div",{className:"mt-2",children:a.jsxs(Me,{size:"sm",onClick:()=>window.location.reload(),children:[a.jsx(lo,{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(An,{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."})]})]})})]})]})}),B&&U&&a.jsx(xn,{title:"Restore Backup",message:`Are you sure you want to restore from "${U.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()=>{L(!1),j(!0),q(null);try{E("Uploading backup file...");const be=await J.importBackup(U);q(be),be.success?e("Backup restored. Please restart Bambuddy.","success"):e(be.message,"error")}catch(be){const O=be instanceof Error?be.message:"Failed to restore backup";q({success:!1,message:O}),e(O,"error")}finally{j(!1),E(""),D(null)}},onCancel:()=>{L(!1),D(null)}}),(k||C)&&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:k?"Creating Backup":"Restoring Backup"}),a.jsx("p",{className:"text-bambu-gray mb-4",children:M||(k?"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(An,{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 OZe={starttls:587,ssl:465,none:25},IZe={587:"starttls",465:"ssl",25:"none"};function zZe(){const{t}=Dt(),{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}=Ze({queryKey:["smtpSettings"],queryFn:()=>J.getSMTPSettings()}),{data:d}=Ze({queryKey:["advancedAuthStatus"],queryFn:()=>J.getAdvancedAuthStatus()});w.useEffect(()=>{l&&i({...l,smtp_password:""})},[l]);const u=P=>{i({...r,smtp_security:P,smtp_port:OZe[P]})},h=P=>{const C=IZe[P];i({...r,smtp_port:P,...C?{smtp_security:C}:{}})},f=P=>{i({...r,smtp_auth_enabled:P,...P?{}:{smtp_username:"",smtp_password:""}})},p=st({mutationFn:P=>J.saveSMTPSettings(P),onSuccess:()=>{n.invalidateQueries({queryKey:["smtpSettings"]}),n.invalidateQueries({queryKey:["advancedAuthStatus"]}),e(t("settings.email.success.settingsSaved"),"success")},onError:P=>{e(P.message,"error")}}),x=st({mutationFn:P=>J.testSMTP(P),onSuccess:P=>{e(P.message,P.success?"success":"error")},onError:P=>{e(P.message,"error")}}),v=st({mutationFn:P=>P?J.enableAdvancedAuth():J.disableAdvancedAuth(),onSuccess:P=>{n.invalidateQueries({queryKey:["advancedAuthStatus"]}),e(P.message,"success")},onError:P=>{e(P.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(!d?.advanced_auth_enabled&&!d?.smtp_configured){e(t("settings.email.errors.configureSmtpFirst"),"error");return}v.mutate(!d?.advanced_auth_enabled)};if(c)return a.jsx("div",{className:"flex items-center justify-center p-12",children:a.jsx(at,{className:"w-8 h-8 animate-spin text-bambu-green"})});const N=d?.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",k="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(St,{children:[a.jsx(On,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(p0,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:t("settings.email.advancedAuth")||"Advanced Authentication"})]}),a.jsx(Me,{onClick:_,disabled:v.isPending,variant:N?"danger":"primary",children:N?a.jsxs(a.Fragment,{children:[a.jsx(U_,{className:"w-4 h-4"}),t("settings.email.disable")||"Disable"]}):a.jsxs(a.Fragment,{children:[a.jsx(Um,{className:"w-4 h-4"}),t("settings.email.enable")||"Enable"]})})]})}),a.jsx(Nt,{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(yr,{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(An,{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(St,{children:[a.jsx(On,{children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:t("settings.email.smtpSettings")||"SMTP Configuration"})}),a.jsx(Nt,{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:P=>f(P.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:P=>i({...r,smtp_username:P.target.value}),placeholder:"your.email@gmail.com",disabled:!r.smtp_auth_enabled,className:r.smtp_auth_enabled?A:k})]}),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:P=>i({...r,smtp_password:P.target.value}),placeholder:l?"••••••••":"App password",disabled:!r.smtp_auth_enabled,className:r.smtp_auth_enabled?A:k})]})]}),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:P=>i({...r,smtp_host:P.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:P=>h(parseInt(P.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:P=>u(P.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:P=>i({...r,smtp_from_email:P.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:P=>i({...r,smtp_from_name:P.target.value}),placeholder:"BamBuddy",className:A})]})]}),a.jsx("div",{className:"flex gap-2",children:a.jsx(Me,{onClick:g,disabled:p.isPending,className:"flex-1",children:p.isPending?a.jsxs(a.Fragment,{children:[a.jsx(at,{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(St,{children:[a.jsx(On,{children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:t("settings.email.testConnection")||"Test SMTP Connection"})}),a.jsx(Nt,{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:P=>o(P.target.value),placeholder:"test@example.com",className:A})]}),a.jsx(Me,{onClick:y,disabled:x.isPending,variant:"secondary",children:x.isPending?a.jsxs(a.Fragment,{children:[a.jsx(at,{className:"w-4 h-4 animate-spin"}),t("settings.email.sending")||"Sending..."]}):a.jsxs(a.Fragment,{children:[a.jsx(QC,{className:"w-4 h-4"}),t("settings.email.sendTest")||"Send Test Email"]})})]})})]})})]})}const UZe={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 BZe(t,e){const n=e.replace("#/","").split("/");let r=t;for(const i of n)r=r[i];return r}function Iy(t,e,n=0){if(n>5)return"...";if(e.$ref)return Iy(t,BZe(t,e.$ref),n+1);if(e.allOf){const r={};for(const i of e.allOf){const s=Iy(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?[Iy(t,e.items,n+1)]:[];case"object":if(e.properties){const r={};for(const[i,s]of Object.entries(e.properties))r[i]=Iy(t,s,n+1);return r}return{};default:return null}}function HZe({path:t,method:e,spec:n,schema:r,apiKey:i}){const[s,o]=w.useState(!1),[l,c]=w.useState({}),[d,u]=w.useState(""),[h,f]=w.useState(null),[p,x]=w.useState(!1),[v,g]=w.useState(!1);w.useEffect(()=>{if(s&&n.parameters){const j={};for(const M of n.parameters)M.schema?.default!==void 0&&(j[M.name]=String(M.schema.default));c(M=>({...j,...M}))}},[s,n.parameters]),w.useEffect(()=>{if(s&&n.requestBody?.content?.["application/json"]?.schema&&!d){const j=n.requestBody.content["application/json"].schema,M=Iy(r,j);u(JSON.stringify(M,null,2))}},[s,n.requestBody,r,d]);const _=(()=>{const j=[];for(const M of n.parameters||[])if(M.in==="path"||M.required){const E=l[M.name];(E===void 0||E==="")&&j.push(M.name)}return j})(),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 j=t;const M=new URLSearchParams;for(const te of n.parameters||[]){const H=l[te.name];H!==void 0&&H!==""&&(te.in==="path"?j=j.replace(`{${te.name}}`,encodeURIComponent(H)):te.in==="query"&&M.append(te.name,H))}const E=M.toString(),B=`${j}${E?`?${E}`:""}`,L={"Content-Type":"application/json"};i&&(L["X-API-Key"]=i);const U={method:e.toUpperCase(),headers:L};["post","put","patch"].includes(e)&&d&&(U.body=d);const D=performance.now(),$=await fetch(B,U),q=Math.round(performance.now()-D),z={};$.headers.forEach((te,H)=>{z[H]=te});let W;$.headers.get("content-type")?.includes("application/json")?W=await $.json():W=await $.text(),f({status:$.status,statusText:$.statusText,headers:z,body:W,duration:q})}catch(j){f({status:0,statusText:"Network Error",headers:{},body:j instanceof Error?j.message:"Unknown error",duration:0})}finally{x(!1)}},A=async()=>{if(h){const j=typeof h.body=="string"?h.body:JSON.stringify(h.body,null,2);try{await navigator.clipboard.writeText(j),g(!0),setTimeout(()=>g(!1),2e3)}catch{const M=document.createElement("textarea");M.value=j,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)}}},k=(n.parameters||[]).filter(j=>j.in==="path"),P=(n.parameters||[]).filter(j=>j.in==="query"),C=["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(Mn,{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 ${UZe[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}),k.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:k.map(j=>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:[j.name,j.required&&a.jsx("span",{className:"text-red-400 ml-1",children:"*"})]}),a.jsx("input",{type:"text",value:l[j.name]||"",onChange:M=>c(E=>({...E,[j.name]:M.target.value})),placeholder:j.description||j.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"})]},j.name))})]}),P.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:P.map(j=>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:[j.name,j.required&&a.jsx("span",{className:"text-red-400 ml-1",children:"*"})]}),j.schema?.enum?a.jsxs("select",{value:l[j.name]||"",onChange:M=>c(E=>({...E,[j.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 --"}),j.schema.enum.map(M=>a.jsx("option",{value:M,children:M},M))]}):a.jsx("input",{type:"text",value:l[j.name]||"",onChange:M=>c(E=>({...E,[j.name]:M.target.value})),placeholder:j.description||j.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"})]},j.name))})]}),C&&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:d,onChange:j=>u(j.target.value),rows:8,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm font-mono focus:border-bambu-green focus:outline-none resize-y",placeholder:"JSON request body..."})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs(Me,{onClick:N,disabled:p,children:[p?a.jsx(at,{className:"w-4 h-4 animate-spin"}):a.jsx(oo,{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(Va,{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(Me,{variant:"secondary",size:"sm",onClick:A,children:v?a.jsx(yr,{className:"w-3 h-3 text-green-400"}):a.jsx(Ql,{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 $Ze({apiKey:t=""}){const[e,n]=w.useState(null),[r,i]=w.useState(!0),[s,o]=w.useState(null),[l,c]=w.useState(new Set),[d,u]=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(at,{className:"w-8 h-8 text-bambu-green animate-spin"})});if(s||!e)return a.jsx(St,{children:a.jsx(Nt,{className:"py-8",children:a.jsxs("div",{className:"text-center text-red-400",children:[a.jsx(Va,{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 k of A)h[k]||(h[k]=[]),h[k].push({path:g,method:_,spec:N})}const f=Object.entries(h).map(([g,y])=>{if(!d)return{tag:g,endpoints:y};const _=y.filter(({path:N,method:A,spec:k})=>{const P=d.toLowerCase();return N.toLowerCase().includes(P)||A.toLowerCase().includes(P)||(k.summary?.toLowerCase()||"").includes(P)||(k.description?.toLowerCase()||"").includes(P)});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:d,onChange:g=>u(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(Me,{variant:"secondary",size:"sm",onClick:x,children:"Expand All"}),a.jsx(Me,{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(ta,{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(St,{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(Mn,{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(Nt,{className:"pt-0 space-y-2",children:y.map(({path:_,method:N,spec:A})=>a.jsx(HZe,{path:_,method:N,spec:A,schema:e,apiKey:t},`${N}-${_}`))})]},g))})]})}const VZe=["general","network","plugs","notifications","filament","apikeys","virtual-printer","users","backup"],qZe={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"},oK=["bg-blue-500","bg-green-500","bg-yellow-500","bg-red-500","bg-orange-500","bg-teal-500","bg-cyan-500","bg-purple-500"],lK=(t,e)=>qZe[t]||oK[e%oK.length];function GZe(){const t=Qt(),e=ac(),[n,r]=xF(),{t:i,i18n:s}=Dt(),{showToast:o}=dn(),{authEnabled:l,user:c,refreshAuth:d}=jr(),{mode:u,darkStyle:h,darkBackground:f,darkAccent:p,lightStyle:x,lightBackground:v,lightAccent:g,setDarkStyle:y,setDarkBackground:_,setDarkAccent:N,setLightStyle:A,setLightBackground:k,setLightAccent:P}=ep(),[C,j]=w.useState(null),[M,E]=w.useState(!1),[B,L]=w.useState(null),[U,D]=w.useState(!1),[$,q]=w.useState(null),[z,W]=w.useState(null),[Q,te]=w.useState(!1),[H,X]=w.useState(OX()),Z=n.get("tab"),ee=Z==="email",Se=ee?"users":Z&&VZe.includes(Z)?Z:"general",[oe,ie]=w.useState(Se),[me,se]=w.useState(ee?"email":"users"),ce=he=>{ie(he),he==="users"&&se("users"),he==="general"?n.delete("tab"):n.set("tab",he),r(n,{replace:!0})},[Ce,le]=w.useState(!1),[Le,V]=w.useState(""),[K,fe]=w.useState({can_queue:!0,can_control_printer:!1,can_read_status:!0}),[Y,re]=w.useState(null),[ue,Fe]=w.useState(null),[Pe,be]=w.useState(""),[O,R]=w.useState(!1),[G,de]=w.useState(!1),[ge,ae]=w.useState(null),[Ue,ze]=w.useState(!1),[$e,Re]=w.useState(!1),[pe,ve]=w.useState(!1),[Ne,xe]=w.useState({currentPassword:"",newPassword:"",confirmPassword:""}),[we,qe]=w.useState(!1),[ke,nt]=w.useState(!1),[De,We]=w.useState(!1),[Oe,je]=w.useState(!1),[Ve,ot]=w.useState(null),[kt,Ft]=w.useState(null),[Vt,At]=w.useState(null),[Be,mt]=w.useState(!1),[yt,zt]=w.useState({username:"",password:"",email:"",confirmPassword:"",role:"user",group_ids:[]}),[yn,gr]=w.useState(null),[sr,nr]=w.useState(null),[Gn,br]=w.useState(!1),[or,oi]=w.useState({}),[Ie,_e]=w.useState({}),tt=he=>{X(he),Uge(he),o(i("settings.toast.settingsSaved"),"success")},it=()=>{localStorage.removeItem("sidebarOrder"),window.location.reload()},{data:Ke,isLoading:Lt}=Ze({queryKey:["settings"],queryFn:J.getSettings}),{data:ye,isLoading:He,isFetching:Ye}=Ze({queryKey:["storage-usage"],queryFn:()=>J.getStorageUsage(),enabled:oe==="general",staleTime:1/0,refetchInterval:!1,refetchOnWindowFocus:!1,refetchOnReconnect:!1}),Xe=async()=>{nt(!0);try{const he=await J.getStorageUsage({refresh:!0});t.setQueryData(["storage-usage"],he)}catch(he){const Et=he instanceof Error?he.message:"Failed to refresh storage usage";o(Et,"error")}finally{nt(!1)}},{data:Te,isLoading:ct}=Ze({queryKey:["smart-plugs"],queryFn:J.getSmartPlugs}),{data:gt,isLoading:lt}=Ze({queryKey:["smart-plugs-energy",Te?.map(he=>he.id)],queryFn:async()=>{if(!Te||Te.length===0)return null;const he=await Promise.all(Te.filter(fo=>fo.enabled).map(async fo=>{try{const Ns=await J.getSmartPlugStatus(fo.id);return{plug:fo,status:Ns}}catch{return{plug:fo,status:null}}}));let Et=0,ua=0,Jr=0,Qc=0,lp=0;for(const{plug:fo,status:Ns}of he){const EA=fo.plug_type==="mqtt"&&Ns?.energy?.power!=null;(Ns?.reachable||EA)&&Ns?.energy&&(lp++,Ns.energy?.power!=null&&(Et+=Ns.energy.power),Ns.energy?.today!=null&&(ua+=Ns.energy.today),Ns.energy?.yesterday!=null&&(Jr+=Ns.energy.yesterday),Ns.energy?.total!=null&&(Qc+=Ns.energy.total))}return{totalPower:Et,totalToday:ua,totalYesterday:Jr,totalLifetime:Qc,reachableCount:lp,totalPlugs:Te.filter(fo=>fo.enabled).length}},enabled:oe==="plugs"&&!!Te&&Te.length>0,refetchInterval:oe==="plugs"?1e4:!1}),{data:Tt,isLoading:Bt}=Ze({queryKey:["notification-providers"],queryFn:J.getNotificationProviders}),{data:It,isLoading:Pt}=Ze({queryKey:["api-keys"],queryFn:J.getAPIKeys}),tn=st({mutationFn:he=>J.createAPIKey(he),onSuccess:he=>{re(he.key||null),le(!1),V(""),t.invalidateQueries({queryKey:["api-keys"]}),o(i("settings.toast.apiKeyCreated"))},onError:he=>{o(`Failed to create API key: ${he.message}`,"error")}}),en=st({mutationFn:he=>J.deleteAPIKey(he),onSuccess:()=>{t.invalidateQueries({queryKey:["api-keys"]}),o(i("settings.toast.apiKeyDeleted"))},onError:he=>{o(`Failed to delete API key: ${he.message}`,"error")}}),{data:on}=Ze({queryKey:["printers"],queryFn:J.getPrinters}),{data:gn,isLoading:Tn}=Ze({queryKey:["notification-templates"],queryFn:J.getNotificationTemplates}),{data:Zt}=Ze({queryKey:["virtual-printer-settings"],queryFn:_ge.getSettings,refetchInterval:1e4}),fn=Zt?.status?.running??!1,{data:un}=Ze({queryKey:["ffmpeg-status"],queryFn:J.checkFfmpeg}),{data:qr}=Ze({queryKey:["version"],queryFn:J.getVersion}),{data:pn,refetch:lr,isRefetching:as}=Ze({queryKey:["updateCheck"],queryFn:J.checkForUpdates,enabled:Ke?.check_updates!==!1,staleTime:300*1e3}),{data:bn,refetch:vr}=Ze({queryKey:["updateStatus"],queryFn:J.getUpdateStatus,refetchInterval:he=>{const Et=he.state.data;return Et?.status==="downloading"||Et?.status==="installing"?1e3:!1}}),{data:Qn}=Ze({queryKey:["mqtt-status"],queryFn:J.getMQTTStatus,refetchInterval:oe==="network"?5e3:!1}),{data:xa}=Ze({queryKey:["github-backup-status"],queryFn:J.getGitHubBackupStatus}),{data:Ua}=Ze({queryKey:["cloud-status"],queryFn:J.getCloudStatus}),{data:aa={advanced_auth_enabled:!1,smtp_configured:!1}}=Ze({queryKey:["advancedAuthStatus"],queryFn:()=>J.getAdvancedAuthStatus()}),{hasPermission:bt}=jr(),{data:Ot=[],isLoading:vn}=Ze({queryKey:["users"],queryFn:()=>J.getUsers(),enabled:l&&bt("users:read")}),{data:vt=[],isLoading:Un}=Ze({queryKey:["groups"],queryFn:()=>J.getGroups(),enabled:l&&bt("groups:read")}),Qr=st({mutationFn:he=>J.createUser(he),onSuccess:()=>{t.invalidateQueries({queryKey:["users"]}),t.invalidateQueries({queryKey:["groups"]}),We(!1),zt({username:"",password:"",email:"",confirmPassword:"",role:"user",group_ids:[]}),o(i("settings.toast.userCreated"))},onError:he=>{o(he.message,"error")}}),Zn=st({mutationFn:({id:he,data:Et})=>J.updateUser(he,Et),onSuccess:()=>{t.invalidateQueries({queryKey:["users"]}),t.invalidateQueries({queryKey:["groups"]}),je(!1),ot(null),zt({username:"",password:"",email:"",confirmPassword:"",role:"user",group_ids:[]}),o(i("settings.toast.userUpdated"))},onError:he=>{o(he.message,"error")}}),dr=st({mutationFn:({id:he,deleteItems:Et})=>J.deleteUser(he,Et),onSuccess:()=>{t.invalidateQueries({queryKey:["users"]}),o(i("settings.toast.userDeleted")),Ft(null),At(null)},onError:he=>{o(he.message,"error")}}),li=st({mutationFn:he=>J.resetUserPassword({user_id:he}),onSuccess:he=>{o(he.message,"success")},onError:he=>{o(he.message,"error")}}),rn=async he=>{Ft(he),mt(!0);try{const Et=await J.getUserItemsCount(he);At(Et)}catch{At({archives:0,queue_items:0,library_files:0})}finally{mt(!1)}},Pn=st({mutationFn:he=>J.deleteGroup(he),onSuccess:()=>{t.invalidateQueries({queryKey:["groups"]}),o(i("settings.toast.groupDeleted"))},onError:he=>{o(he.message,"error")}}),Ci=()=>{const he=aa?.advanced_auth_enabled||!1;if(!yt.username){o(i("settings.toast.fillRequiredFields"),"error");return}if(he&&!yt.email){o("Email is required when advanced authentication is enabled","error");return}if(!he){if(!yt.password){o(i("settings.toast.fillRequiredFields"),"error");return}if(yt.password!==yt.confirmPassword){o(i("settings.toast.passwordsDoNotMatch"),"error");return}if(yt.password.length<6){o(i("settings.toast.passwordTooShort"),"error");return}}Qr.mutate({username:yt.username,password:he?void 0:yt.password,email:yt.email||void 0,role:yt.role,group_ids:yt.group_ids.length>0?yt.group_ids:void 0})},Bs=he=>{if(yt.password){if(yt.password!==yt.confirmPassword){o(i("settings.toast.passwordsDoNotMatch"),"error");return}if(yt.password.length<6){o(i("settings.toast.passwordTooShort"),"error");return}}const Et={username:yt.username||void 0,password:yt.password||void 0,role:yt.role,group_ids:yt.group_ids};Et.password||delete Et.password,Zn.mutate({id:he,data:Et})},zo=he=>{ot(he.id),zt({username:he.username,password:"",email:he.email||"",confirmPassword:"",role:he.role,group_ids:he.groups?.map(Et=>Et.id)||[]}),je(!0)},Uo=he=>{zt(Et=>({...Et,group_ids:Et.group_ids.includes(he)?Et.group_ids.filter(ua=>ua!==he):[...Et.group_ids,he]}))},zi=st({mutationFn:J.applyUpdate,onSuccess:he=>{he.is_docker?o(he.message,"error"):vr()}}),[Dr,Hs]=w.useState(null),Ca=st({mutationFn:J.testAllNotificationProviders,onSuccess:he=>{Hs(he),t.invalidateQueries({queryKey:["notification-providers"]}),he.failed===0?o(`All ${he.tested} providers tested successfully!`,"success"):o(`${he.success}/${he.tested} providers succeeded`,he.failed>0?"error":"success")},onError:he=>{o(`Failed to test providers: ${he.message}`,"error")}}),Zr=st({mutationFn:async he=>{if(!Te)return{success:0,failed:0};const Et=Te.filter(Jr=>Jr.enabled),ua=await Promise.all(Et.map(async Jr=>{try{return await J.controlSmartPlug(Jr.id,he),{success:!0}}catch{return{success:!1}}}));return{success:ua.filter(Jr=>Jr.success).length,failed:ua.filter(Jr=>!Jr.success).length}},onSuccess:(he,Et)=>{t.invalidateQueries({queryKey:["smart-plugs"]}),t.invalidateQueries({queryKey:["smart-plugs-energy"]}),he.failed===0?o(`All ${he.success} plugs turned ${Et}`,"success"):o(`${he.success} plugs turned ${Et}, ${he.failed} failed`,"error")},onError:he=>{o(`Failed: ${he.message}`,"error")}}),is=w.useRef(null),ur=w.useRef(!1),Ui=w.useRef(!0);w.useEffect(()=>{if(Ke&&!C){const he={...Ke,external_url:Ke.external_url||window.location.origin};j(he),setTimeout(()=>{Ui.current=!1},100)}},[Ke,C]);const Pl=st({mutationFn:J.updateSettings,onSuccess:he=>{t.setQueryData(["settings"],he),t.invalidateQueries({queryKey:["archiveStats"]}),o(i("settings.toast.settingsSaved"),"success")},onError:he=>{o(`Failed to save: ${he.message}`,"error")},onSettled:()=>{ur.current=!1}}),Cr=st({mutationFn:({id:he,data:Et})=>J.updatePrinter(he,Et),onSuccess:()=>{t.invalidateQueries({queryKey:["printers"]}),o(i("settings.toast.cameraSettingsSaved"),"success")},onError:he=>{o(`Failed to update printer: ${he.message}`,"error")}});w.useEffect(()=>{if(!(Ui.current||!C||!Ke||!(Ke.auto_archive!==C.auto_archive||Ke.save_thumbnails!==C.save_thumbnails||Ke.capture_finish_photo!==C.capture_finish_photo||Ke.default_filament_cost!==C.default_filament_cost||Ke.currency!==C.currency||Ke.energy_cost_per_kwh!==C.energy_cost_per_kwh||Ke.energy_tracking_mode!==C.energy_tracking_mode||Ke.check_updates!==C.check_updates||(Ke.check_printer_firmware??!0)!==(C.check_printer_firmware??!0)||(Ke.include_beta_updates??!1)!==(C.include_beta_updates??!1)||Ke.notification_language!==C.notification_language||(Ke.bed_cooled_threshold??35)!==(C.bed_cooled_threshold??35)||Ke.ams_humidity_good!==C.ams_humidity_good||Ke.ams_humidity_fair!==C.ams_humidity_fair||Ke.ams_temp_good!==C.ams_temp_good||Ke.ams_temp_fair!==C.ams_temp_fair||Ke.ams_history_retention_days!==C.ams_history_retention_days||Ke.per_printer_mapping_expanded!==C.per_printer_mapping_expanded||Ke.date_format!==C.date_format||Ke.time_format!==C.time_format||Ke.default_printer_id!==C.default_printer_id||Ke.ftp_retry_enabled!==C.ftp_retry_enabled||Ke.ftp_retry_count!==C.ftp_retry_count||Ke.ftp_retry_delay!==C.ftp_retry_delay||Ke.ftp_timeout!==C.ftp_timeout||Ke.mqtt_enabled!==C.mqtt_enabled||Ke.mqtt_broker!==C.mqtt_broker||Ke.mqtt_port!==C.mqtt_port||Ke.mqtt_username!==C.mqtt_username||Ke.mqtt_password!==C.mqtt_password||Ke.mqtt_topic_prefix!==C.mqtt_topic_prefix||Ke.mqtt_use_tls!==C.mqtt_use_tls||Ke.external_url!==C.external_url||Ke.ha_enabled!==C.ha_enabled||Ke.ha_url!==C.ha_url||Ke.ha_token!==C.ha_token||(Ke.library_archive_mode??"ask")!==(C.library_archive_mode??"ask")||Number(Ke.library_disk_warning_gb??5)!==Number(C.library_disk_warning_gb??5)||(Ke.camera_view_mode??"window")!==(C.camera_view_mode??"window")||(Ke.preferred_slicer??"bambu_studio")!==(C.preferred_slicer??"bambu_studio")||Ke.prometheus_enabled!==C.prometheus_enabled||Ke.prometheus_token!==C.prometheus_token))&&!ur.current)return is.current&&clearTimeout(is.current),is.current=setTimeout(()=>{if(ur.current)return;ur.current=!0;const Et={auto_archive:C.auto_archive,save_thumbnails:C.save_thumbnails,capture_finish_photo:C.capture_finish_photo,default_filament_cost:C.default_filament_cost,currency:C.currency,energy_cost_per_kwh:C.energy_cost_per_kwh,energy_tracking_mode:C.energy_tracking_mode,check_updates:C.check_updates,check_printer_firmware:C.check_printer_firmware,include_beta_updates:C.include_beta_updates,notification_language:C.notification_language,bed_cooled_threshold:C.bed_cooled_threshold,ams_humidity_good:C.ams_humidity_good,ams_humidity_fair:C.ams_humidity_fair,ams_temp_good:C.ams_temp_good,ams_temp_fair:C.ams_temp_fair,ams_history_retention_days:C.ams_history_retention_days,per_printer_mapping_expanded:C.per_printer_mapping_expanded,date_format:C.date_format,time_format:C.time_format,default_printer_id:C.default_printer_id,ftp_retry_enabled:C.ftp_retry_enabled,ftp_retry_count:C.ftp_retry_count,ftp_retry_delay:C.ftp_retry_delay,ftp_timeout:C.ftp_timeout,mqtt_enabled:C.mqtt_enabled,mqtt_broker:C.mqtt_broker,mqtt_port:C.mqtt_port,mqtt_username:C.mqtt_username,mqtt_password:C.mqtt_password,mqtt_topic_prefix:C.mqtt_topic_prefix,mqtt_use_tls:C.mqtt_use_tls,external_url:C.external_url,ha_enabled:C.ha_enabled,ha_url:C.ha_url,ha_token:C.ha_token,library_archive_mode:C.library_archive_mode,library_disk_warning_gb:C.library_disk_warning_gb,camera_view_mode:C.camera_view_mode,preferred_slicer:C.preferred_slicer,prometheus_enabled:C.prometheus_enabled,prometheus_token:C.prometheus_token};Pl.mutate(Et)},500),()=>{is.current&&clearTimeout(is.current)}},[C,Ke,Pl]);const Xt=w.useCallback((he,Et)=>{j(ua=>ua?{...ua,[he]:Et}:null)},[]),ya=async(he,Et,ua)=>{if(!Et){o(i("settings.toast.enterCameraUrl"),"error");return}_e(Jr=>({...Jr,[he]:!0})),oi(Jr=>({...Jr,[he]:null}));try{const Jr=await J.testExternalCamera(he,Et,ua);oi(Qc=>({...Qc,[he]:Jr})),Jr.success?o(i("settings.toast.cameraConnected",{resolution:Jr.resolution||""}),"success"):o(Jr.error||i("settings.toast.connectionFailed"),"error")}catch(Jr){const Qc=Jr instanceof Error?Jr.message:i("settings.toast.testFailed");oi(lp=>({...lp,[he]:{success:!1,error:Qc}})),o(Qc,"error")}finally{_e(Jr=>({...Jr,[he]:!1}))}},[$n,kr]=w.useState({}),Yc=w.useRef({}),Wv=w.useRef(new Set);w.useEffect(()=>{if(on){const he={};on.forEach(Et=>{Et.external_camera_url&&!Wv.current.has(Et.id)&&(he[Et.id]=Et.external_camera_url,Wv.current.add(Et.id))}),Object.keys(he).length>0&&kr(Et=>({...Et,...he}))}},[on]);const hx=(he,Et)=>{kr(ua=>({...ua,[he]:Et})),Yc.current[he]&&clearTimeout(Yc.current[he]),Yc.current[he]=setTimeout(()=>{Cr.mutate({id:he,data:{external_camera_url:Et||null}})},800)},op=(he,Et)=>{const ua={};Et.type!==void 0&&(ua.external_camera_type=Et.type||null),Et.enabled!==void 0&&(ua.external_camera_enabled=Et.enabled),Cr.mutate({id:he,data:ua})};return Lt||!C?a.jsx("div",{className:"p-4 md:p-8 flex justify-center",children:a.jsx(at,{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:()=>ce("general"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px ${oe==="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:()=>ce("plugs"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${oe==="plugs"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[a.jsx(gl,{className:"w-4 h-4"}),i("settings.tabs.smartPlugs"),Te&&Te.length>0&&a.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:Te.length})]}),a.jsxs("button",{onClick:()=>ce("notifications"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${oe==="notifications"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[a.jsx(qg,{className:"w-4 h-4"}),i("settings.tabs.notifications"),Tt&&Tt.length>0&&a.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:Tt.length})]}),a.jsxs("button",{onClick:()=>ce("filament"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${oe==="filament"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[a.jsx(ime,{className:"w-4 h-4"}),i("settings.tabs.filament")]}),a.jsxs("button",{onClick:()=>ce("network"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${oe==="network"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[a.jsx(Wg,{className:"w-4 h-4"}),i("settings.tabs.network"),a.jsx("span",{className:`w-2 h-2 rounded-full ${Qn?.enabled?"bg-green-400":"bg-gray-500"}`})]}),a.jsxs("button",{onClick:()=>ce("apikeys"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${oe==="apikeys"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[a.jsx(al,{className:"w-4 h-4"}),i("settings.tabs.apiKeys"),It&&It.length>0&&a.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:It.length})]}),a.jsxs("button",{onClick:()=>ce("virtual-printer"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${oe==="virtual-printer"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[a.jsx(Nr,{className:"w-4 h-4"}),i("settings.tabs.virtualPrinter"),a.jsx("span",{className:`w-2 h-2 rounded-full ${fn?"bg-green-400":"bg-gray-500"}`})]}),a.jsxs("button",{onClick:()=>ce("users"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${oe==="users"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[a.jsx(fh,{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:()=>ce("backup"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${oe==="backup"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[a.jsx(jc,{className:"w-4 h-4"}),i("settings.tabs.backup"),a.jsx("span",{className:`w-2 h-2 rounded-full ${Ua?.is_authenticated&&xa?.configured&&xa?.enabled?"bg-green-400":"bg-gray-500"}`})]})]}),oe==="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(St,{children:[a.jsx(On,{children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.general")})}),a.jsxs(Nt,{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[a.jsx(Eh,{className:"w-4 h-4 inline mr-1"}),i("settings.language")]}),a.jsxs("div",{className:"relative",children:[a.jsx("select",{value:s.language,onChange:he=>{s.changeLanguage(he.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:xB.map(he=>a.jsxs("option",{value:he.code,children:[he.nativeName," (",he.name,")"]},he.code))}),a.jsx(Mn,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:i("settings.languageDescription")})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:i("settings.defaultView")}),a.jsxs("div",{className:"relative",children:[a.jsx("select",{value:H,onChange:he=>tt(he.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:b0.map(he=>a.jsx("option",{value:he.to,children:i(he.labelKey)},he.id))}),a.jsx(Mn,{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:C.date_format||"system",onChange:he=>Xt("date_format",he.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(Mn,{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:C.time_format||"system",onChange:he=>Xt("time_format",he.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(Mn,{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:C.default_printer_id??"",onChange:he=>Xt("default_printer_id",he.target.value?Number(he.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")}),on?.map(he=>a.jsx("option",{value:he.id,children:he.name},he.id))]}),a.jsx(Mn,{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:C.preferred_slicer??"bambu_studio",onChange:he=>Xt("preferred_slicer",he.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(Mn,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:i("settings.preferredSlicerDescription")})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:i("settings.sidebarOrder")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Drag items in the sidebar to reorder. Reset to default order here."})]}),a.jsxs(Me,{variant:"secondary",size:"sm",onClick:it,children:[a.jsx(lo,{className:"w-4 h-4"}),"Reset"]})]})]})]}),a.jsxs(St,{children:[a.jsx(On,{children:a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(KC,{className:"w-5 h-5"}),"Appearance"]})}),a.jsxs(Nt,{className:"space-y-6",children:[a.jsxs("div",{className:`space-y-3 p-4 rounded-lg border ${u==="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",u==="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:he=>{_(he.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:he=>{N(he.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:he=>{y(he.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 ${u==="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",u==="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:he=>{k(he.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:he=>{P(he.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:he=>{A(he.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(St,{children:[a.jsx(On,{children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.archiveSettings")})}),a.jsxs(Nt,{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:C.auto_archive,onChange:he=>Xt("auto_archive",he.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:C.save_thumbnails,onChange:he=>Xt("save_thumbnails",he.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:C.capture_finish_photo,onChange:he=>Xt("capture_finish_photo",he.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"})]})]}),C.capture_finish_photo&&un&&!un.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(An,{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(St,{children:[a.jsx(On,{children:a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(jF,{className:"w-5 h-5 text-bambu-green"}),"Camera"]})}),a.jsxs(Nt,{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:C.camera_view_mode??"window",onChange:he=>Xt("camera_view_mode",he.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:C.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."}),on&&on.length>0?a.jsx("div",{className:"space-y-3",children:on.map(he=>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:he.name}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:he.external_camera_enabled,onChange:Et=>op(he.id,{enabled:Et.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"})]})]}),he.external_camera_enabled&&a.jsxs("div",{className:"space-y-2 mt-2",children:[a.jsx("input",{type:"text",placeholder:he.external_camera_type==="usb"?"Device path (/dev/video0)":"Camera URL (rtsp://... or http://...)",value:$n[he.id]??he.external_camera_url??"",onChange:Et=>hx(he.id,Et.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:he.external_camera_type||"mjpeg",onChange:Et=>op(he.id,{type:Et.target.value}),className:"flex-1 px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"mjpeg",children:"MJPEG Stream"}),a.jsx("option",{value:"rtsp",children:"RTSP Stream"}),a.jsx("option",{value:"snapshot",children:"HTTP Snapshot"}),a.jsx("option",{value:"usb",children:"USB Camera (V4L2)"})]}),a.jsx(Me,{size:"sm",variant:"secondary",onClick:()=>ya(he.id,$n[he.id]??he.external_camera_url??"",he.external_camera_type||"mjpeg"),disabled:Ie[he.id]||!($n[he.id]??he.external_camera_url),children:Ie[he.id]?a.jsx(at,{className:"w-4 h-4 animate-spin"}):"Test"})]}),or[he.id]&&a.jsx("div",{className:`text-xs flex items-center gap-1 ${or[he.id]?.success?"text-green-500":"text-red-500"}`,children:or[he.id]?.success?a.jsxs(a.Fragment,{children:[a.jsx(yr,{className:"w-3 h-3"}),"Connected",or[he.id]?.resolution&&` (${or[he.id]?.resolution})`]}):a.jsxs(a.Fragment,{children:[a.jsx(mi,{className:"w-3 h-3"}),or[he.id]?.error||i("settings.toast.connectionFailed")]})})]})]},he.id))}):a.jsx("p",{className:"text-xs text-bambu-gray italic",children:i("settings.noPrintersConfigured")})]})]})]}),a.jsxs(St,{children:[a.jsx(On,{children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.costTracking")})}),a.jsxs(Nt,{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:C.currency,onChange:he=>Xt("currency",he.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:D$e.map(he=>a.jsx("option",{value:he.code,children:he.label},he.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:il(C.currency)}),a.jsx("input",{type:"number",step:"0.01",min:"0",value:C.default_filament_cost,onChange:he=>Xt("default_filament_cost",parseFloat(he.target.value)||0),style:{paddingLeft:`${Math.max(2,il(C.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:il(C.currency)}),a.jsx("input",{type:"number",step:"0.001",min:"0",value:C.energy_cost_per_kwh,onChange:he=>Xt("energy_cost_per_kwh",parseFloat(he.target.value)||0),style:{paddingLeft:`${Math.max(2,il(C.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:C.energy_tracking_mode||"total",onChange:he=>Xt("energy_tracking_mode",he.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:C.energy_tracking_mode==="print"?"Dashboard shows sum of energy used during prints":"Dashboard shows lifetime energy from smart plugs"})]})]})]}),a.jsxs(St,{children:[a.jsx(On,{children:a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(Ps,{className:"w-5 h-5 text-bambu-green"}),"File Manager"]})}),a.jsxs(Nt,{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:C.library_archive_mode??"ask",onChange:he=>Xt("library_archive_mode",he.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:C.library_disk_warning_gb??5,onChange:he=>Xt("library_disk_warning_gb",parseFloat(he.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(EZe,{}),a.jsxs(St,{children:[a.jsx(On,{children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:"Updates"})}),a.jsxs(Nt,{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:i("settings.checkForUpdatesLabel")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically check for new versions on startup"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:C.check_updates,onChange:he=>Xt("check_updates",he.target.checked),className:"sr-only peer"}),a.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:i("settings.checkPrinterFirmware")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Check for printer firmware updates from Bambu Lab"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:C.check_printer_firmware??!0,onChange:he=>Xt("check_printer_firmware",he.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 ${C.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:C.include_beta_updates??!1,onChange:he=>Xt("include_beta_updates",he.target.checked),disabled:!C.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",{className:"border-t border-bambu-dark-tertiary pt-4",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:i("settings.currentVersion")}),a.jsxs("p",{className:"text-sm text-bambu-gray",children:["v",qr?.version||"..."]})]}),a.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>lr(),disabled:as,children:[as?a.jsx(at,{className:"w-4 h-4 animate-spin"}):a.jsx(Sr,{className:"w-4 h-4"}),"Check now"]})]}),pn?.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",pn.latest_version]}),pn.release_name&&pn.release_name!==pn.latest_version&&a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:pn.release_name})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[pn.release_notes&&a.jsx("button",{onClick:()=>ze(!0),className:"text-bambu-gray hover:text-white transition-colors text-sm underline",children:"Release Notes"}),pn.release_url&&a.jsx("a",{href:pn.release_url,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-gray hover:text-white transition-colors",title:i("settings.viewReleaseOnGitHub"),children:a.jsx(ta,{className:"w-4 h-4"})})]})]}),bn?.status==="downloading"||bn?.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(at,{className:"w-4 h-4 animate-spin"}),a.jsx("span",{children:bn.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:`${bn.progress}%`}})})]}):bn?.status==="complete"?a.jsx("div",{className:"mt-3 p-2 bg-bambu-green/20 rounded text-sm text-bambu-green",children:bn.message}):bn?.status==="error"?a.jsx("div",{className:"mt-3 p-2 bg-red-500/20 rounded text-sm text-red-400",children:bn.error||bn.message}):pn?.is_docker?a.jsxs("div",{className:"mt-3 p-3 bg-bambu-dark-tertiary rounded-lg",children:[a.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:"Update via Docker Compose:"}),a.jsx("code",{className:"block text-xs bg-bambu-dark p-2 rounded text-bambu-green font-mono",children:"docker compose pull && docker compose up -d"})]}):a.jsxs(Me,{className:"mt-3",onClick:()=>zi.mutate(),disabled:zi.isPending,children:[zi.isPending?a.jsx(at,{className:"w-4 h-4 animate-spin"}):a.jsx(ga,{className:"w-4 h-4"}),"Install Update"]})]}):pn?.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: ",pn.error]}):pn&&!pn.update_available?a.jsx("p",{className:"mt-2 text-sm text-bambu-gray",children:"You're running the latest version"}):null]})]})]}),a.jsxs(St,{children:[a.jsx(On,{children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.dataManagement")})}),a.jsxs(Nt,{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:i("settings.clearNotificationLogs")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:i("settings.clearNotificationLogsDescription")})]}),a.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>R(!0),children:[a.jsx(Yt,{className:"w-4 h-4"}),i("common.clear")]})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:i("settings.resetUiPreferences")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:i("settings.resetUiPreferencesDescription")})]}),a.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>de(!0),children:[a.jsx(Yt,{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(Me,{variant:"secondary",size:"sm",onClick:Xe,disabled:Ye||ke,children:[a.jsx(Sr,{className:`w-4 h-4 ${Ye||ke?"animate-spin":""}`}),i("common.refresh","Refresh")]})]}),a.jsx("div",{className:"mt-3",children:He?a.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[a.jsx(at,{className:"w-4 h-4 animate-spin"}),i("common.loading","Loading")]}):ye?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"w-full h-3 bg-bambu-dark rounded-full overflow-hidden flex",children:ye.categories.filter(he=>he.bytes>0).map((he,Et)=>a.jsx("div",{className:`${lK(he.key,Et)} h-full`,style:{width:`${he.percent_of_total}%`},title:`${he.label}: ${he.formatted}`},he.key))}),a.jsx("div",{className:"mt-3 flex flex-wrap gap-3",children:ye.categories.filter(he=>he.bytes>0).map((he,Et)=>a.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[a.jsx("span",{className:`w-3 h-3 rounded-full ${lK(he.key,Et)}`}),a.jsx("span",{className:"text-bambu-gray",children:he.label}),a.jsx("span",{className:"text-white",children:he.formatted}),a.jsxs("span",{className:"text-bambu-gray",children:["(",he.percent_of_total.toFixed(1),"%)"]})]},he.key))}),a.jsxs("div",{className:"mt-2 text-xs text-bambu-gray",children:[i("settings.storageUsageTotal","Total"),": ",a.jsx("span",{className:"text-white",children:ye.total_formatted}),ye.scan_errors>0&&a.jsxs("span",{className:"ml-2 text-amber-400",children:[i("settings.storageUsageErrors","Scan errors"),": ",ye.scan_errors]})]}),ye.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:ye.other_breakdown.map(he=>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:he.label}),a.jsx("span",{className:`px-2 py-0.5 rounded-full border ${he.kind==="system"?"border-slate-500 text-slate-300":"border-bambu-green text-bambu-green"}`,children:he.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:he.formatted}),a.jsxs("span",{children:["(",he.percent_of_total.toFixed(1),"%)"]})]})]},`${he.bucket}-${he.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(Me,{variant:"secondary",size:"sm",onClick:()=>ce("backup"),children:[a.jsx(jc,{className:"w-4 h-4"}),"Go to Backup"]})]})]})]})]})]}),oe==="network"&&C&&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(St,{children:[a.jsx(On,{children:a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(Eh,{className:"w-5 h-5 text-blue-400"}),"External URL"]})}),a.jsxs(Nt,{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:C.external_url??"",onChange:he=>Xt("external_url",he.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(St,{children:[a.jsx(On,{children:a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(Sr,{className:"w-5 h-5 text-blue-400"}),"FTP Retry"]})}),a.jsxs(Nt,{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:C.ftp_retry_enabled??!0,onChange:he=>Xt("ftp_retry_enabled",he.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"})]})]}),C.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:C.ftp_retry_count??3,onChange:he=>Xt("ftp_retry_count",parseInt(he.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(he=>a.jsxs("option",{value:he,children:[he," ",he===1?"time":"times"]},he))}),a.jsx(Mn,{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:C.ftp_retry_delay??2,onChange:he=>Xt("ftp_retry_delay",parseInt(he.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(he=>a.jsxs("option",{value:he,children:[he," ",he===1?"second":"seconds"]},he))}),a.jsx(Mn,{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:C.ftp_timeout??30,onChange:he=>Xt("ftp_timeout",parseInt(he.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(he=>a.jsxs("option",{value:he,children:[he," seconds"]},he))}),a.jsx(Mn,{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(St,{children:[a.jsx(On,{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(dv,{className:"w-5 h-5 text-bambu-green"}),"Home Assistant"]}),C.ha_enabled&&sr&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${sr.success?"bg-green-400":"bg-red-400"}`}),a.jsx("span",{className:`text-sm ${sr.success?"text-green-400":"text-red-400"}`,children:sr.success?"Connected":"Disconnected"})]})]})}),a.jsxs(Nt,{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")}),C.ha_env_managed&&a.jsxs("div",{className:"flex items-center gap-1 mt-1",children:[a.jsx(Um,{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:C.ha_enabled??!1,onChange:he=>Xt("ha_enabled",he.target.checked),disabled:C.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 ${C.ha_env_managed?"opacity-60 cursor-not-allowed":""}`})]})]}),C.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",C.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:C.ha_url??"",onChange:he=>Xt("ha_url",he.target.value),placeholder:"http://192.168.1.100:8123",disabled:C.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 ${C.ha_url_from_env?"opacity-60 cursor-not-allowed":""}`}),C.ha_url_from_env&&a.jsx(Um,{className:"absolute right-3 top-2.5 w-4 h-4 text-bambu-gray"})]}),C.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",C.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:C.ha_token??"",onChange:he=>Xt("ha_token",he.target.value),placeholder:"eyJ0eXAiOiJKV1QiLC...",disabled:C.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 ${C.ha_token_from_env?"opacity-60 cursor-not-allowed":""}`}),C.ha_token_from_env&&a.jsx(Um,{className:"absolute right-3 top-2.5 w-4 h-4 text-bambu-gray"})]}),C.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"})]}),C.ha_url&&C.ha_token&&a.jsx("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:a.jsxs(Me,{variant:"secondary",size:"sm",disabled:Gn,onClick:async()=>{br(!0),nr(null);try{const he=await J.testHAConnection(C.ha_url,C.ha_token);nr(he)}catch(he){nr({success:!1,message:null,error:he instanceof Error?he.message:i("common.unknownError")})}finally{br(!1)}},children:[Gn?a.jsx(at,{className:"w-4 h-4 animate-spin"}):a.jsx(Wg,{className:"w-4 h-4"}),i("settings.testConnection")]})})]})]})]}),a.jsxs(St,{children:[a.jsx(On,{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(Wg,{className:"w-5 h-5 text-blue-400"}),"MQTT Publishing"]}),Qn?.enabled&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${Qn.connected?"bg-green-400":"bg-red-400"}`}),a.jsx("span",{className:`text-sm ${Qn.connected?"text-green-400":"text-red-400"}`,children:Qn.connected?"Connected":"Disconnected"})]})]})}),a.jsxs(Nt,{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:C.mqtt_enabled??!1,onChange:he=>Xt("mqtt_enabled",he.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"})]})]}),C.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:C.mqtt_broker??"",onChange:he=>Xt("mqtt_broker",he.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:C.mqtt_port??1883,onChange:he=>Xt("mqtt_port",Math.min(65535,Math.max(1,parseInt(he.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:C.mqtt_use_tls??!1,onChange:he=>{const Et=he.target.checked;Xt("mqtt_use_tls",Et);const ua=C.mqtt_port??1883;Et&&ua===1883?Xt("mqtt_port",8883):!Et&&ua===8883&&Xt("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:C.mqtt_username??"",onChange:he=>Xt("mqtt_username",he.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:C.mqtt_password??"",onChange:he=>Xt("mqtt_password",he.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:C.mqtt_topic_prefix??"bambuddy",onChange:he=>Xt("mqtt_topic_prefix",he.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: ",C.mqtt_topic_prefix||"bambuddy","/printers/<serial>/status, etc."]})]}),Qn&&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 ${Qn.connected?"bg-green-400":"bg-red-400"}`}),a.jsx("span",{className:"text-bambu-gray",children:Qn.connected?a.jsxs(a.Fragment,{children:[i("settings.mqttConnectedTo")," ",a.jsxs("span",{className:"text-white",children:[Qn.broker,":",Qn.port]})]}):i("settings.spoolmanDisconnected")})]})})]})]})]})]}),a.jsx("div",{className:"flex-1 lg:max-w-md space-y-4",children:a.jsxs(St,{children:[a.jsx(On,{children:a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(u3,{className:"w-5 h-5 text-orange-400"}),"Prometheus Metrics"]})}),a.jsxs(Nt,{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:C.prometheus_enabled??!1,onChange:he=>Xt("prometheus_enabled",he.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"})]})]}),C.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:C.prometheus_token??"",onChange:he=>Xt("prometheus_token",he.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)"})]})]})]})]})]})})]}),sr&&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:[sr.success?a.jsx(yr,{className:"w-8 h-8 text-green-400"}):a.jsx(mi,{className:"w-8 h-8 text-red-400"}),a.jsx("h3",{className:"text-lg font-medium text-white",children:sr.success?"Connection Successful":"Connection Failed"})]}),a.jsx("p",{className:"text-bambu-gray mb-6",children:sr.success?sr.message||"Successfully connected to Home Assistant.":sr.error||"Failed to connect to Home Assistant."}),a.jsx("div",{className:"flex justify-end",children:a.jsx(Me,{variant:"primary",onClick:()=>nr(null),children:"OK"})})]})}),oe==="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(gl,{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:[Te&&Te.filter(he=>he.enabled).length>1&&a.jsxs(a.Fragment,{children:[a.jsxs(Me,{variant:"secondary",size:"sm",className:"whitespace-nowrap",onClick:()=>ae("on"),disabled:Zr.isPending,title:i("settings.turnAllPlugsOn"),children:[Zr.isPending?a.jsx(at,{className:"w-4 h-4 animate-spin"}):a.jsx(fu,{className:"w-4 h-4 text-bambu-green"}),"All On"]}),a.jsxs(Me,{variant:"secondary",size:"sm",className:"whitespace-nowrap",onClick:()=>ae("off"),disabled:Zr.isPending,title:i("settings.turnAllPlugsOff"),children:[Zr.isPending?a.jsx(at,{className:"w-4 h-4 animate-spin"}):a.jsx(YC,{className:"w-4 h-4 text-red-400"}),"All Off"]})]}),a.jsxs(Me,{className:"whitespace-nowrap",onClick:()=>{L(null),E(!0)},children:[a.jsx(Xn,{className:"w-4 h-4"}),"Add Smart Plug"]})]})]}),Te&&Te.length>0&&a.jsxs(St,{className:"mb-6",children:[a.jsx(On,{children:a.jsxs("h3",{className:"text-base font-semibold text-white flex items-center gap-2",children:[a.jsx(ru,{className:"w-4 h-4 text-yellow-400"}),"Energy Summary",lt&&a.jsx(at,{className:"w-4 h-4 animate-spin text-bambu-gray ml-2"})]})}),a.jsx(Nt,{children:gt?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(ru,{className:"w-3 h-3"}),"Current Power"]}),a.jsxs("div",{className:"text-xl font-bold text-white",children:[gt.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:[gt.reachableCount,"/",gt.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(da,{className:"w-3 h-3"}),"Today"]}),a.jsxs("div",{className:"text-xl font-bold text-white",children:[gt.totalToday.toFixed(3),a.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),(C?.energy_cost_per_kwh??0)>0&&a.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(gt.totalToday*(C?.energy_cost_per_kwh??0)).toFixed(2)," ",il(C?.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(u3,{className:"w-3 h-3"}),"Yesterday"]}),a.jsxs("div",{className:"text-xl font-bold text-white",children:[gt.totalYesterday.toFixed(3),a.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),(C?.energy_cost_per_kwh??0)>0&&a.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(gt.totalYesterday*(C?.energy_cost_per_kwh??0)).toFixed(2)," ",il(C?.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(a3,{className:"w-3 h-3"}),"Total"]}),a.jsxs("div",{className:"text-xl font-bold text-white",children:[gt.totalLifetime.toFixed(1),a.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),(C?.energy_cost_per_kwh??0)>0&&a.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(gt.totalLifetime*(C?.energy_cost_per_kwh??0)).toFixed(2)," ",il(C?.currency||"USD")]})]})]}):lt?null:a.jsx("p",{className:"text-sm text-bambu-gray",children:"Enable plugs to see energy summary"})})]}),ct?a.jsx("div",{className:"flex justify-center py-12",children:a.jsx(at,{className:"w-8 h-8 text-bambu-green animate-spin"})}):Te&&Te.length>0?a.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Te.map(he=>a.jsx(gZe,{plug:he,onEdit:Et=>{L(Et),E(!0)}},he.id))}):a.jsx(St,{children:a.jsx(Nt,{className:"py-12",children:a.jsxs("div",{className:"text-center text-bambu-gray",children:[a.jsx(gl,{className:"w-16 h-16 mx-auto mb-4 opacity-30"}),a.jsx("p",{className:"text-lg font-medium text-white mb-2",children:i("settings.noSmartPlugsTitle")}),a.jsx("p",{className:"text-sm mb-4",children:i("settings.noSmartPlugsDescription")}),a.jsxs(Me,{onClick:()=>{L(null),E(!0)},children:[a.jsx(Xn,{className:"w-4 h-4"}),i("settings.addFirstSmartPlug")]})]})})})]}),oe==="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(qg,{className:"w-5 h-5 text-bambu-green"}),i("settings.providers")]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs(Me,{size:"sm",variant:"secondary",onClick:()=>te(!0),children:[a.jsx(f0,{className:"w-4 h-4"}),i("settings.log")]}),Tt&&Tt.length>0&&a.jsxs(Me,{size:"sm",variant:"secondary",onClick:()=>{Hs(null),Ca.mutate()},disabled:Ca.isPending,children:[Ca.isPending?a.jsx(at,{className:"w-4 h-4 animate-spin"}):a.jsx(QC,{className:"w-4 h-4"}),i("settings.testAll")]}),a.jsxs(Me,{size:"sm",onClick:()=>{q(null),D(!0)},children:[a.jsx(Xn,{className:"w-4 h-4"}),"Add"]})]})]}),a.jsx(St,{className:"mb-4",children:a.jsx(Nt,{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:C.notification_language||"en",onChange:he=>Xt("notification_language",he.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:xB.map(he=>a.jsx("option",{value:he.code,children:he.nativeName},he.code))})]})})}),a.jsx(St,{className:"mb-4",children:a.jsx(Nt,{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:C.bed_cooled_threshold??35,onChange:he=>Xt("bed_cooled_threshold",Number(he.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"})]})]})})}),Dr&&a.jsx(St,{className:"mb-4",children:a.jsxs(Nt,{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:()=>Hs(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(yr,{className:"w-4 h-4"}),i("settings.testPassedCount",{count:Dr.success})]}),Dr.failed>0&&a.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[a.jsx(mi,{className:"w-4 h-4"}),i("settings.testFailedCount",{count:Dr.failed})]})]}),Dr.results.filter(he=>!he.success).length>0&&a.jsx("div",{className:"space-y-1 mt-2 pt-2 border-t border-bambu-dark-tertiary",children:Dr.results.filter(he=>!he.success).map(he=>a.jsxs("div",{className:"text-xs text-red-400",children:[a.jsxs("span",{className:"font-medium",children:[he.provider_name,":"]})," ",he.message]},he.provider_id))})]})}),Bt?a.jsx("div",{className:"flex justify-center py-12",children:a.jsx(at,{className:"w-6 h-6 text-bambu-green animate-spin"})}):Tt&&Tt.length>0?a.jsx("div",{className:"space-y-3",children:Tt.map(he=>a.jsx(yZe,{provider:he,onEdit:Et=>{q(Et),D(!0)}},he.id))}):a.jsx(St,{children:a.jsx(Nt,{className:"py-8",children:a.jsxs("div",{className:"text-center text-bambu-gray",children:[a.jsx(qg,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),a.jsx("p",{className:"text-sm font-medium text-white mb-2",children:i("settings.noProvidersTitle")}),a.jsx("p",{className:"text-xs mb-3",children:i("settings.noProvidersDescription")}),a.jsxs(Me,{size:"sm",onClick:()=>{q(null),D(!0)},children:[a.jsx(Xn,{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(Ps,{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")}),Tn?a.jsx("div",{className:"flex justify-center py-8",children:a.jsx(at,{className:"w-6 h-6 text-bambu-green animate-spin"})}):gn&&gn.length>0?a.jsx("div",{className:"space-y-2",children:[...gn].sort((he,Et)=>he.name.localeCompare(Et.name)).map(he=>a.jsx(St,{className:"cursor-pointer hover:border-bambu-green/50 transition-colors",onClick:()=>W(he),children:a.jsx(Nt,{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:he.name}),a.jsx("p",{className:"text-bambu-gray text-xs truncate mt-0.5",children:he.title_template})]}),a.jsx("button",{className:"p-1.5 hover:bg-bambu-dark-tertiary rounded transition-colors shrink-0 ml-2",onClick:Et=>{Et.stopPropagation(),W(he)},children:a.jsx(ef,{className:"w-4 h-4 text-bambu-gray"})})]})})},he.id))}):a.jsx(St,{children:a.jsx(Nt,{className:"py-8",children:a.jsxs("div",{className:"text-center text-bambu-gray",children:[a.jsx(Ps,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),a.jsx("p",{className:"text-sm",children:i("settings.noTemplatesAvailable")})]})})})]})]}),oe==="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(al,{className:"w-5 h-5 text-bambu-green"}),i("settings.apiKeys")]}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:i("settings.apiKeysDescription")})]}),a.jsxs(Me,{size:"sm",onClick:()=>le(!0),className:"flex-shrink-0",children:[a.jsx(Xn,{className:"w-4 h-4"}),i("settings.createKey")]})]}),Y&&a.jsx(St,{className:"mb-6 border-bambu-green",children:a.jsx(Nt,{className:"py-4",children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx(yr,{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:Y}),a.jsx(Me,{variant:"secondary",size:"sm",onClick:async()=>{try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(Y);else{const he=document.createElement("textarea");he.value=Y,he.style.position="fixed",he.style.left="-999999px",document.body.appendChild(he),he.select(),document.execCommand("copy"),document.body.removeChild(he)}o(i("settings.toast.keyCopied"))}catch{o(i("settings.toast.copyFailed"),"error")}},children:a.jsx(Ql,{className:"w-4 h-4"})})]}),a.jsxs("div",{className:"flex gap-2 mt-3",children:[a.jsx(Me,{variant:"secondary",size:"sm",onClick:()=>{be(Y),o(i("settings.toast.keyAddedToBrowser"))},children:i("settings.useInApiBrowser")}),a.jsx(Me,{variant:"secondary",size:"sm",onClick:()=>re(null),children:i("common.dismiss")})]})]})]})})}),Ce&&a.jsxs(St,{className:"mb-6",children:[a.jsx(On,{children:a.jsx("h3",{className:"text-base font-semibold text-white",children:i("settings.createNewApiKey")})}),a.jsxs(Nt,{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:Le,onChange:he=>V(he.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:K.can_read_status,onChange:he=>fe(Et=>({...Et,can_read_status:he.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:K.can_queue,onChange:he=>fe(Et=>({...Et,can_queue:he.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:K.can_control_printer,onChange:he=>fe(Et=>({...Et,can_control_printer:he.target.checked})),className:"w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green"}),a.jsxs("div",{children:[a.jsx("span",{className:"text-white",children:i("settings.controlPrinter")}),a.jsx("p",{className:"text-xs text-bambu-gray",children:i("settings.controlPrinterDescription")})]})]})]})]}),a.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[a.jsxs(Me,{onClick:()=>tn.mutate({name:Le||i("settings.unnamedKey"),...K}),disabled:tn.isPending,children:[tn.isPending?a.jsx(at,{className:"w-4 h-4 animate-spin"}):a.jsx(Xn,{className:"w-4 h-4"}),i("settings.createKey")]}),a.jsx(Me,{variant:"secondary",onClick:()=>le(!1),children:i("common.cancel")})]})]})]}),Pt?a.jsx("div",{className:"flex justify-center py-12",children:a.jsx(at,{className:"w-8 h-8 text-bambu-green animate-spin"})}):It&&It.length>0?a.jsx("div",{className:"space-y-3",children:It.map(he=>a.jsx(St,{children:a.jsx(Nt,{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(al,{className:`w-5 h-5 ${he.enabled?"text-bambu-green":"text-bambu-gray"}`}),a.jsxs("div",{children:[a.jsx("p",{className:"text-white font-medium",children:he.name}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:[he.key_prefix,"••••••••",he.last_used&&` · ${i("settings.lastUsed")}: ${mb(he.last_used)}`]})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:"flex gap-1 text-xs",children:[he.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")}),he.can_queue&&a.jsx("span",{className:"px-1.5 py-0.5 bg-green-500/20 text-green-400 rounded",children:i("queue.title")}),he.can_control_printer&&a.jsx("span",{className:"px-1.5 py-0.5 bg-orange-500/20 text-orange-400 rounded",children:i("settings.control")})]}),a.jsx(Me,{variant:"secondary",size:"sm",onClick:()=>Fe(he.id),children:a.jsx(Yt,{className:"w-4 h-4 text-red-400"})})]})]})})},he.id))}):a.jsx(St,{children:a.jsx(Nt,{className:"py-12",children:a.jsxs("div",{className:"text-center text-bambu-gray",children:[a.jsx(al,{className:"w-16 h-16 mx-auto mb-4 opacity-30"}),a.jsx("p",{className:"text-lg font-medium text-white mb-2",children:i("settings.apiKeysEmptyTitle")}),a.jsx("p",{className:"text-sm mb-4",children:i("settings.apiKeysEmptyDescription")}),a.jsxs(Me,{onClick:()=>le(!0),children:[a.jsx(Xn,{className:"w-4 h-4"}),i("settings.createFirstKey")]})]})})}),a.jsxs(St,{className:"mt-6",children:[a.jsx(On,{children:a.jsx("h3",{className:"text-base font-semibold text-white",children:i("settings.webhookEndpoints")})}),a.jsxs(Nt,{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(Eh,{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(St,{className:"mb-4",children:a.jsxs(Nt,{className:"py-3",children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:i("settings.apiKeyForTesting")}),a.jsx("input",{type:"text",value:Pe,onChange:he=>be(he.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($Ze,{apiKey:Pe})]})]}),oe==="virtual-printer"&&a.jsx(RZe,{}),oe==="filament"&&C&&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(AZe,{}),a.jsxs(St,{children:[a.jsx(On,{children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.amsDisplayThresholds")})}),a.jsxs(Nt,{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(AF,{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:C.ams_humidity_good??40,onChange:he=>Xt("ams_humidity_good",parseInt(he.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:C.ams_humidity_fair??60,onChange:he=>Xt("ams_humidity_fair",parseInt(he.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(JC,{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:C.ams_temp_good??28,onChange:he=>Xt("ams_temp_good",parseFloat(he.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:C.ams_temp_fair??35,onChange:he=>Xt("ams_temp_fair",parseFloat(he.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(jc,{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:C.ams_history_retention_days??30,onChange:he=>Xt("ams_history_retention_days",parseInt(he.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(Nr,{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:C.per_printer_mapping_expanded??!1,onChange:he=>Xt("per_printer_mapping_expanded",he.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(TZe,{}),a.jsx(MZe,{})]})]})}),ue!==null&&a.jsx(xn,{title:i("settings.deleteApiKeyTitle"),message:i("settings.deleteApiKeyMessage"),confirmText:i("settings.deleteKey"),variant:"danger",onConfirm:()=>{en.mutate(ue),Fe(null)},onCancel:()=>Fe(null)}),M&&a.jsx(bZe,{plug:B,onClose:()=>{E(!1),L(null)}}),U&&a.jsx(vZe,{provider:$,onClose:()=>{D(!1),q(null)}}),z&&a.jsx(wZe,{template:z,onClose:()=>W(null)}),Q&&a.jsx(NZe,{onClose:()=>te(!1)}),O&&a.jsx(xn,{title:i("settings.clearNotificationLogs"),message:i("settings.clearLogsMessage"),confirmText:i("settings.clearLogs"),variant:"warning",onConfirm:async()=>{R(!1);try{const he=await J.clearNotificationLogs(30);o(he.message,"success")}catch{o(i("settings.toast.clearLogsFailed"),"error")}},onCancel:()=>R(!1)}),G&&a.jsx(xn,{title:i("settings.resetUiPreferences"),message:i("settings.resetUiPreferencesMessage"),confirmText:i("settings.resetPreferences"),variant:"default",onConfirm:()=>{de(!1),localStorage.clear(),o(i("settings.toast.uiPreferencesReset"),"success"),setTimeout(()=>window.location.reload(),1e3)},onCancel:()=>de(!1)}),ge&&a.jsx(xn,{title:`Turn All Plugs ${ge==="on"?"On":"Off"}`,message:`This will turn ${ge==="on"?"ON":"OFF"} all ${Te?.filter(he=>he.enabled).length||0} enabled smart plugs. ${ge==="off"?"Any running printers may be affected!":""}`,confirmText:`Turn All ${ge==="on"?"On":"Off"}`,variant:ge==="off"?"danger":"warning",onConfirm:()=>{const he=ge;ae(null),Zr.mutate(he)},onCancel:()=>ae(null)}),Ue&&pn?.release_notes&&a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:()=>ze(!1),children:a.jsxs(St,{className:"w-full max-w-2xl max-h-[80vh] flex flex-col",onClick:he=>he.stopPropagation(),children:[a.jsxs(On,{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",pn.latest_version]}),pn.release_name&&pn.release_name!==pn.latest_version&&a.jsx("p",{className:"text-sm text-bambu-gray",children:pn.release_name})]}),a.jsx("button",{onClick:()=>ze(!1),className:"p-1 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white",children:a.jsx(Rt,{className:"w-5 h-5"})})]}),a.jsx(Nt,{className:"overflow-y-auto flex-1",children:a.jsx("pre",{className:"text-sm text-bambu-gray whitespace-pre-wrap font-sans",children:pn.release_notes})}),a.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary shrink-0 flex gap-2",children:[pn.release_url&&a.jsx("a",{href:pn.release_url,target:"_blank",rel:"noopener noreferrer",className:"flex-1",children:a.jsxs(Me,{variant:"secondary",className:"w-full",children:[a.jsx(ta,{className:"w-4 h-4"}),"View on GitHub"]})}),a.jsx(Me,{onClick:()=>ze(!1),className:"flex-1",children:"Close"})]})]})}),oe==="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:()=>se("users"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${me==="users"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[a.jsx(fh,{className:"w-4 h-4"}),i("settings.tabs.users")]}),a.jsxs("button",{onClick:()=>se("email"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${me==="email"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[a.jsx(p0,{className:"w-4 h-4"}),i("settings.tabs.emailAuth")||"Email Authentication",aa?.advanced_auth_enabled&&a.jsx("span",{className:"w-2 h-2 rounded-full bg-green-400"})]})]}),me==="users"&&a.jsxs(a.Fragment,{children:[a.jsx(St,{children:a.jsx(Nt,{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(Um,{className:"w-5 h-5 text-green-400"}):a.jsx(U_,{className:"w-5 h-5 text-gray-400"})}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-white font-medium",children:i("settings.authentication")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:i(l?"settings.authEnabledDescription":"settings.authDisabledDescription")})]})]}),l?c?.is_admin&&a.jsxs(Me,{variant:"secondary",onClick:()=>Re(!0),children:[a.jsx(U_,{className:"w-4 h-4"}),i("common.disable")]}):a.jsxs(Me,{onClick:()=>e("/setup"),children:[a.jsx(Um,{className:"w-4 h-4"}),i("common.enable")]})]})})}),aa?.advanced_auth_enabled&&a.jsx(St,{className:"border-blue-500/30 bg-blue-500/5",children:a.jsx(Nt,{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(p0,{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(St,{children:[a.jsx(On,{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(fh,{className:"w-5 h-5 text-bambu-green"}),i("settings.currentUser")]}),a.jsxs(Me,{size:"sm",variant:"ghost",onClick:()=>ve(!0),children:[a.jsx(al,{className:"w-4 h-4"}),i("settings.changePassword")]})]})}),a.jsx(Nt,{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(he=>a.jsx("span",{className:`px-2 py-0.5 rounded-full text-xs font-medium ${he.name==="Administrators"?"bg-purple-500/20 text-purple-300":he.name==="Operators"?"bg-blue-500/20 text-blue-300":he.name==="Viewers"?"bg-green-500/20 text-green-300":"bg-gray-500/20 text-gray-300"}`,children:he.name},he.id))]})]})})})]}),a.jsxs(St,{children:[a.jsx(On,{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(fh,{className:"w-5 h-5 text-bambu-green"}),i("settings.users")]}),bt("users:create")&&a.jsxs(Me,{size:"sm",onClick:()=>{We(!0),zt({username:"",password:"",email:"",confirmPassword:"",role:"user",group_ids:[]})},children:[a.jsx(Xn,{className:"w-4 h-4"}),i("settings.addUser")]})]})}),a.jsx(Nt,{children:vn?a.jsx("div",{className:"flex items-center justify-center py-8",children:a.jsx(at,{className:"w-6 h-6 text-bambu-green animate-spin"})}):Ot.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:Ot.map(he=>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:he.username}),a.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[he.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")}),he.groups?.map(Et=>a.jsx("span",{className:`px-2 py-0.5 rounded-full text-xs font-medium ${Et.name==="Administrators"?"bg-purple-500/20 text-purple-300":Et.name==="Operators"?"bg-blue-500/20 text-blue-300":Et.name==="Viewers"?"bg-green-500/20 text-green-300":"bg-gray-500/20 text-gray-300"}`,children:Et.name},Et.id))]})]}),a.jsxs("div",{className:"flex items-center gap-1 ml-4",children:[bt("users:update")&&a.jsx(Me,{size:"sm",variant:"ghost",onClick:()=>zo(he),children:a.jsx(ef,{className:"w-4 h-4"})}),bt("users:delete")&&he.id!==c?.id&&a.jsx(Me,{size:"sm",variant:"ghost",onClick:()=>rn(he.id),children:a.jsx(Yt,{className:"w-4 h-4"})})]})]},he.id))})})]})]}),a.jsx("div",{children:a.jsxs(St,{children:[a.jsx(On,{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(d3,{className:"w-5 h-5 text-bambu-green"}),i("settings.groups")]}),bt("groups:create")&&a.jsxs(Me,{size:"sm",onClick:()=>e("/groups/new"),children:[a.jsx(Xn,{className:"w-4 h-4"}),i("settings.addGroup")]})]})}),a.jsx(Nt,{children:Un?a.jsx("div",{className:"flex items-center justify-center py-8",children:a.jsx(at,{className:"w-6 h-6 text-bambu-green animate-spin"})}):vt.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:vt.map(he=>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(d3,{className:`w-4 h-4 ${he.name==="Administrators"?"text-purple-400":he.name==="Operators"?"text-blue-400":he.name==="Viewers"?"text-green-400":"text-bambu-gray"}`}),a.jsx("span",{className:"text-white font-medium",children:he.name}),he.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:[bt("groups:update")&&a.jsx(Me,{size:"sm",variant:"ghost",onClick:()=>e(`/groups/${he.id}/edit`),children:a.jsx(ef,{className:"w-4 h-4"})}),bt("groups:delete")&&!he.is_system&&a.jsx(Me,{size:"sm",variant:"ghost",onClick:()=>gr(he.id),children:a.jsx(Yt,{className:"w-4 h-4"})})]})]}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1 ml-6",children:he.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:he.user_count})}),a.jsx("span",{children:i("settings.permissionCount",{count:he.permissions.length})})]})]},he.id))})})]})})]}),!l&&a.jsx(St,{children:a.jsx(Nt,{className:"py-6",children:a.jsxs("div",{className:"text-center",children:[a.jsx(U_,{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(yr,{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(yr,{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(yr,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),a.jsx("span",{children:i("settings.authDisabledFeature3")})]})]}),a.jsxs(Me,{onClick:()=>e("/setup"),children:[a.jsx(Um,{className:"w-4 h-4"}),i("settings.enableAuthentication")]})]})})})]}),me==="email"&&a.jsx("div",{className:"max-w-2xl",children:a.jsx(zZe,{})})]}),De&&!aa?.advanced_auth_enabled&&a.jsx("div",{className:"fixed inset-0 bg-black flex items-center justify-center z-50 p-4",onClick:()=>{We(!1),zt({username:"",password:"",email:"",confirmPassword:"",role:"user",group_ids:[]})},children:a.jsxs(St,{className:"w-full max-w-md",onClick:he=>he.stopPropagation(),children:[a.jsx(On,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(fh,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.createUser")})]}),a.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>{We(!1),zt({username:"",password:"",email:"",confirmPassword:"",role:"user",group_ids:[]})},children:a.jsx(Rt,{className:"w-5 h-5"})})]})}),a.jsxs(Nt,{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:yt.username,onChange:he=>zt({...yt,username:he.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:yt.password,onChange:he=>zt({...yt,password:he.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:yt.confirmPassword,onChange:he=>zt({...yt,confirmPassword:he.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 ${yt.confirmPassword&&yt.password!==yt.confirmPassword?"border-red-500":"border-bambu-dark-tertiary"}`,placeholder:i("settings.confirmPasswordPlaceholder"),autoComplete:"new-password",minLength:6}),yt.confirmPassword&&yt.password!==yt.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:[vt.map(he=>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:yt.group_ids.includes(he.id),onChange:()=>Uo(he.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:he.name}),he.is_system&&a.jsx("span",{className:"text-xs text-yellow-400",children:"(System)"})]},he.id)),vt.length===0&&a.jsx("p",{className:"text-sm text-bambu-gray",children:i("settings.noGroupsAvailable")})]})]})]}),a.jsxs("div",{className:"mt-6 flex justify-end gap-3",children:[a.jsx(Me,{variant:"secondary",onClick:()=>{We(!1),zt({username:"",password:"",email:"",confirmPassword:"",role:"user",group_ids:[]})},children:"Cancel"}),a.jsx(Me,{onClick:Ci,disabled:Qr.isPending||!yt.username||!yt.password||yt.password!==yt.confirmPassword||yt.password.length<6,children:Qr.isPending?a.jsxs(a.Fragment,{children:[a.jsx(at,{className:"w-4 h-4 animate-spin"}),"Creating..."]}):a.jsxs(a.Fragment,{children:[a.jsx(Xn,{className:"w-4 h-4"}),"Create User"]})})]})]})]})}),De&&aa?.advanced_auth_enabled&&a.jsx(kZe,{formData:yt,setFormData:zt,groups:vt,onClose:()=>{We(!1),zt({username:"",password:"",email:"",confirmPassword:"",role:"user",group_ids:[]})},onCreate:Ci,isCreating:Qr.isPending,isCreateButtonDisabled:Qr.isPending||!yt.username||!yt.email}),Oe&&Ve!==null&&a.jsx("div",{className:"fixed inset-0 bg-black flex items-center justify-center z-50 p-4",onClick:()=>{je(!1),ot(null),zt({username:"",password:"",email:"",confirmPassword:"",role:"user",group_ids:[]})},children:a.jsxs(St,{className:"w-full max-w-md",onClick:he=>he.stopPropagation(),children:[a.jsx(On,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(ef,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.editUser")})]}),a.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>{je(!1),ot(null),zt({username:"",password:"",email:"",confirmPassword:"",role:"user",group_ids:[]})},children:a.jsx(Rt,{className:"w-5 h-5"})})]})}),a.jsxs(Nt,{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")," ",aa?.advanced_auth_enabled&&a.jsx("span",{className:"text-red-400",children:"*"})]}),a.jsx("input",{type:"text",value:yt.username,onChange:he=>zt({...yt,username:he.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"," ",aa?.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:yt.email,onChange:he=>zt({...yt,email:he.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:aa?.advanced_auth_enabled})]}),!aa?.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:yt.password,onChange:he=>zt({...yt,password:he.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})]}),yt.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:yt.confirmPassword,onChange:he=>zt({...yt,confirmPassword:he.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 ${yt.confirmPassword&&yt.password!==yt.confirmPassword?"border-red-500":"border-bambu-dark-tertiary"}`,placeholder:i("settings.confirmNewPassword"),autoComplete:"new-password",minLength:6}),yt.confirmPassword&&yt.password!==yt.confirmPassword&&a.jsx("p",{className:"text-red-400 text-xs mt-1",children:i("settings.passwordsDoNotMatch")})]})]}),aa?.advanced_auth_enabled&&a.jsxs("div",{className:"bg-bambu-dark-secondary/50 border border-bambu-green/20 rounded-lg p-3 space-y-3",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:i("users.form.passwordManagedByAdvancedAuth")||'Password is managed by Advanced Authentication. Use "Reset Password" to send a new password to the user via email.'}),a.jsx(Me,{variant:"secondary",size:"sm",onClick:()=>Ve&&li.mutate(Ve),disabled:li.isPending||!yt.email,className:"w-full",children:li.isPending?a.jsxs(a.Fragment,{children:[a.jsx(at,{className:"w-4 h-4 animate-spin"}),i("users.form.resettingPassword")||"Resetting Password..."]}):a.jsxs(a.Fragment,{children:[a.jsx(lo,{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:vt.map(he=>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:yt.group_ids.includes(he.id),onChange:()=>Uo(he.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:he.name}),he.is_system&&a.jsxs("span",{className:"text-xs text-yellow-400",children:["(",i("users.system")||"System",")"]})]},he.id))})]})]}),a.jsxs("div",{className:"mt-6 flex justify-end gap-3",children:[a.jsx(Me,{variant:"secondary",onClick:()=>{je(!1),ot(null),zt({username:"",password:"",email:"",confirmPassword:"",role:"user",group_ids:[]})},children:i("users.modal.cancel")||"Cancel"}),a.jsx(Me,{onClick:()=>Bs(Ve),disabled:Zn.isPending||!yt.username||aa?.advanced_auth_enabled&&!yt.email||!!(!aa?.advanced_auth_enabled&&yt.password&&(yt.password!==yt.confirmPassword||yt.password.length<6)),children:Zn.isPending?a.jsxs(a.Fragment,{children:[a.jsx(at,{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"]})})]})]})]})}),kt!==null&&a.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",onClick:()=>{Ft(null),At(null)},children:a.jsxs(St,{className:"w-full max-w-md",onClick:he=>he.stopPropagation(),children:[a.jsx(On,{children:a.jsxs("div",{className:"flex items-center gap-2 text-red-400",children:[a.jsx(Yt,{className:"w-5 h-5"}),a.jsx("h3",{className:"text-lg font-semibold",children:i("settings.deleteUserTitle")})]})}),a.jsx(Nt,{className:"space-y-4",children:Be?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"})}):Vt&&Vt.archives+Vt.queue_items+Vt.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:[Vt.archives>0&&a.jsxs("li",{children:[Vt.archives," archive",Vt.archives!==1?"s":""]}),Vt.queue_items>0&&a.jsxs("li",{children:[Vt.queue_items," queue item",Vt.queue_items!==1?"s":""]}),Vt.library_files>0&&a.jsxs("li",{children:[Vt.library_files," library file",Vt.library_files!==1?"s":""]})]}),a.jsx("p",{className:"text-bambu-gray text-sm",children:i("settings.userItemsQuestion")}),a.jsxs("div",{className:"flex flex-col gap-2",children:[a.jsx(Me,{variant:"danger",onClick:()=>dr.mutate({id:kt,deleteItems:!0}),disabled:dr.isPending,className:"justify-center",children:"Delete user AND their items"}),a.jsx(Me,{variant:"secondary",onClick:()=>dr.mutate({id:kt,deleteItems:!1}),disabled:dr.isPending,className:"justify-center",children:"Delete user, keep items (become ownerless)"}),a.jsx(Me,{variant:"ghost",onClick:()=>{Ft(null),At(null)},disabled:dr.isPending,className:"justify-center",children:"Cancel"})]})]}):a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"text-white",children:i("settings.deleteUserConfirm")}),a.jsx("p",{className:"text-bambu-gray text-sm",children:i("settings.actionCannotBeUndone")}),a.jsxs("div",{className:"flex gap-2 justify-end",children:[a.jsx(Me,{variant:"ghost",onClick:()=>{Ft(null),At(null)},disabled:dr.isPending,children:"Cancel"}),a.jsx(Me,{variant:"danger",onClick:()=>dr.mutate({id:kt,deleteItems:!1}),disabled:dr.isPending,children:"Delete User"})]})]})})]})}),yn!==null&&a.jsx(xn,{title:i("settings.deleteGroupTitle"),message:i("settings.deleteGroupMessage"),confirmText:i("settings.deleteGroup"),variant:"danger",onConfirm:()=>{Pn.mutate(yn),gr(null)},onCancel:()=>gr(null)}),oe==="backup"&&a.jsx(LZe,{}),$e&&a.jsx(xn,{title:i("settings.disableAuthenticationTitle"),message:i("settings.disableAuthenticationMessage"),confirmText:i("settings.disableAuthentication"),variant:"danger",onConfirm:async()=>{try{await J.disableAuth(),o(i("settings.toast.authDisabled"),"success"),await d(),Re(!1),window.location.href="/"}catch(he){const Et=he instanceof Error?he.message:i("settings.toast.authDisableFailed");o(Et,"error")}},onCancel:()=>Re(!1)}),pe&&a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:()=>{ve(!1),xe({currentPassword:"",newPassword:"",confirmPassword:""})},children:a.jsxs(St,{className:"w-full max-w-md",onClick:he=>he.stopPropagation(),children:[a.jsx(On,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(al,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.changePassword")})]}),a.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>{ve(!1),xe({currentPassword:"",newPassword:"",confirmPassword:""})},children:a.jsx(Rt,{className:"w-5 h-5"})})]})}),a.jsxs(Nt,{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:Ne.currentPassword,onChange:he=>xe({...Ne,currentPassword:he.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:Ne.newPassword,onChange:he=>xe({...Ne,newPassword:he.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:Ne.confirmPassword,onChange:he=>xe({...Ne,confirmPassword:he.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 ${Ne.confirmPassword&&Ne.newPassword!==Ne.confirmPassword?"border-red-500":"border-bambu-dark-tertiary"}`,placeholder:i("settings.confirmNewPassword"),autoComplete:"new-password",minLength:6}),Ne.confirmPassword&&Ne.newPassword!==Ne.confirmPassword&&a.jsx("p",{className:"text-red-400 text-xs mt-1",children:i("settings.passwordsDoNotMatch")})]})]}),a.jsxs("div",{className:"mt-6 flex justify-end gap-3",children:[a.jsx(Me,{variant:"secondary",onClick:()=>{ve(!1),xe({currentPassword:"",newPassword:"",confirmPassword:""})},children:"Cancel"}),a.jsx(Me,{onClick:async()=>{if(Ne.newPassword!==Ne.confirmPassword){o(i("settings.toast.passwordsDoNotMatch"),"error");return}if(Ne.newPassword.length<6){o(i("settings.toast.passwordTooShort"),"error");return}qe(!0);try{await J.changePassword(Ne.currentPassword,Ne.newPassword),o(i("settings.toast.passwordChanged"),"success"),ve(!1),xe({currentPassword:"",newPassword:"",confirmPassword:""})}catch(he){const Et=he instanceof Error?he.message:"Failed to change password";o(Et,"error")}finally{qe(!1)}},disabled:we||!Ne.currentPassword||!Ne.newPassword||Ne.newPassword!==Ne.confirmPassword||Ne.newPassword.length<6,children:we?a.jsxs(a.Fragment,{children:[a.jsx(at,{className:"w-4 h-4 animate-spin"}),"Changing..."]}):a.jsxs(a.Fragment,{children:[a.jsx(al,{className:"w-4 h-4"}),"Change Password"]})})]})]})]})})]})}const Zie=t=>{const e=parseFloat(t);return(Math.trunc(e*1e3)/1e3).toFixed(3)},WZe=t=>t.startsWith("HH")?"HF":"S",KZe=t=>{const e=t.match(/^([A-Z]{2}\d{2})/);return e?e[1]:"HH00"},Jie=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 Mj({profile:t,onEdit:e,onCopy:n,selectionMode:r,isSelected:i,onToggleSelect:s,note:o}){const l=WZe(t.nozzle_id),c=t.nozzle_diameter,d=()=>{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(co,{className:"w-4 h-4 text-bambu-green"}):a.jsx(Sl,{className:"w-4 h-4"})}),a.jsxs("button",{onClick:d,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:Zie(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(TX,{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:u=>{u.stopPropagation(),n()},className:"text-bambu-gray hover:text-white transition-colors p-1",title:"Copy profile",children:a.jsx(Ql,{className:"w-4 h-4"})})]})}function Pj({profile:t,printerId:e,nozzleDiameter:n,existingProfiles:r=[],builtinFilaments:i=[],isDualNozzle:s=!1,initialNote:o="",initialNoteKey:l=null,onClose:c,onSave:d,onSaveNote:u,hasPermission:h}){const{t:f}=Dt(),{showToast:p}=dn(),[x,v]=w.useState(t?.name||""),[g,y]=w.useState(t?.k_value?Zie(t.k_value):"0.020"),[_,N]=w.useState(t?.filament_id||""),[A,k]=w.useState(t?.nozzle_id?KZe(t.nozzle_id):"HH00"),[P,C]=w.useState(t?.nozzle_diameter||n),[j,M]=w.useState(t?[t.extruder_id]:s?[0,1]:[0]),[E,B]=w.useState(!1),[L,U]=w.useState({current:0,total:0}),[D,$]=w.useState(o),q=Wr.useMemo(()=>{const Z=new Map;for(const Se of i)Z.set(Se.filament_id,Se.name);const ee=new Map;for(const Se of r)if(Se.filament_id&&!ee.has(Se.filament_id)){const ie=Z.get(Se.filament_id)||Jie(Se.name||"");ee.set(Se.filament_id,{id:Se.filament_id,name:ie||Se.filament_id})}return Array.from(ee.values()).sort((Se,oe)=>Se.name.localeCompare(oe.name))},[r,i]),z=st({mutationFn:Z=>(console.log("[KProfile] Calling API..."),J.setKProfile(e,Z)),onSuccess:Z=>{if(console.log("[KProfile] Save success:",Z),p(f("kProfiles.toast.profileSaved")),u&&D!==o){let ee;D===""&&l?ee=l:t&&t.slot_id>0?ee=t.setting_id||`slot_${t.slot_id}_${t.filament_id}_${t.extruder_id}`:ee=`name_${x}_${_}`,u(ee,D)}B(!0),setTimeout(()=>{B(!1),d()},2500)},onError:Z=>{console.error("[KProfile] Save error:",Z),p(Z.message,"error"),B(!1)}}),W=st({mutationFn:Z=>(console.log("[KProfile] Deleting profile..."),J.deleteKProfile(e,Z)),onSuccess:Z=>{console.log("[KProfile] Delete success:",Z),p(f("kProfiles.toast.profileDeleted")),B(!0),setTimeout(()=>{B(!1),c()},4e3)},onError:Z=>{console.error("[KProfile] Delete error:",Z),p(Z.message,"error"),B(!1)}}),[Q,te]=w.useState(!1),H=()=>{t&&W.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})},X=async Z=>{if(Z.preventDefault(),s&&!t&&j.length===0){p(f("kProfiles.toast.selectAtLeastOneExtruder"),"error");return}const ee=parseFloat(g).toFixed(6),Se=`${A}-${P}`;if(t||j.length===1){const ie={name:x,k_value:ee,filament_id:_,nozzle_id:Se,nozzle_diameter:P,extruder_id:t?t.extruder_id:j[0],setting_id:t?.setting_id,slot_id:t?.slot_id??0};console.log("[KProfile] Saving profile:",ie),z.mutate(ie);return}B(!0),U({current:1,total:j.length});const oe=j.map(ie=>({name:x,k_value:ee,filament_id:_,nozzle_id:Se,nozzle_diameter:P,extruder_id:ie,setting_id:void 0,slot_id:0}));console.log(`[KProfile] Saving ${oe.length} profiles in batch:`,oe);try{if(await J.setKProfilesBatch(e,oe),p(f("kProfiles.toast.profilesSaved",{count:j.length})),u&&D){const ie=`name_${x}_${_}`;u(ie,D)}}catch(ie){console.error("[KProfile] Failed to save batch:",ie),p(f("kProfiles.toast.failedToSaveBatch"),"error"),B(!1),U({current:0,total:0});return}U({current:j.length,total:j.length}),setTimeout(()=>{B(!1),U({current:0,total:0}),d()},3e3)};return a.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:[a.jsxs(St,{className:"w-full max-w-md relative",children:[E&&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(at,{className:"w-8 h-8 text-bambu-green animate-spin mb-3"}),a.jsx("p",{className:"text-white font-medium",children:L.total>1?f("kProfiles.modal.savingExtruder",{current:L.current,total:L.total}):f("kProfiles.modal.syncing")}),a.jsx("p",{className:"text-bambu-gray text-sm mt-1",children:f("kProfiles.modal.pleaseWait")})]}),a.jsxs(Nt,{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:E,children:a.jsx(Rt,{className:"w-5 h-5"})})]}),a.jsxs("form",{onSubmit:X,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:Z=>v(Z.target.value),disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,placeholder: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:Z=>{const ee=Z.target.value;(ee===""||/^\d*\.?\d*$/.test(ee))&&y(ee)},onBlur:Z=>{const ee=parseFloat(Z.target.value);isNaN(ee)||y((Math.trunc(ee*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:Z=>{const ee=Z.target.value;if(N(ee),!t&&ee&&!x){const Se=q.find(oe=>oe.id===ee);Se&&v(`${A==="HH00"?"HF":"S"} ${Se.name}`)}},disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,required:!t,children:[a.jsx("option",{value:"",children:f("kProfiles.modal.selectFilament")}),t?.filament_id&&a.jsx("option",{value:t.filament_id,children:q.find(Z=>Z.id===t.filament_id)?.name||t.filament_id},t.filament_id),!t&&q.map(Z=>a.jsx("option",{value:Z.id,children:Z.name},Z.id))]}),!t&&q.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:Z=>{const ee=Z.target.value;if(k(ee),!t&&_&&!x){const Se=q.find(oe=>oe.id===_);Se&&v(`${ee==="HS00"?"HF":"S"} ${Se.name}`)}},disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,children:[a.jsx("option",{value:"HH00",children: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:P,onChange:Z=>C(Z.target.value),disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,children:[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:j.includes(1),onChange:Z=>{Z.target.checked?M([...j,1]):M(j.filter(ee=>ee!==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:j.includes(0),onChange:Z=>{Z.target.checked?M([...j,0]):M(j.filter(ee=>ee!==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:D,onChange:Z=>$(Z.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(Me,{type:"button",variant:"secondary",onClick:()=>te(!0),disabled:W.isPending||E||!h("kprofiles:delete"),title:h("kprofiles:delete")?void 0:f("kProfiles.permission.noDelete"),className:"text-red-500 hover:bg-red-500/10",children:W.isPending?a.jsx(at,{className:"w-4 h-4 animate-spin"}):a.jsx(Yt,{className:"w-4 h-4"})}),a.jsx(Me,{type:"button",variant:"secondary",onClick:c,disabled:E,className:"flex-1",children:f("common.cancel")}),a.jsxs(Me,{type:"submit",disabled:z.isPending||E||!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:[z.isPending?a.jsx(at,{className:"w-4 h-4 animate-spin"}):a.jsx(qC,{className:"w-4 h-4"}),f("common.save")]})]})]})]})]}),Q&&a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-[60]",children:a.jsx(St,{className:"w-full max-w-sm",children:a.jsxs(Nt,{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(Yt,{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(Me,{variant:"secondary",onClick:()=>te(!1),className:"flex-1",children:f("common.cancel")}),a.jsxs(Me,{onClick:()=>{te(!1),H()},disabled:W.isPending,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[W.isPending?a.jsx(at,{className:"w-4 h-4 animate-spin"}):a.jsx(Yt,{className:"w-4 h-4"}),f("common.delete")]})]})]})})})]})}const O_={NOZZLE_DIAMETER:"bambusy_kprofiles_nozzle",SORT_OPTION:"bambusy_kprofiles_sort"};function XZe(){const{t}=Dt(),{showToast:e}=dn(),{hasPermission:n}=jr(),[r,i]=w.useState(null),[s,o]=w.useState(()=>localStorage.getItem(O_.NOZZLE_DIAMETER)||"0.4"),[l,c]=w.useState(null),[d,u]=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(O_.SORT_OPTION)||"name"),[k,P]=w.useState(!1),[C,j]=w.useState(new Set),[M,E]=w.useState(!1),[B,L]=w.useState(!1),U=w.useCallback(R=>`${R.slot_id}_${R.extruder_id}`,[]);w.useEffect(()=>{localStorage.setItem(O_.NOZZLE_DIAMETER,s)},[s]),w.useEffect(()=>{localStorage.setItem(O_.SORT_OPTION,N)},[N]);const{data:D,isLoading:$}=Ze({queryKey:["printers"],queryFn:J.getPrinters}),{data:q,isLoading:z,isFetching:W,error:Q,refetch:te}=Ze({queryKey:["kprofiles",r,s],queryFn:async()=>{console.log("[KProfiles] Fetching profiles for printer",r,"nozzle",s);const R=await J.getKProfiles(r,s);return console.log("[KProfiles] Received profiles:",R?.profiles?.length||0,"profiles"),R},enabled:!!r,retry:!1,staleTime:0,gcTime:0,refetchOnMount:"always"}),{data:H}=Ze({queryKey:["kprofiles",r,"0.4"],queryFn:()=>J.getKProfiles(r,"0.4"),enabled:!!r,staleTime:6e4}),{data:X}=Ze({queryKey:["builtinFilaments"],queryFn:()=>J.getBuiltinFilaments(),staleTime:3e5}),{data:Z}=Ze({queryKey:["filamentIdMap"],queryFn:()=>J.getFilamentIdMap(),staleTime:3e5}),{data:ee,refetch:Se}=Ze({queryKey:["kprofile-notes",r],queryFn:()=>J.getKProfileNotes(r),enabled:!!r,staleTime:3e4}),oe=Q?.message?.includes("not connected");w.useEffect(()=>{if(!r&&D&&D.length>0){const R=D.find(G=>G.is_active);R&&i(R.id)}},[r,D]),w.useEffect(()=>{if(r){const R=setTimeout(()=>{te()},150);return()=>clearTimeout(R)}},[r,s]);const ie=D?.filter(R=>R.is_active)||[],me=Wr.useMemo(()=>{const R=new Map;if(X)for(const G of X)R.set(G.filament_id,G.name);if(Z)for(const[G,de]of Object.entries(Z))R.has(G)||R.set(G,de);return R},[X,Z]),se=Wr.useMemo(()=>Array.from(me.entries()).map(([R,G])=>({filament_id:R,name:G})),[me]),ce=Wr.useCallback(R=>me.get(R.filament_id)||Jie(R.name),[me]),Ce=Wr.useMemo(()=>q?.profiles?q.profiles.filter(G=>{const de=p.toLowerCase(),ge=!de||G.name.toLowerCase().includes(de)||G.filament_id.toLowerCase().includes(de),ae=v==="all"||v==="left"&&G.extruder_id===1||v==="right"&&G.extruder_id===0,Ue=y==="all"||y==="hf"&&G.nozzle_id.startsWith("HH")||y==="s"&&G.nozzle_id.startsWith("HS");return ge&&ae&&Ue}).sort((G,de)=>{switch(N){case"k_value":return parseFloat(G.k_value)-parseFloat(de.k_value);case"filament":return ce(G).localeCompare(ce(de));default:return G.name.localeCompare(de.name)}}):[],[q?.profiles,p,v,y,N,ce]),le=D?.find(R=>R.id===r),Le=le?.nozzle_count===2;w.useEffect(()=>{const R=G=>{G.target instanceof HTMLInputElement||G.target instanceof HTMLTextAreaElement||G.target instanceof HTMLSelectElement||l||d||h||(G.key==="r"||G.key==="R"?(G.preventDefault(),te()):G.key==="n"||G.key==="N"?(G.preventDefault(),u(!0)):G.key==="Escape"&&k&&(G.preventDefault(),P(!1),j(new Set)))};return window.addEventListener("keydown",R),()=>window.removeEventListener("keydown",R)},[l,d,h,k,te]);const V=w.useCallback(()=>{if(!q?.profiles||q.profiles.length===0){e(t("kProfiles.toast.noProfilesToExport"),"error");return}const R={version:1,exported_at:new Date().toISOString(),printer:le?.name||"Unknown",nozzle_diameter:s,profiles:q.profiles.map(ae=>({name:ae.name,k_value:ae.k_value,filament_id:ae.filament_id,nozzle_id:ae.nozzle_id,nozzle_diameter:ae.nozzle_diameter,extruder_id:ae.extruder_id}))},G=new Blob([JSON.stringify(R,null,2)],{type:"application/json"}),de=URL.createObjectURL(G),ge=document.createElement("a");ge.href=de,ge.download=`kprofiles_${le?.name||"printer"}_${s}mm_${new Date().toISOString().split("T")[0]}.json`,document.body.appendChild(ge),ge.click(),document.body.removeChild(ge),URL.revokeObjectURL(de),e(t("kProfiles.toast.exportedProfiles",{count:q.profiles.length}))},[q?.profiles,le,s,e,t]),K=w.useCallback(()=>{const R=document.createElement("input");R.type="file",R.accept=".json",R.onchange=async G=>{const de=G.target.files?.[0];if(de)try{const ge=await de.text(),ae=JSON.parse(ge);if(!ae.profiles||!Array.isArray(ae.profiles)){e(t("kProfiles.toast.invalidFileFormat"),"error");return}let Ue=0;for(const ze of ae.profiles)if(!(!ze.name||!ze.k_value||!ze.filament_id))try{await J.setKProfile(r,{name:ze.name,k_value:parseFloat(ze.k_value).toFixed(6),filament_id:ze.filament_id,nozzle_id:ze.nozzle_id||`HH00-${s}`,nozzle_diameter:ze.nozzle_diameter||s,extruder_id:ze.extruder_id??0,slot_id:0}),Ue++,await new Promise($e=>setTimeout($e,500))}catch($e){console.error("Failed to import profile:",ze.name,$e)}e(t("kProfiles.toast.importedProfiles",{count:Ue,total:ae.profiles.length})),te()}catch(ge){console.error("Import error:",ge),e(t("kProfiles.toast.failedToParseImport"),"error")}},R.click()},[r,s,e,te,t]),fe=w.useCallback(R=>{j(G=>{const de=new Set(G);return de.has(R)?de.delete(R):de.add(R),de})},[]),Y=w.useCallback(()=>{j(new Set(Ce.map(R=>U(R))))},[Ce,U]),re=w.useCallback(()=>{C.size!==0&&E(!0)},[C.size]),ue=w.useCallback(async()=>{const R=Ce.filter(de=>C.has(U(de)));L(!0);let G=0;for(const de of R)try{await J.deleteKProfile(r,{slot_id:de.slot_id,extruder_id:de.extruder_id,nozzle_id:de.nozzle_id,nozzle_diameter:de.nozzle_diameter,filament_id:de.filament_id,setting_id:de.setting_id}),G++,await new Promise(ge=>setTimeout(ge,300))}catch(ge){console.error("Failed to delete profile:",de.name,ge)}e(t("kProfiles.toast.profilesDeleted",{count:G})),L(!1),E(!1),P(!1),j(new Set),te()},[r,C,Ce,e,te,U,t]),Fe=w.useCallback(R=>{const G=[];return R.setting_id&&G.push(R.setting_id),G.push(`slot_${R.slot_id}_${R.filament_id}_${R.extruder_id}`),G.push(`name_${R.name}_${R.filament_id}`),G},[]),Pe=w.useCallback(async(R,G)=>{if(r)try{await J.setKProfileNote(r,R,G),Se()}catch(de){console.error("Failed to save note:",de),e(t("kProfiles.toast.failedToSaveNote"),"error")}},[r,Se,e,t]),be=w.useCallback(R=>{if(!ee?.notes)return{note:"",key:null};const G=Fe(R);for(const de of G)if(ee.notes[de])return{note:ee.notes[de],key:de};return{note:"",key:null}},[ee,Fe]),O=w.useCallback(R=>be(R).note,[be]);return $?a.jsx("div",{className:"flex justify-center py-12",children:a.jsx(at,{className:"w-8 h-8 text-bambu-green animate-spin"})}):!D||D.length===0?a.jsx(St,{children:a.jsxs(Nt,{className:"py-12 text-center",children:[a.jsx(Va,{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")})]})}):ie.length===0?a.jsx(St,{children:a.jsxs(Nt,{className:"py-12 text-center",children:[a.jsx(Nr,{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:[W&&!z&&a.jsxs("div",{className:"fixed inset-0 bg-black/50 flex flex-col items-center justify-center z-40",children:[a.jsx(at,{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:R=>i(parseInt(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:ie.map(R=>a.jsx("option",{value:R.id,children:R.name},R.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:R=>o(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:"0.2",children:"0.2mm"}),a.jsx("option",{value:"0.4",children:"0.4mm"}),a.jsx("option",{value:"0.6",children:"0.6mm"}),a.jsx("option",{value:"0.8",children:"0.8mm"})]})]}),a.jsxs("div",{className:"flex items-end gap-2",children:[a.jsxs(Me,{variant:"secondary",onClick:()=>te(),disabled:W||!n("kprofiles:read"),title:n("kprofiles:read")?void 0:t("kProfiles.permission.noRead"),children:[a.jsx(Sr,{className:`w-4 h-4 ${W?"animate-spin":""}`}),t("kProfiles.refresh")]}),a.jsxs(Me,{onClick:()=>u(!0),disabled:!n("kprofiles:create"),title:n("kprofiles:create")?void 0:t("kProfiles.permission.noCreate"),children:[a.jsx(Xn,{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:R=>x(R.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"})]}),Le&&a.jsx("div",{className:"w-36",children:a.jsxs("select",{value:v,onChange:R=>g(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:"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:R=>_(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:"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:R=>A(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:"name",children:t("kProfiles.sortName")}),a.jsx("option",{value:"k_value",children:t("kProfiles.sortKValue")}),a.jsx("option",{value:"filament",children:t("kProfiles.sortFilament")})]})})]}),a.jsxs("div",{className:"flex flex-wrap gap-2 mb-6",children:[a.jsxs(Me,{variant:"secondary",onClick:V,disabled:!q?.profiles?.length||!n("kprofiles:read"),title:n("kprofiles:read")?void 0:t("kProfiles.permission.noExport"),children:[a.jsx(ga,{className:"w-4 h-4"}),t("kProfiles.export")]}),a.jsxs(Me,{variant:"secondary",onClick:K,disabled:!n("kprofiles:create"),title:n("kprofiles:create")?void 0:t("kProfiles.permission.noImport"),children:[a.jsx(Oa,{className:"w-4 h-4"}),t("kProfiles.import")]}),a.jsx("div",{className:"flex-1"}),k?a.jsxs(a.Fragment,{children:[a.jsxs(Me,{variant:"secondary",onClick:Y,children:[a.jsx(co,{className:"w-4 h-4"}),t("kProfiles.selectAll")]}),a.jsxs(Me,{variant:"secondary",onClick:re,disabled:C.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(Yt,{className:"w-4 h-4"}),t("kProfiles.delete")," (",C.size,")"]}),a.jsxs(Me,{variant:"secondary",onClick:()=>{P(!1),j(new Set)},children:[a.jsx(Rt,{className:"w-4 h-4"}),t("common.cancel")]})]}):a.jsxs(Me,{variant:"secondary",onClick:()=>P(!0),disabled:!Ce.length||!n("kprofiles:delete"),title:n("kprofiles:delete")?void 0:t("kProfiles.permission.noDelete"),children:[a.jsx(co,{className:"w-4 h-4"}),t("kProfiles.select")]})]}),z?a.jsx("div",{className:"flex justify-center py-12",children:a.jsx(at,{className:"w-8 h-8 text-bambu-green animate-spin"})}):oe?a.jsx(St,{children:a.jsxs(Nt,{className:"py-12 text-center",children:[a.jsx(Gh,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),a.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:t("kProfiles.printerOffline")}),a.jsx("p",{className:"text-bambu-gray mb-4",children:t("kProfiles.printerOfflineDesc")}),a.jsxs(Me,{variant:"secondary",onClick:()=>te(),children:[a.jsx(Sr,{className:"w-4 h-4"}),t("common.refresh")]})]})}):Ce.length>0?Le?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:Ce.filter(R=>R.extruder_id===1).map(R=>a.jsx(Mj,{profile:R,onEdit:()=>c(R),onCopy:()=>f(R),selectionMode:k,isSelected:C.has(U(R)),onToggleSelect:()=>fe(U(R)),note:O(R)},U(R)))})]}),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:Ce.filter(R=>R.extruder_id===0).map(R=>a.jsx(Mj,{profile:R,onEdit:()=>c(R),onCopy:()=>f(R),selectionMode:k,isSelected:C.has(U(R)),onToggleSelect:()=>fe(U(R)),note:O(R)},U(R)))})]})]}):a.jsx("div",{className:"space-y-1",children:Ce.map(R=>a.jsx(Mj,{profile:R,onEdit:()=>c(R),onCopy:()=>f(R),selectionMode:k,isSelected:C.has(U(R)),onToggleSelect:()=>fe(U(R)),note:O(R)},U(R)))}):p||v!=="all"||y!=="all"?a.jsx(St,{children:a.jsxs(Nt,{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(St,{children:a.jsxs(Nt,{className:"py-12 text-center",children:[a.jsx(qC,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),a.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:t("kProfiles.noKProfiles")}),a.jsx("p",{className:"text-bambu-gray mb-4",children:t("kProfiles.noKProfilesDesc",{diameter:s})}),a.jsxs(Me,{onClick:()=>u(!0),children:[a.jsx(Xn,{className:"w-4 h-4"}),t("kProfiles.createFirstProfile")]})]})}),l&&r&&(()=>{const{note:R,key:G}=be(l);return a.jsx(Pj,{profile:l,printerId:r,nozzleDiameter:s,existingProfiles:H?.profiles||q?.profiles,builtinFilaments:se,isDualNozzle:Le,initialNote:R,initialNoteKey:G,onSaveNote:Pe,hasPermission:n,onClose:()=>{console.log("[KProfiles] Edit modal onClose - refetching profiles..."),c(null),te()},onSave:()=>{c(null),te()}})})(),d&&r&&a.jsx(Pj,{printerId:r,nozzleDiameter:s,existingProfiles:H?.profiles||q?.profiles,builtinFilaments:se,isDualNozzle:Le,onSaveNote:Pe,hasPermission:n,onClose:()=>{u(!1),te()},onSave:()=>{u(!1),te()}}),h&&r&&a.jsx(Pj,{printerId:r,nozzleDiameter:s,existingProfiles:H?.profiles||q?.profiles,builtinFilaments:se,isDualNozzle:Le,onSaveNote:Pe,hasPermission:n,profile:{...h,slot_id:0,name:`${h.name} (Copy)`},onClose:()=>{f(null),te()},onSave:()=>{f(null),te()}}),M&&a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:a.jsx(St,{className:"w-full max-w-sm",children:a.jsxs(Nt,{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(Yt,{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:C.size})}),a.jsxs("div",{className:"flex gap-3",children:[a.jsx(Me,{variant:"secondary",onClick:()=>E(!1),disabled:B,className:"flex-1",children:t("common.cancel")}),a.jsxs(Me,{onClick:ue,disabled:B,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[B?a.jsx(at,{className:"w-4 h-4 animate-spin"}):a.jsx(Yt,{className:"w-4 h-4"}),t("common.delete")]})]})]})})})]})}const ese=["PLA","PETG","PCTG","ABS","ASA","TPU","PC","PA","PVA","HIPS","PP","PET","NYLON"],YZe={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 QZe(t){const e=t.toUpperCase();for(const n of ese)if(new RegExp(`\\b${n}\\b`).test(e))return n;return null}function ZZe(t){const e=t.replace(/@.+$/,"").trim(),n=e.toUpperCase();for(const r of ese){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 Ej({preset:t,onDelete:e,onExpand:n,isExpanded:r}){const{t:i}=Dt(),{hasPermission:s}=jr(),o=t.filament_type||QZe(t.name),l=t.filament_vendor||ZZe(t.name);let c=null,d=!1;if(t.default_filament_colour)try{const u=JSON.parse(t.default_filament_colour),h=Array.isArray(u)?u[0]:u;typeof h=="string"&&/^#?[0-9a-fA-F]{6,8}$/.test(h.replace("#",""))&&(c=h.replace("#","").slice(0,6),d=!0)}catch{const u=t.default_filament_colour;/^#?[0-9a-fA-F]{6,8}$/.test(u.replace("#",""))&&(c=u.replace("#","").slice(0,6),d=!0)}return!c&&o&&(c=YZe[o.toUpperCase()]||null),a.jsx(St,{className:"bg-bambu-dark border-bambu-dark-tertiary hover:border-bambu-dark-tertiary/80 transition-colors",children:a.jsxs(Nt,{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 ${!d&&!c?"opacity-25":d?"":"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(Yt,{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(wl,{className:"w-3.5 h-3.5"}):a.jsx(Mn,{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 JZe(){const{t}=Dt(),{hasPermission:e}=jr(),n=Qt(),{showToast:r}=dn(),[i,s]=w.useState(""),[o,l]=w.useState(null),[c,d]=w.useState(!1),[u,h]=w.useState(null),{data:f,isLoading:p}=Ze({queryKey:["localPresets"],queryFn:()=>J.getLocalPresets()}),x=st({mutationFn:async C=>{const j=[];for(const M of Array.from(C)){const E=new FormData;E.append("file",M),j.push(await J.importLocalPresets(E))}return j},onSuccess:C=>{n.invalidateQueries({queryKey:["localPresets"]});let j=0,M=0,E=0;for(const B of C)j+=B.imported,M+=B.skipped,E+=B.errors.length;j>0&&r(t("profiles.localProfiles.toast.importSuccess",{count:j})),M>0&&r(t("profiles.localProfiles.toast.importSkipped",{count:M}),"warning"),E>0&&r(t("profiles.localProfiles.toast.importError",{count:E}),"error")},onError:C=>{r(C.message,"error")}}),v=st({mutationFn:C=>J.deleteLocalPreset(C),onSuccess:()=>{n.invalidateQueries({queryKey:["localPresets"]}),h(null),r(t("profiles.localProfiles.toast.deleted"))}}),g=w.useCallback(C=>{!C||C.length===0||x.mutate(C)},[x]),y=w.useCallback(C=>{C.preventDefault(),d(!1),g(C.dataTransfer.files)},[g]),_=w.useCallback(C=>{if(!i)return C;const j=i.toLowerCase();return C.filter(M=>M.name.toLowerCase().includes(j)||M.filament_type?.toLowerCase().includes(j)||M.filament_vendor?.toLowerCase().includes(j))},[i]),N=w.useMemo(()=>_(f?.filament||[]),[f?.filament,_]),A=w.useMemo(()=>_(f?.printer||[]),[f?.printer,_]),k=w.useMemo(()=>_(f?.process||[]),[f?.process,_]),P=N.length+A.length+k.length;return p?a.jsx("div",{className:"flex items-center justify-center py-16",children:a.jsx(at,{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:C=>{C.preventDefault(),d(!0)},onDragLeave:()=>d(!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:C=>g(C.target.files)}),x.isPending?a.jsxs("div",{className:"flex items-center justify-center gap-2",children:[a.jsx(at,{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(Oa,{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")})]})]}),P>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:C=>s(C.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"})]}),P===0&&!p&&a.jsxs("div",{className:"text-center py-12",children:[a.jsx(Vb,{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")})]}),P>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(HC,{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(C=>a.jsx(Ej,{preset:C,onDelete:j=>h(j),onExpand:l,isExpanded:o===C.id},C.id))})]}),k.length>0&&a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[a.jsx(ri,{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:["(",k.length,")"]})]}),a.jsx("div",{className:"space-y-2",children:k.map(C=>a.jsx(Ej,{preset:C,onDelete:j=>h(j),onExpand:l,isExpanded:o===C.id},C.id))})]}),A.length>0&&a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[a.jsx(tu,{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(C=>a.jsx(Ej,{preset:C,onDelete:j=>h(j),onExpand:l,isExpanded:o===C.id},C.id))})]})]}),u!==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(Va,{className:"w-5 h-5 text-red-400"}),a.jsx("h3",{className:"text-white font-medium",children:t("profiles.localProfiles.deleteConfirmTitle")})]}),a.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:t("profiles.localProfiles.deleteConfirm")}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(Me,{variant:"secondary",size:"sm",onClick:()=>h(null),children:t("profiles.localProfiles.cancel")}),a.jsxs(Me,{variant:"danger",size:"sm",onClick:()=>v.mutate(u),disabled:v.isPending,children:[v.isPending?a.jsx(at,{className:"w-4 h-4 animate-spin"}):a.jsx(Yt,{className:"w-4 h-4"}),t("profiles.localProfiles.delete")]})]})]})})]})}function hI(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,d=n.match(/\b(PLA|PETG|ABS|ASA|TPU|PC|PA|PVA|HIPS|PP|PET(?:-?CF)?|PA(?:-?CF)?|PLA(?:-?CF)?)\b/i),u=d?d[1].toUpperCase():null;return{printer:i,nozzle:o,layerHeight:c,filamentType:u}}function av(t){return/^(P[FPM]US|PF\d|PP\d)/.test(t)}function eJe({onSuccess:t,t:e}){const{showToast:n}=dn(),[r,i]=w.useState("email"),[s,o]=w.useState(""),[l,c]=w.useState(""),[d,u]=w.useState(""),[h,f]=w.useState(""),[p,x]=w.useState("global"),[v,g]=w.useState(null),[y,_]=w.useState(null),N=st({mutationFn:()=>J.cloudLogin(s,l,p),onSuccess:j=>{j.success?(n(e("profiles.login.toast.loggedIn")),t()):j.needs_verification?(g(j.verification_type||"email"),_(j.tfa_key||null),j.verification_type==="totp"?n(e("profiles.login.toast.enterTotp")):n(e("profiles.login.toast.codeSent")),i("code")):n(j.message,"error")},onError:j=>n(j.message,"error")}),A=st({mutationFn:()=>J.cloudVerify(s,d,y||void 0),onSuccess:j=>{j.success?(n(e("profiles.login.toast.loggedIn")),t()):n(j.message,"error")},onError:j=>n(j.message,"error")}),k=st({mutationFn:()=>J.cloudSetToken(h),onSuccess:()=>{n(e("profiles.login.toast.tokenSet")),t()},onError:j=>n(j.message,"error")}),P=j=>{j.preventDefault(),r==="email"?N.mutate():r==="code"?A.mutate():r==="token"&&k.mutate()},C=N.isPending||A.isPending||k.isPending;return a.jsx(St,{className:"max-w-md mx-auto",children:a.jsxs(Nt,{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($b,{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:P,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:j=>o(j.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:j=>c(j.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:j=>x(j.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:d,onChange:j=>u(j.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:j=>f(j.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(Me,{type:"button",variant:"secondary",onClick:()=>i("email"),className:"flex-1",children:e("profiles.login.back")}),a.jsxs(Me,{type:"submit",disabled:C,className:"flex-1",children:[C?a.jsx(at,{className:"w-4 h-4 animate-spin"}):a.jsx(OB,{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(al,{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(OB,{className:"w-4 h-4"}),e("profiles.login.useEmail")]})})]})]})})}function Tg({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(Mn,{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 tJe(){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(Mf,{className:"w-5 h-5"})}):null}function jj({setting:t,onClick:e,onDuplicate:n,compareMode:r,isCompareSelected:i,compareIndex:s,compareDisabled:o,t:l}){const c=hI(t.name),d=av(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&&d&&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:u=>{u.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(Ql,{className:"w-4 h-4"})})]})}function iF(t,e=0){const n=" ".repeat(e);if(t===null)return"null";if(t===void 0)return"undefined";if(typeof t=="string"){if(t.includes("\\n")||t.includes(`
- `)){const i=t.replace(/\\n/g,`
- `).replace(/\\"/g,'"').replace(/\\t/g," ").split(`
- `);if(i.length>1)return`"""
- `+i.map(s=>n+" "+s).join(`
- `)+`
- `+n+'"""'}return JSON.stringify(t)}if(typeof t=="number"||typeof t=="boolean")return String(t);if(Array.isArray(t))return t.length===0?"[]":`[
- `+t.map(i=>n+" "+iF(i,e+1)).join(`,
- `)+`
- `+n+"]";if(typeof t=="object"){const r=Object.entries(t);return r.length===0?"{}":`{
- `+r.map(([s,o])=>n+" "+JSON.stringify(s)+": "+iF(o,e+1)).join(`,
- `)+`
- `+n+"}"}return String(t)}function nJe({setting:t,onClose:e,onDeleted:n,onDuplicate:r,onEdit:i,hasPermission:s,t:o}){const{showToast:l}=dn(),c=Qt(),[d,u]=w.useState(!1),{data:h,isLoading:f}=Ze({queryKey:["cloudSettingDetail",t.setting_id],queryFn:()=>J.getCloudSettingDetail(t.setting_id)}),p=st({mutationFn:()=>J.deleteCloudSetting(t.setting_id),onSuccess:()=>{l(o("profiles.presets.toast.deleted")),c.invalidateQueries({queryKey:["cloudSettings"]}),n()},onError:g=>l(g.message,"error")}),x=av(t.setting_id),v=hI(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(St,{className:"w-full max-w-3xl max-h-[90vh] flex flex-col overflow-hidden",children:a.jsxs(Nt,{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(Rt,{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(at,{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:iF(h)}):a.jsx("div",{className:"text-center py-16 text-bambu-gray",children:o("profiles.presets.failedToLoadDetails")})}),d?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(An,{className:"w-5 h-5"}),a.jsx("span",{className:"font-medium",children:o("profiles.presets.deleteConfirm")})]}),a.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:o("profiles.presets.deleteWarning",{name:t.name})}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Me,{variant:"secondary",onClick:()=>u(!1),disabled:p.isPending,className:"flex-1",children:o("common.cancel")}),a.jsxs(Me,{variant:"danger",onClick:()=>p.mutate(),disabled:p.isPending,className:"flex-1",children:[p.isPending?a.jsx(at,{className:"w-4 h-4 animate-spin"}):a.jsx(Yt,{className:"w-4 h-4"}),o("common.delete")]})]})]}):a.jsx("div",{className:"flex-shrink-0 p-4 border-t border-bambu-dark-tertiary",children:a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Me,{variant:"secondary",onClick:e,className:"flex-1",children:o("common.close")}),a.jsxs(Me,{variant:"secondary",onClick:r,disabled:!s("cloud:auth"),title:s("cloud:auth")?void 0:o("profiles.presets.noDuplicatePermission"),children:[a.jsx(Ql,{className:"w-4 h-4"}),o("profiles.presets.duplicate")]}),x&&a.jsxs(a.Fragment,{children:[a.jsxs(Me,{variant:"secondary",onClick:i,disabled:f||!h||!s("cloud:auth"),title:s("cloud:auth")?void 0:o("profiles.presets.noEditPermission"),children:[a.jsx(Ga,{className:"w-4 h-4"}),o("common.edit")]}),a.jsx(Me,{variant:"danger",onClick:()=>u(!0),disabled:!s("cloud:auth"),title:s("cloud:auth")?void 0:o("profiles.presets.noDeletePermission"),children:a.jsx(Yt,{className:"w-4 h-4"})})]})]})})]})})})}function tse(){try{const t=localStorage.getItem("bambusy_preset_templates");return t?JSON.parse(t):[]}catch{return[]}}function nse(t){localStorage.setItem("bambusy_preset_templates",JSON.stringify(t))}function rJe({onClose:t,onApply:e,t:n}){const{showToast:r}=dn(),[i,s]=w.useState(tse),[o,l]=w.useState("all"),[c,d]=w.useState(null),[u,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(U=>U.type===o),k=U=>{s(U),nse(U)},P=U=>{const D=i.filter($=>$.id!==U);k(D),N(null),r(n("profiles.templates.toast.deleted"))},C=U=>{d(U.id),h(U.name),p(U.description),v(JSON.stringify(U.settings,null,2)),y(null)},j=()=>{if(!(!c||!u.trim()))try{const U=JSON.parse(x),D=i.map($=>$.id===c?{...$,name:u.trim(),description:f.trim(),settings:U}:$);k(D),d(null),r(n("profiles.templates.toast.updated"))}catch(U){y(U.message)}},M=()=>{d(null),h(""),p(""),v("{}"),y(null)},E=U=>{const D=i.map($=>$.id===U?{...$,showInModal:!$.showInModal}:$);k(D)},B={filament:{label:n("profiles.presets.types.filament"),icon:HC,color:"text-amber-400"},print:{label:n("profiles.presets.types.process"),icon:tu,color:"text-blue-400"},printer:{label:n("profiles.presets.types.printer"),icon:Nr,color:"text-purple-400"}},L=_?i.find(U=>U.id===_):null;return w.useEffect(()=>{const U=D=>{D.key==="Escape"&&(_?N(null):c?M():t())};return window.addEventListener("keydown",U),()=>window.removeEventListener("keydown",U)},[_,c,t]),a.jsxs("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:[L&&a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-60",children:a.jsx(St,{className:"w-full max-w-md",children:a.jsxs(Nt,{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(An,{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:L.name})}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Me,{variant:"secondary",onClick:()=>N(null),className:"flex-1",children:n("common.cancel")}),a.jsxs(Me,{onClick:()=>P(_),className:"flex-1 bg-red-500 hover:bg-red-600",children:[a.jsx(Yt,{className:"w-4 h-4"}),n("common.delete")]})]})]})})}),a.jsx(St,{className:"w-full max-w-2xl max-h-[80vh] flex flex-col",children:a.jsxs(Nt,{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(hb,{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(Rt,{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(U=>a.jsx("button",{onClick:()=>l(U),className:`px-3 py-1 text-sm rounded-lg transition-colors ${o===U?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:U==="all"?n("common.all"):B[U].label},U))]}),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(hb,{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(U=>{const D=B[U.type],$=D.icon;return c===U.id?a.jsxs("div",{className:"p-4 bg-bambu-dark rounded-lg border border-bambu-green",children:[a.jsxs("div",{className:"grid grid-cols-2 gap-3 mb-3",children:[a.jsx("input",{type:"text",value:u,onChange:q=>h(q.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:q=>p(q.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:q=>{v(q.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(Me,{size:"sm",onClick:j,disabled:!u.trim(),children:[a.jsx(bs,{className:"w-4 h-4"}),"Save"]}),a.jsx(Me,{size:"sm",variant:"secondary",onClick:M,children:"Cancel"})]})]},U.id):a.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary hover:border-bambu-gray-dark transition-colors",children:[a.jsx($,{className:`w-5 h-5 ${D.color} flex-shrink-0`}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-sm font-medium text-white",children:U.name}),a.jsx("p",{className:"text-xs text-bambu-gray truncate",children:U.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(U.settings).length})}),a.jsx("button",{onClick:()=>E(U.id),className:`p-1 transition-colors ${U.showInModal?"text-bambu-green hover:text-bambu-green/70":"text-bambu-gray hover:text-white"}`,title:U.showInModal?n("profiles.templates.shownInModals"):n("profiles.templates.hiddenInModals"),children:U.showInModal?a.jsx(Zl,{className:"w-4 h-4"}):a.jsx(cv,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>e(U),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:()=>C(U),className:"p-1 text-bambu-gray hover:text-white",title:n("common.edit"),children:a.jsx(Ga,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>N(U.id),className:"p-1 text-bambu-gray hover:text-red-400",title:n("common.delete"),children:a.jsx(Yt,{className:"w-4 h-4"})})]},U.id)})})})]})})]})}function rse({onClose:t,leftPreset:e,rightPreset:n,leftLabel:r,rightLabel:i,t:s}){const[o,l]=w.useState("changes"),[c,d]=w.useState(""),u=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 k;!N&&A?k="added":N&&!A?k="removed":JSON.stringify(y)!==JSON.stringify(_)?k="changed":k="same",v.push({key:g,left:y,right:_,status:k})}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=[...u];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},[u,o,c]),f=w.useMemo(()=>({added:u.filter(x=>x.status==="added").length,removed:u.filter(x=>x.status==="removed").length,changed:u.filter(x=>x.status==="changed").length,same:u.filter(x=>x.status==="same").length}),[u]),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(St,{className:"w-full max-w-4xl max-h-[85vh] flex flex-col overflow-hidden",children:a.jsxs(Nt,{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(Gg,{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(Rt,{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(Xn,{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(w1,{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(r3,{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(BM,{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=>d(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(BM,{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(Xn,{className:"w-3.5 h-3.5 text-green-400"}),removed:a.jsx(w1,{className:"w-3.5 h-3.5 text-red-400"}),changed:a.jsx(r3,{className:"w-3.5 h-3.5 text-amber-400"}),same:a.jsx(BM,{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 aJe({onClose:t,initialData:e,allPresets:n,t:r}){const{showToast:i}=dn(),s=Qt(),o=!!e?.setting_id,[l,c]=w.useState("common"),[d,u]=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)),[k,P]=w.useState(null),[C,j]=w.useState(""),[M,E]=w.useState(!1),[B,L]=w.useState(""),[U,D]=w.useState(!1),[$,q]=w.useState(tse),[z,W]=w.useState(!1),[Q,te]=w.useState(""),[H,X]=w.useState(""),[Z,ee]=w.useState(!0),[Se,oe]=w.useState(null),[ie,me]=w.useState(!1),se=w.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer})[d]||[],[n,d]),ce=w.useMemo(()=>se.filter(Ne=>av(Ne.setting_id)),[se]),{data:Ce}=Ze({queryKey:["cloudFields",d],queryFn:()=>J.getCloudFields(d==="print"?"process":d),staleTime:1e3*60*60}),{data:le}=Ze({queryKey:["allPresetDetails",d,ce.map(Ne=>Ne.setting_id).join(",")],queryFn:async()=>{const Ne={};for(let we=0;we<ce.length;we+=5){const qe=ce.slice(we,we+5);(await Promise.all(qe.map(async nt=>{try{const De=await J.getCloudSettingDetail(nt.setting_id);return{id:nt.setting_id,detail:De}}catch{return null}}))).forEach(nt=>{nt&&(Ne[nt.id]=nt.detail)})}return Ne},enabled:ce.length>0,staleTime:1e3*60*10}),{data:Le,isLoading:V}=Ze({queryKey:["cloudSettingDetail",p],queryFn:()=>J.getCloudSettingDetail(p),enabled:!!p});w.useEffect(()=>{l!=="json"&&A(JSON.stringify(y,null,2))},[y,l]);const K=w.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer}[d]||[]).filter(xe=>!av(xe.setting_id)).sort((xe,we)=>xe.name.localeCompare(we.name)),[n,d]);w.useEffect(()=>{if(!p)return;const Ne=K.find(xe=>xe.setting_id===p);Ne&&(g(Ne.name),o||(_({inherits:Ne.name}),A(JSON.stringify({inherits:Ne.name},null,2))))},[p,K,o]);const fe=w.useMemo(()=>{const Ne=Ce?.fields||[],xe=new Set(Ne.map(nt=>nt.key)),we=new Set,qe=new Set(["inherits","updated_time","compatible_printers","compatible_prints"]);le&&Object.values(le).forEach(nt=>{nt?.setting&&Object.keys(nt.setting).forEach(De=>{!xe.has(De)&&!qe.has(De)&&we.add(De)})}),Object.keys(y).forEach(nt=>{!xe.has(nt)&&!qe.has(nt)&&we.add(nt)});const ke=Array.from(we).sort().map(nt=>({key:nt,label:nt.replace(/_/g," ").replace(/\b\w/g,De=>De.toUpperCase()),type:"text",category:"discovered",description:r("profiles.presets.discoveredFromPresets")}));return[...Ne,...ke]},[Ce,le,y,r]),Y=fe.filter(Ne=>Ne.label.toLowerCase().includes(C.toLowerCase())||Ne.key.toLowerCase().includes(C.toLowerCase())),re=()=>{if(B.trim()){const Ne=B.trim().toLowerCase().replace(/\s+/g,"_");ue(Ne,""),L(""),D(!1),i(r("profiles.presets.toast.fieldAdded",{key:Ne}))}},ue=(Ne,xe)=>{_(we=>{const qe={...we};return xe===""||xe===void 0?delete qe[Ne]:qe[Ne]=xe,qe})},Fe=Ne=>{_(xe=>({...xe,...Ne.settings})),oe(Ne.name),i(r("profiles.templates.toast.applied"))},Pe=()=>{if(!Q.trim())return;const Ne={...y};if(delete Ne.inherits,Object.keys(Ne).length===0){i(r("profiles.presets.noOverridesToSave"),"error");return}const xe={id:Date.now().toString(),name:Q.trim(),description:H.trim()||r("profiles.presets.customTemplate"),type:d,settings:Ne,showInModal:Z},we=[...$,xe];q(we),nse(we),W(!1),te(""),X(""),ee(!0),i(r("profiles.templates.toast.created"))},be=w.useMemo(()=>$.filter(Ne=>Ne.type===d&&Ne.showInModal),[d,$]),O=Ne=>{A(Ne);try{const xe=JSON.parse(Ne);_(xe),P(null)}catch(xe){P(xe.message)}},R=Ne=>{Ne.preventDefault(),E(!1);const xe=Ne.dataTransfer.files[0];if(xe&&xe.name.endsWith(".json")){const we=new FileReader;we.onload=qe=>{try{const ke=qe.target?.result,nt=JSON.parse(ke),De=nt.setting||nt;_(We=>({...We,...De})),A(JSON.stringify({...y,...De},null,2)),i(r("profiles.presets.fileImported"))}catch{i(r("profiles.presets.invalidJsonFile"),"error")}},we.readAsText(xe)}},G=st({mutationFn:()=>{const Ne={...y},xe=d==="filament"?"filament_settings_id":d==="print"?"print_settings_id":"printer_settings_id";Ne[xe]=`"${h}"`;const we={type:d,name:h,base_id:p,setting:Ne};return J.createCloudSetting(we)},onSuccess:async()=>{i(r("profiles.presets.toast.created")),await s.refetchQueries({queryKey:["cloudSettings"]}),t()},onError:Ne=>i(Ne.message,"error")}),de=st({mutationFn:()=>{if(!e?.setting_id)throw new Error(r("profiles.presets.noSettingId"));return J.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:Ne=>i(Ne.message,"error")}),ge=o?de:G,ae=Le?.setting?.inherits,Ue=ae?K.find(Ne=>Ne.name===ae):void 0,{data:ze}=Ze({queryKey:["cloudSettingDetail",Ue?.setting_id],queryFn:()=>J.getCloudSettingDetail(Ue.setting_id),enabled:!!Ue?.setting_id}),$e=w.useMemo(()=>{const Ne=ze?.setting||{},xe=Le?.setting||{},we=p&&le?.[p]?.setting?le[p].setting:{};return{...Ne,...xe,...we}},[p,Le,ze,le]),Re=Ne=>{if(Ne==null)return"";if(Array.isArray(Ne)){const xe=[...new Set(Ne.map(we=>String(we)))];return xe.length===1?xe[0]:Ne.join(", ")}return String(Ne)},pe=Ne=>{const xe=y[Ne.key],we=$e[Ne.key],qe=Re(we),ke=V?r("common.loading"):qe||"",nt="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(Ne.type==="boolean"){const De=xe==="1"||xe===void 0&&we==="1";return a.jsx("button",{type:"button",onClick:()=>ue(Ne.key,xe==="1"?"0":"1"),className:`w-8 h-5 rounded-full transition-colors ${De?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,children:a.jsx("div",{className:`w-4 h-4 rounded-full bg-white shadow transition-transform ${De?"translate-x-3.5":"translate-x-0.5"}`})})}return Ne.type==="select"?a.jsxs("select",{value:xe||"",onChange:De=>ue(Ne.key,De.target.value),className:nt,children:[a.jsx("option",{value:"",children:ke}),Ne.options?.map(De=>a.jsx("option",{value:De.value,children:De.label},De.value))]}):a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:Ne.type==="number"?"number":"text",value:xe!==void 0?String(xe):"",onChange:De=>ue(Ne.key,De.target.value),step:Ne.step,min:Ne.min,max:Ne.max,placeholder:ke,className:nt}),Ne.unit&&a.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:Ne.unit})]})},ve=w.useMemo(()=>Le?.setting?Le.setting:{},[Le]);return a.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onDragOver:Ne=>{Ne.preventDefault(),E(!0)},onDragLeave:()=>E(!1),onDrop:R,children:[ie&&p&&a.jsx(rse,{onClose:()=>me(!1),leftPreset:ve,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(St,{className:"w-full max-w-6xl max-h-[90vh] flex flex-col overflow-y-auto",children:a.jsxs(Nt,{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:()=>me(!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(Gg,{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(Rt,{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(Oa,{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:d,onChange:Ne=>{u(Ne.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:Ne=>x(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",children:[a.jsx("option",{value:"",children:r("profiles.presets.selectBasePreset")}),K.map(Ne=>a.jsx("option",{value:Ne.setting_id,children:Ne.name},Ne.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:Ne=>f(Ne.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(na,{className:"w-3 h-3 text-bambu-green"}),r("profiles.presets.inheritsFrom")," ",a.jsx("span",{className:"text-white",children:v}),V&&a.jsx(at,{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(IB,{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(GC,{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(vX,{className:"w-4 h-4"}),"JSON",k&&a.jsx(Va,{className:"w-3 h-3 text-red-400"})]}),a.jsx("div",{className:"flex-1 max-[640px]:hidden"}),a.jsxs("button",{onClick:()=>{const Ne={name:h,type:d,base_id:p,setting:y},xe=new Blob([JSON.stringify(Ne,null,2)],{type:"application/json"}),we=URL.createObjectURL(xe),qe=document.createElement("a");qe.href=we,qe.download=`${h||"preset"}.json`,document.body.appendChild(qe),qe.click(),document.body.removeChild(qe),URL.revokeObjectURL(we),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(ga,{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(Oa,{className:"w-4 h-4"}),r("common.upload")]}),a.jsx("input",{id:"file-import",type:"file",accept:".json",className:"hidden",onChange:Ne=>{const xe=Ne.target.files?.[0];if(xe){const we=new FileReader;we.onload=qe=>{try{const ke=JSON.parse(qe.target?.result),nt=ke.setting||ke;_(De=>({...De,...nt})),i(r("profiles.presets.fileImported"))}catch{i(r("profiles.presets.invalidJson"),"error")}},we.readAsText(xe)}}})]}),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(hb,{className:"w-4 h-4 text-amber-400"}),r("profiles.templates.title")]}),Object.keys(y).filter(Ne=>Ne!=="inherits").length>0&&a.jsxs("button",{onClick:()=>W(!z),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")]})]}),z&&a.jsxs("div",{className:"mb-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"grid grid-cols-2 gap-2 mb-2",children:[a.jsx("input",{type:"text",value:Q,onChange:Ne=>te(Ne.target.value),placeholder:r("profiles.templates.namePlaceholder"),className:"px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",autoFocus:!0}),a.jsx("input",{type:"text",value:H,onChange:Ne=>X(Ne.target.value),placeholder:r("profiles.templates.descriptionPlaceholder"),className:"px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex gap-2",children:[a.jsxs(Me,{size:"sm",onClick:Pe,disabled:!Q.trim(),children:[a.jsx(bs,{className:"w-3 h-3"}),r("common.save")]}),a.jsx(Me,{size:"sm",variant:"secondary",onClick:()=>W(!1),children:r("common.cancel")})]}),a.jsxs("button",{onClick:()=>ee(!Z),className:`flex items-center gap-1.5 text-xs transition-colors ${Z?"text-bambu-green":"text-bambu-gray hover:text-white"}`,children:[Z?a.jsx(Zl,{className:"w-3.5 h-3.5"}):a.jsx(cv,{className:"w-3.5 h-3.5"}),r(Z?"profiles.templates.shownInModals":"profiles.templates.hiddenInModals")]})]})]}),Se&&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(na,{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:Se})]}),a.jsx("button",{onClick:()=>oe(null),className:"ml-auto text-bambu-green/70 hover:text-bambu-green",children:a.jsx(Rt,{className:"w-4 h-4"})})]}),a.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[be.map(Ne=>a.jsxs("button",{onClick:()=>Fe(Ne),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:Ne.name}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:Ne.description})]},Ne.id)),be.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:fe.slice(0,10).map(Ne=>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:Ne.label}),a.jsx("div",{className:"w-48 max-[640px]:w-full",children:pe(Ne)})]},Ne.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(([Ne])=>Ne!=="inherits").map(([Ne,xe])=>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:[Ne,": ",String(xe).slice(0,20),a.jsx("button",{onClick:()=>ue(Ne,void 0),className:"hover:text-white",children:a.jsx(Rt,{className:"w-3 h-3"})})]},Ne))})]})]}),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:le?r("profiles.templates.fieldsCount",{count:fe.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:C,onChange:Ne=>j(Ne.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:[Y.filter(Ne=>!(Ne.key in y)).map(Ne=>{const xe=$e[Ne.key],we=Re(xe);return a.jsxs("div",{onClick:()=>{_(qe=>({...qe,[Ne.key]:we||""}))},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:Ne.label}),a.jsx("p",{className:"text-xs text-bambu-gray-dark truncate",children:Ne.key})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[we&&a.jsxs("span",{className:"text-xs text-bambu-gray bg-bambu-dark px-2 py-0.5 rounded max-w-32 truncate",title:we,children:[we.slice(0,20),we.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(Xn,{className:"w-4 h-4 text-bambu-gray group-hover:text-bambu-green transition-colors"})})]})]},Ne.key)}),Y.filter(Ne=>!(Ne.key in y)).length===0&&a.jsx("p",{className:"text-center text-bambu-gray py-4 text-sm",children:r(C?"profiles.presets.noMatchingFields":"profiles.presets.allFieldsAdded")})]}),a.jsx("div",{className:"pt-3 mt-3 border-t border-bambu-dark-tertiary flex-shrink-0",children:U?a.jsxs("div",{className:"flex gap-2",children:[a.jsx("input",{type:"text",value:B,onChange:Ne=>L(Ne.target.value),onKeyDown:Ne=>Ne.key==="Enter"&&re(),placeholder:"custom_field_name",className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white font-mono text-sm placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none",autoFocus:!0}),a.jsx(Me,{size:"sm",onClick:re,disabled:!B.trim(),children:a.jsx(Xn,{className:"w-4 h-4"})}),a.jsx(Me,{size:"sm",variant:"secondary",onClick:()=>{D(!1),L("")},children:a.jsx(Rt,{className:"w-4 h-4"})})]}):a.jsxs("button",{onClick:()=>D(!0),className:"w-full flex items-center justify-center gap-2 p-2 text-sm text-bambu-gray hover:text-white border border-dashed border-bambu-dark-tertiary hover:border-bambu-gray-dark rounded-lg transition-colors",children:[a.jsx(Xn,{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(Ne=>Ne!=="inherits").length})})]}),a.jsxs("div",{className:"flex-1 overflow-y-auto space-y-2 pr-2 min-h-0",children:[Object.entries(y).filter(([Ne])=>Ne!=="inherits").map(([Ne,xe])=>{const we=fe.find(qe=>qe.key===Ne);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:we?.label||Ne}),a.jsx("p",{className:"text-xs text-bambu-gray-dark",children:Ne})]}),a.jsx("button",{onClick:()=>ue(Ne,void 0),className:"p-1 text-bambu-gray hover:text-red-400 transition-colors",children:a.jsx(Rt,{className:"w-4 h-4"})})]}),we?pe(we):a.jsx("input",{type:"text",value:String(xe),onChange:qe=>ue(Ne,qe.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"})]},Ne)}),Object.keys(y).filter(Ne=>Ne!=="inherits").length===0&&a.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[a.jsx(IB,{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(Ne=>Ne!=="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:()=>{W(!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:[k&&a.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[a.jsx(Va,{className:"w-4 h-4"}),k]}),a.jsx("textarea",{value:N,onChange:Ne=>O(Ne.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 ${k?"border-red-500 focus:border-red-500":"border-bambu-dark-tertiary focus:border-bambu-green"}`,spellCheck:!1}),a.jsx("p",{className:"text-xs text-bambu-gray",children:r("profiles.presets.jsonTip")})]})]}),a.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary flex gap-2",children:[a.jsx(Me,{variant:"secondary",onClick:t,className:"flex-1",children:r("common.cancel")}),a.jsxs(Me,{onClick:()=>ge.mutate(),disabled:ge.isPending||!h.trim()||!o&&!p||!!k,className:"flex-1",children:[ge.isPending?a.jsx(at,{className:"w-4 h-4 animate-spin"}):o?a.jsx(bs,{className:"w-4 h-4"}):a.jsx(Xn,{className:"w-4 h-4"}),r(o?"common.save":e?"common.duplicate":"common.create")]})]})]})})]})}function iJe({settings:t,lastSyncTime:e,onRefresh:n,isRefreshing:r,printers:i,hasPermission:s,t:o}){const[l,c]=w.useState(""),[d,u]=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"),[k,P]=w.useState(null),[C,j]=w.useState(!1),[M,E]=w.useState(!1),[B,L]=w.useState(null),[U,D]=w.useState(null),[$,q]=w.useState(null),[z,W]=w.useState(!1),[Q,te]=w.useState([null,null]),[H,X]=w.useState(!1),[Z,ee]=w.useState(null),Se=Qt(),oe=w.useMemo(()=>[...t.filament.map(re=>({...re,type:"filament"})),...t.printer.map(re=>({...re,type:"printer"})),...t.process.map(re=>({...re,type:"process"}))].map(re=>({...re,meta:hI(re.name)})),[t]),ie=w.useMemo(()=>{const Y=new Set,re=new Set,ue=new Set;return oe.forEach(Fe=>{Fe.meta.nozzle&&Y.add(Fe.meta.nozzle),Fe.meta.filamentType&&re.add(Fe.meta.filamentType),Fe.meta.layerHeight&&ue.add(Fe.meta.layerHeight)}),{printers:i.map(Fe=>({id:Fe.id.toString(),name:Fe.name})),nozzles:Array.from(Y).sort((Fe,Pe)=>parseFloat(Fe)-parseFloat(Pe)),filaments:Array.from(re).sort(),layerHeights:Array.from(ue).sort((Fe,Pe)=>parseFloat(Fe)-parseFloat(Pe))}},[oe,i]),me=w.useMemo(()=>p==="all"?null:i.find(re=>re.id.toString()===p)?.model||null,[p,i]),se=w.useMemo(()=>oe.filter(Y=>d==="all"||Y.type===d).filter(Y=>{if(h==="all")return!0;const re=av(Y.setting_id);return h==="custom"?re:!re}).filter(Y=>{if(p==="all"||!me)return!0;const re=Y.meta.printer?.toLowerCase()||"",ue=me.toLowerCase();return re.includes(ue)||ue.includes(re)}).filter(Y=>v==="all"||Y.meta.nozzle===v).filter(Y=>y==="all"||Y.meta.filamentType===y).filter(Y=>N==="all"||Y.meta.layerHeight===N).filter(Y=>l===""||Y.name.toLowerCase().includes(l.toLowerCase())).sort((Y,re)=>Y.name.localeCompare(re.name)),[oe,d,h,p,me,v,y,N,l]),ce=Y=>{if(z){const re=Q[0]?.setting_id===Y.setting_id,ue=Q[1]?.setting_id===Y.setting_id;if(re)te([Q[1],null]);else if(ue)te([Q[0],null]);else if(!Q[0])te([Y,null]);else if(Q[1]){if(Q[0].type!==Y.type)return;te([Q[0],Y])}else{if(Q[0].type!==Y.type)return;te([Q[0],Y])}}else P(Y)},Ce=Y=>{if(Q[0]?.setting_id===Y.setting_id)return 0;if(Q[1]?.setting_id===Y.setting_id)return 1},le=async Y=>{try{const re=await J.getCloudSettingDetail(Y.setting_id),ue=Y.type==="process"?"print":Y.type;L({type:ue,name:Y.name,base_id:re.base_id||"GFSA00",setting:re.setting||{}}),P(null)}catch(re){console.error("Failed to fetch preset details for duplication:",re)}},Le=async Y=>{try{Se.removeQueries({queryKey:["cloudSettingDetail",Y.setting_id]});const re=await J.getCloudSettingDetail(Y.setting_id),ue=Y.type==="process"?"print":Y.type;D({type:ue,name:Y.name,base_id:re.base_id||"GFSA00",setting:re.setting||{},setting_id:Y.setting_id}),P(null)}catch(re){console.error("Failed to fetch preset details for editing:",re)}},V=()=>{u("all"),f("all"),x("all"),g("all"),_("all"),A("all"),c("")},K=d!=="all"||h!=="all"||p!=="all"||v!=="all"||y!=="all"||N!=="all"||l!=="",fe=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:Y=>c(Y.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(Me,{variant:z?"primary":"secondary",onClick:()=>{z?(W(!1),te([null,null])):W(!0)},children:[a.jsx(Gg,{className:"w-4 h-4"}),o(z?"common.cancel":"profiles.presets.compare")]}),a.jsxs(Me,{variant:"secondary",onClick:()=>E(!0),disabled:!s("cloud:auth"),title:s("cloud:auth")?void 0:o("profiles.cloudView.noTemplatesPermission"),children:[a.jsx(hb,{className:"w-4 h-4"}),o("profiles.cloudView.templates")]}),a.jsxs(Me,{variant:"secondary",onClick:n,disabled:r||!s("cloud:auth"),title:s("cloud:auth")?void 0:o("profiles.cloudView.noRefreshPermission"),children:[a.jsx(Sr,{className:`w-4 h-4 ${r?"animate-spin":""}`}),o("profiles.cloudView.refresh")]}),a.jsxs(Me,{onClick:()=>j(!0),disabled:!s("cloud:auth"),title:s("cloud:auth")?void 0:o("profiles.cloudView.noCreatePermission"),children:[a.jsx(Xn,{className:"w-4 h-4"}),o("profiles.cloudView.newPreset")]})]})]}),a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsx(VC,{className:"w-4 h-4 text-bambu-gray"}),a.jsx(Tg,{label:o("profiles.cloudView.filters.type"),value:d,options:[{value:"all",label:o("profiles.cloudView.filters.all"),count:fe},{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:Y=>u(Y)}),a.jsx(Tg,{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:Y=>f(Y)}),ie.printers.length>0&&a.jsx(Tg,{label:o("profiles.cloudView.filters.printer"),value:p,options:[{value:"all",label:o("profiles.cloudView.filters.all")},...ie.printers.map(Y=>({value:Y.id,label:Y.name}))],onChange:x}),ie.nozzles.length>0&&a.jsx(Tg,{label:o("profiles.cloudView.filters.nozzle"),value:v,options:[{value:"all",label:o("profiles.cloudView.filters.all")},...ie.nozzles.map(Y=>({value:Y,label:Y}))],onChange:g}),ie.filaments.length>0&&(d==="all"||d==="filament")&&a.jsx(Tg,{label:o("profiles.cloudView.filters.filament"),value:y,options:[{value:"all",label:o("profiles.cloudView.filters.all")},...ie.filaments.map(Y=>({value:Y,label:Y}))],onChange:_}),ie.layerHeights.length>0&&(d==="all"||d==="process")&&a.jsx(Tg,{label:o("profiles.cloudView.filters.layer"),value:N,options:[{value:"all",label:o("profiles.cloudView.filters.all")},...ie.layerHeights.map(Y=>({value:Y,label:Y}))],onChange:A}),K&&a.jsx("button",{onClick:V,className:"px-3 py-2 text-sm text-bambu-gray hover:text-white transition-colors",children:o("profiles.cloudView.clearFilters")})]})]}),z&&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(Gg,{className:"w-5 h-5 text-blue-400"}),a.jsx("span",{className:"text-white font-medium",children:o("profiles.cloudView.compareMode")}),a.jsx("span",{className:"text-bambu-gray",children:Q[0]?o("profiles.cloudView.selectAnotherPreset",{type:Q[0].type}):o("profiles.cloudView.clickTwoPresets")})]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:`px-2 py-1 text-sm rounded truncate max-w-[200px] ${Q[0]?"bg-blue-500/30 text-blue-700 dark:text-blue-300":"bg-bambu-dark text-bambu-gray"}`,children:Q[0]?Q[0].name:o("profiles.cloudView.selectFirst")}),a.jsx(r3,{className:"w-4 h-4 text-bambu-gray"}),a.jsx("span",{className:`px-2 py-1 text-sm rounded truncate max-w-[200px] ${Q[1]?"bg-blue-500/30 text-blue-700 dark:text-blue-300":"bg-bambu-dark text-bambu-gray"}`,children:Q[1]?Q[1].name:o("profiles.cloudView.selectSecond")})]}),Q[0]&&Q[1]&&a.jsxs(Me,{size:"sm",onClick:async()=>{try{const[Y,re]=await Promise.all([J.getCloudSettingDetail(Q[0].setting_id),J.getCloudSettingDetail(Q[1].setting_id)]);ee([Y.setting||{},re.setting||{}]),X(!0)}catch{}},children:[a.jsx(Gg,{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(qn,{className:"w-3 h-3"}),o("profiles.cloudView.lastSynced")," ",g0(e.toISOString(),"system",o)]}),a.jsx("span",{children:o("profiles.cloudView.showingCount",{showing:se.length,total:fe})}),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")]})]})]}),se.length===0?a.jsxs("div",{className:"text-center py-16",children:[a.jsx(ri,{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")}),K&&a.jsx("button",{onClick:V,className:"mt-2 text-sm text-bambu-green hover:text-bambu-green-light",children:o("profiles.cloudView.clearFilters")})]}):a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[a.jsx(HC,{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:["(",se.filter(Y=>Y.type==="filament").length,")"]})]}),a.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[se.filter(Y=>Y.type==="filament").map(Y=>a.jsx(jj,{setting:Y,onClick:()=>ce(Y),onDuplicate:()=>le(Y),compareMode:z,isCompareSelected:Ce(Y)!==void 0,compareIndex:Ce(Y),compareDisabled:z&&!!Q[0]&&Q[0].type!==Y.type,t:o},Y.setting_id)),se.filter(Y=>Y.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(tu,{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:["(",se.filter(Y=>Y.type==="process").length,")"]})]}),a.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[se.filter(Y=>Y.type==="process").map(Y=>a.jsx(jj,{setting:Y,onClick:()=>ce(Y),onDuplicate:()=>le(Y),compareMode:z,isCompareSelected:Ce(Y)!==void 0,compareIndex:Ce(Y),compareDisabled:z&&!!Q[0]&&Q[0].type!==Y.type,t:o},Y.setting_id)),se.filter(Y=>Y.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(Nr,{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:["(",se.filter(Y=>Y.type==="printer").length,")"]})]}),a.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[se.filter(Y=>Y.type==="printer").map(Y=>a.jsx(jj,{setting:Y,onClick:()=>ce(Y),onDuplicate:()=>le(Y),compareMode:z,isCompareSelected:Ce(Y)!==void 0,compareIndex:Ce(Y),compareDisabled:z&&!!Q[0]&&Q[0].type!==Y.type,t:o},Y.setting_id)),se.filter(Y=>Y.type==="printer").length===0&&a.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:o("profiles.cloudView.noPrinterPresets")})]})]})]}),k&&a.jsx(nJe,{setting:k,onClose:()=>P(null),onDeleted:()=>P(null),onDuplicate:()=>le(k),onEdit:()=>Le(k),hasPermission:s,t:o}),(C||B||U||$)&&a.jsx(aJe,{onClose:()=>{j(!1),L(null),D(null),q(null)},initialData:U||B||($?{type:$.type,name:"",base_id:"",setting:$.setting}:void 0),allPresets:t,t:o}),M&&a.jsx(rJe,{onClose:()=>E(!1),onApply:Y=>{q({type:Y.type,setting:Y.settings}),E(!1)},t:o}),H&&Z&&Q[0]&&Q[1]&&a.jsx(rse,{onClose:()=>{X(!1),ee(null)},leftPreset:Z[0],rightPreset:Z[1],leftLabel:Q[0].name,rightLabel:Q[1].name,t:o})]})}function sJe(){const{t}=Dt(),e=Qt(),{showToast:n}=dn(),{hasPermission:r}=jr(),[i,s]=w.useState("cloud"),[o,l]=w.useState(),{data:c,isLoading:d}=Ze({queryKey:["cloudStatus"],queryFn:J.getCloudStatus}),{data:u=[]}=Ze({queryKey:["printers"],queryFn:J.getPrinters}),{data:h,isLoading:f,refetch:p,dataUpdatedAt:x}=Ze({queryKey:["cloudSettings"],queryFn:()=>J.getCloudSettings(),enabled:!!c?.is_authenticated,retry:!1,staleTime:1e3*60*5});w.useEffect(()=>{x&&l(new Date(x))},[x]);const v=st({mutationFn:J.cloudLogout,onSuccess:()=>{e.invalidateQueries({queryKey:["cloudStatus"]}),e.removeQueries({queryKey:["cloudSettings"]}),n(t("profiles.toast.loggedOut"))}}),g=()=>{e.invalidateQueries({queryKey:["cloudStatus"]})};return d?a.jsx("div",{className:"p-4 md:p-8 flex items-center justify-center min-h-[400px]",children:a.jsx(at,{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($b,{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(Vb,{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(qC,{className:"w-4 h-4"}),t("profiles.tabs.kprofiles")]})]}),i==="cloud"&&a.jsxs(a.Fragment,{children:[c?.is_authenticated&&a.jsxs("div",{className:"flex items-center justify-between p-3 mb-6 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-2 h-2 rounded-full bg-bambu-green animate-pulse"}),a.jsxs("span",{className:"text-sm text-bambu-gray",children:[t("profiles.connectedAs")," ",a.jsx("span",{className:"text-white",children:c.email})]})]}),a.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>v.mutate(),disabled:v.isPending||!r("cloud:auth"),title:r("cloud:auth")?void 0:t("profiles.noLogoutPermission"),children:[a.jsx(l3,{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(at,{className:"w-8 h-8 text-bambu-green animate-spin"})}):h?a.jsx(iJe,{settings:h,lastSyncTime:o,onRefresh:()=>p(),isRefreshing:f,printers:u,hasPermission:r,t}):a.jsxs("div",{className:"text-center py-16",children:[a.jsx("p",{className:"text-bambu-gray mb-4",children:t("profiles.failedToLoad")}),a.jsx(Me,{onClick:()=>p(),children:t("profiles.retry")})]}):a.jsx(eJe,{onSuccess:g,t})]}),i==="local"&&a.jsx(JZe,{}),i==="kprofiles"&&a.jsx(XZe,{}),a.jsx(tJe,{})]})}const zy={Droplet:HC,Flame:Tme,Ruler:lpe,Sparkles:hb,Square:Sl,Cable:uhe,Wrench:jf,Calendar:da,Timer:Od,Cog:Qhe,Fan:wX,Zap:ru,Wind:jX,Thermometer:JC,Layers:ri,Box:ei,Target:MX,RefreshCw:Sr,Settings:ZC,Filter:VC,CircleDot:jhe};function l0(t){return t&&zy[t]||jf}function Mg(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 Dj(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 oJe(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"),d=n.includes("H2S"),u=l||c||d,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":u?"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":u?"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":d?"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":u?"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":d?"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 u?"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 u?"https://wiki.bambulab.com/en/h2/maintenance/x-axis-lubrication":null;default:return null}}function lJe({item:t,onPerform:e,onToggle:n,hasPermission:r,t:i}){const s=l0(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))})(),d=()=>t.enabled?t.is_due?"text-red-400":t.is_warning?"text-amber-400":"text-bambu-green":"text-bambu-gray",u=()=>t.enabled?t.is_due?"bg-red-500":t.is_warning?"bg-amber-500":"bg-bambu-green":"bg-bambu-gray/30",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:Mg(Math.abs(p),"days",i)}):t.is_warning?i("maintenance.dueIn",{duration:Mg(p,"days",i)}):i("maintenance.timeLeft",{duration:Mg(p,"days",i)})}else return t.is_due?i("maintenance.overdueBy",{duration:Mg(Math.abs(t.hours_until_due),"hours",i)}):t.is_warning?i("maintenance.dueIn",{duration:Mg(t.hours_until_due,"hours",i)}):i("maintenance.timeLeft",{duration:Mg(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 ${d()}`}),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(da,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"})}),(()=>{const p=t.maintenance_type_wiki_url||oJe(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(ta,{className:"w-3.5 h-3.5"})}):null})()]}),a.jsx("div",{className:"mt-2 mb-1.5",children:a.jsx("div",{className:"w-full h-1.5 bg-bambu-dark rounded-full overflow-hidden",children:a.jsx("div",{className:`h-full rounded-full transition-all duration-500 ${u()}`,style:{width:`${c}%`}})})}),a.jsxs("div",{className:`text-xs flex items-center gap-1 ${d()}`,children:[t.is_due&&a.jsx(An,{className:"w-3 h-3"}),t.is_warning&&!t.is_due&&a.jsx(qn,{className:"w-3 h-3"}),!t.is_due&&!t.is_warning&&t.enabled&&a.jsx(na,{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(Ln,{checked:t.enabled,onChange:p=>n(t.id,p),disabled:!r("maintenance:update")})}),a.jsxs(Me,{size:"sm",variant:t.is_due?"primary":"secondary",onClick:()=>e(t.id),disabled:!t.enabled||!r("maintenance:update"),title:r("maintenance:update")?void 0:i("maintenance.noPermissionPerform"),className:"!px-3",children:[a.jsx(lo,{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,d]=w.useState(!1),[u,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(u);!isNaN(v)&&v>=0&&(r(t.printer_id,v),d(!1))};return a.jsxs(St,{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(An,{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(qn,{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(na,{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(wl,{className:"w-4 h-4"}):a.jsx(Mn,{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(Od,{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:u,onChange:v=>h(v.target.value),onKeyDown:v=>{v.key==="Enter"&&x(),v.key==="Escape"&&d(!1)},className:"w-24 px-2 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm",min:"0",step:"1",autoFocus:!0}),a.jsx("span",{className:"text-xs text-bambu-gray",children:s("common.hours")}),a.jsx(Me,{size:"sm",onClick:x,children:s("common.save")}),a.jsx(Me,{size:"sm",variant:"secondary",onClick:()=>d(!1),children:s("common.cancel")})]}):a.jsxs("button",{onClick:()=>{i("maintenance:update")&&(h(Math.round(t.total_print_hours).toString()),d(!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(Pf,{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=l0(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(Nt,{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(lJe,{item:v,onPerform:e,onToggle:n,hasPermission:i,t:s},v.id))})})]})}function dJe({overview:t,types:e,onUpdateInterval:n,onAddType:r,onUpdateType:i,onDeleteType:s,onRestoreDefaults:o,isRestoringDefaults:l,onAssignType:c,onRemoveItem:d,hasPermission:u,t:h}){const[f,p]=w.useState(null),[x,v]=w.useState(""),[g,y]=w.useState("hours"),[_,N]=w.useState(!1),[A,k]=w.useState(""),[P,C]=w.useState("100"),[j,M]=w.useState("hours"),[E,B]=w.useState("Wrench"),[L,U]=w.useState(""),[D,$]=w.useState(new Set),[q,z]=w.useState(null),[W,Q]=w.useState(null),te=w.useMemo(()=>t?t.map(O=>({id:O.printer_id,name:O.printer_name})):[],[t]),H=O=>t?t.filter(R=>R.maintenance_items.some(G=>G.maintenance_type_id===O)).map(R=>({printerId:R.printer_id,printerName:R.printer_name,itemId:R.maintenance_items.find(G=>G.maintenance_type_id===O)?.id})):[],X=O=>{if(!t)return[];const R=new Set(H(O).map(G=>G.printerId));return te.filter(G=>!R.has(G.id))},[Z,ee]=w.useState(null),[Se,oe]=w.useState(""),[ie,me]=w.useState(""),[se,ce]=w.useState("hours"),[Ce,le]=w.useState("Wrench"),[Le,V]=w.useState(""),K=O=>{ee(O),oe(O.name),me(O.default_interval_hours.toString()),ce(O.interval_type||"hours"),le(O.icon||"Wrench"),V(O.wiki_url||"")},fe=()=>{Z&&Se.trim()&&parseFloat(ie)>0&&(i(Z.id,{name:Se.trim(),default_interval_hours:parseFloat(ie),interval_type:se,icon:Ce,wiki_url:Le.trim()||null}),ee(null))},Y=(O,R,G)=>{const de=parseFloat(x);if(!isNaN(de)&&de>0){const ge=Math.abs(de-R)<.01?null:de;n(O,{custom_interval_hours:ge,custom_interval_type:g!==G?g:null})}p(null)},re=O=>{O.preventDefault(),A.trim()&&parseFloat(P)>0&&D.size>0&&(r({name:A.trim(),default_interval_hours:parseFloat(P),interval_type:j,icon:E,wiki_url:L.trim()||null},Array.from(D)),k(""),C("100"),M("hours"),U(""),$(new Set),N(!1))},ue=O=>{$(R=>{const G=new Set(R);return G.has(O)?G.delete(O):G.add(O),G})},Fe=t?.map(O=>({printerId:O.printer_id,printerName:O.printer_name,items:O.maintenance_items.sort((R,G)=>R.maintenance_type_id-G.maintenance_type_id)})).sort((O,R)=>O.printerName.localeCompare(R.printerName))||[],Pe=e.filter(O=>O.is_system),be=e.filter(O=>!O.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(Me,{variant:"secondary",onClick:o,disabled:!u("maintenance:delete")||l,title:u("maintenance:delete")?void 0:h("maintenance.noPermissionDeleteTypes"),children:h("maintenance.restoreDefaults")}),a.jsxs(Me,{onClick:()=>N(!_),disabled:!u("maintenance:create"),title:u("maintenance:create")?void 0:h("maintenance.noPermissionEditTypes"),children:[a.jsx(Xn,{className:"w-4 h-4"}),h("maintenance.addCustomType")]})]})]}),_&&a.jsx(St,{className:"mb-6",children:a.jsx(Nt,{className:"py-4",children:a.jsxs("form",{onSubmit:re,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:O=>k(O.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:j,onChange:O=>{M(O.target.value),O.target.value==="days"?C("30"):C("100")},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"hours",children: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:j==="days"?h("maintenance.calendarDays").toLowerCase():h("common.hours")})}),a.jsx("input",{type:"number",value:P,onChange:O=>C(O.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(zy).map(O=>{const R=zy[O];return a.jsx("button",{type:"button",onClick:()=>B(O),className:`p-2 rounded-lg transition-colors ${E===O?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:a.jsx(R,{className:"w-4 h-4"})},O)})})]})}),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:L,onChange:O=>U(O.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:te.map(O=>a.jsx("button",{type:"button",onClick:()=>ue(O.id),className:`px-3 py-1.5 rounded-lg text-sm transition-colors ${D.has(O.id)?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:O.name},O.id))}),D.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(Me,{type:"button",variant:"secondary",onClick:()=>{N(!1),$(new Set)},children:h("common.cancel")}),a.jsx(Me,{type:"submit",disabled:!A.trim()||D.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:[Pe.map(O=>{const R=l0(O.icon),G=O.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(R,{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:O.name}),a.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5 flex items-center gap-1",children:[G==="days"?a.jsx(da,{className:"w-3 h-3"}):a.jsx(Od,{className:"w-3 h-3"}),Dj(O.default_interval_hours,G,h)]})]}),a.jsx("button",{onClick:()=>{u("maintenance:delete")&&Q(O)},disabled:!u("maintenance:delete"),title:u("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 ${u("maintenance:delete")?"":"opacity-50 cursor-not-allowed"}`,children:a.jsx(Yt,{className:"w-4 h-4"})})]})},O.id)}),be.map(O=>{const R=l0(O.icon),G=O.interval_type||"hours";if(Z?.id===O.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:Se,onChange:ze=>oe(ze.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:se,onChange:ze=>ce(ze.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:ie,onChange:ze=>me(ze.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(zy).map(ze=>{const $e=zy[ze];return a.jsx("button",{type:"button",onClick:()=>le(ze),className:`p-1.5 rounded transition-colors ${Ce===ze?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:a.jsx($e,{className:"w-3.5 h-3.5"})},ze)})}),a.jsx("input",{type:"url",value:Le,onChange:ze=>V(ze.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(Me,{size:"sm",onClick:fe,disabled:!Se.trim(),children:h("common.save")}),a.jsx(Me,{size:"sm",variant:"secondary",onClick:()=>ee(null),children:h("common.cancel")})]})]})},O.id);const ge=H(O.id),ae=X(O.id),Ue=q===O.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(R,{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:O.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:[G==="days"?a.jsx(da,{className:"w-3 h-3"}):a.jsx(Od,{className:"w-3 h-3"}),Dj(O.default_interval_hours,G,h)]})]}),a.jsxs("button",{onClick:()=>z(Ue?null:O.id),className:`px-2 py-1 rounded-lg border transition-colors flex items-center gap-1 ${ge.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:ge.length}),children:[a.jsx(Nr,{className:"w-3 h-3"}),a.jsx("span",{className:"text-xs font-medium",children:ge.length}),a.jsx(Mn,{className:`w-3 h-3 transition-transform ${Ue?"rotate-180":""}`})]}),a.jsx("button",{onClick:()=>K(O),disabled:!u("maintenance:update"),title:u("maintenance:update")?void 0:h("maintenance.noPermissionEditTypes"),className:`p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors ${u("maintenance:update")?"":"opacity-50 cursor-not-allowed"}`,children:a.jsx(Pf,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>{confirm(h("maintenance.deleteTypeConfirm",{name:O.name}))&&s(O.id)},disabled:!u("maintenance:delete"),title:u("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 ${u("maintenance:delete")?"":"opacity-50 cursor-not-allowed"}`,children:a.jsx(Yt,{className:"w-4 h-4"})})]}),Ue&&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")}),ge.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:ge.map(ze=>a.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-dark rounded text-xs text-white",children:[ze.printerName,a.jsx("button",{onClick:()=>ze.itemId&&d(ze.itemId),disabled:!u("maintenance:delete"),title:u("maintenance:delete")?h("maintenance.removeFromPrinter"):h("maintenance.noPermissionRemovePrinter"),className:`ml-1 ${u("maintenance:delete")?"hover:text-red-400":"opacity-50 cursor-not-allowed"}`,children:"×"})]},ze.printerId))}),ae.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")}),ae.map(ze=>a.jsxs("button",{onClick:()=>c(ze.id,O.id),disabled:!u("maintenance:create"),title:u("maintenance:create")?void 0:h("maintenance.noPermissionAssignPrinter"),className:`px-2 py-1 bg-bambu-dark rounded text-xs transition-colors ${u("maintenance:create")?"hover:bg-bambu-green/20 text-bambu-gray hover:text-bambu-green":"opacity-50 cursor-not-allowed text-bambu-gray"}`,children:["+ ",ze.name]},ze.id))]})]})]},O.id)})]})]}),Fe.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:Fe.map(O=>a.jsx(St,{children:a.jsxs(Nt,{className:"py-4",children:[a.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:O.printerName}),a.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-2",children:O.items.map(R=>{const G=l0(R.maintenance_type_icon),de=e.find($e=>$e.id===R.maintenance_type_id),ge=de?.default_interval_hours||R.interval_hours,ae=de?.interval_type||"hours",Ue=R.interval_type||"hours",ze=f===R.id;return a.jsxs("div",{className:"flex items-center gap-2 p-2.5 bg-bambu-dark rounded-lg",children:[a.jsx(G,{className:"w-4 h-4 text-bambu-gray shrink-0"}),a.jsx("span",{className:"text-xs text-bambu-gray flex-1 truncate",children:R.maintenance_type_name}),ze?a.jsxs("div",{className:"flex items-center gap-1",children:[g==="days"?a.jsx(da,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"}):a.jsx(Od,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"}),a.jsxs("select",{value:g,onChange:$e=>y($e.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:$e=>v($e.target.value),onKeyDown:$e=>{$e.key==="Enter"&&Y(R.id,ge,ae),$e.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(Me,{size:"sm",onClick:()=>Y(R.id,ge,ae),children:"OK"})]}):a.jsxs("button",{onClick:()=>{u("maintenance:update")&&(p(R.id),v(R.interval_hours.toString()),y(Ue))},disabled:!u("maintenance:update"),title:u("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 ${u("maintenance:update")?"hover:bg-bambu-dark-secondary hover:border-bambu-green":"opacity-50 cursor-not-allowed"}`,children:[Ue==="days"?a.jsx(da,{className:"w-3 h-3"}):a.jsx(Od,{className:"w-3 h-3"}),Dj(R.interval_hours,Ue,h),a.jsx(Pf,{className:"w-3 h-3 text-bambu-gray"})]})]},R.id)})})]})},O.printerId))})]}),Fe.length===0&&a.jsx(St,{children:a.jsxs(Nt,{className:"text-center py-12",children:[a.jsx(qn,{className:"w-12 h-12 mx-auto mb-4 text-bambu-gray/30"}),a.jsx("p",{className:"text-bambu-gray",children:h("common.noPrinters")}),a.jsx("p",{className:"text-sm text-bambu-gray/70 mt-1",children:h("maintenance.intervalOverridesDescription")})]})}),W&&a.jsx(xn,{title:h("maintenance.deleteSystemTypeTitle"),message:h("maintenance.deleteSystemTypeMessage",{name:W.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(W.id),Q(null)},onCancel:()=>Q(null)})]})}function uJe(){const{t}=Dt(),e=Qt(),{showToast:n}=dn(),{hasPermission:r}=jr(),[i,s]=w.useState("status"),{data:o,isLoading:l}=Ze({queryKey:["maintenanceOverview"],queryFn:J.getMaintenanceOverview}),{data:c}=Ze({queryKey:["maintenanceTypes"],queryFn:J.getMaintenanceTypes}),d=st({mutationFn:({id:P,notes:C})=>J.performMaintenance(P,C),onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceOverview"]}),e.invalidateQueries({queryKey:["maintenanceSummary"]}),n(t("maintenance.maintenanceComplete"))},onError:P=>{n(P.message,"error")}}),u=st({mutationFn:({id:P,data:C})=>J.updateMaintenanceItem(P,C),onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceOverview"]})},onError:P=>{n(P.message,"error")}}),h=st({mutationFn:({id:P,data:C})=>J.updateMaintenanceType(P,C),onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceTypes"]}),e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.typeUpdated"))},onError:P=>{n(P.message,"error")}}),f=st({mutationFn:J.deleteMaintenanceType,onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceTypes"]}),e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.typeDeleted"))},onError:P=>{n(P.message,"error")}}),p=st({mutationFn:J.restoreDefaultMaintenanceTypes,onSuccess:P=>{e.invalidateQueries({queryKey:["maintenanceTypes"]}),e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.defaultsRestored",{count:P.restored}))},onError:P=>{n(P.message,"error")}}),x=st({mutationFn:({printerId:P,hours:C})=>J.setPrinterHours(P,C),onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceOverview"]}),e.invalidateQueries({queryKey:["maintenanceSummary"]}),n(t("maintenance.printHoursUpdated"))},onError:P=>{n(P.message,"error")}}),v=st({mutationFn:({printerId:P,typeId:C})=>J.assignMaintenanceType(P,C),onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.printerAssigned"))},onError:P=>{n(P.message,"error")}}),g=st({mutationFn:J.removeMaintenanceItem,onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.printerRemoved"))},onError:P=>{n(P.message,"error")}}),y=P=>{d.mutate({id:P})},_=(P,C)=>{u.mutate({id:P,data:{enabled:C}})},N=(P,C)=>{x.mutate({printerId:P,hours:C})};if(l)return a.jsx("div",{className:"p-4 md:p-8 flex justify-center",children:a.jsx(at,{className:"w-8 h-8 text-bambu-green animate-spin"})});const A=o?.reduce((P,C)=>P+C.due_count,0)||0,k=o?.reduce((P,C)=>P+C.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&&k>0&&" · ",k>0&&a.jsx("span",{className:"text-amber-400",children:t("maintenance.warningCount",{count:k})}),A===0&&k===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((P,C)=>{const j=P.due_count*10+P.warning_count,M=C.due_count*10+C.warning_count;return j!==M?M-j:P.printer_name.localeCompare(C.printer_name)}).map(P=>a.jsx(cJe,{overview:P,onPerform:y,onToggle:_,onSetHours:N,hasPermission:r,t},P.printer_id)):a.jsx(St,{children:a.jsxs(Nt,{className:"text-center py-16",children:[a.jsx(jf,{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(dJe,{overview:o,types:c||[],onUpdateInterval:(P,C)=>u.mutate({id:P,data:C}),onAddType:async(P,C)=>{const j=await J.createMaintenanceType(P);for(const M of C)await J.assignMaintenanceType(M,j.id);e.invalidateQueries({queryKey:["maintenanceTypes"]}),e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.typeUpdated"))},onUpdateType:(P,C)=>h.mutate({id:P,data:C}),onDeleteType:P=>f.mutate(P),onRestoreDefaults:()=>p.mutate(),isRestoringDefaults:p.isPending,onAssignType:(P,C)=>v.mutate({printerId:P,typeId:C}),onRemoveItem:P=>g.mutate(P),hasPermission:r,t})]})}const cK=["#ef4444","#f97316","#eab308","#22c55e","#06b6d4","#3b82f6","#8b5cf6","#ec4899","#6b7280"];function ase({project:t,onClose:e,onSave:n,isLoading:r,t:i}){const[s,o]=w.useState(t?.name||""),[l,c]=w.useState(t?.description||""),[d,u]=w.useState(t?.color||cK[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]||""),[k,P]=w.useState(t?.priority||"normal"),C=j=>{j.preventDefault(),n({name:s.trim(),description:l.trim()||void 0,color:d,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:k,...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: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:i("common.name")}),a.jsx("input",{type:"text",value:s,onChange:j=>o(j.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:j=>c(j.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:cK.map(j=>a.jsx("button",{type:"button",onClick:()=>u(j),className:`w-8 h-8 rounded-full transition-transform ${d===j?"ring-2 ring-white ring-offset-2 ring-offset-bambu-dark-secondary scale-110":""}`,style:{backgroundColor:j}},j))})]}),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:j=>f(j.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:j=>x(j.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:j=>_(j.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:j=>A(j.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:k,onChange:j=>P(j.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:j=>g(j.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white focus:outline-none focus:border-bambu-green",children:[a.jsx("option",{value:"active",children:i("projects.statusActive")}),a.jsx("option",{value:"completed",children:i("projects.statusCompleted")}),a.jsx("option",{value:"archived",children:i("projects.statusArchived")})]})]}),a.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[a.jsx(Me,{type:"button",variant:"secondary",onClick:e,children:i("common.cancel")}),a.jsx(Me,{type:"submit",disabled:!s.trim()||r,children:r?a.jsx(at,{className:"w-4 h-4 animate-spin"}):i(t?"common.save":"projects.create")})]})]})]})})}function hJe({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",d=t.status==="archived",[u,h]=w.useState(!1),p=c?{icon:ub,color:"text-bambu-green",bg:"bg-bambu-green/10"}:d?{icon:Ds,color:"text-bambu-gray",bg:"bg-bambu-gray/10"}:t.queue_count>0?{icon:qn,color:"text-blue-400",bg:"bg-blue-400/10"}:{icon: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")}),d&&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(!u),children:a.jsx(Mh,{className:"w-4 h-4"})}),u&&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(Pf,{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(Yt,{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(Ds,{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(An,{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(qn,{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:J.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(fi,{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(An,{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(ri,{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(fi,{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(An,{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(o3,{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 mJe(){const{t}=Dt(),e=ac(),n=Qt(),{showToast:r}=dn(),{hasPermission:i}=jr(),[s,o]=w.useState(!1),[l,c]=w.useState(),[d,u]=w.useState("active"),[h,f]=w.useState(null),{data:p,isLoading:x}=Ze({queryKey:["projects",d==="all"?void 0:d],queryFn:()=>J.getProjects(d==="all"?void 0:d)}),v=st({mutationFn:U=>J.createProject(U),onSuccess:()=>{n.invalidateQueries({queryKey:["projects"]}),o(!1),r(t("projects.toast.created"),"success")},onError:U=>{r(U.message,"error")}}),g=st({mutationFn:({id:U,data:D})=>J.updateProject(U,D),onSuccess:()=>{n.invalidateQueries({queryKey:["projects"]}),o(!1),c(void 0),r(t("projects.toast.updated"),"success")},onError:U=>{r(U.message,"error")}}),y=st({mutationFn:U=>J.deleteProject(U),onSuccess:()=>{f(null),r(t("projects.toast.deleted"),"success"),setTimeout(()=>window.location.reload(),100)},onError:U=>{f(null),r(U.message,"error")}}),_=st({mutationFn:U=>J.importProject(U),onSuccess:()=>{n.invalidateQueries({queryKey:["projects"]}),r(t("projects.toast.imported"),"success")},onError:U=>{r(U.message,"error")}}),N=w.useRef(null),A=async()=>{try{const U=await J.getProjects(),D=await Promise.all(U.map(async W=>await J.exportProjectJson(W.id))),$=new Blob([JSON.stringify(D,null,2)],{type:"application/json"}),q=URL.createObjectURL($),z=document.createElement("a");z.href=q,z.download=`bambuddy_projects_${new Date().toISOString().split("T")[0]}.json`,z.click(),URL.revokeObjectURL(q),r(t("projects.toast.exported"),"success")}catch(U){r(U.message,"error")}},k=()=>{N.current?.click()},P=async U=>{const D=U.target.files?.[0];if(D){try{if(D.name.toLowerCase().endsWith(".zip"))await J.importProjectFile(D),n.invalidateQueries({queryKey:["projects"]}),r(t("projects.toast.imported"),"success");else{const q=await D.text(),z=JSON.parse(q),W=Array.isArray(z)?z:[z];for(const Q of W)await _.mutateAsync(Q);W.length>1&&r(t("projects.toast.multipleImported",{count:W.length}),"success")}}catch($){r(`${t("projects.toast.importFailed")}: ${$.message}`,"error")}U.target.value=""}},C=U=>{l?g.mutate({id:l.id,data:U}):v.mutate(U)},j=U=>{c(U),o(!0)},M=U=>{e(`/projects/${U.id}`)},E=U=>{f(U)},B=()=>{h!==null&&y.mutate(h)},L=p?.reduce((U,D)=>(U[D.status]=(U[D.status]||0)+1,U.all=(U.all||0)+1,U),{})||{};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:P,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(Me,{variant:"secondary",onClick:k,disabled:!i("projects:create"),title:i("projects:create")?t("projects.importProject"):t("projects.noImportPermission"),children:[a.jsx(Oa,{className:"w-4 h-4 mr-2"}),t("projects.import")]}),a.jsxs(Me,{variant:"secondary",onClick:A,disabled:!i("projects:read"),title:i("projects:read")?t("projects.exportAll"):t("projects.noExportPermission"),children:[a.jsx(ga,{className:"w-4 h-4 mr-2"}),t("projects.export")]}),a.jsxs(Me,{onClick:()=>o(!0),className:"sm:w-auto w-full",disabled:!i("projects:create"),title:i("projects:create")?void 0:t("projects.noCreatePermission"),children:[a.jsx(Xn,{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:qn},{key:"completed",label:t("projects.statusCompleted"),icon:ub},{key:"archived",label:t("projects.statusArchived"),icon:Ds},{key:"all",label:t("common.all"),icon:xs}].map(({key:U,label:D,icon:$})=>a.jsxs("button",{onClick:()=>u(U),className:`flex items-center gap-2 px-4 py-2 text-sm rounded-lg transition-all ${d===U?"bg-bambu-card text-white shadow-sm":"text-bambu-gray hover:text-white"}`,children:[a.jsx($,{className:"w-4 h-4"}),a.jsx("span",{children:D}),L[U]>0&&a.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded-full ${d===U?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark-tertiary"}`,children:L[U]})]},U))}),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(at,{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:d==="all"?t("projects.noProjects"):t("projects.noProjectsFiltered",{status:d})}),a.jsx("p",{className:"text-bambu-gray text-center max-w-md mb-6",children:d==="all"?t("projects.createFirst"):t("projects.noProjectsFilteredHelp",{status:d})}),d==="all"&&a.jsxs(Me,{onClick:()=>o(!0),disabled:!i("projects:create"),title:i("projects:create")?void 0:t("projects.noCreatePermission"),children:[a.jsx(Xn,{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(U=>a.jsx(hJe,{project:U,onClick:()=>M(U),onEdit:()=>j(U),onDelete:()=>E(U.id),hasPermission:i,t},U.id))}),h!==null&&a.jsx(xn,{title:t("projects.deleteProject"),message:t("projects.deleteConfirm"),confirmText:t("projects.deleteProject"),variant:"danger",onConfirm:B,onCancel:()=>f(null)}),s&&a.jsx(ase,{project:l,onClose:()=>{o(!1),c(void 0)},onSave:C,isLoading:v.isPending||g.isPending,t})]})}function fJe(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 pJe(t){return t>=1e3?`${(t/1e3).toFixed(2)}kg`:`${Math.round(t)}g`}function gJe({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 dK({icon:t,label:e,value:n,subValue:r,hint:i,color:s="text-bambu-gray"}){return a.jsx(St,{children:a.jsx(Nt,{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 bJe({archives:t,t:e}){return t.length===0?a.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[a.jsx(fi,{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(Ys,{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:J.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(fi,{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(mi,{className:"w-8 h-8 text-white"})}),n.status==="completed"&&a.jsx("div",{className:"absolute top-1 right-1",children:a.jsx(yr,{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 xJe({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(An,{className:"w-3 h-3"}),i]})}function yJe(t){return t?mb(t,{year:"numeric",month:"short",day:"numeric"}):""}function Rj(t,e){if(!t)return null;const n=tr(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 vJe(){const{id:t}=sv(),e=ac(),{t:n}=Dt(),r=Qt(),{showToast:i}=dn(),{hasPermission:s}=jr(),[o,l]=w.useState(!1),[c,d]=w.useState(!1),[u,h]=w.useState(""),f=parseInt(t||"0",10),{data:p,isLoading:x,error:v}=Ze({queryKey:["project",f],queryFn:()=>J.getProject(f),enabled:f>0}),{data:g,isLoading:y}=Ze({queryKey:["project-archives",f],queryFn:()=>J.getProjectArchives(f),enabled:f>0}),{data:_,isLoading:N}=Ze({queryKey:["project-bom",f],queryFn:()=>J.getProjectBOM(f),enabled:f>0}),{data:A,isLoading:k}=Ze({queryKey:["project-timeline",f],queryFn:()=>J.getProjectTimeline(f,20),enabled:f>0}),{data:P}=Ze({queryKey:["settings"],queryFn:J.getSettings}),{data:C}=Ze({queryKey:["project-folders",f],queryFn:()=>J.getLibraryFoldersByProject(f),enabled:f>0}),j=il(P?.currency||"USD"),M=P?.time_format||"system",E=st({mutationFn:we=>J.updateProject(f,we),onSuccess:()=>{r.invalidateQueries({queryKey:["project",f]}),r.invalidateQueries({queryKey:["projects"]}),l(!1),d(!1),i(n("projectDetail.toast.projectUpdated"),"success")},onError:we=>{i(we.message,"error")}}),B=()=>{h(p?.notes||""),d(!0)},L=()=>{E.mutate({notes:u})},U=()=>{d(!1),h("")},[D,$]=w.useState(""),[q,z]=w.useState(1),[W,Q]=w.useState(""),[te,H]=w.useState(""),[X,Z]=w.useState(""),[ee,Se]=w.useState(!1),[oe,ie]=w.useState(!1),[me,se]=w.useState(null),[ce,Ce]=w.useState(""),[le,Le]=w.useState(1),[V,K]=w.useState(""),[fe,Y]=w.useState(""),[re,ue]=w.useState(""),[Fe,Pe]=w.useState({isOpen:!1,title:"",message:"",onConfirm:()=>{}}),be=st({mutationFn:we=>J.createBOMItem(f,we),onSuccess:()=>{r.invalidateQueries({queryKey:["project-bom",f]}),r.invalidateQueries({queryKey:["project",f]}),$(""),z(1),Q(""),H(""),Z(""),Se(!1),i(n("projectDetail.toast.partAdded"),"success")},onError:we=>i(we.message,"error")}),O=st({mutationFn:({itemId:we,data:qe})=>J.updateBOMItem(f,we,qe),onSuccess:()=>{r.invalidateQueries({queryKey:["project-bom",f]}),r.invalidateQueries({queryKey:["project",f]}),se(null)},onError:we=>i(we.message,"error")}),R=st({mutationFn:we=>J.deleteBOMItem(f,we),onSuccess:()=>{r.invalidateQueries({queryKey:["project-bom",f]}),r.invalidateQueries({queryKey:["project",f]}),i(n("projectDetail.toast.partRemoved"),"success")},onError:we=>i(we.message,"error")}),G=we=>{we.preventDefault(),D.trim()&&be.mutate({name:D.trim(),quantity_needed:q,unit_price:W?parseFloat(W):void 0,sourcing_url:te.trim()||void 0,remarks:X.trim()||void 0})},de=we=>{const qe=we.is_complete?0:we.quantity_needed;O.mutate({itemId:we.id,data:{quantity_acquired:qe}})},ge=(we,qe)=>{Pe({isOpen:!0,title:n("projectDetail.bom.deletePart"),message:n("projectDetail.bom.deleteConfirm",{name:qe}),onConfirm:()=>{Pe(ke=>({...ke,isOpen:!1})),R.mutate(we)}})},ae=we=>{se(we),Ce(we.name),Le(we.quantity_needed),K(we.unit_price?.toString()||""),Y(we.sourcing_url||""),ue(we.remarks||"")},Ue=we=>{we.preventDefault(),!(!me||!ce.trim())&&O.mutate({itemId:me.id,data:{name:ce.trim(),quantity_needed:le,unit_price:V?parseFloat(V):void 0,sourcing_url:fe.trim()||void 0,remarks:re.trim()||void 0}})},ze=()=>{se(null)},$e=async()=>{try{const{blob:we,filename:qe}=await J.exportProjectZip(Number(f)),ke=URL.createObjectURL(we),nt=document.createElement("a");nt.href=ke,nt.download=qe||`${p?.name||"project"}_${new Date().toISOString().split("T")[0]}.zip`,nt.click(),URL.revokeObjectURL(ke),i(n("projectDetail.toast.projectExported"),"success")}catch(we){i(we.message,"error")}},Re=st({mutationFn:()=>J.createTemplateFromProject(f),onSuccess:()=>{r.invalidateQueries({queryKey:["projects"]}),i(n("projectDetail.toast.templateCreated"),"success")},onError:we=>i(we.message,"error")}),pe=we=>Df(we,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(at,{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(Me,{variant:"secondary",className:"mt-4",onClick:()=>e("/projects"),children:n("projectDetail.backToProjects")})]});const ve=p.stats,Ne=ve?.progress_percent??0,xe=ve?.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(Ys,{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(gX,{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(gJe,{status:p.status,t:n})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs(Me,{variant:"secondary",onClick:$e,disabled:!s("projects:read"),title:s("projects:read")?n("projectDetail.exportProject"):n("projectDetail.noExportPermission"),children:[a.jsx(ga,{className:"w-4 h-4 mr-2"}),n("projectDetail.export")]}),a.jsxs(Me,{onClick:()=>l(!0),disabled:!s("projects:update"),title:s("projects:update")?void 0:n("projectDetail.noEditPermission"),children:[a.jsx(Pf,{className:"w-4 h-4 mr-2"}),n("common.edit")]})]})]}),(p.target_count||p.target_parts_count)&&a.jsx(St,{children:a.jsxs(Nt,{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:[ve?.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(Ne,100)}%`,backgroundColor:Ne>=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:Ne.toFixed(0)})}),ve?.remaining_prints!=null&&ve.remaining_prints>0&&a.jsx("span",{className:"text-xs text-bambu-gray/70",children:n("projectDetail.progress.remaining",{count:ve.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:[ve?.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(xe,100)}%`,backgroundColor:xe>=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:xe.toFixed(0)})}),ve?.remaining_parts!=null&&ve.remaining_parts>0&&a.jsx("span",{className:"text-xs text-bambu-gray/70",children:n("projectDetail.progress.remaining",{count:ve.remaining_parts})})]})]})]})}),ve&&a.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[a.jsx(St,{children:a.jsx(Nt,{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(fi,{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:[ve.total_archives," ",a.jsx("span",{className:"text-sm font-normal text-bambu-gray",children:n("projectDetail.stats.total")})]}),ve.failed_prints>0&&a.jsx("p",{className:"text-sm text-status-error",children:n("projectDetail.stats.failed",{count:ve.failed_prints})}),a.jsx("p",{className:"text-sm text-bambu-gray",children:n("projectDetail.stats.partsPrinted",{count:ve.completed_prints})})]})]})})}),a.jsx(dK,{icon:qn,label:n("projectDetail.stats.printTime"),value:fJe(ve.total_print_time_hours),color:"text-yellow-400"}),a.jsx(dK,{icon:Nr,label:n("projectDetail.stats.filamentUsed"),value:pJe(ve.total_filament_grams),color:"text-purple-400"})]}),ve&&(ve.estimated_cost>0||p.budget)&&a.jsx(St,{children:a.jsxs(Nt,{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:[j,ve.estimated_cost.toFixed(2)]})]}),ve.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:[ve.total_energy_kwh.toFixed(3)," kWh",ve.total_energy_cost>0&&a.jsxs("span",{className:"text-sm text-bambu-gray ml-1",children:["(",j,ve.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:[j,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-ve.estimated_cost>=0?"text-bambu-green":"text-red-400"}`,children:[j,(p.budget-ve.estimated_cost).toFixed(2)]})]})]})]})]})}),p.children&&p.children.length>0&&a.jsx(St,{children:a.jsxs(Nt,{className:"p-4",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2 mb-3",children:[a.jsx(Rme,{className:"w-5 h-5"}),n("projectDetail.subProjects.title",{count:p.children.length})]}),a.jsx("div",{className:"space-y-2",children:p.children.map(we=>a.jsxs(Ys,{to:`/projects/${we.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:we.color||"#6b7280"}}),a.jsx("span",{className:"text-white",children:we.name}),a.jsx("span",{className:`text-xs px-2 py-0.5 rounded ${we.status==="completed"?"bg-status-ok/20 text-status-ok":we.status==="archived"?"bg-bambu-gray/20 text-bambu-gray":"bg-blue-500/20 text-blue-400"}`,children:we.status})]}),we.progress_percent!==null&&a.jsxs("span",{className:"text-sm text-bambu-gray",children:[we.progress_percent.toFixed(0),"%"]})]},we.id))})]})}),p.parent_id&&p.parent_name&&a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx(ri,{className:"w-4 h-4 text-bambu-gray"}),a.jsx("span",{className:"text-bambu-gray",children:n("projectDetail.partOf")}),a.jsx(Ys,{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(xJe,{priority:p.priority,t:n})]}),p.due_date&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(da,{className:"w-4 h-4 text-bambu-gray"}),a.jsx("span",{className:"text-sm text-white",children:yJe(p.due_date)}),Rj(p.due_date,n)&&a.jsxs("span",{className:`text-xs ${Rj(p.due_date,n).color}`,children:["(",Rj(p.due_date,n).label,")"]})]}),p.tags&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(qh,{className:"w-4 h-4 text-bambu-gray"}),a.jsx("div",{className:"flex flex-wrap gap-1",children:p.tags.split(",").map((we,qe)=>a.jsx("span",{className:"px-2 py-0.5 bg-bambu-dark-tertiary text-bambu-gray text-xs rounded",children:we.trim()},qe))})]})]}),a.jsx(St,{children:a.jsxs(Nt,{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(Ps,{className:"w-5 h-5"}),n("projectDetail.notes.title")]}),c?a.jsxs("div",{className:"flex gap-2",children:[a.jsxs(Me,{variant:"secondary",size:"sm",onClick:U,disabled:E.isPending,children:[a.jsx(Rt,{className:"w-4 h-4 mr-1"}),n("common.cancel")]}),a.jsxs(Me,{size:"sm",onClick:L,disabled:E.isPending,children:[E.isPending?a.jsx(at,{className:"w-4 h-4 animate-spin mr-1"}):a.jsx(bs,{className:"w-4 h-4 mr-1"}),n("common.save")]})]}):a.jsxs(Me,{variant:"secondary",size:"sm",onClick:B,disabled:!s("projects:update"),title:s("projects:update")?void 0:n("projectDetail.notes.noEditPermission"),children:[a.jsx(Pf,{className:"w-4 h-4 mr-1"}),n("common.edit")]})]}),c?a.jsx(JR,{content:u,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(St,{children:a.jsxs(Nt,{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(Jl,{className:"w-5 h-5"}),n("projectDetail.files.title")]})}),a.jsxs("p",{className:"text-xs text-bambu-gray mb-3",children:[a.jsx(Ys,{to:"/files",className:"text-bambu-green hover:underline",children:n("projectDetail.files.linkFolders")})," ",n("projectDetail.files.forQuickAccess")]}),C&&C.length>0?a.jsx("div",{className:"space-y-2",children:C.map(we=>a.jsxs(Ys,{to:`/files?folder=${we.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(Jl,{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:we.name}),a.jsx("p",{className:"text-xs text-bambu-gray",children:n("projectDetail.files.fileCount",{count:we.file_count})})]})]}),a.jsx(pi,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"})]},we.id))}):a.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:n("projectDetail.files.empty")})]})}),a.jsx(St,{children:a.jsxs(Nt,{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(AX,{className:"w-5 h-5"}),n("projectDetail.bom.title"),ve&&ve.bom_total_items>0&&a.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",n("projectDetail.bom.acquired",{completed:ve.bom_completed_items,total:ve.bom_total_items}),")"]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[_&&_.some(we=>we.is_complete)&&a.jsx("button",{onClick:()=>ie(!oe),className:`text-xs px-2 py-1 rounded transition-colors ${oe?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:n(oe?"projectDetail.bom.showAll":"projectDetail.bom.hideDone")}),!ee&&a.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>Se(!0),disabled:!s("projects:update"),title:s("projects:update")?void 0:n("projectDetail.bom.noAddPermission"),children:[a.jsx(Xn,{className:"w-4 h-4 mr-1"}),n("projectDetail.bom.addPart")]})]})]}),ee&&a.jsxs("form",{onSubmit:G,className:"bg-bambu-dark rounded-lg p-4 mb-4 space-y-3",children:[a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[a.jsx("input",{type:"text",value:D,onChange:we=>$(we.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:q,onChange:we=>z(parseInt(we.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:W,onChange:we=>Q(we.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:j})})]})]}),a.jsx("input",{type:"url",value:te,onChange:we=>H(we.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:X,onChange:we=>Z(we.target.value),className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:n("projectDetail.bom.remarksPlaceholder")}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(Me,{type:"button",variant:"secondary",size:"sm",onClick:()=>Se(!1),children:n("common.cancel")}),a.jsx(Me,{type:"submit",size:"sm",disabled:!D.trim()||be.isPending,children:be.isPending?a.jsx(at,{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(at,{className:"w-6 h-6 animate-spin text-bambu-green"})}):_&&_.length>0?a.jsxs("div",{className:"space-y-2",children:[_.filter(we=>!oe||!we.is_complete).map(we=>a.jsx("div",{className:`p-3 rounded-lg transition-colors ${we.is_complete?"bg-status-ok/10":"bg-bambu-dark"}`,children:me?.id===we.id?a.jsxs("form",{onSubmit:Ue,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:ce,onChange:qe=>Ce(qe.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:le,onChange:qe=>Le(parseInt(qe.target.value)||1),className:"w-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white focus:outline-none focus:border-bambu-green",min:"1",placeholder:n("projectDetail.bom.qty")}),a.jsx("input",{type:"number",step:"0.01",value:V,onChange:qe=>K(qe.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:j})})]})]}),a.jsx("input",{type:"url",value:fe,onChange:qe=>Y(qe.target.value),className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:n("projectDetail.bom.sourcingUrlPlaceholder")}),a.jsx("input",{type:"text",value:re,onChange:qe=>ue(qe.target.value),className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:n("projectDetail.bom.remarksPlaceholder")}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(Me,{type:"button",variant:"secondary",size:"sm",onClick:ze,children:n("common.cancel")}),a.jsx(Me,{type:"submit",size:"sm",disabled:!ce.trim()||O.isPending,children:O.isPending?a.jsx(at,{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")&&de(we),disabled:O.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 ${we.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:we.is_complete&&a.jsx(yr,{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 ${we.is_complete?"text-bambu-gray line-through":"text-white"}`,children:[we.name,a.jsxs("span",{className:"text-bambu-gray font-normal ml-2",children:["x",we.quantity_needed]})]}),we.unit_price!==null&&a.jsxs("span",{className:"text-xs text-bambu-green whitespace-nowrap",children:[j,(we.unit_price*we.quantity_needed).toFixed(2)]})]}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("button",{onClick:()=>s("projects:update")&&ae(we),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(Ga,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>s("projects:update")&&ge(we.id,we.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(Yt,{className:"w-4 h-4"})})]})]}),we.sourcing_url&&a.jsxs("a",{href:we.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:qe=>qe.stopPropagation(),children:[a.jsx(ta,{className:"w-3 h-3 flex-shrink-0"}),a.jsx("span",{className:"truncate",children:(()=>{try{return new URL(we.sourcing_url).hostname.replace("www.","")}catch{return we.sourcing_url}})()})]}),we.remarks&&a.jsx("p",{className:"mt-1 text-xs text-bambu-gray/80 italic",children:we.remarks})]})]})},we.id)),_.some(we=>we.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:[j,_.reduce((we,qe)=>we+(qe.unit_price||0)*qe.quantity_needed,0).toFixed(2)]})]})]}):a.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:n("projectDetail.bom.empty")})]})}),a.jsx(St,{children:a.jsxs(Nt,{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(f0,{className:"w-5 h-5"}),n("projectDetail.timeline.title")]})}),k?a.jsx("div",{className:"flex items-center justify-center py-4",children:a.jsx(at,{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((we,qe)=>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 ${we.event_type==="print_completed"?"bg-status-ok/20 text-status-ok":we.event_type==="print_failed"?"bg-status-error/20 text-status-error":we.event_type==="print_started"?"bg-yellow-500/20 text-yellow-400":"bg-bambu-dark-tertiary text-bambu-gray"}`,children:[we.event_type==="print_completed"&&a.jsx(yr,{className:"w-4 h-4"}),we.event_type==="print_failed"&&a.jsx(mi,{className:"w-4 h-4"}),we.event_type==="print_started"&&a.jsx(Nr,{className:"w-4 h-4"}),we.event_type==="queued"&&a.jsx(o3,{className:"w-4 h-4"}),we.event_type==="project_created"&&a.jsx(Xn,{className:"w-4 h-4"})]}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-sm text-white",children:we.title}),we.description&&a.jsx("p",{className:"text-xs text-bambu-gray truncate",children:we.description}),a.jsx("p",{className:"text-xs text-bambu-gray/70",children:pe(we.timestamp)})]})]},qe))}):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(Me,{variant:"secondary",size:"sm",onClick:()=>Re.mutate(),disabled:Re.isPending||!s("projects:create"),title:s("projects:create")?void 0:n("projectDetail.template.noCreatePermission"),children:[Re.isPending?a.jsx(at,{className:"w-4 h-4 animate-spin mr-2"}):a.jsx(Ql,{className:"w-4 h-4 mr-2"}),n("projectDetail.template.saveAsTemplate")]})}),ve&&(ve.queued_prints>0||ve.in_progress_prints>0)&&a.jsx(St,{children:a.jsxs(Nt,{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(o3,{className:"w-5 h-5"}),n("projectDetail.queue.title")]}),a.jsx(Ys,{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:[ve.in_progress_prints>0&&a.jsx("span",{className:"text-yellow-400",children:n("projectDetail.queue.printing",{count:ve.in_progress_prints})}),ve.queued_prints>0&&a.jsx("span",{className:"text-bambu-gray",children:n("projectDetail.queue.queued",{count:ve.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(fi,{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(at,{className:"w-6 h-6 animate-spin text-bambu-green"})}):a.jsx(bJe,{archives:g||[],t:n})]}),o&&a.jsx(ase,{t:n,project:{...p,archive_count:ve?.total_archives||0,total_items:ve?.total_items||0,completed_count:ve?.completed_prints||0,failed_count:ve?.failed_prints||0,queue_count:ve?.queued_prints||0,progress_percent:ve?.progress_percent||null,archives:[]},onClose:()=>l(!1),onSave:we=>E.mutate(we),isLoading:E.isPending}),Fe.isOpen&&a.jsx(xn,{title:Fe.title,message:Fe.message,confirmText:n("common.delete"),variant:"danger",onConfirm:Fe.onConfirm,onCancel:()=>Pe(we=>({...we,isOpen:!1}))})]})}function wJe({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(Me,{type:"button",variant:"secondary",onClick:e,children:i("common.cancel")}),a.jsx(Me,{type:"submit",disabled:!s.trim()||r,children:r?a.jsx(at,{className:"w-4 h-4 animate-spin"}):i("common.create")})]})]})]})})}function SJe({type:t,currentName:e,onClose:n,onSave:r,isLoading:i,t:s}){const[o,l]=w.useState(e),c=d=>{d.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:d=>l(d.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",autoFocus:!0,required:!0})]}),a.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[a.jsx(Me,{type:"button",variant:"secondary",onClick:n,children:s("common.cancel")}),a.jsx(Me,{type:"submit",disabled:!o.trim()||o.trim()===e||i,children:i?a.jsx(at,{className:"w-4 h-4 animate-spin"}):s("common.rename")})]})]})]})})}function _Je({folders:t,selectedFiles:e,currentFolderId:n,onClose:r,onMove:i,isLoading:s,t:o}){const[l,c]=w.useState(null),d=(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(...d(x.children,f+1));return p},u=[{id:null,name:o("fileManager.rootNoFolder"),depth:0},...d(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:u.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(Jl,{className:"w-4 h-4"}),h.name,h.id===n&&a.jsxs("span",{className:"text-xs text-bambu-gray ml-auto",children:["(",o("fileManager.current"),")"]})]},h.id??"root"))}),a.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[a.jsx(Me,{type:"button",variant:"secondary",onClick:r,children:o("common.cancel")}),a.jsx(Me,{onClick:()=>i(l),disabled:s,children:s?a.jsx(at,{className:"w-4 h-4 animate-spin"}):o("common.move")})]})]})]})})}function NJe({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:d}=Ze({queryKey:["projects"],queryFn:()=>J.getProjects()}),{data:u}=Ze({queryKey:["archives-for-link"],queryFn:()=>J.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(Dh,{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(Rt,{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(bX,{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(Ds,{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"?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("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")}):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(hf,{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(Me,{variant:"danger",onClick:f,disabled:r,children:[a.jsx(ek,{className:"w-4 h-4 mr-2"}),i("fileManager.unlink")]}),a.jsxs("div",{className:`flex gap-2 ${p?"":"ml-auto"}`,children:[a.jsx(Me,{variant:"secondary",onClick:e,children:i("common.cancel")}),a.jsx(Me,{onClick:h,disabled:!l||r,children:r?a.jsx(at,{className:"w-4 h-4 animate-spin"}):i("fileManager.link")})]})]})]})})}function CJe({folderId:t,onClose:e,onUploadComplete:n,t:r}){const[i,s]=w.useState([]),[o,l]=w.useState(!1),[c,d]=w.useState(!1),[u,h]=w.useState(!0),[f,p]=w.useState(!1),[x,v]=w.useState(!0),g=w.useRef(null),y=$=>{$.preventDefault(),l(!0)},_=$=>{$.preventDefault(),l(!1)},N=$=>{$.preventDefault(),l(!1);const q=Array.from($.dataTransfer.files);k(q)},A=$=>{$.target.files&&k(Array.from($.target.files))},k=$=>{const q=$.map(z=>({file:z,status:"pending",isZip:z.name.toLowerCase().endsWith(".zip"),is3mf:z.name.toLowerCase().endsWith(".3mf")}));s(z=>[...z,...q])},P=$=>{s(q=>q.filter((z,W)=>W!==$))},C=i.some($=>$.isZip&&$.status==="pending"),j=i.some($=>$.file.name.toLowerCase().endsWith(".stl")&&$.status==="pending"),M=i.some($=>$.is3mf&&$.status==="pending"),E=async()=>{if(i.length!==0){d(!0);for(let $=0;$<i.length;$++)if(i[$].status==="pending"){s(q=>q.map((z,W)=>W===$?{...z,status:"uploading"}:z));try{if(i[$].isZip){const q=await J.extractZipFile(i[$].file,t,u,f,x);s(z=>z.map((W,Q)=>Q===$?{...W,status:q.errors.length>0&&q.extracted===0?"error":"success",extractedCount:q.extracted,error:q.errors.length>0?`${q.errors.length} files failed`:void 0}:W))}else await J.uploadLibraryFile(i[$].file,t,x),s(q=>q.map((z,W)=>W===$?{...z,status:"success"}:z))}catch(q){s(z=>z.map((W,Q)=>Q===$?{...W,status:"error",error:q instanceof Error?q.message:"Upload failed"}:W))}}d(!1),n(),e()}},B=i.filter($=>$.status==="pending").length,L=i.filter($=>$.status==="success").length,U=i.filter($=>$.status==="error").length,D=i.length>0&&B===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(Rt,{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(Oa,{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}),C&&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(Ds,{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:u,onChange:$=>h($.target.checked),className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),a.jsx("span",{className:"text-sm text-white",children:r("fileManager.preserveZipStructure")})]}),a.jsxs("label",{className:"flex items-center gap-2 mt-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:f,onChange:$=>p($.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(Nr,{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")})]})]})}),(j||C)&&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(eu,{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(C&&!j?"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:$=>v($.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(($,q)=>a.jsxs("div",{className:"flex items-center gap-3 p-2 bg-bambu-dark rounded-lg",children:[$.isZip?a.jsx(Ds,{className:"w-4 h-4 text-blue-400 flex-shrink-0"}):a.jsx($C,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-sm text-white truncate",children:$.file.name}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:[($.file.size/1024/1024).toFixed(2)," MB",$.isZip&&$.status==="pending"&&a.jsxs("span",{className:"text-blue-400 ml-2",children:["• ",r("fileManager.willBeExtracted")]}),$.extractedCount!==void 0&&a.jsxs("span",{className:"text-green-400 ml-2",children:["• ",r("fileManager.filesExtracted",{count:$.extractedCount})]})]})]}),$.status==="pending"&&a.jsx("button",{onClick:()=>P(q),className:"p-1 hover:bg-bambu-dark-tertiary rounded",children:a.jsx(Rt,{className:"w-4 h-4 text-bambu-gray"})}),$.status==="uploading"&&a.jsx(at,{className:"w-4 h-4 text-bambu-green animate-spin"}),$.status==="success"&&a.jsx(yr,{className:"w-4 h-4 text-green-500"}),$.status==="error"&&a.jsx("span",{title:$.error,children:a.jsx(mi,{className:"w-4 h-4 text-red-500"})})]},q))}),D&&a.jsx("div",{className:"p-3 bg-bambu-dark rounded-lg",children:a.jsxs("p",{className:"text-sm text-white",children:[r("fileManager.uploadComplete",{succeeded:L}),U>0&&a.jsxs("span",{className:"text-red-400",children:[", ",r("fileManager.uploadFailed",{count:U})]})]})})]}),a.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary flex justify-end gap-2",children:[a.jsx(Me,{variant:"secondary",onClick:e,children:r(D?"common.close":"common.cancel")}),!D&&a.jsx(Me,{onClick:E,disabled:B===0||c,children:c?a.jsxs(a.Fragment,{children:[a.jsx(at,{className:"w-4 h-4 mr-2 animate-spin"}),r("fileManager.uploading")]}):a.jsxs(a.Fragment,{children:[a.jsx(Oa,{className:"w-4 h-4 mr-2"}),r("common.upload")," ",B>0?`(${B})`:""]})})]})]})})}function ise({folder:t,selectedFolderId:e,onSelect:n,onDelete:r,onLink:i,onRename:s,depth:o=0,wrapNames:l=!1,hasPermission:c,t:d}){const[u,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(!u)},className:"p-0.5 hover:bg-bambu-dark-tertiary rounded",children:a.jsx(pi,{className:`w-3.5 h-3.5 transition-transform ${u?"rotate-90":""}`})}):a.jsx("div",{className:"w-4.5"}),a.jsx(Jl,{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(Dh,{className:"w-3 h-3"}),t.project_name?a.jsx(bX,{className:"w-3 h-3"}):a.jsx(Ds,{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:d("fileManager.linkToProjectOrArchive"),children:a.jsx(Dh,{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(Mh,{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:d("fileManager.noPermissionRenameFolder"),children:[a.jsx(Ga,{className:"w-3.5 h-3.5"}),d("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:d("fileManager.noPermissionLinkFolder"),children:[a.jsx(Dh,{className:"w-3.5 h-3.5"}),d(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:d("fileManager.noPermissionDeleteFolder"),children:[a.jsx(Yt,{className:"w-3.5 h-3.5"}),d("common.delete")]})]})]})]})})]}),x&&u&&a.jsx("div",{children:t.children.map(g=>a.jsx(ise,{folder:g,selectedFolderId:e,onSelect:n,onDelete:r,onLink:i,onRename:s,depth:o+1,wrapNames:l,hasPermission:c,t:d},g.id))})]})}function sF(t){const e=t.toLowerCase();return e.endsWith(".gcode")||e.includes(".gcode.")}function kJe({file:t,isSelected:e,isMobile:n,onSelect:r,onDelete:i,onDownload:s,onAddToQueue:o,onPrint:l,onPreview3d:c,onRename:d,onGenerateThumbnail:u,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:`${J.getLibraryFileThumbnailUrl(t.id)}${h?`?v=${h}`:""}`,alt:t.filename,className:"w-full h-full object-cover"}):a.jsx(hf,{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:hl(t.file_size)}),t.print_time_seconds&&a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(qn,{className:"w-3 h-3"}),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(Nr,{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(nu,{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(Mh,{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&&sF(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(Nr,{className:"w-3.5 h-3.5"}),v("common.print")]}),o&&sF(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(qn,{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(ei,{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(ga,{className:"w-3.5 h-3.5"}),v("common.download")]}),d&&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.noPermissionRenameFile"),children:[a.jsx(Ga,{className:"w-3.5 h-3.5"}),v("common.rename")]}),u&&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)&&(u(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(eu,{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(Yt,{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 AJe(){const{t}=Dt(),e=Qt(),{showToast:n}=dn(),{hasPermission:r,hasAnyPermission:i,canModify:s,authEnabled:o}=jr(),[l]=xF(),c=l.get("folder"),d=c?parseInt(c,10):null,[u,h]=w.useState(d),[f,p]=w.useState([]),[x,v]=w.useState(!1),[g,y]=w.useState(!1),[_,N]=w.useState(!1),[A,k]=w.useState(null),[P,C]=w.useState(null),[j,M]=w.useState(null),[E,B]=w.useState(null),[L,U]=w.useState(null),[D,$]=w.useState(null),[q,z]=w.useState({}),[W,Q]=w.useState(null),[te,H]=w.useState(()=>localStorage.getItem("library-view-mode")||"grid"),[X,Z]=w.useState(()=>localStorage.getItem("library-wrap-folders")==="true"),[ee,Se]=w.useState(()=>{const Be=localStorage.getItem("library-sidebar-width");return Be?parseInt(Be,10):256}),[oe,ie]=w.useState(!1),me=w.useRef(null);w.useEffect(()=>{if(!oe)return;document.body.style.userSelect="none",document.body.style.cursor="col-resize";const Be=yt=>{if(!me.current)return;const zt=me.current.parentElement?.getBoundingClientRect();if(!zt)return;const yn=yt.clientX-zt.left,gr=Math.min(500,Math.max(200,yn));Se(gr)},mt=()=>{ie(!1),document.body.style.userSelect="",document.body.style.cursor="",localStorage.setItem("library-sidebar-width",String(ee))};return document.addEventListener("mousemove",Be),document.addEventListener("mouseup",mt),()=>{document.removeEventListener("mousemove",Be),document.removeEventListener("mouseup",mt),document.body.style.userSelect="",document.body.style.cursor=""}},[oe,ee]);const[se,ce]=w.useState(""),[Ce,le]=w.useState("all"),[Le,V]=w.useState(""),[K,fe]=w.useState(()=>localStorage.getItem("library-sort-field")||"name"),[Y,re]=w.useState(()=>localStorage.getItem("library-sort-direction")||"asc"),ue=Cne();w.useEffect(()=>{const Be=l.get("folder");if(Be){const mt=parseInt(Be,10);h(mt)}},[l]);const{data:Fe}=Ze({queryKey:["settings"],queryFn:()=>J.getSettings()}),{data:Pe,isLoading:be}=Ze({queryKey:["library-folders"],queryFn:()=>J.getLibraryFolders()}),{data:O,isLoading:R}=Ze({queryKey:["library-files",u],queryFn:()=>J.getLibraryFiles(u,u===null)}),{data:G}=Ze({queryKey:["library-stats"],queryFn:()=>J.getLibraryStats()}),{data:de}=Ze({queryKey:["users"],queryFn:()=>J.getUsers()}),ge=w.useMemo(()=>{if(!O)return[];const Be=new Set(O.map(mt=>mt.file_type));return Array.from(Be).sort()},[O]),ae=w.useMemo(()=>{if(!O)return[];let Be=[...O];if(se.trim()){const mt=se.toLowerCase();Be=Be.filter(yt=>yt.filename.toLowerCase().includes(mt)||yt.print_name&&yt.print_name.toLowerCase().includes(mt))}if(Ce!=="all"&&(Be=Be.filter(mt=>mt.file_type===Ce)),Le.trim()){const mt=Le.toLowerCase();Be=Be.filter(yt=>yt.created_by_username&&yt.created_by_username.toLowerCase().includes(mt))}return Be.sort((mt,yt)=>{let zt=0;switch(K){case"name":zt=(mt.print_name||mt.filename).localeCompare(yt.print_name||yt.filename);break;case"date":zt=(tr(mt.created_at)?.getTime()??0)-(tr(yt.created_at)?.getTime()??0);break;case"size":zt=mt.file_size-yt.file_size;break;case"type":zt=mt.file_type.localeCompare(yt.file_type);break;case"prints":zt=mt.print_count-yt.print_count;break}return Y==="asc"?zt:-zt}),Be},[O,se,Ce,Le,K,Y]),Ue=w.useMemo(()=>{if(!G||!Fe)return!1;const Be=(Fe.library_disk_warning_gb||5)*1024*1024*1024;return G.disk_free_bytes<Be},[G,Fe]),ze=st({mutationFn:Be=>J.createLibraryFolder(Be),onSuccess:()=>{e.invalidateQueries({queryKey:["library-folders"]}),v(!1),n(t("fileManager.toast.folderCreated"),"success")},onError:Be=>n(Be.message,"error")}),$e=st({mutationFn:Be=>J.deleteLibraryFolder(Be),onSuccess:()=>{e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["library-stats"]}),u===P?.id&&h(null),C(null),n(t("fileManager.toast.folderDeleted"),"success")},onError:Be=>{C(null),n(Be.message,"error")}}),Re=st({mutationFn:Be=>J.deleteLibraryFile(Be),onSuccess:()=>{e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["library-stats"]}),p(Be=>Be.filter(mt=>mt!==P?.id)),C(null),n(t("fileManager.toast.fileDeleted"),"success")},onError:Be=>{C(null),n(Be.message,"error")}}),pe=st({mutationFn:Be=>J.bulkDeleteLibrary(Be,[]),onSuccess:(Be,mt)=>{e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["library-stats"]}),n(t("fileManager.toast.filesDeleted",{count:mt.length}),"success"),p([]),C(null)},onError:Be=>{C(null),n(Be.message,"error")}}),ve=st({mutationFn:({fileIds:Be,folderId:mt})=>J.moveLibraryFiles(Be,mt),onSuccess:()=>{e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["library-folders"]}),p([]),y(!1),n(t("fileManager.toast.filesMoved"),"success")},onError:Be=>n(Be.message,"error")}),Ne=st({mutationFn:({id:Be,data:mt})=>J.updateLibraryFolder(Be,mt),onSuccess:(Be,mt)=>{e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["project-folders"]}),e.invalidateQueries({queryKey:["archive-folders"]}),k(null);const yt=mt.data.project_id===0&&mt.data.archive_id===0;n(t(yt?"fileManager.toast.folderUnlinked":"fileManager.toast.folderLinked"),"success")},onError:Be=>n(Be.message,"error")}),xe=st({mutationFn:({id:Be,filename:mt})=>J.updateLibraryFile(Be,{filename:mt}),onSuccess:()=>{e.invalidateQueries({queryKey:["library-files"]}),$(null),n(t("fileManager.toast.fileRenamed"),"success")},onError:Be=>{$(null),n(Be.message,"error")}}),we=st({mutationFn:({id:Be,name:mt})=>J.updateLibraryFolder(Be,{name:mt}),onSuccess:()=>{e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["library-files"]}),$(null),n(t("fileManager.toast.folderRenamed"),"success")},onError:Be=>{$(null),n(Be.message,"error")}}),qe=st({mutationFn:()=>J.batchGenerateStlThumbnails({all_missing:!0}),onSuccess:Be=>{if(e.invalidateQueries({queryKey:["library-files"]}),Be.succeeded>0){const mt=Date.now(),yt={};Be.results.forEach(zt=>{zt.success&&(yt[zt.file_id]=mt)}),z(zt=>({...zt,...yt}))}Be.succeeded>0&&Be.failed===0?n(t("fileManager.toast.thumbnailsGenerated",{count:Be.succeeded}),"success"):Be.succeeded>0&&Be.failed>0?n(t("fileManager.toast.thumbnailsGeneratedPartial",{succeeded:Be.succeeded,failed:Be.failed}),"success"):Be.processed===0?n(t("fileManager.toast.noStlMissingThumbnails"),"info"):n(t("fileManager.toast.failedToGenerateThumbnails",{error:Be.results[0]?.error||"Unknown error"}),"error")},onError:Be=>n(Be.message,"error")}),ke=st({mutationFn:Be=>J.batchGenerateStlThumbnails({file_ids:[Be]}),onSuccess:Be=>{if(e.invalidateQueries({queryKey:["library-files"]}),Be.succeeded>0){const mt=Be.results[0]?.file_id;mt&&z(yt=>({...yt,[mt]:Date.now()})),n(t("fileManager.toast.thumbnailGenerated"),"success")}else n(t("fileManager.toast.failedToGenerateThumbnail",{error:Be.results[0]?.error||"Unknown error"}),"error")},onError:Be=>n(Be.message,"error")}),nt=w.useCallback(Be=>{const mt=Be.toLowerCase();return mt.endsWith(".gcode")||mt.includes(".gcode.")},[]),De=w.useMemo(()=>O?O.filter(Be=>f.includes(Be.id)&&nt(Be.filename)):[],[O,f,nt]),We=w.useCallback(Be=>{p(mt=>mt.includes(Be)?mt.filter(yt=>yt!==Be):[...mt,Be])},[]),Oe=w.useCallback(()=>{ae.length>0&&p(ae.map(Be=>Be.id))},[ae]),je=w.useCallback(()=>{p([])},[]),Ve=()=>{e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["library-stats"]})},ot=Be=>{J.downloadLibraryFile(Be).catch(mt=>{console.error("Library file download failed:",mt)})},kt=()=>{P&&(P.type==="file"?Re.mutate(P.id):P.type==="folder"?$e.mutate(P.id):P.type==="bulk"&&pe.mutate(f))},Ft=$e.isPending||Re.isPending||pe.isPending,Vt=Be=>{H(Be),localStorage.setItem("library-view-mode",Be)},At=be||R;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(Jl,{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:()=>Vt("grid"),className:`p-1.5 rounded transition-colors ${te==="grid"?"bg-bambu-dark-secondary text-white":"text-bambu-gray hover:text-white"}`,title:t("fileManager.gridView"),children:a.jsx(uv,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>Vt("list"),className:`p-1.5 rounded transition-colors ${te==="list"?"bg-bambu-dark-secondary text-white":"text-bambu-gray hover:text-white"}`,title:t("fileManager.listView"),children:a.jsx(GC,{className:"w-4 h-4"})})]}),a.jsxs(Me,{variant:"secondary",onClick:()=>qe.mutate(),disabled:qe.isPending||!i("library:update_own","library:update_all"),title:i("library:update_own","library:update_all")?t("fileManager.generateThumbnailsForMissing"):t("fileManager.noPermissionGenerateThumbnail"),children:[qe.isPending?a.jsx(at,{className:"w-4 h-4 mr-2 animate-spin"}):a.jsx(eu,{className:"w-4 h-4 mr-2"}),t("fileManager.generateThumbnails")]}),a.jsxs(Me,{variant:"secondary",onClick:()=>v(!0),disabled:!r("library:upload"),title:r("library:upload")?void 0:t("fileManager.noPermissionCreateFolder"),children:[a.jsx(jme,{className:"w-4 h-4 mr-2"}),t("fileManager.newFolder")]}),a.jsxs(Me,{onClick:()=>N(!0),disabled:!r("library:upload"),title:r("library:upload")?void 0:t("fileManager.noPermissionUpload"),children:[a.jsx(Oa,{className:"w-4 h-4 mr-2"}),t("common.upload")]})]})]}),Ue&&G&&Fe&&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(An,{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:hl(G.disk_free_bytes),total:hl(G.disk_total_bytes),threshold:Fe.library_disk_warning_gb})})]})]}),G&&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($C,{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:G.total_files})]}),a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx(Jl,{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:G.total_folders})]}),a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx(Vb,{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:hl(G.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 ${Ue?"text-amber-500":"text-white"}`,children:hl(G.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:u??"",onChange:Be=>h(Be.target.value?parseInt(Be.target.value,10):null),className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg px-3 py-2.5 text-white focus:outline-none focus:border-bambu-green",children:[a.jsxs("option",{value:"",children:["📁 ",t("fileManager.allFiles")]}),Pe&&(()=>{const Be=(mt,yt=0)=>{const zt=[];for(const yn of mt)zt.push({id:yn.id,name:yn.name,fileCount:yn.file_count,depth:yt}),yn.children.length>0&&zt.push(...Be(yn.children,yt+1));return zt};return Be(Pe).map(mt=>a.jsxs("option",{value:mt.id,children:["│ ".repeat(mt.depth),"📂 ",mt.name," ",mt.fileCount>0?`(${mt.fileCount})`:""]},mt.id))})()]})}),a.jsxs("div",{ref:me,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:`${ee}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 ${oe?"bg-bambu-green":"hover:bg-bambu-green/50"}`,onMouseDown:Be=>{Be.preventDefault(),ie(!0)},onDoubleClick:()=>{Se(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 ${oe?"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 Be=!X;Z(Be),localStorage.setItem("library-wrap-folders",String(Be))},className:`text-xs px-1.5 py-0.5 rounded transition-colors ${X?"bg-bambu-green/20 text-bambu-green":"text-bambu-gray hover:text-white hover:bg-bambu-dark"}`,title:t(X?"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 ${u===null?"bg-bambu-green/20 text-bambu-green":"hover:bg-bambu-dark text-white"}`,onClick:()=>h(null),children:[a.jsx(hf,{className:"w-4 h-4"}),a.jsx("span",{className:"text-sm",children:t("fileManager.allFiles")})]}),Pe?.map(Be=>a.jsx(ise,{folder:Be,selectedFolderId:u,onSelect:h,onDelete:mt=>C({type:"folder",id:mt}),onLink:k,onRename:mt=>$({type:"folder",id:mt.id,name:mt.name}),wrapNames:X,hasPermission:r,t},Be.id))]})]}),a.jsxs("div",{className:"flex-1 flex flex-col min-w-0 min-h-0",children:[O&&O.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:se,onChange:Be=>ce(Be.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(VC,{className:"w-4 h-4 text-bambu-gray hidden sm:block"}),a.jsxs("select",{value:Ce,onChange:Be=>le(Be.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")}),ge.map(Be=>a.jsx("option",{value:Be,children:Be.toUpperCase()},Be))]})]}),o&&a.jsxs("div",{className:"relative",children:[a.jsx("input",{type:"text",placeholder:t("fileManager.filterByUser",{defaultValue:"Filter by user"}),value:Le,onChange:Be=>V(Be.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 ${Le?"pr-7":""}`,style:Le?{WebkitAppearance:"none",MozAppearance:"textfield"}:void 0}),Le&&a.jsx("button",{onClick:()=>V(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white z-10",children:a.jsx(Rt,{className:"w-3 h-3"})}),a.jsx("datalist",{id:"usernames-list",children:de?.map(Be=>a.jsx("option",{value:Be.username},Be.id))})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("select",{value:K,onChange:Be=>{const mt=Be.target.value;fe(mt),localStorage.setItem("library-sort-field",mt)},className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1.5 text-sm text-white focus:outline-none focus:border-bambu-green",children:[a.jsx("option",{value:"name",children:t("common.name")}),a.jsx("option",{value:"date",children:t("common.date")}),a.jsx("option",{value:"size",children:t("fileManager.size")}),a.jsx("option",{value:"type",children:t("common.type")}),a.jsx("option",{value:"prints",children:t("fileManager.prints")})]}),a.jsx("button",{onClick:()=>re(Be=>{const mt=Be==="asc"?"desc":"asc";return localStorage.setItem("library-sort-direction",mt),mt}),className:"p-1.5 rounded bg-bambu-dark border border-bambu-dark-tertiary hover:border-bambu-green transition-colors",title:t(Y==="asc"?"fileManager.ascending":"fileManager.descending"),children:Y==="asc"?a.jsx(Yue,{className:"w-4 h-4 text-white"}):a.jsx($ue,{className:"w-4 h-4 text-white"})})]}),(se||Ce!=="all"||Le)&&a.jsx("span",{className:"text-sm text-bambu-gray hidden sm:inline",children:t("fileManager.resultsCount",{showing:ae.length,total:O.length})})]}),ae.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===ae.length&&f.length>0?a.jsxs(Me,{variant:"secondary",size:"sm",onClick:je,children:[a.jsx(Sl,{className:"w-4 h-4 sm:mr-1"}),a.jsx("span",{className:"hidden sm:inline",children:t("fileManager.deselectAll")})]}):a.jsxs(Me,{variant:"secondary",size:"sm",onClick:Oe,children:[a.jsx(co,{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:[De.length===1&&a.jsxs(Me,{variant:"primary",size:"sm",onClick:()=>B(De[0]),disabled:!r("printers:control"),title:r("printers:control")?void 0:t("fileManager.noPermissionPrint"),children:[a.jsx(oo,{className:"w-4 h-4 sm:mr-1"}),a.jsx("span",{className:"hidden sm:inline",children:t("common.print")})]}),De.length===1&&a.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>U(De[0]),disabled:!r("queue:create"),title:r("queue:create")?void 0:t("fileManager.noPermissionAddToQueue"),children:[a.jsx(qn,{className:"w-4 h-4 sm:mr-1"}),a.jsx("span",{className:"hidden sm:inline",children:t("fileManager.schedulePrint")})]}),a.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>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(Bfe,{className:"w-4 h-4 sm:mr-1"}),a.jsx("span",{className:"hidden sm:inline",children:t("common.move")})]}),a.jsxs(Me,{variant:"danger",size:"sm",onClick:()=>{f.length===1?C({type:"file",id:f[0]}):C({type:"bulk",id:0,count:f.length})},disabled:!i("library:delete_own","library:delete_all"),title:i("library:delete_own","library:delete_all")?void 0:t("fileManager.noPermissionDeleteFiles"),children:[a.jsx(Yt,{className:"w-4 h-4 sm:mr-1"}),a.jsx("span",{className:"hidden sm:inline",children:t("common.delete")})]}),a.jsxs(Me,{variant:"secondary",size:"sm",onClick:je,children:[a.jsx(Rt,{className:"w-4 h-4 sm:mr-1"}),a.jsx("span",{className:"hidden sm:inline",children:t("common.clear")})]})]})]})]}),At?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(at,{className:"w-8 h-8 animate-spin text-bambu-green"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:t("fileManager.loadingFiles")})]})}):O?.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(hf,{className:"w-12 h-12 text-bambu-gray/50"})}),a.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:t(u!==null?"fileManager.folderIsEmpty":"fileManager.noFilesYet")}),a.jsx("p",{className:"text-bambu-gray text-center max-w-md mb-6",children:t(u!==null?"fileManager.folderEmptyDescription":"fileManager.noFilesDescription")}),a.jsxs(Me,{onClick:()=>N(!0),disabled:!r("library:upload"),title:r("library:upload")?void 0:t("fileManager.noPermissionUpload"),children:[a.jsx(Xn,{className:"w-4 h-4 mr-2"}),t("fileManager.uploadFiles")]})]}):ae.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(Me,{variant:"secondary",onClick:()=>{ce(""),le("all")},children:t("fileManager.clearFilters")})]}):te==="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:ae.map(Be=>a.jsx(kJe,{file:Be,isSelected:f.includes(Be.id),isMobile:ue,t,onSelect:We,onDelete:mt=>C({type:"file",id:mt}),onDownload:ot,onAddToQueue:mt=>{const yt=O?.find(zt=>zt.id===mt);yt&&U(yt)},onPrint:M,onPreview3d:Q,onRename:mt=>$({type:"file",id:mt.id,name:mt.filename}),onGenerateThumbnail:mt=>ke.mutate(mt.id),thumbnailVersion:q[Be.id],hasPermission:r,canModify:s,authEnabled:o},Be.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",{})]}),ae.map(Be=>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(Be.id)?"bg-bambu-green/10":""}`,onClick:()=>We(Be.id),children:[a.jsx("div",{className:`w-5 h-5 rounded border-2 flex items-center justify-center ${f.includes(Be.id)?"bg-bambu-green border-bambu-green":"border-bambu-gray/50"}`,children:f.includes(Be.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:Be.thumbnail_path?a.jsx("img",{src:`${J.getLibraryFileThumbnailUrl(Be.id)}${q[Be.id]?`?v=${q[Be.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(hf,{className:"w-5 h-5 text-bambu-gray/50"})})}),Be.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:`${J.getLibraryFileThumbnailUrl(Be.id)}${q[Be.id]?`?v=${q[Be.id]}`:""}`,alt:Be.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:Be.print_name||Be.filename})})]}),o&&a.jsx("div",{className:"text-sm text-bambu-gray flex items-center gap-1",children:Be.created_by_username?a.jsxs(a.Fragment,{children:[a.jsx(nu,{className:"w-3 h-3"}),a.jsx("span",{className:"truncate",children:Be.created_by_username})]}):"-"}),a.jsx("div",{children:a.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded font-medium ${Be.file_type==="3mf"?"bg-bambu-green/20 text-bambu-green":Be.file_type==="gcode"?"bg-blue-500/20 text-blue-400":Be.file_type==="stl"?"bg-purple-500/20 text-purple-400":"bg-bambu-gray/20 text-bambu-gray"}`,children:Be.file_type.toUpperCase()})}),a.jsx("div",{className:"text-sm text-bambu-gray",children:hl(Be.file_size)}),a.jsx("div",{className:"text-sm text-bambu-gray",children:Be.print_count>0?`${Be.print_count}x`:"-"}),a.jsxs("div",{className:"flex items-center gap-1",onClick:mt=>mt.stopPropagation(),children:[sF(Be.filename)&&a.jsxs(a.Fragment,{children:[a.jsx("button",{onClick:()=>r("printers:control")&&M(Be),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(Nr,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>{r("queue:create")&&U(Be)},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(qn,{className:"w-4 h-4"})})]}),(Be.file_type==="3mf"||Be.file_type==="gcode"||Be.file_type==="stl")&&a.jsx("button",{onClick:()=>r("library:read")&&Q(Be),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(ei,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>r("library:read")&&ot(Be.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(ga,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>s("library","update",Be.created_by_id)&&$({type:"file",id:Be.id,name:Be.filename}),className:`p-1.5 rounded transition-colors ${s("library","update",Be.created_by_id)?"hover:bg-bambu-dark text-bambu-gray hover:text-white":"text-bambu-gray/50 cursor-not-allowed"}`,title:s("library","update",Be.created_by_id)?t("common.rename"):t("fileManager.noPermissionRenameFile"),disabled:!s("library","update",Be.created_by_id),children:a.jsx(Ga,{className:"w-4 h-4"})}),Be.file_type==="stl"&&a.jsx("button",{onClick:()=>s("library","update",Be.created_by_id)&&ke.mutate(Be.id),className:`p-1.5 rounded transition-colors ${s("library","update",Be.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",Be.created_by_id)?t("fileManager.generateThumbnail"):t("fileManager.noPermissionGenerateThumbnail"),disabled:ke.isPending||!s("library","update",Be.created_by_id),children:a.jsx(eu,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>s("library","delete",Be.created_by_id)&&C({type:"file",id:Be.id}),className:`p-1.5 rounded transition-colors ${s("library","delete",Be.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",Be.created_by_id)?t("common.delete"):t("fileManager.noPermissionDeleteFile"),disabled:!s("library","delete",Be.created_by_id),children:a.jsx(Yt,{className:"w-4 h-4"})})]})]},Be.id))]})})]})]}),x&&a.jsx(wJe,{parentId:u,onClose:()=>v(!1),onSave:Be=>ze.mutate(Be),isLoading:ze.isPending,t}),g&&Pe&&a.jsx(_Je,{folders:Pe,selectedFiles:f,currentFolderId:u,onClose:()=>y(!1),onMove:Be=>ve.mutate({fileIds:f,folderId:Be}),isLoading:ve.isPending,t}),_&&a.jsx(CJe,{folderId:u,onClose:()=>N(!1),onUploadComplete:Ve,t}),A&&a.jsx(NJe,{folder:A,onClose:()=>k(null),onLink:Be=>Ne.mutate({id:A.id,data:Be}),isLoading:Ne.isPending,t}),P&&a.jsx(xn,{title:P.type==="folder"?t("fileManager.deleteFolder"):P.type==="bulk"?t("fileManager.deleteFilesCount",{count:P.count}):t("fileManager.deleteFile"),message:P.type==="folder"?t("fileManager.deleteFolderConfirm"):P.type==="bulk"?t("fileManager.deleteFilesConfirm",{count:P.count}):t("fileManager.deleteFileConfirm"),confirmText:t("common.delete"),variant:"danger",isLoading:Ft,loadingText:t("fileManager.deleting"),onConfirm:kt,onCancel:()=>C(null)}),j&&a.jsx(Yd,{mode:"reprint",libraryFileId:j.id,archiveName:j.print_name||j.filename,onClose:()=>M(null),onSuccess:()=>{M(null),e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["archives"]})}}),E&&a.jsx(Yd,{mode:"reprint",libraryFileId:E.id,archiveName:E.print_name||E.filename,onClose:()=>B(null),onSuccess:()=>{B(null),p([]),e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["archives"]})}}),L&&a.jsx(Yd,{mode:"add-to-queue",libraryFileId:L.id,archiveName:L.print_name||L.filename,onClose:()=>U(null),onSuccess:()=>{U(null),p([]),e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["queue"]}),e.invalidateQueries({queryKey:["archives"]})}}),W&&a.jsx(bO,{libraryFileId:W.id,title:W.print_name||W.filename,fileType:W.file_type,onClose:()=>Q(null)}),D&&a.jsx(SJe,{type:D.type,currentName:D.name,onClose:()=>$(null),onSave:Be=>{D.type==="file"?xe.mutate({id:D.id,filename:Be}):we.mutate({id:D.id,name:Be})},isLoading:xe.isPending||we.isPending,t})]})}const Fj=5,TJe=2e3,MJe=3e4,PJe=5e3;function EJe(){const{t}=Dt(),e=Qt(),{showToast:n}=dn(),{hasPermission:r}=jr(),{printerId:i}=sv(),s=parseInt(i||"0",10),[o,l]=w.useState("stream"),[c,d]=w.useState(!1),[u,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,k]=w.useState(0),[P,C]=w.useState(!1),[j,M]=w.useState(0),[E,B]=w.useState(1),[L,U]=w.useState({x:0,y:0}),[D,$]=w.useState(!1),[q,z]=w.useState({x:0,y:0}),[W,Q]=w.useState(null),[te,H]=w.useState(null),X=w.useRef(null),Z=w.useRef(null),ee=w.useRef(null),Se=w.useRef(null),oe=w.useRef(null),{data:ie}=Ze({queryKey:["printer",s],queryFn:()=>J.getPrinter(s),enabled:s>0}),{data:me}=Ze({queryKey:["printerStatus",s],queryFn:()=>J.getPrinterStatus(s),refetchInterval:3e4,enabled:s>0}),se=st({mutationFn:ve=>J.setChamberLight(s,ve),onMutate:async ve=>{await e.cancelQueries({queryKey:["printerStatus",s]});const Ne=e.getQueryData(["printerStatus",s]);return e.setQueryData(["printerStatus",s],xe=>({...xe,chamber_light:ve})),{previousStatus:Ne}},onSuccess:(ve,Ne)=>{n(`Chamber light ${Ne?"on":"off"}`)},onError:(ve,Ne,xe)=>{xe?.previousStatus&&e.setQueryData(["printerStatus",s],xe.previousStatus),n(ve.message||t("printers.toast.failedToControlChamberLight"),"error")}}),ce=(me?.state==="RUNNING"||me?.state==="PAUSE")&&(me?.printable_objects_count??0)>=2;w.useEffect(()=>(ie&&(document.title=`${ie.name} - Camera`),()=>{document.title="Bambuddy"}),[ie]);const Ce=w.useRef(!1);w.useEffect(()=>{const ve=`/api/v1/printers/${s}/camera/stop`;Ce.current=!1;const Ne=()=>{if(s>0&&!Ce.current){Ce.current=!0;const qe={},ke=au();ke&&(qe.Authorization=`Bearer ${ke}`),fetch(ve,{method:"POST",keepalive:!0,headers:qe}).catch(()=>{})}},xe=()=>{Ne()};window.addEventListener("beforeunload",xe);const we=X.current;return()=>{window.removeEventListener("beforeunload",xe),we&&(we.src=""),Ne()}},[s]),w.useEffect(()=>{if(f&&!g){const Ne=setTimeout(()=>{p(!1)},o==="stream"?3e3:2e4);return()=>clearTimeout(Ne)}},[o,f,x,g]),w.useEffect(()=>{const ve=()=>{const Ne=!!document.fullscreenElement;N(Ne),B(1),U({x:0,y:0}),o==="stream"&&!g&&(X.current&&(X.current.src=""),setTimeout(()=>{p(!0),v(Date.now())},200))};return document.addEventListener("fullscreenchange",ve),()=>document.removeEventListener("fullscreenchange",ve)},[o,g]),w.useEffect(()=>{let ve;const Ne=()=>{clearTimeout(ve),ve=setTimeout(()=>{localStorage.setItem("cameraWindowState",JSON.stringify({width:window.outerWidth,height:window.outerHeight,left:window.screenX,top:window.screenY}))},500)};return window.addEventListener("resize",Ne),()=>{clearTimeout(ve),window.removeEventListener("resize",Ne)}},[]),w.useEffect(()=>()=>{ee.current&&clearTimeout(ee.current),Se.current&&clearInterval(Se.current),oe.current&&clearInterval(oe.current)},[]);const le=w.useCallback(()=>{if(A>=Fj){C(!1),h(!0);return}const ve=Math.min(TJe*Math.pow(2,A),MJe);C(!0),M(Math.ceil(ve/1e3)),Se.current=setInterval(()=>{M(Ne=>Ne<=1?(Se.current&&clearInterval(Se.current),0):Ne-1)},1e3),ee.current=setTimeout(()=>{k(Ne=>Ne+1),C(!1),p(!0),h(!1),X.current&&(X.current.src=""),v(Date.now())},ve)},[A]);w.useEffect(()=>{if(o!=="stream"||f||P||g){oe.current&&(clearInterval(oe.current),oe.current=null);return}return oe.current=setInterval(async()=>{try{const ve=await J.getCameraStatus(s);(ve.stalled||!ve.active&&!u)&&(console.log(`Stream issue detected: stalled=${ve.stalled}, active=${ve.active}, reconnecting...`),oe.current&&(clearInterval(oe.current),oe.current=null),p(!1),le())}catch{}},PJe),()=>{oe.current&&(clearInterval(oe.current),oe.current=null)}},[o,f,u,P,g,s,le]);const Le=()=>{p(!1),o==="stream"&&A<Fj?le():h(!0)},V=()=>{if(p(!1),h(!1),k(0),C(!1),ee.current&&clearTimeout(ee.current),Se.current&&clearInterval(Se.current),X.current&&!localStorage.getItem("cameraWindowState")){const ve=X.current,Ne=ve.naturalWidth,xe=ve.naturalHeight;if(Ne>0&&xe>0){const ke=window.outerWidth-window.innerWidth,nt=window.outerHeight-window.innerHeight,De=Ne+16+ke,We=xe+45+16+nt;try{window.resizeTo(De,We)}catch{}}}},K=()=>{if(s>0){const ve={},Ne=au();Ne&&(ve.Authorization=`Bearer ${Ne}`),fetch(`/api/v1/printers/${s}/camera/stop`,{method:"POST",headers:ve}).catch(()=>{})}},fe=ve=>{o===ve||g||(y(!0),p(!0),h(!1),k(0),C(!1),B(1),U({x:0,y:0}),ee.current&&clearTimeout(ee.current),Se.current&&clearInterval(Se.current),X.current&&(X.current.src=""),o==="stream"&&K(),setTimeout(()=>{l(ve),v(Date.now()),y(!1)},100))},Y=()=>{g||(y(!0),p(!0),h(!1),k(0),C(!1),ee.current&&clearTimeout(ee.current),Se.current&&clearInterval(Se.current),X.current&&(X.current.src=""),o==="stream"&&K(),setTimeout(()=>{v(Date.now()),y(!1)},100))},re=()=>{Z.current&&(document.fullscreenElement?document.exitFullscreen():Z.current.requestFullscreen())},ue=()=>{B(ve=>Math.min(ve+.5,4))},Fe=()=>{B(ve=>{const Ne=Math.max(ve-.5,1);return Ne===1&&U({x:0,y:0}),Ne})},Pe=ve=>{ve.preventDefault(),ve.deltaY<0?ue():Fe()},be=ve=>{E>1&&(ve.preventDefault(),$(!0),z({x:ve.clientX-L.x,y:ve.clientY-L.y}))},O=w.useCallback(()=>{if(!Z.current)return{x:300,y:200};const ve=Z.current.getBoundingClientRect(),Ne=ve.width*(E-1)/2,xe=ve.height*(E-1)/2;return{x:Math.max(50,Ne),y:Math.max(50,xe)}},[E]),R=ve=>{if(D&&E>1){const Ne=ve.clientX-q.x,xe=ve.clientY-q.y,we=O();U({x:Math.max(-we.x,Math.min(we.x,Ne)),y:Math.max(-we.y,Math.min(we.y,xe))})}},G=()=>{$(!1)},de=ve=>{if(ve.length<2)return 0;const Ne=ve[0].clientX-ve[1].clientX,xe=ve[0].clientY-ve[1].clientY;return Math.sqrt(Ne*Ne+xe*xe)},ge=ve=>ve.length<2?{x:ve[0].clientX,y:ve[0].clientY}:{x:(ve[0].clientX+ve[1].clientX)/2,y:(ve[0].clientY+ve[1].clientY)/2},ae=ve=>{ve.touches.length===2?(ve.preventDefault(),Q(de(ve.touches)),H(ge(ve.touches))):ve.touches.length===1&&E>1&&(ve.preventDefault(),$(!0),z({x:ve.touches[0].clientX-L.x,y:ve.touches[0].clientY-L.y}))},Ue=ve=>{if(ve.touches.length===2&&W!==null){ve.preventDefault();const Ne=de(ve.touches),xe=Ne/W;B(qe=>{const ke=Math.max(1,Math.min(4,qe*xe));return ke===1&&U({x:0,y:0}),ke}),Q(Ne);const we=ge(ve.touches);if(te){const qe=O();U(ke=>({x:Math.max(-qe.x,Math.min(qe.x,ke.x+(we.x-te.x))),y:Math.max(-qe.y,Math.min(qe.y,ke.y+(we.y-te.y)))}))}H(we)}else if(ve.touches.length===1&&D&&E>1){ve.preventDefault();const Ne=ve.touches[0].clientX-q.x,xe=ve.touches[0].clientY-q.y,we=O();U({x:Math.max(-we.x,Math.min(we.x,Ne)),y:Math.max(-we.y,Math.min(we.y,xe))})}},ze=ve=>{ve.touches.length<2&&(Q(null),H(null)),ve.touches.length===0&&$(!1)},$e=()=>{B(1),U({x:0,y:0})},Re=g?"":o==="stream"?`/api/v1/printers/${s}/camera/stream?fps=15&t=${x}`:`/api/v1/printers/${s}/camera/snapshot?t=${x}`,pe=f||g||P;return s?a.jsxs("div",{ref:Z,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(db,{className:"w-4 h-4"}),ie?.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:()=>fe("stream"),disabled:pe,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:()=>fe("snapshot"),disabled:pe,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:()=>se.mutate(!me?.chamber_light),disabled:!me?.connected||se.isPending||!r("printers:control"),className:`p-1.5 rounded disabled:opacity-50 ${me?.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(dL,{on:me?.chamber_light??!1,className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>d(!0),disabled:!ce||!r("printers:control"),className:`p-1.5 rounded disabled:opacity-50 ${ce&&r("printers:control")?"hover:bg-bambu-dark-tertiary":""}`,title:r("printers:control")?t(ce?"printers.skipObjects.tooltip":"printers.skipObjects.onlyWhilePrinting"):t("printers.permission.noControl"),children:a.jsx(hk,{className:"w-4 h-4 text-bambu-gray"})}),a.jsx("button",{onClick:Y,disabled:pe,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded disabled:opacity-50",title:t(o==="stream"?"camera.restartStream":"camera.refreshSnapshot"),children:a.jsx(Sr,{className:`w-4 h-4 text-bambu-gray ${pe?"animate-spin":""}`})}),a.jsx("button",{onClick:re,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded",title:t(_?"camera.exitFullscreen":"camera.fullscreen"),children:_?a.jsx(CX,{className:"w-4 h-4 text-bambu-gray"}):a.jsx(Mfe,{className:"w-4 h-4 text-bambu-gray"})})]})]}),a.jsx("div",{className:"flex-1 flex items-center justify-center p-2 overflow-hidden",onWheel:Pe,onMouseMove:R,onMouseUp:G,onMouseLeave:G,onTouchStart:ae,onTouchMove:Ue,onTouchEnd:ze,style:{touchAction:"none"},children:a.jsxs("div",{className:"relative w-full h-full flex items-center justify-center",children:[(f||g)&&!P&&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(Sr,{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")})]})}),P&&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(Gh,{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:j,attempt:A+1,max:Fj})}),a.jsx("button",{onClick:Y,className:"px-4 py-2 bg-bambu-green text-white text-sm rounded hover:bg-bambu-green/80 transition-colors",children:t("camera.reconnectNow")})]})}),u&&!P&&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(An,{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:Y,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:X,src:Re,alt:t("camera.cameraStream"),className:"max-w-full max-h-full object-contain select-none",style:{transform:`scale(${E}) translate(${L.x/E}px, ${L.y/E}px)`,cursor:E>1?D?"grabbing":"grab":"default"},onError:Re?Le:void 0,onLoad:Re?V:void 0,onMouseDown:be,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:Fe,disabled:E<=1,className:"p-1.5 hover:bg-white/10 rounded disabled:opacity-30",title:t("camera.zoomOut"),children:a.jsx(RF,{className:"w-4 h-4 text-white"})}),a.jsxs("button",{onClick:$e,className:"px-2 py-1 text-sm text-white hover:bg-white/10 rounded min-w-[48px]",title:t("camera.resetZoom"),children:[Math.round(E*100),"%"]}),a.jsx("button",{onClick:ue,disabled:E>=4,className:"p-1.5 hover:bg-white/10 rounded disabled:opacity-30",title:t("camera.zoomIn"),children:a.jsx(DF,{className:"w-4 h-4 text-white"})})]})]})}),a.jsx(uL,{printerId:s,isOpen:c,onClose:()=>d(!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 jJe(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 DJe(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 RJe(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 FJe(){const{printerId:t}=sv(),[e]=xF(),{t:n}=Dt(),r=Qt(),i=parseInt(t||"0",10),[s,o]=w.useState(Date.now()),l=w.useMemo(()=>jJe(e),[e]),c=RJe(l.size),{data:d}=Ze({queryKey:["printer",i],queryFn:()=>J.getPrinter(i),enabled:i>0}),{data:u}=Ze({queryKey:["printerStatus",i],queryFn:()=>J.getPrinterStatus(i),enabled:i>0,refetchInterval:2e3}),{data:h}=Ze({queryKey:["settings"],queryFn:J.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 k=JSON.parse(A.data);k.type==="printer_status"&&k.printer_id===i&&r.setQueryData(["printerStatus",i],k.status)}catch{}},N.onerror=()=>{},()=>{N.close()}},[i,r]),w.useEffect(()=>(document.title=d?`${d.name} - ${n("streamOverlay.title")}`:n("streamOverlay.title"),()=>{document.title="Bambuddy"}),[d,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(!u)return a.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:a.jsx("p",{className:"text-gray-400",children:n("common.loading")})});const x=u.state==="RUNNING"||u.state==="PAUSE",v=u.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&&d&&a.jsxs("div",{className:`flex items-center ${c.gap} mb-2`,children:[a.jsx(Nr,{className:`${c.icon} text-white/70`}),a.jsx("span",{className:`${c.text} text-white font-medium`,children:d.name})]}),l.showFilename&&u.current_print&&a.jsx("div",{className:`${c.textLarge} text-white font-semibold mb-2 truncate drop-shadow-md`,children:u.current_print.replace(/\.gcode\.3mf$|\.3mf$|\.gcode$/i,"")}),l.showStatus&&a.jsx("div",{className:`${c.text} text-white/70 mb-2`,children:DJe(u,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&&u.layer_num!=null&&u.total_layers!=null&&u.total_layers>0&&a.jsxs("div",{className:`flex items-center ${c.gap} text-white/70`,children:[a.jsx(ri,{className:c.icon}),a.jsxs("span",{className:c.text,children:[a.jsx("span",{className:"text-white",children:u.layer_num}),a.jsx("span",{className:"mx-1",children:"/"}),a.jsx("span",{children:u.total_layers})]})]}),l.showEta&&u.remaining_time!=null&&u.remaining_time>0&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:`flex items-center ${c.gap} text-white/70`,children:[a.jsx(Od,{className:c.icon}),a.jsx("span",{className:`${c.text} text-white`,children:Js(u.remaining_time*60)})]}),a.jsxs("div",{className:`flex items-center ${c.gap} text-white/70`,children:[a.jsx(qn,{className:c.icon}),a.jsxs("span",{className:`${c.text} text-white`,children:[n("streamOverlay.eta")," ",FF(u.remaining_time,f,n)]})]})]})]}),!x&&a.jsx("div",{className:`${c.text} text-white/70 py-2`,children:u.connected?n("streamOverlay.printerIdle"):n("streamOverlay.printerOffline")})]})})]})}function LJe(){const{t}=Dt(),{id:e}=sv(),{mode:n}=ep(),{data:r,isLoading:i,error:s}=Ze({queryKey:["external-link",e],queryFn:()=>J.getExternalLink(Number(e)),enabled:!!e});return i?a.jsx("div",{className:"flex items-center justify-center h-full",children:a.jsx(at,{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(An,{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 uK(){const{id:t}=sv(),e=ac(),n=Qt(),{t:r}=Dt(),{showToast:i}=dn(),s=!!t,[o,l]=w.useState(""),[c,d]=w.useState(""),[u,h]=w.useState([]),[f,p]=w.useState(""),[x,v]=w.useState(!1),{data:g,isLoading:y}=Ze({queryKey:["group",t],queryFn:()=>J.getGroup(Number(t)),enabled:s}),{data:_,isLoading:N}=Ze({queryKey:["permissions"],queryFn:()=>J.getPermissions()});s&&g&&!x&&(l(g.name),d(g.description||""),h(g.permissions),v(!0));const A=st({mutationFn:z=>J.createGroup(z),onSuccess:()=>{n.invalidateQueries({queryKey:["groups"]}),i(r("groups.toast.created")),e("/settings?tab=users")},onError:z=>{i(z.message,"error")}}),k=st({mutationFn:z=>J.updateGroup(Number(t),z),onSuccess:()=>{n.invalidateQueries({queryKey:["groups"]}),i(r("groups.toast.updated")),e("/settings?tab=users")},onError:z=>{i(z.message,"error")}}),P=A.isPending||k.isPending,C=()=>{if(!o.trim()){i(r("groups.toast.enterGroupName"),"error");return}s?k.mutate({name:o!==g?.name?o:void 0,description:c,permissions:u}):A.mutate({name:o,description:c||void 0,permissions:u})},j=z=>{h(W=>W.includes(z)?W.filter(Q=>Q!==z):[...W,z])},M=(z,W)=>{const Q=z.permissions.map(te=>te.value);h(te=>{const H=te.filter(X=>!Q.includes(X));return W?[...H,...Q]:H})},E=z=>z.permissions.every(W=>u.includes(W.value)),B=z=>{const W=z.permissions.filter(Q=>u.includes(Q.value)).length;return W>0&&W<z.permissions.length},L=()=>{_&&h(_.all_permissions)},U=()=>{h([])},D=f.toLowerCase(),$=w.useMemo(()=>_?D?_.categories.map(z=>({...z,permissions:z.permissions.filter(W=>W.label.toLowerCase().includes(D))})).filter(z=>z.permissions.length>0):_.categories:[],[_,D]),q=_?.all_permissions.length??0;return y||N?a.jsx("div",{className:"flex items-center justify-center py-16",children:a.jsx(at,{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(gX,{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(An,{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:z=>l(z.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:z=>d(z.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:u.length})," / ",q]}),a.jsx(Me,{size:"sm",variant:"ghost",onClick:L,children:r("groups.editor.selectAll")}),a.jsx(Me,{size:"sm",variant:"ghost",onClick:U,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:z=>p(z.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"})]})]}),$.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:$.map(z=>{const W=_.categories.find(Z=>Z.name===z.name),Q=W.permissions.filter(Z=>u.includes(Z.value)).length,te=W.permissions.length,H=E(W),X=B(W);return a.jsxs(St,{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(W,!H),className:`w-5 h-5 rounded border flex items-center justify-center transition-colors shrink-0 ${H?"bg-bambu-green border-bambu-green":X?"bg-bambu-green/50 border-bambu-green":"border-bambu-gray hover:border-white"}`,children:[H&&a.jsx(na,{className:"w-3 h-3 text-white"}),X&&!H&&a.jsx(w1,{className:"w-3 h-3 text-white"})]}),a.jsx(d3,{className:"w-4 h-4 text-bambu-gray shrink-0"}),a.jsx("span",{className:"text-white font-medium text-sm",children:z.name})]}),a.jsxs("span",{className:"text-xs text-bambu-gray tabular-nums",children:[Q,"/",te]})]}),a.jsx("div",{className:"p-3 space-y-1",children:z.permissions.map(Z=>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:u.includes(Z.value),onChange:()=>j(Z.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:Z.label})]},Z.value))})]},z.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(Me,{variant:"secondary",onClick:()=>e("/settings?tab=users"),children:r("common.cancel")}),a.jsx(Me,{onClick:C,disabled:P||!o.trim(),children:P?a.jsxs(a.Fragment,{children:[a.jsx(at,{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 hK={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 OJe(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 IJe=["PLA","PETG","ABS","TPU","ASA","PC","PA","PVA","HIPS","PA-CF","PETG-CF","PLA-CF"],zJe=["Bambu","PolyLite","PolyTerra","eSUN","Overture","Fiberon","SUNLU","Inland","Hatchbox","Generic"],c0=["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"}],UJe=[{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"}],mK=[...sse,...UJe],ose="bambuddy-recent-colors",BJe=8,HJe=[{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 Ib(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 d=e.toUpperCase().indexOf(c.toUpperCase());if(d!==-1){r=c,i=d;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 c0)if(o.toLowerCase().includes(c.toLowerCase())){l=c;break}if(!l&&s)for(const c of c0){const d=new RegExp(`\\s+${c}$`,"i");if(d.test(s)){l=c,s=s.replace(d,"").trim();break}}return{brand:s,material:r,variant:l}}function $Je(t,e){const n=new Set(zJe);for(const r of t){const{brand:i}=Ib(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}=Ib(r.name);i&&i.length>1&&n.add(i)}return Array.from(n).sort((r,i)=>r.localeCompare(i))}function VJe(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 qJe(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=VJe(n);if(r.length>0)return r}return HJe}function GJe(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 WJe(){try{const t=localStorage.getItem(ose);if(t)return JSON.parse(t)}catch{}return[]}function KJe(t,e){const n=e.filter(i=>i.hex.toUpperCase()!==t.hex.toUpperCase()),r=[t,...n].slice(0,BJe);try{localStorage.setItem(ose,JSON.stringify(r))}catch{}return r}function Lj(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=Ib(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 XJe({formData:t,updateField:e,cloudAuthenticated:n,loadingCloudPresets:r,presetInputValue:i,setPresetInputValue:s,selectedPresetOption:o,filamentOptions:l,availableBrands:c,availableMaterials:d,quickAdd:u,quantity:h,onQuantityChange:f,errors:p}){const{t:x}=Dt(),[v,g]=w.useState(!1),[y,_]=w.useState(!1),[N,A]=w.useState(!1),[k,P]=w.useState(!1),[C,j]=w.useState(""),[M,E]=w.useState(""),[B,L]=w.useState(""),[U,D]=w.useState(String(t.label_weight)),[$,q]=w.useState(!1),z=w.useRef(null),W=w.useRef(null),Q=w.useRef(null),te=w.useRef(null);w.useEffect(()=>{const oe=ie=>{z.current&&!z.current.contains(ie.target)&&g(!1),te.current&&!te.current.contains(ie.target)&&P(!1),W.current&&!W.current.contains(ie.target)&&_(!1),Q.current&&!Q.current.contains(ie.target)&&A(!1)};return document.addEventListener("mousedown",oe),()=>document.removeEventListener("mousedown",oe)},[]);const H=w.useMemo(()=>{if(!i)return l;const oe=i.toLowerCase();return l.filter(ie=>ie.displayName.toLowerCase().includes(oe)||ie.code.toLowerCase().includes(oe))},[l,i]),X=w.useMemo(()=>{if(!C)return c;const oe=C.toLowerCase();return c.filter(me=>me.toLowerCase().includes(oe)).sort((me,se)=>{const ce=me.toLowerCase()===oe,Ce=se.toLowerCase()===oe;return ce&&!Ce?-1:!ce&&Ce?1:me.localeCompare(se)})},[c,C]),Z=w.useMemo(()=>{if(!M)return c0;const oe=M.toLowerCase();return c0.filter(ie=>ie.toLowerCase().includes(oe))},[M]),ee=w.useMemo(()=>{if(!B)return d;const oe=B.toLowerCase();return d.filter(me=>me.toLowerCase().includes(oe)).sort((me,se)=>{const ce=me.toLowerCase()===oe,Ce=se.toLowerCase()===oe;return ce&&!Ce?-1:!ce&&Ce?1:me.localeCompare(se)})},[B,d]);w.useEffect(()=>{$||D(String(t.label_weight))},[t.label_weight,$]);const Se=oe=>{e("slicer_filament",oe.code),s(oe.displayName),g(!1);const ie=Ib(oe.name);ie.material&&e("material",ie.material),ie.brand&&e("brand",ie.brand),ie.variant&&e("subtype",ie.variant)};return a.jsxs("div",{className:"space-y-4",children:[!u&&a.jsx("div",{className:"flex items-center gap-2 text-xs text-bambu-gray",children:r?a.jsxs(a.Fragment,{children:[a.jsx(at,{className:"w-3 h-3 animate-spin"})," ",x("inventory.loadingPresets")]}):n?a.jsxs(a.Fragment,{children:[a.jsx($b,{className:"w-3 h-3 text-bambu-green"})," ",x("inventory.cloudConnected")]}):a.jsxs(a.Fragment,{children:[a.jsx(Bhe,{className:"w-3 h-3"})," ",x("inventory.cloudNotConnected")]})}),!u&&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:z,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:oe=>{s(oe.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:H.length===0?a.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:x("inventory.noPresetsFound")}):H.map(oe=>a.jsx("button",{type:"button",className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary truncate ${o?.code===oe.code?"bg-bambu-green/10 text-bambu-green":"text-white"}`,onClick:()=>Se(oe),children:oe.displayName},oe.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:te,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:k?B:t.material,onChange:oe=>{L(oe.target.value),P(!0)},onFocus:()=>{P(!0),L("")}}),a.jsx(Mn,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray/50 pointer-events-none"}),k&&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:[ee.length===0?a.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:x("inventory.noResults")}):ee.map(oe=>a.jsx("button",{type:"button",className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${t.material===oe?"bg-bambu-green/10 text-bambu-green":"text-white"}`,onClick:()=>{e("material",oe),P(!1),L("")},children:oe},oe)),B&&!ee.includes(B)&&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",B),P(!1),L("")},children:x("inventory.useCustomMaterial",{material:B})})]})]}),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"),!u&&" *"]}),a.jsxs("div",{className:"relative",ref:W,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?C:t.brand,onChange:oe=>{j(oe.target.value),_(!0)},onFocus:()=>{_(!0),j("")}}),a.jsx(Mn,{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:[X.length===0?a.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:x("inventory.noResults")}):X.map(oe=>a.jsx("button",{type:"button",className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${t.brand===oe?"bg-bambu-green/10 text-bambu-green":"text-white"}`,onClick:()=>{e("brand",oe),_(!1),j("")},children:oe},oe)),C&&!X.includes(C)&&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",C),_(!1),j("")},children:x("inventory.useCustomBrand",{brand:C})})]})]}),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"),!u&&" *"]}),a.jsxs("div",{className:"relative",ref:Q,children:[a.jsx("input",{type:"text",value:N?M:t.subtype,onChange:oe=>{E(oe.target.value),A(!0)},onFocus:()=>{A(!0),E("")},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(Mn,{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:[Z.length===0?a.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:x("inventory.noResults")}):Z.map(oe=>a.jsx("button",{type:"button",className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${t.subtype===oe?"bg-bambu-green/10 text-bambu-green":"text-white"}`,onClick:()=>{e("subtype",oe),A(!1),E("")},children:oe},oe)),M&&!c0.some(oe=>oe.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),E("")},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:U,min:0,onFocus:()=>q(!0),onChange:oe=>D(oe.target.value),onBlur:()=>{q(!1);const oe=U.trim(),ie=Number(oe);if(!oe||!Number.isFinite(ie)||ie<0){D(String(t.label_weight));return}const me=Math.round(ie);e("label_weight",me),D(String(me))}}),a.jsx("span",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-xs text-bambu-gray",children:"g"})]})]}),u&&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:oe=>{const ie=Math.max(1,Math.min(100,parseInt(oe.target.value)||1));f(ie)}})]})]})}function YJe({formData:t,updateField:e,recentColors:n,onColorUsed:r,catalogColors:i}){const{t:s}=Dt(),[o,l]=w.useState(!1),[c,d]=w.useState(""),u=t.rgba.replace("#","").substring(0,6),h=y=>u.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(C=>C.length>=2):[],k=C=>{if(A.length===0)return!0;const j=C.toLowerCase();return A.some(M=>j.includes(M))};if(y&&!_){const C=i.filter(j=>k(j.manufacturer));if(C.length>0)return C.map(j=>({name:j.color_name,hex:j.hex_color.replace("#","").substring(0,6),manufacturer:j.manufacturer,material:typeof j.material=="string"?j.material:void 0}))}const P=_&&N?`${_} ${N}`:"";if(P){const C=i.filter(M=>k(M.manufacturer)&&M.material?.toLowerCase()===P);if(C.length>0)return C.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 j=P.replace(/\+$/,"");if(j!==P){const M=i.filter(E=>k(E.manufacturer)&&E.material?.toLowerCase()===j);if(M.length>0)return M.map(E=>({name:E.color_name,hex:E.hex_color.replace("#","").substring(0,6),manufacturer:E.manufacturer,material:typeof E.material=="string"?E.material:void 0}))}}if(_){const C=i.filter(j=>k(j.manufacturer)&&(!j.material||j.material.toLowerCase().startsWith(_)));if(C.length>0)return C.map(j=>({name:j.color_name,hex:j.hex_color.replace("#","").substring(0,6),manufacturer:j.manufacturer,material:typeof j.material=="string"?j.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?mK.filter(y=>y.name.toLowerCase().includes(c.toLowerCase())):o?mK: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:`#${u}`}}),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(qn,{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=>d(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(wl,{className:"w-3 h-3"})]}):a.jsxs(a.Fragment,{children:[s("inventory.showAll")," ",a.jsx(Mn,{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:u.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:`#${u}`,onChange:y=>{const _=y.target.value.replace("#","").toUpperCase();e("rgba",_+"FF")},title:s("inventory.pickColor")})]})]})]})]})}function QJe({catalog:t,value:e,onChange:n,catalogId:r,onCatalogIdChange:i}){const{t:s}=Dt(),[o,l]=w.useState(!1),[c,d]=w.useState(""),u=w.useRef(null),h=w.useRef(null);w.useEffect(()=>{const v=g=>{u.current&&!u.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(upe,{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:u,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),d("")},onChange:v=>{d(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),d("")},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 ZJe({formData:t,updateField:e,spoolCatalog:n,currencySymbol:r}){const{t:i}=Dt(),{showToast:s}=dn(),[o,l]=w.useState(""),[c,d]=w.useState(!1),[u,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(QJe,{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:u,min:0,max:t.label_weight,onFocus:()=>p(!0),onChange:g=>{h(g.target.value)},onBlur:()=>{p(!1);const g=u.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:()=>d(!0),onChange:g=>{l(g.target.value)},onBlur:()=>{d(!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),k=Math.max(0,Math.min(t.label_weight,A-t.core_weight));e("weight_used",Math.max(0,t.label_weight-k)),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 JJe({formData:t,printersWithCalibrations:e,selectedProfiles:n,setSelectedProfiles:r,expandedPrinters:i,setExpandedPrinters:s}){const{t:o}=Dt(),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 _})},d=()=>{const f=new Set;for(const{printer:p,calibrations:x}of e){if(!p.connected)continue;const v=x.filter(y=>Lj(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((k,P)=>P.k_value-k.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 u=e.reduce((f,{printer:p,calibrations:x})=>p.connected?f+x.filter(v=>Lj(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")]}),u>0&&a.jsxs("button",{type:"button",onClick:d,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(hb,{className:"w-3.5 h-3.5"}),o("inventory.autoSelect")," (",u,")"]})]}),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=>Lj(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(Mn,{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 eet(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 tet={completed:"text-bambu-green",failed:"text-red-400",aborted:"text-yellow-400"};function net({spoolId:t}){const{t:e}=Dt(),n=Qt(),{showToast:r}=dn(),{data:i,isLoading:s}=Ze({queryKey:["spool-usage",t],queryFn:()=>J.getSpoolUsageHistory(t)}),o=st({mutationFn:()=>J.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(at,{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(qn,{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(Me,{variant:"ghost",size:"sm",onClick:()=>o.mutate(),disabled:o.isPending,className:"text-xs text-bambu-gray hover:text-red-400",children:[a.jsx(Yt,{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:eet(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:tet[l.status]||"text-bambu-gray",children:l.status})]})]},l.id))})]})}function ret({isOpen:t,onClose:e,spool:n,printersWithCalibrations:r=[],currencySymbol:i}){const{t:s}=Dt(),o=Qt(),{showToast:l}=dn(),c=!!n,[d,u]=w.useState(hK),[h,f]=w.useState({}),[p,x]=w.useState("filament"),[v,g]=w.useState(!1),[y,_]=w.useState(!1),[N,A]=w.useState(1),[k,P]=w.useState(!1),[C,j]=w.useState(!1),[M,E]=w.useState([]),[B,L]=w.useState(""),[U,D]=w.useState([]),[$,q]=w.useState([]),[z,W]=w.useState([]),[Q,te]=w.useState([]),[H,X]=w.useState([]),[Z,ee]=w.useState(new Set),[Se,oe]=w.useState(new Set),ie=r.length>0?r:H,me=w.useMemo(()=>Z.size,[Z]);w.useEffect(()=>{te(WJe())},[]),w.useEffect(()=>{t&&((async()=>{j(!0);try{const ge=await J.getCloudStatus();if(P(ge.is_authenticated),ge.is_authenticated){const ae=await J.getFilamentPresets();E(ae)}}catch(ge){console.error("Failed to fetch cloud presets:",ge),P(!1)}finally{j(!1)}})(),J.getSpoolCatalog().then(D).catch(console.error),J.getColorCatalog().then(W).catch(console.error),J.getLocalPresets().then(ge=>q(ge.filament)).catch(console.error),r.length===0&&(async()=>{try{const ge=await J.getPrinters(),ae=await Promise.all(ge.map(ze=>J.getPrinterStatus(ze.id).catch(()=>null))),Ue=[];for(let ze=0;ze<ge.length;ze++){const $e=ge[ze],pe=ae[ze]?.connected??!1;let ve=[];if(pe)try{ve=(await J.getKProfiles($e.id)).profiles.map(xe=>({cali_idx:xe.slot_id,filament_id:xe.filament_id,setting_id:xe.setting_id||"",name:xe.name,k_value:parseFloat(xe.k_value)||0,n_coef:parseFloat(xe.n_coef)||0,extruder_id:xe.extruder_id,nozzle_diameter:xe.nozzle_diameter}))}catch{}Ue.push({printer:{...$e,connected:pe},calibrations:ve})}X(Ue)}catch(ge){console.error("Failed to fetch printer calibrations:",ge)}})())},[t,r.length]);const se=w.useMemo(()=>qJe(M,new Set,$),[M,$]),ce=w.useMemo(()=>{const de=$Je(M,$),ge=z.map(Ue=>Ue.manufacturer?.trim()).filter(Ue=>!!Ue),ae=new Set([...de,...ge]);return Array.from(ae).sort((Ue,ze)=>Ue.localeCompare(ze))},[M,$,z]),Ce=w.useMemo(()=>{const de=z.map(ae=>ae.material?.trim()).filter(ae=>!!ae),ge=new Set([...IJe,...de]);return Array.from(ge).sort((ae,Ue)=>ae.localeCompare(Ue))},[z]),le=w.useMemo(()=>{const de=[];for(const ge of z){const ae=ge.manufacturer?.trim(),Ue=ge.material?.trim();ae&&Ue&&de.push({brand:ae,material:Ue})}for(const ge of M){const ae=Ib(ge.name);ae.brand&&ae.material&&de.push({brand:ae.brand,material:ae.material})}for(const ge of $){const ae=Ib(ge.name),Ue=ge.filament_vendor?.trim()||ae.brand,ze=ae.material;Ue&&ze&&de.push({brand:Ue,material:ze})}return de},[M,z,$]),Le=w.useMemo(()=>{const de=new Map;for(const ge of le){const ae=ge.brand.toLowerCase(),Ue=ge.material.toLowerCase();de.has(ae)||de.set(ae,new Set),de.get(ae).add(Ue)}return de},[le]),V=w.useMemo(()=>{const de=new Map;for(const ge of le){const ae=ge.brand.toLowerCase(),Ue=ge.material.toLowerCase();de.has(Ue)||de.set(Ue,new Set),de.get(Ue).add(ae)}return de},[le]),K=w.useMemo(()=>{if(!d.material)return ce;const de=d.material.toLowerCase(),ge=V.get(de);return!ge||ge.size===0?ce:ce.filter(ae=>ge.has(ae.toLowerCase()))},[ce,d.material,V]),fe=w.useMemo(()=>{if(!d.brand)return Ce;const de=d.brand.toLowerCase(),ge=Le.get(de);return!ge||ge.size===0?Ce:Ce.filter(ae=>ge.has(ae.toLowerCase()))},[Ce,d.brand,Le]),Y=w.useMemo(()=>GJe(d.slicer_filament,se),[d.slicer_filament,se]);w.useEffect(()=>{if(t){if(n)if(u({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}),L(n.slicer_filament_name||n.slicer_filament||""),n.k_profiles&&n.k_profiles.length>0){const de=new Set;for(const ge of n.k_profiles)ge.cali_idx!==null&&ge.cali_idx!==void 0&&de.add(`${ge.printer_id}:${ge.cali_idx}:${ge.extruder??"null"}`);ee(de)}else ee(new Set);else u(hK),L(""),ee(new Set),_(!1),A(1);f({}),x("filament"),g(!1)}},[t,n]),w.useEffect(()=>{t&&ie.length>0&&oe(new Set(ie.map(de=>String(de.printer.id))))},[t,ie]);const re=(de,ge)=>{u(ae=>({...ae,[de]:ge})),de==="weight_used"&&g(!0),h[de]&&f(ae=>({...ae,[de]:void 0}))},ue=de=>{te(ge=>KJe(de,ge))},Fe=st({mutationFn:de=>J.createSpool(de),onSuccess:async de=>{Z.size>0&&de?.id&&await O(de.id),await o.invalidateQueries({queryKey:["inventory-spools"]}),l(s("inventory.spoolCreated"),"success"),e()},onError:de=>{l(de.message,"error")}}),Pe=st({mutationFn:({data:de,qty:ge})=>J.bulkCreateSpools(de,ge),onSuccess:async de=>{if(Z.size>0)for(const ge of de)await O(ge.id);await o.invalidateQueries({queryKey:["inventory-spools"]}),l(s("inventory.spoolsCreated",{count:de.length}),"success"),e()},onError:de=>{l(de.message,"error")}}),be=st({mutationFn:de=>J.updateSpool(n.id,de),onSuccess:async()=>{n?.id&&await O(n.id),await o.invalidateQueries({queryKey:["inventory-spools"]}),l(s("inventory.spoolUpdated"),"success"),e()},onError:de=>{l(de.message,"error")}}),O=async de=>{if(Z.size===0){try{await J.saveSpoolKProfiles(de,[])}catch{}return}const ge=[];for(const ae of Z){const[Ue,ze,$e]=ae.split(":"),Re=parseInt(Ue),pe=parseInt(ze),ve=$e==="null"?0:parseInt($e),Ne=ie.find(xe=>xe.printer.id===Re);if(Ne){const xe=Ne.calibrations.find(we=>we.cali_idx===pe);xe&&ge.push({printer_id:Re,extruder:ve,nozzle_diameter:xe.nozzle_diameter||"0.4",k_value:xe.k_value,name:xe.name||null,cali_idx:xe.cali_idx,setting_id:xe.setting_id||null})}}if(ge.length>0)try{await J.saveSpoolKProfiles(de,ge)}catch(ae){console.error("Failed to save K-profiles:",ae)}};if(w.useEffect(()=>{if(!t)return;const de=ge=>{ge.key==="Escape"&&e()};return document.addEventListener("keydown",de),()=>document.removeEventListener("keydown",de)},[t,e]),!t)return null;const R=()=>{const de=OJe(d,y);if(!de.isValid){f(de.errors),(de.errors.slicer_filament||de.errors.material||de.errors.brand||de.errors.subtype)&&x("filament");return}const ge=Y?.displayName||B||null,ae={material:d.material,subtype:d.subtype||null,brand:d.brand||null,color_name:d.color_name||null,rgba:d.rgba||null,label_weight:d.label_weight,core_weight:d.core_weight,core_weight_catalog_id:d.core_weight_catalog_id,slicer_filament:d.slicer_filament||null,slicer_filament_name:ge,nozzle_temp_min:null,nozzle_temp_max:null,note:d.note||null,cost_per_kg:d.cost_per_kg};(!c||v)&&(ae.weight_used=d.weight_used),c?be.mutate(ae):N>1?Pe.mutate({data:ae,qty:N}):Fe.mutate(ae)},G=Fe.isPending||Pe.isPending||be.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(Rt,{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(ru,{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(KC,{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(Jue,{className:"w-4 h-4"}),s("inventory.paProfileTab"),me>0&&a.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded-full bg-bambu-green/20 text-bambu-green",children:me})]})]}),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(XJe,{formData:d,updateField:re,cloudAuthenticated:k,loadingCloudPresets:C,presetInputValue:B,setPresetInputValue:L,selectedPresetOption:Y,filamentOptions:se,availableBrands:K,availableMaterials:fe,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(YJe,{formData:d,updateField:re,recentColors:Q,onColorUsed:ue,catalogColors:z})]}),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(ZJe,{formData:d,updateField:re,spoolCatalog:U,currencySymbol:i})]}),c&&n&&a.jsx("div",{children:a.jsx(net,{spoolId:n.id})})]}):a.jsx(JJe,{formData:d,updateField:re,printersWithCalibrations:ie,selectedProfiles:Z,setSelectedProfiles:ee,expandedPrinters:Se,setExpandedPrinters:oe})}),a.jsxs("div",{className:"flex justify-end gap-2 p-4 border-t border-bambu-dark-tertiary flex-shrink-0",children:[a.jsx(Me,{variant:"secondary",onClick:e,children:s("common.cancel")}),a.jsx(Me,{onClick:R,disabled:G,children:G?a.jsxs(a.Fragment,{children:[a.jsx(at,{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 aet({isOpen:t,onClose:e,columns:n,defaultColumns:r,onSave:i}){const{t:s}=Dt(),[o,l]=w.useState(n),[c,d]=w.useState(null),u=w.useRef(null);if(w.useEffect(()=>{t&&l(n.map(A=>({...A})))},[t,n]),w.useEffect(()=>{if(!t)return;const A=k=>{k.key==="Escape"&&e()};return window.addEventListener("keydown",A),()=>window.removeEventListener("keydown",A)},[t,e]),!t)return null;const h=A=>{l(k=>k.map((P,C)=>C===A?{...P,visible:!P.visible}:P))},f=(A,k)=>{k<0||k>=o.length||l(P=>{const C=[...P],[j]=C.splice(A,1);return C.splice(k,0,j),C})},p=(A,k)=>{u.current=k,d(k),A.dataTransfer.effectAllowed="move"},x=(A,k)=>{A.preventDefault(),A.dataTransfer.dropEffect="move";const P=u.current;P!==null&&P!==k&&(f(P,k),u.current=k,d(k))},v=A=>{A.preventDefault()},g=()=>{u.current=null,d(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(St,{className:"w-full max-w-md max-h-[80vh] flex flex-col",onClick:A=>A.stopPropagation(),children:a.jsxs(Nt,{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,k)=>a.jsxs("div",{className:`flex items-center gap-2 p-2 rounded-lg border transition-colors ${c===k?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary bg-bambu-dark-tertiary/50"} ${A.visible?"":"opacity-50"}`,draggable:!0,onDragStart:P=>p(P,k),onDragOver:P=>x(P,k),onDrop:v,onDragEnd:g,children:[a.jsx("div",{className:"cursor-grab text-bambu-gray/50 hover:text-bambu-gray",children:a.jsx(jh,{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(k,k-1),disabled:k===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(wl,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>f(k,k+1),disabled:k===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(Mn,{className:"w-4 h-4"})})]}),a.jsx("button",{onClick:()=>h(k),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(Zl,{className:"w-4 h-4"}):a.jsx(cv,{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(Me,{variant:"secondary",onClick:y,className:"mr-auto",children:[a.jsx(lo,{className:"w-4 h-4"}),s("inventory.reset")]}),a.jsx(Me,{variant:"secondary",onClick:e,children:s("inventory.cancel")}),a.jsx(Me,{onClick:_,children:s("inventory.applyChanges")})]})]})})})}function fK(t){return`${t.material}|${t.subtype||""}|${t.brand||""}|${t.color_name||""}|${t.rgba||""}|${t.label_weight}`}const lse="bambuddy-inventory-columns",u1=[{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}];function iet(){try{const t=localStorage.getItem(lse);if(t){const e=JSON.parse(t),n=new Set(u1.map(o=>o.id)),r=new Set(e.map(o=>o.id)),i=e.filter(o=>n.has(o.id)),s=u1.filter(o=>!r.has(o.id));return[...i,...s]}}catch{}return u1.map(t=>({...t}))}function set(t){try{localStorage.setItem(lse,JSON.stringify(t))}catch{}}function Ec(t,e=!1){return e&&t>=1e3?`${(t/1e3).toFixed(1)}kg`:`${Math.round(t)}g`}const oet={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 Oj(t,e="system"){if(!t)return"-";const n=tr(t);return n?h3(n,e):"-"}const cet={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")},oF={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:Oj(t.created_at,e)}),encode_time:({spool:t,dateFormat:e})=>a.jsx("span",{className:"text-sm text-bambu-gray",children:Oj(t.encode_time,e)}),last_used_time:({spool:t,dateFormat:e})=>a.jsx("span",{className:"text-sm text-bambu-gray",children:t.last_used?Oj(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:xO(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=pO(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)}`:"-"})},Ij={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||""} ${pO(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},lF="bambuddy-inventory-sort";function det(){try{const t=localStorage.getItem(lF);if(t)return JSON.parse(t)}catch{}return null}function uet(t){try{t?localStorage.setItem(lF,JSON.stringify(t)):localStorage.removeItem(lF)}catch{}}function het(){const{data:t}=Ze({queryKey:["spoolman-settings"],queryFn:J.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(met,{})}function met(){const{t}=Dt(),e=Qt(),{showToast:n}=dn(),[r,i]=w.useState(null),[s,o]=w.useState(null),[l,c]=w.useState("active"),[d,u]=w.useState("all"),[h,f]=w.useState(""),[p,x]=w.useState(""),[v,g]=w.useState("all"),[y,_]=w.useState(""),[N,A]=w.useState("table"),[k,P]=w.useState(det),[C,j]=w.useState(iet),[M,E]=w.useState(!1),[B,L]=w.useState(()=>{try{return localStorage.getItem("bambuddy-inventory-group")==="true"}catch{return!1}}),[U,D]=w.useState(new Set),[$,q]=w.useState(0),[z,W]=w.useState(()=>{try{const Re=localStorage.getItem("bambuddy-inventory-pageSize");if(Re){const pe=Number(Re);if([15,30,50,100,-1].includes(pe))return pe}}catch{}return 15}),{data:Q}=Ze({queryKey:["settings"],queryFn:J.getSettings}),te=Q?.date_format||"system",{data:H,isLoading:X}=Ze({queryKey:["inventory-spools"],queryFn:()=>J.getSpools(!0),refetchInterval:3e4}),{data:Z}=Ze({queryKey:["spool-assignments"],queryFn:()=>J.getAssignments(),refetchInterval:3e4}),ee=st({mutationFn:Re=>J.deleteSpool(Re),onSuccess:()=>{e.invalidateQueries({queryKey:["inventory-spools"]}),n(t("inventory.spoolDeleted"),"success")}}),Se=st({mutationFn:Re=>J.archiveSpool(Re),onSuccess:()=>{e.invalidateQueries({queryKey:["inventory-spools"]}),n(t("inventory.spoolArchived"),"success")}}),oe=st({mutationFn:Re=>J.restoreSpool(Re),onSuccess:()=>{e.invalidateQueries({queryKey:["inventory-spools"]}),n(t("inventory.spoolRestored"),"success")}}),ie=w.useMemo(()=>{if(!H)return null;let Re=0,pe=0,ve=0,Ne=0;const xe={};for(const we of H){if(we.archived_at)continue;Ne++;const qe=Math.max(0,we.label_weight-we.weight_used);Re+=qe,pe+=we.weight_used,(we.label_weight>0?qe/we.label_weight*100:0)<20&&ve++;const nt=we.material||"Unknown";xe[nt]||(xe[nt]={count:0,weight:0}),xe[nt].count++,xe[nt].weight+=qe}return{totalWeight:Re,totalConsumed:pe,lowStock:ve,byMaterial:xe,totalSpools:Ne}},[H]),me=Z?.length??0,se=il(Q?.currency||"USD"),ce=w.useMemo(()=>{const Re={};for(const pe of Z||[])Re[pe.spool_id]=pe;return Re},[Z]),Ce=w.useMemo(()=>ie?Object.entries(ie.byMaterial).sort((Re,pe)=>pe[1].weight-Re[1].weight).slice(0,4):[],[ie]),le=w.useMemo(()=>{let Re=H||[];if(l==="active"?Re=Re.filter(pe=>!pe.archived_at):Re=Re.filter(pe=>!!pe.archived_at),d==="used"?Re=Re.filter(pe=>pe.weight_used>0):d==="new"&&(Re=Re.filter(pe=>pe.weight_used===0)),h&&(Re=Re.filter(pe=>pe.material===h)),p&&(Re=Re.filter(pe=>pe.brand===p)),v==="stock"?Re=Re.filter(pe=>!pe.slicer_filament):v==="configured"&&(Re=Re.filter(pe=>!!pe.slicer_filament)),y){const pe=y.toLowerCase();Re=Re.filter(ve=>ve.brand?.toLowerCase().includes(pe)||ve.material.toLowerCase().includes(pe)||ve.color_name?.toLowerCase().includes(pe)||ve.subtype?.toLowerCase().includes(pe)||ve.note?.toLowerCase().includes(pe)||ve.slicer_filament_name?.toLowerCase().includes(pe))}return Re},[H,l,d,h,p,v,y]),Le=()=>q(0),V=[...new Set(H?.map(Re=>Re.material)||[])].sort(),K=[...new Set(H?.map(Re=>Re.brand).filter(Boolean)||[])].sort(),fe=l!=="active"||d!=="all"||!!h||!!p||v!=="all"||!!y,Y=Re=>{j(Re),set(Re)},re=w.useMemo(()=>C.filter(Re=>Re.visible).map(Re=>Re.id),[C]),ue=Re=>{Ij[Re]&&(P(pe=>{let ve;return pe?.column===Re?ve=pe.direction==="asc"?{column:Re,direction:"desc"}:null:ve={column:Re,direction:"asc"},uet(ve),ve}),Le())},Fe=w.useMemo(()=>{if(!k)return le;const Re=Ij[k.column];return Re?[...le].sort((ve,Ne)=>{const xe=Re(ve,ce),we=Re(Ne,ce);return xe<we?k.direction==="asc"?-1:1:xe>we?k.direction==="asc"?1:-1:0}):le},[le,k,ce]),Pe=w.useMemo(()=>{if(!B)return Fe.map(Ne=>({type:"single",spool:Ne}));const Re=new Map;for(const Ne of Fe)if(!(Ne.weight_used>0||ce[Ne.id])){const xe=fK(Ne),we=Re.get(xe);we?we.push(Ne):Re.set(xe,[Ne])}const pe=[],ve=new Set;for(const Ne of Fe){if(Ne.weight_used>0||ce[Ne.id]){pe.push({type:"single",spool:Ne});continue}const xe=fK(Ne);if(ve.has(xe))continue;ve.add(xe);const we=Re.get(xe);we.length===1?pe.push({type:"single",spool:we[0]}):pe.push({type:"group",key:xe,spools:we,representative:we[0]})}return pe},[Fe,B,ce]),be=z===-1,O=Pe.length,R=be?O||1:z,G=Math.max(1,Math.ceil(O/R)),de=be?0:Math.min($,G-1),ge=be?Pe:Pe.slice(de*R,(de+1)*R),ae=()=>{const Re=!B;L(Re),D(new Set),Le();try{localStorage.setItem("bambuddy-inventory-group",String(Re))}catch{}},Ue=Re=>{D(pe=>{const ve=new Set(pe);return ve.has(Re)?ve.delete(Re):ve.add(Re),ve})},ze=Re=>{W(Re),q(0);try{localStorage.setItem("bambuddy-inventory-pageSize",String(Re))}catch{}},$e=()=>{c("active"),u("all"),f(""),x(""),g("all"),_(""),Le()};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(fi,{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(Me,{onClick:()=>i({spool:null}),children:[a.jsx(Xn,{className:"w-4 h-4"}),t("inventory.addSpool")]})]}),ie&&!X&&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(fi,{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(ie.totalWeight,!0)}),a.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:[ie.totalSpools," ",ie.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(EF,{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(ie.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(ri,{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:Ce.map(([Re,pe])=>a.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium ${oet[Re]||"bg-bambu-dark-tertiary text-bambu-gray"}`,children:[Re," ",a.jsx("span",{className:"opacity-70",children:Ec(pe.weight,!0)})]},Re))})]}),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(Nr,{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:me}),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(An,{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 ${ie.lowStock>0?"text-yellow-400":"text-white"}`,children:ie.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:Re=>{_(Re.target.value),Le()},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:()=>{_(""),Le()},className:"absolute right-3 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",children:a.jsx(Rt,{className:"w-4 h-4"})})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[N==="table"&&a.jsxs("button",{onClick:()=>E(!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(Jhe,{className:"w-4 h-4"}),a.jsx("span",{className:"hidden sm:inline",children:t("inventory.columns")})]}),a.jsxs("button",{onClick:ae,className:`flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium border rounded-lg transition-colors ${B?"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(Wme,{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(zpe,{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(uv,{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"),Le()},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(fi,{className:"w-3.5 h-3.5"}),t("inventory.active")]}),a.jsxs("button",{onClick:()=>{c("archived"),Le()},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(Ds,{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:()=>{u("all"),Le()},className:`px-3 py-1.5 text-xs font-medium transition-colors ${d==="all"?"bg-bambu-green/20 text-bambu-green":"text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:t("inventory.all")}),a.jsxs("button",{onClick:()=>{u("used"),Le()},className:`flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium transition-colors ${d==="used"?"bg-bambu-green/20 text-bambu-green":"text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:[a.jsx(qn,{className:"w-3.5 h-3.5"}),t("inventory.used")]}),a.jsx("button",{onClick:()=>{u("new"),Le()},className:`px-3 py-1.5 text-xs font-medium transition-colors ${d==="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"),Le()},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"),Le()},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"),Le()},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:Re=>{f(Re.target.value),Le()},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(Re=>a.jsx("option",{value:Re,children:Re},Re))]}),a.jsxs("select",{value:p,onChange:Re=>{x(Re.target.value),Le()},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")}),K.map(Re=>a.jsx("option",{value:Re,children:Re},Re))]}),fe&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary"}),a.jsxs("button",{onClick:$e,className:"flex items-center gap-1 text-xs text-bambu-gray hover:text-bambu-green transition-colors",children:[a.jsx(Rt,{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"),B&&O<Fe.length&&` (${O} ${t("inventory.groupedRows")})`]})]}),X?a.jsx("div",{className:"flex justify-center py-16",children:a.jsx(at,{className:"w-8 h-8 text-bambu-green animate-spin"})}):N==="cards"?ge.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:ge.map(Re=>{if(Re.type==="group"){const{key:we,spools:qe,representative:ke}=Re,nt=ke.rgba?`#${ke.rgba.substring(0,6)}`:"#808080",De=U.has(we);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:()=>Ue(we),children:[a.jsx("div",{className:"h-10 flex items-center px-4 gap-3",style:{backgroundColor:nt},children:a.jsx("span",{className:"bg-white/90 text-gray-800 px-3 py-0.5 rounded-full text-sm font-medium",children:xO(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(Mn,{className:`w-4 h-4 text-bambu-gray transition-transform ${De?"":"-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:qe.length})})]})]})]}),De&&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:qe.map(We=>{const Oe=Math.max(0,We.label_weight-We.weight_used),je=We.label_weight>0?Oe/We.label_weight*100:0,Ve=We.rgba?`#${We.rgba.substring(0,6)}`:"#808080";return a.jsx(pK,{spool:We,remaining:Oe,pct:je,colorStyle:Ve,onClick:()=>i({spool:We}),t},We.id)})})]},`group-${we}`)}const pe=Re.spool,ve=Math.max(0,pe.label_weight-pe.weight_used),Ne=pe.label_weight>0?ve/pe.label_weight*100:0,xe=pe.rgba?`#${pe.rgba.substring(0,6)}`:"#808080";return a.jsx(pK,{spool:pe,remaining:ve,pct:Ne,colorStyle:xe,onClick:()=>i({spool:pe}),t},pe.id)})}),a.jsx(fet,{pageIndex:de,pageSize:z,totalRows:O,totalPages:G,onPageChange:q,onPageSizeChange:ze,t})]}):a.jsx(gK,{hasFilters:fe,onAddSpool:()=>i({spool:null}),t}):ge.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:[re.map(Re=>{const pe=!!Ij[Re],ve=k?.column===Re;return a.jsx("th",{className:`text-left py-3 px-4 text-xs font-medium uppercase tracking-wide select-none ${Re==="remaining"?"min-w-[150px]":""} ${pe?"cursor-pointer hover:text-bambu-green transition-colors":""} ${ve?"text-bambu-green":"text-bambu-gray"}`,onClick:pe?()=>ue(Re):void 0,children:a.jsxs("span",{className:"inline-flex items-center gap-1",children:[cet[Re]?.(t)??Re,pe&&(ve?k.direction==="asc"?a.jsx(Mf,{className:"w-3 h-3"}):a.jsx(cb,{className:"w-3 h-3"}):a.jsx(kF,{className:"w-3 h-3 opacity-30"}))]})},Re)}),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:ge.map(Re=>{if(Re.type==="group"){const{key:xe,spools:we,representative:qe}=Re,ke=U.has(xe),nt=Math.max(0,qe.label_weight-qe.weight_used),De=qe.label_weight>0?nt/qe.label_weight*100:0;return a.jsx(pet,{spools:we,representative:qe,remaining:nt,pct:De,isExpanded:ke,onToggle:()=>Ue(xe),onEdit:We=>i({spool:We}),onArchive:We=>o({type:"archive",spoolId:We}),onDelete:We=>o({type:"delete",spoolId:We}),visibleColumns:re,assignmentMap:ce,currencySymbol:se,dateFormat:te,t},`group-${xe}`)}const pe=Re.spool,ve=Math.max(0,pe.label_weight-pe.weight_used),Ne=pe.label_weight>0?ve/pe.label_weight*100:0;return a.jsx(cse,{spool:pe,remaining:ve,pct:Ne,onEdit:()=>i({spool:pe}),onRestore:()=>oe.mutate(pe.id),onArchive:()=>o({type:"archive",spoolId:pe.id}),onDelete:()=>o({type:"delete",spoolId:pe.id}),visibleColumns:re,assignmentMap:ce,currencySymbol:se,dateFormat:te,t},pe.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:be?`${O} ${t(O!==1?"inventory.spools":"inventory.spool")}`:a.jsxs(a.Fragment,{children:[t("inventory.showing")," ",de*R+1," ",t("inventory.to")," ",Math.min((de+1)*R,O)," ",t("inventory.of")," ",O," ",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:z,onChange:Re=>ze(Number(Re.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(Re=>a.jsx("option",{value:Re,children:Re},Re)),a.jsx("option",{value:-1,children:t("inventory.all")})]}),!be&&a.jsxs(a.Fragment,{children:[a.jsx("button",{onClick:()=>q(0),disabled:de===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(xX,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>q(Re=>Math.max(0,Re-1)),disabled:de===0,className:"p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:a.jsx(Yl,{className:"w-4 h-4"})}),a.jsxs("span",{className:"text-bambu-gray px-2 whitespace-nowrap",children:[t("inventory.page")," ",de+1," ",t("inventory.of")," ",G]}),a.jsx("button",{onClick:()=>q(Re=>Math.min(G-1,Re+1)),disabled:de>=G-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:()=>q(G-1),disabled:de>=G-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(yX,{className:"w-4 h-4"})})]})]})]})]}):a.jsx(gK,{hasFilters:fe,onAddSpool:()=>i({spool:null}),t}),r!==null&&a.jsx(ret,{isOpen:!0,onClose:()=>i(null),spool:r.spool,currencySymbol:se}),s&&a.jsx(xn,{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"?ee.mutate(s.spoolId):Se.mutate(s.spoolId),o(null)},onCancel:()=>o(null)}),a.jsx(aet,{isOpen:M,onClose:()=>E(!1),columns:C,defaultColumns:u1,onSave:Y})]})}function fet({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:d=>s(Number(d.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(d=>a.jsx("option",{value:d,children:d},d)),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(xX,{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(Yl,{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(yX,{className:"w-4 h-4"})})]})]})]})}function pK({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:xO(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 cse({spool:t,remaining:e,pct:n,onEdit:r,onRestore:i,onArchive:s,onDelete:o,visibleColumns:l,assignmentMap:c,currencySymbol:d,dateFormat:u,t:h}){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(f=>a.jsx("td",{className:"py-3 px-4",children:oF[f]?.({spool:t,remaining:e,pct:n,assignmentMap:c,currencySymbol:d,dateFormat:u,t:h})},f)),a.jsx("td",{className:"py-3 px-4",children:a.jsxs("div",{className:"flex items-center justify-end gap-1",onClick:f=>f.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(ef,{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(lo,{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(Ds,{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(Yt,{className:"w-4 h-4"})})]})})]})}function pet({spools:t,representative:e,remaining:n,pct:r,isExpanded:i,onToggle:s,onEdit:o,onArchive:l,onDelete:c,visibleColumns:d,assignmentMap:u,currencySymbol:h,dateFormat:f,t:p}){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:[d.map((x,v)=>a.jsx("td",{className:"py-3 px-4",children:v===0?a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Mn,{className:`w-4 h-4 text-bambu-gray transition-transform ${i?"":"-rotate-90"}`}),oF[x]?.({spool:e,remaining:n,pct:r,assignmentMap:u,currencySymbol:h,dateFormat:f,t:p})]}):x==="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})}):oF[x]?.({spool:e,remaining:n,pct:r,assignmentMap:u,currencySymbol:h,dateFormat:f,t:p})},x)),a.jsx("td",{className:"py-3 px-4",children:a.jsx("span",{className:"text-xs text-bambu-gray",children:t.map(x=>`#${x.id}`).join(", ")})})]}),i&&t.map(x=>{const v=Math.max(0,x.label_weight-x.weight_used),g=x.label_weight>0?v/x.label_weight*100:0;return a.jsx(cse,{spool:x,remaining:v,pct:g,onEdit:()=>o(x),onRestore:()=>{},onArchive:()=>l(x.id),onDelete:()=>c(x.id),visibleColumns:d,assignmentMap:u,currencySymbol:h,dateFormat:f,t:p},x.id)})]})}function gK({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(Me,{onClick:e,children:[a.jsx(fi,{className:"w-4 h-4"}),n("inventory.addSpool")]})]})}const bK=["DEBUG","INFO","WARNING","ERROR"],zj={DEBUG:"text-gray-400",INFO:"text-blue-400",WARNING:"text-yellow-400",ERROR:"text-red-400"},get={DEBUG:BC,INFO:eo,WARNING:An,ERROR:Va};function bet(){const t=Qt(),[e,n]=w.useState(!0),[r,i]=w.useState(new Set),[s,o]=w.useState(""),[l,c]=w.useState("ALL"),[d,u]=w.useState(!1),[h,f]=w.useState(!1),p=w.useRef(null),{data:x,isLoading:v,refetch:g}=Ze({queryKey:["application-logs",l,s],queryFn:()=>Kg.getLogs({limit:200,level:l==="ALL"?void 0:l,search:s||void 0}),refetchInterval:h?2e3:!1,enabled:d});w.useEffect(()=>{d||f(!1)},[d]);const y=st({mutationFn:()=>Kg.clearLogs(),onSuccess:()=>{t.invalidateQueries({queryKey:["application-logs"]})}});w.useEffect(()=>{e&&p.current&&x?.entries&&(p.current.scrollTop=p.current.scrollHeight)},[x?.entries,e]);const _=C=>{i(j=>{const M=new Set(j);return M.has(C)?M.delete(C):M.add(C),M})},N=C=>{const j=C.split(" ");return j.length>=2?j[1]:C},A=w.useMemo(()=>x?.entries??[],[x?.entries]),k=w.useMemo(()=>[...A].reverse(),[A]),P=({level:C})=>{const j=get[C]||eo;return a.jsx(j,{className:`w-3.5 h-3.5 ${zj[C]||"text-gray-400"}`})};return a.jsxs("div",{className:"bg-bambu-dark rounded-lg overflow-hidden",children:[a.jsxs("button",{onClick:()=>u(!d),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(BC,{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"]}),d?a.jsx(wl,{className:"w-5 h-5 text-bambu-gray"}):a.jsx(Mn,{className:"w-5 h-5 text-bambu-gray"})]})]}),d&&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:C=>{C.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(Sl,{className:"w-4 h-4"}),"Stop"]}):a.jsxs("button",{onClick:C=>{C.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(oo,{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(Yt,{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(Sr,{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:C=>n(C.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:C=>o(C.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(Rt,{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"}),bK.map((C,j)=>a.jsx("button",{onClick:()=>c(C),className:`px-2 py-1.5 text-xs transition-colors flex items-center gap-1 ${j===bK.length-1?"rounded-r":""} ${l===C?`${zj[C]} bg-bambu-dark-tertiary`:"text-bambu-gray hover:text-white"}`,children:C},C))]})]})]}),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:k.map((C,j)=>{const M=r.has(j),E=C.message.includes(`
- `);return a.jsx("div",{className:`p-2 cursor-pointer hover:bg-bambu-dark-secondary/50 transition-colors ${M?"bg-bambu-dark-secondary/30":""}`,onClick:()=>E&&_(j),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(C.timestamp)}),a.jsx("span",{className:"shrink-0",children:a.jsx(P,{level:C.level})}),a.jsxs("span",{className:"text-purple-400/80 shrink-0 max-w-[200px] truncate",title:C.logger_name,children:["[",C.logger_name,"]"]}),a.jsx("span",{className:`flex-1 ${zj[C.level]||"text-white/80"} ${!M&&E?"truncate":""}`,children:M?a.jsx("pre",{className:"whitespace-pre-wrap break-all",children:C.message}):C.message.split(`
- `)[0]}),E&&a.jsx("span",{className:"text-bambu-gray/50 shrink-0",children:M?a.jsx(wl,{className:"w-3.5 h-3.5"}):a.jsx(Mn,{className:"w-3.5 h-3.5"})})]})},j)})})}),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 xet(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 Ma({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 xK({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 ah({title:t,icon:e,children:n}){return a.jsxs(St,{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 yet(){const{t}=Dt(),e=Qt(),[n,r]=w.useState(null),[i,s]=w.useState(!1),[o,l]=w.useState(!1),{data:c,isLoading:d,refetch:u,isFetching:h}=Ze({queryKey:["systemInfo"],queryFn:J.getSystemInfo,refetchInterval:3e4}),{data:f}=Ze({queryKey:["debugLogging"],queryFn:Kg.getDebugLoggingState,staleTime:10*1e3,refetchInterval:10*1e3}),{data:p}=Ze({queryKey:["settings"],queryFn:J.getSettings}),{data:x}=Ze({queryKey:["library-stats"],queryFn:J.getLibraryStats}),v=p?.time_format||"system",g=async()=>{l(!0);try{const A=await Kg.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 Kg.downloadSupportBundle()}catch(A){r(A instanceof Error?A.message:"Failed to download support bundle")}finally{s(!1)}};if(d)return a.jsx("div",{className:"flex items-center justify-center h-64",children:a.jsx(at,{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:()=>u(),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(Sr,{className:`w-4 h-4 ${h?"animate-spin":""}`}),t("common.refresh","Refresh")]})]}),a.jsx(ah,{title:t("system.application","Application"),icon:Bm,children:a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[a.jsx(Ma,{icon:Bm,label:t("system.version","Version"),value:`v${c.app.version}`}),a.jsx(Ma,{icon:qn,label:t("system.uptime","System Uptime"),value:c.system.uptime_formatted}),a.jsx(Ma,{icon:Bm,label:t("system.hostname","Hostname"),value:c.system.hostname})]})}),a.jsx(ah,{title:t("support.title","Support & Troubleshooting"),icon:Jme,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(BC,{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(at,{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(ga,{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(at,{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(bet,{})]})}),a.jsxs(ah,{title:t("system.database","Database"),icon:jc,children:[a.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mb-4",children:[a.jsx(Ma,{icon:Ds,label:t("system.totalArchives","Total Archives"),value:c.database.archives}),a.jsx(Ma,{icon:ub,label:t("system.completed","Completed"),value:c.database.archives_completed,color:"text-green-500"}),a.jsx(Ma,{icon:mi,label:t("system.failed","Failed"),value:c.database.archives_failed,color:"text-red-500"}),a.jsx(Ma,{icon:at,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(Ma,{icon:Nr,label:t("system.printers","Printers"),value:c.database.printers}),a.jsx(Ma,{icon:KC,label:t("system.filaments","Filaments"),value:c.database.filaments}),a.jsx(Ma,{icon:xs,label:t("system.projects","Projects"),value:c.database.projects}),a.jsx(Ma,{icon:gl,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(Ma,{icon:qn,label:t("system.totalPrintTime","Total Print Time"),value:c.database.total_print_time_formatted}),a.jsx(Ma,{icon:Ds,label:t("system.totalFilament","Total Filament Used"),value:`${c.database.total_filament_kg} kg`,subValue:`${c.database.total_filament_grams.toLocaleString()} g`})]})]}),a.jsxs(ah,{title:t("system.connectedPrinters","Connected Printers"),icon:Nr,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(ah,{title:t("system.storage","Storage"),icon:Vb,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(xK,{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(Ma,{icon:Ds,label:t("system.archiveStorage","Archive Storage"),value:c.storage.archive_size_formatted}),a.jsx(Ma,{icon:jc,label:t("system.databaseSize","Database Size"),value:c.storage.database_size_formatted}),x&&a.jsx(Ma,{icon:Jl,label:t("system.fileManagerStorage","File Manager"),value:xet(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(ah,{title:t("system.memory","Memory"),icon:Efe,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(xK,{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(ah,{title:t("system.cpu","CPU"),icon:tS,children:a.jsx("div",{className:"space-y-4",children:a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsx(Ma,{icon:tS,label:t("system.cores","Cores"),value:c.cpu.count,subValue:`${c.cpu.count_logical} logical`}),a.jsx(Ma,{icon:tS,label:t("system.usage","Usage"),value:`${c.cpu.percent}%`})]})})})]}),a.jsx(ah,{title:t("system.systemDetails","System Details"),icon:Bm,children:a.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[a.jsx(Ma,{icon:Bm,label:t("system.os","Operating System"),value:c.system.platform,subValue:c.system.platform_release}),a.jsx(Ma,{icon:tS,label:t("system.architecture","Architecture"),value:c.system.architecture}),a.jsx(Ma,{icon:Bm,label:t("system.python","Python"),value:c.system.python_version}),a.jsx(Ma,{icon:qn,label:t("system.bootTime","Boot Time"),value:Df(c.system.boot_time,v)})]})})]})}function vet(){const t=ac(),{t:e}=Dt(),{login:n}=jr(),{showToast:r}=dn(),{mode:i}=ep(),[s,o]=w.useState(""),[l,c]=w.useState(""),[d,u]=w.useState(!1),[h,f]=w.useState(""),{data:p}=Ze({queryKey:["advancedAuthStatus"],queryFn:()=>J.getAdvancedAuthStatus()}),x=st({mutationFn:()=>n(s,l),onSuccess:()=>{r(e("login.loginSuccess")),t("/")},onError:_=>{r(_.message||e("login.loginFailed"),"error")}}),v=st({mutationFn:_=>J.forgotPassword({email:_}),onSuccess:_=>{r(_.message,"success"),u(!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:()=>u(!0),className:"text-sm text-bambu-gray hover:text-bambu-green transition-colors",children:e("login.forgotPassword")})})]})]}),d&&a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:()=>u(!1),children:a.jsxs(St,{className:"w-full max-w-md",onClick:_=>_.stopPropagation(),children:[a.jsx(On,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(p0,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:e("login.forgotPasswordTitle")})]}),a.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>{u(!1),f("")},children:a.jsx(Rt,{className:"w-5 h-5"})})]})}),a.jsx(Nt,{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(Me,{type:"button",variant:"secondary",className:"flex-1",onClick:()=>{u(!1),f("")},children:e("login.cancel")||"Cancel"}),a.jsx(Me,{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(Me,{variant:"secondary",className:"w-full",onClick:()=>u(!1),children:e("login.gotIt")})]})})]})})]})}function wet(){const t=ac(),{t:e}=Dt(),{showToast:n}=dn(),{mode:r}=ep(),{refreshAuth:i}=jr(),[s,o]=w.useState(!1),[l,c]=w.useState(""),[d,u]=w.useState(""),[h,f]=w.useState(""),p=st({mutationFn:()=>J.setupAuth({auth_enabled:s,admin_username:s?l:void 0,admin_password:s?d: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||d)){if(!l||!d){n(e("setup.toast.enterBothCredentials"),"error");return}if(d!==h){n(e("setup.toast.passwordsDoNotMatch"),"error");return}if(d.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(eo,{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:d,onChange:v=>u(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"})]}),d&&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 _et(){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),d=w.useRef([]),u=w.useRef(!1),h=w.useRef(()=>{}),f=w.useCallback(()=>{if(u.current||d.current.length===0)return;u.current=!0;const _=()=>{const N=d.current.shift();N?requestAnimationFrame(()=>{h.current(N),d.current.length>0?setTimeout(_,16):u.current=!1}):u.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 k=null;A.onopen=()=>{console.log("[WebSocket] Connected"),i(!0),k=window.setInterval(()=>{A.readyState===WebSocket.OPEN&&A.send(JSON.stringify({type:"ping"}))},3e4)},A.onmessage=P=>{try{const C=JSON.parse(P.data);C.type==="printer_status"&&C.printer_id!==void 0&&C.data?h.current(C):(d.current.push(C),f())}catch{}},A.onclose=P=>{console.log("[WebSocket] Closed",P.code,P.reason),k&&(clearInterval(k),k=null),i(!1),t.current=null,e.current=window.setTimeout(()=>{p()},3e3)},A.onerror=P=>{console.error("[WebSocket] Error",P),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 k=new Map(l.current);l.current.clear(),c.current=null,requestAnimationFrame(()=>{k.forEach((P,C)=>{n.setQueryData(["printerStatus",C],j=>{const M={...j,...P};return M.wifi_signal==null&&j?.wifi_signal!=null&&(M.wifi_signal=j.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(k=>{setTimeout(()=>{requestAnimationFrame(()=>{n.invalidateQueries({queryKey:[k]})})},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_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 Net({selectedPrinterId:t,onPrinterChange:e,deviceOnline:n}){const{t:r}=Dt(),[i,s]=w.useState(new Date),{data:o=[]}=Ze({queryKey:["printers"],queryFn:()=>J.getPrinters()}),l=lv({queries:o.map(u=>({queryKey:["printerStatus",u.id],queryFn:()=>J.getPrinterStatus(u.id),refetchInterval:1e4}))}),c=w.useMemo(()=>o.filter((u,h)=>l[h]?.data?.connected),[o,l]);w.useEffect(()=>{const u=c.some(h=>h.id===t);(!t||!u)&&c.length>0&&e(c[0].id)},[c,t,e]),w.useEffect(()=>{const u=setInterval(()=>s(new Date),1e3);return()=>clearInterval(u)},[]);const d=u=>u.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});return 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:u=>e(Number(u.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(u=>a.jsx("option",{value:u.id,children:u.name},u.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.online","Online"):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(u=>a.jsx("div",{className:`w-1 rounded-sm ${u<=4?"bg-white":"bg-bambu-dark-tertiary"}`,style:{height:`${u*4}px`}},u))}):a.jsx(Gh,{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.online","Online"):r("spoolbuddy.status.offline","Offline")})]}),a.jsx("span",{className:"text-white/50 text-base font-mono min-w-[50px] text-right",children:d(i)})]})]})}const Cet=[{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/inventory",labelKey:"spoolbuddy.nav.inventory",fallback:"Inventory",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:"M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4"})})},{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 ket(){const{t}=Dt();return a.jsx("nav",{className:"h-14 bg-bambu-dark-secondary border-t border-bambu-dark-tertiary flex items-stretch shrink-0",children:Cet.map(e=>a.jsxs(Og,{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 Aet({alert:t}){const{t:e}=Dt(),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 Tet={weight:null,weightStable:!1,rawAdc:null,matchedSpool:null,unknownTagUid:null,deviceOnline:!1,deviceId:null};function Met(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 Pet(){const[t,e]=w.useReducer(Met,Tet),n=w.useCallback(u=>{const h=u.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(u=>{const h=u.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(u=>{const h=u.detail;e({type:"UNKNOWN_TAG",tagUid:h.tag_uid??h.data?.tag_uid??"",deviceId:h.device_id??h.data?.device_id??""})},[]),s=w.useCallback(u=>{const h=u.detail;e({type:"TAG_REMOVED",deviceId:h.device_id??h.data?.device_id??""})},[]),o=w.useCallback(u=>{const h=u.detail;e({type:"DEVICE_ONLINE",deviceId:h.device_id??h.data?.device_id??""})},[]),l=w.useCallback(u=>{const h=u.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,d=t.weight!==null&&t.matchedSpool?Math.max(0,t.weight-t.matchedSpool.core_weight):null;return{...t,remainingWeight:c,netWeight:d}}function Eet(){const[t,e]=w.useState(null),[n,r]=w.useState(null),i=Pet();return w.useEffect(()=>{const s=document.documentElement,o=s.classList.contains("dark");return s.classList.add("dark"),()=>{o||s.classList.remove("dark")}},[]),w.useEffect(()=>{i.deviceOnline?r(null):r({type:"warning",message:"SpoolBuddy device disconnected"})},[i.deviceOnline]),a.jsxs("div",{className:"w-screen h-screen bg-bambu-dark text-white flex flex-col overflow-hidden",children:[a.jsx(Net,{selectedPrinterId:t,onPrinterChange:e,deviceOnline:i.deviceOnline}),a.jsx("main",{className:"flex-1 overflow-y-auto",children:a.jsx(KK,{context:{selectedPrinterId:t,setSelectedPrinterId:e,sbState:i,setAlert:r}})}),a.jsx(Aet,{alert:n}),a.jsx(ket,{})]})}function PA({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 jet="spoolbuddy-default-core-weight";function dse(){try{const t=localStorage.getItem(jet);if(t){const e=parseInt(t,10);if(e>=0&&e<=500)return e}}catch{}return 250}function Det({spool:t,scaleWeight:e,weightStable:n,onClose:r,onSyncWeight:i}){const{t:s}=Dt(),[o,l]=w.useState(!1),[c,d]=w.useState(!1),u=t.rgba?`#${t.rgba.slice(0,6)}`:"#808080",h=t.core_weight&&t.core_weight>0?t.core_weight:dse(),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,k=async()=>{if(!(e===null||!n)){l(!0);try{await Xg.updateSpoolWeight(t.id,Math.round(e)),d(!0),i?.(),setTimeout(()=>d(!1),3e3)}catch(P){console.error("Failed to sync weight:",P)}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(PA,{color:u,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(na,{className:"w-3.5 h-3.5"}):a.jsxs(a.Fragment,{children:[a.jsx(An,{className:"w-3.5 h-3.5"}),a.jsx("button",{onClick:k,className:"p-1 hover:bg-green-500/20 rounded transition-colors text-green-500",title:s("spoolbuddy.dashboard.syncWeight","Sync Weight"),children:a.jsx(Sr,{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:[a.jsx("button",{onClick:k,disabled:!n||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":"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")}),r&&a.jsx("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:s("spoolbuddy.dashboard.close","Close")})]})]})}function Ret({tagUid:t,scaleWeight:e,coreWeight:n,onLinkSpool:r,onClose:i}){const{t:s}=Dt(),o=n??dse(),l=e!==null?Math.round(Math.max(0,e)):null,c=l!==null?Math.round(Math.max(0,l-o)):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:s("spoolbuddy.dashboard.newTag","New Tag Detected")}),a.jsx("p",{className:"text-sm text-zinc-500 font-mono mt-1",children:t})]}),l!==null&&a.jsxs("div",{className:"text-sm text-zinc-400",children:[a.jsxs("span",{className:"font-mono font-semibold",children:[l,"g"]})," ",s("spoolbuddy.dashboard.onScale","on scale"),c!==null&&c>0&&a.jsxs("span",{className:"text-zinc-500",children:[" • ~",c,"g filament"]})]}),a.jsxs("div",{className:"flex flex-wrap gap-2 justify-center",children:[r&&a.jsxs("button",{onClick:r,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:[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"})}),s("spoolbuddy.dashboard.linkSpool","Link to Spool")]}),i&&a.jsx("button",{onClick:i,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 Fet({isOpen:t,onClose:e,tagId:n,untaggedSpools:r,onLink:i}){const{t:s}=Dt(),[o,l]=w.useState(null),c=w.useCallback(()=>{l(null),e()},[e]),d=w.useCallback(h=>{h.key==="Escape"&&c()},[c]);if(w.useEffect(()=>(t&&(document.addEventListener("keydown",d),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",d),document.body.style.overflow=""}),[t,d]),!t)return null;const u=()=>{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(Rt,{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(PA,{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:u,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 yK=["#00AE42","#FF6B35","#3B82F6","#EF4444","#A855F7","#FBBF24","#14B8A6","#EC4899","#F97316","#22C55E"];function Let(){const{t}=Dt(),[e,n]=w.useState(0);w.useEffect(()=>{const i=setInterval(()=>{n(s=>(s+1)%yK.length)},2e3);return()=>clearInterval(i)},[]);const r=yK[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(PA,{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 Oet(){const{t}=Dt();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 Iet(){const{sbState:t}=mF(),{t:e}=Dt(),{data:n=[],refetch:r}=Ze({queryKey:["inventory-spools"],queryFn:()=>J.getSpools(!1)}),[i,s]=w.useState(null),[o,l]=w.useState(null),[c,d]=w.useState(null),[u,h]=w.useState(!1),f=t.matchedSpool?.tag_uid??t.unknownTagUid??null,p=t.weight,x=t.weightStable,v=w.useRef(null);p===null?v.current=null:(v.current===null||Math.abs(p-v.current)>=3||x)&&(v.current=p);const y=v.current,_=w.useMemo(()=>i?n.find(q=>q.tag_uid===i)??null:null,[i,n]),N=w.useMemo(()=>n.filter(q=>!q.tag_uid&&!q.archived_at),[n]);w.useEffect(()=>{if(f){const q=c===f;(i!==null&&i!==f||!q&&i!==f)&&(s(f),l(null),d(null)),!q&&p!==null&&x&&l(Math.round(Math.max(0,p)))}else c&&(s(null),d(null),l(null))},[f,p,x,i,c]);const[A,k]=w.useState(null);w.useEffect(()=>{_?.id!==A&&k(null)},[_?.id]),w.useEffect(()=>{if(_&&f&&x&&A!==_.id){k(_.id);const q=p!==null?Math.round(Math.max(0,p)):null;q!==null&&Xg.updateSpoolWeight(_.id,q).catch(z=>console.error("Failed to update spool weight:",z))}},[_?.id,f,x]);const P=()=>{d(i)},C=async q=>{if(i)try{await J.updateSpool(q.id,{tag_uid:i}),h(!1),r()}catch(z){console.error("Failed to link tag:",z)}},j=i&&c!==i,M=_!==null,E=j&&!M,L=p!==null&&(f===i||f===null&&i!==null)?p:null,U=n.length,D=new Set(n.map(q=>q.material)).size,$=new Set(n.filter(q=>q.brand).map(q=>q.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:U}),a.jsx("span",{className:"text-sm text-zinc-500",children:e("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:D}),a.jsx("span",{className:"text-sm text-zinc-500",children:e("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:$}),a.jsx("span",{className:"text-sm text-zinc-500",children:e("spoolbuddy.spool.brand","Brands")})]})]}),a.jsxs("div",{className:"flex-1 flex gap-4 min-h-0",children:[a.jsx("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:e("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?e("spoolbuddy.status.online","Online"):e("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:e("spoolbuddy.spool.scaleWeight","Scale")})]}),a.jsx("span",{className:"text-lg font-mono font-semibold text-zinc-100",children:y!==null?`${Math.abs(y)<=20?0:Math.round(Math.max(0,y))}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 ${f?"text-green-500":"text-zinc-500"}`,children:f?e("spoolbuddy.dashboard.tagDetected","Tag detected"):e("spoolbuddy.dashboard.noTag","No tag")})]})]})]})}),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:e("spoolbuddy.dashboard.currentSpool","Current Spool")}),a.jsx("div",{className:"flex-1 flex items-center justify-center min-h-0",children:j&&M&&_?a.jsx(Det,{spool:{id:_.id,tag_uid:i,material:_.material,subtype:_.subtype,color_name:_.color_name,rgba:_.rgba,brand:_.brand,label_weight:_.label_weight,core_weight:_.core_weight,weight_used:_.weight_used},scaleWeight:L,weightStable:x,onClose:P,onSyncWeight:()=>r()}):j&&E?a.jsx(Ret,{tagUid:i,scaleWeight:L??(o!==null?o:null),onLinkSpool:N.length>0?()=>h(!0):void 0,onClose:P}):t.deviceOnline?a.jsx(Let,{}):a.jsx(Oet,{})})]})})]}),i&&a.jsx(Fet,{isOpen:u,onClose:()=>h(!1),tagId:i,untaggedSpools:N,onLink:C})]})}function zet(t){return t?`#${t.slice(0,6)}`:"#808080"}function use(t){return!t.tray_type||t.tray_type===""}function Uet(t){return t<=3?`AMS ${String.fromCharCode(65+t)}`:t>=128&&t<=135?`AMS HT ${String.fromCharCode(65+t-128)}`:`AMS ${t}`}function Bet({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 Het({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 $et({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 Vet({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 qet({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 Get({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 hse({humidity:t,goodThreshold:e=40,fairThreshold:n=60}){let r,i;return t<=e?(r="#22a352",i=Bet):t<=n?(r="#d4a017",i=Het):(r="#c62828",i=$et),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=Vet):t<=n?(r="#d4a017",i=qet):(r="#c62828",i=Get),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 fse({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 Wet({tray:t,slotIndex:e,isActive:n,onClick:r}){const i=use(t),s=zet(t.tray_color);return a.jsxs("div",{className:`relative flex flex-col items-center p-2.5 rounded-lg transition-all ${n?"ring-2 ring-bambu-green":""} ${r?"cursor-pointer hover:bg-white/5":""}`,onClick:r,children:[a.jsxs("div",{className:"relative w-16 h-16 mb-1",children:[i?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:s}),a.jsx("circle",{cx:"28",cy:"28",r:"20",fill:s,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:i?"Empty":t.tray_type||"Unknown"}),!i&&t.remain!==null&&t.remain!==void 0&&t.remain>=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:`${t.remain}%`,backgroundColor:t.remain>50?"#22c55e":t.remain>20?"#f59e0b":"#ef4444"}})}),a.jsx("span",{className:"absolute top-1 right-1 text-xs text-white/30",children:e+1})]})}function Ket({unit:t,activeSlot:e,onConfigureSlot:n,isDualNozzle:r,nozzleSide:i,thresholds:s}){const o=t.tray||[],l=t.is_ams_ht,c=l?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:Uet(t.id)}),r&&i&&a.jsx(fse,{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(hse,{humidity:t.humidity,goodThreshold:s?.humidityGood,fairThreshold:s?.humidityFair})]})]}),a.jsx("div",{className:`grid ${l?"grid-cols-1 max-w-[100px] mx-auto":"grid-cols-4"} gap-2`,children:Array.from({length:c}).map((d,u)=>{const h=o[u]||{id:u,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(Wet,{tray:h,slotIndex:u,isActive:e===u,onClick:n?()=>n(t.id,u,use(h)?null:h):void 0},u)})})]})}function vK(t){return t<=3?`AMS ${String.fromCharCode(65+t)}`:t>=128&&t<=135?`AMS HT ${String.fromCharCode(65+t-128)}`:`AMS ${t}`}function Xet(t){return t?{O1D:"H2D",O1E:"H2D Pro",O2D:"H2D Pro",O1C:"H2C",O1S:"H2S","BL-P001":"X1C","BL-P002":"X1","BL-P003":"X1E",C11:"P1S",C12:"P1P",C13:"P2S",N2S:"A1",N1:"A1 Mini",X1C:"X1C",X1:"X1",X1E:"X1E",P1S:"P1S",P1P:"P1P",P2S:"P2S",A1:"A1","A1 Mini":"A1 Mini",H2D:"H2D","H2D Pro":"H2D Pro",H2C:"H2C",H2S:"H2S"}[t]||t:""}function Uj(t){return!t.tray_type||t.tray_type===""}function Yet(t){return t?`#${t.slice(0,6)}`:"#808080"}function Qet(){const{selectedPrinterId:t,setAlert:e}=mF(),{t:n}=Dt(),r=Qt(),{data:i}=Ze({queryKey:["printerStatus",t],queryFn:()=>J.getPrinterStatus(t),enabled:t!==null,staleTime:30*1e3}),{data:s}=Ze({queryKey:["printer",t],queryFn:()=>J.getPrinter(t),enabled:t!==null,staleTime:60*1e3}),{data:o}=Ze({queryKey:["slotPresets",t],queryFn:()=>J.getSlotPresets(t),enabled:t!==null,staleTime:120*1e3}),{data:l}=Ze({queryKey:["settings"],queryFn:()=>J.getSettings(),staleTime:300*1e3}),c=i?.connected??!1,d=w.useMemo(()=>i?.ams??[],[i?.ams]),u=w.useMemo(()=>d.filter(M=>!M.is_ams_ht),[d]),h=w.useMemo(()=>d.filter(M=>M.is_ams_ht),[d]),f=i?.tray_now??255,p=s?.nozzle_count===2||i?.temperatures?.nozzle_2!==void 0,x=w.useMemo(()=>[...i?.vt_tray??[]].sort((M,E)=>(M.id??254)-(E.id??254)),[i?.vt_tray]),v=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,g=w.useRef({});w.useEffect(()=>{i?.ams_extruder_map&&Object.keys(i.ams_extruder_map).length>0&&(g.current=i.ams_extruder_map)},[i?.ams_extruder_map]);const y=i?.ams_extruder_map&&Object.keys(i.ams_extruder_map).length>0?i.ams_extruder_map:g.current,_=w.useCallback(M=>{if(!p)return null;const E=y[String(M)],B=M>=128?M-128:M;return(E!==void 0?E:B)===1?"L":"R"},[p,y]),[N,A]=w.useState(null),k=w.useCallback(M=>{if(f===255||f===254)return null;if(M<=3&&Math.floor(f/4)===M)return f%4;if(M>=128&&M<=135){const E=M-128;if(f===16+E)return 0}return null},[f]),P=w.useCallback((M,E,B)=>{const L=M>=128?(M-128)*4+E+64:M*4+E,U=o?.[L],D=y[String(M)],$=M>=128?M-128:M,q=D!==void 0?D:$;A({amsId:M,trayId:E,trayCount:B&&M>=128?1:4,trayType:B?.tray_type||void 0,trayColor:B?.tray_color||void 0,traySubBrands:B?.tray_sub_brands||void 0,trayInfoIdx:B?.tray_info_idx||void 0,extruderId:p?q:void 0,caliIdx:B?.cali_idx,savedPresetId:U?.preset_id})},[o,y,p]),C=w.useCallback(M=>{const E=M.id??254,B=E-254,L=o?.[1020+B];A({amsId:255,trayId:B,trayCount:1,trayType:M.tray_type||void 0,trayColor:M.tray_color||void 0,traySubBrands:M.tray_sub_brands||void 0,trayInfoIdx:M.tray_info_idx||void 0,extruderId:p?E===254?1:0:void 0,caliIdx:M.cali_idx,savedPresetId:L?.preset_id})},[o,p]);w.useEffect(()=>{if(!c&&t){e({type:"warning",message:n("spoolbuddy.ams.printerDisconnected","Printer disconnected")});return}for(const M of d)for(const E of M.tray||[])if(E.remain!==null&&E.remain>=0&&E.remain<15&&E.tray_type){e({type:"warning",message:`Low Filament: ${E.tray_type} (${vK(M.id)}) - ${E.remain}% remaining`});return}e(null)},[d,c,t,e,n]);const j=w.useMemo(()=>{const M=[];for(const E of h){const B=E.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};M.push({key:`ht-${E.id}`,label:vK(E.id),tray:B,isEmpty:Uj(B),isActive:k(E.id)===0,temp:E.temp,humidity:E.humidity,nozzleSide:_(E.id),onClick:()=>P(E.id,0,Uj(B)?null:B)})}for(const E of x){const B=E.id??254,L=p&&f===254?B===254&&i?.active_extruder===1||B===255&&i?.active_extruder===0:f===B;M.push({key:`ext-${B}`,label:p?B===254?n("printers.extL","Ext-L"):n("printers.extR","Ext-R"):n("printers.ext","Ext"),tray:E,isEmpty:Uj(E),isActive:L,nozzleSide:p?B===254?"L":"R":null,onClick:()=>C(E)})}return M},[h,x,p,f,i?.active_extruder,n,k,_,P,C]);return a.jsxs("div",{className:"h-full flex flex-col p-4",children:[a.jsx("div",{className:"flex-1 min-h-0",children:t?c?d.length===0&&x.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(ri,{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 flex-1 min-h-0",children:u.map(M=>a.jsx(Ket,{unit:M,activeSlot:k(M.id),onConfigureSlot:P,isDualNozzle:p,nozzleSide:_(M.id),thresholds:v},M.id))}),j.length>0&&a.jsx("div",{className:"flex gap-2 flex-shrink-0",children:j.map(({key:M,label:E,tray:B,isEmpty:L,isActive:U,temp:D,humidity:$,nozzleSide:q,onClick:z})=>{const W=Yet(B.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-2 ${U?"ring-2 ring-bambu-green":""}`,onClick:z,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:W}),a.jsx("circle",{cx:"28",cy:"28",r:"20",fill:W,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"})]}),U&&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:E}),q&&a.jsx(fse,{side:q})]}),a.jsx("div",{className:"text-sm text-white/80 truncate",children:L?"Empty":B.tray_type||"?"}),(D!=null||$!=null)&&a.jsxs("div",{className:"flex items-center gap-1.5",children:[D!=null&&a.jsx(mse,{temp:D,goodThreshold:v?.tempGood,fairThreshold:v?.tempFair}),$!=null&&a.jsx(hse,{humidity:$,goodThreshold:v?.humidityGood,fairThreshold:v?.humidityFair})]})]}),!L&&B.remain!=null&&B.remain>=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:`${B.remain}%`,backgroundColor:B.remain>50?"#22c55e":B.remain>20?"#f59e0b":"#ef4444"}})})]},M)})})]}):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")})]})})}),N&&t&&a.jsx(wne,{isOpen:!!N,onClose:()=>A(null),printerId:t,slotInfo:N,printerModel:Xet(s?.model??null)||void 0,fullScreen:!0,onSuccess:()=>{r.invalidateQueries({queryKey:["slotPresets",t]}),r.invalidateQueries({queryKey:["printerStatus",t]})}})]})}function Zet(t){if(!t)return"-";try{return new Date(t).toLocaleDateString(void 0,{month:"short",day:"numeric"})}catch{return"-"}}function Jet({spool:t}){const{t:e}=Dt(),[n,r]=w.useState(!1),i=Math.max(0,t.label_weight-t.weight_used),s=t.label_weight>0?i/t.label_weight*100:0,o=t.rgba?`#${t.rgba.slice(0,6)}`:"#808080",l=s>50?"#22c55e":s>15?"#f59e0b":"#ef4444";return a.jsxs("button",{className:"w-full bg-zinc-800 rounded-lg p-3.5 text-left transition-colors hover:bg-zinc-750 active:bg-zinc-700",onClick:()=>r(!n),children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(PA,{color:o,isEmpty:!1,size:36}),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-base font-medium text-zinc-100 truncate",children:t.color_name||t.material}),t.tag_uid&&a.jsx("svg",{className:"w-3 h-3 text-green-500 shrink-0",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("span",{className:"text-sm text-zinc-500 truncate block",children:[t.brand?`${t.brand} • `:"",t.material,t.subtype?` ${t.subtype}`:""]})]}),a.jsxs("div",{className:"text-right shrink-0",children:[a.jsxs("div",{className:"text-base text-zinc-300",children:[Math.round(i),"g"]}),a.jsx("div",{className:"text-sm text-zinc-500",children:e("spoolbuddy.spool.remaining","Remaining")})]})]}),a.jsx("div",{className:"w-full h-1.5 bg-zinc-700 rounded-full overflow-hidden mt-2",children:a.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${Math.min(100,s)}%`,backgroundColor:l}})}),n&&a.jsxs("div",{className:"mt-3 pt-3 border-t border-zinc-700 grid grid-cols-2 gap-x-4 gap-y-2 text-sm",children:[a.jsxs("div",{className:"flex justify-between",children:[a.jsx("span",{className:"text-zinc-500",children:e("spoolbuddy.spool.labelWeight","Label")}),a.jsxs("span",{className:"text-zinc-400",children:[t.label_weight,"g"]})]}),a.jsxs("div",{className:"flex justify-between",children:[a.jsx("span",{className:"text-zinc-500",children:e("spoolbuddy.spool.coreWeight","Core")}),a.jsxs("span",{className:"text-zinc-400",children:[t.core_weight,"g"]})]}),a.jsxs("div",{className:"flex justify-between",children:[a.jsx("span",{className:"text-zinc-500",children:e("spoolbuddy.spool.material","Material")}),a.jsxs("span",{className:"text-zinc-400",children:[t.material,t.subtype?` ${t.subtype}`:""]})]}),a.jsxs("div",{className:"flex justify-between",children:[a.jsx("span",{className:"text-zinc-500",children:e("spoolbuddy.spool.lastUsed","Last used")}),a.jsx("span",{className:"text-zinc-400",children:Zet(t.last_used)})]}),t.tag_uid&&a.jsxs("div",{className:"col-span-2 flex justify-between",children:[a.jsx("span",{className:"text-zinc-500",children:"Tag"}),a.jsx("span",{className:"text-zinc-400 font-mono text-xs",children:t.tag_uid})]})]})]})}function ett(){const{t}=Dt(),[e,n]=w.useState(""),{data:r=[],isLoading:i}=Ze({queryKey:["inventory-spools"],queryFn:()=>J.getSpools(!1)}),s=w.useMemo(()=>{if(!e.trim())return r;const o=e.toLowerCase();return r.filter(l=>l.material.toLowerCase().includes(o)||l.brand?.toLowerCase().includes(o)||l.color_name?.toLowerCase().includes(o))},[r,e]);return a.jsxs("div",{className:"h-full flex flex-col p-4",children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsx("h1",{className:"text-xl font-semibold text-zinc-100",children:t("spoolbuddy.nav.inventory","Inventory")}),a.jsxs("span",{className:"text-sm text-zinc-500",children:[r.length," ",t("spoolbuddy.inventory.spools","spools")]})]}),a.jsxs("div",{className:"relative mb-4",children:[a.jsx("svg",{className:"absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-zinc-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),a.jsx("input",{type:"text",value:e,onChange:o=>n(o.target.value),placeholder:t("spoolbuddy.inventory.search","Search spools..."),className:"w-full pl-10 pr-4 py-2.5 bg-zinc-800 border border-zinc-700 rounded-lg text-sm text-zinc-100 placeholder-zinc-500 focus:outline-none focus:border-green-500 min-h-[44px]"})]}),a.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto space-y-2",children:i?a.jsx("div",{className:"flex items-center justify-center h-32",children:a.jsx("span",{className:"text-zinc-500",children:t("common.loading","Loading...")})}):s.length===0?a.jsxs("div",{className:"flex flex-col items-center justify-center h-32 text-zinc-500",children:[a.jsx("svg",{className:"w-10 h-10 mb-2 opacity-50",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4"})}),a.jsx("p",{className:"text-sm",children:e?t("spoolbuddy.inventory.noResults","No matching spools"):t("spoolbuddy.inventory.empty","No spools in inventory")})]}):s.map(o=>a.jsx(Jet,{spool:o},o.id))})]})}function ttt(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({device:t,weight:e,weightStable:n,rawAdc:r}){const{t:i}=Dt(),[s,o]=w.useState(!1),[l,c]=w.useState("idle"),[d,u]=w.useState(500),[h,f]=w.useState(!1),p=async()=>{f(!0);try{await Xg.tare(t.device_id)}catch(g){console.error("Failed to tare:",g)}finally{f(!1)}},x=()=>{c("tare")},v=async()=>{if(l==="tare"){o(!0);try{await Xg.tare(t.device_id),c("weight")}catch(g){console.error("Failed to tare:",g)}finally{o(!1)}}else if(l==="weight"){if(r===null)return;o(!0);try{await Xg.setCalibrationFactor(t.device_id,d,r),c("idle")}catch(g){console.error("Failed to calibrate:",g)}finally{o(!1)}}};return a.jsxs("div",{className:"bg-zinc-800 rounded-lg p-4",children:[a.jsx("h3",{className:"text-base font-semibold text-zinc-100 mb-4",children:i("spoolbuddy.settings.scaleCalibration","Scale Calibration")}),a.jsxs("div",{className:"flex items-center justify-between mb-3",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-sm font-mono text-zinc-200",children:e!==null?`${e.toFixed(1)} g`:"-- g"})]})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-4 mb-4 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:p,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]",children:h?"...":i("spoolbuddy.weight.tare","Tare")}),a.jsx("button",{onClick:x,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:"border border-zinc-700 rounded-lg p-3 space-y-3",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:"flex items-center gap-2",children:[a.jsx("label",{className:"text-xs text-zinc-400",children:i("spoolbuddy.settings.knownWeight","Known weight (g)")}),a.jsx("input",{type:"number",value:d,onChange:g=>u(Number(g.target.value)),className:"w-24 px-2 py-2 bg-zinc-900 border border-zinc-600 rounded text-sm text-zinc-100 focus:outline-none focus:border-green-500 min-h-[44px]",min:1})]}),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:v,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 rtt({device:t}){const{t:e}=Dt();return a.jsxs("div",{className:"bg-zinc-800 rounded-lg p-4",children:[a.jsx("h3",{className:"text-base font-semibold text-zinc-100 mb-4",children:e("spoolbuddy.settings.deviceInfo","Device Info")}),a.jsxs("div",{className:"space-y-2 text-sm",children:[a.jsxs("div",{className:"flex justify-between",children:[a.jsx("span",{className:"text-zinc-500",children:"Device ID"}),a.jsx("span",{className:"text-zinc-300 font-mono text-xs",children:t.device_id})]}),a.jsxs("div",{className:"flex justify-between",children:[a.jsx("span",{className:"text-zinc-500",children:e("spoolbuddy.settings.hostname","Hostname")}),a.jsx("span",{className:"text-zinc-300",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.firmware","Firmware")}),a.jsx("span",{className:"text-zinc-300",children:t.firmware_version??"-"})]}),a.jsxs("div",{className:"flex justify-between",children:[a.jsx("span",{className:"text-zinc-500",children:"NFC"}),a.jsx("span",{className:t.nfc_ok?"text-green-400":"text-zinc-500",children:t.nfc_ok?e("spoolbuddy.status.nfcReady","Ready"):e("spoolbuddy.status.nfcOff","Off")})]}),a.jsxs("div",{className:"flex justify-between",children:[a.jsx("span",{className:"text-zinc-500",children:e("spoolbuddy.settings.scale","Scale")}),a.jsx("span",{className:t.scale_ok?"text-green-400":"text-red-400",children:t.scale_ok?"OK":e("common.error","Error")})]}),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:ttt(t.uptime_s)})]}),a.jsxs("div",{className:"flex justify-between",children:[a.jsx("span",{className:"text-zinc-500",children:e("spoolbuddy.status.status","Status")}),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")})]})]})]})}function att(){const{sbState:t}=mF(),{t:e}=Dt(),{data:n=[]}=Ze({queryKey:["spoolbuddy-devices"],queryFn:()=>Xg.getDevices(),refetchInterval:1e4}),r=t.deviceId?n.find(i=>i.device_id===t.deviceId)??n[0]:n[0];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-4",children:e("spoolbuddy.nav.settings","Settings")}),a.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto space-y-4",children:r?a.jsxs(a.Fragment,{children:[a.jsx(ntt,{device:r,weight:t.weight,weightStable:t.weightStable,rawAdc:t.rawAdc}),a.jsx(rtt,{device:r})]}):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 itt=new Mue({defaultOptions:{queries:{staleTime:1e3*60,retry:1}}});function wK({children:t}){return _et(),a.jsx(a.Fragment,{children:t})}function SK({children:t}){const{authEnabled:e,loading:n,user:r}=jr();return n?a.jsx("div",{className:"min-h-screen flex items-center justify-center",children:"Loading..."}):e&&!r?a.jsx(lb,{to:"/login",replace:!0}):a.jsx(a.Fragment,{children:t})}function Bj({children:t}){const{authEnabled:e,loading:n,user:r,isAdmin:i}=jr();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(lb,{to:"/",replace:!0}):a.jsx(lb,{to:"/login",replace:!0}):a.jsx(a.Fragment,{children:t})}function stt({children:t}){const{authEnabled:e,loading:n}=jr();return n?a.jsx("div",{className:"min-h-screen flex items-center justify-center",children:"Loading..."}):e?a.jsx(lb,{to:"/login",replace:!0}):a.jsx(a.Fragment,{children:t})}function ott(){return a.jsx(Nge,{children:a.jsx(jge,{children:a.jsx(Pue,{client:itt,children:a.jsx(Pge,{children:a.jsx(Xde,{children:a.jsxs(Nde,{children:[a.jsx(Ir,{path:"/setup",element:a.jsx(stt,{children:a.jsx(wet,{})})}),a.jsx(Ir,{path:"/login",element:a.jsx(vet,{})}),a.jsx(Ir,{path:"/camera/:printerId",element:a.jsx(EJe,{})}),a.jsx(Ir,{path:"/overlay/:printerId",element:a.jsx(FJe,{})}),a.jsxs(Ir,{element:a.jsx(SK,{children:a.jsx(wK,{children:a.jsx(Eet,{})})}),children:[a.jsx(Ir,{path:"spoolbuddy",element:a.jsx(Iet,{})}),a.jsx(Ir,{path:"spoolbuddy/ams",element:a.jsx(Qet,{})}),a.jsx(Ir,{path:"spoolbuddy/inventory",element:a.jsx(ett,{})}),a.jsx(Ir,{path:"spoolbuddy/settings",element:a.jsx(att,{})})]}),a.jsxs(Ir,{element:a.jsx(SK,{children:a.jsx(wK,{children:a.jsx(Bge,{})})}),children:[a.jsx(Ir,{index:!0,element:a.jsx(P$e,{})}),a.jsx(Ir,{path:"archives",element:a.jsx(bYe,{})}),a.jsx(Ir,{path:"queue",element:a.jsx(tZe,{})}),a.jsx(Ir,{path:"stats",element:a.jsx(pZe,{})}),a.jsx(Ir,{path:"profiles",element:a.jsx(sJe,{})}),a.jsx(Ir,{path:"maintenance",element:a.jsx(uJe,{})}),a.jsx(Ir,{path:"projects",element:a.jsx(mJe,{})}),a.jsx(Ir,{path:"projects/:id",element:a.jsx(vJe,{})}),a.jsx(Ir,{path:"inventory",element:a.jsx(het,{})}),a.jsx(Ir,{path:"files",element:a.jsx(AJe,{})}),a.jsx(Ir,{path:"settings",element:a.jsx(Bj,{children:a.jsx(GZe,{})})}),a.jsx(Ir,{path:"groups/new",element:a.jsx(Bj,{children:a.jsx(uK,{})})}),a.jsx(Ir,{path:"groups/:id/edit",element:a.jsx(Bj,{children:a.jsx(uK,{})})}),a.jsx(Ir,{path:"users",element:a.jsx(lb,{to:"/settings?tab=users",replace:!0})}),a.jsx(Ir,{path:"groups",element:a.jsx(lb,{to:"/settings?tab=users",replace:!0})}),a.jsx(Ir,{path:"system",element:a.jsx(yet,{})}),a.jsx(Ir,{path:"external/:id",element:a.jsx(LJe,{})})]})]})})})})})})}vle.createRoot(document.getElementById("root")).render(a.jsx(w.StrictMode,{children:a.jsx(ott,{})}));
|