| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665 |
- function Aae(t,e){for(var n=0;n<e.length;n++){const r=e[n];if(typeof r!="string"&&!Array.isArray(r)){for(const i in r)if(i!=="default"&&!(i in t)){const a=Object.getOwnPropertyDescriptor(r,i);a&&Object.defineProperty(t,i,a.get?a:{enumerable:!0,get:()=>r[i]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const a of i)if(a.type==="childList")for(const o of a.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(i){const a={};return i.integrity&&(a.integrity=i.integrity),i.referrerPolicy&&(a.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?a.credentials="include":i.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function r(i){if(i.ep)return;i.ep=!0;const a=n(i);fetch(i.href,a)}})();var Aw=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function hl(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var zE={exports:{}},Eb={};var FU;function Cae(){if(FU)return Eb;FU=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(r,i,a){var o=null;if(a!==void 0&&(o=""+a),i.key!==void 0&&(o=""+i.key),"key"in i){a={};for(var l in i)l!=="key"&&(a[l]=i[l])}else a=i;return i=a.ref,{$$typeof:t,type:r,key:o,ref:i!==void 0?i:null,props:a}}return Eb.Fragment=e,Eb.jsx=n,Eb.jsxs=n,Eb}var IU;function jae(){return IU||(IU=1,zE.exports=Cae()),zE.exports}var s=jae(),BE={exports:{}},yn={};var UU;function Pae(){if(UU)return yn;UU=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),a=Symbol.for("react.consumer"),o=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),u=Symbol.for("react.memo"),d=Symbol.for("react.lazy"),f=Symbol.for("react.activity"),p=Symbol.iterator;function m(B){return B===null||typeof B!="object"?null:(B=p&&B[p]||B["@@iterator"],typeof B=="function"?B:null)}var x={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},b=Object.assign,y={};function v(B,X,ne){this.props=B,this.context=X,this.refs=y,this.updater=ne||x}v.prototype.isReactComponent={},v.prototype.setState=function(B,X){if(typeof B!="object"&&typeof B!="function"&&B!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,B,X,"setState")},v.prototype.forceUpdate=function(B){this.updater.enqueueForceUpdate(this,B,"forceUpdate")};function S(){}S.prototype=v.prototype;function N(B,X,ne){this.props=B,this.context=X,this.refs=y,this.updater=ne||x}var T=N.prototype=new S;T.constructor=N,b(T,v.prototype),T.isPureReactComponent=!0;var k=Array.isArray;function C(){}var E={H:null,A:null,T:null,S:null},D=Object.prototype.hasOwnProperty;function A(B,X,ne){var se=ne.ref;return{$$typeof:t,type:B,key:X,ref:se!==void 0?se:null,props:ne}}function R(B,X){return A(B.type,X,B.props)}function U(B){return typeof B=="object"&&B!==null&&B.$$typeof===t}function F(B){var X={"=":"=0",":":"=2"};return"$"+B.replace(/[=:]/g,function(ne){return X[ne]})}var $=/\/+/g;function j(B,X){return typeof B=="object"&&B!==null&&B.key!=null?F(""+B.key):X.toString(36)}function H(B){switch(B.status){case"fulfilled":return B.value;case"rejected":throw B.reason;default:switch(typeof B.status=="string"?B.then(C,C):(B.status="pending",B.then(function(X){B.status==="pending"&&(B.status="fulfilled",B.value=X)},function(X){B.status==="pending"&&(B.status="rejected",B.reason=X)})),B.status){case"fulfilled":return B.value;case"rejected":throw B.reason}}throw B}function K(B,X,ne,se,be){var xe=typeof B;(xe==="undefined"||xe==="boolean")&&(B=null);var de=!1;if(B===null)de=!0;else switch(xe){case"bigint":case"string":case"number":de=!0;break;case"object":switch(B.$$typeof){case t:case e:de=!0;break;case d:return de=B._init,K(de(B._payload),X,ne,se,be)}}if(de)return be=be(B),de=se===""?"."+j(B,0):se,k(be)?(ne="",de!=null&&(ne=de.replace($,"$&/")+"/"),K(be,X,ne,"",function(Ne){return Ne})):be!=null&&(U(be)&&(be=R(be,ne+(be.key==null||B&&B.key===be.key?"":(""+be.key).replace($,"$&/")+"/")+de)),X.push(be)),1;de=0;var Pe=se===""?".":se+":";if(k(B))for(var ie=0;ie<B.length;ie++)se=B[ie],xe=Pe+j(se,ie),de+=K(se,X,ne,xe,be);else if(ie=m(B),typeof ie=="function")for(B=ie.call(B),ie=0;!(se=B.next()).done;)se=se.value,xe=Pe+j(se,ie++),de+=K(se,X,ne,xe,be);else if(xe==="object"){if(typeof B.then=="function")return K(H(B),X,ne,se,be);throw X=String(B),Error("Objects are not valid as a React child (found: "+(X==="[object Object]"?"object with keys {"+Object.keys(B).join(", ")+"}":X)+"). If you meant to render a collection of children, use an array instead.")}return de}function V(B,X,ne){if(B==null)return B;var se=[],be=0;return K(B,se,"","",function(xe){return X.call(ne,xe,be++)}),se}function Q(B){if(B._status===-1){var X=B._result;X=X(),X.then(function(ne){(B._status===0||B._status===-1)&&(B._status=1,B._result=ne)},function(ne){(B._status===0||B._status===-1)&&(B._status=2,B._result=ne)}),B._status===-1&&(B._status=0,B._result=X)}if(B._status===1)return B._result.default;throw B._result}var Z=typeof reportError=="function"?reportError:function(B){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var X=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof B=="object"&&B!==null&&typeof B.message=="string"?String(B.message):String(B),error:B});if(!window.dispatchEvent(X))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",B);return}console.error(B)},ae={map:V,forEach:function(B,X,ne){V(B,function(){X.apply(this,arguments)},ne)},count:function(B){var X=0;return V(B,function(){X++}),X},toArray:function(B){return V(B,function(X){return X})||[]},only:function(B){if(!U(B))throw Error("React.Children.only expected to receive a single React element child.");return B}};return yn.Activity=f,yn.Children=ae,yn.Component=v,yn.Fragment=n,yn.Profiler=i,yn.PureComponent=N,yn.StrictMode=r,yn.Suspense=c,yn.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=E,yn.__COMPILER_RUNTIME={__proto__:null,c:function(B){return E.H.useMemoCache(B)}},yn.cache=function(B){return function(){return B.apply(null,arguments)}},yn.cacheSignal=function(){return null},yn.cloneElement=function(B,X,ne){if(B==null)throw Error("The argument must be a React element, but you passed "+B+".");var se=b({},B.props),be=B.key;if(X!=null)for(xe in X.key!==void 0&&(be=""+X.key),X)!D.call(X,xe)||xe==="key"||xe==="__self"||xe==="__source"||xe==="ref"&&X.ref===void 0||(se[xe]=X[xe]);var xe=arguments.length-2;if(xe===1)se.children=ne;else if(1<xe){for(var de=Array(xe),Pe=0;Pe<xe;Pe++)de[Pe]=arguments[Pe+2];se.children=de}return A(B.type,be,se)},yn.createContext=function(B){return B={$$typeof:o,_currentValue:B,_currentValue2:B,_threadCount:0,Provider:null,Consumer:null},B.Provider=B,B.Consumer={$$typeof:a,_context:B},B},yn.createElement=function(B,X,ne){var se,be={},xe=null;if(X!=null)for(se in X.key!==void 0&&(xe=""+X.key),X)D.call(X,se)&&se!=="key"&&se!=="__self"&&se!=="__source"&&(be[se]=X[se]);var de=arguments.length-2;if(de===1)be.children=ne;else if(1<de){for(var Pe=Array(de),ie=0;ie<de;ie++)Pe[ie]=arguments[ie+2];be.children=Pe}if(B&&B.defaultProps)for(se in de=B.defaultProps,de)be[se]===void 0&&(be[se]=de[se]);return A(B,xe,be)},yn.createRef=function(){return{current:null}},yn.forwardRef=function(B){return{$$typeof:l,render:B}},yn.isValidElement=U,yn.lazy=function(B){return{$$typeof:d,_payload:{_status:-1,_result:B},_init:Q}},yn.memo=function(B,X){return{$$typeof:u,type:B,compare:X===void 0?null:X}},yn.startTransition=function(B){var X=E.T,ne={};E.T=ne;try{var se=B(),be=E.S;be!==null&&be(ne,se),typeof se=="object"&&se!==null&&typeof se.then=="function"&&se.then(C,Z)}catch(xe){Z(xe)}finally{X!==null&&ne.types!==null&&(X.types=ne.types),E.T=X}},yn.unstable_useCacheRefresh=function(){return E.H.useCacheRefresh()},yn.use=function(B){return E.H.use(B)},yn.useActionState=function(B,X,ne){return E.H.useActionState(B,X,ne)},yn.useCallback=function(B,X){return E.H.useCallback(B,X)},yn.useContext=function(B){return E.H.useContext(B)},yn.useDebugValue=function(){},yn.useDeferredValue=function(B,X){return E.H.useDeferredValue(B,X)},yn.useEffect=function(B,X){return E.H.useEffect(B,X)},yn.useEffectEvent=function(B){return E.H.useEffectEvent(B)},yn.useId=function(){return E.H.useId()},yn.useImperativeHandle=function(B,X,ne){return E.H.useImperativeHandle(B,X,ne)},yn.useInsertionEffect=function(B,X){return E.H.useInsertionEffect(B,X)},yn.useLayoutEffect=function(B,X){return E.H.useLayoutEffect(B,X)},yn.useMemo=function(B,X){return E.H.useMemo(B,X)},yn.useOptimistic=function(B,X){return E.H.useOptimistic(B,X)},yn.useReducer=function(B,X,ne){return E.H.useReducer(B,X,ne)},yn.useRef=function(B){return E.H.useRef(B)},yn.useState=function(B){return E.H.useState(B)},yn.useSyncExternalStore=function(B,X,ne){return E.H.useSyncExternalStore(B,X,ne)},yn.useTransition=function(){return E.H.useTransition()},yn.version="19.2.0",yn}var zU;function px(){return zU||(zU=1,BE.exports=Pae()),BE.exports}var _=px();const Jr=hl(_),Dae=Aae({__proto__:null,default:Jr},[_]);var HE={exports:{}},Tb={},$E={exports:{}},VE={};var BU;function Rae(){return BU||(BU=1,(function(t){function e(K,V){var Q=K.length;K.push(V);e:for(;0<Q;){var Z=Q-1>>>1,ae=K[Z];if(0<i(ae,V))K[Z]=V,K[Q]=ae,Q=Z;else break e}}function n(K){return K.length===0?null:K[0]}function r(K){if(K.length===0)return null;var V=K[0],Q=K.pop();if(Q!==V){K[0]=Q;e:for(var Z=0,ae=K.length,B=ae>>>1;Z<B;){var X=2*(Z+1)-1,ne=K[X],se=X+1,be=K[se];if(0>i(ne,Q))se<ae&&0>i(be,ne)?(K[Z]=be,K[se]=Q,Z=se):(K[Z]=ne,K[X]=Q,Z=X);else if(se<ae&&0>i(be,Q))K[Z]=be,K[se]=Q,Z=se;else break e}}return V}function i(K,V){var Q=K.sortIndex-V.sortIndex;return Q!==0?Q:K.id-V.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var a=performance;t.unstable_now=function(){return a.now()}}else{var o=Date,l=o.now();t.unstable_now=function(){return o.now()-l}}var c=[],u=[],d=1,f=null,p=3,m=!1,x=!1,b=!1,y=!1,v=typeof setTimeout=="function"?setTimeout:null,S=typeof clearTimeout=="function"?clearTimeout:null,N=typeof setImmediate<"u"?setImmediate:null;function T(K){for(var V=n(u);V!==null;){if(V.callback===null)r(u);else if(V.startTime<=K)r(u),V.sortIndex=V.expirationTime,e(c,V);else break;V=n(u)}}function k(K){if(b=!1,T(K),!x)if(n(c)!==null)x=!0,C||(C=!0,F());else{var V=n(u);V!==null&&H(k,V.startTime-K)}}var C=!1,E=-1,D=5,A=-1;function R(){return y?!0:!(t.unstable_now()-A<D)}function U(){if(y=!1,C){var K=t.unstable_now();A=K;var V=!0;try{e:{x=!1,b&&(b=!1,S(E),E=-1),m=!0;var Q=p;try{t:{for(T(K),f=n(c);f!==null&&!(f.expirationTime>K&&R());){var Z=f.callback;if(typeof Z=="function"){f.callback=null,p=f.priorityLevel;var ae=Z(f.expirationTime<=K);if(K=t.unstable_now(),typeof ae=="function"){f.callback=ae,T(K),V=!0;break t}f===n(c)&&r(c),T(K)}else r(c);f=n(c)}if(f!==null)V=!0;else{var B=n(u);B!==null&&H(k,B.startTime-K),V=!1}}break e}finally{f=null,p=Q,m=!1}V=void 0}}finally{V?F():C=!1}}}var F;if(typeof N=="function")F=function(){N(U)};else if(typeof MessageChannel<"u"){var $=new MessageChannel,j=$.port2;$.port1.onmessage=U,F=function(){j.postMessage(null)}}else F=function(){v(U,0)};function H(K,V){E=v(function(){K(t.unstable_now())},V)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(K){K.callback=null},t.unstable_forceFrameRate=function(K){0>K||125<K?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):D=0<K?Math.floor(1e3/K):5},t.unstable_getCurrentPriorityLevel=function(){return p},t.unstable_next=function(K){switch(p){case 1:case 2:case 3:var V=3;break;default:V=p}var Q=p;p=V;try{return K()}finally{p=Q}},t.unstable_requestPaint=function(){y=!0},t.unstable_runWithPriority=function(K,V){switch(K){case 1:case 2:case 3:case 4:case 5:break;default:K=3}var Q=p;p=K;try{return V()}finally{p=Q}},t.unstable_scheduleCallback=function(K,V,Q){var Z=t.unstable_now();switch(typeof Q=="object"&&Q!==null?(Q=Q.delay,Q=typeof Q=="number"&&0<Q?Z+Q:Z):Q=Z,K){case 1:var ae=-1;break;case 2:ae=250;break;case 5:ae=1073741823;break;case 4:ae=1e4;break;default:ae=5e3}return ae=Q+ae,K={id:d++,callback:V,priorityLevel:K,startTime:Q,expirationTime:ae,sortIndex:-1},Q>Z?(K.sortIndex=Q,e(u,K),n(c)===null&&K===n(u)&&(b?(S(E),E=-1):b=!0,H(k,Q-Z))):(K.sortIndex=ae,e(c,K),x||m||(x=!0,C||(C=!0,F()))),K},t.unstable_shouldYield=R,t.unstable_wrapCallback=function(K){var V=p;return function(){var Q=p;p=V;try{return K.apply(this,arguments)}finally{p=Q}}}})(VE)),VE}var HU;function Oae(){return HU||(HU=1,$E.exports=Rae()),$E.exports}var GE={exports:{}},Ha={};var $U;function Lae(){if($U)return Ha;$U=1;var t=px();function e(c){var u="https://react.dev/errors/"+c;if(1<arguments.length){u+="?args[]="+encodeURIComponent(arguments[1]);for(var d=2;d<arguments.length;d++)u+="&args[]="+encodeURIComponent(arguments[d])}return"Minified React error #"+c+"; visit "+u+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var r={d:{f:n,r:function(){throw Error(e(522))},D:n,C:n,L:n,m:n,X:n,S:n,M:n},p:0,findDOMNode:null},i=Symbol.for("react.portal");function a(c,u,d){var f=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:i,key:f==null?null:""+f,children:c,containerInfo:u,implementation:d}}var o=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function l(c,u){if(c==="font")return"";if(typeof u=="string")return u==="use-credentials"?u:""}return Ha.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,Ha.createPortal=function(c,u){var d=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!u||u.nodeType!==1&&u.nodeType!==9&&u.nodeType!==11)throw Error(e(299));return a(c,u,null,d)},Ha.flushSync=function(c){var u=o.T,d=r.p;try{if(o.T=null,r.p=2,c)return c()}finally{o.T=u,r.p=d,r.d.f()}},Ha.preconnect=function(c,u){typeof c=="string"&&(u?(u=u.crossOrigin,u=typeof u=="string"?u==="use-credentials"?u:"":void 0):u=null,r.d.C(c,u))},Ha.prefetchDNS=function(c){typeof c=="string"&&r.d.D(c)},Ha.preinit=function(c,u){if(typeof c=="string"&&u&&typeof u.as=="string"){var d=u.as,f=l(d,u.crossOrigin),p=typeof u.integrity=="string"?u.integrity:void 0,m=typeof u.fetchPriority=="string"?u.fetchPriority:void 0;d==="style"?r.d.S(c,typeof u.precedence=="string"?u.precedence:void 0,{crossOrigin:f,integrity:p,fetchPriority:m}):d==="script"&&r.d.X(c,{crossOrigin:f,integrity:p,fetchPriority:m,nonce:typeof u.nonce=="string"?u.nonce:void 0})}},Ha.preinitModule=function(c,u){if(typeof c=="string")if(typeof u=="object"&&u!==null){if(u.as==null||u.as==="script"){var d=l(u.as,u.crossOrigin);r.d.M(c,{crossOrigin:d,integrity:typeof u.integrity=="string"?u.integrity:void 0,nonce:typeof u.nonce=="string"?u.nonce:void 0})}}else u==null&&r.d.M(c)},Ha.preload=function(c,u){if(typeof c=="string"&&typeof u=="object"&&u!==null&&typeof u.as=="string"){var d=u.as,f=l(d,u.crossOrigin);r.d.L(c,d,{crossOrigin:f,integrity:typeof u.integrity=="string"?u.integrity:void 0,nonce:typeof u.nonce=="string"?u.nonce:void 0,type:typeof u.type=="string"?u.type:void 0,fetchPriority:typeof u.fetchPriority=="string"?u.fetchPriority:void 0,referrerPolicy:typeof u.referrerPolicy=="string"?u.referrerPolicy:void 0,imageSrcSet:typeof u.imageSrcSet=="string"?u.imageSrcSet:void 0,imageSizes:typeof u.imageSizes=="string"?u.imageSizes:void 0,media:typeof u.media=="string"?u.media:void 0})}},Ha.preloadModule=function(c,u){if(typeof c=="string")if(u){var d=l(u.as,u.crossOrigin);r.d.m(c,{as:typeof u.as=="string"&&u.as!=="script"?u.as:void 0,crossOrigin:d,integrity:typeof u.integrity=="string"?u.integrity:void 0})}else r.d.m(c)},Ha.requestFormReset=function(c){r.d.r(c)},Ha.unstable_batchedUpdates=function(c,u){return c(u)},Ha.useFormState=function(c,u,d){return o.H.useFormState(c,u,d)},Ha.useFormStatus=function(){return o.H.useHostTransitionStatus()},Ha.version="19.2.0",Ha}var VU;function yq(){if(VU)return GE.exports;VU=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),GE.exports=Lae(),GE.exports}var GU;function Fae(){if(GU)return Tb;GU=1;var t=Oae(),e=px(),n=yq();function r(h){var g="https://react.dev/errors/"+h;if(1<arguments.length){g+="?args[]="+encodeURIComponent(arguments[1]);for(var w=2;w<arguments.length;w++)g+="&args[]="+encodeURIComponent(arguments[w])}return"Minified React error #"+h+"; visit "+g+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function i(h){return!(!h||h.nodeType!==1&&h.nodeType!==9&&h.nodeType!==11)}function a(h){var g=h,w=h;if(h.alternate)for(;g.return;)g=g.return;else{h=g;do g=h,(g.flags&4098)!==0&&(w=g.return),h=g.return;while(h)}return g.tag===3?w:null}function o(h){if(h.tag===13){var g=h.memoizedState;if(g===null&&(h=h.alternate,h!==null&&(g=h.memoizedState)),g!==null)return g.dehydrated}return null}function l(h){if(h.tag===31){var g=h.memoizedState;if(g===null&&(h=h.alternate,h!==null&&(g=h.memoizedState)),g!==null)return g.dehydrated}return null}function c(h){if(a(h)!==h)throw Error(r(188))}function u(h){var g=h.alternate;if(!g){if(g=a(h),g===null)throw Error(r(188));return g!==h?null:h}for(var w=h,M=g;;){var P=w.return;if(P===null)break;var L=P.alternate;if(L===null){if(M=P.return,M!==null){w=M;continue}break}if(P.child===L.child){for(L=P.child;L;){if(L===w)return c(P),h;if(L===M)return c(P),g;L=L.sibling}throw Error(r(188))}if(w.return!==M.return)w=P,M=L;else{for(var J=!1,ve=P.child;ve;){if(ve===w){J=!0,w=P,M=L;break}if(ve===M){J=!0,M=P,w=L;break}ve=ve.sibling}if(!J){for(ve=L.child;ve;){if(ve===w){J=!0,w=L,M=P;break}if(ve===M){J=!0,M=L,w=P;break}ve=ve.sibling}if(!J)throw Error(r(189))}}if(w.alternate!==M)throw Error(r(190))}if(w.tag!==3)throw Error(r(188));return w.stateNode.current===w?h:g}function d(h){var g=h.tag;if(g===5||g===26||g===27||g===6)return h;for(h=h.child;h!==null;){if(g=d(h),g!==null)return g;h=h.sibling}return null}var f=Object.assign,p=Symbol.for("react.element"),m=Symbol.for("react.transitional.element"),x=Symbol.for("react.portal"),b=Symbol.for("react.fragment"),y=Symbol.for("react.strict_mode"),v=Symbol.for("react.profiler"),S=Symbol.for("react.consumer"),N=Symbol.for("react.context"),T=Symbol.for("react.forward_ref"),k=Symbol.for("react.suspense"),C=Symbol.for("react.suspense_list"),E=Symbol.for("react.memo"),D=Symbol.for("react.lazy"),A=Symbol.for("react.activity"),R=Symbol.for("react.memo_cache_sentinel"),U=Symbol.iterator;function F(h){return h===null||typeof h!="object"?null:(h=U&&h[U]||h["@@iterator"],typeof h=="function"?h:null)}var $=Symbol.for("react.client.reference");function j(h){if(h==null)return null;if(typeof h=="function")return h.$$typeof===$?null:h.displayName||h.name||null;if(typeof h=="string")return h;switch(h){case b:return"Fragment";case v:return"Profiler";case y:return"StrictMode";case k:return"Suspense";case C:return"SuspenseList";case A:return"Activity"}if(typeof h=="object")switch(h.$$typeof){case x:return"Portal";case N:return h.displayName||"Context";case S:return(h._context.displayName||"Context")+".Consumer";case T:var g=h.render;return h=h.displayName,h||(h=g.displayName||g.name||"",h=h!==""?"ForwardRef("+h+")":"ForwardRef"),h;case E:return g=h.displayName||null,g!==null?g:j(h.type)||"Memo";case D:g=h._payload,h=h._init;try{return j(h(g))}catch{}}return null}var H=Array.isArray,K=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,V=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Q={pending:!1,data:null,method:null,action:null},Z=[],ae=-1;function B(h){return{current:h}}function X(h){0>ae||(h.current=Z[ae],Z[ae]=null,ae--)}function ne(h,g){ae++,Z[ae]=h.current,h.current=g}var se=B(null),be=B(null),xe=B(null),de=B(null);function Pe(h,g){switch(ne(xe,g),ne(be,h),ne(se,null),g.nodeType){case 9:case 11:h=(h=g.documentElement)&&(h=h.namespaceURI)?sU(h):0;break;default:if(h=g.tagName,g=g.namespaceURI)g=sU(g),h=oU(g,h);else switch(h){case"svg":h=1;break;case"math":h=2;break;default:h=0}}X(se),ne(se,h)}function ie(){X(se),X(be),X(xe)}function Ne(h){h.memoizedState!==null&&ne(de,h);var g=se.current,w=oU(g,h.type);g!==w&&(ne(be,h),ne(se,w))}function Oe(h){be.current===h&&(X(se),X(be)),de.current===h&&(X(de),Sb._currentValue=Q)}var ge,Ke;function G(h){if(ge===void 0)try{throw Error()}catch(w){var g=w.stack.trim().match(/\n( *(at )?)/);ge=g&&g[1]||"",Ke=-1<w.stack.indexOf(`
- at`)?" (<anonymous>)":-1<w.stack.indexOf("@")?"@unknown:0:0":""}return`
- `+ge+h+Ke}var Y=!1;function ce(h,g){if(!h||Y)return"";Y=!0;var w=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var M={DetermineComponentFrameRoot:function(){try{if(g){var vt=function(){throw Error()};if(Object.defineProperty(vt.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(vt,[])}catch(pt){var ct=pt}Reflect.construct(h,[],vt)}else{try{vt.call()}catch(pt){ct=pt}h.call(vt.prototype)}}else{try{throw Error()}catch(pt){ct=pt}(vt=h())&&typeof vt.catch=="function"&&vt.catch(function(){})}}catch(pt){if(pt&&ct&&typeof pt.stack=="string")return[pt.stack,ct.stack]}return[null,null]}};M.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var P=Object.getOwnPropertyDescriptor(M.DetermineComponentFrameRoot,"name");P&&P.configurable&&Object.defineProperty(M.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var L=M.DetermineComponentFrameRoot(),J=L[0],ve=L[1];if(J&&ve){var Ue=J.split(`
- `),it=ve.split(`
- `);for(P=M=0;M<Ue.length&&!Ue[M].includes("DetermineComponentFrameRoot");)M++;for(;P<it.length&&!it[P].includes("DetermineComponentFrameRoot");)P++;if(M===Ue.length||P===it.length)for(M=Ue.length-1,P=it.length-1;1<=M&&0<=P&&Ue[M]!==it[P];)P--;for(;1<=M&&0<=P;M--,P--)if(Ue[M]!==it[P]){if(M!==1||P!==1)do if(M--,P--,0>P||Ue[M]!==it[P]){var gt=`
- `+Ue[M].replace(" at new "," at ");return h.displayName&>.includes("<anonymous>")&&(gt=gt.replace("<anonymous>",h.displayName)),gt}while(1<=M&&0<=P);break}}}finally{Y=!1,Error.prepareStackTrace=w}return(w=h?h.displayName||h.name:"")?G(w):""}function q(h,g){switch(h.tag){case 26:case 27:case 5:return G(h.type);case 16:return G("Lazy");case 13:return h.child!==g&&g!==null?G("Suspense Fallback"):G("Suspense");case 19:return G("SuspenseList");case 0:case 15:return ce(h.type,!1);case 11:return ce(h.type.render,!1);case 1:return ce(h.type,!0);case 31:return G("Activity");default:return""}}function te(h){try{var g="",w=null;do g+=q(h,w),w=h,h=h.return;while(h);return g}catch(M){return`
- Error generating stack: `+M.message+`
- `+M.stack}}var I=Object.prototype.hasOwnProperty,fe=t.unstable_scheduleCallback,me=t.unstable_cancelCallback,Ee=t.unstable_shouldYield,z=t.unstable_requestPaint,O=t.unstable_now,ee=t.unstable_getCurrentPriorityLevel,le=t.unstable_ImmediatePriority,_e=t.unstable_UserBlockingPriority,we=t.unstable_NormalPriority,re=t.unstable_LowPriority,Fe=t.unstable_IdlePriority,He=t.log,Ve=t.unstable_setDisableYieldValue,$e=null,ye=null;function je(h){if(typeof He=="function"&&Ve(h),ye&&typeof ye.setStrictMode=="function")try{ye.setStrictMode($e,h)}catch{}}var Be=Math.clz32?Math.clz32:Me,Se=Math.log,Xe=Math.LN2;function Me(h){return h>>>=0,h===0?32:31-(Se(h)/Xe|0)|0}var tt=256,ke=262144,We=4194304;function ze(h){var g=h&42;if(g!==0)return g;switch(h&-h){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return h&261888;case 262144:case 524288:case 1048576:case 2097152:return h&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return h&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return h}}function W(h,g,w){var M=h.pendingLanes;if(M===0)return 0;var P=0,L=h.suspendedLanes,J=h.pingedLanes;h=h.warmLanes;var ve=M&134217727;return ve!==0?(M=ve&~L,M!==0?P=ze(M):(J&=ve,J!==0?P=ze(J):w||(w=ve&~h,w!==0&&(P=ze(w))))):(ve=M&~L,ve!==0?P=ze(ve):J!==0?P=ze(J):w||(w=M&~h,w!==0&&(P=ze(w)))),P===0?0:g!==0&&g!==P&&(g&L)===0&&(L=P&-P,w=g&-g,L>=w||L===32&&(w&4194048)!==0)?g:P}function De(h,g){return(h.pendingLanes&~(h.suspendedLanes&~h.pingedLanes)&g)===0}function Ye(h,g){switch(h){case 1:case 2:case 4:case 8:case 64:return g+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return g+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function xt(){var h=We;return We<<=1,(We&62914560)===0&&(We=4194304),h}function ft(h){for(var g=[],w=0;31>w;w++)g.push(h);return g}function Bt(h,g){h.pendingLanes|=g,g!==268435456&&(h.suspendedLanes=0,h.pingedLanes=0,h.warmLanes=0)}function Lt(h,g,w,M,P,L){var J=h.pendingLanes;h.pendingLanes=w,h.suspendedLanes=0,h.pingedLanes=0,h.warmLanes=0,h.expiredLanes&=w,h.entangledLanes&=w,h.errorRecoveryDisabledLanes&=w,h.shellSuspendCounter=0;var ve=h.entanglements,Ue=h.expirationTimes,it=h.hiddenUpdates;for(w=J&~w;0<w;){var gt=31-Be(w),vt=1<<gt;ve[gt]=0,Ue[gt]=-1;var ct=it[gt];if(ct!==null)for(it[gt]=null,gt=0;gt<ct.length;gt++){var pt=ct[gt];pt!==null&&(pt.lane&=-536870913)}w&=~vt}M!==0&&vn(h,M,0),L!==0&&P===0&&h.tag!==0&&(h.suspendedLanes|=L&~(J&~g))}function vn(h,g,w){h.pendingLanes|=g,h.suspendedLanes&=~g;var M=31-Be(g);h.entangledLanes|=g,h.entanglements[M]=h.entanglements[M]|1073741824|w&261930}function Jt(h,g){var w=h.entangledLanes|=g;for(h=h.entanglements;w;){var M=31-Be(w),P=1<<M;P&g|h[M]&g&&(h[M]|=g),w&=~P}}function ir(h,g){var w=g&-g;return w=(w&42)!==0?1:fr(w),(w&(h.suspendedLanes|g))!==0?0:w}function fr(h){switch(h){case 2:h=1;break;case 8:h=4;break;case 32:h=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:h=128;break;case 268435456:h=134217728;break;default:h=0}return h}function Dn(h){return h&=-h,2<h?8<h?(h&134217727)!==0?32:268435456:8:2}function ln(){var h=V.p;return h!==0?h:(h=window.event,h===void 0?32:CU(h.type))}function mr(h,g){var w=V.p;try{return V.p=h,g()}finally{V.p=w}}var Fn=Math.random().toString(36).slice(2),Xn="__reactFiber$"+Fn,bn="__reactProps$"+Fn,wi="__reactContainer$"+Fn,Ba="__reactEvents$"+Fn,Ae="__reactListeners$"+Fn,Ze="__reactHandles$"+Fn,st="__reactResources$"+Fn,lt="__reactMarker$"+Fn;function ot(h){delete h[Xn],delete h[bn],delete h[Ba],delete h[Ae],delete h[Ze]}function Et(h){var g=h[Xn];if(g)return g;for(var w=h.parentNode;w;){if(g=w[wi]||w[Xn]){if(w=g.alternate,g.child!==null||w!==null&&w.child!==null)for(h=mU(h);h!==null;){if(w=h[Xn])return w;h=mU(h)}return g}h=w,w=h.parentNode}return null}function he(h){if(h=h[Xn]||h[wi]){var g=h.tag;if(g===5||g===6||g===13||g===31||g===26||g===27||g===3)return h}return null}function pe(h){var g=h.tag;if(g===5||g===26||g===27||g===6)return h.stateNode;throw Error(r(33))}function Ie(h){var g=h[st];return g||(g=h[st]={hoistableStyles:new Map,hoistableScripts:new Map}),g}function Le(h){h[lt]=!0}var Ce=new Set,ut={};function St(h,g){At(h,g),At(h+"Capture",g)}function At(h,g){for(ut[h]=g,h=0;h<g.length;h++)Ce.add(g[h])}var Tt=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),Ft={},Pt={};function Nt(h){return I.call(Pt,h)?!0:I.call(Ft,h)?!1:Tt.test(h)?Pt[h]=!0:(Ft[h]=!0,!1)}function en(h,g,w){if(Nt(g))if(w===null)h.removeAttribute(g);else{switch(typeof w){case"undefined":case"function":case"symbol":h.removeAttribute(g);return;case"boolean":var M=g.toLowerCase().slice(0,5);if(M!=="data-"&&M!=="aria-"){h.removeAttribute(g);return}}h.setAttribute(g,""+w)}}function Ht(h,g,w){if(w===null)h.removeAttribute(g);else{switch(typeof w){case"undefined":case"function":case"symbol":case"boolean":h.removeAttribute(g);return}h.setAttribute(g,""+w)}}function dn(h,g,w,M){if(M===null)h.removeAttribute(w);else{switch(typeof M){case"undefined":case"function":case"symbol":case"boolean":h.removeAttribute(w);return}h.setAttributeNS(g,w,""+M)}}function cn(h){switch(typeof h){case"bigint":case"boolean":case"number":case"string":case"undefined":return h;case"object":return h;default:return""}}function Sn(h){var g=h.type;return(h=h.nodeName)&&h.toLowerCase()==="input"&&(g==="checkbox"||g==="radio")}function Gt(h,g,w){var M=Object.getOwnPropertyDescriptor(h.constructor.prototype,g);if(!h.hasOwnProperty(g)&&typeof M<"u"&&typeof M.get=="function"&&typeof M.set=="function"){var P=M.get,L=M.set;return Object.defineProperty(h,g,{configurable:!0,get:function(){return P.call(this)},set:function(J){w=""+J,L.call(this,J)}}),Object.defineProperty(h,g,{enumerable:M.enumerable}),{getValue:function(){return w},setValue:function(J){w=""+J},stopTracking:function(){h._valueTracker=null,delete h[g]}}}}function sn(h){if(!h._valueTracker){var g=Sn(h)?"checked":"value";h._valueTracker=Gt(h,g,""+h[g])}}function un(h){if(!h)return!1;var g=h._valueTracker;if(!g)return!0;var w=g.getValue(),M="";return h&&(M=Sn(h)?h.checked?"true":"false":h.value),h=M,h!==w?(g.setValue(h),!0):!1}function Yt(h){if(h=h||(typeof document<"u"?document:void 0),typeof h>"u")return null;try{return h.activeElement||h.body}catch{return h.body}}var nr=/[\n"\\]/g;function jn(h){return h.replace(nr,function(g){return"\\"+g.charCodeAt(0).toString(16)+" "})}function ii(h,g,w,M,P,L,J,ve){h.name="",J!=null&&typeof J!="function"&&typeof J!="symbol"&&typeof J!="boolean"?h.type=J:h.removeAttribute("type"),g!=null?J==="number"?(g===0&&h.value===""||h.value!=g)&&(h.value=""+cn(g)):h.value!==""+cn(g)&&(h.value=""+cn(g)):J!=="submit"&&J!=="reset"||h.removeAttribute("value"),g!=null?cr(h,J,cn(g)):w!=null?cr(h,J,cn(w)):M!=null&&h.removeAttribute("value"),P==null&&L!=null&&(h.defaultChecked=!!L),P!=null&&(h.checked=P&&typeof P!="function"&&typeof P!="symbol"),ve!=null&&typeof ve!="function"&&typeof ve!="symbol"&&typeof ve!="boolean"?h.name=""+cn(ve):h.removeAttribute("name")}function rr(h,g,w,M,P,L,J,ve){if(L!=null&&typeof L!="function"&&typeof L!="symbol"&&typeof L!="boolean"&&(h.type=L),g!=null||w!=null){if(!(L!=="submit"&&L!=="reset"||g!=null)){sn(h);return}w=w!=null?""+cn(w):"",g=g!=null?""+cn(g):w,ve||g===h.value||(h.value=g),h.defaultValue=g}M=M??P,M=typeof M!="function"&&typeof M!="symbol"&&!!M,h.checked=ve?h.checked:!!M,h.defaultChecked=!!M,J!=null&&typeof J!="function"&&typeof J!="symbol"&&typeof J!="boolean"&&(h.name=J),sn(h)}function cr(h,g,w){g==="number"&&Yt(h.ownerDocument)===h||h.defaultValue===""+w||(h.defaultValue=""+w)}function et(h,g,w,M){if(h=h.options,g){g={};for(var P=0;P<w.length;P++)g["$"+w[P]]=!0;for(w=0;w<h.length;w++)P=g.hasOwnProperty("$"+h[w].value),h[w].selected!==P&&(h[w].selected=P),P&&M&&(h[w].defaultSelected=!0)}else{for(w=""+cn(w),g=null,P=0;P<h.length;P++){if(h[P].value===w){h[P].selected=!0,M&&(h[P].defaultSelected=!0);return}g!==null||h[P].disabled||(g=h[P])}g!==null&&(g.selected=!0)}}function jt(h,g,w){if(g!=null&&(g=""+cn(g),g!==h.value&&(h.value=g),w==null)){h.defaultValue!==g&&(h.defaultValue=g);return}h.defaultValue=w!=null?""+cn(w):""}function qt(h,g,w,M){if(g==null){if(M!=null){if(w!=null)throw Error(r(92));if(H(M)){if(1<M.length)throw Error(r(93));M=M[0]}w=M}w==null&&(w=""),g=w}w=cn(g),h.defaultValue=w,M=h.textContent,M===w&&M!==""&&M!==null&&(h.value=M),sn(h)}function yt(h,g){if(g){var w=h.firstChild;if(w&&w===h.lastChild&&w.nodeType===3){w.nodeValue=g;return}}h.textContent=g}var wn=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function Fr(h,g,w){var M=g.indexOf("--")===0;w==null||typeof w=="boolean"||w===""?M?h.setProperty(g,""):g==="float"?h.cssFloat="":h[g]="":M?h.setProperty(g,w):typeof w!="number"||w===0||wn.has(g)?g==="float"?h.cssFloat=w:h[g]=(""+w).trim():h[g]=w+"px"}function Yr(h,g,w){if(g!=null&&typeof g!="object")throw Error(r(62));if(h=h.style,w!=null){for(var M in w)!w.hasOwnProperty(M)||g!=null&&g.hasOwnProperty(M)||(M.indexOf("--")===0?h.setProperty(M,""):M==="float"?h.cssFloat="":h[M]="");for(var P in g)M=g[P],g.hasOwnProperty(P)&&w[P]!==M&&Fr(h,P,M)}else for(var L in g)g.hasOwnProperty(L)&&Fr(h,L,g[L])}function Br(h){if(h.indexOf("-")===-1)return!1;switch(h){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Ws=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),tn=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function on(h){return tn.test(""+h)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":h}function _i(){}var Ss=null;function _o(h){return h=h.target||h.srcElement||window,h.correspondingUseElement&&(h=h.correspondingUseElement),h.nodeType===3?h.parentNode:h}var So=null,Mo=null;function Ms(h){var g=he(h);if(g&&(h=g.stateNode)){var w=h[bn]||null;e:switch(h=g.stateNode,g.type){case"input":if(ii(h,w.value,w.defaultValue,w.defaultValue,w.checked,w.defaultChecked,w.type,w.name),g=w.name,w.type==="radio"&&g!=null){for(w=h;w.parentNode;)w=w.parentNode;for(w=w.querySelectorAll('input[name="'+jn(""+g)+'"][type="radio"]'),g=0;g<w.length;g++){var M=w[g];if(M!==h&&M.form===h.form){var P=M[bn]||null;if(!P)throw Error(r(90));ii(M,P.value,P.defaultValue,P.defaultValue,P.checked,P.defaultChecked,P.type,P.name)}}for(g=0;g<w.length;g++)M=w[g],M.form===h.form&&un(M)}break e;case"textarea":jt(h,w.value,w.defaultValue);break e;case"select":g=w.value,g!=null&&et(h,!!w.multiple,g,!1)}}}var Si=!1;function Ks(h,g,w){if(Si)return h(g,w);Si=!0;try{var M=h(g);return M}finally{if(Si=!1,(So!==null||Mo!==null)&&(ow(),So&&(g=So,h=Mo,Mo=So=null,Ms(g),h)))for(g=0;g<h.length;g++)Ms(h[g])}}function la(h,g){var w=h.stateNode;if(w===null)return null;var M=w[bn]||null;if(M===null)return null;w=M[g];e:switch(g){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(M=!M.disabled)||(h=h.type,M=!(h==="button"||h==="input"||h==="select"||h==="textarea")),h=!M;break e;default:h=!1}if(h)return null;if(w&&typeof w!="function")throw Error(r(231,g,typeof w));return w}var Hr=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Ux=!1;if(Hr)try{var $h={};Object.defineProperty($h,"passive",{get:function(){Ux=!0}}),window.addEventListener("test",$h,$h),window.removeEventListener("test",$h,$h)}catch{Ux=!1}var $l=null,zx=null,Dm=null;function Rm(){if(Dm)return Dm;var h,g=zx,w=g.length,M,P="value"in $l?$l.value:$l.textContent,L=P.length;for(h=0;h<w&&g[h]===P[h];h++);var J=w-h;for(M=1;M<=J&&g[w-M]===P[L-M];M++);return Dm=P.slice(h,1<M?1-M:void 0)}function Vh(h){var g=h.keyCode;return"charCode"in h?(h=h.charCode,h===0&&g===13&&(h=13)):h=g,h===10&&(h=13),32<=h||h===13?h:0}function Qu(){return!0}function Cc(){return!1}function ca(h){function g(w,M,P,L,J){this._reactName=w,this._targetInst=P,this.type=M,this.nativeEvent=L,this.target=J,this.currentTarget=null;for(var ve in h)h.hasOwnProperty(ve)&&(w=h[ve],this[ve]=w?w(L):L[ve]);return this.isDefaultPrevented=(L.defaultPrevented!=null?L.defaultPrevented:L.returnValue===!1)?Qu:Cc,this.isPropagationStopped=Cc,this}return f(g.prototype,{preventDefault:function(){this.defaultPrevented=!0;var w=this.nativeEvent;w&&(w.preventDefault?w.preventDefault():typeof w.returnValue!="unknown"&&(w.returnValue=!1),this.isDefaultPrevented=Qu)},stopPropagation:function(){var w=this.nativeEvent;w&&(w.stopPropagation?w.stopPropagation():typeof w.cancelBubble!="unknown"&&(w.cancelBubble=!0),this.isPropagationStopped=Qu)},persist:function(){},isPersistent:Qu}),g}var pl={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(h){return h.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Vl=ca(pl),gl=f({},pl,{view:0,detail:0}),Om=ca(gl),Lm,Fm,Zu,hn=f({},gl,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:$x,button:0,buttons:0,relatedTarget:function(h){return h.relatedTarget===void 0?h.fromElement===h.srcElement?h.toElement:h.fromElement:h.relatedTarget},movementX:function(h){return"movementX"in h?h.movementX:(h!==Zu&&(Zu&&h.type==="mousemove"?(Lm=h.screenX-Zu.screenX,Fm=h.screenY-Zu.screenY):Fm=Lm=0,Zu=h),Lm)},movementY:function(h){return"movementY"in h?h.movementY:Fm}}),Sv=ca(hn),Bx=f({},hn,{dataTransfer:0}),Mv=ca(Bx),Hx=f({},gl,{relatedTarget:0}),Im=ca(Hx),G2=f({},pl,{animationName:0,elapsedTime:0,pseudoElement:0}),Nv=ca(G2),oe=f({},pl,{clipboardData:function(h){return"clipboardData"in h?h.clipboardData:window.clipboardData}}),wt=ca(oe),Rn=f({},pl,{data:0}),Jn=ca(Rn),No={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Ju={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},is={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function as(h){var g=this.nativeEvent;return g.getModifierState?g.getModifierState(h):(h=is[h])?!!g[h]:!1}function $x(){return as}var uF=f({},gl,{key:function(h){if(h.key){var g=No[h.key]||h.key;if(g!=="Unidentified")return g}return h.type==="keypress"?(h=Vh(h),h===13?"Enter":String.fromCharCode(h)):h.type==="keydown"||h.type==="keyup"?Ju[h.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:$x,charCode:function(h){return h.type==="keypress"?Vh(h):0},keyCode:function(h){return h.type==="keydown"||h.type==="keyup"?h.keyCode:0},which:function(h){return h.type==="keypress"?Vh(h):h.type==="keydown"||h.type==="keyup"?h.keyCode:0}}),Bre=ca(uF),Hre=f({},hn,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),dF=ca(Hre),$re=f({},gl,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:$x}),Vre=ca($re),Gre=f({},pl,{propertyName:0,elapsedTime:0,pseudoElement:0}),qre=ca(Gre),Wre=f({},hn,{deltaX:function(h){return"deltaX"in h?h.deltaX:"wheelDeltaX"in h?-h.wheelDeltaX:0},deltaY:function(h){return"deltaY"in h?h.deltaY:"wheelDeltaY"in h?-h.wheelDeltaY:"wheelDelta"in h?-h.wheelDelta:0},deltaZ:0,deltaMode:0}),Kre=ca(Wre),Xre=f({},pl,{newState:0,oldState:0}),Yre=ca(Xre),Qre=[9,13,27,32],q2=Hr&&"CompositionEvent"in window,Vx=null;Hr&&"documentMode"in document&&(Vx=document.documentMode);var Zre=Hr&&"TextEvent"in window&&!Vx,hF=Hr&&(!q2||Vx&&8<Vx&&11>=Vx),fF=" ",mF=!1;function pF(h,g){switch(h){case"keyup":return Qre.indexOf(g.keyCode)!==-1;case"keydown":return g.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function gF(h){return h=h.detail,typeof h=="object"&&"data"in h?h.data:null}var Um=!1;function Jre(h,g){switch(h){case"compositionend":return gF(g);case"keypress":return g.which!==32?null:(mF=!0,fF);case"textInput":return h=g.data,h===fF&&mF?null:h;default:return null}}function eie(h,g){if(Um)return h==="compositionend"||!q2&&pF(h,g)?(h=Rm(),Dm=zx=$l=null,Um=!1,h):null;switch(h){case"paste":return null;case"keypress":if(!(g.ctrlKey||g.altKey||g.metaKey)||g.ctrlKey&&g.altKey){if(g.char&&1<g.char.length)return g.char;if(g.which)return String.fromCharCode(g.which)}return null;case"compositionend":return hF&&g.locale!=="ko"?null:g.data;default:return null}}var tie={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function xF(h){var g=h&&h.nodeName&&h.nodeName.toLowerCase();return g==="input"?!!tie[h.type]:g==="textarea"}function bF(h,g,w,M){So?Mo?Mo.push(M):Mo=[M]:So=M,g=mw(g,"onChange"),0<g.length&&(w=new Vl("onChange","change",null,w,M),h.push({event:w,listeners:g}))}var Gx=null,qx=null;function nie(h){eU(h,0)}function kv(h){var g=pe(h);if(un(g))return h}function yF(h,g){if(h==="change")return g}var vF=!1;if(Hr){var W2;if(Hr){var K2="oninput"in document;if(!K2){var wF=document.createElement("div");wF.setAttribute("oninput","return;"),K2=typeof wF.oninput=="function"}W2=K2}else W2=!1;vF=W2&&(!document.documentMode||9<document.documentMode)}function _F(){Gx&&(Gx.detachEvent("onpropertychange",SF),qx=Gx=null)}function SF(h){if(h.propertyName==="value"&&kv(qx)){var g=[];bF(g,qx,h,_o(h)),Ks(nie,g)}}function rie(h,g,w){h==="focusin"?(_F(),Gx=g,qx=w,Gx.attachEvent("onpropertychange",SF)):h==="focusout"&&_F()}function iie(h){if(h==="selectionchange"||h==="keyup"||h==="keydown")return kv(qx)}function aie(h,g){if(h==="click")return kv(g)}function sie(h,g){if(h==="input"||h==="change")return kv(g)}function oie(h,g){return h===g&&(h!==0||1/h===1/g)||h!==h&&g!==g}var Xs=typeof Object.is=="function"?Object.is:oie;function Wx(h,g){if(Xs(h,g))return!0;if(typeof h!="object"||h===null||typeof g!="object"||g===null)return!1;var w=Object.keys(h),M=Object.keys(g);if(w.length!==M.length)return!1;for(M=0;M<w.length;M++){var P=w[M];if(!I.call(g,P)||!Xs(h[P],g[P]))return!1}return!0}function MF(h){for(;h&&h.firstChild;)h=h.firstChild;return h}function NF(h,g){var w=MF(h);h=0;for(var M;w;){if(w.nodeType===3){if(M=h+w.textContent.length,h<=g&&M>=g)return{node:w,offset:g-h};h=M}e:{for(;w;){if(w.nextSibling){w=w.nextSibling;break e}w=w.parentNode}w=void 0}w=MF(w)}}function kF(h,g){return h&&g?h===g?!0:h&&h.nodeType===3?!1:g&&g.nodeType===3?kF(h,g.parentNode):"contains"in h?h.contains(g):h.compareDocumentPosition?!!(h.compareDocumentPosition(g)&16):!1:!1}function EF(h){h=h!=null&&h.ownerDocument!=null&&h.ownerDocument.defaultView!=null?h.ownerDocument.defaultView:window;for(var g=Yt(h.document);g instanceof h.HTMLIFrameElement;){try{var w=typeof g.contentWindow.location.href=="string"}catch{w=!1}if(w)h=g.contentWindow;else break;g=Yt(h.document)}return g}function X2(h){var g=h&&h.nodeName&&h.nodeName.toLowerCase();return g&&(g==="input"&&(h.type==="text"||h.type==="search"||h.type==="tel"||h.type==="url"||h.type==="password")||g==="textarea"||h.contentEditable==="true")}var lie=Hr&&"documentMode"in document&&11>=document.documentMode,zm=null,Y2=null,Kx=null,Q2=!1;function TF(h,g,w){var M=w.window===w?w.document:w.nodeType===9?w:w.ownerDocument;Q2||zm==null||zm!==Yt(M)||(M=zm,"selectionStart"in M&&X2(M)?M={start:M.selectionStart,end:M.selectionEnd}:(M=(M.ownerDocument&&M.ownerDocument.defaultView||window).getSelection(),M={anchorNode:M.anchorNode,anchorOffset:M.anchorOffset,focusNode:M.focusNode,focusOffset:M.focusOffset}),Kx&&Wx(Kx,M)||(Kx=M,M=mw(Y2,"onSelect"),0<M.length&&(g=new Vl("onSelect","select",null,g,w),h.push({event:g,listeners:M}),g.target=zm)))}function Gh(h,g){var w={};return w[h.toLowerCase()]=g.toLowerCase(),w["Webkit"+h]="webkit"+g,w["Moz"+h]="moz"+g,w}var Bm={animationend:Gh("Animation","AnimationEnd"),animationiteration:Gh("Animation","AnimationIteration"),animationstart:Gh("Animation","AnimationStart"),transitionrun:Gh("Transition","TransitionRun"),transitionstart:Gh("Transition","TransitionStart"),transitioncancel:Gh("Transition","TransitionCancel"),transitionend:Gh("Transition","TransitionEnd")},Z2={},AF={};Hr&&(AF=document.createElement("div").style,"AnimationEvent"in window||(delete Bm.animationend.animation,delete Bm.animationiteration.animation,delete Bm.animationstart.animation),"TransitionEvent"in window||delete Bm.transitionend.transition);function qh(h){if(Z2[h])return Z2[h];if(!Bm[h])return h;var g=Bm[h],w;for(w in g)if(g.hasOwnProperty(w)&&w in AF)return Z2[h]=g[w];return h}var CF=qh("animationend"),jF=qh("animationiteration"),PF=qh("animationstart"),cie=qh("transitionrun"),uie=qh("transitionstart"),die=qh("transitioncancel"),DF=qh("transitionend"),RF=new Map,J2="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(" ");J2.push("scrollEnd");function xl(h,g){RF.set(h,g),St(g,[h])}var Ev=typeof reportError=="function"?reportError:function(h){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var g=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof h=="object"&&h!==null&&typeof h.message=="string"?String(h.message):String(h),error:h});if(!window.dispatchEvent(g))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",h);return}console.error(h)},ko=[],Hm=0,ek=0;function Tv(){for(var h=Hm,g=ek=Hm=0;g<h;){var w=ko[g];ko[g++]=null;var M=ko[g];ko[g++]=null;var P=ko[g];ko[g++]=null;var L=ko[g];if(ko[g++]=null,M!==null&&P!==null){var J=M.pending;J===null?P.next=P:(P.next=J.next,J.next=P),M.pending=P}L!==0&&OF(w,P,L)}}function Av(h,g,w,M){ko[Hm++]=h,ko[Hm++]=g,ko[Hm++]=w,ko[Hm++]=M,ek|=M,h.lanes|=M,h=h.alternate,h!==null&&(h.lanes|=M)}function tk(h,g,w,M){return Av(h,g,w,M),Cv(h)}function Wh(h,g){return Av(h,null,null,g),Cv(h)}function OF(h,g,w){h.lanes|=w;var M=h.alternate;M!==null&&(M.lanes|=w);for(var P=!1,L=h.return;L!==null;)L.childLanes|=w,M=L.alternate,M!==null&&(M.childLanes|=w),L.tag===22&&(h=L.stateNode,h===null||h._visibility&1||(P=!0)),h=L,L=L.return;return h.tag===3?(L=h.stateNode,P&&g!==null&&(P=31-Be(w),h=L.hiddenUpdates,M=h[P],M===null?h[P]=[g]:M.push(g),g.lane=w|536870912),L):null}function Cv(h){if(50<gb)throw gb=0,uE=null,Error(r(185));for(var g=h.return;g!==null;)h=g,g=h.return;return h.tag===3?h.stateNode:null}var $m={};function hie(h,g,w,M){this.tag=h,this.key=w,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=g,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=M,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Ys(h,g,w,M){return new hie(h,g,w,M)}function nk(h){return h=h.prototype,!(!h||!h.isReactComponent)}function jc(h,g){var w=h.alternate;return w===null?(w=Ys(h.tag,g,h.key,h.mode),w.elementType=h.elementType,w.type=h.type,w.stateNode=h.stateNode,w.alternate=h,h.alternate=w):(w.pendingProps=g,w.type=h.type,w.flags=0,w.subtreeFlags=0,w.deletions=null),w.flags=h.flags&65011712,w.childLanes=h.childLanes,w.lanes=h.lanes,w.child=h.child,w.memoizedProps=h.memoizedProps,w.memoizedState=h.memoizedState,w.updateQueue=h.updateQueue,g=h.dependencies,w.dependencies=g===null?null:{lanes:g.lanes,firstContext:g.firstContext},w.sibling=h.sibling,w.index=h.index,w.ref=h.ref,w.refCleanup=h.refCleanup,w}function LF(h,g){h.flags&=65011714;var w=h.alternate;return w===null?(h.childLanes=0,h.lanes=g,h.child=null,h.subtreeFlags=0,h.memoizedProps=null,h.memoizedState=null,h.updateQueue=null,h.dependencies=null,h.stateNode=null):(h.childLanes=w.childLanes,h.lanes=w.lanes,h.child=w.child,h.subtreeFlags=0,h.deletions=null,h.memoizedProps=w.memoizedProps,h.memoizedState=w.memoizedState,h.updateQueue=w.updateQueue,h.type=w.type,g=w.dependencies,h.dependencies=g===null?null:{lanes:g.lanes,firstContext:g.firstContext}),h}function jv(h,g,w,M,P,L){var J=0;if(M=h,typeof h=="function")nk(h)&&(J=1);else if(typeof h=="string")J=xae(h,w,se.current)?26:h==="html"||h==="head"||h==="body"?27:5;else e:switch(h){case A:return h=Ys(31,w,g,P),h.elementType=A,h.lanes=L,h;case b:return Kh(w.children,P,L,g);case y:J=8,P|=24;break;case v:return h=Ys(12,w,g,P|2),h.elementType=v,h.lanes=L,h;case k:return h=Ys(13,w,g,P),h.elementType=k,h.lanes=L,h;case C:return h=Ys(19,w,g,P),h.elementType=C,h.lanes=L,h;default:if(typeof h=="object"&&h!==null)switch(h.$$typeof){case N:J=10;break e;case S:J=9;break e;case T:J=11;break e;case E:J=14;break e;case D:J=16,M=null;break e}J=29,w=Error(r(130,h===null?"null":typeof h,"")),M=null}return g=Ys(J,w,g,P),g.elementType=h,g.type=M,g.lanes=L,g}function Kh(h,g,w,M){return h=Ys(7,h,M,g),h.lanes=w,h}function rk(h,g,w){return h=Ys(6,h,null,g),h.lanes=w,h}function FF(h){var g=Ys(18,null,null,0);return g.stateNode=h,g}function ik(h,g,w){return g=Ys(4,h.children!==null?h.children:[],h.key,g),g.lanes=w,g.stateNode={containerInfo:h.containerInfo,pendingChildren:null,implementation:h.implementation},g}var IF=new WeakMap;function Eo(h,g){if(typeof h=="object"&&h!==null){var w=IF.get(h);return w!==void 0?w:(g={value:h,source:g,stack:te(g)},IF.set(h,g),g)}return{value:h,source:g,stack:te(g)}}var Vm=[],Gm=0,Pv=null,Xx=0,To=[],Ao=0,ed=null,Gl=1,ql="";function Pc(h,g){Vm[Gm++]=Xx,Vm[Gm++]=Pv,Pv=h,Xx=g}function UF(h,g,w){To[Ao++]=Gl,To[Ao++]=ql,To[Ao++]=ed,ed=h;var M=Gl;h=ql;var P=32-Be(M)-1;M&=~(1<<P),w+=1;var L=32-Be(g)+P;if(30<L){var J=P-P%5;L=(M&(1<<J)-1).toString(32),M>>=J,P-=J,Gl=1<<32-Be(g)+P|w<<P|M,ql=L+h}else Gl=1<<L|w<<P|M,ql=h}function ak(h){h.return!==null&&(Pc(h,1),UF(h,1,0))}function sk(h){for(;h===Pv;)Pv=Vm[--Gm],Vm[Gm]=null,Xx=Vm[--Gm],Vm[Gm]=null;for(;h===ed;)ed=To[--Ao],To[Ao]=null,ql=To[--Ao],To[Ao]=null,Gl=To[--Ao],To[Ao]=null}function zF(h,g){To[Ao++]=Gl,To[Ao++]=ql,To[Ao++]=ed,Gl=g.id,ql=g.overflow,ed=h}var Ma=null,$r=null,Yn=!1,td=null,Co=!1,ok=Error(r(519));function nd(h){var g=Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Yx(Eo(g,h)),ok}function BF(h){var g=h.stateNode,w=h.type,M=h.memoizedProps;switch(g[Xn]=h,g[bn]=M,w){case"dialog":Un("cancel",g),Un("close",g);break;case"iframe":case"object":case"embed":Un("load",g);break;case"video":case"audio":for(w=0;w<bb.length;w++)Un(bb[w],g);break;case"source":Un("error",g);break;case"img":case"image":case"link":Un("error",g),Un("load",g);break;case"details":Un("toggle",g);break;case"input":Un("invalid",g),rr(g,M.value,M.defaultValue,M.checked,M.defaultChecked,M.type,M.name,!0);break;case"select":Un("invalid",g);break;case"textarea":Un("invalid",g),qt(g,M.value,M.defaultValue,M.children)}w=M.children,typeof w!="string"&&typeof w!="number"&&typeof w!="bigint"||g.textContent===""+w||M.suppressHydrationWarning===!0||iU(g.textContent,w)?(M.popover!=null&&(Un("beforetoggle",g),Un("toggle",g)),M.onScroll!=null&&Un("scroll",g),M.onScrollEnd!=null&&Un("scrollend",g),M.onClick!=null&&(g.onclick=_i),g=!0):g=!1,g||nd(h,!0)}function HF(h){for(Ma=h.return;Ma;)switch(Ma.tag){case 5:case 31:case 13:Co=!1;return;case 27:case 3:Co=!0;return;default:Ma=Ma.return}}function qm(h){if(h!==Ma)return!1;if(!Yn)return HF(h),Yn=!0,!1;var g=h.tag,w;if((w=g!==3&&g!==27)&&((w=g===5)&&(w=h.type,w=!(w!=="form"&&w!=="button")||NE(h.type,h.memoizedProps)),w=!w),w&&$r&&nd(h),HF(h),g===13){if(h=h.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(r(317));$r=fU(h)}else if(g===31){if(h=h.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(r(317));$r=fU(h)}else g===27?(g=$r,gd(h.type)?(h=CE,CE=null,$r=h):$r=g):$r=Ma?Po(h.stateNode.nextSibling):null;return!0}function Xh(){$r=Ma=null,Yn=!1}function lk(){var h=td;return h!==null&&(Ts===null?Ts=h:Ts.push.apply(Ts,h),td=null),h}function Yx(h){td===null?td=[h]:td.push(h)}var ck=B(null),Yh=null,Dc=null;function rd(h,g,w){ne(ck,g._currentValue),g._currentValue=w}function Rc(h){h._currentValue=ck.current,X(ck)}function uk(h,g,w){for(;h!==null;){var M=h.alternate;if((h.childLanes&g)!==g?(h.childLanes|=g,M!==null&&(M.childLanes|=g)):M!==null&&(M.childLanes&g)!==g&&(M.childLanes|=g),h===w)break;h=h.return}}function dk(h,g,w,M){var P=h.child;for(P!==null&&(P.return=h);P!==null;){var L=P.dependencies;if(L!==null){var J=P.child;L=L.firstContext;e:for(;L!==null;){var ve=L;L=P;for(var Ue=0;Ue<g.length;Ue++)if(ve.context===g[Ue]){L.lanes|=w,ve=L.alternate,ve!==null&&(ve.lanes|=w),uk(L.return,w,h),M||(J=null);break e}L=ve.next}}else if(P.tag===18){if(J=P.return,J===null)throw Error(r(341));J.lanes|=w,L=J.alternate,L!==null&&(L.lanes|=w),uk(J,w,h),J=null}else J=P.child;if(J!==null)J.return=P;else for(J=P;J!==null;){if(J===h){J=null;break}if(P=J.sibling,P!==null){P.return=J.return,J=P;break}J=J.return}P=J}}function Wm(h,g,w,M){h=null;for(var P=g,L=!1;P!==null;){if(!L){if((P.flags&524288)!==0)L=!0;else if((P.flags&262144)!==0)break}if(P.tag===10){var J=P.alternate;if(J===null)throw Error(r(387));if(J=J.memoizedProps,J!==null){var ve=P.type;Xs(P.pendingProps.value,J.value)||(h!==null?h.push(ve):h=[ve])}}else if(P===de.current){if(J=P.alternate,J===null)throw Error(r(387));J.memoizedState.memoizedState!==P.memoizedState.memoizedState&&(h!==null?h.push(Sb):h=[Sb])}P=P.return}h!==null&&dk(g,h,w,M),g.flags|=262144}function Dv(h){for(h=h.firstContext;h!==null;){if(!Xs(h.context._currentValue,h.memoizedValue))return!0;h=h.next}return!1}function Qh(h){Yh=h,Dc=null,h=h.dependencies,h!==null&&(h.firstContext=null)}function Na(h){return $F(Yh,h)}function Rv(h,g){return Yh===null&&Qh(h),$F(h,g)}function $F(h,g){var w=g._currentValue;if(g={context:g,memoizedValue:w,next:null},Dc===null){if(h===null)throw Error(r(308));Dc=g,h.dependencies={lanes:0,firstContext:g},h.flags|=524288}else Dc=Dc.next=g;return w}var fie=typeof AbortController<"u"?AbortController:function(){var h=[],g=this.signal={aborted:!1,addEventListener:function(w,M){h.push(M)}};this.abort=function(){g.aborted=!0,h.forEach(function(w){return w()})}},mie=t.unstable_scheduleCallback,pie=t.unstable_NormalPriority,Ci={$$typeof:N,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function hk(){return{controller:new fie,data:new Map,refCount:0}}function Qx(h){h.refCount--,h.refCount===0&&mie(pie,function(){h.controller.abort()})}var Zx=null,fk=0,Km=0,Xm=null;function gie(h,g){if(Zx===null){var w=Zx=[];fk=0,Km=gE(),Xm={status:"pending",value:void 0,then:function(M){w.push(M)}}}return fk++,g.then(VF,VF),g}function VF(){if(--fk===0&&Zx!==null){Xm!==null&&(Xm.status="fulfilled");var h=Zx;Zx=null,Km=0,Xm=null;for(var g=0;g<h.length;g++)(0,h[g])()}}function xie(h,g){var w=[],M={status:"pending",value:null,reason:null,then:function(P){w.push(P)}};return h.then(function(){M.status="fulfilled",M.value=g;for(var P=0;P<w.length;P++)(0,w[P])(g)},function(P){for(M.status="rejected",M.reason=P,P=0;P<w.length;P++)(0,w[P])(void 0)}),M}var GF=K.S;K.S=function(h,g){T5=O(),typeof g=="object"&&g!==null&&typeof g.then=="function"&&gie(h,g),GF!==null&&GF(h,g)};var Zh=B(null);function mk(){var h=Zh.current;return h!==null?h:Pr.pooledCache}function Ov(h,g){g===null?ne(Zh,Zh.current):ne(Zh,g.pool)}function qF(){var h=mk();return h===null?null:{parent:Ci._currentValue,pool:h}}var Ym=Error(r(460)),pk=Error(r(474)),Lv=Error(r(542)),Fv={then:function(){}};function WF(h){return h=h.status,h==="fulfilled"||h==="rejected"}function KF(h,g,w){switch(w=h[w],w===void 0?h.push(g):w!==g&&(g.then(_i,_i),g=w),g.status){case"fulfilled":return g.value;case"rejected":throw h=g.reason,YF(h),h;default:if(typeof g.status=="string")g.then(_i,_i);else{if(h=Pr,h!==null&&100<h.shellSuspendCounter)throw Error(r(482));h=g,h.status="pending",h.then(function(M){if(g.status==="pending"){var P=g;P.status="fulfilled",P.value=M}},function(M){if(g.status==="pending"){var P=g;P.status="rejected",P.reason=M}})}switch(g.status){case"fulfilled":return g.value;case"rejected":throw h=g.reason,YF(h),h}throw ef=g,Ym}}function Jh(h){try{var g=h._init;return g(h._payload)}catch(w){throw w!==null&&typeof w=="object"&&typeof w.then=="function"?(ef=w,Ym):w}}var ef=null;function XF(){if(ef===null)throw Error(r(459));var h=ef;return ef=null,h}function YF(h){if(h===Ym||h===Lv)throw Error(r(483))}var Qm=null,Jx=0;function Iv(h){var g=Jx;return Jx+=1,Qm===null&&(Qm=[]),KF(Qm,h,g)}function eb(h,g){g=g.props.ref,h.ref=g!==void 0?g:null}function Uv(h,g){throw g.$$typeof===p?Error(r(525)):(h=Object.prototype.toString.call(g),Error(r(31,h==="[object Object]"?"object with keys {"+Object.keys(g).join(", ")+"}":h)))}function QF(h){function g(Je,Ge){if(h){var rt=Je.deletions;rt===null?(Je.deletions=[Ge],Je.flags|=16):rt.push(Ge)}}function w(Je,Ge){if(!h)return null;for(;Ge!==null;)g(Je,Ge),Ge=Ge.sibling;return null}function M(Je){for(var Ge=new Map;Je!==null;)Je.key!==null?Ge.set(Je.key,Je):Ge.set(Je.index,Je),Je=Je.sibling;return Ge}function P(Je,Ge){return Je=jc(Je,Ge),Je.index=0,Je.sibling=null,Je}function L(Je,Ge,rt){return Je.index=rt,h?(rt=Je.alternate,rt!==null?(rt=rt.index,rt<Ge?(Je.flags|=67108866,Ge):rt):(Je.flags|=67108866,Ge)):(Je.flags|=1048576,Ge)}function J(Je){return h&&Je.alternate===null&&(Je.flags|=67108866),Je}function ve(Je,Ge,rt,bt){return Ge===null||Ge.tag!==6?(Ge=rk(rt,Je.mode,bt),Ge.return=Je,Ge):(Ge=P(Ge,rt),Ge.return=Je,Ge)}function Ue(Je,Ge,rt,bt){var Kt=rt.type;return Kt===b?gt(Je,Ge,rt.props.children,bt,rt.key):Ge!==null&&(Ge.elementType===Kt||typeof Kt=="object"&&Kt!==null&&Kt.$$typeof===D&&Jh(Kt)===Ge.type)?(Ge=P(Ge,rt.props),eb(Ge,rt),Ge.return=Je,Ge):(Ge=jv(rt.type,rt.key,rt.props,null,Je.mode,bt),eb(Ge,rt),Ge.return=Je,Ge)}function it(Je,Ge,rt,bt){return Ge===null||Ge.tag!==4||Ge.stateNode.containerInfo!==rt.containerInfo||Ge.stateNode.implementation!==rt.implementation?(Ge=ik(rt,Je.mode,bt),Ge.return=Je,Ge):(Ge=P(Ge,rt.children||[]),Ge.return=Je,Ge)}function gt(Je,Ge,rt,bt,Kt){return Ge===null||Ge.tag!==7?(Ge=Kh(rt,Je.mode,bt,Kt),Ge.return=Je,Ge):(Ge=P(Ge,rt),Ge.return=Je,Ge)}function vt(Je,Ge,rt){if(typeof Ge=="string"&&Ge!==""||typeof Ge=="number"||typeof Ge=="bigint")return Ge=rk(""+Ge,Je.mode,rt),Ge.return=Je,Ge;if(typeof Ge=="object"&&Ge!==null){switch(Ge.$$typeof){case m:return rt=jv(Ge.type,Ge.key,Ge.props,null,Je.mode,rt),eb(rt,Ge),rt.return=Je,rt;case x:return Ge=ik(Ge,Je.mode,rt),Ge.return=Je,Ge;case D:return Ge=Jh(Ge),vt(Je,Ge,rt)}if(H(Ge)||F(Ge))return Ge=Kh(Ge,Je.mode,rt,null),Ge.return=Je,Ge;if(typeof Ge.then=="function")return vt(Je,Iv(Ge),rt);if(Ge.$$typeof===N)return vt(Je,Rv(Je,Ge),rt);Uv(Je,Ge)}return null}function ct(Je,Ge,rt,bt){var Kt=Ge!==null?Ge.key:null;if(typeof rt=="string"&&rt!==""||typeof rt=="number"||typeof rt=="bigint")return Kt!==null?null:ve(Je,Ge,""+rt,bt);if(typeof rt=="object"&&rt!==null){switch(rt.$$typeof){case m:return rt.key===Kt?Ue(Je,Ge,rt,bt):null;case x:return rt.key===Kt?it(Je,Ge,rt,bt):null;case D:return rt=Jh(rt),ct(Je,Ge,rt,bt)}if(H(rt)||F(rt))return Kt!==null?null:gt(Je,Ge,rt,bt,null);if(typeof rt.then=="function")return ct(Je,Ge,Iv(rt),bt);if(rt.$$typeof===N)return ct(Je,Ge,Rv(Je,rt),bt);Uv(Je,rt)}return null}function pt(Je,Ge,rt,bt,Kt){if(typeof bt=="string"&&bt!==""||typeof bt=="number"||typeof bt=="bigint")return Je=Je.get(rt)||null,ve(Ge,Je,""+bt,Kt);if(typeof bt=="object"&&bt!==null){switch(bt.$$typeof){case m:return Je=Je.get(bt.key===null?rt:bt.key)||null,Ue(Ge,Je,bt,Kt);case x:return Je=Je.get(bt.key===null?rt:bt.key)||null,it(Ge,Je,bt,Kt);case D:return bt=Jh(bt),pt(Je,Ge,rt,bt,Kt)}if(H(bt)||F(bt))return Je=Je.get(rt)||null,gt(Ge,Je,bt,Kt,null);if(typeof bt.then=="function")return pt(Je,Ge,rt,Iv(bt),Kt);if(bt.$$typeof===N)return pt(Je,Ge,rt,Rv(Ge,bt),Kt);Uv(Ge,bt)}return null}function Vt(Je,Ge,rt,bt){for(var Kt=null,ar=null,Wt=Ge,Mn=Ge=0,qn=null;Wt!==null&&Mn<rt.length;Mn++){Wt.index>Mn?(qn=Wt,Wt=null):qn=Wt.sibling;var sr=ct(Je,Wt,rt[Mn],bt);if(sr===null){Wt===null&&(Wt=qn);break}h&&Wt&&sr.alternate===null&&g(Je,Wt),Ge=L(sr,Ge,Mn),ar===null?Kt=sr:ar.sibling=sr,ar=sr,Wt=qn}if(Mn===rt.length)return w(Je,Wt),Yn&&Pc(Je,Mn),Kt;if(Wt===null){for(;Mn<rt.length;Mn++)Wt=vt(Je,rt[Mn],bt),Wt!==null&&(Ge=L(Wt,Ge,Mn),ar===null?Kt=Wt:ar.sibling=Wt,ar=Wt);return Yn&&Pc(Je,Mn),Kt}for(Wt=M(Wt);Mn<rt.length;Mn++)qn=pt(Wt,Je,Mn,rt[Mn],bt),qn!==null&&(h&&qn.alternate!==null&&Wt.delete(qn.key===null?Mn:qn.key),Ge=L(qn,Ge,Mn),ar===null?Kt=qn:ar.sibling=qn,ar=qn);return h&&Wt.forEach(function(wd){return g(Je,wd)}),Yn&&Pc(Je,Mn),Kt}function nn(Je,Ge,rt,bt){if(rt==null)throw Error(r(151));for(var Kt=null,ar=null,Wt=Ge,Mn=Ge=0,qn=null,sr=rt.next();Wt!==null&&!sr.done;Mn++,sr=rt.next()){Wt.index>Mn?(qn=Wt,Wt=null):qn=Wt.sibling;var wd=ct(Je,Wt,sr.value,bt);if(wd===null){Wt===null&&(Wt=qn);break}h&&Wt&&wd.alternate===null&&g(Je,Wt),Ge=L(wd,Ge,Mn),ar===null?Kt=wd:ar.sibling=wd,ar=wd,Wt=qn}if(sr.done)return w(Je,Wt),Yn&&Pc(Je,Mn),Kt;if(Wt===null){for(;!sr.done;Mn++,sr=rt.next())sr=vt(Je,sr.value,bt),sr!==null&&(Ge=L(sr,Ge,Mn),ar===null?Kt=sr:ar.sibling=sr,ar=sr);return Yn&&Pc(Je,Mn),Kt}for(Wt=M(Wt);!sr.done;Mn++,sr=rt.next())sr=pt(Wt,Je,Mn,sr.value,bt),sr!==null&&(h&&sr.alternate!==null&&Wt.delete(sr.key===null?Mn:sr.key),Ge=L(sr,Ge,Mn),ar===null?Kt=sr:ar.sibling=sr,ar=sr);return h&&Wt.forEach(function(Tae){return g(Je,Tae)}),Yn&&Pc(Je,Mn),Kt}function Sr(Je,Ge,rt,bt){if(typeof rt=="object"&&rt!==null&&rt.type===b&&rt.key===null&&(rt=rt.props.children),typeof rt=="object"&&rt!==null){switch(rt.$$typeof){case m:e:{for(var Kt=rt.key;Ge!==null;){if(Ge.key===Kt){if(Kt=rt.type,Kt===b){if(Ge.tag===7){w(Je,Ge.sibling),bt=P(Ge,rt.props.children),bt.return=Je,Je=bt;break e}}else if(Ge.elementType===Kt||typeof Kt=="object"&&Kt!==null&&Kt.$$typeof===D&&Jh(Kt)===Ge.type){w(Je,Ge.sibling),bt=P(Ge,rt.props),eb(bt,rt),bt.return=Je,Je=bt;break e}w(Je,Ge);break}else g(Je,Ge);Ge=Ge.sibling}rt.type===b?(bt=Kh(rt.props.children,Je.mode,bt,rt.key),bt.return=Je,Je=bt):(bt=jv(rt.type,rt.key,rt.props,null,Je.mode,bt),eb(bt,rt),bt.return=Je,Je=bt)}return J(Je);case x:e:{for(Kt=rt.key;Ge!==null;){if(Ge.key===Kt)if(Ge.tag===4&&Ge.stateNode.containerInfo===rt.containerInfo&&Ge.stateNode.implementation===rt.implementation){w(Je,Ge.sibling),bt=P(Ge,rt.children||[]),bt.return=Je,Je=bt;break e}else{w(Je,Ge);break}else g(Je,Ge);Ge=Ge.sibling}bt=ik(rt,Je.mode,bt),bt.return=Je,Je=bt}return J(Je);case D:return rt=Jh(rt),Sr(Je,Ge,rt,bt)}if(H(rt))return Vt(Je,Ge,rt,bt);if(F(rt)){if(Kt=F(rt),typeof Kt!="function")throw Error(r(150));return rt=Kt.call(rt),nn(Je,Ge,rt,bt)}if(typeof rt.then=="function")return Sr(Je,Ge,Iv(rt),bt);if(rt.$$typeof===N)return Sr(Je,Ge,Rv(Je,rt),bt);Uv(Je,rt)}return typeof rt=="string"&&rt!==""||typeof rt=="number"||typeof rt=="bigint"?(rt=""+rt,Ge!==null&&Ge.tag===6?(w(Je,Ge.sibling),bt=P(Ge,rt),bt.return=Je,Je=bt):(w(Je,Ge),bt=rk(rt,Je.mode,bt),bt.return=Je,Je=bt),J(Je)):w(Je,Ge)}return function(Je,Ge,rt,bt){try{Jx=0;var Kt=Sr(Je,Ge,rt,bt);return Qm=null,Kt}catch(Wt){if(Wt===Ym||Wt===Lv)throw Wt;var ar=Ys(29,Wt,null,Je.mode);return ar.lanes=bt,ar.return=Je,ar}finally{}}}var tf=QF(!0),ZF=QF(!1),id=!1;function gk(h){h.updateQueue={baseState:h.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function xk(h,g){h=h.updateQueue,g.updateQueue===h&&(g.updateQueue={baseState:h.baseState,firstBaseUpdate:h.firstBaseUpdate,lastBaseUpdate:h.lastBaseUpdate,shared:h.shared,callbacks:null})}function ad(h){return{lane:h,tag:0,payload:null,callback:null,next:null}}function sd(h,g,w){var M=h.updateQueue;if(M===null)return null;if(M=M.shared,(ur&2)!==0){var P=M.pending;return P===null?g.next=g:(g.next=P.next,P.next=g),M.pending=g,g=Cv(h),OF(h,null,w),g}return Av(h,M,g,w),Cv(h)}function tb(h,g,w){if(g=g.updateQueue,g!==null&&(g=g.shared,(w&4194048)!==0)){var M=g.lanes;M&=h.pendingLanes,w|=M,g.lanes=w,Jt(h,w)}}function bk(h,g){var w=h.updateQueue,M=h.alternate;if(M!==null&&(M=M.updateQueue,w===M)){var P=null,L=null;if(w=w.firstBaseUpdate,w!==null){do{var J={lane:w.lane,tag:w.tag,payload:w.payload,callback:null,next:null};L===null?P=L=J:L=L.next=J,w=w.next}while(w!==null);L===null?P=L=g:L=L.next=g}else P=L=g;w={baseState:M.baseState,firstBaseUpdate:P,lastBaseUpdate:L,shared:M.shared,callbacks:M.callbacks},h.updateQueue=w;return}h=w.lastBaseUpdate,h===null?w.firstBaseUpdate=g:h.next=g,w.lastBaseUpdate=g}var yk=!1;function nb(){if(yk){var h=Xm;if(h!==null)throw h}}function rb(h,g,w,M){yk=!1;var P=h.updateQueue;id=!1;var L=P.firstBaseUpdate,J=P.lastBaseUpdate,ve=P.shared.pending;if(ve!==null){P.shared.pending=null;var Ue=ve,it=Ue.next;Ue.next=null,J===null?L=it:J.next=it,J=Ue;var gt=h.alternate;gt!==null&&(gt=gt.updateQueue,ve=gt.lastBaseUpdate,ve!==J&&(ve===null?gt.firstBaseUpdate=it:ve.next=it,gt.lastBaseUpdate=Ue))}if(L!==null){var vt=P.baseState;J=0,gt=it=Ue=null,ve=L;do{var ct=ve.lane&-536870913,pt=ct!==ve.lane;if(pt?(Gn&ct)===ct:(M&ct)===ct){ct!==0&&ct===Km&&(yk=!0),gt!==null&&(gt=gt.next={lane:0,tag:ve.tag,payload:ve.payload,callback:null,next:null});e:{var Vt=h,nn=ve;ct=g;var Sr=w;switch(nn.tag){case 1:if(Vt=nn.payload,typeof Vt=="function"){vt=Vt.call(Sr,vt,ct);break e}vt=Vt;break e;case 3:Vt.flags=Vt.flags&-65537|128;case 0:if(Vt=nn.payload,ct=typeof Vt=="function"?Vt.call(Sr,vt,ct):Vt,ct==null)break e;vt=f({},vt,ct);break e;case 2:id=!0}}ct=ve.callback,ct!==null&&(h.flags|=64,pt&&(h.flags|=8192),pt=P.callbacks,pt===null?P.callbacks=[ct]:pt.push(ct))}else pt={lane:ct,tag:ve.tag,payload:ve.payload,callback:ve.callback,next:null},gt===null?(it=gt=pt,Ue=vt):gt=gt.next=pt,J|=ct;if(ve=ve.next,ve===null){if(ve=P.shared.pending,ve===null)break;pt=ve,ve=pt.next,pt.next=null,P.lastBaseUpdate=pt,P.shared.pending=null}}while(!0);gt===null&&(Ue=vt),P.baseState=Ue,P.firstBaseUpdate=it,P.lastBaseUpdate=gt,L===null&&(P.shared.lanes=0),dd|=J,h.lanes=J,h.memoizedState=vt}}function JF(h,g){if(typeof h!="function")throw Error(r(191,h));h.call(g)}function eI(h,g){var w=h.callbacks;if(w!==null)for(h.callbacks=null,h=0;h<w.length;h++)JF(w[h],g)}var Zm=B(null),zv=B(0);function tI(h,g){h=$c,ne(zv,h),ne(Zm,g),$c=h|g.baseLanes}function vk(){ne(zv,$c),ne(Zm,Zm.current)}function wk(){$c=zv.current,X(Zm),X(zv)}var Qs=B(null),jo=null;function od(h){var g=h.alternate;ne(Mi,Mi.current&1),ne(Qs,h),jo===null&&(g===null||Zm.current!==null||g.memoizedState!==null)&&(jo=h)}function _k(h){ne(Mi,Mi.current),ne(Qs,h),jo===null&&(jo=h)}function nI(h){h.tag===22?(ne(Mi,Mi.current),ne(Qs,h),jo===null&&(jo=h)):ld()}function ld(){ne(Mi,Mi.current),ne(Qs,Qs.current)}function Zs(h){X(Qs),jo===h&&(jo=null),X(Mi)}var Mi=B(0);function Bv(h){for(var g=h;g!==null;){if(g.tag===13){var w=g.memoizedState;if(w!==null&&(w=w.dehydrated,w===null||TE(w)||AE(w)))return g}else if(g.tag===19&&(g.memoizedProps.revealOrder==="forwards"||g.memoizedProps.revealOrder==="backwards"||g.memoizedProps.revealOrder==="unstable_legacy-backwards"||g.memoizedProps.revealOrder==="together")){if((g.flags&128)!==0)return g}else if(g.child!==null){g.child.return=g,g=g.child;continue}if(g===h)break;for(;g.sibling===null;){if(g.return===null||g.return===h)return null;g=g.return}g.sibling.return=g.return,g=g.sibling}return null}var Oc=0,_n=null,wr=null,ji=null,Hv=!1,Jm=!1,nf=!1,$v=0,ib=0,ep=null,bie=0;function di(){throw Error(r(321))}function Sk(h,g){if(g===null)return!1;for(var w=0;w<g.length&&w<h.length;w++)if(!Xs(h[w],g[w]))return!1;return!0}function Mk(h,g,w,M,P,L){return Oc=L,_n=g,g.memoizedState=null,g.updateQueue=null,g.lanes=0,K.H=h===null||h.memoizedState===null?UI:Uk,nf=!1,L=w(M,P),nf=!1,Jm&&(L=iI(g,w,M,P)),rI(h),L}function rI(h){K.H=ob;var g=wr!==null&&wr.next!==null;if(Oc=0,ji=wr=_n=null,Hv=!1,ib=0,ep=null,g)throw Error(r(300));h===null||Pi||(h=h.dependencies,h!==null&&Dv(h)&&(Pi=!0))}function iI(h,g,w,M){_n=h;var P=0;do{if(Jm&&(ep=null),ib=0,Jm=!1,25<=P)throw Error(r(301));if(P+=1,ji=wr=null,h.updateQueue!=null){var L=h.updateQueue;L.lastEffect=null,L.events=null,L.stores=null,L.memoCache!=null&&(L.memoCache.index=0)}K.H=zI,L=g(w,M)}while(Jm);return L}function yie(){var h=K.H,g=h.useState()[0];return g=typeof g.then=="function"?ab(g):g,h=h.useState()[0],(wr!==null?wr.memoizedState:null)!==h&&(_n.flags|=1024),g}function Nk(){var h=$v!==0;return $v=0,h}function kk(h,g,w){g.updateQueue=h.updateQueue,g.flags&=-2053,h.lanes&=~w}function Ek(h){if(Hv){for(h=h.memoizedState;h!==null;){var g=h.queue;g!==null&&(g.pending=null),h=h.next}Hv=!1}Oc=0,ji=wr=_n=null,Jm=!1,ib=$v=0,ep=null}function ss(){var h={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return ji===null?_n.memoizedState=ji=h:ji=ji.next=h,ji}function Ni(){if(wr===null){var h=_n.alternate;h=h!==null?h.memoizedState:null}else h=wr.next;var g=ji===null?_n.memoizedState:ji.next;if(g!==null)ji=g,wr=h;else{if(h===null)throw _n.alternate===null?Error(r(467)):Error(r(310));wr=h,h={memoizedState:wr.memoizedState,baseState:wr.baseState,baseQueue:wr.baseQueue,queue:wr.queue,next:null},ji===null?_n.memoizedState=ji=h:ji=ji.next=h}return ji}function Vv(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function ab(h){var g=ib;return ib+=1,ep===null&&(ep=[]),h=KF(ep,h,g),g=_n,(ji===null?g.memoizedState:ji.next)===null&&(g=g.alternate,K.H=g===null||g.memoizedState===null?UI:Uk),h}function Gv(h){if(h!==null&&typeof h=="object"){if(typeof h.then=="function")return ab(h);if(h.$$typeof===N)return Na(h)}throw Error(r(438,String(h)))}function Tk(h){var g=null,w=_n.updateQueue;if(w!==null&&(g=w.memoCache),g==null){var M=_n.alternate;M!==null&&(M=M.updateQueue,M!==null&&(M=M.memoCache,M!=null&&(g={data:M.data.map(function(P){return P.slice()}),index:0})))}if(g==null&&(g={data:[],index:0}),w===null&&(w=Vv(),_n.updateQueue=w),w.memoCache=g,w=g.data[g.index],w===void 0)for(w=g.data[g.index]=Array(h),M=0;M<h;M++)w[M]=R;return g.index++,w}function Lc(h,g){return typeof g=="function"?g(h):g}function qv(h){var g=Ni();return Ak(g,wr,h)}function Ak(h,g,w){var M=h.queue;if(M===null)throw Error(r(311));M.lastRenderedReducer=w;var P=h.baseQueue,L=M.pending;if(L!==null){if(P!==null){var J=P.next;P.next=L.next,L.next=J}g.baseQueue=P=L,M.pending=null}if(L=h.baseState,P===null)h.memoizedState=L;else{g=P.next;var ve=J=null,Ue=null,it=g,gt=!1;do{var vt=it.lane&-536870913;if(vt!==it.lane?(Gn&vt)===vt:(Oc&vt)===vt){var ct=it.revertLane;if(ct===0)Ue!==null&&(Ue=Ue.next={lane:0,revertLane:0,gesture:null,action:it.action,hasEagerState:it.hasEagerState,eagerState:it.eagerState,next:null}),vt===Km&&(gt=!0);else if((Oc&ct)===ct){it=it.next,ct===Km&&(gt=!0);continue}else vt={lane:0,revertLane:it.revertLane,gesture:null,action:it.action,hasEagerState:it.hasEagerState,eagerState:it.eagerState,next:null},Ue===null?(ve=Ue=vt,J=L):Ue=Ue.next=vt,_n.lanes|=ct,dd|=ct;vt=it.action,nf&&w(L,vt),L=it.hasEagerState?it.eagerState:w(L,vt)}else ct={lane:vt,revertLane:it.revertLane,gesture:it.gesture,action:it.action,hasEagerState:it.hasEagerState,eagerState:it.eagerState,next:null},Ue===null?(ve=Ue=ct,J=L):Ue=Ue.next=ct,_n.lanes|=vt,dd|=vt;it=it.next}while(it!==null&&it!==g);if(Ue===null?J=L:Ue.next=ve,!Xs(L,h.memoizedState)&&(Pi=!0,gt&&(w=Xm,w!==null)))throw w;h.memoizedState=L,h.baseState=J,h.baseQueue=Ue,M.lastRenderedState=L}return P===null&&(M.lanes=0),[h.memoizedState,M.dispatch]}function Ck(h){var g=Ni(),w=g.queue;if(w===null)throw Error(r(311));w.lastRenderedReducer=h;var M=w.dispatch,P=w.pending,L=g.memoizedState;if(P!==null){w.pending=null;var J=P=P.next;do L=h(L,J.action),J=J.next;while(J!==P);Xs(L,g.memoizedState)||(Pi=!0),g.memoizedState=L,g.baseQueue===null&&(g.baseState=L),w.lastRenderedState=L}return[L,M]}function aI(h,g,w){var M=_n,P=Ni(),L=Yn;if(L){if(w===void 0)throw Error(r(407));w=w()}else w=g();var J=!Xs((wr||P).memoizedState,w);if(J&&(P.memoizedState=w,Pi=!0),P=P.queue,Dk(lI.bind(null,M,P,h),[h]),P.getSnapshot!==g||J||ji!==null&&ji.memoizedState.tag&1){if(M.flags|=2048,tp(9,{destroy:void 0},oI.bind(null,M,P,w,g),null),Pr===null)throw Error(r(349));L||(Oc&127)!==0||sI(M,g,w)}return w}function sI(h,g,w){h.flags|=16384,h={getSnapshot:g,value:w},g=_n.updateQueue,g===null?(g=Vv(),_n.updateQueue=g,g.stores=[h]):(w=g.stores,w===null?g.stores=[h]:w.push(h))}function oI(h,g,w,M){g.value=w,g.getSnapshot=M,cI(g)&&uI(h)}function lI(h,g,w){return w(function(){cI(g)&&uI(h)})}function cI(h){var g=h.getSnapshot;h=h.value;try{var w=g();return!Xs(h,w)}catch{return!0}}function uI(h){var g=Wh(h,2);g!==null&&As(g,h,2)}function jk(h){var g=ss();if(typeof h=="function"){var w=h;if(h=w(),nf){je(!0);try{w()}finally{je(!1)}}}return g.memoizedState=g.baseState=h,g.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Lc,lastRenderedState:h},g}function dI(h,g,w,M){return h.baseState=w,Ak(h,wr,typeof M=="function"?M:Lc)}function vie(h,g,w,M,P){if(Xv(h))throw Error(r(485));if(h=g.action,h!==null){var L={payload:P,action:h,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(J){L.listeners.push(J)}};K.T!==null?w(!0):L.isTransition=!1,M(L),w=g.pending,w===null?(L.next=g.pending=L,hI(g,L)):(L.next=w.next,g.pending=w.next=L)}}function hI(h,g){var w=g.action,M=g.payload,P=h.state;if(g.isTransition){var L=K.T,J={};K.T=J;try{var ve=w(P,M),Ue=K.S;Ue!==null&&Ue(J,ve),fI(h,g,ve)}catch(it){Pk(h,g,it)}finally{L!==null&&J.types!==null&&(L.types=J.types),K.T=L}}else try{L=w(P,M),fI(h,g,L)}catch(it){Pk(h,g,it)}}function fI(h,g,w){w!==null&&typeof w=="object"&&typeof w.then=="function"?w.then(function(M){mI(h,g,M)},function(M){return Pk(h,g,M)}):mI(h,g,w)}function mI(h,g,w){g.status="fulfilled",g.value=w,pI(g),h.state=w,g=h.pending,g!==null&&(w=g.next,w===g?h.pending=null:(w=w.next,g.next=w,hI(h,w)))}function Pk(h,g,w){var M=h.pending;if(h.pending=null,M!==null){M=M.next;do g.status="rejected",g.reason=w,pI(g),g=g.next;while(g!==M)}h.action=null}function pI(h){h=h.listeners;for(var g=0;g<h.length;g++)(0,h[g])()}function gI(h,g){return g}function xI(h,g){if(Yn){var w=Pr.formState;if(w!==null){e:{var M=_n;if(Yn){if($r){t:{for(var P=$r,L=Co;P.nodeType!==8;){if(!L){P=null;break t}if(P=Po(P.nextSibling),P===null){P=null;break t}}L=P.data,P=L==="F!"||L==="F"?P:null}if(P){$r=Po(P.nextSibling),M=P.data==="F!";break e}}nd(M)}M=!1}M&&(g=w[0])}}return w=ss(),w.memoizedState=w.baseState=g,M={pending:null,lanes:0,dispatch:null,lastRenderedReducer:gI,lastRenderedState:g},w.queue=M,w=LI.bind(null,_n,M),M.dispatch=w,M=jk(!1),L=Ik.bind(null,_n,!1,M.queue),M=ss(),P={state:g,dispatch:null,action:h,pending:null},M.queue=P,w=vie.bind(null,_n,P,L,w),P.dispatch=w,M.memoizedState=h,[g,w,!1]}function bI(h){var g=Ni();return yI(g,wr,h)}function yI(h,g,w){if(g=Ak(h,g,gI)[0],h=qv(Lc)[0],typeof g=="object"&&g!==null&&typeof g.then=="function")try{var M=ab(g)}catch(J){throw J===Ym?Lv:J}else M=g;g=Ni();var P=g.queue,L=P.dispatch;return w!==g.memoizedState&&(_n.flags|=2048,tp(9,{destroy:void 0},wie.bind(null,P,w),null)),[M,L,h]}function wie(h,g){h.action=g}function vI(h){var g=Ni(),w=wr;if(w!==null)return yI(g,w,h);Ni(),g=g.memoizedState,w=Ni();var M=w.queue.dispatch;return w.memoizedState=h,[g,M,!1]}function tp(h,g,w,M){return h={tag:h,create:w,deps:M,inst:g,next:null},g=_n.updateQueue,g===null&&(g=Vv(),_n.updateQueue=g),w=g.lastEffect,w===null?g.lastEffect=h.next=h:(M=w.next,w.next=h,h.next=M,g.lastEffect=h),h}function wI(){return Ni().memoizedState}function Wv(h,g,w,M){var P=ss();_n.flags|=h,P.memoizedState=tp(1|g,{destroy:void 0},w,M===void 0?null:M)}function Kv(h,g,w,M){var P=Ni();M=M===void 0?null:M;var L=P.memoizedState.inst;wr!==null&&M!==null&&Sk(M,wr.memoizedState.deps)?P.memoizedState=tp(g,L,w,M):(_n.flags|=h,P.memoizedState=tp(1|g,L,w,M))}function _I(h,g){Wv(8390656,8,h,g)}function Dk(h,g){Kv(2048,8,h,g)}function _ie(h){_n.flags|=4;var g=_n.updateQueue;if(g===null)g=Vv(),_n.updateQueue=g,g.events=[h];else{var w=g.events;w===null?g.events=[h]:w.push(h)}}function SI(h){var g=Ni().memoizedState;return _ie({ref:g,nextImpl:h}),function(){if((ur&2)!==0)throw Error(r(440));return g.impl.apply(void 0,arguments)}}function MI(h,g){return Kv(4,2,h,g)}function NI(h,g){return Kv(4,4,h,g)}function kI(h,g){if(typeof g=="function"){h=h();var w=g(h);return function(){typeof w=="function"?w():g(null)}}if(g!=null)return h=h(),g.current=h,function(){g.current=null}}function EI(h,g,w){w=w!=null?w.concat([h]):null,Kv(4,4,kI.bind(null,g,h),w)}function Rk(){}function TI(h,g){var w=Ni();g=g===void 0?null:g;var M=w.memoizedState;return g!==null&&Sk(g,M[1])?M[0]:(w.memoizedState=[h,g],h)}function AI(h,g){var w=Ni();g=g===void 0?null:g;var M=w.memoizedState;if(g!==null&&Sk(g,M[1]))return M[0];if(M=h(),nf){je(!0);try{h()}finally{je(!1)}}return w.memoizedState=[M,g],M}function Ok(h,g,w){return w===void 0||(Oc&1073741824)!==0&&(Gn&261930)===0?h.memoizedState=g:(h.memoizedState=w,h=C5(),_n.lanes|=h,dd|=h,w)}function CI(h,g,w,M){return Xs(w,g)?w:Zm.current!==null?(h=Ok(h,w,M),Xs(h,g)||(Pi=!0),h):(Oc&42)===0||(Oc&1073741824)!==0&&(Gn&261930)===0?(Pi=!0,h.memoizedState=w):(h=C5(),_n.lanes|=h,dd|=h,g)}function jI(h,g,w,M,P){var L=V.p;V.p=L!==0&&8>L?L:8;var J=K.T,ve={};K.T=ve,Ik(h,!1,g,w);try{var Ue=P(),it=K.S;if(it!==null&&it(ve,Ue),Ue!==null&&typeof Ue=="object"&&typeof Ue.then=="function"){var gt=xie(Ue,M);sb(h,g,gt,to(h))}else sb(h,g,M,to(h))}catch(vt){sb(h,g,{then:function(){},status:"rejected",reason:vt},to())}finally{V.p=L,J!==null&&ve.types!==null&&(J.types=ve.types),K.T=J}}function Sie(){}function Lk(h,g,w,M){if(h.tag!==5)throw Error(r(476));var P=PI(h).queue;jI(h,P,g,Q,w===null?Sie:function(){return DI(h),w(M)})}function PI(h){var g=h.memoizedState;if(g!==null)return g;g={memoizedState:Q,baseState:Q,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Lc,lastRenderedState:Q},next:null};var w={};return g.next={memoizedState:w,baseState:w,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Lc,lastRenderedState:w},next:null},h.memoizedState=g,h=h.alternate,h!==null&&(h.memoizedState=g),g}function DI(h){var g=PI(h);g.next===null&&(g=h.alternate.memoizedState),sb(h,g.next.queue,{},to())}function Fk(){return Na(Sb)}function RI(){return Ni().memoizedState}function OI(){return Ni().memoizedState}function Mie(h){for(var g=h.return;g!==null;){switch(g.tag){case 24:case 3:var w=to();h=ad(w);var M=sd(g,h,w);M!==null&&(As(M,g,w),tb(M,g,w)),g={cache:hk()},h.payload=g;return}g=g.return}}function Nie(h,g,w){var M=to();w={lane:M,revertLane:0,gesture:null,action:w,hasEagerState:!1,eagerState:null,next:null},Xv(h)?FI(g,w):(w=tk(h,g,w,M),w!==null&&(As(w,h,M),II(w,g,M)))}function LI(h,g,w){var M=to();sb(h,g,w,M)}function sb(h,g,w,M){var P={lane:M,revertLane:0,gesture:null,action:w,hasEagerState:!1,eagerState:null,next:null};if(Xv(h))FI(g,P);else{var L=h.alternate;if(h.lanes===0&&(L===null||L.lanes===0)&&(L=g.lastRenderedReducer,L!==null))try{var J=g.lastRenderedState,ve=L(J,w);if(P.hasEagerState=!0,P.eagerState=ve,Xs(ve,J))return Av(h,g,P,0),Pr===null&&Tv(),!1}catch{}finally{}if(w=tk(h,g,P,M),w!==null)return As(w,h,M),II(w,g,M),!0}return!1}function Ik(h,g,w,M){if(M={lane:2,revertLane:gE(),gesture:null,action:M,hasEagerState:!1,eagerState:null,next:null},Xv(h)){if(g)throw Error(r(479))}else g=tk(h,w,M,2),g!==null&&As(g,h,2)}function Xv(h){var g=h.alternate;return h===_n||g!==null&&g===_n}function FI(h,g){Jm=Hv=!0;var w=h.pending;w===null?g.next=g:(g.next=w.next,w.next=g),h.pending=g}function II(h,g,w){if((w&4194048)!==0){var M=g.lanes;M&=h.pendingLanes,w|=M,g.lanes=w,Jt(h,w)}}var ob={readContext:Na,use:Gv,useCallback:di,useContext:di,useEffect:di,useImperativeHandle:di,useLayoutEffect:di,useInsertionEffect:di,useMemo:di,useReducer:di,useRef:di,useState:di,useDebugValue:di,useDeferredValue:di,useTransition:di,useSyncExternalStore:di,useId:di,useHostTransitionStatus:di,useFormState:di,useActionState:di,useOptimistic:di,useMemoCache:di,useCacheRefresh:di};ob.useEffectEvent=di;var UI={readContext:Na,use:Gv,useCallback:function(h,g){return ss().memoizedState=[h,g===void 0?null:g],h},useContext:Na,useEffect:_I,useImperativeHandle:function(h,g,w){w=w!=null?w.concat([h]):null,Wv(4194308,4,kI.bind(null,g,h),w)},useLayoutEffect:function(h,g){return Wv(4194308,4,h,g)},useInsertionEffect:function(h,g){Wv(4,2,h,g)},useMemo:function(h,g){var w=ss();g=g===void 0?null:g;var M=h();if(nf){je(!0);try{h()}finally{je(!1)}}return w.memoizedState=[M,g],M},useReducer:function(h,g,w){var M=ss();if(w!==void 0){var P=w(g);if(nf){je(!0);try{w(g)}finally{je(!1)}}}else P=g;return M.memoizedState=M.baseState=P,h={pending:null,lanes:0,dispatch:null,lastRenderedReducer:h,lastRenderedState:P},M.queue=h,h=h.dispatch=Nie.bind(null,_n,h),[M.memoizedState,h]},useRef:function(h){var g=ss();return h={current:h},g.memoizedState=h},useState:function(h){h=jk(h);var g=h.queue,w=LI.bind(null,_n,g);return g.dispatch=w,[h.memoizedState,w]},useDebugValue:Rk,useDeferredValue:function(h,g){var w=ss();return Ok(w,h,g)},useTransition:function(){var h=jk(!1);return h=jI.bind(null,_n,h.queue,!0,!1),ss().memoizedState=h,[!1,h]},useSyncExternalStore:function(h,g,w){var M=_n,P=ss();if(Yn){if(w===void 0)throw Error(r(407));w=w()}else{if(w=g(),Pr===null)throw Error(r(349));(Gn&127)!==0||sI(M,g,w)}P.memoizedState=w;var L={value:w,getSnapshot:g};return P.queue=L,_I(lI.bind(null,M,L,h),[h]),M.flags|=2048,tp(9,{destroy:void 0},oI.bind(null,M,L,w,g),null),w},useId:function(){var h=ss(),g=Pr.identifierPrefix;if(Yn){var w=ql,M=Gl;w=(M&~(1<<32-Be(M)-1)).toString(32)+w,g="_"+g+"R_"+w,w=$v++,0<w&&(g+="H"+w.toString(32)),g+="_"}else w=bie++,g="_"+g+"r_"+w.toString(32)+"_";return h.memoizedState=g},useHostTransitionStatus:Fk,useFormState:xI,useActionState:xI,useOptimistic:function(h){var g=ss();g.memoizedState=g.baseState=h;var w={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return g.queue=w,g=Ik.bind(null,_n,!0,w),w.dispatch=g,[h,g]},useMemoCache:Tk,useCacheRefresh:function(){return ss().memoizedState=Mie.bind(null,_n)},useEffectEvent:function(h){var g=ss(),w={impl:h};return g.memoizedState=w,function(){if((ur&2)!==0)throw Error(r(440));return w.impl.apply(void 0,arguments)}}},Uk={readContext:Na,use:Gv,useCallback:TI,useContext:Na,useEffect:Dk,useImperativeHandle:EI,useInsertionEffect:MI,useLayoutEffect:NI,useMemo:AI,useReducer:qv,useRef:wI,useState:function(){return qv(Lc)},useDebugValue:Rk,useDeferredValue:function(h,g){var w=Ni();return CI(w,wr.memoizedState,h,g)},useTransition:function(){var h=qv(Lc)[0],g=Ni().memoizedState;return[typeof h=="boolean"?h:ab(h),g]},useSyncExternalStore:aI,useId:RI,useHostTransitionStatus:Fk,useFormState:bI,useActionState:bI,useOptimistic:function(h,g){var w=Ni();return dI(w,wr,h,g)},useMemoCache:Tk,useCacheRefresh:OI};Uk.useEffectEvent=SI;var zI={readContext:Na,use:Gv,useCallback:TI,useContext:Na,useEffect:Dk,useImperativeHandle:EI,useInsertionEffect:MI,useLayoutEffect:NI,useMemo:AI,useReducer:Ck,useRef:wI,useState:function(){return Ck(Lc)},useDebugValue:Rk,useDeferredValue:function(h,g){var w=Ni();return wr===null?Ok(w,h,g):CI(w,wr.memoizedState,h,g)},useTransition:function(){var h=Ck(Lc)[0],g=Ni().memoizedState;return[typeof h=="boolean"?h:ab(h),g]},useSyncExternalStore:aI,useId:RI,useHostTransitionStatus:Fk,useFormState:vI,useActionState:vI,useOptimistic:function(h,g){var w=Ni();return wr!==null?dI(w,wr,h,g):(w.baseState=h,[h,w.queue.dispatch])},useMemoCache:Tk,useCacheRefresh:OI};zI.useEffectEvent=SI;function zk(h,g,w,M){g=h.memoizedState,w=w(M,g),w=w==null?g:f({},g,w),h.memoizedState=w,h.lanes===0&&(h.updateQueue.baseState=w)}var Bk={enqueueSetState:function(h,g,w){h=h._reactInternals;var M=to(),P=ad(M);P.payload=g,w!=null&&(P.callback=w),g=sd(h,P,M),g!==null&&(As(g,h,M),tb(g,h,M))},enqueueReplaceState:function(h,g,w){h=h._reactInternals;var M=to(),P=ad(M);P.tag=1,P.payload=g,w!=null&&(P.callback=w),g=sd(h,P,M),g!==null&&(As(g,h,M),tb(g,h,M))},enqueueForceUpdate:function(h,g){h=h._reactInternals;var w=to(),M=ad(w);M.tag=2,g!=null&&(M.callback=g),g=sd(h,M,w),g!==null&&(As(g,h,w),tb(g,h,w))}};function BI(h,g,w,M,P,L,J){return h=h.stateNode,typeof h.shouldComponentUpdate=="function"?h.shouldComponentUpdate(M,L,J):g.prototype&&g.prototype.isPureReactComponent?!Wx(w,M)||!Wx(P,L):!0}function HI(h,g,w,M){h=g.state,typeof g.componentWillReceiveProps=="function"&&g.componentWillReceiveProps(w,M),typeof g.UNSAFE_componentWillReceiveProps=="function"&&g.UNSAFE_componentWillReceiveProps(w,M),g.state!==h&&Bk.enqueueReplaceState(g,g.state,null)}function rf(h,g){var w=g;if("ref"in g){w={};for(var M in g)M!=="ref"&&(w[M]=g[M])}if(h=h.defaultProps){w===g&&(w=f({},w));for(var P in h)w[P]===void 0&&(w[P]=h[P])}return w}function $I(h){Ev(h)}function VI(h){console.error(h)}function GI(h){Ev(h)}function Yv(h,g){try{var w=h.onUncaughtError;w(g.value,{componentStack:g.stack})}catch(M){setTimeout(function(){throw M})}}function qI(h,g,w){try{var M=h.onCaughtError;M(w.value,{componentStack:w.stack,errorBoundary:g.tag===1?g.stateNode:null})}catch(P){setTimeout(function(){throw P})}}function Hk(h,g,w){return w=ad(w),w.tag=3,w.payload={element:null},w.callback=function(){Yv(h,g)},w}function WI(h){return h=ad(h),h.tag=3,h}function KI(h,g,w,M){var P=w.type.getDerivedStateFromError;if(typeof P=="function"){var L=M.value;h.payload=function(){return P(L)},h.callback=function(){qI(g,w,M)}}var J=w.stateNode;J!==null&&typeof J.componentDidCatch=="function"&&(h.callback=function(){qI(g,w,M),typeof P!="function"&&(hd===null?hd=new Set([this]):hd.add(this));var ve=M.stack;this.componentDidCatch(M.value,{componentStack:ve!==null?ve:""})})}function kie(h,g,w,M,P){if(w.flags|=32768,M!==null&&typeof M=="object"&&typeof M.then=="function"){if(g=w.alternate,g!==null&&Wm(g,w,P,!0),w=Qs.current,w!==null){switch(w.tag){case 31:case 13:return jo===null?lw():w.alternate===null&&hi===0&&(hi=3),w.flags&=-257,w.flags|=65536,w.lanes=P,M===Fv?w.flags|=16384:(g=w.updateQueue,g===null?w.updateQueue=new Set([M]):g.add(M),fE(h,M,P)),!1;case 22:return w.flags|=65536,M===Fv?w.flags|=16384:(g=w.updateQueue,g===null?(g={transitions:null,markerInstances:null,retryQueue:new Set([M])},w.updateQueue=g):(w=g.retryQueue,w===null?g.retryQueue=new Set([M]):w.add(M)),fE(h,M,P)),!1}throw Error(r(435,w.tag))}return fE(h,M,P),lw(),!1}if(Yn)return g=Qs.current,g!==null?((g.flags&65536)===0&&(g.flags|=256),g.flags|=65536,g.lanes=P,M!==ok&&(h=Error(r(422),{cause:M}),Yx(Eo(h,w)))):(M!==ok&&(g=Error(r(423),{cause:M}),Yx(Eo(g,w))),h=h.current.alternate,h.flags|=65536,P&=-P,h.lanes|=P,M=Eo(M,w),P=Hk(h.stateNode,M,P),bk(h,P),hi!==4&&(hi=2)),!1;var L=Error(r(520),{cause:M});if(L=Eo(L,w),pb===null?pb=[L]:pb.push(L),hi!==4&&(hi=2),g===null)return!0;M=Eo(M,w),w=g;do{switch(w.tag){case 3:return w.flags|=65536,h=P&-P,w.lanes|=h,h=Hk(w.stateNode,M,h),bk(w,h),!1;case 1:if(g=w.type,L=w.stateNode,(w.flags&128)===0&&(typeof g.getDerivedStateFromError=="function"||L!==null&&typeof L.componentDidCatch=="function"&&(hd===null||!hd.has(L))))return w.flags|=65536,P&=-P,w.lanes|=P,P=WI(P),KI(P,h,w,M),bk(w,P),!1}w=w.return}while(w!==null);return!1}var $k=Error(r(461)),Pi=!1;function ka(h,g,w,M){g.child=h===null?ZF(g,null,w,M):tf(g,h.child,w,M)}function XI(h,g,w,M,P){w=w.render;var L=g.ref;if("ref"in M){var J={};for(var ve in M)ve!=="ref"&&(J[ve]=M[ve])}else J=M;return Qh(g),M=Mk(h,g,w,J,L,P),ve=Nk(),h!==null&&!Pi?(kk(h,g,P),Fc(h,g,P)):(Yn&&ve&&ak(g),g.flags|=1,ka(h,g,M,P),g.child)}function YI(h,g,w,M,P){if(h===null){var L=w.type;return typeof L=="function"&&!nk(L)&&L.defaultProps===void 0&&w.compare===null?(g.tag=15,g.type=L,QI(h,g,L,M,P)):(h=jv(w.type,null,M,g,g.mode,P),h.ref=g.ref,h.return=g,g.child=h)}if(L=h.child,!Qk(h,P)){var J=L.memoizedProps;if(w=w.compare,w=w!==null?w:Wx,w(J,M)&&h.ref===g.ref)return Fc(h,g,P)}return g.flags|=1,h=jc(L,M),h.ref=g.ref,h.return=g,g.child=h}function QI(h,g,w,M,P){if(h!==null){var L=h.memoizedProps;if(Wx(L,M)&&h.ref===g.ref)if(Pi=!1,g.pendingProps=M=L,Qk(h,P))(h.flags&131072)!==0&&(Pi=!0);else return g.lanes=h.lanes,Fc(h,g,P)}return Vk(h,g,w,M,P)}function ZI(h,g,w,M){var P=M.children,L=h!==null?h.memoizedState:null;if(h===null&&g.stateNode===null&&(g.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),M.mode==="hidden"){if((g.flags&128)!==0){if(L=L!==null?L.baseLanes|w:w,h!==null){for(M=g.child=h.child,P=0;M!==null;)P=P|M.lanes|M.childLanes,M=M.sibling;M=P&~L}else M=0,g.child=null;return JI(h,g,L,w,M)}if((w&536870912)!==0)g.memoizedState={baseLanes:0,cachePool:null},h!==null&&Ov(g,L!==null?L.cachePool:null),L!==null?tI(g,L):vk(),nI(g);else return M=g.lanes=536870912,JI(h,g,L!==null?L.baseLanes|w:w,w,M)}else L!==null?(Ov(g,L.cachePool),tI(g,L),ld(),g.memoizedState=null):(h!==null&&Ov(g,null),vk(),ld());return ka(h,g,P,w),g.child}function lb(h,g){return h!==null&&h.tag===22||g.stateNode!==null||(g.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),g.sibling}function JI(h,g,w,M,P){var L=mk();return L=L===null?null:{parent:Ci._currentValue,pool:L},g.memoizedState={baseLanes:w,cachePool:L},h!==null&&Ov(g,null),vk(),nI(g),h!==null&&Wm(h,g,M,!0),g.childLanes=P,null}function Qv(h,g){return g=Jv({mode:g.mode,children:g.children},h.mode),g.ref=h.ref,h.child=g,g.return=h,g}function e5(h,g,w){return tf(g,h.child,null,w),h=Qv(g,g.pendingProps),h.flags|=2,Zs(g),g.memoizedState=null,h}function Eie(h,g,w){var M=g.pendingProps,P=(g.flags&128)!==0;if(g.flags&=-129,h===null){if(Yn){if(M.mode==="hidden")return h=Qv(g,M),g.lanes=536870912,lb(null,h);if(_k(g),(h=$r)?(h=hU(h,Co),h=h!==null&&h.data==="&"?h:null,h!==null&&(g.memoizedState={dehydrated:h,treeContext:ed!==null?{id:Gl,overflow:ql}:null,retryLane:536870912,hydrationErrors:null},w=FF(h),w.return=g,g.child=w,Ma=g,$r=null)):h=null,h===null)throw nd(g);return g.lanes=536870912,null}return Qv(g,M)}var L=h.memoizedState;if(L!==null){var J=L.dehydrated;if(_k(g),P)if(g.flags&256)g.flags&=-257,g=e5(h,g,w);else if(g.memoizedState!==null)g.child=h.child,g.flags|=128,g=null;else throw Error(r(558));else if(Pi||Wm(h,g,w,!1),P=(w&h.childLanes)!==0,Pi||P){if(M=Pr,M!==null&&(J=ir(M,w),J!==0&&J!==L.retryLane))throw L.retryLane=J,Wh(h,J),As(M,h,J),$k;lw(),g=e5(h,g,w)}else h=L.treeContext,$r=Po(J.nextSibling),Ma=g,Yn=!0,td=null,Co=!1,h!==null&&zF(g,h),g=Qv(g,M),g.flags|=4096;return g}return h=jc(h.child,{mode:M.mode,children:M.children}),h.ref=g.ref,g.child=h,h.return=g,h}function Zv(h,g){var w=g.ref;if(w===null)h!==null&&h.ref!==null&&(g.flags|=4194816);else{if(typeof w!="function"&&typeof w!="object")throw Error(r(284));(h===null||h.ref!==w)&&(g.flags|=4194816)}}function Vk(h,g,w,M,P){return Qh(g),w=Mk(h,g,w,M,void 0,P),M=Nk(),h!==null&&!Pi?(kk(h,g,P),Fc(h,g,P)):(Yn&&M&&ak(g),g.flags|=1,ka(h,g,w,P),g.child)}function t5(h,g,w,M,P,L){return Qh(g),g.updateQueue=null,w=iI(g,M,w,P),rI(h),M=Nk(),h!==null&&!Pi?(kk(h,g,L),Fc(h,g,L)):(Yn&&M&&ak(g),g.flags|=1,ka(h,g,w,L),g.child)}function n5(h,g,w,M,P){if(Qh(g),g.stateNode===null){var L=$m,J=w.contextType;typeof J=="object"&&J!==null&&(L=Na(J)),L=new w(M,L),g.memoizedState=L.state!==null&&L.state!==void 0?L.state:null,L.updater=Bk,g.stateNode=L,L._reactInternals=g,L=g.stateNode,L.props=M,L.state=g.memoizedState,L.refs={},gk(g),J=w.contextType,L.context=typeof J=="object"&&J!==null?Na(J):$m,L.state=g.memoizedState,J=w.getDerivedStateFromProps,typeof J=="function"&&(zk(g,w,J,M),L.state=g.memoizedState),typeof w.getDerivedStateFromProps=="function"||typeof L.getSnapshotBeforeUpdate=="function"||typeof L.UNSAFE_componentWillMount!="function"&&typeof L.componentWillMount!="function"||(J=L.state,typeof L.componentWillMount=="function"&&L.componentWillMount(),typeof L.UNSAFE_componentWillMount=="function"&&L.UNSAFE_componentWillMount(),J!==L.state&&Bk.enqueueReplaceState(L,L.state,null),rb(g,M,L,P),nb(),L.state=g.memoizedState),typeof L.componentDidMount=="function"&&(g.flags|=4194308),M=!0}else if(h===null){L=g.stateNode;var ve=g.memoizedProps,Ue=rf(w,ve);L.props=Ue;var it=L.context,gt=w.contextType;J=$m,typeof gt=="object"&>!==null&&(J=Na(gt));var vt=w.getDerivedStateFromProps;gt=typeof vt=="function"||typeof L.getSnapshotBeforeUpdate=="function",ve=g.pendingProps!==ve,gt||typeof L.UNSAFE_componentWillReceiveProps!="function"&&typeof L.componentWillReceiveProps!="function"||(ve||it!==J)&&HI(g,L,M,J),id=!1;var ct=g.memoizedState;L.state=ct,rb(g,M,L,P),nb(),it=g.memoizedState,ve||ct!==it||id?(typeof vt=="function"&&(zk(g,w,vt,M),it=g.memoizedState),(Ue=id||BI(g,w,Ue,M,ct,it,J))?(gt||typeof L.UNSAFE_componentWillMount!="function"&&typeof L.componentWillMount!="function"||(typeof L.componentWillMount=="function"&&L.componentWillMount(),typeof L.UNSAFE_componentWillMount=="function"&&L.UNSAFE_componentWillMount()),typeof L.componentDidMount=="function"&&(g.flags|=4194308)):(typeof L.componentDidMount=="function"&&(g.flags|=4194308),g.memoizedProps=M,g.memoizedState=it),L.props=M,L.state=it,L.context=J,M=Ue):(typeof L.componentDidMount=="function"&&(g.flags|=4194308),M=!1)}else{L=g.stateNode,xk(h,g),J=g.memoizedProps,gt=rf(w,J),L.props=gt,vt=g.pendingProps,ct=L.context,it=w.contextType,Ue=$m,typeof it=="object"&&it!==null&&(Ue=Na(it)),ve=w.getDerivedStateFromProps,(it=typeof ve=="function"||typeof L.getSnapshotBeforeUpdate=="function")||typeof L.UNSAFE_componentWillReceiveProps!="function"&&typeof L.componentWillReceiveProps!="function"||(J!==vt||ct!==Ue)&&HI(g,L,M,Ue),id=!1,ct=g.memoizedState,L.state=ct,rb(g,M,L,P),nb();var pt=g.memoizedState;J!==vt||ct!==pt||id||h!==null&&h.dependencies!==null&&Dv(h.dependencies)?(typeof ve=="function"&&(zk(g,w,ve,M),pt=g.memoizedState),(gt=id||BI(g,w,gt,M,ct,pt,Ue)||h!==null&&h.dependencies!==null&&Dv(h.dependencies))?(it||typeof L.UNSAFE_componentWillUpdate!="function"&&typeof L.componentWillUpdate!="function"||(typeof L.componentWillUpdate=="function"&&L.componentWillUpdate(M,pt,Ue),typeof L.UNSAFE_componentWillUpdate=="function"&&L.UNSAFE_componentWillUpdate(M,pt,Ue)),typeof L.componentDidUpdate=="function"&&(g.flags|=4),typeof L.getSnapshotBeforeUpdate=="function"&&(g.flags|=1024)):(typeof L.componentDidUpdate!="function"||J===h.memoizedProps&&ct===h.memoizedState||(g.flags|=4),typeof L.getSnapshotBeforeUpdate!="function"||J===h.memoizedProps&&ct===h.memoizedState||(g.flags|=1024),g.memoizedProps=M,g.memoizedState=pt),L.props=M,L.state=pt,L.context=Ue,M=gt):(typeof L.componentDidUpdate!="function"||J===h.memoizedProps&&ct===h.memoizedState||(g.flags|=4),typeof L.getSnapshotBeforeUpdate!="function"||J===h.memoizedProps&&ct===h.memoizedState||(g.flags|=1024),M=!1)}return L=M,Zv(h,g),M=(g.flags&128)!==0,L||M?(L=g.stateNode,w=M&&typeof w.getDerivedStateFromError!="function"?null:L.render(),g.flags|=1,h!==null&&M?(g.child=tf(g,h.child,null,P),g.child=tf(g,null,w,P)):ka(h,g,w,P),g.memoizedState=L.state,h=g.child):h=Fc(h,g,P),h}function r5(h,g,w,M){return Xh(),g.flags|=256,ka(h,g,w,M),g.child}var Gk={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function qk(h){return{baseLanes:h,cachePool:qF()}}function Wk(h,g,w){return h=h!==null?h.childLanes&~w:0,g&&(h|=eo),h}function i5(h,g,w){var M=g.pendingProps,P=!1,L=(g.flags&128)!==0,J;if((J=L)||(J=h!==null&&h.memoizedState===null?!1:(Mi.current&2)!==0),J&&(P=!0,g.flags&=-129),J=(g.flags&32)!==0,g.flags&=-33,h===null){if(Yn){if(P?od(g):ld(),(h=$r)?(h=hU(h,Co),h=h!==null&&h.data!=="&"?h:null,h!==null&&(g.memoizedState={dehydrated:h,treeContext:ed!==null?{id:Gl,overflow:ql}:null,retryLane:536870912,hydrationErrors:null},w=FF(h),w.return=g,g.child=w,Ma=g,$r=null)):h=null,h===null)throw nd(g);return AE(h)?g.lanes=32:g.lanes=536870912,null}var ve=M.children;return M=M.fallback,P?(ld(),P=g.mode,ve=Jv({mode:"hidden",children:ve},P),M=Kh(M,P,w,null),ve.return=g,M.return=g,ve.sibling=M,g.child=ve,M=g.child,M.memoizedState=qk(w),M.childLanes=Wk(h,J,w),g.memoizedState=Gk,lb(null,M)):(od(g),Kk(g,ve))}var Ue=h.memoizedState;if(Ue!==null&&(ve=Ue.dehydrated,ve!==null)){if(L)g.flags&256?(od(g),g.flags&=-257,g=Xk(h,g,w)):g.memoizedState!==null?(ld(),g.child=h.child,g.flags|=128,g=null):(ld(),ve=M.fallback,P=g.mode,M=Jv({mode:"visible",children:M.children},P),ve=Kh(ve,P,w,null),ve.flags|=2,M.return=g,ve.return=g,M.sibling=ve,g.child=M,tf(g,h.child,null,w),M=g.child,M.memoizedState=qk(w),M.childLanes=Wk(h,J,w),g.memoizedState=Gk,g=lb(null,M));else if(od(g),AE(ve)){if(J=ve.nextSibling&&ve.nextSibling.dataset,J)var it=J.dgst;J=it,M=Error(r(419)),M.stack="",M.digest=J,Yx({value:M,source:null,stack:null}),g=Xk(h,g,w)}else if(Pi||Wm(h,g,w,!1),J=(w&h.childLanes)!==0,Pi||J){if(J=Pr,J!==null&&(M=ir(J,w),M!==0&&M!==Ue.retryLane))throw Ue.retryLane=M,Wh(h,M),As(J,h,M),$k;TE(ve)||lw(),g=Xk(h,g,w)}else TE(ve)?(g.flags|=192,g.child=h.child,g=null):(h=Ue.treeContext,$r=Po(ve.nextSibling),Ma=g,Yn=!0,td=null,Co=!1,h!==null&&zF(g,h),g=Kk(g,M.children),g.flags|=4096);return g}return P?(ld(),ve=M.fallback,P=g.mode,Ue=h.child,it=Ue.sibling,M=jc(Ue,{mode:"hidden",children:M.children}),M.subtreeFlags=Ue.subtreeFlags&65011712,it!==null?ve=jc(it,ve):(ve=Kh(ve,P,w,null),ve.flags|=2),ve.return=g,M.return=g,M.sibling=ve,g.child=M,lb(null,M),M=g.child,ve=h.child.memoizedState,ve===null?ve=qk(w):(P=ve.cachePool,P!==null?(Ue=Ci._currentValue,P=P.parent!==Ue?{parent:Ue,pool:Ue}:P):P=qF(),ve={baseLanes:ve.baseLanes|w,cachePool:P}),M.memoizedState=ve,M.childLanes=Wk(h,J,w),g.memoizedState=Gk,lb(h.child,M)):(od(g),w=h.child,h=w.sibling,w=jc(w,{mode:"visible",children:M.children}),w.return=g,w.sibling=null,h!==null&&(J=g.deletions,J===null?(g.deletions=[h],g.flags|=16):J.push(h)),g.child=w,g.memoizedState=null,w)}function Kk(h,g){return g=Jv({mode:"visible",children:g},h.mode),g.return=h,h.child=g}function Jv(h,g){return h=Ys(22,h,null,g),h.lanes=0,h}function Xk(h,g,w){return tf(g,h.child,null,w),h=Kk(g,g.pendingProps.children),h.flags|=2,g.memoizedState=null,h}function a5(h,g,w){h.lanes|=g;var M=h.alternate;M!==null&&(M.lanes|=g),uk(h.return,g,w)}function Yk(h,g,w,M,P,L){var J=h.memoizedState;J===null?h.memoizedState={isBackwards:g,rendering:null,renderingStartTime:0,last:M,tail:w,tailMode:P,treeForkCount:L}:(J.isBackwards=g,J.rendering=null,J.renderingStartTime=0,J.last=M,J.tail=w,J.tailMode=P,J.treeForkCount=L)}function s5(h,g,w){var M=g.pendingProps,P=M.revealOrder,L=M.tail;M=M.children;var J=Mi.current,ve=(J&2)!==0;if(ve?(J=J&1|2,g.flags|=128):J&=1,ne(Mi,J),ka(h,g,M,w),M=Yn?Xx:0,!ve&&h!==null&&(h.flags&128)!==0)e:for(h=g.child;h!==null;){if(h.tag===13)h.memoizedState!==null&&a5(h,w,g);else if(h.tag===19)a5(h,w,g);else if(h.child!==null){h.child.return=h,h=h.child;continue}if(h===g)break e;for(;h.sibling===null;){if(h.return===null||h.return===g)break e;h=h.return}h.sibling.return=h.return,h=h.sibling}switch(P){case"forwards":for(w=g.child,P=null;w!==null;)h=w.alternate,h!==null&&Bv(h)===null&&(P=w),w=w.sibling;w=P,w===null?(P=g.child,g.child=null):(P=w.sibling,w.sibling=null),Yk(g,!1,P,w,L,M);break;case"backwards":case"unstable_legacy-backwards":for(w=null,P=g.child,g.child=null;P!==null;){if(h=P.alternate,h!==null&&Bv(h)===null){g.child=P;break}h=P.sibling,P.sibling=w,w=P,P=h}Yk(g,!0,w,null,L,M);break;case"together":Yk(g,!1,null,null,void 0,M);break;default:g.memoizedState=null}return g.child}function Fc(h,g,w){if(h!==null&&(g.dependencies=h.dependencies),dd|=g.lanes,(w&g.childLanes)===0)if(h!==null){if(Wm(h,g,w,!1),(w&g.childLanes)===0)return null}else return null;if(h!==null&&g.child!==h.child)throw Error(r(153));if(g.child!==null){for(h=g.child,w=jc(h,h.pendingProps),g.child=w,w.return=g;h.sibling!==null;)h=h.sibling,w=w.sibling=jc(h,h.pendingProps),w.return=g;w.sibling=null}return g.child}function Qk(h,g){return(h.lanes&g)!==0?!0:(h=h.dependencies,!!(h!==null&&Dv(h)))}function Tie(h,g,w){switch(g.tag){case 3:Pe(g,g.stateNode.containerInfo),rd(g,Ci,h.memoizedState.cache),Xh();break;case 27:case 5:Ne(g);break;case 4:Pe(g,g.stateNode.containerInfo);break;case 10:rd(g,g.type,g.memoizedProps.value);break;case 31:if(g.memoizedState!==null)return g.flags|=128,_k(g),null;break;case 13:var M=g.memoizedState;if(M!==null)return M.dehydrated!==null?(od(g),g.flags|=128,null):(w&g.child.childLanes)!==0?i5(h,g,w):(od(g),h=Fc(h,g,w),h!==null?h.sibling:null);od(g);break;case 19:var P=(h.flags&128)!==0;if(M=(w&g.childLanes)!==0,M||(Wm(h,g,w,!1),M=(w&g.childLanes)!==0),P){if(M)return s5(h,g,w);g.flags|=128}if(P=g.memoizedState,P!==null&&(P.rendering=null,P.tail=null,P.lastEffect=null),ne(Mi,Mi.current),M)break;return null;case 22:return g.lanes=0,ZI(h,g,w,g.pendingProps);case 24:rd(g,Ci,h.memoizedState.cache)}return Fc(h,g,w)}function o5(h,g,w){if(h!==null)if(h.memoizedProps!==g.pendingProps)Pi=!0;else{if(!Qk(h,w)&&(g.flags&128)===0)return Pi=!1,Tie(h,g,w);Pi=(h.flags&131072)!==0}else Pi=!1,Yn&&(g.flags&1048576)!==0&&UF(g,Xx,g.index);switch(g.lanes=0,g.tag){case 16:e:{var M=g.pendingProps;if(h=Jh(g.elementType),g.type=h,typeof h=="function")nk(h)?(M=rf(h,M),g.tag=1,g=n5(null,g,h,M,w)):(g.tag=0,g=Vk(null,g,h,M,w));else{if(h!=null){var P=h.$$typeof;if(P===T){g.tag=11,g=XI(null,g,h,M,w);break e}else if(P===E){g.tag=14,g=YI(null,g,h,M,w);break e}}throw g=j(h)||h,Error(r(306,g,""))}}return g;case 0:return Vk(h,g,g.type,g.pendingProps,w);case 1:return M=g.type,P=rf(M,g.pendingProps),n5(h,g,M,P,w);case 3:e:{if(Pe(g,g.stateNode.containerInfo),h===null)throw Error(r(387));M=g.pendingProps;var L=g.memoizedState;P=L.element,xk(h,g),rb(g,M,null,w);var J=g.memoizedState;if(M=J.cache,rd(g,Ci,M),M!==L.cache&&dk(g,[Ci],w,!0),nb(),M=J.element,L.isDehydrated)if(L={element:M,isDehydrated:!1,cache:J.cache},g.updateQueue.baseState=L,g.memoizedState=L,g.flags&256){g=r5(h,g,M,w);break e}else if(M!==P){P=Eo(Error(r(424)),g),Yx(P),g=r5(h,g,M,w);break e}else{switch(h=g.stateNode.containerInfo,h.nodeType){case 9:h=h.body;break;default:h=h.nodeName==="HTML"?h.ownerDocument.body:h}for($r=Po(h.firstChild),Ma=g,Yn=!0,td=null,Co=!0,w=ZF(g,null,M,w),g.child=w;w;)w.flags=w.flags&-3|4096,w=w.sibling}else{if(Xh(),M===P){g=Fc(h,g,w);break e}ka(h,g,M,w)}g=g.child}return g;case 26:return Zv(h,g),h===null?(w=bU(g.type,null,g.pendingProps,null))?g.memoizedState=w:Yn||(w=g.type,h=g.pendingProps,M=pw(xe.current).createElement(w),M[Xn]=g,M[bn]=h,Ea(M,w,h),Le(M),g.stateNode=M):g.memoizedState=bU(g.type,h.memoizedProps,g.pendingProps,h.memoizedState),null;case 27:return Ne(g),h===null&&Yn&&(M=g.stateNode=pU(g.type,g.pendingProps,xe.current),Ma=g,Co=!0,P=$r,gd(g.type)?(CE=P,$r=Po(M.firstChild)):$r=P),ka(h,g,g.pendingProps.children,w),Zv(h,g),h===null&&(g.flags|=4194304),g.child;case 5:return h===null&&Yn&&((P=M=$r)&&(M=iae(M,g.type,g.pendingProps,Co),M!==null?(g.stateNode=M,Ma=g,$r=Po(M.firstChild),Co=!1,P=!0):P=!1),P||nd(g)),Ne(g),P=g.type,L=g.pendingProps,J=h!==null?h.memoizedProps:null,M=L.children,NE(P,L)?M=null:J!==null&&NE(P,J)&&(g.flags|=32),g.memoizedState!==null&&(P=Mk(h,g,yie,null,null,w),Sb._currentValue=P),Zv(h,g),ka(h,g,M,w),g.child;case 6:return h===null&&Yn&&((h=w=$r)&&(w=aae(w,g.pendingProps,Co),w!==null?(g.stateNode=w,Ma=g,$r=null,h=!0):h=!1),h||nd(g)),null;case 13:return i5(h,g,w);case 4:return Pe(g,g.stateNode.containerInfo),M=g.pendingProps,h===null?g.child=tf(g,null,M,w):ka(h,g,M,w),g.child;case 11:return XI(h,g,g.type,g.pendingProps,w);case 7:return ka(h,g,g.pendingProps,w),g.child;case 8:return ka(h,g,g.pendingProps.children,w),g.child;case 12:return ka(h,g,g.pendingProps.children,w),g.child;case 10:return M=g.pendingProps,rd(g,g.type,M.value),ka(h,g,M.children,w),g.child;case 9:return P=g.type._context,M=g.pendingProps.children,Qh(g),P=Na(P),M=M(P),g.flags|=1,ka(h,g,M,w),g.child;case 14:return YI(h,g,g.type,g.pendingProps,w);case 15:return QI(h,g,g.type,g.pendingProps,w);case 19:return s5(h,g,w);case 31:return Eie(h,g,w);case 22:return ZI(h,g,w,g.pendingProps);case 24:return Qh(g),M=Na(Ci),h===null?(P=mk(),P===null&&(P=Pr,L=hk(),P.pooledCache=L,L.refCount++,L!==null&&(P.pooledCacheLanes|=w),P=L),g.memoizedState={parent:M,cache:P},gk(g),rd(g,Ci,P)):((h.lanes&w)!==0&&(xk(h,g),rb(g,null,null,w),nb()),P=h.memoizedState,L=g.memoizedState,P.parent!==M?(P={parent:M,cache:M},g.memoizedState=P,g.lanes===0&&(g.memoizedState=g.updateQueue.baseState=P),rd(g,Ci,M)):(M=L.cache,rd(g,Ci,M),M!==P.cache&&dk(g,[Ci],w,!0))),ka(h,g,g.pendingProps.children,w),g.child;case 29:throw g.pendingProps}throw Error(r(156,g.tag))}function Ic(h){h.flags|=4}function Zk(h,g,w,M,P){if((g=(h.mode&32)!==0)&&(g=!1),g){if(h.flags|=16777216,(P&335544128)===P)if(h.stateNode.complete)h.flags|=8192;else if(R5())h.flags|=8192;else throw ef=Fv,pk}else h.flags&=-16777217}function l5(h,g){if(g.type!=="stylesheet"||(g.state.loading&4)!==0)h.flags&=-16777217;else if(h.flags|=16777216,!SU(g))if(R5())h.flags|=8192;else throw ef=Fv,pk}function ew(h,g){g!==null&&(h.flags|=4),h.flags&16384&&(g=h.tag!==22?xt():536870912,h.lanes|=g,ap|=g)}function cb(h,g){if(!Yn)switch(h.tailMode){case"hidden":g=h.tail;for(var w=null;g!==null;)g.alternate!==null&&(w=g),g=g.sibling;w===null?h.tail=null:w.sibling=null;break;case"collapsed":w=h.tail;for(var M=null;w!==null;)w.alternate!==null&&(M=w),w=w.sibling;M===null?g||h.tail===null?h.tail=null:h.tail.sibling=null:M.sibling=null}}function Vr(h){var g=h.alternate!==null&&h.alternate.child===h.child,w=0,M=0;if(g)for(var P=h.child;P!==null;)w|=P.lanes|P.childLanes,M|=P.subtreeFlags&65011712,M|=P.flags&65011712,P.return=h,P=P.sibling;else for(P=h.child;P!==null;)w|=P.lanes|P.childLanes,M|=P.subtreeFlags,M|=P.flags,P.return=h,P=P.sibling;return h.subtreeFlags|=M,h.childLanes=w,g}function Aie(h,g,w){var M=g.pendingProps;switch(sk(g),g.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Vr(g),null;case 1:return Vr(g),null;case 3:return w=g.stateNode,M=null,h!==null&&(M=h.memoizedState.cache),g.memoizedState.cache!==M&&(g.flags|=2048),Rc(Ci),ie(),w.pendingContext&&(w.context=w.pendingContext,w.pendingContext=null),(h===null||h.child===null)&&(qm(g)?Ic(g):h===null||h.memoizedState.isDehydrated&&(g.flags&256)===0||(g.flags|=1024,lk())),Vr(g),null;case 26:var P=g.type,L=g.memoizedState;return h===null?(Ic(g),L!==null?(Vr(g),l5(g,L)):(Vr(g),Zk(g,P,null,M,w))):L?L!==h.memoizedState?(Ic(g),Vr(g),l5(g,L)):(Vr(g),g.flags&=-16777217):(h=h.memoizedProps,h!==M&&Ic(g),Vr(g),Zk(g,P,h,M,w)),null;case 27:if(Oe(g),w=xe.current,P=g.type,h!==null&&g.stateNode!=null)h.memoizedProps!==M&&Ic(g);else{if(!M){if(g.stateNode===null)throw Error(r(166));return Vr(g),null}h=se.current,qm(g)?BF(g):(h=pU(P,M,w),g.stateNode=h,Ic(g))}return Vr(g),null;case 5:if(Oe(g),P=g.type,h!==null&&g.stateNode!=null)h.memoizedProps!==M&&Ic(g);else{if(!M){if(g.stateNode===null)throw Error(r(166));return Vr(g),null}if(L=se.current,qm(g))BF(g);else{var J=pw(xe.current);switch(L){case 1:L=J.createElementNS("http://www.w3.org/2000/svg",P);break;case 2:L=J.createElementNS("http://www.w3.org/1998/Math/MathML",P);break;default:switch(P){case"svg":L=J.createElementNS("http://www.w3.org/2000/svg",P);break;case"math":L=J.createElementNS("http://www.w3.org/1998/Math/MathML",P);break;case"script":L=J.createElement("div"),L.innerHTML="<script><\/script>",L=L.removeChild(L.firstChild);break;case"select":L=typeof M.is=="string"?J.createElement("select",{is:M.is}):J.createElement("select"),M.multiple?L.multiple=!0:M.size&&(L.size=M.size);break;default:L=typeof M.is=="string"?J.createElement(P,{is:M.is}):J.createElement(P)}}L[Xn]=g,L[bn]=M;e:for(J=g.child;J!==null;){if(J.tag===5||J.tag===6)L.appendChild(J.stateNode);else if(J.tag!==4&&J.tag!==27&&J.child!==null){J.child.return=J,J=J.child;continue}if(J===g)break e;for(;J.sibling===null;){if(J.return===null||J.return===g)break e;J=J.return}J.sibling.return=J.return,J=J.sibling}g.stateNode=L;e:switch(Ea(L,P,M),P){case"button":case"input":case"select":case"textarea":M=!!M.autoFocus;break e;case"img":M=!0;break e;default:M=!1}M&&Ic(g)}}return Vr(g),Zk(g,g.type,h===null?null:h.memoizedProps,g.pendingProps,w),null;case 6:if(h&&g.stateNode!=null)h.memoizedProps!==M&&Ic(g);else{if(typeof M!="string"&&g.stateNode===null)throw Error(r(166));if(h=xe.current,qm(g)){if(h=g.stateNode,w=g.memoizedProps,M=null,P=Ma,P!==null)switch(P.tag){case 27:case 5:M=P.memoizedProps}h[Xn]=g,h=!!(h.nodeValue===w||M!==null&&M.suppressHydrationWarning===!0||iU(h.nodeValue,w)),h||nd(g,!0)}else h=pw(h).createTextNode(M),h[Xn]=g,g.stateNode=h}return Vr(g),null;case 31:if(w=g.memoizedState,h===null||h.memoizedState!==null){if(M=qm(g),w!==null){if(h===null){if(!M)throw Error(r(318));if(h=g.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(r(557));h[Xn]=g}else Xh(),(g.flags&128)===0&&(g.memoizedState=null),g.flags|=4;Vr(g),h=!1}else w=lk(),h!==null&&h.memoizedState!==null&&(h.memoizedState.hydrationErrors=w),h=!0;if(!h)return g.flags&256?(Zs(g),g):(Zs(g),null);if((g.flags&128)!==0)throw Error(r(558))}return Vr(g),null;case 13:if(M=g.memoizedState,h===null||h.memoizedState!==null&&h.memoizedState.dehydrated!==null){if(P=qm(g),M!==null&&M.dehydrated!==null){if(h===null){if(!P)throw Error(r(318));if(P=g.memoizedState,P=P!==null?P.dehydrated:null,!P)throw Error(r(317));P[Xn]=g}else Xh(),(g.flags&128)===0&&(g.memoizedState=null),g.flags|=4;Vr(g),P=!1}else P=lk(),h!==null&&h.memoizedState!==null&&(h.memoizedState.hydrationErrors=P),P=!0;if(!P)return g.flags&256?(Zs(g),g):(Zs(g),null)}return Zs(g),(g.flags&128)!==0?(g.lanes=w,g):(w=M!==null,h=h!==null&&h.memoizedState!==null,w&&(M=g.child,P=null,M.alternate!==null&&M.alternate.memoizedState!==null&&M.alternate.memoizedState.cachePool!==null&&(P=M.alternate.memoizedState.cachePool.pool),L=null,M.memoizedState!==null&&M.memoizedState.cachePool!==null&&(L=M.memoizedState.cachePool.pool),L!==P&&(M.flags|=2048)),w!==h&&w&&(g.child.flags|=8192),ew(g,g.updateQueue),Vr(g),null);case 4:return ie(),h===null&&vE(g.stateNode.containerInfo),Vr(g),null;case 10:return Rc(g.type),Vr(g),null;case 19:if(X(Mi),M=g.memoizedState,M===null)return Vr(g),null;if(P=(g.flags&128)!==0,L=M.rendering,L===null)if(P)cb(M,!1);else{if(hi!==0||h!==null&&(h.flags&128)!==0)for(h=g.child;h!==null;){if(L=Bv(h),L!==null){for(g.flags|=128,cb(M,!1),h=L.updateQueue,g.updateQueue=h,ew(g,h),g.subtreeFlags=0,h=w,w=g.child;w!==null;)LF(w,h),w=w.sibling;return ne(Mi,Mi.current&1|2),Yn&&Pc(g,M.treeForkCount),g.child}h=h.sibling}M.tail!==null&&O()>aw&&(g.flags|=128,P=!0,cb(M,!1),g.lanes=4194304)}else{if(!P)if(h=Bv(L),h!==null){if(g.flags|=128,P=!0,h=h.updateQueue,g.updateQueue=h,ew(g,h),cb(M,!0),M.tail===null&&M.tailMode==="hidden"&&!L.alternate&&!Yn)return Vr(g),null}else 2*O()-M.renderingStartTime>aw&&w!==536870912&&(g.flags|=128,P=!0,cb(M,!1),g.lanes=4194304);M.isBackwards?(L.sibling=g.child,g.child=L):(h=M.last,h!==null?h.sibling=L:g.child=L,M.last=L)}return M.tail!==null?(h=M.tail,M.rendering=h,M.tail=h.sibling,M.renderingStartTime=O(),h.sibling=null,w=Mi.current,ne(Mi,P?w&1|2:w&1),Yn&&Pc(g,M.treeForkCount),h):(Vr(g),null);case 22:case 23:return Zs(g),wk(),M=g.memoizedState!==null,h!==null?h.memoizedState!==null!==M&&(g.flags|=8192):M&&(g.flags|=8192),M?(w&536870912)!==0&&(g.flags&128)===0&&(Vr(g),g.subtreeFlags&6&&(g.flags|=8192)):Vr(g),w=g.updateQueue,w!==null&&ew(g,w.retryQueue),w=null,h!==null&&h.memoizedState!==null&&h.memoizedState.cachePool!==null&&(w=h.memoizedState.cachePool.pool),M=null,g.memoizedState!==null&&g.memoizedState.cachePool!==null&&(M=g.memoizedState.cachePool.pool),M!==w&&(g.flags|=2048),h!==null&&X(Zh),null;case 24:return w=null,h!==null&&(w=h.memoizedState.cache),g.memoizedState.cache!==w&&(g.flags|=2048),Rc(Ci),Vr(g),null;case 25:return null;case 30:return null}throw Error(r(156,g.tag))}function Cie(h,g){switch(sk(g),g.tag){case 1:return h=g.flags,h&65536?(g.flags=h&-65537|128,g):null;case 3:return Rc(Ci),ie(),h=g.flags,(h&65536)!==0&&(h&128)===0?(g.flags=h&-65537|128,g):null;case 26:case 27:case 5:return Oe(g),null;case 31:if(g.memoizedState!==null){if(Zs(g),g.alternate===null)throw Error(r(340));Xh()}return h=g.flags,h&65536?(g.flags=h&-65537|128,g):null;case 13:if(Zs(g),h=g.memoizedState,h!==null&&h.dehydrated!==null){if(g.alternate===null)throw Error(r(340));Xh()}return h=g.flags,h&65536?(g.flags=h&-65537|128,g):null;case 19:return X(Mi),null;case 4:return ie(),null;case 10:return Rc(g.type),null;case 22:case 23:return Zs(g),wk(),h!==null&&X(Zh),h=g.flags,h&65536?(g.flags=h&-65537|128,g):null;case 24:return Rc(Ci),null;case 25:return null;default:return null}}function c5(h,g){switch(sk(g),g.tag){case 3:Rc(Ci),ie();break;case 26:case 27:case 5:Oe(g);break;case 4:ie();break;case 31:g.memoizedState!==null&&Zs(g);break;case 13:Zs(g);break;case 19:X(Mi);break;case 10:Rc(g.type);break;case 22:case 23:Zs(g),wk(),h!==null&&X(Zh);break;case 24:Rc(Ci)}}function ub(h,g){try{var w=g.updateQueue,M=w!==null?w.lastEffect:null;if(M!==null){var P=M.next;w=P;do{if((w.tag&h)===h){M=void 0;var L=w.create,J=w.inst;M=L(),J.destroy=M}w=w.next}while(w!==P)}}catch(ve){gr(g,g.return,ve)}}function cd(h,g,w){try{var M=g.updateQueue,P=M!==null?M.lastEffect:null;if(P!==null){var L=P.next;M=L;do{if((M.tag&h)===h){var J=M.inst,ve=J.destroy;if(ve!==void 0){J.destroy=void 0,P=g;var Ue=w,it=ve;try{it()}catch(gt){gr(P,Ue,gt)}}}M=M.next}while(M!==L)}}catch(gt){gr(g,g.return,gt)}}function u5(h){var g=h.updateQueue;if(g!==null){var w=h.stateNode;try{eI(g,w)}catch(M){gr(h,h.return,M)}}}function d5(h,g,w){w.props=rf(h.type,h.memoizedProps),w.state=h.memoizedState;try{w.componentWillUnmount()}catch(M){gr(h,g,M)}}function db(h,g){try{var w=h.ref;if(w!==null){switch(h.tag){case 26:case 27:case 5:var M=h.stateNode;break;case 30:M=h.stateNode;break;default:M=h.stateNode}typeof w=="function"?h.refCleanup=w(M):w.current=M}}catch(P){gr(h,g,P)}}function Wl(h,g){var w=h.ref,M=h.refCleanup;if(w!==null)if(typeof M=="function")try{M()}catch(P){gr(h,g,P)}finally{h.refCleanup=null,h=h.alternate,h!=null&&(h.refCleanup=null)}else if(typeof w=="function")try{w(null)}catch(P){gr(h,g,P)}else w.current=null}function h5(h){var g=h.type,w=h.memoizedProps,M=h.stateNode;try{e:switch(g){case"button":case"input":case"select":case"textarea":w.autoFocus&&M.focus();break e;case"img":w.src?M.src=w.src:w.srcSet&&(M.srcset=w.srcSet)}}catch(P){gr(h,h.return,P)}}function Jk(h,g,w){try{var M=h.stateNode;Zie(M,h.type,w,g),M[bn]=g}catch(P){gr(h,h.return,P)}}function f5(h){return h.tag===5||h.tag===3||h.tag===26||h.tag===27&&gd(h.type)||h.tag===4}function eE(h){e:for(;;){for(;h.sibling===null;){if(h.return===null||f5(h.return))return null;h=h.return}for(h.sibling.return=h.return,h=h.sibling;h.tag!==5&&h.tag!==6&&h.tag!==18;){if(h.tag===27&&gd(h.type)||h.flags&2||h.child===null||h.tag===4)continue e;h.child.return=h,h=h.child}if(!(h.flags&2))return h.stateNode}}function tE(h,g,w){var M=h.tag;if(M===5||M===6)h=h.stateNode,g?(w.nodeType===9?w.body:w.nodeName==="HTML"?w.ownerDocument.body:w).insertBefore(h,g):(g=w.nodeType===9?w.body:w.nodeName==="HTML"?w.ownerDocument.body:w,g.appendChild(h),w=w._reactRootContainer,w!=null||g.onclick!==null||(g.onclick=_i));else if(M!==4&&(M===27&&gd(h.type)&&(w=h.stateNode,g=null),h=h.child,h!==null))for(tE(h,g,w),h=h.sibling;h!==null;)tE(h,g,w),h=h.sibling}function tw(h,g,w){var M=h.tag;if(M===5||M===6)h=h.stateNode,g?w.insertBefore(h,g):w.appendChild(h);else if(M!==4&&(M===27&&gd(h.type)&&(w=h.stateNode),h=h.child,h!==null))for(tw(h,g,w),h=h.sibling;h!==null;)tw(h,g,w),h=h.sibling}function m5(h){var g=h.stateNode,w=h.memoizedProps;try{for(var M=h.type,P=g.attributes;P.length;)g.removeAttributeNode(P[0]);Ea(g,M,w),g[Xn]=h,g[bn]=w}catch(L){gr(h,h.return,L)}}var Uc=!1,Di=!1,nE=!1,p5=typeof WeakSet=="function"?WeakSet:Set,ua=null;function jie(h,g){if(h=h.containerInfo,SE=_w,h=EF(h),X2(h)){if("selectionStart"in h)var w={start:h.selectionStart,end:h.selectionEnd};else e:{w=(w=h.ownerDocument)&&w.defaultView||window;var M=w.getSelection&&w.getSelection();if(M&&M.rangeCount!==0){w=M.anchorNode;var P=M.anchorOffset,L=M.focusNode;M=M.focusOffset;try{w.nodeType,L.nodeType}catch{w=null;break e}var J=0,ve=-1,Ue=-1,it=0,gt=0,vt=h,ct=null;t:for(;;){for(var pt;vt!==w||P!==0&&vt.nodeType!==3||(ve=J+P),vt!==L||M!==0&&vt.nodeType!==3||(Ue=J+M),vt.nodeType===3&&(J+=vt.nodeValue.length),(pt=vt.firstChild)!==null;)ct=vt,vt=pt;for(;;){if(vt===h)break t;if(ct===w&&++it===P&&(ve=J),ct===L&&++gt===M&&(Ue=J),(pt=vt.nextSibling)!==null)break;vt=ct,ct=vt.parentNode}vt=pt}w=ve===-1||Ue===-1?null:{start:ve,end:Ue}}else w=null}w=w||{start:0,end:0}}else w=null;for(ME={focusedElem:h,selectionRange:w},_w=!1,ua=g;ua!==null;)if(g=ua,h=g.child,(g.subtreeFlags&1028)!==0&&h!==null)h.return=g,ua=h;else for(;ua!==null;){switch(g=ua,L=g.alternate,h=g.flags,g.tag){case 0:if((h&4)!==0&&(h=g.updateQueue,h=h!==null?h.events:null,h!==null))for(w=0;w<h.length;w++)P=h[w],P.ref.impl=P.nextImpl;break;case 11:case 15:break;case 1:if((h&1024)!==0&&L!==null){h=void 0,w=g,P=L.memoizedProps,L=L.memoizedState,M=w.stateNode;try{var Vt=rf(w.type,P);h=M.getSnapshotBeforeUpdate(Vt,L),M.__reactInternalSnapshotBeforeUpdate=h}catch(nn){gr(w,w.return,nn)}}break;case 3:if((h&1024)!==0){if(h=g.stateNode.containerInfo,w=h.nodeType,w===9)EE(h);else if(w===1)switch(h.nodeName){case"HEAD":case"HTML":case"BODY":EE(h);break;default:h.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((h&1024)!==0)throw Error(r(163))}if(h=g.sibling,h!==null){h.return=g.return,ua=h;break}ua=g.return}}function g5(h,g,w){var M=w.flags;switch(w.tag){case 0:case 11:case 15:Bc(h,w),M&4&&ub(5,w);break;case 1:if(Bc(h,w),M&4)if(h=w.stateNode,g===null)try{h.componentDidMount()}catch(J){gr(w,w.return,J)}else{var P=rf(w.type,g.memoizedProps);g=g.memoizedState;try{h.componentDidUpdate(P,g,h.__reactInternalSnapshotBeforeUpdate)}catch(J){gr(w,w.return,J)}}M&64&&u5(w),M&512&&db(w,w.return);break;case 3:if(Bc(h,w),M&64&&(h=w.updateQueue,h!==null)){if(g=null,w.child!==null)switch(w.child.tag){case 27:case 5:g=w.child.stateNode;break;case 1:g=w.child.stateNode}try{eI(h,g)}catch(J){gr(w,w.return,J)}}break;case 27:g===null&&M&4&&m5(w);case 26:case 5:Bc(h,w),g===null&&M&4&&h5(w),M&512&&db(w,w.return);break;case 12:Bc(h,w);break;case 31:Bc(h,w),M&4&&y5(h,w);break;case 13:Bc(h,w),M&4&&v5(h,w),M&64&&(h=w.memoizedState,h!==null&&(h=h.dehydrated,h!==null&&(w=zie.bind(null,w),sae(h,w))));break;case 22:if(M=w.memoizedState!==null||Uc,!M){g=g!==null&&g.memoizedState!==null||Di,P=Uc;var L=Di;Uc=M,(Di=g)&&!L?Hc(h,w,(w.subtreeFlags&8772)!==0):Bc(h,w),Uc=P,Di=L}break;case 30:break;default:Bc(h,w)}}function x5(h){var g=h.alternate;g!==null&&(h.alternate=null,x5(g)),h.child=null,h.deletions=null,h.sibling=null,h.tag===5&&(g=h.stateNode,g!==null&&ot(g)),h.stateNode=null,h.return=null,h.dependencies=null,h.memoizedProps=null,h.memoizedState=null,h.pendingProps=null,h.stateNode=null,h.updateQueue=null}var Qr=null,Ns=!1;function zc(h,g,w){for(w=w.child;w!==null;)b5(h,g,w),w=w.sibling}function b5(h,g,w){if(ye&&typeof ye.onCommitFiberUnmount=="function")try{ye.onCommitFiberUnmount($e,w)}catch{}switch(w.tag){case 26:Di||Wl(w,g),zc(h,g,w),w.memoizedState?w.memoizedState.count--:w.stateNode&&(w=w.stateNode,w.parentNode.removeChild(w));break;case 27:Di||Wl(w,g);var M=Qr,P=Ns;gd(w.type)&&(Qr=w.stateNode,Ns=!1),zc(h,g,w),vb(w.stateNode),Qr=M,Ns=P;break;case 5:Di||Wl(w,g);case 6:if(M=Qr,P=Ns,Qr=null,zc(h,g,w),Qr=M,Ns=P,Qr!==null)if(Ns)try{(Qr.nodeType===9?Qr.body:Qr.nodeName==="HTML"?Qr.ownerDocument.body:Qr).removeChild(w.stateNode)}catch(L){gr(w,g,L)}else try{Qr.removeChild(w.stateNode)}catch(L){gr(w,g,L)}break;case 18:Qr!==null&&(Ns?(h=Qr,uU(h.nodeType===9?h.body:h.nodeName==="HTML"?h.ownerDocument.body:h,w.stateNode),fp(h)):uU(Qr,w.stateNode));break;case 4:M=Qr,P=Ns,Qr=w.stateNode.containerInfo,Ns=!0,zc(h,g,w),Qr=M,Ns=P;break;case 0:case 11:case 14:case 15:cd(2,w,g),Di||cd(4,w,g),zc(h,g,w);break;case 1:Di||(Wl(w,g),M=w.stateNode,typeof M.componentWillUnmount=="function"&&d5(w,g,M)),zc(h,g,w);break;case 21:zc(h,g,w);break;case 22:Di=(M=Di)||w.memoizedState!==null,zc(h,g,w),Di=M;break;default:zc(h,g,w)}}function y5(h,g){if(g.memoizedState===null&&(h=g.alternate,h!==null&&(h=h.memoizedState,h!==null))){h=h.dehydrated;try{fp(h)}catch(w){gr(g,g.return,w)}}}function v5(h,g){if(g.memoizedState===null&&(h=g.alternate,h!==null&&(h=h.memoizedState,h!==null&&(h=h.dehydrated,h!==null))))try{fp(h)}catch(w){gr(g,g.return,w)}}function Pie(h){switch(h.tag){case 31:case 13:case 19:var g=h.stateNode;return g===null&&(g=h.stateNode=new p5),g;case 22:return h=h.stateNode,g=h._retryCache,g===null&&(g=h._retryCache=new p5),g;default:throw Error(r(435,h.tag))}}function nw(h,g){var w=Pie(h);g.forEach(function(M){if(!w.has(M)){w.add(M);var P=Bie.bind(null,h,M);M.then(P,P)}})}function ks(h,g){var w=g.deletions;if(w!==null)for(var M=0;M<w.length;M++){var P=w[M],L=h,J=g,ve=J;e:for(;ve!==null;){switch(ve.tag){case 27:if(gd(ve.type)){Qr=ve.stateNode,Ns=!1;break e}break;case 5:Qr=ve.stateNode,Ns=!1;break e;case 3:case 4:Qr=ve.stateNode.containerInfo,Ns=!0;break e}ve=ve.return}if(Qr===null)throw Error(r(160));b5(L,J,P),Qr=null,Ns=!1,L=P.alternate,L!==null&&(L.return=null),P.return=null}if(g.subtreeFlags&13886)for(g=g.child;g!==null;)w5(g,h),g=g.sibling}var bl=null;function w5(h,g){var w=h.alternate,M=h.flags;switch(h.tag){case 0:case 11:case 14:case 15:ks(g,h),Es(h),M&4&&(cd(3,h,h.return),ub(3,h),cd(5,h,h.return));break;case 1:ks(g,h),Es(h),M&512&&(Di||w===null||Wl(w,w.return)),M&64&&Uc&&(h=h.updateQueue,h!==null&&(M=h.callbacks,M!==null&&(w=h.shared.hiddenCallbacks,h.shared.hiddenCallbacks=w===null?M:w.concat(M))));break;case 26:var P=bl;if(ks(g,h),Es(h),M&512&&(Di||w===null||Wl(w,w.return)),M&4){var L=w!==null?w.memoizedState:null;if(M=h.memoizedState,w===null)if(M===null)if(h.stateNode===null){e:{M=h.type,w=h.memoizedProps,P=P.ownerDocument||P;t:switch(M){case"title":L=P.getElementsByTagName("title")[0],(!L||L[lt]||L[Xn]||L.namespaceURI==="http://www.w3.org/2000/svg"||L.hasAttribute("itemprop"))&&(L=P.createElement(M),P.head.insertBefore(L,P.querySelector("head > title"))),Ea(L,M,w),L[Xn]=h,Le(L),M=L;break e;case"link":var J=wU("link","href",P).get(M+(w.href||""));if(J){for(var ve=0;ve<J.length;ve++)if(L=J[ve],L.getAttribute("href")===(w.href==null||w.href===""?null:w.href)&&L.getAttribute("rel")===(w.rel==null?null:w.rel)&&L.getAttribute("title")===(w.title==null?null:w.title)&&L.getAttribute("crossorigin")===(w.crossOrigin==null?null:w.crossOrigin)){J.splice(ve,1);break t}}L=P.createElement(M),Ea(L,M,w),P.head.appendChild(L);break;case"meta":if(J=wU("meta","content",P).get(M+(w.content||""))){for(ve=0;ve<J.length;ve++)if(L=J[ve],L.getAttribute("content")===(w.content==null?null:""+w.content)&&L.getAttribute("name")===(w.name==null?null:w.name)&&L.getAttribute("property")===(w.property==null?null:w.property)&&L.getAttribute("http-equiv")===(w.httpEquiv==null?null:w.httpEquiv)&&L.getAttribute("charset")===(w.charSet==null?null:w.charSet)){J.splice(ve,1);break t}}L=P.createElement(M),Ea(L,M,w),P.head.appendChild(L);break;default:throw Error(r(468,M))}L[Xn]=h,Le(L),M=L}h.stateNode=M}else _U(P,h.type,h.stateNode);else h.stateNode=vU(P,M,h.memoizedProps);else L!==M?(L===null?w.stateNode!==null&&(w=w.stateNode,w.parentNode.removeChild(w)):L.count--,M===null?_U(P,h.type,h.stateNode):vU(P,M,h.memoizedProps)):M===null&&h.stateNode!==null&&Jk(h,h.memoizedProps,w.memoizedProps)}break;case 27:ks(g,h),Es(h),M&512&&(Di||w===null||Wl(w,w.return)),w!==null&&M&4&&Jk(h,h.memoizedProps,w.memoizedProps);break;case 5:if(ks(g,h),Es(h),M&512&&(Di||w===null||Wl(w,w.return)),h.flags&32){P=h.stateNode;try{yt(P,"")}catch(Vt){gr(h,h.return,Vt)}}M&4&&h.stateNode!=null&&(P=h.memoizedProps,Jk(h,P,w!==null?w.memoizedProps:P)),M&1024&&(nE=!0);break;case 6:if(ks(g,h),Es(h),M&4){if(h.stateNode===null)throw Error(r(162));M=h.memoizedProps,w=h.stateNode;try{w.nodeValue=M}catch(Vt){gr(h,h.return,Vt)}}break;case 3:if(bw=null,P=bl,bl=gw(g.containerInfo),ks(g,h),bl=P,Es(h),M&4&&w!==null&&w.memoizedState.isDehydrated)try{fp(g.containerInfo)}catch(Vt){gr(h,h.return,Vt)}nE&&(nE=!1,_5(h));break;case 4:M=bl,bl=gw(h.stateNode.containerInfo),ks(g,h),Es(h),bl=M;break;case 12:ks(g,h),Es(h);break;case 31:ks(g,h),Es(h),M&4&&(M=h.updateQueue,M!==null&&(h.updateQueue=null,nw(h,M)));break;case 13:ks(g,h),Es(h),h.child.flags&8192&&h.memoizedState!==null!=(w!==null&&w.memoizedState!==null)&&(iw=O()),M&4&&(M=h.updateQueue,M!==null&&(h.updateQueue=null,nw(h,M)));break;case 22:P=h.memoizedState!==null;var Ue=w!==null&&w.memoizedState!==null,it=Uc,gt=Di;if(Uc=it||P,Di=gt||Ue,ks(g,h),Di=gt,Uc=it,Es(h),M&8192)e:for(g=h.stateNode,g._visibility=P?g._visibility&-2:g._visibility|1,P&&(w===null||Ue||Uc||Di||af(h)),w=null,g=h;;){if(g.tag===5||g.tag===26){if(w===null){Ue=w=g;try{if(L=Ue.stateNode,P)J=L.style,typeof J.setProperty=="function"?J.setProperty("display","none","important"):J.display="none";else{ve=Ue.stateNode;var vt=Ue.memoizedProps.style,ct=vt!=null&&vt.hasOwnProperty("display")?vt.display:null;ve.style.display=ct==null||typeof ct=="boolean"?"":(""+ct).trim()}}catch(Vt){gr(Ue,Ue.return,Vt)}}}else if(g.tag===6){if(w===null){Ue=g;try{Ue.stateNode.nodeValue=P?"":Ue.memoizedProps}catch(Vt){gr(Ue,Ue.return,Vt)}}}else if(g.tag===18){if(w===null){Ue=g;try{var pt=Ue.stateNode;P?dU(pt,!0):dU(Ue.stateNode,!1)}catch(Vt){gr(Ue,Ue.return,Vt)}}}else if((g.tag!==22&&g.tag!==23||g.memoizedState===null||g===h)&&g.child!==null){g.child.return=g,g=g.child;continue}if(g===h)break e;for(;g.sibling===null;){if(g.return===null||g.return===h)break e;w===g&&(w=null),g=g.return}w===g&&(w=null),g.sibling.return=g.return,g=g.sibling}M&4&&(M=h.updateQueue,M!==null&&(w=M.retryQueue,w!==null&&(M.retryQueue=null,nw(h,w))));break;case 19:ks(g,h),Es(h),M&4&&(M=h.updateQueue,M!==null&&(h.updateQueue=null,nw(h,M)));break;case 30:break;case 21:break;default:ks(g,h),Es(h)}}function Es(h){var g=h.flags;if(g&2){try{for(var w,M=h.return;M!==null;){if(f5(M)){w=M;break}M=M.return}if(w==null)throw Error(r(160));switch(w.tag){case 27:var P=w.stateNode,L=eE(h);tw(h,L,P);break;case 5:var J=w.stateNode;w.flags&32&&(yt(J,""),w.flags&=-33);var ve=eE(h);tw(h,ve,J);break;case 3:case 4:var Ue=w.stateNode.containerInfo,it=eE(h);tE(h,it,Ue);break;default:throw Error(r(161))}}catch(gt){gr(h,h.return,gt)}h.flags&=-3}g&4096&&(h.flags&=-4097)}function _5(h){if(h.subtreeFlags&1024)for(h=h.child;h!==null;){var g=h;_5(g),g.tag===5&&g.flags&1024&&g.stateNode.reset(),h=h.sibling}}function Bc(h,g){if(g.subtreeFlags&8772)for(g=g.child;g!==null;)g5(h,g.alternate,g),g=g.sibling}function af(h){for(h=h.child;h!==null;){var g=h;switch(g.tag){case 0:case 11:case 14:case 15:cd(4,g,g.return),af(g);break;case 1:Wl(g,g.return);var w=g.stateNode;typeof w.componentWillUnmount=="function"&&d5(g,g.return,w),af(g);break;case 27:vb(g.stateNode);case 26:case 5:Wl(g,g.return),af(g);break;case 22:g.memoizedState===null&&af(g);break;case 30:af(g);break;default:af(g)}h=h.sibling}}function Hc(h,g,w){for(w=w&&(g.subtreeFlags&8772)!==0,g=g.child;g!==null;){var M=g.alternate,P=h,L=g,J=L.flags;switch(L.tag){case 0:case 11:case 15:Hc(P,L,w),ub(4,L);break;case 1:if(Hc(P,L,w),M=L,P=M.stateNode,typeof P.componentDidMount=="function")try{P.componentDidMount()}catch(it){gr(M,M.return,it)}if(M=L,P=M.updateQueue,P!==null){var ve=M.stateNode;try{var Ue=P.shared.hiddenCallbacks;if(Ue!==null)for(P.shared.hiddenCallbacks=null,P=0;P<Ue.length;P++)JF(Ue[P],ve)}catch(it){gr(M,M.return,it)}}w&&J&64&&u5(L),db(L,L.return);break;case 27:m5(L);case 26:case 5:Hc(P,L,w),w&&M===null&&J&4&&h5(L),db(L,L.return);break;case 12:Hc(P,L,w);break;case 31:Hc(P,L,w),w&&J&4&&y5(P,L);break;case 13:Hc(P,L,w),w&&J&4&&v5(P,L);break;case 22:L.memoizedState===null&&Hc(P,L,w),db(L,L.return);break;case 30:break;default:Hc(P,L,w)}g=g.sibling}}function rE(h,g){var w=null;h!==null&&h.memoizedState!==null&&h.memoizedState.cachePool!==null&&(w=h.memoizedState.cachePool.pool),h=null,g.memoizedState!==null&&g.memoizedState.cachePool!==null&&(h=g.memoizedState.cachePool.pool),h!==w&&(h!=null&&h.refCount++,w!=null&&Qx(w))}function iE(h,g){h=null,g.alternate!==null&&(h=g.alternate.memoizedState.cache),g=g.memoizedState.cache,g!==h&&(g.refCount++,h!=null&&Qx(h))}function yl(h,g,w,M){if(g.subtreeFlags&10256)for(g=g.child;g!==null;)S5(h,g,w,M),g=g.sibling}function S5(h,g,w,M){var P=g.flags;switch(g.tag){case 0:case 11:case 15:yl(h,g,w,M),P&2048&&ub(9,g);break;case 1:yl(h,g,w,M);break;case 3:yl(h,g,w,M),P&2048&&(h=null,g.alternate!==null&&(h=g.alternate.memoizedState.cache),g=g.memoizedState.cache,g!==h&&(g.refCount++,h!=null&&Qx(h)));break;case 12:if(P&2048){yl(h,g,w,M),h=g.stateNode;try{var L=g.memoizedProps,J=L.id,ve=L.onPostCommit;typeof ve=="function"&&ve(J,g.alternate===null?"mount":"update",h.passiveEffectDuration,-0)}catch(Ue){gr(g,g.return,Ue)}}else yl(h,g,w,M);break;case 31:yl(h,g,w,M);break;case 13:yl(h,g,w,M);break;case 23:break;case 22:L=g.stateNode,J=g.alternate,g.memoizedState!==null?L._visibility&2?yl(h,g,w,M):hb(h,g):L._visibility&2?yl(h,g,w,M):(L._visibility|=2,np(h,g,w,M,(g.subtreeFlags&10256)!==0||!1)),P&2048&&rE(J,g);break;case 24:yl(h,g,w,M),P&2048&&iE(g.alternate,g);break;default:yl(h,g,w,M)}}function np(h,g,w,M,P){for(P=P&&((g.subtreeFlags&10256)!==0||!1),g=g.child;g!==null;){var L=h,J=g,ve=w,Ue=M,it=J.flags;switch(J.tag){case 0:case 11:case 15:np(L,J,ve,Ue,P),ub(8,J);break;case 23:break;case 22:var gt=J.stateNode;J.memoizedState!==null?gt._visibility&2?np(L,J,ve,Ue,P):hb(L,J):(gt._visibility|=2,np(L,J,ve,Ue,P)),P&&it&2048&&rE(J.alternate,J);break;case 24:np(L,J,ve,Ue,P),P&&it&2048&&iE(J.alternate,J);break;default:np(L,J,ve,Ue,P)}g=g.sibling}}function hb(h,g){if(g.subtreeFlags&10256)for(g=g.child;g!==null;){var w=h,M=g,P=M.flags;switch(M.tag){case 22:hb(w,M),P&2048&&rE(M.alternate,M);break;case 24:hb(w,M),P&2048&&iE(M.alternate,M);break;default:hb(w,M)}g=g.sibling}}var fb=8192;function rp(h,g,w){if(h.subtreeFlags&fb)for(h=h.child;h!==null;)M5(h,g,w),h=h.sibling}function M5(h,g,w){switch(h.tag){case 26:rp(h,g,w),h.flags&fb&&h.memoizedState!==null&&bae(w,bl,h.memoizedState,h.memoizedProps);break;case 5:rp(h,g,w);break;case 3:case 4:var M=bl;bl=gw(h.stateNode.containerInfo),rp(h,g,w),bl=M;break;case 22:h.memoizedState===null&&(M=h.alternate,M!==null&&M.memoizedState!==null?(M=fb,fb=16777216,rp(h,g,w),fb=M):rp(h,g,w));break;default:rp(h,g,w)}}function N5(h){var g=h.alternate;if(g!==null&&(h=g.child,h!==null)){g.child=null;do g=h.sibling,h.sibling=null,h=g;while(h!==null)}}function mb(h){var g=h.deletions;if((h.flags&16)!==0){if(g!==null)for(var w=0;w<g.length;w++){var M=g[w];ua=M,E5(M,h)}N5(h)}if(h.subtreeFlags&10256)for(h=h.child;h!==null;)k5(h),h=h.sibling}function k5(h){switch(h.tag){case 0:case 11:case 15:mb(h),h.flags&2048&&cd(9,h,h.return);break;case 3:mb(h);break;case 12:mb(h);break;case 22:var g=h.stateNode;h.memoizedState!==null&&g._visibility&2&&(h.return===null||h.return.tag!==13)?(g._visibility&=-3,rw(h)):mb(h);break;default:mb(h)}}function rw(h){var g=h.deletions;if((h.flags&16)!==0){if(g!==null)for(var w=0;w<g.length;w++){var M=g[w];ua=M,E5(M,h)}N5(h)}for(h=h.child;h!==null;){switch(g=h,g.tag){case 0:case 11:case 15:cd(8,g,g.return),rw(g);break;case 22:w=g.stateNode,w._visibility&2&&(w._visibility&=-3,rw(g));break;default:rw(g)}h=h.sibling}}function E5(h,g){for(;ua!==null;){var w=ua;switch(w.tag){case 0:case 11:case 15:cd(8,w,g);break;case 23:case 22:if(w.memoizedState!==null&&w.memoizedState.cachePool!==null){var M=w.memoizedState.cachePool.pool;M!=null&&M.refCount++}break;case 24:Qx(w.memoizedState.cache)}if(M=w.child,M!==null)M.return=w,ua=M;else e:for(w=h;ua!==null;){M=ua;var P=M.sibling,L=M.return;if(x5(M),M===w){ua=null;break e}if(P!==null){P.return=L,ua=P;break e}ua=L}}}var Die={getCacheForType:function(h){var g=Na(Ci),w=g.data.get(h);return w===void 0&&(w=h(),g.data.set(h,w)),w},cacheSignal:function(){return Na(Ci).controller.signal}},Rie=typeof WeakMap=="function"?WeakMap:Map,ur=0,Pr=null,In=null,Gn=0,pr=0,Js=null,ud=!1,ip=!1,aE=!1,$c=0,hi=0,dd=0,sf=0,sE=0,eo=0,ap=0,pb=null,Ts=null,oE=!1,iw=0,T5=0,aw=1/0,sw=null,hd=null,qi=0,fd=null,sp=null,Vc=0,lE=0,cE=null,A5=null,gb=0,uE=null;function to(){return(ur&2)!==0&&Gn!==0?Gn&-Gn:K.T!==null?gE():ln()}function C5(){if(eo===0)if((Gn&536870912)===0||Yn){var h=ke;ke<<=1,(ke&3932160)===0&&(ke=262144),eo=h}else eo=536870912;return h=Qs.current,h!==null&&(h.flags|=32),eo}function As(h,g,w){(h===Pr&&(pr===2||pr===9)||h.cancelPendingCommit!==null)&&(op(h,0),md(h,Gn,eo,!1)),Bt(h,w),((ur&2)===0||h!==Pr)&&(h===Pr&&((ur&2)===0&&(sf|=w),hi===4&&md(h,Gn,eo,!1)),Kl(h))}function j5(h,g,w){if((ur&6)!==0)throw Error(r(327));var M=!w&&(g&127)===0&&(g&h.expiredLanes)===0||De(h,g),P=M?Fie(h,g):hE(h,g,!0),L=M;do{if(P===0){ip&&!M&&md(h,g,0,!1);break}else{if(w=h.current.alternate,L&&!Oie(w)){P=hE(h,g,!1),L=!1;continue}if(P===2){if(L=g,h.errorRecoveryDisabledLanes&L)var J=0;else J=h.pendingLanes&-536870913,J=J!==0?J:J&536870912?536870912:0;if(J!==0){g=J;e:{var ve=h;P=pb;var Ue=ve.current.memoizedState.isDehydrated;if(Ue&&(op(ve,J).flags|=256),J=hE(ve,J,!1),J!==2){if(aE&&!Ue){ve.errorRecoveryDisabledLanes|=L,sf|=L,P=4;break e}L=Ts,Ts=P,L!==null&&(Ts===null?Ts=L:Ts.push.apply(Ts,L))}P=J}if(L=!1,P!==2)continue}}if(P===1){op(h,0),md(h,g,0,!0);break}e:{switch(M=h,L=P,L){case 0:case 1:throw Error(r(345));case 4:if((g&4194048)!==g)break;case 6:md(M,g,eo,!ud);break e;case 2:Ts=null;break;case 3:case 5:break;default:throw Error(r(329))}if((g&62914560)===g&&(P=iw+300-O(),10<P)){if(md(M,g,eo,!ud),W(M,0,!0)!==0)break e;Vc=g,M.timeoutHandle=lU(P5.bind(null,M,w,Ts,sw,oE,g,eo,sf,ap,ud,L,"Throttled",-0,0),P);break e}P5(M,w,Ts,sw,oE,g,eo,sf,ap,ud,L,null,-0,0)}}break}while(!0);Kl(h)}function P5(h,g,w,M,P,L,J,ve,Ue,it,gt,vt,ct,pt){if(h.timeoutHandle=-1,vt=g.subtreeFlags,vt&8192||(vt&16785408)===16785408){vt={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:_i},M5(g,L,vt);var Vt=(L&62914560)===L?iw-O():(L&4194048)===L?T5-O():0;if(Vt=yae(vt,Vt),Vt!==null){Vc=L,h.cancelPendingCommit=Vt(z5.bind(null,h,g,L,w,M,P,J,ve,Ue,gt,vt,null,ct,pt)),md(h,L,J,!it);return}}z5(h,g,L,w,M,P,J,ve,Ue)}function Oie(h){for(var g=h;;){var w=g.tag;if((w===0||w===11||w===15)&&g.flags&16384&&(w=g.updateQueue,w!==null&&(w=w.stores,w!==null)))for(var M=0;M<w.length;M++){var P=w[M],L=P.getSnapshot;P=P.value;try{if(!Xs(L(),P))return!1}catch{return!1}}if(w=g.child,g.subtreeFlags&16384&&w!==null)w.return=g,g=w;else{if(g===h)break;for(;g.sibling===null;){if(g.return===null||g.return===h)return!0;g=g.return}g.sibling.return=g.return,g=g.sibling}}return!0}function md(h,g,w,M){g&=~sE,g&=~sf,h.suspendedLanes|=g,h.pingedLanes&=~g,M&&(h.warmLanes|=g),M=h.expirationTimes;for(var P=g;0<P;){var L=31-Be(P),J=1<<L;M[L]=-1,P&=~J}w!==0&&vn(h,w,g)}function ow(){return(ur&6)===0?(xb(0),!1):!0}function dE(){if(In!==null){if(pr===0)var h=In.return;else h=In,Dc=Yh=null,Ek(h),Qm=null,Jx=0,h=In;for(;h!==null;)c5(h.alternate,h),h=h.return;In=null}}function op(h,g){var w=h.timeoutHandle;w!==-1&&(h.timeoutHandle=-1,tae(w)),w=h.cancelPendingCommit,w!==null&&(h.cancelPendingCommit=null,w()),Vc=0,dE(),Pr=h,In=w=jc(h.current,null),Gn=g,pr=0,Js=null,ud=!1,ip=De(h,g),aE=!1,ap=eo=sE=sf=dd=hi=0,Ts=pb=null,oE=!1,(g&8)!==0&&(g|=g&32);var M=h.entangledLanes;if(M!==0)for(h=h.entanglements,M&=g;0<M;){var P=31-Be(M),L=1<<P;g|=h[P],M&=~L}return $c=g,Tv(),w}function D5(h,g){_n=null,K.H=ob,g===Ym||g===Lv?(g=XF(),pr=3):g===pk?(g=XF(),pr=4):pr=g===$k?8:g!==null&&typeof g=="object"&&typeof g.then=="function"?6:1,Js=g,In===null&&(hi=1,Yv(h,Eo(g,h.current)))}function R5(){var h=Qs.current;return h===null?!0:(Gn&4194048)===Gn?jo===null:(Gn&62914560)===Gn||(Gn&536870912)!==0?h===jo:!1}function O5(){var h=K.H;return K.H=ob,h===null?ob:h}function L5(){var h=K.A;return K.A=Die,h}function lw(){hi=4,ud||(Gn&4194048)!==Gn&&Qs.current!==null||(ip=!0),(dd&134217727)===0&&(sf&134217727)===0||Pr===null||md(Pr,Gn,eo,!1)}function hE(h,g,w){var M=ur;ur|=2;var P=O5(),L=L5();(Pr!==h||Gn!==g)&&(sw=null,op(h,g)),g=!1;var J=hi;e:do try{if(pr!==0&&In!==null){var ve=In,Ue=Js;switch(pr){case 8:dE(),J=6;break e;case 3:case 2:case 9:case 6:Qs.current===null&&(g=!0);var it=pr;if(pr=0,Js=null,lp(h,ve,Ue,it),w&&ip){J=0;break e}break;default:it=pr,pr=0,Js=null,lp(h,ve,Ue,it)}}Lie(),J=hi;break}catch(gt){D5(h,gt)}while(!0);return g&&h.shellSuspendCounter++,Dc=Yh=null,ur=M,K.H=P,K.A=L,In===null&&(Pr=null,Gn=0,Tv()),J}function Lie(){for(;In!==null;)F5(In)}function Fie(h,g){var w=ur;ur|=2;var M=O5(),P=L5();Pr!==h||Gn!==g?(sw=null,aw=O()+500,op(h,g)):ip=De(h,g);e:do try{if(pr!==0&&In!==null){g=In;var L=Js;t:switch(pr){case 1:pr=0,Js=null,lp(h,g,L,1);break;case 2:case 9:if(WF(L)){pr=0,Js=null,I5(g);break}g=function(){pr!==2&&pr!==9||Pr!==h||(pr=7),Kl(h)},L.then(g,g);break e;case 3:pr=7;break e;case 4:pr=5;break e;case 7:WF(L)?(pr=0,Js=null,I5(g)):(pr=0,Js=null,lp(h,g,L,7));break;case 5:var J=null;switch(In.tag){case 26:J=In.memoizedState;case 5:case 27:var ve=In;if(J?SU(J):ve.stateNode.complete){pr=0,Js=null;var Ue=ve.sibling;if(Ue!==null)In=Ue;else{var it=ve.return;it!==null?(In=it,cw(it)):In=null}break t}}pr=0,Js=null,lp(h,g,L,5);break;case 6:pr=0,Js=null,lp(h,g,L,6);break;case 8:dE(),hi=6;break e;default:throw Error(r(462))}}Iie();break}catch(gt){D5(h,gt)}while(!0);return Dc=Yh=null,K.H=M,K.A=P,ur=w,In!==null?0:(Pr=null,Gn=0,Tv(),hi)}function Iie(){for(;In!==null&&!Ee();)F5(In)}function F5(h){var g=o5(h.alternate,h,$c);h.memoizedProps=h.pendingProps,g===null?cw(h):In=g}function I5(h){var g=h,w=g.alternate;switch(g.tag){case 15:case 0:g=t5(w,g,g.pendingProps,g.type,void 0,Gn);break;case 11:g=t5(w,g,g.pendingProps,g.type.render,g.ref,Gn);break;case 5:Ek(g);default:c5(w,g),g=In=LF(g,$c),g=o5(w,g,$c)}h.memoizedProps=h.pendingProps,g===null?cw(h):In=g}function lp(h,g,w,M){Dc=Yh=null,Ek(g),Qm=null,Jx=0;var P=g.return;try{if(kie(h,P,g,w,Gn)){hi=1,Yv(h,Eo(w,h.current)),In=null;return}}catch(L){if(P!==null)throw In=P,L;hi=1,Yv(h,Eo(w,h.current)),In=null;return}g.flags&32768?(Yn||M===1?h=!0:ip||(Gn&536870912)!==0?h=!1:(ud=h=!0,(M===2||M===9||M===3||M===6)&&(M=Qs.current,M!==null&&M.tag===13&&(M.flags|=16384))),U5(g,h)):cw(g)}function cw(h){var g=h;do{if((g.flags&32768)!==0){U5(g,ud);return}h=g.return;var w=Aie(g.alternate,g,$c);if(w!==null){In=w;return}if(g=g.sibling,g!==null){In=g;return}In=g=h}while(g!==null);hi===0&&(hi=5)}function U5(h,g){do{var w=Cie(h.alternate,h);if(w!==null){w.flags&=32767,In=w;return}if(w=h.return,w!==null&&(w.flags|=32768,w.subtreeFlags=0,w.deletions=null),!g&&(h=h.sibling,h!==null)){In=h;return}In=h=w}while(h!==null);hi=6,In=null}function z5(h,g,w,M,P,L,J,ve,Ue){h.cancelPendingCommit=null;do uw();while(qi!==0);if((ur&6)!==0)throw Error(r(327));if(g!==null){if(g===h.current)throw Error(r(177));if(L=g.lanes|g.childLanes,L|=ek,Lt(h,w,L,J,ve,Ue),h===Pr&&(In=Pr=null,Gn=0),sp=g,fd=h,Vc=w,lE=L,cE=P,A5=M,(g.subtreeFlags&10256)!==0||(g.flags&10256)!==0?(h.callbackNode=null,h.callbackPriority=0,Hie(we,function(){return G5(),null})):(h.callbackNode=null,h.callbackPriority=0),M=(g.flags&13878)!==0,(g.subtreeFlags&13878)!==0||M){M=K.T,K.T=null,P=V.p,V.p=2,J=ur,ur|=4;try{jie(h,g,w)}finally{ur=J,V.p=P,K.T=M}}qi=1,B5(),H5(),$5()}}function B5(){if(qi===1){qi=0;var h=fd,g=sp,w=(g.flags&13878)!==0;if((g.subtreeFlags&13878)!==0||w){w=K.T,K.T=null;var M=V.p;V.p=2;var P=ur;ur|=4;try{w5(g,h);var L=ME,J=EF(h.containerInfo),ve=L.focusedElem,Ue=L.selectionRange;if(J!==ve&&ve&&ve.ownerDocument&&kF(ve.ownerDocument.documentElement,ve)){if(Ue!==null&&X2(ve)){var it=Ue.start,gt=Ue.end;if(gt===void 0&&(gt=it),"selectionStart"in ve)ve.selectionStart=it,ve.selectionEnd=Math.min(gt,ve.value.length);else{var vt=ve.ownerDocument||document,ct=vt&&vt.defaultView||window;if(ct.getSelection){var pt=ct.getSelection(),Vt=ve.textContent.length,nn=Math.min(Ue.start,Vt),Sr=Ue.end===void 0?nn:Math.min(Ue.end,Vt);!pt.extend&&nn>Sr&&(J=Sr,Sr=nn,nn=J);var Je=NF(ve,nn),Ge=NF(ve,Sr);if(Je&&Ge&&(pt.rangeCount!==1||pt.anchorNode!==Je.node||pt.anchorOffset!==Je.offset||pt.focusNode!==Ge.node||pt.focusOffset!==Ge.offset)){var rt=vt.createRange();rt.setStart(Je.node,Je.offset),pt.removeAllRanges(),nn>Sr?(pt.addRange(rt),pt.extend(Ge.node,Ge.offset)):(rt.setEnd(Ge.node,Ge.offset),pt.addRange(rt))}}}}for(vt=[],pt=ve;pt=pt.parentNode;)pt.nodeType===1&&vt.push({element:pt,left:pt.scrollLeft,top:pt.scrollTop});for(typeof ve.focus=="function"&&ve.focus(),ve=0;ve<vt.length;ve++){var bt=vt[ve];bt.element.scrollLeft=bt.left,bt.element.scrollTop=bt.top}}_w=!!SE,ME=SE=null}finally{ur=P,V.p=M,K.T=w}}h.current=g,qi=2}}function H5(){if(qi===2){qi=0;var h=fd,g=sp,w=(g.flags&8772)!==0;if((g.subtreeFlags&8772)!==0||w){w=K.T,K.T=null;var M=V.p;V.p=2;var P=ur;ur|=4;try{g5(h,g.alternate,g)}finally{ur=P,V.p=M,K.T=w}}qi=3}}function $5(){if(qi===4||qi===3){qi=0,z();var h=fd,g=sp,w=Vc,M=A5;(g.subtreeFlags&10256)!==0||(g.flags&10256)!==0?qi=5:(qi=0,sp=fd=null,V5(h,h.pendingLanes));var P=h.pendingLanes;if(P===0&&(hd=null),Dn(w),g=g.stateNode,ye&&typeof ye.onCommitFiberRoot=="function")try{ye.onCommitFiberRoot($e,g,void 0,(g.current.flags&128)===128)}catch{}if(M!==null){g=K.T,P=V.p,V.p=2,K.T=null;try{for(var L=h.onRecoverableError,J=0;J<M.length;J++){var ve=M[J];L(ve.value,{componentStack:ve.stack})}}finally{K.T=g,V.p=P}}(Vc&3)!==0&&uw(),Kl(h),P=h.pendingLanes,(w&261930)!==0&&(P&42)!==0?h===uE?gb++:(gb=0,uE=h):gb=0,xb(0)}}function V5(h,g){(h.pooledCacheLanes&=g)===0&&(g=h.pooledCache,g!=null&&(h.pooledCache=null,Qx(g)))}function uw(){return B5(),H5(),$5(),G5()}function G5(){if(qi!==5)return!1;var h=fd,g=lE;lE=0;var w=Dn(Vc),M=K.T,P=V.p;try{V.p=32>w?32:w,K.T=null,w=cE,cE=null;var L=fd,J=Vc;if(qi=0,sp=fd=null,Vc=0,(ur&6)!==0)throw Error(r(331));var ve=ur;if(ur|=4,k5(L.current),S5(L,L.current,J,w),ur=ve,xb(0,!1),ye&&typeof ye.onPostCommitFiberRoot=="function")try{ye.onPostCommitFiberRoot($e,L)}catch{}return!0}finally{V.p=P,K.T=M,V5(h,g)}}function q5(h,g,w){g=Eo(w,g),g=Hk(h.stateNode,g,2),h=sd(h,g,2),h!==null&&(Bt(h,2),Kl(h))}function gr(h,g,w){if(h.tag===3)q5(h,h,w);else for(;g!==null;){if(g.tag===3){q5(g,h,w);break}else if(g.tag===1){var M=g.stateNode;if(typeof g.type.getDerivedStateFromError=="function"||typeof M.componentDidCatch=="function"&&(hd===null||!hd.has(M))){h=Eo(w,h),w=WI(2),M=sd(g,w,2),M!==null&&(KI(w,M,g,h),Bt(M,2),Kl(M));break}}g=g.return}}function fE(h,g,w){var M=h.pingCache;if(M===null){M=h.pingCache=new Rie;var P=new Set;M.set(g,P)}else P=M.get(g),P===void 0&&(P=new Set,M.set(g,P));P.has(w)||(aE=!0,P.add(w),h=Uie.bind(null,h,g,w),g.then(h,h))}function Uie(h,g,w){var M=h.pingCache;M!==null&&M.delete(g),h.pingedLanes|=h.suspendedLanes&w,h.warmLanes&=~w,Pr===h&&(Gn&w)===w&&(hi===4||hi===3&&(Gn&62914560)===Gn&&300>O()-iw?(ur&2)===0&&op(h,0):sE|=w,ap===Gn&&(ap=0)),Kl(h)}function W5(h,g){g===0&&(g=xt()),h=Wh(h,g),h!==null&&(Bt(h,g),Kl(h))}function zie(h){var g=h.memoizedState,w=0;g!==null&&(w=g.retryLane),W5(h,w)}function Bie(h,g){var w=0;switch(h.tag){case 31:case 13:var M=h.stateNode,P=h.memoizedState;P!==null&&(w=P.retryLane);break;case 19:M=h.stateNode;break;case 22:M=h.stateNode._retryCache;break;default:throw Error(r(314))}M!==null&&M.delete(g),W5(h,w)}function Hie(h,g){return fe(h,g)}var dw=null,cp=null,mE=!1,hw=!1,pE=!1,pd=0;function Kl(h){h!==cp&&h.next===null&&(cp===null?dw=cp=h:cp=cp.next=h),hw=!0,mE||(mE=!0,Vie())}function xb(h,g){if(!pE&&hw){pE=!0;do for(var w=!1,M=dw;M!==null;){if(h!==0){var P=M.pendingLanes;if(P===0)var L=0;else{var J=M.suspendedLanes,ve=M.pingedLanes;L=(1<<31-Be(42|h)+1)-1,L&=P&~(J&~ve),L=L&201326741?L&201326741|1:L?L|2:0}L!==0&&(w=!0,Q5(M,L))}else L=Gn,L=W(M,M===Pr?L:0,M.cancelPendingCommit!==null||M.timeoutHandle!==-1),(L&3)===0||De(M,L)||(w=!0,Q5(M,L));M=M.next}while(w);pE=!1}}function $ie(){K5()}function K5(){hw=mE=!1;var h=0;pd!==0&&eae()&&(h=pd);for(var g=O(),w=null,M=dw;M!==null;){var P=M.next,L=X5(M,g);L===0?(M.next=null,w===null?dw=P:w.next=P,P===null&&(cp=w)):(w=M,(h!==0||(L&3)!==0)&&(hw=!0)),M=P}qi!==0&&qi!==5||xb(h),pd!==0&&(pd=0)}function X5(h,g){for(var w=h.suspendedLanes,M=h.pingedLanes,P=h.expirationTimes,L=h.pendingLanes&-62914561;0<L;){var J=31-Be(L),ve=1<<J,Ue=P[J];Ue===-1?((ve&w)===0||(ve&M)!==0)&&(P[J]=Ye(ve,g)):Ue<=g&&(h.expiredLanes|=ve),L&=~ve}if(g=Pr,w=Gn,w=W(h,h===g?w:0,h.cancelPendingCommit!==null||h.timeoutHandle!==-1),M=h.callbackNode,w===0||h===g&&(pr===2||pr===9)||h.cancelPendingCommit!==null)return M!==null&&M!==null&&me(M),h.callbackNode=null,h.callbackPriority=0;if((w&3)===0||De(h,w)){if(g=w&-w,g===h.callbackPriority)return g;switch(M!==null&&me(M),Dn(w)){case 2:case 8:w=_e;break;case 32:w=we;break;case 268435456:w=Fe;break;default:w=we}return M=Y5.bind(null,h),w=fe(w,M),h.callbackPriority=g,h.callbackNode=w,g}return M!==null&&M!==null&&me(M),h.callbackPriority=2,h.callbackNode=null,2}function Y5(h,g){if(qi!==0&&qi!==5)return h.callbackNode=null,h.callbackPriority=0,null;var w=h.callbackNode;if(uw()&&h.callbackNode!==w)return null;var M=Gn;return M=W(h,h===Pr?M:0,h.cancelPendingCommit!==null||h.timeoutHandle!==-1),M===0?null:(j5(h,M,g),X5(h,O()),h.callbackNode!=null&&h.callbackNode===w?Y5.bind(null,h):null)}function Q5(h,g){if(uw())return null;j5(h,g,!0)}function Vie(){nae(function(){(ur&6)!==0?fe(le,$ie):K5()})}function gE(){if(pd===0){var h=Km;h===0&&(h=tt,tt<<=1,(tt&261888)===0&&(tt=256)),pd=h}return pd}function Z5(h){return h==null||typeof h=="symbol"||typeof h=="boolean"?null:typeof h=="function"?h:on(""+h)}function J5(h,g){var w=g.ownerDocument.createElement("input");return w.name=g.name,w.value=g.value,h.id&&w.setAttribute("form",h.id),g.parentNode.insertBefore(w,g),h=new FormData(h),w.parentNode.removeChild(w),h}function Gie(h,g,w,M,P){if(g==="submit"&&w&&w.stateNode===P){var L=Z5((P[bn]||null).action),J=M.submitter;J&&(g=(g=J[bn]||null)?Z5(g.formAction):J.getAttribute("formAction"),g!==null&&(L=g,J=null));var ve=new Vl("action","action",null,M,P);h.push({event:ve,listeners:[{instance:null,listener:function(){if(M.defaultPrevented){if(pd!==0){var Ue=J?J5(P,J):new FormData(P);Lk(w,{pending:!0,data:Ue,method:P.method,action:L},null,Ue)}}else typeof L=="function"&&(ve.preventDefault(),Ue=J?J5(P,J):new FormData(P),Lk(w,{pending:!0,data:Ue,method:P.method,action:L},L,Ue))},currentTarget:P}]})}}for(var xE=0;xE<J2.length;xE++){var bE=J2[xE],qie=bE.toLowerCase(),Wie=bE[0].toUpperCase()+bE.slice(1);xl(qie,"on"+Wie)}xl(CF,"onAnimationEnd"),xl(jF,"onAnimationIteration"),xl(PF,"onAnimationStart"),xl("dblclick","onDoubleClick"),xl("focusin","onFocus"),xl("focusout","onBlur"),xl(cie,"onTransitionRun"),xl(uie,"onTransitionStart"),xl(die,"onTransitionCancel"),xl(DF,"onTransitionEnd"),At("onMouseEnter",["mouseout","mouseover"]),At("onMouseLeave",["mouseout","mouseover"]),At("onPointerEnter",["pointerout","pointerover"]),At("onPointerLeave",["pointerout","pointerover"]),St("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),St("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),St("onBeforeInput",["compositionend","keypress","textInput","paste"]),St("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),St("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),St("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var bb="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),Kie=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(bb));function eU(h,g){g=(g&4)!==0;for(var w=0;w<h.length;w++){var M=h[w],P=M.event;M=M.listeners;e:{var L=void 0;if(g)for(var J=M.length-1;0<=J;J--){var ve=M[J],Ue=ve.instance,it=ve.currentTarget;if(ve=ve.listener,Ue!==L&&P.isPropagationStopped())break e;L=ve,P.currentTarget=it;try{L(P)}catch(gt){Ev(gt)}P.currentTarget=null,L=Ue}else for(J=0;J<M.length;J++){if(ve=M[J],Ue=ve.instance,it=ve.currentTarget,ve=ve.listener,Ue!==L&&P.isPropagationStopped())break e;L=ve,P.currentTarget=it;try{L(P)}catch(gt){Ev(gt)}P.currentTarget=null,L=Ue}}}}function Un(h,g){var w=g[Ba];w===void 0&&(w=g[Ba]=new Set);var M=h+"__bubble";w.has(M)||(tU(g,h,2,!1),w.add(M))}function yE(h,g,w){var M=0;g&&(M|=4),tU(w,h,M,g)}var fw="_reactListening"+Math.random().toString(36).slice(2);function vE(h){if(!h[fw]){h[fw]=!0,Ce.forEach(function(w){w!=="selectionchange"&&(Kie.has(w)||yE(w,!1,h),yE(w,!0,h))});var g=h.nodeType===9?h:h.ownerDocument;g===null||g[fw]||(g[fw]=!0,yE("selectionchange",!1,g))}}function tU(h,g,w,M){switch(CU(g)){case 2:var P=_ae;break;case 8:P=Sae;break;default:P=OE}w=P.bind(null,g,w,h),P=void 0,!Ux||g!=="touchstart"&&g!=="touchmove"&&g!=="wheel"||(P=!0),M?P!==void 0?h.addEventListener(g,w,{capture:!0,passive:P}):h.addEventListener(g,w,!0):P!==void 0?h.addEventListener(g,w,{passive:P}):h.addEventListener(g,w,!1)}function wE(h,g,w,M,P){var L=M;if((g&1)===0&&(g&2)===0&&M!==null)e:for(;;){if(M===null)return;var J=M.tag;if(J===3||J===4){var ve=M.stateNode.containerInfo;if(ve===P)break;if(J===4)for(J=M.return;J!==null;){var Ue=J.tag;if((Ue===3||Ue===4)&&J.stateNode.containerInfo===P)return;J=J.return}for(;ve!==null;){if(J=Et(ve),J===null)return;if(Ue=J.tag,Ue===5||Ue===6||Ue===26||Ue===27){M=L=J;continue e}ve=ve.parentNode}}M=M.return}Ks(function(){var it=L,gt=_o(w),vt=[];e:{var ct=RF.get(h);if(ct!==void 0){var pt=Vl,Vt=h;switch(h){case"keypress":if(Vh(w)===0)break e;case"keydown":case"keyup":pt=Bre;break;case"focusin":Vt="focus",pt=Im;break;case"focusout":Vt="blur",pt=Im;break;case"beforeblur":case"afterblur":pt=Im;break;case"click":if(w.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":pt=Sv;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":pt=Mv;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":pt=Vre;break;case CF:case jF:case PF:pt=Nv;break;case DF:pt=qre;break;case"scroll":case"scrollend":pt=Om;break;case"wheel":pt=Kre;break;case"copy":case"cut":case"paste":pt=wt;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":pt=dF;break;case"toggle":case"beforetoggle":pt=Yre}var nn=(g&4)!==0,Sr=!nn&&(h==="scroll"||h==="scrollend"),Je=nn?ct!==null?ct+"Capture":null:ct;nn=[];for(var Ge=it,rt;Ge!==null;){var bt=Ge;if(rt=bt.stateNode,bt=bt.tag,bt!==5&&bt!==26&&bt!==27||rt===null||Je===null||(bt=la(Ge,Je),bt!=null&&nn.push(yb(Ge,bt,rt))),Sr)break;Ge=Ge.return}0<nn.length&&(ct=new pt(ct,Vt,null,w,gt),vt.push({event:ct,listeners:nn}))}}if((g&7)===0){e:{if(ct=h==="mouseover"||h==="pointerover",pt=h==="mouseout"||h==="pointerout",ct&&w!==Ss&&(Vt=w.relatedTarget||w.fromElement)&&(Et(Vt)||Vt[wi]))break e;if((pt||ct)&&(ct=gt.window===gt?gt:(ct=gt.ownerDocument)?ct.defaultView||ct.parentWindow:window,pt?(Vt=w.relatedTarget||w.toElement,pt=it,Vt=Vt?Et(Vt):null,Vt!==null&&(Sr=a(Vt),nn=Vt.tag,Vt!==Sr||nn!==5&&nn!==27&&nn!==6)&&(Vt=null)):(pt=null,Vt=it),pt!==Vt)){if(nn=Sv,bt="onMouseLeave",Je="onMouseEnter",Ge="mouse",(h==="pointerout"||h==="pointerover")&&(nn=dF,bt="onPointerLeave",Je="onPointerEnter",Ge="pointer"),Sr=pt==null?ct:pe(pt),rt=Vt==null?ct:pe(Vt),ct=new nn(bt,Ge+"leave",pt,w,gt),ct.target=Sr,ct.relatedTarget=rt,bt=null,Et(gt)===it&&(nn=new nn(Je,Ge+"enter",Vt,w,gt),nn.target=rt,nn.relatedTarget=Sr,bt=nn),Sr=bt,pt&&Vt)t:{for(nn=Xie,Je=pt,Ge=Vt,rt=0,bt=Je;bt;bt=nn(bt))rt++;bt=0;for(var Kt=Ge;Kt;Kt=nn(Kt))bt++;for(;0<rt-bt;)Je=nn(Je),rt--;for(;0<bt-rt;)Ge=nn(Ge),bt--;for(;rt--;){if(Je===Ge||Ge!==null&&Je===Ge.alternate){nn=Je;break t}Je=nn(Je),Ge=nn(Ge)}nn=null}else nn=null;pt!==null&&nU(vt,ct,pt,nn,!1),Vt!==null&&Sr!==null&&nU(vt,Sr,Vt,nn,!0)}}e:{if(ct=it?pe(it):window,pt=ct.nodeName&&ct.nodeName.toLowerCase(),pt==="select"||pt==="input"&&ct.type==="file")var ar=yF;else if(xF(ct))if(vF)ar=sie;else{ar=iie;var Wt=rie}else pt=ct.nodeName,!pt||pt.toLowerCase()!=="input"||ct.type!=="checkbox"&&ct.type!=="radio"?it&&Br(it.elementType)&&(ar=yF):ar=aie;if(ar&&(ar=ar(h,it))){bF(vt,ar,w,gt);break e}Wt&&Wt(h,ct,it),h==="focusout"&&it&&ct.type==="number"&&it.memoizedProps.value!=null&&cr(ct,"number",ct.value)}switch(Wt=it?pe(it):window,h){case"focusin":(xF(Wt)||Wt.contentEditable==="true")&&(zm=Wt,Y2=it,Kx=null);break;case"focusout":Kx=Y2=zm=null;break;case"mousedown":Q2=!0;break;case"contextmenu":case"mouseup":case"dragend":Q2=!1,TF(vt,w,gt);break;case"selectionchange":if(lie)break;case"keydown":case"keyup":TF(vt,w,gt)}var Mn;if(q2)e:{switch(h){case"compositionstart":var qn="onCompositionStart";break e;case"compositionend":qn="onCompositionEnd";break e;case"compositionupdate":qn="onCompositionUpdate";break e}qn=void 0}else Um?pF(h,w)&&(qn="onCompositionEnd"):h==="keydown"&&w.keyCode===229&&(qn="onCompositionStart");qn&&(hF&&w.locale!=="ko"&&(Um||qn!=="onCompositionStart"?qn==="onCompositionEnd"&&Um&&(Mn=Rm()):($l=gt,zx="value"in $l?$l.value:$l.textContent,Um=!0)),Wt=mw(it,qn),0<Wt.length&&(qn=new Jn(qn,h,null,w,gt),vt.push({event:qn,listeners:Wt}),Mn?qn.data=Mn:(Mn=gF(w),Mn!==null&&(qn.data=Mn)))),(Mn=Zre?Jre(h,w):eie(h,w))&&(qn=mw(it,"onBeforeInput"),0<qn.length&&(Wt=new Jn("onBeforeInput","beforeinput",null,w,gt),vt.push({event:Wt,listeners:qn}),Wt.data=Mn)),Gie(vt,h,it,w,gt)}eU(vt,g)})}function yb(h,g,w){return{instance:h,listener:g,currentTarget:w}}function mw(h,g){for(var w=g+"Capture",M=[];h!==null;){var P=h,L=P.stateNode;if(P=P.tag,P!==5&&P!==26&&P!==27||L===null||(P=la(h,w),P!=null&&M.unshift(yb(h,P,L)),P=la(h,g),P!=null&&M.push(yb(h,P,L))),h.tag===3)return M;h=h.return}return[]}function Xie(h){if(h===null)return null;do h=h.return;while(h&&h.tag!==5&&h.tag!==27);return h||null}function nU(h,g,w,M,P){for(var L=g._reactName,J=[];w!==null&&w!==M;){var ve=w,Ue=ve.alternate,it=ve.stateNode;if(ve=ve.tag,Ue!==null&&Ue===M)break;ve!==5&&ve!==26&&ve!==27||it===null||(Ue=it,P?(it=la(w,L),it!=null&&J.unshift(yb(w,it,Ue))):P||(it=la(w,L),it!=null&&J.push(yb(w,it,Ue)))),w=w.return}J.length!==0&&h.push({event:g,listeners:J})}var Yie=/\r\n?/g,Qie=/\u0000|\uFFFD/g;function rU(h){return(typeof h=="string"?h:""+h).replace(Yie,`
- `).replace(Qie,"")}function iU(h,g){return g=rU(g),rU(h)===g}function _r(h,g,w,M,P,L){switch(w){case"children":typeof M=="string"?g==="body"||g==="textarea"&&M===""||yt(h,M):(typeof M=="number"||typeof M=="bigint")&&g!=="body"&&yt(h,""+M);break;case"className":Ht(h,"class",M);break;case"tabIndex":Ht(h,"tabindex",M);break;case"dir":case"role":case"viewBox":case"width":case"height":Ht(h,w,M);break;case"style":Yr(h,M,L);break;case"data":if(g!=="object"){Ht(h,"data",M);break}case"src":case"href":if(M===""&&(g!=="a"||w!=="href")){h.removeAttribute(w);break}if(M==null||typeof M=="function"||typeof M=="symbol"||typeof M=="boolean"){h.removeAttribute(w);break}M=on(""+M),h.setAttribute(w,M);break;case"action":case"formAction":if(typeof M=="function"){h.setAttribute(w,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof L=="function"&&(w==="formAction"?(g!=="input"&&_r(h,g,"name",P.name,P,null),_r(h,g,"formEncType",P.formEncType,P,null),_r(h,g,"formMethod",P.formMethod,P,null),_r(h,g,"formTarget",P.formTarget,P,null)):(_r(h,g,"encType",P.encType,P,null),_r(h,g,"method",P.method,P,null),_r(h,g,"target",P.target,P,null)));if(M==null||typeof M=="symbol"||typeof M=="boolean"){h.removeAttribute(w);break}M=on(""+M),h.setAttribute(w,M);break;case"onClick":M!=null&&(h.onclick=_i);break;case"onScroll":M!=null&&Un("scroll",h);break;case"onScrollEnd":M!=null&&Un("scrollend",h);break;case"dangerouslySetInnerHTML":if(M!=null){if(typeof M!="object"||!("__html"in M))throw Error(r(61));if(w=M.__html,w!=null){if(P.children!=null)throw Error(r(60));h.innerHTML=w}}break;case"multiple":h.multiple=M&&typeof M!="function"&&typeof M!="symbol";break;case"muted":h.muted=M&&typeof M!="function"&&typeof M!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(M==null||typeof M=="function"||typeof M=="boolean"||typeof M=="symbol"){h.removeAttribute("xlink:href");break}w=on(""+M),h.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",w);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":M!=null&&typeof M!="function"&&typeof M!="symbol"?h.setAttribute(w,""+M):h.removeAttribute(w);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":M&&typeof M!="function"&&typeof M!="symbol"?h.setAttribute(w,""):h.removeAttribute(w);break;case"capture":case"download":M===!0?h.setAttribute(w,""):M!==!1&&M!=null&&typeof M!="function"&&typeof M!="symbol"?h.setAttribute(w,M):h.removeAttribute(w);break;case"cols":case"rows":case"size":case"span":M!=null&&typeof M!="function"&&typeof M!="symbol"&&!isNaN(M)&&1<=M?h.setAttribute(w,M):h.removeAttribute(w);break;case"rowSpan":case"start":M==null||typeof M=="function"||typeof M=="symbol"||isNaN(M)?h.removeAttribute(w):h.setAttribute(w,M);break;case"popover":Un("beforetoggle",h),Un("toggle",h),en(h,"popover",M);break;case"xlinkActuate":dn(h,"http://www.w3.org/1999/xlink","xlink:actuate",M);break;case"xlinkArcrole":dn(h,"http://www.w3.org/1999/xlink","xlink:arcrole",M);break;case"xlinkRole":dn(h,"http://www.w3.org/1999/xlink","xlink:role",M);break;case"xlinkShow":dn(h,"http://www.w3.org/1999/xlink","xlink:show",M);break;case"xlinkTitle":dn(h,"http://www.w3.org/1999/xlink","xlink:title",M);break;case"xlinkType":dn(h,"http://www.w3.org/1999/xlink","xlink:type",M);break;case"xmlBase":dn(h,"http://www.w3.org/XML/1998/namespace","xml:base",M);break;case"xmlLang":dn(h,"http://www.w3.org/XML/1998/namespace","xml:lang",M);break;case"xmlSpace":dn(h,"http://www.w3.org/XML/1998/namespace","xml:space",M);break;case"is":en(h,"is",M);break;case"innerText":case"textContent":break;default:(!(2<w.length)||w[0]!=="o"&&w[0]!=="O"||w[1]!=="n"&&w[1]!=="N")&&(w=Ws.get(w)||w,en(h,w,M))}}function _E(h,g,w,M,P,L){switch(w){case"style":Yr(h,M,L);break;case"dangerouslySetInnerHTML":if(M!=null){if(typeof M!="object"||!("__html"in M))throw Error(r(61));if(w=M.__html,w!=null){if(P.children!=null)throw Error(r(60));h.innerHTML=w}}break;case"children":typeof M=="string"?yt(h,M):(typeof M=="number"||typeof M=="bigint")&&yt(h,""+M);break;case"onScroll":M!=null&&Un("scroll",h);break;case"onScrollEnd":M!=null&&Un("scrollend",h);break;case"onClick":M!=null&&(h.onclick=_i);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!ut.hasOwnProperty(w))e:{if(w[0]==="o"&&w[1]==="n"&&(P=w.endsWith("Capture"),g=w.slice(2,P?w.length-7:void 0),L=h[bn]||null,L=L!=null?L[w]:null,typeof L=="function"&&h.removeEventListener(g,L,P),typeof M=="function")){typeof L!="function"&&L!==null&&(w in h?h[w]=null:h.hasAttribute(w)&&h.removeAttribute(w)),h.addEventListener(g,M,P);break e}w in h?h[w]=M:M===!0?h.setAttribute(w,""):en(h,w,M)}}}function Ea(h,g,w){switch(g){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Un("error",h),Un("load",h);var M=!1,P=!1,L;for(L in w)if(w.hasOwnProperty(L)){var J=w[L];if(J!=null)switch(L){case"src":M=!0;break;case"srcSet":P=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,g));default:_r(h,g,L,J,w,null)}}P&&_r(h,g,"srcSet",w.srcSet,w,null),M&&_r(h,g,"src",w.src,w,null);return;case"input":Un("invalid",h);var ve=L=J=P=null,Ue=null,it=null;for(M in w)if(w.hasOwnProperty(M)){var gt=w[M];if(gt!=null)switch(M){case"name":P=gt;break;case"type":J=gt;break;case"checked":Ue=gt;break;case"defaultChecked":it=gt;break;case"value":L=gt;break;case"defaultValue":ve=gt;break;case"children":case"dangerouslySetInnerHTML":if(gt!=null)throw Error(r(137,g));break;default:_r(h,g,M,gt,w,null)}}rr(h,L,ve,Ue,it,J,P,!1);return;case"select":Un("invalid",h),M=J=L=null;for(P in w)if(w.hasOwnProperty(P)&&(ve=w[P],ve!=null))switch(P){case"value":L=ve;break;case"defaultValue":J=ve;break;case"multiple":M=ve;default:_r(h,g,P,ve,w,null)}g=L,w=J,h.multiple=!!M,g!=null?et(h,!!M,g,!1):w!=null&&et(h,!!M,w,!0);return;case"textarea":Un("invalid",h),L=P=M=null;for(J in w)if(w.hasOwnProperty(J)&&(ve=w[J],ve!=null))switch(J){case"value":M=ve;break;case"defaultValue":P=ve;break;case"children":L=ve;break;case"dangerouslySetInnerHTML":if(ve!=null)throw Error(r(91));break;default:_r(h,g,J,ve,w,null)}qt(h,M,P,L);return;case"option":for(Ue in w)if(w.hasOwnProperty(Ue)&&(M=w[Ue],M!=null))switch(Ue){case"selected":h.selected=M&&typeof M!="function"&&typeof M!="symbol";break;default:_r(h,g,Ue,M,w,null)}return;case"dialog":Un("beforetoggle",h),Un("toggle",h),Un("cancel",h),Un("close",h);break;case"iframe":case"object":Un("load",h);break;case"video":case"audio":for(M=0;M<bb.length;M++)Un(bb[M],h);break;case"image":Un("error",h),Un("load",h);break;case"details":Un("toggle",h);break;case"embed":case"source":case"link":Un("error",h),Un("load",h);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(it in w)if(w.hasOwnProperty(it)&&(M=w[it],M!=null))switch(it){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,g));default:_r(h,g,it,M,w,null)}return;default:if(Br(g)){for(gt in w)w.hasOwnProperty(gt)&&(M=w[gt],M!==void 0&&_E(h,g,gt,M,w,void 0));return}}for(ve in w)w.hasOwnProperty(ve)&&(M=w[ve],M!=null&&_r(h,g,ve,M,w,null))}function Zie(h,g,w,M){switch(g){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var P=null,L=null,J=null,ve=null,Ue=null,it=null,gt=null;for(pt in w){var vt=w[pt];if(w.hasOwnProperty(pt)&&vt!=null)switch(pt){case"checked":break;case"value":break;case"defaultValue":Ue=vt;default:M.hasOwnProperty(pt)||_r(h,g,pt,null,M,vt)}}for(var ct in M){var pt=M[ct];if(vt=w[ct],M.hasOwnProperty(ct)&&(pt!=null||vt!=null))switch(ct){case"type":L=pt;break;case"name":P=pt;break;case"checked":it=pt;break;case"defaultChecked":gt=pt;break;case"value":J=pt;break;case"defaultValue":ve=pt;break;case"children":case"dangerouslySetInnerHTML":if(pt!=null)throw Error(r(137,g));break;default:pt!==vt&&_r(h,g,ct,pt,M,vt)}}ii(h,J,ve,Ue,it,gt,L,P);return;case"select":pt=J=ve=ct=null;for(L in w)if(Ue=w[L],w.hasOwnProperty(L)&&Ue!=null)switch(L){case"value":break;case"multiple":pt=Ue;default:M.hasOwnProperty(L)||_r(h,g,L,null,M,Ue)}for(P in M)if(L=M[P],Ue=w[P],M.hasOwnProperty(P)&&(L!=null||Ue!=null))switch(P){case"value":ct=L;break;case"defaultValue":ve=L;break;case"multiple":J=L;default:L!==Ue&&_r(h,g,P,L,M,Ue)}g=ve,w=J,M=pt,ct!=null?et(h,!!w,ct,!1):!!M!=!!w&&(g!=null?et(h,!!w,g,!0):et(h,!!w,w?[]:"",!1));return;case"textarea":pt=ct=null;for(ve in w)if(P=w[ve],w.hasOwnProperty(ve)&&P!=null&&!M.hasOwnProperty(ve))switch(ve){case"value":break;case"children":break;default:_r(h,g,ve,null,M,P)}for(J in M)if(P=M[J],L=w[J],M.hasOwnProperty(J)&&(P!=null||L!=null))switch(J){case"value":ct=P;break;case"defaultValue":pt=P;break;case"children":break;case"dangerouslySetInnerHTML":if(P!=null)throw Error(r(91));break;default:P!==L&&_r(h,g,J,P,M,L)}jt(h,ct,pt);return;case"option":for(var Vt in w)if(ct=w[Vt],w.hasOwnProperty(Vt)&&ct!=null&&!M.hasOwnProperty(Vt))switch(Vt){case"selected":h.selected=!1;break;default:_r(h,g,Vt,null,M,ct)}for(Ue in M)if(ct=M[Ue],pt=w[Ue],M.hasOwnProperty(Ue)&&ct!==pt&&(ct!=null||pt!=null))switch(Ue){case"selected":h.selected=ct&&typeof ct!="function"&&typeof ct!="symbol";break;default:_r(h,g,Ue,ct,M,pt)}return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var nn in w)ct=w[nn],w.hasOwnProperty(nn)&&ct!=null&&!M.hasOwnProperty(nn)&&_r(h,g,nn,null,M,ct);for(it in M)if(ct=M[it],pt=w[it],M.hasOwnProperty(it)&&ct!==pt&&(ct!=null||pt!=null))switch(it){case"children":case"dangerouslySetInnerHTML":if(ct!=null)throw Error(r(137,g));break;default:_r(h,g,it,ct,M,pt)}return;default:if(Br(g)){for(var Sr in w)ct=w[Sr],w.hasOwnProperty(Sr)&&ct!==void 0&&!M.hasOwnProperty(Sr)&&_E(h,g,Sr,void 0,M,ct);for(gt in M)ct=M[gt],pt=w[gt],!M.hasOwnProperty(gt)||ct===pt||ct===void 0&&pt===void 0||_E(h,g,gt,ct,M,pt);return}}for(var Je in w)ct=w[Je],w.hasOwnProperty(Je)&&ct!=null&&!M.hasOwnProperty(Je)&&_r(h,g,Je,null,M,ct);for(vt in M)ct=M[vt],pt=w[vt],!M.hasOwnProperty(vt)||ct===pt||ct==null&&pt==null||_r(h,g,vt,ct,M,pt)}function aU(h){switch(h){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function Jie(){if(typeof performance.getEntriesByType=="function"){for(var h=0,g=0,w=performance.getEntriesByType("resource"),M=0;M<w.length;M++){var P=w[M],L=P.transferSize,J=P.initiatorType,ve=P.duration;if(L&&ve&&aU(J)){for(J=0,ve=P.responseEnd,M+=1;M<w.length;M++){var Ue=w[M],it=Ue.startTime;if(it>ve)break;var gt=Ue.transferSize,vt=Ue.initiatorType;gt&&aU(vt)&&(Ue=Ue.responseEnd,J+=gt*(Ue<ve?1:(ve-it)/(Ue-it)))}if(--M,g+=8*(L+J)/(P.duration/1e3),h++,10<h)break}}if(0<h)return g/h/1e6}return navigator.connection&&(h=navigator.connection.downlink,typeof h=="number")?h:5}var SE=null,ME=null;function pw(h){return h.nodeType===9?h:h.ownerDocument}function sU(h){switch(h){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function oU(h,g){if(h===0)switch(g){case"svg":return 1;case"math":return 2;default:return 0}return h===1&&g==="foreignObject"?0:h}function NE(h,g){return h==="textarea"||h==="noscript"||typeof g.children=="string"||typeof g.children=="number"||typeof g.children=="bigint"||typeof g.dangerouslySetInnerHTML=="object"&&g.dangerouslySetInnerHTML!==null&&g.dangerouslySetInnerHTML.__html!=null}var kE=null;function eae(){var h=window.event;return h&&h.type==="popstate"?h===kE?!1:(kE=h,!0):(kE=null,!1)}var lU=typeof setTimeout=="function"?setTimeout:void 0,tae=typeof clearTimeout=="function"?clearTimeout:void 0,cU=typeof Promise=="function"?Promise:void 0,nae=typeof queueMicrotask=="function"?queueMicrotask:typeof cU<"u"?function(h){return cU.resolve(null).then(h).catch(rae)}:lU;function rae(h){setTimeout(function(){throw h})}function gd(h){return h==="head"}function uU(h,g){var w=g,M=0;do{var P=w.nextSibling;if(h.removeChild(w),P&&P.nodeType===8)if(w=P.data,w==="/$"||w==="/&"){if(M===0){h.removeChild(P),fp(g);return}M--}else if(w==="$"||w==="$?"||w==="$~"||w==="$!"||w==="&")M++;else if(w==="html")vb(h.ownerDocument.documentElement);else if(w==="head"){w=h.ownerDocument.head,vb(w);for(var L=w.firstChild;L;){var J=L.nextSibling,ve=L.nodeName;L[lt]||ve==="SCRIPT"||ve==="STYLE"||ve==="LINK"&&L.rel.toLowerCase()==="stylesheet"||w.removeChild(L),L=J}}else w==="body"&&vb(h.ownerDocument.body);w=P}while(w);fp(g)}function dU(h,g){var w=h;h=0;do{var M=w.nextSibling;if(w.nodeType===1?g?(w._stashedDisplay=w.style.display,w.style.display="none"):(w.style.display=w._stashedDisplay||"",w.getAttribute("style")===""&&w.removeAttribute("style")):w.nodeType===3&&(g?(w._stashedText=w.nodeValue,w.nodeValue=""):w.nodeValue=w._stashedText||""),M&&M.nodeType===8)if(w=M.data,w==="/$"){if(h===0)break;h--}else w!=="$"&&w!=="$?"&&w!=="$~"&&w!=="$!"||h++;w=M}while(w)}function EE(h){var g=h.firstChild;for(g&&g.nodeType===10&&(g=g.nextSibling);g;){var w=g;switch(g=g.nextSibling,w.nodeName){case"HTML":case"HEAD":case"BODY":EE(w),ot(w);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(w.rel.toLowerCase()==="stylesheet")continue}h.removeChild(w)}}function iae(h,g,w,M){for(;h.nodeType===1;){var P=w;if(h.nodeName.toLowerCase()!==g.toLowerCase()){if(!M&&(h.nodeName!=="INPUT"||h.type!=="hidden"))break}else if(M){if(!h[lt])switch(g){case"meta":if(!h.hasAttribute("itemprop"))break;return h;case"link":if(L=h.getAttribute("rel"),L==="stylesheet"&&h.hasAttribute("data-precedence"))break;if(L!==P.rel||h.getAttribute("href")!==(P.href==null||P.href===""?null:P.href)||h.getAttribute("crossorigin")!==(P.crossOrigin==null?null:P.crossOrigin)||h.getAttribute("title")!==(P.title==null?null:P.title))break;return h;case"style":if(h.hasAttribute("data-precedence"))break;return h;case"script":if(L=h.getAttribute("src"),(L!==(P.src==null?null:P.src)||h.getAttribute("type")!==(P.type==null?null:P.type)||h.getAttribute("crossorigin")!==(P.crossOrigin==null?null:P.crossOrigin))&&L&&h.hasAttribute("async")&&!h.hasAttribute("itemprop"))break;return h;default:return h}}else if(g==="input"&&h.type==="hidden"){var L=P.name==null?null:""+P.name;if(P.type==="hidden"&&h.getAttribute("name")===L)return h}else return h;if(h=Po(h.nextSibling),h===null)break}return null}function aae(h,g,w){if(g==="")return null;for(;h.nodeType!==3;)if((h.nodeType!==1||h.nodeName!=="INPUT"||h.type!=="hidden")&&!w||(h=Po(h.nextSibling),h===null))return null;return h}function hU(h,g){for(;h.nodeType!==8;)if((h.nodeType!==1||h.nodeName!=="INPUT"||h.type!=="hidden")&&!g||(h=Po(h.nextSibling),h===null))return null;return h}function TE(h){return h.data==="$?"||h.data==="$~"}function AE(h){return h.data==="$!"||h.data==="$?"&&h.ownerDocument.readyState!=="loading"}function sae(h,g){var w=h.ownerDocument;if(h.data==="$~")h._reactRetry=g;else if(h.data!=="$?"||w.readyState!=="loading")g();else{var M=function(){g(),w.removeEventListener("DOMContentLoaded",M)};w.addEventListener("DOMContentLoaded",M),h._reactRetry=M}}function Po(h){for(;h!=null;h=h.nextSibling){var g=h.nodeType;if(g===1||g===3)break;if(g===8){if(g=h.data,g==="$"||g==="$!"||g==="$?"||g==="$~"||g==="&"||g==="F!"||g==="F")break;if(g==="/$"||g==="/&")return null}}return h}var CE=null;function fU(h){h=h.nextSibling;for(var g=0;h;){if(h.nodeType===8){var w=h.data;if(w==="/$"||w==="/&"){if(g===0)return Po(h.nextSibling);g--}else w!=="$"&&w!=="$!"&&w!=="$?"&&w!=="$~"&&w!=="&"||g++}h=h.nextSibling}return null}function mU(h){h=h.previousSibling;for(var g=0;h;){if(h.nodeType===8){var w=h.data;if(w==="$"||w==="$!"||w==="$?"||w==="$~"||w==="&"){if(g===0)return h;g--}else w!=="/$"&&w!=="/&"||g++}h=h.previousSibling}return null}function pU(h,g,w){switch(g=pw(w),h){case"html":if(h=g.documentElement,!h)throw Error(r(452));return h;case"head":if(h=g.head,!h)throw Error(r(453));return h;case"body":if(h=g.body,!h)throw Error(r(454));return h;default:throw Error(r(451))}}function vb(h){for(var g=h.attributes;g.length;)h.removeAttributeNode(g[0]);ot(h)}var Do=new Map,gU=new Set;function gw(h){return typeof h.getRootNode=="function"?h.getRootNode():h.nodeType===9?h:h.ownerDocument}var Gc=V.d;V.d={f:oae,r:lae,D:cae,C:uae,L:dae,m:hae,X:mae,S:fae,M:pae};function oae(){var h=Gc.f(),g=ow();return h||g}function lae(h){var g=he(h);g!==null&&g.tag===5&&g.type==="form"?DI(g):Gc.r(h)}var up=typeof document>"u"?null:document;function xU(h,g,w){var M=up;if(M&&typeof g=="string"&&g){var P=jn(g);P='link[rel="'+h+'"][href="'+P+'"]',typeof w=="string"&&(P+='[crossorigin="'+w+'"]'),gU.has(P)||(gU.add(P),h={rel:h,crossOrigin:w,href:g},M.querySelector(P)===null&&(g=M.createElement("link"),Ea(g,"link",h),Le(g),M.head.appendChild(g)))}}function cae(h){Gc.D(h),xU("dns-prefetch",h,null)}function uae(h,g){Gc.C(h,g),xU("preconnect",h,g)}function dae(h,g,w){Gc.L(h,g,w);var M=up;if(M&&h&&g){var P='link[rel="preload"][as="'+jn(g)+'"]';g==="image"&&w&&w.imageSrcSet?(P+='[imagesrcset="'+jn(w.imageSrcSet)+'"]',typeof w.imageSizes=="string"&&(P+='[imagesizes="'+jn(w.imageSizes)+'"]')):P+='[href="'+jn(h)+'"]';var L=P;switch(g){case"style":L=dp(h);break;case"script":L=hp(h)}Do.has(L)||(h=f({rel:"preload",href:g==="image"&&w&&w.imageSrcSet?void 0:h,as:g},w),Do.set(L,h),M.querySelector(P)!==null||g==="style"&&M.querySelector(wb(L))||g==="script"&&M.querySelector(_b(L))||(g=M.createElement("link"),Ea(g,"link",h),Le(g),M.head.appendChild(g)))}}function hae(h,g){Gc.m(h,g);var w=up;if(w&&h){var M=g&&typeof g.as=="string"?g.as:"script",P='link[rel="modulepreload"][as="'+jn(M)+'"][href="'+jn(h)+'"]',L=P;switch(M){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":L=hp(h)}if(!Do.has(L)&&(h=f({rel:"modulepreload",href:h},g),Do.set(L,h),w.querySelector(P)===null)){switch(M){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(w.querySelector(_b(L)))return}M=w.createElement("link"),Ea(M,"link",h),Le(M),w.head.appendChild(M)}}}function fae(h,g,w){Gc.S(h,g,w);var M=up;if(M&&h){var P=Ie(M).hoistableStyles,L=dp(h);g=g||"default";var J=P.get(L);if(!J){var ve={loading:0,preload:null};if(J=M.querySelector(wb(L)))ve.loading=5;else{h=f({rel:"stylesheet",href:h,"data-precedence":g},w),(w=Do.get(L))&&jE(h,w);var Ue=J=M.createElement("link");Le(Ue),Ea(Ue,"link",h),Ue._p=new Promise(function(it,gt){Ue.onload=it,Ue.onerror=gt}),Ue.addEventListener("load",function(){ve.loading|=1}),Ue.addEventListener("error",function(){ve.loading|=2}),ve.loading|=4,xw(J,g,M)}J={type:"stylesheet",instance:J,count:1,state:ve},P.set(L,J)}}}function mae(h,g){Gc.X(h,g);var w=up;if(w&&h){var M=Ie(w).hoistableScripts,P=hp(h),L=M.get(P);L||(L=w.querySelector(_b(P)),L||(h=f({src:h,async:!0},g),(g=Do.get(P))&&PE(h,g),L=w.createElement("script"),Le(L),Ea(L,"link",h),w.head.appendChild(L)),L={type:"script",instance:L,count:1,state:null},M.set(P,L))}}function pae(h,g){Gc.M(h,g);var w=up;if(w&&h){var M=Ie(w).hoistableScripts,P=hp(h),L=M.get(P);L||(L=w.querySelector(_b(P)),L||(h=f({src:h,async:!0,type:"module"},g),(g=Do.get(P))&&PE(h,g),L=w.createElement("script"),Le(L),Ea(L,"link",h),w.head.appendChild(L)),L={type:"script",instance:L,count:1,state:null},M.set(P,L))}}function bU(h,g,w,M){var P=(P=xe.current)?gw(P):null;if(!P)throw Error(r(446));switch(h){case"meta":case"title":return null;case"style":return typeof w.precedence=="string"&&typeof w.href=="string"?(g=dp(w.href),w=Ie(P).hoistableStyles,M=w.get(g),M||(M={type:"style",instance:null,count:0,state:null},w.set(g,M)),M):{type:"void",instance:null,count:0,state:null};case"link":if(w.rel==="stylesheet"&&typeof w.href=="string"&&typeof w.precedence=="string"){h=dp(w.href);var L=Ie(P).hoistableStyles,J=L.get(h);if(J||(P=P.ownerDocument||P,J={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},L.set(h,J),(L=P.querySelector(wb(h)))&&!L._p&&(J.instance=L,J.state.loading=5),Do.has(h)||(w={rel:"preload",as:"style",href:w.href,crossOrigin:w.crossOrigin,integrity:w.integrity,media:w.media,hrefLang:w.hrefLang,referrerPolicy:w.referrerPolicy},Do.set(h,w),L||gae(P,h,w,J.state))),g&&M===null)throw Error(r(528,""));return J}if(g&&M!==null)throw Error(r(529,""));return null;case"script":return g=w.async,w=w.src,typeof w=="string"&&g&&typeof g!="function"&&typeof g!="symbol"?(g=hp(w),w=Ie(P).hoistableScripts,M=w.get(g),M||(M={type:"script",instance:null,count:0,state:null},w.set(g,M)),M):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,h))}}function dp(h){return'href="'+jn(h)+'"'}function wb(h){return'link[rel="stylesheet"]['+h+"]"}function yU(h){return f({},h,{"data-precedence":h.precedence,precedence:null})}function gae(h,g,w,M){h.querySelector('link[rel="preload"][as="style"]['+g+"]")?M.loading=1:(g=h.createElement("link"),M.preload=g,g.addEventListener("load",function(){return M.loading|=1}),g.addEventListener("error",function(){return M.loading|=2}),Ea(g,"link",w),Le(g),h.head.appendChild(g))}function hp(h){return'[src="'+jn(h)+'"]'}function _b(h){return"script[async]"+h}function vU(h,g,w){if(g.count++,g.instance===null)switch(g.type){case"style":var M=h.querySelector('style[data-href~="'+jn(w.href)+'"]');if(M)return g.instance=M,Le(M),M;var P=f({},w,{"data-href":w.href,"data-precedence":w.precedence,href:null,precedence:null});return M=(h.ownerDocument||h).createElement("style"),Le(M),Ea(M,"style",P),xw(M,w.precedence,h),g.instance=M;case"stylesheet":P=dp(w.href);var L=h.querySelector(wb(P));if(L)return g.state.loading|=4,g.instance=L,Le(L),L;M=yU(w),(P=Do.get(P))&&jE(M,P),L=(h.ownerDocument||h).createElement("link"),Le(L);var J=L;return J._p=new Promise(function(ve,Ue){J.onload=ve,J.onerror=Ue}),Ea(L,"link",M),g.state.loading|=4,xw(L,w.precedence,h),g.instance=L;case"script":return L=hp(w.src),(P=h.querySelector(_b(L)))?(g.instance=P,Le(P),P):(M=w,(P=Do.get(L))&&(M=f({},w),PE(M,P)),h=h.ownerDocument||h,P=h.createElement("script"),Le(P),Ea(P,"link",M),h.head.appendChild(P),g.instance=P);case"void":return null;default:throw Error(r(443,g.type))}else g.type==="stylesheet"&&(g.state.loading&4)===0&&(M=g.instance,g.state.loading|=4,xw(M,w.precedence,h));return g.instance}function xw(h,g,w){for(var M=w.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),P=M.length?M[M.length-1]:null,L=P,J=0;J<M.length;J++){var ve=M[J];if(ve.dataset.precedence===g)L=ve;else if(L!==P)break}L?L.parentNode.insertBefore(h,L.nextSibling):(g=w.nodeType===9?w.head:w,g.insertBefore(h,g.firstChild))}function jE(h,g){h.crossOrigin==null&&(h.crossOrigin=g.crossOrigin),h.referrerPolicy==null&&(h.referrerPolicy=g.referrerPolicy),h.title==null&&(h.title=g.title)}function PE(h,g){h.crossOrigin==null&&(h.crossOrigin=g.crossOrigin),h.referrerPolicy==null&&(h.referrerPolicy=g.referrerPolicy),h.integrity==null&&(h.integrity=g.integrity)}var bw=null;function wU(h,g,w){if(bw===null){var M=new Map,P=bw=new Map;P.set(w,M)}else P=bw,M=P.get(w),M||(M=new Map,P.set(w,M));if(M.has(h))return M;for(M.set(h,null),w=w.getElementsByTagName(h),P=0;P<w.length;P++){var L=w[P];if(!(L[lt]||L[Xn]||h==="link"&&L.getAttribute("rel")==="stylesheet")&&L.namespaceURI!=="http://www.w3.org/2000/svg"){var J=L.getAttribute(g)||"";J=h+J;var ve=M.get(J);ve?ve.push(L):M.set(J,[L])}}return M}function _U(h,g,w){h=h.ownerDocument||h,h.head.insertBefore(w,g==="title"?h.querySelector("head > title"):null)}function xae(h,g,w){if(w===1||g.itemProp!=null)return!1;switch(h){case"meta":case"title":return!0;case"style":if(typeof g.precedence!="string"||typeof g.href!="string"||g.href==="")break;return!0;case"link":if(typeof g.rel!="string"||typeof g.href!="string"||g.href===""||g.onLoad||g.onError)break;switch(g.rel){case"stylesheet":return h=g.disabled,typeof g.precedence=="string"&&h==null;default:return!0}case"script":if(g.async&&typeof g.async!="function"&&typeof g.async!="symbol"&&!g.onLoad&&!g.onError&&g.src&&typeof g.src=="string")return!0}return!1}function SU(h){return!(h.type==="stylesheet"&&(h.state.loading&3)===0)}function bae(h,g,w,M){if(w.type==="stylesheet"&&(typeof M.media!="string"||matchMedia(M.media).matches!==!1)&&(w.state.loading&4)===0){if(w.instance===null){var P=dp(M.href),L=g.querySelector(wb(P));if(L){g=L._p,g!==null&&typeof g=="object"&&typeof g.then=="function"&&(h.count++,h=yw.bind(h),g.then(h,h)),w.state.loading|=4,w.instance=L,Le(L);return}L=g.ownerDocument||g,M=yU(M),(P=Do.get(P))&&jE(M,P),L=L.createElement("link"),Le(L);var J=L;J._p=new Promise(function(ve,Ue){J.onload=ve,J.onerror=Ue}),Ea(L,"link",M),w.instance=L}h.stylesheets===null&&(h.stylesheets=new Map),h.stylesheets.set(w,g),(g=w.state.preload)&&(w.state.loading&3)===0&&(h.count++,w=yw.bind(h),g.addEventListener("load",w),g.addEventListener("error",w))}}var DE=0;function yae(h,g){return h.stylesheets&&h.count===0&&ww(h,h.stylesheets),0<h.count||0<h.imgCount?function(w){var M=setTimeout(function(){if(h.stylesheets&&ww(h,h.stylesheets),h.unsuspend){var L=h.unsuspend;h.unsuspend=null,L()}},6e4+g);0<h.imgBytes&&DE===0&&(DE=62500*Jie());var P=setTimeout(function(){if(h.waitingForImages=!1,h.count===0&&(h.stylesheets&&ww(h,h.stylesheets),h.unsuspend)){var L=h.unsuspend;h.unsuspend=null,L()}},(h.imgBytes>DE?50:800)+g);return h.unsuspend=w,function(){h.unsuspend=null,clearTimeout(M),clearTimeout(P)}}:null}function yw(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)ww(this,this.stylesheets);else if(this.unsuspend){var h=this.unsuspend;this.unsuspend=null,h()}}}var vw=null;function ww(h,g){h.stylesheets=null,h.unsuspend!==null&&(h.count++,vw=new Map,g.forEach(vae,h),vw=null,yw.call(h))}function vae(h,g){if(!(g.state.loading&4)){var w=vw.get(h);if(w)var M=w.get(null);else{w=new Map,vw.set(h,w);for(var P=h.querySelectorAll("link[data-precedence],style[data-precedence]"),L=0;L<P.length;L++){var J=P[L];(J.nodeName==="LINK"||J.getAttribute("media")!=="not all")&&(w.set(J.dataset.precedence,J),M=J)}M&&w.set(null,M)}P=g.instance,J=P.getAttribute("data-precedence"),L=w.get(J)||M,L===M&&w.set(null,P),w.set(J,P),this.count++,M=yw.bind(this),P.addEventListener("load",M),P.addEventListener("error",M),L?L.parentNode.insertBefore(P,L.nextSibling):(h=h.nodeType===9?h.head:h,h.insertBefore(P,h.firstChild)),g.state.loading|=4}}var Sb={$$typeof:N,Provider:null,Consumer:null,_currentValue:Q,_currentValue2:Q,_threadCount:0};function wae(h,g,w,M,P,L,J,ve,Ue){this.tag=1,this.containerInfo=h,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=ft(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=ft(0),this.hiddenUpdates=ft(null),this.identifierPrefix=M,this.onUncaughtError=P,this.onCaughtError=L,this.onRecoverableError=J,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=Ue,this.incompleteTransitions=new Map}function MU(h,g,w,M,P,L,J,ve,Ue,it,gt,vt){return h=new wae(h,g,w,J,Ue,it,gt,vt,ve),g=1,L===!0&&(g|=24),L=Ys(3,null,null,g),h.current=L,L.stateNode=h,g=hk(),g.refCount++,h.pooledCache=g,g.refCount++,L.memoizedState={element:M,isDehydrated:w,cache:g},gk(L),h}function NU(h){return h?(h=$m,h):$m}function kU(h,g,w,M,P,L){P=NU(P),M.context===null?M.context=P:M.pendingContext=P,M=ad(g),M.payload={element:w},L=L===void 0?null:L,L!==null&&(M.callback=L),w=sd(h,M,g),w!==null&&(As(w,h,g),tb(w,h,g))}function EU(h,g){if(h=h.memoizedState,h!==null&&h.dehydrated!==null){var w=h.retryLane;h.retryLane=w!==0&&w<g?w:g}}function RE(h,g){EU(h,g),(h=h.alternate)&&EU(h,g)}function TU(h){if(h.tag===13||h.tag===31){var g=Wh(h,67108864);g!==null&&As(g,h,67108864),RE(h,67108864)}}function AU(h){if(h.tag===13||h.tag===31){var g=to();g=fr(g);var w=Wh(h,g);w!==null&&As(w,h,g),RE(h,g)}}var _w=!0;function _ae(h,g,w,M){var P=K.T;K.T=null;var L=V.p;try{V.p=2,OE(h,g,w,M)}finally{V.p=L,K.T=P}}function Sae(h,g,w,M){var P=K.T;K.T=null;var L=V.p;try{V.p=8,OE(h,g,w,M)}finally{V.p=L,K.T=P}}function OE(h,g,w,M){if(_w){var P=LE(M);if(P===null)wE(h,g,M,Sw,w),jU(h,M);else if(Nae(P,h,g,w,M))M.stopPropagation();else if(jU(h,M),g&4&&-1<Mae.indexOf(h)){for(;P!==null;){var L=he(P);if(L!==null)switch(L.tag){case 3:if(L=L.stateNode,L.current.memoizedState.isDehydrated){var J=ze(L.pendingLanes);if(J!==0){var ve=L;for(ve.pendingLanes|=2,ve.entangledLanes|=2;J;){var Ue=1<<31-Be(J);ve.entanglements[1]|=Ue,J&=~Ue}Kl(L),(ur&6)===0&&(aw=O()+500,xb(0))}}break;case 31:case 13:ve=Wh(L,2),ve!==null&&As(ve,L,2),ow(),RE(L,2)}if(L=LE(M),L===null&&wE(h,g,M,Sw,w),L===P)break;P=L}P!==null&&M.stopPropagation()}else wE(h,g,M,null,w)}}function LE(h){return h=_o(h),FE(h)}var Sw=null;function FE(h){if(Sw=null,h=Et(h),h!==null){var g=a(h);if(g===null)h=null;else{var w=g.tag;if(w===13){if(h=o(g),h!==null)return h;h=null}else if(w===31){if(h=l(g),h!==null)return h;h=null}else if(w===3){if(g.stateNode.current.memoizedState.isDehydrated)return g.tag===3?g.stateNode.containerInfo:null;h=null}else g!==h&&(h=null)}}return Sw=h,null}function CU(h){switch(h){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(ee()){case le:return 2;case _e:return 8;case we:case re:return 32;case Fe:return 268435456;default:return 32}default:return 32}}var IE=!1,xd=null,bd=null,yd=null,Mb=new Map,Nb=new Map,vd=[],Mae="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function jU(h,g){switch(h){case"focusin":case"focusout":xd=null;break;case"dragenter":case"dragleave":bd=null;break;case"mouseover":case"mouseout":yd=null;break;case"pointerover":case"pointerout":Mb.delete(g.pointerId);break;case"gotpointercapture":case"lostpointercapture":Nb.delete(g.pointerId)}}function kb(h,g,w,M,P,L){return h===null||h.nativeEvent!==L?(h={blockedOn:g,domEventName:w,eventSystemFlags:M,nativeEvent:L,targetContainers:[P]},g!==null&&(g=he(g),g!==null&&TU(g)),h):(h.eventSystemFlags|=M,g=h.targetContainers,P!==null&&g.indexOf(P)===-1&&g.push(P),h)}function Nae(h,g,w,M,P){switch(g){case"focusin":return xd=kb(xd,h,g,w,M,P),!0;case"dragenter":return bd=kb(bd,h,g,w,M,P),!0;case"mouseover":return yd=kb(yd,h,g,w,M,P),!0;case"pointerover":var L=P.pointerId;return Mb.set(L,kb(Mb.get(L)||null,h,g,w,M,P)),!0;case"gotpointercapture":return L=P.pointerId,Nb.set(L,kb(Nb.get(L)||null,h,g,w,M,P)),!0}return!1}function PU(h){var g=Et(h.target);if(g!==null){var w=a(g);if(w!==null){if(g=w.tag,g===13){if(g=o(w),g!==null){h.blockedOn=g,mr(h.priority,function(){AU(w)});return}}else if(g===31){if(g=l(w),g!==null){h.blockedOn=g,mr(h.priority,function(){AU(w)});return}}else if(g===3&&w.stateNode.current.memoizedState.isDehydrated){h.blockedOn=w.tag===3?w.stateNode.containerInfo:null;return}}}h.blockedOn=null}function Mw(h){if(h.blockedOn!==null)return!1;for(var g=h.targetContainers;0<g.length;){var w=LE(h.nativeEvent);if(w===null){w=h.nativeEvent;var M=new w.constructor(w.type,w);Ss=M,w.target.dispatchEvent(M),Ss=null}else return g=he(w),g!==null&&TU(g),h.blockedOn=w,!1;g.shift()}return!0}function DU(h,g,w){Mw(h)&&w.delete(g)}function kae(){IE=!1,xd!==null&&Mw(xd)&&(xd=null),bd!==null&&Mw(bd)&&(bd=null),yd!==null&&Mw(yd)&&(yd=null),Mb.forEach(DU),Nb.forEach(DU)}function Nw(h,g){h.blockedOn===g&&(h.blockedOn=null,IE||(IE=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,kae)))}var kw=null;function RU(h){kw!==h&&(kw=h,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){kw===h&&(kw=null);for(var g=0;g<h.length;g+=3){var w=h[g],M=h[g+1],P=h[g+2];if(typeof M!="function"){if(FE(M||w)===null)continue;break}var L=he(w);L!==null&&(h.splice(g,3),g-=3,Lk(L,{pending:!0,data:P,method:w.method,action:M},M,P))}}))}function fp(h){function g(Ue){return Nw(Ue,h)}xd!==null&&Nw(xd,h),bd!==null&&Nw(bd,h),yd!==null&&Nw(yd,h),Mb.forEach(g),Nb.forEach(g);for(var w=0;w<vd.length;w++){var M=vd[w];M.blockedOn===h&&(M.blockedOn=null)}for(;0<vd.length&&(w=vd[0],w.blockedOn===null);)PU(w),w.blockedOn===null&&vd.shift();if(w=(h.ownerDocument||h).$$reactFormReplay,w!=null)for(M=0;M<w.length;M+=3){var P=w[M],L=w[M+1],J=P[bn]||null;if(typeof L=="function")J||RU(w);else if(J){var ve=null;if(L&&L.hasAttribute("formAction")){if(P=L,J=L[bn]||null)ve=J.formAction;else if(FE(P)!==null)continue}else ve=J.action;typeof ve=="function"?w[M+1]=ve:(w.splice(M,3),M-=3),RU(w)}}}function OU(){function h(L){L.canIntercept&&L.info==="react-transition"&&L.intercept({handler:function(){return new Promise(function(J){return P=J})},focusReset:"manual",scroll:"manual"})}function g(){P!==null&&(P(),P=null),M||setTimeout(w,20)}function w(){if(!M&&!navigation.transition){var L=navigation.currentEntry;L&&L.url!=null&&navigation.navigate(L.url,{state:L.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var M=!1,P=null;return navigation.addEventListener("navigate",h),navigation.addEventListener("navigatesuccess",g),navigation.addEventListener("navigateerror",g),setTimeout(w,100),function(){M=!0,navigation.removeEventListener("navigate",h),navigation.removeEventListener("navigatesuccess",g),navigation.removeEventListener("navigateerror",g),P!==null&&(P(),P=null)}}}function UE(h){this._internalRoot=h}Ew.prototype.render=UE.prototype.render=function(h){var g=this._internalRoot;if(g===null)throw Error(r(409));var w=g.current,M=to();kU(w,M,h,g,null,null)},Ew.prototype.unmount=UE.prototype.unmount=function(){var h=this._internalRoot;if(h!==null){this._internalRoot=null;var g=h.containerInfo;kU(h.current,2,null,h,null,null),ow(),g[wi]=null}};function Ew(h){this._internalRoot=h}Ew.prototype.unstable_scheduleHydration=function(h){if(h){var g=ln();h={blockedOn:null,target:h,priority:g};for(var w=0;w<vd.length&&g!==0&&g<vd[w].priority;w++);vd.splice(w,0,h),w===0&&PU(h)}};var LU=e.version;if(LU!=="19.2.0")throw Error(r(527,LU,"19.2.0"));V.findDOMNode=function(h){var g=h._reactInternals;if(g===void 0)throw typeof h.render=="function"?Error(r(188)):(h=Object.keys(h).join(","),Error(r(268,h)));return h=u(g),h=h!==null?d(h):null,h=h===null?null:h.stateNode,h};var Eae={bundleType:0,version:"19.2.0",rendererPackageName:"react-dom",currentDispatcherRef:K,reconcilerVersion:"19.2.0"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Tw=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Tw.isDisabled&&Tw.supportsFiber)try{$e=Tw.inject(Eae),ye=Tw}catch{}}return Tb.createRoot=function(h,g){if(!i(h))throw Error(r(299));var w=!1,M="",P=$I,L=VI,J=GI;return g!=null&&(g.unstable_strictMode===!0&&(w=!0),g.identifierPrefix!==void 0&&(M=g.identifierPrefix),g.onUncaughtError!==void 0&&(P=g.onUncaughtError),g.onCaughtError!==void 0&&(L=g.onCaughtError),g.onRecoverableError!==void 0&&(J=g.onRecoverableError)),g=MU(h,1,!1,null,null,w,M,null,P,L,J,OU),h[wi]=g.current,vE(h),new UE(g)},Tb.hydrateRoot=function(h,g,w){if(!i(h))throw Error(r(299));var M=!1,P="",L=$I,J=VI,ve=GI,Ue=null;return w!=null&&(w.unstable_strictMode===!0&&(M=!0),w.identifierPrefix!==void 0&&(P=w.identifierPrefix),w.onUncaughtError!==void 0&&(L=w.onUncaughtError),w.onCaughtError!==void 0&&(J=w.onCaughtError),w.onRecoverableError!==void 0&&(ve=w.onRecoverableError),w.formState!==void 0&&(Ue=w.formState)),g=MU(h,1,!0,g,w??null,M,P,Ue,L,J,ve,OU),g.context=NU(null),w=g.current,M=to(),M=fr(M),P=ad(M),P.callback=null,sd(w,P,M),w=M,g.current.lanes=w,Bt(g,w),Kl(g),h[wi]=g.current,vE(h),new Ew(g)},Tb.version="19.2.0",Tb}var qU;function Iae(){if(qU)return HE.exports;qU=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),HE.exports=Fae(),HE.exports}var Uae=Iae();const fn=t=>typeof t=="string",Ab=()=>{let t,e;const n=new Promise((r,i)=>{t=r,e=i});return n.resolve=t,n.reject=e,n},WU=t=>t==null?"":""+t,zae=(t,e,n)=>{t.forEach(r=>{e[r]&&(n[r]=e[r])})},Bae=/###/g,KU=t=>t&&t.indexOf("###")>-1?t.replace(Bae,"."):t,XU=t=>!t||fn(t),x0=(t,e,n)=>{const r=fn(e)?e.split("."):e;let i=0;for(;i<r.length-1;){if(XU(t))return{};const a=KU(r[i]);!t[a]&&n&&(t[a]=new n),Object.prototype.hasOwnProperty.call(t,a)?t=t[a]:t={},++i}return XU(t)?{}:{obj:t,k:KU(r[i])}},YU=(t,e,n)=>{const{obj:r,k:i}=x0(t,e,Object);if(r!==void 0||e.length===1){r[i]=n;return}let a=e[e.length-1],o=e.slice(0,e.length-1),l=x0(t,o,Object);for(;l.obj===void 0&&o.length;)a=`${o[o.length-1]}.${a}`,o=o.slice(0,o.length-1),l=x0(t,o,Object),l?.obj&&typeof l.obj[`${l.k}.${a}`]<"u"&&(l.obj=void 0);l.obj[`${l.k}.${a}`]=n},Hae=(t,e,n,r)=>{const{obj:i,k:a}=x0(t,e,Object);i[a]=i[a]||[],i[a].push(n)},U1=(t,e)=>{const{obj:n,k:r}=x0(t,e);if(n&&Object.prototype.hasOwnProperty.call(n,r))return n[r]},$ae=(t,e,n)=>{const r=U1(t,n);return r!==void 0?r:U1(e,n)},vq=(t,e,n)=>{for(const r in e)r!=="__proto__"&&r!=="constructor"&&(r in t?fn(t[r])||t[r]instanceof String||fn(e[r])||e[r]instanceof String?n&&(t[r]=e[r]):vq(t[r],e[r],n):t[r]=e[r]);return t},mp=t=>t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var Vae={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};const Gae=t=>fn(t)?t.replace(/[&<>"'\/]/g,e=>Vae[e]):t;class qae{constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){const n=this.regExpMap.get(e);if(n!==void 0)return n;const r=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,r),this.regExpQueue.push(e),r}}const Wae=[" ",",","?","!",";"],Kae=new qae(20),Xae=(t,e,n)=>{e=e||"",n=n||"";const r=Wae.filter(o=>e.indexOf(o)<0&&n.indexOf(o)<0);if(r.length===0)return!0;const i=Kae.getRegExp(`(${r.map(o=>o==="?"?"\\?":o).join("|")})`);let a=!i.test(t);if(!a){const o=t.indexOf(n);o>0&&!i.test(t.substring(0,o))&&(a=!0)}return a},Yj=(t,e,n=".")=>{if(!t)return;if(t[e])return Object.prototype.hasOwnProperty.call(t,e)?t[e]:void 0;const r=e.split(n);let i=t;for(let a=0;a<r.length;){if(!i||typeof i!="object")return;let o,l="";for(let c=a;c<r.length;++c)if(c!==a&&(l+=n),l+=r[c],o=i[l],o!==void 0){if(["string","number","boolean"].indexOf(typeof o)>-1&&c<r.length-1)continue;a+=c-a+1;break}i=o}return i},B0=t=>t?.replace("_","-"),Yae={type:"logger",log(t){this.output("log",t)},warn(t){this.output("warn",t)},error(t){this.output("error",t)},output(t,e){console?.[t]?.apply?.(console,e)}};class z1{constructor(e,n={}){this.init(e,n)}init(e,n={}){this.prefix=n.prefix||"i18next:",this.logger=e||Yae,this.options=n,this.debug=n.debug}log(...e){return this.forward(e,"log","",!0)}warn(...e){return this.forward(e,"warn","",!0)}error(...e){return this.forward(e,"error","")}deprecate(...e){return this.forward(e,"warn","WARNING DEPRECATED: ",!0)}forward(e,n,r,i){return i&&!this.debug?null:(fn(e[0])&&(e[0]=`${r}${this.prefix} ${e[0]}`),this.logger[n](e))}create(e){return new z1(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new z1(this.logger,e)}}var sc=new z1;let tN=class{constructor(){this.observers={}}on(e,n){return e.split(" ").forEach(r=>{this.observers[r]||(this.observers[r]=new Map);const i=this.observers[r].get(n)||0;this.observers[r].set(n,i+1)}),this}off(e,n){if(this.observers[e]){if(!n){delete this.observers[e];return}this.observers[e].delete(n)}}emit(e,...n){this.observers[e]&&Array.from(this.observers[e].entries()).forEach(([i,a])=>{for(let o=0;o<a;o++)i(...n)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([i,a])=>{for(let o=0;o<a;o++)i.apply(i,[e,...n])})}};class QU extends tN{constructor(e,n={ns:["translation"],defaultNS:"translation"}){super(),this.data=e||{},this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){this.options.ns.indexOf(e)<0&&this.options.ns.push(e)}removeNamespaces(e){const n=this.options.ns.indexOf(e);n>-1&&this.options.ns.splice(n,1)}getResource(e,n,r,i={}){const a=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,o=i.ignoreJSONStructure!==void 0?i.ignoreJSONStructure:this.options.ignoreJSONStructure;let l;e.indexOf(".")>-1?l=e.split("."):(l=[e,n],r&&(Array.isArray(r)?l.push(...r):fn(r)&&a?l.push(...r.split(a)):l.push(r)));const c=U1(this.data,l);return!c&&!n&&!r&&e.indexOf(".")>-1&&(e=l[0],n=l[1],r=l.slice(2).join(".")),c||!o||!fn(r)?c:Yj(this.data?.[e]?.[n],r,a)}addResource(e,n,r,i,a={silent:!1}){const o=a.keySeparator!==void 0?a.keySeparator:this.options.keySeparator;let l=[e,n];r&&(l=l.concat(o?r.split(o):r)),e.indexOf(".")>-1&&(l=e.split("."),i=n,n=l[1]),this.addNamespaces(n),YU(this.data,l,i),a.silent||this.emit("added",e,n,r,i)}addResources(e,n,r,i={silent:!1}){for(const a in r)(fn(r[a])||Array.isArray(r[a]))&&this.addResource(e,n,a,r[a],{silent:!0});i.silent||this.emit("added",e,n,r)}addResourceBundle(e,n,r,i,a,o={silent:!1,skipCopy:!1}){let l=[e,n];e.indexOf(".")>-1&&(l=e.split("."),i=r,r=n,n=l[1]),this.addNamespaces(n);let c=U1(this.data,l)||{};o.skipCopy||(r=JSON.parse(JSON.stringify(r))),i?vq(c,r,a):c={...c,...r},YU(this.data,l,c),o.silent||this.emit("added",e,n,r)}removeResourceBundle(e,n){this.hasResourceBundle(e,n)&&delete this.data[e][n],this.removeNamespaces(n),this.emit("removed",e,n)}hasResourceBundle(e,n){return this.getResource(e,n)!==void 0}getResourceBundle(e,n){return n||(n=this.options.defaultNS),this.getResource(e,n)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){const n=this.getDataByLanguage(e);return!!(n&&Object.keys(n)||[]).find(i=>n[i]&&Object.keys(n[i]).length>0)}toJSON(){return this.data}}var wq={processors:{},addPostProcessor(t){this.processors[t.name]=t},handle(t,e,n,r,i){return t.forEach(a=>{e=this.processors[a]?.process(e,n,r,i)??e}),e}};const _q=Symbol("i18next/PATH_KEY");function Qae(){const t=[],e=Object.create(null);let n;return e.get=(r,i)=>(n?.revoke?.(),i===_q?t:(t.push(i),n=Proxy.revocable(r,e),n.proxy)),Proxy.revocable(Object.create(null),e).proxy}function Qj(t,e){const{[_q]:n}=t(Qae());return n.join(e?.keySeparator??".")}const ZU={},qE=t=>!fn(t)&&typeof t!="boolean"&&typeof t!="number";class B1 extends tN{constructor(e,n={}){super(),zae(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=sc.create("translator")}changeLanguage(e){e&&(this.language=e)}exists(e,n={interpolation:{}}){const r={...n};if(e==null)return!1;const i=this.resolve(e,r);if(i?.res===void 0)return!1;const a=qE(i.res);return!(r.returnObjects===!1&&a)}extractFromKey(e,n){let r=n.nsSeparator!==void 0?n.nsSeparator:this.options.nsSeparator;r===void 0&&(r=":");const i=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator;let a=n.ns||this.options.defaultNS||[];const o=r&&e.indexOf(r)>-1,l=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!Xae(e,r,i);if(o&&!l){const c=e.match(this.interpolator.nestingRegexp);if(c&&c.length>0)return{key:e,namespaces:fn(a)?[a]:a};const u=e.split(r);(r!==i||r===i&&this.options.ns.indexOf(u[0])>-1)&&(a=u.shift()),e=u.join(i)}return{key:e,namespaces:fn(a)?[a]:a}}translate(e,n,r){let i=typeof n=="object"?{...n}:n;if(typeof i!="object"&&this.options.overloadTranslationOptionHandler&&(i=this.options.overloadTranslationOptionHandler(arguments)),typeof i=="object"&&(i={...i}),i||(i={}),e==null)return"";typeof e=="function"&&(e=Qj(e,{...this.options,...i})),Array.isArray(e)||(e=[String(e)]);const a=i.returnDetails!==void 0?i.returnDetails:this.options.returnDetails,o=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,{key:l,namespaces:c}=this.extractFromKey(e[e.length-1],i),u=c[c.length-1];let d=i.nsSeparator!==void 0?i.nsSeparator:this.options.nsSeparator;d===void 0&&(d=":");const f=i.lng||this.language,p=i.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(f?.toLowerCase()==="cimode")return p?a?{res:`${u}${d}${l}`,usedKey:l,exactUsedKey:l,usedLng:f,usedNS:u,usedParams:this.getUsedParamsDetails(i)}:`${u}${d}${l}`:a?{res:l,usedKey:l,exactUsedKey:l,usedLng:f,usedNS:u,usedParams:this.getUsedParamsDetails(i)}:l;const m=this.resolve(e,i);let x=m?.res;const b=m?.usedKey||l,y=m?.exactUsedKey||l,v=["[object Number]","[object Function]","[object RegExp]"],S=i.joinArrays!==void 0?i.joinArrays:this.options.joinArrays,N=!this.i18nFormat||this.i18nFormat.handleAsObject,T=i.count!==void 0&&!fn(i.count),k=B1.hasDefaultValue(i),C=T?this.pluralResolver.getSuffix(f,i.count,i):"",E=i.ordinal&&T?this.pluralResolver.getSuffix(f,i.count,{ordinal:!1}):"",D=T&&!i.ordinal&&i.count===0,A=D&&i[`defaultValue${this.options.pluralSeparator}zero`]||i[`defaultValue${C}`]||i[`defaultValue${E}`]||i.defaultValue;let R=x;N&&!x&&k&&(R=A);const U=qE(R),F=Object.prototype.toString.apply(R);if(N&&R&&U&&v.indexOf(F)<0&&!(fn(S)&&Array.isArray(R))){if(!i.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const $=this.options.returnedObjectHandler?this.options.returnedObjectHandler(b,R,{...i,ns:c}):`key '${l} (${this.language})' returned an object instead of string.`;return a?(m.res=$,m.usedParams=this.getUsedParamsDetails(i),m):$}if(o){const $=Array.isArray(R),j=$?[]:{},H=$?y:b;for(const K in R)if(Object.prototype.hasOwnProperty.call(R,K)){const V=`${H}${o}${K}`;k&&!x?j[K]=this.translate(V,{...i,defaultValue:qE(A)?A[K]:void 0,joinArrays:!1,ns:c}):j[K]=this.translate(V,{...i,joinArrays:!1,ns:c}),j[K]===V&&(j[K]=R[K])}x=j}}else if(N&&fn(S)&&Array.isArray(x))x=x.join(S),x&&(x=this.extendTranslation(x,e,i,r));else{let $=!1,j=!1;!this.isValidLookup(x)&&k&&($=!0,x=A),this.isValidLookup(x)||(j=!0,x=l);const K=(i.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&j?void 0:x,V=k&&A!==x&&this.options.updateMissing;if(j||$||V){if(this.logger.log(V?"updateKey":"missingKey",f,u,l,V?A:x),o){const B=this.resolve(l,{...i,keySeparator:!1});B&&B.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let Q=[];const Z=this.languageUtils.getFallbackCodes(this.options.fallbackLng,i.lng||this.language);if(this.options.saveMissingTo==="fallback"&&Z&&Z[0])for(let B=0;B<Z.length;B++)Q.push(Z[B]);else this.options.saveMissingTo==="all"?Q=this.languageUtils.toResolveHierarchy(i.lng||this.language):Q.push(i.lng||this.language);const ae=(B,X,ne)=>{const se=k&&ne!==x?ne:K;this.options.missingKeyHandler?this.options.missingKeyHandler(B,u,X,se,V,i):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(B,u,X,se,V,i),this.emit("missingKey",B,u,X,x)};this.options.saveMissing&&(this.options.saveMissingPlurals&&T?Q.forEach(B=>{const X=this.pluralResolver.getSuffixes(B,i);D&&i[`defaultValue${this.options.pluralSeparator}zero`]&&X.indexOf(`${this.options.pluralSeparator}zero`)<0&&X.push(`${this.options.pluralSeparator}zero`),X.forEach(ne=>{ae([B],l+ne,i[`defaultValue${ne}`]||A)})}):ae(Q,l,A))}x=this.extendTranslation(x,e,i,m,r),j&&x===l&&this.options.appendNamespaceToMissingKey&&(x=`${u}${d}${l}`),(j||$)&&this.options.parseMissingKeyHandler&&(x=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${u}${d}${l}`:l,$?x:void 0,i))}return a?(m.res=x,m.usedParams=this.getUsedParamsDetails(i),m):x}extendTranslation(e,n,r,i,a){if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...r},r.lng||this.language||i.usedLng,i.usedNS,i.usedKey,{resolved:i});else if(!r.skipInterpolation){r.interpolation&&this.interpolator.init({...r,interpolation:{...this.options.interpolation,...r.interpolation}});const c=fn(e)&&(r?.interpolation?.skipOnVariables!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let u;if(c){const f=e.match(this.interpolator.nestingRegexp);u=f&&f.length}let d=r.replace&&!fn(r.replace)?r.replace:r;if(this.options.interpolation.defaultVariables&&(d={...this.options.interpolation.defaultVariables,...d}),e=this.interpolator.interpolate(e,d,r.lng||this.language||i.usedLng,r),c){const f=e.match(this.interpolator.nestingRegexp),p=f&&f.length;u<p&&(r.nest=!1)}!r.lng&&i&&i.res&&(r.lng=this.language||i.usedLng),r.nest!==!1&&(e=this.interpolator.nest(e,(...f)=>a?.[0]===f[0]&&!r.context?(this.logger.warn(`It seems you are nesting recursively key: ${f[0]} in key: ${n[0]}`),null):this.translate(...f,n),r)),r.interpolation&&this.interpolator.reset()}const o=r.postProcess||this.options.postProcess,l=fn(o)?[o]:o;return e!=null&&l?.length&&r.applyPostProcessor!==!1&&(e=wq.handle(l,e,n,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...i,usedParams:this.getUsedParamsDetails(r)},...r}:r,this)),e}resolve(e,n={}){let r,i,a,o,l;return fn(e)&&(e=[e]),e.forEach(c=>{if(this.isValidLookup(r))return;const u=this.extractFromKey(c,n),d=u.key;i=d;let f=u.namespaces;this.options.fallbackNS&&(f=f.concat(this.options.fallbackNS));const p=n.count!==void 0&&!fn(n.count),m=p&&!n.ordinal&&n.count===0,x=n.context!==void 0&&(fn(n.context)||typeof n.context=="number")&&n.context!=="",b=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);f.forEach(y=>{this.isValidLookup(r)||(l=y,!ZU[`${b[0]}-${y}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(l)&&(ZU[`${b[0]}-${y}`]=!0,this.logger.warn(`key "${i}" for languages "${b.join(", ")}" won't get resolved as namespace "${l}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),b.forEach(v=>{if(this.isValidLookup(r))return;o=v;const S=[d];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(S,d,v,y,n);else{let T;p&&(T=this.pluralResolver.getSuffix(v,n.count,n));const k=`${this.options.pluralSeparator}zero`,C=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(p&&(n.ordinal&&T.indexOf(C)===0&&S.push(d+T.replace(C,this.options.pluralSeparator)),S.push(d+T),m&&S.push(d+k)),x){const E=`${d}${this.options.contextSeparator||"_"}${n.context}`;S.push(E),p&&(n.ordinal&&T.indexOf(C)===0&&S.push(E+T.replace(C,this.options.pluralSeparator)),S.push(E+T),m&&S.push(E+k))}}let N;for(;N=S.pop();)this.isValidLookup(r)||(a=N,r=this.getResource(v,y,N,n))}))})}),{res:r,usedKey:i,exactUsedKey:a,usedLng:o,usedNS:l}}isValidLookup(e){return e!==void 0&&!(!this.options.returnNull&&e===null)&&!(!this.options.returnEmptyString&&e==="")}getResource(e,n,r,i={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(e,n,r,i):this.resourceStore.getResource(e,n,r,i)}getUsedParamsDetails(e={}){const n=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],r=e.replace&&!fn(e.replace);let i=r?e.replace:e;if(r&&typeof e.count<"u"&&(i.count=e.count),this.options.interpolation.defaultVariables&&(i={...this.options.interpolation.defaultVariables,...i}),!r){i={...i};for(const a of n)delete i[a]}return i}static hasDefaultValue(e){const n="defaultValue";for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&n===r.substring(0,n.length)&&e[r]!==void 0)return!0;return!1}}class JU{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=sc.create("languageUtils")}getScriptPartFromCode(e){if(e=B0(e),!e||e.indexOf("-")<0)return null;const n=e.split("-");return n.length===2||(n.pop(),n[n.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(n.join("-"))}getLanguagePartFromCode(e){if(e=B0(e),!e||e.indexOf("-")<0)return e;const n=e.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(e){if(fn(e)&&e.indexOf("-")>-1){let n;try{n=Intl.getCanonicalLocales(e)[0]}catch{}return n&&this.options.lowerCaseLng&&(n=n.toLowerCase()),n||(this.options.lowerCaseLng?e.toLowerCase():e)}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}isSupportedCode(e){return(this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}getBestMatchFromCodes(e){if(!e)return null;let n;return e.forEach(r=>{if(n)return;const i=this.formatLanguageCode(r);(!this.options.supportedLngs||this.isSupportedCode(i))&&(n=i)}),!n&&this.options.supportedLngs&&e.forEach(r=>{if(n)return;const i=this.getScriptPartFromCode(r);if(this.isSupportedCode(i))return n=i;const a=this.getLanguagePartFromCode(r);if(this.isSupportedCode(a))return n=a;n=this.options.supportedLngs.find(o=>{if(o===a)return o;if(!(o.indexOf("-")<0&&a.indexOf("-")<0)&&(o.indexOf("-")>0&&a.indexOf("-")<0&&o.substring(0,o.indexOf("-"))===a||o.indexOf(a)===0&&a.length>1))return o})}),n||(n=this.getFallbackCodes(this.options.fallbackLng)[0]),n}getFallbackCodes(e,n){if(!e)return[];if(typeof e=="function"&&(e=e(n)),fn(e)&&(e=[e]),Array.isArray(e))return e;if(!n)return e.default||[];let r=e[n];return r||(r=e[this.getScriptPartFromCode(n)]),r||(r=e[this.formatLanguageCode(n)]),r||(r=e[this.getLanguagePartFromCode(n)]),r||(r=e.default),r||[]}toResolveHierarchy(e,n){const r=this.getFallbackCodes((n===!1?[]:n)||this.options.fallbackLng||[],e),i=[],a=o=>{o&&(this.isSupportedCode(o)?i.push(o):this.logger.warn(`rejecting language code not found in supportedLngs: ${o}`))};return fn(e)&&(e.indexOf("-")>-1||e.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&a(this.formatLanguageCode(e)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&a(this.getScriptPartFromCode(e)),this.options.load!=="currentOnly"&&a(this.getLanguagePartFromCode(e))):fn(e)&&a(this.formatLanguageCode(e)),r.forEach(o=>{i.indexOf(o)<0&&a(this.formatLanguageCode(o))}),i}}const ez={zero:0,one:1,two:2,few:3,many:4,other:5},tz={select:t=>t===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class Zae{constructor(e,n={}){this.languageUtils=e,this.options=n,this.logger=sc.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,n){this.rules[e]=n}clearCache(){this.pluralRulesCache={}}getRule(e,n={}){const r=B0(e==="dev"?"en":e),i=n.ordinal?"ordinal":"cardinal",a=JSON.stringify({cleanedCode:r,type:i});if(a in this.pluralRulesCache)return this.pluralRulesCache[a];let o;try{o=new Intl.PluralRules(r,{type:i})}catch{if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),tz;if(!e.match(/-|_/))return tz;const c=this.languageUtils.getLanguagePartFromCode(e);o=this.getRule(c,n)}return this.pluralRulesCache[a]=o,o}needsPlural(e,n={}){let r=this.getRule(e,n);return r||(r=this.getRule("dev",n)),r?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(e,n,r={}){return this.getSuffixes(e,r).map(i=>`${n}${i}`)}getSuffixes(e,n={}){let r=this.getRule(e,n);return r||(r=this.getRule("dev",n)),r?r.resolvedOptions().pluralCategories.sort((i,a)=>ez[i]-ez[a]).map(i=>`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${i}`):[]}getSuffix(e,n,r={}){const i=this.getRule(e,r);return i?`${this.options.prepend}${r.ordinal?`ordinal${this.options.prepend}`:""}${i.select(n)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",n,r))}}const nz=(t,e,n,r=".",i=!0)=>{let a=$ae(t,e,n);return!a&&i&&fn(n)&&(a=Yj(t,n,r),a===void 0&&(a=Yj(e,n,r))),a},WE=t=>t.replace(/\$/g,"$$$$");class Jae{constructor(e={}){this.logger=sc.create("interpolator"),this.options=e,this.format=e?.interpolation?.format||(n=>n),this.init(e)}init(e={}){e.interpolation||(e.interpolation={escapeValue:!0});const{escape:n,escapeValue:r,useRawValueToEscape:i,prefix:a,prefixEscaped:o,suffix:l,suffixEscaped:c,formatSeparator:u,unescapeSuffix:d,unescapePrefix:f,nestingPrefix:p,nestingPrefixEscaped:m,nestingSuffix:x,nestingSuffixEscaped:b,nestingOptionsSeparator:y,maxReplaces:v,alwaysFormat:S}=e.interpolation;this.escape=n!==void 0?n:Gae,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=i!==void 0?i:!1,this.prefix=a?mp(a):o||"{{",this.suffix=l?mp(l):c||"}}",this.formatSeparator=u||",",this.unescapePrefix=d?"":f||"-",this.unescapeSuffix=this.unescapePrefix?"":d||"",this.nestingPrefix=p?mp(p):m||mp("$t("),this.nestingSuffix=x?mp(x):b||mp(")"),this.nestingOptionsSeparator=y||",",this.maxReplaces=v||1e3,this.alwaysFormat=S!==void 0?S:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const e=(n,r)=>n?.source===r?(n.lastIndex=0,n):new RegExp(r,"g");this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(e,n,r,i){let a,o,l;const c=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},u=m=>{if(m.indexOf(this.formatSeparator)<0){const v=nz(n,c,m,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(v,void 0,r,{...i,...n,interpolationkey:m}):v}const x=m.split(this.formatSeparator),b=x.shift().trim(),y=x.join(this.formatSeparator).trim();return this.format(nz(n,c,b,this.options.keySeparator,this.options.ignoreJSONStructure),y,r,{...i,...n,interpolationkey:b})};this.resetRegExp();const d=i?.missingInterpolationHandler||this.options.missingInterpolationHandler,f=i?.interpolation?.skipOnVariables!==void 0?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:m=>WE(m)},{regex:this.regexp,safeValue:m=>this.escapeValue?WE(this.escape(m)):WE(m)}].forEach(m=>{for(l=0;a=m.regex.exec(e);){const x=a[1].trim();if(o=u(x),o===void 0)if(typeof d=="function"){const y=d(e,a,i);o=fn(y)?y:""}else if(i&&Object.prototype.hasOwnProperty.call(i,x))o="";else if(f){o=a[0];continue}else this.logger.warn(`missed to pass in variable ${x} for interpolating ${e}`),o="";else!fn(o)&&!this.useRawValueToEscape&&(o=WU(o));const b=m.safeValue(o);if(e=e.replace(a[0],b),f?(m.regex.lastIndex+=o.length,m.regex.lastIndex-=a[0].length):m.regex.lastIndex=0,l++,l>=this.maxReplaces)break}}),e}nest(e,n,r={}){let i,a,o;const l=(c,u)=>{const d=this.nestingOptionsSeparator;if(c.indexOf(d)<0)return c;const f=c.split(new RegExp(`${d}[ ]*{`));let p=`{${f[1]}`;c=f[0],p=this.interpolate(p,o);const m=p.match(/'/g),x=p.match(/"/g);((m?.length??0)%2===0&&!x||x.length%2!==0)&&(p=p.replace(/'/g,'"'));try{o=JSON.parse(p),u&&(o={...u,...o})}catch(b){return this.logger.warn(`failed parsing options string in nesting for key ${c}`,b),`${c}${d}${p}`}return o.defaultValue&&o.defaultValue.indexOf(this.prefix)>-1&&delete o.defaultValue,c};for(;i=this.nestingRegexp.exec(e);){let c=[];o={...r},o=o.replace&&!fn(o.replace)?o.replace:o,o.applyPostProcessor=!1,delete o.defaultValue;const u=/{.*}/.test(i[1])?i[1].lastIndexOf("}")+1:i[1].indexOf(this.formatSeparator);if(u!==-1&&(c=i[1].slice(u).split(this.formatSeparator).map(d=>d.trim()).filter(Boolean),i[1]=i[1].slice(0,u)),a=n(l.call(this,i[1].trim(),o),o),a&&i[0]===e&&!fn(a))return a;fn(a)||(a=WU(a)),a||(this.logger.warn(`missed to resolve ${i[1]} for nesting ${e}`),a=""),c.length&&(a=c.reduce((d,f)=>this.format(d,f,r.lng,{...r,interpolationkey:i[1].trim()}),a.trim())),e=e.replace(i[0],a),this.regexp.lastIndex=0}return e}}const ese=t=>{let e=t.toLowerCase().trim();const n={};if(t.indexOf("(")>-1){const r=t.split("(");e=r[0].toLowerCase().trim();const i=r[1].substring(0,r[1].length-1);e==="currency"&&i.indexOf(":")<0?n.currency||(n.currency=i.trim()):e==="relativetime"&&i.indexOf(":")<0?n.range||(n.range=i.trim()):i.split(";").forEach(o=>{if(o){const[l,...c]=o.split(":"),u=c.join(":").trim().replace(/^'+|'+$/g,""),d=l.trim();n[d]||(n[d]=u),u==="false"&&(n[d]=!1),u==="true"&&(n[d]=!0),isNaN(u)||(n[d]=parseInt(u,10))}})}return{formatName:e,formatOptions:n}},rz=t=>{const e={};return(n,r,i)=>{let a=i;i&&i.interpolationkey&&i.formatParams&&i.formatParams[i.interpolationkey]&&i[i.interpolationkey]&&(a={...a,[i.interpolationkey]:void 0});const o=r+JSON.stringify(a);let l=e[o];return l||(l=t(B0(r),i),e[o]=l),l(n)}},tse=t=>(e,n,r)=>t(B0(n),r)(e);class nse{constructor(e={}){this.logger=sc.create("formatter"),this.options=e,this.init(e)}init(e,n={interpolation:{}}){this.formatSeparator=n.interpolation.formatSeparator||",";const r=n.cacheInBuiltFormats?rz:tse;this.formats={number:r((i,a)=>{const o=new Intl.NumberFormat(i,{...a});return l=>o.format(l)}),currency:r((i,a)=>{const o=new Intl.NumberFormat(i,{...a,style:"currency"});return l=>o.format(l)}),datetime:r((i,a)=>{const o=new Intl.DateTimeFormat(i,{...a});return l=>o.format(l)}),relativetime:r((i,a)=>{const o=new Intl.RelativeTimeFormat(i,{...a});return l=>o.format(l,a.range||"day")}),list:r((i,a)=>{const o=new Intl.ListFormat(i,{...a});return l=>o.format(l)})}}add(e,n){this.formats[e.toLowerCase().trim()]=n}addCached(e,n){this.formats[e.toLowerCase().trim()]=rz(n)}format(e,n,r,i={}){const a=n.split(this.formatSeparator);if(a.length>1&&a[0].indexOf("(")>1&&a[0].indexOf(")")<0&&a.find(l=>l.indexOf(")")>-1)){const l=a.findIndex(c=>c.indexOf(")")>-1);a[0]=[a[0],...a.splice(1,l)].join(this.formatSeparator)}return a.reduce((l,c)=>{const{formatName:u,formatOptions:d}=ese(c);if(this.formats[u]){let f=l;try{const p=i?.formatParams?.[i.interpolationkey]||{},m=p.locale||p.lng||i.locale||i.lng||r;f=this.formats[u](l,m,{...d,...i,...p})}catch(p){this.logger.warn(p)}return f}else this.logger.warn(`there was no format function for ${u}`);return l},e)}}const rse=(t,e)=>{t.pending[e]!==void 0&&(delete t.pending[e],t.pendingCount--)};class ise extends tN{constructor(e,n,r,i={}){super(),this.backend=e,this.store=n,this.services=r,this.languageUtils=r.languageUtils,this.options=i,this.logger=sc.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=i.maxParallelReads||10,this.readingCalls=0,this.maxRetries=i.maxRetries>=0?i.maxRetries:5,this.retryTimeout=i.retryTimeout>=1?i.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(r,i.backend,i)}queueLoad(e,n,r,i){const a={},o={},l={},c={};return e.forEach(u=>{let d=!0;n.forEach(f=>{const p=`${u}|${f}`;!r.reload&&this.store.hasResourceBundle(u,f)?this.state[p]=2:this.state[p]<0||(this.state[p]===1?o[p]===void 0&&(o[p]=!0):(this.state[p]=1,d=!1,o[p]===void 0&&(o[p]=!0),a[p]===void 0&&(a[p]=!0),c[f]===void 0&&(c[f]=!0)))}),d||(l[u]=!0)}),(Object.keys(a).length||Object.keys(o).length)&&this.queue.push({pending:o,pendingCount:Object.keys(o).length,loaded:{},errors:[],callback:i}),{toLoad:Object.keys(a),pending:Object.keys(o),toLoadLanguages:Object.keys(l),toLoadNamespaces:Object.keys(c)}}loaded(e,n,r){const i=e.split("|"),a=i[0],o=i[1];n&&this.emit("failedLoading",a,o,n),!n&&r&&this.store.addResourceBundle(a,o,r,void 0,void 0,{skipCopy:!0}),this.state[e]=n?-1:2,n&&r&&(this.state[e]=0);const l={};this.queue.forEach(c=>{Hae(c.loaded,[a],o),rse(c,e),n&&c.errors.push(n),c.pendingCount===0&&!c.done&&(Object.keys(c.loaded).forEach(u=>{l[u]||(l[u]={});const d=c.loaded[u];d.length&&d.forEach(f=>{l[u][f]===void 0&&(l[u][f]=!0)})}),c.done=!0,c.errors.length?c.callback(c.errors):c.callback())}),this.emit("loaded",l),this.queue=this.queue.filter(c=>!c.done)}read(e,n,r,i=0,a=this.retryTimeout,o){if(!e.length)return o(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:n,fcName:r,tried:i,wait:a,callback:o});return}this.readingCalls++;const l=(u,d)=>{if(this.readingCalls--,this.waitingReads.length>0){const f=this.waitingReads.shift();this.read(f.lng,f.ns,f.fcName,f.tried,f.wait,f.callback)}if(u&&d&&i<this.maxRetries){setTimeout(()=>{this.read.call(this,e,n,r,i+1,a*2,o)},a);return}o(u,d)},c=this.backend[r].bind(this.backend);if(c.length===2){try{const u=c(e,n);u&&typeof u.then=="function"?u.then(d=>l(null,d)).catch(l):l(null,u)}catch(u){l(u)}return}return c(e,n,l)}prepareLoading(e,n,r={},i){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),i&&i();fn(e)&&(e=this.languageUtils.toResolveHierarchy(e)),fn(n)&&(n=[n]);const a=this.queueLoad(e,n,r,i);if(!a.toLoad.length)return a.pending.length||i(),null;a.toLoad.forEach(o=>{this.loadOne(o)})}load(e,n,r){this.prepareLoading(e,n,{},r)}reload(e,n,r){this.prepareLoading(e,n,{reload:!0},r)}loadOne(e,n=""){const r=e.split("|"),i=r[0],a=r[1];this.read(i,a,"read",void 0,void 0,(o,l)=>{o&&this.logger.warn(`${n}loading namespace ${a} for language ${i} failed`,o),!o&&l&&this.logger.log(`${n}loaded namespace ${a} for language ${i}`,l),this.loaded(e,o,l)})}saveMissing(e,n,r,i,a,o={},l=()=>{}){if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(n)){this.logger.warn(`did not save key "${r}" as the namespace "${n}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(r==null||r==="")){if(this.backend?.create){const c={...o,isUpdate:a},u=this.backend.create.bind(this.backend);if(u.length<6)try{let d;u.length===5?d=u(e,n,r,i,c):d=u(e,n,r,i),d&&typeof d.then=="function"?d.then(f=>l(null,f)).catch(l):l(null,d)}catch(d){l(d)}else u(e,n,r,i,l,c)}!e||!e[0]||this.store.addResource(e[0],n,r,i)}}}const iz=()=>({debug:!1,initAsync:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:t=>{let e={};if(typeof t[1]=="object"&&(e=t[1]),fn(t[1])&&(e.defaultValue=t[1]),fn(t[2])&&(e.tDescription=t[2]),typeof t[2]=="object"||typeof t[3]=="object"){const n=t[3]||t[2];Object.keys(n).forEach(r=>{e[r]=n[r]})}return e},interpolation:{escapeValue:!0,format:t=>t,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),az=t=>(fn(t.ns)&&(t.ns=[t.ns]),fn(t.fallbackLng)&&(t.fallbackLng=[t.fallbackLng]),fn(t.fallbackNS)&&(t.fallbackNS=[t.fallbackNS]),t.supportedLngs?.indexOf?.("cimode")<0&&(t.supportedLngs=t.supportedLngs.concat(["cimode"])),typeof t.initImmediate=="boolean"&&(t.initAsync=t.initImmediate),t),Cw=()=>{},ase=t=>{Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(n=>{typeof t[n]=="function"&&(t[n]=t[n].bind(t))})};class b0 extends tN{constructor(e={},n){if(super(),this.options=az(e),this.services={},this.logger=sc,this.modules={external:[]},ase(this),n&&!this.isInitialized&&!e.isClone){if(!this.options.initAsync)return this.init(e,n),this;setTimeout(()=>{this.init(e,n)},0)}}init(e={},n){this.isInitializing=!0,typeof e=="function"&&(n=e,e={}),e.defaultNS==null&&e.ns&&(fn(e.ns)?e.defaultNS=e.ns:e.ns.indexOf("translation")<0&&(e.defaultNS=e.ns[0]));const r=iz();this.options={...r,...this.options,...az(e)},this.options.interpolation={...r.interpolation,...this.options.interpolation},e.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=e.keySeparator),e.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=e.nsSeparator);const i=u=>u?typeof u=="function"?new u:u:null;if(!this.options.isClone){this.modules.logger?sc.init(i(this.modules.logger),this.options):sc.init(null,this.options);let u;this.modules.formatter?u=this.modules.formatter:u=nse;const d=new JU(this.options);this.store=new QU(this.options.resources,this.options);const f=this.services;f.logger=sc,f.resourceStore=this.store,f.languageUtils=d,f.pluralResolver=new Zae(d,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),this.options.interpolation.format&&this.options.interpolation.format!==r.interpolation.format&&this.logger.deprecate("init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting"),u&&(!this.options.interpolation.format||this.options.interpolation.format===r.interpolation.format)&&(f.formatter=i(u),f.formatter.init&&f.formatter.init(f,this.options),this.options.interpolation.format=f.formatter.format.bind(f.formatter)),f.interpolator=new Jae(this.options),f.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},f.backendConnector=new ise(i(this.modules.backend),f.resourceStore,f,this.options),f.backendConnector.on("*",(m,...x)=>{this.emit(m,...x)}),this.modules.languageDetector&&(f.languageDetector=i(this.modules.languageDetector),f.languageDetector.init&&f.languageDetector.init(f,this.options.detection,this.options)),this.modules.i18nFormat&&(f.i18nFormat=i(this.modules.i18nFormat),f.i18nFormat.init&&f.i18nFormat.init(this)),this.translator=new B1(this.services,this.options),this.translator.on("*",(m,...x)=>{this.emit(m,...x)}),this.modules.external.forEach(m=>{m.init&&m.init(this)})}if(this.format=this.options.interpolation.format,n||(n=Cw),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const u=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);u.length>0&&u[0]!=="dev"&&(this.options.lng=u[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(u=>{this[u]=(...d)=>this.store[u](...d)}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(u=>{this[u]=(...d)=>(this.store[u](...d),this)});const l=Ab(),c=()=>{const u=(d,f)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),l.resolve(f),n(d,f)};if(this.languages&&!this.isInitialized)return u(null,this.t.bind(this));this.changeLanguage(this.options.lng,u)};return this.options.resources||!this.options.initAsync?c():setTimeout(c,0),l}loadResources(e,n=Cw){let r=n;const i=fn(e)?e:this.language;if(typeof e=="function"&&(r=e),!this.options.resources||this.options.partialBundledLanguages){if(i?.toLowerCase()==="cimode"&&(!this.options.preload||this.options.preload.length===0))return r();const a=[],o=l=>{if(!l||l==="cimode")return;this.services.languageUtils.toResolveHierarchy(l).forEach(u=>{u!=="cimode"&&a.indexOf(u)<0&&a.push(u)})};i?o(i):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(c=>o(c)),this.options.preload?.forEach?.(l=>o(l)),this.services.backendConnector.load(a,this.options.ns,l=>{!l&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),r(l)})}else r(null)}reloadResources(e,n,r){const i=Ab();return typeof e=="function"&&(r=e,e=void 0),typeof n=="function"&&(r=n,n=void 0),e||(e=this.languages),n||(n=this.options.ns),r||(r=Cw),this.services.backendConnector.reload(e,n,a=>{i.resolve(),r(a)}),i}use(e){if(!e)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!e.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return e.type==="backend"&&(this.modules.backend=e),(e.type==="logger"||e.log&&e.warn&&e.error)&&(this.modules.logger=e),e.type==="languageDetector"&&(this.modules.languageDetector=e),e.type==="i18nFormat"&&(this.modules.i18nFormat=e),e.type==="postProcessor"&&wq.addPostProcessor(e),e.type==="formatter"&&(this.modules.formatter=e),e.type==="3rdParty"&&this.modules.external.push(e),this}setResolvedLanguage(e){if(!(!e||!this.languages)&&!(["cimode","dev"].indexOf(e)>-1)){for(let n=0;n<this.languages.length;n++){const r=this.languages[n];if(!(["cimode","dev"].indexOf(r)>-1)&&this.store.hasLanguageSomeTranslations(r)){this.resolvedLanguage=r;break}}!this.resolvedLanguage&&this.languages.indexOf(e)<0&&this.store.hasLanguageSomeTranslations(e)&&(this.resolvedLanguage=e,this.languages.unshift(e))}}changeLanguage(e,n){this.isLanguageChangingTo=e;const r=Ab();this.emit("languageChanging",e);const i=l=>{this.language=l,this.languages=this.services.languageUtils.toResolveHierarchy(l),this.resolvedLanguage=void 0,this.setResolvedLanguage(l)},a=(l,c)=>{c?this.isLanguageChangingTo===e&&(i(c),this.translator.changeLanguage(c),this.isLanguageChangingTo=void 0,this.emit("languageChanged",c),this.logger.log("languageChanged",c)):this.isLanguageChangingTo=void 0,r.resolve((...u)=>this.t(...u)),n&&n(l,(...u)=>this.t(...u))},o=l=>{!e&&!l&&this.services.languageDetector&&(l=[]);const c=fn(l)?l:l&&l[0],u=this.store.hasLanguageSomeTranslations(c)?c:this.services.languageUtils.getBestMatchFromCodes(fn(l)?[l]:l);u&&(this.language||i(u),this.translator.language||this.translator.changeLanguage(u),this.services.languageDetector?.cacheUserLanguage?.(u)),this.loadResources(u,d=>{a(d,u)})};return!e&&this.services.languageDetector&&!this.services.languageDetector.async?o(this.services.languageDetector.detect()):!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(o):this.services.languageDetector.detect(o):o(e),r}getFixedT(e,n,r){const i=(a,o,...l)=>{let c;typeof o!="object"?c=this.options.overloadTranslationOptionHandler([a,o].concat(l)):c={...o},c.lng=c.lng||i.lng,c.lngs=c.lngs||i.lngs,c.ns=c.ns||i.ns,c.keyPrefix!==""&&(c.keyPrefix=c.keyPrefix||r||i.keyPrefix);const u=this.options.keySeparator||".";let d;return c.keyPrefix&&Array.isArray(a)?d=a.map(f=>(typeof f=="function"&&(f=Qj(f,{...this.options,...o})),`${c.keyPrefix}${u}${f}`)):(typeof a=="function"&&(a=Qj(a,{...this.options,...o})),d=c.keyPrefix?`${c.keyPrefix}${u}${a}`:a),this.t(d,c)};return fn(e)?i.lng=e:i.lngs=e,i.ns=n,i.keyPrefix=r,i}t(...e){return this.translator?.translate(...e)}exists(...e){return this.translator?.exists(...e)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e,n={}){if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;const r=n.lng||this.resolvedLanguage||this.languages[0],i=this.options?this.options.fallbackLng:!1,a=this.languages[this.languages.length-1];if(r.toLowerCase()==="cimode")return!0;const o=(l,c)=>{const u=this.services.backendConnector.state[`${l}|${c}`];return u===-1||u===0||u===2};if(n.precheck){const l=n.precheck(this,o);if(l!==void 0)return l}return!!(this.hasResourceBundle(r,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||o(r,e)&&(!i||o(a,e)))}loadNamespaces(e,n){const r=Ab();return this.options.ns?(fn(e)&&(e=[e]),e.forEach(i=>{this.options.ns.indexOf(i)<0&&this.options.ns.push(i)}),this.loadResources(i=>{r.resolve(),n&&n(i)}),r):(n&&n(),Promise.resolve())}loadLanguages(e,n){const r=Ab();fn(e)&&(e=[e]);const i=this.options.preload||[],a=e.filter(o=>i.indexOf(o)<0&&this.services.languageUtils.isSupportedCode(o));return a.length?(this.options.preload=i.concat(a),this.loadResources(o=>{r.resolve(),n&&n(o)}),r):(n&&n(),Promise.resolve())}dir(e){if(e||(e=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language)),!e)return"rtl";try{const i=new Intl.Locale(e);if(i&&i.getTextInfo){const a=i.getTextInfo();if(a&&a.direction)return a.direction}}catch{}const n=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"],r=this.services?.languageUtils||new JU(iz());return e.toLowerCase().indexOf("-latn")>1?"ltr":n.indexOf(r.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(e={},n){const r=new b0(e,n);return r.createInstance=b0.createInstance,r}cloneInstance(e={},n=Cw){const r=e.forkResourceStore;r&&delete e.forkResourceStore;const i={...this.options,...e,isClone:!0},a=new b0(i);if((e.debug!==void 0||e.prefix!==void 0)&&(a.logger=a.logger.clone(e)),["store","services","language"].forEach(l=>{a[l]=this[l]}),a.services={...this.services},a.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},r){const l=Object.keys(this.store.data).reduce((c,u)=>(c[u]={...this.store.data[u]},c[u]=Object.keys(c[u]).reduce((d,f)=>(d[f]={...c[u][f]},d),c[u]),c),{});a.store=new QU(l,i),a.services.resourceStore=a.store}return a.translator=new B1(a.services,i),a.translator.on("*",(l,...c)=>{a.emit(l,...c)}),a.init(i,n),a.translator.options=i,a.translator.backendConnector.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},a}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const _s=b0.createInstance();_s.createInstance;_s.dir;_s.init;_s.loadResources;_s.reloadResources;_s.use;_s.changeLanguage;_s.getFixedT;_s.t;_s.exists;_s.setDefaultNamespace;_s.hasLoadedNamespace;_s.loadNamespaces;_s.loadLanguages;const sse=(t,e,n,r)=>{const i=[n,{code:e,...r||{}}];if(t?.services?.logger?.forward)return t.services.logger.forward(i,"warn","react-i18next::",!0);em(i[0])&&(i[0]=`react-i18next:: ${i[0]}`),t?.services?.logger?.warn?t.services.logger.warn(...i):console?.warn&&console.warn(...i)},sz={},Sq=(t,e,n,r)=>{em(n)&&sz[n]||(em(n)&&(sz[n]=new Date),sse(t,e,n,r))},Mq=(t,e)=>()=>{if(t.isInitialized)e();else{const n=()=>{setTimeout(()=>{t.off("initialized",n)},0),e()};t.on("initialized",n)}},Zj=(t,e,n)=>{t.loadNamespaces(e,Mq(t,n))},oz=(t,e,n,r)=>{if(em(n)&&(n=[n]),t.options.preload&&t.options.preload.indexOf(e)>-1)return Zj(t,n,r);n.forEach(i=>{t.options.ns.indexOf(i)<0&&t.options.ns.push(i)}),t.loadLanguages(e,Mq(t,r))},ose=(t,e,n={})=>!e.languages||!e.languages.length?(Sq(e,"NO_LANGUAGES","i18n.languages were undefined or empty",{languages:e.languages}),!0):e.hasLoadedNamespace(t,{lng:n.lng,precheck:(r,i)=>{if(n.bindI18n&&n.bindI18n.indexOf("languageChanging")>-1&&r.services.backendConnector.backend&&r.isLanguageChangingTo&&!i(r.isLanguageChangingTo,t))return!1}}),em=t=>typeof t=="string",lse=t=>typeof t=="object"&&t!==null,cse=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,use={"&":"&","&":"&","<":"<","<":"<",">":">",">":">","'":"'","'":"'",""":'"',""":'"'," ":" "," ":" ","©":"©","©":"©","®":"®","®":"®","…":"…","…":"…","/":"/","/":"/"},dse=t=>use[t],hse=t=>t.replace(cse,dse);let Jj={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:hse};const fse=(t={})=>{Jj={...Jj,...t}},mse=()=>Jj;let Nq;const pse=t=>{Nq=t},gse=()=>Nq,xse={type:"3rdParty",init(t){fse(t.options.react),pse(t)}},bse=_.createContext();class yse{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach(n=>{this.usedNamespaces[n]||(this.usedNamespaces[n]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}var KE={exports:{}},XE={};var lz;function vse(){if(lz)return XE;lz=1;var t=px();function e(f,p){return f===p&&(f!==0||1/f===1/p)||f!==f&&p!==p}var n=typeof Object.is=="function"?Object.is:e,r=t.useState,i=t.useEffect,a=t.useLayoutEffect,o=t.useDebugValue;function l(f,p){var m=p(),x=r({inst:{value:m,getSnapshot:p}}),b=x[0].inst,y=x[1];return a(function(){b.value=m,b.getSnapshot=p,c(b)&&y({inst:b})},[f,m,p]),i(function(){return c(b)&&y({inst:b}),f(function(){c(b)&&y({inst:b})})},[f]),o(m),m}function c(f){var p=f.getSnapshot;f=f.value;try{var m=p();return!n(f,m)}catch{return!0}}function u(f,p){return p()}var d=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?u:l;return XE.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:d,XE}var cz;function kq(){return cz||(cz=1,KE.exports=vse()),KE.exports}var fR=kq();const wse=(t,e)=>em(e)?e:lse(e)&&em(e.defaultValue)?e.defaultValue:Array.isArray(t)?t[t.length-1]:t,_se={t:wse,ready:!1},Sse=()=>()=>{},Hn=(t,e={})=>{const{i18n:n}=e,{i18n:r,defaultNS:i}=_.useContext(bse)||{},a=n||r||gse();a&&!a.reportNamespaces&&(a.reportNamespaces=new yse),a||Sq(a,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const o=_.useMemo(()=>({...mse(),...a?.options?.react,...e}),[a,e]),{useSuspense:l,keyPrefix:c}=o,u=i||a?.options?.defaultNS,d=em(u)?[u]:u||["translation"],f=_.useMemo(()=>d,d);a?.reportNamespaces?.addUsedNamespaces?.(f);const p=_.useRef(0),m=_.useCallback(A=>{if(!a)return Sse;const{bindI18n:R,bindI18nStore:U}=o,F=()=>{p.current+=1,A()};return R&&a.on(R,F),U&&a.store.on(U,F),()=>{R&&R.split(" ").forEach($=>a.off($,F)),U&&U.split(" ").forEach($=>a.store.off($,F))}},[a,o]),x=_.useRef(),b=_.useCallback(()=>{if(!a)return _se;const A=!!(a.isInitialized||a.initializedStoreOnce)&&f.every(H=>ose(H,a,o)),R=e.lng||a.language,U=p.current,F=x.current;if(F&&F.ready===A&&F.lng===R&&F.keyPrefix===c&&F.revision===U)return F;const j={t:a.getFixedT(R,o.nsMode==="fallback"?f:f[0],c),ready:A,lng:R,keyPrefix:c,revision:U};return x.current=j,j},[a,f,c,o,e.lng]),[y,v]=_.useState(0),{t:S,ready:N}=fR.useSyncExternalStore(m,b,b);_.useEffect(()=>{if(a&&!N&&!l){const A=()=>v(R=>R+1);e.lng?oz(a,e.lng,f,A):Zj(a,f,A)}},[a,e.lng,f,N,l,y]);const T=a||{},k=_.useRef(null),C=_.useRef(),E=A=>{const R=Object.getOwnPropertyDescriptors(A);R.__original&&delete R.__original;const U=Object.create(Object.getPrototypeOf(A),R);if(!Object.prototype.hasOwnProperty.call(U,"__original"))try{Object.defineProperty(U,"__original",{value:A,writable:!1,enumerable:!1,configurable:!1})}catch{}return U},D=_.useMemo(()=>{const A=T,R=A?.language;let U=A;A&&(k.current&&k.current.__original===A?C.current!==R?(U=E(A),k.current=U,C.current=R):U=k.current:(U=E(A),k.current=U,C.current=R));const F=[S,U,N];return F.t=S,F.i18n=U,F.ready=N,F},[S,T,N,T.resolvedLanguage,T.language,T.languages]);if(a&&l&&!N)throw new Promise(A=>{const R=()=>A();e.lng?oz(a,e.lng,f,R):Zj(a,f,R)});return D},{slice:Mse,forEach:Nse}=[];function kse(t){return Nse.call(Mse.call(arguments,1),e=>{if(e)for(const n in e)t[n]===void 0&&(t[n]=e[n])}),t}function Ese(t){return typeof t!="string"?!1:[/<\s*script.*?>/i,/<\s*\/\s*script\s*>/i,/<\s*img.*?on\w+\s*=/i,/<\s*\w+\s*on\w+\s*=.*?>/i,/javascript\s*:/i,/vbscript\s*:/i,/expression\s*\(/i,/eval\s*\(/i,/alert\s*\(/i,/document\.cookie/i,/document\.write\s*\(/i,/window\.location/i,/innerHTML/i].some(n=>n.test(t))}const uz=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,Tse=function(t,e){const r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{path:"/"},i=encodeURIComponent(e);let a=`${t}=${i}`;if(r.maxAge>0){const o=r.maxAge-0;if(Number.isNaN(o))throw new Error("maxAge should be a Number");a+=`; Max-Age=${Math.floor(o)}`}if(r.domain){if(!uz.test(r.domain))throw new TypeError("option domain is invalid");a+=`; Domain=${r.domain}`}if(r.path){if(!uz.test(r.path))throw new TypeError("option path is invalid");a+=`; Path=${r.path}`}if(r.expires){if(typeof r.expires.toUTCString!="function")throw new TypeError("option expires is invalid");a+=`; Expires=${r.expires.toUTCString()}`}if(r.httpOnly&&(a+="; HttpOnly"),r.secure&&(a+="; Secure"),r.sameSite)switch(typeof r.sameSite=="string"?r.sameSite.toLowerCase():r.sameSite){case!0:a+="; SameSite=Strict";break;case"lax":a+="; SameSite=Lax";break;case"strict":a+="; SameSite=Strict";break;case"none":a+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}return r.partitioned&&(a+="; Partitioned"),a},dz={create(t,e,n,r){let i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{path:"/",sameSite:"strict"};n&&(i.expires=new Date,i.expires.setTime(i.expires.getTime()+n*60*1e3)),r&&(i.domain=r),document.cookie=Tse(t,e,i)},read(t){const e=`${t}=`,n=document.cookie.split(";");for(let r=0;r<n.length;r++){let i=n[r];for(;i.charAt(0)===" ";)i=i.substring(1,i.length);if(i.indexOf(e)===0)return i.substring(e.length,i.length)}return null},remove(t,e){this.create(t,"",-1,e)}};var Ase={name:"cookie",lookup(t){let{lookupCookie:e}=t;if(e&&typeof document<"u")return dz.read(e)||void 0},cacheUserLanguage(t,e){let{lookupCookie:n,cookieMinutes:r,cookieDomain:i,cookieOptions:a}=e;n&&typeof document<"u"&&dz.create(n,t,r,i,a)}},Cse={name:"querystring",lookup(t){let{lookupQuerystring:e}=t,n;if(typeof window<"u"){let{search:r}=window.location;!window.location.search&&window.location.hash?.indexOf("?")>-1&&(r=window.location.hash.substring(window.location.hash.indexOf("?")));const a=r.substring(1).split("&");for(let o=0;o<a.length;o++){const l=a[o].indexOf("=");l>0&&a[o].substring(0,l)===e&&(n=a[o].substring(l+1))}}return n}},jse={name:"hash",lookup(t){let{lookupHash:e,lookupFromHashIndex:n}=t,r;if(typeof window<"u"){const{hash:i}=window.location;if(i&&i.length>2){const a=i.substring(1);if(e){const o=a.split("&");for(let l=0;l<o.length;l++){const c=o[l].indexOf("=");c>0&&o[l].substring(0,c)===e&&(r=o[l].substring(c+1))}}if(r)return r;if(!r&&n>-1){const o=i.match(/\/([a-zA-Z-]*)/g);return Array.isArray(o)?o[typeof n=="number"?n:0]?.replace("/",""):void 0}}}return r}};let pp=null;const hz=()=>{if(pp!==null)return pp;try{if(pp=typeof window<"u"&&window.localStorage!==null,!pp)return!1;const t="i18next.translate.boo";window.localStorage.setItem(t,"foo"),window.localStorage.removeItem(t)}catch{pp=!1}return pp};var Pse={name:"localStorage",lookup(t){let{lookupLocalStorage:e}=t;if(e&&hz())return window.localStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupLocalStorage:n}=e;n&&hz()&&window.localStorage.setItem(n,t)}};let gp=null;const fz=()=>{if(gp!==null)return gp;try{if(gp=typeof window<"u"&&window.sessionStorage!==null,!gp)return!1;const t="i18next.translate.boo";window.sessionStorage.setItem(t,"foo"),window.sessionStorage.removeItem(t)}catch{gp=!1}return gp};var Dse={name:"sessionStorage",lookup(t){let{lookupSessionStorage:e}=t;if(e&&fz())return window.sessionStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupSessionStorage:n}=e;n&&fz()&&window.sessionStorage.setItem(n,t)}},Rse={name:"navigator",lookup(t){const e=[];if(typeof navigator<"u"){const{languages:n,userLanguage:r,language:i}=navigator;if(n)for(let a=0;a<n.length;a++)e.push(n[a]);r&&e.push(r),i&&e.push(i)}return e.length>0?e:void 0}},Ose={name:"htmlTag",lookup(t){let{htmlTag:e}=t,n;const r=e||(typeof document<"u"?document.documentElement:null);return r&&typeof r.getAttribute=="function"&&(n=r.getAttribute("lang")),n}},Lse={name:"path",lookup(t){let{lookupFromPathIndex:e}=t;if(typeof window>"u")return;const n=window.location.pathname.match(/\/([a-zA-Z-]*)/g);return Array.isArray(n)?n[typeof e=="number"?e:0]?.replace("/",""):void 0}},Fse={name:"subdomain",lookup(t){let{lookupFromSubdomainIndex:e}=t;const n=typeof e=="number"?e+1:1,r=typeof window<"u"&&window.location?.hostname?.match(/^(\w{2,5})\.(([a-z0-9-]{1,63}\.[a-z]{2,6})|localhost)/i);if(r)return r[n]}};let Eq=!1;try{document.cookie,Eq=!0}catch{}const Tq=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];Eq||Tq.splice(1,1);const Ise=()=>({order:Tq,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:t=>t});class Aq{constructor(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.type="languageDetector",this.detectors={},this.init(e,n)}init(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{languageUtils:{}},n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};this.services=e,this.options=kse(n,this.options||{},Ise()),typeof this.options.convertDetectedLanguage=="string"&&this.options.convertDetectedLanguage.indexOf("15897")>-1&&(this.options.convertDetectedLanguage=i=>i.replace("-","_")),this.options.lookupFromUrlIndex&&(this.options.lookupFromPathIndex=this.options.lookupFromUrlIndex),this.i18nOptions=r,this.addDetector(Ase),this.addDetector(Cse),this.addDetector(Pse),this.addDetector(Dse),this.addDetector(Rse),this.addDetector(Ose),this.addDetector(Lse),this.addDetector(Fse),this.addDetector(jse)}addDetector(e){return this.detectors[e.name]=e,this}detect(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.options.order,n=[];return e.forEach(r=>{if(this.detectors[r]){let i=this.detectors[r].lookup(this.options);i&&typeof i=="string"&&(i=[i]),i&&(n=n.concat(i))}}),n=n.filter(r=>r!=null&&!Ese(r)).map(r=>this.options.convertDetectedLanguage(r)),this.services&&this.services.languageUtils&&this.services.languageUtils.getBestMatchFromCodes?n:n.length>0?n[0]:null}cacheUserLanguage(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.options.caches;n&&(this.options.excludeCacheFor&&this.options.excludeCacheFor.indexOf(e)>-1||n.forEach(r=>{this.detectors[r]&&this.detectors[r].cacheUserLanguage(e,this.options)}))}}Aq.type="languageDetector";const Use={nav:{printers:"Printers",archives:"Archives",queue:"Queue",stats:"Statistics",profiles:"Profiles",maintenance:"Maintenance",projects:"Projects",files:"File Manager",settings:"Settings",system:"System",collapseSidebar:"Collapse sidebar",expandSidebar:"Expand sidebar",update:"Update",updateAvailable:"Update available: v{{version}}",updateAvailableBanner:"Version {{version}} is available!",viewUpdate:"View update",viewOnGithub:"View on GitHub",keyboardShortcuts:"Keyboard shortcuts (?)",switchToLight:"Switch to light mode",switchToDark:"Switch to dark mode",smartSwitches:"Smart Switches",logout:"Logout"},common:{save:"Save",saving:"Saving...",cancel:"Cancel",delete:"Delete",edit:"Edit",add:"Add",close:"Close",confirm:"Confirm",loading:"Loading...",error:"Error",success:"Success",warning:"Warning",enabled:"Enabled",disabled:"Disabled",yes:"Yes",no:"No",on:"On",off:"Off",all:"All",none:"None",search:"Search",filter:"Filter",sort:"Sort",refresh:"Refresh",download:"Download",upload:"Upload",actions:"Actions",status:"Status",name:"Name",description:"Description",date:"Date",time:"Time",hours:"hours",minutes:"minutes",seconds:"seconds",days:"days",enable:"Enable",disable:"Disable",permissions:"Permissions",noPrinters:"No printers configured",noData:"No data available",linkNotFound:"Link not found",required:"Required",optional:"Optional",dismiss:"Dismiss",apply:"Apply",reset:"Reset",clear:"Clear",selectAll:"Select All",deselectAll:"Deselect All",noChange:"— No change —",unchanged:"Unchanged",unassigned:"Unassigned",unknown:"Unknown",unknownError:"Unknown error",today:"Today",asap:"ASAP",overdue:"Overdue",now:"Now",collapse:"Collapse",expand:"Expand",viewArchive:"View archive",viewInFileManager:"View in File Manager",addedBy:"Added by {{username}}",prints:"prints",more:"+{{count}} more",ascending:"Ascending",descending:"Descending",printer:"Printer",remove:"Remove",type:"Type",print:"Print",rename:"Rename",move:"Move",create:"Create",duplicate:"Duplicate",left:"Left",right:"Right"},printers:{title:"Printers",addPrinter:"Add Printer",editPrinter:"Edit Printer",deletePrinter:"Delete Printer",printerName:"Printer Name",serialNumber:"Serial Number",ipAddress:"IP Address",accessCode:"Access Code",model:"Model",nozzleCount:"Nozzle Count",autoArchive:"Auto Archive",status:{idle:"Idle",printing:"Printing",paused:"Paused",offline:"Offline",error:"Error",finished:"Finished",unknown:"Unknown"},temperatures:{nozzle:"Nozzle",bed:"Bed",chamber:"Chamber"},progress:"{{percent}}% complete",timeRemaining:"{{time}} remaining",deleteConfirm:'Are you sure you want to delete "{{name}}"?',maintenanceOk:"Maintenance OK",maintenanceWarning:"{{count}} warning",maintenanceWarning_plural:"{{count}} warnings",maintenanceDue:"{{count}} due",maintenanceDue_plural:"{{count}} due",sort:{name:"Name",status:"Status",model:"Model",location:"Location",ascending:"Sort ascending",descending:"Sort descending"},cardSize:{small:"Small cards",medium:"Medium cards",large:"Large cards",extraLarge:"Extra large cards"},hideOffline:"Hide offline",powerOn:"Power On",offlinePrintersWithPlugs:"Offline printers with smart plugs",noPrintersConfigured:"No printers configured yet",readyToPrint:"Ready to print",external:"External",deleteArchives:"Delete print archives",noLabel:"No label",printPreview:"Print preview",width:"Width",height:"Height",noObjectsFound:"No objects found",objectsLoadedOnPrintStart:"Objects are loaded when a print starts",willBeSkipped:"Will be skipped",name:"Name",serialCannotBeChanged:"Serial number cannot be changed",locationHelp:"Used to group printers and filter queue jobs",wifiSignal:{veryWeak:"Very weak",weak:"Weak",fair:"Fair",good:"Good",excellent:"Excellent"},maintenanceUpToDate:"All maintenance up to date - Click to view",chamberLightOn:"Turn on chamber light",chamberLightOff:"Turn off chamber light",browseFiles:"Browse printer files",autoOffAfterPrint:"Auto power-off after print",autoOffExecuted:"Auto-off was executed - turn printer on to reset",hmsErrors:"HMS Errors",viewHmsErrors:"View {{count}} HMS error(s)",resume:"Resume",pause:"Pause",stop:"Stop",camera:"Camera",skipObject:"Skip Object",reconnect:"Reconnect",mqttDebug:"MQTT Debug",activeNozzle:"Active: {{nozzle}} nozzle",firmwareUpdate:"Firmware Update",firmwareInstructions:"On the printer's touchscreen, go to",firmwareNav:"Navigate to",settings:"Settings",firmware:"Firmware",discoverPrinters:"Discover Printers",searching:"Searching...",manualEntry:"Manual Entry",addFromCloud:"Add from Cloud",toast:{printerDeleted:"Printer deleted",printerAdded:"Printer added",printerUpdated:"Printer updated",failedToDelete:"Failed to delete printer",failedToAdd:"Failed to add printer",failedToUpdate:"Failed to update printer",commandSent:"Command sent",failedToSendCommand:"Failed to send command",turnedOn:"{{name}} turned on",failedToPowerOn:"Failed to power on {{name}}",scriptTriggered:"Script triggered",printStopped:"Print stopped",printPaused:"Print paused",printResumed:"Print resumed",referenceDeleted:"Reference deleted",detectionAreaSaved:"Detection area saved",failedToRunScript:"Failed to run script",failedToStopPrint:"Failed to stop print",failedToPausePrint:"Failed to pause print",failedToResumePrint:"Failed to resume print",failedToControlChamberLight:"Failed to control chamber light",failedToUpdateSetting:"Failed to update setting",failedToSkipObjects:"Failed to skip objects",failedToRereadRfid:"Failed to re-read RFID",failedToCheckPlate:"Failed to check plate",failedToUpdateLabel:"Failed to update label",failedToDeleteReference:"Failed to delete reference",failedToSaveDetectionArea:"Failed to save detection area",plateCheckEnabled:"Plate check enabled",plateCheckDisabled:"Plate check disabled",calibrationSaved:"Calibration saved!",calibrationFailed:"Calibration failed",rfidRereadInitiated:"RFID re-read initiated"},connection:{connected:"Connected",offline:"Offline"},queue:{inQueue:"{{count}} print in queue",inQueue_plural:"{{count}} prints in queue"},controls:"Controls",rfid:{reread:"Re-read RFID"},permission:{noAdd:"You do not have permission to add printers",noEdit:"You do not have permission to edit printers",noDelete:"You do not have permission to delete printers",noControl:"You do not have permission to control printers",noFiles:"You do not have permission to access printer files",noAmsRfid:"You do not have permission to re-read AMS RFID",noSmartPlugControl:"You do not have permission to control smart plugs"},modal:{addTitle:"Add Printer",editTitle:"Edit Printer",myPrinter:"My Printer",selectModel:"Select model...",locationGroup:"Location / Group (optional)",locationPlaceholder:"e.g., Workshop, Office, Basement",autoArchiveLabel:"Auto-archive completed prints",fromPrinterSettings:"From printer settings",modelOptional:"Model (optional)",saveChanges:"Save Changes"},skipObjects:{tooltip:"Skip objects",onlyWhilePrinting:"Skip objects (only while printing)",requiresMultiple:"Skip objects (requires 2+ objects)",title:"Skip Objects",matchIdsInfo:"Match IDs with your printer display",printerShowsIds:"The printer screen shows object IDs on the build plate",skipSelected:"Skip Selected",skipping:"Skipping...",noObjectsSelected:"No objects selected",selectObjectsToSkip:"Select objects you want to skip from the current print",skipped:"skipped",objectsSkipped:"Objects skipped",activeCount:"{{count}} active",waitForLayer:"Wait for layer 2+ to skip objects (currently layer {{layer}})",skip:"Skip"},confirm:{deleteTitle:"Delete Printer",deleteMessage:'Are you sure you want to delete "{{name}}"? This will remove all connection settings.',deleteArchivesNote:"All print history for this printer will be permanently deleted.",keepArchivesNote:"Print history will be kept but no longer associated with this printer.",stopTitle:"Stop Print",stopMessage:'Are you sure you want to stop the current print on "{{name}}"? This will cancel the print job.',stopButton:"Stop Print",pauseTitle:"Pause Print",pauseMessage:'Are you sure you want to pause the current print on "{{name}}"?',pauseButton:"Pause Print",resumeTitle:"Resume Print",resumeMessage:'Are you sure you want to resume the print on "{{name}}"?',resumeButton:"Resume Print",powerOnTitle:"Power On Printer",powerOnMessage:'Are you sure you want to turn ON the power for "{{name}}"?',powerOnButton:"Power On",powerOffTitle:"Power Off Printer",powerOffMessage:'Are you sure you want to turn OFF the power for "{{name}}"?',powerOffWarning:'WARNING: "{{name}}" is currently printing! Are you sure you want to turn OFF the power? This will interrupt the print and may damage the printer.',powerOffButton:"Power Off"},discovery:{title:"Discover Printers",searching:"Searching...",scanning:"Scanning...",scanProgress:"Scanning... {{scanned}}/{{total}}",foundPrinters:"Found {{count}} printer(s)",noPrintersFound:"No printers found",noPrintersFoundSubnet:"No printers found in the specified subnet.",noPrintersFoundNetwork:"No printers found on the network.",allConfigured:"All discovered printers are already configured.",alreadyAdded:"Already added",select:"Select",manualEntry:"Manual Entry",addFromCloud:"Add from Cloud",subnetToScan:"Subnet to scan",dockerNote:"Docker detected. Enter your printer's subnet in CIDR notation. Requires network_mode: host in docker-compose.yml.",scanSubnet:"Scan Subnet for Printers",discoverNetwork:"Discover Printers on Network",scanningSubnet:"Scanning subnet for Bambu printers...",scanningNetwork:"Scanning network...",serialRequired:"Serial required",unknown:"Unknown",failedToStart:"Failed to start discovery"},filaments:"Filaments",openCameraOverlay:"Open camera overlay",openCameraWindow:"Open camera in new window",firmwareUpdateAvailable:"Firmware update available: {{current}} → {{latest}}",firmwareUpdateButton:"Update",plateDetection:{noPermission:"You do not have permission to update printers",enabledClick:"Plate check enabled - Click to disable",disabledClick:"Plate check disabled - Click to enable",manageCalibration:"Manage plate detection calibration",calibrationRequired:"Calibration Required",calibrationInstructions:"Please ensure the build plate is <strong>completely empty</strong>, then click Calibrate.",calibrationDescription:"Calibration captures a reference image of the empty plate. Future checks will compare against this reference to detect objects.",calibrationTip:"<strong>Tip:</strong> You can store up to 5 calibrations for different plates. The system automatically uses the best match when checking.",plateEmpty:"Plate appears empty",objectsDetected:"Objects detected on plate",confidence:"Confidence",difference:"Difference",analysisPreview:"Analysis preview:",analysisLegend:"Green box = detection area, Red overlay = differences from calibration",savedReferences:"Saved References ({{count}}/{{max}})",deleteReference:"Delete reference",labelPlaceholder:"Label...",clickToEdit:"{{label}} - Click to edit",clickToAddLabel:"Click to add label"},fans:{partCooling:"Part Cooling Fan",auxiliary:"Auxiliary Fan",chamber:"Chamber Fan"},clickToViewHmsErrors:"Click to view HMS errors",estimatedCompletion:"Estimated completion time",slotOptions:"Slot options",firmwareModal:{title:"Firmware Update",currentVersion:"Current:",latestVersion:"Latest:",releaseNotes:"Release Notes",checkingPrereqs:"Checking prerequisites...",sdCardReady:"SD card ready. Click below to upload firmware.",uploadedSuccess:"Firmware uploaded to SD card!",applyInstructions:"To apply the update on your printer:",step1:"On the printer's touchscreen, go to <strong>Settings</strong>",step2:"Navigate to <strong>Firmware</strong>",step3:"Select <strong>Update from SD card</strong>",step4:"The update will take 10-20 minutes",done:"Done",starting:"Starting...",uploadFirmware:"Upload Firmware",uploadedToast:"Firmware uploaded! Trigger update from printer screen."},accessCodePlaceholder:"Leave empty to keep current",roi:{title:"Detection Area (ROI)",xStart:"X Start",yStart:"Y Start",width:"Width",height:"Height",instruction:"Adjust the detection area to focus on the build plate. The green box in the preview shows the current area."}},archives:{title:"Print Archives",searchPlaceholder:"Search archives...",filterByPrinter:"Filter by printer",filterByStatus:"Filter by status",sortBy:"Sort by",sortNewest:"Newest first",sortOldest:"Oldest first",sortName:"Name",sortDuration:"Duration",sortLargest:"Largest first",sortSmallest:"Smallest first",sortSize:"Size",noArchives:"No archives found",noArchivesSearch:"No archives match your search",noArchivesYet:"No archives yet",loadingArchives:"Loading archives...",releaseToUpload:"Release to upload",showAll:"Show all",showFavoritesOnly:"Show favorites only",gridView:"Grid view",listView:"List view",calendarView:"Calendar view",manageTags:"Manage Tags",showFailedPrints:"Show failed prints",hideFailedPrints:"Hide failed prints",printTime:"Print Time",filamentUsed:"Filament Used",cost:"Cost",reprint:"Reprint",preview:"Preview",deleteArchive:"Delete Archive",deleteConfirm:"Are you sure you want to delete this archive?",favorite:"Favorite",unfavorite:"Remove from favorites",viewDetails:"View Details",status:{completed:"Completed",failed:"Failed",stopped:"Stopped"},toast:{source3mfAttached:"Source 3MF attached: {{filename}}",failedUploadSource3mf:"Failed to upload source 3MF",source3mfRemoved:"Source 3MF removed",failedRemoveSource3mf:"Failed to remove source 3MF",f3dAttached:"F3D attached: {{filename}}",failedUploadF3d:"Failed to upload F3D",f3dRemoved:"F3D removed",failedRemoveF3d:"Failed to remove F3D",timelapseAttached:"Timelapse attached: {{filename}}",timelapseAlreadyAttached:"Timelapse already attached",noMatchingTimelapse:"No matching timelapse found",failedScanTimelapse:"Failed to scan for timelapse",failedAttachTimelapse:"Failed to attach timelapse",archiveDeleted:"Archive deleted",failedDeleteArchive:"Failed to delete archive",addedToFavorites:"Added to favorites",removedFromFavorites:"Removed from favorites",projectUpdated:"Project updated",failedUpdateProject:"Failed to update project",linkCopied:"Link copied to clipboard",failedCopyLink:"Failed to copy link",photoDeleted:"Photo deleted",failedDeletePhoto:"Failed to delete photo",failedDeleteArchives:"Failed to delete archives",failedUpdateFavorites:"Failed to update favorites",exportDownloaded:"Export downloaded",exportFailed:"Export failed"},menu:{print:"Print",schedule:"Schedule",openInBambuStudio:"Open in Bambu Studio",slice:"Slice",externalLink:"External Link",viewOnMakerWorld:"View on MakerWorld",preview3d:"3D Preview",viewTimelapse:"View Timelapse",scanForTimelapse:"Scan for Timelapse",downloadSource3mf:"Download Source 3MF",uploadSource3mf:"Upload Source 3MF",replaceSource3mf:"Replace Source 3MF",removeSource3mf:"Remove Source 3MF",uploadF3d:"Upload F3D",replaceF3d:"Replace F3D",downloadF3d:"Download F3D",removeF3d:"Remove F3D",download:"Download",copyDownloadLink:"Copy Download Link",qrCode:"QR Code",viewPhotos:"View Photos",viewPhotosCount:"View Photos ({{count}})",projectPage:"Project Page",addToFavorites:"Add to Favorites",removeFromFavorites:"Remove from Favorites",edit:"Edit",goToProject:"Go to Project: {{name}}",addToProject:"Add to Project",removeFromProject:"Remove from Project",loading:"Loading...",noProjectsAvailable:"No projects available",select:"Select",deselect:"Deselect",delete:"Delete"},permission:{noReprint:"You do not have permission to reprint this archive",noAddToQueue:"You do not have permission to add to queue",noUpdateArchives:"You do not have permission to update archives",noUploadFiles:"You do not have permission to upload files",noDownload:"You do not have permission to download archives",noCopyLink:"You do not have permission to copy download links",noDelete:"You do not have permission to delete this archive",noCreate:"You do not have permission to create archives"},card:{previousPlate:"Previous plate",nextPlate:"Next plate",plateNumber:"Plate {{index}}",moreOptions:"Right-click for more options",addToFavorites:"Add to favorites",removeFromFavorites:"Remove from favorites",cancelled:"cancelled",failed:"failed",duplicate:"duplicate",duplicateTitle:"This model has been printed before",openSource3mf:"Open source 3MF in Bambu Studio (right-click for more options)",downloadF3d:"Download Fusion 360 design file",viewTimelapse:"View timelapse",viewPhoto:"View 1 photo",viewPhotos:"View {{count}} photos",openFolder:"Open folder: {{name}}",slicedFile:"Sliced file - ready to print",sourceFile:"Source file only - no AMS mapping available",gcode:"GCODE",source:"SOURCE",project:"Project: {{name}}",estimated:"Estimated: {{time}}",actual:"Actual: {{time}}",accuracy:"Accuracy: {{percent}}%",filament:"{{weight}}g",layer:"{{count}} layer",layers:"{{count}} layers",object:"{{count}} object",objects:"{{count}} objects",slicedFor:"Sliced for {{model}}",uploadedBy:"Uploaded by {{name}}",noPermissionReprint:"You do not have permission to reprint",noPermissionEdit:"You do not have permission to edit archives",noPermissionDelete:"You do not have permission to delete archives",reprint:"Reprint",schedulePrint:"Schedule Print",schedule:"Schedule",openInBambuStudio:"Open in Bambu Studio",openInBambuStudioToSlice:"Open in Bambu Studio to slice",slice:"Slice",externalLink:"External Link",makerWorld:"MakerWorld: {{designer}}",viewProject:"View project",noExternalLink:"No external link",preview3d:"3D Preview",download:"Download",edit:"Edit",delete:"Delete"},modal:{deleteArchive:"Delete Archive",deleteConfirm:'Are you sure you want to delete "{{name}}"? This action cannot be undone.',deleteButton:"Delete",removeSource3mf:"Remove Source 3MF",removeSource3mfConfirm:'Are you sure you want to remove the source 3MF file from "{{name}}"? This will delete the original slicer project file.',removeButton:"Remove",removeF3d:"Remove F3D",removeF3dConfirm:'Are you sure you want to remove the Fusion 360 design file from "{{name}}"?',timelapse:"{{name}} - Timelapse",selectTimelapse:"Select Timelapse",selectTimelapseDesc:"No auto-match found. Select the timelapse for this print:",deleteArchives:"Delete Archives",deleteArchivesConfirm:"Are you sure you want to delete {{count}} archive(s)? This action cannot be undone.",deleteCount:"Delete {{count}}"},page:{title:"Archives",printsCount:"{{filtered}} of {{total}} prints",dropFilesHere:"Drop .3mf files here",releaseToUpload:"Release to upload",only3mfSupported:"Only .3mf files are supported",close:"Close",selected:"{{count}} selected",selectAll:"Select All",tags:"Tags",project:"Project",favorite:"Favorite",delete:"Delete",toggledFavorites:"Toggled favorites for {{count}} archive(s)",failedUpdateFavorites:"Failed to update favorites",archivesDeleted:"{{count}} archive(s) deleted",failedDeleteArchives:"Failed to delete archives",photoDeleted:"Photo deleted",failedDeletePhoto:"Failed to delete photo"},list:{name:"Name",printer:"Printer",date:"Date",size:"Size",actions:"Actions",hasTimelapse:"Has timelapse"}},queue:{title:"Print Queue",subtitle:"Schedule and manage your print jobs",addToQueue:"Add to Queue",print:"Print",reprint:"Re-print",schedulePrint:"Schedule Print",editQueueItem:"Edit Queue Item",printToPrinters:"Print to {{count}} Printers",queueToPrinters:"Queue to {{count}} Printers",sending:"Sending...",sendingProgress:"Sending {{current}}/{{total}}...",adding:"Adding...",addingProgress:"Adding {{current}}/{{total}}...",savingProgress:"Saving {{current}}/{{total}}...",clearQueue:"Clear Queue",clearHistory:"Clear History",emptyQueue:"Queue is empty",position:"Position",scheduledTime:"Scheduled Time",moveUp:"Move Up",moveDown:"Move Down",startNow:"Start Now",printingInProgress:"Printing in progress...",viewArchive:"View archive",viewInFileManager:"View in File Manager",itemCount:"{{count}} item",itemCount_plural:"{{count}} items",dragToReorder:"Drag to reorder (ASAP only)",reorderHint:"Position only affects ASAP items. Scheduled items run at their set time.",addedBy:"Added by {{name}}",sections:{currentlyPrinting:"Currently Printing",queued:"Queued",history:"History"},status:{pending:"Pending",waiting:"Waiting",printing:"Printing",completed:"Completed",failed:"Failed",skipped:"Skipped",cancelled:"Cancelled"},summary:{printing:"Printing",queued:"Queued",totalTime:"Total Queue Time",history:"History"},filter:{allPrinters:"All Printers",unassigned:"Unassigned",allStatus:"All Status",allLocations:"All Locations",any:"Any"},sort:{byPosition:"Sort by Position",byName:"Sort by Name",byPrinter:"Sort by Printer",bySchedule:"Sort by Schedule",byDate:"Sort by Date",ascendingOldest:"Ascending (oldest first)",descendingNewest:"Descending (newest first)"},badges:{staged:"Staged",requiresPrevious:"Requires previous success",autoPowerOff:"Auto power off"},empty:{title:"No prints scheduled",description:'Schedule a print from the Archives page using the "Schedule" option in the context menu, or drag and drop files to get started.'},time:{asap:"ASAP",overdue:"Overdue",now:"Now",lessThanMinute:"In less than a minute",inMinutes:"In {{count}} min",inHours:"In {{count}} hours"},actions:{stopPrint:"Stop Print",startPrint:"Start Print",requeue:"Re-queue"},bulkEdit:{title:"Edit {{count}} Item",title_plural:"Edit {{count}} Items",description:"Only changed settings will be applied to selected items.",printer:"Printer",noChange:"— No change —",queueOptions:"Queue Options",staged:"Staged (manual start)",autoPowerOff:"Auto power off after print",requirePrevious:"Require previous success",printOptions:"Print Options",bedLevelling:"Bed levelling",flowCalibration:"Flow calibration",vibrationCalibration:"Vibration calibration",layerInspection:"First layer inspection",timelapse:"Timelapse",useAms:"Use AMS",applyChanges:"Apply Changes",selectAll:"Select All",deselectAll:"Deselect All",selected:"{{count}} selected",editSelected:"Edit Selected",cancelSelected:"Cancel Selected"},confirm:{cancelTitle:"Cancel Scheduled Print",cancelMessage:'Are you sure you want to cancel "{{name}}"?',stopTitle:"Stop Print",stopMessage:'Are you sure you want to stop the current print "{{name}}"? This will cancel the print job on the printer.',removeTitle:"Remove from History",removeMessage:'Are you sure you want to remove "{{name}}" from the queue history?',clearHistoryTitle:"Clear History",clearHistoryMessage:"Are you sure you want to remove all {{count}} item(s) from the history?",cancelButton:"Cancel Print",stopButton:"Stop Print",thisPrint:"this print",thisItem:"this item"},toast:{cancelled:"Queue item cancelled",cancelFailed:"Failed to cancel item",removed:"Queue item removed",removeFailed:"Failed to remove item",stopped:"Print stopped",stopFailed:"Failed to stop print",released:"Print released to queue",startFailed:"Failed to start print",reorderFailed:"Failed to reorder queue",historyCleared:"Cleared {{count}} history item(s)",clearHistoryFailed:"Failed to clear history",updateFailed:"Failed to update items",bulkCancelled:"Cancelled {{count}} item(s)",bulkCancelFailed:"Failed to cancel items"},permissions:{noStopPrint:"You do not have permission to stop prints",noStartPrint:"You do not have permission to start prints",noEdit:"You do not have permission to edit this queue item",noCancel:"You do not have permission to cancel this queue item",noRequeue:"You do not have permission to re-queue items",noRemove:"You do not have permission to remove this queue item",noClearHistory:"You do not have permission to clear all history",noEditItems:"You do not have permission to edit queue items",noCancelItems:"You do not have permission to cancel queue items"}},stats:{title:"Dashboard",subtitle:"Drag widgets to rearrange. Click the eye icon to hide.",overview:"Overview",totalPrints:"Total Prints",successRate:"Success Rate",totalPrintTime:"Total Print Time",printTime:"Print Time",totalFilament:"Total Filament Used",filamentUsed:"Filament Used",filamentCost:"Filament Cost",totalCost:"Total Cost",energyUsed:"Energy Used",energyCost:"Energy Cost",averagePrintTime:"Average Print Time",printsPerDay:"Prints per Day",byPrinter:"By Printer",printsByPrinter:"Prints by Printer",byMaterial:"By Material",byMonth:"By Month",last7Days:"Last 7 Days",last30Days:"Last 30 Days",last90Days:"Last 90 Days",allTime:"All Time",quickStats:"Quick Stats",printActivity:"Print Activity",filamentTypes:"Filament Types",filamentTrends:"Filament Trends",failureAnalysis:"Failure Analysis",timeAccuracy:"Time Accuracy",successful:"Successful:",failed:"Failed:",perfectEstimate:"100% = perfect estimate",noTimeAccuracyData:"No time accuracy data yet",noFilamentData:"No filament data available",noPrinterData:"No printer data available",noPrintData:"No print data available",noPrintDataLast30Days:"No print data in the last 30 days",failureReasons:"Failure Reasons",topFailureReasons:"Top Failure Reasons",failedPrintsCount:"{{failed}} / {{total}} prints failed",lastWeekRate:"Last week: {{rate}}%",resetLayout:"Reset Layout",recalculateCosts:"Recalculate Costs",recalculateCostsHint:"Recalculate all archive costs using current filament prices",exportStats:"Export Stats",exportAsCsv:"Export as CSV",exportAsExcel:"Export as Excel",hiddenCount:"{{count}} Hidden",exportDownloaded:"Export downloaded",exportFailed:"Export failed",layoutReset:"Layout reset",recalculatedCosts:"Recalculated costs for {{count}} archives",recalculateFailed:"Failed to recalculate costs",loadingStats:"Loading statistics...",noPermissionResetLayout:"You do not have permission to reset layout",noPermissionRecalculate:"You do not have permission to recalculate costs"},maintenance:{title:"Maintenance",overview:"Overview",allOk:"All maintenance up to date",dueCount:"{{count}} item due",dueCount_plural:"{{count}} items due",warningCount:"{{count}} warning",warningCount_plural:"{{count}} warnings",totalPrintTime:"Total Print Time",nextMaintenance:"Next Maintenance",nothingDue:"Nothing due",tasks:"Tasks",lastPerformed:"Last performed",interval:"Interval",hoursRemaining:"{{hours}}h remaining",hoursOverdue:"{{hours}}h overdue",markDone:"Mark as Done",performMaintenance:"Perform Maintenance",history:"History",noHistory:"No maintenance history",editPrintHours:"Edit Print Hours",currentHours:"Current Hours",statusTab:"Status",settingsTab:"Settings",overdueCount:"{{count}} overdue",dueSoonCount:"{{count}} due soon",dueSoon:"Due soon",allGood:"All good",overdueBy:"Overdue by {{duration}}",dueIn:"Due in {{duration}}",timeLeft:"{{duration}} left",day:"1 day",days:"{{count}} days",week:"1 week",weeks:"{{count}} weeks",month:"1 month",months:"{{count}} months",year:"1 year",maintenanceTypes:"Maintenance Types",maintenanceTypesDescription:"System types and your custom maintenance tasks",addCustomType:"Add Custom Type",intervalType:"Interval Type",intervalValue:"Interval ({{type}})",icon:"Icon",documentationLink:"Documentation Link (optional)",assignToPrinters:"Assign to Printers",selectAtLeastOnePrinter:"Select at least one printer",addType:"Add Type",custom:"Custom",printHours:"Print Hours",calendarDays:"Calendar Days",exampleName:"e.g., Replace HEPA Filter",viewDocumentation:"View documentation",timeBasedInterval:"Time-based interval",intervalOverrides:"Interval Overrides",intervalOverridesDescription:"Customize intervals for specific printers",assignedToPrinters:"Assigned to printers:",noPrintersAssigned:"No printers assigned",addPrinterShort:"Add:",printersAssignedClick:"{{count}} printer(s) assigned - click to manage",removeFromPrinter:"Remove from this printer",types:{lubricateRails:"Lubricate Linear Rails",cleanNozzle:"Clean Nozzle/Hotend",checkBelts:"Check Belt Tension",cleanBuildPlate:"Clean Build Plate",checkExtruder:"Check Extruder Gears",checkCooling:"Check Cooling Fans",generalInspection:"General Inspection",cleanCarbonRods:"Clean Carbon Rods",checkPtfeTube:"Check PTFE Tube",replaceHepaFilter:"Replace HEPA Filter",replaceCarbonFilter:"Replace Carbon Filter",lubricateLeftNozzleRail:"Lubricate Left Nozzle Rail"},maintenanceComplete:"Maintenance marked as complete",typeUpdated:"Maintenance type updated",typeDeleted:"Maintenance type deleted",printHoursUpdated:"Print hours updated",printerAssigned:"Printer assigned",printerRemoved:"Printer removed",deleteTypeConfirm:'Delete "{{name}}"?',noPermissionUpdate:"You do not have permission to update maintenance items",noPermissionPerform:"You do not have permission to perform maintenance",noPermissionEditTypes:"You do not have permission to edit maintenance types",noPermissionDeleteTypes:"You do not have permission to delete maintenance types",noPermissionEditHours:"You do not have permission to edit print hours",noPermissionRemovePrinter:"You do not have permission to remove printer assignments",noPermissionAssignPrinter:"You do not have permission to assign printers",noPermissionEditIntervals:"You do not have permission to edit intervals",configureSettings:"Configure maintenance types and intervals"},settings:{title:"Settings",general:"General",tabs:{general:"General",smartPlugs:"Smart Plugs",notifications:"Notifications",filament:"Filament",network:"Network",apiKeys:"API Keys",virtualPrinter:"Virtual Printer",users:"Users",backup:"Backup"},appearance:"Appearance",notifications:"Notifications",smartPlugs:"Smart Plugs",spoolman:"Spoolman",updates:"Updates",language:"Language",languageDescription:"Select your preferred language",theme:"Theme",themeLight:"Light",themeDark:"Dark",themeSystem:"System",defaultView:"Default View",defaultViewDescription:"Page to show when opening the app",checkForUpdates:"Check for Updates",autoUpdate:"Auto Update",currentVersion:"Current Version",latestVersion:"Latest Version",upToDate:"You are up to date",updateAvailable:"Update available",notificationLanguage:"Notification Language",notificationLanguageDescription:"Language for push notifications",notificationProviders:"Notification Providers",addProvider:"Add Provider",editProvider:"Edit Provider",providerType:"Provider Type",testNotification:"Test Notification",testSuccess:"Test notification sent successfully",testFailed:"Failed to send test notification",quietHours:"Quiet Hours",quietHoursDescription:"Do not disturb during these hours",quietHoursStart:"Start",quietHoursEnd:"End",events:{title:"Notification Events",printStart:"Print Started",printComplete:"Print Completed",printFailed:"Print Failed",printStopped:"Print Stopped",printProgress:"Progress Milestones",printProgressDescription:"Notify at 25%, 50%, 75%",printerOffline:"Printer Offline",printerError:"Printer Error",filamentLow:"Low Filament",maintenanceDue:"Maintenance Due",maintenanceDueDescription:"Notify when maintenance is needed"},smartPlug:{title:"Smart Plugs",add:"Add Smart Plug",edit:"Edit Smart Plug",name:"Name",ipAddress:"IP Address",linkedPrinter:"Linked Printer",autoOn:"Auto Power On",autoOnDescription:"Turn on when print starts",autoOff:"Auto Power Off",autoOffDescription:"Turn off after print completes",offDelay:"Off Delay",offDelayMinutes:"Minutes after print",offDelayTemp:"When nozzle below temperature",currentState:"Current State",turnOn:"Turn On",turnOff:"Turn Off"},spoolmanEnabled:"Enable Spoolman Integration",spoolmanUrl:"Spoolman URL",spoolmanConnected:"Connected",spoolmanDisconnected:"Disconnected",noDefaultPrinter:"No default (ask each time)",sidebarOrder:"Sidebar order",saveThumbnails:"Save thumbnails",captureFinishPhoto:"Capture finish photo",noPrintersConfigured:"No printers configured",archiveMode:{always:"Always create archive entry",never:"Never create archive entry",ask:"Ask each time"},checkForUpdatesLabel:"Check for updates",checkPrinterFirmware:"Check printer firmware",enableRetry:"Enable retry",homeAssistantDescription:"Control smart plugs via Home Assistant",mqttConnectedTo:"Connected to",prometheusDescription:"Expose printer data in Prometheus format",noSmartPlugsTitle:"No smart plugs configured",noSmartPlugsDescription:"Add a Tasmota-based smart plug to track energy usage and automate power control.",noProvidersTitle:"No providers configured",noProvidersDescription:"Add a provider to receive alerts.",noTemplatesAvailable:"No templates available. Restart the backend to seed default templates.",apiPermissionView:"View printer status and queue",apiPermissionEdit:"Add and remove items from print queue",apiKeysEmptyTitle:"No API keys",apiKeysEmptyDescription:"Create an API key to integrate with external services.",noUsersFound:"No users found",noGroupsFound:"No groups found",noGroupsAvailable:"No groups available",passwordsDoNotMatch:"Passwords do not match",systemGroupWarning:"System group names cannot be changed",authDisabledTitle:"Authentication is Disabled",authDisabledFeature1:"Require login to access the system",authDisabledFeature2:"Create multiple users with group-based permissions",authDisabledFeature3:"Control access with 50+ granular permissions",userHasCreated:"This user has created:",userItemsQuestion:"What would you like to do with these items?",deleteUserConfirm:"Are you sure you want to delete this user?",actionCannotBeUndone:"This action cannot be undone.",addFirstSmartPlug:"Add Your First Smart Plug",providers:"Providers",log:"Log",testAll:"Test All",testResults:"Test Results",testPassedCount:"{{count}} passed",testFailedCount:"{{count}} failed",messageTemplates:"Message Templates",messageTemplatesDescription:"Customize notification messages for each event.",apiKeys:"API Keys",apiKeysDescription:"Create API keys for external integrations and webhooks.",createKey:"Create Key",apiKeyCreated:"API Key Created Successfully",apiKeyCopyWarning:"Copy this key now - it won't be shown again!",useInApiBrowser:"Use in API Browser",createNewApiKey:"Create New API Key",keyName:"Key Name",keyNamePlaceholder:"e.g., Home Assistant, OctoPrint",readStatus:"Read Status",readStatusDescription:"View printer status and queue",manageQueue:"Manage Queue",manageQueueDescription:"Add and remove items from print queue",controlPrinter:"Control Printer",controlPrinterDescription:"Pause, resume, and stop prints",unnamedKey:"Unnamed Key",lastUsed:"Last used",read:"Read",control:"Control",createFirstKey:"Create Your First Key",webhookEndpoints:"Webhook Endpoints",webhookApiKeyHint:"Use your API key in the X-API-Key header.",webhook:{getAllStatus:"Get all printer status",getSpecificStatus:"Get specific printer status",addToQueue:"Add to print queue",pausePrint:"Pause print",resumePrint:"Resume print",stopPrint:"Stop print"},apiBrowser:"API Browser",apiBrowserDescription:"Explore and test all available API endpoints.",apiKeyForTesting:"API Key for Testing",apiKeyPlaceholder:"Paste your API key here to test authenticated endpoints...",apiKeyHint:"This key will be sent as X-API-Key header with requests.",deleteApiKeyTitle:"Delete API Key",deleteApiKeyMessage:"Are you sure you want to delete this API key? Any integrations using this key will stop working.",deleteKey:"Delete Key",amsDisplayThresholds:"AMS Display Thresholds",amsThresholdsDescription:"Configure color thresholds for AMS humidity and temperature indicators.",humidity:"Humidity",goodGreen:"Good (green)",fairOrange:"Fair (orange)",aboveFairBad:"Above fair threshold shows as red (bad)",temperature:"Temperature",goodBlue:"Good (blue)",aboveFairHot:"Above fair threshold shows as red (hot)",historyRetention:"History Retention",keepSensorHistory:"Keep sensor history for",historyRetentionDescription:"Older humidity and temperature data will be automatically deleted",printModal:"Print Modal",expandCustomMapping:"Expand custom mapping by default",expandCustomMappingDescription:"When printing to multiple printers, show per-printer AMS mapping expanded",authentication:"Authentication",authEnabledDescription:"Your instance is secured with user authentication",authDisabledDescription:"Enable to require login and manage user access",authDisabledMessage:"Enable authentication to create user accounts, manage permissions, and secure your Bambuddy instance.",enableAuthentication:"Enable Authentication",currentUser:"Current User",changePassword:"Change Password",admin:"Admin",users:"Users",addUser:"Add User",groups:"Groups",addGroup:"Add Group",system:"System",noDescription:"No description",userCount:"{{count}} users",permissionCount:"{{count}} permissions",createUser:"Create User",username:"Username",enterUsername:"Enter username",password:"Password",enterPassword:"Enter password (min 6 characters)",confirmPassword:"Confirm Password",confirmPasswordPlaceholder:"Confirm password",viewReleaseOnGitHub:"View release on GitHub",turnAllPlugsOn:"Turn all plugs on",turnAllPlugsOff:"Turn all plugs off",clearNotificationLogs:"Clear Notification Logs",clearLogsMessage:"This will permanently delete all notification logs older than 30 days. This action cannot be undone.",clearLogs:"Clear Logs",resetUiPreferences:"Reset UI Preferences",resetUiPreferencesMessage:"This will reset all UI preferences to defaults: sidebar order, theme, dashboard layout, view modes, and sorting preferences. Your printers, archives, and server settings will NOT be affected. The page will reload after clearing.",resetPreferences:"Reset Preferences",deleteGroupTitle:"Delete Group",deleteGroupMessage:"Are you sure you want to delete this group? Users in this group will lose these permissions.",deleteGroup:"Delete Group",disableAuthenticationTitle:"Disable Authentication",disableAuthenticationMessage:"Are you sure you want to disable authentication? This will make your Bambuddy instance accessible without login. All users will remain in the database but authentication will be disabled.",disableAuthentication:"Disable Authentication",configureBambuddy:"Configure Bambuddy",systemDefault:"System Default",archiveSettings:"Archive Settings",newWindow:"New Window",embeddedOverlay:"Embedded Overlay",externalCameras:"External Cameras",costTracking:"Cost Tracking",printsOnly:"Prints Only",totalConsumption:"Total Consumption",dataManagement:"Data Management",clearNotificationLogsDescription:"Delete notification logs older than 30 days",resetUiPreferencesDescription:"Reset sidebar order, theme, view modes, and layout preferences. Printers, archives, and settings are not affected.",enableHomeAssistant:"Enable Home Assistant",enableMqtt:"Enable MQTT",useTls:"Use TLS",enableMetricsEndpoint:"Enable Metrics Endpoint",availableMetrics:"Available Metrics",editUser:"Edit User",deleteUserTitle:"Delete User",groupName:"Group Name",leaveEmptyForAnonymous:"Leave empty for anonymous",leaveEmptyForNoAuth:"Leave empty for no authentication",enterNewPassword:"Enter new password",confirmNewPassword:"Confirm new password",enterGroupName:"Enter group name",enterDescriptionOptional:"Enter description (optional)",enterCurrentPassword:"Enter current password",enterNewPasswordMin6:"Enter new password (min 6 characters)",toast:{keyCopied:"Key copied to clipboard",copyFailed:"Failed to copy key",keyAddedToBrowser:"Key added to API Browser",clearLogsFailed:"Failed to clear logs",uiPreferencesReset:"UI preferences reset. Refreshing...",authDisabled:"Authentication disabled successfully",authDisableFailed:"Failed to disable authentication",apiKeyCreated:"API key created",apiKeyDeleted:"API key deleted",userCreated:"User created successfully",userUpdated:"User updated successfully",userDeleted:"User deleted successfully",groupCreated:"Group created successfully",groupUpdated:"Group updated successfully",groupDeleted:"Group deleted successfully",fillRequiredFields:"Please fill in all required fields",passwordsDoNotMatch:"Passwords do not match",passwordTooShort:"Password must be at least 6 characters",enterGroupName:"Please enter a group name",settingsSaved:"Settings saved",cameraSettingsSaved:"Camera settings saved",enterCameraUrl:"Please enter a camera URL",passwordChanged:"Password changed successfully",connectionFailed:"Connection failed",testFailed:"Test failed",cameraConnected:"Camera connected{{resolution}}"},testConnection:"Test Connection"},notification:{printStarted:{title:"Print Started",body:"{{printer}}: {{filename}} has started printing"},printCompleted:{title:"Print Completed",body:"{{printer}}: {{filename}} completed successfully"},printFailed:{title:"Print Failed",body:"{{printer}}: {{filename}} has failed"},printStopped:{title:"Print Stopped",body:"{{printer}}: {{filename}} was stopped"},printProgress:{title:"Print Progress",body:"{{printer}}: {{filename}} is {{percent}}% complete"},printerOffline:{title:"Printer Offline",body:"{{printer}} is offline"},printerError:{title:"Printer Error",body:"{{printer}}: {{error}}"},filamentLow:{title:"Low Filament",body:"{{printer}}: Filament is running low"},maintenanceDue:{title:"Maintenance Due",body:"{{printer}}: {{items}} need attention"}},errors:{generic:"Something went wrong",networkError:"Network error. Please check your connection.",notFound:"Not found",unauthorized:"Unauthorized",serverError:"Server error",validationError:"Please check your input",printerConnectionFailed:"Failed to connect to printer",saveFailed:"Failed to save changes",deleteFailed:"Failed to delete",loadFailed:"Failed to load data"},hmsErrors:{title:"Errors - {{name}}",noErrors:"No errors",viewOnWiki:"View on Bambu Lab Wiki",clearInstructions:"Clear errors on the printer to dismiss them here."},mqttDebug:{title:"MQTT Debug Log",searchPlaceholder:"Search topic or payload...",noMessages:"No messages logged yet",startLoggingHint:'Click "Start Logging" to begin capturing MQTT messages',noMessagesMatch:"No messages match your filter",adjustFilterHint:"Try adjusting your search or filter criteria",incoming:"Incoming",outgoing:"Outgoing",loggingStopped:"Logging stopped",loggingActive:"Logging active - messages will auto-refresh",startLogging:"Start Logging",stopLogging:"Stop Logging",clearLog:"Clear Log",topic:"Topic",timestamp:"Timestamp",direction:"Direction",all:"All"},printerFiles:{title:"File Manager",storageUsed:"Used:",storageFree:"Free:",filterPlaceholder:"Filter files...",deleteButton:"Delete",deleteFiles:"Delete {{count}} Files",deleteFileConfirm:'Delete "{{name}}"? This cannot be undone.',deleteFilesConfirm:"Delete {{count}} selected files? This cannot be undone.",noFiles:"No files on printer",loadingFiles:"Loading files...",failedToLoad:"Failed to load files",toast:{filesDeleted:"Deleted {{count}} file(s)",deleteFailed:"Delete failed: {{error}}"}},confirm:{delete:"Are you sure you want to delete this?",unsavedChanges:"You have unsaved changes. Are you sure you want to leave?",clearQueue:"Are you sure you want to clear the queue?"},login:{title:"Bambuddy Login",subtitle:"Sign in to your account",username:"Username",usernamePlaceholder:"Enter your username",password:"Password",passwordPlaceholder:"Enter your password",signIn:"Sign in",signingIn:"Logging in...",forgotPassword:"Forgot your password?",loginSuccess:"Logged in successfully",loginFailed:"Login failed",enterCredentials:"Please enter username and password",forgotPasswordTitle:"Forgot Password",forgotPasswordMessage:"If you've forgotten your password, please contact your system administrator to reset it.",howToReset:"How to reset your password:",resetStep1:"Contact your Bambuddy administrator",resetStep2:"Ask them to reset your password in User Management",resetStep3:"They can set a new temporary password for you",resetStep4:"Log in with the new password and change it in Settings",gotIt:"Got it"},setup:{title:"Bambuddy Setup",subtitle:"Configure authentication for your Bambuddy instance",enableAuth:"Enable Authentication",adminAccount:"Admin Account",adminAccountDesc:"If admin users already exist, authentication will be enabled using the existing admin accounts. Leave the fields below empty to use existing admins, or enter new credentials to create a new admin user.",adminUsername:"Admin Username",adminPassword:"Admin Password",optionalIfAdminExists:"(optional if admin users exist)",adminUsernamePlaceholder:"Enter admin username (optional)",adminPasswordPlaceholder:"Enter admin password (optional)",confirmPassword:"Confirm Password",confirmPasswordPlaceholder:"Confirm admin password",settingUp:"Setting up...",completeSetup:"Complete Setup",toast:{authEnabledAdminCreated:"Authentication enabled and admin user created",authEnabledExistingAdmins:"Authentication enabled using existing admin users",setupCompleted:"Setup completed",enterBothCredentials:"Please enter both admin username and password, or leave both empty to use existing admin users",passwordsDoNotMatch:"Passwords do not match",passwordTooShort:"Password must be at least 6 characters"}},changePassword:{title:"Change Password",currentPassword:"Current Password",currentPasswordPlaceholder:"Enter current password",newPassword:"New Password",newPasswordPlaceholder:"Enter new password (min 6 characters)",confirmPassword:"Confirm New Password",confirmPasswordPlaceholder:"Confirm new password",passwordsDoNotMatch:"Passwords do not match",passwordTooShort:"Password must be at least 6 characters",changing:"Changing...",success:"Password changed successfully",failed:"Failed to change password"},plateAlert:{title:"Print Paused!",message:"Objects detected on build plate. The print has been automatically paused. Please clear the plate and resume the print.",understand:"I Understand"},camera:{title:"Camera View",invalidPrinterId:"Invalid printer ID",live:"Live",snapshot:"Snapshot",restartStream:"Restart stream",refreshSnapshot:"Refresh snapshot",fullscreen:"Fullscreen",exitFullscreen:"Exit fullscreen",connectingToCamera:"Connecting to camera...",capturingSnapshot:"Capturing snapshot...",connectionLost:"Connection lost",connectionFailed:"Camera connection failed",reconnecting:"Reconnecting in {{countdown}}s... (attempt {{attempt}}/{{max}})",reconnectNow:"Reconnect now",cameraUnavailable:"Camera unavailable",cameraUnavailableDesc:"Make sure the printer is powered on and connected.",noCamera:"No camera available",retry:"Retry",cameraStream:"Camera stream",zoomOut:"Zoom out",zoomIn:"Zoom in",resetZoom:"Reset zoom",recording:"Recording",startRecording:"Start Recording",stopRecording:"Stop Recording"},groups:{title:"Group Management",subtitle:"Manage permission groups for access control",backToSettings:"Back to Settings",createGroup:"Create Group",noPermission:"You do not have permission to access this page.",system:"System",noDescription:"No description",usersCount:"{{count}} users",permissionsCount:"{{count}} permissions",edit:"Edit",delete:"Delete",toast:{created:"Group created successfully",updated:"Group updated successfully",deleted:"Group deleted successfully",enterGroupName:"Please enter a group name"},modal:{editGroup:"Edit Group",createGroup:"Create Group",cancel:"Cancel",saving:"Saving...",creating:"Creating...",saveChanges:"Save Changes"},form:{groupName:"Group Name",groupNamePlaceholder:"Enter group name",systemGroupWarning:"System group names cannot be changed",description:"Description",descriptionPlaceholder:"Enter description (optional)",permissions:"Permissions ({{count}} selected)"},deleteModal:{title:"Delete Group",message:"Are you sure you want to delete this group? Users in this group will lose these permissions.",confirm:"Delete Group"}},users:{title:"User Management",subtitle:"Manage users and their access to your Bambuddy instance",backToSettings:"Back to Settings",createUser:"Create User",noPermission:"You do not have permission to access this page.",admin:"Admin",noGroups:"No groups",active:"Active",inactive:"Inactive",edit:"Edit",delete:"Delete",system:"System",noGroupsAvailable:"No groups available",table:{username:"Username",groups:"Groups",status:"Status",actions:"Actions"},toast:{created:"User created successfully",updated:"User updated successfully",deleted:"User deleted successfully",fillRequired:"Please fill in all required fields",passwordsDoNotMatch:"Passwords do not match",passwordTooShort:"Password must be at least 6 characters"},modal:{createUser:"Create User",editUser:"Edit User",cancel:"Cancel",creating:"Creating...",saving:"Saving...",saveChanges:"Save Changes"},form:{username:"Username",usernamePlaceholder:"Enter username",password:"Password",passwordPlaceholder:"Enter password",confirmPassword:"Confirm Password",confirmPasswordPlaceholder:"Confirm password",newPasswordPlaceholder:"Enter new password",confirmNewPasswordPlaceholder:"Confirm new password",leaveBlankToKeep:"leave blank to keep current",groups:"Groups"},deleteModal:{title:"Delete User",message:"Are you sure you want to delete this user? This action cannot be undone.",confirm:"Delete User"}},streamOverlay:{title:"Stream Overlay",invalidPrinterId:"Invalid printer ID",cameraStream:"Camera stream",progress:"Progress",eta:"ETA",tomorrow:"Tomorrow",printerIdle:"Printer is idle",printerOffline:"Printer offline",status:{printing:"Printing",paused:"Paused",finished:"Finished",failed:"Failed",idle:"Idle",unknown:"Unknown"}},profiles:{title:"Profiles",subtitle:"Manage your slicer presets and pressure advance calibrations",tabs:{cloud:"Cloud Profiles",kprofiles:"K-Profiles"},connectedAs:"Connected as",logout:"Logout",noLogoutPermission:"You do not have permission to logout",failedToLoad:"Failed to load profiles",retry:"Retry",time:{justNow:"Just now",minsAgo:"{{count}}m ago",hoursAgo:"{{count}}h ago",daysAgo:"{{count}}d ago"},toast:{loggedOut:"Logged out"},login:{title:"Connect to Bambu Cloud",subtitle:"Sync your slicer presets across devices",email:"Email",password:"Password",region:"Region",regionGlobal:"Global",regionChina:"China",verificationCode:"Verification Code",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"},fileManager:{title:"File Manager",subtitle:"Organize and manage your print files",uploadFiles:"Upload Files",newFolder:"New Folder",folderName:"Folder Name",folderNamePlaceholder:"e.g., Functional Parts",renameFile:"Rename File",renameFolder:"Rename Folder",moveFiles:"Move {{count}} File(s)",rootNoFolder:"Root (No Folder)",current:"current",linkFolder:"Link Folder",linkFolderDescription:'Link "{{name}}" to a project or archive for quick access.',project:"Project",archive:"Archive",noProjectsFound:"No projects found",noArchivesFound:"No archives found",unlink:"Unlink",link:"Link",dragDropFiles:"Drag & drop files here",dropFilesHere:"Drop files here",orClickToBrowse:"or click to browse",allFileTypesSupported:"All file types supported. ZIP files will be extracted.",zipFilesDetected:"ZIP files detected",zipExtractOptions:"ZIP files will be extracted. Choose how to handle folder structure:",preserveZipStructure:"Preserve folder structure from ZIP",createFolderFromZip:"Create folder from ZIP filename",stlThumbnailGeneration:"STL thumbnail generation",zipMayContainStl:"ZIP files may contain STL files. Thumbnails can be generated during extraction.",thumbnailsCanBeGenerated:"Thumbnails can be generated for STL files. Large models may take longer to process.",generateThumbnailsForStl:"Generate thumbnails for STL files",willBeExtracted:"Will be extracted",filesExtracted:"{{count}} files extracted",uploadComplete:"Upload complete: {{succeeded}} succeeded",uploadFailed:"{{count}} failed",uploading:"Uploading...",changeLink:"Change Link...",linkTo:"Link to...",linkToProjectOrArchive:"Link to project or archive",addToQueue:"Add to Queue",generateThumbnail:"Generate Thumbnail",generateThumbnails:"Generate Thumbnails",generateThumbnailsForMissing:"Generate thumbnails for STL files missing them",gridView:"Grid view",listView:"List view",lowDiskSpaceWarning:"Low disk space warning",lowDiskSpaceDetails:"Only {{free}} free of {{total}} total. Threshold is set to {{threshold}} GB in settings.",files:"Files",folders:"Folders",size:"Size",free:"Free",allFiles:"All Files",wrap:"Wrap",enableTextWrapping:"Enable text wrapping",disableTextWrapping:"Disable text wrapping",dragToResizeTooltip:"Drag to resize, double-click to reset",searchFiles:"Search files...",allTypes:"All types",prints:"Prints",ascending:"Ascending",descending:"Descending",resultsCount:"{{showing}} of {{total}} files",selectAll:"Select All",deselectAll:"Deselect All",selected:"{{count}} selected",adding:"Adding...",loadingFiles:"Loading files...",folderIsEmpty:"Folder is empty",noFilesYet:"No files yet",folderEmptyDescription:"Upload files or move files into this folder to get started.",noFilesDescription:"Upload files to start organizing your print-related files.",noMatchingFiles:"No matching files",noMatchingFilesDescription:"No files match your current search or filter criteria.",clearFilters:"Clear filters",printedCount:"Printed {{count}}x",uploadedBy:"Uploaded by {{name}}",deleteFolder:"Delete Folder",deleteFile:"Delete File",deleteFilesCount:"Delete {{count}} Files",deleteFolderConfirm:"Are you sure you want to delete this folder? All files inside will also be deleted.",deleteFileConfirm:"Are you sure you want to delete this file?",deleteFilesConfirm:"Are you sure you want to delete {{count}} selected files? This action cannot be undone.",deleting:"Deleting...",noPermissionRenameFolder:"You do not have permission to rename folders",noPermissionLinkFolder:"You do not have permission to link folders",noPermissionDeleteFolder:"You do not have permission to delete folders",noPermissionPrint:"You do not have permission to print",noPermissionAddToQueue:"You do not have permission to add to queue",noPermissionDownload:"You do not have permission to download files",noPermissionRenameFile:"You do not have permission to rename this file",noPermissionGenerateThumbnail:"You do not have permission to generate thumbnails",noPermissionDeleteFile:"You do not have permission to delete this file",noPermissionCreateFolder:"You do not have permission to create folders",noPermissionUpload:"You do not have permission to upload files",noPermissionMoveFiles:"You do not have permission to move files",noPermissionDeleteFiles:"You do not have permission to delete files",toast:{folderCreated:"Folder created",folderDeleted:"Folder deleted",fileDeleted:"File deleted",filesDeleted:"Deleted {{count}} files",filesMoved:"Files moved",folderLinked:"Folder linked",folderUnlinked:"Folder unlinked",addedToQueue:"Added {{count}} file(s) to queue",addedToQueuePartial:"Added {{added}} file(s), {{failed}} failed",failedToAddToQueue:"Failed to add files: {{error}}",fileRenamed:"File renamed",folderRenamed:"Folder renamed",thumbnailsGenerated:"Generated {{count}} thumbnail(s)",thumbnailsGeneratedPartial:"Generated {{succeeded}} thumbnail(s), {{failed}} failed",noStlMissingThumbnails:"No STL files missing thumbnails",failedToGenerateThumbnails:"Failed to generate thumbnails: {{error}}",thumbnailGenerated:"Thumbnail generated",failedToGenerateThumbnail:"Failed to generate thumbnail: {{error}}"}},projects:{title:"Projects",subtitle:"Organize and track your 3D printing projects",newProject:"New Project",editProject:"Edit Project",deleteProject:"Delete Project",projectName:"Project Name",description:"Description",noProjects:"No projects yet",noProjectsFiltered:"No {{status}} projects",noProjectsFilteredHelp:"You don't have any {{status}} projects. Projects will appear here when their status changes.",createFirst:"Create your first project to start organizing related prints, tracking progress, and managing your builds.",createFirstButton:"Create Your First Project",create:"Create",files:"Files",prints:"Prints",plates:"plates",parts:"parts",lastModified:"Last Modified",deleteConfirm:"Are you sure you want to delete this project? Archives and queue items will be unlinked but not deleted.",addFiles:"Add Files",removeFile:"Remove File",viewDetails:"View Details",namePlaceholder:"e.g., Voron 2.4 Build",descriptionPlaceholder:"Optional description...",color:"Color",targetPlates:"Target Plates",targetPlatesPlaceholder:"e.g., 25",targetPlatesHelp:"Number of print jobs",targetParts:"Target Parts",targetPartsPlaceholder:"e.g., 150",targetPartsHelp:"Total objects needed",tagsLabel:"Tags (comma-separated)",tagsPlaceholder:"e.g., voron, functional, gift",dueDate:"Due Date",priority:"Priority",priorityLow:"Low",priorityNormal:"Normal",priorityHigh:"High",priorityUrgent:"Urgent",statusActive:"Active",statusCompleted:"Completed",statusArchived:"Archived",done:"Done",completed:"completed",failed:"failed",inQueue:"in queue",noPrintsYet:"No prints yet",printJobs:"Print jobs (plates)",partsPrinted:"Parts printed",failedParts:"Failed parts",import:"Import",export:"Export",importProject:"Import project",exportAll:"Export all projects",loading:"Loading projects...",noEditPermission:"You do not have permission to edit projects",noDeletePermission:"You do not have permission to delete projects",noCreatePermission:"You do not have permission to create projects",noImportPermission:"You do not have permission to import projects",noExportPermission:"You do not have permission to export projects",toast:{created:"Project created",updated:"Project updated",deleted:"Project deleted",imported:"Project imported",multipleImported:"{{count}} projects imported",importFailed:"Import failed",exported:"Projects exported (metadata only)"}},projectDetail:{notFound:"Project not found",backToProjects:"Back to Projects",export:"Export",exportProject:"Export project",noExportPermission:"You do not have permission to export projects",noEditPermission:"You do not have permission to edit projects",partOf:"Part of:",priorityLabel:"Priority:",noPrints:"No prints in this project yet",status:{active:"Active",completed:"Completed",archived:"Archived"},priority:{low:"Low",normal:"Normal",high:"High",urgent:"Urgent"},dueDate:{overdue:"Overdue",today:"Due today",daysLeft:"{{count}} days left"},progress:{platesProgress:"Plates Progress",partsProgress:"Parts Progress",printJobs:"print jobs",parts:"parts",percentComplete:"{{percent}}% complete",remaining:"{{count}} remaining"},stats:{printJobs:"Print Jobs",total:"total",failed:"{{count}} failed",partsPrinted:"{{count}} parts printed",printTime:"Print Time",filamentUsed:"Filament Used"},cost:{title:"Cost Tracking",filamentCost:"Filament Cost",energy:"Energy",budget:"Budget",remaining:"Remaining"},subProjects:{title:"Sub-projects ({{count}})"},notes:{title:"Notes",noEditPermission:"You do not have permission to edit notes",placeholder:"Add notes about this project...",empty:"No notes yet. Click Edit to add notes."},files:{title:"Files",linkFolders:"Link folders from the File Manager",forQuickAccess:"to this project for quick access.",fileCount:"{{count}} file(s)",empty:"No folders linked. Go to File Manager and link a folder to this project."},bom:{title:"Bill of Materials",acquired:"{{completed}}/{{total}} acquired",showAll:"Show all",hideDone:"Hide done",addPart:"Add Part",noAddPermission:"You do not have permission to add parts",partNamePlaceholder:"Part name (e.g., M3x8 screws)",partName:"Part name",qty:"Qty",price:"Price ({{currency}})",sourcingUrlPlaceholder:"Sourcing URL (optional)",remarksPlaceholder:"Remarks (optional)",deletePart:"Delete Part",deleteConfirm:'Are you sure you want to delete "{{name}}"?',noUpdatePermission:"You do not have permission to update parts",noEditPermission:"You do not have permission to edit parts",noDeletePermission:"You do not have permission to delete parts",totalCost:"Total cost:",empty:"No parts in the bill of materials. Add hardware, electronics, or other components to track what needs to be sourced."},timeline:{title:"Activity Timeline",empty:"No activity yet."},template:{saveAsTemplate:"Save as Template",noCreatePermission:"You do not have permission to create templates"},queue:{title:"Queue",viewAll:"View all",printing:"{{count}} printing",queued:"{{count}} queued"},prints:{title:"Prints ({{count}})"},toast:{projectUpdated:"Project updated",partAdded:"Part added",partRemoved:"Part removed",exportFailed:"Export failed",projectExported:"Project exported",templateCreated:"Template created"}},system:{title:"System Information",version:"Version",uptime:"Uptime",cpuUsage:"CPU Usage",memoryUsage:"Memory Usage",diskUsage:"Disk Usage",networkInfo:"Network Info",logs:"Logs",debugMode:"Debug Mode",enableDebug:"Enable Debug Logging",disableDebug:"Disable Debug Logging",downloadLogs:"Download Logs",clearLogs:"Clear Logs",dockerInfo:"Docker Info",containerName:"Container Name",imageName:"Image Name",platform:"Platform",architecture:"Architecture"},library:{title:"Filament Library",addFilament:"Add Filament",editFilament:"Edit Filament",deleteFilament:"Delete Filament",vendor:"Vendor",material:"Material",color:"Color",kFactor:"K Factor",temperature:"Temperature",noFilaments:"No filaments in library",deleteConfirm:"Are you sure you want to delete this filament?",importFromPrinter:"Import from Printer",exportToFile:"Export to File"},spoolman:{title:"Spoolman Integration",enabled:"Spoolman Enabled",url:"Spoolman URL",connected:"Connected",disconnected:"Not Connected",testConnection:"Test Connection",sync:"Sync",syncing:"Syncing...",lastSync:"Last Sync",linkToSpoolman:"Link to Spoolman",openInSpoolman:"Open in Spoolman",unlinkSpool:"Unlink Spool",selectSpool:"Select Spool",noUnlinkedSpools:"No unlinked spools available",linkSuccess:"Spool linked to Spoolman successfully",linkFailed:"Failed to link spool",spoolId:"Spool ID",weight:"Weight",remaining:"Remaining"},timelapse:{title:"Timelapse",create:"Create Timelapse",download:"Download",delete:"Delete",preview:"Preview",frameRate:"Frame Rate",quality:"Quality",processing:"Processing...",noTimelapses:"No timelapses available"},ams:{title:"AMS",slot:"Slot",empty:"Empty",emptySlot:"Empty slot",unknown:"Unknown",humidity:"Humidity",temperature:"Temperature",filamentType:"Filament Type",filamentColor:"Color",remaining:"Remaining",history:"AMS History",noHistory:"No history available",configureSlot:"Configure Slot",externalSpool:"External Spool",profile:"Profile",kFactor:"K Factor",fill:"Fill",configure:"Configure"},printModal:{title:"Start Print",selectPrinter:"Select Printer",selectPlate:"Select Plate",filamentMapping:"Filament Mapping",printSettings:"Print Settings",bedLeveling:"Bed Leveling",flowCalibration:"Flow Calibration",vibrationCalibration:"Vibration Calibration",layerInspection:"First Layer Inspection",timelapse:"Timelapse",startPrint:"Start Print",addToQueue:"Add to Queue",cancel:"Cancel",noPrintersAvailable:"No printers available",printerBusy:"Printer is busy",printerOffline:"Printer is offline"},backup:{title:"Backup & Restore",createBackup:"Create Backup",restoreBackup:"Restore Backup",downloadBackup:"Download Backup",uploadBackup:"Upload Backup",lastBackup:"Last Backup",autoBackup:"Auto Backup",backupNow:"Backup Now",restoreWarning:"Warning: Restoring a backup will overwrite all current data.",includeArchives:"Include Archives",includeSettings:"Include Settings",includeProfiles:"Include Profiles",backupSuccess:"Backup created successfully",restoreSuccess:"Backup restored successfully",backupFailed:"Backup failed",restoreFailed:"Restore failed"},tags:{title:"Tags",addTag:"Add Tag",editTag:"Edit Tag",deleteTag:"Delete Tag",tagName:"Tag Name",tagColor:"Tag Color",noTags:"No tags",deleteConfirm:"Are you sure you want to delete this tag?",manageTags:"Manage Tags"},uploadModal:{title:"Upload 3MF Files",dragDrop:"Drag & drop .3mf files here",or:"or",browseFiles:"Browse Files",extractionInfo:"The printer model will be automatically extracted from the 3MF file metadata.",uploaded:"uploaded",failed:"failed",uploading:"Uploading...",upload:"Upload",uploadFailed:"Upload failed"},editArchive:{title:"Edit Archive",name:"Name",namePlaceholder:"Print name",printer:"Printer",noPrinter:"No printer",project:"Project",noProject:"No project",itemsPrinted:"Items Printed",itemsPrintedHelp:"Number of items produced in this print job",notes:"Notes",notesPlaceholder:"Add notes about this print...",externalLink:"External Link",externalLinkPlaceholder:"https://printables.com/model/...",externalLinkHelp:"Link to Printables, Thingiverse, or other source",tags:"Tags",tagsPlaceholder:"Add tags...",addMoreTags:"Add more tags...",matchingTags:'Matching "{{query}}"',existingTags:"Existing tags",clickToAdd:"(click to add)",status:"Status",failureReason:"Failure Reason",selectReason:"Select reason...",photos:"Photos of Printed Result",photosHelp:"Click + to add photos of your printed result",printResult:"Print result",saving:"Saving...",failureReasons:{adhesionFailure:"Adhesion failure",spaghettiDetached:"Spaghetti / Detached",layerShift:"Layer shift",cloggedNozzle:"Clogged nozzle",filamentRunout:"Filament runout",warping:"Warping",stringing:"Stringing",underExtrusion:"Under-extrusion",powerFailure:"Power failure",userCancelled:"User cancelled",other:"Other"},statuses:{completed:"Completed",failed:"Failed",aborted:"Cancelled",printing:"Printing"}},kProfiles:{title:"K-Profiles",noPrintersConfigured:"No Printers Configured",addPrinterInSettings:"Add a printer in Settings to manage K-profiles",noActivePrinters:"No Active Printers",enablePrinterConnection:"Enable a printer connection to view its K-profiles",loadingProfiles:"Loading K-Profiles...",printerOffline:"Printer Offline",printerOfflineDesc:"The selected printer is not connected. Power it on to view K-profiles.",noMatchingProfiles:"No Matching Profiles",noMatchingProfilesDesc:"No profiles match your search criteria",noKProfiles:"No K-Profiles",noKProfilesDesc:"No pressure advance profiles found for {{diameter}}mm nozzle",createFirstProfile:"Create First Profile",printer:"Printer",nozzle:"Nozzle",refresh:"Refresh",addProfile:"Add Profile",export:"Export",import:"Import",select:"Select",selectAll:"Select All",delete:"Delete",searchPlaceholder:"Search by name or filament...",allExtruders:"All Extruders",leftOnly:"Left Only",rightOnly:"Right Only",allFlow:"All Flow",hfOnly:"HF Only",sOnly:"S Only",sortName:"Sort: Name",sortKValue:"Sort: K-Value",sortFilament:"Sort: Filament",leftExtruder:"Left Extruder",rightExtruder:"Right Extruder",modal:{addTitle:"Add K-Profile",editTitle:"Edit K-Profile",profileName:"Profile Name",profileNamePlaceholder:"My PLA Profile",kValue:"K-Value",kValuePlaceholder:"0.020",kValueHelp:"Typical range: 0.01 - 0.06 for PLA, 0.02 - 0.10 for PETG",filament:"Filament",selectFilament:"Select filament...",noFilamentsHelp:"No filaments found. Create a K-profile in Bambu Studio first.",flowType:"Flow Type",highFlow:"High Flow",standard:"Standard",nozzleSize:"Nozzle Size",extruder:"Extruder",extruders:"Extruders",left:"Left",right:"Right",notes:"Notes (stored locally)",notesPlaceholder:"Add notes about this profile...",notesHelp:"Notes are saved in Bambuddy, not on the printer",syncing:"Syncing with printer...",savingExtruder:"Saving to extruder {{current}}/{{total}}...",pleaseWait:"Please wait"},deleteConfirm:{title:"Delete Profile",cannotUndo:"This cannot be undone",message:'Are you sure you want to delete "{{name}}" from the printer?'},bulkDelete:{title:"Delete Profiles",cannotUndo:"This cannot be undone",message:"Are you sure you want to delete {{count}} selected profiles from the printer?"},toast:{profileSaved:"K-profile saved",profilesSaved:"K-profile saved to {{count}} extruders",selectAtLeastOneExtruder:"Please select at least one extruder",profileDeleted:"K-profile deleted",profilesDeleted:"Deleted {{count}} profiles",exportedProfiles:"Exported {{count}} profiles",importedProfiles:"Imported {{count}} of {{total}} profiles",noProfilesToExport:"No profiles to export",invalidFileFormat:"Invalid file format",failedToParseImport:"Failed to parse import file",failedToSaveBatch:"Failed to save K-profiles",noteSaved:"Note saved",failedToSaveNote:"Failed to save note"},permission:{noRead:"You do not have permission to refresh profiles",noCreate:"You do not have permission to add profiles",noUpdate:"You do not have permission to update K-profiles",noDelete:"You do not have permission to delete K-profiles",noExport:"You do not have permission to export profiles",noImport:"You do not have permission to import profiles"}},maintenanceDescriptions:{lubricateRails:"Apply lubricant to linear rails for smooth motion",cleanNozzle:"Clean hotend and nozzle to prevent clogs",checkBelts:"Verify belt tension for accurate prints",cleanBuildPlate:"Clean build plate for better adhesion",checkExtruder:"Inspect extruder gears for wear",checkCooling:"Ensure cooling fans are working properly",generalInspection:"General printer inspection",cleanCarbonRods:"Clean carbon rods to reduce friction",checkPtfeTube:"Inspect PTFE tube for wear or damage",replaceHepaFilter:"Replace HEPA filter for air quality",replaceCarbonFilter:"Replace activated carbon filter",lubricateLeftNozzleRail:"Lubricate left nozzle rail (H2 series)"}},zse={nav:{printers:"Drucker",archives:"Archiv",queue:"Warteschlange",stats:"Statistiken",profiles:"Profile",maintenance:"Wartung",projects:"Projekte",files:"Dateimanager",settings:"Einstellungen",system:"System",collapseSidebar:"Seitenleiste einklappen",expandSidebar:"Seitenleiste ausklappen",update:"Update",updateAvailable:"Update verfügbar: v{{version}}",updateAvailableBanner:"Version {{version}} ist verfügbar!",viewUpdate:"Update anzeigen",viewOnGithub:"Auf GitHub ansehen",keyboardShortcuts:"Tastaturkürzel (?)",switchToLight:"Zum hellen Modus wechseln",switchToDark:"Zum dunklen Modus wechseln",smartSwitches:"Smart Switches",logout:"Abmelden"},common:{save:"Speichern",saving:"Speichern...",cancel:"Abbrechen",delete:"Löschen",edit:"Bearbeiten",add:"Hinzufügen",close:"Schließen",confirm:"Bestätigen",loading:"Lädt...",error:"Fehler",success:"Erfolg",warning:"Warnung",enabled:"Aktiviert",disabled:"Deaktiviert",yes:"Ja",no:"Nein",on:"An",off:"Aus",all:"Alle",none:"Keine",search:"Suchen",filter:"Filtern",sort:"Sortieren",refresh:"Aktualisieren",download:"Herunterladen",upload:"Hochladen",actions:"Aktionen",status:"Status",name:"Name",description:"Beschreibung",date:"Datum",time:"Zeit",hours:"Stunden",minutes:"Minuten",seconds:"Sekunden",days:"Tage",enable:"Aktivieren",disable:"Deaktivieren",permissions:"Berechtigungen",noPrinters:"Keine Drucker konfiguriert",noData:"Keine Daten verfügbar",linkNotFound:"Link nicht gefunden",required:"Erforderlich",optional:"Optional",dismiss:"Schließen",apply:"Anwenden",reset:"Zurücksetzen",clear:"Leeren",selectAll:"Alle auswählen",deselectAll:"Auswahl aufheben",noChange:"— Keine Änderung —",unchanged:"Unverändert",unassigned:"Nicht zugewiesen",unknown:"Unbekannt",unknownError:"Unbekannter Fehler",today:"Heute",asap:"Sofort",overdue:"Überfällig",now:"Jetzt",collapse:"Einklappen",expand:"Ausklappen",viewArchive:"Archiv anzeigen",viewInFileManager:"Im Dateimanager anzeigen",addedBy:"Hinzugefügt von {{username}}",prints:"Drucke",more:"+{{count}} weitere",ascending:"Aufsteigend",descending:"Absteigend",printer:"Drucker",remove:"Entfernen",type:"Typ",print:"Drucken",rename:"Umbenennen",move:"Verschieben",create:"Erstellen",duplicate:"Duplizieren",left:"Links",right:"Rechts"},printers:{title:"Drucker",addPrinter:"Drucker hinzufügen",editPrinter:"Drucker bearbeiten",deletePrinter:"Drucker löschen",printerName:"Druckername",serialNumber:"Seriennummer",ipAddress:"IP-Adresse",accessCode:"Zugangscode",model:"Modell",nozzleCount:"Düsenanzahl",autoArchive:"Automatische Archivierung",status:{idle:"Bereit",printing:"Druckt",paused:"Pausiert",offline:"Offline",error:"Fehler",finished:"Fertig",unknown:"Unbekannt"},temperatures:{nozzle:"Düse",bed:"Druckbett",chamber:"Kammer"},progress:"{{percent}}% abgeschlossen",timeRemaining:"Noch {{time}}",deleteConfirm:'Möchten Sie "{{name}}" wirklich löschen?',maintenanceOk:"Wartung OK",maintenanceWarning:"{{count}} Warnung",maintenanceWarning_plural:"{{count}} Warnungen",maintenanceDue:"{{count}} fällig",maintenanceDue_plural:"{{count}} fällig",sort:{name:"Name",status:"Status",model:"Modell",location:"Standort",ascending:"Aufsteigend sortieren",descending:"Absteigend sortieren"},cardSize:{small:"Kleine Karten",medium:"Mittlere Karten",large:"Große Karten",extraLarge:"Extra große Karten"},hideOffline:"Offline ausblenden",powerOn:"Einschalten",offlinePrintersWithPlugs:"Offline-Drucker mit Smart-Plugs",noPrintersConfigured:"Noch keine Drucker konfiguriert",readyToPrint:"Druckbereit",external:"Extern",deleteArchives:"Druckarchive löschen",noLabel:"Keine Bezeichnung",printPreview:"Druckvorschau",width:"Breite",height:"Höhe",noObjectsFound:"Keine Objekte gefunden",objectsLoadedOnPrintStart:"Objekte werden beim Druckstart geladen",willBeSkipped:"Wird übersprungen",name:"Name",serialCannotBeChanged:"Seriennummer kann nicht geändert werden",locationHelp:"Dient zur Gruppierung von Druckern und zum Filtern von Warteschlangenaufträgen",wifiSignal:{veryWeak:"Sehr schwach",weak:"Schwach",fair:"Ausreichend",good:"Gut",excellent:"Ausgezeichnet"},maintenanceUpToDate:"Alle Wartungen aktuell - Klicken zum Anzeigen",chamberLightOn:"Kammerbeleuchtung einschalten",chamberLightOff:"Kammerbeleuchtung ausschalten",browseFiles:"Druckerdateien durchsuchen",autoOffAfterPrint:"Automatisches Ausschalten nach Druck",autoOffExecuted:"Auto-off wurde ausgeführt - Drucker einschalten zum Zurücksetzen",hmsErrors:"HMS-Fehler",viewHmsErrors:"{{count}} HMS-Fehler anzeigen",resume:"Fortsetzen",pause:"Pausieren",stop:"Stoppen",camera:"Kamera",skipObject:"Objekt überspringen",reconnect:"Neu verbinden",mqttDebug:"MQTT-Debug",activeNozzle:"Aktiv: {{nozzle}} Düse",firmwareUpdate:"Firmware-Update",firmwareInstructions:"Gehen Sie auf dem Touchscreen des Druckers zu",firmwareNav:"Navigieren Sie zu",settings:"Einstellungen",firmware:"Firmware",discoverPrinters:"Drucker entdecken",searching:"Suche...",manualEntry:"Manuelle Eingabe",addFromCloud:"Aus Cloud hinzufügen",toast:{printerDeleted:"Drucker gelöscht",printerAdded:"Drucker hinzugefügt",printerUpdated:"Drucker aktualisiert",failedToDelete:"Drucker konnte nicht gelöscht werden",failedToAdd:"Drucker konnte nicht hinzugefügt werden",failedToUpdate:"Drucker konnte nicht aktualisiert werden",commandSent:"Befehl gesendet",failedToSendCommand:"Befehl konnte nicht gesendet werden",turnedOn:"{{name}} eingeschaltet",failedToPowerOn:"{{name}} konnte nicht eingeschaltet werden",scriptTriggered:"Skript ausgelöst",printStopped:"Druck gestoppt",printPaused:"Druck pausiert",printResumed:"Druck fortgesetzt",referenceDeleted:"Referenz gelöscht",detectionAreaSaved:"Erkennungsbereich gespeichert",failedToRunScript:"Skript konnte nicht ausgeführt werden",failedToStopPrint:"Druck konnte nicht gestoppt werden",failedToPausePrint:"Druck konnte nicht pausiert werden",failedToResumePrint:"Druck konnte nicht fortgesetzt werden",failedToControlChamberLight:"Kammerbeleuchtung konnte nicht gesteuert werden",failedToUpdateSetting:"Einstellung konnte nicht aktualisiert werden",failedToSkipObjects:"Objekte konnten nicht übersprungen werden",failedToRereadRfid:"RFID konnte nicht erneut gelesen werden",failedToCheckPlate:"Platte konnte nicht überprüft werden",failedToUpdateLabel:"Bezeichnung konnte nicht aktualisiert werden",failedToDeleteReference:"Referenz konnte nicht gelöscht werden",failedToSaveDetectionArea:"Erkennungsbereich konnte nicht gespeichert werden",plateCheckEnabled:"Plattenprüfung aktiviert",plateCheckDisabled:"Plattenprüfung deaktiviert",calibrationSaved:"Kalibrierung gespeichert!",calibrationFailed:"Kalibrierung fehlgeschlagen",rfidRereadInitiated:"RFID-Neueinlesen gestartet"},connection:{connected:"Verbunden",offline:"Offline"},queue:{inQueue:"{{count}} Druck in Warteschlange",inQueue_plural:"{{count}} Drucke in Warteschlange"},controls:"Steuerung",rfid:{reread:"RFID neu lesen"},permission:{noAdd:"Sie haben keine Berechtigung, Drucker hinzuzufügen",noEdit:"Sie haben keine Berechtigung, Drucker zu bearbeiten",noDelete:"Sie haben keine Berechtigung, Drucker zu löschen",noControl:"Sie haben keine Berechtigung, Drucker zu steuern",noFiles:"Sie haben keine Berechtigung, auf Druckerdateien zuzugreifen",noAmsRfid:"Sie haben keine Berechtigung, AMS-RFID erneut zu lesen",noSmartPlugControl:"Sie haben keine Berechtigung, Smart Plugs zu steuern"},modal:{addTitle:"Drucker hinzufügen",editTitle:"Drucker bearbeiten",myPrinter:"Mein Drucker",selectModel:"Modell auswählen...",locationGroup:"Standort / Gruppe (optional)",locationPlaceholder:"z.B. Werkstatt, Büro, Keller",autoArchiveLabel:"Abgeschlossene Drucke automatisch archivieren",fromPrinterSettings:"Aus Druckereinstellungen",modelOptional:"Modell (optional)",saveChanges:"Änderungen speichern"},skipObjects:{tooltip:"Objekte überspringen",onlyWhilePrinting:"Objekte überspringen (nur während des Drucks)",requiresMultiple:"Objekte überspringen (erfordert 2+ Objekte)",title:"Objekte überspringen",matchIdsInfo:"IDs mit Drucker-Display abgleichen",printerShowsIds:"Der Druckerbildschirm zeigt Objekt-IDs auf der Bauplatte",skipSelected:"Ausgewählte überspringen",skipping:"Überspringe...",noObjectsSelected:"Keine Objekte ausgewählt",selectObjectsToSkip:"Wählen Sie Objekte aus, die Sie vom aktuellen Druck überspringen möchten",skipped:"übersprungen",objectsSkipped:"Objekte übersprungen",activeCount:"{{count}} aktiv",waitForLayer:"Warten Sie auf Schicht 2+ zum Überspringen von Objekten (aktuell Schicht {{layer}})",skip:"Überspringen"},confirm:{deleteTitle:"Drucker löschen",deleteMessage:'Möchten Sie "{{name}}" wirklich löschen? Alle Verbindungseinstellungen werden entfernt.',deleteArchivesNote:"Der gesamte Druckverlauf für diesen Drucker wird dauerhaft gelöscht.",keepArchivesNote:"Der Druckverlauf wird beibehalten, aber nicht mehr mit diesem Drucker verknüpft.",stopTitle:"Druck stoppen",stopMessage:'Möchten Sie den aktuellen Druck auf "{{name}}" wirklich stoppen? Der Druckauftrag wird abgebrochen.',stopButton:"Druck stoppen",pauseTitle:"Druck pausieren",pauseMessage:'Möchten Sie den aktuellen Druck auf "{{name}}" wirklich pausieren?',pauseButton:"Druck pausieren",resumeTitle:"Druck fortsetzen",resumeMessage:'Möchten Sie den Druck auf "{{name}}" fortsetzen?',resumeButton:"Druck fortsetzen",powerOnTitle:"Drucker einschalten",powerOnMessage:'Möchten Sie die Stromversorgung für "{{name}}" wirklich EINSCHALTEN?',powerOnButton:"Einschalten",powerOffTitle:"Drucker ausschalten",powerOffMessage:'Möchten Sie die Stromversorgung für "{{name}}" wirklich AUSSCHALTEN?',powerOffWarning:'WARNUNG: "{{name}}" druckt gerade! Möchten Sie die Stromversorgung wirklich AUSSCHALTEN? Dies unterbricht den Druck und kann den Drucker beschädigen.',powerOffButton:"Ausschalten"},discovery:{title:"Drucker entdecken",searching:"Suche...",scanning:"Scanne...",scanProgress:"Scanne... {{scanned}}/{{total}}",foundPrinters:"{{count}} Drucker gefunden",noPrintersFound:"Keine Drucker gefunden",noPrintersFoundSubnet:"Keine Drucker im angegebenen Subnetz gefunden.",noPrintersFoundNetwork:"Keine Drucker im Netzwerk gefunden.",allConfigured:"Alle erkannten Drucker sind bereits konfiguriert.",alreadyAdded:"Bereits hinzugefügt",select:"Auswählen",manualEntry:"Manuelle Eingabe",addFromCloud:"Aus Cloud hinzufügen",subnetToScan:"Zu scannendes Subnetz",dockerNote:"Docker erkannt. Geben Sie das Subnetz Ihres Druckers in CIDR-Notation ein. Erfordert network_mode: host in docker-compose.yml.",scanSubnet:"Subnetz nach Druckern scannen",discoverNetwork:"Drucker im Netzwerk suchen",scanningSubnet:"Subnetz wird nach Bambu-Druckern gescannt...",scanningNetwork:"Netzwerk wird gescannt...",serialRequired:"Seriennummer erforderlich",unknown:"Unbekannt",failedToStart:"Erkennung konnte nicht gestartet werden"},filaments:"Filamente",openCameraOverlay:"Kamera-Overlay öffnen",openCameraWindow:"Kamera in neuem Fenster öffnen",firmwareUpdateAvailable:"Firmware-Update verfügbar: {{current}} → {{latest}}",firmwareUpdateButton:"Update",plateDetection:{noPermission:"Sie haben keine Berechtigung, Drucker zu aktualisieren",enabledClick:"Plattenprüfung aktiviert - Klicken zum Deaktivieren",disabledClick:"Plattenprüfung deaktiviert - Klicken zum Aktivieren",manageCalibration:"Platten-Erkennungskalibrierung verwalten",calibrationRequired:"Kalibrierung erforderlich",calibrationInstructions:"Bitte stellen Sie sicher, dass die Druckplatte <strong>vollständig leer</strong> ist, und klicken Sie dann auf Kalibrieren.",calibrationDescription:"Die Kalibrierung erfasst ein Referenzbild der leeren Platte. Zukünftige Prüfungen vergleichen mit dieser Referenz, um Objekte zu erkennen.",calibrationTip:"<strong>Tipp:</strong> Sie können bis zu 5 Kalibrierungen für verschiedene Platten speichern. Das System verwendet automatisch die beste Übereinstimmung bei der Prüfung.",plateEmpty:"Platte erscheint leer",objectsDetected:"Objekte auf Platte erkannt",confidence:"Konfidenz",difference:"Differenz",analysisPreview:"Analysevorschau:",analysisLegend:"Grüner Rahmen = Erkennungsbereich, Rote Überlagerung = Unterschiede zur Kalibrierung",savedReferences:"Gespeicherte Referenzen ({{count}}/{{max}})",deleteReference:"Referenz löschen",labelPlaceholder:"Bezeichnung...",clickToEdit:"{{label}} - Zum Bearbeiten klicken",clickToAddLabel:"Zum Hinzufügen einer Bezeichnung klicken"},fans:{partCooling:"Bauteilkühlung",auxiliary:"Hilfsventilator",chamber:"Kammerventilator"},clickToViewHmsErrors:"Klicken, um HMS-Fehler anzuzeigen",estimatedCompletion:"Geschätzte Fertigstellungszeit",slotOptions:"Slot-Optionen",firmwareModal:{title:"Firmware-Update",currentVersion:"Aktuell:",latestVersion:"Neueste:",releaseNotes:"Versionshinweise",checkingPrereqs:"Prüfe Voraussetzungen...",sdCardReady:"SD-Karte bereit. Klicken Sie unten, um die Firmware hochzuladen.",uploadedSuccess:"Firmware auf SD-Karte hochgeladen!",applyInstructions:"So wenden Sie das Update auf Ihrem Drucker an:",step1:"Gehen Sie auf dem Touchscreen des Druckers zu <strong>Einstellungen</strong>",step2:"Navigieren Sie zu <strong>Firmware</strong>",step3:"Wählen Sie <strong>Update von SD-Karte</strong>",step4:"Das Update dauert 10-20 Minuten",done:"Fertig",starting:"Starte...",uploadFirmware:"Firmware hochladen",uploadedToast:"Firmware hochgeladen! Starten Sie das Update vom Druckerbildschirm."},accessCodePlaceholder:"Leer lassen, um den aktuellen zu behalten",roi:{title:"Erkennungsbereich (ROI)",xStart:"X-Start",yStart:"Y-Start",width:"Breite",height:"Höhe",instruction:"Passen Sie den Erkennungsbereich an, um sich auf die Druckplatte zu konzentrieren. Der grüne Rahmen in der Vorschau zeigt den aktuellen Bereich."}},archives:{title:"Druckarchiv",searchPlaceholder:"Archiv durchsuchen...",filterByPrinter:"Nach Drucker filtern",filterByStatus:"Nach Status filtern",sortBy:"Sortieren nach",sortNewest:"Neueste zuerst",sortOldest:"Älteste zuerst",sortName:"Name",sortDuration:"Dauer",sortLargest:"Größte zuerst",sortSmallest:"Kleinste zuerst",sortSize:"Größe",noArchives:"Keine Archive gefunden",noArchivesSearch:"Keine Archive entsprechen Ihrer Suche",noArchivesYet:"Noch keine Archive",loadingArchives:"Lade Archive...",releaseToUpload:"Loslassen zum Hochladen",showAll:"Alle anzeigen",showFavoritesOnly:"Nur Favoriten anzeigen",gridView:"Rasteransicht",listView:"Listenansicht",calendarView:"Kalenderansicht",manageTags:"Tags verwalten",showFailedPrints:"Fehlgeschlagene Drucke anzeigen",hideFailedPrints:"Fehlgeschlagene Drucke ausblenden",printTime:"Druckzeit",filamentUsed:"Verbrauchtes Filament",cost:"Kosten",reprint:"Drucken",preview:"Vorschau",deleteArchive:"Archiv löschen",deleteConfirm:"Möchten Sie dieses Archiv wirklich löschen?",favorite:"Favorit",unfavorite:"Aus Favoriten entfernen",viewDetails:"Details anzeigen",status:{completed:"Abgeschlossen",failed:"Fehlgeschlagen",stopped:"Gestoppt"},toast:{source3mfAttached:"Quell-3MF angehängt: {{filename}}",failedUploadSource3mf:"Fehler beim Hochladen der Quell-3MF",source3mfRemoved:"Quell-3MF entfernt",failedRemoveSource3mf:"Fehler beim Entfernen der Quell-3MF",f3dAttached:"F3D angehängt: {{filename}}",failedUploadF3d:"Fehler beim Hochladen der F3D",f3dRemoved:"F3D entfernt",failedRemoveF3d:"Fehler beim Entfernen der F3D",timelapseAttached:"Zeitraffer angehängt: {{filename}}",timelapseAlreadyAttached:"Zeitraffer bereits angehängt",noMatchingTimelapse:"Kein passender Zeitraffer gefunden",failedScanTimelapse:"Fehler beim Suchen nach Zeitraffer",failedAttachTimelapse:"Fehler beim Anhängen des Zeitraffers",archiveDeleted:"Archiv gelöscht",failedDeleteArchive:"Fehler beim Löschen des Archivs",addedToFavorites:"Zu Favoriten hinzugefügt",removedFromFavorites:"Aus Favoriten entfernt",projectUpdated:"Projekt aktualisiert",failedUpdateProject:"Fehler beim Aktualisieren des Projekts",linkCopied:"Link in die Zwischenablage kopiert",failedCopyLink:"Fehler beim Kopieren des Links",photoDeleted:"Foto gelöscht",failedDeletePhoto:"Fehler beim Löschen des Fotos",failedDeleteArchives:"Fehler beim Löschen der Archive",failedUpdateFavorites:"Fehler beim Aktualisieren der Favoriten",exportDownloaded:"Export heruntergeladen",exportFailed:"Export fehlgeschlagen"},menu:{print:"Drucken",schedule:"Planen",openInBambuStudio:"In Bambu Studio öffnen",slice:"Slicen",externalLink:"Externer Link",viewOnMakerWorld:"Auf MakerWorld ansehen",preview3d:"3D-Vorschau",viewTimelapse:"Zeitraffer ansehen",scanForTimelapse:"Nach Zeitraffer suchen",downloadSource3mf:"Quell-3MF herunterladen",uploadSource3mf:"Quell-3MF hochladen",replaceSource3mf:"Quell-3MF ersetzen",removeSource3mf:"Quell-3MF entfernen",uploadF3d:"F3D hochladen",replaceF3d:"F3D ersetzen",downloadF3d:"F3D herunterladen",removeF3d:"F3D entfernen",download:"Herunterladen",copyDownloadLink:"Download-Link kopieren",qrCode:"QR-Code",viewPhotos:"Fotos ansehen",viewPhotosCount:"Fotos ansehen ({{count}})",projectPage:"Projektseite",addToFavorites:"Zu Favoriten hinzufügen",removeFromFavorites:"Aus Favoriten entfernen",edit:"Bearbeiten",goToProject:"Zum Projekt: {{name}}",addToProject:"Zu Projekt hinzufügen",removeFromProject:"Aus Projekt entfernen",loading:"Laden...",noProjectsAvailable:"Keine Projekte verfügbar",select:"Auswählen",deselect:"Abwählen",delete:"Löschen"},permission:{noReprint:"Sie haben keine Berechtigung, dieses Archiv erneut zu drucken",noAddToQueue:"Sie haben keine Berechtigung, zur Warteschlange hinzuzufügen",noUpdateArchives:"Sie haben keine Berechtigung, Archive zu aktualisieren",noUploadFiles:"Sie haben keine Berechtigung, Dateien hochzuladen",noDownload:"Sie haben keine Berechtigung, Archive herunterzuladen",noCopyLink:"Sie haben keine Berechtigung, Download-Links zu kopieren",noDelete:"Sie haben keine Berechtigung, dieses Archiv zu löschen",noCreate:"Sie haben keine Berechtigung, Archive zu erstellen"},card:{previousPlate:"Vorherige Platte",nextPlate:"Nächste Platte",plateNumber:"Platte {{index}}",moreOptions:"Rechtsklick für mehr Optionen",addToFavorites:"Zu Favoriten hinzufügen",removeFromFavorites:"Aus Favoriten entfernen",cancelled:"abgebrochen",failed:"fehlgeschlagen",duplicate:"Duplikat",duplicateTitle:"Dieses Modell wurde bereits zuvor gedruckt",openSource3mf:"Quell-3MF in Bambu Studio öffnen (Rechtsklick für mehr Optionen)",downloadF3d:"Fusion 360 Designdatei herunterladen",viewTimelapse:"Zeitraffer ansehen",viewPhoto:"1 Foto ansehen",viewPhotos:"{{count}} Fotos ansehen",openFolder:"Ordner öffnen: {{name}}",slicedFile:"Geslicte Datei - druckbereit",sourceFile:"Nur Quelldatei - keine AMS-Zuordnung verfügbar",gcode:"GCODE",source:"QUELLE",project:"Projekt: {{name}}",estimated:"Geschätzt: {{time}}",actual:"Tatsächlich: {{time}}",accuracy:"Genauigkeit: {{percent}}%",filament:"{{weight}}g",layer:"{{count}} Schicht",layers:"{{count}} Schichten",object:"{{count}} Objekt",objects:"{{count}} Objekte",slicedFor:"Geslict für {{model}}",uploadedBy:"Hochgeladen von {{name}}",noPermissionReprint:"Sie haben keine Berechtigung, erneut zu drucken",noPermissionEdit:"Sie haben keine Berechtigung, Archive zu bearbeiten",noPermissionDelete:"Sie haben keine Berechtigung, Archive zu löschen",reprint:"Drucken",schedulePrint:"Druck planen",schedule:"Planen",openInBambuStudio:"In Bambu Studio öffnen",openInBambuStudioToSlice:"In Bambu Studio öffnen zum Slicen",slice:"Slicen",externalLink:"Externer Link",makerWorld:"MakerWorld: {{designer}}",viewProject:"Projekt ansehen",noExternalLink:"Kein externer Link",preview3d:"3D-Vorschau",download:"Herunterladen",edit:"Bearbeiten",delete:"Löschen"},modal:{deleteArchive:"Archiv löschen",deleteConfirm:'Möchten Sie "{{name}}" wirklich löschen? Diese Aktion kann nicht rückgängig gemacht werden.',deleteButton:"Löschen",removeSource3mf:"Quell-3MF entfernen",removeSource3mfConfirm:'Möchten Sie die Quell-3MF-Datei wirklich von "{{name}}" entfernen? Die ursprüngliche Slicer-Projektdatei wird gelöscht.',removeButton:"Entfernen",removeF3d:"F3D entfernen",removeF3dConfirm:'Möchten Sie die Fusion 360 Designdatei wirklich von "{{name}}" entfernen?',timelapse:"{{name}} - Zeitraffer",selectTimelapse:"Zeitraffer auswählen",selectTimelapseDesc:"Keine automatische Übereinstimmung gefunden. Wählen Sie den Zeitraffer für diesen Druck:",deleteArchives:"Archive löschen",deleteArchivesConfirm:"Möchten Sie wirklich {{count}} Archiv(e) löschen? Diese Aktion kann nicht rückgängig gemacht werden.",deleteCount:"{{count}} löschen"},page:{title:"Archive",printsCount:"{{filtered}} von {{total}} Drucken",dropFilesHere:".3mf-Dateien hier ablegen",releaseToUpload:"Loslassen zum Hochladen",only3mfSupported:"Nur .3mf-Dateien werden unterstützt",close:"Schließen",selected:"{{count}} ausgewählt",selectAll:"Alle auswählen",tags:"Tags",project:"Projekt",favorite:"Favorit",delete:"Löschen",toggledFavorites:"Favoriten für {{count}} Archiv(e) umgeschaltet",failedUpdateFavorites:"Fehler beim Aktualisieren der Favoriten",archivesDeleted:"{{count}} Archiv(e) gelöscht",failedDeleteArchives:"Fehler beim Löschen der Archive",photoDeleted:"Foto gelöscht",failedDeletePhoto:"Fehler beim Löschen des Fotos"},list:{name:"Name",printer:"Drucker",date:"Datum",size:"Größe",actions:"Aktionen",hasTimelapse:"Hat Zeitraffer"}},queue:{title:"Druckwarteschlange",subtitle:"Planen und verwalten Sie Ihre Druckaufträge",addToQueue:"Zur Warteschlange hinzufügen",print:"Drucken",reprint:"Erneut drucken",schedulePrint:"Druck planen",editQueueItem:"Warteschlangeneintrag bearbeiten",printToPrinters:"Auf {{count}} Druckern drucken",queueToPrinters:"Zu {{count}} Druckern hinzufügen",sending:"Wird gesendet...",sendingProgress:"Sende {{current}}/{{total}}...",adding:"Wird hinzugefügt...",addingProgress:"Füge hinzu {{current}}/{{total}}...",savingProgress:"Speichere {{current}}/{{total}}...",clearQueue:"Warteschlange leeren",clearHistory:"Verlauf löschen",emptyQueue:"Warteschlange ist leer",position:"Position",scheduledTime:"Geplante Zeit",moveUp:"Nach oben",moveDown:"Nach unten",startNow:"Jetzt starten",printingInProgress:"Druck läuft...",viewArchive:"Archiv anzeigen",viewInFileManager:"Im Dateimanager anzeigen",itemCount:"{{count}} Element",itemCount_plural:"{{count}} Elemente",dragToReorder:"Ziehen zum Neuordnen (nur Sofort)",reorderHint:"Position betrifft nur Sofort-Elemente. Geplante Elemente werden zur festgelegten Zeit ausgeführt.",addedBy:"Hinzugefügt von {{name}}",sections:{currentlyPrinting:"Aktuell druckend",queued:"In Warteschlange",history:"Verlauf"},status:{pending:"Ausstehend",waiting:"Wartend",printing:"Druckt",completed:"Abgeschlossen",failed:"Fehlgeschlagen",skipped:"Übersprungen",cancelled:"Abgebrochen"},summary:{printing:"Druckt",queued:"In Warteschlange",totalTime:"Gesamte Wartezeit",history:"Verlauf"},filter:{allPrinters:"Alle Drucker",unassigned:"Nicht zugewiesen",allStatus:"Alle Status",allLocations:"Alle Standorte",any:"Beliebig"},sort:{byPosition:"Nach Position sortieren",byName:"Nach Name sortieren",byPrinter:"Nach Drucker sortieren",bySchedule:"Nach Zeitplan sortieren",byDate:"Nach Datum sortieren",ascendingOldest:"Aufsteigend (älteste zuerst)",descendingNewest:"Absteigend (neueste zuerst)"},badges:{staged:"Bereitgestellt",requiresPrevious:"Erfordert vorherigen Erfolg",autoPowerOff:"Automatisch ausschalten"},empty:{title:"Keine Drucke geplant",description:'Planen Sie einen Druck von der Archivseite über die Option "Planen" im Kontextmenü oder ziehen Sie Dateien hierher.'},time:{asap:"Sofort",overdue:"Überfällig",now:"Jetzt",lessThanMinute:"In weniger als einer Minute",inMinutes:"In {{count}} Min",inHours:"In {{count}} Stunden"},actions:{stopPrint:"Druck stoppen",startPrint:"Druck starten",requeue:"Erneut einreihen"},bulkEdit:{title:"{{count}} Element bearbeiten",title_plural:"{{count}} Elemente bearbeiten",description:"Nur geänderte Einstellungen werden auf ausgewählte Elemente angewendet.",printer:"Drucker",noChange:"— Keine Änderung —",queueOptions:"Warteschlangenoptionen",staged:"Bereitgestellt (manueller Start)",autoPowerOff:"Nach Druck automatisch ausschalten",requirePrevious:"Vorherigen Erfolg erfordern",printOptions:"Druckoptionen",bedLevelling:"Bett-Nivellierung",flowCalibration:"Fluss-Kalibrierung",vibrationCalibration:"Vibrations-Kalibrierung",layerInspection:"Erste-Schicht-Prüfung",timelapse:"Zeitraffer",useAms:"AMS verwenden",applyChanges:"Änderungen übernehmen",selectAll:"Alle auswählen",deselectAll:"Auswahl aufheben",selected:"{{count}} ausgewählt",editSelected:"Ausgewählte bearbeiten",cancelSelected:"Ausgewählte abbrechen"},confirm:{cancelTitle:"Geplanten Druck abbrechen",cancelMessage:'Möchten Sie "{{name}}" wirklich abbrechen?',stopTitle:"Druck stoppen",stopMessage:'Möchten Sie den aktuellen Druck "{{name}}" wirklich stoppen? Der Druckauftrag wird am Drucker abgebrochen.',removeTitle:"Aus Verlauf entfernen",removeMessage:'Möchten Sie "{{name}}" wirklich aus dem Warteschlangenverlauf entfernen?',clearHistoryTitle:"Verlauf löschen",clearHistoryMessage:"Möchten Sie alle {{count}} Element(e) aus dem Verlauf entfernen?",cancelButton:"Druck abbrechen",stopButton:"Druck stoppen",thisPrint:"diesen Druck",thisItem:"dieses Element"},toast:{cancelled:"Warteschlangenelement abgebrochen",cancelFailed:"Element konnte nicht abgebrochen werden",removed:"Warteschlangenelement entfernt",removeFailed:"Element konnte nicht entfernt werden",stopped:"Druck gestoppt",stopFailed:"Druck konnte nicht gestoppt werden",released:"Druck in Warteschlange freigegeben",startFailed:"Druck konnte nicht gestartet werden",reorderFailed:"Warteschlange konnte nicht neu geordnet werden",historyCleared:"{{count}} Verlaufselement(e) gelöscht",clearHistoryFailed:"Verlauf konnte nicht gelöscht werden",updateFailed:"Elemente konnten nicht aktualisiert werden",bulkCancelled:"{{count}} Element(e) abgebrochen",bulkCancelFailed:"Elemente konnten nicht abgebrochen werden"},permissions:{noStopPrint:"Sie haben keine Berechtigung, Drucke zu stoppen",noStartPrint:"Sie haben keine Berechtigung, Drucke zu starten",noEdit:"Sie haben keine Berechtigung, dieses Warteschlangenelement zu bearbeiten",noCancel:"Sie haben keine Berechtigung, dieses Warteschlangenelement abzubrechen",noRequeue:"Sie haben keine Berechtigung, Elemente erneut einzureihen",noRemove:"Sie haben keine Berechtigung, dieses Warteschlangenelement zu entfernen",noClearHistory:"Sie haben keine Berechtigung, den gesamten Verlauf zu löschen",noEditItems:"Sie haben keine Berechtigung, Warteschlangenelemente zu bearbeiten",noCancelItems:"Sie haben keine Berechtigung, Warteschlangenelemente abzubrechen"}},stats:{title:"Dashboard",subtitle:"Widgets zum Neuanordnen ziehen. Auf das Augensymbol klicken zum Ausblenden.",overview:"Übersicht",totalPrints:"Gesamtdrucke",successRate:"Erfolgsrate",totalPrintTime:"Gesamtdruckzeit",printTime:"Druckzeit",totalFilament:"Gesamtverbrauch Filament",filamentUsed:"Filamentverbrauch",filamentCost:"Filamentkosten",totalCost:"Gesamtkosten",energyUsed:"Energieverbrauch",energyCost:"Energiekosten",averagePrintTime:"Durchschnittliche Druckzeit",printsPerDay:"Drucke pro Tag",byPrinter:"Nach Drucker",printsByPrinter:"Drucke nach Drucker",byMaterial:"Nach Material",byMonth:"Nach Monat",last7Days:"Letzte 7 Tage",last30Days:"Letzte 30 Tage",last90Days:"Letzte 90 Tage",allTime:"Gesamt",quickStats:"Schnellstatistiken",printActivity:"Druckaktivität",filamentTypes:"Filamenttypen",filamentTrends:"Filamenttrends",failureAnalysis:"Fehleranalyse",timeAccuracy:"Zeitgenauigkeit",successful:"Erfolgreich:",failed:"Fehlgeschlagen:",perfectEstimate:"100% = perfekte Schätzung",noTimeAccuracyData:"Noch keine Zeitgenauigkeitsdaten",noFilamentData:"Keine Filamentdaten verfügbar",noPrinterData:"Keine Druckerdaten verfügbar",noPrintData:"Keine Druckdaten verfügbar",noPrintDataLast30Days:"Keine Druckdaten in den letzten 30 Tagen",failureReasons:"Fehlerursachen",topFailureReasons:"Häufigste Fehlerursachen",failedPrintsCount:"{{failed}} / {{total}} Drucke fehlgeschlagen",lastWeekRate:"Letzte Woche: {{rate}}%",resetLayout:"Layout zurücksetzen",recalculateCosts:"Kosten neu berechnen",recalculateCostsHint:"Alle Archivkosten mit aktuellen Filamentpreisen neu berechnen",exportStats:"Statistiken exportieren",exportAsCsv:"Als CSV exportieren",exportAsExcel:"Als Excel exportieren",hiddenCount:"{{count}} ausgeblendet",exportDownloaded:"Export heruntergeladen",exportFailed:"Export fehlgeschlagen",layoutReset:"Layout zurückgesetzt",recalculatedCosts:"Kosten für {{count}} Archive neu berechnet",recalculateFailed:"Kosten konnten nicht neu berechnet werden",loadingStats:"Statistiken werden geladen...",noPermissionResetLayout:"Sie haben keine Berechtigung, das Layout zurückzusetzen",noPermissionRecalculate:"Sie haben keine Berechtigung, Kosten neu zu berechnen"},maintenance:{title:"Wartung",overview:"Übersicht",allOk:"Alle Wartungen aktuell",dueCount:"{{count}} Aufgabe fällig",dueCount_plural:"{{count}} Aufgaben fällig",warningCount:"{{count}} Warnung",warningCount_plural:"{{count}} Warnungen",totalPrintTime:"Gesamtdruckzeit",nextMaintenance:"Nächste Wartung",nothingDue:"Nichts fällig",tasks:"Aufgaben",lastPerformed:"Zuletzt durchgeführt",interval:"Intervall",hoursRemaining:"{{hours}}h verbleibend",hoursOverdue:"{{hours}}h überfällig",markDone:"Als erledigt markieren",performMaintenance:"Wartung durchführen",history:"Verlauf",noHistory:"Kein Wartungsverlauf",editPrintHours:"Druckstunden bearbeiten",currentHours:"Aktuelle Stunden",statusTab:"Status",settingsTab:"Einstellungen",overdueCount:"{{count}} überfällig",dueSoonCount:"{{count}} bald fällig",dueSoon:"Bald fällig",allGood:"Alles in Ordnung",overdueBy:"Überfällig um {{duration}}",dueIn:"Fällig in {{duration}}",timeLeft:"{{duration}} verbleibend",day:"1 Tag",days:"{{count}} Tage",week:"1 Woche",weeks:"{{count}} Wochen",month:"1 Monat",months:"{{count}} Monate",year:"1 Jahr",maintenanceTypes:"Wartungstypen",maintenanceTypesDescription:"Systemtypen und Ihre benutzerdefinierten Wartungsaufgaben",addCustomType:"Benutzerdefinierten Typ hinzufügen",intervalType:"Intervalltyp",intervalValue:"Intervall ({{type}})",icon:"Symbol",documentationLink:"Dokumentationslink (optional)",assignToPrinters:"Druckern zuweisen",selectAtLeastOnePrinter:"Wählen Sie mindestens einen Drucker",addType:"Typ hinzufügen",custom:"Benutzerdefiniert",printHours:"Druckstunden",calendarDays:"Kalendertage",exampleName:"z.B. HEPA-Filter ersetzen",viewDocumentation:"Dokumentation anzeigen",timeBasedInterval:"Zeitbasiertes Intervall",intervalOverrides:"Intervall-Überschreibungen",intervalOverridesDescription:"Intervalle für bestimmte Drucker anpassen",assignedToPrinters:"Druckern zugewiesen:",noPrintersAssigned:"Keine Drucker zugewiesen",addPrinterShort:"Hinzufügen:",printersAssignedClick:"{{count}} Drucker zugewiesen - klicken zum Verwalten",removeFromPrinter:"Von diesem Drucker entfernen",types:{lubricateRails:"Linearschienen schmieren",cleanNozzle:"Düse/Hotend reinigen",checkBelts:"Riemenspannung prüfen",cleanBuildPlate:"Druckbett reinigen",checkExtruder:"Extruderzahnräder prüfen",checkCooling:"Kühlungslüfter prüfen",generalInspection:"Allgemeine Inspektion",cleanCarbonRods:"Kohlenstoffstangen reinigen",checkPtfeTube:"PTFE-Schlauch prüfen",replaceHepaFilter:"HEPA-Filter ersetzen",replaceCarbonFilter:"Aktivkohlefilter ersetzen",lubricateLeftNozzleRail:"Linke Düsenschiene schmieren"},maintenanceComplete:"Wartung als abgeschlossen markiert",typeUpdated:"Wartungstyp aktualisiert",typeDeleted:"Wartungstyp gelöscht",printHoursUpdated:"Druckstunden aktualisiert",printerAssigned:"Drucker zugewiesen",printerRemoved:"Drucker entfernt",deleteTypeConfirm:'"{{name}}" löschen?',noPermissionUpdate:"Sie haben keine Berechtigung, Wartungselemente zu aktualisieren",noPermissionPerform:"Sie haben keine Berechtigung, Wartungen durchzuführen",noPermissionEditTypes:"Sie haben keine Berechtigung, Wartungstypen zu bearbeiten",noPermissionDeleteTypes:"Sie haben keine Berechtigung, Wartungstypen zu löschen",noPermissionEditHours:"Sie haben keine Berechtigung, Druckstunden zu bearbeiten",noPermissionRemovePrinter:"Sie haben keine Berechtigung, Druckerzuweisungen zu entfernen",noPermissionAssignPrinter:"Sie haben keine Berechtigung, Drucker zuzuweisen",noPermissionEditIntervals:"Sie haben keine Berechtigung, Intervalle zu bearbeiten",configureSettings:"Wartungstypen und Intervalle konfigurieren"},settings:{title:"Einstellungen",general:"Allgemein",tabs:{general:"Allgemein",smartPlugs:"Smart Plugs",notifications:"Benachrichtigungen",filament:"Filament",network:"Netzwerk",apiKeys:"API-Schlüssel",virtualPrinter:"Virtueller Drucker",users:"Benutzer",backup:"Sicherung"},appearance:"Erscheinungsbild",notifications:"Benachrichtigungen",smartPlugs:"Smart Plugs",spoolman:"Spoolman",updates:"Updates",language:"Sprache",languageDescription:"Wählen Sie Ihre bevorzugte Sprache",theme:"Design",themeLight:"Hell",themeDark:"Dunkel",themeSystem:"System",defaultView:"Standardansicht",defaultViewDescription:"Seite, die beim Öffnen der App angezeigt wird",checkForUpdates:"Nach Updates suchen",autoUpdate:"Automatische Updates",currentVersion:"Aktuelle Version",latestVersion:"Neueste Version",upToDate:"Sie sind auf dem neuesten Stand",updateAvailable:"Update verfügbar",notificationLanguage:"Benachrichtigungssprache",notificationLanguageDescription:"Sprache für Push-Benachrichtigungen",notificationProviders:"Benachrichtigungsanbieter",addProvider:"Anbieter hinzufügen",editProvider:"Anbieter bearbeiten",providerType:"Anbietertyp",testNotification:"Testbenachrichtigung",testSuccess:"Testbenachrichtigung erfolgreich gesendet",testFailed:"Testbenachrichtigung konnte nicht gesendet werden",quietHours:"Ruhezeiten",quietHoursDescription:"Keine Störungen während dieser Zeiten",quietHoursStart:"Beginn",quietHoursEnd:"Ende",events:{title:"Benachrichtigungsereignisse",printStart:"Druck gestartet",printComplete:"Druck abgeschlossen",printFailed:"Druck fehlgeschlagen",printStopped:"Druck gestoppt",printProgress:"Fortschrittsmeldungen",printProgressDescription:"Bei 25%, 50%, 75% benachrichtigen",printerOffline:"Drucker offline",printerError:"Druckerfehler",filamentLow:"Filament niedrig",maintenanceDue:"Wartung fällig",maintenanceDueDescription:"Benachrichtigen, wenn Wartung erforderlich"},smartPlug:{title:"Smart Plugs",add:"Smart Plug hinzufügen",edit:"Smart Plug bearbeiten",name:"Name",ipAddress:"IP-Adresse",linkedPrinter:"Verknüpfter Drucker",autoOn:"Automatisch einschalten",autoOnDescription:"Einschalten beim Druckstart",autoOff:"Automatisch ausschalten",autoOffDescription:"Ausschalten nach Druckende",offDelay:"Ausschaltverzögerung",offDelayMinutes:"Minuten nach Druck",offDelayTemp:"Wenn Düse unter Temperatur",currentState:"Aktueller Status",turnOn:"Einschalten",turnOff:"Ausschalten"},spoolmanEnabled:"Spoolman-Integration aktivieren",spoolmanUrl:"Spoolman URL",spoolmanConnected:"Verbunden",spoolmanDisconnected:"Nicht verbunden",noDefaultPrinter:"Kein Standard (jedes Mal fragen)",sidebarOrder:"Seitenleisten-Reihenfolge",saveThumbnails:"Vorschaubilder speichern",captureFinishPhoto:"Abschlussfoto aufnehmen",noPrintersConfigured:"Keine Drucker konfiguriert",archiveMode:{always:"Immer Archiveintrag erstellen",never:"Nie Archiveintrag erstellen",ask:"Jedes Mal fragen"},checkForUpdatesLabel:"Nach Updates suchen",checkPrinterFirmware:"Drucker-Firmware prüfen",enableRetry:"Wiederholung aktivieren",homeAssistantDescription:"Smart Plugs über Home Assistant steuern",mqttConnectedTo:"Verbunden mit",prometheusDescription:"Druckerdaten im Prometheus-Format bereitstellen",noSmartPlugsTitle:"Keine Smart Plugs konfiguriert",noSmartPlugsDescription:"Fügen Sie einen Tasmota-basierten Smart Plug hinzu, um den Energieverbrauch zu verfolgen und die Stromsteuerung zu automatisieren.",noProvidersTitle:"Keine Anbieter konfiguriert",noProvidersDescription:"Fügen Sie einen Anbieter hinzu, um Benachrichtigungen zu erhalten.",noTemplatesAvailable:"Keine Vorlagen verfügbar. Starten Sie das Backend neu, um Standardvorlagen zu laden.",apiPermissionView:"Druckerstatus und Warteschlange anzeigen",apiPermissionEdit:"Elemente zur Druckwarteschlange hinzufügen und entfernen",apiKeysEmptyTitle:"Keine API-Schlüssel",apiKeysEmptyDescription:"Erstellen Sie einen API-Schlüssel zur Integration mit externen Diensten.",noUsersFound:"Keine Benutzer gefunden",noGroupsFound:"Keine Gruppen gefunden",noGroupsAvailable:"Keine Gruppen verfügbar",passwordsDoNotMatch:"Passwörter stimmen nicht überein",systemGroupWarning:"System-Gruppennamen können nicht geändert werden",authDisabledTitle:"Authentifizierung ist deaktiviert",authDisabledFeature1:"Anmeldung zum Zugriff auf das System erforderlich",authDisabledFeature2:"Mehrere Benutzer mit gruppenbasierten Berechtigungen erstellen",authDisabledFeature3:"Zugriff mit über 50 granularen Berechtigungen steuern",userHasCreated:"Dieser Benutzer hat erstellt:",userItemsQuestion:"Was möchten Sie mit diesen Elementen tun?",deleteUserConfirm:"Möchten Sie diesen Benutzer wirklich löschen?",actionCannotBeUndone:"Diese Aktion kann nicht rückgängig gemacht werden.",addFirstSmartPlug:"Ersten Smart Plug hinzufügen",providers:"Anbieter",log:"Protokoll",testAll:"Alle testen",testResults:"Testergebnisse",testPassedCount:"{{count}} bestanden",testFailedCount:"{{count}} fehlgeschlagen",messageTemplates:"Nachrichtenvorlagen",messageTemplatesDescription:"Passen Sie Benachrichtigungen für jedes Ereignis an.",apiKeys:"API-Schlüssel",apiKeysDescription:"Erstellen Sie API-Schlüssel für externe Integrationen und Webhooks.",createKey:"Schlüssel erstellen",apiKeyCreated:"API-Schlüssel erfolgreich erstellt",apiKeyCopyWarning:"Kopieren Sie diesen Schlüssel jetzt - er wird nicht mehr angezeigt!",useInApiBrowser:"Im API-Browser verwenden",createNewApiKey:"Neuen API-Schlüssel erstellen",keyName:"Schlüsselname",keyNamePlaceholder:"z.B. Home Assistant, OctoPrint",readStatus:"Status lesen",readStatusDescription:"Druckerstatus und Warteschlange anzeigen",manageQueue:"Warteschlange verwalten",manageQueueDescription:"Elemente zur Druckwarteschlange hinzufügen und entfernen",controlPrinter:"Drucker steuern",controlPrinterDescription:"Drucke pausieren, fortsetzen und stoppen",unnamedKey:"Unbenannter Schlüssel",lastUsed:"Zuletzt verwendet",read:"Lesen",control:"Steuern",createFirstKey:"Ersten Schlüssel erstellen",webhookEndpoints:"Webhook-Endpunkte",webhookApiKeyHint:"Verwenden Sie Ihren API-Schlüssel im X-API-Key-Header.",webhook:{getAllStatus:"Alle Druckerstatus abrufen",getSpecificStatus:"Spezifischen Druckerstatus abrufen",addToQueue:"Zur Druckwarteschlange hinzufügen",pausePrint:"Druck pausieren",resumePrint:"Druck fortsetzen",stopPrint:"Druck stoppen"},apiBrowser:"API-Browser",apiBrowserDescription:"Erkunden und testen Sie alle verfügbaren API-Endpunkte.",apiKeyForTesting:"API-Schlüssel zum Testen",apiKeyPlaceholder:"Fügen Sie hier Ihren API-Schlüssel ein, um authentifizierte Endpunkte zu testen...",apiKeyHint:"Dieser Schlüssel wird als X-API-Key-Header mit Anfragen gesendet.",deleteApiKeyTitle:"API-Schlüssel löschen",deleteApiKeyMessage:"Möchten Sie diesen API-Schlüssel wirklich löschen? Alle Integrationen, die diesen Schlüssel verwenden, funktionieren nicht mehr.",deleteKey:"Schlüssel löschen",amsDisplayThresholds:"AMS-Anzeigeschwellenwerte",amsThresholdsDescription:"Konfigurieren Sie Farbschwellenwerte für AMS-Feuchtigkeits- und Temperaturanzeigen.",humidity:"Luftfeuchtigkeit",goodGreen:"Gut (grün)",fairOrange:"Mittel (orange)",aboveFairBad:"Über dem mittleren Schwellenwert wird rot angezeigt (schlecht)",temperature:"Temperatur",goodBlue:"Gut (blau)",aboveFairHot:"Über dem mittleren Schwellenwert wird rot angezeigt (heiß)",historyRetention:"Verlaufsaufbewahrung",keepSensorHistory:"Sensorverlauf behalten für",historyRetentionDescription:"Ältere Feuchtigkeits- und Temperaturdaten werden automatisch gelöscht",printModal:"Druckdialog",expandCustomMapping:"Benutzerdefinierte Zuordnung standardmäßig erweitern",expandCustomMappingDescription:"Bei Druck auf mehrere Drucker die AMS-Zuordnung pro Drucker erweitert anzeigen",authentication:"Authentifizierung",authEnabledDescription:"Ihre Instanz ist mit Benutzerauthentifizierung gesichert",authDisabledDescription:"Aktivieren Sie die Anmeldepflicht und verwalten Sie den Benutzerzugriff",authDisabledMessage:"Aktivieren Sie die Authentifizierung, um Benutzerkonten zu erstellen, Berechtigungen zu verwalten und Ihre Bambuddy-Instanz zu sichern.",enableAuthentication:"Authentifizierung aktivieren",currentUser:"Aktueller Benutzer",changePassword:"Passwort ändern",admin:"Admin",users:"Benutzer",addUser:"Benutzer hinzufügen",groups:"Gruppen",addGroup:"Gruppe hinzufügen",system:"System",noDescription:"Keine Beschreibung",userCount:"{{count}} Benutzer",permissionCount:"{{count}} Berechtigungen",createUser:"Benutzer erstellen",username:"Benutzername",enterUsername:"Benutzername eingeben",password:"Passwort",enterPassword:"Passwort eingeben (min. 6 Zeichen)",confirmPassword:"Passwort bestätigen",confirmPasswordPlaceholder:"Passwort bestätigen",viewReleaseOnGitHub:"Release auf GitHub anzeigen",turnAllPlugsOn:"Alle Stecker einschalten",turnAllPlugsOff:"Alle Stecker ausschalten",clearNotificationLogs:"Benachrichtigungsprotokolle löschen",clearLogsMessage:"Dadurch werden alle Benachrichtigungsprotokolle, die älter als 30 Tage sind, dauerhaft gelöscht. Diese Aktion kann nicht rückgängig gemacht werden.",clearLogs:"Protokolle löschen",resetUiPreferences:"UI-Einstellungen zurücksetzen",resetUiPreferencesMessage:"Dadurch werden alle UI-Einstellungen auf Standardwerte zurückgesetzt: Seitenleisten-Reihenfolge, Theme, Dashboard-Layout, Ansichtsmodi und Sortiereinstellungen. Ihre Drucker, Archive und Servereinstellungen werden NICHT beeinträchtigt. Die Seite wird nach dem Löschen neu geladen.",resetPreferences:"Einstellungen zurücksetzen",deleteGroupTitle:"Gruppe löschen",deleteGroupMessage:"Möchten Sie diese Gruppe wirklich löschen? Benutzer in dieser Gruppe verlieren diese Berechtigungen.",deleteGroup:"Gruppe löschen",disableAuthenticationTitle:"Authentifizierung deaktivieren",disableAuthenticationMessage:"Möchten Sie die Authentifizierung wirklich deaktivieren? Dadurch wird Ihre Bambuddy-Instanz ohne Anmeldung zugänglich. Alle Benutzer bleiben in der Datenbank, aber die Authentifizierung wird deaktiviert.",disableAuthentication:"Authentifizierung deaktivieren",configureBambuddy:"Bambuddy konfigurieren",systemDefault:"Systemstandard",archiveSettings:"Archiv-Einstellungen",newWindow:"Neues Fenster",embeddedOverlay:"Eingebettetes Overlay",externalCameras:"Externe Kameras",costTracking:"Kostenverfolgung",printsOnly:"Nur Drucke",totalConsumption:"Gesamtverbrauch",dataManagement:"Datenverwaltung",clearNotificationLogsDescription:"Benachrichtigungsprotokolle älter als 30 Tage löschen",resetUiPreferencesDescription:"Seitenleisten-Reihenfolge, Theme, Ansichtsmodi und Layout-Einstellungen zurücksetzen. Drucker, Archive und Einstellungen werden nicht beeinflusst.",enableHomeAssistant:"Home Assistant aktivieren",enableMqtt:"MQTT aktivieren",useTls:"TLS verwenden",enableMetricsEndpoint:"Metrik-Endpunkt aktivieren",availableMetrics:"Verfügbare Metriken",editUser:"Benutzer bearbeiten",deleteUserTitle:"Benutzer löschen",groupName:"Gruppenname",leaveEmptyForAnonymous:"Leer lassen für anonym",leaveEmptyForNoAuth:"Leer lassen für keine Authentifizierung",enterNewPassword:"Neues Passwort eingeben",confirmNewPassword:"Neues Passwort bestätigen",enterGroupName:"Gruppenname eingeben",enterDescriptionOptional:"Beschreibung eingeben (optional)",enterCurrentPassword:"Aktuelles Passwort eingeben",enterNewPasswordMin6:"Neues Passwort eingeben (min. 6 Zeichen)",toast:{keyCopied:"Schlüssel in Zwischenablage kopiert",copyFailed:"Schlüssel konnte nicht kopiert werden",keyAddedToBrowser:"Schlüssel zum API-Browser hinzugefügt",clearLogsFailed:"Protokolle konnten nicht gelöscht werden",uiPreferencesReset:"UI-Einstellungen zurückgesetzt. Wird neu geladen...",authDisabled:"Authentifizierung erfolgreich deaktiviert",authDisableFailed:"Authentifizierung konnte nicht deaktiviert werden",apiKeyCreated:"API-Schlüssel erstellt",apiKeyDeleted:"API-Schlüssel gelöscht",userCreated:"Benutzer erfolgreich erstellt",userUpdated:"Benutzer erfolgreich aktualisiert",userDeleted:"Benutzer erfolgreich gelöscht",groupCreated:"Gruppe erfolgreich erstellt",groupUpdated:"Gruppe erfolgreich aktualisiert",groupDeleted:"Gruppe erfolgreich gelöscht",fillRequiredFields:"Bitte füllen Sie alle erforderlichen Felder aus",passwordsDoNotMatch:"Passwörter stimmen nicht überein",passwordTooShort:"Passwort muss mindestens 6 Zeichen lang sein",enterGroupName:"Bitte geben Sie einen Gruppennamen ein",settingsSaved:"Einstellungen gespeichert",cameraSettingsSaved:"Kamera-Einstellungen gespeichert",enterCameraUrl:"Bitte geben Sie eine Kamera-URL ein",passwordChanged:"Passwort erfolgreich geändert",connectionFailed:"Verbindung fehlgeschlagen",testFailed:"Test fehlgeschlagen",cameraConnected:"Kamera verbunden{{resolution}}"},testConnection:"Verbindung testen"},notification:{printStarted:{title:"Druck gestartet",body:"{{printer}}: {{filename}} wird gedruckt"},printCompleted:{title:"Druck abgeschlossen",body:"{{printer}}: {{filename}} erfolgreich abgeschlossen"},printFailed:{title:"Druck fehlgeschlagen",body:"{{printer}}: {{filename}} ist fehlgeschlagen"},printStopped:{title:"Druck gestoppt",body:"{{printer}}: {{filename}} wurde gestoppt"},printProgress:{title:"Druckfortschritt",body:"{{printer}}: {{filename}} ist zu {{percent}}% abgeschlossen"},printerOffline:{title:"Drucker offline",body:"{{printer}} ist offline"},printerError:{title:"Druckerfehler",body:"{{printer}}: {{error}}"},filamentLow:{title:"Filament niedrig",body:"{{printer}}: Filament geht zur Neige"},maintenanceDue:{title:"Wartung fällig",body:"{{printer}}: {{items}} benötigen Aufmerksamkeit"}},errors:{generic:"Etwas ist schiefgelaufen",networkError:"Netzwerkfehler. Bitte überprüfen Sie Ihre Verbindung.",notFound:"Nicht gefunden",unauthorized:"Nicht autorisiert",serverError:"Serverfehler",validationError:"Bitte überprüfen Sie Ihre Eingabe",printerConnectionFailed:"Verbindung zum Drucker fehlgeschlagen",saveFailed:"Speichern fehlgeschlagen",deleteFailed:"Löschen fehlgeschlagen",loadFailed:"Laden der Daten fehlgeschlagen"},hmsErrors:{title:"Fehler - {{name}}",noErrors:"Keine Fehler",viewOnWiki:"Im Bambu Lab Wiki ansehen",clearInstructions:"Löschen Sie die Fehler am Drucker, um sie hier zu entfernen."},mqttDebug:{title:"MQTT-Debug-Protokoll",searchPlaceholder:"Topic oder Payload suchen...",noMessages:"Noch keine Nachrichten protokolliert",startLoggingHint:'Klicken Sie auf "Protokollierung starten", um MQTT-Nachrichten aufzuzeichnen',noMessagesMatch:"Keine Nachrichten entsprechen Ihrem Filter",adjustFilterHint:"Versuchen Sie, Ihre Such- oder Filterkriterien anzupassen",incoming:"Eingehend",outgoing:"Ausgehend",loggingStopped:"Protokollierung gestoppt",loggingActive:"Protokollierung aktiv - Nachrichten werden automatisch aktualisiert",startLogging:"Protokollierung starten",stopLogging:"Protokollierung stoppen",clearLog:"Protokoll löschen",topic:"Topic",timestamp:"Zeitstempel",direction:"Richtung",all:"Alle"},printerFiles:{title:"Dateimanager",storageUsed:"Belegt:",storageFree:"Frei:",filterPlaceholder:"Dateien filtern...",deleteButton:"Löschen",deleteFiles:"{{count}} Dateien löschen",deleteFileConfirm:'"{{name}}" löschen? Dies kann nicht rückgängig gemacht werden.',deleteFilesConfirm:"{{count}} ausgewählte Dateien löschen? Dies kann nicht rückgängig gemacht werden.",noFiles:"Keine Dateien auf dem Drucker",loadingFiles:"Dateien werden geladen...",failedToLoad:"Dateien konnten nicht geladen werden",toast:{filesDeleted:"{{count}} Datei(en) gelöscht",deleteFailed:"Löschen fehlgeschlagen: {{error}}"}},confirm:{delete:"Möchten Sie dies wirklich löschen?",unsavedChanges:"Sie haben ungespeicherte Änderungen. Möchten Sie wirklich verlassen?",clearQueue:"Möchten Sie die Warteschlange wirklich leeren?"},login:{title:"Bambuddy Anmeldung",subtitle:"Melden Sie sich bei Ihrem Konto an",username:"Benutzername",usernamePlaceholder:"Benutzername eingeben",password:"Passwort",passwordPlaceholder:"Passwort eingeben",signIn:"Anmelden",signingIn:"Anmeldung läuft...",forgotPassword:"Passwort vergessen?",loginSuccess:"Erfolgreich angemeldet",loginFailed:"Anmeldung fehlgeschlagen",enterCredentials:"Bitte Benutzername und Passwort eingeben",forgotPasswordTitle:"Passwort vergessen",forgotPasswordMessage:"Wenn Sie Ihr Passwort vergessen haben, wenden Sie sich bitte an Ihren Systemadministrator.",howToReset:"So setzen Sie Ihr Passwort zurück:",resetStep1:"Kontaktieren Sie Ihren Bambuddy-Administrator",resetStep2:"Bitten Sie ihn, Ihr Passwort in der Benutzerverwaltung zurückzusetzen",resetStep3:"Er kann ein neues temporäres Passwort für Sie festlegen",resetStep4:"Melden Sie sich mit dem neuen Passwort an und ändern Sie es in den Einstellungen",gotIt:"Verstanden"},setup:{title:"Bambuddy Einrichtung",subtitle:"Konfigurieren Sie die Authentifizierung für Ihre Bambuddy-Instanz",enableAuth:"Authentifizierung aktivieren",adminAccount:"Admin-Konto",adminAccountDesc:"Wenn bereits Admin-Benutzer existieren, wird die Authentifizierung mit den vorhandenen Admin-Konten aktiviert. Lassen Sie die Felder unten leer, um vorhandene Admins zu verwenden, oder geben Sie neue Anmeldedaten ein, um einen neuen Admin-Benutzer zu erstellen.",adminUsername:"Admin-Benutzername",adminPassword:"Admin-Passwort",optionalIfAdminExists:"(optional, wenn Admin-Benutzer existieren)",adminUsernamePlaceholder:"Admin-Benutzernamen eingeben (optional)",adminPasswordPlaceholder:"Admin-Passwort eingeben (optional)",confirmPassword:"Passwort bestätigen",confirmPasswordPlaceholder:"Admin-Passwort bestätigen",settingUp:"Einrichtung läuft...",completeSetup:"Einrichtung abschließen",toast:{authEnabledAdminCreated:"Authentifizierung aktiviert und Admin-Benutzer erstellt",authEnabledExistingAdmins:"Authentifizierung mit vorhandenen Admin-Benutzern aktiviert",setupCompleted:"Einrichtung abgeschlossen",enterBothCredentials:"Bitte geben Sie sowohl Admin-Benutzernamen als auch Passwort ein, oder lassen Sie beide leer, um vorhandene Admin-Benutzer zu verwenden",passwordsDoNotMatch:"Passwörter stimmen nicht überein",passwordTooShort:"Passwort muss mindestens 6 Zeichen lang sein"}},changePassword:{title:"Passwort ändern",currentPassword:"Aktuelles Passwort",currentPasswordPlaceholder:"Aktuelles Passwort eingeben",newPassword:"Neues Passwort",newPasswordPlaceholder:"Neues Passwort eingeben (min. 6 Zeichen)",confirmPassword:"Neues Passwort bestätigen",confirmPasswordPlaceholder:"Neues Passwort bestätigen",passwordsDoNotMatch:"Passwörter stimmen nicht überein",passwordTooShort:"Passwort muss mindestens 6 Zeichen lang sein",changing:"Wird geändert...",success:"Passwort erfolgreich geändert",failed:"Passwortänderung fehlgeschlagen"},plateAlert:{title:"Druck pausiert!",message:"Objekte auf dem Druckbett erkannt. Der Druck wurde automatisch pausiert. Bitte räumen Sie das Druckbett und setzen Sie den Druck fort.",understand:"Verstanden"},camera:{title:"Kameraansicht",invalidPrinterId:"Ungültige Drucker-ID",live:"Live",snapshot:"Schnappschuss",restartStream:"Stream neu starten",refreshSnapshot:"Schnappschuss aktualisieren",fullscreen:"Vollbild",exitFullscreen:"Vollbild beenden",connectingToCamera:"Verbinde mit Kamera...",capturingSnapshot:"Schnappschuss wird aufgenommen...",connectionLost:"Verbindung verloren",connectionFailed:"Kameraverbindung fehlgeschlagen",reconnecting:"Neuverbindung in {{countdown}}s... (Versuch {{attempt}}/{{max}})",reconnectNow:"Jetzt verbinden",cameraUnavailable:"Kamera nicht verfügbar",cameraUnavailableDesc:"Stellen Sie sicher, dass der Drucker eingeschaltet und verbunden ist.",noCamera:"Keine Kamera verfügbar",retry:"Erneut versuchen",cameraStream:"Kamera-Stream",zoomOut:"Verkleinern",zoomIn:"Vergrößern",resetZoom:"Zoom zurücksetzen",recording:"Aufnahme",startRecording:"Aufnahme starten",stopRecording:"Aufnahme stoppen"},groups:{title:"Gruppenverwaltung",subtitle:"Berechtigungsgruppen für Zugriffskontrolle verwalten",backToSettings:"Zurück zu Einstellungen",createGroup:"Gruppe erstellen",noPermission:"Sie haben keine Berechtigung, auf diese Seite zuzugreifen.",system:"System",noDescription:"Keine Beschreibung",usersCount:"{{count}} Benutzer",permissionsCount:"{{count}} Berechtigungen",edit:"Bearbeiten",delete:"Löschen",toast:{created:"Gruppe erfolgreich erstellt",updated:"Gruppe erfolgreich aktualisiert",deleted:"Gruppe erfolgreich gelöscht",enterGroupName:"Bitte geben Sie einen Gruppennamen ein"},modal:{editGroup:"Gruppe bearbeiten",createGroup:"Gruppe erstellen",cancel:"Abbrechen",saving:"Speichern...",creating:"Erstellen...",saveChanges:"Änderungen speichern"},form:{groupName:"Gruppenname",groupNamePlaceholder:"Gruppennamen eingeben",systemGroupWarning:"Systemgruppennamen können nicht geändert werden",description:"Beschreibung",descriptionPlaceholder:"Beschreibung eingeben (optional)",permissions:"Berechtigungen ({{count}} ausgewählt)"},deleteModal:{title:"Gruppe löschen",message:"Sind Sie sicher, dass Sie diese Gruppe löschen möchten? Benutzer in dieser Gruppe verlieren diese Berechtigungen.",confirm:"Gruppe löschen"}},users:{title:"Benutzerverwaltung",subtitle:"Benutzer und deren Zugriff auf Ihre Bambuddy-Instanz verwalten",backToSettings:"Zurück zu Einstellungen",createUser:"Benutzer erstellen",noPermission:"Sie haben keine Berechtigung, auf diese Seite zuzugreifen.",admin:"Admin",noGroups:"Keine Gruppen",active:"Aktiv",inactive:"Inaktiv",edit:"Bearbeiten",delete:"Löschen",system:"System",noGroupsAvailable:"Keine Gruppen verfügbar",table:{username:"Benutzername",groups:"Gruppen",status:"Status",actions:"Aktionen"},toast:{created:"Benutzer erfolgreich erstellt",updated:"Benutzer erfolgreich aktualisiert",deleted:"Benutzer erfolgreich gelöscht",fillRequired:"Bitte füllen Sie alle Pflichtfelder aus",passwordsDoNotMatch:"Passwörter stimmen nicht überein",passwordTooShort:"Passwort muss mindestens 6 Zeichen lang sein"},modal:{createUser:"Benutzer erstellen",editUser:"Benutzer bearbeiten",cancel:"Abbrechen",creating:"Erstellen...",saving:"Speichern...",saveChanges:"Änderungen speichern"},form:{username:"Benutzername",usernamePlaceholder:"Benutzernamen eingeben",password:"Passwort",passwordPlaceholder:"Passwort eingeben",confirmPassword:"Passwort bestätigen",confirmPasswordPlaceholder:"Passwort bestätigen",newPasswordPlaceholder:"Neues Passwort eingeben",confirmNewPasswordPlaceholder:"Neues Passwort bestätigen",leaveBlankToKeep:"leer lassen, um das aktuelle zu behalten",groups:"Gruppen"},deleteModal:{title:"Benutzer löschen",message:"Sind Sie sicher, dass Sie diesen Benutzer löschen möchten? Diese Aktion kann nicht rückgängig gemacht werden.",confirm:"Benutzer löschen"}},streamOverlay:{title:"Stream-Overlay",invalidPrinterId:"Ungültige Drucker-ID",cameraStream:"Kamera-Stream",progress:"Fortschritt",eta:"ETA",tomorrow:"Morgen",printerIdle:"Drucker ist inaktiv",printerOffline:"Drucker offline",status:{printing:"Druckt",paused:"Pausiert",finished:"Fertig",failed:"Fehlgeschlagen",idle:"Inaktiv",unknown:"Unbekannt"}},profiles:{title:"Profile",subtitle:"Verwalten Sie Ihre Slicer-Voreinstellungen und Druckvorschub-Kalibrierungen",tabs:{cloud:"Cloud-Profile",kprofiles:"K-Profile"},connectedAs:"Verbunden als",logout:"Abmelden",noLogoutPermission:"Sie haben keine Berechtigung zum Abmelden",failedToLoad:"Profile konnten nicht geladen werden",retry:"Erneut versuchen",time:{justNow:"Gerade eben",minsAgo:"vor {{count}}m",hoursAgo:"vor {{count}}h",daysAgo:"vor {{count}}d"},toast:{loggedOut:"Abgemeldet"},login:{title:"Mit Bambu Cloud verbinden",subtitle:"Synchronisieren Sie Ihre Slicer-Voreinstellungen geräteübergreifend",email:"E-Mail",password:"Passwort",region:"Region",regionGlobal:"Global",regionChina:"China",verificationCode:"Bestätigungscode",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"},fileManager:{title:"Dateimanager",subtitle:"Organisieren und verwalten Sie Ihre Druckdateien",uploadFiles:"Dateien hochladen",newFolder:"Neuer Ordner",folderName:"Ordnername",folderNamePlaceholder:"z.B. Funktionsteile",renameFile:"Datei umbenennen",renameFolder:"Ordner umbenennen",moveFiles:"{{count}} Datei(en) verschieben",rootNoFolder:"Stammverzeichnis (Kein Ordner)",current:"aktuell",linkFolder:"Ordner verknüpfen",linkFolderDescription:'"{{name}}" mit einem Projekt oder Archiv verknüpfen für schnellen Zugriff.',project:"Projekt",archive:"Archiv",noProjectsFound:"Keine Projekte gefunden",noArchivesFound:"Keine Archive gefunden",unlink:"Verknüpfung aufheben",link:"Verknüpfen",dragDropFiles:"Dateien hierher ziehen",dropFilesHere:"Dateien hier ablegen",orClickToBrowse:"oder klicken zum Durchsuchen",allFileTypesSupported:"Alle Dateitypen werden unterstützt. ZIP-Dateien werden extrahiert.",zipFilesDetected:"ZIP-Dateien erkannt",zipExtractOptions:"ZIP-Dateien werden extrahiert. Wählen Sie, wie die Ordnerstruktur behandelt werden soll:",preserveZipStructure:"Ordnerstruktur aus ZIP beibehalten",createFolderFromZip:"Ordner aus ZIP-Dateiname erstellen",stlThumbnailGeneration:"STL-Vorschaubildgenerierung",zipMayContainStl:"ZIP-Dateien können STL-Dateien enthalten. Vorschaubilder können während der Extraktion generiert werden.",thumbnailsCanBeGenerated:"Vorschaubilder können für STL-Dateien generiert werden. Große Modelle benötigen möglicherweise mehr Zeit.",generateThumbnailsForStl:"Vorschaubilder für STL-Dateien generieren",willBeExtracted:"Wird extrahiert",filesExtracted:"{{count}} Dateien extrahiert",uploadComplete:"Upload abgeschlossen: {{succeeded}} erfolgreich",uploadFailed:"{{count}} fehlgeschlagen",uploading:"Hochladen...",changeLink:"Verknüpfung ändern...",linkTo:"Verknüpfen mit...",linkToProjectOrArchive:"Mit Projekt oder Archiv verknüpfen",addToQueue:"Zur Warteschlange",generateThumbnail:"Vorschaubild generieren",generateThumbnails:"Vorschaubilder generieren",generateThumbnailsForMissing:"Vorschaubilder für STL-Dateien ohne Vorschau generieren",gridView:"Rasteransicht",listView:"Listenansicht",lowDiskSpaceWarning:"Warnung: Wenig Speicherplatz",lowDiskSpaceDetails:"Nur {{free}} frei von {{total}} gesamt. Schwellenwert ist auf {{threshold}} GB eingestellt.",files:"Dateien",folders:"Ordner",size:"Größe",free:"Frei",allFiles:"Alle Dateien",wrap:"Umbrechen",enableTextWrapping:"Textumbruch aktivieren",disableTextWrapping:"Textumbruch deaktivieren",dragToResizeTooltip:"Ziehen zum Ändern der Größe, Doppelklick zum Zurücksetzen",searchFiles:"Dateien suchen...",allTypes:"Alle Typen",prints:"Drucke",ascending:"Aufsteigend",descending:"Absteigend",resultsCount:"{{showing}} von {{total}} Dateien",selectAll:"Alle auswählen",deselectAll:"Auswahl aufheben",selected:"{{count}} ausgewählt",adding:"Hinzufügen...",loadingFiles:"Dateien werden geladen...",folderIsEmpty:"Ordner ist leer",noFilesYet:"Noch keine Dateien",folderEmptyDescription:"Laden Sie Dateien hoch oder verschieben Sie Dateien in diesen Ordner.",noFilesDescription:"Laden Sie Dateien hoch, um Ihre Druckdateien zu organisieren.",noMatchingFiles:"Keine passenden Dateien",noMatchingFilesDescription:"Keine Dateien entsprechen Ihren aktuellen Such- oder Filterkriterien.",clearFilters:"Filter zurücksetzen",printedCount:"{{count}}x gedruckt",uploadedBy:"Hochgeladen von {{name}}",deleteFolder:"Ordner löschen",deleteFile:"Datei löschen",deleteFilesCount:"{{count}} Dateien löschen",deleteFolderConfirm:"Möchten Sie diesen Ordner wirklich löschen? Alle Dateien darin werden ebenfalls gelöscht.",deleteFileConfirm:"Möchten Sie diese Datei wirklich löschen?",deleteFilesConfirm:"Möchten Sie {{count}} ausgewählte Dateien wirklich löschen? Diese Aktion kann nicht rückgängig gemacht werden.",deleting:"Wird gelöscht...",noPermissionRenameFolder:"Sie haben keine Berechtigung, Ordner umzubenennen",noPermissionLinkFolder:"Sie haben keine Berechtigung, Ordner zu verknüpfen",noPermissionDeleteFolder:"Sie haben keine Berechtigung, Ordner zu löschen",noPermissionPrint:"Sie haben keine Berechtigung zum Drucken",noPermissionAddToQueue:"Sie haben keine Berechtigung, zur Warteschlange hinzuzufügen",noPermissionDownload:"Sie haben keine Berechtigung, Dateien herunterzuladen",noPermissionRenameFile:"Sie haben keine Berechtigung, diese Datei umzubenennen",noPermissionGenerateThumbnail:"Sie haben keine Berechtigung, Vorschaubilder zu generieren",noPermissionDeleteFile:"Sie haben keine Berechtigung, diese Datei zu löschen",noPermissionCreateFolder:"Sie haben keine Berechtigung, Ordner zu erstellen",noPermissionUpload:"Sie haben keine Berechtigung, Dateien hochzuladen",noPermissionMoveFiles:"Sie haben keine Berechtigung, Dateien zu verschieben",noPermissionDeleteFiles:"Sie haben keine Berechtigung, Dateien zu löschen",toast:{folderCreated:"Ordner erstellt",folderDeleted:"Ordner gelöscht",fileDeleted:"Datei gelöscht",filesDeleted:"{{count}} Dateien gelöscht",filesMoved:"Dateien verschoben",folderLinked:"Ordner verknüpft",folderUnlinked:"Ordnerverknüpfung aufgehoben",addedToQueue:"{{count}} Datei(en) zur Warteschlange hinzugefügt",addedToQueuePartial:"{{added}} Datei(en) hinzugefügt, {{failed}} fehlgeschlagen",failedToAddToQueue:"Fehler beim Hinzufügen: {{error}}",fileRenamed:"Datei umbenannt",folderRenamed:"Ordner umbenannt",thumbnailsGenerated:"{{count}} Vorschaubild(er) generiert",thumbnailsGeneratedPartial:"{{succeeded}} Vorschaubild(er) generiert, {{failed}} fehlgeschlagen",noStlMissingThumbnails:"Keine STL-Dateien ohne Vorschaubild",failedToGenerateThumbnails:"Fehler beim Generieren der Vorschaubilder: {{error}}",thumbnailGenerated:"Vorschaubild generiert",failedToGenerateThumbnail:"Fehler beim Generieren des Vorschaubildes: {{error}}"}},projects:{title:"Projekte",subtitle:"Organisieren und verfolgen Sie Ihre 3D-Druckprojekte",newProject:"Neues Projekt",editProject:"Projekt bearbeiten",deleteProject:"Projekt löschen",projectName:"Projektname",description:"Beschreibung",noProjects:"Noch keine Projekte",noProjectsFiltered:"Keine {{status}} Projekte",noProjectsFilteredHelp:"Sie haben keine {{status}} Projekte. Projekte werden hier angezeigt, wenn sich ihr Status ändert.",createFirst:"Erstellen Sie Ihr erstes Projekt, um verwandte Drucke zu organisieren, den Fortschritt zu verfolgen und Ihre Builds zu verwalten.",createFirstButton:"Erstes Projekt erstellen",create:"Erstellen",files:"Dateien",prints:"Drucke",plates:"Platten",parts:"Teile",lastModified:"Zuletzt geändert",deleteConfirm:"Möchten Sie dieses Projekt wirklich löschen? Archive und Warteschlangenelemente werden getrennt, aber nicht gelöscht.",addFiles:"Dateien hinzufügen",removeFile:"Datei entfernen",viewDetails:"Details anzeigen",namePlaceholder:"z.B. Voron 2.4 Build",descriptionPlaceholder:"Optionale Beschreibung...",color:"Farbe",targetPlates:"Ziel-Platten",targetPlatesPlaceholder:"z.B. 25",targetPlatesHelp:"Anzahl der Druckaufträge",targetParts:"Ziel-Teile",targetPartsPlaceholder:"z.B. 150",targetPartsHelp:"Benötigte Objekte insgesamt",tagsLabel:"Tags (kommagetrennt)",tagsPlaceholder:"z.B. voron, funktional, geschenk",dueDate:"Fälligkeitsdatum",priority:"Priorität",priorityLow:"Niedrig",priorityNormal:"Normal",priorityHigh:"Hoch",priorityUrgent:"Dringend",statusActive:"Aktiv",statusCompleted:"Abgeschlossen",statusArchived:"Archiviert",done:"Fertig",completed:"abgeschlossen",failed:"fehlgeschlagen",inQueue:"in Warteschlange",noPrintsYet:"Noch keine Drucke",printJobs:"Druckaufträge (Platten)",partsPrinted:"Gedruckte Teile",failedParts:"Fehlgeschlagene Teile",import:"Importieren",export:"Exportieren",importProject:"Projekt importieren",exportAll:"Alle Projekte exportieren",loading:"Projekte werden geladen...",noEditPermission:"Sie haben keine Berechtigung, Projekte zu bearbeiten",noDeletePermission:"Sie haben keine Berechtigung, Projekte zu löschen",noCreatePermission:"Sie haben keine Berechtigung, Projekte zu erstellen",noImportPermission:"Sie haben keine Berechtigung, Projekte zu importieren",noExportPermission:"Sie haben keine Berechtigung, Projekte zu exportieren",toast:{created:"Projekt erstellt",updated:"Projekt aktualisiert",deleted:"Projekt gelöscht",imported:"Projekt importiert",multipleImported:"{{count}} Projekte importiert",importFailed:"Import fehlgeschlagen",exported:"Projekte exportiert (nur Metadaten)"}},projectDetail:{notFound:"Projekt nicht gefunden",backToProjects:"Zurück zu Projekten",export:"Exportieren",exportProject:"Projekt exportieren",noExportPermission:"Sie haben keine Berechtigung, Projekte zu exportieren",noEditPermission:"Sie haben keine Berechtigung, Projekte zu bearbeiten",partOf:"Teil von:",priorityLabel:"Priorität:",noPrints:"Noch keine Drucke in diesem Projekt",status:{active:"Aktiv",completed:"Abgeschlossen",archived:"Archiviert"},priority:{low:"Niedrig",normal:"Normal",high:"Hoch",urgent:"Dringend"},dueDate:{overdue:"Überfällig",today:"Heute fällig",daysLeft:"{{count}} Tage übrig"},progress:{platesProgress:"Platten-Fortschritt",partsProgress:"Teile-Fortschritt",printJobs:"Druckaufträge",parts:"Teile",percentComplete:"{{percent}}% abgeschlossen",remaining:"{{count}} verbleibend"},stats:{printJobs:"Druckaufträge",total:"gesamt",failed:"{{count}} fehlgeschlagen",partsPrinted:"{{count}} Teile gedruckt",printTime:"Druckzeit",filamentUsed:"Filament verbraucht"},cost:{title:"Kostenverfolgung",filamentCost:"Filamentkosten",energy:"Energie",budget:"Budget",remaining:"Verbleibend"},subProjects:{title:"Unterprojekte ({{count}})"},notes:{title:"Notizen",noEditPermission:"Sie haben keine Berechtigung, Notizen zu bearbeiten",placeholder:"Notizen zu diesem Projekt hinzufügen...",empty:"Noch keine Notizen. Klicken Sie auf Bearbeiten, um Notizen hinzuzufügen."},files:{title:"Dateien",linkFolders:"Ordner aus dem Dateimanager verknüpfen",forQuickAccess:"für schnellen Zugriff auf dieses Projekt.",fileCount:"{{count}} Datei(en)",empty:"Keine Ordner verknüpft. Gehen Sie zum Dateimanager und verknüpfen Sie einen Ordner mit diesem Projekt."},bom:{title:"Stückliste",acquired:"{{completed}}/{{total}} beschafft",showAll:"Alle anzeigen",hideDone:"Erledigte ausblenden",addPart:"Teil hinzufügen",noAddPermission:"Sie haben keine Berechtigung, Teile hinzuzufügen",partNamePlaceholder:"Teilename (z.B. M3x8 Schrauben)",partName:"Teilename",qty:"Menge",price:"Preis ({{currency}})",sourcingUrlPlaceholder:"Bezugsquelle-URL (optional)",remarksPlaceholder:"Bemerkungen (optional)",deletePart:"Teil löschen",deleteConfirm:'Möchten Sie "{{name}}" wirklich löschen?',noUpdatePermission:"Sie haben keine Berechtigung, Teile zu aktualisieren",noEditPermission:"Sie haben keine Berechtigung, Teile zu bearbeiten",noDeletePermission:"Sie haben keine Berechtigung, Teile zu löschen",totalCost:"Gesamtkosten:",empty:"Keine Teile in der Stückliste. Fügen Sie Hardware, Elektronik oder andere Komponenten hinzu, um zu verfolgen, was beschafft werden muss."},timeline:{title:"Aktivitätsverlauf",empty:"Noch keine Aktivität."},template:{saveAsTemplate:"Als Vorlage speichern",noCreatePermission:"Sie haben keine Berechtigung, Vorlagen zu erstellen"},queue:{title:"Warteschlange",viewAll:"Alle anzeigen",printing:"{{count}} druckend",queued:"{{count}} in Warteschlange"},prints:{title:"Drucke ({{count}})"},toast:{projectUpdated:"Projekt aktualisiert",partAdded:"Teil hinzugefügt",partRemoved:"Teil entfernt",exportFailed:"Export fehlgeschlagen",projectExported:"Projekt exportiert",templateCreated:"Vorlage erstellt"}},system:{title:"Systeminformationen",version:"Version",uptime:"Laufzeit",cpuUsage:"CPU-Auslastung",memoryUsage:"Speicherauslastung",diskUsage:"Festplattenauslastung",networkInfo:"Netzwerkinformationen",logs:"Protokolle",debugMode:"Debug-Modus",enableDebug:"Debug-Protokollierung aktivieren",disableDebug:"Debug-Protokollierung deaktivieren",downloadLogs:"Protokolle herunterladen",clearLogs:"Protokolle löschen",dockerInfo:"Docker-Info",containerName:"Container-Name",imageName:"Image-Name",platform:"Plattform",architecture:"Architektur"},library:{title:"Filament-Bibliothek",addFilament:"Filament hinzufügen",editFilament:"Filament bearbeiten",deleteFilament:"Filament löschen",vendor:"Hersteller",material:"Material",color:"Farbe",kFactor:"K-Faktor",temperature:"Temperatur",noFilaments:"Keine Filamente in der Bibliothek",deleteConfirm:"Möchten Sie dieses Filament wirklich löschen?",importFromPrinter:"Vom Drucker importieren",exportToFile:"In Datei exportieren"},spoolman:{title:"Spoolman-Integration",enabled:"Spoolman aktiviert",url:"Spoolman URL",connected:"Verbunden",disconnected:"Nicht verbunden",testConnection:"Verbindung testen",sync:"Synchronisieren",syncing:"Synchronisiert...",lastSync:"Letzte Synchronisierung",linkToSpoolman:"Mit Spoolman verknüpfen",openInSpoolman:"In Spoolman öffnen",unlinkSpool:"Spule trennen",selectSpool:"Spule auswählen",noUnlinkedSpools:"Keine nicht verknüpften Spulen verfügbar",linkSuccess:"Spule erfolgreich mit Spoolman verknüpft",linkFailed:"Verknüpfung mit Spoolman fehlgeschlagen",spoolId:"Spulen-ID",weight:"Gewicht",remaining:"Verbleibend"},timelapse:{title:"Zeitraffer",create:"Zeitraffer erstellen",download:"Herunterladen",delete:"Löschen",preview:"Vorschau",frameRate:"Bildrate",quality:"Qualität",processing:"Wird verarbeitet...",noTimelapses:"Keine Zeitraffer verfügbar"},ams:{title:"AMS",slot:"Slot",empty:"Leer",emptySlot:"Leerer Slot",unknown:"Unbekannt",humidity:"Luftfeuchtigkeit",temperature:"Temperatur",filamentType:"Filamenttyp",filamentColor:"Farbe",remaining:"Verbleibend",history:"AMS-Verlauf",noHistory:"Kein Verlauf verfügbar",configureSlot:"Slot konfigurieren",externalSpool:"Externe Spule",profile:"Profil",kFactor:"K-Faktor",fill:"Füllstand",configure:"Konfigurieren"},printModal:{title:"Druck starten",selectPrinter:"Drucker auswählen",selectPlate:"Platte auswählen",filamentMapping:"Filamentzuordnung",printSettings:"Druckeinstellungen",bedLeveling:"Bett-Nivellierung",flowCalibration:"Fluss-Kalibrierung",vibrationCalibration:"Vibrations-Kalibrierung",layerInspection:"Erste-Schicht-Prüfung",timelapse:"Zeitraffer",startPrint:"Druck starten",addToQueue:"Zur Warteschlange hinzufügen",cancel:"Abbrechen",noPrintersAvailable:"Keine Drucker verfügbar",printerBusy:"Drucker ist beschäftigt",printerOffline:"Drucker ist offline"},backup:{title:"Sichern & Wiederherstellen",createBackup:"Sicherung erstellen",restoreBackup:"Sicherung wiederherstellen",downloadBackup:"Sicherung herunterladen",uploadBackup:"Sicherung hochladen",lastBackup:"Letzte Sicherung",autoBackup:"Automatische Sicherung",backupNow:"Jetzt sichern",restoreWarning:"Warnung: Das Wiederherstellen einer Sicherung überschreibt alle aktuellen Daten.",includeArchives:"Archive einschließen",includeSettings:"Einstellungen einschließen",includeProfiles:"Profile einschließen",backupSuccess:"Sicherung erfolgreich erstellt",restoreSuccess:"Sicherung erfolgreich wiederhergestellt",backupFailed:"Sicherung fehlgeschlagen",restoreFailed:"Wiederherstellung fehlgeschlagen"},tags:{title:"Tags",addTag:"Tag hinzufügen",editTag:"Tag bearbeiten",deleteTag:"Tag löschen",tagName:"Tag-Name",tagColor:"Tag-Farbe",noTags:"Keine Tags",deleteConfirm:"Möchten Sie diesen Tag wirklich löschen?",manageTags:"Tags verwalten"},uploadModal:{title:"3MF-Dateien hochladen",dragDrop:"3MF-Dateien hierher ziehen",or:"oder",browseFiles:"Dateien durchsuchen",extractionInfo:"Das Druckermodell wird automatisch aus den 3MF-Datei-Metadaten extrahiert.",uploaded:"hochgeladen",failed:"fehlgeschlagen",uploading:"Wird hochgeladen...",upload:"Hochladen",uploadFailed:"Hochladen fehlgeschlagen"},editArchive:{title:"Archiv bearbeiten",name:"Name",namePlaceholder:"Druckname",printer:"Drucker",noPrinter:"Kein Drucker",project:"Projekt",noProject:"Kein Projekt",itemsPrinted:"Gedruckte Teile",itemsPrintedHelp:"Anzahl der in diesem Druckauftrag produzierten Teile",notes:"Notizen",notesPlaceholder:"Notizen zu diesem Druck hinzufügen...",externalLink:"Externer Link",externalLinkPlaceholder:"https://printables.com/model/...",externalLinkHelp:"Link zu Printables, Thingiverse oder anderer Quelle",tags:"Tags",tagsPlaceholder:"Tags hinzufügen...",addMoreTags:"Weitere Tags hinzufügen...",matchingTags:'Übereinstimmend mit "{{query}}"',existingTags:"Vorhandene Tags",clickToAdd:"(zum Hinzufügen klicken)",status:"Status",failureReason:"Fehlergrund",selectReason:"Grund auswählen...",photos:"Fotos des Druckergebnisses",photosHelp:"Klicken Sie auf + um Fotos Ihres Druckergebnisses hinzuzufügen",printResult:"Druckergebnis",saving:"Wird gespeichert...",failureReasons:{adhesionFailure:"Haftungsfehler",spaghettiDetached:"Spaghetti / Abgelöst",layerShift:"Schichtversatz",cloggedNozzle:"Verstopfte Düse",filamentRunout:"Filament aufgebraucht",warping:"Verformung",stringing:"Fadenziehen",underExtrusion:"Unterextrusion",powerFailure:"Stromausfall",userCancelled:"Vom Benutzer abgebrochen",other:"Sonstiges"},statuses:{completed:"Abgeschlossen",failed:"Fehlgeschlagen",aborted:"Abgebrochen",printing:"Druckt"}},kProfiles:{title:"K-Profile",noPrintersConfigured:"Keine Drucker konfiguriert",addPrinterInSettings:"Fügen Sie einen Drucker in den Einstellungen hinzu, um K-Profile zu verwalten",noActivePrinters:"Keine aktiven Drucker",enablePrinterConnection:"Aktivieren Sie eine Druckerverbindung, um K-Profile anzuzeigen",loadingProfiles:"Lade K-Profile...",printerOffline:"Drucker offline",printerOfflineDesc:"Der ausgewählte Drucker ist nicht verbunden. Schalten Sie ihn ein, um K-Profile anzuzeigen.",noMatchingProfiles:"Keine passenden Profile",noMatchingProfilesDesc:"Keine Profile entsprechen Ihren Suchkriterien",noKProfiles:"Keine K-Profile",noKProfilesDesc:"Keine Druckvorschub-Profile für {{diameter}}mm Düse gefunden",createFirstProfile:"Erstes Profil erstellen",printer:"Drucker",nozzle:"Düse",refresh:"Aktualisieren",addProfile:"Profil hinzufügen",export:"Exportieren",import:"Importieren",select:"Auswählen",selectAll:"Alle auswählen",delete:"Löschen",searchPlaceholder:"Nach Name oder Filament suchen...",allExtruders:"Alle Extruder",leftOnly:"Nur links",rightOnly:"Nur rechts",allFlow:"Alle Flusstypen",hfOnly:"Nur HF",sOnly:"Nur S",sortName:"Sortieren: Name",sortKValue:"Sortieren: K-Wert",sortFilament:"Sortieren: Filament",leftExtruder:"Linker Extruder",rightExtruder:"Rechter Extruder",modal:{addTitle:"K-Profil hinzufügen",editTitle:"K-Profil bearbeiten",profileName:"Profilname",profileNamePlaceholder:"Mein PLA-Profil",kValue:"K-Wert",kValuePlaceholder:"0,020",kValueHelp:"Typischer Bereich: 0,01 - 0,06 für PLA, 0,02 - 0,10 für PETG",filament:"Filament",selectFilament:"Filament auswählen...",noFilamentsHelp:"Keine Filamente gefunden. Erstellen Sie zuerst ein K-Profil in Bambu Studio.",flowType:"Flusstyp",highFlow:"High Flow",standard:"Standard",nozzleSize:"Düsengröße",extruder:"Extruder",extruders:"Extruder",left:"Links",right:"Rechts",notes:"Notizen (lokal gespeichert)",notesPlaceholder:"Notizen zu diesem Profil hinzufügen...",notesHelp:"Notizen werden in Bambuddy gespeichert, nicht auf dem Drucker",syncing:"Synchronisiert mit Drucker...",savingExtruder:"Speichern auf Extruder {{current}}/{{total}}...",pleaseWait:"Bitte warten"},deleteConfirm:{title:"Profil löschen",cannotUndo:"Dies kann nicht rückgängig gemacht werden",message:'Möchten Sie "{{name}}" wirklich vom Drucker löschen?'},bulkDelete:{title:"Profile löschen",cannotUndo:"Dies kann nicht rückgängig gemacht werden",message:"Möchten Sie wirklich {{count}} ausgewählte Profile vom Drucker löschen?"},toast:{profileSaved:"K-Profil gespeichert",profilesSaved:"K-Profil auf {{count}} Extrudern gespeichert",selectAtLeastOneExtruder:"Bitte wählen Sie mindestens einen Extruder aus",profileDeleted:"K-Profil gelöscht",profilesDeleted:"{{count}} Profile gelöscht",exportedProfiles:"{{count}} Profile exportiert",importedProfiles:"{{count}} von {{total}} Profilen importiert",noProfilesToExport:"Keine Profile zum Exportieren",invalidFileFormat:"Ungültiges Dateiformat",failedToParseImport:"Import-Datei konnte nicht gelesen werden",failedToSaveBatch:"K-Profile konnten nicht gespeichert werden",noteSaved:"Notiz gespeichert",failedToSaveNote:"Notiz konnte nicht gespeichert werden"},permission:{noRead:"Sie haben keine Berechtigung, Profile zu aktualisieren",noCreate:"Sie haben keine Berechtigung, Profile hinzuzufügen",noUpdate:"Sie haben keine Berechtigung, K-Profile zu aktualisieren",noDelete:"Sie haben keine Berechtigung, K-Profile zu löschen",noExport:"Sie haben keine Berechtigung, Profile zu exportieren",noImport:"Sie haben keine Berechtigung, Profile zu importieren"}},maintenanceDescriptions:{lubricateRails:"Schmiermittel auf Linearschienen für sanfte Bewegung auftragen",cleanNozzle:"Hotend und Düse reinigen, um Verstopfungen zu verhindern",checkBelts:"Riemenspannung für präzise Drucke überprüfen",cleanBuildPlate:"Druckplatte für bessere Haftung reinigen",checkExtruder:"Extruderzahnräder auf Verschleiß prüfen",checkCooling:"Sicherstellen, dass Lüfter ordnungsgemäß funktionieren",generalInspection:"Allgemeine Druckerinspektion",cleanCarbonRods:"Karbonstäbe reinigen, um Reibung zu reduzieren",checkPtfeTube:"PTFE-Schlauch auf Verschleiß oder Beschädigung prüfen",replaceHepaFilter:"HEPA-Filter für Luftqualität ersetzen",replaceCarbonFilter:"Aktivkohlefilter ersetzen",lubricateLeftNozzleRail:"Linke Düsenschiene schmieren (H2-Serie)"}},Bse={nav:{printers:"プリンター",archives:"アーカイブ",queue:"キュー",stats:"統計",profiles:"プロファイル",maintenance:"メンテナンス",projects:"プロジェクト",files:"ファイル管理",settings:"設定",system:"システム",collapseSidebar:"サイドバーを閉じる",expandSidebar:"サイドバーを開く",update:"アップデート",updateAvailable:"アップデートあり: v{{version}}",viewOnGithub:"GitHubで表示",keyboardShortcuts:"キーボードショートカット (?)",switchToLight:"ライトモードに切替",switchToDark:"ダークモードに切替"},common:{save:"保存",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:"秒",noPrinters:"プリンターが登録されていません",noData:"データがありません",required:"必須",optional:"オプション",unknown:"不明",done:"完了",saving:"保存中...",saveChanges:"変更を保存",today:"今日",turnOn:"オンにする",turnOff:"オフにする",deletePhoto:"写真を削除",deletePhotoConfirm:"この写真を削除しますか?元に戻せません。",create:"作成",print:"印刷",clear:"クリア",project:"プロジェクト",archive:"アーカイブ",unknownError:"不明なエラー",show:"表示",hide:"非表示",back:"戻る",export:"エクスポート",import:"インポート",retry:"リトライ",printer:"プリンター",model:"モデル",ok:"OK"},printers:{title:"プリンター",addPrinter:"プリンターを追加",editPrinter:"プリンターを編集",deletePrinter:"プリンターを削除",printerName:"プリンター名",serialNumber:"シリアル番号",ipAddress:"IPアドレス",accessCode:"アクセスコード",model:"モデル",nozzleCount:"ノズル数",autoArchive:"自動アーカイブ",connected:"接続中",offline:"オフライン",unknownModel:"不明なモデル",statusLabel:"ステータス",status:{printing:"印刷中",paused:"一時停止",finished:"完了",failed:"失敗",idle:"待機中"},lastPrint:"最後",readyToPrint:"印刷可能",estimatedCompletion:"完了予定時刻",filaments:"フィラメント",controls:"コントロール",external:"外部",externalSpool:"外部スプール",files:"ファイル",browseFiles:"プリンターのファイルを参照",update:"アップデート",loading:"プリンターを読み込み中...",hideOffline:"オフラインを非表示",ungrouped:"未グループ",hmsErrors:"クリックしてHMSエラーを表示",slotOptions:"スロットオプション",rereadRfid:"RFIDを再読み取り",clickToView:"クリックして表示",maintenanceUpToDate:"すべてのメンテナンスが最新です",maintenanceDue:"{{count}}件のメンテナンス期限",maintenanceDueSoon:"{{count}}件のメンテナンスがまもなく期限",printsInQueue:"キューに{{count}}件の印刷",firmwareUpdateAvailable:"ファームウェアアップデートあり: {{current}} → {{latest}}",statusSummary:{printing:"印刷中",idle:"待機中",offline:"オフライン"},sort:{name:"名前",status:"ステータス",model:"モデル",location:"ロケーション",ascending:"昇順で並べ替え",descending:"降順で並べ替え"},cardSize:{small:"小",medium:"中",large:"大",extraLarge:"特大",cards:"カード"},temps:{nozzle:"ノズル",bed:"ベッド",chamber:"チャンバー",left:"左",right:"右",activeNozzle:"アクティブ: {{side}}ノズル"},fans:{partCooling:"パーツ冷却ファン",auxiliary:"補助ファン",chamber:"チャンバーファン"},printControl:{stop:"停止",pause:"一時停止",resume:"再開",stopPrint:"印刷を停止",pausePrint:"印刷を一時停止",resumePrint:"印刷を再開"},power:{on:"オン",off:"オフ",powerOn:"電源オン",autoOff:"自動オフ",autoOffDone:"自動オフ完了",autoOffTooltip:"印刷後に自動電源オフ",autoOffExecutedTooltip:"自動オフが実行されました - リセットするにはプリンターの電源を入れてください",offlineWithPlugs:"スマートプラグ付きオフラインプリンター",noPlugs:"スマートプラグ付きプリンターなし"},chamberLight:{turnOn:"チャンバーライトをオン",turnOff:"チャンバーライトをオフ"},camera:{openOverlay:"カメラオーバーレイを開く",openWindow:"カメラを新しいウィンドウで開く"},menu:{reconnect:"再接続",mqttDebug:"MQTTデバッグ"},confirm:{deleteTitle:"プリンターを削除",deleteMessage:"「{{name}}」を削除しますか?すべての接続設定が削除されます。",deleteArchives:"印刷アーカイブを削除",deleteArchivesYes:"このプリンターのすべての印刷履歴が完全に削除されます。",deleteArchivesNo:"印刷履歴は保持されますが、このプリンターとの関連付けは解除されます。",powerOnTitle:"プリンターの電源をオン",powerOnMessage:"「{{name}}」の電源をオンにしますか?",powerOn:"電源オン",powerOffTitle:"プリンターの電源をオフ",powerOffMessage:"「{{name}}」の電源をオフにしますか?",powerOffWarning:"警告: 「{{name}}」は現在印刷中です!電源をオフにしますか?印刷が中断され、プリンターが損傷する可能性があります。",powerOff:"電源オフ",stopTitle:"印刷を停止",stopMessage:"「{{name}}」の現在の印刷を停止しますか?印刷ジョブがキャンセルされます。",stopButton:"印刷を停止",pauseTitle:"印刷を一時停止",pauseMessage:"「{{name}}」の現在の印刷を一時停止しますか?",pauseButton:"印刷を一時停止",resumeTitle:"印刷を再開",resumeMessage:"「{{name}}」の印刷を再開しますか?",resumeButton:"印刷を再開"},skipObjects:{title:"オブジェクトスキップ",onlyWhilePrinting:"オブジェクトスキップ(印刷中のみ)",requires2Objects:"オブジェクトスキップ(2つ以上のオブジェクトが必要)",noObjects:"オブジェクトが見つかりません",objectsLoadedOnStart:"オブジェクトは印刷開始時に読み込まれます",matchIds:"プリンターのディスプレイとIDを照合してください",printerScreenShows:"プリンター画面にビルドプレート上のオブジェクトIDが表示されます",skippedCount:"{{skipped}}/{{total}}スキップ済み",waitForLayer:"オブジェクトをスキップするにはレイヤー2以降をお待ちください(現在レイヤー{{layer}})",activeCount:"{{count}}個アクティブ",willBeSkipped:"スキップされます",waitForLayer2:"レイヤー2以降をお待ちください",skipThisObject:"このオブジェクトをスキップ",skip:"スキップ",skipped:"スキップ済み"},form:{name:"名前",namePlaceholder:"マイプリンター",ipAddress:"IPアドレス",serialNumber:"シリアル番号",serialCannotChange:"シリアル番号は変更できません",accessCode:"アクセスコード",accessCodePlaceholder:"プリンター設定から取得",accessCodeKeepCurrent:"現在のコードを維持する場合は空のまま",modelOptional:"モデル(任意)",model:"モデル",selectModel:"モデルを選択...",locationGroup:"ロケーション / グループ",locationPlaceholder:"例: 工房、オフィス、地下室",locationHint:"プリンターのグループ化とキュージョブのフィルタリングに使用",autoArchive:"完了した印刷を自動アーカイブ"},discovery:{subnetToScan:"スキャンするサブネット",dockerSubnetHint:"Dockerが検出されました。CIDR表記でプリンターのサブネットを入力してください。docker-compose.ymlにnetwork_mode: hostが必要です。",scanning:"スキャン中...",scanningProgress:"スキャン中... {{scanned}}/{{total}}",scanSubnet:"サブネットをスキャンしてプリンターを検出",discoverNetwork:"ネットワーク上のプリンターを検出",serialRequired:"シリアル番号が必要です",scanningSubnet:"サブネットでBambuプリンターをスキャン中...",scanningNetwork:"ネットワークをスキャン中...",noPrintersSubnet:"指定されたサブネットにプリンターが見つかりません。",noPrintersNetwork:"ネットワーク上にプリンターが見つかりません。",allConfigured:"検出されたすべてのプリンターは既に設定済みです。"},firmware:{title:"ファームウェアアップデート",current:"現在",latest:"最新",releaseNotes:"リリースノート",checkingPrerequisites:"前提条件を確認中...",sdCardReady:"SDカード準備完了。下をクリックしてファームウェアをアップロードしてください。",uploadedToSd:"ファームウェアをSDカードにアップロードしました!",applyInstructions:"プリンターでアップデートを適用するには:",step1:"プリンターのタッチスクリーンで設定に移動",step2:"ファームウェアに移動",step3:"SDカードからアップデートを選択",step4:"アップデートには10〜20分かかります",starting:"開始中...",uploadFirmware:"ファームウェアをアップロード",uploadSuccess:"ファームウェアをアップロードしました!プリンター画面からアップデートを実行してください。"},empty:{noPrinters:"プリンターがまだ設定されていません",addFirst:"最初のプリンターを追加"},toast:{printStopped:"印刷を停止しました",printPaused:"印刷を一時停止しました",printResumed:"印刷を再開しました",failedToStop:"印刷の停止に失敗しました",failedToPause:"印刷の一時停止に失敗しました",failedToResume:"印刷の再開に失敗しました",chamberLightOn:"チャンバーライトをオンにしました",chamberLightOff:"チャンバーライトをオフにしました",failedChamberLight:"チャンバーライトの制御に失敗しました",objectsSkipped:"オブジェクトをスキップしました",failedToSkipObjects:"オブジェクトのスキップに失敗しました",rfidRereadInitiated:"RFID再読み取りを開始しました",failedRfidReread:"RFID再読み取りに失敗しました"},progress:"{{percent}}% 完了",timeRemaining:"残り {{time}}",maintenanceOk:"メンテナンス正常",maintenanceWarning:"{{count}}件の警告",maintenanceWarning_plural:"{{count}}件の警告",colors:{unknown:"不明",black:"黒",white:"白",darkGray:"ダークグレー",lightGray:"ライトグレー",gray:"グレー",brown:"茶色",red:"赤",orange:"オレンジ",yellow:"黄色",green:"緑",cyan:"シアン",blue:"青",purple:"紫",pink:"ピンク"},humidity:{unknown:"不明",good:"良好",fair:"注意",bad:"警告"},temperature:{good:"良好",fair:"注意",bad:"高温"},wifi:{excellent:"非常に良い",good:"良い",fair:"普通",weak:"弱い",veryWeak:"非常に弱い"},h2Series:"H2シリーズ",x1Series:"X1シリーズ",pSeries:"Pシリーズ",a1Series:"A1シリーズ",searchPresets:"プリセットを検索...",noCloudPresets:"クラウドプリセットがありません。Bambu Cloudにログインして同期してください。",noMatchingPresets:"一致するプリセットが見つかりません。",colorNamePlaceholder:"色の名前またはHex値(例:brown、FF8800)",clearCustomColor:"カスタムカラーをクリア",copySpoolUuid:"スプールUUIDをコピー",configureSlot:"フィラメントプロファイルとK値でスロットを設定"},archives:{title:"印刷アーカイブ",searchPlaceholder:"アーカイブを検索...",filterByPrinter:"プリンターで絞り込み",filterByStatus:"ステータスで絞り込み",sortBy:"並べ替え",sortNewest:"新しい順",sortOldest:"古い順",sortName:"名前順",sortDuration:"時間順",noArchives:"アーカイブが見つかりません",printTime:"印刷時間",filamentUsed:"フィラメント使用量",cost:"コスト",reprint:"再印刷",preview:"プレビュー",deleteArchive:"アーカイブを削除",deleteConfirm:"このアーカイブを削除しますか?",favorite:"お気に入り",unfavorite:"お気に入りから削除",viewDetails:"詳細を表示",status:{completed:"完了",failed:"失敗",stopped:"中止"},collections:{all:"すべてのアーカイブ",recent:"過去24時間","this-week":"今週","this-month":"今月",favorites:"お気に入り",failed:"失敗した印刷",duplicates:"重複"},bulkDeleted:"{{count}}件のアーカイブを削除しました",bulkDeleteFailed:"アーカイブの削除に失敗しました",bulkDeleteTitle:"アーカイブを削除",bulkDeleteConfirm:"{{count}}件のアーカイブを削除しますか?この操作は元に戻せません。",deleteCount:"{{count}}件を削除",only3mfSupported:".3mfファイルのみ対応しています",dropFilesHere:".3mfファイルをここにドロップ",releaseToUpload:"ドロップしてアップロード",selectedCount:"{{count}}件選択中",selectAll:"すべて選択",tags:"タグ",project:"プロジェクト",toggledFavorites:"{{count}}件のアーカイブのお気に入りを切替えました",favoriteUpdateFailed:"お気に入りの更新に失敗しました",favoriteBulk:"お気に入り",showingCount:"{{total}}件中{{shown}}件を表示",export:"エクスポート",exportDownloaded:"エクスポートをダウンロードしました",exportFailed:"エクスポートに失敗しました",exportCsv:"CSVでエクスポート",exportExcel:"Excelでエクスポート",compare:"比較 ({{count}})",select:"選択",upload3mf:"3MFアップロード",allPrinters:"すべてのプリンター",allMaterials:"すべての素材",allFiles:"すべてのファイル",slicedGcode:"スライス済み (GCODE)",sourceFileOnly:"ソースのみ",showAll:"すべて表示",showFavoritesOnly:"お気に入りのみ表示",favorites:"お気に入り",showFailedPrints:"失敗した印刷を表示",hideFailedPrints:"失敗した印刷を非表示",hideFailed:"失敗を非表示",allTags:"すべてのタグ",enterNewTag:"新しいタグを入力...",sortNewestFirst:"新しい順",sortOldestFirst:"古い順",sortNameAZ:"名前 A-Z",sortNameZA:"名前 Z-A",sortLargestFirst:"大きい順",sortSmallestFirst:"小さい順",gridView:"グリッド表示",listView:"リスト表示",calendarView:"カレンダー表示",reset:"リセット",colors:"カラー:",matchAnyColor:"いずれかの選択色に一致",matchAllColors:"すべての選択色に一致",clear:"クリア",loading:"アーカイブを読み込み中...",noMatchingArchives:"検索に一致するアーカイブはありません",noArchivesYet:"アーカイブはまだありません",autoCreated:"印刷完了時にアーカイブは自動的に作成されます",unknownPrinter:"不明",noPrinter:"プリンターなし",rightClickOptions:"右クリックでオプション表示",printedBefore:"このモデルは以前印刷されたことがあります",openSource3mf:"ソース3MFをBambu Studioで開く(右クリックでオプション表示)",viewPhotos:"{{count}}枚の写真を表示",openFolder:"フォルダーを開く: {{name}}",projectName:"プロジェクト: {{name}}",makerWorldDesigner:"MakerWorld: {{designer}}",notFromMakerWorld:"MakerWorldではありません",hasTimelapse:"タイムラプスあり",moreOptions:"その他のオプション",downloadF3d:"Fusion 360デザインファイルをダウンロード",listName:"名前",listPrinter:"プリンター",listDate:"日付",listSize:"サイズ",listActions:"アクション"},queue:{title:"印刷キュー",description:"印刷ジョブのスケジュールと管理",addToQueue:"キューに追加",clearQueue:"キューをクリア",clearHistory:"履歴をクリア",emptyQueue:"キューは空です",position:"順番",scheduledTime:"予定時刻",moveUp:"上に移動",moveDown:"下に移動",remove:"削除",requeue:"再キュー",startNow:"今すぐ開始",startPrint:"印刷を開始",stopPrint:"印刷を停止",unassigned:"未割当",printerNumber:"プリンター #{{id}}",staged:"ステージ済み",requiresPreviousSuccess:"前の印刷の成功が必要",autoPowerOff:"自動電源オフ",printingInProgress:"印刷中...",currentlyPrinting:"印刷中",viewArchive:"アーカイブを表示",viewInFileManager:"ファイルマネージャーで表示",itemCount:"{{count}}件",dragToReorder:"ドラッグして並べ替え(ASAPのみ)",overdue:"期限超過",dragReorderTooltip:"順番はASAPアイテムのみに影響します。スケジュール済みアイテムは設定された時間に実行されます。",anyModel:"任意の{{model}}{{location}}{{filaments}}",addedBy:"{{username}}が追加",bulkEdit:{title:"{{count}}件のアイテムを編集",description:"変更した設定のみが選択されたアイテムに適用されます。",printer:"プリンター",noChange:"— 変更なし —",queueOptions:"キューオプション",stagedManualStart:"ステージ済み(手動開始)",autoPowerOff:"印刷後に自動電源オフ",requirePreviousSuccess:"前の印刷の成功が必要",printOptions:"印刷オプション",bedLevelling:"ベッドレベリング",flowCalibration:"フローキャリブレーション",vibrationCalibration:"振動キャリブレーション",firstLayerInspection:"第一層検査",timelapse:"タイムラプス",useAms:"AMS使用",on:"オン",off:"オフ",saving:"保存中...",applyChanges:"変更を適用"},bulkActions:{selectAll:"すべて選択",deselectAll:"すべて選択解除",selected:"{{count}}件選択中",editSelected:"選択を編集",cancelSelected:"選択をキャンセル"},permissions:{noStopPermission:"印刷を停止する権限がありません",noStartPermission:"印刷を開始する権限がありません",noEditPermission:"キューアイテムを編集する権限がありません",noCancelPermission:"キューアイテムをキャンセルする権限がありません",noRequeuePermission:"アイテムを再キューする権限がありません",noRemovePermission:"キューアイテムを削除する権限がありません",noClearHistoryPermission:"履歴をクリアする権限がありません"},status:{pending:"待機中",printing:"印刷中",completed:"完了",failed:"失敗",skipped:"スキップ",cancelled:"キャンセル済み",waiting:"待機中"},summary:{printing:"印刷中",queued:"キュー中",totalQueueTime:"合計キュー時間",history:"履歴"},filters:{allPrinters:"すべてのプリンター",allStatus:"すべてのステータス"},sort:{byPosition:"順番で並べ替え",byName:"名前で並べ替え",byPrinter:"プリンターで並べ替え",bySchedule:"スケジュールで並べ替え",byDate:"日付で並べ替え",ascending:"昇順",descending:"降順",ascendingOldest:"昇順(古い順)",descendingNewest:"降順(新しい順)"},empty:{title:"スケジュールされた印刷はありません",description:"アーカイブページのコンテキストメニューから「スケジュール」オプションを使用するか、ファイルをドラッグ&ドロップして始めましょう。"},confirm:{cancelTitle:"スケジュール済み印刷をキャンセル",cancelMessage:"「{{name}}」をキャンセルしますか?",cancelButton:"印刷をキャンセル",stopTitle:"印刷を停止",stopMessage:"現在の印刷「{{name}}」を停止しますか?プリンター上の印刷ジョブがキャンセルされます。",stopButton:"印刷を停止",removeTitle:"履歴から削除",removeMessage:"「{{name}}」をキュー履歴から削除しますか?",clearHistoryMessage:"{{count}}件の履歴をすべて削除しますか?",thisPrint:"この印刷",thisItem:"このアイテム"},toast:{itemCancelled:"キューアイテムをキャンセルしました",itemRemoved:"キューアイテムを削除しました",printStopped:"印刷を停止しました",printReleased:"印刷をキューに戻しました",clearedHistory:"{{count}}件の履歴をクリアしました",failedToCancel:"アイテムのキャンセルに失敗しました",failedToRemove:"アイテムの削除に失敗しました",failedToStop:"印刷の停止に失敗しました",failedToStart:"印刷の開始に失敗しました",failedToReorder:"キューの並べ替えに失敗しました",failedToClear:"履歴のクリアに失敗しました",failedToUpdateItems:"アイテムの更新に失敗しました",cancelledItems:"{{count}}件のアイテムをキャンセルしました",failedToCancelItems:"アイテムの一括キャンセルに失敗しました"}},stats:{title:"統計",overview:"概要",totalPrints:"総印刷数",successRate:"成功率",totalPrintTime:"総印刷時間",totalFilament:"総フィラメント使用量",totalCost:"総コスト",averagePrintTime:"平均印刷時間",printsPerDay:"1日あたりの印刷数",byPrinter:"プリンター別",byMaterial:"素材別",byMonth:"月別",last7Days:"過去7日間",last30Days:"過去30日間",last90Days:"過去90日間",allTime:"全期間",dashboard:"統計ダッシュボード",dashboardDescription:"3Dプリントアクティビティの概要",loadingStatistics:"統計を読み込み中...",quickStats:"クイック統計",printTime:"印刷時間",filamentUsed:"フィラメント使用量",filamentCost:"フィラメントコスト",energyUsed:"エネルギー使用量",energyCost:"エネルギーコスト",successful:"成功",failed:"失敗",printsByPrinter:"プリンター別印刷数",printerFallback:"プリンター #{{id}}",timeAccuracy:"時間精度",noTimeAccuracyData:"時間精度データがありません",perfectEstimate:"100% = 完全な推定",filamentTypes:"フィラメントタイプ",noFilamentData:"フィラメントデータがありません",printsCount:"{{count}}回印刷",moreTypes:"+{{count}}種類",noPrinterData:"プリンターデータがありません",filamentUsageTrends:"フィラメント使用トレンド",noPrintData:"印刷データがありません",printActivity:"印刷アクティビティ",failureAnalysis30Days:"失敗分析(30日間)",noPrintDataLast30Days:"過去30日間の印刷データがありません",printsFailed:"{{total}}回中{{failed}}回失敗",lastWeek:"先週",failureReasons:"失敗理由",topFailureReasons:"主な失敗理由",unknown:"不明",moreReasons:"+{{count}}件の理由",hiddenCount:"{{count}}件非表示",layoutReset:"レイアウトをリセットしました",resetLayout:"レイアウトをリセット",exportStats:"統計をエクスポート",exportAsCsv:"CSVでエクスポート",exportAsExcel:"Excelでエクスポート",exportDownloaded:"エクスポートをダウンロードしました",exportFailed:"エクスポートに失敗しました",filament:"フィラメント",cost:"コスト",prints:"プリント",filamentGrams:"フィラメント (g)",weekOf:"週:",periodFilament:"期間フィラメント",periodCost:"期間コスト",avgPerPrint:"プリントあたりの平均",total:"合計",avg:"平均",usageOverTime:"使用量の推移",noDataForTimeRange:"選択した期間のデータがありません",byFilamentType:"フィラメントタイプ別",usage:"使用量",monthlyComparison:"月間比較",noPermissionRecalculate:"コストを再計算する権限がありません",noPermissionResetLayout:"レイアウトをリセットする権限がありません",recalculateCosts:"コストを再計算",recalculateFailed:"コストの再計算に失敗しました",recalculateTooltip:"現在のフィラメント価格に基づいてすべてのプリントコストを再計算します"},profiles:{title:"フィラメントプロファイル",addProfile:"プロファイルを追加",editProfile:"プロファイルを編集",deleteProfile:"プロファイルを削除",material:"素材",brand:"ブランド",color:"色",diameter:"直径",density:"密度",costPerKg:"1kgあたりの価格",spoolWeight:"スプール重量",noProfiles:"プロファイルが登録されていません",deleteConfirm:"このプロファイルを削除しますか?",templateName:"テンプレート名",descriptionOptional:"説明(任意)",searchFields:"フィールドを検索...",presetNamePlaceholder:"マイカスタムプリセット",searchPresets:"プリセットを検索...",connectToCloud:"Bambu Cloudに接続",syncDescription:"デバイス間でスライサープリセットを同期",email:"メールアドレス",password:"パスワード",region:"リージョン",regionGlobal:"グローバル",regionChina:"中国",verificationCode:"認証コード",totpCode:"認証アプリコード",checkEmail:"メール ({{email}}) に届いた6桁のコードを入力してください",enterTotpHint:"認証アプリの6桁のコードを入力してください",accessToken:"アクセストークン",accessTokenHint:"Bambu Labのアクセストークンを貼り付け(Bambu Studioから取得)",login:"ログイン",verify:"認証",setToken:"トークン設定",useTokenInstead:"アクセストークンを使用",loginWithEmail:"メールでログイン",loggedIn:"ログインしました",verificationSent:"認証コードをメールに送信しました",enterTotp:"認証アプリのコードを入力してください",tokenSet:"トークンを設定しました",loggedOut:"ログアウトしました",logout:"ログアウト",connectedAs:"接続中:",pageTitle:"プロファイル",pageDescription:"スライサープリセットと圧力キャリブレーションの管理",cloudProfiles:"クラウドプロファイル",kProfiles:"Kプロファイル",scrollToTop:"トップに戻る",justNow:"たった今",minutesAgo:"{{count}}分前",hoursAgo:"{{count}}時間前",daysAgo:"{{count}}日前",lastSynced:"最終同期:",duplicate:"複製",myPresetEditable:"マイプリセット(編集可能)",editable:"編集可能",typePreset:"{{type}}プリセット",presetDeleted:"プリセットを削除しました",presetCreated:"プリセットを作成しました",presetUpdated:"プリセットを更新しました",presetExported:"プリセットをエクスポートしました",presetName:"プリセット名",failedToLoadDetails:"プリセットの詳細を読み込めませんでした",failedToLoadProfiles:"プロファイルの読み込みに失敗しました",deletePresetConfirm:"このプリセットを削除しますか?",deletePresetWarning:'"{{name}}"をBambu Cloudから完全に削除します。この操作は元に戻せません。',noPresetsFound:"プリセットが見つかりません",showingPresets:"{{total}}件中{{count}}件を表示",myPresetLegend:"= マイプリセット(編集可能)",typeLabel:"タイプ",typeFilter:"タイプ:",owner:"所有者",myPresets:"マイプリセット",builtIn:"ビルトイン",nozzle:"ノズル",filament:"フィラメント",process:"プロセス",printer:"プリンター",layer:"レイヤー",clearFilters:"フィルターをクリア",noFilamentPresets:"フィラメントプリセットなし",noProcessPresets:"プロセスプリセットなし",noPrinterPresets:"プリンタープリセットなし",compare:"比較",compareMode:"比較モード",comparePresets:"プリセットを比較",compareNow:"比較を実行",compareWithBase:"ベースプリセットと比較",selectAnotherPreset:"同じタイプ({{type}})の別のプリセットを選択",clickTwoPresets:"同じタイプのプリセットを2つクリックして比較",selectFirst:"1. 最初を選択",selectSecond:"2. 2番目を選択",left:"左:",right:"右:",addedCount:"{{count}}件追加",removedCount:"{{count}}件削除",changedCount:"{{count}}件変更",sameCount:"{{count}}件同じ",changes:"変更点",noDifferences:"差分はありません",noFieldsMatch:"検索に一致するフィールドがありません",field:"フィールド",quickTemplates:"クイックテンプレート",templates:"テンプレート",deleteTemplate:"テンプレートを削除",actionCannotBeUndone:"この操作は元に戻せません",confirmDeleteTemplate:'"{{name}}"を削除してもよろしいですか?',templateDeleted:"テンプレートを削除しました",templateUpdated:"テンプレートを更新しました",templateApplied:"テンプレートを適用しました",templateAppliedName:"テンプレート適用: {{name}}",templateSaved:"テンプレートを保存しました",customTemplate:"カスタムテンプレート",noTemplatesYet:"テンプレートはまだありません",createTemplatesHint:"プリセットエディターからテンプレートを作成",noTemplatesSelected:"テンプレートが選択されていません。テンプレートボタンから有効にしてください。",manageTemplatesHint:"メインページのテンプレートボタンからテンプレートを管理",settingsJson:"設定 (JSON)",fieldsCount:"{{count}}フィールド",shownInModals:"モーダルに表示",hiddenInModals:"モーダルで非表示",apply:"適用",saveAsTemplate:"テンプレートとして保存",editPreset:"プリセットを編集",duplicatePreset:"プリセットを複製",createNewPreset:"新しいプリセットを作成",newPreset:"新規プリセット",customizeSettings:"新しいプリセットの設定をカスタマイズ",dropJsonToImport:"JSONファイルをドロップしてインポート",basePreset:"ベースプリセット",selectBasePreset:"ベースプリセットを選択...",inheritsFrom:"継承元:",commonTab:"共通",allFieldsTab:"全フィールド",jsonTab:"JSON",exportToJsonFile:"設定をJSONファイルにエクスポート",importFromJsonFile:"JSONファイルから設定をインポート",commonSettings:"共通設定",currentOverrides:"現在のオーバーライド",availableFields:"利用可能なフィールド",noMatchingFields:"一致するフィールドがありません",allFieldsAdded:"すべてのフィールドが追加済みです",addCustomField:"カスタムフィールドを追加",yourOverrides:"オーバーライド一覧",noOverridesYet:"オーバーライドはまだありません",clickFieldsToAdd:"左のフィールドをクリックして追加",dragDropTip:"ヒント: このモーダルに.jsonファイルをドラッグ&ドロップして設定をインポート",fieldAdded:'フィールド "{{key}}" を追加しました',noOverridesToSave:"保存するオーバーライドがありません",fileImported:"ファイルをインポートしました",fileImportedSuccess:"ファイルを正常にインポートしました",invalidJson:"無効なJSON",noPermissionCreate:"プロファイルを作成する権限がありません",noPermissionDelete:"プロファイルを削除する権限がありません",noPermissionDuplicate:"プロファイルを複製する権限がありません",noPermissionEdit:"プロファイルを編集する権限がありません",noPermissionLogout:"ログアウトする権限がありません",noPermissionManageTemplates:"テンプレートを管理する権限がありません",noPermissionRefresh:"プロファイルを更新する権限がありません"},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:"現在の時間",today:"今日",overdue:"期限超過",dueSoon:"まもなく期限",collapse:"折りたたむ",expand:"展開",left:"残り",timeBasedInterval:"時間ベースのインターバル",viewDocumentation:"ドキュメントを表示",printersAssigned:"{{count}}台のプリンターが割り当て済み - クリックして管理",deleteTypeConfirm:"「{{name}}」を削除しますか?",removeFromPrinter:"このプリンターから削除",addLabel:"追加:",maintenanceTypes:"メンテナンスタイプ",systemTypesDescription:"システムタイプとカスタムメンテナンスタスク",addCustomType:"カスタムタイプを追加",intervalType:"インターバルタイプ",printHours:"印刷時間",calendarDays:"カレンダー日数",intervalWithUnit:"インターバル ({{unit}})",days:"日",icon:"アイコン",documentationLink:"ドキュメントリンク(任意)",docLinkPlaceholder:"ドキュメントリンク(任意)",namePlaceholder:"例:HEPAフィルター交換",assignToPrinters:"プリンターに割り当て",selectAtLeastOnePrinter:"プリンターを1台以上選択してください",addType:"タイプを追加",custom:"カスタム",assignedToPrinters:"割り当て済みプリンター:",noPrintersAssigned:"プリンター未割り当て",intervalOverrides:"インターバルのオーバーライド",customizeIntervals:"プリンターごとにインターバルをカスタマイズ",addPrintersForMaintenance:"メンテナンスインターバルを設定するにはプリンターを追加してください",reset:"リセット",countOverdue:"{{count}}件が期限超過",countDueSoon:"{{count}}件がまもなく期限",allGood:"問題なし",nHours:"{{count}}時間",tasksOverdue:"{{count}}件のタスクが期限超過",configureDescription:"メンテナンスタイプとインターバルを設定",addPrintersToTrack:"メンテナンスを追跡するにはプリンターを追加してください",markedComplete:"メンテナンスを完了としてマーク",typeUpdated:"メンテナンスタイプを更新しました",typeDeleted:"メンテナンスタイプを削除しました",typeAdded:"メンテナンスタイプを追加しました",hoursUpdated:"印刷時間を更新しました",printerAssigned:"プリンターを割り当てました",printerRemoved:"プリンターを削除しました",wikiUrlPlaceholder:"https://wiki.bambulab.com/...",duration:{oneDay:"1日",days:"{{count}}日",weeks:"{{count}}週間",months:"{{count}}ヶ月",oneWeek:"1週間",nWeeks:"{{count}}週間",oneMonth:"1ヶ月",nMonths:"{{count}}ヶ月",oneYear:"1年"},noPermissionCreate:"メンテナンス記録を作成する権限がありません",noPermissionUpdate:"メンテナンス記録を更新する権限がありません",noPermissionPerform:"メンテナンスを実行する権限がありません",noPermissionRemove:"メンテナンス記録を削除する権限がありません",noPermissionAssign:"メンテナンスを割り当てる権限がありません",noPermissionEditTypes:"メンテナンスタイプを編集する権限がありません",noPermissionDeleteTypes:"メンテナンスタイプを削除する権限がありません",noPermissionEditIntervals:"メンテナンス間隔を編集する権限がありません",noPermissionEditHours:"メンテナンス時間を編集する権限がありません",types:{lubricateRails:"リニアレールの潤滑",cleanNozzle:"ノズル/ホットエンドの清掃",checkBelts:"ベルト張力の確認",cleanBuildPlate:"ビルドプレートの清掃",checkExtruder:"エクストルーダーギアの確認",checkCooling:"冷却ファンの確認",generalInspection:"総合点検",cleanCarbonRods:"カーボンロッドの清掃",checkPtfeTube:"PTFEチューブの確認",replaceHepaFilter:"HEPAフィルター交換",replaceCarbonFilter:"カーボンフィルター交換",lubricateLeftNozzleRail:"左ノズルレールの潤滑"}},settings:{title:"設定",general:"一般",appearance:"外観",notifications:"通知",smartPlugs:"スマートプラグ",tabSpoolman:"Spoolman",updates:"アップデート",language:"言語",languageDescription:"表示言語を選択してください",theme:"テーマ",themeLight:"ライト",themeDark:"ダーク",themeSystem:"システム設定に従う",defaultView:"デフォルト画面",defaultViewDescription:"アプリ起動時に表示するページ",checkForUpdates:"アップデートを確認",autoUpdate:"自動アップデート",currentVersion:"現在のバージョン",latestVersion:"最新バージョン",upToDate:"最新です",updateAvailable:"アップデートあり",telemetry:"匿名テレメトリ",telemetryDescription:"匿名の使用状況データを送信してBamBuddyの改善に協力する",telemetryLearnMore:"詳しく見る",telemetryInfoTitle:"どのようなデータが収集されますか?",telemetryInfoIntro:"BamBuddyはアプリの利用者数、使用バージョン、プリンターモデルを把握するために最小限の匿名データを収集します。これはバグ修正や新機能の優先順位付けに役立ちます。",telemetryInfoCollected:"収集するデータ:",telemetryInfoItem1:"ランダムなインストールID(個人やハードウェアとは紐付きません)",telemetryInfoItem2:"使用中のアプリバージョン",telemetryInfoItem3:"プリンターのモデル名(例: X1C, P1S)- 名前やシリアル番号は含みません",telemetryInfoItem4:"タイムスタンプ(日次/週次のアクティブユーザー数の計測用)",telemetryInfoNotCollected:"収集しないデータ:",telemetryInfoNotItem1:"IPアドレスはハッシュ化され、復元できません",telemetryInfoNotItem2:"プリンター名、シリアル番号、アクセスコード",telemetryInfoNotItem3:"印刷履歴、ファイル名、その他の個人的なコンテンツ",telemetryInfoNotItem4:"個人を特定できる情報",telemetryInfoFooter:"テレメトリはいつでも無効にできます。インストールIDはランダムに生成され、個人を追跡することはできません。",notificationLanguage:"通知の言語",notificationLanguageDescription:"プッシュ通知の言語",notificationProviders:"通知プロバイダー",addProvider:"プロバイダーを追加",editProvider:"プロバイダーを編集",providerType:"プロバイダーの種類",testNotification:"テスト通知",testSuccess:"テスト通知を送信しました",testFailed:"テスト通知の送信に失敗しました",quietHours:"おやすみ時間",quietHoursDescription:"この時間帯は通知を送信しません",quietHoursStart:"開始",quietHoursEnd:"終了",events:{title:"通知イベント",printStart:"印刷開始",printComplete:"印刷完了",printFailed:"印刷失敗",printStopped:"印刷中止",printProgress:"進捗マイルストーン",printProgressDescription:"25%, 50%, 75%で通知",printerOffline:"プリンターオフライン",printerError:"プリンターエラー",filamentLow:"フィラメント残量低下",maintenanceDue:"メンテナンス期限",maintenanceDueDescription:"メンテナンスが必要なときに通知"},smartPlug:{title:"スマートプラグ",add:"スマートプラグを追加",edit:"スマートプラグを編集",name:"名前",ipAddress:"IPアドレス",linkedPrinter:"連携プリンター",autoOn:"自動電源オン",autoOnDescription:"印刷開始時に電源を入れる",autoOff:"自動電源オフ",autoOffDescription:"印刷完了後に電源を切る",offDelay:"オフ遅延",offDelayMinutes:"印刷後の待機時間(分)",offDelayTemp:"ノズル温度が下回ったとき",currentState:"現在の状態",turnOn:"電源オン",turnOff:"電源オフ"},spoolman:{title:"Spoolman連携",description:"Spoolmanに接続してフィラメント在庫を管理します。AMSデータは自動的に同期されます。",howSyncWorks:"同期の仕組み",syncInfo1:"公式Bambu LabスプールのみRFIDで同期されます",syncInfo2:"新しいスプールは初回同期時にSpoolmanに自動作成されます",syncInfo3:"サードパーティ・詰め替えスプールはスキップされます",linkingExisting:"既存スプールの連携",linkingExistingDesc:"既存のSpoolmanスプールをAMSに連携するには、AMSスロットにカーソルを合わせて「Spoolmanに連携」をクリックしてください。",enable:"Spoolmanを有効化",enableDesc:"Spoolmanサーバーとフィラメントデータを同期",url:"Spoolman URL",urlHint:"SpoolmanサーバーのURL(例: http://localhost:7912)",syncMode:"同期モード",syncModeAuto:"自動",syncModeManual:"手動のみ",syncModeAutoDesc:"変更が検出されるとAMSデータが自動同期されます",syncModeManualDesc:"手動トリガー時のみ同期",statusLabel:"ステータス:",connected:"接続中",disconnected:"未接続",disconnect:"切断",connect:"接続",syncAmsData:"AMSデータを同期",syncAmsDataDesc:"プリンターのAMSデータをSpoolmanに手動同期",allPrinters:"すべてのプリンター",sync:"同期",syncSuccess:"{{count}}個のスプールを同期しました",syncWithErrors:"{{count}}個のスプールを同期({{errorCount}}件のエラー)",spoolsSkipped:"{{count}}個のスプールをスキップ",showAll:"すべて表示",showLess:"折りたたむ",andMore:"...他{{count}}件",errors:"エラー:",linkToSpoolman:"Spoolmanに連携",linkingAmsTray:"連携するAMSトレイ:",spoolUuid:"スプールUUID:",selectSpoolToLink:"連携するSpoolmanスプールを選択:",unknownFilament:"不明なフィラメント",noUnlinkedSpools:"Spoolmanに未連携のスプールが見つかりません。",allSpoolsLinked:"すべてのスプールはAMSトレイに連携済みです。",linking:"連携中...",linkSpool:"スプールを連携",linkTooltip:"このスプールをSpoolmanスプールに連携",noUnlinked:"未連携のスプールがありません"},subtitle:"Bambuddyの設定",saved:"設定を保存しました",saveFailed:"保存に失敗しました: {{error}}",tabGeneral:"一般",tabSmartPlugs:"スマートプラグ",tabNotifications:"通知",tabFilament:"フィラメント",tabNetwork:"ネットワーク",tabApiKeys:"APIキー",tabVirtualPrinter:"仮想プリンター",tabUsers:"ユーザー",dateFormat:"日付形式",timeFormat:"時刻形式",systemDefault:"システムデフォルト",dateFormatUS:"US (MM/DD/YYYY)",dateFormatEU:"EU (DD/MM/YYYY)",dateFormatISO:"ISO (YYYY-MM-DD)",timeFormat12h:"12時間 (3:30 PM)",timeFormat24h:"24時間 (15:30)",defaultPrinter:"デフォルトプリンター",noDefaultPrinter:"デフォルトなし(毎回選択)",defaultPrinterDescription:"アップロード、再印刷、その他の操作でこのプリンターを事前選択します。",sidebarOrder:"サイドバーの順序",sidebarOrderDescription:"サイドバーの項目をドラッグ&ドロップで並べ替えできます。ここでデフォルトの順序にリセットできます。",reset:"リセット",darkMode:"ダークモード",lightMode:"ライトモード",active:"(有効)",background:"背景",accent:"アクセント",style:"スタイル",bgNeutral:"ニュートラル",bgWarm:"ウォーム",bgCool:"クール",bgOLED:"OLED ブラック",bgSlate:"スレートブルー",bgForest:"フォレストグリーン",accentGreen:"グリーン",accentTeal:"ティール",accentBlue:"ブルー",accentOrange:"オレンジ",accentPurple:"パープル",accentRed:"レッド",styleClassic:"クラシック",styleGlow:"グロー",styleVibrant:"ビブラント",themeToggleHint:"サイドバーの太陽/月アイコンでダークモードとライトモードを切り替えます。",archiveSettings:"アーカイブ設定",autoArchive:"自動アーカイブ",autoArchiveDescription:"印刷完了時に3MFファイルを自動的に保存",saveThumbnails:"サムネイルを保存",saveThumbnailsDescription:"3MFファイルからプレビュー画像を抽出して保存",captureFinishPhoto:"完了写真を撮影",captureFinishPhotoDescription:"印刷完了時にプリンターカメラから写真を撮影",ffmpegNotInstalled:"ffmpegがインストールされていません",ffmpegInstruction:"カメラキャプチャにはffmpegが必要です。brew install ffmpeg(macOS)またはapt install ffmpeg(Linux)でインストールしてください。",camera:"カメラ",cameraViewMode:"カメラ表示モード",cameraNewWindow:"新しいウィンドウ",cameraEmbedded:"埋め込みオーバーレイ",cameraEmbeddedDescription:"メイン画面上のリサイズ可能なオーバーレイでカメラを開きます",cameraNewWindowDescription:"別のブラウザウィンドウでカメラを開きます",costTracking:"コスト追跡",defaultFilamentCost:"デフォルトフィラメントコスト(kg単位)",currency:"通貨",electricityCost:"電気代(kWh単位)",energyDisplayMode:"エネルギー表示モード",energyPrintsOnly:"印刷のみ",energyTotalConsumption:"総消費量",energyPrintsOnlyDescription:"ダッシュボードに印刷中に使用されたエネルギーの合計を表示",energyTotalDescription:"ダッシュボードにスマートプラグの累計エネルギーを表示",fileManager:"ファイルマネージャー",archiveOnPrint:"印刷時のアーカイブエントリ作成",archiveAlways:"常にアーカイブエントリを作成",archiveNever:"アーカイブエントリを作成しない",archiveAsk:"毎回確認",archiveOnPrintDescription:"ファイルマネージャーから印刷する際、オプションでアーカイブエントリを作成",lowDiskWarning:"ディスク容量不足の警告",lowDiskWarningDescription:"空きディスク容量がこのしきい値を下回ると警告を表示",checkPrinterFirmware:"プリンターファームウェアの確認",checkPrinterFirmwareDescription:"Bambu Labのプリンターファームウェア更新を確認",checkForUpdatesDescription:"起動時に自動的に新しいバージョンを確認",checkNow:"今すぐ確認",releaseNotes:"リリースノート",viewOnGitHub:"GitHubで表示",updateViaDocker:"Docker Composeでアップデート:",installUpdate:"アップデートをインストール",close:"閉じる",dataManagement:"データ管理",backupData:"データのバックアップ",backupDescription:"設定、プロバイダー、プリンターなどをエクスポート",export:"エクスポート",restoreBackup:"バックアップの復元",restoreDescription:"重複処理オプション付きでバックアップファイルから設定をインポート",restore:"復元",clearLogs:"通知ログを削除",clearLogsDescription:"30日以上前の通知ログを削除",clear:"削除",resetUI:"UIの設定をリセット",resetUIDescription:"サイドバーの順序、テーマ、表示モード、レイアウト設定をリセットします。プリンター、アーカイブ、設定には影響しません。",clearLogsTitle:"通知ログを削除",clearLogsMessage:"30日以上前のすべての通知ログを完全に削除します。この操作は元に戻せません。",clearLogsConfirm:"ログを削除",clearLogsFailed:"ログの削除に失敗しました",resetUITitle:"UIの設定をリセット",resetUIMessage:"すべてのUI設定をデフォルトにリセットします:サイドバーの順序、テーマ、ダッシュボードレイアウト、表示モード、ソート設定。プリンター、アーカイブ、サーバー設定には影響しません。クリア後にページが再読み込みされます。",resetPreferences:"設定をリセット",preferencesReset:"UI設定をリセットしました。更新中...",externalUrl:"外部URL",externalUrlDescription:"Bambuddyがアクセス可能な外部URL。通知画像や外部連携に使用されます。",bambuddyUrl:"Bambuddy URL",externalUrlHint:"プロトコルとポートを含めてください(例: http://192.168.1.100:8000)",ftpRetry:"FTPリトライ",ftpRetryDescription:"プリンターのWi-Fiが不安定な場合にFTP操作をリトライします。3MFダウンロード、印刷アップロード、タイムラプスダウンロード、ファームウェアアップデートに適用されます。",enableRetry:"リトライを有効化",enableRetryDescription:"失敗したFTP操作を自動的にリトライ",retryAttempts:"リトライ回数",times:"回",retryAttemptsDescription:"諦めるまでのリトライ回数(1-10)",retryDelay:"リトライ間隔",seconds:"秒",retryDelayDescription:"リトライ間の待ち時間(1-30)",connectionTimeout:"接続タイムアウト",connectionTimeoutDescription:"遅い接続用のソケットタイムアウト。Wi-Fiが弱いA1/A1 Miniプリンターの場合は増やしてください(10-120)",homeAssistant:"Home Assistant",connected:"接続済み",disconnected:"未接続",homeAssistantDescription:"Home Assistantに接続してHA REST APIでスマートプラグを制御します。switch、light、input_booleanエンティティに対応しています。",enableHA:"Home Assistantを有効化",enableHADescription:"Home Assistantでスマートプラグを制御",haUrl:"Home Assistant URL",haToken:"長期アクセストークン",haTokenHint:"HAでトークンを作成: プロフィール → 長期アクセストークン → トークン作成",testConnection:"接続テスト",connectionSuccessful:"接続成功",connectionFailed:"接続失敗",haConnectionSuccess:"Home Assistantへの接続に成功しました。",haConnectionFailed:"Home Assistantへの接続に失敗しました。",mqttPublishing:"MQTT配信",mqttDescription:"BamBuddyイベントを外部MQTTブローカーに配信し、Node-RED、Home Assistant、その他の自動化システムと連携します。",enableMqtt:"MQTTを有効化",enableMqttDescription:"外部MQTTブローカーにイベントを配信",brokerHostname:"ブローカーホスト名",port:"ポート",useTls:"TLSを使用",usernameOptional:"ユーザー名(オプション)",passwordOptional:"パスワード(オプション)",topicPrefix:"トピックプレフィックス",connectedTo:"接続先:",notConnected:"未接続",smartPlugsDescription:"スマートプラグ(TasmotaまたはHome Assistant)を接続して、電源制御を自動化し、プリンターのエネルギー消費を追跡します。",turnAllPlugsOn:"すべてのプラグをオン",turnAllPlugsOff:"すべてのプラグをオフ",allOn:"全オン",allOff:"全オフ",addSmartPlug:"スマートプラグを追加",energySummary:"エネルギー概要",currentPower:"現在の電力",today:"今日",yesterday:"昨日",total:"合計",enablePlugsForEnergy:"プラグを有効にしてエネルギー概要を表示",noSmartPlugs:"スマートプラグが設定されていません",noSmartPlugsDescription:"Tasmotaベースのスマートプラグを追加して、エネルギー消費を追跡し、電源制御を自動化します。",addFirstSmartPlug:"最初のスマートプラグを追加",providers:"プロバイダー",log:"ログ",testAll:"すべてテスト",add:"追加",testResults:"テスト結果",dismiss:"閉じる",noProviders:"プロバイダーが設定されていません",noProvidersDescription:"アラートを受信するにはプロバイダーを追加してください。",messageTemplates:"メッセージテンプレート",templatesDescription:"各イベントの通知メッセージをカスタマイズします。",noTemplates:"テンプレートがありません。バックエンドを再起動してデフォルトテンプレートを作成してください。",testAllSuccess:"すべて{{count}}件のプロバイダーのテストに成功しました!",testAllPartial:"{{success}}/{{tested}}件のプロバイダーが成功",testProvidersFailed:"プロバイダーのテストに失敗しました: {{error}}",bulkPlugSuccess:"すべて{{count}}個のプラグを{{action}}にしました",bulkPlugPartial:"{{success}}個のプラグを{{action}}にしました、{{failed}}個が失敗",bulkPlugFailed:"失敗: {{error}}",apiKeys:"APIキー",apiKeysDescription:"外部連携やWebhook用のAPIキーを作成します。",createKey:"キーを作成",apiKeyCreated:"APIキーを作成しました",apiKeyDeleted:"APIキーを削除しました",apiKeySuccess:"APIキーが正常に作成されました",apiKeyCopyWarning:"今すぐこのキーをコピーしてください - 再表示されません!",keyCopied:"キーをクリップボードにコピーしました",keyCopyFailed:"キーのコピーに失敗しました",keyAddedToBrowser:"キーをAPIブラウザに追加しました",useInBrowser:"APIブラウザで使用",createNewApiKey:"新しいAPIキーを作成",keyName:"キー名",permissions:"権限",readStatus:"ステータスの読み取り",readStatusDescription:"プリンターのステータスとキューを表示",manageQueue:"キューの管理",manageQueueDescription:"印刷キューへのアイテムの追加と削除",controlPrinter:"プリンターの制御",controlPrinterDescription:"印刷の一時停止、再開、停止",cancel:"キャンセル",lastUsed:"最終使用:",badgeRead:"読取",badgeQueue:"キュー",badgeControl:"制御",noApiKeys:"APIキーがありません",noApiKeysDescription:"外部サービスとの連携用にAPIキーを作成してください。",createFirstKey:"最初のキーを作成",deleteApiKeyTitle:"APIキーを削除",deleteApiKeyMessage:"このAPIキーを削除してもよろしいですか?このキーを使用しているすべての連携が動作しなくなります。",deleteKey:"キーを削除",webhookEndpoints:"Webhookエンドポイント",webhookApiKeyHint:"X-API-KeyヘッダーでAPIキーを使用してください。",webhookGetAll:"すべてのプリンターステータスを取得",webhookGetOne:"特定のプリンターステータスを取得",webhookQueue:"印刷キューに追加",webhookPause:"印刷を一時停止",webhookResume:"印刷を再開",webhookStop:"印刷を停止",apiBrowser:"APIブラウザ",apiBrowserDescription:"すべての利用可能なAPIエンドポイントを探索してテストします。",apiKeyForTesting:"テスト用APIキー",apiKeyHeaderHint:"このキーはリクエストのX-API-Keyヘッダーとして送信されます。",apiKeyCreateFailed:"APIキーの作成に失敗しました: {{error}}",apiKeyDeleteFailed:"APIキーの削除に失敗しました: {{error}}",amsThresholds:"AMS表示しきい値",amsThresholdsDescription:"AMS湿度と温度インジケーターの色しきい値を設定します。",humidity:"湿度",goodGreen:"良好(緑)≤",fairOrange:"普通(オレンジ)≤",aboveFairBad:"普通のしきい値以上は赤(悪い)で表示",temperature:"温度",goodBlue:"良好(青)≤",aboveFairHot:"普通のしきい値以上は赤(高温)で表示",historyRetention:"履歴の保持",keepHistoryFor:"センサー履歴の保持期間",days:"日",historyRetentionDescription:"古い湿度と温度データは自動的に削除されます",printModal:"印刷ダイアログ",expandMapping:"カスタムマッピングをデフォルトで展開",expandMappingDescription:"複数のプリンターに印刷する際、プリンターごとのAMSマッピングを展開して表示",currentUser:"現在のユーザー",role:"ロール:",roleAdmin:"管理者",roleUser:"ユーザー",manageUsers:"ユーザー管理",disableAuth:"認証を無効化",rolePermissions:"ロール権限",rolePermissionsDescription:"各ロールの権限の概要。",adminPerm1:"プリンター設定の管理",adminPerm2:"ユーザーの作成、編集、削除",adminPerm3:"すべてのシステム機能へのアクセス",userPerm1:"印刷ジョブの送信",userPerm2:"ファイルとアーカイブの管理",userPerm3:"フィラメントの管理",disableAuthTitle:"認証を無効化",disableAuthMessage:"認証を無効にしてもよろしいですか?これにより、Bambuddyインスタンスはログインなしでアクセス可能になります。すべてのユーザーはデータベースに残りますが、認証は無効になります。",disableAuthConfirm:"認証を無効化",authDisabledSuccess:"認証を正常に無効化しました",disableAuthFailed:"認証の無効化に失敗しました",unknownError:"不明なエラー",haUrlPlaceholder:"http://homeassistant.local:8123",haTokenPlaceholder:"長期アクセストークン",mqttHostPlaceholder:"例: 192.168.1.100",leaveEmptyAnonymous:"匿名接続の場合は空欄",mqttTopicDefault:"bambuddy",apiKeyNamePlaceholder:"例: Home Assistantインテグレーション",apiKeyTestPlaceholder:"テスト用APIキーを貼り付け",unnamedKey:"名前なしキー",plugsOnline:"{{online}}/{{total}} オンライン",passed:"{{count}}件 成功",failed:"{{count}}件 失敗",externalUrlPlaceholder:"http://192.168.1.100:8000",bulkPlugTitle:"すべてのプラグを{{action}}",bulkPlugMessage:"有効な{{count}}個のスマートプラグをすべて{{action}}しますか?",bulkPlugConfirm:"すべて{{action}}",updateCheckFailed:"確認失敗: {{error}}",releaseNotesTitle:"リリースノート - v{{version}}",mqttTopicsHint:"トピック: {{prefix}}/printers/<serial>/status など",virtualPrinterUpdated:"仮想プリンター設定を更新しました",vp:{title:"仮想プリンター",running:"稼働中",stopped:"停止中",description:"Bambu StudioやOrcaSlicerに表示される仮想プリンターを有効にします。このプリンターに送信されたファイルは印刷せずに直接アーカイブされます。",enable:"仮想プリンターを有効化",visibleInSlicer:"スライサーの検出リストに「Bambuddy」として表示",notVisible:"スライサーに表示されません",printerModel:"プリンターモデル",printerModelDescription:"エミュレートするプリンターモデルを選択します。",modelRestartWarning:"モデルを変更すると仮想プリンターが再起動されます",accessCode:"アクセスコード",accessCodeSet:"アクセスコードが設定済み",noAccessCode:"アクセスコード未設定 - 有効化に必要です",accessCodeRequired:"先にアクセスコードを設定してください",accessCodeEmpty:"アクセスコードは空にできません",accessCodeLength:"アクセスコードは8文字である必要があります",accessCodeHint:"8文字である必要があります。スライサーの認証に使用されます。",mode:"モード",modeArchive:"アーカイブ",modeArchiveDesc:"ファイルを即座にアーカイブ",modeReview:"レビュー",modeReviewDesc:"アーカイブ前にレビューとタグ付け",modeQueue:"キュー",modeQueueDesc:"アーカイブしてキューに追加",setupRequired:"セットアップが必要",setupDescription:"仮想プリンター機能を使用するには、追加のシステム設定が必要です。ポートフォワーディング、ファイアウォールルール、プラットフォーム固有の設定が含まれます。",readSetupGuide:"有効化する前にセットアップガイドをお読みください",howItWorks:"仕組み:",step1:"お使いのプラットフォームのセットアップガイドを完了する",step2:"仮想プリンターを有効にしてアクセスコードを設定する",step3:"Bambu StudioまたはOrcaSlicerで「プリンターを追加」を開く",step4:"検出リストに「Bambuddy」プリンターが表示される",step5:"設定したアクセスコードで接続する",step6:"Bambuddyに「印刷」すると、3MFファイルがアーカイブされる",statusDetails:"ステータス詳細",printerName:"プリンター名",model:"モデル",serialNumber:"シリアルナンバー",pendingFiles:"保留中のファイル"},enterNewCodeToChange:"新しいコードを入力して変更",enter8CharCode:"8文字のコードを入力",notificationTitlePlaceholder:"通知タイトル...",notificationBodyPlaceholder:"通知本文...",templateTitleRequired:"タイトルは必須です",templateBodyRequired:"本文は必須です",editTemplate:"テンプレートを編集: {{name}}",templateTitle:"タイトル",templateBody:"本文",availableVariables:"利用可能な変数",insertVariableHint:"クリックして本文のカーソル位置に挿入",livePreview:"ライブプレビュー",loadingPreview:"プレビューを読み込み中...",previewTitle:"タイトル:",previewBody:"本文:",enterTemplateToPreview:"テンプレートの内容を入力するとプレビューが表示されます",resetToDefault:"デフォルトに戻す",noExternalLinks:"外部リンクが設定されていません",clickAddLink:"「リンクを追加」をクリックして追加",deleteLink:"リンクを削除",deleteLinkConfirm:"「{{name}}」を削除しますか?この操作は取り消せません。",editLink:"リンクを編集",addExternalLink:"外部リンクを追加",addLink:"リンクを追加",sidebarLinks:"サイドバーリンク",sidebarLinksDescription:"外部リンクをサイドバーナビゲーションに追加します。ドラッグで並べ替え。",linkNamePlaceholder:"マイリンク",linkNameLabel:"名前",linkUrlLabel:"URL",linkIconLabel:"アイコン",linkCustomIcon:"カスタムアイコン",linkCustomIconHint:"PNG, JPG, GIF, SVG, WebP, ICO。最大1MB。",linkChoosePresetIcon:"またはプリセットアイコンを選択",linkNameRequired:"名前は必須です",linkUrlRequired:"URLは必須です",linkUrlInvalid:"URLは http:// または https:// で始まる必要があります",linkInvalidImageType:"有効な画像ファイルを選択してください(PNG, JPG, GIF, SVG, WebP, ICO)",linkImageTooLarge:"画像ファイルは1MB以下にしてください",removeCustomIcon:"カスタムアイコンを削除",jsonRequestBody:"JSONリクエストボディ...",searchEndpoints:"エンドポイントを検索...",groups:"グループ",addGroup:"グループを追加",noGroupsFound:"グループが見つかりません",systemGroup:"システム",noDescription:"説明なし",users:"ユーザー",addUser:"ユーザーを追加",noUsersFound:"ユーザーが見つかりません",admin:"管理者",authentication:"認証",authEnableDescription:"認証を有効にして、ユーザーアカウントの作成、権限の管理、Bambuddyインスタンスのセキュリティ保護を行います。",authSecuredDescription:"Bambuddyインスタンスは認証で保護されています。",enable:"有効にする",disable:"無効にする",changePassword:"パスワードを変更",backup:"バックアップ",backupAndRestore:"バックアップと復元",backupAndRestoreDescription:"Bambuddyデータのバックアップを作成および復元します",goToBackup:"バックアップへ移動",homeAssistantDescriptionFull:"Home Assistantに接続してスマートホームデバイスを制御します",usersCount:"{{count}}人のユーザー",permissionsCount:"{{count}}個の権限",authDisabledTitle:"認証が無効です",authDisabledDescription:"認証を有効にして、ユーザーアカウントの作成、権限の管理、Bambuddyインスタンスのセキュリティを確保しましょう。",authFeature1:"システムへのアクセスにログインを要求",authFeature2:"グループベースの権限を持つ複数のユーザーを作成",authFeature3:"50以上のきめ細かい権限でアクセスを制御",enableAuthentication:"認証を有効にする",createUser:"ユーザーを作成",username:"ユーザー名",enterUsername:"ユーザー名を入力",password:"パスワード",enterPassword:"パスワードを入力(6文字以上)",confirmPassword:"パスワードの確認",confirmPasswordPlaceholder:"パスワードを確認",passwordsDoNotMatch:"パスワードが一致しません",groupsLabel:"グループ",systemLabel:"(システム)",noGroupsAvailable:"利用可能なグループがありません",creating:"作成中...",editUser:"ユーザーを編集",leaveBlankToKeep:"(現在のパスワードを維持する場合は空白)",enterNewPassword:"新しいパスワードを入力",confirmNewPassword:"新しいパスワードを確認",deleteUser:"ユーザーを削除",deleteUserConfirm:"このユーザーを削除してもよろしいですか?この操作は元に戻せません。",createGroup:"グループを作成",editGroup:"グループを編集",groupName:"グループ名",enterGroupName:"グループ名を入力",systemGroupNameReadonly:"システムグループ名は変更できません",descriptionLabel:"説明",enterDescription:"説明を入力(任意)",permissionsSelected:"権限({{count}}件選択中)",deleteGroup:"グループを削除",deleteGroupConfirm:"このグループを削除してもよろしいですか?このグループのユーザーはこれらの権限を失います。",changePasswordTitle:"パスワードの変更",currentPassword:"現在のパスワード",enterCurrentPassword:"現在のパスワードを入力",newPassword:"新しいパスワード",enterNewPasswordMin6:"新しいパスワードを入力(6文字以上)",confirmNewPasswordPlaceholder:"新しいパスワードを確認",passwordMinLength:"パスワードは6文字以上である必要があります",passwordChanged:"パスワードが正常に変更されました",failedToChangePassword:"パスワードの変更に失敗しました",changingPassword:"変更中...",prometheusTitle:"Prometheusメトリクス",prometheusDescriptionPre:"プリンターメトリクスを",prometheusDescriptionPost:"でPrometheus/Grafanaモニタリング用に公開します。",enableMetricsEndpoint:"メトリクスエンドポイントを有効化",exposePrometheusData:"プリンターデータをPrometheus形式で公開",bearerTokenOptional:"Bearerトークン(任意)",bearerTokenPlaceholder:"認証不要の場合は空欄のまま",bearerTokenHint:"設定した場合、リクエストに次のヘッダーが必要: ",availableMetrics:"利用可能なメトリクス",metricConnectionStatus:"接続状態",metricPrinterState:"プリンター状態(アイドル/印刷中など)",metricPrintProgress:"印刷進捗 0-100%",metricBedTemp:"ベッド温度",metricNozzleTemp:"ノズル温度",metricPrintsTotal:"結果別の合計印刷数",metricAndMore:"...その他(レイヤー、ファン、キュー、フィラメント使用量)"},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:"データの読み込みに失敗しました"},confirm:{delete:"削除しますか?",unsavedChanges:"保存されていない変更があります。このページを離れますか?",clearQueue:"キューをクリアしますか?"},calendar:{months:{january:"1月",february:"2月",march:"3月",april:"4月",may:"5月",june:"6月",july:"7月",august:"8月",september:"9月",october:"10月",november:"11月",december:"12月"},daysShort:{sun:"日",mon:"月",tue:"火",wed:"水",thu:"木",fri:"金",sat:"土"}},notificationLog:{title:"通知ログ",lastDays:"過去{{days}}日間:",notifications:"件の通知",sent:"送信済み",failed:"失敗",last24Hours:"過去24時間",showFailedOnly:"失敗のみ表示",clearOld:"古いログを削除",noFailedNotifications:"失敗した通知はありません",noNotificationsLogged:"通知ログはありません",unknownProvider:"不明なプロバイダー",titleLabel:"タイトル",messageLabel:"メッセージ",errorLabel:"エラー",provider:"プロバイダー:",time:"時間:",clearLogsFailed:"ログの削除に失敗しました: {{error}}",events:{print_start:"印刷開始",print_complete:"印刷完了",print_failed:"印刷失敗",print_stopped:"印刷中止",print_progress:"進捗",printer_offline:"プリンターオフライン",printer_error:"プリンターエラー",filament_low:"フィラメント残量低下",maintenance_due:"メンテナンス期限",ams_humidity_high:"AMS湿度高",ams_temperature_high:"AMS温度高",test:"テスト"}},providers:{callmebot:"CallMeBot/WhatsApp",ntfy:"ntfy",pushover:"Pushover",telegram:"Telegram",email:"メール",discord:"Discord",webhook:"Webhook",descriptions:{email:"SMTPメール通知",telegram:"Telegramボット経由の通知",discord:"Webhook経由でDiscordチャンネルに送信",ntfy:"無料のセルフホスト対応プッシュ通知",pushover:"シンプルで確実なプッシュ通知",callmebot:"CallMeBot経由の無料WhatsApp通知",webhook:"任意のURLへの汎用HTTP POST"}},backup:{categories:{settings:"設定",notification_providers:"通知プロバイダー",notification_templates:"通知テンプレート",smart_plugs:"スマートプラグ",printers:"プリンター",filaments:"フィラメント",maintenance_types:"メンテナンスタイプ",archives:"アーカイブ",projects:"プロジェクト",pending_uploads:"アップロード待ち",external_links:"外部リンク",api_keys:"APIキー"},notificationProviders:"通知プロバイダー",notificationTemplates:"通知テンプレート",externalLinks:"外部リンク",printers:"プリンター",filamentInventory:"フィラメント在庫",maintenanceTypes:"メンテナンスタイプ",printArchives:"印刷アーカイブ",projects:"プロジェクト",pendingUploads:"保留中のアップロード",apiKeys:"APIキー",settingsDescription:"言語、テーマ、更新設定",notificationProvidersDescription:"ntfy、Pushover、Discordなど",notificationTemplatesDescription:"カスタムメッセージテンプレート",smartPlugsDescription:"Tasmotaプラグ設定",externalLinksDescription:"外部サービスへのサイドバーリンク",printersDescription:"プリンター情報(アクセスコードを除く)",filamentInventoryDescription:"フィラメントの種類とコスト",maintenanceDescription:"カスタムメンテナンススケジュール",printArchivesDescription:"全印刷データ+ファイル(3MF、サムネイル、写真)",projectsDescription:"プロジェクト、BOMアイテム、添付ファイル",pendingUploadsDescription:"レビュー待ちの仮想プリンターアップロード",apiKeysDescription:"Webhook APIキー(インポート時に新しいキーが生成されます)"},restore:{failedToRestore:"バックアップの復元に失敗しました。ファイル形式を確認してください。",title:"バックアップの復元",restoring:"復元中...",complete:"復元完了",failed:"復元失敗",importDescription:"バックアップファイルから設定をインポート",pleaseWait:"データを復元しています。しばらくお待ちください",duplicateHandling:"重複処理の仕組み:",clickToSelect:"クリックしてバックアップファイルを選択 (.json または .zip)",replaceExisting:"既存データを上書き",keepExisting:"既存データを保持",overwriteDescription:"既に存在する項目をバックアップデータで上書きします",skipDescription:"まだ存在しない項目のみ復元します",caution:"注意:",overwriteWarning:"上書きすると、現在の設定がバックアップのデータに置き換えられます。セキュリティのため、プリンターのアクセスコードは上書きされません。",restore:"復元",processing:"バックアップファイルを処理中...",itemsRestored:"復元済み項目",itemsSkipped:"スキップ済み項目",restoredSection:"復元済み",filesSection:"ファイル (3MF、サムネイルなど)",skippedSection:"スキップ (既に存在)",andMore:"...他 {{count}} 件",newApiKeys:"新しいAPIキーが生成されました",copyKeysWarning:"これらのキーは一度だけ表示されます。今すぐコピーしてください!",copy:"コピー",noDataFound:"バックアップファイルに復元するデータが見つかりませんでした。",dupPrinters:"プリンター",dupPrintersDesc:"シリアル番号で照合",dupSmartPlugs:"スマートプラグ",dupSmartPlugsDesc:"IPアドレスで照合",dupNotificationProviders:"通知プロバイダー",dupNotificationProvidersDesc:"名前で照合",dupFilaments:"フィラメント",dupFilamentsDesc:"名前 + 種類 + ブランドで照合",dupArchives:"アーカイブ",dupArchivesDesc:"コンテンツハッシュで照合 (常にスキップ)",dupPendingUploads:"アップロード待ち",dupPendingUploadsDesc:"ファイル名で照合",dupSettingsTemplates:"設定とテンプレート",dupSettingsTemplatesDesc:"常に上書き"},files:{root:"ルート",cache:"キャッシュ",models:"モデル",timelapse:"タイムラプス",used:"使用中:",free:"空き:",filterPlaceholder:"ファイルを検索...",noFiles:"このディレクトリにファイルがありません",deleteFile:"ファイルを削除",deleteConfirm:'"{{name}}"を削除しますか?この操作は元に戻せません。',fileManager:"ファイル管理",pageDescription:"プリントファイルを整理・管理",newFolder:"新しいフォルダ",folderName:"フォルダ名",folderNamePlaceholder:"例: 機能パーツ",renameFile:"ファイル名を変更",renameFolder:"フォルダ名を変更",rename:"名前変更",rootNoFolder:"ルート(フォルダなし)",moveFilesCount:"{{count}}個のファイルを移動",current:"(現在)",move:"移動",linkFolder:"フォルダをリンク",linkFolderDescription:"「{{name}}」をプロジェクトまたはアーカイブにリンクしてすばやくアクセス。",noProjectsFound:"プロジェクトが見つかりません",noArchivesFound:"アーカイブが見つかりません",unlink:"リンク解除",link:"リンク",uploadFiles:"ファイルをアップロード",dropFilesHere:"ここにファイルをドロップ",dragAndDropFiles:"ファイルをドラッグ&ドロップ",orClickToBrowse:"またはクリックして選択",zipAutoExtract:"ZIPファイルは自動的に展開されます",zipFilesDetected:"ZIPファイルを検出",zipChooseHandling:"ZIPファイルが展開されます。フォルダ構造の処理方法を選択してください:",preserveZipStructure:"ZIPのフォルダ構造を保持",willBeExtracted:"• 展開予定",filesExtracted:"• {{count}}個のファイルを展開済み",uploadComplete:"アップロード完了: {{count}}個成功",uploadErrorCount:"、{{count}}個失敗",uploading:"アップロード中...",filesFailed:"{{count}}個のファイルが失敗",uploadFailed:"アップロード失敗",linkToProjectOrArchive:"プロジェクトまたはアーカイブにリンク",changeLink:"リンクを変更...",linkTo:"リンク先...",printedCount:"{{count}}回印刷済み",addToQueue:"キューに追加",adding:"追加中...",folderCreated:"フォルダを作成しました",folderDeleted:"フォルダを削除しました",fileDeleted:"ファイルを削除しました",deletedFiles:"{{count}}個のファイルを削除しました",filesMoved:"ファイルを移動しました",folderUnlinked:"フォルダのリンクを解除しました",folderLinked:"フォルダをリンクしました",addedToQueue:"{{count}}個のファイルをキューに追加しました",addedToQueueWithErrors:"{{added}}個追加、{{errors}}個失敗",failedToAddFiles:"ファイルの追加に失敗: {{error}}",fileRenamed:"ファイル名を変更しました",folderRenamed:"フォルダ名を変更しました",gridView:"グリッド表示",listView:"リスト表示",lowDiskSpaceWarning:"ディスク容量不足の警告",lowDiskSpaceDescription:"空き容量は{{free}}(合計{{total}})。しきい値は設定で{{threshold}} GBに設定されています。",filesLabel:"ファイル:",foldersLabel:"フォルダ:",sizeLabel:"サイズ:",freeLabel:"空き:",folders:"フォルダ",allFiles:"すべてのファイル",allTypes:"すべての種類",date:"日付",size:"サイズ",type:"種類",prints:"印刷回数",ascending:"昇順",descending:"降順",filteredCount:"{{total}}件中{{filtered}}件",deselectAll:"すべて選択解除",selectAll:"すべて選択",selectedCount:"{{count}}件選択中",loadingFiles:"ファイルを読み込み中...",folderEmpty:"フォルダは空です",noFilesYet:"ファイルはまだありません",emptyFolderDescription:"ファイルをアップロードするか、このフォルダにファイルを移動してください。",emptyRootDescription:"プリント関連ファイルの整理を始めるにはファイルをアップロードしてください。",noMatchingFiles:"一致するファイルがありません",noMatchingFilesDescription:"現在の検索またはフィルター条件に一致するファイルがありません。",clearFilters:"フィルターをクリア",sort:{nameAsc:"名前 (A-Z)",nameDesc:"名前 (Z-A)",sizeAsc:"サイズ (小さい順)",sizeDesc:"サイズ (大きい順)",dateAsc:"日付 (古い順)",dateDesc:"日付 (新しい順)"},searchFiles:"ファイルを検索...",deleteFolder:"フォルダを削除",deleteBulkTitle:"{{count}}件のファイルを削除",deleteFolderConfirm:"このフォルダを削除しますか?中のファイルもすべて削除されます。",deleteMultipleConfirm:"選択した{{count}}件のファイルを削除しますか?この操作は元に戻せません。",deleteFileConfirm:"このファイルを削除しますか?",deleting:"削除中..."},printOptions:{title:"印刷オプション",bedLevelling:"ベッドレベリング",bedLevellingDesc:"印刷前にベッドを自動レベリング",flowCali:"フローキャリブレーション",flowCaliDesc:"押出量を校正",vibrationCali:"振動キャリブレーション",vibrationCaliDesc:"リンギングを低減",layerInspect:"初層検査",layerInspectDesc:"AIによる初層の検査",timelapse:"タイムラプス",timelapseDesc:"タイムラプス動画を記録"},printModal:{powerOffWhenDone:"完了後にプリンターの電源をオフ",immediateHelp:"プリンターがアイドル状態になり次第、印刷を開始します。",scheduledHelp:"スケジュールされた時間にプリンターがアイドル状態であれば印刷を開始します。ビジー状態の場合は、利用可能になるまで待機します。",stagedHelp:"印刷はステージングされますが、自動的には開始されません。キューに送るにはスタートボタンを使用してください。",print:"印刷",reprint:"再印刷",printToMultiple:"{{count}}台のプリンターに印刷",editQueueItem:"キューアイテムを編集",sameTypeDifferentColor:"同じタイプ、異なる色",filamentTypeNotLoaded:"フィラメントタイプが読み込まれていません",specificPrinter:"特定のプリンター",selectPrinters:"プリンターを選択",selectAll:"すべて選択",printersSelected:"{{count}}台のプリンターを選択中",noPrintersAvailable:"利用可能なプリンターがありません",noActivePrintersAvailable:"アクティブなプリンターがありません",inactive:"非アクティブ",unknownModel:"不明なモデル",customMapping:"カスタムマッピング",auto:"自動",showAll:"すべて表示",selectAtLeastOne:"プリンターを1台以上選択してください",selectTargetModel:"ターゲットモデルを選択",selectSlot:"スロットを選択...",reRead:"再読み込み",customSlotMapping:"カスタムスロットマッピング",autoMatched:"自動マッチ",manuallySelected:"手動選択",schedulerWillAssign:"スケジューラーが最初に利用可能なアイドル状態の{{model}}プリンターに割り当てます",inLocation:"{{location}}内",anyModel:"任意の{{model}}",hiddenPrinters:"他{{count}}台のプリンターが非表示(異なるモデル)",showOnlyModel:"{{model}}プリンターのみ表示",matchedCount:"({{matched}}/{{total}} 一致)",targetModelLabel:"ターゲットモデル",selectAModel:"モデルを選択...",locationFilterLabel:"ロケーションフィルター(任意)",anyLocation:"すべてのロケーション"},login:{title:"Bambuddy ログイン",subtitle:"アカウントにサインイン",username:"ユーザー名",usernamePlaceholder:"ユーザー名を入力",password:"パスワード",passwordPlaceholder:"パスワードを入力",loggingIn:"ログイン中...",signIn:"サインイン",enterCredentials:"ユーザー名とパスワードを入力してください",success:"ログインしました",failed:"ログインに失敗しました"},setup:{title:"Bambuddy セットアップ",description:"Bambuddyインスタンスの認証を設定します",enableAuthentication:"認証を有効にする",adminAccount:"管理者アカウント",adminAccountDescription:"既に管理者ユーザーが存在する場合、既存の管理者アカウントを使用して認証が有効になります。既存の管理者を使用するには以下のフィールドを空のままにするか、新しい管理者ユーザーを作成するには新しい認証情報を入力してください。",adminUsername:"管理者ユーザー名",adminPassword:"管理者パスワード",optionalIfAdminsExist:"管理者ユーザーが存在する場合は任意",placeholderAdminUsername:"管理者ユーザー名を入力(任意)",placeholderAdminPassword:"管理者パスワードを入力(任意)",confirmPassword:"パスワードの確認",placeholderConfirmPassword:"管理者パスワードを確認",settingUp:"セットアップ中...",completeSetup:"セットアップを完了",toast:{authEnabledAdminCreated:"認証が有効になり、管理者ユーザーが作成されました",authEnabledExistingAdmins:"既存の管理者ユーザーを使用して認証が有効になりました",setupCompleted:"セットアップが完了しました",enterBothOrLeaveEmpty:"管理者ユーザー名とパスワードの両方を入力するか、既存の管理者ユーザーを使用するには両方を空にしてください",passwordsDoNotMatch:"パスワードが一致しません",passwordMinLength:"パスワードは6文字以上必要です"}},users:{title:"ユーザー管理",description:"Bambuddyインスタンスのユーザーとアクセスを管理します",noPermission:"このページにアクセスする権限がありません。",backToSettings:"設定に戻る",createUser:"ユーザーを作成",deleteUser:"ユーザーを削除",deleteConfirmMessage:"このユーザーを削除してもよろしいですか?この操作は元に戻せません。",password:"パスワード",placeholderUsername:"ユーザー名を入力",placeholderPassword:"パスワードを入力",roleUser:"ユーザー",roleAdmin:"管理者",statusActive:"アクティブ",statusInactive:"非アクティブ",save:"保存",cancel:"キャンセル",edit:"編集",delete:"削除",creating:"作成中...",admin:"管理者",editUser:"ユーザーを編集",groups:"グループ",noGroups:"グループなし",noGroupsAvailable:"利用可能なグループがありません",confirmPassword:"パスワードの確認",placeholderNewPassword:"新しいパスワード",placeholderConfirmPassword:"パスワードの確認",placeholderConfirmNewPassword:"新しいパスワードの確認",leaveBlankToKeepCurrent:"現在のパスワードを維持する場合は空のままにしてください",saveChanges:"変更を保存",saving:"保存中...",system:"システム",table:{username:"ユーザー名",role:"ロール",status:"ステータス",actions:"アクション",groups:"グループ"},toast:{userCreated:"ユーザーが正常に作成されました",userUpdated:"ユーザーが正常に更新されました",userDeleted:"ユーザーが正常に削除されました",fillRequiredFields:"必須項目をすべて入力してください",passwordMinLength:"パスワードは6文字以上である必要があります",passwordsDoNotMatch:"パスワードが一致しません"}},upload:{title:"3MFファイルのアップロード",dragDrop:".3mfファイルをここにドラッグ&ドロップ",or:"または",browseFiles:"ファイルを参照",associatePrinter:"プリンターに関連付け(任意)",noPrinter:"プリンターなし",uploaded:"アップロード済み",failedCount:"失敗",filesUploaded:"{{count}}ファイルをアップロードしました",printerModelExtracted:"プリンターモデルは3MFメタデータから自動抽出されます",filesFailed:"{{count}}ファイルのアップロードに失敗しました",partialResult:"{{uploaded}}件アップロード、{{failed}}件失敗",failed:"アップロードに失敗しました",uploading:"アップロード中...",upload:"アップロード"},gcode:{loading:"G-codeを読み込み中...",notAvailable:"G-codeが利用できません",notSlicedMessage:"このファイルはまだスライスされていません。G-codeプレビューはBambu StudioまたはOrca Slicerでスライス後に利用可能です。",loadFailed:"G-codeの読み込みに失敗しました"},dashboard:{dragToReorder:"ドラッグして並べ替え",sizeClickCycle:"サイズ: {{size}} - クリックで変更",hideWidget:"ウィジェットを非表示",resetLayout:"レイアウトをリセット",hiddenCount:"{{count}}件非表示",hiddenWidgets:"非表示のウィジェット(クリックで表示):",allHidden:"すべてのウィジェットが非表示です。"},printerQueue:{nextInQueue:"次のキュー",asap:"即時",now:"今すぐ",inLessThanMin:"1分以内",inMinutes:"{{count}}分後",inHours:"{{count}}時間後"},smartPlug:{offline:"オフライン",admin:"管理",openAdminPage:"プラグの管理ページを開く",linkedTo:"接続先:",alerts:"アラート",automationSettings:"自動化設定",showInSwitchbar:"スイッチバーに表示",switchbarDesc:"サイドバーからクイックアクセス",enabledDesc:"このプラグの自動化を有効にする",autoOffDesc:"印刷完了後に自動オフ(1回のみ)",delayMode:"オフ遅延モード",temp:"温度",delayMinutes:"遅延(分)",tempThreshold:"温度しきい値(℃)",tempThresholdDesc:"ノズルがこの温度以下に冷えたらオフにします",deleteTitle:"スマートプラグを削除",deleteConfirm:'"{{name}}"を削除してもよろしいですか?この操作は元に戻せません。',turnOnTitle:"スマートプラグをオン",turnOnConfirm:'"{{name}}"をオンにしてもよろしいですか?',turnOn:"オン",turnOffTitle:"スマートプラグをオフ",turnOffConfirm:'"{{name}}"をオフにしてもよろしいですか?接続されたデバイスの電源が切断されます。',turnOff:"オフ",controlFailed:'"{{name}}"の{{action}}に失敗しました',monitorOnly:"モニタリングのみ",waiting:"データを待機中...",monitor:"モニター",power:"電力",kwhToday:"本日の消費電力",settings:"設定",smartSwitches:"スマートスイッチ",noSwitchesInSwitchbar:"スイッチバーに有効なスイッチがありません",enableInSettings:"設定 → スマートプラグで有効にしてください"},addSmartPlug:{addTitle:"スマートプラグを追加",editTitle:"スマートプラグを編集",tasmota:"Tasmota",homeAssistant:"Home Assistant",stopScanning:"スキャンを停止",discoverDevices:"Tasmotaデバイスを検出",scanningNetwork:"ネットワークをスキャン中...",foundDevices:"{{count}}台のデバイスが見つかりました - クリックして選択:",noDevicesFound:"ネットワーク上にTasmotaデバイスが見つかりません",failedToStartScan:"スキャンの開始に失敗しました",haNotConfigured:"Home Assistantが設定されていません。",haNotConfiguredPath:"設定 → ネットワーク → Home Assistant で設定してください",selectEntity:"エンティティを選択",chooseEntity:"エンティティを選択...",loadingEntities:"エンティティを読み込み中...",failedToLoadEntities:"エンティティの読み込みに失敗しました: {{error}}",searchEntities:"エンティティを検索...",noEntitiesMatching:"「{{search}}」に一致するエンティティが見つかりません",noEntitiesAvailable:"利用可能なエンティティがありません",searchingEntities:"すべてのエンティティを検索中({{count}}件見つかりました)",showingEntities:"switch、light、input_booleanを表示中({{count}}件利用可能)",energyMonitoring:"エネルギーモニタリング(任意)",energyMonitoringDescription:"電力/エネルギーデータを提供するセンサーを検索して選択します。",powerSensor:"電力センサー(W)",searchPowerSensors:"電力センサーを検索...",energyToday:"今日のエネルギー(kWh)",totalEnergy:"総エネルギー(kWh)",searchEnergySensors:"エネルギーセンサーを検索...",noMatchingSensors:"一致するセンサーがありません",ipAddress:"IPアドレス",ipAddressPlaceholder:"192.168.1.100",test:"テスト",connected:"接続されました!",device:"デバイス",state:"状態",connectionFailed:"接続に失敗しました",name:"名前",namePlaceholder:"リビングのプラグ",username:"ユーザー名",usernamePlaceholder:"admin",password:"パスワード",passwordPlaceholder:"********",authHint:"Tasmotaデバイスが認証を必要としない場合は空のままにしてください",linkToPrinter:"プリンターに連携",noPrinterOption:"プリンターなし(手動制御のみ)",linkToPrinterHint:"連携すると印刷の開始/完了時に自動オン/オフが有効になります",powerAlerts:"電力アラート",alertAbove:"超過時にアラート(W)",alertAbovePlaceholder:"例: 200",alertBelow:"下回った時にアラート(W)",alertBelowPlaceholder:"例: 10",powerAlertHint:"消費電力がこれらのしきい値を超えた/下回った場合に通知します。無効にするには空のままにしてください。",dailySchedule:"デイリースケジュール",turnOnAt:"オンにする時刻",turnOffAt:"オフにする時刻",scheduleHint:"毎日これらの時刻にプラグを自動的にオン/オフします。スキップするには空のままにしてください。",showInSwitchbar:"スイッチバーに表示",showInSwitchbarHint:"サイドバーからクイックアクセス",nameRequired:"名前は必須です",ipRequired:"Tasmotaプラグの場合、IPアドレスは必須です",entityRequired:"Home Assistantプラグの場合、エンティティは必須です",mqtt:"MQTT",mqttTopicRequired:"MQTTトピックは、電力、エネルギー、またはステートのいずれかを設定する必要があります",mqttBrokerNotConfigured:"MQTTブローカーが設定されていません。ブローカーアドレスを設定してください:",mqttBrokerNotConfiguredPath:"設定 → ネットワーク → MQTT発行",mqttBrokerNotConfiguredHint:"(パブリッシュを有効にする必要はありません。ブローカーの詳細を入力するだけです)。",mqttMonitorOnly:"モニタリングのみ",mqttMonitorOnlyDescription:"MQTTプラグはMQTTサブスクリプション経由で電力/エネルギーデータを受信します。オン/オフ制御はできません - MQTTブローカーまたはホームオートメーションシステムを使用してください。",mqttPowerMonitoring:"電力モニタリング",mqttEnergyMonitoring:"エネルギーモニタリング",mqttStateMonitoring:"ステートモニタリング",mqttTopic:"トピック",mqttJsonPath:"JSONパス",mqttMultiplier:"乗数",mqttOnValue:"ONの値",mqttPowerJsonPathHint:"JSONパスはJSONペイロードから値を抽出します(例:「power_l1」)。トピックが生の数値を発行する場合は空のままにしてください。",mqttPowerMultiplierHint:"乗数 0.001 で mW→W、1000 で kW→W に変換します。",mqttEnergyJsonPathHint:"JSONパスはJSONペイロードから値を抽出します。生の値の場合は空のままにしてください。",mqttEnergyMultiplierHint:"乗数 0.001 で Wh→kWh、1000 で MWh→kWh に変換します。",mqttStateJsonPathHint:"JSONパスはJSONペイロードから値を抽出します。生の値の場合は空のままにしてください。",mqttStateOnValueHint:"ONの値:「ON」を意味する正確な文字列。自動検出(ON、true、1)の場合は空のままにしてください。"},addNotification:{addTitle:"通知プロバイダーを追加",editTitle:"通知プロバイダーを編集",nameRequired:"名前は必須です",fieldRequired:"{{field}}は必須です",namePlaceholder:"マイ通知",providerType:"プロバイダータイプ",configuration:"設定",testConfiguration:"設定をテスト",printerFilter:"プリンターフィルター",allPrinters:"すべてのプリンター",printerFilterDesc:"このプリンターのイベントのみ通知を送信",quietHours:"サイレント時間(おやすみモード)",start:"開始",end:"終了",dailyDigest:"デイリーダイジェスト",dailyDigestDesc:"通知をまとめて1日1回のサマリーとして送信",sendDigestAt:"ダイジェスト送信時刻",digestDescription:"イベントを収集し、この時刻にまとめて送信します",notificationEvents:"通知イベント",printEvents:"印刷イベント",printerStatus:"プリンターステータス",events:{start:"開始",complete:"完了",failed:"失敗",stopped:"停止",progress:"進捗",offline:"オフライン",error:"エラー",lowFilament:"フィラメント残量少",maintenance:"メンテナンス"},config:{callmebot:{phoneNumber:"電話番号",apiKey:"APIキー",apiKeyPlaceholder:"CallMeBot APIキー"},ntfy:{serverUrl:"サーバーURL",topic:"トピック",authToken:"認証トークン",authTokenPlaceholder:"認証(任意)"},pushover:{userKey:"ユーザーキー",userKeyPlaceholder:"Pushoverユーザーキー",appToken:"アプリトークン",appTokenPlaceholder:"Pushoverアプリトークン",priority:"優先度",priorityPlaceholder:"0(通常)"},telegram:{botToken:"Botトークン",botTokenPlaceholder:"@BotFatherから取得したトークン",chatId:"チャットID",chatIdPlaceholder:"チャットまたはグループID"},email:{smtpServer:"SMTPサーバー",smtpPort:"SMTPポート",security:"セキュリティ",starttls:"STARTTLS(ポート587)",ssl:"SSL/TLS(ポート465)",securityNone:"なし(ポート25)",authentication:"認証",username:"ユーザー名",password:"パスワード",passwordPlaceholder:"アプリパスワード",fromEmail:"送信元メール",toEmail:"送信先メール"},discord:{webhookUrl:"Webhook URL"},webhook:{webhookUrl:"Webhook URL",payloadFormat:"ペイロード形式",genericJson:"汎用JSON",slackMattermost:"Slack / Mattermost",authorization:"認証",authorizationPlaceholder:"Bearerトークン(任意)",titleFieldName:"タイトルフィールド名",messageFieldName:"メッセージフィールド名"}}},pendingUploads:{title:"保留中のアップロード({{count}}件)",justNow:"たった今",minutesAgo:"{{count}}分前",hoursAgo:"{{count}}時間前",daysAgo:"{{count}}日前",fromSource:"{{ip}}から",archive:"アーカイブ",archiveAll:"すべてアーカイブ",discardAll:"すべて破棄",discard:"破棄",discardTitle:"アップロードを破棄",discardConfirm:'"{{filename}}"を破棄してもよろしいですか?この操作は元に戻せません。',tags:"タグ",tagsPlaceholder:"例: 機能部品、プロトタイプ、ギフト",notes:"メモ",notesPlaceholder:"この印刷についてメモを追加...",project:"プロジェクト",noProject:"プロジェクトなし",description:"これらのファイルはバーチャルプリンター経由でアップロードされました。確認してアーカイブし、コレクションに追加してください。",archiveAllTitle:"すべてのアップロードをアーカイブ",archiveAllConfirm:"保留中のアップロード{{count}}件をすべてアーカイブしてもよろしいですか?",discardAllTitle:"すべてのアップロードを破棄",discardAllConfirm:"保留中のアップロード{{count}}件をすべて破棄してもよろしいですか?この操作は元に戻せません。",archived:"アーカイブ済み: {{name}}",archiveFailed:"アーカイブに失敗しました",discarded:"アップロードを破棄しました",discardFailed:"破棄に失敗しました",archivedCount:"{{count}}ファイルをアーカイブしました",discardedCount:"{{count}}ファイルを破棄しました",archiveAllFailed:"すべてのアーカイブに失敗しました",discardAllFailed:"すべての破棄に失敗しました"},shortcuts:{title:"キーボードショートカット",navigation:"ナビゲーション",archives:"アーカイブ",profiles:"K-プロファイル",general:"一般",goToPrinters:"プリンターへ",goToArchives:"アーカイブへ",goToQueue:"キューへ",goToStatistics:"統計へ",goToProfiles:"クラウドプロファイルへ",goToSettings:"設定へ",openItem:"{{item}}を開く",goToItem:"{{item}}へ移動",focusSearch:"検索にフォーカス",openUpload:"アップロードダイアログを開く",clearSelection:"選択解除 / 入力をクリア",contextMenu:"カードのコンテキストメニュー",refreshProfiles:"プロファイルを更新",newProfile:"新しいプロファイル",exitSelection:"選択モードを終了",showHelp:"このヘルプを表示",pressKey:"押す",orClickToClose:"または外側をクリックで閉じる"},logViewer:{title:"アプリケーションログ",liveStreaming:"ライブストリーミング - {{count}}エントリ",description:"アプリケーションログの表示とフィルタ",live:"ライブ",stop:"停止",start:"開始",clear:"クリア",autoScroll:"自動スクロール",searchPlaceholder:"メッセージまたはロガー名で検索...",noEntries:"ログエントリが見つかりません",emptyLog:"ログファイルが空またはクリアされています",autoRefreshing:"2秒ごとに自動更新中",clickStart:"開始をクリックしてライブログストリーミングを有効にする"},editArchive:{title:"アーカイブを編集",name:"名前",printNamePlaceholder:"印刷名",printer:"プリンター",noPrinter:"プリンターなし",project:"プロジェクト",noProject:"プロジェクトなし",itemsPrinted:"印刷数",itemsPrintedDescription:"この印刷ジョブで生産されたアイテム数",notes:"メモ",notesPlaceholder:"この印刷についてメモを追加...",tags:"タグ",addTags:"タグを追加...",addMoreTags:"タグをさらに追加...",existingTagsHint:"既存のタグ(クリックで追加)",externalLink:"外部リンク",externalLinkPlaceholder:"https://...",externalLinkDescription:"MakerWorld、Printables、Thingiverseなどへのリンク",status:"ステータス",statusCompleted:"完了",statusFailed:"失敗",statusCancelled:"キャンセル",statusPrinting:"印刷中",failureReason:"失敗理由",selectReason:"理由を選択...",failureReasons:{adhesionFailure:"定着不良",spaghettiDetached:"スパゲッティ / 剥離",layerShift:"レイヤーシフト",cloggedNozzle:"ノズル詰まり",filamentRunout:"フィラメント切れ",warping:"反り",stringing:"糸引き",underExtrusion:"押出不足",powerFailure:"電源障害",userCancelled:"ユーザーによるキャンセル",other:"その他"},photos:"印刷結果の写真",printResult:"印刷結果",photosDescription:"+をクリックして印刷結果の写真を追加",saving:"保存中..."},mqttDebug:{title:"MQTTデバッグログ",empty:"<空>",startLogging:"ログ記録を開始",searchPlaceholder:"トピックまたはペイロードで検索...",incoming:"受信",outgoing:"送信",noMessages:"まだメッセージが記録されていません",clickStart:"「ログ記録を開始」をクリックしてMQTTメッセージの記録を開始",noMatch:"フィルタに一致するメッセージがありません",adjustFilter:"検索条件またはフィルタ条件を調整してみてください",loggingActive:"ログ記録中 - メッセージは自動更新されます",loggingStopped:"ログ記録停止"},archiveActions:{print:"印刷",schedule:"スケジュール",openInSlicer:"Bambu Studioで開く",slice:"スライス",viewMakerWorld:"MakerWorldで表示",preview3d:"3Dプレビュー",viewTimelapse:"タイムラプスを表示",scanTimelapse:"タイムラプスを検索",downloadSource3mf:"ソース3MFをダウンロード",uploadSource3mf:"ソース3MFをアップロード",replaceSource3mf:"ソース3MFを置換",removeSource3mf:"ソース3MFを削除",replaceF3d:"F3Dを置換",uploadF3d:"F3Dをアップロード",downloadF3d:"F3Dをダウンロード",removeF3d:"F3Dを削除",copyLink:"ダウンロードリンクをコピー",qrCode:"QRコード",viewPhotos:"写真を表示",projectPage:"プロジェクトページ",goToProject:"プロジェクトへ: {{name}}",addToProject:"プロジェクトに追加",removeFromProject:"プロジェクトから削除",noProjects:"利用可能なプロジェクトがありません",deselect:"選択解除",select:"選択",remove:"削除",source3mfAttached:"ソース3MFを添付しました: {{filename}}",source3mfUploadFailed:"ソース3MFのアップロードに失敗しました",source3mfRemoved:"ソース3MFを削除しました",source3mfRemoveFailed:"ソース3MFの削除に失敗しました",f3dAttached:"F3Dを添付しました: {{filename}}",f3dUploadFailed:"F3Dのアップロードに失敗しました",f3dRemoved:"F3Dを削除しました",f3dRemoveFailed:"F3Dの削除に失敗しました",timelapseAttached:"タイムラプスを添付しました: {{filename}}",timelapseExists:"タイムラプスは既に添付されています",noTimelapseFound:"一致するタイムラプスが見つかりません",timelapseScanFailed:"タイムラプスの検索に失敗しました",timelapseAttachFailed:"タイムラプスの添付に失敗しました",deleted:"アーカイブを削除しました",deleteFailed:"アーカイブの削除に失敗しました",addedToFavorites:"お気に入りに追加しました",removedFromFavorites:"お気に入りから削除しました",projectUpdated:"プロジェクトを更新しました",projectUpdateFailed:"プロジェクトの更新に失敗しました",linkCopied:"リンクをクリップボードにコピーしました",linkCopyFailed:"リンクのコピーに失敗しました",photoDeleted:"写真を削除しました",photoDeleteFailed:"写真の削除に失敗しました",deleteTitle:"アーカイブを削除",deleteConfirm:'"{{name}}"を削除してもよろしいですか?この操作は元に戻せません。',removeSource3mfTitle:"ソース3MFを削除",removeSource3mfConfirm:'"{{name}}"からソース3MFファイルを削除してもよろしいですか?元のスライサープロジェクトファイルが削除されます。',removeF3dTitle:"F3Dを削除",removeF3dConfirm:'"{{name}}"からFusion 360デザインファイルを削除してもよろしいですか?',selectTimelapse:"タイムラプスを選択",selectTimelapseDesc:"自動一致が見つかりませんでした。この印刷のタイムラプスを選択してください:"},camera:{camera:"カメラ",invalidPrinterId:"無効なプリンターID",printerFallback:"プリンター #{{id}}",live:"ライブ",snapshot:"スナップショット",restartStream:"ストリームを再開",refreshSnapshot:"スナップショットを更新",fullscreen:"フルスクリーン",exitFullscreen:"フルスクリーンを終了",connectingToCamera:"カメラに接続中...",capturingSnapshot:"スナップショットを撮影中...",connectionLost:"接続が切断されました",reconnectingIn:"{{seconds}}秒後に再接続します(試行{{attempt}}/{{maxAttempts}})",reconnectNow:"今すぐ再接続",cameraUnavailable:"カメラが利用できません",makeSurePrinterConnected:"プリンターが接続されていること、およびプリンター設定でカメラが有効になっていることを確認してください。",retry:"再試行",cameraStream:"カメラストリーム",zoomIn:"ズームイン",zoomOut:"ズームアウト",resetZoom:"ズームをリセット",skipBack:"5秒戻る",skipForward:"5秒進む",refreshStream:"ストリームを更新",dragToResize:"ドラッグしてリサイズ"},archiveCard:{slicedReady:"スライス済みファイル - 印刷可能",sourceOnly:"ソースファイルのみ - AMSマッピングなし",gcode:"GCODE",source:"ソース",layers:"レイヤー",objects:"{{count}}オブジェクト",objects_other:"{{count}}オブジェクト",cancelled:"キャンセル",failed:"失敗",duplicate:"重複"},providerCard:{last:"最終: ",lastSuccessAt:"最終: {{date}}",printer:"プリンター: ",allPrinters:"すべてのプリンター",tagStart:"開始",tagComplete:"完了",tagFailed:"失敗",tagStopped:"中止",tagProgress:"進捗",tagOffline:"オフライン",tagLowFilament:"フィラメント残量低下",tagMaintenance:"メンテナンス",tagAmsHumidity:"AMS湿度",tagAmsTemp:"AMS温度",tagAmsHtHumidity:"AMS-HT湿度",tagAmsHtTemp:"AMS-HT温度",quiet:"おやすみ",digest:"ダイジェスト ",digestAt:"ダイジェスト {{time}}",sendTest:"テスト通知を送信",eventSettings:"イベント設定",sendNotifications:"このプロバイダーから通知を送信",printEvents:"印刷イベント",printerStatus:"プリンターステータス",amsAlarms:"AMSアラーム",amsHumidityHigh:"AMS湿度高",amsHumidityHighDesc:"通常AMSの湿度がしきい値を超過",amsTempHigh:"AMS温度高",amsTempHighDesc:"通常AMSの温度がしきい値を超過",amsHtAlarms:"AMS-HTアラーム",amsHtHumidityHigh:"AMS-HT湿度高",amsHtHumidityHighDesc:"AMS-HTの湿度がしきい値を超過",amsHtTempHigh:"AMS-HT温度高",amsHtTempHighDesc:"AMS-HTの温度がしきい値を超過",noNotificationsDuring:"この時間帯は通知を送信しません",editQuietHours:"プロバイダーを編集しておやすみ時間を変更",dailyDigest:"デイリーダイジェスト",dailyDigestDesc:"通知を1日1回のサマリーにまとめる",sendAt:"送信時刻",editDigestTime:"プロバイダーを編集してダイジェスト時刻を変更",deleteTitle:"通知プロバイダーを削除",deleteConfirm:"「{{name}}」を削除してもよろしいですか?この操作は元に戻せません。"},projects:{title:"プロジェクト",subtitle:"印刷プロジェクトを管理",editProject:"プロジェクトを編集",newProject:"新規プロジェクト",namePlaceholder:"プロジェクト名",descriptionPlaceholder:"プロジェクトの説明(任意)",color:"色",targetPlates:"目標プレート数",targetPlatesPlaceholder:"例: 10",targetPlatesHint:"必要な印刷ジョブ/プレート数",targetParts:"目標パーツ数",targetPartsPlaceholder:"例: 50",targetPartsHint:"必要な個別パーツの総数",tags:"タグ",tagsPlaceholder:"カンマ区切りのタグ",dueDate:"期限",priorityLabel:"優先度",priority:{low:"低",normal:"通常",high:"高",urgent:"緊急"},status:{active:"進行中",completed:"完了",archived:"アーカイブ済み"},create:"作成",parts:"パーツ",plates:"プレート",failed:"失敗",completed:"完了",inQueue:"キュー内",noPrintsYet:"印刷履歴なし",more:"もっと見る",printJobsPlates:"印刷ジョブ / プレート",partsPrinted:"印刷済みパーツ",failedParts:"失敗パーツ",projectCreated:"プロジェクトを作成しました",projectUpdated:"プロジェクトを更新しました",projectDeleted:"プロジェクトを削除しました",all:"すべて",loading:"プロジェクトを読み込み中...",noProjectsYet:"プロジェクトがまだありません",noStatusProjects:"{{status}}のプロジェクトはありません",noProjectsHint:"プロジェクトを作成して印刷を整理・追跡しましょう",noStatusProjectsHint:"ステータスが「{{status}}」のプロジェクトはありません",createFirstProject:"最初のプロジェクトを作成",deleteProject:"プロジェクトを削除",deleteProjectConfirm:"このプロジェクトを削除しますか?この操作は取り消せません。",exportAllProjects:"すべてのプロジェクトをエクスポート",importProject:"プロジェクトをインポート",importFailed:"インポートに失敗しました",projectImported:"プロジェクトがインポートされました",projectsExported:"プロジェクトがエクスポートされました",noCreatePermission:"プロジェクトを作成する権限がありません",noDeletePermission:"プロジェクトを削除する権限がありません",noEditPermission:"プロジェクトを編集する権限がありません",noExportPermission:"プロジェクトをエクスポートする権限がありません",noImportPermission:"プロジェクトをインポートする権限がありません"},projectDetail:{statusActive:"進行中",statusCompleted:"完了",statusArchived:"アーカイブ済み",noPrintsYet:"印刷履歴なし",print:"印刷",unknown:"不明",priorityLow:"低",priorityNormal:"通常",priorityHigh:"高",priorityUrgent:"緊急",overdue:"期限超過",dueToday:"本日期限",daysLeft:"残り{{count}}日",projectUpdated:"プロジェクトを更新しました",partAdded:"パーツを追加しました",partRemoved:"パーツを削除しました",deletePart:"パーツを削除",deletePartConfirm:"「{{name}}」を削除しますか?",templateCreated:"プロジェクトからテンプレートを作成しました",error:"エラー",projectNotFound:"プロジェクトが見つかりません",backToProjects:"プロジェクト一覧に戻る",projects:"プロジェクト",edit:"編集",platesProgress:"プレート進捗",printJobs:"印刷ジョブ",percentComplete:"% 完了",remaining:"残り",partsProgress:"パーツ進捗",parts:"パーツ",printJobsCard:"印刷ジョブ",total:"合計",failed:"失敗",partsPrinted:"印刷済みパーツ",printTime:"印刷時間",filamentUsed:"フィラメント使用量",costTracking:"コスト追跡",filamentCost:"フィラメント",energy:"エネルギー",budget:"予算",budgetRemaining:"残り予算",subProjects:"サブプロジェクト ({{count}})",partOf:"所属先",priority:"優先度",notes:"メモ",cancel:"キャンセル",save:"保存",notesPlaceholder:"このプロジェクトについてメモを追加...",noNotesYet:"メモがありません。編集をクリックして追加してください。",files:"ファイル",linkFoldersFromFileManager:"ファイルマネージャーからフォルダーをリンク",toThisProjectForQuickAccess:"してクイックアクセス。",fileCount:"{{count}}ファイル",noFoldersLinked:"リンクされたフォルダーはありません",billOfMaterials:"部品表(BOM)",bomAcquired:"{{completed}}/{{total}} 取得済み",showAll:"すべて表示",hideDone:"完了を非表示",addPart:"パーツを追加",partNamePlaceholder:"パーツ名",qty:"数量",pricePlaceholder:"価格 ({{currency}})",sourcingUrlPlaceholder:"URL(任意)",remarksPlaceholder:"備考",delete:"削除",totalCost:"合計コスト",noBomParts:"BOMにパーツがありません",activityTimeline:"アクティビティタイムライン",noActivityYet:"アクティビティがありません",timelineEvents:{project_created:"プロジェクト作成",print_completed:"印刷完了",print_failed:"印刷失敗",print_started:"印刷開始",queued:"キューに追加"},saveAsTemplate:"テンプレートとして保存",queue:"キュー",viewAll:"すべて表示",printing:"印刷中",queued:"キュー内",prints:"{{count}}件の印刷",exportProject:"プロジェクトをエクスポート",exportFailed:"エクスポートに失敗しました",projectExported:"プロジェクトがエクスポートされました",noEditPermission:"このプロジェクトを編集する権限がありません",noAddPartsPermission:"パーツを追加する権限がありません",noDeletePartsPermission:"パーツを削除する権限がありません",noEditPartsPermission:"パーツを編集する権限がありません",noUpdatePartsPermission:"パーツを更新する権限がありません",noEditNotesPermission:"ノートを編集する権限がありません",noCreateTemplatesPermission:"テンプレートを作成する権限がありません",noExportPermission:"プロジェクトをエクスポートする権限がありません"},projectPage:{title:"プロジェクトページ",loadFailed:"プロジェクトページデータの読み込みに失敗",noData:"プロジェクトページデータがありません",noDataHint:"このプロジェクトにはMakerWorldページデータがありません",titleField:"タイトル",designer:"デザイナー",license:"ライセンス",description:"説明",descriptionPlaceholder:"プロジェクトの説明...",printProfile:"印刷プロファイル",profileTitle:"プロファイルタイトル",profileDescriptionPlaceholder:"プロファイルの説明",byUser:"{{name}} 作",images:"画像 ({{count}})",viewOnMakerWorld:"MakerWorldで表示"},batchProject:{addedToProject:"{{count}}件のアーカイブを「{{project}}」に追加しました",assignFailed:"プロジェクトへのアーカイブ割り当てに失敗しました",removedFromProject:"{{count}}件のアーカイブをプロジェクトから削除しました",removeFailed:"プロジェクトからのアーカイブ削除に失敗しました",assignTitle:"プロジェクトに割り当て",assignDescription:"{{count}}件の選択されたアーカイブのプロジェクトを選択:",removeFromProject:"プロジェクトから削除",clearAssignment:"選択されたアーカイブのプロジェクト割り当てを解除",orAssignTo:"または割り当て先:",archiveCount:"{{count}}件のアーカイブ",noProjects:"プロジェクトがありません。先にプロジェクトを作成してください。"},richTextEditor:{bold:"太字",italic:"斜体",underline:"下線",bulletList:"箇条書き",numberedList:"番号付きリスト",alignLeft:"左揃え",alignCenter:"中央揃え",alignRight:"右揃え",addLink:"リンクを追加",removeLink:"リンクを削除"},kProfiles:{editProfile:"K-プロファイルを編集",addProfile:"K-プロファイルを追加",hasNote:"メモあり",copyProfile:"プロファイルをコピー",profileNamePlaceholder:"マイPLAプロファイル",notesPlaceholder:"このプロファイルのメモを追加...",searchPlaceholder:"名前またはフィラメントで検索...",exportToJson:"JSONにエクスポート",importFromJson:"JSONからインポート",selectAllVisible:"表示中のプロファイルをすべて選択",enterSelectionMode:"一括削除の選択モードに入る",unnamed:"名前なし",notePrefix:"メモ: ",profileName:"プロファイル名",kValue:"K値",kValueRange:"一般的な範囲: PLA 0.01 - 0.06、PETG 0.02 - 0.10",filament:"フィラメント",selectFilament:"フィラメントを選択...",noFilamentsFound:"フィラメントが見つかりません。まずBambu StudioでKプロファイルを作成してください。",flowType:"フロータイプ",highFlow:"ハイフロー",standard:"スタンダード",nozzleSize:"ノズルサイズ",extruder:"エクストルーダー",extruders:"エクストルーダー",left:"左",right:"右",notesStoredLocally:"メモ(ローカル保存)",notesHint:"メモはBambuddyに保存され、プリンターには保存されません",deleteProfileTitle:"プロファイルを削除",cannotBeUndone:"この操作は元に戻せません",confirmDeleteProfile:'"{{name}}"をプリンターから削除してもよろしいですか?',profileSaved:"Kプロファイルを保存しました",profileDeleted:"Kプロファイルを削除しました",selectExtruder:"エクストルーダーを少なくとも1つ選択してください",profileSavedToExtruders:"Kプロファイルを{{count}}個のエクストルーダーに保存しました",failedToSave:"Kプロファイルの保存に失敗しました",syncingWithPrinter:"プリンターと同期中...",pleaseWait:"お待ちください",savingToExtruder:"エクストルーダー {{current}}/{{total}} に保存中...",noPrintersConfigured:"プリンターが設定されていません",addPrinterHint:"設定でプリンターを追加してKプロファイルを管理",noActivePrinters:"アクティブなプリンターがありません",enablePrinterHint:"プリンター接続を有効にしてKプロファイルを表示",loadingProfiles:"Kプロファイルを読み込み中...",nozzle:"ノズル",allExtruders:"すべてのエクストルーダー",leftOnly:"左のみ",rightOnly:"右のみ",allFlow:"すべてのフロー",hfOnly:"HFのみ",sOnly:"Sのみ",sortName:"ソート: 名前",sortKValue:"ソート: K値",sortFilament:"ソート: フィラメント",selectAll:"すべて選択",select:"選択",printerOffline:"プリンターオフライン",printerOfflineHint:"プリンターが接続されていません。電源を入れてKプロファイルを表示してください。",leftExtruder:"左エクストルーダー",rightExtruder:"右エクストルーダー",noMatchingProfiles:"一致するプロファイルなし",noProfilesMatch:"検索条件に一致するプロファイルがありません",noKProfiles:"Kプロファイルなし",noProfilesForNozzle:"{{diameter}}mmノズルの圧力キャリブレーションプロファイルが見つかりません",createFirstProfile:"最初のプロファイルを作成",deleteProfiles:"プロファイルを削除",confirmBulkDelete:"{{count}}件の選択されたプロファイルをプリンターから削除してもよろしいですか?",noProfilesToExport:"エクスポートするプロファイルがありません",exportedProfiles:"{{count}}件のプロファイルをエクスポートしました",invalidFileFormat:"無効なファイル形式",importedProfiles:"{{total}}件中{{imported}}件のプロファイルをインポートしました",failedToParseImport:"インポートファイルの解析に失敗しました",deletedProfiles:"{{count}}件のプロファイルを削除しました",failedToSaveNote:"メモの保存に失敗しました",noPermissionAdd:"K-プロファイルを追加する権限がありません",noPermissionDelete:"K-プロファイルを削除する権限がありません",noPermissionDeleteBulk:"K-プロファイルを一括削除する権限がありません",noPermissionExport:"K-プロファイルをエクスポートする権限がありません",noPermissionImport:"K-プロファイルをインポートする権限がありません",noPermissionRefresh:"K-プロファイルを更新する権限がありません"},apiBrowser:{validationError:"バリデーションエラー",missingRequiredParams:"必須パラメーターが不足: {{params}}",networkError:"ネットワークエラー",pathParameters:"パスパラメーター",queryParameters:"クエリパラメーター",selectOption:"-- 選択 --",requestBody:"リクエストボディ",execute:"実行",fillInRequired:"入力してください: {{params}}",response:"レスポンス",failedToFetchSchema:"OpenAPIスキーマの取得に失敗しました",failedToLoadSchema:"APIスキーマの読み込みに失敗しました",otherCategory:"その他",expandAll:"すべて展開",collapseAll:"すべて折りたたむ",swaggerUI:"Swagger UI",endpointCount:"{{categories}}カテゴリー内{{count}}エンドポイント"},githubBackup:{title:"GitHubバックアップ",enabled:"有効",cloudLoginRequired:"Bambu Cloudのログインが必要です。プロファイル → クラウドプロファイルからサインインしてGitHubバックアップを有効にしてください。",description:"プロファイルをプライベートGitHubリポジトリに自動同期し、バックアップとバージョン履歴を管理します。",repositoryUrl:"リポジトリURL",personalAccessToken:"パーソナルアクセストークン",saved:"保存済み",enterNewToken:"新しいトークンを入力して更新",tokenHint:"Contents読み取り/書き込み権限を持つFine-grainedトークン",branch:"ブランチ",autoBackup:"自動バックアップ",manualOnly:"手動のみ",hourly:"毎時",daily:"毎日",weekly:"毎週",includeInBackup:"バックアップに含める",kProfiles:"Kプロファイル",noPrintersConnected:"プリンター未接続",printersConnected:"{{connected}}/{{total}} 接続中",kProfilesDescription:"接続されたプリンターからの圧力前進キャリブレーション",cloudProfiles:"クラウドプロファイル",cloudProfilesDescription:"Bambu Cloudのフィラメント、プリンター、プロセスプリセット",appSettings:"アプリ設定",appSettingsDescription:"Bambuddyの設定(機密データを除く)",lastBackup:"最終バックアップ",noBackupsYet:"バックアップなし",next:"次回",startingBackup:"バックアップ開始中...",backupNow:"今すぐバックアップ",test:"テスト",enableBackup:"バックアップを有効化",testConnection:"接続テスト",history:"履歴",date:"日付",status:"ステータス",commit:"コミット",localBackup:"ローカルバックアップ",localDescription:"Bambuddyデータをローカルファイルとしてエクスポートまたはインポートし、手動バックアップや移行に利用できます。",exportData:"データエクスポート",exportDescription:"すべての設定、プリンター、プロファイルをダウンロード",importBackup:"バックアップのインポート",importDescription:"以前のエクスポートファイルから復元",tokenUpdated:"トークンを更新しました",settingsSaved:"設定を保存しました",failedToSave:"保存に失敗しました: {{error}}",backupEnabled:"GitHubバックアップを有効にしました",backupComplete:"バックアップ完了 - {{count}}ファイル更新",backupSkipped:"バックアップをスキップ - 変更なし",backupFailed:"バックアップに失敗しました: {{error}}",logsCleared:"{{count}}件のログを削除しました",failedToClearLogs:"ログの削除に失敗しました: {{error}}",enterRepoUrl:"リポジトリURLを入力してください",enterRepoUrlAndToken:"リポジトリURLとアクセストークンを入力してください",repoUrlRequired:"リポジトリURLは必須です",tokenRequired:"アクセストークンは必須です",backupDownloaded:"バックアップのダウンロードが完了しました",failedToCreateBackup:"バックアップの作成に失敗しました",backupRestored:"バックアップの復元が完了しました"}},Hse={en:{translation:Use},de:{translation:zse},ja:{translation:Bse}};_s.use(Aq).use(xse).init({resources:Hse,fallbackLng:"en",supportedLngs:["en","de","ja"],detection:{order:["localStorage","navigator","htmlTag"],lookupLocalStorage:"bambutrack_language",caches:["localStorage"]},interpolation:{escapeValue:!1},react:{useSuspense:!1}});const mz=[{code:"en",name:"English",nativeName:"English"},{code:"de",name:"German",nativeName:"Deutsch"},{code:"ja",name:"Japanese",nativeName:"日本語"}];var pz="popstate";function $se(t={}){function e(r,i){let{pathname:a,search:o,hash:l}=r.location;return eP("",{pathname:a,search:o,hash:l},i.state&&i.state.usr||null,i.state&&i.state.key||"default")}function n(r,i){return typeof i=="string"?i:H0(i)}return Gse(e,n,null,t)}function ni(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function bo(t,e){if(!t){typeof console<"u"&&console.warn(e);try{throw new Error(e)}catch{}}}function Vse(){return Math.random().toString(36).substring(2,10)}function gz(t,e){return{usr:t.state,key:t.key,idx:e}}function eP(t,e,n=null,r){return{pathname:typeof t=="string"?t:t.pathname,search:"",hash:"",...typeof e=="string"?gx(e):e,state:n,key:e&&e.key||r||Vse()}}function H0({pathname:t="/",search:e="",hash:n=""}){return e&&e!=="?"&&(t+=e.charAt(0)==="?"?e:"?"+e),n&&n!=="#"&&(t+=n.charAt(0)==="#"?n:"#"+n),t}function gx(t){let e={};if(t){let n=t.indexOf("#");n>=0&&(e.hash=t.substring(n),t=t.substring(0,n));let r=t.indexOf("?");r>=0&&(e.search=t.substring(r),t=t.substring(0,r)),t&&(e.pathname=t)}return e}function Gse(t,e,n,r={}){let{window:i=document.defaultView,v5Compat:a=!1}=r,o=i.history,l="POP",c=null,u=d();u==null&&(u=0,o.replaceState({...o.state,idx:u},""));function d(){return(o.state||{idx:null}).idx}function f(){l="POP";let y=d(),v=y==null?null:y-u;u=y,c&&c({action:l,location:b.location,delta:v})}function p(y,v){l="PUSH";let S=eP(b.location,y,v);u=d()+1;let N=gz(S,u),T=b.createHref(S);try{o.pushState(N,"",T)}catch(k){if(k instanceof DOMException&&k.name==="DataCloneError")throw k;i.location.assign(T)}a&&c&&c({action:l,location:b.location,delta:1})}function m(y,v){l="REPLACE";let S=eP(b.location,y,v);u=d();let N=gz(S,u),T=b.createHref(S);o.replaceState(N,"",T),a&&c&&c({action:l,location:b.location,delta:0})}function x(y){return qse(y)}let b={get action(){return l},get location(){return t(i,o)},listen(y){if(c)throw new Error("A history only accepts one active listener");return i.addEventListener(pz,f),c=y,()=>{i.removeEventListener(pz,f),c=null}},createHref(y){return e(i,y)},createURL:x,encodeLocation(y){let v=x(y);return{pathname:v.pathname,search:v.search,hash:v.hash}},push:p,replace:m,go(y){return o.go(y)}};return b}function qse(t,e=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),ni(n,"No window.location.(origin|href) available to create URL");let r=typeof t=="string"?t:H0(t);return r=r.replace(/ $/,"%20"),!e&&r.startsWith("//")&&(r=n+r),new URL(r,n)}function Cq(t,e,n="/"){return Wse(t,e,n,!1)}function Wse(t,e,n,r){let i=typeof e=="string"?gx(e):e,a=Du(i.pathname||"/",n);if(a==null)return null;let o=jq(t);Kse(o);let l=null;for(let c=0;l==null&&c<o.length;++c){let u=aoe(a);l=roe(o[c],u,r)}return l}function jq(t,e=[],n=[],r="",i=!1){let a=(o,l,c=i,u)=>{let d={relativePath:u===void 0?o.path||"":u,caseSensitive:o.caseSensitive===!0,childrenIndex:l,route:o};if(d.relativePath.startsWith("/")){if(!d.relativePath.startsWith(r)&&c)return;ni(d.relativePath.startsWith(r),`Absolute route path "${d.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),d.relativePath=d.relativePath.slice(r.length)}let f=Mu([r,d.relativePath]),p=n.concat(d);o.children&&o.children.length>0&&(ni(o.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${f}".`),jq(o.children,e,p,f,c)),!(o.path==null&&!o.index)&&e.push({path:f,score:toe(f,o.index),routesMeta:p})};return t.forEach((o,l)=>{if(o.path===""||!o.path?.includes("?"))a(o,l);else for(let c of Pq(o.path))a(o,l,!0,c)}),e}function Pq(t){let e=t.split("/");if(e.length===0)return[];let[n,...r]=e,i=n.endsWith("?"),a=n.replace(/\?$/,"");if(r.length===0)return i?[a,""]:[a];let o=Pq(r.join("/")),l=[];return l.push(...o.map(c=>c===""?a:[a,c].join("/"))),i&&l.push(...o),l.map(c=>t.startsWith("/")&&c===""?"/":c)}function Kse(t){t.sort((e,n)=>e.score!==n.score?n.score-e.score:noe(e.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var Xse=/^:[\w-]+$/,Yse=3,Qse=2,Zse=1,Jse=10,eoe=-2,xz=t=>t==="*";function toe(t,e){let n=t.split("/"),r=n.length;return n.some(xz)&&(r+=eoe),e&&(r+=Qse),n.filter(i=>!xz(i)).reduce((i,a)=>i+(Xse.test(a)?Yse:a===""?Zse:Jse),r)}function noe(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 roe(t,e,n=!1){let{routesMeta:r}=t,i={},a="/",o=[];for(let l=0;l<r.length;++l){let c=r[l],u=l===r.length-1,d=a==="/"?e:e.slice(a.length)||"/",f=H1({path:c.relativePath,caseSensitive:c.caseSensitive,end:u},d),p=c.route;if(!f&&u&&n&&!r[r.length-1].route.index&&(f=H1({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},d)),!f)return null;Object.assign(i,f.params),o.push({params:i,pathname:Mu([a,f.pathname]),pathnameBase:coe(Mu([a,f.pathnameBase])),route:p}),f.pathnameBase!=="/"&&(a=Mu([a,f.pathnameBase]))}return o}function H1(t,e){typeof t=="string"&&(t={path:t,caseSensitive:!1,end:!0});let[n,r]=ioe(t.path,t.caseSensitive,t.end),i=e.match(n);if(!i)return null;let a=i[0],o=a.replace(/(.)\/+$/,"$1"),l=i.slice(1);return{params:r.reduce((u,{paramName:d,isOptional:f},p)=>{if(d==="*"){let x=l[p]||"";o=a.slice(0,a.length-x.length).replace(/(.)\/+$/,"$1")}const m=l[p];return f&&!m?u[d]=void 0:u[d]=(m||"").replace(/%2F/g,"/"),u},{}),pathname:a,pathnameBase:o,pattern:t}}function ioe(t,e=!1,n=!0){bo(t==="*"||!t.endsWith("*")||t.endsWith("/*"),`Route path "${t}" will be treated as if it were "${t.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${t.replace(/\*$/,"/*")}".`);let r=[],i="^"+t.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(o,l,c)=>(r.push({paramName:l,isOptional:c!=null}),c?"/?([^\\/]+)?":"/([^\\/]+)")).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return t.endsWith("*")?(r.push({paramName:"*"}),i+=t==="*"||t==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?i+="\\/*$":t!==""&&t!=="/"&&(i+="(?:(?=\\/|$))"),[new RegExp(i,e?void 0:"i"),r]}function aoe(t){try{return t.split("/").map(e=>decodeURIComponent(e).replace(/\//g,"%2F")).join("/")}catch(e){return bo(!1,`The URL path "${t}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${e}).`),t}}function Du(t,e){if(e==="/")return t;if(!t.toLowerCase().startsWith(e.toLowerCase()))return null;let n=e.endsWith("/")?e.length-1:e.length,r=t.charAt(n);return r&&r!=="/"?null:t.slice(n)||"/"}var Dq=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,soe=t=>Dq.test(t);function ooe(t,e="/"){let{pathname:n,search:r="",hash:i=""}=typeof t=="string"?gx(t):t,a;if(n)if(soe(n))a=n;else{if(n.includes("//")){let o=n;n=n.replace(/\/\/+/g,"/"),bo(!1,`Pathnames cannot have embedded double slashes - normalizing ${o} -> ${n}`)}n.startsWith("/")?a=bz(n.substring(1),"/"):a=bz(n,e)}else a=e;return{pathname:a,search:uoe(r),hash:doe(i)}}function bz(t,e){let n=e.replace(/\/+$/,"").split("/");return t.split("/").forEach(i=>{i===".."?n.length>1&&n.pop():i!=="."&&n.push(i)}),n.length>1?n.join("/"):"/"}function YE(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 loe(t){return t.filter((e,n)=>n===0||e.route.path&&e.route.path.length>0)}function mR(t){let e=loe(t);return e.map((n,r)=>r===e.length-1?n.pathname:n.pathnameBase)}function pR(t,e,n,r=!1){let i;typeof t=="string"?i=gx(t):(i={...t},ni(!i.pathname||!i.pathname.includes("?"),YE("?","pathname","search",i)),ni(!i.pathname||!i.pathname.includes("#"),YE("#","pathname","hash",i)),ni(!i.search||!i.search.includes("#"),YE("#","search","hash",i)));let a=t===""||i.pathname==="",o=a?"/":i.pathname,l;if(o==null)l=n;else{let f=e.length-1;if(!r&&o.startsWith("..")){let p=o.split("/");for(;p[0]==="..";)p.shift(),f-=1;i.pathname=p.join("/")}l=f>=0?e[f]:"/"}let c=ooe(i,l),u=o&&o!=="/"&&o.endsWith("/"),d=(a||o===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(u||d)&&(c.pathname+="/"),c}var Mu=t=>t.join("/").replace(/\/\/+/g,"/"),coe=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),uoe=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,doe=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t,hoe=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 foe(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}function moe(t){return t.map(e=>e.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var Rq=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Oq(t,e){let n=t;if(typeof n!="string"||!Dq.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,i=!1;if(Rq)try{let a=new URL(window.location.href),o=n.startsWith("//")?new URL(a.protocol+n):new URL(n),l=Du(o.pathname,e);o.origin===a.origin&&l!=null?n=l+o.search+o.hash:i=!0}catch{bo(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:r,isExternal:i,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var Lq=["POST","PUT","PATCH","DELETE"];new Set(Lq);var poe=["GET",...Lq];new Set(poe);var xx=_.createContext(null);xx.displayName="DataRouter";var nN=_.createContext(null);nN.displayName="DataRouterState";var goe=_.createContext(!1),Fq=_.createContext({isTransitioning:!1});Fq.displayName="ViewTransition";var xoe=_.createContext(new Map);xoe.displayName="Fetchers";var boe=_.createContext(null);boe.displayName="Await";var wo=_.createContext(null);wo.displayName="Navigation";var Oy=_.createContext(null);Oy.displayName="Location";var fl=_.createContext({outlet:null,matches:[],isDataRoute:!1});fl.displayName="Route";var gR=_.createContext(null);gR.displayName="RouteError";var Iq="REACT_ROUTER_ERROR",yoe="REDIRECT",voe="ROUTE_ERROR_RESPONSE";function woe(t){if(t.startsWith(`${Iq}:${yoe}:{`))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 _oe(t){if(t.startsWith(`${Iq}:${voe}:{`))try{let e=JSON.parse(t.slice(40));if(typeof e=="object"&&e&&typeof e.status=="number"&&typeof e.statusText=="string")return new hoe(e.status,e.statusText,e.data)}catch{}}function Soe(t,{relative:e}={}){ni(bx(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:r}=_.useContext(wo),{hash:i,pathname:a,search:o}=Ly(t,{relative:e}),l=a;return n!=="/"&&(l=a==="/"?n:Mu([n,a])),r.createHref({pathname:l,search:o,hash:i})}function bx(){return _.useContext(Oy)!=null}function Mc(){return ni(bx(),"useLocation() may be used only in the context of a <Router> component."),_.useContext(Oy).location}var Uq="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function zq(t){_.useContext(wo).static||_.useLayoutEffect(t)}function Nc(){let{isDataRoute:t}=_.useContext(fl);return t?Ioe():Moe()}function Moe(){ni(bx(),"useNavigate() may be used only in the context of a <Router> component.");let t=_.useContext(xx),{basename:e,navigator:n}=_.useContext(wo),{matches:r}=_.useContext(fl),{pathname:i}=Mc(),a=JSON.stringify(mR(r)),o=_.useRef(!1);return zq(()=>{o.current=!0}),_.useCallback((c,u={})=>{if(bo(o.current,Uq),!o.current)return;if(typeof c=="number"){n.go(c);return}let d=pR(c,JSON.parse(a),i,u.relative==="path");t==null&&e!=="/"&&(d.pathname=d.pathname==="/"?e:Mu([e,d.pathname])),(u.replace?n.replace:n.push)(d,u.state,u)},[e,n,a,i,t])}var Noe=_.createContext(null);function koe(t){let e=_.useContext(fl).outlet;return _.useMemo(()=>e&&_.createElement(Noe.Provider,{value:t},e),[e,t])}function rN(){let{matches:t}=_.useContext(fl),e=t[t.length-1];return e?e.params:{}}function Ly(t,{relative:e}={}){let{matches:n}=_.useContext(fl),{pathname:r}=Mc(),i=JSON.stringify(mR(n));return _.useMemo(()=>pR(t,JSON.parse(i),r,e==="path"),[t,i,r,e])}function Eoe(t,e){return Bq(t,e)}function Bq(t,e,n,r,i){ni(bx(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:a}=_.useContext(wo),{matches:o}=_.useContext(fl),l=o[o.length-1],c=l?l.params:{},u=l?l.pathname:"/",d=l?l.pathnameBase:"/",f=l&&l.route;{let S=f&&f.path||"";$q(u,!f||S.endsWith("*")||S.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${u}" (under <Route path="${S}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
- Please change the parent <Route path="${S}"> to <Route path="${S==="/"?"*":`${S}/*`}">.`)}let p=Mc(),m;if(e){let S=typeof e=="string"?gx(e):e;ni(d==="/"||S.pathname?.startsWith(d),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${d}" but pathname "${S.pathname}" was given in the \`location\` prop.`),m=S}else m=p;let x=m.pathname||"/",b=x;if(d!=="/"){let S=d.replace(/^\//,"").split("/");b="/"+x.replace(/^\//,"").split("/").slice(S.length).join("/")}let y=Cq(t,{pathname:b});bo(f||y!=null,`No routes matched location "${m.pathname}${m.search}${m.hash}" `),bo(y==null||y[y.length-1].route.element!==void 0||y[y.length-1].route.Component!==void 0||y[y.length-1].route.lazy!==void 0,`Matched leaf route at location "${m.pathname}${m.search}${m.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let v=Poe(y&&y.map(S=>Object.assign({},S,{params:Object.assign({},c,S.params),pathname:Mu([d,a.encodeLocation?a.encodeLocation(S.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:S.pathname]),pathnameBase:S.pathnameBase==="/"?d:Mu([d,a.encodeLocation?a.encodeLocation(S.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:S.pathnameBase])})),o,n,r,i);return e&&v?_.createElement(Oy.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...m},navigationType:"POP"}},v):v}function Toe(){let t=Foe(),e=foe(t)?`${t.status} ${t.statusText}`:t instanceof Error?t.message:JSON.stringify(t),n=t instanceof Error?t.stack:null,r="rgba(200,200,200, 0.5)",i={padding:"0.5rem",backgroundColor:r},a={padding:"2px 4px",backgroundColor:r},o=null;return console.error("Error handled by React Router default ErrorBoundary:",t),o=_.createElement(_.Fragment,null,_.createElement("p",null,"💿 Hey developer 👋"),_.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",_.createElement("code",{style:a},"ErrorBoundary")," or"," ",_.createElement("code",{style:a},"errorElement")," prop on your route.")),_.createElement(_.Fragment,null,_.createElement("h2",null,"Unexpected Application Error!"),_.createElement("h3",{style:{fontStyle:"italic"}},e),n?_.createElement("pre",{style:i},n):null,o)}var Aoe=_.createElement(Toe,null),Hq=class extends _.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,e){return e.location!==t.location||e.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:e.error,location:e.location,revalidation:t.revalidation||e.revalidation}}componentDidCatch(t,e){this.props.onError?this.props.onError(t,e):console.error("React Router caught the following error during render",t)}render(){let t=this.state.error;if(this.context&&typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){const n=_oe(t.digest);n&&(t=n)}let e=t!==void 0?_.createElement(fl.Provider,{value:this.props.routeContext},_.createElement(gR.Provider,{value:t,children:this.props.component})):this.props.children;return this.context?_.createElement(Coe,{error:t},e):e}};Hq.contextType=goe;var QE=new WeakMap;function Coe({children:t,error:e}){let{basename:n}=_.useContext(wo);if(typeof e=="object"&&e&&"digest"in e&&typeof e.digest=="string"){let r=woe(e.digest);if(r){let i=QE.get(e);if(i)throw i;let a=Oq(r.location,n);if(Rq&&!QE.get(e))if(a.isExternal||r.reloadDocument)window.location.href=a.absoluteURL||a.to;else{const o=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(a.to,{replace:r.replace}));throw QE.set(e,o),o}return _.createElement("meta",{httpEquiv:"refresh",content:`0;url=${a.absoluteURL||a.to}`})}}return t}function joe({routeContext:t,match:e,children:n}){let r=_.useContext(xx);return r&&r.static&&r.staticContext&&(e.route.errorElement||e.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=e.route.id),_.createElement(fl.Provider,{value:t},n)}function Poe(t,e=[],n=null,r=null,i=null){if(t==null){if(!n)return null;if(n.errors)t=n.matches;else if(e.length===0&&!n.initialized&&n.matches.length>0)t=n.matches;else return null}let a=t,o=n?.errors;if(o!=null){let d=a.findIndex(f=>f.route.id&&o?.[f.route.id]!==void 0);ni(d>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(o).join(",")}`),a=a.slice(0,Math.min(a.length,d+1))}let l=!1,c=-1;if(n)for(let d=0;d<a.length;d++){let f=a[d];if((f.route.HydrateFallback||f.route.hydrateFallbackElement)&&(c=d),f.route.id){let{loaderData:p,errors:m}=n,x=f.route.loader&&!p.hasOwnProperty(f.route.id)&&(!m||m[f.route.id]===void 0);if(f.route.lazy||x){l=!0,c>=0?a=a.slice(0,c+1):a=[a[0]];break}}}let u=n&&r?(d,f)=>{r(d,{location:n.location,params:n.matches?.[0]?.params??{},unstable_pattern:moe(n.matches),errorInfo:f})}:void 0;return a.reduceRight((d,f,p)=>{let m,x=!1,b=null,y=null;n&&(m=o&&f.route.id?o[f.route.id]:void 0,b=f.route.errorElement||Aoe,l&&(c<0&&p===0?($q("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),x=!0,y=null):c===p&&(x=!0,y=f.route.hydrateFallbackElement||null)));let v=e.concat(a.slice(0,p+1)),S=()=>{let N;return m?N=b:x?N=y:f.route.Component?N=_.createElement(f.route.Component,null):f.route.element?N=f.route.element:N=d,_.createElement(joe,{match:f,routeContext:{outlet:d,matches:v,isDataRoute:n!=null},children:N})};return n&&(f.route.ErrorBoundary||f.route.errorElement||p===0)?_.createElement(Hq,{location:n.location,revalidation:n.revalidation,component:b,error:m,children:S(),routeContext:{outlet:null,matches:v,isDataRoute:!0},onError:u}):S()},null)}function xR(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Doe(t){let e=_.useContext(xx);return ni(e,xR(t)),e}function Roe(t){let e=_.useContext(nN);return ni(e,xR(t)),e}function Ooe(t){let e=_.useContext(fl);return ni(e,xR(t)),e}function bR(t){let e=Ooe(t),n=e.matches[e.matches.length-1];return ni(n.route.id,`${t} can only be used on routes that contain a unique "id"`),n.route.id}function Loe(){return bR("useRouteId")}function Foe(){let t=_.useContext(gR),e=Roe("useRouteError"),n=bR("useRouteError");return t!==void 0?t:e.errors?.[n]}function Ioe(){let{router:t}=Doe("useNavigate"),e=bR("useNavigate"),n=_.useRef(!1);return zq(()=>{n.current=!0}),_.useCallback(async(i,a={})=>{bo(n.current,Uq),n.current&&(typeof i=="number"?await t.navigate(i):await t.navigate(i,{fromRouteId:e,...a}))},[t,e])}var yz={};function $q(t,e,n){!e&&!yz[t]&&(yz[t]=!0,bo(!1,n))}_.memo(Uoe);function Uoe({routes:t,future:e,state:n,onError:r}){return Bq(t,void 0,n,r,e)}function Fg({to:t,replace:e,state:n,relative:r}){ni(bx(),"<Navigate> may be used only in the context of a <Router> component.");let{static:i}=_.useContext(wo);bo(!i,"<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.");let{matches:a}=_.useContext(fl),{pathname:o}=Mc(),l=Nc(),c=pR(t,mR(a),o,r==="path"),u=JSON.stringify(c);return _.useEffect(()=>{l(JSON.parse(u),{replace:e,state:n,relative:r})},[l,u,r,e,n]),null}function zoe(t){return koe(t.context)}function Li(t){ni(!1,"A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.")}function Boe({basename:t="/",children:e=null,location:n,navigationType:r="POP",navigator:i,static:a=!1,unstable_useTransitions:o}){ni(!bx(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let l=t.replace(/^\/*/,"/"),c=_.useMemo(()=>({basename:l,navigator:i,static:a,unstable_useTransitions:o,future:{}}),[l,i,a,o]);typeof n=="string"&&(n=gx(n));let{pathname:u="/",search:d="",hash:f="",state:p=null,key:m="default"}=n,x=_.useMemo(()=>{let b=Du(u,l);return b==null?null:{location:{pathname:b,search:d,hash:f,state:p,key:m},navigationType:r}},[l,u,d,f,p,m,r]);return bo(x!=null,`<Router basename="${l}"> is not able to match the URL "${u}${d}${f}" because it does not start with the basename, so the <Router> won't render anything.`),x==null?null:_.createElement(wo.Provider,{value:c},_.createElement(Oy.Provider,{children:e,value:x}))}function Hoe({children:t,location:e}){return Eoe(tP(t),e)}function tP(t,e=[]){let n=[];return _.Children.forEach(t,(r,i)=>{if(!_.isValidElement(r))return;let a=[...e,i];if(r.type===_.Fragment){n.push.apply(n,tP(r.props.children,a));return}ni(r.type===Li,`[${typeof r.type=="string"?r.type:r.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),ni(!r.props.index||!r.props.children,"An index route cannot have child routes.");let o={id:r.props.id||a.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,middleware:r.props.middleware,loader:r.props.loader,action:r.props.action,hydrateFallbackElement:r.props.hydrateFallbackElement,HydrateFallback:r.props.HydrateFallback,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.hasErrorBoundary===!0||r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(o.children=tP(r.props.children,a)),n.push(o)}),n}var f1="get",m1="application/x-www-form-urlencoded";function iN(t){return typeof HTMLElement<"u"&&t instanceof HTMLElement}function $oe(t){return iN(t)&&t.tagName.toLowerCase()==="button"}function Voe(t){return iN(t)&&t.tagName.toLowerCase()==="form"}function Goe(t){return iN(t)&&t.tagName.toLowerCase()==="input"}function qoe(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function Woe(t,e){return t.button===0&&(!e||e==="_self")&&!qoe(t)}function nP(t=""){return new URLSearchParams(typeof t=="string"||Array.isArray(t)||t instanceof URLSearchParams?t:Object.keys(t).reduce((e,n)=>{let r=t[n];return e.concat(Array.isArray(r)?r.map(i=>[n,i]):[[n,r]])},[]))}function Koe(t,e){let n=nP(t);return e&&e.forEach((r,i)=>{n.has(i)||e.getAll(i).forEach(a=>{n.append(i,a)})}),n}var jw=null;function Xoe(){if(jw===null)try{new FormData(document.createElement("form"),0),jw=!1}catch{jw=!0}return jw}var Yoe=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function ZE(t){return t!=null&&!Yoe.has(t)?(bo(!1,`"${t}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${m1}"`),null):t}function Qoe(t,e){let n,r,i,a,o;if(Voe(t)){let l=t.getAttribute("action");r=l?Du(l,e):null,n=t.getAttribute("method")||f1,i=ZE(t.getAttribute("enctype"))||m1,a=new FormData(t)}else if($oe(t)||Goe(t)&&(t.type==="submit"||t.type==="image")){let l=t.form;if(l==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let c=t.getAttribute("formaction")||l.getAttribute("action");if(r=c?Du(c,e):null,n=t.getAttribute("formmethod")||l.getAttribute("method")||f1,i=ZE(t.getAttribute("formenctype"))||ZE(l.getAttribute("enctype"))||m1,a=new FormData(l,t),!Xoe()){let{name:u,type:d,value:f}=t;if(d==="image"){let p=u?`${u}.`:"";a.append(`${p}x`,"0"),a.append(`${p}y`,"0")}else u&&a.append(u,f)}}else{if(iN(t))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=f1,r=null,i=m1,o=t}return a&&i==="text/plain"&&(o=a,a=void 0),{action:r,method:n.toLowerCase(),encType:i,formData:a,body:o}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function yR(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function Zoe(t,e,n,r){let i=typeof t=="string"?new URL(t,typeof window>"u"?"server://singlefetch/":window.location.origin):t;return n?i.pathname.endsWith("/")?i.pathname=`${i.pathname}_.${r}`:i.pathname=`${i.pathname}.${r}`:i.pathname==="/"?i.pathname=`_root.${r}`:e&&Du(i.pathname,e)==="/"?i.pathname=`${e.replace(/\/$/,"")}/_root.${r}`:i.pathname=`${i.pathname.replace(/\/$/,"")}.${r}`,i}async function Joe(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 ele(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 tle(t,e,n){let r=await Promise.all(t.map(async i=>{let a=e.routes[i.route.id];if(a){let o=await Joe(a,n);return o.links?o.links():[]}return[]}));return ale(r.flat(1).filter(ele).filter(i=>i.rel==="stylesheet"||i.rel==="preload").map(i=>i.rel==="stylesheet"?{...i,rel:"prefetch",as:"style"}:{...i,rel:"prefetch"}))}function vz(t,e,n,r,i,a){let o=(c,u)=>n[u]?c.route.id!==n[u].route.id:!0,l=(c,u)=>n[u].pathname!==c.pathname||n[u].route.path?.endsWith("*")&&n[u].params["*"]!==c.params["*"];return a==="assets"?e.filter((c,u)=>o(c,u)||l(c,u)):a==="data"?e.filter((c,u)=>{let d=r.routes[c.route.id];if(!d||!d.hasLoader)return!1;if(o(c,u)||l(c,u))return!0;if(c.route.shouldRevalidate){let f=c.route.shouldRevalidate({currentUrl:new URL(i.pathname+i.search+i.hash,window.origin),currentParams:n[0]?.params||{},nextUrl:new URL(t,window.origin),nextParams:c.params,defaultShouldRevalidate:!0});if(typeof f=="boolean")return f}return!0}):[]}function nle(t,e,{includeHydrateFallback:n}={}){return rle(t.map(r=>{let i=e.routes[r.route.id];if(!i)return[];let a=[i.module];return i.clientActionModule&&(a=a.concat(i.clientActionModule)),i.clientLoaderModule&&(a=a.concat(i.clientLoaderModule)),n&&i.hydrateFallbackModule&&(a=a.concat(i.hydrateFallbackModule)),i.imports&&(a=a.concat(i.imports)),a}).flat(1))}function rle(t){return[...new Set(t)]}function ile(t){let e={},n=Object.keys(t).sort();for(let r of n)e[r]=t[r];return e}function ale(t,e){let n=new Set;return new Set(e),t.reduce((r,i)=>{let a=JSON.stringify(ile(i));return n.has(a)||(n.add(a),r.push({key:a,link:i})),r},[])}function Vq(){let t=_.useContext(xx);return yR(t,"You must render this element inside a <DataRouterContext.Provider> element"),t}function sle(){let t=_.useContext(nN);return yR(t,"You must render this element inside a <DataRouterStateContext.Provider> element"),t}var vR=_.createContext(void 0);vR.displayName="FrameworkContext";function Gq(){let t=_.useContext(vR);return yR(t,"You must render this element inside a <HydratedRouter> element"),t}function ole(t,e){let n=_.useContext(vR),[r,i]=_.useState(!1),[a,o]=_.useState(!1),{onFocus:l,onBlur:c,onMouseEnter:u,onMouseLeave:d,onTouchStart:f}=e,p=_.useRef(null);_.useEffect(()=>{if(t==="render"&&o(!0),t==="viewport"){let b=v=>{v.forEach(S=>{o(S.isIntersecting)})},y=new IntersectionObserver(b,{threshold:.5});return p.current&&y.observe(p.current),()=>{y.disconnect()}}},[t]),_.useEffect(()=>{if(r){let b=setTimeout(()=>{o(!0)},100);return()=>{clearTimeout(b)}}},[r]);let m=()=>{i(!0)},x=()=>{i(!1),o(!1)};return n?t!=="intent"?[a,p,{}]:[a,p,{onFocus:Cb(l,m),onBlur:Cb(c,x),onMouseEnter:Cb(u,m),onMouseLeave:Cb(d,x),onTouchStart:Cb(f,m)}]:[!1,p,{}]}function Cb(t,e){return n=>{t&&t(n),n.defaultPrevented||e(n)}}function lle({page:t,...e}){let{router:n}=Vq(),r=_.useMemo(()=>Cq(n.routes,t,n.basename),[n.routes,t,n.basename]);return r?_.createElement(ule,{page:t,matches:r,...e}):null}function cle(t){let{manifest:e,routeModules:n}=Gq(),[r,i]=_.useState([]);return _.useEffect(()=>{let a=!1;return tle(t,e,n).then(o=>{a||i(o)}),()=>{a=!0}},[t,e,n]),r}function ule({page:t,matches:e,...n}){let r=Mc(),{future:i,manifest:a,routeModules:o}=Gq(),{basename:l}=Vq(),{loaderData:c,matches:u}=sle(),d=_.useMemo(()=>vz(t,e,u,a,r,"data"),[t,e,u,a,r]),f=_.useMemo(()=>vz(t,e,u,a,r,"assets"),[t,e,u,a,r]),p=_.useMemo(()=>{if(t===r.pathname+r.search+r.hash)return[];let b=new Set,y=!1;if(e.forEach(S=>{let N=a.routes[S.route.id];!N||!N.hasLoader||(!d.some(T=>T.route.id===S.route.id)&&S.route.id in c&&o[S.route.id]?.shouldRevalidate||N.hasClientLoader?y=!0:b.add(S.route.id))}),b.size===0)return[];let v=Zoe(t,l,i.unstable_trailingSlashAwareDataRequests,"data");return y&&b.size>0&&v.searchParams.set("_routes",e.filter(S=>b.has(S.route.id)).map(S=>S.route.id).join(",")),[v.pathname+v.search]},[l,i.unstable_trailingSlashAwareDataRequests,c,r,a,d,e,t,o]),m=_.useMemo(()=>nle(f,a),[f,a]),x=cle(f);return _.createElement(_.Fragment,null,p.map(b=>_.createElement("link",{key:b,rel:"prefetch",as:"fetch",href:b,...n})),m.map(b=>_.createElement("link",{key:b,rel:"modulepreload",href:b,...n})),x.map(({key:b,link:y})=>_.createElement("link",{key:b,nonce:n.nonce,...y})))}function dle(...t){return e=>{t.forEach(n=>{typeof n=="function"?n(e):n!=null&&(n.current=e)})}}var hle=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{hle&&(window.__reactRouterVersion="7.12.0")}catch{}function fle({basename:t,children:e,unstable_useTransitions:n,window:r}){let i=_.useRef();i.current==null&&(i.current=$se({window:r,v5Compat:!0}));let a=i.current,[o,l]=_.useState({action:a.action,location:a.location}),c=_.useCallback(u=>{n===!1?l(u):_.startTransition(()=>l(u))},[n]);return _.useLayoutEffect(()=>a.listen(c),[a,c]),_.createElement(Boe,{basename:t,children:e,location:o.location,navigationType:o.action,navigator:a,unstable_useTransitions:n})}var qq=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Ds=_.forwardRef(function({onClick:e,discover:n="render",prefetch:r="none",relative:i,reloadDocument:a,replace:o,state:l,target:c,to:u,preventScrollReset:d,viewTransition:f,unstable_defaultShouldRevalidate:p,...m},x){let{basename:b,unstable_useTransitions:y}=_.useContext(wo),v=typeof u=="string"&&qq.test(u),S=Oq(u,b);u=S.to;let N=Soe(u,{relative:i}),[T,k,C]=ole(r,m),E=gle(u,{replace:o,state:l,target:c,preventScrollReset:d,relative:i,viewTransition:f,unstable_defaultShouldRevalidate:p,unstable_useTransitions:y});function D(R){e&&e(R),R.defaultPrevented||E(R)}let A=_.createElement("a",{...m,...C,href:S.absoluteURL||N,onClick:S.isExternal||a?e:D,ref:dle(x,k),target:c,"data-discover":!v&&n==="render"?"true":void 0});return T&&!v?_.createElement(_.Fragment,null,A,_.createElement(lle,{page:N})):A});Ds.displayName="Link";var n0=_.forwardRef(function({"aria-current":e="page",caseSensitive:n=!1,className:r="",end:i=!1,style:a,to:o,viewTransition:l,children:c,...u},d){let f=Ly(o,{relative:u.relative}),p=Mc(),m=_.useContext(nN),{navigator:x,basename:b}=_.useContext(wo),y=m!=null&&wle(f)&&l===!0,v=x.encodeLocation?x.encodeLocation(f).pathname:f.pathname,S=p.pathname,N=m&&m.navigation&&m.navigation.location?m.navigation.location.pathname:null;n||(S=S.toLowerCase(),N=N?N.toLowerCase():null,v=v.toLowerCase()),N&&b&&(N=Du(N,b)||N);const T=v!=="/"&&v.endsWith("/")?v.length-1:v.length;let k=S===v||!i&&S.startsWith(v)&&S.charAt(T)==="/",C=N!=null&&(N===v||!i&&N.startsWith(v)&&N.charAt(v.length)==="/"),E={isActive:k,isPending:C,isTransitioning:y},D=k?e:void 0,A;typeof r=="function"?A=r(E):A=[r,k?"active":null,C?"pending":null,y?"transitioning":null].filter(Boolean).join(" ");let R=typeof a=="function"?a(E):a;return _.createElement(Ds,{...u,"aria-current":D,className:A,ref:d,style:R,to:o,viewTransition:l},typeof c=="function"?c(E):c)});n0.displayName="NavLink";var mle=_.forwardRef(({discover:t="render",fetcherKey:e,navigate:n,reloadDocument:r,replace:i,state:a,method:o=f1,action:l,onSubmit:c,relative:u,preventScrollReset:d,viewTransition:f,unstable_defaultShouldRevalidate:p,...m},x)=>{let{unstable_useTransitions:b}=_.useContext(wo),y=yle(),v=vle(l,{relative:u}),S=o.toLowerCase()==="get"?"get":"post",N=typeof l=="string"&&qq.test(l),T=k=>{if(c&&c(k),k.defaultPrevented)return;k.preventDefault();let C=k.nativeEvent.submitter,E=C?.getAttribute("formmethod")||o,D=()=>y(C||k.currentTarget,{fetcherKey:e,method:E,navigate:n,replace:i,state:a,relative:u,preventScrollReset:d,viewTransition:f,unstable_defaultShouldRevalidate:p});b&&n!==!1?_.startTransition(()=>D()):D()};return _.createElement("form",{ref:x,method:S,action:v,onSubmit:r?c:T,...m,"data-discover":!N&&t==="render"?"true":void 0})});mle.displayName="Form";function ple(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Wq(t){let e=_.useContext(xx);return ni(e,ple(t)),e}function gle(t,{target:e,replace:n,state:r,preventScrollReset:i,relative:a,viewTransition:o,unstable_defaultShouldRevalidate:l,unstable_useTransitions:c}={}){let u=Nc(),d=Mc(),f=Ly(t,{relative:a});return _.useCallback(p=>{if(Woe(p,e)){p.preventDefault();let m=n!==void 0?n:H0(d)===H0(f),x=()=>u(t,{replace:m,state:r,preventScrollReset:i,relative:a,viewTransition:o,unstable_defaultShouldRevalidate:l});c?_.startTransition(()=>x()):x()}},[d,u,f,n,r,e,t,i,a,o,l,c])}function wR(t){bo(typeof URLSearchParams<"u","You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.");let e=_.useRef(nP(t)),n=_.useRef(!1),r=Mc(),i=_.useMemo(()=>Koe(r.search,n.current?null:e.current),[r.search]),a=Nc(),o=_.useCallback((l,c)=>{const u=nP(typeof l=="function"?l(new URLSearchParams(i)):l);n.current=!0,a("?"+u,c)},[a,i]);return[i,o]}var xle=0,ble=()=>`__${String(++xle)}__`;function yle(){let{router:t}=Wq("useSubmit"),{basename:e}=_.useContext(wo),n=Loe(),r=t.fetch,i=t.navigate;return _.useCallback(async(a,o={})=>{let{action:l,method:c,encType:u,formData:d,body:f}=Qoe(a,e);if(o.navigate===!1){let p=o.fetcherKey||ble();await r(p,n,o.action||l,{unstable_defaultShouldRevalidate:o.unstable_defaultShouldRevalidate,preventScrollReset:o.preventScrollReset,formData:d,body:f,formMethod:o.method||c,formEncType:o.encType||u,flushSync:o.flushSync})}else await i(o.action||l,{unstable_defaultShouldRevalidate:o.unstable_defaultShouldRevalidate,preventScrollReset:o.preventScrollReset,formData:d,body:f,formMethod:o.method||c,formEncType:o.encType||u,replace:o.replace,state:o.state,fromRouteId:n,flushSync:o.flushSync,viewTransition:o.viewTransition})},[r,i,e,n])}function vle(t,{relative:e}={}){let{basename:n}=_.useContext(wo),r=_.useContext(fl);ni(r,"useFormAction must be used inside a RouteContext");let[i]=r.matches.slice(-1),a={...Ly(t||".",{relative:e})},o=Mc();if(t==null){a.search=o.search;let l=new URLSearchParams(a.search),c=l.getAll("index");if(c.some(d=>d==="")){l.delete("index"),c.filter(f=>f).forEach(f=>l.append("index",f));let d=l.toString();a.search=d?`?${d}`:""}}return(!t||t===".")&&i.route.index&&(a.search=a.search?a.search.replace(/^\?/,"?index&"):"?index"),n!=="/"&&(a.pathname=a.pathname==="/"?n:Mu([n,a.pathname])),H0(a)}function wle(t,{relative:e}={}){let n=_.useContext(Fq);ni(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=Wq("useViewTransitionState"),i=Ly(t,{relative:e});if(!n.isTransitioning)return!1;let a=Du(n.currentLocation.pathname,r)||n.currentLocation.pathname,o=Du(n.nextLocation.pathname,r)||n.nextLocation.pathname;return H1(i.pathname,o)!=null||H1(i.pathname,a)!=null}var gu=yq();const _le=hl(gu);var km=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(){}},Sle={setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},Mle=class{#t=Sle;#e=!1;setTimeoutProvider(t){this.#t=t}setTimeout(t,e){return this.#t.setTimeout(t,e)}clearTimeout(t){this.#t.clearTimeout(t)}setInterval(t,e){return this.#t.setInterval(t,e)}clearInterval(t){this.#t.clearInterval(t)}},jf=new Mle;function Nle(t){setTimeout(t,0)}var tm=typeof window>"u"||"Deno"in globalThis;function Ya(){}function kle(t,e){return typeof t=="function"?t(e):t}function rP(t){return typeof t=="number"&&t>=0&&t!==1/0}function Kq(t,e){return Math.max(t+(e||0)-Date.now(),0)}function rh(t,e){return typeof t=="function"?t(e):t}function Ho(t,e){return typeof t=="function"?t(e):t}function wz(t,e){const{type:n="all",exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:l}=t;if(o){if(r){if(e.queryHash!==_R(o,e.options))return!1}else if(!$0(e.queryKey,o))return!1}if(n!=="all"){const c=e.isActive();if(n==="active"&&!c||n==="inactive"&&c)return!1}return!(typeof l=="boolean"&&e.isStale()!==l||i&&i!==e.state.fetchStatus||a&&!a(e))}function _z(t,e){const{exact:n,status:r,predicate:i,mutationKey:a}=t;if(a){if(!e.options.mutationKey)return!1;if(n){if(nm(e.options.mutationKey)!==nm(a))return!1}else if(!$0(e.options.mutationKey,a))return!1}return!(r&&e.state.status!==r||i&&!i(e))}function _R(t,e){return(e?.queryKeyHashFn||nm)(t)}function nm(t){return JSON.stringify(t,(e,n)=>iP(n)?Object.keys(n).sort().reduce((r,i)=>(r[i]=n[i],r),{}):n)}function $0(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?Object.keys(e).every(n=>$0(t[n],e[n])):!1}var Ele=Object.prototype.hasOwnProperty;function SR(t,e){if(t===e)return t;const n=Sz(t)&&Sz(e);if(!n&&!(iP(t)&&iP(e)))return e;const i=(n?t:Object.keys(t)).length,a=n?e:Object.keys(e),o=a.length,l=n?new Array(o):{};let c=0;for(let u=0;u<o;u++){const d=n?u:a[u],f=t[d],p=e[d];if(f===p){l[d]=f,(n?u<i:Ele.call(t,d))&&c++;continue}if(f===null||p===null||typeof f!="object"||typeof p!="object"){l[d]=p;continue}const m=SR(f,p);l[d]=m,m===f&&c++}return i===o&&c===i?t:l}function V0(t,e){if(!e||Object.keys(t).length!==Object.keys(e).length)return!1;for(const n in t)if(t[n]!==e[n])return!1;return!0}function Sz(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function iP(t){if(!Mz(t))return!1;const e=t.constructor;if(e===void 0)return!0;const n=e.prototype;return!(!Mz(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}function Mz(t){return Object.prototype.toString.call(t)==="[object Object]"}function Tle(t){return new Promise(e=>{jf.setTimeout(e,t)})}function aP(t,e,n){return typeof n.structuralSharing=="function"?n.structuralSharing(t,e):n.structuralSharing!==!1?SR(t,e):e}function Ale(t,e,n=0){const r=[...t,e];return n&&r.length>n?r.slice(1):r}function Cle(t,e,n=0){const r=[e,...t];return n&&r.length>n?r.slice(0,-1):r}var MR=Symbol();function Xq(t,e){return!t.queryFn&&e?.initialPromise?()=>e.initialPromise:!t.queryFn||t.queryFn===MR?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function Yq(t,e){return typeof t=="function"?t(...e):!!t}var jle=class extends km{#t;#e;#n;constructor(){super(),this.#n=t=>{if(!tm&&window.addEventListener){const e=()=>t();return window.addEventListener("visibilitychange",e,!1),()=>{window.removeEventListener("visibilitychange",e)}}}}onSubscribe(){this.#e||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#e?.(),this.#e=void 0)}setEventListener(t){this.#n=t,this.#e?.(),this.#e=t(e=>{typeof e=="boolean"?this.setFocused(e):this.onFocus()})}setFocused(t){this.#t!==t&&(this.#t=t,this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(e=>{e(t)})}isFocused(){return typeof this.#t=="boolean"?this.#t:globalThis.document?.visibilityState!=="hidden"}},NR=new jle;function sP(){let t,e;const n=new Promise((i,a)=>{t=i,e=a});n.status="pending",n.catch(()=>{});function r(i){Object.assign(n,i),delete n.resolve,delete n.reject}return n.resolve=i=>{r({status:"fulfilled",value:i}),t(i)},n.reject=i=>{r({status:"rejected",reason:i}),e(i)},n}var Ple=Nle;function Dle(){let t=[],e=0,n=l=>{l()},r=l=>{l()},i=Ple;const a=l=>{e?t.push(l):i(()=>{n(l)})},o=()=>{const l=t;t=[],l.length&&i(()=>{r(()=>{l.forEach(c=>{n(c)})})})};return{batch:l=>{let c;e++;try{c=l()}finally{e--,e||o()}return c},batchCalls:l=>(...c)=>{a(()=>{l(...c)})},schedule:a,setNotifyFunction:l=>{n=l},setBatchNotifyFunction:l=>{r=l},setScheduler:l=>{i=l}}}var xi=Dle(),Rle=class extends km{#t=!0;#e;#n;constructor(){super(),this.#n=t=>{if(!tm&&window.addEventListener){const e=()=>t(!0),n=()=>t(!1);return window.addEventListener("online",e,!1),window.addEventListener("offline",n,!1),()=>{window.removeEventListener("online",e),window.removeEventListener("offline",n)}}}}onSubscribe(){this.#e||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#e?.(),this.#e=void 0)}setEventListener(t){this.#n=t,this.#e?.(),this.#e=t(this.setOnline.bind(this))}setOnline(t){this.#t!==t&&(this.#t=t,this.listeners.forEach(n=>{n(t)}))}isOnline(){return this.#t}},$1=new Rle;function Ole(t){return Math.min(1e3*2**t,3e4)}function Qq(t){return(t??"online")==="online"?$1.isOnline():!0}var oP=class extends Error{constructor(t){super("CancelledError"),this.revert=t?.revert,this.silent=t?.silent}};function Zq(t){let e=!1,n=0,r;const i=sP(),a=()=>i.status!=="pending",o=b=>{if(!a()){const y=new oP(b);p(y),t.onCancel?.(y)}},l=()=>{e=!0},c=()=>{e=!1},u=()=>NR.isFocused()&&(t.networkMode==="always"||$1.isOnline())&&t.canRun(),d=()=>Qq(t.networkMode)&&t.canRun(),f=b=>{a()||(r?.(),i.resolve(b))},p=b=>{a()||(r?.(),i.reject(b))},m=()=>new Promise(b=>{r=y=>{(a()||u())&&b(y)},t.onPause?.()}).then(()=>{r=void 0,a()||t.onContinue?.()}),x=()=>{if(a())return;let b;const y=n===0?t.initialPromise:void 0;try{b=y??t.fn()}catch(v){b=Promise.reject(v)}Promise.resolve(b).then(f).catch(v=>{if(a())return;const S=t.retry??(tm?0:3),N=t.retryDelay??Ole,T=typeof N=="function"?N(n,v):N,k=S===!0||typeof S=="number"&&n<S||typeof S=="function"&&S(n,v);if(e||!k){p(v);return}n++,t.onFail?.(n,v),Tle(T).then(()=>u()?void 0:m()).then(()=>{e?p(v):x()})})};return{promise:i,status:()=>i.status,cancel:o,continue:()=>(r?.(),i),cancelRetry:l,continueRetry:c,canStart:d,start:()=>(d()?x():m().then(x),i)}}var Jq=class{#t;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),rP(this.gcTime)&&(this.#t=jf.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(tm?1/0:300*1e3))}clearGcTimeout(){this.#t&&(jf.clearTimeout(this.#t),this.#t=void 0)}},Lle=class extends Jq{#t;#e;#n;#i;#r;#a;#o;constructor(t){super(),this.#o=!1,this.#a=t.defaultOptions,this.setOptions(t.options),this.observers=[],this.#i=t.client,this.#n=this.#i.getQueryCache(),this.queryKey=t.queryKey,this.queryHash=t.queryHash,this.#t=kz(this.options),this.state=t.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#r?.promise}setOptions(t){if(this.options={...this.#a,...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const e=kz(this.options);e.data!==void 0&&(this.setState(Nz(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#n.remove(this)}setData(t,e){const n=aP(this.state.data,t,this.options);return this.#s({data:n,type:"success",dataUpdatedAt:e?.updatedAt,manual:e?.manual}),n}setState(t,e){this.#s({type:"setState",state:t,setStateOptions:e})}cancel(t){const e=this.#r?.promise;return this.#r?.cancel(t),e?e.then(Ya).catch(Ya):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#t)}isActive(){return this.observers.some(t=>Ho(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===MR||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>rh(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!Kq(this.state.dataUpdatedAt,t)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#r?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#r?.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),this.#n.notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(e=>e!==t),this.observers.length||(this.#r&&(this.#o?this.#r.cancel({revert:!0}):this.#r.cancelRetry()),this.scheduleGc()),this.#n.notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#s({type:"invalidate"})}async fetch(t,e){if(this.state.fetchStatus!=="idle"&&this.#r?.status()!=="rejected"){if(this.state.data!==void 0&&e?.cancelRefetch)this.cancel({silent:!0});else if(this.#r)return this.#r.continueRetry(),this.#r.promise}if(t&&this.setOptions(t),!this.options.queryFn){const l=this.observers.find(c=>c.options.queryFn);l&&this.setOptions(l.options)}const n=new AbortController,r=l=>{Object.defineProperty(l,"signal",{enumerable:!0,get:()=>(this.#o=!0,n.signal)})},i=()=>{const l=Xq(this.options,e),u=(()=>{const d={client:this.#i,queryKey:this.queryKey,meta:this.meta};return r(d),d})();return this.#o=!1,this.options.persister?this.options.persister(l,u,this):l(u)},o=(()=>{const l={fetchOptions:e,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:i};return r(l),l})();this.options.behavior?.onFetch(o,this),this.#e=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==o.fetchOptions?.meta)&&this.#s({type:"fetch",meta:o.fetchOptions?.meta}),this.#r=Zq({initialPromise:e?.initialPromise,fn:o.fetchFn,onCancel:l=>{l instanceof oP&&l.revert&&this.setState({...this.#e,fetchStatus:"idle"}),n.abort()},onFail:(l,c)=>{this.#s({type:"failed",failureCount:l,error:c})},onPause:()=>{this.#s({type:"pause"})},onContinue:()=>{this.#s({type:"continue"})},retry:o.options.retry,retryDelay:o.options.retryDelay,networkMode:o.options.networkMode,canRun:()=>!0});try{const l=await this.#r.start();if(l===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(l),this.#n.config.onSuccess?.(l,this),this.#n.config.onSettled?.(l,this.state.error,this),l}catch(l){if(l instanceof oP){if(l.silent)return this.#r.promise;if(l.revert){if(this.state.data===void 0)throw l;return this.state.data}}throw this.#s({type:"error",error:l}),this.#n.config.onError?.(l,this),this.#n.config.onSettled?.(this.state.data,l,this),l}finally{this.scheduleGc()}}#s(t){const e=n=>{switch(t.type){case"failed":return{...n,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...n,fetchStatus:"paused"};case"continue":return{...n,fetchStatus:"fetching"};case"fetch":return{...n,...eW(n.data,this.options),fetchMeta:t.meta??null};case"success":const r={...n,...Nz(t.data,t.dataUpdatedAt),dataUpdateCount:n.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#e=t.manual?r:void 0,r;case"error":const i=t.error;return{...n,error:i,errorUpdateCount:n.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:n.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error"};case"invalidate":return{...n,isInvalidated:!0};case"setState":return{...n,...t.state}}};this.state=e(this.state),xi.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),this.#n.notify({query:this,type:"updated",action:t})})}};function eW(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Qq(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function Nz(t,e){return{data:t,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}function kz(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 kR=class extends km{constructor(t,e){super(),this.options=e,this.#t=t,this.#s=null,this.#o=sP(),this.bindMethods(),this.setOptions(e)}#t;#e=void 0;#n=void 0;#i=void 0;#r;#a;#o;#s;#f;#d;#h;#c;#u;#l;#p=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#e.addObserver(this),Ez(this.#e,this.options)?this.#m():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return lP(this.#e,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return lP(this.#e,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#v(),this.#w(),this.#e.removeObserver(this)}setOptions(t){const e=this.options,n=this.#e;if(this.options=this.#t.defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Ho(this.options.enabled,this.#e)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#_(),this.#e.setOptions(this.options),e._defaulted&&!V0(this.options,e)&&this.#t.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#e,observer:this});const r=this.hasListeners();r&&Tz(this.#e,n,this.options,e)&&this.#m(),this.updateResult(),r&&(this.#e!==n||Ho(this.options.enabled,this.#e)!==Ho(e.enabled,this.#e)||rh(this.options.staleTime,this.#e)!==rh(e.staleTime,this.#e))&&this.#g();const i=this.#x();r&&(this.#e!==n||Ho(this.options.enabled,this.#e)!==Ho(e.enabled,this.#e)||i!==this.#l)&&this.#b(i)}getOptimisticResult(t){const e=this.#t.getQueryCache().build(this.#t,t),n=this.createResult(e,t);return Ile(this,n)&&(this.#i=n,this.#a=this.options,this.#r=this.#e.state),n}getCurrentResult(){return this.#i}trackResult(t,e){return new Proxy(t,{get:(n,r)=>(this.trackProp(r),e?.(r),r==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&this.#o.status==="pending"&&this.#o.reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(n,r))})}trackProp(t){this.#p.add(t)}getCurrentQuery(){return this.#e}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const e=this.#t.defaultQueryOptions(t),n=this.#t.getQueryCache().build(this.#t,e);return n.fetch().then(()=>this.createResult(n,e))}fetch(t){return this.#m({...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#i))}#m(t){this.#_();let e=this.#e.fetch(this.options,t);return t?.throwOnError||(e=e.catch(Ya)),e}#g(){this.#v();const t=rh(this.options.staleTime,this.#e);if(tm||this.#i.isStale||!rP(t))return;const n=Kq(this.#i.dataUpdatedAt,t)+1;this.#c=jf.setTimeout(()=>{this.#i.isStale||this.updateResult()},n)}#x(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#e):this.options.refetchInterval)??!1}#b(t){this.#w(),this.#l=t,!(tm||Ho(this.options.enabled,this.#e)===!1||!rP(this.#l)||this.#l===0)&&(this.#u=jf.setInterval(()=>{(this.options.refetchIntervalInBackground||NR.isFocused())&&this.#m()},this.#l))}#y(){this.#g(),this.#b(this.#x())}#v(){this.#c&&(jf.clearTimeout(this.#c),this.#c=void 0)}#w(){this.#u&&(jf.clearInterval(this.#u),this.#u=void 0)}createResult(t,e){const n=this.#e,r=this.options,i=this.#i,a=this.#r,o=this.#a,c=t!==n?t.state:this.#n,{state:u}=t;let d={...u},f=!1,p;if(e._optimisticResults){const D=this.hasListeners(),A=!D&&Ez(t,e),R=D&&Tz(t,n,e,r);(A||R)&&(d={...d,...eW(u.data,t.options)}),e._optimisticResults==="isRestoring"&&(d.fetchStatus="idle")}let{error:m,errorUpdatedAt:x,status:b}=d;p=d.data;let y=!1;if(e.placeholderData!==void 0&&p===void 0&&b==="pending"){let D;i?.isPlaceholderData&&e.placeholderData===o?.placeholderData?(D=i.data,y=!0):D=typeof e.placeholderData=="function"?e.placeholderData(this.#h?.state.data,this.#h):e.placeholderData,D!==void 0&&(b="success",p=aP(i?.data,D,e),f=!0)}if(e.select&&p!==void 0&&!y)if(i&&p===a?.data&&e.select===this.#f)p=this.#d;else try{this.#f=e.select,p=e.select(p),p=aP(i?.data,p,e),this.#d=p,this.#s=null}catch(D){this.#s=D}this.#s&&(m=this.#s,p=this.#d,x=Date.now(),b="error");const v=d.fetchStatus==="fetching",S=b==="pending",N=b==="error",T=S&&v,k=p!==void 0,E={status:b,fetchStatus:d.fetchStatus,isPending:S,isSuccess:b==="success",isError:N,isInitialLoading:T,isLoading:T,data:p,dataUpdatedAt:d.dataUpdatedAt,error:m,errorUpdatedAt:x,failureCount:d.fetchFailureCount,failureReason:d.fetchFailureReason,errorUpdateCount:d.errorUpdateCount,isFetched:d.dataUpdateCount>0||d.errorUpdateCount>0,isFetchedAfterMount:d.dataUpdateCount>c.dataUpdateCount||d.errorUpdateCount>c.errorUpdateCount,isFetching:v,isRefetching:v&&!S,isLoadingError:N&&!k,isPaused:d.fetchStatus==="paused",isPlaceholderData:f,isRefetchError:N&&k,isStale:ER(t,e),refetch:this.refetch,promise:this.#o,isEnabled:Ho(e.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const D=U=>{E.status==="error"?U.reject(E.error):E.data!==void 0&&U.resolve(E.data)},A=()=>{const U=this.#o=E.promise=sP();D(U)},R=this.#o;switch(R.status){case"pending":t.queryHash===n.queryHash&&D(R);break;case"fulfilled":(E.status==="error"||E.data!==R.value)&&A();break;case"rejected":(E.status!=="error"||E.error!==R.reason)&&A();break}}return E}updateResult(){const t=this.#i,e=this.createResult(this.#e,this.options);if(this.#r=this.#e.state,this.#a=this.options,this.#r.data!==void 0&&(this.#h=this.#e),V0(e,t))return;this.#i=e;const n=()=>{if(!t)return!0;const{notifyOnChangeProps:r}=this.options,i=typeof r=="function"?r():r;if(i==="all"||!i&&!this.#p.size)return!0;const a=new Set(i??this.#p);return this.options.throwOnError&&a.add("error"),Object.keys(this.#i).some(o=>{const l=o;return this.#i[l]!==t[l]&&a.has(l)})};this.#S({listeners:n()})}#_(){const t=this.#t.getQueryCache().build(this.#t,this.options);if(t===this.#e)return;const e=this.#e;this.#e=t,this.#n=t.state,this.hasListeners()&&(e?.removeObserver(this),t.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}#S(t){xi.batch(()=>{t.listeners&&this.listeners.forEach(e=>{e(this.#i)}),this.#t.getQueryCache().notify({query:this.#e,type:"observerResultsUpdated"})})}};function Fle(t,e){return Ho(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&e.retryOnMount===!1)}function Ez(t,e){return Fle(t,e)||t.state.data!==void 0&&lP(t,e,e.refetchOnMount)}function lP(t,e,n){if(Ho(e.enabled,t)!==!1&&rh(e.staleTime,t)!=="static"){const r=typeof n=="function"?n(t):n;return r==="always"||r!==!1&&ER(t,e)}return!1}function Tz(t,e,n,r){return(t!==e||Ho(r.enabled,t)===!1)&&(!n.suspense||t.state.status!=="error")&&ER(t,n)}function ER(t,e){return Ho(e.enabled,t)!==!1&&t.isStaleByTime(rh(e.staleTime,t))}function Ile(t,e){return!V0(t.getCurrentResult(),e)}function Az(t){return{onFetch:(e,n)=>{const r=e.options,i=e.fetchOptions?.meta?.fetchMore?.direction,a=e.state.data?.pages||[],o=e.state.data?.pageParams||[];let l={pages:[],pageParams:[]},c=0;const u=async()=>{let d=!1;const f=x=>{Object.defineProperty(x,"signal",{enumerable:!0,get:()=>(e.signal.aborted?d=!0:e.signal.addEventListener("abort",()=>{d=!0}),e.signal)})},p=Xq(e.options,e.fetchOptions),m=async(x,b,y)=>{if(d)return Promise.reject();if(b==null&&x.pages.length)return Promise.resolve(x);const S=(()=>{const C={client:e.client,queryKey:e.queryKey,pageParam:b,direction:y?"backward":"forward",meta:e.options.meta};return f(C),C})(),N=await p(S),{maxPages:T}=e.options,k=y?Cle:Ale;return{pages:k(x.pages,N,T),pageParams:k(x.pageParams,b,T)}};if(i&&a.length){const x=i==="backward",b=x?Ule:Cz,y={pages:a,pageParams:o},v=b(r,y);l=await m(y,v,x)}else{const x=t??a.length;do{const b=c===0?o[0]??r.initialPageParam:Cz(r,l);if(c>0&&b==null)break;l=await m(l,b),c++}while(c<x)}return l};e.options.persister?e.fetchFn=()=>e.options.persister?.(u,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},n):e.fetchFn=u}}}function Cz(t,{pages:e,pageParams:n}){const r=e.length-1;return e.length>0?t.getNextPageParam(e[r],e,n[r],n):void 0}function Ule(t,{pages:e,pageParams:n}){return e.length>0?t.getPreviousPageParam?.(e[0],e,n[0],n):void 0}var zle=class extends Jq{#t;#e;#n;#i;constructor(t){super(),this.#t=t.client,this.mutationId=t.mutationId,this.#n=t.mutationCache,this.#e=[],this.state=t.state||tW(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){this.#e.includes(t)||(this.#e.push(t),this.clearGcTimeout(),this.#n.notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){this.#e=this.#e.filter(e=>e!==t),this.scheduleGc(),this.#n.notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){this.#e.length||(this.state.status==="pending"?this.scheduleGc():this.#n.remove(this))}continue(){return this.#i?.continue()??this.execute(this.state.variables)}async execute(t){const e=()=>{this.#r({type:"continue"})},n={client:this.#t,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#i=Zq({fn:()=>this.options.mutationFn?this.options.mutationFn(t,n):Promise.reject(new Error("No mutationFn found")),onFail:(a,o)=>{this.#r({type:"failed",failureCount:a,error:o})},onPause:()=>{this.#r({type:"pause"})},onContinue:e,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)});const r=this.state.status==="pending",i=!this.#i.canStart();try{if(r)e();else{this.#r({type:"pending",variables:t,isPaused:i}),await this.#n.config.onMutate?.(t,this,n);const o=await this.options.onMutate?.(t,n);o!==this.state.context&&this.#r({type:"pending",context:o,variables:t,isPaused:i})}const a=await this.#i.start();return await this.#n.config.onSuccess?.(a,t,this.state.context,this,n),await this.options.onSuccess?.(a,t,this.state.context,n),await this.#n.config.onSettled?.(a,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(a,null,t,this.state.context,n),this.#r({type:"success",data:a}),a}catch(a){try{throw await this.#n.config.onError?.(a,t,this.state.context,this,n),await this.options.onError?.(a,t,this.state.context,n),await this.#n.config.onSettled?.(void 0,a,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(void 0,a,t,this.state.context,n),a}finally{this.#r({type:"error",error:a})}}finally{this.#n.runNext(this)}}#r(t){const e=n=>{switch(t.type){case"failed":return{...n,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...n,isPaused:!0};case"continue":return{...n,isPaused:!1};case"pending":return{...n,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...n,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...n,data:void 0,error:t.error,failureCount:n.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=e(this.state),xi.batch(()=>{this.#e.forEach(n=>{n.onMutationUpdate(t)}),this.#n.notify({mutation:this,type:"updated",action:t})})}};function tW(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Ble=class extends km{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 zle({client:t,mutationCache:this,mutationId:++this.#n,options:t.defaultMutationOptions(e),state:n});return this.add(r),r}add(t){this.#t.add(t);const e=Pw(t);if(typeof e=="string"){const n=this.#e.get(e);n?n.push(t):this.#e.set(e,[t])}this.notify({type:"added",mutation:t})}remove(t){if(this.#t.delete(t)){const e=Pw(t);if(typeof e=="string"){const n=this.#e.get(e);if(n)if(n.length>1){const r=n.indexOf(t);r!==-1&&n.splice(r,1)}else n[0]===t&&this.#e.delete(e)}}this.notify({type:"removed",mutation:t})}canRun(t){const e=Pw(t);if(typeof e=="string"){const r=this.#e.get(e)?.find(i=>i.state.status==="pending");return!r||r===t}else return!0}runNext(t){const e=Pw(t);return typeof e=="string"?this.#e.get(e)?.find(r=>r!==t&&r.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){xi.batch(()=>{this.#t.forEach(t=>{this.notify({type:"removed",mutation:t})}),this.#t.clear(),this.#e.clear()})}getAll(){return Array.from(this.#t)}find(t){const e={exact:!0,...t};return this.getAll().find(n=>_z(e,n))}findAll(t={}){return this.getAll().filter(e=>_z(t,e))}notify(t){xi.batch(()=>{this.listeners.forEach(e=>{e(t)})})}resumePausedMutations(){const t=this.getAll().filter(e=>e.state.isPaused);return xi.batch(()=>Promise.all(t.map(e=>e.continue().catch(Ya))))}};function Pw(t){return t.options.scope?.id}var Hle=class extends km{#t;#e=void 0;#n;#i;constructor(e,n){super(),this.#t=e,this.setOptions(n),this.bindMethods(),this.#r()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){const n=this.options;this.options=this.#t.defaultMutationOptions(e),V0(this.options,n)||this.#t.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#n,observer:this}),n?.mutationKey&&this.options.mutationKey&&nm(n.mutationKey)!==nm(this.options.mutationKey)?this.reset():this.#n?.state.status==="pending"&&this.#n.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#r(),this.#a(e)}getCurrentResult(){return this.#e}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#r(),this.#a()}mutate(e,n){return this.#i=n,this.#n?.removeObserver(this),this.#n=this.#t.getMutationCache().build(this.#t,this.options),this.#n.addObserver(this),this.#n.execute(e)}#r(){const e=this.#n?.state??tW();this.#e={...e,isPending:e.status==="pending",isSuccess:e.status==="success",isError:e.status==="error",isIdle:e.status==="idle",mutate:this.mutate,reset:this.reset}}#a(e){xi.batch(()=>{if(this.#i&&this.hasListeners()){const n=this.#e.variables,r=this.#e.context,i={client:this.#t,meta:this.options.meta,mutationKey:this.options.mutationKey};e?.type==="success"?(this.#i.onSuccess?.(e.data,n,r,i),this.#i.onSettled?.(e.data,null,n,r,i)):e?.type==="error"&&(this.#i.onError?.(e.error,n,r,i),this.#i.onSettled?.(void 0,e.error,n,r,i))}this.listeners.forEach(n=>{n(this.#e)})})}};function jz(t,e){const n=new Set(e);return t.filter(r=>!n.has(r))}function $le(t,e,n){const r=t.slice(0);return r[e]=n,r}var Vle=class extends km{#t;#e;#n;#i;#r;#a;#o;#s;#f=[];constructor(t,e,n){super(),this.#t=t,this.#i=n,this.#n=[],this.#r=[],this.#e=[],this.setQueries(e)}onSubscribe(){this.listeners.size===1&&this.#r.forEach(t=>{t.subscribe(e=>{this.#u(t,e)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#r.forEach(t=>{t.destroy()})}setQueries(t,e){this.#n=t,this.#i=e,xi.batch(()=>{const n=this.#r,r=this.#c(this.#n);this.#f=r,r.forEach(d=>d.observer.setOptions(d.defaultedQueryOptions));const i=r.map(d=>d.observer),a=i.map(d=>d.getCurrentResult()),o=n.length!==i.length,l=i.some((d,f)=>d!==n[f]),c=o||l,u=c?!0:a.some((d,f)=>{const p=this.#e[f];return!p||!V0(d,p)});!c&&!u||(c&&(this.#r=i),this.#e=a,this.hasListeners()&&(c&&(jz(n,i).forEach(d=>{d.destroy()}),jz(i,n).forEach(d=>{d.subscribe(f=>{this.#u(d,f)})})),this.#l()))})}getCurrentResult(){return this.#e}getQueries(){return this.#r.map(t=>t.getCurrentQuery())}getObservers(){return this.#r}getOptimisticResult(t,e){const n=this.#c(t),r=n.map(i=>i.observer.getOptimisticResult(i.defaultedQueryOptions));return[r,i=>this.#h(i??r,e),()=>this.#d(r,n)]}#d(t,e){return e.map((n,r)=>{const i=t[r];return n.defaultedQueryOptions.notifyOnChangeProps?i:n.observer.trackResult(i,a=>{e.forEach(o=>{o.observer.trackProp(a)})})})}#h(t,e){return e?((!this.#a||this.#e!==this.#s||e!==this.#o)&&(this.#o=e,this.#s=this.#e,this.#a=SR(this.#a,e(t))),this.#a):t}#c(t){const e=new Map;this.#r.forEach(r=>{const i=r.options.queryHash;if(!i)return;const a=e.get(i);a?a.push(r):e.set(i,[r])});const n=[];return t.forEach(r=>{const i=this.#t.defaultQueryOptions(r),o=e.get(i.queryHash)?.shift()??new kR(this.#t,i);n.push({defaultedQueryOptions:i,observer:o})}),n}#u(t,e){const n=this.#r.indexOf(t);n!==-1&&(this.#e=$le(this.#e,n,e),this.#l())}#l(){if(this.hasListeners()){const t=this.#a,e=this.#d(this.#e,this.#f),n=this.#h(e,this.#i?.combine);t!==n&&xi.batch(()=>{this.listeners.forEach(r=>{r(this.#e)})})}}},Gle=class extends km{constructor(t={}){super(),this.config=t,this.#t=new Map}#t;build(t,e,n){const r=e.queryKey,i=e.queryHash??_R(r,e);let a=this.get(i);return a||(a=new Lle({client:t,queryKey:r,queryHash:i,options:t.defaultQueryOptions(e),state:n,defaultOptions:t.getQueryDefaults(r)}),this.add(a)),a}add(t){this.#t.has(t.queryHash)||(this.#t.set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const e=this.#t.get(t.queryHash);e&&(t.destroy(),e===t&&this.#t.delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){xi.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return this.#t.get(t)}getAll(){return[...this.#t.values()]}find(t){const e={exact:!0,...t};return this.getAll().find(n=>wz(e,n))}findAll(t={}){const e=this.getAll();return Object.keys(t).length>0?e.filter(n=>wz(t,n)):e}notify(t){xi.batch(()=>{this.listeners.forEach(e=>{e(t)})})}onFocus(){xi.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){xi.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},qle=class{#t;#e;#n;#i;#r;#a;#o;#s;constructor(t={}){this.#t=t.queryCache||new Gle,this.#e=t.mutationCache||new Ble,this.#n=t.defaultOptions||{},this.#i=new Map,this.#r=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=NR.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#t.onFocus())}),this.#s=$1.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#t.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(t){return this.#t.findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return this.#e.findAll({...t,status:"pending"}).length}getQueryData(t){const e=this.defaultQueryOptions({queryKey:t});return this.#t.get(e.queryHash)?.state.data}ensureQueryData(t){const e=this.defaultQueryOptions(t),n=this.#t.build(this,e),r=n.state.data;return r===void 0?this.fetchQuery(t):(t.revalidateIfStale&&n.isStaleByTime(rh(e.staleTime,n))&&this.prefetchQuery(e),Promise.resolve(r))}getQueriesData(t){return this.#t.findAll(t).map(({queryKey:e,state:n})=>{const r=n.data;return[e,r]})}setQueryData(t,e,n){const r=this.defaultQueryOptions({queryKey:t}),a=this.#t.get(r.queryHash)?.state.data,o=kle(e,a);if(o!==void 0)return this.#t.build(this,r).setData(o,{...n,manual:!0})}setQueriesData(t,e,n){return xi.batch(()=>this.#t.findAll(t).map(({queryKey:r})=>[r,this.setQueryData(r,e,n)]))}getQueryState(t){const e=this.defaultQueryOptions({queryKey:t});return this.#t.get(e.queryHash)?.state}removeQueries(t){const e=this.#t;xi.batch(()=>{e.findAll(t).forEach(n=>{e.remove(n)})})}resetQueries(t,e){const n=this.#t;return xi.batch(()=>(n.findAll(t).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){const n={revert:!0,...e},r=xi.batch(()=>this.#t.findAll(t).map(i=>i.cancel(n)));return Promise.all(r).then(Ya).catch(Ya)}invalidateQueries(t,e={}){return xi.batch(()=>(this.#t.findAll(t).forEach(n=>{n.invalidate()}),t?.refetchType==="none"?Promise.resolve():this.refetchQueries({...t,type:t?.refetchType??t?.type??"active"},e)))}refetchQueries(t,e={}){const n={...e,cancelRefetch:e.cancelRefetch??!0},r=xi.batch(()=>this.#t.findAll(t).filter(i=>!i.isDisabled()&&!i.isStatic()).map(i=>{let a=i.fetch(void 0,n);return n.throwOnError||(a=a.catch(Ya)),i.state.fetchStatus==="paused"?Promise.resolve():a}));return Promise.all(r).then(Ya)}fetchQuery(t){const e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);const n=this.#t.build(this,e);return n.isStaleByTime(rh(e.staleTime,n))?n.fetch(e):Promise.resolve(n.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(Ya).catch(Ya)}fetchInfiniteQuery(t){return t.behavior=Az(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(Ya).catch(Ya)}ensureInfiniteQueryData(t){return t.behavior=Az(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return $1.isOnline()?this.#e.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#t}getMutationCache(){return this.#e}getDefaultOptions(){return this.#n}setDefaultOptions(t){this.#n=t}setQueryDefaults(t,e){this.#i.set(nm(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...this.#i.values()],n={};return e.forEach(r=>{$0(t,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(t,e){this.#r.set(nm(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...this.#r.values()],n={};return e.forEach(r=>{$0(t,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(t){if(t._defaulted)return t;const e={...this.#n.queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return e.queryHash||(e.queryHash=_R(e.queryKey,e)),e.refetchOnReconnect===void 0&&(e.refetchOnReconnect=e.networkMode!=="always"),e.throwOnError===void 0&&(e.throwOnError=!!e.suspense),!e.networkMode&&e.persister&&(e.networkMode="offlineFirst"),e.queryFn===MR&&(e.enabled=!1),e}defaultMutationOptions(t){return t?._defaulted?t:{...this.#n.mutations,...t?.mutationKey&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){this.#t.clear(),this.#e.clear()}},nW=_.createContext(void 0),an=t=>{const e=_.useContext(nW);if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},Wle=({client:t,children:e})=>(_.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),s.jsx(nW.Provider,{value:t,children:e})),rW=_.createContext(!1),iW=()=>_.useContext(rW);rW.Provider;function Kle(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var Xle=_.createContext(Kle()),aW=()=>_.useContext(Xle),sW=(t,e)=>{(t.suspense||t.throwOnError||t.experimental_prefetchInRender)&&(e.isReset()||(t.retryOnMount=!1))},oW=t=>{_.useEffect(()=>{t.clearReset()},[t])},lW=({result:t,errorResetBoundary:e,throwOnError:n,query:r,suspense:i})=>t.isError&&!e.isReset()&&!t.isFetching&&r&&(i&&t.data===void 0||Yq(n,[t.error,r])),cW=t=>{if(t.suspense){const n=i=>i==="static"?i:Math.max(i??1e3,1e3),r=t.staleTime;t.staleTime=typeof r=="function"?(...i)=>n(r(...i)):n(r),typeof t.gcTime=="number"&&(t.gcTime=Math.max(t.gcTime,1e3))}},uW=(t,e)=>t.isLoading&&t.isFetching&&!e,cP=(t,e)=>t?.suspense&&e.isPending,V1=(t,e,n)=>e.fetchOptimistic(t).catch(()=>{n.clearReset()});function dW({queries:t,...e},n){const r=an(),i=iW(),a=aW(),o=_.useMemo(()=>t.map(b=>{const y=r.defaultQueryOptions(b);return y._optimisticResults=i?"isRestoring":"optimistic",y}),[t,r,i]);o.forEach(b=>{cW(b),sW(b,a)}),oW(a);const[l]=_.useState(()=>new Vle(r,o,e)),[c,u,d]=l.getOptimisticResult(o,e.combine),f=!i&&e.subscribed!==!1;_.useSyncExternalStore(_.useCallback(b=>f?l.subscribe(xi.batchCalls(b)):Ya,[l,f]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),_.useEffect(()=>{l.setQueries(o,e)},[o,e,l]);const m=c.some((b,y)=>cP(o[y],b))?c.flatMap((b,y)=>{const v=o[y];if(v){const S=new kR(r,v);if(cP(v,b))return V1(v,S,a);uW(b,i)&&V1(v,S,a)}return[]}):[];if(m.length>0)throw Promise.all(m);const x=c.find((b,y)=>{const v=o[y];return v&&lW({result:b,errorResetBoundary:a,throwOnError:v.throwOnError,query:r.getQueryCache().get(v.queryHash),suspense:v.suspense})});if(x?.error)throw x.error;return u(d())}function Yle(t,e,n){const r=iW(),i=aW(),a=an(),o=a.defaultQueryOptions(t);a.getDefaultOptions().queries?._experimental_beforeQuery?.(o),o._optimisticResults=r?"isRestoring":"optimistic",cW(o),sW(o,i),oW(i);const l=!a.getQueryCache().get(o.queryHash),[c]=_.useState(()=>new e(a,o)),u=c.getOptimisticResult(o),d=!r&&t.subscribed!==!1;if(_.useSyncExternalStore(_.useCallback(f=>{const p=d?c.subscribe(xi.batchCalls(f)):Ya;return c.updateResult(),p},[c,d]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),_.useEffect(()=>{c.setOptions(o)},[o,c]),cP(o,u))throw V1(o,c,i);if(lW({result:u,errorResetBoundary:i,throwOnError:o.throwOnError,query:a.getQueryCache().get(o.queryHash),suspense:o.suspense}))throw u.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(o,u),o.experimental_prefetchInRender&&!tm&&uW(u,r)&&(l?V1(o,c,i):a.getQueryCache().get(o.queryHash)?.promise)?.catch(Ya).finally(()=>{c.updateResult()}),o.notifyOnChangeProps?u:c.trackResult(u)}function at(t,e){return Yle(t,kR)}function mt(t,e){const n=an(),[r]=_.useState(()=>new Hle(n,t));_.useEffect(()=>{r.setOptions(t)},[r,t]);const i=_.useSyncExternalStore(_.useCallback(o=>r.subscribe(xi.batchCalls(o)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=_.useCallback((o,l)=>{r.mutate(o,l).catch(Ya)},[r]);if(i.error&&Yq(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}const Qle=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Zle=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase()),Pz=t=>{const e=Zle(t);return e.charAt(0).toUpperCase()+e.slice(1)},hW=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim(),Jle=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var ece={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 tce=_.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i="",children:a,iconNode:o,...l},c)=>_.createElement("svg",{ref:c,...ece,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:hW("lucide",i),...!a&&!Jle(l)&&{"aria-hidden":"true"},...l},[...o.map(([u,d])=>_.createElement(u,d)),...Array.isArray(a)?a:[a]]));const Qe=(t,e)=>{const n=_.forwardRef(({className:r,...i},a)=>_.createElement(tce,{ref:a,iconNode:e,className:hW(`lucide-${Qle(Pz(t))}`,`lucide-${t}`,r),...i}));return n.displayName=Pz(t),n};const nce=[["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"}]],rce=Qe("air-vent",nce);const ice=[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]],fo=Qe("archive",ice);const ace=[["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"}]],sce=Qe("arrow-down-wide-narrow",ace);const oce=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],G0=Qe("arrow-down",oce);const lce=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],cce=Qe("arrow-left",lce);const uce=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],uP=Qe("arrow-right",uce);const dce=[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]],fW=Qe("arrow-up-down",dce);const hce=[["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"}]],fce=Qe("arrow-up-narrow-wide",hce);const mce=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Ig=Qe("arrow-up",mce);const pce=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]],wg=Qe("bell",pce);const gce=[["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"}]],xce=Qe("bold",gce);const bce=[["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"}]],yce=Qe("book",bce);const vce=[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z",key:"1fy3hk"}]],wce=Qe("bookmark",vce);const _ce=[["path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z",key:"hh9hay"}],["path",{d:"m3.3 7 8.7 5 8.7-5",key:"g66t2b"}],["path",{d:"M12 22V12",key:"d0xqtd"}]],lo=Qe("box",_ce);const Sce=[["path",{d:"M16 20V4a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v16",key:"jecpp"}],["rect",{width:"20",height:"14",x:"2",y:"6",rx:"2",key:"i6l2r4"}]],mW=Qe("briefcase",Sce);const Mce=[["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"}]],aN=Qe("bug",Mce);const Nce=[["path",{d:"M17 19a1 1 0 0 1-1-1v-2a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2a1 1 0 0 1-1 1z",key:"trhst0"}],["path",{d:"M17 21v-2",key:"ds4u3f"}],["path",{d:"M19 14V6.5a1 1 0 0 0-7 0v11a1 1 0 0 1-7 0V10",key:"1mo9zo"}],["path",{d:"M21 21v-2",key:"eo0ou"}],["path",{d:"M3 5V3",key:"1k5hjh"}],["path",{d:"M4 10a2 2 0 0 1-2-2V6a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2a2 2 0 0 1-2 2z",key:"1dd30t"}],["path",{d:"M7 5V3",key:"1t1388"}]],kce=Qe("cable",Nce);const Ece=[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["line",{x1:"8",x2:"16",y1:"6",y2:"6",key:"x4nwl0"}],["line",{x1:"16",x2:"16",y1:"14",y2:"18",key:"wjye3r"}],["path",{d:"M16 10h.01",key:"1m94wz"}],["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M8 18h.01",key:"lrp35t"}]],Tce=Qe("calculator",Ece);const Ace=[["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"}]],Cce=Qe("calendar-days",Ace);const jce=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]],si=Qe("calendar",jce);const Pce=[["path",{d:"M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z",key:"18u6gg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]],Ug=Qe("camera",Pce);const Dce=[["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"}]],Rce=Qe("chart-column",Dce);const Oce=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Ia=Qe("check",Oce);const Lce=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],ei=Qe("chevron-down",Lce);const Fce=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],gs=Qe("chevron-right",Fce);const Ice=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],gh=Qe("chevron-left",Ice);const Uce=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],xh=Qe("chevron-up",Uce);const zce=[["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"}]],Hi=Qe("circle-alert",zce);const Bce=[["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"}]],JE=Qe("circle-arrow-up",Bce);const Hce=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],Ar=Qe("circle-check-big",Hce);const $ce=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],sN=Qe("circle-check",$ce);const Vce=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],Gce=Qe("circle-dot",Vce);const qce=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Wce=Qe("circle-question-mark",qce);const Kce=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]],Xce=Qe("circle-stop",Kce);const Yce=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],Yi=Qe("circle-x",Yce);const Qce=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],dP=Qe("circle",Qce);const Zce=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],er=Qe("clock",Zce);const Jce=[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]],oN=Qe("cloud",Jce);const eue=[["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"}]],tue=Qe("code-xml",eue);const nue=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],pW=Qe("code",nue);const rue=[["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"}]],iue=Qe("coffee",rue);const aue=[["path",{d:"M11 10.27 7 3.34",key:"16pf9h"}],["path",{d:"m11 13.73-4 6.93",key:"794ttg"}],["path",{d:"M12 22v-2",key:"1osdcq"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M14 12h8",key:"4f43i9"}],["path",{d:"m17 20.66-1-1.73",key:"eq3orb"}],["path",{d:"m17 3.34-1 1.73",key:"2wel8s"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"m20.66 17-1.73-1",key:"sg0v6f"}],["path",{d:"m20.66 7-1.73 1",key:"1ow05n"}],["path",{d:"m3.34 17 1.73-1",key:"nuk764"}],["path",{d:"m3.34 7 1.73 1",key:"1ulond"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["circle",{cx:"12",cy:"12",r:"8",key:"46899m"}]],sue=Qe("cog",aue);const oue=[["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"}]],lue=Qe("compass",oue);const cue=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],Fl=Qe("copy",cue);const uue=[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]],Dw=Qe("cpu",uue);const due=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5v14a9 3 0 0 0 18 0V5",key:"aqi0yr"}]],hue=Qe("cylinder",due);const fue=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]],Nu=Qe("database",fue);const mue=[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]],hP=Qe("dollar-sign",mue);const pue=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],yi=Qe("download",pue);const gue=[["path",{d:"M12 22a7 7 0 0 0 7-7c0-2-1-3.9-3-5.5s-3.5-4-4-6.5c-.5 2.5-2 4.9-4 6.5C6 11.1 5 13 5 15a7 7 0 0 0 7 7z",key:"c7niix"}]],TR=Qe("droplet",gue);const xue=[["path",{d:"M7 16.3c2.2 0 4-1.83 4-4.05 0-1.16-.57-2.26-1.71-3.19S7.29 6.75 7 5.3c-.29 1.45-1.14 2.84-2.29 3.76S3 11.1 3 12.25c0 2.22 1.8 4.05 4 4.05z",key:"1ptgy4"}],["path",{d:"M12.56 6.6A10.97 10.97 0 0 0 14 3.02c.5 2.5 2 4.9 4 6.5s3 3.5 3 5.5a6.98 6.98 0 0 1-11.91 4.97",key:"1sl1rz"}]],AR=Qe("droplets",xue);const bue=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]],ih=Qe("ellipsis-vertical",bue);const yue=[["line",{x1:"5",x2:"19",y1:"9",y2:"9",key:"1nwqeh"}],["line",{x1:"5",x2:"19",y1:"15",y2:"15",key:"g8yjpy"}]],eT=Qe("equal",yue);const vue=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],Kr=Qe("external-link",vue);const wue=[["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"}]],lN=Qe("eye-off",wue);const _ue=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Ru=Qe("eye",_ue);const Sue=[["path",{d:"M10.827 16.379a6.082 6.082 0 0 1-8.618-7.002l5.412 1.45a6.082 6.082 0 0 1 7.002-8.618l-1.45 5.412a6.082 6.082 0 0 1 8.618 7.002l-5.412-1.45a6.082 6.082 0 0 1-7.002 8.618l1.45-5.412Z",key:"484a7f"}],["path",{d:"M12 12v.01",key:"u5ubse"}]],gW=Qe("fan",Sue);const Mue=[["path",{d:"M14.5 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v3.8",key:"1kchwa"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M11.7 14.2 7 17l-4.7-2.8",key:"1yk8tc"}],["path",{d:"M3 13.1a2 2 0 0 0-.999 1.76v3.24a2 2 0 0 0 .969 1.78L6 21.7a2 2 0 0 0 2.03.01L11 19.9a2 2 0 0 0 1-1.76V14.9a2 2 0 0 0-.97-1.78L8 11.3a2 2 0 0 0-2.03-.01z",key:"19flxy"}],["path",{d:"M7 17v5",key:"1yj1jh"}]],zf=Qe("file-box",Mue);const Nue=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}]],G1=Qe("file-code",Nue);const kue=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Eue=Qe("file-exclamation-point",kue);const Tue=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M8 13h2",key:"yr2amv"}],["path",{d:"M14 13h2",key:"un5t4a"}],["path",{d:"M8 17h2",key:"2yhykz"}],["path",{d:"M14 17h2",key:"10kma7"}]],q1=Qe("file-spreadsheet",Tue);const Aue=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],Ls=Qe("file-text",Aue);const Cue=[["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"}]],cN=Qe("file",Cue);const jue=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 3v18",key:"bbkbws"}],["path",{d:"M3 7.5h4",key:"zfgn84"}],["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 16.5h4",key:"1230mu"}],["path",{d:"M17 3v18",key:"in4fa5"}],["path",{d:"M17 7.5h4",key:"myr1c1"}],["path",{d:"M17 16.5h4",key:"go4c1d"}]],ah=Qe("film",jue);const Pue=[["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"}]],Due=Qe("flame",Pue);const Rue=[["path",{d:"M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z",key:"1fr9dc"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M12 10v2",key:"hh53o1"}],["path",{d:"M16 10v6",key:"1d6xys"}]],Ja=Qe("folder-kanban",Rue);const Oue=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],Il=Qe("folder-open",Oue);const Lue=[["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"}]],Fue=Qe("folder-plus",Lue);const Iue=[["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"}]],Uue=Qe("folder-tree",Iue);const zue=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],xW=Qe("folder",zue);const Bue=[["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"}]],Hue=Qe("fullscreen",Bue);const $ue=[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]],uN=Qe("funnel",$ue);const Vue=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],dN=Qe("gauge",Vue);const Gue=[["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"}]],que=Qe("gift",Gue);const Wue=[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["path",{d:"M11 18H8a2 2 0 0 1-2-2V9",key:"19pyzm"}]],_g=Qe("git-compare",Wue);const Kue=[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]],fP=Qe("github",Kue);const Xue=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],sh=Qe("globe",Xue);const Yue=[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]],zg=Qe("grip-vertical",Yue);const Que=[["path",{d:"M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2",key:"1fvzgz"}],["path",{d:"M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2",key:"1kc0my"}],["path",{d:"M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8",key:"10h0bg"}],["path",{d:"M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15",key:"1s1gnw"}]],bW=Qe("hand",Que);const Zue=[["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"}]],hN=Qe("hard-drive",Zue);const Jue=[["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"}]],ede=Qe("hash",Jue);const tde=[["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"}]],nde=Qe("headphones",tde);const rde=[["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"}]],ide=Qe("heart",rde);const ade=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],q0=Qe("history",ade);const sde=[["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"}]],fN=Qe("house",sde);const ode=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],Ou=Qe("image",ode);const lde=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Zo=Qe("info",lde);const cde=[["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"}]],ude=Qe("italic",cde);const dde=[["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"}]],$o=Qe("key",dde);const hde=[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]],mP=Qe("keyboard",hde);const fde=[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],sl=Qe("layers",fde);const mde=[["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"}]],mN=Qe("layout-grid",mde);const pde=[["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"}]],gde=Qe("link-2-off",pde);const xde=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],uc=Qe("link-2",xde);const bde=[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]],Fy=Qe("link",bde);const yde=[["path",{d:"M11 5h10",key:"1cz7ny"}],["path",{d:"M11 12h10",key:"1438ji"}],["path",{d:"M11 19h10",key:"11t30w"}],["path",{d:"M4 4h1v5",key:"10yrso"}],["path",{d:"M4 9h2",key:"r1h2o0"}],["path",{d:"M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02",key:"xtkcd5"}]],yW=Qe("list-ordered",yde);const vde=[["path",{d:"M13 5h8",key:"a7qcls"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["rect",{x:"3",y:"4",width:"6",height:"6",rx:"1",key:"cif1o7"}]],pP=Qe("list-todo",vde);const wde=[["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"}]],pN=Qe("list",wde);const _de=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],ht=Qe("loader-circle",_de);const Sde=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 9.9-1",key:"1mm8w8"}]],tT=Qe("lock-open",Sde);const Mde=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],nT=Qe("lock",Mde);const Nde=[["path",{d:"m10 17 5-5-5-5",key:"1bsop3"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}]],Dz=Qe("log-in",Nde);const kde=[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],gP=Qe("log-out",kde);const Ede=[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]],Tde=Qe("mail",Ede);const Ade=[["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"}]],Cde=Qe("map",Ade);const jde=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],vW=Qe("maximize-2",jde);const Pde=[["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"}]],Dde=Qe("maximize",Pde);const Rde=[["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"}]],Ode=Qe("memory-stick",Rde);const Lde=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],Fde=Qe("menu",Lde);const Ide=[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]],wW=Qe("minimize-2",Ide);const Ude=[["path",{d:"M8 3v3a2 2 0 0 1-2 2H3",key:"hohbtr"}],["path",{d:"M21 8h-3a2 2 0 0 1-2-2V3",key:"5jw1f3"}],["path",{d:"M3 16h3a2 2 0 0 1 2 2v3",key:"198tvr"}],["path",{d:"M16 21v-3a2 2 0 0 1 2-2h3",key:"ph8mxp"}]],_W=Qe("minimize",Ude);const zde=[["path",{d:"M5 12h14",key:"1ays0h"}]],xP=Qe("minus",zde);const Bde=[["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"}]],Hde=Qe("monitor",Bde);const $de=[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]],W1=Qe("moon",$de);const Vde=[["path",{d:"M18 8L22 12L18 16",key:"1r0oui"}],["path",{d:"M2 12H22",key:"1m8cig"}]],Gde=Qe("move-right",Vde);const qde=[["path",{d:"M9 18V5l12-2v13",key:"1jmyc2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["circle",{cx:"18",cy:"16",r:"3",key:"1hluhg"}]],bP=Qe("music",qde);const Wde=[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]],mc=Qe("package",Wde);const Kde=[["path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",key:"e79jfc"}],["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}]],SW=Qe("palette",Kde);const Xde=[["rect",{x:"14",y:"3",width:"5",height:"18",rx:"1",key:"kaeet6"}],["rect",{x:"5",y:"3",width:"5",height:"18",rx:"1",key:"1wsw3u"}]],CR=Qe("pause",Xde);const Yde=[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],rm=Qe("pen-line",Yde);const Qde=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],fg=Qe("pen",Qde);const Zde=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],Qi=Qe("pencil",Zde);const Jde=[["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"}]],ehe=Qe("phone",Jde);const the=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],Is=Qe("play",the);const nhe=[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M9 8V2",key:"14iosj"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z",key:"osxo6l"}]],tl=Qe("plug",nhe);const rhe=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],dr=Qe("plus",rhe);const ihe=[["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"}]],gN=Qe("power-off",ihe);const ahe=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],Gu=Qe("power",ahe);const she=[["path",{d:"M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2",key:"143wyd"}],["path",{d:"M6 9V3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v6",key:"1itne7"}],["rect",{x:"6",y:"14",width:"12",height:"8",rx:"1",key:"1ue0tg"}]],Ur=Qe("printer",she);const ohe=[["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"}]],MW=Qe("qr-code",ohe);const lhe=[["path",{d:"M16.247 7.761a6 6 0 0 1 0 8.478",key:"1fwjs5"}],["path",{d:"M19.075 4.933a10 10 0 0 1 0 14.134",key:"ehdyv1"}],["path",{d:"M4.925 19.067a10 10 0 0 1 0-14.134",key:"1q22gi"}],["path",{d:"M7.753 16.239a6 6 0 0 1 0-8.478",key:"r2q7qm"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]],jR=Qe("radio",lhe);const che=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],Dr=Qe("refresh-cw",che);const uhe=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],Rh=Qe("rotate-ccw",uhe);const dhe=[["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"}]],hhe=Qe("ruler",dhe);const fhe=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],hs=Qe("save",fhe);const mhe=[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["path",{d:"m16 16-1.9-1.9",key:"1dq9hf"}]],K1=Qe("scan-search",mhe);const phe=[["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"}]],ghe=Qe("scissors",phe);const xhe=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],ba=Qe("search",xhe);const bhe=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],PR=Qe("send",bhe);const yhe=[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]],yf=Qe("server",yhe);const vhe=[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],bh=Qe("settings-2",vhe);const whe=[["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"}]],xN=Qe("settings",whe);const _he=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],rT=Qe("shield",_he);const She=[["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"}]],NW=Qe("shopping-cart",She);const Mhe=[["path",{d:"M2 20h.01",key:"4haj6o"}],["path",{d:"M7 20v-4",key:"j294jx"}],["path",{d:"M12 20v-8",key:"i3yub9"}],["path",{d:"M17 20V8",key:"1tkaf5"}],["path",{d:"M22 4v16",key:"sih9yq"}]],Nhe=Qe("signal",Mhe);const khe=[["path",{d:"M17.971 4.285A2 2 0 0 1 21 6v12a2 2 0 0 1-3.029 1.715l-9.997-5.998a2 2 0 0 1-.003-3.432z",key:"15892j"}],["path",{d:"M3 20V4",key:"1ptbpl"}]],Ehe=Qe("skip-back",khe);const The=[["path",{d:"M21 4v16",key:"7j8fe9"}],["path",{d:"M6.029 4.285A2 2 0 0 0 3 6v12a2 2 0 0 0 3.029 1.715l9.997-5.998a2 2 0 0 0 .003-3.432z",key:"zs4d6"}]],DR=Qe("skip-forward",The);const Ahe=[["path",{d:"M10 8h4",key:"1sr2af"}],["path",{d:"M12 21v-9",key:"17s77i"}],["path",{d:"M12 8V3",key:"13r4qs"}],["path",{d:"M17 16h4",key:"h1uq16"}],["path",{d:"M19 12V3",key:"o1uvq1"}],["path",{d:"M19 21v-5",key:"qua636"}],["path",{d:"M3 14h4",key:"bcjad9"}],["path",{d:"M5 10V3",key:"cb8scm"}],["path",{d:"M5 21v-7",key:"1w1uti"}]],Rz=Qe("sliders-vertical",Ahe);const Che=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],W0=Qe("sparkles",Che);const jhe=[["path",{d:"M21 10.656V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.344",key:"2acyp4"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],ol=Qe("square-check-big",jhe);const Phe=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 12h8",key:"1wcyev"}]],Dhe=Qe("square-minus",Phe);const Rhe=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],ll=Qe("square",Rhe);const Ohe=[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]],im=Qe("star",Ohe);const Lhe=[["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"}]],kW=Qe("sticky-note",Lhe);const Fhe=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],Oz=Qe("sun",Fhe);const Ihe=[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]],yh=Qe("tag",Ihe);const Uhe=[["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"}]],EW=Qe("target",Uhe);const zhe=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],TW=Qe("terminal",zhe);const Bhe=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 19H5",key:"vjpgq2"}]],Hhe=Qe("text-align-center",Bhe);const $he=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 19H7",key:"4cu937"}]],Vhe=Qe("text-align-end",$he);const Ghe=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]],qhe=Qe("text-align-start",Ghe);const Whe=[["path",{d:"M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"17jzev"}]],bN=Qe("thermometer",Whe);const Khe=[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]],xu=Qe("timer",Khe);const Xhe=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],rn=Qe("trash-2",Xhe);const Yhe=[["path",{d:"M16 17h6v-6",key:"t6n2it"}],["path",{d:"m22 17-8.5-8.5-5 5L2 7",key:"x473p"}]],AW=Qe("trending-down",Yhe);const Qhe=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],yP=Qe("trending-up",Qhe);const Zhe=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Cn=Qe("triangle-alert",Zhe);const Jhe=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],efe=Qe("underline",Jhe);const tfe=[["path",{d:"m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71",key:"yqzxt4"}],["path",{d:"m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71",key:"4qinb0"}],["line",{x1:"8",x2:"8",y1:"2",y2:"5",key:"1041cp"}],["line",{x1:"2",x2:"5",y1:"8",y2:"8",key:"14m1p5"}],["line",{x1:"16",x2:"16",y1:"19",y2:"22",key:"rzdirn"}],["line",{x1:"19",x2:"22",y1:"16",y2:"16",key:"ox905f"}]],RR=Qe("unlink",tfe);const nfe=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],Ua=Qe("upload",nfe);const rfe=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],am=Qe("user",rfe);const ife=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],mg=Qe("users",ife);const afe=[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]],OR=Qe("video",afe);const sfe=[["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"}]],ofe=Qe("volume-2",sfe);const lfe=[["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"}]],cfe=Qe("volume-x",lfe);const ufe=[["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"}]],dfe=Qe("wand-sparkles",ufe);const hfe=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],sm=Qe("wifi-off",hfe);const ffe=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]],Sg=Qe("wifi",ffe);const mfe=[["path",{d:"M12.8 19.6A2 2 0 1 0 14 16H2",key:"148xed"}],["path",{d:"M17.5 8a2.5 2.5 0 1 1 2 4H2",key:"1u4tom"}],["path",{d:"M9.8 4.4A2 2 0 1 1 11 8H2",key:"75valh"}]],CW=Qe("wind",mfe);const pfe=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]],om=Qe("wrench",pfe);const gfe=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Rt=Qe("x",gfe);const xfe=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],LR=Qe("zoom-in",xfe);const bfe=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],vh=Qe("zap",bfe);const yfe=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],FR=Qe("zoom-out",yfe),pn="/api/v1";let Wn=localStorage.getItem("auth_token");function r0(t){Wn=t,t?localStorage.setItem("auth_token",t):localStorage.removeItem("auth_token")}function Lz(){return Wn}async function Re(t,e={}){const n={"Content-Type":"application/json",...e.headers};Wn&&(n.Authorization=`Bearer ${Wn}`);const r=await fetch(`${pn}${t}`,{...e,cache:"no-store",headers:n});if(!r.ok){r.status===401&&r0(null);const o=(await r.json().catch(()=>({}))).detail,l=typeof o=="string"?o:o?JSON.stringify(o):`HTTP ${r.status}`;throw new Error(l)}const i=r.headers.get("content-length");if(!(r.status===204||i==="0"))return await r.json()}const ue={getAuthStatus:()=>Re("/auth/status"),setupAuth:t=>Re("/auth/setup",{method:"POST",body:JSON.stringify(t)}),login:t=>Re("/auth/login",{method:"POST",body:JSON.stringify(t)}),logout:()=>Re("/auth/logout",{method:"POST"}),getCurrentUser:()=>Re("/auth/me"),disableAuth:()=>Re("/auth/disable",{method:"POST"}),getUsers:()=>Re("/users/"),getUser:t=>Re(`/users/${t}`),createUser:t=>Re("/users/",{method:"POST",body:JSON.stringify(t)}),updateUser:(t,e)=>Re(`/users/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteUser:(t,e=!1)=>Re(`/users/${t}?delete_items=${e}`,{method:"DELETE"}),getUserItemsCount:t=>Re(`/users/${t}/items-count`),changePassword:(t,e)=>Re("/users/me/change-password",{method:"POST",body:JSON.stringify({current_password:t,new_password:e})}),getPermissions:()=>Re("/groups/permissions"),getGroups:()=>Re("/groups/"),getGroup:t=>Re(`/groups/${t}`),createGroup:t=>Re("/groups/",{method:"POST",body:JSON.stringify(t)}),updateGroup:(t,e)=>Re(`/groups/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteGroup:t=>Re(`/groups/${t}`,{method:"DELETE"}),addUserToGroup:(t,e)=>Re(`/groups/${t}/users/${e}`,{method:"POST"}),removeUserFromGroup:(t,e)=>Re(`/groups/${t}/users/${e}`,{method:"DELETE"}),getPrinters:()=>Re("/printers/"),getPrinter:t=>Re(`/printers/${t}`),createPrinter:t=>Re("/printers/",{method:"POST",body:JSON.stringify(t)}),updatePrinter:(t,e)=>Re(`/printers/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deletePrinter:(t,e=!0)=>Re(`/printers/${t}?delete_archives=${e}`,{method:"DELETE"}),getPrinterStatus:t=>Re(`/printers/${t}/status`),refreshPrinterStatus:t=>Re(`/printers/${t}/refresh-status`,{method:"POST"}),connectPrinter:t=>Re(`/printers/${t}/connect`,{method:"POST"}),disconnectPrinter:t=>Re(`/printers/${t}/disconnect`,{method:"POST"}),testExternalCamera:(t,e,n)=>Re(`/printers/${t}/camera/external/test?url=${encodeURIComponent(e)}&camera_type=${encodeURIComponent(n)}`,{method:"POST"}),stopPrint:t=>Re(`/printers/${t}/print/stop`,{method:"POST"}),pausePrint:t=>Re(`/printers/${t}/print/pause`,{method:"POST"}),resumePrint:t=>Re(`/printers/${t}/print/resume`,{method:"POST"}),getCurrentPrintUser:t=>Re(`/printers/${t}/current-print-user`),setChamberLight:(t,e)=>Re(`/printers/${t}/chamber-light?on=${e}`,{method:"POST"}),getPrintableObjects:t=>Re(`/printers/${t}/print/objects`),skipObjects:(t,e)=>Re(`/printers/${t}/print/skip-objects`,{method:"POST",body:JSON.stringify(e)}),refreshAmsSlot:(t,e,n)=>Re(`/printers/${t}/ams/${e}/slot/${n}/refresh`,{method:"POST"}),enableMQTTLogging:t=>Re(`/printers/${t}/logging/enable`,{method:"POST"}),disableMQTTLogging:t=>Re(`/printers/${t}/logging/disable`,{method:"POST"}),getMQTTLogs:t=>Re(`/printers/${t}/logging`),clearMQTTLogs:t=>Re(`/printers/${t}/logging`,{method:"DELETE"}),getPrinterFiles:(t,e="/")=>Re(`/printers/${t}/files?path=${encodeURIComponent(e)}`),getPrinterFileDownloadUrl:(t,e)=>`${pn}/printers/${t}/files/download?path=${encodeURIComponent(e)}`,downloadPrinterFilesAsZip:async(t,e)=>{const n={"Content-Type":"application/json"};Wn&&(n.Authorization=`Bearer ${Wn}`);const r=await fetch(`${pn}/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)=>Re(`/printers/${t}/files?path=${encodeURIComponent(e)}`,{method:"DELETE"}),getPrinterStorage:t=>Re(`/printers/${t}/storage`),getArchives:(t,e,n=50,r=0)=>{const i=new URLSearchParams;return t&&i.set("printer_id",String(t)),e&&i.set("project_id",String(e)),i.set("limit",String(n)),i.set("offset",String(r)),Re(`/archives/?${i}`)},getArchive:t=>Re(`/archives/${t}`),searchArchives:(t,e)=>{const n=new URLSearchParams;return n.set("q",t),e?.printerId&&n.set("printer_id",String(e.printerId)),e?.projectId&&n.set("project_id",String(e.projectId)),e?.status&&n.set("status",e.status),e?.limit&&n.set("limit",String(e.limit)),e?.offset&&n.set("offset",String(e.offset)),Re(`/archives/search?${n}`)},rebuildSearchIndex:()=>Re("/archives/search/rebuild-index",{method:"POST"}),updateArchive:(t,e)=>Re(`/archives/${t}`,{method:"PATCH",body:JSON.stringify(e)}),toggleFavorite:t=>Re(`/archives/${t}/favorite`,{method:"POST"}),deleteArchive:t=>Re(`/archives/${t}`,{method:"DELETE"}),getArchiveStats:()=>Re("/archives/stats"),getTags:()=>Re("/archives/tags"),renameTag:(t,e)=>Re(`/archives/tags/${encodeURIComponent(t)}`,{method:"PUT",body:JSON.stringify({new_name:e})}),deleteTag:t=>Re(`/archives/tags/${encodeURIComponent(t)}`,{method:"DELETE"}),recalculateCosts:()=>Re("/archives/recalculate-costs",{method:"POST"}),getFailureAnalysis:t=>{const e=new URLSearchParams;return t?.days&&e.set("days",String(t.days)),t?.printerId&&e.set("printer_id",String(t.printerId)),t?.projectId&&e.set("project_id",String(t.projectId)),Re(`/archives/analysis/failures?${e}`)},compareArchives:t=>Re(`/archives/compare?archive_ids=${t.join(",")}`),findSimilarArchives:(t,e=10)=>Re(`/archives/${t}/similar?limit=${e}`),exportArchives:async t=>{const e=new URLSearchParams;t?.format&&e.set("format",t.format),t?.fields&&e.set("fields",t.fields.join(",")),t?.printerId&&e.set("printer_id",String(t.printerId)),t?.projectId&&e.set("project_id",String(t.projectId)),t?.status&&e.set("status",t.status),t?.dateFrom&&e.set("date_from",t.dateFrom),t?.dateTo&&e.set("date_to",t.dateTo),t?.search&&e.set("search",t.search);const n={};Wn&&(n.Authorization=`Bearer ${Wn}`);const r=await fetch(`${pn}/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 a=t?.format==="xlsx"?"archives_export.xlsx":"archives_export.csv";if(i){const l=i.match(/filename="?([^"]+)"?/);l&&(a=l[1])}return{blob:await r.blob(),filename:a}},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={};Wn&&(n.Authorization=`Bearer ${Wn}`);const r=await fetch(`${pn}/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 a=t?.format==="xlsx"?"stats_export.xlsx":"stats_export.csv";if(i){const l=i.match(/filename="?([^"]+)"?/);l&&(a=l[1])}return{blob:await r.blob(),filename:a}},getArchiveDuplicates:t=>Re(`/archives/${t}/duplicates`),backfillContentHashes:()=>Re("/archives/backfill-hashes",{method:"POST"}),getArchiveThumbnail:t=>`${pn}/archives/${t}/thumbnail?v=${Date.now()}`,getArchivePlateThumbnail:(t,e)=>`${pn}/archives/${t}/plate-thumbnail/${e}`,getArchiveDownload:t=>`${pn}/archives/${t}/download`,getArchiveGcode:t=>`${pn}/archives/${t}/gcode`,getArchivePlatePreview:t=>`${pn}/archives/${t}/plate-preview`,getArchiveTimelapse:t=>`${pn}/archives/${t}/timelapse?v=${Date.now()}`,scanArchiveTimelapse:t=>Re(`/archives/${t}/timelapse/scan`,{method:"POST"}),selectArchiveTimelapse:(t,e)=>Re(`/archives/${t}/timelapse/select?filename=${encodeURIComponent(e)}`,{method:"POST"}),uploadArchiveTimelapse:async(t,e)=>{const n=new FormData;n.append("file",e);const r={};Wn&&(r.Authorization=`Bearer ${Wn}`);const i=await fetch(`${pn}/archives/${t}/timelapse/upload`,{method:"POST",headers:r,body:n});if(!i.ok){const a=await i.json().catch(()=>({}));throw new Error(a.detail||`HTTP ${i.status}`)}return i.json()},getTimelapseInfo:t=>Re(`/archives/${t}/timelapse/info`),getTimelapseThumbnails:(t,e=10)=>Re(`/archives/${t}/timelapse/thumbnails?count=${e}`),processTimelapse:async(t,e,n)=>{const r=new FormData;r.append("trim_start",String(e.trimStart??0)),e.trimEnd!==void 0&&r.append("trim_end",String(e.trimEnd)),r.append("speed",String(e.speed??1)),r.append("save_mode",e.saveMode),e.outputFilename&&r.append("output_filename",e.outputFilename),n&&r.append("audio",n);const i={};Wn&&(i.Authorization=`Bearer ${Wn}`);const a=await fetch(`${pn}/archives/${t}/timelapse/process`,{method:"POST",headers:i,body:r});if(!a.ok){const o=await a.json().catch(()=>({}));throw new Error(o.detail||`HTTP ${a.status}`)}return a.json()},getArchivePhotoUrl:(t,e)=>`${pn}/archives/${t}/photos/${encodeURIComponent(e)}`,uploadArchivePhoto:async(t,e)=>{const n=new FormData;n.append("file",e);const r={};Wn&&(r.Authorization=`Bearer ${Wn}`);const i=await fetch(`${pn}/archives/${t}/photos`,{headers:r,method:"POST",body:n});if(!i.ok){const a=await i.json().catch(()=>({}));throw new Error(a.detail||`HTTP ${i.status}`)}return i.json()},deleteArchivePhoto:(t,e)=>Re(`/archives/${t}/photos/${encodeURIComponent(e)}`,{method:"DELETE"}),getSource3mfDownloadUrl:t=>`${pn}/archives/${t}/source`,getSource3mfForSlicer:(t,e)=>`${pn}/archives/${t}/source/${encodeURIComponent(e.endsWith(".3mf")?e:e+".3mf")}`,uploadSource3mf:async(t,e)=>{const n=new FormData;n.append("file",e);const r={};Wn&&(r.Authorization=`Bearer ${Wn}`);const i=await fetch(`${pn}/archives/${t}/source`,{method:"POST",headers:r,body:n});if(!i.ok){const a=await i.json().catch(()=>({}));throw new Error(a.detail||`HTTP ${i.status}`)}return i.json()},deleteSource3mf:t=>Re(`/archives/${t}/source`,{method:"DELETE"}),getF3dDownloadUrl:t=>`${pn}/archives/${t}/f3d`,uploadF3d:async(t,e)=>{const n=new FormData;n.append("file",e);const r={};Wn&&(r.Authorization=`Bearer ${Wn}`);const i=await fetch(`${pn}/archives/${t}/f3d`,{method:"POST",headers:r,body:n});if(!i.ok){const a=await i.json().catch(()=>({}));throw new Error(a.detail||`HTTP ${i.status}`)}return i.json()},deleteF3d:t=>Re(`/archives/${t}/f3d`,{method:"DELETE"}),getArchiveQRCodeUrl:(t,e=200)=>`${pn}/archives/${t}/qrcode?size=${e}`,getArchiveCapabilities:t=>Re(`/archives/${t}/capabilities`),getArchiveProjectPage:t=>Re(`/archives/${t}/project-page`),updateArchiveProjectPage:(t,e)=>Re(`/archives/${t}/project-page`,{method:"PATCH",body:JSON.stringify(e)}),getArchiveProjectImageUrl:(t,e)=>`${pn}/archives/${t}/project-image/${encodeURIComponent(e)}`,getArchiveForSlicer:(t,e)=>`${pn}/archives/${t}/file/${encodeURIComponent(e.endsWith(".3mf")?e:e+".3mf")}`,getArchivePlates:t=>Re(`/archives/${t}/plates`),getArchiveFilamentRequirements:(t,e)=>Re(`/archives/${t}/filament-requirements${e!==void 0?`?plate_id=${e}`:""}`),reprintArchive:(t,e,n)=>Re(`/archives/${t}/reprint?printer_id=${e}`,{method:"POST",headers:n?{"Content-Type":"application/json"}:void 0,body:n?JSON.stringify(n):void 0}),uploadArchive:async(t,e)=>{const n=new FormData;n.append("file",t);const r=e?`${pn}/archives/upload?printer_id=${e}`:`${pn}/archives/upload`,i={};Wn&&(i.Authorization=`Bearer ${Wn}`);const a=await fetch(r,{method:"POST",headers:i,body:n});if(!a.ok){const o=await a.json().catch(()=>({}));throw new Error(o.detail||`HTTP ${a.status}`)}return a.json()},uploadArchivesBulk:async(t,e)=>{const n=new FormData;t.forEach(o=>n.append("files",o));const r=e?`${pn}/archives/upload-bulk?printer_id=${e}`:`${pn}/archives/upload-bulk`,i={};Wn&&(i.Authorization=`Bearer ${Wn}`);const a=await fetch(r,{method:"POST",headers:i,body:n});if(!a.ok){const o=await a.json().catch(()=>({}));throw new Error(o.detail||`HTTP ${a.status}`)}return a.json()},getSettings:()=>Re("/settings/"),updateSettings:t=>Re("/settings/",{method:"PUT",body:JSON.stringify(t)}),getMQTTStatus:()=>Re("/settings/mqtt/status"),resetSettings:()=>Re("/settings/reset",{method:"POST"}),exportBackup:async()=>{const t=`${pn}/settings/backup`,e=await fetch(t);if(!e.ok){const a=await e.text();throw new Error(a||`Backup failed with status ${e.status}`)}const n=e.headers.get("Content-Disposition");let r="bambuddy-backup.zip";if(n){const a=n.match(/filename=([^;]+)/);a&&(r=a[1].trim())}return{blob:await e.blob(),filename:r}},importBackup:async t=>{const e=new FormData;e.append("file",t);const n=`${pn}/settings/restore`,r={};return Wn&&(r.Authorization=`Bearer ${Wn}`),(await fetch(n,{method:"POST",headers:r,body:e})).json()},checkFfmpeg:()=>Re("/settings/check-ffmpeg"),getCloudStatus:()=>Re("/cloud/status"),cloudLogin:(t,e,n="global")=>Re("/cloud/login",{method:"POST",body:JSON.stringify({email:t,password:e,region:n})}),cloudVerify:(t,e,n)=>Re("/cloud/verify",{method:"POST",body:JSON.stringify({email:t,code:e,tfa_key:n})}),cloudSetToken:t=>Re("/cloud/token",{method:"POST",body:JSON.stringify({access_token:t})}),cloudLogout:()=>Re("/cloud/logout",{method:"POST"}),getCloudSettings:(t="02.04.00.70")=>Re(`/cloud/settings?version=${t}`),getCloudSettingDetail:t=>Re(`/cloud/settings/${t}`),createCloudSetting:t=>Re("/cloud/settings",{method:"POST",body:JSON.stringify(t)}),updateCloudSetting:(t,e)=>Re(`/cloud/settings/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteCloudSetting:t=>Re(`/cloud/settings/${t}`,{method:"DELETE"}),getCloudDevices:()=>Re("/cloud/devices"),getCloudFields:t=>Re(`/cloud/fields/${t}`),getAllCloudFields:()=>Re("/cloud/fields"),getFilamentInfo:t=>Re("/cloud/filament-info",{method:"POST",body:JSON.stringify(t)}),getSmartPlugs:()=>Re("/smart-plugs/"),getSmartPlug:t=>Re(`/smart-plugs/${t}`),getSmartPlugByPrinter:t=>Re(`/smart-plugs/by-printer/${t}`),getScriptPlugsByPrinter:t=>Re(`/smart-plugs/by-printer/${t}/scripts`),createSmartPlug:t=>Re("/smart-plugs/",{method:"POST",body:JSON.stringify(t)}),updateSmartPlug:(t,e)=>Re(`/smart-plugs/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteSmartPlug:t=>Re(`/smart-plugs/${t}`,{method:"DELETE"}),controlSmartPlug:(t,e)=>Re(`/smart-plugs/${t}/control`,{method:"POST",body:JSON.stringify({action:e})}),getSmartPlugStatus:t=>Re(`/smart-plugs/${t}/status`),testSmartPlugConnection:(t,e,n)=>Re("/smart-plugs/test-connection",{method:"POST",body:JSON.stringify({ip_address:t,username:e,password:n})}),startTasmotaScan:()=>fetch(`${pn}/smart-plugs/discover/scan`,{method:"POST"}).then(t=>t.ok?t.json():t.json().then(e=>{throw new Error(e.detail||`HTTP ${t.status}`)})),getTasmotaScanStatus:()=>Re("/smart-plugs/discover/status"),stopTasmotaScan:()=>fetch(`${pn}/smart-plugs/discover/stop`,{method:"POST"}).then(t=>t.ok?t.json():t.json().then(e=>{throw new Error(e.detail||`HTTP ${t.status}`)})),getDiscoveredTasmotaDevices:()=>Re("/smart-plugs/discover/devices"),testHAConnection:(t,e)=>Re("/smart-plugs/ha/test-connection",{method:"POST",body:JSON.stringify({url:t,token:e})}),getHAEntities:t=>{const e=t?`?search=${encodeURIComponent(t)}`:"";return Re(`/smart-plugs/ha/entities${e}`)},getHASensorEntities:()=>Re("/smart-plugs/ha/sensors"),getQueue:(t,e)=>{const n=new URLSearchParams;return t&&n.set("printer_id",String(t)),e&&n.set("status",e),Re(`/queue/?${n}`)},getQueueItem:t=>Re(`/queue/${t}`),addToQueue:t=>Re("/queue/",{method:"POST",body:JSON.stringify(t)}),updateQueueItem:(t,e)=>Re(`/queue/${t}`,{method:"PATCH",body:JSON.stringify(e)}),removeFromQueue:t=>Re(`/queue/${t}`,{method:"DELETE"}),reorderQueue:t=>Re("/queue/reorder",{method:"POST",body:JSON.stringify({items:t})}),cancelQueueItem:t=>Re(`/queue/${t}/cancel`,{method:"POST"}),stopQueueItem:t=>Re(`/queue/${t}/stop`,{method:"POST"}),startQueueItem:t=>Re(`/queue/${t}/start`,{method:"POST"}),bulkUpdateQueue:t=>Re("/queue/bulk",{method:"PATCH",body:JSON.stringify(t)}),getKProfiles:(t,e="0.4")=>Re(`/printers/${t}/kprofiles/?nozzle_diameter=${e}`),setKProfile:(t,e)=>Re(`/printers/${t}/kprofiles/`,{method:"POST",body:JSON.stringify(e)}),deleteKProfile:(t,e)=>Re(`/printers/${t}/kprofiles/`,{method:"DELETE",body:JSON.stringify(e)}),setKProfilesBatch:(t,e)=>Re(`/printers/${t}/kprofiles/batch`,{method:"POST",body:JSON.stringify(e)}),getKProfileNotes:t=>Re(`/printers/${t}/kprofiles/notes`),setKProfileNote:(t,e,n)=>Re(`/printers/${t}/kprofiles/notes`,{method:"PUT",body:JSON.stringify({setting_id:e,note:n})}),deleteKProfileNote:(t,e)=>Re(`/printers/${t}/kprofiles/notes/${encodeURIComponent(e)}`,{method:"DELETE"}),getSlotPresets:t=>Re(`/printers/${t}/slot-presets`),getSlotPreset:(t,e,n)=>Re(`/printers/${t}/slot-presets/${e}/${n}`),saveSlotPreset:(t,e,n,r,i)=>Re(`/printers/${t}/slot-presets/${e}/${n}?preset_id=${encodeURIComponent(r)}&preset_name=${encodeURIComponent(i)}`,{method:"PUT"}),deleteSlotPreset:(t,e,n)=>Re(`/printers/${t}/slot-presets/${e}/${n}`,{method:"DELETE"}),configureAmsSlot:(t,e,n,r)=>{const i=new URLSearchParams({tray_info_idx:r.tray_info_idx,tray_type:r.tray_type,tray_sub_brands:r.tray_sub_brands,tray_color:r.tray_color,nozzle_temp_min:r.nozzle_temp_min.toString(),nozzle_temp_max:r.nozzle_temp_max.toString(),cali_idx:r.cali_idx.toString(),nozzle_diameter:r.nozzle_diameter});return r.setting_id&&i.set("setting_id",r.setting_id),r.kprofile_filament_id&&i.set("kprofile_filament_id",r.kprofile_filament_id),r.kprofile_setting_id&&i.set("kprofile_setting_id",r.kprofile_setting_id),r.k_value!==void 0&&r.k_value>0&&i.set("k_value",r.k_value.toString()),Re(`/printers/${t}/slots/${e}/${n}/configure?${i}`,{method:"POST"})},resetAmsSlot:(t,e,n)=>Re(`/printers/${t}/ams/${e}/tray/${n}/reset`,{method:"POST"}),listFilaments:()=>Re("/filaments/"),getFilament:t=>Re(`/filaments/${t}`),getFilamentsByType:t=>Re(`/filaments/by-type/${t}`),getNotificationProviders:()=>Re("/notifications/"),getNotificationProvider:t=>Re(`/notifications/${t}`),createNotificationProvider:t=>Re("/notifications/",{method:"POST",body:JSON.stringify(t)}),updateNotificationProvider:(t,e)=>Re(`/notifications/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteNotificationProvider:t=>Re(`/notifications/${t}`,{method:"DELETE"}),testNotificationProvider:t=>Re(`/notifications/${t}/test`,{method:"POST"}),testNotificationConfig:t=>Re("/notifications/test-config",{method:"POST",body:JSON.stringify(t)}),testAllNotificationProviders:()=>Re("/notifications/test-all",{method:"POST"}),getNotificationTemplates:()=>Re("/notification-templates"),getNotificationTemplate:t=>Re(`/notification-templates/${t}`),updateNotificationTemplate:(t,e)=>Re(`/notification-templates/${t}`,{method:"PUT",body:JSON.stringify(e)}),resetNotificationTemplate:t=>Re(`/notification-templates/${t}/reset`,{method:"POST"}),getTemplateVariables:()=>Re("/notification-templates/variables"),previewTemplate:t=>Re("/notification-templates/preview",{method:"POST",body:JSON.stringify(t)}),getNotificationLogs:t=>{const e=new URLSearchParams;return t?.limit&&e.set("limit",String(t.limit)),t?.offset&&e.set("offset",String(t.offset)),t?.provider_id&&e.set("provider_id",String(t.provider_id)),t?.event_type&&e.set("event_type",t.event_type),t?.success!==void 0&&e.set("success",String(t.success)),t?.days&&e.set("days",String(t.days)),Re(`/notifications/logs?${e}`)},getNotificationLogStats:(t=7)=>Re(`/notifications/logs/stats?days=${t}`),clearNotificationLogs:(t=30)=>Re(`/notifications/logs?older_than_days=${t}`,{method:"DELETE"}),getSpoolmanStatus:()=>Re("/spoolman/status"),connectSpoolman:()=>Re("/spoolman/connect",{method:"POST"}),disconnectSpoolman:()=>Re("/spoolman/disconnect",{method:"POST"}),syncPrinterAms:t=>Re(`/spoolman/sync/${t}`,{method:"POST"}),syncAllPrintersAms:()=>Re("/spoolman/sync-all",{method:"POST"}),getSpoolmanSpools:()=>Re("/spoolman/spools"),getSpoolmanFilaments:()=>Re("/spoolman/filaments"),getUnlinkedSpools:()=>Re("/spoolman/spools/unlinked"),getLinkedSpools:()=>Re("/spoolman/spools/linked"),linkSpool:(t,e)=>Re(`/spoolman/spools/${t}/link`,{method:"POST",body:JSON.stringify({tray_uuid:e})}),getVersion:()=>Re("/updates/version"),checkForUpdates:()=>Re("/updates/check"),applyUpdate:()=>Re("/updates/apply",{method:"POST"}),getUpdateStatus:()=>Re("/updates/status"),getMaintenanceTypes:()=>Re("/maintenance/types"),createMaintenanceType:t=>Re("/maintenance/types",{method:"POST",body:JSON.stringify(t)}),updateMaintenanceType:(t,e)=>Re(`/maintenance/types/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteMaintenanceType:t=>Re(`/maintenance/types/${t}`,{method:"DELETE"}),getMaintenanceOverview:()=>Re("/maintenance/overview"),getPrinterMaintenance:t=>Re(`/maintenance/printers/${t}`),updateMaintenanceItem:(t,e)=>Re(`/maintenance/items/${t}`,{method:"PATCH",body:JSON.stringify(e)}),performMaintenance:(t,e)=>Re(`/maintenance/items/${t}/perform`,{method:"POST",body:JSON.stringify({notes:e})}),getMaintenanceHistory:t=>Re(`/maintenance/items/${t}/history`),getMaintenanceSummary:()=>Re("/maintenance/summary"),setPrinterHours:(t,e)=>Re(`/maintenance/printers/${t}/hours?total_hours=${e}`,{method:"PATCH"}),assignMaintenanceType:(t,e)=>Re(`/maintenance/printers/${t}/assign/${e}`,{method:"POST"}),removeMaintenanceItem:t=>Re(`/maintenance/items/${t}`,{method:"DELETE"}),getCameraStreamUrl:(t,e=10)=>`${pn}/printers/${t}/camera/stream?fps=${e}`,getCameraSnapshotUrl:t=>`${pn}/printers/${t}/camera/snapshot`,testCameraConnection:t=>Re(`/printers/${t}/camera/test`),checkPlateEmpty:(t,e)=>{const n=new URLSearchParams;return n.set("use_external",String(e?.useExternal??!1)),n.set("include_debug_image",String(e?.includeDebugImage??!1)),Re(`/printers/${t}/camera/check-plate?${n.toString()}`)},getPlateDetectionStatus:t=>Re(`/printers/${t}/camera/plate-detection/status`),calibratePlateDetection:(t,e)=>{const n=new URLSearchParams;return e?.label&&n.set("label",e.label),n.set("use_external",String(e?.useExternal??!1)),Re(`/printers/${t}/camera/plate-detection/calibrate?${n.toString()}`,{method:"POST"})},deletePlateCalibration:t=>Re(`/printers/${t}/camera/plate-detection/calibrate`,{method:"DELETE"}),getPlateReferences:t=>Re(`/printers/${t}/camera/plate-detection/references`),getPlateReferenceThumbnailUrl:(t,e)=>`${pn}/printers/${t}/camera/plate-detection/references/${e}/thumbnail`,updatePlateReferenceLabel:(t,e,n)=>{const r=new URLSearchParams;return r.set("label",n),Re(`/printers/${t}/camera/plate-detection/references/${e}?${r.toString()}`,{method:"PUT"})},deletePlateReference:(t,e)=>Re(`/printers/${t}/camera/plate-detection/references/${e}`,{method:"DELETE"}),getExternalLinks:()=>Re("/external-links/"),getExternalLink:t=>Re(`/external-links/${t}`),createExternalLink:t=>Re("/external-links/",{method:"POST",body:JSON.stringify(t)}),updateExternalLink:(t,e)=>Re(`/external-links/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteExternalLink:t=>Re(`/external-links/${t}`,{method:"DELETE"}),reorderExternalLinks:t=>Re("/external-links/reorder",{method:"PUT",body:JSON.stringify({ids:t})}),uploadExternalLinkIcon:async(t,e)=>{const n=new FormData;n.append("file",e);const r={};Wn&&(r.Authorization=`Bearer ${Wn}`);const i=await fetch(`${pn}/external-links/${t}/icon`,{method:"POST",headers:r,body:n});if(!i.ok){const a=await i.json().catch(()=>({}));throw new Error(a.detail||`HTTP ${i.status}`)}return i.json()},deleteExternalLinkIcon:t=>Re(`/external-links/${t}/icon`,{method:"DELETE"}),getExternalLinkIconUrl:t=>`${pn}/external-links/${t}/icon`,getProjects:t=>{const e=new URLSearchParams;return t&&e.set("status",t),Re(`/projects/?${e}`)},getProject:t=>Re(`/projects/${t}`),createProject:t=>Re("/projects/",{method:"POST",body:JSON.stringify(t)}),updateProject:(t,e)=>Re(`/projects/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteProject:t=>Re(`/projects/${t}`,{method:"DELETE"}),getProjectArchives:(t,e=100,n=0)=>Re(`/projects/${t}/archives?limit=${e}&offset=${n}`),addArchivesToProject:(t,e)=>Re(`/projects/${t}/add-archives`,{method:"POST",body:JSON.stringify({archive_ids:e})}),removeArchivesFromProject:(t,e)=>Re(`/projects/${t}/remove-archives`,{method:"POST",body:JSON.stringify({archive_ids:e})}),addQueueItemsToProject:(t,e)=>Re(`/projects/${t}/add-queue`,{method:"POST",body:JSON.stringify({queue_item_ids:e})}),uploadProjectAttachment:async(t,e)=>{const n=new FormData;n.append("file",e);const r={};Wn&&(r.Authorization=`Bearer ${Wn}`);const i=await fetch(`${pn}/projects/${t}/attachments`,{method:"POST",headers:r,body:n});if(!i.ok){const a=await i.json().catch(()=>({}));throw new Error(a.detail||`HTTP ${i.status}`)}return i.json()},getProjectAttachmentUrl:(t,e)=>`${pn}/projects/${t}/attachments/${encodeURIComponent(e)}`,deleteProjectAttachment:(t,e)=>Re(`/projects/${t}/attachments/${encodeURIComponent(e)}`,{method:"DELETE"}),getProjectBOM:t=>Re(`/projects/${t}/bom`),createBOMItem:(t,e)=>Re(`/projects/${t}/bom`,{method:"POST",body:JSON.stringify(e)}),updateBOMItem:(t,e,n)=>Re(`/projects/${t}/bom/${e}`,{method:"PATCH",body:JSON.stringify(n)}),deleteBOMItem:(t,e)=>Re(`/projects/${t}/bom/${e}`,{method:"DELETE"}),getTemplates:()=>Re("/projects/templates/"),createTemplateFromProject:t=>Re(`/projects/${t}/create-template`,{method:"POST"}),createProjectFromTemplate:(t,e)=>Re(`/projects/from-template/${t}${e?`?name=${encodeURIComponent(e)}`:""}`,{method:"POST"}),getProjectTimeline:(t,e=50)=>Re(`/projects/${t}/timeline?limit=${e}`),exportProjectJson:t=>Re(`/projects/${t}/export?format=json`),importProject:t=>Re("/projects/import",{method:"POST",body:JSON.stringify(t)}),getAPIKeys:()=>Re("/api-keys/"),createAPIKey:t=>Re("/api-keys/",{method:"POST",body:JSON.stringify(t)}),updateAPIKey:(t,e)=>Re(`/api-keys/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteAPIKey:t=>Re(`/api-keys/${t}`,{method:"DELETE"}),getAMSHistory:(t,e,n=24)=>Re(`/ams-history/${t}/${e}?hours=${n}`),getSystemInfo:()=>Re("/system/info"),getLibraryFolders:()=>Re("/library/folders"),createLibraryFolder:t=>Re("/library/folders",{method:"POST",body:JSON.stringify(t)}),updateLibraryFolder:(t,e)=>Re(`/library/folders/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteLibraryFolder:t=>Re(`/library/folders/${t}`,{method:"DELETE"}),getLibraryFoldersByProject:t=>Re(`/library/folders/by-project/${t}`),getLibraryFoldersByArchive:t=>Re(`/library/folders/by-archive/${t}`),getLibraryFiles:(t,e=!0)=>{const n=new URLSearchParams;return t!=null&&n.set("folder_id",String(t)),n.set("include_root",String(e)),Re(`/library/files?${n}`)},getLibraryFile:t=>Re(`/library/files/${t}`),uploadLibraryFile:async(t,e,n=!0)=>{const r=new FormData;r.append("file",t);const i=new URLSearchParams;e&&i.set("folder_id",String(e)),i.set("generate_stl_thumbnails",String(n));const a={};Wn&&(a.Authorization=`Bearer ${Wn}`);const o=await fetch(`${pn}/library/files?${i}`,{method:"POST",headers:a,body:r});if(!o.ok){const l=await o.json().catch(()=>({}));throw new Error(l.detail||`HTTP ${o.status}`)}return o.json()},extractZipFile:async(t,e,n=!0,r=!1,i=!0)=>{const a=new FormData;a.append("file",t);const o=new URLSearchParams;e&&o.set("folder_id",String(e)),o.set("preserve_structure",String(n)),o.set("create_folder_from_zip",String(r)),o.set("generate_stl_thumbnails",String(i));const l={};Wn&&(l.Authorization=`Bearer ${Wn}`);const c=await fetch(`${pn}/library/files/extract-zip?${o}`,{method:"POST",headers:l,body:a});if(!c.ok){const u=await c.json().catch(()=>({}));throw new Error(u.detail||`HTTP ${c.status}`)}return c.json()},updateLibraryFile:(t,e)=>Re(`/library/files/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteLibraryFile:t=>Re(`/library/files/${t}`,{method:"DELETE"}),getLibraryFileDownloadUrl:t=>`${pn}/library/files/${t}/download`,getLibraryFileThumbnailUrl:t=>`${pn}/library/files/${t}/thumbnail`,getLibraryFilePlateThumbnail:(t,e)=>`${pn}/library/files/${t}/plate-thumbnail/${e}`,getLibraryFileGcodeUrl:t=>`${pn}/library/files/${t}/gcode`,moveLibraryFiles:(t,e)=>Re("/library/files/move",{method:"POST",body:JSON.stringify({file_ids:t,folder_id:e})}),bulkDeleteLibrary:(t,e)=>Re("/library/bulk-delete",{method:"POST",body:JSON.stringify({file_ids:t,folder_ids:e})}),getLibraryStats:()=>Re("/library/stats"),batchGenerateStlThumbnails:t=>Re("/library/generate-stl-thumbnails",{method:"POST",body:JSON.stringify(t)}),addLibraryFilesToQueue:t=>Re("/library/files/add-to-queue",{method:"POST",body:JSON.stringify({file_ids:t})}),printLibraryFile:(t,e,n)=>Re(`/library/files/${t}/print?printer_id=${e}`,{method:"POST",body:n?JSON.stringify(n):void 0}),getLibraryFilePlates:t=>Re(`/library/files/${t}/plates`),getLibraryFileFilamentRequirements:(t,e)=>Re(`/library/files/${t}/filament-requirements${e!==void 0?`?plate_id=${e}`:""}`),getGitHubBackupConfig:()=>Re("/github-backup/config"),saveGitHubBackupConfig:t=>Re("/github-backup/config",{method:"POST",body:JSON.stringify(t)}),updateGitHubBackupConfig:t=>Re("/github-backup/config",{method:"PATCH",body:JSON.stringify(t)}),deleteGitHubBackupConfig:()=>Re("/github-backup/config",{method:"DELETE"}),testGitHubConnection:(t,e)=>Re(`/github-backup/test?repo_url=${encodeURIComponent(t)}&token=${encodeURIComponent(e)}`,{method:"POST"}),testGitHubStoredConnection:()=>Re("/github-backup/test-stored",{method:"POST"}),triggerGitHubBackup:()=>Re("/github-backup/run",{method:"POST"}),getGitHubBackupStatus:()=>Re("/github-backup/status"),getGitHubBackupLogs:(t=50)=>Re(`/github-backup/logs?limit=${t}`),clearGitHubBackupLogs:(t=10)=>Re(`/github-backup/logs?keep_last=${t}`,{method:"DELETE"})},Xl={getInfo:()=>Re("/discovery/info"),getStatus:()=>Re("/discovery/status"),startDiscovery:(t=10)=>Re(`/discovery/start?duration=${t}`,{method:"POST"}),stopDiscovery:()=>Re("/discovery/stop",{method:"POST"}),getDiscoveredPrinters:()=>Re("/discovery/printers"),startSubnetScan:(t,e=1)=>Re("/discovery/scan",{method:"POST",body:JSON.stringify({subnet:t,timeout:e})}),getScanStatus:()=>Re("/discovery/scan/status"),stopSubnetScan:()=>Re("/discovery/scan/stop",{method:"POST"})},p1={getSettings:()=>Re("/settings/virtual-printer"),getModels:()=>Re("/settings/virtual-printer/models"),updateSettings:t=>{const e=new URLSearchParams;return t.enabled!==void 0&&e.set("enabled",String(t.enabled)),t.access_code!==void 0&&e.set("access_code",t.access_code),t.mode!==void 0&&e.set("mode",t.mode),t.model!==void 0&&e.set("model",t.model),Re(`/settings/virtual-printer?${e.toString()}`,{method:"PUT"})}},ag={list:()=>Re("/pending-uploads/"),getCount:()=>Re("/pending-uploads/count"),get:t=>Re(`/pending-uploads/${t}`),archive:(t,e)=>Re(`/pending-uploads/${t}/archive`,{method:"POST",body:JSON.stringify(e||{})}),discard:t=>Re(`/pending-uploads/${t}`,{method:"DELETE"}),archiveAll:()=>Re("/pending-uploads/archive-all",{method:"POST"}),discardAll:()=>Re("/pending-uploads/discard-all",{method:"DELETE"})},g1={checkUpdates:()=>Re("/firmware/updates"),checkPrinterUpdate:t=>Re(`/firmware/updates/${t}`),prepareUpload:t=>Re(`/firmware/updates/${t}/prepare`),startUpload:t=>Re(`/firmware/updates/${t}/upload`,{method:"POST"}),getUploadStatus:t=>Re(`/firmware/updates/${t}/upload/status`)},Mg={getDebugLoggingState:()=>Re("/support/debug-logging"),setDebugLogging:t=>Re("/support/debug-logging",{method:"POST",body:JSON.stringify({enabled:t})}),downloadSupportBundle:async()=>{const t={};Wn&&(t.Authorization=`Bearer ${Wn}`);const e=await fetch(`${pn}/support/bundle`,{headers:t});if(!e.ok){const c=await e.json().catch(()=>({}));throw new Error(c.detail||`HTTP ${e.status}`)}const r=e.headers.get("Content-Disposition")?.match(/filename=(.+)/),i=r?r[1]:"bambuddy-support.zip",a=await e.blob(),o=window.URL.createObjectURL(a),l=document.createElement("a");l.href=o,l.download=i,document.body.appendChild(l),l.click(),document.body.removeChild(l),window.URL.revokeObjectURL(o)},getLogs:t=>{const e=new URLSearchParams;t?.limit&&e.set("limit",t.limit.toString()),t?.level&&e.set("level",t.level),t?.search&&e.set("search",t.search);const n=e.toString();return Re(`/support/logs${n?`?${n}`:""}`)},clearLogs:()=>Re("/support/logs",{method:"DELETE"})},jW=_.createContext(void 0);function vfe({children:t}){const[e,n]=_.useState(()=>{const E=localStorage.getItem("theme-mode"),D=localStorage.getItem("theme");return E||D||"dark"}),[r,i]=_.useState(()=>localStorage.getItem("dark-style")||"classic"),[a,o]=_.useState(()=>localStorage.getItem("dark-background")||"neutral"),[l,c]=_.useState(()=>localStorage.getItem("dark-accent")||"green"),[u,d]=_.useState(()=>localStorage.getItem("light-style")||"classic"),[f,p]=_.useState(()=>localStorage.getItem("light-background")||"neutral"),[m,x]=_.useState(()=>localStorage.getItem("light-accent")||"green");_.useEffect(()=>{ue.getSettings().then(E=>{E.dark_style&&(i(E.dark_style),localStorage.setItem("dark-style",E.dark_style)),E.dark_background&&(o(E.dark_background),localStorage.setItem("dark-background",E.dark_background)),E.dark_accent&&(c(E.dark_accent),localStorage.setItem("dark-accent",E.dark_accent)),E.light_style&&(d(E.light_style),localStorage.setItem("light-style",E.light_style)),E.light_background&&(p(E.light_background),localStorage.setItem("light-background",E.light_background)),E.light_accent&&(x(E.light_accent),localStorage.setItem("light-accent",E.light_accent))}).catch(()=>{})},[]),_.useEffect(()=>{const E=document.documentElement;E.classList.remove("dark","style-classic","style-glow","style-vibrant","bg-neutral","bg-warm","bg-cool","bg-oled","bg-slate","bg-forest","accent-green","accent-teal","accent-blue","accent-orange","accent-purple","accent-red"),e==="dark"?(E.classList.add("dark"),E.classList.add(`style-${r}`),E.classList.add(`bg-${a}`),E.classList.add(`accent-${l}`)):(E.classList.add(`style-${u}`),E.classList.add(`bg-${f}`),E.classList.add(`accent-${m}`)),localStorage.setItem("theme-mode",e),localStorage.removeItem("theme")},[e,r,a,l,u,f,m]);const b=()=>n(E=>E==="dark"?"light":"dark"),y=E=>n(E),v=E=>{i(E),localStorage.setItem("dark-style",E),ue.updateSettings({dark_style:E}).catch(()=>{})},S=E=>{o(E),localStorage.setItem("dark-background",E),ue.updateSettings({dark_background:E}).catch(()=>{})},N=E=>{c(E),localStorage.setItem("dark-accent",E),ue.updateSettings({dark_accent:E}).catch(()=>{})},T=E=>{d(E),localStorage.setItem("light-style",E),ue.updateSettings({light_style:E}).catch(()=>{})},k=E=>{p(E),localStorage.setItem("light-background",E),ue.updateSettings({light_background:E}).catch(()=>{})},C=E=>{x(E),localStorage.setItem("light-accent",E),ue.updateSettings({light_accent:E}).catch(()=>{})};return s.jsx(jW.Provider,{value:{mode:e,darkStyle:r,darkBackground:a,darkAccent:l,lightStyle:u,lightBackground:f,lightAccent:m,toggleMode:b,setMode:y,setDarkStyle:v,setDarkBackground:S,setDarkAccent:N,setLightStyle:T,setLightBackground:k,setLightAccent:C},children:t})}function Oh(){const t=_.useContext(jW);if(!t)throw new Error("useTheme must be used within ThemeProvider");return t}function _t({children:t,className:e="",onClick:n,onContextMenu:r,...i}){return s.jsx("div",{className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary card-shadow ${e}`,onClick:n,onContextMenu:r,...i,children:t})}function Kn({children:t,className:e=""}){return s.jsx("div",{className:`px-6 py-4 border-b border-bambu-dark-tertiary ${e}`,children:t})}function Mt({children:t,className:e=""}){return s.jsx("div",{className:`p-6 ${e}`,children:t})}function wfe(t,e,n){return[{category:"Navigation",items:t?t.slice(0,9).map((i,a)=>({keys:[String(a+1)],description:i.type==="external"?`Open ${i.label}`:`Go to ${i.labelKey?n(i.labelKey):i.label}`,isExternal:i.type==="external"})):e?e.map((i,a)=>({keys:[String(a+1)],description:`Go to ${n(i.labelKey)}`,isExternal:!1})):[{keys:["1"],description:"Go to Printers",isExternal:!1},{keys:["2"],description:"Go to Archives",isExternal:!1},{keys:["3"],description:"Go to Queue",isExternal:!1},{keys:["4"],description:"Go to Statistics",isExternal:!1},{keys:["5"],description:"Go to Cloud Profiles",isExternal:!1},{keys:["6"],description:"Go to Settings",isExternal:!1}]},{category:"Archives",items:[{keys:["/"],description:"Focus search",isExternal:!1},{keys:["U"],description:"Open upload modal",isExternal:!1},{keys:["Esc"],description:"Clear selection / blur input",isExternal:!1},{keys:["Right-click"],description:"Context menu on cards",isExternal:!1}]},{category:"K-Profiles",items:[{keys:["R"],description:"Refresh profiles",isExternal:!1},{keys:["N"],description:"New profile",isExternal:!1},{keys:["Esc"],description:"Exit selection mode",isExternal:!1}]},{category:"General",items:[{keys:["?"],description:"Show this help",isExternal:!1}]}]}function Fz({children:t}){return s.jsx("kbd",{className:"px-2 py-1 text-xs font-mono bg-bambu-dark border border-bambu-dark-tertiary rounded text-white",children:t})}function _fe({onClose:t,navItems:e,sidebarItems:n}){const{t:r}=Hn(),i=wfe(n,e,r);return _.useEffect(()=>{const a=o=>{o.key==="Escape"&&t()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[t]),s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:t,children:s.jsx(_t,{className:"w-full max-w-md",onClick:a=>a.stopPropagation(),children:s.jsxs(Mt,{className:"p-0",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(mP,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-xl font-semibold text-white",children:"Keyboard Shortcuts"})]}),s.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(Rt,{className:"w-5 h-5"})})]}),s.jsx("div",{className:"p-4 space-y-6 max-h-[60vh] overflow-y-auto",children:i.map(a=>s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-3",children:a.category}),s.jsx("div",{className:"space-y-2",children:a.items.map(o=>s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("span",{className:"text-white text-sm flex items-center gap-1.5",children:[o.description,o.isExternal&&s.jsx(Kr,{className:"w-3 h-3 text-bambu-gray"})]}),s.jsx("div",{className:"flex gap-1",children:o.keys.map(l=>s.jsx(Fz,{children:l},l))})]},o.description))})]},a.category))}),s.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:s.jsxs("p",{className:"text-xs text-bambu-gray text-center",children:["Press ",s.jsx(Fz,{children:"Esc"})," or click outside to close"]})})]})})})}function Te({variant:t="primary",size:e="md",className:n="",children:r,...i}){const a="inline-flex items-center justify-center font-medium rounded-lg transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-bambu-dark disabled:opacity-50 disabled:cursor-not-allowed",o={primary:"bg-bambu-green hover:bg-bambu-green-light text-white focus:ring-bambu-green",secondary:"bg-bambu-dark-tertiary hover:bg-bambu-gray-dark text-white focus:ring-bambu-gray",danger:"bg-red-600 hover:bg-red-700 text-white focus:ring-red-500",ghost:"bg-transparent hover:bg-bambu-dark-tertiary text-bambu-gray-light hover:text-white"},l={sm:"px-3 py-1.5 text-sm gap-1.5 min-h-[44px] md:min-h-0",md:"px-4 py-2 text-sm gap-2 min-h-[44px] md:min-h-0",lg:"px-6 py-3 text-base gap-2 min-h-[48px] md:min-h-0"};return s.jsx("button",{className:`${a} ${o[t]} ${l[e]} ${n}`,...i,children:r})}function Zn({title:t,message:e,confirmText:n,cancelText:r,variant:i="default",isLoading:a=!1,loadingText:o,onConfirm:l,onCancel:c}){const{t:u}=Hn(),d=n??u("common.confirm"),f=r??u("common.cancel"),p=o??u("common.loading");_.useEffect(()=>{const b=y=>{y.key==="Escape"&&!a&&c()};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[c,a]);const x={danger:{icon:"text-red-400",button:"bg-red-500 hover:bg-red-600"},warning:{icon:"text-yellow-400",button:"bg-yellow-500 hover:bg-yellow-600"},default:{icon:"text-bambu-green",button:"bg-bambu-green hover:bg-bambu-green-dark"}}[i];return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:a?void 0:c,children:s.jsx(_t,{className:"w-full max-w-md",onClick:b=>b.stopPropagation(),children:s.jsxs(Mt,{className:"p-6",children:[s.jsxs("div",{className:"flex items-start gap-4",children:[s.jsx("div",{className:`p-2 rounded-full bg-bambu-dark ${x.icon}`,children:s.jsx(Cn,{className:"w-6 h-6"})}),s.jsxs("div",{className:"flex-1",children:[s.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:t}),s.jsx("p",{className:"text-bambu-gray text-sm",children:e})]})]}),s.jsxs("div",{className:"flex gap-3 mt-6",children:[s.jsx(Te,{variant:"secondary",onClick:c,className:"flex-1",disabled:a,children:f}),s.jsx(Te,{onClick:l,className:`flex-1 ${x.button}`,disabled:a,children:a?s.jsxs(s.Fragment,{children:[s.jsx(ht,{className:"w-4 h-4 mr-2 animate-spin"}),p]}):d})]})]})})})}function Sfe({plug:t}){const e=an(),[n,r]=_.useState(null),{data:i,isLoading:a}=at({queryKey:["smart-plug-status",t.id],queryFn:()=>ue.getSmartPlugStatus(t.id),refetchInterval:1e4}),o=mt({mutationFn:m=>ue.controlSmartPlug(t.id,m),onSuccess:()=>{e.invalidateQueries({queryKey:["smart-plug-status",t.id]})}}),l=i?.state==="ON",c=t.plug_type==="mqtt"&&i?.energy?.power!==null&&i?.energy?.power!==void 0,u=(i?.reachable??!1)||c,d=o.isPending,f=t.plug_type==="mqtt",p=()=>{n&&(o.mutate(n),r(null))};return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center justify-between py-2 px-3 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:`p-1.5 rounded ${f?u?"bg-teal-500/20":"bg-red-500/20":u?l?"bg-bambu-green/20":"bg-bambu-dark":"bg-red-500/20"}`,children:f?s.jsx(jR,{className:`w-4 h-4 ${u?"text-teal-400":"text-red-400"}`}):s.jsx(tl,{className:`w-4 h-4 ${u?l?"text-bambu-green":"text-bambu-gray":"text-red-400"}`})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white font-medium",children:t.name}),s.jsx("div",{className:"flex items-center gap-1 text-xs",children:a?s.jsx(ht,{className:"w-3 h-3 text-bambu-gray animate-spin"}):f?u?s.jsxs(s.Fragment,{children:[s.jsx(vh,{className:"w-3 h-3 text-teal-400"}),s.jsxs("span",{className:"text-teal-400",children:[Math.round(i?.energy?.power??0),"W"]}),s.jsx("span",{className:"text-bambu-gray mx-1",children:"|"}),s.jsx(Ru,{className:"w-3 h-3 text-bambu-gray"}),s.jsx("span",{className:"text-bambu-gray",children:"Monitor"})]}):s.jsxs(s.Fragment,{children:[s.jsx(sm,{className:"w-3 h-3 text-status-error"}),s.jsx("span",{className:"text-status-error",children:"Waiting"})]}):u?s.jsxs(s.Fragment,{children:[s.jsx(Sg,{className:"w-3 h-3 text-status-ok"}),s.jsx("span",{className:l?"text-status-ok":"text-bambu-gray",children:i?.state||"Unknown"}),i?.energy?.power!==null&&i?.energy?.power!==void 0&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-bambu-gray mx-1",children:"|"}),s.jsx(vh,{className:"w-3 h-3 text-yellow-400"}),s.jsxs("span",{className:"text-yellow-400",children:[Math.round(i.energy.power),"W"]})]})]}):s.jsxs(s.Fragment,{children:[s.jsx(sm,{className:"w-3 h-3 text-status-error"}),s.jsx("span",{className:"text-status-error",children:"Offline"})]})})]})]}),!f&&s.jsxs("div",{className:"flex gap-1",children:[s.jsx("button",{onClick:()=>r("on"),disabled:!u||d,className:`p-1.5 rounded transition-colors ${l?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"} disabled:opacity-50 disabled:cursor-not-allowed`,title:"Turn On",children:d?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(Gu,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>r("off"),disabled:!u||d,className:`p-1.5 rounded transition-colors ${!l&&u?"bg-bambu-dark-tertiary text-white":"bg-bambu-dark text-bambu-gray hover:text-white"} disabled:opacity-50 disabled:cursor-not-allowed`,title:"Turn Off",children:d?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(gN,{className:"w-4 h-4"})})]})]}),n&&s.jsx(Zn,{title:`Turn ${n==="on"?"On":"Off"} Smart Plug`,message:`Are you sure you want to turn ${n==="on"?"on":"off"} "${t.name}"?`,confirmText:n==="on"?"Turn On":"Turn Off",variant:n==="off"?"warning":"default",onConfirm:p,onCancel:()=>r(null)})]})}function Iz({onClose:t}){const{data:e,isLoading:n}=at({queryKey:["smart-plugs"],queryFn:ue.getSmartPlugs}),r=e?.filter(i=>i.show_in_switchbar)||[];return s.jsxs("div",{className:"absolute bottom-full left-0 mb-2 w-72 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl shadow-xl z-50",onMouseLeave:t,children:[s.jsx("div",{className:"px-4 py-3 border-b border-bambu-dark-tertiary",children:s.jsxs("h3",{className:"text-sm font-semibold text-white flex items-center gap-2",children:[s.jsx(tl,{className:"w-4 h-4 text-bambu-green"}),"Smart Switches"]})}),s.jsx("div",{className:"p-2 max-h-80 overflow-y-auto",children:n?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx(ht,{className:"w-6 h-6 text-bambu-gray animate-spin"})}):r.length===0?s.jsxs("div",{className:"text-center py-6 px-4",children:[s.jsx(tl,{className:"w-8 h-8 text-bambu-gray mx-auto mb-2"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"No switches in switchbar"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:'Enable "Show in Switchbar" in Settings > Smart Plugs'})]}):s.jsx("div",{className:"space-y-1",children:r.map(i=>s.jsx(Sfe,{plug:i},i.id))})})]})}const PW=[{name:"globe",icon:sh},{name:"link",icon:Fy},{name:"external-link",icon:Kr},{name:"book",icon:yce},{name:"file-text",icon:Ls},{name:"home",icon:fN},{name:"star",icon:im},{name:"heart",icon:ide},{name:"bookmark",icon:wce},{name:"shopping-cart",icon:NW},{name:"music",icon:bP},{name:"video",icon:OR},{name:"image",icon:Ou},{name:"camera",icon:Ug},{name:"map",icon:Cde},{name:"compass",icon:lue},{name:"coffee",icon:iue},{name:"gift",icon:que},{name:"wrench",icon:om},{name:"zap",icon:vh},{name:"cloud",icon:oN},{name:"database",icon:Nu},{name:"folder",icon:xW},{name:"mail",icon:Tde},{name:"phone",icon:ehe},{name:"user",icon:am},{name:"users",icon:mg},{name:"server",icon:yf},{name:"terminal",icon:TW},{name:"code",icon:pW}];function yN(t){return PW.find(n=>n.name===t)?.icon||Fy}function Mfe({value:t,onChange:e}){const[n,r]=_.useState(!1),i=yN(t);return s.jsxs("div",{className:"relative",children:[s.jsxs("button",{type:"button",onClick:()=>r(!n),className:"flex items-center gap-2 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white hover:border-bambu-gray focus:border-bambu-green focus:outline-none w-full",children:[s.jsx(i,{className:"w-5 h-5"}),s.jsx("span",{className:"text-sm text-bambu-gray flex-1 text-left",children:t})]}),n&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>r(!1)}),s.jsx("div",{className:"absolute z-50 mt-1 w-full max-h-64 overflow-y-auto bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg",children:s.jsx("div",{className:"grid grid-cols-5 gap-1 p-2",children:PW.map(({name:a,icon:o})=>s.jsx("button",{type:"button",onClick:()=>{e(a),r(!1)},className:`p-2 rounded-lg transition-colors flex items-center justify-center ${t===a?"bg-bambu-green text-white":"hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:a,children:s.jsx(o,{className:"w-5 h-5"})},a))})})]})]})}const Uz=768;function IR(){const[t,e]=_.useState(()=>typeof window<"u"?window.innerWidth<Uz:!1);return _.useEffect(()=>{const n=window.matchMedia(`(max-width: ${Uz-1}px)`),r=i=>{e(i.matches)};return e(n.matches),n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[]),t}const DW=_.createContext(void 0);function Nfe({children:t}){const[e,n]=_.useState(null),[r,i]=_.useState(!1),[a,o]=_.useState(!1),[l,c]=_.useState(!0),u=_.useRef(!1),d=_.useRef(!0),f=async()=>{try{const C=await ue.getAuthStatus();if(!d.current)return;if(i(C.auth_enabled),o(C.requires_setup),C.auth_enabled)if(Lz())try{const D=await ue.getCurrentUser();if(!d.current)return;n(D)}catch{if(r0(null),!d.current)return;n(null)}else n(null);else n(null)}catch{if(!d.current)return;i(!1),n(null)}finally{d.current&&c(!1)}};_.useEffect(()=>(d.current=!0,f(),()=>{d.current=!1}),[]),_.useEffect(()=>{if(!l&&a&&!r){const C=window.location.pathname;C!=="/setup"&&!C.startsWith("/camera/")&&!u.current&&(u.current=!0,window.location.href="/setup")}else a||(u.current=!1)},[l,a,r]);const p=async(C,E)=>{const D=await ue.login({username:C,password:E});r0(D.access_token),n(D.user)},m=()=>{r0(null),n(null),ue.logout().catch(()=>{}),window.location.href="/login"},x=async()=>{if(r&&Lz())try{const C=await ue.getCurrentUser();d.current&&n(C)}catch{r0(null),d.current&&n(null)}},b=async()=>{await f()},y=_.useMemo(()=>new Set(e?.permissions??[]),[e?.permissions]),v=_.useMemo(()=>r?e?.is_admin??!1:!0,[r,e?.is_admin]),S=_.useCallback(C=>!r||v?!0:y.has(C),[r,v,y]),N=_.useCallback((...C)=>!r||v?!0:C.some(E=>y.has(E)),[r,v,y]),T=_.useCallback((...C)=>!r||v?!0:C.every(E=>y.has(E)),[r,v,y]),k=_.useCallback((C,E,D)=>{if(!r||v)return!0;const A=`${C}:${E}_all`,R=`${C}:${E}_own`;return y.has(A)?!0:y.has(R)?D==null?!1:D===e?.id:!1},[r,v,y,e?.id]);return s.jsx(DW.Provider,{value:{user:e,authEnabled:r,requiresSetup:a,loading:l,isAdmin:v,login:p,logout:m,refreshUser:x,refreshAuth:b,hasPermission:S,hasAnyPermission:N,hasAllPermissions:T,canModify:k},children:t})}function Ai(){const t=_.useContext(DW);if(t===void 0)throw new Error("useAuth must be used within an AuthProvider");return t}const RW=_.createContext(void 0);function $n(){const t=_.useContext(RW);if(!t)throw new Error("useToast must be used within a ToastProvider");return t}const kfe={success:s.jsx(Ar,{className:"w-5 h-5 text-green-400"}),error:s.jsx(Yi,{className:"w-5 h-5 text-red-400"}),warning:s.jsx(Hi,{className:"w-5 h-5 text-yellow-400"}),info:s.jsx(Zo,{className:"w-5 h-5 text-blue-400"}),loading:s.jsx(ht,{className:"w-5 h-5 text-bambu-green animate-spin"})},Efe={success:"bg-green-500/10 border-green-500/30",error:"bg-red-500/10 border-red-500/30",warning:"bg-yellow-500/10 border-yellow-500/30",info:"bg-blue-500/10 border-blue-500/30",loading:"bg-bambu-green/10 border-bambu-green/30"};function Tfe({children:t}){const[e,n]=_.useState([]),r=_.useCallback((o,l="success")=>{const c=Math.random().toString(36).substr(2,9);n(u=>[...u,{id:c,message:o,type:l}]),setTimeout(()=>{n(u=>u.filter(d=>d.id!==c))},3e3)},[]),i=_.useCallback((o,l,c="info")=>{n(u=>u.find(f=>f.id===o)?u.map(f=>f.id===o?{...f,message:l,type:c,persistent:!0}:f):[...u,{id:o,message:l,type:c,persistent:!0}])},[]),a=_.useCallback(o=>{n(l=>l.filter(c=>c.id!==o))},[]);return s.jsxs(RW.Provider,{value:{showToast:r,showPersistentToast:i,dismissToast:a},children:[t,s.jsx("div",{className:"fixed bottom-4 right-4 z-50 flex flex-col gap-2",children:e.map(o=>s.jsxs("div",{className:`flex items-center gap-3 px-4 py-3 rounded-lg border shadow-lg backdrop-blur-sm animate-slide-in ${Efe[o.type]}`,children:[kfe[o.type],s.jsx("span",{className:"text-white text-sm",children:o.message}),s.jsx("button",{onClick:()=>a(o.id),className:"ml-2 text-bambu-gray hover:text-white transition-colors",children:s.jsx(Rt,{className:"w-4 h-4"})})]},o.id))})]})}const K0=[{id:"printers",to:"/",icon:Ur,labelKey:"nav.printers"},{id:"archives",to:"/archives",icon:fo,labelKey:"nav.archives"},{id:"queue",to:"/queue",icon:si,labelKey:"nav.queue"},{id:"stats",to:"/stats",icon:Rce,labelKey:"nav.stats"},{id:"profiles",to:"/profiles",icon:oN,labelKey:"nav.profiles"},{id:"maintenance",to:"/maintenance",icon:om,labelKey:"nav.maintenance"},{id:"projects",to:"/projects",icon:Ja,labelKey:"nav.projects"},{id:"files",to:"/files",icon:Il,labelKey:"nav.files"},{id:"settings",to:"/settings",icon:xN,labelKey:"nav.settings"}];function Afe(){const t=localStorage.getItem("sidebarOrder");if(t)try{return JSON.parse(t)}catch{return K0.map(e=>e.id)}return K0.map(e=>e.id)}function Cfe(t){localStorage.setItem("sidebarOrder",JSON.stringify(t))}function iT(t){return t.startsWith("ext-")}function OW(){return localStorage.getItem("defaultView")||"/"}function jfe(t){localStorage.setItem("defaultView",t)}function Pfe(){const t=Nc(),e=Mc(),{mode:n,toggleMode:r}=Oh(),{t:i}=Hn(),a=IR(),{user:o,authEnabled:l,logout:c,hasPermission:u}=Ai(),{showToast:d}=$n(),[f,p]=_.useState(!1),[m,x]=_.useState({currentPassword:"",newPassword:"",confirmPassword:""}),[b,y]=_.useState(!1),[v,S]=_.useState(()=>localStorage.getItem("sidebarExpanded")!=="false"),[N,T]=_.useState(!1),[k,C]=_.useState(!1),[E,D]=_.useState(!1),[A,R]=_.useState(Afe),[U,F]=_.useState(null),[$,j]=_.useState(null),H=_.useRef(!1),[K,V]=_.useState(()=>sessionStorage.getItem("dismissedUpdateVersion")),[Q,Z]=_.useState(null),{data:ae}=at({queryKey:["version"],queryFn:ue.getVersion,staleTime:1/0}),{data:B}=at({queryKey:["settings"],queryFn:ue.getSettings,staleTime:300*1e3}),{data:X}=at({queryKey:["updateCheck"],queryFn:ue.checkForUpdates,enabled:B?.check_updates!==!1,staleTime:3600*1e3,refetchInterval:3600*1e3}),{data:ne}=at({queryKey:["external-links"],queryFn:ue.getExternalLinks}),{data:se}=at({queryKey:["smart-plugs"],queryFn:ue.getSmartPlugs,staleTime:30*1e3}),be=se?.some(O=>O.show_in_switchbar)??!1,{data:xe}=at({queryKey:["debugLogging"],queryFn:Mg.getDebugLoggingState,staleTime:60*1e3,refetchInterval:60*1e3}),{data:de}=at({queryKey:["queue","pending"],queryFn:()=>ue.getQueue(void 0,"pending"),staleTime:5*1e3,refetchInterval:5*1e3,refetchOnWindowFocus:!0}),Pe=de?.length??0,{data:ie}=at({queryKey:["pending-uploads","count"],queryFn:ag.getCount,staleTime:5*1e3,refetchInterval:5*1e3,refetchOnWindowFocus:!0}),Ne=ie?.count??0,[Oe,ge]=_.useState(null);_.useEffect(()=>{if(!xe?.enabled||!xe.enabled_at){ge(null);return}const O=new Date(xe.enabled_at).getTime(),ee=()=>{ge(Math.floor((Date.now()-O)/1e3))};ee();const le=setInterval(ee,1e3);return()=>clearInterval(le)},[xe?.enabled,xe?.enabled_at]);const Ke=_.useMemo(()=>new Map(K0.map(O=>[O.id,O])),[]),G=_.useMemo(()=>new Map((ne||[]).map(O=>[`ext-${O.id}`,O])),[ne]),Y=(()=>{const O=[],ee=new Set,le=l&&o?.role==="user";for(const _e of A)le&&_e==="settings"||(Ke.has(_e)||G.has(_e))&&(O.push(_e),ee.add(_e));for(const _e of K0)le&&_e.id==="settings"||ee.has(_e.id)||(O.push(_e.id),ee.add(_e.id));for(const _e of ne||[]){const we=`ext-${_e.id}`;ee.has(we)||(O.push(we),ee.add(we))}return O})(),ce=(O,ee)=>{F(ee),O.dataTransfer.effectAllowed="move",O.dataTransfer.setData("text/plain",ee)},q=(O,ee)=>{O.preventDefault(),O.dataTransfer.dropEffect="move",j(ee)},te=()=>{j(null)},I=(O,ee)=>{if(O.preventDefault(),U===null||U===ee){F(null),j(null);return}const le=[...Y],_e=le.indexOf(U),we=le.indexOf(ee);if(_e===-1||we===-1){F(null),j(null);return}le.splice(_e,1),le.splice(we,0,U),R(le),Cfe(le),F(null),j(null)},fe=()=>{F(null),j(null)},me=X?.update_available&&X.latest_version&&X.latest_version!==K,Ee=()=>{X?.latest_version&&(sessionStorage.setItem("dismissedUpdateVersion",X.latest_version),V(X.latest_version))};_.useEffect(()=>{if(!H.current&&e.pathname==="/"){const O=OW();O!=="/"&&(H.current=!0,t(O,{replace:!0}))}},[e.pathname,t]),_.useEffect(()=>{localStorage.setItem("sidebarExpanded",String(v))},[v]),_.useEffect(()=>{a&&T(!1)},[e.pathname,a]),_.useEffect(()=>{const O=ee=>{const le=ee.detail;Z({printer_id:le.printer_id,printer_name:le.printer_name,message:le.message})};return window.addEventListener("plate-not-empty",O),()=>window.removeEventListener("plate-not-empty",O)},[]);const z=_.useCallback(O=>{const ee=O.target;if(!(ee.tagName==="INPUT"||ee.tagName==="TEXTAREA"||ee.isContentEditable)&&!O.metaKey&&!O.ctrlKey&&!O.altKey){const le=parseInt(O.key);if(le>=1&&le<=Y.length&&le<=9){const _e=Y[le-1];if(O.preventDefault(),iT(_e)){const we=_e.replace("ext-","");t(`/external/${we}`)}else{const we=Ke.get(_e);we&&t(we.to)}return}switch(O.key){case"?":O.preventDefault(),C(!0);break;case"Escape":C(!1);break}}},[t,Y,Ke]);return _.useEffect(()=>(document.addEventListener("keydown",z),()=>document.removeEventListener("keydown",z)),[z]),s.jsxs("div",{className:"flex min-h-screen",children:[a&&s.jsxs("header",{className:"fixed top-0 left-0 right-0 z-40 h-14 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary flex items-center px-4",children:[s.jsx("button",{onClick:()=>T(!0),className:"p-2 -ml-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors","aria-label":"Open menu",children:s.jsx(Fde,{className:"w-6 h-6 text-white"})}),s.jsx("img",{src:n==="dark"?"/img/bambuddy_logo_dark_transparent.png":"/img/bambuddy_logo_light.png",alt:"Bambuddy",className:"h-8 ml-3"})]}),a&&N&&s.jsx("div",{className:"fixed inset-0 bg-black/60 z-40 transition-opacity",onClick:()=>T(!1)}),s.jsxs("aside",{className:`bg-bambu-dark-secondary border-r border-bambu-dark-tertiary flex flex-col transition-all duration-300 ${a?`fixed inset-y-0 left-0 z-50 w-72 transform ${N?"translate-x-0":"-translate-x-full"}`:`fixed inset-y-0 left-0 z-30 ${v?"w-64":"w-16"}`}`,children:[s.jsx("div",{className:`border-b border-bambu-dark-tertiary flex items-center justify-center ${a||v?"p-4":"p-2"}`,children:s.jsx("img",{src:n==="dark"?"/img/bambuddy_logo_dark_transparent.png":"/img/bambuddy_logo_light.png",alt:"Bambuddy",className:a||v?"h-16 w-auto":"h-8 w-8 object-cover object-left"})}),s.jsx("nav",{className:"flex-1 p-2",children:s.jsx("ul",{className:"space-y-2",children:Y.map(O=>{if(iT(O)){const le=G.get(O);if(!le)return null;const _e=le.custom_icon?null:yN(le.icon);return s.jsx("li",{draggable:!0,onDragStart:we=>ce(we,O),onDragOver:we=>q(we,O),onDragLeave:te,onDrop:we=>I(we,O),onDragEnd:fe,className:`relative ${U===O?"opacity-50":""} ${$===O&&U!==O?"before:absolute before:left-0 before:right-0 before:top-0 before:h-0.5 before:bg-bambu-green":""}`,children:s.jsxs(n0,{to:`/external/${le.id}`,className:({isActive:we})=>`flex items-center ${a||v?"gap-3 px-4":"justify-center px-2"} py-3 rounded-lg transition-colors group ${we?"bg-bambu-green text-white":"text-bambu-gray-light hover:bg-bambu-dark-tertiary hover:text-white"}`,title:!a&&!v?le.name:void 0,children:[v&&!a&&s.jsx(zg,{className:"w-4 h-4 flex-shrink-0 opacity-0 group-hover:opacity-50 cursor-grab active:cursor-grabbing -ml-1"}),le.custom_icon?s.jsx("img",{src:`/api/v1/external-links/${le.id}/icon`,alt:"",className:`w-5 h-5 flex-shrink-0 ${n==="dark"?"invert opacity-[0.65]":"opacity-60"}`}):_e&&s.jsx(_e,{className:"w-5 h-5 flex-shrink-0"}),(a||v)&&s.jsx("span",{children:le.name})]})},O)}else{const le=Ke.get(O);if(!le)return null;const{to:_e,icon:we,labelKey:re}=le,Fe=O==="queue"&&Pe>0,He=O==="archives"&&Ne>0,Ve=Fe?Pe:He?Ne:0,$e=Fe||He;return s.jsx("li",{draggable:!0,onDragStart:ye=>ce(ye,O),onDragOver:ye=>q(ye,O),onDragLeave:te,onDrop:ye=>I(ye,O),onDragEnd:fe,className:`relative ${U===O?"opacity-50":""} ${$===O&&U!==O?"before:absolute before:left-0 before:right-0 before:top-0 before:h-0.5 before:bg-bambu-green":""}`,children:s.jsxs(n0,{to:_e,className:({isActive:ye})=>`flex items-center ${a||v?"gap-3 px-4":"justify-center px-2"} py-3 rounded-lg transition-colors group ${ye?"bg-bambu-green text-white":"text-bambu-gray-light hover:bg-bambu-dark-tertiary hover:text-white"}`,title:!a&&!v?i(re):void 0,children:[v&&!a&&s.jsx(zg,{className:"w-4 h-4 flex-shrink-0 opacity-0 group-hover:opacity-50 cursor-grab active:cursor-grabbing -ml-1"}),s.jsxs("div",{className:"relative",children:[s.jsx(we,{className:"w-5 h-5 flex-shrink-0"}),$e&&s.jsx("span",{className:`absolute -top-1.5 -right-1.5 min-w-[18px] h-[18px] px-1 flex items-center justify-center text-[10px] font-bold rounded-full ${He?"bg-blue-500 text-white":"bg-yellow-500 text-black"}`,children:Ve>99?"99+":Ve})]}),(a||v)&&s.jsx("span",{children:i(re)})]})},O)}})})}),!a&&s.jsx("button",{onClick:()=>S(!v),className:"p-2 mx-2 mb-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white flex items-center justify-center",title:i(v?"nav.collapseSidebar":"nav.expandSidebar"),children:v?s.jsx(gh,{className:"w-5 h-5"}):s.jsx(gs,{className:"w-5 h-5"})}),s.jsx("div",{className:"p-2 border-t border-bambu-dark-tertiary",children:a||v?s.jsxs("div",{className:"flex flex-col gap-2 px-2",children:[s.jsxs("div",{className:"flex items-center justify-center gap-1",children:[be&&s.jsxs("div",{className:"relative",children:[s.jsx("button",{onMouseEnter:()=>D(!0),className:`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${E?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.smartSwitches",{defaultValue:"Smart Switches"}),children:s.jsx(tl,{className:"w-5 h-5"})}),E&&s.jsx(Iz,{onClose:()=>D(!1)})]}),u("system:read")?s.jsx(n0,{to:"/system",className:({isActive:O})=>`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${O?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.system"),children:s.jsx(Zo,{className:"w-5 h-5"})}):s.jsx("span",{className:"p-2 rounded-lg text-bambu-gray/50 cursor-not-allowed",title:"You do not have permission to view system information",children:s.jsx(Zo,{className:"w-5 h-5"})}),s.jsx("a",{href:"https://github.com/maziggy/bambuddy",target:"_blank",rel:"noopener noreferrer",className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("nav.viewOnGithub"),children:s.jsx(fP,{className:"w-5 h-5"})}),s.jsx("button",{onClick:()=>C(!0),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("nav.keyboardShortcuts"),children:s.jsx(mP,{className:"w-5 h-5"})}),s.jsx("button",{onClick:r,className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i(n==="dark"?"nav.switchToLight":"nav.switchToDark"),children:n==="dark"?s.jsx(Oz,{className:"w-5 h-5"}):s.jsx(W1,{className:"w-5 h-5"})}),l&&o&&s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:()=>p(!0),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("changePassword.title"),children:s.jsx($o,{className:"w-5 h-5"})}),s.jsx("button",{onClick:c,className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("nav.logout",{defaultValue:"Logout"}),children:s.jsx(gP,{className:"w-5 h-5"})})]})]}),s.jsxs("div",{className:"flex items-center justify-center gap-2",children:[s.jsxs("span",{className:"text-sm text-bambu-gray",children:["v",ae?.version||"..."]}),X?.update_available&&s.jsxs("button",{onClick:()=>t("/settings"),className:"flex items-center gap-1 text-xs text-bambu-green hover:text-bambu-green/80 transition-colors",title:i("nav.updateAvailable",{version:X.latest_version}),children:[s.jsx(JE,{className:"w-4 h-4"}),s.jsx("span",{children:i("nav.update")})]})]})]}):s.jsxs("div",{className:"flex flex-col items-center gap-1",children:[X?.update_available&&s.jsx("button",{onClick:()=>t("/settings"),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-green hover:text-bambu-green/80",title:i("nav.updateAvailable",{version:X.latest_version}),children:s.jsx(JE,{className:"w-5 h-5"})}),be&&s.jsxs("div",{className:"relative",children:[s.jsx("button",{onMouseEnter:()=>D(!0),className:`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${E?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.smartSwitches",{defaultValue:"Smart Switches"}),children:s.jsx(tl,{className:"w-5 h-5"})}),E&&s.jsx(Iz,{onClose:()=>D(!1)})]}),u("system:read")?s.jsx(n0,{to:"/system",className:({isActive:O})=>`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${O?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.system"),children:s.jsx(Zo,{className:"w-5 h-5"})}):s.jsx("span",{className:"p-2 rounded-lg text-bambu-gray/50 cursor-not-allowed",title:"You do not have permission to view system information",children:s.jsx(Zo,{className:"w-5 h-5"})}),s.jsx("a",{href:"https://github.com/maziggy/bambuddy",target:"_blank",rel:"noopener noreferrer",className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("nav.viewOnGithub"),children:s.jsx(fP,{className:"w-5 h-5"})}),s.jsx("button",{onClick:()=>C(!0),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("nav.keyboardShortcuts"),children:s.jsx(mP,{className:"w-5 h-5"})}),s.jsx("button",{onClick:r,className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i(n==="dark"?"nav.switchToLight":"nav.switchToDark"),children:n==="dark"?s.jsx(Oz,{className:"w-5 h-5"}):s.jsx(W1,{className:"w-5 h-5"})}),l&&o&&s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:()=>p(!0),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("changePassword.title"),children:s.jsx($o,{className:"w-5 h-5"})}),s.jsx("button",{onClick:c,className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("nav.logout",{defaultValue:"Logout"}),children:s.jsx(gP,{className:"w-5 h-5"})})]})]})})]}),s.jsxs("main",{className:`flex-1 bg-bambu-dark overflow-auto transition-all duration-300 ${a?"mt-14":v?"ml-64":"ml-16"}`,children:[xe?.enabled&&s.jsx("div",{className:"bg-amber-500/20 border-b border-amber-500/30 px-4 py-2 flex items-center justify-between",children:s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx(aN,{className:"w-4 h-4 text-amber-500 animate-pulse"}),s.jsxs("span",{className:"text-amber-200",children:[i("support.debugLoggingActive",{defaultValue:"Debug logging is active"}),Oe!==null&&s.jsxs("span",{className:"text-amber-300/70 ml-2",children:["(",Math.floor(Oe/60),"m ",Oe%60,"s)"]})]}),s.jsx("button",{onClick:()=>t("/system"),className:"text-amber-400 hover:text-amber-300 font-medium underline ml-2",children:i("support.manageLogs",{defaultValue:"Manage"})})]})}),me&&s.jsxs("div",{className:"bg-bambu-green/20 border-b border-bambu-green/30 px-4 py-2 flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx(JE,{className:"w-4 h-4 text-bambu-green"}),s.jsx("span",{children:i("nav.updateAvailableBanner",{version:X?.latest_version,defaultValue:`Version ${X?.latest_version} is available!`})}),s.jsx("button",{onClick:()=>t("/settings"),className:"text-bambu-green hover:text-bambu-green/80 font-medium underline",children:i("nav.viewUpdate",{defaultValue:"View update"})})]}),s.jsx("button",{onClick:Ee,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:i("common.dismiss",{defaultValue:"Dismiss"}),children:s.jsx(Rt,{className:"w-4 h-4"})})]}),s.jsx(zoe,{})]}),k&&s.jsx(_fe,{onClose:()=>C(!1),sidebarItems:Y.map(O=>{if(iT(O)){const ee=G.get(O);return ee?{type:"external",label:ee.name}:null}else{const ee=Ke.get(O);return ee?{type:"nav",label:ee.labelKey,labelKey:ee.labelKey}:null}}).filter(Boolean)}),Q&&s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-[100] p-4",children:s.jsx("div",{className:"bg-bambu-dark-secondary border-2 border-yellow-500 rounded-xl shadow-2xl max-w-md w-full animate-in fade-in zoom-in duration-200",children:s.jsxs("div",{className:"p-6 text-center",children:[s.jsx("div",{className:"w-16 h-16 mx-auto mb-4 rounded-full bg-yellow-500/20 flex items-center justify-center",children:s.jsx("svg",{className:"w-10 h-10 text-yellow-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})})}),s.jsx("h2",{className:"text-xl font-bold text-yellow-400 mb-2",children:i("plateAlert.title")}),s.jsx("p",{className:"text-lg text-white mb-2",children:Q.printer_name}),s.jsx("p",{className:"text-bambu-gray mb-6",children:i("plateAlert.message")}),s.jsx("button",{onClick:()=>Z(null),className:"w-full py-3 px-6 bg-yellow-500 hover:bg-yellow-600 text-black font-semibold rounded-lg transition-colors",children:i("plateAlert.understand")})]})})}),f&&s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:()=>{p(!1),x({currentPassword:"",newPassword:"",confirmPassword:""})},children:s.jsxs(_t,{className:"w-full max-w-md",onClick:O=>O.stopPropagation(),children:[s.jsx(Kn,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx($o,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:i("changePassword.title")})]}),s.jsx(Te,{variant:"ghost",size:"sm",onClick:()=>{p(!1),x({currentPassword:"",newPassword:"",confirmPassword:""})},children:s.jsx(Rt,{className:"w-5 h-5"})})]})}),s.jsxs(Mt,{children:[s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:i("changePassword.currentPassword")}),s.jsx("input",{type:"password",value:m.currentPassword,onChange:O=>x({...m,currentPassword:O.target.value}),className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:i("changePassword.currentPasswordPlaceholder"),autoComplete:"current-password"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:i("changePassword.newPassword")}),s.jsx("input",{type:"password",value:m.newPassword,onChange:O=>x({...m,newPassword:O.target.value}),className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:i("changePassword.newPasswordPlaceholder"),autoComplete:"new-password",minLength:6})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:i("changePassword.confirmPassword")}),s.jsx("input",{type:"password",value:m.confirmPassword,onChange:O=>x({...m,confirmPassword:O.target.value}),className:`w-full px-4 py-3 bg-bambu-dark-secondary border rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors ${m.confirmPassword&&m.newPassword!==m.confirmPassword?"border-red-500":"border-bambu-dark-tertiary"}`,placeholder:i("changePassword.confirmPasswordPlaceholder"),autoComplete:"new-password",minLength:6}),m.confirmPassword&&m.newPassword!==m.confirmPassword&&s.jsx("p",{className:"text-red-400 text-xs mt-1",children:i("changePassword.passwordsDoNotMatch")})]})]}),s.jsxs("div",{className:"mt-6 flex justify-end gap-3",children:[s.jsx(Te,{variant:"secondary",onClick:()=>{p(!1),x({currentPassword:"",newPassword:"",confirmPassword:""})},children:i("common.cancel")}),s.jsx(Te,{onClick:async()=>{if(m.newPassword!==m.confirmPassword){d(i("changePassword.passwordsDoNotMatch"),"error");return}if(m.newPassword.length<6){d(i("changePassword.passwordTooShort"),"error");return}y(!0);try{await ue.changePassword(m.currentPassword,m.newPassword),d(i("changePassword.success"),"success"),p(!1),x({currentPassword:"",newPassword:"",confirmPassword:""})}catch(O){const ee=O instanceof Error?O.message:i("changePassword.failed");d(ee,"error")}finally{y(!1)}},disabled:b||!m.currentPassword||!m.newPassword||m.newPassword!==m.confirmPassword||m.newPassword.length<6,children:b?s.jsxs(s.Fragment,{children:[s.jsx(ht,{className:"w-4 h-4 animate-spin"}),i("changePassword.changing")]}):s.jsxs(s.Fragment,{children:[s.jsx($o,{className:"w-4 h-4"}),i("changePassword.title")]})})]})]})]})})]})}function y0(t,e="system"){return e==="12h"?t.hour12=!0:e==="24h"&&(t.hour12=!1),t}function Ii(t){return t?t.endsWith("Z")||/[+-]\d{2}:\d{2}$/.test(t)?new Date(t):new Date(t+"Z"):null}function Bg(t,e){const n=Ii(t);if(!n)return"";const r={year:"numeric",month:"short",day:"numeric"};return n.toLocaleDateString(void 0,e??r)}function Hg(t,e="system",n){const r=Ii(t);if(!r)return"";const a=y0(n??{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"},e);return r.toLocaleString(void 0,a)}function Dfe(t,e="system",n){const i=y0({...{hour:"2-digit",minute:"2-digit"},...n},e);return t.toLocaleTimeString([],i)}function Rfe(t){if(t===0)return"0 B";const e=1024,n=["B","KB","MB","GB"],r=Math.floor(Math.log(t)/Math.log(e));return`${parseFloat((t/Math.pow(e,r)).toFixed(1))} ${n[r]}`}function zz(t){if(t===0)return"0 GB";const e=t/(1024*1024*1024);return e>=1?`${e.toFixed(1)} GB`:`${(t/(1024*1024)).toFixed(0)} MB`}function Ofe(t,e){if(e)return xW;switch(t.toLowerCase().split(".").pop()||""){case"3mf":return zf;case"gcode":return Ls;case"mp4":case"avi":return ah;case"png":case"jpg":case"jpeg":return Ou;default:return cN}}const Lfe=[{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 Ffe({printerId:t,printerName:e,onClose:n}){const{t:r}=Hn(),{showToast:i}=$n(),a=an(),[o,l]=_.useState("/"),[c,u]=_.useState(new Set),[d,f]=_.useState(""),[p,m]=_.useState([]),[x,b]=_.useState("name-asc"),[y,v]=_.useState(null);_.useEffect(()=>{const H=K=>{K.key==="Escape"&&n()};return window.addEventListener("keydown",H),()=>window.removeEventListener("keydown",H)},[n]);const{data:S,isLoading:N,refetch:T}=at({queryKey:["printerFiles",t,o],queryFn:()=>ue.getPrinterFiles(t,o)}),{data:k}=at({queryKey:["printerStorage",t],queryFn:()=>ue.getPrinterStorage(t),staleTime:3e4}),C=mt({mutationFn:async H=>{for(const K of H)await ue.deletePrinterFile(t,K)},onSuccess:()=>{i(r("printerFiles.toast.filesDeleted",{count:p.length})),a.invalidateQueries({queryKey:["printerFiles",t]}),u(new Set),m([])},onError:H=>{i(r("printerFiles.toast.deleteFailed",{error:H.message}),"error")}}),E=H=>{l(H),u(new Set)},D=()=>{if(o==="/")return;const H=o.split("/").filter(Boolean);H.pop(),l(H.length?"/"+H.join("/"):"/"),u(new Set)},A=(H,K)=>{K.stopPropagation(),u(V=>{const Q=new Set(V);return Q.has(H)?Q.delete(H):Q.add(H),Q})},R=()=>{if(!S?.files)return;const H=S.files.filter(K=>!K.is_directory&&(!d||K.name.toLowerCase().includes(d.toLowerCase()))).map(K=>K.path);u(new Set(H))},U=()=>{u(new Set)},F=async()=>{if(c.size===0)return;const H=Array.from(c);if(H.length===1){window.open(ue.getPrinterFileDownloadUrl(t,H[0]),"_blank"),u(new Set);return}v({current:0,total:H.length});try{const K=await ue.downloadPrinterFilesAsZip(t,H),V=URL.createObjectURL(K),Q=document.createElement("a");Q.href=V,Q.download=`${e.replace(/[^a-zA-Z0-9]/g,"_")}-files.zip`,document.body.appendChild(Q),Q.click(),document.body.removeChild(Q),URL.revokeObjectURL(V),i(`Downloaded ${H.length} files as ZIP`),u(new Set)}catch(K){i(`Download failed: ${K instanceof Error?K.message:"Unknown error"}`,"error")}finally{v(null)}},$=()=>{c.size!==0&&m(Array.from(c))},j=[{path:"/",label:"Root"},{path:"/cache",label:"Cache"},{path:"/model",label:"Models"},{path:"/timelapse",label:"Timelapse"}];return s.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:n,children:[s.jsxs("div",{className:"w-full max-w-3xl max-h-[85vh] flex flex-col bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary overflow-hidden",onClick:H=>H.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary flex-shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(hN,{className:"w-5 h-5 text-bambu-green"}),s.jsxs("div",{children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:r("printerFiles.title")}),s.jsx("p",{className:"text-sm text-bambu-gray",children:e})]})]}),s.jsxs("div",{className:"flex items-center gap-4",children:[k&&(k.used_bytes!=null||k.free_bytes!=null)&&s.jsxs("div",{className:"text-sm text-bambu-gray flex items-center gap-2",children:[k.used_bytes!=null&&s.jsxs("span",{children:[r("printerFiles.storageUsed")," ",zz(k.used_bytes)]}),k.used_bytes!=null&&k.free_bytes!=null&&s.jsx("span",{className:"text-bambu-dark-tertiary",children:"|"}),k.free_bytes!=null&&s.jsxs("span",{children:[r("printerFiles.storageFree")," ",zz(k.free_bytes)]})]}),s.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(Rt,{className:"w-5 h-5"})})]})]}),s.jsxs("div",{className:"flex items-center gap-2 p-3 border-b border-bambu-dark-tertiary bg-bambu-dark/50 flex-shrink-0",children:[j.map(H=>s.jsx("button",{onClick:()=>{E(H.path),f("")},className:`px-3 py-1 text-sm rounded-full transition-colors ${o===H.path?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,children:H.label},H.path)),s.jsx("div",{className:"flex-1"}),s.jsxs("div",{className:"relative",children:[s.jsx(ba,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",placeholder:r("printerFiles.filterPlaceholder"),value:d,onChange:H=>f(H.target.value),className:"w-40 pl-8 pr-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{className:"relative flex items-center gap-1",children:[s.jsx(fW,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("select",{value:x,onChange:H=>b(H.target.value),className:"appearance-none bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm py-1.5 pl-2 pr-6 focus:border-bambu-green focus:outline-none cursor-pointer",children:Lfe.map(H=>s.jsx("option",{value:H.value,children:H.label},H.value))})]}),s.jsx(Te,{variant:"secondary",size:"sm",onClick:()=>T(),disabled:N,children:s.jsx(Dr,{className:`w-4 h-4 ${N?"animate-spin":""}`})})]}),s.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-bambu-dark text-sm flex-shrink-0",children:[s.jsx("button",{onClick:D,disabled:o==="/",className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-50 disabled:cursor-not-allowed",children:s.jsx(gh,{className:"w-4 h-4"})}),s.jsx("span",{className:"text-bambu-gray font-mono",children:o})]}),s.jsx("div",{className:"flex-1 overflow-y-auto p-2 min-h-0",children:N?s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx(ht,{className:"w-8 h-8 text-bambu-green animate-spin"})}):S?.files?.length?s.jsx("div",{className:"space-y-1",children:[...S.files].filter(H=>!d||H.name.toLowerCase().includes(d.toLowerCase())).sort((H,K)=>{if(H.is_directory&&!K.is_directory)return-1;if(!H.is_directory&&K.is_directory)return 1;switch(x){case"name-asc":return H.name.localeCompare(K.name);case"name-desc":return K.name.localeCompare(H.name);case"size-asc":return H.size-K.size;case"size-desc":return K.size-H.size;case"date-asc":{const V=H.mtime?new Date(H.mtime).getTime():0,Q=K.mtime?new Date(K.mtime).getTime():0;return V-Q}case"date-desc":{const V=H.mtime?new Date(H.mtime).getTime():0;return(K.mtime?new Date(K.mtime).getTime():0)-V}default:return H.name.localeCompare(K.name)}}).map(H=>{const K=Ofe(H.name,H.is_directory),V=c.has(H.path);return s.jsxs("div",{className:`flex items-center gap-3 p-2 rounded-lg cursor-pointer transition-colors ${V?"bg-bambu-green/20 border border-bambu-green/50":"hover:bg-bambu-dark-tertiary"}`,onClick:()=>{H.is_directory&&E(H.path)},children:[H.is_directory?null:s.jsx("button",{onClick:Q=>A(H.path,Q),className:"flex-shrink-0 text-bambu-gray hover:text-white",children:V?s.jsx(ol,{className:"w-5 h-5 text-bambu-green"}):s.jsx(ll,{className:"w-5 h-5"})}),s.jsx(K,{className:`w-5 h-5 flex-shrink-0 ${H.is_directory?"text-bambu-green":"text-bambu-gray"}`}),s.jsx("span",{className:"flex-1 text-white truncate",children:H.name}),!H.is_directory&&s.jsx("span",{className:"text-sm text-bambu-gray",children:Rfe(H.size)}),H.is_directory&&s.jsx(gh,{className:"w-4 h-4 text-bambu-gray rotate-180"})]},H.path)})}):s.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"No files in this directory"})}),s.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary bg-bambu-dark/50 flex-shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx("div",{className:"text-sm text-bambu-gray",children:c.size>0?`${c.size} selected`:d?`${S?.files?.filter(H=>H.name.toLowerCase().includes(d.toLowerCase())).length||0} of ${S?.files?.length||0} items`:`${S?.files?.length||0} items`}),S?.files?.some(H=>!H.is_directory)&&s.jsx("div",{className:"flex items-center gap-2",children:c.size>0?s.jsxs("button",{onClick:U,className:"flex items-center gap-1 text-xs text-bambu-gray hover:text-white transition-colors",children:[s.jsx(Dhe,{className:"w-4 h-4"}),"Deselect All"]}):s.jsxs("button",{onClick:R,className:"flex items-center gap-1 text-xs text-bambu-gray hover:text-white transition-colors",children:[s.jsx(ol,{className:"w-4 h-4"}),"Select All"]})})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Te,{variant:"secondary",disabled:c.size===0||y!==null,onClick:F,children:y?s.jsxs(s.Fragment,{children:[s.jsx(ht,{className:"w-4 h-4 animate-spin"}),y.current,"/",y.total]}):s.jsxs(s.Fragment,{children:[s.jsx(yi,{className:"w-4 h-4"}),"Download",c.size>1?` (${c.size})`:""]})}),s.jsxs(Te,{variant:"secondary",disabled:c.size===0||C.isPending,onClick:$,className:"text-red-400 hover:text-red-300",children:[C.isPending?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(rn,{className:"w-4 h-4"}),r("printerFiles.deleteButton"),c.size>1?` (${c.size})`:""]})]})]})]}),p.length>0&&s.jsx(Zn,{title:p.length>1?r("printerFiles.deleteFiles",{count:p.length}):r("fileManager.deleteFile"),message:p.length>1?r("printerFiles.deleteFilesConfirm",{count:p.length}):r("printerFiles.deleteFileConfirm",{name:p[0].split("/").pop()}),confirmText:r("common.delete"),variant:"danger",onConfirm:()=>{C.mutate(p)},onCancel:()=>m([])})]})}const Ife="embeddedCameraState_",Bz=5,Ufe=2e3,zfe=3e4,Bfe=5e3,aT={x:window.innerWidth-420,y:20,width:400,height:300};function Hfe({printerId:t,printerName:e,viewerIndex:n=0,onClose:r}){const i=`${Ife}${t}`,a=()=>{try{const je=localStorage.getItem(i);if(je){const Be=JSON.parse(je);return{x:Math.min(Math.max(0,Be.x),window.innerWidth-100),y:Math.min(Math.max(0,Be.y),window.innerHeight-100),width:Math.max(200,Math.min(Be.width,window.innerWidth-20)),height:Math.max(150,Math.min(Be.height,window.innerHeight-20))}}}catch{}const ye=n*30;return{...aT,x:Math.max(0,aT.x-ye),y:Math.max(0,aT.y+ye)}},[o,l]=_.useState(a),[c,u]=_.useState(!1),[d,f]=_.useState(!1),[p,m]=_.useState({x:0,y:0}),[x,b]=_.useState(!1),[y,v]=_.useState(!1),[S,N]=_.useState(1),[T,k]=_.useState({x:0,y:0}),[C,E]=_.useState(!1),[D,A]=_.useState({x:0,y:0}),[R,U]=_.useState(null),[F,$]=_.useState(null),[j,H]=_.useState(!1),[K,V]=_.useState(!0),[Q,Z]=_.useState(Date.now()),[ae,B]=_.useState(0),[X,ne]=_.useState(!1),[se,be]=_.useState(0),xe=_.useRef(null),de=_.useRef(null),Pe=_.useRef(null),ie=_.useRef(null),Ne=_.useRef(null),{data:Oe}=at({queryKey:["printer",t],queryFn:()=>ue.getPrinter(t),enabled:t>0});_.useEffect(()=>{const ye=setTimeout(()=>{localStorage.setItem(i,JSON.stringify(o))},500);return()=>clearTimeout(ye)},[o,i]);const ge=_.useRef(!1);_.useEffect(()=>{ge.current=!1;const ye=`/api/v1/printers/${t}/camera/stop`,je=()=>{t>0&&!ge.current&&(ge.current=!0,navigator.sendBeacon(ye))},Be=de.current;return()=>{Be&&(Be.src=""),je(),Pe.current&&clearTimeout(Pe.current),ie.current&&clearInterval(ie.current),Ne.current&&clearInterval(Ne.current)}},[t]),_.useEffect(()=>{if(K){const ye=setTimeout(()=>V(!1),3e3);return()=>clearTimeout(ye)}},[K,Q]);const Ke=_.useCallback(()=>{if(ae>=Bz){ne(!1),H(!0);return}const ye=Math.min(Ufe*Math.pow(2,ae),zfe);ne(!0),be(Math.ceil(ye/1e3)),ie.current=setInterval(()=>{be(je=>je<=1?(ie.current&&clearInterval(ie.current),0):je-1)},1e3),Pe.current=setTimeout(()=>{B(je=>je+1),ne(!1),V(!0),H(!1),de.current&&(de.current.src=""),Z(Date.now())},ye)},[ae]);_.useEffect(()=>{if(K||X||x){Ne.current&&(clearInterval(Ne.current),Ne.current=null);return}return Ne.current=setInterval(async()=>{try{const ye=await fetch(`/api/v1/printers/${t}/camera/status`);if(ye.ok){const je=await ye.json();(je.stalled||!je.active&&!j)&&(Ne.current&&(clearInterval(Ne.current),Ne.current=null),V(!1),Ke())}}catch{}},Bfe),()=>{Ne.current&&(clearInterval(Ne.current),Ne.current=null)}},[K,j,X,x,t,Ke]),_.useEffect(()=>{const ye=()=>{const je=!!document.fullscreenElement;v(je),je||(N(1),k({x:0,y:0}))};return document.addEventListener("fullscreenchange",ye),()=>document.removeEventListener("fullscreenchange",ye)},[]);const G=()=>{xe.current&&(document.fullscreenElement?document.exitFullscreen():xe.current.requestFullscreen())},Y=()=>{N(ye=>Math.min(ye+.5,4))},ce=()=>{N(ye=>{const je=Math.max(ye-.5,1);return je===1&&k({x:0,y:0}),je})},q=ye=>{ye.preventDefault(),ye.deltaY<0?Y():ce()},te=ye=>{S>1&&(ye.preventDefault(),E(!0),A({x:ye.clientX-T.x,y:ye.clientY-T.y}))},I=_.useCallback(()=>{if(!xe.current||!de.current)return{x:200,y:150};const ye=xe.current.getBoundingClientRect(),je=ye.width*(S-1)/2,Be=ye.height*(S-1)/2;return{x:Math.max(50,je),y:Math.max(50,Be)}},[S]),fe=ye=>{if(C&&S>1){const je=ye.clientX-D.x,Be=ye.clientY-D.y,Se=I();k({x:Math.max(-Se.x,Math.min(Se.x,je)),y:Math.max(-Se.y,Math.min(Se.y,Be))})}},me=()=>{E(!1)},Ee=ye=>{if(ye.length<2)return 0;const je=ye[0].clientX-ye[1].clientX,Be=ye[0].clientY-ye[1].clientY;return Math.sqrt(je*je+Be*Be)},z=ye=>ye.length<2?{x:ye[0].clientX,y:ye[0].clientY}:{x:(ye[0].clientX+ye[1].clientX)/2,y:(ye[0].clientY+ye[1].clientY)/2},O=ye=>{ye.touches.length===2?(ye.preventDefault(),U(Ee(ye.touches)),$(z(ye.touches))):ye.touches.length===1&&S>1&&(ye.preventDefault(),E(!0),A({x:ye.touches[0].clientX-T.x,y:ye.touches[0].clientY-T.y}))},ee=ye=>{if(ye.touches.length===2&&R!==null){ye.preventDefault();const je=Ee(ye.touches),Be=je/R;N(Xe=>{const Me=Math.max(1,Math.min(4,Xe*Be));return Me===1&&k({x:0,y:0}),Me}),U(je);const Se=z(ye.touches);if(F){const Xe=I();k(Me=>({x:Math.max(-Xe.x,Math.min(Xe.x,Me.x+(Se.x-F.x))),y:Math.max(-Xe.y,Math.min(Xe.y,Me.y+(Se.y-F.y)))}))}$(Se)}else if(ye.touches.length===1&&C&&S>1){ye.preventDefault();const je=ye.touches[0].clientX-D.x,Be=ye.touches[0].clientY-D.y,Se=I();k({x:Math.max(-Se.x,Math.min(Se.x,je)),y:Math.max(-Se.y,Math.min(Se.y,Be))})}},le=ye=>{ye.touches.length<2&&(U(null),$(null)),ye.touches.length===0&&E(!1)},_e=()=>{N(1),k({x:0,y:0})},we=()=>{V(!1),ae<Bz?Ke():H(!0)},re=()=>{V(!1),H(!1),B(0),ne(!1),Pe.current&&clearTimeout(Pe.current),ie.current&&clearInterval(ie.current)},Fe=()=>{V(!0),H(!1),B(0),ne(!1),Pe.current&&clearTimeout(Pe.current),ie.current&&clearInterval(ie.current),fetch(`/api/v1/printers/${t}/camera/stop`).catch(()=>{}),de.current&&(de.current.src=""),setTimeout(()=>Z(Date.now()),100)},He=ye=>{ye.target.closest(".no-drag")||(u(!0),m({x:ye.clientX-o.x,y:ye.clientY-o.y}))},Ve=ye=>{ye.stopPropagation(),f(!0)};_.useEffect(()=>{const ye=Be=>{if(c)l(Se=>({...Se,x:Math.max(0,Math.min(Be.clientX-p.x,window.innerWidth-Se.width)),y:Math.max(0,Math.min(Be.clientY-p.y,window.innerHeight-Se.height))}));else if(d&&xe.current){const Se=xe.current.getBoundingClientRect();l(Xe=>({...Xe,width:Math.max(200,Math.min(Be.clientX-Se.left,window.innerWidth-Xe.x-10)),height:Math.max(150,Math.min(Be.clientY-Se.top,window.innerHeight-Xe.y-10))}))}},je=()=>{u(!1),f(!1)};if(c||d)return document.addEventListener("mousemove",ye),document.addEventListener("mouseup",je),()=>{document.removeEventListener("mousemove",ye),document.removeEventListener("mouseup",je)}},[c,d,p]);const $e=`/api/v1/printers/${t}/camera/stream?fps=15&t=${Q}`;return s.jsxs("div",{ref:xe,className:`${y?"fixed inset-0 z-[100]":"fixed z-50 rounded-lg shadow-2xl border border-bambu-dark-tertiary"} bg-bambu-dark-secondary overflow-hidden`,style:y?void 0:{left:o.x,top:o.y,width:x?200:o.width,height:x?40:o.height,cursor:c?"grabbing":"default"},children:[s.jsxs("div",{className:"flex items-center justify-between px-3 py-2 bg-bambu-dark border-b border-bambu-dark-tertiary cursor-grab active:cursor-grabbing",onMouseDown:He,children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm text-white truncate",children:[s.jsx(zg,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),s.jsx("span",{className:"truncate",children:Oe?.name||e})]}),s.jsxs("div",{className:"flex items-center gap-1 no-drag",children:[s.jsx("button",{onClick:Fe,disabled:K||X,className:"p-1 hover:bg-bambu-dark-tertiary rounded disabled:opacity-50",title:"Refresh stream",children:s.jsx(Dr,{className:`w-3.5 h-3.5 text-bambu-gray ${K?"animate-spin":""}`})}),s.jsx("button",{onClick:G,className:"p-1 hover:bg-bambu-dark-tertiary rounded",title:y?"Exit fullscreen":"Fullscreen",children:y?s.jsx(_W,{className:"w-3.5 h-3.5 text-bambu-gray"}):s.jsx(Hue,{className:"w-3.5 h-3.5 text-bambu-gray"})}),s.jsx("button",{onClick:()=>b(!x),className:"p-1 hover:bg-bambu-dark-tertiary rounded",title:x?"Expand":"Minimize",children:x?s.jsx(vW,{className:"w-3.5 h-3.5 text-bambu-gray"}):s.jsx(wW,{className:"w-3.5 h-3.5 text-bambu-gray"})}),s.jsx("button",{onClick:r,className:"p-1 hover:bg-red-500/20 rounded",title:"Close",children:s.jsx(Rt,{className:"w-3.5 h-3.5 text-bambu-gray hover:text-red-400"})})]})]}),!x&&s.jsxs("div",{className:"relative w-full bg-black flex items-center justify-center overflow-hidden h-[calc(100%-40px)]",onWheel:q,onMouseMove:fe,onMouseUp:me,onMouseLeave:me,onTouchStart:O,onTouchMove:ee,onTouchEnd:le,style:{touchAction:"none"},children:[K&&!X&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50 z-10",children:s.jsx(Dr,{className:"w-6 h-6 text-bambu-gray animate-spin"})}),X&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/80 z-10",children:s.jsxs("div",{className:"text-center p-2",children:[s.jsx(sm,{className:"w-6 h-6 text-orange-400 mx-auto mb-2"}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:["Reconnecting in ",se,"s..."]})]})}),j&&!X&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black z-10",children:s.jsxs("div",{className:"text-center p-2",children:[s.jsx(Cn,{className:"w-6 h-6 text-orange-400 mx-auto mb-2"}),s.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:"Camera unavailable"}),s.jsx("button",{onClick:Fe,className:"px-2 py-1 text-xs bg-bambu-green text-white rounded hover:bg-bambu-green/80",children:"Retry"})]})}),s.jsx("img",{ref:de,src:$e,alt:"Camera stream",className:"max-w-full max-h-full object-contain select-none",style:{transform:`scale(${S}) translate(${T.x/S}px, ${T.y/S}px)`,cursor:S>1?C?"grabbing":"grab":"default"},onError:we,onLoad:re,onMouseDown:te,draggable:!1},Q),s.jsxs("div",{className:"absolute bottom-2 left-2 flex items-center gap-1 bg-black/60 rounded px-1.5 py-1 no-drag",children:[s.jsx("button",{onClick:ce,disabled:S<=1,className:"p-1 hover:bg-white/10 rounded disabled:opacity-30",title:"Zoom out",children:s.jsx(FR,{className:"w-3.5 h-3.5 text-white"})}),s.jsxs("button",{onClick:_e,className:"px-1.5 py-0.5 text-xs text-white hover:bg-white/10 rounded min-w-[32px]",title:"Reset zoom",children:[Math.round(S*100),"%"]}),s.jsx("button",{onClick:Y,disabled:S>=4,className:"p-1 hover:bg-white/10 rounded disabled:opacity-30",title:"Zoom in",children:s.jsx(LR,{className:"w-3.5 h-3.5 text-white"})})]}),!y&&s.jsx("div",{className:"absolute bottom-0 right-0 w-6 h-6 cursor-se-resize no-drag hover:bg-white/10 rounded-tl transition-colors",onMouseDown:Ve,title:"Drag to resize",children:s.jsx("svg",{className:"w-6 h-6 text-bambu-gray/70 hover:text-bambu-gray",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M22 22H20V20H22V22ZM22 18H20V16H22V18ZM18 22H16V20H18V22ZM22 14H20V12H22V14ZM18 18H16V16H18V18ZM14 22H12V20H14V22ZM22 10H20V8H22V10ZM18 14H16V12H18V14ZM14 18H12V16H14V18ZM10 22H8V20H10V22Z"})})})]})]})}function $fe({printerId:t,printerName:e,onClose:n}){const{t:r}=Hn(),i=an(),[a,o]=_.useState(!0),[l,c]=_.useState(new Set),[u,d]=_.useState(""),[f,p]=_.useState("all"),m=_.useRef(null),{data:x,isLoading:b,refetch:y}=at({queryKey:["mqtt-logs",t],queryFn:()=>ue.getMQTTLogs(t),refetchInterval:1e3}),v=mt({mutationFn:()=>ue.enableMQTTLogging(t),onSuccess:()=>{i.invalidateQueries({queryKey:["mqtt-logs",t]})}}),S=mt({mutationFn:()=>ue.disableMQTTLogging(t),onSuccess:()=>{i.invalidateQueries({queryKey:["mqtt-logs",t]})}}),N=mt({mutationFn:()=>ue.clearMQTTLogs(t),onSuccess:()=>{i.invalidateQueries({queryKey:["mqtt-logs",t]})}});_.useEffect(()=>{const R=U=>{U.key==="Escape"&&n()};return window.addEventListener("keydown",R),()=>window.removeEventListener("keydown",R)},[n]),_.useEffect(()=>{a&&m.current&&(m.current.scrollTop=m.current.scrollHeight)},[x?.logs,a]);const T=R=>{c(U=>{const F=new Set(U);return F.has(R)?F.delete(R):F.add(R),F})},k=R=>new Date(R).toLocaleTimeString("en-US",{hour12:!1,fractionalSecondDigits:3}),C=(R,U)=>{if(R==null)return"<empty>";const F=typeof R=="string"?JSON.parse(R):R,$=JSON.stringify(F,null,U?2:0);return!U&&$.length>100?$.substring(0,100)+"...":$},E=x?.logging_enabled??!1,D=_.useMemo(()=>x?.logs??[],[x?.logs]),A=_.useMemo(()=>D.filter(R=>{if(f!=="all"&&R.direction!==f)return!1;if(u.trim()){const U=u.toLowerCase(),F=R.topic.toLowerCase().includes(U),j=JSON.stringify(R.payload).toLowerCase().includes(U);return F||j}return!0}),[D,u,f]);return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg max-w-4xl w-full max-h-[85vh] flex flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:r("mqttDebug.title")}),s.jsx("p",{className:"text-sm text-bambu-gray",children:e})]}),s.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(Rt,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"flex flex-col gap-2 p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[E?s.jsxs(Te,{size:"sm",variant:"secondary",onClick:()=>S.mutate(),disabled:S.isPending,children:[s.jsx(ll,{className:"w-4 h-4"}),r("mqttDebug.stopLogging")]}):s.jsxs(Te,{size:"sm",onClick:()=>v.mutate(),disabled:v.isPending,children:[s.jsx(Is,{className:"w-4 h-4"}),r("mqttDebug.startLogging")]}),s.jsxs(Te,{size:"sm",variant:"secondary",onClick:()=>N.mutate(),disabled:N.isPending||D.length===0,children:[s.jsx(rn,{className:"w-4 h-4"}),r("mqttDebug.clearLog")]}),s.jsx(Te,{size:"sm",variant:"secondary",onClick:()=>y(),disabled:b,children:s.jsx(Dr,{className:`w-4 h-4 ${b?"animate-spin":""}`})}),s.jsx("div",{className:"flex-1"}),s.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:a,onChange:R=>o(R.target.checked),className:"rounded border-bambu-dark-tertiary"}),"Auto-scroll"]}),s.jsxs("span",{className:"text-sm text-bambu-gray",children:[A.length,"/",D.length]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsx(ba,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",placeholder:r("mqttDebug.searchPlaceholder"),value:u,onChange:R=>d(R.target.value),className:"w-full pl-8 pr-3 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"}),u&&s.jsx("button",{onClick:()=>d(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",children:s.jsx(Rt,{className:"w-4 h-4"})})]}),s.jsxs("div",{className:"flex items-center gap-1 bg-bambu-dark rounded border border-bambu-dark-tertiary",children:[s.jsx("button",{onClick:()=>p("all"),className:`px-2 py-1.5 text-xs rounded-l transition-colors ${f==="all"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white"}`,children:r("mqttDebug.all")}),s.jsxs("button",{onClick:()=>p("in"),className:`px-2 py-1.5 text-xs transition-colors flex items-center gap-1 ${f==="in"?"bg-blue-500 text-white":"text-bambu-gray hover:text-white"}`,children:[s.jsx(G0,{className:"w-3 h-3"}),r("mqttDebug.incoming")]}),s.jsxs("button",{onClick:()=>p("out"),className:`px-2 py-1.5 text-xs rounded-r transition-colors flex items-center gap-1 ${f==="out"?"bg-green-500 text-white":"text-bambu-gray hover:text-white"}`,children:[s.jsx(Ig,{className:"w-3 h-3"}),r("mqttDebug.outgoing")]})]})]})]}),s.jsx("div",{ref:m,className:"flex-1 overflow-auto p-4 font-mono text-xs bg-black min-h-[400px]",children:D.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-bambu-gray",children:[s.jsx("p",{className:"mb-2",children:r("mqttDebug.noMessages")}),!E&&s.jsx("p",{className:"text-sm",children:r("mqttDebug.startLoggingHint")})]}):A.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-bambu-gray",children:[s.jsx("p",{className:"mb-2",children:r("mqttDebug.noMessagesMatch")}),s.jsx("p",{className:"text-sm",children:r("mqttDebug.adjustFilterHint")})]}):s.jsx("div",{className:"space-y-1",children:A.map((R,U)=>{const F=l.has(U),$=R.direction==="in";return s.jsxs("div",{className:`p-2 rounded cursor-pointer hover:bg-bambu-dark-secondary transition-colors ${F?"bg-bambu-dark-secondary":""}`,onClick:()=>T(U),children:[s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("span",{className:"text-bambu-gray shrink-0",children:k(R.timestamp)}),s.jsx("span",{className:`shrink-0 ${$?"text-blue-400":"text-green-400"}`,title:r($?"mqttDebug.incoming":"mqttDebug.outgoing"),children:$?s.jsx(G0,{className:"w-3 h-3"}):s.jsx(Ig,{className:"w-3 h-3"})}),s.jsx("span",{className:"text-purple-400 shrink-0",children:R.topic})]}),F?s.jsx("pre",{className:"mt-2 p-3 bg-gray-900 border border-gray-700 rounded text-green-400 overflow-x-auto whitespace-pre-wrap break-all max-h-96 overflow-y-auto text-xs",children:C(R.payload,!0)}):s.jsx("pre",{className:"mt-1 text-white/80 truncate",children:C(R.payload,!1)})]},U)})})}),s.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary",children:[s.jsx("div",{className:"text-sm text-bambu-gray",children:E?s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"}),r("mqttDebug.loggingActive")]}):s.jsx("span",{children:r("mqttDebug.loggingStopped")})}),s.jsx(Te,{variant:"secondary",onClick:n,children:r("common.close")})]})]})})}const vP={"0300_4000":"Z axis homing failed; the task has been stopped.","0300_4001":"The printer timed out waiting for the nozzle to cool down before homing.","0300_4002":"Auto Bed Leveling failed; the task has been stopped.","0300_4005":"The hotend cooling fan speed is abnormal.","0300_4006":"The nozzle is clogged.","0300_4008":"The AMS failed to change filament.","0300_4009":"Homing XY axis failed.","0300_400A":"Mechanical resonance frequency identification failed.","0300_400B":"Internal communication exception","0300_400C":"The task was canceled.","0300_400D":"Resume failed after power loss.","0300_400E":"The motor self-check failed.","0300_400F":"The power supply voltage does not match the printer.","0300_4010":"Nozzle offset calibration failed.","0300_4011":"Flow Dynamics Calibration failed; please reinitiate printing or calibration.","0300_4013":"Printing cannot be initiated while AMS is drying.","0300_4014":"Homing Z axis failed: temperature control abnormality.","0300_4015":"Nozzle clumping detection calibration failed. Please go to 'Assistant' for troubleshooting.","0300_4016":"Nozzle cleaning failed. Please click the Assistant for troubleshooting.","0300_401F":"The hotend is not installed, and the toolhead cannot perform homing. Please install the hotend and then continue.","0300_4020":"The nozzle presence detection failed. Please check the Assistant for details.","0300_4021":"Nozzle offset calibration sensor signal abnormality detected. Please check the sensor and retry.","0300_4042":"The Laser Safety Window is not properly installed. The task has been stopped.","0300_4044":"The Flame Sensor is abnormal. The sensor may be short-circuited. Please troubleshoot the issue before starting a print job.","0300_404B":"Task aborted because the front door or top cover is open.","0300_404D":"The current temperature of the hotend, heatbed, or chamber is too high. Please wait for it to cool down to room temperature before restarting the task.","0300_4050":"Liveview Camera calibration timeout; please restart the printer.","0300_4052":"Blade Z-axis homing failed","0300_4057":"Z-axis step loss detected. The task has stopped. Please check if there are any obstructions beneath the heatbed.","0300_4066":"Calibration of motion precision failed.","0300_4067":"Calibration result is over the threshold.","0300_4068":"Step loss occurred during the motion accuracy enhancement process. Please try again.","0300_8000":"Printing was paused for unknown reason. You can select 'Resume' to resume the print job.","0300_8001":"Printing was paused by the user. You can select 'Resume' to continue printing.","0300_8002":"First layer defects were detected by the Micro Lidar. Please check the quality of the printed model before continuing your print.","0300_8003":"Spaghetti defects were detected by the AI Print Monitoring. Please check the quality of the printed model before continuing your print.","0300_8004":"Filament ran out. Please load new filament.","0300_8005":"Toolhead front cover fell off. Please remount the front cover and check to make sure your print is going okay.","0300_8006":"The build plate marker was not detected. Please confirm the build plate is correctly positioned on the heatbed with all four corners aligned, and the marker is visible.","0300_8007":"There was an unfinished print job when the printer lost power. If the model is still adhered to the build plate, you can try resuming the print job.","0300_8008":"Nozzle temperature malfunction","0300_8009":"Heatbed temperature malfunction","0300_800A":"A Filament pile-up was detected by AI Print Monitoring. Please clean filament from the waste chute.","0300_800B":"The cutter is stuck. Please make sure the cutter handle is out and check the filament sensor cable connection.","0300_800C":"Skipped step detected: auto-recover complete; please resume print and check if there are any layer shift problems.","0300_800D":"Detected that the extruder is not extruding normally. If the defects are acceptable, select 'Resume' to resume the print job.","0300_800E":"The print file is not available. Please check to see if the storage media has been removed.","0300_800F":"The door seems to be open, so printing was paused.","0300_8010":"The hotend cooling fan speed is abnormal.","0300_8011":"Detected build plate is not the same as the Gcode file. Please adjust slicer settings or use the correct plate.","0300_8013":"Printing paused due to the pause command added to the printing file.","0300_8014":"The nozzle is covered with filament, or the build plate is installed incorrectly. Please cancel this print and clean the nozzle or adjust the build plate according to the actual status. You can als...","0300_8015":"The filament on external spool has run out; please load new filament. If the filament is loaded, please select 'Resume'.","0300_8016":"The nozzle is clogged with filament. Please cancel this print and clean the nozzle or select 'Resume' to resume the print job.","0300_8017":"Foreign objects detected on heatbed. Please check and clean the heatbed. Then, select 'Resume' to resume the print job.","0300_8018":"Chamber temperature malfunction.","0300_8019":"No build plate is placed.","0300_801A":"Filament extrusion error; please check the assistant for troubleshooting. After resolving the issue, decide whether to cancel or resume the print job based on the actual print status.","0300_801B":"Nozzle temperature problem detected. Refer to Assistant to re-connect the hotend connector. POWER OFF the printer before this operation to avoid short circuits.","0300_801C":"The extrusion resistance is abnormal. The extruder may be clogged; please refer to the assistant. After trouble shooting, you can select 'Resume' to resume the print job.","0300_801D":"The extruder servo motor position sensor is malfunctioning. Please power off the printer first and check if the connection cable is loose.","0300_801E":"The extrusion motor is overloaded, please check the Assistant for details.","0300_8021":"The nozzle may not be installed or not properly installed. Please ensure the nozzle is correctly installed before proceeding.","0300_8022":"The heatbed may be obstructed while moving downward. Please clear any objects beneath the heatbed and check for any resistance or jamming during its movement.","0300_8028":"Nozzle offset calibration sensor error. If using a single hotend or the calibration function is disabled, you may ignore this and continue printing; otherwise, it is recommended to check the sensor...","0300_8041":"Platform detection timeout: please restart the printer.","0300_8042":"Task paused because the door is open.","0300_8043":"The laser module is abnormal.","0300_8044":"Fire was detected inside the chamber.","0300_8045":"Material detection timeout: please restart the printer.","0300_8046":"Foreign object detect timeout: please restart the printer.","0300_8047":"Quick-release lever detection time out: please restart the printer.","0300_8048":"Laser Module unlock has timed out, and the task cannot proceed. Please restart the printer and try again.","0300_8049":"The current plate is invalid.","0300_804A":"Emergency stop button improperly installed. Please reinstall according to the Wiki before proceeding.","0300_804B":"Task paused. The Laser Safety Window is open.","0300_804E":"This is a printing task. Please detach the Laser/Cutting Module from the Toolhead.","0300_804F":"The loading/unloading process is currently ongoing. Please stop the process or remove the laser/cutting module.","0300_8050":"This device does not support the 40W Laser Module. Please remove it or replace it with a 10W Laser Module.","0300_8051":"The cutting module has dropped or the cutting module cable is disconnected; please check the module.","0300_8053":"Laser module detected. Please install the right nozzle correctly to ensure proper Laser Module Mounting Calibration.","0300_8054":"Please place the paper required for Print Then Cut.","0300_8055":"The module mounted on the toolhead does not match the task. Please install the correct module.","0300_8057":"The rotary attachment is disconnected. Please ensure it is properly installed and the cable is securely plugged in.","0300_8058":"The rotary attachment is detected. Please remove it before continuing.","0300_8061":"The mode of Airflow System failed to activate; check the air door condition.","0300_8062":"The chamber temperature is too high. It may be due to high environmental temperature.","0300_8063":"The chamber temperature is too high. Please open the top cover and front door to cool down.","0300_8064":"The chamber temperature is too high. Please open the top cover and front door to cool down. (Open door detection for this print job will be set to 'Notification' level)","0300_8065":"The temperature of the MC module is too high. Please check the Wiki for possible explanations.","0300_8071":"The Toolhead Enhanced Cooling Fan module is malfunctioning.","0300_807D":"Fire Extinguisher not detected, the automatic extinguishing function will be unavailable.","0300_807E":"Fire Extinguisher not detected, the automatic extinguishing function will be unavailable.","0300_807F":"Fire Extinguisher is malfunctioning.","0300_8080":"Fire extinguisher motor reset failed.","0300_8081":"Fire extinguisher cylinder not installed. Please confirm on the extinguisher page.","0300_8082":"The Fire Extinguisher Gas Cylinder is empty.","0300_C012":"Please heat the nozzle to above 170°C.","0300_C056":"A minor fire was detected inside the chamber, and the Auto Fire Extinguishing process has been aborted.","0300_C070":"The fire extinguisher has been detected and is ready for use after the laser module is connected.","0500_4001":"Failed to connect to Bambu Cloud. Please check your network connection.","0500_4002":"Unsupported print file path or name. Please resend the print job.","0500_4003":"Printing stopped because the printer was unable to parse the file. Please resend your print job.","0500_4004":"Device is busy and cannot start new task. Please wait for current task to complete before sending new task.","0500_4005":"Print jobs are not allowed to be sent while updating firmware.","0500_4006":"There is not enough free storage space for the print job. Restoring to factory settings can free up available space.","0500_4007":"The device requires a repair upgrade, and printing is currently unavailable.","0500_4008":"Starting printing failed; please power cycle the printer and resend the print job.","0500_4009":"Print jobs are not allowed to be sent while updating logs.","0500_400A":"The file name is not supported. Please rename and restart the print job.","0500_400B":"There was a problem downloading a file. Please check your network connection and resend the print job.","0500_400C":"Please insert a MicroSD card and restart the print job.","0500_400D":"Please run a self-test and restart the print job.","0500_400E":"Printing was cancelled.","0500_400F":"AMS is initializing and cannot be upgraded at the moment. Please try again later.","0500_4010":"AMS is drying and cannot be upgraded at the moment. Please try again later.","0500_4011":"The printer is loading or unloading filament and cannot be upgraded at the moment. Please try again later.","0500_4012":"The device is printing and cannot be upgraded at the moment. Please try again later.","0500_4013":"AMS is in operation and cannot be upgraded at the moment. Please try again when it is idle.","0500_4014":"Slicing for the print job failed. Please check your settings and restart the print job.","0500_4015":"There is not enough free storage space for the print job. Please format or clear files from the MicroSD card to free up space.","0500_4016":"The MicroSD Card is write-protected. Please replace the MicroSD Card.","0500_4017":"Binding failed. Please retry or restart the printer and retry.","0500_4018":"Binding configuration information parsing failed; please try again.","0500_4019":"The printer has already been bound. Please unbind it and try again.","0500_401A":"Cloud access failed. Possible reasons include network instability caused by interference, inability to access the internet, or router firewall configuration restrictions. You can try moving the pri...","0500_401B":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0500_401C":"Cloud access is rejected. If you have tried multiple times and are still failing, please contact customer support.","0500_401D":"Cloud access failed, which may be caused by network instability due to interference. You can try moving the printer closer to the router before you try again.","0500_401E":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0500_401F":"Authorization timed out. Please make sure that your phone or PC has access to the internet, and ensure that the Bambu Studio/Bambu Handy APP is running in the foreground during the binding operation.","0500_4020":"Cloud access rejected. If you have tried multiple times and are still failing, please contact customer support.","0500_4021":"Cloud access failed, which may be caused by network instability due to interference. You can try moving the printer closer to the router before you try again.","0500_4022":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0500_4023":"Cloud access rejected. If you have tried multiple times and are still failing, please contact customer support.","0500_4024":"Cloud access failed. Possible reasons include network instability caused by interference, inability to access the internet, or router firewall configuration restrictions. You can try moving the pri...","0500_4025":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0500_4026":"Cloud access rejected. If you have tried multiple times and are still failing, please contact customer support.","0500_4027":"Cloud access failed; this may be caused by network instability due to interference. You can try moving the printer closer to the router before you try again.","0500_4028":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0500_4029":"Cloud access is rejected. If you have tried multiple times and are still failing, please contact customer support.","0500_402A":"Failed to connect to the router, which may be caused by wireless interference or being too far away from the router. Please try again or move the printer closer to the router and try again.","0500_402B":"Router connection failed due to incorrect password. Please check the password and try again.","0500_402C":"Failed to obtain IP address, which may be caused by wireless interference resulting in data transmission failure or the DHCP address pool of the router being full. Please move the printer closer to...","0500_402D":"System exception","0500_402E":"System does not support the file system currently used by the USB flash drive. Please replace or format the USB flash drive to FAT32.","0500_402F":"The MicroSD card sector data is damaged. Please use the SD card repair tool to repair or format it. If it still cannot be identified, please replace the MicroSD card.","0500_4030":"The device is currently upgrading. Please try again when it is idle.","0500_4031":"The accessory firmware does not match the printer. Please update it on the 'Firmware' page.","0500_4033":"The AMS firmware does not match the printer. Please update it on the 'Firmware' page.","0500_4034":"The Laser Module firmware does not match the printer. Please update it on the 'Firmware' page.","0500_4035":"The BirdsEye Camera is malfunctioning. Please try restarting the device. If the issue persists after multiple restarts, check the camera connection status or contact customer support.","0500_4037":"Your sliced file is not compatible with current printer model. This file can't be printed on this printer.","0500_4038":"The nozzle diameter in sliced file is not consistent with the current nozzle setting. This file can't be printed.","0500_4039":"The current task does not allow the installation of the laser/cutting module, and the task has been halted.","0500_403A":"The current temperature is too low. In order to protect you and your printer, printing tasks, moving an axis and other operations are disabled. Please move the printer to an environment above 10 de...","0500_403B":"Laser/cutting tasks cannot be initiated on the machine at the moment. Please use the computer software to start the task.","0500_403C":"The current nozzle setting does not match the slicing file. Continuing to print may affect print quality. It is recommended to re-slice before starting the print.","0500_403D":"The toolhead module is not set up. Please set it up before initiating the task.","0500_403E":"The current tool head does not support initialization.","0500_403F":"Failed to download print job; please check your network connection.","0500_4040":"The printer has reached its power limit. Please connect a dedicated power adapter to this AMS to enable drying.","0500_4041":"The AMS drying cannot be started during printing.","0500_4042":"Due to power limitations, starting AMS drying will pause current operations such as nozzle heating and fan running. Do you want to proceed with drying?","0500_4043":"Due to power limitations, only one AMS is allowed to use the device's power for drying.","0500_4044":"BirdsEye Camera malfunction: please contact customer support.","0500_4045":"Hotend check in progress. This operation is temporarily unavailable. Please wait.","0500_4050":"Error detected on the print board.","0500_4052":"Error detected on the hot end.","0500_4054":"Error detected on the mat.","0500_405D":"Laser module Serial Number error: unable to calibrate or make project.","0500_4065":"The task requires a Laser Platform, but the current one is a Cutting Platform. Please replace it, measure the material thickness in the software, and then restart the task.","0500_4070":"The laser or cutter module is connected, so the device cannot initiate a 3D printing task.","0500_4075":"No Laser Platform was detected, which may affect thickness measurement accuracy. Please place the laser platform correctly and ensure the rear markers are not blocked, then restart the thickness me...","0500_4076":"Please place the Laser Platform correctly and ensure the rear markers are not blocked, then restart the thickness measurement in the software before initiating the task.","0500_4097":"The device cannot detect the Laser Module. Please reconnect the module cable or restart the printer.","0500_4098":"The device cannot detect AMS A. Please reconnect the AMS cable or restart the printer.","0500_4099":"The firmware of Cutting Module does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0500_409A":"The firmware of the Air Pump does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0500_409B":"The firmware of the Laser Module does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0500_409D":"The firmware of AMS A does not match the printer; the device cannot continue working. Please upgrade it on the 'Firmware' page.","0500_409E":"The device cannot detect the Cutting Module. Please reconnect the module cable or restart the printer.","0500_409F":"The device cannot detect the Air Pump. Please reconnect the module cable or restart the printer.","0500_40A0":"The Rotary Attachment module is not detected. Please reconnect the cable or restart the printer.","0500_40A1":"The Auto Fire Extinguishing System is not detected. Please reconnect the module cable or restart the printer.","0500_40A3":"AMS(or AMS lite) A communication is abnormal. Please reconnect the module cable or restart the printer.","0500_40A4":"The current firmware only supports 1 AMS Lite. Please remove all AMS units before reconnecting the supported AMS Lite device.","0500_40A5":"The current firmware only supports AMS/AMS 2 Pro/AMS HT, with a maximum of 4 units. Please remove all AMS units before reconnecting the supported one.","0500_8013":"The print file is not available. Please check to see if the storage media has been removed.","0500_8036":"Your sliced file is not consistent with the current printer model. Continue?","0500_803C":"The current nozzle setting does not match the slicing file. Continuing to print may affect print quality. It is recommended to re-slice before starting the print.","0500_8040":"Toolhead front cover is detached. Moving the toolhead may damage the printer. Do you want to continue?","0500_8041":"The filament in hotend is too cold. Extrusion may damage the extruder. Still feeding in/out the filament?","0500_8048":"The module on the toolhead is not calibrated. Please cancel the task to perform calibration or switch to a calibrated module.","0500_8051":"Detected build plate is not the same as the Gcode file. Please adjust slicer settings or use the correct plate.","0500_8053":"Nozzle mismatch was detected during printing. Please initiate the print after re-slicing, or continue printing after replacing with the correct nozzle. Caution: the hotend temperature is high.","0500_8055":"Laser module is installed, but a Cutting Platform is detected. Please place a Laser Platform and perform laser calibration.","0500_8056":"Cutting module is installed, but the laser platform is detected. Please place the cutting platform for calibration.","0500_8058":"Please place the light grip cutting mat correctly and ensure the marker is exposed.","0500_8059":"Cutting platform base is not correctly aligned. Please ensure that the four corners of the platform are aligned with the heatbed.","0500_805A":"Please place the cutting mat on cutting protection base.","0500_805B":"The cutting mat type is unknown; please replace it with the correct cutting mat.","0500_805C":"The grip cutting mat type does not match; please place a LightGrip cutting mat.","0500_805E":"Cutting module Serial Number error: unable to calibrate or make project.","0500_8060":"The current module on toolhead does not meet requirements. Please replace the module as per the on-screen instructions.","0500_8061":"No print plate detected. Please make sure it is placed correctly.","0500_8062":"The print plate marker was not detected. Please confirm the print plate is correctly positioned on the heatbed with all four corners aligned, and the marker is visible. If strong light is shining o...","0500_8063":"The platform is not detected during calibration; please make sure the Laser Platform is properly placed.","0500_8064":"Please place the Laser Platform correctly and ensure the rear markers are not blocked for laser calibration.","0500_8066":"The task requires a Cutting Platform, but the current one is a Laser Platform. Please replace it with a Cutting Platform (Cutting Protection Base + LightGrip cutting mat).","0500_8067":"Please place a LightGrip cutting mat on the cutting protection base.","0500_8068":"Please place the strong grip cutting mat correctly and ensure the marker is exposed.","0500_8069":"Unable to recognize the left and right hotends. They might be third party hotends, or the hotend marks may be dirty. Please manually set the hotend types.","0500_806A":"Unable to recognize the left and right hotends. They might be third party hotends, or the hotend marks may be dirty. Please set hotend types on printer screen before next print.","0500_806B":"Quick-release Lever is not locked. Please press down the external toolhead module to ensure it is properly seated, then push down the level to lock it in place.","0500_806C":"Please place the cutting platform correctly and ensure the marker is exposed.","0500_806D":"Material not detected. Please confirm placement and continue.","0500_806E":"Foreign objects detected on heatbed; please check and clean up the heatbed.","0500_806F":"The grip cutting mat type does not match; please place a StrongGrip cutting mat.","0500_8071":"No cutting platform was detected. Please confirm that it has been correctly placed.","0500_8072":"Live View camera is blocked","0500_8073":"Heatbed limit block is obstructed or contaminated. Please clean and ensure the limit block is visible, otherwise platform position offset detection may be inaccurate.","0500_8074":"The Laser Platform is offset. Please ensure that the four corners of the platform are aligned with the heatbed, and the marker is not obstructed.","0500_8077":"The visual marker was not detected. Please ensure the paper is properly placed.","0500_8078":"Current material does not match the sliced file settings. Please load the correct material and ensure the QR code on the material is not damaged or dirty.","0500_8079":"Please place the Laser Test Material (350g paperboard) and position support strips underneath to prevent material warping.","0500_807A":"The foreign object detection function is not working. You can continue the task or check the assistant for troubleshooting.","0500_807B":"Please place the cutting platform (cutting protection base + LightGrip cutting mat).","0500_807C":"Please place the cutting platform (cutting protection base + StrongGrip cutting mat).","0500_807D":"This task requires a Cutting Platform, but the current one is a Laser Platform. Please replace it with a Cutting Platform (Cutting Protection Base + StrongGrip Cutting Mat).","0500_807E":"Please place a StrongGrip cutting mat on the cutting protection base.","0500_8080":"The left and right hotends are not installed.","0500_8081":"The left and right hotends are not installed.","0500_8082":"Please remove the protective film on the Opaque Glossy Acrylic before processing","0500_8083":"Material is not allowed in Mounting Calibration. Please remove the material from the platform.","0500_8084":"The Live View Camera is dirty; please clean it and continue.","0500_8085":"Toolhead camera is obstructed","0500_8086":"Toolhead Camera is dirty, which affects the AI function; please clean the lens surface.","0500_8087":"BirdsEye camera is obstructed","0500_8088":"The Birdseye Camera is dirty","0500_8089":"Task paused due to Presence Check failed. Please check the printer to continue.","0500_808A":"The BirdsEye Camera is installed offset. Please refer to the assistant to reinstall it.","0500_808B":"The BirdsEye Camera setup failed. Please remove all objects and the mat on the heatbed to ensure the heatbed markers are visible. Meanwhile, please ensure the BirdsEye Camera is installed correctly...","0500_808C":"Detected build plate offset. Please align the build plate with the heatbed, and then continue.","0500_808D":"The Cutting Module offset calibration failed, which may result in inaccurate cuts. Please ensure the cutting material is properly positioned and check whether the cutting blade tip is worn.","0500_808E":"BirdsEye Camera initialization failed. The toolhead camera did not detect the Heatbed features. Please clean the Heatbed, remove all objects and pads, and ensure the bed markings are visible. Check...","0500_808F":"Nozzle camera lens is dirty, affecting AI monitoring. Clean the lens with a non-woven cloth and a small amount of alcohol. Beware of hotend heat; wait for it to cool before handling.","0500_8090":"Please attach the 80g White Printing Paper to the center area of the platform.","0500_8091":"The Cutting Module offset calibration failed, which may result in inaccurate cuts. Please ensure the 80g white printer paper(letter paper thickness) is properly positioned and check whether the cut...","0500_8092":"Toolhead Camera initialization failed. This print can still continue, but some AI functions will be disabled. If you encounter this issue again after restarting, please contact customer support.","0500_8093":"The nozzle silicone sleeve is not installed; there is a risk of temperature control failure. Please install it correctly and try again.","0500_80A0":"The visual encoder board was not detected. Please check if the board is properly placed and aligned at all four corners, and ensure the positioning markings are clear and free from wear.","0500_C010":"MicroSD Card read/write exception: please reinsert or replace the MicroSD Card.","0500_C032":"Laser/Cutting module connected to the toolhead. The drying process has been automatically stopped.","0500_C036":"This is a printing task. Please detach the Laser/Cutting Module from the Toolhead.","0500_C07F":"Device is busy and cannot perform this operation. To proceed, please pause or stop the current task.","0501_4017":"Binding failed. Please retry or restart the printer and retry.","0501_4018":"Binding configuration information parsing failed; please try again.","0501_4019":"The printer has already been bound. Please unbind it and try again.","0501_401A":"Cloud access failed. Possible reasons include network instability caused by interference, inability to access the internet, or router firewall configuration restrictions. You can try moving the pri...","0501_401B":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0501_401C":"Cloud access is rejected. If you have tried multiple times and are still failing, please contact customer support.","0501_401D":"Cloud access failed, which may be caused by network instability due to interference. You can try moving the printer closer to the router before you try again.","0501_401E":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0501_401F":"Authorization timed out. Please make sure that your phone or PC has access to the internet, and ensure that the Bambu Studio/Bambu Handy APP is running in the foreground during the binding operation.","0501_4020":"Cloud access rejected. If you have tried multiple times and are still failing, please contact customer support.","0501_4021":"Cloud access failed, which may be caused by network instability due to interference. You can try moving the printer closer to the router before you try again.","0501_4022":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0501_4023":"Cloud access rejected. If you have tried multiple times and are still failing, please contact customer support.","0501_4024":"Cloud access failed. Possible reasons include network instability caused by interference, inability to access the internet, or router firewall configuration restrictions. You can try moving the pri...","0501_4025":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0501_4026":"Cloud access rejected. If you have tried multiple times and are still failing, please contact customer support.","0501_4027":"Cloud access failed; this may be caused by network instability due to interference. You can try moving the printer closer to the router before you try again.","0501_4028":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0501_4029":"Cloud access is rejected. If you have tried multiple times and are still failing, please contact customer support.","0501_4031":"Device discovery binding is in progress, and the QR code cannot be displayed on the screen. You can wait for the binding to finish or abort the device discovery binding process in the APP/Studio an...","0501_4032":"QR code binding is in progress, so device discovery binding cannot be performed. You can scan the QR code on the screen for binding or exit the QR code display page on screen and try device discove...","0501_4033":"Your APP region does not match with your printer; please download the APP in the corresponding region and register your account again.","0501_4034":"The slicing progress has not been updated for a long time, and the printing task has exited. Please confirm the parameters and reinitiate printing.","0501_4035":"The device is in the process of binding and cannot respond to new binding requests.","0501_4038":"The regional settings do not match the printer; please check the printer's regional settings.","0501_4039":"Device login has expired; please try to bind again.","0501_4098":"The device cannot detect AMS B. Please reconnect the AMS cable or restart the printer.","0501_409D":"The firmware of AMS B does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0501_40A3":"AMS(or AMS lite) B communication is abnormal. Please reconnect the module cable or restart the printer.","0502_4001":"Current filament will be used in this print job. Settings cannot be changed.","0502_4002":"Please go to “Settings > Calibration” to run the Motion Accuracy Enhancement Calibration before turning on Motion Accuracy Enhancement mode.","0502_4003":"The printer is currently printing and the motion accuracy enhancement feature cannot be turned on or off.","0502_4004":"Some features are not supported by the current device. Please check the Studio feature settings or update the firmware to the latest version.","0502_4005":"The AMS has not been calibrated yet, so printing cannot be initiated.","0502_4006":"Unknown module detected; please try updating the firmware to the latest version.","0502_400D":"Failed to start a new task: filament loading/unloading not completed.","0502_400E":"Failed to start a new task: The nozzle cold pull was not completed.","0502_4013":"This device is not compatible with the 40W laser module. Please replace it with a 10W laser module or remove it.","0502_4098":"The device cannot detect AMS C. Please reconnect the AMS cable or restart the printer.","0502_409D":"The firmware of AMS C does not match the printer; the device cannot continue working. Please upgrade it on the 'Firmware' page.","0502_40A3":"AMS(or AMS lite) C communication is abnormal. Please reconnect the module cable or restart the printer.","0502_C00F":"The device is busy and cannot perform nozzle identification.","0502_C010":"Due to printer power limitations, printing, calibration, controls and other actions cannot be performed during AMS drying. Please stop the drying process before proceeding with any other operation.","0502_C011":"Currently in 2D production mode. Please continue the operation on the printer","0502_C012":"The task cannot be paused.","0502_C014":"The AMS Remaining Filament Estimation is enabled by default and cannot be disabled.","0502_C024":"The flow dynamic calibration records have exceeded the storage limit. Please delete some historical records in the slicer software before adding new calibration data.","0503_4098":"The device cannot detect AMS D. Please reconnect the AMS cable or restart the printer.","0503_409D":"The firmware of AMS D does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0503_40A3":"AMS(or AMS lite) D communication is abnormal. Please reconnect the module cable or restart the printer.","0580_4096":"The device cannot detect AMS-HT A. Please reconnect the AMS-HT cable or restart the printer.","0580_409C":"The firmware of AMS-HT A does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0580_40A2":"AMS-HT A communication is abnormal. Please reconnect the module cable or restart the printer.","0581_4096":"The device cannot detect AMS-HT B. Please reconnect the AMS-HT cable or restart the printer.","0581_409C":"The firmware of AMS-HT B does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0581_40A2":"AMS-HT B communication is abnormal. Please reconnect the module cable or restart the printer.","0582_4096":"The device cannot detect AMS-HT C. Please reconnect the AMS-HT cable or restart the printer.","0582_409C":"The firmware of AMS-HT C does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0582_40A2":"AMS-HT C communication is abnormal. Please reconnect the module cable or restart the printer.","0583_4096":"The device cannot detect AMS-HT D. Please reconnect the AMS-HT cable or restart the printer.","0583_409C":"The firmware of AMS-HT D does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0583_40A2":"AMS-HT D communication is abnormal. Please reconnect the module cable or restart the printer.","0584_4096":"The device cannot detect AMS-HT F. Please reconnect the AMS-HT cable or restart the printer.","0584_409C":"The firmware of AMS-HT E does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0584_40A2":"AMS-HT E communication is abnormal. Please reconnect the module cable or restart the printer.","0585_4096":"The device cannot detect AMS-HT E. Please reconnect the AMS-HT cable or restart the printer.","0585_409C":"The firmware of AMS-HT F does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0585_40A2":"AMS-HT F communication is abnormal. Please reconnect the module cable or restart the printer.","0586_4096":"The device cannot detect AMS-HT G. Please reconnect the AMS-HT cable or restart the printer.","0586_409C":"The firmware of AMS-HT G does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0586_40A2":"AMS-HT G communication is abnormal. Please reconnect the module cable or restart the printer.","0587_4096":"The device cannot detect AMS-HT H. Please reconnect the AMS-HT cable or restart the printer.","0587_409C":"The firmware of AMS-HT H does not match the printer; the device cannot continue working. Please upgrade it on the 'Firmware' page.","0587_40A2":"AMS-HT H communication is abnormal. Please reconnect the module cable or restart the printer.","05FE_8053":"The left nozzle is not matched with slicing file. Please initiate the print after re-slicing, or continue printing after replacing with the correct nozzle. Caution: the hotend temperature is high.","05FE_8069":"Unable to recognize the left hotend. It might be a third party hotend, or the hotend mark may be dirty. Please manually set the hotend type.","05FE_806A":"Unable to recognize the left hotend. It might be a third party hotend, or the hotend mark may be dirty. Please set hotend type on printer screen before next print.","05FE_8080":"The left hotend is not installed.","05FE_8081":"The left hotend is not installed.","05FF_8053":"The right nozzle is not matched with slicing file. Please initiate the print after re-slicing, or continue printing after replacing with the correct nozzle. Caution: the hotend temperature is high.","05FF_8069":"Unable to recognize the right hotend. It might be a third party hotend, or the hotend mark may be dirty. Please manually set the hotend type.","05FF_806A":"Unable to recognize the right hotend. It might be a third party hotend, or the hotend mark may be dirty. Please set hotend type on printer screen before next print.","05FF_8080":"The right hotend is not installed.","05FF_8081":"The right hotend is not installed.","0700_4001":"The AMS has been disabled for a print, but it still has filament loaded. Please unload the AMS filament and switch to the spool holder filament for printing.","0700_4025":"Failed to read the filament information.","0700_8001":"Failed to cut the filament. Please check the cutter.","0700_8002":"The cutter is stuck. Please make sure the cutter handle is out.","0700_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","0700_8004":"AMS failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","0700_8005":"The AMS failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","0700_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","0700_8007":"Extruding filament failed. The extruder might be clogged.","0700_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS A to the extruder is properly connected.","0700_8010":"The AMS assist motor is overloaded. This could be due to entangled filament or a stuck spool.","0700_8011":"AMS filament ran out. Please insert a new filament into the same AMS slot.","0700_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","0700_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","0700_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","0700_8017":"AMS A is drying. Please stop drying process before loading/unloading material.","0700_8021":"AMS setup failed; please refer to the assistant.","0700_8023":"AMS A cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","0700_C069":"An error occurred during AMS A drying. Please go to Assistant for more details.","0700_C06A":"AMS A is reading RFID. Unable to start drying. Please try again later.","0700_C06B":"AMS A is changing filament. Unable to start drying. Please try again later.","0700_C06C":"AMS A is in Feed Assist Mode. Unable to start drying. Please try again later.","0700_C06D":"AMS A is assisting in filament insertion. Unable to start drying. Please try again later.","0700_C06E":"AMS A motor is performing self-test. Unable to start drying. Please try again later.","0701_4001":"Filament is still loaded from the AMS after it has been disabled. Please unload the filament, load from the spool holder, and restart printing.","0701_4025":"Failed to read the filament information.","0701_8001":"Failed to cut the filament. Please check the cutter.","0701_8002":"The cutter is stuck. Please make sure the cutter handle is out.","0701_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","0701_8004":"AMS failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","0701_8005":"The AMS failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","0701_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","0701_8007":"Extruding filament failed. The extruder might be clogged.","0701_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS B to the extruder is properly connected.","0701_8010":"The AMS assist motor is overloaded. This could be due to entangled filament or a stuck spool.","0701_8011":"AMS filament ran out. Please insert a new filament into the same AMS slot.","0701_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","0701_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","0701_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","0701_8017":"AMS B is drying. Please stop drying process before loading/unloading material.","0701_8021":"AMS setup failed; please refer to the assistant.","0701_8023":"AMS B cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","0701_C069":"An error occurred during AMS B drying. Please go to Assistant for more details.","0701_C06A":"AMS B is reading RFID. Unable to start drying. Please try again later.","0701_C06B":"AMS B is changing filament. Unable to start drying. Please try again later.","0701_C06C":"AMS B is in Feed Assist Mode. Unable to start drying. Please try again later.","0701_C06D":"AMS B is assisting in filament insertion. Unable to start drying. Please try again later.","0701_C06E":"AMS B motor is performing self-test. Unable to start drying. Please try again later.","0702_4001":"Filament is still loaded from the AMS after it has been disabled. Please unload the filament, load from the spool holder, and restart printing.","0702_4025":"Failed to read the filament information.","0702_8001":"Failed to cut the filament. Please check the cutter.","0702_8002":"The cutter is stuck. Please make sure the cutter handle is out.","0702_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","0702_8004":"AMS failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","0702_8005":"The AMS failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","0702_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","0702_8007":"Extruding filament failed. The extruder might be clogged.","0702_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS C to the extruder is properly connected.","0702_8010":"The AMS assist motor is overloaded. This could be due to entangled filament or a stuck spool.","0702_8011":"AMS filament ran out. Please insert a new filament into the same AMS slot.","0702_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","0702_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","0702_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","0702_8017":"AMS C is drying. Please stop drying process before loading/unloading material.","0702_8021":"AMS setup failed; please refer to the assistant.","0702_8023":"AMS C cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","0702_C069":"An error occurred during AMS C drying. Please go to Assistant for more details.","0702_C06A":"AMS C is reading RFID. Unable to start drying. Please try again later.","0702_C06B":"AMS C is changing filament. Unable to start drying. Please try again later.","0702_C06C":"AMS C is in Feed Assist Mode. Unable to start drying. Please try again later.","0702_C06D":"AMS C is assisting in filament insertion. Unable to start drying. Please try again later.","0702_C06E":"AMS C motor is performing self-test. Unable to start drying. Please try again later.","0703_4001":"Filament is still loaded from the AMS after it has been disabled. Please unload the filament, load from the spool holder, and restart printing.","0703_4025":"Failed to read the filament information.","0703_8001":"Failed to cut the filament. Please check the cutter.","0703_8002":"The cutter is stuck. Please make sure the cutter handle is out.","0703_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","0703_8004":"AMS failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","0703_8005":"The AMS failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","0703_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","0703_8007":"Extruding filament failed. The extruder might be clogged.","0703_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS D to the extruder is properly connected.","0703_8010":"The AMS assist motor is overloaded. This could be due to entangled filament or a stuck spool.","0703_8011":"AMS filament ran out. Please insert a new filament into the same AMS slot.","0703_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","0703_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","0703_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","0703_8017":"AMS D is drying. Please stop drying process before loading/unloading material.","0703_8021":"AMS setup failed; please refer to the assistant.","0703_8023":"AMS D cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","0703_C069":"An error occurred during AMS D drying. Please go to Assistant for more details.","0703_C06A":"AMS D is reading RFID. Unable to start drying. Please try again later.","0703_C06B":"AMS D is changing filament. Unable to start drying. Please try again later.","0703_C06C":"AMS D is in Feed Assist Mode. Unable to start drying. Please try again later.","0703_C06D":"AMS D is assisting in filament insertion. Unable to start drying. Please try again later.","0703_C06E":"AMS D motor is performing self-test. Unable to start drying. Please try again later.","0704_4025":"Failed to read the filament information.","0704_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","0704_8004":"AMS failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","0704_8005":"The AMS failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","0704_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","0704_8007":"Extruding filament failed. The extruder might be clogged.","0704_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS E to the extruder is properly connected.","0704_8010":"The AMS assist motor is overloaded. This could be due to entangled filament or a stuck spool.","0704_8011":"AMS filament ran out. Please insert a new filament into the same AMS slot.","0704_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","0704_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","0704_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","0704_8021":"AMS setup failed; please refer to the assistant.","0704_8023":"AMS E cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","0705_4025":"Failed to read the filament information.","0705_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","0705_8004":"AMS failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","0705_8005":"The AMS failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","0705_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","0705_8007":"Extruding filament failed. The extruder might be clogged.","0705_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS F to the extruder is properly connected.","0705_8010":"The AMS assist motor is overloaded. This could be due to entangled filament or a stuck spool.","0705_8011":"AMS filament ran out. Please insert a new filament into the same AMS slot.","0705_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","0705_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","0705_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","0705_8021":"AMS setup failed; please refer to the assistant.","0705_8023":"AMS F cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","0706_4025":"Failed to read the filament information.","0706_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","0706_8004":"AMS failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","0706_8005":"The AMS failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","0706_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","0706_8007":"Extruding filament failed. The extruder might be clogged.","0706_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS G to the extruder is properly connected.","0706_8010":"The AMS assist motor is overloaded. This could be due to entangled filament or a stuck spool.","0706_8011":"AMS filament ran out. Please insert a new filament into the same AMS slot.","0706_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","0706_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","0706_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","0706_8021":"AMS setup failed; please refer to the assistant.","0706_8023":"AMS G cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","0707_4025":"Failed to read the filament information.","0707_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","0707_8004":"AMS failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","0707_8005":"The AMS failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","0707_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","0707_8007":"Extruding filament failed. The extruder might be clogged.","0707_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS H to the extruder is properly connected.","0707_8010":"The AMS assist motor is overloaded. This could be due to entangled filament or a stuck spool.","0707_8011":"AMS filament ran out. Please insert a new filament into the same AMS slot.","0707_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","0707_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","0707_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","0707_8021":"AMS setup failed; please refer to the assistant.","0707_8023":"AMS H cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","07FE_8001":"Failed to cut the filament of the left extruder. Please check the cutter.","07FE_8002":"The cutter of the left extruder is stuck. Please pull out the cutter handle.","07FE_8003":"Please pull out the filament on the spool holder of the left extruder. If this message persists, please check to see if there is filament broken in the extruder. (Connect a PTFE tube if you are ab...","07FE_8004":"Failed to pull back the filament from the left extruder. Please check whether the filament is stuck inside the extruder.","07FE_8005":"Failed to feed the filament outside the AMS. Please clip the end of the filament flat and check to see if the spool is stuck.","07FE_8006":"Please feed filament into the PTFE tube of the left extruder until it can not be pushed any farther.","07FE_8007":"Please observe the nozzle of the left extruder. If the filament has been extruded, select 'Continue'; if it has not, please push the filament forward slightly, and then select 'Retry'.","07FE_8010":"Check if the left external filament spool or filament is stuck.","07FE_8011":"The external filament connected to the left extruder has run out; please load a new filament.","07FE_8012":"Failed to get mapping table; please select 'Resume' to retry.","07FE_8013":"Timeout purging old filament of the left extruder: Please check if the filament is stuck or the extruder is clogged.","07FE_8020":"Extruder change failed; please refer to the assistant.","07FE_8021":"AMS setup failed; please refer to the assistant.","07FE_8024":"Extruder position calibration failed; please refer to the assistant.","07FE_8025":"Cold pull timed out. Please promptly operate or check whether the filament is broken inside the extruder, and click the Assistant for details.","07FE_8030":"The filament specified in the slicer has been used up. Printing is paused. Please go to the machine to replace the material and resume printing.","07FE_C003":"Please pull out the filament on the spool holder of the left extruder. If this message persists, please check to see if there is filament broken in the extruder or PTFE tube. (Connect a PTFE tube i...","07FE_C006":"Please feed filament into the PTFE tube of the left extruder until it can not be pushed any farther.","07FE_C008":"Please pull out the filament on the spool holder of the left extruder. If this message persists, please check to see if there is filament broken in the extruder or PTFE tube. (Connect a PTFE tube i...","07FE_C009":"Please feed filament into the PTFE tube of the left extruder until it can not be pushed any farther.","07FE_C00A":"Please observe the nozzle of the left extruder. If the filament has been extruded, select 'Continue'; if not, please push the filament forward slightly and then select 'Retry'.","07FE_C010":"Insert the filament (over 30cm long) until it stops. You might see slight smoke during flushing. After insertion, close the front door and top cover.","07FE_C011":"Please manually and slowly pull out the filament from the extruder. Then click “Continue”.","07FE_C012":"Press the black PTFE tube coupler and unplug the PTFE tube. After completing the operation, click 'Continue.'","07FF_4001":"Filament is still loaded from the AMS after it has been disabled. Please unload the filament, load from the spool holder, and restart printing.","07FF_8001":"Failed to cut the filament of the right extruder. Please check the cutter.","07FF_8002":"The cutter is stuck. Please make sure the cutter handle is out.","07FF_8003":"Please pull out the filament on the spool holder of the right extruder. If this message persists, please check to see if there is filament broken in the extruder. (Connect a PTFE tube if you are a...","07FF_8004":"Failed to pull back the filament from the right extruder. Please check whether the filament is stuck inside the extruder.","07FF_8005":"Failed to feed the filament outside the AMS. Please clip the end of the filament flat and check to see if the spool is stuck.","07FF_8006":"Please feed filament into the PTFE tube of the right extruder until it can not be pushed any farther.","07FF_8007":"Please observe the nozzle of the right extruder. If the filament has been extruded, select 'Continue'; if it has not, please push the filament forward slightly, and then select 'Retry'.","07FF_8010":"Check if the external filament spool or filament is stuck.","07FF_8011":"External filament has run out; please load a new filament.","07FF_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","07FF_8013":"Timeout purging old filament of the right extruder: Please check if the filament is stuck or the extruder is clogged.","07FF_8020":"Extruder change failed; please refer to the assistant.","07FF_8021":"AMS setup failed; please refer to the assistant.","07FF_8024":"Extruder position calibration failed; please refer to the assistant.","07FF_8025":"Cold pull timed out. Please promptly operate or check whether the filament is broken inside the extruder, and click the Assistant for details.","07FF_8030":"The filament specified in the slicer has been used up. Printing is paused. Please go to the machine to replace the material and resume printing.","07FF_C003":"Please pull out the filament on the spool holder of the right extruder. If this message persists, please check to see if there is filament broken in the extruder or PTFE tube. (Connect a PTFE tube ...","07FF_C006":"Please feed filament into the PTFE tube of the right extruder until it can not be pushed any farther.","07FF_C008":"Please pull out the filament on the spool holder of the right extruder. If this message persists, please check to see if there is filament broken in the extruder or PTFE tube. (Connect a PTFE tube ...","07FF_C009":"Please feed filament into the PTFE tube of the right extruder until it can not be pushed any farther.","07FF_C00A":"Please observe the nozzle of the right extruder. If the filament has been extruded, select 'Continue'; if not, please push the filament forward slightly and then select 'Retry'.","07FF_C010":"Insert the filament (over 30cm long) until it stops. You might see slight smoke during flushing. After insertion, close the front door and top cover.","07FF_C011":"Hold the driven wheel bracket, slowly pull the filament from the extruder, then press 'Continue'.","07FF_C012":"Press the black PTFE tube coupler and unplug the PTFE tube. After completing the operation, click 'Continue.'","0C00_4020":"The setup of BirdsEye Camera failed. Please clear all objects and remove the mat. Make sure the marker is not obstructed. Meanwhile, clean both the BirdsEye Camera and Toolhead Camera, and remove a...","0C00_4021":"The setup of BirdsEye Camera failed; please reboot the printer.","0C00_4022":"The setup of BirdsEye Camera failed. Please check if the laser module is working properly.","0C00_4024":"The Birdseye Camera is installed offset. Please refer to the assistant to reinstall it.","0C00_4025":"The Birdseye Camera is dirty. Please clean it and restart the process.","0C00_4026":"The Live View Camera initialization failed; please reboot the printer.","0C00_4027":"The Live View Camera calibration failed. Please refer to the assistant for details and recalibrate the camera after processing.","0C00_4029":"Material not detected. Please confirm placement and continue.","0C00_402A":"The visual marker was not detected. Please re-paste the paper in the correct position.","0C00_402C":"Device data link error. Please reboot the printer","0C00_402D":"The toolhead camera is not working properly; please reboot the device.","0C00_403D":"The vision encoder plate was not detected. Please confirm it is correctly positioned on the heatbed.","0C00_403E":"The high-precision nozzle offset calibration has failed, possibly due to a damaged pattern or the similarity of the colors of the two selected filaments. Please clear the printed pattern and replac...","0C00_4041":"Toolhead camera calibration failed. Please ensure the Calibration Marker on the heatbed or Height Calibration Marker on the homing area is clean and undamaged, then re-run the calibration process.","0C00_8001":"First layer defects were detected. If the defects are acceptable, select 'Resume' to resume the print job.","0C00_8005":"Purged filament has piled up in the waste chute, which may cause a tool head collision.","0C00_8009":"Build plate localization marker was not found.","0C00_800B":"The heatbed marker was not detected. Please clear all objects and remove the mat. Make sure the marker is not obstructed.","0C00_8015":"Objects detected on the platform; please clean them up in a timely manner.","0C00_8016":"The foreign object detection function is not working. You can continue the task or check assistant for solutions.","0C00_8017":"Foreign objects detected on the platform; please clean them up on time.","0C00_8018":"The foreign object detection function is not working. You can continue the task or view the assistant for troubleshooting.","0C00_8033":"Quick-release Lever is not locked. Please push it down to secure.","0C00_8034":"Liveview Camera initialization failed. This print can still continue, but some AI functions will be disabled. If you encounter this issue again after restarting, please contact customer support.","0C00_803F":"AI detected nozzle clumping. Please check the nozzle condition. Refer to assistant for solutions.","0C00_8040":"AI detected air-printing defect. Please check the hotend extrusion status. Refer to assistant for solutions.","0C00_8042":"The AI print monitor has detected a spaghetti defect. Please check the print and take the necessary action.","0C00_8043":"AI detected nozzle clumping. Please check the nozzle condition. Refer to assistant for solutions.","0C00_C003":"Possible defects were detected in the first layer.","0C00_C004":"Possible spaghetti failure was detected.","0C00_C006":"Purged filament may have piled up in the waste chute.","1000_C001":"High bed temperature may lead to filament clogging in the nozzle. You may open the chamber door.","1000_C002":"Printing CF material with stainless steel may cause nozzle damage.","1000_C003":"Enabling Timelapse in traditional mode may cause defects; please activate this feature as needed.","1001_4001":"Timelapse is not supported as Spiral Vase mode is enabled in slicing presets.","1001_4002":"Timelapse is not supported as the Print sequence is set to 'By object'.","1001_8003":"The time-lapse mode is set to Traditional in the slicing file. This may cause surface defects. Would you like to enable it?","1001_8004":"Prime Tower is not enabled and time-lapse mode is set to Smooth in slicing file. This may cause surface defects. Would you like to enable it?","1200_4001":"Filament is still loaded from the AMS when it has been disabled. Please unload AMS filament, load from spool holder, and restart print job.","1200_8001":"Cutting the filament failed. Please check to see if the cutter is stuck. Refer to the Assistant for solutions.","1200_8002":"The cutter is stuck. Please pull out the cutter handle.","1200_8003":"Failed to pull out the filament from the extruder. Please check whether the extruder is clogged or whether the filament is broken inside the extruder.","1200_8004":"Failed to pull back the filament from the toolhead. Please check whether the filament is stuck.","1200_8005":"The filament is not inserted. Please insert the filament.","1200_8006":"Unable to feed filament into the extruder. This could be due to tangled filament or a stuck spool. If not, please check if the AMS PTFE tube is connected.","1200_8007":"Failed to extrude the filament. This might be caused by clogged extruder or stuck filament. Refer to the Assistant for solutions.","1200_8010":"Filament or spool may be stuck.","1200_8011":"AMS filament has run out. Please insert a new filament into the same AMS slot.","1200_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1200_8013":"Timeout while purging old filament. Please check if the filament is stuck or the extruder clogged.","1200_8014":"The filament location in the toolhead was not found. Refer to the Assistant for solutions.","1200_8015":"Failed to pull out the filament from the toolhead. Please check if the filament is stuck, or if it is broken inside the extruder or PTFE tube.","1200_8016":"The extruder is not extruding normally. Refer to the Assistant for troubleshooting. There may be defects in this layer, but you may resume if the defects are acceptable.","1201_4001":"Filament is still loaded from the AMS when it has been disabled. Please unload AMS filament, load from spool holder, and restart print job.","1201_8001":"Failed to cut the filament. Please check the cutter.","1201_8002":"The cutter is stuck. Please pull out the cutter handle.","1201_8003":"Failed to pull out the filament from the extruder. Please check whether the extruder is clogged or whether the filament is broken inside the extruder.","1201_8004":"Failed to pull back the filament from the toolhead. Please check whether the filament is stuck.","1201_8005":"Failed to feed the filament. Please load the filament and then select 'Retry'.","1201_8006":"Failed to feed the filament into the toolhead. Please check whether the filament is stuck.","1201_8007":"Failed to extrude the filament. The extruder may be clogged or the filament may be stuck; please refer to HMS.","1201_8010":"Please check if the spool or filament is stuck.","1201_8011":"AMS filament has run out. Please insert a new filament into the same AMS slot.","1201_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1201_8013":"Timeout while purging old filament. Please check if the filament is stuck or the extruder clogged.","1201_8014":"Failed to check the filament location in the tool head; please refer to the HMS.","1201_8015":"Failed to pull back the filament from the toolhead. Please check if the filament is stuck or the filament is broken inside the extruder.","1201_8016":"The extruder is not extruding normally; please refer to the HMS. After trouble shooting, if the defects are acceptable, please resume printing.","1202_4001":"Filament is still loaded from the AMS when it has been disabled. Please unload AMS filament, load from spool holder, and restart print job.","1202_8001":"Failed to cut the filament. Please check the cutter.","1202_8002":"The cutter is stuck. Please pull out the cutter handle.","1202_8003":"Failed to pull out the filament from the extruder. Please check whether the extruder is clogged or whether the filament is broken inside the extruder.","1202_8004":"Failed to pull back the filament from the toolhead. Please check whether the filament is stuck.","1202_8005":"The filament is not inserted. Please insert the filament.","1202_8006":"Failed to feed the filament into the toolhead. Please check whether the filament is stuck.","1202_8007":"Failed to extrude the filament. The extruder may be clogged or the filament may be stuck; please refer to HMS.","1202_8010":"Please check if the spool or filament is stuck.","1202_8011":"AMS filament has run out. Please insert a new filament into the same AMS slot.","1202_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1202_8013":"Timeout while purging old filament. Please check if the filament is stuck or the extruder clogged.","1202_8014":"Failed to check the filament location in the tool head; please refer to the HMS.","1202_8015":"Failed to pull back the filament from the toolhead. Please check if the filament is stuck or is broken inside the extruder.","1202_8016":"The extruder is not extruding normally; please refer to the HMS. After trouble shooting, if the defects are acceptable, please resume printing.","1203_4001":"Filament is still loaded from the AMS when it has been disabled. Please unload AMS filament, load from spool holder, and restart print job.","1203_8001":"Failed to cut the filament. Please check the cutter.","1203_8002":"The cutter is stuck. Please pull out the cutter handle.","1203_8003":"Failed to pull out the filament from the extruder. Please check whether the extruder is clogged or whether the filament is broken inside the extruder.","1203_8004":"Failed to pull back the filament from the toolhead. Please check whether the filament is stuck.","1203_8005":"The filament is not inserted. Please insert the filament.","1203_8006":"Failed to feed the filament into the toolhead. Please check whether the filament is stuck.","1203_8007":"Failed to extrude the filament. The extruder may be clogged or the filament may be stuck; please refer to HMS.","1203_8010":"Please check if the spool or filament is stuck.","1203_8011":"AMS filament has run out. Please insert a new filament into the same AMS slot.","1203_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1203_8013":"Timeout while purging old filament. Please check if the filament is stuck or the extruder clogged.","1203_8014":"Failed to check the filament location in the tool head; please refer to the HMS.","1203_8015":"Failed to pull back the filament from the toolhead. Please check if the filament is stuck or is broken inside the extruder.","1203_8016":"The extruder is not extruding normally; please refer to the HMS. After trouble shooting, if the defects are acceptable, please resume printing.","12FF_4001":"Filament is still loaded from the AMS when it has been disabled. Please unload AMS filament, load from spool holder, and restart print job.","12FF_8001":"Failed to cut the filament. Please check the cutter.","12FF_8002":"The cutter is stuck. Please pull out the cutter handle.","12FF_8003":"Please pull out the filament on the spool holder. If this message persists, please check to see if there is filament broken in the extruder or PTFE tube. (Connect a PTFE tube if you are about to us...","12FF_8004":"Failed to pull back the filament from the toolhead. Please check whether the filament is stuck.","12FF_8005":"The filament is not inserted. Please insert the filament.","12FF_8006":"Please feed filament into the PTFE tube until it can not be pushed any farther.","12FF_8007":"Check nozzle. Select 'Done' if filament was extruded, otherwise push filament forward slightly and select 'Retry.'","12FF_8010":"Please check if the filament or the spool is stuck.","12FF_8011":"AMS filament has run out. Please insert a new filament into the same AMS slot.","12FF_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","12FF_8013":"Timeout while purging old filament. Please check if the filament is stuck or the extruder clogged.","12FF_C003":"Please pull out the filament on the spool holder. If this message persists, please check to see if there is filament broken in the extruder or PTFE Tube. (Connect a PTFE tube if you are about to us...","12FF_C006":"Please feed filament into the PTFE tube until it can not be pushed any farther.","1800_4025":"Failed to read the filament information.","1800_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","1800_8004":"AMS-HT failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","1800_8005":"The AMS-HT failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","1800_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","1800_8007":"Extruding filament failed. The extruder might be clogged.","1800_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS-HT A to the extruder is properly connected.","1800_8010":"The AMS-HT assist motor is overloaded. This could be due to entangled filament or a stuck spool.","1800_8011":"AMS-HT filament ran out. Please insert a new filament into the same AMS-HT slot.","1800_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1800_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","1800_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","1800_8017":"AMS-HT A is drying. Please stop drying process before loading/unloading material.","1800_8021":"AMS setup failed; please refer to the assistant.","1800_8023":"AMS-HT A cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","1800_C069":"An error occurred during AMS-HT A drying. Please go to Assistant for more details.","1800_C06A":"AMS-HT A is reading RFID. Unable to start drying. Please try again later.","1800_C06B":"AMS-HT A is changing filament. Unable to start drying. Please try again later.","1800_C06C":"AMS-HT A is in Feed Assist Mode. Unable to start drying. Please try again later.","1800_C06D":"AMS-HT A is assisting in filament insertion. Unable to start drying. Please try again later.","1800_C06E":"AMS-HT A motor is performing self-test. Unable to start drying. Please try again later.","1801_4025":"Failed to read the filament information.","1801_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","1801_8004":"AMS-HT failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","1801_8005":"The AMS-HT failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","1801_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","1801_8007":"Extruding filament failed. The extruder might be clogged.","1801_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS-HT B to the extruder is properly connected.","1801_8010":"The AMS-HT assist motor is overloaded. This could be due to entangled filament or a stuck spool.","1801_8011":"AMS-HT filament ran out. Please insert a new filament into the same AMS-HT slot.","1801_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1801_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","1801_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","1801_8017":"AMS-HT B is drying. Please stop drying process before loading/unloading material.","1801_8021":"AMS setup failed; please refer to the assistant.","1801_8023":"AMS-HT B cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","1801_C069":"An error occurred during AMS-HT B drying. Please go to Assistant for more details.","1801_C06A":"AMS-HT B is reading RFID. Unable to start drying. Please try again later.","1801_C06B":"AMS-HT B is changing filament. Unable to start drying. Please try again later.","1801_C06C":"AMS-HT B is in Feed Assist Mode. Unable to start drying. Please try again later.","1801_C06D":"AMS-HT B is assisting in filament insertion. Unable to start drying. Please try again later.","1801_C06E":"AMS-HT B motor is performing self-test. Unable to start drying. Please try again later.","1802_4025":"Failed to read the filament information.","1802_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","1802_8004":"AMS-HT failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","1802_8005":"The AMS-HT failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","1802_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","1802_8007":"Extruding filament failed. The extruder might be clogged.","1802_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS-HT C to the extruder is properly connected.","1802_8010":"The AMS-HT assist motor is overloaded. This could be due to entangled filament or a stuck spool.","1802_8011":"AMS-HT filament ran out. Please insert a new filament into the same AMS-HT slot.","1802_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1802_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","1802_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","1802_8017":"AMS-HT C is drying. Please stop drying process before loading/unloading material.","1802_8021":"AMS setup failed; please refer to the assistant.","1802_8023":"AMS-HT C cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","1802_C069":"An error occurred during AMS-HT C drying. Please go to Assistant for more details.","1802_C06A":"AMS-HT C is reading RFID. Unable to start drying. Please try again later.","1802_C06B":"AMS-HT C is changing filament. Unable to start drying. Please try again later.","1802_C06C":"AMS-HT C is in Feed Assist Mode. Unable to start drying. Please try again later.","1802_C06D":"AMS-HT C is assisting in filament insertion. Unable to start drying. Please try again later.","1802_C06E":"AMS-HT C motor is performing self-test. Unable to start drying. Please try again later.","1803_4025":"Failed to read the filament information.","1803_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","1803_8004":"AMS-HT failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","1803_8005":"The AMS-HT failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","1803_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","1803_8007":"Extruding filament failed. The extruder might be clogged.","1803_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS-HT D to the extruder is properly connected.","1803_8010":"The AMS-HT assist motor is overloaded. This could be due to entangled filament or a stuck spool.","1803_8011":"AMS-HT filament ran out. Please insert a new filament into the same AMS-HT slot.","1803_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1803_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","1803_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","1803_8017":"AMS-HT D is drying. Please stop drying process before loading/unloading material.","1803_8021":"AMS setup failed; please refer to the assistant.","1803_8023":"AMS-HT D cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","1803_C069":"An error occurred during AMS-HT D drying. Please go to Assistant for more details.","1803_C06A":"AMS-HT D is reading RFID. Unable to start drying. Please try again later.","1803_C06B":"AMS-HT D is changing filament. Unable to start drying. Please try again later.","1803_C06C":"AMS-HT D is in Feed Assist Mode. Unable to start drying. Please try again later.","1803_C06D":"AMS-HT D is assisting in filament insertion. Unable to start drying. Please try again later.","1803_C06E":"AMS-HT D motor is performing self-test. Unable to start drying. Please try again later.","1804_4025":"Failed to read the filament information.","1804_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","1804_8004":"AMS-HT failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","1804_8005":"The AMS-HT failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","1804_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","1804_8007":"Extruding filament failed. The extruder might be clogged.","1804_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS-HT E to the extruder is properly connected.","1804_8010":"The AMS-HT assist motor is overloaded. This could be due to entangled filament or a stuck spool.","1804_8011":"AMS-HT filament ran out. Please insert a new filament into the same AMS-HT slot.","1804_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1804_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","1804_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","1804_8021":"AMS setup failed; please refer to the assistant.","1804_8023":"AMS-HT E cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","1804_C069":"An error occurred during AMS-HT E drying. Please go to Assistant for more details.","1804_C06A":"AMS-HT E is reading RFID. Unable to start drying. Please try again later.","1804_C06B":"AMS-HT E is changing filament. Unable to start drying. Please try again later.","1804_C06C":"AMS-HT E is in Feed Assist Mode. Unable to start drying. Please try again later.","1804_C06D":"AMS-HT E is assisting in filament insertion. Unable to start drying. Please try again later.","1804_C06E":"AMS-HT E motor is performing self-test. Unable to start drying. Please try again later.","1805_4025":"Failed to read the filament information.","1805_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","1805_8004":"AMS-HT failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","1805_8005":"The AMS-HT failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","1805_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","1805_8007":"Extruding filament failed. The extruder might be clogged.","1805_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS-HT F to the extruder is properly connected.","1805_8010":"The AMS-HT assist motor is overloaded. This could be due to entangled filament or a stuck spool.","1805_8011":"AMS-HT filament ran out. Please insert a new filament into the same AMS-HT slot.","1805_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1805_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","1805_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","1805_8021":"AMS setup failed; please refer to the assistant.","1805_8023":"AMS-HT F cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","1805_C069":"An error occurred during AMS-HT F drying. Please go to Assistant for more details.","1805_C06A":"AMS-HT F is reading RFID. Unable to start drying. Please try again later.","1805_C06B":"AMS-HT F is changing filament. Unable to start drying. Please try again later.","1805_C06C":"AMS-HT F is in Feed Assist Mode. Unable to start drying. Please try again later.","1805_C06D":"AMS-HT F is assisting in filament insertion. Unable to start drying. Please try again later.","1805_C06E":"AMS-HT F motor is performing self-test. Unable to start drying. Please try again later.","1806_4025":"Failed to read the filament information.","1806_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","1806_8004":"AMS-HT failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","1806_8005":"The AMS-HT failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","1806_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","1806_8007":"Extruding filament failed. The extruder might be clogged.","1806_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS-HT G to the extruder is properly connected.","1806_8010":"The AMS-HT assist motor is overloaded. This could be due to entangled filament or a stuck spool.","1806_8011":"AMS-HT filament ran out. Please insert a new filament into the same AMS-HT slot.","1806_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1806_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","1806_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","1806_8021":"AMS setup failed; please refer to the assistant.","1806_8023":"AMS-HT G cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","1806_C069":"An error occurred during AMS-HT G drying. Please go to Assistant for more details.","1806_C06A":"AMS-HT G is reading RFID. Unable to start drying. Please try again later.","1806_C06B":"AMS-HT G is changing filament. Unable to start drying. Please try again later.","1806_C06C":"AMS-HT G is in Feed Assist Mode. Unable to start drying. Please try again later.","1806_C06D":"AMS-HT G is assisting in filament insertion. Unable to start drying. Please try again later.","1806_C06E":"AMS-HT G motor is performing self-test. Unable to start drying. Please try again later.","1807_4025":"Failed to read the filament information.","1807_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","1807_8004":"AMS-HT failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","1807_8005":"The AMS-HT failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","1807_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","1807_8007":"Extruding filament failed. The extruder might be clogged.","1807_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS-HT H to the extruder is properly connected.","1807_8010":"The AMS-HT assist motor is overloaded. This could be due to entangled filament or a stuck spool.","1807_8011":"AMS-HT filament ran out. Please insert a new filament into the same AMS-HT slot.","1807_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1807_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","1807_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","1807_8021":"AMS setup failed; please refer to the assistant.","1807_8023":"AMS-HT H cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","1807_C069":"An error occurred during AMS-HT H drying. Please go to Assistant for more details.","1807_C06A":"AMS-HT H is reading RFID. Unable to start drying. Please try again later.","1807_C06B":"AMS-HT H is changing filament. Unable to start drying. Please try again later.","1807_C06C":"AMS-HT H is in Feed Assist Mode. Unable to start drying. Please try again later.","1807_C06D":"AMS-HT H is assisting in filament insertion. Unable to start drying. Please try again later.","1807_C06E":"AMS-HT H motor is performing self-test. Unable to start drying. Please try again later.","18FE_8001":"Failed to cut the filament of the left extruder. Please check the cutter.","18FE_8002":"The cutter of the left extruder is stuck. Please pull out the cutter handle.","18FE_8003":"Please pull out the filament on the spool holder of the left extruder. If this message persists, please check to see if there is filament broken in the extruder. (Connect a PTFE tube if you are ab...","18FE_8004":"Failed to pull back the filament from the left extruder. Please check whether the filament is stuck inside the extruder.","18FE_8005":"Failed to feed the filament outside the AMS-HT. Please clip the end of the filament flat and check to see if the spool is stuck.","18FE_8006":"Please feed filament into the PTFE tube of the left extruder until it can not be pushed any farther.","18FE_8007":"Please observe the nozzle of the left extruder. If the filament has been extruded, select 'Continue'; if it has not, please push the filament forward slightly, and then select 'Retry'.","18FE_8011":"The external filament connected to the left extruder has run out; please load a new filament.","18FE_8012":"Failed to get mapping table; please select 'Resume' to retry.","18FE_8013":"Timeout purging old filament of the left extruder: Please check if the filament is stuck or the extruder is clogged.","18FE_8020":"Extruder change failed; please refer to the assistant.","18FE_8021":"AMS setup failed; please refer to the assistant.","18FE_8024":"Extruder position calibration failed; please refer to the assistant.","18FE_C003":"Please pull out the filament on the spool holder of the left extruder. If this message persists, please check to see if there is filament broken in the extruder or PTFE tube. (Connect a PTFE tube i...","18FE_C006":"Please feed filament into the PTFE tube of the left extruder until it can not be pushed any farther.","18FE_C008":"Please pull out the filament on the spool holder of the left extruder. If this message persists, please check to see if there is filament broken in the extruder or PTFE tube. (Connect a PTFE tube i...","18FE_C009":"Please feed filament into the PTFE tube of the left extruder until it can not be pushed any farther.","18FE_C00A":"Please observe the nozzle of the left extruder. If the filament has been extruded, select 'Continue'; if not, please push the filament forward slightly and then select 'Retry'.","18FF_8001":"Failed to cut the filament of the right extruder. Please check the cutter.","18FF_8002":"The cutter of the right extruder is stuck. Please pull out the cutter handle.","18FF_8003":"Please pull out the filament on the spool holder of the right extruder. If this message persists, please check to see if there is filament broken in the extruder. (Connect a PTFE tube if you are a...","18FF_8004":"Failed to pull back the filament from the right extruder. Please check whether the filament is stuck inside the extruder.","18FF_8005":"Failed to feed the filament outside the AMS-HT. Please clip the end of the filament flat and check to see if the spool is stuck.","18FF_8006":"Please feed filament into the PTFE tube of the right extruder until it can not be pushed any farther.","18FF_8007":"Please observe the nozzle of the right extruder. If the filament has been extruded, select 'Continue'; if it has not, please push the filament forward slightly, and then select 'Retry'.","18FF_8011":"The external filament connected to the right extruder has run out; please load a new filament.","18FF_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","18FF_8013":"Timeout purging old filament of the right extruder: Please check if the filament is stuck or the extruder is clogged.","18FF_8020":"Extruder change failed; please refer to the assistant.","18FF_8021":"AMS setup failed; please refer to the assistant.","18FF_8024":"Extruder position calibration failed; please refer to the assistant.","18FF_C003":"Please pull out the filament on the spool holder of the right extruder. If this message persists, please check to see if there is filament broken in the extruder or PTFE tube. (Connect a PTFE tube ...","18FF_C006":"Please feed filament into the PTFE tube of the right extruder until it can not be pushed any farther.","18FF_C008":"Please pull out the filament on the spool holder of the right extruder. If this message persists, please check to see if there is filament broken in the extruder or PTFE tube. (Connect a PTFE tube ...","18FF_C009":"Please feed filament into the PTFE tube of the right extruder until it can not be pushed any farther.","18FF_C00A":"Please observe the nozzle of the right extruder. If the filament has been extruded, select 'Continue'; if not, please push the filament forward slightly and then select 'Retry'."};function Vfe(t){switch(t){case 1:return{label:"Fatal",color:"text-red-500",bgColor:"bg-red-500/20",Icon:Cn};case 2:return{label:"Serious",color:"text-red-400",bgColor:"bg-red-500/15",Icon:Cn};case 3:return{label:"Warning",color:"text-orange-400",bgColor:"bg-orange-500/20",Icon:Hi};case 4:default:return{label:"Info",color:"text-blue-400",bgColor:"bg-blue-500/20",Icon:Zo}}}function wP(t,e){const n=t>>16&65535||(t>>8&255)<<8|t&255,r=e&65535;return`${n.toString(16).padStart(4,"0").toUpperCase()}_${r.toString(16).padStart(4,"0").toUpperCase()}`}function Gfe(t){return t.filter(e=>{const n=parseInt(e.code.replace("0x",""),16)||0,r=wP(e.attr,n);return vP[r]!==void 0})}function qfe(){return"https://wiki.bambulab.com/en/hms/home"}function Wfe({printerName:t,errors:e,onClose:n}){const{t:r}=Hn();console.log("HMSErrorModal errors:",JSON.stringify(e,null,2));const i=e.filter(a=>{const o=parseInt(a.code.replace("0x",""),16)||0,l=wP(a.attr,o);return vP[l]!==void 0});return _.useEffect(()=>{const a=o=>{o.key==="Escape"&&n()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[n]),s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg shadow-xl max-w-lg w-full max-h-[80vh] flex flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Cn,{className:"w-5 h-5 text-orange-400"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:r("hmsErrors.title",{name:t})})]}),s.jsx("button",{onClick:n,className:"p-1 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:s.jsx(Rt,{className:"w-5 h-5 text-bambu-gray"})})]}),s.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:i.length===0?s.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[s.jsx(Hi,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),s.jsx("p",{children:r("hmsErrors.noErrors")})]}):s.jsx("div",{className:"space-y-3",children:i.map((a,o)=>{const{label:l,color:c,bgColor:u,Icon:d}=Vfe(a.severity),f=parseInt(a.code.replace("0x",""),16)||0,p=wP(a.attr,f),m=vP[p],x=qfe(),b=p.replace("_","-");return s.jsx("div",{className:`p-4 rounded-lg ${u} border border-white/10`,children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(d,{className:`w-5 h-5 ${c} flex-shrink-0 mt-0.5`}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[s.jsxs("span",{className:`font-mono text-sm ${c}`,children:["[",b,"]"]}),s.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full ${u} ${c}`,children:l})]}),s.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:m}),s.jsxs("a",{href:x,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-bambu-green hover:underline",children:[s.jsx(Kr,{className:"w-3 h-3"}),r("hmsErrors.viewOnWiki")]})]})]})},`${a.code}-${o}`)})})}),s.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:s.jsx("p",{className:"text-xs text-bambu-gray",children:r("hmsErrors.clearInstructions")})})]})})}function Kfe(t){if(!t)return"ASAP";const e=Ii(t);if(!e)return"ASAP";const n=new Date,r=e.getTime()-n.getTime();return r<0?"Now":r<6e4?"In <1 min":r<36e5?`In ${Math.round(r/6e4)} min`:r<864e5?`In ${Math.round(r/36e5)}h`:e.toLocaleDateString()}function Xfe({printerId:t}){const{data:e}=at({queryKey:["queue",t,"pending"],queryFn:()=>ue.getQueue(t,"pending"),refetchInterval:3e4}),n=e?.[0],r=e?.length||0;return r===0?null:s.jsx(Ds,{to:"/queue",className:"block mb-3 p-3 bg-bambu-dark rounded-lg hover:bg-bambu-dark-tertiary transition-colors",children:s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[s.jsx(si,{className:"w-5 h-5 text-yellow-400 flex-shrink-0"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"text-xs text-bambu-gray",children:"Next in queue"}),s.jsx("p",{className:"text-sm text-white truncate",children:n?.archive_name||`Archive #${n?.archive_id}`})]})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsxs("span",{className:"text-xs text-bambu-gray flex items-center gap-1",children:[s.jsx(er,{className:"w-3 h-3"}),Kfe(n?.scheduled_time||null)]}),r>1&&s.jsxs("span",{className:"text-xs px-1.5 py-0.5 bg-yellow-400/20 text-yellow-400 rounded",children:["+",r-1]}),s.jsx(gs,{className:"w-4 h-4 text-bambu-gray"})]})]})})}function LW(t){var e,n,r="";if(typeof t=="string"||typeof t=="number")r+=t;else if(typeof t=="object")if(Array.isArray(t)){var i=t.length;for(e=0;e<i;e++)t[e]&&(n=LW(t[e]))&&(r&&(r+=" "),r+=n)}else for(n in t)t[n]&&(r&&(r+=" "),r+=n);return r}function tr(){for(var t,e,n=0,r="",i=arguments.length;n<i;n++)(t=arguments[n])&&(e=LW(t))&&(r&&(r+=" "),r+=e);return r}var Yfe=["dangerouslySetInnerHTML","onCopy","onCopyCapture","onCut","onCutCapture","onPaste","onPasteCapture","onCompositionEnd","onCompositionEndCapture","onCompositionStart","onCompositionStartCapture","onCompositionUpdate","onCompositionUpdateCapture","onFocus","onFocusCapture","onBlur","onBlurCapture","onChange","onChangeCapture","onBeforeInput","onBeforeInputCapture","onInput","onInputCapture","onReset","onResetCapture","onSubmit","onSubmitCapture","onInvalid","onInvalidCapture","onLoad","onLoadCapture","onError","onErrorCapture","onKeyDown","onKeyDownCapture","onKeyPress","onKeyPressCapture","onKeyUp","onKeyUpCapture","onAbort","onAbortCapture","onCanPlay","onCanPlayCapture","onCanPlayThrough","onCanPlayThroughCapture","onDurationChange","onDurationChangeCapture","onEmptied","onEmptiedCapture","onEncrypted","onEncryptedCapture","onEnded","onEndedCapture","onLoadedData","onLoadedDataCapture","onLoadedMetadata","onLoadedMetadataCapture","onLoadStart","onLoadStartCapture","onPause","onPauseCapture","onPlay","onPlayCapture","onPlaying","onPlayingCapture","onProgress","onProgressCapture","onRateChange","onRateChangeCapture","onSeeked","onSeekedCapture","onSeeking","onSeekingCapture","onStalled","onStalledCapture","onSuspend","onSuspendCapture","onTimeUpdate","onTimeUpdateCapture","onVolumeChange","onVolumeChangeCapture","onWaiting","onWaitingCapture","onAuxClick","onAuxClickCapture","onClick","onClickCapture","onContextMenu","onContextMenuCapture","onDoubleClick","onDoubleClickCapture","onDrag","onDragCapture","onDragEnd","onDragEndCapture","onDragEnter","onDragEnterCapture","onDragExit","onDragExitCapture","onDragLeave","onDragLeaveCapture","onDragOver","onDragOverCapture","onDragStart","onDragStartCapture","onDrop","onDropCapture","onMouseDown","onMouseDownCapture","onMouseEnter","onMouseLeave","onMouseMove","onMouseMoveCapture","onMouseOut","onMouseOutCapture","onMouseOver","onMouseOverCapture","onMouseUp","onMouseUpCapture","onSelect","onSelectCapture","onTouchCancel","onTouchCancelCapture","onTouchEnd","onTouchEndCapture","onTouchMove","onTouchMoveCapture","onTouchStart","onTouchStartCapture","onPointerDown","onPointerDownCapture","onPointerMove","onPointerMoveCapture","onPointerUp","onPointerUpCapture","onPointerCancel","onPointerCancelCapture","onPointerEnter","onPointerEnterCapture","onPointerLeave","onPointerLeaveCapture","onPointerOver","onPointerOverCapture","onPointerOut","onPointerOutCapture","onGotPointerCapture","onGotPointerCaptureCapture","onLostPointerCapture","onLostPointerCaptureCapture","onScroll","onScrollCapture","onWheel","onWheelCapture","onAnimationStart","onAnimationStartCapture","onAnimationEnd","onAnimationEndCapture","onAnimationIteration","onAnimationIterationCapture","onTransitionEnd","onTransitionEndCapture"];function UR(t){if(typeof t!="string")return!1;var e=Yfe;return e.includes(t)}var Qfe=["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"],Zfe=new Set(Qfe);function FW(t){return typeof t!="string"?!1:Zfe.has(t)}function IW(t){return typeof t=="string"&&t.startsWith("data-")}function xs(t){if(typeof t!="object"||t===null)return{};var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(FW(n)||IW(n))&&(e[n]=t[n]);return e}function lm(t){if(t==null)return null;if(_.isValidElement(t)&&typeof t.props=="object"&&t.props!==null){var e=t.props;return xs(e)}return typeof t=="object"&&!Array.isArray(t)?xs(t):null}function za(t){var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(FW(n)||IW(n)||UR(n))&&(e[n]=t[n]);return e}function Jfe(t){return t==null?null:_.isValidElement(t)?za(t.props):typeof t=="object"&&!Array.isArray(t)?za(t):null}var eme=["children","width","height","viewBox","className","style","title","desc"];function _P(){return _P=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},_P.apply(null,arguments)}function tme(t,e){if(t==null)return{};var n,r,i=nme(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function nme(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var zR=_.forwardRef((t,e)=>{var{children:n,width:r,height:i,viewBox:a,className:o,style:l,title:c,desc:u}=t,d=tme(t,eme),f=a||{width:r,height:i,x:0,y:0},p=tr("recharts-surface",o);return _.createElement("svg",_P({},za(d),{className:p,width:r,height:i,style:l,viewBox:"".concat(f.x," ").concat(f.y," ").concat(f.width," ").concat(f.height),ref:e}),_.createElement("title",null,c),_.createElement("desc",null,u),n)}),rme=["children","className"];function SP(){return SP=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},SP.apply(null,arguments)}function ime(t,e){if(t==null)return{};var n,r,i=ame(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function 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 oi=_.forwardRef((t,e)=>{var{children:n,className:r}=t,i=ime(t,rme),a=tr("recharts-layer",r);return _.createElement("g",SP({className:a},za(i),{ref:e}),n)}),UW=_.createContext(null),sme=()=>_.useContext(UW);function Ir(t){return function(){return t}}const zW=Math.cos,X1=Math.sin,Bl=Math.sqrt,Y1=Math.PI,vN=2*Y1,MP=Math.PI,NP=2*MP,vf=1e-6,ome=NP-vf;function BW(t){this._+=t[0];for(let e=1,n=t.length;e<n;++e)this._+=arguments[e]+t[e]}function lme(t){let e=Math.floor(t);if(!(e>=0))throw new Error(`invalid digits: ${t}`);if(e>15)return BW;const n=10**e;return function(r){this._+=r[0];for(let i=1,a=r.length;i<a;++i)this._+=Math.round(arguments[i]*n)/n+r[i]}}class cme{constructor(e){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=e==null?BW:lme(e)}moveTo(e,n){this._append`M${this._x0=this._x1=+e},${this._y0=this._y1=+n}`}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._append`Z`)}lineTo(e,n){this._append`L${this._x1=+e},${this._y1=+n}`}quadraticCurveTo(e,n,r,i){this._append`Q${+e},${+n},${this._x1=+r},${this._y1=+i}`}bezierCurveTo(e,n,r,i,a,o){this._append`C${+e},${+n},${+r},${+i},${this._x1=+a},${this._y1=+o}`}arcTo(e,n,r,i,a){if(e=+e,n=+n,r=+r,i=+i,a=+a,a<0)throw new Error(`negative radius: ${a}`);let o=this._x1,l=this._y1,c=r-e,u=i-n,d=o-e,f=l-n,p=d*d+f*f;if(this._x1===null)this._append`M${this._x1=e},${this._y1=n}`;else if(p>vf)if(!(Math.abs(f*c-u*d)>vf)||!a)this._append`L${this._x1=e},${this._y1=n}`;else{let m=r-o,x=i-l,b=c*c+u*u,y=m*m+x*x,v=Math.sqrt(b),S=Math.sqrt(p),N=a*Math.tan((MP-Math.acos((b+p-y)/(2*v*S)))/2),T=N/S,k=N/v;Math.abs(T-1)>vf&&this._append`L${e+T*d},${n+T*f}`,this._append`A${a},${a},0,0,${+(f*m>d*x)},${this._x1=e+k*c},${this._y1=n+k*u}`}}arc(e,n,r,i,a,o){if(e=+e,n=+n,r=+r,o=!!o,r<0)throw new Error(`negative radius: ${r}`);let l=r*Math.cos(i),c=r*Math.sin(i),u=e+l,d=n+c,f=1^o,p=o?i-a:a-i;this._x1===null?this._append`M${u},${d}`:(Math.abs(this._x1-u)>vf||Math.abs(this._y1-d)>vf)&&this._append`L${u},${d}`,r&&(p<0&&(p=p%NP+NP),p>ome?this._append`A${r},${r},0,1,${f},${e-l},${n-c}A${r},${r},0,1,${f},${this._x1=u},${this._y1=d}`:p>vf&&this._append`A${r},${r},0,${+(p>=MP)},${f},${this._x1=e+r*Math.cos(a)},${this._y1=n+r*Math.sin(a)}`)}rect(e,n,r,i){this._append`M${this._x0=this._x1=+e},${this._y0=this._y1=+n}h${r=+r}v${+i}h${-r}Z`}toString(){return this._}}function BR(t){let e=3;return t.digits=function(n){if(!arguments.length)return e;if(n==null)e=null;else{const r=Math.floor(n);if(!(r>=0))throw new RangeError(`invalid digits: ${n}`);e=r}return t},()=>new cme(e)}function HR(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function HW(t){this._context=t}HW.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 wN(t){return new HW(t)}function $W(t){return t[0]}function VW(t){return t[1]}function GW(t,e){var n=Ir(!0),r=null,i=wN,a=null,o=BR(l);t=typeof t=="function"?t:t===void 0?$W:Ir(t),e=typeof e=="function"?e:e===void 0?VW:Ir(e);function l(c){var u,d=(c=HR(c)).length,f,p=!1,m;for(r==null&&(a=i(m=o())),u=0;u<=d;++u)!(u<d&&n(f=c[u],u,c))===p&&((p=!p)?a.lineStart():a.lineEnd()),p&&a.point(+t(f,u,c),+e(f,u,c));if(m)return a=null,m+""||null}return l.x=function(c){return arguments.length?(t=typeof c=="function"?c:Ir(+c),l):t},l.y=function(c){return arguments.length?(e=typeof c=="function"?c:Ir(+c),l):e},l.defined=function(c){return arguments.length?(n=typeof c=="function"?c:Ir(!!c),l):n},l.curve=function(c){return arguments.length?(i=c,r!=null&&(a=i(r)),l):i},l.context=function(c){return arguments.length?(c==null?r=a=null:a=i(r=c),l):r},l}function Rw(t,e,n){var r=null,i=Ir(!0),a=null,o=wN,l=null,c=BR(u);t=typeof t=="function"?t:t===void 0?$W:Ir(+t),e=typeof e=="function"?e:Ir(e===void 0?0:+e),n=typeof n=="function"?n:n===void 0?VW:Ir(+n);function u(f){var p,m,x,b=(f=HR(f)).length,y,v=!1,S,N=new Array(b),T=new Array(b);for(a==null&&(l=o(S=c())),p=0;p<=b;++p){if(!(p<b&&i(y=f[p],p,f))===v)if(v=!v)m=p,l.areaStart(),l.lineStart();else{for(l.lineEnd(),l.lineStart(),x=p-1;x>=m;--x)l.point(N[x],T[x]);l.lineEnd(),l.areaEnd()}v&&(N[p]=+t(y,p,f),T[p]=+e(y,p,f),l.point(r?+r(y,p,f):N[p],n?+n(y,p,f):T[p]))}if(S)return l=null,S+""||null}function d(){return GW().defined(i).curve(o).context(a)}return u.x=function(f){return arguments.length?(t=typeof f=="function"?f:Ir(+f),r=null,u):t},u.x0=function(f){return arguments.length?(t=typeof f=="function"?f:Ir(+f),u):t},u.x1=function(f){return arguments.length?(r=f==null?null:typeof f=="function"?f:Ir(+f),u):r},u.y=function(f){return arguments.length?(e=typeof f=="function"?f:Ir(+f),n=null,u):e},u.y0=function(f){return arguments.length?(e=typeof f=="function"?f:Ir(+f),u):e},u.y1=function(f){return arguments.length?(n=f==null?null:typeof f=="function"?f:Ir(+f),u):n},u.lineX0=u.lineY0=function(){return d().x(t).y(e)},u.lineY1=function(){return d().x(t).y(n)},u.lineX1=function(){return d().x(r).y(e)},u.defined=function(f){return arguments.length?(i=typeof f=="function"?f:Ir(!!f),u):i},u.curve=function(f){return arguments.length?(o=f,a!=null&&(l=o(a)),u):o},u.context=function(f){return arguments.length?(f==null?a=l=null:l=o(a=f),u):a},u}class qW{constructor(e,n){this._context=e,this._x=n}areaStart(){this._line=0}areaEnd(){this._line=NaN}lineStart(){this._point=0}lineEnd(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line}point(e,n){switch(e=+e,n=+n,this._point){case 0:{this._point=1,this._line?this._context.lineTo(e,n):this._context.moveTo(e,n);break}case 1:this._point=2;default:{this._x?this._context.bezierCurveTo(this._x0=(this._x0+e)/2,this._y0,this._x0,n,e,n):this._context.bezierCurveTo(this._x0,this._y0=(this._y0+n)/2,e,this._y0,e,n);break}}this._x0=e,this._y0=n}}function ume(t){return new qW(t,!0)}function dme(t){return new qW(t,!1)}const $R={draw(t,e){const n=Bl(e/Y1);t.moveTo(n,0),t.arc(0,0,n,0,vN)}},hme={draw(t,e){const n=Bl(e/5)/2;t.moveTo(-3*n,-n),t.lineTo(-n,-n),t.lineTo(-n,-3*n),t.lineTo(n,-3*n),t.lineTo(n,-n),t.lineTo(3*n,-n),t.lineTo(3*n,n),t.lineTo(n,n),t.lineTo(n,3*n),t.lineTo(-n,3*n),t.lineTo(-n,n),t.lineTo(-3*n,n),t.closePath()}},WW=Bl(1/3),fme=WW*2,mme={draw(t,e){const n=Bl(e/fme),r=n*WW;t.moveTo(0,-n),t.lineTo(r,0),t.lineTo(0,n),t.lineTo(-r,0),t.closePath()}},pme={draw(t,e){const n=Bl(e),r=-n/2;t.rect(r,r,n,n)}},gme=.8908130915292852,KW=X1(Y1/10)/X1(7*Y1/10),xme=X1(vN/10)*KW,bme=-zW(vN/10)*KW,yme={draw(t,e){const n=Bl(e*gme),r=xme*n,i=bme*n;t.moveTo(0,-n),t.lineTo(r,i);for(let a=1;a<5;++a){const o=vN*a/5,l=zW(o),c=X1(o);t.lineTo(c*n,-l*n),t.lineTo(l*r-c*i,c*r+l*i)}t.closePath()}},sT=Bl(3),vme={draw(t,e){const n=-Bl(e/(sT*3));t.moveTo(0,n*2),t.lineTo(-sT*n,-n),t.lineTo(sT*n,-n),t.closePath()}},Ro=-.5,Oo=Bl(3)/2,kP=1/Bl(12),wme=(kP/2+1)*3,_me={draw(t,e){const n=Bl(e/wme),r=n/2,i=n*kP,a=r,o=n*kP+n,l=-a,c=o;t.moveTo(r,i),t.lineTo(a,o),t.lineTo(l,c),t.lineTo(Ro*r-Oo*i,Oo*r+Ro*i),t.lineTo(Ro*a-Oo*o,Oo*a+Ro*o),t.lineTo(Ro*l-Oo*c,Oo*l+Ro*c),t.lineTo(Ro*r+Oo*i,Ro*i-Oo*r),t.lineTo(Ro*a+Oo*o,Ro*o-Oo*a),t.lineTo(Ro*l+Oo*c,Ro*c-Oo*l),t.closePath()}};function Sme(t,e){let n=null,r=BR(i);t=typeof t=="function"?t:Ir(t||$R),e=typeof e=="function"?e:Ir(e===void 0?64:+e);function i(){let a;if(n||(n=a=r()),t.apply(this,arguments).draw(n,+e.apply(this,arguments)),a)return n=null,a+""||null}return i.type=function(a){return arguments.length?(t=typeof a=="function"?a:Ir(a),i):t},i.size=function(a){return arguments.length?(e=typeof a=="function"?a:Ir(+a),i):e},i.context=function(a){return arguments.length?(n=a??null,i):n},i}function Q1(){}function Z1(t,e,n){t._context.bezierCurveTo((2*t._x0+t._x1)/3,(2*t._y0+t._y1)/3,(t._x0+2*t._x1)/3,(t._y0+2*t._y1)/3,(t._x0+4*t._x1+e)/6,(t._y0+4*t._y1+n)/6)}function XW(t){this._context=t}XW.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){switch(this._point){case 3:Z1(this,this._x1,this._y1);case 2:this._context.lineTo(this._x1,this._y1);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2;break;case 2:this._point=3,this._context.lineTo((5*this._x0+this._x1)/6,(5*this._y0+this._y1)/6);default:Z1(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function Mme(t){return new XW(t)}function YW(t){this._context=t}YW.prototype={areaStart:Q1,areaEnd:Q1,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._y0=this._y1=this._y2=this._y3=this._y4=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:{this._context.moveTo(this._x2,this._y2),this._context.closePath();break}case 2:{this._context.moveTo((this._x2+2*this._x3)/3,(this._y2+2*this._y3)/3),this._context.lineTo((this._x3+2*this._x2)/3,(this._y3+2*this._y2)/3),this._context.closePath();break}case 3:{this.point(this._x2,this._y2),this.point(this._x3,this._y3),this.point(this._x4,this._y4);break}}},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._x2=t,this._y2=e;break;case 1:this._point=2,this._x3=t,this._y3=e;break;case 2:this._point=3,this._x4=t,this._y4=e,this._context.moveTo((this._x0+4*this._x1+t)/6,(this._y0+4*this._y1+e)/6);break;default:Z1(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function Nme(t){return new YW(t)}function QW(t){this._context=t}QW.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===3)&&this._context.closePath(),this._line=1-this._line},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3;var n=(this._x0+4*this._x1+t)/6,r=(this._y0+4*this._y1+e)/6;this._line?this._context.lineTo(n,r):this._context.moveTo(n,r);break;case 3:this._point=4;default:Z1(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function kme(t){return new QW(t)}function ZW(t){this._context=t}ZW.prototype={areaStart:Q1,areaEnd:Q1,lineStart:function(){this._point=0},lineEnd:function(){this._point&&this._context.closePath()},point:function(t,e){t=+t,e=+e,this._point?this._context.lineTo(t,e):(this._point=1,this._context.moveTo(t,e))}};function Eme(t){return new ZW(t)}function Hz(t){return t<0?-1:1}function $z(t,e,n){var r=t._x1-t._x0,i=e-t._x1,a=(t._y1-t._y0)/(r||i<0&&-0),o=(n-t._y1)/(i||r<0&&-0),l=(a*i+o*r)/(r+i);return(Hz(a)+Hz(o))*Math.min(Math.abs(a),Math.abs(o),.5*Math.abs(l))||0}function Vz(t,e){var n=t._x1-t._x0;return n?(3*(t._y1-t._y0)/n-e)/2:e}function oT(t,e,n){var r=t._x0,i=t._y0,a=t._x1,o=t._y1,l=(a-r)/3;t._context.bezierCurveTo(r+l,i+l*e,a-l,o-l*n,a,o)}function J1(t){this._context=t}J1.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=this._t0=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x1,this._y1);break;case 3:oT(this,this._t0,Vz(this,this._t0));break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(t,e){var n=NaN;if(t=+t,e=+e,!(t===this._x1&&e===this._y1)){switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2;break;case 2:this._point=3,oT(this,Vz(this,n=$z(this,t,e)),n);break;default:oT(this,this._t0,n=$z(this,t,e));break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e,this._t0=n}}};function JW(t){this._context=new eK(t)}(JW.prototype=Object.create(J1.prototype)).point=function(t,e){J1.prototype.point.call(this,e,t)};function eK(t){this._context=t}eK.prototype={moveTo:function(t,e){this._context.moveTo(e,t)},closePath:function(){this._context.closePath()},lineTo:function(t,e){this._context.lineTo(e,t)},bezierCurveTo:function(t,e,n,r,i,a){this._context.bezierCurveTo(e,t,r,n,a,i)}};function Tme(t){return new J1(t)}function Ame(t){return new JW(t)}function tK(t){this._context=t}tK.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=[],this._y=[]},lineEnd:function(){var t=this._x,e=this._y,n=t.length;if(n)if(this._line?this._context.lineTo(t[0],e[0]):this._context.moveTo(t[0],e[0]),n===2)this._context.lineTo(t[1],e[1]);else for(var r=Gz(t),i=Gz(e),a=0,o=1;o<n;++a,++o)this._context.bezierCurveTo(r[0][a],i[0][a],r[1][a],i[1][a],t[o],e[o]);(this._line||this._line!==0&&n===1)&&this._context.closePath(),this._line=1-this._line,this._x=this._y=null},point:function(t,e){this._x.push(+t),this._y.push(+e)}};function Gz(t){var e,n=t.length-1,r,i=new Array(n),a=new Array(n),o=new Array(n);for(i[0]=0,a[0]=2,o[0]=t[0]+2*t[1],e=1;e<n-1;++e)i[e]=1,a[e]=4,o[e]=4*t[e]+2*t[e+1];for(i[n-1]=2,a[n-1]=7,o[n-1]=8*t[n-1]+t[n],e=1;e<n;++e)r=i[e]/a[e-1],a[e]-=r,o[e]-=r*o[e-1];for(i[n-1]=o[n-1]/a[n-1],e=n-2;e>=0;--e)i[e]=(o[e]-i[e+1])/a[e];for(a[n-1]=(t[n]+i[n-1])/2,e=0;e<n-1;++e)a[e]=2*t[e+1]-i[e+1];return[i,a]}function Cme(t){return new tK(t)}function _N(t,e){this._context=t,this._t=e}_N.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 jme(t){return new _N(t,.5)}function Pme(t){return new _N(t,0)}function Dme(t){return new _N(t,1)}function $g(t,e){if((o=t.length)>1)for(var n=1,r,i,a=t[e[0]],o,l=a.length;n<o;++n)for(i=a,a=t[e[n]],r=0;r<l;++r)a[r][1]+=a[r][0]=isNaN(i[r][1])?i[r][0]:i[r][1]}function EP(t){for(var e=t.length,n=new Array(e);--e>=0;)n[e]=e;return n}function Rme(t,e){return t[e]}function Ome(t){const e=[];return e.key=t,e}function Lme(){var t=Ir([]),e=EP,n=$g,r=Rme;function i(a){var o=Array.from(t.apply(this,arguments),Ome),l,c=o.length,u=-1,d;for(const f of a)for(l=0,++u;l<c;++l)(o[l][u]=[0,+r(f,o[l].key,u,a)]).data=f;for(l=0,d=HR(e(o));l<c;++l)o[d[l]].index=l;return n(o,d),o}return i.keys=function(a){return arguments.length?(t=typeof a=="function"?a:Ir(Array.from(a)),i):t},i.value=function(a){return arguments.length?(r=typeof a=="function"?a:Ir(+a),i):r},i.order=function(a){return arguments.length?(e=a==null?EP:typeof a=="function"?a:Ir(Array.from(a)),i):e},i.offset=function(a){return arguments.length?(n=a??$g,i):n},i}function Fme(t,e){if((r=t.length)>0){for(var n,r,i=0,a=t[0].length,o;i<a;++i){for(o=n=0;n<r;++n)o+=t[n][i][1]||0;if(o)for(n=0;n<r;++n)t[n][i][1]/=o}$g(t,e)}}function Ime(t,e){if((i=t.length)>0){for(var n=0,r=t[e[0]],i,a=r.length;n<a;++n){for(var o=0,l=0;o<i;++o)l+=t[o][n][1]||0;r[n][1]+=r[n][0]=-l/2}$g(t,e)}}function Ume(t,e){if(!(!((o=t.length)>0)||!((a=(i=t[e[0]]).length)>0))){for(var n=0,r=1,i,a,o;r<a;++r){for(var l=0,c=0,u=0;l<o;++l){for(var d=t[e[l]],f=d[r][1]||0,p=d[r-1][1]||0,m=(f-p)/2,x=0;x<l;++x){var b=t[e[x]],y=b[r][1]||0,v=b[r-1][1]||0;m+=y-v}c+=f,u+=m*f}i[r-1][1]+=i[r-1][0]=n,c&&(n-=u/c)}i[r-1][1]+=i[r-1][0]=n,$g(t,e)}}var lT={},cT={},qz;function zme(){return qz||(qz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n==="__proto__"}t.isUnsafeProperty=e})(cT)),cT}var uT={},Wz;function nK(){return Wz||(Wz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){switch(typeof n){case"number":case"symbol":return!1;case"string":return n.includes(".")||n.includes("[")||n.includes("]")}}t.isDeepKey=e})(uT)),uT}var dT={},Kz;function VR(){return Kz||(Kz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return typeof n=="string"||typeof n=="symbol"?n:Object.is(n?.valueOf?.(),-0)?"-0":String(n)}t.toKey=e})(dT)),dT}var hT={},fT={},Xz;function Bme(){return Xz||(Xz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){if(n==null)return"";if(typeof n=="string")return n;if(Array.isArray(n))return n.map(e).join(",");const r=String(n);return r==="0"&&Object.is(Number(n),-0)?"-0":r}t.toString=e})(fT)),fT}var Yz;function GR(){return Yz||(Yz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Bme(),n=VR();function r(i){if(Array.isArray(i))return i.map(n.toKey);if(typeof i=="symbol")return[i];i=e.toString(i);const a=[],o=i.length;if(o===0)return a;let l=0,c="",u="",d=!1;for(i.charCodeAt(0)===46&&(a.push(""),l++);l<o;){const f=i[l];u?f==="\\"&&l+1<o?(l++,c+=i[l]):f===u?u="":c+=f:d?f==='"'||f==="'"?u=f:f==="]"?(d=!1,a.push(c),c=""):c+=f:f==="["?(d=!0,c&&(a.push(c),c="")):f==="."?c&&(a.push(c),c=""):c+=f,l++}return c&&a.push(c),a}t.toPath=r})(hT)),hT}var Qz;function qR(){return Qz||(Qz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=zme(),n=nK(),r=VR(),i=GR();function a(l,c,u){if(l==null)return u;switch(typeof c){case"string":{if(e.isUnsafeProperty(c))return u;const d=l[c];return d===void 0?n.isDeepKey(c)?a(l,i.toPath(c),u):u:d}case"number":case"symbol":{typeof c=="number"&&(c=r.toKey(c));const d=l[c];return d===void 0?u:d}default:{if(Array.isArray(c))return o(l,c,u);if(Object.is(c?.valueOf(),-0)?c="-0":c=String(c),e.isUnsafeProperty(c))return u;const d=l[c];return d===void 0?u:d}}}function o(l,c,u){if(c.length===0)return u;let d=l;for(let f=0;f<c.length;f++){if(d==null||e.isUnsafeProperty(c[f]))return u;d=d[c[f]]}return d===void 0?u:d}t.get=a})(lT)),lT}var mT,Zz;function Hme(){return Zz||(Zz=1,mT=qR().get),mT}var $me=Hme();const cm=hl($me);var ya=t=>t===0?0:t>0?1:-1,$s=t=>typeof t=="number"&&t!=+t,Lu=t=>typeof t=="string"&&t.indexOf("%")===t.length-1,zt=t=>(typeof t=="number"||t instanceof Number)&&!$s(t),cl=t=>zt(t)||typeof t=="string",Vme=0,X0=t=>{var e=++Vme;return"".concat(t||"").concat(e)},es=function(e,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(!zt(e)&&typeof e!="string")return r;var a;if(Lu(e)){if(n==null)return r;var o=e.indexOf("%");a=n*parseFloat(e.slice(0,o))/100}else a=+e;return $s(a)&&(a=r),i&&n!=null&&a>n&&(a=n),a},rK=t=>{if(!Array.isArray(t))return!1;for(var e=t.length,n={},r=0;r<e;r++)if(!n[t[r]])n[t[r]]=!0;else return!0;return!1};function hr(t,e,n){return zt(t)&&zt(e)?t+n*(e-t):e}function iK(t,e,n){if(!(!t||!t.length))return t.find(r=>r&&(typeof e=="function"?e(r):cm(r,e))===n)}var Xr=t=>t===null||typeof t>"u",Iy=t=>Xr(t)?t:"".concat(t.charAt(0).toUpperCase()).concat(t.slice(1));function Gme(t){return t!=null}function Uy(){}var qme=["type","size","sizeType"];function TP(){return TP=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},TP.apply(null,arguments)}function Jz(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function eB(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Jz(Object(n),!0).forEach(function(r){Wme(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Jz(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Wme(t,e,n){return(e=Kme(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Kme(t){var e=Xme(t,"string");return typeof e=="symbol"?e:e+""}function Xme(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Yme(t,e){if(t==null)return{};var n,r,i=Qme(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function Qme(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var aK={symbolCircle:$R,symbolCross:hme,symbolDiamond:mme,symbolSquare:pme,symbolStar:yme,symbolTriangle:vme,symbolWye:_me},Zme=Math.PI/180,Jme=t=>{var e="symbol".concat(Iy(t));return aK[e]||$R},epe=(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*Zme;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}},tpe=(t,e)=>{aK["symbol".concat(Iy(t))]=e},WR=t=>{var{type:e="circle",size:n=64,sizeType:r="area"}=t,i=Yme(t,qme),a=eB(eB({},i),{},{type:e,size:n,sizeType:r}),o="circle";typeof e=="string"&&(o=e);var l=()=>{var p=Jme(o),m=Sme().type(p).size(epe(n,r,o)),x=m();if(x!==null)return x},{className:c,cx:u,cy:d}=a,f=za(a);return zt(u)&&zt(d)&&zt(n)?_.createElement("path",TP({},f,{className:tr("recharts-symbols",c),transform:"translate(".concat(u,", ").concat(d,")"),d:l()})):null};WR.registerSymbol=tpe;var sK=t=>"radius"in t&&"startAngle"in t&&"endAngle"in t,KR=(t,e)=>{if(!t||typeof t=="function"||typeof t=="boolean")return null;var n=t;if(_.isValidElement(t)&&(n=t.props),typeof n!="object"&&typeof n!="function")return null;var r={};return Object.keys(n).forEach(i=>{UR(i)&&(r[i]=(a=>n[i](n,a)))}),r},npe=(t,e,n)=>r=>(t(e,n,r),null),zy=(t,e,n)=>{if(t===null||typeof t!="object"&&typeof t!="function")return null;var r=null;return Object.keys(t).forEach(i=>{var a=t[i];UR(i)&&typeof a=="function"&&(r||(r={}),r[i]=npe(a,e,n))}),r};function tB(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function rpe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?tB(Object(n),!0).forEach(function(r){ipe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):tB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function ipe(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=spe(t,"string");return typeof e=="symbol"?e:e+""}function spe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function li(t,e){var n=rpe({},t),r=e,i=Object.keys(e),a=i.reduce((o,l)=>(o[l]===void 0&&r[l]!==void 0&&(o[l]=r[l]),o),n);return a}function eS(){return eS=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},eS.apply(null,arguments)}function nB(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function ope(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?nB(Object(n),!0).forEach(function(r){lpe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):nB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function lpe(t,e,n){return(e=cpe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function cpe(t){var e=upe(t,"string");return typeof e=="symbol"?e:e+""}function upe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var zo=32,dpe={align:"center",iconSize:14,inactiveColor:"#ccc",layout:"horizontal",verticalAlign:"middle"};function hpe(t){var{data:e,iconType:n,inactiveColor:r}=t,i=zo/2,a=zo/6,o=zo/3,l=e.inactive?r:e.color,c=n??e.type;if(c==="none")return null;if(c==="plainline"){var u;return _.createElement("line",{strokeWidth:4,fill:"none",stroke:l,strokeDasharray:(u=e.payload)===null||u===void 0?void 0:u.strokeDasharray,x1:0,y1:i,x2:zo,y2:i,className:"recharts-legend-icon"})}if(c==="line")return _.createElement("path",{strokeWidth:4,fill:"none",stroke:l,d:"M0,".concat(i,"h").concat(o,`
- A`).concat(a,",").concat(a,",0,1,1,").concat(2*o,",").concat(i,`
- H`).concat(zo,"M").concat(2*o,",").concat(i,`
- A`).concat(a,",").concat(a,",0,1,1,").concat(o,",").concat(i),className:"recharts-legend-icon"});if(c==="rect")return _.createElement("path",{stroke:"none",fill:l,d:"M0,".concat(zo/8,"h").concat(zo,"v").concat(zo*3/4,"h").concat(-zo,"z"),className:"recharts-legend-icon"});if(_.isValidElement(e.legendIcon)){var d=ope({},e);return delete d.legendIcon,_.cloneElement(e.legendIcon,d)}return _.createElement(WR,{fill:l,cx:i,cy:i,size:zo,sizeType:"diameter",type:c})}function fpe(t){var{payload:e,iconSize:n,layout:r,formatter:i,inactiveColor:a,iconType:o}=t,l={x:0,y:0,width:zo,height:zo},c={display:r==="horizontal"?"inline-block":"block",marginRight:10},u={display:"inline-block",verticalAlign:"middle",marginRight:4};return e.map((d,f)=>{var p=d.formatter||i,m=tr({"recharts-legend-item":!0,["legend-item-".concat(f)]:!0,inactive:d.inactive});if(d.type==="none")return null;var x=d.inactive?a:d.color,b=p?p(d.value,d,f):d.value;return _.createElement("li",eS({className:m,style:c,key:"legend-item-".concat(f)},zy(t,d,f)),_.createElement(zR,{width:n,height:n,viewBox:l,style:u,"aria-label":"".concat(b," legend icon")},_.createElement(hpe,{data:d,iconType:o,inactiveColor:a})),_.createElement("span",{className:"recharts-legend-item-text",style:{color:x}},b))})}var mpe=t=>{var e=li(t,dpe),{payload:n,layout:r,align:i}=e;if(!n||!n.length)return null;var a={padding:0,margin:0,textAlign:r==="horizontal"?i:"left"};return _.createElement("ul",{className:"recharts-default-legend",style:a},_.createElement(fpe,eS({},e,{payload:n})))},pT={},gT={},rB;function ppe(){return rB||(rB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r){const i=new Map;for(let a=0;a<n.length;a++){const o=n[a],l=r(o);i.has(l)||i.set(l,o)}return Array.from(i.values())}t.uniqBy=e})(gT)),gT}var xT={},iB;function oK(){return iB||(iB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n}t.identity=e})(xT)),xT}var bT={},yT={},vT={},aB;function gpe(){return aB||(aB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Number.isSafeInteger(n)&&n>=0}t.isLength=e})(vT)),vT}var sB;function XR(){return sB||(sB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=gpe();function n(r){return r!=null&&typeof r!="function"&&e.isLength(r.length)}t.isArrayLike=n})(yT)),yT}var wT={},oB;function xpe(){return oB||(oB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return typeof n=="object"&&n!==null}t.isObjectLike=e})(wT)),wT}var lB;function bpe(){return lB||(lB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=XR(),n=xpe();function r(i){return n.isObjectLike(i)&&e.isArrayLike(i)}t.isArrayLikeObject=r})(bT)),bT}var _T={},ST={},cB;function ype(){return cB||(cB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=qR();function n(r){return function(i){return e.get(i,r)}}t.property=n})(ST)),ST}var MT={},NT={},kT={},ET={},uB;function lK(){return uB||(uB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n!==null&&(typeof n=="object"||typeof n=="function")}t.isObject=e})(ET)),ET}var TT={},dB;function cK(){return dB||(dB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n==null||typeof n!="object"&&typeof n!="function"}t.isPrimitive=e})(TT)),TT}var AT={},hB;function uK(){return hB||(hB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r){return n===r||Number.isNaN(n)&&Number.isNaN(r)}t.eq=e})(AT)),AT}var fB;function vpe(){return fB||(fB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=lK(),n=cK(),r=uK();function i(d,f,p){return typeof p!="function"?i(d,f,()=>{}):a(d,f,function m(x,b,y,v,S,N){const T=p(x,b,y,v,S,N);return T!==void 0?!!T:a(x,b,m,N)},new Map)}function a(d,f,p,m){if(f===d)return!0;switch(typeof f){case"object":return o(d,f,p,m);case"function":return Object.keys(f).length>0?a(d,{...f},p,m):r.eq(d,f);default:return e.isObject(d)?typeof f=="string"?f==="":!0:r.eq(d,f)}}function o(d,f,p,m){if(f==null)return!0;if(Array.isArray(f))return c(d,f,p,m);if(f instanceof Map)return l(d,f,p,m);if(f instanceof Set)return u(d,f,p,m);const x=Object.keys(f);if(d==null)return x.length===0;if(x.length===0)return!0;if(m?.has(f))return m.get(f)===d;m?.set(f,d);try{for(let b=0;b<x.length;b++){const y=x[b];if(!n.isPrimitive(d)&&!(y in d)||f[y]===void 0&&d[y]!==void 0||f[y]===null&&d[y]!==null||!p(d[y],f[y],y,d,f,m))return!1}return!0}finally{m?.delete(f)}}function l(d,f,p,m){if(f.size===0)return!0;if(!(d instanceof Map))return!1;for(const[x,b]of f.entries()){const y=d.get(x);if(p(y,b,x,d,f,m)===!1)return!1}return!0}function c(d,f,p,m){if(f.length===0)return!0;if(!Array.isArray(d))return!1;const x=new Set;for(let b=0;b<f.length;b++){const y=f[b];let v=!1;for(let S=0;S<d.length;S++){if(x.has(S))continue;const N=d[S];let T=!1;if(p(N,y,b,d,f,m)&&(T=!0),T){x.add(S),v=!0;break}}if(!v)return!1}return!0}function u(d,f,p,m){return f.size===0?!0:d instanceof Set?c([...d],[...f],p,m):!1}t.isMatchWith=i,t.isSetMatch=u})(kT)),kT}var mB;function dK(){return mB||(mB=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})(NT)),NT}var CT={},jT={},PT={},pB;function wpe(){return pB||(pB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Object.getOwnPropertySymbols(n).filter(r=>Object.prototype.propertyIsEnumerable.call(n,r))}t.getSymbols=e})(PT)),PT}var DT={},gB;function hK(){return gB||(gB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n==null?n===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(n)}t.getTag=e})(DT)),DT}var RT={},xB;function fK(){return xB||(xB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e="[object RegExp]",n="[object String]",r="[object Number]",i="[object Boolean]",a="[object Arguments]",o="[object Symbol]",l="[object Date]",c="[object Map]",u="[object Set]",d="[object Array]",f="[object Function]",p="[object ArrayBuffer]",m="[object Object]",x="[object Error]",b="[object DataView]",y="[object Uint8Array]",v="[object Uint8ClampedArray]",S="[object Uint16Array]",N="[object Uint32Array]",T="[object BigUint64Array]",k="[object Int8Array]",C="[object Int16Array]",E="[object Int32Array]",D="[object BigInt64Array]",A="[object Float32Array]",R="[object Float64Array]";t.argumentsTag=a,t.arrayBufferTag=p,t.arrayTag=d,t.bigInt64ArrayTag=D,t.bigUint64ArrayTag=T,t.booleanTag=i,t.dataViewTag=b,t.dateTag=l,t.errorTag=x,t.float32ArrayTag=A,t.float64ArrayTag=R,t.functionTag=f,t.int16ArrayTag=C,t.int32ArrayTag=E,t.int8ArrayTag=k,t.mapTag=c,t.numberTag=r,t.objectTag=m,t.regexpTag=e,t.setTag=u,t.stringTag=n,t.symbolTag=o,t.uint16ArrayTag=S,t.uint32ArrayTag=N,t.uint8ArrayTag=y,t.uint8ClampedArrayTag=v})(RT)),RT}var OT={},bB;function _pe(){return bB||(bB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}t.isTypedArray=e})(OT)),OT}var yB;function mK(){return yB||(yB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=wpe(),n=hK(),r=fK(),i=cK(),a=_pe();function o(d,f){return l(d,void 0,d,new Map,f)}function l(d,f,p,m=new Map,x=void 0){const b=x?.(d,f,p,m);if(b!==void 0)return b;if(i.isPrimitive(d))return d;if(m.has(d))return m.get(d);if(Array.isArray(d)){const y=new Array(d.length);m.set(d,y);for(let v=0;v<d.length;v++)y[v]=l(d[v],v,p,m,x);return Object.hasOwn(d,"index")&&(y.index=d.index),Object.hasOwn(d,"input")&&(y.input=d.input),y}if(d instanceof Date)return new Date(d.getTime());if(d instanceof RegExp){const y=new RegExp(d.source,d.flags);return y.lastIndex=d.lastIndex,y}if(d instanceof Map){const y=new Map;m.set(d,y);for(const[v,S]of d)y.set(v,l(S,v,p,m,x));return y}if(d instanceof Set){const y=new Set;m.set(d,y);for(const v of d)y.add(l(v,void 0,p,m,x));return y}if(typeof Buffer<"u"&&Buffer.isBuffer(d))return d.subarray();if(a.isTypedArray(d)){const y=new(Object.getPrototypeOf(d)).constructor(d.length);m.set(d,y);for(let v=0;v<d.length;v++)y[v]=l(d[v],v,p,m,x);return y}if(d instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&d instanceof SharedArrayBuffer)return d.slice(0);if(d instanceof DataView){const y=new DataView(d.buffer.slice(0),d.byteOffset,d.byteLength);return m.set(d,y),c(y,d,p,m,x),y}if(typeof File<"u"&&d instanceof File){const y=new File([d],d.name,{type:d.type});return m.set(d,y),c(y,d,p,m,x),y}if(typeof Blob<"u"&&d instanceof Blob){const y=new Blob([d],{type:d.type});return m.set(d,y),c(y,d,p,m,x),y}if(d instanceof Error){const y=new d.constructor;return m.set(d,y),y.message=d.message,y.name=d.name,y.stack=d.stack,y.cause=d.cause,c(y,d,p,m,x),y}if(d instanceof Boolean){const y=new Boolean(d.valueOf());return m.set(d,y),c(y,d,p,m,x),y}if(d instanceof Number){const y=new Number(d.valueOf());return m.set(d,y),c(y,d,p,m,x),y}if(d instanceof String){const y=new String(d.valueOf());return m.set(d,y),c(y,d,p,m,x),y}if(typeof d=="object"&&u(d)){const y=Object.create(Object.getPrototypeOf(d));return m.set(d,y),c(y,d,p,m,x),y}return d}function c(d,f,p=d,m,x){const b=[...Object.keys(f),...e.getSymbols(f)];for(let y=0;y<b.length;y++){const v=b[y],S=Object.getOwnPropertyDescriptor(d,v);(S==null||S.writable)&&(d[v]=l(f[v],v,p,m,x))}}function u(d){switch(n.getTag(d)){case r.argumentsTag:case r.arrayTag:case r.arrayBufferTag:case r.dataViewTag:case r.booleanTag:case r.dateTag:case r.float32ArrayTag:case r.float64ArrayTag:case r.int8ArrayTag:case r.int16ArrayTag:case r.int32ArrayTag:case r.mapTag:case r.numberTag:case r.objectTag:case r.regexpTag:case r.setTag:case r.stringTag:case r.symbolTag:case r.uint8ArrayTag:case r.uint8ClampedArrayTag:case r.uint16ArrayTag:case r.uint32ArrayTag:return!0;default:return!1}}t.cloneDeepWith=o,t.cloneDeepWithImpl=l,t.copyProperties=c})(jT)),jT}var vB;function Spe(){return vB||(vB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=mK();function n(r){return e.cloneDeepWithImpl(r,void 0,r,new Map,void 0)}t.cloneDeep=n})(CT)),CT}var wB;function Mpe(){return wB||(wB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=dK(),n=Spe();function r(i){return i=n.cloneDeep(i),a=>e.isMatch(a,i)}t.matches=r})(MT)),MT}var LT={},FT={},IT={},_B;function Npe(){return _B||(_B=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=mK(),n=fK();function r(i,a){return e.cloneDeepWith(i,(o,l,c,u)=>{const d=a?.(o,l,c,u);if(d!==void 0)return d;if(typeof i=="object")switch(Object.prototype.toString.call(i)){case n.numberTag:case n.stringTag:case n.booleanTag:{const f=new i.constructor(i?.valueOf());return e.copyProperties(f,i),f}case n.argumentsTag:{const f={};return e.copyProperties(f,i),f.length=i.length,f[Symbol.iterator]=i[Symbol.iterator],f}default:return}})}t.cloneDeepWith=r})(IT)),IT}var SB;function kpe(){return SB||(SB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Npe();function n(r){return e.cloneDeepWith(r)}t.cloneDeep=n})(FT)),FT}var UT={},zT={},MB;function pK(){return MB||(MB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=/^(?:0|[1-9]\d*)$/;function n(r,i=Number.MAX_SAFE_INTEGER){switch(typeof r){case"number":return Number.isInteger(r)&&r>=0&&r<i;case"symbol":return!1;case"string":return e.test(r)}}t.isIndex=n})(zT)),zT}var BT={},NB;function Epe(){return NB||(NB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=hK();function n(r){return r!==null&&typeof r=="object"&&e.getTag(r)==="[object Arguments]"}t.isArguments=n})(BT)),BT}var kB;function Tpe(){return kB||(kB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=nK(),n=pK(),r=Epe(),i=GR();function a(o,l){let c;if(Array.isArray(l)?c=l:typeof l=="string"&&e.isDeepKey(l)&&o?.[l]==null?c=i.toPath(l):c=[l],c.length===0)return!1;let u=o;for(let d=0;d<c.length;d++){const f=c[d];if((u==null||!Object.hasOwn(u,f))&&!((Array.isArray(u)||r.isArguments(u))&&n.isIndex(f)&&f<u.length))return!1;u=u[f]}return!0}t.has=a})(UT)),UT}var EB;function Ape(){return EB||(EB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=dK(),n=VR(),r=kpe(),i=qR(),a=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(u){const d=i.get(u,l);return d===void 0?a.has(u,l):c===void 0?d===void 0:e.isMatch(d,c)}}t.matchesProperty=o})(LT)),LT}var TB;function Cpe(){return TB||(TB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=oK(),n=ype(),r=Mpe(),i=Ape();function a(o){if(o==null)return e.identity;switch(typeof o){case"function":return o;case"object":return Array.isArray(o)&&o.length===2?i.matchesProperty(o[0],o[1]):r.matches(o);case"string":case"symbol":case"number":return n.property(o)}}t.iteratee=a})(_T)),_T}var AB;function jpe(){return AB||(AB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=ppe(),n=oK(),r=bpe(),i=Cpe();function a(o,l=n.identity){return r.isArrayLikeObject(o)?e.uniqBy(Array.from(o),i.iteratee(l)):[]}t.uniqBy=a})(pT)),pT}var HT,CB;function Ppe(){return CB||(CB=1,HT=jpe().uniqBy),HT}var Dpe=Ppe();const jB=hl(Dpe);function gK(t,e,n){return e===!0?jB(t,n):typeof e=="function"?jB(t,e):t}var $T={exports:{}},VT={};var PB;function Rpe(){if(PB)return VT;PB=1;var t=px(),e=kq();function n(u,d){return u===d&&(u!==0||1/u===1/d)||u!==u&&d!==d}var r=typeof Object.is=="function"?Object.is:n,i=e.useSyncExternalStore,a=t.useRef,o=t.useEffect,l=t.useMemo,c=t.useDebugValue;return VT.useSyncExternalStoreWithSelector=function(u,d,f,p,m){var x=a(null);if(x.current===null){var b={hasValue:!1,value:null};x.current=b}else b=x.current;x=l(function(){function v(C){if(!S){if(S=!0,N=C,C=p(C),m!==void 0&&b.hasValue){var E=b.value;if(m(E,C))return T=E}return T=C}if(E=T,r(N,C))return E;var D=p(C);return m!==void 0&&m(E,D)?(N=C,E):(N=C,T=D)}var S=!1,N,T,k=f===void 0?null:f;return[function(){return v(d())},k===null?void 0:function(){return v(k())}]},[d,f,p,m]);var y=i(u,x[0],x[1]);return o(function(){b.hasValue=!0,b.value=y},[y]),c(y),y},VT}var DB;function Ope(){return DB||(DB=1,$T.exports=Rpe()),$T.exports}var xK=Ope(),YR=_.createContext(null),Lpe=t=>t,Lr=()=>{var t=_.useContext(YR);return t?t.store.dispatch:Lpe},x1=()=>{},Fpe=()=>x1,Ipe=(t,e)=>t===e;function It(t){var e=_.useContext(YR);return xK.useSyncExternalStoreWithSelector(e?e.subscription.addNestedSub:Fpe,e?e.store.getState:x1,e?e.store.getState:x1,e?t:x1,Ipe)}function Upe(t,e=`expected a function, instead received ${typeof t}`){if(typeof t!="function")throw new TypeError(e)}function zpe(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 RB=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}},Gpe=typeof WeakRef<"u"?WeakRef:Vpe,qpe=0,OB=1;function Ow(){return{s:qpe,v:void 0,o:null,p:null}}function bK(t,e={}){let n=Ow();const{resultEqualityCheck:r}=e;let i,a=0;function o(){let l=n;const{length:c}=arguments;for(let f=0,p=c;f<p;f++){const m=arguments[f];if(typeof m=="function"||typeof m=="object"&&m!==null){let x=l.o;x===null&&(l.o=x=new WeakMap);const b=x.get(m);b===void 0?(l=Ow(),x.set(m,l)):l=b}else{let x=l.p;x===null&&(l.p=x=new Map);const b=x.get(m);b===void 0?(l=Ow(),x.set(m,l)):l=b}}const u=l;let d;if(l.s===OB)d=l.v;else if(d=t.apply(null,arguments),a++,r){const f=i?.deref?.()??i;f!=null&&r(f,d)&&(d=f,a!==0&&a--),i=typeof d=="object"&&d!==null||typeof d=="function"?new Gpe(d):d}return u.s=OB,u.v=d,d}return o.clearCache=()=>{n=Ow(),o.resetResultsCount()},o.resultsCount=()=>a,o.resetResultsCount=()=>{a=0},o}function Wpe(t,...e){const n=typeof t=="function"?{memoize:t,memoizeOptions:e}:t,r=(...i)=>{let a=0,o=0,l,c={},u=i.pop();typeof u=="object"&&(c=u,u=i.pop()),Upe(u,`createSelector expects an output function after the inputs, but received: [${typeof u}]`);const d={...n,...c},{memoize:f,memoizeOptions:p=[],argsMemoize:m=bK,argsMemoizeOptions:x=[]}=d,b=RB(p),y=RB(x),v=Hpe(i),S=f(function(){return a++,u.apply(null,arguments)},...b),N=m(function(){o++;const k=$pe(v,arguments);return l=S.apply(null,k),l},...y);return Object.assign(N,{resultFunc:u,memoizedResultFunc:S,dependencies:v,dependencyRecomputations:()=>o,resetDependencyRecomputations:()=>{o=0},lastResult:()=>l,recomputations:()=>a,resetRecomputations:()=>{a=0},memoize:f,argsMemoize:m})};return Object.assign(r,{withTypes:()=>r}),r}var nt=Wpe(bK),Kpe=Object.assign((t,e=nt)=>{zpe(t,`createStructuredSelector expects first argument to be an object where each property is a selector, instead received a ${typeof t}`);const n=Object.keys(t),r=n.map(a=>t[a]);return e(r,(...a)=>a.reduce((o,l,c)=>(o[n[c]]=l,o),{}))},{withTypes:()=>Kpe}),GT={},qT={},WT={},LB;function Xpe(){return LB||(LB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(r){return typeof r=="symbol"?1:r===null?2:r===void 0?3:r!==r?4:0}const n=(r,i,a)=>{if(r!==i){const o=e(r),l=e(i);if(o===l&&o===0){if(r<i)return a==="desc"?1:-1;if(r>i)return a==="desc"?-1:1}return a==="desc"?l-o:o-l}return 0};t.compareValues=n})(WT)),WT}var KT={},XT={},FB;function yK(){return FB||(FB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return typeof n=="symbol"||n instanceof Symbol}t.isSymbol=e})(XT)),XT}var IB;function Ype(){return IB||(IB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=yK(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r=/^\w*$/;function i(a,o){return Array.isArray(a)?!1:typeof a=="number"||typeof a=="boolean"||a==null||e.isSymbol(a)?!0:typeof a=="string"&&(r.test(a)||!n.test(a))||o!=null&&Object.hasOwn(o,a)}t.isKey=i})(KT)),KT}var UB;function Qpe(){return UB||(UB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Xpe(),n=Ype(),r=GR();function i(a,o,l,c){if(a==null)return[];l=c?void 0:l,Array.isArray(a)||(a=Object.values(a)),Array.isArray(o)||(o=o==null?[null]:[o]),o.length===0&&(o=[null]),Array.isArray(l)||(l=l==null?[]:[l]),l=l.map(m=>String(m));const u=(m,x)=>{let b=m;for(let y=0;y<x.length&&b!=null;++y)b=b[x[y]];return b},d=(m,x)=>x==null||m==null?x:typeof m=="object"&&"key"in m?Object.hasOwn(x,m.key)?x[m.key]:u(x,m.path):typeof m=="function"?m(x):Array.isArray(m)?u(x,m):typeof x=="object"?x[m]:x,f=o.map(m=>(Array.isArray(m)&&m.length===1&&(m=m[0]),m==null||typeof m=="function"||Array.isArray(m)||n.isKey(m)?m:{key:m,path:r.toPath(m)}));return a.map(m=>({original:m,criteria:f.map(x=>d(x,m))})).slice().sort((m,x)=>{for(let b=0;b<f.length;b++){const y=e.compareValues(m.criteria[b],x.criteria[b],l[b]);if(y!==0)return y}return 0}).map(m=>m.original)}t.orderBy=i})(qT)),qT}var YT={},zB;function Zpe(){return zB||(zB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r=1){const i=[],a=Math.floor(r),o=(l,c)=>{for(let u=0;u<l.length;u++){const d=l[u];Array.isArray(d)&&c<a?o(d,c+1):i.push(d)}};return o(n,0),i}t.flatten=e})(YT)),YT}var QT={},BB;function vK(){return BB||(BB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=pK(),n=XR(),r=lK(),i=uK();function a(o,l,c){return r.isObject(c)&&(typeof l=="number"&&n.isArrayLike(c)&&e.isIndex(l)&&l<c.length||typeof l=="string"&&l in c)?i.eq(c[l],o):!1}t.isIterateeCall=a})(QT)),QT}var HB;function Jpe(){return HB||(HB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Qpe(),n=Zpe(),r=vK();function i(a,...o){const l=o.length;return l>1&&r.isIterateeCall(a,o[0],o[1])?o=[]:l>2&&r.isIterateeCall(o[0],o[1],o[2])&&(o=[o[0]]),e.orderBy(a,n.flatten(o),["asc"])}t.sortBy=i})(GT)),GT}var ZT,$B;function ege(){return $B||($B=1,ZT=Jpe().sortBy),ZT}var tge=ege();const SN=hl(tge);var wK=t=>t.legend.settings,nge=t=>t.legend.size,rge=t=>t.legend.payload,ige=nt([rge,wK],(t,e)=>{var{itemSorter:n}=e,r=t.flat(1);return n?SN(r,n):r});function age(){return It(ige)}var Lw=1;function _K(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],[e,n]=_.useState({height:0,left:0,top:0,width:0}),r=_.useCallback(i=>{if(i!=null){var a=i.getBoundingClientRect(),o={height:a.height,left:a.left,top:a.top,width:a.width};(Math.abs(o.height-e.height)>Lw||Math.abs(o.left-e.left)>Lw||Math.abs(o.top-e.top)>Lw||Math.abs(o.width-e.width)>Lw)&&n({height:o.height,left:o.left,top:o.top,width:o.width})}},[e.width,e.height,e.top,e.left,...t]);return[e,r]}function ja(t){return`Minified Redux error #${t}; visit https://redux.js.org/Errors?code=${t} for the full message or use the non-minified dev environment for full errors. `}var sge=typeof Symbol=="function"&&Symbol.observable||"@@observable",VB=sge,JT=()=>Math.random().toString(36).substring(7).split("").join("."),oge={INIT:`@@redux/INIT${JT()}`,REPLACE:`@@redux/REPLACE${JT()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${JT()}`},tS=oge;function QR(t){if(typeof t!="object"||t===null)return!1;let e=t;for(;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e||Object.getPrototypeOf(t)===null}function SK(t,e,n){if(typeof t!="function")throw new Error(ja(2));if(typeof e=="function"&&typeof n=="function"||typeof n=="function"&&typeof arguments[3]=="function")throw new Error(ja(0));if(typeof e=="function"&&typeof n>"u"&&(n=e,e=void 0),typeof n<"u"){if(typeof n!="function")throw new Error(ja(1));return n(SK)(t,e)}let r=t,i=e,a=new Map,o=a,l=0,c=!1;function u(){o===a&&(o=new Map,a.forEach((y,v)=>{o.set(v,y)}))}function d(){if(c)throw new Error(ja(3));return i}function f(y){if(typeof y!="function")throw new Error(ja(4));if(c)throw new Error(ja(5));let v=!0;u();const S=l++;return o.set(S,y),function(){if(v){if(c)throw new Error(ja(6));v=!1,u(),o.delete(S),a=null}}}function p(y){if(!QR(y))throw new Error(ja(7));if(typeof y.type>"u")throw new Error(ja(8));if(typeof y.type!="string")throw new Error(ja(17));if(c)throw new Error(ja(9));try{c=!0,i=r(i,y)}finally{c=!1}return(a=o).forEach(S=>{S()}),y}function m(y){if(typeof y!="function")throw new Error(ja(10));r=y,p({type:tS.REPLACE})}function x(){const y=f;return{subscribe(v){if(typeof v!="object"||v===null)throw new Error(ja(11));function S(){const T=v;T.next&&T.next(d())}return S(),{unsubscribe:y(S)}},[VB](){return this}}}return p({type:tS.INIT}),{dispatch:p,subscribe:f,getState:d,replaceReducer:m,[VB]:x}}function lge(t){Object.keys(t).forEach(e=>{const n=t[e];if(typeof n(void 0,{type:tS.INIT})>"u")throw new Error(ja(12));if(typeof n(void 0,{type:tS.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(ja(13))})}function MK(t){const e=Object.keys(t),n={};for(let a=0;a<e.length;a++){const o=e[a];typeof t[o]=="function"&&(n[o]=t[o])}const r=Object.keys(n);let i;try{lge(n)}catch(a){i=a}return function(o={},l){if(i)throw i;let c=!1;const u={};for(let d=0;d<r.length;d++){const f=r[d],p=n[f],m=o[f],x=p(m,l);if(typeof x>"u")throw l&&l.type,new Error(ja(14));u[f]=x,c=c||x!==m}return c=c||r.length!==Object.keys(o).length,c?u:o}}function nS(...t){return t.length===0?e=>e:t.length===1?t[0]:t.reduce((e,n)=>(...r)=>e(n(...r)))}function cge(...t){return e=>(n,r)=>{const i=e(n,r);let a=()=>{throw new Error(ja(15))};const o={getState:i.getState,dispatch:(c,...u)=>a(c,...u)},l=t.map(c=>c(o));return a=nS(...l)(i.dispatch),{...i,dispatch:a}}}function NK(t){return QR(t)&&"type"in t&&typeof t.type=="string"}var kK=Symbol.for("immer-nothing"),GB=Symbol.for("immer-draftable"),bs=Symbol.for("immer-state");function El(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var ho=Object,Vg=ho.getPrototypeOf,rS="constructor",MN="prototype",AP="configurable",iS="enumerable",b1="writable",Y0="value",Fu=t=>!!t&&!!t[bs];function Ul(t){return t?EK(t)||NN(t)||!!t[GB]||!!t[rS]?.[GB]||kN(t)||EN(t):!1}var uge=ho[MN][rS].toString(),qB=new WeakMap;function EK(t){if(!t||!ZR(t))return!1;const e=Vg(t);if(e===null||e===ho[MN])return!0;const n=ho.hasOwnProperty.call(e,rS)&&e[rS];if(n===Object)return!0;if(!sg(n))return!1;let r=qB.get(n);return r===void 0&&(r=Function.toString.call(n),qB.set(n,r)),r===uge}function By(t,e,n=!0){Hy(t)===0?(n?Reflect.ownKeys(t):ho.keys(t)).forEach(i=>{e(i,t[i],t)}):t.forEach((r,i)=>e(i,r,t))}function Hy(t){const e=t[bs];return e?e.type_:NN(t)?1:kN(t)?2:EN(t)?3:0}var WB=(t,e,n=Hy(t))=>n===2?t.has(e):ho[MN].hasOwnProperty.call(t,e),CP=(t,e,n=Hy(t))=>n===2?t.get(e):t[e],aS=(t,e,n,r=Hy(t))=>{r===2?t.set(e,n):r===3?t.add(n):t[e]=n};function dge(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}var NN=Array.isArray,kN=t=>t instanceof Map,EN=t=>t instanceof Set,ZR=t=>typeof t=="object",sg=t=>typeof t=="function",eA=t=>typeof t=="boolean",du=t=>t.copy_||t.base_,JR=t=>t.modified_?t.copy_:t.base_;function jP(t,e){if(kN(t))return new Map(t);if(EN(t))return new Set(t);if(NN(t))return Array[MN].slice.call(t);const n=EK(t);if(e===!0||e==="class_only"&&!n){const r=ho.getOwnPropertyDescriptors(t);delete r[bs];let i=Reflect.ownKeys(r);for(let a=0;a<i.length;a++){const o=i[a],l=r[o];l[b1]===!1&&(l[b1]=!0,l[AP]=!0),(l.get||l.set)&&(r[o]={[AP]:!0,[b1]:!0,[iS]:l[iS],[Y0]:t[o]})}return ho.create(Vg(t),r)}else{const r=Vg(t);if(r!==null&&n)return{...t};const i=ho.create(r);return ho.assign(i,t)}}function eO(t,e=!1){return TN(t)||Fu(t)||!Ul(t)||(Hy(t)>1&&ho.defineProperties(t,{set:Fw,add:Fw,clear:Fw,delete:Fw}),ho.freeze(t),e&&By(t,(n,r)=>{eO(r,!0)},!1)),t}function hge(){El(2)}var Fw={[Y0]:hge};function TN(t){return t===null||!ZR(t)?!0:ho.isFrozen(t)}var sS="MapSet",PP="Patches",TK={};function Gg(t){const e=TK[t];return e||El(0,t),e}var fge=t=>!!TK[t],Q0,AK=()=>Q0,mge=(t,e)=>({drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:fge(sS)?Gg(sS):void 0});function KB(t,e){e&&(t.patchPlugin_=Gg(PP),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function DP(t){RP(t),t.drafts_.forEach(pge),t.drafts_=null}function RP(t){t===Q0&&(Q0=t.parent_)}var XB=t=>Q0=mge(Q0,t);function pge(t){const e=t[bs];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function YB(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];if(t!==void 0&&t!==n){n[bs].modified_&&(DP(e),El(4)),Ul(t)&&(t=QB(e,t));const{patchPlugin_:i}=e;i&&i.generateReplacementPatches_(n[bs].base_,t,e)}else t=QB(e,n);return gge(e,t,!0),DP(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==kK?t:void 0}function QB(t,e){if(TN(e))return e;const n=e[bs];if(!n)return tO(e,t.handledSet_,t);if(!AN(n,t))return e;if(!n.modified_)return n.base_;if(!n.finalized_){const{callbacks_:r}=n;if(r)for(;r.length>0;)r.pop()(t);PK(n,t)}return n.copy_}function gge(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&eO(e,n)}function CK(t){t.finalized_=!0,t.scope_.unfinalizedDrafts_--}var AN=(t,e)=>t.scope_===e,xge=[];function jK(t,e,n,r){const i=du(t),a=t.type_;if(r!==void 0&&CP(i,r,a)===e){aS(i,r,n,a);return}if(!t.draftLocations_){const l=t.draftLocations_=new Map;By(i,(c,u)=>{if(Fu(u)){const d=l.get(u)||[];d.push(c),l.set(u,d)}})}const o=t.draftLocations_.get(e)??xge;for(const l of o)aS(i,l,n,a)}function bge(t,e,n){t.callbacks_.push(function(i){const a=e;if(!a||!AN(a,i))return;i.mapSetPlugin_?.fixSetContents(a);const o=JR(a);jK(t,a.draft_??a,o,n),PK(a,i)})}function PK(t,e){if(t.modified_&&!t.finalized_&&(t.type_===3||(t.assigned_?.size??0)>0)){const{patchPlugin_:r}=e;if(r){const i=r.getPath(t);i&&r.generatePatches_(t,i,e)}CK(t)}}function yge(t,e,n){const{scope_:r}=t;if(Fu(n)){const i=n[bs];AN(i,r)&&i.callbacks_.push(function(){y1(t);const o=JR(i);jK(t,n,o,e)})}else Ul(n)&&t.callbacks_.push(function(){const a=du(t);CP(a,e,t.type_)===n&&r.drafts_.length>1&&(t.assigned_.get(e)??!1)===!0&&t.copy_&&tO(CP(t.copy_,e,t.type_),r.handledSet_,r)})}function tO(t,e,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||Fu(t)||e.has(t)||!Ul(t)||TN(t)||(e.add(t),By(t,(r,i)=>{if(Fu(i)){const a=i[bs];if(AN(a,n)){const o=JR(a);aS(t,r,o,t.type_),CK(a)}}else Ul(i)&&tO(i,e,n)})),t}function vge(t,e){const n=NN(t),r={type_:n?1:0,scope_:e?e.scope_:AK(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:e,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0};let i=r,a=nO;n&&(i=[r],a=Z0);const{revoke:o,proxy:l}=Proxy.revocable(i,a);return r.draft_=l,r.revoke_=o,[l,r]}var nO={get(t,e){if(e===bs)return t;const n=du(t);if(!WB(n,e,t.type_))return wge(t,n,e);const r=n[e];if(t.finalized_||!Ul(r))return r;if(r===tA(t.base_,e)){y1(t);const i=t.type_===1?+e:e,a=LP(t.scope_,r,t,i);return t.copy_[i]=a}return r},has(t,e){return e in du(t)},ownKeys(t){return Reflect.ownKeys(du(t))},set(t,e,n){const r=DK(du(t),e);if(r?.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const i=tA(du(t),e),a=i?.[bs];if(a&&a.base_===n)return t.copy_[e]=n,t.assigned_.set(e,!1),!0;if(dge(n,i)&&(n!==void 0||WB(t.base_,e,t.type_)))return!0;y1(t),OP(t)}return t.copy_[e]===n&&(n!==void 0||e in t.copy_)||Number.isNaN(n)&&Number.isNaN(t.copy_[e])||(t.copy_[e]=n,t.assigned_.set(e,!0),yge(t,e,n)),!0},deleteProperty(t,e){return y1(t),tA(t.base_,e)!==void 0||e in t.base_?(t.assigned_.set(e,!1),OP(t)):t.assigned_.delete(e),t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const n=du(t),r=Reflect.getOwnPropertyDescriptor(n,e);return r&&{[b1]:!0,[AP]:t.type_!==1||e!=="length",[iS]:r[iS],[Y0]:n[e]}},defineProperty(){El(11)},getPrototypeOf(t){return Vg(t.base_)},setPrototypeOf(){El(12)}},Z0={};By(nO,(t,e)=>{Z0[t]=function(){const n=arguments;return n[0]=n[0][0],e.apply(this,n)}});Z0.deleteProperty=function(t,e){return Z0.set.call(this,t,e,void 0)};Z0.set=function(t,e,n){return nO.set.call(this,t[0],e,n,t[0])};function tA(t,e){const n=t[bs];return(n?du(n):t)[e]}function wge(t,e,n){const r=DK(e,n);return r?Y0 in r?r[Y0]:r.get?.call(t.draft_):void 0}function DK(t,e){if(!(e in t))return;let n=Vg(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,e);if(r)return r;n=Vg(n)}}function OP(t){t.modified_||(t.modified_=!0,t.parent_&&OP(t.parent_))}function y1(t){t.copy_||(t.assigned_=new Map,t.copy_=jP(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var _ge=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(n,r,i)=>{if(sg(n)&&!sg(r)){const o=r;r=n;const l=this;return function(u=o,...d){return l.produce(u,f=>r.call(this,f,...d))}}sg(r)||El(6),i!==void 0&&!sg(i)&&El(7);let a;if(Ul(n)){const o=XB(this),l=LP(o,n,void 0);let c=!0;try{a=r(l),c=!1}finally{c?DP(o):RP(o)}return KB(o,i),YB(a,o)}else if(!n||!ZR(n)){if(a=r(n),a===void 0&&(a=n),a===kK&&(a=void 0),this.autoFreeze_&&eO(a,!0),i){const o=[],l=[];Gg(PP).generateReplacementPatches_(n,a,{patches_:o,inversePatches_:l}),i(o,l)}return a}else El(1,n)},this.produceWithPatches=(n,r)=>{if(sg(n))return(l,...c)=>this.produceWithPatches(l,u=>n(u,...c));let i,a;return[this.produce(n,r,(l,c)=>{i=l,a=c}),i,a]},eA(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),eA(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),eA(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){Ul(e)||El(8),Fu(e)&&(e=Ol(e));const n=XB(this),r=LP(n,e,void 0);return r[bs].isManual_=!0,RP(n),r}finishDraft(e,n){const r=e&&e[bs];(!r||!r.isManual_)&&El(9);const{scope_:i}=r;return KB(i,n),YB(void 0,i)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,n){let r;for(r=n.length-1;r>=0;r--){const a=n[r];if(a.path.length===0&&a.op==="replace"){e=a.value;break}}r>-1&&(n=n.slice(r+1));const i=Gg(PP).applyPatches_;return Fu(e)?i(e,n):this.produce(e,a=>i(a,n))}};function LP(t,e,n,r){const[i,a]=kN(e)?Gg(sS).proxyMap_(e,n):EN(e)?Gg(sS).proxySet_(e,n):vge(e,n);return(n?.scope_??AK()).drafts_.push(i),a.callbacks_=n?.callbacks_??[],a.key_=r,n&&r!==void 0?bge(n,a,r):a.callbacks_.push(function(c){c.mapSetPlugin_?.fixSetContents(a);const{patchPlugin_:u}=c;a.modified_&&u&&u.generatePatches_(a,[],c)}),i}function Ol(t){return Fu(t)||El(10,t),RK(t)}function RK(t){if(!Ul(t)||TN(t))return t;const e=t[bs];let n,r=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=jP(t,e.scope_.immer_.useStrictShallowCopy_),r=e.scope_.immer_.shouldUseStrictIteration()}else n=jP(t,!0);return By(n,(i,a)=>{aS(n,i,RK(a))},r),e&&(e.finalized_=!1),n}var Sge=new _ge,OK=Sge.produce;function LK(t){return({dispatch:n,getState:r})=>i=>a=>typeof a=="function"?a(n,r,t):i(a)}var Mge=LK(),Nge=LK,kge=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?nS:nS.apply(null,arguments)};function ul(t,e){function n(...r){if(e){let i=e(...r);if(!i)throw new Error(mo(0));return{type:t,payload:i.payload,..."meta"in i&&{meta:i.meta},..."error"in i&&{error:i.error}}}return{type:t,payload:r[0]}}return n.toString=()=>`${t}`,n.type=t,n.match=r=>NK(r)&&r.type===t,n}var FK=class i0 extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,i0.prototype)}static get[Symbol.species](){return i0}concat(...e){return super.concat.apply(this,e)}prepend(...e){return e.length===1&&Array.isArray(e[0])?new i0(...e[0].concat(this)):new i0(...e.concat(this))}};function ZB(t){return Ul(t)?OK(t,()=>{}):t}function Iw(t,e,n){return t.has(e)?t.get(e):t.set(e,n(e)).get(e)}function Ege(t){return typeof t=="boolean"}var Tge=()=>function(e){const{thunk:n=!0,immutableCheck:r=!0,serializableCheck:i=!0,actionCreatorCheck:a=!0}=e??{};let o=new FK;return n&&(Ege(n)?o.push(Mge):o.push(Nge(n.extraArgument))),o},IK="RTK_autoBatch",Zr=()=>t=>({payload:t,meta:{[IK]:!0}}),JB=t=>e=>{setTimeout(e,t)},UK=(t={type:"raf"})=>e=>(...n)=>{const r=e(...n);let i=!0,a=!1,o=!1;const l=new Set,c=t.type==="tick"?queueMicrotask:t.type==="raf"?typeof window<"u"&&window.requestAnimationFrame?window.requestAnimationFrame:JB(10):t.type==="callback"?t.queueNotification:JB(t.timeout),u=()=>{o=!1,a&&(a=!1,l.forEach(d=>d()))};return Object.assign({},r,{subscribe(d){const f=()=>i&&d(),p=r.subscribe(f);return l.add(d),()=>{p(),l.delete(d)}},dispatch(d){try{return i=!d?.meta?.[IK],a=!i,a&&(o||(o=!0,c(u))),r.dispatch(d)}finally{i=!0}}})},Age=t=>function(n){const{autoBatch:r=!0}=n??{};let i=new FK(t);return r&&i.push(UK(typeof r=="object"?r:void 0)),i};function Cge(t){const e=Tge(),{reducer:n=void 0,middleware:r,devTools:i=!0,preloadedState:a=void 0,enhancers:o=void 0}=t||{};let l;if(typeof n=="function")l=n;else if(QR(n))l=MK(n);else throw new Error(mo(1));let c;typeof r=="function"?c=r(e):c=e();let u=nS;i&&(u=kge({trace:!1,...typeof i=="object"&&i}));const d=cge(...c),f=Age(d);let p=typeof o=="function"?o(f):f();const m=u(...p);return SK(l,a,m)}function zK(t){const e={},n=[];let r;const i={addCase(a,o){const l=typeof a=="string"?a:a.type;if(!l)throw new Error(mo(28));if(l in e)throw new Error(mo(29));return e[l]=o,i},addAsyncThunk(a,o){return o.pending&&(e[a.pending.type]=o.pending),o.rejected&&(e[a.rejected.type]=o.rejected),o.fulfilled&&(e[a.fulfilled.type]=o.fulfilled),o.settled&&n.push({matcher:a.settled,reducer:o.settled}),i},addMatcher(a,o){return n.push({matcher:a,reducer:o}),i},addDefaultCase(a){return r=a,i}};return t(i),[e,n,r]}function jge(t){return typeof t=="function"}function Pge(t,e){let[n,r,i]=zK(e),a;if(jge(t))a=()=>ZB(t());else{const l=ZB(t);a=()=>l}function o(l=a(),c){let u=[n[c.type],...r.filter(({matcher:d})=>d(c)).map(({reducer:d})=>d)];return u.filter(d=>!!d).length===0&&(u=[i]),u.reduce((d,f)=>{if(f)if(Fu(d)){const m=f(d,c);return m===void 0?d:m}else{if(Ul(d))return OK(d,p=>f(p,c));{const p=f(d,c);if(p===void 0){if(d===null)return d;throw Error("A case reducer on a non-draftable value must not return undefined")}return p}}return d},l)}return o.getInitialState=a,o}var Dge="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",Rge=(t=21)=>{let e="",n=t;for(;n--;)e+=Dge[Math.random()*64|0];return e},Oge=Symbol.for("rtk-slice-createasyncthunk");function Lge(t,e){return`${t}/${e}`}function Fge({creators:t}={}){const e=t?.asyncThunk?.[Oge];return function(r){const{name:i,reducerPath:a=i}=r;if(!i)throw new Error(mo(11));const o=(typeof r.reducers=="function"?r.reducers(Uge()):r.reducers)||{},l=Object.keys(o),c={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},u={addCase(N,T){const k=typeof N=="string"?N:N.type;if(!k)throw new Error(mo(12));if(k in c.sliceCaseReducersByType)throw new Error(mo(13));return c.sliceCaseReducersByType[k]=T,u},addMatcher(N,T){return c.sliceMatchers.push({matcher:N,reducer:T}),u},exposeAction(N,T){return c.actionCreators[N]=T,u},exposeCaseReducer(N,T){return c.sliceCaseReducersByName[N]=T,u}};l.forEach(N=>{const T=o[N],k={reducerName:N,type:Lge(i,N),createNotation:typeof r.reducers=="function"};Bge(T)?$ge(k,T,u,e):zge(k,T,u)});function d(){const[N={},T=[],k=void 0]=typeof r.extraReducers=="function"?zK(r.extraReducers):[r.extraReducers],C={...N,...c.sliceCaseReducersByType};return Pge(r.initialState,E=>{for(let D in C)E.addCase(D,C[D]);for(let D of c.sliceMatchers)E.addMatcher(D.matcher,D.reducer);for(let D of T)E.addMatcher(D.matcher,D.reducer);k&&E.addDefaultCase(k)})}const f=N=>N,p=new Map,m=new WeakMap;let x;function b(N,T){return x||(x=d()),x(N,T)}function y(){return x||(x=d()),x.getInitialState()}function v(N,T=!1){function k(E){let D=E[N];return typeof D>"u"&&T&&(D=Iw(m,k,y)),D}function C(E=f){const D=Iw(p,T,()=>new WeakMap);return Iw(D,E,()=>{const A={};for(const[R,U]of Object.entries(r.selectors??{}))A[R]=Ige(U,E,()=>Iw(m,E,y),T);return A})}return{reducerPath:N,getSelectors:C,get selectors(){return C(k)},selectSlice:k}}const S={name:i,reducer:b,actions:c.actionCreators,caseReducers:c.sliceCaseReducersByName,getInitialState:y,...v(a),injectInto(N,{reducerPath:T,...k}={}){const C=T??a;return N.inject({reducerPath:C,reducer:b},k),{...S,...v(C,!0)}}};return S}}function Ige(t,e,n,r){function i(a,...o){let l=e(a);return typeof l>"u"&&r&&(l=n()),t(l,...o)}return i.unwrapped=t,i}var Vs=Fge();function Uge(){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 zge({type:t,reducerName:e,createNotation:n},r,i){let a,o;if("reducer"in r){if(n&&!Hge(r))throw new Error(mo(17));a=r.reducer,o=r.prepare}else a=r;i.addCase(t,a).exposeCaseReducer(e,a).exposeAction(e,o?ul(t,o):ul(t))}function Bge(t){return t._reducerDefinitionType==="asyncThunk"}function Hge(t){return t._reducerDefinitionType==="reducerWithPrepare"}function $ge({type:t,reducerName:e},n,r,i){if(!i)throw new Error(mo(18));const{payloadCreator:a,fulfilled:o,pending:l,rejected:c,settled:u,options:d}=n,f=i(t,a,d);r.exposeAction(e,f),o&&r.addCase(f.fulfilled,o),l&&r.addCase(f.pending,l),c&&r.addCase(f.rejected,c),u&&r.addMatcher(f.settled,u),r.exposeCaseReducer(e,{fulfilled:o||Uw,pending:l||Uw,rejected:c||Uw,settled:u||Uw})}function Uw(){}var Vge="task",BK="listener",HK="completed",rO="cancelled",Gge=`task-${rO}`,qge=`task-${HK}`,FP=`${BK}-${rO}`,Wge=`${BK}-${HK}`,CN=class{constructor(t){this.code=t,this.message=`${Vge} ${rO} (reason: ${t})`}name="TaskAbortError";message},iO=(t,e)=>{if(typeof t!="function")throw new TypeError(mo(32))},oS=()=>{},$K=(t,e=oS)=>(t.catch(e),t),VK=(t,e)=>(t.addEventListener("abort",e,{once:!0}),()=>t.removeEventListener("abort",e)),Bf=(t,e)=>{const n=t.signal;n.aborted||("reason"in n||Object.defineProperty(n,"reason",{enumerable:!0,value:e,configurable:!0,writable:!0}),t.abort(e))},Hf=t=>{if(t.aborted){const{reason:e}=t;throw new CN(e)}};function GK(t,e){let n=oS;return new Promise((r,i)=>{const a=()=>i(new CN(t.reason));if(t.aborted){a();return}n=VK(t,a),e.finally(()=>n()).then(r,i)}).finally(()=>{n=oS})}var Kge=async(t,e)=>{try{return await Promise.resolve(),{status:"ok",value:await t()}}catch(n){return{status:n instanceof CN?"cancelled":"rejected",error:n}}finally{e?.()}},lS=t=>e=>$K(GK(t,e).then(n=>(Hf(t),n))),qK=t=>{const e=lS(t);return n=>e(new Promise(r=>setTimeout(r,n)))},{assign:Ng}=Object,e8={},jN="listenerMiddleware",Xge=(t,e)=>{const n=r=>VK(t,()=>Bf(r,t.reason));return(r,i)=>{iO(r);const a=new AbortController;n(a);const o=Kge(async()=>{Hf(t),Hf(a.signal);const l=await r({pause:lS(a.signal),delay:qK(a.signal),signal:a.signal});return Hf(a.signal),l},()=>Bf(a,qge));return i?.autoJoin&&e.push(o.catch(oS)),{result:lS(t)(o),cancel(){Bf(a,Gge)}}}},Yge=(t,e)=>{const n=async(r,i)=>{Hf(e);let a=()=>{};const l=[new Promise((c,u)=>{let d=t({predicate:r,effect:(f,p)=>{p.unsubscribe(),c([f,p.getState(),p.getOriginalState()])}});a=()=>{d(),u()}})];i!=null&&l.push(new Promise(c=>setTimeout(c,i,null)));try{const c=await GK(e,Promise.race(l));return Hf(e),c}finally{a()}};return(r,i)=>$K(n(r,i))},WK=t=>{let{type:e,actionCreator:n,matcher:r,predicate:i,effect:a}=t;if(e)i=ul(e).match;else if(n)e=n.type,i=n.match;else if(r)i=r;else if(!i)throw new Error(mo(21));return iO(a),{predicate:i,type:e,effect:a}},KK=Ng(t=>{const{type:e,predicate:n,effect:r}=WK(t);return{id:Rge(),effect:r,type:e,predicate:n,pending:new Set,unsubscribe:()=>{throw new Error(mo(22))}}},{withTypes:()=>KK}),t8=(t,e)=>{const{type:n,effect:r,predicate:i}=WK(e);return Array.from(t.values()).find(a=>(typeof n=="string"?a.type===n:a.predicate===i)&&a.effect===r)},IP=t=>{t.pending.forEach(e=>{Bf(e,FP)})},Qge=(t,e)=>()=>{for(const n of e.keys())IP(n);t.clear()},n8=(t,e,n)=>{try{t(e,n)}catch(r){setTimeout(()=>{throw r},0)}},XK=Ng(ul(`${jN}/add`),{withTypes:()=>XK}),Zge=ul(`${jN}/removeAll`),YK=Ng(ul(`${jN}/remove`),{withTypes:()=>YK}),Jge=(...t)=>{console.error(`${jN}/error`,...t)},$y=(t={})=>{const e=new Map,n=new Map,r=m=>{const x=n.get(m)??0;n.set(m,x+1)},i=m=>{const x=n.get(m)??1;x===1?n.delete(m):n.set(m,x-1)},{extra:a,onError:o=Jge}=t;iO(o);const l=m=>(m.unsubscribe=()=>e.delete(m.id),e.set(m.id,m),x=>{m.unsubscribe(),x?.cancelActive&&IP(m)}),c=m=>{const x=t8(e,m)??KK(m);return l(x)};Ng(c,{withTypes:()=>c});const u=m=>{const x=t8(e,m);return x&&(x.unsubscribe(),m.cancelActive&&IP(x)),!!x};Ng(u,{withTypes:()=>u});const d=async(m,x,b,y)=>{const v=new AbortController,S=Yge(c,v.signal),N=[];try{m.pending.add(v),r(m),await Promise.resolve(m.effect(x,Ng({},b,{getOriginalState:y,condition:(T,k)=>S(T,k).then(Boolean),take:S,delay:qK(v.signal),pause:lS(v.signal),extra:a,signal:v.signal,fork:Xge(v.signal,N),unsubscribe:m.unsubscribe,subscribe:()=>{e.set(m.id,m)},cancelActiveListeners:()=>{m.pending.forEach((T,k,C)=>{T!==v&&(Bf(T,FP),C.delete(T))})},cancel:()=>{Bf(v,FP),m.pending.delete(v)},throwIfCancelled:()=>{Hf(v.signal)}})))}catch(T){T instanceof CN||n8(o,T,{raisedBy:"effect"})}finally{await Promise.all(N),Bf(v,Wge),i(m),m.pending.delete(v)}},f=Qge(e,n);return{middleware:m=>x=>b=>{if(!NK(b))return x(b);if(XK.match(b))return c(b.payload);if(Zge.match(b)){f();return}if(YK.match(b))return u(b.payload);let y=m.getState();const v=()=>{if(y===e8)throw new Error(mo(23));return y};let S;try{if(S=x(b),e.size>0){const N=m.getState(),T=Array.from(e.values());for(const k of T){let C=!1;try{C=k.predicate(b,N,y)}catch(E){C=!1,n8(o,E,{raisedBy:"predicate"})}C&&d(k,b,m,v)}}}finally{y=e8}return S},startListening:c,stopListening:u,clearListeners:f}};function mo(t){return`Minified Redux Toolkit error #${t}; visit https://redux-toolkit.js.org/Errors?code=${t} for the full message or use the non-minified dev environment for full errors. `}var exe={layoutType:"horizontal",width:0,height:0,margin:{top:5,right:5,bottom:5,left:5},scale:1},QK=Vs({name:"chartLayout",initialState:exe,reducers:{setLayout(t,e){t.layoutType=e.payload},setChartSize(t,e){t.width=e.payload.width,t.height=e.payload.height},setMargin(t,e){var n,r,i,a;t.margin.top=(n=e.payload.top)!==null&&n!==void 0?n:0,t.margin.right=(r=e.payload.right)!==null&&r!==void 0?r:0,t.margin.bottom=(i=e.payload.bottom)!==null&&i!==void 0?i:0,t.margin.left=(a=e.payload.left)!==null&&a!==void 0?a:0},setScale(t,e){t.scale=e.payload}}}),{setMargin:txe,setLayout:nxe,setChartSize:rxe,setScale:ixe}=QK.actions,axe=QK.reducer;function ZK(t,e,n){return Array.isArray(t)&&t&&e+n!==0?t.slice(e,n+1):t}function r8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function pg(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?r8(Object(n),!0).forEach(function(r){sxe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):r8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function sxe(t,e,n){return(e=oxe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function oxe(t){var e=lxe(t,"string");return typeof e=="symbol"?e:e+""}function lxe(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 yr(t,e,n){return Xr(t)||Xr(e)?n:cl(e)?cm(t,e,n):typeof e=="function"?e(t):n}var cxe=(t,e,n)=>{if(e&&n){var{width:r,height:i}=n,{align:a,verticalAlign:o,layout:l}=e;if((l==="vertical"||l==="horizontal"&&o==="middle")&&a!=="center"&&zt(t[a]))return pg(pg({},t),{},{[a]:t[a]+(r||0)});if((l==="horizontal"||l==="vertical"&&a==="center")&&o!=="middle"&&zt(t[o]))return pg(pg({},t),{},{[o]:t[o]+(i||0)})}return t},kc=(t,e)=>t==="horizontal"&&e==="xAxis"||t==="vertical"&&e==="yAxis"||t==="centric"&&e==="angleAxis"||t==="radial"&&e==="radiusAxis",JK=(t,e,n,r)=>{if(r)return t.map(l=>l.coordinate);var i,a,o=t.map(l=>(l.coordinate===e&&(i=!0),l.coordinate===n&&(a=!0),l.coordinate));return i||o.push(e),a||o.push(n),o},eX=(t,e,n)=>{if(!t)return null;var{duplicateDomain:r,type:i,range:a,scale:o,realScaleType:l,isCategorical:c,categoricalDomain:u,tickCount:d,ticks:f,niceTicks:p,axisType:m}=t;if(!o)return null;var x=l==="scaleBand"&&o.bandwidth?o.bandwidth()/2:2,b=i==="category"&&o.bandwidth?o.bandwidth()/x:0;if(b=m==="angleAxis"&&a&&a.length>=2?ya(a[0]-a[1])*2*b:b,f||p){var y=(f||p||[]).map((v,S)=>{var N=r?r.indexOf(v):v;return{coordinate:o(N)+b,value:v,offset:b,index:S}});return y.filter(v=>!$s(v.coordinate))}return c&&u?u.map((v,S)=>({coordinate:o(v)+b,value:v,index:S,offset:b})):o.ticks&&d!=null?o.ticks(d).map((v,S)=>({coordinate:o(v)+b,value:v,offset:b,index:S})):o.domain().map((v,S)=>({coordinate:o(v)+b,value:r?r[v]:v,index:S,offset:b}))},i8=1e-4,uxe=t=>{var e=t.domain();if(!(!e||e.length<=2)){var n=e.length,r=t.range(),i=Math.min(r[0],r[1])-i8,a=Math.max(r[0],r[1])+i8,o=t(e[0]),l=t(e[n-1]);(o<i||o>a||l<i||l>a)&&t.domain([e[0],e[n-1]])}},dxe=(t,e)=>{if(!e||e.length!==2||!zt(e[0])||!zt(e[1]))return t;var n=Math.min(e[0],e[1]),r=Math.max(e[0],e[1]),i=[t[0],t[1]];return(!zt(t[0])||t[0]<n)&&(i[0]=n),(!zt(t[1])||t[1]>r)&&(i[1]=r),i[0]>r&&(i[0]=r),i[1]<n&&(i[1]=n),i},hxe=t=>{var e=t.length;if(!(e<=0))for(var n=0,r=t[0].length;n<r;++n)for(var i=0,a=0,o=0;o<e;++o){var l=$s(t[o][n][1])?t[o][n][0]:t[o][n][1];l>=0?(t[o][n][0]=i,t[o][n][1]=i+l,i=t[o][n][1]):(t[o][n][0]=a,t[o][n][1]=a+l,a=t[o][n][1])}},fxe=t=>{var e=t.length;if(!(e<=0))for(var n=0,r=t[0].length;n<r;++n)for(var i=0,a=0;a<e;++a){var o=$s(t[a][n][1])?t[a][n][0]:t[a][n][1];o>=0?(t[a][n][0]=i,t[a][n][1]=i+o,i=t[a][n][1]):(t[a][n][0]=0,t[a][n][1]=0)}},mxe={sign:hxe,expand:Fme,none:$g,silhouette:Ime,wiggle:Ume,positive:fxe},pxe=(t,e,n)=>{var r=mxe[n],i=Lme().keys(e).value((a,o)=>Number(yr(a,o,0))).order(EP).offset(r);return i(t)};function tX(t){return t==null?void 0:String(t)}function cS(t){var{axis:e,ticks:n,bandSize:r,entry:i,index:a,dataKey:o}=t;if(e.type==="category"){if(!e.allowDuplicatedCategory&&e.dataKey&&!Xr(i[e.dataKey])){var l=iK(n,"value",i[e.dataKey]);if(l)return l.coordinate+r/2}return n[a]?n[a].coordinate+r/2:null}var c=yr(i,Xr(o)?e.dataKey:o);return Xr(c)?null:e.scale(c)}var a8=t=>{var{axis:e,ticks:n,offset:r,bandSize:i,entry:a,index:o}=t;if(e.type==="category")return n[o]?n[o].coordinate+r:null;var l=yr(a,e.dataKey,e.scale.domain()[o]);return Xr(l)?null:e.scale(l)-i/2+r},gxe=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]},xxe=t=>{var e=t.flat(2).filter(zt);return[Math.min(...e),Math.max(...e)]},bxe=t=>[t[0]===1/0?0:t[0],t[1]===-1/0?0:t[1]],yxe=(t,e,n)=>{if(t!=null)return bxe(Object.keys(t).reduce((r,i)=>{var a=t[i],{stackedData:o}=a,l=o.reduce((c,u)=>{var d=ZK(u,e,n),f=xxe(d);return[Math.min(c[0],f[0]),Math.max(c[1],f[1])]},[1/0,-1/0]);return[Math.min(l[0],r[0]),Math.max(l[1],r[1])]},[1/0,-1/0]))},s8=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,o8=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,wh=(t,e,n)=>{if(t&&t.scale&&t.scale.bandwidth){var r=t.scale.bandwidth();if(!n||r>0)return r}if(t&&e&&e.length>=2){for(var i=SN(e,d=>d.coordinate),a=1/0,o=1,l=i.length;o<l;o++){var c=i[o],u=i[o-1];a=Math.min((c.coordinate||0)-(u.coordinate||0),a)}return a===1/0?0:a}return n?void 0:0};function l8(t){var{tooltipEntrySettings:e,dataKey:n,payload:r,value:i,name:a}=t;return pg(pg({},e),{},{dataKey:n,payload:r,value:i,name:a})}function Lh(t,e){if(t)return String(t);if(typeof e=="string")return e}var vxe=(t,e)=>{if(e==="horizontal")return t.chartX;if(e==="vertical")return t.chartY},wxe=(t,e)=>e==="centric"?t.angle:t.radius,qu=t=>t.layout.width,Wu=t=>t.layout.height,_xe=t=>t.layout.scale,nX=t=>t.layout.margin,PN=nt(t=>t.cartesianAxis.xAxis,t=>Object.values(t)),DN=nt(t=>t.cartesianAxis.yAxis,t=>Object.values(t)),rX="data-recharts-item-index",iX="data-recharts-item-data-key",Vy=60;function c8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function zw(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?c8(Object(n),!0).forEach(function(r){Sxe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):c8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Sxe(t,e,n){return(e=Mxe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Mxe(t){var e=Nxe(t,"string");return typeof e=="symbol"?e:e+""}function Nxe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var kxe=t=>t.brush.height;function Exe(t){var e=DN(t);return e.reduce((n,r)=>{if(r.orientation==="left"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:Vy;return n+i}return n},0)}function Txe(t){var e=DN(t);return e.reduce((n,r)=>{if(r.orientation==="right"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:Vy;return n+i}return n},0)}function Axe(t){var e=PN(t);return e.reduce((n,r)=>r.orientation==="top"&&!r.mirror&&!r.hide?n+r.height:n,0)}function Cxe(t){var e=PN(t);return e.reduce((n,r)=>r.orientation==="bottom"&&!r.mirror&&!r.hide?n+r.height:n,0)}var na=nt([qu,Wu,nX,kxe,Exe,Txe,Axe,Cxe,wK,nge],(t,e,n,r,i,a,o,l,c,u)=>{var d={left:(n.left||0)+i,right:(n.right||0)+a},f={top:(n.top||0)+o,bottom:(n.bottom||0)+l},p=zw(zw({},f),d),m=p.bottom;p.bottom+=r,p=cxe(p,c,u);var x=t-p.left-p.right,b=e-p.top-p.bottom;return zw(zw({brushBottom:m},p),{},{width:Math.max(x,0),height:Math.max(b,0)})}),jxe=nt(na,t=>({x:t.left,y:t.top,width:t.width,height:t.height})),aO=nt(qu,Wu,(t,e)=>({x:0,y:0,width:t,height:e})),Pxe=_.createContext(null),ra=()=>_.useContext(Pxe)!=null,RN=t=>t.brush,ON=nt([RN,na,nX],(t,e,n)=>({height:t.height,x:zt(t.x)?t.x:e.left,y:zt(t.y)?t.y:e.top+e.height+e.brushBottom-(n?.bottom||0),width:zt(t.width)?t.width:e.width})),nA={},rA={},iA={},u8;function Dxe(){return u8||(u8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r,{signal:i,edges:a}={}){let o,l=null;const c=a!=null&&a.includes("leading"),u=a==null||a.includes("trailing"),d=()=>{l!==null&&(n.apply(o,l),o=void 0,l=null)},f=()=>{u&&d(),b()};let p=null;const m=()=>{p!=null&&clearTimeout(p),p=setTimeout(()=>{p=null,f()},r)},x=()=>{p!==null&&(clearTimeout(p),p=null)},b=()=>{x(),o=void 0,l=null},y=()=>{d()},v=function(...S){if(i?.aborted)return;o=this,l=S;const N=p==null;m(),c&&N&&d()};return v.schedule=m,v.cancel=b,v.flush=y,i?.addEventListener("abort",b,{once:!0}),v}t.debounce=e})(iA)),iA}var d8;function Rxe(){return d8||(d8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Dxe();function n(r,i=0,a={}){typeof a!="object"&&(a={});const{leading:o=!1,trailing:l=!0,maxWait:c}=a,u=Array(2);o&&(u[0]="leading"),l&&(u[1]="trailing");let d,f=null;const p=e.debounce(function(...b){d=r.apply(this,b),f=null},i,{edges:u}),m=function(...b){return c!=null&&(f===null&&(f=Date.now()),Date.now()-f>=c)?(d=r.apply(this,b),f=Date.now(),p.cancel(),p.schedule(),d):(p.apply(this,b),d)},x=()=>(p.flush(),d);return m.cancel=p.cancel,m.flush=x,m}t.debounce=n})(rA)),rA}var h8;function Oxe(){return h8||(h8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Rxe();function n(r,i=0,a={}){const{leading:o=!0,trailing:l=!0}=a;return e.debounce(r,i,{leading:o,maxWait:i,trailing:l})}t.throttle=n})(nA)),nA}var aA,f8;function Lxe(){return f8||(f8=1,aA=Oxe().throttle),aA}var Fxe=Lxe();const Ixe=hl(Fxe);var uS=function(e,n){for(var r=arguments.length,i=new Array(r>2?r-2:0),a=2;a<r;a++)i[a-2]=arguments[a];if(typeof console<"u"&&console.warn&&(n===void 0&&console.warn("LogUtils requires an error message argument"),!e))if(n===void 0)console.warn("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var o=0;console.warn(n.replace(/%s/g,()=>i[o++]))}},aX=(t,e,n)=>{var{width:r="100%",height:i="100%",aspect:a,maxHeight:o}=n,l=Lu(r)?t:Number(r),c=Lu(i)?e:Number(i);return a&&a>0&&(l?c=l/a:c&&(l=c*a),o&&c!=null&&c>o&&(c=o)),{calculatedWidth:l,calculatedHeight:c}},Uxe={width:0,height:0,overflow:"visible"},zxe={width:0,overflowX:"visible"},Bxe={height:0,overflowY:"visible"},Hxe={},$xe=t=>{var{width:e,height:n}=t,r=Lu(e),i=Lu(n);return r&&i?Uxe:r?zxe:i?Bxe:Hxe};function Vxe(t){var{width:e,height:n,aspect:r}=t,i=e,a=n;return i===void 0&&a===void 0?(i="100%",a="100%"):i===void 0?i=r&&r>0?void 0:"100%":a===void 0&&(a=r&&r>0?void 0:"100%"),{width:i,height:a}}function vr(t){return Number.isFinite(t)}function pc(t){return typeof t=="number"&&t>0&&Number.isFinite(t)}function UP(){return UP=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},UP.apply(null,arguments)}function m8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function p8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?m8(Object(n),!0).forEach(function(r){Gxe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):m8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Gxe(t,e,n){return(e=qxe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function qxe(t){var e=Wxe(t,"string");return typeof e=="symbol"?e:e+""}function Wxe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var sX=_.createContext({width:-1,height:-1});function Kxe(t){return pc(t.width)&&pc(t.height)}function oX(t){var{children:e,width:n,height:r}=t,i=_.useMemo(()=>({width:n,height:r}),[n,r]);return Kxe(i)?_.createElement(sX.Provider,{value:i},e):null}var sO=()=>_.useContext(sX),Xxe=_.forwardRef((t,e)=>{var{aspect:n,initialDimension:r={width:-1,height:-1},width:i,height:a,minWidth:o=0,minHeight:l,maxHeight:c,children:u,debounce:d=0,id:f,className:p,onResize:m,style:x={}}=t,b=_.useRef(null),y=_.useRef();y.current=m,_.useImperativeHandle(e,()=>b.current);var[v,S]=_.useState({containerWidth:r.width,containerHeight:r.height}),N=_.useCallback((D,A)=>{S(R=>{var U=Math.round(D),F=Math.round(A);return R.containerWidth===U&&R.containerHeight===F?R:{containerWidth:U,containerHeight:F}})},[]);_.useEffect(()=>{if(b.current==null||typeof ResizeObserver>"u")return Uy;var D=F=>{var $,{width:j,height:H}=F[0].contentRect;N(j,H),($=y.current)===null||$===void 0||$.call(y,j,H)};d>0&&(D=Ixe(D,d,{trailing:!0,leading:!1}));var A=new ResizeObserver(D),{width:R,height:U}=b.current.getBoundingClientRect();return N(R,U),A.observe(b.current),()=>{A.disconnect()}},[N,d]);var{containerWidth:T,containerHeight:k}=v;uS(!n||n>0,"The aspect(%s) must be greater than zero.",n);var{calculatedWidth:C,calculatedHeight:E}=aX(T,k,{width:i,height:a,aspect:n,maxHeight:c});return uS(C!=null&&C>0||E!=null&&E>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.`,C,E,i,a,o,l,n),_.createElement("div",{id:f?"".concat(f):void 0,className:tr("recharts-responsive-container",p),style:p8(p8({},x),{},{width:i,height:a,minWidth:o,minHeight:l,maxHeight:c}),ref:b},_.createElement("div",{style:$xe({width:i,height:a})},_.createElement(oX,{width:C,height:E},u)))}),v1=_.forwardRef((t,e)=>{var n=sO();if(pc(n.width)&&pc(n.height))return t.children;var{width:r,height:i}=Vxe({width:t.width,height:t.height,aspect:t.aspect}),{calculatedWidth:a,calculatedHeight:o}=aX(void 0,void 0,{width:r,height:i,aspect:t.aspect,maxHeight:t.maxHeight});return zt(a)&&zt(o)?_.createElement(oX,{width:a,height:o},t.children):_.createElement(Xxe,UP({},t,{width:r,height:i,ref:e}))});function lX(t){if(t)return{x:t.x,y:t.y,upperWidth:"upperWidth"in t?t.upperWidth:t.width,lowerWidth:"lowerWidth"in t?t.lowerWidth:t.width,width:t.width,height:t.height}}var Gy=()=>{var t,e=ra(),n=It(jxe),r=It(ON),i=(t=It(RN))===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}},Yxe={top:0,bottom:0,left:0,right:0,width:0,height:0,brushBottom:0},cX=()=>{var t;return(t=It(na))!==null&&t!==void 0?t:Yxe},oO=()=>It(qu),lO=()=>It(Wu),Qxe=()=>It(t=>t.layout.margin),Vn=t=>t.layout.layoutType,Em=()=>It(Vn),Zxe=()=>{var t=Em();if(t==="horizontal"||t==="vertical")return t},Jxe=()=>{var t=Em();return t!==void 0},LN=t=>{var e=Lr(),n=ra(),{width:r,height:i}=t,a=sO(),o=r,l=i;return a&&(o=a.width>0?a.width:r,l=a.height>0?a.height:i),_.useEffect(()=>{!n&&pc(o)&&pc(l)&&e(rxe({width:o,height:l}))},[e,n,o,l]),null},uX=Symbol.for("immer-nothing"),g8=Symbol.for("immer-draftable"),yo=Symbol.for("immer-state");function Tl(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var J0=Object.getPrototypeOf;function qg(t){return!!t&&!!t[yo]}function um(t){return t?dX(t)||Array.isArray(t)||!!t[g8]||!!t.constructor?.[g8]||qy(t)||IN(t):!1}var ebe=Object.prototype.constructor.toString(),x8=new WeakMap;function dX(t){if(!t||typeof t!="object")return!1;const e=Object.getPrototypeOf(t);if(e===null||e===Object.prototype)return!0;const n=Object.hasOwnProperty.call(e,"constructor")&&e.constructor;if(n===Object)return!0;if(typeof n!="function")return!1;let r=x8.get(n);return r===void 0&&(r=Function.toString.call(n),x8.set(n,r)),r===ebe}function dS(t,e,n=!0){FN(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 FN(t){const e=t[yo];return e?e.type_:Array.isArray(t)?1:qy(t)?2:IN(t)?3:0}function zP(t,e){return FN(t)===2?t.has(e):Object.prototype.hasOwnProperty.call(t,e)}function hX(t,e,n){const r=FN(t);r===2?t.set(e,n):r===3?t.add(n):t[e]=n}function tbe(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}function qy(t){return t instanceof Map}function IN(t){return t instanceof Set}function wf(t){return t.copy_||t.base_}function BP(t,e){if(qy(t))return new Map(t);if(IN(t))return new Set(t);if(Array.isArray(t))return Array.prototype.slice.call(t);const n=dX(t);if(e===!0||e==="class_only"&&!n){const r=Object.getOwnPropertyDescriptors(t);delete r[yo];let i=Reflect.ownKeys(r);for(let a=0;a<i.length;a++){const o=i[a],l=r[o];l.writable===!1&&(l.writable=!0,l.configurable=!0),(l.get||l.set)&&(r[o]={configurable:!0,writable:!0,enumerable:l.enumerable,value:t[o]})}return Object.create(J0(t),r)}else{const r=J0(t);if(r!==null&&n)return{...t};const i=Object.create(r);return Object.assign(i,t)}}function cO(t,e=!1){return UN(t)||qg(t)||!um(t)||(FN(t)>1&&Object.defineProperties(t,{set:Bw,add:Bw,clear:Bw,delete:Bw}),Object.freeze(t),e&&Object.values(t).forEach(n=>cO(n,!0))),t}function nbe(){Tl(2)}var Bw={value:nbe};function UN(t){return t===null||typeof t!="object"?!0:Object.isFrozen(t)}var rbe={};function dm(t){const e=rbe[t];return e||Tl(0,t),e}var ey;function fX(){return ey}function ibe(t,e){return{drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function b8(t,e){e&&(dm("Patches"),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function HP(t){$P(t),t.drafts_.forEach(abe),t.drafts_=null}function $P(t){t===ey&&(ey=t.parent_)}function y8(t){return ey=ibe(ey,t)}function abe(t){const e=t[yo];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function v8(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];return t!==void 0&&t!==n?(n[yo].modified_&&(HP(e),Tl(4)),um(t)&&(t=hS(e,t),e.parent_||fS(e,t)),e.patches_&&dm("Patches").generateReplacementPatches_(n[yo].base_,t,e.patches_,e.inversePatches_)):t=hS(e,n,[]),HP(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==uX?t:void 0}function hS(t,e,n){if(UN(e))return e;const r=t.immer_.shouldUseStrictIteration(),i=e[yo];if(!i)return dS(e,(a,o)=>w8(t,i,e,a,o,n),r),e;if(i.scope_!==t)return e;if(!i.modified_)return fS(t,i.base_,!0),i.base_;if(!i.finalized_){i.finalized_=!0,i.scope_.unfinalizedDrafts_--;const a=i.copy_;let o=a,l=!1;i.type_===3&&(o=new Set(a),a.clear(),l=!0),dS(o,(c,u)=>w8(t,i,a,c,u,n,l),r),fS(t,a,!1),n&&t.patches_&&dm("Patches").generatePatches_(i,n,t.patches_,t.inversePatches_)}return i.copy_}function w8(t,e,n,r,i,a,o){if(i==null||typeof i!="object"&&!o)return;const l=UN(i);if(!(l&&!o)){if(qg(i)){const c=a&&e&&e.type_!==3&&!zP(e.assigned_,r)?a.concat(r):void 0,u=hS(t,i,c);if(hX(n,r,u),qg(u))t.canAutoFreeze_=!1;else return}else o&&n.add(i);if(um(i)&&!l){if(!t.immer_.autoFreeze_&&t.unfinalizedDrafts_<1||e&&e.base_&&e.base_[r]===i&&l)return;hS(t,i),(!e||!e.scope_.parent_)&&typeof r!="symbol"&&(qy(n)?n.has(r):Object.prototype.propertyIsEnumerable.call(n,r))&&fS(t,i)}}}function fS(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&cO(e,n)}function sbe(t,e){const n=Array.isArray(t),r={type_:n?1:0,scope_:e?e.scope_:fX(),modified_:!1,finalized_:!1,assigned_:{},parent_:e,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=r,a=uO;n&&(i=[r],a=ty);const{revoke:o,proxy:l}=Proxy.revocable(i,a);return r.draft_=l,r.revoke_=o,l}var uO={get(t,e){if(e===yo)return t;const n=wf(t);if(!zP(n,e))return obe(t,n,e);const r=n[e];return t.finalized_||!um(r)?r:r===sA(t.base_,e)?(oA(t),t.copy_[e]=GP(r,t)):r},has(t,e){return e in wf(t)},ownKeys(t){return Reflect.ownKeys(wf(t))},set(t,e,n){const r=mX(wf(t),e);if(r?.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const i=sA(wf(t),e),a=i?.[yo];if(a&&a.base_===n)return t.copy_[e]=n,t.assigned_[e]=!1,!0;if(tbe(n,i)&&(n!==void 0||zP(t.base_,e)))return!0;oA(t),VP(t)}return t.copy_[e]===n&&(n!==void 0||e in t.copy_)||Number.isNaN(n)&&Number.isNaN(t.copy_[e])||(t.copy_[e]=n,t.assigned_[e]=!0),!0},deleteProperty(t,e){return sA(t.base_,e)!==void 0||e in t.base_?(t.assigned_[e]=!1,oA(t),VP(t)):delete t.assigned_[e],t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const n=wf(t),r=Reflect.getOwnPropertyDescriptor(n,e);return r&&{writable:!0,configurable:t.type_!==1||e!=="length",enumerable:r.enumerable,value:n[e]}},defineProperty(){Tl(11)},getPrototypeOf(t){return J0(t.base_)},setPrototypeOf(){Tl(12)}},ty={};dS(uO,(t,e)=>{ty[t]=function(){return arguments[0]=arguments[0][0],e.apply(this,arguments)}});ty.deleteProperty=function(t,e){return ty.set.call(this,t,e,void 0)};ty.set=function(t,e,n){return uO.set.call(this,t[0],e,n,t[0])};function sA(t,e){const n=t[yo];return(n?wf(n):t)[e]}function obe(t,e,n){const r=mX(e,n);return r?"value"in r?r.value:r.get?.call(t.draft_):void 0}function mX(t,e){if(!(e in t))return;let n=J0(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,e);if(r)return r;n=J0(n)}}function VP(t){t.modified_||(t.modified_=!0,t.parent_&&VP(t.parent_))}function oA(t){t.copy_||(t.copy_=BP(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var lbe=class{constructor(t){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!0,this.produce=(e,n,r)=>{if(typeof e=="function"&&typeof n!="function"){const a=n;n=e;const o=this;return function(c=a,...u){return o.produce(c,d=>n.call(this,d,...u))}}typeof n!="function"&&Tl(6),r!==void 0&&typeof r!="function"&&Tl(7);let i;if(um(e)){const a=y8(this),o=GP(e,void 0);let l=!0;try{i=n(o),l=!1}finally{l?HP(a):$P(a)}return b8(a,r),v8(i,a)}else if(!e||typeof e!="object"){if(i=n(e),i===void 0&&(i=e),i===uX&&(i=void 0),this.autoFreeze_&&cO(i,!0),r){const a=[],o=[];dm("Patches").generateReplacementPatches_(e,i,a,o),r(a,o)}return i}else Tl(1,e)},this.produceWithPatches=(e,n)=>{if(typeof e=="function")return(o,...l)=>this.produceWithPatches(o,c=>e(c,...l));let r,i;return[this.produce(e,n,(o,l)=>{r=o,i=l}),r,i]},typeof t?.autoFreeze=="boolean"&&this.setAutoFreeze(t.autoFreeze),typeof t?.useStrictShallowCopy=="boolean"&&this.setUseStrictShallowCopy(t.useStrictShallowCopy),typeof t?.useStrictIteration=="boolean"&&this.setUseStrictIteration(t.useStrictIteration)}createDraft(t){um(t)||Tl(8),qg(t)&&(t=cbe(t));const e=y8(this),n=GP(t,void 0);return n[yo].isManual_=!0,$P(e),n}finishDraft(t,e){const n=t&&t[yo];(!n||!n.isManual_)&&Tl(9);const{scope_:r}=n;return b8(r,e),v8(void 0,r)}setAutoFreeze(t){this.autoFreeze_=t}setUseStrictShallowCopy(t){this.useStrictShallowCopy_=t}setUseStrictIteration(t){this.useStrictIteration_=t}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(t,e){let n;for(n=e.length-1;n>=0;n--){const i=e[n];if(i.path.length===0&&i.op==="replace"){t=i.value;break}}n>-1&&(e=e.slice(n+1));const r=dm("Patches").applyPatches_;return qg(t)?r(t,e):this.produce(t,i=>r(i,e))}};function GP(t,e){const n=qy(t)?dm("MapSet").proxyMap_(t,e):IN(t)?dm("MapSet").proxySet_(t,e):sbe(t,e);return(e?e.scope_:fX()).drafts_.push(n),n}function cbe(t){return qg(t)||Tl(10,t),pX(t)}function pX(t){if(!um(t)||UN(t))return t;const e=t[yo];let n,r=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=BP(t,e.scope_.immer_.useStrictShallowCopy_),r=e.scope_.immer_.shouldUseStrictIteration()}else n=BP(t,!0);return dS(n,(i,a)=>{hX(n,i,pX(a))},r),e&&(e.finalized_=!1),n}var ube=new lbe;ube.produce;var dbe={settings:{layout:"horizontal",align:"center",verticalAlign:"middle",itemSorter:"value"},size:{width:0,height:0},payload:[]},gX=Vs({name:"legend",initialState:dbe,reducers:{setLegendSize(t,e){t.size.width=e.payload.width,t.size.height=e.payload.height},setLegendSettings(t,e){t.settings.align=e.payload.align,t.settings.layout=e.payload.layout,t.settings.verticalAlign=e.payload.verticalAlign,t.settings.itemSorter=e.payload.itemSorter},addLegendPayload:{reducer(t,e){t.payload.push(e.payload)},prepare:Zr()},replaceLegendPayload:{reducer(t,e){var{prev:n,next:r}=e.payload,i=Ol(t).payload.indexOf(n);i>-1&&(t.payload[i]=r)},prepare:Zr()},removeLegendPayload:{reducer(t,e){var n=Ol(t).payload.indexOf(e.payload);n>-1&&t.payload.splice(n,1)},prepare:Zr()}}}),{setLegendSize:_8,setLegendSettings:hbe,addLegendPayload:xX,replaceLegendPayload:bX,removeLegendPayload:yX}=gX.actions,fbe=gX.reducer,mbe=["contextPayload"];function qP(){return qP=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},qP.apply(null,arguments)}function S8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Wg(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?S8(Object(n),!0).forEach(function(r){pbe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):S8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function pbe(t,e,n){return(e=gbe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function gbe(t){var e=xbe(t,"string");return typeof e=="symbol"?e:e+""}function xbe(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 bbe(t,e){if(t==null)return{};var n,r,i=ybe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function ybe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function vbe(t){return t.value}function wbe(t){var{contextPayload:e}=t,n=bbe(t,mbe),r=gK(e,t.payloadUniqBy,vbe),i=Wg(Wg({},n),{},{payload:r});return _.isValidElement(t.content)?_.cloneElement(t.content,i):typeof t.content=="function"?_.createElement(t.content,i):_.createElement(mpe,i)}function _be(t,e,n,r,i,a){var{layout:o,align:l,verticalAlign:c}=e,u,d;return(!t||(t.left===void 0||t.left===null)&&(t.right===void 0||t.right===null))&&(l==="center"&&o==="vertical"?u={left:((r||0)-a.width)/2}:u=l==="right"?{right:n&&n.right||0}:{left:n&&n.left||0}),(!t||(t.top===void 0||t.top===null)&&(t.bottom===void 0||t.bottom===null))&&(c==="middle"?d={top:((i||0)-a.height)/2}:d=c==="bottom"?{bottom:n&&n.bottom||0}:{top:n&&n.top||0}),Wg(Wg({},u),d)}function Sbe(t){var e=Lr();return _.useEffect(()=>{e(hbe(t))},[e,t]),null}function Mbe(t){var e=Lr();return _.useEffect(()=>(e(_8(t)),()=>{e(_8({width:0,height:0}))}),[e,t]),null}function Nbe(t,e,n,r){return t==="vertical"&&zt(e)?{height:e}:t==="horizontal"?{width:n||r}:null}var kbe={align:"center",iconSize:14,itemSorter:"value",layout:"horizontal",verticalAlign:"bottom"};function dO(t){var e=li(t,kbe),n=age(),r=sme(),i=Qxe(),{width:a,height:o,wrapperStyle:l,portal:c}=e,[u,d]=_K([n]),f=oO(),p=lO();if(f==null||p==null)return null;var m=f-(i?.left||0)-(i?.right||0),x=Nbe(e.layout,o,a,m),b=c?l:Wg(Wg({position:"absolute",width:x?.width||a||"auto",height:x?.height||o||"auto"},_be(l,e,i,f,p,u)),l),y=c??r;if(y==null||n==null)return null;var v=_.createElement("div",{className:"recharts-legend-wrapper",style:b,ref:d},_.createElement(Sbe,{layout:e.layout,align:e.align,verticalAlign:e.verticalAlign,itemSorter:e.itemSorter}),!c&&_.createElement(Mbe,{width:u.width,height:u.height}),_.createElement(wbe,qP({},e,x,{margin:i,chartWidth:f,chartHeight:p,contextPayload:n})));return gu.createPortal(v,y)}dO.displayName="Legend";function WP(){return WP=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},WP.apply(null,arguments)}function M8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function lA(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?M8(Object(n),!0).forEach(function(r){Ebe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):M8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Ebe(t,e,n){return(e=Tbe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Tbe(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 Cbe(t){return Array.isArray(t)&&cl(t[0])&&cl(t[1])?t.join(" ~ "):t}var jbe=t=>{var{separator:e=" : ",contentStyle:n={},itemStyle:r={},labelStyle:i={},payload:a,formatter:o,itemSorter:l,wrapperClassName:c,labelClassName:u,label:d,labelFormatter:f,accessibilityLayer:p=!1}=t,m=()=>{if(a&&a.length){var k={padding:0,margin:0},C=(l?SN(a,l):a).map((E,D)=>{if(E.type==="none")return null;var A=E.formatter||o||Cbe,{value:R,name:U}=E,F=R,$=U;if(A){var j=A(R,U,E,D,a);if(Array.isArray(j))[F,$]=j;else if(j!=null)F=j;else return null}var H=lA({display:"block",paddingTop:4,paddingBottom:4,color:E.color||"#000"},r);return _.createElement("li",{className:"recharts-tooltip-item",key:"tooltip-item-".concat(D),style:H},cl($)?_.createElement("span",{className:"recharts-tooltip-item-name"},$):null,cl($)?_.createElement("span",{className:"recharts-tooltip-item-separator"},e):null,_.createElement("span",{className:"recharts-tooltip-item-value"},F),_.createElement("span",{className:"recharts-tooltip-item-unit"},E.unit||""))});return _.createElement("ul",{className:"recharts-tooltip-item-list",style:k},C)}return null},x=lA({margin:0,padding:10,backgroundColor:"#fff",border:"1px solid #ccc",whiteSpace:"nowrap"},n),b=lA({margin:0},i),y=!Xr(d),v=y?d:"",S=tr("recharts-default-tooltip",c),N=tr("recharts-tooltip-label",u);y&&f&&a!==void 0&&a!==null&&(v=f(d,a));var T=p?{role:"status","aria-live":"assertive"}:{};return _.createElement("div",WP({className:S,style:x},T),_.createElement("p",{className:N,style:b},_.isValidElement(v)?v:"".concat(v)),m())},jb="recharts-tooltip-wrapper",Pbe={visibility:"hidden"};function Dbe(t){var{coordinate:e,translateX:n,translateY:r}=t;return tr(jb,{["".concat(jb,"-right")]:zt(n)&&e&&zt(e.x)&&n>=e.x,["".concat(jb,"-left")]:zt(n)&&e&&zt(e.x)&&n<e.x,["".concat(jb,"-bottom")]:zt(r)&&e&&zt(e.y)&&r>=e.y,["".concat(jb,"-top")]:zt(r)&&e&&zt(e.y)&&r<e.y})}function N8(t){var{allowEscapeViewBox:e,coordinate:n,key:r,offsetTopLeft:i,position:a,reverseDirection:o,tooltipDimension:l,viewBox:c,viewBoxDimension:u}=t;if(a&&zt(a[r]))return a[r];var d=n[r]-l-(i>0?i:0),f=n[r]+i;if(e[r])return o[r]?d:f;var p=c[r];if(p==null)return 0;if(o[r]){var m=d,x=p;return m<x?Math.max(f,p):Math.max(d,p)}if(u==null)return 0;var b=f+l,y=p+u;return b>y?Math.max(d,p):Math.max(f,p)}function Rbe(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 Obe(t){var{allowEscapeViewBox:e,coordinate:n,offsetTopLeft:r,position:i,reverseDirection:a,tooltipBox:o,useTranslate3d:l,viewBox:c}=t,u,d,f;return o.height>0&&o.width>0&&n?(d=N8({allowEscapeViewBox:e,coordinate:n,key:"x",offsetTopLeft:r,position:i,reverseDirection:a,tooltipDimension:o.width,viewBox:c,viewBoxDimension:c.width}),f=N8({allowEscapeViewBox:e,coordinate:n,key:"y",offsetTopLeft:r,position:i,reverseDirection:a,tooltipDimension:o.height,viewBox:c,viewBoxDimension:c.height}),u=Rbe({translateX:d,translateY:f,useTranslate3d:l})):u=Pbe,{cssProperties:u,cssClasses:Dbe({translateX:d,translateY:f,coordinate:n})}}function k8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Hw(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?k8(Object(n),!0).forEach(function(r){KP(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):k8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function KP(t,e,n){return(e=Lbe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Lbe(t){var e=Fbe(t,"string");return typeof e=="symbol"?e:e+""}function Fbe(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 Ibe extends _.PureComponent{constructor(){super(...arguments),KP(this,"state",{dismissed:!1,dismissedAtCoordinate:{x:0,y:0}}),KP(this,"handleKeyDown",e=>{if(e.key==="Escape"){var n,r,i,a;this.setState({dismissed:!0,dismissedAtCoordinate:{x:(n=(r=this.props.coordinate)===null||r===void 0?void 0:r.x)!==null&&n!==void 0?n:0,y:(i=(a=this.props.coordinate)===null||a===void 0?void 0:a.y)!==null&&i!==void 0?i:0}})}})}componentDidMount(){document.addEventListener("keydown",this.handleKeyDown)}componentWillUnmount(){document.removeEventListener("keydown",this.handleKeyDown)}componentDidUpdate(){var e,n;this.state.dismissed&&(((e=this.props.coordinate)===null||e===void 0?void 0:e.x)!==this.state.dismissedAtCoordinate.x||((n=this.props.coordinate)===null||n===void 0?void 0:n.y)!==this.state.dismissedAtCoordinate.y)&&(this.state.dismissed=!1)}render(){var{active:e,allowEscapeViewBox:n,animationDuration:r,animationEasing:i,children:a,coordinate:o,hasPayload:l,isAnimationActive:c,offset:u,position:d,reverseDirection:f,useTranslate3d:p,viewBox:m,wrapperStyle:x,lastBoundingBox:b,innerRef:y,hasPortalFromProps:v}=this.props,{cssClasses:S,cssProperties:N}=Obe({allowEscapeViewBox:n,coordinate:o,offsetTopLeft:u,position:d,reverseDirection:f,tooltipBox:{height:b.height,width:b.width},useTranslate3d:p,viewBox:m}),T=v?{}:Hw(Hw({transition:c&&e?"transform ".concat(r,"ms ").concat(i):void 0},N),{},{pointerEvents:"none",visibility:!this.state.dismissed&&e&&l?"visible":"hidden",position:"absolute",top:0,left:0}),k=Hw(Hw({},T),{},{visibility:!this.state.dismissed&&e&&l?"visible":"hidden"},x);return _.createElement("div",{xmlns:"http://www.w3.org/1999/xhtml",tabIndex:-1,className:S,style:k,ref:y},a)}}var vX=()=>{var t;return(t=It(e=>e.rootProps.accessibilityLayer))!==null&&t!==void 0?t:!0};function XP(){return XP=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},XP.apply(null,arguments)}function E8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function T8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?E8(Object(n),!0).forEach(function(r){Ube(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):E8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Ube(t,e,n){return(e=zbe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function zbe(t){var e=Bbe(t,"string");return typeof e=="symbol"?e:e+""}function Bbe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var A8={curveBasisClosed:Nme,curveBasisOpen:kme,curveBasis:Mme,curveBumpX:ume,curveBumpY:dme,curveLinearClosed:Eme,curveLinear:wN,curveMonotoneX:Tme,curveMonotoneY:Ame,curveNatural:Cme,curveStep:jme,curveStepAfter:Dme,curveStepBefore:Pme},mS=t=>vr(t.x)&&vr(t.y),C8=t=>t.base!=null&&mS(t.base)&&mS(t),Pb=t=>t.x,Db=t=>t.y,Hbe=(t,e)=>{if(typeof t=="function")return t;var n="curve".concat(Iy(t));return(n==="curveMonotone"||n==="curveBump")&&e?A8["".concat(n).concat(e==="vertical"?"Y":"X")]:A8[n]||wN},$be=t=>{var{type:e="linear",points:n=[],baseLine:r,layout:i,connectNulls:a=!1}=t,o=Hbe(e,i),l=a?n.filter(mS):n,c;if(Array.isArray(r)){var u=n.map((m,x)=>T8(T8({},m),{},{base:r[x]}));i==="vertical"?c=Rw().y(Db).x1(Pb).x0(m=>m.base.x):c=Rw().x(Pb).y1(Db).y0(m=>m.base.y);var d=c.defined(C8).curve(o),f=a?u.filter(C8):u;return d(f)}i==="vertical"&&zt(r)?c=Rw().y(Db).x1(Pb).x0(r):zt(r)?c=Rw().x(Pb).y1(Db).y0(r):c=GW().x(Pb).y(Db);var p=c.defined(mS).curve(o);return p(l)},kg=t=>{var{className:e,points:n,path:r,pathRef:i}=t;if((!n||!n.length)&&!r)return null;var a=n&&n.length?$be(t):r;return _.createElement("path",XP({},xs(t),KR(t),{className:tr("recharts-curve",e),d:a===null?void 0:a,ref:i}))},Vbe=["x","y","top","left","width","height","className"];function YP(){return YP=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},YP.apply(null,arguments)}function j8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Gbe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?j8(Object(n),!0).forEach(function(r){qbe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):j8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function qbe(t,e,n){return(e=Wbe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Wbe(t){var e=Kbe(t,"string");return typeof e=="symbol"?e:e+""}function Kbe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Xbe(t,e){if(t==null)return{};var n,r,i=Ybe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function Ybe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var Qbe=(t,e,n,r,i,a)=>"M".concat(t,",").concat(i,"v").concat(r,"M").concat(a,",").concat(e,"h").concat(n),Zbe=t=>{var{x:e=0,y:n=0,top:r=0,left:i=0,width:a=0,height:o=0,className:l}=t,c=Xbe(t,Vbe),u=Gbe({x:e,y:n,top:r,left:i,width:a,height:o},c);return!zt(e)||!zt(n)||!zt(a)||!zt(o)||!zt(r)||!zt(i)?null:_.createElement("path",YP({},za(u),{className:tr("recharts-cross",l),d:Qbe(e,n,a,o,r,i)}))};function Jbe(t,e,n,r){var i=r/2;return{stroke:"none",fill:"#ccc",x:t==="horizontal"?e.x-i:n.left+.5,y:t==="horizontal"?n.top+.5:e.y-i,width:t==="horizontal"?r:n.width-1,height:t==="horizontal"?n.height-1:r}}function P8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function D8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?P8(Object(n),!0).forEach(function(r){e0e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):P8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function e0e(t,e,n){return(e=t0e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function t0e(t){var e=n0e(t,"string");return typeof e=="symbol"?e:e+""}function n0e(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 r0e=t=>t.replace(/([A-Z])/g,e=>"-".concat(e.toLowerCase())),wX=(t,e,n)=>t.map(r=>"".concat(r0e(r)," ").concat(e,"ms ").concat(n)).join(","),i0e=(t,e)=>[Object.keys(t),Object.keys(e)].reduce((n,r)=>n.filter(i=>r.includes(i))),ny=(t,e)=>Object.keys(e).reduce((n,r)=>D8(D8({},n),{},{[r]:t(r,e[r])}),{});function R8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Ki(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?R8(Object(n),!0).forEach(function(r){a0e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):R8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function a0e(t,e,n){return(e=s0e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function s0e(t){var e=o0e(t,"string");return typeof e=="symbol"?e:e+""}function o0e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var pS=(t,e,n)=>t+(e-t)*n,QP=t=>{var{from:e,to:n}=t;return e!==n},_X=(t,e,n)=>{var r=ny((i,a)=>{if(QP(a)){var[o,l]=t(a.from,a.to,a.velocity);return Ki(Ki({},a),{},{from:o,velocity:l})}return a},e);return n<1?ny((i,a)=>QP(a)?Ki(Ki({},a),{},{velocity:pS(a.velocity,r[i].velocity,n),from:pS(a.from,r[i].from,n)}):a,e):_X(t,r,n-1)};function l0e(t,e,n,r,i,a){var o,l=r.reduce((p,m)=>Ki(Ki({},p),{},{[m]:{from:t[m],velocity:0,to:e[m]}}),{}),c=()=>ny((p,m)=>m.from,l),u=()=>!Object.values(l).filter(QP).length,d=null,f=p=>{o||(o=p);var m=p-o,x=m/n.dt;l=_X(n,l,x),i(Ki(Ki(Ki({},t),e),c())),o=p,u()||(d=a.setTimeout(f))};return()=>(d=a.setTimeout(f),()=>{var p;(p=d)===null||p===void 0||p()})}function c0e(t,e,n,r,i,a,o){var l=null,c=i.reduce((f,p)=>Ki(Ki({},f),{},{[p]:[t[p],e[p]]}),{}),u,d=f=>{u||(u=f);var p=(f-u)/r,m=ny((b,y)=>pS(...y,n(p)),c);if(a(Ki(Ki(Ki({},t),e),m)),p<1)l=o.setTimeout(d);else{var x=ny((b,y)=>pS(...y,n(1)),c);a(Ki(Ki(Ki({},t),e),x))}};return()=>(l=o.setTimeout(d),()=>{var f;(f=l)===null||f===void 0||f()})}const u0e=(t,e,n,r,i,a)=>{var o=i0e(t,e);return n==null?()=>(i(Ki(Ki({},t),e)),()=>{}):n.isStepper===!0?l0e(t,e,n,o,i,a):c0e(t,e,n,r,o,i,a)};var gS=1e-4,SX=(t,e)=>[0,3*t,3*e-6*t,3*t-3*e+1],MX=(t,e)=>t.map((n,r)=>n*e**r).reduce((n,r)=>n+r),O8=(t,e)=>n=>{var r=SX(t,e);return MX(r,n)},d0e=(t,e)=>n=>{var r=SX(t,e),i=[...r.map((a,o)=>a*o).slice(1),0];return MX(i,n)},h0e=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];if(n.length===1)switch(n[0]){case"linear":return[0,0,1,1];case"ease":return[.25,.1,.25,1];case"ease-in":return[.42,0,1,1];case"ease-out":return[.42,0,.58,1];case"ease-in-out":return[0,0,.58,1];default:{var i,a=n[0].split("(");if(a[0]==="cubic-bezier"&&((i=a[1])===null||i===void 0?void 0:i.split(")")[0].split(",").length)===4){var o=a[1].split(")")[0].split(",").map(l=>parseFloat(l));return[o[0],o[1],o[2],o[3]]}}}return n.length===4?n:[0,0,1,1]},f0e=(t,e,n,r)=>{var i=O8(t,n),a=O8(e,r),o=d0e(t,n),l=u=>u>1?1:u<0?0:u,c=u=>{for(var d=u>1?1:u,f=d,p=0;p<8;++p){var m=i(f)-d,x=o(f);if(Math.abs(m-d)<gS||x<gS)return a(f);f=l(f-m/x)}return a(f)};return c.isStepper=!1,c},L8=function(){return f0e(...h0e(...arguments))},m0e=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},{stiff:n=100,damping:r=8,dt:i=17}=e,a=(o,l,c)=>{var u=-(o-l)*n,d=c*r,f=c+(u-d)*i/1e3,p=c*i/1e3+o;return Math.abs(p-l)<gS&&Math.abs(f)<gS?[l,0]:[p,f]};return a.isStepper=!0,a.dt=i,a},p0e=t=>{if(typeof t=="string")switch(t){case"ease":case"ease-in-out":case"ease-out":case"ease-in":case"linear":return L8(t);case"spring":return m0e();default:if(t.split("(")[0]==="cubic-bezier")return L8(t)}return typeof t=="function"?t:null};function g0e(t){var e,n=()=>null,r=!1,i=null,a=o=>{if(!r){if(Array.isArray(o)){if(!o.length)return;var l=o,[c,...u]=l;if(typeof c=="number"){i=t.setTimeout(a.bind(null,u),c);return}a(c),i=t.setTimeout(a.bind(null,u));return}typeof o=="string"&&(e=o,n(e)),typeof o=="object"&&(e=o,n(e)),typeof o=="function"&&o()}};return{stop:()=>{r=!0},start:o=>{r=!1,i&&(i(),i=null),a(o)},subscribe:o=>(n=o,()=>{n=()=>null}),getTimeoutController:()=>t}}class x0e{setTimeout(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=performance.now(),i=null,a=o=>{o-r>=n?e(o):typeof requestAnimationFrame=="function"&&(i=requestAnimationFrame(a))};return i=requestAnimationFrame(a),()=>{i!=null&&cancelAnimationFrame(i)}}}function b0e(){return g0e(new x0e)}var y0e=_.createContext(b0e);function v0e(t,e){var n=_.useContext(y0e);return _.useMemo(()=>e??n(t),[t,e,n])}var w0e=()=>!(typeof window<"u"&&window.document&&window.document.createElement&&window.setTimeout),yx={devToolsEnabled:!1,isSsr:w0e()},_0e={begin:0,duration:1e3,easing:"ease",isActive:!0,canBegin:!0,onAnimationEnd:()=>{},onAnimationStart:()=>{}},F8={t:0},cA={t:1};function vx(t){var e=li(t,_0e),{isActive:n,canBegin:r,duration:i,easing:a,begin:o,onAnimationEnd:l,onAnimationStart:c,children:u}=e,d=n==="auto"?!yx.isSsr:n,f=v0e(e.animationId,e.animationManager),[p,m]=_.useState(d?F8:cA),x=_.useRef(null);return _.useEffect(()=>{d||m(cA)},[d]),_.useEffect(()=>{if(!d||!r)return Uy;var b=u0e(F8,cA,p0e(a),i,m,f.getTimeoutController()),y=()=>{x.current=b()};return f.start([c,o,y,i,l]),()=>{f.stop(),x.current&&x.current(),l()}},[d,r,i,a,o,c,l,f]),u(p.t)}function wx(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"animation-",n=_.useRef(X0(e)),r=_.useRef(t);return r.current!==t&&(n.current=X0(e),r.current=t),n.current}var S0e=["radius"],M0e=["radius"];function I8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function U8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?I8(Object(n),!0).forEach(function(r){N0e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):I8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function N0e(t,e,n){return(e=k0e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function k0e(t){var e=E0e(t,"string");return typeof e=="symbol"?e:e+""}function E0e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function xS(){return xS=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},xS.apply(null,arguments)}function z8(t,e){if(t==null)return{};var n,r,i=T0e(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function T0e(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var B8=(t,e,n,r,i)=>{var a=Math.min(Math.abs(n)/2,Math.abs(r)/2),o=r>=0?1:-1,l=n>=0?1:-1,c=r>=0&&n>=0||r<0&&n<0?1:0,u;if(a>0&&i instanceof Array){for(var d=[0,0,0,0],f=0,p=4;f<p;f++)d[f]=i[f]>a?a:i[f];u="M".concat(t,",").concat(e+o*d[0]),d[0]>0&&(u+="A ".concat(d[0],",").concat(d[0],",0,0,").concat(c,",").concat(t+l*d[0],",").concat(e)),u+="L ".concat(t+n-l*d[1],",").concat(e),d[1]>0&&(u+="A ".concat(d[1],",").concat(d[1],",0,0,").concat(c,`,
- `).concat(t+n,",").concat(e+o*d[1])),u+="L ".concat(t+n,",").concat(e+r-o*d[2]),d[2]>0&&(u+="A ".concat(d[2],",").concat(d[2],",0,0,").concat(c,`,
- `).concat(t+n-l*d[2],",").concat(e+r)),u+="L ".concat(t+l*d[3],",").concat(e+r),d[3]>0&&(u+="A ".concat(d[3],",").concat(d[3],",0,0,").concat(c,`,
- `).concat(t,",").concat(e+r-o*d[3])),u+="Z"}else if(a>0&&i===+i&&i>0){var m=Math.min(a,i);u="M ".concat(t,",").concat(e+o*m,`
- A `).concat(m,",").concat(m,",0,0,").concat(c,",").concat(t+l*m,",").concat(e,`
- L `).concat(t+n-l*m,",").concat(e,`
- A `).concat(m,",").concat(m,",0,0,").concat(c,",").concat(t+n,",").concat(e+o*m,`
- L `).concat(t+n,",").concat(e+r-o*m,`
- A `).concat(m,",").concat(m,",0,0,").concat(c,",").concat(t+n-l*m,",").concat(e+r,`
- L `).concat(t+l*m,",").concat(e+r,`
- A `).concat(m,",").concat(m,",0,0,").concat(c,",").concat(t,",").concat(e+r-o*m," Z")}else u="M ".concat(t,",").concat(e," h ").concat(n," v ").concat(r," h ").concat(-n," Z");return u},H8={x:0,y:0,width:0,height:0,radius:0,isAnimationActive:!1,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},NX=t=>{var e=li(t,H8),n=_.useRef(null),[r,i]=_.useState(-1);_.useEffect(()=>{if(n.current&&n.current.getTotalLength)try{var V=n.current.getTotalLength();V&&i(V)}catch{}},[]);var{x:a,y:o,width:l,height:c,radius:u,className:d}=e,{animationEasing:f,animationDuration:p,animationBegin:m,isAnimationActive:x,isUpdateAnimationActive:b}=e,y=_.useRef(l),v=_.useRef(c),S=_.useRef(a),N=_.useRef(o),T=_.useMemo(()=>({x:a,y:o,width:l,height:c,radius:u}),[a,o,l,c,u]),k=wx(T,"rectangle-");if(a!==+a||o!==+o||l!==+l||c!==+c||l===0||c===0)return null;var C=tr("recharts-rectangle",d);if(!b){var E=za(e),{radius:D}=E,A=z8(E,S0e);return _.createElement("path",xS({},A,{radius:typeof u=="number"?u:void 0,className:C,d:B8(a,o,l,c,u)}))}var R=y.current,U=v.current,F=S.current,$=N.current,j="0px ".concat(r===-1?1:r,"px"),H="".concat(r,"px 0px"),K=wX(["strokeDasharray"],p,typeof f=="string"?f:H8.animationEasing);return _.createElement(vx,{animationId:k,key:k,canBegin:r>0,duration:p,easing:f,isActive:b,begin:m},V=>{var Q=hr(R,l,V),Z=hr(U,c,V),ae=hr(F,a,V),B=hr($,o,V);n.current&&(y.current=Q,v.current=Z,S.current=ae,N.current=B);var X;x?V>0?X={transition:K,strokeDasharray:H}:X={strokeDasharray:j}:X={strokeDasharray:H};var ne=za(e),{radius:se}=ne,be=z8(ne,M0e);return _.createElement("path",xS({},be,{radius:typeof u=="number"?u:void 0,className:C,d:B8(ae,B,Q,Z,u),ref:n,style:U8(U8({},X),e.style)}))})};function $8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function V8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?$8(Object(n),!0).forEach(function(r){A0e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):$8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function A0e(t,e,n){return(e=C0e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function C0e(t){var e=j0e(t,"string");return typeof e=="symbol"?e:e+""}function j0e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var bS=Math.PI/180,P0e=t=>t*180/Math.PI,zi=(t,e,n,r)=>({x:t+Math.cos(-bS*r)*n,y:e+Math.sin(-bS*r)*n}),kX=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},D0e=(t,e)=>{var{x:n,y:r}=t,{x:i,y:a}=e;return Math.sqrt((n-i)**2+(r-a)**2)},R0e=(t,e)=>{var{x:n,y:r}=t,{cx:i,cy:a}=e,o=D0e({x:n,y:r},{x:i,y:a});if(o<=0)return{radius:o,angle:0};var l=(n-i)/o,c=Math.acos(l);return r>a&&(c=2*Math.PI-c),{radius:o,angle:P0e(c),angleInRadian:c}},O0e=t=>{var{startAngle:e,endAngle:n}=t,r=Math.floor(e/360),i=Math.floor(n/360),a=Math.min(r,i);return{startAngle:e-a*360,endAngle:n-a*360}},L0e=(t,e)=>{var{startAngle:n,endAngle:r}=e,i=Math.floor(n/360),a=Math.floor(r/360),o=Math.min(i,a);return t+o*360},F0e=(t,e)=>{var{chartX:n,chartY:r}=t,{radius:i,angle:a}=R0e({x:n,y:r},e),{innerRadius:o,outerRadius:l}=e;if(i<o||i>l||i===0)return null;var{startAngle:c,endAngle:u}=O0e(e),d=a,f;if(c<=u){for(;d>u;)d-=360;for(;d<c;)d+=360;f=d>=c&&d<=u}else{for(;d>c;)d-=360;for(;d<u;)d+=360;f=d>=u&&d<=c}return f?V8(V8({},e),{},{radius:i,angle:L0e(d,e)}):null};function EX(t){var{cx:e,cy:n,radius:r,startAngle:i,endAngle:a}=t,o=zi(e,n,r,i),l=zi(e,n,r,a);return{points:[o,l],cx:e,cy:n,radius:r,startAngle:i,endAngle:a}}function ZP(){return ZP=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},ZP.apply(null,arguments)}var I0e=(t,e)=>{var n=ya(e-t),r=Math.min(Math.abs(e-t),359.999);return n*r},$w=t=>{var{cx:e,cy:n,radius:r,angle:i,sign:a,isExternal:o,cornerRadius:l,cornerIsExternal:c}=t,u=l*(o?1:-1)+r,d=Math.asin(l/u)/bS,f=c?i:i+a*d,p=zi(e,n,u,f),m=zi(e,n,r,f),x=c?i-a*d:i,b=zi(e,n,u*Math.cos(d*bS),x);return{center:p,circleTangency:m,lineTangency:b,theta:d}},TX=t=>{var{cx:e,cy:n,innerRadius:r,outerRadius:i,startAngle:a,endAngle:o}=t,l=I0e(a,o),c=a+l,u=zi(e,n,i,a),d=zi(e,n,i,c),f="M ".concat(u.x,",").concat(u.y,`
- A `).concat(i,",").concat(i,`,0,
- `).concat(+(Math.abs(l)>180),",").concat(+(a>c),`,
- `).concat(d.x,",").concat(d.y,`
- `);if(r>0){var p=zi(e,n,r,a),m=zi(e,n,r,c);f+="L ".concat(m.x,",").concat(m.y,`
- A `).concat(r,",").concat(r,`,0,
- `).concat(+(Math.abs(l)>180),",").concat(+(a<=c),`,
- `).concat(p.x,",").concat(p.y," Z")}else f+="L ".concat(e,",").concat(n," Z");return f},U0e=t=>{var{cx:e,cy:n,innerRadius:r,outerRadius:i,cornerRadius:a,forceCornerRadius:o,cornerIsExternal:l,startAngle:c,endAngle:u}=t,d=ya(u-c),{circleTangency:f,lineTangency:p,theta:m}=$w({cx:e,cy:n,radius:i,angle:c,sign:d,cornerRadius:a,cornerIsExternal:l}),{circleTangency:x,lineTangency:b,theta:y}=$w({cx:e,cy:n,radius:i,angle:u,sign:-d,cornerRadius:a,cornerIsExternal:l}),v=l?Math.abs(c-u):Math.abs(c-u)-m-y;if(v<0)return o?"M ".concat(p.x,",").concat(p.y,`
- a`).concat(a,",").concat(a,",0,0,1,").concat(a*2,`,0
- a`).concat(a,",").concat(a,",0,0,1,").concat(-a*2,`,0
- `):TX({cx:e,cy:n,innerRadius:r,outerRadius:i,startAngle:c,endAngle:u});var S="M ".concat(p.x,",").concat(p.y,`
- A`).concat(a,",").concat(a,",0,0,").concat(+(d<0),",").concat(f.x,",").concat(f.y,`
- A`).concat(i,",").concat(i,",0,").concat(+(v>180),",").concat(+(d<0),",").concat(x.x,",").concat(x.y,`
- A`).concat(a,",").concat(a,",0,0,").concat(+(d<0),",").concat(b.x,",").concat(b.y,`
- `);if(r>0){var{circleTangency:N,lineTangency:T,theta:k}=$w({cx:e,cy:n,radius:r,angle:c,sign:d,isExternal:!0,cornerRadius:a,cornerIsExternal:l}),{circleTangency:C,lineTangency:E,theta:D}=$w({cx:e,cy:n,radius:r,angle:u,sign:-d,isExternal:!0,cornerRadius:a,cornerIsExternal:l}),A=l?Math.abs(c-u):Math.abs(c-u)-k-D;if(A<0&&a===0)return"".concat(S,"L").concat(e,",").concat(n,"Z");S+="L".concat(E.x,",").concat(E.y,`
- A`).concat(a,",").concat(a,",0,0,").concat(+(d<0),",").concat(C.x,",").concat(C.y,`
- A`).concat(r,",").concat(r,",0,").concat(+(A>180),",").concat(+(d>0),",").concat(N.x,",").concat(N.y,`
- A`).concat(a,",").concat(a,",0,0,").concat(+(d<0),",").concat(T.x,",").concat(T.y,"Z")}else S+="L".concat(e,",").concat(n,"Z");return S},z0e={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},AX=t=>{var e=li(t,z0e),{cx:n,cy:r,innerRadius:i,outerRadius:a,cornerRadius:o,forceCornerRadius:l,cornerIsExternal:c,startAngle:u,endAngle:d,className:f}=e;if(a<i||u===d)return null;var p=tr("recharts-sector",f),m=a-i,x=es(o,m,0,!0),b;return x>0&&Math.abs(u-d)<360?b=U0e({cx:n,cy:r,innerRadius:i,outerRadius:a,cornerRadius:Math.min(x,m/2),forceCornerRadius:l,cornerIsExternal:c,startAngle:u,endAngle:d}):b=TX({cx:n,cy:r,innerRadius:i,outerRadius:a,startAngle:u,endAngle:d}),_.createElement("path",ZP({},za(e),{className:p,d:b}))};function B0e(t,e,n){if(t==="horizontal")return[{x:e.x,y:n.top},{x:e.x,y:n.top+n.height}];if(t==="vertical")return[{x:n.left,y:e.y},{x:n.left+n.width,y:e.y}];if(sK(e)){if(t==="centric"){var{cx:r,cy:i,innerRadius:a,outerRadius:o,angle:l}=e,c=zi(r,i,a,l),u=zi(r,i,o,l);return[{x:c.x,y:c.y},{x:u.x,y:u.y}]}return EX(e)}}var uA={},dA={},hA={},G8;function H0e(){return G8||(G8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=yK();function n(r){return e.isSymbol(r)?NaN:Number(r)}t.toNumber=n})(hA)),hA}var q8;function $0e(){return q8||(q8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=H0e();function n(r){return r?(r=e.toNumber(r),r===1/0||r===-1/0?(r<0?-1:1)*Number.MAX_VALUE:r===r?r:0):r===0?r:0}t.toFinite=n})(dA)),dA}var W8;function V0e(){return W8||(W8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=vK(),n=$0e();function r(i,a,o){o&&typeof o!="number"&&e.isIterateeCall(i,a,o)&&(a=o=void 0),i=n.toFinite(i),a===void 0?(a=i,i=0):a=n.toFinite(a),o=o===void 0?i<a?1:-1:n.toFinite(o);const l=Math.max(Math.ceil((a-i)/(o||1)),0),c=new Array(l);for(let u=0;u<l;u++)c[u]=i,i+=o;return c}t.range=r})(uA)),uA}var fA,K8;function G0e(){return K8||(K8=1,fA=V0e().range),fA}var q0e=G0e();const CX=hl(q0e);function oh(t,e){return t==null||e==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function W0e(t,e){return t==null||e==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function hO(t){let e,n,r;t.length!==2?(e=oh,n=(l,c)=>oh(t(l),c),r=(l,c)=>t(l)-c):(e=t===oh||t===W0e?t:K0e,n=t,r=t);function i(l,c,u=0,d=l.length){if(u<d){if(e(c,c)!==0)return d;do{const f=u+d>>>1;n(l[f],c)<0?u=f+1:d=f}while(u<d)}return u}function a(l,c,u=0,d=l.length){if(u<d){if(e(c,c)!==0)return d;do{const f=u+d>>>1;n(l[f],c)<=0?u=f+1:d=f}while(u<d)}return u}function o(l,c,u=0,d=l.length){const f=i(l,c,u,d-1);return f>u&&r(l[f-1],c)>-r(l[f],c)?f-1:f}return{left:i,center:o,right:a}}function K0e(){return 0}function jX(t){return t===null?NaN:+t}function*X0e(t,e){for(let n of t)n!=null&&(n=+n)>=n&&(yield n)}const Y0e=hO(oh),Wy=Y0e.right;hO(jX).center;class X8 extends Map{constructor(e,n=J0e){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:n}}),e!=null)for(const[r,i]of e)this.set(r,i)}get(e){return super.get(Y8(this,e))}has(e){return super.has(Y8(this,e))}set(e,n){return super.set(Q0e(this,e),n)}delete(e){return super.delete(Z0e(this,e))}}function Y8({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):n}function Q0e({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):(t.set(r,n),n)}function Z0e({_intern:t,_key:e},n){const r=e(n);return t.has(r)&&(n=t.get(r),t.delete(r)),n}function J0e(t){return t!==null&&typeof t=="object"?t.valueOf():t}function eye(t=oh){if(t===oh)return PX;if(typeof t!="function")throw new TypeError("compare is not a function");return(e,n)=>{const r=t(e,n);return r||r===0?r:(t(n,n)===0)-(t(e,e)===0)}}function PX(t,e){return(t==null||!(t>=t))-(e==null||!(e>=e))||(t<e?-1:t>e?1:0)}const tye=Math.sqrt(50),nye=Math.sqrt(10),rye=Math.sqrt(2);function yS(t,e,n){const r=(e-t)/Math.max(0,n),i=Math.floor(Math.log10(r)),a=r/Math.pow(10,i),o=a>=tye?10:a>=nye?5:a>=rye?2:1;let l,c,u;return i<0?(u=Math.pow(10,-i)/o,l=Math.round(t*u),c=Math.round(e*u),l/u<t&&++l,c/u>e&&--c,u=-u):(u=Math.pow(10,i)*o,l=Math.round(t/u),c=Math.round(e/u),l*u<t&&++l,c*u>e&&--c),c<l&&.5<=n&&n<2?yS(t,e,n*2):[l,c,u]}function JP(t,e,n){if(e=+e,t=+t,n=+n,!(n>0))return[];if(t===e)return[t];const r=e<t,[i,a,o]=r?yS(e,t,n):yS(t,e,n);if(!(a>=i))return[];const l=a-i+1,c=new Array(l);if(r)if(o<0)for(let u=0;u<l;++u)c[u]=(a-u)/-o;else for(let u=0;u<l;++u)c[u]=(a-u)*o;else if(o<0)for(let u=0;u<l;++u)c[u]=(i+u)/-o;else for(let u=0;u<l;++u)c[u]=(i+u)*o;return c}function e3(t,e,n){return e=+e,t=+t,n=+n,yS(t,e,n)[2]}function t3(t,e,n){e=+e,t=+t,n=+n;const r=e<t,i=r?e3(e,t,n):e3(t,e,n);return(r?-1:1)*(i<0?1/-i:i)}function Q8(t,e){let n;for(const r of t)r!=null&&(n<r||n===void 0&&r>=r)&&(n=r);return n}function Z8(t,e){let n;for(const r of t)r!=null&&(n>r||n===void 0&&r>=r)&&(n=r);return n}function DX(t,e,n=0,r=1/0,i){if(e=Math.floor(e),n=Math.floor(Math.max(0,n)),r=Math.floor(Math.min(t.length-1,r)),!(n<=e&&e<=r))return t;for(i=i===void 0?PX:eye(i);r>n;){if(r-n>600){const c=r-n+1,u=e-n+1,d=Math.log(c),f=.5*Math.exp(2*d/3),p=.5*Math.sqrt(d*f*(c-f)/c)*(u-c/2<0?-1:1),m=Math.max(n,Math.floor(e-u*f/c+p)),x=Math.min(r,Math.floor(e+(c-u)*f/c+p));DX(t,e,m,x,i)}const a=t[e];let o=n,l=r;for(Rb(t,n,e),i(t[r],a)>0&&Rb(t,n,r);o<l;){for(Rb(t,o,l),++o,--l;i(t[o],a)<0;)++o;for(;i(t[l],a)>0;)--l}i(t[n],a)===0?Rb(t,n,l):(++l,Rb(t,l,r)),l<=e&&(n=l+1),e<=l&&(r=l-1)}return t}function Rb(t,e,n){const r=t[e];t[e]=t[n],t[n]=r}function iye(t,e,n){if(t=Float64Array.from(X0e(t)),!(!(r=t.length)||isNaN(e=+e))){if(e<=0||r<2)return Z8(t);if(e>=1)return Q8(t);var r,i=(r-1)*e,a=Math.floor(i),o=Q8(DX(t,a).subarray(0,a+1)),l=Z8(t.subarray(a+1));return o+(l-o)*(i-a)}}function aye(t,e,n=jX){if(!(!(r=t.length)||isNaN(e=+e))){if(e<=0||r<2)return+n(t[0],0,t);if(e>=1)return+n(t[r-1],r-1,t);var r,i=(r-1)*e,a=Math.floor(i),o=+n(t[a],a,t),l=+n(t[a+1],a+1,t);return o+(l-o)*(i-a)}}function sye(t,e,n){t=+t,e=+e,n=(i=arguments.length)<2?(e=t,t=0,1):i<3?1:+n;for(var r=-1,i=Math.max(0,Math.ceil((e-t)/n))|0,a=new Array(i);++r<i;)a[r]=t+r*n;return a}function ml(t,e){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(e).domain(t);break}return this}function Ku(t,e){switch(arguments.length){case 0:break;case 1:{typeof t=="function"?this.interpolator(t):this.range(t);break}default:{this.domain(t),typeof e=="function"?this.interpolator(e):this.range(e);break}}return this}const n3=Symbol("implicit");function fO(){var t=new X8,e=[],n=[],r=n3;function i(a){let o=t.get(a);if(o===void 0){if(r!==n3)return r;t.set(a,o=e.push(a)-1)}return n[o%n.length]}return i.domain=function(a){if(!arguments.length)return e.slice();e=[],t=new X8;for(const o of a)t.has(o)||t.set(o,e.push(o)-1);return i},i.range=function(a){return arguments.length?(n=Array.from(a),i):n.slice()},i.unknown=function(a){return arguments.length?(r=a,i):r},i.copy=function(){return fO(e,n).unknown(r)},ml.apply(i,arguments),i}function mO(){var t=fO().unknown(void 0),e=t.domain,n=t.range,r=0,i=1,a,o,l=!1,c=0,u=0,d=.5;delete t.unknown;function f(){var p=e().length,m=i<r,x=m?i:r,b=m?r:i;a=(b-x)/Math.max(1,p-c+u*2),l&&(a=Math.floor(a)),x+=(b-x-a*(p-c))*d,o=a*(1-c),l&&(x=Math.round(x),o=Math.round(o));var y=sye(p).map(function(v){return x+a*v});return n(m?y.reverse():y)}return t.domain=function(p){return arguments.length?(e(p),f()):e()},t.range=function(p){return arguments.length?([r,i]=p,r=+r,i=+i,f()):[r,i]},t.rangeRound=function(p){return[r,i]=p,r=+r,i=+i,l=!0,f()},t.bandwidth=function(){return o},t.step=function(){return a},t.round=function(p){return arguments.length?(l=!!p,f()):l},t.padding=function(p){return arguments.length?(c=Math.min(1,u=+p),f()):c},t.paddingInner=function(p){return arguments.length?(c=Math.min(1,p),f()):c},t.paddingOuter=function(p){return arguments.length?(u=+p,f()):u},t.align=function(p){return arguments.length?(d=Math.max(0,Math.min(1,p)),f()):d},t.copy=function(){return mO(e(),[r,i]).round(l).paddingInner(c).paddingOuter(u).align(d)},ml.apply(f(),arguments)}function RX(t){var e=t.copy;return t.padding=t.paddingOuter,delete t.paddingInner,delete t.paddingOuter,t.copy=function(){return RX(e())},t}function oye(){return RX(mO.apply(null,arguments).paddingInner(1))}function pO(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function OX(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function Ky(){}var ry=.7,vS=1/ry,Eg="\\s*([+-]?\\d+)\\s*",iy="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",dc="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",lye=/^#([0-9a-f]{3,8})$/,cye=new RegExp(`^rgb\\(${Eg},${Eg},${Eg}\\)$`),uye=new RegExp(`^rgb\\(${dc},${dc},${dc}\\)$`),dye=new RegExp(`^rgba\\(${Eg},${Eg},${Eg},${iy}\\)$`),hye=new RegExp(`^rgba\\(${dc},${dc},${dc},${iy}\\)$`),fye=new RegExp(`^hsl\\(${iy},${dc},${dc}\\)$`),mye=new RegExp(`^hsla\\(${iy},${dc},${dc},${iy}\\)$`),J8={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};pO(Ky,ay,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:e6,formatHex:e6,formatHex8:pye,formatHsl:gye,formatRgb:t6,toString:t6});function e6(){return this.rgb().formatHex()}function pye(){return this.rgb().formatHex8()}function gye(){return LX(this).formatHsl()}function t6(){return this.rgb().formatRgb()}function ay(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=lye.exec(t))?(n=e[1].length,e=parseInt(e[1],16),n===6?n6(e):n===3?new Fs(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):n===8?Vw(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):n===4?Vw(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|e&240,((e&15)<<4|e&15)/255):null):(e=cye.exec(t))?new Fs(e[1],e[2],e[3],1):(e=uye.exec(t))?new Fs(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=dye.exec(t))?Vw(e[1],e[2],e[3],e[4]):(e=hye.exec(t))?Vw(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=fye.exec(t))?a6(e[1],e[2]/100,e[3]/100,1):(e=mye.exec(t))?a6(e[1],e[2]/100,e[3]/100,e[4]):J8.hasOwnProperty(t)?n6(J8[t]):t==="transparent"?new Fs(NaN,NaN,NaN,0):null}function n6(t){return new Fs(t>>16&255,t>>8&255,t&255,1)}function Vw(t,e,n,r){return r<=0&&(t=e=n=NaN),new Fs(t,e,n,r)}function xye(t){return t instanceof Ky||(t=ay(t)),t?(t=t.rgb(),new Fs(t.r,t.g,t.b,t.opacity)):new Fs}function r3(t,e,n,r){return arguments.length===1?xye(t):new Fs(t,e,n,r??1)}function Fs(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}pO(Fs,r3,OX(Ky,{brighter(t){return t=t==null?vS:Math.pow(vS,t),new Fs(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?ry:Math.pow(ry,t),new Fs(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new Fs($f(this.r),$f(this.g),$f(this.b),wS(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:r6,formatHex:r6,formatHex8:bye,formatRgb:i6,toString:i6}));function r6(){return`#${Pf(this.r)}${Pf(this.g)}${Pf(this.b)}`}function bye(){return`#${Pf(this.r)}${Pf(this.g)}${Pf(this.b)}${Pf((isNaN(this.opacity)?1:this.opacity)*255)}`}function i6(){const t=wS(this.opacity);return`${t===1?"rgb(":"rgba("}${$f(this.r)}, ${$f(this.g)}, ${$f(this.b)}${t===1?")":`, ${t})`}`}function wS(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function $f(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function Pf(t){return t=$f(t),(t<16?"0":"")+t.toString(16)}function a6(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new Al(t,e,n,r)}function LX(t){if(t instanceof Al)return new Al(t.h,t.s,t.l,t.opacity);if(t instanceof Ky||(t=ay(t)),!t)return new Al;if(t instanceof Al)return t;t=t.rgb();var e=t.r/255,n=t.g/255,r=t.b/255,i=Math.min(e,n,r),a=Math.max(e,n,r),o=NaN,l=a-i,c=(a+i)/2;return l?(e===a?o=(n-r)/l+(n<r)*6:n===a?o=(r-e)/l+2:o=(e-n)/l+4,l/=c<.5?a+i:2-a-i,o*=60):l=c>0&&c<1?0:o,new Al(o,l,c,t.opacity)}function yye(t,e,n,r){return arguments.length===1?LX(t):new Al(t,e,n,r??1)}function Al(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}pO(Al,yye,OX(Ky,{brighter(t){return t=t==null?vS:Math.pow(vS,t),new Al(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?ry:Math.pow(ry,t),new Al(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+(this.h<0)*360,e=isNaN(t)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*e,i=2*n-r;return new Fs(mA(t>=240?t-240:t+120,i,r),mA(t,i,r),mA(t<120?t+240:t-120,i,r),this.opacity)},clamp(){return new Al(s6(this.h),Gw(this.s),Gw(this.l),wS(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const t=wS(this.opacity);return`${t===1?"hsl(":"hsla("}${s6(this.h)}, ${Gw(this.s)*100}%, ${Gw(this.l)*100}%${t===1?")":`, ${t})`}`}}));function s6(t){return t=(t||0)%360,t<0?t+360:t}function Gw(t){return Math.max(0,Math.min(1,t||0))}function mA(t,e,n){return(t<60?e+(n-e)*t/60:t<180?n:t<240?e+(n-e)*(240-t)/60:e)*255}const gO=t=>()=>t;function vye(t,e){return function(n){return t+n*e}}function wye(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 _ye(t){return(t=+t)==1?FX:function(e,n){return n-e?wye(e,n,t):gO(isNaN(e)?n:e)}}function FX(t,e){var n=e-t;return n?vye(t,n):gO(isNaN(t)?e:t)}const o6=(function t(e){var n=_ye(e);function r(i,a){var o=n((i=r3(i)).r,(a=r3(a)).r),l=n(i.g,a.g),c=n(i.b,a.b),u=FX(i.opacity,a.opacity);return function(d){return i.r=o(d),i.g=l(d),i.b=c(d),i.opacity=u(d),i+""}}return r.gamma=t,r})(1);function Sye(t,e){e||(e=[]);var n=t?Math.min(e.length,t.length):0,r=e.slice(),i;return function(a){for(i=0;i<n;++i)r[i]=t[i]*(1-a)+e[i]*a;return r}}function Mye(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function Nye(t,e){var n=e?e.length:0,r=t?Math.min(n,t.length):0,i=new Array(r),a=new Array(n),o;for(o=0;o<r;++o)i[o]=_x(t[o],e[o]);for(;o<n;++o)a[o]=e[o];return function(l){for(o=0;o<r;++o)a[o]=i[o](l);return a}}function kye(t,e){var n=new Date;return t=+t,e=+e,function(r){return n.setTime(t*(1-r)+e*r),n}}function _S(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}function Eye(t,e){var n={},r={},i;(t===null||typeof t!="object")&&(t={}),(e===null||typeof e!="object")&&(e={});for(i in e)i in t?n[i]=_x(t[i],e[i]):r[i]=e[i];return function(a){for(i in n)r[i]=n[i](a);return r}}var i3=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,pA=new RegExp(i3.source,"g");function Tye(t){return function(){return t}}function Aye(t){return function(e){return t(e)+""}}function Cye(t,e){var n=i3.lastIndex=pA.lastIndex=0,r,i,a,o=-1,l=[],c=[];for(t=t+"",e=e+"";(r=i3.exec(t))&&(i=pA.exec(e));)(a=i.index)>n&&(a=e.slice(n,a),l[o]?l[o]+=a:l[++o]=a),(r=r[0])===(i=i[0])?l[o]?l[o]+=i:l[++o]=i:(l[++o]=null,c.push({i:o,x:_S(r,i)})),n=pA.lastIndex;return n<e.length&&(a=e.slice(n),l[o]?l[o]+=a:l[++o]=a),l.length<2?c[0]?Aye(c[0].x):Tye(e):(e=c.length,function(u){for(var d=0,f;d<e;++d)l[(f=c[d]).i]=f.x(u);return l.join("")})}function _x(t,e){var n=typeof e,r;return e==null||n==="boolean"?gO(e):(n==="number"?_S:n==="string"?(r=ay(e))?(e=r,o6):Cye:e instanceof ay?o6:e instanceof Date?kye:Mye(e)?Sye:Array.isArray(e)?Nye:typeof e.valueOf!="function"&&typeof e.toString!="function"||isNaN(e)?Eye:_S)(t,e)}function xO(t,e){return t=+t,e=+e,function(n){return Math.round(t*(1-n)+e*n)}}function jye(t,e){e===void 0&&(e=t,t=_x);for(var n=0,r=e.length-1,i=e[0],a=new Array(r<0?0:r);n<r;)a[n]=t(i,i=e[++n]);return function(o){var l=Math.max(0,Math.min(r-1,Math.floor(o*=r)));return a[l](o-l)}}function Pye(t){return function(){return t}}function SS(t){return+t}var l6=[0,1];function fs(t){return t}function a3(t,e){return(e-=t=+t)?function(n){return(n-t)/e}:Pye(isNaN(e)?NaN:.5)}function Dye(t,e){var n;return t>e&&(n=t,t=e,e=n),function(r){return Math.max(t,Math.min(e,r))}}function Rye(t,e,n){var r=t[0],i=t[1],a=e[0],o=e[1];return i<r?(r=a3(i,r),a=n(o,a)):(r=a3(r,i),a=n(a,o)),function(l){return a(r(l))}}function Oye(t,e,n){var r=Math.min(t.length,e.length)-1,i=new Array(r),a=new Array(r),o=-1;for(t[r]<t[0]&&(t=t.slice().reverse(),e=e.slice().reverse());++o<r;)i[o]=a3(t[o],t[o+1]),a[o]=n(e[o],e[o+1]);return function(l){var c=Wy(t,l,1,r)-1;return a[c](i[c](l))}}function Xy(t,e){return e.domain(t.domain()).range(t.range()).interpolate(t.interpolate()).clamp(t.clamp()).unknown(t.unknown())}function zN(){var t=l6,e=l6,n=_x,r,i,a,o=fs,l,c,u;function d(){var p=Math.min(t.length,e.length);return o!==fs&&(o=Dye(t[0],t[p-1])),l=p>2?Oye:Rye,c=u=null,f}function f(p){return p==null||isNaN(p=+p)?a:(c||(c=l(t.map(r),e,n)))(r(o(p)))}return f.invert=function(p){return o(i((u||(u=l(e,t.map(r),_S)))(p)))},f.domain=function(p){return arguments.length?(t=Array.from(p,SS),d()):t.slice()},f.range=function(p){return arguments.length?(e=Array.from(p),d()):e.slice()},f.rangeRound=function(p){return e=Array.from(p),n=xO,d()},f.clamp=function(p){return arguments.length?(o=p?!0:fs,d()):o!==fs},f.interpolate=function(p){return arguments.length?(n=p,d()):n},f.unknown=function(p){return arguments.length?(a=p,f):a},function(p,m){return r=p,i=m,d()}}function bO(){return zN()(fs,fs)}function Lye(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)}function MS(t,e){if((n=(t=e?t.toExponential(e-1):t.toExponential()).indexOf("e"))<0)return null;var n,r=t.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+t.slice(n+1)]}function Kg(t){return t=MS(Math.abs(t)),t?t[1]:NaN}function Fye(t,e){return function(n,r){for(var i=n.length,a=[],o=0,l=t[0],c=0;i>0&&l>0&&(c+l+1>r&&(l=Math.max(1,r-c)),a.push(n.substring(i-=l,i+l)),!((c+=l+1)>r));)l=t[o=(o+1)%t.length];return a.reverse().join(e)}}function Iye(t){return function(e){return e.replace(/[0-9]/g,function(n){return t[+n]})}}var Uye=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function sy(t){if(!(e=Uye.exec(t)))throw new Error("invalid format: "+t);var e;return new yO({fill:e[1],align:e[2],sign:e[3],symbol:e[4],zero:e[5],width:e[6],comma:e[7],precision:e[8]&&e[8].slice(1),trim:e[9],type:e[10]})}sy.prototype=yO.prototype;function yO(t){this.fill=t.fill===void 0?" ":t.fill+"",this.align=t.align===void 0?">":t.align+"",this.sign=t.sign===void 0?"-":t.sign+"",this.symbol=t.symbol===void 0?"":t.symbol+"",this.zero=!!t.zero,this.width=t.width===void 0?void 0:+t.width,this.comma=!!t.comma,this.precision=t.precision===void 0?void 0:+t.precision,this.trim=!!t.trim,this.type=t.type===void 0?"":t.type+""}yO.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function zye(t){e:for(var e=t.length,n=1,r=-1,i;n<e;++n)switch(t[n]){case".":r=i=n;break;case"0":r===0&&(r=n),i=n;break;default:if(!+t[n])break e;r>0&&(r=0);break}return r>0?t.slice(0,r)+t.slice(i+1):t}var IX;function Bye(t,e){var n=MS(t,e);if(!n)return t+"";var r=n[0],i=n[1],a=i-(IX=Math.max(-8,Math.min(8,Math.floor(i/3)))*3)+1,o=r.length;return a===o?r:a>o?r+new Array(a-o+1).join("0"):a>0?r.slice(0,a)+"."+r.slice(a):"0."+new Array(1-a).join("0")+MS(t,Math.max(0,e+a-1))[0]}function c6(t,e){var n=MS(t,e);if(!n)return t+"";var r=n[0],i=n[1];return i<0?"0."+new Array(-i).join("0")+r:r.length>i+1?r.slice(0,i+1)+"."+r.slice(i+1):r+new Array(i-r.length+2).join("0")}const u6={"%":(t,e)=>(t*100).toFixed(e),b:t=>Math.round(t).toString(2),c:t=>t+"",d:Lye,e:(t,e)=>t.toExponential(e),f:(t,e)=>t.toFixed(e),g:(t,e)=>t.toPrecision(e),o:t=>Math.round(t).toString(8),p:(t,e)=>c6(t*100,e),r:c6,s:Bye,X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function d6(t){return t}var h6=Array.prototype.map,f6=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function Hye(t){var e=t.grouping===void 0||t.thousands===void 0?d6:Fye(h6.call(t.grouping,Number),t.thousands+""),n=t.currency===void 0?"":t.currency[0]+"",r=t.currency===void 0?"":t.currency[1]+"",i=t.decimal===void 0?".":t.decimal+"",a=t.numerals===void 0?d6:Iye(h6.call(t.numerals,String)),o=t.percent===void 0?"%":t.percent+"",l=t.minus===void 0?"−":t.minus+"",c=t.nan===void 0?"NaN":t.nan+"";function u(f){f=sy(f);var p=f.fill,m=f.align,x=f.sign,b=f.symbol,y=f.zero,v=f.width,S=f.comma,N=f.precision,T=f.trim,k=f.type;k==="n"?(S=!0,k="g"):u6[k]||(N===void 0&&(N=12),T=!0,k="g"),(y||p==="0"&&m==="=")&&(y=!0,p="0",m="=");var C=b==="$"?n:b==="#"&&/[boxX]/.test(k)?"0"+k.toLowerCase():"",E=b==="$"?r:/[%p]/.test(k)?o:"",D=u6[k],A=/[defgprs%]/.test(k);N=N===void 0?6:/[gprs]/.test(k)?Math.max(1,Math.min(21,N)):Math.max(0,Math.min(20,N));function R(U){var F=C,$=E,j,H,K;if(k==="c")$=D(U)+$,U="";else{U=+U;var V=U<0||1/U<0;if(U=isNaN(U)?c:D(Math.abs(U),N),T&&(U=zye(U)),V&&+U==0&&x!=="+"&&(V=!1),F=(V?x==="("?x:l:x==="-"||x==="("?"":x)+F,$=(k==="s"?f6[8+IX/3]:"")+$+(V&&x==="("?")":""),A){for(j=-1,H=U.length;++j<H;)if(K=U.charCodeAt(j),48>K||K>57){$=(K===46?i+U.slice(j+1):U.slice(j))+$,U=U.slice(0,j);break}}}S&&!y&&(U=e(U,1/0));var Q=F.length+U.length+$.length,Z=Q<v?new Array(v-Q+1).join(p):"";switch(S&&y&&(U=e(Z+U,Z.length?v-$.length:1/0),Z=""),m){case"<":U=F+U+$+Z;break;case"=":U=F+Z+U+$;break;case"^":U=Z.slice(0,Q=Z.length>>1)+F+U+$+Z.slice(Q);break;default:U=Z+F+U+$;break}return a(U)}return R.toString=function(){return f+""},R}function d(f,p){var m=u((f=sy(f),f.type="f",f)),x=Math.max(-8,Math.min(8,Math.floor(Kg(p)/3)))*3,b=Math.pow(10,-x),y=f6[8+x/3];return function(v){return m(b*v)+y}}return{format:u,formatPrefix:d}}var qw,vO,UX;$ye({thousands:",",grouping:[3],currency:["$",""]});function $ye(t){return qw=Hye(t),vO=qw.format,UX=qw.formatPrefix,qw}function Vye(t){return Math.max(0,-Kg(Math.abs(t)))}function Gye(t,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(Kg(e)/3)))*3-Kg(Math.abs(t)))}function qye(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,Kg(e)-Kg(t))+1}function zX(t,e,n,r){var i=t3(t,e,n),a;switch(r=sy(r??",f"),r.type){case"s":{var o=Math.max(Math.abs(t),Math.abs(e));return r.precision==null&&!isNaN(a=Gye(i,o))&&(r.precision=a),UX(r,o)}case"":case"e":case"g":case"p":case"r":{r.precision==null&&!isNaN(a=qye(i,Math.max(Math.abs(t),Math.abs(e))))&&(r.precision=a-(r.type==="e"));break}case"f":case"%":{r.precision==null&&!isNaN(a=Vye(i))&&(r.precision=a-(r.type==="%")*2);break}}return vO(r)}function Fh(t){var e=t.domain;return t.ticks=function(n){var r=e();return JP(r[0],r[r.length-1],n??10)},t.tickFormat=function(n,r){var i=e();return zX(i[0],i[i.length-1],n??10,r)},t.nice=function(n){n==null&&(n=10);var r=e(),i=0,a=r.length-1,o=r[i],l=r[a],c,u,d=10;for(l<o&&(u=o,o=l,l=u,u=i,i=a,a=u);d-- >0;){if(u=e3(o,l,n),u===c)return r[i]=o,r[a]=l,e(r);if(u>0)o=Math.floor(o/u)*u,l=Math.ceil(l/u)*u;else if(u<0)o=Math.ceil(o*u)/u,l=Math.floor(l*u)/u;else break;c=u}return t},t}function BX(){var t=bO();return t.copy=function(){return Xy(t,BX())},ml.apply(t,arguments),Fh(t)}function HX(t){var e;function n(r){return r==null||isNaN(r=+r)?e:r}return n.invert=n,n.domain=n.range=function(r){return arguments.length?(t=Array.from(r,SS),n):t.slice()},n.unknown=function(r){return arguments.length?(e=r,n):e},n.copy=function(){return HX(t).unknown(e)},t=arguments.length?Array.from(t,SS):[0,1],Fh(n)}function $X(t,e){t=t.slice();var n=0,r=t.length-1,i=t[n],a=t[r],o;return a<i&&(o=n,n=r,r=o,o=i,i=a,a=o),t[n]=e.floor(i),t[r]=e.ceil(a),t}function m6(t){return Math.log(t)}function p6(t){return Math.exp(t)}function Wye(t){return-Math.log(-t)}function Kye(t){return-Math.exp(-t)}function Xye(t){return isFinite(t)?+("1e"+t):t<0?0:t}function Yye(t){return t===10?Xye:t===Math.E?Math.exp:e=>Math.pow(t,e)}function Qye(t){return t===Math.E?Math.log:t===10&&Math.log10||t===2&&Math.log2||(t=Math.log(t),e=>Math.log(e)/t)}function g6(t){return(e,n)=>-t(-e,n)}function wO(t){const e=t(m6,p6),n=e.domain;let r=10,i,a;function o(){return i=Qye(r),a=Yye(r),n()[0]<0?(i=g6(i),a=g6(a),t(Wye,Kye)):t(m6,p6),e}return e.base=function(l){return arguments.length?(r=+l,o()):r},e.domain=function(l){return arguments.length?(n(l),o()):n()},e.ticks=l=>{const c=n();let u=c[0],d=c[c.length-1];const f=d<u;f&&([u,d]=[d,u]);let p=i(u),m=i(d),x,b;const y=l==null?10:+l;let v=[];if(!(r%1)&&m-p<y){if(p=Math.floor(p),m=Math.ceil(m),u>0){for(;p<=m;++p)for(x=1;x<r;++x)if(b=p<0?x/a(-p):x*a(p),!(b<u)){if(b>d)break;v.push(b)}}else for(;p<=m;++p)for(x=r-1;x>=1;--x)if(b=p>0?x/a(-p):x*a(p),!(b<u)){if(b>d)break;v.push(b)}v.length*2<y&&(v=JP(u,d,y))}else v=JP(p,m,Math.min(m-p,y)).map(a);return f?v.reverse():v},e.tickFormat=(l,c)=>{if(l==null&&(l=10),c==null&&(c=r===10?"s":","),typeof c!="function"&&(!(r%1)&&(c=sy(c)).precision==null&&(c.trim=!0),c=vO(c)),l===1/0)return c;const u=Math.max(1,r*l/e.ticks().length);return d=>{let f=d/a(Math.round(i(d)));return f*r<r-.5&&(f*=r),f<=u?c(d):""}},e.nice=()=>n($X(n(),{floor:l=>a(Math.floor(i(l))),ceil:l=>a(Math.ceil(i(l)))})),e}function VX(){const t=wO(zN()).domain([1,10]);return t.copy=()=>Xy(t,VX()).base(t.base()),ml.apply(t,arguments),t}function x6(t){return function(e){return Math.sign(e)*Math.log1p(Math.abs(e/t))}}function b6(t){return function(e){return Math.sign(e)*Math.expm1(Math.abs(e))*t}}function _O(t){var e=1,n=t(x6(e),b6(e));return n.constant=function(r){return arguments.length?t(x6(e=+r),b6(e)):e},Fh(n)}function GX(){var t=_O(zN());return t.copy=function(){return Xy(t,GX()).constant(t.constant())},ml.apply(t,arguments)}function y6(t){return function(e){return e<0?-Math.pow(-e,t):Math.pow(e,t)}}function Zye(t){return t<0?-Math.sqrt(-t):Math.sqrt(t)}function Jye(t){return t<0?-t*t:t*t}function SO(t){var e=t(fs,fs),n=1;function r(){return n===1?t(fs,fs):n===.5?t(Zye,Jye):t(y6(n),y6(1/n))}return e.exponent=function(i){return arguments.length?(n=+i,r()):n},Fh(e)}function MO(){var t=SO(zN());return t.copy=function(){return Xy(t,MO()).exponent(t.exponent())},ml.apply(t,arguments),t}function eve(){return MO.apply(null,arguments).exponent(.5)}function v6(t){return Math.sign(t)*t*t}function tve(t){return Math.sign(t)*Math.sqrt(Math.abs(t))}function qX(){var t=bO(),e=[0,1],n=!1,r;function i(a){var o=tve(t(a));return isNaN(o)?r:n?Math.round(o):o}return i.invert=function(a){return t.invert(v6(a))},i.domain=function(a){return arguments.length?(t.domain(a),i):t.domain()},i.range=function(a){return arguments.length?(t.range((e=Array.from(a,SS)).map(v6)),i):e.slice()},i.rangeRound=function(a){return i.range(a).round(!0)},i.round=function(a){return arguments.length?(n=!!a,i):n},i.clamp=function(a){return arguments.length?(t.clamp(a),i):t.clamp()},i.unknown=function(a){return arguments.length?(r=a,i):r},i.copy=function(){return qX(t.domain(),e).round(n).clamp(t.clamp()).unknown(r)},ml.apply(i,arguments),Fh(i)}function WX(){var t=[],e=[],n=[],r;function i(){var o=0,l=Math.max(1,e.length);for(n=new Array(l-1);++o<l;)n[o-1]=aye(t,o/l);return a}function a(o){return o==null||isNaN(o=+o)?r:e[Wy(n,o)]}return a.invertExtent=function(o){var l=e.indexOf(o);return l<0?[NaN,NaN]:[l>0?n[l-1]:t[0],l<n.length?n[l]:t[t.length-1]]},a.domain=function(o){if(!arguments.length)return t.slice();t=[];for(let l of o)l!=null&&!isNaN(l=+l)&&t.push(l);return t.sort(oh),i()},a.range=function(o){return arguments.length?(e=Array.from(o),i()):e.slice()},a.unknown=function(o){return arguments.length?(r=o,a):r},a.quantiles=function(){return n.slice()},a.copy=function(){return WX().domain(t).range(e).unknown(r)},ml.apply(a,arguments)}function KX(){var t=0,e=1,n=1,r=[.5],i=[0,1],a;function o(c){return c!=null&&c<=c?i[Wy(r,c,0,n)]:a}function l(){var c=-1;for(r=new Array(n);++c<n;)r[c]=((c+1)*e-(c-n)*t)/(n+1);return o}return o.domain=function(c){return arguments.length?([t,e]=c,t=+t,e=+e,l()):[t,e]},o.range=function(c){return arguments.length?(n=(i=Array.from(c)).length-1,l()):i.slice()},o.invertExtent=function(c){var u=i.indexOf(c);return u<0?[NaN,NaN]:u<1?[t,r[0]]:u>=n?[r[n-1],e]:[r[u-1],r[u]]},o.unknown=function(c){return arguments.length&&(a=c),o},o.thresholds=function(){return r.slice()},o.copy=function(){return KX().domain([t,e]).range(i).unknown(a)},ml.apply(Fh(o),arguments)}function XX(){var t=[.5],e=[0,1],n,r=1;function i(a){return a!=null&&a<=a?e[Wy(t,a,0,r)]:n}return i.domain=function(a){return arguments.length?(t=Array.from(a),r=Math.min(t.length,e.length-1),i):t.slice()},i.range=function(a){return arguments.length?(e=Array.from(a),r=Math.min(t.length,e.length-1),i):e.slice()},i.invertExtent=function(a){var o=e.indexOf(a);return[t[o-1],t[o]]},i.unknown=function(a){return arguments.length?(n=a,i):n},i.copy=function(){return XX().domain(t).range(e).unknown(n)},ml.apply(i,arguments)}const gA=new Date,xA=new Date;function ia(t,e,n,r){function i(a){return t(a=arguments.length===0?new Date:new Date(+a)),a}return i.floor=a=>(t(a=new Date(+a)),a),i.ceil=a=>(t(a=new Date(a-1)),e(a,1),t(a),a),i.round=a=>{const o=i(a),l=i.ceil(a);return a-o<l-a?o:l},i.offset=(a,o)=>(e(a=new Date(+a),o==null?1:Math.floor(o)),a),i.range=(a,o,l)=>{const c=[];if(a=i.ceil(a),l=l==null?1:Math.floor(l),!(a<o)||!(l>0))return c;let u;do c.push(u=new Date(+a)),e(a,l),t(a);while(u<a&&a<o);return c},i.filter=a=>ia(o=>{if(o>=o)for(;t(o),!a(o);)o.setTime(o-1)},(o,l)=>{if(o>=o)if(l<0)for(;++l<=0;)for(;e(o,-1),!a(o););else for(;--l>=0;)for(;e(o,1),!a(o););}),n&&(i.count=(a,o)=>(gA.setTime(+a),xA.setTime(+o),t(gA),t(xA),Math.floor(n(gA,xA))),i.every=a=>(a=Math.floor(a),!isFinite(a)||!(a>0)?null:a>1?i.filter(r?o=>r(o)%a===0:o=>i.count(0,o)%a===0):i)),i}const NS=ia(()=>{},(t,e)=>{t.setTime(+t+e)},(t,e)=>e-t);NS.every=t=>(t=Math.floor(t),!isFinite(t)||!(t>0)?null:t>1?ia(e=>{e.setTime(Math.floor(e/t)*t)},(e,n)=>{e.setTime(+e+n*t)},(e,n)=>(n-e)/t):NS);NS.range;const bu=1e3,Jo=bu*60,yu=Jo*60,Iu=yu*24,NO=Iu*7,w6=Iu*30,bA=Iu*365,Df=ia(t=>{t.setTime(t-t.getMilliseconds())},(t,e)=>{t.setTime(+t+e*bu)},(t,e)=>(e-t)/bu,t=>t.getUTCSeconds());Df.range;const kO=ia(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*bu)},(t,e)=>{t.setTime(+t+e*Jo)},(t,e)=>(e-t)/Jo,t=>t.getMinutes());kO.range;const EO=ia(t=>{t.setUTCSeconds(0,0)},(t,e)=>{t.setTime(+t+e*Jo)},(t,e)=>(e-t)/Jo,t=>t.getUTCMinutes());EO.range;const TO=ia(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*bu-t.getMinutes()*Jo)},(t,e)=>{t.setTime(+t+e*yu)},(t,e)=>(e-t)/yu,t=>t.getHours());TO.range;const AO=ia(t=>{t.setUTCMinutes(0,0,0)},(t,e)=>{t.setTime(+t+e*yu)},(t,e)=>(e-t)/yu,t=>t.getUTCHours());AO.range;const Yy=ia(t=>t.setHours(0,0,0,0),(t,e)=>t.setDate(t.getDate()+e),(t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*Jo)/Iu,t=>t.getDate()-1);Yy.range;const BN=ia(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/Iu,t=>t.getUTCDate()-1);BN.range;const YX=ia(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/Iu,t=>Math.floor(t/Iu));YX.range;function Tm(t){return ia(e=>{e.setDate(e.getDate()-(e.getDay()+7-t)%7),e.setHours(0,0,0,0)},(e,n)=>{e.setDate(e.getDate()+n*7)},(e,n)=>(n-e-(n.getTimezoneOffset()-e.getTimezoneOffset())*Jo)/NO)}const HN=Tm(0),kS=Tm(1),nve=Tm(2),rve=Tm(3),Xg=Tm(4),ive=Tm(5),ave=Tm(6);HN.range;kS.range;nve.range;rve.range;Xg.range;ive.range;ave.range;function Am(t){return ia(e=>{e.setUTCDate(e.getUTCDate()-(e.getUTCDay()+7-t)%7),e.setUTCHours(0,0,0,0)},(e,n)=>{e.setUTCDate(e.getUTCDate()+n*7)},(e,n)=>(n-e)/NO)}const $N=Am(0),ES=Am(1),sve=Am(2),ove=Am(3),Yg=Am(4),lve=Am(5),cve=Am(6);$N.range;ES.range;sve.range;ove.range;Yg.range;lve.range;cve.range;const CO=ia(t=>{t.setDate(1),t.setHours(0,0,0,0)},(t,e)=>{t.setMonth(t.getMonth()+e)},(t,e)=>e.getMonth()-t.getMonth()+(e.getFullYear()-t.getFullYear())*12,t=>t.getMonth());CO.range;const jO=ia(t=>{t.setUTCDate(1),t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCMonth(t.getUTCMonth()+e)},(t,e)=>e.getUTCMonth()-t.getUTCMonth()+(e.getUTCFullYear()-t.getUTCFullYear())*12,t=>t.getUTCMonth());jO.range;const Uu=ia(t=>{t.setMonth(0,1),t.setHours(0,0,0,0)},(t,e)=>{t.setFullYear(t.getFullYear()+e)},(t,e)=>e.getFullYear()-t.getFullYear(),t=>t.getFullYear());Uu.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:ia(e=>{e.setFullYear(Math.floor(e.getFullYear()/t)*t),e.setMonth(0,1),e.setHours(0,0,0,0)},(e,n)=>{e.setFullYear(e.getFullYear()+n*t)});Uu.range;const zu=ia(t=>{t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCFullYear(t.getUTCFullYear()+e)},(t,e)=>e.getUTCFullYear()-t.getUTCFullYear(),t=>t.getUTCFullYear());zu.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:ia(e=>{e.setUTCFullYear(Math.floor(e.getUTCFullYear()/t)*t),e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)},(e,n)=>{e.setUTCFullYear(e.getUTCFullYear()+n*t)});zu.range;function QX(t,e,n,r,i,a){const o=[[Df,1,bu],[Df,5,5*bu],[Df,15,15*bu],[Df,30,30*bu],[a,1,Jo],[a,5,5*Jo],[a,15,15*Jo],[a,30,30*Jo],[i,1,yu],[i,3,3*yu],[i,6,6*yu],[i,12,12*yu],[r,1,Iu],[r,2,2*Iu],[n,1,NO],[e,1,w6],[e,3,3*w6],[t,1,bA]];function l(u,d,f){const p=d<u;p&&([u,d]=[d,u]);const m=f&&typeof f.range=="function"?f:c(u,d,f),x=m?m.range(u,+d+1):[];return p?x.reverse():x}function c(u,d,f){const p=Math.abs(d-u)/f,m=hO(([,,y])=>y).right(o,p);if(m===o.length)return t.every(t3(u/bA,d/bA,f));if(m===0)return NS.every(Math.max(t3(u,d,f),1));const[x,b]=o[p/o[m-1][2]<o[m][2]/p?m-1:m];return x.every(b)}return[l,c]}const[uve,dve]=QX(zu,jO,$N,YX,AO,EO),[hve,fve]=QX(Uu,CO,HN,Yy,TO,kO);function yA(t){if(0<=t.y&&t.y<100){var e=new Date(-1,t.m,t.d,t.H,t.M,t.S,t.L);return e.setFullYear(t.y),e}return new Date(t.y,t.m,t.d,t.H,t.M,t.S,t.L)}function vA(t){if(0<=t.y&&t.y<100){var e=new Date(Date.UTC(-1,t.m,t.d,t.H,t.M,t.S,t.L));return e.setUTCFullYear(t.y),e}return new Date(Date.UTC(t.y,t.m,t.d,t.H,t.M,t.S,t.L))}function Ob(t,e,n){return{y:t,m:e,d:n,H:0,M:0,S:0,L:0}}function mve(t){var e=t.dateTime,n=t.date,r=t.time,i=t.periods,a=t.days,o=t.shortDays,l=t.months,c=t.shortMonths,u=Lb(i),d=Fb(i),f=Lb(a),p=Fb(a),m=Lb(o),x=Fb(o),b=Lb(l),y=Fb(l),v=Lb(c),S=Fb(c),N={a:V,A:Q,b:Z,B:ae,c:null,d:E6,e:E6,f:Fve,g:Wve,G:Xve,H:Rve,I:Ove,j:Lve,L:ZX,m:Ive,M:Uve,p:B,q:X,Q:C6,s:j6,S:zve,u:Bve,U:Hve,V:$ve,w:Vve,W:Gve,x:null,X:null,y:qve,Y:Kve,Z:Yve,"%":A6},T={a:ne,A:se,b:be,B:xe,c:null,d:T6,e:T6,f:ewe,g:uwe,G:hwe,H:Qve,I:Zve,j:Jve,L:eY,m:twe,M:nwe,p:de,q:Pe,Q:C6,s:j6,S:rwe,u:iwe,U:awe,V:swe,w:owe,W:lwe,x:null,X:null,y:cwe,Y:dwe,Z:fwe,"%":A6},k={a:R,A:U,b:F,B:$,c:j,d:N6,e:N6,f:Cve,g:M6,G:S6,H:k6,I:k6,j:kve,L:Ave,m:Nve,M:Eve,p:A,q:Mve,Q:Pve,s:Dve,S:Tve,u:yve,U:vve,V:wve,w:bve,W:_ve,x:H,X:K,y:M6,Y:S6,Z:Sve,"%":jve};N.x=C(n,N),N.X=C(r,N),N.c=C(e,N),T.x=C(n,T),T.X=C(r,T),T.c=C(e,T);function C(ie,Ne){return function(Oe){var ge=[],Ke=-1,G=0,Y=ie.length,ce,q,te;for(Oe instanceof Date||(Oe=new Date(+Oe));++Ke<Y;)ie.charCodeAt(Ke)===37&&(ge.push(ie.slice(G,Ke)),(q=_6[ce=ie.charAt(++Ke)])!=null?ce=ie.charAt(++Ke):q=ce==="e"?" ":"0",(te=Ne[ce])&&(ce=te(Oe,q)),ge.push(ce),G=Ke+1);return ge.push(ie.slice(G,Ke)),ge.join("")}}function E(ie,Ne){return function(Oe){var ge=Ob(1900,void 0,1),Ke=D(ge,ie,Oe+="",0),G,Y;if(Ke!=Oe.length)return null;if("Q"in ge)return new Date(ge.Q);if("s"in ge)return new Date(ge.s*1e3+("L"in ge?ge.L:0));if(Ne&&!("Z"in ge)&&(ge.Z=0),"p"in ge&&(ge.H=ge.H%12+ge.p*12),ge.m===void 0&&(ge.m="q"in ge?ge.q:0),"V"in ge){if(ge.V<1||ge.V>53)return null;"w"in ge||(ge.w=1),"Z"in ge?(G=vA(Ob(ge.y,0,1)),Y=G.getUTCDay(),G=Y>4||Y===0?ES.ceil(G):ES(G),G=BN.offset(G,(ge.V-1)*7),ge.y=G.getUTCFullYear(),ge.m=G.getUTCMonth(),ge.d=G.getUTCDate()+(ge.w+6)%7):(G=yA(Ob(ge.y,0,1)),Y=G.getDay(),G=Y>4||Y===0?kS.ceil(G):kS(G),G=Yy.offset(G,(ge.V-1)*7),ge.y=G.getFullYear(),ge.m=G.getMonth(),ge.d=G.getDate()+(ge.w+6)%7)}else("W"in ge||"U"in ge)&&("w"in ge||(ge.w="u"in ge?ge.u%7:"W"in ge?1:0),Y="Z"in ge?vA(Ob(ge.y,0,1)).getUTCDay():yA(Ob(ge.y,0,1)).getDay(),ge.m=0,ge.d="W"in ge?(ge.w+6)%7+ge.W*7-(Y+5)%7:ge.w+ge.U*7-(Y+6)%7);return"Z"in ge?(ge.H+=ge.Z/100|0,ge.M+=ge.Z%100,vA(ge)):yA(ge)}}function D(ie,Ne,Oe,ge){for(var Ke=0,G=Ne.length,Y=Oe.length,ce,q;Ke<G;){if(ge>=Y)return-1;if(ce=Ne.charCodeAt(Ke++),ce===37){if(ce=Ne.charAt(Ke++),q=k[ce in _6?Ne.charAt(Ke++):ce],!q||(ge=q(ie,Oe,ge))<0)return-1}else if(ce!=Oe.charCodeAt(ge++))return-1}return ge}function A(ie,Ne,Oe){var ge=u.exec(Ne.slice(Oe));return ge?(ie.p=d.get(ge[0].toLowerCase()),Oe+ge[0].length):-1}function R(ie,Ne,Oe){var ge=m.exec(Ne.slice(Oe));return ge?(ie.w=x.get(ge[0].toLowerCase()),Oe+ge[0].length):-1}function U(ie,Ne,Oe){var ge=f.exec(Ne.slice(Oe));return ge?(ie.w=p.get(ge[0].toLowerCase()),Oe+ge[0].length):-1}function F(ie,Ne,Oe){var ge=v.exec(Ne.slice(Oe));return ge?(ie.m=S.get(ge[0].toLowerCase()),Oe+ge[0].length):-1}function $(ie,Ne,Oe){var ge=b.exec(Ne.slice(Oe));return ge?(ie.m=y.get(ge[0].toLowerCase()),Oe+ge[0].length):-1}function j(ie,Ne,Oe){return D(ie,e,Ne,Oe)}function H(ie,Ne,Oe){return D(ie,n,Ne,Oe)}function K(ie,Ne,Oe){return D(ie,r,Ne,Oe)}function V(ie){return o[ie.getDay()]}function Q(ie){return a[ie.getDay()]}function Z(ie){return c[ie.getMonth()]}function ae(ie){return l[ie.getMonth()]}function B(ie){return i[+(ie.getHours()>=12)]}function X(ie){return 1+~~(ie.getMonth()/3)}function ne(ie){return o[ie.getUTCDay()]}function se(ie){return a[ie.getUTCDay()]}function be(ie){return c[ie.getUTCMonth()]}function xe(ie){return l[ie.getUTCMonth()]}function de(ie){return i[+(ie.getUTCHours()>=12)]}function Pe(ie){return 1+~~(ie.getUTCMonth()/3)}return{format:function(ie){var Ne=C(ie+="",N);return Ne.toString=function(){return ie},Ne},parse:function(ie){var Ne=E(ie+="",!1);return Ne.toString=function(){return ie},Ne},utcFormat:function(ie){var Ne=C(ie+="",T);return Ne.toString=function(){return ie},Ne},utcParse:function(ie){var Ne=E(ie+="",!0);return Ne.toString=function(){return ie},Ne}}}var _6={"-":"",_:" ",0:"0"},Sa=/^\s*\d+/,pve=/^%/,gve=/[\\^$*+?|[\]().{}]/g;function lr(t,e,n){var r=t<0?"-":"",i=(r?-t:t)+"",a=i.length;return r+(a<n?new Array(n-a+1).join(e)+i:i)}function xve(t){return t.replace(gve,"\\$&")}function Lb(t){return new RegExp("^(?:"+t.map(xve).join("|")+")","i")}function Fb(t){return new Map(t.map((e,n)=>[e.toLowerCase(),n]))}function bve(t,e,n){var r=Sa.exec(e.slice(n,n+1));return r?(t.w=+r[0],n+r[0].length):-1}function yve(t,e,n){var r=Sa.exec(e.slice(n,n+1));return r?(t.u=+r[0],n+r[0].length):-1}function vve(t,e,n){var r=Sa.exec(e.slice(n,n+2));return r?(t.U=+r[0],n+r[0].length):-1}function wve(t,e,n){var r=Sa.exec(e.slice(n,n+2));return r?(t.V=+r[0],n+r[0].length):-1}function _ve(t,e,n){var r=Sa.exec(e.slice(n,n+2));return r?(t.W=+r[0],n+r[0].length):-1}function S6(t,e,n){var r=Sa.exec(e.slice(n,n+4));return r?(t.y=+r[0],n+r[0].length):-1}function M6(t,e,n){var r=Sa.exec(e.slice(n,n+2));return r?(t.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function Sve(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 Mve(t,e,n){var r=Sa.exec(e.slice(n,n+1));return r?(t.q=r[0]*3-3,n+r[0].length):-1}function Nve(t,e,n){var r=Sa.exec(e.slice(n,n+2));return r?(t.m=r[0]-1,n+r[0].length):-1}function N6(t,e,n){var r=Sa.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1}function kve(t,e,n){var r=Sa.exec(e.slice(n,n+3));return r?(t.m=0,t.d=+r[0],n+r[0].length):-1}function k6(t,e,n){var r=Sa.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1}function Eve(t,e,n){var r=Sa.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1}function Tve(t,e,n){var r=Sa.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1}function Ave(t,e,n){var r=Sa.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1}function Cve(t,e,n){var r=Sa.exec(e.slice(n,n+6));return r?(t.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function jve(t,e,n){var r=pve.exec(e.slice(n,n+1));return r?n+r[0].length:-1}function Pve(t,e,n){var r=Sa.exec(e.slice(n));return r?(t.Q=+r[0],n+r[0].length):-1}function Dve(t,e,n){var r=Sa.exec(e.slice(n));return r?(t.s=+r[0],n+r[0].length):-1}function E6(t,e){return lr(t.getDate(),e,2)}function Rve(t,e){return lr(t.getHours(),e,2)}function Ove(t,e){return lr(t.getHours()%12||12,e,2)}function Lve(t,e){return lr(1+Yy.count(Uu(t),t),e,3)}function ZX(t,e){return lr(t.getMilliseconds(),e,3)}function Fve(t,e){return ZX(t,e)+"000"}function Ive(t,e){return lr(t.getMonth()+1,e,2)}function Uve(t,e){return lr(t.getMinutes(),e,2)}function zve(t,e){return lr(t.getSeconds(),e,2)}function Bve(t){var e=t.getDay();return e===0?7:e}function Hve(t,e){return lr(HN.count(Uu(t)-1,t),e,2)}function JX(t){var e=t.getDay();return e>=4||e===0?Xg(t):Xg.ceil(t)}function $ve(t,e){return t=JX(t),lr(Xg.count(Uu(t),t)+(Uu(t).getDay()===4),e,2)}function Vve(t){return t.getDay()}function Gve(t,e){return lr(kS.count(Uu(t)-1,t),e,2)}function qve(t,e){return lr(t.getFullYear()%100,e,2)}function Wve(t,e){return t=JX(t),lr(t.getFullYear()%100,e,2)}function Kve(t,e){return lr(t.getFullYear()%1e4,e,4)}function Xve(t,e){var n=t.getDay();return t=n>=4||n===0?Xg(t):Xg.ceil(t),lr(t.getFullYear()%1e4,e,4)}function Yve(t){var e=t.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+lr(e/60|0,"0",2)+lr(e%60,"0",2)}function T6(t,e){return lr(t.getUTCDate(),e,2)}function Qve(t,e){return lr(t.getUTCHours(),e,2)}function Zve(t,e){return lr(t.getUTCHours()%12||12,e,2)}function Jve(t,e){return lr(1+BN.count(zu(t),t),e,3)}function eY(t,e){return lr(t.getUTCMilliseconds(),e,3)}function ewe(t,e){return eY(t,e)+"000"}function twe(t,e){return lr(t.getUTCMonth()+1,e,2)}function nwe(t,e){return lr(t.getUTCMinutes(),e,2)}function rwe(t,e){return lr(t.getUTCSeconds(),e,2)}function iwe(t){var e=t.getUTCDay();return e===0?7:e}function awe(t,e){return lr($N.count(zu(t)-1,t),e,2)}function tY(t){var e=t.getUTCDay();return e>=4||e===0?Yg(t):Yg.ceil(t)}function swe(t,e){return t=tY(t),lr(Yg.count(zu(t),t)+(zu(t).getUTCDay()===4),e,2)}function owe(t){return t.getUTCDay()}function lwe(t,e){return lr(ES.count(zu(t)-1,t),e,2)}function cwe(t,e){return lr(t.getUTCFullYear()%100,e,2)}function uwe(t,e){return t=tY(t),lr(t.getUTCFullYear()%100,e,2)}function dwe(t,e){return lr(t.getUTCFullYear()%1e4,e,4)}function hwe(t,e){var n=t.getUTCDay();return t=n>=4||n===0?Yg(t):Yg.ceil(t),lr(t.getUTCFullYear()%1e4,e,4)}function fwe(){return"+0000"}function A6(){return"%"}function C6(t){return+t}function j6(t){return Math.floor(+t/1e3)}var xp,nY,rY;mwe({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 mwe(t){return xp=mve(t),nY=xp.format,xp.parse,rY=xp.utcFormat,xp.utcParse,xp}function pwe(t){return new Date(t)}function gwe(t){return t instanceof Date?+t:+new Date(+t)}function PO(t,e,n,r,i,a,o,l,c,u){var d=bO(),f=d.invert,p=d.domain,m=u(".%L"),x=u(":%S"),b=u("%I:%M"),y=u("%I %p"),v=u("%a %d"),S=u("%b %d"),N=u("%B"),T=u("%Y");function k(C){return(c(C)<C?m:l(C)<C?x:o(C)<C?b:a(C)<C?y:r(C)<C?i(C)<C?v:S:n(C)<C?N:T)(C)}return d.invert=function(C){return new Date(f(C))},d.domain=function(C){return arguments.length?p(Array.from(C,gwe)):p().map(pwe)},d.ticks=function(C){var E=p();return t(E[0],E[E.length-1],C??10)},d.tickFormat=function(C,E){return E==null?k:u(E)},d.nice=function(C){var E=p();return(!C||typeof C.range!="function")&&(C=e(E[0],E[E.length-1],C??10)),C?p($X(E,C)):d},d.copy=function(){return Xy(d,PO(t,e,n,r,i,a,o,l,c,u))},d}function xwe(){return ml.apply(PO(hve,fve,Uu,CO,HN,Yy,TO,kO,Df,nY).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)}function bwe(){return ml.apply(PO(uve,dve,zu,jO,$N,BN,AO,EO,Df,rY).domain([Date.UTC(2e3,0,1),Date.UTC(2e3,0,2)]),arguments)}function VN(){var t=0,e=1,n,r,i,a,o=fs,l=!1,c;function u(f){return f==null||isNaN(f=+f)?c:o(i===0?.5:(f=(a(f)-n)*i,l?Math.max(0,Math.min(1,f)):f))}u.domain=function(f){return arguments.length?([t,e]=f,n=a(t=+t),r=a(e=+e),i=n===r?0:1/(r-n),u):[t,e]},u.clamp=function(f){return arguments.length?(l=!!f,u):l},u.interpolator=function(f){return arguments.length?(o=f,u):o};function d(f){return function(p){var m,x;return arguments.length?([m,x]=p,o=f(m,x),u):[o(0),o(1)]}}return u.range=d(_x),u.rangeRound=d(xO),u.unknown=function(f){return arguments.length?(c=f,u):c},function(f){return a=f,n=f(t),r=f(e),i=n===r?0:1/(r-n),u}}function Ih(t,e){return e.domain(t.domain()).interpolator(t.interpolator()).clamp(t.clamp()).unknown(t.unknown())}function iY(){var t=Fh(VN()(fs));return t.copy=function(){return Ih(t,iY())},Ku.apply(t,arguments)}function aY(){var t=wO(VN()).domain([1,10]);return t.copy=function(){return Ih(t,aY()).base(t.base())},Ku.apply(t,arguments)}function sY(){var t=_O(VN());return t.copy=function(){return Ih(t,sY()).constant(t.constant())},Ku.apply(t,arguments)}function DO(){var t=SO(VN());return t.copy=function(){return Ih(t,DO()).exponent(t.exponent())},Ku.apply(t,arguments)}function ywe(){return DO.apply(null,arguments).exponent(.5)}function oY(){var t=[],e=fs;function n(r){if(r!=null&&!isNaN(r=+r))return e((Wy(t,r,1)-1)/(t.length-1))}return n.domain=function(r){if(!arguments.length)return t.slice();t=[];for(let i of r)i!=null&&!isNaN(i=+i)&&t.push(i);return t.sort(oh),n},n.interpolator=function(r){return arguments.length?(e=r,n):e},n.range=function(){return t.map((r,i)=>e(i/(t.length-1)))},n.quantiles=function(r){return Array.from({length:r+1},(i,a)=>iye(t,a/r))},n.copy=function(){return oY(e).domain(t)},Ku.apply(n,arguments)}function GN(){var t=0,e=.5,n=1,r=1,i,a,o,l,c,u=fs,d,f=!1,p;function m(b){return isNaN(b=+b)?p:(b=.5+((b=+d(b))-a)*(r*b<r*a?l:c),u(f?Math.max(0,Math.min(1,b)):b))}m.domain=function(b){return arguments.length?([t,e,n]=b,i=d(t=+t),a=d(e=+e),o=d(n=+n),l=i===a?0:.5/(a-i),c=a===o?0:.5/(o-a),r=a<i?-1:1,m):[t,e,n]},m.clamp=function(b){return arguments.length?(f=!!b,m):f},m.interpolator=function(b){return arguments.length?(u=b,m):u};function x(b){return function(y){var v,S,N;return arguments.length?([v,S,N]=y,u=jye(b,[v,S,N]),m):[u(0),u(.5),u(1)]}}return m.range=x(_x),m.rangeRound=x(xO),m.unknown=function(b){return arguments.length?(p=b,m):p},function(b){return d=b,i=b(t),a=b(e),o=b(n),l=i===a?0:.5/(a-i),c=a===o?0:.5/(o-a),r=a<i?-1:1,m}}function lY(){var t=Fh(GN()(fs));return t.copy=function(){return Ih(t,lY())},Ku.apply(t,arguments)}function cY(){var t=wO(GN()).domain([.1,1,10]);return t.copy=function(){return Ih(t,cY()).base(t.base())},Ku.apply(t,arguments)}function uY(){var t=_O(GN());return t.copy=function(){return Ih(t,uY()).constant(t.constant())},Ku.apply(t,arguments)}function RO(){var t=SO(GN());return t.copy=function(){return Ih(t,RO()).exponent(t.exponent())},Ku.apply(t,arguments)}function vwe(){return RO.apply(null,arguments).exponent(.5)}const a0=Object.freeze(Object.defineProperty({__proto__:null,scaleBand:mO,scaleDiverging:lY,scaleDivergingLog:cY,scaleDivergingPow:RO,scaleDivergingSqrt:vwe,scaleDivergingSymlog:uY,scaleIdentity:HX,scaleImplicit:n3,scaleLinear:BX,scaleLog:VX,scaleOrdinal:fO,scalePoint:oye,scalePow:MO,scaleQuantile:WX,scaleQuantize:KX,scaleRadial:qX,scaleSequential:iY,scaleSequentialLog:aY,scaleSequentialPow:DO,scaleSequentialQuantile:oY,scaleSequentialSqrt:ywe,scaleSequentialSymlog:sY,scaleSqrt:eve,scaleSymlog:GX,scaleThreshold:XX,scaleTime:xwe,scaleUtc:bwe,tickFormat:zX},Symbol.toStringTag,{value:"Module"}));var Uh=t=>t.chartData,OO=nt([Uh],t=>{var e=t.chartData!=null?t.chartData.length-1:0;return{chartData:t.chartData,computedData:t.computedData,dataEndIndex:e,dataStartIndex:0}}),Qy=(t,e,n,r)=>r?OO(t):Uh(t);function _h(t){if(Array.isArray(t)&&t.length===2){var[e,n]=t;if(vr(e)&&vr(n))return!0}return!1}function P6(t,e,n){return n?t:[Math.min(t[0],e[0]),Math.max(t[1],e[1])]}function dY(t,e){if(e&&typeof t!="function"&&Array.isArray(t)&&t.length===2){var[n,r]=t,i,a;if(vr(n))i=n;else if(typeof n=="function")return;if(vr(r))a=r;else if(typeof r=="function")return;var o=[i,a];if(_h(o))return o}}function wwe(t,e,n){if(!(!n&&e==null)){if(typeof t=="function"&&e!=null)try{var r=t(e,n);if(_h(r))return P6(r,e,n)}catch{}if(Array.isArray(t)&&t.length===2){var[i,a]=t,o,l;if(i==="auto")e!=null&&(o=Math.min(...e));else if(zt(i))o=i;else if(typeof i=="function")try{e!=null&&(o=i(e?.[0]))}catch{}else if(typeof i=="string"&&s8.test(i)){var c=s8.exec(i);if(c==null||e==null)o=void 0;else{var u=+c[1];o=e[0]-u}}else o=e?.[0];if(a==="auto")e!=null&&(l=Math.max(...e));else if(zt(a))l=a;else if(typeof a=="function")try{e!=null&&(l=a(e?.[1]))}catch{}else if(typeof a=="string"&&o8.test(a)){var d=o8.exec(a);if(d==null||e==null)l=void 0;else{var f=+d[1];l=e[1]+f}}else l=e?.[1];var p=[o,l];if(_h(p))return e==null?p:P6(p,e,n)}}}var Sx=1e9,_we={precision:20,rounding:4,toExpNeg:-7,toExpPos:21,LN10:"2.302585092994045684017991454684364207601101488628772976033327900967572609677352480235997205089598298341967784042286"},FO,ti=!0,dl="[DecimalError] ",Vf=dl+"Invalid argument: ",LO=dl+"Exponent out of range: ",Mx=Math.floor,_f=Math.pow,Swe=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,co,pa=1e7,Wr=7,hY=9007199254740991,TS=Mx(hY/Wr),$t={};$t.absoluteValue=$t.abs=function(){var t=new this.constructor(this);return t.s&&(t.s=1),t};$t.comparedTo=$t.cmp=function(t){var e,n,r,i,a=this;if(t=new a.constructor(t),a.s!==t.s)return a.s||-t.s;if(a.e!==t.e)return a.e>t.e^a.s<0?1:-1;for(r=a.d.length,i=t.d.length,e=0,n=r<i?r:i;e<n;++e)if(a.d[e]!==t.d[e])return a.d[e]>t.d[e]^a.s<0?1:-1;return r===i?0:r>i^a.s<0?1:-1};$t.decimalPlaces=$t.dp=function(){var t=this,e=t.d.length-1,n=(e-t.e)*Wr;if(e=t.d[e],e)for(;e%10==0;e/=10)n--;return n<0?0:n};$t.dividedBy=$t.div=function(t){return ku(this,new this.constructor(t))};$t.dividedToIntegerBy=$t.idiv=function(t){var e=this,n=e.constructor;return Or(ku(e,new n(t),0,1),n.precision)};$t.equals=$t.eq=function(t){return!this.cmp(t)};$t.exponent=function(){return $i(this)};$t.greaterThan=$t.gt=function(t){return this.cmp(t)>0};$t.greaterThanOrEqualTo=$t.gte=function(t){return this.cmp(t)>=0};$t.isInteger=$t.isint=function(){return this.e>this.d.length-2};$t.isNegative=$t.isneg=function(){return this.s<0};$t.isPositive=$t.ispos=function(){return this.s>0};$t.isZero=function(){return this.s===0};$t.lessThan=$t.lt=function(t){return this.cmp(t)<0};$t.lessThanOrEqualTo=$t.lte=function(t){return this.cmp(t)<1};$t.logarithm=$t.log=function(t){var e,n=this,r=n.constructor,i=r.precision,a=i+5;if(t===void 0)t=new r(10);else if(t=new r(t),t.s<1||t.eq(co))throw Error(dl+"NaN");if(n.s<1)throw Error(dl+(n.s?"NaN":"-Infinity"));return n.eq(co)?new r(0):(ti=!1,e=ku(oy(n,a),oy(t,a),a),ti=!0,Or(e,i))};$t.minus=$t.sub=function(t){var e=this;return t=new e.constructor(t),e.s==t.s?pY(e,t):fY(e,(t.s=-t.s,t))};$t.modulo=$t.mod=function(t){var e,n=this,r=n.constructor,i=r.precision;if(t=new r(t),!t.s)throw Error(dl+"NaN");return n.s?(ti=!1,e=ku(n,t,0,1).times(t),ti=!0,n.minus(e)):Or(new r(n),i)};$t.naturalExponential=$t.exp=function(){return mY(this)};$t.naturalLogarithm=$t.ln=function(){return oy(this)};$t.negated=$t.neg=function(){var t=new this.constructor(this);return t.s=-t.s||0,t};$t.plus=$t.add=function(t){var e=this;return t=new e.constructor(t),e.s==t.s?fY(e,t):pY(e,(t.s=-t.s,t))};$t.precision=$t.sd=function(t){var e,n,r,i=this;if(t!==void 0&&t!==!!t&&t!==1&&t!==0)throw Error(Vf+t);if(e=$i(i)+1,r=i.d.length-1,n=r*Wr+1,r=i.d[r],r){for(;r%10==0;r/=10)n--;for(r=i.d[0];r>=10;r/=10)n++}return t&&e>n?e:n};$t.squareRoot=$t.sqrt=function(){var t,e,n,r,i,a,o,l=this,c=l.constructor;if(l.s<1){if(!l.s)return new c(0);throw Error(dl+"NaN")}for(t=$i(l),ti=!1,i=Math.sqrt(+l),i==0||i==1/0?(e=oc(l.d),(e.length+t)%2==0&&(e+="0"),i=Math.sqrt(e),t=Mx((t+1)/2)-(t<0||t%2),i==1/0?e="5e"+t:(e=i.toExponential(),e=e.slice(0,e.indexOf("e")+1)+t),r=new c(e)):r=new c(i.toString()),n=c.precision,i=o=n+3;;)if(a=r,r=a.plus(ku(l,a,o+2)).times(.5),oc(a.d).slice(0,o)===(e=oc(r.d)).slice(0,o)){if(e=e.slice(o-3,o+1),i==o&&e=="4999"){if(Or(a,n+1,0),a.times(a).eq(l)){r=a;break}}else if(e!="9999")break;o+=4}return ti=!0,Or(r,n)};$t.times=$t.mul=function(t){var e,n,r,i,a,o,l,c,u,d=this,f=d.constructor,p=d.d,m=(t=new f(t)).d;if(!d.s||!t.s)return new f(0);for(t.s*=d.s,n=d.e+t.e,c=p.length,u=m.length,c<u&&(a=p,p=m,m=a,o=c,c=u,u=o),a=[],o=c+u,r=o;r--;)a.push(0);for(r=u;--r>=0;){for(e=0,i=c+r;i>r;)l=a[i]+m[r]*p[i-r-1]+e,a[i--]=l%pa|0,e=l/pa|0;a[i]=(a[i]+e)%pa|0}for(;!a[--o];)a.pop();return e?++n:a.shift(),t.d=a,t.e=n,ti?Or(t,f.precision):t};$t.toDecimalPlaces=$t.todp=function(t,e){var n=this,r=n.constructor;return n=new r(n),t===void 0?n:(gc(t,0,Sx),e===void 0?e=r.rounding:gc(e,0,8),Or(n,t+$i(n)+1,e))};$t.toExponential=function(t,e){var n,r=this,i=r.constructor;return t===void 0?n=hm(r,!0):(gc(t,0,Sx),e===void 0?e=i.rounding:gc(e,0,8),r=Or(new i(r),t+1,e),n=hm(r,!0,t+1)),n};$t.toFixed=function(t,e){var n,r,i=this,a=i.constructor;return t===void 0?hm(i):(gc(t,0,Sx),e===void 0?e=a.rounding:gc(e,0,8),r=Or(new a(i),t+$i(i)+1,e),n=hm(r.abs(),!1,t+$i(r)+1),i.isneg()&&!i.isZero()?"-"+n:n)};$t.toInteger=$t.toint=function(){var t=this,e=t.constructor;return Or(new e(t),$i(t)+1,e.rounding)};$t.toNumber=function(){return+this};$t.toPower=$t.pow=function(t){var e,n,r,i,a,o,l=this,c=l.constructor,u=12,d=+(t=new c(t));if(!t.s)return new c(co);if(l=new c(l),!l.s){if(t.s<1)throw Error(dl+"Infinity");return l}if(l.eq(co))return l;if(r=c.precision,t.eq(co))return Or(l,r);if(e=t.e,n=t.d.length-1,o=e>=n,a=l.s,o){if((n=d<0?-d:d)<=hY){for(i=new c(co),e=Math.ceil(r/Wr+4),ti=!1;n%2&&(i=i.times(l),R6(i.d,e)),n=Mx(n/2),n!==0;)l=l.times(l),R6(l.d,e);return ti=!0,t.s<0?new c(co).div(i):Or(i,r)}}else if(a<0)throw Error(dl+"NaN");return a=a<0&&t.d[Math.max(e,n)]&1?-1:1,l.s=1,ti=!1,i=t.times(oy(l,r+u)),ti=!0,i=mY(i),i.s=a,i};$t.toPrecision=function(t,e){var n,r,i=this,a=i.constructor;return t===void 0?(n=$i(i),r=hm(i,n<=a.toExpNeg||n>=a.toExpPos)):(gc(t,1,Sx),e===void 0?e=a.rounding:gc(e,0,8),i=Or(new a(i),t,e),n=$i(i),r=hm(i,t<=n||n<=a.toExpNeg,t)),r};$t.toSignificantDigits=$t.tosd=function(t,e){var n=this,r=n.constructor;return t===void 0?(t=r.precision,e=r.rounding):(gc(t,1,Sx),e===void 0?e=r.rounding:gc(e,0,8)),Or(new r(n),t,e)};$t.toString=$t.valueOf=$t.val=$t.toJSON=$t[Symbol.for("nodejs.util.inspect.custom")]=function(){var t=this,e=$i(t),n=t.constructor;return hm(t,e<=n.toExpNeg||e>=n.toExpPos)};function fY(t,e){var n,r,i,a,o,l,c,u,d=t.constructor,f=d.precision;if(!t.s||!e.s)return e.s||(e=new d(t)),ti?Or(e,f):e;if(c=t.d,u=e.d,o=t.e,i=e.e,c=c.slice(),a=o-i,a){for(a<0?(r=c,a=-a,l=u.length):(r=u,i=o,l=c.length),o=Math.ceil(f/Wr),l=o>l?o+1:l+1,a>l&&(a=l,r.length=1),r.reverse();a--;)r.push(0);r.reverse()}for(l=c.length,a=u.length,l-a<0&&(a=l,r=u,u=c,c=r),n=0;a;)n=(c[--a]=c[a]+u[a]+n)/pa|0,c[a]%=pa;for(n&&(c.unshift(n),++i),l=c.length;c[--l]==0;)c.pop();return e.d=c,e.e=i,ti?Or(e,f):e}function gc(t,e,n){if(t!==~~t||t<e||t>n)throw Error(Vf+t)}function oc(t){var e,n,r,i=t.length-1,a="",o=t[0];if(i>0){for(a+=o,e=1;e<i;e++)r=t[e]+"",n=Wr-r.length,n&&(a+=Ud(n)),a+=r;o=t[e],r=o+"",n=Wr-r.length,n&&(a+=Ud(n))}else if(o===0)return"0";for(;o%10===0;)o/=10;return a+o}var ku=(function(){function t(r,i){var a,o=0,l=r.length;for(r=r.slice();l--;)a=r[l]*i+o,r[l]=a%pa|0,o=a/pa|0;return o&&r.unshift(o),r}function e(r,i,a,o){var l,c;if(a!=o)c=a>o?1:-1;else for(l=c=0;l<a;l++)if(r[l]!=i[l]){c=r[l]>i[l]?1:-1;break}return c}function n(r,i,a){for(var o=0;a--;)r[a]-=o,o=r[a]<i[a]?1:0,r[a]=o*pa+r[a]-i[a];for(;!r[0]&&r.length>1;)r.shift()}return function(r,i,a,o){var l,c,u,d,f,p,m,x,b,y,v,S,N,T,k,C,E,D,A=r.constructor,R=r.s==i.s?1:-1,U=r.d,F=i.d;if(!r.s)return new A(r);if(!i.s)throw Error(dl+"Division by zero");for(c=r.e-i.e,E=F.length,k=U.length,m=new A(R),x=m.d=[],u=0;F[u]==(U[u]||0);)++u;if(F[u]>(U[u]||0)&&--c,a==null?S=a=A.precision:o?S=a+($i(r)-$i(i))+1:S=a,S<0)return new A(0);if(S=S/Wr+2|0,u=0,E==1)for(d=0,F=F[0],S++;(u<k||d)&&S--;u++)N=d*pa+(U[u]||0),x[u]=N/F|0,d=N%F|0;else{for(d=pa/(F[0]+1)|0,d>1&&(F=t(F,d),U=t(U,d),E=F.length,k=U.length),T=E,b=U.slice(0,E),y=b.length;y<E;)b[y++]=0;D=F.slice(),D.unshift(0),C=F[0],F[1]>=pa/2&&++C;do d=0,l=e(F,b,E,y),l<0?(v=b[0],E!=y&&(v=v*pa+(b[1]||0)),d=v/C|0,d>1?(d>=pa&&(d=pa-1),f=t(F,d),p=f.length,y=b.length,l=e(f,b,p,y),l==1&&(d--,n(f,E<p?D:F,p))):(d==0&&(l=d=1),f=F.slice()),p=f.length,p<y&&f.unshift(0),n(b,f,y),l==-1&&(y=b.length,l=e(F,b,E,y),l<1&&(d++,n(b,E<y?D:F,y))),y=b.length):l===0&&(d++,b=[0]),x[u++]=d,l&&b[0]?b[y++]=U[T]||0:(b=[U[T]],y=1);while((T++<k||b[0]!==void 0)&&S--)}return x[0]||x.shift(),m.e=c,Or(m,o?a+$i(m)+1:a)}})();function mY(t,e){var n,r,i,a,o,l,c=0,u=0,d=t.constructor,f=d.precision;if($i(t)>16)throw Error(LO+$i(t));if(!t.s)return new d(co);for(ti=!1,l=f,o=new d(.03125);t.abs().gte(.1);)t=t.times(o),u+=5;for(r=Math.log(_f(2,u))/Math.LN10*2+5|0,l+=r,n=i=a=new d(co),d.precision=l;;){if(i=Or(i.times(t),l),n=n.times(++c),o=a.plus(ku(i,n,l)),oc(o.d).slice(0,l)===oc(a.d).slice(0,l)){for(;u--;)a=Or(a.times(a),l);return d.precision=f,e==null?(ti=!0,Or(a,f)):a}a=o}}function $i(t){for(var e=t.e*Wr,n=t.d[0];n>=10;n/=10)e++;return e}function wA(t,e,n){if(e>t.LN10.sd())throw ti=!0,n&&(t.precision=n),Error(dl+"LN10 precision limit exceeded");return Or(new t(t.LN10),e)}function Ud(t){for(var e="";t--;)e+="0";return e}function oy(t,e){var n,r,i,a,o,l,c,u,d,f=1,p=10,m=t,x=m.d,b=m.constructor,y=b.precision;if(m.s<1)throw Error(dl+(m.s?"NaN":"-Infinity"));if(m.eq(co))return new b(0);if(e==null?(ti=!1,u=y):u=e,m.eq(10))return e==null&&(ti=!0),wA(b,u);if(u+=p,b.precision=u,n=oc(x),r=n.charAt(0),a=$i(m),Math.abs(a)<15e14){for(;r<7&&r!=1||r==1&&n.charAt(1)>3;)m=m.times(t),n=oc(m.d),r=n.charAt(0),f++;a=$i(m),r>1?(m=new b("0."+n),a++):m=new b(r+"."+n.slice(1))}else return c=wA(b,u+2,y).times(a+""),m=oy(new b(r+"."+n.slice(1)),u-p).plus(c),b.precision=y,e==null?(ti=!0,Or(m,y)):m;for(l=o=m=ku(m.minus(co),m.plus(co),u),d=Or(m.times(m),u),i=3;;){if(o=Or(o.times(d),u),c=l.plus(ku(o,new b(i),u)),oc(c.d).slice(0,u)===oc(l.d).slice(0,u))return l=l.times(2),a!==0&&(l=l.plus(wA(b,u+2,y).times(a+""))),l=ku(l,new b(f),u),b.precision=y,e==null?(ti=!0,Or(l,y)):l;l=c,i+=2}}function D6(t,e){var n,r,i;for((n=e.indexOf("."))>-1&&(e=e.replace(".","")),(r=e.search(/e/i))>0?(n<0&&(n=r),n+=+e.slice(r+1),e=e.substring(0,r)):n<0&&(n=e.length),r=0;e.charCodeAt(r)===48;)++r;for(i=e.length;e.charCodeAt(i-1)===48;)--i;if(e=e.slice(r,i),e){if(i-=r,n=n-r-1,t.e=Mx(n/Wr),t.d=[],r=(n+1)%Wr,n<0&&(r+=Wr),r<i){for(r&&t.d.push(+e.slice(0,r)),i-=Wr;r<i;)t.d.push(+e.slice(r,r+=Wr));e=e.slice(r),r=Wr-e.length}else r-=i;for(;r--;)e+="0";if(t.d.push(+e),ti&&(t.e>TS||t.e<-TS))throw Error(LO+n)}else t.s=0,t.e=0,t.d=[0];return t}function Or(t,e,n){var r,i,a,o,l,c,u,d,f=t.d;for(o=1,a=f[0];a>=10;a/=10)o++;if(r=e-o,r<0)r+=Wr,i=e,u=f[d=0];else{if(d=Math.ceil((r+1)/Wr),a=f.length,d>=a)return t;for(u=a=f[d],o=1;a>=10;a/=10)o++;r%=Wr,i=r-Wr+o}if(n!==void 0&&(a=_f(10,o-i-1),l=u/a%10|0,c=e<0||f[d+1]!==void 0||u%a,c=n<4?(l||c)&&(n==0||n==(t.s<0?3:2)):l>5||l==5&&(n==4||c||n==6&&(r>0?i>0?u/_f(10,o-i):0:f[d-1])%10&1||n==(t.s<0?8:7))),e<1||!f[0])return c?(a=$i(t),f.length=1,e=e-a-1,f[0]=_f(10,(Wr-e%Wr)%Wr),t.e=Mx(-e/Wr)||0):(f.length=1,f[0]=t.e=t.s=0),t;if(r==0?(f.length=d,a=1,d--):(f.length=d+1,a=_f(10,Wr-r),f[d]=i>0?(u/_f(10,o-i)%_f(10,i)|0)*a:0),c)for(;;)if(d==0){(f[0]+=a)==pa&&(f[0]=1,++t.e);break}else{if(f[d]+=a,f[d]!=pa)break;f[d--]=0,a=1}for(r=f.length;f[--r]===0;)f.pop();if(ti&&(t.e>TS||t.e<-TS))throw Error(LO+$i(t));return t}function pY(t,e){var n,r,i,a,o,l,c,u,d,f,p=t.constructor,m=p.precision;if(!t.s||!e.s)return e.s?e.s=-e.s:e=new p(t),ti?Or(e,m):e;if(c=t.d,f=e.d,r=e.e,u=t.e,c=c.slice(),o=u-r,o){for(d=o<0,d?(n=c,o=-o,l=f.length):(n=f,r=u,l=c.length),i=Math.max(Math.ceil(m/Wr),l)+2,o>i&&(o=i,n.length=1),n.reverse(),i=o;i--;)n.push(0);n.reverse()}else{for(i=c.length,l=f.length,d=i<l,d&&(l=i),i=0;i<l;i++)if(c[i]!=f[i]){d=c[i]<f[i];break}o=0}for(d&&(n=c,c=f,f=n,e.s=-e.s),l=c.length,i=f.length-l;i>0;--i)c[l++]=0;for(i=f.length;i>o;){if(c[--i]<f[i]){for(a=i;a&&c[--a]===0;)c[a]=pa-1;--c[a],c[i]+=pa}c[i]-=f[i]}for(;c[--l]===0;)c.pop();for(;c[0]===0;c.shift())--r;return c[0]?(e.d=c,e.e=r,ti?Or(e,m):e):new p(0)}function hm(t,e,n){var r,i=$i(t),a=oc(t.d),o=a.length;return e?(n&&(r=n-o)>0?a=a.charAt(0)+"."+a.slice(1)+Ud(r):o>1&&(a=a.charAt(0)+"."+a.slice(1)),a=a+(i<0?"e":"e+")+i):i<0?(a="0."+Ud(-i-1)+a,n&&(r=n-o)>0&&(a+=Ud(r))):i>=o?(a+=Ud(i+1-o),n&&(r=n-i-1)>0&&(a=a+"."+Ud(r))):((r=i+1)<o&&(a=a.slice(0,r)+"."+a.slice(r)),n&&(r=n-o)>0&&(i+1===o&&(a+="."),a+=Ud(r))),t.s<0?"-"+a:a}function R6(t,e){if(t.length>e)return t.length=e,!0}function gY(t){var e,n,r;function i(a){var o=this;if(!(o instanceof i))return new i(a);if(o.constructor=i,a instanceof i){o.s=a.s,o.e=a.e,o.d=(a=a.d)?a.slice():a;return}if(typeof a=="number"){if(a*0!==0)throw Error(Vf+a);if(a>0)o.s=1;else if(a<0)a=-a,o.s=-1;else{o.s=0,o.e=0,o.d=[0];return}if(a===~~a&&a<1e7){o.e=0,o.d=[a];return}return D6(o,a.toString())}else if(typeof a!="string")throw Error(Vf+a);if(a.charCodeAt(0)===45?(a=a.slice(1),o.s=-1):o.s=1,Swe.test(a))D6(o,a);else throw Error(Vf+a)}if(i.prototype=$t,i.ROUND_UP=0,i.ROUND_DOWN=1,i.ROUND_CEIL=2,i.ROUND_FLOOR=3,i.ROUND_HALF_UP=4,i.ROUND_HALF_DOWN=5,i.ROUND_HALF_EVEN=6,i.ROUND_HALF_CEIL=7,i.ROUND_HALF_FLOOR=8,i.clone=gY,i.config=i.set=Mwe,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 Mwe(t){if(!t||typeof t!="object")throw Error(dl+"Object expected");var e,n,r,i=["precision",1,Sx,"rounding",0,8,"toExpNeg",-1/0,0,"toExpPos",0,1/0];for(e=0;e<i.length;e+=3)if((r=t[n=i[e]])!==void 0)if(Mx(r)===r&&r>=i[e+1]&&r<=i[e+2])this[n]=r;else throw Error(Vf+n+": "+r);if((r=t[n="LN10"])!==void 0)if(r==Math.LN10)this[n]=new this(r);else throw Error(Vf+n+": "+r);return this}var FO=gY(_we);co=new FO(1);const br=FO;var Nwe=t=>t,xY={},bY=t=>t===xY,O6=t=>function e(){return arguments.length===0||arguments.length===1&&bY(arguments.length<=0?void 0:arguments[0])?e:t(...arguments)},yY=(t,e)=>t===1?e:O6(function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];var a=r.filter(o=>o!==xY).length;return a>=t?e(...r):yY(t-a,O6(function(){for(var o=arguments.length,l=new Array(o),c=0;c<o;c++)l[c]=arguments[c];var u=r.map(d=>bY(d)?l.shift():d);return e(...u,...l)}))}),kwe=t=>yY(t.length,t),s3=(t,e)=>{for(var n=[],r=t;r<e;++r)n[r-t]=r;return n},Ewe=kwe((t,e)=>Array.isArray(e)?e.map(t):Object.keys(e).map(n=>e[n]).map(t)),Twe=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];if(!n.length)return Nwe;var i=n.reverse(),a=i[0],o=i.slice(1);return function(){return o.reduce((l,c)=>c(l),a(...arguments))}},o3=t=>Array.isArray(t)?t.reverse():t.split("").reverse().join("");function vY(t){var e;return t===0?e=1:e=Math.floor(new br(t).abs().log(10).toNumber())+1,e}function wY(t,e,n){for(var r=new br(t),i=0,a=[];r.lt(e)&&i<1e5;)a.push(r.toNumber()),r=r.add(n),i++;return a}var _Y=t=>{var[e,n]=t,[r,i]=[e,n];return e>n&&([r,i]=[n,e]),[r,i]},SY=(t,e,n)=>{if(t.lte(0))return new br(0);var r=vY(t.toNumber()),i=new br(10).pow(r),a=t.div(i),o=r!==1?.05:.1,l=new br(Math.ceil(a.div(o).toNumber())).add(n).mul(o),c=l.mul(i);return e?new br(c.toNumber()):new br(Math.ceil(c.toNumber()))},Awe=(t,e,n)=>{var r=new br(1),i=new br(t);if(!i.isint()&&n){var a=Math.abs(t);a<1?(r=new br(10).pow(vY(t)-1),i=new br(Math.floor(i.div(r).toNumber())).mul(r)):a>1&&(i=new br(Math.floor(t)))}else t===0?i=new br(Math.floor((e-1)/2)):n||(i=new br(Math.floor(t)));var o=Math.floor((e-1)/2),l=Twe(Ewe(c=>i.add(new br(c-o).mul(r)).toNumber()),s3);return l(0,e)},MY=function(e,n,r,i){var a=arguments.length>4&&arguments[4]!==void 0?arguments[4]:0;if(!Number.isFinite((n-e)/(r-1)))return{step:new br(0),tickMin:new br(0),tickMax:new br(0)};var o=SY(new br(n).sub(e).div(r-1),i,a),l;e<=0&&n>=0?l=new br(0):(l=new br(e).add(n).div(2),l=l.sub(new br(l).mod(o)));var c=Math.ceil(l.sub(e).div(o).toNumber()),u=Math.ceil(new br(n).sub(l).div(o).toNumber()),d=c+u+1;return d>r?MY(e,n,r,i,a+1):(d<r&&(u=n>0?u+(r-d):u,c=n>0?c:c+(r-d)),{step:o,tickMin:l.sub(new br(c).mul(o)),tickMax:l.add(new br(u).mul(o))})},Cwe=function(e){var[n,r]=e,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:6,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,o=Math.max(i,2),[l,c]=_Y([n,r]);if(l===-1/0||c===1/0){var u=c===1/0?[l,...s3(0,i-1).map(()=>1/0)]:[...s3(0,i-1).map(()=>-1/0),c];return n>r?o3(u):u}if(l===c)return Awe(l,i,a);var{step:d,tickMin:f,tickMax:p}=MY(l,c,o,a,0),m=wY(f,p.add(new br(.1).mul(d)),d);return n>r?o3(m):m},jwe=function(e,n){var[r,i]=e,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,[o,l]=_Y([r,i]);if(o===-1/0||l===1/0)return[r,i];if(o===l)return[o];var c=Math.max(n,2),u=SY(new br(l).sub(o).div(c-1),a,0),d=[...wY(new br(o),new br(l),u),l];return a===!1&&(d=d.map(f=>Math.round(f))),r>i?o3(d):d},NY=t=>t.rootProps.maxBarSize,Pwe=t=>t.rootProps.barGap,kY=t=>t.rootProps.barCategoryGap,Dwe=t=>t.rootProps.barSize,Zy=t=>t.rootProps.stackOffset,EY=t=>t.rootProps.reverseStackOrder,IO=t=>t.options.chartName,UO=t=>t.rootProps.syncId,TY=t=>t.rootProps.syncMethod,zO=t=>t.options.eventEmitter,Rwe=t=>t.rootProps.baseValue,bi={grid:-100,barBackground:-50,area:100,cursorRectangle:200,bar:300,line:400,axis:500,scatter:600,activeBar:1e3,cursorLine:1100,activeDot:1200,label:2e3},hu={allowDuplicatedCategory:!0,angleAxisId:0,reversed:!1,scale:"auto",tick:!0,type:"category"},so={allowDataOverflow:!1,allowDuplicatedCategory:!0,radiusAxisId:0,scale:"auto",tick:!0,tickCount:5,type:"number"},qN=(t,e)=>{if(!(!t||!e))return t!=null&&t.reversed?[e[1],e[0]]:e},Owe={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:!1,dataKey:void 0,domain:void 0,id:hu.angleAxisId,includeHidden:!1,name:void 0,reversed:hu.reversed,scale:hu.scale,tick:hu.tick,tickCount:void 0,ticks:void 0,type:hu.type,unit:void 0},Lwe={allowDataOverflow:so.allowDataOverflow,allowDecimals:!1,allowDuplicatedCategory:so.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:so.radiusAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:so.scale,tick:so.tick,tickCount:so.tickCount,ticks:void 0,type:so.type,unit:void 0},Fwe={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:hu.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:hu.angleAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:hu.scale,tick:hu.tick,tickCount:void 0,ticks:void 0,type:"number",unit:void 0},Iwe={allowDataOverflow:so.allowDataOverflow,allowDecimals:!1,allowDuplicatedCategory:so.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:so.radiusAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:so.scale,tick:so.tick,tickCount:so.tickCount,ticks:void 0,type:"category",unit:void 0},BO=(t,e)=>t.polarAxis.angleAxis[e]!=null?t.polarAxis.angleAxis[e]:t.layout.layoutType==="radial"?Fwe:Owe,HO=(t,e)=>t.polarAxis.radiusAxis[e]!=null?t.polarAxis.radiusAxis[e]:t.layout.layoutType==="radial"?Iwe:Lwe,WN=t=>t.polarOptions,$O=nt([qu,Wu,na],kX),AY=nt([WN,$O],(t,e)=>{if(t!=null)return es(t.innerRadius,e,0)}),CY=nt([WN,$O],(t,e)=>{if(t!=null)return es(t.outerRadius,e,e*.8)}),Uwe=t=>{if(t==null)return[0,0];var{startAngle:e,endAngle:n}=t;return[e,n]},jY=nt([WN],Uwe);nt([BO,jY],qN);var PY=nt([$O,AY,CY],(t,e,n)=>{if(!(t==null||e==null||n==null))return[e,n]});nt([HO,PY],qN);var DY=nt([Vn,WN,AY,CY,qu,Wu],(t,e,n,r,i,a)=>{if(!(t!=="centric"&&t!=="radial"||e==null||n==null||r==null)){var{cx:o,cy:l,startAngle:c,endAngle:u}=e;return{cx:es(o,i,i/2),cy:es(l,a,a/2),innerRadius:n,outerRadius:r,startAngle:c,endAngle:u,clockWise:!1}}}),ri=(t,e)=>e,Jy=(t,e,n)=>n;function KN(t){return t?.id}function RY(t,e,n){var{chartData:r=[]}=e,{allowDuplicatedCategory:i,dataKey:a}=n,o=new Map;return t.forEach(l=>{var c,u=(c=l.data)!==null&&c!==void 0?c:r;if(!(u==null||u.length===0)){var d=KN(l);u.forEach((f,p)=>{var m=a==null||i?p:String(yr(f,a,null)),x=yr(f,l.dataKey,0),b;o.has(m)?b=o.get(m):b={},Object.assign(b,{[d]:x}),o.set(m,b)})}}),Array.from(o.values())}function XN(t){return t.stackId!=null&&t.dataKey!=null}var YN=(t,e)=>t===e?!0:t==null||e==null?!1:t[0]===e[0]&&t[1]===e[1];function QN(t,e){return Array.isArray(t)&&Array.isArray(e)&&t.length===0&&e.length===0?!0:t===e}function zwe(t,e){if(t.length===e.length){for(var n=0;n<t.length;n++)if(t[n]!==e[n])return!1;return!0}return!1}var aa=t=>{var e=Vn(t);return e==="horizontal"?"xAxis":e==="vertical"?"yAxis":e==="centric"?"angleAxis":"radiusAxis"},Nx=t=>t.tooltip.settings.axisId;function L6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function AS(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?L6(Object(n),!0).forEach(function(r){Bwe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):L6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Bwe(t,e,n){return(e=Hwe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Hwe(t){var e=$we(t,"string");return typeof e=="symbol"?e:e+""}function $we(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var l3=[0,"auto"],fa={allowDataOverflow:!1,allowDecimals:!0,allowDuplicatedCategory:!0,angle:0,dataKey:void 0,domain:void 0,height:30,hide:!0,id:0,includeHidden:!1,interval:"preserveEnd",minTickGap:5,mirror:!1,name:void 0,orientation:"bottom",padding:{left:0,right:0},reversed:!1,scale:"auto",tick:!0,tickCount:5,tickFormatter:void 0,ticks:void 0,type:"category",unit:void 0},OY=(t,e)=>t.cartesianAxis.xAxis[e],Ec=(t,e)=>{var n=OY(t,e);return n??fa},ma={allowDataOverflow:!1,allowDecimals:!0,allowDuplicatedCategory:!0,angle:0,dataKey:void 0,domain:l3,hide:!0,id:0,includeHidden:!1,interval:"preserveEnd",minTickGap:5,mirror:!1,name:void 0,orientation:"left",padding:{top:0,bottom:0},reversed:!1,scale:"auto",tick:!0,tickCount:5,tickFormatter:void 0,ticks:void 0,type:"number",unit:void 0,width:Vy},LY=(t,e)=>t.cartesianAxis.yAxis[e],Tc=(t,e)=>{var n=LY(t,e);return n??ma},Vwe={domain:[0,"auto"],includeHidden:!1,reversed:!1,allowDataOverflow:!1,allowDuplicatedCategory:!1,dataKey:void 0,id:0,name:"",range:[64,64],scale:"auto",type:"number",unit:""},VO=(t,e)=>{var n=t.cartesianAxis.zAxis[e];return n??Vwe},ci=(t,e,n)=>{switch(e){case"xAxis":return Ec(t,n);case"yAxis":return Tc(t,n);case"zAxis":return VO(t,n);case"angleAxis":return BO(t,n);case"radiusAxis":return HO(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},Gwe=(t,e,n)=>{switch(e){case"xAxis":return Ec(t,n);case"yAxis":return Tc(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},ev=(t,e,n)=>{switch(e){case"xAxis":return Ec(t,n);case"yAxis":return Tc(t,n);case"angleAxis":return BO(t,n);case"radiusAxis":return HO(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},FY=t=>t.graphicalItems.cartesianItems.some(e=>e.type==="bar")||t.graphicalItems.polarItems.some(e=>e.type==="radialBar");function GO(t,e){return n=>{switch(t){case"xAxis":return"xAxisId"in n&&n.xAxisId===e;case"yAxis":return"yAxisId"in n&&n.yAxisId===e;case"zAxis":return"zAxisId"in n&&n.zAxisId===e;case"angleAxis":return"angleAxisId"in n&&n.angleAxisId===e;case"radiusAxis":return"radiusAxisId"in n&&n.radiusAxisId===e;default:return!1}}}var tv=t=>t.graphicalItems.cartesianItems,qwe=nt([ri,Jy],GO),qO=(t,e,n)=>t.filter(n).filter(r=>e?.includeHidden===!0?!0:!r.hide),nv=nt([tv,ci,qwe],qO,{memoizeOptions:{resultEqualityCheck:QN}}),IY=nt([nv],t=>t.filter(e=>e.type==="area"||e.type==="bar").filter(XN)),UY=t=>t.filter(e=>!("stackId"in e)||e.stackId===void 0),Wwe=nt([nv],UY),WO=t=>t.map(e=>e.data).filter(Boolean).flat(1),Kwe=nt([nv],WO,{memoizeOptions:{resultEqualityCheck:QN}}),KO=(t,e)=>{var{chartData:n=[],dataStartIndex:r,dataEndIndex:i}=e;return t.length>0?t:n.slice(r,i+1)},XO=nt([Kwe,Qy],KO),YO=(t,e,n)=>e?.dataKey!=null?t.map(r=>({value:yr(r,e.dataKey)})):n.length>0?n.map(r=>r.dataKey).flatMap(r=>t.map(i=>({value:yr(i,r)}))):t.map(r=>({value:r})),ZN=nt([XO,ci,nv],YO);function zY(t,e){switch(t){case"xAxis":return e.direction==="x";case"yAxis":return e.direction==="y";default:return!1}}function w1(t){if(cl(t)||t instanceof Date){var e=Number(t);if(vr(e))return e}}function F6(t){if(Array.isArray(t)){var e=[w1(t[0]),w1(t[1])];return _h(e)?e:void 0}var n=w1(t);if(n!=null)return[n,n]}function Bu(t){return t.map(w1).filter(Gme)}function Xwe(t,e,n){return!n||typeof e!="number"||$s(e)?[]:n.length?Bu(n.flatMap(r=>{var i=yr(t,r.dataKey),a,o;if(Array.isArray(i)?[a,o]=i:a=o=i,!(!vr(a)||!vr(o)))return[e-a,e+o]})):[]}var sa=t=>{var e=aa(t),n=Nx(t);return ev(t,e,n)},rv=nt([sa],t=>t?.dataKey),Ywe=nt([IY,Qy,sa],RY),BY=(t,e,n,r)=>{var i={},a=e.reduce((o,l)=>(l.stackId==null||(o[l.stackId]==null&&(o[l.stackId]=[]),o[l.stackId].push(l)),o),i);return Object.fromEntries(Object.entries(a).map(o=>{var[l,c]=o,u=r?[...c].reverse():c,d=u.map(KN);return[l,{stackedData:pxe(t,d,n),graphicalItems:u}]}))},ly=nt([Ywe,IY,Zy,EY],BY),HY=(t,e,n,r)=>{var{dataStartIndex:i,dataEndIndex:a}=e;if(r==null&&n!=="zAxis"){var o=yxe(t,i,a);if(!(o!=null&&o[0]===0&&o[1]===0))return o}},Qwe=nt([ci],t=>t.allowDataOverflow),QO=t=>{var e;if(t==null||!("domain"in t))return l3;if(t.domain!=null)return t.domain;if(t.ticks!=null){if(t.type==="number"){var n=Bu(t.ticks);return[Math.min(...n),Math.max(...n)]}if(t.type==="category")return t.ticks.map(String)}return(e=t?.domain)!==null&&e!==void 0?e:l3},ZO=nt([ci],QO),JO=nt([ZO,Qwe],dY),Zwe=nt([ly,Uh,ri,JO],HY,{memoizeOptions:{resultEqualityCheck:YN}}),JN=t=>t.errorBars,Jwe=(t,e,n)=>t.flatMap(r=>e[r.id]).filter(Boolean).filter(r=>zY(n,r)),CS=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];var i=n.filter(Boolean);if(i.length!==0){var a=i.flat(),o=Math.min(...a),l=Math.max(...a);return[o,l]}},e4=(t,e,n,r,i)=>{var a,o;if(n.length>0&&t.forEach(l=>{n.forEach(c=>{var u,d,f=(u=r[c.id])===null||u===void 0?void 0:u.filter(v=>zY(i,v)),p=yr(l,(d=e.dataKey)!==null&&d!==void 0?d:c.dataKey),m=Xwe(l,p,f);if(m.length>=2){var x=Math.min(...m),b=Math.max(...m);(a==null||x<a)&&(a=x),(o==null||b>o)&&(o=b)}var y=F6(p);y!=null&&(a=a==null?y[0]:Math.min(a,y[0]),o=o==null?y[1]:Math.max(o,y[1]))})}),e?.dataKey!=null&&t.forEach(l=>{var c=F6(yr(l,e.dataKey));c!=null&&(a=a==null?c[0]:Math.min(a,c[0]),o=o==null?c[1]:Math.max(o,c[1]))}),vr(a)&&vr(o))return[a,o]},e_e=nt([XO,ci,Wwe,JN,ri],e4,{memoizeOptions:{resultEqualityCheck:YN}});function t_e(t){var{value:e}=t;if(cl(e)||e instanceof Date)return e}var n_e=(t,e,n)=>{var r=t.map(t_e).filter(i=>i!=null);return n&&(e.dataKey==null||e.allowDuplicatedCategory&&rK(r))?CX(0,t.length):e.allowDuplicatedCategory?r:Array.from(new Set(r))},$Y=t=>t.referenceElements.dots,kx=(t,e,n)=>t.filter(r=>r.ifOverflow==="extendDomain").filter(r=>e==="xAxis"?r.xAxisId===n:r.yAxisId===n),r_e=nt([$Y,ri,Jy],kx),VY=t=>t.referenceElements.areas,i_e=nt([VY,ri,Jy],kx),GY=t=>t.referenceElements.lines,a_e=nt([GY,ri,Jy],kx),qY=(t,e)=>{var n=Bu(t.map(r=>e==="xAxis"?r.x:r.y));if(n.length!==0)return[Math.min(...n),Math.max(...n)]},s_e=nt(r_e,ri,qY),WY=(t,e)=>{var n=Bu(t.flatMap(r=>[e==="xAxis"?r.x1:r.y1,e==="xAxis"?r.x2:r.y2]));if(n.length!==0)return[Math.min(...n),Math.max(...n)]},o_e=nt([i_e,ri],WY);function l_e(t){var e;if(t.x!=null)return Bu([t.x]);var n=(e=t.segment)===null||e===void 0?void 0:e.map(r=>r.x);return n==null||n.length===0?[]:Bu(n)}function c_e(t){var e;if(t.y!=null)return Bu([t.y]);var n=(e=t.segment)===null||e===void 0?void 0:e.map(r=>r.y);return n==null||n.length===0?[]:Bu(n)}var KY=(t,e)=>{var n=t.flatMap(r=>e==="xAxis"?l_e(r):c_e(r));if(n.length!==0)return[Math.min(...n),Math.max(...n)]},u_e=nt([a_e,ri],KY),d_e=nt(s_e,u_e,o_e,(t,e,n)=>CS(t,n,e)),t4=(t,e,n,r,i,a,o,l)=>{if(n!=null)return n;var c=o==="vertical"&&l==="xAxis"||o==="horizontal"&&l==="yAxis",u=c?CS(r,a,i):CS(a,i);return wwe(e,u,t.allowDataOverflow)},h_e=nt([ci,ZO,JO,Zwe,e_e,d_e,Vn,ri],t4,{memoizeOptions:{resultEqualityCheck:YN}}),f_e=[0,1],n4=(t,e,n,r,i,a,o)=>{if(!((t==null||n==null||n.length===0)&&o===void 0)){var{dataKey:l,type:c}=t,u=kc(e,a);if(u&&l==null){var d;return CX(0,(d=n?.length)!==null&&d!==void 0?d:0)}return c==="category"?n_e(r,t,u):i==="expand"?f_e:o}},r4=nt([ci,Vn,XO,ZN,Zy,ri,h_e],n4),XY=(t,e,n,r,i)=>{if(t!=null){var{scale:a,type:o}=t;if(a==="auto")return e==="radial"&&i==="radiusAxis"?"band":e==="radial"&&i==="angleAxis"?"linear":o==="category"&&r&&(r.indexOf("LineChart")>=0||r.indexOf("AreaChart")>=0||r.indexOf("ComposedChart")>=0&&!n)?"point":o==="category"?"band":"linear";if(typeof a=="string"){var l="scale".concat(Iy(a));return l in a0?l:"point"}}},Ex=nt([ci,Vn,FY,IO,ri],XY);function m_e(t){if(t!=null){if(t in a0)return a0[t]();var e="scale".concat(Iy(t));if(e in a0)return a0[e]()}}function i4(t,e,n,r){if(!(n==null||r==null)){if(typeof t.scale=="function")return t.scale.copy().domain(n).range(r);var i=m_e(e);if(i!=null){var a=i.domain(n).range(r);return uxe(a),a}}}var a4=(t,e,n)=>{var r=QO(e);if(!(n!=="auto"&&n!=="linear")){if(e!=null&&e.tickCount&&Array.isArray(r)&&(r[0]==="auto"||r[1]==="auto")&&_h(t))return Cwe(t,e.tickCount,e.allowDecimals);if(e!=null&&e.tickCount&&e.type==="number"&&_h(t))return jwe(t,e.tickCount,e.allowDecimals)}},s4=nt([r4,ev,Ex],a4),o4=(t,e,n,r)=>{if(r!=="angleAxis"&&t?.type==="number"&&_h(e)&&Array.isArray(n)&&n.length>0){var i=e[0],a=n[0],o=e[1],l=n[n.length-1];return[Math.min(i,a),Math.max(o,l)]}return e},p_e=nt([ci,r4,s4,ri],o4),g_e=nt(ZN,ci,(t,e)=>{if(!(!e||e.type!=="number")){var n=1/0,r=Array.from(Bu(t.map(l=>l.value))).sort((l,c)=>l-c);if(r.length<2)return 1/0;var i=r[r.length-1]-r[0];if(i===0)return 1/0;for(var a=0;a<r.length-1;a++){var o=r[a+1]-r[a];n=Math.min(n,o)}return n/i}}),YY=nt(g_e,Vn,kY,na,(t,e,n,r)=>r,(t,e,n,r,i)=>{if(!vr(t))return 0;var a=e==="vertical"?r.height:r.width;if(i==="gap")return t*a/2;if(i==="no-gap"){var o=es(n,t*a),l=t*a/2;return l-o-(l-o)/a*o}return 0}),x_e=(t,e)=>{var n=Ec(t,e);return n==null||typeof n.padding!="string"?0:YY(t,"xAxis",e,n.padding)},b_e=(t,e)=>{var n=Tc(t,e);return n==null||typeof n.padding!="string"?0:YY(t,"yAxis",e,n.padding)},y_e=nt(Ec,x_e,(t,e)=>{var n,r;if(t==null)return{left:0,right:0};var{padding:i}=t;return typeof i=="string"?{left:e,right:e}:{left:((n=i.left)!==null&&n!==void 0?n:0)+e,right:((r=i.right)!==null&&r!==void 0?r:0)+e}}),v_e=nt(Tc,b_e,(t,e)=>{var n,r;if(t==null)return{top:0,bottom:0};var{padding:i}=t;return typeof i=="string"?{top:e,bottom:e}:{top:((n=i.top)!==null&&n!==void 0?n:0)+e,bottom:((r=i.bottom)!==null&&r!==void 0?r:0)+e}}),w_e=nt([na,y_e,ON,RN,(t,e,n)=>n],(t,e,n,r,i)=>{var{padding:a}=r;return i?[a.left,n.width-a.right]:[t.left+e.left,t.left+t.width-e.right]}),__e=nt([na,Vn,v_e,ON,RN,(t,e,n)=>n],(t,e,n,r,i,a)=>{var{padding:o}=i;return a?[r.height-o.bottom,o.top]:e==="horizontal"?[t.top+t.height-n.bottom,t.top+n.top]:[t.top+n.top,t.top+t.height-n.bottom]}),iv=(t,e,n,r)=>{var i;switch(e){case"xAxis":return w_e(t,n,r);case"yAxis":return __e(t,n,r);case"zAxis":return(i=VO(t,n))===null||i===void 0?void 0:i.range;case"angleAxis":return jY(t);case"radiusAxis":return PY(t,n);default:return}},QY=nt([ci,iv],qN),Sh=nt([ci,Ex,p_e,QY],i4);nt([nv,JN,ri],Jwe);function ZY(t,e){return t.id<e.id?-1:t.id>e.id?1:0}var e2=(t,e)=>e,t2=(t,e,n)=>n,S_e=nt(PN,e2,t2,(t,e,n)=>t.filter(r=>r.orientation===e).filter(r=>r.mirror===n).sort(ZY)),M_e=nt(DN,e2,t2,(t,e,n)=>t.filter(r=>r.orientation===e).filter(r=>r.mirror===n).sort(ZY)),JY=(t,e)=>({width:t.width,height:e.height}),N_e=(t,e)=>{var n=typeof e.width=="number"?e.width:Vy;return{width:n,height:t.height}},eQ=nt(na,Ec,JY),k_e=(t,e,n)=>{switch(e){case"top":return t.top;case"bottom":return n-t.bottom;default:return 0}},E_e=(t,e,n)=>{switch(e){case"left":return t.left;case"right":return n-t.right;default:return 0}},T_e=nt(Wu,na,S_e,e2,t2,(t,e,n,r,i)=>{var a={},o;return n.forEach(l=>{var c=JY(e,l);o==null&&(o=k_e(e,r,t));var u=r==="top"&&!i||r==="bottom"&&i;a[l.id]=o-Number(u)*c.height,o+=(u?-1:1)*c.height}),a}),A_e=nt(qu,na,M_e,e2,t2,(t,e,n,r,i)=>{var a={},o;return n.forEach(l=>{var c=N_e(e,l);o==null&&(o=E_e(e,r,t));var u=r==="left"&&!i||r==="right"&&i;a[l.id]=o-Number(u)*c.width,o+=(u?-1:1)*c.width}),a}),C_e=(t,e)=>{var n=Ec(t,e);if(n!=null)return T_e(t,n.orientation,n.mirror)},j_e=nt([na,Ec,C_e,(t,e)=>e],(t,e,n,r)=>{if(e!=null){var i=n?.[r];return i==null?{x:t.left,y:0}:{x:t.left,y:i}}}),P_e=(t,e)=>{var n=Tc(t,e);if(n!=null)return A_e(t,n.orientation,n.mirror)},D_e=nt([na,Tc,P_e,(t,e)=>e],(t,e,n,r)=>{if(e!=null){var i=n?.[r];return i==null?{x:0,y:t.top}:{x:i,y:t.top}}}),tQ=nt(na,Tc,(t,e)=>{var n=typeof e.width=="number"?e.width:Vy;return{width:n,height:t.height}}),I6=(t,e,n)=>{switch(e){case"xAxis":return eQ(t,n).width;case"yAxis":return tQ(t,n).height;default:return}},nQ=(t,e,n,r)=>{if(n!=null){var{allowDuplicatedCategory:i,type:a,dataKey:o}=n,l=kc(t,r),c=e.map(u=>u.value);if(o&&l&&a==="category"&&i&&rK(c))return c}},l4=nt([Vn,ZN,ci,ri],nQ),rQ=(t,e,n,r)=>{if(!(n==null||n.dataKey==null)){var{type:i,scale:a}=n,o=kc(t,r);if(o&&(i==="number"||a!=="auto"))return e.map(l=>l.value)}},c4=nt([Vn,ZN,ev,ri],rQ),U6=nt([Vn,Gwe,Ex,Sh,l4,c4,iv,s4,ri],(t,e,n,r,i,a,o,l,c)=>{if(e!=null){var u=kc(t,c);return{angle:e.angle,interval:e.interval,minTickGap:e.minTickGap,orientation:e.orientation,tick:e.tick,tickCount:e.tickCount,tickFormatter:e.tickFormatter,ticks:e.ticks,type:e.type,unit:e.unit,axisType:c,categoricalDomain:a,duplicateDomain:i,isCategorical:u,niceTicks:l,range:o,realScaleType:n,scale:r}}}),R_e=(t,e,n,r,i,a,o,l,c)=>{if(!(e==null||r==null)){var u=kc(t,c),{type:d,ticks:f,tickCount:p}=e,m=n==="scaleBand"&&typeof r.bandwidth=="function"?r.bandwidth()/2:2,x=d==="category"&&r.bandwidth?r.bandwidth()/m:0;x=c==="angleAxis"&&a!=null&&a.length>=2?ya(a[0]-a[1])*2*x:x;var b=f||i;if(b){var y=b.map((v,S)=>{var N=o?o.indexOf(v):v;return{index:S,coordinate:r(N)+x,value:v,offset:x}});return y.filter(v=>vr(v.coordinate))}return u&&l?l.map((v,S)=>({coordinate:r(v)+x,value:v,index:S,offset:x})).filter(v=>vr(v.coordinate)):r.ticks?r.ticks(p).map(v=>({coordinate:r(v)+x,value:v,offset:x})):r.domain().map((v,S)=>({coordinate:r(v)+x,value:o?o[v]:v,index:S,offset:x}))}},iQ=nt([Vn,ev,Ex,Sh,s4,iv,l4,c4,ri],R_e),O_e=(t,e,n,r,i,a,o)=>{if(!(e==null||n==null||r==null||r[0]===r[1])){var l=kc(t,o),{tickCount:c}=e,u=0;return u=o==="angleAxis"&&r?.length>=2?ya(r[0]-r[1])*2*u:u,l&&a?a.map((d,f)=>({coordinate:n(d)+u,value:d,index:f,offset:u})):n.ticks?n.ticks(c).map(d=>({coordinate:n(d)+u,value:d,offset:u})):n.domain().map((d,f)=>({coordinate:n(d)+u,value:i?i[d]:d,index:f,offset:u}))}},xc=nt([Vn,ev,Sh,iv,l4,c4,ri],O_e),bc=nt(ci,Sh,(t,e)=>{if(!(t==null||e==null))return AS(AS({},t),{},{scale:e})}),L_e=nt([ci,Ex,r4,QY],i4);nt((t,e,n)=>VO(t,n),L_e,(t,e)=>{if(!(t==null||e==null))return AS(AS({},t),{},{scale:e})});var F_e=nt([Vn,PN,DN],(t,e,n)=>{switch(t){case"horizontal":return e.some(r=>r.reversed)?"right-to-left":"left-to-right";case"vertical":return n.some(r=>r.reversed)?"bottom-to-top":"top-to-bottom";case"centric":case"radial":return"left-to-right";default:return}}),aQ=t=>t.options.defaultTooltipEventType,sQ=t=>t.options.validateTooltipEventTypes;function oQ(t,e,n){if(t==null)return e;var r=t?"axis":"item";return n==null?e:n.includes(r)?r:e}function u4(t,e){var n=aQ(t),r=sQ(t);return oQ(e,n,r)}function I_e(t){return It(e=>u4(e,t))}var lQ=(t,e)=>{var n,r=Number(e);if(!($s(r)||e==null))return r>=0?t==null||(n=t[r])===null||n===void 0?void 0:n.value:void 0},U_e=t=>t.tooltip.settings,Wd={active:!1,index:null,dataKey:void 0,graphicalItemId:void 0,coordinate:void 0},z_e={itemInteraction:{click:Wd,hover:Wd},axisInteraction:{click:Wd,hover:Wd},keyboardInteraction:Wd,syncInteraction:{active:!1,index:null,dataKey:void 0,label:void 0,coordinate:void 0,sourceViewBox:void 0,graphicalItemId:void 0},tooltipItemPayloads:[],settings:{shared:void 0,trigger:"hover",axisId:0,active:!1,defaultIndex:void 0}},cQ=Vs({name:"tooltip",initialState:z_e,reducers:{addTooltipEntrySettings:{reducer(t,e){t.tooltipItemPayloads.push(e.payload)},prepare:Zr()},replaceTooltipEntrySettings:{reducer(t,e){var{prev:n,next:r}=e.payload,i=Ol(t).tooltipItemPayloads.indexOf(n);i>-1&&(t.tooltipItemPayloads[i]=r)},prepare:Zr()},removeTooltipEntrySettings:{reducer(t,e){var n=Ol(t).tooltipItemPayloads.indexOf(e.payload);n>-1&&t.tooltipItemPayloads.splice(n,1)},prepare:Zr()},setTooltipSettingsState(t,e){t.settings=e.payload},setActiveMouseOverItemIndex(t,e){t.syncInteraction.active=!1,t.keyboardInteraction.active=!1,t.itemInteraction.hover.active=!0,t.itemInteraction.hover.index=e.payload.activeIndex,t.itemInteraction.hover.dataKey=e.payload.activeDataKey,t.itemInteraction.hover.graphicalItemId=e.payload.activeGraphicalItemId,t.itemInteraction.hover.coordinate=e.payload.activeCoordinate},mouseLeaveChart(t){t.itemInteraction.hover.active=!1,t.axisInteraction.hover.active=!1},mouseLeaveItem(t){t.itemInteraction.hover.active=!1},setActiveClickItemIndex(t,e){t.syncInteraction.active=!1,t.itemInteraction.click.active=!0,t.keyboardInteraction.active=!1,t.itemInteraction.click.index=e.payload.activeIndex,t.itemInteraction.click.dataKey=e.payload.activeDataKey,t.itemInteraction.click.graphicalItemId=e.payload.activeGraphicalItemId,t.itemInteraction.click.coordinate=e.payload.activeCoordinate},setMouseOverAxisIndex(t,e){t.syncInteraction.active=!1,t.axisInteraction.hover.active=!0,t.keyboardInteraction.active=!1,t.axisInteraction.hover.index=e.payload.activeIndex,t.axisInteraction.hover.dataKey=e.payload.activeDataKey,t.axisInteraction.hover.coordinate=e.payload.activeCoordinate},setMouseClickAxisIndex(t,e){t.syncInteraction.active=!1,t.keyboardInteraction.active=!1,t.axisInteraction.click.active=!0,t.axisInteraction.click.index=e.payload.activeIndex,t.axisInteraction.click.dataKey=e.payload.activeDataKey,t.axisInteraction.click.coordinate=e.payload.activeCoordinate},setSyncInteraction(t,e){t.syncInteraction=e.payload},setKeyboardInteraction(t,e){t.keyboardInteraction.active=e.payload.active,t.keyboardInteraction.index=e.payload.activeIndex,t.keyboardInteraction.coordinate=e.payload.activeCoordinate,t.keyboardInteraction.dataKey=e.payload.activeDataKey}}}),{addTooltipEntrySettings:B_e,replaceTooltipEntrySettings:H_e,removeTooltipEntrySettings:$_e,setTooltipSettingsState:V_e,setActiveMouseOverItemIndex:uQ,mouseLeaveItem:G_e,mouseLeaveChart:dQ,setActiveClickItemIndex:q_e,setMouseOverAxisIndex:hQ,setMouseClickAxisIndex:W_e,setSyncInteraction:c3,setKeyboardInteraction:u3}=cQ.actions,K_e=cQ.reducer;function z6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Ww(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?z6(Object(n),!0).forEach(function(r){X_e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):z6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function X_e(t,e,n){return(e=Y_e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Y_e(t){var e=Q_e(t,"string");return typeof e=="symbol"?e:e+""}function Q_e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Z_e(t,e,n){return e==="axis"?n==="click"?t.axisInteraction.click:t.axisInteraction.hover:n==="click"?t.itemInteraction.click:t.itemInteraction.hover}function J_e(t){return t.index!=null}var fQ=(t,e,n,r)=>{if(e==null)return Wd;var i=Z_e(t,e,n);if(i==null)return Wd;if(i.active)return i;if(t.keyboardInteraction.active)return t.keyboardInteraction;if(t.syncInteraction.active&&t.syncInteraction.index!=null)return t.syncInteraction;var a=t.settings.active===!0;if(J_e(i)){if(a)return Ww(Ww({},i),{},{active:!0})}else if(r!=null)return{active:!0,coordinate:void 0,dataKey:void 0,index:r,graphicalItemId:void 0};return Ww(Ww({},Wd),{},{coordinate:i.coordinate})};function e1e(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 t1e(t,e){var n=e1e(t),r=e[0],i=e[1];if(n===void 0)return!1;var a=Math.min(r,i),o=Math.max(r,i);return n>=a&&n<=o}function n1e(t,e,n){if(n==null||e==null)return!0;var r=yr(t,e);return r==null||!_h(n)?!0:t1e(r,n)}var d4=(t,e,n,r)=>{var i=t?.index;if(i==null)return null;var a=Number(i);if(!vr(a))return i;var o=0,l=1/0;e.length>0&&(l=e.length-1);var c=Math.max(o,Math.min(a,l)),u=e[c];return u==null||n1e(u,n,r)?String(c):null},mQ=(t,e,n,r,i,a,o,l)=>{if(!(a==null||l==null)){var c=o[0],u=c==null?void 0:l(c.positions,a);if(u!=null)return u;var d=i?.[Number(a)];if(d)switch(n){case"horizontal":return{x:d.coordinate,y:(r.top+e)/2};default:return{x:(r.left+t)/2,y:d.coordinate}}}},pQ=(t,e,n,r)=>{if(e==="axis")return t.tooltipItemPayloads;if(t.tooltipItemPayloads.length===0)return[];var i;return n==="hover"?i=t.itemInteraction.hover.dataKey:i=t.itemInteraction.click.dataKey,i==null&&r!=null?[t.tooltipItemPayloads[0]]:t.tooltipItemPayloads.filter(a=>{var o;return((o=a.settings)===null||o===void 0?void 0:o.dataKey)===i})},av=t=>t.options.tooltipPayloadSearcher,Tx=t=>t.tooltip;function B6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function H6(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?B6(Object(n),!0).forEach(function(r){r1e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):B6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function r1e(t,e,n){return(e=i1e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function i1e(t){var e=a1e(t,"string");return typeof e=="symbol"?e:e+""}function a1e(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 s1e(t,e){return t??e}var gQ=(t,e,n,r,i,a,o)=>{if(!(e==null||a==null)){var{chartData:l,computedData:c,dataStartIndex:u,dataEndIndex:d}=n,f=[];return t.reduce((p,m)=>{var x,{dataDefinedOnItem:b,settings:y}=m,v=s1e(b,l),S=Array.isArray(v)?ZK(v,u,d):v,N=(x=y?.dataKey)!==null&&x!==void 0?x:r,T=y?.nameKey,k;if(r&&Array.isArray(S)&&!Array.isArray(S[0])&&o==="axis"?k=iK(S,r,i):k=a(S,e,c,T),Array.isArray(k))k.forEach(E=>{var D=H6(H6({},y),{},{name:E.name,unit:E.unit,color:void 0,fill:void 0});p.push(l8({tooltipEntrySettings:D,dataKey:E.dataKey,payload:E.payload,value:yr(E.payload,E.dataKey),name:E.name}))});else{var C;p.push(l8({tooltipEntrySettings:y,dataKey:N,payload:k,value:yr(k,N),name:(C=yr(k,T))!==null&&C!==void 0?C:y?.name}))}return p},f)}},h4=nt([sa,Vn,FY,IO,aa],XY),o1e=nt([t=>t.graphicalItems.cartesianItems,t=>t.graphicalItems.polarItems],(t,e)=>[...t,...e]),l1e=nt([aa,Nx],GO),sv=nt([o1e,sa,l1e],qO,{memoizeOptions:{resultEqualityCheck:QN}}),c1e=nt([sv],t=>t.filter(XN)),u1e=nt([sv],WO,{memoizeOptions:{resultEqualityCheck:QN}}),Ax=nt([u1e,Uh],KO),d1e=nt([c1e,Uh,sa],RY),f4=nt([Ax,sa,sv],YO),xQ=nt([sa],QO),h1e=nt([sa],t=>t.allowDataOverflow),bQ=nt([xQ,h1e],dY),f1e=nt([sv],t=>t.filter(XN)),m1e=nt([d1e,f1e,Zy,EY],BY),p1e=nt([m1e,Uh,aa,bQ],HY),g1e=nt([sv],UY),x1e=nt([Ax,sa,g1e,JN,aa],e4,{memoizeOptions:{resultEqualityCheck:YN}}),b1e=nt([$Y,aa,Nx],kx),y1e=nt([b1e,aa],qY),v1e=nt([VY,aa,Nx],kx),w1e=nt([v1e,aa],WY),_1e=nt([GY,aa,Nx],kx),S1e=nt([_1e,aa],KY),M1e=nt([y1e,S1e,w1e],CS),N1e=nt([sa,xQ,bQ,p1e,x1e,M1e,Vn,aa],t4),ov=nt([sa,Vn,Ax,f4,Zy,aa,N1e],n4),k1e=nt([ov,sa,h4],a4),E1e=nt([sa,ov,k1e,aa],o4),yQ=t=>{var e=aa(t),n=Nx(t),r=!1;return iv(t,e,n,r)},vQ=nt([sa,yQ],qN),wQ=nt([sa,h4,E1e,vQ],i4),T1e=nt([Vn,f4,sa,aa],nQ),A1e=nt([Vn,f4,sa,aa],rQ),C1e=(t,e,n,r,i,a,o,l)=>{if(e){var{type:c}=e,u=kc(t,l);if(r){var d=n==="scaleBand"&&r.bandwidth?r.bandwidth()/2:2,f=c==="category"&&r.bandwidth?r.bandwidth()/d:0;return f=l==="angleAxis"&&i!=null&&i?.length>=2?ya(i[0]-i[1])*2*f:f,u&&o?o.map((p,m)=>({coordinate:r(p)+f,value:p,index:m,offset:f})):r.domain().map((p,m)=>({coordinate:r(p)+f,value:a?a[p]:p,index:m,offset:f}))}}},Xu=nt([Vn,sa,h4,wQ,yQ,T1e,A1e,aa],C1e),m4=nt([aQ,sQ,U_e],(t,e,n)=>oQ(n.shared,t,e)),_Q=t=>t.tooltip.settings.trigger,p4=t=>t.tooltip.settings.defaultIndex,lv=nt([Tx,m4,_Q,p4],fQ),Mh=nt([lv,Ax,rv,ov],d4),SQ=nt([Xu,Mh],lQ),g4=nt([lv],t=>{if(t)return t.dataKey}),j1e=nt([lv],t=>{if(t)return t.graphicalItemId}),MQ=nt([Tx,m4,_Q,p4],pQ),P1e=nt([qu,Wu,Vn,na,Xu,p4,MQ,av],mQ),D1e=nt([lv,P1e],(t,e)=>t!=null&&t.coordinate?t.coordinate:e),R1e=nt([lv],t=>t.active),O1e=nt([MQ,Mh,Uh,rv,SQ,av,m4],gQ),L1e=nt([O1e],t=>{if(t!=null){var e=t.map(n=>n.payload).filter(n=>n!=null);return Array.from(new Set(e))}});function $6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function V6(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?$6(Object(n),!0).forEach(function(r){F1e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):$6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function F1e(t,e,n){return(e=I1e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function I1e(t){var e=U1e(t,"string");return typeof e=="symbol"?e:e+""}function U1e(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 z1e=()=>It(sa),B1e=()=>{var t=z1e(),e=It(Xu),n=It(wQ);return wh(!t||!n?void 0:V6(V6({},t),{},{scale:n}),e)};function G6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function bp(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?G6(Object(n),!0).forEach(function(r){H1e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):G6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function H1e(t,e,n){return(e=$1e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function $1e(t){var e=V1e(t,"string");return typeof e=="symbol"?e:e+""}function V1e(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 G1e=(t,e,n,r)=>{var i=e.find(a=>a&&a.index===n);if(i){if(t==="horizontal")return{x:i.coordinate,y:r.chartY};if(t==="vertical")return{x:r.chartX,y:i.coordinate}}return{x:0,y:0}},q1e=(t,e,n,r)=>{var i=e.find(u=>u&&u.index===n);if(i){if(t==="centric"){var a=i.coordinate,{radius:o}=r;return bp(bp(bp({},r),zi(r.cx,r.cy,o,a)),{},{angle:a,radius:o})}var l=i.coordinate,{angle:c}=r;return bp(bp(bp({},r),zi(r.cx,r.cy,l,c)),{},{angle:c,radius:l})}return{angle:0,clockWise:!1,cx:0,cy:0,endAngle:0,innerRadius:0,outerRadius:0,radius:0,startAngle:0,x:0,y:0}};function W1e(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 NQ=(t,e,n,r,i)=>{var a,o=-1,l=(a=e?.length)!==null&&a!==void 0?a:0;if(l<=1||t==null)return 0;if(r==="angleAxis"&&i!=null&&Math.abs(Math.abs(i[1]-i[0])-360)<=1e-6)for(var c=0;c<l;c++){var u=c>0?n[c-1].coordinate:n[l-1].coordinate,d=n[c].coordinate,f=c>=l-1?n[0].coordinate:n[c+1].coordinate,p=void 0;if(ya(d-u)!==ya(f-d)){var m=[];if(ya(f-d)===ya(i[1]-i[0])){p=f;var x=d+i[1]-i[0];m[0]=Math.min(x,(x+u)/2),m[1]=Math.max(x,(x+u)/2)}else{p=u;var b=f+i[1]-i[0];m[0]=Math.min(d,(b+d)/2),m[1]=Math.max(d,(b+d)/2)}var y=[Math.min(d,(p+d)/2),Math.max(d,(p+d)/2)];if(t>y[0]&&t<=y[1]||t>=m[0]&&t<=m[1]){({index:o}=n[c]);break}}else{var v=Math.min(u,f),S=Math.max(u,f);if(t>(v+d)/2&&t<=(S+d)/2){({index:o}=n[c]);break}}}else if(e){for(var N=0;N<l;N++)if(N===0&&t<=(e[N].coordinate+e[N+1].coordinate)/2||N>0&&N<l-1&&t>(e[N].coordinate+e[N-1].coordinate)/2&&t<=(e[N].coordinate+e[N+1].coordinate)/2||N===l-1&&t>(e[N].coordinate+e[N-1].coordinate)/2){({index:o}=e[N]);break}}return o},kQ=()=>It(IO),x4=(t,e)=>e,EQ=(t,e,n)=>n,b4=(t,e,n,r)=>r,K1e=nt(Xu,t=>SN(t,e=>e.coordinate)),y4=nt([Tx,x4,EQ,b4],fQ),v4=nt([y4,Ax,rv,ov],d4),X1e=(t,e,n)=>{if(e!=null){var r=Tx(t);return e==="axis"?n==="hover"?r.axisInteraction.hover.dataKey:r.axisInteraction.click.dataKey:n==="hover"?r.itemInteraction.hover.dataKey:r.itemInteraction.click.dataKey}},TQ=nt([Tx,x4,EQ,b4],pQ),jS=nt([qu,Wu,Vn,na,Xu,b4,TQ,av],mQ),Y1e=nt([y4,jS],(t,e)=>{var n;return(n=t.coordinate)!==null&&n!==void 0?n:e}),AQ=nt([Xu,v4],lQ),Q1e=nt([TQ,v4,Uh,rv,AQ,av,x4],gQ),Z1e=nt([y4,v4],(t,e)=>({isActive:t.active&&e!=null,activeIndex:e})),J1e=(t,e,n,r,i,a,o)=>{if(!(!t||!n||!r||!i)&&W1e(t,o)){var l=vxe(t,e),c=NQ(l,a,i,n,r),u=G1e(e,i,c,t);return{activeIndex:String(c),activeCoordinate:u}}},eSe=(t,e,n,r,i,a,o)=>{if(!(!t||!r||!i||!a||!n)){var l=F0e(t,n);if(l){var c=wxe(l,e),u=NQ(c,o,a,r,i),d=q1e(e,a,u,l);return{activeIndex:String(u),activeCoordinate:d}}}},tSe=(t,e,n,r,i,a,o,l)=>{if(!(!t||!e||!r||!i||!a))return e==="horizontal"||e==="vertical"?J1e(t,e,r,i,a,o,l):eSe(t,e,n,r,i,a,o)},nSe=nt(t=>t.zIndex.zIndexMap,(t,e)=>e,(t,e,n)=>n,(t,e,n)=>{if(e!=null){var r=t[e];if(r!=null)return n?r.panoramaElementId:r.elementId}}),rSe=nt(t=>t.zIndex.zIndexMap,t=>{var e=Object.keys(t).map(r=>parseInt(r,10)).concat(Object.values(bi)),n=Array.from(new Set(e));return n.sort((r,i)=>r-i)},{memoizeOptions:{resultEqualityCheck:zwe}});function q6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function W6(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?q6(Object(n),!0).forEach(function(r){iSe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):q6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function iSe(t,e,n){return(e=aSe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function aSe(t){var e=sSe(t,"string");return typeof e=="symbol"?e:e+""}function sSe(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 oSe={},lSe={zIndexMap:Object.values(bi).reduce((t,e)=>W6(W6({},t),{},{[e]:{elementId:void 0,panoramaElementId:void 0,consumers:0}}),oSe)},cSe=new Set(Object.values(bi));function uSe(t){return cSe.has(t)}var CQ=Vs({name:"zIndex",initialState:lSe,reducers:{registerZIndexPortal:{reducer:(t,e)=>{var{zIndex:n}=e.payload;t.zIndexMap[n]?t.zIndexMap[n].consumers+=1:t.zIndexMap[n]={consumers:1,elementId:void 0,panoramaElementId:void 0}},prepare:Zr()},unregisterZIndexPortal:{reducer:(t,e)=>{var{zIndex:n}=e.payload;t.zIndexMap[n]&&(t.zIndexMap[n].consumers-=1,t.zIndexMap[n].consumers<=0&&!uSe(n)&&delete t.zIndexMap[n])},prepare:Zr()},registerZIndexPortalId:{reducer:(t,e)=>{var{zIndex:n,elementId:r,isPanorama:i}=e.payload;t.zIndexMap[n]?i?t.zIndexMap[n].panoramaElementId=r:t.zIndexMap[n].elementId=r:t.zIndexMap[n]={consumers:0,elementId:i?void 0:r,panoramaElementId:i?r:void 0}},prepare:Zr()},unregisterZIndexPortalId:{reducer:(t,e)=>{var{zIndex:n}=e.payload;t.zIndexMap[n]&&(e.payload.isPanorama?t.zIndexMap[n].panoramaElementId=void 0:t.zIndexMap[n].elementId=void 0)},prepare:Zr()}}}),{registerZIndexPortal:dSe,unregisterZIndexPortal:hSe,registerZIndexPortalId:fSe,unregisterZIndexPortalId:mSe}=CQ.actions,pSe=CQ.reducer;function ts(t){var{zIndex:e,children:n}=t,r=Jxe(),i=r&&e!==void 0&&e!==0,a=ra(),o=Lr();_.useLayoutEffect(()=>i?(o(dSe({zIndex:e})),()=>{o(hSe({zIndex:e}))}):Uy,[o,e,i]);var l=It(u=>nSe(u,e,a));if(!i)return n;if(!l)return null;var c=document.getElementById(l);return c?gu.createPortal(n,c):null}function d3(){return d3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},d3.apply(null,arguments)}function K6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Kw(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?K6(Object(n),!0).forEach(function(r){gSe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):K6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function gSe(t,e,n){return(e=xSe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function xSe(t){var e=bSe(t,"string");return typeof e=="symbol"?e:e+""}function bSe(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 ySe(t){var{cursor:e,cursorComp:n,cursorProps:r}=t;return _.isValidElement(e)?_.cloneElement(e,r):_.createElement(n,r)}function vSe(t){var e,{coordinate:n,payload:r,index:i,offset:a,tooltipAxisBandSize:o,layout:l,cursor:c,tooltipEventType:u,chartName:d}=t,f=n,p=r,m=i;if(!c||!f||d!=="ScatterChart"&&u!=="axis")return null;var x,b,y;if(d==="ScatterChart")x=f,b=Zbe,y=bi.cursorLine;else if(d==="BarChart")x=Jbe(l,f,a,o),b=NX,y=bi.cursorRectangle;else if(l==="radial"&&sK(f)){var{cx:v,cy:S,radius:N,startAngle:T,endAngle:k}=EX(f);x={cx:v,cy:S,startAngle:T,endAngle:k,innerRadius:N,outerRadius:N},b=AX,y=bi.cursorLine}else x={points:B0e(l,f,a)},b=kg,y=bi.cursorLine;var C=typeof c=="object"&&"className"in c?c.className:void 0,E=Kw(Kw(Kw(Kw({stroke:"#ccc",pointerEvents:"none"},a),x),lm(c)),{},{payload:p,payloadIndex:m,className:tr("recharts-tooltip-cursor",C)});return _.createElement(ts,{zIndex:(e=t.zIndex)!==null&&e!==void 0?e:y},_.createElement(ySe,{cursor:c,cursorComp:b,cursorProps:E}))}function wSe(t){var e=B1e(),n=cX(),r=Em(),i=kQ();return e==null||n==null||r==null||i==null?null:_.createElement(vSe,d3({},t,{offset:n,layout:r,tooltipAxisBandSize:e,chartName:i}))}var jQ=_.createContext(null),_Se=()=>_.useContext(jQ),_A={exports:{}},X6;function SSe(){return X6||(X6=1,(function(t){var e=Object.prototype.hasOwnProperty,n="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(n=!1));function i(c,u,d){this.fn=c,this.context=u,this.once=d||!1}function a(c,u,d,f,p){if(typeof d!="function")throw new TypeError("The listener must be a function");var m=new i(d,f||c,p),x=n?n+u:u;return c._events[x]?c._events[x].fn?c._events[x]=[c._events[x],m]:c._events[x].push(m):(c._events[x]=m,c._eventsCount++),c}function o(c,u){--c._eventsCount===0?c._events=new r:delete c._events[u]}function l(){this._events=new r,this._eventsCount=0}l.prototype.eventNames=function(){var u=[],d,f;if(this._eventsCount===0)return u;for(f in d=this._events)e.call(d,f)&&u.push(n?f.slice(1):f);return Object.getOwnPropertySymbols?u.concat(Object.getOwnPropertySymbols(d)):u},l.prototype.listeners=function(u){var d=n?n+u:u,f=this._events[d];if(!f)return[];if(f.fn)return[f.fn];for(var p=0,m=f.length,x=new Array(m);p<m;p++)x[p]=f[p].fn;return x},l.prototype.listenerCount=function(u){var d=n?n+u:u,f=this._events[d];return f?f.fn?1:f.length:0},l.prototype.emit=function(u,d,f,p,m,x){var b=n?n+u:u;if(!this._events[b])return!1;var y=this._events[b],v=arguments.length,S,N;if(y.fn){switch(y.once&&this.removeListener(u,y.fn,void 0,!0),v){case 1:return y.fn.call(y.context),!0;case 2:return y.fn.call(y.context,d),!0;case 3:return y.fn.call(y.context,d,f),!0;case 4:return y.fn.call(y.context,d,f,p),!0;case 5:return y.fn.call(y.context,d,f,p,m),!0;case 6:return y.fn.call(y.context,d,f,p,m,x),!0}for(N=1,S=new Array(v-1);N<v;N++)S[N-1]=arguments[N];y.fn.apply(y.context,S)}else{var T=y.length,k;for(N=0;N<T;N++)switch(y[N].once&&this.removeListener(u,y[N].fn,void 0,!0),v){case 1:y[N].fn.call(y[N].context);break;case 2:y[N].fn.call(y[N].context,d);break;case 3:y[N].fn.call(y[N].context,d,f);break;case 4:y[N].fn.call(y[N].context,d,f,p);break;default:if(!S)for(k=1,S=new Array(v-1);k<v;k++)S[k-1]=arguments[k];y[N].fn.apply(y[N].context,S)}}return!0},l.prototype.on=function(u,d,f){return a(this,u,d,f,!1)},l.prototype.once=function(u,d,f){return a(this,u,d,f,!0)},l.prototype.removeListener=function(u,d,f,p){var m=n?n+u:u;if(!this._events[m])return this;if(!d)return o(this,m),this;var x=this._events[m];if(x.fn)x.fn===d&&(!p||x.once)&&(!f||x.context===f)&&o(this,m);else{for(var b=0,y=[],v=x.length;b<v;b++)(x[b].fn!==d||p&&!x[b].once||f&&x[b].context!==f)&&y.push(x[b]);y.length?this._events[m]=y.length===1?y[0]:y:o(this,m)}return this},l.prototype.removeAllListeners=function(u){var d;return u?(d=n?n+u:u,this._events[d]&&o(this,d)):(this._events=new r,this._eventsCount=0),this},l.prototype.off=l.prototype.removeListener,l.prototype.addListener=l.prototype.on,l.prefixed=n,l.EventEmitter=l,t.exports=l})(_A)),_A.exports}var MSe=SSe();const NSe=hl(MSe);var cy=new NSe,h3="recharts.syncEvent.tooltip",Y6="recharts.syncEvent.brush";function n2(t,e){if(e){var n=Number.parseInt(e,10);if(!$s(n))return t?.[n]}}var kSe={chartName:"",tooltipPayloadSearcher:void 0,eventEmitter:void 0,defaultTooltipEventType:"axis"},PQ=Vs({name:"options",initialState:kSe,reducers:{createEventEmitter:t=>{t.eventEmitter==null&&(t.eventEmitter=Symbol("rechartsEventEmitter"))}}}),ESe=PQ.reducer,{createEventEmitter:TSe}=PQ.actions;function ASe(t){return t.tooltip.syncInteraction}var CSe={chartData:void 0,computedData:void 0,dataStartIndex:0,dataEndIndex:0},DQ=Vs({name:"chartData",initialState:CSe,reducers:{setChartData(t,e){if(t.chartData=e.payload,e.payload==null){t.dataStartIndex=0,t.dataEndIndex=0;return}e.payload.length>0&&t.dataEndIndex!==e.payload.length-1&&(t.dataEndIndex=e.payload.length-1)},setComputedData(t,e){t.computedData=e.payload},setDataStartEndIndexes(t,e){var{startIndex:n,endIndex:r}=e.payload;n!=null&&(t.dataStartIndex=n),r!=null&&(t.dataEndIndex=r)}}}),{setChartData:Q6,setDataStartEndIndexes:jSe,setComputedData:DXe}=DQ.actions,PSe=DQ.reducer,DSe=["x","y"];function Z6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function yp(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Z6(Object(n),!0).forEach(function(r){RSe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Z6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function RSe(t,e,n){return(e=OSe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function OSe(t){var e=LSe(t,"string");return typeof e=="symbol"?e:e+""}function LSe(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 FSe(t,e){if(t==null)return{};var n,r,i=ISe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function ISe(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 USe(){var t=It(UO),e=It(zO),n=Lr(),r=It(TY),i=It(Xu),a=Em(),o=Gy(),l=It(c=>c.rootProps.className);_.useEffect(()=>{if(t==null)return Uy;var c=(u,d,f)=>{if(e!==f&&t===u){if(r==="index"){var p;if(o&&d!==null&&d!==void 0&&(p=d.payload)!==null&&p!==void 0&&p.coordinate&&d.payload.sourceViewBox){var m=d.payload.coordinate,{x,y:b}=m,y=FSe(m,DSe),{x:v,y:S,width:N,height:T}=d.payload.sourceViewBox,k=yp(yp({},y),{},{x:o.x+(N?(x-v)/N:0)*o.width,y:o.y+(T?(b-S)/T:0)*o.height});n(yp(yp({},d),{},{payload:yp(yp({},d.payload),{},{coordinate:k})}))}else n(d);return}if(i!=null){var C;if(typeof r=="function"){var E={activeTooltipIndex:d.payload.index==null?void 0:Number(d.payload.index),isTooltipActive:d.payload.active,activeIndex:d.payload.index==null?void 0:Number(d.payload.index),activeLabel:d.payload.label,activeDataKey:d.payload.dataKey,activeCoordinate:d.payload.coordinate},D=r(i,E);C=i[D]}else r==="value"&&(C=i.find(K=>String(K.value)===d.payload.label));var{coordinate:A}=d.payload;if(C==null||d.payload.active===!1||A==null||o==null){n(c3({active:!1,coordinate:void 0,dataKey:void 0,index:null,label:void 0,sourceViewBox:void 0,graphicalItemId:void 0}));return}var{x:R,y:U}=A,F=Math.min(R,o.x+o.width),$=Math.min(U,o.y+o.height),j={x:a==="horizontal"?C.coordinate:F,y:a==="horizontal"?$:C.coordinate},H=c3({active:d.payload.active,coordinate:j,dataKey:d.payload.dataKey,index:String(C.index),label:d.payload.label,sourceViewBox:d.payload.sourceViewBox,graphicalItemId:d.payload.graphicalItemId});n(H)}}};return cy.on(h3,c),()=>{cy.off(h3,c)}},[l,n,e,t,r,i,a,o])}function zSe(){var t=It(UO),e=It(zO),n=Lr();_.useEffect(()=>{if(t==null)return Uy;var r=(i,a,o)=>{e!==o&&t===i&&n(jSe(a))};return cy.on(Y6,r),()=>{cy.off(Y6,r)}},[n,e,t])}function BSe(){var t=Lr();_.useEffect(()=>{t(TSe())},[t]),USe(),zSe()}function HSe(t,e,n,r,i,a){var o=It(m=>X1e(m,t,e)),l=It(zO),c=It(UO),u=It(TY),d=It(ASe),f=d?.active,p=Gy();_.useEffect(()=>{if(!f&&c!=null&&l!=null){var m=c3({active:a,coordinate:n,dataKey:o,index:i,label:typeof r=="number"?String(r):r,sourceViewBox:p,graphicalItemId:void 0});cy.emit(h3,c,m,l)}},[f,n,o,i,r,l,c,u,a,p])}function J6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function eH(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?J6(Object(n),!0).forEach(function(r){$Se(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):J6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function $Se(t,e,n){return(e=VSe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function VSe(t){var e=GSe(t,"string");return typeof e=="symbol"?e:e+""}function GSe(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 qSe(t){return t.dataKey}function WSe(t,e){return _.isValidElement(t)?_.cloneElement(t,e):typeof t=="function"?_.createElement(t,e):_.createElement(jbe,e)}var tH=[],KSe={allowEscapeViewBox:{x:!1,y:!1},animationDuration:400,animationEasing:"ease",axisId:0,contentStyle:{},cursor:!0,filterNull:!0,isAnimationActive:"auto",itemSorter:"name",itemStyle:{},labelStyle:{},offset:10,reverseDirection:{x:!1,y:!1},separator:" : ",trigger:"hover",useTranslate3d:!1,wrapperStyle:{}};function _1(t){var e,n,r=li(t,KSe),{active:i,allowEscapeViewBox:a,animationDuration:o,animationEasing:l,content:c,filterNull:u,isAnimationActive:d,offset:f,payloadUniqBy:p,position:m,reverseDirection:x,useTranslate3d:b,wrapperStyle:y,cursor:v,shared:S,trigger:N,defaultIndex:T,portal:k,axisId:C}=r,E=Lr(),D=typeof T=="number"?String(T):T;_.useEffect(()=>{E(V_e({shared:S,trigger:N,axisId:C,active:i,defaultIndex:D}))},[E,S,N,C,i,D]);var A=Gy(),R=vX(),U=I_e(S),{activeIndex:F,isActive:$}=(e=It(de=>Z1e(de,U,N,D)))!==null&&e!==void 0?e:{},j=It(de=>Q1e(de,U,N,D)),H=It(de=>AQ(de,U,N,D)),K=It(de=>Y1e(de,U,N,D)),V=j,Q=_Se(),Z=(n=i??$)!==null&&n!==void 0?n:!1,[ae,B]=_K([V,Z]),X=U==="axis"?H:void 0;HSe(U,N,K,X,F,Z);var ne=k??Q;if(ne==null||A==null||U==null)return null;var se=V??tH;Z||(se=tH),u&&se.length&&(se=gK(se.filter(de=>de.value!=null&&(de.hide!==!0||r.includeHidden)),p,qSe));var be=se.length>0,xe=_.createElement(Ibe,{allowEscapeViewBox:a,animationDuration:o,animationEasing:l,isAnimationActive:d,active:Z,coordinate:K,hasPayload:be,offset:f,position:m,reverseDirection:x,useTranslate3d:b,viewBox:A,wrapperStyle:y,lastBoundingBox:ae,innerRef:B,hasPortalFromProps:!!k},WSe(c,eH(eH({},r),{},{payload:se,label:X,active:Z,activeIndex:F,coordinate:K,accessibilityLayer:R})));return _.createElement(_.Fragment,null,gu.createPortal(xe,ne),Z&&_.createElement(wSe,{cursor:v,tooltipEventType:U,coordinate:K,payload:se,index:F}))}var cv=t=>null;cv.displayName="Cell";function XSe(t,e,n){return(e=YSe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function YSe(t){var e=QSe(t,"string");return typeof e=="symbol"?e:e+""}function QSe(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 ZSe{constructor(e){XSe(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 nH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function JSe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?nH(Object(n),!0).forEach(function(r){eMe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):nH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function eMe(t,e,n){return(e=tMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function tMe(t){var e=nMe(t,"string");return typeof e=="symbol"?e:e+""}function nMe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var rMe={cacheSize:2e3,enableCache:!0},RQ=JSe({},rMe),rH=new ZSe(RQ.cacheSize),iMe={position:"absolute",top:"-20000px",left:0,padding:0,margin:0,border:"none",whiteSpace:"pre"},iH="recharts_measurement_span";function aMe(t,e){var n=e.fontSize||"",r=e.fontFamily||"",i=e.fontWeight||"",a=e.fontStyle||"",o=e.letterSpacing||"",l=e.textTransform||"";return"".concat(t,"|").concat(n,"|").concat(r,"|").concat(i,"|").concat(a,"|").concat(o,"|").concat(l)}var aH=(t,e)=>{try{var n=document.getElementById(iH);n||(n=document.createElement("span"),n.setAttribute("id",iH),n.setAttribute("aria-hidden","true"),document.body.appendChild(n)),Object.assign(n.style,iMe,e),n.textContent="".concat(t);var r=n.getBoundingClientRect();return{width:r.width,height:r.height}}catch{return{width:0,height:0}}},v0=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(e==null||yx.isSsr)return{width:0,height:0};if(!RQ.enableCache)return aH(e,n);var r=aMe(e,n),i=rH.get(r);if(i)return i;var a=aH(e,n);return rH.set(r,a),a},sH=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([*/])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,oH=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([+-])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,sMe=/^px|cm|vh|vw|em|rem|%|mm|in|pt|pc|ex|ch|vmin|vmax|Q$/,oMe=/(-?\d+(?:\.\d+)?)([a-zA-Z%]+)?/,OQ={cm:96/2.54,mm:96/25.4,pt:96/72,pc:96/6,in:96,Q:96/(2.54*40),px:1},lMe=Object.keys(OQ),gg="NaN";function cMe(t,e){return t*OQ[e]}class Ps{static parse(e){var n,[,r,i]=(n=oMe.exec(e))!==null&&n!==void 0?n:[];return new Ps(parseFloat(r),i??"")}constructor(e,n){this.num=e,this.unit=n,this.num=e,this.unit=n,$s(e)&&(this.unit=""),n!==""&&!sMe.test(n)&&(this.num=NaN,this.unit=""),lMe.includes(n)&&(this.num=cMe(e,n),this.unit="px")}add(e){return this.unit!==e.unit?new Ps(NaN,""):new Ps(this.num+e.num,this.unit)}subtract(e){return this.unit!==e.unit?new Ps(NaN,""):new Ps(this.num-e.num,this.unit)}multiply(e){return this.unit!==""&&e.unit!==""&&this.unit!==e.unit?new Ps(NaN,""):new Ps(this.num*e.num,this.unit||e.unit)}divide(e){return this.unit!==""&&e.unit!==""&&this.unit!==e.unit?new Ps(NaN,""):new Ps(this.num/e.num,this.unit||e.unit)}toString(){return"".concat(this.num).concat(this.unit)}isNaN(){return $s(this.num)}}function LQ(t){if(t.includes(gg))return gg;for(var e=t;e.includes("*")||e.includes("/");){var n,[,r,i,a]=(n=sH.exec(e))!==null&&n!==void 0?n:[],o=Ps.parse(r??""),l=Ps.parse(a??""),c=i==="*"?o.multiply(l):o.divide(l);if(c.isNaN())return gg;e=e.replace(sH,c.toString())}for(;e.includes("+")||/.-\d+(?:\.\d+)?/.test(e);){var u,[,d,f,p]=(u=oH.exec(e))!==null&&u!==void 0?u:[],m=Ps.parse(d??""),x=Ps.parse(p??""),b=f==="+"?m.add(x):m.subtract(x);if(b.isNaN())return gg;e=e.replace(oH,b.toString())}return e}var lH=/\(([^()]*)\)/;function uMe(t){for(var e=t,n;(n=lH.exec(e))!=null;){var[,r]=n;e=e.replace(lH,LQ(r))}return e}function dMe(t){var e=t.replace(/\s+/g,"");return e=uMe(e),e=LQ(e),e}function hMe(t){try{return dMe(t)}catch{return gg}}function SA(t){var e=hMe(t.slice(5,-1));return e===gg?"":e}var fMe=["x","y","lineHeight","capHeight","fill","scaleToFit","textAnchor","verticalAnchor"],mMe=["dx","dy","angle","className","breakAll"];function f3(){return f3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},f3.apply(null,arguments)}function cH(t,e){if(t==null)return{};var n,r,i=pMe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function pMe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var FQ=/[ \f\n\r\t\v\u2028\u2029]+/,IQ=t=>{var{children:e,breakAll:n,style:r}=t;try{var i=[];Xr(e)||(n?i=e.toString().split(""):i=e.toString().split(FQ));var a=i.map(l=>({word:l,width:v0(l,r).width})),o=n?0:v0(" ",r).width;return{wordsWithComputedWidth:a,spaceWidth:o}}catch{return null}};function gMe(t){return t==="start"||t==="middle"||t==="end"||t==="inherit"}var UQ=(t,e,n,r)=>t.reduce((i,a)=>{var{word:o,width:l}=a,c=i[i.length-1];if(c&&l!=null&&(e==null||r||c.width+l+n<Number(e)))c.words.push(o),c.width+=l+n;else{var u={words:[o],width:l};i.push(u)}return i},[]),zQ=t=>t.reduce((e,n)=>e.width>n.width?e:n),xMe="…",uH=(t,e,n,r,i,a,o,l)=>{var c=t.slice(0,e),u=IQ({breakAll:n,style:r,children:c+xMe});if(!u)return[!1,[]];var d=UQ(u.wordsWithComputedWidth,a,o,l),f=d.length>i||zQ(d).width>Number(a);return[f,d]},bMe=(t,e,n,r,i)=>{var{maxLines:a,children:o,style:l,breakAll:c}=t,u=zt(a),d=String(o),f=UQ(e,r,n,i);if(!u||i)return f;var p=f.length>a||zQ(f).width>Number(r);if(!p)return f;for(var m=0,x=d.length-1,b=0,y;m<=x&&b<=d.length-1;){var v=Math.floor((m+x)/2),S=v-1,[N,T]=uH(d,S,c,l,a,r,n,i),[k]=uH(d,v,c,l,a,r,n,i);if(!N&&!k&&(m=v+1),N&&k&&(x=v-1),!N&&k){y=T;break}b++}return y||f},dH=t=>{var e=Xr(t)?[]:t.toString().split(FQ);return[{words:e,width:void 0}]},yMe=t=>{var{width:e,scaleToFit:n,children:r,style:i,breakAll:a,maxLines:o}=t;if((e||n)&&!yx.isSsr){var l,c,u=IQ({breakAll:a,children:r,style:i});if(u){var{wordsWithComputedWidth:d,spaceWidth:f}=u;l=d,c=f}else return dH(r);return bMe({breakAll:a,children:r,maxLines:o,style:i},l,c,e,!!n)}return dH(r)},BQ="#808080",vMe={angle:0,breakAll:!1,capHeight:"0.71em",fill:BQ,lineHeight:"1em",scaleToFit:!1,textAnchor:"start",verticalAnchor:"end",x:0,y:0},r2=_.forwardRef((t,e)=>{var n=li(t,vMe),{x:r,y:i,lineHeight:a,capHeight:o,fill:l,scaleToFit:c,textAnchor:u,verticalAnchor:d}=n,f=cH(n,fMe),p=_.useMemo(()=>yMe({breakAll:f.breakAll,children:f.children,maxLines:f.maxLines,scaleToFit:c,style:f.style,width:f.width}),[f.breakAll,f.children,f.maxLines,c,f.style,f.width]),{dx:m,dy:x,angle:b,className:y,breakAll:v}=f,S=cH(f,mMe);if(!cl(r)||!cl(i)||p.length===0)return null;var N=Number(r)+(zt(m)?m:0),T=Number(i)+(zt(x)?x:0);if(!vr(N)||!vr(T))return null;var k;switch(d){case"start":k=SA("calc(".concat(o,")"));break;case"middle":k=SA("calc(".concat((p.length-1)/2," * -").concat(a," + (").concat(o," / 2))"));break;default:k=SA("calc(".concat(p.length-1," * -").concat(a,")"));break}var C=[];if(c){var E=p[0].width,{width:D}=f;C.push("scale(".concat(zt(D)&&zt(E)?D/E:1,")"))}return b&&C.push("rotate(".concat(b,", ").concat(N,", ").concat(T,")")),C.length&&(S.transform=C.join(" ")),_.createElement("text",f3({},za(S),{ref:e,x:N,y:T,className:tr("recharts-text",y),textAnchor:u,fill:l.includes("url")?BQ:l}),p.map((A,R)=>{var U=A.words.join(v?"":" ");return _.createElement("tspan",{x:N,dy:R===0?k:a,key:"".concat(U,"-").concat(R)},U)}))});r2.displayName="Text";var wMe=["labelRef"];function _Me(t,e){if(t==null)return{};var n,r,i=SMe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function SMe(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 hH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function ki(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?hH(Object(n),!0).forEach(function(r){MMe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):hH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function MMe(t,e,n){return(e=NMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function NMe(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 fu(){return fu=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},fu.apply(null,arguments)}var HQ=_.createContext(null),$Q=t=>{var{x:e,y:n,upperWidth:r,lowerWidth:i,width:a,height:o,children:l}=t,c=_.useMemo(()=>({x:e,y:n,upperWidth:r,lowerWidth:i,width:a,height:o}),[e,n,r,i,a,o]);return _.createElement(HQ.Provider,{value:c},l)},VQ=()=>{var t=_.useContext(HQ),e=Gy();return t||lX(e)},EMe=_.createContext(null),TMe=()=>{var t=_.useContext(EMe),e=It(DY);return t||e},AMe=t=>{var{value:e,formatter:n}=t,r=Xr(t.children)?e:t.children;return typeof n=="function"?n(r):r},w4=t=>t!=null&&typeof t=="function",CMe=(t,e)=>{var n=ya(e-t),r=Math.min(Math.abs(e-t),360);return n*r},jMe=(t,e,n,r,i)=>{var{offset:a,className:o}=t,{cx:l,cy:c,innerRadius:u,outerRadius:d,startAngle:f,endAngle:p,clockWise:m}=i,x=(u+d)/2,b=CMe(f,p),y=b>=0?1:-1,v,S;switch(e){case"insideStart":v=f+y*a,S=m;break;case"insideEnd":v=p-y*a,S=!m;break;case"end":v=p+y*a,S=m;break;default:throw new Error("Unsupported position ".concat(e))}S=b<=0?S:!S;var N=zi(l,c,x,v),T=zi(l,c,x,v+(S?1:-1)*359),k="M".concat(N.x,",").concat(N.y,`
- A`).concat(x,",").concat(x,",0,1,").concat(S?0:1,`,
- `).concat(T.x,",").concat(T.y),C=Xr(t.id)?X0("recharts-radial-line-"):t.id;return _.createElement("text",fu({},r,{dominantBaseline:"central",className:tr("recharts-radial-bar-label",o)}),_.createElement("defs",null,_.createElement("path",{id:C,d:k})),_.createElement("textPath",{xlinkHref:"#".concat(C)},n))},PMe=(t,e,n)=>{var{cx:r,cy:i,innerRadius:a,outerRadius:o,startAngle:l,endAngle:c}=t,u=(l+c)/2;if(n==="outside"){var{x:d,y:f}=zi(r,i,o+e,u);return{x:d,y:f,textAnchor:d>=r?"start":"end",verticalAnchor:"middle"}}if(n==="center")return{x:r,y:i,textAnchor:"middle",verticalAnchor:"middle"};if(n==="centerTop")return{x:r,y:i,textAnchor:"middle",verticalAnchor:"start"};if(n==="centerBottom")return{x:r,y:i,textAnchor:"middle",verticalAnchor:"end"};var p=(a+o)/2,{x:m,y:x}=zi(r,i,p,u);return{x:m,y:x,textAnchor:"middle",verticalAnchor:"middle"}},m3=t=>"cx"in t&&zt(t.cx),DMe=(t,e)=>{var{parentViewBox:n,offset:r,position:i}=t,a;n!=null&&!m3(n)&&(a=n);var{x:o,y:l,upperWidth:c,lowerWidth:u,height:d}=e,f=o,p=o+(c-u)/2,m=(f+p)/2,x=(c+u)/2,b=f+c/2,y=d>=0?1:-1,v=y*r,S=y>0?"end":"start",N=y>0?"start":"end",T=c>=0?1:-1,k=T*r,C=T>0?"end":"start",E=T>0?"start":"end";if(i==="top"){var D={x:f+c/2,y:l-v,textAnchor:"middle",verticalAnchor:S};return ki(ki({},D),a?{height:Math.max(l-a.y,0),width:c}:{})}if(i==="bottom"){var A={x:p+u/2,y:l+d+v,textAnchor:"middle",verticalAnchor:N};return ki(ki({},A),a?{height:Math.max(a.y+a.height-(l+d),0),width:u}:{})}if(i==="left"){var R={x:m-k,y:l+d/2,textAnchor:C,verticalAnchor:"middle"};return ki(ki({},R),a?{width:Math.max(R.x-a.x,0),height:d}:{})}if(i==="right"){var U={x:m+x+k,y:l+d/2,textAnchor:E,verticalAnchor:"middle"};return ki(ki({},U),a?{width:Math.max(a.x+a.width-U.x,0),height:d}:{})}var F=a?{width:x,height:d}:{};return i==="insideLeft"?ki({x:m+k,y:l+d/2,textAnchor:E,verticalAnchor:"middle"},F):i==="insideRight"?ki({x:m+x-k,y:l+d/2,textAnchor:C,verticalAnchor:"middle"},F):i==="insideTop"?ki({x:f+c/2,y:l+v,textAnchor:"middle",verticalAnchor:N},F):i==="insideBottom"?ki({x:p+u/2,y:l+d-v,textAnchor:"middle",verticalAnchor:S},F):i==="insideTopLeft"?ki({x:f+k,y:l+v,textAnchor:E,verticalAnchor:N},F):i==="insideTopRight"?ki({x:f+c-k,y:l+v,textAnchor:C,verticalAnchor:N},F):i==="insideBottomLeft"?ki({x:p+k,y:l+d-v,textAnchor:E,verticalAnchor:S},F):i==="insideBottomRight"?ki({x:p+u-k,y:l+d-v,textAnchor:C,verticalAnchor:S},F):i&&typeof i=="object"&&(zt(i.x)||Lu(i.x))&&(zt(i.y)||Lu(i.y))?ki({x:o+es(i.x,x),y:l+es(i.y,d),textAnchor:"end",verticalAnchor:"end"},F):ki({x:b,y:l+d/2,textAnchor:"middle",verticalAnchor:"middle"},F)},RMe={angle:0,offset:5,zIndex:bi.label,position:"middle",textBreakAll:!1};function zd(t){var e=li(t,RMe),{viewBox:n,position:r,value:i,children:a,content:o,className:l="",textBreakAll:c,labelRef:u}=e,d=TMe(),f=VQ(),p=r==="center"?f:d??f,m,x,b;if(n==null?m=p:m3(n)?m=n:m=lX(n),!m||Xr(i)&&Xr(a)&&!_.isValidElement(o)&&typeof o!="function")return null;var y=ki(ki({},e),{},{viewBox:m});if(_.isValidElement(o)){var{labelRef:v}=y,S=_Me(y,wMe);return _.cloneElement(o,S)}if(typeof o=="function"){if(x=_.createElement(o,y),_.isValidElement(x))return x}else x=AMe(e);var N=za(e);if(m3(m)){if(r==="insideStart"||r==="insideEnd"||r==="end")return jMe(e,r,x,N,m);b=PMe(m,e.offset,e.position)}else b=DMe(e,m);return _.createElement(ts,{zIndex:e.zIndex},_.createElement(r2,fu({ref:u,className:tr("recharts-label",l)},N,b,{textAnchor:gMe(N.textAnchor)?N.textAnchor:b.textAnchor,breakAll:c}),x))}zd.displayName="Label";var OMe=(t,e,n)=>{if(!t)return null;var r={viewBox:e,labelRef:n};return t===!0?_.createElement(zd,fu({key:"label-implicit"},r)):cl(t)?_.createElement(zd,fu({key:"label-implicit",value:t},r)):_.isValidElement(t)?t.type===zd?_.cloneElement(t,ki({key:"label-implicit"},r)):_.createElement(zd,fu({key:"label-implicit",content:t},r)):w4(t)?_.createElement(zd,fu({key:"label-implicit",content:t},r)):t&&typeof t=="object"?_.createElement(zd,fu({},t,{key:"label-implicit"},r)):null};function GQ(t){var{label:e,labelRef:n}=t,r=VQ();return OMe(e,r,n)||null}var MA={},NA={},fH;function LMe(){return fH||(fH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n[n.length-1]}t.last=e})(NA)),NA}var kA={},mH;function FMe(){return mH||(mH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Array.isArray(n)?n:Array.from(n)}t.toArray=e})(kA)),kA}var pH;function IMe(){return pH||(pH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=LMe(),n=FMe(),r=XR();function i(a){if(r.isArrayLike(a))return e.last(n.toArray(a))}t.last=i})(MA)),MA}var EA,gH;function UMe(){return gH||(gH=1,EA=IMe().last),EA}var zMe=UMe();const BMe=hl(zMe);var HMe=["valueAccessor"],$Me=["dataKey","clockWise","id","textBreakAll","zIndex"];function PS(){return PS=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},PS.apply(null,arguments)}function xH(t,e){if(t==null)return{};var n,r,i=VMe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function VMe(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 GMe=t=>Array.isArray(t.value)?BMe(t.value):t.value,qQ=_.createContext(void 0),_4=qQ.Provider,WQ=_.createContext(void 0),qMe=WQ.Provider;function WMe(){return _.useContext(qQ)}function KMe(){return _.useContext(WQ)}function S1(t){var{valueAccessor:e=GMe}=t,n=xH(t,HMe),{dataKey:r,clockWise:i,id:a,textBreakAll:o,zIndex:l}=n,c=xH(n,$Me),u=WMe(),d=KMe(),f=u||d;return!f||!f.length?null:_.createElement(ts,{zIndex:l??bi.label},_.createElement(oi,{className:"recharts-label-list"},f.map((p,m)=>{var x,b=Xr(r)?e(p,m):yr(p&&p.payload,r),y=Xr(a)?{}:{id:"".concat(a,"-").concat(m)};return _.createElement(zd,PS({key:"label-".concat(m)},za(p),c,y,{fill:(x=n.fill)!==null&&x!==void 0?x:p.fill,parentViewBox:p.parentViewBox,value:b,textBreakAll:o,viewBox:p.viewBox,index:m,zIndex:0}))})))}S1.displayName="LabelList";function i2(t){var{label:e}=t;return e?e===!0?_.createElement(S1,{key:"labelList-implicit"}):_.isValidElement(e)||w4(e)?_.createElement(S1,{key:"labelList-implicit",content:e}):typeof e=="object"?_.createElement(S1,PS({key:"labelList-implicit"},e,{type:String(e.type)})):null:null}function p3(){return p3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},p3.apply(null,arguments)}var KQ=t=>{var{cx:e,cy:n,r,className:i}=t,a=tr("recharts-dot",i);return zt(e)&&zt(n)&&zt(r)?_.createElement("circle",p3({},xs(t),KR(t),{className:a,cx:e,cy:n,r})):null},XQ=t=>t.graphicalItems.polarItems,XMe=nt([ri,Jy],GO),a2=nt([XQ,ci,XMe],qO),YMe=nt([a2],WO),s2=nt([YMe,OO],KO),QMe=nt([s2,ci,a2],YO);nt([s2,ci,a2],(t,e,n)=>n.length>0?t.flatMap(r=>n.flatMap(i=>{var a,o=yr(r,(a=e.dataKey)!==null&&a!==void 0?a:i.dataKey);return{value:o,errorDomain:[]}})).filter(Boolean):e?.dataKey!=null?t.map(r=>({value:yr(r,e.dataKey),errorDomain:[]})):t.map(r=>({value:r,errorDomain:[]})));var bH=()=>{},ZMe=nt([s2,ci,a2,JN,ri],e4),JMe=nt([ci,ZO,JO,bH,ZMe,bH,Vn,ri],t4),YQ=nt([ci,Vn,s2,QMe,Zy,ri,JMe],n4),eNe=nt([YQ,ci,Ex],a4);nt([ci,YQ,eNe,ri],o4);var tNe={radiusAxis:{},angleAxis:{}},QQ=Vs({name:"polarAxis",initialState:tNe,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:RXe,removeRadiusAxis:OXe,addAngleAxis:LXe,removeAngleAxis:FXe}=QQ.actions,nNe=QQ.reducer;function yH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function vH(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?yH(Object(n),!0).forEach(function(r){rNe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):yH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function rNe(t,e,n){return(e=iNe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function iNe(t){var e=aNe(t,"string");return typeof e=="symbol"?e:e+""}function aNe(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 sNe=(t,e)=>e,S4=nt([XQ,sNe],(t,e)=>t.filter(n=>n.type==="pie").find(n=>n.id===e)),oNe=[],M4=(t,e,n)=>n?.length===0?oNe:n,ZQ=nt([OO,S4,M4],(t,e,n)=>{var{chartData:r}=t;if(e!=null){var i;if(e?.data!=null&&e.data.length>0?i=e.data:i=r,(!i||!i.length)&&n!=null&&(i=n.map(a=>vH(vH({},e.presentationProps),a.props))),i!=null)return i}}),lNe=nt([ZQ,S4,M4],(t,e,n)=>{if(!(t==null||e==null))return t.map((r,i)=>{var a,o=yr(r,e.nameKey,e.name),l;return n!=null&&(a=n[i])!==null&&a!==void 0&&(a=a.props)!==null&&a!==void 0&&a.fill?l=n[i].props.fill:typeof r=="object"&&r!=null&&"fill"in r?l=r.fill:l=e.fill,{value:Lh(o,e.dataKey),color:l,payload:r,type:e.legendType}})}),cNe=nt([ZQ,S4,M4,na],(t,e,n,r)=>{if(!(e==null||t==null))return u2e({offset:r,pieSettings:e,displayedData:t,cells:n})}),TA={exports:{}},Mr={};var wH;function uNe(){if(wH)return Mr;wH=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),a=Symbol.for("react.consumer"),o=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),u=Symbol.for("react.suspense_list"),d=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),p=Symbol.for("react.view_transition"),m=Symbol.for("react.client.reference");function x(b){if(typeof b=="object"&&b!==null){var y=b.$$typeof;switch(y){case t:switch(b=b.type,b){case n:case i:case r:case c:case u:case p:return b;default:switch(b=b&&b.$$typeof,b){case o:case l:case f:case d:return b;case a:return b;default:return y}}case e:return y}}}return Mr.ContextConsumer=a,Mr.ContextProvider=o,Mr.Element=t,Mr.ForwardRef=l,Mr.Fragment=n,Mr.Lazy=f,Mr.Memo=d,Mr.Portal=e,Mr.Profiler=i,Mr.StrictMode=r,Mr.Suspense=c,Mr.SuspenseList=u,Mr.isContextConsumer=function(b){return x(b)===a},Mr.isContextProvider=function(b){return x(b)===o},Mr.isElement=function(b){return typeof b=="object"&&b!==null&&b.$$typeof===t},Mr.isForwardRef=function(b){return x(b)===l},Mr.isFragment=function(b){return x(b)===n},Mr.isLazy=function(b){return x(b)===f},Mr.isMemo=function(b){return x(b)===d},Mr.isPortal=function(b){return x(b)===e},Mr.isProfiler=function(b){return x(b)===i},Mr.isStrictMode=function(b){return x(b)===r},Mr.isSuspense=function(b){return x(b)===c},Mr.isSuspenseList=function(b){return x(b)===u},Mr.isValidElementType=function(b){return typeof b=="string"||typeof b=="function"||b===n||b===i||b===r||b===c||b===u||typeof b=="object"&&b!==null&&(b.$$typeof===f||b.$$typeof===d||b.$$typeof===o||b.$$typeof===a||b.$$typeof===l||b.$$typeof===m||b.getModuleId!==void 0)},Mr.typeOf=x,Mr}var _H;function dNe(){return _H||(_H=1,TA.exports=uNe()),TA.exports}var hNe=dNe(),SH=t=>typeof t=="string"?t:t?t.displayName||t.name||"Component":"",MH=null,AA=null,JQ=t=>{if(t===MH&&Array.isArray(AA))return AA;var e=[];return _.Children.forEach(t,n=>{Xr(n)||(hNe.isFragment(n)?e=e.concat(JQ(n.props.children)):e.push(n))}),AA=e,MH=t,e};function N4(t,e){var n=[],r=[];return Array.isArray(e)?r=e.map(i=>SH(i)):r=[SH(e)],JQ(t).forEach(i=>{var a=cm(i,"type.displayName")||cm(i,"type.name");a&&r.indexOf(a)!==-1&&n.push(i)}),n}var k4=t=>t&&typeof t=="object"&&"clipDot"in t?!!t.clipDot:!0,CA={},NH;function fNe(){return NH||(NH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){if(typeof n!="object"||n==null)return!1;if(Object.getPrototypeOf(n)===null)return!0;if(Object.prototype.toString.call(n)!=="[object Object]"){const i=n[Symbol.toStringTag];return i==null||!Object.getOwnPropertyDescriptor(n,Symbol.toStringTag)?.writable?!1:n.toString()===`[object ${i}]`}let r=n;for(;Object.getPrototypeOf(r)!==null;)r=Object.getPrototypeOf(r);return Object.getPrototypeOf(n)===r}t.isPlainObject=e})(CA)),CA}var jA,kH;function mNe(){return kH||(kH=1,jA=fNe().isPlainObject),jA}var pNe=mNe();const gNe=hl(pNe);function EH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function TH(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?EH(Object(n),!0).forEach(function(r){xNe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):EH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function xNe(t,e,n){return(e=bNe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function bNe(t){var e=yNe(t,"string");return typeof e=="symbol"?e:e+""}function yNe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function DS(){return DS=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},DS.apply(null,arguments)}var AH=(t,e,n,r,i)=>{var a=n-r,o;return o="M ".concat(t,",").concat(e),o+="L ".concat(t+n,",").concat(e),o+="L ".concat(t+n-a/2,",").concat(e+i),o+="L ".concat(t+n-a/2-r,",").concat(e+i),o+="L ".concat(t,",").concat(e," Z"),o},vNe={x:0,y:0,upperWidth:0,lowerWidth:0,height:0,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},wNe=t=>{var e=li(t,vNe),{x:n,y:r,upperWidth:i,lowerWidth:a,height:o,className:l}=e,{animationEasing:c,animationDuration:u,animationBegin:d,isUpdateAnimationActive:f}=e,p=_.useRef(null),[m,x]=_.useState(-1),b=_.useRef(i),y=_.useRef(a),v=_.useRef(o),S=_.useRef(n),N=_.useRef(r),T=wx(t,"trapezoid-");if(_.useEffect(()=>{if(p.current&&p.current.getTotalLength)try{var j=p.current.getTotalLength();j&&x(j)}catch{}},[]),n!==+n||r!==+r||i!==+i||a!==+a||o!==+o||i===0&&a===0||o===0)return null;var k=tr("recharts-trapezoid",l);if(!f)return _.createElement("g",null,_.createElement("path",DS({},za(e),{className:k,d:AH(n,r,i,a,o)})));var C=b.current,E=y.current,D=v.current,A=S.current,R=N.current,U="0px ".concat(m===-1?1:m,"px"),F="".concat(m,"px 0px"),$=wX(["strokeDasharray"],u,c);return _.createElement(vx,{animationId:T,key:T,canBegin:m>0,duration:u,easing:c,isActive:f,begin:d},j=>{var H=hr(C,i,j),K=hr(E,a,j),V=hr(D,o,j),Q=hr(A,n,j),Z=hr(R,r,j);p.current&&(b.current=H,y.current=K,v.current=V,S.current=Q,N.current=Z);var ae=j>0?{transition:$,strokeDasharray:F}:{strokeDasharray:U};return _.createElement("path",DS({},za(e),{className:k,d:AH(Q,Z,H,K,V),ref:p,style:TH(TH({},ae),e.style)}))})},_Ne=["option","shapeType","propTransformer","activeClassName"];function SNe(t,e){if(t==null)return{};var n,r,i=MNe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function MNe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function CH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function RS(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?CH(Object(n),!0).forEach(function(r){NNe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):CH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function NNe(t,e,n){return(e=kNe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function kNe(t){var e=ENe(t,"string");return typeof e=="symbol"?e:e+""}function ENe(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 TNe(t,e){return RS(RS({},e),t)}function ANe(t,e){return t==="symbols"}function jH(t){var{shapeType:e,elementProps:n}=t;switch(e){case"rectangle":return _.createElement(NX,n);case"trapezoid":return _.createElement(wNe,n);case"sector":return _.createElement(AX,n);case"symbols":if(ANe(e))return _.createElement(WR,n);break;case"curve":return _.createElement(kg,n);default:return null}}function CNe(t){return _.isValidElement(t)?t.props:t}function E4(t){var{option:e,shapeType:n,propTransformer:r=TNe,activeClassName:i="recharts-active-shape"}=t,a=SNe(t,_Ne),o;if(_.isValidElement(e))o=_.cloneElement(e,RS(RS({},a),CNe(e)));else if(typeof e=="function")o=e(a,a.index);else if(gNe(e)&&typeof e!="boolean"){var l=r(e,a);o=_.createElement(jH,{shapeType:n,elementProps:l})}else{var c=a;o=_.createElement(jH,{shapeType:n,elementProps:c})}return a.isActive?_.createElement(oi,{className:i},o):o}var T4=(t,e,n)=>{var r=Lr();return(i,a)=>o=>{t?.(i,a,o),r(uQ({activeIndex:String(a),activeDataKey:e,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}},A4=t=>{var e=Lr();return(n,r)=>i=>{t?.(n,r,i),e(G_e())}},C4=(t,e,n)=>{var r=Lr();return(i,a)=>o=>{t?.(i,a,o),r(q_e({activeIndex:String(a),activeDataKey:e,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}};function o2(t){var{tooltipEntrySettings:e}=t,n=Lr(),r=ra(),i=_.useRef(null);return _.useLayoutEffect(()=>{r||(i.current===null?n(B_e(e)):i.current!==e&&n(H_e({prev:i.current,next:e})),i.current=e)},[e,n,r]),_.useLayoutEffect(()=>()=>{i.current&&(n($_e(i.current)),i.current=null)},[n]),null}function j4(t){var{legendPayload:e}=t,n=Lr(),r=ra(),i=_.useRef(null);return _.useLayoutEffect(()=>{r||(i.current===null?n(xX(e)):i.current!==e&&n(bX({prev:i.current,next:e})),i.current=e)},[n,r,e]),_.useLayoutEffect(()=>()=>{i.current&&(n(yX(i.current)),i.current=null)},[n]),null}function jNe(t){var{legendPayload:e}=t,n=Lr(),r=It(Vn),i=_.useRef(null);return _.useLayoutEffect(()=>{r!=="centric"&&r!=="radial"||(i.current===null?n(xX(e)):i.current!==e&&n(bX({prev:i.current,next:e})),i.current=e)},[n,r,e]),_.useLayoutEffect(()=>()=>{i.current&&(n(yX(i.current)),i.current=null)},[n]),null}var PA,PNe=()=>{var[t]=_.useState(()=>X0("uid-"));return t},DNe=(PA=Dae.useId)!==null&&PA!==void 0?PA:PNe;function eZ(t,e){var n=DNe();return e||(t?"".concat(t,"-").concat(n):n)}var RNe=_.createContext(void 0),l2=t=>{var{id:e,type:n,children:r}=t,i=eZ("recharts-".concat(n),e);return _.createElement(RNe.Provider,{value:i},r(i))},ONe={cartesianItems:[],polarItems:[]},tZ=Vs({name:"graphicalItems",initialState:ONe,reducers:{addCartesianGraphicalItem:{reducer(t,e){t.cartesianItems.push(e.payload)},prepare:Zr()},replaceCartesianGraphicalItem:{reducer(t,e){var{prev:n,next:r}=e.payload,i=Ol(t).cartesianItems.indexOf(n);i>-1&&(t.cartesianItems[i]=r)},prepare:Zr()},removeCartesianGraphicalItem:{reducer(t,e){var n=Ol(t).cartesianItems.indexOf(e.payload);n>-1&&t.cartesianItems.splice(n,1)},prepare:Zr()},addPolarGraphicalItem:{reducer(t,e){t.polarItems.push(e.payload)},prepare:Zr()},removePolarGraphicalItem:{reducer(t,e){var n=Ol(t).polarItems.indexOf(e.payload);n>-1&&t.polarItems.splice(n,1)},prepare:Zr()}}}),{addCartesianGraphicalItem:LNe,replaceCartesianGraphicalItem:FNe,removeCartesianGraphicalItem:INe,addPolarGraphicalItem:UNe,removePolarGraphicalItem:zNe}=tZ.actions,BNe=tZ.reducer,HNe=t=>{var e=Lr(),n=_.useRef(null);return _.useLayoutEffect(()=>{n.current===null?e(LNe(t)):n.current!==t&&e(FNe({prev:n.current,next:t})),n.current=t},[e,t]),_.useLayoutEffect(()=>()=>{n.current&&(e(INe(n.current)),n.current=null)},[e]),null},P4=_.memo(HNe);function $Ne(t){var e=Lr();return _.useLayoutEffect(()=>(e(UNe(t)),()=>{e(zNe(t))}),[e,t]),null}var VNe=["key"],GNe=["onMouseEnter","onClick","onMouseLeave"],qNe=["id"],WNe=["id"];function PH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function pi(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?PH(Object(n),!0).forEach(function(r){KNe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):PH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function KNe(t,e,n){return(e=XNe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function XNe(t){var e=YNe(t,"string");return typeof e=="symbol"?e:e+""}function YNe(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 Nh(){return Nh=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},Nh.apply(null,arguments)}function c2(t,e){if(t==null)return{};var n,r,i=QNe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function QNe(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 ZNe(t){var e=_.useMemo(()=>N4(t.children,cv),[t.children]),n=It(r=>lNe(r,t.id,e));return n==null?null:_.createElement(jNe,{legendPayload:n})}var JNe=_.memo(t=>{var{dataKey:e,nameKey:n,sectors:r,stroke:i,strokeWidth:a,fill:o,name:l,hide:c,tooltipType:u}=t,d={dataDefinedOnItem:r.map(f=>f.tooltipPayload),positions:r.map(f=>f.tooltipPosition),settings:{stroke:i,strokeWidth:a,fill:o,dataKey:e,nameKey:n,name:Lh(l,e),hide:c,type:u,color:o,unit:""}};return _.createElement(o2,{tooltipEntrySettings:d})}),e2e=(t,e)=>t>e?"start":t<e?"end":"middle",t2e=(t,e,n)=>es(typeof e=="function"?e(t):e,n,n*.8),n2e=(t,e,n)=>{var{top:r,left:i,width:a,height:o}=e,l=kX(a,o),c=i+es(t.cx,a,a/2),u=r+es(t.cy,o,o/2),d=es(t.innerRadius,l,0),f=t2e(n,t.outerRadius,l),p=t.maxRadius||Math.sqrt(a*a+o*o)/2;return{cx:c,cy:u,innerRadius:d,outerRadius:f,maxRadius:p}},r2e=(t,e)=>{var n=ya(e-t),r=Math.min(Math.abs(e-t),360);return n*r};function i2e(t){return t&&typeof t=="object"&&"className"in t&&typeof t.className=="string"?t.className:""}var a2e=(t,e)=>{if(_.isValidElement(t))return _.cloneElement(t,e);if(typeof t=="function")return t(e);var n=tr("recharts-pie-label-line",typeof t!="boolean"?t.className:""),{key:r}=e,i=c2(e,VNe);return _.createElement(kg,Nh({},i,{type:"linear",className:n}))},s2e=(t,e,n)=>{if(_.isValidElement(t))return _.cloneElement(t,e);var r=n;if(typeof t=="function"&&(r=t(e),_.isValidElement(r)))return r;var i=tr("recharts-pie-label-text",i2e(t));return _.createElement(r2,Nh({},e,{alignmentBaseline:"middle",className:i}),r)};function o2e(t){var{sectors:e,props:n,showLabels:r}=t,{label:i,labelLine:a,dataKey:o}=n;if(!r||!i||!e)return null;var l=xs(n),c=lm(i),u=lm(a),d=typeof i=="object"&&"offsetRadius"in i&&typeof i.offsetRadius=="number"&&i.offsetRadius||20,f=e.map((p,m)=>{var x=(p.startAngle+p.endAngle)/2,b=zi(p.cx,p.cy,p.outerRadius+d,x),y=pi(pi(pi(pi({},l),p),{},{stroke:"none"},c),{},{index:m,textAnchor:e2e(b.x,p.cx)},b),v=pi(pi(pi(pi({},l),p),{},{fill:"none",stroke:p.fill},u),{},{index:m,points:[zi(p.cx,p.cy,p.outerRadius,x),b],key:"line"});return _.createElement(ts,{zIndex:bi.label,key:"label-".concat(p.startAngle,"-").concat(p.endAngle,"-").concat(p.midAngle,"-").concat(m)},_.createElement(oi,null,a&&a2e(a,v),s2e(i,y,yr(p,o))))});return _.createElement(oi,{className:"recharts-pie-labels"},f)}function l2e(t){var{sectors:e,props:n,showLabels:r}=t,{label:i}=n;return typeof i=="object"&&i!=null&&"position"in i?_.createElement(i2,{label:i}):_.createElement(o2e,{sectors:e,props:n,showLabels:r})}function c2e(t){var{sectors:e,activeShape:n,inactiveShape:r,allOtherPieProps:i,shape:a,id:o}=t,l=It(Mh),c=It(g4),u=It(j1e),{onMouseEnter:d,onClick:f,onMouseLeave:p}=i,m=c2(i,GNe),x=T4(d,i.dataKey,o),b=A4(p),y=C4(f,i.dataKey,o);return e==null||e.length===0?null:_.createElement(_.Fragment,null,e.map((v,S)=>{if(v?.startAngle===0&&v?.endAngle===0&&e.length!==1)return null;var N=u==null||u===o,T=String(S)===l&&(c==null||i.dataKey===c)&&N,k=l?r:null,C=n&&T?n:k,E=pi(pi({},v),{},{stroke:v.stroke,tabIndex:-1,[rX]:S,[iX]:i.dataKey});return _.createElement(oi,Nh({key:"sector-".concat(v?.startAngle,"-").concat(v?.endAngle,"-").concat(v.midAngle,"-").concat(S),tabIndex:-1,className:"recharts-pie-sector"},zy(m,v,S),{onMouseEnter:x(v,S),onMouseLeave:b(v,S),onClick:y(v,S)}),_.createElement(E4,Nh({option:a??C,index:S,shapeType:"sector",isActive:T},E)))}))}function u2e(t){var e,{pieSettings:n,displayedData:r,cells:i,offset:a}=t,{cornerRadius:o,startAngle:l,endAngle:c,dataKey:u,nameKey:d,tooltipType:f}=n,p=Math.abs(n.minAngle),m=r2e(l,c),x=Math.abs(m),b=r.length<=1?0:(e=n.paddingAngle)!==null&&e!==void 0?e:0,y=r.filter(C=>yr(C,u,0)!==0).length,v=(x>=360?y:y-1)*b,S=x-y*p-v,N=r.reduce((C,E)=>{var D=yr(E,u,0);return C+(zt(D)?D:0)},0),T;if(N>0){var k;T=r.map((C,E)=>{var D=yr(C,u,0),A=yr(C,d,E),R=n2e(n,a,C),U=(zt(D)?D:0)/N,F,$=pi(pi({},C),i&&i[E]&&i[E].props);E?F=k.endAngle+ya(m)*b*(D!==0?1:0):F=l;var j=F+ya(m)*((D!==0?p:0)+U*S),H=(F+j)/2,K=(R.innerRadius+R.outerRadius)/2,V=[{name:A,value:D,payload:$,dataKey:u,type:f}],Q=zi(R.cx,R.cy,K,H);return k=pi(pi(pi(pi({},n.presentationProps),{},{percent:U,cornerRadius:typeof o=="string"?parseFloat(o):o,name:A,tooltipPayload:V,midAngle:H,middleRadius:K,tooltipPosition:Q},$),R),{},{value:D,dataKey:u,startAngle:F,endAngle:j,payload:$,paddingAngle:ya(m)*b}),k})}return T}function d2e(t){var{showLabels:e,sectors:n,children:r}=t,i=_.useMemo(()=>!e||!n?[]:n.map(a=>({value:a.value,payload:a.payload,clockWise:!1,parentViewBox:void 0,viewBox:{cx:a.cx,cy:a.cy,innerRadius:a.innerRadius,outerRadius:a.outerRadius,startAngle:a.startAngle,endAngle:a.endAngle,clockWise:!1},fill:a.fill})),[n,e]);return _.createElement(qMe,{value:e?i:void 0},r)}function h2e(t){var{props:e,previousSectorsRef:n,id:r}=t,{sectors:i,isAnimationActive:a,animationBegin:o,animationDuration:l,animationEasing:c,activeShape:u,inactiveShape:d,onAnimationStart:f,onAnimationEnd:p}=e,m=wx(e,"recharts-pie-"),x=n.current,[b,y]=_.useState(!1),v=_.useCallback(()=>{typeof p=="function"&&p(),y(!1)},[p]),S=_.useCallback(()=>{typeof f=="function"&&f(),y(!0)},[f]);return _.createElement(d2e,{showLabels:!b,sectors:i},_.createElement(vx,{animationId:m,begin:o,duration:l,isActive:a,easing:c,onAnimationStart:S,onAnimationEnd:v,key:m},N=>{var T=[],k=i&&i[0],C=k?.startAngle;return i?.forEach((E,D)=>{var A=x&&x[D],R=D>0?cm(E,"paddingAngle",0):0;if(A){var U=hr(A.endAngle-A.startAngle,E.endAngle-E.startAngle,N),F=pi(pi({},E),{},{startAngle:C+R,endAngle:C+U+R});T.push(F),C=F.endAngle}else{var{endAngle:$,startAngle:j}=E,H=hr(0,$-j,N),K=pi(pi({},E),{},{startAngle:C+R,endAngle:C+H+R});T.push(K),C=K.endAngle}}),n.current=T,_.createElement(oi,null,_.createElement(c2e,{sectors:T,activeShape:u,inactiveShape:d,allOtherPieProps:e,shape:e.shape,id:r}))}),_.createElement(l2e,{showLabels:!b,sectors:i,props:e}),e.children)}var f2e={animationBegin:400,animationDuration:1500,animationEasing:"ease",cx:"50%",cy:"50%",dataKey:"value",endAngle:360,fill:"#808080",hide:!1,innerRadius:0,isAnimationActive:"auto",label:!1,labelLine:!0,legendType:"rect",minAngle:0,nameKey:"name",outerRadius:"80%",paddingAngle:0,rootTabIndex:0,startAngle:0,stroke:"#fff",zIndex:bi.area};function m2e(t){var{id:e}=t,n=c2(t,qNe),{hide:r,className:i,rootTabIndex:a}=t,o=_.useMemo(()=>N4(t.children,cv),[t.children]),l=It(d=>cNe(d,e,o)),c=_.useRef(null),u=tr("recharts-pie",i);return r||l==null?(c.current=null,_.createElement(oi,{tabIndex:a,className:u})):_.createElement(ts,{zIndex:t.zIndex},_.createElement(JNe,{dataKey:t.dataKey,nameKey:t.nameKey,sectors:l,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,tooltipType:t.tooltipType}),_.createElement(oi,{tabIndex:a,className:u},_.createElement(h2e,{props:pi(pi({},n),{},{sectors:l}),previousSectorsRef:c,id:e})))}function nZ(t){var e=li(t,f2e),{id:n}=e,r=c2(e,WNe),i=xs(r);return _.createElement(l2,{id:n,type:"pie"},a=>_.createElement(_.Fragment,null,_.createElement($Ne,{type:"pie",id:a,data:r.data,dataKey:r.dataKey,hide:r.hide,angleAxisId:0,radiusAxisId:0,name:r.name,nameKey:r.nameKey,tooltipType:r.tooltipType,legendType:r.legendType,fill:r.fill,cx:r.cx,cy:r.cy,startAngle:r.startAngle,endAngle:r.endAngle,paddingAngle:r.paddingAngle,minAngle:r.minAngle,innerRadius:r.innerRadius,outerRadius:r.outerRadius,cornerRadius:r.cornerRadius,presentationProps:i,maxRadius:e.maxRadius}),_.createElement(ZNe,Nh({},r,{id:a})),_.createElement(m2e,Nh({},r,{id:a}))))}nZ.displayName="Pie";var p2e=["points"];function DH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function DA(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?DH(Object(n),!0).forEach(function(r){g2e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):DH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function g2e(t,e,n){return(e=x2e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function x2e(t){var e=b2e(t,"string");return typeof e=="symbol"?e:e+""}function b2e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function OS(){return OS=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},OS.apply(null,arguments)}function y2e(t,e){if(t==null)return{};var n,r,i=v2e(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function v2e(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 w2e(t){var{option:e,dotProps:n,className:r}=t;if(_.isValidElement(e))return _.cloneElement(e,n);if(typeof e=="function")return e(n);var i=tr(r,typeof e!="boolean"?e.className:""),a=n??{},{points:o}=a,l=y2e(a,p2e);return _.createElement(KQ,OS({},l,{className:i}))}function _2e(t,e){return t==null?!1:e?!0:t.length===1}function rZ(t){var{points:e,dot:n,className:r,dotClassName:i,dataKey:a,baseProps:o,needClip:l,clipPathId:c,zIndex:u=bi.scatter}=t;if(!_2e(e,n))return null;var d=k4(n),f=Jfe(n),p=e.map((x,b)=>{var y,v,S=DA(DA(DA({r:3},o),f),{},{index:b,cx:(y=x.x)!==null&&y!==void 0?y:void 0,cy:(v=x.y)!==null&&v!==void 0?v:void 0,dataKey:a,value:x.value,payload:x.payload,points:e});return _.createElement(w2e,{key:"dot-".concat(b),option:n,dotProps:S,className:i})}),m={};return l&&c!=null&&(m.clipPath="url(#clipPath-".concat(d?"":"dots-").concat(c,")")),_.createElement(ts,{zIndex:u},_.createElement(oi,OS({className:r},m),p))}function RH(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 OH(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?RH(Object(n),!0).forEach(function(r){S2e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):RH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function S2e(t,e,n){return(e=M2e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function M2e(t){var e=N2e(t,"string");return typeof e=="symbol"?e:e+""}function N2e(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 k2e={xAxis:{},yAxis:{},zAxis:{}},iZ=Vs({name:"cartesianAxis",initialState:k2e,reducers:{addXAxis:{reducer(t,e){t.xAxis[e.payload.id]=e.payload},prepare:Zr()},replaceXAxis:{reducer(t,e){var{prev:n,next:r}=e.payload;t.xAxis[n.id]!==void 0&&(n.id!==r.id&&delete t.xAxis[n.id],t.xAxis[r.id]=r)},prepare:Zr()},removeXAxis:{reducer(t,e){delete t.xAxis[e.payload.id]},prepare:Zr()},addYAxis:{reducer(t,e){t.yAxis[e.payload.id]=e.payload},prepare:Zr()},replaceYAxis:{reducer(t,e){var{prev:n,next:r}=e.payload;t.yAxis[n.id]!==void 0&&(n.id!==r.id&&delete t.yAxis[n.id],t.yAxis[r.id]=r)},prepare:Zr()},removeYAxis:{reducer(t,e){delete t.yAxis[e.payload.id]},prepare:Zr()},addZAxis:{reducer(t,e){t.zAxis[e.payload.id]=e.payload},prepare:Zr()},replaceZAxis:{reducer(t,e){var{prev:n,next:r}=e.payload;t.zAxis[n.id]!==void 0&&(n.id!==r.id&&delete t.zAxis[n.id],t.zAxis[r.id]=r)},prepare:Zr()},removeZAxis:{reducer(t,e){delete t.zAxis[e.payload.id]},prepare:Zr()},updateYAxisWidth(t,e){var{id:n,width:r}=e.payload,i=t.yAxis[n];if(i){var a=i.widthHistory||[];if(a.length===3&&a[0]===a[2]&&r===a[1]&&r!==i.width&&Math.abs(r-a[0])<=1)return;var o=[...a,r].slice(-3);t.yAxis[n]=OH(OH({},t.yAxis[n]),{},{width:r,widthHistory:o})}}}}),{addXAxis:E2e,replaceXAxis:T2e,removeXAxis:A2e,addYAxis:C2e,replaceYAxis:j2e,removeYAxis:P2e,addZAxis:IXe,replaceZAxis:UXe,removeZAxis:zXe,updateYAxisWidth:D2e}=iZ.actions,R2e=iZ.reducer,O2e=nt([na],t=>({top:t.top,bottom:t.bottom,left:t.left,right:t.right})),L2e=nt([O2e,qu,Wu],(t,e,n)=>{if(!(!t||e==null||n==null))return{x:t.left,y:t.top,width:Math.max(0,e-t.left-t.right),height:Math.max(0,n-t.top-t.bottom)}}),u2=()=>It(L2e),F2e=()=>It(L1e);function LH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function RA(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?LH(Object(n),!0).forEach(function(r){I2e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):LH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function I2e(t,e,n){return(e=U2e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function U2e(t){var e=z2e(t,"string");return typeof e=="symbol"?e:e+""}function z2e(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 B2e=t=>{var{point:e,childIndex:n,mainColor:r,activeDot:i,dataKey:a,clipPath:o}=t;if(i===!1||e.x==null||e.y==null)return null;var l={index:n,dataKey:a,cx:e.x,cy:e.y,r:4,fill:r??"none",strokeWidth:2,stroke:"#fff",payload:e.payload,value:e.value},c=RA(RA(RA({},l),lm(i)),KR(i)),u;return _.isValidElement(i)?u=_.cloneElement(i,c):typeof i=="function"?u=i(c):u=_.createElement(KQ,c),_.createElement(oi,{className:"recharts-active-dot",clipPath:o},u)};function g3(t){var{points:e,mainColor:n,activeDot:r,itemDataKey:i,clipPath:a,zIndex:o=bi.activeDot}=t,l=It(Mh),c=F2e();if(e==null||c==null)return null;var u=e.find(d=>c.includes(d.payload));return Xr(u)?null:_.createElement(ts,{zIndex:o},_.createElement(B2e,{point:u,childIndex:Number(l),mainColor:n,dataKey:i,activeDot:r,clipPath:a}))}var H2e="Invariant failed";function $2e(t,e){throw new Error(H2e)}var V2e=["x","y"];function x3(){return x3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},x3.apply(null,arguments)}function FH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Ib(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?FH(Object(n),!0).forEach(function(r){G2e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):FH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function G2e(t,e,n){return(e=q2e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function q2e(t){var e=W2e(t,"string");return typeof e=="symbol"?e:e+""}function W2e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function K2e(t,e){if(t==null)return{};var n,r,i=X2e(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function X2e(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 Y2e(t,e){var{x:n,y:r}=t,i=K2e(t,V2e),a="".concat(n),o=parseInt(a,10),l="".concat(r),c=parseInt(l,10),u="".concat(e.height||i.height),d=parseInt(u,10),f="".concat(e.width||i.width),p=parseInt(f,10);return Ib(Ib(Ib(Ib(Ib({},e),i),o?{x:o}:{}),c?{y:c}:{}),{},{height:d,width:p,name:e.name,radius:e.radius})}function LS(t){return _.createElement(E4,x3({shapeType:"rectangle",propTransformer:Y2e,activeClassName:"recharts-active-bar"},t))}var Q2e=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return(r,i)=>{if(zt(e))return e;var a=zt(r)||Xr(r);return a?e(r,i):(a||$2e(),n)}},Z2e={},aZ=Vs({name:"errorBars",initialState:Z2e,reducers:{addErrorBar:(t,e)=>{var{itemId:n,errorBar:r}=e.payload;t[n]||(t[n]=[]),t[n].push(r)},replaceErrorBar:(t,e)=>{var{itemId:n,prev:r,next:i}=e.payload;t[n]&&(t[n]=t[n].map(a=>a.dataKey===r.dataKey&&a.direction===r.direction?i:a))},removeErrorBar:(t,e)=>{var{itemId:n,errorBar:r}=e.payload;t[n]&&(t[n]=t[n].filter(i=>i.dataKey!==r.dataKey||i.direction!==r.direction))}}}),{addErrorBar:BXe,replaceErrorBar:HXe,removeErrorBar:$Xe}=aZ.actions,J2e=aZ.reducer,eke=["children"];function tke(t,e){if(t==null)return{};var n,r,i=nke(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function nke(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 rke={data:[],xAxisId:"xAxis-0",yAxisId:"yAxis-0",dataPointFormatter:()=>({x:0,y:0,value:0}),errorBarOffset:0},ike=_.createContext(rke);function sZ(t){var{children:e}=t,n=tke(t,eke);return _.createElement(ike.Provider,{value:n},e)}function d2(t,e){var n,r,i=It(u=>Ec(u,t)),a=It(u=>Tc(u,e)),o=(n=i?.allowDataOverflow)!==null&&n!==void 0?n:fa.allowDataOverflow,l=(r=a?.allowDataOverflow)!==null&&r!==void 0?r:ma.allowDataOverflow,c=o||l;return{needClip:c,needClipX:o,needClipY:l}}function D4(t){var{xAxisId:e,yAxisId:n,clipPathId:r}=t,i=u2(),{needClipX:a,needClipY:o,needClip:l}=d2(e,n);if(!l||!i)return null;var{x:c,y:u,width:d,height:f}=i;return _.createElement("clipPath",{id:"clipPath-".concat(r)},_.createElement("rect",{x:a?c:c-d/2,y:o?u:u-f/2,width:a?d:d*2,height:o?f:f*2}))}function ake(t,e){return t&&typeof t=="object"&&"zIndex"in t&&typeof t.zIndex=="number"&&vr(t.zIndex)?t.zIndex:e}var OA={exports:{}},LA={};var IH;function ske(){if(IH)return LA;IH=1;var t=px();function e(c,u){return c===u&&(c!==0||1/c===1/u)||c!==c&&u!==u}var n=typeof Object.is=="function"?Object.is:e,r=t.useSyncExternalStore,i=t.useRef,a=t.useEffect,o=t.useMemo,l=t.useDebugValue;return LA.useSyncExternalStoreWithSelector=function(c,u,d,f,p){var m=i(null);if(m.current===null){var x={hasValue:!1,value:null};m.current=x}else x=m.current;m=o(function(){function y(k){if(!v){if(v=!0,S=k,k=f(k),p!==void 0&&x.hasValue){var C=x.value;if(p(C,k))return N=C}return N=k}if(C=N,n(S,k))return C;var E=f(k);return p!==void 0&&p(C,E)?(S=k,C):(S=k,N=E)}var v=!1,S,N,T=d===void 0?null:d;return[function(){return y(u())},T===null?void 0:function(){return y(T())}]},[u,d,f,p]);var b=r(c,m[0],m[1]);return a(function(){x.hasValue=!0,x.value=b},[b]),l(b),b},LA}var UH;function oke(){return UH||(UH=1,OA.exports=ske()),OA.exports}oke();function lke(t){t()}function cke(){let t=null,e=null;return{clear(){t=null,e=null},notify(){lke(()=>{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 zH={notify(){},get:()=>[]};function uke(t,e){let n,r=zH,i=0,a=!1;function o(b){d();const y=r.subscribe(b);let v=!1;return()=>{v||(v=!0,y(),f())}}function l(){r.notify()}function c(){x.onStateChange&&x.onStateChange()}function u(){return a}function d(){i++,n||(n=t.subscribe(c),r=cke())}function f(){i--,n&&i===0&&(n(),n=void 0,r.clear(),r=zH)}function p(){a||(a=!0,d())}function m(){a&&(a=!1,f())}const x={addNestedSub:o,notifyNestedSubs:l,handleChangeWrapper:c,isSubscribed:u,trySubscribe:p,tryUnsubscribe:m,getListeners:()=>r};return x}var dke=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",hke=dke(),fke=()=>typeof navigator<"u"&&navigator.product==="ReactNative",mke=fke(),pke=()=>hke||mke?_.useLayoutEffect:_.useEffect,gke=pke();function BH(t,e){return t===e?t!==0||e!==0||1/t===1/e:t!==t&&e!==e}function xke(t,e){if(BH(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])||!BH(t[n[i]],e[n[i]]))return!1;return!0}var bke=Symbol.for("react-redux-context"),yke=typeof globalThis<"u"?globalThis:{};function vke(){if(!_.createContext)return{};const t=yke[bke]??=new Map;let e=t.get(_.createContext);return e||(e=_.createContext(null),t.set(_.createContext,e)),e}var wke=vke();function _ke(t){const{children:e,context:n,serverState:r,store:i}=t,a=_.useMemo(()=>{const c=uke(i);return{store:i,subscription:c,getServerState:r?()=>r:void 0}},[i,r]),o=_.useMemo(()=>i.getState(),[i]);gke(()=>{const{subscription:c}=a;return c.onStateChange=c.notifyNestedSubs,c.trySubscribe(),o!==i.getState()&&c.notifyNestedSubs(),()=>{c.tryUnsubscribe(),c.onStateChange=void 0}},[a,o]);const l=n||wke;return _.createElement(l.Provider,{value:a},e)}var Ske=_ke,Mke=new Set(["axisLine","tickLine","activeBar","activeDot","activeLabel","activeShape","allowEscapeViewBox","background","cursor","dot","label","line","margin","padding","position","shape","style","tick","wrapperStyle"]);function Nke(t,e){return t==null&&e==null?!0:typeof t=="number"&&typeof e=="number"?t===e||t!==t&&e!==e:t===e}function uv(t,e){var n=new Set([...Object.keys(t),...Object.keys(e)]);for(var r of n)if(Mke.has(r)){if(t[r]==null&&e[r]==null)continue;if(!xke(t[r],e[r]))return!1}else if(!Nke(t[r],e[r]))return!1;return!0}var kke=["onMouseEnter","onMouseLeave","onClick"],Eke=["value","background","tooltipPosition"],Tke=["id"],Ake=["onMouseEnter","onClick","onMouseLeave"];function Hu(){return Hu=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Hu.apply(null,arguments)}function HH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function ds(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?HH(Object(n),!0).forEach(function(r){Cke(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):HH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Cke(t,e,n){return(e=jke(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function jke(t){var e=Pke(t,"string");return typeof e=="symbol"?e:e+""}function Pke(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function FS(t,e){if(t==null)return{};var n,r,i=Dke(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function Dke(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 Rke=t=>{var{dataKey:e,name:n,fill:r,legendType:i,hide:a}=t;return[{inactive:a,dataKey:e,type:i,color:r,value:Lh(n,e),payload:t}]},Oke=_.memo(t=>{var{dataKey:e,stroke:n,strokeWidth:r,fill:i,name:a,hide:o,unit:l,tooltipType:c}=t,u={dataDefinedOnItem:void 0,positions:void 0,settings:{stroke:n,strokeWidth:r,fill:i,dataKey:e,nameKey:void 0,name:Lh(a,e),hide:o,type:c,color:i,unit:l}};return _.createElement(o2,{tooltipEntrySettings:u})});function Lke(t){var e=It(Mh),{data:n,dataKey:r,background:i,allOtherBarProps:a}=t,{onMouseEnter:o,onMouseLeave:l,onClick:c}=a,u=FS(a,kke),d=T4(o,r),f=A4(l),p=C4(c,r);if(!i||n==null)return null;var m=lm(i);return _.createElement(ts,{zIndex:ake(i,bi.barBackground)},n.map((x,b)=>{var{value:y,background:v,tooltipPosition:S}=x,N=FS(x,Eke);if(!v)return null;var T=d(x,b),k=f(x,b),C=p(x,b),E=ds(ds(ds(ds(ds({option:i,isActive:String(b)===e},N),{},{fill:"#eee"},v),m),zy(u,x,b)),{},{onMouseEnter:T,onMouseLeave:k,onClick:C,dataKey:r,index:b,className:"recharts-bar-background-rectangle"});return _.createElement(LS,Hu({key:"background-bar-".concat(b)},E))}))}function Fke(t){var{showLabels:e,children:n,rects:r}=t,i=r?.map(a=>{var o={x:a.x,y:a.y,width:a.width,lowerWidth:a.width,upperWidth:a.width,height:a.height};return ds(ds({},o),{},{value:a.value,payload:a.payload,parentViewBox:a.parentViewBox,viewBox:o,fill:a.fill})});return _.createElement(_4,{value:e?i:void 0},n)}function Ike(t){var{shape:e,activeBar:n,baseProps:r,entry:i,index:a,dataKey:o}=t,l=It(Mh),c=It(g4),u=n&&String(a)===l&&(c==null||o===c),d=u?n:e;return u?_.createElement(ts,{zIndex:bi.activeBar},_.createElement(LS,Hu({},r,{name:String(r.name)},i,{isActive:u,option:d,index:a,dataKey:o}))):_.createElement(LS,Hu({},r,{name:String(r.name)},i,{isActive:u,option:d,index:a,dataKey:o}))}function Uke(t){var{shape:e,baseProps:n,entry:r,index:i,dataKey:a}=t;return _.createElement(LS,Hu({},n,{name:String(n.name)},r,{isActive:!1,option:e,index:i,dataKey:a}))}function zke(t){var e,{data:n,props:r}=t,i=(e=xs(r))!==null&&e!==void 0?e:{},{id:a}=i,o=FS(i,Tke),{shape:l,dataKey:c,activeBar:u}=r,{onMouseEnter:d,onClick:f,onMouseLeave:p}=r,m=FS(r,Ake),x=T4(d,c),b=A4(p),y=C4(f,c);return n?_.createElement(_.Fragment,null,n.map((v,S)=>_.createElement(oi,Hu({key:"rectangle-".concat(v?.x,"-").concat(v?.y,"-").concat(v?.value,"-").concat(S),className:"recharts-bar-rectangle"},zy(m,v,S),{onMouseEnter:x(v,S),onMouseLeave:b(v,S),onClick:y(v,S)}),u?_.createElement(Ike,{shape:l,activeBar:u,baseProps:o,entry:v,index:S,dataKey:c}):_.createElement(Uke,{shape:l,baseProps:o,entry:v,index:S,dataKey:c})))):null}function Bke(t){var{props:e,previousRectanglesRef:n}=t,{data:r,layout:i,isAnimationActive:a,animationBegin:o,animationDuration:l,animationEasing:c,onAnimationEnd:u,onAnimationStart:d}=e,f=n.current,p=wx(e,"recharts-bar-"),[m,x]=_.useState(!1),b=!m,y=_.useCallback(()=>{typeof u=="function"&&u(),x(!1)},[u]),v=_.useCallback(()=>{typeof d=="function"&&d(),x(!0)},[d]);return _.createElement(Fke,{showLabels:b,rects:r},_.createElement(vx,{animationId:p,begin:o,duration:l,isActive:a,easing:c,onAnimationEnd:y,onAnimationStart:v,key:p},S=>{var N=S===1?r:r?.map((T,k)=>{var C=f&&f[k];if(C)return ds(ds({},T),{},{x:hr(C.x,T.x,S),y:hr(C.y,T.y,S),width:hr(C.width,T.width,S),height:hr(C.height,T.height,S)});if(i==="horizontal"){var E=hr(0,T.height,S),D=hr(T.stackedBarStart,T.y,S);return ds(ds({},T),{},{y:D,height:E})}var A=hr(0,T.width,S),R=hr(T.stackedBarStart,T.x,S);return ds(ds({},T),{},{width:A,x:R})});return S>0&&(n.current=N??null),N==null?null:_.createElement(oi,null,_.createElement(zke,{props:e,data:N}))}),_.createElement(i2,{label:e.label}),e.children)}function Hke(t){var e=_.useRef(null);return _.createElement(Bke,{previousRectanglesRef:e,props:t})}var oZ=0,$ke=(t,e)=>{var n=Array.isArray(t.value)?t.value[1]:t.value;return{x:t.x,y:t.y,value:n,errorVal:yr(t,e)}};class Vke extends _.PureComponent{render(){var{hide:e,data:n,dataKey:r,className:i,xAxisId:a,yAxisId:o,needClip:l,background:c,id:u}=this.props;if(e||n==null)return null;var d=tr("recharts-bar",i),f=u;return _.createElement(oi,{className:d,id:u},l&&_.createElement("defs",null,_.createElement(D4,{clipPathId:f,xAxisId:a,yAxisId:o})),_.createElement(oi,{className:"recharts-bar-rectangles",clipPath:l?"url(#clipPath-".concat(f,")"):void 0},_.createElement(Lke,{data:n,dataKey:r,background:c,allOtherBarProps:this.props}),_.createElement(Hke,this.props)))}}var Gke={activeBar:!1,animationBegin:0,animationDuration:400,animationEasing:"ease",background:!1,hide:!1,isAnimationActive:"auto",label:!1,legendType:"rect",minPointSize:oZ,xAxisId:0,yAxisId:0,zIndex:bi.bar};function qke(t){var{xAxisId:e,yAxisId:n,hide:r,legendType:i,minPointSize:a,activeBar:o,animationBegin:l,animationDuration:c,animationEasing:u,isAnimationActive:d}=t,{needClip:f}=d2(e,n),p=Em(),m=ra(),x=N4(t.children,cv),b=It(S=>vEe(S,e,n,m,t.id,x));if(p!=="vertical"&&p!=="horizontal")return null;var y,v=b?.[0];return v==null||v.height==null||v.width==null?y=0:y=p==="vertical"?v.height/2:v.width/2,_.createElement(sZ,{xAxisId:e,yAxisId:n,data:b,dataPointFormatter:$ke,errorBarOffset:y},_.createElement(Vke,Hu({},t,{layout:p,needClip:f,data:b,xAxisId:e,yAxisId:n,hide:r,legendType:i,minPointSize:a,activeBar:o,animationBegin:l,animationDuration:c,animationEasing:u,isAnimationActive:d})))}function Wke(t){var{layout:e,barSettings:{dataKey:n,minPointSize:r},pos:i,bandSize:a,xAxis:o,yAxis:l,xAxisTicks:c,yAxisTicks:u,stackedData:d,displayedData:f,offset:p,cells:m,parentViewBox:x,dataStartIndex:b}=t,y=e==="horizontal"?l:o,v=d?y.scale.domain():null,S=gxe({numericAxis:y}),N=y.scale(S);return f.map((T,k)=>{var C,E,D,A,R,U;d?C=dxe(d[k+b],v):(C=yr(T,n),Array.isArray(C)||(C=[S,C]));var F=Q2e(r,oZ)(C[1],k);if(e==="horizontal"){var $,[j,H]=[l.scale(C[0]),l.scale(C[1])];E=a8({axis:o,ticks:c,bandSize:a,offset:i.offset,entry:T,index:k}),D=($=H??j)!==null&&$!==void 0?$:void 0,A=i.size;var K=j-H;if(R=$s(K)?0:K,U={x:E,y:p.top,width:A,height:p.height},Math.abs(F)>0&&Math.abs(R)<Math.abs(F)){var V=ya(R||F)*(Math.abs(F)-Math.abs(R));D-=V,R+=V}}else{var[Q,Z]=[o.scale(C[0]),o.scale(C[1])];if(E=Q,D=a8({axis:l,ticks:u,bandSize:a,offset:i.offset,entry:T,index:k}),A=Z-Q,R=i.size,U={x:p.left,y:D,width:p.width,height:R},Math.abs(F)>0&&Math.abs(A)<Math.abs(F)){var ae=ya(A||F)*(Math.abs(F)-Math.abs(A));A+=ae}}if(E==null||D==null||A==null||R==null)return null;var B=ds(ds({},T),{},{stackedBarStart:N,x:E,y:D,width:A,height:R,value:d?C:C[1],payload:T,background:U,tooltipPosition:{x:E+A/2,y:D+R/2},parentViewBox:x},m&&m[k]&&m[k].props);return B}).filter(Boolean)}function Kke(t){var e=li(t,Gke),n=ra();return _.createElement(l2,{id:e.id,type:"bar"},r=>_.createElement(_.Fragment,null,_.createElement(j4,{legendPayload:Rke(e)}),_.createElement(Oke,{dataKey:e.dataKey,stroke:e.stroke,strokeWidth:e.strokeWidth,fill:e.fill,name:e.name,hide:e.hide,unit:e.unit,tooltipType:e.tooltipType}),_.createElement(P4,{type:"bar",id:r,data:void 0,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,dataKey:e.dataKey,stackId:tX(e.stackId),hide:e.hide,barSize:e.barSize,minPointSize:e.minPointSize,maxBarSize:e.maxBarSize,isPanorama:n}),_.createElement(ts,{zIndex:e.zIndex},_.createElement(qke,Hu({},e,{id:r})))))}var lZ=_.memo(Kke,uv);lZ.displayName="Bar";function $H(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Xw(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?$H(Object(n),!0).forEach(function(r){Xke(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):$H(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Xke(t,e,n){return(e=Yke(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Yke(t){var e=Qke(t,"string");return typeof e=="symbol"?e:e+""}function Qke(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var Zke=(t,e)=>e,Jke=(t,e,n)=>n,eEe=(t,e,n,r)=>r,tEe=(t,e,n,r,i)=>i,dv=nt([tv,tEe],(t,e)=>t.filter(n=>n.type==="bar").find(n=>n.id===e)),nEe=nt([dv],t=>t?.maxBarSize),rEe=(t,e,n,r,i,a)=>a,VH=(t,e,n)=>{var r=n??t;if(!Xr(r))return es(r,e,0)},iEe=nt([Vn,tv,Zke,Jke,eEe],(t,e,n,r,i)=>e.filter(a=>t==="horizontal"?a.xAxisId===n:a.yAxisId===r).filter(a=>a.isPanorama===i).filter(a=>a.hide===!1).filter(a=>a.type==="bar")),aEe=(t,e,n,r)=>{var i=Vn(t);return i==="horizontal"?ly(t,"yAxis",n,r):ly(t,"xAxis",e,r)},sEe=(t,e,n)=>{var r=Vn(t);return r==="horizontal"?I6(t,"xAxis",e):I6(t,"yAxis",n)},oEe=(t,e,n)=>{var r={},i=t.filter(XN),a=t.filter(u=>u.stackId==null),o=i.reduce((u,d)=>(u[d.stackId]||(u[d.stackId]=[]),u[d.stackId].push(d),u),r),l=Object.entries(o).map(u=>{var[d,f]=u,p=f.map(x=>x.dataKey),m=VH(e,n,f[0].barSize);return{stackId:d,dataKeys:p,barSize:m}}),c=a.map(u=>{var d=[u.dataKey].filter(p=>p!=null),f=VH(e,n,u.barSize);return{stackId:void 0,dataKeys:d,barSize:f}});return[...l,...c]},lEe=nt([iEe,Dwe,sEe],oEe),cEe=(t,e,n,r,i)=>{var a,o,l=dv(t,e,n,r,i);if(l!=null){var c=Vn(t),u=NY(t),{maxBarSize:d}=l,f=Xr(d)?u:d,p,m;return c==="horizontal"?(p=bc(t,"xAxis",e,r),m=xc(t,"xAxis",e,r)):(p=bc(t,"yAxis",n,r),m=xc(t,"yAxis",n,r)),(a=(o=wh(p,m,!0))!==null&&o!==void 0?o:f)!==null&&a!==void 0?a:0}},cZ=(t,e,n,r)=>{var i=Vn(t),a,o;return i==="horizontal"?(a=bc(t,"xAxis",e,r),o=xc(t,"xAxis",e,r)):(a=bc(t,"yAxis",n,r),o=xc(t,"yAxis",n,r)),wh(a,o)};function uEe(t,e,n,r,i){var a=r.length;if(!(a<1)){var o=es(t,n,0,!0),l,c=[];if(vr(r[0].barSize)){var u=!1,d=n/a,f=r.reduce((v,S)=>v+(S.barSize||0),0);f+=(a-1)*o,f>=n&&(f-=(a-1)*o,o=0),f>=n&&d>0&&(u=!0,d*=.9,f=a*d);var p=(n-f)/2>>0,m={offset:p-o,size:0};l=r.reduce((v,S)=>{var N,T={stackId:S.stackId,dataKeys:S.dataKeys,position:{offset:m.offset+m.size+o,size:u?d:(N=S.barSize)!==null&&N!==void 0?N:0}},k=[...v,T];return m=k[k.length-1].position,k},c)}else{var x=es(e,n,0,!0);n-2*x-(a-1)*o<=0&&(o=0);var b=(n-2*x-(a-1)*o)/a;b>1&&(b>>=0);var y=vr(i)?Math.min(b,i):b;l=r.reduce((v,S,N)=>[...v,{stackId:S.stackId,dataKeys:S.dataKeys,position:{offset:x+(b+o)*N+(b-y)/2,size:y}}],c)}return l}}var dEe=(t,e,n,r,i,a,o)=>{var l=Xr(o)?e:o,c=uEe(n,r,i!==a?i:a,t,l);return i!==a&&c!=null&&(c=c.map(u=>Xw(Xw({},u),{},{position:Xw(Xw({},u.position),{},{offset:u.position.offset-i/2})}))),c},hEe=nt([lEe,NY,Pwe,kY,cEe,cZ,nEe],dEe),fEe=(t,e,n,r)=>bc(t,"xAxis",e,r),mEe=(t,e,n,r)=>bc(t,"yAxis",n,r),pEe=(t,e,n,r)=>xc(t,"xAxis",e,r),gEe=(t,e,n,r)=>xc(t,"yAxis",n,r),xEe=nt([hEe,dv],(t,e)=>{if(!(t==null||e==null)){var n=t.find(r=>r.stackId===e.stackId&&e.dataKey!=null&&r.dataKeys.includes(e.dataKey));if(n!=null)return n.position}}),bEe=(t,e)=>{var n=KN(e);if(!(!t||n==null||e==null)){var{stackId:r}=e;if(r!=null){var i=t[r];if(i){var{stackedData:a}=i;if(a)return a.find(o=>o.key===n)}}}},yEe=nt([aEe,dv],bEe),vEe=nt([na,aO,fEe,mEe,pEe,gEe,xEe,Vn,Qy,cZ,yEe,dv,rEe],(t,e,n,r,i,a,o,l,c,u,d,f,p)=>{var{chartData:m,dataStartIndex:x,dataEndIndex:b}=c;if(!(f==null||o==null||e==null||l!=="horizontal"&&l!=="vertical"||n==null||r==null||i==null||a==null||u==null)){var{data:y}=f,v;if(y!=null&&y.length>0?v=y:v=m?.slice(x,b+1),v!=null)return Wke({layout:l,barSettings:f,pos:o,parentViewBox:e,bandSize:u,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:a,stackedData:d,displayedData:v,offset:t,cells:p,dataStartIndex:x})}}),uZ=t=>{var{chartData:e}=t,n=Lr(),r=ra();return _.useEffect(()=>r?()=>{}:(n(Q6(e)),()=>{n(Q6(void 0))}),[e,n,r]),null},GH={x:0,y:0,width:0,height:0,padding:{top:0,right:0,bottom:0,left:0}},dZ=Vs({name:"brush",initialState:GH,reducers:{setBrushSettings(t,e){return e.payload==null?GH:e.payload}}}),{setBrushSettings:VXe}=dZ.actions,wEe=dZ.reducer;function qH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Yw(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?qH(Object(n),!0).forEach(function(r){hZ(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):qH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function hZ(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=SEe(t,"string");return typeof e=="symbol"?e:e+""}function SEe(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 MEe=(t,e)=>{var{x:n,y:r}=t,{x:i,y:a}=e;return{x:Math.min(n,i),y:Math.min(r,a),width:Math.abs(i-n),height:Math.abs(a-r)}},NEe=t=>{var{x1:e,y1:n,x2:r,y2:i}=t;return MEe({x:e,y:n},{x:r,y:i})};class h2{static create(e){return new h2(e)}constructor(e){this.scale=e}get domain(){return this.scale.domain}get range(){return this.scale.range}get rangeMin(){return this.range()[0]}get rangeMax(){return this.range()[1]}get bandwidth(){return this.scale.bandwidth}apply(e){var{bandAware:n,position:r}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(e!==void 0){if(r)switch(r){case"start":return this.scale(e);case"middle":{var i=this.bandwidth?this.bandwidth()/2:0;return this.scale(e)+i}case"end":{var a=this.bandwidth?this.bandwidth():0;return this.scale(e)+a}default:return this.scale(e)}if(n){var o=this.bandwidth?this.bandwidth()/2:0;return this.scale(e)+o}return this.scale(e)}}isInRange(e){var n=this.range(),r=n[0],i=n[n.length-1];return r<=i?e>=r&&e<=i:e>=i&&e<=r}}hZ(h2,"EPS",1e-4);var kEe=t=>{var e=Object.keys(t).reduce((n,r)=>Yw(Yw({},n),{},{[r]:h2.create(t[r])}),{});return Yw(Yw({},e),{},{apply(n){var{bandAware:r,position:i}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return Object.fromEntries(Object.entries(n).map(a=>{var[o,l]=a;return[o,e[o].apply(l,{bandAware:r,position:i})]}))},isInRange(n){return Object.keys(n).every(r=>e[r].isInRange(n[r]))}})};function EEe(t){return(t%180+180)%180}var TEe=function(e){var{width:n,height:r}=e,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,a=EEe(i),o=a*Math.PI/180,l=Math.atan(r/n),c=o>l&&o<Math.PI-l?r/Math.sin(o):n/Math.cos(o);return Math.abs(c)},AEe={dots:[],areas:[],lines:[]},fZ=Vs({name:"referenceElements",initialState:AEe,reducers:{addDot:(t,e)=>{t.dots.push(e.payload)},removeDot:(t,e)=>{var n=Ol(t).dots.findIndex(r=>r===e.payload);n!==-1&&t.dots.splice(n,1)},addArea:(t,e)=>{t.areas.push(e.payload)},removeArea:(t,e)=>{var n=Ol(t).areas.findIndex(r=>r===e.payload);n!==-1&&t.areas.splice(n,1)},addLine:(t,e)=>{t.lines.push(e.payload)},removeLine:(t,e)=>{var n=Ol(t).lines.findIndex(r=>r===e.payload);n!==-1&&t.lines.splice(n,1)}}}),{addDot:GXe,removeDot:qXe,addArea:WXe,removeArea:KXe,addLine:CEe,removeLine:jEe}=fZ.actions,PEe=fZ.reducer,mZ=_.createContext(void 0),DEe=t=>{var{children:e}=t,[n]=_.useState("".concat(X0("recharts"),"-clip")),r=u2();if(r==null)return null;var{x:i,y:a,width:o,height:l}=r;return _.createElement(mZ.Provider,{value:n},_.createElement("defs",null,_.createElement("clipPath",{id:n},_.createElement("rect",{x:i,y:a,height:l,width:o}))),e)},REe=()=>_.useContext(mZ);function WH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function KH(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?WH(Object(n),!0).forEach(function(r){OEe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):WH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function OEe(t,e,n){return(e=LEe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function LEe(t){var e=FEe(t,"string");return typeof e=="symbol"?e:e+""}function FEe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function IS(){return IS=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},IS.apply(null,arguments)}var IEe=(t,e)=>{var n;if(_.isValidElement(t))n=_.cloneElement(t,e);else if(typeof t=="function")n=t(e);else{if(!vr(e.x1)||!vr(e.y1)||!vr(e.x2)||!vr(e.y2))return null;n=_.createElement("line",IS({},e,{className:"recharts-reference-line-line"}))}return n},UEe=(t,e,n,r,i,a)=>{var{x:o,width:l}=a,c=i.y.apply(t,{position:n});if($s(c)||e==="discard"&&!i.y.isInRange(c))return null;var u=[{x:o+l,y:c},{x:o,y:c}];return r==="left"?u.reverse():u},zEe=(t,e,n,r,i,a)=>{var{y:o,height:l}=a,c=i.x.apply(t,{position:n});if($s(c)||e==="discard"&&!i.x.isInRange(c))return null;var u=[{x:c,y:o+l},{x:c,y:o}];return r==="top"?u.reverse():u},BEe=(t,e,n,r)=>{var i=t.map(a=>r.apply(a,{position:n}));return e==="discard"&&i.some(a=>!r.isInRange(a))?null:i},HEe=(t,e,n,r,i,a)=>{var{x:o,y:l,segment:c,ifOverflow:u}=a,d=cl(o),f=cl(l);return f?UEe(l,u,n,i,t,e):d?zEe(o,u,n,r,t,e):c!=null&&c.length===2?BEe(c,u,n,t):null};function $Ee(t){var e=Lr();return _.useEffect(()=>(e(CEe(t)),()=>{e(jEe(t))})),null}function VEe(t){var{xAxisId:e,yAxisId:n,shape:r,className:i,ifOverflow:a}=t,o=ra(),l=REe(),c=It(C=>Ec(C,e)),u=It(C=>Tc(C,n)),d=It(C=>Sh(C,"xAxis",e,o)),f=It(C=>Sh(C,"yAxis",n,o)),p=Gy();if(!l||!p||c==null||u==null||d==null||f==null)return null;var m=kEe({x:d,y:f}),x=HEe(m,p,t.position,c.orientation,u.orientation,t);if(!x)return null;var[{x:b,y},{x:v,y:S}]=x,N=a==="hidden"?"url(#".concat(l,")"):void 0,T=KH(KH({clipPath:N},za(t)),{},{x1:b,y1:y,x2:v,y2:S}),k=NEe({x1:b,y1:y,x2:v,y2:S});return _.createElement(ts,{zIndex:t.zIndex},_.createElement(oi,{className:tr("recharts-reference-line",i)},IEe(r,T),_.createElement($Q,IS({},k,{lowerWidth:k.width,upperWidth:k.width}),_.createElement(GQ,{label:t.label}),t.children)))}var GEe={ifOverflow:"discard",xAxisId:0,yAxisId:0,fill:"none",stroke:"#ccc",fillOpacity:1,strokeWidth:1,position:"middle",zIndex:bi.line};function s0(t){var e=li(t,GEe);return _.createElement(_.Fragment,null,_.createElement($Ee,{yAxisId:e.yAxisId,xAxisId:e.xAxisId,ifOverflow:e.ifOverflow,x:e.x,y:e.y,segment:e.segment}),_.createElement(VEe,e))}s0.displayName="ReferenceLine";function pZ(t,e){if(e<1)return[];if(e===1)return t;for(var n=[],r=0;r<t.length;r+=e)n.push(t[r]);return n}function qEe(t,e,n){var r={width:t.width+e.width,height:t.height+e.height};return TEe(r,n)}function WEe(t,e,n){var r=n==="width",{x:i,y:a,width:o,height:l}=t;return e===1?{start:r?i:a,end:r?i+o:a+l}:{start:r?i+o:a+l,end:r?i:a}}function US(t,e,n,r,i){if(t*e<t*r||t*e>t*i)return!1;var a=n();return t*(e-t*a/2-r)>=0&&t*(e+t*a/2-i)<=0}function KEe(t,e){return pZ(t,e+1)}function XEe(t,e,n,r,i){for(var a=(r||[]).slice(),{start:o,end:l}=e,c=0,u=1,d=o,f=function(){var x=r?.[c];if(x===void 0)return{v:pZ(r,u)};var b=c,y,v=()=>(y===void 0&&(y=n(x,b)),y),S=x.coordinate,N=c===0||US(t,S,v,d,l);N||(c=0,d=o,u+=1),N&&(d=S+t*(v()/2+i),c+=u)},p;u<=a.length;)if(p=f(),p)return p.v;return[]}function XH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Ka(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?XH(Object(n),!0).forEach(function(r){YEe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):XH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function YEe(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=ZEe(t,"string");return typeof e=="symbol"?e:e+""}function ZEe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function JEe(t,e,n,r,i){for(var a=(r||[]).slice(),o=a.length,{start:l}=e,{end:c}=e,u=function(p){var m=a[p],x,b=()=>(x===void 0&&(x=n(m,p)),x);if(p===o-1){var y=t*(m.coordinate+t*b()/2-c);a[p]=m=Ka(Ka({},m),{},{tickCoord:y>0?m.coordinate-y*t:m.coordinate})}else a[p]=m=Ka(Ka({},m),{},{tickCoord:m.coordinate});if(m.tickCoord!=null){var v=US(t,m.tickCoord,b,l,c);v&&(c=m.tickCoord-t*(b()/2+i),a[p]=Ka(Ka({},m),{},{isShow:!0}))}},d=o-1;d>=0;d--)u(d);return a}function eTe(t,e,n,r,i,a){var o=(r||[]).slice(),l=o.length,{start:c,end:u}=e;if(a){var d=r[l-1],f=n(d,l-1),p=t*(d.coordinate+t*f/2-u);if(o[l-1]=d=Ka(Ka({},d),{},{tickCoord:p>0?d.coordinate-p*t:d.coordinate}),d.tickCoord!=null){var m=US(t,d.tickCoord,()=>f,c,u);m&&(u=d.tickCoord-t*(f/2+i),o[l-1]=Ka(Ka({},d),{},{isShow:!0}))}}for(var x=a?l-1:l,b=function(S){var N=o[S],T,k=()=>(T===void 0&&(T=n(N,S)),T);if(S===0){var C=t*(N.coordinate-t*k()/2-c);o[S]=N=Ka(Ka({},N),{},{tickCoord:C<0?N.coordinate-C*t:N.coordinate})}else o[S]=N=Ka(Ka({},N),{},{tickCoord:N.coordinate});if(N.tickCoord!=null){var E=US(t,N.tickCoord,k,c,u);E&&(c=N.tickCoord+t*(k()/2+i),o[S]=Ka(Ka({},N),{},{isShow:!0}))}},y=0;y<x;y++)b(y);return o}function R4(t,e,n){var{tick:r,ticks:i,viewBox:a,minTickGap:o,orientation:l,interval:c,tickFormatter:u,unit:d,angle:f}=t;if(!i||!i.length||!r)return[];if(zt(c)||yx.isSsr){var p;return(p=KEe(i,zt(c)?c:0))!==null&&p!==void 0?p:[]}var m=[],x=l==="top"||l==="bottom"?"width":"height",b=d&&x==="width"?v0(d,{fontSize:e,letterSpacing:n}):{width:0,height:0},y=(N,T)=>{var k=typeof u=="function"?u(N.value,T):N.value;return x==="width"?qEe(v0(k,{fontSize:e,letterSpacing:n}),b,f):v0(k,{fontSize:e,letterSpacing:n})[x]},v=i.length>=2?ya(i[1].coordinate-i[0].coordinate):1,S=WEe(a,v,x);return c==="equidistantPreserveStart"?XEe(v,S,y,i,o):(c==="preserveStart"||c==="preserveStartEnd"?m=eTe(v,S,y,i,o,c==="preserveStartEnd"):m=JEe(v,S,y,i,o),m.filter(N=>N.isShow))}var tTe=t=>{var{ticks:e,label:n,labelGapWithTick:r=5,tickSize:i=0,tickMargin:a=0}=t,o=0;if(e){Array.from(e).forEach(d=>{if(d){var f=d.getBoundingClientRect();f.width>o&&(o=f.width)}});var l=n?n.getBoundingClientRect().width:0,c=i+a,u=o+c+l+(n?r:0);return Math.round(u)}return 0},nTe=["axisLine","width","height","className","hide","ticks","axisType"];function rTe(t,e){if(t==null)return{};var n,r,i=iTe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function iTe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function fm(){return fm=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},fm.apply(null,arguments)}function YH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Fi(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?YH(Object(n),!0).forEach(function(r){aTe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):YH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function aTe(t,e,n){return(e=sTe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function sTe(t){var e=oTe(t,"string");return typeof e=="symbol"?e:e+""}function oTe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var Eu={x:0,y:0,width:0,height:0,viewBox:{x:0,y:0,width:0,height:0},orientation:"bottom",ticks:[],stroke:"#666",tickLine:!0,axisLine:!0,tick:!0,mirror:!1,minTickGap:5,tickSize:6,tickMargin:2,interval:"preserveEnd",zIndex:bi.axis};function lTe(t){var{x:e,y:n,width:r,height:i,orientation:a,mirror:o,axisLine:l,otherSvgProps:c}=t;if(!l)return null;var u=Fi(Fi(Fi({},c),xs(l)),{},{fill:"none"});if(a==="top"||a==="bottom"){var d=+(a==="top"&&!o||a==="bottom"&&o);u=Fi(Fi({},u),{},{x1:e,y1:n+d*i,x2:e+r,y2:n+d*i})}else{var f=+(a==="left"&&!o||a==="right"&&o);u=Fi(Fi({},u),{},{x1:e+f*r,y1:n,x2:e+f*r,y2:n+i})}return _.createElement("line",fm({},u,{className:tr("recharts-cartesian-axis-line",cm(l,"className"))}))}function cTe(t,e,n,r,i,a,o,l,c){var u,d,f,p,m,x,b=l?-1:1,y=t.tickSize||o,v=zt(t.tickCoord)?t.tickCoord:t.coordinate;switch(a){case"top":u=d=t.coordinate,p=n+ +!l*i,f=p-b*y,x=f-b*c,m=v;break;case"left":f=p=t.coordinate,d=e+ +!l*r,u=d-b*y,m=u-b*c,x=v;break;case"right":f=p=t.coordinate,d=e+ +l*r,u=d+b*y,m=u+b*c,x=v;break;default:u=d=t.coordinate,p=n+ +l*i,f=p+b*y,x=f+b*c,m=v;break}return{line:{x1:u,y1:f,x2:d,y2:p},tick:{x:m,y:x}}}function uTe(t,e){switch(t){case"left":return e?"start":"end";case"right":return e?"end":"start";default:return"middle"}}function dTe(t,e){switch(t){case"left":case"right":return"middle";case"top":return e?"start":"end";default:return e?"end":"start"}}function hTe(t){var{option:e,tickProps:n,value:r}=t,i,a=tr(n.className,"recharts-cartesian-axis-tick-value");if(_.isValidElement(e))i=_.cloneElement(e,Fi(Fi({},n),{},{className:a}));else if(typeof e=="function")i=e(Fi(Fi({},n),{},{className:a}));else{var o="recharts-cartesian-axis-tick-value";typeof e!="boolean"&&(o=tr(o,e?.className)),i=_.createElement(r2,fm({},n,{className:o}),r)}return i}var fTe=_.forwardRef((t,e)=>{var{ticks:n=[],tick:r,tickLine:i,stroke:a,tickFormatter:o,unit:l,padding:c,tickTextProps:u,orientation:d,mirror:f,x:p,y:m,width:x,height:b,tickSize:y,tickMargin:v,fontSize:S,letterSpacing:N,getTicksConfig:T,events:k,axisType:C}=t,E=R4(Fi(Fi({},T),{},{ticks:n}),S,N),D=uTe(d,f),A=dTe(d,f),R=xs(T),U=lm(r),F={};typeof i=="object"&&(F=i);var $=Fi(Fi({},R),{},{fill:"none"},F),j=E.map(V=>Fi({entry:V},cTe(V,p,m,x,b,d,y,f,v))),H=j.map(V=>{var{entry:Q,line:Z}=V;return _.createElement(oi,{className:"recharts-cartesian-axis-tick",key:"tick-".concat(Q.value,"-").concat(Q.coordinate,"-").concat(Q.tickCoord)},i&&_.createElement("line",fm({},$,Z,{className:tr("recharts-cartesian-axis-tick-line",cm(i,"className"))})))}),K=j.map((V,Q)=>{var{entry:Z,tick:ae}=V,B=Fi(Fi(Fi(Fi({textAnchor:D,verticalAnchor:A},R),{},{stroke:"none",fill:a},U),ae),{},{index:Q,payload:Z,visibleTicksCount:E.length,tickFormatter:o,padding:c},u);return _.createElement(oi,fm({className:"recharts-cartesian-axis-tick-label",key:"tick-label-".concat(Z.value,"-").concat(Z.coordinate,"-").concat(Z.tickCoord)},zy(k,Z,Q)),r&&_.createElement(hTe,{option:r,tickProps:B,value:"".concat(typeof o=="function"?o(Z.value,Q):Z.value).concat(l||"")}))});return _.createElement("g",{className:"recharts-cartesian-axis-ticks recharts-".concat(C,"-ticks")},K.length>0&&_.createElement(ts,{zIndex:bi.label},_.createElement("g",{className:"recharts-cartesian-axis-tick-labels recharts-".concat(C,"-tick-labels"),ref:e},K)),H.length>0&&_.createElement("g",{className:"recharts-cartesian-axis-tick-lines recharts-".concat(C,"-tick-lines")},H))}),mTe=_.forwardRef((t,e)=>{var{axisLine:n,width:r,height:i,className:a,hide:o,ticks:l,axisType:c}=t,u=rTe(t,nTe),[d,f]=_.useState(""),[p,m]=_.useState(""),x=_.useRef(null);_.useImperativeHandle(e,()=>({getCalculatedWidth:()=>{var y;return tTe({ticks:x.current,label:(y=t.labelRef)===null||y===void 0?void 0:y.current,labelGapWithTick:5,tickSize:t.tickSize,tickMargin:t.tickMargin})}}));var b=_.useCallback(y=>{if(y){var v=y.getElementsByClassName("recharts-cartesian-axis-tick-value");x.current=v;var S=v[0];if(S){var N=window.getComputedStyle(S),T=N.fontSize,k=N.letterSpacing;(T!==d||k!==p)&&(f(T),m(k))}}},[d,p]);return o||r!=null&&r<=0||i!=null&&i<=0?null:_.createElement(ts,{zIndex:t.zIndex},_.createElement(oi,{className:tr("recharts-cartesian-axis",a)},_.createElement(lTe,{x:t.x,y:t.y,width:r,height:i,orientation:t.orientation,mirror:t.mirror,axisLine:n,otherSvgProps:xs(t)}),_.createElement(fTe,{ref:b,axisType:c,events:u,fontSize:d,getTicksConfig:t,height:t.height,letterSpacing:p,mirror:t.mirror,orientation:t.orientation,padding:t.padding,stroke:t.stroke,tick:t.tick,tickFormatter:t.tickFormatter,tickLine:t.tickLine,tickMargin:t.tickMargin,tickSize:t.tickSize,tickTextProps:t.tickTextProps,ticks:l,unit:t.unit,width:t.width,x:t.x,y:t.y}),_.createElement($Q,{x:t.x,y:t.y,width:t.width,height:t.height,lowerWidth:t.width,upperWidth:t.width},_.createElement(GQ,{label:t.label,labelRef:t.labelRef}),t.children)))}),O4=_.forwardRef((t,e)=>{var n=li(t,Eu);return _.createElement(mTe,fm({},n,{ref:e}))});O4.displayName="CartesianAxis";var pTe=["x1","y1","x2","y2","key"],gTe=["offset"],xTe=["xAxisId","yAxisId"],bTe=["xAxisId","yAxisId"];function QH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Qa(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?QH(Object(n),!0).forEach(function(r){yTe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):QH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function yTe(t,e,n){return(e=vTe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function vTe(t){var e=wTe(t,"string");return typeof e=="symbol"?e:e+""}function wTe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Rf(){return Rf=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Rf.apply(null,arguments)}function zS(t,e){if(t==null)return{};var n,r,i=_Te(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function _Te(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=t=>{var{fill:e}=t;if(!e||e==="none")return null;var{fillOpacity:n,x:r,y:i,width:a,height:o,ry:l}=t;return _.createElement("rect",{x:r,y:i,ry:l,width:a,height:o,stroke:"none",fill:e,fillOpacity:n,className:"recharts-cartesian-grid-bg"})};function gZ(t){var{option:e,lineItemProps:n}=t,r;if(_.isValidElement(e))r=_.cloneElement(e,n);else if(typeof e=="function")r=e(n);else{var i,{x1:a,y1:o,x2:l,y2:c,key:u}=n,d=zS(n,pTe),f=(i=xs(d))!==null&&i!==void 0?i:{},{offset:p}=f,m=zS(f,gTe);r=_.createElement("line",Rf({},m,{x1:a,y1:o,x2:l,y2:c,fill:"none",key:u}))}return r}function MTe(t){var{x:e,width:n,horizontal:r=!0,horizontalPoints:i}=t;if(!r||!i||!i.length)return null;var{xAxisId:a,yAxisId:o}=t,l=zS(t,xTe),c=i.map((u,d)=>{var f=Qa(Qa({},l),{},{x1:e,y1:u,x2:e+n,y2:u,key:"line-".concat(d),index:d});return _.createElement(gZ,{key:"line-".concat(d),option:r,lineItemProps:f})});return _.createElement("g",{className:"recharts-cartesian-grid-horizontal"},c)}function NTe(t){var{y:e,height:n,vertical:r=!0,verticalPoints:i}=t;if(!r||!i||!i.length)return null;var{xAxisId:a,yAxisId:o}=t,l=zS(t,bTe),c=i.map((u,d)=>{var f=Qa(Qa({},l),{},{x1:u,y1:e,x2:u,y2:e+n,key:"line-".concat(d),index:d});return _.createElement(gZ,{option:r,lineItemProps:f,key:"line-".concat(d)})});return _.createElement("g",{className:"recharts-cartesian-grid-vertical"},c)}function kTe(t){var{horizontalFill:e,fillOpacity:n,x:r,y:i,width:a,height:o,horizontalPoints:l,horizontal:c=!0}=t;if(!c||!e||!e.length||l==null)return null;var u=l.map(f=>Math.round(f+i-i)).sort((f,p)=>f-p);i!==u[0]&&u.unshift(0);var d=u.map((f,p)=>{var m=!u[p+1],x=m?i+o-f:u[p+1]-f;if(x<=0)return null;var b=p%e.length;return _.createElement("rect",{key:"react-".concat(p),y:f,x:r,height:x,width:a,stroke:"none",fill:e[b],fillOpacity:n,className:"recharts-cartesian-grid-bg"})});return _.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},d)}function ETe(t){var{vertical:e=!0,verticalFill:n,fillOpacity:r,x:i,y:a,width:o,height:l,verticalPoints:c}=t;if(!e||!n||!n.length)return null;var u=c.map(f=>Math.round(f+i-i)).sort((f,p)=>f-p);i!==u[0]&&u.unshift(0);var d=u.map((f,p)=>{var m=!u[p+1],x=m?i+o-f:u[p+1]-f;if(x<=0)return null;var b=p%n.length;return _.createElement("rect",{key:"react-".concat(p),x:f,y:a,width:x,height:l,stroke:"none",fill:n[b],fillOpacity:r,className:"recharts-cartesian-grid-bg"})});return _.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},d)}var TTe=(t,e)=>{var{xAxis:n,width:r,height:i,offset:a}=t;return JK(R4(Qa(Qa(Qa({},Eu),n),{},{ticks:eX(n),viewBox:{x:0,y:0,width:r,height:i}})),a.left,a.left+a.width,e)},ATe=(t,e)=>{var{yAxis:n,width:r,height:i,offset:a}=t;return JK(R4(Qa(Qa(Qa({},Eu),n),{},{ticks:eX(n),viewBox:{x:0,y:0,width:r,height:i}})),a.top,a.top+a.height,e)},CTe={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[],xAxisId:0,yAxisId:0,syncWithTicks:!1,zIndex:bi.grid};function BS(t){var e=oO(),n=lO(),r=cX(),i=Qa(Qa({},li(t,CTe)),{},{x:zt(t.x)?t.x:r.left,y:zt(t.y)?t.y:r.top,width:zt(t.width)?t.width:r.width,height:zt(t.height)?t.height:r.height}),{xAxisId:a,yAxisId:o,x:l,y:c,width:u,height:d,syncWithTicks:f,horizontalValues:p,verticalValues:m}=i,x=ra(),b=It(A=>U6(A,"xAxis",a,x)),y=It(A=>U6(A,"yAxis",o,x));if(!pc(u)||!pc(d)||!zt(l)||!zt(c))return null;var v=i.verticalCoordinatesGenerator||TTe,S=i.horizontalCoordinatesGenerator||ATe,{horizontalPoints:N,verticalPoints:T}=i;if((!N||!N.length)&&typeof S=="function"){var k=p&&p.length,C=S({yAxis:y?Qa(Qa({},y),{},{ticks:k?p:y.ticks}):void 0,width:e??u,height:n??d,offset:r},k?!0:f);uS(Array.isArray(C),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(typeof C,"]")),Array.isArray(C)&&(N=C)}if((!T||!T.length)&&typeof v=="function"){var E=m&&m.length,D=v({xAxis:b?Qa(Qa({},b),{},{ticks:E?m:b.ticks}):void 0,width:e??u,height:n??d,offset:r},E?!0:f);uS(Array.isArray(D),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(typeof D,"]")),Array.isArray(D)&&(T=D)}return _.createElement(ts,{zIndex:i.zIndex},_.createElement("g",{className:"recharts-cartesian-grid"},_.createElement(STe,{fill:i.fill,fillOpacity:i.fillOpacity,x:i.x,y:i.y,width:i.width,height:i.height,ry:i.ry}),_.createElement(kTe,Rf({},i,{horizontalPoints:N})),_.createElement(ETe,Rf({},i,{verticalPoints:T})),_.createElement(MTe,Rf({},i,{offset:r,horizontalPoints:N,xAxis:b,yAxis:y})),_.createElement(NTe,Rf({},i,{offset:r,verticalPoints:T,xAxis:b,yAxis:y}))))}BS.displayName="CartesianGrid";var xZ=(t,e,n,r)=>bc(t,"xAxis",e,r),bZ=(t,e,n,r)=>xc(t,"xAxis",e,r),yZ=(t,e,n,r)=>bc(t,"yAxis",n,r),vZ=(t,e,n,r)=>xc(t,"yAxis",n,r),jTe=nt([Vn,xZ,yZ,bZ,vZ],(t,e,n,r,i)=>kc(t,"xAxis")?wh(e,r,!1):wh(n,i,!1)),PTe=(t,e,n,r,i)=>i;function DTe(t){return t.type==="line"}var RTe=nt([tv,PTe],(t,e)=>t.filter(DTe).find(n=>n.id===e)),OTe=nt([Vn,xZ,yZ,bZ,vZ,RTe,jTe,Qy],(t,e,n,r,i,a,o,l)=>{var{chartData:c,dataStartIndex:u,dataEndIndex:d}=l;if(!(a==null||e==null||n==null||r==null||i==null||r.length===0||i.length===0||o==null||t!=="horizontal"&&t!=="vertical")){var{dataKey:f,data:p}=a,m;if(p!=null&&p.length>0?m=p:m=c?.slice(u,d+1),m!=null)return tAe({layout:t,xAxis:e,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataKey:f,bandSize:o,displayedData:m})}});function wZ(t){var e=lm(t),n=3,r=2;if(e!=null){var{r:i,strokeWidth:a}=e,o=Number(i),l=Number(a);return(Number.isNaN(o)||o<0)&&(o=n),(Number.isNaN(l)||l<0)&&(l=r),{r:o,strokeWidth:l}}return{r:n,strokeWidth:r}}var LTe=["id"],FTe=["type","layout","connectNulls","needClip","shape"],ITe=["activeDot","animateNewValues","animationBegin","animationDuration","animationEasing","connectNulls","dot","hide","isAnimationActive","label","legendType","xAxisId","yAxisId","id"];function uy(){return uy=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},uy.apply(null,arguments)}function ZH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function nc(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?ZH(Object(n),!0).forEach(function(r){UTe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ZH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function UTe(t,e,n){return(e=zTe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function zTe(t){var e=BTe(t,"string");return typeof e=="symbol"?e:e+""}function BTe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function L4(t,e){if(t==null)return{};var n,r,i=HTe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function HTe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var $Te=t=>{var{dataKey:e,name:n,stroke:r,legendType:i,hide:a}=t;return[{inactive:a,dataKey:e,type:i,color:r,value:Lh(n,e),payload:t}]},VTe=_.memo(t=>{var{dataKey:e,data:n,stroke:r,strokeWidth:i,fill:a,name:o,hide:l,unit:c,tooltipType:u}=t,d={dataDefinedOnItem:n,positions:void 0,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:e,nameKey:void 0,name:Lh(o,e),hide:l,type:u,color:r,unit:c}};return _.createElement(o2,{tooltipEntrySettings:d})}),_Z=(t,e)=>"".concat(e,"px ").concat(t-e,"px");function GTe(t,e){for(var n=t.length%2!==0?[...t,0]:t,r=[],i=0;i<e;++i)r=[...r,...n];return r}var qTe=(t,e,n)=>{var r=n.reduce((f,p)=>f+p);if(!r)return _Z(e,t);for(var i=Math.floor(t/r),a=t%r,o=e-t,l=[],c=0,u=0;c<n.length;u+=n[c],++c)if(u+n[c]>a){l=[...n.slice(0,c),a-u];break}var d=l.length%2===0?[0,o]:[o];return[...GTe(n,i),...l,...d].map(f=>"".concat(f,"px")).join(", ")};function WTe(t){var{clipPathId:e,points:n,props:r}=t,{dot:i,dataKey:a,needClip:o}=r,{id:l}=r,c=L4(r,LTe),u=xs(c);return _.createElement(rZ,{points:n,dot:i,className:"recharts-line-dots",dotClassName:"recharts-line-dot",dataKey:a,baseProps:u,needClip:o,clipPathId:e})}function KTe(t){var{showLabels:e,children:n,points:r}=t,i=_.useMemo(()=>r?.map(a=>{var o,l,c={x:(o=a.x)!==null&&o!==void 0?o:0,y:(l=a.y)!==null&&l!==void 0?l:0,width:0,lowerWidth:0,upperWidth:0,height:0};return nc(nc({},c),{},{value:a.value,payload:a.payload,viewBox:c,parentViewBox:void 0,fill:void 0})}),[r]);return _.createElement(_4,{value:e?i:void 0},n)}function JH(t){var{clipPathId:e,pathRef:n,points:r,strokeDasharray:i,props:a}=t,{type:o,layout:l,connectNulls:c,needClip:u,shape:d}=a,f=L4(a,FTe),p=nc(nc({},za(f)),{},{fill:"none",className:"recharts-line-curve",clipPath:u?"url(#clipPath-".concat(e,")"):void 0,points:r,type:o,layout:l,connectNulls:c,strokeDasharray:i??a.strokeDasharray});return _.createElement(_.Fragment,null,r?.length>1&&_.createElement(E4,uy({shapeType:"curve",option:d},p,{pathRef:n})),_.createElement(WTe,{points:r,clipPathId:e,props:a}))}function XTe(t){try{return t&&t.getTotalLength&&t.getTotalLength()||0}catch{return 0}}function YTe(t){var{clipPathId:e,props:n,pathRef:r,previousPointsRef:i,longestAnimatedLengthRef:a}=t,{points:o,strokeDasharray:l,isAnimationActive:c,animationBegin:u,animationDuration:d,animationEasing:f,animateNewValues:p,width:m,height:x,onAnimationEnd:b,onAnimationStart:y}=n,v=i.current,S=wx(o,"recharts-line-"),N=_.useRef(S),[T,k]=_.useState(!1),C=!T,E=_.useCallback(()=>{typeof b=="function"&&b(),k(!1)},[b]),D=_.useCallback(()=>{typeof y=="function"&&y(),k(!0)},[y]),A=XTe(r.current),R=_.useRef(0);N.current!==S&&(R.current=a.current,N.current=S);var U=R.current;return _.createElement(KTe,{points:o,showLabels:C},n.children,_.createElement(vx,{animationId:S,begin:u,duration:d,isActive:c,easing:f,onAnimationEnd:E,onAnimationStart:D,key:S},F=>{var $=hr(U,A+U,F),j=Math.min($,A),H;if(c)if(l){var K="".concat(l).split(/[,\s]+/gim).map(Z=>parseFloat(Z));H=qTe(j,A,K)}else H=_Z(A,j);else H=l==null?void 0:String(l);if(F>0&&A>0&&(i.current=o,a.current=Math.max(a.current,j)),v){var V=v.length/o.length,Q=F===1?o:o.map((Z,ae)=>{var B=Math.floor(ae*V);if(v[B]){var X=v[B];return nc(nc({},Z),{},{x:hr(X.x,Z.x,F),y:hr(X.y,Z.y,F)})}return p?nc(nc({},Z),{},{x:hr(m*2,Z.x,F),y:hr(x/2,Z.y,F)}):nc(nc({},Z),{},{x:Z.x,y:Z.y})});return i.current=Q,_.createElement(JH,{props:n,points:Q,clipPathId:e,pathRef:r,strokeDasharray:H})}return _.createElement(JH,{props:n,points:o,clipPathId:e,pathRef:r,strokeDasharray:H})}),_.createElement(i2,{label:n.label}))}function QTe(t){var{clipPathId:e,props:n}=t,r=_.useRef(null),i=_.useRef(0),a=_.useRef(null);return _.createElement(YTe,{props:n,clipPathId:e,previousPointsRef:r,longestAnimatedLengthRef:i,pathRef:a})}var ZTe=(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:yr(t.payload,e)}};class JTe extends _.Component{render(){var{hide:e,dot:n,points:r,className:i,xAxisId:a,yAxisId:o,top:l,left:c,width:u,height:d,id:f,needClip:p,zIndex:m}=this.props;if(e)return null;var x=tr("recharts-line",i),b=f,{r:y,strokeWidth:v}=wZ(n),S=k4(n),N=y*2+v,T=p?"url(#clipPath-".concat(S?"":"dots-").concat(b,")"):void 0;return _.createElement(ts,{zIndex:m},_.createElement(oi,{className:x},p&&_.createElement("defs",null,_.createElement(D4,{clipPathId:b,xAxisId:a,yAxisId:o}),!S&&_.createElement("clipPath",{id:"clipPath-dots-".concat(b)},_.createElement("rect",{x:c-N/2,y:l-N/2,width:u+N,height:d+N}))),_.createElement(sZ,{xAxisId:a,yAxisId:o,data:r,dataPointFormatter:ZTe,errorBarOffset:0},_.createElement(QTe,{props:this.props,clipPathId:b}))),_.createElement(g3,{activeDot:this.props.activeDot,points:r,mainColor:this.props.stroke,itemDataKey:this.props.dataKey,clipPath:T}))}}var SZ={activeDot:!0,animateNewValues:!0,animationBegin:0,animationDuration:1500,animationEasing:"ease",connectNulls:!1,dot:!0,fill:"#fff",hide:!1,isAnimationActive:"auto",label:!1,legendType:"line",stroke:"#3182bd",strokeWidth:1,xAxisId:0,yAxisId:0,zIndex:bi.line,type:"linear"};function eAe(t){var e=li(t,SZ),{activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:a,animationEasing:o,connectNulls:l,dot:c,hide:u,isAnimationActive:d,label:f,legendType:p,xAxisId:m,yAxisId:x,id:b}=e,y=L4(e,ITe),{needClip:v}=d2(m,x),S=u2(),N=Em(),T=ra(),k=It(R=>OTe(R,m,x,T,b));if(N!=="horizontal"&&N!=="vertical"||k==null||S==null)return null;var{height:C,width:E,x:D,y:A}=S;return _.createElement(JTe,uy({},y,{id:b,connectNulls:l,dot:c,activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:a,animationEasing:o,isAnimationActive:d,hide:u,label:f,legendType:p,xAxisId:m,yAxisId:x,points:k,layout:N,height:C,width:E,left:D,top:A,needClip:v}))}function tAe(t){var{layout:e,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:a,dataKey:o,bandSize:l,displayedData:c}=t;return c.map((u,d)=>{var f=yr(u,o);if(e==="horizontal"){var p=cS({axis:n,ticks:i,bandSize:l,entry:u,index:d}),m=Xr(f)?null:r.scale(f);return{x:p,y:m,value:f,payload:u}}var x=Xr(f)?null:n.scale(f),b=cS({axis:r,ticks:a,bandSize:l,entry:u,index:d});return x==null||b==null?null:{x,y:b,value:f,payload:u}}).filter(Boolean)}function nAe(t){var e=li(t,SZ),n=ra();return _.createElement(l2,{id:e.id,type:"line"},r=>_.createElement(_.Fragment,null,_.createElement(j4,{legendPayload:$Te(e)}),_.createElement(VTe,{dataKey:e.dataKey,data:e.data,stroke:e.stroke,strokeWidth:e.strokeWidth,fill:e.fill,name:e.name,hide:e.hide,unit:e.unit,tooltipType:e.tooltipType}),_.createElement(P4,{type:"line",id:r,data:e.data,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,dataKey:e.dataKey,hide:e.hide,isPanorama:n}),_.createElement(eAe,uy({},e,{id:r}))))}var MZ=_.memo(nAe,uv);MZ.displayName="Line";var NZ=(t,e,n,r)=>bc(t,"xAxis",e,r),kZ=(t,e,n,r)=>xc(t,"xAxis",e,r),EZ=(t,e,n,r)=>bc(t,"yAxis",n,r),TZ=(t,e,n,r)=>xc(t,"yAxis",n,r),rAe=nt([Vn,NZ,EZ,kZ,TZ],(t,e,n,r,i)=>kc(t,"xAxis")?wh(e,r,!1):wh(n,i,!1)),iAe=(t,e,n,r,i)=>i,AZ=nt([tv,iAe],(t,e)=>t.filter(n=>n.type==="area").find(n=>n.id===e)),aAe=(t,e,n,r,i)=>{var a,o=AZ(t,e,n,r,i);if(o!=null){var l=Vn(t),c=kc(l,"xAxis"),u;if(c?u=ly(t,"yAxis",n,r):u=ly(t,"xAxis",e,r),u!=null){var{stackId:d}=o,f=KN(o);if(!(d==null||f==null)){var p=(a=u[d])===null||a===void 0?void 0:a.stackedData;return p?.find(m=>m.key===f)}}}},sAe=nt([Vn,NZ,EZ,kZ,TZ,aAe,Qy,rAe,AZ,Rwe],(t,e,n,r,i,a,o,l,c,u)=>{var{chartData:d,dataStartIndex:f,dataEndIndex:p}=o;if(!(c==null||t!=="horizontal"&&t!=="vertical"||e==null||n==null||r==null||i==null||r.length===0||i.length===0||l==null)){var{data:m}=c,x;if(m&&m.length>0?x=m:x=d?.slice(f,p+1),x!=null)return NAe({layout:t,xAxis:e,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataStartIndex:f,areaSettings:c,stackedData:a,displayedData:x,chartBaseValue:u,bandSize:l})}}),oAe=["id"],lAe=["activeDot","animationBegin","animationDuration","animationEasing","connectNulls","dot","fill","fillOpacity","hide","isAnimationActive","legendType","stroke","xAxisId","yAxisId"];function Gf(){return Gf=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Gf.apply(null,arguments)}function CZ(t,e){if(t==null)return{};var n,r,i=cAe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function cAe(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 e$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function xg(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?e$(Object(n),!0).forEach(function(r){uAe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):e$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function uAe(t,e,n){return(e=dAe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function dAe(t){var e=hAe(t,"string");return typeof e=="symbol"?e:e+""}function hAe(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 HS(t,e){return t&&t!=="none"?t:e}var fAe=t=>{var{dataKey:e,name:n,stroke:r,fill:i,legendType:a,hide:o}=t;return[{inactive:o,dataKey:e,type:a,color:HS(r,i),value:Lh(n,e),payload:t}]},mAe=_.memo(t=>{var{dataKey:e,data:n,stroke:r,strokeWidth:i,fill:a,name:o,hide:l,unit:c,tooltipType:u}=t,d={dataDefinedOnItem:n,positions:void 0,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:e,nameKey:void 0,name:Lh(o,e),hide:l,type:u,color:HS(r,a),unit:c}};return _.createElement(o2,{tooltipEntrySettings:d})});function pAe(t){var{clipPathId:e,points:n,props:r}=t,{needClip:i,dot:a,dataKey:o}=r,l=xs(r);return _.createElement(rZ,{points:n,dot:a,className:"recharts-area-dots",dotClassName:"recharts-area-dot",dataKey:o,baseProps:l,needClip:i,clipPathId:e})}function gAe(t){var{showLabels:e,children:n,points:r}=t,i=r.map(a=>{var o,l,c={x:(o=a.x)!==null&&o!==void 0?o:0,y:(l=a.y)!==null&&l!==void 0?l:0,width:0,lowerWidth:0,upperWidth:0,height:0};return xg(xg({},c),{},{value:a.value,payload:a.payload,parentViewBox:void 0,viewBox:c,fill:void 0})});return _.createElement(_4,{value:e?i:void 0},n)}function t$(t){var{points:e,baseLine:n,needClip:r,clipPathId:i,props:a}=t,{layout:o,type:l,stroke:c,connectNulls:u,isRange:d}=a,{id:f}=a,p=CZ(a,oAe),m=xs(p),x=za(p);return _.createElement(_.Fragment,null,e?.length>1&&_.createElement(oi,{clipPath:r?"url(#clipPath-".concat(i,")"):void 0},_.createElement(kg,Gf({},x,{id:f,points:e,connectNulls:u,type:l,baseLine:n,layout:o,stroke:"none",className:"recharts-area-area"})),c!=="none"&&_.createElement(kg,Gf({},m,{className:"recharts-area-curve",layout:o,type:l,connectNulls:u,fill:"none",points:e})),c!=="none"&&d&&_.createElement(kg,Gf({},m,{className:"recharts-area-curve",layout:o,type:l,connectNulls:u,fill:"none",points:n}))),_.createElement(pAe,{points:e,props:p,clipPathId:i}))}function xAe(t){var{alpha:e,baseLine:n,points:r,strokeWidth:i}=t,a=r[0].y,o=r[r.length-1].y;if(!vr(a)||!vr(o))return null;var l=e*Math.abs(a-o),c=Math.max(...r.map(u=>u.x||0));return zt(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(u=>u.x||0),c)),zt(c)?_.createElement("rect",{x:0,y:a<o?a:a-l,width:c+(i?parseInt("".concat(i),10):1),height:Math.floor(l)}):null}function bAe(t){var{alpha:e,baseLine:n,points:r,strokeWidth:i}=t,a=r[0].x,o=r[r.length-1].x;if(!vr(a)||!vr(o))return null;var l=e*Math.abs(a-o),c=Math.max(...r.map(u=>u.y||0));return zt(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(u=>u.y||0),c)),zt(c)?_.createElement("rect",{x:a<o?a:a-l,y:0,width:l,height:Math.floor(c+(i?parseInt("".concat(i),10):1))}):null}function yAe(t){var{alpha:e,layout:n,points:r,baseLine:i,strokeWidth:a}=t;return n==="vertical"?_.createElement(xAe,{alpha:e,points:r,baseLine:i,strokeWidth:a}):_.createElement(bAe,{alpha:e,points:r,baseLine:i,strokeWidth:a})}function vAe(t){var{needClip:e,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:a}=t,{points:o,baseLine:l,isAnimationActive:c,animationBegin:u,animationDuration:d,animationEasing:f,onAnimationStart:p,onAnimationEnd:m}=r,x=_.useMemo(()=>({points:o,baseLine:l}),[o,l]),b=wx(x,"recharts-area-"),y=Zxe(),[v,S]=_.useState(!1),N=!v,T=_.useCallback(()=>{typeof m=="function"&&m(),S(!1)},[m]),k=_.useCallback(()=>{typeof p=="function"&&p(),S(!0)},[p]);if(y==null)return null;var C=i.current,E=a.current;return _.createElement(gAe,{showLabels:N,points:o},r.children,_.createElement(vx,{animationId:b,begin:u,duration:d,isActive:c,easing:f,onAnimationEnd:T,onAnimationStart:k,key:b},D=>{if(C){var A=C.length/o.length,R=D===1?o:o.map((F,$)=>{var j=Math.floor($*A);if(C[j]){var H=C[j];return xg(xg({},F),{},{x:hr(H.x,F.x,D),y:hr(H.y,F.y,D)})}return F}),U;return zt(l)?U=hr(E,l,D):Xr(l)||$s(l)?U=hr(E,0,D):U=l.map((F,$)=>{var j=Math.floor($*A);if(Array.isArray(E)&&E[j]){var H=E[j];return xg(xg({},F),{},{x:hr(H.x,F.x,D),y:hr(H.y,F.y,D)})}return F}),D>0&&(i.current=R,a.current=U),_.createElement(t$,{points:R,baseLine:U,needClip:e,clipPathId:n,props:r})}return D>0&&(i.current=o,a.current=l),_.createElement(oi,null,c&&_.createElement("defs",null,_.createElement("clipPath",{id:"animationClipPath-".concat(n)},_.createElement(yAe,{alpha:D,points:o,baseLine:l,layout:y,strokeWidth:r.strokeWidth}))),_.createElement(oi,{clipPath:"url(#animationClipPath-".concat(n,")")},_.createElement(t$,{points:o,baseLine:l,needClip:e,clipPathId:n,props:r})))}),_.createElement(i2,{label:r.label}))}function wAe(t){var{needClip:e,clipPathId:n,props:r}=t,i=_.useRef(null),a=_.useRef();return _.createElement(vAe,{needClip:e,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:a})}class _Ae extends _.PureComponent{render(){var{hide:e,dot:n,points:r,className:i,top:a,left:o,needClip:l,xAxisId:c,yAxisId:u,width:d,height:f,id:p,baseLine:m,zIndex:x}=this.props;if(e)return null;var b=tr("recharts-area",i),y=p,{r:v,strokeWidth:S}=wZ(n),N=k4(n),T=v*2+S,k=l?"url(#clipPath-".concat(N?"":"dots-").concat(y,")"):void 0;return _.createElement(ts,{zIndex:x},_.createElement(oi,{className:b},l&&_.createElement("defs",null,_.createElement(D4,{clipPathId:y,xAxisId:c,yAxisId:u}),!N&&_.createElement("clipPath",{id:"clipPath-dots-".concat(y)},_.createElement("rect",{x:o-T/2,y:a-T/2,width:d+T,height:f+T}))),_.createElement(wAe,{needClip:l,clipPathId:y,props:this.props})),_.createElement(g3,{points:r,mainColor:HS(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:k}),this.props.isRange&&Array.isArray(m)&&_.createElement(g3,{points:m,mainColor:HS(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:k}))}}var jZ={activeDot:!0,animationBegin:0,animationDuration:1500,animationEasing:"ease",connectNulls:!1,dot:!1,fill:"#3182bd",fillOpacity:.6,hide:!1,isAnimationActive:"auto",legendType:"line",stroke:"#3182bd",strokeWidth:1,type:"linear",label:!1,xAxisId:0,yAxisId:0,zIndex:bi.area};function SAe(t){var e,n=li(t,jZ),{activeDot:r,animationBegin:i,animationDuration:a,animationEasing:o,connectNulls:l,dot:c,fill:u,fillOpacity:d,hide:f,isAnimationActive:p,legendType:m,stroke:x,xAxisId:b,yAxisId:y}=n,v=CZ(n,lAe),S=Em(),N=kQ(),{needClip:T}=d2(b,y),k=ra(),{points:C,isRange:E,baseLine:D}=(e=It(j=>sAe(j,b,y,k,t.id)))!==null&&e!==void 0?e:{},A=u2();if(S!=="horizontal"&&S!=="vertical"||A==null||N!=="AreaChart"&&N!=="ComposedChart")return null;var{height:R,width:U,x:F,y:$}=A;return!C||!C.length?null:_.createElement(_Ae,Gf({},v,{activeDot:r,animationBegin:i,animationDuration:a,animationEasing:o,baseLine:D,connectNulls:l,dot:c,fill:u,fillOpacity:d,height:R,hide:f,layout:S,isAnimationActive:p==="auto"?!yx.isSsr:p,isRange:E,legendType:m,needClip:T,points:C,stroke:x,width:U,left:F,top:$,xAxisId:b,yAxisId:y}))}var MAe=(t,e,n,r,i)=>{var a=n??e;if(zt(a))return a;var o=t==="horizontal"?i:r,l=o.scale.domain();if(o.type==="number"){var c=Math.max(l[0],l[1]),u=Math.min(l[0],l[1]);return a==="dataMin"?u:a==="dataMax"||c<0?c:Math.max(Math.min(l[0],l[1]),0)}return a==="dataMin"?l[0]:a==="dataMax"?l[1]:l[0]};function NAe(t){var{areaSettings:{connectNulls:e,baseValue:n,dataKey:r},stackedData:i,layout:a,chartBaseValue:o,xAxis:l,yAxis:c,displayedData:u,dataStartIndex:d,xAxisTicks:f,yAxisTicks:p,bandSize:m}=t,x=i&&i.length,b=MAe(a,o,n,l,c),y=a==="horizontal",v=!1,S=u.map((T,k)=>{var C;x?C=i[d+k]:(C=yr(T,r),Array.isArray(C)?v=!0:C=[b,C]);var E=C[1]==null||x&&!e&&yr(T,r)==null;return y?{x:cS({axis:l,ticks:f,bandSize:m,entry:T,index:k}),y:E?null:c.scale(C[1]),value:C,payload:T}:{x:E?null:l.scale(C[1]),y:cS({axis:c,ticks:p,bandSize:m,entry:T,index:k}),value:C,payload:T}}),N;return x||v?N=S.map(T=>{var k=Array.isArray(T.value)?T.value[0]:null;return y?{x:T.x,y:k!=null&&T.y!=null?c.scale(k):null,payload:T.payload}:{x:k!=null?l.scale(k):null,y:T.y,payload:T.payload}}):N=y?c.scale(b):l.scale(b),{points:S,baseLine:N,isRange:v}}function kAe(t){var e=li(t,jZ),n=ra();return _.createElement(l2,{id:e.id,type:"area"},r=>_.createElement(_.Fragment,null,_.createElement(j4,{legendPayload:fAe(e)}),_.createElement(mAe,{dataKey:e.dataKey,data:e.data,stroke:e.stroke,strokeWidth:e.strokeWidth,fill:e.fill,name:e.name,hide:e.hide,unit:e.unit,tooltipType:e.tooltipType}),_.createElement(P4,{type:"area",id:r,data:e.data,dataKey:e.dataKey,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,stackId:tX(e.stackId),hide:e.hide,barSize:void 0,baseValue:e.baseValue,isPanorama:n,connectNulls:e.connectNulls}),_.createElement(SAe,Gf({},e,{id:r}))))}var PZ=_.memo(kAe,uv);PZ.displayName="Area";var EAe=["domain","range"],TAe=["domain","range"];function n$(t,e){if(t==null)return{};var n,r,i=AAe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function AAe(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 r$(t,e){return t===e?!0:Array.isArray(t)&&t.length===2&&Array.isArray(e)&&e.length===2?t[0]===e[0]&&t[1]===e[1]:!1}function DZ(t,e){if(t===e)return!0;var{domain:n,range:r}=t,i=n$(t,EAe),{domain:a,range:o}=e,l=n$(e,TAe);return!r$(n,a)||!r$(r,o)?!1:uv(i,l)}var CAe=["dangerouslySetInnerHTML","ticks"],jAe=["id"];function b3(){return b3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},b3.apply(null,arguments)}function i$(t,e){if(t==null)return{};var n,r,i=PAe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function PAe(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 DAe(t){var e=Lr(),n=_.useRef(null);return _.useLayoutEffect(()=>{n.current===null?e(E2e(t)):n.current!==t&&e(T2e({prev:n.current,next:t})),n.current=t},[t,e]),_.useLayoutEffect(()=>()=>{n.current&&(e(A2e(n.current)),n.current=null)},[e]),null}var RAe=t=>{var{xAxisId:e,className:n}=t,r=It(aO),i=ra(),a="xAxis",o=It(y=>Sh(y,a,e,i)),l=It(y=>iQ(y,a,e,i)),c=It(y=>eQ(y,e)),u=It(y=>j_e(y,e)),d=It(y=>OY(y,e));if(c==null||u==null||d==null)return null;var{dangerouslySetInnerHTML:f,ticks:p}=t,m=i$(t,CAe),{id:x}=d,b=i$(d,jAe);return _.createElement(O4,b3({},m,b,{scale:o,x:u.x,y:u.y,width:c.width,height:c.height,className:tr("recharts-".concat(a," ").concat(a),n),viewBox:r,ticks:l,axisType:a}))},OAe={allowDataOverflow:fa.allowDataOverflow,allowDecimals:fa.allowDecimals,allowDuplicatedCategory:fa.allowDuplicatedCategory,angle:fa.angle,axisLine:Eu.axisLine,height:fa.height,hide:!1,includeHidden:fa.includeHidden,interval:fa.interval,minTickGap:fa.minTickGap,mirror:fa.mirror,orientation:fa.orientation,padding:fa.padding,reversed:fa.reversed,scale:fa.scale,tick:fa.tick,tickCount:fa.tickCount,tickLine:Eu.tickLine,tickSize:Eu.tickSize,type:fa.type,xAxisId:0},LAe=t=>{var e=li(t,OAe);return _.createElement(_.Fragment,null,_.createElement(DAe,{allowDataOverflow:e.allowDataOverflow,allowDecimals:e.allowDecimals,allowDuplicatedCategory:e.allowDuplicatedCategory,angle:e.angle,dataKey:e.dataKey,domain:e.domain,height:e.height,hide:e.hide,id:e.xAxisId,includeHidden:e.includeHidden,interval:e.interval,minTickGap:e.minTickGap,mirror:e.mirror,name:e.name,orientation:e.orientation,padding:e.padding,reversed:e.reversed,scale:e.scale,tick:e.tick,tickCount:e.tickCount,tickFormatter:e.tickFormatter,ticks:e.ticks,type:e.type,unit:e.unit}),_.createElement(RAe,e))},$S=_.memo(LAe,DZ);$S.displayName="XAxis";var FAe=["dangerouslySetInnerHTML","ticks"],IAe=["id"];function y3(){return y3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},y3.apply(null,arguments)}function a$(t,e){if(t==null)return{};var n,r,i=UAe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function UAe(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 zAe(t){var e=Lr(),n=_.useRef(null);return _.useLayoutEffect(()=>{n.current===null?e(C2e(t)):n.current!==t&&e(j2e({prev:n.current,next:t})),n.current=t},[t,e]),_.useLayoutEffect(()=>()=>{n.current&&(e(P2e(n.current)),n.current=null)},[e]),null}var BAe=t=>{var{yAxisId:e,className:n,width:r,label:i}=t,a=_.useRef(null),o=_.useRef(null),l=It(aO),c=ra(),u=Lr(),d="yAxis",f=It(k=>Sh(k,d,e,c)),p=It(k=>tQ(k,e)),m=It(k=>D_e(k,e)),x=It(k=>iQ(k,d,e,c)),b=It(k=>LY(k,e));if(_.useLayoutEffect(()=>{if(!(r!=="auto"||!p||w4(i)||_.isValidElement(i)||b==null)){var k=a.current;if(k){var C=k.getCalculatedWidth();Math.round(p.width)!==Math.round(C)&&u(D2e({id:e,width:C}))}}},[x,p,u,i,e,r,b]),p==null||m==null||b==null)return null;var{dangerouslySetInnerHTML:y,ticks:v}=t,S=a$(t,FAe),{id:N}=b,T=a$(b,IAe);return _.createElement(O4,y3({},S,T,{ref:a,labelRef:o,scale:f,x:m.x,y:m.y,tickTextProps:r==="auto"?{width:void 0}:{width:r},width:p.width,height:p.height,className:tr("recharts-".concat(d," ").concat(d),n),viewBox:l,ticks:x,axisType:d}))},HAe={allowDataOverflow:ma.allowDataOverflow,allowDecimals:ma.allowDecimals,allowDuplicatedCategory:ma.allowDuplicatedCategory,angle:ma.angle,axisLine:Eu.axisLine,hide:!1,includeHidden:ma.includeHidden,interval:ma.interval,minTickGap:ma.minTickGap,mirror:ma.mirror,orientation:ma.orientation,padding:ma.padding,reversed:ma.reversed,scale:ma.scale,tick:ma.tick,tickCount:ma.tickCount,tickLine:Eu.tickLine,tickSize:Eu.tickSize,type:ma.type,width:ma.width,yAxisId:0},$Ae=t=>{var e=li(t,HAe);return _.createElement(_.Fragment,null,_.createElement(zAe,{interval:e.interval,id:e.yAxisId,scale:e.scale,type:e.type,domain:e.domain,allowDataOverflow:e.allowDataOverflow,dataKey:e.dataKey,allowDuplicatedCategory:e.allowDuplicatedCategory,allowDecimals:e.allowDecimals,tickCount:e.tickCount,padding:e.padding,includeHidden:e.includeHidden,reversed:e.reversed,ticks:e.ticks,width:e.width,orientation:e.orientation,mirror:e.mirror,hide:e.hide,unit:e.unit,name:e.name,angle:e.angle,minTickGap:e.minTickGap,tick:e.tick,tickFormatter:e.tickFormatter}),_.createElement(BAe,e))},VS=_.memo($Ae,DZ);VS.displayName="YAxis";var VAe=(t,e)=>e,F4=nt([VAe,Vn,DY,aa,vQ,Xu,K1e,na],tSe),I4=t=>{var e=t.currentTarget.getBoundingClientRect(),n=e.width/t.currentTarget.offsetWidth,r=e.height/t.currentTarget.offsetHeight;return{chartX:Math.round((t.clientX-e.left)/n),chartY:Math.round((t.clientY-e.top)/r)}},RZ=ul("mouseClick"),OZ=$y();OZ.startListening({actionCreator:RZ,effect:(t,e)=>{var n=t.payload,r=F4(e.getState(),I4(n));r?.activeIndex!=null&&e.dispatch(W_e({activeIndex:r.activeIndex,activeDataKey:void 0,activeCoordinate:r.activeCoordinate}))}});var v3=ul("mouseMove"),LZ=$y(),Qw=null;LZ.startListening({actionCreator:v3,effect:(t,e)=>{var n=t.payload;Qw!==null&&cancelAnimationFrame(Qw);var r=I4(n);Qw=requestAnimationFrame(()=>{var i=e.getState(),a=u4(i,i.tooltip.settings.shared);if(a==="axis"){var o=F4(i,r);o?.activeIndex!=null?e.dispatch(hQ({activeIndex:o.activeIndex,activeDataKey:void 0,activeCoordinate:o.activeCoordinate})):e.dispatch(dQ())}Qw=null})}});var s$={accessibilityLayer:!0,barCategoryGap:"10%",barGap:4,barSize:void 0,className:void 0,maxBarSize:void 0,stackOffset:"none",syncId:void 0,syncMethod:"index",baseValue:void 0,reverseStackOrder:!1},FZ=Vs({name:"rootProps",initialState:s$,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:s$.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}}}),GAe=FZ.reducer,{updateOptions:qAe}=FZ.actions,IZ=Vs({name:"polarOptions",initialState:null,reducers:{updatePolarOptions:(t,e)=>e.payload}}),{updatePolarOptions:WAe}=IZ.actions,KAe=IZ.reducer,UZ=ul("keyDown"),zZ=ul("focus"),U4=$y();U4.startListening({actionCreator:UZ,effect:(t,e)=>{var n=e.getState(),r=n.rootProps.accessibilityLayer!==!1;if(r){var{keyboardInteraction:i}=n.tooltip,a=t.payload;if(!(a!=="ArrowRight"&&a!=="ArrowLeft"&&a!=="Enter")){var o=d4(i,Ax(n),rv(n),ov(n)),l=o==null?-1:Number(o);if(!(!Number.isFinite(l)||l<0)){var c=Xu(n);if(a==="Enter"){var u=jS(n,"axis","hover",String(i.index));e.dispatch(u3({active:!i.active,activeIndex:i.index,activeDataKey:i.dataKey,activeCoordinate:u}));return}var d=F_e(n),f=d==="left-to-right"?1:-1,p=a==="ArrowRight"?1:-1,m=l+p*f;if(!(c==null||m>=c.length||m<0)){var x=jS(n,"axis","hover",String(m));e.dispatch(u3({active:!0,activeIndex:m.toString(),activeDataKey:void 0,activeCoordinate:x}))}}}}}});U4.startListening({actionCreator:zZ,effect:(t,e)=>{var n=e.getState(),r=n.rootProps.accessibilityLayer!==!1;if(r){var{keyboardInteraction:i}=n.tooltip;if(!i.active&&i.index==null){var a="0",o=jS(n,"axis","hover",String(a));e.dispatch(u3({activeDataKey:void 0,active:!0,activeIndex:a,activeCoordinate:o}))}}}});var Uo=ul("externalEvent"),BZ=$y(),FA=new Map;BZ.startListening({actionCreator:Uo,effect:(t,e)=>{var{handler:n,reactEvent:r}=t.payload;if(n!=null){r.persist();var i=r.type,a=FA.get(i);a!==void 0&&cancelAnimationFrame(a);var o=requestAnimationFrame(()=>{try{var l=e.getState(),c={activeCoordinate:D1e(l),activeDataKey:g4(l),activeIndex:Mh(l),activeLabel:SQ(l),activeTooltipIndex:Mh(l),isTooltipActive:R1e(l)};n(c,r)}finally{FA.delete(i)}});FA.set(i,o)}}});var XAe=nt([Tx],t=>t.tooltipItemPayloads),YAe=nt([XAe,av,(t,e,n)=>e,(t,e,n)=>n],(t,e,n,r)=>{var i=t.find(l=>l.settings.dataKey===r);if(i!=null){var{positions:a}=i;if(a!=null){var o=e(a,n);return o}}}),HZ=ul("touchMove"),$Z=$y();$Z.startListening({actionCreator:HZ,effect:(t,e)=>{var n=t.payload;if(!(n.touches==null||n.touches.length===0)){var r=e.getState(),i=u4(r,r.tooltip.settings.shared);if(i==="axis"){var a=F4(r,I4({clientX:n.touches[0].clientX,clientY:n.touches[0].clientY,currentTarget:n.currentTarget}));a?.activeIndex!=null&&e.dispatch(hQ({activeIndex:a.activeIndex,activeDataKey:void 0,activeCoordinate:a.activeCoordinate}))}else if(i==="item"){var o,l=n.touches[0];if(document.elementFromPoint==null)return;var c=document.elementFromPoint(l.clientX,l.clientY);if(!c||!c.getAttribute)return;var u=c.getAttribute(rX),d=(o=c.getAttribute(iX))!==null&&o!==void 0?o:void 0,f=YAe(e.getState(),u,d);e.dispatch(uQ({activeDataKey:d,activeIndex:u,activeCoordinate:f}))}}}});var QAe=MK({brush:wEe,cartesianAxis:R2e,chartData:PSe,errorBars:J2e,graphicalItems:BNe,layout:axe,legend:fbe,options:ESe,polarAxis:nNe,polarOptions:KAe,referenceElements:PEe,rootProps:GAe,tooltip:K_e,zIndex:pSe}),ZAe=function(e){return Cge({reducer:QAe,preloadedState:e,middleware:n=>{var r;return n({serializableCheck:!1,immutableCheck:!["commonjs","es6","production"].includes((r="es6")!==null&&r!==void 0?r:"")}).concat([OZ.middleware,LZ.middleware,U4.middleware,BZ.middleware,$Z.middleware])},enhancers:n=>{var r=n;return typeof n=="function"&&(r=n()),r.concat(UK({type:"raf"}))},devTools:yx.devToolsEnabled})};function VZ(t){var{preloadedState:e,children:n,reduxStoreName:r}=t,i=ra(),a=_.useRef(null);if(i)return n;a.current==null&&(a.current=ZAe(e));var o=YR;return _.createElement(Ske,{context:o,store:a.current},n)}function JAe(t){var{layout:e,margin:n}=t,r=Lr(),i=ra();return _.useEffect(()=>{i||(r(nxe(e)),r(txe(n)))},[r,i,e,n]),null}var GZ=_.memo(JAe,uv);function qZ(t){var e=Lr();return _.useEffect(()=>{e(qAe(t))},[e,t]),null}function o$(t){var{zIndex:e,isPanorama:n}=t,r=n?"recharts-zindex-panorama-":"recharts-zindex-",i=eZ("".concat(r).concat(e)),a=Lr();return _.useLayoutEffect(()=>(a(fSe({zIndex:e,elementId:i,isPanorama:n})),()=>{a(mSe({zIndex:e,isPanorama:n}))}),[a,e,i,n]),_.createElement("g",{tabIndex:-1,id:i})}function l$(t){var{children:e,isPanorama:n}=t,r=It(rSe);if(!r||r.length===0)return e;var i=r.filter(o=>o<0),a=r.filter(o=>o>0);return _.createElement(_.Fragment,null,i.map(o=>_.createElement(o$,{key:o,zIndex:o,isPanorama:n})),e,a.map(o=>_.createElement(o$,{key:o,zIndex:o,isPanorama:n})))}var eCe=["children"];function tCe(t,e){if(t==null)return{};var n,r,i=nCe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function nCe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function GS(){return GS=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},GS.apply(null,arguments)}var rCe={width:"100%",height:"100%",display:"block"},iCe=_.forwardRef((t,e)=>{var n=oO(),r=lO(),i=vX();if(!pc(n)||!pc(r))return null;var{children:a,otherAttributes:o,title:l,desc:c}=t,u,d;return o!=null&&(typeof o.tabIndex=="number"?u=o.tabIndex:u=i?0:void 0,typeof o.role=="string"?d=o.role:d=i?"application":void 0),_.createElement(zR,GS({},o,{title:l,desc:c,role:d,tabIndex:u,width:n,height:r,style:rCe,ref:e}),a)}),aCe=t=>{var{children:e}=t,n=It(ON);if(!n)return null;var{width:r,height:i,y:a,x:o}=n;return _.createElement(zR,{width:r,height:i,x:o,y:a},e)},c$=_.forwardRef((t,e)=>{var{children:n}=t,r=tCe(t,eCe),i=ra();return i?_.createElement(aCe,null,_.createElement(l$,{isPanorama:!0},n)):_.createElement(iCe,GS({ref:e},r),_.createElement(l$,{isPanorama:!1},n))});function sCe(){var t=Lr(),[e,n]=_.useState(null),r=It(_xe);return _.useEffect(()=>{if(e!=null){var i=e.getBoundingClientRect(),a=i.width/e.offsetWidth;vr(a)&&a!==r&&t(ixe(a))}},[e,t,r]),n}function u$(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 oCe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?u$(Object(n),!0).forEach(function(r){lCe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):u$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function lCe(t,e,n){return(e=cCe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function cCe(t){var e=uCe(t,"string");return typeof e=="symbol"?e:e+""}function uCe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function mm(){return mm=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},mm.apply(null,arguments)}var dCe=()=>(BSe(),null);function qS(t){if(typeof t=="number")return t;if(typeof t=="string"){var e=parseFloat(t);if(!Number.isNaN(e))return e}return 0}var hCe=_.forwardRef((t,e)=>{var n,r,i=_.useRef(null),[a,o]=_.useState({containerWidth:qS((n=t.style)===null||n===void 0?void 0:n.width),containerHeight:qS((r=t.style)===null||r===void 0?void 0:r.height)}),l=_.useCallback((u,d)=>{o(f=>{var p=Math.round(u),m=Math.round(d);return f.containerWidth===p&&f.containerHeight===m?f:{containerWidth:p,containerHeight:m}})},[]),c=_.useCallback(u=>{if(typeof e=="function"&&e(u),u!=null&&typeof ResizeObserver<"u"){var{width:d,height:f}=u.getBoundingClientRect();l(d,f);var p=x=>{var{width:b,height:y}=x[0].contentRect;l(b,y)},m=new ResizeObserver(p);m.observe(u),i.current=m}},[e,l]);return _.useEffect(()=>()=>{var u=i.current;u?.disconnect()},[l]),_.createElement(_.Fragment,null,_.createElement(LN,{width:a.containerWidth,height:a.containerHeight}),_.createElement("div",mm({ref:c},t)))}),fCe=_.forwardRef((t,e)=>{var{width:n,height:r}=t,[i,a]=_.useState({containerWidth:qS(n),containerHeight:qS(r)}),o=_.useCallback((c,u)=>{a(d=>{var f=Math.round(c),p=Math.round(u);return d.containerWidth===f&&d.containerHeight===p?d:{containerWidth:f,containerHeight:p}})},[]),l=_.useCallback(c=>{if(typeof e=="function"&&e(c),c!=null){var{width:u,height:d}=c.getBoundingClientRect();o(u,d)}},[e,o]);return _.createElement(_.Fragment,null,_.createElement(LN,{width:i.containerWidth,height:i.containerHeight}),_.createElement("div",mm({ref:l},t)))}),mCe=_.forwardRef((t,e)=>{var{width:n,height:r}=t;return _.createElement(_.Fragment,null,_.createElement(LN,{width:n,height:r}),_.createElement("div",mm({ref:e},t)))}),pCe=_.forwardRef((t,e)=>{var{width:n,height:r}=t;return Lu(n)||Lu(r)?_.createElement(fCe,mm({},t,{ref:e})):_.createElement(mCe,mm({},t,{ref:e}))});function gCe(t){return t===!0?hCe:pCe}var xCe=_.forwardRef((t,e)=>{var{children:n,className:r,height:i,onClick:a,onContextMenu:o,onDoubleClick:l,onMouseDown:c,onMouseEnter:u,onMouseLeave:d,onMouseMove:f,onMouseUp:p,onTouchEnd:m,onTouchMove:x,onTouchStart:b,style:y,width:v,responsive:S,dispatchTouchEvents:N=!0}=t,T=_.useRef(null),k=Lr(),[C,E]=_.useState(null),[D,A]=_.useState(null),R=sCe(),U=sO(),F=U?.width>0?U.width:v,$=U?.height>0?U.height:i,j=_.useCallback(ie=>{R(ie),typeof e=="function"&&e(ie),E(ie),A(ie),ie!=null&&(T.current=ie)},[R,e,E,A]),H=_.useCallback(ie=>{k(RZ(ie)),k(Uo({handler:a,reactEvent:ie}))},[k,a]),K=_.useCallback(ie=>{k(v3(ie)),k(Uo({handler:u,reactEvent:ie}))},[k,u]),V=_.useCallback(ie=>{k(dQ()),k(Uo({handler:d,reactEvent:ie}))},[k,d]),Q=_.useCallback(ie=>{k(v3(ie)),k(Uo({handler:f,reactEvent:ie}))},[k,f]),Z=_.useCallback(()=>{k(zZ())},[k]),ae=_.useCallback(ie=>{k(UZ(ie.key))},[k]),B=_.useCallback(ie=>{k(Uo({handler:o,reactEvent:ie}))},[k,o]),X=_.useCallback(ie=>{k(Uo({handler:l,reactEvent:ie}))},[k,l]),ne=_.useCallback(ie=>{k(Uo({handler:c,reactEvent:ie}))},[k,c]),se=_.useCallback(ie=>{k(Uo({handler:p,reactEvent:ie}))},[k,p]),be=_.useCallback(ie=>{k(Uo({handler:b,reactEvent:ie}))},[k,b]),xe=_.useCallback(ie=>{N&&k(HZ(ie)),k(Uo({handler:x,reactEvent:ie}))},[k,N,x]),de=_.useCallback(ie=>{k(Uo({handler:m,reactEvent:ie}))},[k,m]),Pe=gCe(S);return _.createElement(jQ.Provider,{value:C},_.createElement(UW.Provider,{value:D},_.createElement(Pe,{width:F??y?.width,height:$??y?.height,className:tr("recharts-wrapper",r),style:oCe({position:"relative",cursor:"default",width:F,height:$},y),onClick:H,onContextMenu:B,onDoubleClick:X,onFocus:Z,onKeyDown:ae,onMouseDown:ne,onMouseEnter:K,onMouseLeave:V,onMouseMove:Q,onMouseUp:se,onTouchEnd:de,onTouchMove:xe,onTouchStart:be,ref:j},_.createElement(dCe,null),n)))}),bCe=["width","height","responsive","children","className","style","compact","title","desc"];function yCe(t,e){if(t==null)return{};var n,r,i=vCe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function vCe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var WZ=_.forwardRef((t,e)=>{var{width:n,height:r,responsive:i,children:a,className:o,style:l,compact:c,title:u,desc:d}=t,f=yCe(t,bCe),p=xs(f);return c?_.createElement(_.Fragment,null,_.createElement(LN,{width:n,height:r}),_.createElement(c$,{otherAttributes:p,title:u,desc:d},a)):_.createElement(xCe,{className:o,style:l,width:n,height:r,responsive:i??!1,onClick:t.onClick,onMouseLeave:t.onMouseLeave,onMouseEnter:t.onMouseEnter,onMouseMove:t.onMouseMove,onMouseDown:t.onMouseDown,onMouseUp:t.onMouseUp,onContextMenu:t.onContextMenu,onDoubleClick:t.onDoubleClick,onTouchStart:t.onTouchStart,onTouchMove:t.onTouchMove,onTouchEnd:t.onTouchEnd},_.createElement(c$,{otherAttributes:p,title:u,desc:d,ref:e},_.createElement(DEe,null,a)))});function w3(){return w3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},w3.apply(null,arguments)}var wCe={top:5,right:5,bottom:5,left:5},_Ce={accessibilityLayer:!0,barCategoryGap:"10%",barGap:4,layout:"horizontal",margin:wCe,responsive:!1,reverseStackOrder:!1,stackOffset:"none",syncMethod:"index"},z4=_.forwardRef(function(e,n){var r,i=li(e.categoricalChartProps,_Ce),{chartName:a,defaultTooltipEventType:o,validateTooltipEventTypes:l,tooltipPayloadSearcher:c,categoricalChartProps:u}=e,d={chartName:a,defaultTooltipEventType:o,validateTooltipEventTypes:l,tooltipPayloadSearcher:c,eventEmitter:void 0};return _.createElement(VZ,{preloadedState:{options:d},reduxStoreName:(r=u.id)!==null&&r!==void 0?r:a},_.createElement(uZ,{chartData:u.data}),_.createElement(GZ,{layout:i.layout,margin:i.margin}),_.createElement(qZ,{baseValue:i.baseValue,accessibilityLayer:i.accessibilityLayer,barCategoryGap:i.barCategoryGap,maxBarSize:i.maxBarSize,stackOffset:i.stackOffset,barGap:i.barGap,barSize:i.barSize,syncId:i.syncId,syncMethod:i.syncMethod,className:i.className,reverseStackOrder:i.reverseStackOrder}),_.createElement(WZ,w3({},i,{ref:n})))}),SCe=["axis"],MCe=_.forwardRef((t,e)=>_.createElement(z4,{chartName:"LineChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:SCe,tooltipPayloadSearcher:n2,categoricalChartProps:t,ref:e})),NCe=["axis","item"],kCe=_.forwardRef((t,e)=>_.createElement(z4,{chartName:"BarChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:NCe,tooltipPayloadSearcher:n2,categoricalChartProps:t,ref:e}));function ECe(t){var e=Lr();return _.useEffect(()=>{e(WAe(t))},[e,t]),null}var TCe=["layout"];function _3(){return _3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},_3.apply(null,arguments)}function ACe(t,e){if(t==null)return{};var n,r,i=CCe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function CCe(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 jCe={top:5,right:5,bottom:5,left:5},KZ={accessibilityLayer:!0,stackOffset:"none",barCategoryGap:"10%",barGap:4,margin:jCe,reverseStackOrder:!1,syncMethod:"index",layout:"radial",responsive:!1,cx:"50%",cy:"50%",innerRadius:0,outerRadius:"80%"},PCe=_.forwardRef(function(e,n){var r,i=li(e.categoricalChartProps,KZ),{layout:a}=i,o=ACe(i,TCe),{chartName:l,defaultTooltipEventType:c,validateTooltipEventTypes:u,tooltipPayloadSearcher:d}=e,f={chartName:l,defaultTooltipEventType:c,validateTooltipEventTypes:u,tooltipPayloadSearcher:d,eventEmitter:void 0};return _.createElement(VZ,{preloadedState:{options:f},reduxStoreName:(r=i.id)!==null&&r!==void 0?r:l},_.createElement(uZ,{chartData:i.data}),_.createElement(GZ,{layout:a,margin:i.margin}),_.createElement(qZ,{baseValue:void 0,accessibilityLayer:i.accessibilityLayer,barCategoryGap:i.barCategoryGap,maxBarSize:i.maxBarSize,stackOffset:i.stackOffset,barGap:i.barGap,barSize:i.barSize,syncId:i.syncId,syncMethod:i.syncMethod,className:i.className,reverseStackOrder:i.reverseStackOrder}),_.createElement(ECe,{cx:i.cx,cy:i.cy,startAngle:i.startAngle,endAngle:i.endAngle,innerRadius:i.innerRadius,outerRadius:i.outerRadius}),_.createElement(WZ,_3({},o,{ref:n})))});function d$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function h$(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?d$(Object(n),!0).forEach(function(r){DCe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):d$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function DCe(t,e,n){return(e=RCe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function RCe(t){var e=OCe(t,"string");return typeof e=="symbol"?e:e+""}function OCe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var LCe=["item"],FCe=h$(h$({},KZ),{},{layout:"centric",startAngle:0,endAngle:360}),ICe=_.forwardRef((t,e)=>{var n=li(t,FCe);return _.createElement(PCe,{chartName:"PieChart",defaultTooltipEventType:"item",validateTooltipEventTypes:LCe,tooltipPayloadSearcher:n2,categoricalChartProps:n,ref:e})}),UCe=["axis"],zCe=_.forwardRef((t,e)=>_.createElement(z4,{chartName:"AreaChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:UCe,tooltipPayloadSearcher:n2,categoricalChartProps:t,ref:e}));const f$=[{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 BCe({isOpen:t,onClose:e,printerId:n,printerName:r,amsId:i,amsLabel:a,initialMode:o="humidity",thresholds:l}){const{t:c}=Hn(),{mode:u}=Oh(),[d,f]=_.useState("24h"),[p,m]=_.useState(o),x=u==="dark",{data:b}=at({queryKey:["settings"],queryFn:ue.getSettings}),y=b?.time_format||"system";_.useEffect(()=>{if(!t)return;const se=be=>{be.key==="Escape"&&e()};return window.addEventListener("keydown",se),()=>window.removeEventListener("keydown",se)},[t,e]);const v=f$.find(se=>se.value===d)?.hours||24,{data:S,isLoading:N,error:T}=at({queryKey:["ams-history",n,i,v],queryFn:()=>ue.getAMSHistory(n,i,v),enabled:t,refetchInterval:6e4});if(!t)return null;const k=S?.data.map(se=>{const be=Ii(se.recorded_at)||new Date,xe={hour:"2-digit",minute:"2-digit",...v>24?{day:"numeric",month:"short"}:{}};return{time:be.getTime(),humidity:se.humidity,temperature:se.temperature,timeLabel:be.toLocaleTimeString([],y0(xe,y))}})||[],C=l?.humidityGood||40,E=l?.humidityFair||60,D=l?.tempGood||30,A=l?.tempFair||35,R=k[k.length-1],U=R?.humidity,F=R?.temperature,$=se=>{const be=se.filter(Oe=>Oe!=null);if(be.length<4)return"stable";const xe=be.slice(0,Math.floor(be.length/4)),de=be.slice(-Math.floor(be.length/4)),Pe=xe.reduce((Oe,ge)=>Oe+ge,0)/xe.length,Ne=de.reduce((Oe,ge)=>Oe+ge,0)/de.length-Pe;return Math.abs(Ne)<2?"stable":Ne>0?"up":"down"},j=$(k.map(se=>se.humidity)),H=$(k.map(se=>se.temperature)),K=({trend:se})=>se==="up"?s.jsx(yP,{className:"w-4 h-4 text-red-400"}):se==="down"?s.jsx(AW,{className:"w-4 h-4 text-green-400"}):s.jsx(xP,{className:"w-4 h-4 text-gray-400 dark:text-bambu-gray"}),V=se=>se==null?"#9ca3af":se<=C?"#22a352":se<=E?"#d4a017":"#c62828",Q=se=>se==null?"#9ca3af":se<=D?"#22a352":se<=A?"#d4a017":"#c62828",Z=x?"#2d2d2d":"#ffffff",ae=x?"#1d1d1d":"#f3f4f6",B=x?"#3d3d3d":"#e5e7eb",X=x?"#ffffff":"#111827",ne=x?"#9ca3af":"#4b5563";return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:e,children:s.jsxs("div",{className:"rounded-xl w-full max-w-4xl max-h-[90vh] overflow-hidden shadow-xl",style:{backgroundColor:Z},onClick:se=>se.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b",style:{borderColor:B},children:[s.jsxs("div",{children:[s.jsxs("h2",{className:"text-lg font-semibold",style:{color:X},children:[a," ",c("common.history","History")]}),s.jsx("p",{className:"text-sm",style:{color:ne},children:r})]}),s.jsx("button",{onClick:e,className:"p-2 rounded-lg transition-colors",style:{color:ne},children:s.jsx(Rt,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"p-6 space-y-6 overflow-y-auto max-h-[calc(90vh-80px)]",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex gap-1 rounded-lg p-1",style:{backgroundColor:ae},children:[s.jsxs("button",{onClick:()=>m("humidity"),className:`flex items-center gap-2 px-3 py-1.5 text-sm rounded-md transition-colors ${p==="humidity"?"bg-blue-600 text-white":""}`,style:p!=="humidity"?{color:ne}:void 0,children:[s.jsx(AR,{className:"w-4 h-4"}),c("common.humidity","Humidity")]}),s.jsxs("button",{onClick:()=>m("temperature"),className:`flex items-center gap-2 px-3 py-1.5 text-sm rounded-md transition-colors ${p==="temperature"?"bg-orange-600 text-white":""}`,style:p!=="temperature"?{color:ne}:void 0,children:[s.jsx(bN,{className:"w-4 h-4"}),c("common.temperature","Temperature")]})]}),s.jsx("div",{className:"flex gap-1 rounded-lg p-1",style:{backgroundColor:ae},children:f$.map(se=>s.jsx("button",{onClick:()=>f(se.value),className:`px-3 py-1 text-sm rounded-md transition-colors ${d===se.value?"bg-bambu-green text-white":""}`,style:d!==se.value?{color:ne}:void 0,children:se.label},se.value))})]}),s.jsx("div",{className:"grid grid-cols-4 gap-4",children:p==="humidity"?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:ae},children:[s.jsx("p",{className:"text-xs",style:{color:ne},children:c("common.current","Current")}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("p",{className:"text-2xl font-bold",style:{color:V(U)},children:U!=null?`${U}%`:"—"}),s.jsx(K,{trend:j})]})]}),s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:ae},children:[s.jsx("p",{className:"text-xs",style:{color:ne},children:c("common.average","Average")}),s.jsx("p",{className:"text-2xl font-bold",style:{color:X},children:S?.avg_humidity!=null?`${S.avg_humidity}%`:"—"})]}),s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:ae},children:[s.jsx("p",{className:"text-xs",style:{color:ne},children:c("common.min","Min")}),s.jsx("p",{className:"text-2xl font-bold text-green-500",children:S?.min_humidity!=null?`${S.min_humidity}%`:"—"})]}),s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:ae},children:[s.jsx("p",{className:"text-xs",style:{color:ne},children:c("common.max","Max")}),s.jsx("p",{className:"text-2xl font-bold text-red-500",children:S?.max_humidity!=null?`${S.max_humidity}%`:"—"})]})]}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:ae},children:[s.jsx("p",{className:"text-xs",style:{color:ne},children:c("common.current","Current")}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("p",{className:"text-2xl font-bold",style:{color:Q(F)},children:F!=null?`${F}°C`:"—"}),s.jsx(K,{trend:H})]})]}),s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:ae},children:[s.jsx("p",{className:"text-xs",style:{color:ne},children:c("common.average","Average")}),s.jsx("p",{className:"text-2xl font-bold",style:{color:X},children:S?.avg_temperature!=null?`${S.avg_temperature}°C`:"—"})]}),s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:ae},children:[s.jsx("p",{className:"text-xs",style:{color:ne},children:c("common.min","Min")}),s.jsx("p",{className:"text-2xl font-bold text-blue-500",children:S?.min_temperature!=null?`${S.min_temperature}°C`:"—"})]}),s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:ae},children:[s.jsx("p",{className:"text-xs",style:{color:ne},children:c("common.max","Max")}),s.jsx("p",{className:"text-2xl font-bold text-red-500",children:S?.max_temperature!=null?`${S.max_temperature}°C`:"—"})]})]})}),s.jsx("div",{className:"rounded-lg p-4",style:{backgroundColor:ae},children:N?s.jsx("div",{className:"h-[300px] flex items-center justify-center",style:{color:ne},children:c("common.loading","Loading...")}):T?s.jsx("div",{className:"h-[300px] flex items-center justify-center text-red-500",children:c("common.error","Error loading data")}):k.length===0?s.jsx("div",{className:"h-[300px] flex items-center justify-center",style:{color:ne},children:c("common.noData","No data available for this time range")}):s.jsx(v1,{width:"100%",height:300,children:s.jsxs(MCe,{data:k,children:[s.jsx(BS,{strokeDasharray:"3 3",stroke:x?"#3d3d3d":"#e5e7eb"}),s.jsx($S,{dataKey:"time",type:"number",domain:["dataMin","dataMax"],tickFormatter:se=>{const be=new Date(se);return v>24?be.toLocaleDateString([],{day:"numeric",month:"short"}):be.toLocaleTimeString([],y0({hour:"2-digit",minute:"2-digit"},y))},stroke:x?"#9ca3af":"#6b7280",tick:{fontSize:12}}),s.jsx(VS,{stroke:x?"#9ca3af":"#6b7280",tick:{fontSize:12},domain:p==="humidity"?[0,100]:["auto","auto"],tickFormatter:se=>p==="humidity"?`${se}%`:`${se}°C`}),s.jsx(_1,{contentStyle:{backgroundColor:x?"#2d2d2d":"#ffffff",border:`1px solid ${x?"#3d3d3d":"#e5e7eb"}`,borderRadius:"8px",color:x?"#fff":"#000"},labelFormatter:se=>new Date(se).toLocaleString(void 0,y0({year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"},y)),formatter:se=>[p==="humidity"?`${se??0}%`:`${se??0}°C`,p==="humidity"?"Humidity":"Temperature"]}),s.jsx(dO,{}),p==="humidity"?s.jsxs(s.Fragment,{children:[s.jsx(s0,{y:C,stroke:"#22a352",strokeDasharray:"5 5",label:{value:"Good",fill:"#22a352",fontSize:10}}),s.jsx(s0,{y:E,stroke:"#d4a017",strokeDasharray:"5 5",label:{value:"Fair",fill:"#d4a017",fontSize:10}})]}):s.jsxs(s.Fragment,{children:[s.jsx(s0,{y:D,stroke:"#22a352",strokeDasharray:"5 5",label:{value:"Good",fill:"#22a352",fontSize:10}}),s.jsx(s0,{y:A,stroke:"#d4a017",strokeDasharray:"5 5",label:{value:"Fair",fill:"#d4a017",fontSize:10}})]}),s.jsx(MZ,{type:"monotone",dataKey:p,name:p==="humidity"?"Humidity":"Temperature",stroke:p==="humidity"?"#3b82f6":"#f97316",strokeWidth:2,dot:!1,activeDot:{r:4}})]})})}),s.jsx("div",{className:"text-xs text-center",style:{color:ne},children:c("amsHistory.recordingInfo","Data is recorded every 5 minutes while the printer is connected")})]})]})})}function IA({data:t,children:e,disabled:n,className:r="",spoolman:i,configureSlot:a}){const{t:o}=Hn(),[l,c]=_.useState(!1),[u,d]=_.useState("top"),[f,p]=_.useState(!1),m=_.useRef(null),x=_.useRef(null),b=_.useRef(null),y=()=>{const E=t.trayUuid;E&&(navigator.clipboard&&window.isSecureContext?navigator.clipboard.writeText(E).then(()=>{p(!0),setTimeout(()=>p(!1),2e3)}).catch(()=>{v(E)}):v(E))},v=E=>{const D=document.createElement("textarea");D.value=E,D.style.position="fixed",D.style.opacity="0",document.body.appendChild(D),D.select();try{document.execCommand("copy"),p(!0),setTimeout(()=>p(!1),2e3)}catch{console.error("Failed to copy to clipboard")}document.body.removeChild(D)};_.useEffect(()=>{if(l&&m.current&&x.current){const E=m.current.getBoundingClientRect(),D=x.current.offsetHeight,A=E.top,R=window.innerHeight-E.bottom;A<D+12&&R>A?d("bottom"):d("top")}},[l]);const S=()=>{n||(b.current&&clearTimeout(b.current),b.current=setTimeout(()=>c(!0),80))},N=()=>{b.current&&clearTimeout(b.current),b.current=setTimeout(()=>c(!1),100)};_.useEffect(()=>()=>{b.current&&clearTimeout(b.current)},[]);const T=E=>E<=15?"#ef4444":E<=30?"#f97316":E<=50?"#eab308":"#22c55e",k=E=>{if(!E)return!1;const D=E.replace("#",""),A=parseInt(D.slice(0,2),16),R=parseInt(D.slice(2,4),16),U=parseInt(D.slice(4,6),16);return(.299*A+.587*R+.114*U)/255>.6},C=t.colorHex?`#${t.colorHex.replace("#","")}`:null;return s.jsxs("div",{ref:m,className:`relative ${r}`,onMouseEnter:S,onMouseLeave:N,children:[e,l&&s.jsxs("div",{ref:x,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:[s.jsxs("div",{className:`
- w-52 bg-bambu-dark-secondary border border-bambu-dark-tertiary
- rounded-lg shadow-xl overflow-hidden
- backdrop-blur-sm
- `,children:[s.jsxs("div",{className:"h-12 relative overflow-hidden",style:{backgroundColor:C||"#3d3d3d"},children:[s.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-white/10 to-transparent"}),s.jsx("div",{className:`
- absolute inset-0 flex items-center justify-center
- font-semibold text-sm tracking-wide
- ${k(C)?"text-black/80":"text-white/90"}
- `,children:t.colorName}),s.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"})]}),s.jsxs("div",{className:"p-3 space-y-2.5",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:o("ams.profile")}),s.jsx("span",{className:"text-xs text-white font-semibold truncate max-w-[120px]",children:t.profile})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:o("ams.kFactor")}),s.jsx("span",{className:"text-xs text-bambu-green font-mono font-bold",children:t.kFactor})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium flex items-center gap-1",children:[s.jsx(AR,{className:"w-3 h-3"}),o("ams.fill")]}),s.jsx("span",{className:"text-xs text-white font-semibold",children:t.fillLevel!==null?`${t.fillLevel}%`:"—"})]}),s.jsx("div",{className:"h-1.5 bg-black/40 rounded-full overflow-hidden",children:t.fillLevel!==null?s.jsx("div",{className:"h-full rounded-full transition-all duration-300",style:{width:`${t.fillLevel}%`,backgroundColor:T(t.fillLevel)}}):s.jsx("div",{className:"h-full w-full bg-bambu-gray/30 rounded-full"})})]}),i?.enabled&&t.trayUuid&&s.jsxs("div",{className:"pt-2 mt-2 border-t border-bambu-dark-tertiary space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:o("spoolman.spoolId")}),s.jsxs("button",{onClick:E=>{E.stopPropagation(),y()},className:"flex items-center gap-1 text-xs text-bambu-gray hover:text-white transition-colors",title:"Copy spool UUID",children:[s.jsxs("span",{className:"font-mono text-[10px] truncate max-w-[80px]",children:[t.trayUuid.slice(0,8),"..."]}),f?s.jsx(Ia,{className:"w-3 h-3 text-bambu-green"}):s.jsx(Fl,{className:"w-3 h-3"})]})]}),i.linkedSpoolId&&i.spoolmanUrl&&s.jsxs("a",{href:`${i.spoolmanUrl.replace(/\/$/,"")}/spool/show/${i.linkedSpoolId}`,target:"_blank",rel:"noopener noreferrer",onClick:E=>E.stopPropagation(),className:"w-full flex items-center justify-center gap-1.5 px-2 py-1.5 text-xs font-medium rounded transition-colors bg-bambu-green/20 hover:bg-bambu-green/30 text-bambu-green",title:o("spoolman.openInSpoolman"),children:[s.jsx(Kr,{className:"w-3.5 h-3.5"}),o("spoolman.openInSpoolman")]}),!i.linkedSpoolId&&i.onLinkSpool&&s.jsxs("button",{onClick:E=>{E.stopPropagation(),i.hasUnlinkedSpools!==!1&&i.onLinkSpool?.(t.trayUuid)},disabled:i.hasUnlinkedSpools===!1,className:`w-full flex items-center justify-center gap-1.5 px-2 py-1.5 text-xs font-medium rounded transition-colors ${i.hasUnlinkedSpools===!1?"bg-bambu-gray/10 text-bambu-gray cursor-not-allowed":"bg-bambu-green/20 hover:bg-bambu-green/30 text-bambu-green"}`,title:i.hasUnlinkedSpools===!1?o("spoolman.noUnlinkedSpools"):o("spoolman.linkToSpoolman"),children:[s.jsx(uc,{className:"w-3.5 h-3.5"}),o("spoolman.linkToSpoolman")]})]}),a?.enabled&&s.jsx("div",{className:`${i?.enabled&&t.trayUuid?"":"pt-2 mt-2 border-t border-bambu-dark-tertiary"}`,children:s.jsxs("button",{onClick:E=>{E.stopPropagation(),a.onConfigure?.()},className:"w-full flex items-center justify-center gap-1.5 px-2 py-1.5 text-xs font-medium rounded transition-colors bg-bambu-blue/20 hover:bg-bambu-blue/30 text-bambu-blue",title:o("ams.configureSlot"),children:[s.jsx(bh,{className:"w-3.5 h-3.5"}),o("ams.configure")]})})]})]}),s.jsx("div",{className:`
- 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 m$({children:t,className:e="",configureSlot:n}){const{t:r}=Hn(),[i,a]=_.useState(!1),o=_.useRef(null),l=()=>{o.current&&clearTimeout(o.current),o.current=setTimeout(()=>a(!0),80)},c=()=>{o.current&&clearTimeout(o.current),o.current=setTimeout(()=>a(!1),100)};return _.useEffect(()=>()=>{o.current&&clearTimeout(o.current)},[]),s.jsxs("div",{className:`relative ${e}`,onMouseEnter:l,onMouseLeave:c,children:[t,i&&s.jsxs("div",{className:`
- 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:[s.jsxs("div",{className:`
- bg-bambu-dark-secondary border border-bambu-dark-tertiary
- rounded-md shadow-lg overflow-hidden
- `,children:[s.jsx("div",{className:"px-3 py-1.5 text-xs text-bambu-gray whitespace-nowrap",children:r("ams.emptySlot")}),n?.enabled&&s.jsx("div",{className:"px-2 pb-2",children:s.jsxs("button",{onClick:u=>{u.stopPropagation(),n.onConfigure?.()},className:"w-full flex items-center justify-center gap-1.5 px-2 py-1.5 text-xs font-medium rounded transition-colors bg-bambu-blue/20 hover:bg-bambu-blue/30 text-bambu-blue",title:r("ams.configureSlot"),children:[s.jsx(bh,{className:"w-3.5 h-3.5"}),r("ams.configure")]})})]}),s.jsx("div",{className:`
- 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 HCe({isOpen:t,onClose:e,trayUuid:n,trayInfo:r}){const{t:i}=Hn(),a=an(),{showToast:o}=$n(),[l,c]=_.useState(null),{data:u,isLoading:d}=at({queryKey:["unlinked-spools"],queryFn:ue.getUnlinkedSpools,enabled:t}),f=mt({mutationFn:m=>ue.linkSpool(m,n),onSuccess:()=>{a.invalidateQueries({queryKey:["unlinked-spools"]}),a.invalidateQueries({queryKey:["linked-spools"]}),a.invalidateQueries({queryKey:["spoolman-status"]}),o(i("spoolman.linkSuccess"),"success"),e()},onError:m=>{o(`${i("spoolman.linkFailed")}: ${m.message}`,"error")}});if(!t)return null;const p=()=>{l&&f.mutate(l)};return s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[s.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:e}),s.jsxs("div",{className:"relative w-full max-w-md mx-4 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl shadow-2xl",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(uc,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:i("spoolman.linkToSpoolman")})]}),s.jsx("button",{onClick:e,className:"p-1 text-bambu-gray hover:text-white rounded transition-colors",children:s.jsx(Rt,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"p-4 space-y-4",children:[r&&s.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[s.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Linking AMS tray:"}),s.jsxs("div",{className:"flex items-center gap-2",children:[r.color&&s.jsx("span",{className:"w-4 h-4 rounded-full border border-white/20",style:{backgroundColor:`#${r.color}`}}),s.jsx("span",{className:"text-white font-medium",children:r.type}),s.jsxs("span",{className:"text-bambu-gray",children:["(",r.location,")"]})]})]}),s.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[s.jsxs("p",{className:"text-xs text-bambu-gray mb-1",children:[i("spoolman.spoolId"),":"]}),s.jsx("code",{className:"text-xs text-bambu-green font-mono break-all",children:n})]}),s.jsxs("div",{children:[s.jsxs("p",{className:"text-sm text-bambu-gray mb-2",children:[i("spoolman.selectSpool"),":"]}),d?s.jsx("div",{className:"flex justify-center py-8",children:s.jsx(ht,{className:"w-6 h-6 text-bambu-green animate-spin"})}):u&&u.length>0?s.jsx("div",{className:"max-h-64 overflow-y-auto space-y-2",children:u.map(m=>s.jsx("button",{onClick:()=>c(m.id),className:`w-full p-3 rounded-lg border text-left transition-colors ${l===m.id?"bg-bambu-green/20 border-bambu-green":"bg-bambu-dark border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:s.jsxs("div",{className:"flex items-center gap-2",children:[m.filament_color_hex&&s.jsx("span",{className:"w-4 h-4 rounded-full border border-white/20 flex-shrink-0",style:{backgroundColor:`#${m.filament_color_hex}`}}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-white font-medium truncate",children:m.filament_name||"Unknown filament"}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[m.filament_material||"Unknown",m.remaining_weight!==null&&` - ${Math.round(m.remaining_weight)}g`,m.location&&` - ${m.location}`]})]}),l===m.id&&s.jsx(Ia,{className:"w-4 h-4 text-bambu-green flex-shrink-0"})]})},m.id))}):s.jsx("div",{className:"text-center py-8 text-bambu-gray",children:s.jsx("p",{children:i("spoolman.noUnlinkedSpools")})})]})]}),s.jsxs("div",{className:"flex justify-end gap-2 p-4 border-t border-bambu-dark-tertiary",children:[s.jsx(Te,{variant:"secondary",onClick:e,children:i("common.cancel")}),s.jsx(Te,{onClick:p,disabled:!l||f.isPending,children:f.isPending?s.jsxs(s.Fragment,{children:[s.jsx(ht,{className:"w-4 h-4 animate-spin"}),i("spoolman.syncing")]}):s.jsxs(s.Fragment,{children:[s.jsx(uc,{className:"w-4 h-4"}),i("spoolman.linkToSpoolman")]})})]}),f.isError&&s.jsx("div",{className:"mx-4 mb-4 p-2 bg-red-500/20 border border-red-500/50 rounded text-sm text-red-400",children:f.error.message})]})]})}function $Ce(t,e){if(t===255)return"External";let n,r=!1;t>=128&&t<=135?(n=t-128,r=!0):t>=0&&t<=3?(n=t,r=e===1):n=0,n=Math.max(0,Math.min(n,7));const i=String.fromCharCode(65+n);return r?`HT-${i}`:`AMS-${i}`}function p$(t){const e=t.includes("_")?t.split("_")[0]:t;return e.startsWith("GFS")?"GF"+e.slice(3):(e.startsWith("PFUS")||e.startsWith("PFSP"),e)}const VCe=["PLA","PETG","ABS","ASA","TPU","PC","PA","NYLON","PVA","HIPS","PP","PET"];function g$(t){const e=t.replace(/@.+$/,"").trim(),n=e.toUpperCase();for(const i of VCe){const a=new RegExp(`\\b${i}\\b`,"i");if(a.test(n)){const o=e.split(a),l=o[0]?.trim()||"",c=o[1]?.trim()||"";return{material:i,brand:l,variant:c}}}const r=e.split(/\s+/);return r.length>=2?{material:r[1],brand:r[0],variant:r.slice(2).join(" ")}:{material:e,brand:"",variant:""}}function UA(t){return!t.startsWith("GF")&&!t.startsWith("P1")}const GCe={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"},qCe=[{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"}],WCe=[{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 KCe(t){const e=t.toLowerCase().trim();return GCe[e]||null}function XCe({isOpen:t,onClose:e,printerId:n,slotInfo:r,nozzleDiameter:i="0.4",onSuccess:a}){const[o,l]=_.useState(""),[c,u]=_.useState(null),[d,f]=_.useState(""),[p,m]=_.useState(""),[x,b]=_.useState(""),[y,v]=_.useState(!1),[S,N]=_.useState(!1),{data:T,isLoading:k}=at({queryKey:["cloudSettings"],queryFn:()=>ue.getCloudSettings(),enabled:t}),{data:C,isLoading:E}=at({queryKey:["kprofiles",n,i],queryFn:()=>ue.getKProfiles(n,i),enabled:t&&!!n}),D=mt({mutationFn:async()=>{if(!o)throw new Error("No filament preset selected");const Q=T?.filament.find(ie=>ie.setting_id===o);if(!Q)throw new Error("Selected preset not found");const Z=g$(Q.name),ae=c?.slot_id??-1,B=d||r.trayColor?.slice(0,6)||"FFFFFF",X=Q.name.replace(/@.+$/,"").trim();let ne=p$(o);if(!o.startsWith("GFS"))try{const ie=await ue.getCloudSettingDetail(o);ie.filament_id?ne=ie.filament_id:ie.base_id&&(ne=p$(ie.base_id),console.log(`Derived tray_info_idx from base_id: ${ie.base_id} -> ${ne}`))}catch(ie){console.warn("Failed to fetch preset detail for filament_id:",ie)}let se=190,be=230;const xe=Z.material.toUpperCase();xe.includes("PLA")?(se=190,be=230):xe.includes("PETG")?(se=220,be=260):xe.includes("ABS")||xe.includes("ASA")?(se=240,be=280):xe.includes("TPU")?(se=200,be=240):xe.includes("PC")?(se=260,be=300):(xe.includes("PA")||xe.includes("NYLON"))&&(se=250,be=290);const de=c?.k_value?parseFloat(c.k_value):0,Pe=await ue.configureAmsSlot(n,r.amsId,r.trayId,{tray_info_idx:ne,tray_type:Z.material||"PLA",tray_sub_brands:X,tray_color:B+"FF",nozzle_temp_min:se,nozzle_temp_max:be,cali_idx:ae,nozzle_diameter:i,setting_id:o,kprofile_filament_id:c?.filament_id,kprofile_setting_id:c?.setting_id||void 0,k_value:de});try{await ue.saveSlotPreset(n,r.amsId,r.trayId,o,X)}catch(ie){console.warn("Failed to save slot preset mapping:",ie)}return Pe},onSuccess:()=>{v(!0),a?.(),setTimeout(()=>{v(!1),e()},1500)}}),A=mt({mutationFn:async()=>ue.resetAmsSlot(n,r.amsId,r.trayId),onSuccess:()=>{v(!0),a?.(),setTimeout(()=>{v(!1),e()},1500)}}),R=_.useMemo(()=>{if(!T?.filament)return[];const Q=x.toLowerCase();return T.filament.filter(Z=>Q?Z.name.toLowerCase().includes(Q):!0).sort((Z,ae)=>{const B=UA(Z.setting_id),X=UA(ae.setting_id);return B&&!X?-1:!B&&X?1:Z.name.localeCompare(ae.name)})},[T?.filament,x]),U=_.useMemo(()=>{if(!o||!T?.filament)return null;const Q=T.filament.find(B=>B.setting_id===o);if(!Q)return null;let Z=Q.name.replace(/@.+$/,"").trim();Z.startsWith("# ")&&(Z=Z.slice(2).trim());const ae=g$(Z);return{fullName:Z,material:ae.material,brand:ae.brand}},[o,T?.filament]),F=U?.fullName||"",$=_.useMemo(()=>{if(!C?.profiles||!U)return[];const{fullName:Q,material:Z,brand:ae}=U,B=Q.toUpperCase(),X=Z.toUpperCase(),ne=ae.toUpperCase();if(!X||X.length<2)return[];const se=C.profiles.filter(xe=>{const de=xe.name.toUpperCase();if(ne)return!(!de.includes(ne)||!de.includes(X));if(de.includes(B)||de.includes(X))return!0;const ie={NYLON:["PA","PA-CF","PA6"],PA:["NYLON"]}[X]||[];for(const Ne of ie)if(de.includes(Ne))return!0;return!1}),be=new Map;for(const xe of se){const de=`${xe.name}|${xe.k_value}`,Pe=be.get(de);Pe?xe.extruder_id===1&&Pe.extruder_id===0&&be.set(de,xe):be.set(de,xe)}return Array.from(be.values())},[C?.profiles,U]);_.useEffect(()=>{if(t&&T?.filament){if(r.trayInfoIdx){const Q=T.filament.find(Z=>Z.setting_id===r.trayInfoIdx);Q&&l(Q.setting_id)}}else t||(l(""),u(null),f(""),m(""),b(""),v(!1))},[t,T?.filament,r.trayInfoIdx]),_.useEffect(()=>{$.length>0?u($[0]):u(null)},[o,$]);const j=_.useCallback(Q=>{Q.key==="Escape"&&e()},[e]);if(_.useEffect(()=>{if(t)return document.addEventListener("keydown",j),()=>document.removeEventListener("keydown",j)},[t,j]),!t)return null;const H=k||E,K=o&&!D.isPending,V=d||r.trayColor?.slice(0,6)||"FFFFFF";return s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[s.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:e}),s.jsxs("div",{className:"relative w-full max-w-lg mx-4 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl shadow-2xl",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(bh,{className:"w-5 h-5 text-bambu-blue"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Configure AMS Slot"})]}),s.jsx("button",{onClick:e,className:"p-1 text-bambu-gray hover:text-white rounded transition-colors",children:s.jsx(Rt,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"p-4 space-y-4 max-h-[60vh] overflow-y-auto",children:[y&&s.jsx("div",{className:"absolute inset-0 bg-bambu-dark-secondary/95 z-10 flex items-center justify-center rounded-xl",children:s.jsxs("div",{className:"text-center space-y-3",children:[s.jsx(sN,{className:"w-16 h-16 text-bambu-green mx-auto"}),s.jsx("p",{className:"text-lg font-semibold text-white",children:"Slot Configured!"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Settings sent to printer"})]})}),s.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[s.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Configuring slot:"}),s.jsxs("div",{className:"flex items-center gap-2",children:[r.trayColor&&s.jsx("span",{className:"w-4 h-4 rounded-full border border-white/20",style:{backgroundColor:`#${r.trayColor.slice(0,6)}`}}),s.jsxs("span",{className:"text-white font-medium",children:[$Ce(r.amsId,r.trayCount)," Slot ",r.trayId+1]}),r.traySubBrands&&s.jsxs("span",{className:"text-bambu-gray",children:["(",r.traySubBrands,")"]})]})]}),H?s.jsx("div",{className:"flex justify-center py-8",children:s.jsx(ht,{className:"w-6 h-6 text-bambu-green animate-spin"})}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-2",children:["Filament Profile ",s.jsx("span",{className:"text-red-400",children:"*"})]}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{type:"text",placeholder:"Search presets...",value:x,onChange:Q=>b(Q.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder:text-bambu-gray focus:border-bambu-green focus:outline-none mb-2"}),s.jsx("div",{className:"max-h-48 overflow-y-auto space-y-1",children:R.length===0?s.jsx("p",{className:"text-center py-4 text-bambu-gray",children:T?.filament?.length===0?"No cloud presets. Login to Bambu Cloud to sync.":"No matching presets found."}):R.map(Q=>s.jsx("button",{onClick:()=>l(Q.setting_id),className:`w-full p-2 rounded-lg border text-left transition-colors ${o===Q.setting_id?"bg-bambu-green/20 border-bambu-green":"bg-bambu-dark border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-white text-sm truncate",children:Q.name}),UA(Q.setting_id)&&s.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-bambu-blue/20 text-bambu-blue",children:"Custom"})]})},Q.setting_id))})]})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-2",children:["K Profile (Pressure Advance)",F&&s.jsxs("span",{className:"ml-2 text-xs text-bambu-blue",children:["Filtering for: ",F]})]}),$.length>0?s.jsxs("div",{className:"relative",children:[s.jsxs("select",{value:c?.name||"",onChange:Q=>{const Z=$.find(ae=>ae.name===Q.target.value);u(Z||null)},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none appearance-none pr-10",children:[s.jsx("option",{value:"",children:"No K profile (use default 0.020)"}),$.map(Q=>s.jsxs("option",{value:Q.name,children:[Q.name," (K=",Q.k_value,")"]},`${Q.name}-${Q.extruder_id}`))]}),s.jsx(ei,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}):o?s.jsx("p",{className:"text-sm text-bambu-gray italic py-2",children:"No matching K profiles found. Default K=0.020 will be used."}):s.jsx("span",{className:"inline-block text-xs px-2 py-1 rounded bg-amber-500/20 text-amber-400 border border-amber-500/30",children:"Select a filament profile first"}),c&&s.jsxs("p",{className:"text-xs text-bambu-green mt-1",children:["K=",c.k_value," from printer calibration"]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"Custom Color (optional)"}),s.jsxs("div",{className:"flex flex-wrap gap-1.5 mb-2",children:[qCe.map(Q=>s.jsx("button",{onClick:()=>{f(Q.hex),m(Q.name)},className:`w-7 h-7 rounded-md border-2 transition-all ${d===Q.hex?"border-bambu-green scale-110":"border-white/20 hover:border-white/40"}`,style:{backgroundColor:`#${Q.hex}`},title:Q.name},Q.hex)),s.jsx("button",{onClick:()=>N(!S),className:"w-7 h-7 rounded-md border-2 border-white/20 hover:border-white/40 flex items-center justify-center text-white/60 hover:text-white/80 transition-all text-xs",title:S?"Show less colors":"Show more colors",children:S?"−":"+"})]}),S&&s.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:WCe.map(Q=>s.jsx("button",{onClick:()=>{f(Q.hex),m(Q.name)},className:`w-7 h-7 rounded-md border-2 transition-all ${d===Q.hex?"border-bambu-green scale-110":"border-white/20 hover:border-white/40"}`,style:{backgroundColor:`#${Q.hex}`},title:Q.name},Q.hex))}),s.jsxs("div",{className:"flex gap-2 items-center",children:[s.jsx("div",{className:"w-10 h-10 rounded-lg border-2 border-white/20 flex-shrink-0",style:{backgroundColor:`#${V}`}}),s.jsx("input",{type:"text",placeholder:"Color name or hex (e.g., brown, FF8800)",value:p,onChange:Q=>{const Z=Q.target.value;m(Z);const ae=KCe(Z);if(ae)f(ae);else{const B=Z.replace(/[^0-9A-Fa-f]/g,"").toUpperCase();B.length===6?f(B):B.length===3&&f(B.split("").map(X=>X+X).join(""))}},className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder:text-bambu-gray focus:border-bambu-green focus:outline-none text-sm"}),d&&s.jsx("button",{onClick:()=>{f(""),m("")},className:"px-2 py-1 text-xs text-bambu-gray hover:text-white bg-bambu-dark-tertiary rounded",title:"Clear custom color",children:"Clear"})]}),d&&s.jsxs("p",{className:"text-xs text-bambu-gray mt-1.5",children:["Hex: #",d]})]})]})]}),s.jsxs("div",{className:"flex justify-between p-4 border-t border-bambu-dark-tertiary",children:[s.jsx(Te,{variant:"secondary",onClick:()=>A.mutate(),disabled:A.isPending||D.isPending,className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:A.isPending?s.jsxs(s.Fragment,{children:[s.jsx(ht,{className:"w-4 h-4 animate-spin"}),"Resetting..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Rh,{className:"w-4 h-4"}),"Reset Slot"]})}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Te,{variant:"secondary",onClick:e,children:"Cancel"}),s.jsx(Te,{onClick:()=>D.mutate(),disabled:!K,children:D.isPending?s.jsxs(s.Fragment,{children:[s.jsx(ht,{className:"w-4 h-4 animate-spin"}),"Configuring..."]}):s.jsxs(s.Fragment,{children:[s.jsx(bh,{className:"w-4 h-4"}),"Configure Slot"]})})]})]}),(D.isError||A.isError)&&s.jsx("div",{className:"mx-4 mb-4 p-2 bg-red-500/20 border border-red-500/50 rounded text-sm text-red-400",children:D.error?.message||A.error?.message})]})]})}function YCe({on:t,className:e="w-5 h-5"}){const n=t?"#facc15":"none",r=t?"#78350f":"currentColor",i=t?1:0;return s.jsxs("svg",{viewBox:"0 0 32 32",fill:"none",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,children:[s.jsxs("g",{stroke:r,opacity:i,children:[s.jsx("line",{x1:"16",y1:"2",x2:"16",y2:"6"}),s.jsx("line",{x1:"6.1",y1:"6.1",x2:"8.9",y2:"8.9"}),s.jsx("line",{x1:"25.9",y1:"6.1",x2:"23.1",y2:"8.9"}),s.jsx("line",{x1:"2",y1:"16",x2:"6",y2:"16"}),s.jsx("line",{x1:"30",y1:"16",x2:"26",y2:"16"})]}),s.jsx("path",{d:"M12 24v-2.3c0-.9-.4-1.7-1-2.3C9.2 17.6 8 15.4 8 13c0-4.4 3.6-8 8-8s8 3.6 8 8c0 2.4-1.2 4.6-3 6.4-.6.6-1 1.4-1 2.3V24",fill:n,stroke:r}),s.jsx("path",{d:"M12 24h8",stroke:r}),s.jsx("path",{d:"M12 27h8",stroke:r}),s.jsx("path",{d:"M13 30h6",stroke:r})]})}const x$=({className:t})=>s.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("rect",{x:"2",y:"15",width:"5",height:"5",rx:"0.5"}),s.jsx("rect",{x:"9.5",y:"15",width:"5",height:"5",rx:"0.5",fill:"currentColor",opacity:"0.3"}),s.jsx("rect",{x:"17",y:"15",width:"5",height:"5",rx:"0.5"}),s.jsx("path",{d:"M4 12 C4 6, 14 6, 14 12"}),s.jsx("polyline",{points:"12,10 14,12 12,14"})]}),b$={"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"},QCe={W0:"White",W1:"Jade White",W2:"Ivory White",W3:"Bone White",Y0:"Yellow",Y1:"Gold",Y2:"Sunflower Yellow",Y3:"Bronze",Y4:"Gold",A0:"Orange",A1:"Pumpkin Orange",A2:"Mandarin Orange",R0:"Red",R1:"Scarlet Red",R2:"Maroon Red",R3:"Hot Pink",R4:"Dark Red",R5:"Red Granite",P0:"Beige",P1:"Pink",P2:"Indigo Purple",P3:"Sakura Pink",P4:"Lilac Purple",P5:"Purple",P6:"Magenta",P7:"Violet Purple",B0:"Blue",B1:"Blue Grey",B2:"Cobalt Blue",B3:"Cobalt Blue",B4:"Ice Blue",B5:"Turquoise",B6:"Navy Blue",B7:"Royal Purple",B8:"Cyan",G0:"Green",G1:"Grass Green",G2:"Mistletoe Green",G3:"Bright Green",G6:"Bambu Green",G7:"Dark Green",N0:"Brown",N1:"Peanut Brown",N2:"Dark Brown",N3:"Caramel",D0:"Gray",D1:"Silver",D2:"Light Gray",D3:"Dark Gray",D4:"White Marble",D5:"Slate Gray",D6:"Lava Gray",K0:"Black",K1:"Charcoal",K2:"Onyx Black",C0:"Clear Black",C1:"Transparent",M0:"Arctic Whisper",M1:"Solar Breeze",M2:"Ocean to Meadow",M3:"Pink Citrus",M4:"Aurora Purple",M5:"Blueberry Bubblegum",M6:"Dusk Glare",M7:"Cotton Candy Cloud",M8:"Dawn Radiance",T1:"Gilded Rose",T2:"Midnight Blaze",T3:"Neon City",T4:"Blue Hawaii",T5:"Velvet Eclipse"};function zA(t){if(!t)return null;if(b$[t])return b$[t];const e=t.split("-");if(e.length<2)return null;const n=e[1];return QCe[n]||null}function BA(t){if(!t||t.length<6)return"Unknown";const e=parseInt(t.substring(0,2),16),n=parseInt(t.substring(2,4),16),r=parseInt(t.substring(4,6),16),i=Math.max(e,n,r)/255,a=Math.min(e,n,r)/255,o=(i+a)/2;let l=0,c=0;if(i!==a){const u=i-a;c=o>.5?u/(2-i-a):u/(i+a);const d=e/255,f=n/255,p=r/255;i===d?l=((f-p)/u+(f<p?6:0))/6:i===f?l=((p-d)/u+2)/6:l=((d-f)/u+4)/6}return l=l*360,o<.15?"Black":o>.85?"White":c<.15?o<.4?"Dark Gray":o>.6?"Light Gray":"Gray":l>=15&&l<45&&o<.45||l>=45&&l<70&&o<.4?"Brown":l<15||l>=345?"Red":l<45?"Orange":l<70?"Yellow":l<150?"Green":l<200?"Cyan":l<260?"Blue":l<290?"Purple":l<345?"Pink":"Unknown"}function HA(t){return(t??.02).toFixed(3)}function y$({side:t}){const{mode:e}=Oh(),n=e==="dark"?"#1a4d2e":"#e7f5e9";return s.jsx("span",{className:"inline-flex items-center justify-center w-4 h-4 text-[10px] font-bold rounded",style:{backgroundColor:n,color:"#00ae42"},children:t})}function v$({className:t}){return s.jsx("svg",{className:t,viewBox:"0 0 36 54",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:s.jsx("path",{d:"M17.8131 0.00538C18.4463 -0.15091 20.3648 3.14642 20.8264 3.84781C25.4187 10.816 35.3089 26.9368 35.9383 34.8694C37.4182 53.5822 11.882 61.3357 2.53721 45.3789C-1.73471 38.0791 0.016 32.2049 3.178 25.0232C6.99221 16.3662 12.6411 7.90372 17.8131 0.00538ZM18.3738 7.24807L17.5881 7.48441C14.4452 12.9431 10.917 18.2341 8.19369 23.9368C4.6808 31.29 1.18317 38.5479 7.69403 45.5657C17.3058 55.9228 34.9847 46.8808 31.4604 32.8681C29.2558 24.0969 22.4207 15.2913 18.3776 7.24807H18.3738Z",fill:"#C3C2C1"})})}function ZCe({className:t}){return s.jsxs("svg",{className:t,viewBox:"0 0 35 53",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("path",{d:"M17.3165 0.0038C17.932 -0.14959 19.7971 3.08645 20.2458 3.77481C24.7103 10.6135 34.3251 26.4346 34.937 34.2198C36.3757 52.5848 11.5505 60.1942 2.46584 44.534C-1.68714 37.3735 0.0148 31.6085 3.08879 24.5603C6.79681 16.0605 12.2884 7.75907 17.3165 0.0038ZM17.8615 7.11561L17.0977 7.34755C14.0423 12.7048 10.6124 17.8974 7.96483 23.4941C4.54975 30.7107 1.14949 37.8337 7.47908 44.721C16.8233 54.8856 34.01 46.0117 30.5838 32.2595C28.4405 23.6512 21.7957 15.0093 17.8652 7.11561H17.8615Z",fill:"#C3C2C1"}),s.jsx("path",{d:"M5.03547 30.112C9.64453 30.4936 11.632 35.7985 16.4154 35.791C19.6339 35.7873 20.2161 33.2283 22.3853 31.6197C31.6776 24.7286 33.5835 37.4894 27.9881 44.4254C18.1878 56.5653 -1.16063 44.6013 5.03917 30.1158L5.03547 30.112Z",fill:"#1F8FEB"})]})}function JCe({className:t}){return s.jsxs("svg",{className:t,viewBox:"0 0 36 54",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("path",{d:"M17.9625 4.48059L4.77216 26.3154L2.08228 40.2175L10.0224 50.8414H23.1594L33.3246 42.1693V30.2455L17.9625 4.48059Z",fill:"#1F8FEB"}),s.jsx("path",{d:"M17.7948 0.00538C18.4273 -0.15091 20.3438 3.14642 20.8048 3.84781C25.3921 10.816 35.2715 26.9368 35.9001 34.8694C37.3784 53.5822 11.8702 61.3357 2.53562 45.3789C-1.73163 38.0829 0.0134 32.2087 3.1757 25.027C6.98574 16.3662 12.6284 7.90372 17.7948 0.00538ZM18.3549 7.24807L17.57 7.48441C14.4306 12.9431 10.9063 18.2341 8.1859 23.9368C4.67686 31.29 1.18305 38.5479 7.68679 45.5657C17.2881 55.9228 34.9476 46.8808 31.4271 32.8681C29.2249 24.0969 22.3974 15.2913 18.3587 7.24807H18.3549Z",fill:"#C3C2C1"})]})}function eje({className:t}){return s.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("path",{d:"M6 0.5C4.6 0.5 3.5 1.6 3.5 3V12.1C2.6 12.8 2 13.9 2 15C2 17.2 3.8 19 6 19C8.2 19 10 17.2 10 15C10 13.9 9.4 12.8 8.5 12.1V3C8.5 1.6 7.4 0.5 6 0.5Z",stroke:"#C3C2C1",strokeWidth:"1",fill:"none"}),s.jsx("circle",{cx:"6",cy:"15",r:"2.5",stroke:"#C3C2C1",strokeWidth:"1",fill:"none"})]})}function tje({className:t}){return s.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("rect",{x:"4.5",y:"8",width:"3",height:"4.5",fill:"#d4a017",rx:"0.5"}),s.jsx("circle",{cx:"6",cy:"15",r:"2",fill:"#d4a017"}),s.jsx("path",{d:"M6 0.5C4.6 0.5 3.5 1.6 3.5 3V12.1C2.6 12.8 2 13.9 2 15C2 17.2 3.8 19 6 19C8.2 19 10 17.2 10 15C10 13.9 9.4 12.8 8.5 12.1V3C8.5 1.6 7.4 0.5 6 0.5Z",stroke:"#C3C2C1",strokeWidth:"1",fill:"none"})]})}function nje({className:t}){return s.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("rect",{x:"4.5",y:"3",width:"3",height:"9.5",fill:"#c62828",rx:"0.5"}),s.jsx("circle",{cx:"6",cy:"15",r:"2",fill:"#c62828"}),s.jsx("path",{d:"M6 0.5C4.6 0.5 3.5 1.6 3.5 3V12.1C2.6 12.8 2 13.9 2 15C2 17.2 3.8 19 6 19C8.2 19 10 17.2 10 15C10 13.9 9.4 12.8 8.5 12.1V3C8.5 1.6 7.4 0.5 6 0.5Z",stroke:"#C3C2C1",strokeWidth:"1",fill:"none"})]})}function $A({className:t,color:e,isHeating:n}){const i={"text-orange-400":"#fb923c","text-blue-400":"#60a5fa","text-green-400":"#4ade80"}[e]||"#888",a=n?{filter:`drop-shadow(0 0 4px ${i}) drop-shadow(0 0 8px ${i})`}:{};return n?s.jsxs("svg",{className:t,style:a,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("rect",{x:"4.5",y:"3",width:"3",height:"9.5",fill:i,rx:"0.5"}),s.jsx("circle",{cx:"6",cy:"15",r:"2",fill:i}),s.jsx("path",{d:"M6 0.5C4.6 0.5 3.5 1.6 3.5 3V12.1C2.6 12.8 2 13.9 2 15C2 17.2 3.8 19 6 19C8.2 19 10 17.2 10 15C10 13.9 9.4 12.8 8.5 12.1V3C8.5 1.6 7.4 0.5 6 0.5Z",stroke:i,strokeWidth:"1",fill:"none"})]}):s.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("path",{d:"M6 0.5C4.6 0.5 3.5 1.6 3.5 3V12.1C2.6 12.8 2 13.9 2 15C2 17.2 3.8 19 6 19C8.2 19 10 17.2 10 15C10 13.9 9.4 12.8 8.5 12.1V3C8.5 1.6 7.4 0.5 6 0.5Z",stroke:i,strokeWidth:"1",fill:"none"}),s.jsx("circle",{cx:"6",cy:"15",r:"2.5",stroke:i,strokeWidth:"1",fill:"none"})]})}function w$({humidity:t,goodThreshold:e=40,fairThreshold:n=60,onClick:r,compact:i}){const a=typeof t=="string"?parseInt(t,10):t,o=typeof e=="number"?e:40,l=typeof n=="number"?n:60;let c,u;isNaN(a)?(c="#C3C2C1",u="Unknown"):a<=o?(c="#22a352",u="Good"):a<=l?(c="#d4a017",u="Fair"):(c="#c62828",u="Bad");let d;return isNaN(a)||a<=o?d=v$:a<=l?d=ZCe:d=JCe,s.jsxs("button",{type:"button",onClick:r,className:`flex items-center gap-1 ${r?"cursor-pointer hover:opacity-80 transition-opacity":""}`,title:`Humidity: ${a}% - ${u}${r?" (click for history)":""}`,children:[s.jsx(d,{className:i?"w-2.5 h-3":"w-3 h-4"}),s.jsxs("span",{className:`font-medium tabular-nums ${i?"text-[10px]":"text-xs"}`,style:{color:c},children:[a,"%"]})]})}function _$({temp:t,goodThreshold:e=28,fairThreshold:n=35,onClick:r,compact:i}){const a=typeof e=="number"?e:28,o=typeof n=="number"?n:35;let l,c,u;return t<=a?(l="#22a352",c="Good",u=eje):t<=o?(l="#d4a017",c="Fair",u=tje):(l="#c62828",c="Bad",u=nje),s.jsxs("button",{type:"button",onClick:r,className:`flex items-center gap-1 ${r?"cursor-pointer hover:opacity-80 transition-opacity":""}`,title:`Temperature: ${t}°C - ${c}${r?" (click for history)":""}`,children:[s.jsx(u,{className:i?"w-2.5 h-3":"w-3 h-4"}),s.jsxs("span",{className:`tabular-nums text-right ${i?"text-[10px] w-8":"w-12"}`,style:{color:l},children:[t,"°C"]})]})}function _d(t,e){const n=typeof t=="string"?parseInt(t,10):t,r=isNaN(n)?0:n,i=e===1,a=r>=128?r-128:r,o=String.fromCharCode(65+a);return i?`HT-${o}`:`AMS-${o}`}function S$(t){return t>50?"#00ae42":t>=15?"#f59e0b":"#ef4444"}function rje(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function ije(t,e="system"){const n=new Date,r=new Date(n.getTime()+t*60*1e3),i=new Date;i.setHours(0,0,0,0);const a=new Date(r);a.setHours(0,0,0,0);const o={hour:"2-digit",minute:"2-digit"};e==="12h"?o.hour12=!0:e==="24h"&&(o.hour12=!1);const l=r.toLocaleTimeString([],o),c=Math.floor((a.getTime()-i.getTime())/(1e3*60*60*24));return c===0?l:c===1?`Tomorrow ${l}`:r.toLocaleDateString([],{weekday:"short"})+" "+l}function aje(t){if(!t)return"/img/printers/default.png";const e=t.toLowerCase().replace(/\s+/g,"");return e.includes("x1e")?"/img/printers/x1e.png":e.includes("x1c")||e.includes("x1carbon")||e.includes("x1")?"/img/printers/x1c.png":e.includes("h2d")||e.includes("h2c")||e.includes("h2s")?"/img/printers/h2d.png":e.includes("p2s")||e.includes("p1s")?"/img/printers/p1s.png":e.includes("p1p")?"/img/printers/p1p.png":e.includes("a1mini")?"/img/printers/a1mini.png":e.includes("a1")?"/img/printers/a1.png":"/img/printers/default.png"}function sje(t){return t==null?{labelKey:"",color:"text-bambu-gray",bars:0}:t>=-50?{labelKey:"printers.wifiSignal.excellent",color:"text-bambu-green",bars:4}:t>=-60?{labelKey:"printers.wifiSignal.good",color:"text-bambu-green",bars:3}:t>=-70?{labelKey:"printers.wifiSignal.fair",color:"text-yellow-400",bars:2}:t>=-80?{labelKey:"printers.wifiSignal.weak",color:"text-orange-400",bars:1}:{labelKey:"printers.wifiSignal.veryWeak",color:"text-red-400",bars:1}}function VA(t){return t?!!(t.tray_info_idx&&t.tray_info_idx.startsWith("GF")||t.tray_uuid&&t.tray_uuid!=="00000000000000000000000000000000"||t.tag_uid&&t.tag_uid!=="0000000000000000"):!1}function oje({url:t,printName:e}){const{t:n}=Hn(),[r,i]=_.useState(!1),[a,o]=_.useState(!1),[l,c]=_.useState(!1);return s.jsxs(s.Fragment,{children:[s.jsx("div",{className:`w-20 h-20 flex-shrink-0 rounded-lg overflow-hidden bg-bambu-dark-tertiary flex items-center justify-center ${t&&r?"cursor-pointer":""}`,onClick:()=>t&&r&&c(!0),children:t&&!a?s.jsxs(s.Fragment,{children:[s.jsx("img",{src:t,alt:n("printers.printPreview"),className:`w-full h-full object-cover ${r?"block":"hidden"}`,onLoad:()=>i(!0),onError:()=>o(!0)}),!r&&s.jsx(lo,{className:"w-8 h-8 text-bambu-gray"})]}):s.jsx(lo,{className:"w-8 h-8 text-bambu-gray"})}),l&&t&&s.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-8",onClick:()=>c(!1),children:s.jsxs("div",{className:"relative max-w-2xl max-h-full",children:[s.jsx("img",{src:t,alt:n("printers.printPreview"),className:"max-w-full max-h-[80vh] rounded-lg shadow-2xl"}),e&&s.jsx("p",{className:"text-white text-center mt-4 text-lg",children:e})]})})]})}function lje({printers:t}){const{t:e}=Hn(),n=an(),r=_.useMemo(()=>{let a=0,o=0,l=0,c=0;return t?.forEach(u=>{const d=n.getQueryData(["printerStatus",u.id]);d===void 0?c++:d.connected?d.state==="RUNNING"?a++:o++:l++}),{printing:a,idle:o,offline:l,loading:c,total:t?.length||0}},[t,n]),[,i]=_.useState(0);return _.useEffect(()=>{let a=!1;const o=n.getQueryCache().subscribe(()=>{a||(a=!0,requestAnimationFrame(()=>{i(l=>l+1),a=!1}))});return()=>o()},[n]),t?.length?s.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[r.printing>0&&s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("div",{className:"w-2 h-2 rounded-full bg-bambu-green animate-pulse"}),s.jsxs("span",{className:"text-bambu-gray",children:[s.jsx("span",{className:"text-white font-medium",children:r.printing})," ",e("printers.status.printing").toLowerCase()]})]}),r.idle>0&&s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("div",{className:"w-2 h-2 rounded-full bg-blue-400"}),s.jsxs("span",{className:"text-bambu-gray",children:[s.jsx("span",{className:"text-white font-medium",children:r.idle})," ",e("printers.status.idle").toLowerCase()]})]}),r.offline>0&&s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("div",{className:"w-2 h-2 rounded-full bg-gray-400"}),s.jsxs("span",{className:"text-bambu-gray",children:[s.jsx("span",{className:"text-white font-medium",children:r.offline})," ",e("printers.status.offline").toLowerCase()]})]})]}):null}function M$(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 N$({printer:t,hideIfDisconnected:e,maintenanceInfo:n,viewMode:r="expanded",cardSize:i=2,amsThresholds:a,spoolmanEnabled:o=!1,hasUnlinkedSpools:l=!1,linkedSpools:c,spoolmanUrl:u,timeFormat:d="system",cameraViewMode:f="window",onOpenEmbeddedCamera:p,checkPrinterFirmware:m=!0}){const{t:x}=Hn(),b=an(),y=Nc(),{showToast:v}=$n(),{hasPermission:S}=Ai(),[N,T]=_.useState(!1),[k,C]=_.useState(!1),[E,D]=_.useState(!0),[A,R]=_.useState(!1),[U,F]=_.useState(!1),[$,j]=_.useState(!1),[H,K]=_.useState(!1),[V,Q]=_.useState(!1),[Z,ae]=_.useState(!1),[B,X]=_.useState(!1),[ne,se]=_.useState(!1),[be,xe]=_.useState(!1),[de,Pe]=_.useState(!1),[ie,Ne]=_.useState(null),[Oe,ge]=_.useState(null),[Ke,G]=_.useState(null),[Y,ce]=_.useState(!1),[q,te]=_.useState(null),[I,fe]=_.useState(!1),[me,Ee]=_.useState(!1),[z,O]=_.useState(null),[ee,le]=_.useState(!1),[_e,we]=_.useState(!1),{data:re}=at({queryKey:["printerStatus",t.id],queryFn:()=>ue.getPrinterStatus(t.id),refetchInterval:3e4}),{data:Fe}=at({queryKey:["firmwareUpdate",t.id],queryFn:()=>g1.checkPrinterUpdate(t.id),staleTime:300*1e3,refetchInterval:300*1e3,enabled:m}),He=_.useMemo(()=>{const et=new Set;if(re?.ams)for(const jt of re.ams)for(const qt of jt.tray||[])qt.tray_info_idx&&et.add(qt.tray_info_idx);return re?.vt_tray?.tray_info_idx&&et.add(re.vt_tray.tray_info_idx),Array.from(et)},[re?.ams,re?.vt_tray]),{data:Ve}=at({queryKey:["filamentInfo",He],queryFn:()=>ue.getFilamentInfo(He),enabled:He.length>0,staleTime:300*1e3}),{data:$e}=at({queryKey:["slotPresets",t.id],queryFn:()=>ue.getSlotPresets(t.id),staleTime:120*1e3}),[ye,je]=_.useState(null);_.useEffect(()=>{re?.wifi_signal!=null&&je(re.wifi_signal)},[re?.wifi_signal]);const Be=re?.wifi_signal??ye,Se=_.useRef(void 0);_.useEffect(()=>{re?.connected!==void 0&&(Se.current=re.connected)},[re?.connected]);const Xe=re?.connected??Se.current,Me=_.useRef({});_.useEffect(()=>{re?.ams_extruder_map&&Object.keys(re.ams_extruder_map).length>0&&(Me.current=re.ams_extruder_map)},[re?.ams_extruder_map]);const tt=re?.ams_extruder_map&&Object.keys(re.ams_extruder_map).length>0?re.ams_extruder_map:Me.current,ke=_.useRef([]);_.useEffect(()=>{re?.ams&&re.ams.length>0&&(ke.current=re.ams)},[re?.ams]);const We=re?.ams&&re.ams.length>0?re.ams:ke.current,ze=_.useRef(255),W=re?.tray_now;W!==void 0&&W!==255&&(ze.current=W);const De=W===void 0||W===255?ze.current:W,{data:Ye}=at({queryKey:["smartPlugByPrinter",t.id],queryFn:()=>ue.getSmartPlugByPrinter(t.id)}),{data:xt}=at({queryKey:["scriptPlugsByPrinter",t.id],queryFn:()=>ue.getScriptPlugsByPrinter(t.id)}),{data:ft}=at({queryKey:["smartPlugStatus",Ye?.id],queryFn:()=>Ye?ue.getSmartPlugStatus(Ye.id):null,enabled:!!Ye,refetchInterval:1e4}),{data:Bt}=at({queryKey:["queue",t.id,"pending"],queryFn:()=>ue.getQueue(t.id,"pending")}),Lt=Bt?.length||0,{data:vn}=at({queryKey:["queue",t.id,"printing"],queryFn:()=>ue.getQueue(t.id,"printing"),enabled:re?.state==="RUNNING"}),{data:Jt}=at({queryKey:["currentPrintUser",t.id],queryFn:()=>ue.getCurrentPrintUser(t.id),enabled:re?.state==="RUNNING"}),ir=vn?.[0]?.created_by_username||Jt?.username,{data:fr}=at({queryKey:["archives",t.id,"last"],queryFn:()=>ue.getArchives(t.id,1,0),enabled:re?.connected&&re?.state!=="RUNNING"}),Dn=fr?.[0],ln=e&&Xe===!1,mr=mt({mutationFn:et=>ue.deletePrinter(t.id,et.deleteArchives),onSuccess:()=>{b.invalidateQueries({queryKey:["printers"]}),b.invalidateQueries({queryKey:["archives"]}),b.invalidateQueries({queryKey:["maintenanceOverview"]})},onError:et=>v(et.message||x("printers.toast.failedToDelete"),"error")}),Fn=mt({mutationFn:()=>ue.connectPrinter(t.id),onSuccess:()=>{b.invalidateQueries({queryKey:["printerStatus",t.id]})}}),Xn=mt({mutationFn:et=>Ye?ue.controlSmartPlug(Ye.id,et):Promise.reject("No plug"),onSuccess:()=>{b.invalidateQueries({queryKey:["smartPlugStatus",Ye?.id]})}}),bn=mt({mutationFn:et=>Ye?ue.updateSmartPlug(Ye.id,{auto_off:et}):Promise.reject("No plug"),onSuccess:()=>{b.invalidateQueries({queryKey:["smartPlugByPrinter",t.id]}),b.invalidateQueries({queryKey:["smart-plugs"]})}}),wi=mt({mutationFn:et=>ue.controlSmartPlug(et,"on"),onSuccess:()=>{v(x("printers.toast.scriptTriggered"))},onError:et=>v(et.message||x("printers.toast.failedToRunScript"),"error")}),Ba=mt({mutationFn:()=>ue.stopPrint(t.id),onSuccess:()=>{v(x("printers.toast.printStopped")),b.invalidateQueries({queryKey:["printerStatus",t.id]})},onError:et=>v(et.message||x("printers.toast.failedToStopPrint"),"error")}),Ae=mt({mutationFn:()=>ue.pausePrint(t.id),onSuccess:()=>{v(x("printers.toast.printPaused")),b.invalidateQueries({queryKey:["printerStatus",t.id]})},onError:et=>v(et.message||x("printers.toast.failedToPausePrint"),"error")}),Ze=mt({mutationFn:()=>ue.resumePrint(t.id),onSuccess:()=>{v(x("printers.toast.printResumed")),b.invalidateQueries({queryKey:["printerStatus",t.id]})},onError:et=>v(et.message||x("printers.toast.failedToResumePrint"),"error")}),st=mt({mutationFn:et=>ue.setChamberLight(t.id,et),onMutate:async et=>{await b.cancelQueries({queryKey:["printerStatus",t.id]});const jt=b.getQueryData(["printerStatus",t.id]);return b.setQueryData(["printerStatus",t.id],qt=>({...qt,chamber_light:et})),{previousStatus:jt}},onSuccess:(et,jt)=>{v(`Chamber light ${jt?"on":"off"}`)},onError:(et,jt,qt)=>{qt?.previousStatus&&b.setQueryData(["printerStatus",t.id],qt.previousStatus),v(et.message||x("printers.toast.failedToControlChamberLight"),"error")}}),lt=mt({mutationFn:et=>ue.updatePrinter(t.id,{plate_detection_enabled:et}),onSuccess:()=>{b.invalidateQueries({queryKey:["printers"]}),v(lt.variables?x("printers.toast.plateCheckEnabled"):x("printers.toast.plateCheckDisabled"))},onError:et=>v(et.message||x("printers.toast.failedToUpdateSetting"),"error")}),ot=(re?.state==="RUNNING"||re?.state==="PAUSE"||re?.state==="PAUSED")&&(re?.printable_objects_count??0)>=2,{data:Et,refetch:he}=at({queryKey:["printableObjects",t.id],queryFn:()=>ue.getPrintableObjects(t.id),enabled:de||ot,refetchInterval:de?5e3:ot?3e4:!1}),pe=mt({mutationFn:et=>ue.skipObjects(t.id,et),onSuccess:et=>{v(et.message||x("printers.skipObjects.objectsSkipped")),he()},onError:et=>v(et.message||x("printers.toast.failedToSkipObjects"),"error")}),[Ie,Le]=_.useState(null),Ce=_.useRef(!1),ut=_.useRef(null),St=_.useRef(!1),At=mt({mutationFn:({amsId:et,slotId:jt})=>ue.refreshAmsSlot(t.id,et,jt),onMutate:({amsId:et,slotId:jt})=>{ut.current&&clearTimeout(ut.current),Ce.current=!1,St.current=!1,Le({amsId:et,slotId:jt}),setTimeout(()=>{St.current=!0},2e3),ut.current=setTimeout(()=>{Le(null)},3e4)},onSuccess:et=>{v(et.message||x("printers.toast.rfidRereadInitiated"))},onError:et=>{v(et.message||x("printers.toast.failedToRereadRfid"),"error"),ut.current&&clearTimeout(ut.current),Le(null)}}),[Tt,Ft]=_.useState(null),[Pt,Nt]=_.useState(null),en=async()=>{try{const et=await ue.getPlateReferences(t.id);Ft(et)}catch{}},Ht=()=>{lt.mutate(!t.plate_detection_enabled)},dn=async()=>{fe(!0),te(null);const et=re?.chamber_light===!1;we(et),et&&(await ue.setChamberLight(t.id,!0),await new Promise(jt=>setTimeout(jt,2500)));try{const jt=await ue.checkPlateEmpty(t.id,{includeDebugImage:!0});te(jt),en()}catch(jt){v(jt instanceof Error?jt.message:x("printers.toast.failedToCheckPlate"),"error"),et&&(await ue.setChamberLight(t.id,!1),we(!1))}finally{fe(!1)}},cn=_.useCallback(async()=>{te(null),_e&&(await ue.setChamberLight(t.id,!1),we(!1))},[_e,t.id]),Sn=async et=>{Ee(!0);try{const jt=await ue.calibratePlateDetection(t.id,{label:et});if(jt.success){v(jt.message||x("printers.toast.calibrationSaved"),"success"),en();const qt=await ue.checkPlateEmpty(t.id,{includeDebugImage:!0});te(qt)}else v(jt.message||x("printers.toast.calibrationFailed"),"error")}catch(jt){v(jt instanceof Error?jt.message:x("printers.toast.calibrationFailed"),"error")}finally{Ee(!1)}},Gt=async(et,jt)=>{try{await ue.updatePlateReferenceLabel(t.id,et,jt),Nt(null),en()}catch(qt){v(qt instanceof Error?qt.message:x("printers.toast.failedToUpdateLabel"),"error")}},sn=async et=>{try{await ue.deletePlateReference(t.id,et),v(x("printers.toast.referenceDeleted"),"success"),en();const jt=await ue.checkPlateEmpty(t.id,{includeDebugImage:!0});te(jt)}catch(jt){v(jt instanceof Error?jt.message:x("printers.toast.failedToDeleteReference"),"error")}},un=async()=>{if(z){le(!0);try{await ue.updatePrinter(t.id,{plate_detection_roi:z}),v(x("printers.toast.detectionAreaSaved"),"success"),O(null);const et=await ue.checkPlateEmpty(t.id,{includeDebugImage:!0});te(et)}catch(et){v(et instanceof Error?et.message:x("printers.toast.failedToSaveDetectionArea"),"error")}finally{le(!1)}}};_.useEffect(()=>{const et=jt=>{jt.key==="Escape"&&q&&cn()};return window.addEventListener("keydown",et),()=>window.removeEventListener("keydown",et)},[q,cn]);const Yt=_.useRef(null);_.useEffect(()=>{if(!Ie)return;const et=re?.ams_status_main??0;return et!==0&&(Ce.current=!0,Yt.current&&(clearTimeout(Yt.current),Yt.current=null)),Ce.current&&et===0&&(St.current?(ut.current&&clearTimeout(ut.current),Le(null)):Yt.current||(Yt.current=setTimeout(()=>{ut.current&&clearTimeout(ut.current),Le(null)},2e3))),()=>{Yt.current&&clearTimeout(Yt.current)}},[re?.ams_status_main,Ie]);const[nr,jn]=_.useState(null);if(ln)return null;const ii=()=>{switch(i){case 1:return"w-10 h-10";case 2:return"w-14 h-14";case 3:return"w-16 h-16";case 4:return"w-20 h-20";default:return"w-14 h-14"}},rr=()=>{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"}},cr=()=>{switch(i){case 1:return"mb-2";case 2:return"mb-4";case 3:return"mb-5";case 4:return"mb-6";default:return"mb-4"}};return s.jsxs(_t,{className:"relative",children:[s.jsxs(Mt,{className:i>=3?"p-5":"",children:[s.jsxs("div",{className:cr(),children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[s.jsx("img",{src:aje(t.model),alt:t.model||x("common.printer"),className:`object-contain rounded-lg bg-bambu-dark flex-shrink-0 ${ii()}`}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("h3",{className:`font-semibold text-white ${rr()}`,children:t.name}),r==="compact"&&s.jsx("div",{className:`w-2 h-2 rounded-full flex-shrink-0 ${re?.connected?"bg-status-ok":"bg-status-error"}`,title:re?.connected?x("printers.connection.connected"):x("printers.connection.offline")})]}),s.jsxs("p",{className:"text-sm text-bambu-gray",children:[t.model||"Unknown Model",r==="expanded"&&re?.nozzles&&re.nozzles[0]?.nozzle_diameter&&s.jsxs("span",{className:"ml-1.5 text-bambu-gray",title:re.nozzles[0].nozzle_type||"Nozzle",children:["• ",re.nozzles[0].nozzle_diameter,"mm"]}),r==="expanded"&&n&&n.total_print_hours>0&&s.jsxs("span",{className:"ml-2 text-bambu-gray",children:[s.jsx(er,{className:"w-3 h-3 inline-block mr-1"}),Math.round(n.total_print_hours),"h"]})]})]})]}),s.jsxs("div",{className:"relative flex-shrink-0",children:[s.jsx(Te,{variant:"ghost",size:"sm",onClick:()=>T(!N),children:s.jsx(ih,{className:"w-4 h-4"})}),N&&s.jsxs("div",{className:"absolute right-0 mt-2 w-48 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg z-10",children:[s.jsxs("button",{className:`w-full px-4 py-2 text-left text-sm flex items-center gap-2 ${S("printers:update")?"hover:bg-bambu-dark-tertiary":"opacity-50 cursor-not-allowed"}`,onClick:()=>{S("printers:update")&&(R(!0),T(!1))},title:S("printers:update")?void 0:x("printers.permission.noEdit"),children:[s.jsx(Qi,{className:"w-4 h-4"}),x("common.edit")]}),s.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:()=>{Fn.mutate(),T(!1)},children:[s.jsx(Dr,{className:"w-4 h-4"}),x("printers.reconnect")]}),s.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:()=>{j(!0),T(!1)},children:[s.jsx(TW,{className:"w-4 h-4"}),x("printers.mqttDebug")]}),s.jsxs("button",{className:`w-full px-4 py-2 text-left text-sm flex items-center gap-2 ${S("printers:delete")?"text-red-400 hover:bg-bambu-dark-tertiary":"text-red-400/50 cursor-not-allowed"}`,onClick:()=>{S("printers:delete")&&(C(!0),T(!1))},title:S("printers:delete")?void 0:x("printers.permission.noDelete"),children:[s.jsx(rn,{className:"w-4 h-4"}),x("common.delete")]})]})]})]}),r==="expanded"&&s.jsxs("div",{className:"flex flex-wrap items-center gap-2 mt-2",children:[s.jsxs("span",{className:`flex items-center gap-1.5 px-2 py-1 rounded-full text-xs ${re?.connected?"bg-status-ok/20 text-status-ok":"bg-status-error/20 text-status-error"}`,children:[re?.connected?s.jsx(Fy,{className:"w-3 h-3"}):s.jsx(RR,{className:"w-3 h-3"}),re?.connected?x("printers.connection.connected"):x("printers.connection.offline")]}),re?.connected&&Be!=null&&s.jsxs("span",{className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs ${Be>=-50||Be>=-60?"bg-status-ok/20 text-status-ok":Be>=-70?"bg-status-warning/20 text-status-warning":Be>=-80?"bg-orange-500/20 text-orange-600":"bg-status-error/20 text-status-error"}`,title:`WiFi: ${Be} dBm - ${x(sje(Be).labelKey)}`,children:[s.jsx(Nhe,{className:"w-3 h-3"}),Be,"dBm"]}),re?.connected&&(()=>{const et=re.hms_errors?Gfe(re.hms_errors):[];return s.jsxs("button",{onClick:()=>ae(!0),className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs cursor-pointer hover:opacity-80 transition-opacity ${et.length>0?et.some(jt=>jt.severity<=2)?"bg-status-error/20 text-status-error":"bg-status-warning/20 text-status-warning":"bg-status-ok/20 text-status-ok"}`,title:x("printers.clickToViewHmsErrors"),children:[s.jsx(Cn,{className:"w-3 h-3"}),et.length>0?et.length:"OK"]})})(),n&&s.jsxs("button",{onClick:()=>y("/maintenance"),className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs cursor-pointer hover:opacity-80 transition-opacity ${n.due_count>0?"bg-status-error/20 text-status-error":n.warning_count>0?"bg-status-warning/20 text-status-warning":"bg-status-ok/20 text-status-ok"}`,title:n.due_count>0||n.warning_count>0?`${n.due_count>0?`${n.due_count} maintenance due`:""}${n.due_count>0&&n.warning_count>0?", ":""}${n.warning_count>0?`${n.warning_count} due soon`:""} - Click to view`:x("printers.maintenanceUpToDate"),children:[s.jsx(om,{className:"w-3 h-3"}),n.due_count>0||n.warning_count>0?n.due_count+n.warning_count:"OK"]}),Lt>0&&s.jsxs("button",{onClick:()=>y("/queue"),className:"flex items-center gap-1 px-2 py-1 rounded-full text-xs bg-purple-500/20 text-purple-400 hover:opacity-80 transition-opacity",title:x("printers.queue.inQueue",{count:Lt}),children:[s.jsx(sl,{className:"w-3 h-3"}),Lt]}),Fe?.update_available&&s.jsxs("button",{onClick:()=>ce(!0),className:"flex items-center gap-1 px-2 py-1 rounded-full text-xs bg-orange-500/20 text-orange-400 hover:opacity-80 transition-opacity",title:x("printers.firmwareUpdateAvailable",{current:Fe.current_version,latest:Fe.latest_version}),children:[s.jsx(yi,{className:"w-3 h-3"}),x("printers.firmwareUpdateButton")]})]})]}),k&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:s.jsx(_t,{className:"w-full max-w-md mx-4",children:s.jsxs(Mt,{children:[s.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[s.jsx("div",{className:"p-2 rounded-full bg-red-500/20",children:s.jsx(Cn,{className:"w-5 h-5 text-red-400"})}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-semibold text-white",children:x("printers.confirm.deleteTitle")}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:x("printers.confirm.deleteMessage",{name:t.name})})]})]}),s.jsx("div",{className:"bg-bambu-dark rounded-lg p-3 mb-4",children:s.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:E,onChange:et=>D(et.target.checked),className:"mt-0.5 w-4 h-4 rounded border-bambu-gray bg-bambu-dark-secondary text-bambu-green focus:ring-bambu-green focus:ring-offset-0"}),s.jsxs("div",{children:[s.jsx("span",{className:"text-sm text-white",children:x("printers.deleteArchives")}),s.jsx("p",{className:"text-xs text-bambu-gray mt-0.5",children:x(E?"printers.confirm.deleteArchivesNote":"printers.confirm.keepArchivesNote")})]})]})}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(Te,{variant:"secondary",onClick:()=>{C(!1),D(!0)},children:x("common.cancel")}),s.jsx(Te,{variant:"danger",onClick:()=>{mr.mutate({deleteArchives:E}),C(!1),D(!0)},children:"Delete"})]})]})})}),re?.connected&&s.jsxs(s.Fragment,{children:[r==="compact"?s.jsx("div",{className:"mt-2",children:re.state==="RUNNING"?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-1.5",children:s.jsx("div",{className:"bg-bambu-green h-1.5 rounded-full transition-all",style:{width:`${re.progress||0}%`}})}),s.jsxs("span",{className:"text-xs text-white",children:[Math.round(re.progress||0),"%"]})]}):s.jsx("p",{className:"text-xs text-bambu-gray",children:M$(re.state,re.stg_cur_name)})}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"mb-4 p-3 bg-bambu-dark rounded-lg relative",children:[s.jsxs("button",{onClick:()=>Pe(!0),disabled:!(re.state==="RUNNING"||re.state==="PAUSE"||re.state==="PAUSED")||(re.printable_objects_count??0)<2||!S("printers:control"),className:`absolute top-2 right-2 p-1.5 rounded transition-colors z-10 ${(re.state==="RUNNING"||re.state==="PAUSE"||re.state==="PAUSED")&&(re.printable_objects_count??0)>=2&&S("printers:control")?"text-bambu-gray hover:text-white hover:bg-white/10":"text-bambu-gray/30 cursor-not-allowed"}`,title:S("printers:control")?re.state==="RUNNING"||re.state==="PAUSE"||re.state==="PAUSED"?(re.printable_objects_count??0)>=2?x("printers.skipObjects.tooltip"):x("printers.skipObjects.requiresMultiple"):x("printers.skipObjects.onlyWhilePrinting"):x("printers.permission.noControl"),children:[s.jsx(x$,{className:"w-4 h-4"}),Et&&Et.skipped_count>0&&s.jsx("span",{className:"absolute -top-1 -right-1 min-w-[16px] h-4 px-1 flex items-center justify-center text-[10px] font-bold bg-red-500 text-white rounded-full",children:Et.skipped_count})]}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx(oje,{url:re.state==="RUNNING"?re.cover_url:null,printName:re.state==="RUNNING"&&(re.subtask_name||re.current_print)||void 0}),s.jsx("div",{className:"flex-1 min-w-0",children:re.current_print&&re.state==="RUNNING"?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-sm text-bambu-gray mb-1",children:re.stg_cur_name||"Printing"}),s.jsx("p",{className:"text-white text-sm mb-2 truncate",children:re.subtask_name||re.current_print}),s.jsxs("div",{className:"flex items-center justify-between text-sm",children:[s.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-2 mr-3",children:s.jsx("div",{className:"bg-bambu-green h-2 rounded-full transition-all",style:{width:`${re.progress||0}%`}})}),s.jsxs("span",{className:"text-white",children:[Math.round(re.progress||0),"%"]})]}),s.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-bambu-gray",children:[re.remaining_time!=null&&re.remaining_time>0&&s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(er,{className:"w-3 h-3"}),rje(re.remaining_time*60)]}),s.jsxs("span",{className:"text-bambu-green font-medium",title:x("printers.estimatedCompletion"),children:["ETA ",ije(re.remaining_time,d)]})]}),re.layer_num!=null&&re.total_layers!=null&&re.total_layers>0&&s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(sl,{className:"w-3 h-3"}),re.layer_num,"/",re.total_layers]}),ir&&s.jsxs("span",{className:"flex items-center gap-1",title:`Started by ${ir}`,children:[s.jsx(am,{className:"w-3 h-3"}),ir]})]})]}):s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-sm text-bambu-gray mb-1",children:x("printers.sort.status")}),s.jsx("p",{className:"text-white text-sm mb-2",children:M$(re.state,re.stg_cur_name)}),s.jsxs("div",{className:"flex items-center justify-between text-sm",children:[s.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-2 mr-3",children:s.jsx("div",{className:"bg-bambu-dark-tertiary h-2 rounded-full"})}),s.jsx("span",{className:"text-bambu-gray",children:"—"})]}),Dn?s.jsxs("p",{className:"text-xs text-bambu-gray mt-2 truncate",title:Dn.print_name||Dn.filename,children:["Last: ",Dn.print_name||Dn.filename,Dn.completed_at&&s.jsxs("span",{className:"ml-1 text-bambu-gray/60",children:["• ",Bg(Dn.completed_at,{month:"short",day:"numeric"})]})]}):s.jsx("p",{className:"text-xs text-bambu-gray mt-2",children:x("printers.readyToPrint")})]})})]})]}),re.state!=="RUNNING"&&s.jsx(Xfe,{printerId:t.id})]}),re.temperatures&&r==="expanded"&&(()=>{const et=re.temperatures.nozzle_heating||re.temperatures.nozzle_2_heating||!1,jt=re.temperatures.bed_heating||!1,qt=re.temperatures.chamber_heating||!1,yt=t.nozzle_count===2||re.temperatures.nozzle_2!==void 0,wn=re.active_extruder===1?"L":"R";return s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsxs("div",{className:"text-center px-2 py-1.5 bg-bambu-dark rounded-lg flex-1",children:[s.jsx($A,{className:"w-3.5 h-3.5 mx-auto mb-0.5",color:"text-orange-400",isHeating:et}),re.temperatures.nozzle_2!==void 0?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-[9px] text-bambu-gray",children:"L / R"}),s.jsxs("p",{className:"text-[11px] text-white",children:[Math.round(re.temperatures.nozzle||0),"° / ",Math.round(re.temperatures.nozzle_2||0),"°"]})]}):s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-[9px] text-bambu-gray",children:x("printers.temperatures.nozzle")}),s.jsxs("p",{className:"text-[11px] text-white",children:[Math.round(re.temperatures.nozzle||0),"°C"]})]})]}),s.jsxs("div",{className:"text-center px-2 py-1.5 bg-bambu-dark rounded-lg flex-1",children:[s.jsx($A,{className:"w-3.5 h-3.5 mx-auto mb-0.5",color:"text-blue-400",isHeating:jt}),s.jsx("p",{className:"text-[9px] text-bambu-gray",children:x("printers.temperatures.bed")}),s.jsxs("p",{className:"text-[11px] text-white",children:[Math.round(re.temperatures.bed||0),"°C"]})]}),re.temperatures.chamber!==void 0&&s.jsxs("div",{className:"text-center px-2 py-1.5 bg-bambu-dark rounded-lg flex-1",children:[s.jsx($A,{className:"w-3.5 h-3.5 mx-auto mb-0.5",color:"text-green-400",isHeating:qt}),s.jsx("p",{className:"text-[9px] text-bambu-gray",children:x("printers.temperatures.chamber")}),s.jsxs("p",{className:"text-[11px] text-white",children:[Math.round(re.temperatures.chamber||0),"°C"]})]}),yt&&s.jsxs("div",{className:"text-center px-2 py-1.5 bg-bambu-dark rounded-lg",title:x("printers.activeNozzle",{nozzle:x(wn==="L"?"common.left":"common.right")}),children:[s.jsx("p",{className:`text-[11px] font-bold ${wn==="L"?"text-amber-400":"text-gray-500"}`,children:"L"}),s.jsx("p",{className:"text-[9px] text-bambu-gray",children:x("printers.temperatures.nozzle")}),s.jsx("p",{className:`text-[11px] font-bold ${wn==="R"?"text-amber-400":"text-gray-500"}`,children:"R"})]})]})})(),r==="expanded"&&(()=>{const et=re.state==="RUNNING",jt=re.state==="PAUSED"||re.state==="PAUSE",qt=et||jt,yt=Ba.isPending||Ae.isPending||Ze.isPending,wn=re.cooling_fan_speed,Fr=re.big_fan1_speed,Yr=re.big_fan2_speed;return s.jsxs("div",{className:"mt-3",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:x("printers.controls")}),s.jsx("div",{className:"flex-1 h-px bg-bambu-dark-tertiary/30"})]}),s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:`flex items-center gap-1 px-1.5 py-1 rounded ${wn&&wn>0?"bg-cyan-500/10":"bg-bambu-dark"}`,title:x("printers.fans.partCooling"),children:[s.jsx(gW,{className:`w-3.5 h-3.5 ${wn&&wn>0?"text-cyan-400":"text-bambu-gray/50"}`}),s.jsxs("span",{className:`text-[10px] ${wn&&wn>0?"text-cyan-400":"text-bambu-gray/50"}`,children:[wn??0,"%"]})]}),s.jsxs("div",{className:`flex items-center gap-1 px-1.5 py-1 rounded ${Fr&&Fr>0?"bg-blue-500/10":"bg-bambu-dark"}`,title:x("printers.fans.auxiliary"),children:[s.jsx(CW,{className:`w-3.5 h-3.5 ${Fr&&Fr>0?"text-blue-400":"text-bambu-gray/50"}`}),s.jsxs("span",{className:`text-[10px] ${Fr&&Fr>0?"text-blue-400":"text-bambu-gray/50"}`,children:[Fr??0,"%"]})]}),s.jsxs("div",{className:`flex items-center gap-1 px-1.5 py-1 rounded ${Yr&&Yr>0?"bg-green-500/10":"bg-bambu-dark"}`,title:x("printers.fans.chamber"),children:[s.jsx(rce,{className:`w-3.5 h-3.5 ${Yr&&Yr>0?"text-green-400":"text-bambu-gray/50"}`}),s.jsxs("span",{className:`text-[10px] ${Yr&&Yr>0?"text-green-400":"text-bambu-gray/50"}`,children:[Yr??0,"%"]})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("button",{onClick:()=>X(!0),disabled:!qt||yt||!S("printers:control"),className:`
- flex items-center justify-center gap-1 px-3 py-1.5 rounded-lg text-xs font-medium
- transition-colors
- ${qt&&S("printers:control")?"bg-red-500/20 text-red-400 hover:bg-red-500/30":"bg-bambu-dark text-bambu-gray/50 cursor-not-allowed"}
- `,title:S("printers:control")?x("printers.stop"):x("printers.permission.noControl"),children:[s.jsx(ll,{className:"w-3 h-3"}),x("printers.stop")]}),s.jsxs("button",{onClick:()=>jt?xe(!0):se(!0),disabled:!qt||yt||!S("printers:control"),className:`
- flex items-center justify-center gap-1 px-3 py-1.5 rounded-lg text-xs font-medium
- transition-colors
- ${qt&&S("printers:control")?jt?"bg-bambu-green/20 text-bambu-green hover:bg-bambu-green/30":"bg-yellow-500/20 text-yellow-400 hover:bg-yellow-500/30":"bg-bambu-dark text-bambu-gray/50 cursor-not-allowed"}
- `,title:S("printers:control")?x(jt?"printers.resume":"printers.pause"):x("printers.permission.noControl"),children:[jt?s.jsx(Is,{className:"w-3 h-3"}):s.jsx(CR,{className:"w-3 h-3"}),x(jt?"printers.resume":"printers.pause")]})]})]})]})})(),We&&We.length>0&&r==="expanded"&&(()=>{const et=We.filter(yt=>yt.tray.length>1),jt=We.filter(yt=>yt.tray.length===1),qt=t.nozzle_count===2||re?.temperatures?.nozzle_2!==void 0;return s.jsxs("div",{className:"mt-3",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:x("printers.filaments")}),s.jsx("div",{className:"flex-1 h-px bg-bambu-dark-tertiary/30"})]}),s.jsxs("div",{className:"space-y-3",children:[et.length>0&&s.jsx("div",{className:"grid grid-cols-2 gap-3",children:et.map(yt=>{const wn=tt[String(yt.id)],Fr=yt.id>=128?yt.id-128:yt.id,Yr=wn!==void 0?wn:Fr,Br=Yr===1,Ws=Yr===0;return s.jsxs("div",{className:"p-2.5 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary/30",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"text-[10px] text-white font-medium",children:_d(yt.id,yt.tray.length)}),qt&&(Br||Ws)&&s.jsx(y$,{side:Br?"L":"R"})]}),(yt.humidity!=null||yt.temp!=null)&&s.jsxs("div",{className:"flex items-center gap-1.5",children:[yt.humidity!=null&&s.jsx(w$,{humidity:yt.humidity,goodThreshold:a?.humidityGood,fairThreshold:a?.humidityFair,onClick:()=>Ne({amsId:yt.id,amsLabel:_d(yt.id,yt.tray.length),mode:"humidity"}),compact:!0}),yt.temp!=null&&s.jsx(_$,{temp:yt.temp,goodThreshold:a?.tempGood,fairThreshold:a?.tempFair,onClick:()=>Ne({amsId:yt.id,amsLabel:_d(yt.id,yt.tray.length),mode:"temperature"}),compact:!0})]})]}),s.jsx("div",{className:"grid grid-cols-4 gap-1.5",children:[0,1,2,3].map(tn=>{const on=yt.tray[tn]||yt.tray.find(Hr=>Hr.id===tn),_i=on?.tray_type&&on.remain>=0,Ss=!on?.tray_type,_o=yt.id*4+tn,So=De===_o,Mo=on?.tray_info_idx?Ve?.[on.tray_info_idx]:null,Ms=$e?.[_o],Si=on?.tray_type?{vendor:VA(on)?"Bambu Lab":"Generic",profile:Mo?.name||Ms?.preset_name||on.tray_sub_brands||on.tray_type,colorName:zA(on.tray_id_name)||BA(on.tray_color),colorHex:on.tray_color||null,kFactor:HA(on.k),fillLevel:_i?on.remain:null,trayUuid:on.tray_uuid||null}:null,Ks=Ie?.amsId===yt.id&&Ie?.slotId===tn,la=s.jsxs("div",{className:`bg-bambu-dark-tertiary rounded p-1 text-center ${Ss?"opacity-50":""} ${So?"ring-2 ring-bambu-green ring-offset-1 ring-offset-bambu-dark":""}`,children:[s.jsx("div",{className:"w-3.5 h-3.5 rounded-full mx-auto mb-0.5 border-2",style:{backgroundColor:on?.tray_color?`#${on.tray_color}`:on?.tray_type?"#333":"transparent",borderColor:Ss?"#666":"rgba(255,255,255,0.1)",borderStyle:Ss?"dashed":"solid"}}),s.jsx("div",{className:"text-[9px] text-white font-bold truncate",children:on?.tray_type||"—"}),s.jsx("div",{className:"mt-1 h-1.5 bg-black/30 rounded-full overflow-hidden",children:_i&&on?s.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${on.remain}%`,backgroundColor:S$(on.remain)}}):on?.tray_type?s.jsx("div",{className:"h-full w-full rounded-full bg-white/50 dark:bg-gray-500/40"}):null})]});return s.jsxs("div",{className:"relative group",children:[Ks&&s.jsx("div",{className:"absolute inset-0 bg-bambu-dark-tertiary/80 rounded flex items-center justify-center z-20",children:s.jsx(Dr,{className:"w-4 h-4 text-bambu-green animate-spin"})}),re?.state!=="RUNNING"&&s.jsx("button",{onClick:Hr=>{Hr.stopPropagation(),jn(nr?.amsId===yt.id&&nr?.slotId===tn?null:{amsId:yt.id,slotId:tn})},className:"absolute -top-1 -right-1 w-4 h-4 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-full flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity z-10 hover:bg-bambu-dark-tertiary",title:x("printers.slotOptions"),children:s.jsx(ih,{className:"w-2.5 h-2.5 text-bambu-gray"})}),re?.state!=="RUNNING"&&nr?.amsId===yt.id&&nr?.slotId===tn&&s.jsx("div",{className:"absolute top-full left-0 mt-1 z-50 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 min-w-[120px]",children:s.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-xs flex items-center gap-2 ${S("printers:ams_rfid")?"text-white hover:bg-bambu-dark-tertiary":"text-bambu-gray/50 cursor-not-allowed"}`,onClick:Hr=>{Hr.stopPropagation(),S("printers:ams_rfid")&&(At.mutate({amsId:yt.id,slotId:tn}),jn(null))},disabled:Ks||!S("printers:ams_rfid"),title:S("printers:ams_rfid")?void 0:x("printers.permission.noAmsRfid"),children:[s.jsx(Dr,{className:`w-3 h-3 ${Ks?"animate-spin":""}`}),x("printers.rfid.reread")]})}),Si?s.jsx(IA,{data:Si,spoolman:{enabled:o,hasUnlinkedSpools:l,linkedSpoolId:Si.trayUuid?c?.[Si.trayUuid.toUpperCase()]:void 0,spoolmanUrl:u,onLinkSpool:o&&Si.trayUuid?Hr=>{ge({trayUuid:Hr,trayInfo:{type:Si.profile,color:Si.colorHex||"",location:`${_d(yt.id,yt.tray.length)} Slot ${tn+1}`}})}:void 0},configureSlot:{enabled:S("printers:control"),onConfigure:()=>G({amsId:yt.id,trayId:tn,trayCount:yt.tray.length,trayType:on?.tray_type||void 0,trayColor:on?.tray_color||void 0,traySubBrands:on?.tray_sub_brands||void 0,trayInfoIdx:on?.tray_info_idx||void 0})},children:la}):s.jsx(m$,{configureSlot:{enabled:S("printers:control"),onConfigure:()=>G({amsId:yt.id,trayId:tn,trayCount:yt.tray.length})},children:la})]},tn)})})]},yt.id)})}),(jt.length>0||re.vt_tray&&re.vt_tray.tray_type)&&s.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[jt.map(yt=>{const wn=tt[String(yt.id)],Fr=yt.id>=128?yt.id-128:yt.id,Yr=wn!==void 0?wn:Fr,Br=Yr===1,Ws=Yr===0,tn=yt.tray[0],on=tn?.tray_type&&tn.remain>=0,_i=!tn?.tray_type,Ss=yt.id*4+(tn?.id??0),_o=De===Ss,So=tn?.tray_info_idx?Ve?.[tn.tray_info_idx]:null,Mo=$e?.[Ss],Ms=tn?.tray_type?{vendor:VA(tn)?"Bambu Lab":"Generic",profile:So?.name||Mo?.preset_name||tn.tray_sub_brands||tn.tray_type,colorName:zA(tn.tray_id_name)||BA(tn.tray_color),colorHex:tn.tray_color||null,kFactor:HA(tn.k),fillLevel:on?tn.remain:null,trayUuid:tn.tray_uuid||null}:null,Si=tn?.id??0,Ks=Ie?.amsId===yt.id&&Ie?.slotId===Si,la=s.jsxs("div",{className:`bg-bambu-dark-tertiary rounded p-1 text-center ${_i?"opacity-50":""} ${_o?"ring-2 ring-bambu-green ring-offset-1 ring-offset-bambu-dark":""}`,children:[s.jsx("div",{className:"w-3.5 h-3.5 rounded-full mx-auto mb-0.5 border-2",style:{backgroundColor:tn?.tray_color?`#${tn.tray_color}`:tn?.tray_type?"#333":"transparent",borderColor:_i?"#666":"rgba(255,255,255,0.1)",borderStyle:_i?"dashed":"solid"}}),s.jsx("div",{className:"text-[9px] text-white font-bold truncate",children:tn?.tray_type||"—"}),s.jsx("div",{className:"mt-1 h-1.5 bg-black/30 rounded-full overflow-hidden",children:on?s.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${tn.remain}%`,backgroundColor:S$(tn.remain)}}):tn?.tray_type?s.jsx("div",{className:"h-full w-full rounded-full bg-white/50 dark:bg-gray-500/40"}):null})]});return s.jsxs("div",{className:"p-2.5 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary/30",children:[s.jsxs("div",{className:"flex items-center gap-1 mb-2",children:[s.jsx("span",{className:"text-[10px] text-white font-medium",children:_d(yt.id,yt.tray.length)}),qt&&(Br||Ws)&&s.jsx(y$,{side:Br?"L":"R"})]}),s.jsxs("div",{className:"flex gap-1.5",children:[s.jsxs("div",{className:"relative group flex-1",children:[Ks&&s.jsx("div",{className:"absolute inset-0 bg-bambu-dark-tertiary/80 rounded flex items-center justify-center z-20",children:s.jsx(Dr,{className:"w-4 h-4 text-bambu-green animate-spin"})}),re?.state!=="RUNNING"&&s.jsx("button",{onClick:Hr=>{Hr.stopPropagation(),jn(nr?.amsId===yt.id&&nr?.slotId===Si?null:{amsId:yt.id,slotId:Si})},className:"absolute -top-1 -right-1 w-4 h-4 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-full flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity z-10 hover:bg-bambu-dark-tertiary",title:x("printers.slotOptions"),children:s.jsx(ih,{className:"w-2.5 h-2.5 text-bambu-gray"})}),re?.state!=="RUNNING"&&nr?.amsId===yt.id&&nr?.slotId===Si&&s.jsx("div",{className:"absolute top-full left-0 mt-1 z-50 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 min-w-[120px]",children:s.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-xs flex items-center gap-2 ${S("printers:ams_rfid")?"text-white hover:bg-bambu-dark-tertiary":"text-bambu-gray/50 cursor-not-allowed"}`,onClick:Hr=>{Hr.stopPropagation(),S("printers:ams_rfid")&&(At.mutate({amsId:yt.id,slotId:Si}),jn(null))},disabled:Ks||!S("printers:ams_rfid"),title:S("printers:ams_rfid")?void 0:x("printers.permission.noAmsRfid"),children:[s.jsx(Dr,{className:`w-3 h-3 ${Ks?"animate-spin":""}`}),x("printers.rfid.reread")]})}),Ms?s.jsx(IA,{data:Ms,spoolman:{enabled:o,hasUnlinkedSpools:l,linkedSpoolId:Ms.trayUuid?c?.[Ms.trayUuid.toUpperCase()]:void 0,spoolmanUrl:u,onLinkSpool:o&&Ms.trayUuid?Hr=>{ge({trayUuid:Hr,trayInfo:{type:Ms.profile,color:Ms.colorHex||"",location:_d(yt.id,yt.tray.length)}})}:void 0},configureSlot:{enabled:S("printers:control"),onConfigure:()=>G({amsId:yt.id,trayId:Si,trayCount:yt.tray.length,trayType:tn?.tray_type||void 0,trayColor:tn?.tray_color||void 0,traySubBrands:tn?.tray_sub_brands||void 0,trayInfoIdx:tn?.tray_info_idx||void 0})},children:la}):s.jsx(m$,{configureSlot:{enabled:S("printers:control"),onConfigure:()=>G({amsId:yt.id,trayId:Si,trayCount:yt.tray.length})},children:la})]}),(yt.humidity!=null||yt.temp!=null)&&s.jsxs("div",{className:"flex flex-col justify-center gap-1 shrink-0",children:[yt.temp!=null&&s.jsx(_$,{temp:yt.temp,goodThreshold:a?.tempGood,fairThreshold:a?.tempFair,onClick:()=>Ne({amsId:yt.id,amsLabel:_d(yt.id,yt.tray.length),mode:"temperature"}),compact:!0}),yt.humidity!=null&&s.jsx(w$,{humidity:yt.humidity,goodThreshold:a?.humidityGood,fairThreshold:a?.humidityFair,onClick:()=>Ne({amsId:yt.id,amsLabel:_d(yt.id,yt.tray.length),mode:"humidity"}),compact:!0})]})]})]},yt.id)}),re.vt_tray&&re.vt_tray.tray_type&&(()=>{const yt=re.vt_tray,wn=De===254,Fr=yt.tray_info_idx?Ve?.[yt.tray_info_idx]:null,Yr=$e?.[1020],Br={vendor:VA(yt)?"Bambu Lab":"Generic",profile:Fr?.name||Yr?.preset_name||yt.tray_sub_brands||yt.tray_type||"Unknown",colorName:zA(yt.tray_id_name)||BA(yt.tray_color),colorHex:yt.tray_color||null,kFactor:HA(yt.k),fillLevel:null,trayUuid:yt.tray_uuid||null},Ws=s.jsxs("div",{className:`bg-bambu-dark-tertiary rounded p-1 text-center cursor-default ${wn?"ring-2 ring-bambu-green ring-offset-1 ring-offset-bambu-dark":""}`,children:[s.jsx("div",{className:"w-3.5 h-3.5 rounded-full mx-auto mb-0.5 border-2",style:{backgroundColor:yt.tray_color?`#${yt.tray_color}`:"#333",borderColor:wn?"var(--accent)":"rgba(255,255,255,0.1)"}}),s.jsx("div",{className:"text-[9px] text-white font-bold truncate",children:yt.tray_type||"Spool"}),s.jsx("div",{className:"mt-1 h-1.5 bg-black/30 rounded-full overflow-hidden",children:s.jsx("div",{className:"h-full w-full rounded-full bg-white/50 dark:bg-gray-500/40"})})]});return s.jsxs("div",{className:"p-2.5 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary/30",children:[s.jsx("div",{className:"flex items-center gap-1 mb-2",children:s.jsx("span",{className:"text-[10px] text-white font-medium",children:x("printers.external")})}),s.jsx(IA,{data:Br,spoolman:{enabled:o,hasUnlinkedSpools:l,linkedSpoolId:Br.trayUuid?c?.[Br.trayUuid.toUpperCase()]:void 0,spoolmanUrl:u,onLinkSpool:o&&Br.trayUuid?tn=>{ge({trayUuid:tn,trayInfo:{type:Br.profile,color:Br.colorHex||"",location:"External Spool"}})}:void 0},configureSlot:{enabled:S("printers:control"),onConfigure:()=>G({amsId:255,trayId:0,trayCount:1,trayType:yt.tray_type||void 0,trayColor:yt.tray_color||void 0,traySubBrands:yt.tray_sub_brands||void 0,trayInfoIdx:yt.tray_info_idx||void 0})},children:Ws})]})})()]})]})]})})()]}),Ye&&r==="expanded"&&s.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx(vh,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),s.jsx("span",{className:"text-sm text-white truncate",children:Ye.name}),ft&&s.jsxs("span",{className:`text-xs px-1.5 py-0.5 rounded flex-shrink-0 ${ft.state==="ON"?"bg-bambu-green/20 text-bambu-green":ft.state==="OFF"?"bg-red-500/20 text-red-400":"bg-bambu-gray/20 text-bambu-gray"}`,children:[ft.state||"?",ft.state==="ON"&&ft.energy?.power!=null&&s.jsxs("span",{className:"text-yellow-400 ml-1.5",children:["· ",ft.energy.power,"W"]})]})]}),s.jsx("div",{className:"flex-1"}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsxs("button",{onClick:()=>K(!0),disabled:Xn.isPending||ft?.state==="ON"||!S("smart_plugs:control"),className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${S("smart_plugs:control")?ft?.state==="ON"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary":"bg-bambu-dark text-bambu-gray/50 cursor-not-allowed"}`,title:S("smart_plugs:control")?void 0:x("printers.permission.noSmartPlugControl"),children:[s.jsx(Gu,{className:"w-3 h-3"}),"On"]}),s.jsxs("button",{onClick:()=>Q(!0),disabled:Xn.isPending||ft?.state==="OFF"||!S("smart_plugs:control"),className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${S("smart_plugs:control")?ft?.state==="OFF"?"bg-red-500/30 text-red-400":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary":"bg-bambu-dark text-bambu-gray/50 cursor-not-allowed"}`,title:S("smart_plugs:control")?void 0:x("printers.permission.noSmartPlugControl"),children:[s.jsx(gN,{className:"w-3 h-3"}),"Off"]})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx("span",{className:`text-xs hidden sm:inline ${Ye.auto_off_executed?"text-bambu-green":"text-bambu-gray"}`,children:Ye.auto_off_executed?"Auto-off done":"Auto-off"}),s.jsx("button",{onClick:()=>bn.mutate(!Ye.auto_off),disabled:bn.isPending||Ye.auto_off_executed||!S("smart_plugs:control"),title:S("smart_plugs:control")?Ye.auto_off_executed?x("printers.autoOffExecuted"):x("printers.autoOffAfterPrint"):x("printers.permission.noSmartPlugControl"),className:`relative w-9 h-5 rounded-full transition-colors flex-shrink-0 ${S("smart_plugs:control")?Ye.auto_off_executed?"bg-bambu-green/50 cursor-not-allowed":Ye.auto_off?"bg-bambu-green":"bg-bambu-dark-tertiary":"bg-bambu-dark-tertiary/50 cursor-not-allowed"}`,children:s.jsx("span",{className:`absolute top-[2px] left-[2px] w-4 h-4 bg-white rounded-full transition-transform ${Ye.auto_off||Ye.auto_off_executed?"translate-x-4":"translate-x-0"}`})})]})]}),xt&&xt.length>0&&s.jsxs("div",{className:"flex items-center gap-2 mt-2 pt-2 border-t border-bambu-dark-tertiary/50",children:[s.jsx(Is,{className:"w-3.5 h-3.5 text-blue-400 flex-shrink-0"}),s.jsx("span",{className:"text-xs text-bambu-gray",children:"Scripts:"}),s.jsx("div",{className:"flex flex-wrap gap-1",children:xt.map(et=>s.jsxs("button",{onClick:()=>wi.mutate(et.id),disabled:wi.isPending,title:`Run ${et.ha_entity_id}`,className:"px-2 py-0.5 text-xs bg-blue-500/20 text-blue-400 hover:bg-blue-500/30 rounded transition-colors flex items-center gap-1",children:[s.jsx(Is,{className:"w-2.5 h-2.5"}),et.name]},et.id))})]})]}),r==="expanded"&&s.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3",children:[s.jsxs("div",{className:"text-xs text-bambu-gray",children:[s.jsx("p",{children:t.ip_address}),s.jsx("p",{className:"truncate",children:t.serial_number})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx(Te,{variant:"secondary",size:"sm",onClick:()=>st.mutate(!re?.chamber_light),disabled:!re?.connected||st.isPending||!S("printers:control"),title:S("printers:control")?re?.chamber_light?x("printers.chamberLightOff"):x("printers.chamberLightOn"):x("printers.permission.noControl"),className:re?.chamber_light?"bg-yellow-500/20 hover:bg-yellow-500/30 border-yellow-500/30":"",children:s.jsx(YCe,{on:re?.chamber_light??!1,className:"w-4 h-4"})}),s.jsx(Te,{variant:"secondary",size:"sm",onClick:()=>{if(f==="embedded"&&p)p(t.id,t.name);else{const et=localStorage.getItem("cameraWindowState"),jt=et?JSON.parse(et):{width:640,height:400},qt=[`width=${jt.width}`,`height=${jt.height}`,jt.left!==void 0?`left=${jt.left}`:"",jt.top!==void 0?`top=${jt.top}`:"","menubar=no,toolbar=no,location=no,status=no,noopener"].filter(Boolean).join(",");window.open(`/camera/${t.id}`,`camera-${t.id}`,qt)}},disabled:!re?.connected,title:x(f==="embedded"?"printers.openCameraOverlay":"printers.openCameraWindow"),children:s.jsx(OR,{className:"w-4 h-4"})}),s.jsxs("div",{className:`inline-flex rounded-md ${t.plate_detection_enabled?"ring-1 ring-green-500":""}`,children:[s.jsx(Te,{variant:"secondary",size:"sm",onClick:Ht,disabled:!re?.connected||lt.isPending||!S("printers:update"),title:S("printers:update")?t.plate_detection_enabled?x("printers.plateDetection.enabledClick"):x("printers.plateDetection.disabledClick"):x("printers.plateDetection.noPermission"),className:`!rounded-r-none !border-r-0 ${t.plate_detection_enabled?"!border-green-500 !text-green-400 hover:!bg-green-500/20":""}`,children:lt.isPending?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(K1,{className:"w-4 h-4"})}),s.jsx(Te,{variant:"secondary",size:"sm",onClick:dn,disabled:!re?.connected||I||!S("printers:update"),title:S("printers:update")?x("printers.plateDetection.manageCalibration"):x("printers.plateDetection.noPermission"),className:`!rounded-l-none !px-1.5 ${t.plate_detection_enabled?"!border-green-500 !text-green-400 hover:!bg-green-500/20":""}`,children:I?s.jsx(ht,{className:"w-3 h-3 animate-spin"}):s.jsx(ei,{className:"w-3 h-3"})})]}),s.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>F(!0),disabled:!S("printers:files"),title:S("printers:files")?x("printers.browseFiles"):x("printers.permission.noFiles"),children:[s.jsx(hN,{className:"w-4 h-4"}),"Files"]})]})]})]}),U&&s.jsx(Ffe,{printerId:t.id,printerName:t.name,onClose:()=>F(!1)}),$&&s.jsx($fe,{printerId:t.id,printerName:t.name,onClose:()=>j(!1)}),q&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:()=>cn(),children:s.jsxs("div",{className:"bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl shadow-2xl max-w-lg w-full",onClick:et=>et.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[q.needs_calibration?s.jsx(K1,{className:"w-5 h-5 text-blue-500"}):q.is_empty?s.jsx(Ar,{className:"w-5 h-5 text-green-500"}):s.jsx(Yi,{className:"w-5 h-5 text-yellow-500"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Build Plate Check"}),q.reference_count!==void 0&&q.max_references&&s.jsxs("span",{className:"text-xs text-bambu-gray bg-bambu-dark-tertiary px-2 py-1 rounded",children:[q.reference_count,"/",q.max_references," refs"]})]}),s.jsx("button",{onClick:()=>cn(),className:"p-1 text-bambu-gray hover:text-white rounded transition-colors",children:s.jsx(Rt,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"p-4 space-y-4",children:[q.needs_calibration?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"p-3 rounded-lg bg-blue-500/20 border border-blue-500/50",children:[s.jsx("p",{className:"font-medium text-blue-400",children:x("printers.plateDetection.calibrationRequired")}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",dangerouslySetInnerHTML:{__html:x("printers.plateDetection.calibrationInstructions")}})]}),s.jsxs("div",{className:"text-sm text-bambu-gray space-y-2",children:[s.jsx("p",{children:x("printers.plateDetection.calibrationDescription")}),s.jsx("p",{dangerouslySetInnerHTML:{__html:x("printers.plateDetection.calibrationTip")}})]})]}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:`p-3 rounded-lg ${q.is_empty?"bg-green-500/20 border border-green-500/50":"bg-yellow-500/20 border border-yellow-500/50"}`,children:[s.jsx("p",{className:`font-medium ${q.is_empty?"text-green-400":"text-yellow-400"}`,children:q.is_empty?x("printers.plateDetection.plateEmpty"):x("printers.plateDetection.objectsDetected")}),s.jsxs("p",{className:"text-sm text-bambu-gray mt-1",children:[x("printers.plateDetection.confidence"),": ",Math.round(q.confidence*100),"% | ",x("printers.plateDetection.difference"),": ",q.difference_percent.toFixed(1),"%"]})]}),q.debug_image_url&&s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:x("printers.plateDetection.analysisPreview")}),s.jsx("img",{src:q.debug_image_url,alt:x("printers.plateDetection.analysisPreview"),className:"w-full rounded-lg border border-bambu-dark-tertiary"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-2",children:x("printers.plateDetection.analysisLegend")})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:q.message})]}),Tt&&Tt.references.length>0&&s.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[s.jsx("p",{className:"text-sm font-medium text-white mb-2",children:x("printers.plateDetection.savedReferences",{count:Tt.references.length,max:Tt.max_references})}),s.jsx("div",{className:"grid grid-cols-5 gap-2",children:Tt.references.map(et=>s.jsxs("div",{className:"relative group",children:[s.jsx("img",{src:ue.getPlateReferenceThumbnailUrl(t.id,et.index),alt:et.label||`Reference ${et.index+1}`,className:"w-full aspect-video object-cover rounded border border-bambu-dark-tertiary"}),s.jsx("button",{onClick:()=>sn(et.index),className:"absolute top-1 right-1 p-0.5 bg-red-500/80 rounded opacity-0 group-hover:opacity-100 transition-opacity",title:x("printers.plateDetection.deleteReference"),children:s.jsx(Rt,{className:"w-3 h-3 text-white"})}),Pt?.index===et.index?s.jsx("input",{type:"text",value:Pt.label,onChange:jt=>Nt({...Pt,label:jt.target.value}),onBlur:()=>Gt(et.index,Pt.label),onKeyDown:jt=>{jt.key==="Enter"&&Gt(et.index,Pt.label),jt.key==="Escape"&&Nt(null)},className:"w-full mt-1 px-1 py-0.5 text-xs bg-bambu-dark-tertiary border border-bambu-green rounded text-white",autoFocus:!0,placeholder:x("printers.plateDetection.labelPlaceholder")}):s.jsx("p",{className:"text-xs text-bambu-gray mt-1 truncate cursor-pointer hover:text-white",onClick:()=>Nt({index:et.index,label:et.label}),title:et.label?x("printers.plateDetection.clickToEdit",{label:et.label}):x("printers.plateDetection.clickToAddLabel"),children:et.label||s.jsx("span",{className:"italic opacity-50",children:x("printers.noLabel")})}),s.jsx("p",{className:"text-[10px] text-bambu-gray/60",children:et.timestamp?new Date(et.timestamp).toLocaleDateString():""})]},et.index))})]}),!q.needs_calibration&&s.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("p",{className:"text-sm font-medium text-white",children:x("printers.roi.title")}),z?s.jsxs("div",{className:"flex gap-1",children:[s.jsx(Te,{variant:"ghost",size:"sm",onClick:()=>O(null),disabled:ee,children:x("common.cancel")}),s.jsx(Te,{size:"sm",onClick:un,disabled:ee,children:ee?s.jsx(ht,{className:"w-3 h-3 animate-spin"}):x("common.save")})]}):s.jsxs(Te,{variant:"ghost",size:"sm",onClick:()=>O(q.roi||{x:.15,y:.35,w:.7,h:.55}),children:[s.jsx(Qi,{className:"w-3 h-3 mr-1"}),x("common.edit")]})]}),z?s.jsxs("div",{className:"space-y-3 bg-bambu-dark-tertiary/50 p-3 rounded-lg",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-bambu-gray",children:x("printers.roi.xStart")}),s.jsx("input",{type:"range",min:"0",max:"0.9",step:"0.01",value:z.x,onChange:et=>O({...z,x:parseFloat(et.target.value)}),className:"w-full h-1.5 bg-bambu-dark-tertiary rounded-lg cursor-pointer accent-green-500"}),s.jsxs("span",{className:"text-xs text-bambu-gray",children:[Math.round(z.x*100),"%"]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-bambu-gray",children:x("printers.roi.yStart")}),s.jsx("input",{type:"range",min:"0",max:"0.9",step:"0.01",value:z.y,onChange:et=>O({...z,y:parseFloat(et.target.value)}),className:"w-full h-1.5 bg-bambu-dark-tertiary rounded-lg cursor-pointer accent-green-500"}),s.jsxs("span",{className:"text-xs text-bambu-gray",children:[Math.round(z.y*100),"%"]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-bambu-gray",children:x("printers.width")}),s.jsx("input",{type:"range",min:"0.1",max:"1",step:"0.01",value:z.w,onChange:et=>O({...z,w:parseFloat(et.target.value)}),className:"w-full h-1.5 bg-bambu-dark-tertiary rounded-lg cursor-pointer accent-green-500"}),s.jsxs("span",{className:"text-xs text-bambu-gray",children:[Math.round(z.w*100),"%"]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-bambu-gray",children:x("printers.height")}),s.jsx("input",{type:"range",min:"0.1",max:"1",step:"0.01",value:z.h,onChange:et=>O({...z,h:parseFloat(et.target.value)}),className:"w-full h-1.5 bg-bambu-dark-tertiary rounded-lg cursor-pointer accent-green-500"}),s.jsxs("span",{className:"text-xs text-bambu-gray",children:[Math.round(z.h*100),"%"]})]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:x("printers.roi.instruction")})]}):s.jsxs("p",{className:"text-xs text-bambu-gray",children:["Current: X=",Math.round((q.roi?.x||.15)*100),"%, Y=",Math.round((q.roi?.y||.35)*100),"%, W=",Math.round((q.roi?.w||.7)*100),"%, H=",Math.round((q.roi?.h||.55)*100),"%"]})]})]}),s.jsx("div",{className:"flex justify-end gap-2 p-4 border-t border-bambu-dark-tertiary",children:q.needs_calibration?s.jsxs(s.Fragment,{children:[s.jsx(Te,{variant:"ghost",onClick:()=>cn(),children:x("common.cancel")}),s.jsx(Te,{onClick:()=>Sn(),disabled:me,children:me?s.jsxs(s.Fragment,{children:[s.jsx(ht,{className:"w-4 h-4 mr-2 animate-spin"}),"Calibrating..."]}):"Calibrate Empty Plate"})]}):s.jsxs(s.Fragment,{children:[s.jsx(Te,{variant:"ghost",onClick:()=>Sn(),disabled:me,children:me?"Adding...":`Add Reference (${Tt?.references.length||0}/${Tt?.max_references||5})`}),s.jsx(Te,{onClick:()=>cn(),children:"Close"})]})})]})}),H&&Ye&&s.jsx(Zn,{title:x("printers.confirm.powerOnTitle"),message:x("printers.confirm.powerOnMessage",{name:t.name}),confirmText:x("printers.confirm.powerOnButton"),variant:"default",onConfirm:()=>{Xn.mutate("on"),K(!1)},onCancel:()=>K(!1)}),V&&Ye&&s.jsx(Zn,{title:x("printers.confirm.powerOffTitle"),message:re?.state==="RUNNING"?x("printers.confirm.powerOffWarning",{name:t.name}):x("printers.confirm.powerOffMessage",{name:t.name}),confirmText:x("printers.confirm.powerOffButton"),variant:"danger",onConfirm:()=>{Xn.mutate("off"),Q(!1)},onCancel:()=>Q(!1)}),B&&s.jsx(Zn,{title:x("printers.confirm.stopTitle"),message:x("printers.confirm.stopMessage",{name:t.name}),confirmText:x("printers.confirm.stopButton"),variant:"danger",onConfirm:()=>{Ba.mutate(),X(!1)},onCancel:()=>X(!1)}),ne&&s.jsx(Zn,{title:x("printers.confirm.pauseTitle"),message:x("printers.confirm.pauseMessage",{name:t.name}),confirmText:x("printers.confirm.pauseButton"),variant:"default",onConfirm:()=>{Ae.mutate(),se(!1)},onCancel:()=>se(!1)}),be&&s.jsx(Zn,{title:x("printers.confirm.resumeTitle"),message:x("printers.confirm.resumeMessage",{name:t.name}),confirmText:x("printers.confirm.resumeButton"),variant:"default",onConfirm:()=>{Ze.mutate(),xe(!1)},onCancel:()=>xe(!1)}),de&&s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",onClick:()=>Pe(!1),onKeyDown:et=>et.key==="Escape"&&Pe(!1),tabIndex:-1,ref:et=>et?.focus(),children:[s.jsx("div",{className:"absolute inset-0 bg-black/50 z-0"}),s.jsxs("div",{className:"relative z-10 bg-white dark:bg-bambu-dark border border-gray-200 dark:border-bambu-dark-tertiary rounded-xl shadow-2xl w-[560px] max-h-[85vh] flex flex-col overflow-hidden",onClick:et=>et.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-gray-200 dark:border-bambu-dark-tertiary bg-gray-50 dark:bg-bambu-dark",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(x$,{className:"w-4 h-4 text-bambu-green"}),s.jsx("span",{className:"text-sm font-medium text-gray-900 dark:text-white",children:x("printers.skipObjects.title")})]}),s.jsx("button",{onClick:()=>Pe(!1),className:"p-1 text-gray-500 dark:text-bambu-gray hover:text-gray-900 dark:hover:text-white rounded transition-colors",children:s.jsx(Rt,{className:"w-4 h-4"})})]}),Et?Et.objects.length===0?s.jsxs("div",{className:"text-center py-8 px-4 text-bambu-gray",children:[s.jsx("p",{className:"text-sm",children:x("printers.noObjectsFound")}),s.jsx("p",{className:"text-xs mt-1 opacity-70",children:x("printers.objectsLoadedOnPrintStart")})]}):s.jsxs("div",{className:"flex flex-col overflow-hidden",children:[s.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5 bg-blue-50 dark:bg-blue-500/10 border-b border-gray-200 dark:border-bambu-dark-tertiary",children:[s.jsx("div",{className:"flex-shrink-0 w-8 h-8 rounded-lg bg-blue-100 dark:bg-blue-500/20 flex items-center justify-center",children:s.jsx(Hde,{className:"w-4 h-4 text-blue-500 dark:text-blue-400"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-xs text-blue-600 dark:text-blue-300",children:x("printers.skipObjects.matchIdsInfo")}),s.jsx("p",{className:"text-[10px] text-blue-500/70 dark:text-blue-300/60",children:x("printers.skipObjects.printerShowsIds")})]}),s.jsxs("div",{className:"flex-shrink-0 text-xs text-gray-500 dark:text-bambu-gray",children:[Et.skipped_count,"/",Et.total," ",x("printers.skipObjects.skipped")]})]}),(re?.layer_num??0)<=1&&s.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-amber-50 dark:bg-amber-500/10 border-b border-gray-200 dark:border-bambu-dark-tertiary",children:[s.jsx(Hi,{className:"w-4 h-4 text-amber-500 dark:text-amber-400 flex-shrink-0"}),s.jsx("p",{className:"text-xs text-amber-600 dark:text-amber-400",children:x("printers.skipObjects.waitForLayer",{layer:re?.layer_num??0})})]}),s.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[s.jsx("div",{className:"w-52 flex-shrink-0 p-4 border-r border-gray-200 dark:border-bambu-dark-tertiary bg-gray-50 dark:bg-bambu-dark-secondary overflow-y-auto",children:s.jsxs("div",{className:"relative",children:[re?.cover_url?s.jsx("img",{src:`${re.cover_url}?view=top`,alt:x("printers.printPreview"),className:"w-full aspect-square object-contain rounded-lg bg-gray-900 dark:bg-gray-900 border border-gray-300 dark:border-gray-600"}):s.jsx("div",{className:"w-full aspect-square rounded-lg bg-gray-100 dark:bg-bambu-dark flex items-center justify-center",children:s.jsx(lo,{className:"w-8 h-8 text-gray-300 dark:text-bambu-gray/30"})}),Et.objects.length>0&&s.jsx("div",{className:"absolute inset-0 pointer-events-none",children:Et.objects.map((et,jt)=>{let qt,yt;if(et.x!=null&&et.y!=null&&Et.bbox_all){const[wn,Fr,Yr,Br]=Et.bbox_all,Ws=Yr-wn,tn=Br-Fr,on=8,_i=100-on*2;qt=on+(et.x-wn)/Ws*_i,yt=on+(Br-et.y)/tn*_i,qt=Math.max(5,Math.min(95,qt)),yt=Math.max(5,Math.min(95,yt))}else if(et.x!=null&&et.y!=null)qt=et.x/256*100,yt=100-et.y/256*100,qt=Math.max(5,Math.min(95,qt)),yt=Math.max(5,Math.min(95,yt));else{const wn=Math.ceil(Math.sqrt(Et.objects.length)),Fr=Math.floor(jt/wn),Yr=jt%wn,Br=Math.ceil(Et.objects.length/wn);qt=15+Yr*(70/wn)+35/wn,yt=15+Fr*(70/Br)+35/Br}return s.jsx("div",{className:`absolute flex items-center justify-center w-6 h-6 rounded-full text-[10px] font-bold shadow-lg ${et.skipped?"bg-red-500 text-white line-through":"bg-bambu-green text-black"}`,style:{left:`${qt}%`,top:`${yt}%`,transform:"translate(-50%, -50%)"},title:et.name,children:et.id},et.id)})}),s.jsx("div",{className:"absolute bottom-2 right-2 px-2 py-1 bg-white/90 dark:bg-black/80 rounded text-[10px] text-gray-700 dark:text-white shadow-sm",children:x("printers.skipObjects.activeCount",{count:Et.objects.filter(et=>!et.skipped).length})})]})}),s.jsx("div",{className:"flex-1 min-w-0 overflow-y-auto",children:Et.objects.map(et=>s.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
- ${et.skipped?"bg-red-50 dark:bg-red-500/10":"hover:bg-gray-50 dark:hover:bg-bambu-dark/50"}
- `,children:[s.jsxs("div",{className:`
- w-12 h-12 flex-shrink-0 rounded-lg flex flex-col items-center justify-center
- ${et.skipped?"bg-red-100 dark:bg-red-500/20 border border-red-300 dark:border-red-500/40":"bg-green-100 dark:bg-bambu-green/20 border border-green-300 dark:border-bambu-green/40"}
- `,children:[s.jsx("span",{className:`text-lg font-mono font-bold ${et.skipped?"text-red-500 dark:text-red-400":"text-green-600 dark:text-bambu-green"}`,children:et.id}),s.jsx("span",{className:`text-[8px] uppercase tracking-wider ${et.skipped?"text-red-400/60":"text-green-500/60 dark:text-bambu-green/60"}`,children:"ID"})]}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("span",{className:`block text-sm truncate ${et.skipped?"text-red-500 dark:text-red-400 line-through":"text-gray-900 dark:text-white"}`,children:et.name}),et.skipped&&s.jsx("span",{className:"text-[10px] text-red-400/60",children:x("printers.willBeSkipped")})]}),et.skipped?s.jsx("span",{className:"px-4 py-2 text-xs text-red-500 dark:text-red-400/70 bg-red-100 dark:bg-red-500/10 rounded-lg",children:x("printers.skipObjects.skipped")}):s.jsx("button",{onClick:()=>pe.mutate([et.id]),disabled:pe.isPending||(re?.layer_num??0)<=1||!S("printers:control"),className:`px-4 py-2 text-xs font-medium rounded-lg transition-colors ${(re?.layer_num??0)<=1||!S("printers:control")?"bg-gray-100 dark:bg-bambu-dark text-gray-400 dark:text-bambu-gray/50 cursor-not-allowed":"bg-red-100 dark:bg-red-500/20 text-red-600 dark:text-red-400 hover:bg-red-200 dark:hover:bg-red-500/30 border border-red-300 dark:border-red-500/30"}`,title:S("printers:control")?(re?.layer_num??0)<=1?x("printers.skipObjects.waitForLayer",{layer:re?.layer_num??0}):x("printers.skipObjects.skip"):x("printers.permission.noControl"),children:x("printers.skipObjects.skip")})]},et.id))})]})]}):s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx(ht,{className:"w-5 h-5 animate-spin text-bambu-gray"})})]})]}),Z&&s.jsx(Wfe,{printerName:t.name,errors:re?.hms_errors||[],onClose:()=>ae(!1)}),ie&&s.jsx(BCe,{isOpen:!!ie,onClose:()=>Ne(null),printerId:t.id,printerName:t.name,amsId:ie.amsId,amsLabel:ie.amsLabel,initialMode:ie.mode,thresholds:a}),Oe&&s.jsx(HCe,{isOpen:!!Oe,onClose:()=>ge(null),trayUuid:Oe.trayUuid,trayInfo:Oe.trayInfo}),Ke&&s.jsx(XCe,{isOpen:!!Ke,onClose:()=>G(null),printerId:t.id,slotInfo:Ke,onSuccess:()=>{b.invalidateQueries({queryKey:["slotPresets",t.id]}),b.invalidateQueries({queryKey:["printerStatus",t.id]})}}),A&&s.jsx(dje,{printer:t,onClose:()=>R(!1)}),Y&&Fe&&s.jsx(uje,{printer:t,firmwareInfo:Fe,onClose:()=>ce(!1)}),nr&&s.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>jn(null)})]})}function cje({onClose:t,onAdd:e,existingSerials:n}){const{t:r}=Hn(),[i,a]=_.useState({name:"",serial_number:"",ip_address:"",access_code:"",model:"",location:"",auto_archive:!0}),[o,l]=_.useState(!1),[c,u]=_.useState([]),[d,f]=_.useState(""),[p,m]=_.useState(!1),[x,b]=_.useState(!1),[y,v]=_.useState("192.168.1.0/24"),[S,N]=_.useState({scanned:0,total:0});_.useEffect(()=>{Xl.getInfo().then(D=>{b(D.is_docker)}).catch(()=>{})},[]);const T=c.filter(D=>!n.includes(D.serial)),k=async()=>{f(""),u([]),l(!0),m(!1),N({scanned:0,total:0});try{if(x){await Xl.startSubnetScan(y);const D=setInterval(async()=>{try{const A=await Xl.getScanStatus();N({scanned:A.scanned,total:A.total});const R=await Xl.getDiscoveredPrinters();u(R),A.running||(clearInterval(D),l(!1),m(!0))}catch(A){console.error("Failed to get scan status:",A)}},500)}else{await Xl.startDiscovery(10);const D=setInterval(async()=>{try{const A=await Xl.getDiscoveredPrinters();u(A)}catch(A){console.error("Failed to get discovered printers:",A)}},1e3);setTimeout(async()=>{clearInterval(D);try{await Xl.stopDiscovery()}catch{}l(!1),m(!0);try{const A=await Xl.getDiscoveredPrinters();u(A)}catch(A){console.error("Failed to get final discovered printers:",A)}},1e4)}}catch(D){console.error("Failed to start discovery:",D),f(D instanceof Error?D.message:r("printers.discovery.failedToStart")),l(!1),m(!0)}},C=D=>D?{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"}[D]||D:"",E=D=>{const A=D.serial.startsWith("unknown-")?"":D.serial;a({...i,name:D.name||"",serial_number:A,ip_address:D.ip_address,model:C(D.model)}),u([])};return _.useEffect(()=>()=>{Xl.stopDiscovery().catch(()=>{}),Xl.stopSubnetScan().catch(()=>{})},[]),_.useEffect(()=>{const D=A=>{A.key==="Escape"&&t()};return window.addEventListener("keydown",D),()=>window.removeEventListener("keydown",D)},[t]),s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:t,children:s.jsx(_t,{className:"w-full max-w-md",onClick:D=>D.stopPropagation(),children:s.jsxs(Mt,{children:[s.jsx("h2",{className:"text-xl font-semibold mb-4",children:r("printers.addPrinter")}),s.jsxs("div",{className:"mb-4 pb-4 border-b border-bambu-dark-tertiary",children:[x&&s.jsxs("div",{className:"mb-3",children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("printers.discovery.subnetToScan")}),s.jsx("input",{type:"text",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none text-sm",value:y,onChange:D=>v(D.target.value),placeholder:"192.168.1.0/24",disabled:o}),s.jsx("p",{className:"mt-1 text-xs text-bambu-gray",children:r("printers.discovery.dockerNote")})]}),s.jsx(Te,{type:"button",variant:"secondary",onClick:k,disabled:o,className:"w-full",children:o?s.jsxs(s.Fragment,{children:[s.jsx(ht,{className:"w-4 h-4 animate-spin"}),x&&S.total>0?r("printers.discovery.scanProgress",{scanned:S.scanned,total:S.total}):r("printers.discovery.scanning")]}):s.jsxs(s.Fragment,{children:[s.jsx(ba,{className:"w-4 h-4"}),r(x?"printers.discovery.scanSubnet":"printers.discovery.discoverNetwork")]})}),d&&s.jsx("div",{className:"mt-2 text-sm text-red-400",children:d}),T.length>0&&s.jsx("div",{className:"mt-3 space-y-2 max-h-40 overflow-y-auto",children:T.map(D=>s.jsxs("div",{className:"flex items-center justify-between p-2 bg-bambu-dark rounded-lg hover:bg-bambu-dark-secondary cursor-pointer transition-colors",onClick:()=>E(D),children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"font-medium text-white text-sm truncate",children:D.name||D.serial}),s.jsxs("p",{className:"text-xs text-bambu-gray truncate",children:[C(D.model)||r("printers.discovery.unknown")," • ",D.ip_address,D.serial.startsWith("unknown-")&&s.jsxs("span",{className:"text-yellow-500",children:[" • ",r("printers.discovery.serialRequired")]})]})]}),s.jsx(ei,{className:"w-4 h-4 text-bambu-gray -rotate-90 flex-shrink-0 ml-2"})]},D.serial))}),o&&s.jsx("p",{className:"mt-2 text-sm text-bambu-gray text-center",children:r(x?"printers.discovery.scanningSubnet":"printers.discovery.scanningNetwork")}),p&&!o&&c.length===0&&s.jsx("p",{className:"mt-2 text-sm text-bambu-gray text-center",children:r(x?"printers.discovery.noPrintersFoundSubnet":"printers.discovery.noPrintersFoundNetwork")}),p&&!o&&c.length>0&&T.length===0&&s.jsx("p",{className:"mt-2 text-sm text-bambu-gray text-center",children:r("printers.discovery.allConfigured")})]}),s.jsxs("form",{onSubmit:D=>{D.preventDefault(),e(i)},className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("printers.name")}),s.jsx("input",{type:"text",required:!0,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:i.name,onChange:D=>a({...i,name:D.target.value}),placeholder:r("printers.modal.myPrinter")})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("printers.ipAddress")}),s.jsx("input",{type:"text",required:!0,pattern:"\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:i.ip_address,onChange:D=>a({...i,ip_address:D.target.value}),placeholder:"192.168.1.100"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("printers.serialNumber")}),s.jsx("input",{type:"text",required:!0,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:i.serial_number,onChange:D=>a({...i,serial_number:D.target.value}),placeholder:"01P00A000000000"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("printers.accessCode")}),s.jsx("input",{type:"password",required:!0,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:i.access_code,onChange:D=>a({...i,access_code:D.target.value}),placeholder:r("printers.modal.fromPrinterSettings")})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("printers.modal.modelOptional")}),s.jsxs("select",{className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:i.model||"",onChange:D=>a({...i,model:D.target.value}),children:[s.jsx("option",{value:"",children:r("printers.modal.selectModel")}),s.jsxs("optgroup",{label:"H2 Series",children:[s.jsx("option",{value:"H2C",children:"H2C"}),s.jsx("option",{value:"H2D",children:"H2D"}),s.jsx("option",{value:"H2D Pro",children:"H2D Pro"}),s.jsx("option",{value:"H2S",children:"H2S"})]}),s.jsxs("optgroup",{label:"X1 Series",children:[s.jsx("option",{value:"X1E",children:"X1E"}),s.jsx("option",{value:"X1C",children:"X1 Carbon"}),s.jsx("option",{value:"X1",children:"X1"})]}),s.jsxs("optgroup",{label:"P Series",children:[s.jsx("option",{value:"P2S",children:"P2S"}),s.jsx("option",{value:"P1S",children:"P1S"}),s.jsx("option",{value:"P1P",children:"P1P"})]}),s.jsxs("optgroup",{label:"A1 Series",children:[s.jsx("option",{value:"A1",children:"A1"}),s.jsx("option",{value:"A1 Mini",children:"A1 Mini"})]})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("printers.modal.locationGroup")}),s.jsx("input",{type:"text",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:i.location||"",onChange:D=>a({...i,location:D.target.value}),placeholder:r("printers.modal.locationPlaceholder")}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:r("printers.locationHelp")})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",id:"auto_archive",checked:i.auto_archive,onChange:D=>a({...i,auto_archive:D.target.checked}),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),s.jsx("label",{htmlFor:"auto_archive",className:"text-sm text-bambu-gray",children:r("printers.modal.autoArchiveLabel")})]}),s.jsxs("div",{className:"flex gap-3 pt-4",children:[s.jsx(Te,{type:"button",variant:"secondary",onClick:t,className:"flex-1",children:r("common.cancel")}),s.jsx(Te,{type:"submit",className:"flex-1",children:r("printers.addPrinter")})]})]})]})})})}function uje({printer:t,firmwareInfo:e,onClose:n}){const{t:r}=Hn(),i=an(),{showToast:a}=$n(),[o,l]=_.useState(null),[c,u]=_.useState(!1),[d,f]=_.useState(null),{data:p,isLoading:m}=at({queryKey:["firmwarePrepare",t.id],queryFn:()=>g1.prepareUpload(t.id),staleTime:3e4}),x=mt({mutationFn:()=>g1.startUpload(t.id),onSuccess:()=>{u(!0);const y=setInterval(async()=>{try{const v=await g1.getUploadStatus(t.id);l(v),(v.status==="complete"||v.status==="error")&&(clearInterval(y),f(null),u(!1),v.status==="complete"&&(a(r("printers.firmwareModal.uploadedToast"),"success"),i.invalidateQueries({queryKey:["firmwareUpdate",t.id]})))}catch{}},2e3);f(y)},onError:y=>{a(`Failed to start upload: ${y.message}`,"error"),u(!1)}});_.useEffect(()=>()=>{d&&clearInterval(d)},[d]);const b=()=>{l(null),x.mutate()};return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:s.jsx(_t,{className:"w-full max-w-md mx-4",children:s.jsxs(Mt,{children:[s.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[s.jsx("div",{className:"p-2 rounded-full bg-orange-500/20",children:s.jsx(yi,{className:"w-5 h-5 text-orange-400"})}),s.jsxs("div",{className:"flex-1",children:[s.jsx("h3",{className:"text-lg font-semibold text-white",children:r("printers.firmwareModal.title")}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:t.name})]})]}),s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3 mb-4",children:[s.jsxs("div",{className:"flex justify-between items-center text-sm",children:[s.jsx("span",{className:"text-bambu-gray",children:r("printers.firmwareModal.currentVersion")}),s.jsx("span",{className:"text-white font-mono",children:e.current_version||r("common.unknown")})]}),s.jsxs("div",{className:"flex justify-between items-center text-sm mt-1",children:[s.jsx("span",{className:"text-bambu-gray",children:r("printers.firmwareModal.latestVersion")}),s.jsx("span",{className:"text-orange-400 font-mono",children:e.latest_version})]}),e.release_notes&&s.jsxs("details",{className:"mt-3 text-sm",children:[s.jsx("summary",{className:"text-orange-400 cursor-pointer hover:underline",children:r("printers.firmwareModal.releaseNotes")}),s.jsx("div",{className:"mt-2 text-bambu-gray text-xs max-h-40 overflow-y-auto whitespace-pre-wrap",children:e.release_notes})]})]}),m?s.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-sm mb-4",children:[s.jsx(ht,{className:"w-4 h-4 animate-spin"}),r("printers.firmwareModal.checkingPrereqs")]}):p&&!c&&!o?s.jsx("div",{className:"mb-4",children:p.can_proceed?s.jsxs("div",{className:"flex items-center gap-2 text-bambu-green text-sm",children:[s.jsx(lo,{className:"w-4 h-4"}),r("printers.firmwareModal.sdCardReady")]}):s.jsx("div",{className:"space-y-1",children:p.errors.map((y,v)=>s.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[s.jsx(Hi,{className:"w-4 h-4 flex-shrink-0"}),y]},v))})}):null,(c||o)&&o&&s.jsxs("div",{className:"mb-4",children:[s.jsxs("div",{className:"flex items-center justify-between text-sm mb-1",children:[s.jsx("span",{className:"text-bambu-gray capitalize",children:o.status}),s.jsxs("span",{className:"text-white",children:[o.progress,"%"]})]}),s.jsx("div",{className:"w-full bg-bambu-dark-tertiary rounded-full h-2",children:s.jsx("div",{className:`h-2 rounded-full transition-all ${o.status==="error"?"bg-status-error":o.status==="complete"?"bg-status-ok":"bg-orange-500"} ${o.status==="uploading"?"animate-pulse":""}`,style:{width:`${o.progress}%`}})}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:o.message}),o.error&&s.jsx("p",{className:"text-xs text-red-400 mt-1",children:o.error})]}),o?.status==="complete"&&s.jsxs("div",{className:"bg-bambu-green/10 border border-bambu-green/30 rounded-lg p-3 mb-4",children:[s.jsx("p",{className:"text-sm text-bambu-green font-medium mb-2",children:r("printers.firmwareModal.uploadedSuccess")}),s.jsx("p",{className:"text-xs text-bambu-gray",children:r("printers.firmwareModal.applyInstructions")}),s.jsxs("ol",{className:"text-xs text-bambu-gray mt-1 list-decimal list-inside space-y-1",children:[s.jsx("li",{dangerouslySetInnerHTML:{__html:r("printers.firmwareModal.step1")}}),s.jsx("li",{dangerouslySetInnerHTML:{__html:r("printers.firmwareModal.step2")}}),s.jsx("li",{dangerouslySetInnerHTML:{__html:r("printers.firmwareModal.step3")}}),s.jsx("li",{children:r("printers.firmwareModal.step4")})]})]}),s.jsxs("div",{className:"flex gap-2 justify-end",children:[s.jsx(Te,{variant:"secondary",onClick:n,children:o?.status==="complete"?r("printers.firmwareModal.done"):r("common.cancel")}),p?.can_proceed&&!c&&o?.status!=="complete"&&s.jsx(Te,{onClick:b,disabled:x.isPending,children:x.isPending?s.jsxs(s.Fragment,{children:[s.jsx(ht,{className:"w-4 h-4 animate-spin mr-2"}),r("printers.firmwareModal.starting")]}):s.jsxs(s.Fragment,{children:[s.jsx(yi,{className:"w-4 h-4 mr-2"}),r("printers.firmwareModal.uploadFirmware")]})})]})]})})})}function dje({printer:t,onClose:e}){const{t:n}=Hn(),r=an(),{showToast:i}=$n(),[a,o]=_.useState({name:t.name,ip_address:t.ip_address,access_code:"",model:t.model||"",location:t.location||"",auto_archive:t.auto_archive}),l=mt({mutationFn:u=>ue.updatePrinter(t.id,u),onSuccess:()=>{r.invalidateQueries({queryKey:["printers"]}),r.invalidateQueries({queryKey:["printerStatus",t.id]}),e()},onError:u=>i(u.message||n("printers.toast.failedToUpdate"),"error")});_.useEffect(()=>{const u=d=>{d.key==="Escape"&&e()};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[e]);const c=u=>{u.preventDefault();const d={name:a.name,ip_address:a.ip_address,model:a.model||void 0,location:a.location||void 0,auto_archive:a.auto_archive};a.access_code&&(d.access_code=a.access_code),l.mutate(d)};return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:e,children:s.jsx(_t,{className:"w-full max-w-md",onClick:u=>u.stopPropagation(),children:s.jsxs(Mt,{children:[s.jsx("h2",{className:"text-xl font-semibold mb-4",children:n("printers.editPrinter")}),s.jsxs("form",{onSubmit:c,className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("printers.name")}),s.jsx("input",{type:"text",required:!0,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:a.name,onChange:u=>o({...a,name:u.target.value}),placeholder:n("printers.modal.myPrinter")})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("printers.ipAddress")}),s.jsx("input",{type:"text",required:!0,pattern:"\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:a.ip_address,onChange:u=>o({...a,ip_address:u.target.value}),placeholder:"192.168.1.100"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("printers.serialNumber")}),s.jsx("input",{type:"text",disabled:!0,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray cursor-not-allowed",value:t.serial_number}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:n("printers.serialCannotBeChanged")})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("printers.accessCode")}),s.jsx("input",{type:"password",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:a.access_code,onChange:u=>o({...a,access_code:u.target.value}),placeholder:n("printers.accessCodePlaceholder")})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("printers.model")}),s.jsxs("select",{className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:a.model,onChange:u=>o({...a,model:u.target.value}),children:[s.jsx("option",{value:"",children:n("printers.modal.selectModel")}),s.jsxs("optgroup",{label:"H2 Series",children:[s.jsx("option",{value:"H2C",children:"H2C"}),s.jsx("option",{value:"H2D",children:"H2D"}),s.jsx("option",{value:"H2D Pro",children:"H2D Pro"}),s.jsx("option",{value:"H2S",children:"H2S"})]}),s.jsxs("optgroup",{label:"X1 Series",children:[s.jsx("option",{value:"X1E",children:"X1E"}),s.jsx("option",{value:"X1C",children:"X1 Carbon"}),s.jsx("option",{value:"X1",children:"X1"})]}),s.jsxs("optgroup",{label:"P Series",children:[s.jsx("option",{value:"P2S",children:"P2S"}),s.jsx("option",{value:"P1S",children:"P1S"}),s.jsx("option",{value:"P1P",children:"P1P"})]}),s.jsxs("optgroup",{label:"A1 Series",children:[s.jsx("option",{value:"A1",children:"A1"}),s.jsx("option",{value:"A1 Mini",children:"A1 Mini"})]})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Location / Group"}),s.jsx("input",{type:"text",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:a.location,onChange:u=>o({...a,location:u.target.value}),placeholder:n("printers.modal.locationPlaceholder")}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:n("printers.locationHelp")})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",id:"edit_auto_archive",checked:a.auto_archive,onChange:u=>o({...a,auto_archive:u.target.checked}),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),s.jsx("label",{htmlFor:"edit_auto_archive",className:"text-sm text-bambu-gray",children:n("printers.modal.autoArchiveLabel")})]}),s.jsxs("div",{className:"flex gap-3 pt-4",children:[s.jsx(Te,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:n("common.cancel")}),s.jsx(Te,{type:"submit",className:"flex-1",disabled:l.isPending,children:l.isPending?n("common.saving"):n("printers.modal.saveChanges")})]})]})]})})})}function hje(t){const{data:e}=at({queryKey:["printerStatus",t],queryFn:()=>ue.getPrinterStatus(t),refetchInterval:3e4});return!e?.connected}function fje({printer:t,plug:e,onPowerOn:n,isPowering:r}){const i=hje(t.id),{data:a}=at({queryKey:["smartPlugStatus",e.id],queryFn:()=>ue.getSmartPlugStatus(e.id),refetchInterval:1e4});return i?s.jsxs("div",{className:"flex items-center justify-between px-3 py-2 hover:bg-gray-100 dark:hover:bg-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx("span",{className:"text-sm text-gray-900 dark:text-white truncate",children:t.name}),a&&s.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded ${a.state==="ON"?"bg-bambu-green/20 text-bambu-green":"bg-red-500/20 text-red-400"}`,children:a.state||"?"})]}),s.jsxs("button",{onClick:()=>n(e.id),disabled:r||a?.state==="ON",className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${a?.state==="ON"?"bg-bambu-green/20 text-bambu-green cursor-default":"bg-bambu-green/20 text-bambu-green hover:bg-bambu-green hover:text-white"}`,children:[s.jsx(Gu,{className:"w-3 h-3"}),r?"...":"On"]})]}):null}function mje(){const{t}=Hn(),[e,n]=_.useState(!1),[r,i]=_.useState(()=>localStorage.getItem("hideDisconnectedPrinters")==="true"),[a,o]=_.useState(!1),[l,c]=_.useState(null),[u,d]=_.useState(()=>localStorage.getItem("printerSortBy")||"name"),[f,p]=_.useState(()=>localStorage.getItem("printerSortAsc")!=="false"),[m,x]=_.useState(()=>{const de=localStorage.getItem("printerCardSize");return de?parseInt(de,10):2}),b=m===1?"compact":"expanded",y=an(),{showToast:v}=$n(),{hasPermission:S}=Ai(),[N,T]=_.useState(()=>{const de=localStorage.getItem("openEmbeddedCameras");if(de)try{const Pe=JSON.parse(de);return new Map(Pe.map(ie=>[ie.id,ie]))}catch{return new Map}return new Map});_.useEffect(()=>{const de=Array.from(N.values());de.length>0?localStorage.setItem("openEmbeddedCameras",JSON.stringify(de)):localStorage.removeItem("openEmbeddedCameras")},[N]);const{data:k,isLoading:C}=at({queryKey:["printers"],queryFn:ue.getPrinters}),{data:E}=at({queryKey:["settings"],queryFn:ue.getSettings});_.useEffect(()=>{E?.camera_view_mode==="window"&&N.size>0&&T(new Map)},[E?.camera_view_mode,N.size]);const{data:D}=at({queryKey:["smart-plugs"],queryFn:ue.getSmartPlugs}),{data:A}=at({queryKey:["maintenanceOverview"],queryFn:ue.getMaintenanceOverview,staleTime:60*1e3}),{data:R}=at({queryKey:["spoolman-status"],queryFn:ue.getSpoolmanStatus,staleTime:60*1e3}),U=R?.enabled&&R?.connected,{data:F}=at({queryKey:["unlinked-spools"],queryFn:ue.getUnlinkedSpools,enabled:!!U,staleTime:30*1e3}),$=F&&F.length>0,{data:j}=at({queryKey:["linked-spools"],queryFn:ue.getLinkedSpools,enabled:!!U,staleTime:30*1e3}),H=j?.linked,K=A?.reduce((de,Pe)=>(de[Pe.printer_id]={due_count:Pe.due_count,warning_count:Pe.warning_count,total_print_hours:Pe.total_print_hours},de),{})||{},V=D?.reduce((de,Pe)=>(Pe.printer_id&&(de[Pe.printer_id]=Pe),de),{})||{},Q=mt({mutationFn:ue.createPrinter,onSuccess:()=>{y.invalidateQueries({queryKey:["printers"]}),y.invalidateQueries({queryKey:["maintenanceOverview"]}),n(!1)},onError:de=>v(de.message||t("printers.toast.failedToAdd"),"error")}),Z=mt({mutationFn:de=>ue.controlSmartPlug(de,"on"),onSuccess:()=>{y.invalidateQueries({queryKey:["smart-plugs"]}),c(null)},onError:()=>{c(null)}}),ae=()=>{const de=!r;i(de),localStorage.setItem("hideDisconnectedPrinters",String(de))},B=de=>{d(de),localStorage.setItem("printerSortBy",de)},X=()=>{const de=!f;p(de),localStorage.setItem("printerSortAsc",String(de))},ne=()=>{switch(m){case 1:return"grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5";case 2:return"grid-cols-1 md:grid-cols-2 xl:grid-cols-3";case 3:return"grid-cols-1 lg:grid-cols-2";case 4:return"grid-cols-1";default:return"grid-cols-1 md:grid-cols-2 xl:grid-cols-3"}},se=["S","M","L","XL"],be=_.useMemo(()=>{if(!k)return[];const de=[...k];switch(u){case"name":de.sort((Pe,ie)=>Pe.name.localeCompare(ie.name));break;case"model":de.sort((Pe,ie)=>(Pe.model||"").localeCompare(ie.model||""));break;case"location":de.sort((Pe,ie)=>{const Ne=Pe.location||"",Oe=ie.location||"";return!Ne&&Oe?1:Ne&&!Oe?-1:Ne.localeCompare(Oe)||Pe.name.localeCompare(ie.name)});break;case"status":de.sort((Pe,ie)=>{const Ne=y.getQueryData(["printerStatus",Pe.id]),Oe=y.getQueryData(["printerStatus",ie.id]),ge=Ke=>Ke?.connected?Ke.state==="RUNNING"?0:1:2;return ge(Ne)-ge(Oe)});break}return f||de.reverse(),de},[k,u,f,y]),xe=_.useMemo(()=>{if(u!=="location")return null;const de={};return be.forEach(Pe=>{const ie=Pe.location||"Ungrouped";de[ie]||(de[ie]=[]),de[ie].push(Pe)}),de},[u,be]);return s.jsxs("div",{className:"p-4 md:p-8",children:[s.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4 mb-6",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold text-white",children:t("printers.title")}),s.jsx(lje,{printers:k})]}),s.jsxs("div",{className:"flex items-center gap-2 sm:gap-3 flex-wrap",children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsxs("select",{value:u,onChange:de=>B(de.target.value),className:"text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg px-2 py-1.5 text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"name",children:t("printers.sort.name")}),s.jsx("option",{value:"status",children:t("printers.sort.status")}),s.jsx("option",{value:"model",children:t("printers.sort.model")}),s.jsx("option",{value:"location",children:t("printers.sort.location")})]}),s.jsx("button",{onClick:X,className:"p-1.5 rounded-lg hover:bg-bambu-dark-tertiary transition-colors",title:t(f?"printers.sort.descending":"printers.sort.ascending"),children:f?s.jsx(Ig,{className:"w-4 h-4 text-bambu-gray"}):s.jsx(G0,{className:"w-4 h-4 text-bambu-gray"})})]}),s.jsx("div",{className:"flex items-center bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:se.map((de,Pe)=>{const ie=Pe+1,Ne=m===ie;return s.jsx("button",{onClick:()=>{x(ie),localStorage.setItem("printerCardSize",String(ie))},className:`px-2 py-1.5 text-xs font-medium transition-colors ${Pe===0?"rounded-l-lg":""} ${Pe===se.length-1?"rounded-r-lg":""} ${Ne?"bg-bambu-green text-white":"text-bambu-gray hover:bg-bambu-dark-tertiary hover:text-white"}`,title:t(de==="S"?"printers.cardSize.small":de==="M"?"printers.cardSize.medium":de==="L"?"printers.cardSize.large":"printers.cardSize.extraLarge"),children:de},de)})}),s.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),s.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:r,onChange:ae,className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),t("printers.hideOffline")]}),r&&Object.keys(V).length>0&&s.jsxs("div",{className:"relative",children:[s.jsxs("button",{onClick:()=>o(!a),className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-white dark:bg-bambu-dark-secondary border border-gray-200 dark:border-bambu-dark-tertiary rounded-lg text-gray-600 dark:text-bambu-gray hover:text-gray-900 dark:hover:text-white hover:border-bambu-green transition-colors",children:[s.jsx(Gu,{className:"w-4 h-4"}),t("printers.powerOn"),s.jsx(ei,{className:`w-3 h-3 transition-transform ${a?"rotate-180":""}`})]}),a&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>o(!1)}),s.jsxs("div",{className:"absolute right-0 mt-2 w-56 bg-white dark:bg-bambu-dark-secondary border border-gray-200 dark:border-bambu-dark-tertiary rounded-lg shadow-lg z-20 py-1",children:[s.jsx("div",{className:"px-3 py-2 text-xs text-gray-500 dark:text-bambu-gray border-b border-gray-200 dark:border-bambu-dark-tertiary",children:t("printers.offlinePrintersWithPlugs")}),k?.filter(de=>V[de.id]).map(de=>s.jsx(fje,{printer:de,plug:V[de.id],onPowerOn:Pe=>{c(Pe),Z.mutate(Pe)},isPowering:l===V[de.id]?.id},de.id)),k?.filter(de=>V[de.id]).length===0&&s.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No printers with smart plugs"})]})]})]}),s.jsxs(Te,{onClick:()=>n(!0),disabled:!S("printers:create"),title:S("printers:create")?void 0:t("printers.permission.noAdd"),children:[s.jsx(dr,{className:"w-4 h-4"}),t("printers.addPrinter")]})]})]}),C?s.jsx("div",{className:"text-center py-12 text-bambu-gray",children:t("common.loading")}):k?.length===0?s.jsx(_t,{children:s.jsxs(Mt,{className:"text-center py-12",children:[s.jsx("p",{className:"text-bambu-gray mb-4",children:t("printers.noPrintersConfigured")}),s.jsxs(Te,{onClick:()=>n(!0),disabled:!S("printers:create"),title:S("printers:create")?void 0:t("printers.permission.noAdd"),children:[s.jsx(dr,{className:"w-4 h-4"}),t("printers.addPrinter")]})]})}):xe?s.jsx("div",{className:"space-y-6",children:Object.entries(xe).map(([de,Pe])=>s.jsxs("div",{children:[s.jsxs("h2",{className:"text-lg font-semibold text-white mb-3 flex items-center gap-2",children:[s.jsx("span",{className:"w-2 h-2 rounded-full bg-bambu-green"}),de,s.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",Pe.length,")"]})]}),s.jsx("div",{className:`grid gap-4 ${m>=3?"gap-6":""} ${ne()}`,children:Pe.map(ie=>s.jsx(N$,{printer:ie,hideIfDisconnected:r,maintenanceInfo:K[ie.id],viewMode:b,cardSize:m,amsThresholds:E?{humidityGood:Number(E.ams_humidity_good)||40,humidityFair:Number(E.ams_humidity_fair)||60,tempGood:Number(E.ams_temp_good)||28,tempFair:Number(E.ams_temp_fair)||35}:void 0,spoolmanEnabled:U,hasUnlinkedSpools:$,linkedSpools:H,spoolmanUrl:R?.url,timeFormat:E?.time_format||"system",cameraViewMode:E?.camera_view_mode||"window",onOpenEmbeddedCamera:(Ne,Oe)=>T(ge=>new Map(ge).set(Ne,{id:Ne,name:Oe})),checkPrinterFirmware:E?.check_printer_firmware!==!1},ie.id))})]},de))}):s.jsx("div",{className:`grid gap-4 ${m>=3?"gap-6":""} ${ne()}`,children:be.map(de=>s.jsx(N$,{printer:de,hideIfDisconnected:r,maintenanceInfo:K[de.id],viewMode:b,cardSize:m,spoolmanEnabled:U,hasUnlinkedSpools:$,linkedSpools:H,spoolmanUrl:R?.url,amsThresholds:E?{humidityGood:Number(E.ams_humidity_good)||40,humidityFair:Number(E.ams_humidity_fair)||60,tempGood:Number(E.ams_temp_good)||28,tempFair:Number(E.ams_temp_fair)||35}:void 0,timeFormat:E?.time_format||"system",cameraViewMode:E?.camera_view_mode||"window",onOpenEmbeddedCamera:(Pe,ie)=>T(Ne=>new Map(Ne).set(Pe,{id:Pe,name:ie})),checkPrinterFirmware:E?.check_printer_firmware!==!1},de.id))}),e&&s.jsx(cje,{onClose:()=>n(!1),onAdd:de=>Q.mutate(de),existingSerials:k?.map(de=>de.serial_number)||[]}),Array.from(N.values()).map((de,Pe)=>s.jsx(Hfe,{printerId:de.id,printerName:de.name,viewerIndex:Pe,onClose:()=>T(ie=>{const Ne=new Map(ie);return Ne.delete(de.id),Ne})},de.id))]})}function pje(){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 gje(){switch(pje()){case"windows":return"bambustudio://";case"macos":case"linux":default:return"bambustudioopen://"}}function mu(t){const e=gje();window.location.href=`${e}${encodeURIComponent(t)}`}const B4="181",Tg={ROTATE:0,DOLLY:1,PAN:2},bg={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},xje=0,k$=1,bje=2,XZ=1,yje=2,ou=3,kh=0,Us=1,ic=2,Tu=0,Ag=1,E$=2,T$=3,A$=4,vje=5,Mf=100,wje=101,_je=102,Sje=103,Mje=104,Nje=200,kje=201,Eje=202,Tje=203,S3=204,M3=205,Aje=206,Cje=207,jje=208,Pje=209,Dje=210,Rje=211,Oje=212,Lje=213,Fje=214,N3=0,k3=1,E3=2,Qg=3,T3=4,A3=5,C3=6,j3=7,H4=0,Ije=1,Uje=2,lh=0,zje=1,Bje=2,Hje=3,$je=4,Vje=5,Gje=6,qje=7,YZ=300,Zg=301,Jg=302,P3=303,D3=304,f2=306,R3=1e3,vu=1001,O3=1002,po=1003,Wje=1004,Zw=1005,el=1006,GA=1007,Of=1008,yc=1009,QZ=1010,ZZ=1011,dy=1012,$4=1013,pm=1014,wu=1015,Cx=1016,V4=1017,G4=1018,hy=1020,JZ=35902,eJ=35899,tJ=1021,nJ=1022,Pl=1023,fy=1026,my=1027,rJ=1028,q4=1029,W4=1030,K4=1031,X4=1033,M1=33776,N1=33777,k1=33778,E1=33779,L3=35840,F3=35841,I3=35842,U3=35843,z3=36196,B3=37492,H3=37496,$3=37808,V3=37809,G3=37810,q3=37811,W3=37812,K3=37813,X3=37814,Y3=37815,Q3=37816,Z3=37817,J3=37818,eD=37819,tD=37820,nD=37821,rD=36492,iD=36494,aD=36495,sD=36283,oD=36284,lD=36285,cD=36286,Kje=3200,Xje=3201,iJ=0,Yje=1,Kd="",Vo="srgb",ex="srgb-linear",WS="linear",Nr="srgb",vp=7680,C$=519,Qje=512,Zje=513,Jje=514,aJ=515,ePe=516,tPe=517,nPe=518,rPe=519,j$=35044,P$="300 es",lc=2e3,KS=2001;function sJ(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function XS(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function iPe(){const t=XS("canvas");return t.style.display="block",t}const D$={};function R$(...t){const e="THREE."+t.shift();console.log(e,...t)}function gn(...t){const e="THREE."+t.shift();console.warn(e,...t)}function Ei(...t){const e="THREE."+t.shift();console.error(e,...t)}function py(...t){const e=t.join(" ");e in D$||(D$[e]=!0,gn(...t))}function aPe(t,e,n){return new Promise(function(r,i){function a(){switch(t.clientWaitSync(e,t.SYNC_FLUSH_COMMANDS_BIT,0)){case t.WAIT_FAILED:i();break;case t.TIMEOUT_EXPIRED:setTimeout(a,n);break;default:r()}}setTimeout(a,n)})}let Cm=class{addEventListener(e,n){this._listeners===void 0&&(this._listeners={});const r=this._listeners;r[e]===void 0&&(r[e]=[]),r[e].indexOf(n)===-1&&r[e].push(n)}hasEventListener(e,n){const r=this._listeners;return r===void 0?!1:r[e]!==void 0&&r[e].indexOf(n)!==-1}removeEventListener(e,n){const r=this._listeners;if(r===void 0)return;const i=r[e];if(i!==void 0){const a=i.indexOf(n);a!==-1&&i.splice(a,1)}}dispatchEvent(e){const n=this._listeners;if(n===void 0)return;const r=n[e.type];if(r!==void 0){e.target=this;const i=r.slice(0);for(let a=0,o=i.length;a<o;a++)i[a].call(this,e);e.target=null}}};const $a=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"],T1=Math.PI/180,uD=180/Math.PI;function hv(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return($a[t&255]+$a[t>>8&255]+$a[t>>16&255]+$a[t>>24&255]+"-"+$a[e&255]+$a[e>>8&255]+"-"+$a[e>>16&15|64]+$a[e>>24&255]+"-"+$a[n&63|128]+$a[n>>8&255]+"-"+$a[n>>16&255]+$a[n>>24&255]+$a[r&255]+$a[r>>8&255]+$a[r>>16&255]+$a[r>>24&255]).toLowerCase()}function zn(t,e,n){return Math.max(e,Math.min(n,t))}function sPe(t,e){return(t%e+e)%e}function qA(t,e,n){return(1-n)*t+n*e}function Ub(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return t/4294967295;case Uint16Array:return t/65535;case Uint8Array:return t/255;case Int32Array:return Math.max(t/2147483647,-1);case Int16Array:return Math.max(t/32767,-1);case Int8Array:return Math.max(t/127,-1);default:throw new Error("Invalid component type.")}}function Cs(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return Math.round(t*4294967295);case Uint16Array:return Math.round(t*65535);case Uint8Array:return Math.round(t*255);case Int32Array:return Math.round(t*2147483647);case Int16Array:return Math.round(t*32767);case Int8Array:return Math.round(t*127);default:throw new Error("Invalid component type.")}}const oPe={DEG2RAD:T1};let Tn=class oJ{constructor(e=0,n=0){oJ.prototype.isVector2=!0,this.x=e,this.y=n}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,n){return this.x=e,this.y=n,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const n=this.x,r=this.y,i=e.elements;return this.x=i[0]*n+i[3]*r+i[6],this.y=i[1]*n+i[4]*r+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,n){return this.x=zn(this.x,e.x,n.x),this.y=zn(this.y,e.y,n.y),this}clampScalar(e,n){return this.x=zn(this.x,e,n),this.y=zn(this.y,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(zn(r,e,n))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const n=Math.sqrt(this.lengthSq()*e.lengthSq());if(n===0)return Math.PI/2;const r=this.dot(e)/n;return Math.acos(zn(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,r=this.y-e.y;return n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this}rotateAround(e,n){const r=Math.cos(n),i=Math.sin(n),a=this.x-e.x,o=this.y-e.y;return this.x=a*r-o*i+e.x,this.y=a*i+o*r+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},gm=class{constructor(e=0,n=0,r=0,i=1){this.isQuaternion=!0,this._x=e,this._y=n,this._z=r,this._w=i}static slerpFlat(e,n,r,i,a,o,l){let c=r[i+0],u=r[i+1],d=r[i+2],f=r[i+3],p=a[o+0],m=a[o+1],x=a[o+2],b=a[o+3];if(l<=0){e[n+0]=c,e[n+1]=u,e[n+2]=d,e[n+3]=f;return}if(l>=1){e[n+0]=p,e[n+1]=m,e[n+2]=x,e[n+3]=b;return}if(f!==b||c!==p||u!==m||d!==x){let y=c*p+u*m+d*x+f*b;y<0&&(p=-p,m=-m,x=-x,b=-b,y=-y);let v=1-l;if(y<.9995){const S=Math.acos(y),N=Math.sin(S);v=Math.sin(v*S)/N,l=Math.sin(l*S)/N,c=c*v+p*l,u=u*v+m*l,d=d*v+x*l,f=f*v+b*l}else{c=c*v+p*l,u=u*v+m*l,d=d*v+x*l,f=f*v+b*l;const S=1/Math.sqrt(c*c+u*u+d*d+f*f);c*=S,u*=S,d*=S,f*=S}}e[n]=c,e[n+1]=u,e[n+2]=d,e[n+3]=f}static multiplyQuaternionsFlat(e,n,r,i,a,o){const l=r[i],c=r[i+1],u=r[i+2],d=r[i+3],f=a[o],p=a[o+1],m=a[o+2],x=a[o+3];return e[n]=l*x+d*f+c*m-u*p,e[n+1]=c*x+d*p+u*f-l*m,e[n+2]=u*x+d*m+l*p-c*f,e[n+3]=d*x-l*f-c*p-u*m,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,n,r,i){return this._x=e,this._y=n,this._z=r,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,n=!0){const r=e._x,i=e._y,a=e._z,o=e._order,l=Math.cos,c=Math.sin,u=l(r/2),d=l(i/2),f=l(a/2),p=c(r/2),m=c(i/2),x=c(a/2);switch(o){case"XYZ":this._x=p*d*f+u*m*x,this._y=u*m*f-p*d*x,this._z=u*d*x+p*m*f,this._w=u*d*f-p*m*x;break;case"YXZ":this._x=p*d*f+u*m*x,this._y=u*m*f-p*d*x,this._z=u*d*x-p*m*f,this._w=u*d*f+p*m*x;break;case"ZXY":this._x=p*d*f-u*m*x,this._y=u*m*f+p*d*x,this._z=u*d*x+p*m*f,this._w=u*d*f-p*m*x;break;case"ZYX":this._x=p*d*f-u*m*x,this._y=u*m*f+p*d*x,this._z=u*d*x-p*m*f,this._w=u*d*f+p*m*x;break;case"YZX":this._x=p*d*f+u*m*x,this._y=u*m*f+p*d*x,this._z=u*d*x-p*m*f,this._w=u*d*f-p*m*x;break;case"XZY":this._x=p*d*f-u*m*x,this._y=u*m*f-p*d*x,this._z=u*d*x+p*m*f,this._w=u*d*f+p*m*x;break;default:gn("Quaternion: .setFromEuler() encountered an unknown order: "+o)}return n===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,n){const r=n/2,i=Math.sin(r);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(r),this._onChangeCallback(),this}setFromRotationMatrix(e){const n=e.elements,r=n[0],i=n[4],a=n[8],o=n[1],l=n[5],c=n[9],u=n[2],d=n[6],f=n[10],p=r+l+f;if(p>0){const m=.5/Math.sqrt(p+1);this._w=.25/m,this._x=(d-c)*m,this._y=(a-u)*m,this._z=(o-i)*m}else if(r>l&&r>f){const m=2*Math.sqrt(1+r-l-f);this._w=(d-c)/m,this._x=.25*m,this._y=(i+o)/m,this._z=(a+u)/m}else if(l>f){const m=2*Math.sqrt(1+l-r-f);this._w=(a-u)/m,this._x=(i+o)/m,this._y=.25*m,this._z=(c+d)/m}else{const m=2*Math.sqrt(1+f-r-l);this._w=(o-i)/m,this._x=(a+u)/m,this._y=(c+d)/m,this._z=.25*m}return this._onChangeCallback(),this}setFromUnitVectors(e,n){let r=e.dot(n)+1;return r<1e-8?(r=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=r):(this._x=0,this._y=-e.z,this._z=e.y,this._w=r)):(this._x=e.y*n.z-e.z*n.y,this._y=e.z*n.x-e.x*n.z,this._z=e.x*n.y-e.y*n.x,this._w=r),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(zn(this.dot(e),-1,1)))}rotateTowards(e,n){const r=this.angleTo(e);if(r===0)return this;const i=Math.min(1,n/r);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,n){const r=e._x,i=e._y,a=e._z,o=e._w,l=n._x,c=n._y,u=n._z,d=n._w;return this._x=r*d+o*l+i*u-a*c,this._y=i*d+o*c+a*l-r*u,this._z=a*d+o*u+r*c-i*l,this._w=o*d-r*l-i*c-a*u,this._onChangeCallback(),this}slerp(e,n){if(n<=0)return this;if(n>=1)return this.copy(e);let r=e._x,i=e._y,a=e._z,o=e._w,l=this.dot(e);l<0&&(r=-r,i=-i,a=-a,o=-o,l=-l);let c=1-n;if(l<.9995){const u=Math.acos(l),d=Math.sin(u);c=Math.sin(c*u)/d,n=Math.sin(n*u)/d,this._x=this._x*c+r*n,this._y=this._y*c+i*n,this._z=this._z*c+a*n,this._w=this._w*c+o*n,this._onChangeCallback()}else this._x=this._x*c+r*n,this._y=this._y*c+i*n,this._z=this._z*c+a*n,this._w=this._w*c+o*n,this.normalize();return this}slerpQuaternions(e,n,r){return this.copy(e).slerp(n,r)}random(){const e=2*Math.PI*Math.random(),n=2*Math.PI*Math.random(),r=Math.random(),i=Math.sqrt(1-r),a=Math.sqrt(r);return this.set(i*Math.sin(e),i*Math.cos(e),a*Math.sin(n),a*Math.cos(n))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,n=0){return this._x=e[n],this._y=e[n+1],this._z=e[n+2],this._w=e[n+3],this._onChangeCallback(),this}toArray(e=[],n=0){return e[n]=this._x,e[n+1]=this._y,e[n+2]=this._z,e[n+3]=this._w,e}fromBufferAttribute(e,n){return this._x=e.getX(n),this._y=e.getY(n),this._z=e.getZ(n),this._w=e.getW(n),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},dt=class lJ{constructor(e=0,n=0,r=0){lJ.prototype.isVector3=!0,this.x=e,this.y=n,this.z=r}set(e,n,r){return r===void 0&&(r=this.z),this.x=e,this.y=n,this.z=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this.z=e.z+n.z,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this.z+=e.z*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this.z=e.z-n.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,n){return this.x=e.x*n.x,this.y=e.y*n.y,this.z=e.z*n.z,this}applyEuler(e){return this.applyQuaternion(O$.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(O$.setFromAxisAngle(e,n))}applyMatrix3(e){const n=this.x,r=this.y,i=this.z,a=e.elements;return this.x=a[0]*n+a[3]*r+a[6]*i,this.y=a[1]*n+a[4]*r+a[7]*i,this.z=a[2]*n+a[5]*r+a[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const n=this.x,r=this.y,i=this.z,a=e.elements,o=1/(a[3]*n+a[7]*r+a[11]*i+a[15]);return this.x=(a[0]*n+a[4]*r+a[8]*i+a[12])*o,this.y=(a[1]*n+a[5]*r+a[9]*i+a[13])*o,this.z=(a[2]*n+a[6]*r+a[10]*i+a[14])*o,this}applyQuaternion(e){const n=this.x,r=this.y,i=this.z,a=e.x,o=e.y,l=e.z,c=e.w,u=2*(o*i-l*r),d=2*(l*n-a*i),f=2*(a*r-o*n);return this.x=n+c*u+o*f-l*d,this.y=r+c*d+l*u-a*f,this.z=i+c*f+a*d-o*u,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const n=this.x,r=this.y,i=this.z,a=e.elements;return this.x=a[0]*n+a[4]*r+a[8]*i,this.y=a[1]*n+a[5]*r+a[9]*i,this.z=a[2]*n+a[6]*r+a[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,n){return this.x=zn(this.x,e.x,n.x),this.y=zn(this.y,e.y,n.y),this.z=zn(this.z,e.z,n.z),this}clampScalar(e,n){return this.x=zn(this.x,e,n),this.y=zn(this.y,e,n),this.z=zn(this.z,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(zn(r,e,n))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this.z=e.z+(n.z-e.z)*r,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,n){const r=e.x,i=e.y,a=e.z,o=n.x,l=n.y,c=n.z;return this.x=i*c-a*l,this.y=a*o-r*c,this.z=r*l-i*o,this}projectOnVector(e){const n=e.lengthSq();if(n===0)return this.set(0,0,0);const r=e.dot(this)/n;return this.copy(e).multiplyScalar(r)}projectOnPlane(e){return WA.copy(this).projectOnVector(e),this.sub(WA)}reflect(e){return this.sub(WA.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const n=Math.sqrt(this.lengthSq()*e.lengthSq());if(n===0)return Math.PI/2;const r=this.dot(e)/n;return Math.acos(zn(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,r=this.y-e.y,i=this.z-e.z;return n*n+r*r+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,n,r){const i=Math.sin(n)*e;return this.x=i*Math.sin(r),this.y=Math.cos(n)*e,this.z=i*Math.cos(r),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,n,r){return this.x=e*Math.sin(n),this.y=r,this.z=e*Math.cos(n),this}setFromMatrixPosition(e){const n=e.elements;return this.x=n[12],this.y=n[13],this.z=n[14],this}setFromMatrixScale(e){const n=this.setFromMatrixColumn(e,0).length(),r=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=n,this.y=r,this.z=i,this}setFromMatrixColumn(e,n){return this.fromArray(e.elements,n*4)}setFromMatrix3Column(e,n){return this.fromArray(e.elements,n*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this.z=e[n+2],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e[n+2]=this.z,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this.z=e.getZ(n),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,n=Math.random()*2-1,r=Math.sqrt(1-n*n);return this.x=r*Math.cos(e),this.y=n,this.z=r*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};const WA=new dt,O$=new gm;let Pn=class cJ{constructor(e,n,r,i,a,o,l,c,u){cJ.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,n,r,i,a,o,l,c,u)}set(e,n,r,i,a,o,l,c,u){const d=this.elements;return d[0]=e,d[1]=i,d[2]=l,d[3]=n,d[4]=a,d[5]=c,d[6]=r,d[7]=o,d[8]=u,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const n=this.elements,r=e.elements;return n[0]=r[0],n[1]=r[1],n[2]=r[2],n[3]=r[3],n[4]=r[4],n[5]=r[5],n[6]=r[6],n[7]=r[7],n[8]=r[8],this}extractBasis(e,n,r){return e.setFromMatrix3Column(this,0),n.setFromMatrix3Column(this,1),r.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const n=e.elements;return this.set(n[0],n[4],n[8],n[1],n[5],n[9],n[2],n[6],n[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){const r=e.elements,i=n.elements,a=this.elements,o=r[0],l=r[3],c=r[6],u=r[1],d=r[4],f=r[7],p=r[2],m=r[5],x=r[8],b=i[0],y=i[3],v=i[6],S=i[1],N=i[4],T=i[7],k=i[2],C=i[5],E=i[8];return a[0]=o*b+l*S+c*k,a[3]=o*y+l*N+c*C,a[6]=o*v+l*T+c*E,a[1]=u*b+d*S+f*k,a[4]=u*y+d*N+f*C,a[7]=u*v+d*T+f*E,a[2]=p*b+m*S+x*k,a[5]=p*y+m*N+x*C,a[8]=p*v+m*T+x*E,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[3]*=e,n[6]*=e,n[1]*=e,n[4]*=e,n[7]*=e,n[2]*=e,n[5]*=e,n[8]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[1],i=e[2],a=e[3],o=e[4],l=e[5],c=e[6],u=e[7],d=e[8];return n*o*d-n*l*u-r*a*d+r*l*c+i*a*u-i*o*c}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],a=e[3],o=e[4],l=e[5],c=e[6],u=e[7],d=e[8],f=d*o-l*u,p=l*c-d*a,m=u*a-o*c,x=n*f+r*p+i*m;if(x===0)return this.set(0,0,0,0,0,0,0,0,0);const b=1/x;return e[0]=f*b,e[1]=(i*u-d*r)*b,e[2]=(l*r-i*o)*b,e[3]=p*b,e[4]=(d*n-i*c)*b,e[5]=(i*a-l*n)*b,e[6]=m*b,e[7]=(r*c-u*n)*b,e[8]=(o*n-r*a)*b,this}transpose(){let e;const n=this.elements;return e=n[1],n[1]=n[3],n[3]=e,e=n[2],n[2]=n[6],n[6]=e,e=n[5],n[5]=n[7],n[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const n=this.elements;return e[0]=n[0],e[1]=n[3],e[2]=n[6],e[3]=n[1],e[4]=n[4],e[5]=n[7],e[6]=n[2],e[7]=n[5],e[8]=n[8],this}setUvTransform(e,n,r,i,a,o,l){const c=Math.cos(a),u=Math.sin(a);return this.set(r*c,r*u,-r*(c*o+u*l)+o+e,-i*u,i*c,-i*(-u*o+c*l)+l+n,0,0,1),this}scale(e,n){return this.premultiply(KA.makeScale(e,n)),this}rotate(e){return this.premultiply(KA.makeRotation(-e)),this}translate(e,n){return this.premultiply(KA.makeTranslation(e,n)),this}makeTranslation(e,n){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,n,0,0,1),this}makeRotation(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,-r,0,r,n,0,0,0,1),this}makeScale(e,n){return this.set(e,0,0,0,n,0,0,0,1),this}equals(e){const n=this.elements,r=e.elements;for(let i=0;i<9;i++)if(n[i]!==r[i])return!1;return!0}fromArray(e,n=0){for(let r=0;r<9;r++)this.elements[r]=e[r+n];return this}toArray(e=[],n=0){const r=this.elements;return e[n]=r[0],e[n+1]=r[1],e[n+2]=r[2],e[n+3]=r[3],e[n+4]=r[4],e[n+5]=r[5],e[n+6]=r[6],e[n+7]=r[7],e[n+8]=r[8],e}clone(){return new this.constructor().fromArray(this.elements)}};const KA=new Pn,L$=new Pn().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),F$=new Pn().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function lPe(){const t={enabled:!0,workingColorSpace:ex,spaces:{},convert:function(i,a,o){return this.enabled===!1||a===o||!a||!o||(this.spaces[a].transfer===Nr&&(i.r=Au(i.r),i.g=Au(i.g),i.b=Au(i.b)),this.spaces[a].primaries!==this.spaces[o].primaries&&(i.applyMatrix3(this.spaces[a].toXYZ),i.applyMatrix3(this.spaces[o].fromXYZ)),this.spaces[o].transfer===Nr&&(i.r=Cg(i.r),i.g=Cg(i.g),i.b=Cg(i.b))),i},workingToColorSpace:function(i,a){return this.convert(i,this.workingColorSpace,a)},colorSpaceToWorking:function(i,a){return this.convert(i,a,this.workingColorSpace)},getPrimaries:function(i){return this.spaces[i].primaries},getTransfer:function(i){return i===Kd?WS:this.spaces[i].transfer},getToneMappingMode:function(i){return this.spaces[i].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(i,a=this.workingColorSpace){return i.fromArray(this.spaces[a].luminanceCoefficients)},define:function(i){Object.assign(this.spaces,i)},_getMatrix:function(i,a,o){return i.copy(this.spaces[a].toXYZ).multiply(this.spaces[o].fromXYZ)},_getDrawingBufferColorSpace:function(i){return this.spaces[i].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(i=this.workingColorSpace){return this.spaces[i].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(i,a){return py("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),t.workingToColorSpace(i,a)},toWorkingColorSpace:function(i,a){return py("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),t.colorSpaceToWorking(i,a)}},e=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],r=[.3127,.329];return t.define({[ex]:{primaries:e,whitePoint:r,transfer:WS,toXYZ:L$,fromXYZ:F$,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:Vo},outputColorSpaceConfig:{drawingBufferColorSpace:Vo}},[Vo]:{primaries:e,whitePoint:r,transfer:Nr,toXYZ:L$,fromXYZ:F$,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:Vo}}}),t}const or=lPe();function Au(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function Cg(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let wp,cPe=class{static getDataURL(e,n="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let r;if(e instanceof HTMLCanvasElement)r=e;else{wp===void 0&&(wp=XS("canvas")),wp.width=e.width,wp.height=e.height;const i=wp.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),r=wp}return r.toDataURL(n)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const n=XS("canvas");n.width=e.width,n.height=e.height;const r=n.getContext("2d");r.drawImage(e,0,0,e.width,e.height);const i=r.getImageData(0,0,e.width,e.height),a=i.data;for(let o=0;o<a.length;o++)a[o]=Au(a[o]/255)*255;return r.putImageData(i,0,0),n}else if(e.data){const n=e.data.slice(0);for(let r=0;r<n.length;r++)n instanceof Uint8Array||n instanceof Uint8ClampedArray?n[r]=Math.floor(Au(n[r]/255)*255):n[r]=Au(n[r]);return{data:n,width:e.width,height:e.height}}else return gn("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},uPe=0,Y4=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:uPe++}),this.uuid=hv(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const n=this.data;return typeof HTMLVideoElement<"u"&&n instanceof HTMLVideoElement?e.set(n.videoWidth,n.videoHeight,0):n instanceof VideoFrame?e.set(n.displayHeight,n.displayWidth,0):n!==null?e.set(n.width,n.height,n.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const n=e===void 0||typeof e=="string";if(!n&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const r={uuid:this.uuid,url:""},i=this.data;if(i!==null){let a;if(Array.isArray(i)){a=[];for(let o=0,l=i.length;o<l;o++)i[o].isDataTexture?a.push(XA(i[o].image)):a.push(XA(i[o]))}else a=XA(i);r.url=a}return n||(e.images[this.uuid]=r),r}};function XA(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?cPe.getDataURL(t):t.data?{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(gn("Texture: Unable to serialize Texture."),{})}let dPe=0;const YA=new dt;let Hl=class A1 extends Cm{constructor(e=A1.DEFAULT_IMAGE,n=A1.DEFAULT_MAPPING,r=vu,i=vu,a=el,o=Of,l=Pl,c=yc,u=A1.DEFAULT_ANISOTROPY,d=Kd){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:dPe++}),this.uuid=hv(),this.name="",this.source=new Y4(e),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=a,this.minFilter=o,this.anisotropy=u,this.format=l,this.internalFormat=null,this.type=c,this.offset=new Tn(0,0),this.repeat=new Tn(1,1),this.center=new Tn(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Pn,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=d,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(YA).x}get height(){return this.source.getSize(YA).y}get depth(){return this.source.getSize(YA).z}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,n){this.updateRanges.push({start:e,count:n})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const n in e){const r=e[n];if(r===void 0){gn(`Texture.setValues(): parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){gn(`Texture.setValues(): property '${n}' does not exist.`);continue}i&&r&&i.isVector2&&r.isVector2||i&&r&&i.isVector3&&r.isVector3||i&&r&&i.isMatrix3&&r.isMatrix3?i.copy(r):this[n]=r}}toJSON(e){const n=e===void 0||typeof e=="string";if(!n&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const r={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(r.userData=this.userData),n||(e.textures[this.uuid]=r),r}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==YZ)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case R3:e.x=e.x-Math.floor(e.x);break;case vu:e.x=e.x<0?0:1;break;case O3:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case R3:e.y=e.y-Math.floor(e.y);break;case vu:e.y=e.y<0?0:1;break;case O3:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}};Hl.DEFAULT_IMAGE=null;Hl.DEFAULT_MAPPING=YZ;Hl.DEFAULT_ANISOTROPY=1;let Ui=class uJ{constructor(e=0,n=0,r=0,i=1){uJ.prototype.isVector4=!0,this.x=e,this.y=n,this.z=r,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,n,r,i){return this.x=e,this.y=n,this.z=r,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;case 3:this.w=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this.z=e.z+n.z,this.w=e.w+n.w,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this.z+=e.z*n,this.w+=e.w*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this.z=e.z-n.z,this.w=e.w-n.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const n=this.x,r=this.y,i=this.z,a=this.w,o=e.elements;return this.x=o[0]*n+o[4]*r+o[8]*i+o[12]*a,this.y=o[1]*n+o[5]*r+o[9]*i+o[13]*a,this.z=o[2]*n+o[6]*r+o[10]*i+o[14]*a,this.w=o[3]*n+o[7]*r+o[11]*i+o[15]*a,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const n=Math.sqrt(1-e.w*e.w);return n<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/n,this.y=e.y/n,this.z=e.z/n),this}setAxisAngleFromRotationMatrix(e){let n,r,i,a;const c=e.elements,u=c[0],d=c[4],f=c[8],p=c[1],m=c[5],x=c[9],b=c[2],y=c[6],v=c[10];if(Math.abs(d-p)<.01&&Math.abs(f-b)<.01&&Math.abs(x-y)<.01){if(Math.abs(d+p)<.1&&Math.abs(f+b)<.1&&Math.abs(x+y)<.1&&Math.abs(u+m+v-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const N=(u+1)/2,T=(m+1)/2,k=(v+1)/2,C=(d+p)/4,E=(f+b)/4,D=(x+y)/4;return N>T&&N>k?N<.01?(r=0,i=.707106781,a=.707106781):(r=Math.sqrt(N),i=C/r,a=E/r):T>k?T<.01?(r=.707106781,i=0,a=.707106781):(i=Math.sqrt(T),r=C/i,a=D/i):k<.01?(r=.707106781,i=.707106781,a=0):(a=Math.sqrt(k),r=E/a,i=D/a),this.set(r,i,a,n),this}let S=Math.sqrt((y-x)*(y-x)+(f-b)*(f-b)+(p-d)*(p-d));return Math.abs(S)<.001&&(S=1),this.x=(y-x)/S,this.y=(f-b)/S,this.z=(p-d)/S,this.w=Math.acos((u+m+v-1)/2),this}setFromMatrixPosition(e){const n=e.elements;return this.x=n[12],this.y=n[13],this.z=n[14],this.w=n[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,n){return this.x=zn(this.x,e.x,n.x),this.y=zn(this.y,e.y,n.y),this.z=zn(this.z,e.z,n.z),this.w=zn(this.w,e.w,n.w),this}clampScalar(e,n){return this.x=zn(this.x,e,n),this.y=zn(this.y,e,n),this.z=zn(this.z,e,n),this.w=zn(this.w,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(zn(r,e,n))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this.w+=(e.w-this.w)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this.z=e.z+(n.z-e.z)*r,this.w=e.w+(n.w-e.w)*r,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this.z=e[n+2],this.w=e[n+3],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e[n+2]=this.z,e[n+3]=this.w,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this.z=e.getZ(n),this.w=e.getW(n),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}},hPe=class extends Cm{constructor(e=1,n=1,r={}){super(),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:el,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},r),this.isRenderTarget=!0,this.width=e,this.height=n,this.depth=r.depth,this.scissor=new Ui(0,0,e,n),this.scissorTest=!1,this.viewport=new Ui(0,0,e,n);const i={width:e,height:n,depth:r.depth},a=new Hl(i);this.textures=[];const o=r.count;for(let l=0;l<o;l++)this.textures[l]=a.clone(),this.textures[l].isRenderTargetTexture=!0,this.textures[l].renderTarget=this;this._setTextureOptions(r),this.depthBuffer=r.depthBuffer,this.stencilBuffer=r.stencilBuffer,this.resolveDepthBuffer=r.resolveDepthBuffer,this.resolveStencilBuffer=r.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=r.depthTexture,this.samples=r.samples,this.multiview=r.multiview}_setTextureOptions(e={}){const n={minFilter:el,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(n.mapping=e.mapping),e.wrapS!==void 0&&(n.wrapS=e.wrapS),e.wrapT!==void 0&&(n.wrapT=e.wrapT),e.wrapR!==void 0&&(n.wrapR=e.wrapR),e.magFilter!==void 0&&(n.magFilter=e.magFilter),e.minFilter!==void 0&&(n.minFilter=e.minFilter),e.format!==void 0&&(n.format=e.format),e.type!==void 0&&(n.type=e.type),e.anisotropy!==void 0&&(n.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(n.colorSpace=e.colorSpace),e.flipY!==void 0&&(n.flipY=e.flipY),e.generateMipmaps!==void 0&&(n.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(n.internalFormat=e.internalFormat);for(let r=0;r<this.textures.length;r++)this.textures[r].setValues(n)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,n,r=1){if(this.width!==e||this.height!==n||this.depth!==r){this.width=e,this.height=n,this.depth=r;for(let i=0,a=this.textures.length;i<a;i++)this.textures[i].image.width=e,this.textures[i].image.height=n,this.textures[i].image.depth=r,this.textures[i].isData3DTexture!==!0&&(this.textures[i].isArrayTexture=this.textures[i].image.depth>1);this.dispose()}this.viewport.set(0,0,e,n),this.scissor.set(0,0,e,n)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let n=0,r=e.textures.length;n<r;n++){this.textures[n]=e.textures[n].clone(),this.textures[n].isRenderTargetTexture=!0,this.textures[n].renderTarget=this;const i=Object.assign({},e.textures[n].image);this.textures[n].source=new Y4(i)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}},xm=class extends hPe{constructor(e=1,n=1,r={}){super(e,n,r),this.isWebGLRenderTarget=!0}},dJ=class extends Hl{constructor(e=null,n=1,r=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:n,height:r,depth:i},this.magFilter=po,this.minFilter=po,this.wrapR=vu,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},fPe=class extends Hl{constructor(e=null,n=1,r=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:n,height:r,depth:i},this.magFilter=po,this.minFilter=po,this.wrapR=vu,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},bm=class{constructor(e=new dt(1/0,1/0,1/0),n=new dt(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=n}set(e,n){return this.min.copy(e),this.max.copy(n),this}setFromArray(e){this.makeEmpty();for(let n=0,r=e.length;n<r;n+=3)this.expandByPoint(vl.fromArray(e,n));return this}setFromBufferAttribute(e){this.makeEmpty();for(let n=0,r=e.count;n<r;n++)this.expandByPoint(vl.fromBufferAttribute(e,n));return this}setFromPoints(e){this.makeEmpty();for(let n=0,r=e.length;n<r;n++)this.expandByPoint(e[n]);return this}setFromCenterAndSize(e,n){const r=vl.copy(n).multiplyScalar(.5);return this.min.copy(e).sub(r),this.max.copy(e).add(r),this}setFromObject(e,n=!1){return this.makeEmpty(),this.expandByObject(e,n)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,n=!1){e.updateWorldMatrix(!1,!1);const r=e.geometry;if(r!==void 0){const a=r.getAttribute("position");if(n===!0&&a!==void 0&&e.isInstancedMesh!==!0)for(let o=0,l=a.count;o<l;o++)e.isMesh===!0?e.getVertexPosition(o,vl):vl.fromBufferAttribute(a,o),vl.applyMatrix4(e.matrixWorld),this.expandByPoint(vl);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Jw.copy(e.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),Jw.copy(r.boundingBox)),Jw.applyMatrix4(e.matrixWorld),this.union(Jw)}const i=e.children;for(let a=0,o=i.length;a<o;a++)this.expandByObject(i[a],n);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,n){return n.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,vl),vl.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let n,r;return e.normal.x>0?(n=e.normal.x*this.min.x,r=e.normal.x*this.max.x):(n=e.normal.x*this.max.x,r=e.normal.x*this.min.x),e.normal.y>0?(n+=e.normal.y*this.min.y,r+=e.normal.y*this.max.y):(n+=e.normal.y*this.max.y,r+=e.normal.y*this.min.y),e.normal.z>0?(n+=e.normal.z*this.min.z,r+=e.normal.z*this.max.z):(n+=e.normal.z*this.max.z,r+=e.normal.z*this.min.z),n<=-e.constant&&r>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(zb),e_.subVectors(this.max,zb),_p.subVectors(e.a,zb),Sp.subVectors(e.b,zb),Mp.subVectors(e.c,zb),Sd.subVectors(Sp,_p),Md.subVectors(Mp,Sp),of.subVectors(_p,Mp);let n=[0,-Sd.z,Sd.y,0,-Md.z,Md.y,0,-of.z,of.y,Sd.z,0,-Sd.x,Md.z,0,-Md.x,of.z,0,-of.x,-Sd.y,Sd.x,0,-Md.y,Md.x,0,-of.y,of.x,0];return!QA(n,_p,Sp,Mp,e_)||(n=[1,0,0,0,1,0,0,0,1],!QA(n,_p,Sp,Mp,e_))?!1:(t_.crossVectors(Sd,Md),n=[t_.x,t_.y,t_.z],QA(n,_p,Sp,Mp,e_))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,vl).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(vl).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(qc[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),qc[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),qc[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),qc[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),qc[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),qc[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),qc[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),qc[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(qc),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}};const qc=[new dt,new dt,new dt,new dt,new dt,new dt,new dt,new dt],vl=new dt,Jw=new bm,_p=new dt,Sp=new dt,Mp=new dt,Sd=new dt,Md=new dt,of=new dt,zb=new dt,e_=new dt,t_=new dt,lf=new dt;function QA(t,e,n,r,i){for(let a=0,o=t.length-3;a<=o;a+=3){lf.fromArray(t,a);const l=i.x*Math.abs(lf.x)+i.y*Math.abs(lf.y)+i.z*Math.abs(lf.z),c=e.dot(lf),u=n.dot(lf),d=r.dot(lf);if(Math.max(-Math.max(c,u,d),Math.min(c,u,d))>l)return!1}return!0}const mPe=new bm,Bb=new dt,ZA=new dt;let m2=class{constructor(e=new dt,n=-1){this.isSphere=!0,this.center=e,this.radius=n}set(e,n){return this.center.copy(e),this.radius=n,this}setFromPoints(e,n){const r=this.center;n!==void 0?r.copy(n):mPe.setFromPoints(e).getCenter(r);let i=0;for(let a=0,o=e.length;a<o;a++)i=Math.max(i,r.distanceToSquared(e[a]));return this.radius=Math.sqrt(i),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const n=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=n*n}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,n){const r=this.center.distanceToSquared(e);return n.copy(e),r>this.radius*this.radius&&(n.sub(this.center).normalize(),n.multiplyScalar(this.radius).add(this.center)),n}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Bb.subVectors(e,this.center);const n=Bb.lengthSq();if(n>this.radius*this.radius){const r=Math.sqrt(n),i=(r-this.radius)*.5;this.center.addScaledVector(Bb,i/r),this.radius+=i}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(ZA.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Bb.copy(e.center).add(ZA)),this.expandByPoint(Bb.copy(e.center).sub(ZA))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}};const Wc=new dt,JA=new dt,n_=new dt,Nd=new dt,eC=new dt,r_=new dt,tC=new dt;let Q4=class{constructor(e=new dt,n=new dt(0,0,-1)){this.origin=e,this.direction=n}set(e,n){return this.origin.copy(e),this.direction.copy(n),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,n){return n.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Wc)),this}closestPointToPoint(e,n){n.subVectors(e,this.origin);const r=n.dot(this.direction);return r<0?n.copy(this.origin):n.copy(this.origin).addScaledVector(this.direction,r)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const n=Wc.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(Wc.copy(this.origin).addScaledVector(this.direction,n),Wc.distanceToSquared(e))}distanceSqToSegment(e,n,r,i){JA.copy(e).add(n).multiplyScalar(.5),n_.copy(n).sub(e).normalize(),Nd.copy(this.origin).sub(JA);const a=e.distanceTo(n)*.5,o=-this.direction.dot(n_),l=Nd.dot(this.direction),c=-Nd.dot(n_),u=Nd.lengthSq(),d=Math.abs(1-o*o);let f,p,m,x;if(d>0)if(f=o*c-l,p=o*l-c,x=a*d,f>=0)if(p>=-x)if(p<=x){const b=1/d;f*=b,p*=b,m=f*(f+o*p+2*l)+p*(o*f+p+2*c)+u}else p=a,f=Math.max(0,-(o*p+l)),m=-f*f+p*(p+2*c)+u;else p=-a,f=Math.max(0,-(o*p+l)),m=-f*f+p*(p+2*c)+u;else p<=-x?(f=Math.max(0,-(-o*a+l)),p=f>0?-a:Math.min(Math.max(-a,-c),a),m=-f*f+p*(p+2*c)+u):p<=x?(f=0,p=Math.min(Math.max(-a,-c),a),m=p*(p+2*c)+u):(f=Math.max(0,-(o*a+l)),p=f>0?a:Math.min(Math.max(-a,-c),a),m=-f*f+p*(p+2*c)+u);else p=o>0?-a:a,f=Math.max(0,-(o*p+l)),m=-f*f+p*(p+2*c)+u;return r&&r.copy(this.origin).addScaledVector(this.direction,f),i&&i.copy(JA).addScaledVector(n_,p),m}intersectSphere(e,n){Wc.subVectors(e.center,this.origin);const r=Wc.dot(this.direction),i=Wc.dot(Wc)-r*r,a=e.radius*e.radius;if(i>a)return null;const o=Math.sqrt(a-i),l=r-o,c=r+o;return c<0?null:l<0?this.at(c,n):this.at(l,n)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const n=e.normal.dot(this.direction);if(n===0)return e.distanceToPoint(this.origin)===0?0:null;const r=-(this.origin.dot(e.normal)+e.constant)/n;return r>=0?r:null}intersectPlane(e,n){const r=this.distanceToPlane(e);return r===null?null:this.at(r,n)}intersectsPlane(e){const n=e.distanceToPoint(this.origin);return n===0||e.normal.dot(this.direction)*n<0}intersectBox(e,n){let r,i,a,o,l,c;const u=1/this.direction.x,d=1/this.direction.y,f=1/this.direction.z,p=this.origin;return u>=0?(r=(e.min.x-p.x)*u,i=(e.max.x-p.x)*u):(r=(e.max.x-p.x)*u,i=(e.min.x-p.x)*u),d>=0?(a=(e.min.y-p.y)*d,o=(e.max.y-p.y)*d):(a=(e.max.y-p.y)*d,o=(e.min.y-p.y)*d),r>o||a>i||((a>r||isNaN(r))&&(r=a),(o<i||isNaN(i))&&(i=o),f>=0?(l=(e.min.z-p.z)*f,c=(e.max.z-p.z)*f):(l=(e.max.z-p.z)*f,c=(e.min.z-p.z)*f),r>c||l>i)||((l>r||r!==r)&&(r=l),(c<i||i!==i)&&(i=c),i<0)?null:this.at(r>=0?r:i,n)}intersectsBox(e){return this.intersectBox(e,Wc)!==null}intersectTriangle(e,n,r,i,a){eC.subVectors(n,e),r_.subVectors(r,e),tC.crossVectors(eC,r_);let o=this.direction.dot(tC),l;if(o>0){if(i)return null;l=1}else if(o<0)l=-1,o=-o;else return null;Nd.subVectors(this.origin,e);const c=l*this.direction.dot(r_.crossVectors(Nd,r_));if(c<0)return null;const u=l*this.direction.dot(eC.cross(Nd));if(u<0||c+u>o)return null;const d=-l*Nd.dot(tC);return d<0?null:this.at(d/o,a)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},Vi=class dD{constructor(e,n,r,i,a,o,l,c,u,d,f,p,m,x,b,y){dD.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,n,r,i,a,o,l,c,u,d,f,p,m,x,b,y)}set(e,n,r,i,a,o,l,c,u,d,f,p,m,x,b,y){const v=this.elements;return v[0]=e,v[4]=n,v[8]=r,v[12]=i,v[1]=a,v[5]=o,v[9]=l,v[13]=c,v[2]=u,v[6]=d,v[10]=f,v[14]=p,v[3]=m,v[7]=x,v[11]=b,v[15]=y,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new dD().fromArray(this.elements)}copy(e){const n=this.elements,r=e.elements;return n[0]=r[0],n[1]=r[1],n[2]=r[2],n[3]=r[3],n[4]=r[4],n[5]=r[5],n[6]=r[6],n[7]=r[7],n[8]=r[8],n[9]=r[9],n[10]=r[10],n[11]=r[11],n[12]=r[12],n[13]=r[13],n[14]=r[14],n[15]=r[15],this}copyPosition(e){const n=this.elements,r=e.elements;return n[12]=r[12],n[13]=r[13],n[14]=r[14],this}setFromMatrix3(e){const n=e.elements;return this.set(n[0],n[3],n[6],0,n[1],n[4],n[7],0,n[2],n[5],n[8],0,0,0,0,1),this}extractBasis(e,n,r){return e.setFromMatrixColumn(this,0),n.setFromMatrixColumn(this,1),r.setFromMatrixColumn(this,2),this}makeBasis(e,n,r){return this.set(e.x,n.x,r.x,0,e.y,n.y,r.y,0,e.z,n.z,r.z,0,0,0,0,1),this}extractRotation(e){const n=this.elements,r=e.elements,i=1/Np.setFromMatrixColumn(e,0).length(),a=1/Np.setFromMatrixColumn(e,1).length(),o=1/Np.setFromMatrixColumn(e,2).length();return n[0]=r[0]*i,n[1]=r[1]*i,n[2]=r[2]*i,n[3]=0,n[4]=r[4]*a,n[5]=r[5]*a,n[6]=r[6]*a,n[7]=0,n[8]=r[8]*o,n[9]=r[9]*o,n[10]=r[10]*o,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromEuler(e){const n=this.elements,r=e.x,i=e.y,a=e.z,o=Math.cos(r),l=Math.sin(r),c=Math.cos(i),u=Math.sin(i),d=Math.cos(a),f=Math.sin(a);if(e.order==="XYZ"){const p=o*d,m=o*f,x=l*d,b=l*f;n[0]=c*d,n[4]=-c*f,n[8]=u,n[1]=m+x*u,n[5]=p-b*u,n[9]=-l*c,n[2]=b-p*u,n[6]=x+m*u,n[10]=o*c}else if(e.order==="YXZ"){const p=c*d,m=c*f,x=u*d,b=u*f;n[0]=p+b*l,n[4]=x*l-m,n[8]=o*u,n[1]=o*f,n[5]=o*d,n[9]=-l,n[2]=m*l-x,n[6]=b+p*l,n[10]=o*c}else if(e.order==="ZXY"){const p=c*d,m=c*f,x=u*d,b=u*f;n[0]=p-b*l,n[4]=-o*f,n[8]=x+m*l,n[1]=m+x*l,n[5]=o*d,n[9]=b-p*l,n[2]=-o*u,n[6]=l,n[10]=o*c}else if(e.order==="ZYX"){const p=o*d,m=o*f,x=l*d,b=l*f;n[0]=c*d,n[4]=x*u-m,n[8]=p*u+b,n[1]=c*f,n[5]=b*u+p,n[9]=m*u-x,n[2]=-u,n[6]=l*c,n[10]=o*c}else if(e.order==="YZX"){const p=o*c,m=o*u,x=l*c,b=l*u;n[0]=c*d,n[4]=b-p*f,n[8]=x*f+m,n[1]=f,n[5]=o*d,n[9]=-l*d,n[2]=-u*d,n[6]=m*f+x,n[10]=p-b*f}else if(e.order==="XZY"){const p=o*c,m=o*u,x=l*c,b=l*u;n[0]=c*d,n[4]=-f,n[8]=u*d,n[1]=p*f+b,n[5]=o*d,n[9]=m*f-x,n[2]=x*f-m,n[6]=l*d,n[10]=b*f+p}return n[3]=0,n[7]=0,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromQuaternion(e){return this.compose(pPe,e,gPe)}lookAt(e,n,r){const i=this.elements;return no.subVectors(e,n),no.lengthSq()===0&&(no.z=1),no.normalize(),kd.crossVectors(r,no),kd.lengthSq()===0&&(Math.abs(r.z)===1?no.x+=1e-4:no.z+=1e-4,no.normalize(),kd.crossVectors(r,no)),kd.normalize(),i_.crossVectors(no,kd),i[0]=kd.x,i[4]=i_.x,i[8]=no.x,i[1]=kd.y,i[5]=i_.y,i[9]=no.y,i[2]=kd.z,i[6]=i_.z,i[10]=no.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){const r=e.elements,i=n.elements,a=this.elements,o=r[0],l=r[4],c=r[8],u=r[12],d=r[1],f=r[5],p=r[9],m=r[13],x=r[2],b=r[6],y=r[10],v=r[14],S=r[3],N=r[7],T=r[11],k=r[15],C=i[0],E=i[4],D=i[8],A=i[12],R=i[1],U=i[5],F=i[9],$=i[13],j=i[2],H=i[6],K=i[10],V=i[14],Q=i[3],Z=i[7],ae=i[11],B=i[15];return a[0]=o*C+l*R+c*j+u*Q,a[4]=o*E+l*U+c*H+u*Z,a[8]=o*D+l*F+c*K+u*ae,a[12]=o*A+l*$+c*V+u*B,a[1]=d*C+f*R+p*j+m*Q,a[5]=d*E+f*U+p*H+m*Z,a[9]=d*D+f*F+p*K+m*ae,a[13]=d*A+f*$+p*V+m*B,a[2]=x*C+b*R+y*j+v*Q,a[6]=x*E+b*U+y*H+v*Z,a[10]=x*D+b*F+y*K+v*ae,a[14]=x*A+b*$+y*V+v*B,a[3]=S*C+N*R+T*j+k*Q,a[7]=S*E+N*U+T*H+k*Z,a[11]=S*D+N*F+T*K+k*ae,a[15]=S*A+N*$+T*V+k*B,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[4]*=e,n[8]*=e,n[12]*=e,n[1]*=e,n[5]*=e,n[9]*=e,n[13]*=e,n[2]*=e,n[6]*=e,n[10]*=e,n[14]*=e,n[3]*=e,n[7]*=e,n[11]*=e,n[15]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[4],i=e[8],a=e[12],o=e[1],l=e[5],c=e[9],u=e[13],d=e[2],f=e[6],p=e[10],m=e[14],x=e[3],b=e[7],y=e[11],v=e[15];return x*(+a*c*f-i*u*f-a*l*p+r*u*p+i*l*m-r*c*m)+b*(+n*c*m-n*u*p+a*o*p-i*o*m+i*u*d-a*c*d)+y*(+n*u*f-n*l*m-a*o*f+r*o*m+a*l*d-r*u*d)+v*(-i*l*d-n*c*f+n*l*p+i*o*f-r*o*p+r*c*d)}transpose(){const e=this.elements;let n;return n=e[1],e[1]=e[4],e[4]=n,n=e[2],e[2]=e[8],e[8]=n,n=e[6],e[6]=e[9],e[9]=n,n=e[3],e[3]=e[12],e[12]=n,n=e[7],e[7]=e[13],e[13]=n,n=e[11],e[11]=e[14],e[14]=n,this}setPosition(e,n,r){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=n,i[14]=r),this}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],a=e[3],o=e[4],l=e[5],c=e[6],u=e[7],d=e[8],f=e[9],p=e[10],m=e[11],x=e[12],b=e[13],y=e[14],v=e[15],S=f*y*u-b*p*u+b*c*m-l*y*m-f*c*v+l*p*v,N=x*p*u-d*y*u-x*c*m+o*y*m+d*c*v-o*p*v,T=d*b*u-x*f*u+x*l*m-o*b*m-d*l*v+o*f*v,k=x*f*c-d*b*c-x*l*p+o*b*p+d*l*y-o*f*y,C=n*S+r*N+i*T+a*k;if(C===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const E=1/C;return e[0]=S*E,e[1]=(b*p*a-f*y*a-b*i*m+r*y*m+f*i*v-r*p*v)*E,e[2]=(l*y*a-b*c*a+b*i*u-r*y*u-l*i*v+r*c*v)*E,e[3]=(f*c*a-l*p*a-f*i*u+r*p*u+l*i*m-r*c*m)*E,e[4]=N*E,e[5]=(d*y*a-x*p*a+x*i*m-n*y*m-d*i*v+n*p*v)*E,e[6]=(x*c*a-o*y*a-x*i*u+n*y*u+o*i*v-n*c*v)*E,e[7]=(o*p*a-d*c*a+d*i*u-n*p*u-o*i*m+n*c*m)*E,e[8]=T*E,e[9]=(x*f*a-d*b*a-x*r*m+n*b*m+d*r*v-n*f*v)*E,e[10]=(o*b*a-x*l*a+x*r*u-n*b*u-o*r*v+n*l*v)*E,e[11]=(d*l*a-o*f*a-d*r*u+n*f*u+o*r*m-n*l*m)*E,e[12]=k*E,e[13]=(d*b*i-x*f*i+x*r*p-n*b*p-d*r*y+n*f*y)*E,e[14]=(x*l*i-o*b*i-x*r*c+n*b*c+o*r*y-n*l*y)*E,e[15]=(o*f*i-d*l*i+d*r*c-n*f*c-o*r*p+n*l*p)*E,this}scale(e){const n=this.elements,r=e.x,i=e.y,a=e.z;return n[0]*=r,n[4]*=i,n[8]*=a,n[1]*=r,n[5]*=i,n[9]*=a,n[2]*=r,n[6]*=i,n[10]*=a,n[3]*=r,n[7]*=i,n[11]*=a,this}getMaxScaleOnAxis(){const e=this.elements,n=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],r=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(n,r,i))}makeTranslation(e,n,r){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,n,0,0,1,r,0,0,0,1),this}makeRotationX(e){const n=Math.cos(e),r=Math.sin(e);return this.set(1,0,0,0,0,n,-r,0,0,r,n,0,0,0,0,1),this}makeRotationY(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,0,r,0,0,1,0,0,-r,0,n,0,0,0,0,1),this}makeRotationZ(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,-r,0,0,r,n,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,n){const r=Math.cos(n),i=Math.sin(n),a=1-r,o=e.x,l=e.y,c=e.z,u=a*o,d=a*l;return this.set(u*o+r,u*l-i*c,u*c+i*l,0,u*l+i*c,d*l+r,d*c-i*o,0,u*c-i*l,d*c+i*o,a*c*c+r,0,0,0,0,1),this}makeScale(e,n,r){return this.set(e,0,0,0,0,n,0,0,0,0,r,0,0,0,0,1),this}makeShear(e,n,r,i,a,o){return this.set(1,r,a,0,e,1,o,0,n,i,1,0,0,0,0,1),this}compose(e,n,r){const i=this.elements,a=n._x,o=n._y,l=n._z,c=n._w,u=a+a,d=o+o,f=l+l,p=a*u,m=a*d,x=a*f,b=o*d,y=o*f,v=l*f,S=c*u,N=c*d,T=c*f,k=r.x,C=r.y,E=r.z;return i[0]=(1-(b+v))*k,i[1]=(m+T)*k,i[2]=(x-N)*k,i[3]=0,i[4]=(m-T)*C,i[5]=(1-(p+v))*C,i[6]=(y+S)*C,i[7]=0,i[8]=(x+N)*E,i[9]=(y-S)*E,i[10]=(1-(p+b))*E,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,n,r){const i=this.elements;let a=Np.set(i[0],i[1],i[2]).length();const o=Np.set(i[4],i[5],i[6]).length(),l=Np.set(i[8],i[9],i[10]).length();this.determinant()<0&&(a=-a),e.x=i[12],e.y=i[13],e.z=i[14],wl.copy(this);const u=1/a,d=1/o,f=1/l;return wl.elements[0]*=u,wl.elements[1]*=u,wl.elements[2]*=u,wl.elements[4]*=d,wl.elements[5]*=d,wl.elements[6]*=d,wl.elements[8]*=f,wl.elements[9]*=f,wl.elements[10]*=f,n.setFromRotationMatrix(wl),r.x=a,r.y=o,r.z=l,this}makePerspective(e,n,r,i,a,o,l=lc,c=!1){const u=this.elements,d=2*a/(n-e),f=2*a/(r-i),p=(n+e)/(n-e),m=(r+i)/(r-i);let x,b;if(c)x=a/(o-a),b=o*a/(o-a);else if(l===lc)x=-(o+a)/(o-a),b=-2*o*a/(o-a);else if(l===KS)x=-o/(o-a),b=-o*a/(o-a);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+l);return u[0]=d,u[4]=0,u[8]=p,u[12]=0,u[1]=0,u[5]=f,u[9]=m,u[13]=0,u[2]=0,u[6]=0,u[10]=x,u[14]=b,u[3]=0,u[7]=0,u[11]=-1,u[15]=0,this}makeOrthographic(e,n,r,i,a,o,l=lc,c=!1){const u=this.elements,d=2/(n-e),f=2/(r-i),p=-(n+e)/(n-e),m=-(r+i)/(r-i);let x,b;if(c)x=1/(o-a),b=o/(o-a);else if(l===lc)x=-2/(o-a),b=-(o+a)/(o-a);else if(l===KS)x=-1/(o-a),b=-a/(o-a);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+l);return u[0]=d,u[4]=0,u[8]=0,u[12]=p,u[1]=0,u[5]=f,u[9]=0,u[13]=m,u[2]=0,u[6]=0,u[10]=x,u[14]=b,u[3]=0,u[7]=0,u[11]=0,u[15]=1,this}equals(e){const n=this.elements,r=e.elements;for(let i=0;i<16;i++)if(n[i]!==r[i])return!1;return!0}fromArray(e,n=0){for(let r=0;r<16;r++)this.elements[r]=e[r+n];return this}toArray(e=[],n=0){const r=this.elements;return e[n]=r[0],e[n+1]=r[1],e[n+2]=r[2],e[n+3]=r[3],e[n+4]=r[4],e[n+5]=r[5],e[n+6]=r[6],e[n+7]=r[7],e[n+8]=r[8],e[n+9]=r[9],e[n+10]=r[10],e[n+11]=r[11],e[n+12]=r[12],e[n+13]=r[13],e[n+14]=r[14],e[n+15]=r[15],e}};const Np=new dt,wl=new Vi,pPe=new dt(0,0,0),gPe=new dt(1,1,1),kd=new dt,i_=new dt,no=new dt,I$=new Vi,U$=new gm;let Eh=class hJ{constructor(e=0,n=0,r=0,i=hJ.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=n,this._z=r,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,n,r,i=this._order){return this._x=e,this._y=n,this._z=r,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,n=this._order,r=!0){const i=e.elements,a=i[0],o=i[4],l=i[8],c=i[1],u=i[5],d=i[9],f=i[2],p=i[6],m=i[10];switch(n){case"XYZ":this._y=Math.asin(zn(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-d,m),this._z=Math.atan2(-o,a)):(this._x=Math.atan2(p,u),this._z=0);break;case"YXZ":this._x=Math.asin(-zn(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(l,m),this._z=Math.atan2(c,u)):(this._y=Math.atan2(-f,a),this._z=0);break;case"ZXY":this._x=Math.asin(zn(p,-1,1)),Math.abs(p)<.9999999?(this._y=Math.atan2(-f,m),this._z=Math.atan2(-o,u)):(this._y=0,this._z=Math.atan2(c,a));break;case"ZYX":this._y=Math.asin(-zn(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(p,m),this._z=Math.atan2(c,a)):(this._x=0,this._z=Math.atan2(-o,u));break;case"YZX":this._z=Math.asin(zn(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-d,u),this._y=Math.atan2(-f,a)):(this._x=0,this._y=Math.atan2(l,m));break;case"XZY":this._z=Math.asin(-zn(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(p,u),this._y=Math.atan2(l,a)):(this._x=Math.atan2(-d,m),this._y=0);break;default:gn("Euler: .setFromRotationMatrix() encountered an unknown order: "+n)}return this._order=n,r===!0&&this._onChangeCallback(),this}setFromQuaternion(e,n,r){return I$.makeRotationFromQuaternion(e),this.setFromRotationMatrix(I$,n,r)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return U$.setFromEuler(this),this.setFromQuaternion(U$,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}};Eh.DEFAULT_ORDER="XYZ";let fJ=class{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}},xPe=0;const z$=new dt,kp=new gm,Kc=new Vi,a_=new dt,Hb=new dt,bPe=new dt,yPe=new gm,B$=new dt(1,0,0),H$=new dt(0,1,0),$$=new dt(0,0,1),V$={type:"added"},vPe={type:"removed"},Ep={type:"childadded",child:null},nC={type:"childremoved",child:null};let vo=class C1 extends Cm{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:xPe++}),this.uuid=hv(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=C1.DEFAULT_UP.clone();const e=new dt,n=new Eh,r=new gm,i=new dt(1,1,1);function a(){r.setFromEuler(n,!1)}function o(){n.setFromQuaternion(r,void 0,!1)}n._onChange(a),r._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:n},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Vi},normalMatrix:{value:new Pn}}),this.matrix=new Vi,this.matrixWorld=new Vi,this.matrixAutoUpdate=C1.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=C1.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new fJ,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,n){this.quaternion.setFromAxisAngle(e,n)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,n){return kp.setFromAxisAngle(e,n),this.quaternion.multiply(kp),this}rotateOnWorldAxis(e,n){return kp.setFromAxisAngle(e,n),this.quaternion.premultiply(kp),this}rotateX(e){return this.rotateOnAxis(B$,e)}rotateY(e){return this.rotateOnAxis(H$,e)}rotateZ(e){return this.rotateOnAxis($$,e)}translateOnAxis(e,n){return z$.copy(e).applyQuaternion(this.quaternion),this.position.add(z$.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(B$,e)}translateY(e){return this.translateOnAxis(H$,e)}translateZ(e){return this.translateOnAxis($$,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Kc.copy(this.matrixWorld).invert())}lookAt(e,n,r){e.isVector3?a_.copy(e):a_.set(e,n,r);const i=this.parent;this.updateWorldMatrix(!0,!1),Hb.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Kc.lookAt(Hb,a_,this.up):Kc.lookAt(a_,Hb,this.up),this.quaternion.setFromRotationMatrix(Kc),i&&(Kc.extractRotation(i.matrixWorld),kp.setFromRotationMatrix(Kc),this.quaternion.premultiply(kp.invert()))}add(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.add(arguments[n]);return this}return e===this?(Ei("Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(V$),Ep.child=e,this.dispatchEvent(Ep),Ep.child=null):Ei("Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let r=0;r<arguments.length;r++)this.remove(arguments[r]);return this}const n=this.children.indexOf(e);return n!==-1&&(e.parent=null,this.children.splice(n,1),e.dispatchEvent(vPe),nC.child=e,this.dispatchEvent(nC),nC.child=null),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),Kc.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Kc.multiply(e.parent.matrixWorld)),e.applyMatrix4(Kc),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(V$),Ep.child=e,this.dispatchEvent(Ep),Ep.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,n){if(this[e]===n)return this;for(let r=0,i=this.children.length;r<i;r++){const o=this.children[r].getObjectByProperty(e,n);if(o!==void 0)return o}}getObjectsByProperty(e,n,r=[]){this[e]===n&&r.push(this);const i=this.children;for(let a=0,o=i.length;a<o;a++)i[a].getObjectsByProperty(e,n,r);return r}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Hb,e,bPe),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Hb,yPe,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const n=this.matrixWorld.elements;return e.set(n[8],n[9],n[10]).normalize()}raycast(){}traverse(e){e(this);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].traverseVisible(e)}traverseAncestors(e){const n=this.parent;n!==null&&(e(n),n.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].updateMatrixWorld(e)}updateWorldMatrix(e,n){const r=this.parent;if(e===!0&&r!==null&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),n===!0){const i=this.children;for(let a=0,o=i.length;a<o;a++)i[a].updateWorldMatrix(!1,!0)}}toJSON(e){const n=e===void 0||typeof e=="string",r={};n&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},r.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map(l=>({...l,boundingBox:l.boundingBox?l.boundingBox.toJSON():void 0,boundingSphere:l.boundingSphere?l.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map(l=>({...l})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(e),i.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(i.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(i.boundingBox=this.boundingBox.toJSON()));function a(l,c){return l[c.uuid]===void 0&&(l[c.uuid]=c.toJSON(e)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=a(e.geometries,this.geometry);const l=this.geometry.parameters;if(l!==void 0&&l.shapes!==void 0){const c=l.shapes;if(Array.isArray(c))for(let u=0,d=c.length;u<d;u++){const f=c[u];a(e.shapes,f)}else a(e.shapes,c)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(a(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const l=[];for(let c=0,u=this.material.length;c<u;c++)l.push(a(e.materials,this.material[c]));i.material=l}else i.material=a(e.materials,this.material);if(this.children.length>0){i.children=[];for(let l=0;l<this.children.length;l++)i.children.push(this.children[l].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let l=0;l<this.animations.length;l++){const c=this.animations[l];i.animations.push(a(e.animations,c))}}if(n){const l=o(e.geometries),c=o(e.materials),u=o(e.textures),d=o(e.images),f=o(e.shapes),p=o(e.skeletons),m=o(e.animations),x=o(e.nodes);l.length>0&&(r.geometries=l),c.length>0&&(r.materials=c),u.length>0&&(r.textures=u),d.length>0&&(r.images=d),f.length>0&&(r.shapes=f),p.length>0&&(r.skeletons=p),m.length>0&&(r.animations=m),x.length>0&&(r.nodes=x)}return r.object=i,r;function o(l){const c=[];for(const u in l){const d=l[u];delete d.metadata,c.push(d)}return c}}clone(e){return new this.constructor().copy(this,e)}copy(e,n=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),n===!0)for(let r=0;r<e.children.length;r++){const i=e.children[r];this.add(i.clone())}return this}};vo.DEFAULT_UP=new dt(0,1,0);vo.DEFAULT_MATRIX_AUTO_UPDATE=!0;vo.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const _l=new dt,Xc=new dt,rC=new dt,Yc=new dt,Tp=new dt,Ap=new dt,G$=new dt,iC=new dt,aC=new dt,sC=new dt,oC=new Ui,lC=new Ui,cC=new Ui;let $b=class og{constructor(e=new dt,n=new dt,r=new dt){this.a=e,this.b=n,this.c=r}static getNormal(e,n,r,i){i.subVectors(r,n),_l.subVectors(e,n),i.cross(_l);const a=i.lengthSq();return a>0?i.multiplyScalar(1/Math.sqrt(a)):i.set(0,0,0)}static getBarycoord(e,n,r,i,a){_l.subVectors(i,n),Xc.subVectors(r,n),rC.subVectors(e,n);const o=_l.dot(_l),l=_l.dot(Xc),c=_l.dot(rC),u=Xc.dot(Xc),d=Xc.dot(rC),f=o*u-l*l;if(f===0)return a.set(0,0,0),null;const p=1/f,m=(u*c-l*d)*p,x=(o*d-l*c)*p;return a.set(1-m-x,x,m)}static containsPoint(e,n,r,i){return this.getBarycoord(e,n,r,i,Yc)===null?!1:Yc.x>=0&&Yc.y>=0&&Yc.x+Yc.y<=1}static getInterpolation(e,n,r,i,a,o,l,c){return this.getBarycoord(e,n,r,i,Yc)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(a,Yc.x),c.addScaledVector(o,Yc.y),c.addScaledVector(l,Yc.z),c)}static getInterpolatedAttribute(e,n,r,i,a,o){return oC.setScalar(0),lC.setScalar(0),cC.setScalar(0),oC.fromBufferAttribute(e,n),lC.fromBufferAttribute(e,r),cC.fromBufferAttribute(e,i),o.setScalar(0),o.addScaledVector(oC,a.x),o.addScaledVector(lC,a.y),o.addScaledVector(cC,a.z),o}static isFrontFacing(e,n,r,i){return _l.subVectors(r,n),Xc.subVectors(e,n),_l.cross(Xc).dot(i)<0}set(e,n,r){return this.a.copy(e),this.b.copy(n),this.c.copy(r),this}setFromPointsAndIndices(e,n,r,i){return this.a.copy(e[n]),this.b.copy(e[r]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,n,r,i){return this.a.fromBufferAttribute(e,n),this.b.fromBufferAttribute(e,r),this.c.fromBufferAttribute(e,i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return _l.subVectors(this.c,this.b),Xc.subVectors(this.a,this.b),_l.cross(Xc).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return og.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return og.getBarycoord(e,this.a,this.b,this.c,n)}getInterpolation(e,n,r,i,a){return og.getInterpolation(e,this.a,this.b,this.c,n,r,i,a)}containsPoint(e){return og.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return og.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,n){const r=this.a,i=this.b,a=this.c;let o,l;Tp.subVectors(i,r),Ap.subVectors(a,r),iC.subVectors(e,r);const c=Tp.dot(iC),u=Ap.dot(iC);if(c<=0&&u<=0)return n.copy(r);aC.subVectors(e,i);const d=Tp.dot(aC),f=Ap.dot(aC);if(d>=0&&f<=d)return n.copy(i);const p=c*f-d*u;if(p<=0&&c>=0&&d<=0)return o=c/(c-d),n.copy(r).addScaledVector(Tp,o);sC.subVectors(e,a);const m=Tp.dot(sC),x=Ap.dot(sC);if(x>=0&&m<=x)return n.copy(a);const b=m*u-c*x;if(b<=0&&u>=0&&x<=0)return l=u/(u-x),n.copy(r).addScaledVector(Ap,l);const y=d*x-m*f;if(y<=0&&f-d>=0&&m-x>=0)return G$.subVectors(a,i),l=(f-d)/(f-d+(m-x)),n.copy(i).addScaledVector(G$,l);const v=1/(y+b+p);return o=b*v,l=p*v,n.copy(r).addScaledVector(Tp,o).addScaledVector(Ap,l)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}};const mJ={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},Ed={h:0,s:0,l:0},s_={h:0,s:0,l:0};function uC(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+(e-t)*6*n:n<1/2?e:n<2/3?t+(e-t)*6*(2/3-n):t}let Bn=class{constructor(e,n,r){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,n,r)}set(e,n,r){if(n===void 0&&r===void 0){const i=e;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(e,n,r);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,n=Vo){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,or.colorSpaceToWorking(this,n),this}setRGB(e,n,r,i=or.workingColorSpace){return this.r=e,this.g=n,this.b=r,or.colorSpaceToWorking(this,i),this}setHSL(e,n,r,i=or.workingColorSpace){if(e=sPe(e,1),n=zn(n,0,1),r=zn(r,0,1),n===0)this.r=this.g=this.b=r;else{const a=r<=.5?r*(1+n):r+n-r*n,o=2*r-a;this.r=uC(o,a,e+1/3),this.g=uC(o,a,e),this.b=uC(o,a,e-1/3)}return or.colorSpaceToWorking(this,i),this}setStyle(e,n=Vo){function r(a){a!==void 0&&parseFloat(a)<1&&gn("Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let a;const o=i[1],l=i[2];switch(o){case"rgb":case"rgba":if(a=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return r(a[4]),this.setRGB(Math.min(255,parseInt(a[1],10))/255,Math.min(255,parseInt(a[2],10))/255,Math.min(255,parseInt(a[3],10))/255,n);if(a=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return r(a[4]),this.setRGB(Math.min(100,parseInt(a[1],10))/100,Math.min(100,parseInt(a[2],10))/100,Math.min(100,parseInt(a[3],10))/100,n);break;case"hsl":case"hsla":if(a=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return r(a[4]),this.setHSL(parseFloat(a[1])/360,parseFloat(a[2])/100,parseFloat(a[3])/100,n);break;default:gn("Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const a=i[1],o=a.length;if(o===3)return this.setRGB(parseInt(a.charAt(0),16)/15,parseInt(a.charAt(1),16)/15,parseInt(a.charAt(2),16)/15,n);if(o===6)return this.setHex(parseInt(a,16),n);gn("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,n);return this}setColorName(e,n=Vo){const r=mJ[e.toLowerCase()];return r!==void 0?this.setHex(r,n):gn("Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Au(e.r),this.g=Au(e.g),this.b=Au(e.b),this}copyLinearToSRGB(e){return this.r=Cg(e.r),this.g=Cg(e.g),this.b=Cg(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Vo){return or.workingToColorSpace(Va.copy(this),e),Math.round(zn(Va.r*255,0,255))*65536+Math.round(zn(Va.g*255,0,255))*256+Math.round(zn(Va.b*255,0,255))}getHexString(e=Vo){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=or.workingColorSpace){or.workingToColorSpace(Va.copy(this),n);const r=Va.r,i=Va.g,a=Va.b,o=Math.max(r,i,a),l=Math.min(r,i,a);let c,u;const d=(l+o)/2;if(l===o)c=0,u=0;else{const f=o-l;switch(u=d<=.5?f/(o+l):f/(2-o-l),o){case r:c=(i-a)/f+(i<a?6:0);break;case i:c=(a-r)/f+2;break;case a:c=(r-i)/f+4;break}c/=6}return e.h=c,e.s=u,e.l=d,e}getRGB(e,n=or.workingColorSpace){return or.workingToColorSpace(Va.copy(this),n),e.r=Va.r,e.g=Va.g,e.b=Va.b,e}getStyle(e=Vo){or.workingToColorSpace(Va.copy(this),e);const n=Va.r,r=Va.g,i=Va.b;return e!==Vo?`color(${e} ${n.toFixed(3)} ${r.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(n*255)},${Math.round(r*255)},${Math.round(i*255)})`}offsetHSL(e,n,r){return this.getHSL(Ed),this.setHSL(Ed.h+e,Ed.s+n,Ed.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(Ed),e.getHSL(s_);const r=qA(Ed.h,s_.h,n),i=qA(Ed.s,s_.s,n),a=qA(Ed.l,s_.l,n);return this.setHSL(r,i,a),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const n=this.r,r=this.g,i=this.b,a=e.elements;return this.r=a[0]*n+a[3]*r+a[6]*i,this.g=a[1]*n+a[4]*r+a[7]*i,this.b=a[2]*n+a[5]*r+a[8]*i,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,n=0){return this.r=e[n],this.g=e[n+1],this.b=e[n+2],this}toArray(e=[],n=0){return e[n]=this.r,e[n+1]=this.g,e[n+2]=this.b,e}fromBufferAttribute(e,n){return this.r=e.getX(n),this.g=e.getY(n),this.b=e.getZ(n),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}};const Va=new Bn;Bn.NAMES=mJ;let wPe=0,jx=class extends Cm{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:wPe++}),this.uuid=hv(),this.name="",this.type="Material",this.blending=Ag,this.side=kh,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=S3,this.blendDst=M3,this.blendEquation=Mf,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Bn(0,0,0),this.blendAlpha=0,this.depthFunc=Qg,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=C$,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=vp,this.stencilZFail=vp,this.stencilZPass=vp,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const n in e){const r=e[n];if(r===void 0){gn(`Material: parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){gn(`Material: '${n}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(r):i&&i.isVector3&&r&&r.isVector3?i.copy(r):this[n]=r}}toJSON(e){const n=e===void 0||typeof e=="string";n&&(e={textures:{},images:{}});const r={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.color&&this.color.isColor&&(r.color=this.color.getHex()),this.roughness!==void 0&&(r.roughness=this.roughness),this.metalness!==void 0&&(r.metalness=this.metalness),this.sheen!==void 0&&(r.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(r.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(r.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(r.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(r.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(r.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(r.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(r.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(r.shininess=this.shininess),this.clearcoat!==void 0&&(r.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(r.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(r.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(r.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(r.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,r.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(r.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(r.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(r.dispersion=this.dispersion),this.iridescence!==void 0&&(r.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(r.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(r.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(r.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(r.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(r.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(r.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(r.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(r.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(r.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(r.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(r.lightMap=this.lightMap.toJSON(e).uuid,r.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(r.aoMap=this.aoMap.toJSON(e).uuid,r.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(r.bumpMap=this.bumpMap.toJSON(e).uuid,r.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(r.normalMap=this.normalMap.toJSON(e).uuid,r.normalMapType=this.normalMapType,r.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(r.displacementMap=this.displacementMap.toJSON(e).uuid,r.displacementScale=this.displacementScale,r.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(r.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(r.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(r.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(r.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(r.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(r.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(r.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(r.combine=this.combine)),this.envMapRotation!==void 0&&(r.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(r.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(r.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(r.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(r.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(r.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(r.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(r.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(r.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(r.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(r.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(r.size=this.size),this.shadowSide!==null&&(r.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(r.sizeAttenuation=this.sizeAttenuation),this.blending!==Ag&&(r.blending=this.blending),this.side!==kh&&(r.side=this.side),this.vertexColors===!0&&(r.vertexColors=!0),this.opacity<1&&(r.opacity=this.opacity),this.transparent===!0&&(r.transparent=!0),this.blendSrc!==S3&&(r.blendSrc=this.blendSrc),this.blendDst!==M3&&(r.blendDst=this.blendDst),this.blendEquation!==Mf&&(r.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(r.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(r.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(r.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(r.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(r.blendAlpha=this.blendAlpha),this.depthFunc!==Qg&&(r.depthFunc=this.depthFunc),this.depthTest===!1&&(r.depthTest=this.depthTest),this.depthWrite===!1&&(r.depthWrite=this.depthWrite),this.colorWrite===!1&&(r.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(r.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==C$&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==vp&&(r.stencilFail=this.stencilFail),this.stencilZFail!==vp&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==vp&&(r.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(r.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(r.rotation=this.rotation),this.polygonOffset===!0&&(r.polygonOffset=!0),this.polygonOffsetFactor!==0&&(r.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(r.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(r.linewidth=this.linewidth),this.dashSize!==void 0&&(r.dashSize=this.dashSize),this.gapSize!==void 0&&(r.gapSize=this.gapSize),this.scale!==void 0&&(r.scale=this.scale),this.dithering===!0&&(r.dithering=!0),this.alphaTest>0&&(r.alphaTest=this.alphaTest),this.alphaHash===!0&&(r.alphaHash=!0),this.alphaToCoverage===!0&&(r.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(r.premultipliedAlpha=!0),this.forceSinglePass===!0&&(r.forceSinglePass=!0),this.wireframe===!0&&(r.wireframe=!0),this.wireframeLinewidth>1&&(r.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(r.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(r.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(r.flatShading=!0),this.visible===!1&&(r.visible=!1),this.toneMapped===!1&&(r.toneMapped=!1),this.fog===!1&&(r.fog=!1),Object.keys(this.userData).length>0&&(r.userData=this.userData);function i(a){const o=[];for(const l in a){const c=a[l];delete c.metadata,o.push(c)}return o}if(n){const a=i(e.textures),o=i(e.images);a.length>0&&(r.textures=a),o.length>0&&(r.images=o)}return r}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const n=e.clippingPlanes;let r=null;if(n!==null){const i=n.length;r=new Array(i);for(let a=0;a!==i;++a)r[a]=n[a].clone()}return this.clippingPlanes=r,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}},Z4=class extends jx{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Bn(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Eh,this.combine=H4,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}};const Ri=new dt,o_=new Tn;let _Pe=0,nl=class{constructor(e,n,r=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:_Pe++}),this.name="",this.array=e,this.itemSize=n,this.count=e!==void 0?e.length/n:0,this.normalized=r,this.usage=j$,this.updateRanges=[],this.gpuType=wu,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,n){this.updateRanges.push({start:e,count:n})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,n,r){e*=this.itemSize,r*=n.itemSize;for(let i=0,a=this.itemSize;i<a;i++)this.array[e+i]=n.array[r+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let n=0,r=this.count;n<r;n++)o_.fromBufferAttribute(this,n),o_.applyMatrix3(e),this.setXY(n,o_.x,o_.y);else if(this.itemSize===3)for(let n=0,r=this.count;n<r;n++)Ri.fromBufferAttribute(this,n),Ri.applyMatrix3(e),this.setXYZ(n,Ri.x,Ri.y,Ri.z);return this}applyMatrix4(e){for(let n=0,r=this.count;n<r;n++)Ri.fromBufferAttribute(this,n),Ri.applyMatrix4(e),this.setXYZ(n,Ri.x,Ri.y,Ri.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)Ri.fromBufferAttribute(this,n),Ri.applyNormalMatrix(e),this.setXYZ(n,Ri.x,Ri.y,Ri.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)Ri.fromBufferAttribute(this,n),Ri.transformDirection(e),this.setXYZ(n,Ri.x,Ri.y,Ri.z);return this}set(e,n=0){return this.array.set(e,n),this}getComponent(e,n){let r=this.array[e*this.itemSize+n];return this.normalized&&(r=Ub(r,this.array)),r}setComponent(e,n,r){return this.normalized&&(r=Cs(r,this.array)),this.array[e*this.itemSize+n]=r,this}getX(e){let n=this.array[e*this.itemSize];return this.normalized&&(n=Ub(n,this.array)),n}setX(e,n){return this.normalized&&(n=Cs(n,this.array)),this.array[e*this.itemSize]=n,this}getY(e){let n=this.array[e*this.itemSize+1];return this.normalized&&(n=Ub(n,this.array)),n}setY(e,n){return this.normalized&&(n=Cs(n,this.array)),this.array[e*this.itemSize+1]=n,this}getZ(e){let n=this.array[e*this.itemSize+2];return this.normalized&&(n=Ub(n,this.array)),n}setZ(e,n){return this.normalized&&(n=Cs(n,this.array)),this.array[e*this.itemSize+2]=n,this}getW(e){let n=this.array[e*this.itemSize+3];return this.normalized&&(n=Ub(n,this.array)),n}setW(e,n){return this.normalized&&(n=Cs(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,r){return e*=this.itemSize,this.normalized&&(n=Cs(n,this.array),r=Cs(r,this.array)),this.array[e+0]=n,this.array[e+1]=r,this}setXYZ(e,n,r,i){return e*=this.itemSize,this.normalized&&(n=Cs(n,this.array),r=Cs(r,this.array),i=Cs(i,this.array)),this.array[e+0]=n,this.array[e+1]=r,this.array[e+2]=i,this}setXYZW(e,n,r,i,a){return e*=this.itemSize,this.normalized&&(n=Cs(n,this.array),r=Cs(r,this.array),i=Cs(i,this.array),a=Cs(a,this.array)),this.array[e+0]=n,this.array[e+1]=r,this.array[e+2]=i,this.array[e+3]=a,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==j$&&(e.usage=this.usage),e}},pJ=class extends nl{constructor(e,n,r){super(new Uint16Array(e),n,r)}},gJ=class extends nl{constructor(e,n,r){super(new Uint32Array(e),n,r)}},Ll=class extends nl{constructor(e,n,r){super(new Float32Array(e),n,r)}},SPe=0;const Lo=new Vi,dC=new vo,Cp=new dt,ro=new bm,Vb=new bm,da=new dt;let Ac=class xJ extends Cm{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:SPe++}),this.uuid=hv(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(sJ(e)?gJ:pJ)(e,1):this.index=e,this}setIndirect(e){return this.indirect=e,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,n){return this.attributes[e]=n,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,n,r=0){this.groups.push({start:e,count:n,materialIndex:r})}clearGroups(){this.groups=[]}setDrawRange(e,n){this.drawRange.start=e,this.drawRange.count=n}applyMatrix4(e){const n=this.attributes.position;n!==void 0&&(n.applyMatrix4(e),n.needsUpdate=!0);const r=this.attributes.normal;if(r!==void 0){const a=new Pn().getNormalMatrix(e);r.applyNormalMatrix(a),r.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Lo.makeRotationFromQuaternion(e),this.applyMatrix4(Lo),this}rotateX(e){return Lo.makeRotationX(e),this.applyMatrix4(Lo),this}rotateY(e){return Lo.makeRotationY(e),this.applyMatrix4(Lo),this}rotateZ(e){return Lo.makeRotationZ(e),this.applyMatrix4(Lo),this}translate(e,n,r){return Lo.makeTranslation(e,n,r),this.applyMatrix4(Lo),this}scale(e,n,r){return Lo.makeScale(e,n,r),this.applyMatrix4(Lo),this}lookAt(e){return dC.lookAt(e),dC.updateMatrix(),this.applyMatrix4(dC.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Cp).negate(),this.translate(Cp.x,Cp.y,Cp.z),this}setFromPoints(e){const n=this.getAttribute("position");if(n===void 0){const r=[];for(let i=0,a=e.length;i<a;i++){const o=e[i];r.push(o.x,o.y,o.z||0)}this.setAttribute("position",new Ll(r,3))}else{const r=Math.min(e.length,n.count);for(let i=0;i<r;i++){const a=e[i];n.setXYZ(i,a.x,a.y,a.z||0)}e.length>n.count&&gn("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),n.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new bm);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Ei("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new dt(-1/0,-1/0,-1/0),new dt(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),n)for(let r=0,i=n.length;r<i;r++){const a=n[r];ro.setFromBufferAttribute(a),this.morphTargetsRelative?(da.addVectors(this.boundingBox.min,ro.min),this.boundingBox.expandByPoint(da),da.addVectors(this.boundingBox.max,ro.max),this.boundingBox.expandByPoint(da)):(this.boundingBox.expandByPoint(ro.min),this.boundingBox.expandByPoint(ro.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Ei('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new m2);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Ei("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new dt,1/0);return}if(e){const r=this.boundingSphere.center;if(ro.setFromBufferAttribute(e),n)for(let a=0,o=n.length;a<o;a++){const l=n[a];Vb.setFromBufferAttribute(l),this.morphTargetsRelative?(da.addVectors(ro.min,Vb.min),ro.expandByPoint(da),da.addVectors(ro.max,Vb.max),ro.expandByPoint(da)):(ro.expandByPoint(Vb.min),ro.expandByPoint(Vb.max))}ro.getCenter(r);let i=0;for(let a=0,o=e.count;a<o;a++)da.fromBufferAttribute(e,a),i=Math.max(i,r.distanceToSquared(da));if(n)for(let a=0,o=n.length;a<o;a++){const l=n[a],c=this.morphTargetsRelative;for(let u=0,d=l.count;u<d;u++)da.fromBufferAttribute(l,u),c&&(Cp.fromBufferAttribute(e,u),da.add(Cp)),i=Math.max(i,r.distanceToSquared(da))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&Ei('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,n=this.attributes;if(e===null||n.position===void 0||n.normal===void 0||n.uv===void 0){Ei("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const r=n.position,i=n.normal,a=n.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new nl(new Float32Array(4*r.count),4));const o=this.getAttribute("tangent"),l=[],c=[];for(let D=0;D<r.count;D++)l[D]=new dt,c[D]=new dt;const u=new dt,d=new dt,f=new dt,p=new Tn,m=new Tn,x=new Tn,b=new dt,y=new dt;function v(D,A,R){u.fromBufferAttribute(r,D),d.fromBufferAttribute(r,A),f.fromBufferAttribute(r,R),p.fromBufferAttribute(a,D),m.fromBufferAttribute(a,A),x.fromBufferAttribute(a,R),d.sub(u),f.sub(u),m.sub(p),x.sub(p);const U=1/(m.x*x.y-x.x*m.y);isFinite(U)&&(b.copy(d).multiplyScalar(x.y).addScaledVector(f,-m.y).multiplyScalar(U),y.copy(f).multiplyScalar(m.x).addScaledVector(d,-x.x).multiplyScalar(U),l[D].add(b),l[A].add(b),l[R].add(b),c[D].add(y),c[A].add(y),c[R].add(y))}let S=this.groups;S.length===0&&(S=[{start:0,count:e.count}]);for(let D=0,A=S.length;D<A;++D){const R=S[D],U=R.start,F=R.count;for(let $=U,j=U+F;$<j;$+=3)v(e.getX($+0),e.getX($+1),e.getX($+2))}const N=new dt,T=new dt,k=new dt,C=new dt;function E(D){k.fromBufferAttribute(i,D),C.copy(k);const A=l[D];N.copy(A),N.sub(k.multiplyScalar(k.dot(A))).normalize(),T.crossVectors(C,A);const U=T.dot(c[D])<0?-1:1;o.setXYZW(D,N.x,N.y,N.z,U)}for(let D=0,A=S.length;D<A;++D){const R=S[D],U=R.start,F=R.count;for(let $=U,j=U+F;$<j;$+=3)E(e.getX($+0)),E(e.getX($+1)),E(e.getX($+2))}}computeVertexNormals(){const e=this.index,n=this.getAttribute("position");if(n!==void 0){let r=this.getAttribute("normal");if(r===void 0)r=new nl(new Float32Array(n.count*3),3),this.setAttribute("normal",r);else for(let p=0,m=r.count;p<m;p++)r.setXYZ(p,0,0,0);const i=new dt,a=new dt,o=new dt,l=new dt,c=new dt,u=new dt,d=new dt,f=new dt;if(e)for(let p=0,m=e.count;p<m;p+=3){const x=e.getX(p+0),b=e.getX(p+1),y=e.getX(p+2);i.fromBufferAttribute(n,x),a.fromBufferAttribute(n,b),o.fromBufferAttribute(n,y),d.subVectors(o,a),f.subVectors(i,a),d.cross(f),l.fromBufferAttribute(r,x),c.fromBufferAttribute(r,b),u.fromBufferAttribute(r,y),l.add(d),c.add(d),u.add(d),r.setXYZ(x,l.x,l.y,l.z),r.setXYZ(b,c.x,c.y,c.z),r.setXYZ(y,u.x,u.y,u.z)}else for(let p=0,m=n.count;p<m;p+=3)i.fromBufferAttribute(n,p+0),a.fromBufferAttribute(n,p+1),o.fromBufferAttribute(n,p+2),d.subVectors(o,a),f.subVectors(i,a),d.cross(f),r.setXYZ(p+0,d.x,d.y,d.z),r.setXYZ(p+1,d.x,d.y,d.z),r.setXYZ(p+2,d.x,d.y,d.z);this.normalizeNormals(),r.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let n=0,r=e.count;n<r;n++)da.fromBufferAttribute(e,n),da.normalize(),e.setXYZ(n,da.x,da.y,da.z)}toNonIndexed(){function e(l,c){const u=l.array,d=l.itemSize,f=l.normalized,p=new u.constructor(c.length*d);let m=0,x=0;for(let b=0,y=c.length;b<y;b++){l.isInterleavedBufferAttribute?m=c[b]*l.data.stride+l.offset:m=c[b]*d;for(let v=0;v<d;v++)p[x++]=u[m++]}return new nl(p,d,f)}if(this.index===null)return gn("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new xJ,r=this.index.array,i=this.attributes;for(const l in i){const c=i[l],u=e(c,r);n.setAttribute(l,u)}const a=this.morphAttributes;for(const l in a){const c=[],u=a[l];for(let d=0,f=u.length;d<f;d++){const p=u[d],m=e(p,r);c.push(m)}n.morphAttributes[l]=c}n.morphTargetsRelative=this.morphTargetsRelative;const o=this.groups;for(let l=0,c=o.length;l<c;l++){const u=o[l];n.addGroup(u.start,u.count,u.materialIndex)}return n}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const c=this.parameters;for(const u in c)c[u]!==void 0&&(e[u]=c[u]);return e}e.data={attributes:{}};const n=this.index;n!==null&&(e.data.index={type:n.array.constructor.name,array:Array.prototype.slice.call(n.array)});const r=this.attributes;for(const c in r){const u=r[c];e.data.attributes[c]=u.toJSON(e.data)}const i={};let a=!1;for(const c in this.morphAttributes){const u=this.morphAttributes[c],d=[];for(let f=0,p=u.length;f<p;f++){const m=u[f];d.push(m.toJSON(e.data))}d.length>0&&(i[c]=d,a=!0)}a&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));const l=this.boundingSphere;return l!==null&&(e.data.boundingSphere=l.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const n={};this.name=e.name;const r=e.index;r!==null&&this.setIndex(r.clone());const i=e.attributes;for(const u in i){const d=i[u];this.setAttribute(u,d.clone(n))}const a=e.morphAttributes;for(const u in a){const d=[],f=a[u];for(let p=0,m=f.length;p<m;p++)d.push(f[p].clone(n));this.morphAttributes[u]=d}this.morphTargetsRelative=e.morphTargetsRelative;const o=e.groups;for(let u=0,d=o.length;u<d;u++){const f=o[u];this.addGroup(f.start,f.count,f.materialIndex)}const l=e.boundingBox;l!==null&&(this.boundingBox=l.clone());const c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}};const q$=new Vi,cf=new Q4,l_=new m2,W$=new dt,c_=new dt,u_=new dt,d_=new dt,hC=new dt,h_=new dt,K$=new dt,f_=new dt;let vc=class extends vo{constructor(e=new Ac,n=new Z4){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=n,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,n){return super.copy(e,n),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const n=this.geometry.morphAttributes,r=Object.keys(n);if(r.length>0){const i=n[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let a=0,o=i.length;a<o;a++){const l=i[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[l]=a}}}}getVertexPosition(e,n){const r=this.geometry,i=r.attributes.position,a=r.morphAttributes.position,o=r.morphTargetsRelative;n.fromBufferAttribute(i,e);const l=this.morphTargetInfluences;if(a&&l){h_.set(0,0,0);for(let c=0,u=a.length;c<u;c++){const d=l[c],f=a[c];d!==0&&(hC.fromBufferAttribute(f,e),o?h_.addScaledVector(hC,d):h_.addScaledVector(hC.sub(n),d))}n.add(h_)}return n}raycast(e,n){const r=this.geometry,i=this.material,a=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),l_.copy(r.boundingSphere),l_.applyMatrix4(a),cf.copy(e.ray).recast(e.near),!(l_.containsPoint(cf.origin)===!1&&(cf.intersectSphere(l_,W$)===null||cf.origin.distanceToSquared(W$)>(e.far-e.near)**2))&&(q$.copy(a).invert(),cf.copy(e.ray).applyMatrix4(q$),!(r.boundingBox!==null&&cf.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,n,cf)))}_computeIntersections(e,n,r){let i;const a=this.geometry,o=this.material,l=a.index,c=a.attributes.position,u=a.attributes.uv,d=a.attributes.uv1,f=a.attributes.normal,p=a.groups,m=a.drawRange;if(l!==null)if(Array.isArray(o))for(let x=0,b=p.length;x<b;x++){const y=p[x],v=o[y.materialIndex],S=Math.max(y.start,m.start),N=Math.min(l.count,Math.min(y.start+y.count,m.start+m.count));for(let T=S,k=N;T<k;T+=3){const C=l.getX(T),E=l.getX(T+1),D=l.getX(T+2);i=m_(this,v,e,r,u,d,f,C,E,D),i&&(i.faceIndex=Math.floor(T/3),i.face.materialIndex=y.materialIndex,n.push(i))}}else{const x=Math.max(0,m.start),b=Math.min(l.count,m.start+m.count);for(let y=x,v=b;y<v;y+=3){const S=l.getX(y),N=l.getX(y+1),T=l.getX(y+2);i=m_(this,o,e,r,u,d,f,S,N,T),i&&(i.faceIndex=Math.floor(y/3),n.push(i))}}else if(c!==void 0)if(Array.isArray(o))for(let x=0,b=p.length;x<b;x++){const y=p[x],v=o[y.materialIndex],S=Math.max(y.start,m.start),N=Math.min(c.count,Math.min(y.start+y.count,m.start+m.count));for(let T=S,k=N;T<k;T+=3){const C=T,E=T+1,D=T+2;i=m_(this,v,e,r,u,d,f,C,E,D),i&&(i.faceIndex=Math.floor(T/3),i.face.materialIndex=y.materialIndex,n.push(i))}}else{const x=Math.max(0,m.start),b=Math.min(c.count,m.start+m.count);for(let y=x,v=b;y<v;y+=3){const S=y,N=y+1,T=y+2;i=m_(this,o,e,r,u,d,f,S,N,T),i&&(i.faceIndex=Math.floor(y/3),n.push(i))}}}};function MPe(t,e,n,r,i,a,o,l){let c;if(e.side===Us?c=r.intersectTriangle(o,a,i,!0,l):c=r.intersectTriangle(i,a,o,e.side===kh,l),c===null)return null;f_.copy(l),f_.applyMatrix4(t.matrixWorld);const u=n.ray.origin.distanceTo(f_);return u<n.near||u>n.far?null:{distance:u,point:f_.clone(),object:t}}function m_(t,e,n,r,i,a,o,l,c,u){t.getVertexPosition(l,c_),t.getVertexPosition(c,u_),t.getVertexPosition(u,d_);const d=MPe(t,e,n,r,c_,u_,d_,K$);if(d){const f=new dt;$b.getBarycoord(K$,c_,u_,d_,f),i&&(d.uv=$b.getInterpolatedAttribute(i,l,c,u,f,new Tn)),a&&(d.uv1=$b.getInterpolatedAttribute(a,l,c,u,f,new Tn)),o&&(d.normal=$b.getInterpolatedAttribute(o,l,c,u,f,new dt),d.normal.dot(r.direction)>0&&d.normal.multiplyScalar(-1));const p={a:l,b:c,c:u,normal:new dt,materialIndex:0};$b.getNormal(c_,u_,d_,p.normal),d.face=p,d.barycoord=f}return d}let J4=class bJ extends Ac{constructor(e=1,n=1,r=1,i=1,a=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:n,depth:r,widthSegments:i,heightSegments:a,depthSegments:o};const l=this;i=Math.floor(i),a=Math.floor(a),o=Math.floor(o);const c=[],u=[],d=[],f=[];let p=0,m=0;x("z","y","x",-1,-1,r,n,e,o,a,0),x("z","y","x",1,-1,r,n,-e,o,a,1),x("x","z","y",1,1,e,r,n,i,o,2),x("x","z","y",1,-1,e,r,-n,i,o,3),x("x","y","z",1,-1,e,n,r,i,a,4),x("x","y","z",-1,-1,e,n,-r,i,a,5),this.setIndex(c),this.setAttribute("position",new Ll(u,3)),this.setAttribute("normal",new Ll(d,3)),this.setAttribute("uv",new Ll(f,2));function x(b,y,v,S,N,T,k,C,E,D,A){const R=T/E,U=k/D,F=T/2,$=k/2,j=C/2,H=E+1,K=D+1;let V=0,Q=0;const Z=new dt;for(let ae=0;ae<K;ae++){const B=ae*U-$;for(let X=0;X<H;X++){const ne=X*R-F;Z[b]=ne*S,Z[y]=B*N,Z[v]=j,u.push(Z.x,Z.y,Z.z),Z[b]=0,Z[y]=0,Z[v]=C>0?1:-1,d.push(Z.x,Z.y,Z.z),f.push(X/E),f.push(1-ae/D),V+=1}}for(let ae=0;ae<D;ae++)for(let B=0;B<E;B++){const X=p+B+H*ae,ne=p+B+H*(ae+1),se=p+(B+1)+H*(ae+1),be=p+(B+1)+H*ae;c.push(X,ne,be),c.push(ne,se,be),Q+=6}l.addGroup(m,Q,A),m+=Q,p+=V}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new bJ(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};function tx(t){const e={};for(const n in t){e[n]={};for(const r in t[n]){const i=t[n][r];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?i.isRenderTargetTexture?(gn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[n][r]=null):e[n][r]=i.clone():Array.isArray(i)?e[n][r]=i.slice():e[n][r]=i}}return e}function cs(t){const e={};for(let n=0;n<t.length;n++){const r=tx(t[n]);for(const i in r)e[i]=r[i]}return e}function NPe(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function yJ(t){const e=t.getRenderTarget();return e===null?t.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:or.workingColorSpace}const kPe={clone:tx,merge:cs};var EPe=`void main() {
- gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
- }`,TPe=`void main() {
- gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
- }`;let $u=class extends jx{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=EPe,this.fragmentShader=TPe,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=tx(e.uniforms),this.uniformsGroups=NPe(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){const n=super.toJSON(e);n.glslVersion=this.glslVersion,n.uniforms={};for(const i in this.uniforms){const o=this.uniforms[i].value;o&&o.isTexture?n.uniforms[i]={type:"t",value:o.toJSON(e).uuid}:o&&o.isColor?n.uniforms[i]={type:"c",value:o.getHex()}:o&&o.isVector2?n.uniforms[i]={type:"v2",value:o.toArray()}:o&&o.isVector3?n.uniforms[i]={type:"v3",value:o.toArray()}:o&&o.isVector4?n.uniforms[i]={type:"v4",value:o.toArray()}:o&&o.isMatrix3?n.uniforms[i]={type:"m3",value:o.toArray()}:o&&o.isMatrix4?n.uniforms[i]={type:"m4",value:o.toArray()}:n.uniforms[i]={value:o}}Object.keys(this.defines).length>0&&(n.defines=this.defines),n.vertexShader=this.vertexShader,n.fragmentShader=this.fragmentShader,n.lights=this.lights,n.clipping=this.clipping;const r={};for(const i in this.extensions)this.extensions[i]===!0&&(r[i]=!0);return Object.keys(r).length>0&&(n.extensions=r),n}},vJ=class extends vo{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Vi,this.projectionMatrix=new Vi,this.projectionMatrixInverse=new Vi,this.coordinateSystem=lc,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,n){return super.copy(e,n),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,n){super.updateWorldMatrix(e,n),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}};const Td=new dt,X$=new Tn,Y$=new Tn;let Wo=class extends vJ{constructor(e=50,n=1,r=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=r,this.far=i,this.focus=10,this.aspect=n,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,n){return super.copy(e,n),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const n=.5*this.getFilmHeight()/e;this.fov=uD*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(T1*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return uD*2*Math.atan(Math.tan(T1*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,n,r){Td.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(Td.x,Td.y).multiplyScalar(-e/Td.z),Td.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),r.set(Td.x,Td.y).multiplyScalar(-e/Td.z)}getViewSize(e,n){return this.getViewBounds(e,X$,Y$),n.subVectors(Y$,X$)}setViewOffset(e,n,r,i,a,o){this.aspect=e/n,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=n,this.view.offsetX=r,this.view.offsetY=i,this.view.width=a,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let n=e*Math.tan(T1*.5*this.fov)/this.zoom,r=2*n,i=this.aspect*r,a=-.5*i;const o=this.view;if(this.view!==null&&this.view.enabled){const c=o.fullWidth,u=o.fullHeight;a+=o.offsetX*i/c,n-=o.offsetY*r/u,i*=o.width/c,r*=o.height/u}const l=this.filmOffset;l!==0&&(a+=e*l/this.getFilmWidth()),this.projectionMatrix.makePerspective(a,a+i,n,n-r,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const n=super.toJSON(e);return n.object.fov=this.fov,n.object.zoom=this.zoom,n.object.near=this.near,n.object.far=this.far,n.object.focus=this.focus,n.object.aspect=this.aspect,this.view!==null&&(n.object.view=Object.assign({},this.view)),n.object.filmGauge=this.filmGauge,n.object.filmOffset=this.filmOffset,n}};const jp=-90,Pp=1;let APe=class extends vo{constructor(e,n,r){super(),this.type="CubeCamera",this.renderTarget=r,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new Wo(jp,Pp,e,n);i.layers=this.layers,this.add(i);const a=new Wo(jp,Pp,e,n);a.layers=this.layers,this.add(a);const o=new Wo(jp,Pp,e,n);o.layers=this.layers,this.add(o);const l=new Wo(jp,Pp,e,n);l.layers=this.layers,this.add(l);const c=new Wo(jp,Pp,e,n);c.layers=this.layers,this.add(c);const u=new Wo(jp,Pp,e,n);u.layers=this.layers,this.add(u)}updateCoordinateSystem(){const e=this.coordinateSystem,n=this.children.concat(),[r,i,a,o,l,c]=n;for(const u of n)this.remove(u);if(e===lc)r.up.set(0,1,0),r.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),a.up.set(0,0,-1),a.lookAt(0,1,0),o.up.set(0,0,1),o.lookAt(0,-1,0),l.up.set(0,1,0),l.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(e===KS)r.up.set(0,-1,0),r.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),a.up.set(0,0,1),a.lookAt(0,1,0),o.up.set(0,0,-1),o.lookAt(0,-1,0),l.up.set(0,-1,0),l.lookAt(0,0,1),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const u of n)this.add(u),u.updateMatrixWorld()}update(e,n){this.parent===null&&this.updateMatrixWorld();const{renderTarget:r,activeMipmapLevel:i}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[a,o,l,c,u,d]=this.children,f=e.getRenderTarget(),p=e.getActiveCubeFace(),m=e.getActiveMipmapLevel(),x=e.xr.enabled;e.xr.enabled=!1;const b=r.texture.generateMipmaps;r.texture.generateMipmaps=!1,e.setRenderTarget(r,0,i),e.render(n,a),e.setRenderTarget(r,1,i),e.render(n,o),e.setRenderTarget(r,2,i),e.render(n,l),e.setRenderTarget(r,3,i),e.render(n,c),e.setRenderTarget(r,4,i),e.render(n,u),r.texture.generateMipmaps=b,e.setRenderTarget(r,5,i),e.render(n,d),e.setRenderTarget(f,p,m),e.xr.enabled=x,r.texture.needsPMREMUpdate=!0}},wJ=class extends Hl{constructor(e=[],n=Zg,r,i,a,o,l,c,u,d){super(e,n,r,i,a,o,l,c,u,d),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},CPe=class extends xm{constructor(e=1,n={}){super(e,e,n),this.isWebGLCubeRenderTarget=!0;const r={width:e,height:e,depth:1},i=[r,r,r,r,r,r];this.texture=new wJ(i),this._setTextureOptions(n),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,n){this.texture.type=n.type,this.texture.colorSpace=n.colorSpace,this.texture.generateMipmaps=n.generateMipmaps,this.texture.minFilter=n.minFilter,this.texture.magFilter=n.magFilter;const r={uniforms:{tEquirect:{value:null}},vertexShader:`
- 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 J4(5,5,5),a=new $u({name:"CubemapFromEquirect",uniforms:tx(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:Us,blending:Tu});a.uniforms.tEquirect.value=n;const o=new vc(i,a),l=n.minFilter;return n.minFilter===Of&&(n.minFilter=el),new APe(1,10,this).update(e,o),n.minFilter=l,o.geometry.dispose(),o.material.dispose(),this}clear(e,n=!0,r=!0,i=!0){const a=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(n,r,i);e.setRenderTarget(a)}},o0=class extends vo{constructor(){super(),this.isGroup=!0,this.type="Group"}};const jPe={type:"move"};let fC=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new o0,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new o0,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new dt,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new dt),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new o0,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new dt,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new dt),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const n=this._hand;if(n)for(const r of e.hand.values())this._getHandJoint(n,r)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,n,r){let i=null,a=null,o=null;const l=this._targetRay,c=this._grip,u=this._hand;if(e&&n.session.visibilityState!=="visible-blurred"){if(u&&e.hand){o=!0;for(const b of e.hand.values()){const y=n.getJointPose(b,r),v=this._getHandJoint(u,b);y!==null&&(v.matrix.fromArray(y.transform.matrix),v.matrix.decompose(v.position,v.rotation,v.scale),v.matrixWorldNeedsUpdate=!0,v.jointRadius=y.radius),v.visible=y!==null}const d=u.joints["index-finger-tip"],f=u.joints["thumb-tip"],p=d.position.distanceTo(f.position),m=.02,x=.005;u.inputState.pinching&&p>m+x?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!u.inputState.pinching&&p<=m-x&&(u.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(a=n.getPose(e.gripSpace,r),a!==null&&(c.matrix.fromArray(a.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,a.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(a.linearVelocity)):c.hasLinearVelocity=!1,a.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(a.angularVelocity)):c.hasAngularVelocity=!1));l!==null&&(i=n.getPose(e.targetRaySpace,r),i===null&&a!==null&&(i=a),i!==null&&(l.matrix.fromArray(i.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,i.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(i.linearVelocity)):l.hasLinearVelocity=!1,i.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(i.angularVelocity)):l.hasAngularVelocity=!1,this.dispatchEvent(jPe)))}return l!==null&&(l.visible=i!==null),c!==null&&(c.visible=a!==null),u!==null&&(u.visible=o!==null),this}_getHandJoint(e,n){if(e.joints[n.jointName]===void 0){const r=new o0;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[n.jointName]=r,e.add(r)}return e.joints[n.jointName]}},PPe=class extends vo{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new Eh,this.environmentIntensity=1,this.environmentRotation=new Eh,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}},DPe=class extends Hl{constructor(e=null,n=1,r=1,i,a,o,l,c,u=po,d=po,f,p){super(null,o,l,c,u,d,i,a,f,p),this.isDataTexture=!0,this.image={data:e,width:n,height:r},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};const mC=new dt,RPe=new dt,OPe=new Pn;let Bd=class{constructor(e=new dt(1,0,0),n=0){this.isPlane=!0,this.normal=e,this.constant=n}set(e,n){return this.normal.copy(e),this.constant=n,this}setComponents(e,n,r,i){return this.normal.set(e,n,r),this.constant=i,this}setFromNormalAndCoplanarPoint(e,n){return this.normal.copy(e),this.constant=-n.dot(this.normal),this}setFromCoplanarPoints(e,n,r){const i=mC.subVectors(r,n).cross(RPe.subVectors(e,n)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,n){return n.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,n){const r=e.delta(mC),i=this.normal.dot(r);if(i===0)return this.distanceToPoint(e.start)===0?n.copy(e.start):null;const a=-(e.start.dot(this.normal)+this.constant)/i;return a<0||a>1?null:n.copy(e.start).addScaledVector(r,a)}intersectsLine(e){const n=this.distanceToPoint(e.start),r=this.distanceToPoint(e.end);return n<0&&r>0||r<0&&n>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,n){const r=n||OPe.getNormalMatrix(e),i=this.coplanarPoint(mC).applyMatrix4(e),a=this.normal.applyMatrix3(r).normalize();return this.constant=-i.dot(a),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}};const uf=new m2,LPe=new Tn(.5,.5),p_=new dt;let eL=class{constructor(e=new Bd,n=new Bd,r=new Bd,i=new Bd,a=new Bd,o=new Bd){this.planes=[e,n,r,i,a,o]}set(e,n,r,i,a,o){const l=this.planes;return l[0].copy(e),l[1].copy(n),l[2].copy(r),l[3].copy(i),l[4].copy(a),l[5].copy(o),this}copy(e){const n=this.planes;for(let r=0;r<6;r++)n[r].copy(e.planes[r]);return this}setFromProjectionMatrix(e,n=lc,r=!1){const i=this.planes,a=e.elements,o=a[0],l=a[1],c=a[2],u=a[3],d=a[4],f=a[5],p=a[6],m=a[7],x=a[8],b=a[9],y=a[10],v=a[11],S=a[12],N=a[13],T=a[14],k=a[15];if(i[0].setComponents(u-o,m-d,v-x,k-S).normalize(),i[1].setComponents(u+o,m+d,v+x,k+S).normalize(),i[2].setComponents(u+l,m+f,v+b,k+N).normalize(),i[3].setComponents(u-l,m-f,v-b,k-N).normalize(),r)i[4].setComponents(c,p,y,T).normalize(),i[5].setComponents(u-c,m-p,v-y,k-T).normalize();else if(i[4].setComponents(u-c,m-p,v-y,k-T).normalize(),n===lc)i[5].setComponents(u+c,m+p,v+y,k+T).normalize();else if(n===KS)i[5].setComponents(c,p,y,T).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+n);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),uf.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),uf.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(uf)}intersectsSprite(e){uf.center.set(0,0,0);const n=LPe.distanceTo(e.center);return uf.radius=.7071067811865476+n,uf.applyMatrix4(e.matrixWorld),this.intersectsSphere(uf)}intersectsSphere(e){const n=this.planes,r=e.center,i=-e.radius;for(let a=0;a<6;a++)if(n[a].distanceToPoint(r)<i)return!1;return!0}intersectsBox(e){const n=this.planes;for(let r=0;r<6;r++){const i=n[r];if(p_.x=i.normal.x>0?e.max.x:e.min.x,p_.y=i.normal.y>0?e.max.y:e.min.y,p_.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(p_)<0)return!1}return!0}containsPoint(e){const n=this.planes;for(let r=0;r<6;r++)if(n[r].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}},_J=class extends jx{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Bn(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}};const YS=new dt,QS=new dt,Q$=new Vi,Gb=new Q4,g_=new m2,pC=new dt,Z$=new dt;let FPe=class extends vo{constructor(e=new Ac,n=new _J){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=n,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,n){return super.copy(e,n),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const n=e.attributes.position,r=[0];for(let i=1,a=n.count;i<a;i++)YS.fromBufferAttribute(n,i-1),QS.fromBufferAttribute(n,i),r[i]=r[i-1],r[i]+=YS.distanceTo(QS);e.setAttribute("lineDistance",new Ll(r,1))}else gn("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,n){const r=this.geometry,i=this.matrixWorld,a=e.params.Line.threshold,o=r.drawRange;if(r.boundingSphere===null&&r.computeBoundingSphere(),g_.copy(r.boundingSphere),g_.applyMatrix4(i),g_.radius+=a,e.ray.intersectsSphere(g_)===!1)return;Q$.copy(i).invert(),Gb.copy(e.ray).applyMatrix4(Q$);const l=a/((this.scale.x+this.scale.y+this.scale.z)/3),c=l*l,u=this.isLineSegments?2:1,d=r.index,p=r.attributes.position;if(d!==null){const m=Math.max(0,o.start),x=Math.min(d.count,o.start+o.count);for(let b=m,y=x-1;b<y;b+=u){const v=d.getX(b),S=d.getX(b+1),N=x_(this,e,Gb,c,v,S,b);N&&n.push(N)}if(this.isLineLoop){const b=d.getX(x-1),y=d.getX(m),v=x_(this,e,Gb,c,b,y,x-1);v&&n.push(v)}}else{const m=Math.max(0,o.start),x=Math.min(p.count,o.start+o.count);for(let b=m,y=x-1;b<y;b+=u){const v=x_(this,e,Gb,c,b,b+1,b);v&&n.push(v)}if(this.isLineLoop){const b=x_(this,e,Gb,c,x-1,m,x-1);b&&n.push(b)}}}updateMorphTargets(){const n=this.geometry.morphAttributes,r=Object.keys(n);if(r.length>0){const i=n[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let a=0,o=i.length;a<o;a++){const l=i[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[l]=a}}}}};function x_(t,e,n,r,i,a,o){const l=t.geometry.attributes.position;if(YS.fromBufferAttribute(l,i),QS.fromBufferAttribute(l,a),n.distanceSqToSegment(YS,QS,pC,Z$)>r)return;pC.applyMatrix4(t.matrixWorld);const u=e.ray.origin.distanceTo(pC);if(!(u<e.near||u>e.far))return{distance:u,point:Z$.clone().applyMatrix4(t.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:t}}const J$=new dt,eV=new dt;let IPe=class extends FPe{constructor(e,n){super(e,n),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const n=e.attributes.position,r=[];for(let i=0,a=n.count;i<a;i+=2)J$.fromBufferAttribute(n,i),eV.fromBufferAttribute(n,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+J$.distanceTo(eV);e.setAttribute("lineDistance",new Ll(r,1))}else gn("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},SJ=class extends Hl{constructor(e,n,r=pm,i,a,o,l=po,c=po,u,d=fy,f=1){if(d!==fy&&d!==my)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const p={width:e,height:n,depth:f};super(p,i,a,o,l,c,d,r,u),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new Y4(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const n=super.toJSON(e);return this.compareFunction!==null&&(n.compareFunction=this.compareFunction),n}};class MJ extends Hl{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}let tL=class NJ extends Ac{constructor(e=1,n=1,r=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:n,widthSegments:r,heightSegments:i};const a=e/2,o=n/2,l=Math.floor(r),c=Math.floor(i),u=l+1,d=c+1,f=e/l,p=n/c,m=[],x=[],b=[],y=[];for(let v=0;v<d;v++){const S=v*p-o;for(let N=0;N<u;N++){const T=N*f-a;x.push(T,-S,0),b.push(0,0,1),y.push(N/l),y.push(1-v/c)}}for(let v=0;v<c;v++)for(let S=0;S<l;S++){const N=S+u*v,T=S+u*(v+1),k=S+1+u*(v+1),C=S+1+u*v;m.push(N,T,C),m.push(T,k,C)}this.setIndex(m),this.setAttribute("position",new Ll(x,3)),this.setAttribute("normal",new Ll(b,3)),this.setAttribute("uv",new Ll(y,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new NJ(e.width,e.height,e.widthSegments,e.heightSegments)}};class UPe extends jx{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Bn(16777215),this.specular=new Bn(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Bn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=iJ,this.normalScale=new Tn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Eh,this.combine=H4,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 zPe=class extends jx{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Kje,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}},BPe=class extends jx{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}},kJ=class extends vo{constructor(e,n=1){super(),this.isLight=!0,this.type="Light",this.color=new Bn(e),this.intensity=n}dispose(){}copy(e,n){return super.copy(e,n),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const n=super.toJSON(e);return n.object.color=this.color.getHex(),n.object.intensity=this.intensity,this.groundColor!==void 0&&(n.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(n.object.distance=this.distance),this.angle!==void 0&&(n.object.angle=this.angle),this.decay!==void 0&&(n.object.decay=this.decay),this.penumbra!==void 0&&(n.object.penumbra=this.penumbra),this.shadow!==void 0&&(n.object.shadow=this.shadow.toJSON()),this.target!==void 0&&(n.object.target=this.target.uuid),n}};const gC=new Vi,tV=new dt,nV=new dt;let HPe=class{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Tn(512,512),this.mapType=yc,this.map=null,this.mapPass=null,this.matrix=new Vi,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new eL,this._frameExtents=new Tn(1,1),this._viewportCount=1,this._viewports=[new Ui(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const n=this.camera,r=this.matrix;tV.setFromMatrixPosition(e.matrixWorld),n.position.copy(tV),nV.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(nV),n.updateMatrixWorld(),gC.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(gC,n.coordinateSystem,n.reversedDepth),n.reversedDepth?r.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):r.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),r.multiply(gC)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.intensity!==1&&(e.intensity=this.intensity),this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}},EJ=class extends vJ{constructor(e=-1,n=1,r=1,i=-1,a=.1,o=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=n,this.top=r,this.bottom=i,this.near=a,this.far=o,this.updateProjectionMatrix()}copy(e,n){return super.copy(e,n),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,n,r,i,a,o){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=n,this.view.offsetX=r,this.view.offsetY=i,this.view.width=a,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),n=(this.top-this.bottom)/(2*this.zoom),r=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let a=r-e,o=r+e,l=i+n,c=i-n;if(this.view!==null&&this.view.enabled){const u=(this.right-this.left)/this.view.fullWidth/this.zoom,d=(this.top-this.bottom)/this.view.fullHeight/this.zoom;a+=u*this.view.offsetX,o=a+u*this.view.width,l-=d*this.view.offsetY,c=l-d*this.view.height}this.projectionMatrix.makeOrthographic(a,o,l,c,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const n=super.toJSON(e);return n.object.zoom=this.zoom,n.object.left=this.left,n.object.right=this.right,n.object.top=this.top,n.object.bottom=this.bottom,n.object.near=this.near,n.object.far=this.far,this.view!==null&&(n.object.view=Object.assign({},this.view)),n}};class $Pe extends HPe{constructor(){super(new EJ(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class rV extends kJ{constructor(e,n){super(e,n),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(vo.DEFAULT_UP),this.updateMatrix(),this.target=new vo,this.shadow=new $Pe}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}let VPe=class extends kJ{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}},GPe=class extends Wo{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}},iV=class{constructor(e=1,n=0,r=0){this.radius=e,this.phi=n,this.theta=r}set(e,n,r){return this.radius=e,this.phi=n,this.theta=r,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=zn(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,n,r){return this.radius=Math.sqrt(e*e+n*n+r*r),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,r),this.phi=Math.acos(zn(n/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};class qPe extends IPe{constructor(e=10,n=10,r=4473924,i=8947848){r=new Bn(r),i=new Bn(i);const a=n/2,o=e/n,l=e/2,c=[],u=[];for(let p=0,m=0,x=-l;p<=n;p++,x+=o){c.push(-l,0,x,l,0,x),c.push(x,0,-l,x,0,l);const b=p===a?r:i;b.toArray(u,m),m+=3,b.toArray(u,m),m+=3,b.toArray(u,m),m+=3,b.toArray(u,m),m+=3}const d=new Ac;d.setAttribute("position",new Ll(c,3)),d.setAttribute("color",new Ll(u,3));const f=new _J({vertexColors:!0,toneMapped:!1});super(d,f),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class WPe extends Cm{constructor(e,n=null){super(),this.object=e,this.domElement=n,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(e){if(e===void 0){gn("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function aV(t,e,n,r){const i=KPe(r);switch(n){case tJ:return t*e;case rJ:return t*e/i.components*i.byteLength;case q4:return t*e/i.components*i.byteLength;case W4:return t*e*2/i.components*i.byteLength;case K4:return t*e*2/i.components*i.byteLength;case nJ:return t*e*3/i.components*i.byteLength;case Pl:return t*e*4/i.components*i.byteLength;case X4:return t*e*4/i.components*i.byteLength;case M1:case N1:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case k1:case E1:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case F3:case U3:return Math.max(t,16)*Math.max(e,8)/4;case L3:case I3:return Math.max(t,8)*Math.max(e,8)/2;case z3:case B3:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case H3:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case $3:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case V3:return Math.floor((t+4)/5)*Math.floor((e+3)/4)*16;case G3:return Math.floor((t+4)/5)*Math.floor((e+4)/5)*16;case q3:return Math.floor((t+5)/6)*Math.floor((e+4)/5)*16;case W3:return Math.floor((t+5)/6)*Math.floor((e+5)/6)*16;case K3:return Math.floor((t+7)/8)*Math.floor((e+4)/5)*16;case X3:return Math.floor((t+7)/8)*Math.floor((e+5)/6)*16;case Y3:return Math.floor((t+7)/8)*Math.floor((e+7)/8)*16;case Q3:return Math.floor((t+9)/10)*Math.floor((e+4)/5)*16;case Z3:return Math.floor((t+9)/10)*Math.floor((e+5)/6)*16;case J3:return Math.floor((t+9)/10)*Math.floor((e+7)/8)*16;case eD:return Math.floor((t+9)/10)*Math.floor((e+9)/10)*16;case tD:return Math.floor((t+11)/12)*Math.floor((e+9)/10)*16;case nD:return Math.floor((t+11)/12)*Math.floor((e+11)/12)*16;case rD:case iD:case aD:return Math.ceil(t/4)*Math.ceil(e/4)*16;case sD:case oD:return Math.ceil(t/4)*Math.ceil(e/4)*8;case lD:case cD:return Math.ceil(t/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${n} format.`)}function KPe(t){switch(t){case yc:case QZ:return{byteLength:1,components:1};case dy:case ZZ:case Cx:return{byteLength:2,components:1};case V4:case G4:return{byteLength:2,components:4};case pm:case $4:case wu:return{byteLength:4,components:1};case JZ:case eJ:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${t}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:B4}}));typeof window<"u"&&(window.__THREE__?gn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=B4);function TJ(){let t=null,e=!1,n=null,r=null;function i(a,o){n(a,o),r=t.requestAnimationFrame(i)}return{start:function(){e!==!0&&n!==null&&(r=t.requestAnimationFrame(i),e=!0)},stop:function(){t.cancelAnimationFrame(r),e=!1},setAnimationLoop:function(a){n=a},setContext:function(a){t=a}}}function XPe(t){const e=new WeakMap;function n(l,c){const u=l.array,d=l.usage,f=u.byteLength,p=t.createBuffer();t.bindBuffer(c,p),t.bufferData(c,u,d),l.onUploadCallback();let m;if(u instanceof Float32Array)m=t.FLOAT;else if(typeof Float16Array<"u"&&u instanceof Float16Array)m=t.HALF_FLOAT;else if(u instanceof Uint16Array)l.isFloat16BufferAttribute?m=t.HALF_FLOAT:m=t.UNSIGNED_SHORT;else if(u instanceof Int16Array)m=t.SHORT;else if(u instanceof Uint32Array)m=t.UNSIGNED_INT;else if(u instanceof Int32Array)m=t.INT;else if(u instanceof Int8Array)m=t.BYTE;else if(u instanceof Uint8Array)m=t.UNSIGNED_BYTE;else if(u instanceof Uint8ClampedArray)m=t.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+u);return{buffer:p,type:m,bytesPerElement:u.BYTES_PER_ELEMENT,version:l.version,size:f}}function r(l,c,u){const d=c.array,f=c.updateRanges;if(t.bindBuffer(u,l),f.length===0)t.bufferSubData(u,0,d);else{f.sort((m,x)=>m.start-x.start);let p=0;for(let m=1;m<f.length;m++){const x=f[p],b=f[m];b.start<=x.start+x.count+1?x.count=Math.max(x.count,b.start+b.count-x.start):(++p,f[p]=b)}f.length=p+1;for(let m=0,x=f.length;m<x;m++){const b=f[m];t.bufferSubData(u,b.start*d.BYTES_PER_ELEMENT,d,b.start,b.count)}c.clearUpdateRanges()}c.onUploadCallback()}function i(l){return l.isInterleavedBufferAttribute&&(l=l.data),e.get(l)}function a(l){l.isInterleavedBufferAttribute&&(l=l.data);const c=e.get(l);c&&(t.deleteBuffer(c.buffer),e.delete(l))}function o(l,c){if(l.isInterleavedBufferAttribute&&(l=l.data),l.isGLBufferAttribute){const d=e.get(l);(!d||d.version<l.version)&&e.set(l,{buffer:l.buffer,type:l.type,bytesPerElement:l.elementSize,version:l.version});return}const u=e.get(l);if(u===void 0)e.set(l,n(l,c));else if(u.version<l.version){if(u.size!==l.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");r(u.buffer,l,c),u.version=l.version}}return{get:i,remove:a,update:o}}var YPe=`#ifdef USE_ALPHAHASH
- if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
- #endif`,QPe=`#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`,ZPe=`#ifdef USE_ALPHAMAP
- diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
- #endif`,JPe=`#ifdef USE_ALPHAMAP
- uniform sampler2D alphaMap;
- #endif`,e3e=`#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`,t3e=`#ifdef USE_ALPHATEST
- uniform float alphaTest;
- #endif`,n3e=`#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`,r3e=`#ifdef USE_AOMAP
- uniform sampler2D aoMap;
- uniform float aoMapIntensity;
- #endif`,i3e=`#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`,a3e=`#ifdef USE_BATCHING
- mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
- #endif`,s3e=`vec3 transformed = vec3( position );
- #ifdef USE_ALPHAHASH
- vPosition = vec3( position );
- #endif`,o3e=`vec3 objectNormal = vec3( normal );
- #ifdef USE_TANGENT
- vec3 objectTangent = vec3( tangent.xyz );
- #endif`,l3e=`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`,c3e=`#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`,u3e=`#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`,d3e=`#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`,h3e=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
- #endif`,f3e=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- #endif`,m3e=`#if NUM_CLIPPING_PLANES > 0
- vClipPosition = - mvPosition.xyz;
- #endif`,p3e=`#if defined( USE_COLOR_ALPHA )
- diffuseColor *= vColor;
- #elif defined( USE_COLOR )
- diffuseColor.rgb *= vColor;
- #endif`,g3e=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR )
- varying vec3 vColor;
- #endif`,x3e=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
- varying vec3 vColor;
- #endif`,b3e=`#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`,y3e=`#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`,v3e=`#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`,w3e=`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`,_3e=`#ifdef USE_DISPLACEMENTMAP
- uniform sampler2D displacementMap;
- uniform float displacementScale;
- uniform float displacementBias;
- #endif`,S3e=`#ifdef USE_DISPLACEMENTMAP
- transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
- #endif`,M3e=`#ifdef USE_EMISSIVEMAP
- vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
- #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
- emissiveColor = sRGBTransferEOTF( emissiveColor );
- #endif
- totalEmissiveRadiance *= emissiveColor.rgb;
- #endif`,N3e=`#ifdef USE_EMISSIVEMAP
- uniform sampler2D emissiveMap;
- #endif`,k3e="gl_FragColor = linearToOutputTexel( gl_FragColor );",E3e=`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 );
- }`,T3e=`#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`,A3e=`#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`,C3e=`#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`,j3e=`#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`,P3e=`#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`,D3e=`#ifdef USE_FOG
- vFogDepth = - mvPosition.z;
- #endif`,R3e=`#ifdef USE_FOG
- varying float vFogDepth;
- #endif`,O3e=`#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`,L3e=`#ifdef USE_FOG
- uniform vec3 fogColor;
- varying float vFogDepth;
- #ifdef FOG_EXP2
- uniform float fogDensity;
- #else
- uniform float fogNear;
- uniform float fogFar;
- #endif
- #endif`,F3e=`#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
- }`,I3e=`#ifdef USE_LIGHTMAP
- uniform sampler2D lightMap;
- uniform float lightMapIntensity;
- #endif`,U3e=`LambertMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularStrength = specularStrength;`,z3e=`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`,B3e=`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`,H3e=`#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`,$3e=`ToonMaterial material;
- material.diffuseColor = diffuseColor.rgb;`,V3e=`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`,G3e=`BlinnPhongMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularColor = specular;
- material.specularShininess = shininess;
- material.specularStrength = specularStrength;`,q3e=`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`,W3e=`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`,K3e=`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 );
- }`,X3e=`
- 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`,Y3e=`#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`,Q3e=`#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`,Z3e=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
- gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
- #endif`,J3e=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
- uniform float logDepthBufFC;
- varying float vFragDepth;
- varying float vIsPerspective;
- #endif`,eDe=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
- varying float vFragDepth;
- varying float vIsPerspective;
- #endif`,tDe=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
- vFragDepth = 1.0 + gl_Position.w;
- vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
- #endif`,nDe=`#ifdef USE_MAP
- vec4 sampledDiffuseColor = texture2D( map, vMapUv );
- #ifdef DECODE_VIDEO_TEXTURE
- sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
- #endif
- diffuseColor *= sampledDiffuseColor;
- #endif`,rDe=`#ifdef USE_MAP
- uniform sampler2D map;
- #endif`,iDe=`#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`,aDe=`#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`,sDe=`float metalnessFactor = metalness;
- #ifdef USE_METALNESSMAP
- vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
- metalnessFactor *= texelMetalness.b;
- #endif`,oDe=`#ifdef USE_METALNESSMAP
- uniform sampler2D metalnessMap;
- #endif`,lDe=`#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`,cDe=`#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`,uDe=`#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`,dDe=`#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`,hDe=`#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`,fDe=`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;`,mDe=`#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`,pDe=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,gDe=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,xDe=`#ifndef FLAT_SHADED
- vNormal = normalize( transformedNormal );
- #ifdef USE_TANGENT
- vTangent = normalize( transformedTangent );
- vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
- #endif
- #endif`,bDe=`#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`,yDe=`#ifdef USE_CLEARCOAT
- vec3 clearcoatNormal = nonPerturbedNormal;
- #endif`,vDe=`#ifdef USE_CLEARCOAT_NORMALMAP
- vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
- clearcoatMapN.xy *= clearcoatNormalScale;
- clearcoatNormal = normalize( tbn2 * clearcoatMapN );
- #endif`,wDe=`#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`,_De=`#ifdef USE_IRIDESCENCEMAP
- uniform sampler2D iridescenceMap;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- uniform sampler2D iridescenceThicknessMap;
- #endif`,SDe=`#ifdef OPAQUE
- diffuseColor.a = 1.0;
- #endif
- #ifdef USE_TRANSMISSION
- diffuseColor.a *= material.transmissionAlpha;
- #endif
- gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,MDe=`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 );
- }`,NDe=`#ifdef PREMULTIPLIED_ALPHA
- gl_FragColor.rgb *= gl_FragColor.a;
- #endif`,kDe=`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;`,EDe=`#ifdef DITHERING
- gl_FragColor.rgb = dithering( gl_FragColor.rgb );
- #endif`,TDe=`#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`,ADe=`float roughnessFactor = roughness;
- #ifdef USE_ROUGHNESSMAP
- vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
- roughnessFactor *= texelRoughness.g;
- #endif`,CDe=`#ifdef USE_ROUGHNESSMAP
- uniform sampler2D roughnessMap;
- #endif`,jDe=`#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`,PDe=`#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`,DDe=`#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`,RDe=`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;
- }`,ODe=`#ifdef USE_SKINNING
- mat4 boneMatX = getBoneMatrix( skinIndex.x );
- mat4 boneMatY = getBoneMatrix( skinIndex.y );
- mat4 boneMatZ = getBoneMatrix( skinIndex.z );
- mat4 boneMatW = getBoneMatrix( skinIndex.w );
- #endif`,LDe=`#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`,FDe=`#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`,IDe=`#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`,UDe=`float specularStrength;
- #ifdef USE_SPECULARMAP
- vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
- specularStrength = texelSpecular.r;
- #else
- specularStrength = 1.0;
- #endif`,zDe=`#ifdef USE_SPECULARMAP
- uniform sampler2D specularMap;
- #endif`,BDe=`#if defined( TONE_MAPPING )
- gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
- #endif`,HDe=`#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; }`,$De=`#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`,VDe=`#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`,GDe=`#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`,qDe=`#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`,WDe=`#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`,KDe=`#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 XDe=`varying vec2 vUv;
- uniform mat3 uvTransform;
- void main() {
- vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
- gl_Position = vec4( position.xy, 1.0, 1.0 );
- }`,YDe=`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>
- }`,QDe=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,ZDe=`#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>
- }`,JDe=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,eRe=`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>
- }`,tRe=`#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;
- }`,nRe=`#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
- }`,rRe=`#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;
- }`,iRe=`#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 );
- }`,aRe=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- }`,sRe=`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>
- }`,oRe=`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>
- }`,lRe=`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>
- }`,cRe=`#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>
- }`,uRe=`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>
- }`,dRe=`#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>
- }`,hRe=`#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>
- }`,fRe=`#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;
- }`,mRe=`#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>
- }`,pRe=`#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
- }`,gRe=`#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
- }`,xRe=`#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>
- }`,bRe=`#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>
- }`,yRe=`#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
- }`,vRe=`#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>
- }`,wRe=`#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>
- }`,_Re=`#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>
- }`,SRe=`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>
- }`,MRe=`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>
- }`,NRe=`#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>
- }`,kRe=`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>
- }`,ERe=`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>
- }`,TRe=`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>
- }`,kn={alphahash_fragment:YPe,alphahash_pars_fragment:QPe,alphamap_fragment:ZPe,alphamap_pars_fragment:JPe,alphatest_fragment:e3e,alphatest_pars_fragment:t3e,aomap_fragment:n3e,aomap_pars_fragment:r3e,batching_pars_vertex:i3e,batching_vertex:a3e,begin_vertex:s3e,beginnormal_vertex:o3e,bsdfs:l3e,iridescence_fragment:c3e,bumpmap_pars_fragment:u3e,clipping_planes_fragment:d3e,clipping_planes_pars_fragment:h3e,clipping_planes_pars_vertex:f3e,clipping_planes_vertex:m3e,color_fragment:p3e,color_pars_fragment:g3e,color_pars_vertex:x3e,color_vertex:b3e,common:y3e,cube_uv_reflection_fragment:v3e,defaultnormal_vertex:w3e,displacementmap_pars_vertex:_3e,displacementmap_vertex:S3e,emissivemap_fragment:M3e,emissivemap_pars_fragment:N3e,colorspace_fragment:k3e,colorspace_pars_fragment:E3e,envmap_fragment:T3e,envmap_common_pars_fragment:A3e,envmap_pars_fragment:C3e,envmap_pars_vertex:j3e,envmap_physical_pars_fragment:H3e,envmap_vertex:P3e,fog_vertex:D3e,fog_pars_vertex:R3e,fog_fragment:O3e,fog_pars_fragment:L3e,gradientmap_pars_fragment:F3e,lightmap_pars_fragment:I3e,lights_lambert_fragment:U3e,lights_lambert_pars_fragment:z3e,lights_pars_begin:B3e,lights_toon_fragment:$3e,lights_toon_pars_fragment:V3e,lights_phong_fragment:G3e,lights_phong_pars_fragment:q3e,lights_physical_fragment:W3e,lights_physical_pars_fragment:K3e,lights_fragment_begin:X3e,lights_fragment_maps:Y3e,lights_fragment_end:Q3e,logdepthbuf_fragment:Z3e,logdepthbuf_pars_fragment:J3e,logdepthbuf_pars_vertex:eDe,logdepthbuf_vertex:tDe,map_fragment:nDe,map_pars_fragment:rDe,map_particle_fragment:iDe,map_particle_pars_fragment:aDe,metalnessmap_fragment:sDe,metalnessmap_pars_fragment:oDe,morphinstance_vertex:lDe,morphcolor_vertex:cDe,morphnormal_vertex:uDe,morphtarget_pars_vertex:dDe,morphtarget_vertex:hDe,normal_fragment_begin:fDe,normal_fragment_maps:mDe,normal_pars_fragment:pDe,normal_pars_vertex:gDe,normal_vertex:xDe,normalmap_pars_fragment:bDe,clearcoat_normal_fragment_begin:yDe,clearcoat_normal_fragment_maps:vDe,clearcoat_pars_fragment:wDe,iridescence_pars_fragment:_De,opaque_fragment:SDe,packing:MDe,premultiplied_alpha_fragment:NDe,project_vertex:kDe,dithering_fragment:EDe,dithering_pars_fragment:TDe,roughnessmap_fragment:ADe,roughnessmap_pars_fragment:CDe,shadowmap_pars_fragment:jDe,shadowmap_pars_vertex:PDe,shadowmap_vertex:DDe,shadowmask_pars_fragment:RDe,skinbase_vertex:ODe,skinning_pars_vertex:LDe,skinning_vertex:FDe,skinnormal_vertex:IDe,specularmap_fragment:UDe,specularmap_pars_fragment:zDe,tonemapping_fragment:BDe,tonemapping_pars_fragment:HDe,transmission_fragment:$De,transmission_pars_fragment:VDe,uv_pars_fragment:GDe,uv_pars_vertex:qDe,uv_vertex:WDe,worldpos_vertex:KDe,background_vert:XDe,background_frag:YDe,backgroundCube_vert:QDe,backgroundCube_frag:ZDe,cube_vert:JDe,cube_frag:eRe,depth_vert:tRe,depth_frag:nRe,distanceRGBA_vert:rRe,distanceRGBA_frag:iRe,equirect_vert:aRe,equirect_frag:sRe,linedashed_vert:oRe,linedashed_frag:lRe,meshbasic_vert:cRe,meshbasic_frag:uRe,meshlambert_vert:dRe,meshlambert_frag:hRe,meshmatcap_vert:fRe,meshmatcap_frag:mRe,meshnormal_vert:pRe,meshnormal_frag:gRe,meshphong_vert:xRe,meshphong_frag:bRe,meshphysical_vert:yRe,meshphysical_frag:vRe,meshtoon_vert:wRe,meshtoon_frag:_Re,points_vert:SRe,points_frag:MRe,shadow_vert:NRe,shadow_frag:kRe,sprite_vert:ERe,sprite_frag:TRe},Ot={common:{diffuse:{value:new Bn(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Pn},alphaMap:{value:null},alphaMapTransform:{value:new Pn},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Pn}},envmap:{envMap:{value:null},envMapRotation:{value:new Pn},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Pn}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Pn}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Pn},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Pn},normalScale:{value:new Tn(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Pn},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Pn}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Pn}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Pn}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Bn(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new Bn(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Pn},alphaTest:{value:0},uvTransform:{value:new Pn}},sprite:{diffuse:{value:new Bn(16777215)},opacity:{value:1},center:{value:new Tn(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Pn},alphaMap:{value:null},alphaMapTransform:{value:new Pn},alphaTest:{value:0}}},rc={basic:{uniforms:cs([Ot.common,Ot.specularmap,Ot.envmap,Ot.aomap,Ot.lightmap,Ot.fog]),vertexShader:kn.meshbasic_vert,fragmentShader:kn.meshbasic_frag},lambert:{uniforms:cs([Ot.common,Ot.specularmap,Ot.envmap,Ot.aomap,Ot.lightmap,Ot.emissivemap,Ot.bumpmap,Ot.normalmap,Ot.displacementmap,Ot.fog,Ot.lights,{emissive:{value:new Bn(0)}}]),vertexShader:kn.meshlambert_vert,fragmentShader:kn.meshlambert_frag},phong:{uniforms:cs([Ot.common,Ot.specularmap,Ot.envmap,Ot.aomap,Ot.lightmap,Ot.emissivemap,Ot.bumpmap,Ot.normalmap,Ot.displacementmap,Ot.fog,Ot.lights,{emissive:{value:new Bn(0)},specular:{value:new Bn(1118481)},shininess:{value:30}}]),vertexShader:kn.meshphong_vert,fragmentShader:kn.meshphong_frag},standard:{uniforms:cs([Ot.common,Ot.envmap,Ot.aomap,Ot.lightmap,Ot.emissivemap,Ot.bumpmap,Ot.normalmap,Ot.displacementmap,Ot.roughnessmap,Ot.metalnessmap,Ot.fog,Ot.lights,{emissive:{value:new Bn(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:kn.meshphysical_vert,fragmentShader:kn.meshphysical_frag},toon:{uniforms:cs([Ot.common,Ot.aomap,Ot.lightmap,Ot.emissivemap,Ot.bumpmap,Ot.normalmap,Ot.displacementmap,Ot.gradientmap,Ot.fog,Ot.lights,{emissive:{value:new Bn(0)}}]),vertexShader:kn.meshtoon_vert,fragmentShader:kn.meshtoon_frag},matcap:{uniforms:cs([Ot.common,Ot.bumpmap,Ot.normalmap,Ot.displacementmap,Ot.fog,{matcap:{value:null}}]),vertexShader:kn.meshmatcap_vert,fragmentShader:kn.meshmatcap_frag},points:{uniforms:cs([Ot.points,Ot.fog]),vertexShader:kn.points_vert,fragmentShader:kn.points_frag},dashed:{uniforms:cs([Ot.common,Ot.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:kn.linedashed_vert,fragmentShader:kn.linedashed_frag},depth:{uniforms:cs([Ot.common,Ot.displacementmap]),vertexShader:kn.depth_vert,fragmentShader:kn.depth_frag},normal:{uniforms:cs([Ot.common,Ot.bumpmap,Ot.normalmap,Ot.displacementmap,{opacity:{value:1}}]),vertexShader:kn.meshnormal_vert,fragmentShader:kn.meshnormal_frag},sprite:{uniforms:cs([Ot.sprite,Ot.fog]),vertexShader:kn.sprite_vert,fragmentShader:kn.sprite_frag},background:{uniforms:{uvTransform:{value:new Pn},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:kn.background_vert,fragmentShader:kn.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Pn}},vertexShader:kn.backgroundCube_vert,fragmentShader:kn.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:kn.cube_vert,fragmentShader:kn.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:kn.equirect_vert,fragmentShader:kn.equirect_frag},distanceRGBA:{uniforms:cs([Ot.common,Ot.displacementmap,{referencePosition:{value:new dt},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:kn.distanceRGBA_vert,fragmentShader:kn.distanceRGBA_frag},shadow:{uniforms:cs([Ot.lights,Ot.fog,{color:{value:new Bn(0)},opacity:{value:1}}]),vertexShader:kn.shadow_vert,fragmentShader:kn.shadow_frag}};rc.physical={uniforms:cs([rc.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Pn},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Pn},clearcoatNormalScale:{value:new Tn(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Pn},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Pn},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Pn},sheen:{value:0},sheenColor:{value:new Bn(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Pn},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Pn},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Pn},transmissionSamplerSize:{value:new Tn},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Pn},attenuationDistance:{value:0},attenuationColor:{value:new Bn(0)},specularColor:{value:new Bn(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Pn},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Pn},anisotropyVector:{value:new Tn},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Pn}}]),vertexShader:kn.meshphysical_vert,fragmentShader:kn.meshphysical_frag};const b_={r:0,b:0,g:0},df=new Eh,ARe=new Vi;function CRe(t,e,n,r,i,a,o){const l=new Bn(0);let c=a===!0?0:1,u,d,f=null,p=0,m=null;function x(N){let T=N.isScene===!0?N.background:null;return T&&T.isTexture&&(T=(N.backgroundBlurriness>0?n:e).get(T)),T}function b(N){let T=!1;const k=x(N);k===null?v(l,c):k&&k.isColor&&(v(k,1),T=!0);const C=t.xr.getEnvironmentBlendMode();C==="additive"?r.buffers.color.setClear(0,0,0,1,o):C==="alpha-blend"&&r.buffers.color.setClear(0,0,0,0,o),(t.autoClear||T)&&(r.buffers.depth.setTest(!0),r.buffers.depth.setMask(!0),r.buffers.color.setMask(!0),t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil))}function y(N,T){const k=x(T);k&&(k.isCubeTexture||k.mapping===f2)?(d===void 0&&(d=new vc(new J4(1,1,1),new $u({name:"BackgroundCubeMaterial",uniforms:tx(rc.backgroundCube.uniforms),vertexShader:rc.backgroundCube.vertexShader,fragmentShader:rc.backgroundCube.fragmentShader,side:Us,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),d.geometry.deleteAttribute("normal"),d.geometry.deleteAttribute("uv"),d.onBeforeRender=function(C,E,D){this.matrixWorld.copyPosition(D.matrixWorld)},Object.defineProperty(d.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(d)),df.copy(T.backgroundRotation),df.x*=-1,df.y*=-1,df.z*=-1,k.isCubeTexture&&k.isRenderTargetTexture===!1&&(df.y*=-1,df.z*=-1),d.material.uniforms.envMap.value=k,d.material.uniforms.flipEnvMap.value=k.isCubeTexture&&k.isRenderTargetTexture===!1?-1:1,d.material.uniforms.backgroundBlurriness.value=T.backgroundBlurriness,d.material.uniforms.backgroundIntensity.value=T.backgroundIntensity,d.material.uniforms.backgroundRotation.value.setFromMatrix4(ARe.makeRotationFromEuler(df)),d.material.toneMapped=or.getTransfer(k.colorSpace)!==Nr,(f!==k||p!==k.version||m!==t.toneMapping)&&(d.material.needsUpdate=!0,f=k,p=k.version,m=t.toneMapping),d.layers.enableAll(),N.unshift(d,d.geometry,d.material,0,0,null)):k&&k.isTexture&&(u===void 0&&(u=new vc(new tL(2,2),new $u({name:"BackgroundMaterial",uniforms:tx(rc.background.uniforms),vertexShader:rc.background.vertexShader,fragmentShader:rc.background.fragmentShader,side:kh,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),u.geometry.deleteAttribute("normal"),Object.defineProperty(u.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(u)),u.material.uniforms.t2D.value=k,u.material.uniforms.backgroundIntensity.value=T.backgroundIntensity,u.material.toneMapped=or.getTransfer(k.colorSpace)!==Nr,k.matrixAutoUpdate===!0&&k.updateMatrix(),u.material.uniforms.uvTransform.value.copy(k.matrix),(f!==k||p!==k.version||m!==t.toneMapping)&&(u.material.needsUpdate=!0,f=k,p=k.version,m=t.toneMapping),u.layers.enableAll(),N.unshift(u,u.geometry,u.material,0,0,null))}function v(N,T){N.getRGB(b_,yJ(t)),r.buffers.color.setClear(b_.r,b_.g,b_.b,T,o)}function S(){d!==void 0&&(d.geometry.dispose(),d.material.dispose(),d=void 0),u!==void 0&&(u.geometry.dispose(),u.material.dispose(),u=void 0)}return{getClearColor:function(){return l},setClearColor:function(N,T=1){l.set(N),c=T,v(l,c)},getClearAlpha:function(){return c},setClearAlpha:function(N){c=N,v(l,c)},render:b,addToRenderList:y,dispose:S}}function jRe(t,e){const n=t.getParameter(t.MAX_VERTEX_ATTRIBS),r={},i=p(null);let a=i,o=!1;function l(R,U,F,$,j){let H=!1;const K=f($,F,U);a!==K&&(a=K,u(a.object)),H=m(R,$,F,j),H&&x(R,$,F,j),j!==null&&e.update(j,t.ELEMENT_ARRAY_BUFFER),(H||o)&&(o=!1,T(R,U,F,$),j!==null&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e.get(j).buffer))}function c(){return t.createVertexArray()}function u(R){return t.bindVertexArray(R)}function d(R){return t.deleteVertexArray(R)}function f(R,U,F){const $=F.wireframe===!0;let j=r[R.id];j===void 0&&(j={},r[R.id]=j);let H=j[U.id];H===void 0&&(H={},j[U.id]=H);let K=H[$];return K===void 0&&(K=p(c()),H[$]=K),K}function p(R){const U=[],F=[],$=[];for(let j=0;j<n;j++)U[j]=0,F[j]=0,$[j]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:U,enabledAttributes:F,attributeDivisors:$,object:R,attributes:{},index:null}}function m(R,U,F,$){const j=a.attributes,H=U.attributes;let K=0;const V=F.getAttributes();for(const Q in V)if(V[Q].location>=0){const ae=j[Q];let B=H[Q];if(B===void 0&&(Q==="instanceMatrix"&&R.instanceMatrix&&(B=R.instanceMatrix),Q==="instanceColor"&&R.instanceColor&&(B=R.instanceColor)),ae===void 0||ae.attribute!==B||B&&ae.data!==B.data)return!0;K++}return a.attributesNum!==K||a.index!==$}function x(R,U,F,$){const j={},H=U.attributes;let K=0;const V=F.getAttributes();for(const Q in V)if(V[Q].location>=0){let ae=H[Q];ae===void 0&&(Q==="instanceMatrix"&&R.instanceMatrix&&(ae=R.instanceMatrix),Q==="instanceColor"&&R.instanceColor&&(ae=R.instanceColor));const B={};B.attribute=ae,ae&&ae.data&&(B.data=ae.data),j[Q]=B,K++}a.attributes=j,a.attributesNum=K,a.index=$}function b(){const R=a.newAttributes;for(let U=0,F=R.length;U<F;U++)R[U]=0}function y(R){v(R,0)}function v(R,U){const F=a.newAttributes,$=a.enabledAttributes,j=a.attributeDivisors;F[R]=1,$[R]===0&&(t.enableVertexAttribArray(R),$[R]=1),j[R]!==U&&(t.vertexAttribDivisor(R,U),j[R]=U)}function S(){const R=a.newAttributes,U=a.enabledAttributes;for(let F=0,$=U.length;F<$;F++)U[F]!==R[F]&&(t.disableVertexAttribArray(F),U[F]=0)}function N(R,U,F,$,j,H,K){K===!0?t.vertexAttribIPointer(R,U,F,j,H):t.vertexAttribPointer(R,U,F,$,j,H)}function T(R,U,F,$){b();const j=$.attributes,H=F.getAttributes(),K=U.defaultAttributeValues;for(const V in H){const Q=H[V];if(Q.location>=0){let Z=j[V];if(Z===void 0&&(V==="instanceMatrix"&&R.instanceMatrix&&(Z=R.instanceMatrix),V==="instanceColor"&&R.instanceColor&&(Z=R.instanceColor)),Z!==void 0){const ae=Z.normalized,B=Z.itemSize,X=e.get(Z);if(X===void 0)continue;const ne=X.buffer,se=X.type,be=X.bytesPerElement,xe=se===t.INT||se===t.UNSIGNED_INT||Z.gpuType===$4;if(Z.isInterleavedBufferAttribute){const de=Z.data,Pe=de.stride,ie=Z.offset;if(de.isInstancedInterleavedBuffer){for(let Ne=0;Ne<Q.locationSize;Ne++)v(Q.location+Ne,de.meshPerAttribute);R.isInstancedMesh!==!0&&$._maxInstanceCount===void 0&&($._maxInstanceCount=de.meshPerAttribute*de.count)}else for(let Ne=0;Ne<Q.locationSize;Ne++)y(Q.location+Ne);t.bindBuffer(t.ARRAY_BUFFER,ne);for(let Ne=0;Ne<Q.locationSize;Ne++)N(Q.location+Ne,B/Q.locationSize,se,ae,Pe*be,(ie+B/Q.locationSize*Ne)*be,xe)}else{if(Z.isInstancedBufferAttribute){for(let de=0;de<Q.locationSize;de++)v(Q.location+de,Z.meshPerAttribute);R.isInstancedMesh!==!0&&$._maxInstanceCount===void 0&&($._maxInstanceCount=Z.meshPerAttribute*Z.count)}else for(let de=0;de<Q.locationSize;de++)y(Q.location+de);t.bindBuffer(t.ARRAY_BUFFER,ne);for(let de=0;de<Q.locationSize;de++)N(Q.location+de,B/Q.locationSize,se,ae,B*be,B/Q.locationSize*de*be,xe)}}else if(K!==void 0){const ae=K[V];if(ae!==void 0)switch(ae.length){case 2:t.vertexAttrib2fv(Q.location,ae);break;case 3:t.vertexAttrib3fv(Q.location,ae);break;case 4:t.vertexAttrib4fv(Q.location,ae);break;default:t.vertexAttrib1fv(Q.location,ae)}}}}S()}function k(){D();for(const R in r){const U=r[R];for(const F in U){const $=U[F];for(const j in $)d($[j].object),delete $[j];delete U[F]}delete r[R]}}function C(R){if(r[R.id]===void 0)return;const U=r[R.id];for(const F in U){const $=U[F];for(const j in $)d($[j].object),delete $[j];delete U[F]}delete r[R.id]}function E(R){for(const U in r){const F=r[U];if(F[R.id]===void 0)continue;const $=F[R.id];for(const j in $)d($[j].object),delete $[j];delete F[R.id]}}function D(){A(),o=!0,a!==i&&(a=i,u(a.object))}function A(){i.geometry=null,i.program=null,i.wireframe=!1}return{setup:l,reset:D,resetDefaultState:A,dispose:k,releaseStatesOfGeometry:C,releaseStatesOfProgram:E,initAttributes:b,enableAttribute:y,disableUnusedAttributes:S}}function PRe(t,e,n){let r;function i(u){r=u}function a(u,d){t.drawArrays(r,u,d),n.update(d,r,1)}function o(u,d,f){f!==0&&(t.drawArraysInstanced(r,u,d,f),n.update(d,r,f))}function l(u,d,f){if(f===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(r,u,0,d,0,f);let m=0;for(let x=0;x<f;x++)m+=d[x];n.update(m,r,1)}function c(u,d,f,p){if(f===0)return;const m=e.get("WEBGL_multi_draw");if(m===null)for(let x=0;x<u.length;x++)o(u[x],d[x],p[x]);else{m.multiDrawArraysInstancedWEBGL(r,u,0,d,0,p,0,f);let x=0;for(let b=0;b<f;b++)x+=d[b]*p[b];n.update(x,r,1)}}this.setMode=i,this.render=a,this.renderInstances=o,this.renderMultiDraw=l,this.renderMultiDrawInstances=c}function DRe(t,e,n,r){let i;function a(){if(i!==void 0)return i;if(e.has("EXT_texture_filter_anisotropic")===!0){const E=e.get("EXT_texture_filter_anisotropic");i=t.getParameter(E.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i}function o(E){return!(E!==Pl&&r.convert(E)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_FORMAT))}function l(E){const D=E===Cx&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(E!==yc&&r.convert(E)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_TYPE)&&E!==wu&&!D)}function c(E){if(E==="highp"){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";E="mediump"}return E==="mediump"&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let u=n.precision!==void 0?n.precision:"highp";const d=c(u);d!==u&&(gn("WebGLRenderer:",u,"not supported, using",d,"instead."),u=d);const f=n.logarithmicDepthBuffer===!0,p=n.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),m=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),x=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),b=t.getParameter(t.MAX_TEXTURE_SIZE),y=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),v=t.getParameter(t.MAX_VERTEX_ATTRIBS),S=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),N=t.getParameter(t.MAX_VARYING_VECTORS),T=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),k=x>0,C=t.getParameter(t.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:a,getMaxPrecision:c,textureFormatReadable:o,textureTypeReadable:l,precision:u,logarithmicDepthBuffer:f,reversedDepthBuffer:p,maxTextures:m,maxVertexTextures:x,maxTextureSize:b,maxCubemapSize:y,maxAttributes:v,maxVertexUniforms:S,maxVaryings:N,maxFragmentUniforms:T,vertexTextures:k,maxSamples:C}}function RRe(t){const e=this;let n=null,r=0,i=!1,a=!1;const o=new Bd,l=new Pn,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(f,p){const m=f.length!==0||p||r!==0||i;return i=p,r=f.length,m},this.beginShadows=function(){a=!0,d(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(f,p){n=d(f,p,0)},this.setState=function(f,p,m){const x=f.clippingPlanes,b=f.clipIntersection,y=f.clipShadows,v=t.get(f);if(!i||x===null||x.length===0||a&&!y)a?d(null):u();else{const S=a?0:r,N=S*4;let T=v.clippingState||null;c.value=T,T=d(x,p,N,m);for(let k=0;k!==N;++k)T[k]=n[k];v.clippingState=T,this.numIntersection=b?this.numPlanes:0,this.numPlanes+=S}};function u(){c.value!==n&&(c.value=n,c.needsUpdate=r>0),e.numPlanes=r,e.numIntersection=0}function d(f,p,m,x){const b=f!==null?f.length:0;let y=null;if(b!==0){if(y=c.value,x!==!0||y===null){const v=m+b*4,S=p.matrixWorldInverse;l.getNormalMatrix(S),(y===null||y.length<v)&&(y=new Float32Array(v));for(let N=0,T=m;N!==b;++N,T+=4)o.copy(f[N]).applyMatrix4(S,l),o.normal.toArray(y,T),y[T+3]=o.constant}c.value=y,c.needsUpdate=!0}return e.numPlanes=b,e.numIntersection=0,y}}function ORe(t){let e=new WeakMap;function n(o,l){return l===P3?o.mapping=Zg:l===D3&&(o.mapping=Jg),o}function r(o){if(o&&o.isTexture){const l=o.mapping;if(l===P3||l===D3)if(e.has(o)){const c=e.get(o).texture;return n(c,o.mapping)}else{const c=o.image;if(c&&c.height>0){const u=new CPe(c.height);return u.fromEquirectangularTexture(t,o),e.set(o,u),o.addEventListener("dispose",i),n(u.texture,o.mapping)}else return null}}return o}function i(o){const l=o.target;l.removeEventListener("dispose",i);const c=e.get(l);c!==void 0&&(e.delete(l),c.dispose())}function a(){e=new WeakMap}return{get:r,dispose:a}}const Qd=4,sV=[.125,.215,.35,.446,.526,.582],Nf=20,LRe=256,qb=new EJ,oV=new Bn;let xC=null,bC=0,yC=0,vC=!1;const FRe=new dt;let lV=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,n=0,r=.1,i=100,a={}){const{size:o=256,position:l=FRe}=a;xC=this._renderer.getRenderTarget(),bC=this._renderer.getActiveCubeFace(),yC=this._renderer.getActiveMipmapLevel(),vC=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(o);const c=this._allocateTargets();return c.depthBuffer=!0,this._sceneToCubeUV(e,r,i,c,l),n>0&&this._blur(c,0,0,n),this._applyPMREM(c),this._cleanup(c),c}fromEquirectangular(e,n=null){return this._fromTexture(e,n)}fromCubemap(e,n=null){return this._fromTexture(e,n)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=dV(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=uV(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodMeshes.length;e++)this._lodMeshes[e].geometry.dispose()}_cleanup(e){this._renderer.setRenderTarget(xC,bC,yC),this._renderer.xr.enabled=vC,e.scissorTest=!1,Dp(e,0,0,e.width,e.height)}_fromTexture(e,n){e.mapping===Zg||e.mapping===Jg?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),xC=this._renderer.getRenderTarget(),bC=this._renderer.getActiveCubeFace(),yC=this._renderer.getActiveMipmapLevel(),vC=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const r=n||this._allocateTargets();return this._textureToCubeUV(e,r),this._applyPMREM(r),this._cleanup(r),r}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),n=4*this._cubeSize,r={magFilter:el,minFilter:el,generateMipmaps:!1,type:Cx,format:Pl,colorSpace:ex,depthBuffer:!1},i=cV(e,n,r);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==n){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=cV(e,n,r);const{_lodMax:a}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=IRe(a)),this._blurMaterial=zRe(a,e,n),this._ggxMaterial=URe(a,e,n)}return i}_compileMaterial(e){const n=new vc(new Ac,e);this._renderer.compile(n,qb)}_sceneToCubeUV(e,n,r,i,a){const c=new Wo(90,1,n,r),u=[1,-1,1,1,1,1],d=[1,1,1,-1,-1,-1],f=this._renderer,p=f.autoClear,m=f.toneMapping;f.getClearColor(oV),f.toneMapping=lh,f.autoClear=!1,f.state.buffers.depth.getReversed()&&(f.setRenderTarget(i),f.clearDepth(),f.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new vc(new J4,new Z4({name:"PMREM.Background",side:Us,depthWrite:!1,depthTest:!1})));const b=this._backgroundBox,y=b.material;let v=!1;const S=e.background;S?S.isColor&&(y.color.copy(S),e.background=null,v=!0):(y.color.copy(oV),v=!0);for(let N=0;N<6;N++){const T=N%3;T===0?(c.up.set(0,u[N],0),c.position.set(a.x,a.y,a.z),c.lookAt(a.x+d[N],a.y,a.z)):T===1?(c.up.set(0,0,u[N]),c.position.set(a.x,a.y,a.z),c.lookAt(a.x,a.y+d[N],a.z)):(c.up.set(0,u[N],0),c.position.set(a.x,a.y,a.z),c.lookAt(a.x,a.y,a.z+d[N]));const k=this._cubeSize;Dp(i,T*k,N>2?k:0,k,k),f.setRenderTarget(i),v&&f.render(b,c),f.render(e,c)}f.toneMapping=m,f.autoClear=p,e.background=S}_textureToCubeUV(e,n){const r=this._renderer,i=e.mapping===Zg||e.mapping===Jg;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=dV()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=uV());const a=i?this._cubemapMaterial:this._equirectMaterial,o=this._lodMeshes[0];o.material=a;const l=a.uniforms;l.envMap.value=e;const c=this._cubeSize;Dp(n,0,0,3*c,2*c),r.setRenderTarget(n),r.render(o,qb)}_applyPMREM(e){const n=this._renderer,r=n.autoClear;n.autoClear=!1;const i=this._lodMeshes.length;for(let a=1;a<i;a++)this._applyGGXFilter(e,a-1,a);n.autoClear=r}_applyGGXFilter(e,n,r){const i=this._renderer,a=this._pingPongRenderTarget,o=this._ggxMaterial,l=this._lodMeshes[r];l.material=o;const c=o.uniforms,u=r/(this._lodMeshes.length-1),d=n/(this._lodMeshes.length-1),f=Math.sqrt(u*u-d*d),p=.05+u*.95,m=f*p,{_lodMax:x}=this,b=this._sizeLods[r],y=3*b*(r>x-Qd?r-x+Qd:0),v=4*(this._cubeSize-b);c.envMap.value=e.texture,c.roughness.value=m,c.mipInt.value=x-n,Dp(a,y,v,3*b,2*b),i.setRenderTarget(a),i.render(l,qb),c.envMap.value=a.texture,c.roughness.value=0,c.mipInt.value=x-r,Dp(e,y,v,3*b,2*b),i.setRenderTarget(e),i.render(l,qb)}_blur(e,n,r,i,a){const o=this._pingPongRenderTarget;this._halfBlur(e,o,n,r,i,"latitudinal",a),this._halfBlur(o,e,r,r,i,"longitudinal",a)}_halfBlur(e,n,r,i,a,o,l){const c=this._renderer,u=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&Ei("blur direction must be either latitudinal or longitudinal!");const d=3,f=this._lodMeshes[i];f.material=u;const p=u.uniforms,m=this._sizeLods[r]-1,x=isFinite(a)?Math.PI/(2*m):2*Math.PI/(2*Nf-1),b=a/x,y=isFinite(a)?1+Math.floor(d*b):Nf;y>Nf&&gn(`sigmaRadians, ${a}, is too large and will clip, as it requested ${y} samples when the maximum is set to ${Nf}`);const v=[];let S=0;for(let E=0;E<Nf;++E){const D=E/b,A=Math.exp(-D*D/2);v.push(A),E===0?S+=A:E<y&&(S+=2*A)}for(let E=0;E<v.length;E++)v[E]=v[E]/S;p.envMap.value=e.texture,p.samples.value=y,p.weights.value=v,p.latitudinal.value=o==="latitudinal",l&&(p.poleAxis.value=l);const{_lodMax:N}=this;p.dTheta.value=x,p.mipInt.value=N-r;const T=this._sizeLods[i],k=3*T*(i>N-Qd?i-N+Qd:0),C=4*(this._cubeSize-T);Dp(n,k,C,3*T,2*T),c.setRenderTarget(n),c.render(f,qb)}};function IRe(t){const e=[],n=[],r=[];let i=t;const a=t-Qd+1+sV.length;for(let o=0;o<a;o++){const l=Math.pow(2,i);e.push(l);let c=1/l;o>t-Qd?c=sV[o-t+Qd-1]:o===0&&(c=0),n.push(c);const u=1/(l-2),d=-u,f=1+u,p=[d,d,f,d,f,f,d,d,f,f,d,f],m=6,x=6,b=3,y=2,v=1,S=new Float32Array(b*x*m),N=new Float32Array(y*x*m),T=new Float32Array(v*x*m);for(let C=0;C<m;C++){const E=C%3*2/3-1,D=C>2?0:-1,A=[E,D,0,E+2/3,D,0,E+2/3,D+1,0,E,D,0,E+2/3,D+1,0,E,D+1,0];S.set(A,b*x*C),N.set(p,y*x*C);const R=[C,C,C,C,C,C];T.set(R,v*x*C)}const k=new Ac;k.setAttribute("position",new nl(S,b)),k.setAttribute("uv",new nl(N,y)),k.setAttribute("faceIndex",new nl(T,v)),r.push(new vc(k,null)),i>Qd&&i--}return{lodMeshes:r,sizeLods:e,sigmas:n}}function cV(t,e,n){const r=new xm(t,e,n);return r.texture.mapping=f2,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function Dp(t,e,n,r,i){t.viewport.set(e,n,r,i),t.scissor.set(e,n,r,i)}function URe(t,e,n){return new $u({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:LRe,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:p2(),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:Tu,depthTest:!1,depthWrite:!1})}function zRe(t,e,n){const r=new Float32Array(Nf),i=new dt(0,1,0);return new $u({name:"SphericalGaussianBlur",defines:{n:Nf,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:p2(),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:Tu,depthTest:!1,depthWrite:!1})}function uV(){return new $u({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:p2(),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:Tu,depthTest:!1,depthWrite:!1})}function dV(){return new $u({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:p2(),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:Tu,depthTest:!1,depthWrite:!1})}function p2(){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 BRe(t){let e=new WeakMap,n=null;function r(l){if(l&&l.isTexture){const c=l.mapping,u=c===P3||c===D3,d=c===Zg||c===Jg;if(u||d){let f=e.get(l);const p=f!==void 0?f.texture.pmremVersion:0;if(l.isRenderTargetTexture&&l.pmremVersion!==p)return n===null&&(n=new lV(t)),f=u?n.fromEquirectangular(l,f):n.fromCubemap(l,f),f.texture.pmremVersion=l.pmremVersion,e.set(l,f),f.texture;if(f!==void 0)return f.texture;{const m=l.image;return u&&m&&m.height>0||d&&m&&i(m)?(n===null&&(n=new lV(t)),f=u?n.fromEquirectangular(l):n.fromCubemap(l),f.texture.pmremVersion=l.pmremVersion,e.set(l,f),l.addEventListener("dispose",a),f.texture):null}}}return l}function i(l){let c=0;const u=6;for(let d=0;d<u;d++)l[d]!==void 0&&c++;return c===u}function a(l){const c=l.target;c.removeEventListener("dispose",a);const u=e.get(c);u!==void 0&&(e.delete(c),u.dispose())}function o(){e=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:r,dispose:o}}function HRe(t){const e={};function n(r){if(e[r]!==void 0)return e[r];const i=t.getExtension(r);return e[r]=i,i}return{has:function(r){return n(r)!==null},init:function(){n("EXT_color_buffer_float"),n("WEBGL_clip_cull_distance"),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float"),n("WEBGL_multisampled_render_to_texture"),n("WEBGL_render_shared_exponent")},get:function(r){const i=n(r);return i===null&&py("WebGLRenderer: "+r+" extension not supported."),i}}}function $Re(t,e,n,r){const i={},a=new WeakMap;function o(f){const p=f.target;p.index!==null&&e.remove(p.index);for(const x in p.attributes)e.remove(p.attributes[x]);p.removeEventListener("dispose",o),delete i[p.id];const m=a.get(p);m&&(e.remove(m),a.delete(p)),r.releaseStatesOfGeometry(p),p.isInstancedBufferGeometry===!0&&delete p._maxInstanceCount,n.memory.geometries--}function l(f,p){return i[p.id]===!0||(p.addEventListener("dispose",o),i[p.id]=!0,n.memory.geometries++),p}function c(f){const p=f.attributes;for(const m in p)e.update(p[m],t.ARRAY_BUFFER)}function u(f){const p=[],m=f.index,x=f.attributes.position;let b=0;if(m!==null){const S=m.array;b=m.version;for(let N=0,T=S.length;N<T;N+=3){const k=S[N+0],C=S[N+1],E=S[N+2];p.push(k,C,C,E,E,k)}}else if(x!==void 0){const S=x.array;b=x.version;for(let N=0,T=S.length/3-1;N<T;N+=3){const k=N+0,C=N+1,E=N+2;p.push(k,C,C,E,E,k)}}else return;const y=new(sJ(p)?gJ:pJ)(p,1);y.version=b;const v=a.get(f);v&&e.remove(v),a.set(f,y)}function d(f){const p=a.get(f);if(p){const m=f.index;m!==null&&p.version<m.version&&u(f)}else u(f);return a.get(f)}return{get:l,update:c,getWireframeAttribute:d}}function VRe(t,e,n){let r;function i(p){r=p}let a,o;function l(p){a=p.type,o=p.bytesPerElement}function c(p,m){t.drawElements(r,m,a,p*o),n.update(m,r,1)}function u(p,m,x){x!==0&&(t.drawElementsInstanced(r,m,a,p*o,x),n.update(m,r,x))}function d(p,m,x){if(x===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(r,m,0,a,p,0,x);let y=0;for(let v=0;v<x;v++)y+=m[v];n.update(y,r,1)}function f(p,m,x,b){if(x===0)return;const y=e.get("WEBGL_multi_draw");if(y===null)for(let v=0;v<p.length;v++)u(p[v]/o,m[v],b[v]);else{y.multiDrawElementsInstancedWEBGL(r,m,0,a,p,0,b,0,x);let v=0;for(let S=0;S<x;S++)v+=m[S]*b[S];n.update(v,r,1)}}this.setMode=i,this.setIndex=l,this.render=c,this.renderInstances=u,this.renderMultiDraw=d,this.renderMultiDrawInstances=f}function GRe(t){const e={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function r(a,o,l){switch(n.calls++,o){case t.TRIANGLES:n.triangles+=l*(a/3);break;case t.LINES:n.lines+=l*(a/2);break;case t.LINE_STRIP:n.lines+=l*(a-1);break;case t.LINE_LOOP:n.lines+=l*a;break;case t.POINTS:n.points+=l*a;break;default:Ei("WebGLInfo: Unknown draw mode:",o);break}}function i(){n.calls=0,n.triangles=0,n.points=0,n.lines=0}return{memory:e,render:n,programs:null,autoReset:!0,reset:i,update:r}}function qRe(t,e,n){const r=new WeakMap,i=new Ui;function a(o,l,c){const u=o.morphTargetInfluences,d=l.morphAttributes.position||l.morphAttributes.normal||l.morphAttributes.color,f=d!==void 0?d.length:0;let p=r.get(l);if(p===void 0||p.count!==f){let R=function(){D.dispose(),r.delete(l),l.removeEventListener("dispose",R)};var m=R;p!==void 0&&p.texture.dispose();const x=l.morphAttributes.position!==void 0,b=l.morphAttributes.normal!==void 0,y=l.morphAttributes.color!==void 0,v=l.morphAttributes.position||[],S=l.morphAttributes.normal||[],N=l.morphAttributes.color||[];let T=0;x===!0&&(T=1),b===!0&&(T=2),y===!0&&(T=3);let k=l.attributes.position.count*T,C=1;k>e.maxTextureSize&&(C=Math.ceil(k/e.maxTextureSize),k=e.maxTextureSize);const E=new Float32Array(k*C*4*f),D=new dJ(E,k,C,f);D.type=wu,D.needsUpdate=!0;const A=T*4;for(let U=0;U<f;U++){const F=v[U],$=S[U],j=N[U],H=k*C*4*U;for(let K=0;K<F.count;K++){const V=K*A;x===!0&&(i.fromBufferAttribute(F,K),E[H+V+0]=i.x,E[H+V+1]=i.y,E[H+V+2]=i.z,E[H+V+3]=0),b===!0&&(i.fromBufferAttribute($,K),E[H+V+4]=i.x,E[H+V+5]=i.y,E[H+V+6]=i.z,E[H+V+7]=0),y===!0&&(i.fromBufferAttribute(j,K),E[H+V+8]=i.x,E[H+V+9]=i.y,E[H+V+10]=i.z,E[H+V+11]=j.itemSize===4?i.w:1)}}p={count:f,texture:D,size:new Tn(k,C)},r.set(l,p),l.addEventListener("dispose",R)}if(o.isInstancedMesh===!0&&o.morphTexture!==null)c.getUniforms().setValue(t,"morphTexture",o.morphTexture,n);else{let x=0;for(let y=0;y<u.length;y++)x+=u[y];const b=l.morphTargetsRelative?1:1-x;c.getUniforms().setValue(t,"morphTargetBaseInfluence",b),c.getUniforms().setValue(t,"morphTargetInfluences",u)}c.getUniforms().setValue(t,"morphTargetsTexture",p.texture,n),c.getUniforms().setValue(t,"morphTargetsTextureSize",p.size)}return{update:a}}function WRe(t,e,n,r){let i=new WeakMap;function a(c){const u=r.render.frame,d=c.geometry,f=e.get(c,d);if(i.get(f)!==u&&(e.update(f),i.set(f,u)),c.isInstancedMesh&&(c.hasEventListener("dispose",l)===!1&&c.addEventListener("dispose",l),i.get(c)!==u&&(n.update(c.instanceMatrix,t.ARRAY_BUFFER),c.instanceColor!==null&&n.update(c.instanceColor,t.ARRAY_BUFFER),i.set(c,u))),c.isSkinnedMesh){const p=c.skeleton;i.get(p)!==u&&(p.update(),i.set(p,u))}return f}function o(){i=new WeakMap}function l(c){const u=c.target;u.removeEventListener("dispose",l),n.remove(u.instanceMatrix),u.instanceColor!==null&&n.remove(u.instanceColor)}return{update:a,dispose:o}}const AJ=new Hl,hV=new SJ(1,1),CJ=new dJ,jJ=new fPe,PJ=new wJ,fV=[],mV=[],pV=new Float32Array(16),gV=new Float32Array(9),xV=new Float32Array(4);function Px(t,e,n){const r=t[0];if(r<=0||r>0)return t;const i=e*n;let a=fV[i];if(a===void 0&&(a=new Float32Array(i),fV[i]=a),e!==0){r.toArray(a,0);for(let o=1,l=0;o!==e;++o)l+=n,t[o].toArray(a,l)}return a}function Zi(t,e){if(t.length!==e.length)return!1;for(let n=0,r=t.length;n<r;n++)if(t[n]!==e[n])return!1;return!0}function Ji(t,e){for(let n=0,r=e.length;n<r;n++)t[n]=e[n]}function g2(t,e){let n=mV[e];n===void 0&&(n=new Int32Array(e),mV[e]=n);for(let r=0;r!==e;++r)n[r]=t.allocateTextureUnit();return n}function KRe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function XRe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y)&&(t.uniform2f(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(Zi(n,e))return;t.uniform2fv(this.addr,e),Ji(n,e)}}function YRe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(t.uniform3f(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else if(e.r!==void 0)(n[0]!==e.r||n[1]!==e.g||n[2]!==e.b)&&(t.uniform3f(this.addr,e.r,e.g,e.b),n[0]=e.r,n[1]=e.g,n[2]=e.b);else{if(Zi(n,e))return;t.uniform3fv(this.addr,e),Ji(n,e)}}function QRe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||n[3]!==e.w)&&(t.uniform4f(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(Zi(n,e))return;t.uniform4fv(this.addr,e),Ji(n,e)}}function ZRe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Zi(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),Ji(n,e)}else{if(Zi(n,r))return;xV.set(r),t.uniformMatrix2fv(this.addr,!1,xV),Ji(n,r)}}function JRe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Zi(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),Ji(n,e)}else{if(Zi(n,r))return;gV.set(r),t.uniformMatrix3fv(this.addr,!1,gV),Ji(n,r)}}function eOe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Zi(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),Ji(n,e)}else{if(Zi(n,r))return;pV.set(r),t.uniformMatrix4fv(this.addr,!1,pV),Ji(n,r)}}function tOe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function nOe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y)&&(t.uniform2i(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(Zi(n,e))return;t.uniform2iv(this.addr,e),Ji(n,e)}}function rOe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(t.uniform3i(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else{if(Zi(n,e))return;t.uniform3iv(this.addr,e),Ji(n,e)}}function iOe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||n[3]!==e.w)&&(t.uniform4i(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(Zi(n,e))return;t.uniform4iv(this.addr,e),Ji(n,e)}}function aOe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function sOe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y)&&(t.uniform2ui(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(Zi(n,e))return;t.uniform2uiv(this.addr,e),Ji(n,e)}}function oOe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(t.uniform3ui(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else{if(Zi(n,e))return;t.uniform3uiv(this.addr,e),Ji(n,e)}}function lOe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||n[3]!==e.w)&&(t.uniform4ui(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(Zi(n,e))return;t.uniform4uiv(this.addr,e),Ji(n,e)}}function cOe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i);let a;this.type===t.SAMPLER_2D_SHADOW?(hV.compareFunction=aJ,a=hV):a=AJ,n.setTexture2D(e||a,i)}function uOe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(e||jJ,i)}function dOe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTextureCube(e||PJ,i)}function hOe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(e||CJ,i)}function fOe(t){switch(t){case 5126:return KRe;case 35664:return XRe;case 35665:return YRe;case 35666:return QRe;case 35674:return ZRe;case 35675:return JRe;case 35676:return eOe;case 5124:case 35670:return tOe;case 35667:case 35671:return nOe;case 35668:case 35672:return rOe;case 35669:case 35673:return iOe;case 5125:return aOe;case 36294:return sOe;case 36295:return oOe;case 36296:return lOe;case 35678:case 36198:case 36298:case 36306:case 35682:return cOe;case 35679:case 36299:case 36307:return uOe;case 35680:case 36300:case 36308:case 36293:return dOe;case 36289:case 36303:case 36311:case 36292:return hOe}}function mOe(t,e){t.uniform1fv(this.addr,e)}function pOe(t,e){const n=Px(e,this.size,2);t.uniform2fv(this.addr,n)}function gOe(t,e){const n=Px(e,this.size,3);t.uniform3fv(this.addr,n)}function xOe(t,e){const n=Px(e,this.size,4);t.uniform4fv(this.addr,n)}function bOe(t,e){const n=Px(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function yOe(t,e){const n=Px(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function vOe(t,e){const n=Px(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function wOe(t,e){t.uniform1iv(this.addr,e)}function _Oe(t,e){t.uniform2iv(this.addr,e)}function SOe(t,e){t.uniform3iv(this.addr,e)}function MOe(t,e){t.uniform4iv(this.addr,e)}function NOe(t,e){t.uniform1uiv(this.addr,e)}function kOe(t,e){t.uniform2uiv(this.addr,e)}function EOe(t,e){t.uniform3uiv(this.addr,e)}function TOe(t,e){t.uniform4uiv(this.addr,e)}function AOe(t,e,n){const r=this.cache,i=e.length,a=g2(n,i);Zi(r,a)||(t.uniform1iv(this.addr,a),Ji(r,a));for(let o=0;o!==i;++o)n.setTexture2D(e[o]||AJ,a[o])}function COe(t,e,n){const r=this.cache,i=e.length,a=g2(n,i);Zi(r,a)||(t.uniform1iv(this.addr,a),Ji(r,a));for(let o=0;o!==i;++o)n.setTexture3D(e[o]||jJ,a[o])}function jOe(t,e,n){const r=this.cache,i=e.length,a=g2(n,i);Zi(r,a)||(t.uniform1iv(this.addr,a),Ji(r,a));for(let o=0;o!==i;++o)n.setTextureCube(e[o]||PJ,a[o])}function POe(t,e,n){const r=this.cache,i=e.length,a=g2(n,i);Zi(r,a)||(t.uniform1iv(this.addr,a),Ji(r,a));for(let o=0;o!==i;++o)n.setTexture2DArray(e[o]||CJ,a[o])}function DOe(t){switch(t){case 5126:return mOe;case 35664:return pOe;case 35665:return gOe;case 35666:return xOe;case 35674:return bOe;case 35675:return yOe;case 35676:return vOe;case 5124:case 35670:return wOe;case 35667:case 35671:return _Oe;case 35668:case 35672:return SOe;case 35669:case 35673:return MOe;case 5125:return NOe;case 36294:return kOe;case 36295:return EOe;case 36296:return TOe;case 35678:case 36198:case 36298:case 36306:case 35682:return AOe;case 35679:case 36299:case 36307:return COe;case 35680:case 36300:case 36308:case 36293:return jOe;case 36289:case 36303:case 36311:case 36292:return POe}}let ROe=class{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.setValue=fOe(n.type)}},OOe=class{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.size=n.size,this.setValue=DOe(n.type)}},LOe=class{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,n,r){const i=this.seq;for(let a=0,o=i.length;a!==o;++a){const l=i[a];l.setValue(e,n[l.id],r)}}};const wC=/(\w+)(\])?(\[|\.)?/g;function bV(t,e){t.seq.push(e),t.map[e.id]=e}function FOe(t,e,n){const r=t.name,i=r.length;for(wC.lastIndex=0;;){const a=wC.exec(r),o=wC.lastIndex;let l=a[1];const c=a[2]==="]",u=a[3];if(c&&(l=l|0),u===void 0||u==="["&&o+2===i){bV(n,u===void 0?new ROe(l,t,e):new OOe(l,t,e));break}else{let f=n.map[l];f===void 0&&(f=new LOe(l),bV(n,f)),n=f}}}let j1=class{constructor(e,n){this.seq=[],this.map={};const r=e.getProgramParameter(n,e.ACTIVE_UNIFORMS);for(let i=0;i<r;++i){const a=e.getActiveUniform(n,i),o=e.getUniformLocation(n,a.name);FOe(a,o,this)}}setValue(e,n,r,i){const a=this.map[n];a!==void 0&&a.setValue(e,r,i)}setOptional(e,n,r){const i=n[r];i!==void 0&&this.setValue(e,r,i)}static upload(e,n,r,i){for(let a=0,o=n.length;a!==o;++a){const l=n[a],c=r[l.id];c.needsUpdate!==!1&&l.setValue(e,c.value,i)}}static seqWithValue(e,n){const r=[];for(let i=0,a=e.length;i!==a;++i){const o=e[i];o.id in n&&r.push(o)}return r}};function yV(t,e,n){const r=t.createShader(e);return t.shaderSource(r,n),t.compileShader(r),r}const IOe=37297;let UOe=0;function zOe(t,e){const n=t.split(`
- `),r=[],i=Math.max(e-6,0),a=Math.min(e+6,n.length);for(let o=i;o<a;o++){const l=o+1;r.push(`${l===e?">":" "} ${l}: ${n[o]}`)}return r.join(`
- `)}const vV=new Pn;function BOe(t){or._getMatrix(vV,or.workingColorSpace,t);const e=`mat3( ${vV.elements.map(n=>n.toFixed(4))} )`;switch(or.getTransfer(t)){case WS:return[e,"LinearTransferOETF"];case Nr:return[e,"sRGBTransferOETF"];default:return gn("WebGLProgram: Unsupported color space: ",t),[e,"LinearTransferOETF"]}}function wV(t,e,n){const r=t.getShaderParameter(e,t.COMPILE_STATUS),a=(t.getShaderInfoLog(e)||"").trim();if(r&&a==="")return"";const o=/ERROR: 0:(\d+)/.exec(a);if(o){const l=parseInt(o[1]);return n.toUpperCase()+`
- `+a+`
- `+zOe(t.getShaderSource(e),l)}else return a}function HOe(t,e){const n=BOe(e);return[`vec4 ${t}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join(`
- `)}function $Oe(t,e){let n;switch(e){case zje:n="Linear";break;case Bje:n="Reinhard";break;case Hje:n="Cineon";break;case $je:n="ACESFilmic";break;case Gje:n="AgX";break;case qje:n="Neutral";break;case Vje:n="Custom";break;default:gn("WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}const y_=new dt;function VOe(){or.getLuminanceCoefficients(y_);const t=y_.x.toFixed(4),e=y_.y.toFixed(4),n=y_.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${t}, ${e}, ${n} );`," return dot( weights, rgb );","}"].join(`
- `)}function GOe(t){return[t.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",t.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(l0).join(`
- `)}function qOe(t){const e=[];for(const n in t){const r=t[n];r!==!1&&e.push("#define "+n+" "+r)}return e.join(`
- `)}function WOe(t,e){const n={},r=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let i=0;i<r;i++){const a=t.getActiveAttrib(e,i),o=a.name;let l=1;a.type===t.FLOAT_MAT2&&(l=2),a.type===t.FLOAT_MAT3&&(l=3),a.type===t.FLOAT_MAT4&&(l=4),n[o]={type:a.type,location:t.getAttribLocation(e,o),locationSize:l}}return n}function l0(t){return t!==""}function _V(t,e){const n=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return t.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,n).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function SV(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const KOe=/^[ \t]*#include +<([\w\d./]+)>/gm;function hD(t){return t.replace(KOe,YOe)}const XOe=new Map;function YOe(t,e){let n=kn[e];if(n===void 0){const r=XOe.get(e);if(r!==void 0)n=kn[r],gn('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,r);else throw new Error("Can not resolve #include <"+e+">")}return hD(n)}const QOe=/#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 MV(t){return t.replace(QOe,ZOe)}function ZOe(t,e,n,r){let i="";for(let a=parseInt(e);a<parseInt(n);a++)i+=r.replace(/\[\s*i\s*\]/g,"[ "+a+" ]").replace(/UNROLLED_LOOP_INDEX/g,a);return i}function NV(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 JOe(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===XZ?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===yje?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===ou&&(e="SHADOWMAP_TYPE_VSM"),e}function e4e(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case Zg:case Jg:e="ENVMAP_TYPE_CUBE";break;case f2:e="ENVMAP_TYPE_CUBE_UV";break}return e}function t4e(t){let e="ENVMAP_MODE_REFLECTION";if(t.envMap)switch(t.envMapMode){case Jg:e="ENVMAP_MODE_REFRACTION";break}return e}function n4e(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case H4:e="ENVMAP_BLENDING_MULTIPLY";break;case Ije:e="ENVMAP_BLENDING_MIX";break;case Uje:e="ENVMAP_BLENDING_ADD";break}return e}function r4e(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 i4e(t,e,n,r){const i=t.getContext(),a=n.defines;let o=n.vertexShader,l=n.fragmentShader;const c=JOe(n),u=e4e(n),d=t4e(n),f=n4e(n),p=r4e(n),m=GOe(n),x=qOe(a),b=i.createProgram();let y,v,S=n.glslVersion?"#version "+n.glslVersion+`
- `:"";n.isRawShaderMaterial?(y=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(l0).join(`
- `),y.length>0&&(y+=`
- `),v=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(l0).join(`
- `),v.length>0&&(v+=`
- `)):(y=[NV(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+d:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&n.flatShading===!1?"#define USE_MORPHNORMALS":"",n.morphColors?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
- `].filter(l0).join(`
- `),v=[NV(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.envMap?"#define "+d:"",n.envMap?"#define "+f:"",p?"#define CUBEUV_TEXEL_WIDTH "+p.texelWidth:"",p?"#define CUBEUV_TEXEL_HEIGHT "+p.texelHeight:"",p?"#define CUBEUV_MAX_MIP "+p.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.dispersion?"#define USE_DISPERSION":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor||n.batchingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==lh?"#define TONE_MAPPING":"",n.toneMapping!==lh?kn.tonemapping_pars_fragment:"",n.toneMapping!==lh?$Oe("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",kn.colorspace_pars_fragment,HOe("linearToOutputTexel",n.outputColorSpace),VOe(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
- `].filter(l0).join(`
- `)),o=hD(o),o=_V(o,n),o=SV(o,n),l=hD(l),l=_V(l,n),l=SV(l,n),o=MV(o),l=MV(l),n.isRawShaderMaterial!==!0&&(S=`#version 300 es
- `,y=[m,"#define attribute in","#define varying out","#define texture2D texture"].join(`
- `)+`
- `+y,v=["#define varying in",n.glslVersion===P$?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===P$?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`
- `)+`
- `+v);const N=S+y+o,T=S+v+l,k=yV(i,i.VERTEX_SHADER,N),C=yV(i,i.FRAGMENT_SHADER,T);i.attachShader(b,k),i.attachShader(b,C),n.index0AttributeName!==void 0?i.bindAttribLocation(b,0,n.index0AttributeName):n.morphTargets===!0&&i.bindAttribLocation(b,0,"position"),i.linkProgram(b);function E(U){if(t.debug.checkShaderErrors){const F=i.getProgramInfoLog(b)||"",$=i.getShaderInfoLog(k)||"",j=i.getShaderInfoLog(C)||"",H=F.trim(),K=$.trim(),V=j.trim();let Q=!0,Z=!0;if(i.getProgramParameter(b,i.LINK_STATUS)===!1)if(Q=!1,typeof t.debug.onShaderError=="function")t.debug.onShaderError(i,b,k,C);else{const ae=wV(i,k,"vertex"),B=wV(i,C,"fragment");Ei("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(b,i.VALIDATE_STATUS)+`
- Material Name: `+U.name+`
- Material Type: `+U.type+`
- Program Info Log: `+H+`
- `+ae+`
- `+B)}else H!==""?gn("WebGLProgram: Program Info Log:",H):(K===""||V==="")&&(Z=!1);Z&&(U.diagnostics={runnable:Q,programLog:H,vertexShader:{log:K,prefix:y},fragmentShader:{log:V,prefix:v}})}i.deleteShader(k),i.deleteShader(C),D=new j1(i,b),A=WOe(i,b)}let D;this.getUniforms=function(){return D===void 0&&E(this),D};let A;this.getAttributes=function(){return A===void 0&&E(this),A};let R=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return R===!1&&(R=i.getProgramParameter(b,IOe)),R},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(b),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=UOe++,this.cacheKey=e,this.usedTimes=1,this.program=b,this.vertexShader=k,this.fragmentShader=C,this}let a4e=0,s4e=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const n=e.vertexShader,r=e.fragmentShader,i=this._getShaderStage(n),a=this._getShaderStage(r),o=this._getShaderCacheForMaterial(e);return o.has(i)===!1&&(o.add(i),i.usedTimes++),o.has(a)===!1&&(o.add(a),a.usedTimes++),this}remove(e){const n=this.materialCache.get(e);for(const r of n)r.usedTimes--,r.usedTimes===0&&this.shaderCache.delete(r.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const n=this.materialCache;let r=n.get(e);return r===void 0&&(r=new Set,n.set(e,r)),r}_getShaderStage(e){const n=this.shaderCache;let r=n.get(e);return r===void 0&&(r=new o4e(e),n.set(e,r)),r}},o4e=class{constructor(e){this.id=a4e++,this.code=e,this.usedTimes=0}};function l4e(t,e,n,r,i,a,o){const l=new fJ,c=new s4e,u=new Set,d=[],f=i.logarithmicDepthBuffer,p=i.vertexTextures;let m=i.precision;const x={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function b(A){return u.add(A),A===0?"uv":`uv${A}`}function y(A,R,U,F,$){const j=F.fog,H=$.geometry,K=A.isMeshStandardMaterial?F.environment:null,V=(A.isMeshStandardMaterial?n:e).get(A.envMap||K),Q=V&&V.mapping===f2?V.image.height:null,Z=x[A.type];A.precision!==null&&(m=i.getMaxPrecision(A.precision),m!==A.precision&&gn("WebGLProgram.getParameters:",A.precision,"not supported, using",m,"instead."));const ae=H.morphAttributes.position||H.morphAttributes.normal||H.morphAttributes.color,B=ae!==void 0?ae.length:0;let X=0;H.morphAttributes.position!==void 0&&(X=1),H.morphAttributes.normal!==void 0&&(X=2),H.morphAttributes.color!==void 0&&(X=3);let ne,se,be,xe;if(Z){const ft=rc[Z];ne=ft.vertexShader,se=ft.fragmentShader}else ne=A.vertexShader,se=A.fragmentShader,c.update(A),be=c.getVertexShaderID(A),xe=c.getFragmentShaderID(A);const de=t.getRenderTarget(),Pe=t.state.buffers.depth.getReversed(),ie=$.isInstancedMesh===!0,Ne=$.isBatchedMesh===!0,Oe=!!A.map,ge=!!A.matcap,Ke=!!V,G=!!A.aoMap,Y=!!A.lightMap,ce=!!A.bumpMap,q=!!A.normalMap,te=!!A.displacementMap,I=!!A.emissiveMap,fe=!!A.metalnessMap,me=!!A.roughnessMap,Ee=A.anisotropy>0,z=A.clearcoat>0,O=A.dispersion>0,ee=A.iridescence>0,le=A.sheen>0,_e=A.transmission>0,we=Ee&&!!A.anisotropyMap,re=z&&!!A.clearcoatMap,Fe=z&&!!A.clearcoatNormalMap,He=z&&!!A.clearcoatRoughnessMap,Ve=ee&&!!A.iridescenceMap,$e=ee&&!!A.iridescenceThicknessMap,ye=le&&!!A.sheenColorMap,je=le&&!!A.sheenRoughnessMap,Be=!!A.specularMap,Se=!!A.specularColorMap,Xe=!!A.specularIntensityMap,Me=_e&&!!A.transmissionMap,tt=_e&&!!A.thicknessMap,ke=!!A.gradientMap,We=!!A.alphaMap,ze=A.alphaTest>0,W=!!A.alphaHash,De=!!A.extensions;let Ye=lh;A.toneMapped&&(de===null||de.isXRRenderTarget===!0)&&(Ye=t.toneMapping);const xt={shaderID:Z,shaderType:A.type,shaderName:A.name,vertexShader:ne,fragmentShader:se,defines:A.defines,customVertexShaderID:be,customFragmentShaderID:xe,isRawShaderMaterial:A.isRawShaderMaterial===!0,glslVersion:A.glslVersion,precision:m,batching:Ne,batchingColor:Ne&&$._colorsTexture!==null,instancing:ie,instancingColor:ie&&$.instanceColor!==null,instancingMorph:ie&&$.morphTexture!==null,supportsVertexTextures:p,outputColorSpace:de===null?t.outputColorSpace:de.isXRRenderTarget===!0?de.texture.colorSpace:ex,alphaToCoverage:!!A.alphaToCoverage,map:Oe,matcap:ge,envMap:Ke,envMapMode:Ke&&V.mapping,envMapCubeUVHeight:Q,aoMap:G,lightMap:Y,bumpMap:ce,normalMap:q,displacementMap:p&&te,emissiveMap:I,normalMapObjectSpace:q&&A.normalMapType===Yje,normalMapTangentSpace:q&&A.normalMapType===iJ,metalnessMap:fe,roughnessMap:me,anisotropy:Ee,anisotropyMap:we,clearcoat:z,clearcoatMap:re,clearcoatNormalMap:Fe,clearcoatRoughnessMap:He,dispersion:O,iridescence:ee,iridescenceMap:Ve,iridescenceThicknessMap:$e,sheen:le,sheenColorMap:ye,sheenRoughnessMap:je,specularMap:Be,specularColorMap:Se,specularIntensityMap:Xe,transmission:_e,transmissionMap:Me,thicknessMap:tt,gradientMap:ke,opaque:A.transparent===!1&&A.blending===Ag&&A.alphaToCoverage===!1,alphaMap:We,alphaTest:ze,alphaHash:W,combine:A.combine,mapUv:Oe&&b(A.map.channel),aoMapUv:G&&b(A.aoMap.channel),lightMapUv:Y&&b(A.lightMap.channel),bumpMapUv:ce&&b(A.bumpMap.channel),normalMapUv:q&&b(A.normalMap.channel),displacementMapUv:te&&b(A.displacementMap.channel),emissiveMapUv:I&&b(A.emissiveMap.channel),metalnessMapUv:fe&&b(A.metalnessMap.channel),roughnessMapUv:me&&b(A.roughnessMap.channel),anisotropyMapUv:we&&b(A.anisotropyMap.channel),clearcoatMapUv:re&&b(A.clearcoatMap.channel),clearcoatNormalMapUv:Fe&&b(A.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:He&&b(A.clearcoatRoughnessMap.channel),iridescenceMapUv:Ve&&b(A.iridescenceMap.channel),iridescenceThicknessMapUv:$e&&b(A.iridescenceThicknessMap.channel),sheenColorMapUv:ye&&b(A.sheenColorMap.channel),sheenRoughnessMapUv:je&&b(A.sheenRoughnessMap.channel),specularMapUv:Be&&b(A.specularMap.channel),specularColorMapUv:Se&&b(A.specularColorMap.channel),specularIntensityMapUv:Xe&&b(A.specularIntensityMap.channel),transmissionMapUv:Me&&b(A.transmissionMap.channel),thicknessMapUv:tt&&b(A.thicknessMap.channel),alphaMapUv:We&&b(A.alphaMap.channel),vertexTangents:!!H.attributes.tangent&&(q||Ee),vertexColors:A.vertexColors,vertexAlphas:A.vertexColors===!0&&!!H.attributes.color&&H.attributes.color.itemSize===4,pointsUvs:$.isPoints===!0&&!!H.attributes.uv&&(Oe||We),fog:!!j,useFog:A.fog===!0,fogExp2:!!j&&j.isFogExp2,flatShading:A.flatShading===!0&&A.wireframe===!1,sizeAttenuation:A.sizeAttenuation===!0,logarithmicDepthBuffer:f,reversedDepthBuffer:Pe,skinning:$.isSkinnedMesh===!0,morphTargets:H.morphAttributes.position!==void 0,morphNormals:H.morphAttributes.normal!==void 0,morphColors:H.morphAttributes.color!==void 0,morphTargetsCount:B,morphTextureStride:X,numDirLights:R.directional.length,numPointLights:R.point.length,numSpotLights:R.spot.length,numSpotLightMaps:R.spotLightMap.length,numRectAreaLights:R.rectArea.length,numHemiLights:R.hemi.length,numDirLightShadows:R.directionalShadowMap.length,numPointLightShadows:R.pointShadowMap.length,numSpotLightShadows:R.spotShadowMap.length,numSpotLightShadowsWithMaps:R.numSpotLightShadowsWithMaps,numLightProbes:R.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:A.dithering,shadowMapEnabled:t.shadowMap.enabled&&U.length>0,shadowMapType:t.shadowMap.type,toneMapping:Ye,decodeVideoTexture:Oe&&A.map.isVideoTexture===!0&&or.getTransfer(A.map.colorSpace)===Nr,decodeVideoTextureEmissive:I&&A.emissiveMap.isVideoTexture===!0&&or.getTransfer(A.emissiveMap.colorSpace)===Nr,premultipliedAlpha:A.premultipliedAlpha,doubleSided:A.side===ic,flipSided:A.side===Us,useDepthPacking:A.depthPacking>=0,depthPacking:A.depthPacking||0,index0AttributeName:A.index0AttributeName,extensionClipCullDistance:De&&A.extensions.clipCullDistance===!0&&r.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(De&&A.extensions.multiDraw===!0||Ne)&&r.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:r.has("KHR_parallel_shader_compile"),customProgramCacheKey:A.customProgramCacheKey()};return xt.vertexUv1s=u.has(1),xt.vertexUv2s=u.has(2),xt.vertexUv3s=u.has(3),u.clear(),xt}function v(A){const R=[];if(A.shaderID?R.push(A.shaderID):(R.push(A.customVertexShaderID),R.push(A.customFragmentShaderID)),A.defines!==void 0)for(const U in A.defines)R.push(U),R.push(A.defines[U]);return A.isRawShaderMaterial===!1&&(S(R,A),N(R,A),R.push(t.outputColorSpace)),R.push(A.customProgramCacheKey),R.join()}function S(A,R){A.push(R.precision),A.push(R.outputColorSpace),A.push(R.envMapMode),A.push(R.envMapCubeUVHeight),A.push(R.mapUv),A.push(R.alphaMapUv),A.push(R.lightMapUv),A.push(R.aoMapUv),A.push(R.bumpMapUv),A.push(R.normalMapUv),A.push(R.displacementMapUv),A.push(R.emissiveMapUv),A.push(R.metalnessMapUv),A.push(R.roughnessMapUv),A.push(R.anisotropyMapUv),A.push(R.clearcoatMapUv),A.push(R.clearcoatNormalMapUv),A.push(R.clearcoatRoughnessMapUv),A.push(R.iridescenceMapUv),A.push(R.iridescenceThicknessMapUv),A.push(R.sheenColorMapUv),A.push(R.sheenRoughnessMapUv),A.push(R.specularMapUv),A.push(R.specularColorMapUv),A.push(R.specularIntensityMapUv),A.push(R.transmissionMapUv),A.push(R.thicknessMapUv),A.push(R.combine),A.push(R.fogExp2),A.push(R.sizeAttenuation),A.push(R.morphTargetsCount),A.push(R.morphAttributeCount),A.push(R.numDirLights),A.push(R.numPointLights),A.push(R.numSpotLights),A.push(R.numSpotLightMaps),A.push(R.numHemiLights),A.push(R.numRectAreaLights),A.push(R.numDirLightShadows),A.push(R.numPointLightShadows),A.push(R.numSpotLightShadows),A.push(R.numSpotLightShadowsWithMaps),A.push(R.numLightProbes),A.push(R.shadowMapType),A.push(R.toneMapping),A.push(R.numClippingPlanes),A.push(R.numClipIntersection),A.push(R.depthPacking)}function N(A,R){l.disableAll(),R.supportsVertexTextures&&l.enable(0),R.instancing&&l.enable(1),R.instancingColor&&l.enable(2),R.instancingMorph&&l.enable(3),R.matcap&&l.enable(4),R.envMap&&l.enable(5),R.normalMapObjectSpace&&l.enable(6),R.normalMapTangentSpace&&l.enable(7),R.clearcoat&&l.enable(8),R.iridescence&&l.enable(9),R.alphaTest&&l.enable(10),R.vertexColors&&l.enable(11),R.vertexAlphas&&l.enable(12),R.vertexUv1s&&l.enable(13),R.vertexUv2s&&l.enable(14),R.vertexUv3s&&l.enable(15),R.vertexTangents&&l.enable(16),R.anisotropy&&l.enable(17),R.alphaHash&&l.enable(18),R.batching&&l.enable(19),R.dispersion&&l.enable(20),R.batchingColor&&l.enable(21),R.gradientMap&&l.enable(22),A.push(l.mask),l.disableAll(),R.fog&&l.enable(0),R.useFog&&l.enable(1),R.flatShading&&l.enable(2),R.logarithmicDepthBuffer&&l.enable(3),R.reversedDepthBuffer&&l.enable(4),R.skinning&&l.enable(5),R.morphTargets&&l.enable(6),R.morphNormals&&l.enable(7),R.morphColors&&l.enable(8),R.premultipliedAlpha&&l.enable(9),R.shadowMapEnabled&&l.enable(10),R.doubleSided&&l.enable(11),R.flipSided&&l.enable(12),R.useDepthPacking&&l.enable(13),R.dithering&&l.enable(14),R.transmission&&l.enable(15),R.sheen&&l.enable(16),R.opaque&&l.enable(17),R.pointsUvs&&l.enable(18),R.decodeVideoTexture&&l.enable(19),R.decodeVideoTextureEmissive&&l.enable(20),R.alphaToCoverage&&l.enable(21),A.push(l.mask)}function T(A){const R=x[A.type];let U;if(R){const F=rc[R];U=kPe.clone(F.uniforms)}else U=A.uniforms;return U}function k(A,R){let U;for(let F=0,$=d.length;F<$;F++){const j=d[F];if(j.cacheKey===R){U=j,++U.usedTimes;break}}return U===void 0&&(U=new i4e(t,R,A,a),d.push(U)),U}function C(A){if(--A.usedTimes===0){const R=d.indexOf(A);d[R]=d[d.length-1],d.pop(),A.destroy()}}function E(A){c.remove(A)}function D(){c.dispose()}return{getParameters:y,getProgramCacheKey:v,getUniforms:T,acquireProgram:k,releaseProgram:C,releaseShaderCache:E,programs:d,dispose:D}}function c4e(){let t=new WeakMap;function e(o){return t.has(o)}function n(o){let l=t.get(o);return l===void 0&&(l={},t.set(o,l)),l}function r(o){t.delete(o)}function i(o,l,c){t.get(o)[l]=c}function a(){t=new WeakMap}return{has:e,get:n,remove:r,update:i,dispose:a}}function u4e(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 kV(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 EV(){const t=[];let e=0;const n=[],r=[],i=[];function a(){e=0,n.length=0,r.length=0,i.length=0}function o(f,p,m,x,b,y){let v=t[e];return v===void 0?(v={id:f.id,object:f,geometry:p,material:m,groupOrder:x,renderOrder:f.renderOrder,z:b,group:y},t[e]=v):(v.id=f.id,v.object=f,v.geometry=p,v.material=m,v.groupOrder=x,v.renderOrder=f.renderOrder,v.z=b,v.group=y),e++,v}function l(f,p,m,x,b,y){const v=o(f,p,m,x,b,y);m.transmission>0?r.push(v):m.transparent===!0?i.push(v):n.push(v)}function c(f,p,m,x,b,y){const v=o(f,p,m,x,b,y);m.transmission>0?r.unshift(v):m.transparent===!0?i.unshift(v):n.unshift(v)}function u(f,p){n.length>1&&n.sort(f||u4e),r.length>1&&r.sort(p||kV),i.length>1&&i.sort(p||kV)}function d(){for(let f=e,p=t.length;f<p;f++){const m=t[f];if(m.id===null)break;m.id=null,m.object=null,m.geometry=null,m.material=null,m.group=null}}return{opaque:n,transmissive:r,transparent:i,init:a,push:l,unshift:c,finish:d,sort:u}}function d4e(){let t=new WeakMap;function e(r,i){const a=t.get(r);let o;return a===void 0?(o=new EV,t.set(r,[o])):i>=a.length?(o=new EV,a.push(o)):o=a[i],o}function n(){t=new WeakMap}return{get:e,dispose:n}}function h4e(){const t={};return{get:function(e){if(t[e.id]!==void 0)return t[e.id];let n;switch(e.type){case"DirectionalLight":n={direction:new dt,color:new Bn};break;case"SpotLight":n={position:new dt,direction:new dt,color:new Bn,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new dt,color:new Bn,distance:0,decay:0};break;case"HemisphereLight":n={direction:new dt,skyColor:new Bn,groundColor:new Bn};break;case"RectAreaLight":n={color:new Bn,position:new dt,halfWidth:new dt,halfHeight:new dt};break}return t[e.id]=n,n}}}function f4e(){const t={};return{get:function(e){if(t[e.id]!==void 0)return t[e.id];let n;switch(e.type){case"DirectionalLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Tn};break;case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Tn};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Tn,shadowCameraNear:1,shadowCameraFar:1e3};break}return t[e.id]=n,n}}}let m4e=0;function p4e(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function g4e(t){const e=new h4e,n=f4e(),r={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let u=0;u<9;u++)r.probe.push(new dt);const i=new dt,a=new Vi,o=new Vi;function l(u){let d=0,f=0,p=0;for(let A=0;A<9;A++)r.probe[A].set(0,0,0);let m=0,x=0,b=0,y=0,v=0,S=0,N=0,T=0,k=0,C=0,E=0;u.sort(p4e);for(let A=0,R=u.length;A<R;A++){const U=u[A],F=U.color,$=U.intensity,j=U.distance,H=U.shadow&&U.shadow.map?U.shadow.map.texture:null;if(U.isAmbientLight)d+=F.r*$,f+=F.g*$,p+=F.b*$;else if(U.isLightProbe){for(let K=0;K<9;K++)r.probe[K].addScaledVector(U.sh.coefficients[K],$);E++}else if(U.isDirectionalLight){const K=e.get(U);if(K.color.copy(U.color).multiplyScalar(U.intensity),U.castShadow){const V=U.shadow,Q=n.get(U);Q.shadowIntensity=V.intensity,Q.shadowBias=V.bias,Q.shadowNormalBias=V.normalBias,Q.shadowRadius=V.radius,Q.shadowMapSize=V.mapSize,r.directionalShadow[m]=Q,r.directionalShadowMap[m]=H,r.directionalShadowMatrix[m]=U.shadow.matrix,S++}r.directional[m]=K,m++}else if(U.isSpotLight){const K=e.get(U);K.position.setFromMatrixPosition(U.matrixWorld),K.color.copy(F).multiplyScalar($),K.distance=j,K.coneCos=Math.cos(U.angle),K.penumbraCos=Math.cos(U.angle*(1-U.penumbra)),K.decay=U.decay,r.spot[b]=K;const V=U.shadow;if(U.map&&(r.spotLightMap[k]=U.map,k++,V.updateMatrices(U),U.castShadow&&C++),r.spotLightMatrix[b]=V.matrix,U.castShadow){const Q=n.get(U);Q.shadowIntensity=V.intensity,Q.shadowBias=V.bias,Q.shadowNormalBias=V.normalBias,Q.shadowRadius=V.radius,Q.shadowMapSize=V.mapSize,r.spotShadow[b]=Q,r.spotShadowMap[b]=H,T++}b++}else if(U.isRectAreaLight){const K=e.get(U);K.color.copy(F).multiplyScalar($),K.halfWidth.set(U.width*.5,0,0),K.halfHeight.set(0,U.height*.5,0),r.rectArea[y]=K,y++}else if(U.isPointLight){const K=e.get(U);if(K.color.copy(U.color).multiplyScalar(U.intensity),K.distance=U.distance,K.decay=U.decay,U.castShadow){const V=U.shadow,Q=n.get(U);Q.shadowIntensity=V.intensity,Q.shadowBias=V.bias,Q.shadowNormalBias=V.normalBias,Q.shadowRadius=V.radius,Q.shadowMapSize=V.mapSize,Q.shadowCameraNear=V.camera.near,Q.shadowCameraFar=V.camera.far,r.pointShadow[x]=Q,r.pointShadowMap[x]=H,r.pointShadowMatrix[x]=U.shadow.matrix,N++}r.point[x]=K,x++}else if(U.isHemisphereLight){const K=e.get(U);K.skyColor.copy(U.color).multiplyScalar($),K.groundColor.copy(U.groundColor).multiplyScalar($),r.hemi[v]=K,v++}}y>0&&(t.has("OES_texture_float_linear")===!0?(r.rectAreaLTC1=Ot.LTC_FLOAT_1,r.rectAreaLTC2=Ot.LTC_FLOAT_2):(r.rectAreaLTC1=Ot.LTC_HALF_1,r.rectAreaLTC2=Ot.LTC_HALF_2)),r.ambient[0]=d,r.ambient[1]=f,r.ambient[2]=p;const D=r.hash;(D.directionalLength!==m||D.pointLength!==x||D.spotLength!==b||D.rectAreaLength!==y||D.hemiLength!==v||D.numDirectionalShadows!==S||D.numPointShadows!==N||D.numSpotShadows!==T||D.numSpotMaps!==k||D.numLightProbes!==E)&&(r.directional.length=m,r.spot.length=b,r.rectArea.length=y,r.point.length=x,r.hemi.length=v,r.directionalShadow.length=S,r.directionalShadowMap.length=S,r.pointShadow.length=N,r.pointShadowMap.length=N,r.spotShadow.length=T,r.spotShadowMap.length=T,r.directionalShadowMatrix.length=S,r.pointShadowMatrix.length=N,r.spotLightMatrix.length=T+k-C,r.spotLightMap.length=k,r.numSpotLightShadowsWithMaps=C,r.numLightProbes=E,D.directionalLength=m,D.pointLength=x,D.spotLength=b,D.rectAreaLength=y,D.hemiLength=v,D.numDirectionalShadows=S,D.numPointShadows=N,D.numSpotShadows=T,D.numSpotMaps=k,D.numLightProbes=E,r.version=m4e++)}function c(u,d){let f=0,p=0,m=0,x=0,b=0;const y=d.matrixWorldInverse;for(let v=0,S=u.length;v<S;v++){const N=u[v];if(N.isDirectionalLight){const T=r.directional[f];T.direction.setFromMatrixPosition(N.matrixWorld),i.setFromMatrixPosition(N.target.matrixWorld),T.direction.sub(i),T.direction.transformDirection(y),f++}else if(N.isSpotLight){const T=r.spot[m];T.position.setFromMatrixPosition(N.matrixWorld),T.position.applyMatrix4(y),T.direction.setFromMatrixPosition(N.matrixWorld),i.setFromMatrixPosition(N.target.matrixWorld),T.direction.sub(i),T.direction.transformDirection(y),m++}else if(N.isRectAreaLight){const T=r.rectArea[x];T.position.setFromMatrixPosition(N.matrixWorld),T.position.applyMatrix4(y),o.identity(),a.copy(N.matrixWorld),a.premultiply(y),o.extractRotation(a),T.halfWidth.set(N.width*.5,0,0),T.halfHeight.set(0,N.height*.5,0),T.halfWidth.applyMatrix4(o),T.halfHeight.applyMatrix4(o),x++}else if(N.isPointLight){const T=r.point[p];T.position.setFromMatrixPosition(N.matrixWorld),T.position.applyMatrix4(y),p++}else if(N.isHemisphereLight){const T=r.hemi[b];T.direction.setFromMatrixPosition(N.matrixWorld),T.direction.transformDirection(y),b++}}}return{setup:l,setupView:c,state:r}}function TV(t){const e=new g4e(t),n=[],r=[];function i(d){u.camera=d,n.length=0,r.length=0}function a(d){n.push(d)}function o(d){r.push(d)}function l(){e.setup(n)}function c(d){e.setupView(n,d)}const u={lightsArray:n,shadowsArray:r,camera:null,lights:e,transmissionRenderTarget:{}};return{init:i,state:u,setupLights:l,setupLightsView:c,pushLight:a,pushShadow:o}}function x4e(t){let e=new WeakMap;function n(i,a=0){const o=e.get(i);let l;return o===void 0?(l=new TV(t),e.set(i,[l])):a>=o.length?(l=new TV(t),o.push(l)):l=o[a],l}function r(){e=new WeakMap}return{get:n,dispose:r}}const b4e=`void main() {
- gl_Position = vec4( position, 1.0 );
- }`,y4e=`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 v4e(t,e,n){let r=new eL;const i=new Tn,a=new Tn,o=new Ui,l=new zPe({depthPacking:Xje}),c=new BPe,u={},d=n.maxTextureSize,f={[kh]:Us,[Us]:kh,[ic]:ic},p=new $u({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Tn},radius:{value:4}},vertexShader:b4e,fragmentShader:y4e}),m=p.clone();m.defines.HORIZONTAL_PASS=1;const x=new Ac;x.setAttribute("position",new nl(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const b=new vc(x,p),y=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=XZ;let v=this.type;this.render=function(C,E,D){if(y.enabled===!1||y.autoUpdate===!1&&y.needsUpdate===!1||C.length===0)return;const A=t.getRenderTarget(),R=t.getActiveCubeFace(),U=t.getActiveMipmapLevel(),F=t.state;F.setBlending(Tu),F.buffers.depth.getReversed()===!0?F.buffers.color.setClear(0,0,0,0):F.buffers.color.setClear(1,1,1,1),F.buffers.depth.setTest(!0),F.setScissorTest(!1);const $=v!==ou&&this.type===ou,j=v===ou&&this.type!==ou;for(let H=0,K=C.length;H<K;H++){const V=C[H],Q=V.shadow;if(Q===void 0){gn("WebGLShadowMap:",V,"has no shadow.");continue}if(Q.autoUpdate===!1&&Q.needsUpdate===!1)continue;i.copy(Q.mapSize);const Z=Q.getFrameExtents();if(i.multiply(Z),a.copy(Q.mapSize),(i.x>d||i.y>d)&&(i.x>d&&(a.x=Math.floor(d/Z.x),i.x=a.x*Z.x,Q.mapSize.x=a.x),i.y>d&&(a.y=Math.floor(d/Z.y),i.y=a.y*Z.y,Q.mapSize.y=a.y)),Q.map===null||$===!0||j===!0){const B=this.type!==ou?{minFilter:po,magFilter:po}:{};Q.map!==null&&Q.map.dispose(),Q.map=new xm(i.x,i.y,B),Q.map.texture.name=V.name+".shadowMap",Q.camera.updateProjectionMatrix()}t.setRenderTarget(Q.map),t.clear();const ae=Q.getViewportCount();for(let B=0;B<ae;B++){const X=Q.getViewport(B);o.set(a.x*X.x,a.y*X.y,a.x*X.z,a.y*X.w),F.viewport(o),Q.updateMatrices(V,B),r=Q.getFrustum(),T(E,D,Q.camera,V,this.type)}Q.isPointLightShadow!==!0&&this.type===ou&&S(Q,D),Q.needsUpdate=!1}v=this.type,y.needsUpdate=!1,t.setRenderTarget(A,R,U)};function S(C,E){const D=e.update(b);p.defines.VSM_SAMPLES!==C.blurSamples&&(p.defines.VSM_SAMPLES=C.blurSamples,m.defines.VSM_SAMPLES=C.blurSamples,p.needsUpdate=!0,m.needsUpdate=!0),C.mapPass===null&&(C.mapPass=new xm(i.x,i.y)),p.uniforms.shadow_pass.value=C.map.texture,p.uniforms.resolution.value=C.mapSize,p.uniforms.radius.value=C.radius,t.setRenderTarget(C.mapPass),t.clear(),t.renderBufferDirect(E,null,D,p,b,null),m.uniforms.shadow_pass.value=C.mapPass.texture,m.uniforms.resolution.value=C.mapSize,m.uniforms.radius.value=C.radius,t.setRenderTarget(C.map),t.clear(),t.renderBufferDirect(E,null,D,m,b,null)}function N(C,E,D,A){let R=null;const U=D.isPointLight===!0?C.customDistanceMaterial:C.customDepthMaterial;if(U!==void 0)R=U;else if(R=D.isPointLight===!0?c:l,t.localClippingEnabled&&E.clipShadows===!0&&Array.isArray(E.clippingPlanes)&&E.clippingPlanes.length!==0||E.displacementMap&&E.displacementScale!==0||E.alphaMap&&E.alphaTest>0||E.map&&E.alphaTest>0||E.alphaToCoverage===!0){const F=R.uuid,$=E.uuid;let j=u[F];j===void 0&&(j={},u[F]=j);let H=j[$];H===void 0&&(H=R.clone(),j[$]=H,E.addEventListener("dispose",k)),R=H}if(R.visible=E.visible,R.wireframe=E.wireframe,A===ou?R.side=E.shadowSide!==null?E.shadowSide:E.side:R.side=E.shadowSide!==null?E.shadowSide:f[E.side],R.alphaMap=E.alphaMap,R.alphaTest=E.alphaToCoverage===!0?.5:E.alphaTest,R.map=E.map,R.clipShadows=E.clipShadows,R.clippingPlanes=E.clippingPlanes,R.clipIntersection=E.clipIntersection,R.displacementMap=E.displacementMap,R.displacementScale=E.displacementScale,R.displacementBias=E.displacementBias,R.wireframeLinewidth=E.wireframeLinewidth,R.linewidth=E.linewidth,D.isPointLight===!0&&R.isMeshDistanceMaterial===!0){const F=t.properties.get(R);F.light=D}return R}function T(C,E,D,A,R){if(C.visible===!1)return;if(C.layers.test(E.layers)&&(C.isMesh||C.isLine||C.isPoints)&&(C.castShadow||C.receiveShadow&&R===ou)&&(!C.frustumCulled||r.intersectsObject(C))){C.modelViewMatrix.multiplyMatrices(D.matrixWorldInverse,C.matrixWorld);const $=e.update(C),j=C.material;if(Array.isArray(j)){const H=$.groups;for(let K=0,V=H.length;K<V;K++){const Q=H[K],Z=j[Q.materialIndex];if(Z&&Z.visible){const ae=N(C,Z,A,R);C.onBeforeShadow(t,C,E,D,$,ae,Q),t.renderBufferDirect(D,null,$,ae,C,Q),C.onAfterShadow(t,C,E,D,$,ae,Q)}}}else if(j.visible){const H=N(C,j,A,R);C.onBeforeShadow(t,C,E,D,$,H,null),t.renderBufferDirect(D,null,$,H,C,null),C.onAfterShadow(t,C,E,D,$,H,null)}}const F=C.children;for(let $=0,j=F.length;$<j;$++)T(F[$],E,D,A,R)}function k(C){C.target.removeEventListener("dispose",k);for(const D in u){const A=u[D],R=C.target.uuid;R in A&&(A[R].dispose(),delete A[R])}}}const w4e={[N3]:k3,[E3]:C3,[T3]:j3,[Qg]:A3,[k3]:N3,[C3]:E3,[j3]:T3,[A3]:Qg};function _4e(t,e){function n(){let Me=!1;const tt=new Ui;let ke=null;const We=new Ui(0,0,0,0);return{setMask:function(ze){ke!==ze&&!Me&&(t.colorMask(ze,ze,ze,ze),ke=ze)},setLocked:function(ze){Me=ze},setClear:function(ze,W,De,Ye,xt){xt===!0&&(ze*=Ye,W*=Ye,De*=Ye),tt.set(ze,W,De,Ye),We.equals(tt)===!1&&(t.clearColor(ze,W,De,Ye),We.copy(tt))},reset:function(){Me=!1,ke=null,We.set(-1,0,0,0)}}}function r(){let Me=!1,tt=!1,ke=null,We=null,ze=null;return{setReversed:function(W){if(tt!==W){const De=e.get("EXT_clip_control");W?De.clipControlEXT(De.LOWER_LEFT_EXT,De.ZERO_TO_ONE_EXT):De.clipControlEXT(De.LOWER_LEFT_EXT,De.NEGATIVE_ONE_TO_ONE_EXT),tt=W;const Ye=ze;ze=null,this.setClear(Ye)}},getReversed:function(){return tt},setTest:function(W){W?de(t.DEPTH_TEST):Pe(t.DEPTH_TEST)},setMask:function(W){ke!==W&&!Me&&(t.depthMask(W),ke=W)},setFunc:function(W){if(tt&&(W=w4e[W]),We!==W){switch(W){case N3:t.depthFunc(t.NEVER);break;case k3:t.depthFunc(t.ALWAYS);break;case E3:t.depthFunc(t.LESS);break;case Qg:t.depthFunc(t.LEQUAL);break;case T3:t.depthFunc(t.EQUAL);break;case A3:t.depthFunc(t.GEQUAL);break;case C3:t.depthFunc(t.GREATER);break;case j3:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}We=W}},setLocked:function(W){Me=W},setClear:function(W){ze!==W&&(tt&&(W=1-W),t.clearDepth(W),ze=W)},reset:function(){Me=!1,ke=null,We=null,ze=null,tt=!1}}}function i(){let Me=!1,tt=null,ke=null,We=null,ze=null,W=null,De=null,Ye=null,xt=null;return{setTest:function(ft){Me||(ft?de(t.STENCIL_TEST):Pe(t.STENCIL_TEST))},setMask:function(ft){tt!==ft&&!Me&&(t.stencilMask(ft),tt=ft)},setFunc:function(ft,Bt,Lt){(ke!==ft||We!==Bt||ze!==Lt)&&(t.stencilFunc(ft,Bt,Lt),ke=ft,We=Bt,ze=Lt)},setOp:function(ft,Bt,Lt){(W!==ft||De!==Bt||Ye!==Lt)&&(t.stencilOp(ft,Bt,Lt),W=ft,De=Bt,Ye=Lt)},setLocked:function(ft){Me=ft},setClear:function(ft){xt!==ft&&(t.clearStencil(ft),xt=ft)},reset:function(){Me=!1,tt=null,ke=null,We=null,ze=null,W=null,De=null,Ye=null,xt=null}}}const a=new n,o=new r,l=new i,c=new WeakMap,u=new WeakMap;let d={},f={},p=new WeakMap,m=[],x=null,b=!1,y=null,v=null,S=null,N=null,T=null,k=null,C=null,E=new Bn(0,0,0),D=0,A=!1,R=null,U=null,F=null,$=null,j=null;const H=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let K=!1,V=0;const Q=t.getParameter(t.VERSION);Q.indexOf("WebGL")!==-1?(V=parseFloat(/^WebGL (\d)/.exec(Q)[1]),K=V>=1):Q.indexOf("OpenGL ES")!==-1&&(V=parseFloat(/^OpenGL ES (\d)/.exec(Q)[1]),K=V>=2);let Z=null,ae={};const B=t.getParameter(t.SCISSOR_BOX),X=t.getParameter(t.VIEWPORT),ne=new Ui().fromArray(B),se=new Ui().fromArray(X);function be(Me,tt,ke,We){const ze=new Uint8Array(4),W=t.createTexture();t.bindTexture(Me,W),t.texParameteri(Me,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(Me,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let De=0;De<ke;De++)Me===t.TEXTURE_3D||Me===t.TEXTURE_2D_ARRAY?t.texImage3D(tt,0,t.RGBA,1,1,We,0,t.RGBA,t.UNSIGNED_BYTE,ze):t.texImage2D(tt+De,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,ze);return W}const xe={};xe[t.TEXTURE_2D]=be(t.TEXTURE_2D,t.TEXTURE_2D,1),xe[t.TEXTURE_CUBE_MAP]=be(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),xe[t.TEXTURE_2D_ARRAY]=be(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),xe[t.TEXTURE_3D]=be(t.TEXTURE_3D,t.TEXTURE_3D,1,1),a.setClear(0,0,0,1),o.setClear(1),l.setClear(0),de(t.DEPTH_TEST),o.setFunc(Qg),ce(!1),q(k$),de(t.CULL_FACE),G(Tu);function de(Me){d[Me]!==!0&&(t.enable(Me),d[Me]=!0)}function Pe(Me){d[Me]!==!1&&(t.disable(Me),d[Me]=!1)}function ie(Me,tt){return f[Me]!==tt?(t.bindFramebuffer(Me,tt),f[Me]=tt,Me===t.DRAW_FRAMEBUFFER&&(f[t.FRAMEBUFFER]=tt),Me===t.FRAMEBUFFER&&(f[t.DRAW_FRAMEBUFFER]=tt),!0):!1}function Ne(Me,tt){let ke=m,We=!1;if(Me){ke=p.get(tt),ke===void 0&&(ke=[],p.set(tt,ke));const ze=Me.textures;if(ke.length!==ze.length||ke[0]!==t.COLOR_ATTACHMENT0){for(let W=0,De=ze.length;W<De;W++)ke[W]=t.COLOR_ATTACHMENT0+W;ke.length=ze.length,We=!0}}else ke[0]!==t.BACK&&(ke[0]=t.BACK,We=!0);We&&t.drawBuffers(ke)}function Oe(Me){return x!==Me?(t.useProgram(Me),x=Me,!0):!1}const ge={[Mf]:t.FUNC_ADD,[wje]:t.FUNC_SUBTRACT,[_je]:t.FUNC_REVERSE_SUBTRACT};ge[Sje]=t.MIN,ge[Mje]=t.MAX;const Ke={[Nje]:t.ZERO,[kje]:t.ONE,[Eje]:t.SRC_COLOR,[S3]:t.SRC_ALPHA,[Dje]:t.SRC_ALPHA_SATURATE,[jje]:t.DST_COLOR,[Aje]:t.DST_ALPHA,[Tje]:t.ONE_MINUS_SRC_COLOR,[M3]:t.ONE_MINUS_SRC_ALPHA,[Pje]:t.ONE_MINUS_DST_COLOR,[Cje]:t.ONE_MINUS_DST_ALPHA,[Rje]:t.CONSTANT_COLOR,[Oje]:t.ONE_MINUS_CONSTANT_COLOR,[Lje]:t.CONSTANT_ALPHA,[Fje]:t.ONE_MINUS_CONSTANT_ALPHA};function G(Me,tt,ke,We,ze,W,De,Ye,xt,ft){if(Me===Tu){b===!0&&(Pe(t.BLEND),b=!1);return}if(b===!1&&(de(t.BLEND),b=!0),Me!==vje){if(Me!==y||ft!==A){if((v!==Mf||T!==Mf)&&(t.blendEquation(t.FUNC_ADD),v=Mf,T=Mf),ft)switch(Me){case Ag:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case E$:t.blendFunc(t.ONE,t.ONE);break;case T$:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case A$:t.blendFuncSeparate(t.DST_COLOR,t.ONE_MINUS_SRC_ALPHA,t.ZERO,t.ONE);break;default:Ei("WebGLState: Invalid blending: ",Me);break}else switch(Me){case Ag:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case E$:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE,t.ONE,t.ONE);break;case T$:Ei("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case A$:Ei("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Ei("WebGLState: Invalid blending: ",Me);break}S=null,N=null,k=null,C=null,E.set(0,0,0),D=0,y=Me,A=ft}return}ze=ze||tt,W=W||ke,De=De||We,(tt!==v||ze!==T)&&(t.blendEquationSeparate(ge[tt],ge[ze]),v=tt,T=ze),(ke!==S||We!==N||W!==k||De!==C)&&(t.blendFuncSeparate(Ke[ke],Ke[We],Ke[W],Ke[De]),S=ke,N=We,k=W,C=De),(Ye.equals(E)===!1||xt!==D)&&(t.blendColor(Ye.r,Ye.g,Ye.b,xt),E.copy(Ye),D=xt),y=Me,A=!1}function Y(Me,tt){Me.side===ic?Pe(t.CULL_FACE):de(t.CULL_FACE);let ke=Me.side===Us;tt&&(ke=!ke),ce(ke),Me.blending===Ag&&Me.transparent===!1?G(Tu):G(Me.blending,Me.blendEquation,Me.blendSrc,Me.blendDst,Me.blendEquationAlpha,Me.blendSrcAlpha,Me.blendDstAlpha,Me.blendColor,Me.blendAlpha,Me.premultipliedAlpha),o.setFunc(Me.depthFunc),o.setTest(Me.depthTest),o.setMask(Me.depthWrite),a.setMask(Me.colorWrite);const We=Me.stencilWrite;l.setTest(We),We&&(l.setMask(Me.stencilWriteMask),l.setFunc(Me.stencilFunc,Me.stencilRef,Me.stencilFuncMask),l.setOp(Me.stencilFail,Me.stencilZFail,Me.stencilZPass)),I(Me.polygonOffset,Me.polygonOffsetFactor,Me.polygonOffsetUnits),Me.alphaToCoverage===!0?de(t.SAMPLE_ALPHA_TO_COVERAGE):Pe(t.SAMPLE_ALPHA_TO_COVERAGE)}function ce(Me){R!==Me&&(Me?t.frontFace(t.CW):t.frontFace(t.CCW),R=Me)}function q(Me){Me!==xje?(de(t.CULL_FACE),Me!==U&&(Me===k$?t.cullFace(t.BACK):Me===bje?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):Pe(t.CULL_FACE),U=Me}function te(Me){Me!==F&&(K&&t.lineWidth(Me),F=Me)}function I(Me,tt,ke){Me?(de(t.POLYGON_OFFSET_FILL),($!==tt||j!==ke)&&(t.polygonOffset(tt,ke),$=tt,j=ke)):Pe(t.POLYGON_OFFSET_FILL)}function fe(Me){Me?de(t.SCISSOR_TEST):Pe(t.SCISSOR_TEST)}function me(Me){Me===void 0&&(Me=t.TEXTURE0+H-1),Z!==Me&&(t.activeTexture(Me),Z=Me)}function Ee(Me,tt,ke){ke===void 0&&(Z===null?ke=t.TEXTURE0+H-1:ke=Z);let We=ae[ke];We===void 0&&(We={type:void 0,texture:void 0},ae[ke]=We),(We.type!==Me||We.texture!==tt)&&(Z!==ke&&(t.activeTexture(ke),Z=ke),t.bindTexture(Me,tt||xe[Me]),We.type=Me,We.texture=tt)}function z(){const Me=ae[Z];Me!==void 0&&Me.type!==void 0&&(t.bindTexture(Me.type,null),Me.type=void 0,Me.texture=void 0)}function O(){try{t.compressedTexImage2D(...arguments)}catch(Me){Me("WebGLState:",Me)}}function ee(){try{t.compressedTexImage3D(...arguments)}catch(Me){Me("WebGLState:",Me)}}function le(){try{t.texSubImage2D(...arguments)}catch(Me){Me("WebGLState:",Me)}}function _e(){try{t.texSubImage3D(...arguments)}catch(Me){Me("WebGLState:",Me)}}function we(){try{t.compressedTexSubImage2D(...arguments)}catch(Me){Me("WebGLState:",Me)}}function re(){try{t.compressedTexSubImage3D(...arguments)}catch(Me){Me("WebGLState:",Me)}}function Fe(){try{t.texStorage2D(...arguments)}catch(Me){Me("WebGLState:",Me)}}function He(){try{t.texStorage3D(...arguments)}catch(Me){Me("WebGLState:",Me)}}function Ve(){try{t.texImage2D(...arguments)}catch(Me){Me("WebGLState:",Me)}}function $e(){try{t.texImage3D(...arguments)}catch(Me){Me("WebGLState:",Me)}}function ye(Me){ne.equals(Me)===!1&&(t.scissor(Me.x,Me.y,Me.z,Me.w),ne.copy(Me))}function je(Me){se.equals(Me)===!1&&(t.viewport(Me.x,Me.y,Me.z,Me.w),se.copy(Me))}function Be(Me,tt){let ke=u.get(tt);ke===void 0&&(ke=new WeakMap,u.set(tt,ke));let We=ke.get(Me);We===void 0&&(We=t.getUniformBlockIndex(tt,Me.name),ke.set(Me,We))}function Se(Me,tt){const We=u.get(tt).get(Me);c.get(tt)!==We&&(t.uniformBlockBinding(tt,We,Me.__bindingPointIndex),c.set(tt,We))}function Xe(){t.disable(t.BLEND),t.disable(t.CULL_FACE),t.disable(t.DEPTH_TEST),t.disable(t.POLYGON_OFFSET_FILL),t.disable(t.SCISSOR_TEST),t.disable(t.STENCIL_TEST),t.disable(t.SAMPLE_ALPHA_TO_COVERAGE),t.blendEquation(t.FUNC_ADD),t.blendFunc(t.ONE,t.ZERO),t.blendFuncSeparate(t.ONE,t.ZERO,t.ONE,t.ZERO),t.blendColor(0,0,0,0),t.colorMask(!0,!0,!0,!0),t.clearColor(0,0,0,0),t.depthMask(!0),t.depthFunc(t.LESS),o.setReversed(!1),t.clearDepth(1),t.stencilMask(4294967295),t.stencilFunc(t.ALWAYS,0,4294967295),t.stencilOp(t.KEEP,t.KEEP,t.KEEP),t.clearStencil(0),t.cullFace(t.BACK),t.frontFace(t.CCW),t.polygonOffset(0,0),t.activeTexture(t.TEXTURE0),t.bindFramebuffer(t.FRAMEBUFFER,null),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),t.bindFramebuffer(t.READ_FRAMEBUFFER,null),t.useProgram(null),t.lineWidth(1),t.scissor(0,0,t.canvas.width,t.canvas.height),t.viewport(0,0,t.canvas.width,t.canvas.height),d={},Z=null,ae={},f={},p=new WeakMap,m=[],x=null,b=!1,y=null,v=null,S=null,N=null,T=null,k=null,C=null,E=new Bn(0,0,0),D=0,A=!1,R=null,U=null,F=null,$=null,j=null,ne.set(0,0,t.canvas.width,t.canvas.height),se.set(0,0,t.canvas.width,t.canvas.height),a.reset(),o.reset(),l.reset()}return{buffers:{color:a,depth:o,stencil:l},enable:de,disable:Pe,bindFramebuffer:ie,drawBuffers:Ne,useProgram:Oe,setBlending:G,setMaterial:Y,setFlipSided:ce,setCullFace:q,setLineWidth:te,setPolygonOffset:I,setScissorTest:fe,activeTexture:me,bindTexture:Ee,unbindTexture:z,compressedTexImage2D:O,compressedTexImage3D:ee,texImage2D:Ve,texImage3D:$e,updateUBOMapping:Be,uniformBlockBinding:Se,texStorage2D:Fe,texStorage3D:He,texSubImage2D:le,texSubImage3D:_e,compressedTexSubImage2D:we,compressedTexSubImage3D:re,scissor:ye,viewport:je,reset:Xe}}function S4e(t,e,n,r,i,a,o){const l=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),u=new Tn,d=new WeakMap;let f;const p=new WeakMap;let m=!1;try{m=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function x(z,O){return m?new OffscreenCanvas(z,O):XS("canvas")}function b(z,O,ee){let le=1;const _e=Ee(z);if((_e.width>ee||_e.height>ee)&&(le=ee/Math.max(_e.width,_e.height)),le<1)if(typeof HTMLImageElement<"u"&&z instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&z instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&z instanceof ImageBitmap||typeof VideoFrame<"u"&&z instanceof VideoFrame){const we=Math.floor(le*_e.width),re=Math.floor(le*_e.height);f===void 0&&(f=x(we,re));const Fe=O?x(we,re):f;return Fe.width=we,Fe.height=re,Fe.getContext("2d").drawImage(z,0,0,we,re),gn("WebGLRenderer: Texture has been resized from ("+_e.width+"x"+_e.height+") to ("+we+"x"+re+")."),Fe}else return"data"in z&&gn("WebGLRenderer: Image in DataTexture is too big ("+_e.width+"x"+_e.height+")."),z;return z}function y(z){return z.generateMipmaps}function v(z){t.generateMipmap(z)}function S(z){return z.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:z.isWebGL3DRenderTarget?t.TEXTURE_3D:z.isWebGLArrayRenderTarget||z.isCompressedArrayTexture?t.TEXTURE_2D_ARRAY:t.TEXTURE_2D}function N(z,O,ee,le,_e=!1){if(z!==null){if(t[z]!==void 0)return t[z];gn("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+z+"'")}let we=O;if(O===t.RED&&(ee===t.FLOAT&&(we=t.R32F),ee===t.HALF_FLOAT&&(we=t.R16F),ee===t.UNSIGNED_BYTE&&(we=t.R8)),O===t.RED_INTEGER&&(ee===t.UNSIGNED_BYTE&&(we=t.R8UI),ee===t.UNSIGNED_SHORT&&(we=t.R16UI),ee===t.UNSIGNED_INT&&(we=t.R32UI),ee===t.BYTE&&(we=t.R8I),ee===t.SHORT&&(we=t.R16I),ee===t.INT&&(we=t.R32I)),O===t.RG&&(ee===t.FLOAT&&(we=t.RG32F),ee===t.HALF_FLOAT&&(we=t.RG16F),ee===t.UNSIGNED_BYTE&&(we=t.RG8)),O===t.RG_INTEGER&&(ee===t.UNSIGNED_BYTE&&(we=t.RG8UI),ee===t.UNSIGNED_SHORT&&(we=t.RG16UI),ee===t.UNSIGNED_INT&&(we=t.RG32UI),ee===t.BYTE&&(we=t.RG8I),ee===t.SHORT&&(we=t.RG16I),ee===t.INT&&(we=t.RG32I)),O===t.RGB_INTEGER&&(ee===t.UNSIGNED_BYTE&&(we=t.RGB8UI),ee===t.UNSIGNED_SHORT&&(we=t.RGB16UI),ee===t.UNSIGNED_INT&&(we=t.RGB32UI),ee===t.BYTE&&(we=t.RGB8I),ee===t.SHORT&&(we=t.RGB16I),ee===t.INT&&(we=t.RGB32I)),O===t.RGBA_INTEGER&&(ee===t.UNSIGNED_BYTE&&(we=t.RGBA8UI),ee===t.UNSIGNED_SHORT&&(we=t.RGBA16UI),ee===t.UNSIGNED_INT&&(we=t.RGBA32UI),ee===t.BYTE&&(we=t.RGBA8I),ee===t.SHORT&&(we=t.RGBA16I),ee===t.INT&&(we=t.RGBA32I)),O===t.RGB&&(ee===t.UNSIGNED_INT_5_9_9_9_REV&&(we=t.RGB9_E5),ee===t.UNSIGNED_INT_10F_11F_11F_REV&&(we=t.R11F_G11F_B10F)),O===t.RGBA){const re=_e?WS:or.getTransfer(le);ee===t.FLOAT&&(we=t.RGBA32F),ee===t.HALF_FLOAT&&(we=t.RGBA16F),ee===t.UNSIGNED_BYTE&&(we=re===Nr?t.SRGB8_ALPHA8:t.RGBA8),ee===t.UNSIGNED_SHORT_4_4_4_4&&(we=t.RGBA4),ee===t.UNSIGNED_SHORT_5_5_5_1&&(we=t.RGB5_A1)}return(we===t.R16F||we===t.R32F||we===t.RG16F||we===t.RG32F||we===t.RGBA16F||we===t.RGBA32F)&&e.get("EXT_color_buffer_float"),we}function T(z,O){let ee;return z?O===null||O===pm||O===hy?ee=t.DEPTH24_STENCIL8:O===wu?ee=t.DEPTH32F_STENCIL8:O===dy&&(ee=t.DEPTH24_STENCIL8,gn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):O===null||O===pm||O===hy?ee=t.DEPTH_COMPONENT24:O===wu?ee=t.DEPTH_COMPONENT32F:O===dy&&(ee=t.DEPTH_COMPONENT16),ee}function k(z,O){return y(z)===!0||z.isFramebufferTexture&&z.minFilter!==po&&z.minFilter!==el?Math.log2(Math.max(O.width,O.height))+1:z.mipmaps!==void 0&&z.mipmaps.length>0?z.mipmaps.length:z.isCompressedTexture&&Array.isArray(z.image)?O.mipmaps.length:1}function C(z){const O=z.target;O.removeEventListener("dispose",C),D(O),O.isVideoTexture&&d.delete(O)}function E(z){const O=z.target;O.removeEventListener("dispose",E),R(O)}function D(z){const O=r.get(z);if(O.__webglInit===void 0)return;const ee=z.source,le=p.get(ee);if(le){const _e=le[O.__cacheKey];_e.usedTimes--,_e.usedTimes===0&&A(z),Object.keys(le).length===0&&p.delete(ee)}r.remove(z)}function A(z){const O=r.get(z);t.deleteTexture(O.__webglTexture);const ee=z.source,le=p.get(ee);delete le[O.__cacheKey],o.memory.textures--}function R(z){const O=r.get(z);if(z.depthTexture&&(z.depthTexture.dispose(),r.remove(z.depthTexture)),z.isWebGLCubeRenderTarget)for(let le=0;le<6;le++){if(Array.isArray(O.__webglFramebuffer[le]))for(let _e=0;_e<O.__webglFramebuffer[le].length;_e++)t.deleteFramebuffer(O.__webglFramebuffer[le][_e]);else t.deleteFramebuffer(O.__webglFramebuffer[le]);O.__webglDepthbuffer&&t.deleteRenderbuffer(O.__webglDepthbuffer[le])}else{if(Array.isArray(O.__webglFramebuffer))for(let le=0;le<O.__webglFramebuffer.length;le++)t.deleteFramebuffer(O.__webglFramebuffer[le]);else t.deleteFramebuffer(O.__webglFramebuffer);if(O.__webglDepthbuffer&&t.deleteRenderbuffer(O.__webglDepthbuffer),O.__webglMultisampledFramebuffer&&t.deleteFramebuffer(O.__webglMultisampledFramebuffer),O.__webglColorRenderbuffer)for(let le=0;le<O.__webglColorRenderbuffer.length;le++)O.__webglColorRenderbuffer[le]&&t.deleteRenderbuffer(O.__webglColorRenderbuffer[le]);O.__webglDepthRenderbuffer&&t.deleteRenderbuffer(O.__webglDepthRenderbuffer)}const ee=z.textures;for(let le=0,_e=ee.length;le<_e;le++){const we=r.get(ee[le]);we.__webglTexture&&(t.deleteTexture(we.__webglTexture),o.memory.textures--),r.remove(ee[le])}r.remove(z)}let U=0;function F(){U=0}function $(){const z=U;return z>=i.maxTextures&&gn("WebGLTextures: Trying to use "+z+" texture units while this GPU supports only "+i.maxTextures),U+=1,z}function j(z){const O=[];return O.push(z.wrapS),O.push(z.wrapT),O.push(z.wrapR||0),O.push(z.magFilter),O.push(z.minFilter),O.push(z.anisotropy),O.push(z.internalFormat),O.push(z.format),O.push(z.type),O.push(z.generateMipmaps),O.push(z.premultiplyAlpha),O.push(z.flipY),O.push(z.unpackAlignment),O.push(z.colorSpace),O.join()}function H(z,O){const ee=r.get(z);if(z.isVideoTexture&&fe(z),z.isRenderTargetTexture===!1&&z.isExternalTexture!==!0&&z.version>0&&ee.__version!==z.version){const le=z.image;if(le===null)gn("WebGLRenderer: Texture marked for update but no image data found.");else if(le.complete===!1)gn("WebGLRenderer: Texture marked for update but image is incomplete");else{xe(ee,z,O);return}}else z.isExternalTexture&&(ee.__webglTexture=z.sourceTexture?z.sourceTexture:null);n.bindTexture(t.TEXTURE_2D,ee.__webglTexture,t.TEXTURE0+O)}function K(z,O){const ee=r.get(z);if(z.isRenderTargetTexture===!1&&z.version>0&&ee.__version!==z.version){xe(ee,z,O);return}else z.isExternalTexture&&(ee.__webglTexture=z.sourceTexture?z.sourceTexture:null);n.bindTexture(t.TEXTURE_2D_ARRAY,ee.__webglTexture,t.TEXTURE0+O)}function V(z,O){const ee=r.get(z);if(z.isRenderTargetTexture===!1&&z.version>0&&ee.__version!==z.version){xe(ee,z,O);return}n.bindTexture(t.TEXTURE_3D,ee.__webglTexture,t.TEXTURE0+O)}function Q(z,O){const ee=r.get(z);if(z.version>0&&ee.__version!==z.version){de(ee,z,O);return}n.bindTexture(t.TEXTURE_CUBE_MAP,ee.__webglTexture,t.TEXTURE0+O)}const Z={[R3]:t.REPEAT,[vu]:t.CLAMP_TO_EDGE,[O3]:t.MIRRORED_REPEAT},ae={[po]:t.NEAREST,[Wje]:t.NEAREST_MIPMAP_NEAREST,[Zw]:t.NEAREST_MIPMAP_LINEAR,[el]:t.LINEAR,[GA]:t.LINEAR_MIPMAP_NEAREST,[Of]:t.LINEAR_MIPMAP_LINEAR},B={[Qje]:t.NEVER,[rPe]:t.ALWAYS,[Zje]:t.LESS,[aJ]:t.LEQUAL,[Jje]:t.EQUAL,[nPe]:t.GEQUAL,[ePe]:t.GREATER,[tPe]:t.NOTEQUAL};function X(z,O){if(O.type===wu&&e.has("OES_texture_float_linear")===!1&&(O.magFilter===el||O.magFilter===GA||O.magFilter===Zw||O.magFilter===Of||O.minFilter===el||O.minFilter===GA||O.minFilter===Zw||O.minFilter===Of)&&gn("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),t.texParameteri(z,t.TEXTURE_WRAP_S,Z[O.wrapS]),t.texParameteri(z,t.TEXTURE_WRAP_T,Z[O.wrapT]),(z===t.TEXTURE_3D||z===t.TEXTURE_2D_ARRAY)&&t.texParameteri(z,t.TEXTURE_WRAP_R,Z[O.wrapR]),t.texParameteri(z,t.TEXTURE_MAG_FILTER,ae[O.magFilter]),t.texParameteri(z,t.TEXTURE_MIN_FILTER,ae[O.minFilter]),O.compareFunction&&(t.texParameteri(z,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(z,t.TEXTURE_COMPARE_FUNC,B[O.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(O.magFilter===po||O.minFilter!==Zw&&O.minFilter!==Of||O.type===wu&&e.has("OES_texture_float_linear")===!1)return;if(O.anisotropy>1||r.get(O).__currentAnisotropy){const ee=e.get("EXT_texture_filter_anisotropic");t.texParameterf(z,ee.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(O.anisotropy,i.getMaxAnisotropy())),r.get(O).__currentAnisotropy=O.anisotropy}}}function ne(z,O){let ee=!1;z.__webglInit===void 0&&(z.__webglInit=!0,O.addEventListener("dispose",C));const le=O.source;let _e=p.get(le);_e===void 0&&(_e={},p.set(le,_e));const we=j(O);if(we!==z.__cacheKey){_e[we]===void 0&&(_e[we]={texture:t.createTexture(),usedTimes:0},o.memory.textures++,ee=!0),_e[we].usedTimes++;const re=_e[z.__cacheKey];re!==void 0&&(_e[z.__cacheKey].usedTimes--,re.usedTimes===0&&A(O)),z.__cacheKey=we,z.__webglTexture=_e[we].texture}return ee}function se(z,O,ee){return Math.floor(Math.floor(z/ee)/O)}function be(z,O,ee,le){const we=z.updateRanges;if(we.length===0)n.texSubImage2D(t.TEXTURE_2D,0,0,0,O.width,O.height,ee,le,O.data);else{we.sort(($e,ye)=>$e.start-ye.start);let re=0;for(let $e=1;$e<we.length;$e++){const ye=we[re],je=we[$e],Be=ye.start+ye.count,Se=se(je.start,O.width,4),Xe=se(ye.start,O.width,4);je.start<=Be+1&&Se===Xe&&se(je.start+je.count-1,O.width,4)===Se?ye.count=Math.max(ye.count,je.start+je.count-ye.start):(++re,we[re]=je)}we.length=re+1;const Fe=t.getParameter(t.UNPACK_ROW_LENGTH),He=t.getParameter(t.UNPACK_SKIP_PIXELS),Ve=t.getParameter(t.UNPACK_SKIP_ROWS);t.pixelStorei(t.UNPACK_ROW_LENGTH,O.width);for(let $e=0,ye=we.length;$e<ye;$e++){const je=we[$e],Be=Math.floor(je.start/4),Se=Math.ceil(je.count/4),Xe=Be%O.width,Me=Math.floor(Be/O.width),tt=Se,ke=1;t.pixelStorei(t.UNPACK_SKIP_PIXELS,Xe),t.pixelStorei(t.UNPACK_SKIP_ROWS,Me),n.texSubImage2D(t.TEXTURE_2D,0,Xe,Me,tt,ke,ee,le,O.data)}z.clearUpdateRanges(),t.pixelStorei(t.UNPACK_ROW_LENGTH,Fe),t.pixelStorei(t.UNPACK_SKIP_PIXELS,He),t.pixelStorei(t.UNPACK_SKIP_ROWS,Ve)}}function xe(z,O,ee){let le=t.TEXTURE_2D;(O.isDataArrayTexture||O.isCompressedArrayTexture)&&(le=t.TEXTURE_2D_ARRAY),O.isData3DTexture&&(le=t.TEXTURE_3D);const _e=ne(z,O),we=O.source;n.bindTexture(le,z.__webglTexture,t.TEXTURE0+ee);const re=r.get(we);if(we.version!==re.__version||_e===!0){n.activeTexture(t.TEXTURE0+ee);const Fe=or.getPrimaries(or.workingColorSpace),He=O.colorSpace===Kd?null:or.getPrimaries(O.colorSpace),Ve=O.colorSpace===Kd||Fe===He?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,O.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,O.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,O.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ve);let $e=b(O.image,!1,i.maxTextureSize);$e=me(O,$e);const ye=a.convert(O.format,O.colorSpace),je=a.convert(O.type);let Be=N(O.internalFormat,ye,je,O.colorSpace,O.isVideoTexture);X(le,O);let Se;const Xe=O.mipmaps,Me=O.isVideoTexture!==!0,tt=re.__version===void 0||_e===!0,ke=we.dataReady,We=k(O,$e);if(O.isDepthTexture)Be=T(O.format===my,O.type),tt&&(Me?n.texStorage2D(t.TEXTURE_2D,1,Be,$e.width,$e.height):n.texImage2D(t.TEXTURE_2D,0,Be,$e.width,$e.height,0,ye,je,null));else if(O.isDataTexture)if(Xe.length>0){Me&&tt&&n.texStorage2D(t.TEXTURE_2D,We,Be,Xe[0].width,Xe[0].height);for(let ze=0,W=Xe.length;ze<W;ze++)Se=Xe[ze],Me?ke&&n.texSubImage2D(t.TEXTURE_2D,ze,0,0,Se.width,Se.height,ye,je,Se.data):n.texImage2D(t.TEXTURE_2D,ze,Be,Se.width,Se.height,0,ye,je,Se.data);O.generateMipmaps=!1}else Me?(tt&&n.texStorage2D(t.TEXTURE_2D,We,Be,$e.width,$e.height),ke&&be(O,$e,ye,je)):n.texImage2D(t.TEXTURE_2D,0,Be,$e.width,$e.height,0,ye,je,$e.data);else if(O.isCompressedTexture)if(O.isCompressedArrayTexture){Me&&tt&&n.texStorage3D(t.TEXTURE_2D_ARRAY,We,Be,Xe[0].width,Xe[0].height,$e.depth);for(let ze=0,W=Xe.length;ze<W;ze++)if(Se=Xe[ze],O.format!==Pl)if(ye!==null)if(Me){if(ke)if(O.layerUpdates.size>0){const De=aV(Se.width,Se.height,O.format,O.type);for(const Ye of O.layerUpdates){const xt=Se.data.subarray(Ye*De/Se.data.BYTES_PER_ELEMENT,(Ye+1)*De/Se.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,ze,0,0,Ye,Se.width,Se.height,1,ye,xt)}O.clearLayerUpdates()}else n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,ze,0,0,0,Se.width,Se.height,$e.depth,ye,Se.data)}else n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,ze,Be,Se.width,Se.height,$e.depth,0,Se.data,0,0);else gn("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Me?ke&&n.texSubImage3D(t.TEXTURE_2D_ARRAY,ze,0,0,0,Se.width,Se.height,$e.depth,ye,je,Se.data):n.texImage3D(t.TEXTURE_2D_ARRAY,ze,Be,Se.width,Se.height,$e.depth,0,ye,je,Se.data)}else{Me&&tt&&n.texStorage2D(t.TEXTURE_2D,We,Be,Xe[0].width,Xe[0].height);for(let ze=0,W=Xe.length;ze<W;ze++)Se=Xe[ze],O.format!==Pl?ye!==null?Me?ke&&n.compressedTexSubImage2D(t.TEXTURE_2D,ze,0,0,Se.width,Se.height,ye,Se.data):n.compressedTexImage2D(t.TEXTURE_2D,ze,Be,Se.width,Se.height,0,Se.data):gn("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Me?ke&&n.texSubImage2D(t.TEXTURE_2D,ze,0,0,Se.width,Se.height,ye,je,Se.data):n.texImage2D(t.TEXTURE_2D,ze,Be,Se.width,Se.height,0,ye,je,Se.data)}else if(O.isDataArrayTexture)if(Me){if(tt&&n.texStorage3D(t.TEXTURE_2D_ARRAY,We,Be,$e.width,$e.height,$e.depth),ke)if(O.layerUpdates.size>0){const ze=aV($e.width,$e.height,O.format,O.type);for(const W of O.layerUpdates){const De=$e.data.subarray(W*ze/$e.data.BYTES_PER_ELEMENT,(W+1)*ze/$e.data.BYTES_PER_ELEMENT);n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,W,$e.width,$e.height,1,ye,je,De)}O.clearLayerUpdates()}else n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,$e.width,$e.height,$e.depth,ye,je,$e.data)}else n.texImage3D(t.TEXTURE_2D_ARRAY,0,Be,$e.width,$e.height,$e.depth,0,ye,je,$e.data);else if(O.isData3DTexture)Me?(tt&&n.texStorage3D(t.TEXTURE_3D,We,Be,$e.width,$e.height,$e.depth),ke&&n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,$e.width,$e.height,$e.depth,ye,je,$e.data)):n.texImage3D(t.TEXTURE_3D,0,Be,$e.width,$e.height,$e.depth,0,ye,je,$e.data);else if(O.isFramebufferTexture){if(tt)if(Me)n.texStorage2D(t.TEXTURE_2D,We,Be,$e.width,$e.height);else{let ze=$e.width,W=$e.height;for(let De=0;De<We;De++)n.texImage2D(t.TEXTURE_2D,De,Be,ze,W,0,ye,je,null),ze>>=1,W>>=1}}else if(Xe.length>0){if(Me&&tt){const ze=Ee(Xe[0]);n.texStorage2D(t.TEXTURE_2D,We,Be,ze.width,ze.height)}for(let ze=0,W=Xe.length;ze<W;ze++)Se=Xe[ze],Me?ke&&n.texSubImage2D(t.TEXTURE_2D,ze,0,0,ye,je,Se):n.texImage2D(t.TEXTURE_2D,ze,Be,ye,je,Se);O.generateMipmaps=!1}else if(Me){if(tt){const ze=Ee($e);n.texStorage2D(t.TEXTURE_2D,We,Be,ze.width,ze.height)}ke&&n.texSubImage2D(t.TEXTURE_2D,0,0,0,ye,je,$e)}else n.texImage2D(t.TEXTURE_2D,0,Be,ye,je,$e);y(O)&&v(le),re.__version=we.version,O.onUpdate&&O.onUpdate(O)}z.__version=O.version}function de(z,O,ee){if(O.image.length!==6)return;const le=ne(z,O),_e=O.source;n.bindTexture(t.TEXTURE_CUBE_MAP,z.__webglTexture,t.TEXTURE0+ee);const we=r.get(_e);if(_e.version!==we.__version||le===!0){n.activeTexture(t.TEXTURE0+ee);const re=or.getPrimaries(or.workingColorSpace),Fe=O.colorSpace===Kd?null:or.getPrimaries(O.colorSpace),He=O.colorSpace===Kd||re===Fe?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,O.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,O.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,O.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,He);const Ve=O.isCompressedTexture||O.image[0].isCompressedTexture,$e=O.image[0]&&O.image[0].isDataTexture,ye=[];for(let W=0;W<6;W++)!Ve&&!$e?ye[W]=b(O.image[W],!0,i.maxCubemapSize):ye[W]=$e?O.image[W].image:O.image[W],ye[W]=me(O,ye[W]);const je=ye[0],Be=a.convert(O.format,O.colorSpace),Se=a.convert(O.type),Xe=N(O.internalFormat,Be,Se,O.colorSpace),Me=O.isVideoTexture!==!0,tt=we.__version===void 0||le===!0,ke=_e.dataReady;let We=k(O,je);X(t.TEXTURE_CUBE_MAP,O);let ze;if(Ve){Me&&tt&&n.texStorage2D(t.TEXTURE_CUBE_MAP,We,Xe,je.width,je.height);for(let W=0;W<6;W++){ze=ye[W].mipmaps;for(let De=0;De<ze.length;De++){const Ye=ze[De];O.format!==Pl?Be!==null?Me?ke&&n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+W,De,0,0,Ye.width,Ye.height,Be,Ye.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+W,De,Xe,Ye.width,Ye.height,0,Ye.data):gn("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):Me?ke&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+W,De,0,0,Ye.width,Ye.height,Be,Se,Ye.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+W,De,Xe,Ye.width,Ye.height,0,Be,Se,Ye.data)}}}else{if(ze=O.mipmaps,Me&&tt){ze.length>0&&We++;const W=Ee(ye[0]);n.texStorage2D(t.TEXTURE_CUBE_MAP,We,Xe,W.width,W.height)}for(let W=0;W<6;W++)if($e){Me?ke&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+W,0,0,0,ye[W].width,ye[W].height,Be,Se,ye[W].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+W,0,Xe,ye[W].width,ye[W].height,0,Be,Se,ye[W].data);for(let De=0;De<ze.length;De++){const xt=ze[De].image[W].image;Me?ke&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+W,De+1,0,0,xt.width,xt.height,Be,Se,xt.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+W,De+1,Xe,xt.width,xt.height,0,Be,Se,xt.data)}}else{Me?ke&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+W,0,0,0,Be,Se,ye[W]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+W,0,Xe,Be,Se,ye[W]);for(let De=0;De<ze.length;De++){const Ye=ze[De];Me?ke&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+W,De+1,0,0,Be,Se,Ye.image[W]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+W,De+1,Xe,Be,Se,Ye.image[W])}}}y(O)&&v(t.TEXTURE_CUBE_MAP),we.__version=_e.version,O.onUpdate&&O.onUpdate(O)}z.__version=O.version}function Pe(z,O,ee,le,_e,we){const re=a.convert(ee.format,ee.colorSpace),Fe=a.convert(ee.type),He=N(ee.internalFormat,re,Fe,ee.colorSpace),Ve=r.get(O),$e=r.get(ee);if($e.__renderTarget=O,!Ve.__hasExternalTextures){const ye=Math.max(1,O.width>>we),je=Math.max(1,O.height>>we);_e===t.TEXTURE_3D||_e===t.TEXTURE_2D_ARRAY?n.texImage3D(_e,we,He,ye,je,O.depth,0,re,Fe,null):n.texImage2D(_e,we,He,ye,je,0,re,Fe,null)}n.bindFramebuffer(t.FRAMEBUFFER,z),I(O)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,le,_e,$e.__webglTexture,0,te(O)):(_e===t.TEXTURE_2D||_e>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&_e<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,le,_e,$e.__webglTexture,we),n.bindFramebuffer(t.FRAMEBUFFER,null)}function ie(z,O,ee){if(t.bindRenderbuffer(t.RENDERBUFFER,z),O.depthBuffer){const le=O.depthTexture,_e=le&&le.isDepthTexture?le.type:null,we=T(O.stencilBuffer,_e),re=O.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,Fe=te(O);I(O)?l.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,Fe,we,O.width,O.height):ee?t.renderbufferStorageMultisample(t.RENDERBUFFER,Fe,we,O.width,O.height):t.renderbufferStorage(t.RENDERBUFFER,we,O.width,O.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,re,t.RENDERBUFFER,z)}else{const le=O.textures;for(let _e=0;_e<le.length;_e++){const we=le[_e],re=a.convert(we.format,we.colorSpace),Fe=a.convert(we.type),He=N(we.internalFormat,re,Fe,we.colorSpace),Ve=te(O);ee&&I(O)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,Ve,He,O.width,O.height):I(O)?l.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,Ve,He,O.width,O.height):t.renderbufferStorage(t.RENDERBUFFER,He,O.width,O.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function Ne(z,O){if(O&&O.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(t.FRAMEBUFFER,z),!(O.depthTexture&&O.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const le=r.get(O.depthTexture);le.__renderTarget=O,(!le.__webglTexture||O.depthTexture.image.width!==O.width||O.depthTexture.image.height!==O.height)&&(O.depthTexture.image.width=O.width,O.depthTexture.image.height=O.height,O.depthTexture.needsUpdate=!0),H(O.depthTexture,0);const _e=le.__webglTexture,we=te(O);if(O.depthTexture.format===fy)I(O)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,_e,0,we):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,_e,0);else if(O.depthTexture.format===my)I(O)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,_e,0,we):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,_e,0);else throw new Error("Unknown depthTexture format")}function Oe(z){const O=r.get(z),ee=z.isWebGLCubeRenderTarget===!0;if(O.__boundDepthTexture!==z.depthTexture){const le=z.depthTexture;if(O.__depthDisposeCallback&&O.__depthDisposeCallback(),le){const _e=()=>{delete O.__boundDepthTexture,delete O.__depthDisposeCallback,le.removeEventListener("dispose",_e)};le.addEventListener("dispose",_e),O.__depthDisposeCallback=_e}O.__boundDepthTexture=le}if(z.depthTexture&&!O.__autoAllocateDepthBuffer){if(ee)throw new Error("target.depthTexture not supported in Cube render targets");const le=z.texture.mipmaps;le&&le.length>0?Ne(O.__webglFramebuffer[0],z):Ne(O.__webglFramebuffer,z)}else if(ee){O.__webglDepthbuffer=[];for(let le=0;le<6;le++)if(n.bindFramebuffer(t.FRAMEBUFFER,O.__webglFramebuffer[le]),O.__webglDepthbuffer[le]===void 0)O.__webglDepthbuffer[le]=t.createRenderbuffer(),ie(O.__webglDepthbuffer[le],z,!1);else{const _e=z.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,we=O.__webglDepthbuffer[le];t.bindRenderbuffer(t.RENDERBUFFER,we),t.framebufferRenderbuffer(t.FRAMEBUFFER,_e,t.RENDERBUFFER,we)}}else{const le=z.texture.mipmaps;if(le&&le.length>0?n.bindFramebuffer(t.FRAMEBUFFER,O.__webglFramebuffer[0]):n.bindFramebuffer(t.FRAMEBUFFER,O.__webglFramebuffer),O.__webglDepthbuffer===void 0)O.__webglDepthbuffer=t.createRenderbuffer(),ie(O.__webglDepthbuffer,z,!1);else{const _e=z.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,we=O.__webglDepthbuffer;t.bindRenderbuffer(t.RENDERBUFFER,we),t.framebufferRenderbuffer(t.FRAMEBUFFER,_e,t.RENDERBUFFER,we)}}n.bindFramebuffer(t.FRAMEBUFFER,null)}function ge(z,O,ee){const le=r.get(z);O!==void 0&&Pe(le.__webglFramebuffer,z,z.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),ee!==void 0&&Oe(z)}function Ke(z){const O=z.texture,ee=r.get(z),le=r.get(O);z.addEventListener("dispose",E);const _e=z.textures,we=z.isWebGLCubeRenderTarget===!0,re=_e.length>1;if(re||(le.__webglTexture===void 0&&(le.__webglTexture=t.createTexture()),le.__version=O.version,o.memory.textures++),we){ee.__webglFramebuffer=[];for(let Fe=0;Fe<6;Fe++)if(O.mipmaps&&O.mipmaps.length>0){ee.__webglFramebuffer[Fe]=[];for(let He=0;He<O.mipmaps.length;He++)ee.__webglFramebuffer[Fe][He]=t.createFramebuffer()}else ee.__webglFramebuffer[Fe]=t.createFramebuffer()}else{if(O.mipmaps&&O.mipmaps.length>0){ee.__webglFramebuffer=[];for(let Fe=0;Fe<O.mipmaps.length;Fe++)ee.__webglFramebuffer[Fe]=t.createFramebuffer()}else ee.__webglFramebuffer=t.createFramebuffer();if(re)for(let Fe=0,He=_e.length;Fe<He;Fe++){const Ve=r.get(_e[Fe]);Ve.__webglTexture===void 0&&(Ve.__webglTexture=t.createTexture(),o.memory.textures++)}if(z.samples>0&&I(z)===!1){ee.__webglMultisampledFramebuffer=t.createFramebuffer(),ee.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,ee.__webglMultisampledFramebuffer);for(let Fe=0;Fe<_e.length;Fe++){const He=_e[Fe];ee.__webglColorRenderbuffer[Fe]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,ee.__webglColorRenderbuffer[Fe]);const Ve=a.convert(He.format,He.colorSpace),$e=a.convert(He.type),ye=N(He.internalFormat,Ve,$e,He.colorSpace,z.isXRRenderTarget===!0),je=te(z);t.renderbufferStorageMultisample(t.RENDERBUFFER,je,ye,z.width,z.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Fe,t.RENDERBUFFER,ee.__webglColorRenderbuffer[Fe])}t.bindRenderbuffer(t.RENDERBUFFER,null),z.depthBuffer&&(ee.__webglDepthRenderbuffer=t.createRenderbuffer(),ie(ee.__webglDepthRenderbuffer,z,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(we){n.bindTexture(t.TEXTURE_CUBE_MAP,le.__webglTexture),X(t.TEXTURE_CUBE_MAP,O);for(let Fe=0;Fe<6;Fe++)if(O.mipmaps&&O.mipmaps.length>0)for(let He=0;He<O.mipmaps.length;He++)Pe(ee.__webglFramebuffer[Fe][He],z,O,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Fe,He);else Pe(ee.__webglFramebuffer[Fe],z,O,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Fe,0);y(O)&&v(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(re){for(let Fe=0,He=_e.length;Fe<He;Fe++){const Ve=_e[Fe],$e=r.get(Ve);let ye=t.TEXTURE_2D;(z.isWebGL3DRenderTarget||z.isWebGLArrayRenderTarget)&&(ye=z.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(ye,$e.__webglTexture),X(ye,Ve),Pe(ee.__webglFramebuffer,z,Ve,t.COLOR_ATTACHMENT0+Fe,ye,0),y(Ve)&&v(ye)}n.unbindTexture()}else{let Fe=t.TEXTURE_2D;if((z.isWebGL3DRenderTarget||z.isWebGLArrayRenderTarget)&&(Fe=z.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(Fe,le.__webglTexture),X(Fe,O),O.mipmaps&&O.mipmaps.length>0)for(let He=0;He<O.mipmaps.length;He++)Pe(ee.__webglFramebuffer[He],z,O,t.COLOR_ATTACHMENT0,Fe,He);else Pe(ee.__webglFramebuffer,z,O,t.COLOR_ATTACHMENT0,Fe,0);y(O)&&v(Fe),n.unbindTexture()}z.depthBuffer&&Oe(z)}function G(z){const O=z.textures;for(let ee=0,le=O.length;ee<le;ee++){const _e=O[ee];if(y(_e)){const we=S(z),re=r.get(_e).__webglTexture;n.bindTexture(we,re),v(we),n.unbindTexture()}}}const Y=[],ce=[];function q(z){if(z.samples>0){if(I(z)===!1){const O=z.textures,ee=z.width,le=z.height;let _e=t.COLOR_BUFFER_BIT;const we=z.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,re=r.get(z),Fe=O.length>1;if(Fe)for(let Ve=0;Ve<O.length;Ve++)n.bindFramebuffer(t.FRAMEBUFFER,re.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ve,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,re.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ve,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,re.__webglMultisampledFramebuffer);const He=z.texture.mipmaps;He&&He.length>0?n.bindFramebuffer(t.DRAW_FRAMEBUFFER,re.__webglFramebuffer[0]):n.bindFramebuffer(t.DRAW_FRAMEBUFFER,re.__webglFramebuffer);for(let Ve=0;Ve<O.length;Ve++){if(z.resolveDepthBuffer&&(z.depthBuffer&&(_e|=t.DEPTH_BUFFER_BIT),z.stencilBuffer&&z.resolveStencilBuffer&&(_e|=t.STENCIL_BUFFER_BIT)),Fe){t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,re.__webglColorRenderbuffer[Ve]);const $e=r.get(O[Ve]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,$e,0)}t.blitFramebuffer(0,0,ee,le,0,0,ee,le,_e,t.NEAREST),c===!0&&(Y.length=0,ce.length=0,Y.push(t.COLOR_ATTACHMENT0+Ve),z.depthBuffer&&z.resolveDepthBuffer===!1&&(Y.push(we),ce.push(we),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,ce)),t.invalidateFramebuffer(t.READ_FRAMEBUFFER,Y))}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),Fe)for(let Ve=0;Ve<O.length;Ve++){n.bindFramebuffer(t.FRAMEBUFFER,re.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ve,t.RENDERBUFFER,re.__webglColorRenderbuffer[Ve]);const $e=r.get(O[Ve]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,re.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ve,t.TEXTURE_2D,$e,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,re.__webglMultisampledFramebuffer)}else if(z.depthBuffer&&z.resolveDepthBuffer===!1&&c){const O=z.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[O])}}}function te(z){return Math.min(i.maxSamples,z.samples)}function I(z){const O=r.get(z);return z.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&O.__useRenderToTexture!==!1}function fe(z){const O=o.render.frame;d.get(z)!==O&&(d.set(z,O),z.update())}function me(z,O){const ee=z.colorSpace,le=z.format,_e=z.type;return z.isCompressedTexture===!0||z.isVideoTexture===!0||ee!==ex&&ee!==Kd&&(or.getTransfer(ee)===Nr?(le!==Pl||_e!==yc)&&gn("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Ei("WebGLTextures: Unsupported texture color space:",ee)),O}function Ee(z){return typeof HTMLImageElement<"u"&&z instanceof HTMLImageElement?(u.width=z.naturalWidth||z.width,u.height=z.naturalHeight||z.height):typeof VideoFrame<"u"&&z instanceof VideoFrame?(u.width=z.displayWidth,u.height=z.displayHeight):(u.width=z.width,u.height=z.height),u}this.allocateTextureUnit=$,this.resetTextureUnits=F,this.setTexture2D=H,this.setTexture2DArray=K,this.setTexture3D=V,this.setTextureCube=Q,this.rebindTextures=ge,this.setupRenderTarget=Ke,this.updateRenderTargetMipmap=G,this.updateMultisampleRenderTarget=q,this.setupDepthRenderbuffer=Oe,this.setupFrameBufferTexture=Pe,this.useMultisampledRTT=I}function M4e(t,e){function n(r,i=Kd){let a;const o=or.getTransfer(i);if(r===yc)return t.UNSIGNED_BYTE;if(r===V4)return t.UNSIGNED_SHORT_4_4_4_4;if(r===G4)return t.UNSIGNED_SHORT_5_5_5_1;if(r===JZ)return t.UNSIGNED_INT_5_9_9_9_REV;if(r===eJ)return t.UNSIGNED_INT_10F_11F_11F_REV;if(r===QZ)return t.BYTE;if(r===ZZ)return t.SHORT;if(r===dy)return t.UNSIGNED_SHORT;if(r===$4)return t.INT;if(r===pm)return t.UNSIGNED_INT;if(r===wu)return t.FLOAT;if(r===Cx)return t.HALF_FLOAT;if(r===tJ)return t.ALPHA;if(r===nJ)return t.RGB;if(r===Pl)return t.RGBA;if(r===fy)return t.DEPTH_COMPONENT;if(r===my)return t.DEPTH_STENCIL;if(r===rJ)return t.RED;if(r===q4)return t.RED_INTEGER;if(r===W4)return t.RG;if(r===K4)return t.RG_INTEGER;if(r===X4)return t.RGBA_INTEGER;if(r===M1||r===N1||r===k1||r===E1)if(o===Nr)if(a=e.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(r===M1)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(r===N1)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(r===k1)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(r===E1)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=e.get("WEBGL_compressed_texture_s3tc"),a!==null){if(r===M1)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(r===N1)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(r===k1)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(r===E1)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(r===L3||r===F3||r===I3||r===U3)if(a=e.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(r===L3)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(r===F3)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(r===I3)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(r===U3)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(r===z3||r===B3||r===H3)if(a=e.get("WEBGL_compressed_texture_etc"),a!==null){if(r===z3||r===B3)return o===Nr?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(r===H3)return o===Nr?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(r===$3||r===V3||r===G3||r===q3||r===W3||r===K3||r===X3||r===Y3||r===Q3||r===Z3||r===J3||r===eD||r===tD||r===nD)if(a=e.get("WEBGL_compressed_texture_astc"),a!==null){if(r===$3)return o===Nr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(r===V3)return o===Nr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(r===G3)return o===Nr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(r===q3)return o===Nr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(r===W3)return o===Nr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(r===K3)return o===Nr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(r===X3)return o===Nr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(r===Y3)return o===Nr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(r===Q3)return o===Nr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(r===Z3)return o===Nr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(r===J3)return o===Nr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(r===eD)return o===Nr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(r===tD)return o===Nr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(r===nD)return o===Nr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(r===rD||r===iD||r===aD)if(a=e.get("EXT_texture_compression_bptc"),a!==null){if(r===rD)return o===Nr?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(r===iD)return a.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(r===aD)return a.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(r===sD||r===oD||r===lD||r===cD)if(a=e.get("EXT_texture_compression_rgtc"),a!==null){if(r===sD)return a.COMPRESSED_RED_RGTC1_EXT;if(r===oD)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(r===lD)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(r===cD)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return r===hy?t.UNSIGNED_INT_24_8:t[r]!==void 0?t[r]:null}return{convert:n}}const N4e=`
- void main() {
- gl_Position = vec4( position, 1.0 );
- }`,k4e=`
- 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 E4e{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,n){if(this.texture===null){const r=new MJ(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 $u({vertexShader:N4e,fragmentShader:k4e,uniforms:{depthColor:{value:this.texture},depthWidth:{value:n.z},depthHeight:{value:n.w}}});this.mesh=new vc(new tL(20,20),r)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}let T4e=class extends Cm{constructor(e,n){super();const r=this;let i=null,a=1,o=null,l="local-floor",c=1,u=null,d=null,f=null,p=null,m=null,x=null;const b=typeof XRWebGLBinding<"u",y=new E4e,v={},S=n.getContextAttributes();let N=null,T=null;const k=[],C=[],E=new Tn;let D=null;const A=new Wo;A.viewport=new Ui;const R=new Wo;R.viewport=new Ui;const U=[A,R],F=new GPe;let $=null,j=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(xe){let de=k[xe];return de===void 0&&(de=new fC,k[xe]=de),de.getTargetRaySpace()},this.getControllerGrip=function(xe){let de=k[xe];return de===void 0&&(de=new fC,k[xe]=de),de.getGripSpace()},this.getHand=function(xe){let de=k[xe];return de===void 0&&(de=new fC,k[xe]=de),de.getHandSpace()};function H(xe){const de=C.indexOf(xe.inputSource);if(de===-1)return;const Pe=k[de];Pe!==void 0&&(Pe.update(xe.inputSource,xe.frame,u||o),Pe.dispatchEvent({type:xe.type,data:xe.inputSource}))}function K(){i.removeEventListener("select",H),i.removeEventListener("selectstart",H),i.removeEventListener("selectend",H),i.removeEventListener("squeeze",H),i.removeEventListener("squeezestart",H),i.removeEventListener("squeezeend",H),i.removeEventListener("end",K),i.removeEventListener("inputsourceschange",V);for(let xe=0;xe<k.length;xe++){const de=C[xe];de!==null&&(C[xe]=null,k[xe].disconnect(de))}$=null,j=null,y.reset();for(const xe in v)delete v[xe];e.setRenderTarget(N),m=null,p=null,f=null,i=null,T=null,be.stop(),r.isPresenting=!1,e.setPixelRatio(D),e.setSize(E.width,E.height,!1),r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(xe){a=xe,r.isPresenting===!0&&gn("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(xe){l=xe,r.isPresenting===!0&&gn("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return u||o},this.setReferenceSpace=function(xe){u=xe},this.getBaseLayer=function(){return p!==null?p:m},this.getBinding=function(){return f===null&&b&&(f=new XRWebGLBinding(i,n)),f},this.getFrame=function(){return x},this.getSession=function(){return i},this.setSession=async function(xe){if(i=xe,i!==null){if(N=e.getRenderTarget(),i.addEventListener("select",H),i.addEventListener("selectstart",H),i.addEventListener("selectend",H),i.addEventListener("squeeze",H),i.addEventListener("squeezestart",H),i.addEventListener("squeezeend",H),i.addEventListener("end",K),i.addEventListener("inputsourceschange",V),S.xrCompatible!==!0&&await n.makeXRCompatible(),D=e.getPixelRatio(),e.getSize(E),b&&"createProjectionLayer"in XRWebGLBinding.prototype){let Pe=null,ie=null,Ne=null;S.depth&&(Ne=S.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,Pe=S.stencil?my:fy,ie=S.stencil?hy:pm);const Oe={colorFormat:n.RGBA8,depthFormat:Ne,scaleFactor:a};f=this.getBinding(),p=f.createProjectionLayer(Oe),i.updateRenderState({layers:[p]}),e.setPixelRatio(1),e.setSize(p.textureWidth,p.textureHeight,!1),T=new xm(p.textureWidth,p.textureHeight,{format:Pl,type:yc,depthTexture:new SJ(p.textureWidth,p.textureHeight,ie,void 0,void 0,void 0,void 0,void 0,void 0,Pe),stencilBuffer:S.stencil,colorSpace:e.outputColorSpace,samples:S.antialias?4:0,resolveDepthBuffer:p.ignoreDepthValues===!1,resolveStencilBuffer:p.ignoreDepthValues===!1})}else{const Pe={antialias:S.antialias,alpha:!0,depth:S.depth,stencil:S.stencil,framebufferScaleFactor:a};m=new XRWebGLLayer(i,n,Pe),i.updateRenderState({baseLayer:m}),e.setPixelRatio(1),e.setSize(m.framebufferWidth,m.framebufferHeight,!1),T=new xm(m.framebufferWidth,m.framebufferHeight,{format:Pl,type:yc,colorSpace:e.outputColorSpace,stencilBuffer:S.stencil,resolveDepthBuffer:m.ignoreDepthValues===!1,resolveStencilBuffer:m.ignoreDepthValues===!1})}T.isXRRenderTarget=!0,this.setFoveation(c),u=null,o=await i.requestReferenceSpace(l),be.setContext(i),be.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return y.getDepthTexture()};function V(xe){for(let de=0;de<xe.removed.length;de++){const Pe=xe.removed[de],ie=C.indexOf(Pe);ie>=0&&(C[ie]=null,k[ie].disconnect(Pe))}for(let de=0;de<xe.added.length;de++){const Pe=xe.added[de];let ie=C.indexOf(Pe);if(ie===-1){for(let Oe=0;Oe<k.length;Oe++)if(Oe>=C.length){C.push(Pe),ie=Oe;break}else if(C[Oe]===null){C[Oe]=Pe,ie=Oe;break}if(ie===-1)break}const Ne=k[ie];Ne&&Ne.connect(Pe)}}const Q=new dt,Z=new dt;function ae(xe,de,Pe){Q.setFromMatrixPosition(de.matrixWorld),Z.setFromMatrixPosition(Pe.matrixWorld);const ie=Q.distanceTo(Z),Ne=de.projectionMatrix.elements,Oe=Pe.projectionMatrix.elements,ge=Ne[14]/(Ne[10]-1),Ke=Ne[14]/(Ne[10]+1),G=(Ne[9]+1)/Ne[5],Y=(Ne[9]-1)/Ne[5],ce=(Ne[8]-1)/Ne[0],q=(Oe[8]+1)/Oe[0],te=ge*ce,I=ge*q,fe=ie/(-ce+q),me=fe*-ce;if(de.matrixWorld.decompose(xe.position,xe.quaternion,xe.scale),xe.translateX(me),xe.translateZ(fe),xe.matrixWorld.compose(xe.position,xe.quaternion,xe.scale),xe.matrixWorldInverse.copy(xe.matrixWorld).invert(),Ne[10]===-1)xe.projectionMatrix.copy(de.projectionMatrix),xe.projectionMatrixInverse.copy(de.projectionMatrixInverse);else{const Ee=ge+fe,z=Ke+fe,O=te-me,ee=I+(ie-me),le=G*Ke/z*Ee,_e=Y*Ke/z*Ee;xe.projectionMatrix.makePerspective(O,ee,le,_e,Ee,z),xe.projectionMatrixInverse.copy(xe.projectionMatrix).invert()}}function B(xe,de){de===null?xe.matrixWorld.copy(xe.matrix):xe.matrixWorld.multiplyMatrices(de.matrixWorld,xe.matrix),xe.matrixWorldInverse.copy(xe.matrixWorld).invert()}this.updateCamera=function(xe){if(i===null)return;let de=xe.near,Pe=xe.far;y.texture!==null&&(y.depthNear>0&&(de=y.depthNear),y.depthFar>0&&(Pe=y.depthFar)),F.near=R.near=A.near=de,F.far=R.far=A.far=Pe,($!==F.near||j!==F.far)&&(i.updateRenderState({depthNear:F.near,depthFar:F.far}),$=F.near,j=F.far),F.layers.mask=xe.layers.mask|6,A.layers.mask=F.layers.mask&3,R.layers.mask=F.layers.mask&5;const ie=xe.parent,Ne=F.cameras;B(F,ie);for(let Oe=0;Oe<Ne.length;Oe++)B(Ne[Oe],ie);Ne.length===2?ae(F,A,R):F.projectionMatrix.copy(A.projectionMatrix),X(xe,F,ie)};function X(xe,de,Pe){Pe===null?xe.matrix.copy(de.matrixWorld):(xe.matrix.copy(Pe.matrixWorld),xe.matrix.invert(),xe.matrix.multiply(de.matrixWorld)),xe.matrix.decompose(xe.position,xe.quaternion,xe.scale),xe.updateMatrixWorld(!0),xe.projectionMatrix.copy(de.projectionMatrix),xe.projectionMatrixInverse.copy(de.projectionMatrixInverse),xe.isPerspectiveCamera&&(xe.fov=uD*2*Math.atan(1/xe.projectionMatrix.elements[5]),xe.zoom=1)}this.getCamera=function(){return F},this.getFoveation=function(){if(!(p===null&&m===null))return c},this.setFoveation=function(xe){c=xe,p!==null&&(p.fixedFoveation=xe),m!==null&&m.fixedFoveation!==void 0&&(m.fixedFoveation=xe)},this.hasDepthSensing=function(){return y.texture!==null},this.getDepthSensingMesh=function(){return y.getMesh(F)},this.getCameraTexture=function(xe){return v[xe]};let ne=null;function se(xe,de){if(d=de.getViewerPose(u||o),x=de,d!==null){const Pe=d.views;m!==null&&(e.setRenderTargetFramebuffer(T,m.framebuffer),e.setRenderTarget(T));let ie=!1;Pe.length!==F.cameras.length&&(F.cameras.length=0,ie=!0);for(let Ke=0;Ke<Pe.length;Ke++){const G=Pe[Ke];let Y=null;if(m!==null)Y=m.getViewport(G);else{const q=f.getViewSubImage(p,G);Y=q.viewport,Ke===0&&(e.setRenderTargetTextures(T,q.colorTexture,q.depthStencilTexture),e.setRenderTarget(T))}let ce=U[Ke];ce===void 0&&(ce=new Wo,ce.layers.enable(Ke),ce.viewport=new Ui,U[Ke]=ce),ce.matrix.fromArray(G.transform.matrix),ce.matrix.decompose(ce.position,ce.quaternion,ce.scale),ce.projectionMatrix.fromArray(G.projectionMatrix),ce.projectionMatrixInverse.copy(ce.projectionMatrix).invert(),ce.viewport.set(Y.x,Y.y,Y.width,Y.height),Ke===0&&(F.matrix.copy(ce.matrix),F.matrix.decompose(F.position,F.quaternion,F.scale)),ie===!0&&F.cameras.push(ce)}const Ne=i.enabledFeatures;if(Ne&&Ne.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&b){f=r.getBinding();const Ke=f.getDepthInformation(Pe[0]);Ke&&Ke.isValid&&Ke.texture&&y.init(Ke,i.renderState)}if(Ne&&Ne.includes("camera-access")&&b){e.state.unbindTexture(),f=r.getBinding();for(let Ke=0;Ke<Pe.length;Ke++){const G=Pe[Ke].camera;if(G){let Y=v[G];Y||(Y=new MJ,v[G]=Y);const ce=f.getCameraImage(G);Y.sourceTexture=ce}}}}for(let Pe=0;Pe<k.length;Pe++){const ie=C[Pe],Ne=k[Pe];ie!==null&&Ne!==void 0&&Ne.update(ie,de,u||o)}ne&&ne(xe,de),de.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:de}),x=null}const be=new TJ;be.setAnimationLoop(se),this.setAnimationLoop=function(xe){ne=xe},this.dispose=function(){}}};const hf=new Eh,A4e=new Vi;function C4e(t,e){function n(y,v){y.matrixAutoUpdate===!0&&y.updateMatrix(),v.value.copy(y.matrix)}function r(y,v){v.color.getRGB(y.fogColor.value,yJ(t)),v.isFog?(y.fogNear.value=v.near,y.fogFar.value=v.far):v.isFogExp2&&(y.fogDensity.value=v.density)}function i(y,v,S,N,T){v.isMeshBasicMaterial||v.isMeshLambertMaterial?a(y,v):v.isMeshToonMaterial?(a(y,v),f(y,v)):v.isMeshPhongMaterial?(a(y,v),d(y,v)):v.isMeshStandardMaterial?(a(y,v),p(y,v),v.isMeshPhysicalMaterial&&m(y,v,T)):v.isMeshMatcapMaterial?(a(y,v),x(y,v)):v.isMeshDepthMaterial?a(y,v):v.isMeshDistanceMaterial?(a(y,v),b(y,v)):v.isMeshNormalMaterial?a(y,v):v.isLineBasicMaterial?(o(y,v),v.isLineDashedMaterial&&l(y,v)):v.isPointsMaterial?c(y,v,S,N):v.isSpriteMaterial?u(y,v):v.isShadowMaterial?(y.color.value.copy(v.color),y.opacity.value=v.opacity):v.isShaderMaterial&&(v.uniformsNeedUpdate=!1)}function a(y,v){y.opacity.value=v.opacity,v.color&&y.diffuse.value.copy(v.color),v.emissive&&y.emissive.value.copy(v.emissive).multiplyScalar(v.emissiveIntensity),v.map&&(y.map.value=v.map,n(v.map,y.mapTransform)),v.alphaMap&&(y.alphaMap.value=v.alphaMap,n(v.alphaMap,y.alphaMapTransform)),v.bumpMap&&(y.bumpMap.value=v.bumpMap,n(v.bumpMap,y.bumpMapTransform),y.bumpScale.value=v.bumpScale,v.side===Us&&(y.bumpScale.value*=-1)),v.normalMap&&(y.normalMap.value=v.normalMap,n(v.normalMap,y.normalMapTransform),y.normalScale.value.copy(v.normalScale),v.side===Us&&y.normalScale.value.negate()),v.displacementMap&&(y.displacementMap.value=v.displacementMap,n(v.displacementMap,y.displacementMapTransform),y.displacementScale.value=v.displacementScale,y.displacementBias.value=v.displacementBias),v.emissiveMap&&(y.emissiveMap.value=v.emissiveMap,n(v.emissiveMap,y.emissiveMapTransform)),v.specularMap&&(y.specularMap.value=v.specularMap,n(v.specularMap,y.specularMapTransform)),v.alphaTest>0&&(y.alphaTest.value=v.alphaTest);const S=e.get(v),N=S.envMap,T=S.envMapRotation;N&&(y.envMap.value=N,hf.copy(T),hf.x*=-1,hf.y*=-1,hf.z*=-1,N.isCubeTexture&&N.isRenderTargetTexture===!1&&(hf.y*=-1,hf.z*=-1),y.envMapRotation.value.setFromMatrix4(A4e.makeRotationFromEuler(hf)),y.flipEnvMap.value=N.isCubeTexture&&N.isRenderTargetTexture===!1?-1:1,y.reflectivity.value=v.reflectivity,y.ior.value=v.ior,y.refractionRatio.value=v.refractionRatio),v.lightMap&&(y.lightMap.value=v.lightMap,y.lightMapIntensity.value=v.lightMapIntensity,n(v.lightMap,y.lightMapTransform)),v.aoMap&&(y.aoMap.value=v.aoMap,y.aoMapIntensity.value=v.aoMapIntensity,n(v.aoMap,y.aoMapTransform))}function o(y,v){y.diffuse.value.copy(v.color),y.opacity.value=v.opacity,v.map&&(y.map.value=v.map,n(v.map,y.mapTransform))}function l(y,v){y.dashSize.value=v.dashSize,y.totalSize.value=v.dashSize+v.gapSize,y.scale.value=v.scale}function c(y,v,S,N){y.diffuse.value.copy(v.color),y.opacity.value=v.opacity,y.size.value=v.size*S,y.scale.value=N*.5,v.map&&(y.map.value=v.map,n(v.map,y.uvTransform)),v.alphaMap&&(y.alphaMap.value=v.alphaMap,n(v.alphaMap,y.alphaMapTransform)),v.alphaTest>0&&(y.alphaTest.value=v.alphaTest)}function u(y,v){y.diffuse.value.copy(v.color),y.opacity.value=v.opacity,y.rotation.value=v.rotation,v.map&&(y.map.value=v.map,n(v.map,y.mapTransform)),v.alphaMap&&(y.alphaMap.value=v.alphaMap,n(v.alphaMap,y.alphaMapTransform)),v.alphaTest>0&&(y.alphaTest.value=v.alphaTest)}function d(y,v){y.specular.value.copy(v.specular),y.shininess.value=Math.max(v.shininess,1e-4)}function f(y,v){v.gradientMap&&(y.gradientMap.value=v.gradientMap)}function p(y,v){y.metalness.value=v.metalness,v.metalnessMap&&(y.metalnessMap.value=v.metalnessMap,n(v.metalnessMap,y.metalnessMapTransform)),y.roughness.value=v.roughness,v.roughnessMap&&(y.roughnessMap.value=v.roughnessMap,n(v.roughnessMap,y.roughnessMapTransform)),v.envMap&&(y.envMapIntensity.value=v.envMapIntensity)}function m(y,v,S){y.ior.value=v.ior,v.sheen>0&&(y.sheenColor.value.copy(v.sheenColor).multiplyScalar(v.sheen),y.sheenRoughness.value=v.sheenRoughness,v.sheenColorMap&&(y.sheenColorMap.value=v.sheenColorMap,n(v.sheenColorMap,y.sheenColorMapTransform)),v.sheenRoughnessMap&&(y.sheenRoughnessMap.value=v.sheenRoughnessMap,n(v.sheenRoughnessMap,y.sheenRoughnessMapTransform))),v.clearcoat>0&&(y.clearcoat.value=v.clearcoat,y.clearcoatRoughness.value=v.clearcoatRoughness,v.clearcoatMap&&(y.clearcoatMap.value=v.clearcoatMap,n(v.clearcoatMap,y.clearcoatMapTransform)),v.clearcoatRoughnessMap&&(y.clearcoatRoughnessMap.value=v.clearcoatRoughnessMap,n(v.clearcoatRoughnessMap,y.clearcoatRoughnessMapTransform)),v.clearcoatNormalMap&&(y.clearcoatNormalMap.value=v.clearcoatNormalMap,n(v.clearcoatNormalMap,y.clearcoatNormalMapTransform),y.clearcoatNormalScale.value.copy(v.clearcoatNormalScale),v.side===Us&&y.clearcoatNormalScale.value.negate())),v.dispersion>0&&(y.dispersion.value=v.dispersion),v.iridescence>0&&(y.iridescence.value=v.iridescence,y.iridescenceIOR.value=v.iridescenceIOR,y.iridescenceThicknessMinimum.value=v.iridescenceThicknessRange[0],y.iridescenceThicknessMaximum.value=v.iridescenceThicknessRange[1],v.iridescenceMap&&(y.iridescenceMap.value=v.iridescenceMap,n(v.iridescenceMap,y.iridescenceMapTransform)),v.iridescenceThicknessMap&&(y.iridescenceThicknessMap.value=v.iridescenceThicknessMap,n(v.iridescenceThicknessMap,y.iridescenceThicknessMapTransform))),v.transmission>0&&(y.transmission.value=v.transmission,y.transmissionSamplerMap.value=S.texture,y.transmissionSamplerSize.value.set(S.width,S.height),v.transmissionMap&&(y.transmissionMap.value=v.transmissionMap,n(v.transmissionMap,y.transmissionMapTransform)),y.thickness.value=v.thickness,v.thicknessMap&&(y.thicknessMap.value=v.thicknessMap,n(v.thicknessMap,y.thicknessMapTransform)),y.attenuationDistance.value=v.attenuationDistance,y.attenuationColor.value.copy(v.attenuationColor)),v.anisotropy>0&&(y.anisotropyVector.value.set(v.anisotropy*Math.cos(v.anisotropyRotation),v.anisotropy*Math.sin(v.anisotropyRotation)),v.anisotropyMap&&(y.anisotropyMap.value=v.anisotropyMap,n(v.anisotropyMap,y.anisotropyMapTransform))),y.specularIntensity.value=v.specularIntensity,y.specularColor.value.copy(v.specularColor),v.specularColorMap&&(y.specularColorMap.value=v.specularColorMap,n(v.specularColorMap,y.specularColorMapTransform)),v.specularIntensityMap&&(y.specularIntensityMap.value=v.specularIntensityMap,n(v.specularIntensityMap,y.specularIntensityMapTransform))}function x(y,v){v.matcap&&(y.matcap.value=v.matcap)}function b(y,v){const S=e.get(v).light;y.referencePosition.value.setFromMatrixPosition(S.matrixWorld),y.nearDistance.value=S.shadow.camera.near,y.farDistance.value=S.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function j4e(t,e,n,r){let i={},a={},o=[];const l=t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS);function c(S,N){const T=N.program;r.uniformBlockBinding(S,T)}function u(S,N){let T=i[S.id];T===void 0&&(x(S),T=d(S),i[S.id]=T,S.addEventListener("dispose",y));const k=N.program;r.updateUBOMapping(S,k);const C=e.render.frame;a[S.id]!==C&&(p(S),a[S.id]=C)}function d(S){const N=f();S.__bindingPointIndex=N;const T=t.createBuffer(),k=S.__size,C=S.usage;return t.bindBuffer(t.UNIFORM_BUFFER,T),t.bufferData(t.UNIFORM_BUFFER,k,C),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,N,T),T}function f(){for(let S=0;S<l;S++)if(o.indexOf(S)===-1)return o.push(S),S;return Ei("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function p(S){const N=i[S.id],T=S.uniforms,k=S.__cache;t.bindBuffer(t.UNIFORM_BUFFER,N);for(let C=0,E=T.length;C<E;C++){const D=Array.isArray(T[C])?T[C]:[T[C]];for(let A=0,R=D.length;A<R;A++){const U=D[A];if(m(U,C,A,k)===!0){const F=U.__offset,$=Array.isArray(U.value)?U.value:[U.value];let j=0;for(let H=0;H<$.length;H++){const K=$[H],V=b(K);typeof K=="number"||typeof K=="boolean"?(U.__data[0]=K,t.bufferSubData(t.UNIFORM_BUFFER,F+j,U.__data)):K.isMatrix3?(U.__data[0]=K.elements[0],U.__data[1]=K.elements[1],U.__data[2]=K.elements[2],U.__data[3]=0,U.__data[4]=K.elements[3],U.__data[5]=K.elements[4],U.__data[6]=K.elements[5],U.__data[7]=0,U.__data[8]=K.elements[6],U.__data[9]=K.elements[7],U.__data[10]=K.elements[8],U.__data[11]=0):(K.toArray(U.__data,j),j+=V.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,F,U.__data)}}}t.bindBuffer(t.UNIFORM_BUFFER,null)}function m(S,N,T,k){const C=S.value,E=N+"_"+T;if(k[E]===void 0)return typeof C=="number"||typeof C=="boolean"?k[E]=C:k[E]=C.clone(),!0;{const D=k[E];if(typeof C=="number"||typeof C=="boolean"){if(D!==C)return k[E]=C,!0}else if(D.equals(C)===!1)return D.copy(C),!0}return!1}function x(S){const N=S.uniforms;let T=0;const k=16;for(let E=0,D=N.length;E<D;E++){const A=Array.isArray(N[E])?N[E]:[N[E]];for(let R=0,U=A.length;R<U;R++){const F=A[R],$=Array.isArray(F.value)?F.value:[F.value];for(let j=0,H=$.length;j<H;j++){const K=$[j],V=b(K),Q=T%k,Z=Q%V.boundary,ae=Q+Z;T+=Z,ae!==0&&k-ae<V.storage&&(T+=k-ae),F.__data=new Float32Array(V.storage/Float32Array.BYTES_PER_ELEMENT),F.__offset=T,T+=V.storage}}}const C=T%k;return C>0&&(T+=k-C),S.__size=T,S.__cache={},this}function b(S){const N={boundary:0,storage:0};return typeof S=="number"||typeof S=="boolean"?(N.boundary=4,N.storage=4):S.isVector2?(N.boundary=8,N.storage=8):S.isVector3||S.isColor?(N.boundary=16,N.storage=12):S.isVector4?(N.boundary=16,N.storage=16):S.isMatrix3?(N.boundary=48,N.storage=48):S.isMatrix4?(N.boundary=64,N.storage=64):S.isTexture?gn("WebGLRenderer: Texture samplers can not be part of an uniforms group."):gn("WebGLRenderer: Unsupported uniform value type.",S),N}function y(S){const N=S.target;N.removeEventListener("dispose",y);const T=o.indexOf(N.__bindingPointIndex);o.splice(T,1),t.deleteBuffer(i[N.id]),delete i[N.id],delete a[N.id]}function v(){for(const S in i)t.deleteBuffer(i[S]);o=[],i={},a={}}return{bind:c,update:u,dispose:v}}const P4e=new Uint16Array([11481,15204,11534,15171,11808,15015,12385,14843,12894,14716,13396,14600,13693,14483,13976,14366,14237,14171,14405,13961,14511,13770,14605,13598,14687,13444,14760,13305,14822,13066,14876,12857,14923,12675,14963,12517,14997,12379,15025,12230,15049,12023,15070,11843,15086,11687,15100,11551,15111,11433,15120,11330,15127,11217,15132,11060,15135,10922,15138,10801,15139,10695,15139,10600,13012,14923,13020,14917,13064,14886,13176,14800,13349,14666,13513,14526,13724,14398,13960,14230,14200,14020,14383,13827,14488,13651,14583,13491,14667,13348,14740,13132,14803,12908,14856,12713,14901,12542,14938,12394,14968,12241,14992,12017,15010,11822,15024,11654,15034,11507,15041,11380,15044,11269,15044,11081,15042,10913,15037,10764,15031,10635,15023,10520,15014,10419,15003,10330,13657,14676,13658,14673,13670,14660,13698,14622,13750,14547,13834,14442,13956,14317,14112,14093,14291,13889,14407,13704,14499,13538,14586,13389,14664,13201,14733,12966,14792,12758,14842,12577,14882,12418,14915,12272,14940,12033,14959,11826,14972,11646,14980,11490,14983,11355,14983,11212,14979,11008,14971,10830,14961,10675,14950,10540,14936,10420,14923,10315,14909,10204,14894,10041,14089,14460,14090,14459,14096,14452,14112,14431,14141,14388,14186,14305,14252,14130,14341,13941,14399,13756,14467,13585,14539,13430,14610,13272,14677,13026,14737,12808,14790,12617,14833,12449,14869,12303,14896,12065,14916,11845,14929,11655,14937,11490,14939,11347,14936,11184,14930,10970,14921,10783,14912,10621,14900,10480,14885,10356,14867,10247,14848,10062,14827,9894,14805,9745,14400,14208,14400,14206,14402,14198,14406,14174,14415,14122,14427,14035,14444,13913,14469,13767,14504,13613,14548,13463,14598,13324,14651,13082,14704,12858,14752,12658,14795,12483,14831,12330,14860,12106,14881,11875,14895,11675,14903,11501,14905,11351,14903,11178,14900,10953,14892,10757,14880,10589,14865,10442,14847,10313,14827,10162,14805,9965,14782,9792,14757,9642,14731,9507,14562,13883,14562,13883,14563,13877,14566,13862,14570,13830,14576,13773,14584,13689,14595,13582,14613,13461,14637,13336,14668,13120,14704,12897,14741,12695,14776,12516,14808,12358,14835,12150,14856,11910,14870,11701,14878,11519,14882,11361,14884,11187,14880,10951,14871,10748,14858,10572,14842,10418,14823,10286,14801,10099,14777,9897,14751,9722,14725,9567,14696,9430,14666,9309,14702,13604,14702,13604,14702,13600,14703,13591,14705,13570,14707,13533,14709,13477,14712,13400,14718,13305,14727,13106,14743,12907,14762,12716,14784,12539,14807,12380,14827,12190,14844,11943,14855,11727,14863,11539,14870,11376,14871,11204,14868,10960,14858,10748,14845,10565,14829,10406,14809,10269,14786,10058,14761,9852,14734,9671,14705,9512,14674,9374,14641,9253,14608,9076,14821,13366,14821,13365,14821,13364,14821,13358,14821,13344,14821,13320,14819,13252,14817,13145,14815,13011,14814,12858,14817,12698,14823,12539,14832,12389,14841,12214,14850,11968,14856,11750,14861,11558,14866,11390,14867,11226,14862,10972,14853,10754,14840,10565,14823,10401,14803,10259,14780,10032,14754,9820,14725,9635,14694,9473,14661,9333,14627,9203,14593,8988,14557,8798,14923,13014,14922,13014,14922,13012,14922,13004,14920,12987,14919,12957,14915,12907,14909,12834,14902,12738,14894,12623,14888,12498,14883,12370,14880,12203,14878,11970,14875,11759,14873,11569,14874,11401,14872,11243,14865,10986,14855,10762,14842,10568,14825,10401,14804,10255,14781,10017,14754,9799,14725,9611,14692,9445,14658,9301,14623,9139,14587,8920,14548,8729,14509,8562,15008,12672,15008,12672,15008,12671,15007,12667,15005,12656,15001,12637,14997,12605,14989,12556,14978,12490,14966,12407,14953,12313,14940,12136,14927,11934,14914,11742,14903,11563,14896,11401,14889,11247,14879,10992,14866,10767,14851,10570,14833,10400,14812,10252,14789,10007,14761,9784,14731,9592,14698,9424,14663,9279,14627,9088,14588,8868,14548,8676,14508,8508,14467,8360,15080,12386,15080,12386,15079,12385,15078,12383,15076,12378,15072,12367,15066,12347,15057,12315,15045,12253,15030,12138,15012,11998,14993,11845,14972,11685,14951,11530,14935,11383,14920,11228,14904,10981,14887,10762,14870,10567,14850,10397,14827,10248,14803,9997,14774,9771,14743,9578,14710,9407,14674,9259,14637,9048,14596,8826,14555,8632,14514,8464,14471,8317,14427,8182,15139,12008,15139,12008,15138,12008,15137,12007,15135,12003,15130,11990,15124,11969,15115,11929,15102,11872,15086,11794,15064,11693,15041,11581,15013,11459,14987,11336,14966,11170,14944,10944,14921,10738,14898,10552,14875,10387,14850,10239,14824,9983,14794,9758,14762,9563,14728,9392,14692,9244,14653,9014,14611,8791,14569,8597,14526,8427,14481,8281,14436,8110,14391,7885,15188,11617,15188,11617,15187,11617,15186,11618,15183,11617,15179,11612,15173,11601,15163,11581,15150,11546,15133,11495,15110,11427,15083,11346,15051,11246,15024,11057,14996,10868,14967,10687,14938,10517,14911,10362,14882,10206,14853,9956,14821,9737,14787,9543,14752,9375,14715,9228,14675,8980,14632,8760,14589,8565,14544,8395,14498,8248,14451,8049,14404,7824,14357,7630,15228,11298,15228,11298,15227,11299,15226,11301,15223,11303,15219,11302,15213,11299,15204,11290,15191,11271,15174,11217,15150,11129,15119,11015,15087,10886,15057,10744,15024,10599,14990,10455,14957,10318,14924,10143,14891,9911,14856,9701,14820,9516,14782,9352,14744,9200,14703,8946,14659,8725,14615,8533,14568,8366,14521,8220,14472,7992,14423,7770,14374,7578,14315,7408,15260,10819,15260,10819,15259,10822,15258,10826,15256,10832,15251,10836,15246,10841,15237,10838,15225,10821,15207,10788,15183,10734,15151,10660,15120,10571,15087,10469,15049,10359,15012,10249,14974,10041,14937,9837,14900,9647,14860,9475,14820,9320,14779,9147,14736,8902,14691,8688,14646,8499,14598,8335,14549,8189,14499,7940,14448,7720,14397,7529,14347,7363,14256,7218,15285,10410,15285,10411,15285,10413,15284,10418,15282,10425,15278,10434,15272,10442,15264,10449,15252,10445,15235,10433,15210,10403,15179,10358,15149,10301,15113,10218,15073,10059,15033,9894,14991,9726,14951,9565,14909,9413,14865,9273,14822,9073,14777,8845,14730,8641,14682,8459,14633,8300,14583,8129,14531,7883,14479,7670,14426,7482,14373,7321,14305,7176,14201,6939,15305,9939,15305,9940,15305,9945,15304,9955,15302,9967,15298,9989,15293,10010,15286,10033,15274,10044,15258,10045,15233,10022,15205,9975,15174,9903,15136,9808,15095,9697,15053,9578,15009,9451,14965,9327,14918,9198,14871,8973,14825,8766,14775,8579,14725,8408,14675,8259,14622,8058,14569,7821,14515,7615,14460,7435,14405,7276,14350,7108,14256,6866,14149,6653,15321,9444,15321,9445,15321,9448,15320,9458,15317,9470,15314,9490,15310,9515,15302,9540,15292,9562,15276,9579,15251,9577,15226,9559,15195,9519,15156,9463,15116,9389,15071,9304,15025,9208,14978,9023,14927,8838,14878,8661,14827,8496,14774,8344,14722,8206,14667,7973,14612,7749,14556,7555,14499,7382,14443,7229,14385,7025,14322,6791,14210,6588,14100,6409,15333,8920,15333,8921,15332,8927,15332,8943,15329,8965,15326,9002,15322,9048,15316,9106,15307,9162,15291,9204,15267,9221,15244,9221,15212,9196,15175,9134,15133,9043,15088,8930,15040,8801,14990,8665,14938,8526,14886,8391,14830,8261,14775,8087,14719,7866,14661,7664,14603,7482,14544,7322,14485,7178,14426,6936,14367,6713,14281,6517,14166,6348,14054,6198,15341,8360,15341,8361,15341,8366,15341,8379,15339,8399,15336,8431,15332,8473,15326,8527,15318,8585,15302,8632,15281,8670,15258,8690,15227,8690,15191,8664,15149,8612,15104,8543,15055,8456,15001,8360,14948,8259,14892,8122,14834,7923,14776,7734,14716,7558,14656,7397,14595,7250,14534,7070,14472,6835,14410,6628,14350,6443,14243,6283,14125,6135,14010,5889,15348,7715,15348,7717,15348,7725,15347,7745,15345,7780,15343,7836,15339,7905,15334,8e3,15326,8103,15310,8193,15293,8239,15270,8270,15240,8287,15204,8283,15163,8260,15118,8223,15067,8143,15014,8014,14958,7873,14899,7723,14839,7573,14778,7430,14715,7293,14652,7164,14588,6931,14524,6720,14460,6531,14396,6362,14330,6210,14207,6015,14086,5781,13969,5576,15352,7114,15352,7116,15352,7128,15352,7159,15350,7195,15348,7237,15345,7299,15340,7374,15332,7457,15317,7544,15301,7633,15280,7703,15251,7754,15216,7775,15176,7767,15131,7733,15079,7670,15026,7588,14967,7492,14906,7387,14844,7278,14779,7171,14714,6965,14648,6770,14581,6587,14515,6420,14448,6269,14382,6123,14299,5881,14172,5665,14049,5477,13929,5310,15355,6329,15355,6330,15355,6339,15355,6362,15353,6410,15351,6472,15349,6572,15344,6688,15337,6835,15323,6985,15309,7142,15287,7220,15260,7277,15226,7310,15188,7326,15142,7318,15090,7285,15036,7239,14976,7177,14914,7045,14849,6892,14782,6736,14714,6581,14645,6433,14576,6293,14506,6164,14438,5946,14369,5733,14270,5540,14140,5369,14014,5216,13892,5043,15357,5483,15357,5484,15357,5496,15357,5528,15356,5597,15354,5692,15351,5835,15347,6011,15339,6195,15328,6317,15314,6446,15293,6566,15268,6668,15235,6746,15197,6796,15152,6811,15101,6790,15046,6748,14985,6673,14921,6583,14854,6479,14785,6371,14714,6259,14643,6149,14571,5946,14499,5750,14428,5567,14358,5401,14242,5250,14109,5111,13980,4870,13856,4657,15359,4555,15359,4557,15358,4573,15358,4633,15357,4715,15355,4841,15353,5061,15349,5216,15342,5391,15331,5577,15318,5770,15299,5967,15274,6150,15243,6223,15206,6280,15161,6310,15111,6317,15055,6300,14994,6262,14928,6208,14860,6141,14788,5994,14715,5838,14641,5684,14566,5529,14492,5384,14418,5247,14346,5121,14216,4892,14079,4682,13948,4496,13822,4330,15359,3498,15359,3501,15359,3520,15359,3598,15358,3719,15356,3860,15355,4137,15351,4305,15344,4563,15334,4809,15321,5116,15303,5273,15280,5418,15250,5547,15214,5653,15170,5722,15120,5761,15064,5763,15002,5733,14935,5673,14865,5597,14792,5504,14716,5400,14640,5294,14563,5185,14486,5041,14410,4841,14335,4655,14191,4482,14051,4325,13918,4183,13790,4012,15360,2282,15360,2285,15360,2306,15360,2401,15359,2547,15357,2748,15355,3103,15352,3349,15345,3675,15336,4020,15324,4272,15307,4496,15285,4716,15255,4908,15220,5086,15178,5170,15128,5214,15072,5234,15010,5231,14943,5206,14871,5166,14796,5102,14718,4971,14639,4833,14559,4687,14480,4541,14402,4401,14315,4268,14167,4142,14025,3958,13888,3747,13759,3556,15360,923,15360,925,15360,946,15360,1052,15359,1214,15357,1494,15356,1892,15352,2274,15346,2663,15338,3099,15326,3393,15309,3679,15288,3980,15260,4183,15226,4325,15185,4437,15136,4517,15080,4570,15018,4591,14950,4581,14877,4545,14800,4485,14720,4411,14638,4325,14556,4231,14475,4136,14395,3988,14297,3803,14145,3628,13999,3465,13861,3314,13729,3177,15360,263,15360,264,15360,272,15360,325,15359,407,15358,548,15356,780,15352,1144,15347,1580,15339,2099,15328,2425,15312,2795,15292,3133,15264,3329,15232,3517,15191,3689,15143,3819,15088,3923,15025,3978,14956,3999,14882,3979,14804,3931,14722,3855,14639,3756,14554,3645,14470,3529,14388,3409,14279,3289,14124,3173,13975,3055,13834,2848,13701,2658,15360,49,15360,49,15360,52,15360,75,15359,111,15358,201,15356,283,15353,519,15348,726,15340,1045,15329,1415,15314,1795,15295,2173,15269,2410,15237,2649,15197,2866,15150,3054,15095,3140,15032,3196,14963,3228,14888,3236,14808,3224,14725,3191,14639,3146,14553,3088,14466,2976,14382,2836,14262,2692,14103,2549,13952,2409,13808,2278,13674,2154,15360,4,15360,4,15360,4,15360,13,15359,33,15358,59,15357,112,15353,199,15348,302,15341,456,15331,628,15316,827,15297,1082,15272,1332,15241,1601,15202,1851,15156,2069,15101,2172,15039,2256,14970,2314,14894,2348,14813,2358,14728,2344,14640,2311,14551,2263,14463,2203,14376,2133,14247,2059,14084,1915,13930,1761,13784,1609,13648,1464,15360,0,15360,0,15360,0,15360,3,15359,18,15358,26,15357,53,15354,80,15348,97,15341,165,15332,238,15318,326,15299,427,15275,529,15245,654,15207,771,15161,885,15108,994,15046,1089,14976,1170,14900,1229,14817,1266,14731,1284,14641,1282,14550,1260,14460,1223,14370,1174,14232,1116,14066,1050,13909,981,13761,910,13623,839]);let Qc=null;function D4e(){return Qc===null&&(Qc=new DPe(P4e,32,32,W4,Cx),Qc.minFilter=el,Qc.magFilter=el,Qc.wrapS=vu,Qc.wrapT=vu,Qc.generateMipmaps=!1,Qc.needsUpdate=!0),Qc}let R4e=class{constructor(e={}){const{canvas:n=iPe(),context:r=null,depth:i=!0,stencil:a=!1,alpha:o=!1,antialias:l=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:u=!1,powerPreference:d="default",failIfMajorPerformanceCaveat:f=!1,reversedDepthBuffer:p=!1}=e;this.isWebGLRenderer=!0;let m;if(r!==null){if(typeof WebGLRenderingContext<"u"&&r instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");m=r.getContextAttributes().alpha}else m=o;const x=new Set([X4,K4,q4]),b=new Set([yc,pm,dy,hy,V4,G4]),y=new Uint32Array(4),v=new Int32Array(4);let S=null,N=null;const T=[],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=lh,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const C=this;let E=!1;this._outputColorSpace=Vo;let D=0,A=0,R=null,U=-1,F=null;const $=new Ui,j=new Ui;let H=null;const K=new Bn(0);let V=0,Q=n.width,Z=n.height,ae=1,B=null,X=null;const ne=new Ui(0,0,Q,Z),se=new Ui(0,0,Q,Z);let be=!1;const xe=new eL;let de=!1,Pe=!1;const ie=new Vi,Ne=new dt,Oe=new Ui,ge={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Ke=!1;function G(){return R===null?ae:1}let Y=r;function ce(he,pe){return n.getContext(he,pe)}try{const he={alpha:!0,depth:i,stencil:a,antialias:l,premultipliedAlpha:c,preserveDrawingBuffer:u,powerPreference:d,failIfMajorPerformanceCaveat:f};if("setAttribute"in n&&n.setAttribute("data-engine",`three.js r${B4}`),n.addEventListener("webglcontextlost",ze,!1),n.addEventListener("webglcontextrestored",W,!1),n.addEventListener("webglcontextcreationerror",De,!1),Y===null){const pe="webgl2";if(Y=ce(pe,he),Y===null)throw ce(pe)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(he){throw he("WebGLRenderer: "+he.message),he}let q,te,I,fe,me,Ee,z,O,ee,le,_e,we,re,Fe,He,Ve,$e,ye,je,Be,Se,Xe,Me,tt;function ke(){q=new HRe(Y),q.init(),Xe=new M4e(Y,q),te=new DRe(Y,q,e,Xe),I=new _4e(Y,q),te.reversedDepthBuffer&&p&&I.buffers.depth.setReversed(!0),fe=new GRe(Y),me=new c4e,Ee=new S4e(Y,q,I,me,te,Xe,fe),z=new ORe(C),O=new BRe(C),ee=new XPe(Y),Me=new jRe(Y,ee),le=new $Re(Y,ee,fe,Me),_e=new WRe(Y,le,ee,fe),je=new qRe(Y,te,Ee),Ve=new RRe(me),we=new l4e(C,z,O,q,te,Me,Ve),re=new C4e(C,me),Fe=new d4e,He=new x4e(q),ye=new CRe(C,z,O,I,_e,m,c),$e=new v4e(C,_e,te),tt=new j4e(Y,fe,te,I),Be=new PRe(Y,q,fe),Se=new VRe(Y,q,fe),fe.programs=we.programs,C.capabilities=te,C.extensions=q,C.properties=me,C.renderLists=Fe,C.shadowMap=$e,C.state=I,C.info=fe}ke();const We=new T4e(C,Y);this.xr=We,this.getContext=function(){return Y},this.getContextAttributes=function(){return Y.getContextAttributes()},this.forceContextLoss=function(){const he=q.get("WEBGL_lose_context");he&&he.loseContext()},this.forceContextRestore=function(){const he=q.get("WEBGL_lose_context");he&&he.restoreContext()},this.getPixelRatio=function(){return ae},this.setPixelRatio=function(he){he!==void 0&&(ae=he,this.setSize(Q,Z,!1))},this.getSize=function(he){return he.set(Q,Z)},this.setSize=function(he,pe,Ie=!0){if(We.isPresenting){gn("WebGLRenderer: Can't change size while VR device is presenting.");return}Q=he,Z=pe,n.width=Math.floor(he*ae),n.height=Math.floor(pe*ae),Ie===!0&&(n.style.width=he+"px",n.style.height=pe+"px"),this.setViewport(0,0,he,pe)},this.getDrawingBufferSize=function(he){return he.set(Q*ae,Z*ae).floor()},this.setDrawingBufferSize=function(he,pe,Ie){Q=he,Z=pe,ae=Ie,n.width=Math.floor(he*Ie),n.height=Math.floor(pe*Ie),this.setViewport(0,0,he,pe)},this.getCurrentViewport=function(he){return he.copy($)},this.getViewport=function(he){return he.copy(ne)},this.setViewport=function(he,pe,Ie,Le){he.isVector4?ne.set(he.x,he.y,he.z,he.w):ne.set(he,pe,Ie,Le),I.viewport($.copy(ne).multiplyScalar(ae).round())},this.getScissor=function(he){return he.copy(se)},this.setScissor=function(he,pe,Ie,Le){he.isVector4?se.set(he.x,he.y,he.z,he.w):se.set(he,pe,Ie,Le),I.scissor(j.copy(se).multiplyScalar(ae).round())},this.getScissorTest=function(){return be},this.setScissorTest=function(he){I.setScissorTest(be=he)},this.setOpaqueSort=function(he){B=he},this.setTransparentSort=function(he){X=he},this.getClearColor=function(he){return he.copy(ye.getClearColor())},this.setClearColor=function(){ye.setClearColor(...arguments)},this.getClearAlpha=function(){return ye.getClearAlpha()},this.setClearAlpha=function(){ye.setClearAlpha(...arguments)},this.clear=function(he=!0,pe=!0,Ie=!0){let Le=0;if(he){let Ce=!1;if(R!==null){const ut=R.texture.format;Ce=x.has(ut)}if(Ce){const ut=R.texture.type,St=b.has(ut),At=ye.getClearColor(),Tt=ye.getClearAlpha(),Ft=At.r,Pt=At.g,Nt=At.b;St?(y[0]=Ft,y[1]=Pt,y[2]=Nt,y[3]=Tt,Y.clearBufferuiv(Y.COLOR,0,y)):(v[0]=Ft,v[1]=Pt,v[2]=Nt,v[3]=Tt,Y.clearBufferiv(Y.COLOR,0,v))}else Le|=Y.COLOR_BUFFER_BIT}pe&&(Le|=Y.DEPTH_BUFFER_BIT),Ie&&(Le|=Y.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),Y.clear(Le)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){n.removeEventListener("webglcontextlost",ze,!1),n.removeEventListener("webglcontextrestored",W,!1),n.removeEventListener("webglcontextcreationerror",De,!1),ye.dispose(),Fe.dispose(),He.dispose(),me.dispose(),z.dispose(),O.dispose(),_e.dispose(),Me.dispose(),tt.dispose(),we.dispose(),We.dispose(),We.removeEventListener("sessionstart",Jt),We.removeEventListener("sessionend",ir),fr.stop()};function ze(he){he.preventDefault(),R$("WebGLRenderer: Context Lost."),E=!0}function W(){R$("WebGLRenderer: Context Restored."),E=!1;const he=fe.autoReset,pe=$e.enabled,Ie=$e.autoUpdate,Le=$e.needsUpdate,Ce=$e.type;ke(),fe.autoReset=he,$e.enabled=pe,$e.autoUpdate=Ie,$e.needsUpdate=Le,$e.type=Ce}function De(he){Ei("WebGLRenderer: A WebGL context could not be created. Reason: ",he.statusMessage)}function Ye(he){const pe=he.target;pe.removeEventListener("dispose",Ye),xt(pe)}function xt(he){ft(he),me.remove(he)}function ft(he){const pe=me.get(he).programs;pe!==void 0&&(pe.forEach(function(Ie){we.releaseProgram(Ie)}),he.isShaderMaterial&&we.releaseShaderCache(he))}this.renderBufferDirect=function(he,pe,Ie,Le,Ce,ut){pe===null&&(pe=ge);const St=Ce.isMesh&&Ce.matrixWorld.determinant()<0,At=Ae(he,pe,Ie,Le,Ce);I.setMaterial(Le,St);let Tt=Ie.index,Ft=1;if(Le.wireframe===!0){if(Tt=le.getWireframeAttribute(Ie),Tt===void 0)return;Ft=2}const Pt=Ie.drawRange,Nt=Ie.attributes.position;let en=Pt.start*Ft,Ht=(Pt.start+Pt.count)*Ft;ut!==null&&(en=Math.max(en,ut.start*Ft),Ht=Math.min(Ht,(ut.start+ut.count)*Ft)),Tt!==null?(en=Math.max(en,0),Ht=Math.min(Ht,Tt.count)):Nt!=null&&(en=Math.max(en,0),Ht=Math.min(Ht,Nt.count));const dn=Ht-en;if(dn<0||dn===1/0)return;Me.setup(Ce,Le,At,Ie,Tt);let cn,Sn=Be;if(Tt!==null&&(cn=ee.get(Tt),Sn=Se,Sn.setIndex(cn)),Ce.isMesh)Le.wireframe===!0?(I.setLineWidth(Le.wireframeLinewidth*G()),Sn.setMode(Y.LINES)):Sn.setMode(Y.TRIANGLES);else if(Ce.isLine){let Gt=Le.linewidth;Gt===void 0&&(Gt=1),I.setLineWidth(Gt*G()),Ce.isLineSegments?Sn.setMode(Y.LINES):Ce.isLineLoop?Sn.setMode(Y.LINE_LOOP):Sn.setMode(Y.LINE_STRIP)}else Ce.isPoints?Sn.setMode(Y.POINTS):Ce.isSprite&&Sn.setMode(Y.TRIANGLES);if(Ce.isBatchedMesh)if(Ce._multiDrawInstances!==null)py("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),Sn.renderMultiDrawInstances(Ce._multiDrawStarts,Ce._multiDrawCounts,Ce._multiDrawCount,Ce._multiDrawInstances);else if(q.get("WEBGL_multi_draw"))Sn.renderMultiDraw(Ce._multiDrawStarts,Ce._multiDrawCounts,Ce._multiDrawCount);else{const Gt=Ce._multiDrawStarts,sn=Ce._multiDrawCounts,un=Ce._multiDrawCount,Yt=Tt?ee.get(Tt).bytesPerElement:1,nr=me.get(Le).currentProgram.getUniforms();for(let jn=0;jn<un;jn++)nr.setValue(Y,"_gl_DrawID",jn),Sn.render(Gt[jn]/Yt,sn[jn])}else if(Ce.isInstancedMesh)Sn.renderInstances(en,dn,Ce.count);else if(Ie.isInstancedBufferGeometry){const Gt=Ie._maxInstanceCount!==void 0?Ie._maxInstanceCount:1/0,sn=Math.min(Ie.instanceCount,Gt);Sn.renderInstances(en,dn,sn)}else Sn.render(en,dn)};function Bt(he,pe,Ie){he.transparent===!0&&he.side===ic&&he.forceSinglePass===!1?(he.side=Us,he.needsUpdate=!0,bn(he,pe,Ie),he.side=kh,he.needsUpdate=!0,bn(he,pe,Ie),he.side=ic):bn(he,pe,Ie)}this.compile=function(he,pe,Ie=null){Ie===null&&(Ie=he),N=He.get(Ie),N.init(pe),k.push(N),Ie.traverseVisible(function(Ce){Ce.isLight&&Ce.layers.test(pe.layers)&&(N.pushLight(Ce),Ce.castShadow&&N.pushShadow(Ce))}),he!==Ie&&he.traverseVisible(function(Ce){Ce.isLight&&Ce.layers.test(pe.layers)&&(N.pushLight(Ce),Ce.castShadow&&N.pushShadow(Ce))}),N.setupLights();const Le=new Set;return he.traverse(function(Ce){if(!(Ce.isMesh||Ce.isPoints||Ce.isLine||Ce.isSprite))return;const ut=Ce.material;if(ut)if(Array.isArray(ut))for(let St=0;St<ut.length;St++){const At=ut[St];Bt(At,Ie,Ce),Le.add(At)}else Bt(ut,Ie,Ce),Le.add(ut)}),N=k.pop(),Le},this.compileAsync=function(he,pe,Ie=null){const Le=this.compile(he,pe,Ie);return new Promise(Ce=>{function ut(){if(Le.forEach(function(St){me.get(St).currentProgram.isReady()&&Le.delete(St)}),Le.size===0){Ce(he);return}setTimeout(ut,10)}q.get("KHR_parallel_shader_compile")!==null?ut():setTimeout(ut,10)})};let Lt=null;function vn(he){Lt&&Lt(he)}function Jt(){fr.stop()}function ir(){fr.start()}const fr=new TJ;fr.setAnimationLoop(vn),typeof self<"u"&&fr.setContext(self),this.setAnimationLoop=function(he){Lt=he,We.setAnimationLoop(he),he===null?fr.stop():fr.start()},We.addEventListener("sessionstart",Jt),We.addEventListener("sessionend",ir),this.render=function(he,pe){if(pe!==void 0&&pe.isCamera!==!0){Ei("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(E===!0)return;if(he.matrixWorldAutoUpdate===!0&&he.updateMatrixWorld(),pe.parent===null&&pe.matrixWorldAutoUpdate===!0&&pe.updateMatrixWorld(),We.enabled===!0&&We.isPresenting===!0&&(We.cameraAutoUpdate===!0&&We.updateCamera(pe),pe=We.getCamera()),he.isScene===!0&&he.onBeforeRender(C,he,pe,R),N=He.get(he,k.length),N.init(pe),k.push(N),ie.multiplyMatrices(pe.projectionMatrix,pe.matrixWorldInverse),xe.setFromProjectionMatrix(ie,lc,pe.reversedDepth),Pe=this.localClippingEnabled,de=Ve.init(this.clippingPlanes,Pe),S=Fe.get(he,T.length),S.init(),T.push(S),We.enabled===!0&&We.isPresenting===!0){const ut=C.xr.getDepthSensingMesh();ut!==null&&Dn(ut,pe,-1/0,C.sortObjects)}Dn(he,pe,0,C.sortObjects),S.finish(),C.sortObjects===!0&&S.sort(B,X),Ke=We.enabled===!1||We.isPresenting===!1||We.hasDepthSensing()===!1,Ke&&ye.addToRenderList(S,he),this.info.render.frame++,de===!0&&Ve.beginShadows();const Ie=N.state.shadowsArray;$e.render(Ie,he,pe),de===!0&&Ve.endShadows(),this.info.autoReset===!0&&this.info.reset();const Le=S.opaque,Ce=S.transmissive;if(N.setupLights(),pe.isArrayCamera){const ut=pe.cameras;if(Ce.length>0)for(let St=0,At=ut.length;St<At;St++){const Tt=ut[St];mr(Le,Ce,he,Tt)}Ke&&ye.render(he);for(let St=0,At=ut.length;St<At;St++){const Tt=ut[St];ln(S,he,Tt,Tt.viewport)}}else Ce.length>0&&mr(Le,Ce,he,pe),Ke&&ye.render(he),ln(S,he,pe);R!==null&&A===0&&(Ee.updateMultisampleRenderTarget(R),Ee.updateRenderTargetMipmap(R)),he.isScene===!0&&he.onAfterRender(C,he,pe),Me.resetDefaultState(),U=-1,F=null,k.pop(),k.length>0?(N=k[k.length-1],de===!0&&Ve.setGlobalState(C.clippingPlanes,N.state.camera)):N=null,T.pop(),T.length>0?S=T[T.length-1]:S=null};function Dn(he,pe,Ie,Le){if(he.visible===!1)return;if(he.layers.test(pe.layers)){if(he.isGroup)Ie=he.renderOrder;else if(he.isLOD)he.autoUpdate===!0&&he.update(pe);else if(he.isLight)N.pushLight(he),he.castShadow&&N.pushShadow(he);else if(he.isSprite){if(!he.frustumCulled||xe.intersectsSprite(he)){Le&&Oe.setFromMatrixPosition(he.matrixWorld).applyMatrix4(ie);const St=_e.update(he),At=he.material;At.visible&&S.push(he,St,At,Ie,Oe.z,null)}}else if((he.isMesh||he.isLine||he.isPoints)&&(!he.frustumCulled||xe.intersectsObject(he))){const St=_e.update(he),At=he.material;if(Le&&(he.boundingSphere!==void 0?(he.boundingSphere===null&&he.computeBoundingSphere(),Oe.copy(he.boundingSphere.center)):(St.boundingSphere===null&&St.computeBoundingSphere(),Oe.copy(St.boundingSphere.center)),Oe.applyMatrix4(he.matrixWorld).applyMatrix4(ie)),Array.isArray(At)){const Tt=St.groups;for(let Ft=0,Pt=Tt.length;Ft<Pt;Ft++){const Nt=Tt[Ft],en=At[Nt.materialIndex];en&&en.visible&&S.push(he,St,en,Ie,Oe.z,Nt)}}else At.visible&&S.push(he,St,At,Ie,Oe.z,null)}}const ut=he.children;for(let St=0,At=ut.length;St<At;St++)Dn(ut[St],pe,Ie,Le)}function ln(he,pe,Ie,Le){const{opaque:Ce,transmissive:ut,transparent:St}=he;N.setupLightsView(Ie),de===!0&&Ve.setGlobalState(C.clippingPlanes,Ie),Le&&I.viewport($.copy(Le)),Ce.length>0&&Fn(Ce,pe,Ie),ut.length>0&&Fn(ut,pe,Ie),St.length>0&&Fn(St,pe,Ie),I.buffers.depth.setTest(!0),I.buffers.depth.setMask(!0),I.buffers.color.setMask(!0),I.setPolygonOffset(!1)}function mr(he,pe,Ie,Le){if((Ie.isScene===!0?Ie.overrideMaterial:null)!==null)return;N.state.transmissionRenderTarget[Le.id]===void 0&&(N.state.transmissionRenderTarget[Le.id]=new xm(1,1,{generateMipmaps:!0,type:q.has("EXT_color_buffer_half_float")||q.has("EXT_color_buffer_float")?Cx:yc,minFilter:Of,samples:4,stencilBuffer:a,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:or.workingColorSpace}));const ut=N.state.transmissionRenderTarget[Le.id],St=Le.viewport||$;ut.setSize(St.z*C.transmissionResolutionScale,St.w*C.transmissionResolutionScale);const At=C.getRenderTarget(),Tt=C.getActiveCubeFace(),Ft=C.getActiveMipmapLevel();C.setRenderTarget(ut),C.getClearColor(K),V=C.getClearAlpha(),V<1&&C.setClearColor(16777215,.5),C.clear(),Ke&&ye.render(Ie);const Pt=C.toneMapping;C.toneMapping=lh;const Nt=Le.viewport;if(Le.viewport!==void 0&&(Le.viewport=void 0),N.setupLightsView(Le),de===!0&&Ve.setGlobalState(C.clippingPlanes,Le),Fn(he,Ie,Le),Ee.updateMultisampleRenderTarget(ut),Ee.updateRenderTargetMipmap(ut),q.has("WEBGL_multisampled_render_to_texture")===!1){let en=!1;for(let Ht=0,dn=pe.length;Ht<dn;Ht++){const cn=pe[Ht],{object:Sn,geometry:Gt,material:sn,group:un}=cn;if(sn.side===ic&&Sn.layers.test(Le.layers)){const Yt=sn.side;sn.side=Us,sn.needsUpdate=!0,Xn(Sn,Ie,Le,Gt,sn,un),sn.side=Yt,sn.needsUpdate=!0,en=!0}}en===!0&&(Ee.updateMultisampleRenderTarget(ut),Ee.updateRenderTargetMipmap(ut))}C.setRenderTarget(At,Tt,Ft),C.setClearColor(K,V),Nt!==void 0&&(Le.viewport=Nt),C.toneMapping=Pt}function Fn(he,pe,Ie){const Le=pe.isScene===!0?pe.overrideMaterial:null;for(let Ce=0,ut=he.length;Ce<ut;Ce++){const St=he[Ce],{object:At,geometry:Tt,group:Ft}=St;let Pt=St.material;Pt.allowOverride===!0&&Le!==null&&(Pt=Le),At.layers.test(Ie.layers)&&Xn(At,pe,Ie,Tt,Pt,Ft)}}function Xn(he,pe,Ie,Le,Ce,ut){he.onBeforeRender(C,pe,Ie,Le,Ce,ut),he.modelViewMatrix.multiplyMatrices(Ie.matrixWorldInverse,he.matrixWorld),he.normalMatrix.getNormalMatrix(he.modelViewMatrix),Ce.onBeforeRender(C,pe,Ie,Le,he,ut),Ce.transparent===!0&&Ce.side===ic&&Ce.forceSinglePass===!1?(Ce.side=Us,Ce.needsUpdate=!0,C.renderBufferDirect(Ie,pe,Le,Ce,he,ut),Ce.side=kh,Ce.needsUpdate=!0,C.renderBufferDirect(Ie,pe,Le,Ce,he,ut),Ce.side=ic):C.renderBufferDirect(Ie,pe,Le,Ce,he,ut),he.onAfterRender(C,pe,Ie,Le,Ce,ut)}function bn(he,pe,Ie){pe.isScene!==!0&&(pe=ge);const Le=me.get(he),Ce=N.state.lights,ut=N.state.shadowsArray,St=Ce.state.version,At=we.getParameters(he,Ce.state,ut,pe,Ie),Tt=we.getProgramCacheKey(At);let Ft=Le.programs;Le.environment=he.isMeshStandardMaterial?pe.environment:null,Le.fog=pe.fog,Le.envMap=(he.isMeshStandardMaterial?O:z).get(he.envMap||Le.environment),Le.envMapRotation=Le.environment!==null&&he.envMap===null?pe.environmentRotation:he.envMapRotation,Ft===void 0&&(he.addEventListener("dispose",Ye),Ft=new Map,Le.programs=Ft);let Pt=Ft.get(Tt);if(Pt!==void 0){if(Le.currentProgram===Pt&&Le.lightsStateVersion===St)return Ba(he,At),Pt}else At.uniforms=we.getUniforms(he),he.onBeforeCompile(At,C),Pt=we.acquireProgram(At,Tt),Ft.set(Tt,Pt),Le.uniforms=At.uniforms;const Nt=Le.uniforms;return(!he.isShaderMaterial&&!he.isRawShaderMaterial||he.clipping===!0)&&(Nt.clippingPlanes=Ve.uniform),Ba(he,At),Le.needsLights=st(he),Le.lightsStateVersion=St,Le.needsLights&&(Nt.ambientLightColor.value=Ce.state.ambient,Nt.lightProbe.value=Ce.state.probe,Nt.directionalLights.value=Ce.state.directional,Nt.directionalLightShadows.value=Ce.state.directionalShadow,Nt.spotLights.value=Ce.state.spot,Nt.spotLightShadows.value=Ce.state.spotShadow,Nt.rectAreaLights.value=Ce.state.rectArea,Nt.ltc_1.value=Ce.state.rectAreaLTC1,Nt.ltc_2.value=Ce.state.rectAreaLTC2,Nt.pointLights.value=Ce.state.point,Nt.pointLightShadows.value=Ce.state.pointShadow,Nt.hemisphereLights.value=Ce.state.hemi,Nt.directionalShadowMap.value=Ce.state.directionalShadowMap,Nt.directionalShadowMatrix.value=Ce.state.directionalShadowMatrix,Nt.spotShadowMap.value=Ce.state.spotShadowMap,Nt.spotLightMatrix.value=Ce.state.spotLightMatrix,Nt.spotLightMap.value=Ce.state.spotLightMap,Nt.pointShadowMap.value=Ce.state.pointShadowMap,Nt.pointShadowMatrix.value=Ce.state.pointShadowMatrix),Le.currentProgram=Pt,Le.uniformsList=null,Pt}function wi(he){if(he.uniformsList===null){const pe=he.currentProgram.getUniforms();he.uniformsList=j1.seqWithValue(pe.seq,he.uniforms)}return he.uniformsList}function Ba(he,pe){const Ie=me.get(he);Ie.outputColorSpace=pe.outputColorSpace,Ie.batching=pe.batching,Ie.batchingColor=pe.batchingColor,Ie.instancing=pe.instancing,Ie.instancingColor=pe.instancingColor,Ie.instancingMorph=pe.instancingMorph,Ie.skinning=pe.skinning,Ie.morphTargets=pe.morphTargets,Ie.morphNormals=pe.morphNormals,Ie.morphColors=pe.morphColors,Ie.morphTargetsCount=pe.morphTargetsCount,Ie.numClippingPlanes=pe.numClippingPlanes,Ie.numIntersection=pe.numClipIntersection,Ie.vertexAlphas=pe.vertexAlphas,Ie.vertexTangents=pe.vertexTangents,Ie.toneMapping=pe.toneMapping}function Ae(he,pe,Ie,Le,Ce){pe.isScene!==!0&&(pe=ge),Ee.resetTextureUnits();const ut=pe.fog,St=Le.isMeshStandardMaterial?pe.environment:null,At=R===null?C.outputColorSpace:R.isXRRenderTarget===!0?R.texture.colorSpace:ex,Tt=(Le.isMeshStandardMaterial?O:z).get(Le.envMap||St),Ft=Le.vertexColors===!0&&!!Ie.attributes.color&&Ie.attributes.color.itemSize===4,Pt=!!Ie.attributes.tangent&&(!!Le.normalMap||Le.anisotropy>0),Nt=!!Ie.morphAttributes.position,en=!!Ie.morphAttributes.normal,Ht=!!Ie.morphAttributes.color;let dn=lh;Le.toneMapped&&(R===null||R.isXRRenderTarget===!0)&&(dn=C.toneMapping);const cn=Ie.morphAttributes.position||Ie.morphAttributes.normal||Ie.morphAttributes.color,Sn=cn!==void 0?cn.length:0,Gt=me.get(Le),sn=N.state.lights;if(de===!0&&(Pe===!0||he!==F)){const jt=he===F&&Le.id===U;Ve.setState(Le,he,jt)}let un=!1;Le.version===Gt.__version?(Gt.needsLights&&Gt.lightsStateVersion!==sn.state.version||Gt.outputColorSpace!==At||Ce.isBatchedMesh&&Gt.batching===!1||!Ce.isBatchedMesh&&Gt.batching===!0||Ce.isBatchedMesh&&Gt.batchingColor===!0&&Ce.colorTexture===null||Ce.isBatchedMesh&&Gt.batchingColor===!1&&Ce.colorTexture!==null||Ce.isInstancedMesh&&Gt.instancing===!1||!Ce.isInstancedMesh&&Gt.instancing===!0||Ce.isSkinnedMesh&&Gt.skinning===!1||!Ce.isSkinnedMesh&&Gt.skinning===!0||Ce.isInstancedMesh&&Gt.instancingColor===!0&&Ce.instanceColor===null||Ce.isInstancedMesh&&Gt.instancingColor===!1&&Ce.instanceColor!==null||Ce.isInstancedMesh&&Gt.instancingMorph===!0&&Ce.morphTexture===null||Ce.isInstancedMesh&&Gt.instancingMorph===!1&&Ce.morphTexture!==null||Gt.envMap!==Tt||Le.fog===!0&&Gt.fog!==ut||Gt.numClippingPlanes!==void 0&&(Gt.numClippingPlanes!==Ve.numPlanes||Gt.numIntersection!==Ve.numIntersection)||Gt.vertexAlphas!==Ft||Gt.vertexTangents!==Pt||Gt.morphTargets!==Nt||Gt.morphNormals!==en||Gt.morphColors!==Ht||Gt.toneMapping!==dn||Gt.morphTargetsCount!==Sn)&&(un=!0):(un=!0,Gt.__version=Le.version);let Yt=Gt.currentProgram;un===!0&&(Yt=bn(Le,pe,Ce));let nr=!1,jn=!1,ii=!1;const rr=Yt.getUniforms(),cr=Gt.uniforms;if(I.useProgram(Yt.program)&&(nr=!0,jn=!0,ii=!0),Le.id!==U&&(U=Le.id,jn=!0),nr||F!==he){I.buffers.depth.getReversed()&&he.reversedDepth!==!0&&(he._reversedDepth=!0,he.updateProjectionMatrix()),rr.setValue(Y,"projectionMatrix",he.projectionMatrix),rr.setValue(Y,"viewMatrix",he.matrixWorldInverse);const qt=rr.map.cameraPosition;qt!==void 0&&qt.setValue(Y,Ne.setFromMatrixPosition(he.matrixWorld)),te.logarithmicDepthBuffer&&rr.setValue(Y,"logDepthBufFC",2/(Math.log(he.far+1)/Math.LN2)),(Le.isMeshPhongMaterial||Le.isMeshToonMaterial||Le.isMeshLambertMaterial||Le.isMeshBasicMaterial||Le.isMeshStandardMaterial||Le.isShaderMaterial)&&rr.setValue(Y,"isOrthographic",he.isOrthographicCamera===!0),F!==he&&(F=he,jn=!0,ii=!0)}if(Ce.isSkinnedMesh){rr.setOptional(Y,Ce,"bindMatrix"),rr.setOptional(Y,Ce,"bindMatrixInverse");const jt=Ce.skeleton;jt&&(jt.boneTexture===null&&jt.computeBoneTexture(),rr.setValue(Y,"boneTexture",jt.boneTexture,Ee))}Ce.isBatchedMesh&&(rr.setOptional(Y,Ce,"batchingTexture"),rr.setValue(Y,"batchingTexture",Ce._matricesTexture,Ee),rr.setOptional(Y,Ce,"batchingIdTexture"),rr.setValue(Y,"batchingIdTexture",Ce._indirectTexture,Ee),rr.setOptional(Y,Ce,"batchingColorTexture"),Ce._colorsTexture!==null&&rr.setValue(Y,"batchingColorTexture",Ce._colorsTexture,Ee));const et=Ie.morphAttributes;if((et.position!==void 0||et.normal!==void 0||et.color!==void 0)&&je.update(Ce,Ie,Yt),(jn||Gt.receiveShadow!==Ce.receiveShadow)&&(Gt.receiveShadow=Ce.receiveShadow,rr.setValue(Y,"receiveShadow",Ce.receiveShadow)),Le.isMeshGouraudMaterial&&Le.envMap!==null&&(cr.envMap.value=Tt,cr.flipEnvMap.value=Tt.isCubeTexture&&Tt.isRenderTargetTexture===!1?-1:1),Le.isMeshStandardMaterial&&Le.envMap===null&&pe.environment!==null&&(cr.envMapIntensity.value=pe.environmentIntensity),cr.dfgLUT!==void 0&&(cr.dfgLUT.value=D4e()),jn&&(rr.setValue(Y,"toneMappingExposure",C.toneMappingExposure),Gt.needsLights&&Ze(cr,ii),ut&&Le.fog===!0&&re.refreshFogUniforms(cr,ut),re.refreshMaterialUniforms(cr,Le,ae,Z,N.state.transmissionRenderTarget[he.id]),j1.upload(Y,wi(Gt),cr,Ee)),Le.isShaderMaterial&&Le.uniformsNeedUpdate===!0&&(j1.upload(Y,wi(Gt),cr,Ee),Le.uniformsNeedUpdate=!1),Le.isSpriteMaterial&&rr.setValue(Y,"center",Ce.center),rr.setValue(Y,"modelViewMatrix",Ce.modelViewMatrix),rr.setValue(Y,"normalMatrix",Ce.normalMatrix),rr.setValue(Y,"modelMatrix",Ce.matrixWorld),Le.isShaderMaterial||Le.isRawShaderMaterial){const jt=Le.uniformsGroups;for(let qt=0,yt=jt.length;qt<yt;qt++){const wn=jt[qt];tt.update(wn,Yt),tt.bind(wn,Yt)}}return Yt}function Ze(he,pe){he.ambientLightColor.needsUpdate=pe,he.lightProbe.needsUpdate=pe,he.directionalLights.needsUpdate=pe,he.directionalLightShadows.needsUpdate=pe,he.pointLights.needsUpdate=pe,he.pointLightShadows.needsUpdate=pe,he.spotLights.needsUpdate=pe,he.spotLightShadows.needsUpdate=pe,he.rectAreaLights.needsUpdate=pe,he.hemisphereLights.needsUpdate=pe}function st(he){return he.isMeshLambertMaterial||he.isMeshToonMaterial||he.isMeshPhongMaterial||he.isMeshStandardMaterial||he.isShadowMaterial||he.isShaderMaterial&&he.lights===!0}this.getActiveCubeFace=function(){return D},this.getActiveMipmapLevel=function(){return A},this.getRenderTarget=function(){return R},this.setRenderTargetTextures=function(he,pe,Ie){const Le=me.get(he);Le.__autoAllocateDepthBuffer=he.resolveDepthBuffer===!1,Le.__autoAllocateDepthBuffer===!1&&(Le.__useRenderToTexture=!1),me.get(he.texture).__webglTexture=pe,me.get(he.depthTexture).__webglTexture=Le.__autoAllocateDepthBuffer?void 0:Ie,Le.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(he,pe){const Ie=me.get(he);Ie.__webglFramebuffer=pe,Ie.__useDefaultFramebuffer=pe===void 0};const lt=Y.createFramebuffer();this.setRenderTarget=function(he,pe=0,Ie=0){R=he,D=pe,A=Ie;let Le=!0,Ce=null,ut=!1,St=!1;if(he){const Tt=me.get(he);if(Tt.__useDefaultFramebuffer!==void 0)I.bindFramebuffer(Y.FRAMEBUFFER,null),Le=!1;else if(Tt.__webglFramebuffer===void 0)Ee.setupRenderTarget(he);else if(Tt.__hasExternalTextures)Ee.rebindTextures(he,me.get(he.texture).__webglTexture,me.get(he.depthTexture).__webglTexture);else if(he.depthBuffer){const Nt=he.depthTexture;if(Tt.__boundDepthTexture!==Nt){if(Nt!==null&&me.has(Nt)&&(he.width!==Nt.image.width||he.height!==Nt.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");Ee.setupDepthRenderbuffer(he)}}const Ft=he.texture;(Ft.isData3DTexture||Ft.isDataArrayTexture||Ft.isCompressedArrayTexture)&&(St=!0);const Pt=me.get(he).__webglFramebuffer;he.isWebGLCubeRenderTarget?(Array.isArray(Pt[pe])?Ce=Pt[pe][Ie]:Ce=Pt[pe],ut=!0):he.samples>0&&Ee.useMultisampledRTT(he)===!1?Ce=me.get(he).__webglMultisampledFramebuffer:Array.isArray(Pt)?Ce=Pt[Ie]:Ce=Pt,$.copy(he.viewport),j.copy(he.scissor),H=he.scissorTest}else $.copy(ne).multiplyScalar(ae).floor(),j.copy(se).multiplyScalar(ae).floor(),H=be;if(Ie!==0&&(Ce=lt),I.bindFramebuffer(Y.FRAMEBUFFER,Ce)&&Le&&I.drawBuffers(he,Ce),I.viewport($),I.scissor(j),I.setScissorTest(H),ut){const Tt=me.get(he.texture);Y.framebufferTexture2D(Y.FRAMEBUFFER,Y.COLOR_ATTACHMENT0,Y.TEXTURE_CUBE_MAP_POSITIVE_X+pe,Tt.__webglTexture,Ie)}else if(St){const Tt=pe;for(let Ft=0;Ft<he.textures.length;Ft++){const Pt=me.get(he.textures[Ft]);Y.framebufferTextureLayer(Y.FRAMEBUFFER,Y.COLOR_ATTACHMENT0+Ft,Pt.__webglTexture,Ie,Tt)}}else if(he!==null&&Ie!==0){const Tt=me.get(he.texture);Y.framebufferTexture2D(Y.FRAMEBUFFER,Y.COLOR_ATTACHMENT0,Y.TEXTURE_2D,Tt.__webglTexture,Ie)}U=-1},this.readRenderTargetPixels=function(he,pe,Ie,Le,Ce,ut,St,At=0){if(!(he&&he.isWebGLRenderTarget)){Ei("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Tt=me.get(he).__webglFramebuffer;if(he.isWebGLCubeRenderTarget&&St!==void 0&&(Tt=Tt[St]),Tt){I.bindFramebuffer(Y.FRAMEBUFFER,Tt);try{const Ft=he.textures[At],Pt=Ft.format,Nt=Ft.type;if(!te.textureFormatReadable(Pt)){Ei("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!te.textureTypeReadable(Nt)){Ei("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}pe>=0&&pe<=he.width-Le&&Ie>=0&&Ie<=he.height-Ce&&(he.textures.length>1&&Y.readBuffer(Y.COLOR_ATTACHMENT0+At),Y.readPixels(pe,Ie,Le,Ce,Xe.convert(Pt),Xe.convert(Nt),ut))}finally{const Ft=R!==null?me.get(R).__webglFramebuffer:null;I.bindFramebuffer(Y.FRAMEBUFFER,Ft)}}},this.readRenderTargetPixelsAsync=async function(he,pe,Ie,Le,Ce,ut,St,At=0){if(!(he&&he.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Tt=me.get(he).__webglFramebuffer;if(he.isWebGLCubeRenderTarget&&St!==void 0&&(Tt=Tt[St]),Tt)if(pe>=0&&pe<=he.width-Le&&Ie>=0&&Ie<=he.height-Ce){I.bindFramebuffer(Y.FRAMEBUFFER,Tt);const Ft=he.textures[At],Pt=Ft.format,Nt=Ft.type;if(!te.textureFormatReadable(Pt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!te.textureTypeReadable(Nt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const en=Y.createBuffer();Y.bindBuffer(Y.PIXEL_PACK_BUFFER,en),Y.bufferData(Y.PIXEL_PACK_BUFFER,ut.byteLength,Y.STREAM_READ),he.textures.length>1&&Y.readBuffer(Y.COLOR_ATTACHMENT0+At),Y.readPixels(pe,Ie,Le,Ce,Xe.convert(Pt),Xe.convert(Nt),0);const Ht=R!==null?me.get(R).__webglFramebuffer:null;I.bindFramebuffer(Y.FRAMEBUFFER,Ht);const dn=Y.fenceSync(Y.SYNC_GPU_COMMANDS_COMPLETE,0);return Y.flush(),await aPe(Y,dn,4),Y.bindBuffer(Y.PIXEL_PACK_BUFFER,en),Y.getBufferSubData(Y.PIXEL_PACK_BUFFER,0,ut),Y.deleteBuffer(en),Y.deleteSync(dn),ut}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(he,pe=null,Ie=0){const Le=Math.pow(2,-Ie),Ce=Math.floor(he.image.width*Le),ut=Math.floor(he.image.height*Le),St=pe!==null?pe.x:0,At=pe!==null?pe.y:0;Ee.setTexture2D(he,0),Y.copyTexSubImage2D(Y.TEXTURE_2D,Ie,0,0,St,At,Ce,ut),I.unbindTexture()};const ot=Y.createFramebuffer(),Et=Y.createFramebuffer();this.copyTextureToTexture=function(he,pe,Ie=null,Le=null,Ce=0,ut=null){ut===null&&(Ce!==0?(py("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),ut=Ce,Ce=0):ut=0);let St,At,Tt,Ft,Pt,Nt,en,Ht,dn;const cn=he.isCompressedTexture?he.mipmaps[ut]:he.image;if(Ie!==null)St=Ie.max.x-Ie.min.x,At=Ie.max.y-Ie.min.y,Tt=Ie.isBox3?Ie.max.z-Ie.min.z:1,Ft=Ie.min.x,Pt=Ie.min.y,Nt=Ie.isBox3?Ie.min.z:0;else{const et=Math.pow(2,-Ce);St=Math.floor(cn.width*et),At=Math.floor(cn.height*et),he.isDataArrayTexture?Tt=cn.depth:he.isData3DTexture?Tt=Math.floor(cn.depth*et):Tt=1,Ft=0,Pt=0,Nt=0}Le!==null?(en=Le.x,Ht=Le.y,dn=Le.z):(en=0,Ht=0,dn=0);const Sn=Xe.convert(pe.format),Gt=Xe.convert(pe.type);let sn;pe.isData3DTexture?(Ee.setTexture3D(pe,0),sn=Y.TEXTURE_3D):pe.isDataArrayTexture||pe.isCompressedArrayTexture?(Ee.setTexture2DArray(pe,0),sn=Y.TEXTURE_2D_ARRAY):(Ee.setTexture2D(pe,0),sn=Y.TEXTURE_2D),Y.pixelStorei(Y.UNPACK_FLIP_Y_WEBGL,pe.flipY),Y.pixelStorei(Y.UNPACK_PREMULTIPLY_ALPHA_WEBGL,pe.premultiplyAlpha),Y.pixelStorei(Y.UNPACK_ALIGNMENT,pe.unpackAlignment);const un=Y.getParameter(Y.UNPACK_ROW_LENGTH),Yt=Y.getParameter(Y.UNPACK_IMAGE_HEIGHT),nr=Y.getParameter(Y.UNPACK_SKIP_PIXELS),jn=Y.getParameter(Y.UNPACK_SKIP_ROWS),ii=Y.getParameter(Y.UNPACK_SKIP_IMAGES);Y.pixelStorei(Y.UNPACK_ROW_LENGTH,cn.width),Y.pixelStorei(Y.UNPACK_IMAGE_HEIGHT,cn.height),Y.pixelStorei(Y.UNPACK_SKIP_PIXELS,Ft),Y.pixelStorei(Y.UNPACK_SKIP_ROWS,Pt),Y.pixelStorei(Y.UNPACK_SKIP_IMAGES,Nt);const rr=he.isDataArrayTexture||he.isData3DTexture,cr=pe.isDataArrayTexture||pe.isData3DTexture;if(he.isDepthTexture){const et=me.get(he),jt=me.get(pe),qt=me.get(et.__renderTarget),yt=me.get(jt.__renderTarget);I.bindFramebuffer(Y.READ_FRAMEBUFFER,qt.__webglFramebuffer),I.bindFramebuffer(Y.DRAW_FRAMEBUFFER,yt.__webglFramebuffer);for(let wn=0;wn<Tt;wn++)rr&&(Y.framebufferTextureLayer(Y.READ_FRAMEBUFFER,Y.COLOR_ATTACHMENT0,me.get(he).__webglTexture,Ce,Nt+wn),Y.framebufferTextureLayer(Y.DRAW_FRAMEBUFFER,Y.COLOR_ATTACHMENT0,me.get(pe).__webglTexture,ut,dn+wn)),Y.blitFramebuffer(Ft,Pt,St,At,en,Ht,St,At,Y.DEPTH_BUFFER_BIT,Y.NEAREST);I.bindFramebuffer(Y.READ_FRAMEBUFFER,null),I.bindFramebuffer(Y.DRAW_FRAMEBUFFER,null)}else if(Ce!==0||he.isRenderTargetTexture||me.has(he)){const et=me.get(he),jt=me.get(pe);I.bindFramebuffer(Y.READ_FRAMEBUFFER,ot),I.bindFramebuffer(Y.DRAW_FRAMEBUFFER,Et);for(let qt=0;qt<Tt;qt++)rr?Y.framebufferTextureLayer(Y.READ_FRAMEBUFFER,Y.COLOR_ATTACHMENT0,et.__webglTexture,Ce,Nt+qt):Y.framebufferTexture2D(Y.READ_FRAMEBUFFER,Y.COLOR_ATTACHMENT0,Y.TEXTURE_2D,et.__webglTexture,Ce),cr?Y.framebufferTextureLayer(Y.DRAW_FRAMEBUFFER,Y.COLOR_ATTACHMENT0,jt.__webglTexture,ut,dn+qt):Y.framebufferTexture2D(Y.DRAW_FRAMEBUFFER,Y.COLOR_ATTACHMENT0,Y.TEXTURE_2D,jt.__webglTexture,ut),Ce!==0?Y.blitFramebuffer(Ft,Pt,St,At,en,Ht,St,At,Y.COLOR_BUFFER_BIT,Y.NEAREST):cr?Y.copyTexSubImage3D(sn,ut,en,Ht,dn+qt,Ft,Pt,St,At):Y.copyTexSubImage2D(sn,ut,en,Ht,Ft,Pt,St,At);I.bindFramebuffer(Y.READ_FRAMEBUFFER,null),I.bindFramebuffer(Y.DRAW_FRAMEBUFFER,null)}else cr?he.isDataTexture||he.isData3DTexture?Y.texSubImage3D(sn,ut,en,Ht,dn,St,At,Tt,Sn,Gt,cn.data):pe.isCompressedArrayTexture?Y.compressedTexSubImage3D(sn,ut,en,Ht,dn,St,At,Tt,Sn,cn.data):Y.texSubImage3D(sn,ut,en,Ht,dn,St,At,Tt,Sn,Gt,cn):he.isDataTexture?Y.texSubImage2D(Y.TEXTURE_2D,ut,en,Ht,St,At,Sn,Gt,cn.data):he.isCompressedTexture?Y.compressedTexSubImage2D(Y.TEXTURE_2D,ut,en,Ht,cn.width,cn.height,Sn,cn.data):Y.texSubImage2D(Y.TEXTURE_2D,ut,en,Ht,St,At,Sn,Gt,cn);Y.pixelStorei(Y.UNPACK_ROW_LENGTH,un),Y.pixelStorei(Y.UNPACK_IMAGE_HEIGHT,Yt),Y.pixelStorei(Y.UNPACK_SKIP_PIXELS,nr),Y.pixelStorei(Y.UNPACK_SKIP_ROWS,jn),Y.pixelStorei(Y.UNPACK_SKIP_IMAGES,ii),ut===0&&pe.generateMipmaps&&Y.generateMipmap(sn),I.unbindTexture()},this.initRenderTarget=function(he){me.get(he).__webglFramebuffer===void 0&&Ee.setupRenderTarget(he)},this.initTexture=function(he){he.isCubeTexture?Ee.setTextureCube(he,0):he.isData3DTexture?Ee.setTexture3D(he,0):he.isDataArrayTexture||he.isCompressedArrayTexture?Ee.setTexture2DArray(he,0):Ee.setTexture2D(he,0),I.unbindTexture()},this.resetState=function(){D=0,A=0,R=null,I.reset(),Me.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return lc}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const n=this.getContext();n.drawingBufferColorSpace=or._getDrawingBufferColorSpace(e),n.unpackColorSpace=or._getUnpackColorSpace()}};const AV={type:"change"},nL={type:"start"},DJ={type:"end"},v_=new Q4,CV=new Bd,O4e=Math.cos(70*oPe.DEG2RAD),Wi=new dt,js=2*Math.PI,Tr={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},_C=1e-6;class L4e extends WPe{constructor(e,n=null){super(e,n),this.state=Tr.NONE,this.target=new dt,this.cursor=new dt,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:Tg.ROTATE,MIDDLE:Tg.DOLLY,RIGHT:Tg.PAN},this.touches={ONE:bg.ROTATE,TWO:bg.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new dt,this._lastQuaternion=new gm,this._lastTargetPosition=new dt,this._quat=new gm().setFromUnitVectors(e.up,new dt(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new iV,this._sphericalDelta=new iV,this._scale=1,this._panOffset=new dt,this._rotateStart=new Tn,this._rotateEnd=new Tn,this._rotateDelta=new Tn,this._panStart=new Tn,this._panEnd=new Tn,this._panDelta=new Tn,this._dollyStart=new Tn,this._dollyEnd=new Tn,this._dollyDelta=new Tn,this._dollyDirection=new dt,this._mouse=new Tn,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=I4e.bind(this),this._onPointerDown=F4e.bind(this),this._onPointerUp=U4e.bind(this),this._onContextMenu=q4e.bind(this),this._onMouseWheel=H4e.bind(this),this._onKeyDown=$4e.bind(this),this._onTouchStart=V4e.bind(this),this._onTouchMove=G4e.bind(this),this._onMouseDown=z4e.bind(this),this._onMouseMove=B4e.bind(this),this._interceptControlDown=W4e.bind(this),this._interceptControlUp=K4e.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(AV),this.update(),this.state=Tr.NONE}update(e=null){const n=this.object.position;Wi.copy(n).sub(this.target),Wi.applyQuaternion(this._quat),this._spherical.setFromVector3(Wi),this.autoRotate&&this.state===Tr.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let r=this.minAzimuthAngle,i=this.maxAzimuthAngle;isFinite(r)&&isFinite(i)&&(r<-Math.PI?r+=js:r>Math.PI&&(r-=js),i<-Math.PI?i+=js:i>Math.PI&&(i-=js),r<=i?this._spherical.theta=Math.max(r,Math.min(i,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(r+i)/2?Math.max(r,this._spherical.theta):Math.min(i,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let a=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const o=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),a=o!=this._spherical.radius}if(Wi.setFromSpherical(this._spherical),Wi.applyQuaternion(this._quatInverse),n.copy(this.target).add(Wi),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let o=null;if(this.object.isPerspectiveCamera){const l=Wi.length();o=this._clampDistance(l*this._scale);const c=l-o;this.object.position.addScaledVector(this._dollyDirection,c),this.object.updateMatrixWorld(),a=!!c}else if(this.object.isOrthographicCamera){const l=new dt(this._mouse.x,this._mouse.y,0);l.unproject(this.object);const c=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),a=c!==this.object.zoom;const u=new dt(this._mouse.x,this._mouse.y,0);u.unproject(this.object),this.object.position.sub(u).add(l),this.object.updateMatrixWorld(),o=Wi.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;o!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(o).add(this.object.position):(v_.origin.copy(this.object.position),v_.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(v_.direction))<O4e?this.object.lookAt(this.target):(CV.setFromNormalAndCoplanarPoint(this.object.up,this.target),v_.intersectPlane(CV,this.target))))}else if(this.object.isOrthographicCamera){const o=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),o!==this.object.zoom&&(this.object.updateProjectionMatrix(),a=!0)}return this._scale=1,this._performCursorZoom=!1,a||this._lastPosition.distanceToSquared(this.object.position)>_C||8*(1-this._lastQuaternion.dot(this.object.quaternion))>_C||this._lastTargetPosition.distanceToSquared(this.target)>_C?(this.dispatchEvent(AV),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?js/60*this.autoRotateSpeed*e:js/60/60*this.autoRotateSpeed}_getZoomScale(e){const n=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*n)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,n){Wi.setFromMatrixColumn(n,0),Wi.multiplyScalar(-e),this._panOffset.add(Wi)}_panUp(e,n){this.screenSpacePanning===!0?Wi.setFromMatrixColumn(n,1):(Wi.setFromMatrixColumn(n,0),Wi.crossVectors(this.object.up,Wi)),Wi.multiplyScalar(e),this._panOffset.add(Wi)}_pan(e,n){const r=this.domElement;if(this.object.isPerspectiveCamera){const i=this.object.position;Wi.copy(i).sub(this.target);let a=Wi.length();a*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*a/r.clientHeight,this.object.matrix),this._panUp(2*n*a/r.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/r.clientWidth,this.object.matrix),this._panUp(n*(this.object.top-this.object.bottom)/this.object.zoom/r.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,n){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const r=this.domElement.getBoundingClientRect(),i=e-r.left,a=n-r.top,o=r.width,l=r.height;this._mouse.x=i/o*2-1,this._mouse.y=-(a/l)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const n=this.domElement;this._rotateLeft(js*this._rotateDelta.x/n.clientHeight),this._rotateUp(js*this._rotateDelta.y/n.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let n=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(js*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),n=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-js*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),n=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(js*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),n=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-js*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),n=!0;break}n&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),r=.5*(e.pageX+n.x),i=.5*(e.pageY+n.y);this._rotateStart.set(r,i)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),r=.5*(e.pageX+n.x),i=.5*(e.pageY+n.y);this._panStart.set(r,i)}}_handleTouchStartDolly(e){const n=this._getSecondPointerPosition(e),r=e.pageX-n.x,i=e.pageY-n.y,a=Math.sqrt(r*r+i*i);this._dollyStart.set(0,a)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const r=this._getSecondPointerPosition(e),i=.5*(e.pageX+r.x),a=.5*(e.pageY+r.y);this._rotateEnd.set(i,a)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const n=this.domElement;this._rotateLeft(js*this._rotateDelta.x/n.clientHeight),this._rotateUp(js*this._rotateDelta.y/n.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),r=.5*(e.pageX+n.x),i=.5*(e.pageY+n.y);this._panEnd.set(r,i)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const n=this._getSecondPointerPosition(e),r=e.pageX-n.x,i=e.pageY-n.y,a=Math.sqrt(r*r+i*i);this._dollyEnd.set(0,a),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const o=(e.pageX+n.x)*.5,l=(e.pageY+n.y)*.5;this._updateZoomParameters(o,l)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let n=0;n<this._pointers.length;n++)if(this._pointers[n]==e.pointerId){this._pointers.splice(n,1);return}}_isTrackingPointer(e){for(let n=0;n<this._pointers.length;n++)if(this._pointers[n]==e.pointerId)return!0;return!1}_trackPointer(e){let n=this._pointerPositions[e.pointerId];n===void 0&&(n=new Tn,this._pointerPositions[e.pointerId]=n),n.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){const n=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[n]}_customWheelEvent(e){const n=e.deltaMode,r={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(n){case 1:r.deltaY*=16;break;case 2:r.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(r.deltaY*=10),r}}function F4e(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 I4e(t){this.enabled!==!1&&(t.pointerType==="touch"?this._onTouchMove(t):this._onMouseMove(t))}function U4e(t){switch(this._removePointer(t),this._pointers.length){case 0:this.domElement.releasePointerCapture(t.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(DJ),this.state=Tr.NONE;break;case 1:const e=this._pointers[0],n=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:n.x,pageY:n.y});break}}function z4e(t){let e;switch(t.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case Tg.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(t),this.state=Tr.DOLLY;break;case Tg.ROTATE:if(t.ctrlKey||t.metaKey||t.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(t),this.state=Tr.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(t),this.state=Tr.ROTATE}break;case Tg.PAN:if(t.ctrlKey||t.metaKey||t.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(t),this.state=Tr.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(t),this.state=Tr.PAN}break;default:this.state=Tr.NONE}this.state!==Tr.NONE&&this.dispatchEvent(nL)}function B4e(t){switch(this.state){case Tr.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(t);break;case Tr.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(t);break;case Tr.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(t);break}}function H4e(t){this.enabled===!1||this.enableZoom===!1||this.state!==Tr.NONE||(t.preventDefault(),this.dispatchEvent(nL),this._handleMouseWheel(this._customWheelEvent(t)),this.dispatchEvent(DJ))}function $4e(t){this.enabled!==!1&&this._handleKeyDown(t)}function V4e(t){switch(this._trackPointer(t),this._pointers.length){case 1:switch(this.touches.ONE){case bg.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(t),this.state=Tr.TOUCH_ROTATE;break;case bg.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(t),this.state=Tr.TOUCH_PAN;break;default:this.state=Tr.NONE}break;case 2:switch(this.touches.TWO){case bg.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(t),this.state=Tr.TOUCH_DOLLY_PAN;break;case bg.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(t),this.state=Tr.TOUCH_DOLLY_ROTATE;break;default:this.state=Tr.NONE}break;default:this.state=Tr.NONE}this.state!==Tr.NONE&&this.dispatchEvent(nL)}function G4e(t){switch(this._trackPointer(t),this.state){case Tr.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(t),this.update();break;case Tr.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(t),this.update();break;case Tr.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(t),this.update();break;case Tr.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(t),this.update();break;default:this.state=Tr.NONE}}function q4e(t){this.enabled!==!1&&t.preventDefault()}function W4e(t){t.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function K4e(t){t.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function X4e(t,e=!1){const n=t[0].index!==null,r=new Set(Object.keys(t[0].attributes)),i=new Set(Object.keys(t[0].morphAttributes)),a={},o={},l=t[0].morphTargetsRelative,c=new Ac;let u=0;for(let d=0;d<t.length;++d){const f=t[d];let p=0;if(n!==(f.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const m in f.attributes){if(!r.has(m))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+'. All geometries must have compatible attributes; make sure "'+m+'" attribute exists among all geometries, or in none of them.'),null;a[m]===void 0&&(a[m]=[]),a[m].push(f.attributes[m]),p++}if(p!==r.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". Make sure all geometries have the same number of attributes."),null;if(l!==f.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const m in f.morphAttributes){if(!i.has(m))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". .morphAttributes must be consistent throughout all geometries."),null;o[m]===void 0&&(o[m]=[]),o[m].push(f.morphAttributes[m])}if(e){let m;if(n)m=f.index.count;else if(f.attributes.position!==void 0)m=f.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". The geometry must have either an index or a position attribute"),null;c.addGroup(u,m,d),u+=m}}if(n){let d=0;const f=[];for(let p=0;p<t.length;++p){const m=t[p].index;for(let x=0;x<m.count;++x)f.push(m.getX(x)+d);d+=t[p].attributes.position.count}c.setIndex(f)}for(const d in a){const f=jV(a[d]);if(!f)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+d+" attribute."),null;c.setAttribute(d,f)}for(const d in o){const f=o[d][0].length;if(f===0)break;c.morphAttributes=c.morphAttributes||{},c.morphAttributes[d]=[];for(let p=0;p<f;++p){const m=[];for(let b=0;b<o[d].length;++b)m.push(o[d][b][p]);const x=jV(m);if(!x)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+d+" morphAttribute."),null;c.morphAttributes[d].push(x)}}return c}function jV(t){let e,n,r,i=-1,a=0;for(let u=0;u<t.length;++u){const d=t[u];if(e===void 0&&(e=d.array.constructor),e!==d.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(n===void 0&&(n=d.itemSize),n!==d.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(r===void 0&&(r=d.normalized),r!==d.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(i===-1&&(i=d.gpuType),i!==d.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;a+=d.count*n}const o=new e(a),l=new nl(o,n,r);let c=0;for(let u=0;u<t.length;++u){const d=t[u];if(d.isInterleavedBufferAttribute){const f=c/n;for(let p=0,m=d.count;p<m;p++)for(let x=0;x<n;x++){const b=d.getComponent(p,x);l.setComponent(p+f,x,b)}}else o.set(d.array,c);c+=d.count*n}return i!==void 0&&(l.gpuType=i),l}function w_(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var SC={exports:{}};var PV;function Y4e(){return PV||(PV=1,(function(t,e){(function(n){t.exports=n()})(function(){return(function n(r,i,a){function o(u,d){if(!i[u]){if(!r[u]){var f=typeof w_=="function"&&w_;if(!d&&f)return f(u,!0);if(l)return l(u,!0);var p=new Error("Cannot find module '"+u+"'");throw p.code="MODULE_NOT_FOUND",p}var m=i[u]={exports:{}};r[u][0].call(m.exports,function(x){var b=r[u][1][x];return o(b||x)},m,m.exports,n,r,i,a)}return i[u].exports}for(var l=typeof w_=="function"&&w_,c=0;c<a.length;c++)o(a[c]);return o})({1:[function(n,r,i){var a=n("./utils"),o=n("./support"),l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";i.encode=function(c){for(var u,d,f,p,m,x,b,y=[],v=0,S=c.length,N=S,T=a.getTypeOf(c)!=="string";v<c.length;)N=S-v,f=T?(u=c[v++],d=v<S?c[v++]:0,v<S?c[v++]:0):(u=c.charCodeAt(v++),d=v<S?c.charCodeAt(v++):0,v<S?c.charCodeAt(v++):0),p=u>>2,m=(3&u)<<4|d>>4,x=1<N?(15&d)<<2|f>>6:64,b=2<N?63&f:64,y.push(l.charAt(p)+l.charAt(m)+l.charAt(x)+l.charAt(b));return y.join("")},i.decode=function(c){var u,d,f,p,m,x,b=0,y=0,v="data:";if(c.substr(0,v.length)===v)throw new Error("Invalid base64 input, it looks like a data url.");var S,N=3*(c=c.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(c.charAt(c.length-1)===l.charAt(64)&&N--,c.charAt(c.length-2)===l.charAt(64)&&N--,N%1!=0)throw new Error("Invalid base64 input, bad content length.");for(S=o.uint8array?new Uint8Array(0|N):new Array(0|N);b<c.length;)u=l.indexOf(c.charAt(b++))<<2|(p=l.indexOf(c.charAt(b++)))>>4,d=(15&p)<<4|(m=l.indexOf(c.charAt(b++)))>>2,f=(3&m)<<6|(x=l.indexOf(c.charAt(b++))),S[y++]=u,m!==64&&(S[y++]=d),x!==64&&(S[y++]=f);return S}},{"./support":30,"./utils":32}],2:[function(n,r,i){var a=n("./external"),o=n("./stream/DataWorker"),l=n("./stream/Crc32Probe"),c=n("./stream/DataLengthProbe");function u(d,f,p,m,x){this.compressedSize=d,this.uncompressedSize=f,this.crc32=p,this.compression=m,this.compressedContent=x}u.prototype={getContentWorker:function(){var d=new o(a.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new c("data_length")),f=this;return d.on("end",function(){if(this.streamInfo.data_length!==f.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),d},getCompressedWorker:function(){return new o(a.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},u.createWorkerFrom=function(d,f,p){return d.pipe(new l).pipe(new c("uncompressedSize")).pipe(f.compressWorker(p)).pipe(new c("compressedSize")).withStreamInfo("compression",f)},r.exports=u},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(n,r,i){var a=n("./stream/GenericWorker");i.STORE={magic:"\0\0",compressWorker:function(){return new a("STORE compression")},uncompressWorker:function(){return new a("STORE decompression")}},i.DEFLATE=n("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(n,r,i){var a=n("./utils"),o=(function(){for(var l,c=[],u=0;u<256;u++){l=u;for(var d=0;d<8;d++)l=1&l?3988292384^l>>>1:l>>>1;c[u]=l}return c})();r.exports=function(l,c){return l!==void 0&&l.length?a.getTypeOf(l)!=="string"?(function(u,d,f,p){var m=o,x=p+f;u^=-1;for(var b=p;b<x;b++)u=u>>>8^m[255&(u^d[b])];return-1^u})(0|c,l,l.length,0):(function(u,d,f,p){var m=o,x=p+f;u^=-1;for(var b=p;b<x;b++)u=u>>>8^m[255&(u^d.charCodeAt(b))];return-1^u})(0|c,l,l.length,0):0}},{"./utils":32}],5:[function(n,r,i){i.base64=!1,i.binary=!1,i.dir=!1,i.createFolders=!0,i.date=null,i.compression=null,i.compressionOptions=null,i.comment=null,i.unixPermissions=null,i.dosPermissions=null},{}],6:[function(n,r,i){var a=null;a=typeof Promise<"u"?Promise:n("lie"),r.exports={Promise:a}},{lie:37}],7:[function(n,r,i){var a=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",o=n("pako"),l=n("./utils"),c=n("./stream/GenericWorker"),u=a?"uint8array":"array";function d(f,p){c.call(this,"FlateWorker/"+f),this._pako=null,this._pakoAction=f,this._pakoOptions=p,this.meta={}}i.magic="\b\0",l.inherits(d,c),d.prototype.processChunk=function(f){this.meta=f.meta,this._pako===null&&this._createPako(),this._pako.push(l.transformTo(u,f.data),!1)},d.prototype.flush=function(){c.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},d.prototype.cleanUp=function(){c.prototype.cleanUp.call(this),this._pako=null},d.prototype._createPako=function(){this._pako=new o[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var f=this;this._pako.onData=function(p){f.push({data:p,meta:f.meta})}},i.compressWorker=function(f){return new d("Deflate",f)},i.uncompressWorker=function(){return new d("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(n,r,i){function a(m,x){var b,y="";for(b=0;b<x;b++)y+=String.fromCharCode(255&m),m>>>=8;return y}function o(m,x,b,y,v,S){var N,T,k=m.file,C=m.compression,E=S!==u.utf8encode,D=l.transformTo("string",S(k.name)),A=l.transformTo("string",u.utf8encode(k.name)),R=k.comment,U=l.transformTo("string",S(R)),F=l.transformTo("string",u.utf8encode(R)),$=A.length!==k.name.length,j=F.length!==R.length,H="",K="",V="",Q=k.dir,Z=k.date,ae={crc32:0,compressedSize:0,uncompressedSize:0};x&&!b||(ae.crc32=m.crc32,ae.compressedSize=m.compressedSize,ae.uncompressedSize=m.uncompressedSize);var B=0;x&&(B|=8),E||!$&&!j||(B|=2048);var X=0,ne=0;Q&&(X|=16),v==="UNIX"?(ne=798,X|=(function(be,xe){var de=be;return be||(de=xe?16893:33204),(65535&de)<<16})(k.unixPermissions,Q)):(ne=20,X|=(function(be){return 63&(be||0)})(k.dosPermissions)),N=Z.getUTCHours(),N<<=6,N|=Z.getUTCMinutes(),N<<=5,N|=Z.getUTCSeconds()/2,T=Z.getUTCFullYear()-1980,T<<=4,T|=Z.getUTCMonth()+1,T<<=5,T|=Z.getUTCDate(),$&&(K=a(1,1)+a(d(D),4)+A,H+="up"+a(K.length,2)+K),j&&(V=a(1,1)+a(d(U),4)+F,H+="uc"+a(V.length,2)+V);var se="";return se+=`
- \0`,se+=a(B,2),se+=C.magic,se+=a(N,2),se+=a(T,2),se+=a(ae.crc32,4),se+=a(ae.compressedSize,4),se+=a(ae.uncompressedSize,4),se+=a(D.length,2),se+=a(H.length,2),{fileRecord:f.LOCAL_FILE_HEADER+se+D+H,dirRecord:f.CENTRAL_FILE_HEADER+a(ne,2)+se+a(U.length,2)+"\0\0\0\0"+a(X,4)+a(y,4)+D+H+U}}var l=n("../utils"),c=n("../stream/GenericWorker"),u=n("../utf8"),d=n("../crc32"),f=n("../signature");function p(m,x,b,y){c.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=x,this.zipPlatform=b,this.encodeFileName=y,this.streamFiles=m,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}l.inherits(p,c),p.prototype.push=function(m){var x=m.meta.percent||0,b=this.entriesCount,y=this._sources.length;this.accumulate?this.contentBuffer.push(m):(this.bytesWritten+=m.data.length,c.prototype.push.call(this,{data:m.data,meta:{currentFile:this.currentFile,percent:b?(x+100*(b-y-1))/b:100}}))},p.prototype.openedSource=function(m){this.currentSourceOffset=this.bytesWritten,this.currentFile=m.file.name;var x=this.streamFiles&&!m.file.dir;if(x){var b=o(m,x,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:b.fileRecord,meta:{percent:0}})}else this.accumulate=!0},p.prototype.closedSource=function(m){this.accumulate=!1;var x=this.streamFiles&&!m.file.dir,b=o(m,x,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(b.dirRecord),x)this.push({data:(function(y){return f.DATA_DESCRIPTOR+a(y.crc32,4)+a(y.compressedSize,4)+a(y.uncompressedSize,4)})(m),meta:{percent:100}});else for(this.push({data:b.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},p.prototype.flush=function(){for(var m=this.bytesWritten,x=0;x<this.dirRecords.length;x++)this.push({data:this.dirRecords[x],meta:{percent:100}});var b=this.bytesWritten-m,y=(function(v,S,N,T,k){var C=l.transformTo("string",k(T));return f.CENTRAL_DIRECTORY_END+"\0\0\0\0"+a(v,2)+a(v,2)+a(S,4)+a(N,4)+a(C.length,2)+C})(this.dirRecords.length,b,m,this.zipComment,this.encodeFileName);this.push({data:y,meta:{percent:100}})},p.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},p.prototype.registerPrevious=function(m){this._sources.push(m);var x=this;return m.on("data",function(b){x.processChunk(b)}),m.on("end",function(){x.closedSource(x.previous.streamInfo),x._sources.length?x.prepareNextSource():x.end()}),m.on("error",function(b){x.error(b)}),this},p.prototype.resume=function(){return!!c.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},p.prototype.error=function(m){var x=this._sources;if(!c.prototype.error.call(this,m))return!1;for(var b=0;b<x.length;b++)try{x[b].error(m)}catch{}return!0},p.prototype.lock=function(){c.prototype.lock.call(this);for(var m=this._sources,x=0;x<m.length;x++)m[x].lock()},r.exports=p},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(n,r,i){var a=n("../compressions"),o=n("./ZipFileWorker");i.generateWorker=function(l,c,u){var d=new o(c.streamFiles,u,c.platform,c.encodeFileName),f=0;try{l.forEach(function(p,m){f++;var x=(function(S,N){var T=S||N,k=a[T];if(!k)throw new Error(T+" is not a valid compression method !");return k})(m.options.compression,c.compression),b=m.options.compressionOptions||c.compressionOptions||{},y=m.dir,v=m.date;m._compressWorker(x,b).withStreamInfo("file",{name:p,dir:y,date:v,comment:m.comment||"",unixPermissions:m.unixPermissions,dosPermissions:m.dosPermissions}).pipe(d)}),d.entriesCount=f}catch(p){d.error(p)}return d}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(n,r,i){function a(){if(!(this instanceof a))return new a;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var o=new a;for(var l in this)typeof this[l]!="function"&&(o[l]=this[l]);return o}}(a.prototype=n("./object")).loadAsync=n("./load"),a.support=n("./support"),a.defaults=n("./defaults"),a.version="3.10.1",a.loadAsync=function(o,l){return new a().loadAsync(o,l)},a.external=n("./external"),r.exports=a},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(n,r,i){var a=n("./utils"),o=n("./external"),l=n("./utf8"),c=n("./zipEntries"),u=n("./stream/Crc32Probe"),d=n("./nodejsUtils");function f(p){return new o.Promise(function(m,x){var b=p.decompressed.getContentWorker().pipe(new u);b.on("error",function(y){x(y)}).on("end",function(){b.streamInfo.crc32!==p.decompressed.crc32?x(new Error("Corrupted zip : CRC32 mismatch")):m()}).resume()})}r.exports=function(p,m){var x=this;return m=a.extend(m||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:l.utf8decode}),d.isNode&&d.isStream(p)?o.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):a.prepareContent("the loaded zip file",p,!0,m.optimizedBinaryString,m.base64).then(function(b){var y=new c(m);return y.load(b),y}).then(function(b){var y=[o.Promise.resolve(b)],v=b.files;if(m.checkCRC32)for(var S=0;S<v.length;S++)y.push(f(v[S]));return o.Promise.all(y)}).then(function(b){for(var y=b.shift(),v=y.files,S=0;S<v.length;S++){var N=v[S],T=N.fileNameStr,k=a.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:m.createFolders}),N.dir||(x.file(k).unsafeOriginalName=T)}return y.zipComment.length&&(x.comment=y.zipComment),x})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(n,r,i){var a=n("../utils"),o=n("../stream/GenericWorker");function l(c,u){o.call(this,"Nodejs stream input adapter for "+c),this._upstreamEnded=!1,this._bindStream(u)}a.inherits(l,o),l.prototype._bindStream=function(c){var u=this;(this._stream=c).pause(),c.on("data",function(d){u.push({data:d,meta:{percent:0}})}).on("error",function(d){u.isPaused?this.generatedError=d:u.error(d)}).on("end",function(){u.isPaused?u._upstreamEnded=!0:u.end()})},l.prototype.pause=function(){return!!o.prototype.pause.call(this)&&(this._stream.pause(),!0)},l.prototype.resume=function(){return!!o.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},r.exports=l},{"../stream/GenericWorker":28,"../utils":32}],13:[function(n,r,i){var a=n("readable-stream").Readable;function o(l,c,u){a.call(this,c),this._helper=l;var d=this;l.on("data",function(f,p){d.push(f)||d._helper.pause(),u&&u(p)}).on("error",function(f){d.emit("error",f)}).on("end",function(){d.push(null)})}n("../utils").inherits(o,a),o.prototype._read=function(){this._helper.resume()},r.exports=o},{"../utils":32,"readable-stream":16}],14:[function(n,r,i){r.exports={isNode:typeof Buffer<"u",newBufferFrom:function(a,o){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(a,o);if(typeof a=="number")throw new Error('The "data" argument must not be a number');return new Buffer(a,o)},allocBuffer:function(a){if(Buffer.alloc)return Buffer.alloc(a);var o=new Buffer(a);return o.fill(0),o},isBuffer:function(a){return Buffer.isBuffer(a)},isStream:function(a){return a&&typeof a.on=="function"&&typeof a.pause=="function"&&typeof a.resume=="function"}}},{}],15:[function(n,r,i){function a(k,C,E){var D,A=l.getTypeOf(C),R=l.extend(E||{},d);R.date=R.date||new Date,R.compression!==null&&(R.compression=R.compression.toUpperCase()),typeof R.unixPermissions=="string"&&(R.unixPermissions=parseInt(R.unixPermissions,8)),R.unixPermissions&&16384&R.unixPermissions&&(R.dir=!0),R.dosPermissions&&16&R.dosPermissions&&(R.dir=!0),R.dir&&(k=v(k)),R.createFolders&&(D=y(k))&&S.call(this,D,!0);var U=A==="string"&&R.binary===!1&&R.base64===!1;E&&E.binary!==void 0||(R.binary=!U),(C instanceof f&&C.uncompressedSize===0||R.dir||!C||C.length===0)&&(R.base64=!1,R.binary=!0,C="",R.compression="STORE",A="string");var F=null;F=C instanceof f||C instanceof c?C:x.isNode&&x.isStream(C)?new b(k,C):l.prepareContent(k,C,R.binary,R.optimizedBinaryString,R.base64);var $=new p(k,F,R);this.files[k]=$}var o=n("./utf8"),l=n("./utils"),c=n("./stream/GenericWorker"),u=n("./stream/StreamHelper"),d=n("./defaults"),f=n("./compressedObject"),p=n("./zipObject"),m=n("./generate"),x=n("./nodejsUtils"),b=n("./nodejs/NodejsStreamInputAdapter"),y=function(k){k.slice(-1)==="/"&&(k=k.substring(0,k.length-1));var C=k.lastIndexOf("/");return 0<C?k.substring(0,C):""},v=function(k){return k.slice(-1)!=="/"&&(k+="/"),k},S=function(k,C){return C=C!==void 0?C:d.createFolders,k=v(k),this.files[k]||a.call(this,k,null,{dir:!0,createFolders:C}),this.files[k]};function N(k){return Object.prototype.toString.call(k)==="[object RegExp]"}var T={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(k){var C,E,D;for(C in this.files)D=this.files[C],(E=C.slice(this.root.length,C.length))&&C.slice(0,this.root.length)===this.root&&k(E,D)},filter:function(k){var C=[];return this.forEach(function(E,D){k(E,D)&&C.push(D)}),C},file:function(k,C,E){if(arguments.length!==1)return k=this.root+k,a.call(this,k,C,E),this;if(N(k)){var D=k;return this.filter(function(R,U){return!U.dir&&D.test(R)})}var A=this.files[this.root+k];return A&&!A.dir?A:null},folder:function(k){if(!k)return this;if(N(k))return this.filter(function(A,R){return R.dir&&k.test(A)});var C=this.root+k,E=S.call(this,C),D=this.clone();return D.root=E.name,D},remove:function(k){k=this.root+k;var C=this.files[k];if(C||(k.slice(-1)!=="/"&&(k+="/"),C=this.files[k]),C&&!C.dir)delete this.files[k];else for(var E=this.filter(function(A,R){return R.name.slice(0,k.length)===k}),D=0;D<E.length;D++)delete this.files[E[D].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(k){var C,E={};try{if((E=l.extend(k||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:o.utf8encode})).type=E.type.toLowerCase(),E.compression=E.compression.toUpperCase(),E.type==="binarystring"&&(E.type="string"),!E.type)throw new Error("No output type specified.");l.checkSupport(E.type),E.platform!=="darwin"&&E.platform!=="freebsd"&&E.platform!=="linux"&&E.platform!=="sunos"||(E.platform="UNIX"),E.platform==="win32"&&(E.platform="DOS");var D=E.comment||this.comment||"";C=m.generateWorker(this,E,D)}catch(A){(C=new c("error")).error(A)}return new u(C,E.type||"string",E.mimeType)},generateAsync:function(k,C){return this.generateInternalStream(k).accumulate(C)},generateNodeStream:function(k,C){return(k=k||{}).type||(k.type="nodebuffer"),this.generateInternalStream(k).toNodejsStream(C)}};r.exports=T},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(n,r,i){r.exports=n("stream")},{stream:void 0}],17:[function(n,r,i){var a=n("./DataReader");function o(l){a.call(this,l);for(var c=0;c<this.data.length;c++)l[c]=255&l[c]}n("../utils").inherits(o,a),o.prototype.byteAt=function(l){return this.data[this.zero+l]},o.prototype.lastIndexOfSignature=function(l){for(var c=l.charCodeAt(0),u=l.charCodeAt(1),d=l.charCodeAt(2),f=l.charCodeAt(3),p=this.length-4;0<=p;--p)if(this.data[p]===c&&this.data[p+1]===u&&this.data[p+2]===d&&this.data[p+3]===f)return p-this.zero;return-1},o.prototype.readAndCheckSignature=function(l){var c=l.charCodeAt(0),u=l.charCodeAt(1),d=l.charCodeAt(2),f=l.charCodeAt(3),p=this.readData(4);return c===p[0]&&u===p[1]&&d===p[2]&&f===p[3]},o.prototype.readData=function(l){if(this.checkOffset(l),l===0)return[];var c=this.data.slice(this.zero+this.index,this.zero+this.index+l);return this.index+=l,c},r.exports=o},{"../utils":32,"./DataReader":18}],18:[function(n,r,i){var a=n("../utils");function o(l){this.data=l,this.length=l.length,this.index=0,this.zero=0}o.prototype={checkOffset:function(l){this.checkIndex(this.index+l)},checkIndex:function(l){if(this.length<this.zero+l||l<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+l+"). Corrupted zip ?")},setIndex:function(l){this.checkIndex(l),this.index=l},skip:function(l){this.setIndex(this.index+l)},byteAt:function(){},readInt:function(l){var c,u=0;for(this.checkOffset(l),c=this.index+l-1;c>=this.index;c--)u=(u<<8)+this.byteAt(c);return this.index+=l,u},readString:function(l){return a.transformTo("string",this.readData(l))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var l=this.readInt(4);return new Date(Date.UTC(1980+(l>>25&127),(l>>21&15)-1,l>>16&31,l>>11&31,l>>5&63,(31&l)<<1))}},r.exports=o},{"../utils":32}],19:[function(n,r,i){var a=n("./Uint8ArrayReader");function o(l){a.call(this,l)}n("../utils").inherits(o,a),o.prototype.readData=function(l){this.checkOffset(l);var c=this.data.slice(this.zero+this.index,this.zero+this.index+l);return this.index+=l,c},r.exports=o},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(n,r,i){var a=n("./DataReader");function o(l){a.call(this,l)}n("../utils").inherits(o,a),o.prototype.byteAt=function(l){return this.data.charCodeAt(this.zero+l)},o.prototype.lastIndexOfSignature=function(l){return this.data.lastIndexOf(l)-this.zero},o.prototype.readAndCheckSignature=function(l){return l===this.readData(4)},o.prototype.readData=function(l){this.checkOffset(l);var c=this.data.slice(this.zero+this.index,this.zero+this.index+l);return this.index+=l,c},r.exports=o},{"../utils":32,"./DataReader":18}],21:[function(n,r,i){var a=n("./ArrayReader");function o(l){a.call(this,l)}n("../utils").inherits(o,a),o.prototype.readData=function(l){if(this.checkOffset(l),l===0)return new Uint8Array(0);var c=this.data.subarray(this.zero+this.index,this.zero+this.index+l);return this.index+=l,c},r.exports=o},{"../utils":32,"./ArrayReader":17}],22:[function(n,r,i){var a=n("../utils"),o=n("../support"),l=n("./ArrayReader"),c=n("./StringReader"),u=n("./NodeBufferReader"),d=n("./Uint8ArrayReader");r.exports=function(f){var p=a.getTypeOf(f);return a.checkSupport(p),p!=="string"||o.uint8array?p==="nodebuffer"?new u(f):o.uint8array?new d(a.transformTo("uint8array",f)):new l(a.transformTo("array",f)):new c(f)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(n,r,i){i.LOCAL_FILE_HEADER="PK",i.CENTRAL_FILE_HEADER="PK",i.CENTRAL_DIRECTORY_END="PK",i.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",i.ZIP64_CENTRAL_DIRECTORY_END="PK",i.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(n,r,i){var a=n("./GenericWorker"),o=n("../utils");function l(c){a.call(this,"ConvertWorker to "+c),this.destType=c}o.inherits(l,a),l.prototype.processChunk=function(c){this.push({data:o.transformTo(this.destType,c.data),meta:c.meta})},r.exports=l},{"../utils":32,"./GenericWorker":28}],25:[function(n,r,i){var a=n("./GenericWorker"),o=n("../crc32");function l(){a.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}n("../utils").inherits(l,a),l.prototype.processChunk=function(c){this.streamInfo.crc32=o(c.data,this.streamInfo.crc32||0),this.push(c)},r.exports=l},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(n,r,i){var a=n("../utils"),o=n("./GenericWorker");function l(c){o.call(this,"DataLengthProbe for "+c),this.propName=c,this.withStreamInfo(c,0)}a.inherits(l,o),l.prototype.processChunk=function(c){if(c){var u=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=u+c.data.length}o.prototype.processChunk.call(this,c)},r.exports=l},{"../utils":32,"./GenericWorker":28}],27:[function(n,r,i){var a=n("../utils"),o=n("./GenericWorker");function l(c){o.call(this,"DataWorker");var u=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,c.then(function(d){u.dataIsReady=!0,u.data=d,u.max=d&&d.length||0,u.type=a.getTypeOf(d),u.isPaused||u._tickAndRepeat()},function(d){u.error(d)})}a.inherits(l,o),l.prototype.cleanUp=function(){o.prototype.cleanUp.call(this),this.data=null},l.prototype.resume=function(){return!!o.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,a.delay(this._tickAndRepeat,[],this)),!0)},l.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(a.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},l.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var c=null,u=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":c=this.data.substring(this.index,u);break;case"uint8array":c=this.data.subarray(this.index,u);break;case"array":case"nodebuffer":c=this.data.slice(this.index,u)}return this.index=u,this.push({data:c,meta:{percent:this.max?this.index/this.max*100:0}})},r.exports=l},{"../utils":32,"./GenericWorker":28}],28:[function(n,r,i){function a(o){this.name=o||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}a.prototype={push:function(o){this.emit("data",o)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(o){this.emit("error",o)}return!0},error:function(o){return!this.isFinished&&(this.isPaused?this.generatedError=o:(this.isFinished=!0,this.emit("error",o),this.previous&&this.previous.error(o),this.cleanUp()),!0)},on:function(o,l){return this._listeners[o].push(l),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(o,l){if(this._listeners[o])for(var c=0;c<this._listeners[o].length;c++)this._listeners[o][c].call(this,l)},pipe:function(o){return o.registerPrevious(this)},registerPrevious:function(o){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=o.streamInfo,this.mergeStreamInfo(),this.previous=o;var l=this;return o.on("data",function(c){l.processChunk(c)}),o.on("end",function(){l.end()}),o.on("error",function(c){l.error(c)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var o=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),o=!0),this.previous&&this.previous.resume(),!o},flush:function(){},processChunk:function(o){this.push(o)},withStreamInfo:function(o,l){return this.extraStreamInfo[o]=l,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var o in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,o)&&(this.streamInfo[o]=this.extraStreamInfo[o])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var o="Worker "+this.name;return this.previous?this.previous+" -> "+o:o}},r.exports=a},{}],29:[function(n,r,i){var a=n("../utils"),o=n("./ConvertWorker"),l=n("./GenericWorker"),c=n("../base64"),u=n("../support"),d=n("../external"),f=null;if(u.nodestream)try{f=n("../nodejs/NodejsStreamOutputAdapter")}catch{}function p(x,b){return new d.Promise(function(y,v){var S=[],N=x._internalType,T=x._outputType,k=x._mimeType;x.on("data",function(C,E){S.push(C),b&&b(E)}).on("error",function(C){S=[],v(C)}).on("end",function(){try{var C=(function(E,D,A){switch(E){case"blob":return a.newBlob(a.transformTo("arraybuffer",D),A);case"base64":return c.encode(D);default:return a.transformTo(E,D)}})(T,(function(E,D){var A,R=0,U=null,F=0;for(A=0;A<D.length;A++)F+=D[A].length;switch(E){case"string":return D.join("");case"array":return Array.prototype.concat.apply([],D);case"uint8array":for(U=new Uint8Array(F),A=0;A<D.length;A++)U.set(D[A],R),R+=D[A].length;return U;case"nodebuffer":return Buffer.concat(D);default:throw new Error("concat : unsupported type '"+E+"'")}})(N,S),k);y(C)}catch(E){v(E)}S=[]}).resume()})}function m(x,b,y){var v=b;switch(b){case"blob":case"arraybuffer":v="uint8array";break;case"base64":v="string"}try{this._internalType=v,this._outputType=b,this._mimeType=y,a.checkSupport(v),this._worker=x.pipe(new o(v)),x.lock()}catch(S){this._worker=new l("error"),this._worker.error(S)}}m.prototype={accumulate:function(x){return p(this,x)},on:function(x,b){var y=this;return x==="data"?this._worker.on(x,function(v){b.call(y,v.data,v.meta)}):this._worker.on(x,function(){a.delay(b,arguments,y)}),this},resume:function(){return a.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(x){if(a.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new f(this,{objectMode:this._outputType!=="nodebuffer"},x)}},r.exports=m},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(n,r,i){if(i.base64=!0,i.array=!0,i.string=!0,i.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",i.nodebuffer=typeof Buffer<"u",i.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")i.blob=!1;else{var a=new ArrayBuffer(0);try{i.blob=new Blob([a],{type:"application/zip"}).size===0}catch{try{var o=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);o.append(a),i.blob=o.getBlob("application/zip").size===0}catch{i.blob=!1}}}try{i.nodestream=!!n("readable-stream").Readable}catch{i.nodestream=!1}},{"readable-stream":16}],31:[function(n,r,i){for(var a=n("./utils"),o=n("./support"),l=n("./nodejsUtils"),c=n("./stream/GenericWorker"),u=new Array(256),d=0;d<256;d++)u[d]=252<=d?6:248<=d?5:240<=d?4:224<=d?3:192<=d?2:1;u[254]=u[254]=1;function f(){c.call(this,"utf-8 decode"),this.leftOver=null}function p(){c.call(this,"utf-8 encode")}i.utf8encode=function(m){return o.nodebuffer?l.newBufferFrom(m,"utf-8"):(function(x){var b,y,v,S,N,T=x.length,k=0;for(S=0;S<T;S++)(64512&(y=x.charCodeAt(S)))==55296&&S+1<T&&(64512&(v=x.charCodeAt(S+1)))==56320&&(y=65536+(y-55296<<10)+(v-56320),S++),k+=y<128?1:y<2048?2:y<65536?3:4;for(b=o.uint8array?new Uint8Array(k):new Array(k),S=N=0;N<k;S++)(64512&(y=x.charCodeAt(S)))==55296&&S+1<T&&(64512&(v=x.charCodeAt(S+1)))==56320&&(y=65536+(y-55296<<10)+(v-56320),S++),y<128?b[N++]=y:(y<2048?b[N++]=192|y>>>6:(y<65536?b[N++]=224|y>>>12:(b[N++]=240|y>>>18,b[N++]=128|y>>>12&63),b[N++]=128|y>>>6&63),b[N++]=128|63&y);return b})(m)},i.utf8decode=function(m){return o.nodebuffer?a.transformTo("nodebuffer",m).toString("utf-8"):(function(x){var b,y,v,S,N=x.length,T=new Array(2*N);for(b=y=0;b<N;)if((v=x[b++])<128)T[y++]=v;else if(4<(S=u[v]))T[y++]=65533,b+=S-1;else{for(v&=S===2?31:S===3?15:7;1<S&&b<N;)v=v<<6|63&x[b++],S--;1<S?T[y++]=65533:v<65536?T[y++]=v:(v-=65536,T[y++]=55296|v>>10&1023,T[y++]=56320|1023&v)}return T.length!==y&&(T.subarray?T=T.subarray(0,y):T.length=y),a.applyFromCharCode(T)})(m=a.transformTo(o.uint8array?"uint8array":"array",m))},a.inherits(f,c),f.prototype.processChunk=function(m){var x=a.transformTo(o.uint8array?"uint8array":"array",m.data);if(this.leftOver&&this.leftOver.length){if(o.uint8array){var b=x;(x=new Uint8Array(b.length+this.leftOver.length)).set(this.leftOver,0),x.set(b,this.leftOver.length)}else x=this.leftOver.concat(x);this.leftOver=null}var y=(function(S,N){var T;for((N=N||S.length)>S.length&&(N=S.length),T=N-1;0<=T&&(192&S[T])==128;)T--;return T<0||T===0?N:T+u[S[T]]>N?T:N})(x),v=x;y!==x.length&&(o.uint8array?(v=x.subarray(0,y),this.leftOver=x.subarray(y,x.length)):(v=x.slice(0,y),this.leftOver=x.slice(y,x.length))),this.push({data:i.utf8decode(v),meta:m.meta})},f.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:i.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},i.Utf8DecodeWorker=f,a.inherits(p,c),p.prototype.processChunk=function(m){this.push({data:i.utf8encode(m.data),meta:m.meta})},i.Utf8EncodeWorker=p},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(n,r,i){var a=n("./support"),o=n("./base64"),l=n("./nodejsUtils"),c=n("./external");function u(b){return b}function d(b,y){for(var v=0;v<b.length;++v)y[v]=255&b.charCodeAt(v);return y}n("setimmediate"),i.newBlob=function(b,y){i.checkSupport("blob");try{return new Blob([b],{type:y})}catch{try{var v=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return v.append(b),v.getBlob(y)}catch{throw new Error("Bug : can't construct the Blob.")}}};var f={stringifyByChunk:function(b,y,v){var S=[],N=0,T=b.length;if(T<=v)return String.fromCharCode.apply(null,b);for(;N<T;)y==="array"||y==="nodebuffer"?S.push(String.fromCharCode.apply(null,b.slice(N,Math.min(N+v,T)))):S.push(String.fromCharCode.apply(null,b.subarray(N,Math.min(N+v,T)))),N+=v;return S.join("")},stringifyByChar:function(b){for(var y="",v=0;v<b.length;v++)y+=String.fromCharCode(b[v]);return y},applyCanBeUsed:{uint8array:(function(){try{return a.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}})(),nodebuffer:(function(){try{return a.nodebuffer&&String.fromCharCode.apply(null,l.allocBuffer(1)).length===1}catch{return!1}})()}};function p(b){var y=65536,v=i.getTypeOf(b),S=!0;if(v==="uint8array"?S=f.applyCanBeUsed.uint8array:v==="nodebuffer"&&(S=f.applyCanBeUsed.nodebuffer),S)for(;1<y;)try{return f.stringifyByChunk(b,v,y)}catch{y=Math.floor(y/2)}return f.stringifyByChar(b)}function m(b,y){for(var v=0;v<b.length;v++)y[v]=b[v];return y}i.applyFromCharCode=p;var x={};x.string={string:u,array:function(b){return d(b,new Array(b.length))},arraybuffer:function(b){return x.string.uint8array(b).buffer},uint8array:function(b){return d(b,new Uint8Array(b.length))},nodebuffer:function(b){return d(b,l.allocBuffer(b.length))}},x.array={string:p,array:u,arraybuffer:function(b){return new Uint8Array(b).buffer},uint8array:function(b){return new Uint8Array(b)},nodebuffer:function(b){return l.newBufferFrom(b)}},x.arraybuffer={string:function(b){return p(new Uint8Array(b))},array:function(b){return m(new Uint8Array(b),new Array(b.byteLength))},arraybuffer:u,uint8array:function(b){return new Uint8Array(b)},nodebuffer:function(b){return l.newBufferFrom(new Uint8Array(b))}},x.uint8array={string:p,array:function(b){return m(b,new Array(b.length))},arraybuffer:function(b){return b.buffer},uint8array:u,nodebuffer:function(b){return l.newBufferFrom(b)}},x.nodebuffer={string:p,array:function(b){return m(b,new Array(b.length))},arraybuffer:function(b){return x.nodebuffer.uint8array(b).buffer},uint8array:function(b){return m(b,new Uint8Array(b.length))},nodebuffer:u},i.transformTo=function(b,y){if(y=y||"",!b)return y;i.checkSupport(b);var v=i.getTypeOf(y);return x[v][b](y)},i.resolve=function(b){for(var y=b.split("/"),v=[],S=0;S<y.length;S++){var N=y[S];N==="."||N===""&&S!==0&&S!==y.length-1||(N===".."?v.pop():v.push(N))}return v.join("/")},i.getTypeOf=function(b){return typeof b=="string"?"string":Object.prototype.toString.call(b)==="[object Array]"?"array":a.nodebuffer&&l.isBuffer(b)?"nodebuffer":a.uint8array&&b instanceof Uint8Array?"uint8array":a.arraybuffer&&b instanceof ArrayBuffer?"arraybuffer":void 0},i.checkSupport=function(b){if(!a[b.toLowerCase()])throw new Error(b+" is not supported by this platform")},i.MAX_VALUE_16BITS=65535,i.MAX_VALUE_32BITS=-1,i.pretty=function(b){var y,v,S="";for(v=0;v<(b||"").length;v++)S+="\\x"+((y=b.charCodeAt(v))<16?"0":"")+y.toString(16).toUpperCase();return S},i.delay=function(b,y,v){setImmediate(function(){b.apply(v||null,y||[])})},i.inherits=function(b,y){function v(){}v.prototype=y.prototype,b.prototype=new v},i.extend=function(){var b,y,v={};for(b=0;b<arguments.length;b++)for(y in arguments[b])Object.prototype.hasOwnProperty.call(arguments[b],y)&&v[y]===void 0&&(v[y]=arguments[b][y]);return v},i.prepareContent=function(b,y,v,S,N){return c.Promise.resolve(y).then(function(T){return a.blob&&(T instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(T))!==-1)&&typeof FileReader<"u"?new c.Promise(function(k,C){var E=new FileReader;E.onload=function(D){k(D.target.result)},E.onerror=function(D){C(D.target.error)},E.readAsArrayBuffer(T)}):T}).then(function(T){var k=i.getTypeOf(T);return k?(k==="arraybuffer"?T=i.transformTo("uint8array",T):k==="string"&&(N?T=o.decode(T):v&&S!==!0&&(T=(function(C){return d(C,a.uint8array?new Uint8Array(C.length):new Array(C.length))})(T))),T):c.Promise.reject(new Error("Can't read the data of '"+b+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(n,r,i){var a=n("./reader/readerFor"),o=n("./utils"),l=n("./signature"),c=n("./zipEntry"),u=n("./support");function d(f){this.files=[],this.loadOptions=f}d.prototype={checkSignature:function(f){if(!this.reader.readAndCheckSignature(f)){this.reader.index-=4;var p=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+o.pretty(p)+", expected "+o.pretty(f)+")")}},isSignature:function(f,p){var m=this.reader.index;this.reader.setIndex(f);var x=this.reader.readString(4)===p;return this.reader.setIndex(m),x},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var f=this.reader.readData(this.zipCommentLength),p=u.uint8array?"uint8array":"array",m=o.transformTo(p,f);this.zipComment=this.loadOptions.decodeFileName(m)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var f,p,m,x=this.zip64EndOfCentralSize-44;0<x;)f=this.reader.readInt(2),p=this.reader.readInt(4),m=this.reader.readData(p),this.zip64ExtensibleData[f]={id:f,length:p,value:m}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var f,p;for(f=0;f<this.files.length;f++)p=this.files[f],this.reader.setIndex(p.localHeaderOffset),this.checkSignature(l.LOCAL_FILE_HEADER),p.readLocalPart(this.reader),p.handleUTF8(),p.processAttributes()},readCentralDir:function(){var f;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(l.CENTRAL_FILE_HEADER);)(f=new c({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(f);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var f=this.reader.lastIndexOfSignature(l.CENTRAL_DIRECTORY_END);if(f<0)throw this.isSignature(0,l.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(f);var p=f;if(this.checkSignature(l.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===o.MAX_VALUE_16BITS||this.diskWithCentralDirStart===o.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===o.MAX_VALUE_16BITS||this.centralDirRecords===o.MAX_VALUE_16BITS||this.centralDirSize===o.MAX_VALUE_32BITS||this.centralDirOffset===o.MAX_VALUE_32BITS){if(this.zip64=!0,(f=this.reader.lastIndexOfSignature(l.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(f),this.checkSignature(l.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,l.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(l.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(l.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var m=this.centralDirOffset+this.centralDirSize;this.zip64&&(m+=20,m+=12+this.zip64EndOfCentralSize);var x=p-m;if(0<x)this.isSignature(p,l.CENTRAL_FILE_HEADER)||(this.reader.zero=x);else if(x<0)throw new Error("Corrupted zip: missing "+Math.abs(x)+" bytes.")},prepareReader:function(f){this.reader=a(f)},load:function(f){this.prepareReader(f),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},r.exports=d},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(n,r,i){var a=n("./reader/readerFor"),o=n("./utils"),l=n("./compressedObject"),c=n("./crc32"),u=n("./utf8"),d=n("./compressions"),f=n("./support");function p(m,x){this.options=m,this.loadOptions=x}p.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(m){var x,b;if(m.skip(22),this.fileNameLength=m.readInt(2),b=m.readInt(2),this.fileName=m.readData(this.fileNameLength),m.skip(b),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((x=(function(y){for(var v in d)if(Object.prototype.hasOwnProperty.call(d,v)&&d[v].magic===y)return d[v];return null})(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+o.pretty(this.compressionMethod)+" unknown (inner file : "+o.transformTo("string",this.fileName)+")");this.decompressed=new l(this.compressedSize,this.uncompressedSize,this.crc32,x,m.readData(this.compressedSize))},readCentralPart:function(m){this.versionMadeBy=m.readInt(2),m.skip(2),this.bitFlag=m.readInt(2),this.compressionMethod=m.readString(2),this.date=m.readDate(),this.crc32=m.readInt(4),this.compressedSize=m.readInt(4),this.uncompressedSize=m.readInt(4);var x=m.readInt(2);if(this.extraFieldsLength=m.readInt(2),this.fileCommentLength=m.readInt(2),this.diskNumberStart=m.readInt(2),this.internalFileAttributes=m.readInt(2),this.externalFileAttributes=m.readInt(4),this.localHeaderOffset=m.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");m.skip(x),this.readExtraFields(m),this.parseZIP64ExtraField(m),this.fileComment=m.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var m=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),m==0&&(this.dosPermissions=63&this.externalFileAttributes),m==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var m=a(this.extraFields[1].value);this.uncompressedSize===o.MAX_VALUE_32BITS&&(this.uncompressedSize=m.readInt(8)),this.compressedSize===o.MAX_VALUE_32BITS&&(this.compressedSize=m.readInt(8)),this.localHeaderOffset===o.MAX_VALUE_32BITS&&(this.localHeaderOffset=m.readInt(8)),this.diskNumberStart===o.MAX_VALUE_32BITS&&(this.diskNumberStart=m.readInt(4))}},readExtraFields:function(m){var x,b,y,v=m.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});m.index+4<v;)x=m.readInt(2),b=m.readInt(2),y=m.readData(b),this.extraFields[x]={id:x,length:b,value:y};m.setIndex(v)},handleUTF8:function(){var m=f.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=u.utf8decode(this.fileName),this.fileCommentStr=u.utf8decode(this.fileComment);else{var x=this.findExtraFieldUnicodePath();if(x!==null)this.fileNameStr=x;else{var b=o.transformTo(m,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(b)}var y=this.findExtraFieldUnicodeComment();if(y!==null)this.fileCommentStr=y;else{var v=o.transformTo(m,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(v)}}},findExtraFieldUnicodePath:function(){var m=this.extraFields[28789];if(m){var x=a(m.value);return x.readInt(1)!==1||c(this.fileName)!==x.readInt(4)?null:u.utf8decode(x.readData(m.length-5))}return null},findExtraFieldUnicodeComment:function(){var m=this.extraFields[25461];if(m){var x=a(m.value);return x.readInt(1)!==1||c(this.fileComment)!==x.readInt(4)?null:u.utf8decode(x.readData(m.length-5))}return null}},r.exports=p},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(n,r,i){function a(x,b,y){this.name=x,this.dir=y.dir,this.date=y.date,this.comment=y.comment,this.unixPermissions=y.unixPermissions,this.dosPermissions=y.dosPermissions,this._data=b,this._dataBinary=y.binary,this.options={compression:y.compression,compressionOptions:y.compressionOptions}}var o=n("./stream/StreamHelper"),l=n("./stream/DataWorker"),c=n("./utf8"),u=n("./compressedObject"),d=n("./stream/GenericWorker");a.prototype={internalStream:function(x){var b=null,y="string";try{if(!x)throw new Error("No output type specified.");var v=(y=x.toLowerCase())==="string"||y==="text";y!=="binarystring"&&y!=="text"||(y="string"),b=this._decompressWorker();var S=!this._dataBinary;S&&!v&&(b=b.pipe(new c.Utf8EncodeWorker)),!S&&v&&(b=b.pipe(new c.Utf8DecodeWorker))}catch(N){(b=new d("error")).error(N)}return new o(b,y,"")},async:function(x,b){return this.internalStream(x).accumulate(b)},nodeStream:function(x,b){return this.internalStream(x||"nodebuffer").toNodejsStream(b)},_compressWorker:function(x,b){if(this._data instanceof u&&this._data.compression.magic===x.magic)return this._data.getCompressedWorker();var y=this._decompressWorker();return this._dataBinary||(y=y.pipe(new c.Utf8EncodeWorker)),u.createWorkerFrom(y,x,b)},_decompressWorker:function(){return this._data instanceof u?this._data.getContentWorker():this._data instanceof d?this._data:new l(this._data)}};for(var f=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],p=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},m=0;m<f.length;m++)a.prototype[f[m]]=p;r.exports=a},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(n,r,i){(function(a){var o,l,c=a.MutationObserver||a.WebKitMutationObserver;if(c){var u=0,d=new c(x),f=a.document.createTextNode("");d.observe(f,{characterData:!0}),o=function(){f.data=u=++u%2}}else if(a.setImmediate||a.MessageChannel===void 0)o="document"in a&&"onreadystatechange"in a.document.createElement("script")?function(){var b=a.document.createElement("script");b.onreadystatechange=function(){x(),b.onreadystatechange=null,b.parentNode.removeChild(b),b=null},a.document.documentElement.appendChild(b)}:function(){setTimeout(x,0)};else{var p=new a.MessageChannel;p.port1.onmessage=x,o=function(){p.port2.postMessage(0)}}var m=[];function x(){var b,y;l=!0;for(var v=m.length;v;){for(y=m,m=[],b=-1;++b<v;)y[b]();v=m.length}l=!1}r.exports=function(b){m.push(b)!==1||l||o()}}).call(this,typeof Aw<"u"?Aw:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(n,r,i){var a=n("immediate");function o(){}var l={},c=["REJECTED"],u=["FULFILLED"],d=["PENDING"];function f(v){if(typeof v!="function")throw new TypeError("resolver must be a function");this.state=d,this.queue=[],this.outcome=void 0,v!==o&&b(this,v)}function p(v,S,N){this.promise=v,typeof S=="function"&&(this.onFulfilled=S,this.callFulfilled=this.otherCallFulfilled),typeof N=="function"&&(this.onRejected=N,this.callRejected=this.otherCallRejected)}function m(v,S,N){a(function(){var T;try{T=S(N)}catch(k){return l.reject(v,k)}T===v?l.reject(v,new TypeError("Cannot resolve promise with itself")):l.resolve(v,T)})}function x(v){var S=v&&v.then;if(v&&(typeof v=="object"||typeof v=="function")&&typeof S=="function")return function(){S.apply(v,arguments)}}function b(v,S){var N=!1;function T(E){N||(N=!0,l.reject(v,E))}function k(E){N||(N=!0,l.resolve(v,E))}var C=y(function(){S(k,T)});C.status==="error"&&T(C.value)}function y(v,S){var N={};try{N.value=v(S),N.status="success"}catch(T){N.status="error",N.value=T}return N}(r.exports=f).prototype.finally=function(v){if(typeof v!="function")return this;var S=this.constructor;return this.then(function(N){return S.resolve(v()).then(function(){return N})},function(N){return S.resolve(v()).then(function(){throw N})})},f.prototype.catch=function(v){return this.then(null,v)},f.prototype.then=function(v,S){if(typeof v!="function"&&this.state===u||typeof S!="function"&&this.state===c)return this;var N=new this.constructor(o);return this.state!==d?m(N,this.state===u?v:S,this.outcome):this.queue.push(new p(N,v,S)),N},p.prototype.callFulfilled=function(v){l.resolve(this.promise,v)},p.prototype.otherCallFulfilled=function(v){m(this.promise,this.onFulfilled,v)},p.prototype.callRejected=function(v){l.reject(this.promise,v)},p.prototype.otherCallRejected=function(v){m(this.promise,this.onRejected,v)},l.resolve=function(v,S){var N=y(x,S);if(N.status==="error")return l.reject(v,N.value);var T=N.value;if(T)b(v,T);else{v.state=u,v.outcome=S;for(var k=-1,C=v.queue.length;++k<C;)v.queue[k].callFulfilled(S)}return v},l.reject=function(v,S){v.state=c,v.outcome=S;for(var N=-1,T=v.queue.length;++N<T;)v.queue[N].callRejected(S);return v},f.resolve=function(v){return v instanceof this?v:l.resolve(new this(o),v)},f.reject=function(v){var S=new this(o);return l.reject(S,v)},f.all=function(v){var S=this;if(Object.prototype.toString.call(v)!=="[object Array]")return this.reject(new TypeError("must be an array"));var N=v.length,T=!1;if(!N)return this.resolve([]);for(var k=new Array(N),C=0,E=-1,D=new this(o);++E<N;)A(v[E],E);return D;function A(R,U){S.resolve(R).then(function(F){k[U]=F,++C!==N||T||(T=!0,l.resolve(D,k))},function(F){T||(T=!0,l.reject(D,F))})}},f.race=function(v){var S=this;if(Object.prototype.toString.call(v)!=="[object Array]")return this.reject(new TypeError("must be an array"));var N=v.length,T=!1;if(!N)return this.resolve([]);for(var k=-1,C=new this(o);++k<N;)E=v[k],S.resolve(E).then(function(D){T||(T=!0,l.resolve(C,D))},function(D){T||(T=!0,l.reject(C,D))});var E;return C}},{immediate:36}],38:[function(n,r,i){var a={};(0,n("./lib/utils/common").assign)(a,n("./lib/deflate"),n("./lib/inflate"),n("./lib/zlib/constants")),r.exports=a},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(n,r,i){var a=n("./zlib/deflate"),o=n("./utils/common"),l=n("./utils/strings"),c=n("./zlib/messages"),u=n("./zlib/zstream"),d=Object.prototype.toString,f=0,p=-1,m=0,x=8;function b(v){if(!(this instanceof b))return new b(v);this.options=o.assign({level:p,method:x,chunkSize:16384,windowBits:15,memLevel:8,strategy:m,to:""},v||{});var S=this.options;S.raw&&0<S.windowBits?S.windowBits=-S.windowBits:S.gzip&&0<S.windowBits&&S.windowBits<16&&(S.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new u,this.strm.avail_out=0;var N=a.deflateInit2(this.strm,S.level,S.method,S.windowBits,S.memLevel,S.strategy);if(N!==f)throw new Error(c[N]);if(S.header&&a.deflateSetHeader(this.strm,S.header),S.dictionary){var T;if(T=typeof S.dictionary=="string"?l.string2buf(S.dictionary):d.call(S.dictionary)==="[object ArrayBuffer]"?new Uint8Array(S.dictionary):S.dictionary,(N=a.deflateSetDictionary(this.strm,T))!==f)throw new Error(c[N]);this._dict_set=!0}}function y(v,S){var N=new b(S);if(N.push(v,!0),N.err)throw N.msg||c[N.err];return N.result}b.prototype.push=function(v,S){var N,T,k=this.strm,C=this.options.chunkSize;if(this.ended)return!1;T=S===~~S?S:S===!0?4:0,typeof v=="string"?k.input=l.string2buf(v):d.call(v)==="[object ArrayBuffer]"?k.input=new Uint8Array(v):k.input=v,k.next_in=0,k.avail_in=k.input.length;do{if(k.avail_out===0&&(k.output=new o.Buf8(C),k.next_out=0,k.avail_out=C),(N=a.deflate(k,T))!==1&&N!==f)return this.onEnd(N),!(this.ended=!0);k.avail_out!==0&&(k.avail_in!==0||T!==4&&T!==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 T===4?(N=a.deflateEnd(this.strm),this.onEnd(N),this.ended=!0,N===f):T!==2||(this.onEnd(f),!(k.avail_out=0))},b.prototype.onData=function(v){this.chunks.push(v)},b.prototype.onEnd=function(v){v===f&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=o.flattenChunks(this.chunks)),this.chunks=[],this.err=v,this.msg=this.strm.msg},i.Deflate=b,i.deflate=y,i.deflateRaw=function(v,S){return(S=S||{}).raw=!0,y(v,S)},i.gzip=function(v,S){return(S=S||{}).gzip=!0,y(v,S)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(n,r,i){var a=n("./zlib/inflate"),o=n("./utils/common"),l=n("./utils/strings"),c=n("./zlib/constants"),u=n("./zlib/messages"),d=n("./zlib/zstream"),f=n("./zlib/gzheader"),p=Object.prototype.toString;function m(b){if(!(this instanceof m))return new m(b);this.options=o.assign({chunkSize:16384,windowBits:0,to:""},b||{});var y=this.options;y.raw&&0<=y.windowBits&&y.windowBits<16&&(y.windowBits=-y.windowBits,y.windowBits===0&&(y.windowBits=-15)),!(0<=y.windowBits&&y.windowBits<16)||b&&b.windowBits||(y.windowBits+=32),15<y.windowBits&&y.windowBits<48&&(15&y.windowBits)==0&&(y.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new d,this.strm.avail_out=0;var v=a.inflateInit2(this.strm,y.windowBits);if(v!==c.Z_OK)throw new Error(u[v]);this.header=new f,a.inflateGetHeader(this.strm,this.header)}function x(b,y){var v=new m(y);if(v.push(b,!0),v.err)throw v.msg||u[v.err];return v.result}m.prototype.push=function(b,y){var v,S,N,T,k,C,E=this.strm,D=this.options.chunkSize,A=this.options.dictionary,R=!1;if(this.ended)return!1;S=y===~~y?y:y===!0?c.Z_FINISH:c.Z_NO_FLUSH,typeof b=="string"?E.input=l.binstring2buf(b):p.call(b)==="[object ArrayBuffer]"?E.input=new Uint8Array(b):E.input=b,E.next_in=0,E.avail_in=E.input.length;do{if(E.avail_out===0&&(E.output=new o.Buf8(D),E.next_out=0,E.avail_out=D),(v=a.inflate(E,c.Z_NO_FLUSH))===c.Z_NEED_DICT&&A&&(C=typeof A=="string"?l.string2buf(A):p.call(A)==="[object ArrayBuffer]"?new Uint8Array(A):A,v=a.inflateSetDictionary(this.strm,C)),v===c.Z_BUF_ERROR&&R===!0&&(v=c.Z_OK,R=!1),v!==c.Z_STREAM_END&&v!==c.Z_OK)return this.onEnd(v),!(this.ended=!0);E.next_out&&(E.avail_out!==0&&v!==c.Z_STREAM_END&&(E.avail_in!==0||S!==c.Z_FINISH&&S!==c.Z_SYNC_FLUSH)||(this.options.to==="string"?(N=l.utf8border(E.output,E.next_out),T=E.next_out-N,k=l.buf2string(E.output,N),E.next_out=T,E.avail_out=D-T,T&&o.arraySet(E.output,E.output,N,T,0),this.onData(k)):this.onData(o.shrinkBuf(E.output,E.next_out)))),E.avail_in===0&&E.avail_out===0&&(R=!0)}while((0<E.avail_in||E.avail_out===0)&&v!==c.Z_STREAM_END);return v===c.Z_STREAM_END&&(S=c.Z_FINISH),S===c.Z_FINISH?(v=a.inflateEnd(this.strm),this.onEnd(v),this.ended=!0,v===c.Z_OK):S!==c.Z_SYNC_FLUSH||(this.onEnd(c.Z_OK),!(E.avail_out=0))},m.prototype.onData=function(b){this.chunks.push(b)},m.prototype.onEnd=function(b){b===c.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=o.flattenChunks(this.chunks)),this.chunks=[],this.err=b,this.msg=this.strm.msg},i.Inflate=m,i.inflate=x,i.inflateRaw=function(b,y){return(y=y||{}).raw=!0,x(b,y)},i.ungzip=x},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(n,r,i){var a=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";i.assign=function(c){for(var u=Array.prototype.slice.call(arguments,1);u.length;){var d=u.shift();if(d){if(typeof d!="object")throw new TypeError(d+"must be non-object");for(var f in d)d.hasOwnProperty(f)&&(c[f]=d[f])}}return c},i.shrinkBuf=function(c,u){return c.length===u?c:c.subarray?c.subarray(0,u):(c.length=u,c)};var o={arraySet:function(c,u,d,f,p){if(u.subarray&&c.subarray)c.set(u.subarray(d,d+f),p);else for(var m=0;m<f;m++)c[p+m]=u[d+m]},flattenChunks:function(c){var u,d,f,p,m,x;for(u=f=0,d=c.length;u<d;u++)f+=c[u].length;for(x=new Uint8Array(f),u=p=0,d=c.length;u<d;u++)m=c[u],x.set(m,p),p+=m.length;return x}},l={arraySet:function(c,u,d,f,p){for(var m=0;m<f;m++)c[p+m]=u[d+m]},flattenChunks:function(c){return[].concat.apply([],c)}};i.setTyped=function(c){c?(i.Buf8=Uint8Array,i.Buf16=Uint16Array,i.Buf32=Int32Array,i.assign(i,o)):(i.Buf8=Array,i.Buf16=Array,i.Buf32=Array,i.assign(i,l))},i.setTyped(a)},{}],42:[function(n,r,i){var a=n("./common"),o=!0,l=!0;try{String.fromCharCode.apply(null,[0])}catch{o=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{l=!1}for(var c=new a.Buf8(256),u=0;u<256;u++)c[u]=252<=u?6:248<=u?5:240<=u?4:224<=u?3:192<=u?2:1;function d(f,p){if(p<65537&&(f.subarray&&l||!f.subarray&&o))return String.fromCharCode.apply(null,a.shrinkBuf(f,p));for(var m="",x=0;x<p;x++)m+=String.fromCharCode(f[x]);return m}c[254]=c[254]=1,i.string2buf=function(f){var p,m,x,b,y,v=f.length,S=0;for(b=0;b<v;b++)(64512&(m=f.charCodeAt(b)))==55296&&b+1<v&&(64512&(x=f.charCodeAt(b+1)))==56320&&(m=65536+(m-55296<<10)+(x-56320),b++),S+=m<128?1:m<2048?2:m<65536?3:4;for(p=new a.Buf8(S),b=y=0;y<S;b++)(64512&(m=f.charCodeAt(b)))==55296&&b+1<v&&(64512&(x=f.charCodeAt(b+1)))==56320&&(m=65536+(m-55296<<10)+(x-56320),b++),m<128?p[y++]=m:(m<2048?p[y++]=192|m>>>6:(m<65536?p[y++]=224|m>>>12:(p[y++]=240|m>>>18,p[y++]=128|m>>>12&63),p[y++]=128|m>>>6&63),p[y++]=128|63&m);return p},i.buf2binstring=function(f){return d(f,f.length)},i.binstring2buf=function(f){for(var p=new a.Buf8(f.length),m=0,x=p.length;m<x;m++)p[m]=f.charCodeAt(m);return p},i.buf2string=function(f,p){var m,x,b,y,v=p||f.length,S=new Array(2*v);for(m=x=0;m<v;)if((b=f[m++])<128)S[x++]=b;else if(4<(y=c[b]))S[x++]=65533,m+=y-1;else{for(b&=y===2?31:y===3?15:7;1<y&&m<v;)b=b<<6|63&f[m++],y--;1<y?S[x++]=65533:b<65536?S[x++]=b:(b-=65536,S[x++]=55296|b>>10&1023,S[x++]=56320|1023&b)}return d(S,x)},i.utf8border=function(f,p){var m;for((p=p||f.length)>f.length&&(p=f.length),m=p-1;0<=m&&(192&f[m])==128;)m--;return m<0||m===0?p:m+c[f[m]]>p?m:p}},{"./common":41}],43:[function(n,r,i){r.exports=function(a,o,l,c){for(var u=65535&a|0,d=a>>>16&65535|0,f=0;l!==0;){for(l-=f=2e3<l?2e3:l;d=d+(u=u+o[c++]|0)|0,--f;);u%=65521,d%=65521}return u|d<<16|0}},{}],44:[function(n,r,i){r.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(n,r,i){var a=(function(){for(var o,l=[],c=0;c<256;c++){o=c;for(var u=0;u<8;u++)o=1&o?3988292384^o>>>1:o>>>1;l[c]=o}return l})();r.exports=function(o,l,c,u){var d=a,f=u+c;o^=-1;for(var p=u;p<f;p++)o=o>>>8^d[255&(o^l[p])];return-1^o}},{}],46:[function(n,r,i){var a,o=n("../utils/common"),l=n("./trees"),c=n("./adler32"),u=n("./crc32"),d=n("./messages"),f=0,p=4,m=0,x=-2,b=-1,y=4,v=2,S=8,N=9,T=286,k=30,C=19,E=2*T+1,D=15,A=3,R=258,U=R+A+1,F=42,$=113,j=1,H=2,K=3,V=4;function Q(G,Y){return G.msg=d[Y],Y}function Z(G){return(G<<1)-(4<G?9:0)}function ae(G){for(var Y=G.length;0<=--Y;)G[Y]=0}function B(G){var Y=G.state,ce=Y.pending;ce>G.avail_out&&(ce=G.avail_out),ce!==0&&(o.arraySet(G.output,Y.pending_buf,Y.pending_out,ce,G.next_out),G.next_out+=ce,Y.pending_out+=ce,G.total_out+=ce,G.avail_out-=ce,Y.pending-=ce,Y.pending===0&&(Y.pending_out=0))}function X(G,Y){l._tr_flush_block(G,0<=G.block_start?G.block_start:-1,G.strstart-G.block_start,Y),G.block_start=G.strstart,B(G.strm)}function ne(G,Y){G.pending_buf[G.pending++]=Y}function se(G,Y){G.pending_buf[G.pending++]=Y>>>8&255,G.pending_buf[G.pending++]=255&Y}function be(G,Y){var ce,q,te=G.max_chain_length,I=G.strstart,fe=G.prev_length,me=G.nice_match,Ee=G.strstart>G.w_size-U?G.strstart-(G.w_size-U):0,z=G.window,O=G.w_mask,ee=G.prev,le=G.strstart+R,_e=z[I+fe-1],we=z[I+fe];G.prev_length>=G.good_match&&(te>>=2),me>G.lookahead&&(me=G.lookahead);do if(z[(ce=Y)+fe]===we&&z[ce+fe-1]===_e&&z[ce]===z[I]&&z[++ce]===z[I+1]){I+=2,ce++;do;while(z[++I]===z[++ce]&&z[++I]===z[++ce]&&z[++I]===z[++ce]&&z[++I]===z[++ce]&&z[++I]===z[++ce]&&z[++I]===z[++ce]&&z[++I]===z[++ce]&&z[++I]===z[++ce]&&I<le);if(q=R-(le-I),I=le-R,fe<q){if(G.match_start=Y,me<=(fe=q))break;_e=z[I+fe-1],we=z[I+fe]}}while((Y=ee[Y&O])>Ee&&--te!=0);return fe<=G.lookahead?fe:G.lookahead}function xe(G){var Y,ce,q,te,I,fe,me,Ee,z,O,ee=G.w_size;do{if(te=G.window_size-G.lookahead-G.strstart,G.strstart>=ee+(ee-U)){for(o.arraySet(G.window,G.window,ee,ee,0),G.match_start-=ee,G.strstart-=ee,G.block_start-=ee,Y=ce=G.hash_size;q=G.head[--Y],G.head[Y]=ee<=q?q-ee:0,--ce;);for(Y=ce=ee;q=G.prev[--Y],G.prev[Y]=ee<=q?q-ee:0,--ce;);te+=ee}if(G.strm.avail_in===0)break;if(fe=G.strm,me=G.window,Ee=G.strstart+G.lookahead,z=te,O=void 0,O=fe.avail_in,z<O&&(O=z),ce=O===0?0:(fe.avail_in-=O,o.arraySet(me,fe.input,fe.next_in,O,Ee),fe.state.wrap===1?fe.adler=c(fe.adler,me,O,Ee):fe.state.wrap===2&&(fe.adler=u(fe.adler,me,O,Ee)),fe.next_in+=O,fe.total_in+=O,O),G.lookahead+=ce,G.lookahead+G.insert>=A)for(I=G.strstart-G.insert,G.ins_h=G.window[I],G.ins_h=(G.ins_h<<G.hash_shift^G.window[I+1])&G.hash_mask;G.insert&&(G.ins_h=(G.ins_h<<G.hash_shift^G.window[I+A-1])&G.hash_mask,G.prev[I&G.w_mask]=G.head[G.ins_h],G.head[G.ins_h]=I,I++,G.insert--,!(G.lookahead+G.insert<A)););}while(G.lookahead<U&&G.strm.avail_in!==0)}function de(G,Y){for(var ce,q;;){if(G.lookahead<U){if(xe(G),G.lookahead<U&&Y===f)return j;if(G.lookahead===0)break}if(ce=0,G.lookahead>=A&&(G.ins_h=(G.ins_h<<G.hash_shift^G.window[G.strstart+A-1])&G.hash_mask,ce=G.prev[G.strstart&G.w_mask]=G.head[G.ins_h],G.head[G.ins_h]=G.strstart),ce!==0&&G.strstart-ce<=G.w_size-U&&(G.match_length=be(G,ce)),G.match_length>=A)if(q=l._tr_tally(G,G.strstart-G.match_start,G.match_length-A),G.lookahead-=G.match_length,G.match_length<=G.max_lazy_match&&G.lookahead>=A){for(G.match_length--;G.strstart++,G.ins_h=(G.ins_h<<G.hash_shift^G.window[G.strstart+A-1])&G.hash_mask,ce=G.prev[G.strstart&G.w_mask]=G.head[G.ins_h],G.head[G.ins_h]=G.strstart,--G.match_length!=0;);G.strstart++}else G.strstart+=G.match_length,G.match_length=0,G.ins_h=G.window[G.strstart],G.ins_h=(G.ins_h<<G.hash_shift^G.window[G.strstart+1])&G.hash_mask;else q=l._tr_tally(G,0,G.window[G.strstart]),G.lookahead--,G.strstart++;if(q&&(X(G,!1),G.strm.avail_out===0))return j}return G.insert=G.strstart<A-1?G.strstart:A-1,Y===p?(X(G,!0),G.strm.avail_out===0?K:V):G.last_lit&&(X(G,!1),G.strm.avail_out===0)?j:H}function Pe(G,Y){for(var ce,q,te;;){if(G.lookahead<U){if(xe(G),G.lookahead<U&&Y===f)return j;if(G.lookahead===0)break}if(ce=0,G.lookahead>=A&&(G.ins_h=(G.ins_h<<G.hash_shift^G.window[G.strstart+A-1])&G.hash_mask,ce=G.prev[G.strstart&G.w_mask]=G.head[G.ins_h],G.head[G.ins_h]=G.strstart),G.prev_length=G.match_length,G.prev_match=G.match_start,G.match_length=A-1,ce!==0&&G.prev_length<G.max_lazy_match&&G.strstart-ce<=G.w_size-U&&(G.match_length=be(G,ce),G.match_length<=5&&(G.strategy===1||G.match_length===A&&4096<G.strstart-G.match_start)&&(G.match_length=A-1)),G.prev_length>=A&&G.match_length<=G.prev_length){for(te=G.strstart+G.lookahead-A,q=l._tr_tally(G,G.strstart-1-G.prev_match,G.prev_length-A),G.lookahead-=G.prev_length-1,G.prev_length-=2;++G.strstart<=te&&(G.ins_h=(G.ins_h<<G.hash_shift^G.window[G.strstart+A-1])&G.hash_mask,ce=G.prev[G.strstart&G.w_mask]=G.head[G.ins_h],G.head[G.ins_h]=G.strstart),--G.prev_length!=0;);if(G.match_available=0,G.match_length=A-1,G.strstart++,q&&(X(G,!1),G.strm.avail_out===0))return j}else if(G.match_available){if((q=l._tr_tally(G,0,G.window[G.strstart-1]))&&X(G,!1),G.strstart++,G.lookahead--,G.strm.avail_out===0)return j}else G.match_available=1,G.strstart++,G.lookahead--}return G.match_available&&(q=l._tr_tally(G,0,G.window[G.strstart-1]),G.match_available=0),G.insert=G.strstart<A-1?G.strstart:A-1,Y===p?(X(G,!0),G.strm.avail_out===0?K:V):G.last_lit&&(X(G,!1),G.strm.avail_out===0)?j:H}function ie(G,Y,ce,q,te){this.good_length=G,this.max_lazy=Y,this.nice_length=ce,this.max_chain=q,this.func=te}function Ne(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=S,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new o.Buf16(2*E),this.dyn_dtree=new o.Buf16(2*(2*k+1)),this.bl_tree=new o.Buf16(2*(2*C+1)),ae(this.dyn_ltree),ae(this.dyn_dtree),ae(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new o.Buf16(D+1),this.heap=new o.Buf16(2*T+1),ae(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new o.Buf16(2*T+1),ae(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function Oe(G){var Y;return G&&G.state?(G.total_in=G.total_out=0,G.data_type=v,(Y=G.state).pending=0,Y.pending_out=0,Y.wrap<0&&(Y.wrap=-Y.wrap),Y.status=Y.wrap?F:$,G.adler=Y.wrap===2?0:1,Y.last_flush=f,l._tr_init(Y),m):Q(G,x)}function ge(G){var Y=Oe(G);return Y===m&&(function(ce){ce.window_size=2*ce.w_size,ae(ce.head),ce.max_lazy_match=a[ce.level].max_lazy,ce.good_match=a[ce.level].good_length,ce.nice_match=a[ce.level].nice_length,ce.max_chain_length=a[ce.level].max_chain,ce.strstart=0,ce.block_start=0,ce.lookahead=0,ce.insert=0,ce.match_length=ce.prev_length=A-1,ce.match_available=0,ce.ins_h=0})(G.state),Y}function Ke(G,Y,ce,q,te,I){if(!G)return x;var fe=1;if(Y===b&&(Y=6),q<0?(fe=0,q=-q):15<q&&(fe=2,q-=16),te<1||N<te||ce!==S||q<8||15<q||Y<0||9<Y||I<0||y<I)return Q(G,x);q===8&&(q=9);var me=new Ne;return(G.state=me).strm=G,me.wrap=fe,me.gzhead=null,me.w_bits=q,me.w_size=1<<me.w_bits,me.w_mask=me.w_size-1,me.hash_bits=te+7,me.hash_size=1<<me.hash_bits,me.hash_mask=me.hash_size-1,me.hash_shift=~~((me.hash_bits+A-1)/A),me.window=new o.Buf8(2*me.w_size),me.head=new o.Buf16(me.hash_size),me.prev=new o.Buf16(me.w_size),me.lit_bufsize=1<<te+6,me.pending_buf_size=4*me.lit_bufsize,me.pending_buf=new o.Buf8(me.pending_buf_size),me.d_buf=1*me.lit_bufsize,me.l_buf=3*me.lit_bufsize,me.level=Y,me.strategy=I,me.method=ce,ge(G)}a=[new ie(0,0,0,0,function(G,Y){var ce=65535;for(ce>G.pending_buf_size-5&&(ce=G.pending_buf_size-5);;){if(G.lookahead<=1){if(xe(G),G.lookahead===0&&Y===f)return j;if(G.lookahead===0)break}G.strstart+=G.lookahead,G.lookahead=0;var q=G.block_start+ce;if((G.strstart===0||G.strstart>=q)&&(G.lookahead=G.strstart-q,G.strstart=q,X(G,!1),G.strm.avail_out===0)||G.strstart-G.block_start>=G.w_size-U&&(X(G,!1),G.strm.avail_out===0))return j}return G.insert=0,Y===p?(X(G,!0),G.strm.avail_out===0?K:V):(G.strstart>G.block_start&&(X(G,!1),G.strm.avail_out),j)}),new ie(4,4,8,4,de),new ie(4,5,16,8,de),new ie(4,6,32,32,de),new ie(4,4,16,16,Pe),new ie(8,16,32,32,Pe),new ie(8,16,128,128,Pe),new ie(8,32,128,256,Pe),new ie(32,128,258,1024,Pe),new ie(32,258,258,4096,Pe)],i.deflateInit=function(G,Y){return Ke(G,Y,S,15,8,0)},i.deflateInit2=Ke,i.deflateReset=ge,i.deflateResetKeep=Oe,i.deflateSetHeader=function(G,Y){return G&&G.state?G.state.wrap!==2?x:(G.state.gzhead=Y,m):x},i.deflate=function(G,Y){var ce,q,te,I;if(!G||!G.state||5<Y||Y<0)return G?Q(G,x):x;if(q=G.state,!G.output||!G.input&&G.avail_in!==0||q.status===666&&Y!==p)return Q(G,G.avail_out===0?-5:x);if(q.strm=G,ce=q.last_flush,q.last_flush=Y,q.status===F)if(q.wrap===2)G.adler=0,ne(q,31),ne(q,139),ne(q,8),q.gzhead?(ne(q,(q.gzhead.text?1:0)+(q.gzhead.hcrc?2:0)+(q.gzhead.extra?4:0)+(q.gzhead.name?8:0)+(q.gzhead.comment?16:0)),ne(q,255&q.gzhead.time),ne(q,q.gzhead.time>>8&255),ne(q,q.gzhead.time>>16&255),ne(q,q.gzhead.time>>24&255),ne(q,q.level===9?2:2<=q.strategy||q.level<2?4:0),ne(q,255&q.gzhead.os),q.gzhead.extra&&q.gzhead.extra.length&&(ne(q,255&q.gzhead.extra.length),ne(q,q.gzhead.extra.length>>8&255)),q.gzhead.hcrc&&(G.adler=u(G.adler,q.pending_buf,q.pending,0)),q.gzindex=0,q.status=69):(ne(q,0),ne(q,0),ne(q,0),ne(q,0),ne(q,0),ne(q,q.level===9?2:2<=q.strategy||q.level<2?4:0),ne(q,3),q.status=$);else{var fe=S+(q.w_bits-8<<4)<<8;fe|=(2<=q.strategy||q.level<2?0:q.level<6?1:q.level===6?2:3)<<6,q.strstart!==0&&(fe|=32),fe+=31-fe%31,q.status=$,se(q,fe),q.strstart!==0&&(se(q,G.adler>>>16),se(q,65535&G.adler)),G.adler=1}if(q.status===69)if(q.gzhead.extra){for(te=q.pending;q.gzindex<(65535&q.gzhead.extra.length)&&(q.pending!==q.pending_buf_size||(q.gzhead.hcrc&&q.pending>te&&(G.adler=u(G.adler,q.pending_buf,q.pending-te,te)),B(G),te=q.pending,q.pending!==q.pending_buf_size));)ne(q,255&q.gzhead.extra[q.gzindex]),q.gzindex++;q.gzhead.hcrc&&q.pending>te&&(G.adler=u(G.adler,q.pending_buf,q.pending-te,te)),q.gzindex===q.gzhead.extra.length&&(q.gzindex=0,q.status=73)}else q.status=73;if(q.status===73)if(q.gzhead.name){te=q.pending;do{if(q.pending===q.pending_buf_size&&(q.gzhead.hcrc&&q.pending>te&&(G.adler=u(G.adler,q.pending_buf,q.pending-te,te)),B(G),te=q.pending,q.pending===q.pending_buf_size)){I=1;break}I=q.gzindex<q.gzhead.name.length?255&q.gzhead.name.charCodeAt(q.gzindex++):0,ne(q,I)}while(I!==0);q.gzhead.hcrc&&q.pending>te&&(G.adler=u(G.adler,q.pending_buf,q.pending-te,te)),I===0&&(q.gzindex=0,q.status=91)}else q.status=91;if(q.status===91)if(q.gzhead.comment){te=q.pending;do{if(q.pending===q.pending_buf_size&&(q.gzhead.hcrc&&q.pending>te&&(G.adler=u(G.adler,q.pending_buf,q.pending-te,te)),B(G),te=q.pending,q.pending===q.pending_buf_size)){I=1;break}I=q.gzindex<q.gzhead.comment.length?255&q.gzhead.comment.charCodeAt(q.gzindex++):0,ne(q,I)}while(I!==0);q.gzhead.hcrc&&q.pending>te&&(G.adler=u(G.adler,q.pending_buf,q.pending-te,te)),I===0&&(q.status=103)}else q.status=103;if(q.status===103&&(q.gzhead.hcrc?(q.pending+2>q.pending_buf_size&&B(G),q.pending+2<=q.pending_buf_size&&(ne(q,255&G.adler),ne(q,G.adler>>8&255),G.adler=0,q.status=$)):q.status=$),q.pending!==0){if(B(G),G.avail_out===0)return q.last_flush=-1,m}else if(G.avail_in===0&&Z(Y)<=Z(ce)&&Y!==p)return Q(G,-5);if(q.status===666&&G.avail_in!==0)return Q(G,-5);if(G.avail_in!==0||q.lookahead!==0||Y!==f&&q.status!==666){var me=q.strategy===2?(function(Ee,z){for(var O;;){if(Ee.lookahead===0&&(xe(Ee),Ee.lookahead===0)){if(z===f)return j;break}if(Ee.match_length=0,O=l._tr_tally(Ee,0,Ee.window[Ee.strstart]),Ee.lookahead--,Ee.strstart++,O&&(X(Ee,!1),Ee.strm.avail_out===0))return j}return Ee.insert=0,z===p?(X(Ee,!0),Ee.strm.avail_out===0?K:V):Ee.last_lit&&(X(Ee,!1),Ee.strm.avail_out===0)?j:H})(q,Y):q.strategy===3?(function(Ee,z){for(var O,ee,le,_e,we=Ee.window;;){if(Ee.lookahead<=R){if(xe(Ee),Ee.lookahead<=R&&z===f)return j;if(Ee.lookahead===0)break}if(Ee.match_length=0,Ee.lookahead>=A&&0<Ee.strstart&&(ee=we[le=Ee.strstart-1])===we[++le]&&ee===we[++le]&&ee===we[++le]){_e=Ee.strstart+R;do;while(ee===we[++le]&&ee===we[++le]&&ee===we[++le]&&ee===we[++le]&&ee===we[++le]&&ee===we[++le]&&ee===we[++le]&&ee===we[++le]&&le<_e);Ee.match_length=R-(_e-le),Ee.match_length>Ee.lookahead&&(Ee.match_length=Ee.lookahead)}if(Ee.match_length>=A?(O=l._tr_tally(Ee,1,Ee.match_length-A),Ee.lookahead-=Ee.match_length,Ee.strstart+=Ee.match_length,Ee.match_length=0):(O=l._tr_tally(Ee,0,Ee.window[Ee.strstart]),Ee.lookahead--,Ee.strstart++),O&&(X(Ee,!1),Ee.strm.avail_out===0))return j}return Ee.insert=0,z===p?(X(Ee,!0),Ee.strm.avail_out===0?K:V):Ee.last_lit&&(X(Ee,!1),Ee.strm.avail_out===0)?j:H})(q,Y):a[q.level].func(q,Y);if(me!==K&&me!==V||(q.status=666),me===j||me===K)return G.avail_out===0&&(q.last_flush=-1),m;if(me===H&&(Y===1?l._tr_align(q):Y!==5&&(l._tr_stored_block(q,0,0,!1),Y===3&&(ae(q.head),q.lookahead===0&&(q.strstart=0,q.block_start=0,q.insert=0))),B(G),G.avail_out===0))return q.last_flush=-1,m}return Y!==p?m:q.wrap<=0?1:(q.wrap===2?(ne(q,255&G.adler),ne(q,G.adler>>8&255),ne(q,G.adler>>16&255),ne(q,G.adler>>24&255),ne(q,255&G.total_in),ne(q,G.total_in>>8&255),ne(q,G.total_in>>16&255),ne(q,G.total_in>>24&255)):(se(q,G.adler>>>16),se(q,65535&G.adler)),B(G),0<q.wrap&&(q.wrap=-q.wrap),q.pending!==0?m:1)},i.deflateEnd=function(G){var Y;return G&&G.state?(Y=G.state.status)!==F&&Y!==69&&Y!==73&&Y!==91&&Y!==103&&Y!==$&&Y!==666?Q(G,x):(G.state=null,Y===$?Q(G,-3):m):x},i.deflateSetDictionary=function(G,Y){var ce,q,te,I,fe,me,Ee,z,O=Y.length;if(!G||!G.state||(I=(ce=G.state).wrap)===2||I===1&&ce.status!==F||ce.lookahead)return x;for(I===1&&(G.adler=c(G.adler,Y,O,0)),ce.wrap=0,O>=ce.w_size&&(I===0&&(ae(ce.head),ce.strstart=0,ce.block_start=0,ce.insert=0),z=new o.Buf8(ce.w_size),o.arraySet(z,Y,O-ce.w_size,ce.w_size,0),Y=z,O=ce.w_size),fe=G.avail_in,me=G.next_in,Ee=G.input,G.avail_in=O,G.next_in=0,G.input=Y,xe(ce);ce.lookahead>=A;){for(q=ce.strstart,te=ce.lookahead-(A-1);ce.ins_h=(ce.ins_h<<ce.hash_shift^ce.window[q+A-1])&ce.hash_mask,ce.prev[q&ce.w_mask]=ce.head[ce.ins_h],ce.head[ce.ins_h]=q,q++,--te;);ce.strstart=q,ce.lookahead=A-1,xe(ce)}return ce.strstart+=ce.lookahead,ce.block_start=ce.strstart,ce.insert=ce.lookahead,ce.lookahead=0,ce.match_length=ce.prev_length=A-1,ce.match_available=0,G.next_in=me,G.input=Ee,G.avail_in=fe,ce.wrap=I,m},i.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(n,r,i){r.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(n,r,i){r.exports=function(a,o){var l,c,u,d,f,p,m,x,b,y,v,S,N,T,k,C,E,D,A,R,U,F,$,j,H;l=a.state,c=a.next_in,j=a.input,u=c+(a.avail_in-5),d=a.next_out,H=a.output,f=d-(o-a.avail_out),p=d+(a.avail_out-257),m=l.dmax,x=l.wsize,b=l.whave,y=l.wnext,v=l.window,S=l.hold,N=l.bits,T=l.lencode,k=l.distcode,C=(1<<l.lenbits)-1,E=(1<<l.distbits)-1;e:do{N<15&&(S+=j[c++]<<N,N+=8,S+=j[c++]<<N,N+=8),D=T[S&C];t:for(;;){if(S>>>=A=D>>>24,N-=A,(A=D>>>16&255)===0)H[d++]=65535&D;else{if(!(16&A)){if((64&A)==0){D=T[(65535&D)+(S&(1<<A)-1)];continue t}if(32&A){l.mode=12;break e}a.msg="invalid literal/length code",l.mode=30;break e}R=65535&D,(A&=15)&&(N<A&&(S+=j[c++]<<N,N+=8),R+=S&(1<<A)-1,S>>>=A,N-=A),N<15&&(S+=j[c++]<<N,N+=8,S+=j[c++]<<N,N+=8),D=k[S&E];n:for(;;){if(S>>>=A=D>>>24,N-=A,!(16&(A=D>>>16&255))){if((64&A)==0){D=k[(65535&D)+(S&(1<<A)-1)];continue n}a.msg="invalid distance code",l.mode=30;break e}if(U=65535&D,N<(A&=15)&&(S+=j[c++]<<N,(N+=8)<A&&(S+=j[c++]<<N,N+=8)),m<(U+=S&(1<<A)-1)){a.msg="invalid distance too far back",l.mode=30;break e}if(S>>>=A,N-=A,(A=d-f)<U){if(b<(A=U-A)&&l.sane){a.msg="invalid distance too far back",l.mode=30;break e}if($=v,(F=0)===y){if(F+=x-A,A<R){for(R-=A;H[d++]=v[F++],--A;);F=d-U,$=H}}else if(y<A){if(F+=x+y-A,(A-=y)<R){for(R-=A;H[d++]=v[F++],--A;);if(F=0,y<R){for(R-=A=y;H[d++]=v[F++],--A;);F=d-U,$=H}}}else if(F+=y-A,A<R){for(R-=A;H[d++]=v[F++],--A;);F=d-U,$=H}for(;2<R;)H[d++]=$[F++],H[d++]=$[F++],H[d++]=$[F++],R-=3;R&&(H[d++]=$[F++],1<R&&(H[d++]=$[F++]))}else{for(F=d-U;H[d++]=H[F++],H[d++]=H[F++],H[d++]=H[F++],2<(R-=3););R&&(H[d++]=H[F++],1<R&&(H[d++]=H[F++]))}break}}break}}while(c<u&&d<p);c-=R=N>>3,S&=(1<<(N-=R<<3))-1,a.next_in=c,a.next_out=d,a.avail_in=c<u?u-c+5:5-(c-u),a.avail_out=d<p?p-d+257:257-(d-p),l.hold=S,l.bits=N}},{}],49:[function(n,r,i){var a=n("../utils/common"),o=n("./adler32"),l=n("./crc32"),c=n("./inffast"),u=n("./inftrees"),d=1,f=2,p=0,m=-2,x=1,b=852,y=592;function v(F){return(F>>>24&255)+(F>>>8&65280)+((65280&F)<<8)+((255&F)<<24)}function S(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new a.Buf16(320),this.work=new a.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function N(F){var $;return F&&F.state?($=F.state,F.total_in=F.total_out=$.total=0,F.msg="",$.wrap&&(F.adler=1&$.wrap),$.mode=x,$.last=0,$.havedict=0,$.dmax=32768,$.head=null,$.hold=0,$.bits=0,$.lencode=$.lendyn=new a.Buf32(b),$.distcode=$.distdyn=new a.Buf32(y),$.sane=1,$.back=-1,p):m}function T(F){var $;return F&&F.state?(($=F.state).wsize=0,$.whave=0,$.wnext=0,N(F)):m}function k(F,$){var j,H;return F&&F.state?(H=F.state,$<0?(j=0,$=-$):(j=1+($>>4),$<48&&($&=15)),$&&($<8||15<$)?m:(H.window!==null&&H.wbits!==$&&(H.window=null),H.wrap=j,H.wbits=$,T(F))):m}function C(F,$){var j,H;return F?(H=new S,(F.state=H).window=null,(j=k(F,$))!==p&&(F.state=null),j):m}var E,D,A=!0;function R(F){if(A){var $;for(E=new a.Buf32(512),D=new a.Buf32(32),$=0;$<144;)F.lens[$++]=8;for(;$<256;)F.lens[$++]=9;for(;$<280;)F.lens[$++]=7;for(;$<288;)F.lens[$++]=8;for(u(d,F.lens,0,288,E,0,F.work,{bits:9}),$=0;$<32;)F.lens[$++]=5;u(f,F.lens,0,32,D,0,F.work,{bits:5}),A=!1}F.lencode=E,F.lenbits=9,F.distcode=D,F.distbits=5}function U(F,$,j,H){var K,V=F.state;return V.window===null&&(V.wsize=1<<V.wbits,V.wnext=0,V.whave=0,V.window=new a.Buf8(V.wsize)),H>=V.wsize?(a.arraySet(V.window,$,j-V.wsize,V.wsize,0),V.wnext=0,V.whave=V.wsize):(H<(K=V.wsize-V.wnext)&&(K=H),a.arraySet(V.window,$,j-H,K,V.wnext),(H-=K)?(a.arraySet(V.window,$,j-H,H,0),V.wnext=H,V.whave=V.wsize):(V.wnext+=K,V.wnext===V.wsize&&(V.wnext=0),V.whave<V.wsize&&(V.whave+=K))),0}i.inflateReset=T,i.inflateReset2=k,i.inflateResetKeep=N,i.inflateInit=function(F){return C(F,15)},i.inflateInit2=C,i.inflate=function(F,$){var j,H,K,V,Q,Z,ae,B,X,ne,se,be,xe,de,Pe,ie,Ne,Oe,ge,Ke,G,Y,ce,q,te=0,I=new a.Buf8(4),fe=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!F||!F.state||!F.output||!F.input&&F.avail_in!==0)return m;(j=F.state).mode===12&&(j.mode=13),Q=F.next_out,K=F.output,ae=F.avail_out,V=F.next_in,H=F.input,Z=F.avail_in,B=j.hold,X=j.bits,ne=Z,se=ae,Y=p;e:for(;;)switch(j.mode){case x:if(j.wrap===0){j.mode=13;break}for(;X<16;){if(Z===0)break e;Z--,B+=H[V++]<<X,X+=8}if(2&j.wrap&&B===35615){I[j.check=0]=255&B,I[1]=B>>>8&255,j.check=l(j.check,I,2,0),X=B=0,j.mode=2;break}if(j.flags=0,j.head&&(j.head.done=!1),!(1&j.wrap)||(((255&B)<<8)+(B>>8))%31){F.msg="incorrect header check",j.mode=30;break}if((15&B)!=8){F.msg="unknown compression method",j.mode=30;break}if(X-=4,G=8+(15&(B>>>=4)),j.wbits===0)j.wbits=G;else if(G>j.wbits){F.msg="invalid window size",j.mode=30;break}j.dmax=1<<G,F.adler=j.check=1,j.mode=512&B?10:12,X=B=0;break;case 2:for(;X<16;){if(Z===0)break e;Z--,B+=H[V++]<<X,X+=8}if(j.flags=B,(255&j.flags)!=8){F.msg="unknown compression method",j.mode=30;break}if(57344&j.flags){F.msg="unknown header flags set",j.mode=30;break}j.head&&(j.head.text=B>>8&1),512&j.flags&&(I[0]=255&B,I[1]=B>>>8&255,j.check=l(j.check,I,2,0)),X=B=0,j.mode=3;case 3:for(;X<32;){if(Z===0)break e;Z--,B+=H[V++]<<X,X+=8}j.head&&(j.head.time=B),512&j.flags&&(I[0]=255&B,I[1]=B>>>8&255,I[2]=B>>>16&255,I[3]=B>>>24&255,j.check=l(j.check,I,4,0)),X=B=0,j.mode=4;case 4:for(;X<16;){if(Z===0)break e;Z--,B+=H[V++]<<X,X+=8}j.head&&(j.head.xflags=255&B,j.head.os=B>>8),512&j.flags&&(I[0]=255&B,I[1]=B>>>8&255,j.check=l(j.check,I,2,0)),X=B=0,j.mode=5;case 5:if(1024&j.flags){for(;X<16;){if(Z===0)break e;Z--,B+=H[V++]<<X,X+=8}j.length=B,j.head&&(j.head.extra_len=B),512&j.flags&&(I[0]=255&B,I[1]=B>>>8&255,j.check=l(j.check,I,2,0)),X=B=0}else j.head&&(j.head.extra=null);j.mode=6;case 6:if(1024&j.flags&&(Z<(be=j.length)&&(be=Z),be&&(j.head&&(G=j.head.extra_len-j.length,j.head.extra||(j.head.extra=new Array(j.head.extra_len)),a.arraySet(j.head.extra,H,V,be,G)),512&j.flags&&(j.check=l(j.check,H,be,V)),Z-=be,V+=be,j.length-=be),j.length))break e;j.length=0,j.mode=7;case 7:if(2048&j.flags){if(Z===0)break e;for(be=0;G=H[V+be++],j.head&&G&&j.length<65536&&(j.head.name+=String.fromCharCode(G)),G&&be<Z;);if(512&j.flags&&(j.check=l(j.check,H,be,V)),Z-=be,V+=be,G)break e}else j.head&&(j.head.name=null);j.length=0,j.mode=8;case 8:if(4096&j.flags){if(Z===0)break e;for(be=0;G=H[V+be++],j.head&&G&&j.length<65536&&(j.head.comment+=String.fromCharCode(G)),G&&be<Z;);if(512&j.flags&&(j.check=l(j.check,H,be,V)),Z-=be,V+=be,G)break e}else j.head&&(j.head.comment=null);j.mode=9;case 9:if(512&j.flags){for(;X<16;){if(Z===0)break e;Z--,B+=H[V++]<<X,X+=8}if(B!==(65535&j.check)){F.msg="header crc mismatch",j.mode=30;break}X=B=0}j.head&&(j.head.hcrc=j.flags>>9&1,j.head.done=!0),F.adler=j.check=0,j.mode=12;break;case 10:for(;X<32;){if(Z===0)break e;Z--,B+=H[V++]<<X,X+=8}F.adler=j.check=v(B),X=B=0,j.mode=11;case 11:if(j.havedict===0)return F.next_out=Q,F.avail_out=ae,F.next_in=V,F.avail_in=Z,j.hold=B,j.bits=X,2;F.adler=j.check=1,j.mode=12;case 12:if($===5||$===6)break e;case 13:if(j.last){B>>>=7&X,X-=7&X,j.mode=27;break}for(;X<3;){if(Z===0)break e;Z--,B+=H[V++]<<X,X+=8}switch(j.last=1&B,X-=1,3&(B>>>=1)){case 0:j.mode=14;break;case 1:if(R(j),j.mode=20,$!==6)break;B>>>=2,X-=2;break e;case 2:j.mode=17;break;case 3:F.msg="invalid block type",j.mode=30}B>>>=2,X-=2;break;case 14:for(B>>>=7&X,X-=7&X;X<32;){if(Z===0)break e;Z--,B+=H[V++]<<X,X+=8}if((65535&B)!=(B>>>16^65535)){F.msg="invalid stored block lengths",j.mode=30;break}if(j.length=65535&B,X=B=0,j.mode=15,$===6)break e;case 15:j.mode=16;case 16:if(be=j.length){if(Z<be&&(be=Z),ae<be&&(be=ae),be===0)break e;a.arraySet(K,H,V,be,Q),Z-=be,V+=be,ae-=be,Q+=be,j.length-=be;break}j.mode=12;break;case 17:for(;X<14;){if(Z===0)break e;Z--,B+=H[V++]<<X,X+=8}if(j.nlen=257+(31&B),B>>>=5,X-=5,j.ndist=1+(31&B),B>>>=5,X-=5,j.ncode=4+(15&B),B>>>=4,X-=4,286<j.nlen||30<j.ndist){F.msg="too many length or distance symbols",j.mode=30;break}j.have=0,j.mode=18;case 18:for(;j.have<j.ncode;){for(;X<3;){if(Z===0)break e;Z--,B+=H[V++]<<X,X+=8}j.lens[fe[j.have++]]=7&B,B>>>=3,X-=3}for(;j.have<19;)j.lens[fe[j.have++]]=0;if(j.lencode=j.lendyn,j.lenbits=7,ce={bits:j.lenbits},Y=u(0,j.lens,0,19,j.lencode,0,j.work,ce),j.lenbits=ce.bits,Y){F.msg="invalid code lengths set",j.mode=30;break}j.have=0,j.mode=19;case 19:for(;j.have<j.nlen+j.ndist;){for(;ie=(te=j.lencode[B&(1<<j.lenbits)-1])>>>16&255,Ne=65535&te,!((Pe=te>>>24)<=X);){if(Z===0)break e;Z--,B+=H[V++]<<X,X+=8}if(Ne<16)B>>>=Pe,X-=Pe,j.lens[j.have++]=Ne;else{if(Ne===16){for(q=Pe+2;X<q;){if(Z===0)break e;Z--,B+=H[V++]<<X,X+=8}if(B>>>=Pe,X-=Pe,j.have===0){F.msg="invalid bit length repeat",j.mode=30;break}G=j.lens[j.have-1],be=3+(3&B),B>>>=2,X-=2}else if(Ne===17){for(q=Pe+3;X<q;){if(Z===0)break e;Z--,B+=H[V++]<<X,X+=8}X-=Pe,G=0,be=3+(7&(B>>>=Pe)),B>>>=3,X-=3}else{for(q=Pe+7;X<q;){if(Z===0)break e;Z--,B+=H[V++]<<X,X+=8}X-=Pe,G=0,be=11+(127&(B>>>=Pe)),B>>>=7,X-=7}if(j.have+be>j.nlen+j.ndist){F.msg="invalid bit length repeat",j.mode=30;break}for(;be--;)j.lens[j.have++]=G}}if(j.mode===30)break;if(j.lens[256]===0){F.msg="invalid code -- missing end-of-block",j.mode=30;break}if(j.lenbits=9,ce={bits:j.lenbits},Y=u(d,j.lens,0,j.nlen,j.lencode,0,j.work,ce),j.lenbits=ce.bits,Y){F.msg="invalid literal/lengths set",j.mode=30;break}if(j.distbits=6,j.distcode=j.distdyn,ce={bits:j.distbits},Y=u(f,j.lens,j.nlen,j.ndist,j.distcode,0,j.work,ce),j.distbits=ce.bits,Y){F.msg="invalid distances set",j.mode=30;break}if(j.mode=20,$===6)break e;case 20:j.mode=21;case 21:if(6<=Z&&258<=ae){F.next_out=Q,F.avail_out=ae,F.next_in=V,F.avail_in=Z,j.hold=B,j.bits=X,c(F,se),Q=F.next_out,K=F.output,ae=F.avail_out,V=F.next_in,H=F.input,Z=F.avail_in,B=j.hold,X=j.bits,j.mode===12&&(j.back=-1);break}for(j.back=0;ie=(te=j.lencode[B&(1<<j.lenbits)-1])>>>16&255,Ne=65535&te,!((Pe=te>>>24)<=X);){if(Z===0)break e;Z--,B+=H[V++]<<X,X+=8}if(ie&&(240&ie)==0){for(Oe=Pe,ge=ie,Ke=Ne;ie=(te=j.lencode[Ke+((B&(1<<Oe+ge)-1)>>Oe)])>>>16&255,Ne=65535&te,!(Oe+(Pe=te>>>24)<=X);){if(Z===0)break e;Z--,B+=H[V++]<<X,X+=8}B>>>=Oe,X-=Oe,j.back+=Oe}if(B>>>=Pe,X-=Pe,j.back+=Pe,j.length=Ne,ie===0){j.mode=26;break}if(32&ie){j.back=-1,j.mode=12;break}if(64&ie){F.msg="invalid literal/length code",j.mode=30;break}j.extra=15&ie,j.mode=22;case 22:if(j.extra){for(q=j.extra;X<q;){if(Z===0)break e;Z--,B+=H[V++]<<X,X+=8}j.length+=B&(1<<j.extra)-1,B>>>=j.extra,X-=j.extra,j.back+=j.extra}j.was=j.length,j.mode=23;case 23:for(;ie=(te=j.distcode[B&(1<<j.distbits)-1])>>>16&255,Ne=65535&te,!((Pe=te>>>24)<=X);){if(Z===0)break e;Z--,B+=H[V++]<<X,X+=8}if((240&ie)==0){for(Oe=Pe,ge=ie,Ke=Ne;ie=(te=j.distcode[Ke+((B&(1<<Oe+ge)-1)>>Oe)])>>>16&255,Ne=65535&te,!(Oe+(Pe=te>>>24)<=X);){if(Z===0)break e;Z--,B+=H[V++]<<X,X+=8}B>>>=Oe,X-=Oe,j.back+=Oe}if(B>>>=Pe,X-=Pe,j.back+=Pe,64&ie){F.msg="invalid distance code",j.mode=30;break}j.offset=Ne,j.extra=15&ie,j.mode=24;case 24:if(j.extra){for(q=j.extra;X<q;){if(Z===0)break e;Z--,B+=H[V++]<<X,X+=8}j.offset+=B&(1<<j.extra)-1,B>>>=j.extra,X-=j.extra,j.back+=j.extra}if(j.offset>j.dmax){F.msg="invalid distance too far back",j.mode=30;break}j.mode=25;case 25:if(ae===0)break e;if(be=se-ae,j.offset>be){if((be=j.offset-be)>j.whave&&j.sane){F.msg="invalid distance too far back",j.mode=30;break}xe=be>j.wnext?(be-=j.wnext,j.wsize-be):j.wnext-be,be>j.length&&(be=j.length),de=j.window}else de=K,xe=Q-j.offset,be=j.length;for(ae<be&&(be=ae),ae-=be,j.length-=be;K[Q++]=de[xe++],--be;);j.length===0&&(j.mode=21);break;case 26:if(ae===0)break e;K[Q++]=j.length,ae--,j.mode=21;break;case 27:if(j.wrap){for(;X<32;){if(Z===0)break e;Z--,B|=H[V++]<<X,X+=8}if(se-=ae,F.total_out+=se,j.total+=se,se&&(F.adler=j.check=j.flags?l(j.check,K,se,Q-se):o(j.check,K,se,Q-se)),se=ae,(j.flags?B:v(B))!==j.check){F.msg="incorrect data check",j.mode=30;break}X=B=0}j.mode=28;case 28:if(j.wrap&&j.flags){for(;X<32;){if(Z===0)break e;Z--,B+=H[V++]<<X,X+=8}if(B!==(4294967295&j.total)){F.msg="incorrect length check",j.mode=30;break}X=B=0}j.mode=29;case 29:Y=1;break e;case 30:Y=-3;break e;case 31:return-4;case 32:default:return m}return F.next_out=Q,F.avail_out=ae,F.next_in=V,F.avail_in=Z,j.hold=B,j.bits=X,(j.wsize||se!==F.avail_out&&j.mode<30&&(j.mode<27||$!==4))&&U(F,F.output,F.next_out,se-F.avail_out)?(j.mode=31,-4):(ne-=F.avail_in,se-=F.avail_out,F.total_in+=ne,F.total_out+=se,j.total+=se,j.wrap&&se&&(F.adler=j.check=j.flags?l(j.check,K,se,F.next_out-se):o(j.check,K,se,F.next_out-se)),F.data_type=j.bits+(j.last?64:0)+(j.mode===12?128:0)+(j.mode===20||j.mode===15?256:0),(ne==0&&se===0||$===4)&&Y===p&&(Y=-5),Y)},i.inflateEnd=function(F){if(!F||!F.state)return m;var $=F.state;return $.window&&($.window=null),F.state=null,p},i.inflateGetHeader=function(F,$){var j;return F&&F.state?(2&(j=F.state).wrap)==0?m:((j.head=$).done=!1,p):m},i.inflateSetDictionary=function(F,$){var j,H=$.length;return F&&F.state?(j=F.state).wrap!==0&&j.mode!==11?m:j.mode===11&&o(1,$,H,0)!==j.check?-3:U(F,$,H,H)?(j.mode=31,-4):(j.havedict=1,p):m},i.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(n,r,i){var a=n("../utils/common"),o=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],l=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],c=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],u=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];r.exports=function(d,f,p,m,x,b,y,v){var S,N,T,k,C,E,D,A,R,U=v.bits,F=0,$=0,j=0,H=0,K=0,V=0,Q=0,Z=0,ae=0,B=0,X=null,ne=0,se=new a.Buf16(16),be=new a.Buf16(16),xe=null,de=0;for(F=0;F<=15;F++)se[F]=0;for($=0;$<m;$++)se[f[p+$]]++;for(K=U,H=15;1<=H&&se[H]===0;H--);if(H<K&&(K=H),H===0)return x[b++]=20971520,x[b++]=20971520,v.bits=1,0;for(j=1;j<H&&se[j]===0;j++);for(K<j&&(K=j),F=Z=1;F<=15;F++)if(Z<<=1,(Z-=se[F])<0)return-1;if(0<Z&&(d===0||H!==1))return-1;for(be[1]=0,F=1;F<15;F++)be[F+1]=be[F]+se[F];for($=0;$<m;$++)f[p+$]!==0&&(y[be[f[p+$]]++]=$);if(E=d===0?(X=xe=y,19):d===1?(X=o,ne-=257,xe=l,de-=257,256):(X=c,xe=u,-1),F=j,C=b,Q=$=B=0,T=-1,k=(ae=1<<(V=K))-1,d===1&&852<ae||d===2&&592<ae)return 1;for(;;){for(D=F-Q,R=y[$]<E?(A=0,y[$]):y[$]>E?(A=xe[de+y[$]],X[ne+y[$]]):(A=96,0),S=1<<F-Q,j=N=1<<V;x[C+(B>>Q)+(N-=S)]=D<<24|A<<16|R|0,N!==0;);for(S=1<<F-1;B&S;)S>>=1;if(S!==0?(B&=S-1,B+=S):B=0,$++,--se[F]==0){if(F===H)break;F=f[p+y[$]]}if(K<F&&(B&k)!==T){for(Q===0&&(Q=K),C+=j,Z=1<<(V=F-Q);V+Q<H&&!((Z-=se[V+Q])<=0);)V++,Z<<=1;if(ae+=1<<V,d===1&&852<ae||d===2&&592<ae)return 1;x[T=B&k]=K<<24|V<<16|C-b|0}}return B!==0&&(x[C+B]=F-Q<<24|64<<16|0),v.bits=K,0}},{"../utils/common":41}],51:[function(n,r,i){r.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(n,r,i){var a=n("../utils/common"),o=0,l=1;function c(te){for(var I=te.length;0<=--I;)te[I]=0}var u=0,d=29,f=256,p=f+1+d,m=30,x=19,b=2*p+1,y=15,v=16,S=7,N=256,T=16,k=17,C=18,E=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],D=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],A=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],R=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],U=new Array(2*(p+2));c(U);var F=new Array(2*m);c(F);var $=new Array(512);c($);var j=new Array(256);c(j);var H=new Array(d);c(H);var K,V,Q,Z=new Array(m);function ae(te,I,fe,me,Ee){this.static_tree=te,this.extra_bits=I,this.extra_base=fe,this.elems=me,this.max_length=Ee,this.has_stree=te&&te.length}function B(te,I){this.dyn_tree=te,this.max_code=0,this.stat_desc=I}function X(te){return te<256?$[te]:$[256+(te>>>7)]}function ne(te,I){te.pending_buf[te.pending++]=255&I,te.pending_buf[te.pending++]=I>>>8&255}function se(te,I,fe){te.bi_valid>v-fe?(te.bi_buf|=I<<te.bi_valid&65535,ne(te,te.bi_buf),te.bi_buf=I>>v-te.bi_valid,te.bi_valid+=fe-v):(te.bi_buf|=I<<te.bi_valid&65535,te.bi_valid+=fe)}function be(te,I,fe){se(te,fe[2*I],fe[2*I+1])}function xe(te,I){for(var fe=0;fe|=1&te,te>>>=1,fe<<=1,0<--I;);return fe>>>1}function de(te,I,fe){var me,Ee,z=new Array(y+1),O=0;for(me=1;me<=y;me++)z[me]=O=O+fe[me-1]<<1;for(Ee=0;Ee<=I;Ee++){var ee=te[2*Ee+1];ee!==0&&(te[2*Ee]=xe(z[ee]++,ee))}}function Pe(te){var I;for(I=0;I<p;I++)te.dyn_ltree[2*I]=0;for(I=0;I<m;I++)te.dyn_dtree[2*I]=0;for(I=0;I<x;I++)te.bl_tree[2*I]=0;te.dyn_ltree[2*N]=1,te.opt_len=te.static_len=0,te.last_lit=te.matches=0}function ie(te){8<te.bi_valid?ne(te,te.bi_buf):0<te.bi_valid&&(te.pending_buf[te.pending++]=te.bi_buf),te.bi_buf=0,te.bi_valid=0}function Ne(te,I,fe,me){var Ee=2*I,z=2*fe;return te[Ee]<te[z]||te[Ee]===te[z]&&me[I]<=me[fe]}function Oe(te,I,fe){for(var me=te.heap[fe],Ee=fe<<1;Ee<=te.heap_len&&(Ee<te.heap_len&&Ne(I,te.heap[Ee+1],te.heap[Ee],te.depth)&&Ee++,!Ne(I,me,te.heap[Ee],te.depth));)te.heap[fe]=te.heap[Ee],fe=Ee,Ee<<=1;te.heap[fe]=me}function ge(te,I,fe){var me,Ee,z,O,ee=0;if(te.last_lit!==0)for(;me=te.pending_buf[te.d_buf+2*ee]<<8|te.pending_buf[te.d_buf+2*ee+1],Ee=te.pending_buf[te.l_buf+ee],ee++,me===0?be(te,Ee,I):(be(te,(z=j[Ee])+f+1,I),(O=E[z])!==0&&se(te,Ee-=H[z],O),be(te,z=X(--me),fe),(O=D[z])!==0&&se(te,me-=Z[z],O)),ee<te.last_lit;);be(te,N,I)}function Ke(te,I){var fe,me,Ee,z=I.dyn_tree,O=I.stat_desc.static_tree,ee=I.stat_desc.has_stree,le=I.stat_desc.elems,_e=-1;for(te.heap_len=0,te.heap_max=b,fe=0;fe<le;fe++)z[2*fe]!==0?(te.heap[++te.heap_len]=_e=fe,te.depth[fe]=0):z[2*fe+1]=0;for(;te.heap_len<2;)z[2*(Ee=te.heap[++te.heap_len]=_e<2?++_e:0)]=1,te.depth[Ee]=0,te.opt_len--,ee&&(te.static_len-=O[2*Ee+1]);for(I.max_code=_e,fe=te.heap_len>>1;1<=fe;fe--)Oe(te,z,fe);for(Ee=le;fe=te.heap[1],te.heap[1]=te.heap[te.heap_len--],Oe(te,z,1),me=te.heap[1],te.heap[--te.heap_max]=fe,te.heap[--te.heap_max]=me,z[2*Ee]=z[2*fe]+z[2*me],te.depth[Ee]=(te.depth[fe]>=te.depth[me]?te.depth[fe]:te.depth[me])+1,z[2*fe+1]=z[2*me+1]=Ee,te.heap[1]=Ee++,Oe(te,z,1),2<=te.heap_len;);te.heap[--te.heap_max]=te.heap[1],(function(we,re){var Fe,He,Ve,$e,ye,je,Be=re.dyn_tree,Se=re.max_code,Xe=re.stat_desc.static_tree,Me=re.stat_desc.has_stree,tt=re.stat_desc.extra_bits,ke=re.stat_desc.extra_base,We=re.stat_desc.max_length,ze=0;for($e=0;$e<=y;$e++)we.bl_count[$e]=0;for(Be[2*we.heap[we.heap_max]+1]=0,Fe=we.heap_max+1;Fe<b;Fe++)We<($e=Be[2*Be[2*(He=we.heap[Fe])+1]+1]+1)&&($e=We,ze++),Be[2*He+1]=$e,Se<He||(we.bl_count[$e]++,ye=0,ke<=He&&(ye=tt[He-ke]),je=Be[2*He],we.opt_len+=je*($e+ye),Me&&(we.static_len+=je*(Xe[2*He+1]+ye)));if(ze!==0){do{for($e=We-1;we.bl_count[$e]===0;)$e--;we.bl_count[$e]--,we.bl_count[$e+1]+=2,we.bl_count[We]--,ze-=2}while(0<ze);for($e=We;$e!==0;$e--)for(He=we.bl_count[$e];He!==0;)Se<(Ve=we.heap[--Fe])||(Be[2*Ve+1]!==$e&&(we.opt_len+=($e-Be[2*Ve+1])*Be[2*Ve],Be[2*Ve+1]=$e),He--)}})(te,I),de(z,_e,te.bl_count)}function G(te,I,fe){var me,Ee,z=-1,O=I[1],ee=0,le=7,_e=4;for(O===0&&(le=138,_e=3),I[2*(fe+1)+1]=65535,me=0;me<=fe;me++)Ee=O,O=I[2*(me+1)+1],++ee<le&&Ee===O||(ee<_e?te.bl_tree[2*Ee]+=ee:Ee!==0?(Ee!==z&&te.bl_tree[2*Ee]++,te.bl_tree[2*T]++):ee<=10?te.bl_tree[2*k]++:te.bl_tree[2*C]++,z=Ee,_e=(ee=0)===O?(le=138,3):Ee===O?(le=6,3):(le=7,4))}function Y(te,I,fe){var me,Ee,z=-1,O=I[1],ee=0,le=7,_e=4;for(O===0&&(le=138,_e=3),me=0;me<=fe;me++)if(Ee=O,O=I[2*(me+1)+1],!(++ee<le&&Ee===O)){if(ee<_e)for(;be(te,Ee,te.bl_tree),--ee!=0;);else Ee!==0?(Ee!==z&&(be(te,Ee,te.bl_tree),ee--),be(te,T,te.bl_tree),se(te,ee-3,2)):ee<=10?(be(te,k,te.bl_tree),se(te,ee-3,3)):(be(te,C,te.bl_tree),se(te,ee-11,7));z=Ee,_e=(ee=0)===O?(le=138,3):Ee===O?(le=6,3):(le=7,4)}}c(Z);var ce=!1;function q(te,I,fe,me){se(te,(u<<1)+(me?1:0),3),(function(Ee,z,O,ee){ie(Ee),ne(Ee,O),ne(Ee,~O),a.arraySet(Ee.pending_buf,Ee.window,z,O,Ee.pending),Ee.pending+=O})(te,I,fe)}i._tr_init=function(te){ce||((function(){var I,fe,me,Ee,z,O=new Array(y+1);for(Ee=me=0;Ee<d-1;Ee++)for(H[Ee]=me,I=0;I<1<<E[Ee];I++)j[me++]=Ee;for(j[me-1]=Ee,Ee=z=0;Ee<16;Ee++)for(Z[Ee]=z,I=0;I<1<<D[Ee];I++)$[z++]=Ee;for(z>>=7;Ee<m;Ee++)for(Z[Ee]=z<<7,I=0;I<1<<D[Ee]-7;I++)$[256+z++]=Ee;for(fe=0;fe<=y;fe++)O[fe]=0;for(I=0;I<=143;)U[2*I+1]=8,I++,O[8]++;for(;I<=255;)U[2*I+1]=9,I++,O[9]++;for(;I<=279;)U[2*I+1]=7,I++,O[7]++;for(;I<=287;)U[2*I+1]=8,I++,O[8]++;for(de(U,p+1,O),I=0;I<m;I++)F[2*I+1]=5,F[2*I]=xe(I,5);K=new ae(U,E,f+1,p,y),V=new ae(F,D,0,m,y),Q=new ae(new Array(0),A,0,x,S)})(),ce=!0),te.l_desc=new B(te.dyn_ltree,K),te.d_desc=new B(te.dyn_dtree,V),te.bl_desc=new B(te.bl_tree,Q),te.bi_buf=0,te.bi_valid=0,Pe(te)},i._tr_stored_block=q,i._tr_flush_block=function(te,I,fe,me){var Ee,z,O=0;0<te.level?(te.strm.data_type===2&&(te.strm.data_type=(function(ee){var le,_e=4093624447;for(le=0;le<=31;le++,_e>>>=1)if(1&_e&&ee.dyn_ltree[2*le]!==0)return o;if(ee.dyn_ltree[18]!==0||ee.dyn_ltree[20]!==0||ee.dyn_ltree[26]!==0)return l;for(le=32;le<f;le++)if(ee.dyn_ltree[2*le]!==0)return l;return o})(te)),Ke(te,te.l_desc),Ke(te,te.d_desc),O=(function(ee){var le;for(G(ee,ee.dyn_ltree,ee.l_desc.max_code),G(ee,ee.dyn_dtree,ee.d_desc.max_code),Ke(ee,ee.bl_desc),le=x-1;3<=le&&ee.bl_tree[2*R[le]+1]===0;le--);return ee.opt_len+=3*(le+1)+5+5+4,le})(te),Ee=te.opt_len+3+7>>>3,(z=te.static_len+3+7>>>3)<=Ee&&(Ee=z)):Ee=z=fe+5,fe+4<=Ee&&I!==-1?q(te,I,fe,me):te.strategy===4||z===Ee?(se(te,2+(me?1:0),3),ge(te,U,F)):(se(te,4+(me?1:0),3),(function(ee,le,_e,we){var re;for(se(ee,le-257,5),se(ee,_e-1,5),se(ee,we-4,4),re=0;re<we;re++)se(ee,ee.bl_tree[2*R[re]+1],3);Y(ee,ee.dyn_ltree,le-1),Y(ee,ee.dyn_dtree,_e-1)})(te,te.l_desc.max_code+1,te.d_desc.max_code+1,O+1),ge(te,te.dyn_ltree,te.dyn_dtree)),Pe(te),me&&ie(te)},i._tr_tally=function(te,I,fe){return te.pending_buf[te.d_buf+2*te.last_lit]=I>>>8&255,te.pending_buf[te.d_buf+2*te.last_lit+1]=255&I,te.pending_buf[te.l_buf+te.last_lit]=255&fe,te.last_lit++,I===0?te.dyn_ltree[2*fe]++:(te.matches++,I--,te.dyn_ltree[2*(j[fe]+f+1)]++,te.dyn_dtree[2*X(I)]++),te.last_lit===te.lit_bufsize-1},i._tr_align=function(te){se(te,2,3),be(te,N,U),(function(I){I.bi_valid===16?(ne(I,I.bi_buf),I.bi_buf=0,I.bi_valid=0):8<=I.bi_valid&&(I.pending_buf[I.pending++]=255&I.bi_buf,I.bi_buf>>=8,I.bi_valid-=8)})(te)}},{"../utils/common":41}],53:[function(n,r,i){r.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(n,r,i){(function(a){(function(o,l){if(!o.setImmediate){var c,u,d,f,p=1,m={},x=!1,b=o.document,y=Object.getPrototypeOf&&Object.getPrototypeOf(o);y=y&&y.setTimeout?y:o,c={}.toString.call(o.process)==="[object process]"?function(T){process.nextTick(function(){S(T)})}:(function(){if(o.postMessage&&!o.importScripts){var T=!0,k=o.onmessage;return o.onmessage=function(){T=!1},o.postMessage("","*"),o.onmessage=k,T}})()?(f="setImmediate$"+Math.random()+"$",o.addEventListener?o.addEventListener("message",N,!1):o.attachEvent("onmessage",N),function(T){o.postMessage(f+T,"*")}):o.MessageChannel?((d=new MessageChannel).port1.onmessage=function(T){S(T.data)},function(T){d.port2.postMessage(T)}):b&&"onreadystatechange"in b.createElement("script")?(u=b.documentElement,function(T){var k=b.createElement("script");k.onreadystatechange=function(){S(T),k.onreadystatechange=null,u.removeChild(k),k=null},u.appendChild(k)}):function(T){setTimeout(S,0,T)},y.setImmediate=function(T){typeof T!="function"&&(T=new Function(""+T));for(var k=new Array(arguments.length-1),C=0;C<k.length;C++)k[C]=arguments[C+1];var E={callback:T,args:k};return m[p]=E,c(p),p++},y.clearImmediate=v}function v(T){delete m[T]}function S(T){if(x)setTimeout(S,0,T);else{var k=m[T];if(k){x=!0;try{(function(C){var E=C.callback,D=C.args;switch(D.length){case 0:E();break;case 1:E(D[0]);break;case 2:E(D[0],D[1]);break;case 3:E(D[0],D[1],D[2]);break;default:E.apply(l,D)}})(k)}finally{v(T),x=!1}}}}function N(T){T.source===o&&typeof T.data=="string"&&T.data.indexOf(f)===0&&S(+T.data.slice(f.length))}})(typeof self>"u"?a===void 0?this:a:self)}).call(this,typeof Aw<"u"?Aw:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(SC)),SC.exports}var Q4e=Y4e();const Z4e=hl(Q4e);function J4e(t){const e=new Vi;if(!t)return e;const n=t.trim().split(/\s+/).map(parseFloat);return n.length>=12&&e.set(n[0],n[1],n[2],n[9],n[3],n[4],n[5],n[10],n[6],n[7],n[8],n[11],0,0,0,1),e}const DV=J4e;async function RV(t,e=0){const n=[],r=t.getElementsByTagName("mesh");for(let i=0;i<r.length;i++){const a=r[i],o=[],l=[],c=a.getElementsByTagName("vertex");for(let d=0;d<c.length;d++){const f=c[d];o.push(parseFloat(f.getAttribute("x")||"0"),parseFloat(f.getAttribute("y")||"0"),parseFloat(f.getAttribute("z")||"0"))}const u=a.getElementsByTagName("triangle");for(let d=0;d<u.length;d++){const f=u[d];l.push(parseInt(f.getAttribute("v1")||"0"),parseInt(f.getAttribute("v2")||"0"),parseInt(f.getAttribute("v3")||"0"))}o.length>0&&l.length>0&&n.push({vertices:o,triangles:l,extruder:e})}return n}async function eLe(t){const e=await Z4e.loadAsync(t),n=new Map,r=[],i=new DOMParser;async function a(m){const x=m.startsWith("/")?m.slice(1):m,b=e.files[x];if(!b)return null;const y=await b.async("string");return i.parseFromString(y,"application/xml")}const o=new Map,l=new Map,c=e.files["Metadata/model_settings.config"];if(c)try{const m=await c.async("string"),b=i.parseFromString(m,"application/xml").getElementsByTagName("object");for(let y=0;y<b.length;y++){const v=b[y],S=v.getAttribute("id");if(!S)continue;const N=Array.from(v.children).filter(k=>k.tagName==="metadata"&&k.getAttribute("key")==="extruder");if(N.length>0){const k=N[0].getAttribute("value");k&&o.set(S,Math.max(0,parseInt(k,10)-1))}const T=v.getElementsByTagName("part");for(let k=0;k<T.length;k++){const C=T[k],E=C.getAttribute("id");if(!E)continue;const D=Array.from(C.children).filter(A=>A.tagName==="metadata"&&A.getAttribute("key")==="extruder");if(D.length>0){const A=D[0].getAttribute("value");A&&l.set(`${S}:${E}`,Math.max(0,parseInt(A,10)-1))}}}}catch{}const u=Object.keys(e.files).find(m=>m==="3D/3dmodel.model"||m.endsWith("/3dmodel.model"));if(!u){const m=Object.keys(e.files).find(x=>x.endsWith(".model"));if(m){const x=await a(m);if(x){const b=await RV(x,0);b.length>0&&n.set("1",{id:"1",meshes:b,defaultExtruder:0})}}return{objects:n,buildItems:r}}const d=await a(u);if(!d)return{objects:n,buildItems:r};const f=d.getElementsByTagName("object");for(let m=0;m<f.length;m++){const x=f[m],b=x.getAttribute("id");if(!b)continue;let y=o.get(b)??-1;if(y<0){const T=x.getAttribute("p:extruder")||x.getAttributeNS("http://schemas.microsoft.com/3dmanufacturing/production/2015/06","extruder")||"1";y=Math.max(0,parseInt(T,10)-1)}const v=[],S=x.getElementsByTagName("mesh");for(let T=0;T<S.length;T++){const k=S[T],C=[],E=[],D=k.getElementsByTagName("vertex");for(let R=0;R<D.length;R++){const U=D[R];C.push(parseFloat(U.getAttribute("x")||"0"),parseFloat(U.getAttribute("y")||"0"),parseFloat(U.getAttribute("z")||"0"))}const A=k.getElementsByTagName("triangle");for(let R=0;R<A.length;R++){const U=A[R];E.push(parseInt(U.getAttribute("v1")||"0"),parseInt(U.getAttribute("v2")||"0"),parseInt(U.getAttribute("v3")||"0"))}C.length>0&&E.length>0&&v.push({vertices:C,triangles:E,extruder:y})}const N=x.getElementsByTagName("component");for(let T=0;T<N.length;T++){const k=N[T],C=k.getAttribute("p:path")||k.getAttributeNS("http://schemas.microsoft.com/3dmanufacturing/production/2015/06","path"),E=k.getAttribute("objectid");if(C){const D=await a(C);if(D){const A=E?`${b}:${E}`:null,R=A?l.get(A)??y:y,U=await RV(D,R),F=k.getAttribute("transform"),$=DV(F);for(const j of U)if(F){const H=[];for(let K=0;K<j.vertices.length;K+=3){const V=new dt(j.vertices[K],j.vertices[K+1],j.vertices[K+2]);V.applyMatrix4($),H.push(V.x,V.y,V.z)}v.push({vertices:H,triangles:j.triangles,extruder:j.extruder})}else v.push(j)}}}v.length>0&&n.set(b,{id:b,meshes:v,defaultExtruder:y})}const p=d.getElementsByTagName("build");if(p.length>0){const m=p[0].getElementsByTagName("item");for(let x=0;x<m.length;x++){const b=m[x],y=b.getAttribute("objectid");if(!y)continue;const v=DV(b.getAttribute("transform"));r.push({objectId:y,transform:v})}}return{objects:n,buildItems:r}}function OV(t){const e=new Ac,n=new Float32Array(t.vertices.length);for(let r=0;r<t.vertices.length;r+=3)n[r]=t.vertices[r],n[r+1]=t.vertices[r+2],n[r+2]=t.vertices[r+1];return e.setAttribute("position",new nl(n,3)),e.setIndex(t.triangles),e.computeVertexNormals(),e}function tLe({url:t,buildVolume:e={x:256,y:256,z:256},filamentColors:n,className:r=""}){const i=_.useRef(null),a=_.useRef(null),o=_.useRef(null),l=_.useRef(null),c=_.useRef(null),[u,d]=_.useState(!0),[f,p]=_.useState(null);_.useEffect(()=>{if(!i.current)return;const b=i.current,y=b.clientWidth,v=b.clientHeight,S=new PPe;S.background=new Bn(1710618),o.current=S;const N=new Wo(45,y/v,.1,1e4);N.position.set(150,150,150),l.current=N;const T=new R4e({antialias:!0});T.setSize(y,v),T.setPixelRatio(window.devicePixelRatio),b.appendChild(T.domElement),a.current=T;const k=new L4e(N,T.domElement);k.enableDamping=!0,k.dampingFactor=.05,c.current=k;const C=new VPe(16777215,.6);S.add(C);const E=new rV(16777215,.8);E.position.set(100,100,100),S.add(E);const D=new rV(16777215,.4);D.position.set(-100,50,-100),S.add(D);const A=Math.max(e.x,e.y),R=Math.ceil(A/16),U=new qPe(A,R,4473924,3355443);S.add(U);const F=new tL(e.x,e.y),$=new Z4({color:44610,transparent:!0,opacity:.15,side:ic}),j=new vc(F,$);j.rotation.x=-Math.PI/2,j.position.y=-.5,S.add(j);let H;const K=()=>{H=requestAnimationFrame(K),k.update(),T.render(S,N)};K(),fetch(t).then(Q=>{if(!Q.ok)throw new Error("Failed to load file");return Q.arrayBuffer()}).then(eLe).then(({objects:Q,buildItems:Z})=>{if(Q.size===0)throw new Error("No meshes found in 3MF file");const ae=Ne=>{const ge=n?.[Ne]||"#00ae42",Ke=new Bn(ge);return new UPe({color:Ke,shininess:30,flatShading:!1})},B=new o0,X=new Map;if(Z.length>0)for(const Ne of Z){const Oe=Q.get(Ne.objectId);if(Oe)for(const ge of Oe.meshes){const Ke=Ne.extruder??ge.extruder,G=[];for(let ce=0;ce<ge.vertices.length;ce+=3){const q=new dt(ge.vertices[ce],ge.vertices[ce+1],ge.vertices[ce+2]);q.applyMatrix4(Ne.transform),G.push(q.x,q.y,q.z)}const Y=OV({vertices:G,triangles:ge.triangles});X.has(Ke)||X.set(Ke,[]),X.get(Ke).push(Y)}}else for(const Ne of Q.values())for(const Oe of Ne.meshes){const ge=Oe.extruder,Ke=OV(Oe);X.has(ge)||X.set(ge,[]),X.get(ge).push(Ke)}for(const[Ne,Oe]of X){if(Oe.length===0)continue;const ge=Oe.length===1?Oe[0]:X4e(Oe,!1);if(ge){const Ke=ae(Ne),G=new vc(ge,Ke);B.add(G)}if(Oe.length>1)for(const Ke of Oe)Ke.dispose()}const ne=new bm().setFromObject(B),se=ne.getCenter(new dt);B.position.y=-ne.min.y,Z.length===0&&(B.position.x=-se.x,B.position.z=-se.z),S.add(B);const be=new bm().setFromObject(B),xe=be.getCenter(new dt),de=be.getSize(new dt),ie=Math.max(de.x,de.y,de.z)*1.8;N.position.set(xe.x+ie*.7,xe.y+ie*.5,xe.z+ie*.7),k.target.copy(xe),k.update(),d(!1)}).catch(Q=>{p(Q.message),d(!1)});const V=()=>{if(!b)return;const Q=b.clientWidth,Z=b.clientHeight;N.aspect=Q/Z,N.updateProjectionMatrix(),T.setSize(Q,Z)};return window.addEventListener("resize",V),()=>{window.removeEventListener("resize",V),cancelAnimationFrame(H),k.dispose(),T.dispose(),b.removeChild(T.domElement)}},[t,e,n]);const m=()=>{l.current&&c.current&&(l.current.position.set(150,150,150),c.current.target.set(0,50,0),c.current.update())},x=b=>{l.current&&l.current.position.multiplyScalar(b)};return s.jsxs("div",{className:`relative ${r}`,children:[s.jsx("div",{ref:i,className:"w-full h-full min-h-[400px]"}),u&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:s.jsx(ht,{className:"w-8 h-8 text-bambu-green animate-spin"})}),f&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:s.jsx("p",{className:"text-red-400",children:f})}),!u&&!f&&s.jsxs("div",{className:"absolute bottom-4 right-4 flex gap-2",children:[s.jsx(Te,{variant:"secondary",size:"sm",onClick:()=>x(.8),children:s.jsx(LR,{className:"w-4 h-4"})}),s.jsx(Te,{variant:"secondary",size:"sm",onClick:()=>x(1.25),children:s.jsx(FR,{className:"w-4 h-4"})}),s.jsx(Te,{variant:"secondary",size:"sm",onClick:m,children:s.jsx(Rh,{className:"w-4 h-4"})})]})]})}const x2="159",Rp={ROTATE:0,DOLLY:1,PAN:2},Op={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},nLe=0,LV=1,rLe=2,RJ=1,iLe=2,lu=3,Th=0,zs=1,pu=2,ch=0,jg=1,FV=2,IV=3,UV=4,aLe=5,kf=100,sLe=101,oLe=102,zV=103,BV=104,lLe=200,cLe=201,uLe=202,dLe=203,fD=204,mD=205,hLe=206,fLe=207,mLe=208,pLe=209,gLe=210,xLe=211,bLe=212,yLe=213,vLe=214,wLe=0,_Le=1,SLe=2,ZS=3,MLe=4,NLe=5,kLe=6,ELe=7,rL=0,TLe=1,ALe=2,uh=0,CLe=1,jLe=2,PLe=3,DLe=4,RLe=5,OJ=300,nx=301,rx=302,pD=303,gD=304,b2=306,xD=1e3,Cl=1001,bD=1002,Da=1003,HV=1004,MC=1005,Ko=1006,OLe=1007,gy=1008,dh=1009,LLe=1010,FLe=1011,iL=1012,LJ=1013,Zd=1014,_u=1015,xy=1016,FJ=1017,IJ=1018,qf=1020,ILe=1021,Xo=1023,ULe=1024,zLe=1025,Wf=1026,ix=1027,BLe=1028,UJ=1029,HLe=1030,zJ=1031,BJ=1033,NC=33776,kC=33777,EC=33778,TC=33779,$V=35840,VV=35841,GV=35842,qV=35843,HJ=36196,WV=37492,KV=37496,XV=37808,YV=37809,QV=37810,ZV=37811,JV=37812,eG=37813,tG=37814,nG=37815,rG=37816,iG=37817,aG=37818,sG=37819,oG=37820,lG=37821,AC=36492,cG=36494,uG=36495,$Le=36283,dG=36284,hG=36285,fG=36286,$J=3e3,Kf=3001,VLe=3200,GLe=3201,VJ=0,qLe=1,Yo="",Ra="srgb",Vu="srgb-linear",aL="display-p3",y2="display-p3-linear",JS="linear",Gr="srgb",eM="rec709",tM="p3",Lp=7680,mG=519,WLe=512,KLe=513,XLe=514,GJ=515,YLe=516,QLe=517,ZLe=518,JLe=519,yD=35044,pG="300 es",vD=1035,cc=2e3,by=2001;class jm{addEventListener(e,n){this._listeners===void 0&&(this._listeners={});const r=this._listeners;r[e]===void 0&&(r[e]=[]),r[e].indexOf(n)===-1&&r[e].push(n)}hasEventListener(e,n){if(this._listeners===void 0)return!1;const r=this._listeners;return r[e]!==void 0&&r[e].indexOf(n)!==-1}removeEventListener(e,n){if(this._listeners===void 0)return;const i=this._listeners[e];if(i!==void 0){const a=i.indexOf(n);a!==-1&&i.splice(a,1)}}dispatchEvent(e){if(this._listeners===void 0)return;const r=this._listeners[e.type];if(r!==void 0){e.target=this;const i=r.slice(0);for(let a=0,o=i.length;a<o;a++)i[a].call(this,e);e.target=null}}}const Ga=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let gG=1234567;const w0=Math.PI/180,yy=180/Math.PI;function Cu(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(Ga[t&255]+Ga[t>>8&255]+Ga[t>>16&255]+Ga[t>>24&255]+"-"+Ga[e&255]+Ga[e>>8&255]+"-"+Ga[e>>16&15|64]+Ga[e>>24&255]+"-"+Ga[n&63|128]+Ga[n>>8&255]+"-"+Ga[n>>16&255]+Ga[n>>24&255]+Ga[r&255]+Ga[r>>8&255]+Ga[r>>16&255]+Ga[r>>24&255]).toLowerCase()}function Oa(t,e,n){return Math.max(e,Math.min(n,t))}function sL(t,e){return(t%e+e)%e}function eFe(t,e,n,r,i){return r+(t-e)*(i-r)/(n-e)}function tFe(t,e,n){return t!==e?(n-t)/(e-t):0}function _0(t,e,n){return(1-n)*t+n*e}function nFe(t,e,n,r){return _0(t,e,1-Math.exp(-n*r))}function rFe(t,e=1){return e-Math.abs(sL(t,e*2)-e)}function iFe(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*(3-2*t))}function aFe(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*t*(t*(t*6-15)+10))}function sFe(t,e){return t+Math.floor(Math.random()*(e-t+1))}function oFe(t,e){return t+Math.random()*(e-t)}function lFe(t){return t*(.5-Math.random())}function cFe(t){t!==void 0&&(gG=t);let e=gG+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function uFe(t){return t*w0}function dFe(t){return t*yy}function wD(t){return(t&t-1)===0&&t!==0}function hFe(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}function nM(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function fFe(t,e,n,r,i){const a=Math.cos,o=Math.sin,l=a(n/2),c=o(n/2),u=a((e+r)/2),d=o((e+r)/2),f=a((e-r)/2),p=o((e-r)/2),m=a((r-e)/2),x=o((r-e)/2);switch(i){case"XYX":t.set(l*d,c*f,c*p,l*u);break;case"YZY":t.set(c*p,l*d,c*f,l*u);break;case"ZXZ":t.set(c*f,c*p,l*d,l*u);break;case"XZX":t.set(l*d,c*x,c*m,l*u);break;case"YXY":t.set(c*m,l*d,c*x,l*u);break;case"ZYZ":t.set(c*x,c*m,l*d,l*u);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function ac(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return t/4294967295;case Uint16Array:return t/65535;case Uint8Array:return t/255;case Int32Array:return Math.max(t/2147483647,-1);case Int16Array:return Math.max(t/32767,-1);case Int8Array:return Math.max(t/127,-1);default:throw new Error("Invalid component type.")}}function kr(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return Math.round(t*4294967295);case Uint16Array:return Math.round(t*65535);case Uint8Array:return Math.round(t*255);case Int32Array:return Math.round(t*2147483647);case Int16Array:return Math.round(t*32767);case Int8Array:return Math.round(t*127);default:throw new Error("Invalid component type.")}}const qJ={DEG2RAD:w0,RAD2DEG:yy,generateUUID:Cu,clamp:Oa,euclideanModulo:sL,mapLinear:eFe,inverseLerp:tFe,lerp:_0,damp:nFe,pingpong:rFe,smoothstep:iFe,smootherstep:aFe,randInt:sFe,randFloat:oFe,randFloatSpread:lFe,seededRandom:cFe,degToRad:uFe,radToDeg:dFe,isPowerOfTwo:wD,ceilPowerOfTwo:hFe,floorPowerOfTwo:nM,setQuaternionFromProperEuler:fFe,normalize:kr,denormalize:ac};class xn{constructor(e=0,n=0){xn.prototype.isVector2=!0,this.x=e,this.y=n}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,n){return this.x=e,this.y=n,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const n=this.x,r=this.y,i=e.elements;return this.x=i[0]*n+i[3]*r+i[6],this.y=i[1]*n+i[4]*r+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,n){return this.x=Math.max(e.x,Math.min(n.x,this.x)),this.y=Math.max(e.y,Math.min(n.y,this.y)),this}clampScalar(e,n){return this.x=Math.max(e,Math.min(n,this.x)),this.y=Math.max(e,Math.min(n,this.y)),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(n,r)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const n=Math.sqrt(this.lengthSq()*e.lengthSq());if(n===0)return Math.PI/2;const r=this.dot(e)/n;return Math.acos(Oa(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,r=this.y-e.y;return n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this}rotateAround(e,n){const r=Math.cos(n),i=Math.sin(n),a=this.x-e.x,o=this.y-e.y;return this.x=a*r-o*i+e.x,this.y=a*i+o*r+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Ln{constructor(e,n,r,i,a,o,l,c,u){Ln.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,n,r,i,a,o,l,c,u)}set(e,n,r,i,a,o,l,c,u){const d=this.elements;return d[0]=e,d[1]=i,d[2]=l,d[3]=n,d[4]=a,d[5]=c,d[6]=r,d[7]=o,d[8]=u,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const n=this.elements,r=e.elements;return n[0]=r[0],n[1]=r[1],n[2]=r[2],n[3]=r[3],n[4]=r[4],n[5]=r[5],n[6]=r[6],n[7]=r[7],n[8]=r[8],this}extractBasis(e,n,r){return e.setFromMatrix3Column(this,0),n.setFromMatrix3Column(this,1),r.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const n=e.elements;return this.set(n[0],n[4],n[8],n[1],n[5],n[9],n[2],n[6],n[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){const r=e.elements,i=n.elements,a=this.elements,o=r[0],l=r[3],c=r[6],u=r[1],d=r[4],f=r[7],p=r[2],m=r[5],x=r[8],b=i[0],y=i[3],v=i[6],S=i[1],N=i[4],T=i[7],k=i[2],C=i[5],E=i[8];return a[0]=o*b+l*S+c*k,a[3]=o*y+l*N+c*C,a[6]=o*v+l*T+c*E,a[1]=u*b+d*S+f*k,a[4]=u*y+d*N+f*C,a[7]=u*v+d*T+f*E,a[2]=p*b+m*S+x*k,a[5]=p*y+m*N+x*C,a[8]=p*v+m*T+x*E,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[3]*=e,n[6]*=e,n[1]*=e,n[4]*=e,n[7]*=e,n[2]*=e,n[5]*=e,n[8]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[1],i=e[2],a=e[3],o=e[4],l=e[5],c=e[6],u=e[7],d=e[8];return n*o*d-n*l*u-r*a*d+r*l*c+i*a*u-i*o*c}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],a=e[3],o=e[4],l=e[5],c=e[6],u=e[7],d=e[8],f=d*o-l*u,p=l*c-d*a,m=u*a-o*c,x=n*f+r*p+i*m;if(x===0)return this.set(0,0,0,0,0,0,0,0,0);const b=1/x;return e[0]=f*b,e[1]=(i*u-d*r)*b,e[2]=(l*r-i*o)*b,e[3]=p*b,e[4]=(d*n-i*c)*b,e[5]=(i*a-l*n)*b,e[6]=m*b,e[7]=(r*c-u*n)*b,e[8]=(o*n-r*a)*b,this}transpose(){let e;const n=this.elements;return e=n[1],n[1]=n[3],n[3]=e,e=n[2],n[2]=n[6],n[6]=e,e=n[5],n[5]=n[7],n[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const n=this.elements;return e[0]=n[0],e[1]=n[3],e[2]=n[6],e[3]=n[1],e[4]=n[4],e[5]=n[7],e[6]=n[2],e[7]=n[5],e[8]=n[8],this}setUvTransform(e,n,r,i,a,o,l){const c=Math.cos(a),u=Math.sin(a);return this.set(r*c,r*u,-r*(c*o+u*l)+o+e,-i*u,i*c,-i*(-u*o+c*l)+l+n,0,0,1),this}scale(e,n){return this.premultiply(CC.makeScale(e,n)),this}rotate(e){return this.premultiply(CC.makeRotation(-e)),this}translate(e,n){return this.premultiply(CC.makeTranslation(e,n)),this}makeTranslation(e,n){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,n,0,0,1),this}makeRotation(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,-r,0,r,n,0,0,0,1),this}makeScale(e,n){return this.set(e,0,0,0,n,0,0,0,1),this}equals(e){const n=this.elements,r=e.elements;for(let i=0;i<9;i++)if(n[i]!==r[i])return!1;return!0}fromArray(e,n=0){for(let r=0;r<9;r++)this.elements[r]=e[r+n];return this}toArray(e=[],n=0){const r=this.elements;return e[n]=r[0],e[n+1]=r[1],e[n+2]=r[2],e[n+3]=r[3],e[n+4]=r[4],e[n+5]=r[5],e[n+6]=r[6],e[n+7]=r[7],e[n+8]=r[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const CC=new Ln;function WJ(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function rM(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function mFe(){const t=rM("canvas");return t.style.display="block",t}const xG={};function S0(t){t in xG||(xG[t]=!0,console.warn(t))}const bG=new Ln().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),yG=new Ln().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),__={[Vu]:{transfer:JS,primaries:eM,toReference:t=>t,fromReference:t=>t},[Ra]:{transfer:Gr,primaries:eM,toReference:t=>t.convertSRGBToLinear(),fromReference:t=>t.convertLinearToSRGB()},[y2]:{transfer:JS,primaries:tM,toReference:t=>t.applyMatrix3(yG),fromReference:t=>t.applyMatrix3(bG)},[aL]:{transfer:Gr,primaries:tM,toReference:t=>t.convertSRGBToLinear().applyMatrix3(yG),fromReference:t=>t.applyMatrix3(bG).convertLinearToSRGB()}},pFe=new Set([Vu,y2]),Er={enabled:!0,_workingColorSpace:Vu,get legacyMode(){return console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),!this.enabled},set legacyMode(t){console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),this.enabled=!t},get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(t){if(!pFe.has(t))throw new Error(`Unsupported working color space, "${t}".`);this._workingColorSpace=t},convert:function(t,e,n){if(this.enabled===!1||e===n||!e||!n)return t;const r=__[e].toReference,i=__[n].fromReference;return i(r(t))},fromWorkingColorSpace:function(t,e){return this.convert(t,this._workingColorSpace,e)},toWorkingColorSpace:function(t,e){return this.convert(t,e,this._workingColorSpace)},getPrimaries:function(t){return __[t].primaries},getTransfer:function(t){return t===Yo?JS:__[t].transfer}};function Pg(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function jC(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let Fp;class KJ{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{Fp===void 0&&(Fp=rM("canvas")),Fp.width=e.width,Fp.height=e.height;const r=Fp.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),n=Fp}return n.width>2048||n.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),n.toDataURL("image/jpeg",.6)):n.toDataURL("image/png")}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const n=rM("canvas");n.width=e.width,n.height=e.height;const r=n.getContext("2d");r.drawImage(e,0,0,e.width,e.height);const i=r.getImageData(0,0,e.width,e.height),a=i.data;for(let o=0;o<a.length;o++)a[o]=Pg(a[o]/255)*255;return r.putImageData(i,0,0),n}else if(e.data){const n=e.data.slice(0);for(let r=0;r<n.length;r++)n instanceof Uint8Array||n instanceof Uint8ClampedArray?n[r]=Math.floor(Pg(n[r]/255)*255):n[r]=Pg(n[r]);return{data:n,width:e.width,height:e.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let gFe=0;class XJ{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:gFe++}),this.uuid=Cu(),this.data=e,this.version=0}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const n=e===void 0||typeof e=="string";if(!n&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const r={uuid:this.uuid,url:""},i=this.data;if(i!==null){let a;if(Array.isArray(i)){a=[];for(let o=0,l=i.length;o<l;o++)i[o].isDataTexture?a.push(PC(i[o].image)):a.push(PC(i[o]))}else a=PC(i);r.url=a}return n||(e.images[this.uuid]=r),r}}function PC(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?KJ.getDataURL(t):t.data?{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let xFe=0;class Bs extends jm{constructor(e=Bs.DEFAULT_IMAGE,n=Bs.DEFAULT_MAPPING,r=Cl,i=Cl,a=Ko,o=gy,l=Xo,c=dh,u=Bs.DEFAULT_ANISOTROPY,d=Yo){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:xFe++}),this.uuid=Cu(),this.name="",this.source=new XJ(e),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=a,this.minFilter=o,this.anisotropy=u,this.format=l,this.internalFormat=null,this.type=c,this.offset=new xn(0,0),this.repeat=new xn(1,1),this.center=new xn(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Ln,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,typeof d=="string"?this.colorSpace=d:(S0("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=d===Kf?Ra:Yo),this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.needsPMREMUpdate=!1}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}toJSON(e){const n=e===void 0||typeof e=="string";if(!n&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const r={metadata:{version:4.6,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(r.userData=this.userData),n||(e.textures[this.uuid]=r),r}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==OJ)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case xD:e.x=e.x-Math.floor(e.x);break;case Cl:e.x=e.x<0?0:1;break;case bD:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case xD:e.y=e.y-Math.floor(e.y);break;case Cl:e.y=e.y<0?0:1;break;case bD:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}get encoding(){return S0("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===Ra?Kf:$J}set encoding(e){S0("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=e===Kf?Ra:Yo}}Bs.DEFAULT_IMAGE=null;Bs.DEFAULT_MAPPING=OJ;Bs.DEFAULT_ANISOTROPY=1;class Cr{constructor(e=0,n=0,r=0,i=1){Cr.prototype.isVector4=!0,this.x=e,this.y=n,this.z=r,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,n,r,i){return this.x=e,this.y=n,this.z=r,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;case 3:this.w=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this.z=e.z+n.z,this.w=e.w+n.w,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this.z+=e.z*n,this.w+=e.w*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this.z=e.z-n.z,this.w=e.w-n.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const n=this.x,r=this.y,i=this.z,a=this.w,o=e.elements;return this.x=o[0]*n+o[4]*r+o[8]*i+o[12]*a,this.y=o[1]*n+o[5]*r+o[9]*i+o[13]*a,this.z=o[2]*n+o[6]*r+o[10]*i+o[14]*a,this.w=o[3]*n+o[7]*r+o[11]*i+o[15]*a,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const n=Math.sqrt(1-e.w*e.w);return n<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/n,this.y=e.y/n,this.z=e.z/n),this}setAxisAngleFromRotationMatrix(e){let n,r,i,a;const c=e.elements,u=c[0],d=c[4],f=c[8],p=c[1],m=c[5],x=c[9],b=c[2],y=c[6],v=c[10];if(Math.abs(d-p)<.01&&Math.abs(f-b)<.01&&Math.abs(x-y)<.01){if(Math.abs(d+p)<.1&&Math.abs(f+b)<.1&&Math.abs(x+y)<.1&&Math.abs(u+m+v-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const N=(u+1)/2,T=(m+1)/2,k=(v+1)/2,C=(d+p)/4,E=(f+b)/4,D=(x+y)/4;return N>T&&N>k?N<.01?(r=0,i=.707106781,a=.707106781):(r=Math.sqrt(N),i=C/r,a=E/r):T>k?T<.01?(r=.707106781,i=0,a=.707106781):(i=Math.sqrt(T),r=C/i,a=D/i):k<.01?(r=.707106781,i=.707106781,a=0):(a=Math.sqrt(k),r=E/a,i=D/a),this.set(r,i,a,n),this}let S=Math.sqrt((y-x)*(y-x)+(f-b)*(f-b)+(p-d)*(p-d));return Math.abs(S)<.001&&(S=1),this.x=(y-x)/S,this.y=(f-b)/S,this.z=(p-d)/S,this.w=Math.acos((u+m+v-1)/2),this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,n){return this.x=Math.max(e.x,Math.min(n.x,this.x)),this.y=Math.max(e.y,Math.min(n.y,this.y)),this.z=Math.max(e.z,Math.min(n.z,this.z)),this.w=Math.max(e.w,Math.min(n.w,this.w)),this}clampScalar(e,n){return this.x=Math.max(e,Math.min(n,this.x)),this.y=Math.max(e,Math.min(n,this.y)),this.z=Math.max(e,Math.min(n,this.z)),this.w=Math.max(e,Math.min(n,this.w)),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(n,r)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this.w+=(e.w-this.w)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this.z=e.z+(n.z-e.z)*r,this.w=e.w+(n.w-e.w)*r,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this.z=e[n+2],this.w=e[n+3],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e[n+2]=this.z,e[n+3]=this.w,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this.z=e.getZ(n),this.w=e.getW(n),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class bFe extends jm{constructor(e=1,n=1,r={}){super(),this.isRenderTarget=!0,this.width=e,this.height=n,this.depth=1,this.scissor=new Cr(0,0,e,n),this.scissorTest=!1,this.viewport=new Cr(0,0,e,n);const i={width:e,height:n,depth:1};r.encoding!==void 0&&(S0("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),r.colorSpace=r.encoding===Kf?Ra:Yo),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Ko,depthBuffer:!0,stencilBuffer:!1,depthTexture:null,samples:0},r),this.texture=new Bs(i,r.mapping,r.wrapS,r.wrapT,r.magFilter,r.minFilter,r.format,r.type,r.anisotropy,r.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.flipY=!1,this.texture.generateMipmaps=r.generateMipmaps,this.texture.internalFormat=r.internalFormat,this.depthBuffer=r.depthBuffer,this.stencilBuffer=r.stencilBuffer,this.depthTexture=r.depthTexture,this.samples=r.samples}setSize(e,n,r=1){(this.width!==e||this.height!==n||this.depth!==r)&&(this.width=e,this.height=n,this.depth=r,this.texture.image.width=e,this.texture.image.height=n,this.texture.image.depth=r,this.dispose()),this.viewport.set(0,0,e,n),this.scissor.set(0,0,e,n)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.texture=e.texture.clone(),this.texture.isRenderTargetTexture=!0;const n=Object.assign({},e.texture.image);return this.texture.source=new XJ(n),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class ym extends bFe{constructor(e=1,n=1,r={}){super(e,n,r),this.isWebGLRenderTarget=!0}}class YJ extends Bs{constructor(e=null,n=1,r=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:n,height:r,depth:i},this.magFilter=Da,this.minFilter=Da,this.wrapR=Cl,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class yFe extends Bs{constructor(e=null,n=1,r=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:n,height:r,depth:i},this.magFilter=Da,this.minFilter=Da,this.wrapR=Cl,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class vm{constructor(e=0,n=0,r=0,i=1){this.isQuaternion=!0,this._x=e,this._y=n,this._z=r,this._w=i}static slerpFlat(e,n,r,i,a,o,l){let c=r[i+0],u=r[i+1],d=r[i+2],f=r[i+3];const p=a[o+0],m=a[o+1],x=a[o+2],b=a[o+3];if(l===0){e[n+0]=c,e[n+1]=u,e[n+2]=d,e[n+3]=f;return}if(l===1){e[n+0]=p,e[n+1]=m,e[n+2]=x,e[n+3]=b;return}if(f!==b||c!==p||u!==m||d!==x){let y=1-l;const v=c*p+u*m+d*x+f*b,S=v>=0?1:-1,N=1-v*v;if(N>Number.EPSILON){const k=Math.sqrt(N),C=Math.atan2(k,v*S);y=Math.sin(y*C)/k,l=Math.sin(l*C)/k}const T=l*S;if(c=c*y+p*T,u=u*y+m*T,d=d*y+x*T,f=f*y+b*T,y===1-l){const k=1/Math.sqrt(c*c+u*u+d*d+f*f);c*=k,u*=k,d*=k,f*=k}}e[n]=c,e[n+1]=u,e[n+2]=d,e[n+3]=f}static multiplyQuaternionsFlat(e,n,r,i,a,o){const l=r[i],c=r[i+1],u=r[i+2],d=r[i+3],f=a[o],p=a[o+1],m=a[o+2],x=a[o+3];return e[n]=l*x+d*f+c*m-u*p,e[n+1]=c*x+d*p+u*f-l*m,e[n+2]=u*x+d*m+l*p-c*f,e[n+3]=d*x-l*f-c*p-u*m,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,n,r,i){return this._x=e,this._y=n,this._z=r,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,n){const r=e._x,i=e._y,a=e._z,o=e._order,l=Math.cos,c=Math.sin,u=l(r/2),d=l(i/2),f=l(a/2),p=c(r/2),m=c(i/2),x=c(a/2);switch(o){case"XYZ":this._x=p*d*f+u*m*x,this._y=u*m*f-p*d*x,this._z=u*d*x+p*m*f,this._w=u*d*f-p*m*x;break;case"YXZ":this._x=p*d*f+u*m*x,this._y=u*m*f-p*d*x,this._z=u*d*x-p*m*f,this._w=u*d*f+p*m*x;break;case"ZXY":this._x=p*d*f-u*m*x,this._y=u*m*f+p*d*x,this._z=u*d*x+p*m*f,this._w=u*d*f-p*m*x;break;case"ZYX":this._x=p*d*f-u*m*x,this._y=u*m*f+p*d*x,this._z=u*d*x-p*m*f,this._w=u*d*f+p*m*x;break;case"YZX":this._x=p*d*f+u*m*x,this._y=u*m*f+p*d*x,this._z=u*d*x-p*m*f,this._w=u*d*f-p*m*x;break;case"XZY":this._x=p*d*f-u*m*x,this._y=u*m*f-p*d*x,this._z=u*d*x+p*m*f,this._w=u*d*f+p*m*x;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return n!==!1&&this._onChangeCallback(),this}setFromAxisAngle(e,n){const r=n/2,i=Math.sin(r);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(r),this._onChangeCallback(),this}setFromRotationMatrix(e){const n=e.elements,r=n[0],i=n[4],a=n[8],o=n[1],l=n[5],c=n[9],u=n[2],d=n[6],f=n[10],p=r+l+f;if(p>0){const m=.5/Math.sqrt(p+1);this._w=.25/m,this._x=(d-c)*m,this._y=(a-u)*m,this._z=(o-i)*m}else if(r>l&&r>f){const m=2*Math.sqrt(1+r-l-f);this._w=(d-c)/m,this._x=.25*m,this._y=(i+o)/m,this._z=(a+u)/m}else if(l>f){const m=2*Math.sqrt(1+l-r-f);this._w=(a-u)/m,this._x=(i+o)/m,this._y=.25*m,this._z=(c+d)/m}else{const m=2*Math.sqrt(1+f-r-l);this._w=(o-i)/m,this._x=(a+u)/m,this._y=(c+d)/m,this._z=.25*m}return this._onChangeCallback(),this}setFromUnitVectors(e,n){let r=e.dot(n)+1;return r<Number.EPSILON?(r=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=r):(this._x=0,this._y=-e.z,this._z=e.y,this._w=r)):(this._x=e.y*n.z-e.z*n.y,this._y=e.z*n.x-e.x*n.z,this._z=e.x*n.y-e.y*n.x,this._w=r),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Oa(this.dot(e),-1,1)))}rotateTowards(e,n){const r=this.angleTo(e);if(r===0)return this;const i=Math.min(1,n/r);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,n){const r=e._x,i=e._y,a=e._z,o=e._w,l=n._x,c=n._y,u=n._z,d=n._w;return this._x=r*d+o*l+i*u-a*c,this._y=i*d+o*c+a*l-r*u,this._z=a*d+o*u+r*c-i*l,this._w=o*d-r*l-i*c-a*u,this._onChangeCallback(),this}slerp(e,n){if(n===0)return this;if(n===1)return this.copy(e);const r=this._x,i=this._y,a=this._z,o=this._w;let l=o*e._w+r*e._x+i*e._y+a*e._z;if(l<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,l=-l):this.copy(e),l>=1)return this._w=o,this._x=r,this._y=i,this._z=a,this;const c=1-l*l;if(c<=Number.EPSILON){const m=1-n;return this._w=m*o+n*this._w,this._x=m*r+n*this._x,this._y=m*i+n*this._y,this._z=m*a+n*this._z,this.normalize(),this._onChangeCallback(),this}const u=Math.sqrt(c),d=Math.atan2(u,l),f=Math.sin((1-n)*d)/u,p=Math.sin(n*d)/u;return this._w=o*f+this._w*p,this._x=r*f+this._x*p,this._y=i*f+this._y*p,this._z=a*f+this._z*p,this._onChangeCallback(),this}slerpQuaternions(e,n,r){return this.copy(e).slerp(n,r)}random(){const e=Math.random(),n=Math.sqrt(1-e),r=Math.sqrt(e),i=2*Math.PI*Math.random(),a=2*Math.PI*Math.random();return this.set(n*Math.cos(i),r*Math.sin(a),r*Math.cos(a),n*Math.sin(i))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,n=0){return this._x=e[n],this._y=e[n+1],this._z=e[n+2],this._w=e[n+3],this._onChangeCallback(),this}toArray(e=[],n=0){return e[n]=this._x,e[n+1]=this._y,e[n+2]=this._z,e[n+3]=this._w,e}fromBufferAttribute(e,n){return this._x=e.getX(n),this._y=e.getY(n),this._z=e.getZ(n),this._w=e.getW(n),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class qe{constructor(e=0,n=0,r=0){qe.prototype.isVector3=!0,this.x=e,this.y=n,this.z=r}set(e,n,r){return r===void 0&&(r=this.z),this.x=e,this.y=n,this.z=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this.z=e.z+n.z,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this.z+=e.z*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this.z=e.z-n.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,n){return this.x=e.x*n.x,this.y=e.y*n.y,this.z=e.z*n.z,this}applyEuler(e){return this.applyQuaternion(vG.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(vG.setFromAxisAngle(e,n))}applyMatrix3(e){const n=this.x,r=this.y,i=this.z,a=e.elements;return this.x=a[0]*n+a[3]*r+a[6]*i,this.y=a[1]*n+a[4]*r+a[7]*i,this.z=a[2]*n+a[5]*r+a[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const n=this.x,r=this.y,i=this.z,a=e.elements,o=1/(a[3]*n+a[7]*r+a[11]*i+a[15]);return this.x=(a[0]*n+a[4]*r+a[8]*i+a[12])*o,this.y=(a[1]*n+a[5]*r+a[9]*i+a[13])*o,this.z=(a[2]*n+a[6]*r+a[10]*i+a[14])*o,this}applyQuaternion(e){const n=this.x,r=this.y,i=this.z,a=e.x,o=e.y,l=e.z,c=e.w,u=2*(o*i-l*r),d=2*(l*n-a*i),f=2*(a*r-o*n);return this.x=n+c*u+o*f-l*d,this.y=r+c*d+l*u-a*f,this.z=i+c*f+a*d-o*u,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const n=this.x,r=this.y,i=this.z,a=e.elements;return this.x=a[0]*n+a[4]*r+a[8]*i,this.y=a[1]*n+a[5]*r+a[9]*i,this.z=a[2]*n+a[6]*r+a[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,n){return this.x=Math.max(e.x,Math.min(n.x,this.x)),this.y=Math.max(e.y,Math.min(n.y,this.y)),this.z=Math.max(e.z,Math.min(n.z,this.z)),this}clampScalar(e,n){return this.x=Math.max(e,Math.min(n,this.x)),this.y=Math.max(e,Math.min(n,this.y)),this.z=Math.max(e,Math.min(n,this.z)),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(n,r)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this.z=e.z+(n.z-e.z)*r,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,n){const r=e.x,i=e.y,a=e.z,o=n.x,l=n.y,c=n.z;return this.x=i*c-a*l,this.y=a*o-r*c,this.z=r*l-i*o,this}projectOnVector(e){const n=e.lengthSq();if(n===0)return this.set(0,0,0);const r=e.dot(this)/n;return this.copy(e).multiplyScalar(r)}projectOnPlane(e){return DC.copy(this).projectOnVector(e),this.sub(DC)}reflect(e){return this.sub(DC.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const n=Math.sqrt(this.lengthSq()*e.lengthSq());if(n===0)return Math.PI/2;const r=this.dot(e)/n;return Math.acos(Oa(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,r=this.y-e.y,i=this.z-e.z;return n*n+r*r+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,n,r){const i=Math.sin(n)*e;return this.x=i*Math.sin(r),this.y=Math.cos(n)*e,this.z=i*Math.cos(r),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,n,r){return this.x=e*Math.sin(n),this.y=r,this.z=e*Math.cos(n),this}setFromMatrixPosition(e){const n=e.elements;return this.x=n[12],this.y=n[13],this.z=n[14],this}setFromMatrixScale(e){const n=this.setFromMatrixColumn(e,0).length(),r=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=n,this.y=r,this.z=i,this}setFromMatrixColumn(e,n){return this.fromArray(e.elements,n*4)}setFromMatrix3Column(e,n){return this.fromArray(e.elements,n*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this.z=e[n+2],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e[n+2]=this.z,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this.z=e.getZ(n),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=(Math.random()-.5)*2,n=Math.random()*Math.PI*2,r=Math.sqrt(1-e**2);return this.x=r*Math.cos(n),this.y=r*Math.sin(n),this.z=e,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const DC=new qe,vG=new vm;class rl{constructor(e=new qe(1/0,1/0,1/0),n=new qe(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=n}set(e,n){return this.min.copy(e),this.max.copy(n),this}setFromArray(e){this.makeEmpty();for(let n=0,r=e.length;n<r;n+=3)this.expandByPoint(Sl.fromArray(e,n));return this}setFromBufferAttribute(e){this.makeEmpty();for(let n=0,r=e.count;n<r;n++)this.expandByPoint(Sl.fromBufferAttribute(e,n));return this}setFromPoints(e){this.makeEmpty();for(let n=0,r=e.length;n<r;n++)this.expandByPoint(e[n]);return this}setFromCenterAndSize(e,n){const r=Sl.copy(n).multiplyScalar(.5);return this.min.copy(e).sub(r),this.max.copy(e).add(r),this}setFromObject(e,n=!1){return this.makeEmpty(),this.expandByObject(e,n)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,n=!1){e.updateWorldMatrix(!1,!1);const r=e.geometry;if(r!==void 0){const a=r.getAttribute("position");if(n===!0&&a!==void 0&&e.isInstancedMesh!==!0)for(let o=0,l=a.count;o<l;o++)e.isMesh===!0?e.getVertexPosition(o,Sl):Sl.fromBufferAttribute(a,o),Sl.applyMatrix4(e.matrixWorld),this.expandByPoint(Sl);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),S_.copy(e.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),S_.copy(r.boundingBox)),S_.applyMatrix4(e.matrixWorld),this.union(S_)}const i=e.children;for(let a=0,o=i.length;a<o;a++)this.expandByObject(i[a],n);return this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y||e.z<this.min.z||e.z>this.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,n){return n.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y||e.max.z<this.min.z||e.min.z>this.max.z)}intersectsSphere(e){return this.clampPoint(e.center,Sl),Sl.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let n,r;return e.normal.x>0?(n=e.normal.x*this.min.x,r=e.normal.x*this.max.x):(n=e.normal.x*this.max.x,r=e.normal.x*this.min.x),e.normal.y>0?(n+=e.normal.y*this.min.y,r+=e.normal.y*this.max.y):(n+=e.normal.y*this.max.y,r+=e.normal.y*this.min.y),e.normal.z>0?(n+=e.normal.z*this.min.z,r+=e.normal.z*this.max.z):(n+=e.normal.z*this.max.z,r+=e.normal.z*this.min.z),n<=-e.constant&&r>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Wb),M_.subVectors(this.max,Wb),Ip.subVectors(e.a,Wb),Up.subVectors(e.b,Wb),zp.subVectors(e.c,Wb),Ad.subVectors(Up,Ip),Cd.subVectors(zp,Up),ff.subVectors(Ip,zp);let n=[0,-Ad.z,Ad.y,0,-Cd.z,Cd.y,0,-ff.z,ff.y,Ad.z,0,-Ad.x,Cd.z,0,-Cd.x,ff.z,0,-ff.x,-Ad.y,Ad.x,0,-Cd.y,Cd.x,0,-ff.y,ff.x,0];return!RC(n,Ip,Up,zp,M_)||(n=[1,0,0,0,1,0,0,0,1],!RC(n,Ip,Up,zp,M_))?!1:(N_.crossVectors(Ad,Cd),n=[N_.x,N_.y,N_.z],RC(n,Ip,Up,zp,M_))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Sl).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Sl).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(Zc[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Zc[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Zc[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Zc[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Zc[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Zc[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Zc[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Zc[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Zc),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const Zc=[new qe,new qe,new qe,new qe,new qe,new qe,new qe,new qe],Sl=new qe,S_=new rl,Ip=new qe,Up=new qe,zp=new qe,Ad=new qe,Cd=new qe,ff=new qe,Wb=new qe,M_=new qe,N_=new qe,mf=new qe;function RC(t,e,n,r,i){for(let a=0,o=t.length-3;a<=o;a+=3){mf.fromArray(t,a);const l=i.x*Math.abs(mf.x)+i.y*Math.abs(mf.y)+i.z*Math.abs(mf.z),c=e.dot(mf),u=n.dot(mf),d=r.dot(mf);if(Math.max(-Math.max(c,u,d),Math.min(c,u,d))>l)return!1}return!0}const vFe=new rl,Kb=new qe,OC=new qe;class hc{constructor(e=new qe,n=-1){this.center=e,this.radius=n}set(e,n){return this.center.copy(e),this.radius=n,this}setFromPoints(e,n){const r=this.center;n!==void 0?r.copy(n):vFe.setFromPoints(e).getCenter(r);let i=0;for(let a=0,o=e.length;a<o;a++)i=Math.max(i,r.distanceToSquared(e[a]));return this.radius=Math.sqrt(i),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const n=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=n*n}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,n){const r=this.center.distanceToSquared(e);return n.copy(e),r>this.radius*this.radius&&(n.sub(this.center).normalize(),n.multiplyScalar(this.radius).add(this.center)),n}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Kb.subVectors(e,this.center);const n=Kb.lengthSq();if(n>this.radius*this.radius){const r=Math.sqrt(n),i=(r-this.radius)*.5;this.center.addScaledVector(Kb,i/r),this.radius+=i}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(OC.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Kb.copy(e.center).add(OC)),this.expandByPoint(Kb.copy(e.center).sub(OC))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const Jc=new qe,LC=new qe,k_=new qe,jd=new qe,FC=new qe,E_=new qe,IC=new qe;class oL{constructor(e=new qe,n=new qe(0,0,-1)){this.origin=e,this.direction=n}set(e,n){return this.origin.copy(e),this.direction.copy(n),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,n){return n.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Jc)),this}closestPointToPoint(e,n){n.subVectors(e,this.origin);const r=n.dot(this.direction);return r<0?n.copy(this.origin):n.copy(this.origin).addScaledVector(this.direction,r)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const n=Jc.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(Jc.copy(this.origin).addScaledVector(this.direction,n),Jc.distanceToSquared(e))}distanceSqToSegment(e,n,r,i){LC.copy(e).add(n).multiplyScalar(.5),k_.copy(n).sub(e).normalize(),jd.copy(this.origin).sub(LC);const a=e.distanceTo(n)*.5,o=-this.direction.dot(k_),l=jd.dot(this.direction),c=-jd.dot(k_),u=jd.lengthSq(),d=Math.abs(1-o*o);let f,p,m,x;if(d>0)if(f=o*c-l,p=o*l-c,x=a*d,f>=0)if(p>=-x)if(p<=x){const b=1/d;f*=b,p*=b,m=f*(f+o*p+2*l)+p*(o*f+p+2*c)+u}else p=a,f=Math.max(0,-(o*p+l)),m=-f*f+p*(p+2*c)+u;else p=-a,f=Math.max(0,-(o*p+l)),m=-f*f+p*(p+2*c)+u;else p<=-x?(f=Math.max(0,-(-o*a+l)),p=f>0?-a:Math.min(Math.max(-a,-c),a),m=-f*f+p*(p+2*c)+u):p<=x?(f=0,p=Math.min(Math.max(-a,-c),a),m=p*(p+2*c)+u):(f=Math.max(0,-(o*a+l)),p=f>0?a:Math.min(Math.max(-a,-c),a),m=-f*f+p*(p+2*c)+u);else p=o>0?-a:a,f=Math.max(0,-(o*p+l)),m=-f*f+p*(p+2*c)+u;return r&&r.copy(this.origin).addScaledVector(this.direction,f),i&&i.copy(LC).addScaledVector(k_,p),m}intersectSphere(e,n){Jc.subVectors(e.center,this.origin);const r=Jc.dot(this.direction),i=Jc.dot(Jc)-r*r,a=e.radius*e.radius;if(i>a)return null;const o=Math.sqrt(a-i),l=r-o,c=r+o;return c<0?null:l<0?this.at(c,n):this.at(l,n)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const n=e.normal.dot(this.direction);if(n===0)return e.distanceToPoint(this.origin)===0?0:null;const r=-(this.origin.dot(e.normal)+e.constant)/n;return r>=0?r:null}intersectPlane(e,n){const r=this.distanceToPlane(e);return r===null?null:this.at(r,n)}intersectsPlane(e){const n=e.distanceToPoint(this.origin);return n===0||e.normal.dot(this.direction)*n<0}intersectBox(e,n){let r,i,a,o,l,c;const u=1/this.direction.x,d=1/this.direction.y,f=1/this.direction.z,p=this.origin;return u>=0?(r=(e.min.x-p.x)*u,i=(e.max.x-p.x)*u):(r=(e.max.x-p.x)*u,i=(e.min.x-p.x)*u),d>=0?(a=(e.min.y-p.y)*d,o=(e.max.y-p.y)*d):(a=(e.max.y-p.y)*d,o=(e.min.y-p.y)*d),r>o||a>i||((a>r||isNaN(r))&&(r=a),(o<i||isNaN(i))&&(i=o),f>=0?(l=(e.min.z-p.z)*f,c=(e.max.z-p.z)*f):(l=(e.max.z-p.z)*f,c=(e.min.z-p.z)*f),r>c||l>i)||((l>r||r!==r)&&(r=l),(c<i||i!==i)&&(i=c),i<0)?null:this.at(r>=0?r:i,n)}intersectsBox(e){return this.intersectBox(e,Jc)!==null}intersectTriangle(e,n,r,i,a){FC.subVectors(n,e),E_.subVectors(r,e),IC.crossVectors(FC,E_);let o=this.direction.dot(IC),l;if(o>0){if(i)return null;l=1}else if(o<0)l=-1,o=-o;else return null;jd.subVectors(this.origin,e);const c=l*this.direction.dot(E_.crossVectors(jd,E_));if(c<0)return null;const u=l*this.direction.dot(FC.cross(jd));if(u<0||c+u>o)return null;const d=-l*jd.dot(IC);return d<0?null:this.at(d/o,a)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class zr{constructor(e,n,r,i,a,o,l,c,u,d,f,p,m,x,b,y){zr.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,n,r,i,a,o,l,c,u,d,f,p,m,x,b,y)}set(e,n,r,i,a,o,l,c,u,d,f,p,m,x,b,y){const v=this.elements;return v[0]=e,v[4]=n,v[8]=r,v[12]=i,v[1]=a,v[5]=o,v[9]=l,v[13]=c,v[2]=u,v[6]=d,v[10]=f,v[14]=p,v[3]=m,v[7]=x,v[11]=b,v[15]=y,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new zr().fromArray(this.elements)}copy(e){const n=this.elements,r=e.elements;return n[0]=r[0],n[1]=r[1],n[2]=r[2],n[3]=r[3],n[4]=r[4],n[5]=r[5],n[6]=r[6],n[7]=r[7],n[8]=r[8],n[9]=r[9],n[10]=r[10],n[11]=r[11],n[12]=r[12],n[13]=r[13],n[14]=r[14],n[15]=r[15],this}copyPosition(e){const n=this.elements,r=e.elements;return n[12]=r[12],n[13]=r[13],n[14]=r[14],this}setFromMatrix3(e){const n=e.elements;return this.set(n[0],n[3],n[6],0,n[1],n[4],n[7],0,n[2],n[5],n[8],0,0,0,0,1),this}extractBasis(e,n,r){return e.setFromMatrixColumn(this,0),n.setFromMatrixColumn(this,1),r.setFromMatrixColumn(this,2),this}makeBasis(e,n,r){return this.set(e.x,n.x,r.x,0,e.y,n.y,r.y,0,e.z,n.z,r.z,0,0,0,0,1),this}extractRotation(e){const n=this.elements,r=e.elements,i=1/Bp.setFromMatrixColumn(e,0).length(),a=1/Bp.setFromMatrixColumn(e,1).length(),o=1/Bp.setFromMatrixColumn(e,2).length();return n[0]=r[0]*i,n[1]=r[1]*i,n[2]=r[2]*i,n[3]=0,n[4]=r[4]*a,n[5]=r[5]*a,n[6]=r[6]*a,n[7]=0,n[8]=r[8]*o,n[9]=r[9]*o,n[10]=r[10]*o,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromEuler(e){const n=this.elements,r=e.x,i=e.y,a=e.z,o=Math.cos(r),l=Math.sin(r),c=Math.cos(i),u=Math.sin(i),d=Math.cos(a),f=Math.sin(a);if(e.order==="XYZ"){const p=o*d,m=o*f,x=l*d,b=l*f;n[0]=c*d,n[4]=-c*f,n[8]=u,n[1]=m+x*u,n[5]=p-b*u,n[9]=-l*c,n[2]=b-p*u,n[6]=x+m*u,n[10]=o*c}else if(e.order==="YXZ"){const p=c*d,m=c*f,x=u*d,b=u*f;n[0]=p+b*l,n[4]=x*l-m,n[8]=o*u,n[1]=o*f,n[5]=o*d,n[9]=-l,n[2]=m*l-x,n[6]=b+p*l,n[10]=o*c}else if(e.order==="ZXY"){const p=c*d,m=c*f,x=u*d,b=u*f;n[0]=p-b*l,n[4]=-o*f,n[8]=x+m*l,n[1]=m+x*l,n[5]=o*d,n[9]=b-p*l,n[2]=-o*u,n[6]=l,n[10]=o*c}else if(e.order==="ZYX"){const p=o*d,m=o*f,x=l*d,b=l*f;n[0]=c*d,n[4]=x*u-m,n[8]=p*u+b,n[1]=c*f,n[5]=b*u+p,n[9]=m*u-x,n[2]=-u,n[6]=l*c,n[10]=o*c}else if(e.order==="YZX"){const p=o*c,m=o*u,x=l*c,b=l*u;n[0]=c*d,n[4]=b-p*f,n[8]=x*f+m,n[1]=f,n[5]=o*d,n[9]=-l*d,n[2]=-u*d,n[6]=m*f+x,n[10]=p-b*f}else if(e.order==="XZY"){const p=o*c,m=o*u,x=l*c,b=l*u;n[0]=c*d,n[4]=-f,n[8]=u*d,n[1]=p*f+b,n[5]=o*d,n[9]=m*f-x,n[2]=x*f-m,n[6]=l*d,n[10]=b*f+p}return n[3]=0,n[7]=0,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromQuaternion(e){return this.compose(wFe,e,_Fe)}lookAt(e,n,r){const i=this.elements;return io.subVectors(e,n),io.lengthSq()===0&&(io.z=1),io.normalize(),Pd.crossVectors(r,io),Pd.lengthSq()===0&&(Math.abs(r.z)===1?io.x+=1e-4:io.z+=1e-4,io.normalize(),Pd.crossVectors(r,io)),Pd.normalize(),T_.crossVectors(io,Pd),i[0]=Pd.x,i[4]=T_.x,i[8]=io.x,i[1]=Pd.y,i[5]=T_.y,i[9]=io.y,i[2]=Pd.z,i[6]=T_.z,i[10]=io.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){const r=e.elements,i=n.elements,a=this.elements,o=r[0],l=r[4],c=r[8],u=r[12],d=r[1],f=r[5],p=r[9],m=r[13],x=r[2],b=r[6],y=r[10],v=r[14],S=r[3],N=r[7],T=r[11],k=r[15],C=i[0],E=i[4],D=i[8],A=i[12],R=i[1],U=i[5],F=i[9],$=i[13],j=i[2],H=i[6],K=i[10],V=i[14],Q=i[3],Z=i[7],ae=i[11],B=i[15];return a[0]=o*C+l*R+c*j+u*Q,a[4]=o*E+l*U+c*H+u*Z,a[8]=o*D+l*F+c*K+u*ae,a[12]=o*A+l*$+c*V+u*B,a[1]=d*C+f*R+p*j+m*Q,a[5]=d*E+f*U+p*H+m*Z,a[9]=d*D+f*F+p*K+m*ae,a[13]=d*A+f*$+p*V+m*B,a[2]=x*C+b*R+y*j+v*Q,a[6]=x*E+b*U+y*H+v*Z,a[10]=x*D+b*F+y*K+v*ae,a[14]=x*A+b*$+y*V+v*B,a[3]=S*C+N*R+T*j+k*Q,a[7]=S*E+N*U+T*H+k*Z,a[11]=S*D+N*F+T*K+k*ae,a[15]=S*A+N*$+T*V+k*B,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[4]*=e,n[8]*=e,n[12]*=e,n[1]*=e,n[5]*=e,n[9]*=e,n[13]*=e,n[2]*=e,n[6]*=e,n[10]*=e,n[14]*=e,n[3]*=e,n[7]*=e,n[11]*=e,n[15]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[4],i=e[8],a=e[12],o=e[1],l=e[5],c=e[9],u=e[13],d=e[2],f=e[6],p=e[10],m=e[14],x=e[3],b=e[7],y=e[11],v=e[15];return x*(+a*c*f-i*u*f-a*l*p+r*u*p+i*l*m-r*c*m)+b*(+n*c*m-n*u*p+a*o*p-i*o*m+i*u*d-a*c*d)+y*(+n*u*f-n*l*m-a*o*f+r*o*m+a*l*d-r*u*d)+v*(-i*l*d-n*c*f+n*l*p+i*o*f-r*o*p+r*c*d)}transpose(){const e=this.elements;let n;return n=e[1],e[1]=e[4],e[4]=n,n=e[2],e[2]=e[8],e[8]=n,n=e[6],e[6]=e[9],e[9]=n,n=e[3],e[3]=e[12],e[12]=n,n=e[7],e[7]=e[13],e[13]=n,n=e[11],e[11]=e[14],e[14]=n,this}setPosition(e,n,r){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=n,i[14]=r),this}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],a=e[3],o=e[4],l=e[5],c=e[6],u=e[7],d=e[8],f=e[9],p=e[10],m=e[11],x=e[12],b=e[13],y=e[14],v=e[15],S=f*y*u-b*p*u+b*c*m-l*y*m-f*c*v+l*p*v,N=x*p*u-d*y*u-x*c*m+o*y*m+d*c*v-o*p*v,T=d*b*u-x*f*u+x*l*m-o*b*m-d*l*v+o*f*v,k=x*f*c-d*b*c-x*l*p+o*b*p+d*l*y-o*f*y,C=n*S+r*N+i*T+a*k;if(C===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const E=1/C;return e[0]=S*E,e[1]=(b*p*a-f*y*a-b*i*m+r*y*m+f*i*v-r*p*v)*E,e[2]=(l*y*a-b*c*a+b*i*u-r*y*u-l*i*v+r*c*v)*E,e[3]=(f*c*a-l*p*a-f*i*u+r*p*u+l*i*m-r*c*m)*E,e[4]=N*E,e[5]=(d*y*a-x*p*a+x*i*m-n*y*m-d*i*v+n*p*v)*E,e[6]=(x*c*a-o*y*a-x*i*u+n*y*u+o*i*v-n*c*v)*E,e[7]=(o*p*a-d*c*a+d*i*u-n*p*u-o*i*m+n*c*m)*E,e[8]=T*E,e[9]=(x*f*a-d*b*a-x*r*m+n*b*m+d*r*v-n*f*v)*E,e[10]=(o*b*a-x*l*a+x*r*u-n*b*u-o*r*v+n*l*v)*E,e[11]=(d*l*a-o*f*a-d*r*u+n*f*u+o*r*m-n*l*m)*E,e[12]=k*E,e[13]=(d*b*i-x*f*i+x*r*p-n*b*p-d*r*y+n*f*y)*E,e[14]=(x*l*i-o*b*i-x*r*c+n*b*c+o*r*y-n*l*y)*E,e[15]=(o*f*i-d*l*i+d*r*c-n*f*c-o*r*p+n*l*p)*E,this}scale(e){const n=this.elements,r=e.x,i=e.y,a=e.z;return n[0]*=r,n[4]*=i,n[8]*=a,n[1]*=r,n[5]*=i,n[9]*=a,n[2]*=r,n[6]*=i,n[10]*=a,n[3]*=r,n[7]*=i,n[11]*=a,this}getMaxScaleOnAxis(){const e=this.elements,n=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],r=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(n,r,i))}makeTranslation(e,n,r){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,n,0,0,1,r,0,0,0,1),this}makeRotationX(e){const n=Math.cos(e),r=Math.sin(e);return this.set(1,0,0,0,0,n,-r,0,0,r,n,0,0,0,0,1),this}makeRotationY(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,0,r,0,0,1,0,0,-r,0,n,0,0,0,0,1),this}makeRotationZ(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,-r,0,0,r,n,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,n){const r=Math.cos(n),i=Math.sin(n),a=1-r,o=e.x,l=e.y,c=e.z,u=a*o,d=a*l;return this.set(u*o+r,u*l-i*c,u*c+i*l,0,u*l+i*c,d*l+r,d*c-i*o,0,u*c-i*l,d*c+i*o,a*c*c+r,0,0,0,0,1),this}makeScale(e,n,r){return this.set(e,0,0,0,0,n,0,0,0,0,r,0,0,0,0,1),this}makeShear(e,n,r,i,a,o){return this.set(1,r,a,0,e,1,o,0,n,i,1,0,0,0,0,1),this}compose(e,n,r){const i=this.elements,a=n._x,o=n._y,l=n._z,c=n._w,u=a+a,d=o+o,f=l+l,p=a*u,m=a*d,x=a*f,b=o*d,y=o*f,v=l*f,S=c*u,N=c*d,T=c*f,k=r.x,C=r.y,E=r.z;return i[0]=(1-(b+v))*k,i[1]=(m+T)*k,i[2]=(x-N)*k,i[3]=0,i[4]=(m-T)*C,i[5]=(1-(p+v))*C,i[6]=(y+S)*C,i[7]=0,i[8]=(x+N)*E,i[9]=(y-S)*E,i[10]=(1-(p+b))*E,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,n,r){const i=this.elements;let a=Bp.set(i[0],i[1],i[2]).length();const o=Bp.set(i[4],i[5],i[6]).length(),l=Bp.set(i[8],i[9],i[10]).length();this.determinant()<0&&(a=-a),e.x=i[12],e.y=i[13],e.z=i[14],Ml.copy(this);const u=1/a,d=1/o,f=1/l;return Ml.elements[0]*=u,Ml.elements[1]*=u,Ml.elements[2]*=u,Ml.elements[4]*=d,Ml.elements[5]*=d,Ml.elements[6]*=d,Ml.elements[8]*=f,Ml.elements[9]*=f,Ml.elements[10]*=f,n.setFromRotationMatrix(Ml),r.x=a,r.y=o,r.z=l,this}makePerspective(e,n,r,i,a,o,l=cc){const c=this.elements,u=2*a/(n-e),d=2*a/(r-i),f=(n+e)/(n-e),p=(r+i)/(r-i);let m,x;if(l===cc)m=-(o+a)/(o-a),x=-2*o*a/(o-a);else if(l===by)m=-o/(o-a),x=-o*a/(o-a);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+l);return c[0]=u,c[4]=0,c[8]=f,c[12]=0,c[1]=0,c[5]=d,c[9]=p,c[13]=0,c[2]=0,c[6]=0,c[10]=m,c[14]=x,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,n,r,i,a,o,l=cc){const c=this.elements,u=1/(n-e),d=1/(r-i),f=1/(o-a),p=(n+e)*u,m=(r+i)*d;let x,b;if(l===cc)x=(o+a)*f,b=-2*f;else if(l===by)x=a*f,b=-1*f;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+l);return c[0]=2*u,c[4]=0,c[8]=0,c[12]=-p,c[1]=0,c[5]=2*d,c[9]=0,c[13]=-m,c[2]=0,c[6]=0,c[10]=b,c[14]=-x,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){const n=this.elements,r=e.elements;for(let i=0;i<16;i++)if(n[i]!==r[i])return!1;return!0}fromArray(e,n=0){for(let r=0;r<16;r++)this.elements[r]=e[r+n];return this}toArray(e=[],n=0){const r=this.elements;return e[n]=r[0],e[n+1]=r[1],e[n+2]=r[2],e[n+3]=r[3],e[n+4]=r[4],e[n+5]=r[5],e[n+6]=r[6],e[n+7]=r[7],e[n+8]=r[8],e[n+9]=r[9],e[n+10]=r[10],e[n+11]=r[11],e[n+12]=r[12],e[n+13]=r[13],e[n+14]=r[14],e[n+15]=r[15],e}}const Bp=new qe,Ml=new zr,wFe=new qe(0,0,0),_Fe=new qe(1,1,1),Pd=new qe,T_=new qe,io=new qe,wG=new zr,_G=new vm;class fv{constructor(e=0,n=0,r=0,i=fv.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=n,this._z=r,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,n,r,i=this._order){return this._x=e,this._y=n,this._z=r,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,n=this._order,r=!0){const i=e.elements,a=i[0],o=i[4],l=i[8],c=i[1],u=i[5],d=i[9],f=i[2],p=i[6],m=i[10];switch(n){case"XYZ":this._y=Math.asin(Oa(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-d,m),this._z=Math.atan2(-o,a)):(this._x=Math.atan2(p,u),this._z=0);break;case"YXZ":this._x=Math.asin(-Oa(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(l,m),this._z=Math.atan2(c,u)):(this._y=Math.atan2(-f,a),this._z=0);break;case"ZXY":this._x=Math.asin(Oa(p,-1,1)),Math.abs(p)<.9999999?(this._y=Math.atan2(-f,m),this._z=Math.atan2(-o,u)):(this._y=0,this._z=Math.atan2(c,a));break;case"ZYX":this._y=Math.asin(-Oa(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(p,m),this._z=Math.atan2(c,a)):(this._x=0,this._z=Math.atan2(-o,u));break;case"YZX":this._z=Math.asin(Oa(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-d,u),this._y=Math.atan2(-f,a)):(this._x=0,this._y=Math.atan2(l,m));break;case"XZY":this._z=Math.asin(-Oa(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(p,u),this._y=Math.atan2(l,a)):(this._x=Math.atan2(-d,m),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+n)}return this._order=n,r===!0&&this._onChangeCallback(),this}setFromQuaternion(e,n,r){return wG.makeRotationFromQuaternion(e),this.setFromRotationMatrix(wG,n,r)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return _G.setFromEuler(this),this.setFromQuaternion(_G,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],n=0){return e[n]=this._x,e[n+1]=this._y,e[n+2]=this._z,e[n+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}fv.DEFAULT_ORDER="XYZ";class QJ{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}let SFe=0;const SG=new qe,Hp=new vm,eu=new zr,A_=new qe,Xb=new qe,MFe=new qe,NFe=new vm,MG=new qe(1,0,0),NG=new qe(0,1,0),kG=new qe(0,0,1),kFe={type:"added"},EFe={type:"removed"};class ps extends jm{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:SFe++}),this.uuid=Cu(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=ps.DEFAULT_UP.clone();const e=new qe,n=new fv,r=new vm,i=new qe(1,1,1);function a(){r.setFromEuler(n,!1)}function o(){n.setFromQuaternion(r,void 0,!1)}n._onChange(a),r._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:n},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new zr},normalMatrix:{value:new Ln}}),this.matrix=new zr,this.matrixWorld=new zr,this.matrixAutoUpdate=ps.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=ps.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new QJ,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,n){this.quaternion.setFromAxisAngle(e,n)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,n){return Hp.setFromAxisAngle(e,n),this.quaternion.multiply(Hp),this}rotateOnWorldAxis(e,n){return Hp.setFromAxisAngle(e,n),this.quaternion.premultiply(Hp),this}rotateX(e){return this.rotateOnAxis(MG,e)}rotateY(e){return this.rotateOnAxis(NG,e)}rotateZ(e){return this.rotateOnAxis(kG,e)}translateOnAxis(e,n){return SG.copy(e).applyQuaternion(this.quaternion),this.position.add(SG.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(MG,e)}translateY(e){return this.translateOnAxis(NG,e)}translateZ(e){return this.translateOnAxis(kG,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(eu.copy(this.matrixWorld).invert())}lookAt(e,n,r){e.isVector3?A_.copy(e):A_.set(e,n,r);const i=this.parent;this.updateWorldMatrix(!0,!1),Xb.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?eu.lookAt(Xb,A_,this.up):eu.lookAt(A_,Xb,this.up),this.quaternion.setFromRotationMatrix(eu),i&&(eu.extractRotation(i.matrixWorld),Hp.setFromRotationMatrix(eu),this.quaternion.premultiply(Hp.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(kFe)):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let r=0;r<arguments.length;r++)this.remove(arguments[r]);return this}const n=this.children.indexOf(e);return n!==-1&&(e.parent=null,this.children.splice(n,1),e.dispatchEvent(EFe)),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),eu.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),eu.multiply(e.parent.matrixWorld)),e.applyMatrix4(eu),this.add(e),e.updateWorldMatrix(!1,!0),this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,n){if(this[e]===n)return this;for(let r=0,i=this.children.length;r<i;r++){const o=this.children[r].getObjectByProperty(e,n);if(o!==void 0)return o}}getObjectsByProperty(e,n,r=[]){this[e]===n&&r.push(this);const i=this.children;for(let a=0,o=i.length;a<o;a++)i[a].getObjectsByProperty(e,n,r);return r}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Xb,e,MFe),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Xb,NFe,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const n=this.matrixWorld.elements;return e.set(n[8],n[9],n[10]).normalize()}raycast(){}traverse(e){e(this);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].traverseVisible(e)}traverseAncestors(e){const n=this.parent;n!==null&&(e(n),n.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,e=!0);const n=this.children;for(let r=0,i=n.length;r<i;r++){const a=n[r];(a.matrixWorldAutoUpdate===!0||e===!0)&&a.updateMatrixWorld(e)}}updateWorldMatrix(e,n){const r=this.parent;if(e===!0&&r!==null&&r.matrixWorldAutoUpdate===!0&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),n===!0){const i=this.children;for(let a=0,o=i.length;a<o;a++){const l=i[a];l.matrixWorldAutoUpdate===!0&&l.updateWorldMatrix(!1,!0)}}}toJSON(e){const n=e===void 0||typeof e=="string",r={};n&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},r.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.visibility=this._visibility,i.active=this._active,i.bounds=this._bounds.map(l=>({boxInitialized:l.boxInitialized,boxMin:l.box.min.toArray(),boxMax:l.box.max.toArray(),sphereInitialized:l.sphereInitialized,sphereRadius:l.sphere.radius,sphereCenter:l.sphere.center.toArray()})),i.maxGeometryCount=this._maxGeometryCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.geometryCount=this._geometryCount,i.matricesTexture=this._matricesTexture.toJSON(e),this.boundingSphere!==null&&(i.boundingSphere={center:i.boundingSphere.center.toArray(),radius:i.boundingSphere.radius}),this.boundingBox!==null&&(i.boundingBox={min:i.boundingBox.min.toArray(),max:i.boundingBox.max.toArray()}));function a(l,c){return l[c.uuid]===void 0&&(l[c.uuid]=c.toJSON(e)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=a(e.geometries,this.geometry);const l=this.geometry.parameters;if(l!==void 0&&l.shapes!==void 0){const c=l.shapes;if(Array.isArray(c))for(let u=0,d=c.length;u<d;u++){const f=c[u];a(e.shapes,f)}else a(e.shapes,c)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(a(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const l=[];for(let c=0,u=this.material.length;c<u;c++)l.push(a(e.materials,this.material[c]));i.material=l}else i.material=a(e.materials,this.material);if(this.children.length>0){i.children=[];for(let l=0;l<this.children.length;l++)i.children.push(this.children[l].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let l=0;l<this.animations.length;l++){const c=this.animations[l];i.animations.push(a(e.animations,c))}}if(n){const l=o(e.geometries),c=o(e.materials),u=o(e.textures),d=o(e.images),f=o(e.shapes),p=o(e.skeletons),m=o(e.animations),x=o(e.nodes);l.length>0&&(r.geometries=l),c.length>0&&(r.materials=c),u.length>0&&(r.textures=u),d.length>0&&(r.images=d),f.length>0&&(r.shapes=f),p.length>0&&(r.skeletons=p),m.length>0&&(r.animations=m),x.length>0&&(r.nodes=x)}return r.object=i,r;function o(l){const c=[];for(const u in l){const d=l[u];delete d.metadata,c.push(d)}return c}}clone(e){return new this.constructor().copy(this,e)}copy(e,n=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),n===!0)for(let r=0;r<e.children.length;r++){const i=e.children[r];this.add(i.clone())}return this}}ps.DEFAULT_UP=new qe(0,1,0);ps.DEFAULT_MATRIX_AUTO_UPDATE=!0;ps.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Nl=new qe,tu=new qe,UC=new qe,nu=new qe,$p=new qe,Vp=new qe,EG=new qe,zC=new qe,BC=new qe,HC=new qe;let C_=!1;class kl{constructor(e=new qe,n=new qe,r=new qe){this.a=e,this.b=n,this.c=r}static getNormal(e,n,r,i){i.subVectors(r,n),Nl.subVectors(e,n),i.cross(Nl);const a=i.lengthSq();return a>0?i.multiplyScalar(1/Math.sqrt(a)):i.set(0,0,0)}static getBarycoord(e,n,r,i,a){Nl.subVectors(i,n),tu.subVectors(r,n),UC.subVectors(e,n);const o=Nl.dot(Nl),l=Nl.dot(tu),c=Nl.dot(UC),u=tu.dot(tu),d=tu.dot(UC),f=o*u-l*l;if(f===0)return a.set(-2,-1,-1);const p=1/f,m=(u*c-l*d)*p,x=(o*d-l*c)*p;return a.set(1-m-x,x,m)}static containsPoint(e,n,r,i){return this.getBarycoord(e,n,r,i,nu),nu.x>=0&&nu.y>=0&&nu.x+nu.y<=1}static getUV(e,n,r,i,a,o,l,c){return C_===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),C_=!0),this.getInterpolation(e,n,r,i,a,o,l,c)}static getInterpolation(e,n,r,i,a,o,l,c){return this.getBarycoord(e,n,r,i,nu),c.setScalar(0),c.addScaledVector(a,nu.x),c.addScaledVector(o,nu.y),c.addScaledVector(l,nu.z),c}static isFrontFacing(e,n,r,i){return Nl.subVectors(r,n),tu.subVectors(e,n),Nl.cross(tu).dot(i)<0}set(e,n,r){return this.a.copy(e),this.b.copy(n),this.c.copy(r),this}setFromPointsAndIndices(e,n,r,i){return this.a.copy(e[n]),this.b.copy(e[r]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,n,r,i){return this.a.fromBufferAttribute(e,n),this.b.fromBufferAttribute(e,r),this.c.fromBufferAttribute(e,i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Nl.subVectors(this.c,this.b),tu.subVectors(this.a,this.b),Nl.cross(tu).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return kl.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return kl.getBarycoord(e,this.a,this.b,this.c,n)}getUV(e,n,r,i,a){return C_===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),C_=!0),kl.getInterpolation(e,this.a,this.b,this.c,n,r,i,a)}getInterpolation(e,n,r,i,a){return kl.getInterpolation(e,this.a,this.b,this.c,n,r,i,a)}containsPoint(e){return kl.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return kl.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,n){const r=this.a,i=this.b,a=this.c;let o,l;$p.subVectors(i,r),Vp.subVectors(a,r),zC.subVectors(e,r);const c=$p.dot(zC),u=Vp.dot(zC);if(c<=0&&u<=0)return n.copy(r);BC.subVectors(e,i);const d=$p.dot(BC),f=Vp.dot(BC);if(d>=0&&f<=d)return n.copy(i);const p=c*f-d*u;if(p<=0&&c>=0&&d<=0)return o=c/(c-d),n.copy(r).addScaledVector($p,o);HC.subVectors(e,a);const m=$p.dot(HC),x=Vp.dot(HC);if(x>=0&&m<=x)return n.copy(a);const b=m*u-c*x;if(b<=0&&u>=0&&x<=0)return l=u/(u-x),n.copy(r).addScaledVector(Vp,l);const y=d*x-m*f;if(y<=0&&f-d>=0&&m-x>=0)return EG.subVectors(a,i),l=(f-d)/(f-d+(m-x)),n.copy(i).addScaledVector(EG,l);const v=1/(y+b+p);return o=b*v,l=p*v,n.copy(r).addScaledVector($p,o).addScaledVector(Vp,l)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const ZJ={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},Dd={h:0,s:0,l:0},j_={h:0,s:0,l:0};function $C(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+(e-t)*6*n:n<1/2?e:n<2/3?t+(e-t)*6*(2/3-n):t}let Zt=class{constructor(e,n,r){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,n,r)}set(e,n,r){if(n===void 0&&r===void 0){const i=e;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(e,n,r);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,n=Ra){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Er.toWorkingColorSpace(this,n),this}setRGB(e,n,r,i=Er.workingColorSpace){return this.r=e,this.g=n,this.b=r,Er.toWorkingColorSpace(this,i),this}setHSL(e,n,r,i=Er.workingColorSpace){if(e=sL(e,1),n=Oa(n,0,1),r=Oa(r,0,1),n===0)this.r=this.g=this.b=r;else{const a=r<=.5?r*(1+n):r+n-r*n,o=2*r-a;this.r=$C(o,a,e+1/3),this.g=$C(o,a,e),this.b=$C(o,a,e-1/3)}return Er.toWorkingColorSpace(this,i),this}setStyle(e,n=Ra){function r(a){a!==void 0&&parseFloat(a)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let a;const o=i[1],l=i[2];switch(o){case"rgb":case"rgba":if(a=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return r(a[4]),this.setRGB(Math.min(255,parseInt(a[1],10))/255,Math.min(255,parseInt(a[2],10))/255,Math.min(255,parseInt(a[3],10))/255,n);if(a=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return r(a[4]),this.setRGB(Math.min(100,parseInt(a[1],10))/100,Math.min(100,parseInt(a[2],10))/100,Math.min(100,parseInt(a[3],10))/100,n);break;case"hsl":case"hsla":if(a=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return r(a[4]),this.setHSL(parseFloat(a[1])/360,parseFloat(a[2])/100,parseFloat(a[3])/100,n);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const a=i[1],o=a.length;if(o===3)return this.setRGB(parseInt(a.charAt(0),16)/15,parseInt(a.charAt(1),16)/15,parseInt(a.charAt(2),16)/15,n);if(o===6)return this.setHex(parseInt(a,16),n);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,n);return this}setColorName(e,n=Ra){const r=ZJ[e.toLowerCase()];return r!==void 0?this.setHex(r,n):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Pg(e.r),this.g=Pg(e.g),this.b=Pg(e.b),this}copyLinearToSRGB(e){return this.r=jC(e.r),this.g=jC(e.g),this.b=jC(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Ra){return Er.fromWorkingColorSpace(qa.copy(this),e),Math.round(Oa(qa.r*255,0,255))*65536+Math.round(Oa(qa.g*255,0,255))*256+Math.round(Oa(qa.b*255,0,255))}getHexString(e=Ra){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=Er.workingColorSpace){Er.fromWorkingColorSpace(qa.copy(this),n);const r=qa.r,i=qa.g,a=qa.b,o=Math.max(r,i,a),l=Math.min(r,i,a);let c,u;const d=(l+o)/2;if(l===o)c=0,u=0;else{const f=o-l;switch(u=d<=.5?f/(o+l):f/(2-o-l),o){case r:c=(i-a)/f+(i<a?6:0);break;case i:c=(a-r)/f+2;break;case a:c=(r-i)/f+4;break}c/=6}return e.h=c,e.s=u,e.l=d,e}getRGB(e,n=Er.workingColorSpace){return Er.fromWorkingColorSpace(qa.copy(this),n),e.r=qa.r,e.g=qa.g,e.b=qa.b,e}getStyle(e=Ra){Er.fromWorkingColorSpace(qa.copy(this),e);const n=qa.r,r=qa.g,i=qa.b;return e!==Ra?`color(${e} ${n.toFixed(3)} ${r.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(n*255)},${Math.round(r*255)},${Math.round(i*255)})`}offsetHSL(e,n,r){return this.getHSL(Dd),this.setHSL(Dd.h+e,Dd.s+n,Dd.l+r)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,n){return this.r=e.r+n.r,this.g=e.g+n.g,this.b=e.b+n.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,n){return this.r+=(e.r-this.r)*n,this.g+=(e.g-this.g)*n,this.b+=(e.b-this.b)*n,this}lerpColors(e,n,r){return this.r=e.r+(n.r-e.r)*r,this.g=e.g+(n.g-e.g)*r,this.b=e.b+(n.b-e.b)*r,this}lerpHSL(e,n){this.getHSL(Dd),e.getHSL(j_);const r=_0(Dd.h,j_.h,n),i=_0(Dd.s,j_.s,n),a=_0(Dd.l,j_.l,n);return this.setHSL(r,i,a),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const n=this.r,r=this.g,i=this.b,a=e.elements;return this.r=a[0]*n+a[3]*r+a[6]*i,this.g=a[1]*n+a[4]*r+a[7]*i,this.b=a[2]*n+a[5]*r+a[8]*i,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,n=0){return this.r=e[n],this.g=e[n+1],this.b=e[n+2],this}toArray(e=[],n=0){return e[n]=this.r,e[n+1]=this.g,e[n+2]=this.b,e}fromBufferAttribute(e,n){return this.r=e.getX(n),this.g=e.getY(n),this.b=e.getZ(n),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}};const qa=new Zt;Zt.NAMES=ZJ;let TFe=0;class Dx extends jm{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:TFe++}),this.uuid=Cu(),this.name="",this.type="Material",this.blending=jg,this.side=Th,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=fD,this.blendDst=mD,this.blendEquation=kf,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Zt(0,0,0),this.blendAlpha=0,this.depthFunc=ZS,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=mG,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Lp,this.stencilZFail=Lp,this.stencilZPass=Lp,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const n in e){const r=e[n];if(r===void 0){console.warn(`THREE.Material: parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){console.warn(`THREE.Material: '${n}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(r):i&&i.isVector3&&r&&r.isVector3?i.copy(r):this[n]=r}}toJSON(e){const n=e===void 0||typeof e=="string";n&&(e={textures:{},images:{}});const r={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.color&&this.color.isColor&&(r.color=this.color.getHex()),this.roughness!==void 0&&(r.roughness=this.roughness),this.metalness!==void 0&&(r.metalness=this.metalness),this.sheen!==void 0&&(r.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(r.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(r.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(r.emissive=this.emissive.getHex()),this.emissiveIntensity&&this.emissiveIntensity!==1&&(r.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(r.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(r.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(r.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(r.shininess=this.shininess),this.clearcoat!==void 0&&(r.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(r.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(r.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(r.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(r.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,r.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.iridescence!==void 0&&(r.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(r.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(r.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(r.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(r.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(r.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(r.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(r.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(r.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(r.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(r.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(r.lightMap=this.lightMap.toJSON(e).uuid,r.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(r.aoMap=this.aoMap.toJSON(e).uuid,r.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(r.bumpMap=this.bumpMap.toJSON(e).uuid,r.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(r.normalMap=this.normalMap.toJSON(e).uuid,r.normalMapType=this.normalMapType,r.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(r.displacementMap=this.displacementMap.toJSON(e).uuid,r.displacementScale=this.displacementScale,r.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(r.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(r.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(r.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(r.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(r.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(r.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(r.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(r.combine=this.combine)),this.envMapIntensity!==void 0&&(r.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(r.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(r.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(r.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(r.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(r.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(r.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(r.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(r.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(r.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(r.size=this.size),this.shadowSide!==null&&(r.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(r.sizeAttenuation=this.sizeAttenuation),this.blending!==jg&&(r.blending=this.blending),this.side!==Th&&(r.side=this.side),this.vertexColors===!0&&(r.vertexColors=!0),this.opacity<1&&(r.opacity=this.opacity),this.transparent===!0&&(r.transparent=!0),this.blendSrc!==fD&&(r.blendSrc=this.blendSrc),this.blendDst!==mD&&(r.blendDst=this.blendDst),this.blendEquation!==kf&&(r.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(r.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(r.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(r.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(r.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(r.blendAlpha=this.blendAlpha),this.depthFunc!==ZS&&(r.depthFunc=this.depthFunc),this.depthTest===!1&&(r.depthTest=this.depthTest),this.depthWrite===!1&&(r.depthWrite=this.depthWrite),this.colorWrite===!1&&(r.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(r.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==mG&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Lp&&(r.stencilFail=this.stencilFail),this.stencilZFail!==Lp&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==Lp&&(r.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(r.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(r.rotation=this.rotation),this.polygonOffset===!0&&(r.polygonOffset=!0),this.polygonOffsetFactor!==0&&(r.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(r.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(r.linewidth=this.linewidth),this.dashSize!==void 0&&(r.dashSize=this.dashSize),this.gapSize!==void 0&&(r.gapSize=this.gapSize),this.scale!==void 0&&(r.scale=this.scale),this.dithering===!0&&(r.dithering=!0),this.alphaTest>0&&(r.alphaTest=this.alphaTest),this.alphaHash===!0&&(r.alphaHash=!0),this.alphaToCoverage===!0&&(r.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(r.premultipliedAlpha=!0),this.forceSinglePass===!0&&(r.forceSinglePass=!0),this.wireframe===!0&&(r.wireframe=!0),this.wireframeLinewidth>1&&(r.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(r.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(r.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(r.flatShading=!0),this.visible===!1&&(r.visible=!1),this.toneMapped===!1&&(r.toneMapped=!1),this.fog===!1&&(r.fog=!1),Object.keys(this.userData).length>0&&(r.userData=this.userData);function i(a){const o=[];for(const l in a){const c=a[l];delete c.metadata,o.push(c)}return o}if(n){const a=i(e.textures),o=i(e.images);a.length>0&&(r.textures=a),o.length>0&&(r.images=o)}return r}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const n=e.clippingPlanes;let r=null;if(n!==null){const i=n.length;r=new Array(i);for(let a=0;a!==i;++a)r[a]=n[a].clone()}return this.clippingPlanes=r,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class JJ extends Dx{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Zt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=rL,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const Oi=new qe,P_=new xn;class go{constructor(e,n,r=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=n,this.count=e!==void 0?e.length/n:0,this.normalized=r,this.usage=yD,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=_u,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return console.warn('THREE.BufferAttribute: "updateRange" is deprecated and removed in r169. Use "addUpdateRange()" instead.'),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,n){this.updateRanges.push({start:e,count:n})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,n,r){e*=this.itemSize,r*=n.itemSize;for(let i=0,a=this.itemSize;i<a;i++)this.array[e+i]=n.array[r+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let n=0,r=this.count;n<r;n++)P_.fromBufferAttribute(this,n),P_.applyMatrix3(e),this.setXY(n,P_.x,P_.y);else if(this.itemSize===3)for(let n=0,r=this.count;n<r;n++)Oi.fromBufferAttribute(this,n),Oi.applyMatrix3(e),this.setXYZ(n,Oi.x,Oi.y,Oi.z);return this}applyMatrix4(e){for(let n=0,r=this.count;n<r;n++)Oi.fromBufferAttribute(this,n),Oi.applyMatrix4(e),this.setXYZ(n,Oi.x,Oi.y,Oi.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)Oi.fromBufferAttribute(this,n),Oi.applyNormalMatrix(e),this.setXYZ(n,Oi.x,Oi.y,Oi.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)Oi.fromBufferAttribute(this,n),Oi.transformDirection(e),this.setXYZ(n,Oi.x,Oi.y,Oi.z);return this}set(e,n=0){return this.array.set(e,n),this}getComponent(e,n){let r=this.array[e*this.itemSize+n];return this.normalized&&(r=ac(r,this.array)),r}setComponent(e,n,r){return this.normalized&&(r=kr(r,this.array)),this.array[e*this.itemSize+n]=r,this}getX(e){let n=this.array[e*this.itemSize];return this.normalized&&(n=ac(n,this.array)),n}setX(e,n){return this.normalized&&(n=kr(n,this.array)),this.array[e*this.itemSize]=n,this}getY(e){let n=this.array[e*this.itemSize+1];return this.normalized&&(n=ac(n,this.array)),n}setY(e,n){return this.normalized&&(n=kr(n,this.array)),this.array[e*this.itemSize+1]=n,this}getZ(e){let n=this.array[e*this.itemSize+2];return this.normalized&&(n=ac(n,this.array)),n}setZ(e,n){return this.normalized&&(n=kr(n,this.array)),this.array[e*this.itemSize+2]=n,this}getW(e){let n=this.array[e*this.itemSize+3];return this.normalized&&(n=ac(n,this.array)),n}setW(e,n){return this.normalized&&(n=kr(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,r){return e*=this.itemSize,this.normalized&&(n=kr(n,this.array),r=kr(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=kr(n,this.array),r=kr(r,this.array),i=kr(i,this.array)),this.array[e+0]=n,this.array[e+1]=r,this.array[e+2]=i,this}setXYZW(e,n,r,i,a){return e*=this.itemSize,this.normalized&&(n=kr(n,this.array),r=kr(r,this.array),i=kr(i,this.array),a=kr(a,this.array)),this.array[e+0]=n,this.array[e+1]=r,this.array[e+2]=i,this.array[e+3]=a,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==yD&&(e.usage=this.usage),e}}class eee extends go{constructor(e,n,r){super(new Uint16Array(e),n,r)}}class tee extends go{constructor(e,n,r){super(new Uint32Array(e),n,r)}}class Ti extends go{constructor(e,n,r){super(new Float32Array(e),n,r)}}let AFe=0;const Fo=new zr,VC=new ps,Gp=new qe,ao=new rl,Yb=new rl,ha=new qe;class ns extends jm{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:AFe++}),this.uuid=Cu(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(WJ(e)?tee:eee)(e,1):this.index=e,this}getAttribute(e){return this.attributes[e]}setAttribute(e,n){return this.attributes[e]=n,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,n,r=0){this.groups.push({start:e,count:n,materialIndex:r})}clearGroups(){this.groups=[]}setDrawRange(e,n){this.drawRange.start=e,this.drawRange.count=n}applyMatrix4(e){const n=this.attributes.position;n!==void 0&&(n.applyMatrix4(e),n.needsUpdate=!0);const r=this.attributes.normal;if(r!==void 0){const a=new Ln().getNormalMatrix(e);r.applyNormalMatrix(a),r.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Fo.makeRotationFromQuaternion(e),this.applyMatrix4(Fo),this}rotateX(e){return Fo.makeRotationX(e),this.applyMatrix4(Fo),this}rotateY(e){return Fo.makeRotationY(e),this.applyMatrix4(Fo),this}rotateZ(e){return Fo.makeRotationZ(e),this.applyMatrix4(Fo),this}translate(e,n,r){return Fo.makeTranslation(e,n,r),this.applyMatrix4(Fo),this}scale(e,n,r){return Fo.makeScale(e,n,r),this.applyMatrix4(Fo),this}lookAt(e){return VC.lookAt(e),VC.updateMatrix(),this.applyMatrix4(VC.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Gp).negate(),this.translate(Gp.x,Gp.y,Gp.z),this}setFromPoints(e){const n=[];for(let r=0,i=e.length;r<i;r++){const a=e[r];n.push(a.x,a.y,a.z||0)}return this.setAttribute("position",new Ti(n,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new rl);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error('THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".',this),this.boundingBox.set(new qe(-1/0,-1/0,-1/0),new qe(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),n)for(let r=0,i=n.length;r<i;r++){const a=n[r];ao.setFromBufferAttribute(a),this.morphTargetsRelative?(ha.addVectors(this.boundingBox.min,ao.min),this.boundingBox.expandByPoint(ha),ha.addVectors(this.boundingBox.max,ao.max),this.boundingBox.expandByPoint(ha)):(this.boundingBox.expandByPoint(ao.min),this.boundingBox.expandByPoint(ao.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new hc);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error('THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".',this),this.boundingSphere.set(new qe,1/0);return}if(e){const r=this.boundingSphere.center;if(ao.setFromBufferAttribute(e),n)for(let a=0,o=n.length;a<o;a++){const l=n[a];Yb.setFromBufferAttribute(l),this.morphTargetsRelative?(ha.addVectors(ao.min,Yb.min),ao.expandByPoint(ha),ha.addVectors(ao.max,Yb.max),ao.expandByPoint(ha)):(ao.expandByPoint(Yb.min),ao.expandByPoint(Yb.max))}ao.getCenter(r);let i=0;for(let a=0,o=e.count;a<o;a++)ha.fromBufferAttribute(e,a),i=Math.max(i,r.distanceToSquared(ha));if(n)for(let a=0,o=n.length;a<o;a++){const l=n[a],c=this.morphTargetsRelative;for(let u=0,d=l.count;u<d;u++)ha.fromBufferAttribute(l,u),c&&(Gp.fromBufferAttribute(e,u),ha.add(Gp)),i=Math.max(i,r.distanceToSquared(ha))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,n=this.attributes;if(e===null||n.position===void 0||n.normal===void 0||n.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const r=e.array,i=n.position.array,a=n.normal.array,o=n.uv.array,l=i.length/3;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new go(new Float32Array(4*l),4));const c=this.getAttribute("tangent").array,u=[],d=[];for(let R=0;R<l;R++)u[R]=new qe,d[R]=new qe;const f=new qe,p=new qe,m=new qe,x=new xn,b=new xn,y=new xn,v=new qe,S=new qe;function N(R,U,F){f.fromArray(i,R*3),p.fromArray(i,U*3),m.fromArray(i,F*3),x.fromArray(o,R*2),b.fromArray(o,U*2),y.fromArray(o,F*2),p.sub(f),m.sub(f),b.sub(x),y.sub(x);const $=1/(b.x*y.y-y.x*b.y);isFinite($)&&(v.copy(p).multiplyScalar(y.y).addScaledVector(m,-b.y).multiplyScalar($),S.copy(m).multiplyScalar(b.x).addScaledVector(p,-y.x).multiplyScalar($),u[R].add(v),u[U].add(v),u[F].add(v),d[R].add(S),d[U].add(S),d[F].add(S))}let T=this.groups;T.length===0&&(T=[{start:0,count:r.length}]);for(let R=0,U=T.length;R<U;++R){const F=T[R],$=F.start,j=F.count;for(let H=$,K=$+j;H<K;H+=3)N(r[H+0],r[H+1],r[H+2])}const k=new qe,C=new qe,E=new qe,D=new qe;function A(R){E.fromArray(a,R*3),D.copy(E);const U=u[R];k.copy(U),k.sub(E.multiplyScalar(E.dot(U))).normalize(),C.crossVectors(D,U);const $=C.dot(d[R])<0?-1:1;c[R*4]=k.x,c[R*4+1]=k.y,c[R*4+2]=k.z,c[R*4+3]=$}for(let R=0,U=T.length;R<U;++R){const F=T[R],$=F.start,j=F.count;for(let H=$,K=$+j;H<K;H+=3)A(r[H+0]),A(r[H+1]),A(r[H+2])}}computeVertexNormals(){const e=this.index,n=this.getAttribute("position");if(n!==void 0){let r=this.getAttribute("normal");if(r===void 0)r=new go(new Float32Array(n.count*3),3),this.setAttribute("normal",r);else for(let p=0,m=r.count;p<m;p++)r.setXYZ(p,0,0,0);const i=new qe,a=new qe,o=new qe,l=new qe,c=new qe,u=new qe,d=new qe,f=new qe;if(e)for(let p=0,m=e.count;p<m;p+=3){const x=e.getX(p+0),b=e.getX(p+1),y=e.getX(p+2);i.fromBufferAttribute(n,x),a.fromBufferAttribute(n,b),o.fromBufferAttribute(n,y),d.subVectors(o,a),f.subVectors(i,a),d.cross(f),l.fromBufferAttribute(r,x),c.fromBufferAttribute(r,b),u.fromBufferAttribute(r,y),l.add(d),c.add(d),u.add(d),r.setXYZ(x,l.x,l.y,l.z),r.setXYZ(b,c.x,c.y,c.z),r.setXYZ(y,u.x,u.y,u.z)}else for(let p=0,m=n.count;p<m;p+=3)i.fromBufferAttribute(n,p+0),a.fromBufferAttribute(n,p+1),o.fromBufferAttribute(n,p+2),d.subVectors(o,a),f.subVectors(i,a),d.cross(f),r.setXYZ(p+0,d.x,d.y,d.z),r.setXYZ(p+1,d.x,d.y,d.z),r.setXYZ(p+2,d.x,d.y,d.z);this.normalizeNormals(),r.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let n=0,r=e.count;n<r;n++)ha.fromBufferAttribute(e,n),ha.normalize(),e.setXYZ(n,ha.x,ha.y,ha.z)}toNonIndexed(){function e(l,c){const u=l.array,d=l.itemSize,f=l.normalized,p=new u.constructor(c.length*d);let m=0,x=0;for(let b=0,y=c.length;b<y;b++){l.isInterleavedBufferAttribute?m=c[b]*l.data.stride+l.offset:m=c[b]*d;for(let v=0;v<d;v++)p[x++]=u[m++]}return new go(p,d,f)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new ns,r=this.index.array,i=this.attributes;for(const l in i){const c=i[l],u=e(c,r);n.setAttribute(l,u)}const a=this.morphAttributes;for(const l in a){const c=[],u=a[l];for(let d=0,f=u.length;d<f;d++){const p=u[d],m=e(p,r);c.push(m)}n.morphAttributes[l]=c}n.morphTargetsRelative=this.morphTargetsRelative;const o=this.groups;for(let l=0,c=o.length;l<c;l++){const u=o[l];n.addGroup(u.start,u.count,u.materialIndex)}return n}toJSON(){const e={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const c=this.parameters;for(const u in c)c[u]!==void 0&&(e[u]=c[u]);return e}e.data={attributes:{}};const n=this.index;n!==null&&(e.data.index={type:n.array.constructor.name,array:Array.prototype.slice.call(n.array)});const r=this.attributes;for(const c in r){const u=r[c];e.data.attributes[c]=u.toJSON(e.data)}const i={};let a=!1;for(const c in this.morphAttributes){const u=this.morphAttributes[c],d=[];for(let f=0,p=u.length;f<p;f++){const m=u[f];d.push(m.toJSON(e.data))}d.length>0&&(i[c]=d,a=!0)}a&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));const l=this.boundingSphere;return l!==null&&(e.data.boundingSphere={center:l.center.toArray(),radius:l.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const n={};this.name=e.name;const r=e.index;r!==null&&this.setIndex(r.clone(n));const i=e.attributes;for(const u in i){const d=i[u];this.setAttribute(u,d.clone(n))}const a=e.morphAttributes;for(const u in a){const d=[],f=a[u];for(let p=0,m=f.length;p<m;p++)d.push(f[p].clone(n));this.morphAttributes[u]=d}this.morphTargetsRelative=e.morphTargetsRelative;const o=e.groups;for(let u=0,d=o.length;u<d;u++){const f=o[u];this.addGroup(f.start,f.count,f.materialIndex)}const l=e.boundingBox;l!==null&&(this.boundingBox=l.clone());const c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const TG=new zr,pf=new oL,D_=new hc,AG=new qe,qp=new qe,Wp=new qe,Kp=new qe,GC=new qe,R_=new qe,O_=new xn,L_=new xn,F_=new xn,CG=new qe,jG=new qe,PG=new qe,I_=new qe,U_=new qe;class Dl extends ps{constructor(e=new ns,n=new JJ){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=n,this.updateMorphTargets()}copy(e,n){return super.copy(e,n),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const n=this.geometry.morphAttributes,r=Object.keys(n);if(r.length>0){const i=n[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let a=0,o=i.length;a<o;a++){const l=i[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[l]=a}}}}getVertexPosition(e,n){const r=this.geometry,i=r.attributes.position,a=r.morphAttributes.position,o=r.morphTargetsRelative;n.fromBufferAttribute(i,e);const l=this.morphTargetInfluences;if(a&&l){R_.set(0,0,0);for(let c=0,u=a.length;c<u;c++){const d=l[c],f=a[c];d!==0&&(GC.fromBufferAttribute(f,e),o?R_.addScaledVector(GC,d):R_.addScaledVector(GC.sub(n),d))}n.add(R_)}return n}raycast(e,n){const r=this.geometry,i=this.material,a=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),D_.copy(r.boundingSphere),D_.applyMatrix4(a),pf.copy(e.ray).recast(e.near),!(D_.containsPoint(pf.origin)===!1&&(pf.intersectSphere(D_,AG)===null||pf.origin.distanceToSquared(AG)>(e.far-e.near)**2))&&(TG.copy(a).invert(),pf.copy(e.ray).applyMatrix4(TG),!(r.boundingBox!==null&&pf.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,n,pf)))}_computeIntersections(e,n,r){let i;const a=this.geometry,o=this.material,l=a.index,c=a.attributes.position,u=a.attributes.uv,d=a.attributes.uv1,f=a.attributes.normal,p=a.groups,m=a.drawRange;if(l!==null)if(Array.isArray(o))for(let x=0,b=p.length;x<b;x++){const y=p[x],v=o[y.materialIndex],S=Math.max(y.start,m.start),N=Math.min(l.count,Math.min(y.start+y.count,m.start+m.count));for(let T=S,k=N;T<k;T+=3){const C=l.getX(T),E=l.getX(T+1),D=l.getX(T+2);i=z_(this,v,e,r,u,d,f,C,E,D),i&&(i.faceIndex=Math.floor(T/3),i.face.materialIndex=y.materialIndex,n.push(i))}}else{const x=Math.max(0,m.start),b=Math.min(l.count,m.start+m.count);for(let y=x,v=b;y<v;y+=3){const S=l.getX(y),N=l.getX(y+1),T=l.getX(y+2);i=z_(this,o,e,r,u,d,f,S,N,T),i&&(i.faceIndex=Math.floor(y/3),n.push(i))}}else if(c!==void 0)if(Array.isArray(o))for(let x=0,b=p.length;x<b;x++){const y=p[x],v=o[y.materialIndex],S=Math.max(y.start,m.start),N=Math.min(c.count,Math.min(y.start+y.count,m.start+m.count));for(let T=S,k=N;T<k;T+=3){const C=T,E=T+1,D=T+2;i=z_(this,v,e,r,u,d,f,C,E,D),i&&(i.faceIndex=Math.floor(T/3),i.face.materialIndex=y.materialIndex,n.push(i))}}else{const x=Math.max(0,m.start),b=Math.min(c.count,m.start+m.count);for(let y=x,v=b;y<v;y+=3){const S=y,N=y+1,T=y+2;i=z_(this,o,e,r,u,d,f,S,N,T),i&&(i.faceIndex=Math.floor(y/3),n.push(i))}}}}function CFe(t,e,n,r,i,a,o,l){let c;if(e.side===zs?c=r.intersectTriangle(o,a,i,!0,l):c=r.intersectTriangle(i,a,o,e.side===Th,l),c===null)return null;U_.copy(l),U_.applyMatrix4(t.matrixWorld);const u=n.ray.origin.distanceTo(U_);return u<n.near||u>n.far?null:{distance:u,point:U_.clone(),object:t}}function z_(t,e,n,r,i,a,o,l,c,u){t.getVertexPosition(l,qp),t.getVertexPosition(c,Wp),t.getVertexPosition(u,Kp);const d=CFe(t,e,n,r,qp,Wp,Kp,I_);if(d){i&&(O_.fromBufferAttribute(i,l),L_.fromBufferAttribute(i,c),F_.fromBufferAttribute(i,u),d.uv=kl.getInterpolation(I_,qp,Wp,Kp,O_,L_,F_,new xn)),a&&(O_.fromBufferAttribute(a,l),L_.fromBufferAttribute(a,c),F_.fromBufferAttribute(a,u),d.uv1=kl.getInterpolation(I_,qp,Wp,Kp,O_,L_,F_,new xn),d.uv2=d.uv1),o&&(CG.fromBufferAttribute(o,l),jG.fromBufferAttribute(o,c),PG.fromBufferAttribute(o,u),d.normal=kl.getInterpolation(I_,qp,Wp,Kp,CG,jG,PG,new qe),d.normal.dot(r.direction)>0&&d.normal.multiplyScalar(-1));const f={a:l,b:c,c:u,normal:new qe,materialIndex:0};kl.getNormal(qp,Wp,Kp,f.normal),d.face=f}return d}class mv extends ns{constructor(e=1,n=1,r=1,i=1,a=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:n,depth:r,widthSegments:i,heightSegments:a,depthSegments:o};const l=this;i=Math.floor(i),a=Math.floor(a),o=Math.floor(o);const c=[],u=[],d=[],f=[];let p=0,m=0;x("z","y","x",-1,-1,r,n,e,o,a,0),x("z","y","x",1,-1,r,n,-e,o,a,1),x("x","z","y",1,1,e,r,n,i,o,2),x("x","z","y",1,-1,e,r,-n,i,o,3),x("x","y","z",1,-1,e,n,r,i,a,4),x("x","y","z",-1,-1,e,n,-r,i,a,5),this.setIndex(c),this.setAttribute("position",new Ti(u,3)),this.setAttribute("normal",new Ti(d,3)),this.setAttribute("uv",new Ti(f,2));function x(b,y,v,S,N,T,k,C,E,D,A){const R=T/E,U=k/D,F=T/2,$=k/2,j=C/2,H=E+1,K=D+1;let V=0,Q=0;const Z=new qe;for(let ae=0;ae<K;ae++){const B=ae*U-$;for(let X=0;X<H;X++){const ne=X*R-F;Z[b]=ne*S,Z[y]=B*N,Z[v]=j,u.push(Z.x,Z.y,Z.z),Z[b]=0,Z[y]=0,Z[v]=C>0?1:-1,d.push(Z.x,Z.y,Z.z),f.push(X/E),f.push(1-ae/D),V+=1}}for(let ae=0;ae<D;ae++)for(let B=0;B<E;B++){const X=p+B+H*ae,ne=p+B+H*(ae+1),se=p+(B+1)+H*(ae+1),be=p+(B+1)+H*ae;c.push(X,ne,be),c.push(ne,se,be),Q+=6}l.addGroup(m,Q,A),m+=Q,p+=V}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new mv(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function ax(t){const e={};for(const n in t){e[n]={};for(const r in t[n]){const i=t[n][r];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?i.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[n][r]=null):e[n][r]=i.clone():Array.isArray(i)?e[n][r]=i.slice():e[n][r]=i}}return e}function us(t){const e={};for(let n=0;n<t.length;n++){const r=ax(t[n]);for(const i in r)e[i]=r[i]}return e}function jFe(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function nee(t){return t.getRenderTarget()===null?t.outputColorSpace:Er.workingColorSpace}const lL={clone:ax,merge:us};var PFe=`void main() {
- gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
- }`,DFe=`void main() {
- gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
- }`;class Ah extends Dx{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=PFe,this.fragmentShader=DFe,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=ax(e.uniforms),this.uniformsGroups=jFe(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){const n=super.toJSON(e);n.glslVersion=this.glslVersion,n.uniforms={};for(const i in this.uniforms){const o=this.uniforms[i].value;o&&o.isTexture?n.uniforms[i]={type:"t",value:o.toJSON(e).uuid}:o&&o.isColor?n.uniforms[i]={type:"c",value:o.getHex()}:o&&o.isVector2?n.uniforms[i]={type:"v2",value:o.toArray()}:o&&o.isVector3?n.uniforms[i]={type:"v3",value:o.toArray()}:o&&o.isVector4?n.uniforms[i]={type:"v4",value:o.toArray()}:o&&o.isMatrix3?n.uniforms[i]={type:"m3",value:o.toArray()}:o&&o.isMatrix4?n.uniforms[i]={type:"m4",value:o.toArray()}:n.uniforms[i]={value:o}}Object.keys(this.defines).length>0&&(n.defines=this.defines),n.vertexShader=this.vertexShader,n.fragmentShader=this.fragmentShader,n.lights=this.lights,n.clipping=this.clipping;const r={};for(const i in this.extensions)this.extensions[i]===!0&&(r[i]=!0);return Object.keys(r).length>0&&(n.extensions=r),n}}class ree extends ps{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new zr,this.projectionMatrix=new zr,this.projectionMatrixInverse=new zr,this.coordinateSystem=cc}copy(e,n){return super.copy(e,n),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,n){super.updateWorldMatrix(e,n),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}class oo extends ree{constructor(e=50,n=1,r=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=r,this.far=i,this.focus=10,this.aspect=n,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,n){return super.copy(e,n),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const n=.5*this.getFilmHeight()/e;this.fov=yy*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(w0*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return yy*2*Math.atan(Math.tan(w0*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(e,n,r,i,a,o){this.aspect=e/n,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=n,this.view.offsetX=r,this.view.offsetY=i,this.view.width=a,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let n=e*Math.tan(w0*.5*this.fov)/this.zoom,r=2*n,i=this.aspect*r,a=-.5*i;const o=this.view;if(this.view!==null&&this.view.enabled){const c=o.fullWidth,u=o.fullHeight;a+=o.offsetX*i/c,n-=o.offsetY*r/u,i*=o.width/c,r*=o.height/u}const l=this.filmOffset;l!==0&&(a+=e*l/this.getFilmWidth()),this.projectionMatrix.makePerspective(a,a+i,n,n-r,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const n=super.toJSON(e);return n.object.fov=this.fov,n.object.zoom=this.zoom,n.object.near=this.near,n.object.far=this.far,n.object.focus=this.focus,n.object.aspect=this.aspect,this.view!==null&&(n.object.view=Object.assign({},this.view)),n.object.filmGauge=this.filmGauge,n.object.filmOffset=this.filmOffset,n}}const Xp=-90,Yp=1;class RFe extends ps{constructor(e,n,r){super(),this.type="CubeCamera",this.renderTarget=r,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new oo(Xp,Yp,e,n);i.layers=this.layers,this.add(i);const a=new oo(Xp,Yp,e,n);a.layers=this.layers,this.add(a);const o=new oo(Xp,Yp,e,n);o.layers=this.layers,this.add(o);const l=new oo(Xp,Yp,e,n);l.layers=this.layers,this.add(l);const c=new oo(Xp,Yp,e,n);c.layers=this.layers,this.add(c);const u=new oo(Xp,Yp,e,n);u.layers=this.layers,this.add(u)}updateCoordinateSystem(){const e=this.coordinateSystem,n=this.children.concat(),[r,i,a,o,l,c]=n;for(const u of n)this.remove(u);if(e===cc)r.up.set(0,1,0),r.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),a.up.set(0,0,-1),a.lookAt(0,1,0),o.up.set(0,0,1),o.lookAt(0,-1,0),l.up.set(0,1,0),l.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(e===by)r.up.set(0,-1,0),r.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),a.up.set(0,0,1),a.lookAt(0,1,0),o.up.set(0,0,-1),o.lookAt(0,-1,0),l.up.set(0,-1,0),l.lookAt(0,0,1),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const u of n)this.add(u),u.updateMatrixWorld()}update(e,n){this.parent===null&&this.updateMatrixWorld();const{renderTarget:r,activeMipmapLevel:i}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[a,o,l,c,u,d]=this.children,f=e.getRenderTarget(),p=e.getActiveCubeFace(),m=e.getActiveMipmapLevel(),x=e.xr.enabled;e.xr.enabled=!1;const b=r.texture.generateMipmaps;r.texture.generateMipmaps=!1,e.setRenderTarget(r,0,i),e.render(n,a),e.setRenderTarget(r,1,i),e.render(n,o),e.setRenderTarget(r,2,i),e.render(n,l),e.setRenderTarget(r,3,i),e.render(n,c),e.setRenderTarget(r,4,i),e.render(n,u),r.texture.generateMipmaps=b,e.setRenderTarget(r,5,i),e.render(n,d),e.setRenderTarget(f,p,m),e.xr.enabled=x,r.texture.needsPMREMUpdate=!0}}class iee extends Bs{constructor(e,n,r,i,a,o,l,c,u,d){e=e!==void 0?e:[],n=n!==void 0?n:nx,super(e,n,r,i,a,o,l,c,u,d),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class OFe extends ym{constructor(e=1,n={}){super(e,e,n),this.isWebGLCubeRenderTarget=!0;const r={width:e,height:e,depth:1},i=[r,r,r,r,r,r];n.encoding!==void 0&&(S0("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),n.colorSpace=n.encoding===Kf?Ra:Yo),this.texture=new iee(i,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=n.generateMipmaps!==void 0?n.generateMipmaps:!1,this.texture.minFilter=n.minFilter!==void 0?n.minFilter:Ko}fromEquirectangularTexture(e,n){this.texture.type=n.type,this.texture.colorSpace=n.colorSpace,this.texture.generateMipmaps=n.generateMipmaps,this.texture.minFilter=n.minFilter,this.texture.magFilter=n.magFilter;const r={uniforms:{tEquirect:{value:null}},vertexShader:`
- 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 mv(5,5,5),a=new Ah({name:"CubemapFromEquirect",uniforms:ax(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:zs,blending:ch});a.uniforms.tEquirect.value=n;const o=new Dl(i,a),l=n.minFilter;return n.minFilter===gy&&(n.minFilter=Ko),new RFe(1,10,this).update(e,o),n.minFilter=l,o.geometry.dispose(),o.material.dispose(),this}clear(e,n,r,i){const a=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(n,r,i);e.setRenderTarget(a)}}const qC=new qe,LFe=new qe,FFe=new Ln;class Hd{constructor(e=new qe(1,0,0),n=0){this.isPlane=!0,this.normal=e,this.constant=n}set(e,n){return this.normal.copy(e),this.constant=n,this}setComponents(e,n,r,i){return this.normal.set(e,n,r),this.constant=i,this}setFromNormalAndCoplanarPoint(e,n){return this.normal.copy(e),this.constant=-n.dot(this.normal),this}setFromCoplanarPoints(e,n,r){const i=qC.subVectors(r,n).cross(LFe.subVectors(e,n)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,n){return n.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,n){const r=e.delta(qC),i=this.normal.dot(r);if(i===0)return this.distanceToPoint(e.start)===0?n.copy(e.start):null;const a=-(e.start.dot(this.normal)+this.constant)/i;return a<0||a>1?null:n.copy(e.start).addScaledVector(r,a)}intersectsLine(e){const n=this.distanceToPoint(e.start),r=this.distanceToPoint(e.end);return n<0&&r>0||r<0&&n>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,n){const r=n||FFe.getNormalMatrix(e),i=this.coplanarPoint(qC).applyMatrix4(e),a=this.normal.applyMatrix3(r).normalize();return this.constant=-i.dot(a),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const gf=new hc,B_=new qe;class v2{constructor(e=new Hd,n=new Hd,r=new Hd,i=new Hd,a=new Hd,o=new Hd){this.planes=[e,n,r,i,a,o]}set(e,n,r,i,a,o){const l=this.planes;return l[0].copy(e),l[1].copy(n),l[2].copy(r),l[3].copy(i),l[4].copy(a),l[5].copy(o),this}copy(e){const n=this.planes;for(let r=0;r<6;r++)n[r].copy(e.planes[r]);return this}setFromProjectionMatrix(e,n=cc){const r=this.planes,i=e.elements,a=i[0],o=i[1],l=i[2],c=i[3],u=i[4],d=i[5],f=i[6],p=i[7],m=i[8],x=i[9],b=i[10],y=i[11],v=i[12],S=i[13],N=i[14],T=i[15];if(r[0].setComponents(c-a,p-u,y-m,T-v).normalize(),r[1].setComponents(c+a,p+u,y+m,T+v).normalize(),r[2].setComponents(c+o,p+d,y+x,T+S).normalize(),r[3].setComponents(c-o,p-d,y-x,T-S).normalize(),r[4].setComponents(c-l,p-f,y-b,T-N).normalize(),n===cc)r[5].setComponents(c+l,p+f,y+b,T+N).normalize();else if(n===by)r[5].setComponents(l,f,b,N).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+n);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),gf.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),gf.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(gf)}intersectsSprite(e){return gf.center.set(0,0,0),gf.radius=.7071067811865476,gf.applyMatrix4(e.matrixWorld),this.intersectsSphere(gf)}intersectsSphere(e){const n=this.planes,r=e.center,i=-e.radius;for(let a=0;a<6;a++)if(n[a].distanceToPoint(r)<i)return!1;return!0}intersectsBox(e){const n=this.planes;for(let r=0;r<6;r++){const i=n[r];if(B_.x=i.normal.x>0?e.max.x:e.min.x,B_.y=i.normal.y>0?e.max.y:e.min.y,B_.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(B_)<0)return!1}return!0}containsPoint(e){const n=this.planes;for(let r=0;r<6;r++)if(n[r].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}function aee(){let t=null,e=!1,n=null,r=null;function i(a,o){n(a,o),r=t.requestAnimationFrame(i)}return{start:function(){e!==!0&&n!==null&&(r=t.requestAnimationFrame(i),e=!0)},stop:function(){t.cancelAnimationFrame(r),e=!1},setAnimationLoop:function(a){n=a},setContext:function(a){t=a}}}function IFe(t,e){const n=e.isWebGL2,r=new WeakMap;function i(u,d){const f=u.array,p=u.usage,m=f.byteLength,x=t.createBuffer();t.bindBuffer(d,x),t.bufferData(d,f,p),u.onUploadCallback();let b;if(f instanceof Float32Array)b=t.FLOAT;else if(f instanceof Uint16Array)if(u.isFloat16BufferAttribute)if(n)b=t.HALF_FLOAT;else throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");else b=t.UNSIGNED_SHORT;else if(f instanceof Int16Array)b=t.SHORT;else if(f instanceof Uint32Array)b=t.UNSIGNED_INT;else if(f instanceof Int32Array)b=t.INT;else if(f instanceof Int8Array)b=t.BYTE;else if(f instanceof Uint8Array)b=t.UNSIGNED_BYTE;else if(f instanceof Uint8ClampedArray)b=t.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+f);return{buffer:x,type:b,bytesPerElement:f.BYTES_PER_ELEMENT,version:u.version,size:m}}function a(u,d,f){const p=d.array,m=d._updateRange,x=d.updateRanges;if(t.bindBuffer(f,u),m.count===-1&&x.length===0&&t.bufferSubData(f,0,p),x.length!==0){for(let b=0,y=x.length;b<y;b++){const v=x[b];n?t.bufferSubData(f,v.start*p.BYTES_PER_ELEMENT,p,v.start,v.count):t.bufferSubData(f,v.start*p.BYTES_PER_ELEMENT,p.subarray(v.start,v.start+v.count))}d.clearUpdateRanges()}m.count!==-1&&(n?t.bufferSubData(f,m.offset*p.BYTES_PER_ELEMENT,p,m.offset,m.count):t.bufferSubData(f,m.offset*p.BYTES_PER_ELEMENT,p.subarray(m.offset,m.offset+m.count)),m.count=-1),d.onUploadCallback()}function o(u){return u.isInterleavedBufferAttribute&&(u=u.data),r.get(u)}function l(u){u.isInterleavedBufferAttribute&&(u=u.data);const d=r.get(u);d&&(t.deleteBuffer(d.buffer),r.delete(u))}function c(u,d){if(u.isGLBufferAttribute){const p=r.get(u);(!p||p.version<u.version)&&r.set(u,{buffer:u.buffer,type:u.type,bytesPerElement:u.elementSize,version:u.version});return}u.isInterleavedBufferAttribute&&(u=u.data);const f=r.get(u);if(f===void 0)r.set(u,i(u,d));else if(f.version<u.version){if(f.size!==u.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");a(f.buffer,u,d),f.version=u.version}}return{get:o,remove:l,update:c}}class cL extends ns{constructor(e=1,n=1,r=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:n,widthSegments:r,heightSegments:i};const a=e/2,o=n/2,l=Math.floor(r),c=Math.floor(i),u=l+1,d=c+1,f=e/l,p=n/c,m=[],x=[],b=[],y=[];for(let v=0;v<d;v++){const S=v*p-o;for(let N=0;N<u;N++){const T=N*f-a;x.push(T,-S,0),b.push(0,0,1),y.push(N/l),y.push(1-v/c)}}for(let v=0;v<c;v++)for(let S=0;S<l;S++){const N=S+u*v,T=S+u*(v+1),k=S+1+u*(v+1),C=S+1+u*v;m.push(N,T,C),m.push(T,k,C)}this.setIndex(m),this.setAttribute("position",new Ti(x,3)),this.setAttribute("normal",new Ti(b,3)),this.setAttribute("uv",new Ti(y,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new cL(e.width,e.height,e.widthSegments,e.heightSegments)}}var UFe=`#ifdef USE_ALPHAHASH
- if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
- #endif`,zFe=`#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`,BFe=`#ifdef USE_ALPHAMAP
- diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
- #endif`,HFe=`#ifdef USE_ALPHAMAP
- uniform sampler2D alphaMap;
- #endif`,$Fe=`#ifdef USE_ALPHATEST
- if ( diffuseColor.a < alphaTest ) discard;
- #endif`,VFe=`#ifdef USE_ALPHATEST
- uniform float alphaTest;
- #endif`,GFe=`#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`,qFe=`#ifdef USE_AOMAP
- uniform sampler2D aoMap;
- uniform float aoMapIntensity;
- #endif`,WFe=`#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`,KFe=`#ifdef USE_BATCHING
- mat4 batchingMatrix = getBatchingMatrix( batchId );
- #endif`,XFe=`vec3 transformed = vec3( position );
- #ifdef USE_ALPHAHASH
- vPosition = vec3( position );
- #endif`,YFe=`vec3 objectNormal = vec3( normal );
- #ifdef USE_TANGENT
- vec3 objectTangent = vec3( tangent.xyz );
- #endif`,QFe=`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`,ZFe=`#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`,JFe=`#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`,eIe=`#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`,tIe=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
- #endif`,nIe=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- #endif`,rIe=`#if NUM_CLIPPING_PLANES > 0
- vClipPosition = - mvPosition.xyz;
- #endif`,iIe=`#if defined( USE_COLOR_ALPHA )
- diffuseColor *= vColor;
- #elif defined( USE_COLOR )
- diffuseColor.rgb *= vColor;
- #endif`,aIe=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR )
- varying vec3 vColor;
- #endif`,sIe=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
- varying vec3 vColor;
- #endif`,oIe=`#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`,lIe=`#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`,cIe=`#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`,uIe=`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`,dIe=`#ifdef USE_DISPLACEMENTMAP
- uniform sampler2D displacementMap;
- uniform float displacementScale;
- uniform float displacementBias;
- #endif`,hIe=`#ifdef USE_DISPLACEMENTMAP
- transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
- #endif`,fIe=`#ifdef USE_EMISSIVEMAP
- vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
- totalEmissiveRadiance *= emissiveColor.rgb;
- #endif`,mIe=`#ifdef USE_EMISSIVEMAP
- uniform sampler2D emissiveMap;
- #endif`,pIe="gl_FragColor = linearToOutputTexel( gl_FragColor );",gIe=`
- 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 );
- }`,xIe=`#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`,bIe=`#ifdef USE_ENVMAP
- uniform float envMapIntensity;
- uniform float flipEnvMap;
- #ifdef ENVMAP_TYPE_CUBE
- uniform samplerCube envMap;
- #else
- uniform sampler2D envMap;
- #endif
-
- #endif`,yIe=`#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`,vIe=`#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`,wIe=`#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`,_Ie=`#ifdef USE_FOG
- vFogDepth = - mvPosition.z;
- #endif`,SIe=`#ifdef USE_FOG
- varying float vFogDepth;
- #endif`,MIe=`#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`,NIe=`#ifdef USE_FOG
- uniform vec3 fogColor;
- varying float vFogDepth;
- #ifdef FOG_EXP2
- uniform float fogDensity;
- #else
- uniform float fogNear;
- uniform float fogFar;
- #endif
- #endif`,kIe=`#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
- }`,EIe=`#ifdef USE_LIGHTMAP
- vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
- vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
- reflectedLight.indirectDiffuse += lightMapIrradiance;
- #endif`,TIe=`#ifdef USE_LIGHTMAP
- uniform sampler2D lightMap;
- uniform float lightMapIntensity;
- #endif`,AIe=`LambertMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularStrength = specularStrength;`,CIe=`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`,jIe=`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`,PIe=`#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`,DIe=`ToonMaterial material;
- material.diffuseColor = diffuseColor.rgb;`,RIe=`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`,OIe=`BlinnPhongMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularColor = specular;
- material.specularShininess = shininess;
- material.specularStrength = specularStrength;`,LIe=`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`,FIe=`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`,IIe=`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 );
- }`,UIe=`
- 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`,zIe=`#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`,BIe=`#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`,HIe=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
- gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
- #endif`,$Ie=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
- uniform float logDepthBufFC;
- varying float vFragDepth;
- varying float vIsPerspective;
- #endif`,VIe=`#ifdef USE_LOGDEPTHBUF
- #ifdef USE_LOGDEPTHBUF_EXT
- varying float vFragDepth;
- varying float vIsPerspective;
- #else
- uniform float logDepthBufFC;
- #endif
- #endif`,GIe=`#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`,qIe=`#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`,WIe=`#ifdef USE_MAP
- uniform sampler2D map;
- #endif`,KIe=`#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`,XIe=`#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`,YIe=`float metalnessFactor = metalness;
- #ifdef USE_METALNESSMAP
- vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
- metalnessFactor *= texelMetalness.b;
- #endif`,QIe=`#ifdef USE_METALNESSMAP
- uniform sampler2D metalnessMap;
- #endif`,ZIe=`#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`,JIe=`#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`,e5e=`#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`,t5e=`#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`,n5e=`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;`,r5e=`#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`,i5e=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,a5e=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,s5e=`#ifndef FLAT_SHADED
- vNormal = normalize( transformedNormal );
- #ifdef USE_TANGENT
- vTangent = normalize( transformedTangent );
- vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
- #endif
- #endif`,o5e=`#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`,l5e=`#ifdef USE_CLEARCOAT
- vec3 clearcoatNormal = nonPerturbedNormal;
- #endif`,c5e=`#ifdef USE_CLEARCOAT_NORMALMAP
- vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
- clearcoatMapN.xy *= clearcoatNormalScale;
- clearcoatNormal = normalize( tbn2 * clearcoatMapN );
- #endif`,u5e=`#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`,d5e=`#ifdef USE_IRIDESCENCEMAP
- uniform sampler2D iridescenceMap;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- uniform sampler2D iridescenceThicknessMap;
- #endif`,h5e=`#ifdef OPAQUE
- diffuseColor.a = 1.0;
- #endif
- #ifdef USE_TRANSMISSION
- diffuseColor.a *= material.transmissionAlpha;
- #endif
- gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,f5e=`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 );
- }`,m5e=`#ifdef PREMULTIPLIED_ALPHA
- gl_FragColor.rgb *= gl_FragColor.a;
- #endif`,p5e=`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;`,g5e=`#ifdef DITHERING
- gl_FragColor.rgb = dithering( gl_FragColor.rgb );
- #endif`,x5e=`#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`,b5e=`float roughnessFactor = roughness;
- #ifdef USE_ROUGHNESSMAP
- vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
- roughnessFactor *= texelRoughness.g;
- #endif`,y5e=`#ifdef USE_ROUGHNESSMAP
- uniform sampler2D roughnessMap;
- #endif`,v5e=`#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`,w5e=`#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`,_5e=`#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`,S5e=`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;
- }`,M5e=`#ifdef USE_SKINNING
- mat4 boneMatX = getBoneMatrix( skinIndex.x );
- mat4 boneMatY = getBoneMatrix( skinIndex.y );
- mat4 boneMatZ = getBoneMatrix( skinIndex.z );
- mat4 boneMatW = getBoneMatrix( skinIndex.w );
- #endif`,N5e=`#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`,k5e=`#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`,E5e=`#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`,T5e=`float specularStrength;
- #ifdef USE_SPECULARMAP
- vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
- specularStrength = texelSpecular.r;
- #else
- specularStrength = 1.0;
- #endif`,A5e=`#ifdef USE_SPECULARMAP
- uniform sampler2D specularMap;
- #endif`,C5e=`#if defined( TONE_MAPPING )
- gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
- #endif`,j5e=`#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; }`,P5e=`#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`,D5e=`#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`,R5e=`#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`,O5e=`#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`,L5e=`#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`,F5e=`#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 I5e=`varying vec2 vUv;
- uniform mat3 uvTransform;
- void main() {
- vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
- gl_Position = vec4( position.xy, 1.0, 1.0 );
- }`,U5e=`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>
- }`,z5e=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,B5e=`#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>
- }`,H5e=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,$5e=`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>
- }`,V5e=`#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;
- }`,G5e=`#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
- }`,q5e=`#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;
- }`,W5e=`#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 );
- }`,K5e=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- }`,X5e=`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>
- }`,Y5e=`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>
- }`,Q5e=`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>
- }`,Z5e=`#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>
- }`,J5e=`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>
- }`,eUe=`#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>
- }`,tUe=`#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>
- }`,nUe=`#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;
- }`,rUe=`#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>
- }`,iUe=`#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
- }`,aUe=`#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
- }`,sUe=`#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>
- }`,oUe=`#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>
- }`,lUe=`#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
- }`,cUe=`#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>
- }`,uUe=`#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>
- }`,dUe=`#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>
- }`,hUe=`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>
- }`,fUe=`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>
- }`,mUe=`#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>
- }`,pUe=`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>
- }`,gUe=`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>
- }`,xUe=`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>
- }`,En={alphahash_fragment:UFe,alphahash_pars_fragment:zFe,alphamap_fragment:BFe,alphamap_pars_fragment:HFe,alphatest_fragment:$Fe,alphatest_pars_fragment:VFe,aomap_fragment:GFe,aomap_pars_fragment:qFe,batching_pars_vertex:WFe,batching_vertex:KFe,begin_vertex:XFe,beginnormal_vertex:YFe,bsdfs:QFe,iridescence_fragment:ZFe,bumpmap_pars_fragment:JFe,clipping_planes_fragment:eIe,clipping_planes_pars_fragment:tIe,clipping_planes_pars_vertex:nIe,clipping_planes_vertex:rIe,color_fragment:iIe,color_pars_fragment:aIe,color_pars_vertex:sIe,color_vertex:oIe,common:lIe,cube_uv_reflection_fragment:cIe,defaultnormal_vertex:uIe,displacementmap_pars_vertex:dIe,displacementmap_vertex:hIe,emissivemap_fragment:fIe,emissivemap_pars_fragment:mIe,colorspace_fragment:pIe,colorspace_pars_fragment:gIe,envmap_fragment:xIe,envmap_common_pars_fragment:bIe,envmap_pars_fragment:yIe,envmap_pars_vertex:vIe,envmap_physical_pars_fragment:PIe,envmap_vertex:wIe,fog_vertex:_Ie,fog_pars_vertex:SIe,fog_fragment:MIe,fog_pars_fragment:NIe,gradientmap_pars_fragment:kIe,lightmap_fragment:EIe,lightmap_pars_fragment:TIe,lights_lambert_fragment:AIe,lights_lambert_pars_fragment:CIe,lights_pars_begin:jIe,lights_toon_fragment:DIe,lights_toon_pars_fragment:RIe,lights_phong_fragment:OIe,lights_phong_pars_fragment:LIe,lights_physical_fragment:FIe,lights_physical_pars_fragment:IIe,lights_fragment_begin:UIe,lights_fragment_maps:zIe,lights_fragment_end:BIe,logdepthbuf_fragment:HIe,logdepthbuf_pars_fragment:$Ie,logdepthbuf_pars_vertex:VIe,logdepthbuf_vertex:GIe,map_fragment:qIe,map_pars_fragment:WIe,map_particle_fragment:KIe,map_particle_pars_fragment:XIe,metalnessmap_fragment:YIe,metalnessmap_pars_fragment:QIe,morphcolor_vertex:ZIe,morphnormal_vertex:JIe,morphtarget_pars_vertex:e5e,morphtarget_vertex:t5e,normal_fragment_begin:n5e,normal_fragment_maps:r5e,normal_pars_fragment:i5e,normal_pars_vertex:a5e,normal_vertex:s5e,normalmap_pars_fragment:o5e,clearcoat_normal_fragment_begin:l5e,clearcoat_normal_fragment_maps:c5e,clearcoat_pars_fragment:u5e,iridescence_pars_fragment:d5e,opaque_fragment:h5e,packing:f5e,premultiplied_alpha_fragment:m5e,project_vertex:p5e,dithering_fragment:g5e,dithering_pars_fragment:x5e,roughnessmap_fragment:b5e,roughnessmap_pars_fragment:y5e,shadowmap_pars_fragment:v5e,shadowmap_pars_vertex:w5e,shadowmap_vertex:_5e,shadowmask_pars_fragment:S5e,skinbase_vertex:M5e,skinning_pars_vertex:N5e,skinning_vertex:k5e,skinnormal_vertex:E5e,specularmap_fragment:T5e,specularmap_pars_fragment:A5e,tonemapping_fragment:C5e,tonemapping_pars_fragment:j5e,transmission_fragment:P5e,transmission_pars_fragment:D5e,uv_pars_fragment:R5e,uv_pars_vertex:O5e,uv_vertex:L5e,worldpos_vertex:F5e,background_vert:I5e,background_frag:U5e,backgroundCube_vert:z5e,backgroundCube_frag:B5e,cube_vert:H5e,cube_frag:$5e,depth_vert:V5e,depth_frag:G5e,distanceRGBA_vert:q5e,distanceRGBA_frag:W5e,equirect_vert:K5e,equirect_frag:X5e,linedashed_vert:Y5e,linedashed_frag:Q5e,meshbasic_vert:Z5e,meshbasic_frag:J5e,meshlambert_vert:eUe,meshlambert_frag:tUe,meshmatcap_vert:nUe,meshmatcap_frag:rUe,meshnormal_vert:iUe,meshnormal_frag:aUe,meshphong_vert:sUe,meshphong_frag:oUe,meshphysical_vert:lUe,meshphysical_frag:cUe,meshtoon_vert:uUe,meshtoon_frag:dUe,points_vert:hUe,points_frag:fUe,shadow_vert:mUe,shadow_frag:pUe,sprite_vert:gUe,sprite_frag:xUe},Dt={common:{diffuse:{value:new Zt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Ln},alphaMap:{value:null},alphaMapTransform:{value:new Ln},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Ln}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Ln}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Ln}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Ln},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Ln},normalScale:{value:new xn(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Ln},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Ln}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Ln}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Ln}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Zt(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new Zt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Ln},alphaTest:{value:0},uvTransform:{value:new Ln}},sprite:{diffuse:{value:new Zt(16777215)},opacity:{value:1},center:{value:new xn(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Ln},alphaMap:{value:null},alphaMapTransform:{value:new Ln},alphaTest:{value:0}}},Rs={basic:{uniforms:us([Dt.common,Dt.specularmap,Dt.envmap,Dt.aomap,Dt.lightmap,Dt.fog]),vertexShader:En.meshbasic_vert,fragmentShader:En.meshbasic_frag},lambert:{uniforms:us([Dt.common,Dt.specularmap,Dt.envmap,Dt.aomap,Dt.lightmap,Dt.emissivemap,Dt.bumpmap,Dt.normalmap,Dt.displacementmap,Dt.fog,Dt.lights,{emissive:{value:new Zt(0)}}]),vertexShader:En.meshlambert_vert,fragmentShader:En.meshlambert_frag},phong:{uniforms:us([Dt.common,Dt.specularmap,Dt.envmap,Dt.aomap,Dt.lightmap,Dt.emissivemap,Dt.bumpmap,Dt.normalmap,Dt.displacementmap,Dt.fog,Dt.lights,{emissive:{value:new Zt(0)},specular:{value:new Zt(1118481)},shininess:{value:30}}]),vertexShader:En.meshphong_vert,fragmentShader:En.meshphong_frag},standard:{uniforms:us([Dt.common,Dt.envmap,Dt.aomap,Dt.lightmap,Dt.emissivemap,Dt.bumpmap,Dt.normalmap,Dt.displacementmap,Dt.roughnessmap,Dt.metalnessmap,Dt.fog,Dt.lights,{emissive:{value:new Zt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:En.meshphysical_vert,fragmentShader:En.meshphysical_frag},toon:{uniforms:us([Dt.common,Dt.aomap,Dt.lightmap,Dt.emissivemap,Dt.bumpmap,Dt.normalmap,Dt.displacementmap,Dt.gradientmap,Dt.fog,Dt.lights,{emissive:{value:new Zt(0)}}]),vertexShader:En.meshtoon_vert,fragmentShader:En.meshtoon_frag},matcap:{uniforms:us([Dt.common,Dt.bumpmap,Dt.normalmap,Dt.displacementmap,Dt.fog,{matcap:{value:null}}]),vertexShader:En.meshmatcap_vert,fragmentShader:En.meshmatcap_frag},points:{uniforms:us([Dt.points,Dt.fog]),vertexShader:En.points_vert,fragmentShader:En.points_frag},dashed:{uniforms:us([Dt.common,Dt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:En.linedashed_vert,fragmentShader:En.linedashed_frag},depth:{uniforms:us([Dt.common,Dt.displacementmap]),vertexShader:En.depth_vert,fragmentShader:En.depth_frag},normal:{uniforms:us([Dt.common,Dt.bumpmap,Dt.normalmap,Dt.displacementmap,{opacity:{value:1}}]),vertexShader:En.meshnormal_vert,fragmentShader:En.meshnormal_frag},sprite:{uniforms:us([Dt.sprite,Dt.fog]),vertexShader:En.sprite_vert,fragmentShader:En.sprite_frag},background:{uniforms:{uvTransform:{value:new Ln},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:En.background_vert,fragmentShader:En.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:En.backgroundCube_vert,fragmentShader:En.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:En.cube_vert,fragmentShader:En.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:En.equirect_vert,fragmentShader:En.equirect_frag},distanceRGBA:{uniforms:us([Dt.common,Dt.displacementmap,{referencePosition:{value:new qe},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:En.distanceRGBA_vert,fragmentShader:En.distanceRGBA_frag},shadow:{uniforms:us([Dt.lights,Dt.fog,{color:{value:new Zt(0)},opacity:{value:1}}]),vertexShader:En.shadow_vert,fragmentShader:En.shadow_frag}};Rs.physical={uniforms:us([Rs.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Ln},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Ln},clearcoatNormalScale:{value:new xn(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Ln},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Ln},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Ln},sheen:{value:0},sheenColor:{value:new Zt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Ln},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Ln},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Ln},transmissionSamplerSize:{value:new xn},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Ln},attenuationDistance:{value:0},attenuationColor:{value:new Zt(0)},specularColor:{value:new Zt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Ln},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Ln},anisotropyVector:{value:new xn},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Ln}}]),vertexShader:En.meshphysical_vert,fragmentShader:En.meshphysical_frag};const H_={r:0,b:0,g:0};function bUe(t,e,n,r,i,a,o){const l=new Zt(0);let c=a===!0?0:1,u,d,f=null,p=0,m=null;function x(y,v){let S=!1,N=v.isScene===!0?v.background:null;N&&N.isTexture&&(N=(v.backgroundBlurriness>0?n:e).get(N)),N===null?b(l,c):N&&N.isColor&&(b(N,1),S=!0);const T=t.xr.getEnvironmentBlendMode();T==="additive"?r.buffers.color.setClear(0,0,0,1,o):T==="alpha-blend"&&r.buffers.color.setClear(0,0,0,0,o),(t.autoClear||S)&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),N&&(N.isCubeTexture||N.mapping===b2)?(d===void 0&&(d=new Dl(new mv(1,1,1),new Ah({name:"BackgroundCubeMaterial",uniforms:ax(Rs.backgroundCube.uniforms),vertexShader:Rs.backgroundCube.vertexShader,fragmentShader:Rs.backgroundCube.fragmentShader,side:zs,depthTest:!1,depthWrite:!1,fog:!1})),d.geometry.deleteAttribute("normal"),d.geometry.deleteAttribute("uv"),d.onBeforeRender=function(k,C,E){this.matrixWorld.copyPosition(E.matrixWorld)},Object.defineProperty(d.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(d)),d.material.uniforms.envMap.value=N,d.material.uniforms.flipEnvMap.value=N.isCubeTexture&&N.isRenderTargetTexture===!1?-1:1,d.material.uniforms.backgroundBlurriness.value=v.backgroundBlurriness,d.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,d.material.toneMapped=Er.getTransfer(N.colorSpace)!==Gr,(f!==N||p!==N.version||m!==t.toneMapping)&&(d.material.needsUpdate=!0,f=N,p=N.version,m=t.toneMapping),d.layers.enableAll(),y.unshift(d,d.geometry,d.material,0,0,null)):N&&N.isTexture&&(u===void 0&&(u=new Dl(new cL(2,2),new Ah({name:"BackgroundMaterial",uniforms:ax(Rs.background.uniforms),vertexShader:Rs.background.vertexShader,fragmentShader:Rs.background.fragmentShader,side:Th,depthTest:!1,depthWrite:!1,fog:!1})),u.geometry.deleteAttribute("normal"),Object.defineProperty(u.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(u)),u.material.uniforms.t2D.value=N,u.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,u.material.toneMapped=Er.getTransfer(N.colorSpace)!==Gr,N.matrixAutoUpdate===!0&&N.updateMatrix(),u.material.uniforms.uvTransform.value.copy(N.matrix),(f!==N||p!==N.version||m!==t.toneMapping)&&(u.material.needsUpdate=!0,f=N,p=N.version,m=t.toneMapping),u.layers.enableAll(),y.unshift(u,u.geometry,u.material,0,0,null))}function b(y,v){y.getRGB(H_,nee(t)),r.buffers.color.setClear(H_.r,H_.g,H_.b,v,o)}return{getClearColor:function(){return l},setClearColor:function(y,v=1){l.set(y),c=v,b(l,c)},getClearAlpha:function(){return c},setClearAlpha:function(y){c=y,b(l,c)},render:x}}function yUe(t,e,n,r){const i=t.getParameter(t.MAX_VERTEX_ATTRIBS),a=r.isWebGL2?null:e.get("OES_vertex_array_object"),o=r.isWebGL2||a!==null,l={},c=y(null);let u=c,d=!1;function f(j,H,K,V,Q){let Z=!1;if(o){const ae=b(V,K,H);u!==ae&&(u=ae,m(u.object)),Z=v(j,V,K,Q),Z&&S(j,V,K,Q)}else{const ae=H.wireframe===!0;(u.geometry!==V.id||u.program!==K.id||u.wireframe!==ae)&&(u.geometry=V.id,u.program=K.id,u.wireframe=ae,Z=!0)}Q!==null&&n.update(Q,t.ELEMENT_ARRAY_BUFFER),(Z||d)&&(d=!1,D(j,H,K,V),Q!==null&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,n.get(Q).buffer))}function p(){return r.isWebGL2?t.createVertexArray():a.createVertexArrayOES()}function m(j){return r.isWebGL2?t.bindVertexArray(j):a.bindVertexArrayOES(j)}function x(j){return r.isWebGL2?t.deleteVertexArray(j):a.deleteVertexArrayOES(j)}function b(j,H,K){const V=K.wireframe===!0;let Q=l[j.id];Q===void 0&&(Q={},l[j.id]=Q);let Z=Q[H.id];Z===void 0&&(Z={},Q[H.id]=Z);let ae=Z[V];return ae===void 0&&(ae=y(p()),Z[V]=ae),ae}function y(j){const H=[],K=[],V=[];for(let Q=0;Q<i;Q++)H[Q]=0,K[Q]=0,V[Q]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:H,enabledAttributes:K,attributeDivisors:V,object:j,attributes:{},index:null}}function v(j,H,K,V){const Q=u.attributes,Z=H.attributes;let ae=0;const B=K.getAttributes();for(const X in B)if(B[X].location>=0){const se=Q[X];let be=Z[X];if(be===void 0&&(X==="instanceMatrix"&&j.instanceMatrix&&(be=j.instanceMatrix),X==="instanceColor"&&j.instanceColor&&(be=j.instanceColor)),se===void 0||se.attribute!==be||be&&se.data!==be.data)return!0;ae++}return u.attributesNum!==ae||u.index!==V}function S(j,H,K,V){const Q={},Z=H.attributes;let ae=0;const B=K.getAttributes();for(const X in B)if(B[X].location>=0){let se=Z[X];se===void 0&&(X==="instanceMatrix"&&j.instanceMatrix&&(se=j.instanceMatrix),X==="instanceColor"&&j.instanceColor&&(se=j.instanceColor));const be={};be.attribute=se,se&&se.data&&(be.data=se.data),Q[X]=be,ae++}u.attributes=Q,u.attributesNum=ae,u.index=V}function N(){const j=u.newAttributes;for(let H=0,K=j.length;H<K;H++)j[H]=0}function T(j){k(j,0)}function k(j,H){const K=u.newAttributes,V=u.enabledAttributes,Q=u.attributeDivisors;K[j]=1,V[j]===0&&(t.enableVertexAttribArray(j),V[j]=1),Q[j]!==H&&((r.isWebGL2?t:e.get("ANGLE_instanced_arrays"))[r.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](j,H),Q[j]=H)}function C(){const j=u.newAttributes,H=u.enabledAttributes;for(let K=0,V=H.length;K<V;K++)H[K]!==j[K]&&(t.disableVertexAttribArray(K),H[K]=0)}function E(j,H,K,V,Q,Z,ae){ae===!0?t.vertexAttribIPointer(j,H,K,Q,Z):t.vertexAttribPointer(j,H,K,V,Q,Z)}function D(j,H,K,V){if(r.isWebGL2===!1&&(j.isInstancedMesh||V.isInstancedBufferGeometry)&&e.get("ANGLE_instanced_arrays")===null)return;N();const Q=V.attributes,Z=K.getAttributes(),ae=H.defaultAttributeValues;for(const B in Z){const X=Z[B];if(X.location>=0){let ne=Q[B];if(ne===void 0&&(B==="instanceMatrix"&&j.instanceMatrix&&(ne=j.instanceMatrix),B==="instanceColor"&&j.instanceColor&&(ne=j.instanceColor)),ne!==void 0){const se=ne.normalized,be=ne.itemSize,xe=n.get(ne);if(xe===void 0)continue;const de=xe.buffer,Pe=xe.type,ie=xe.bytesPerElement,Ne=r.isWebGL2===!0&&(Pe===t.INT||Pe===t.UNSIGNED_INT||ne.gpuType===LJ);if(ne.isInterleavedBufferAttribute){const Oe=ne.data,ge=Oe.stride,Ke=ne.offset;if(Oe.isInstancedInterleavedBuffer){for(let G=0;G<X.locationSize;G++)k(X.location+G,Oe.meshPerAttribute);j.isInstancedMesh!==!0&&V._maxInstanceCount===void 0&&(V._maxInstanceCount=Oe.meshPerAttribute*Oe.count)}else for(let G=0;G<X.locationSize;G++)T(X.location+G);t.bindBuffer(t.ARRAY_BUFFER,de);for(let G=0;G<X.locationSize;G++)E(X.location+G,be/X.locationSize,Pe,se,ge*ie,(Ke+be/X.locationSize*G)*ie,Ne)}else{if(ne.isInstancedBufferAttribute){for(let Oe=0;Oe<X.locationSize;Oe++)k(X.location+Oe,ne.meshPerAttribute);j.isInstancedMesh!==!0&&V._maxInstanceCount===void 0&&(V._maxInstanceCount=ne.meshPerAttribute*ne.count)}else for(let Oe=0;Oe<X.locationSize;Oe++)T(X.location+Oe);t.bindBuffer(t.ARRAY_BUFFER,de);for(let Oe=0;Oe<X.locationSize;Oe++)E(X.location+Oe,be/X.locationSize,Pe,se,be*ie,be/X.locationSize*Oe*ie,Ne)}}else if(ae!==void 0){const se=ae[B];if(se!==void 0)switch(se.length){case 2:t.vertexAttrib2fv(X.location,se);break;case 3:t.vertexAttrib3fv(X.location,se);break;case 4:t.vertexAttrib4fv(X.location,se);break;default:t.vertexAttrib1fv(X.location,se)}}}}C()}function A(){F();for(const j in l){const H=l[j];for(const K in H){const V=H[K];for(const Q in V)x(V[Q].object),delete V[Q];delete H[K]}delete l[j]}}function R(j){if(l[j.id]===void 0)return;const H=l[j.id];for(const K in H){const V=H[K];for(const Q in V)x(V[Q].object),delete V[Q];delete H[K]}delete l[j.id]}function U(j){for(const H in l){const K=l[H];if(K[j.id]===void 0)continue;const V=K[j.id];for(const Q in V)x(V[Q].object),delete V[Q];delete K[j.id]}}function F(){$(),d=!0,u!==c&&(u=c,m(u.object))}function $(){c.geometry=null,c.program=null,c.wireframe=!1}return{setup:f,reset:F,resetDefaultState:$,dispose:A,releaseStatesOfGeometry:R,releaseStatesOfProgram:U,initAttributes:N,enableAttribute:T,disableUnusedAttributes:C}}function vUe(t,e,n,r){const i=r.isWebGL2;let a;function o(d){a=d}function l(d,f){t.drawArrays(a,d,f),n.update(f,a,1)}function c(d,f,p){if(p===0)return;let m,x;if(i)m=t,x="drawArraysInstanced";else if(m=e.get("ANGLE_instanced_arrays"),x="drawArraysInstancedANGLE",m===null){console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}m[x](a,d,f,p),n.update(f,a,p)}function u(d,f,p){if(p===0)return;const m=e.get("WEBGL_multi_draw");if(m===null)for(let x=0;x<p;x++)this.render(d[x],f[x]);else{m.multiDrawArraysWEBGL(a,d,0,f,0,p);let x=0;for(let b=0;b<p;b++)x+=f[b];n.update(x,a,1)}}this.setMode=o,this.render=l,this.renderInstances=c,this.renderMultiDraw=u}function wUe(t,e,n){let r;function i(){if(r!==void 0)return r;if(e.has("EXT_texture_filter_anisotropic")===!0){const E=e.get("EXT_texture_filter_anisotropic");r=t.getParameter(E.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function a(E){if(E==="highp"){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";E="mediump"}return E==="mediump"&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}const o=typeof WebGL2RenderingContext<"u"&&t.constructor.name==="WebGL2RenderingContext";let l=n.precision!==void 0?n.precision:"highp";const c=a(l);c!==l&&(console.warn("THREE.WebGLRenderer:",l,"not supported, using",c,"instead."),l=c);const u=o||e.has("WEBGL_draw_buffers"),d=n.logarithmicDepthBuffer===!0,f=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),p=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),m=t.getParameter(t.MAX_TEXTURE_SIZE),x=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),b=t.getParameter(t.MAX_VERTEX_ATTRIBS),y=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),v=t.getParameter(t.MAX_VARYING_VECTORS),S=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),N=p>0,T=o||e.has("OES_texture_float"),k=N&&T,C=o?t.getParameter(t.MAX_SAMPLES):0;return{isWebGL2:o,drawBuffers:u,getMaxAnisotropy:i,getMaxPrecision:a,precision:l,logarithmicDepthBuffer:d,maxTextures:f,maxVertexTextures:p,maxTextureSize:m,maxCubemapSize:x,maxAttributes:b,maxVertexUniforms:y,maxVaryings:v,maxFragmentUniforms:S,vertexTextures:N,floatFragmentTextures:T,floatVertexTextures:k,maxSamples:C}}function _Ue(t){const e=this;let n=null,r=0,i=!1,a=!1;const o=new Hd,l=new Ln,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(f,p){const m=f.length!==0||p||r!==0||i;return i=p,r=f.length,m},this.beginShadows=function(){a=!0,d(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(f,p){n=d(f,p,0)},this.setState=function(f,p,m){const x=f.clippingPlanes,b=f.clipIntersection,y=f.clipShadows,v=t.get(f);if(!i||x===null||x.length===0||a&&!y)a?d(null):u();else{const S=a?0:r,N=S*4;let T=v.clippingState||null;c.value=T,T=d(x,p,N,m);for(let k=0;k!==N;++k)T[k]=n[k];v.clippingState=T,this.numIntersection=b?this.numPlanes:0,this.numPlanes+=S}};function u(){c.value!==n&&(c.value=n,c.needsUpdate=r>0),e.numPlanes=r,e.numIntersection=0}function d(f,p,m,x){const b=f!==null?f.length:0;let y=null;if(b!==0){if(y=c.value,x!==!0||y===null){const v=m+b*4,S=p.matrixWorldInverse;l.getNormalMatrix(S),(y===null||y.length<v)&&(y=new Float32Array(v));for(let N=0,T=m;N!==b;++N,T+=4)o.copy(f[N]).applyMatrix4(S,l),o.normal.toArray(y,T),y[T+3]=o.constant}c.value=y,c.needsUpdate=!0}return e.numPlanes=b,e.numIntersection=0,y}}function SUe(t){let e=new WeakMap;function n(o,l){return l===pD?o.mapping=nx:l===gD&&(o.mapping=rx),o}function r(o){if(o&&o.isTexture){const l=o.mapping;if(l===pD||l===gD)if(e.has(o)){const c=e.get(o).texture;return n(c,o.mapping)}else{const c=o.image;if(c&&c.height>0){const u=new OFe(c.height/2);return u.fromEquirectangularTexture(t,o),e.set(o,u),o.addEventListener("dispose",i),n(u.texture,o.mapping)}else return null}}return o}function i(o){const l=o.target;l.removeEventListener("dispose",i);const c=e.get(l);c!==void 0&&(e.delete(l),c.dispose())}function a(){e=new WeakMap}return{get:r,dispose:a}}class MUe extends ree{constructor(e=-1,n=1,r=1,i=-1,a=.1,o=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=n,this.top=r,this.bottom=i,this.near=a,this.far=o,this.updateProjectionMatrix()}copy(e,n){return super.copy(e,n),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,n,r,i,a,o){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=n,this.view.offsetX=r,this.view.offsetY=i,this.view.width=a,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),n=(this.top-this.bottom)/(2*this.zoom),r=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let a=r-e,o=r+e,l=i+n,c=i-n;if(this.view!==null&&this.view.enabled){const u=(this.right-this.left)/this.view.fullWidth/this.zoom,d=(this.top-this.bottom)/this.view.fullHeight/this.zoom;a+=u*this.view.offsetX,o=a+u*this.view.width,l-=d*this.view.offsetY,c=l-d*this.view.height}this.projectionMatrix.makeOrthographic(a,o,l,c,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const n=super.toJSON(e);return n.object.zoom=this.zoom,n.object.left=this.left,n.object.right=this.right,n.object.top=this.top,n.object.bottom=this.bottom,n.object.near=this.near,n.object.far=this.far,this.view!==null&&(n.object.view=Object.assign({},this.view)),n}}const yg=4,DG=[.125,.215,.35,.446,.526,.582],Ef=20,WC=new MUe,RG=new Zt;let KC=null,XC=0,YC=0;const Sf=(1+Math.sqrt(5))/2,Qp=1/Sf,OG=[new qe(1,1,1),new qe(-1,1,1),new qe(1,1,-1),new qe(-1,1,-1),new qe(0,Sf,Qp),new qe(0,Sf,-Qp),new qe(Qp,0,Sf),new qe(-Qp,0,Sf),new qe(Sf,Qp,0),new qe(-Sf,Qp,0)];class LG{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,n=0,r=.1,i=100){KC=this._renderer.getRenderTarget(),XC=this._renderer.getActiveCubeFace(),YC=this._renderer.getActiveMipmapLevel(),this._setSize(256);const a=this._allocateTargets();return a.depthBuffer=!0,this._sceneToCubeUV(e,r,i,a),n>0&&this._blur(a,0,0,n),this._applyPMREM(a),this._cleanup(a),a}fromEquirectangular(e,n=null){return this._fromTexture(e,n)}fromCubemap(e,n=null){return this._fromTexture(e,n)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=UG(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=IG(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(KC,XC,YC),e.scissorTest=!1,$_(e,0,0,e.width,e.height)}_fromTexture(e,n){e.mapping===nx||e.mapping===rx?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),KC=this._renderer.getRenderTarget(),XC=this._renderer.getActiveCubeFace(),YC=this._renderer.getActiveMipmapLevel();const r=n||this._allocateTargets();return this._textureToCubeUV(e,r),this._applyPMREM(r),this._cleanup(r),r}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),n=4*this._cubeSize,r={magFilter:Ko,minFilter:Ko,generateMipmaps:!1,type:xy,format:Xo,colorSpace:Vu,depthBuffer:!1},i=FG(e,n,r);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==n){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=FG(e,n,r);const{_lodMax:a}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=NUe(a)),this._blurMaterial=kUe(a,e,n)}return i}_compileMaterial(e){const n=new Dl(this._lodPlanes[0],e);this._renderer.compile(n,WC)}_sceneToCubeUV(e,n,r,i){const l=new oo(90,1,n,r),c=[1,-1,1,1,1,1],u=[1,1,1,-1,-1,-1],d=this._renderer,f=d.autoClear,p=d.toneMapping;d.getClearColor(RG),d.toneMapping=uh,d.autoClear=!1;const m=new JJ({name:"PMREM.Background",side:zs,depthWrite:!1,depthTest:!1}),x=new Dl(new mv,m);let b=!1;const y=e.background;y?y.isColor&&(m.color.copy(y),e.background=null,b=!0):(m.color.copy(RG),b=!0);for(let v=0;v<6;v++){const S=v%3;S===0?(l.up.set(0,c[v],0),l.lookAt(u[v],0,0)):S===1?(l.up.set(0,0,c[v]),l.lookAt(0,u[v],0)):(l.up.set(0,c[v],0),l.lookAt(0,0,u[v]));const N=this._cubeSize;$_(i,S*N,v>2?N:0,N,N),d.setRenderTarget(i),b&&d.render(x,l),d.render(e,l)}x.geometry.dispose(),x.material.dispose(),d.toneMapping=p,d.autoClear=f,e.background=y}_textureToCubeUV(e,n){const r=this._renderer,i=e.mapping===nx||e.mapping===rx;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=UG()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=IG());const a=i?this._cubemapMaterial:this._equirectMaterial,o=new Dl(this._lodPlanes[0],a),l=a.uniforms;l.envMap.value=e;const c=this._cubeSize;$_(n,0,0,3*c,2*c),r.setRenderTarget(n),r.render(o,WC)}_applyPMREM(e){const n=this._renderer,r=n.autoClear;n.autoClear=!1;for(let i=1;i<this._lodPlanes.length;i++){const a=Math.sqrt(this._sigmas[i]*this._sigmas[i]-this._sigmas[i-1]*this._sigmas[i-1]),o=OG[(i-1)%OG.length];this._blur(e,i-1,i,a,o)}n.autoClear=r}_blur(e,n,r,i,a){const o=this._pingPongRenderTarget;this._halfBlur(e,o,n,r,i,"latitudinal",a),this._halfBlur(o,e,r,r,i,"longitudinal",a)}_halfBlur(e,n,r,i,a,o,l){const c=this._renderer,u=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const d=3,f=new Dl(this._lodPlanes[i],u),p=u.uniforms,m=this._sizeLods[r]-1,x=isFinite(a)?Math.PI/(2*m):2*Math.PI/(2*Ef-1),b=a/x,y=isFinite(a)?1+Math.floor(d*b):Ef;y>Ef&&console.warn(`sigmaRadians, ${a}, is too large and will clip, as it requested ${y} samples when the maximum is set to ${Ef}`);const v=[];let S=0;for(let E=0;E<Ef;++E){const D=E/b,A=Math.exp(-D*D/2);v.push(A),E===0?S+=A:E<y&&(S+=2*A)}for(let E=0;E<v.length;E++)v[E]=v[E]/S;p.envMap.value=e.texture,p.samples.value=y,p.weights.value=v,p.latitudinal.value=o==="latitudinal",l&&(p.poleAxis.value=l);const{_lodMax:N}=this;p.dTheta.value=x,p.mipInt.value=N-r;const T=this._sizeLods[i],k=3*T*(i>N-yg?i-N+yg:0),C=4*(this._cubeSize-T);$_(n,k,C,3*T,2*T),c.setRenderTarget(n),c.render(f,WC)}}function NUe(t){const e=[],n=[],r=[];let i=t;const a=t-yg+1+DG.length;for(let o=0;o<a;o++){const l=Math.pow(2,i);n.push(l);let c=1/l;o>t-yg?c=DG[o-t+yg-1]:o===0&&(c=0),r.push(c);const u=1/(l-2),d=-u,f=1+u,p=[d,d,f,d,f,f,d,d,f,f,d,f],m=6,x=6,b=3,y=2,v=1,S=new Float32Array(b*x*m),N=new Float32Array(y*x*m),T=new Float32Array(v*x*m);for(let C=0;C<m;C++){const E=C%3*2/3-1,D=C>2?0:-1,A=[E,D,0,E+2/3,D,0,E+2/3,D+1,0,E,D,0,E+2/3,D+1,0,E,D+1,0];S.set(A,b*x*C),N.set(p,y*x*C);const R=[C,C,C,C,C,C];T.set(R,v*x*C)}const k=new ns;k.setAttribute("position",new go(S,b)),k.setAttribute("uv",new go(N,y)),k.setAttribute("faceIndex",new go(T,v)),e.push(k),i>yg&&i--}return{lodPlanes:e,sizeLods:n,sigmas:r}}function FG(t,e,n){const r=new ym(t,e,n);return r.texture.mapping=b2,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function $_(t,e,n,r,i){t.viewport.set(e,n,r,i),t.scissor.set(e,n,r,i)}function kUe(t,e,n){const r=new Float32Array(Ef),i=new qe(0,1,0);return new Ah({name:"SphericalGaussianBlur",defines:{n:Ef,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${t}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:r},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:uL(),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:ch,depthTest:!1,depthWrite:!1})}function IG(){return new Ah({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:uL(),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:ch,depthTest:!1,depthWrite:!1})}function UG(){return new Ah({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:uL(),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:ch,depthTest:!1,depthWrite:!1})}function uL(){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 EUe(t){let e=new WeakMap,n=null;function r(l){if(l&&l.isTexture){const c=l.mapping,u=c===pD||c===gD,d=c===nx||c===rx;if(u||d)if(l.isRenderTargetTexture&&l.needsPMREMUpdate===!0){l.needsPMREMUpdate=!1;let f=e.get(l);return n===null&&(n=new LG(t)),f=u?n.fromEquirectangular(l,f):n.fromCubemap(l,f),e.set(l,f),f.texture}else{if(e.has(l))return e.get(l).texture;{const f=l.image;if(u&&f&&f.height>0||d&&f&&i(f)){n===null&&(n=new LG(t));const p=u?n.fromEquirectangular(l):n.fromCubemap(l);return e.set(l,p),l.addEventListener("dispose",a),p.texture}else return null}}}return l}function i(l){let c=0;const u=6;for(let d=0;d<u;d++)l[d]!==void 0&&c++;return c===u}function a(l){const c=l.target;c.removeEventListener("dispose",a);const u=e.get(c);u!==void 0&&(e.delete(c),u.dispose())}function o(){e=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:r,dispose:o}}function TUe(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 AUe(t,e,n,r){const i={},a=new WeakMap;function o(f){const p=f.target;p.index!==null&&e.remove(p.index);for(const x in p.attributes)e.remove(p.attributes[x]);for(const x in p.morphAttributes){const b=p.morphAttributes[x];for(let y=0,v=b.length;y<v;y++)e.remove(b[y])}p.removeEventListener("dispose",o),delete i[p.id];const m=a.get(p);m&&(e.remove(m),a.delete(p)),r.releaseStatesOfGeometry(p),p.isInstancedBufferGeometry===!0&&delete p._maxInstanceCount,n.memory.geometries--}function l(f,p){return i[p.id]===!0||(p.addEventListener("dispose",o),i[p.id]=!0,n.memory.geometries++),p}function c(f){const p=f.attributes;for(const x in p)e.update(p[x],t.ARRAY_BUFFER);const m=f.morphAttributes;for(const x in m){const b=m[x];for(let y=0,v=b.length;y<v;y++)e.update(b[y],t.ARRAY_BUFFER)}}function u(f){const p=[],m=f.index,x=f.attributes.position;let b=0;if(m!==null){const S=m.array;b=m.version;for(let N=0,T=S.length;N<T;N+=3){const k=S[N+0],C=S[N+1],E=S[N+2];p.push(k,C,C,E,E,k)}}else if(x!==void 0){const S=x.array;b=x.version;for(let N=0,T=S.length/3-1;N<T;N+=3){const k=N+0,C=N+1,E=N+2;p.push(k,C,C,E,E,k)}}else return;const y=new(WJ(p)?tee:eee)(p,1);y.version=b;const v=a.get(f);v&&e.remove(v),a.set(f,y)}function d(f){const p=a.get(f);if(p){const m=f.index;m!==null&&p.version<m.version&&u(f)}else u(f);return a.get(f)}return{get:l,update:c,getWireframeAttribute:d}}function CUe(t,e,n,r){const i=r.isWebGL2;let a;function o(m){a=m}let l,c;function u(m){l=m.type,c=m.bytesPerElement}function d(m,x){t.drawElements(a,x,l,m*c),n.update(x,a,1)}function f(m,x,b){if(b===0)return;let y,v;if(i)y=t,v="drawElementsInstanced";else if(y=e.get("ANGLE_instanced_arrays"),v="drawElementsInstancedANGLE",y===null){console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}y[v](a,x,l,m*c,b),n.update(x,a,b)}function p(m,x,b){if(b===0)return;const y=e.get("WEBGL_multi_draw");if(y===null)for(let v=0;v<b;v++)this.render(m[v]/c,x[v]);else{y.multiDrawElementsWEBGL(a,x,0,l,m,0,b);let v=0;for(let S=0;S<b;S++)v+=x[S];n.update(v,a,1)}}this.setMode=o,this.setIndex=u,this.render=d,this.renderInstances=f,this.renderMultiDraw=p}function jUe(t){const e={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function r(a,o,l){switch(n.calls++,o){case t.TRIANGLES:n.triangles+=l*(a/3);break;case t.LINES:n.lines+=l*(a/2);break;case t.LINE_STRIP:n.lines+=l*(a-1);break;case t.LINE_LOOP:n.lines+=l*a;break;case t.POINTS:n.points+=l*a;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",o);break}}function i(){n.calls=0,n.triangles=0,n.points=0,n.lines=0}return{memory:e,render:n,programs:null,autoReset:!0,reset:i,update:r}}function PUe(t,e){return t[0]-e[0]}function DUe(t,e){return Math.abs(e[1])-Math.abs(t[1])}function RUe(t,e,n){const r={},i=new Float32Array(8),a=new WeakMap,o=new Cr,l=[];for(let u=0;u<8;u++)l[u]=[u,0];function c(u,d,f){const p=u.morphTargetInfluences;if(e.isWebGL2===!0){const x=d.morphAttributes.position||d.morphAttributes.normal||d.morphAttributes.color,b=x!==void 0?x.length:0;let y=a.get(d);if(y===void 0||y.count!==b){let H=function(){$.dispose(),a.delete(d),d.removeEventListener("dispose",H)};var m=H;y!==void 0&&y.texture.dispose();const N=d.morphAttributes.position!==void 0,T=d.morphAttributes.normal!==void 0,k=d.morphAttributes.color!==void 0,C=d.morphAttributes.position||[],E=d.morphAttributes.normal||[],D=d.morphAttributes.color||[];let A=0;N===!0&&(A=1),T===!0&&(A=2),k===!0&&(A=3);let R=d.attributes.position.count*A,U=1;R>e.maxTextureSize&&(U=Math.ceil(R/e.maxTextureSize),R=e.maxTextureSize);const F=new Float32Array(R*U*4*b),$=new YJ(F,R,U,b);$.type=_u,$.needsUpdate=!0;const j=A*4;for(let K=0;K<b;K++){const V=C[K],Q=E[K],Z=D[K],ae=R*U*4*K;for(let B=0;B<V.count;B++){const X=B*j;N===!0&&(o.fromBufferAttribute(V,B),F[ae+X+0]=o.x,F[ae+X+1]=o.y,F[ae+X+2]=o.z,F[ae+X+3]=0),T===!0&&(o.fromBufferAttribute(Q,B),F[ae+X+4]=o.x,F[ae+X+5]=o.y,F[ae+X+6]=o.z,F[ae+X+7]=0),k===!0&&(o.fromBufferAttribute(Z,B),F[ae+X+8]=o.x,F[ae+X+9]=o.y,F[ae+X+10]=o.z,F[ae+X+11]=Z.itemSize===4?o.w:1)}}y={count:b,texture:$,size:new xn(R,U)},a.set(d,y),d.addEventListener("dispose",H)}let v=0;for(let N=0;N<p.length;N++)v+=p[N];const S=d.morphTargetsRelative?1:1-v;f.getUniforms().setValue(t,"morphTargetBaseInfluence",S),f.getUniforms().setValue(t,"morphTargetInfluences",p),f.getUniforms().setValue(t,"morphTargetsTexture",y.texture,n),f.getUniforms().setValue(t,"morphTargetsTextureSize",y.size)}else{const x=p===void 0?0:p.length;let b=r[d.id];if(b===void 0||b.length!==x){b=[];for(let T=0;T<x;T++)b[T]=[T,0];r[d.id]=b}for(let T=0;T<x;T++){const k=b[T];k[0]=T,k[1]=p[T]}b.sort(DUe);for(let T=0;T<8;T++)T<x&&b[T][1]?(l[T][0]=b[T][0],l[T][1]=b[T][1]):(l[T][0]=Number.MAX_SAFE_INTEGER,l[T][1]=0);l.sort(PUe);const y=d.morphAttributes.position,v=d.morphAttributes.normal;let S=0;for(let T=0;T<8;T++){const k=l[T],C=k[0],E=k[1];C!==Number.MAX_SAFE_INTEGER&&E?(y&&d.getAttribute("morphTarget"+T)!==y[C]&&d.setAttribute("morphTarget"+T,y[C]),v&&d.getAttribute("morphNormal"+T)!==v[C]&&d.setAttribute("morphNormal"+T,v[C]),i[T]=E,S+=E):(y&&d.hasAttribute("morphTarget"+T)===!0&&d.deleteAttribute("morphTarget"+T),v&&d.hasAttribute("morphNormal"+T)===!0&&d.deleteAttribute("morphNormal"+T),i[T]=0)}const N=d.morphTargetsRelative?1:1-S;f.getUniforms().setValue(t,"morphTargetBaseInfluence",N),f.getUniforms().setValue(t,"morphTargetInfluences",i)}}return{update:c}}function OUe(t,e,n,r){let i=new WeakMap;function a(c){const u=r.render.frame,d=c.geometry,f=e.get(c,d);if(i.get(f)!==u&&(e.update(f),i.set(f,u)),c.isInstancedMesh&&(c.hasEventListener("dispose",l)===!1&&c.addEventListener("dispose",l),i.get(c)!==u&&(n.update(c.instanceMatrix,t.ARRAY_BUFFER),c.instanceColor!==null&&n.update(c.instanceColor,t.ARRAY_BUFFER),i.set(c,u))),c.isSkinnedMesh){const p=c.skeleton;i.get(p)!==u&&(p.update(),i.set(p,u))}return f}function o(){i=new WeakMap}function l(c){const u=c.target;u.removeEventListener("dispose",l),n.remove(u.instanceMatrix),u.instanceColor!==null&&n.remove(u.instanceColor)}return{update:a,dispose:o}}class see extends Bs{constructor(e,n,r,i,a,o,l,c,u,d){if(d=d!==void 0?d:Wf,d!==Wf&&d!==ix)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");r===void 0&&d===Wf&&(r=Zd),r===void 0&&d===ix&&(r=qf),super(null,i,a,o,l,c,d,r,u),this.isDepthTexture=!0,this.image={width:e,height:n},this.magFilter=l!==void 0?l:Da,this.minFilter=c!==void 0?c:Da,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.compareFunction=e.compareFunction,this}toJSON(e){const n=super.toJSON(e);return this.compareFunction!==null&&(n.compareFunction=this.compareFunction),n}}const oee=new Bs,lee=new see(1,1);lee.compareFunction=GJ;const cee=new YJ,uee=new yFe,dee=new iee,zG=[],BG=[],HG=new Float32Array(16),$G=new Float32Array(9),VG=new Float32Array(4);function Rx(t,e,n){const r=t[0];if(r<=0||r>0)return t;const i=e*n;let a=zG[i];if(a===void 0&&(a=new Float32Array(i),zG[i]=a),e!==0){r.toArray(a,0);for(let o=1,l=0;o!==e;++o)l+=n,t[o].toArray(a,l)}return a}function ea(t,e){if(t.length!==e.length)return!1;for(let n=0,r=t.length;n<r;n++)if(t[n]!==e[n])return!1;return!0}function ta(t,e){for(let n=0,r=e.length;n<r;n++)t[n]=e[n]}function w2(t,e){let n=BG[e];n===void 0&&(n=new Int32Array(e),BG[e]=n);for(let r=0;r!==e;++r)n[r]=t.allocateTextureUnit();return n}function LUe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function FUe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y)&&(t.uniform2f(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(ea(n,e))return;t.uniform2fv(this.addr,e),ta(n,e)}}function IUe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(t.uniform3f(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else if(e.r!==void 0)(n[0]!==e.r||n[1]!==e.g||n[2]!==e.b)&&(t.uniform3f(this.addr,e.r,e.g,e.b),n[0]=e.r,n[1]=e.g,n[2]=e.b);else{if(ea(n,e))return;t.uniform3fv(this.addr,e),ta(n,e)}}function UUe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||n[3]!==e.w)&&(t.uniform4f(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(ea(n,e))return;t.uniform4fv(this.addr,e),ta(n,e)}}function zUe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(ea(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),ta(n,e)}else{if(ea(n,r))return;VG.set(r),t.uniformMatrix2fv(this.addr,!1,VG),ta(n,r)}}function BUe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(ea(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),ta(n,e)}else{if(ea(n,r))return;$G.set(r),t.uniformMatrix3fv(this.addr,!1,$G),ta(n,r)}}function HUe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(ea(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),ta(n,e)}else{if(ea(n,r))return;HG.set(r),t.uniformMatrix4fv(this.addr,!1,HG),ta(n,r)}}function $Ue(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function VUe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y)&&(t.uniform2i(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(ea(n,e))return;t.uniform2iv(this.addr,e),ta(n,e)}}function GUe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(t.uniform3i(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else{if(ea(n,e))return;t.uniform3iv(this.addr,e),ta(n,e)}}function qUe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||n[3]!==e.w)&&(t.uniform4i(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(ea(n,e))return;t.uniform4iv(this.addr,e),ta(n,e)}}function WUe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function KUe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y)&&(t.uniform2ui(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(ea(n,e))return;t.uniform2uiv(this.addr,e),ta(n,e)}}function XUe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(t.uniform3ui(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else{if(ea(n,e))return;t.uniform3uiv(this.addr,e),ta(n,e)}}function YUe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||n[3]!==e.w)&&(t.uniform4ui(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(ea(n,e))return;t.uniform4uiv(this.addr,e),ta(n,e)}}function QUe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i);const a=this.type===t.SAMPLER_2D_SHADOW?lee:oee;n.setTexture2D(e||a,i)}function ZUe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(e||uee,i)}function JUe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTextureCube(e||dee,i)}function eze(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(e||cee,i)}function tze(t){switch(t){case 5126:return LUe;case 35664:return FUe;case 35665:return IUe;case 35666:return UUe;case 35674:return zUe;case 35675:return BUe;case 35676:return HUe;case 5124:case 35670:return $Ue;case 35667:case 35671:return VUe;case 35668:case 35672:return GUe;case 35669:case 35673:return qUe;case 5125:return WUe;case 36294:return KUe;case 36295:return XUe;case 36296:return YUe;case 35678:case 36198:case 36298:case 36306:case 35682:return QUe;case 35679:case 36299:case 36307:return ZUe;case 35680:case 36300:case 36308:case 36293:return JUe;case 36289:case 36303:case 36311:case 36292:return eze}}function nze(t,e){t.uniform1fv(this.addr,e)}function rze(t,e){const n=Rx(e,this.size,2);t.uniform2fv(this.addr,n)}function ize(t,e){const n=Rx(e,this.size,3);t.uniform3fv(this.addr,n)}function aze(t,e){const n=Rx(e,this.size,4);t.uniform4fv(this.addr,n)}function sze(t,e){const n=Rx(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function oze(t,e){const n=Rx(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function lze(t,e){const n=Rx(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function cze(t,e){t.uniform1iv(this.addr,e)}function uze(t,e){t.uniform2iv(this.addr,e)}function dze(t,e){t.uniform3iv(this.addr,e)}function hze(t,e){t.uniform4iv(this.addr,e)}function fze(t,e){t.uniform1uiv(this.addr,e)}function mze(t,e){t.uniform2uiv(this.addr,e)}function pze(t,e){t.uniform3uiv(this.addr,e)}function gze(t,e){t.uniform4uiv(this.addr,e)}function xze(t,e,n){const r=this.cache,i=e.length,a=w2(n,i);ea(r,a)||(t.uniform1iv(this.addr,a),ta(r,a));for(let o=0;o!==i;++o)n.setTexture2D(e[o]||oee,a[o])}function bze(t,e,n){const r=this.cache,i=e.length,a=w2(n,i);ea(r,a)||(t.uniform1iv(this.addr,a),ta(r,a));for(let o=0;o!==i;++o)n.setTexture3D(e[o]||uee,a[o])}function yze(t,e,n){const r=this.cache,i=e.length,a=w2(n,i);ea(r,a)||(t.uniform1iv(this.addr,a),ta(r,a));for(let o=0;o!==i;++o)n.setTextureCube(e[o]||dee,a[o])}function vze(t,e,n){const r=this.cache,i=e.length,a=w2(n,i);ea(r,a)||(t.uniform1iv(this.addr,a),ta(r,a));for(let o=0;o!==i;++o)n.setTexture2DArray(e[o]||cee,a[o])}function wze(t){switch(t){case 5126:return nze;case 35664:return rze;case 35665:return ize;case 35666:return aze;case 35674:return sze;case 35675:return oze;case 35676:return lze;case 5124:case 35670:return cze;case 35667:case 35671:return uze;case 35668:case 35672:return dze;case 35669:case 35673:return hze;case 5125:return fze;case 36294:return mze;case 36295:return pze;case 36296:return gze;case 35678:case 36198:case 36298:case 36306:case 35682:return xze;case 35679:case 36299:case 36307:return bze;case 35680:case 36300:case 36308:case 36293:return yze;case 36289:case 36303:case 36311:case 36292:return vze}}class _ze{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.setValue=tze(n.type)}}class Sze{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.size=n.size,this.setValue=wze(n.type)}}class Mze{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,n,r){const i=this.seq;for(let a=0,o=i.length;a!==o;++a){const l=i[a];l.setValue(e,n[l.id],r)}}}const QC=/(\w+)(\])?(\[|\.)?/g;function GG(t,e){t.seq.push(e),t.map[e.id]=e}function Nze(t,e,n){const r=t.name,i=r.length;for(QC.lastIndex=0;;){const a=QC.exec(r),o=QC.lastIndex;let l=a[1];const c=a[2]==="]",u=a[3];if(c&&(l=l|0),u===void 0||u==="["&&o+2===i){GG(n,u===void 0?new _ze(l,t,e):new Sze(l,t,e));break}else{let f=n.map[l];f===void 0&&(f=new Mze(l),GG(n,f)),n=f}}}class P1{constructor(e,n){this.seq=[],this.map={};const r=e.getProgramParameter(n,e.ACTIVE_UNIFORMS);for(let i=0;i<r;++i){const a=e.getActiveUniform(n,i),o=e.getUniformLocation(n,a.name);Nze(a,o,this)}}setValue(e,n,r,i){const a=this.map[n];a!==void 0&&a.setValue(e,r,i)}setOptional(e,n,r){const i=n[r];i!==void 0&&this.setValue(e,r,i)}static upload(e,n,r,i){for(let a=0,o=n.length;a!==o;++a){const l=n[a],c=r[l.id];c.needsUpdate!==!1&&l.setValue(e,c.value,i)}}static seqWithValue(e,n){const r=[];for(let i=0,a=e.length;i!==a;++i){const o=e[i];o.id in n&&r.push(o)}return r}}function qG(t,e,n){const r=t.createShader(e);return t.shaderSource(r,n),t.compileShader(r),r}const kze=37297;let Eze=0;function Tze(t,e){const n=t.split(`
- `),r=[],i=Math.max(e-6,0),a=Math.min(e+6,n.length);for(let o=i;o<a;o++){const l=o+1;r.push(`${l===e?">":" "} ${l}: ${n[o]}`)}return r.join(`
- `)}function Aze(t){const e=Er.getPrimaries(Er.workingColorSpace),n=Er.getPrimaries(t);let r;switch(e===n?r="":e===tM&&n===eM?r="LinearDisplayP3ToLinearSRGB":e===eM&&n===tM&&(r="LinearSRGBToLinearDisplayP3"),t){case Vu:case y2:return[r,"LinearTransferOETF"];case Ra:case aL:return[r,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",t),[r,"LinearTransferOETF"]}}function WG(t,e,n){const r=t.getShaderParameter(e,t.COMPILE_STATUS),i=t.getShaderInfoLog(e).trim();if(r&&i==="")return"";const a=/ERROR: 0:(\d+)/.exec(i);if(a){const o=parseInt(a[1]);return n.toUpperCase()+`
- `+i+`
- `+Tze(t.getShaderSource(e),o)}else return i}function Cze(t,e){const n=Aze(e);return`vec4 ${t}( vec4 value ) { return ${n[0]}( ${n[1]}( value ) ); }`}function jze(t,e){let n;switch(e){case CLe:n="Linear";break;case jLe:n="Reinhard";break;case PLe:n="OptimizedCineon";break;case DLe:n="ACESFilmic";break;case RLe:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}function Pze(t){return[t.extensionDerivatives||t.envMapCubeUVHeight||t.bumpMap||t.normalMapTangentSpace||t.clearcoatNormalMap||t.flatShading||t.shaderID==="physical"?"#extension GL_OES_standard_derivatives : enable":"",(t.extensionFragDepth||t.logarithmicDepthBuffer)&&t.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",t.extensionDrawBuffers&&t.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(t.extensionShaderTextureLOD||t.envMap||t.transmission)&&t.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(c0).join(`
- `)}function Dze(t){const e=[];for(const n in t){const r=t[n];r!==!1&&e.push("#define "+n+" "+r)}return e.join(`
- `)}function Rze(t,e){const n={},r=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let i=0;i<r;i++){const a=t.getActiveAttrib(e,i),o=a.name;let l=1;a.type===t.FLOAT_MAT2&&(l=2),a.type===t.FLOAT_MAT3&&(l=3),a.type===t.FLOAT_MAT4&&(l=4),n[o]={type:a.type,location:t.getAttribLocation(e,o),locationSize:l}}return n}function c0(t){return t!==""}function KG(t,e){const n=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return t.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,n).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function XG(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const Oze=/^[ \t]*#include +<([\w\d./]+)>/gm;function _D(t){return t.replace(Oze,Fze)}const Lze=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function Fze(t,e){let n=En[e];if(n===void 0){const r=Lze.get(e);if(r!==void 0)n=En[r],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,r);else throw new Error("Can not resolve #include <"+e+">")}return _D(n)}const Ize=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function YG(t){return t.replace(Ize,Uze)}function Uze(t,e,n,r){let i="";for(let a=parseInt(e);a<parseInt(n);a++)i+=r.replace(/\[\s*i\s*\]/g,"[ "+a+" ]").replace(/UNROLLED_LOOP_INDEX/g,a);return i}function QG(t){let e="precision "+t.precision+` float;
- 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 zze(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===RJ?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===iLe?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===lu&&(e="SHADOWMAP_TYPE_VSM"),e}function Bze(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case nx:case rx:e="ENVMAP_TYPE_CUBE";break;case b2:e="ENVMAP_TYPE_CUBE_UV";break}return e}function Hze(t){let e="ENVMAP_MODE_REFLECTION";if(t.envMap)switch(t.envMapMode){case rx:e="ENVMAP_MODE_REFRACTION";break}return e}function $ze(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case rL:e="ENVMAP_BLENDING_MULTIPLY";break;case TLe:e="ENVMAP_BLENDING_MIX";break;case ALe:e="ENVMAP_BLENDING_ADD";break}return e}function Vze(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 Gze(t,e,n,r){const i=t.getContext(),a=n.defines;let o=n.vertexShader,l=n.fragmentShader;const c=zze(n),u=Bze(n),d=Hze(n),f=$ze(n),p=Vze(n),m=n.isWebGL2?"":Pze(n),x=Dze(a),b=i.createProgram();let y,v,S=n.glslVersion?"#version "+n.glslVersion+`
- `:"";n.isRawShaderMaterial?(y=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(c0).join(`
- `),y.length>0&&(y+=`
- `),v=[m,"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(c0).join(`
- `),v.length>0&&(v+=`
- `)):(y=[QG(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x,n.batching?"#define USE_BATCHING":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+d:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&n.flatShading===!1?"#define USE_MORPHNORMALS":"",n.morphColors&&n.isWebGL2?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.useLegacyLights?"#define LEGACY_LIGHTS":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )"," attribute vec3 morphTarget0;"," attribute vec3 morphTarget1;"," attribute vec3 morphTarget2;"," attribute vec3 morphTarget3;"," #ifdef USE_MORPHNORMALS"," attribute vec3 morphNormal0;"," attribute vec3 morphNormal1;"," attribute vec3 morphNormal2;"," attribute vec3 morphNormal3;"," #else"," attribute vec3 morphTarget4;"," attribute vec3 morphTarget5;"," attribute vec3 morphTarget6;"," attribute vec3 morphTarget7;"," #endif","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
- `].filter(c0).join(`
- `),v=[m,QG(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.envMap?"#define "+d:"",n.envMap?"#define "+f:"",p?"#define CUBEUV_TEXEL_WIDTH "+p.texelWidth:"",p?"#define CUBEUV_TEXEL_HEIGHT "+p.texelHeight:"",p?"#define CUBEUV_MAX_MIP "+p.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.useLegacyLights?"#define LEGACY_LIGHTS":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==uh?"#define TONE_MAPPING":"",n.toneMapping!==uh?En.tonemapping_pars_fragment:"",n.toneMapping!==uh?jze("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",En.colorspace_pars_fragment,Cze("linearToOutputTexel",n.outputColorSpace),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
- `].filter(c0).join(`
- `)),o=_D(o),o=KG(o,n),o=XG(o,n),l=_D(l),l=KG(l,n),l=XG(l,n),o=YG(o),l=YG(l),n.isWebGL2&&n.isRawShaderMaterial!==!0&&(S=`#version 300 es
- `,y=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join(`
- `)+`
- `+y,v=["precision mediump sampler2DArray;","#define varying in",n.glslVersion===pG?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===pG?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`
- `)+`
- `+v);const N=S+y+o,T=S+v+l,k=qG(i,i.VERTEX_SHADER,N),C=qG(i,i.FRAGMENT_SHADER,T);i.attachShader(b,k),i.attachShader(b,C),n.index0AttributeName!==void 0?i.bindAttribLocation(b,0,n.index0AttributeName):n.morphTargets===!0&&i.bindAttribLocation(b,0,"position"),i.linkProgram(b);function E(U){if(t.debug.checkShaderErrors){const F=i.getProgramInfoLog(b).trim(),$=i.getShaderInfoLog(k).trim(),j=i.getShaderInfoLog(C).trim();let H=!0,K=!0;if(i.getProgramParameter(b,i.LINK_STATUS)===!1)if(H=!1,typeof t.debug.onShaderError=="function")t.debug.onShaderError(i,b,k,C);else{const V=WG(i,k,"vertex"),Q=WG(i,C,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(b,i.VALIDATE_STATUS)+`
- Program Info Log: `+F+`
- `+V+`
- `+Q)}else F!==""?console.warn("THREE.WebGLProgram: Program Info Log:",F):($===""||j==="")&&(K=!1);K&&(U.diagnostics={runnable:H,programLog:F,vertexShader:{log:$,prefix:y},fragmentShader:{log:j,prefix:v}})}i.deleteShader(k),i.deleteShader(C),D=new P1(i,b),A=Rze(i,b)}let D;this.getUniforms=function(){return D===void 0&&E(this),D};let A;this.getAttributes=function(){return A===void 0&&E(this),A};let R=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return R===!1&&(R=i.getProgramParameter(b,kze)),R},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(b),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=Eze++,this.cacheKey=e,this.usedTimes=1,this.program=b,this.vertexShader=k,this.fragmentShader=C,this}let qze=0;class Wze{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const n=e.vertexShader,r=e.fragmentShader,i=this._getShaderStage(n),a=this._getShaderStage(r),o=this._getShaderCacheForMaterial(e);return o.has(i)===!1&&(o.add(i),i.usedTimes++),o.has(a)===!1&&(o.add(a),a.usedTimes++),this}remove(e){const n=this.materialCache.get(e);for(const r of n)r.usedTimes--,r.usedTimes===0&&this.shaderCache.delete(r.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const n=this.materialCache;let r=n.get(e);return r===void 0&&(r=new Set,n.set(e,r)),r}_getShaderStage(e){const n=this.shaderCache;let r=n.get(e);return r===void 0&&(r=new Kze(e),n.set(e,r)),r}}class Kze{constructor(e){this.id=qze++,this.code=e,this.usedTimes=0}}function Xze(t,e,n,r,i,a,o){const l=new QJ,c=new Wze,u=[],d=i.isWebGL2,f=i.logarithmicDepthBuffer,p=i.vertexTextures;let m=i.precision;const x={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function b(A){return A===0?"uv":`uv${A}`}function y(A,R,U,F,$){const j=F.fog,H=$.geometry,K=A.isMeshStandardMaterial?F.environment:null,V=(A.isMeshStandardMaterial?n:e).get(A.envMap||K),Q=V&&V.mapping===b2?V.image.height:null,Z=x[A.type];A.precision!==null&&(m=i.getMaxPrecision(A.precision),m!==A.precision&&console.warn("THREE.WebGLProgram.getParameters:",A.precision,"not supported, using",m,"instead."));const ae=H.morphAttributes.position||H.morphAttributes.normal||H.morphAttributes.color,B=ae!==void 0?ae.length:0;let X=0;H.morphAttributes.position!==void 0&&(X=1),H.morphAttributes.normal!==void 0&&(X=2),H.morphAttributes.color!==void 0&&(X=3);let ne,se,be,xe;if(Z){const Bt=Rs[Z];ne=Bt.vertexShader,se=Bt.fragmentShader}else ne=A.vertexShader,se=A.fragmentShader,c.update(A),be=c.getVertexShaderID(A),xe=c.getFragmentShaderID(A);const de=t.getRenderTarget(),Pe=$.isInstancedMesh===!0,ie=$.isBatchedMesh===!0,Ne=!!A.map,Oe=!!A.matcap,ge=!!V,Ke=!!A.aoMap,G=!!A.lightMap,Y=!!A.bumpMap,ce=!!A.normalMap,q=!!A.displacementMap,te=!!A.emissiveMap,I=!!A.metalnessMap,fe=!!A.roughnessMap,me=A.anisotropy>0,Ee=A.clearcoat>0,z=A.iridescence>0,O=A.sheen>0,ee=A.transmission>0,le=me&&!!A.anisotropyMap,_e=Ee&&!!A.clearcoatMap,we=Ee&&!!A.clearcoatNormalMap,re=Ee&&!!A.clearcoatRoughnessMap,Fe=z&&!!A.iridescenceMap,He=z&&!!A.iridescenceThicknessMap,Ve=O&&!!A.sheenColorMap,$e=O&&!!A.sheenRoughnessMap,ye=!!A.specularMap,je=!!A.specularColorMap,Be=!!A.specularIntensityMap,Se=ee&&!!A.transmissionMap,Xe=ee&&!!A.thicknessMap,Me=!!A.gradientMap,tt=!!A.alphaMap,ke=A.alphaTest>0,We=!!A.alphaHash,ze=!!A.extensions,W=!!H.attributes.uv1,De=!!H.attributes.uv2,Ye=!!H.attributes.uv3;let xt=uh;return A.toneMapped&&(de===null||de.isXRRenderTarget===!0)&&(xt=t.toneMapping),{isWebGL2:d,shaderID:Z,shaderType:A.type,shaderName:A.name,vertexShader:ne,fragmentShader:se,defines:A.defines,customVertexShaderID:be,customFragmentShaderID:xe,isRawShaderMaterial:A.isRawShaderMaterial===!0,glslVersion:A.glslVersion,precision:m,batching:ie,instancing:Pe,instancingColor:Pe&&$.instanceColor!==null,supportsVertexTextures:p,outputColorSpace:de===null?t.outputColorSpace:de.isXRRenderTarget===!0?de.texture.colorSpace:Vu,map:Ne,matcap:Oe,envMap:ge,envMapMode:ge&&V.mapping,envMapCubeUVHeight:Q,aoMap:Ke,lightMap:G,bumpMap:Y,normalMap:ce,displacementMap:p&&q,emissiveMap:te,normalMapObjectSpace:ce&&A.normalMapType===qLe,normalMapTangentSpace:ce&&A.normalMapType===VJ,metalnessMap:I,roughnessMap:fe,anisotropy:me,anisotropyMap:le,clearcoat:Ee,clearcoatMap:_e,clearcoatNormalMap:we,clearcoatRoughnessMap:re,iridescence:z,iridescenceMap:Fe,iridescenceThicknessMap:He,sheen:O,sheenColorMap:Ve,sheenRoughnessMap:$e,specularMap:ye,specularColorMap:je,specularIntensityMap:Be,transmission:ee,transmissionMap:Se,thicknessMap:Xe,gradientMap:Me,opaque:A.transparent===!1&&A.blending===jg,alphaMap:tt,alphaTest:ke,alphaHash:We,combine:A.combine,mapUv:Ne&&b(A.map.channel),aoMapUv:Ke&&b(A.aoMap.channel),lightMapUv:G&&b(A.lightMap.channel),bumpMapUv:Y&&b(A.bumpMap.channel),normalMapUv:ce&&b(A.normalMap.channel),displacementMapUv:q&&b(A.displacementMap.channel),emissiveMapUv:te&&b(A.emissiveMap.channel),metalnessMapUv:I&&b(A.metalnessMap.channel),roughnessMapUv:fe&&b(A.roughnessMap.channel),anisotropyMapUv:le&&b(A.anisotropyMap.channel),clearcoatMapUv:_e&&b(A.clearcoatMap.channel),clearcoatNormalMapUv:we&&b(A.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:re&&b(A.clearcoatRoughnessMap.channel),iridescenceMapUv:Fe&&b(A.iridescenceMap.channel),iridescenceThicknessMapUv:He&&b(A.iridescenceThicknessMap.channel),sheenColorMapUv:Ve&&b(A.sheenColorMap.channel),sheenRoughnessMapUv:$e&&b(A.sheenRoughnessMap.channel),specularMapUv:ye&&b(A.specularMap.channel),specularColorMapUv:je&&b(A.specularColorMap.channel),specularIntensityMapUv:Be&&b(A.specularIntensityMap.channel),transmissionMapUv:Se&&b(A.transmissionMap.channel),thicknessMapUv:Xe&&b(A.thicknessMap.channel),alphaMapUv:tt&&b(A.alphaMap.channel),vertexTangents:!!H.attributes.tangent&&(ce||me),vertexColors:A.vertexColors,vertexAlphas:A.vertexColors===!0&&!!H.attributes.color&&H.attributes.color.itemSize===4,vertexUv1s:W,vertexUv2s:De,vertexUv3s:Ye,pointsUvs:$.isPoints===!0&&!!H.attributes.uv&&(Ne||tt),fog:!!j,useFog:A.fog===!0,fogExp2:j&&j.isFogExp2,flatShading:A.flatShading===!0,sizeAttenuation:A.sizeAttenuation===!0,logarithmicDepthBuffer:f,skinning:$.isSkinnedMesh===!0,morphTargets:H.morphAttributes.position!==void 0,morphNormals:H.morphAttributes.normal!==void 0,morphColors:H.morphAttributes.color!==void 0,morphTargetsCount:B,morphTextureStride:X,numDirLights:R.directional.length,numPointLights:R.point.length,numSpotLights:R.spot.length,numSpotLightMaps:R.spotLightMap.length,numRectAreaLights:R.rectArea.length,numHemiLights:R.hemi.length,numDirLightShadows:R.directionalShadowMap.length,numPointLightShadows:R.pointShadowMap.length,numSpotLightShadows:R.spotShadowMap.length,numSpotLightShadowsWithMaps:R.numSpotLightShadowsWithMaps,numLightProbes:R.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:A.dithering,shadowMapEnabled:t.shadowMap.enabled&&U.length>0,shadowMapType:t.shadowMap.type,toneMapping:xt,useLegacyLights:t._useLegacyLights,decodeVideoTexture:Ne&&A.map.isVideoTexture===!0&&Er.getTransfer(A.map.colorSpace)===Gr,premultipliedAlpha:A.premultipliedAlpha,doubleSided:A.side===pu,flipSided:A.side===zs,useDepthPacking:A.depthPacking>=0,depthPacking:A.depthPacking||0,index0AttributeName:A.index0AttributeName,extensionDerivatives:ze&&A.extensions.derivatives===!0,extensionFragDepth:ze&&A.extensions.fragDepth===!0,extensionDrawBuffers:ze&&A.extensions.drawBuffers===!0,extensionShaderTextureLOD:ze&&A.extensions.shaderTextureLOD===!0,rendererExtensionFragDepth:d||r.has("EXT_frag_depth"),rendererExtensionDrawBuffers:d||r.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:d||r.has("EXT_shader_texture_lod"),rendererExtensionParallelShaderCompile:r.has("KHR_parallel_shader_compile"),customProgramCacheKey:A.customProgramCacheKey()}}function v(A){const R=[];if(A.shaderID?R.push(A.shaderID):(R.push(A.customVertexShaderID),R.push(A.customFragmentShaderID)),A.defines!==void 0)for(const U in A.defines)R.push(U),R.push(A.defines[U]);return A.isRawShaderMaterial===!1&&(S(R,A),N(R,A),R.push(t.outputColorSpace)),R.push(A.customProgramCacheKey),R.join()}function S(A,R){A.push(R.precision),A.push(R.outputColorSpace),A.push(R.envMapMode),A.push(R.envMapCubeUVHeight),A.push(R.mapUv),A.push(R.alphaMapUv),A.push(R.lightMapUv),A.push(R.aoMapUv),A.push(R.bumpMapUv),A.push(R.normalMapUv),A.push(R.displacementMapUv),A.push(R.emissiveMapUv),A.push(R.metalnessMapUv),A.push(R.roughnessMapUv),A.push(R.anisotropyMapUv),A.push(R.clearcoatMapUv),A.push(R.clearcoatNormalMapUv),A.push(R.clearcoatRoughnessMapUv),A.push(R.iridescenceMapUv),A.push(R.iridescenceThicknessMapUv),A.push(R.sheenColorMapUv),A.push(R.sheenRoughnessMapUv),A.push(R.specularMapUv),A.push(R.specularColorMapUv),A.push(R.specularIntensityMapUv),A.push(R.transmissionMapUv),A.push(R.thicknessMapUv),A.push(R.combine),A.push(R.fogExp2),A.push(R.sizeAttenuation),A.push(R.morphTargetsCount),A.push(R.morphAttributeCount),A.push(R.numDirLights),A.push(R.numPointLights),A.push(R.numSpotLights),A.push(R.numSpotLightMaps),A.push(R.numHemiLights),A.push(R.numRectAreaLights),A.push(R.numDirLightShadows),A.push(R.numPointLightShadows),A.push(R.numSpotLightShadows),A.push(R.numSpotLightShadowsWithMaps),A.push(R.numLightProbes),A.push(R.shadowMapType),A.push(R.toneMapping),A.push(R.numClippingPlanes),A.push(R.numClipIntersection),A.push(R.depthPacking)}function N(A,R){l.disableAll(),R.isWebGL2&&l.enable(0),R.supportsVertexTextures&&l.enable(1),R.instancing&&l.enable(2),R.instancingColor&&l.enable(3),R.matcap&&l.enable(4),R.envMap&&l.enable(5),R.normalMapObjectSpace&&l.enable(6),R.normalMapTangentSpace&&l.enable(7),R.clearcoat&&l.enable(8),R.iridescence&&l.enable(9),R.alphaTest&&l.enable(10),R.vertexColors&&l.enable(11),R.vertexAlphas&&l.enable(12),R.vertexUv1s&&l.enable(13),R.vertexUv2s&&l.enable(14),R.vertexUv3s&&l.enable(15),R.vertexTangents&&l.enable(16),R.anisotropy&&l.enable(17),R.alphaHash&&l.enable(18),R.batching&&l.enable(19),A.push(l.mask),l.disableAll(),R.fog&&l.enable(0),R.useFog&&l.enable(1),R.flatShading&&l.enable(2),R.logarithmicDepthBuffer&&l.enable(3),R.skinning&&l.enable(4),R.morphTargets&&l.enable(5),R.morphNormals&&l.enable(6),R.morphColors&&l.enable(7),R.premultipliedAlpha&&l.enable(8),R.shadowMapEnabled&&l.enable(9),R.useLegacyLights&&l.enable(10),R.doubleSided&&l.enable(11),R.flipSided&&l.enable(12),R.useDepthPacking&&l.enable(13),R.dithering&&l.enable(14),R.transmission&&l.enable(15),R.sheen&&l.enable(16),R.opaque&&l.enable(17),R.pointsUvs&&l.enable(18),R.decodeVideoTexture&&l.enable(19),A.push(l.mask)}function T(A){const R=x[A.type];let U;if(R){const F=Rs[R];U=lL.clone(F.uniforms)}else U=A.uniforms;return U}function k(A,R){let U;for(let F=0,$=u.length;F<$;F++){const j=u[F];if(j.cacheKey===R){U=j,++U.usedTimes;break}}return U===void 0&&(U=new Gze(t,R,A,a),u.push(U)),U}function C(A){if(--A.usedTimes===0){const R=u.indexOf(A);u[R]=u[u.length-1],u.pop(),A.destroy()}}function E(A){c.remove(A)}function D(){c.dispose()}return{getParameters:y,getProgramCacheKey:v,getUniforms:T,acquireProgram:k,releaseProgram:C,releaseShaderCache:E,programs:u,dispose:D}}function Yze(){let t=new WeakMap;function e(a){let o=t.get(a);return o===void 0&&(o={},t.set(a,o)),o}function n(a){t.delete(a)}function r(a,o,l){t.get(a)[o]=l}function i(){t=new WeakMap}return{get:e,remove:n,update:r,dispose:i}}function Qze(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.material.id!==e.material.id?t.material.id-e.material.id:t.z!==e.z?t.z-e.z:t.id-e.id}function ZG(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?e.z-t.z:t.id-e.id}function JG(){const t=[];let e=0;const n=[],r=[],i=[];function a(){e=0,n.length=0,r.length=0,i.length=0}function o(f,p,m,x,b,y){let v=t[e];return v===void 0?(v={id:f.id,object:f,geometry:p,material:m,groupOrder:x,renderOrder:f.renderOrder,z:b,group:y},t[e]=v):(v.id=f.id,v.object=f,v.geometry=p,v.material=m,v.groupOrder=x,v.renderOrder=f.renderOrder,v.z=b,v.group=y),e++,v}function l(f,p,m,x,b,y){const v=o(f,p,m,x,b,y);m.transmission>0?r.push(v):m.transparent===!0?i.push(v):n.push(v)}function c(f,p,m,x,b,y){const v=o(f,p,m,x,b,y);m.transmission>0?r.unshift(v):m.transparent===!0?i.unshift(v):n.unshift(v)}function u(f,p){n.length>1&&n.sort(f||Qze),r.length>1&&r.sort(p||ZG),i.length>1&&i.sort(p||ZG)}function d(){for(let f=e,p=t.length;f<p;f++){const m=t[f];if(m.id===null)break;m.id=null,m.object=null,m.geometry=null,m.material=null,m.group=null}}return{opaque:n,transmissive:r,transparent:i,init:a,push:l,unshift:c,finish:d,sort:u}}function Zze(){let t=new WeakMap;function e(r,i){const a=t.get(r);let o;return a===void 0?(o=new JG,t.set(r,[o])):i>=a.length?(o=new JG,a.push(o)):o=a[i],o}function n(){t=new WeakMap}return{get:e,dispose:n}}function Jze(){const t={};return{get:function(e){if(t[e.id]!==void 0)return t[e.id];let n;switch(e.type){case"DirectionalLight":n={direction:new qe,color:new Zt};break;case"SpotLight":n={position:new qe,direction:new qe,color:new Zt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new qe,color:new Zt,distance:0,decay:0};break;case"HemisphereLight":n={direction:new qe,skyColor:new Zt,groundColor:new Zt};break;case"RectAreaLight":n={color:new Zt,position:new qe,halfWidth:new qe,halfHeight:new qe};break}return t[e.id]=n,n}}}function eBe(){const t={};return{get:function(e){if(t[e.id]!==void 0)return t[e.id];let n;switch(e.type){case"DirectionalLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new xn};break;case"SpotLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new xn};break;case"PointLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new xn,shadowCameraNear:1,shadowCameraFar:1e3};break}return t[e.id]=n,n}}}let tBe=0;function nBe(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function rBe(t,e){const n=new Jze,r=eBe(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let d=0;d<9;d++)i.probe.push(new qe);const a=new qe,o=new zr,l=new zr;function c(d,f){let p=0,m=0,x=0;for(let F=0;F<9;F++)i.probe[F].set(0,0,0);let b=0,y=0,v=0,S=0,N=0,T=0,k=0,C=0,E=0,D=0,A=0;d.sort(nBe);const R=f===!0?Math.PI:1;for(let F=0,$=d.length;F<$;F++){const j=d[F],H=j.color,K=j.intensity,V=j.distance,Q=j.shadow&&j.shadow.map?j.shadow.map.texture:null;if(j.isAmbientLight)p+=H.r*K*R,m+=H.g*K*R,x+=H.b*K*R;else if(j.isLightProbe){for(let Z=0;Z<9;Z++)i.probe[Z].addScaledVector(j.sh.coefficients[Z],K);A++}else if(j.isDirectionalLight){const Z=n.get(j);if(Z.color.copy(j.color).multiplyScalar(j.intensity*R),j.castShadow){const ae=j.shadow,B=r.get(j);B.shadowBias=ae.bias,B.shadowNormalBias=ae.normalBias,B.shadowRadius=ae.radius,B.shadowMapSize=ae.mapSize,i.directionalShadow[b]=B,i.directionalShadowMap[b]=Q,i.directionalShadowMatrix[b]=j.shadow.matrix,T++}i.directional[b]=Z,b++}else if(j.isSpotLight){const Z=n.get(j);Z.position.setFromMatrixPosition(j.matrixWorld),Z.color.copy(H).multiplyScalar(K*R),Z.distance=V,Z.coneCos=Math.cos(j.angle),Z.penumbraCos=Math.cos(j.angle*(1-j.penumbra)),Z.decay=j.decay,i.spot[v]=Z;const ae=j.shadow;if(j.map&&(i.spotLightMap[E]=j.map,E++,ae.updateMatrices(j),j.castShadow&&D++),i.spotLightMatrix[v]=ae.matrix,j.castShadow){const B=r.get(j);B.shadowBias=ae.bias,B.shadowNormalBias=ae.normalBias,B.shadowRadius=ae.radius,B.shadowMapSize=ae.mapSize,i.spotShadow[v]=B,i.spotShadowMap[v]=Q,C++}v++}else if(j.isRectAreaLight){const Z=n.get(j);Z.color.copy(H).multiplyScalar(K),Z.halfWidth.set(j.width*.5,0,0),Z.halfHeight.set(0,j.height*.5,0),i.rectArea[S]=Z,S++}else if(j.isPointLight){const Z=n.get(j);if(Z.color.copy(j.color).multiplyScalar(j.intensity*R),Z.distance=j.distance,Z.decay=j.decay,j.castShadow){const ae=j.shadow,B=r.get(j);B.shadowBias=ae.bias,B.shadowNormalBias=ae.normalBias,B.shadowRadius=ae.radius,B.shadowMapSize=ae.mapSize,B.shadowCameraNear=ae.camera.near,B.shadowCameraFar=ae.camera.far,i.pointShadow[y]=B,i.pointShadowMap[y]=Q,i.pointShadowMatrix[y]=j.shadow.matrix,k++}i.point[y]=Z,y++}else if(j.isHemisphereLight){const Z=n.get(j);Z.skyColor.copy(j.color).multiplyScalar(K*R),Z.groundColor.copy(j.groundColor).multiplyScalar(K*R),i.hemi[N]=Z,N++}}S>0&&(e.isWebGL2||t.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=Dt.LTC_FLOAT_1,i.rectAreaLTC2=Dt.LTC_FLOAT_2):t.has("OES_texture_half_float_linear")===!0?(i.rectAreaLTC1=Dt.LTC_HALF_1,i.rectAreaLTC2=Dt.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),i.ambient[0]=p,i.ambient[1]=m,i.ambient[2]=x;const U=i.hash;(U.directionalLength!==b||U.pointLength!==y||U.spotLength!==v||U.rectAreaLength!==S||U.hemiLength!==N||U.numDirectionalShadows!==T||U.numPointShadows!==k||U.numSpotShadows!==C||U.numSpotMaps!==E||U.numLightProbes!==A)&&(i.directional.length=b,i.spot.length=v,i.rectArea.length=S,i.point.length=y,i.hemi.length=N,i.directionalShadow.length=T,i.directionalShadowMap.length=T,i.pointShadow.length=k,i.pointShadowMap.length=k,i.spotShadow.length=C,i.spotShadowMap.length=C,i.directionalShadowMatrix.length=T,i.pointShadowMatrix.length=k,i.spotLightMatrix.length=C+E-D,i.spotLightMap.length=E,i.numSpotLightShadowsWithMaps=D,i.numLightProbes=A,U.directionalLength=b,U.pointLength=y,U.spotLength=v,U.rectAreaLength=S,U.hemiLength=N,U.numDirectionalShadows=T,U.numPointShadows=k,U.numSpotShadows=C,U.numSpotMaps=E,U.numLightProbes=A,i.version=tBe++)}function u(d,f){let p=0,m=0,x=0,b=0,y=0;const v=f.matrixWorldInverse;for(let S=0,N=d.length;S<N;S++){const T=d[S];if(T.isDirectionalLight){const k=i.directional[p];k.direction.setFromMatrixPosition(T.matrixWorld),a.setFromMatrixPosition(T.target.matrixWorld),k.direction.sub(a),k.direction.transformDirection(v),p++}else if(T.isSpotLight){const k=i.spot[x];k.position.setFromMatrixPosition(T.matrixWorld),k.position.applyMatrix4(v),k.direction.setFromMatrixPosition(T.matrixWorld),a.setFromMatrixPosition(T.target.matrixWorld),k.direction.sub(a),k.direction.transformDirection(v),x++}else if(T.isRectAreaLight){const k=i.rectArea[b];k.position.setFromMatrixPosition(T.matrixWorld),k.position.applyMatrix4(v),l.identity(),o.copy(T.matrixWorld),o.premultiply(v),l.extractRotation(o),k.halfWidth.set(T.width*.5,0,0),k.halfHeight.set(0,T.height*.5,0),k.halfWidth.applyMatrix4(l),k.halfHeight.applyMatrix4(l),b++}else if(T.isPointLight){const k=i.point[m];k.position.setFromMatrixPosition(T.matrixWorld),k.position.applyMatrix4(v),m++}else if(T.isHemisphereLight){const k=i.hemi[y];k.direction.setFromMatrixPosition(T.matrixWorld),k.direction.transformDirection(v),y++}}}return{setup:c,setupView:u,state:i}}function e7(t,e){const n=new rBe(t,e),r=[],i=[];function a(){r.length=0,i.length=0}function o(f){r.push(f)}function l(f){i.push(f)}function c(f){n.setup(r,f)}function u(f){n.setupView(r,f)}return{init:a,state:{lightsArray:r,shadowsArray:i,lights:n},setupLights:c,setupLightsView:u,pushLight:o,pushShadow:l}}function iBe(t,e){let n=new WeakMap;function r(a,o=0){const l=n.get(a);let c;return l===void 0?(c=new e7(t,e),n.set(a,[c])):o>=l.length?(c=new e7(t,e),l.push(c)):c=l[o],c}function i(){n=new WeakMap}return{get:r,dispose:i}}class aBe extends Dx{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=VLe,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 sBe extends Dx{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}const oBe=`void main() {
- gl_Position = vec4( position, 1.0 );
- }`,lBe=`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 cBe(t,e,n){let r=new v2;const i=new xn,a=new xn,o=new Cr,l=new aBe({depthPacking:GLe}),c=new sBe,u={},d=n.maxTextureSize,f={[Th]:zs,[zs]:Th,[pu]:pu},p=new Ah({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new xn},radius:{value:4}},vertexShader:oBe,fragmentShader:lBe}),m=p.clone();m.defines.HORIZONTAL_PASS=1;const x=new ns;x.setAttribute("position",new go(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const b=new Dl(x,p),y=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=RJ;let v=this.type;this.render=function(k,C,E){if(y.enabled===!1||y.autoUpdate===!1&&y.needsUpdate===!1||k.length===0)return;const D=t.getRenderTarget(),A=t.getActiveCubeFace(),R=t.getActiveMipmapLevel(),U=t.state;U.setBlending(ch),U.buffers.color.setClear(1,1,1,1),U.buffers.depth.setTest(!0),U.setScissorTest(!1);const F=v!==lu&&this.type===lu,$=v===lu&&this.type!==lu;for(let j=0,H=k.length;j<H;j++){const K=k[j],V=K.shadow;if(V===void 0){console.warn("THREE.WebGLShadowMap:",K,"has no shadow.");continue}if(V.autoUpdate===!1&&V.needsUpdate===!1)continue;i.copy(V.mapSize);const Q=V.getFrameExtents();if(i.multiply(Q),a.copy(V.mapSize),(i.x>d||i.y>d)&&(i.x>d&&(a.x=Math.floor(d/Q.x),i.x=a.x*Q.x,V.mapSize.x=a.x),i.y>d&&(a.y=Math.floor(d/Q.y),i.y=a.y*Q.y,V.mapSize.y=a.y)),V.map===null||F===!0||$===!0){const ae=this.type!==lu?{minFilter:Da,magFilter:Da}:{};V.map!==null&&V.map.dispose(),V.map=new ym(i.x,i.y,ae),V.map.texture.name=K.name+".shadowMap",V.camera.updateProjectionMatrix()}t.setRenderTarget(V.map),t.clear();const Z=V.getViewportCount();for(let ae=0;ae<Z;ae++){const B=V.getViewport(ae);o.set(a.x*B.x,a.y*B.y,a.x*B.z,a.y*B.w),U.viewport(o),V.updateMatrices(K,ae),r=V.getFrustum(),T(C,E,V.camera,K,this.type)}V.isPointLightShadow!==!0&&this.type===lu&&S(V,E),V.needsUpdate=!1}v=this.type,y.needsUpdate=!1,t.setRenderTarget(D,A,R)};function S(k,C){const E=e.update(b);p.defines.VSM_SAMPLES!==k.blurSamples&&(p.defines.VSM_SAMPLES=k.blurSamples,m.defines.VSM_SAMPLES=k.blurSamples,p.needsUpdate=!0,m.needsUpdate=!0),k.mapPass===null&&(k.mapPass=new ym(i.x,i.y)),p.uniforms.shadow_pass.value=k.map.texture,p.uniforms.resolution.value=k.mapSize,p.uniforms.radius.value=k.radius,t.setRenderTarget(k.mapPass),t.clear(),t.renderBufferDirect(C,null,E,p,b,null),m.uniforms.shadow_pass.value=k.mapPass.texture,m.uniforms.resolution.value=k.mapSize,m.uniforms.radius.value=k.radius,t.setRenderTarget(k.map),t.clear(),t.renderBufferDirect(C,null,E,m,b,null)}function N(k,C,E,D){let A=null;const R=E.isPointLight===!0?k.customDistanceMaterial:k.customDepthMaterial;if(R!==void 0)A=R;else if(A=E.isPointLight===!0?c:l,t.localClippingEnabled&&C.clipShadows===!0&&Array.isArray(C.clippingPlanes)&&C.clippingPlanes.length!==0||C.displacementMap&&C.displacementScale!==0||C.alphaMap&&C.alphaTest>0||C.map&&C.alphaTest>0){const U=A.uuid,F=C.uuid;let $=u[U];$===void 0&&($={},u[U]=$);let j=$[F];j===void 0&&(j=A.clone(),$[F]=j),A=j}if(A.visible=C.visible,A.wireframe=C.wireframe,D===lu?A.side=C.shadowSide!==null?C.shadowSide:C.side:A.side=C.shadowSide!==null?C.shadowSide:f[C.side],A.alphaMap=C.alphaMap,A.alphaTest=C.alphaTest,A.map=C.map,A.clipShadows=C.clipShadows,A.clippingPlanes=C.clippingPlanes,A.clipIntersection=C.clipIntersection,A.displacementMap=C.displacementMap,A.displacementScale=C.displacementScale,A.displacementBias=C.displacementBias,A.wireframeLinewidth=C.wireframeLinewidth,A.linewidth=C.linewidth,E.isPointLight===!0&&A.isMeshDistanceMaterial===!0){const U=t.properties.get(A);U.light=E}return A}function T(k,C,E,D,A){if(k.visible===!1)return;if(k.layers.test(C.layers)&&(k.isMesh||k.isLine||k.isPoints)&&(k.castShadow||k.receiveShadow&&A===lu)&&(!k.frustumCulled||r.intersectsObject(k))){k.modelViewMatrix.multiplyMatrices(E.matrixWorldInverse,k.matrixWorld);const F=e.update(k),$=k.material;if(Array.isArray($)){const j=F.groups;for(let H=0,K=j.length;H<K;H++){const V=j[H],Q=$[V.materialIndex];if(Q&&Q.visible){const Z=N(k,Q,D,A);k.onBeforeShadow(t,k,C,E,F,Z,V),t.renderBufferDirect(E,null,F,Z,k,V),k.onAfterShadow(t,k,C,E,F,Z,V)}}}else if($.visible){const j=N(k,$,D,A);k.onBeforeShadow(t,k,C,E,F,j,null),t.renderBufferDirect(E,null,F,j,k,null),k.onAfterShadow(t,k,C,E,F,j,null)}}const U=k.children;for(let F=0,$=U.length;F<$;F++)T(U[F],C,E,D,A)}}function uBe(t,e,n){const r=n.isWebGL2;function i(){let ke=!1;const We=new Cr;let ze=null;const W=new Cr(0,0,0,0);return{setMask:function(De){ze!==De&&!ke&&(t.colorMask(De,De,De,De),ze=De)},setLocked:function(De){ke=De},setClear:function(De,Ye,xt,ft,Bt){Bt===!0&&(De*=ft,Ye*=ft,xt*=ft),We.set(De,Ye,xt,ft),W.equals(We)===!1&&(t.clearColor(De,Ye,xt,ft),W.copy(We))},reset:function(){ke=!1,ze=null,W.set(-1,0,0,0)}}}function a(){let ke=!1,We=null,ze=null,W=null;return{setTest:function(De){De?ie(t.DEPTH_TEST):Ne(t.DEPTH_TEST)},setMask:function(De){We!==De&&!ke&&(t.depthMask(De),We=De)},setFunc:function(De){if(ze!==De){switch(De){case wLe:t.depthFunc(t.NEVER);break;case _Le:t.depthFunc(t.ALWAYS);break;case SLe:t.depthFunc(t.LESS);break;case ZS:t.depthFunc(t.LEQUAL);break;case MLe:t.depthFunc(t.EQUAL);break;case NLe:t.depthFunc(t.GEQUAL);break;case kLe:t.depthFunc(t.GREATER);break;case ELe:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}ze=De}},setLocked:function(De){ke=De},setClear:function(De){W!==De&&(t.clearDepth(De),W=De)},reset:function(){ke=!1,We=null,ze=null,W=null}}}function o(){let ke=!1,We=null,ze=null,W=null,De=null,Ye=null,xt=null,ft=null,Bt=null;return{setTest:function(Lt){ke||(Lt?ie(t.STENCIL_TEST):Ne(t.STENCIL_TEST))},setMask:function(Lt){We!==Lt&&!ke&&(t.stencilMask(Lt),We=Lt)},setFunc:function(Lt,vn,Jt){(ze!==Lt||W!==vn||De!==Jt)&&(t.stencilFunc(Lt,vn,Jt),ze=Lt,W=vn,De=Jt)},setOp:function(Lt,vn,Jt){(Ye!==Lt||xt!==vn||ft!==Jt)&&(t.stencilOp(Lt,vn,Jt),Ye=Lt,xt=vn,ft=Jt)},setLocked:function(Lt){ke=Lt},setClear:function(Lt){Bt!==Lt&&(t.clearStencil(Lt),Bt=Lt)},reset:function(){ke=!1,We=null,ze=null,W=null,De=null,Ye=null,xt=null,ft=null,Bt=null}}}const l=new i,c=new a,u=new o,d=new WeakMap,f=new WeakMap;let p={},m={},x=new WeakMap,b=[],y=null,v=!1,S=null,N=null,T=null,k=null,C=null,E=null,D=null,A=new Zt(0,0,0),R=0,U=!1,F=null,$=null,j=null,H=null,K=null;const V=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let Q=!1,Z=0;const ae=t.getParameter(t.VERSION);ae.indexOf("WebGL")!==-1?(Z=parseFloat(/^WebGL (\d)/.exec(ae)[1]),Q=Z>=1):ae.indexOf("OpenGL ES")!==-1&&(Z=parseFloat(/^OpenGL ES (\d)/.exec(ae)[1]),Q=Z>=2);let B=null,X={};const ne=t.getParameter(t.SCISSOR_BOX),se=t.getParameter(t.VIEWPORT),be=new Cr().fromArray(ne),xe=new Cr().fromArray(se);function de(ke,We,ze,W){const De=new Uint8Array(4),Ye=t.createTexture();t.bindTexture(ke,Ye),t.texParameteri(ke,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(ke,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let xt=0;xt<ze;xt++)r&&(ke===t.TEXTURE_3D||ke===t.TEXTURE_2D_ARRAY)?t.texImage3D(We,0,t.RGBA,1,1,W,0,t.RGBA,t.UNSIGNED_BYTE,De):t.texImage2D(We+xt,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,De);return Ye}const Pe={};Pe[t.TEXTURE_2D]=de(t.TEXTURE_2D,t.TEXTURE_2D,1),Pe[t.TEXTURE_CUBE_MAP]=de(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),r&&(Pe[t.TEXTURE_2D_ARRAY]=de(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),Pe[t.TEXTURE_3D]=de(t.TEXTURE_3D,t.TEXTURE_3D,1,1)),l.setClear(0,0,0,1),c.setClear(1),u.setClear(0),ie(t.DEPTH_TEST),c.setFunc(ZS),te(!1),I(LV),ie(t.CULL_FACE),ce(ch);function ie(ke){p[ke]!==!0&&(t.enable(ke),p[ke]=!0)}function Ne(ke){p[ke]!==!1&&(t.disable(ke),p[ke]=!1)}function Oe(ke,We){return m[ke]!==We?(t.bindFramebuffer(ke,We),m[ke]=We,r&&(ke===t.DRAW_FRAMEBUFFER&&(m[t.FRAMEBUFFER]=We),ke===t.FRAMEBUFFER&&(m[t.DRAW_FRAMEBUFFER]=We)),!0):!1}function ge(ke,We){let ze=b,W=!1;if(ke)if(ze=x.get(We),ze===void 0&&(ze=[],x.set(We,ze)),ke.isWebGLMultipleRenderTargets){const De=ke.texture;if(ze.length!==De.length||ze[0]!==t.COLOR_ATTACHMENT0){for(let Ye=0,xt=De.length;Ye<xt;Ye++)ze[Ye]=t.COLOR_ATTACHMENT0+Ye;ze.length=De.length,W=!0}}else ze[0]!==t.COLOR_ATTACHMENT0&&(ze[0]=t.COLOR_ATTACHMENT0,W=!0);else ze[0]!==t.BACK&&(ze[0]=t.BACK,W=!0);W&&(n.isWebGL2?t.drawBuffers(ze):e.get("WEBGL_draw_buffers").drawBuffersWEBGL(ze))}function Ke(ke){return y!==ke?(t.useProgram(ke),y=ke,!0):!1}const G={[kf]:t.FUNC_ADD,[sLe]:t.FUNC_SUBTRACT,[oLe]:t.FUNC_REVERSE_SUBTRACT};if(r)G[zV]=t.MIN,G[BV]=t.MAX;else{const ke=e.get("EXT_blend_minmax");ke!==null&&(G[zV]=ke.MIN_EXT,G[BV]=ke.MAX_EXT)}const Y={[lLe]:t.ZERO,[cLe]:t.ONE,[uLe]:t.SRC_COLOR,[fD]:t.SRC_ALPHA,[gLe]:t.SRC_ALPHA_SATURATE,[mLe]:t.DST_COLOR,[hLe]:t.DST_ALPHA,[dLe]:t.ONE_MINUS_SRC_COLOR,[mD]:t.ONE_MINUS_SRC_ALPHA,[pLe]:t.ONE_MINUS_DST_COLOR,[fLe]:t.ONE_MINUS_DST_ALPHA,[xLe]:t.CONSTANT_COLOR,[bLe]:t.ONE_MINUS_CONSTANT_COLOR,[yLe]:t.CONSTANT_ALPHA,[vLe]:t.ONE_MINUS_CONSTANT_ALPHA};function ce(ke,We,ze,W,De,Ye,xt,ft,Bt,Lt){if(ke===ch){v===!0&&(Ne(t.BLEND),v=!1);return}if(v===!1&&(ie(t.BLEND),v=!0),ke!==aLe){if(ke!==S||Lt!==U){if((N!==kf||C!==kf)&&(t.blendEquation(t.FUNC_ADD),N=kf,C=kf),Lt)switch(ke){case jg:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case FV:t.blendFunc(t.ONE,t.ONE);break;case IV:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case UV:t.blendFuncSeparate(t.ZERO,t.SRC_COLOR,t.ZERO,t.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",ke);break}else switch(ke){case jg:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case FV:t.blendFunc(t.SRC_ALPHA,t.ONE);break;case IV:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case UV:t.blendFunc(t.ZERO,t.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",ke);break}T=null,k=null,E=null,D=null,A.set(0,0,0),R=0,S=ke,U=Lt}return}De=De||We,Ye=Ye||ze,xt=xt||W,(We!==N||De!==C)&&(t.blendEquationSeparate(G[We],G[De]),N=We,C=De),(ze!==T||W!==k||Ye!==E||xt!==D)&&(t.blendFuncSeparate(Y[ze],Y[W],Y[Ye],Y[xt]),T=ze,k=W,E=Ye,D=xt),(ft.equals(A)===!1||Bt!==R)&&(t.blendColor(ft.r,ft.g,ft.b,Bt),A.copy(ft),R=Bt),S=ke,U=!1}function q(ke,We){ke.side===pu?Ne(t.CULL_FACE):ie(t.CULL_FACE);let ze=ke.side===zs;We&&(ze=!ze),te(ze),ke.blending===jg&&ke.transparent===!1?ce(ch):ce(ke.blending,ke.blendEquation,ke.blendSrc,ke.blendDst,ke.blendEquationAlpha,ke.blendSrcAlpha,ke.blendDstAlpha,ke.blendColor,ke.blendAlpha,ke.premultipliedAlpha),c.setFunc(ke.depthFunc),c.setTest(ke.depthTest),c.setMask(ke.depthWrite),l.setMask(ke.colorWrite);const W=ke.stencilWrite;u.setTest(W),W&&(u.setMask(ke.stencilWriteMask),u.setFunc(ke.stencilFunc,ke.stencilRef,ke.stencilFuncMask),u.setOp(ke.stencilFail,ke.stencilZFail,ke.stencilZPass)),me(ke.polygonOffset,ke.polygonOffsetFactor,ke.polygonOffsetUnits),ke.alphaToCoverage===!0?ie(t.SAMPLE_ALPHA_TO_COVERAGE):Ne(t.SAMPLE_ALPHA_TO_COVERAGE)}function te(ke){F!==ke&&(ke?t.frontFace(t.CW):t.frontFace(t.CCW),F=ke)}function I(ke){ke!==nLe?(ie(t.CULL_FACE),ke!==$&&(ke===LV?t.cullFace(t.BACK):ke===rLe?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):Ne(t.CULL_FACE),$=ke}function fe(ke){ke!==j&&(Q&&t.lineWidth(ke),j=ke)}function me(ke,We,ze){ke?(ie(t.POLYGON_OFFSET_FILL),(H!==We||K!==ze)&&(t.polygonOffset(We,ze),H=We,K=ze)):Ne(t.POLYGON_OFFSET_FILL)}function Ee(ke){ke?ie(t.SCISSOR_TEST):Ne(t.SCISSOR_TEST)}function z(ke){ke===void 0&&(ke=t.TEXTURE0+V-1),B!==ke&&(t.activeTexture(ke),B=ke)}function O(ke,We,ze){ze===void 0&&(B===null?ze=t.TEXTURE0+V-1:ze=B);let W=X[ze];W===void 0&&(W={type:void 0,texture:void 0},X[ze]=W),(W.type!==ke||W.texture!==We)&&(B!==ze&&(t.activeTexture(ze),B=ze),t.bindTexture(ke,We||Pe[ke]),W.type=ke,W.texture=We)}function ee(){const ke=X[B];ke!==void 0&&ke.type!==void 0&&(t.bindTexture(ke.type,null),ke.type=void 0,ke.texture=void 0)}function le(){try{t.compressedTexImage2D.apply(t,arguments)}catch(ke){console.error("THREE.WebGLState:",ke)}}function _e(){try{t.compressedTexImage3D.apply(t,arguments)}catch(ke){console.error("THREE.WebGLState:",ke)}}function we(){try{t.texSubImage2D.apply(t,arguments)}catch(ke){console.error("THREE.WebGLState:",ke)}}function re(){try{t.texSubImage3D.apply(t,arguments)}catch(ke){console.error("THREE.WebGLState:",ke)}}function Fe(){try{t.compressedTexSubImage2D.apply(t,arguments)}catch(ke){console.error("THREE.WebGLState:",ke)}}function He(){try{t.compressedTexSubImage3D.apply(t,arguments)}catch(ke){console.error("THREE.WebGLState:",ke)}}function Ve(){try{t.texStorage2D.apply(t,arguments)}catch(ke){console.error("THREE.WebGLState:",ke)}}function $e(){try{t.texStorage3D.apply(t,arguments)}catch(ke){console.error("THREE.WebGLState:",ke)}}function ye(){try{t.texImage2D.apply(t,arguments)}catch(ke){console.error("THREE.WebGLState:",ke)}}function je(){try{t.texImage3D.apply(t,arguments)}catch(ke){console.error("THREE.WebGLState:",ke)}}function Be(ke){be.equals(ke)===!1&&(t.scissor(ke.x,ke.y,ke.z,ke.w),be.copy(ke))}function Se(ke){xe.equals(ke)===!1&&(t.viewport(ke.x,ke.y,ke.z,ke.w),xe.copy(ke))}function Xe(ke,We){let ze=f.get(We);ze===void 0&&(ze=new WeakMap,f.set(We,ze));let W=ze.get(ke);W===void 0&&(W=t.getUniformBlockIndex(We,ke.name),ze.set(ke,W))}function Me(ke,We){const W=f.get(We).get(ke);d.get(We)!==W&&(t.uniformBlockBinding(We,W,ke.__bindingPointIndex),d.set(We,W))}function tt(){t.disable(t.BLEND),t.disable(t.CULL_FACE),t.disable(t.DEPTH_TEST),t.disable(t.POLYGON_OFFSET_FILL),t.disable(t.SCISSOR_TEST),t.disable(t.STENCIL_TEST),t.disable(t.SAMPLE_ALPHA_TO_COVERAGE),t.blendEquation(t.FUNC_ADD),t.blendFunc(t.ONE,t.ZERO),t.blendFuncSeparate(t.ONE,t.ZERO,t.ONE,t.ZERO),t.blendColor(0,0,0,0),t.colorMask(!0,!0,!0,!0),t.clearColor(0,0,0,0),t.depthMask(!0),t.depthFunc(t.LESS),t.clearDepth(1),t.stencilMask(4294967295),t.stencilFunc(t.ALWAYS,0,4294967295),t.stencilOp(t.KEEP,t.KEEP,t.KEEP),t.clearStencil(0),t.cullFace(t.BACK),t.frontFace(t.CCW),t.polygonOffset(0,0),t.activeTexture(t.TEXTURE0),t.bindFramebuffer(t.FRAMEBUFFER,null),r===!0&&(t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),t.bindFramebuffer(t.READ_FRAMEBUFFER,null)),t.useProgram(null),t.lineWidth(1),t.scissor(0,0,t.canvas.width,t.canvas.height),t.viewport(0,0,t.canvas.width,t.canvas.height),p={},B=null,X={},m={},x=new WeakMap,b=[],y=null,v=!1,S=null,N=null,T=null,k=null,C=null,E=null,D=null,A=new Zt(0,0,0),R=0,U=!1,F=null,$=null,j=null,H=null,K=null,be.set(0,0,t.canvas.width,t.canvas.height),xe.set(0,0,t.canvas.width,t.canvas.height),l.reset(),c.reset(),u.reset()}return{buffers:{color:l,depth:c,stencil:u},enable:ie,disable:Ne,bindFramebuffer:Oe,drawBuffers:ge,useProgram:Ke,setBlending:ce,setMaterial:q,setFlipSided:te,setCullFace:I,setLineWidth:fe,setPolygonOffset:me,setScissorTest:Ee,activeTexture:z,bindTexture:O,unbindTexture:ee,compressedTexImage2D:le,compressedTexImage3D:_e,texImage2D:ye,texImage3D:je,updateUBOMapping:Xe,uniformBlockBinding:Me,texStorage2D:Ve,texStorage3D:$e,texSubImage2D:we,texSubImage3D:re,compressedTexSubImage2D:Fe,compressedTexSubImage3D:He,scissor:Be,viewport:Se,reset:tt}}function dBe(t,e,n,r,i,a,o){const l=i.isWebGL2,c=i.maxTextures,u=i.maxCubemapSize,d=i.maxTextureSize,f=i.maxSamples,p=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,m=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),x=new WeakMap;let b;const y=new WeakMap;let v=!1;try{v=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function S(z,O){return v?new OffscreenCanvas(z,O):rM("canvas")}function N(z,O,ee,le){let _e=1;if((z.width>le||z.height>le)&&(_e=le/Math.max(z.width,z.height)),_e<1||O===!0)if(typeof HTMLImageElement<"u"&&z instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&z instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&z instanceof ImageBitmap){const we=O?nM:Math.floor,re=we(_e*z.width),Fe=we(_e*z.height);b===void 0&&(b=S(re,Fe));const He=ee?S(re,Fe):b;return He.width=re,He.height=Fe,He.getContext("2d").drawImage(z,0,0,re,Fe),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+z.width+"x"+z.height+") to ("+re+"x"+Fe+")."),He}else return"data"in z&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+z.width+"x"+z.height+")."),z;return z}function T(z){return wD(z.width)&&wD(z.height)}function k(z){return l?!1:z.wrapS!==Cl||z.wrapT!==Cl||z.minFilter!==Da&&z.minFilter!==Ko}function C(z,O){return z.generateMipmaps&&O&&z.minFilter!==Da&&z.minFilter!==Ko}function E(z){t.generateMipmap(z)}function D(z,O,ee,le,_e=!1){if(l===!1)return O;if(z!==null){if(t[z]!==void 0)return t[z];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+z+"'")}let we=O;if(O===t.RED&&(ee===t.FLOAT&&(we=t.R32F),ee===t.HALF_FLOAT&&(we=t.R16F),ee===t.UNSIGNED_BYTE&&(we=t.R8)),O===t.RED_INTEGER&&(ee===t.UNSIGNED_BYTE&&(we=t.R8UI),ee===t.UNSIGNED_SHORT&&(we=t.R16UI),ee===t.UNSIGNED_INT&&(we=t.R32UI),ee===t.BYTE&&(we=t.R8I),ee===t.SHORT&&(we=t.R16I),ee===t.INT&&(we=t.R32I)),O===t.RG&&(ee===t.FLOAT&&(we=t.RG32F),ee===t.HALF_FLOAT&&(we=t.RG16F),ee===t.UNSIGNED_BYTE&&(we=t.RG8)),O===t.RGBA){const re=_e?JS:Er.getTransfer(le);ee===t.FLOAT&&(we=t.RGBA32F),ee===t.HALF_FLOAT&&(we=t.RGBA16F),ee===t.UNSIGNED_BYTE&&(we=re===Gr?t.SRGB8_ALPHA8:t.RGBA8),ee===t.UNSIGNED_SHORT_4_4_4_4&&(we=t.RGBA4),ee===t.UNSIGNED_SHORT_5_5_5_1&&(we=t.RGB5_A1)}return(we===t.R16F||we===t.R32F||we===t.RG16F||we===t.RG32F||we===t.RGBA16F||we===t.RGBA32F)&&e.get("EXT_color_buffer_float"),we}function A(z,O,ee){return C(z,ee)===!0||z.isFramebufferTexture&&z.minFilter!==Da&&z.minFilter!==Ko?Math.log2(Math.max(O.width,O.height))+1:z.mipmaps!==void 0&&z.mipmaps.length>0?z.mipmaps.length:z.isCompressedTexture&&Array.isArray(z.image)?O.mipmaps.length:1}function R(z){return z===Da||z===HV||z===MC?t.NEAREST:t.LINEAR}function U(z){const O=z.target;O.removeEventListener("dispose",U),$(O),O.isVideoTexture&&x.delete(O)}function F(z){const O=z.target;O.removeEventListener("dispose",F),H(O)}function $(z){const O=r.get(z);if(O.__webglInit===void 0)return;const ee=z.source,le=y.get(ee);if(le){const _e=le[O.__cacheKey];_e.usedTimes--,_e.usedTimes===0&&j(z),Object.keys(le).length===0&&y.delete(ee)}r.remove(z)}function j(z){const O=r.get(z);t.deleteTexture(O.__webglTexture);const ee=z.source,le=y.get(ee);delete le[O.__cacheKey],o.memory.textures--}function H(z){const O=z.texture,ee=r.get(z),le=r.get(O);if(le.__webglTexture!==void 0&&(t.deleteTexture(le.__webglTexture),o.memory.textures--),z.depthTexture&&z.depthTexture.dispose(),z.isWebGLCubeRenderTarget)for(let _e=0;_e<6;_e++){if(Array.isArray(ee.__webglFramebuffer[_e]))for(let we=0;we<ee.__webglFramebuffer[_e].length;we++)t.deleteFramebuffer(ee.__webglFramebuffer[_e][we]);else t.deleteFramebuffer(ee.__webglFramebuffer[_e]);ee.__webglDepthbuffer&&t.deleteRenderbuffer(ee.__webglDepthbuffer[_e])}else{if(Array.isArray(ee.__webglFramebuffer))for(let _e=0;_e<ee.__webglFramebuffer.length;_e++)t.deleteFramebuffer(ee.__webglFramebuffer[_e]);else t.deleteFramebuffer(ee.__webglFramebuffer);if(ee.__webglDepthbuffer&&t.deleteRenderbuffer(ee.__webglDepthbuffer),ee.__webglMultisampledFramebuffer&&t.deleteFramebuffer(ee.__webglMultisampledFramebuffer),ee.__webglColorRenderbuffer)for(let _e=0;_e<ee.__webglColorRenderbuffer.length;_e++)ee.__webglColorRenderbuffer[_e]&&t.deleteRenderbuffer(ee.__webglColorRenderbuffer[_e]);ee.__webglDepthRenderbuffer&&t.deleteRenderbuffer(ee.__webglDepthRenderbuffer)}if(z.isWebGLMultipleRenderTargets)for(let _e=0,we=O.length;_e<we;_e++){const re=r.get(O[_e]);re.__webglTexture&&(t.deleteTexture(re.__webglTexture),o.memory.textures--),r.remove(O[_e])}r.remove(O),r.remove(z)}let K=0;function V(){K=0}function Q(){const z=K;return z>=c&&console.warn("THREE.WebGLTextures: Trying to use "+z+" texture units while this GPU supports only "+c),K+=1,z}function Z(z){const O=[];return O.push(z.wrapS),O.push(z.wrapT),O.push(z.wrapR||0),O.push(z.magFilter),O.push(z.minFilter),O.push(z.anisotropy),O.push(z.internalFormat),O.push(z.format),O.push(z.type),O.push(z.generateMipmaps),O.push(z.premultiplyAlpha),O.push(z.flipY),O.push(z.unpackAlignment),O.push(z.colorSpace),O.join()}function ae(z,O){const ee=r.get(z);if(z.isVideoTexture&&me(z),z.isRenderTargetTexture===!1&&z.version>0&&ee.__version!==z.version){const le=z.image;if(le===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(le.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{ie(ee,z,O);return}}n.bindTexture(t.TEXTURE_2D,ee.__webglTexture,t.TEXTURE0+O)}function B(z,O){const ee=r.get(z);if(z.version>0&&ee.__version!==z.version){ie(ee,z,O);return}n.bindTexture(t.TEXTURE_2D_ARRAY,ee.__webglTexture,t.TEXTURE0+O)}function X(z,O){const ee=r.get(z);if(z.version>0&&ee.__version!==z.version){ie(ee,z,O);return}n.bindTexture(t.TEXTURE_3D,ee.__webglTexture,t.TEXTURE0+O)}function ne(z,O){const ee=r.get(z);if(z.version>0&&ee.__version!==z.version){Ne(ee,z,O);return}n.bindTexture(t.TEXTURE_CUBE_MAP,ee.__webglTexture,t.TEXTURE0+O)}const se={[xD]:t.REPEAT,[Cl]:t.CLAMP_TO_EDGE,[bD]:t.MIRRORED_REPEAT},be={[Da]:t.NEAREST,[HV]:t.NEAREST_MIPMAP_NEAREST,[MC]:t.NEAREST_MIPMAP_LINEAR,[Ko]:t.LINEAR,[OLe]:t.LINEAR_MIPMAP_NEAREST,[gy]:t.LINEAR_MIPMAP_LINEAR},xe={[WLe]:t.NEVER,[JLe]:t.ALWAYS,[KLe]:t.LESS,[GJ]:t.LEQUAL,[XLe]:t.EQUAL,[ZLe]:t.GEQUAL,[YLe]:t.GREATER,[QLe]:t.NOTEQUAL};function de(z,O,ee){if(ee?(t.texParameteri(z,t.TEXTURE_WRAP_S,se[O.wrapS]),t.texParameteri(z,t.TEXTURE_WRAP_T,se[O.wrapT]),(z===t.TEXTURE_3D||z===t.TEXTURE_2D_ARRAY)&&t.texParameteri(z,t.TEXTURE_WRAP_R,se[O.wrapR]),t.texParameteri(z,t.TEXTURE_MAG_FILTER,be[O.magFilter]),t.texParameteri(z,t.TEXTURE_MIN_FILTER,be[O.minFilter])):(t.texParameteri(z,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(z,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),(z===t.TEXTURE_3D||z===t.TEXTURE_2D_ARRAY)&&t.texParameteri(z,t.TEXTURE_WRAP_R,t.CLAMP_TO_EDGE),(O.wrapS!==Cl||O.wrapT!==Cl)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),t.texParameteri(z,t.TEXTURE_MAG_FILTER,R(O.magFilter)),t.texParameteri(z,t.TEXTURE_MIN_FILTER,R(O.minFilter)),O.minFilter!==Da&&O.minFilter!==Ko&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),O.compareFunction&&(t.texParameteri(z,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(z,t.TEXTURE_COMPARE_FUNC,xe[O.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){const le=e.get("EXT_texture_filter_anisotropic");if(O.magFilter===Da||O.minFilter!==MC&&O.minFilter!==gy||O.type===_u&&e.has("OES_texture_float_linear")===!1||l===!1&&O.type===xy&&e.has("OES_texture_half_float_linear")===!1)return;(O.anisotropy>1||r.get(O).__currentAnisotropy)&&(t.texParameterf(z,le.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(O.anisotropy,i.getMaxAnisotropy())),r.get(O).__currentAnisotropy=O.anisotropy)}}function Pe(z,O){let ee=!1;z.__webglInit===void 0&&(z.__webglInit=!0,O.addEventListener("dispose",U));const le=O.source;let _e=y.get(le);_e===void 0&&(_e={},y.set(le,_e));const we=Z(O);if(we!==z.__cacheKey){_e[we]===void 0&&(_e[we]={texture:t.createTexture(),usedTimes:0},o.memory.textures++,ee=!0),_e[we].usedTimes++;const re=_e[z.__cacheKey];re!==void 0&&(_e[z.__cacheKey].usedTimes--,re.usedTimes===0&&j(O)),z.__cacheKey=we,z.__webglTexture=_e[we].texture}return ee}function ie(z,O,ee){let le=t.TEXTURE_2D;(O.isDataArrayTexture||O.isCompressedArrayTexture)&&(le=t.TEXTURE_2D_ARRAY),O.isData3DTexture&&(le=t.TEXTURE_3D);const _e=Pe(z,O),we=O.source;n.bindTexture(le,z.__webglTexture,t.TEXTURE0+ee);const re=r.get(we);if(we.version!==re.__version||_e===!0){n.activeTexture(t.TEXTURE0+ee);const Fe=Er.getPrimaries(Er.workingColorSpace),He=O.colorSpace===Yo?null:Er.getPrimaries(O.colorSpace),Ve=O.colorSpace===Yo||Fe===He?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,O.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,O.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,O.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ve);const $e=k(O)&&T(O.image)===!1;let ye=N(O.image,$e,!1,d);ye=Ee(O,ye);const je=T(ye)||l,Be=a.convert(O.format,O.colorSpace);let Se=a.convert(O.type),Xe=D(O.internalFormat,Be,Se,O.colorSpace,O.isVideoTexture);de(le,O,je);let Me;const tt=O.mipmaps,ke=l&&O.isVideoTexture!==!0&&Xe!==HJ,We=re.__version===void 0||_e===!0,ze=A(O,ye,je);if(O.isDepthTexture)Xe=t.DEPTH_COMPONENT,l?O.type===_u?Xe=t.DEPTH_COMPONENT32F:O.type===Zd?Xe=t.DEPTH_COMPONENT24:O.type===qf?Xe=t.DEPTH24_STENCIL8:Xe=t.DEPTH_COMPONENT16:O.type===_u&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),O.format===Wf&&Xe===t.DEPTH_COMPONENT&&O.type!==iL&&O.type!==Zd&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),O.type=Zd,Se=a.convert(O.type)),O.format===ix&&Xe===t.DEPTH_COMPONENT&&(Xe=t.DEPTH_STENCIL,O.type!==qf&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),O.type=qf,Se=a.convert(O.type))),We&&(ke?n.texStorage2D(t.TEXTURE_2D,1,Xe,ye.width,ye.height):n.texImage2D(t.TEXTURE_2D,0,Xe,ye.width,ye.height,0,Be,Se,null));else if(O.isDataTexture)if(tt.length>0&&je){ke&&We&&n.texStorage2D(t.TEXTURE_2D,ze,Xe,tt[0].width,tt[0].height);for(let W=0,De=tt.length;W<De;W++)Me=tt[W],ke?n.texSubImage2D(t.TEXTURE_2D,W,0,0,Me.width,Me.height,Be,Se,Me.data):n.texImage2D(t.TEXTURE_2D,W,Xe,Me.width,Me.height,0,Be,Se,Me.data);O.generateMipmaps=!1}else ke?(We&&n.texStorage2D(t.TEXTURE_2D,ze,Xe,ye.width,ye.height),n.texSubImage2D(t.TEXTURE_2D,0,0,0,ye.width,ye.height,Be,Se,ye.data)):n.texImage2D(t.TEXTURE_2D,0,Xe,ye.width,ye.height,0,Be,Se,ye.data);else if(O.isCompressedTexture)if(O.isCompressedArrayTexture){ke&&We&&n.texStorage3D(t.TEXTURE_2D_ARRAY,ze,Xe,tt[0].width,tt[0].height,ye.depth);for(let W=0,De=tt.length;W<De;W++)Me=tt[W],O.format!==Xo?Be!==null?ke?n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,W,0,0,0,Me.width,Me.height,ye.depth,Be,Me.data,0,0):n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,W,Xe,Me.width,Me.height,ye.depth,0,Me.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):ke?n.texSubImage3D(t.TEXTURE_2D_ARRAY,W,0,0,0,Me.width,Me.height,ye.depth,Be,Se,Me.data):n.texImage3D(t.TEXTURE_2D_ARRAY,W,Xe,Me.width,Me.height,ye.depth,0,Be,Se,Me.data)}else{ke&&We&&n.texStorage2D(t.TEXTURE_2D,ze,Xe,tt[0].width,tt[0].height);for(let W=0,De=tt.length;W<De;W++)Me=tt[W],O.format!==Xo?Be!==null?ke?n.compressedTexSubImage2D(t.TEXTURE_2D,W,0,0,Me.width,Me.height,Be,Me.data):n.compressedTexImage2D(t.TEXTURE_2D,W,Xe,Me.width,Me.height,0,Me.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):ke?n.texSubImage2D(t.TEXTURE_2D,W,0,0,Me.width,Me.height,Be,Se,Me.data):n.texImage2D(t.TEXTURE_2D,W,Xe,Me.width,Me.height,0,Be,Se,Me.data)}else if(O.isDataArrayTexture)ke?(We&&n.texStorage3D(t.TEXTURE_2D_ARRAY,ze,Xe,ye.width,ye.height,ye.depth),n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,ye.width,ye.height,ye.depth,Be,Se,ye.data)):n.texImage3D(t.TEXTURE_2D_ARRAY,0,Xe,ye.width,ye.height,ye.depth,0,Be,Se,ye.data);else if(O.isData3DTexture)ke?(We&&n.texStorage3D(t.TEXTURE_3D,ze,Xe,ye.width,ye.height,ye.depth),n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,ye.width,ye.height,ye.depth,Be,Se,ye.data)):n.texImage3D(t.TEXTURE_3D,0,Xe,ye.width,ye.height,ye.depth,0,Be,Se,ye.data);else if(O.isFramebufferTexture){if(We)if(ke)n.texStorage2D(t.TEXTURE_2D,ze,Xe,ye.width,ye.height);else{let W=ye.width,De=ye.height;for(let Ye=0;Ye<ze;Ye++)n.texImage2D(t.TEXTURE_2D,Ye,Xe,W,De,0,Be,Se,null),W>>=1,De>>=1}}else if(tt.length>0&&je){ke&&We&&n.texStorage2D(t.TEXTURE_2D,ze,Xe,tt[0].width,tt[0].height);for(let W=0,De=tt.length;W<De;W++)Me=tt[W],ke?n.texSubImage2D(t.TEXTURE_2D,W,0,0,Be,Se,Me):n.texImage2D(t.TEXTURE_2D,W,Xe,Be,Se,Me);O.generateMipmaps=!1}else ke?(We&&n.texStorage2D(t.TEXTURE_2D,ze,Xe,ye.width,ye.height),n.texSubImage2D(t.TEXTURE_2D,0,0,0,Be,Se,ye)):n.texImage2D(t.TEXTURE_2D,0,Xe,Be,Se,ye);C(O,je)&&E(le),re.__version=we.version,O.onUpdate&&O.onUpdate(O)}z.__version=O.version}function Ne(z,O,ee){if(O.image.length!==6)return;const le=Pe(z,O),_e=O.source;n.bindTexture(t.TEXTURE_CUBE_MAP,z.__webglTexture,t.TEXTURE0+ee);const we=r.get(_e);if(_e.version!==we.__version||le===!0){n.activeTexture(t.TEXTURE0+ee);const re=Er.getPrimaries(Er.workingColorSpace),Fe=O.colorSpace===Yo?null:Er.getPrimaries(O.colorSpace),He=O.colorSpace===Yo||re===Fe?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,O.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,O.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,O.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,He);const Ve=O.isCompressedTexture||O.image[0].isCompressedTexture,$e=O.image[0]&&O.image[0].isDataTexture,ye=[];for(let W=0;W<6;W++)!Ve&&!$e?ye[W]=N(O.image[W],!1,!0,u):ye[W]=$e?O.image[W].image:O.image[W],ye[W]=Ee(O,ye[W]);const je=ye[0],Be=T(je)||l,Se=a.convert(O.format,O.colorSpace),Xe=a.convert(O.type),Me=D(O.internalFormat,Se,Xe,O.colorSpace),tt=l&&O.isVideoTexture!==!0,ke=we.__version===void 0||le===!0;let We=A(O,je,Be);de(t.TEXTURE_CUBE_MAP,O,Be);let ze;if(Ve){tt&&ke&&n.texStorage2D(t.TEXTURE_CUBE_MAP,We,Me,je.width,je.height);for(let W=0;W<6;W++){ze=ye[W].mipmaps;for(let De=0;De<ze.length;De++){const Ye=ze[De];O.format!==Xo?Se!==null?tt?n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+W,De,0,0,Ye.width,Ye.height,Se,Ye.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+W,De,Me,Ye.width,Ye.height,0,Ye.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):tt?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+W,De,0,0,Ye.width,Ye.height,Se,Xe,Ye.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+W,De,Me,Ye.width,Ye.height,0,Se,Xe,Ye.data)}}}else{ze=O.mipmaps,tt&&ke&&(ze.length>0&&We++,n.texStorage2D(t.TEXTURE_CUBE_MAP,We,Me,ye[0].width,ye[0].height));for(let W=0;W<6;W++)if($e){tt?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+W,0,0,0,ye[W].width,ye[W].height,Se,Xe,ye[W].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+W,0,Me,ye[W].width,ye[W].height,0,Se,Xe,ye[W].data);for(let De=0;De<ze.length;De++){const xt=ze[De].image[W].image;tt?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+W,De+1,0,0,xt.width,xt.height,Se,Xe,xt.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+W,De+1,Me,xt.width,xt.height,0,Se,Xe,xt.data)}}else{tt?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+W,0,0,0,Se,Xe,ye[W]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+W,0,Me,Se,Xe,ye[W]);for(let De=0;De<ze.length;De++){const Ye=ze[De];tt?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+W,De+1,0,0,Se,Xe,Ye.image[W]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+W,De+1,Me,Se,Xe,Ye.image[W])}}}C(O,Be)&&E(t.TEXTURE_CUBE_MAP),we.__version=_e.version,O.onUpdate&&O.onUpdate(O)}z.__version=O.version}function Oe(z,O,ee,le,_e,we){const re=a.convert(ee.format,ee.colorSpace),Fe=a.convert(ee.type),He=D(ee.internalFormat,re,Fe,ee.colorSpace);if(!r.get(O).__hasExternalTextures){const $e=Math.max(1,O.width>>we),ye=Math.max(1,O.height>>we);_e===t.TEXTURE_3D||_e===t.TEXTURE_2D_ARRAY?n.texImage3D(_e,we,He,$e,ye,O.depth,0,re,Fe,null):n.texImage2D(_e,we,He,$e,ye,0,re,Fe,null)}n.bindFramebuffer(t.FRAMEBUFFER,z),fe(O)?p.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,le,_e,r.get(ee).__webglTexture,0,I(O)):(_e===t.TEXTURE_2D||_e>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&_e<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,le,_e,r.get(ee).__webglTexture,we),n.bindFramebuffer(t.FRAMEBUFFER,null)}function ge(z,O,ee){if(t.bindRenderbuffer(t.RENDERBUFFER,z),O.depthBuffer&&!O.stencilBuffer){let le=l===!0?t.DEPTH_COMPONENT24:t.DEPTH_COMPONENT16;if(ee||fe(O)){const _e=O.depthTexture;_e&&_e.isDepthTexture&&(_e.type===_u?le=t.DEPTH_COMPONENT32F:_e.type===Zd&&(le=t.DEPTH_COMPONENT24));const we=I(O);fe(O)?p.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,we,le,O.width,O.height):t.renderbufferStorageMultisample(t.RENDERBUFFER,we,le,O.width,O.height)}else t.renderbufferStorage(t.RENDERBUFFER,le,O.width,O.height);t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,z)}else if(O.depthBuffer&&O.stencilBuffer){const le=I(O);ee&&fe(O)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,le,t.DEPTH24_STENCIL8,O.width,O.height):fe(O)?p.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,le,t.DEPTH24_STENCIL8,O.width,O.height):t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_STENCIL,O.width,O.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,z)}else{const le=O.isWebGLMultipleRenderTargets===!0?O.texture:[O.texture];for(let _e=0;_e<le.length;_e++){const we=le[_e],re=a.convert(we.format,we.colorSpace),Fe=a.convert(we.type),He=D(we.internalFormat,re,Fe,we.colorSpace),Ve=I(O);ee&&fe(O)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,Ve,He,O.width,O.height):fe(O)?p.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,Ve,He,O.width,O.height):t.renderbufferStorage(t.RENDERBUFFER,He,O.width,O.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function Ke(z,O){if(O&&O.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(t.FRAMEBUFFER,z),!(O.depthTexture&&O.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!r.get(O.depthTexture).__webglTexture||O.depthTexture.image.width!==O.width||O.depthTexture.image.height!==O.height)&&(O.depthTexture.image.width=O.width,O.depthTexture.image.height=O.height,O.depthTexture.needsUpdate=!0),ae(O.depthTexture,0);const le=r.get(O.depthTexture).__webglTexture,_e=I(O);if(O.depthTexture.format===Wf)fe(O)?p.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,le,0,_e):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,le,0);else if(O.depthTexture.format===ix)fe(O)?p.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,le,0,_e):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,le,0);else throw new Error("Unknown depthTexture format")}function G(z){const O=r.get(z),ee=z.isWebGLCubeRenderTarget===!0;if(z.depthTexture&&!O.__autoAllocateDepthBuffer){if(ee)throw new Error("target.depthTexture not supported in Cube render targets");Ke(O.__webglFramebuffer,z)}else if(ee){O.__webglDepthbuffer=[];for(let le=0;le<6;le++)n.bindFramebuffer(t.FRAMEBUFFER,O.__webglFramebuffer[le]),O.__webglDepthbuffer[le]=t.createRenderbuffer(),ge(O.__webglDepthbuffer[le],z,!1)}else n.bindFramebuffer(t.FRAMEBUFFER,O.__webglFramebuffer),O.__webglDepthbuffer=t.createRenderbuffer(),ge(O.__webglDepthbuffer,z,!1);n.bindFramebuffer(t.FRAMEBUFFER,null)}function Y(z,O,ee){const le=r.get(z);O!==void 0&&Oe(le.__webglFramebuffer,z,z.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),ee!==void 0&&G(z)}function ce(z){const O=z.texture,ee=r.get(z),le=r.get(O);z.addEventListener("dispose",F),z.isWebGLMultipleRenderTargets!==!0&&(le.__webglTexture===void 0&&(le.__webglTexture=t.createTexture()),le.__version=O.version,o.memory.textures++);const _e=z.isWebGLCubeRenderTarget===!0,we=z.isWebGLMultipleRenderTargets===!0,re=T(z)||l;if(_e){ee.__webglFramebuffer=[];for(let Fe=0;Fe<6;Fe++)if(l&&O.mipmaps&&O.mipmaps.length>0){ee.__webglFramebuffer[Fe]=[];for(let He=0;He<O.mipmaps.length;He++)ee.__webglFramebuffer[Fe][He]=t.createFramebuffer()}else ee.__webglFramebuffer[Fe]=t.createFramebuffer()}else{if(l&&O.mipmaps&&O.mipmaps.length>0){ee.__webglFramebuffer=[];for(let Fe=0;Fe<O.mipmaps.length;Fe++)ee.__webglFramebuffer[Fe]=t.createFramebuffer()}else ee.__webglFramebuffer=t.createFramebuffer();if(we)if(i.drawBuffers){const Fe=z.texture;for(let He=0,Ve=Fe.length;He<Ve;He++){const $e=r.get(Fe[He]);$e.__webglTexture===void 0&&($e.__webglTexture=t.createTexture(),o.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(l&&z.samples>0&&fe(z)===!1){const Fe=we?O:[O];ee.__webglMultisampledFramebuffer=t.createFramebuffer(),ee.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,ee.__webglMultisampledFramebuffer);for(let He=0;He<Fe.length;He++){const Ve=Fe[He];ee.__webglColorRenderbuffer[He]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,ee.__webglColorRenderbuffer[He]);const $e=a.convert(Ve.format,Ve.colorSpace),ye=a.convert(Ve.type),je=D(Ve.internalFormat,$e,ye,Ve.colorSpace,z.isXRRenderTarget===!0),Be=I(z);t.renderbufferStorageMultisample(t.RENDERBUFFER,Be,je,z.width,z.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+He,t.RENDERBUFFER,ee.__webglColorRenderbuffer[He])}t.bindRenderbuffer(t.RENDERBUFFER,null),z.depthBuffer&&(ee.__webglDepthRenderbuffer=t.createRenderbuffer(),ge(ee.__webglDepthRenderbuffer,z,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(_e){n.bindTexture(t.TEXTURE_CUBE_MAP,le.__webglTexture),de(t.TEXTURE_CUBE_MAP,O,re);for(let Fe=0;Fe<6;Fe++)if(l&&O.mipmaps&&O.mipmaps.length>0)for(let He=0;He<O.mipmaps.length;He++)Oe(ee.__webglFramebuffer[Fe][He],z,O,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Fe,He);else Oe(ee.__webglFramebuffer[Fe],z,O,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Fe,0);C(O,re)&&E(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(we){const Fe=z.texture;for(let He=0,Ve=Fe.length;He<Ve;He++){const $e=Fe[He],ye=r.get($e);n.bindTexture(t.TEXTURE_2D,ye.__webglTexture),de(t.TEXTURE_2D,$e,re),Oe(ee.__webglFramebuffer,z,$e,t.COLOR_ATTACHMENT0+He,t.TEXTURE_2D,0),C($e,re)&&E(t.TEXTURE_2D)}n.unbindTexture()}else{let Fe=t.TEXTURE_2D;if((z.isWebGL3DRenderTarget||z.isWebGLArrayRenderTarget)&&(l?Fe=z.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),n.bindTexture(Fe,le.__webglTexture),de(Fe,O,re),l&&O.mipmaps&&O.mipmaps.length>0)for(let He=0;He<O.mipmaps.length;He++)Oe(ee.__webglFramebuffer[He],z,O,t.COLOR_ATTACHMENT0,Fe,He);else Oe(ee.__webglFramebuffer,z,O,t.COLOR_ATTACHMENT0,Fe,0);C(O,re)&&E(Fe),n.unbindTexture()}z.depthBuffer&&G(z)}function q(z){const O=T(z)||l,ee=z.isWebGLMultipleRenderTargets===!0?z.texture:[z.texture];for(let le=0,_e=ee.length;le<_e;le++){const we=ee[le];if(C(we,O)){const re=z.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:t.TEXTURE_2D,Fe=r.get(we).__webglTexture;n.bindTexture(re,Fe),E(re),n.unbindTexture()}}}function te(z){if(l&&z.samples>0&&fe(z)===!1){const O=z.isWebGLMultipleRenderTargets?z.texture:[z.texture],ee=z.width,le=z.height;let _e=t.COLOR_BUFFER_BIT;const we=[],re=z.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,Fe=r.get(z),He=z.isWebGLMultipleRenderTargets===!0;if(He)for(let Ve=0;Ve<O.length;Ve++)n.bindFramebuffer(t.FRAMEBUFFER,Fe.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ve,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,Fe.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ve,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,Fe.__webglMultisampledFramebuffer),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Fe.__webglFramebuffer);for(let Ve=0;Ve<O.length;Ve++){we.push(t.COLOR_ATTACHMENT0+Ve),z.depthBuffer&&we.push(re);const $e=Fe.__ignoreDepthValues!==void 0?Fe.__ignoreDepthValues:!1;if($e===!1&&(z.depthBuffer&&(_e|=t.DEPTH_BUFFER_BIT),z.stencilBuffer&&(_e|=t.STENCIL_BUFFER_BIT)),He&&t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,Fe.__webglColorRenderbuffer[Ve]),$e===!0&&(t.invalidateFramebuffer(t.READ_FRAMEBUFFER,[re]),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[re])),He){const ye=r.get(O[Ve]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,ye,0)}t.blitFramebuffer(0,0,ee,le,0,0,ee,le,_e,t.NEAREST),m&&t.invalidateFramebuffer(t.READ_FRAMEBUFFER,we)}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),He)for(let Ve=0;Ve<O.length;Ve++){n.bindFramebuffer(t.FRAMEBUFFER,Fe.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ve,t.RENDERBUFFER,Fe.__webglColorRenderbuffer[Ve]);const $e=r.get(O[Ve]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,Fe.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ve,t.TEXTURE_2D,$e,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Fe.__webglMultisampledFramebuffer)}}function I(z){return Math.min(f,z.samples)}function fe(z){const O=r.get(z);return l&&z.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&O.__useRenderToTexture!==!1}function me(z){const O=o.render.frame;x.get(z)!==O&&(x.set(z,O),z.update())}function Ee(z,O){const ee=z.colorSpace,le=z.format,_e=z.type;return z.isCompressedTexture===!0||z.isVideoTexture===!0||z.format===vD||ee!==Vu&&ee!==Yo&&(Er.getTransfer(ee)===Gr?l===!1?e.has("EXT_sRGB")===!0&&le===Xo?(z.format=vD,z.minFilter=Ko,z.generateMipmaps=!1):O=KJ.sRGBToLinear(O):(le!==Xo||_e!==dh)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",ee)),O}this.allocateTextureUnit=Q,this.resetTextureUnits=V,this.setTexture2D=ae,this.setTexture2DArray=B,this.setTexture3D=X,this.setTextureCube=ne,this.rebindTextures=Y,this.setupRenderTarget=ce,this.updateRenderTargetMipmap=q,this.updateMultisampleRenderTarget=te,this.setupDepthRenderbuffer=G,this.setupFrameBufferTexture=Oe,this.useMultisampledRTT=fe}function hBe(t,e,n){const r=n.isWebGL2;function i(a,o=Yo){let l;const c=Er.getTransfer(o);if(a===dh)return t.UNSIGNED_BYTE;if(a===FJ)return t.UNSIGNED_SHORT_4_4_4_4;if(a===IJ)return t.UNSIGNED_SHORT_5_5_5_1;if(a===LLe)return t.BYTE;if(a===FLe)return t.SHORT;if(a===iL)return t.UNSIGNED_SHORT;if(a===LJ)return t.INT;if(a===Zd)return t.UNSIGNED_INT;if(a===_u)return t.FLOAT;if(a===xy)return r?t.HALF_FLOAT:(l=e.get("OES_texture_half_float"),l!==null?l.HALF_FLOAT_OES:null);if(a===ILe)return t.ALPHA;if(a===Xo)return t.RGBA;if(a===ULe)return t.LUMINANCE;if(a===zLe)return t.LUMINANCE_ALPHA;if(a===Wf)return t.DEPTH_COMPONENT;if(a===ix)return t.DEPTH_STENCIL;if(a===vD)return l=e.get("EXT_sRGB"),l!==null?l.SRGB_ALPHA_EXT:null;if(a===BLe)return t.RED;if(a===UJ)return t.RED_INTEGER;if(a===HLe)return t.RG;if(a===zJ)return t.RG_INTEGER;if(a===BJ)return t.RGBA_INTEGER;if(a===NC||a===kC||a===EC||a===TC)if(c===Gr)if(l=e.get("WEBGL_compressed_texture_s3tc_srgb"),l!==null){if(a===NC)return l.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(a===kC)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(a===EC)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(a===TC)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(l=e.get("WEBGL_compressed_texture_s3tc"),l!==null){if(a===NC)return l.COMPRESSED_RGB_S3TC_DXT1_EXT;if(a===kC)return l.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(a===EC)return l.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(a===TC)return l.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(a===$V||a===VV||a===GV||a===qV)if(l=e.get("WEBGL_compressed_texture_pvrtc"),l!==null){if(a===$V)return l.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(a===VV)return l.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(a===GV)return l.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(a===qV)return l.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(a===HJ)return l=e.get("WEBGL_compressed_texture_etc1"),l!==null?l.COMPRESSED_RGB_ETC1_WEBGL:null;if(a===WV||a===KV)if(l=e.get("WEBGL_compressed_texture_etc"),l!==null){if(a===WV)return c===Gr?l.COMPRESSED_SRGB8_ETC2:l.COMPRESSED_RGB8_ETC2;if(a===KV)return c===Gr?l.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:l.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(a===XV||a===YV||a===QV||a===ZV||a===JV||a===eG||a===tG||a===nG||a===rG||a===iG||a===aG||a===sG||a===oG||a===lG)if(l=e.get("WEBGL_compressed_texture_astc"),l!==null){if(a===XV)return c===Gr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:l.COMPRESSED_RGBA_ASTC_4x4_KHR;if(a===YV)return c===Gr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:l.COMPRESSED_RGBA_ASTC_5x4_KHR;if(a===QV)return c===Gr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:l.COMPRESSED_RGBA_ASTC_5x5_KHR;if(a===ZV)return c===Gr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:l.COMPRESSED_RGBA_ASTC_6x5_KHR;if(a===JV)return c===Gr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:l.COMPRESSED_RGBA_ASTC_6x6_KHR;if(a===eG)return c===Gr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:l.COMPRESSED_RGBA_ASTC_8x5_KHR;if(a===tG)return c===Gr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:l.COMPRESSED_RGBA_ASTC_8x6_KHR;if(a===nG)return c===Gr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:l.COMPRESSED_RGBA_ASTC_8x8_KHR;if(a===rG)return c===Gr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:l.COMPRESSED_RGBA_ASTC_10x5_KHR;if(a===iG)return c===Gr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:l.COMPRESSED_RGBA_ASTC_10x6_KHR;if(a===aG)return c===Gr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:l.COMPRESSED_RGBA_ASTC_10x8_KHR;if(a===sG)return c===Gr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:l.COMPRESSED_RGBA_ASTC_10x10_KHR;if(a===oG)return c===Gr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:l.COMPRESSED_RGBA_ASTC_12x10_KHR;if(a===lG)return c===Gr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:l.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(a===AC||a===cG||a===uG)if(l=e.get("EXT_texture_compression_bptc"),l!==null){if(a===AC)return c===Gr?l.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:l.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(a===cG)return l.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(a===uG)return l.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(a===$Le||a===dG||a===hG||a===fG)if(l=e.get("EXT_texture_compression_rgtc"),l!==null){if(a===AC)return l.COMPRESSED_RED_RGTC1_EXT;if(a===dG)return l.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(a===hG)return l.COMPRESSED_RED_GREEN_RGTC2_EXT;if(a===fG)return l.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return a===qf?r?t.UNSIGNED_INT_24_8:(l=e.get("WEBGL_depth_texture"),l!==null?l.UNSIGNED_INT_24_8_WEBGL:null):t[a]!==void 0?t[a]:null}return{convert:i}}class fBe extends oo{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class u0 extends ps{constructor(){super(),this.isGroup=!0,this.type="Group"}}const mBe={type:"move"};class ZC{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new u0,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new u0,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new qe,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new qe),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new u0,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new qe,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new qe),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const n=this._hand;if(n)for(const r of e.hand.values())this._getHandJoint(n,r)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,n,r){let i=null,a=null,o=null;const l=this._targetRay,c=this._grip,u=this._hand;if(e&&n.session.visibilityState!=="visible-blurred"){if(u&&e.hand){o=!0;for(const b of e.hand.values()){const y=n.getJointPose(b,r),v=this._getHandJoint(u,b);y!==null&&(v.matrix.fromArray(y.transform.matrix),v.matrix.decompose(v.position,v.rotation,v.scale),v.matrixWorldNeedsUpdate=!0,v.jointRadius=y.radius),v.visible=y!==null}const d=u.joints["index-finger-tip"],f=u.joints["thumb-tip"],p=d.position.distanceTo(f.position),m=.02,x=.005;u.inputState.pinching&&p>m+x?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!u.inputState.pinching&&p<=m-x&&(u.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(a=n.getPose(e.gripSpace,r),a!==null&&(c.matrix.fromArray(a.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,a.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(a.linearVelocity)):c.hasLinearVelocity=!1,a.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(a.angularVelocity)):c.hasAngularVelocity=!1));l!==null&&(i=n.getPose(e.targetRaySpace,r),i===null&&a!==null&&(i=a),i!==null&&(l.matrix.fromArray(i.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,i.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(i.linearVelocity)):l.hasLinearVelocity=!1,i.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(i.angularVelocity)):l.hasAngularVelocity=!1,this.dispatchEvent(mBe)))}return l!==null&&(l.visible=i!==null),c!==null&&(c.visible=a!==null),u!==null&&(u.visible=o!==null),this}_getHandJoint(e,n){if(e.joints[n.jointName]===void 0){const r=new u0;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[n.jointName]=r,e.add(r)}return e.joints[n.jointName]}}class pBe extends jm{constructor(e,n){super();const r=this;let i=null,a=1,o=null,l="local-floor",c=1,u=null,d=null,f=null,p=null,m=null,x=null;const b=n.getContextAttributes();let y=null,v=null;const S=[],N=[],T=new xn;let k=null;const C=new oo;C.layers.enable(1),C.viewport=new Cr;const E=new oo;E.layers.enable(2),E.viewport=new Cr;const D=[C,E],A=new fBe;A.layers.enable(1),A.layers.enable(2);let R=null,U=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(ne){let se=S[ne];return se===void 0&&(se=new ZC,S[ne]=se),se.getTargetRaySpace()},this.getControllerGrip=function(ne){let se=S[ne];return se===void 0&&(se=new ZC,S[ne]=se),se.getGripSpace()},this.getHand=function(ne){let se=S[ne];return se===void 0&&(se=new ZC,S[ne]=se),se.getHandSpace()};function F(ne){const se=N.indexOf(ne.inputSource);if(se===-1)return;const be=S[se];be!==void 0&&(be.update(ne.inputSource,ne.frame,u||o),be.dispatchEvent({type:ne.type,data:ne.inputSource}))}function $(){i.removeEventListener("select",F),i.removeEventListener("selectstart",F),i.removeEventListener("selectend",F),i.removeEventListener("squeeze",F),i.removeEventListener("squeezestart",F),i.removeEventListener("squeezeend",F),i.removeEventListener("end",$),i.removeEventListener("inputsourceschange",j);for(let ne=0;ne<S.length;ne++){const se=N[ne];se!==null&&(N[ne]=null,S[ne].disconnect(se))}R=null,U=null,e.setRenderTarget(y),m=null,p=null,f=null,i=null,v=null,X.stop(),r.isPresenting=!1,e.setPixelRatio(k),e.setSize(T.width,T.height,!1),r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(ne){a=ne,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(ne){l=ne,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return u||o},this.setReferenceSpace=function(ne){u=ne},this.getBaseLayer=function(){return p!==null?p:m},this.getBinding=function(){return f},this.getFrame=function(){return x},this.getSession=function(){return i},this.setSession=async function(ne){if(i=ne,i!==null){if(y=e.getRenderTarget(),i.addEventListener("select",F),i.addEventListener("selectstart",F),i.addEventListener("selectend",F),i.addEventListener("squeeze",F),i.addEventListener("squeezestart",F),i.addEventListener("squeezeend",F),i.addEventListener("end",$),i.addEventListener("inputsourceschange",j),b.xrCompatible!==!0&&await n.makeXRCompatible(),k=e.getPixelRatio(),e.getSize(T),i.renderState.layers===void 0||e.capabilities.isWebGL2===!1){const se={antialias:i.renderState.layers===void 0?b.antialias:!0,alpha:!0,depth:b.depth,stencil:b.stencil,framebufferScaleFactor:a};m=new XRWebGLLayer(i,n,se),i.updateRenderState({baseLayer:m}),e.setPixelRatio(1),e.setSize(m.framebufferWidth,m.framebufferHeight,!1),v=new ym(m.framebufferWidth,m.framebufferHeight,{format:Xo,type:dh,colorSpace:e.outputColorSpace,stencilBuffer:b.stencil})}else{let se=null,be=null,xe=null;b.depth&&(xe=b.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,se=b.stencil?ix:Wf,be=b.stencil?qf:Zd);const de={colorFormat:n.RGBA8,depthFormat:xe,scaleFactor:a};f=new XRWebGLBinding(i,n),p=f.createProjectionLayer(de),i.updateRenderState({layers:[p]}),e.setPixelRatio(1),e.setSize(p.textureWidth,p.textureHeight,!1),v=new ym(p.textureWidth,p.textureHeight,{format:Xo,type:dh,depthTexture:new see(p.textureWidth,p.textureHeight,be,void 0,void 0,void 0,void 0,void 0,void 0,se),stencilBuffer:b.stencil,colorSpace:e.outputColorSpace,samples:b.antialias?4:0});const Pe=e.properties.get(v);Pe.__ignoreDepthValues=p.ignoreDepthValues}v.isXRRenderTarget=!0,this.setFoveation(c),u=null,o=await i.requestReferenceSpace(l),X.setContext(i),X.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode};function j(ne){for(let se=0;se<ne.removed.length;se++){const be=ne.removed[se],xe=N.indexOf(be);xe>=0&&(N[xe]=null,S[xe].disconnect(be))}for(let se=0;se<ne.added.length;se++){const be=ne.added[se];let xe=N.indexOf(be);if(xe===-1){for(let Pe=0;Pe<S.length;Pe++)if(Pe>=N.length){N.push(be),xe=Pe;break}else if(N[Pe]===null){N[Pe]=be,xe=Pe;break}if(xe===-1)break}const de=S[xe];de&&de.connect(be)}}const H=new qe,K=new qe;function V(ne,se,be){H.setFromMatrixPosition(se.matrixWorld),K.setFromMatrixPosition(be.matrixWorld);const xe=H.distanceTo(K),de=se.projectionMatrix.elements,Pe=be.projectionMatrix.elements,ie=de[14]/(de[10]-1),Ne=de[14]/(de[10]+1),Oe=(de[9]+1)/de[5],ge=(de[9]-1)/de[5],Ke=(de[8]-1)/de[0],G=(Pe[8]+1)/Pe[0],Y=ie*Ke,ce=ie*G,q=xe/(-Ke+G),te=q*-Ke;se.matrixWorld.decompose(ne.position,ne.quaternion,ne.scale),ne.translateX(te),ne.translateZ(q),ne.matrixWorld.compose(ne.position,ne.quaternion,ne.scale),ne.matrixWorldInverse.copy(ne.matrixWorld).invert();const I=ie+q,fe=Ne+q,me=Y-te,Ee=ce+(xe-te),z=Oe*Ne/fe*I,O=ge*Ne/fe*I;ne.projectionMatrix.makePerspective(me,Ee,z,O,I,fe),ne.projectionMatrixInverse.copy(ne.projectionMatrix).invert()}function Q(ne,se){se===null?ne.matrixWorld.copy(ne.matrix):ne.matrixWorld.multiplyMatrices(se.matrixWorld,ne.matrix),ne.matrixWorldInverse.copy(ne.matrixWorld).invert()}this.updateCamera=function(ne){if(i===null)return;A.near=E.near=C.near=ne.near,A.far=E.far=C.far=ne.far,(R!==A.near||U!==A.far)&&(i.updateRenderState({depthNear:A.near,depthFar:A.far}),R=A.near,U=A.far);const se=ne.parent,be=A.cameras;Q(A,se);for(let xe=0;xe<be.length;xe++)Q(be[xe],se);be.length===2?V(A,C,E):A.projectionMatrix.copy(C.projectionMatrix),Z(ne,A,se)};function Z(ne,se,be){be===null?ne.matrix.copy(se.matrixWorld):(ne.matrix.copy(be.matrixWorld),ne.matrix.invert(),ne.matrix.multiply(se.matrixWorld)),ne.matrix.decompose(ne.position,ne.quaternion,ne.scale),ne.updateMatrixWorld(!0),ne.projectionMatrix.copy(se.projectionMatrix),ne.projectionMatrixInverse.copy(se.projectionMatrixInverse),ne.isPerspectiveCamera&&(ne.fov=yy*2*Math.atan(1/ne.projectionMatrix.elements[5]),ne.zoom=1)}this.getCamera=function(){return A},this.getFoveation=function(){if(!(p===null&&m===null))return c},this.setFoveation=function(ne){c=ne,p!==null&&(p.fixedFoveation=ne),m!==null&&m.fixedFoveation!==void 0&&(m.fixedFoveation=ne)};let ae=null;function B(ne,se){if(d=se.getViewerPose(u||o),x=se,d!==null){const be=d.views;m!==null&&(e.setRenderTargetFramebuffer(v,m.framebuffer),e.setRenderTarget(v));let xe=!1;be.length!==A.cameras.length&&(A.cameras.length=0,xe=!0);for(let de=0;de<be.length;de++){const Pe=be[de];let ie=null;if(m!==null)ie=m.getViewport(Pe);else{const Oe=f.getViewSubImage(p,Pe);ie=Oe.viewport,de===0&&(e.setRenderTargetTextures(v,Oe.colorTexture,p.ignoreDepthValues?void 0:Oe.depthStencilTexture),e.setRenderTarget(v))}let Ne=D[de];Ne===void 0&&(Ne=new oo,Ne.layers.enable(de),Ne.viewport=new Cr,D[de]=Ne),Ne.matrix.fromArray(Pe.transform.matrix),Ne.matrix.decompose(Ne.position,Ne.quaternion,Ne.scale),Ne.projectionMatrix.fromArray(Pe.projectionMatrix),Ne.projectionMatrixInverse.copy(Ne.projectionMatrix).invert(),Ne.viewport.set(ie.x,ie.y,ie.width,ie.height),de===0&&(A.matrix.copy(Ne.matrix),A.matrix.decompose(A.position,A.quaternion,A.scale)),xe===!0&&A.cameras.push(Ne)}}for(let be=0;be<S.length;be++){const xe=N[be],de=S[be];xe!==null&&de!==void 0&&de.update(xe,se,u||o)}ae&&ae(ne,se),se.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:se}),x=null}const X=new aee;X.setAnimationLoop(B),this.setAnimationLoop=function(ne){ae=ne},this.dispose=function(){}}}function gBe(t,e){function n(y,v){y.matrixAutoUpdate===!0&&y.updateMatrix(),v.value.copy(y.matrix)}function r(y,v){v.color.getRGB(y.fogColor.value,nee(t)),v.isFog?(y.fogNear.value=v.near,y.fogFar.value=v.far):v.isFogExp2&&(y.fogDensity.value=v.density)}function i(y,v,S,N,T){v.isMeshBasicMaterial||v.isMeshLambertMaterial?a(y,v):v.isMeshToonMaterial?(a(y,v),f(y,v)):v.isMeshPhongMaterial?(a(y,v),d(y,v)):v.isMeshStandardMaterial?(a(y,v),p(y,v),v.isMeshPhysicalMaterial&&m(y,v,T)):v.isMeshMatcapMaterial?(a(y,v),x(y,v)):v.isMeshDepthMaterial?a(y,v):v.isMeshDistanceMaterial?(a(y,v),b(y,v)):v.isMeshNormalMaterial?a(y,v):v.isLineBasicMaterial?(o(y,v),v.isLineDashedMaterial&&l(y,v)):v.isPointsMaterial?c(y,v,S,N):v.isSpriteMaterial?u(y,v):v.isShadowMaterial?(y.color.value.copy(v.color),y.opacity.value=v.opacity):v.isShaderMaterial&&(v.uniformsNeedUpdate=!1)}function a(y,v){y.opacity.value=v.opacity,v.color&&y.diffuse.value.copy(v.color),v.emissive&&y.emissive.value.copy(v.emissive).multiplyScalar(v.emissiveIntensity),v.map&&(y.map.value=v.map,n(v.map,y.mapTransform)),v.alphaMap&&(y.alphaMap.value=v.alphaMap,n(v.alphaMap,y.alphaMapTransform)),v.bumpMap&&(y.bumpMap.value=v.bumpMap,n(v.bumpMap,y.bumpMapTransform),y.bumpScale.value=v.bumpScale,v.side===zs&&(y.bumpScale.value*=-1)),v.normalMap&&(y.normalMap.value=v.normalMap,n(v.normalMap,y.normalMapTransform),y.normalScale.value.copy(v.normalScale),v.side===zs&&y.normalScale.value.negate()),v.displacementMap&&(y.displacementMap.value=v.displacementMap,n(v.displacementMap,y.displacementMapTransform),y.displacementScale.value=v.displacementScale,y.displacementBias.value=v.displacementBias),v.emissiveMap&&(y.emissiveMap.value=v.emissiveMap,n(v.emissiveMap,y.emissiveMapTransform)),v.specularMap&&(y.specularMap.value=v.specularMap,n(v.specularMap,y.specularMapTransform)),v.alphaTest>0&&(y.alphaTest.value=v.alphaTest);const S=e.get(v).envMap;if(S&&(y.envMap.value=S,y.flipEnvMap.value=S.isCubeTexture&&S.isRenderTargetTexture===!1?-1:1,y.reflectivity.value=v.reflectivity,y.ior.value=v.ior,y.refractionRatio.value=v.refractionRatio),v.lightMap){y.lightMap.value=v.lightMap;const N=t._useLegacyLights===!0?Math.PI:1;y.lightMapIntensity.value=v.lightMapIntensity*N,n(v.lightMap,y.lightMapTransform)}v.aoMap&&(y.aoMap.value=v.aoMap,y.aoMapIntensity.value=v.aoMapIntensity,n(v.aoMap,y.aoMapTransform))}function o(y,v){y.diffuse.value.copy(v.color),y.opacity.value=v.opacity,v.map&&(y.map.value=v.map,n(v.map,y.mapTransform))}function l(y,v){y.dashSize.value=v.dashSize,y.totalSize.value=v.dashSize+v.gapSize,y.scale.value=v.scale}function c(y,v,S,N){y.diffuse.value.copy(v.color),y.opacity.value=v.opacity,y.size.value=v.size*S,y.scale.value=N*.5,v.map&&(y.map.value=v.map,n(v.map,y.uvTransform)),v.alphaMap&&(y.alphaMap.value=v.alphaMap,n(v.alphaMap,y.alphaMapTransform)),v.alphaTest>0&&(y.alphaTest.value=v.alphaTest)}function u(y,v){y.diffuse.value.copy(v.color),y.opacity.value=v.opacity,y.rotation.value=v.rotation,v.map&&(y.map.value=v.map,n(v.map,y.mapTransform)),v.alphaMap&&(y.alphaMap.value=v.alphaMap,n(v.alphaMap,y.alphaMapTransform)),v.alphaTest>0&&(y.alphaTest.value=v.alphaTest)}function d(y,v){y.specular.value.copy(v.specular),y.shininess.value=Math.max(v.shininess,1e-4)}function f(y,v){v.gradientMap&&(y.gradientMap.value=v.gradientMap)}function p(y,v){y.metalness.value=v.metalness,v.metalnessMap&&(y.metalnessMap.value=v.metalnessMap,n(v.metalnessMap,y.metalnessMapTransform)),y.roughness.value=v.roughness,v.roughnessMap&&(y.roughnessMap.value=v.roughnessMap,n(v.roughnessMap,y.roughnessMapTransform)),e.get(v).envMap&&(y.envMapIntensity.value=v.envMapIntensity)}function m(y,v,S){y.ior.value=v.ior,v.sheen>0&&(y.sheenColor.value.copy(v.sheenColor).multiplyScalar(v.sheen),y.sheenRoughness.value=v.sheenRoughness,v.sheenColorMap&&(y.sheenColorMap.value=v.sheenColorMap,n(v.sheenColorMap,y.sheenColorMapTransform)),v.sheenRoughnessMap&&(y.sheenRoughnessMap.value=v.sheenRoughnessMap,n(v.sheenRoughnessMap,y.sheenRoughnessMapTransform))),v.clearcoat>0&&(y.clearcoat.value=v.clearcoat,y.clearcoatRoughness.value=v.clearcoatRoughness,v.clearcoatMap&&(y.clearcoatMap.value=v.clearcoatMap,n(v.clearcoatMap,y.clearcoatMapTransform)),v.clearcoatRoughnessMap&&(y.clearcoatRoughnessMap.value=v.clearcoatRoughnessMap,n(v.clearcoatRoughnessMap,y.clearcoatRoughnessMapTransform)),v.clearcoatNormalMap&&(y.clearcoatNormalMap.value=v.clearcoatNormalMap,n(v.clearcoatNormalMap,y.clearcoatNormalMapTransform),y.clearcoatNormalScale.value.copy(v.clearcoatNormalScale),v.side===zs&&y.clearcoatNormalScale.value.negate())),v.iridescence>0&&(y.iridescence.value=v.iridescence,y.iridescenceIOR.value=v.iridescenceIOR,y.iridescenceThicknessMinimum.value=v.iridescenceThicknessRange[0],y.iridescenceThicknessMaximum.value=v.iridescenceThicknessRange[1],v.iridescenceMap&&(y.iridescenceMap.value=v.iridescenceMap,n(v.iridescenceMap,y.iridescenceMapTransform)),v.iridescenceThicknessMap&&(y.iridescenceThicknessMap.value=v.iridescenceThicknessMap,n(v.iridescenceThicknessMap,y.iridescenceThicknessMapTransform))),v.transmission>0&&(y.transmission.value=v.transmission,y.transmissionSamplerMap.value=S.texture,y.transmissionSamplerSize.value.set(S.width,S.height),v.transmissionMap&&(y.transmissionMap.value=v.transmissionMap,n(v.transmissionMap,y.transmissionMapTransform)),y.thickness.value=v.thickness,v.thicknessMap&&(y.thicknessMap.value=v.thicknessMap,n(v.thicknessMap,y.thicknessMapTransform)),y.attenuationDistance.value=v.attenuationDistance,y.attenuationColor.value.copy(v.attenuationColor)),v.anisotropy>0&&(y.anisotropyVector.value.set(v.anisotropy*Math.cos(v.anisotropyRotation),v.anisotropy*Math.sin(v.anisotropyRotation)),v.anisotropyMap&&(y.anisotropyMap.value=v.anisotropyMap,n(v.anisotropyMap,y.anisotropyMapTransform))),y.specularIntensity.value=v.specularIntensity,y.specularColor.value.copy(v.specularColor),v.specularColorMap&&(y.specularColorMap.value=v.specularColorMap,n(v.specularColorMap,y.specularColorMapTransform)),v.specularIntensityMap&&(y.specularIntensityMap.value=v.specularIntensityMap,n(v.specularIntensityMap,y.specularIntensityMapTransform))}function x(y,v){v.matcap&&(y.matcap.value=v.matcap)}function b(y,v){const S=e.get(v).light;y.referencePosition.value.setFromMatrixPosition(S.matrixWorld),y.nearDistance.value=S.shadow.camera.near,y.farDistance.value=S.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function xBe(t,e,n,r){let i={},a={},o=[];const l=n.isWebGL2?t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS):0;function c(S,N){const T=N.program;r.uniformBlockBinding(S,T)}function u(S,N){let T=i[S.id];T===void 0&&(x(S),T=d(S),i[S.id]=T,S.addEventListener("dispose",y));const k=N.program;r.updateUBOMapping(S,k);const C=e.render.frame;a[S.id]!==C&&(p(S),a[S.id]=C)}function d(S){const N=f();S.__bindingPointIndex=N;const T=t.createBuffer(),k=S.__size,C=S.usage;return t.bindBuffer(t.UNIFORM_BUFFER,T),t.bufferData(t.UNIFORM_BUFFER,k,C),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,N,T),T}function f(){for(let S=0;S<l;S++)if(o.indexOf(S)===-1)return o.push(S),S;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function p(S){const N=i[S.id],T=S.uniforms,k=S.__cache;t.bindBuffer(t.UNIFORM_BUFFER,N);for(let C=0,E=T.length;C<E;C++){const D=T[C];if(m(D,C,k)===!0){const A=D.__offset,R=Array.isArray(D.value)?D.value:[D.value];let U=0;for(let F=0;F<R.length;F++){const $=R[F],j=b($);typeof $=="number"?(D.__data[0]=$,t.bufferSubData(t.UNIFORM_BUFFER,A+U,D.__data)):$.isMatrix3?(D.__data[0]=$.elements[0],D.__data[1]=$.elements[1],D.__data[2]=$.elements[2],D.__data[3]=$.elements[0],D.__data[4]=$.elements[3],D.__data[5]=$.elements[4],D.__data[6]=$.elements[5],D.__data[7]=$.elements[0],D.__data[8]=$.elements[6],D.__data[9]=$.elements[7],D.__data[10]=$.elements[8],D.__data[11]=$.elements[0]):($.toArray(D.__data,U),U+=j.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,A,D.__data)}}t.bindBuffer(t.UNIFORM_BUFFER,null)}function m(S,N,T){const k=S.value;if(T[N]===void 0){if(typeof k=="number")T[N]=k;else{const C=Array.isArray(k)?k:[k],E=[];for(let D=0;D<C.length;D++)E.push(C[D].clone());T[N]=E}return!0}else if(typeof k=="number"){if(T[N]!==k)return T[N]=k,!0}else{const C=Array.isArray(T[N])?T[N]:[T[N]],E=Array.isArray(k)?k:[k];for(let D=0;D<C.length;D++){const A=C[D];if(A.equals(E[D])===!1)return A.copy(E[D]),!0}}return!1}function x(S){const N=S.uniforms;let T=0;const k=16;let C=0;for(let E=0,D=N.length;E<D;E++){const A=N[E],R={boundary:0,storage:0},U=Array.isArray(A.value)?A.value:[A.value];for(let F=0,$=U.length;F<$;F++){const j=U[F],H=b(j);R.boundary+=H.boundary,R.storage+=H.storage}if(A.__data=new Float32Array(R.storage/Float32Array.BYTES_PER_ELEMENT),A.__offset=T,E>0){C=T%k;const F=k-C;C!==0&&F-R.boundary<0&&(T+=k-C,A.__offset=T)}T+=R.storage}return C=T%k,C>0&&(T+=k-C),S.__size=T,S.__cache={},this}function b(S){const N={boundary:0,storage:0};return typeof S=="number"?(N.boundary=4,N.storage=4):S.isVector2?(N.boundary=8,N.storage=8):S.isVector3||S.isColor?(N.boundary=16,N.storage=12):S.isVector4?(N.boundary=16,N.storage=16):S.isMatrix3?(N.boundary=48,N.storage=48):S.isMatrix4?(N.boundary=64,N.storage=64):S.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",S),N}function y(S){const N=S.target;N.removeEventListener("dispose",y);const T=o.indexOf(N.__bindingPointIndex);o.splice(T,1),t.deleteBuffer(i[N.id]),delete i[N.id],delete a[N.id]}function v(){for(const S in i)t.deleteBuffer(i[S]);o=[],i={},a={}}return{bind:c,update:u,dispose:v}}class SD{constructor(e={}){const{canvas:n=mFe(),context:r=null,depth:i=!0,stencil:a=!0,alpha:o=!1,antialias:l=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:u=!1,powerPreference:d="default",failIfMajorPerformanceCaveat:f=!1}=e;this.isWebGLRenderer=!0;let p;r!==null?p=r.getContextAttributes().alpha:p=o;const m=new Uint32Array(4),x=new Int32Array(4);let b=null,y=null;const v=[],S=[];this.domElement=n,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=Ra,this._useLegacyLights=!1,this.toneMapping=uh,this.toneMappingExposure=1;const N=this;let T=!1,k=0,C=0,E=null,D=-1,A=null;const R=new Cr,U=new Cr;let F=null;const $=new Zt(0);let j=0,H=n.width,K=n.height,V=1,Q=null,Z=null;const ae=new Cr(0,0,H,K),B=new Cr(0,0,H,K);let X=!1;const ne=new v2;let se=!1,be=!1,xe=null;const de=new zr,Pe=new xn,ie=new qe,Ne={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Oe(){return E===null?V:1}let ge=r;function Ke(Ae,Ze){for(let st=0;st<Ae.length;st++){const lt=Ae[st],ot=n.getContext(lt,Ze);if(ot!==null)return ot}return null}try{const Ae={alpha:!0,depth:i,stencil:a,antialias:l,premultipliedAlpha:c,preserveDrawingBuffer:u,powerPreference:d,failIfMajorPerformanceCaveat:f};if("setAttribute"in n&&n.setAttribute("data-engine",`three.js r${x2}`),n.addEventListener("webglcontextlost",tt,!1),n.addEventListener("webglcontextrestored",ke,!1),n.addEventListener("webglcontextcreationerror",We,!1),ge===null){const Ze=["webgl2","webgl","experimental-webgl"];if(N.isWebGL1Renderer===!0&&Ze.shift(),ge=Ke(Ze,Ae),ge===null)throw Ke(Ze)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}typeof WebGLRenderingContext<"u"&&ge instanceof WebGLRenderingContext&&console.warn("THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163."),ge.getShaderPrecisionFormat===void 0&&(ge.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(Ae){throw console.error("THREE.WebGLRenderer: "+Ae.message),Ae}let G,Y,ce,q,te,I,fe,me,Ee,z,O,ee,le,_e,we,re,Fe,He,Ve,$e,ye,je,Be,Se;function Xe(){G=new TUe(ge),Y=new wUe(ge,G,e),G.init(Y),je=new hBe(ge,G,Y),ce=new uBe(ge,G,Y),q=new jUe(ge),te=new Yze,I=new dBe(ge,G,ce,te,Y,je,q),fe=new SUe(N),me=new EUe(N),Ee=new IFe(ge,Y),Be=new yUe(ge,G,Ee,Y),z=new AUe(ge,Ee,q,Be),O=new OUe(ge,z,Ee,q),Ve=new RUe(ge,Y,I),re=new _Ue(te),ee=new Xze(N,fe,me,G,Y,Be,re),le=new gBe(N,te),_e=new Zze,we=new iBe(G,Y),He=new bUe(N,fe,me,ce,O,p,c),Fe=new cBe(N,O,Y),Se=new xBe(ge,q,Y,ce),$e=new vUe(ge,G,q,Y),ye=new CUe(ge,G,q,Y),q.programs=ee.programs,N.capabilities=Y,N.extensions=G,N.properties=te,N.renderLists=_e,N.shadowMap=Fe,N.state=ce,N.info=q}Xe();const Me=new pBe(N,ge);this.xr=Me,this.getContext=function(){return ge},this.getContextAttributes=function(){return ge.getContextAttributes()},this.forceContextLoss=function(){const Ae=G.get("WEBGL_lose_context");Ae&&Ae.loseContext()},this.forceContextRestore=function(){const Ae=G.get("WEBGL_lose_context");Ae&&Ae.restoreContext()},this.getPixelRatio=function(){return V},this.setPixelRatio=function(Ae){Ae!==void 0&&(V=Ae,this.setSize(H,K,!1))},this.getSize=function(Ae){return Ae.set(H,K)},this.setSize=function(Ae,Ze,st=!0){if(Me.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}H=Ae,K=Ze,n.width=Math.floor(Ae*V),n.height=Math.floor(Ze*V),st===!0&&(n.style.width=Ae+"px",n.style.height=Ze+"px"),this.setViewport(0,0,Ae,Ze)},this.getDrawingBufferSize=function(Ae){return Ae.set(H*V,K*V).floor()},this.setDrawingBufferSize=function(Ae,Ze,st){H=Ae,K=Ze,V=st,n.width=Math.floor(Ae*st),n.height=Math.floor(Ze*st),this.setViewport(0,0,Ae,Ze)},this.getCurrentViewport=function(Ae){return Ae.copy(R)},this.getViewport=function(Ae){return Ae.copy(ae)},this.setViewport=function(Ae,Ze,st,lt){Ae.isVector4?ae.set(Ae.x,Ae.y,Ae.z,Ae.w):ae.set(Ae,Ze,st,lt),ce.viewport(R.copy(ae).multiplyScalar(V).floor())},this.getScissor=function(Ae){return Ae.copy(B)},this.setScissor=function(Ae,Ze,st,lt){Ae.isVector4?B.set(Ae.x,Ae.y,Ae.z,Ae.w):B.set(Ae,Ze,st,lt),ce.scissor(U.copy(B).multiplyScalar(V).floor())},this.getScissorTest=function(){return X},this.setScissorTest=function(Ae){ce.setScissorTest(X=Ae)},this.setOpaqueSort=function(Ae){Q=Ae},this.setTransparentSort=function(Ae){Z=Ae},this.getClearColor=function(Ae){return Ae.copy(He.getClearColor())},this.setClearColor=function(){He.setClearColor.apply(He,arguments)},this.getClearAlpha=function(){return He.getClearAlpha()},this.setClearAlpha=function(){He.setClearAlpha.apply(He,arguments)},this.clear=function(Ae=!0,Ze=!0,st=!0){let lt=0;if(Ae){let ot=!1;if(E!==null){const Et=E.texture.format;ot=Et===BJ||Et===zJ||Et===UJ}if(ot){const Et=E.texture.type,he=Et===dh||Et===Zd||Et===iL||Et===qf||Et===FJ||Et===IJ,pe=He.getClearColor(),Ie=He.getClearAlpha(),Le=pe.r,Ce=pe.g,ut=pe.b;he?(m[0]=Le,m[1]=Ce,m[2]=ut,m[3]=Ie,ge.clearBufferuiv(ge.COLOR,0,m)):(x[0]=Le,x[1]=Ce,x[2]=ut,x[3]=Ie,ge.clearBufferiv(ge.COLOR,0,x))}else lt|=ge.COLOR_BUFFER_BIT}Ze&&(lt|=ge.DEPTH_BUFFER_BIT),st&&(lt|=ge.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),ge.clear(lt)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){n.removeEventListener("webglcontextlost",tt,!1),n.removeEventListener("webglcontextrestored",ke,!1),n.removeEventListener("webglcontextcreationerror",We,!1),_e.dispose(),we.dispose(),te.dispose(),fe.dispose(),me.dispose(),O.dispose(),Be.dispose(),Se.dispose(),ee.dispose(),Me.dispose(),Me.removeEventListener("sessionstart",Bt),Me.removeEventListener("sessionend",Lt),xe&&(xe.dispose(),xe=null),vn.stop()};function tt(Ae){Ae.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),T=!0}function ke(){console.log("THREE.WebGLRenderer: Context Restored."),T=!1;const Ae=q.autoReset,Ze=Fe.enabled,st=Fe.autoUpdate,lt=Fe.needsUpdate,ot=Fe.type;Xe(),q.autoReset=Ae,Fe.enabled=Ze,Fe.autoUpdate=st,Fe.needsUpdate=lt,Fe.type=ot}function We(Ae){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",Ae.statusMessage)}function ze(Ae){const Ze=Ae.target;Ze.removeEventListener("dispose",ze),W(Ze)}function W(Ae){De(Ae),te.remove(Ae)}function De(Ae){const Ze=te.get(Ae).programs;Ze!==void 0&&(Ze.forEach(function(st){ee.releaseProgram(st)}),Ae.isShaderMaterial&&ee.releaseShaderCache(Ae))}this.renderBufferDirect=function(Ae,Ze,st,lt,ot,Et){Ze===null&&(Ze=Ne);const he=ot.isMesh&&ot.matrixWorld.determinant()<0,pe=bn(Ae,Ze,st,lt,ot);ce.setMaterial(lt,he);let Ie=st.index,Le=1;if(lt.wireframe===!0){if(Ie=z.getWireframeAttribute(st),Ie===void 0)return;Le=2}const Ce=st.drawRange,ut=st.attributes.position;let St=Ce.start*Le,At=(Ce.start+Ce.count)*Le;Et!==null&&(St=Math.max(St,Et.start*Le),At=Math.min(At,(Et.start+Et.count)*Le)),Ie!==null?(St=Math.max(St,0),At=Math.min(At,Ie.count)):ut!=null&&(St=Math.max(St,0),At=Math.min(At,ut.count));const Tt=At-St;if(Tt<0||Tt===1/0)return;Be.setup(ot,lt,pe,st,Ie);let Ft,Pt=$e;if(Ie!==null&&(Ft=Ee.get(Ie),Pt=ye,Pt.setIndex(Ft)),ot.isMesh)lt.wireframe===!0?(ce.setLineWidth(lt.wireframeLinewidth*Oe()),Pt.setMode(ge.LINES)):Pt.setMode(ge.TRIANGLES);else if(ot.isLine){let Nt=lt.linewidth;Nt===void 0&&(Nt=1),ce.setLineWidth(Nt*Oe()),ot.isLineSegments?Pt.setMode(ge.LINES):ot.isLineLoop?Pt.setMode(ge.LINE_LOOP):Pt.setMode(ge.LINE_STRIP)}else ot.isPoints?Pt.setMode(ge.POINTS):ot.isSprite&&Pt.setMode(ge.TRIANGLES);if(ot.isBatchedMesh)Pt.renderMultiDraw(ot._multiDrawStarts,ot._multiDrawCounts,ot._multiDrawCount);else if(ot.isInstancedMesh)Pt.renderInstances(St,Tt,ot.count);else if(st.isInstancedBufferGeometry){const Nt=st._maxInstanceCount!==void 0?st._maxInstanceCount:1/0,en=Math.min(st.instanceCount,Nt);Pt.renderInstances(St,Tt,en)}else Pt.render(St,Tt)};function Ye(Ae,Ze,st){Ae.transparent===!0&&Ae.side===pu&&Ae.forceSinglePass===!1?(Ae.side=zs,Ae.needsUpdate=!0,mr(Ae,Ze,st),Ae.side=Th,Ae.needsUpdate=!0,mr(Ae,Ze,st),Ae.side=pu):mr(Ae,Ze,st)}this.compile=function(Ae,Ze,st=null){st===null&&(st=Ae),y=we.get(st),y.init(),S.push(y),st.traverseVisible(function(ot){ot.isLight&&ot.layers.test(Ze.layers)&&(y.pushLight(ot),ot.castShadow&&y.pushShadow(ot))}),Ae!==st&&Ae.traverseVisible(function(ot){ot.isLight&&ot.layers.test(Ze.layers)&&(y.pushLight(ot),ot.castShadow&&y.pushShadow(ot))}),y.setupLights(N._useLegacyLights);const lt=new Set;return Ae.traverse(function(ot){const Et=ot.material;if(Et)if(Array.isArray(Et))for(let he=0;he<Et.length;he++){const pe=Et[he];Ye(pe,st,ot),lt.add(pe)}else Ye(Et,st,ot),lt.add(Et)}),S.pop(),y=null,lt},this.compileAsync=function(Ae,Ze,st=null){const lt=this.compile(Ae,Ze,st);return new Promise(ot=>{function Et(){if(lt.forEach(function(he){te.get(he).currentProgram.isReady()&<.delete(he)}),lt.size===0){ot(Ae);return}setTimeout(Et,10)}G.get("KHR_parallel_shader_compile")!==null?Et():setTimeout(Et,10)})};let xt=null;function ft(Ae){xt&&xt(Ae)}function Bt(){vn.stop()}function Lt(){vn.start()}const vn=new aee;vn.setAnimationLoop(ft),typeof self<"u"&&vn.setContext(self),this.setAnimationLoop=function(Ae){xt=Ae,Me.setAnimationLoop(Ae),Ae===null?vn.stop():vn.start()},Me.addEventListener("sessionstart",Bt),Me.addEventListener("sessionend",Lt),this.render=function(Ae,Ze){if(Ze!==void 0&&Ze.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(T===!0)return;Ae.matrixWorldAutoUpdate===!0&&Ae.updateMatrixWorld(),Ze.parent===null&&Ze.matrixWorldAutoUpdate===!0&&Ze.updateMatrixWorld(),Me.enabled===!0&&Me.isPresenting===!0&&(Me.cameraAutoUpdate===!0&&Me.updateCamera(Ze),Ze=Me.getCamera()),Ae.isScene===!0&&Ae.onBeforeRender(N,Ae,Ze,E),y=we.get(Ae,S.length),y.init(),S.push(y),de.multiplyMatrices(Ze.projectionMatrix,Ze.matrixWorldInverse),ne.setFromProjectionMatrix(de),be=this.localClippingEnabled,se=re.init(this.clippingPlanes,be),b=_e.get(Ae,v.length),b.init(),v.push(b),Jt(Ae,Ze,0,N.sortObjects),b.finish(),N.sortObjects===!0&&b.sort(Q,Z),this.info.render.frame++,se===!0&&re.beginShadows();const st=y.state.shadowsArray;if(Fe.render(st,Ae,Ze),se===!0&&re.endShadows(),this.info.autoReset===!0&&this.info.reset(),He.render(b,Ae),y.setupLights(N._useLegacyLights),Ze.isArrayCamera){const lt=Ze.cameras;for(let ot=0,Et=lt.length;ot<Et;ot++){const he=lt[ot];ir(b,Ae,he,he.viewport)}}else ir(b,Ae,Ze);E!==null&&(I.updateMultisampleRenderTarget(E),I.updateRenderTargetMipmap(E)),Ae.isScene===!0&&Ae.onAfterRender(N,Ae,Ze),Be.resetDefaultState(),D=-1,A=null,S.pop(),S.length>0?y=S[S.length-1]:y=null,v.pop(),v.length>0?b=v[v.length-1]:b=null};function Jt(Ae,Ze,st,lt){if(Ae.visible===!1)return;if(Ae.layers.test(Ze.layers)){if(Ae.isGroup)st=Ae.renderOrder;else if(Ae.isLOD)Ae.autoUpdate===!0&&Ae.update(Ze);else if(Ae.isLight)y.pushLight(Ae),Ae.castShadow&&y.pushShadow(Ae);else if(Ae.isSprite){if(!Ae.frustumCulled||ne.intersectsSprite(Ae)){lt&&ie.setFromMatrixPosition(Ae.matrixWorld).applyMatrix4(de);const he=O.update(Ae),pe=Ae.material;pe.visible&&b.push(Ae,he,pe,st,ie.z,null)}}else if((Ae.isMesh||Ae.isLine||Ae.isPoints)&&(!Ae.frustumCulled||ne.intersectsObject(Ae))){const he=O.update(Ae),pe=Ae.material;if(lt&&(Ae.boundingSphere!==void 0?(Ae.boundingSphere===null&&Ae.computeBoundingSphere(),ie.copy(Ae.boundingSphere.center)):(he.boundingSphere===null&&he.computeBoundingSphere(),ie.copy(he.boundingSphere.center)),ie.applyMatrix4(Ae.matrixWorld).applyMatrix4(de)),Array.isArray(pe)){const Ie=he.groups;for(let Le=0,Ce=Ie.length;Le<Ce;Le++){const ut=Ie[Le],St=pe[ut.materialIndex];St&&St.visible&&b.push(Ae,he,St,st,ie.z,ut)}}else pe.visible&&b.push(Ae,he,pe,st,ie.z,null)}}const Et=Ae.children;for(let he=0,pe=Et.length;he<pe;he++)Jt(Et[he],Ze,st,lt)}function ir(Ae,Ze,st,lt){const ot=Ae.opaque,Et=Ae.transmissive,he=Ae.transparent;y.setupLightsView(st),se===!0&&re.setGlobalState(N.clippingPlanes,st),Et.length>0&&fr(ot,Et,Ze,st),lt&&ce.viewport(R.copy(lt)),ot.length>0&&Dn(ot,Ze,st),Et.length>0&&Dn(Et,Ze,st),he.length>0&&Dn(he,Ze,st),ce.buffers.depth.setTest(!0),ce.buffers.depth.setMask(!0),ce.buffers.color.setMask(!0),ce.setPolygonOffset(!1)}function fr(Ae,Ze,st,lt){if((st.isScene===!0?st.overrideMaterial:null)!==null)return;const Et=Y.isWebGL2;xe===null&&(xe=new ym(1,1,{generateMipmaps:!0,type:G.has("EXT_color_buffer_half_float")?xy:dh,minFilter:gy,samples:Et?4:0})),N.getDrawingBufferSize(Pe),Et?xe.setSize(Pe.x,Pe.y):xe.setSize(nM(Pe.x),nM(Pe.y));const he=N.getRenderTarget();N.setRenderTarget(xe),N.getClearColor($),j=N.getClearAlpha(),j<1&&N.setClearColor(16777215,.5),N.clear();const pe=N.toneMapping;N.toneMapping=uh,Dn(Ae,st,lt),I.updateMultisampleRenderTarget(xe),I.updateRenderTargetMipmap(xe);let Ie=!1;for(let Le=0,Ce=Ze.length;Le<Ce;Le++){const ut=Ze[Le],St=ut.object,At=ut.geometry,Tt=ut.material,Ft=ut.group;if(Tt.side===pu&&St.layers.test(lt.layers)){const Pt=Tt.side;Tt.side=zs,Tt.needsUpdate=!0,ln(St,st,lt,At,Tt,Ft),Tt.side=Pt,Tt.needsUpdate=!0,Ie=!0}}Ie===!0&&(I.updateMultisampleRenderTarget(xe),I.updateRenderTargetMipmap(xe)),N.setRenderTarget(he),N.setClearColor($,j),N.toneMapping=pe}function Dn(Ae,Ze,st){const lt=Ze.isScene===!0?Ze.overrideMaterial:null;for(let ot=0,Et=Ae.length;ot<Et;ot++){const he=Ae[ot],pe=he.object,Ie=he.geometry,Le=lt===null?he.material:lt,Ce=he.group;pe.layers.test(st.layers)&&ln(pe,Ze,st,Ie,Le,Ce)}}function ln(Ae,Ze,st,lt,ot,Et){Ae.onBeforeRender(N,Ze,st,lt,ot,Et),Ae.modelViewMatrix.multiplyMatrices(st.matrixWorldInverse,Ae.matrixWorld),Ae.normalMatrix.getNormalMatrix(Ae.modelViewMatrix),ot.onBeforeRender(N,Ze,st,lt,Ae,Et),ot.transparent===!0&&ot.side===pu&&ot.forceSinglePass===!1?(ot.side=zs,ot.needsUpdate=!0,N.renderBufferDirect(st,Ze,lt,ot,Ae,Et),ot.side=Th,ot.needsUpdate=!0,N.renderBufferDirect(st,Ze,lt,ot,Ae,Et),ot.side=pu):N.renderBufferDirect(st,Ze,lt,ot,Ae,Et),Ae.onAfterRender(N,Ze,st,lt,ot,Et)}function mr(Ae,Ze,st){Ze.isScene!==!0&&(Ze=Ne);const lt=te.get(Ae),ot=y.state.lights,Et=y.state.shadowsArray,he=ot.state.version,pe=ee.getParameters(Ae,ot.state,Et,Ze,st),Ie=ee.getProgramCacheKey(pe);let Le=lt.programs;lt.environment=Ae.isMeshStandardMaterial?Ze.environment:null,lt.fog=Ze.fog,lt.envMap=(Ae.isMeshStandardMaterial?me:fe).get(Ae.envMap||lt.environment),Le===void 0&&(Ae.addEventListener("dispose",ze),Le=new Map,lt.programs=Le);let Ce=Le.get(Ie);if(Ce!==void 0){if(lt.currentProgram===Ce&<.lightsStateVersion===he)return Xn(Ae,pe),Ce}else pe.uniforms=ee.getUniforms(Ae),Ae.onBuild(st,pe,N),Ae.onBeforeCompile(pe,N),Ce=ee.acquireProgram(pe,Ie),Le.set(Ie,Ce),lt.uniforms=pe.uniforms;const ut=lt.uniforms;return(!Ae.isShaderMaterial&&!Ae.isRawShaderMaterial||Ae.clipping===!0)&&(ut.clippingPlanes=re.uniform),Xn(Ae,pe),lt.needsLights=Ba(Ae),lt.lightsStateVersion=he,lt.needsLights&&(ut.ambientLightColor.value=ot.state.ambient,ut.lightProbe.value=ot.state.probe,ut.directionalLights.value=ot.state.directional,ut.directionalLightShadows.value=ot.state.directionalShadow,ut.spotLights.value=ot.state.spot,ut.spotLightShadows.value=ot.state.spotShadow,ut.rectAreaLights.value=ot.state.rectArea,ut.ltc_1.value=ot.state.rectAreaLTC1,ut.ltc_2.value=ot.state.rectAreaLTC2,ut.pointLights.value=ot.state.point,ut.pointLightShadows.value=ot.state.pointShadow,ut.hemisphereLights.value=ot.state.hemi,ut.directionalShadowMap.value=ot.state.directionalShadowMap,ut.directionalShadowMatrix.value=ot.state.directionalShadowMatrix,ut.spotShadowMap.value=ot.state.spotShadowMap,ut.spotLightMatrix.value=ot.state.spotLightMatrix,ut.spotLightMap.value=ot.state.spotLightMap,ut.pointShadowMap.value=ot.state.pointShadowMap,ut.pointShadowMatrix.value=ot.state.pointShadowMatrix),lt.currentProgram=Ce,lt.uniformsList=null,Ce}function Fn(Ae){if(Ae.uniformsList===null){const Ze=Ae.currentProgram.getUniforms();Ae.uniformsList=P1.seqWithValue(Ze.seq,Ae.uniforms)}return Ae.uniformsList}function Xn(Ae,Ze){const st=te.get(Ae);st.outputColorSpace=Ze.outputColorSpace,st.batching=Ze.batching,st.instancing=Ze.instancing,st.instancingColor=Ze.instancingColor,st.skinning=Ze.skinning,st.morphTargets=Ze.morphTargets,st.morphNormals=Ze.morphNormals,st.morphColors=Ze.morphColors,st.morphTargetsCount=Ze.morphTargetsCount,st.numClippingPlanes=Ze.numClippingPlanes,st.numIntersection=Ze.numClipIntersection,st.vertexAlphas=Ze.vertexAlphas,st.vertexTangents=Ze.vertexTangents,st.toneMapping=Ze.toneMapping}function bn(Ae,Ze,st,lt,ot){Ze.isScene!==!0&&(Ze=Ne),I.resetTextureUnits();const Et=Ze.fog,he=lt.isMeshStandardMaterial?Ze.environment:null,pe=E===null?N.outputColorSpace:E.isXRRenderTarget===!0?E.texture.colorSpace:Vu,Ie=(lt.isMeshStandardMaterial?me:fe).get(lt.envMap||he),Le=lt.vertexColors===!0&&!!st.attributes.color&&st.attributes.color.itemSize===4,Ce=!!st.attributes.tangent&&(!!lt.normalMap||lt.anisotropy>0),ut=!!st.morphAttributes.position,St=!!st.morphAttributes.normal,At=!!st.morphAttributes.color;let Tt=uh;lt.toneMapped&&(E===null||E.isXRRenderTarget===!0)&&(Tt=N.toneMapping);const Ft=st.morphAttributes.position||st.morphAttributes.normal||st.morphAttributes.color,Pt=Ft!==void 0?Ft.length:0,Nt=te.get(lt),en=y.state.lights;if(se===!0&&(be===!0||Ae!==A)){const nr=Ae===A&<.id===D;re.setState(lt,Ae,nr)}let Ht=!1;lt.version===Nt.__version?(Nt.needsLights&&Nt.lightsStateVersion!==en.state.version||Nt.outputColorSpace!==pe||ot.isBatchedMesh&&Nt.batching===!1||!ot.isBatchedMesh&&Nt.batching===!0||ot.isInstancedMesh&&Nt.instancing===!1||!ot.isInstancedMesh&&Nt.instancing===!0||ot.isSkinnedMesh&&Nt.skinning===!1||!ot.isSkinnedMesh&&Nt.skinning===!0||ot.isInstancedMesh&&Nt.instancingColor===!0&&ot.instanceColor===null||ot.isInstancedMesh&&Nt.instancingColor===!1&&ot.instanceColor!==null||Nt.envMap!==Ie||lt.fog===!0&&Nt.fog!==Et||Nt.numClippingPlanes!==void 0&&(Nt.numClippingPlanes!==re.numPlanes||Nt.numIntersection!==re.numIntersection)||Nt.vertexAlphas!==Le||Nt.vertexTangents!==Ce||Nt.morphTargets!==ut||Nt.morphNormals!==St||Nt.morphColors!==At||Nt.toneMapping!==Tt||Y.isWebGL2===!0&&Nt.morphTargetsCount!==Pt)&&(Ht=!0):(Ht=!0,Nt.__version=lt.version);let dn=Nt.currentProgram;Ht===!0&&(dn=mr(lt,Ze,ot));let cn=!1,Sn=!1,Gt=!1;const sn=dn.getUniforms(),un=Nt.uniforms;if(ce.useProgram(dn.program)&&(cn=!0,Sn=!0,Gt=!0),lt.id!==D&&(D=lt.id,Sn=!0),cn||A!==Ae){sn.setValue(ge,"projectionMatrix",Ae.projectionMatrix),sn.setValue(ge,"viewMatrix",Ae.matrixWorldInverse);const nr=sn.map.cameraPosition;nr!==void 0&&nr.setValue(ge,ie.setFromMatrixPosition(Ae.matrixWorld)),Y.logarithmicDepthBuffer&&sn.setValue(ge,"logDepthBufFC",2/(Math.log(Ae.far+1)/Math.LN2)),(lt.isMeshPhongMaterial||lt.isMeshToonMaterial||lt.isMeshLambertMaterial||lt.isMeshBasicMaterial||lt.isMeshStandardMaterial||lt.isShaderMaterial)&&sn.setValue(ge,"isOrthographic",Ae.isOrthographicCamera===!0),A!==Ae&&(A=Ae,Sn=!0,Gt=!0)}if(ot.isSkinnedMesh){sn.setOptional(ge,ot,"bindMatrix"),sn.setOptional(ge,ot,"bindMatrixInverse");const nr=ot.skeleton;nr&&(Y.floatVertexTextures?(nr.boneTexture===null&&nr.computeBoneTexture(),sn.setValue(ge,"boneTexture",nr.boneTexture,I)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}ot.isBatchedMesh&&(sn.setOptional(ge,ot,"batchingTexture"),sn.setValue(ge,"batchingTexture",ot._matricesTexture,I));const Yt=st.morphAttributes;if((Yt.position!==void 0||Yt.normal!==void 0||Yt.color!==void 0&&Y.isWebGL2===!0)&&Ve.update(ot,st,dn),(Sn||Nt.receiveShadow!==ot.receiveShadow)&&(Nt.receiveShadow=ot.receiveShadow,sn.setValue(ge,"receiveShadow",ot.receiveShadow)),lt.isMeshGouraudMaterial&<.envMap!==null&&(un.envMap.value=Ie,un.flipEnvMap.value=Ie.isCubeTexture&&Ie.isRenderTargetTexture===!1?-1:1),Sn&&(sn.setValue(ge,"toneMappingExposure",N.toneMappingExposure),Nt.needsLights&&wi(un,Gt),Et&<.fog===!0&&le.refreshFogUniforms(un,Et),le.refreshMaterialUniforms(un,lt,V,K,xe),P1.upload(ge,Fn(Nt),un,I)),lt.isShaderMaterial&<.uniformsNeedUpdate===!0&&(P1.upload(ge,Fn(Nt),un,I),lt.uniformsNeedUpdate=!1),lt.isSpriteMaterial&&sn.setValue(ge,"center",ot.center),sn.setValue(ge,"modelViewMatrix",ot.modelViewMatrix),sn.setValue(ge,"normalMatrix",ot.normalMatrix),sn.setValue(ge,"modelMatrix",ot.matrixWorld),lt.isShaderMaterial||lt.isRawShaderMaterial){const nr=lt.uniformsGroups;for(let jn=0,ii=nr.length;jn<ii;jn++)if(Y.isWebGL2){const rr=nr[jn];Se.update(rr,dn),Se.bind(rr,dn)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return dn}function wi(Ae,Ze){Ae.ambientLightColor.needsUpdate=Ze,Ae.lightProbe.needsUpdate=Ze,Ae.directionalLights.needsUpdate=Ze,Ae.directionalLightShadows.needsUpdate=Ze,Ae.pointLights.needsUpdate=Ze,Ae.pointLightShadows.needsUpdate=Ze,Ae.spotLights.needsUpdate=Ze,Ae.spotLightShadows.needsUpdate=Ze,Ae.rectAreaLights.needsUpdate=Ze,Ae.hemisphereLights.needsUpdate=Ze}function Ba(Ae){return Ae.isMeshLambertMaterial||Ae.isMeshToonMaterial||Ae.isMeshPhongMaterial||Ae.isMeshStandardMaterial||Ae.isShadowMaterial||Ae.isShaderMaterial&&Ae.lights===!0}this.getActiveCubeFace=function(){return k},this.getActiveMipmapLevel=function(){return C},this.getRenderTarget=function(){return E},this.setRenderTargetTextures=function(Ae,Ze,st){te.get(Ae.texture).__webglTexture=Ze,te.get(Ae.depthTexture).__webglTexture=st;const lt=te.get(Ae);lt.__hasExternalTextures=!0,lt.__hasExternalTextures&&(lt.__autoAllocateDepthBuffer=st===void 0,lt.__autoAllocateDepthBuffer||G.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),lt.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(Ae,Ze){const st=te.get(Ae);st.__webglFramebuffer=Ze,st.__useDefaultFramebuffer=Ze===void 0},this.setRenderTarget=function(Ae,Ze=0,st=0){E=Ae,k=Ze,C=st;let lt=!0,ot=null,Et=!1,he=!1;if(Ae){const Ie=te.get(Ae);Ie.__useDefaultFramebuffer!==void 0?(ce.bindFramebuffer(ge.FRAMEBUFFER,null),lt=!1):Ie.__webglFramebuffer===void 0?I.setupRenderTarget(Ae):Ie.__hasExternalTextures&&I.rebindTextures(Ae,te.get(Ae.texture).__webglTexture,te.get(Ae.depthTexture).__webglTexture);const Le=Ae.texture;(Le.isData3DTexture||Le.isDataArrayTexture||Le.isCompressedArrayTexture)&&(he=!0);const Ce=te.get(Ae).__webglFramebuffer;Ae.isWebGLCubeRenderTarget?(Array.isArray(Ce[Ze])?ot=Ce[Ze][st]:ot=Ce[Ze],Et=!0):Y.isWebGL2&&Ae.samples>0&&I.useMultisampledRTT(Ae)===!1?ot=te.get(Ae).__webglMultisampledFramebuffer:Array.isArray(Ce)?ot=Ce[st]:ot=Ce,R.copy(Ae.viewport),U.copy(Ae.scissor),F=Ae.scissorTest}else R.copy(ae).multiplyScalar(V).floor(),U.copy(B).multiplyScalar(V).floor(),F=X;if(ce.bindFramebuffer(ge.FRAMEBUFFER,ot)&&Y.drawBuffers&<&&ce.drawBuffers(Ae,ot),ce.viewport(R),ce.scissor(U),ce.setScissorTest(F),Et){const Ie=te.get(Ae.texture);ge.framebufferTexture2D(ge.FRAMEBUFFER,ge.COLOR_ATTACHMENT0,ge.TEXTURE_CUBE_MAP_POSITIVE_X+Ze,Ie.__webglTexture,st)}else if(he){const Ie=te.get(Ae.texture),Le=Ze||0;ge.framebufferTextureLayer(ge.FRAMEBUFFER,ge.COLOR_ATTACHMENT0,Ie.__webglTexture,st||0,Le)}D=-1},this.readRenderTargetPixels=function(Ae,Ze,st,lt,ot,Et,he){if(!(Ae&&Ae.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let pe=te.get(Ae).__webglFramebuffer;if(Ae.isWebGLCubeRenderTarget&&he!==void 0&&(pe=pe[he]),pe){ce.bindFramebuffer(ge.FRAMEBUFFER,pe);try{const Ie=Ae.texture,Le=Ie.format,Ce=Ie.type;if(Le!==Xo&&je.convert(Le)!==ge.getParameter(ge.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const ut=Ce===xy&&(G.has("EXT_color_buffer_half_float")||Y.isWebGL2&&G.has("EXT_color_buffer_float"));if(Ce!==dh&&je.convert(Ce)!==ge.getParameter(ge.IMPLEMENTATION_COLOR_READ_TYPE)&&!(Ce===_u&&(Y.isWebGL2||G.has("OES_texture_float")||G.has("WEBGL_color_buffer_float")))&&!ut){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}Ze>=0&&Ze<=Ae.width-lt&&st>=0&&st<=Ae.height-ot&&ge.readPixels(Ze,st,lt,ot,je.convert(Le),je.convert(Ce),Et)}finally{const Ie=E!==null?te.get(E).__webglFramebuffer:null;ce.bindFramebuffer(ge.FRAMEBUFFER,Ie)}}},this.copyFramebufferToTexture=function(Ae,Ze,st=0){const lt=Math.pow(2,-st),ot=Math.floor(Ze.image.width*lt),Et=Math.floor(Ze.image.height*lt);I.setTexture2D(Ze,0),ge.copyTexSubImage2D(ge.TEXTURE_2D,st,0,0,Ae.x,Ae.y,ot,Et),ce.unbindTexture()},this.copyTextureToTexture=function(Ae,Ze,st,lt=0){const ot=Ze.image.width,Et=Ze.image.height,he=je.convert(st.format),pe=je.convert(st.type);I.setTexture2D(st,0),ge.pixelStorei(ge.UNPACK_FLIP_Y_WEBGL,st.flipY),ge.pixelStorei(ge.UNPACK_PREMULTIPLY_ALPHA_WEBGL,st.premultiplyAlpha),ge.pixelStorei(ge.UNPACK_ALIGNMENT,st.unpackAlignment),Ze.isDataTexture?ge.texSubImage2D(ge.TEXTURE_2D,lt,Ae.x,Ae.y,ot,Et,he,pe,Ze.image.data):Ze.isCompressedTexture?ge.compressedTexSubImage2D(ge.TEXTURE_2D,lt,Ae.x,Ae.y,Ze.mipmaps[0].width,Ze.mipmaps[0].height,he,Ze.mipmaps[0].data):ge.texSubImage2D(ge.TEXTURE_2D,lt,Ae.x,Ae.y,he,pe,Ze.image),lt===0&&st.generateMipmaps&&ge.generateMipmap(ge.TEXTURE_2D),ce.unbindTexture()},this.copyTextureToTexture3D=function(Ae,Ze,st,lt,ot=0){if(N.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const Et=Ae.max.x-Ae.min.x+1,he=Ae.max.y-Ae.min.y+1,pe=Ae.max.z-Ae.min.z+1,Ie=je.convert(lt.format),Le=je.convert(lt.type);let Ce;if(lt.isData3DTexture)I.setTexture3D(lt,0),Ce=ge.TEXTURE_3D;else if(lt.isDataArrayTexture)I.setTexture2DArray(lt,0),Ce=ge.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}ge.pixelStorei(ge.UNPACK_FLIP_Y_WEBGL,lt.flipY),ge.pixelStorei(ge.UNPACK_PREMULTIPLY_ALPHA_WEBGL,lt.premultiplyAlpha),ge.pixelStorei(ge.UNPACK_ALIGNMENT,lt.unpackAlignment);const ut=ge.getParameter(ge.UNPACK_ROW_LENGTH),St=ge.getParameter(ge.UNPACK_IMAGE_HEIGHT),At=ge.getParameter(ge.UNPACK_SKIP_PIXELS),Tt=ge.getParameter(ge.UNPACK_SKIP_ROWS),Ft=ge.getParameter(ge.UNPACK_SKIP_IMAGES),Pt=st.isCompressedTexture?st.mipmaps[0]:st.image;ge.pixelStorei(ge.UNPACK_ROW_LENGTH,Pt.width),ge.pixelStorei(ge.UNPACK_IMAGE_HEIGHT,Pt.height),ge.pixelStorei(ge.UNPACK_SKIP_PIXELS,Ae.min.x),ge.pixelStorei(ge.UNPACK_SKIP_ROWS,Ae.min.y),ge.pixelStorei(ge.UNPACK_SKIP_IMAGES,Ae.min.z),st.isDataTexture||st.isData3DTexture?ge.texSubImage3D(Ce,ot,Ze.x,Ze.y,Ze.z,Et,he,pe,Ie,Le,Pt.data):st.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),ge.compressedTexSubImage3D(Ce,ot,Ze.x,Ze.y,Ze.z,Et,he,pe,Ie,Pt.data)):ge.texSubImage3D(Ce,ot,Ze.x,Ze.y,Ze.z,Et,he,pe,Ie,Le,Pt),ge.pixelStorei(ge.UNPACK_ROW_LENGTH,ut),ge.pixelStorei(ge.UNPACK_IMAGE_HEIGHT,St),ge.pixelStorei(ge.UNPACK_SKIP_PIXELS,At),ge.pixelStorei(ge.UNPACK_SKIP_ROWS,Tt),ge.pixelStorei(ge.UNPACK_SKIP_IMAGES,Ft),ot===0&<.generateMipmaps&&ge.generateMipmap(Ce),ce.unbindTexture()},this.initTexture=function(Ae){Ae.isCubeTexture?I.setTextureCube(Ae,0):Ae.isData3DTexture?I.setTexture3D(Ae,0):Ae.isDataArrayTexture||Ae.isCompressedArrayTexture?I.setTexture2DArray(Ae,0):I.setTexture2D(Ae,0),ce.unbindTexture()},this.resetState=function(){k=0,C=0,E=null,ce.reset(),Be.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return cc}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const n=this.getContext();n.drawingBufferColorSpace=e===aL?"display-p3":"srgb",n.unpackColorSpace=Er.workingColorSpace===y2?"display-p3":"srgb"}get physicallyCorrectLights(){return console.warn("THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),!this.useLegacyLights}set physicallyCorrectLights(e){console.warn("THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),this.useLegacyLights=!e}get outputEncoding(){return console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace===Ra?Kf:$J}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===Kf?Ra:Vu}get useLegacyLights(){return console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights}set useLegacyLights(e){console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights=e}}class bBe extends SD{}bBe.prototype.isWebGL1Renderer=!0;class dL{constructor(e,n=1,r=1e3){this.isFog=!0,this.name="",this.color=new Zt(e),this.near=n,this.far=r}clone(){return new dL(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class yBe extends ps{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,n){return super.copy(e,n),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const n=super.toJSON(e);return this.fog!==null&&(n.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(n.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(n.object.backgroundIntensity=this.backgroundIntensity),n}}class vBe{constructor(e,n){this.isInterleavedBuffer=!0,this.array=e,this.stride=n,this.count=e!==void 0?e.length/n:0,this.usage=yD,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=Cu()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return console.warn('THREE.InterleavedBuffer: "updateRange" is deprecated and removed in r169. Use "addUpdateRange()" instead.'),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,n){this.updateRanges.push({start:e,count:n})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,n,r){e*=this.stride,r*=n.stride;for(let i=0,a=this.stride;i<a;i++)this.array[e+i]=n.array[r+i];return this}set(e,n=0){return this.array.set(e,n),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Cu()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const n=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),r=new this.constructor(n,this.stride);return r.setUsage(this.usage),r}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Cu()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const ls=new qe;class Jd{constructor(e,n,r,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=n,this.offset=r,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let n=0,r=this.data.count;n<r;n++)ls.fromBufferAttribute(this,n),ls.applyMatrix4(e),this.setXYZ(n,ls.x,ls.y,ls.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)ls.fromBufferAttribute(this,n),ls.applyNormalMatrix(e),this.setXYZ(n,ls.x,ls.y,ls.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)ls.fromBufferAttribute(this,n),ls.transformDirection(e),this.setXYZ(n,ls.x,ls.y,ls.z);return this}setX(e,n){return this.normalized&&(n=kr(n,this.array)),this.data.array[e*this.data.stride+this.offset]=n,this}setY(e,n){return this.normalized&&(n=kr(n,this.array)),this.data.array[e*this.data.stride+this.offset+1]=n,this}setZ(e,n){return this.normalized&&(n=kr(n,this.array)),this.data.array[e*this.data.stride+this.offset+2]=n,this}setW(e,n){return this.normalized&&(n=kr(n,this.array)),this.data.array[e*this.data.stride+this.offset+3]=n,this}getX(e){let n=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(n=ac(n,this.array)),n}getY(e){let n=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(n=ac(n,this.array)),n}getZ(e){let n=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(n=ac(n,this.array)),n}getW(e){let n=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(n=ac(n,this.array)),n}setXY(e,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(n=kr(n,this.array),r=kr(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=kr(n,this.array),r=kr(r,this.array),i=kr(i,this.array)),this.data.array[e+0]=n,this.data.array[e+1]=r,this.data.array[e+2]=i,this}setXYZW(e,n,r,i,a){return e=e*this.data.stride+this.offset,this.normalized&&(n=kr(n,this.array),r=kr(r,this.array),i=kr(i,this.array),a=kr(a,this.array)),this.data.array[e+0]=n,this.data.array[e+1]=r,this.data.array[e+2]=i,this.data.array[e+3]=a,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const n=[];for(let r=0;r<this.count;r++){const i=r*this.data.stride+this.offset;for(let a=0;a<this.itemSize;a++)n.push(this.data.array[i+a])}return new go(new this.array.constructor(n),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new Jd(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const n=[];for(let r=0;r<this.count;r++){const i=r*this.data.stride+this.offset;for(let a=0;a<this.itemSize;a++)n.push(this.data.array[i+a])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:n,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class wBe extends Bs{constructor(e=null,n=1,r=1,i,a,o,l,c,u=Da,d=Da,f,p){super(null,o,l,c,u,d,i,a,f,p),this.isDataTexture=!0,this.image={data:e,width:n,height:r},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}function _Be(t,e){return t.z-e.z}function SBe(t,e){return e.z-t.z}class MBe{constructor(){this.index=0,this.pool=[],this.list=[]}push(e,n){const r=this.pool,i=this.list;this.index>=r.length&&r.push({start:-1,count:-1,z:-1});const a=r[this.index];i.push(a),this.index++,a.start=e.start,a.count=e.count,a.z=n}reset(){this.list.length=0,this.index=0}}const Zp="batchId",Rd=new zr,t7=new zr,NBe=new zr,n7=new zr,JC=new v2,V_=new rl,xf=new hc,Qb=new qe,ej=new MBe,Wa=new Dl,G_=[];function kBe(t,e,n=0){const r=e.itemSize;if(t.isInterleavedBufferAttribute||t.array.constructor!==e.array.constructor){const i=t.count;for(let a=0;a<i;a++)for(let o=0;o<r;o++)e.setComponent(a+n,o,t.getComponent(a,o))}else e.array.set(t.array,n*r);e.needsUpdate=!0}class EBe extends Dl{get maxGeometryCount(){return this._maxGeometryCount}constructor(e,n,r=n*2,i){super(new ns,i),this.isBatchedMesh=!0,this.perObjectFrustumCulled=!0,this.sortObjects=!0,this.boundingBox=null,this.boundingSphere=null,this.customSort=null,this._drawRanges=[],this._reservedRanges=[],this._visibility=[],this._active=[],this._bounds=[],this._maxGeometryCount=e,this._maxVertexCount=n,this._maxIndexCount=r,this._geometryInitialized=!1,this._geometryCount=0,this._multiDrawCounts=new Int32Array(e),this._multiDrawStarts=new Int32Array(e),this._multiDrawCount=0,this._visibilityChanged=!0,this._matricesTexture=null,this._initMatricesTexture()}_initMatricesTexture(){let e=Math.sqrt(this._maxGeometryCount*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const n=new Float32Array(e*e*4),r=new wBe(n,e,e,Xo,_u);this._matricesTexture=r}_initializeGeometry(e){const n=this.geometry,r=this._maxVertexCount,i=this._maxGeometryCount,a=this._maxIndexCount;if(this._geometryInitialized===!1){for(const l in e.attributes){const c=e.getAttribute(l),{array:u,itemSize:d,normalized:f}=c,p=new u.constructor(r*d),m=new c.constructor(p,d,f);m.setUsage(c.usage),n.setAttribute(l,m)}if(e.getIndex()!==null){const l=r>65536?new Uint32Array(a):new Uint16Array(a);n.setIndex(new go(l,1))}const o=i>65536?new Uint32Array(r):new Uint16Array(r);n.setAttribute(Zp,new go(o,1)),this._geometryInitialized=!0}}_validateGeometry(e){if(e.getAttribute(Zp))throw new Error(`BatchedMesh: Geometry cannot use attribute "${Zp}"`);const n=this.geometry;if(!!e.getIndex()!=!!n.getIndex())throw new Error('BatchedMesh: All geometries must consistently have "index".');for(const r in n.attributes){if(r===Zp)continue;if(!e.hasAttribute(r))throw new Error(`BatchedMesh: Added geometry missing "${r}". All geometries must have consistent attributes.`);const i=e.getAttribute(r),a=n.getAttribute(r);if(i.itemSize!==a.itemSize||i.normalized!==a.normalized)throw new Error("BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new rl);const e=this._geometryCount,n=this.boundingBox,r=this._active;n.makeEmpty();for(let i=0;i<e;i++)r[i]!==!1&&(this.getMatrixAt(i,Rd),this.getBoundingBoxAt(i,V_).applyMatrix4(Rd),n.union(V_))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new hc);const e=this._geometryCount,n=this.boundingSphere,r=this._active;n.makeEmpty();for(let i=0;i<e;i++)r[i]!==!1&&(this.getMatrixAt(i,Rd),this.getBoundingSphereAt(i,xf).applyMatrix4(Rd),n.union(xf))}addGeometry(e,n=-1,r=-1){if(this._initializeGeometry(e),this._validateGeometry(e),this._geometryCount>=this._maxGeometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");const i={vertexStart:-1,vertexCount:-1,indexStart:-1,indexCount:-1};let a=null;const o=this._reservedRanges,l=this._drawRanges,c=this._bounds;this._geometryCount!==0&&(a=o[o.length-1]),n===-1?i.vertexCount=e.getAttribute("position").count:i.vertexCount=n,a===null?i.vertexStart=0:i.vertexStart=a.vertexStart+a.vertexCount;const u=e.getIndex(),d=u!==null;if(d&&(r===-1?i.indexCount=u.count:i.indexCount=r,a===null?i.indexStart=0:i.indexStart=a.indexStart+a.indexCount),i.indexStart!==-1&&i.indexStart+i.indexCount>this._maxIndexCount||i.vertexStart+i.vertexCount>this._maxVertexCount)throw new Error("BatchedMesh: Reserved space request exceeds the maximum buffer size.");const f=this._visibility,p=this._active,m=this._matricesTexture,x=this._matricesTexture.image.data;f.push(!0),p.push(!0);const b=this._geometryCount;this._geometryCount++,NBe.toArray(x,b*16),m.needsUpdate=!0,o.push(i),l.push({start:d?i.indexStart:i.vertexStart,count:-1}),c.push({boxInitialized:!1,box:new rl,sphereInitialized:!1,sphere:new hc});const y=this.geometry.getAttribute(Zp);for(let v=0;v<i.vertexCount;v++)y.setX(i.vertexStart+v,b);return y.needsUpdate=!0,this.setGeometryAt(b,e),b}setGeometryAt(e,n){if(e>=this._geometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");this._validateGeometry(n);const r=this.geometry,i=r.getIndex()!==null,a=r.getIndex(),o=n.getIndex(),l=this._reservedRanges[e];if(i&&o.count>l.indexCount||n.attributes.position.count>l.vertexCount)throw new Error("BatchedMesh: Reserved space not large enough for provided geometry.");const c=l.vertexStart,u=l.vertexCount;for(const m in r.attributes){if(m===Zp)continue;const x=n.getAttribute(m),b=r.getAttribute(m);kBe(x,b,c);const y=x.itemSize;for(let v=x.count,S=u;v<S;v++){const N=c+v;for(let T=0;T<y;T++)b.setComponent(N,T,0)}b.needsUpdate=!0}if(i){const m=l.indexStart;for(let x=0;x<o.count;x++)a.setX(m+x,c+o.getX(x));for(let x=o.count,b=l.indexCount;x<b;x++)a.setX(m+x,c);a.needsUpdate=!0}const d=this._bounds[e];n.boundingBox!==null?(d.box.copy(n.boundingBox),d.boxInitialized=!0):d.boxInitialized=!1,n.boundingSphere!==null?(d.sphere.copy(n.boundingSphere),d.sphereInitialized=!0):d.sphereInitialized=!1;const f=this._drawRanges[e],p=n.getAttribute("position");return f.count=i?o.count:p.count,this._visibilityChanged=!0,e}deleteGeometry(e){const n=this._active;return e>=n.length||n[e]===!1?this:(n[e]=!1,this._visibilityChanged=!0,this)}getBoundingBoxAt(e,n){if(this._active[e]===!1)return this;const i=this._bounds[e],a=i.box,o=this.geometry;if(i.boxInitialized===!1){a.makeEmpty();const l=o.index,c=o.attributes.position,u=this._drawRanges[e];for(let d=u.start,f=u.start+u.count;d<f;d++){let p=d;l&&(p=l.getX(p)),a.expandByPoint(Qb.fromBufferAttribute(c,p))}i.boxInitialized=!0}return n.copy(a),n}getBoundingSphereAt(e,n){if(this._active[e]===!1)return this;const i=this._bounds[e],a=i.sphere,o=this.geometry;if(i.sphereInitialized===!1){a.makeEmpty(),this.getBoundingBoxAt(e,V_),V_.getCenter(a.center);const l=o.index,c=o.attributes.position,u=this._drawRanges[e];let d=0;for(let f=u.start,p=u.start+u.count;f<p;f++){let m=f;l&&(m=l.getX(m)),Qb.fromBufferAttribute(c,m),d=Math.max(d,a.center.distanceToSquared(Qb))}a.radius=Math.sqrt(d),i.sphereInitialized=!0}return n.copy(a),n}setMatrixAt(e,n){const r=this._active,i=this._matricesTexture,a=this._matricesTexture.image.data,o=this._geometryCount;return e>=o||r[e]===!1?this:(n.toArray(a,e*16),i.needsUpdate=!0,this)}getMatrixAt(e,n){const r=this._active,i=this._matricesTexture.image.data,a=this._geometryCount;return e>=a||r[e]===!1?null:n.fromArray(i,e*16)}setVisibleAt(e,n){const r=this._visibility,i=this._active,a=this._geometryCount;return e>=a||i[e]===!1||r[e]===n?this:(r[e]=n,this._visibilityChanged=!0,this)}getVisibleAt(e){const n=this._visibility,r=this._active,i=this._geometryCount;return e>=i||r[e]===!1?!1:n[e]}raycast(e,n){const r=this._visibility,i=this._active,a=this._drawRanges,o=this._geometryCount,l=this.matrixWorld,c=this.geometry;Wa.material=this.material,Wa.geometry.index=c.index,Wa.geometry.attributes=c.attributes,Wa.geometry.boundingBox===null&&(Wa.geometry.boundingBox=new rl),Wa.geometry.boundingSphere===null&&(Wa.geometry.boundingSphere=new hc);for(let u=0;u<o;u++){if(!r[u]||!i[u])continue;const d=a[u];Wa.geometry.setDrawRange(d.start,d.count),this.getMatrixAt(u,Wa.matrixWorld).premultiply(l),this.getBoundingBoxAt(u,Wa.geometry.boundingBox),this.getBoundingSphereAt(u,Wa.geometry.boundingSphere),Wa.raycast(e,G_);for(let f=0,p=G_.length;f<p;f++){const m=G_[f];m.object=this,m.batchId=u,n.push(m)}G_.length=0}Wa.material=null,Wa.geometry.index=null,Wa.geometry.attributes={},Wa.geometry.setDrawRange(0,1/0)}copy(e){return super.copy(e),this.geometry=e.geometry.clone(),this.perObjectFrustumCulled=e.perObjectFrustumCulled,this.sortObjects=e.sortObjects,this.boundingBox=e.boundingBox!==null?e.boundingBox.clone():null,this.boundingSphere=e.boundingSphere!==null?e.boundingSphere.clone():null,this._drawRanges=e._drawRanges.map(n=>({...n})),this._reservedRanges=e._reservedRanges.map(n=>({...n})),this._visibility=e._visibility.slice(),this._active=e._active.slice(),this._bounds=e._bounds.map(n=>({boxInitialized:n.boxInitialized,box:n.box.clone(),sphereInitialized:n.sphereInitialized,sphere:n.sphere.clone()})),this._maxGeometryCount=e._maxGeometryCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._geometryCount=e._geometryCount,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.slice(),this}dispose(){return this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this}onBeforeRender(e,n,r,i,a){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const o=i.getIndex(),l=o===null?1:o.array.BYTES_PER_ELEMENT,c=this._visibility,u=this._multiDrawStarts,d=this._multiDrawCounts,f=this._drawRanges,p=this.perObjectFrustumCulled;p&&(n7.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse).multiply(this.matrixWorld),JC.setFromProjectionMatrix(n7,e.isWebGPURenderer?by:cc));let m=0;if(this.sortObjects){t7.copy(this.matrixWorld).invert(),Qb.setFromMatrixPosition(r.matrixWorld).applyMatrix4(t7);for(let y=0,v=c.length;y<v;y++)if(c[y]){this.getMatrixAt(y,Rd),this.getBoundingSphereAt(y,xf).applyMatrix4(Rd);let S=!1;if(p&&(S=!JC.intersectsSphere(xf)),!S){const N=Qb.distanceTo(xf.center);ej.push(f[y],N)}}const x=ej.list,b=this.customSort;b===null?x.sort(a.transparent?SBe:_Be):b.call(this,x,r);for(let y=0,v=x.length;y<v;y++){const S=x[y];u[m]=S.start*l,d[m]=S.count,m++}ej.reset()}else for(let x=0,b=c.length;x<b;x++)if(c[x]){let y=!1;if(p&&(this.getMatrixAt(x,Rd),this.getBoundingSphereAt(x,xf).applyMatrix4(Rd),y=!JC.intersectsSphere(xf)),!y){const v=f[x];u[m]=v.start*l,d[m]=v.count,m++}}this._multiDrawCount=m,this._visibilityChanged=!1}onBeforeShadow(e,n,r,i,a,o){this.onBeforeRender(e,null,i,a,o)}}class pv extends Dx{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Zt(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const r7=new qe,i7=new qe,a7=new zr,tj=new oL,q_=new hc;class TBe extends ps{constructor(e=new ns,n=new pv){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=n,this.updateMorphTargets()}copy(e,n){return super.copy(e,n),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const n=e.attributes.position,r=[0];for(let i=1,a=n.count;i<a;i++)r7.fromBufferAttribute(n,i-1),i7.fromBufferAttribute(n,i),r[i]=r[i-1],r[i]+=r7.distanceTo(i7);e.setAttribute("lineDistance",new Ti(r,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,n){const r=this.geometry,i=this.matrixWorld,a=e.params.Line.threshold,o=r.drawRange;if(r.boundingSphere===null&&r.computeBoundingSphere(),q_.copy(r.boundingSphere),q_.applyMatrix4(i),q_.radius+=a,e.ray.intersectsSphere(q_)===!1)return;a7.copy(i).invert(),tj.copy(e.ray).applyMatrix4(a7);const l=a/((this.scale.x+this.scale.y+this.scale.z)/3),c=l*l,u=new qe,d=new qe,f=new qe,p=new qe,m=this.isLineSegments?2:1,x=r.index,y=r.attributes.position;if(x!==null){const v=Math.max(0,o.start),S=Math.min(x.count,o.start+o.count);for(let N=v,T=S-1;N<T;N+=m){const k=x.getX(N),C=x.getX(N+1);if(u.fromBufferAttribute(y,k),d.fromBufferAttribute(y,C),tj.distanceSqToSegment(u,d,p,f)>c)continue;p.applyMatrix4(this.matrixWorld);const D=e.ray.origin.distanceTo(p);D<e.near||D>e.far||n.push({distance:D,point:f.clone().applyMatrix4(this.matrixWorld),index:N,face:null,faceIndex:null,object:this})}}else{const v=Math.max(0,o.start),S=Math.min(y.count,o.start+o.count);for(let N=v,T=S-1;N<T;N+=m){if(u.fromBufferAttribute(y,N),d.fromBufferAttribute(y,N+1),tj.distanceSqToSegment(u,d,p,f)>c)continue;p.applyMatrix4(this.matrixWorld);const C=e.ray.origin.distanceTo(p);C<e.near||C>e.far||n.push({distance:C,point:f.clone().applyMatrix4(this.matrixWorld),index: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 a=0,o=i.length;a<o;a++){const l=i[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[l]=a}}}}}const s7=new qe,o7=new qe;class _2 extends TBe{constructor(e,n){super(e,n),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const n=e.attributes.position,r=[];for(let i=0,a=n.count;i<a;i+=2)s7.fromBufferAttribute(n,i),o7.fromBufferAttribute(n,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+s7.distanceTo(o7);e.setAttribute("lineDistance",new Ti(r,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class ABe extends ns{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const n=[],r=new Set,i=new qe,a=new qe;if(e.index!==null){const o=e.attributes.position,l=e.index;let c=e.groups;c.length===0&&(c=[{start:0,count:l.count,materialIndex:0}]);for(let u=0,d=c.length;u<d;++u){const f=c[u],p=f.start,m=f.count;for(let x=p,b=p+m;x<b;x+=3)for(let y=0;y<3;y++){const v=l.getX(x+y),S=l.getX(x+(y+1)%3);i.fromBufferAttribute(o,v),a.fromBufferAttribute(o,S),l7(i,a,r)===!0&&(n.push(i.x,i.y,i.z),n.push(a.x,a.y,a.z))}}}else{const o=e.attributes.position;for(let l=0,c=o.count/3;l<c;l++)for(let u=0;u<3;u++){const d=3*l+u,f=3*l+(u+1)%3;i.fromBufferAttribute(o,d),a.fromBufferAttribute(o,f),l7(i,a,r)===!0&&(n.push(i.x,i.y,i.z),n.push(a.x,a.y,a.z))}}this.setAttribute("position",new Ti(n,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function l7(t,e,n){const r=`${t.x},${t.y},${t.z}-${e.x},${e.y},${e.z}`,i=`${e.x},${e.y},${e.z}-${t.x},${t.y},${t.z}`;return n.has(r)===!0||n.has(i)===!0?!1:(n.add(r),n.add(i),!0)}class CBe extends Dx{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Zt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Zt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=VJ,this.normalScale=new xn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=rL,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class jBe extends pv{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}class hee extends ps{constructor(e,n=1){super(),this.isLight=!0,this.type="Light",this.color=new Zt(e),this.intensity=n}dispose(){}copy(e,n){return super.copy(e,n),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const n=super.toJSON(e);return n.object.color=this.color.getHex(),n.object.intensity=this.intensity,this.groundColor!==void 0&&(n.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(n.object.distance=this.distance),this.angle!==void 0&&(n.object.angle=this.angle),this.decay!==void 0&&(n.object.decay=this.decay),this.penumbra!==void 0&&(n.object.penumbra=this.penumbra),this.shadow!==void 0&&(n.object.shadow=this.shadow.toJSON()),n}}const nj=new zr,c7=new qe,u7=new qe;class PBe{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new xn(512,512),this.map=null,this.mapPass=null,this.matrix=new zr,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new v2,this._frameExtents=new xn(1,1),this._viewportCount=1,this._viewports=[new Cr(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const n=this.camera,r=this.matrix;c7.setFromMatrixPosition(e.matrixWorld),n.position.copy(c7),u7.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(u7),n.updateMatrixWorld(),nj.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(nj),r.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),r.multiply(nj)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}const d7=new zr,Zb=new qe,rj=new qe;class DBe extends PBe{constructor(){super(new oo(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new xn(4,2),this._viewportCount=6,this._viewports=[new Cr(2,1,1,1),new Cr(0,1,1,1),new Cr(3,1,1,1),new Cr(1,1,1,1),new Cr(3,0,1,1),new Cr(1,0,1,1)],this._cubeDirections=[new qe(1,0,0),new qe(-1,0,0),new qe(0,0,1),new qe(0,0,-1),new qe(0,1,0),new qe(0,-1,0)],this._cubeUps=[new qe(0,1,0),new qe(0,1,0),new qe(0,1,0),new qe(0,1,0),new qe(0,0,1),new qe(0,0,-1)]}updateMatrices(e,n=0){const r=this.camera,i=this.matrix,a=e.distance||r.far;a!==r.far&&(r.far=a,r.updateProjectionMatrix()),Zb.setFromMatrixPosition(e.matrixWorld),r.position.copy(Zb),rj.copy(r.position),rj.add(this._cubeDirections[n]),r.up.copy(this._cubeUps[n]),r.lookAt(rj),r.updateMatrixWorld(),i.makeTranslation(-Zb.x,-Zb.y,-Zb.z),d7.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),this._frustum.setFromProjectionMatrix(d7)}}class RBe extends hee{constructor(e,n,r=0,i=2){super(e,n),this.isPointLight=!0,this.type="PointLight",this.distance=r,this.decay=i,this.shadow=new DBe}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 OBe extends hee{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}}class LBe extends ns{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){const e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}}class MD extends vBe{constructor(e,n,r=1){super(e,n),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){const n=super.clone(e);return n.meshPerAttribute=this.meshPerAttribute,n}toJSON(e){const n=super.toJSON(e);return n.isInstancedInterleavedBuffer=!0,n.meshPerAttribute=this.meshPerAttribute,n}}class h7{constructor(e=1,n=0,r=0){return this.radius=e,this.phi=n,this.theta=r,this}set(e,n,r){return this.radius=e,this.phi=n,this.theta=r,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,n,r){return this.radius=Math.sqrt(e*e+n*n+r*r),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,r),this.phi=Math.acos(Oa(n/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}const f7=new qe,W_=new qe;class FBe{constructor(e=new qe,n=new qe){this.start=e,this.end=n}set(e,n){return this.start.copy(e),this.end.copy(n),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,n){return this.delta(n).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,n){f7.subVectors(e,this.start),W_.subVectors(this.end,this.start);const r=W_.dot(W_);let a=W_.dot(f7)/r;return n&&(a=Oa(a,0,1)),a}closestPointToPoint(e,n,r){const i=this.closestPointToPointParameter(e,n);return this.delta(r).multiplyScalar(i).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}class IBe extends _2{constructor(e=1){const n=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],r=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],i=new ns;i.setAttribute("position",new Ti(n,3)),i.setAttribute("color",new Ti(r,3));const a=new pv({vertexColors:!0,toneMapped:!1});super(i,a),this.type="AxesHelper"}setColors(e,n,r){const i=new Zt,a=this.geometry.attributes.color.array;return i.set(e),i.toArray(a,0),i.toArray(a,3),i.set(n),i.toArray(a,6),i.toArray(a,9),i.set(r),i.toArray(a,12),i.toArray(a,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:x2}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=x2);class fc{constructor(e,n,r,i,a="div"){this.parent=e,this.object=n,this.property=r,this._disabled=!1,this._hidden=!1,this.initialValue=this.getValue(),this.domElement=document.createElement(a),this.domElement.classList.add("controller"),this.domElement.classList.add(i),this.$name=document.createElement("div"),this.$name.classList.add("name"),fc.nextNameID=fc.nextNameID||0,this.$name.id=`lil-gui-name-${++fc.nextNameID}`,this.$widget=document.createElement("div"),this.$widget.classList.add("widget"),this.$disable=this.$widget,this.domElement.appendChild(this.$name),this.domElement.appendChild(this.$widget),this.domElement.addEventListener("keydown",o=>o.stopPropagation()),this.domElement.addEventListener("keyup",o=>o.stopPropagation()),this.parent.children.push(this),this.parent.controllers.push(this),this.parent.$children.appendChild(this.domElement),this._listenCallback=this._listenCallback.bind(this),this.name(r)}name(e){return this._name=e,this.$name.textContent=e,this}onChange(e){return this._onChange=e,this}_callOnChange(){this.parent._callOnChange(this),this._onChange!==void 0&&this._onChange.call(this,this.getValue()),this._changed=!0}onFinishChange(e){return this._onFinishChange=e,this}_callOnFinishChange(){this._changed&&(this.parent._callOnFinishChange(this),this._onFinishChange!==void 0&&this._onFinishChange.call(this,this.getValue())),this._changed=!1}reset(){return this.setValue(this.initialValue),this._callOnFinishChange(),this}enable(e=!0){return this.disable(!e)}disable(e=!0){return e===this._disabled?this:(this._disabled=e,this.domElement.classList.toggle("disabled",e),this.$disable.toggleAttribute("disabled",e),this)}show(e=!0){return this._hidden=!e,this.domElement.style.display=this._hidden?"none":"",this}hide(){return this.show(!1)}options(e){const n=this.parent.add(this.object,this.property,e);return n.name(this._name),this.destroy(),n}min(e){return this}max(e){return this}step(e){return this}decimals(e){return this}listen(e=!0){return this._listening=e,this._listenCallbackID!==void 0&&(cancelAnimationFrame(this._listenCallbackID),this._listenCallbackID=void 0),this._listening&&this._listenCallback(),this}_listenCallback(){this._listenCallbackID=requestAnimationFrame(this._listenCallback);const e=this.save();e!==this._listenPrevValue&&this.updateDisplay(),this._listenPrevValue=e}getValue(){return this.object[this.property]}setValue(e){return this.getValue()!==e&&(this.object[this.property]=e,this._callOnChange(),this.updateDisplay()),this}updateDisplay(){return this}load(e){return this.setValue(e),this._callOnFinishChange(),this}save(){return this.getValue()}destroy(){this.listen(!1),this.parent.children.splice(this.parent.children.indexOf(this),1),this.parent.controllers.splice(this.parent.controllers.indexOf(this),1),this.parent.$children.removeChild(this.domElement)}}class UBe extends fc{constructor(e,n,r){super(e,n,r,"boolean","label"),this.$input=document.createElement("input"),this.$input.setAttribute("type","checkbox"),this.$input.setAttribute("aria-labelledby",this.$name.id),this.$widget.appendChild(this.$input),this.$input.addEventListener("change",()=>{this.setValue(this.$input.checked),this._callOnFinishChange()}),this.$disable=this.$input,this.updateDisplay()}updateDisplay(){return this.$input.checked=this.getValue(),this}}function ND(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 zBe={isPrimitive:!0,match:t=>typeof t=="string",fromHexString:ND,toHexString:ND},vy={isPrimitive:!0,match:t=>typeof t=="number",fromHexString:t=>parseInt(t.substring(1),16),toHexString:t=>"#"+t.toString(16).padStart(6,0)},BBe={isPrimitive:!1,match:t=>Array.isArray(t),fromHexString(t,e,n=1){const r=vy.fromHexString(t);e[0]=(r>>16&255)/255*n,e[1]=(r>>8&255)/255*n,e[2]=(r&255)/255*n},toHexString([t,e,n],r=1){r=255/r;const i=t*r<<16^e*r<<8^n*r<<0;return vy.toHexString(i)}},HBe={isPrimitive:!1,match:t=>Object(t)===t,fromHexString(t,e,n=1){const r=vy.fromHexString(t);e.r=(r>>16&255)/255*n,e.g=(r>>8&255)/255*n,e.b=(r&255)/255*n},toHexString({r:t,g:e,b:n},r=1){r=255/r;const i=t*r<<16^e*r<<8^n*r<<0;return vy.toHexString(i)}},$Be=[zBe,vy,BBe,HBe];function VBe(t){return $Be.find(e=>e.match(t))}class GBe extends fc{constructor(e,n,r,i){super(e,n,r,"color"),this.$input=document.createElement("input"),this.$input.setAttribute("type","color"),this.$input.setAttribute("tabindex",-1),this.$input.setAttribute("aria-labelledby",this.$name.id),this.$text=document.createElement("input"),this.$text.setAttribute("type","text"),this.$text.setAttribute("spellcheck","false"),this.$text.setAttribute("aria-labelledby",this.$name.id),this.$display=document.createElement("div"),this.$display.classList.add("display"),this.$display.appendChild(this.$input),this.$widget.appendChild(this.$display),this.$widget.appendChild(this.$text),this._format=VBe(this.initialValue),this._rgbScale=i,this._initialValueHexString=this.save(),this._textFocused=!1,this.$input.addEventListener("input",()=>{this._setValueFromHexString(this.$input.value)}),this.$input.addEventListener("blur",()=>{this._callOnFinishChange()}),this.$text.addEventListener("input",()=>{const a=ND(this.$text.value);a&&this._setValueFromHexString(a)}),this.$text.addEventListener("focus",()=>{this._textFocused=!0,this.$text.select()}),this.$text.addEventListener("blur",()=>{this._textFocused=!1,this.updateDisplay(),this._callOnFinishChange()}),this.$disable=this.$text,this.updateDisplay()}reset(){return this._setValueFromHexString(this._initialValueHexString),this}_setValueFromHexString(e){if(this._format.isPrimitive){const n=this._format.fromHexString(e);this.setValue(n)}else this._format.fromHexString(e,this.getValue(),this._rgbScale),this._callOnChange(),this.updateDisplay()}save(){return this._format.toHexString(this.getValue(),this._rgbScale)}load(e){return this._setValueFromHexString(e),this._callOnFinishChange(),this}updateDisplay(){return this.$input.value=this._format.toHexString(this.getValue(),this._rgbScale),this._textFocused||(this.$text.value=this.$input.value.substring(1)),this.$display.style.backgroundColor=this.$input.value,this}}class ij extends fc{constructor(e,n,r){super(e,n,r,"function"),this.$button=document.createElement("button"),this.$button.appendChild(this.$name),this.$widget.appendChild(this.$button),this.$button.addEventListener("click",i=>{i.preventDefault(),this.getValue().call(this.object),this._callOnChange()}),this.$button.addEventListener("touchstart",()=>{},{passive:!0}),this.$disable=this.$button}}class qBe extends fc{constructor(e,n,r,i,a,o){super(e,n,r,"number"),this._initInput(),this.min(i),this.max(a);const l=o!==void 0;this.step(l?o:this._getImplicitStep(),l),this.updateDisplay()}decimals(e){return this._decimals=e,this.updateDisplay(),this}min(e){return this._min=e,this._onUpdateMinMax(),this}max(e){return this._max=e,this._onUpdateMinMax(),this}step(e,n=!0){return this._step=e,this._stepExplicit=n,this}updateDisplay(){const e=this.getValue();if(this._hasSlider){let n=(e-this._min)/(this._max-this._min);n=Math.max(0,Math.min(n,1)),this.$fill.style.width=n*100+"%"}return this._inputFocused||(this.$input.value=this._decimals===void 0?e:e.toFixed(this._decimals)),this}_initInput(){this.$input=document.createElement("input"),this.$input.setAttribute("type","text"),this.$input.setAttribute("aria-labelledby",this.$name.id),window.matchMedia("(pointer: coarse)").matches&&(this.$input.setAttribute("type","number"),this.$input.setAttribute("step","any")),this.$widget.appendChild(this.$input),this.$disable=this.$input;const n=()=>{let S=parseFloat(this.$input.value);isNaN(S)||(this._stepExplicit&&(S=this._snap(S)),this.setValue(this._clamp(S)))},r=S=>{const N=parseFloat(this.$input.value);isNaN(N)||(this._snapClampSetValue(N+S),this.$input.value=this.getValue())},i=S=>{S.key==="Enter"&&this.$input.blur(),S.code==="ArrowUp"&&(S.preventDefault(),r(this._step*this._arrowKeyMultiplier(S))),S.code==="ArrowDown"&&(S.preventDefault(),r(this._step*this._arrowKeyMultiplier(S)*-1))},a=S=>{this._inputFocused&&(S.preventDefault(),r(this._step*this._normalizeMouseWheel(S)))};let o=!1,l,c,u,d,f;const p=5,m=S=>{l=S.clientX,c=u=S.clientY,o=!0,d=this.getValue(),f=0,window.addEventListener("mousemove",x),window.addEventListener("mouseup",b)},x=S=>{if(o){const N=S.clientX-l,T=S.clientY-c;Math.abs(T)>p?(S.preventDefault(),this.$input.blur(),o=!1,this._setDraggingStyle(!0,"vertical")):Math.abs(N)>p&&b()}if(!o){const N=S.clientY-u;f-=N*this._step*this._arrowKeyMultiplier(S),d+f>this._max?f=this._max-d:d+f<this._min&&(f=this._min-d),this._snapClampSetValue(d+f)}u=S.clientY},b=()=>{this._setDraggingStyle(!1,"vertical"),this._callOnFinishChange(),window.removeEventListener("mousemove",x),window.removeEventListener("mouseup",b)},y=()=>{this._inputFocused=!0},v=()=>{this._inputFocused=!1,this.updateDisplay(),this._callOnFinishChange()};this.$input.addEventListener("input",n),this.$input.addEventListener("keydown",i),this.$input.addEventListener("wheel",a,{passive:!1}),this.$input.addEventListener("mousedown",m),this.$input.addEventListener("focus",y),this.$input.addEventListener("blur",v)}_initSlider(){this._hasSlider=!0,this.$slider=document.createElement("div"),this.$slider.classList.add("slider"),this.$fill=document.createElement("div"),this.$fill.classList.add("fill"),this.$slider.appendChild(this.$fill),this.$widget.insertBefore(this.$slider,this.$input),this.domElement.classList.add("hasSlider");const e=(v,S,N,T,k)=>(v-S)/(N-S)*(k-T)+T,n=v=>{const S=this.$slider.getBoundingClientRect();let N=e(v,S.left,S.right,this._min,this._max);this._snapClampSetValue(N)},r=v=>{this._setDraggingStyle(!0),n(v.clientX),window.addEventListener("mousemove",i),window.addEventListener("mouseup",a)},i=v=>{n(v.clientX)},a=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("mousemove",i),window.removeEventListener("mouseup",a)};let o=!1,l,c;const u=v=>{v.preventDefault(),this._setDraggingStyle(!0),n(v.touches[0].clientX),o=!1},d=v=>{v.touches.length>1||(this._hasScrollBar?(l=v.touches[0].clientX,c=v.touches[0].clientY,o=!0):u(v),window.addEventListener("touchmove",f,{passive:!1}),window.addEventListener("touchend",p))},f=v=>{if(o){const S=v.touches[0].clientX-l,N=v.touches[0].clientY-c;Math.abs(S)>Math.abs(N)?u(v):(window.removeEventListener("touchmove",f),window.removeEventListener("touchend",p))}else v.preventDefault(),n(v.touches[0].clientX)},p=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("touchmove",f),window.removeEventListener("touchend",p)},m=this._callOnFinishChange.bind(this),x=400;let b;const y=v=>{if(Math.abs(v.deltaX)<Math.abs(v.deltaY)&&this._hasScrollBar)return;v.preventDefault();const N=this._normalizeMouseWheel(v)*this._step;this._snapClampSetValue(this.getValue()+N),this.$input.value=this.getValue(),clearTimeout(b),b=setTimeout(m,x)};this.$slider.addEventListener("mousedown",r),this.$slider.addEventListener("touchstart",d,{passive:!1}),this.$slider.addEventListener("wheel",y,{passive:!1})}_setDraggingStyle(e,n="horizontal"){this.$slider&&this.$slider.classList.toggle("active",e),document.body.classList.toggle("lil-gui-dragging",e),document.body.classList.toggle(`lil-gui-${n}`,e)}_getImplicitStep(){return this._hasMin&&this._hasMax?(this._max-this._min)/1e3:.1}_onUpdateMinMax(){!this._hasSlider&&this._hasMin&&this._hasMax&&(this._stepExplicit||this.step(this._getImplicitStep(),!1),this._initSlider(),this.updateDisplay())}_normalizeMouseWheel(e){let{deltaX:n,deltaY:r}=e;return Math.floor(e.deltaY)!==e.deltaY&&e.wheelDelta&&(n=0,r=-e.wheelDelta/120,r*=this._stepExplicit?1:10),n+-r}_arrowKeyMultiplier(e){let n=this._stepExplicit?1:10;return e.shiftKey?n*=10:e.altKey&&(n/=10),n}_snap(e){const n=Math.round(e/this._step)*this._step;return parseFloat(n.toPrecision(15))}_clamp(e){return e<this._min&&(e=this._min),e>this._max&&(e=this._max),e}_snapClampSetValue(e){this.setValue(this._clamp(this._snap(e)))}get _hasScrollBar(){const e=this.parent.root.$children;return e.scrollHeight>e.clientHeight}get _hasMin(){return this._min!==void 0}get _hasMax(){return this._max!==void 0}}class WBe extends fc{constructor(e,n,r,i){super(e,n,r,"option"),this.$select=document.createElement("select"),this.$select.setAttribute("aria-labelledby",this.$name.id),this.$display=document.createElement("div"),this.$display.classList.add("display"),this.$select.addEventListener("change",()=>{this.setValue(this._values[this.$select.selectedIndex]),this._callOnFinishChange()}),this.$select.addEventListener("focus",()=>{this.$display.classList.add("focus")}),this.$select.addEventListener("blur",()=>{this.$display.classList.remove("focus")}),this.$widget.appendChild(this.$select),this.$widget.appendChild(this.$display),this.$disable=this.$select,this.options(i)}options(e){return this._values=Array.isArray(e)?e:Object.values(e),this._names=Array.isArray(e)?e:Object.keys(e),this.$select.replaceChildren(),this._names.forEach(n=>{const r=document.createElement("option");r.textContent=n,this.$select.appendChild(r)}),this.updateDisplay(),this}updateDisplay(){const e=this.getValue(),n=this._values.indexOf(e);return this.$select.selectedIndex=n,this.$display.textContent=n===-1?e:this._names[n],this}}class KBe extends fc{constructor(e,n,r){super(e,n,r,"string"),this.$input=document.createElement("input"),this.$input.setAttribute("type","text"),this.$input.setAttribute("spellcheck","false"),this.$input.setAttribute("aria-labelledby",this.$name.id),this.$input.addEventListener("input",()=>{this.setValue(this.$input.value)}),this.$input.addEventListener("keydown",i=>{i.code==="Enter"&&this.$input.blur()}),this.$input.addEventListener("blur",()=>{this._callOnFinishChange()}),this.$widget.appendChild(this.$input),this.$disable=this.$input,this.updateDisplay()}updateDisplay(){return this.$input.value=this.getValue(),this}}const XBe=`.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 YBe(t){const e=document.createElement("style");e.innerHTML=t;const n=document.querySelector("head link[rel=stylesheet], head style");n?document.head.insertBefore(e,n):document.head.appendChild(e)}let m7=!1;class iM{constructor({parent:e,autoPlace:n=e===void 0,container:r,width:i,title:a="Controls",closeFolders:o=!1,injectStyles:l=!0,touchStyles:c=!0}={}){if(this.parent=e,this.root=e?e.root:this,this.children=[],this.controllers=[],this.folders=[],this._closed=!1,this._hidden=!1,this.domElement=document.createElement("div"),this.domElement.classList.add("lil-gui"),this.$title=document.createElement("div"),this.$title.classList.add("title"),this.$title.setAttribute("role","button"),this.$title.setAttribute("aria-expanded",!0),this.$title.setAttribute("tabindex",0),this.$title.addEventListener("click",()=>this.openAnimated(this._closed)),this.$title.addEventListener("keydown",u=>{(u.code==="Enter"||u.code==="Space")&&(u.preventDefault(),this.$title.click())}),this.$title.addEventListener("touchstart",()=>{},{passive:!0}),this.$children=document.createElement("div"),this.$children.classList.add("children"),this.domElement.appendChild(this.$title),this.domElement.appendChild(this.$children),this.title(a),this.parent){this.parent.children.push(this),this.parent.folders.push(this),this.parent.$children.appendChild(this.domElement);return}this.domElement.classList.add("root"),c&&this.domElement.classList.add("allow-touch-styles"),!m7&&l&&(YBe(XBe),m7=!0),r?r.appendChild(this.domElement):n&&(this.domElement.classList.add("autoPlace"),document.body.appendChild(this.domElement)),i&&this.domElement.style.setProperty("--width",i+"px"),this._closeFolders=o}add(e,n,r,i,a){if(Object(r)===r)return new WBe(this,e,n,r);const o=e[n];switch(typeof o){case"number":return new qBe(this,e,n,r,i,a);case"boolean":return new UBe(this,e,n);case"string":return new KBe(this,e,n);case"function":return new ij(this,e,n)}console.error(`gui.add failed
- property:`,n,`
- object:`,e,`
- value:`,o)}addColor(e,n,r=1){return new GBe(this,e,n,r)}addFolder(e){const n=new iM({parent:this,title:e});return this.root._closeFolders&&n.close(),n}load(e,n=!0){return e.controllers&&this.controllers.forEach(r=>{r instanceof ij||r._name in e.controllers&&r.load(e.controllers[r._name])}),n&&e.folders&&this.folders.forEach(r=>{r._title in e.folders&&r.load(e.folders[r._title])}),this}save(e=!0){const n={controllers:{},folders:{}};return this.controllers.forEach(r=>{if(!(r instanceof ij)){if(r._name in n.controllers)throw new Error(`Cannot save GUI with duplicate property "${r._name}"`);n.controllers[r._name]=r.save()}}),e&&this.folders.forEach(r=>{if(r._title in n.folders)throw new Error(`Cannot save GUI with duplicate folder "${r._title}"`);n.folders[r._title]=r.save()}),n}open(e=!0){return this._setClosed(!e),this.$title.setAttribute("aria-expanded",!this._closed),this.domElement.classList.toggle("closed",this._closed),this}close(){return this.open(!1)}_setClosed(e){this._closed!==e&&(this._closed=e,this._callOnOpenClose(this))}show(e=!0){return this._hidden=!e,this.domElement.style.display=this._hidden?"none":"",this}hide(){return this.show(!1)}openAnimated(e=!0){return this._setClosed(!e),this.$title.setAttribute("aria-expanded",!this._closed),requestAnimationFrame(()=>{const n=this.$children.clientHeight;this.$children.style.height=n+"px",this.domElement.classList.add("transition");const r=a=>{a.target===this.$children&&(this.$children.style.height="",this.domElement.classList.remove("transition"),this.$children.removeEventListener("transitionend",r))};this.$children.addEventListener("transitionend",r);const i=e?this.$children.scrollHeight:0;this.domElement.classList.toggle("closed",!e),requestAnimationFrame(()=>{this.$children.style.height=i+"px"})}),this}title(e){return this._title=e,this.$title.textContent=e,this}reset(e=!0){return(e?this.controllersRecursive():this.controllers).forEach(r=>r.reset()),this}onChange(e){return this._onChange=e,this}_callOnChange(e){this.parent&&this.parent._callOnChange(e),this._onChange!==void 0&&this._onChange.call(this,{object:e.object,property:e.property,value:e.getValue(),controller:e})}onFinishChange(e){return this._onFinishChange=e,this}_callOnFinishChange(e){this.parent&&this.parent._callOnFinishChange(e),this._onFinishChange!==void 0&&this._onFinishChange.call(this,{object:e.object,property:e.property,value:e.getValue(),controller:e})}onOpenClose(e){return this._onOpenClose=e,this}_callOnOpenClose(e){this.parent&&this.parent._callOnOpenClose(e),this._onOpenClose!==void 0&&this._onOpenClose.call(this,e)}destroy(){this.parent&&(this.parent.children.splice(this.parent.children.indexOf(this),1),this.parent.folders.splice(this.parent.folders.indexOf(this),1)),this.domElement.parentElement&&this.domElement.parentElement.removeChild(this.domElement),Array.from(this.children).forEach(e=>e.destroy())}controllersRecursive(){let e=Array.from(this.controllers);return this.folders.forEach(n=>{e=e.concat(n.controllersRecursive())}),e}foldersRecursive(){let e=Array.from(this.folders);return this.folders.forEach(n=>{e=e.concat(n.foldersRecursive())}),e}}function aj(t,e,n,r){return new(n||(n=Promise))((function(i,a){function o(u){try{c(r.next(u))}catch(d){a(d)}}function l(u){try{c(r.throw(u))}catch(d){a(d)}}function c(u){var d;u.done?i(u.value):(d=u.value,d instanceof n?d:new n((function(f){f(d)}))).then(o,l)}c((r=r.apply(t,[])).next())}))}class hL{constructor(e,n,r,i){this.size=e,this.width=n,this.height=r,this.charLength=i,this.chars=""}static parse(e){const n=e.split(" "),r=n[0],i=r.split("x");return new hL(r,+i[0],+i[1],+n[1])}get src(){return"data:image/jpeg;base64,"+this.chars}get isValid(){return this.chars.length==this.charLength&&/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(this.chars)}}class fL{constructor(e,n,r,i){this.src=e,this.gcode=n,this.params=r,this.comment=i}}class p7 extends fL{constructor(e,n,r,i){super(e,n,r,i),this.params=r}}class Od extends fL{constructor(e,n,r,i){super(e,n,void 0,r),this.toolIndex=i}}class g7{constructor(e,n,r,i=0){this.layer=e,this.commands=n,this.lineNumber=r,this.height=i}}class aM{constructor(e){this.lines=[],this.preamble=new g7(-1,[],0),this.layers=[],this.curZ=0,this.maxZ=0,this.metadata={thumbnails:{}},this.tolerance=0,this.tolerance=e??this.tolerance}parseGCode(e){const n=Array.isArray(e)?e:e.split(`
- `);this.lines=this.lines.concat(n);const r=this.lines2commands(n);this.groupIntoLayers(r);const i=this.parseMetadata(r.filter((a=>a.comment))).thumbnails;for(const[a,o]of Object.entries(i))this.metadata.thumbnails[a]=o;return{layers:this.layers,metadata:this.metadata}}lines2commands(e){return e.map((n=>this.parseCommand(n)))}parseCommand(e,n=!0){var r;const i=e.trim().split(";"),a=i[0],o=n&&i[1]||void 0,l=a.split(/([a-zA-Z])/g).slice(1).map((d=>d.trim())),c=l.length?`${(r=l[0])===null||r===void 0?void 0:r.toLowerCase()}${l[1]}`:"",u=this.parseParams(l.slice(2));switch(c){case"g0":case"g00":case"g1":case"g01":case"g2":case"g02":case"g3":case"g03":return new p7(e,c,u,o);case"t0":return new Od(e,c,o,0);case"t1":return new Od(e,c,o,1);case"t2":return new Od(e,c,o,2);case"t3":return new Od(e,c,o,3);case"t4":return new Od(e,c,o,4);case"t5":return new Od(e,c,o,5);case"t6":return new Od(e,c,o,6);case"t7":return new Od(e,c,o,7);default:return new fL(e,c,u,o)}}parseMove(e){return e.reduce(((n,r)=>{const i=r.charAt(0).toLowerCase();return i!="x"&&i!="y"&&i!="z"&&i!="e"&&i!="r"&&i!="f"&&i!="i"&&i!="j"||(n[i]=parseFloat(r.slice(1))),n}),{})}isAlpha(e){const n=e.charCodeAt(0);return n>=97&&n<=122||n>=65&&n<=90}parseParams(e){return e.reduce(((n,r,i,a)=>{if(i%2==0)return n;let o=a[i-1];return o=o.toLowerCase(),this.isAlpha(o)&&(n[o]=parseFloat(r)),n}),{})}groupIntoLayers(e){var n;for(let r=0;r<e.length;r++){const i=e[r];if(i instanceof p7){const a=i.params;if(a.z&&(this.curZ=a.z),((n=a.e)!==null&&n!==void 0?n:0)>0&&(a.x!=null||a.y!=null)&&Math.abs(this.curZ-(this.maxZ||-1/0))>this.tolerance){const o=Math.abs(this.curZ-this.maxZ);this.maxZ=this.curZ,this.layers.push(new g7(this.layers.length,[],r,o))}}this.maxLayer.commands.push(i)}return this.layers}get maxLayer(){var e;return(e=this.layers[this.layers.length-1])!==null&&e!==void 0?e:this.preamble}parseMetadata(e){const n={};let r;for(const i of e){const a=i.comment;if(!a)continue;const o=a.indexOf("thumbnail begin"),l=a.indexOf("thumbnail end");o>-1?r=hL.parse(a.slice(o+15).trim()):r&&(l==-1?r.chars+=a.trim():(r.isValid&&(n[r.size]=r),r=void 0))}return{thumbnails:n}}}aM.prototype.parseGcode=aM.prototype.parseGCode;const x7={type:"change"},sj={type:"start"},b7={type:"end"},K_=new oL,y7=new Hd,QBe=Math.cos(70*qJ.DEG2RAD);class ZBe extends jm{constructor(e,n){super(),this.object=e,this.domElement=n,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new qe,this.cursor=new qe,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:Rp.ROTATE,MIDDLE:Rp.DOLLY,RIGHT:Rp.PAN},this.touches={ONE:Op.ROTATE,TWO:Op.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this.getPolarAngle=function(){return l.phi},this.getAzimuthalAngle=function(){return l.theta},this.getDistance=function(){return this.object.position.distanceTo(this.target)},this.listenToKeyEvents=function(Y){Y.addEventListener("keydown",Oe),this._domElementKeyEvents=Y},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",Oe),this._domElementKeyEvents=null},this.saveState=function(){r.target0.copy(r.target),r.position0.copy(r.object.position),r.zoom0=r.object.zoom},this.reset=function(){r.target.copy(r.target0),r.object.position.copy(r.position0),r.object.zoom=r.zoom0,r.object.updateProjectionMatrix(),r.dispatchEvent(x7),r.update(),a=i.NONE},this.update=(function(){const Y=new qe,ce=new vm().setFromUnitVectors(e.up,new qe(0,1,0)),q=ce.clone().invert(),te=new qe,I=new vm,fe=new qe,me=2*Math.PI;return function(Ee=null){const z=r.object.position;Y.copy(z).sub(r.target),Y.applyQuaternion(ce),l.setFromVector3(Y),r.autoRotate&&a===i.NONE&&R((function(_e){return _e!==null?2*Math.PI/60*r.autoRotateSpeed*_e:2*Math.PI/60/60*r.autoRotateSpeed})(Ee)),r.enableDamping?(l.theta+=c.theta*r.dampingFactor,l.phi+=c.phi*r.dampingFactor):(l.theta+=c.theta,l.phi+=c.phi);let O=r.minAzimuthAngle,ee=r.maxAzimuthAngle;isFinite(O)&&isFinite(ee)&&(O<-Math.PI?O+=me:O>Math.PI&&(O-=me),ee<-Math.PI?ee+=me:ee>Math.PI&&(ee-=me),l.theta=O<=ee?Math.max(O,Math.min(ee,l.theta)):l.theta>(O+ee)/2?Math.max(O,l.theta):Math.min(ee,l.theta)),l.phi=Math.max(r.minPolarAngle,Math.min(r.maxPolarAngle,l.phi)),l.makeSafe(),r.enableDamping===!0?r.target.addScaledVector(d,r.dampingFactor):r.target.add(d),r.target.sub(r.cursor),r.target.clampLength(r.minTargetRadius,r.maxTargetRadius),r.target.add(r.cursor),r.zoomToCursor&&C||r.object.isOrthographicCamera?l.radius=Q(l.radius):l.radius=Q(l.radius*u),Y.setFromSpherical(l),Y.applyQuaternion(q),z.copy(r.target).add(Y),r.object.lookAt(r.target),r.enableDamping===!0?(c.theta*=1-r.dampingFactor,c.phi*=1-r.dampingFactor,d.multiplyScalar(1-r.dampingFactor)):(c.set(0,0,0),d.set(0,0,0));let le=!1;if(r.zoomToCursor&&C){let _e=null;if(r.object.isPerspectiveCamera){const we=Y.length();_e=Q(we*u);const re=we-_e;r.object.position.addScaledVector(T,re),r.object.updateMatrixWorld()}else if(r.object.isOrthographicCamera){const we=new qe(k.x,k.y,0);we.unproject(r.object),r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom/u)),r.object.updateProjectionMatrix(),le=!0;const re=new qe(k.x,k.y,0);re.unproject(r.object),r.object.position.sub(re).add(we),r.object.updateMatrixWorld(),_e=Y.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),r.zoomToCursor=!1;_e!==null&&(this.screenSpacePanning?r.target.set(0,0,-1).transformDirection(r.object.matrix).multiplyScalar(_e).add(r.object.position):(K_.origin.copy(r.object.position),K_.direction.set(0,0,-1).transformDirection(r.object.matrix),Math.abs(r.object.up.dot(K_.direction))<QBe?e.lookAt(r.target):(y7.setFromNormalAndCoplanarPoint(r.object.up,r.target),K_.intersectPlane(y7,r.target))))}else r.object.isOrthographicCamera&&(r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom/u)),r.object.updateProjectionMatrix(),le=!0);return u=1,C=!1,!!(le||te.distanceToSquared(r.object.position)>o||8*(1-I.dot(r.object.quaternion))>o||fe.distanceToSquared(r.target)>0)&&(r.dispatchEvent(x7),te.copy(r.object.position),I.copy(r.object.quaternion),fe.copy(r.target),!0)}})(),this.dispose=function(){r.domElement.removeEventListener("contextmenu",ge),r.domElement.removeEventListener("pointerdown",de),r.domElement.removeEventListener("pointercancel",ie),r.domElement.removeEventListener("wheel",Ne),r.domElement.removeEventListener("pointermove",Pe),r.domElement.removeEventListener("pointerup",ie),r._domElementKeyEvents!==null&&(r._domElementKeyEvents.removeEventListener("keydown",Oe),r._domElementKeyEvents=null)};const r=this,i={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let a=i.NONE;const o=1e-6,l=new h7,c=new h7;let u=1;const d=new qe,f=new xn,p=new xn,m=new xn,x=new xn,b=new xn,y=new xn,v=new xn,S=new xn,N=new xn,T=new qe,k=new xn;let C=!1;const E=[],D={};function A(){return Math.pow(.95,r.zoomSpeed)}function R(Y){c.theta-=Y}function U(Y){c.phi-=Y}const F=(function(){const Y=new qe;return function(ce,q){Y.setFromMatrixColumn(q,0),Y.multiplyScalar(-ce),d.add(Y)}})(),$=(function(){const Y=new qe;return function(ce,q){r.screenSpacePanning===!0?Y.setFromMatrixColumn(q,1):(Y.setFromMatrixColumn(q,0),Y.crossVectors(r.object.up,Y)),Y.multiplyScalar(ce),d.add(Y)}})(),j=(function(){const Y=new qe;return function(ce,q){const te=r.domElement;if(r.object.isPerspectiveCamera){const I=r.object.position;Y.copy(I).sub(r.target);let fe=Y.length();fe*=Math.tan(r.object.fov/2*Math.PI/180),F(2*ce*fe/te.clientHeight,r.object.matrix),$(2*q*fe/te.clientHeight,r.object.matrix)}else r.object.isOrthographicCamera?(F(ce*(r.object.right-r.object.left)/r.object.zoom/te.clientWidth,r.object.matrix),$(q*(r.object.top-r.object.bottom)/r.object.zoom/te.clientHeight,r.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),r.enablePan=!1)}})();function H(Y){r.object.isPerspectiveCamera||r.object.isOrthographicCamera?u/=Y:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),r.enableZoom=!1)}function K(Y){r.object.isPerspectiveCamera||r.object.isOrthographicCamera?u*=Y:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),r.enableZoom=!1)}function V(Y){if(!r.zoomToCursor)return;C=!0;const ce=r.domElement.getBoundingClientRect(),q=Y.clientX-ce.left,te=Y.clientY-ce.top,I=ce.width,fe=ce.height;k.x=q/I*2-1,k.y=-te/fe*2+1,T.set(k.x,k.y,1).unproject(r.object).sub(r.object.position).normalize()}function Q(Y){return Math.max(r.minDistance,Math.min(r.maxDistance,Y))}function Z(Y){f.set(Y.clientX,Y.clientY)}function ae(Y){x.set(Y.clientX,Y.clientY)}function B(){if(E.length===1)f.set(E[0].pageX,E[0].pageY);else{const Y=.5*(E[0].pageX+E[1].pageX),ce=.5*(E[0].pageY+E[1].pageY);f.set(Y,ce)}}function X(){if(E.length===1)x.set(E[0].pageX,E[0].pageY);else{const Y=.5*(E[0].pageX+E[1].pageX),ce=.5*(E[0].pageY+E[1].pageY);x.set(Y,ce)}}function ne(){const Y=E[0].pageX-E[1].pageX,ce=E[0].pageY-E[1].pageY,q=Math.sqrt(Y*Y+ce*ce);v.set(0,q)}function se(Y){if(E.length==1)p.set(Y.pageX,Y.pageY);else{const q=G(Y),te=.5*(Y.pageX+q.x),I=.5*(Y.pageY+q.y);p.set(te,I)}m.subVectors(p,f).multiplyScalar(r.rotateSpeed);const ce=r.domElement;R(2*Math.PI*m.x/ce.clientHeight),U(2*Math.PI*m.y/ce.clientHeight),f.copy(p)}function be(Y){if(E.length===1)b.set(Y.pageX,Y.pageY);else{const ce=G(Y),q=.5*(Y.pageX+ce.x),te=.5*(Y.pageY+ce.y);b.set(q,te)}y.subVectors(b,x).multiplyScalar(r.panSpeed),j(y.x,y.y),x.copy(b)}function xe(Y){const ce=G(Y),q=Y.pageX-ce.x,te=Y.pageY-ce.y,I=Math.sqrt(q*q+te*te);S.set(0,I),N.set(0,Math.pow(S.y/v.y,r.zoomSpeed)),H(N.y),v.copy(S)}function de(Y){r.enabled!==!1&&(E.length===0&&(r.domElement.setPointerCapture(Y.pointerId),r.domElement.addEventListener("pointermove",Pe),r.domElement.addEventListener("pointerup",ie)),(function(ce){E.push(ce)})(Y),Y.pointerType==="touch"?(function(ce){switch(Ke(ce),E.length){case 1:switch(r.touches.ONE){case Op.ROTATE:if(r.enableRotate===!1)return;B(),a=i.TOUCH_ROTATE;break;case Op.PAN:if(r.enablePan===!1)return;X(),a=i.TOUCH_PAN;break;default:a=i.NONE}break;case 2:switch(r.touches.TWO){case Op.DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;r.enableZoom&&ne(),r.enablePan&&X(),a=i.TOUCH_DOLLY_PAN;break;case Op.DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;r.enableZoom&&ne(),r.enableRotate&&B(),a=i.TOUCH_DOLLY_ROTATE;break;default:a=i.NONE}break;default:a=i.NONE}a!==i.NONE&&r.dispatchEvent(sj)})(Y):(function(ce){let q;switch(ce.button){case 0:q=r.mouseButtons.LEFT;break;case 1:q=r.mouseButtons.MIDDLE;break;case 2:q=r.mouseButtons.RIGHT;break;default:q=-1}switch(q){case Rp.DOLLY:if(r.enableZoom===!1)return;(function(te){V(te),v.set(te.clientX,te.clientY)})(ce),a=i.DOLLY;break;case Rp.ROTATE:if(ce.ctrlKey||ce.metaKey||ce.shiftKey){if(r.enablePan===!1)return;ae(ce),a=i.PAN}else{if(r.enableRotate===!1)return;Z(ce),a=i.ROTATE}break;case Rp.PAN:if(ce.ctrlKey||ce.metaKey||ce.shiftKey){if(r.enableRotate===!1)return;Z(ce),a=i.ROTATE}else{if(r.enablePan===!1)return;ae(ce),a=i.PAN}break;default:a=i.NONE}a!==i.NONE&&r.dispatchEvent(sj)})(Y))}function Pe(Y){r.enabled!==!1&&(Y.pointerType==="touch"?(function(ce){switch(Ke(ce),a){case i.TOUCH_ROTATE:if(r.enableRotate===!1)return;se(ce),r.update();break;case i.TOUCH_PAN:if(r.enablePan===!1)return;be(ce),r.update();break;case i.TOUCH_DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;(function(q){r.enableZoom&&xe(q),r.enablePan&&be(q)})(ce),r.update();break;case i.TOUCH_DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;(function(q){r.enableZoom&&xe(q),r.enableRotate&&se(q)})(ce),r.update();break;default:a=i.NONE}})(Y):(function(ce){switch(a){case i.ROTATE:if(r.enableRotate===!1)return;(function(q){p.set(q.clientX,q.clientY),m.subVectors(p,f).multiplyScalar(r.rotateSpeed);const te=r.domElement;R(2*Math.PI*m.x/te.clientHeight),U(2*Math.PI*m.y/te.clientHeight),f.copy(p),r.update()})(ce);break;case i.DOLLY:if(r.enableZoom===!1)return;(function(q){S.set(q.clientX,q.clientY),N.subVectors(S,v),N.y>0?H(A()):N.y<0&&K(A()),v.copy(S),r.update()})(ce);break;case i.PAN:if(r.enablePan===!1)return;(function(q){b.set(q.clientX,q.clientY),y.subVectors(b,x).multiplyScalar(r.panSpeed),j(y.x,y.y),x.copy(b),r.update()})(ce)}})(Y))}function ie(Y){(function(ce){delete D[ce.pointerId];for(let q=0;q<E.length;q++)if(E[q].pointerId==ce.pointerId)return void E.splice(q,1)})(Y),E.length===0&&(r.domElement.releasePointerCapture(Y.pointerId),r.domElement.removeEventListener("pointermove",Pe),r.domElement.removeEventListener("pointerup",ie)),r.dispatchEvent(b7),a=i.NONE}function Ne(Y){r.enabled!==!1&&r.enableZoom!==!1&&a===i.NONE&&(Y.preventDefault(),r.dispatchEvent(sj),(function(ce){V(ce),ce.deltaY<0?K(A()):ce.deltaY>0&&H(A()),r.update()})(Y),r.dispatchEvent(b7))}function Oe(Y){r.enabled!==!1&&r.enablePan!==!1&&(function(ce){let q=!1;switch(ce.code){case r.keys.UP:ce.ctrlKey||ce.metaKey||ce.shiftKey?U(2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):j(0,r.keyPanSpeed),q=!0;break;case r.keys.BOTTOM:ce.ctrlKey||ce.metaKey||ce.shiftKey?U(-2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):j(0,-r.keyPanSpeed),q=!0;break;case r.keys.LEFT:ce.ctrlKey||ce.metaKey||ce.shiftKey?R(2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):j(r.keyPanSpeed,0),q=!0;break;case r.keys.RIGHT:ce.ctrlKey||ce.metaKey||ce.shiftKey?R(-2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):j(-r.keyPanSpeed,0),q=!0}q&&(ce.preventDefault(),r.update())})(Y)}function ge(Y){r.enabled!==!1&&Y.preventDefault()}function Ke(Y){let ce=D[Y.pointerId];ce===void 0&&(ce=new xn,D[Y.pointerId]=ce),ce.set(Y.pageX,Y.pageY)}function G(Y){const ce=Y.pointerId===E[0].pointerId?E[1]:E[0];return D[ce.pointerId]}r.domElement.addEventListener("contextmenu",ge),r.domElement.addEventListener("pointerdown",de),r.domElement.addEventListener("pointercancel",ie),r.domElement.addEventListener("wheel",Ne,{passive:!1}),this.update()}}Dt.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new xn(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},Rs.line={uniforms:lL.merge([Dt.common,Dt.fog,Dt.line]),vertexShader:`
- #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 fee extends Ah{constructor(e){super({type:"LineMaterial",uniforms:lL.clone(Rs.line.uniforms),vertexShader:Rs.line.vertexShader,fragmentShader:Rs.line.fragmentShader,clipping:!0}),this.isLineMaterial=!0,this.setValues(e)}get color(){return this.uniforms.diffuse.value}set color(e){this.uniforms.diffuse.value=e}get worldUnits(){return"WORLD_UNITS"in this.defines}set worldUnits(e){e===!0?this.defines.WORLD_UNITS="":delete this.defines.WORLD_UNITS}get linewidth(){return this.uniforms.linewidth.value}set linewidth(e){this.uniforms.linewidth&&(this.uniforms.linewidth.value=e)}get dashed(){return"USE_DASH"in this.defines}set dashed(e){e===!0!==this.dashed&&(this.needsUpdate=!0),e===!0?this.defines.USE_DASH="":delete this.defines.USE_DASH}get dashScale(){return this.uniforms.dashScale.value}set dashScale(e){this.uniforms.dashScale.value=e}get dashSize(){return this.uniforms.dashSize.value}set dashSize(e){this.uniforms.dashSize.value=e}get dashOffset(){return this.uniforms.dashOffset.value}set dashOffset(e){this.uniforms.dashOffset.value=e}get gapSize(){return this.uniforms.gapSize.value}set gapSize(e){this.uniforms.gapSize.value=e}get opacity(){return this.uniforms.opacity.value}set opacity(e){this.uniforms&&(this.uniforms.opacity.value=e)}get resolution(){return this.uniforms.resolution.value}set resolution(e){this.uniforms.resolution.value.copy(e)}get alphaToCoverage(){return"USE_ALPHA_TO_COVERAGE"in this.defines}set alphaToCoverage(e){this.defines&&(e===!0!==this.alphaToCoverage&&(this.needsUpdate=!0),e===!0?(this.defines.USE_ALPHA_TO_COVERAGE="",this.extensions.derivatives=!0):(delete this.defines.USE_ALPHA_TO_COVERAGE,this.extensions.derivatives=!1))}}const v7=new rl,X_=new qe;class mee extends LBe{constructor(){super(),this.isLineSegmentsGeometry=!0,this.type="LineSegmentsGeometry",this.setIndex([0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5]),this.setAttribute("position",new Ti([-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],3)),this.setAttribute("uv",new Ti([-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],2))}applyMatrix4(e){const n=this.attributes.instanceStart,r=this.attributes.instanceEnd;return n!==void 0&&(n.applyMatrix4(e),r.applyMatrix4(e),n.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}setPositions(e){let n;e instanceof Float32Array?n=e:Array.isArray(e)&&(n=new Float32Array(e));const r=new MD(n,6,1);return this.setAttribute("instanceStart",new Jd(r,3,0)),this.setAttribute("instanceEnd",new Jd(r,3,3)),this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(e){let n;e instanceof Float32Array?n=e:Array.isArray(e)&&(n=new Float32Array(e));const r=new MD(n,6,1);return this.setAttribute("instanceColorStart",new Jd(r,3,0)),this.setAttribute("instanceColorEnd",new Jd(r,3,3)),this}fromWireframeGeometry(e){return this.setPositions(e.attributes.position.array),this}fromEdgesGeometry(e){return this.setPositions(e.attributes.position.array),this}fromMesh(e){return this.fromWireframeGeometry(new ABe(e.geometry)),this}fromLineSegments(e){const n=e.geometry;return this.setPositions(n.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new rl);const e=this.attributes.instanceStart,n=this.attributes.instanceEnd;e!==void 0&&n!==void 0&&(this.boundingBox.setFromBufferAttribute(e),v7.setFromBufferAttribute(n),this.boundingBox.union(v7))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new hc),this.boundingBox===null&&this.computeBoundingBox();const e=this.attributes.instanceStart,n=this.attributes.instanceEnd;if(e!==void 0&&n!==void 0){const r=this.boundingSphere.center;this.boundingBox.getCenter(r);let i=0;for(let a=0,o=e.count;a<o;a++)X_.fromBufferAttribute(e,a),i=Math.max(i,r.distanceToSquared(X_)),X_.fromBufferAttribute(n,a),i=Math.max(i,r.distanceToSquared(X_));this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error("THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.",this)}}toJSON(){}applyMatrix(e){return console.warn("THREE.LineSegmentsGeometry: applyMatrix() has been renamed to applyMatrix4()."),this.applyMatrix4(e)}}const w7=new qe,_7=new qe,Ta=new Cr,Aa=new Cr,Yl=new Cr,oj=new qe,lj=new zr,Ca=new FBe,S7=new qe,Y_=new rl,Q_=new hc,Ql=new Cr;let Zl,Tf;function M7(t,e,n){return Ql.set(0,0,-e,1).applyMatrix4(t.projectionMatrix),Ql.multiplyScalar(1/Ql.w),Ql.x=Tf/n.width,Ql.y=Tf/n.height,Ql.applyMatrix4(t.projectionMatrixInverse),Ql.multiplyScalar(1/Ql.w),Math.abs(Math.max(Ql.x,Ql.y))}class JBe extends Dl{constructor(e=new mee,n=new fee({color:16777215*Math.random()})){super(e,n),this.isLineSegments2=!0,this.type="LineSegments2"}computeLineDistances(){const e=this.geometry,n=e.attributes.instanceStart,r=e.attributes.instanceEnd,i=new Float32Array(2*n.count);for(let o=0,l=0,c=n.count;o<c;o++,l+=2)w7.fromBufferAttribute(n,o),_7.fromBufferAttribute(r,o),i[l]=l===0?0:i[l-1],i[l+1]=i[l]+w7.distanceTo(_7);const a=new MD(i,2,1);return e.setAttribute("instanceDistanceStart",new Jd(a,1,0)),e.setAttribute("instanceDistanceEnd",new Jd(a,1,1)),this}raycast(e,n){const r=this.material.worldUnits,i=e.camera;i!==null||r||console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.');const a=e.params.Line2!==void 0&&e.params.Line2.threshold||0;Zl=e.ray;const o=this.matrixWorld,l=this.geometry,c=this.material;let u,d;Tf=c.linewidth+a,l.boundingSphere===null&&l.computeBoundingSphere(),Q_.copy(l.boundingSphere).applyMatrix4(o),r?u=.5*Tf:u=M7(i,Math.max(i.near,Q_.distanceToPoint(Zl.origin)),c.resolution),Q_.radius+=u,Zl.intersectsSphere(Q_)!==!1&&(l.boundingBox===null&&l.computeBoundingBox(),Y_.copy(l.boundingBox).applyMatrix4(o),r?d=.5*Tf:d=M7(i,Math.max(i.near,Y_.distanceToPoint(Zl.origin)),c.resolution),Y_.expandByScalar(d),Zl.intersectsBox(Y_)!==!1&&(r?(function(f,p){const m=f.matrixWorld,x=f.geometry,b=x.attributes.instanceStart,y=x.attributes.instanceEnd;for(let v=0,S=Math.min(x.instanceCount,b.count);v<S;v++){Ca.start.fromBufferAttribute(b,v),Ca.end.fromBufferAttribute(y,v),Ca.applyMatrix4(m);const N=new qe,T=new qe;Zl.distanceSqToSegment(Ca.start,Ca.end,T,N),T.distanceTo(N)<.5*Tf&&p.push({point:T,pointOnLine:N,distance:Zl.origin.distanceTo(T),object:f,face:null,faceIndex:v,uv:null,uv1:null})}})(this,n):(function(f,p,m){const x=p.projectionMatrix,b=f.material.resolution,y=f.matrixWorld,v=f.geometry,S=v.attributes.instanceStart,N=v.attributes.instanceEnd,T=Math.min(v.instanceCount,S.count),k=-p.near;Zl.at(1,Yl),Yl.w=1,Yl.applyMatrix4(p.matrixWorldInverse),Yl.applyMatrix4(x),Yl.multiplyScalar(1/Yl.w),Yl.x*=b.x/2,Yl.y*=b.y/2,Yl.z=0,oj.copy(Yl),lj.multiplyMatrices(p.matrixWorldInverse,y);for(let C=0,E=T;C<E;C++){if(Ta.fromBufferAttribute(S,C),Aa.fromBufferAttribute(N,C),Ta.w=1,Aa.w=1,Ta.applyMatrix4(lj),Aa.applyMatrix4(lj),Ta.z>k&&Aa.z>k)continue;if(Ta.z>k){const F=Ta.z-Aa.z,$=(Ta.z-k)/F;Ta.lerp(Aa,$)}else if(Aa.z>k){const F=Aa.z-Ta.z,$=(Aa.z-k)/F;Aa.lerp(Ta,$)}Ta.applyMatrix4(x),Aa.applyMatrix4(x),Ta.multiplyScalar(1/Ta.w),Aa.multiplyScalar(1/Aa.w),Ta.x*=b.x/2,Ta.y*=b.y/2,Aa.x*=b.x/2,Aa.y*=b.y/2,Ca.start.copy(Ta),Ca.start.z=0,Ca.end.copy(Aa),Ca.end.z=0;const D=Ca.closestPointToPointParameter(oj,!0);Ca.at(D,S7);const A=qJ.lerp(Ta.z,Aa.z,D),R=A>=-1&&A<=1,U=oj.distanceTo(S7)<.5*Tf;if(R&&U){Ca.start.fromBufferAttribute(S,C),Ca.end.fromBufferAttribute(N,C),Ca.start.applyMatrix4(y),Ca.end.applyMatrix4(y);const F=new qe,$=new qe;Zl.distanceSqToSegment(Ca.start,Ca.end,$,F),m.push({point:$,pointOnLine:F,distance:Zl.origin.distanceTo($),object:f,face:null,faceIndex:C,uv:null,uv1:null})}}})(this,i,n)))}}class e8e extends _2{constructor(e,n,r,i,a=4473924,o=8947848){a=new Zt(a),o=new Zt(o);const l=Math.round(e/n);r=Math.round(r/i)*i/2;const c=[],u=[];let d=0;for(let p=-1*(e=l*n/2);p<=e;p+=n){c.push(p,0,-1*r,p,0,r);const m=p===0?a:o;m.toArray(u,d),d+=3,m.toArray(u,d),d+=3,m.toArray(u,d),d+=3,m.toArray(u,d),d+=3}for(let p=-1*r;p<=r;p+=i){c.push(-1*e,0,p,e,0,p);const m=p===0?a:o;m.toArray(u,d),d+=3,m.toArray(u,d),d+=3,m.toArray(u,d),d+=3,m.toArray(u,d),d+=3}const f=new ns;f.setAttribute("position",new Ti(c,3)),f.setAttribute("color",new Ti(u,3)),super(f,new pv({vertexColors:!0,toneMapped:!1}))}}function t8e(t,e,n,r){const i=(function(o,l,c){o*=.5,l*=.5,c*=.5;const u=new ns,d=[];return d.push(-o,-l,-c,-o,l,-c,-o,l,-c,o,l,-c,o,l,-c,o,-l,-c,o,-l,-c,-o,-l,-c,-o,-l,c,-o,l,c,-o,l,c,o,l,c,o,l,c,o,-l,c,o,-l,c,-o,-l,c,-o,-l,-c,-o,-l,c,-o,l,-c,-o,l,c,o,l,-c,o,l,c,o,-l,-c,o,-l,c),u.setAttribute("position",new Ti(d,3)),u})(t,e,n),a=new _2(i,new jBe({color:new Zt(r),dashSize:3,gapSize:1}));return a.computeLineDistances(),a}var M0=function(){var t=0,e=document.createElement("div");function n(d){return e.appendChild(d.dom),d}function r(d){for(var f=0;f<e.children.length;f++)e.children[f].style.display=f===d?"block":"none";t=d}e.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",e.addEventListener("click",(function(d){d.preventDefault(),r(++t%e.children.length)}),!1);var i=(performance||Date).now(),a=i,o=0,l=n(new M0.Panel("FPS","#0ff","#002")),c=n(new M0.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var u=n(new M0.Panel("MB","#f08","#201"));return r(0),{REVISION:16,dom:e,addPanel:n,showPanel:r,begin:function(){i=(performance||Date).now()},end:function(){o++;var d=(performance||Date).now();if(c.update(d-i,200),d>=a+1e3&&(l.update(1e3*o/(d-a),100),a=d,o=0,u)){var f=performance.memory;u.update(f.usedJSHeapSize/1048576,f.jsHeapSizeLimit/1048576)}return d},update:function(){i=this.end()},domElement:e,setMode:r}};M0.Panel=function(t,e,n){var r=1/0,i=0,a=Math.round,o=a(window.devicePixelRatio||1),l=80*o,c=48*o,u=3*o,d=2*o,f=3*o,p=15*o,m=74*o,x=30*o,b=document.createElement("canvas");b.width=l,b.height=c,b.style.cssText="width:80px;height:48px";var y=b.getContext("2d");return y.font="bold "+9*o+"px Helvetica,Arial,sans-serif",y.textBaseline="top",y.fillStyle=n,y.fillRect(0,0,l,c),y.fillStyle=e,y.fillText(t,u,d),y.fillRect(f,p,m,x),y.fillStyle=n,y.globalAlpha=.9,y.fillRect(f,p,m,x),{dom:b,update:function(v,S){r=Math.min(r,v),i=Math.max(i,v),y.fillStyle=n,y.globalAlpha=1,y.fillRect(0,0,l,p),y.fillStyle=e,y.fillText(a(v)+" "+t+" ("+a(r)+"-"+a(i)+")",u,d),y.drawImage(b,f+o,p,m-o,x,f,p,m-o,x),y.fillRect(f+m-o,p,o,x),y.fillStyle=n,y.globalAlpha=.9,y.fillRect(f+m-o,p,o,a((1-v/S)*x))}}};var n8e=M0;class N7{constructor(e,n){this.openFolders=[],this.watchedObject=e,this.options=n,this.gui=new iM,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 iM,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 r8e extends ns{constructor(e=[new qe],n=.6,r=.2,i=8){super(),this.type="ExtrusionGeometry",this.parameters={points:e,lineWidth:n,lineHeight:r,radialSegments:i,closed:!1};const a=new qe,o=new qe,l=new xn,c=[],u=[],d=[],f=[];function p(m){const[x,b,y]=(function(v){const S=e[v],N=new qe,T=new qe,k=new qe,C=new qe;N.copy(S).sub(e[v-1]||S).normalize().add((e[v+1]||S).clone().sub(S).normalize()).normalize();let E=Number.MAX_VALUE;const D=Math.abs(N.x),A=Math.abs(N.y),R=Math.abs(N.z);return D<=E&&(E=D,T.set(1,0,0)),A<=E&&(E=A,T.set(0,1,0)),R<=E&&T.set(0,0,1),C.crossVectors(N,T).normalize(),T.crossVectors(N,C),k.crossVectors(N,T),[S,T,k]})(m);for(let v=0;v<=i;v++){const S=v/i*Math.PI*2,N=Math.sin(S),T=-Math.cos(S);o.x=T*b.x+N*y.x,o.y=T*b.y+N*y.y,o.z=T*b.z+N*y.z,o.normalize(),u.push(o.x,o.y,o.z),a.x=x.x+n*o.x*.5,a.y=x.y+n*o.y*.5,a.z=x.z+r*o.z*.5,c.push(a.x,a.y,a.z)}}(function(){for(let m=0;m<e.length;m++)p(m);p(closed===!1?e.length-1:0),(function(){for(let m=0;m<e.length;m++)for(let x=0;x<=i;x++)l.x=m/e.length,l.y=x/i,d.push(l.x,l.y)})(),(function(){for(let m=1;m<e.length;m++)for(let x=1;x<=i;x++){const b=(i+1)*(m-1)+(x-1),y=(i+1)*m+(x-1),v=(i+1)*m+x,S=(i+1)*(m-1)+x;f.push(b,y,S),f.push(y,v,S)}})()})(),this.setIndex(f),this.setAttribute("position",new Ti(c,3)),this.setAttribute("normal",new Ti(u,3)),this.setAttribute("uv",new Ti(d,2))}}class N0{static get initial(){const e=new N0;return Object.assign(e,{x:0,y:0,z:0,r:0,e:0,i:0,j:0,t:0}),e}}const cj={h:0,s:0,l:0};class Dg{constructor(e){var n,r,i,a,o,l,c,u,d;if(this.minLayerThreshold=.05,this.renderExtrusion=!0,this.renderTravel=!1,this.renderTubes=!1,this.extrusionWidth=.6,this.singleLayerMode=!1,this.initialCameraPosition=[-100,400,450],this.debug=!1,this.inches=!1,this.nonTravelmoves=[],this.disableGradient=!1,this.state=N0.initial,this.beyondFirstMove=!1,this.disposables=[],this._extrusionColor=Dg.defaultExtrusionColor,this.renderLayerIndex=0,this._geometries={},this._backgroundColor=new Zt(14737632),this._travelColor=new Zt(10027008),this._toolColors={},this.devMode=!1,this._lastRenderTime=0,this._wireframe=!1,this.minLayerThreshold=(n=e.minLayerThreshold)!==null&&n!==void 0?n:this.minLayerThreshold,this.parser=new aM(this.minLayerThreshold),this.scene=new yBe,this.scene.background=this._backgroundColor,e.backgroundColor!==void 0&&(this.backgroundColor=new Zt(e.backgroundColor)),this.targetId=e.targetId,this.endLayer=e.endLayer,this.startLayer=e.startLayer,this.lineWidth=e.lineWidth,this.lineHeight=e.lineHeight,this.buildVolume=e.buildVolume,this.initialCameraPosition=(r=e.initialCameraPosition)!==null&&r!==void 0?r:this.initialCameraPosition,this.debug=(i=e.debug)!==null&&i!==void 0?i:this.debug,this.renderExtrusion=(a=e.renderExtrusion)!==null&&a!==void 0?a:this.renderExtrusion,this.renderTravel=(o=e.renderTravel)!==null&&o!==void 0?o:this.renderTravel,this.nonTravelmoves=(l=e.nonTravelMoves)!==null&&l!==void 0?l:this.nonTravelmoves,this.renderTubes=(c=e.renderTubes)!==null&&c!==void 0?c:this.renderTubes,this.extrusionWidth=(u=e.extrusionWidth)!==null&&u!==void 0?u:this.extrusionWidth,this.devMode=(d=e.devMode)!==null&&d!==void 0?d:this.devMode,this.stats=this.devMode?new n8e:void 0,e.extrusionColor!==void 0&&(this.extrusionColor=e.extrusionColor),e.travelColor!==void 0&&(this.travelColor=new Zt(e.travelColor)),e.topLayerColor!==void 0&&(this.topLayerColor=new Zt(e.topLayerColor)),e.lastSegmentColor!==void 0&&(this.lastSegmentColor=new Zt(e.lastSegmentColor)),e.toolColors){this._toolColors={};for(const[m,x]of Object.entries(e.toolColors))this._toolColors[parseInt(m)]=new Zt(x)}if(e.disableGradient!==void 0&&(this.disableGradient=e.disableGradient),console.info("Using THREE r"+x2),console.debug("opts",e),this.targetId&&console.warn("`targetId` is deprecated and will removed in the future. Use `canvas` instead."),e.canvas)this.canvas=e.canvas,this.renderer=new SD({canvas:this.canvas,preserveDrawingBuffer:!0});else{if(!this.targetId)throw Error("Set either opts.canvas or opts.targetId");const m=document.getElementById(this.targetId);if(!m)throw new Error("Unable to find element "+this.targetId);this.renderer=new SD({preserveDrawingBuffer:!0}),this.canvas=this.renderer.domElement,m.appendChild(this.canvas)}this.camera=new oo(25,this.canvas.offsetWidth/this.canvas.offsetHeight,10,5e3),this.camera.position.fromArray(this.initialCameraPosition);const f=this.camera.far,p=.8*f;this.scene.fog=new dL(this._backgroundColor,p,f),this.resize(),this.controls=new ZBe(this.camera,this.renderer.domElement),this.initScene(),this.animate(),e.allowDragNDrop&&this._enableDropHandler(),this.initStats()}get extrusionColor(){return this._extrusionColor}set extrusionColor(e){if(Array.isArray(e)){this._extrusionColor=[];for(const[n,r]of e.entries())this._extrusionColor[n]=new Zt(r)}else this._extrusionColor=new Zt(e)}get currentToolColor(){var e;return this._extrusionColor===void 0?Dg.defaultExtrusionColor:this._extrusionColor instanceof Zt?this._extrusionColor:(e=this._extrusionColor[this.state.t])!==null&&e!==void 0?e:Dg.defaultExtrusionColor}get backgroundColor(){return this._backgroundColor}set backgroundColor(e){this._backgroundColor=new Zt(e),this.scene.background=this._backgroundColor}get travelColor(){return this._travelColor}set travelColor(e){this._travelColor=new Zt(e)}get topLayerColor(){return this._topLayerColor}set topLayerColor(e){this._topLayerColor=e!==void 0?new Zt(e):void 0}get lastSegmentColor(){return this._lastSegmentColor}set lastSegmentColor(e){this._lastSegmentColor=e!==void 0?new Zt(e):void 0}get layers(){return[this.parser.preamble].concat(this.parser.layers.concat())}get maxLayerIndex(){var e;return((e=this.endLayer)!==null&&e!==void 0?e:this.layers.length)-1}get minLayerIndex(){var e;return this.singleLayerMode?this.maxLayerIndex:((e=this.startLayer)!==null&&e!==void 0?e:0)-1}animate(){var e;this.animationFrameId=requestAnimationFrame((()=>this.animate())),this.controls.update(),this.renderer.render(this.scene,this.camera),(e=this.stats)===null||e===void 0||e.update()}processGCode(e){this.parser.parseGCode(e),this.render()}initScene(){for(;this.scene.children.length>0;)this.scene.remove(this.scene.children[0]);for(;this.disposables.length>0;){const e=this.disposables.pop();e&&e.dispose()}if(this.debug&&this.buildVolume){const e=new IBe(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 OBe(13421772,.3*Math.PI),n=new RBe(16777215,Math.PI,void 0,.001);n.position.set(0,500,500),this.scene.add(e),this.scene.add(n)}}createGroup(e){const n=new u0;return n.name=e,n.quaternion.setFromEuler(new fv(-Math.PI/2,0,0)),this.buildVolume?n.position.set(-this.buildVolume.x/2,0,this.buildVolume.y/2):n.position.set(-100,0,100),n}render(){const e=performance.now();this.group=this.createGroup("allLayers"),this.state=N0.initial,this.initScene();for(let n=0;n<this.layers.length;n++)this.renderLayer(n);this.batchGeometries(),this.scene.add(this.group),this.renderer.render(this.scene,this.camera),this._lastRenderTime=performance.now()-e}renderAnimated(e=1){return aj(this,void 0,void 0,(function*(){return this.initScene(),this.renderLayerIndex=0,this.renderFrameLoop(e>0?e:1)}))}renderFrameLoop(e){return new Promise((n=>{const r=()=>{this.renderLayerIndex>this.layers.length-1?n():(this.renderFrame(e),requestAnimationFrame(r))};r()}))}renderFrame(e){this.group=this.createGroup("layer"+this.renderLayerIndex);for(let n=0;n<e&&this.renderLayerIndex+n<this.layers.length;n++)this.renderLayer(this.renderLayerIndex),this.renderLayerIndex++;this.batchGeometries(),this.scene.add(this.group)}renderLayer(e){var n,r,i,a,o,l,c,u;if(e>this.maxLayerIndex)return;const d=this.layers[e],f={extrusion:[],travel:[],z:this.state.z,height:d.height};for(const p of d.commands)if(p.gcode!="g20"){if(p.gcode.startsWith("t")){this.doRenderExtrusion(f,e),f.extrusion=[];const m=p;this.state.t=m.toolIndex}else if(["g0","g00","g1","g01","g2","g02","g3","g03"].indexOf(p.gcode)>-1){const m=p,x={x:(n=m.params.x)!==null&&n!==void 0?n:this.state.x,y:(r=m.params.y)!==null&&r!==void 0?r:this.state.y,z:(i=m.params.z)!==null&&i!==void 0?i:this.state.z,r:(a=m.params.r)!==null&&a!==void 0?a:this.state.r,e:(o=m.params.e)!==null&&o!==void 0?o:this.state.e,i:(l=m.params.i)!==null&&l!==void 0?l:this.state.i,j:(c=m.params.j)!==null&&c!==void 0?c:this.state.j,t:this.state.t};if(e>=this.minLayerIndex){const b=((u=m.params.e)!==null&&u!==void 0?u:0)>0||this.nonTravelmoves.indexOf(p.gcode)>-1;(x.x!=this.state.x||x.y!=this.state.y||x.z!=this.state.z)&&(b&&this.renderExtrusion||!b&&this.renderTravel)&&(p.gcode=="g2"||p.gcode=="g3"||p.gcode=="g02"||p.gcode=="g03"?this.addArcSegment(f,this.state,x,b,p.gcode=="g2"||p.gcode=="g02"):this.addLineSegment(f,this.state,x,b))}this.state.x=x.x,this.state.y=x.y,this.state.z=x.z,this.beyondFirstMove||(this.beyondFirstMove=!0)}}else this.setInches();this.doRenderExtrusion(f,e)}doRenderExtrusion(e,n){var r,i;if(this.renderExtrusion){let a=this.currentToolColor;if(!this.singleLayerMode&&!this.renderTubes&&!this.disableGradient){const o=.1+.7*n/this.layers.length;a.getHSL(cj),a=new Zt().setHSL(cj.h,cj.s,o)}if(n==this.layers.length-1){const o=(r=this._topLayerColor)!==null&&r!==void 0?r:a,l=(i=this._lastSegmentColor)!==null&&i!==void 0?i:o,c=e.extrusion.splice(-3),u=e.extrusion.splice(-3);this.renderTubes?(this.addTubeLine(e.extrusion,o.getHex(),e.height),this.addTubeLine([...u,...c],l.getHex(),e.height)):(this.addLine(e.extrusion,o.getHex()),this.addLine([...u,...c],l.getHex()))}else this.renderTubes?this.addTubeLine(e.extrusion,a.getHex(),e.height):this.addLine(e.extrusion,a.getHex())}this.renderTravel&&this.addLine(e.travel,this._travelColor.getHex())}setInches(){this.beyondFirstMove?console.warn("Switching units after movement is already made is discouraged and is not supported."):this.inches=!0}drawBuildVolume(){if(!this.buildVolume)return;this.scene.add(new e8e(this.buildVolume.x,10,this.buildVolume.y,10));const e=t8e(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 aM(this.minLayerThreshold)}resetState(){var e;this.startLayer=1,this.endLayer=1/0,this.singleLayerMode=!1,this.beyondFirstMove=!1,this.state=N0.initial,(e=this.devGui)===null||e===void 0||e.reset(),this._geometries={}}resize(){const[e,n]=[this.canvas.offsetWidth,this.canvas.offsetHeight];this.camera.aspect=e/n,this.camera.updateProjectionMatrix(),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(e,n,!1)}addLineSegment(e,n,r,i){(i?e.extrusion:e.travel).push(n.x,n.y,n.z,r.x,r.y,r.z)}addArcSegment(e,n,r,i,a){const o=i?e.extrusion:e.travel,l=n.x,c=n.y,u=n.z,d=r.x,f=r.y,p=r.z;let m=r.r,x=r.i,b=r.j;if(m){const H=d-l,K=f-c,V=Math.sqrt(Math.pow(H/2,2)+Math.pow(K/2,2));m=Math.max(m,V);const Q=Math.pow(H,2)+Math.pow(K,2),Z=Math.pow(m,2)-Q/4;let ae=Math.sqrt(Z/Q);(a&&m<0||!a&&m>0)&&(ae=-ae),x=H/2+K*ae,b=K/2-H*ae}const y=l==d&&c==f,v=l+x,S=c+b,N=Math.sqrt(x*x+b*b),T=Math.atan2(-b,-x),k=Math.atan2(f-S,d-v);let C;y?C=2*Math.PI:(C=a?T-k:k-T,C<0&&(C+=2*Math.PI));let E=N*C/1.8;this.inches&&(E*=25),E<1&&(E=1);let D=C/E;D*=a?-1:1;const A=[];A.push({x:l,y:c,z:u});const R=(u-p)/E;let U=l,F=c,$=u,j=T;for(let H=0;H<E-1;H++)j+=D,U=v+N*Math.cos(j),F=S+N*Math.sin(j),$+=R,A.push({x:U,y:F,z:$});A.push({x:r.x,y:r.y,z:r.z});for(let H=0;H<A.length-1;H++)o.push(A[H].x,A[H].y,A[H].z,A[H+1].x,A[H+1].y,A[H+1].z)}addLine(e,n){var r;if(typeof this.lineWidth=="number"&&this.lineWidth>0)return void this.addThickLine(e,n);const i=new ns;i.setAttribute("position",new Ti(e,3)),this.disposables.push(i);const a=new pv({color:n});this.disposables.push(a);const o=new _2(i,a);(r=this.group)===null||r===void 0||r.add(o)}addTubeLine(e,n,r=.2){let i=[];const a=[];for(let o=0;o<e.length;o+=6){const l=e.slice(o,o+9),c=new qe(l[0],l[1],l[2]),u=new qe(l[3],l[4],l[5]),d=new qe(l[6],l[7],l[8]);i.push(c),u.equals(d)||(i.push(u),a.push(i),i=[])}a.forEach((o=>{var l;const c=new r8e(o,this.extrusionWidth,this.lineHeight||r,4);(l=this._geometries)[n]||(l[n]=[]),this._geometries[n].push(c)}))}addThickLine(e,n){var r;if(!e.length||!this.lineWidth)return;const i=new mee;this.disposables.push(i);const a=new fee({color:n,linewidth:this.lineWidth/(1e3*window.devicePixelRatio)});this.disposables.push(a),i.setPositions(e);const o=new JBe(i,a);(r=this.group)===null||r===void 0||r.add(o)}dispose(){this.disposables.forEach((e=>e.dispose())),this.disposables=[],this.controls.dispose(),this.renderer.dispose(),this.cancelAnimation()}cancelAnimation(){this.animationFrameId!==void 0&&cancelAnimationFrame(this.animationFrameId),this.animationFrameId=void 0}_enableDropHandler(){console.warn("Drag and drop is deprecated as a library feature. See the demo how to implement your own."),this.canvas.addEventListener("dragover",(e=>{e.stopPropagation(),e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect="copy"),this.canvas.classList.add("dragging")})),this.canvas.addEventListener("dragleave",(e=>{e.stopPropagation(),e.preventDefault(),this.canvas.classList.remove("dragging")})),this.canvas.addEventListener("drop",(e=>aj(this,void 0,void 0,(function*(){var n,r;e.stopPropagation(),e.preventDefault(),this.canvas.classList.remove("dragging");const i=((r=(n=e.dataTransfer)===null||n===void 0?void 0:n.files)!==null&&r!==void 0?r:[])[0];this.clear(),yield this._readFromStream(i.stream()),this.render()}))))}batchGeometries(){if(this._geometries)for(const e in this._geometries){const n=this.createBatchMesh(parseInt(e));for(;this._geometries[e].length>0;){const r=this._geometries[e].pop();n.addGeometry(r)}}}createBatchMesh(e){var n;const r=this._geometries[e],i=new CBe({color:e,wireframe:this._wireframe});this.disposables.push(i);const a=r.reduce(((l,c)=>3*c.attributes.position.count+l),0),o=new EBe(r.length,a,void 0,i);return this.disposables.push(o),(n=this.group)===null||n===void 0||n.add(o),o}_readFromStream(e){var n,r;return aj(this,void 0,void 0,(function*(){const i=e.getReader();let a,o="",l=0;do{console.debug("reading from stream"),a=yield i.read(),l+=(r=(n=a.value)===null||n===void 0?void 0:n.length)!==null&&r!==void 0?r:0;const u=(c=a.value,new TextDecoder("utf-8").decode(c)),d=u.lastIndexOf(`
- `),f=u.slice(0,d);this.parser.parseGCode(o+f),o=u.slice(d)}while(!a.done);var c;console.debug("read from stream",l)}))}initGui(){typeof this.devMode=="boolean"&&this.devMode===!0?this.devGui=new N7(this):typeof this.devMode=="object"&&(this.devGui=new N7(this,this.devMode))}initStats(){var e;this.stats&&(typeof this.devMode=="object"&&(this.statsContainer=this.devMode.statsContainer),((e=this.statsContainer)!==null&&e!==void 0?e:document.body).appendChild(this.stats.dom),this.stats.dom.classList.add("stats"),this.initGui())}}Dg.defaultExtrusionColor=new Zt("hotpink");function i8e({gcodeUrl:t,buildVolume:e={x:256,y:256,z:256},filamentColors:n,className:r=""}){const i=_.useRef(null),a=_.useRef(null),o=_.useRef(null),l=_.useRef(!1),[c,u]=_.useState(!0),[d,f]=_.useState(null),[p,m]=_.useState(!1),[x,b]=_.useState(0),[y,v]=_.useState(0),S=_.useMemo(()=>JSON.stringify(n),[n]);_.useEffect(()=>{if(!i.current||l.current)return;l.current=!0;const k=i.current,C=k.parentElement?.getBoundingClientRect();C&&(k.width=C.width,k.height=C.height);const E=n&&n.length>1,D=n?.[0]||"#00ae42",A=new Dg({canvas:k,buildVolume:e,backgroundColor:1710618,extrusionColor:E?n:D,disableGradient:!0,lineHeight:.2,lineWidth:2,renderTravel:!1,renderExtrusion:!0});a.current=A,fetch(t).then(async U=>{if(!U.ok)throw U.status===404&&(await U.json().catch(()=>({}))).detail?.includes("sliced")?(m(!0),new Error("not_sliced")):new Error("Failed to load G-code");return U.text()}).then(U=>{const F=new Set,$=/^(\s*)T(\d+)(\s*;.*)?$/gim;let j;for(;(j=$.exec(U))!==null;){const ae=parseInt(j[2],10);ae<=15&&F.add(ae)}const H=new Map,K=Array.from(F).sort((ae,B)=>ae-B);K.forEach((ae,B)=>{H.set(ae,B%8)});const V=[];K.forEach((ae,B)=>{const X=n?.[ae]||"#00ae42";V[B%8]=X});const Q=U.split(`
- `).map(ae=>{const B=ae.match(/^(\s*)T(\d+)(\s*;.*)?$/i);if(B){const X=parseInt(B[2],10);if(X>15)return`; FILTERED: ${ae.trim()}`;const ne=H.get(X)??0;return`${B[1]}T${ne}${B[3]||""}`}return ae}).join(`
- `);V.length>0&&(A.extrusionColor=V),A.processGCode(Q);const Z=A.layers?.length||0;v(Z),b(Z),A.render(),u(!1)}).catch(U=>{U.message!=="not_sliced"&&f(U.message),u(!1)});const R=()=>{if(k.parentElement&&a.current){const U=k.parentElement.getBoundingClientRect();k.width=U.width,k.height=U.height,a.current.resize()}};return window.addEventListener("resize",R),()=>{window.removeEventListener("resize",R),o.current&&cancelAnimationFrame(o.current),a.current&&(a.current.dispose(),a.current=null),l.current=!1}},[t,S]);const N=_.useCallback(k=>{if(!a.current)return;const C=Math.max(1,Math.min(k,y));b(C),o.current&&cancelAnimationFrame(o.current),o.current=requestAnimationFrame(()=>{a.current&&(a.current.endLayer=C,a.current.render())})},[y]),T=k=>{N(parseInt(k.target.value,10))};return s.jsxs("div",{className:`relative flex flex-col h-full ${r}`,children:[s.jsxs("div",{className:"flex-1 relative bg-bambu-dark rounded-lg overflow-hidden",children:[s.jsx("canvas",{ref:i,className:"w-full h-full"}),c&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:s.jsxs("div",{className:"text-center",children:[s.jsx(ht,{className:"w-8 h-8 animate-spin text-bambu-green mx-auto mb-2"}),s.jsx("p",{className:"text-bambu-gray text-sm",children:"Loading G-code..."})]})}),p&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:s.jsxs("div",{className:"text-center max-w-sm px-4",children:[s.jsx(Eue,{className:"w-12 h-12 text-bambu-gray mx-auto mb-3"}),s.jsx("p",{className:"text-white font-medium mb-2",children:"G-code not available"}),s.jsx("p",{className:"text-bambu-gray text-sm",children:"This file hasn't been sliced yet. G-code preview is only available after slicing in Bambu Studio or Orca Slicer."})]})}),d&&!p&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:s.jsx("div",{className:"text-center text-red-400",children:s.jsx("p",{className:"text-sm",children:d})})})]}),!c&&!d&&!p&&y>0&&s.jsx("div",{className:"mt-4 px-2",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(sl,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),s.jsx("button",{onClick:()=>N(x-1),disabled:x<=1,className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-30 disabled:cursor-not-allowed",children:s.jsx(gh,{className:"w-4 h-4"})}),s.jsx("input",{type:"range",min:1,max:y,value:x,onChange:T,className:"flex-1 h-2 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer accent-bambu-green"}),s.jsx("button",{onClick:()=>N(x+1),disabled:x>=y,className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-30 disabled:cursor-not-allowed",children:s.jsx(gs,{className:"w-4 h-4"})}),s.jsxs("span",{className:"text-sm text-bambu-gray min-w-[80px] text-right",children:[x," / ",y]})]})})]})}function pee({archiveId:t,title:e,onClose:n}){const[r,i]=_.useState(null),[a,o]=_.useState(null),[l,c]=_.useState(!0);_.useEffect(()=>{const d=f=>{f.key==="Escape"&&n()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[n]),_.useEffect(()=>{ue.getArchiveCapabilities(t).then(d=>{o(d),d.has_model?i("3d"):d.has_gcode&&i("gcode"),c(!1)}).catch(()=>{o({has_model:!0,has_gcode:!1,has_source:!1,build_volume:{x:256,y:256,z:256},filament_colors:[]}),i("3d"),c(!1)})},[t]);const u=()=>{const d=e||"model",f=`${window.location.origin}${ue.getArchiveForSlicer(t,d)}`;mu(f)};return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-8",onClick:n,children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-4xl h-[80vh] flex flex-col",onClick:d=>d.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[s.jsx("h2",{className:"text-lg font-semibold text-white truncate flex-1 mr-4",children:e}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(Te,{variant:"secondary",size:"sm",onClick:u,children:[s.jsx(Kr,{className:"w-4 h-4"}),"Open in Slicer"]}),s.jsx(Te,{variant:"ghost",size:"sm",onClick:n,children:s.jsx(Rt,{className:"w-5 h-5"})})]})]}),a&&s.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary",children:[s.jsxs("button",{onClick:()=>a.has_model&&i("3d"),disabled:!a.has_model,className:`flex items-center gap-2 px-6 py-3 text-sm font-medium transition-colors ${r==="3d"?"text-bambu-green border-b-2 border-bambu-green":a.has_model?"text-bambu-gray hover:text-white":"text-bambu-gray/30 cursor-not-allowed"}`,children:[s.jsx(lo,{className:"w-4 h-4"}),"3D Model",!a.has_model&&s.jsx("span",{className:"text-xs",children:"(not available)"})]}),s.jsxs("button",{onClick:()=>a.has_gcode&&i("gcode"),disabled:!a.has_gcode,className:`flex items-center gap-2 px-6 py-3 text-sm font-medium transition-colors ${r==="gcode"?"text-bambu-green border-b-2 border-bambu-green":a.has_gcode?"text-bambu-gray hover:text-white":"text-bambu-gray/30 cursor-not-allowed"}`,children:[s.jsx(tue,{className:"w-4 h-4"}),"G-code Preview",!a.has_gcode&&s.jsx("span",{className:"text-xs",children:"(not sliced)"})]})]}),s.jsx("div",{className:"flex-1 overflow-hidden p-4",children:l?s.jsx("div",{className:"w-full h-full flex items-center justify-center",children:s.jsx(ht,{className:"w-8 h-8 animate-spin text-bambu-green"})}):r==="3d"&&a?s.jsx(tLe,{url:a.has_source?ue.getSource3mfDownloadUrl(t):ue.getArchiveDownload(t),buildVolume:a.build_volume,filamentColors:a.filament_colors,className:"w-full h-full"}):r==="gcode"&&a?s.jsx(i8e,{gcodeUrl:ue.getArchiveGcode(t),filamentColors:a.filament_colors,className:"w-full h-full"}):s.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:"No preview available for this file"})})]})})}const k7={"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 a8e(t){if(!t||t.length<6)return"Unknown";const e=t.replace("#",""),n=parseInt(e.substring(0,2),16),r=parseInt(e.substring(2,4),16),i=parseInt(e.substring(4,6),16),a=Math.max(n,r,i)/255,o=Math.min(n,r,i)/255,l=(a+o)/2;let c=0,u=0;if(a!==o){const d=a-o;u=l>.5?d/(2-a-o):d/(a+o);const f=n/255,p=r/255,m=i/255;a===f?c=((p-m)/d+(p<m?6:0))/6:a===p?c=((m-f)/d+2)/6:c=((f-p)/d+4)/6}return c=c*360,l<.15?"Black":l>.85?"White":u<.15?l<.4?"Dark Gray":l>.6?"Light Gray":"Gray":c<15||c>=345?"Red":c<45?"Orange":c<70?"Yellow":c<150?"Green":c<200?"Cyan":c<260?"Blue":c<290?"Purple":c<345?"Pink":"Unknown"}function sx(t){const e=t.replace("#","").toLowerCase().substring(0,6);return k7[e]?k7[e]:a8e(t)}function sM(t){return t?`#${t.replace("#","").substring(0,6)}`:"#808080"}function va(t){return t?t.replace("#","").toLowerCase().substring(0,6):""}function Ch(t,e,n=40){const r=va(t),i=va(e);if(!r||!i||r.length<6||i.length<6)return!1;const a=parseInt(r.substring(0,2),16),o=parseInt(r.substring(2,4),16),l=parseInt(r.substring(4,6),16),c=parseInt(i.substring(0,2),16),u=parseInt(i.substring(2,4),16),d=parseInt(i.substring(4,6),16);return Math.abs(a-c)<=n&&Math.abs(o-u)<=n&&Math.abs(l-d)<=n}function gee(t,e,n,r){const i=String.fromCharCode(65+(t>=128?t-128:t));return n?`HT-${i}`:`AMS-${i} Slot ${e+1}`}function xee(t,e,n){return t*4+e}function s8e(t){if(!t)return"";const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function o8e(){const t=new Date;return t.setMinutes(t.getMinutes()+1),t.toISOString().slice(0,16)}function E7(t){if(!t)return!1;const e=Date.now()+4320*60*60*1e3;return new Date(t).getTime()>e}function mL(t){const e=[];if(t?.ams?.forEach(n=>{const r=n.tray.length===1;n.tray.forEach(i=>{if(i.tray_type){const a=sM(i.tray_color);e.push({type:i.tray_type,color:a,colorName:sx(a),amsId:n.id,trayId:i.id,isHt:r,isExternal:!1,label:gee(n.id,i.id,r),globalTrayId:xee(n.id,i.id)})}})}),t?.vt_tray?.tray_type){const n=sM(t.vt_tray.tray_color);e.push({type:t.vt_tray.tray_type,color:n,colorName:sx(n),amsId:-1,trayId:0,isHt:!1,isExternal:!0,label:"External",globalTrayId:254})}return e}function T7(t,e){if(!t?.filaments||t.filaments.length===0)return;const n=mL(e);if(n.length===0)return;const r=new Set,i=t.filaments.map(l=>{const c=n.find(p=>!r.has(p.globalTrayId)&&p.type?.toUpperCase()===l.type?.toUpperCase()&&va(p.color)===va(l.color)),u=!c&&n.find(p=>!r.has(p.globalTrayId)&&p.type?.toUpperCase()===l.type?.toUpperCase()&&Ch(p.color,l.color)),d=!c&&!u&&n.find(p=>!r.has(p.globalTrayId)&&p.type?.toUpperCase()===l.type?.toUpperCase()),f=c||u||d||void 0;return f&&r.add(f.globalTrayId),{slot_id:l.slot_id,globalTrayId:f?.globalTrayId??-1}}),a=Math.max(...i.map(l=>l.slot_id||0));if(a<=0)return;const o=new Array(a).fill(-1);return i.forEach(l=>{l.slot_id&&l.slot_id>0&&(o[l.slot_id-1]=l.globalTrayId)}),o}function l8e(t){return _.useMemo(()=>{const e=[];if(t?.ams?.forEach(n=>{const r=n.tray.length===1;n.tray.forEach(i=>{if(i.tray_type){const a=sM(i.tray_color);e.push({type:i.tray_type,color:a,colorName:sx(a),amsId:n.id,trayId:i.id,isHt:r,isExternal:!1,label:gee(n.id,i.id,r),globalTrayId:xee(n.id,i.id)})}})}),t?.vt_tray?.tray_type){const n=sM(t.vt_tray.tray_color);e.push({type:t.vt_tray.tray_type,color:n,colorName:sx(n),amsId:-1,trayId:0,isHt:!1,isExternal:!0,label:"External",globalTrayId:254})}return e},[t])}function bee(t,e,n){const r=l8e(e),i=_.useMemo(()=>{if(!t?.filaments||t.filaments.length===0)return[];const c=new Set(Object.values(n));return t.filaments.map(u=>{const d=u.slot_id||0;if(d>0&&n[d]!==void 0){const N=n[d],T=r.find(k=>k.globalTrayId===N);if(T){const k=T.type?.toUpperCase()===u.type?.toUpperCase(),C=va(T.color)===va(u.color)||Ch(T.color,u.color);let E;return k&&C?E="match":k?E="type_only":E="mismatch",{...u,loaded:T,hasFilament:!0,typeMatch:k,colorMatch:C,status:E,isManual:!0}}}const f=r.find(N=>!c.has(N.globalTrayId)&&N.type?.toUpperCase()===u.type?.toUpperCase()&&va(N.color)===va(u.color)),p=!f&&r.find(N=>!c.has(N.globalTrayId)&&N.type?.toUpperCase()===u.type?.toUpperCase()&&Ch(N.color,u.color)),m=!f&&!p&&r.find(N=>!c.has(N.globalTrayId)&&N.type?.toUpperCase()===u.type?.toUpperCase()),x=f||p||m||void 0;x&&c.add(x.globalTrayId);const b=!!x,y=b,v=!!f||!!p;let S;return f||p?S="match":m?S="type_only":S="mismatch",{...u,loaded:x,hasFilament:b,typeMatch:y,colorMatch:v,status:S,isManual:!1}})},[t,r,n]),a=_.useMemo(()=>{if(i.length===0)return;const c=Math.max(...i.map(d=>d.slot_id||0));if(c<=0)return;const u=new Array(c).fill(-1);return i.forEach(d=>{d.slot_id&&d.slot_id>0&&(u[d.slot_id-1]=d.loaded?.globalTrayId??-1)}),u},[i]),o=i.some(c=>c.status==="mismatch"),l=i.some(c=>c.status==="type_only");return{loadedFilaments:r,filamentComparison:i,amsMapping:a,hasTypeMismatch:o,hasColorMismatch:l}}function c8e(t,e,n){if(!t||t.length===0)return{exactMatches:0,typeOnlyMatches:0,missingTypes:0,totalSlots:0,status:"full"};let r=0,i=0,a=0;const o=new Set(Object.values(n));for(const u of t){const d=u.slot_id||0;if(d>0&&n[d]!==void 0){const b=n[d],y=e.find(v=>v.globalTrayId===b);if(y){const v=y.type?.toUpperCase()===u.type?.toUpperCase(),S=va(y.color)===va(u.color)||Ch(y.color,u.color);v&&S?r++:v?i++:a++;continue}}const f=e.find(b=>!o.has(b.globalTrayId)&&b.type?.toUpperCase()===u.type?.toUpperCase()&&va(b.color)===va(u.color)),p=f?void 0:e.find(b=>!o.has(b.globalTrayId)&&b.type?.toUpperCase()===u.type?.toUpperCase()&&Ch(b.color,u.color)),m=f||p?void 0:e.find(b=>!o.has(b.globalTrayId)&&b.type?.toUpperCase()===u.type?.toUpperCase()),x=f??p??m;x&&o.add(x.globalTrayId),f||p?r++:m?i++:a++}const l=t.length;let c="full";return a>0?c="missing":i>0&&(c="partial"),{exactMatches:r,typeOnlyMatches:i,missingTypes:a,totalSlots:l,status:c}}function u8e(t,e,n){if(!t?.filaments||t.filaments.length===0)return;const r=mL(e);if(r.length===0)return;const i=new Set(Object.values(n)),a=[];for(const c of t.filaments){const u=c.slot_id||0;if(u>0&&n[u]!==void 0){a.push({slot_id:u,globalTrayId:n[u]});continue}const d=r.find(x=>!i.has(x.globalTrayId)&&x.type?.toUpperCase()===c.type?.toUpperCase()&&va(x.color)===va(c.color)),f=d?void 0:r.find(x=>!i.has(x.globalTrayId)&&x.type?.toUpperCase()===c.type?.toUpperCase()&&Ch(x.color,c.color)),p=d||f?void 0:r.find(x=>!i.has(x.globalTrayId)&&x.type?.toUpperCase()===c.type?.toUpperCase()),m=d??f??p;m&&i.add(m.globalTrayId),a.push({slot_id:u,globalTrayId:m?.globalTrayId??-1})}const o=Math.max(...a.map(c=>c.slot_id||0));if(o<=0)return;const l=new Array(o).fill(-1);return a.forEach(c=>{c.slot_id&&c.slot_id>0&&(l[c.slot_id-1]=c.globalTrayId)}),l}const A7={useDefault:!0,manualMappings:{},autoConfigured:!1};function d8e(t,e,n,r,i,a){const o=dW({queries:t.map(x=>({queryKey:["printer-status",x],queryFn:()=>ue.getPrinterStatus(x),enabled:t.length>0,staleTime:5e3}))}),l=_.useMemo(()=>t.map((x,b)=>{const y=o[b],v=y?.data,N=e?.find(R=>R.id===x)?.name||`Printer ${x}`,T=mL(v),k=i[x]||A7,C=T7(n,v),E=k.useDefault?r:k.manualMappings,D=u8e(n,v,E),A=c8e(n?.filaments,T,E);return{printerId:x,printerName:N,status:v,isLoading:y?.isLoading??!1,loadedFilaments:T,autoMapping:C,finalMapping:D,matchStatus:A.status,exactMatches:A.exactMatches,typeOnlyMatches:A.typeOnlyMatches,missingTypes:A.missingTypes,totalSlots:A.totalSlots,config:k}}),[t,o,e,n,i,r]),c=o.some(x=>x.isLoading),u=(x,b)=>{a(y=>({...y,[x]:{...y[x]||A7,...b}}))},d=x=>{const b=l.find(S=>S.printerId===x);if(!b||!b.status||!n?.filaments)return;const y=T7(n,b.status);if(!y)return;const v={};y.forEach((S,N)=>{S!==-1&&(v[N+1]=S)}),u(x,{useDefault:!1,manualMappings:v,autoConfigured:!0})},f=()=>{for(const x of t)d(x)},p=x=>l.find(y=>y.printerId===x)?.finalMapping,m=l.every(x=>x.matchStatus!=="missing");return{printerResults:l,isLoading:c,perPrinterConfigs:i,updatePrinterConfig:u,autoConfigureAll:f,autoConfigurePrinter:d,getFinalMapping:p,allPrintersReady:m}}function h8e({printerResult:t,filamentReqs:e,onUpdateConfig:n}){const r=an(),[i,a]=_.useState(!1),o=(u,d)=>{if(u<=0)return;const f={...t.config.manualMappings};d===""?delete f[u]:f[u]=parseInt(d,10),n({useDefault:!1,manualMappings:f,autoConfigured:!1})},l=async()=>{a(!0);try{await ue.refreshPrinterStatus(t.printerId),await new Promise(u=>setTimeout(u,500)),await r.refetchQueries({queryKey:["printer-status",t.printerId]})}finally{a(!1)}},c=e.map(u=>{const d=u.slot_id||0,f=t.config.manualMappings[d];let p,m=!1;if(f!==void 0)p=t.loadedFilaments.find(b=>b.globalTrayId===f),m=!0;else{const b=new Set(Object.values(t.config.manualMappings)),y=t.loadedFilaments.find(N=>!b.has(N.globalTrayId)&&N.type?.toUpperCase()===u.type?.toUpperCase()&&va(N.color)===va(u.color)),v=y?void 0:t.loadedFilaments.find(N=>!b.has(N.globalTrayId)&&N.type?.toUpperCase()===u.type?.toUpperCase()&&Ch(N.color,u.color)),S=y||v?void 0:t.loadedFilaments.find(N=>!b.has(N.globalTrayId)&&N.type?.toUpperCase()===u.type?.toUpperCase());p=y??v??S}let x="mismatch";if(p){const b=p.type?.toUpperCase()===u.type?.toUpperCase(),y=va(p.color)===va(u.color)||Ch(p.color,u.color);b&&y?x="match":b&&(x="type_only")}return{req:u,loaded:p,status:x,isManual:m}});return s.jsxs("div",{className:"mt-2 bg-bambu-dark rounded-lg p-3 space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("span",{className:"text-xs text-bambu-gray",children:"Custom slot mapping"}),s.jsxs("button",{type:"button",onClick:l,className:"flex items-center gap-1 px-2 py-0.5 text-xs rounded border border-bambu-gray/30 hover:border-bambu-gray hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray hover:text-white",disabled:i,children:[s.jsx(Dr,{className:`w-3 h-3 ${i?"animate-spin":""}`}),s.jsx("span",{children:"Re-read"})]})]}),c.map(({req:u,loaded:d,status:f,isManual:p},m)=>s.jsxs("div",{className:"grid items-center gap-2 text-xs",style:{gridTemplateColumns:"16px minmax(70px, 1fr) auto 2fr 16px"},children:[s.jsx("span",{title:`Required: ${u.type} - ${sx(u.color)}`,children:s.jsx(dP,{className:"w-3 h-3",fill:u.color,stroke:u.color})}),s.jsxs("span",{className:"text-white truncate",children:[u.type," ",s.jsxs("span",{className:"text-bambu-gray",children:["(",u.used_grams,"g)"]})]}),s.jsx("span",{className:"text-bambu-gray",children:"→"}),s.jsxs("select",{value:d?.globalTrayId??"",onChange:x=>o(u.slot_id||0,x.target.value),className:`flex-1 px-2 py-1 rounded border text-xs bg-bambu-dark-secondary focus:outline-none focus:ring-1 focus:ring-bambu-green ${f==="match"?"border-bambu-green/50 text-bambu-green":f==="type_only"?"border-yellow-400/50 text-yellow-400":"border-orange-400/50 text-orange-400"} ${p?"ring-1 ring-blue-400/50":""}`,title:p?"Manually selected":"Auto-matched",children:[s.jsx("option",{value:"",className:"bg-bambu-dark text-bambu-gray",children:"-- Select slot --"}),t.loadedFilaments.map(x=>s.jsxs("option",{value:x.globalTrayId,className:"bg-bambu-dark text-white",children:[x.label,": ",x.type," (",x.colorName,")"]},x.globalTrayId))]}),f==="match"?s.jsx(Ia,{className:"w-3 h-3 text-bambu-green"}):f==="type_only"?s.jsx("span",{title:"Same type, different color",children:s.jsx(Cn,{className:"w-3 h-3 text-yellow-400"})}):s.jsx("span",{title:"Filament type not loaded",children:s.jsx(Cn,{className:"w-3 h-3 text-orange-400"})})]},m))]})}function f8e({printers:t,selectedPrinterIds:e,onMultiSelect:n,isLoading:r=!1,allowMultiple:i=!1,showInactive:a=!1,printerMappingResults:o,filamentReqs:l,onAutoConfigurePrinter:c,onUpdatePrinterConfig:u,assignmentMode:d="printer",onAssignmentModeChange:f,targetModel:p,onTargetModelChange:m,targetLocation:x,onTargetLocationChange:b,slicedForModel:y}){const[v,S]=_.useState(!1),N=a?t:t.filter(V=>V.is_active),T=_.useMemo(()=>{if(d!=="printer"||!y||v)return N;const V=N.filter(Q=>Q.model===y);return V.length>0?V:N},[N,d,y,v]),k=N.length-T.length,C=_.useMemo(()=>{const V=N.map(Q=>Q.model).filter(Q=>!!Q);return[...new Set(V)].sort()},[N]),E=_.useMemo(()=>{if(!p)return[];const V=N.filter(Q=>Q.model===p&&Q.location).map(Q=>Q.location).filter(Q=>!!Q);return[...new Set(V)].sort()},[N,p]),D=f&&m&&C.length>0,A=i&&e.length>1&&o&&l?.filaments&&l.filaments.length>0&&c&&u;if(r)return s.jsx("div",{className:"flex justify-center py-8",children:s.jsx(ht,{className:"w-6 h-6 text-bambu-green animate-spin"})});if(T.length===0)return s.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm mb-4",children:[s.jsx(Hi,{className:"w-4 h-4"}),"No ",a?"":"active ","printers available"]});const R=V=>{i?e.includes(V)?n(e.filter(Q=>Q!==V)):n([...e,V]):n([V])},U=()=>{n(T.map(V=>V.id))},F=()=>{n([])},$=(V,Q,Z)=>{Z.stopPropagation(),!(!c||!u)&&(Q?c(V):u(V,{useDefault:!0,manualMappings:{},autoConfigured:!1}))},j=V=>e.includes(V),H=e.length,K=V=>o?.find(Q=>Q.printerId===V);return s.jsxs("div",{className:"space-y-2 mb-6",children:[D&&s.jsxs("div",{className:"flex gap-2 mb-4",children:[s.jsxs("button",{type:"button",onClick:()=>{f("printer"),m(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg border transition-colors ${d==="printer"?"border-bambu-green bg-bambu-green/10 text-white":"border-bambu-dark-tertiary bg-bambu-dark text-bambu-gray hover:border-bambu-gray"}`,children:[s.jsx(Ur,{className:"w-4 h-4"}),s.jsx("span",{className:"text-sm",children:"Specific Printer"})]}),s.jsxs("button",{type:"button",onClick:()=>{f("model"),n([]);const V=y&&C.includes(y)?y:C[0];m(V)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg border transition-colors ${d==="model"?"border-bambu-green bg-bambu-green/10 text-white":"border-bambu-dark-tertiary bg-bambu-dark text-bambu-gray hover:border-bambu-gray"}`,children:[s.jsx(mg,{className:"w-4 h-4"}),s.jsxs("span",{className:"text-sm",children:["Any ",y||"Model"]})]})]}),d==="model"&&D&&s.jsxs("div",{className:"space-y-3 mb-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Target Model"}),s.jsxs("select",{value:p||"",onChange:V=>{m(V.target.value||null),b&&b(null)},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none text-sm",children:[s.jsx("option",{value:"",children:"Select a model..."}),C.map(V=>s.jsx("option",{value:V,children:V},V))]})]}),p&&E.length>0&&b&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Location Filter (optional)"}),s.jsxs("select",{value:x||"",onChange:V=>b(V.target.value||null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none text-sm",children:[s.jsx("option",{value:"",children:"Any location"}),E.map(V=>s.jsx("option",{value:V,children:V},V))]})]}),p&&s.jsxs("p",{className:"text-xs text-bambu-gray",children:["Scheduler will assign to first available idle ",p," printer",x?` in ${x}`:""]})]}),d==="printer"&&i&&T.length>1&&s.jsxs("div",{className:"flex items-center justify-between text-xs text-bambu-gray mb-2",children:[s.jsx("span",{children:H===0?"Select printers":`${H} printer${H!==1?"s":""} selected`}),s.jsxs("div",{className:"flex gap-2",children:[H<T.length&&s.jsx("button",{type:"button",onClick:U,className:"text-bambu-green hover:text-bambu-green/80 transition-colors",children:"Select all"}),H>0&&s.jsx("button",{type:"button",onClick:F,className:"text-bambu-gray hover:text-white transition-colors",children:"Clear"})]})]}),d==="printer"&&T.map(V=>{const Q=j(V.id),Z=K(V.id),ae=Z&&!Z.config.useDefault;return s.jsxs("div",{children:[s.jsxs("button",{type:"button",onClick:()=>R(V.id),className:`w-full flex items-center gap-3 p-3 rounded-lg border transition-colors ${Q?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary bg-bambu-dark hover:border-bambu-gray"} ${V.is_active?"":"opacity-60"}`,children:[s.jsx("div",{className:`p-2 rounded-lg ${Q?"bg-bambu-green/20":"bg-bambu-dark-tertiary"}`,children:s.jsx(Ur,{className:`w-5 h-5 ${Q?"text-bambu-green":"text-bambu-gray"}`})}),s.jsxs("div",{className:"text-left flex-1",children:[s.jsxs("p",{className:"text-white font-medium",children:[V.name,!V.is_active&&s.jsx("span",{className:"text-bambu-gray text-xs ml-2",children:"(inactive)"})]}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[V.model||"Unknown model"," • ",V.ip_address]})]}),i&&s.jsx("div",{className:`w-5 h-5 rounded border-2 flex items-center justify-center transition-colors ${Q?"bg-bambu-green border-bambu-green":"border-bambu-gray/50"}`,children:Q&&s.jsx(Ia,{className:"w-3 h-3 text-white"})})]}),Q&&A&&Z&&s.jsxs("div",{className:"ml-4 mt-2 mb-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",onClick:B=>B.stopPropagation(),children:[s.jsx("input",{type:"checkbox",checked:ae,onChange:B=>$(V.id,B.target.checked,B),className:"w-3.5 h-3.5 rounded border-bambu-gray/30 bg-bambu-dark-secondary text-bambu-green focus:ring-bambu-green focus:ring-offset-0"}),s.jsx("span",{className:"text-xs text-bambu-gray",children:"Custom mapping"})]}),s.jsxs("span",{className:`text-xs ml-2 ${Z.matchStatus==="full"?"text-bambu-green":Z.matchStatus==="partial"?"text-yellow-400":"text-orange-400"}`,children:["(",Z.exactMatches,"/",Z.totalSlots," matched)"]}),Z.isLoading&&s.jsx(Dr,{className:"w-3 h-3 text-bambu-gray animate-spin"}),ae&&s.jsxs("button",{type:"button",onClick:B=>{B.stopPropagation(),c(V.id)},className:"ml-auto flex items-center gap-1 px-2 py-0.5 text-xs rounded border border-bambu-gray/30 hover:border-bambu-gray hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray hover:text-white",children:[s.jsx(dfe,{className:"w-3 h-3"}),"Auto"]})]}),ae&&s.jsx(h8e,{printerResult:Z,filamentReqs:l.filaments,onUpdateConfig:B=>u(V.id,B)})]})]},V.id)}),d==="printer"&&k>0&&!v&&s.jsxs("button",{type:"button",onClick:()=>S(!0),className:"text-xs text-bambu-gray hover:text-white transition-colors mt-2 flex items-center gap-1",children:[s.jsx(Cn,{className:"w-3 h-3 text-yellow-400"}),k," other printer",k>1?"s":""," hidden (different model) —",s.jsx("span",{className:"underline",children:"show all"})]}),d==="printer"&&v&&y&&s.jsx("button",{type:"button",onClick:()=>S(!1),className:"text-xs text-bambu-gray hover:text-white transition-colors mt-2",children:s.jsxs("span",{className:"underline",children:["Show only ",y," printers"]})}),d==="printer"&&H===0&&s.jsxs("p",{className:"text-xs text-orange-400 mt-1 flex items-center gap-1",children:[s.jsx(Hi,{className:"w-3 h-3"}),"Select at least one printer"]}),d==="model"&&!p&&s.jsxs("p",{className:"text-xs text-orange-400 mt-1 flex items-center gap-1",children:[s.jsx(Hi,{className:"w-3 h-3"}),"Select a target printer model"]})]})}function m8e({plates:t,isMultiPlate:e,selectedPlate:n,onSelect:r}){return!e||t.length<=1?null:s.jsxs("div",{className:"mb-4",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsx(sl,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("span",{className:"text-sm text-bambu-gray",children:"Select Plate to Print"}),!n&&s.jsxs("span",{className:"text-xs text-orange-400 flex items-center gap-1",children:[s.jsx(Cn,{className:"w-3 h-3"}),"Selection required"]})]}),s.jsx("div",{className:"grid grid-cols-2 gap-2",children:t.map(i=>s.jsxs("button",{type:"button",onClick:()=>r(i.index),className:`flex items-center gap-2 p-2 rounded-lg border transition-colors text-left ${n===i.index?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary bg-bambu-dark hover:border-bambu-gray"}`,children:[i.has_thumbnail&&i.thumbnail_url!=null?s.jsx("img",{src:i.thumbnail_url,alt:`Plate ${i.index}`,className:"w-10 h-10 rounded object-cover bg-bambu-dark-tertiary"}):s.jsx("div",{className:"w-10 h-10 rounded bg-bambu-dark-tertiary flex items-center justify-center",children:s.jsx(sl,{className:"w-5 h-5 text-bambu-gray"})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"text-sm text-white font-medium truncate",children:i.name||`Plate ${i.index}`}),s.jsxs("p",{className:"text-xs text-bambu-gray truncate",children:[i.objects.length>0?i.objects.slice(0,3).join(", ")+(i.objects.length>3?"...":""):`${i.filaments.length} filament${i.filaments.length!==1?"s":""}`,i.print_time_seconds!=null?` • ${s8e(i.print_time_seconds)}`:""]})]}),n===i.index&&s.jsx(Ia,{className:"w-4 h-4 text-bambu-green flex-shrink-0"})]},i.index))})]})}function p8e({printerId:t,filamentReqs:e,manualMappings:n,onManualMappingChange:r,defaultExpanded:i=!1}){const a=an(),[o,l]=_.useState(!1),[c,u]=_.useState(i),{data:d}=at({queryKey:["printer-status",t],queryFn:()=>ue.getPrinterStatus(t),enabled:!!t}),{loadedFilaments:f,filamentComparison:p,hasTypeMismatch:m,hasColorMismatch:x}=bee(e,d,n);if(!(e?.filaments&&e.filaments.length>0)||!d)return null;const y=m?"#f97316":x?"#facc15":"#00ae42",v=(N,T)=>{if(N>0)if(T===""){const k={...n};delete k[N],r(k)}else r({...n,[N]:parseInt(T,10)})},S=async()=>{l(!0);try{await ue.refreshPrinterStatus(t),await new Promise(N=>setTimeout(N,500)),await a.refetchQueries({queryKey:["printer-status",t]})}finally{l(!1)}};return s.jsxs("div",{className:"mb-4",children:[s.jsxs("button",{type:"button",onClick:()=>u(!c),className:"flex items-center gap-2 text-sm text-bambu-gray hover:text-white transition-colors w-full",children:[s.jsx(dP,{className:"w-4 h-4",fill:y,stroke:"none"}),s.jsx("span",{children:"Filament Mapping"}),m?s.jsx("span",{className:"text-xs text-orange-400",children:"(Type not found)"}):x?s.jsx("span",{className:"text-xs text-yellow-400",children:"(Color mismatch)"}):s.jsx("span",{className:"text-xs text-bambu-green",children:"(Ready)"}),c?s.jsx(xh,{className:"w-4 h-4 ml-auto"}):s.jsx(ei,{className:"w-4 h-4 ml-auto"})]}),c&&s.jsxs("div",{className:"mt-2 bg-bambu-dark rounded-lg p-3 space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("span",{className:"text-xs text-bambu-gray",children:"Click to change slot assignment"}),s.jsxs("button",{type:"button",onClick:S,className:"flex items-center gap-1 px-2 py-0.5 text-xs rounded border border-bambu-gray/30 hover:border-bambu-gray hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray hover:text-white",disabled:o,children:[s.jsx(Dr,{className:`w-3 h-3 ${o?"animate-spin":""}`}),s.jsx("span",{children:"Re-read"})]})]}),p.map((N,T)=>s.jsxs("div",{className:"grid items-center gap-2 text-xs",style:{gridTemplateColumns:"16px minmax(70px, 1fr) auto 2fr 16px"},children:[s.jsx("span",{title:`Required: ${N.type} - ${sx(N.color)}`,children:s.jsx(dP,{className:"w-3 h-3",fill:N.color,stroke:N.color})}),s.jsxs("span",{className:"text-white truncate",children:[N.type," ",s.jsxs("span",{className:"text-bambu-gray",children:["(",N.used_grams,"g)"]})]}),s.jsx("span",{className:"text-bambu-gray",children:"→"}),s.jsxs("select",{value:N.loaded?.globalTrayId??"",onChange:k=>v(N.slot_id||0,k.target.value),className:`flex-1 px-2 py-1 rounded border text-xs bg-bambu-dark-secondary focus:outline-none focus:ring-1 focus:ring-bambu-green ${N.status==="match"?"border-bambu-green/50 text-bambu-green":N.status==="type_only"?"border-yellow-400/50 text-yellow-400":"border-orange-400/50 text-orange-400"} ${N.isManual?"ring-1 ring-blue-400/50":""}`,title:N.isManual?"Manually selected":"Auto-matched",children:[s.jsx("option",{value:"",className:"bg-bambu-dark text-bambu-gray",children:"-- Select slot --"}),f.map(k=>s.jsxs("option",{value:k.globalTrayId,className:"bg-bambu-dark text-white",children:[k.label,": ",k.type," (",k.colorName,")"]},k.globalTrayId))]}),N.status==="match"?s.jsx(Ia,{className:"w-3 h-3 text-bambu-green"}):N.status==="type_only"?s.jsx("span",{title:"Same type, different color",children:s.jsx(Cn,{className:"w-3 h-3 text-yellow-400"})}):s.jsx("span",{title:"Filament type not loaded",children:s.jsx(Cn,{className:"w-3 h-3 text-orange-400"})})]},T)),m&&s.jsx("p",{className:"text-xs text-orange-400 mt-2",children:"Required filament type not found in printer."})]})]})}const g8e=[{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 x8e({options:t,onChange:e,defaultExpanded:n=!1}){const[r,i]=_.useState(n),a=o=>{e({...t,[o]:!t[o]})};return s.jsxs("div",{className:"mb-4",children:[s.jsxs("button",{type:"button",onClick:()=>i(!r),className:"flex items-center gap-2 text-sm text-bambu-gray hover:text-white transition-colors w-full",children:[s.jsx(xN,{className:"w-4 h-4"}),s.jsx("span",{children:"Print Options"}),r?s.jsx(xh,{className:"w-4 h-4 ml-auto"}):s.jsx(ei,{className:"w-4 h-4 ml-auto"})]}),r&&s.jsx("div",{className:"mt-2 bg-bambu-dark rounded-lg p-3 space-y-2",children:g8e.map(({key:o,label:l,desc:c})=>s.jsxs("label",{className:"flex items-center justify-between cursor-pointer group",children:[s.jsxs("div",{children:[s.jsx("span",{className:"text-sm text-white",children:l}),s.jsx("p",{className:"text-xs text-bambu-gray",children:c})]}),s.jsx("div",{className:`relative w-10 h-5 rounded-full transition-colors ${t[o]?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,onClick:()=>a(o),children:s.jsx("div",{className:`absolute top-0.5 w-4 h-4 rounded-full bg-white transition-transform ${t[o]?"translate-x-5":"translate-x-0.5"}`})})]},o))})]})}function b8e({options:t,onChange:e}){const n=r=>{e({...t,scheduleType:r})};return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"When to print"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("button",{type:"button",className:`flex-1 px-2 py-2 rounded-lg border text-sm flex items-center justify-center gap-1.5 transition-colors ${t.scheduleType==="asap"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>n("asap"),children:[s.jsx(er,{className:"w-4 h-4"}),"ASAP"]}),s.jsxs("button",{type:"button",className:`flex-1 px-2 py-2 rounded-lg border text-sm flex items-center justify-center gap-1.5 transition-colors ${t.scheduleType==="scheduled"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>n("scheduled"),children:[s.jsx(si,{className:"w-4 h-4"}),"Scheduled"]}),s.jsxs("button",{type:"button",className:`flex-1 px-2 py-2 rounded-lg border text-sm flex items-center justify-center gap-1.5 transition-colors ${t.scheduleType==="manual"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>n("manual"),children:[s.jsx(bW,{className:"w-4 h-4"}),"Queue Only"]})]})]}),t.scheduleType==="scheduled"&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Date & Time"}),s.jsx("input",{type:"datetime-local",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:t.scheduledTime,onChange:r=>e({...t,scheduledTime:r.target.value}),min:o8e(),required:!0})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",id:"requirePrevious",checked:t.requirePreviousSuccess,onChange:r=>e({...t,requirePreviousSuccess:r.target.checked}),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),s.jsx("label",{htmlFor:"requirePrevious",className:"text-sm text-bambu-gray",children:"Only start if previous print succeeded"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",id:"autoOffAfter",checked:t.autoOffAfter,onChange:r=>e({...t,autoOffAfter:r.target.checked}),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),s.jsxs("label",{htmlFor:"autoOffAfter",className:"text-sm text-bambu-gray flex items-center gap-1",children:[s.jsx(Gu,{className:"w-3.5 h-3.5"}),"Power off printer when done"]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:t.scheduleType==="asap"?"Print will start as soon as the printer is idle.":t.scheduleType==="scheduled"?"Print will start at the scheduled time if the printer is idle. If busy, it will wait until the printer becomes available.":"Print will be staged but won't start automatically. Use the Start button to release it to the queue."})]})}const Jp={bed_levelling:!0,flow_cali:!1,vibration_cali:!0,layer_inspect:!1,timelapse:!1},y8e={scheduleType:"asap",scheduledTime:"",requirePreviousSuccess:!1,autoOffAfter:!1};function jh({mode:t,archiveId:e,libraryFileId:n,archiveName:r,queueItem:i,onClose:a,onSuccess:o}){const{t:l}=Hn(),c=an(),{showToast:u}=$n(),d=!!n&&!e,[f,p]=_.useState(()=>t==="edit-queue-item"&&i?.printer_id?[i.printer_id]:[]),[m,x]=_.useState(()=>t==="edit-queue-item"&&i?i.plate_id:null),[b,y]=_.useState(()=>t==="edit-queue-item"&&i?{bed_levelling:i.bed_levelling??Jp.bed_levelling,flow_cali:i.flow_cali??Jp.flow_cali,vibration_cali:i.vibration_cali??Jp.vibration_cali,layer_inspect:i.layer_inspect??Jp.layer_inspect,timelapse:i.timelapse??Jp.timelapse}:Jp),[v,S]=_.useState(()=>{if(t==="edit-queue-item"&&i){let Ve="asap";i.manual_start?Ve="manual":i.scheduled_time&&!E7(i.scheduled_time)&&(Ve="scheduled");let $e="";return i.scheduled_time&&!E7(i.scheduled_time)&&($e=new Date(i.scheduled_time).toISOString().slice(0,16)),{scheduleType:Ve,scheduledTime:$e,requirePreviousSuccess:i.require_previous_success,autoOffAfter:i.auto_off_after}}return y8e}),[N,T]=_.useState(()=>{if(t==="edit-queue-item"&&i?.ams_mapping&&Array.isArray(i.ams_mapping)){const Ve={};return i.ams_mapping.forEach(($e,ye)=>{$e!==-1&&(Ve[ye+1]=$e)}),Ve}return{}}),[k,C]=_.useState({}),[E,D]=_.useState(()=>t==="edit-queue-item"&&i?.target_model?"model":"printer"),[A,R]=_.useState(()=>t==="edit-queue-item"&&i?.target_model?i.target_model:null),[U,F]=_.useState(()=>t==="edit-queue-item"&&i?.target_location?i.target_location:null),[$]=_.useState(()=>t==="edit-queue-item"&&i?.printer_id?[i.printer_id]:[]),[j]=_.useState(()=>t==="edit-queue-item"&&i?i.plate_id:null),[H,K]=_.useState(!1),[V,Q]=_.useState({current:0,total:0}),[Z,ae]=_.useState(new Set),B=f.length,X=f.length>0?f[0]:null,{data:ne}=at({queryKey:["settings"],queryFn:ue.getSettings}),{data:se,isLoading:be}=at({queryKey:["printers"],queryFn:ue.getPrinters}),{data:xe}=at({queryKey:["archive",e],queryFn:()=>ue.getArchive(e),enabled:!!e&&!d}),de=xe?.sliced_for_model||null,{data:Pe,isError:ie}=at({queryKey:["archive-plates",e],queryFn:()=>ue.getArchivePlates(e),enabled:!!e&&!d,retry:!1}),{data:Ne}=at({queryKey:["library-file-plates",n],queryFn:()=>ue.getLibraryFilePlates(n),enabled:d&&!!n}),Oe=d?Ne:Pe,{data:ge,isError:Ke}=at({queryKey:["archive-filaments",e,m],queryFn:()=>ue.getArchiveFilamentRequirements(e,m??void 0),enabled:!!e&&!d&&(m!==null||!Oe?.is_multi_plate),retry:!1}),{data:G}=at({queryKey:["library-file-filaments",n,m],queryFn:()=>ue.getLibraryFileFilamentRequirements(n,m??void 0),enabled:d&&!!n&&(m!==null||!Oe?.is_multi_plate)}),Y=!d&&(ie||Ke),ce=d?G:ge,{data:q}=at({queryKey:["printer-status",X],queryFn:()=>ue.getPrinterStatus(X),enabled:!!X}),{amsMapping:te}=bee(ce,q,N),I=d8e(f,se,ce,N,k,C);_.useEffect(()=>{Oe?.plates?.length===1&&!m&&x(Oe.plates[0].index)},[Oe,m]),_.useEffect(()=>{if(t==="edit-queue-item")return;const Ve=se?.filter($e=>$e.is_active)||[];Ve.length===1&&f.length===0&&p([Ve[0].id])},[t,se,f.length]),_.useEffect(()=>{t==="edit-queue-item"?(JSON.stringify(f.sort())!==JSON.stringify($.sort())||m!==j)&&(T({}),C({}),ae(new Set)):(T({}),C({}),ae(new Set))},[t,f,m,$,j]),_.useEffect(()=>{if(!ne?.per_printer_mapping_expanded||f.length<=1)return;const Ve=f.filter($e=>{if(Z.has($e))return!1;const ye=I.printerResults.find(je=>je.printerId===$e);return ye&&ye.status&&!ye.isLoading});Ve.length>0&&(ae($e=>{const ye=new Set($e);return Ve.forEach(je=>ye.add(je)),ye}),Ve.forEach($e=>{I.autoConfigurePrinter($e)}))},[ne?.per_printer_mapping_expanded,f,Z,I]),_.useEffect(()=>{const Ve=$e=>{$e.key==="Escape"&&!H&&a()};return window.addEventListener("keydown",Ve),()=>window.removeEventListener("keydown",Ve)},[a,H]);const fe=Oe?.is_multi_plate??!1,me=Oe?.plates??[],Ee=mt({mutationFn:Ve=>ue.addToQueue(Ve)}),z=mt({mutationFn:Ve=>ue.updateQueueItem(i.id,Ve),onSuccess:()=>{c.invalidateQueries({queryKey:["queue"]}),u("Queue item updated"),o?.(),a()},onError:Ve=>{u(Ve.message||"Failed to update queue item","error")}}),O=async Ve=>{if(Ve?.preventDefault(),E==="printer"&&f.length===0){u("Please select at least one printer","error");return}if(E==="model"&&!A){u("Please select a target printer model","error");return}K(!0);const $e=E==="model"?1:f.length;Q({current:0,total:$e});const ye={success:0,failed:0,errors:[]},je=Se=>{if(f.length>1){const Xe=k[Se];if(Xe&&!Xe.useDefault)return I.getFinalMapping(Se)}return te},Be=Se=>({printer_id:E==="printer"?Se:null,target_model:E==="model"?A:null,target_location:E==="model"?U:null,archive_id:d?void 0:e,library_file_id:d?n:void 0,require_previous_success:v.requirePreviousSuccess,auto_off_after:v.autoOffAfter,manual_start:v.scheduleType==="manual",ams_mapping:Se?je(Se):void 0,plate_id:m,scheduled_time:v.scheduleType==="scheduled"&&v.scheduledTime?new Date(v.scheduledTime).toISOString():void 0,...b});if(E==="model"){Q({current:1,total:1});try{if(t==="reprint"){u("Model-based assignment only works with queue mode","error"),K(!1);return}else if(t==="edit-queue-item"){const Se={printer_id:null,target_model:A,target_location:U,require_previous_success:v.requirePreviousSuccess,auto_off_after:v.autoOffAfter,manual_start:v.scheduleType==="manual",ams_mapping:void 0,plate_id:m,scheduled_time:v.scheduleType==="scheduled"&&v.scheduledTime?new Date(v.scheduledTime).toISOString():null,...b};await z.mutateAsync(Se)}else await Ee.mutateAsync(Be(null));ye.success++}catch(Se){ye.failed++,ye.errors.push(Se.message)}}else for(let Se=0;Se<f.length;Se++){const Xe=f[Se];Q({current:Se+1,total:f.length});try{if(t==="reprint"){const Me=je(Xe);d?await ue.printLibraryFile(n,Xe,{ams_mapping:Me,...b}):await ue.reprintArchive(e,Xe,{plate_id:m??void 0,ams_mapping:Me,...b})}else if(t==="edit-queue-item"&&Se===0){const Me=je(Xe),tt={printer_id:Xe,target_model:null,target_location:null,require_previous_success:v.requirePreviousSuccess,auto_off_after:v.autoOffAfter,manual_start:v.scheduleType==="manual",ams_mapping:Me,plate_id:m,scheduled_time:v.scheduleType==="scheduled"&&v.scheduledTime?new Date(v.scheduledTime).toISOString():null,...b};await z.mutateAsync(tt)}else await Ee.mutateAsync(Be(Xe));ye.success++}catch(Me){ye.failed++;const tt=se?.find(ke=>ke.id===Xe)?.name||`Printer ${Xe}`;ye.errors.push(`${tt}: ${Me.message}`)}}if(K(!1),ye.failed===0){if(E==="model")u(t==="edit-queue-item"?"Queue item updated":`Queued for any ${A}`);else{const Se=t==="reprint"?"sent to":t==="edit-queue-item"?"updated/queued for":"queued for";ye.success===1?u(t==="edit-queue-item"?"Queue item updated":`Print ${Se} printer`):u(`Print ${Se} ${ye.success} printers`)}c.invalidateQueries({queryKey:["queue"]}),o?.(),a()}else ye.success===0?u(`Failed: ${ye.errors[0]}`,"error"):(u(`${ye.success} succeeded, ${ye.failed} failed`,"error"),c.invalidateQueries({queryKey:["queue"]}))},ee=H||z.isPending,le=_.useMemo(()=>!(ee||E==="printer"&&f.length===0||E==="model"&&!A||E==="model"&&t==="reprint"||!d&&fe&&!m),[f.length,E,A,t,fe,m,ee,d]),we=(()=>{const Ve=f.length;return t==="reprint"?{title:l(d?"queue.print":"queue.reprint"),icon:Ur,submitText:Ve>1?l("queue.printToPrinters",{count:Ve}):l("queue.print"),submitIcon:Ur,loadingText:V.total>1?l("queue.sendingProgress",{current:V.current,total:V.total}):l("queue.sending")}:t==="add-to-queue"?{title:l("queue.schedulePrint"),icon:si,submitText:Ve>1?l("queue.queueToPrinters",{count:Ve}):l("queue.addToQueue"),submitIcon:si,loadingText:V.total>1?l("queue.addingProgress",{current:V.current,total:V.total}):l("queue.adding")}:{title:l("queue.editQueueItem"),icon:Qi,submitText:l("common.save"),submitIcon:Qi,loadingText:V.total>1?l("queue.savingProgress",{current:V.current,total:V.total}):l("common.saving")}})(),re=we.icon,Fe=we.submitIcon,He=X&&(d||(fe?m!==null:!0));return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:H?void 0:a,children:s.jsx(_t,{className:"w-full max-w-lg max-h-[90vh] overflow-y-auto",onClick:Ve=>Ve.stopPropagation(),children:s.jsxs(Mt,{className:t==="reprint"?"":"p-0",children:[s.jsxs("div",{className:`flex items-center justify-between ${t==="reprint"?"mb-4":"p-4 border-b border-bambu-dark-tertiary"}`,children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(re,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:we.title})]}),s.jsx(Te,{variant:"ghost",size:"sm",onClick:a,disabled:H,children:s.jsx(Rt,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:O,className:t==="reprint"?"":"p-4 space-y-4",children:[s.jsx("p",{className:`text-sm text-bambu-gray ${t==="reprint"?"mb-4":""}`,children:t==="reprint"?s.jsxs(s.Fragment,{children:["Send ",s.jsx("span",{className:"text-white",children:r})," to printer(s)"]}):s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"block text-bambu-gray mb-1",children:"Print Job"}),s.jsx("span",{className:"text-white font-medium truncate block",children:r})]})}),s.jsx(m8e,{plates:me,isMultiPlate:fe,selectedPlate:m,onSelect:x}),s.jsx(f8e,{printers:se||[],selectedPrinterIds:f,onMultiSelect:p,isLoading:be,allowMultiple:!0,showInactive:t==="edit-queue-item",printerMappingResults:I.printerResults,filamentReqs:ce,onAutoConfigurePrinter:I.autoConfigurePrinter,onUpdatePrinterConfig:I.updatePrinterConfig,assignmentMode:t==="reprint"?"printer":E,onAssignmentModeChange:t!=="reprint"?D:void 0,targetModel:A,onTargetModelChange:t!=="reprint"?R:void 0,targetLocation:U,onTargetLocationChange:t!=="reprint"?F:void 0,slicedForModel:de}),de&&E==="printer"&&f.length===1&&(()=>{const Ve=se?.find($e=>$e.id===f[0]);return Ve&&Ve.model&&de!==Ve.model?s.jsxs("div",{className:"p-3 mb-2 bg-yellow-500/10 border border-yellow-500/30 rounded-lg flex items-center gap-2",children:[s.jsx(Cn,{className:"w-4 h-4 text-yellow-400 flex-shrink-0"}),s.jsxs("span",{className:"text-sm text-yellow-400",children:["File was sliced for ",de,", but printing on ",Ve.model]})]}):null})(),Y&&s.jsxs("div",{className:"flex items-start gap-2 p-3 mb-2 bg-orange-500/10 border border-orange-500/30 rounded-lg text-sm",children:[s.jsx(Hi,{className:"w-4 h-4 text-orange-400 mt-0.5 flex-shrink-0"}),s.jsx("p",{className:"text-orange-400",children:"Archive data unavailable. The source file may have been deleted. Filament mapping is disabled."})]}),He&&!Y&&f.length===1&&s.jsx(p8e,{printerId:X,filamentReqs:ce,manualMappings:N,onManualMappingChange:T,defaultExpanded:ne?.per_printer_mapping_expanded??!1}),(t==="reprint"||B>0||E==="model"&&A)&&s.jsx(x8e,{options:b,onChange:y}),t!=="reprint"&&s.jsx(b8e,{options:v,onChange:S}),z.isError&&s.jsx("div",{className:"mb-4 p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:z.error?.message||"Failed to complete operation"}),s.jsxs("div",{className:`flex gap-3 ${t==="reprint"?"":"pt-2"}`,children:[s.jsx(Te,{type:"button",variant:"secondary",onClick:a,className:"flex-1",disabled:H,children:"Cancel"}),s.jsx(Te,{type:"submit",disabled:!le,className:"flex-1",children:ee?s.jsxs(s.Fragment,{children:[s.jsx(ht,{className:"w-4 h-4 animate-spin"}),we.loadingText]}):s.jsxs(s.Fragment,{children:[s.jsx(Fe,{className:"w-4 h-4"}),we.submitText]})})]})]})]})})})}function v8e({onClose:t,initialFiles:e}){const{t:n}=Hn(),r=an(),{showToast:i}=$n(),a=_.useRef(null),[o,l]=_.useState(()=>e?.filter(k=>k.name.endsWith(".3mf")).map(k=>({file:k,status:"pending"}))||[]),[c,u]=_.useState(!1),[d,f]=_.useState(null);_.useEffect(()=>{const k=C=>{C.key==="Escape"&&t()};return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[t]);const p=mt({mutationFn:k=>ue.uploadArchivesBulk(k),onSuccess:k=>{f(k),r.invalidateQueries({queryKey:["archives"]}),r.invalidateQueries({queryKey:["archiveStats"]}),l(C=>C.map(E=>{const D=k.results.find(R=>R.filename===E.file.name),A=k.errors.find(R=>R.filename===E.file.name);return D?{...E,status:"success",archiveId:D.id}:A?{...E,status:"error",error:A.error}:E})),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(C=>({...C,status:"error",error:"Upload failed"}))),i("Upload failed","error")}}),m=_.useCallback(k=>{k.preventDefault(),u(!0)},[]),x=_.useCallback(k=>{k.preventDefault(),u(!1)},[]),b=_.useCallback(k=>{k.preventDefault(),u(!1);const C=Array.from(k.dataTransfer.files).filter(E=>E.name.endsWith(".3mf"));C.length>0&&l(E=>[...E,...C.map(D=>({file:D,status:"pending"}))])},[]),y=_.useCallback(k=>{const C=Array.from(k.target.files||[]).filter(E=>E.name.endsWith(".3mf"));C.length>0&&l(E=>[...E,...C.map(D=>({file:D,status:"pending"}))]),a.current&&(a.current.value="")},[]),v=_.useCallback(k=>{l(C=>C.filter((E,D)=>D!==k))},[]),S=()=>{if(o.length===0)return;const k=o.filter(C=>C.status==="pending");k.length!==0&&(l(C=>C.map(E=>E.status==="pending"?{...E,status:"uploading"}:E)),p.mutate(k.map(C=>C.file)))},N=o.filter(k=>k.status==="pending").length,T=p.isPending;return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:s.jsx(_t,{className:"w-full max-w-2xl max-h-[90vh] flex flex-col",children:s.jsxs(Mt,{className:"p-0 flex flex-col h-full",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsx("h2",{className:"text-xl font-semibold text-white",children:n("uploadModal.title")}),s.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(Rt,{className:"w-5 h-5"})})]}),s.jsx("div",{className:"p-4",children:s.jsxs("div",{className:`border-2 border-dashed rounded-lg p-8 text-center transition-colors ${c?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,onDragOver:m,onDragLeave:x,onDrop:b,children:[s.jsx(Ua,{className:"w-12 h-12 mx-auto mb-4 text-bambu-gray"}),s.jsx("p",{className:"text-white mb-2",children:n("uploadModal.dragDrop")}),s.jsx("p",{className:"text-bambu-gray text-sm mb-4",children:n("uploadModal.or")}),s.jsx(Te,{variant:"secondary",onClick:()=>a.current?.click(),disabled:T,children:n("uploadModal.browseFiles")}),s.jsx("input",{ref:a,type:"file",accept:".3mf",multiple:!0,className:"hidden",onChange:y})]})}),s.jsx("div",{className:"px-4 pb-4",children:s.jsx("p",{className:"text-xs text-bambu-gray",children:n("uploadModal.extractionInfo")})}),o.length>0&&s.jsx("div",{className:"px-4 pb-4 max-h-60 overflow-y-auto",children:s.jsx("div",{className:"space-y-2",children:o.map((k,C)=>s.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[s.jsx(cN,{className:"w-5 h-5 text-bambu-gray flex-shrink-0"}),s.jsx("span",{className:"flex-1 text-white text-sm truncate",children:k.file.name}),s.jsxs("span",{className:"text-xs text-bambu-gray",children:[(k.file.size/(1024*1024)).toFixed(1)," MB"]}),k.status==="pending"&&s.jsx("button",{onClick:()=>v(C),className:"text-bambu-gray hover:text-red-400 transition-colors",disabled:T,children:s.jsx(Rt,{className:"w-4 h-4"})}),k.status==="uploading"&&s.jsx(ht,{className:"w-4 h-4 text-bambu-green animate-spin"}),k.status==="success"&&s.jsx(Ar,{className:"w-4 h-4 text-bambu-green"}),k.status==="error"&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-xs text-red-400",children:k.error}),s.jsx(Hi,{className:"w-4 h-4 text-red-400"})]})]},`${k.file.name}-${C}`))})}),d&&s.jsx("div",{className:"px-4 pb-4",children:s.jsx("div",{className:"p-3 bg-bambu-dark rounded-lg",children:s.jsxs("p",{className:"text-sm text-white",children:[s.jsx("span",{className:"text-bambu-green",children:d.uploaded})," ",n("uploadModal.uploaded"),d.failed>0&&s.jsxs(s.Fragment,{children:[", ",s.jsx("span",{className:"text-red-400",children:d.failed})," ",n("uploadModal.failed")]})]})})}),s.jsxs("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary",children:[s.jsx(Te,{variant:"secondary",onClick:t,className:"flex-1",children:n(d?"common.close":"common.cancel")}),!d&&s.jsx(Te,{onClick:S,disabled:N===0||T,className:"flex-1",children:T?s.jsxs(s.Fragment,{children:[s.jsx(ht,{className:"w-4 h-4 animate-spin"}),n("uploadModal.uploading")]}):s.jsxs(s.Fragment,{children:[s.jsx(Ua,{className:"w-4 h-4"}),n("uploadModal.upload")," ",N>0&&`(${N})`]})})]})]})})})}const w8e=["adhesionFailure","spaghettiDetached","layerShift","cloggedNozzle","filamentRunout","warping","stringing","underExtrusion","powerFailure","userCancelled","other"],_8e=["completed","failed","aborted","printing"];function yee({archive:t,onClose:e,existingTags:n=[]}){const{t:r}=Hn();_.useEffect(()=>{const ie=Ne=>{Ne.key==="Escape"&&e()};return window.addEventListener("keydown",ie),()=>window.removeEventListener("keydown",ie)},[e]);const i=an(),[a,o]=_.useState(t.print_name||""),[l,c]=_.useState(t.printer_id),[u,d]=_.useState(t.project_id??null),[f,p]=_.useState(t.notes||""),[m,x]=_.useState(t.tags||""),[b,y]=_.useState(t.failure_reason||""),[v,S]=_.useState(t.status),[N,T]=_.useState(t.quantity??1),[k,C]=_.useState(t.photos||[]),[E,D]=_.useState(t.external_url||""),[A,R]=_.useState(!1),[U,F]=_.useState(!1),$=_.useRef(null),j=_.useRef(null),H=_.useRef(null),{data:K}=at({queryKey:["printers"],queryFn:ue.getPrinters}),{data:V}=at({queryKey:["projects"],queryFn:()=>ue.getProjects()}),{data:Q}=at({queryKey:["tags"],queryFn:ue.getTags,enabled:n.length===0}),Z=n.length>0?n:Q?.map(ie=>ie.name)||[],ae=m.split(",").map(ie=>ie.trim()).filter(Boolean),B=m.includes(",")?m.substring(m.lastIndexOf(",")+1).trim().toLowerCase():m.trim().toLowerCase(),X=Z.filter(ie=>!ae.includes(ie)&&(B===""||ie.toLowerCase().includes(B))),ne=ie=>{let Ne;if(B&&!Z.includes(B)?Ne=m.includes(",")?m.substring(0,m.lastIndexOf(",")).split(",").map(Oe=>Oe.trim()).filter(Boolean):[]:Ne=ae,!Ne.includes(ie)){const Oe=[...Ne,ie].join(", ");x(Oe)}H.current!==null&&clearTimeout(H.current),$.current?.focus()},se=ie=>{const Ne=ae.filter(Oe=>Oe!==ie).join(", ");x(Ne)},be=mt({mutationFn:ie=>ue.updateArchive(t.id,ie),onSuccess:()=>{i.invalidateQueries({queryKey:["archives"]}),i.invalidateQueries({queryKey:["projects"]}),e()}}),xe=async ie=>{const Ne=ie.target.files?.[0];if(Ne){R(!0);try{const Oe=await ue.uploadArchivePhoto(t.id,Ne);C(Oe.photos),i.invalidateQueries({queryKey:["archives"]})}catch(Oe){console.error("Failed to upload photo:",Oe)}finally{R(!1),j.current&&(j.current.value="")}}},de=async ie=>{try{const Ne=await ue.deleteArchivePhoto(t.id,ie);C(Ne.photos||[]),i.invalidateQueries({queryKey:["archives"]})}catch(Ne){console.error("Failed to delete photo:",Ne)}},Pe=ie=>{ie.preventDefault();const Ne={print_name:a||void 0,printer_id:l,project_id:u,notes:f||void 0,tags:m||void 0,quantity:N,external_url:E||null};v!==t.status&&(Ne.status=v),v==="failed"||v==="aborted"?Ne.failure_reason=b||void 0:(t.status==="failed"||t.status==="aborted")&&(Ne.failure_reason=null),be.mutate(Ne)};return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-md max-h-[90vh] flex flex-col",onClick:ie=>ie.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:r("editArchive.title")}),s.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(Rt,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:Pe,className:"p-6 space-y-4 overflow-y-auto flex-1",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("editArchive.name")}),s.jsx("input",{type:"text",value:a,onChange:ie=>o(ie.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",placeholder:r("editArchive.namePlaceholder")})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("editArchive.printer")}),s.jsxs("select",{value:l??"",onChange:ie=>c(ie.target.value?Number(ie.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"",children:r("editArchive.noPrinter")}),K?.map(ie=>s.jsx("option",{value:ie.id,children:ie.name},ie.id))]})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[s.jsx(Ja,{className:"w-4 h-4 inline mr-1"}),r("editArchive.project")]}),s.jsxs("select",{value:u??"",onChange:ie=>d(ie.target.value?Number(ie.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"",children:r("editArchive.noProject")}),V?.map(ie=>s.jsx("option",{value:ie.id,children:ie.name},ie.id))]})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[s.jsx(ede,{className:"w-4 h-4 inline mr-1"}),r("editArchive.itemsPrinted")]}),s.jsx("input",{type:"number",min:1,value:N,onChange:ie=>T(Math.max(1,parseInt(ie.target.value)||1)),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",placeholder:"1"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:r("editArchive.itemsPrintedHelp")})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("editArchive.notes")}),s.jsx("textarea",{value:f,onChange:ie=>p(ie.target.value),rows:3,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none resize-none",placeholder:r("editArchive.notesPlaceholder")})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[s.jsx(Fy,{className:"w-4 h-4 inline mr-1"}),r("editArchive.externalLink")]}),s.jsx("input",{type:"url",value:E,onChange:ie=>D(ie.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",placeholder:"https://printables.com/model/..."}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:r("editArchive.externalLinkHelp")})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("editArchive.tags")}),ae.length>0&&s.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:ae.map(ie=>s.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 bg-bambu-dark-tertiary rounded text-sm text-white",children:[s.jsx(yh,{className:"w-3 h-3"}),ie,s.jsx("button",{type:"button",onClick:()=>se(ie),className:"ml-0.5 text-bambu-gray hover:text-white",children:s.jsx(Rt,{className:"w-3 h-3"})})]},ie))}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{ref:$,type:"text",value:m,onChange:ie=>x(ie.target.value),onFocus:()=>{H.current!==null&&clearTimeout(H.current),F(!0)},onBlur:()=>{H.current=window.setTimeout(()=>F(!1),200)},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",placeholder:ae.length>0?r("editArchive.addMoreTags"):r("editArchive.tagsPlaceholder")}),U&&X.length>0&&s.jsxs("div",{className:"absolute top-full left-0 right-0 mt-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg z-10 max-h-40 overflow-y-auto",children:[s.jsxs("div",{className:"p-2 text-xs text-bambu-gray border-b border-bambu-dark-tertiary",children:[B?r("editArchive.matchingTags",{query:B}):r("editArchive.existingTags")," ",r("editArchive.clickToAdd")]}),s.jsx("div",{className:"p-2 flex flex-wrap gap-1.5",children:X.map(ie=>s.jsx("button",{type:"button",onClick:()=>ne(ie),className:"px-2 py-0.5 bg-bambu-dark-tertiary hover:bg-bambu-green/20 rounded text-sm text-bambu-gray hover:text-white transition-colors",children:ie},ie))})]})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("editArchive.status")}),s.jsx("select",{value:v,onChange:ie=>{S(ie.target.value),ie.target.value==="completed"&&y("")},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:_8e.map(ie=>s.jsx("option",{value:ie,children:r(`editArchive.statuses.${ie}`)},ie))})]}),(v==="failed"||v==="aborted")&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("editArchive.failureReason")}),s.jsxs("select",{value:b,onChange:ie=>y(ie.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"",children:r("editArchive.selectReason")}),w8e.map(ie=>s.jsx("option",{value:r(`editArchive.failureReasons.${ie}`),children:r(`editArchive.failureReasons.${ie}`)},ie))]})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[s.jsx(Ug,{className:"w-4 h-4 inline mr-1"}),r("editArchive.photos")]}),s.jsxs("div",{className:"flex flex-wrap gap-2 mb-2",children:[k.map(ie=>s.jsxs("div",{className:"relative group",children:[s.jsx("img",{src:ue.getArchivePhotoUrl(t.id,ie),alt:r("editArchive.printResult"),className:"w-20 h-20 object-cover rounded-lg border border-bambu-dark-tertiary"}),s.jsx("button",{type:"button",onClick:()=>de(ie),className:"absolute -top-1 -right-1 p-1 bg-red-500 rounded-full opacity-0 group-hover:opacity-100 transition-opacity",children:s.jsx(rn,{className:"w-3 h-3 text-white"})})]},ie)),s.jsxs("label",{className:"w-20 h-20 flex items-center justify-center border-2 border-dashed border-bambu-dark-tertiary rounded-lg cursor-pointer hover:border-bambu-green transition-colors",children:[s.jsx("input",{ref:j,type:"file",accept:"image/jpeg,image/png,image/webp",onChange:xe,className:"hidden",disabled:A}),A?s.jsx(ht,{className:"w-6 h-6 text-bambu-gray animate-spin"}):s.jsx(dr,{className:"w-6 h-6 text-bambu-gray"})]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:r("editArchive.photosHelp")})]}),s.jsxs("div",{className:"flex gap-3 pt-2",children:[s.jsx(Te,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:r("common.cancel")}),s.jsxs(Te,{type:"submit",disabled:be.isPending,className:"flex-1",children:[s.jsx(hs,{className:"w-4 h-4"}),be.isPending?r("common.saving"):r("common.save")]})]})]})]})})}function vee({x:t,y:e,items:n,onClose:r}){const i=_.useRef(null),[a,o]=_.useState(null),l=_.useRef(null),[c,u]=_.useState({x:t,y:e,visible:!1}),[d,f]=_.useState(!1),[p,m]=_.useState({});_.useEffect(()=>{const y=N=>{i.current&&!i.current.contains(N.target)&&r()},v=N=>{N.key==="Escape"&&r()},S=()=>{r()};return document.addEventListener("mousedown",y),document.addEventListener("keydown",v),document.addEventListener("scroll",S,!0),()=>{document.removeEventListener("mousedown",y),document.removeEventListener("keydown",v),document.removeEventListener("scroll",S,!0),l.current&&clearTimeout(l.current)}},[r]),_.useLayoutEffect(()=>{if(i.current){i.current.style.visibility="hidden",i.current.style.display="block";const y=i.current.getBoundingClientRect(),v=window.innerWidth,S=window.innerHeight,N=8;let T=t,k=e;t+y.width>v-N&&(T=Math.max(N,v-y.width-N)),T<N&&(T=N),e+y.height>S-N&&(k=Math.max(N,S-y.height-N)),k<N&&(k=N);const C=180,E=v-T-y.width,D=T;f(E<C&&D>C),u({x:T,y:k,visible:!0})}},[t,e]);const x=(y,v)=>{l.current&&(clearTimeout(l.current),l.current=null);const S=v.getBoundingClientRect(),N=window.innerHeight,T=300,E=N-S.top-8<T&&S.top>T;m(D=>({...D,[y]:E?"bottom":"top"})),o(y)},b=()=>{l.current=window.setTimeout(()=>{o(null)},150)};return s.jsx("div",{ref:i,className:"fixed z-50 min-w-[180px] max-w-[280px] bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1",style:{left:c.x,top:c.y,visibility:c.visible?"visible":"hidden"},children:n.map((y,v)=>{if(y.divider)return s.jsx("div",{className:"my-1 border-t border-bambu-dark-tertiary"},v);const S=y.submenu&&y.submenu.length>0;return s.jsxs("div",{className:"relative",onMouseEnter:N=>S&&x(v,N.currentTarget),onMouseLeave:()=>S&&b(),children:[s.jsxs("button",{onMouseEnter:N=>S&&x(v,N.currentTarget.parentElement),onClick:()=>{S?o(a===v?null:v):y.disabled||(y.onClick(),r())},disabled:y.disabled,title:y.title,className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-left transition-colors ${y.disabled?"text-bambu-gray cursor-not-allowed":y.danger?"text-red-400 hover:bg-red-400/10":"text-white hover:bg-bambu-dark-tertiary"} ${S&&a===v?"bg-bambu-dark-tertiary":""}`,children:[y.icon&&s.jsx("span",{className:"w-4 h-4 flex-shrink-0 flex items-center justify-center",children:y.icon}),s.jsx("span",{className:"flex-1",children:y.label}),S&&s.jsx(gs,{className:"w-4 h-4 text-bambu-gray"})]}),S&&a===v&&s.jsx("div",{className:`absolute min-w-[160px] bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 overflow-hidden max-h-[300px] overflow-y-auto z-[60] ${d?"right-full mr-1":"left-full ml-1"} ${p[v]==="bottom"?"bottom-0":"top-0"}`,onMouseEnter:()=>{l.current&&(clearTimeout(l.current),l.current=null)},onMouseLeave:()=>b(),children:y.submenu.map((N,T)=>s.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&&s.jsx("span",{className:"w-4 h-4 flex-shrink-0 flex items-center justify-center",children:N.icon}),N.label]},T))})]},v)})})}function S8e({selectedIds:t,existingTags:e,onClose:n}){const r=an(),{showToast:i}=$n(),[a,o]=_.useState(""),[l,c]=_.useState(new Set),[u,d]=_.useState("add");_.useEffect(()=>{const b=y=>{y.key==="Escape"&&n()};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[n]);const f=mt({mutationFn:async()=>{const b=Array.from(l);let y=0;for(const v of t)try{const S=await ue.getArchive(v),N=S.tags?S.tags.split(",").map(k=>k.trim()).filter(Boolean):[];let T;u==="add"?T=[...new Set([...N,...b])]:T=N.filter(k=>!l.has(k)),await ue.updateArchive(v,{tags:T.join(", ")}),y++}catch(S){throw console.error(`Failed to update archive ${v}:`,S),new Error(`Failed on archive ${v}: ${S instanceof Error?S.message:"Unknown error"}`)}return{count:y,mode:u,tags:b}},onSuccess:({count:b,mode:y,tags:v})=>{r.invalidateQueries({queryKey:["archives"]}),i(`${y==="add"?"Added":"Removed"} ${v.length} tag${v.length!==1?"s":""} ${y==="add"?"to":"from"} ${b} archive${b!==1?"s":""}`),n()},onError:b=>{i(b.message||"Failed to update tags","error")}}),p=b=>{c(y=>{const v=new Set(y);return v.has(b)?v.delete(b):v.add(b),v})},m=()=>{a.trim()&&!l.has(a.trim())&&(c(b=>new Set([...b,a.trim()])),o(""))},x=b=>{b.key==="Enter"&&(b.preventDefault(),m())};return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:s.jsx(_t,{className:"w-full max-w-md",children:s.jsxs(Mt,{className:"p-0",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(yh,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-xl font-semibold text-white",children:u==="add"?"Add Tags":"Remove Tags"})]}),s.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(Rt,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"p-4 space-y-4",children:[s.jsxs("p",{className:"text-sm text-bambu-gray",children:[u==="add"?"Add":"Remove"," tags for ",t.length," selected archive",t.length!==1?"s":""]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Te,{size:"sm",variant:u==="add"?"primary":"secondary",onClick:()=>d("add"),children:"Add Tags"}),s.jsx(Te,{size:"sm",variant:u==="remove"?"primary":"secondary",onClick:()=>d("remove"),children:"Remove Tags"})]}),u==="add"&&s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{type:"text",placeholder:"Enter new tag...",className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",value:a,onChange:b=>o(b.target.value),onKeyDown:x}),s.jsx(Te,{size:"sm",variant:"secondary",onClick:m,disabled:!a.trim(),children:s.jsx(dr,{className:"w-4 h-4"})})]}),e.length>0&&s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:"Existing tags:"}),s.jsx("div",{className:"flex flex-wrap gap-2",children:e.map(b=>s.jsx("button",{onClick:()=>p(b),className:`px-2 py-1 rounded text-sm transition-colors ${l.has(b)?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray-light hover:bg-bambu-dark"}`,children:b},b))})]}),l.size>0&&s.jsxs("div",{children:[s.jsxs("p",{className:"text-xs text-bambu-gray mb-2",children:["Tags to ",u==="add"?"add":"remove",":"]}),s.jsx("div",{className:"flex flex-wrap gap-2",children:Array.from(l).map(b=>s.jsxs("span",{className:`px-2 py-1 rounded text-sm flex items-center gap-1 ${u==="add"?"bg-green-500/20 text-green-400":"bg-red-500/20 text-red-400"}`,children:[b,s.jsx("button",{onClick:()=>p(b),className:"hover:opacity-70",children:s.jsx(Rt,{className:"w-3 h-3"})})]},b))})]})]}),s.jsxs("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary",children:[s.jsx(Te,{variant:"secondary",onClick:n,className:"flex-1",children:"Cancel"}),s.jsx(Te,{onClick:()=>f.mutate(),disabled:l.size===0||f.isPending,className:"flex-1",children:f.isPending?s.jsxs(s.Fragment,{children:[s.jsx(ht,{className:"w-4 h-4 animate-spin"}),"Processing..."]}):s.jsxs(s.Fragment,{children:[s.jsx(yh,{className:"w-4 h-4"}),u==="add"?"Add Tags":"Remove Tags"]})})]})]})})})}function M8e({selectedIds:t,onClose:e}){const n=an(),{showToast:r}=$n(),{data:i,isLoading:a}=at({queryKey:["projects"],queryFn:()=>ue.getProjects()});_.useEffect(()=>{const d=f=>{f.key==="Escape"&&e()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[e]);const o=()=>{n.invalidateQueries({queryKey:["archives"]}),n.invalidateQueries({queryKey:["projects"]}),n.invalidateQueries({queryKey:["project"]}),n.invalidateQueries({queryKey:["project-archives"]})},l=mt({mutationFn:async d=>(await ue.addArchivesToProject(d,t),d),onSuccess:d=>{const f=i?.find(p=>p.id===d);o(),r(`Added ${t.length} archive${t.length!==1?"s":""} to "${f?.name}"`),e()},onError:()=>{r("Failed to assign project","error")}}),c=mt({mutationFn:async()=>{for(const d of t)await ue.updateArchive(d,{project_id:null});return t.length},onSuccess:d=>{o(),r(`Removed ${d} archive${d!==1?"s":""} from project`),e()},onError:()=>{r("Failed to remove from project","error")}}),u=l.isPending||c.isPending;return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:s.jsx(_t,{className:"w-full max-w-md max-h-[80vh] flex flex-col",children:s.jsxs(Mt,{className:"p-0 flex flex-col min-h-0",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ja,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-xl font-semibold text-white",children:"Assign to Project"})]}),s.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",disabled:u,children:s.jsx(Rt,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"p-4 space-y-3 overflow-y-auto min-h-0",children:[s.jsxs("p",{className:"text-sm text-bambu-gray",children:["Assign ",t.length," selected archive",t.length!==1?"s":""," to a project"]}),a?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx(ht,{className:"w-6 h-6 animate-spin text-bambu-gray"})}):s.jsxs("div",{className:"space-y-2",children:[s.jsxs("button",{onClick:()=>c.mutate(),disabled:u,className:"w-full flex items-center gap-3 p-3 rounded-lg bg-bambu-dark hover:bg-bambu-dark-tertiary border border-bambu-dark-tertiary transition-colors text-left disabled:opacity-50",children:[s.jsx("div",{className:"w-8 h-8 rounded-full bg-red-500/20 flex items-center justify-center shrink-0",children:s.jsx(Yi,{className:"w-4 h-4 text-red-400"})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"text-white font-medium",children:"Remove from project"}),s.jsx("p",{className:"text-sm text-bambu-gray truncate",children:"Clear project assignment"})]}),c.isPending&&s.jsx(ht,{className:"w-4 h-4 animate-spin text-bambu-gray shrink-0"})]}),i&&i.length>0&&s.jsxs("div",{className:"flex items-center gap-2 py-2",children:[s.jsx("div",{className:"flex-1 h-px bg-bambu-dark-tertiary"}),s.jsx("span",{className:"text-xs text-bambu-gray",children:"or assign to"}),s.jsx("div",{className:"flex-1 h-px bg-bambu-dark-tertiary"})]}),i?.map(d=>s.jsxs("button",{onClick:()=>l.mutate(d.id),disabled:u,className:"w-full flex items-center gap-3 p-3 rounded-lg bg-bambu-dark hover:bg-bambu-dark-tertiary border border-bambu-dark-tertiary transition-colors text-left disabled:opacity-50",children:[s.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center shrink-0",style:{backgroundColor:d.color?`${d.color}20`:"rgb(var(--bambu-green) / 0.2)"},children:s.jsx(Ja,{className:"w-4 h-4",style:{color:d.color||"rgb(var(--bambu-green))"}})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"text-white font-medium truncate",children:d.name}),s.jsxs("p",{className:"text-sm text-bambu-gray truncate",children:[d.archive_count," archive",d.archive_count!==1?"s":"",d.status&&` • ${d.status}`]})]}),l.isPending&&l.variables===d.id&&s.jsx(ht,{className:"w-4 h-4 animate-spin text-bambu-gray shrink-0"})]},d.id)),(!i||i.length===0)&&s.jsx("p",{className:"text-center text-bambu-gray py-4",children:"No projects yet. Create one from the Projects page."})]})]}),s.jsx("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary shrink-0",children:s.jsx(Te,{variant:"secondary",onClick:e,className:"flex-1",disabled:u,children:"Cancel"})})]})})})}function N8e(t,e){return new Date(t,e+1,0).getDate()}function k8e(t,e){return new Date(t,e,1).getDay()}const E8e=["January","February","March","April","May","June","July","August","September","October","November","December"],T8e=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function A8e({archives:t,onArchiveClick:e,highlightedArchiveId:n}){const r=new Date,[i,a]=_.useState(r.getMonth()),[o,l]=_.useState(r.getFullYear()),[c,u]=_.useState(null),[d,f]=_.useState(null),p=_.useMemo(()=>{const k=new Map;return t.forEach(C=>{const E=Ii(C.completed_at||C.created_at)||new Date,D=`${E.getFullYear()}-${String(E.getMonth()+1).padStart(2,"0")}-${String(E.getDate()).padStart(2,"0")}`,A=k.get(D)||[];A.push(C),k.set(D,A)}),k},[t]),m=N8e(o,i),x=k8e(o,i),b=()=>{i===0?(a(11),l(o-1)):a(i-1)},y=()=>{i===11?(a(0),l(o+1)):a(i+1)},v=()=>{a(r.getMonth()),l(r.getFullYear())},S=[];for(let k=0;k<x;k++)S.push(null);for(let k=1;k<=m;k++)S.push(k);const N=c?p.get(c)||[]:[],T=k=>{k!==c&&f(null),u(k)};return s.jsxs("div",{className:"flex flex-col lg:flex-row gap-6",children:[s.jsxs("div",{className:"flex-1",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsx("button",{onClick:b,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:s.jsx(gh,{className:"w-5 h-5 text-bambu-gray"})}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white",children:[E8e[i]," ",o]}),s.jsx("button",{onClick:v,className:"px-2 py-1 text-xs bg-bambu-dark-tertiary hover:bg-bambu-green/20 text-bambu-gray hover:text-white rounded transition-colors",children:"Today"})]}),s.jsx("button",{onClick:y,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:s.jsx(gs,{className:"w-5 h-5 text-bambu-gray"})})]}),s.jsx("div",{className:"grid grid-cols-7 gap-1 mb-1",children:T8e.map(k=>s.jsx("div",{className:"text-center text-xs text-bambu-gray py-2",children:k},k))}),s.jsx("div",{className:"grid grid-cols-7 gap-1",children:S.map((k,C)=>{if(k===null)return s.jsx("div",{className:"aspect-square"},`empty-${C}`);const E=`${o}-${String(i+1).padStart(2,"0")}-${String(k).padStart(2,"0")}`,D=p.get(E)||[],A=D.length>0,R=k===r.getDate()&&i===r.getMonth()&&o===r.getFullYear(),U=E===c,F=D.filter(j=>j.status==="completed").length,$=D.filter(j=>j.status==="failed").length;return s.jsxs("button",{onClick:()=>T(U?null:E),className:`aspect-square rounded-lg p-1 flex flex-col items-center justify-center transition-colors relative ${U?"bg-bambu-green text-white":R?"bg-bambu-green/20 text-white ring-2 ring-bambu-green":A?"bg-bambu-dark-tertiary hover:bg-bambu-dark-tertiary/70 text-white":"hover:bg-bambu-dark-tertiary/50 text-bambu-gray"}`,children:[s.jsx("span",{className:`text-sm font-medium ${R&&!U?"text-bambu-green":""}`,children:k}),A&&s.jsxs("div",{className:"absolute bottom-1 left-1/2 -translate-x-1/2 flex items-center gap-1",children:[s.jsx("div",{className:`w-2 h-2 rounded-full ${$>0&&F===0?"bg-red-400":$>0?"bg-yellow-400":"bg-green-400"}`}),s.jsx("span",{className:"text-xs font-medium",children:D.length})]})]},k)})}),s.jsx("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:s.jsxs("div",{className:"grid grid-cols-3 gap-4 text-center",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-2xl font-bold text-white",children:t.filter(k=>{const C=new Date(k.completed_at||k.created_at);return C.getMonth()===i&&C.getFullYear()===o}).length}),s.jsx("div",{className:"text-xs text-bambu-gray",children:"Prints this month"})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-2xl font-bold text-green-400",children:t.filter(k=>{const C=new Date(k.completed_at||k.created_at);return C.getMonth()===i&&C.getFullYear()===o&&k.status==="completed"}).length}),s.jsx("div",{className:"text-xs text-bambu-gray",children:"Successful"})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-2xl font-bold text-red-400",children:t.filter(k=>{const C=new Date(k.completed_at||k.created_at);return C.getMonth()===i&&C.getFullYear()===o&&k.status==="failed"}).length}),s.jsx("div",{className:"text-xs text-bambu-gray",children:"Failed"})]})]})})]}),s.jsx("div",{className:"lg:w-80 bg-bambu-dark rounded-xl p-4",children:c?s.jsxs(s.Fragment,{children:[s.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-3",children:new Date(c+"T12:00:00").toLocaleDateString("en-US",{weekday:"long",month:"long",day:"numeric",year:"numeric"})}),N.length>0?s.jsx("div",{className:"space-y-2 max-h-96 overflow-y-auto",children:N.map(k=>{const C=k.id===d||k.id===n;return s.jsxs("button",{onClick:()=>{f(k.id),e?.(k)},className:`w-full flex items-center gap-3 p-2 rounded-lg transition-colors text-left ${C?"":"hover:bg-bambu-dark-tertiary"}`,style:C?{outline:"4px solid #facc15",outlineOffset:"2px"}:void 0,children:[k.thumbnail_path?s.jsx("img",{src:ue.getArchiveThumbnail(k.id),alt:"",className:"w-12 h-12 rounded object-cover"}):s.jsx("div",{className:"w-12 h-12 rounded bg-bambu-dark-tertiary flex items-center justify-center",children:s.jsx("span",{className:"text-xs text-bambu-gray",children:"3MF"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-sm text-white truncate",children:k.print_name||k.filename}),s.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[s.jsx("span",{className:k.status==="failed"?"text-red-400":"text-green-400",children:k.status==="failed"?"Failed":"Completed"}),k.filament_color&&s.jsx("div",{className:"flex gap-0.5",children:k.filament_color.split(",").map((E,D)=>s.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:E}},D))})]})]})]},k.id)})}):s.jsx("p",{className:"text-sm text-bambu-gray",children:"No prints on this day"})]}):s.jsx("div",{className:"text-center py-8",children:s.jsx("p",{className:"text-sm text-bambu-gray",children:"Select a day to see prints"})})})]})}function wee({archiveId:t,archiveName:e,onClose:n}){const r=ue.getArchiveQRCodeUrl(t,300);_.useEffect(()=>{const a=o=>{o.key==="Escape"&&n()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[n]);const i=()=>{const a=document.createElement("a");a.href=r,a.download=`${e}_qrcode.png`,a.click()};return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:n,children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-sm",onClick:a=>a.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:"QR Code"}),s.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(Rt,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"p-6 flex flex-col items-center",children:[s.jsx("p",{className:"text-sm text-bambu-gray mb-4 text-center truncate max-w-full",children:e}),s.jsx("div",{className:"bg-white p-4 rounded-lg mb-4",children:s.jsx("img",{src:r,alt:"QR Code",className:"w-64 h-64"})}),s.jsx("p",{className:"text-xs text-bambu-gray mb-4 text-center",children:"Scan to open this archive"}),s.jsxs(Te,{onClick:i,className:"w-full",children:[s.jsx(yi,{className:"w-4 h-4"}),"Download QR Code"]})]})]})})}function _ee({archiveId:t,archiveName:e,photos:n,onClose:r,onDelete:i}){const[a,o]=_.useState(0),[l,c]=_.useState(!1);if(_.useEffect(()=>{const m=x=>{x.key==="Escape"&&r(),x.key==="ArrowLeft"&&o(b=>Math.max(0,b-1)),x.key==="ArrowRight"&&o(b=>Math.min(n.length-1,b+1))};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[r,n.length]),_.useEffect(()=>{a>=n.length&&o(Math.max(0,n.length-1))},[n.length,a]),n.length===0)return r(),null;const u=n[a],d=ue.getArchivePhotoUrl(t,u),f=()=>{const m=document.createElement("a");m.href=d,m.download=`${e}_photo_${a+1}.jpg`,m.click()},p=()=>{i&&c(!0)};return s.jsxs("div",{className:"fixed inset-0 bg-black/90 flex items-center justify-center z-50",onClick:r,children:[s.jsxs("div",{className:"relative w-full h-full flex flex-col",onClick:m=>m.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 bg-black/50",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:e}),s.jsxs("p",{className:"text-sm text-bambu-gray",children:["Photo ",a+1," of ",n.length]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(Te,{variant:"secondary",size:"sm",onClick:f,children:[s.jsx(yi,{className:"w-4 h-4"}),"Download"]}),i&&s.jsx(Te,{variant:"secondary",size:"sm",onClick:p,className:"text-red-400 hover:text-red-300",children:s.jsx(rn,{className:"w-4 h-4"})}),s.jsx("button",{onClick:r,className:"p-2 text-bambu-gray hover:text-white transition-colors",children:s.jsx(Rt,{className:"w-6 h-6"})})]})]}),s.jsxs("div",{className:"flex-1 min-h-0 flex items-center justify-center p-4 relative overflow-hidden",children:[a>0&&s.jsx("button",{onClick:()=>o(m=>m-1),className:"absolute left-4 z-10 p-3 bg-black/50 hover:bg-black/70 rounded-full transition-colors",children:s.jsx(gh,{className:"w-8 h-8 text-white"})}),s.jsx("img",{src:d,alt:`Photo ${a+1}`,className:"max-w-full max-h-full object-contain rounded-lg",style:{maxHeight:"calc(100vh - 200px)"}}),a<n.length-1&&s.jsx("button",{onClick:()=>o(m=>m+1),className:"absolute right-4 z-10 p-3 bg-black/50 hover:bg-black/70 rounded-full transition-colors",children:s.jsx(gs,{className:"w-8 h-8 text-white"})})]}),n.length>1&&s.jsx("div",{className:"flex justify-center gap-2 p-4 bg-black/50",children:n.map((m,x)=>s.jsx("button",{onClick:()=>o(x),className:`w-16 h-16 rounded-lg overflow-hidden border-2 transition-colors ${x===a?"border-bambu-green":"border-transparent hover:border-bambu-gray"}`,children:s.jsx("img",{src:ue.getArchivePhotoUrl(t,m),alt:`Thumbnail ${x+1}`,className:"w-full h-full object-cover"})},m))})]}),l&&s.jsx(Zn,{title:"Delete Photo",message:"Delete this photo? This cannot be undone.",confirmText:"Delete",variant:"danger",onConfirm:()=>{i?.(u),c(!1)},onCancel:()=>c(!1)})]})}function Pa(t){this.content=t}Pa.prototype={constructor:Pa,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return e==-1?void 0:this.content[e+1]},update:function(t,e,n){var r=n&&n!=t?this.remove(n):this,i=r.find(t),a=r.content.slice();return i==-1?a.push(n||t,e):(a[i+1]=e,n&&(a[i]=n)),new Pa(a)},remove:function(t){var e=this.find(t);if(e==-1)return this;var n=this.content.slice();return n.splice(e,2),new Pa(n)},addToStart:function(t,e){return new Pa([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new Pa(n)},addBefore:function(t,e,n){var r=this.remove(e),i=r.content.slice(),a=r.find(t);return i.splice(a==-1?i.length:a,0,e,n),new Pa(i)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){return t=Pa.from(t),t.size?new Pa(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=Pa.from(t),t.size?new Pa(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=Pa.from(t);for(var n=0;n<t.content.length;n+=2)e=e.remove(t.content[n]);return e},toObject:function(){var t={};return this.forEach(function(e,n){t[e]=n}),t},get size(){return this.content.length>>1}};Pa.from=function(t){if(t instanceof Pa)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new Pa(e)};function See(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let i=t.child(r),a=e.child(r);if(i==a){n+=i.nodeSize;continue}if(!i.sameMarkup(a))return n;if(i.isText&&i.text!=a.text){for(let o=0;i.text[o]==a.text[o];o++)n++;return n}if(i.content.size||a.content.size){let o=See(i.content,a.content,n+1);if(o!=null)return o}n+=i.nodeSize}}function Mee(t,e,n,r){for(let i=t.childCount,a=e.childCount;;){if(i==0||a==0)return i==a?null:{a:n,b:r};let o=t.child(--i),l=e.child(--a),c=o.nodeSize;if(o==l){n-=c,r-=c;continue}if(!o.sameMarkup(l))return{a:n,b:r};if(o.isText&&o.text!=l.text){let u=0,d=Math.min(o.text.length,l.text.length);for(;u<d&&o.text[o.text.length-u-1]==l.text[l.text.length-u-1];)u++,n--,r--;return{a:n,b:r}}if(o.content.size||l.content.size){let u=Mee(o.content,l.content,n-1,r-1);if(u)return u}n-=c,r-=c}}class kt{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,n,r,i=0,a){for(let o=0,l=0;l<n;o++){let c=this.content[o],u=l+c.nodeSize;if(u>e&&r(c,i+l,a||null,o)!==!1&&c.content.size){let d=l+1;c.nodesBetween(Math.max(0,e-d),Math.min(c.content.size,n-d),r,i+d)}l=u}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,i){let a="",o=!0;return this.nodesBetween(e,n,(l,c)=>{let u=l.isText?l.text.slice(Math.max(e,c)-c,n-c):l.isLeaf?i?typeof i=="function"?i(l):i:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&u||l.isTextblock)&&r&&(o?o=!1:a+=r),a+=u},0),a}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);a<e.content.length;a++)i.push(e.content[a]);return new kt(i,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],i=0;if(n>e)for(let a=0,o=0;o<n;a++){let l=this.content[a],c=o+l.nodeSize;c>e&&((o<e||c>n)&&(l.isText?l=l.cut(Math.max(0,e-o),Math.min(l.text.length,n-o)):l=l.cut(Math.max(0,e-o-1),Math.min(l.content.size,n-o-1))),r.push(l),i+=l.nodeSize),o=c}return new kt(r,i)}cutByIndex(e,n){return e==n?kt.empty:e==0&&n==this.content.length?this:new kt(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let i=this.content.slice(),a=this.size+n.nodeSize-r.nodeSize;return i[e]=n,new kt(i,a)}addToStart(e){return new kt([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new kt(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(e.content[n]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let n=this.content[e];if(!n)throw new RangeError("Index "+e+" out of range for "+this);return n}maybeChild(e){return this.content[e]||null}forEach(e){for(let n=0,r=0;n<this.content.length;n++){let i=this.content[n];e(i,r,n),r+=i.nodeSize}}findDiffStart(e,n=0){return See(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return Mee(this,e,n,r)}findIndex(e){if(e==0)return Z_(0,e);if(e==this.size)return Z_(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let i=this.child(n),a=r+i.nodeSize;if(a>=e)return a==e?Z_(n+1,a):Z_(n,r);r=a}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return kt.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new kt(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return kt.empty;let n,r=0;for(let i=0;i<e.length;i++){let a=e[i];r+=a.nodeSize,i&&a.isText&&e[i-1].sameMarkup(a)?(n||(n=e.slice(0,i)),n[n.length-1]=a.withText(n[n.length-1].text+a.text)):n&&n.push(a)}return new kt(n||e,r)}static from(e){if(!e)return kt.empty;if(e instanceof kt)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new kt([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}kt.empty=new kt([],0);const uj={index:0,offset:0};function Z_(t,e){return uj.index=t,uj.offset=e,uj}function oM(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(!oM(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!oM(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let Rr=class kD{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,r=!1;for(let i=0;i<e.length;i++){let a=e[i];if(this.eq(a))return e;if(this.type.excludes(a.type))n||(n=e.slice(0,i));else{if(a.type.excludes(this.type))return e;!r&&a.type.rank>this.type.rank&&(n||(n=e.slice(0,i)),n.push(this),r=!0),n&&n.push(a)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return e.slice(0,n).concat(e.slice(n+1));return e}isInSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return!0;return!1}eq(e){return this==e||this.type==e.type&&oM(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 kD.none;if(e instanceof kD)return[e];let n=e.slice();return n.sort((r,i)=>r.type.rank-i.type.rank),n}};Rr.none=[];class lM extends Error{}class Ut{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=kee(this.content,e+this.openStart,n);return r&&new Ut(r,this.openStart,this.openEnd)}removeBetween(e,n){return new Ut(Nee(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,n){if(!n)return Ut.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new Ut(kt.fromJSON(e,n.content),r,i)}static maxOpen(e,n=!0){let r=0,i=0;for(let a=e.firstChild;a&&!a.isLeaf&&(n||!a.type.spec.isolating);a=a.firstChild)r++;for(let a=e.lastChild;a&&!a.isLeaf&&(n||!a.type.spec.isolating);a=a.lastChild)i++;return new Ut(e,r,i)}}Ut.empty=new Ut(kt.empty,0,0);function Nee(t,e,n){let{index:r,offset:i}=t.findIndex(e),a=t.maybeChild(r),{index:o,offset:l}=t.findIndex(n);if(i==e||a.isText){if(l!=n&&!t.child(o).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=o)throw new RangeError("Removing non-flat range");return t.replaceChild(r,a.copy(Nee(a.content,e-i-1,n-i-1)))}function kee(t,e,n,r){let{index:i,offset:a}=t.findIndex(e),o=t.maybeChild(i);if(a==e||o.isText)return r&&!r.canReplace(i,i,n)?null:t.cut(0,e).append(n).append(t.cut(e));let l=kee(o.content,e-a-1,n,o);return l&&t.replaceChild(i,o.copy(l))}function C8e(t,e,n){if(n.openStart>t.depth)throw new lM("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new lM("Inconsistent open depths");return Eee(t,e,n,0)}function Eee(t,e,n,r){let i=t.index(r),a=t.node(r);if(i==e.index(r)&&r<t.depth-n.openStart){let o=Eee(t,e,n,r+1);return a.copy(a.content.replaceChild(i,o))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&t.depth==r&&e.depth==r){let o=t.parent,l=o.content;return Yf(o,l.cut(0,t.parentOffset).append(n.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=j8e(n,t);return Yf(a,Aee(t,o,l,e,r))}else return Yf(a,cM(t,e,r))}function Tee(t,e){if(!e.type.compatibleContent(t.type))throw new lM("Cannot join "+e.type.name+" onto "+t.type.name)}function ED(t,e,n){let r=t.node(n);return Tee(r,e.node(n)),r}function Xf(t,e){let n=e.length-1;n>=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function k0(t,e,n,r){let i=(e||t).node(n),a=0,o=e?e.index(n):i.childCount;t&&(a=t.index(n),t.depth>n?a++:t.textOffset&&(Xf(t.nodeAfter,r),a++));for(let l=a;l<o;l++)Xf(i.child(l),r);e&&e.depth==n&&e.textOffset&&Xf(e.nodeBefore,r)}function Yf(t,e){return t.type.checkContent(e),t.copy(e)}function Aee(t,e,n,r,i){let a=t.depth>i&&ED(t,e,i+1),o=r.depth>i&&ED(n,r,i+1),l=[];return k0(null,t,i,l),a&&o&&e.index(i)==n.index(i)?(Tee(a,o),Xf(Yf(a,Aee(t,e,n,r,i+1)),l)):(a&&Xf(Yf(a,cM(t,e,i+1)),l),k0(e,n,i,l),o&&Xf(Yf(o,cM(n,r,i+1)),l)),k0(r,null,i,l),new kt(l)}function cM(t,e,n){let r=[];if(k0(null,t,n,r),t.depth>n){let i=ED(t,e,n+1);Xf(Yf(i,cM(t,e,n+1)),r)}return k0(e,null,n,r),new kt(r)}function j8e(t,e){let n=e.depth-t.openStart,i=e.node(n).copy(t.content);for(let a=n-1;a>=0;a--)i=e.node(a).copy(kt.from(i));return{start:i.resolveNoCache(t.openStart+n),end:i.resolveNoCache(i.content.size-t.openEnd-n)}}class wy{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=e.child(n);return r?e.child(n).cut(r):i}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],i=n==0?0:this.path[n*3-1]+1;for(let a=0;a<e;a++)i+=r.child(a).nodeSize;return i}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return Rr.none;if(this.textOffset)return e.child(n).marks;let r=e.maybeChild(n-1),i=e.maybeChild(n);if(!r){let l=r;r=i,i=l}let a=r.marks;for(var o=0;o<a.length;o++)a[o].type.spec.inclusive===!1&&(!i||!a[o].isInSet(i.marks))&&(a=a[o--].removeFromSet(a));return a}marksAcross(e){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let r=n.marks,i=e.parent.maybeChild(e.index());for(var a=0;a<r.length;a++)r[a].type.spec.inclusive===!1&&(!i||!r[a].isInSet(i.marks))&&(r=r[a--].removeFromSet(r));return r}sharedDepth(e){for(let n=this.depth;n>0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new uM(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let n=1;n<=this.depth;n++)e+=(e?"/":"")+this.node(n).type.name+"_"+this.index(n-1);return e+":"+this.parentOffset}static resolve(e,n){if(!(n>=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let r=[],i=0,a=n;for(let o=e;;){let{index:l,offset:c}=o.content.findIndex(a),u=a-c;if(r.push(o,l,i+c),!u||(o=o.child(l),o.isText))break;a=u-1,i+=c+1}return new wy(n,r,a)}static resolveCached(e,n){let r=C7.get(e);if(r)for(let a=0;a<r.elts.length;a++){let o=r.elts[a];if(o.pos==n)return o}else C7.set(e,r=new P8e);let i=r.elts[r.i]=wy.resolve(e,n);return r.i=(r.i+1)%D8e,i}}class P8e{constructor(){this.elts=[],this.i=0}}const D8e=12,C7=new WeakMap;class uM{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 R8e=Object.create(null);let hh=class TD{constructor(e,n,r,i=Rr.none){this.type=e,this.attrs=n,this.marks=i,this.content=r||kt.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&&oM(this.attrs,n||e.defaultAttrs||R8e)&&Rr.sameSet(this.marks,r||Rr.none)}copy(e=null){return e==this.content?this:new TD(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new TD(this.type,this.attrs,this.content,e)}cut(e,n=this.content.size){return e==0&&n==this.content.size?this:this.copy(this.content.cut(e,n))}slice(e,n=this.content.size,r=!1){if(e==n)return Ut.empty;let i=this.resolve(e),a=this.resolve(n),o=r?0:i.sharedDepth(n),l=i.start(o),u=i.node(o).content.cut(i.pos-l,a.pos-l);return new Ut(u,i.depth-o,a.depth-o)}replace(e,n,r){return C8e(this.resolve(e),this.resolve(n),r)}nodeAt(e){for(let n=this;;){let{index:r,offset:i}=n.content.findIndex(e);if(n=n.maybeChild(r),!n)return null;if(i==e||n.isText)return n;e-=i+1}}childAfter(e){let{index:n,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(n),index:n,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:n,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(n),index:n,offset:r};let i=this.content.child(n-1);return{node:i,index:n-1,offset:r-i.nodeSize}}resolve(e){return wy.resolveCached(this,e)}resolveNoCache(e){return wy.resolve(this,e)}rangeHasMark(e,n,r){let i=!1;return n>e&&this.nodesBetween(e,n,a=>(r.isInSet(a.marks)&&(i=!0),!i)),i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),Cee(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(e,n,r=kt.empty,i=0,a=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,i,a),l=o&&o.matchFragment(this.content,n);if(!l||!l.validEnd)return!1;for(let c=i;c<a;c++)if(!this.type.allowsMarks(r.child(c).marks))return!1;return!0}canReplaceWith(e,n,r,i){if(i&&!this.type.allowsMarks(i))return!1;let a=this.contentMatchAt(e).matchType(r),o=a&&a.matchFragment(this.content,n);return o?o.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=Rr.none;for(let n=0;n<this.marks.length;n++){let r=this.marks[n];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!Rr.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(n=>n.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let r;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,r)}let i=kt.fromJSON(e,n.content),a=e.nodeType(n.type).create(n.attrs,i,r);return a.type.checkAttrs(a.attrs),a}};hh.prototype.text=void 0;class dM extends hh{constructor(e,n,r,i){if(super(e,n,null,i),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Cee(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,n){return this.text.slice(e,n)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new dM(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new dM(this.type,this.attrs,e,this.marks)}cut(e=0,n=this.text.length){return e==0&&n==this.text.length?this:this.withText(this.text.slice(e,n))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function Cee(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class wm{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new O8e(e,n);if(r.next==null)return wm.empty;let i=jee(r);r.next&&r.err("Unexpected trailing text");let a=H8e(B8e(i));return $8e(a,r),a}matchType(e){for(let n=0;n<this.next.length;n++)if(this.next[n].type==e)return this.next[n].next;return null}matchFragment(e,n=0,r=e.childCount){let i=this;for(let a=n;i&&a<r;a++)i=i.matchType(e.child(a).type);return i}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:n}=this.next[e];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(e){for(let n=0;n<this.next.length;n++)for(let r=0;r<e.next.length;r++)if(this.next[n].type==e.next[r].type)return!0;return!1}fillBefore(e,n=!1,r=0){let i=[this];function a(o,l){let c=o.matchFragment(e,r);if(c&&(!n||c.validEnd))return kt.from(l.map(u=>u.createAndFill()));for(let u=0;u<o.next.length;u++){let{type:d,next:f}=o.next[u];if(!(d.isText||d.hasRequiredAttrs())&&i.indexOf(f)==-1){i.push(f);let p=a(f,l.concat(d));if(p)return p}}return null}return a(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}computeWrapping(e){let n=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let i=r.shift(),a=i.match;if(a.matchType(e)){let o=[];for(let l=i;l.type;l=l.via)o.push(l.type);return o.reverse()}for(let o=0;o<a.next.length;o++){let{type:l,next:c}=a.next[o];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in n)&&(!i.type||c.validEnd)&&(r.push({match:l.contentMatch,type:l,via:i}),n[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(r){e.push(r);for(let i=0;i<r.next.length;i++)e.indexOf(r.next[i].next)==-1&&n(r.next[i].next)}return n(this),e.map((r,i)=>{let a=i+(r.validEnd?"*":" ")+" ";for(let o=0;o<r.next.length;o++)a+=(o?", ":"")+r.next[o].type.name+"->"+e.indexOf(r.next[o].next);return a}).join(`
- `)}}wm.empty=new wm(!0);class O8e{constructor(e,n){this.string=e,this.nodeTypes=n,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function jee(t){let e=[];do e.push(L8e(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function L8e(t){let e=[];do e.push(F8e(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function F8e(t){let e=z8e(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=I8e(t,e);else break;return e}function j7(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function I8e(t,e){let n=j7(t),r=n;return t.eat(",")&&(t.next!="}"?r=j7(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function U8e(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let i=[];for(let a in n){let o=n[a];o.isInGroup(e)&&i.push(o)}return i.length==0&&t.err("No node type or group '"+e+"' found"),i}function z8e(t){if(t.eat("(")){let e=jee(t);return t.eat(")")||t.err("Missing closing paren"),e}else if(/\W/.test(t.next))t.err("Unexpected token '"+t.next+"'");else{let e=U8e(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 B8e(t){let e=[[]];return i(a(t,0),n()),e;function n(){return e.push([])-1}function r(o,l,c){let u={term:c,to:l};return e[o].push(u),u}function i(o,l){o.forEach(c=>c.to=l)}function a(o,l){if(o.type=="choice")return o.exprs.reduce((c,u)=>c.concat(a(u,l)),[]);if(o.type=="seq")for(let c=0;;c++){let u=a(o.exprs[c],l);if(c==o.exprs.length-1)return u;i(u,l=n())}else if(o.type=="star"){let c=n();return r(l,c),i(a(o.expr,c),c),[r(c)]}else if(o.type=="plus"){let c=n();return i(a(o.expr,l),c),i(a(o.expr,c),c),[r(c)]}else{if(o.type=="opt")return[r(l)].concat(a(o.expr,l));if(o.type=="range"){let c=l;for(let u=0;u<o.min;u++){let d=n();i(a(o.expr,c),d),c=d}if(o.max==-1)i(a(o.expr,c),c);else for(let u=o.min;u<o.max;u++){let d=n();r(c,d),i(a(o.expr,c),d),c=d}return[r(c)]}else{if(o.type=="name")return[r(l,void 0,o.value)];throw new Error("Unknown expr type")}}}}function Pee(t,e){return e-t}function P7(t,e){let n=[];return r(e),n.sort(Pee);function r(i){let a=t[i];if(a.length==1&&!a[0].term)return r(a[0].to);n.push(i);for(let o=0;o<a.length;o++){let{term:l,to:c}=a[o];!l&&n.indexOf(c)==-1&&r(c)}}}function H8e(t){let e=Object.create(null);return n(P7(t,0));function n(r){let i=[];r.forEach(o=>{t[o].forEach(({term:l,to:c})=>{if(!l)return;let u;for(let d=0;d<i.length;d++)i[d][0]==l&&(u=i[d][1]);P7(t,c).forEach(d=>{u||i.push([l,u=[]]),u.indexOf(d)==-1&&u.push(d)})})});let a=e[r.join(",")]=new wm(r.indexOf(t.length-1)>-1);for(let o=0;o<i.length;o++){let l=i[o][1].sort(Pee);a.next.push({type:i[o][0],next:e[l.join(",")]||n(l)})}return a}}function $8e(t,e){for(let n=0,r=[t];n<r.length;n++){let i=r[n],a=!i.validEnd,o=[];for(let l=0;l<i.next.length;l++){let{type:c,next:u}=i.next[l];o.push(c.name),a&&!(c.isText||c.hasRequiredAttrs())&&(a=!1),r.indexOf(u)==-1&&r.push(u)}a&&e.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Dee(t){let e=Object.create(null);for(let n in t){let r=t[n];if(!r.hasDefault)return null;e[n]=r.default}return e}function Ree(t,e){let n=Object.create(null);for(let r in t){let i=e&&e[r];if(i===void 0){let a=t[r];if(a.hasDefault)i=a.default;else throw new RangeError("No value supplied for attribute "+r)}n[r]=i}return n}function Oee(t,e,n,r){for(let i in e)if(!(i in t))throw new RangeError(`Unsupported attribute ${i} for ${n} of type ${i}`);for(let i in t){let a=t[i];a.validate&&a.validate(e[i])}}function Lee(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new G8e(t,r,e[r]);return n}let D7=class Fee{constructor(e,n,r){this.name=e,this.schema=n,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=Lee(e,r.attrs),this.defaultAttrs=Dee(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==wm.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:Ree(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new hh(this,this.computeAttrs(e),kt.from(n),Rr.setFrom(r))}createChecked(e=null,n,r){return n=kt.from(n),this.checkContent(n),new hh(this,this.computeAttrs(e),n,Rr.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=kt.from(n),n.size){let o=this.contentMatch.fillBefore(n);if(!o)return null;n=o.append(n)}let i=this.contentMatch.matchFragment(n),a=i&&i.fillBefore(kt.empty,!0);return a?new hh(this,e,n.append(a),Rr.setFrom(r)):null}validContent(e){let n=this.contentMatch.matchFragment(e);if(!n||!n.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){Oee(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let n=0;n<e.length;n++)if(!this.allowsMarkType(e[n].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let n;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?n&&n.push(e[r]):n||(n=e.slice(0,r));return n?n.length?n:Rr.none:e}static compile(e,n){let r=Object.create(null);e.forEach((a,o)=>r[a]=new Fee(a,n,o));let i=n.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let a in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function V8e(t,e,n){let r=n.split("|");return i=>{let a=i===null?"null":typeof i;if(r.indexOf(a)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${a}`)}}class G8e{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?V8e(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class S2{constructor(e,n,r,i){this.name=e,this.rank=n,this.schema=r,this.spec=i,this.attrs=Lee(e,i.attrs),this.excluded=null;let a=Dee(this.attrs);this.instance=a?new Rr(this,a):null}create(e=null){return!e&&this.instance?this.instance:new Rr(this,Ree(this.attrs,e))}static compile(e,n){let r=Object.create(null),i=0;return e.forEach((a,o)=>r[a]=new S2(a,i++,n,o)),r}removeFromSet(e){for(var n=0;n<e.length;n++)e[n].type==this&&(e=e.slice(0,n).concat(e.slice(n+1)),n--);return e}isInSet(e){for(let n=0;n<e.length;n++)if(e[n].type==this)return e[n]}checkAttrs(e){Oee(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class Iee{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let i in e)n[i]=e[i];n.nodes=Pa.from(e.nodes),n.marks=Pa.from(e.marks||{}),this.nodes=D7.compile(this.spec.nodes,this),this.marks=S2.compile(this.spec.marks,this);let r=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let a=this.nodes[i],o=a.spec.content||"",l=a.spec.marks;if(a.contentMatch=r[o]||(r[o]=wm.parse(o,this.nodes)),a.inlineContent=a.contentMatch.inlineContent,a.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!a.isInline||!a.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=a}a.markSet=l=="_"?null:l?R7(this,l.split(" ")):l==""||!a.inlineContent?[]:null}for(let i in this.marks){let a=this.marks[i],o=a.spec.excludes;a.excluded=o==null?[a]:o==""?[]:R7(this,o.split(" "))}this.nodeFromJSON=i=>hh.fromJSON(this,i),this.markFromJSON=i=>Rr.fromJSON(this,i),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,r,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof D7){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(n,r,i)}text(e,n){let r=this.nodes.text;return new dM(r,r.defaultAttrs,e,Rr.setFrom(n))}mark(e,n){return typeof e=="string"&&(e=this.marks[e]),e.create(n)}nodeType(e){let n=this.nodes[e];if(!n)throw new RangeError("Unknown node type: "+e);return n}}function R7(t,e){let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t.marks[i],o=a;if(a)n.push(a);else for(let l in t.marks){let c=t.marks[l];(i=="_"||c.spec.group&&c.spec.group.split(" ").indexOf(i)>-1)&&n.push(o=c)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function q8e(t){return t.tag!=null}function W8e(t){return t.style!=null}let E0=class AD{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(i=>{if(q8e(i))this.tags.push(i);else if(W8e(i)){let a=/[^=]*/.exec(i.style)[0];r.indexOf(a)<0&&r.push(a),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let a=e.nodes[i.node];return a.contentMatch.matchType(a)})}parse(e,n={}){let r=new L7(this,n,!1);return r.addAll(e,Rr.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new L7(this,n,!0);return r.addAll(e,Rr.none,n.from,n.to),Ut.maxOpen(r.finish())}matchTag(e,n,r){for(let i=r?this.tags.indexOf(r)+1:0;i<this.tags.length;i++){let a=this.tags[i];if(Y8e(e,a.tag)&&(a.namespace===void 0||e.namespaceURI==a.namespace)&&(!a.context||n.matchesContext(a.context))){if(a.getAttrs){let o=a.getAttrs(e);if(o===!1)continue;a.attrs=o||void 0}return a}}}matchStyle(e,n,r,i){for(let a=i?this.styles.indexOf(i)+1:0;a<this.styles.length;a++){let o=this.styles[a],l=o.style;if(!(l.indexOf(e)!=0||o.context&&!r.matchesContext(o.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=n))){if(o.getAttrs){let c=o.getAttrs(n);if(c===!1)continue;o.attrs=c||void 0}return o}}}static schemaRules(e){let n=[];function r(i){let a=i.priority==null?50:i.priority,o=0;for(;o<n.length;o++){let l=n[o];if((l.priority==null?50:l.priority)<a)break}n.splice(o,0,i)}for(let i in e.marks){let a=e.marks[i].spec.parseDOM;a&&a.forEach(o=>{r(o=F7(o)),o.mark||o.ignore||o.clearMark||(o.mark=i)})}for(let i in e.nodes){let a=e.nodes[i].spec.parseDOM;a&&a.forEach(o=>{r(o=F7(o)),o.node||o.ignore||o.mark||(o.node=i)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new AD(e,AD.schemaRules(e)))}};const Uee={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},K8e={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},zee={ol:!0,ul:!0},_y=1,CD=2,T0=4;function O7(t,e,n){return e!=null?(e?_y:0)|(e==="full"?CD:0):t&&t.whitespace=="pre"?_y|CD:n&~T0}class J_{constructor(e,n,r,i,a,o){this.type=e,this.attrs=n,this.marks=r,this.solid=i,this.options=o,this.content=[],this.activeMarks=Rr.none,this.match=a||(o&T0?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(kt.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,i;return(i=r.findWrapping(e.type))?(this.match=r,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&_y)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let a=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=a.withText(a.text.slice(0,a.text.length-i[0].length))}}let n=kt.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(kt.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Uee.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class L7{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let i=n.topNode,a,o=O7(null,n.preserveWhitespace,0)|(r?T0:0);i?a=new J_(i.type,i.attrs,Rr.none,!0,n.topMatch||i.type.contentMatch,o):r?a=new J_(null,null,Rr.none,!0,null,o):a=new J_(e.schema.topNodeType,null,Rr.none,!0,null,o),this.nodes=[a],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let r=e.nodeValue,i=this.top,a=i.options&CD?"full":this.localPreserveWS||(i.options&_y)>0,{schema:o}=this.parser;if(a==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(a)if(a==="full")r=r.replace(/\r\n?/g,`
- `);else if(o.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(o.linebreakReplacement.create())){let l=r.split(/\r?\n|\r/);for(let c=0;c<l.length;c++)c&&this.insertNode(o.linebreakReplacement.create(),n,!0),l[c]&&this.insertNode(o.text(l[c]),n,!/\S/.test(l[c]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let l=i.content[i.content.length-1],c=e.previousSibling;(!l||c&&c.nodeName=="BR"||l.isText&&/[ \t\r\n\u000c]$/.test(l.text))&&(r=r.slice(1))}r&&this.insertNode(o.text(r),n,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,n,r){let i=this.localPreserveWS,a=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let o=e.nodeName.toLowerCase(),l;zee.hasOwnProperty(o)&&this.parser.normalizeLists&&X8e(e);let c=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(c?c.ignore:K8e.hasOwnProperty(o))this.findInside(e),this.ignoreFallback(e,n);else if(!c||c.skip||c.closeParent){c&&c.closeParent?this.open=Math.max(0,this.open-1):c&&c.skip.nodeType&&(e=c.skip);let u,d=this.needsBlock;if(Uee.hasOwnProperty(o))a.content.length&&a.content[0].isInline&&this.open&&(this.open--,a=this.top),u=!0,a.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,n);break e}let f=c&&c.skip?n:this.readStyles(e,n);f&&this.addAll(e,f),u&&this.sync(a),this.needsBlock=d}else{let u=this.readStyles(e,n);u&&this.addElementByRule(e,c,u,c.consuming===!1?l:void 0)}this.localPreserveWS=i}leafFallback(e,n){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
- `),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(e,n){let r=e.style;if(r&&r.length)for(let i=0;i<this.parser.matchedStyles.length;i++){let a=this.parser.matchedStyles[i],o=r.getPropertyValue(a);if(o)for(let l=void 0;;){let c=this.parser.matchStyle(a,o,this,l);if(!c)break;if(c.ignore)return null;if(c.clearMark?n=n.filter(u=>!c.clearMark(u)):n=n.concat(this.parser.schema.marks[c.mark].create(c.attrs)),c.consuming===!1)l=c;else break}}return n}addElementByRule(e,n,r,i){let a,o;if(n.node)if(o=this.parser.schema.nodes[n.node],o.isLeaf)this.insertNode(o.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let c=this.enter(o,n.attrs||null,r,n.preserveWhitespace);c&&(a=!0,r=c)}else{let c=this.parser.schema.marks[n.mark];r=r.concat(c.create(n.attrs))}let l=this.top;if(o&&o.isLeaf)this.findInside(e);else if(i)this.addElement(e,r,i);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(c=>this.insertNode(c,r,!1));else{let c=e;typeof n.contentElement=="string"?c=e.querySelector(n.contentElement):typeof n.contentElement=="function"?c=n.contentElement(e):n.contentElement&&(c=n.contentElement),this.findAround(e,c,!0),this.addAll(c,r),this.findAround(e,c,!1)}a&&this.sync(l)&&this.open--}addAll(e,n,r,i){let a=r||0;for(let o=r?e.childNodes[r]:e.firstChild,l=i==null?null:e.childNodes[i];o!=l;o=o.nextSibling,++a)this.findAtPoint(e,a),this.addDOM(o,n);this.findAtPoint(e,a)}findPlace(e,n,r){let i,a;for(let o=this.open,l=0;o>=0;o--){let c=this.nodes[o],u=c.findWrapping(e);if(u&&(!i||i.length>u.length+l)&&(i=u,a=c,!u.length))break;if(c.solid){if(r)break;l+=2}}if(!i)return null;this.sync(a);for(let o=0;o<i.length;o++)n=this.enterInner(i[o],null,n,!1);return n}insertNode(e,n,r){if(e.isInline&&this.needsBlock&&!this.top.type){let a=this.textblockFromContext();a&&(n=this.enterInner(a,null,n))}let i=this.findPlace(e,n,r);if(i){this.closeExtra();let a=this.top;a.match&&(a.match=a.match.matchType(e.type));let o=Rr.none;for(let l of i.concat(e.marks))(a.type?a.type.allowsMarkType(l.type):I7(l.type,e.type))&&(o=l.addToSet(o));return a.content.push(e.mark(o)),!0}return!1}enter(e,n,r,i){let a=this.findPlace(e.create(n),r,!1);return a&&(a=this.enterInner(e,n,r,!0,i)),a}enterInner(e,n,r,i=!1,a){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let l=O7(e,a,o.options);o.options&T0&&o.content.length==0&&(l|=T0);let c=Rr.none;return r=r.filter(u=>(o.type?o.type.allowsMarkType(u.type):I7(u.type,e))?(c=u.addToSet(c),!1):!0),this.nodes.push(new J_(e,n,c,i,null,l)),this.open++,r}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let n=this.open;n>=0;n--){if(this.nodes[n]==e)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=_y)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let i=r.length-1;i>=0;i--)e+=r[i].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==n&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&e.nodeType==1&&e.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(e,n,r){if(e!=n&&this.find)for(let i=0;i<this.find.length;i++)this.find[i].pos==null&&e.nodeType==1&&e.contains(this.find[i].node)&&n.compareDocumentPosition(this.find[i].node)&(r?2:4)&&(this.find[i].pos=this.currentPos)}findInText(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&(this.find[n].pos=this.currentPos-(e.nodeValue.length-this.find[n].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),r=this.options.context,i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),a=-(r?r.depth+1:0)+(i?0:1),o=(l,c)=>{for(;l>=0;l--){let u=n[l];if(u==""){if(l==n.length-1||l==0)continue;for(;c>=a;c--)if(o(l-1,c))return!0;return!1}else{let d=c>0||c==0&&i?this.nodes[c].type:r&&c>=a?r.node(c-a).type:null;if(!d||d.name!=u&&!d.isInGroup(u))return!1;c--}}return!0};return o(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}}function X8e(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&zee.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function Y8e(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function F7(t){let e={};for(let n in t)e[n]=t[n];return e}function I7(t,e){let n=e.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(t))continue;let a=[],o=l=>{a.push(l);for(let c=0;c<l.edgeCount;c++){let{type:u,next:d}=l.edge(c);if(u==e||a.indexOf(d)<0&&o(d))return!0}};if(o(i.contentMatch))return!0}}class Pm{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=dj(n).createDocumentFragment());let i=r,a=[];return e.forEach(o=>{if(a.length||o.marks.length){let l=0,c=0;for(;l<a.length&&c<o.marks.length;){let u=o.marks[c];if(!this.marks[u.type.name]){c++;continue}if(!u.eq(a[l][0])||u.type.spec.spanning===!1)break;l++,c++}for(;l<a.length;)i=a.pop()[1];for(;c<o.marks.length;){let u=o.marks[c++],d=this.serializeMark(u,o.isInline,n);d&&(a.push([u,i]),i.appendChild(d.dom),i=d.contentDOM||d.dom)}}i.appendChild(this.serializeNodeInner(o,n))}),r}serializeNodeInner(e,n){let{dom:r,contentDOM:i}=D1(dj(n),this.nodes[e.type.name](e),null,e.attrs);if(i){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,n,i)}return r}serializeNode(e,n={}){let r=this.serializeNodeInner(e,n);for(let i=e.marks.length-1;i>=0;i--){let a=this.serializeMark(e.marks[i],e.isInline,n);a&&((a.contentDOM||a.dom).appendChild(r),r=a.dom)}return r}serializeMark(e,n,r={}){let i=this.marks[e.type.name];return i&&D1(dj(r),i(e,n),null,e.attrs)}static renderSpec(e,n,r=null,i){return D1(e,n,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Pm(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=U7(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return U7(e.marks)}}function U7(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function dj(t){return t.document||window.document}const z7=new WeakMap;function Q8e(t){let e=z7.get(t);return e===void 0&&z7.set(t,e=Z8e(t)),e}function Z8e(t){let e=null;function n(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let i=0;i<r.length;i++)n(r[i]);else for(let i in r)n(r[i])}return n(t),e}function D1(t,e,n,r){if(typeof e=="string")return{dom:t.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let i=e[0],a;if(typeof i!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(a=Q8e(r))&&a.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o=i.indexOf(" ");o>0&&(n=i.slice(0,o),i=i.slice(o+1));let l,c=n?t.createElementNS(n,i):t.createElement(i),u=e[1],d=1;if(u&&typeof u=="object"&&u.nodeType==null&&!Array.isArray(u)){d=2;for(let f in u)if(u[f]!=null){let p=f.indexOf(" ");p>0?c.setAttributeNS(f.slice(0,p),f.slice(p+1),u[f]):f=="style"&&c.style?c.style.cssText=u[f]:c.setAttribute(f,u[f])}}for(let f=d;f<e.length;f++){let p=e[f];if(p===0){if(f<e.length-1||f>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:c,contentDOM:c}}else{let{dom:m,contentDOM:x}=D1(t,p,n,r);if(c.appendChild(m),x){if(l)throw new RangeError("Multiple content holes");l=x}}}return{dom:c,contentDOM:l}}const Bee=65535,Hee=Math.pow(2,16);function J8e(t,e){return t+e*Hee}function B7(t){return t&Bee}function e6e(t){return(t-(t&Bee))/Hee}const $ee=1,Vee=2,R1=4,Gee=8;class jD{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&Gee)>0}get deletedBefore(){return(this.delInfo&($ee|R1))>0}get deletedAfter(){return(this.delInfo&(Vee|R1))>0}get deletedAcross(){return(this.delInfo&R1)>0}}class uo{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&uo.empty)return uo.empty}recover(e){let n=0,r=B7(e);if(!this.inverted)for(let i=0;i<r;i++)n+=this.ranges[i*3+2]-this.ranges[i*3+1];return this.ranges[r*3]+n+e6e(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,r){let i=0,a=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let c=this.ranges[l]-(this.inverted?i:0);if(c>e)break;let u=this.ranges[l+a],d=this.ranges[l+o],f=c+u;if(e<=f){let p=u?e==c?-1:e==f?1:n:n,m=c+i+(p<0?0:d);if(r)return m;let x=e==(n<0?c:f)?null:J8e(l/3,e-c),b=e==c?Vee:e==f?$ee:R1;return(n<0?e!=c:e!=f)&&(b|=Gee),new jD(m,b,x)}i+=d-u}return r?e+i:new jD(e+i,0,null)}touches(e,n){let r=0,i=B7(n),a=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let c=this.ranges[l]-(this.inverted?r:0);if(c>e)break;let u=this.ranges[l+a],d=c+u;if(e<=d&&l==i*3)return!0;r+=this.ranges[l+o]-u}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,a=0;i<this.ranges.length;i+=3){let o=this.ranges[i],l=o-(this.inverted?a:0),c=o+(this.inverted?0:a),u=this.ranges[i+n],d=this.ranges[i+r];e(l,l+u,c,c+d),a+=d-u}}invert(){return new uo(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?uo.empty:new uo(e<0?[0,-e,0]:[0,0,e])}}uo.empty=new uo([]);class Sy{constructor(e,n,r=0,i=e?e.length:0){this.mirror=n,this.from=r,this.to=i,this._maps=e||[],this.ownData=!(e||n)}get maps(){return this._maps}slice(e=0,n=this.maps.length){return new Sy(this._maps,this.mirror,e,n)}appendMap(e,n){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),n!=null&&this.setMirror(this._maps.length-1,n)}appendMapping(e){for(let n=0,r=this._maps.length;n<e._maps.length;n++){let i=e.getMirror(n);this.appendMap(e._maps[n],i!=null&&i<n?r+i:void 0)}}getMirror(e){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==e)return this.mirror[n+(n%2?-1:1)]}}setMirror(e,n){this.mirror||(this.mirror=[]),this.mirror.push(e,n)}appendMappingInverted(e){for(let n=e.maps.length-1,r=this._maps.length+e._maps.length;n>=0;n--){let i=e.getMirror(n);this.appendMap(e._maps[n].invert(),i!=null&&i>n?r-i-1:void 0)}}invert(){let e=new Sy;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,n);return e}mapResult(e,n=1){return this._map(e,n,!1)}_map(e,n,r){let i=0;for(let a=this.from;a<this.to;a++){let o=this._maps[a],l=o.mapResult(e,n);if(l.recover!=null){let c=this.getMirror(a);if(c!=null&&c>a&&c<this.to){a=c,e=this._maps[c].recover(l.recover);continue}}i|=l.delInfo,e=l.pos}return r?e:new jD(e,i,null)}}const hj=Object.create(null);class rs{getMap(){return uo.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=hj[n.stepType];if(!r)throw new RangeError(`No step type ${n.stepType} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in hj)throw new RangeError("Duplicate use of step JSON ID "+e);return hj[e]=n,n.prototype.jsonID=e,n}}class Bi{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new Bi(e,null)}static fail(e){return new Bi(null,e)}static fromReplace(e,n,r,i){try{return Bi.ok(e.replace(n,r,i))}catch(a){if(a instanceof lM)return Bi.fail(a.message);throw a}}}function pL(t,e,n){let r=[];for(let i=0;i<t.childCount;i++){let a=t.child(i);a.content.size&&(a=a.copy(pL(a.content,e,a))),a.isInline&&(a=e(a,n,i)),r.push(a)}return kt.fromArray(r)}class eh extends rs{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=e.resolve(this.from),i=r.node(r.sharedDepth(this.to)),a=new Ut(pL(n.content,(o,l)=>!o.isAtom||!l.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),i),n.openStart,n.openEnd);return Bi.fromReplace(e,this.from,this.to,a)}invert(){return new Rl(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new eh(n.pos,r.pos,this.mark)}merge(e){return e instanceof eh&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new eh(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new eh(n.from,n.to,e.markFromJSON(n.mark))}}rs.jsonID("addMark",eh);class Rl extends rs{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=new Ut(pL(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),n.openStart,n.openEnd);return Bi.fromReplace(e,this.from,this.to,r)}invert(){return new eh(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new Rl(n.pos,r.pos,this.mark)}merge(e){return e instanceof Rl&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Rl(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Rl(n.from,n.to,e.markFromJSON(n.mark))}}rs.jsonID("removeMark",Rl);class th extends rs{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Bi.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return Bi.fromReplace(e,this.pos,this.pos+1,new Ut(kt.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let i=0;i<n.marks.length;i++)if(!n.marks[i].isInSet(r))return new th(this.pos,n.marks[i]);return new th(this.pos,this.mark)}}return new _m(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new th(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new th(n.pos,e.markFromJSON(n.mark))}}rs.jsonID("addNodeMark",th);class _m extends rs{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Bi.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return Bi.fromReplace(e,this.pos,this.pos+1,new Ut(kt.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new th(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new _m(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new _m(n.pos,e.markFromJSON(n.mark))}}rs.jsonID("removeNodeMark",_m);class xa extends rs{constructor(e,n,r,i=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=i}apply(e){return this.structure&&PD(e,this.from,this.to)?Bi.fail("Structure replace would overwrite content"):Bi.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new uo([this.from,this.to-this.from,this.slice.size])}invert(e){return new xa(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deletedAcross&&r.deletedAcross?null:new xa(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof xa)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let n=this.slice.size+e.slice.size==0?Ut.empty:new Ut(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new xa(this.from,this.to+(e.to-e.from),n,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let n=this.slice.size+e.slice.size==0?Ut.empty:new Ut(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new xa(e.from,this.to,n,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new xa(n.from,n.to,Ut.fromJSON(e,n.slice),!!n.structure)}}rs.jsonID("replace",xa);class wa extends rs{constructor(e,n,r,i,a,o,l=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=i,this.slice=a,this.insert=o,this.structure=l}apply(e){if(this.structure&&(PD(e,this.from,this.gapFrom)||PD(e,this.gapTo,this.to)))return Bi.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return Bi.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?Bi.fromReplace(e,this.from,this.to,r):Bi.fail("Content does not fit in gap")}getMap(){return new uo([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let n=this.gapTo-this.gapFrom;return new wa(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),i=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),a=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||a>r.pos?null:new wa(n.pos,r.pos,i,a,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new wa(n.from,n.to,n.gapFrom,n.gapTo,Ut.fromJSON(e,n.slice),n.insert,!!n.structure)}}rs.jsonID("replaceAround",wa);function PD(t,e,n){let r=t.resolve(e),i=n-e,a=r.depth;for(;i>0&&a>0&&r.indexAfter(a)==r.node(a).childCount;)a--,i--;if(i>0){let o=r.node(a).maybeChild(r.indexAfter(a));for(;i>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,i--}}return!1}function t6e(t,e,n,r){let i=[],a=[],o,l;t.doc.nodesBetween(e,n,(c,u,d)=>{if(!c.isInline)return;let f=c.marks;if(!r.isInSet(f)&&d.type.allowsMarkType(r.type)){let p=Math.max(u,e),m=Math.min(u+c.nodeSize,n),x=r.addToSet(f);for(let b=0;b<f.length;b++)f[b].isInSet(x)||(o&&o.to==p&&o.mark.eq(f[b])?o.to=m:i.push(o=new Rl(p,m,f[b])));l&&l.to==p?l.to=m:a.push(l=new eh(p,m,r))}}),i.forEach(c=>t.step(c)),a.forEach(c=>t.step(c))}function n6e(t,e,n,r){let i=[],a=0;t.doc.nodesBetween(e,n,(o,l)=>{if(!o.isInline)return;a++;let c=null;if(r instanceof S2){let u=o.marks,d;for(;d=r.isInSet(u);)(c||(c=[])).push(d),u=d.removeFromSet(u)}else r?r.isInSet(o.marks)&&(c=[r]):c=o.marks;if(c&&c.length){let u=Math.min(l+o.nodeSize,n);for(let d=0;d<c.length;d++){let f=c[d],p;for(let m=0;m<i.length;m++){let x=i[m];x.step==a-1&&f.eq(i[m].style)&&(p=x)}p?(p.to=u,p.step=a):i.push({style:f,from:Math.max(l,e),to:u,step:a})}}}),i.forEach(o=>t.step(new Rl(o.from,o.to,o.style)))}function gL(t,e,n,r=n.contentMatch,i=!0){let a=t.doc.nodeAt(e),o=[],l=e+1;for(let c=0;c<a.childCount;c++){let u=a.child(c),d=l+u.nodeSize,f=r.matchType(u.type);if(!f)o.push(new xa(l,d,Ut.empty));else{r=f;for(let p=0;p<u.marks.length;p++)n.allowsMarkType(u.marks[p].type)||t.step(new Rl(l,d,u.marks[p]));if(i&&u.isText&&n.whitespace!="pre"){let p,m=/\r?\n|\r/g,x;for(;p=m.exec(u.text);)x||(x=new Ut(kt.from(n.schema.text(" ",n.allowedMarks(u.marks))),0,0)),o.push(new xa(l+p.index,l+p.index+p[0].length,x))}}l=d}if(!r.validEnd){let c=r.fillBefore(kt.empty,!0);t.replace(l,l,new Ut(c,0,0))}for(let c=o.length-1;c>=0;c--)t.step(o[c])}function r6e(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function Ox(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth,i=0,a=0;;--r){let o=t.$from.node(r),l=t.$from.index(r)+i,c=t.$to.indexAfter(r)-a;if(r<t.depth&&o.canReplace(l,c,n))return r;if(r==0||o.type.spec.isolating||!r6e(o,l,c))break;l&&(i=1),c<o.childCount&&(a=1)}return null}function i6e(t,e,n){let{$from:r,$to:i,depth:a}=e,o=r.before(a+1),l=i.after(a+1),c=o,u=l,d=kt.empty,f=0;for(let x=a,b=!1;x>n;x--)b||r.index(x)>0?(b=!0,d=kt.from(r.node(x).copy(d)),f++):c--;let p=kt.empty,m=0;for(let x=a,b=!1;x>n;x--)b||i.after(x+1)<i.end(x)?(b=!0,p=kt.from(i.node(x).copy(p)),m++):u++;t.step(new wa(c,u,o,l,new Ut(d.append(p),f,m),d.size-f,!0))}function xL(t,e,n=null,r=t){let i=a6e(t,e),a=i&&s6e(r,e);return a?i.map(H7).concat({type:e,attrs:n}).concat(a.map(H7)):null}function H7(t){return{type:t,attrs:null}}function a6e(t,e){let{parent:n,startIndex:r,endIndex:i}=t,a=n.contentMatchAt(r).findWrapping(e);if(!a)return null;let o=a.length?a[0]:e;return n.canReplaceWith(r,i,o)?a:null}function s6e(t,e){let{parent:n,startIndex:r,endIndex:i}=t,a=n.child(r),o=e.contentMatch.findWrapping(a.type);if(!o)return null;let c=(o.length?o[o.length-1]:e).contentMatch;for(let u=r;c&&u<i;u++)c=c.matchType(n.child(u).type);return!c||!c.validEnd?null:o}function o6e(t,e,n){let r=kt.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=kt.from(n[o].type.create(n[o].attrs,r))}let i=e.start,a=e.end;t.step(new wa(i,a,i,a,new Ut(r,0,0),n.length,!0))}function l6e(t,e,n,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let a=t.steps.length;t.doc.nodesBetween(e,n,(o,l)=>{let c=typeof i=="function"?i(o):i;if(o.isTextblock&&!o.hasMarkup(r,c)&&c6e(t.doc,t.mapping.slice(a).map(l),r)){let u=null;if(r.schema.linebreakReplacement){let m=r.whitespace=="pre",x=!!r.contentMatch.matchType(r.schema.linebreakReplacement);m&&!x?u=!1:!m&&x&&(u=!0)}u===!1&&Wee(t,o,l,a),gL(t,t.mapping.slice(a).map(l,1),r,void 0,u===null);let d=t.mapping.slice(a),f=d.map(l,1),p=d.map(l+o.nodeSize,1);return t.step(new wa(f,p,f+1,p-1,new Ut(kt.from(r.create(c,null,o.marks)),0,0),1,!0)),u===!0&&qee(t,o,l,a),!1}})}function qee(t,e,n,r){e.forEach((i,a)=>{if(i.isText){let o,l=/\r?\n|\r/g;for(;o=l.exec(i.text);){let c=t.mapping.slice(r).map(n+1+a+o.index);t.replaceWith(c,c+1,e.type.schema.linebreakReplacement.create())}}})}function Wee(t,e,n,r){e.forEach((i,a)=>{if(i.type==i.type.schema.linebreakReplacement){let o=t.mapping.slice(r).map(n+1+a);t.replaceWith(o,o+1,e.type.schema.text(`
- `))}})}function c6e(t,e,n){let r=t.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function u6e(t,e,n,r,i){let a=t.doc.nodeAt(e);if(!a)throw new RangeError("No node at given position");n||(n=a.type);let o=n.create(r,null,i||a.marks);if(a.isLeaf)return t.replaceWith(e,e+a.nodeSize,o);if(!n.validContent(a.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new wa(e,e+a.nodeSize,e+1,e+a.nodeSize-1,new Ut(kt.from(o),0,0),1,!0))}function ju(t,e,n=1,r){let i=t.resolve(e),a=i.depth-n,o=r&&r[r.length-1]||i.parent;if(a<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let u=i.depth-1,d=n-2;u>a;u--,d--){let f=i.node(u),p=i.index(u);if(f.type.spec.isolating)return!1;let m=f.content.cutByIndex(p,f.childCount),x=r&&r[d+1];x&&(m=m.replaceChild(0,x.type.create(x.attrs)));let b=r&&r[d]||f;if(!f.canReplace(p+1,f.childCount)||!b.type.validContent(m))return!1}let l=i.indexAfter(a),c=r&&r[0];return i.node(a).canReplaceWith(l,l,c?c.type:i.node(a+1).type)}function d6e(t,e,n=1,r){let i=t.doc.resolve(e),a=kt.empty,o=kt.empty;for(let l=i.depth,c=i.depth-n,u=n-1;l>c;l--,u--){a=kt.from(i.node(l).copy(a));let d=r&&r[u];o=kt.from(d?d.type.create(d.attrs,o):i.node(l).copy(o))}t.step(new xa(e,e,new Ut(a.append(o),n,n),!0))}function zh(t,e){let n=t.resolve(e),r=n.index();return Kee(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function h6e(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:r}=t.type.schema;for(let i=0;i<e.childCount;i++){let a=e.child(i),o=a.type==r?t.type.schema.nodes.text:a.type;if(n=n.matchType(o),!n||!t.type.allowsMarks(a.marks))return!1}return n.validEnd}function Kee(t,e){return!!(t&&e&&!t.isLeaf&&h6e(t,e))}function M2(t,e,n=-1){let r=t.resolve(e);for(let i=r.depth;;i--){let a,o,l=r.index(i);if(i==r.depth?(a=r.nodeBefore,o=r.nodeAfter):n>0?(a=r.node(i+1),l++,o=r.node(i).maybeChild(l)):(a=r.node(i).maybeChild(l-1),o=r.node(i+1)),a&&!a.isTextblock&&Kee(a,o)&&r.node(i).canReplace(l,l+1))return e;if(i==0)break;e=n<0?r.before(i):r.after(i)}}function f6e(t,e,n){let r=null,{linebreakReplacement:i}=t.doc.type.schema,a=t.doc.resolve(e-n),o=a.node().type;if(i&&o.inlineContent){let d=o.whitespace=="pre",f=!!o.contentMatch.matchType(i);d&&!f?r=!1:!d&&f&&(r=!0)}let l=t.steps.length;if(r===!1){let d=t.doc.resolve(e+n);Wee(t,d.node(),d.before(),l)}o.inlineContent&&gL(t,e+n-1,o,a.node().contentMatchAt(a.index()),r==null);let c=t.mapping.slice(l),u=c.map(e-n);if(t.step(new xa(u,c.map(e+n,-1),Ut.empty,!0)),r===!0){let d=t.doc.resolve(u);qee(t,d.node(),d.before(),t.steps.length)}return t}function m6e(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(r.parentOffset==0)for(let i=r.depth-1;i>=0;i--){let a=r.index(i);if(r.node(i).canReplaceWith(a,a,n))return r.before(i+1);if(a>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let a=r.indexAfter(i);if(r.node(i).canReplaceWith(a,a,n))return r.after(i+1);if(a<r.node(i).childCount)return null}return null}function Xee(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let i=n.content;for(let a=0;a<n.openStart;a++)i=i.firstChild.content;for(let a=1;a<=(n.openStart==0&&n.size?2:1);a++)for(let o=r.depth;o>=0;o--){let l=o==r.depth?0:r.pos<=(r.start(o+1)+r.end(o+1))/2?-1:1,c=r.index(o)+(l>0?1:0),u=r.node(o),d=!1;if(a==1)d=u.canReplace(c,c,i);else{let f=u.contentMatchAt(c).findWrapping(i.firstChild.type);d=f&&u.canReplaceWith(c,c,f[0])}if(d)return l==0?r.pos:l<0?r.before(o+1):r.after(o+1)}return null}function N2(t,e,n=e,r=Ut.empty){if(e==n&&!r.size)return null;let i=t.resolve(e),a=t.resolve(n);return Yee(i,a,r)?new xa(e,n,r):new p6e(i,a,r).fit()}function Yee(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class p6e{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=kt.empty;for(let i=0;i<=e.depth;i++){let a=e.node(i);this.frontier.push({type:a.type,match:a.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=kt.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let u=this.findFittable();u?this.placeNodes(u):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(e<0?this.$to:r.doc.resolve(e));if(!i)return null;let a=this.placed,o=r.depth,l=i.depth;for(;o&&l&&a.childCount==1;)a=a.firstChild.content,o--,l--;let c=new Ut(a,o,l);return e>-1?new wa(r.pos,e,this.$to.pos,this.$to.end(),c,n):c.size||r.pos!=this.$to.pos?new xa(r.pos,i.pos,c):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,i=this.unplaced.openEnd;r<e;r++){let a=n.firstChild;if(n.childCount>1&&(i=0),a.type.spec.isolating&&i<=r){e=r;break}n=a.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let i,a=null;r?(a=fj(this.unplaced.content,r-1).firstChild,i=a.content):i=this.unplaced.content;let o=i.firstChild;for(let l=this.depth;l>=0;l--){let{type:c,match:u}=this.frontier[l],d,f=null;if(n==1&&(o?u.matchType(o.type)||(f=u.fillBefore(kt.from(o),!1)):a&&c.compatibleContent(a.type)))return{sliceDepth:r,frontierDepth:l,parent:a,inject:f};if(n==2&&o&&(d=u.findWrapping(o.type)))return{sliceDepth:r,frontierDepth:l,parent:a,wrap:d};if(a&&u.matchType(a.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=fj(e,n);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new Ut(e,n+1,Math.max(r,i.size+n>=e.size-r?n+1:0)),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=fj(e,n);if(i.childCount<=1&&n>0){let a=e.size-n<=n+i.size;this.unplaced=new Ut(d0(e,n-1,1),n-1,a?n-1:r)}else this.unplaced=new Ut(d0(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:i,wrap:a}){for(;this.depth>n;)this.closeFrontierNode();if(a)for(let b=0;b<a.length;b++)this.openFrontierNode(a[b]);let o=this.unplaced,l=r?r.content:o.content,c=o.openStart-e,u=0,d=[],{match:f,type:p}=this.frontier[n];if(i){for(let b=0;b<i.childCount;b++)d.push(i.child(b));f=f.matchFragment(i)}let m=l.size+e-(o.content.size-o.openEnd);for(;u<l.childCount;){let b=l.child(u),y=f.matchType(b.type);if(!y)break;u++,(u>1||c==0||b.content.size)&&(f=y,d.push(Qee(b.mark(p.allowedMarks(b.marks)),u==1?c:0,u==l.childCount?m:-1)))}let x=u==l.childCount;x||(m=-1),this.placed=h0(this.placed,n,kt.from(d)),this.frontier[n].match=f,x&&m<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let b=0,y=l;b<m;b++){let v=y.lastChild;this.frontier.push({type:v.type,match:v.contentMatchAt(v.childCount)}),y=v.content}this.unplaced=x?e==0?Ut.empty:new Ut(d0(o.content,e-1,1),e-1,m<0?o.openEnd:e-1):new Ut(d0(o.content,e,u),o.openStart,o.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],n;if(!e.type.isTextblock||!mj(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(n=this.findCloseLevel(this.$to))&&n.depth==this.depth)return-1;let{depth:r}=this.$to,i=this.$to.after(r);for(;r>1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:i}=this.frontier[n],a=n<e.depth&&e.end(n+1)==e.pos+(e.depth-(n+1)),o=mj(e,n,i,r,a);if(o){for(let l=n-1;l>=0;l--){let{match:c,type:u}=this.frontier[l],d=mj(e,l,u,c,!0);if(!d||d.childCount)continue e}return{depth:n,fit:o,move:a?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=h0(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let i=e.node(r),a=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,a)}return e}openFrontierNode(e,n=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=h0(this.placed,this.depth,kt.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(kt.empty,!0);n.childCount&&(this.placed=h0(this.placed,this.frontier.length,n))}}function d0(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(d0(t.firstChild.content,e-1,n)))}function h0(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(h0(t.lastChild.content,e-1,n)))}function fj(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function Qee(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,Qee(r.firstChild,e-1,r.childCount==1?n-1:0))),e>0&&(r=t.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(kt.empty,!0)))),t.copy(r)}function mj(t,e,n,r,i){let a=t.node(e),o=i?t.indexAfter(e):t.index(e);if(o==a.childCount&&!n.compatibleContent(a.type))return null;let l=r.fillBefore(a.content,!0,o);return l&&!g6e(n,a.content,o)?l:null}function g6e(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function x6e(t){return t.spec.defining||t.spec.definingForContent}function b6e(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let i=t.doc.resolve(e),a=t.doc.resolve(n);if(Yee(i,a,r))return t.step(new xa(e,n,r));let o=Jee(i,a);o[o.length-1]==0&&o.pop();let l=-(i.depth+1);o.unshift(l);for(let p=i.depth,m=i.pos-1;p>0;p--,m--){let x=i.node(p).type.spec;if(x.defining||x.definingAsContext||x.isolating)break;o.indexOf(p)>-1?l=p:i.before(p)==m&&o.splice(1,0,-p)}let c=o.indexOf(l),u=[],d=r.openStart;for(let p=r.content,m=0;;m++){let x=p.firstChild;if(u.push(x),m==r.openStart)break;p=x.content}for(let p=d-1;p>=0;p--){let m=u[p],x=x6e(m.type);if(x&&!m.sameMarkup(i.node(Math.abs(l)-1)))d=p;else if(x||!m.type.isTextblock)break}for(let p=r.openStart;p>=0;p--){let m=(p+d+1)%(r.openStart+1),x=u[m];if(x)for(let b=0;b<o.length;b++){let y=o[(b+c)%o.length],v=!0;y<0&&(v=!1,y=-y);let S=i.node(y-1),N=i.index(y-1);if(S.canReplaceWith(N,N,x.type,x.marks))return t.replace(i.before(y),v?a.after(y):n,new Ut(Zee(r.content,0,r.openStart,m),m,r.openEnd))}}let f=t.steps.length;for(let p=o.length-1;p>=0&&(t.replace(e,n,r),!(t.steps.length>f));p--){let m=o[p];m<0||(e=i.before(m),n=a.after(m))}}function Zee(t,e,n,r,i){if(e<n){let a=t.firstChild;t=t.replaceChild(0,a.copy(Zee(a.content,e+1,n,r,a)))}if(e>r){let a=i.contentMatchAt(0),o=a.fillBefore(t).append(t);t=o.append(a.matchFragment(o).fillBefore(kt.empty,!0))}return t}function y6e(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let i=m6e(t.doc,e,r.type);i!=null&&(e=n=i)}t.replaceRange(e,n,new Ut(kt.from(r),0,0))}function v6e(t,e,n){let r=t.doc.resolve(e),i=t.doc.resolve(n),a=Jee(r,i);for(let o=0;o<a.length;o++){let l=a[o],c=o==a.length-1;if(c&&l==0||r.node(l).type.contentMatch.validEnd)return t.delete(r.start(l),i.end(l));if(l>0&&(c||r.node(l-1).canReplace(r.index(l-1),i.indexAfter(l-1))))return t.delete(r.before(l),i.after(l))}for(let o=1;o<=r.depth&&o<=i.depth;o++)if(e-r.start(o)==r.depth-o&&n>r.end(o)&&i.end(o)-n!=i.depth-o&&r.start(o-1)==i.start(o-1)&&r.node(o-1).canReplace(r.index(o-1),i.index(o-1)))return t.delete(r.before(o),n);t.delete(e,n)}function Jee(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let i=r;i>=0;i--){let a=t.start(i);if(a<t.pos-(t.depth-i)||e.end(i)>e.pos+(e.depth-i)||t.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(a==e.start(i)||i==t.depth&&i==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==a-1)&&n.push(i)}return n}class Rg extends rs{constructor(e,n,r){super(),this.pos=e,this.attr=n,this.value=r}apply(e){let n=e.nodeAt(this.pos);if(!n)return Bi.fail("No node at attribute step's position");let r=Object.create(null);for(let a in n.attrs)r[a]=n.attrs[a];r[this.attr]=this.value;let i=n.type.create(r,null,n.marks);return Bi.fromReplace(e,this.pos,this.pos+1,new Ut(kt.from(i),0,n.isLeaf?0:1))}getMap(){return uo.empty}invert(e){return new Rg(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Rg(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new Rg(n.pos,n.attr,n.value)}}rs.jsonID("attr",Rg);class My extends rs{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let i in e.attrs)n[i]=e.attrs[i];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return Bi.ok(r)}getMap(){return uo.empty}invert(e){return new My(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 My(n.attr,n.value)}}rs.jsonID("docAttr",My);let ox=class extends Error{};ox=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};ox.prototype=Object.create(Error.prototype);ox.prototype.constructor=ox;ox.prototype.name="TransformError";class ete{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Sy}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new ox(n.failed);return this}maybeStep(e){let n=e.apply(this.doc);return n.failed||this.addStep(e,n.doc),n}get docChanged(){return this.steps.length>0}addStep(e,n){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=n}replace(e,n=e,r=Ut.empty){let i=N2(this.doc,e,n,r);return i&&this.step(i),this}replaceWith(e,n,r){return this.replace(e,n,new Ut(kt.from(r),0,0))}delete(e,n){return this.replace(e,n,Ut.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return b6e(this,e,n,r),this}replaceRangeWith(e,n,r){return y6e(this,e,n,r),this}deleteRange(e,n){return v6e(this,e,n),this}lift(e,n){return i6e(this,e,n),this}join(e,n=1){return f6e(this,e,n),this}wrap(e,n){return o6e(this,e,n),this}setBlockType(e,n=e,r,i=null){return l6e(this,e,n,r,i),this}setNodeMarkup(e,n,r=null,i){return u6e(this,e,n,r,i),this}setNodeAttribute(e,n,r){return this.step(new Rg(e,n,r)),this}setDocAttribute(e,n){return this.step(new My(e,n)),this}addNodeMark(e,n){return this.step(new th(e,n)),this}removeNodeMark(e,n){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(n instanceof Rr)n.isInSet(r.marks)&&this.step(new _m(e,n));else{let i=r.marks,a,o=[];for(;a=n.isInSet(i);)o.push(new _m(e,a)),i=a.removeFromSet(i);for(let l=o.length-1;l>=0;l--)this.step(o[l])}return this}split(e,n=1,r){return d6e(this,e,n,r),this}addMark(e,n,r){return t6e(this,e,n,r),this}removeMark(e,n,r){return n6e(this,e,n,r),this}clearIncompatible(e,n,r){return gL(this,e,n,r),this}}const pj=Object.create(null);class An{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new w6e(e.min(n),e.max(n))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let n=0;n<e.length;n++)if(e[n].$from.pos!=e[n].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,n=Ut.empty){let r=n.content.lastChild,i=null;for(let l=0;l<n.openEnd;l++)i=r,r=r.lastChild;let a=e.steps.length,o=this.ranges;for(let l=0;l<o.length;l++){let{$from:c,$to:u}=o[l],d=e.mapping.slice(a);e.replaceRange(d.map(c.pos),d.map(u.pos),l?Ut.empty:n),l==0&&G7(e,a,(r?r.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,n){let r=e.steps.length,i=this.ranges;for(let a=0;a<i.length;a++){let{$from:o,$to:l}=i[a],c=e.mapping.slice(r),u=c.map(o.pos),d=c.map(l.pos);a?e.deleteRange(u,d):(e.replaceRangeWith(u,d,n),G7(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let i=e.parent.inlineContent?new mn(e):lg(e.node(0),e.parent,e.pos,e.index(),n,r);if(i)return i;for(let a=e.depth-1;a>=0;a--){let o=n<0?lg(e.node(0),e.node(a),e.before(a+1),e.index(a),n,r):lg(e.node(0),e.node(a),e.after(a+1),e.index(a)+1,n,r);if(o)return o}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new xo(e.node(0))}static atStart(e){return lg(e,e,0,0,1)||new xo(e)}static atEnd(e){return lg(e,e,e.content.size,e.childCount,-1)||new xo(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=pj[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in pj)throw new RangeError("Duplicate use of selection JSON ID "+e);return pj[e]=n,n.prototype.jsonID=e,n}getBookmark(){return mn.between(this.$anchor,this.$head).getBookmark()}}An.prototype.visible=!0;class w6e{constructor(e,n){this.$from=e,this.$to=n}}let $7=!1;function V7(t){!$7&&!t.parent.inlineContent&&($7=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class mn extends An{constructor(e,n=e){V7(e),V7(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return An.near(r);let i=e.resolve(n.map(this.anchor));return new mn(i.parent.inlineContent?i:r,r)}replace(e,n=Ut.empty){if(super.replace(e,n),n==Ut.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof mn&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new k2(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new mn(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let i=e.resolve(n);return new this(i,r==n?i:e.resolve(r))}static between(e,n,r){let i=e.pos-n.pos;if((!r||i)&&(r=i>=0?1:-1),!n.parent.inlineContent){let a=An.findFrom(n,r,!0)||An.findFrom(n,-r,!0);if(a)n=a.$head;else return An.near(n,r)}return e.parent.inlineContent||(i==0?e=n:(e=(An.findFrom(e,-r,!0)||An.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=i<0&&(e=n))),new mn(e,n)}}An.jsonID("text",mn);class k2{constructor(e,n){this.anchor=e,this.head=n}map(e){return new k2(e.map(this.anchor),e.map(this.head))}resolve(e){return mn.between(e.resolve(this.anchor),e.resolve(this.head))}}class Qt extends An{constructor(e){let n=e.nodeAfter,r=e.node(0).resolve(e.pos+n.nodeSize);super(e,r),this.node=n}map(e,n){let{deleted:r,pos:i}=n.mapResult(this.anchor),a=e.resolve(i);return r?An.near(a):new Qt(a)}content(){return new Ut(kt.from(this.node),0,0)}eq(e){return e instanceof Qt&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new bL(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new Qt(e.resolve(n.anchor))}static create(e,n){return new Qt(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}Qt.prototype.visible=!1;An.jsonID("node",Qt);class bL{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new k2(r,r):new bL(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&Qt.isSelectable(r)?new Qt(n):An.near(n)}}class xo extends An{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=Ut.empty){if(n==Ut.empty){e.delete(0,e.doc.content.size);let r=An.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new xo(e)}map(e){return new xo(e)}eq(e){return e instanceof xo}getBookmark(){return _6e}}An.jsonID("all",xo);const _6e={map(){return this},resolve(t){return new xo(t)}};function lg(t,e,n,r,i,a=!1){if(e.inlineContent)return mn.create(t,n);for(let o=r-(i>0?0:1);i>0?o<e.childCount:o>=0;o+=i){let l=e.child(o);if(l.isAtom){if(!a&&Qt.isSelectable(l))return Qt.create(t,n-(i<0?l.nodeSize:0))}else{let c=lg(t,l,n+i,i<0?l.childCount:0,i,a);if(c)return c}n+=l.nodeSize*i}return null}function G7(t,e,n){let r=t.steps.length-1;if(r<e)return;let i=t.steps[r];if(!(i instanceof xa||i instanceof wa))return;let a=t.mapping.maps[r],o;a.forEach((l,c,u,d)=>{o==null&&(o=d)}),t.setSelection(An.near(t.doc.resolve(o),n))}const q7=1,e1=2,W7=4;class S6e extends ete{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|q7)&~e1,this.storedMarks=null,this}get selectionSet(){return(this.updated&q7)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=e1,this}ensureMarks(e){return Rr.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&e1)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~e1,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,n=!0){let r=this.selection;return n&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||Rr.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let i=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),!e)return this.deleteRange(n,r);let a=this.storedMarks;if(!a){let o=this.doc.resolve(n);a=r==n?o.marks():o.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,i.text(e,a)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(An.near(this.selection.$to)),this}}setMeta(e,n){return this.meta[typeof e=="string"?e:e.key]=n,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=W7,this}get scrolledIntoView(){return(this.updated&W7)>0}}function K7(t,e){return!e||!t?t:t.bind(e)}class f0{constructor(e,n,r){this.name=e,this.init=K7(n.init,r),this.apply=K7(n.apply,r)}}const M6e=[new f0("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new f0("selection",{init(t,e){return t.selection||An.atStart(e.doc)},apply(t){return t.selection}}),new f0("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new f0("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class gj{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=M6e.slice(),n&&n.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new f0(r.key,r.spec.state,r))})}}class vg{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,n=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=n){let i=this.config.plugins[r];if(i.spec.filterTransaction&&!i.spec.filterTransaction.call(i,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let n=[e],r=this.applyInner(e),i=null;for(;;){let a=!1;for(let o=0;o<this.config.plugins.length;o++){let l=this.config.plugins[o];if(l.spec.appendTransaction){let c=i?i[o].n:0,u=i?i[o].state:this,d=c<n.length&&l.spec.appendTransaction.call(l,c?n.slice(c):n,u,r);if(d&&r.filterTransaction(d,o)){if(d.setMeta("appendedTransaction",e),!i){i=[];for(let f=0;f<this.config.plugins.length;f++)i.push(f<o?{state:r,n:n.length}:{state:this,n:0})}n.push(d),r=r.applyInner(d),a=!0}i&&(i[o]={state:r,n:n.length})}}if(!a)return{state:r,transactions:n}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let n=new vg(this.config),r=this.config.fields;for(let i=0;i<r.length;i++){let a=r[i];n[a.name]=a.apply(e,this[a.name],this,n)}return n}get tr(){return new S6e(this)}static create(e){let n=new gj(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new vg(n);for(let i=0;i<n.fields.length;i++)r[n.fields[i].name]=n.fields[i].init(e,r);return r}reconfigure(e){let n=new gj(this.schema,e.plugins),r=n.fields,i=new vg(n);for(let a=0;a<r.length;a++){let o=r[a].name;i[o]=this.hasOwnProperty(o)?this[o]:r[a].init(e,i)}return i}toJSON(e){let n={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(n.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[r],a=i.spec.state;a&&a.toJSON&&(n[r]=a.toJSON.call(i,this[i.key]))}return n}static fromJSON(e,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new gj(e.schema,e.plugins),a=new vg(i);return i.fields.forEach(o=>{if(o.name=="doc")a.doc=hh.fromJSON(e.schema,n.doc);else if(o.name=="selection")a.selection=An.fromJSON(a.doc,n.selection);else if(o.name=="storedMarks")n.storedMarks&&(a.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let c=r[l],u=c.spec.state;if(c.key==o.name&&u&&u.fromJSON&&Object.prototype.hasOwnProperty.call(n,l)){a[o.name]=u.fromJSON.call(c,e,n[l],a);return}}a[o.name]=o.init(e,a)}}),a}}function tte(t,e,n){for(let r in t){let i=t[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=tte(i,e,{})),n[r]=i}return n}class ui{constructor(e){this.spec=e,this.props={},e.props&&tte(e.props,this,this.props),this.key=e.key?e.key.key:nte("plugin")}getState(e){return e[this.key]}}const xj=Object.create(null);function nte(t){return t in xj?t+"$"+ ++xj[t]:(xj[t]=0,t+"$")}class oa{constructor(e="key"){this.key=nte(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const yL=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function rte(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const ite=(t,e,n)=>{let r=rte(t,n);if(!r)return!1;let i=vL(r);if(!i){let o=r.blockRange(),l=o&&Ox(o);return l==null?!1:(e&&e(t.tr.lift(o,l).scrollIntoView()),!0)}let a=i.nodeBefore;if(fte(t,i,e,-1))return!0;if(r.parent.content.size==0&&(lx(a,"end")||Qt.isSelectable(a)))for(let o=r.depth;;o--){let l=N2(t.doc,r.before(o),r.after(o),Ut.empty);if(l&&l.slice.size<l.to-l.from){if(e){let c=t.tr.step(l);c.setSelection(lx(a,"end")?An.findFrom(c.doc.resolve(c.mapping.map(i.pos,-1)),-1):Qt.create(c.doc,i.pos-a.nodeSize)),e(c.scrollIntoView())}return!0}if(o==1||r.node(o-1).childCount>1)break}return a.isAtom&&i.depth==r.depth-1?(e&&e(t.tr.delete(i.pos-a.nodeSize,i.pos).scrollIntoView()),!0):!1},N6e=(t,e,n)=>{let r=rte(t,n);if(!r)return!1;let i=vL(r);return i?ate(t,i,e):!1},k6e=(t,e,n)=>{let r=ote(t,n);if(!r)return!1;let i=wL(r);return i?ate(t,i,e):!1};function ate(t,e,n){let r=e.nodeBefore,i=r,a=e.pos-1;for(;!i.isTextblock;a--){if(i.type.spec.isolating)return!1;let d=i.lastChild;if(!d)return!1;i=d}let o=e.nodeAfter,l=o,c=e.pos+1;for(;!l.isTextblock;c++){if(l.type.spec.isolating)return!1;let d=l.firstChild;if(!d)return!1;l=d}let u=N2(t.doc,a,c,Ut.empty);if(!u||u.from!=a||u instanceof xa&&u.slice.size>=c-a)return!1;if(n){let d=t.tr.step(u);d.setSelection(mn.create(d.doc,a)),n(d.scrollIntoView())}return!0}function lx(t,e,n=!1){for(let r=t;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}const ste=(t,e,n)=>{let{$head:r,empty:i}=t.selection,a=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;a=vL(r)}let o=a&&a.nodeBefore;return!o||!Qt.isSelectable(o)?!1:(e&&e(t.tr.setSelection(Qt.create(t.doc,a.pos-o.nodeSize)).scrollIntoView()),!0)};function vL(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){if(t.index(e)>0)return t.doc.resolve(t.before(e+1));if(t.node(e).type.spec.isolating)break}return null}function ote(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const lte=(t,e,n)=>{let r=ote(t,n);if(!r)return!1;let i=wL(r);if(!i)return!1;let a=i.nodeAfter;if(fte(t,i,e,1))return!0;if(r.parent.content.size==0&&(lx(a,"start")||Qt.isSelectable(a))){let o=N2(t.doc,r.before(),r.after(),Ut.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=t.tr.step(o);l.setSelection(lx(a,"start")?An.findFrom(l.doc.resolve(l.mapping.map(i.pos)),1):Qt.create(l.doc,l.mapping.map(i.pos))),e(l.scrollIntoView())}return!0}}return a.isAtom&&i.depth==r.depth-1?(e&&e(t.tr.delete(i.pos,i.pos+a.nodeSize).scrollIntoView()),!0):!1},cte=(t,e,n)=>{let{$head:r,empty:i}=t.selection,a=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size)return!1;a=wL(r)}let o=a&&a.nodeAfter;return!o||!Qt.isSelectable(o)?!1:(e&&e(t.tr.setSelection(Qt.create(t.doc,a.pos)).scrollIntoView()),!0)};function wL(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){let n=t.node(e);if(t.index(e)+1<n.childCount)return t.doc.resolve(t.after(e+1));if(n.type.spec.isolating)break}return null}const E6e=(t,e)=>{let n=t.selection,r=n instanceof Qt,i;if(r){if(n.node.isTextblock||!zh(t.doc,n.from))return!1;i=n.from}else if(i=M2(t.doc,n.from,-1),i==null)return!1;if(e){let a=t.tr.join(i);r&&a.setSelection(Qt.create(a.doc,i-t.doc.resolve(i).nodeBefore.nodeSize)),e(a.scrollIntoView())}return!0},T6e=(t,e)=>{let n=t.selection,r;if(n instanceof Qt){if(n.node.isTextblock||!zh(t.doc,n.to))return!1;r=n.to}else if(r=M2(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},A6e=(t,e)=>{let{$from:n,$to:r}=t.selection,i=n.blockRange(r),a=i&&Ox(i);return a==null?!1:(e&&e(t.tr.lift(i,a).scrollIntoView()),!0)},ute=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(`
- `).scrollIntoView()),!0)};function _L(t){for(let e=0;e<t.edgeCount;e++){let{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}const C6e=(t,e)=>{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),a=n.indexAfter(-1),o=_L(i.contentMatchAt(a));if(!o||!i.canReplaceWith(a,a,o))return!1;if(e){let l=n.after(),c=t.tr.replaceWith(l,l,o.createAndFill());c.setSelection(An.near(c.doc.resolve(l),1)),e(c.scrollIntoView())}return!0},dte=(t,e)=>{let n=t.selection,{$from:r,$to:i}=n;if(n instanceof xo||r.parent.inlineContent||i.parent.inlineContent)return!1;let a=_L(i.parent.contentMatchAt(i.indexAfter()));if(!a||!a.isTextblock)return!1;if(e){let o=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,l=t.tr.insert(o,a.createAndFill());l.setSelection(mn.create(l.doc,o+1)),e(l.scrollIntoView())}return!0},hte=(t,e)=>{let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let a=n.before();if(ju(t.doc,a))return e&&e(t.tr.split(a).scrollIntoView()),!0}let r=n.blockRange(),i=r&&Ox(r);return i==null?!1:(e&&e(t.tr.lift(r,i).scrollIntoView()),!0)};function j6e(t){return(e,n)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof Qt&&e.selection.node.isBlock)return!r.parentOffset||!ju(e.doc,r.pos)?!1:(n&&n(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let a=[],o,l,c=!1,u=!1;for(let m=r.depth;;m--)if(r.node(m).isBlock){c=r.end(m)==r.pos+(r.depth-m),u=r.start(m)==r.pos-(r.depth-m),l=_L(r.node(m-1).contentMatchAt(r.indexAfter(m-1))),a.unshift(c&&l?{type:l}:null),o=m;break}else{if(m==1)return!1;a.unshift(null)}let d=e.tr;(e.selection instanceof mn||e.selection instanceof xo)&&d.deleteSelection();let f=d.mapping.map(r.pos),p=ju(d.doc,f,a.length,a);if(p||(a[0]=l?{type:l}:null,p=ju(d.doc,f,a.length,a)),!p)return!1;if(d.split(f,a.length,a),!c&&u&&r.node(o).type!=l){let m=d.mapping.map(r.before(o)),x=d.doc.resolve(m);l&&r.node(o-1).canReplaceWith(x.index(),x.index()+1,l)&&d.setNodeMarkup(d.mapping.map(r.before(o)),l)}return n&&n(d.scrollIntoView()),!0}}const P6e=j6e(),D6e=(t,e)=>{let{$from:n,to:r}=t.selection,i,a=n.sharedDepth(r);return a==0?!1:(i=n.before(a),e&&e(t.tr.setSelection(Qt.create(t.doc,i))),!0)};function R6e(t,e,n){let r=e.nodeBefore,i=e.nodeAfter,a=e.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&e.parent.canReplace(a-1,a)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(a,a+1)||!(i.isTextblock||zh(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function fte(t,e,n,r){let i=e.nodeBefore,a=e.nodeAfter,o,l,c=i.type.spec.isolating||a.type.spec.isolating;if(!c&&R6e(t,e,n))return!0;let u=!c&&e.parent.canReplace(e.index(),e.index()+1);if(u&&(o=(l=i.contentMatchAt(i.childCount)).findWrapping(a.type))&&l.matchType(o[0]||a.type).validEnd){if(n){let m=e.pos+a.nodeSize,x=kt.empty;for(let v=o.length-1;v>=0;v--)x=kt.from(o[v].create(null,x));x=kt.from(i.copy(x));let b=t.tr.step(new wa(e.pos-1,m,e.pos,m,new Ut(x,1,0),o.length,!0)),y=b.doc.resolve(m+2*o.length);y.nodeAfter&&y.nodeAfter.type==i.type&&zh(b.doc,y.pos)&&b.join(y.pos),n(b.scrollIntoView())}return!0}let d=a.type.spec.isolating||r>0&&c?null:An.findFrom(e,1),f=d&&d.$from.blockRange(d.$to),p=f&&Ox(f);if(p!=null&&p>=e.depth)return n&&n(t.tr.lift(f,p).scrollIntoView()),!0;if(u&&lx(a,"start",!0)&&lx(i,"end")){let m=i,x=[];for(;x.push(m),!m.isTextblock;)m=m.lastChild;let b=a,y=1;for(;!b.isTextblock;b=b.firstChild)y++;if(m.canReplace(m.childCount,m.childCount,b.content)){if(n){let v=kt.empty;for(let N=x.length-1;N>=0;N--)v=kt.from(x[N].copy(v));let S=t.tr.step(new wa(e.pos-x.length,e.pos+a.nodeSize,e.pos+y,e.pos+a.nodeSize-y,new Ut(v,x.length,0),0,!0));n(S.scrollIntoView())}return!0}}return!1}function mte(t){return function(e,n){let r=e.selection,i=t<0?r.$from:r.$to,a=i.depth;for(;i.node(a).isInline;){if(!a)return!1;a--}return i.node(a).isTextblock?(n&&n(e.tr.setSelection(mn.create(e.doc,t<0?i.start(a):i.end(a)))),!0):!1}}const O6e=mte(-1),L6e=mte(1);function F6e(t,e=null){return function(n,r){let{$from:i,$to:a}=n.selection,o=i.blockRange(a),l=o&&xL(o,t,e);return l?(r&&r(n.tr.wrap(o,l).scrollIntoView()),!0):!1}}function X7(t,e=null){return function(n,r){let i=!1;for(let a=0;a<n.selection.ranges.length&&!i;a++){let{$from:{pos:o},$to:{pos:l}}=n.selection.ranges[a];n.doc.nodesBetween(o,l,(c,u)=>{if(i)return!1;if(!(!c.isTextblock||c.hasMarkup(t,e)))if(c.type==t)i=!0;else{let d=n.doc.resolve(u),f=d.index();i=d.parent.canReplaceWith(f,f+1,t)}})}if(!i)return!1;if(r){let a=n.tr;for(let o=0;o<n.selection.ranges.length;o++){let{$from:{pos:l},$to:{pos:c}}=n.selection.ranges[o];a.setBlockType(l,c,t,e)}r(a.scrollIntoView())}return!0}}function SL(...t){return function(e,n,r){for(let i=0;i<t.length;i++)if(t[i](e,n,r))return!0;return!1}}SL(yL,ite,ste);SL(yL,lte,cte);SL(ute,dte,hte,P6e);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function I6e(t,e=null){return function(n,r){let{$from:i,$to:a}=n.selection,o=i.blockRange(a);if(!o)return!1;let l=r?n.tr:null;return U6e(l,o,t,e)?(r&&r(l.scrollIntoView()),!0):!1}}function U6e(t,e,n,r=null){let i=!1,a=e,o=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(n)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let c=o.resolve(e.start-2);a=new uM(c,c,e.depth),e.endIndex<e.parent.childCount&&(e=new uM(e.$from,o.resolve(e.$to.end(e.depth)),e.depth)),i=!0}let l=xL(a,n,r,e);return l?(t&&z6e(t,e,l,i,n),!0):!1}function z6e(t,e,n,r,i){let a=kt.empty;for(let d=n.length-1;d>=0;d--)a=kt.from(n[d].type.create(n[d].attrs,a));t.step(new wa(e.start-(r?2:0),e.end,e.start,e.end,new Ut(a,0,0),n.length,!0));let o=0;for(let d=0;d<n.length;d++)n[d].type==i&&(o=d+1);let l=n.length-o,c=e.start+n.length-(r?2:0),u=e.parent;for(let d=e.startIndex,f=e.endIndex,p=!0;d<f;d++,p=!1)!p&&ju(t.doc,c,l)&&(t.split(c,l),c+=2*l),c+=u.child(d).nodeSize;return t}function B6e(t){return function(e,n){let{$from:r,$to:i}=e.selection,a=r.blockRange(i,o=>o.childCount>0&&o.firstChild.type==t);return a?n?r.node(a.depth-1).type==t?H6e(e,n,t,a):$6e(e,n,a):!0:!1}}function H6e(t,e,n,r){let i=t.tr,a=r.end,o=r.$to.end(r.depth);a<o&&(i.step(new wa(a-1,o,a,o,new Ut(kt.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new uM(i.doc.resolve(r.$from.pos),i.doc.resolve(o),r.depth));const l=Ox(r);if(l==null)return!1;i.lift(r,l);let c=i.doc.resolve(i.mapping.map(a,-1)-1);return zh(i.doc,c.pos)&&c.nodeBefore.type==c.nodeAfter.type&&i.join(c.pos),e(i.scrollIntoView()),!0}function $6e(t,e,n){let r=t.tr,i=n.parent;for(let m=n.end,x=n.endIndex-1,b=n.startIndex;x>b;x--)m-=i.child(x).nodeSize,r.delete(m-1,m+1);let a=r.doc.resolve(n.start),o=a.nodeAfter;if(r.mapping.map(n.end)!=n.start+a.nodeAfter.nodeSize)return!1;let l=n.startIndex==0,c=n.endIndex==i.childCount,u=a.node(-1),d=a.index(-1);if(!u.canReplace(d+(l?0:1),d+1,o.content.append(c?kt.empty:kt.from(i))))return!1;let f=a.pos,p=f+o.nodeSize;return r.step(new wa(f-(l?1:0),p+(c?1:0),f+1,p-1,new Ut((l?kt.empty:kt.from(i.copy(kt.empty))).append(c?kt.empty:kt.from(i.copy(kt.empty))),l?0:1,c?0:1),l?0:1)),e(r.scrollIntoView()),!0}function V6e(t){return function(e,n){let{$from:r,$to:i}=e.selection,a=r.blockRange(i,u=>u.childCount>0&&u.firstChild.type==t);if(!a)return!1;let o=a.startIndex;if(o==0)return!1;let l=a.parent,c=l.child(o-1);if(c.type!=t)return!1;if(n){let u=c.lastChild&&c.lastChild.type==l.type,d=kt.from(u?t.create():null),f=new Ut(kt.from(t.create(null,kt.from(l.type.create(null,d)))),u?3:1,0),p=a.start,m=a.end;n(e.tr.step(new wa(p-(u?3:1),m,p,m,f,1,!0)).scrollIntoView())}return!0}}const La=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},cx=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let DD=null;const uu=function(t,e,n){let r=DD||(DD=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},G6e=function(){DD=null},Sm=function(t,e,n,r){return n&&(Y7(t,e,n,r,-1)||Y7(t,e,n,r,1))},q6e=/^(img|br|input|textarea|hr)$/i;function Y7(t,e,n,r,i){for(var a;;){if(t==n&&e==r)return!0;if(e==(i<0?0:Qo(t))){let o=t.parentNode;if(!o||o.nodeType!=1||gv(t)||q6e.test(t.nodeName)||t.contentEditable=="false")return!1;e=La(t)+(i<0?0:1),t=o}else if(t.nodeType==1){let o=t.childNodes[e+(i<0?-1:0)];if(o.nodeType==1&&o.contentEditable=="false")if(!((a=o.pmViewDesc)===null||a===void 0)&&a.ignoreForSelection)e+=i;else return!1;else t=o,e=i<0?Qo(t):0}else return!1}}function Qo(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function W6e(t,e){for(;;){if(t.nodeType==3&&e)return t;if(t.nodeType==1&&e>0){if(t.contentEditable=="false")return null;t=t.childNodes[e-1],e=Qo(t)}else if(t.parentNode&&!gv(t))e=La(t),t=t.parentNode;else return null}}function K6e(t,e){for(;;){if(t.nodeType==3&&e<t.nodeValue.length)return t;if(t.nodeType==1&&e<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[e],e=0}else if(t.parentNode&&!gv(t))e=La(t)+1,t=t.parentNode;else return null}}function X6e(t,e,n){for(let r=e==0,i=e==Qo(t);r||i;){if(t==n)return!0;let a=La(t);if(t=t.parentNode,!t)return!1;r=r&&a==0,i=i&&a==Qo(t)}}function gv(t){let e;for(let n=t;n&&!(e=n.pmViewDesc);n=n.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const E2=function(t){return t.focusNode&&Sm(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function Af(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function Y6e(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function Q6e(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(Qo(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(Qo(r.startContainer),r.startOffset)}}}const wc=typeof navigator<"u"?navigator:null,Q7=typeof document<"u"?document:null,Bh=wc&&wc.userAgent||"",RD=/Edge\/(\d+)/.exec(Bh),pte=/MSIE \d/.exec(Bh),OD=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Bh),Hs=!!(pte||OD||RD),fh=pte?document.documentMode:OD?+OD[1]:RD?+RD[1]:0,il=!Hs&&/gecko\/(\d+)/i.test(Bh);il&&+(/Firefox\/(\d+)/.exec(Bh)||[0,0])[1];const LD=!Hs&&/Chrome\/(\d+)/.exec(Bh),Za=!!LD,gte=LD?+LD[1]:0,ys=!Hs&&!!wc&&/Apple Computer/.test(wc.vendor),ux=ys&&(/Mobile\/\w+/.test(Bh)||!!wc&&wc.maxTouchPoints>2),Go=ux||(wc?/Mac/.test(wc.platform):!1),Z6e=wc?/Win/.test(wc.platform):!1,Su=/Android \d/.test(Bh),xv=!!Q7&&"webkitFontSmoothing"in Q7.documentElement.style,J6e=xv?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function eHe(t){let e=t.defaultView&&t.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function ru(t,e){return typeof t=="number"?t:t[e]}function tHe(t){let e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,r=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*r}}function Z7(t,e,n){let r=t.someProp("scrollThreshold")||0,i=t.someProp("scrollMargin")||5,a=t.dom.ownerDocument;for(let o=n||t.dom;o;){if(o.nodeType!=1){o=cx(o);continue}let l=o,c=l==a.body,u=c?eHe(a):tHe(l),d=0,f=0;if(e.top<u.top+ru(r,"top")?f=-(u.top-e.top+ru(i,"top")):e.bottom>u.bottom-ru(r,"bottom")&&(f=e.bottom-e.top>u.bottom-u.top?e.top+ru(i,"top")-u.top:e.bottom-u.bottom+ru(i,"bottom")),e.left<u.left+ru(r,"left")?d=-(u.left-e.left+ru(i,"left")):e.right>u.right-ru(r,"right")&&(d=e.right-u.right+ru(i,"right")),d||f)if(c)a.defaultView.scrollBy(d,f);else{let m=l.scrollLeft,x=l.scrollTop;f&&(l.scrollTop+=f),d&&(l.scrollLeft+=d);let b=l.scrollLeft-m,y=l.scrollTop-x;e={left:e.left-b,top:e.top-y,right:e.right-b,bottom:e.bottom-y}}let p=c?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(p))break;o=p=="absolute"?o.offsetParent:cx(o)}}function nHe(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,i;for(let a=(e.left+e.right)/2,o=n+1;o<Math.min(innerHeight,e.bottom);o+=5){let l=t.root.elementFromPoint(a,o);if(!l||l==t.dom||!t.dom.contains(l))continue;let c=l.getBoundingClientRect();if(c.top>=n-20){r=l,i=c.top;break}}return{refDOM:r,refTop:i,stack:xte(t.dom)}}function xte(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=cx(r));return e}function rHe({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;bte(n,r==0?0:r-e)}function bte(t,e){for(let n=0;n<t.length;n++){let{dom:r,top:i,left:a}=t[n];r.scrollTop!=i+e&&(r.scrollTop=i+e),r.scrollLeft!=a&&(r.scrollLeft=a)}}let eg=null;function iHe(t){if(t.setActive)return t.setActive();if(eg)return t.focus(eg);let e=xte(t);t.focus(eg==null?{get preventScroll(){return eg={preventScroll:!0},!0}}:void 0),eg||(eg=!1,bte(e,0))}function yte(t,e){let n,r=2e8,i,a=0,o=e.top,l=e.top,c,u;for(let d=t.firstChild,f=0;d;d=d.nextSibling,f++){let p;if(d.nodeType==1)p=d.getClientRects();else if(d.nodeType==3)p=uu(d).getClientRects();else continue;for(let m=0;m<p.length;m++){let x=p[m];if(x.top<=o&&x.bottom>=l){o=Math.max(x.bottom,o),l=Math.min(x.top,l);let b=x.left>e.left?x.left-e.left:x.right<e.left?e.left-x.right:0;if(b<r){n=d,r=b,i=b&&n.nodeType==3?{left:x.right<e.left?x.right:x.left,top:e.top}:e,d.nodeType==1&&b&&(a=f+(e.left>=(x.left+x.right)/2?1:0));continue}}else x.top>e.top&&!c&&x.left<=e.left&&x.right>=e.left&&(c=d,u={left:Math.max(x.left,Math.min(x.right,e.left)),top:x.top});!n&&(e.left>=x.right&&e.top>=x.top||e.left>=x.left&&e.top>=x.bottom)&&(a=f+1)}}return!n&&c&&(n=c,i=u,r=0),n&&n.nodeType==3?aHe(n,i):!n||r&&n.nodeType==1?{node:t,offset:a}:yte(n,i)}function aHe(t,e){let n=t.nodeValue.length,r=document.createRange();for(let i=0;i<n;i++){r.setEnd(t,i+1),r.setStart(t,i);let a=Id(r,1);if(a.top!=a.bottom&&ML(e,a))return{node:t,offset:i+(e.left>=(a.left+a.right)/2?1:0)}}return{node:t,offset:0}}function ML(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function sHe(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function oHe(t,e,n){let{node:r,offset:i}=yte(e,n),a=-1;if(r.nodeType==1&&!r.firstChild){let o=r.getBoundingClientRect();a=o.left!=o.right&&n.left>(o.left+o.right)/2?1:-1}return t.docView.posFromDOM(r,i,a)}function lHe(t,e,n,r){let i=-1;for(let a=e,o=!1;a!=t.dom;){let l=t.docView.nearestDesc(a,!0),c;if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((c=l.dom.getBoundingClientRect()).width||c.height)&&(l.node.isBlock&&l.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(l.dom.nodeName)&&(!o&&c.left>r.left||c.top>r.top?i=l.posBefore:(!o&&c.right<r.left||c.bottom<r.top)&&(i=l.posAfter),o=!0),!l.contentDOM&&i<0&&!l.node.isText))return(l.node.isBlock?r.top<(c.top+c.bottom)/2:r.left<(c.left+c.right)/2)?l.posBefore:l.posAfter;a=l.dom.parentNode}return i>-1?i:t.docView.posFromDOM(e,n,-1)}function vte(t,e,n){let r=t.childNodes.length;if(r&&n.top<n.bottom)for(let i=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-n.top)/(n.bottom-n.top))-2)),a=i;;){let o=t.childNodes[a];if(o.nodeType==1){let l=o.getClientRects();for(let c=0;c<l.length;c++){let u=l[c];if(ML(e,u))return vte(o,e,u)}}if((a=(a+1)%r)==i)break}return t}function cHe(t,e){let n=t.dom.ownerDocument,r,i=0,a=Q6e(n,e.left,e.top);a&&({node:r,offset:i}=a);let o=(t.root.elementFromPoint?t.root:n).elementFromPoint(e.left,e.top),l;if(!o||!t.dom.contains(o.nodeType!=1?o.parentNode:o)){let u=t.dom.getBoundingClientRect();if(!ML(e,u)||(o=vte(t.dom,e,u),!o))return null}if(ys)for(let u=o;r&&u;u=cx(u))u.draggable&&(r=void 0);if(o=sHe(o,e),r){if(il&&r.nodeType==1&&(i=Math.min(i,r.childNodes.length),i<r.childNodes.length)){let d=r.childNodes[i],f;d.nodeName=="IMG"&&(f=d.getBoundingClientRect()).right<=e.left&&f.bottom>e.top&&i++}let u;xv&&i&&r.nodeType==1&&(u=r.childNodes[i-1]).nodeType==1&&u.contentEditable=="false"&&u.getBoundingClientRect().top>=e.top&&i--,r==t.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=t.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!="BR")&&(l=lHe(t,r,i,e))}l==null&&(l=oHe(t,o,e));let c=t.docView.nearestDesc(o,!0);return{pos:l,inside:c?c.posAtStart-c.border:-1}}function J7(t){return t.top<t.bottom||t.left<t.right}function Id(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(J7(r))return r}return Array.prototype.find.call(n,J7)||t.getBoundingClientRect()}const uHe=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function wte(t,e,n){let{node:r,offset:i,atom:a}=t.docView.domFromPos(e,n<0?-1:1),o=xv||il;if(r.nodeType==3)if(o&&(uHe.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let c=Id(uu(r,i,i),n);if(il&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let u=Id(uu(r,i-1,i-1),-1);if(u.top==c.top){let d=Id(uu(r,i,i+1),-1);if(d.top!=c.top)return Jb(d,d.left<u.left)}}return c}else{let c=i,u=i,d=n<0?1:-1;return n<0&&!i?(u++,d=-1):n>=0&&i==r.nodeValue.length?(c--,d=1):n<0?c--:u++,Jb(Id(uu(r,c,u),d),d<0)}if(!t.state.doc.resolve(e-(a||0)).parent.inlineContent){if(a==null&&i&&(n<0||i==Qo(r))){let c=r.childNodes[i-1];if(c.nodeType==1)return bj(c.getBoundingClientRect(),!1)}if(a==null&&i<Qo(r)){let c=r.childNodes[i];if(c.nodeType==1)return bj(c.getBoundingClientRect(),!0)}return bj(r.getBoundingClientRect(),n>=0)}if(a==null&&i&&(n<0||i==Qo(r))){let c=r.childNodes[i-1],u=c.nodeType==3?uu(c,Qo(c)-(o?0:1)):c.nodeType==1&&(c.nodeName!="BR"||!c.nextSibling)?c:null;if(u)return Jb(Id(u,1),!1)}if(a==null&&i<Qo(r)){let c=r.childNodes[i];for(;c.pmViewDesc&&c.pmViewDesc.ignoreForCoords;)c=c.nextSibling;let u=c?c.nodeType==3?uu(c,0,o?0:1):c.nodeType==1?c:null:null;if(u)return Jb(Id(u,-1),!0)}return Jb(Id(r.nodeType==3?uu(r):r,-n),n>=0)}function Jb(t,e){if(t.width==0)return t;let n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function bj(t,e){if(t.height==0)return t;let n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function _te(t,e,n){let r=t.state,i=t.root.activeElement;r!=e&&t.updateState(e),i!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),i!=t.dom&&i&&i.focus()}}function dHe(t,e,n){let r=e.selection,i=n=="up"?r.$from:r.$to;return _te(t,e,()=>{let{node:a}=t.docView.domFromPos(i.pos,n=="up"?-1:1);for(;;){let l=t.docView.nearestDesc(a,!0);if(!l)break;if(l.node.isBlock){a=l.contentDOM||l.dom;break}a=l.dom.parentNode}let o=wte(t,i.pos,1);for(let l=a.firstChild;l;l=l.nextSibling){let c;if(l.nodeType==1)c=l.getClientRects();else if(l.nodeType==3)c=uu(l,0,l.nodeValue.length).getClientRects();else continue;for(let u=0;u<c.length;u++){let d=c[u];if(d.bottom>d.top+1&&(n=="up"?o.top-d.top>(d.bottom-o.top)*2:d.bottom-o.bottom>(o.bottom-d.top)*2))return!1}}return!0})}const hHe=/[\u0590-\u08ac]/;function fHe(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,a=!i,o=i==r.parent.content.size,l=t.domSelection();return l?!hHe.test(r.parent.textContent)||!l.modify?n=="left"||n=="backward"?a:o:_te(t,e,()=>{let{focusNode:c,focusOffset:u,anchorNode:d,anchorOffset:f}=t.domSelectionRange(),p=l.caretBidiLevel;l.modify("move",n,"character");let m=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:x,focusOffset:b}=t.domSelectionRange(),y=x&&!m.contains(x.nodeType==1?x:x.parentNode)||c==x&&u==b;try{l.collapse(d,f),c&&(c!=d||u!=f)&&l.extend&&l.extend(c,u)}catch{}return p!=null&&(l.caretBidiLevel=p),y}):r.pos==r.start()||r.pos==r.end()}let e9=null,t9=null,n9=!1;function mHe(t,e,n){return e9==e&&t9==n?n9:(e9=e,t9=n,n9=n=="up"||n=="down"?dHe(t,e,n):fHe(t,e,n))}const al=0,r9=1,Lf=2,_c=3;class bv{constructor(e,n,r,i){this.parent=e,this.children=n,this.dom=r,this.contentDOM=i,this.dirty=al,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;n<this.children.length;n++)e+=this.children[n].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let n=0,r=this.posAtStart;;n++){let i=this.children[n];if(i==e)return r;r+=i.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,n,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let a,o;if(e==this.contentDOM)a=e.childNodes[n-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;a=e.previousSibling}for(;a&&!((o=a.pmViewDesc)&&o.parent==this);)a=a.previousSibling;return a?this.posBeforeChild(o)+o.size:this.posAtStart}else{let a,o;if(e==this.contentDOM)a=e.childNodes[n];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;a=e.nextSibling}for(;a&&!((o=a.pmViewDesc)&&o.parent==this);)a=a.nextSibling;return a?this.posBeforeChild(o):this.posAtEnd}let i;if(e==this.dom&&this.contentDOM)i=n>La(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let a=e;;a=a.parentNode){if(a==this.dom){i=!1;break}if(a.previousSibling)break}if(i==null&&n==e.childNodes.length)for(let a=e;;a=a.parentNode){if(a==this.dom){i=!0;break}if(a.nextSibling)break}}return i??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,i=e;i;i=i.parentNode){let a=this.getDesc(i),o;if(a&&(!n||a.node))if(r&&(o=a.nodeDOM)&&!(o.nodeType==1?o.contains(e.nodeType==1?e:e.parentNode):o==e))r=!1;else return a}}getDesc(e){let n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let i=e;i;i=i.parentNode){let a=this.getDesc(i);if(a)return a.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;n<this.children.length;n++){let i=this.children[n],a=r+i.size;if(r==e&&a!=r){for(;!i.border&&i.children.length;)for(let o=0;o<i.children.length;o++){let l=i.children[o];if(l.size){i=l;break}}return i}if(e<a)return i.descAt(e-r-i.border);r=a}}domFromPos(e,n){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,i=0;for(let a=0;r<this.children.length;r++){let o=this.children[r],l=a+o.size;if(l>e||o instanceof Mte){i=e-a;break}a=l}if(i)return this.children[r].domFromPos(i-this.children[r].border,n);for(let a;r&&!(a=this.children[r-1]).size&&a instanceof Ste&&a.side>=0;r--);if(n<=0){let a,o=!0;for(;a=r?this.children[r-1]:null,!(!a||a.dom.parentNode==this.contentDOM);r--,o=!1);return a&&n&&o&&!a.border&&!a.domAtom?a.domFromPos(a.size,n):{node:this.contentDOM,offset:a?La(a.dom)+1:0}}else{let a,o=!0;for(;a=r<this.children.length?this.children[r]:null,!(!a||a.dom.parentNode==this.contentDOM);r++,o=!1);return a&&o&&!a.border&&!a.domAtom?a.domFromPos(0,n):{node:this.contentDOM,offset:a?La(a.dom):this.contentDOM.childNodes.length}}}parseRange(e,n,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:n,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let i=-1,a=-1;for(let o=r,l=0;;l++){let c=this.children[l],u=o+c.size;if(i==-1&&e<=u){let d=o+c.border;if(e>=d&&n<=u-c.border&&c.node&&c.contentDOM&&this.contentDOM.contains(c.contentDOM))return c.parseRange(e,n,d);e=o;for(let f=l;f>0;f--){let p=this.children[f-1];if(p.size&&p.dom.parentNode==this.contentDOM&&!p.emptyChildAt(1)){i=La(p.dom)+1;break}e-=p.size}i==-1&&(i=0)}if(i>-1&&(u>n||l==this.children.length-1)){n=u;for(let d=l+1;d<this.children.length;d++){let f=this.children[d];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(-1)){a=La(f.dom);break}n+=f.size}a==-1&&(a=this.contentDOM.childNodes.length);break}o=u}return{node:this.contentDOM,from:e,to:n,fromOffset:i,toOffset:a}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let n=this.children[e<0?0:this.children.length-1];return n.size==0||n.emptyChildAt(e)}domAfterPos(e){let{node:n,offset:r}=this.domFromPos(e,0);if(n.nodeType!=1||r==n.childNodes.length)throw new RangeError("No node after pos "+e);return n.childNodes[r]}setSelection(e,n,r,i=!1){let a=Math.min(e,n),o=Math.max(e,n);for(let m=0,x=0;m<this.children.length;m++){let b=this.children[m],y=x+b.size;if(a>x&&o<y)return b.setSelection(e-x-b.border,n-x-b.border,r,i);x=y}let l=this.domFromPos(e,e?-1:1),c=n==e?l:this.domFromPos(n,n?-1:1),u=r.root.getSelection(),d=r.domSelectionRange(),f=!1;if((il||ys)&&e==n){let{node:m,offset:x}=l;if(m.nodeType==3){if(f=!!(x&&m.nodeValue[x-1]==`
- `),f&&x==m.nodeValue.length)for(let b=m,y;b;b=b.parentNode){if(y=b.nextSibling){y.nodeName=="BR"&&(l=c={node:y.parentNode,offset:La(y)+1});break}let v=b.pmViewDesc;if(v&&v.node&&v.node.isBlock)break}}else{let b=m.childNodes[x-1];f=b&&(b.nodeName=="BR"||b.contentEditable=="false")}}if(il&&d.focusNode&&d.focusNode!=c.node&&d.focusNode.nodeType==1){let m=d.focusNode.childNodes[d.focusOffset];m&&m.contentEditable=="false"&&(i=!0)}if(!(i||f&&ys)&&Sm(l.node,l.offset,d.anchorNode,d.anchorOffset)&&Sm(c.node,c.offset,d.focusNode,d.focusOffset))return;let p=!1;if((u.extend||e==n)&&!(f&&il)){u.collapse(l.node,l.offset);try{e!=n&&u.extend(c.node,c.offset),p=!0}catch{}}if(!p){if(e>n){let x=l;l=c,c=x}let m=document.createRange();m.setEnd(c.node,c.offset),m.setStart(l.node,l.offset),u.removeAllRanges(),u.addRange(m)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let r=0,i=0;i<this.children.length;i++){let a=this.children[i],o=r+a.size;if(r==o?e<=o&&n>=r:e<o&&n>r){let l=r+a.border,c=o-a.border;if(e>=l&&n<=c){this.dirty=e==r||n==o?Lf:r9,e==l&&n==c&&(a.contentLost||a.dom.parentNode!=this.contentDOM)?a.dirty=_c:a.markDirty(e-l,n-l);return}else a.dirty=a.dom==a.contentDOM&&a.dom.parentNode==this.contentDOM&&!a.children.length?Lf:_c}r=o}this.dirty=Lf}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?Lf:r9;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class Ste extends bv{constructor(e,n,r,i){let a,o=n.type.toDOM;if(typeof o=="function"&&(o=o(r,()=>{if(!a)return i;if(a.parent)return a.parent.posBeforeChild(a)})),!n.type.spec.raw){if(o.nodeType!=1){let l=document.createElement("span");l.appendChild(o),o=l}o.contentEditable="false",o.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=n,this.widget=n,a=this}matchesWidget(e){return this.dirty==al&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let n=this.widget.spec.stopEvent;return n?n(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class pHe extends bv{constructor(e,n,r,i){super(e,[],n,null),this.textDOM=r,this.text=i}get size(){return this.text.length}localPosFromDOM(e,n){return e!=this.textDOM?this.posAtStart+(n?this.size:0):this.posAtStart+n}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class Mm extends bv{constructor(e,n,r,i,a){super(e,[],r,i),this.mark=n,this.spec=a}static create(e,n,r,i){let a=i.nodeViews[n.type.name],o=a&&a(n,i,r);return(!o||!o.dom)&&(o=Pm.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new Mm(e,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&_c||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=_c&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=al){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=al}}slice(e,n,r){let i=Mm.create(this.parent,this.mark,!0,r),a=this.children,o=this.size;n<o&&(a=ID(a,n,o,r)),e>0&&(a=ID(a,0,e,r));for(let l=0;l<a.length;l++)a[l].parent=i;return i.children=a,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class mh extends bv{constructor(e,n,r,i,a,o,l,c,u){super(e,[],a,o),this.node=n,this.outerDeco=r,this.innerDeco=i,this.nodeDOM=l}static create(e,n,r,i,a,o){let l=a.nodeViews[n.type.name],c,u=l&&l(n,a,()=>{if(!c)return o;if(c.parent)return c.parent.posBeforeChild(c)},r,i),d=u&&u.dom,f=u&&u.contentDOM;if(n.isText){if(!d)d=document.createTextNode(n.text);else if(d.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else d||({dom:d,contentDOM:f}=Pm.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!f&&!n.isText&&d.nodeName!="BR"&&(d.hasAttribute("contenteditable")||(d.contentEditable="false"),n.type.spec.draggable&&(d.draggable=!0));let p=d;return d=Ete(d,r,n),u?c=new gHe(e,n,r,i,d,f||null,p,u,a,o+1):n.isText?new T2(e,n,r,i,d,p,a):new mh(e,n,r,i,d,f||null,p,a,o+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let n=this.children.length-1;n>=0;n--){let r=this.children[n];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>kt.empty)}return e}matchesNode(e,n,r){return this.dirty==al&&e.eq(this.node)&&hM(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let r=this.node.inlineContent,i=n,a=e.composing?this.localCompositionInfo(e,n):null,o=a&&a.pos>-1?a:null,l=a&&a.pos<0,c=new bHe(this,o&&o.node,e);wHe(this.node,this.innerDeco,(u,d,f)=>{u.spec.marks?c.syncToMarks(u.spec.marks,r,e):u.type.side>=0&&!f&&c.syncToMarks(d==this.node.childCount?Rr.none:this.node.child(d).marks,r,e),c.placeWidget(u,e,i)},(u,d,f,p)=>{c.syncToMarks(u.marks,r,e);let m;c.findNodeMatch(u,d,f,p)||l&&e.state.selection.from>i&&e.state.selection.to<i+u.nodeSize&&(m=c.findIndexWithChild(a.node))>-1&&c.updateNodeAt(u,d,f,m,e)||c.updateNextNode(u,d,f,e,p,i)||c.addNode(u,d,f,e,i),i+=u.nodeSize}),c.syncToMarks([],r,e),this.node.isTextblock&&c.addTextblockHacks(),c.destroyRest(),(c.changed||this.dirty==Lf)&&(o&&this.protectLocalComposition(e,o),Nte(this.contentDOM,this.children,e),ux&&_He(this.dom))}localCompositionInfo(e,n){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof mn)||r<n||i>n+this.node.content.size)return null;let a=e.input.compositionNode;if(!a||!this.dom.contains(a.parentNode))return null;if(this.node.inlineContent){let o=a.nodeValue,l=SHe(this.node.content,o,r-n,i-n);return l<0?null:{node:a,pos:l,text:o}}else return{node:a,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:i}){if(this.getDesc(n))return;let a=n;for(;a.parentNode!=this.contentDOM;a=a.parentNode){for(;a.previousSibling;)a.parentNode.removeChild(a.previousSibling);for(;a.nextSibling;)a.parentNode.removeChild(a.nextSibling);a.pmViewDesc&&(a.pmViewDesc=void 0)}let o=new pHe(this,a,n,i);e.input.compositionNodes.push(o),this.children=ID(this.children,r,r+i.length,e,o)}update(e,n,r,i){return this.dirty==_c||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,r,i),!0)}updateInner(e,n,r,i){this.updateOuterDeco(n),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=al}updateOuterDeco(e){if(hM(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=kte(this.dom,this.nodeDOM,FD(this.outerDeco,this.node,n),FD(e,this.node,n)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function i9(t,e,n,r,i){Ete(r,e,t);let a=new mh(void 0,t,e,n,r,r,r,i,0);return a.contentDOM&&a.updateChildren(i,0),a}class T2 extends mh{constructor(e,n,r,i,a,o,l){super(e,n,r,i,a,null,o,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,n,r,i){return this.dirty==_c||this.dirty!=al&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=al||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=al,!0)}inParent(){let e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,r){let i=this.node.cut(e,n),a=document.createTextNode(i.text);return new T2(this.parent,i,this.outerDeco,this.innerDeco,a,a,r)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=_c)}get domAtom(){return!1}isText(e){return this.node.text==e}}class Mte extends bv{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==al&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class gHe extends mh{constructor(e,n,r,i,a,o,l,c,u,d){super(e,n,r,i,a,o,l,u,d),this.spec=c}update(e,n,r,i){if(this.dirty==_c)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let a=this.spec.update(e,n,r);return a&&this.updateInner(e,n,r,i),a}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,i){this.spec.setSelection?this.spec.setSelection(e,n,r.root):super.setSelection(e,n,r,i)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function Nte(t,e,n){let r=t.firstChild,i=!1;for(let a=0;a<e.length;a++){let o=e[a],l=o.dom;if(l.parentNode==t){for(;l!=r;)r=a9(r),i=!0;r=r.nextSibling}else i=!0,t.insertBefore(l,r);if(o instanceof Mm){let c=r?r.previousSibling:t.lastChild;Nte(o.contentDOM,o.children,n),r=c?c.nextSibling:t.firstChild}}for(;r;)r=a9(r),i=!0;i&&n.trackWrites==t&&(n.trackWrites=null)}const A0=function(t){t&&(this.nodeName=t)};A0.prototype=Object.create(null);const Ff=[new A0];function FD(t,e,n){if(t.length==0)return Ff;let r=n?Ff[0]:new A0,i=[r];for(let a=0;a<t.length;a++){let o=t[a].type.attrs;if(o){o.nodeName&&i.push(r=new A0(o.nodeName));for(let l in o){let c=o[l];c!=null&&(n&&i.length==1&&i.push(r=new A0(e.isInline?"span":"div")),l=="class"?r.class=(r.class?r.class+" ":"")+c:l=="style"?r.style=(r.style?r.style+";":"")+c:l!="nodeName"&&(r[l]=c))}}}return i}function kte(t,e,n,r){if(n==Ff&&r==Ff)return e;let i=e;for(let a=0;a<r.length;a++){let o=r[a],l=n[a];if(a){let c;l&&l.nodeName==o.nodeName&&i!=t&&(c=i.parentNode)&&c.nodeName.toLowerCase()==o.nodeName||(c=document.createElement(o.nodeName),c.pmIsDeco=!0,c.appendChild(i),l=Ff[0]),i=c}xHe(i,l||Ff[0],o)}return i}function xHe(t,e,n){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in n)&&t.removeAttribute(r);for(let r in n)r!="class"&&r!="style"&&r!="nodeName"&&n[r]!=e[r]&&t.setAttribute(r,n[r]);if(e.class!=n.class){let r=e.class?e.class.split(" ").filter(Boolean):[],i=n.class?n.class.split(" ").filter(Boolean):[];for(let a=0;a<r.length;a++)i.indexOf(r[a])==-1&&t.classList.remove(r[a]);for(let a=0;a<i.length;a++)r.indexOf(i[a])==-1&&t.classList.add(i[a]);t.classList.length==0&&t.removeAttribute("class")}if(e.style!=n.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,i;for(;i=r.exec(e.style);)t.style.removeProperty(i[1])}n.style&&(t.style.cssText+=n.style)}}function Ete(t,e,n){return kte(t,t,Ff,FD(e,n,t.nodeType!=1))}function hM(t,e){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!t[n].type.eq(e[n].type))return!1;return!0}function a9(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class bHe{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=yHe(e.node.content,e)}destroyBetween(e,n){if(e!=n){for(let r=e;r<n;r++)this.top.children[r].destroy();this.top.children.splice(e,n-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,n,r){let i=0,a=this.stack.length>>1,o=Math.min(a,e.length);for(;i<o&&(i==a-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<a;)this.destroyRest(),this.top.dirty=al,this.index=this.stack.pop(),this.top=this.stack.pop(),a--;for(;a<e.length;){this.stack.push(this.top,this.index+1);let l=-1;for(let c=this.index;c<Math.min(this.index+3,this.top.children.length);c++){let u=this.top.children[c];if(u.matchesMark(e[a])&&!this.isLocked(u.dom)){l=c;break}}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let c=Mm.create(this.top,e[a],n,r);this.top.children.splice(this.index,0,c),this.top=c,this.changed=!0}this.index=0,a++}}findNodeMatch(e,n,r,i){let a=-1,o;if(i>=this.preMatch.index&&(o=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&o.matchesNode(e,n,r))a=this.top.children.indexOf(o,this.index);else for(let l=this.index,c=Math.min(this.top.children.length,l+5);l<c;l++){let u=this.top.children[l];if(u.matchesNode(e,n,r)&&!this.preMatch.matched.has(u)){a=l;break}}return a<0?!1:(this.destroyBetween(this.index,a),this.index++,!0)}updateNodeAt(e,n,r,i,a){let o=this.top.children[i];return o.dirty==_c&&o.dom==o.contentDOM&&(o.dirty=Lf),o.update(e,n,r,a)?(this.destroyBetween(this.index,i),this.index++,!0):!1}findIndexWithChild(e){for(;;){let n=e.parentNode;if(!n)return-1;if(n==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let i=this.index;i<this.top.children.length;i++)if(this.top.children[i]==r)return i}return-1}e=n}}updateNextNode(e,n,r,i,a,o){for(let l=this.index;l<this.top.children.length;l++){let c=this.top.children[l];if(c instanceof mh){let u=this.preMatch.matched.get(c);if(u!=null&&u!=a)return!1;let d=c.dom,f,p=this.isLocked(d)&&!(e.isText&&c.node&&c.node.isText&&c.nodeDOM.nodeValue==e.text&&c.dirty!=_c&&hM(n,c.outerDeco));if(!p&&c.update(e,n,r,i))return this.destroyBetween(this.index,l),c.dom!=d&&(this.changed=!0),this.index++,!0;if(!p&&(f=this.recreateWrapper(c,e,n,r,i,o)))return this.destroyBetween(this.index,l),this.top.children[this.index]=f,f.contentDOM&&(f.dirty=Lf,f.updateChildren(i,o+1),f.dirty=al),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,n,r,i,a,o){if(e.dirty||n.isAtom||!e.children.length||!e.node.content.eq(n.content)||!hM(r,e.outerDeco)||!i.eq(e.innerDeco))return null;let l=mh.create(this.top,n,r,i,a,o);if(l.contentDOM){l.children=e.children,e.children=[];for(let c of l.children)c.parent=l}return e.destroy(),l}addNode(e,n,r,i,a){let o=mh.create(this.top,e,n,r,i,a);o.contentDOM&&o.updateChildren(i,a+1),this.top.children.splice(this.index++,0,o),this.changed=!0}placeWidget(e,n,r){let i=this.index<this.top.children.length?this.top.children[this.index]:null;if(i&&i.matchesWidget(e)&&(e==i.widget||!i.widget.type.toDOM.parentNode))this.index++;else{let a=new Ste(this.top,e,n,r);this.top.children.splice(this.index++,0,a),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],n=this.top;for(;e instanceof Mm;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof T2)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((ys||Za)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",n),this.addHackNode("BR",this.top))}addHackNode(e,n){if(n==this.top&&this.index<n.children.length&&n.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let i=new Mte(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 yHe(t,e){let n=e,r=n.children.length,i=t.childCount,a=new Map,o=[];e:for(;i>0;){let l;for(;;)if(r){let u=n.children[r-1];if(u instanceof Mm)n=u,r=u.children.length;else{l=u,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let c=l.node;if(c){if(c!=t.child(i-1))break;--i,a.set(l,i),o.push(l)}}return{index:i,matched:a,matches:o.reverse()}}function vHe(t,e){return t.type.side-e.type.side}function wHe(t,e,n,r){let i=e.locals(t),a=0;if(i.length==0){for(let u=0;u<t.childCount;u++){let d=t.child(u);r(d,i,e.forChild(a,d),u),a+=d.nodeSize}return}let o=0,l=[],c=null;for(let u=0;;){let d,f;for(;o<i.length&&i[o].to==a;){let y=i[o++];y.widget&&(d?(f||(f=[d])).push(y):d=y)}if(d)if(f){f.sort(vHe);for(let y=0;y<f.length;y++)n(f[y],u,!!c)}else n(d,u,!!c);let p,m;if(c)m=-1,p=c,c=null;else if(u<t.childCount)m=u,p=t.child(u++);else break;for(let y=0;y<l.length;y++)l[y].to<=a&&l.splice(y--,1);for(;o<i.length&&i[o].from<=a&&i[o].to>a;)l.push(i[o++]);let x=a+p.nodeSize;if(p.isText){let y=x;o<i.length&&i[o].from<y&&(y=i[o].from);for(let v=0;v<l.length;v++)l[v].to<y&&(y=l[v].to);y<x&&(c=p.cut(y-a),p=p.cut(0,y-a),x=y,m=-1)}else for(;o<i.length&&i[o].to<x;)o++;let b=p.isInline&&!p.isLeaf?l.filter(y=>!y.inline):l.slice();r(p,b,e.forChild(a,p),m),a=x}}function _He(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 SHe(t,e,n,r){for(let i=0,a=0;i<t.childCount&&a<=r;){let o=t.child(i++),l=a;if(a+=o.nodeSize,!o.isText)continue;let c=o.text;for(;i<t.childCount;){let u=t.child(i++);if(a+=u.nodeSize,!u.isText)break;c+=u.text}if(a>=n){if(a>=r&&c.slice(r-e.length-l,r-l)==e)return r-e.length;let u=l<r?c.lastIndexOf(e,r-l-1):-1;if(u>=0&&u+e.length+l>=n)return l+u;if(n==r&&c.length>=r+e.length-l&&c.slice(r-l,r-l+e.length)==e)return r}}return-1}function ID(t,e,n,r,i){let a=[];for(let o=0,l=0;o<t.length;o++){let c=t[o],u=l,d=l+=c.size;u>=n||d<=e?a.push(c):(u<e&&a.push(c.slice(0,e-u,r)),i&&(a.push(i),i=void 0),d>n&&a.push(c.slice(n-u,c.size,r)))}return a}function NL(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let i=t.docView.nearestDesc(n.focusNode),a=i&&i.size==0,o=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let l=r.resolve(o),c,u;if(E2(n)){for(c=o;i&&!i.node;)i=i.parent;let f=i.node;if(i&&f.isAtom&&Qt.isSelectable(f)&&i.parent&&!(f.isInline&&X6e(n.focusNode,n.focusOffset,i.dom))){let p=i.posBefore;u=new Qt(o==p?l:r.resolve(p))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let f=o,p=o;for(let m=0;m<n.rangeCount;m++){let x=n.getRangeAt(m);f=Math.min(f,t.docView.posFromDOM(x.startContainer,x.startOffset,1)),p=Math.max(p,t.docView.posFromDOM(x.endContainer,x.endOffset,-1))}if(f<0)return null;[c,o]=p==t.state.selection.anchor?[p,f]:[f,p],l=r.resolve(o)}else c=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(c<0)return null}let d=r.resolve(c);if(!u){let f=e=="pointer"||t.state.selection.head<l.pos&&!a?1:-1;u=kL(t,d,l,f)}return u}function Tte(t){return t.editable?t.hasFocus():Cte(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function Pu(t,e=!1){let n=t.state.selection;if(Ate(t,n),!!Tte(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&Za){let r=t.domSelectionRange(),i=t.domObserver.currentSelection;if(r.anchorNode&&i.anchorNode&&Sm(r.anchorNode,r.anchorOffset,i.anchorNode,i.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)NHe(t);else{let{anchor:r,head:i}=n,a,o;s9&&!(n instanceof mn)&&(n.$from.parent.inlineContent||(a=o9(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(o=o9(t,n.to))),t.docView.setSelection(r,i,t,e),s9&&(a&&l9(a),o&&l9(o)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&MHe(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const s9=ys||Za&>e<63;function o9(t,e){let{node:n,offset:r}=t.docView.domFromPos(e,0),i=r<n.childNodes.length?n.childNodes[r]:null,a=r?n.childNodes[r-1]:null;if(ys&&i&&i.contentEditable=="false")return yj(i);if((!i||i.contentEditable=="false")&&(!a||a.contentEditable=="false")){if(i)return yj(i);if(a)return yj(a)}}function yj(t){return t.contentEditable="true",ys&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function l9(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function MHe(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let n=t.domSelectionRange(),r=n.anchorNode,i=n.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=i)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!Tte(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function NHe(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,La(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&Hs&&fh<=11&&(n.disabled=!0,n.disabled=!1)}function Ate(t,e){if(e instanceof Qt){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(c9(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else c9(t)}function c9(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function kL(t,e,n,r){return t.someProp("createSelectionBetween",i=>i(t,e,n))||mn.between(e,n,r)}function u9(t){return t.editable&&!t.hasFocus()?!1:Cte(t)}function Cte(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return t.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function kHe(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return Sm(e.node,e.offset,n.anchorNode,n.anchorOffset)}function UD(t,e){let{$anchor:n,$head:r}=t.selection,i=e>0?n.max(r):n.min(r),a=i.parent.inlineContent?i.depth?t.doc.resolve(e>0?i.after():i.before()):null:i;return a&&An.findFrom(a,e)}function $d(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function d9(t,e,n){let r=t.state.selection;if(r instanceof mn)if(n.indexOf("s")>-1){let{$head:i}=r,a=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!a||a.isText||!a.isLeaf)return!1;let o=t.state.doc.resolve(i.pos+a.nodeSize*(e<0?-1:1));return $d(t,new mn(r.$anchor,o))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let i=UD(t.state,e);return i&&i instanceof Qt?$d(t,i):!1}else if(!(Go&&n.indexOf("m")>-1)){let i=r.$head,a=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,o;if(!a||a.isText)return!1;let l=e<0?i.pos-a.nodeSize:i.pos;return a.isAtom||(o=t.docView.descAt(l))&&!o.contentDOM?Qt.isSelectable(a)?$d(t,new Qt(e<0?t.state.doc.resolve(i.pos-a.nodeSize):i)):xv?$d(t,new mn(t.state.doc.resolve(e<0?l:l+a.nodeSize))):!1:!1}}else return!1;else{if(r instanceof Qt&&r.node.isInline)return $d(t,new mn(e>0?r.$to:r.$from));{let i=UD(t.state,e);return i?$d(t,i):!1}}}function fM(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function C0(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function tg(t,e){return e<0?EHe(t):THe(t)}function EHe(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i,a,o=!1;for(il&&n.nodeType==1&&r<fM(n)&&C0(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(n.nodeType!=1)break;{let l=n.childNodes[r-1];if(C0(l,-1))i=n,a=--r;else if(l.nodeType==3)n=l,r=n.nodeValue.length;else break}}else{if(jte(n))break;{let l=n.previousSibling;for(;l&&C0(l,-1);)i=n.parentNode,a=La(l),l=l.previousSibling;if(l)n=l,r=fM(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}o?zD(t,n,r):i&&zD(t,i,a)}function THe(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i=fM(n),a,o;for(;;)if(r<i){if(n.nodeType!=1)break;let l=n.childNodes[r];if(C0(l,1))a=n,o=++r;else break}else{if(jte(n))break;{let l=n.nextSibling;for(;l&&C0(l,1);)a=l.parentNode,o=La(l)+1,l=l.nextSibling;if(l)n=l,r=0,i=fM(n);else{if(n=n.parentNode,n==t.dom)break;r=i=0}}}a&&zD(t,a,o)}function jte(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function AHe(t,e){for(;t&&e==t.childNodes.length&&!gv(t);)e=La(t)+1,t=t.parentNode;for(;t&&e<t.childNodes.length;){let n=t.childNodes[e];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=0}}function CHe(t,e){for(;t&&!e&&!gv(t);)e=La(t),t=t.parentNode;for(;t&&e;){let n=t.childNodes[e-1];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=t.childNodes.length}}function zD(t,e,n){if(e.nodeType!=3){let a,o;(o=AHe(e,n))?(e=o,n=0):(a=CHe(e,n))&&(e=a,n=a.nodeValue.length)}let r=t.domSelection();if(!r)return;if(E2(r)){let a=document.createRange();a.setEnd(e,n),a.setStart(e,n),r.removeAllRanges(),r.addRange(a)}else r.extend&&r.extend(e,n);t.domObserver.setCurSelection();let{state:i}=t;setTimeout(()=>{t.state==i&&Pu(t)},50)}function h9(t,e){let n=t.state.doc.resolve(e);if(!(Za||Z6e)&&n.parent.inlineContent){let i=t.coordsAtPos(e);if(e>n.start()){let a=t.coordsAtPos(e-1),o=(a.top+a.bottom)/2;if(o>i.top&&o<i.bottom&&Math.abs(a.left-i.left)>1)return a.left<i.left?"ltr":"rtl"}if(e<n.end()){let a=t.coordsAtPos(e+1),o=(a.top+a.bottom)/2;if(o>i.top&&o<i.bottom&&Math.abs(a.left-i.left)>1)return a.left>i.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function f9(t,e,n){let r=t.state.selection;if(r instanceof mn&&!r.empty||n.indexOf("s")>-1||Go&&n.indexOf("m")>-1)return!1;let{$from:i,$to:a}=r;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let o=UD(t.state,e);if(o&&o instanceof Qt)return $d(t,o)}if(!i.parent.inlineContent){let o=e<0?i:a,l=r instanceof xo?An.near(o,e):An.findFrom(o,e);return l?$d(t,l):!1}return!1}function m9(t,e){if(!(t.state.selection instanceof mn))return!0;let{$head:n,$anchor:r,empty:i}=t.state.selection;if(!n.sameParent(r))return!0;if(!i)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let a=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(a&&!a.isText){let o=t.state.tr;return e<0?o.delete(n.pos-a.nodeSize,n.pos):o.delete(n.pos,n.pos+a.nodeSize),t.dispatch(o),!0}return!1}function p9(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function jHe(t){if(!ys||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&e.nodeType==1&&n==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;p9(t,r,"true"),setTimeout(()=>p9(t,r,"false"),20)}return!1}function PHe(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function DHe(t,e){let n=e.keyCode,r=PHe(e);if(n==8||Go&&n==72&&r=="c")return m9(t,-1)||tg(t,-1);if(n==46&&!e.shiftKey||Go&&n==68&&r=="c")return m9(t,1)||tg(t,1);if(n==13||n==27)return!0;if(n==37||Go&&n==66&&r=="c"){let i=n==37?h9(t,t.state.selection.from)=="ltr"?-1:1:-1;return d9(t,i,r)||tg(t,i)}else if(n==39||Go&&n==70&&r=="c"){let i=n==39?h9(t,t.state.selection.from)=="ltr"?1:-1:1;return d9(t,i,r)||tg(t,i)}else{if(n==38||Go&&n==80&&r=="c")return f9(t,-1,r)||tg(t,-1);if(n==40||Go&&n==78&&r=="c")return jHe(t)||f9(t,1,r)||tg(t,1);if(r==(Go?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function EL(t,e){t.someProp("transformCopied",m=>{e=m(e,t)});let n=[],{content:r,openStart:i,openEnd:a}=e;for(;i>1&&a>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,a--;let m=r.firstChild;n.push(m.type.name,m.attrs!=m.type.defaultAttrs?m.attrs:null),r=m.content}let o=t.someProp("clipboardSerializer")||Pm.fromSchema(t.state.schema),l=Fte(),c=l.createElement("div");c.appendChild(o.serializeFragment(r,{document:l}));let u=c.firstChild,d,f=0;for(;u&&u.nodeType==1&&(d=Lte[u.nodeName.toLowerCase()]);){for(let m=d.length-1;m>=0;m--){let x=l.createElement(d[m]);for(;c.firstChild;)x.appendChild(c.firstChild);c.appendChild(x),f++}u=c.firstChild}u&&u.nodeType==1&&u.setAttribute("data-pm-slice",`${i} ${a}${f?` -${f}`:""} ${JSON.stringify(n)}`);let p=t.someProp("clipboardTextSerializer",m=>m(e,t))||e.content.textBetween(0,e.content.size,`
- `);return{dom:c,text:p,slice:e}}function Pte(t,e,n,r,i){let a=i.parent.type.spec.code,o,l;if(!n&&!e)return null;let c=!!e&&(r||a||!n);if(c){if(t.someProp("transformPastedText",p=>{e=p(e,a||r,t)}),a)return l=new Ut(kt.from(t.state.schema.text(e.replace(/\r\n?/g,`
- `))),0,0),t.someProp("transformPasted",p=>{l=p(l,t,!0)}),l;let f=t.someProp("clipboardTextParser",p=>p(e,i,r,t));if(f)l=f;else{let p=i.marks(),{schema:m}=t.state,x=Pm.fromSchema(m);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(b=>{let y=o.appendChild(document.createElement("p"));b&&y.appendChild(x.serializeNode(m.text(b,p)))})}}else t.someProp("transformPastedHTML",f=>{n=f(n,t)}),o=FHe(n),xv&&IHe(o);let u=o&&o.querySelector("[data-pm-slice]"),d=u&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(u.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let f=+d[3];f>0;f--){let p=o.firstChild;for(;p&&p.nodeType!=1;)p=p.nextSibling;if(!p)break;o=p}if(l||(l=(t.someProp("clipboardParser")||t.someProp("domParser")||E0.fromSchema(t.state.schema)).parseSlice(o,{preserveWhitespace:!!(c||d),context:i,ruleFromNode(p){return p.nodeName=="BR"&&!p.nextSibling&&p.parentNode&&!RHe.test(p.parentNode.nodeName)?{ignore:!0}:null}})),d)l=UHe(g9(l,+d[1],+d[2]),d[4]);else if(l=Ut.maxOpen(OHe(l.content,i),!0),l.openStart||l.openEnd){let f=0,p=0;for(let m=l.content.firstChild;f<l.openStart&&!m.type.spec.isolating;f++,m=m.firstChild);for(let m=l.content.lastChild;p<l.openEnd&&!m.type.spec.isolating;p++,m=m.lastChild);l=g9(l,f,p)}return t.someProp("transformPasted",f=>{l=f(l,t,c)}),l}const RHe=/^(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 OHe(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let i=e.node(n).contentMatchAt(e.index(n)),a,o=[];if(t.forEach(l=>{if(!o)return;let c=i.findWrapping(l.type),u;if(!c)return o=null;if(u=o.length&&a.length&&Rte(c,a,l,o[o.length-1],0))o[o.length-1]=u;else{o.length&&(o[o.length-1]=Ote(o[o.length-1],a.length));let d=Dte(l,c);o.push(d),i=i.matchType(d.type),a=c}}),o)return kt.from(o)}return t}function Dte(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,kt.from(t));return t}function Rte(t,e,n,r,i){if(i<t.length&&i<e.length&&t[i]==e[i]){let a=Rte(t,e,n,r.lastChild,i+1);if(a)return r.copy(r.content.replaceChild(r.childCount-1,a));if(r.contentMatchAt(r.childCount).matchType(i==t.length-1?n.type:t[i+1]))return r.copy(r.content.append(kt.from(Dte(n,t,i+1))))}}function Ote(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,Ote(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(kt.empty,!0);return t.copy(n.append(r))}function BD(t,e,n,r,i,a){let o=e<0?t.firstChild:t.lastChild,l=o.content;return t.childCount>1&&(a=0),i<r-1&&(l=BD(l,e,n,r,i+1,a)),i>=n&&(l=e<0?o.contentMatchAt(0).fillBefore(l,a<=i).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(kt.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,o.copy(l))}function g9(t,e,n){return e<t.openStart&&(t=new Ut(BD(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new Ut(BD(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const Lte={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let x9=null;function Fte(){return x9||(x9=document.implementation.createHTMLDocument("title"))}let vj=null;function LHe(t){let e=window.trustedTypes;return e?(vj||(vj=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),vj.createHTML(t)):t}function FHe(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=Fte().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),i;if((i=r&&Lte[r[1].toLowerCase()])&&(t=i.map(a=>"<"+a+">").join("")+t+i.map(a=>"</"+a+">").reverse().join("")),n.innerHTML=LHe(t),i)for(let a=0;a<i.length;a++)n=n.querySelector(i[a])||n;return n}function IHe(t){let e=t.querySelectorAll(Za?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<e.length;n++){let r=e[n];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),r)}}function UHe(t,e){if(!t.size)return t;let n=t.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return t}let{content:i,openStart:a,openEnd:o}=t;for(let l=r.length-2;l>=0;l-=2){let c=n.nodes[r[l]];if(!c||c.hasRequiredAttrs())break;i=kt.from(c.create(r[l+1],i)),a++,o++}return new Ut(i,a,o)}const vs={},ws={},zHe={touchstart:!0,touchmove:!0};class BHe{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function HHe(t){for(let e in vs){let n=vs[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{VHe(t,r)&&!TL(t,r)&&(t.editable||!(r.type in ws))&&n(t,r)},zHe[e]?{passive:!0}:void 0)}ys&&t.dom.addEventListener("input",()=>null),HD(t)}function nh(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function $He(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 HD(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>TL(t,r))})}function TL(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function VHe(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 GHe(t,e){!TL(t,e)&&vs[e.type]&&(t.editable||!(e.type in ws))&&vs[e.type](t,e)}ws.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!Ute(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(Su&&Za&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),ux&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();t.input.lastIOSEnter=r,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==r&&(t.someProp("handleKeyDown",i=>i(t,Af(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||DHe(t,n)?n.preventDefault():nh(t,"key")};ws.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};ws.keypress=(t,e)=>{let n=e;if(Ute(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||Go&&n.metaKey)return;if(t.someProp("handleKeyPress",i=>i(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof mn)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(n.charCode),a=()=>t.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!t.someProp("handleTextInput",o=>o(t,r.$from.pos,r.$to.pos,i,a))&&t.dispatch(a()),n.preventDefault()}};function A2(t){return{left:t.clientX,top:t.clientY}}function qHe(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function AL(t,e,n,r,i){if(r==-1)return!1;let a=t.state.doc.resolve(r);for(let o=a.depth+1;o>0;o--)if(t.someProp(e,l=>o>a.depth?l(t,n,a.nodeAfter,a.before(o),i,!0):l(t,n,a.node(o),a.before(o),i,!1)))return!0;return!1}function Og(t,e,n){if(t.focused||t.focus(),t.state.selection.eq(e))return;let r=t.state.tr.setSelection(e);r.setMeta("pointer",!0),t.dispatch(r)}function WHe(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&Qt.isSelectable(r)?(Og(t,new Qt(n)),!0):!1}function KHe(t,e){if(e==-1)return!1;let n=t.state.selection,r,i;n instanceof Qt&&(r=n.node);let a=t.state.doc.resolve(e);for(let o=a.depth+1;o>0;o--){let l=o>a.depth?a.nodeAfter:a.node(o);if(Qt.isSelectable(l)){r&&n.$from.depth>0&&o>=n.$from.depth&&a.before(n.$from.depth+1)==n.$from.pos?i=a.before(n.$from.depth):i=a.before(o);break}}return i!=null?(Og(t,Qt.create(t.state.doc,i)),!0):!1}function XHe(t,e,n,r,i){return AL(t,"handleClickOn",e,n,r)||t.someProp("handleClick",a=>a(t,e,r))||(i?KHe(t,n):WHe(t,n))}function YHe(t,e,n,r){return AL(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",i=>i(t,e,r))}function QHe(t,e,n,r){return AL(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",i=>i(t,e,r))||ZHe(t,n,r)}function ZHe(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(Og(t,mn.create(r,0,r.content.size)),!0):!1;let i=r.resolve(e);for(let a=i.depth+1;a>0;a--){let o=a>i.depth?i.nodeAfter:i.node(a),l=i.before(a);if(o.inlineContent)Og(t,mn.create(r,l+1,l+1+o.content.size));else if(Qt.isSelectable(o))Og(t,Qt.create(r,l));else continue;return!0}}function CL(t){return mM(t)}const Ite=Go?"metaKey":"ctrlKey";vs.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=CL(t),i=Date.now(),a="singleClick";i-t.input.lastClick.time<500&&qHe(n,t.input.lastClick)&&!n[Ite]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?a="doubleClick":t.input.lastClick.type=="doubleClick"&&(a="tripleClick")),t.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:a,button:n.button};let o=t.posAtCoords(A2(n));o&&(a=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new JHe(t,o,n,!!r)):(a=="doubleClick"?YHe:QHe)(t,o.pos,o.inside,n)?n.preventDefault():nh(t,"pointer"))};class JHe{constructor(e,n,r,i){this.view=e,this.pos=n,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[Ite],this.allowDefault=r.shiftKey;let a,o;if(n.inside>-1)a=e.state.doc.nodeAt(n.inside),o=n.inside;else{let d=e.state.doc.resolve(n.pos);a=d.parent,o=d.depth?d.before():0}const l=i?null:r.target,c=l?e.docView.nearestDesc(l,!0):null;this.target=c&&c.nodeDOM.nodeType==1?c.nodeDOM:null;let{selection:u}=e.state;(r.button==0&&a.type.spec.draggable&&a.type.spec.selectable!==!1||u instanceof Qt&&u.from<=o&&u.to>o)&&(this.mightDrag={node:a,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&il&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),nh(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>Pu(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(A2(e))),this.updateAllowDefault(e),this.allowDefault||!n?nh(this.view,"pointer"):XHe(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||ys&&this.mightDrag&&!this.mightDrag.node.isAtom||Za&&!this.view.state.selection.visible&&Math.min(Math.abs(n.pos-this.view.state.selection.from),Math.abs(n.pos-this.view.state.selection.to))<=2)?(Og(this.view,An.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):nh(this.view,"pointer")}move(e){this.updateAllowDefault(e),nh(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}vs.touchstart=t=>{t.input.lastTouch=Date.now(),CL(t),nh(t,"pointer")};vs.touchmove=t=>{t.input.lastTouch=Date.now(),nh(t,"pointer")};vs.contextmenu=t=>CL(t);function Ute(t,e){return t.composing?!0:ys&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const e$e=Su?5e3:-1;ws.compositionstart=ws.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof mn&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))t.markCursor=t.state.storedMarks||n.marks(),mM(t,!0),t.markCursor=null;else if(mM(t,!e.selection.empty),il&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let i=r.focusNode,a=r.focusOffset;i&&i.nodeType==1&&a!=0;){let o=a<0?i.lastChild:i.childNodes[a-1];if(!o)break;if(o.nodeType==3){let l=t.domSelection();l&&l.collapse(o,o.nodeValue.length);break}else i=o,a=-1}}t.input.composing=!0}zte(t,e$e)};ws.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=e.timeStamp,t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,zte(t,20))};function zte(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>mM(t),e))}function Bte(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=n$e());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function t$e(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=W6e(e.focusNode,e.focusOffset),r=K6e(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let i=r.pmViewDesc,a=t.domObserver.lastChangedTextNode;if(n==a||r==a)return a;if(!i||!i.isText(r.nodeValue))return r;if(t.input.compositionNode==r){let o=n.pmViewDesc;if(!(!o||!o.isText(n.nodeValue)))return r}}return n||r}function n$e(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function mM(t,e=!1){if(!(Su&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),Bte(t),e||t.docView&&t.docView.dirty){let n=NL(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 r$e(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),i=document.createRange();i.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}const Ny=Hs&&fh<15||ux&&J6e<604;vs.copy=ws.cut=(t,e)=>{let n=e,r=t.state.selection,i=n.type=="cut";if(r.empty)return;let a=Ny?null:n.clipboardData,o=r.content(),{dom:l,text:c}=EL(t,o);a?(n.preventDefault(),a.clearData(),a.setData("text/html",l.innerHTML),a.setData("text/plain",c)):r$e(t,l),i&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function i$e(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function a$e(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let i=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?ky(t,r.value,null,i,e):ky(t,r.textContent,r.innerHTML,i,e)},50)}function ky(t,e,n,r,i){let a=Pte(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",c=>c(t,i,a||Ut.empty)))return!0;if(!a)return!1;let o=i$e(a),l=o?t.state.tr.replaceSelectionWith(o,r):t.state.tr.replaceSelection(a);return t.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Hte(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let n=t.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}ws.paste=(t,e)=>{let n=e;if(t.composing&&!Su)return;let r=Ny?null:n.clipboardData,i=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&ky(t,Hte(r),r.getData("text/html"),i,n)?n.preventDefault():a$e(t,n)};class $te{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const s$e=Go?"altKey":"ctrlKey";function Vte(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[s$e]}vs.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=t.state.selection,a=i.empty?null:t.posAtCoords(A2(n)),o;if(!(a&&a.pos>=i.from&&a.pos<=(i instanceof Qt?i.to-1:i.to))){if(r&&r.mightDrag)o=Qt.create(t.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let f=t.docView.nearestDesc(n.target,!0);f&&f.node.type.spec.draggable&&f!=t.docView&&(o=Qt.create(t.state.doc,f.posBefore))}}let l=(o||t.state.selection).content(),{dom:c,text:u,slice:d}=EL(t,l);(!n.dataTransfer.files.length||!Za||gte>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Ny?"Text":"text/html",c.innerHTML),n.dataTransfer.effectAllowed="copyMove",Ny||n.dataTransfer.setData("text/plain",u),t.dragging=new $te(d,Vte(t,n),o)};vs.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};ws.dragover=ws.dragenter=(t,e)=>e.preventDefault();ws.drop=(t,e)=>{let n=e,r=t.dragging;if(t.dragging=null,!n.dataTransfer)return;let i=t.posAtCoords(A2(n));if(!i)return;let a=t.state.doc.resolve(i.pos),o=r&&r.slice;o?t.someProp("transformPasted",x=>{o=x(o,t,!1)}):o=Pte(t,Hte(n.dataTransfer),Ny?null:n.dataTransfer.getData("text/html"),!1,a);let l=!!(r&&Vte(t,n));if(t.someProp("handleDrop",x=>x(t,n,o||Ut.empty,l))){n.preventDefault();return}if(!o)return;n.preventDefault();let c=o?Xee(t.state.doc,a.pos,o):a.pos;c==null&&(c=a.pos);let u=t.state.tr;if(l){let{node:x}=r;x?x.replace(u):u.deleteSelection()}let d=u.mapping.map(c),f=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,p=u.doc;if(f?u.replaceRangeWith(d,d,o.content.firstChild):u.replaceRange(d,d,o),u.doc.eq(p))return;let m=u.doc.resolve(d);if(f&&Qt.isSelectable(o.content.firstChild)&&m.nodeAfter&&m.nodeAfter.sameMarkup(o.content.firstChild))u.setSelection(new Qt(m));else{let x=u.mapping.map(c);u.mapping.maps[u.mapping.maps.length-1].forEach((b,y,v,S)=>x=S),u.setSelection(kL(t,m,u.doc.resolve(x)))}t.focus(),t.dispatch(u.setMeta("uiEvent","drop"))};vs.focus=t=>{t.input.lastFocus=Date.now(),t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout(()=>{t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange())&&Pu(t)},20))};vs.blur=(t,e)=>{let n=e;t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),n.relatedTarget&&t.dom.contains(n.relatedTarget)&&t.domObserver.currentSelection.clear(),t.focused=!1)};vs.beforeinput=(t,e)=>{if(Za&&Su&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",a=>a(t,Af(8,"Backspace")))))return;let{$cursor:i}=t.state.selection;i&&i.pos>0&&t.dispatch(t.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let t in ws)vs[t]=ws[t];function Ey(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 pM{constructor(e,n){this.toDOM=e,this.spec=n||Qf,this.side=this.spec.side||0}map(e,n,r,i){let{pos:a,deleted:o}=e.mapResult(n.from+i,this.side<0?-1:1);return o?null:new ms(a-r,a-r,this)}valid(){return!0}eq(e){return this==e||e instanceof pM&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Ey(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class ph{constructor(e,n){this.attrs=e,this.spec=n||Qf}map(e,n,r,i){let a=e.map(n.from+i,this.spec.inclusiveStart?-1:1)-r,o=e.map(n.to+i,this.spec.inclusiveEnd?1:-1)-r;return a>=o?null:new ms(a,o,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof ph&&Ey(this.attrs,e.attrs)&&Ey(this.spec,e.spec)}static is(e){return e.type instanceof ph}destroy(){}}class jL{constructor(e,n){this.attrs=e,this.spec=n||Qf}map(e,n,r,i){let a=e.mapResult(n.from+i,1);if(a.deleted)return null;let o=e.mapResult(n.to+i,-1);return o.deleted||o.pos<=a.pos?null:new ms(a.pos-r,o.pos-r,this)}valid(e,n){let{index:r,offset:i}=e.content.findIndex(n.from),a;return i==n.from&&!(a=e.child(r)).isText&&i+a.nodeSize==n.to}eq(e){return this==e||e instanceof jL&&Ey(this.attrs,e.attrs)&&Ey(this.spec,e.spec)}destroy(){}}class ms{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new ms(e,n,this.type)}eq(e,n=0){return this.type.eq(e.type)&&this.from+n==e.from&&this.to+n==e.to}map(e,n,r){return this.type.map(e,this,n,r)}static widget(e,n,r){return new ms(e,e,new pM(n,r))}static inline(e,n,r,i){return new ms(e,n,new ph(r,i))}static node(e,n,r,i){return new ms(e,n,new jL(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof ph}get widget(){return this.type instanceof pM}}const cg=[],Qf={};class ai{constructor(e,n){this.local=e.length?e:cg,this.children=n.length?n:cg}static create(e,n){return n.length?gM(n,e,0,Qf):Xa}find(e,n,r){let i=[];return this.findInner(e??0,n??1e9,i,0,r),i}findInner(e,n,r,i,a){for(let o=0;o<this.local.length;o++){let l=this.local[o];l.from<=n&&l.to>=e&&(!a||a(l.spec))&&r.push(l.copy(l.from+i,l.to+i))}for(let o=0;o<this.children.length;o+=3)if(this.children[o]<n&&this.children[o+1]>e){let l=this.children[o]+1;this.children[o+2].findInner(e-l,n-l,r,i+l,a)}}map(e,n,r){return this==Xa||e.maps.length==0?this:this.mapInner(e,n,0,0,r||Qf)}mapInner(e,n,r,i,a){let o;for(let l=0;l<this.local.length;l++){let c=this.local[l].map(e,r,i);c&&c.type.valid(n,c)?(o||(o=[])).push(c):a.onRemove&&a.onRemove(this.local[l].spec)}return this.children.length?o$e(this.children,o||[],e,n,r,i,a):o?new ai(o.sort(Zf),cg):Xa}add(e,n){return n.length?this==Xa?ai.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let i,a=0;e.forEach((l,c)=>{let u=c+r,d;if(d=qte(n,l,u)){for(i||(i=this.children.slice());a<i.length&&i[a]<c;)a+=3;i[a]==c?i[a+2]=i[a+2].addInner(l,d,u+1):i.splice(a,0,c,c+l.nodeSize,gM(d,l,u+1,Qf)),a+=3}});let o=Gte(a?Wte(n):n,-r);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||o.splice(l--,1);return new ai(o.length?this.local.concat(o).sort(Zf):this.local,i||this.children)}remove(e){return e.length==0||this==Xa?this:this.removeInner(e,0)}removeInner(e,n){let r=this.children,i=this.local;for(let a=0;a<r.length;a+=3){let o,l=r[a]+n,c=r[a+1]+n;for(let d=0,f;d<e.length;d++)(f=e[d])&&f.from>l&&f.to<c&&(e[d]=null,(o||(o=[])).push(f));if(!o)continue;r==this.children&&(r=this.children.slice());let u=r[a+2].removeInner(o,l+1);u!=Xa?r[a+2]=u:(r.splice(a,3),a-=3)}if(i.length){for(let a=0,o;a<e.length;a++)if(o=e[a])for(let l=0;l<i.length;l++)i[l].eq(o,n)&&(i==this.local&&(i=this.local.slice()),i.splice(l--,1))}return r==this.children&&i==this.local?this:i.length||r.length?new ai(i,r):Xa}forChild(e,n){if(this==Xa)return this;if(n.isLeaf)return ai.empty;let r,i;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let a=e+1,o=a+n.content.size;for(let l=0;l<this.local.length;l++){let c=this.local[l];if(c.from<o&&c.to>a&&c.type instanceof ph){let u=Math.max(a,c.from)-a,d=Math.min(o,c.to)-a;u<d&&(i||(i=[])).push(c.copy(u,d))}}if(i){let l=new ai(i.sort(Zf),cg);return r?new Xd([l,r]):l}return r||Xa}eq(e){if(this==e)return!0;if(!(e instanceof ai)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let n=0;n<this.local.length;n++)if(!this.local[n].eq(e.local[n]))return!1;for(let n=0;n<this.children.length;n+=3)if(this.children[n]!=e.children[n]||this.children[n+1]!=e.children[n+1]||!this.children[n+2].eq(e.children[n+2]))return!1;return!0}locals(e){return PL(this.localsInner(e))}localsInner(e){if(this==Xa)return cg;if(e.inlineContent||!this.local.some(ph.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof ph||n.push(this.local[r]);return n}forEachSet(e){e(this)}}ai.empty=new ai([],[]);ai.removeOverlap=PL;const Xa=ai.empty;class Xd{constructor(e){this.members=e}map(e,n){const r=this.members.map(i=>i.map(e,n,Qf));return Xd.from(r)}forChild(e,n){if(n.isLeaf)return ai.empty;let r=[];for(let i=0;i<this.members.length;i++){let a=this.members[i].forChild(e,n);a!=Xa&&(a instanceof Xd?r=r.concat(a.members):r.push(a))}return Xd.from(r)}eq(e){if(!(e instanceof Xd)||e.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(e.members[n]))return!1;return!0}locals(e){let n,r=!0;for(let i=0;i<this.members.length;i++){let a=this.members[i].localsInner(e);if(a.length)if(!n)n=a;else{r&&(n=n.slice(),r=!1);for(let o=0;o<a.length;o++)n.push(a[o])}}return n?PL(r?n:n.sort(Zf)):cg}static from(e){switch(e.length){case 0:return Xa;case 1:return e[0];default:return new Xd(e.every(n=>n instanceof ai)?e:e.reduce((n,r)=>n.concat(r instanceof ai?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function o$e(t,e,n,r,i,a,o){let l=t.slice();for(let u=0,d=a;u<n.maps.length;u++){let f=0;n.maps[u].forEach((p,m,x,b)=>{let y=b-x-(m-p);for(let v=0;v<l.length;v+=3){let S=l[v+1];if(S<0||p>S+d-f)continue;let N=l[v]+d-f;m>=N?l[v+1]=p<=N?-2:-1:p>=d&&y&&(l[v]+=y,l[v+1]+=y)}f+=y}),d=n.maps[u].map(d,-1)}let c=!1;for(let u=0;u<l.length;u+=3)if(l[u+1]<0){if(l[u+1]==-2){c=!0,l[u+1]=-1;continue}let d=n.map(t[u]+a),f=d-i;if(f<0||f>=r.content.size){c=!0;continue}let p=n.map(t[u+1]+a,-1),m=p-i,{index:x,offset:b}=r.content.findIndex(f),y=r.maybeChild(x);if(y&&b==f&&b+y.nodeSize==m){let v=l[u+2].mapInner(n,y,d+1,t[u]+a+1,o);v!=Xa?(l[u]=f,l[u+1]=m,l[u+2]=v):(l[u+1]=-2,c=!0)}else c=!0}if(c){let u=l$e(l,t,e,n,i,a,o),d=gM(u,r,0,o);e=d.local;for(let f=0;f<l.length;f+=3)l[f+1]<0&&(l.splice(f,3),f-=3);for(let f=0,p=0;f<d.children.length;f+=3){let m=d.children[f];for(;p<l.length&&l[p]<m;)p+=3;l.splice(p,0,d.children[f],d.children[f+1],d.children[f+2])}}return new ai(e.sort(Zf),l)}function Gte(t,e){if(!e||!t.length)return t;let n=[];for(let r=0;r<t.length;r++){let i=t[r];n.push(new ms(i.from+e,i.to+e,i.type))}return n}function l$e(t,e,n,r,i,a,o){function l(c,u){for(let d=0;d<c.local.length;d++){let f=c.local[d].map(r,i,u);f?n.push(f):o.onRemove&&o.onRemove(c.local[d].spec)}for(let d=0;d<c.children.length;d+=3)l(c.children[d+2],c.children[d]+u+1)}for(let c=0;c<t.length;c+=3)t[c+1]==-1&&l(t[c+2],e[c]+a+1);return n}function qte(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,i=null;for(let a=0,o;a<t.length;a++)(o=t[a])&&o.from>n&&o.to<r&&((i||(i=[])).push(o),t[a]=null);return i}function Wte(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function gM(t,e,n,r){let i=[],a=!1;e.forEach((l,c)=>{let u=qte(t,l,c+n);if(u){a=!0;let d=gM(u,l,n+c+1,r);d!=Xa&&i.push(c,c+l.nodeSize,d)}});let o=Gte(a?Wte(t):t,-n).sort(Zf);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||(r.onRemove&&r.onRemove(o[l].spec),o.splice(l--,1));return o.length||i.length?new ai(o,i):Xa}function Zf(t,e){return t.from-e.from||t.to-e.to}function PL(t){let e=t;for(let n=0;n<e.length-1;n++){let r=e[n];if(r.from!=r.to)for(let i=n+1;i<e.length;i++){let a=e[i];if(a.from==r.from){a.to!=r.to&&(e==t&&(e=t.slice()),e[i]=a.copy(a.from,r.to),b9(e,i+1,a.copy(r.to,a.to)));continue}else{a.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,a.from),b9(e,i,r.copy(a.from,r.to)));break}}}return e}function b9(t,e,n){for(;e<t.length&&Zf(n,t[e])>0;)e++;t.splice(e,0,n)}function wj(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=Xa&&e.push(r)}),t.cursorWrapper&&e.push(ai.create(t.state.doc,[t.cursorWrapper.deco])),Xd.from(e)}const c$e={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},u$e=Hs&&fh<=11;class d$e{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class h$e{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new d$e,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let i=0;i<r.length;i++)this.queue.push(r[i]);Hs&&fh<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),u$e&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,c$e)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let n=0;n<e.length;n++)this.queue.push(e[n]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(u9(this.view)){if(this.suppressingSelectionUpdates)return Pu(this.view);if(Hs&&fh<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Sm(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let n=new Set,r;for(let a=e.focusNode;a;a=cx(a))n.add(a);for(let a=e.anchorNode;a;a=cx(a))if(n.has(a)){r=a;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let r=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&u9(e)&&!this.ignoreSelectionChange(r),a=-1,o=-1,l=!1,c=[];if(e.editable)for(let d=0;d<n.length;d++){let f=this.registerMutation(n[d],c);f&&(a=a<0?f.from:Math.min(f.from,a),o=o<0?f.to:Math.max(f.to,o),f.typeOver&&(l=!0))}if(il&&c.length){let d=c.filter(f=>f.nodeName=="BR");if(d.length==2){let[f,p]=d;f.parentNode&&f.parentNode.parentNode==p.parentNode?p.remove():f.remove()}else{let{focusNode:f}=this.currentSelection;for(let p of d){let m=p.parentNode;m&&m.nodeName=="LI"&&(!f||p$e(e,f)!=m)&&p.remove()}}}let u=null;a<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&E2(r)&&(u=NL(e))&&u.eq(An.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Pu(e),this.currentSelection.set(r),e.scrollToSelection()):(a>-1||i)&&(a>-1&&(e.docView.markDirty(a,o),f$e(e)),this.handleDOMChange(a,o,l,c),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Pu(e),this.currentSelection.set(r))}registerMutation(e,n){if(n.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let d=0;d<e.addedNodes.length;d++){let f=e.addedNodes[d];n.push(f),f.nodeType==3&&(this.lastChangedTextNode=f)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let i=e.previousSibling,a=e.nextSibling;if(Hs&&fh<=11&&e.addedNodes.length)for(let d=0;d<e.addedNodes.length;d++){let{previousSibling:f,nextSibling:p}=e.addedNodes[d];(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(i=f),(!p||Array.prototype.indexOf.call(e.addedNodes,p)<0)&&(a=p)}let o=i&&i.parentNode==e.target?La(i)+1:0,l=r.localPosFromDOM(e.target,o,-1),c=a&&a.parentNode==e.target?La(a):e.target.childNodes.length,u=r.localPosFromDOM(e.target,c,1);return{from:l,to:u}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let y9=new WeakMap,v9=!1;function f$e(t){if(!y9.has(t)&&(y9.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=il,v9)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),v9=!0}}function w9(t,e){let n=e.startContainer,r=e.startOffset,i=e.endContainer,a=e.endOffset,o=t.domAtPos(t.state.selection.anchor);return Sm(o.node,o.offset,i,a)&&([n,r,i,a]=[i,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}}function m$e(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return w9(t,i)}let n;function r(i){i.preventDefault(),i.stopImmediatePropagation(),n=i.getTargetRanges()[0]}return t.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),t.dom.removeEventListener("beforeinput",r,!0),n?w9(t,n):null}function p$e(t,e){for(let n=e.parentNode;n&&n!=t.dom;n=n.parentNode){let r=t.docView.nearestDesc(n,!0);if(r&&r.node.isBlock)return n}return null}function g$e(t,e,n){let{node:r,fromOffset:i,toOffset:a,from:o,to:l}=t.docView.parseRange(e,n),c=t.domSelectionRange(),u,d=c.anchorNode;if(d&&t.dom.contains(d.nodeType==1?d:d.parentNode)&&(u=[{node:d,offset:c.anchorOffset}],E2(c)||u.push({node:c.focusNode,offset:c.focusOffset})),Za&&t.input.lastKeyCode===8)for(let y=a;y>i;y--){let v=r.childNodes[y-1],S=v.pmViewDesc;if(v.nodeName=="BR"&&!S){a=y;break}if(!S||S.size)break}let f=t.state.doc,p=t.someProp("domParser")||E0.fromSchema(t.state.schema),m=f.resolve(o),x=null,b=p.parse(r,{topNode:m.parent,topMatch:m.parent.contentMatchAt(m.index()),topOpen:!0,from:i,to:a,preserveWhitespace:m.parent.type.whitespace=="pre"?"full":!0,findPositions:u,ruleFromNode:x$e,context:m});if(u&&u[0].pos!=null){let y=u[0].pos,v=u[1]&&u[1].pos;v==null&&(v=y),x={anchor:y+o,head:v+o}}return{doc:b,sel:x,from:o,to:l}}function x$e(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(ys&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let n=document.createElement("div");return n.appendChild(document.createElement("li")),{skip:n}}else if(t.parentNode.lastChild==t||ys&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName=="IMG"&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null}const b$e=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function y$e(t,e,n,r,i){let a=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let E=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,D=NL(t,E);if(D&&!t.state.selection.eq(D)){if(Za&&Su&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",R=>R(t,Af(13,"Enter"))))return;let A=t.state.tr.setSelection(D);E=="pointer"?A.setMeta("pointer",!0):E=="key"&&A.scrollIntoView(),a&&A.setMeta("composition",a),t.dispatch(A)}return}let o=t.state.doc.resolve(e),l=o.sharedDepth(n);e=o.before(l+1),n=t.state.doc.resolve(n).after(l+1);let c=t.state.selection,u=g$e(t,e,n),d=t.state.doc,f=d.slice(u.from,u.to),p,m;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(p=t.state.selection.to,m="end"):(p=t.state.selection.from,m="start"),t.input.lastKeyCode=null;let x=_$e(f.content,u.doc.content,u.from,p,m);if(x&&t.input.domChangeCount++,(ux&&t.input.lastIOSEnter>Date.now()-225||Su)&&i.some(E=>E.nodeType==1&&!b$e.test(E.nodeName))&&(!x||x.endA>=x.endB)&&t.someProp("handleKeyDown",E=>E(t,Af(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!x)if(r&&c instanceof mn&&!c.empty&&c.$head.sameParent(c.$anchor)&&!t.composing&&!(u.sel&&u.sel.anchor!=u.sel.head))x={start:c.from,endA:c.to,endB:c.to};else{if(u.sel){let E=_9(t,t.state.doc,u.sel);if(E&&!E.eq(t.state.selection)){let D=t.state.tr.setSelection(E);a&&D.setMeta("composition",a),t.dispatch(D)}}return}t.state.selection.from<t.state.selection.to&&x.start==x.endB&&t.state.selection instanceof mn&&(x.start>t.state.selection.from&&x.start<=t.state.selection.from+2&&t.state.selection.from>=u.from?x.start=t.state.selection.from:x.endA<t.state.selection.to&&x.endA>=t.state.selection.to-2&&t.state.selection.to<=u.to&&(x.endB+=t.state.selection.to-x.endA,x.endA=t.state.selection.to)),Hs&&fh<=11&&x.endB==x.start+1&&x.endA==x.start&&x.start>u.from&&u.doc.textBetween(x.start-u.from-1,x.start-u.from+1)==" "&&(x.start--,x.endA--,x.endB--);let b=u.doc.resolveNoCache(x.start-u.from),y=u.doc.resolveNoCache(x.endB-u.from),v=d.resolve(x.start),S=b.sameParent(y)&&b.parent.inlineContent&&v.end()>=x.endA;if((ux&&t.input.lastIOSEnter>Date.now()-225&&(!S||i.some(E=>E.nodeName=="DIV"||E.nodeName=="P"))||!S&&b.pos<u.doc.content.size&&(!b.sameParent(y)||!b.parent.inlineContent)&&b.pos<y.pos&&!/\S/.test(u.doc.textBetween(b.pos,y.pos,"","")))&&t.someProp("handleKeyDown",E=>E(t,Af(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>x.start&&w$e(d,x.start,x.endA,b,y)&&t.someProp("handleKeyDown",E=>E(t,Af(8,"Backspace")))){Su&&Za&&t.domObserver.suppressSelectionUpdates();return}Za&&x.endB==x.start&&(t.input.lastChromeDelete=Date.now()),Su&&!S&&b.start()!=y.start()&&y.parentOffset==0&&b.depth==y.depth&&u.sel&&u.sel.anchor==u.sel.head&&u.sel.head==x.endA&&(x.endB-=2,y=u.doc.resolveNoCache(x.endB-u.from),setTimeout(()=>{t.someProp("handleKeyDown",function(E){return E(t,Af(13,"Enter"))})},20));let N=x.start,T=x.endA,k=E=>{let D=E||t.state.tr.replace(N,T,u.doc.slice(x.start-u.from,x.endB-u.from));if(u.sel){let A=_9(t,D.doc,u.sel);A&&!(Za&&t.composing&&A.empty&&(x.start!=x.endB||t.input.lastChromeDelete<Date.now()-100)&&(A.head==N||A.head==D.mapping.map(T)-1)||Hs&&A.empty&&A.head==N)&&D.setSelection(A)}return a&&D.setMeta("composition",a),D.scrollIntoView()},C;if(S)if(b.pos==y.pos){Hs&&fh<=11&&b.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>Pu(t),20));let E=k(t.state.tr.delete(N,T)),D=d.resolve(x.start).marksAcross(d.resolve(x.endA));D&&E.ensureMarks(D),t.dispatch(E)}else if(x.endA==x.endB&&(C=v$e(b.parent.content.cut(b.parentOffset,y.parentOffset),v.parent.content.cut(v.parentOffset,x.endA-v.start())))){let E=k(t.state.tr);C.type=="add"?E.addMark(N,T,C.mark):E.removeMark(N,T,C.mark),t.dispatch(E)}else if(b.parent.child(b.index()).isText&&b.index()==y.index()-(y.textOffset?0:1)){let E=b.parent.textBetween(b.parentOffset,y.parentOffset),D=()=>k(t.state.tr.insertText(E,N,T));t.someProp("handleTextInput",A=>A(t,N,T,E,D))||t.dispatch(D())}else t.dispatch(k());else t.dispatch(k())}function _9(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:kL(t,e.resolve(n.anchor),e.resolve(n.head))}function v$e(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,i=n,a=r,o,l,c;for(let d=0;d<r.length;d++)i=r[d].removeFromSet(i);for(let d=0;d<n.length;d++)a=n[d].removeFromSet(a);if(i.length==1&&a.length==0)l=i[0],o="add",c=d=>d.mark(l.addToSet(d.marks));else if(i.length==0&&a.length==1)l=a[0],o="remove",c=d=>d.mark(l.removeFromSet(d.marks));else return null;let u=[];for(let d=0;d<e.childCount;d++)u.push(c(e.child(d)));if(kt.from(u).eq(t))return{mark:l,type:o}}function w$e(t,e,n,r,i){if(n-e<=i.pos-r.pos||_j(r,!0,!1)<i.pos)return!1;let a=t.resolve(e);if(!r.parent.isTextblock){let l=a.nodeAfter;return l!=null&&n==e+l.nodeSize}if(a.parentOffset<a.parent.content.size||!a.parent.isTextblock)return!1;let o=t.resolve(_j(a,!0,!0));return!o.parent.isTextblock||o.pos>n||_j(o,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function _j(t,e,n){let r=t.depth,i=e?t.end():t.pos;for(;r>0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,i++,e=!1;if(n){let a=t.node(r).maybeChild(t.indexAfter(r));for(;a&&!a.isLeaf;)a=a.firstChild,i++}return i}function _$e(t,e,n,r,i){let a=t.findDiffStart(e,n);if(a==null)return null;let{a:o,b:l}=t.findDiffEnd(e,n+t.size,n+e.size);if(i=="end"){let c=Math.max(0,a-Math.min(o,l));r-=o+c-a}if(o<a&&t.size<e.size){let c=r<=a&&r>=o?a-r:0;a-=c,a&&a<e.size&&S9(e.textBetween(a-1,a+1))&&(a+=c?1:-1),l=a+(l-o),o=a}else if(l<a){let c=r<=a&&r>=l?a-r:0;a-=c,a&&a<t.size&&S9(t.textBetween(a-1,a+1))&&(a+=c?1:-1),o=a+(o-l),l=a}return{start:a,endA:o,endB:l}}function S9(t){if(t.length!=2)return!1;let e=t.charCodeAt(0),n=t.charCodeAt(1);return e>=56320&&e<=57343&&n>=55296&&n<=56319}class Kte{constructor(e,n){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new BHe,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(T9),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=k9(this),N9(this),this.nodeViews=E9(this),this.docView=i9(this.state.doc,M9(this),wj(this),this.dom,this),this.domObserver=new h$e(this,(r,i,a,o)=>y$e(this,r,i,a,o)),this.domObserver.start(),HHe(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&&HD(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(T9),this.directPlugins=e.plugins),this.updateStateInner(e.state,n)}setProps(e){let n={};for(let r in this._props)n[r]=this._props[r];n.state=this.state;for(let r in e)n[r]=e[r];this.update(n)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,n){var r;let i=this.state,a=!1,o=!1;e.storedMarks&&this.composing&&(Bte(this),o=!0),this.state=e;let l=i.plugins!=e.plugins||this._props.plugins!=n.plugins;if(l||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let m=E9(this);M$e(m,this.nodeViews)&&(this.nodeViews=m,a=!0)}(l||n.handleDOMEvents!=this._props.handleDOMEvents)&&HD(this),this.editable=k9(this),N9(this);let c=wj(this),u=M9(this),d=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",f=a||!this.docView.matchesNode(e.doc,u,c);(f||!e.selection.eq(i.selection))&&(o=!0);let p=d=="preserve"&&o&&this.dom.style.overflowAnchor==null&&nHe(this);if(o){this.domObserver.stop();let m=f&&(Hs||Za)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&S$e(i.selection,e.selection);if(f){let x=Za?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=t$e(this)),(a||!this.docView.update(e.doc,u,c,this))&&(this.docView.updateOuterDeco(u),this.docView.destroy(),this.docView=i9(e.doc,u,c,this.dom,this)),x&&!this.trackWrites&&(m=!0)}m||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&kHe(this))?Pu(this,m):(Ate(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((r=this.dragging)===null||r===void 0)&&r.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),d=="reset"?this.dom.scrollTop=0:d=="to selection"?this.scrollToSelection():p&&rHe(p)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof Qt){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&Z7(this,n.getBoundingClientRect(),e)}else Z7(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let n=0;n<this.directPlugins.length;n++){let r=this.directPlugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let n=0;n<this.state.plugins.length;n++){let r=this.state.plugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let n=0;n<this.pluginViews.length;n++){let r=this.pluginViews[n];r.update&&r.update(this,e)}}updateDraggedNode(e,n){let r=e.node,i=-1;if(this.state.doc.nodeAt(r.from)==r.node)i=r.from;else{let a=r.from+(this.state.doc.content.size-n.doc.content.size);(a>0&&this.state.doc.nodeAt(a))==r.node&&(i=a)}this.dragging=new $te(e.slice,e.move,i<0?void 0:Qt.create(this.state.doc,i))}someProp(e,n){let r=this._props&&this._props[e],i;if(r!=null&&(i=n?n(r):r))return i;for(let o=0;o<this.directPlugins.length;o++){let l=this.directPlugins[o].props[e];if(l!=null&&(i=n?n(l):l))return i}let a=this.state.plugins;if(a)for(let o=0;o<a.length;o++){let l=a[o].props[e];if(l!=null&&(i=n?n(l):l))return i}}hasFocus(){if(Hs){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&iHe(this.dom),Pu(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let n=this.dom.parentNode;n;n=n.parentNode)if(n.nodeType==9||n.nodeType==11&&n.host)return n.getSelection||(Object.getPrototypeOf(n).getSelection=()=>n.ownerDocument.getSelection()),this._root=n}return e||document}updateRoot(){this._root=null}posAtCoords(e){return cHe(this,e)}coordsAtPos(e,n=1){return wte(this,e,n)}domAtPos(e,n=0){return this.docView.domFromPos(e,n)}nodeDOM(e){let n=this.docView.descAt(e);return n?n.nodeDOM:null}posAtDOM(e,n,r=-1){let i=this.docView.posFromDOM(e,n,r);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,n){return mHe(this,n||this.state,e)}pasteHTML(e,n){return ky(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return ky(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return EL(this,e)}destroy(){this.docView&&($He(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],wj(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,G6e())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return GHe(this,e)}domSelectionRange(){let e=this.domSelection();return e?ys&&this.root.nodeType===11&&Y6e(this.dom.ownerDocument)==this.dom&&m$e(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}Kte.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function M9(t){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),t.someProp("attributes",n=>{if(typeof n=="function"&&(n=n(t.state)),n)for(let r in n)r=="class"?e.class+=" "+n[r]:r=="style"?e.style=(e.style?e.style+";":"")+n[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(n[r]))}),e.translate||(e.translate="no"),[ms.node(0,t.state.doc.content.size,e)]}function N9(t){if(t.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),t.cursorWrapper={dom:e,deco:ms.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function k9(t){return!t.someProp("editable",e=>e(t.state)===!1)}function S$e(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 E9(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 M$e(t,e){let n=0,r=0;for(let i in t){if(t[i]!=e[i])return!0;n++}for(let i in e)r++;return n!=r}function T9(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var Ph={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},xM={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},N$e=typeof navigator<"u"&&/Mac/.test(navigator.platform),k$e=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Fa=0;Fa<10;Fa++)Ph[48+Fa]=Ph[96+Fa]=String(Fa);for(var Fa=1;Fa<=24;Fa++)Ph[Fa+111]="F"+Fa;for(var Fa=65;Fa<=90;Fa++)Ph[Fa]=String.fromCharCode(Fa+32),xM[Fa]=String.fromCharCode(Fa);for(var Sj in Ph)xM.hasOwnProperty(Sj)||(xM[Sj]=Ph[Sj]);function E$e(t){var e=N$e&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||k$e&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?xM:Ph)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}const T$e=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),A$e=typeof navigator<"u"&&/Win/.test(navigator.platform);function C$e(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,i,a,o;for(let l=0;l<e.length-1;l++){let c=e[l];if(/^(cmd|meta|m)$/i.test(c))o=!0;else if(/^a(lt)?$/i.test(c))r=!0;else if(/^(c|ctrl|control)$/i.test(c))i=!0;else if(/^s(hift)?$/i.test(c))a=!0;else if(/^mod$/i.test(c))T$e?o=!0:i=!0;else throw new Error("Unrecognized modifier name: "+c)}return r&&(n="Alt-"+n),i&&(n="Ctrl-"+n),o&&(n="Meta-"+n),a&&(n="Shift-"+n),n}function j$e(t){let e=Object.create(null);for(let n in t)e[C$e(n)]=t[n];return e}function Mj(t,e,n=!0){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),n&&e.shiftKey&&(t="Shift-"+t),t}function P$e(t){return new ui({props:{handleKeyDown:Xte(t)}})}function Xte(t){let e=j$e(t);return function(n,r){let i=E$e(r),a,o=e[Mj(i,r)];if(o&&o(n.state,n.dispatch,n))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let l=e[Mj(i,r,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(A$e&&r.ctrlKey&&r.altKey)&&(a=Ph[r.keyCode])&&a!=i){let l=e[Mj(a,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}var D$e=Object.defineProperty,DL=(t,e)=>{for(var n in e)D$e(t,n,{get:e[n],enumerable:!0})};function C2(t){const{state:e,transaction:n}=t;let{selection:r}=n,{doc:i}=n,{storedMarks:a}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return a},get selection(){return r},get doc(){return i},get tr(){return r=n.selection,i=n.doc,a=n.storedMarks,n}}}var j2=class{constructor(t){this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:t,editor:e,state:n}=this,{view:r}=e,{tr:i}=n,a=this.buildProps(i);return Object.fromEntries(Object.entries(t).map(([o,l])=>[o,(...u)=>{const d=l(...u)(a);return!i.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(i),d}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=!0){const{rawCommands:n,editor:r,state:i}=this,{view:a}=r,o=[],l=!!t,c=t||i.tr,u=()=>(!l&&e&&!c.getMeta("preventDispatch")&&!this.hasCustomState&&a.dispatch(c),o.every(f=>f===!0)),d={...Object.fromEntries(Object.entries(n).map(([f,p])=>[f,(...x)=>{const b=this.buildProps(c,e),y=p(...x)(b);return o.push(y),d}])),run:u};return d}createCan(t){const{rawCommands:e,state:n}=this,r=!1,i=t||n.tr,a=this.buildProps(i,r);return{...Object.fromEntries(Object.entries(e).map(([l,c])=>[l,(...u)=>c(...u)({...a,dispatch:void 0})])),chain:()=>this.createChain(i,r)}}buildProps(t,e=!0){const{rawCommands:n,editor:r,state:i}=this,{view:a}=r,o={tr:t,editor:r,view:a,state:C2({state:i,transaction:t}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(t,e),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(n).map(([l,c])=>[l,(...u)=>c(...u)(o)]))}};return o}},Yte={};DL(Yte,{blur:()=>R$e,clearContent:()=>O$e,clearNodes:()=>L$e,command:()=>F$e,createParagraphNear:()=>I$e,cut:()=>U$e,deleteCurrentNode:()=>z$e,deleteNode:()=>B$e,deleteRange:()=>H$e,deleteSelection:()=>$$e,enter:()=>V$e,exitCode:()=>G$e,extendMarkRange:()=>q$e,first:()=>W$e,focus:()=>X$e,forEach:()=>Y$e,insertContent:()=>Q$e,insertContentAt:()=>eVe,joinBackward:()=>rVe,joinDown:()=>nVe,joinForward:()=>iVe,joinItemBackward:()=>aVe,joinItemForward:()=>sVe,joinTextblockBackward:()=>oVe,joinTextblockForward:()=>lVe,joinUp:()=>tVe,keyboardShortcut:()=>uVe,lift:()=>dVe,liftEmptyBlock:()=>hVe,liftListItem:()=>fVe,newlineInCode:()=>mVe,resetAttributes:()=>pVe,scrollIntoView:()=>gVe,selectAll:()=>xVe,selectNodeBackward:()=>bVe,selectNodeForward:()=>yVe,selectParentNode:()=>vVe,selectTextblockEnd:()=>wVe,selectTextblockStart:()=>_Ve,setContent:()=>SVe,setMark:()=>BVe,setMeta:()=>HVe,setNode:()=>$Ve,setNodeSelection:()=>VVe,setTextDirection:()=>GVe,setTextSelection:()=>qVe,sinkListItem:()=>WVe,splitBlock:()=>KVe,splitListItem:()=>XVe,toggleList:()=>YVe,toggleMark:()=>QVe,toggleNode:()=>ZVe,toggleWrap:()=>JVe,undoInputRule:()=>eGe,unsetAllMarks:()=>tGe,unsetMark:()=>nGe,unsetTextDirection:()=>rGe,updateAttributes:()=>iGe,wrapIn:()=>aGe,wrapInList:()=>sGe});var R$e=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window?.getSelection())==null||n.removeAllRanges())}),!0),O$e=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),L$e=()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:i}=r;return n&&i.forEach(({$from:a,$to:o})=>{t.doc.nodesBetween(a.pos,o.pos,(l,c)=>{if(l.type.isText)return;const{doc:u,mapping:d}=e,f=u.resolve(d.map(c)),p=u.resolve(d.map(c+l.nodeSize)),m=f.blockRange(p);if(!m)return;const x=Ox(m);if(l.type.isTextblock){const{defaultType:b}=f.parent.contentMatchAt(f.index());e.setNodeMarkup(m.start,b)}(x||x===0)&&e.lift(m,x)})}),!0},F$e=t=>e=>t(e),I$e=()=>({state:t,dispatch:e})=>dte(t,e),U$e=(t,e)=>({editor:n,tr:r})=>{const{state:i}=n,a=i.doc.slice(t.from,t.to);r.deleteRange(t.from,t.to);const o=r.mapping.map(e);return r.insert(o,a.content),r.setSelection(new mn(r.doc.resolve(Math.max(o-1,0)))),!0},z$e=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;const i=t.selection.$anchor;for(let a=i.depth;a>0;a-=1)if(i.node(a).type===r.type){if(e){const l=i.before(a),c=i.after(a);t.delete(l,c).scrollIntoView()}return!0}return!1};function Gi(t,e){if(typeof t=="string"){if(!e.nodes[t])throw Error(`There is no node type named '${t}'. Maybe you forgot to add the extension?`);return e.nodes[t]}return t}var B$e=t=>({tr:e,state:n,dispatch:r})=>{const i=Gi(t,n.schema),a=e.selection.$anchor;for(let o=a.depth;o>0;o-=1)if(a.node(o).type===i){if(r){const c=a.before(o),u=a.after(o);e.delete(c,u).scrollIntoView()}return!0}return!1},H$e=t=>({tr:e,dispatch:n})=>{const{from:r,to:i}=t;return n&&e.delete(r,i),!0},$$e=()=>({state:t,dispatch:e})=>yL(t,e),V$e=()=>({commands:t})=>t.keyboardShortcut("Enter"),G$e=()=>({state:t,dispatch:e})=>C6e(t,e);function RL(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function bM(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(i=>n.strict?e[i]===t[i]:RL(e[i])?e[i].test(t[i]):e[i]===t[i]):!0}function Qte(t,e,n={}){return t.find(r=>r.type===e&&bM(Object.fromEntries(Object.keys(n).map(i=>[i,r.attrs[i]])),n))}function A9(t,e,n={}){return!!Qte(t,e,n)}function OL(t,e,n){var r;if(!t||!e)return;let i=t.parent.childAfter(t.parentOffset);if((!i.node||!i.node.marks.some(d=>d.type===e))&&(i=t.parent.childBefore(t.parentOffset)),!i.node||!i.node.marks.some(d=>d.type===e)||(n=n||((r=i.node.marks[0])==null?void 0:r.attrs),!Qte([...i.node.marks],e,n)))return;let o=i.index,l=t.start()+i.offset,c=o+1,u=l+i.node.nodeSize;for(;o>0&&A9([...t.parent.child(o-1).marks],e,n);)o-=1,l-=t.parent.child(o).nodeSize;for(;c<t.parent.childCount&&A9([...t.parent.child(c).marks],e,n);)u+=t.parent.child(c).nodeSize,c+=1;return{from:l,to:u}}function Yu(t,e){if(typeof t=="string"){if(!e.marks[t])throw Error(`There is no mark type named '${t}'. Maybe you forgot to add the extension?`);return e.marks[t]}return t}var q$e=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const a=Yu(t,r.schema),{doc:o,selection:l}=n,{$from:c,from:u,to:d}=l;if(i){const f=OL(c,a,e);if(f&&f.from<=u&&f.to>=d){const p=mn.create(o,f.from,f.to);n.setSelection(p)}}return!0},W$e=t=>e=>{const n=typeof t=="function"?t(e):t;for(let r=0;r<n.length;r+=1)if(n[r](e))return!0;return!1};function Zte(t){return t instanceof mn}function If(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function Jte(t,e=null){if(!e)return null;const n=An.atStart(t),r=An.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;const i=n.from,a=r.to;return e==="all"?mn.create(t,If(0,i,a),If(t.content.size,i,a)):mn.create(t,If(e,i,a),If(e,i,a))}function K$e(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function LL(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var X$e=(t=null,e={})=>({editor:n,view:r,tr:i,dispatch:a})=>{e={scrollIntoView:!0,...e};const o=()=>{(LL()||K$e())&&r.dom.focus(),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),e?.scrollIntoView&&n.commands.scrollIntoView())})};if(r.hasFocus()&&t===null||t===!1)return!0;if(a&&t===null&&!Zte(n.state.selection))return o(),!0;const l=Jte(i.doc,t)||n.state.selection,c=n.state.selection.eq(l);return a&&(c||i.setSelection(l),c&&i.storedMarks&&i.setStoredMarks(i.storedMarks),o()),!0},Y$e=(t,e)=>n=>t.every((r,i)=>e(r,{...n,index:i})),Q$e=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),ene=t=>{const e=t.childNodes;for(let n=e.length-1;n>=0;n-=1){const r=e[n];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?t.removeChild(r):r.nodeType===1&&ene(r)}return t};function t1(t){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");const e=`<body>${t}</body>`,n=new window.DOMParser().parseFromString(e,"text/html").body;return ene(n)}function Ty(t,e,n){if(t instanceof hh||t instanceof kt)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 kt.fromArray(t.map(l=>e.nodeFromJSON(l)));const o=e.nodeFromJSON(t);return n.errorOnInvalidContent&&o.check(),o}catch(a){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:a});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",a),Ty("",e,n)}if(i){if(n.errorOnInvalidContent){let o=!1,l="";const c=new Iee({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:u=>(o=!0,l=typeof u=="string"?u:u.outerHTML,null)}]}})});if(n.slice?E0.fromSchema(c).parseSlice(t1(t),n.parseOptions):E0.fromSchema(c).parse(t1(t),n.parseOptions),n.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const a=E0.fromSchema(e);return n.slice?a.parseSlice(t1(t),n.parseOptions).content:a.parse(t1(t),n.parseOptions)}return Ty("",e,n)}function Z$e(t,e,n){const r=t.steps.length-1;if(r<e)return;const i=t.steps[r];if(!(i instanceof xa||i instanceof wa))return;const a=t.mapping.maps[r];let o=0;a.forEach((l,c,u,d)=>{o===0&&(o=d)}),t.setSelection(An.near(t.doc.resolve(o),n))}var J$e=t=>!("type"in t),eVe=(t,e,n)=>({tr:r,dispatch:i,editor:a})=>{var o;if(i){n={parseOptions:a.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let l;const c=y=>{a.emit("contentError",{editor:a,error:y,disableCollaboration:()=>{"collaboration"in a.storage&&typeof a.storage.collaboration=="object"&&a.storage.collaboration&&(a.storage.collaboration.isDisabled=!0)}})},u={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!a.options.enableContentCheck&&a.options.emitContentError)try{Ty(e,a.schema,{parseOptions:u,errorOnInvalidContent:!0})}catch(y){c(y)}try{l=Ty(e,a.schema,{parseOptions:u,errorOnInvalidContent:(o=n.errorOnInvalidContent)!=null?o:a.options.enableContentCheck})}catch(y){return c(y),!1}let{from:d,to:f}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},p=!0,m=!0;if((J$e(l)?l:[l]).forEach(y=>{y.check(),p=p?y.isText&&y.marks.length===0:!1,m=m?y.isBlock:!1}),d===f&&m){const{parent:y}=r.doc.resolve(d);y.isTextblock&&!y.type.spec.code&&!y.childCount&&(d-=1,f+=1)}let b;if(p){if(Array.isArray(e))b=e.map(y=>y.text||"").join("");else if(e instanceof kt){let y="";e.forEach(v=>{v.text&&(y+=v.text)}),b=y}else typeof e=="object"&&e&&e.text?b=e.text:b=e;r.insertText(b,d,f)}else{b=l;const y=r.doc.resolve(d),v=y.node(),S=y.parentOffset===0,N=v.isText||v.isTextblock,T=v.content.size>0;S&&N&&T&&(d=Math.max(0,d-1)),r.replaceWith(d,f,b)}n.updateSelection&&Z$e(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:d,text:b}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:d,text:b})}return!0},tVe=()=>({state:t,dispatch:e})=>E6e(t,e),nVe=()=>({state:t,dispatch:e})=>T6e(t,e),rVe=()=>({state:t,dispatch:e})=>ite(t,e),iVe=()=>({state:t,dispatch:e})=>lte(t,e),aVe=()=>({state:t,dispatch:e,tr:n})=>{try{const r=M2(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},sVe=()=>({state:t,dispatch:e,tr:n})=>{try{const r=M2(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},oVe=()=>({state:t,dispatch:e})=>N6e(t,e),lVe=()=>({state:t,dispatch:e})=>k6e(t,e);function tne(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function cVe(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");let r,i,a,o;for(let l=0;l<e.length-1;l+=1){const c=e[l];if(/^(cmd|meta|m)$/i.test(c))o=!0;else if(/^a(lt)?$/i.test(c))r=!0;else if(/^(c|ctrl|control)$/i.test(c))i=!0;else if(/^s(hift)?$/i.test(c))a=!0;else if(/^mod$/i.test(c))LL()||tne()?o=!0:i=!0;else throw new Error(`Unrecognized modifier name: ${c}`)}return r&&(n=`Alt-${n}`),i&&(n=`Ctrl-${n}`),o&&(n=`Meta-${n}`),a&&(n=`Shift-${n}`),n}var uVe=t=>({editor:e,view:n,tr:r,dispatch:i})=>{const a=cVe(t).split(/-(?!$)/),o=a.find(u=>!["Alt","Ctrl","Meta","Shift"].includes(u)),l=new KeyboardEvent("keydown",{key:o==="Space"?" ":o,altKey:a.includes("Alt"),ctrlKey:a.includes("Ctrl"),metaKey:a.includes("Meta"),shiftKey:a.includes("Shift"),bubbles:!0,cancelable:!0}),c=e.captureTransaction(()=>{n.someProp("handleKeyDown",u=>u(n,l))});return c?.steps.forEach(u=>{const d=u.map(r.mapping);d&&i&&r.maybeStep(d)}),!0};function Dh(t,e,n={}){const{from:r,to:i,empty:a}=t.selection,o=e?Gi(e,t.schema):null,l=[];t.doc.nodesBetween(r,i,(f,p)=>{if(f.isText)return;const m=Math.max(r,p),x=Math.min(i,p+f.nodeSize);l.push({node:f,from:m,to:x})});const c=i-r,u=l.filter(f=>o?o.name===f.node.type.name:!0).filter(f=>bM(f.node.attrs,n,{strict:!1}));return a?!!u.length:u.reduce((f,p)=>f+p.to-p.from,0)>=c}var dVe=(t,e={})=>({state:n,dispatch:r})=>{const i=Gi(t,n.schema);return Dh(n,i,e)?A6e(n,r):!1},hVe=()=>({state:t,dispatch:e})=>hte(t,e),fVe=t=>({state:e,dispatch:n})=>{const r=Gi(t,e.schema);return B6e(r)(e,n)},mVe=()=>({state:t,dispatch:e})=>ute(t,e);function P2(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function C9(t,e){const n=typeof e=="string"?[e]:e;return Object.keys(t).reduce((r,i)=>(n.includes(i)||(r[i]=t[i]),r),{})}var pVe=(t,e)=>({tr:n,state:r,dispatch:i})=>{let a=null,o=null;const l=P2(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(a=Gi(t,r.schema)),l==="mark"&&(o=Yu(t,r.schema));let c=!1;return n.selection.ranges.forEach(u=>{r.doc.nodesBetween(u.$from.pos,u.$to.pos,(d,f)=>{a&&a===d.type&&(c=!0,i&&n.setNodeMarkup(f,void 0,C9(d.attrs,e))),o&&d.marks.length&&d.marks.forEach(p=>{o===p.type&&(c=!0,i&&n.addMark(f,f+d.nodeSize,o.create(C9(p.attrs,e))))})})}),c},gVe=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),xVe=()=>({tr:t,dispatch:e})=>{if(e){const n=new xo(t.doc);t.setSelection(n)}return!0},bVe=()=>({state:t,dispatch:e})=>ste(t,e),yVe=()=>({state:t,dispatch:e})=>cte(t,e),vVe=()=>({state:t,dispatch:e})=>D6e(t,e),wVe=()=>({state:t,dispatch:e})=>L6e(t,e),_Ve=()=>({state:t,dispatch:e})=>O6e(t,e);function $D(t,e,n={},r={}){return Ty(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var SVe=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:i,tr:a,dispatch:o,commands:l})=>{const{doc:c}=a;if(r.preserveWhitespace!=="full"){const u=$D(t,i.schema,r,{errorOnInvalidContent:e??i.options.enableContentCheck});return o&&a.replaceWith(0,c.content.size,u).setMeta("preventUpdate",!n),!0}return o&&a.setMeta("preventUpdate",!n),l.insertContentAt({from:0,to:c.content.size},t,{parseOptions:r,errorOnInvalidContent:e??i.options.enableContentCheck})};function nne(t,e){const n=Yu(e,t.schema),{from:r,to:i,empty:a}=t.selection,o=[];a?(t.storedMarks&&o.push(...t.storedMarks),o.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,i,c=>{o.push(...c.marks)});const l=o.find(c=>c.type.name===n.name);return l?{...l.attrs}:{}}function rne(t,e){const n=new ete(t);return e.forEach(r=>{r.steps.forEach(i=>{n.step(i)})}),n}function MVe(t){for(let e=0;e<t.edgeCount;e+=1){const{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}function NVe(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(i,a)=>{n(i)&&r.push({node:i,pos:a})}),r}function kVe(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 D2(t){return e=>kVe(e.$from,t)}function Xt(t,e,n){return t.config[e]===void 0&&t.parent?Xt(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?Xt(t.parent,e,n):null}):t.config[e]}function FL(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=Xt(e,"addExtensions",n);return r?[e,...FL(r())]:e}).flat(10)}function IL(t,e){const n=Pm.fromSchema(e).serializeFragment(t),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(n),i.innerHTML}function ine(t){return typeof t=="function"}function xr(t,e=void 0,...n){return ine(t)?e?t.bind(e)(...n):t(...n):t}function EVe(t={}){return Object.keys(t).length===0&&t.constructor===Object}function dx(t){const e=t.filter(i=>i.type==="extension"),n=t.filter(i=>i.type==="node"),r=t.filter(i=>i.type==="mark");return{baseExtensions:e,nodeExtensions:n,markExtensions:r}}function ane(t){const e=[],{nodeExtensions:n,markExtensions:r}=dx(t),i=[...n,...r],a={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return t.forEach(o=>{const l={name:o.name,options:o.options,storage:o.storage,extensions:i},c=Xt(o,"addGlobalAttributes",l);if(!c)return;c().forEach(d=>{d.types.forEach(f=>{Object.entries(d.attributes).forEach(([p,m])=>{e.push({type:f,name:p,attribute:{...a,...m}})})})})}),i.forEach(o=>{const l={name:o.name,options:o.options,storage:o.storage},c=Xt(o,"addAttributes",l);if(!c)return;const u=c();Object.entries(u).forEach(([d,f])=>{const p={...a,...f};typeof p?.default=="function"&&(p.default=p.default()),p?.isRequired&&p?.default===void 0&&delete p.default,e.push({type:o.name,name:d,attribute:p})})}),e}function vi(...t){return t.filter(e=>!!e).reduce((e,n)=>{const r={...e};return Object.entries(n).forEach(([i,a])=>{if(!r[i]){r[i]=a;return}if(i==="class"){const l=a?String(a).split(" "):[],c=r[i]?r[i].split(" "):[],u=l.filter(d=>!c.includes(d));r[i]=[...c,...u].join(" ")}else if(i==="style"){const l=a?a.split(";").map(d=>d.trim()).filter(Boolean):[],c=r[i]?r[i].split(";").map(d=>d.trim()).filter(Boolean):[],u=new Map;c.forEach(d=>{const[f,p]=d.split(":").map(m=>m.trim());u.set(f,p)}),l.forEach(d=>{const[f,p]=d.split(":").map(m=>m.trim());u.set(f,p)}),r[i]=Array.from(u.entries()).map(([d,f])=>`${d}: ${f}`).join("; ")}else r[i]=a}),r},{})}function yM(t,e){return e.filter(n=>n.type===t.type.name).filter(n=>n.attribute.rendered).map(n=>n.attribute.renderHTML?n.attribute.renderHTML(t.attrs)||{}:{[n.name]:t.attrs[n.name]}).reduce((n,r)=>vi(n,r),{})}function TVe(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function j9(t,e){return"style"in t?t:{...t,getAttrs:n=>{const r=t.getAttrs?t.getAttrs(n):t.attrs;if(r===!1)return!1;const i=e.reduce((a,o)=>{const l=o.attribute.parseHTML?o.attribute.parseHTML(n):TVe(n.getAttribute(o.name));return l==null?a:{...a,[o.name]:l}},{});return{...r,...i}}}}function P9(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&EVe(n)?!1:n!=null))}function D9(t){var e,n;const r={};return!((e=t?.attribute)!=null&&e.isRequired)&&"default"in(t?.attribute||{})&&(r.default=t.attribute.default),((n=t?.attribute)==null?void 0:n.validate)!==void 0&&(r.validate=t.attribute.validate),[t.name,r]}function AVe(t,e){var n;const r=ane(t),{nodeExtensions:i,markExtensions:a}=dx(t),o=(n=i.find(u=>Xt(u,"topNode")))==null?void 0:n.name,l=Object.fromEntries(i.map(u=>{const d=r.filter(v=>v.type===u.name),f={name:u.name,options:u.options,storage:u.storage,editor:e},p=t.reduce((v,S)=>{const N=Xt(S,"extendNodeSchema",f);return{...v,...N?N(u):{}}},{}),m=P9({...p,content:xr(Xt(u,"content",f)),marks:xr(Xt(u,"marks",f)),group:xr(Xt(u,"group",f)),inline:xr(Xt(u,"inline",f)),atom:xr(Xt(u,"atom",f)),selectable:xr(Xt(u,"selectable",f)),draggable:xr(Xt(u,"draggable",f)),code:xr(Xt(u,"code",f)),whitespace:xr(Xt(u,"whitespace",f)),linebreakReplacement:xr(Xt(u,"linebreakReplacement",f)),defining:xr(Xt(u,"defining",f)),isolating:xr(Xt(u,"isolating",f)),attrs:Object.fromEntries(d.map(D9))}),x=xr(Xt(u,"parseHTML",f));x&&(m.parseDOM=x.map(v=>j9(v,d)));const b=Xt(u,"renderHTML",f);b&&(m.toDOM=v=>b({node:v,HTMLAttributes:yM(v,d)}));const y=Xt(u,"renderText",f);return y&&(m.toText=y),[u.name,m]})),c=Object.fromEntries(a.map(u=>{const d=r.filter(y=>y.type===u.name),f={name:u.name,options:u.options,storage:u.storage,editor:e},p=t.reduce((y,v)=>{const S=Xt(v,"extendMarkSchema",f);return{...y,...S?S(u):{}}},{}),m=P9({...p,inclusive:xr(Xt(u,"inclusive",f)),excludes:xr(Xt(u,"excludes",f)),group:xr(Xt(u,"group",f)),spanning:xr(Xt(u,"spanning",f)),code:xr(Xt(u,"code",f)),attrs:Object.fromEntries(d.map(D9))}),x=xr(Xt(u,"parseHTML",f));x&&(m.parseDOM=x.map(y=>j9(y,d)));const b=Xt(u,"renderHTML",f);return b&&(m.toDOM=y=>b({mark:y,HTMLAttributes:yM(y,d)})),[u.name,m]}));return new Iee({topNode:o,nodes:l,marks:c})}function CVe(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function UL(t){return t.sort((n,r)=>{const i=Xt(n,"priority")||100,a=Xt(r,"priority")||100;return i>a?-1:i<a?1:0})}function sne(t){const e=UL(FL(t)),n=CVe(e.map(r=>r.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(r=>`'${r}'`).join(", ")}]. This can lead to issues.`),e}function one(t,e,n){const{from:r,to:i}=e,{blockSeparator:a=`
- `,textSerializers:o={}}=n||{};let l="";return t.nodesBetween(r,i,(c,u,d,f)=>{var p;c.isBlock&&u>r&&(l+=a);const m=o?.[c.type.name];if(m)return d&&(l+=m({node:c,pos:u,parent:d,index:f,range:e})),!1;c.isText&&(l+=(p=c?.text)==null?void 0:p.slice(Math.max(r,u)-u,i-u))}),l}function jVe(t,e){const n={from:0,to:t.content.size};return one(t,n,e)}function lne(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function PVe(t,e){const n=Gi(e,t.schema),{from:r,to:i}=t.selection,a=[];t.doc.nodesBetween(r,i,l=>{a.push(l)});const o=a.reverse().find(l=>l.type.name===n.name);return o?{...o.attrs}:{}}function cne(t,e){const n=P2(typeof e=="string"?e:e.name,t.schema);return n==="node"?PVe(t,e):n==="mark"?nne(t,e):{}}function DVe(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 RVe(t){const e=DVe(t);return e.length===1?e:e.filter((n,r)=>!e.filter((a,o)=>o!==r).some(a=>n.oldRange.from>=a.oldRange.from&&n.oldRange.to<=a.oldRange.to&&n.newRange.from>=a.newRange.from&&n.newRange.to<=a.newRange.to))}function une(t){const{mapping:e,steps:n}=t,r=[];return e.maps.forEach((i,a)=>{const o=[];if(i.ranges.length)i.forEach((l,c)=>{o.push({from:l,to:c})});else{const{from:l,to:c}=n[a];if(l===void 0||c===void 0)return;o.push({from:l,to:c})}o.forEach(({from:l,to:c})=>{const u=e.slice(a).map(l,-1),d=e.slice(a).map(c),f=e.invert().map(u,-1),p=e.invert().map(d);r.push({oldRange:{from:f,to:p},newRange:{from:u,to:d}})})}),RVe(r)}function zL(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(i=>{const a=n.resolve(t),o=OL(a,i.type);o&&r.push({mark:i,...o})}):n.nodesBetween(t,e,(i,a)=>{!i||i?.nodeSize===void 0||r.push(...i.marks.map(o=>({from:a,to:a+i.nodeSize,mark:o})))}),r}var OVe=(t,e,n,r=20)=>{const i=t.doc.resolve(n);let a=r,o=null;for(;a>0&&o===null;){const l=i.node(a);l?.type.name===e?o=l:a-=1}return[o,a]};function Nj(t,e){return e.nodes[t]||e.marks[t]||null}function O1(t,e,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{const i=t.find(a=>a.type===e&&a.name===r);return i?i.attribute.keepOnSplit:!1}))}var LVe=(t,e=500)=>{let n="";const r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(i,a,o,l)=>{var c,u;const d=((u=(c=i.type.spec).toText)==null?void 0:u.call(c,{node:i,pos:a,parent:o,index:l}))||i.textContent||"%leaf%";n+=i.isAtom&&!i.isText?d:d.slice(0,Math.max(0,r-a))}),n};function VD(t,e,n={}){const{empty:r,ranges:i}=t.selection,a=e?Yu(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(f=>a?a.name===f.type.name:!0).find(f=>bM(f.attrs,n,{strict:!1}));let o=0;const l=[];if(i.forEach(({$from:f,$to:p})=>{const m=f.pos,x=p.pos;t.doc.nodesBetween(m,x,(b,y)=>{if(!b.isText&&!b.marks.length)return;const v=Math.max(m,y),S=Math.min(x,y+b.nodeSize),N=S-v;o+=N,l.push(...b.marks.map(T=>({mark:T,from:v,to:S})))})}),o===0)return!1;const c=l.filter(f=>a?a.name===f.mark.type.name:!0).filter(f=>bM(f.mark.attrs,n,{strict:!1})).reduce((f,p)=>f+p.to-p.from,0),u=l.filter(f=>a?f.mark.type!==a&&f.mark.type.excludes(a):!0).reduce((f,p)=>f+p.to-p.from,0);return(c>0?c+u:c)>=o}function FVe(t,e,n={}){if(!e)return Dh(t,null,n)||VD(t,null,n);const r=P2(e,t.schema);return r==="node"?Dh(t,e,n):r==="mark"?VD(t,e,n):!1}var IVe=(t,e)=>{const{$from:n,$to:r,$anchor:i}=t.selection;if(e){const a=D2(l=>l.type.name===e)(t.selection);if(!a)return!1;const o=t.doc.resolve(a.pos+1);return i.pos+1===o.end()}return!(r.parentOffset<r.parent.nodeSize-2||n.pos!==r.pos)},UVe=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function R9(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function O9(t,e){const{nodeExtensions:n}=dx(e),r=n.find(o=>o.name===t);if(!r)return!1;const i={name:r.name,options:r.options,storage:r.storage},a=xr(Xt(r,"group",i));return typeof a!="string"?!1:a.split(" ").includes("list")}function R2(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){var r;if(n){if(t.type.name==="hardBreak")return!0;if(t.isText)return/^\s*$/m.test((r=t.text)!=null?r:"")}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(t.content.childCount===0)return!0;if(e){let i=!0;return t.content.forEach(a=>{i!==!1&&(R2(a,{ignoreWhitespace:n,checkChildren:e})||(i=!1))}),i}return!1}function dne(t){return t instanceof Qt}function zVe(t,e,n){var r;const{selection:i}=e;let a=null;if(Zte(i)&&(a=i.$cursor),a){const l=(r=t.storedMarks)!=null?r:a.marks();return a.parent.type.allowsMarkType(n)&&(!!n.isInSet(l)||!l.some(u=>u.type.excludes(n)))}const{ranges:o}=i;return o.some(({$from:l,$to:c})=>{let u=l.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(l.pos,c.pos,(d,f,p)=>{if(u)return!1;if(d.isInline){const m=!p||p.type.allowsMarkType(n),x=!!n.isInSet(d.marks)||!d.marks.some(b=>b.type.excludes(n));u=m&&x}return!u}),u})}var BVe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const{selection:a}=n,{empty:o,ranges:l}=a,c=Yu(t,r.schema);if(i)if(o){const u=nne(r,c);n.addStoredMark(c.create({...u,...e}))}else l.forEach(u=>{const d=u.$from.pos,f=u.$to.pos;r.doc.nodesBetween(d,f,(p,m)=>{const x=Math.max(m,d),b=Math.min(m+p.nodeSize,f);p.marks.find(v=>v.type===c)?p.marks.forEach(v=>{c===v.type&&n.addMark(x,b,c.create({...v.attrs,...e}))}):n.addMark(x,b,c.create(e))})});return zVe(r,n,c)},HVe=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),$Ve=(t,e={})=>({state:n,dispatch:r,chain:i})=>{const a=Gi(t,n.schema);let o;return n.selection.$anchor.sameParent(n.selection.$head)&&(o=n.selection.$anchor.parent.attrs),a.isTextblock?i().command(({commands:l})=>X7(a,{...o,...e})(n)?!0:l.clearNodes()).command(({state:l})=>X7(a,{...o,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},VVe=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,i=If(t,0,r.content.size),a=Qt.create(r,i);e.setSelection(a)}return!0},GVe=(t,e)=>({tr:n,state:r,dispatch:i})=>{const{selection:a}=r;let o,l;return typeof e=="number"?(o=e,l=e):e&&"from"in e&&"to"in e?(o=e.from,l=e.to):(o=a.from,l=a.to),i&&n.doc.nodesBetween(o,l,(c,u)=>{c.isText||n.setNodeMarkup(u,void 0,{...c.attrs,dir:t})}),!0},qVe=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:i,to:a}=typeof t=="number"?{from:t,to:t}:t,o=mn.atStart(r).from,l=mn.atEnd(r).to,c=If(i,o,l),u=If(a,o,l),d=mn.create(r,c,u);e.setSelection(d)}return!0},WVe=t=>({state:e,dispatch:n})=>{const r=Gi(t,e.schema);return V6e(r)(e,n)};function L9(t,e){const n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){const r=n.filter(i=>e?.includes(i.type.name));t.tr.ensureMarks(r)}}var KVe=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:i})=>{const{selection:a,doc:o}=e,{$from:l,$to:c}=a,u=i.extensionManager.attributes,d=O1(u,l.node().type.name,l.node().attrs);if(a instanceof Qt&&a.node.isBlock)return!l.parentOffset||!ju(o,l.pos)?!1:(r&&(t&&L9(n,i.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;const f=c.parentOffset===c.parent.content.size,p=l.depth===0?void 0:MVe(l.node(-1).contentMatchAt(l.indexAfter(-1)));let m=f&&p?[{type:p,attrs:d}]:void 0,x=ju(e.doc,e.mapping.map(l.pos),1,m);if(!m&&!x&&ju(e.doc,e.mapping.map(l.pos),1,p?[{type:p}]:void 0)&&(x=!0,m=p?[{type:p,attrs:d}]:void 0),r){if(x&&(a instanceof mn&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,m),p&&!f&&!l.parentOffset&&l.parent.type!==p)){const b=e.mapping.map(l.before()),y=e.doc.resolve(b);l.node(-1).canReplaceWith(y.index(),y.index()+1,p)&&e.setNodeMarkup(e.mapping.map(l.before()),p)}t&&L9(n,i.extensionManager.splittableMarks),e.scrollIntoView()}return x},XVe=(t,e={})=>({tr:n,state:r,dispatch:i,editor:a})=>{var o;const l=Gi(t,r.schema),{$from:c,$to:u}=r.selection,d=r.selection.node;if(d&&d.isBlock||c.depth<2||!c.sameParent(u))return!1;const f=c.node(-1);if(f.type!==l)return!1;const p=a.extensionManager.attributes;if(c.parent.content.size===0&&c.node(-1).childCount===c.indexAfter(-1)){if(c.depth===2||c.node(-3).type!==l||c.index(-2)!==c.node(-2).childCount-1)return!1;if(i){let v=kt.empty;const S=c.index(-1)?1:c.index(-2)?2:3;for(let D=c.depth-S;D>=c.depth-3;D-=1)v=kt.from(c.node(D).copy(v));const N=c.indexAfter(-1)<c.node(-2).childCount?1:c.indexAfter(-2)<c.node(-3).childCount?2:3,T={...O1(p,c.node().type.name,c.node().attrs),...e},k=((o=l.contentMatch.defaultType)==null?void 0:o.createAndFill(T))||void 0;v=v.append(kt.from(l.createAndFill(null,k)||void 0));const C=c.before(c.depth-(S-1));n.replace(C,c.after(-N),new Ut(v,4-S,0));let E=-1;n.doc.nodesBetween(C,n.doc.content.size,(D,A)=>{if(E>-1)return!1;D.isTextblock&&D.content.size===0&&(E=A+1)}),E>-1&&n.setSelection(mn.near(n.doc.resolve(E))),n.scrollIntoView()}return!0}const m=u.pos===c.end()?f.contentMatchAt(0).defaultType:null,x={...O1(p,f.type.name,f.attrs),...e},b={...O1(p,c.node().type.name,c.node().attrs),...e};n.delete(c.pos,u.pos);const y=m?[{type:l,attrs:x},{type:m,attrs:b}]:[{type:l,attrs:x}];if(!ju(n.doc,c.pos,2))return!1;if(i){const{selection:v,storedMarks:S}=r,{splittableMarks:N}=a.extensionManager,T=S||v.$to.parentOffset&&v.$from.marks();if(n.split(c.pos,2,y).scrollIntoView(),!T||!i)return!0;const k=T.filter(C=>N.includes(C.type.name));n.ensureMarks(k)}return!0},kj=(t,e)=>{const n=D2(o=>o.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;const i=t.doc.nodeAt(r);return n.node.type===i?.type&&zh(t.doc,n.pos)&&t.join(n.pos),!0},Ej=(t,e)=>{const n=D2(o=>o.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;const i=t.doc.nodeAt(r);return n.node.type===i?.type&&zh(t.doc,r)&&t.join(r),!0},YVe=(t,e,n,r={})=>({editor:i,tr:a,state:o,dispatch:l,chain:c,commands:u,can:d})=>{const{extensions:f,splittableMarks:p}=i.extensionManager,m=Gi(t,o.schema),x=Gi(e,o.schema),{selection:b,storedMarks:y}=o,{$from:v,$to:S}=b,N=v.blockRange(S),T=y||b.$to.parentOffset&&b.$from.marks();if(!N)return!1;const k=D2(C=>O9(C.type.name,f))(b);if(N.depth>=1&&k&&N.depth-k.depth<=1){if(k.node.type===m)return u.liftListItem(x);if(O9(k.node.type.name,f)&&m.validContent(k.node.content)&&l)return c().command(()=>(a.setNodeMarkup(k.pos,m),!0)).command(()=>kj(a,m)).command(()=>Ej(a,m)).run()}return!n||!T||!l?c().command(()=>d().wrapInList(m,r)?!0:u.clearNodes()).wrapInList(m,r).command(()=>kj(a,m)).command(()=>Ej(a,m)).run():c().command(()=>{const C=d().wrapInList(m,r),E=T.filter(D=>p.includes(D.type.name));return a.ensureMarks(E),C?!0:u.clearNodes()}).wrapInList(m,r).command(()=>kj(a,m)).command(()=>Ej(a,m)).run()},QVe=(t,e={},n={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:a=!1}=n,o=Yu(t,r.schema);return VD(r,o,e)?i.unsetMark(o,{extendEmptyMarkRange:a}):i.setMark(o,e)},ZVe=(t,e,n={})=>({state:r,commands:i})=>{const a=Gi(t,r.schema),o=Gi(e,r.schema),l=Dh(r,a,n);let c;return r.selection.$anchor.sameParent(r.selection.$head)&&(c=r.selection.$anchor.parent.attrs),l?i.setNode(o,c):i.setNode(a,{...c,...n})},JVe=(t,e={})=>({state:n,commands:r})=>{const i=Gi(t,n.schema);return Dh(n,i,e)?r.lift(i):r.wrapIn(i,e)},eGe=()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let r=0;r<n.length;r+=1){const i=n[r];let a;if(i.spec.isInputRules&&(a=i.getState(t))){if(e){const o=t.tr,l=a.transform;for(let c=l.steps.length-1;c>=0;c-=1)o.step(l.steps[c].invert(l.docs[c]));if(a.text){const c=o.doc.resolve(a.from).marks();o.replaceWith(a.from,a.to,t.schema.text(a.text,c))}else o.delete(a.from,a.to)}return!0}}return!1},tGe=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,{empty:r,ranges:i}=n;return r||e&&i.forEach(a=>{t.removeMark(a.$from.pos,a.$to.pos)}),!0},nGe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{var a;const{extendEmptyMarkRange:o=!1}=e,{selection:l}=n,c=Yu(t,r.schema),{$from:u,empty:d,ranges:f}=l;if(!i)return!0;if(d&&o){let{from:p,to:m}=l;const x=(a=u.marks().find(y=>y.type===c))==null?void 0:a.attrs,b=OL(u,c,x);b&&(p=b.from,m=b.to),n.removeMark(p,m,c)}else f.forEach(p=>{n.removeMark(p.$from.pos,p.$to.pos,c)});return n.removeStoredMark(c),!0},rGe=t=>({tr:e,state:n,dispatch:r})=>{const{selection:i}=n;let a,o;return typeof t=="number"?(a=t,o=t):t&&"from"in t&&"to"in t?(a=t.from,o=t.to):(a=i.from,o=i.to),r&&e.doc.nodesBetween(a,o,(l,c)=>{if(l.isText)return;const u={...l.attrs};delete u.dir,e.setNodeMarkup(c,void 0,u)}),!0},iGe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{let a=null,o=null;const l=P2(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(a=Gi(t,r.schema)),l==="mark"&&(o=Yu(t,r.schema));let c=!1;return n.selection.ranges.forEach(u=>{const d=u.$from.pos,f=u.$to.pos;let p,m,x,b;n.selection.empty?r.doc.nodesBetween(d,f,(y,v)=>{a&&a===y.type&&(c=!0,x=Math.max(v,d),b=Math.min(v+y.nodeSize,f),p=v,m=y)}):r.doc.nodesBetween(d,f,(y,v)=>{v<d&&a&&a===y.type&&(c=!0,x=Math.max(v,d),b=Math.min(v+y.nodeSize,f),p=v,m=y),v>=d&&v<=f&&(a&&a===y.type&&(c=!0,i&&n.setNodeMarkup(v,void 0,{...y.attrs,...e})),o&&y.marks.length&&y.marks.forEach(S=>{if(o===S.type&&(c=!0,i)){const N=Math.max(v,d),T=Math.min(v+y.nodeSize,f);n.addMark(N,T,o.create({...S.attrs,...e}))}}))}),m&&(p!==void 0&&i&&n.setNodeMarkup(p,void 0,{...m.attrs,...e}),o&&m.marks.length&&m.marks.forEach(y=>{o===y.type&&i&&n.addMark(x,b,o.create({...y.attrs,...e}))}))}),c},aGe=(t,e={})=>({state:n,dispatch:r})=>{const i=Gi(t,n.schema);return F6e(i,e)(n,r)},sGe=(t,e={})=>({state:n,dispatch:r})=>{const i=Gi(t,n.schema);return I6e(i,e)(n,r)},oGe=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={}}},O2=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},lGe=(t,e)=>{if(RL(e))return e.exec(t);const n=e(t);if(!n)return null;const r=[n.text];return r.index=n.index,r.input=t,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(n.replaceWith)),r};function n1(t){var e;const{editor:n,from:r,to:i,text:a,rules:o,plugin:l}=t,{view:c}=n;if(c.composing)return!1;const u=c.state.doc.resolve(r);if(u.parent.type.spec.code||(e=u.nodeBefore||u.nodeAfter)!=null&&e.marks.find(p=>p.type.spec.code))return!1;let d=!1;const f=LVe(u)+a;return o.forEach(p=>{if(d)return;const m=lGe(f,p.find);if(!m)return;const x=c.state.tr,b=C2({state:c.state,transaction:x}),y={from:r-(m[0].length-a.length),to:i},{commands:v,chain:S,can:N}=new j2({editor:n,state:b});p.handler({state:b,range:y,match:m,commands:v,chain:S,can:N})===null||!x.steps.length||(p.undoable&&x.setMeta(l,{transform:x,from:r,to:i,text:a}),c.dispatch(x),d=!0)}),d}function cGe(t){const{editor:e,rules:n}=t,r=new ui({state:{init(){return null},apply(i,a,o){const l=i.getMeta(r);if(l)return l;const c=i.getMeta("applyInputRules");return!!c&&setTimeout(()=>{let{text:d}=c;typeof d=="string"?d=d:d=IL(kt.from(d),o.schema);const{from:f}=c,p=f+d.length;n1({editor:e,from:f,to:p,text:d,rules:n,plugin:r})}),i.selectionSet||i.docChanged?null:a}},props:{handleTextInput(i,a,o,l){return n1({editor:e,from:a,to:o,text:l,rules:n,plugin:r})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:a}=i.state.selection;a&&n1({editor:e,from:a.pos,to:a.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(i,a){if(a.key!=="Enter")return!1;const{$cursor:o}=i.state.selection;return o?n1({editor:e,from:o.pos,to:o.pos,text:`
- `,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function uGe(t){return Object.prototype.toString.call(t).slice(8,-1)}function r1(t){return uGe(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function hne(t,e){const n={...t};return r1(t)&&r1(e)&&Object.keys(e).forEach(r=>{r1(e[r])&&r1(t[r])?n[r]=hne(t[r],e[r]):n[r]=e[r]}),n}var BL=class{constructor(t={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...t},this.name=this.config.name}get options(){return{...xr(Xt(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...xr(Xt(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>hne(this.options,t)});return e.name=this.name,e.parent=this.parent,e}extend(t={}){const e=new this.constructor({...this.config,...t});return e.parent=this,this.child=e,e.name="name"in t?t.name:e.parent.name,e}},Hh=class fne extends BL{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new fne(n)}static handleExit({editor:e,mark:n}){const{tr:r}=e.state,i=e.state.selection.$from;if(i.pos===i.end()){const o=i.marks();if(!!!o.find(u=>u?.type.name===n.name))return!1;const c=o.find(u=>u?.type.name===n.name);return c&&r.removeStoredMark(c),r.insertText(" ",i.pos),e.view.dispatch(r),!0}return!1}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function dGe(t){return typeof t=="number"}var hGe=class{constructor(t){this.find=t.find,this.handler=t.handler}},fGe=(t,e,n)=>{if(RL(e))return[...t.matchAll(e)];const r=e(t,n);return r?r.map(i=>{const a=[i.text];return a.index=i.index,a.input=t,a.data=i.data,i.replaceWith&&(i.text.includes(i.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),a.push(i.replaceWith)),a}):[]};function mGe(t){const{editor:e,state:n,from:r,to:i,rule:a,pasteEvent:o,dropEvent:l}=t,{commands:c,chain:u,can:d}=new j2({editor:e,state:n}),f=[];return n.doc.nodesBetween(r,i,(m,x)=>{var b,y,v,S,N;if((y=(b=m.type)==null?void 0:b.spec)!=null&&y.code||!(m.isText||m.isTextblock||m.isInline))return;const T=(N=(S=(v=m.content)==null?void 0:v.size)!=null?S:m.nodeSize)!=null?N:0,k=Math.max(r,x),C=Math.min(i,x+T);if(k>=C)return;const E=m.isText?m.text||"":m.textBetween(k-x,C-x,void 0,"");fGe(E,a.find,o).forEach(A=>{if(A.index===void 0)return;const R=k+A.index+1,U=R+A[0].length,F={from:n.tr.mapping.map(R),to:n.tr.mapping.map(U)},$=a.handler({state:n,range:F,match:A,commands:c,chain:u,can:d,pasteEvent:o,dropEvent:l});f.push($)})}),f.every(m=>m!==null)}var i1=null,pGe=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function gGe(t){const{editor:e,rules:n}=t;let r=null,i=!1,a=!1,o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,l;try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}const c=({state:d,from:f,to:p,rule:m,pasteEvt:x})=>{const b=d.tr,y=C2({state:d,transaction:b});if(!(!mGe({editor:e,state:y,from:Math.max(f-1,0),to:p.b-1,rule:m,pasteEvent:x,dropEvent:l})||!b.steps.length)){try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}return o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,b}};return n.map(d=>new ui({view(f){const p=x=>{var b;r=(b=f.dom.parentElement)!=null&&b.contains(x.target)?f.dom.parentElement:null,r&&(i1=e)},m=()=>{i1&&(i1=null)};return window.addEventListener("dragstart",p),window.addEventListener("dragend",m),{destroy(){window.removeEventListener("dragstart",p),window.removeEventListener("dragend",m)}}},props:{handleDOMEvents:{drop:(f,p)=>{if(a=r===f.dom.parentElement,l=p,!a){const m=i1;m?.isEditable&&setTimeout(()=>{const x=m.state.selection;x&&m.commands.deleteRange({from:x.from,to:x.to})},10)}return!1},paste:(f,p)=>{var m;const x=(m=p.clipboardData)==null?void 0:m.getData("text/html");return o=p,i=!!x?.includes("data-pm-slice"),!1}}},appendTransaction:(f,p,m)=>{const x=f[0],b=x.getMeta("uiEvent")==="paste"&&!i,y=x.getMeta("uiEvent")==="drop"&&!a,v=x.getMeta("applyPasteRules"),S=!!v;if(!b&&!y&&!S)return;if(S){let{text:k}=v;typeof k=="string"?k=k:k=IL(kt.from(k),m.schema);const{from:C}=v,E=C+k.length,D=pGe(k);return c({rule:d,state:m,from:C,to:{b:E},pasteEvt:D})}const N=p.doc.content.findDiffStart(m.doc.content),T=p.doc.content.findDiffEnd(m.doc.content);if(!(!dGe(N)||!T||N===T.b))return c({rule:d,state:m,from:N,to:T,pasteEvt:o})}}))}var L2=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=sne(t),this.schema=AVe(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:Nj(e.name,this.schema)},r=Xt(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return UL([...this.extensions].reverse()).flatMap(r=>{const i={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:Nj(r.name,this.schema)},a=[],o=Xt(r,"addKeyboardShortcuts",i);let l={};if(r.type==="mark"&&Xt(r,"exitable",i)&&(l.ArrowRight=()=>Hh.handleExit({editor:t,mark:r})),o){const p=Object.fromEntries(Object.entries(o()).map(([m,x])=>[m,()=>x({editor:t})]));l={...l,...p}}const c=P$e(l);a.push(c);const u=Xt(r,"addInputRules",i);if(R9(r,t.options.enableInputRules)&&u){const p=u();if(p&&p.length){const m=cGe({editor:t,rules:p}),x=Array.isArray(m)?m:[m];a.push(...x)}}const d=Xt(r,"addPasteRules",i);if(R9(r,t.options.enablePasteRules)&&d){const p=d();if(p&&p.length){const m=gGe({editor:t,rules:p});a.push(...m)}}const f=Xt(r,"addProseMirrorPlugins",i);if(f){const p=f();a.push(...p)}return a})}get attributes(){return ane(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=dx(this.extensions);return Object.fromEntries(e.filter(n=>!!Xt(n,"addNodeView")).map(n=>{const r=this.attributes.filter(c=>c.type===n.name),i={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:Gi(n.name,this.schema)},a=Xt(n,"addNodeView",i);if(!a)return[];const o=a();if(!o)return[];const l=(c,u,d,f,p)=>{const m=yM(c,r);return o({node:c,view:u,getPos:d,decorations:f,innerDecorations:p,editor:t,extension:n,HTMLAttributes:m})};return[n.name,l]}))}get markViews(){const{editor:t}=this,{markExtensions:e}=dx(this.extensions);return Object.fromEntries(e.filter(n=>!!Xt(n,"addMarkView")).map(n=>{const r=this.attributes.filter(l=>l.type===n.name),i={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:Yu(n.name,this.schema)},a=Xt(n,"addMarkView",i);if(!a)return[];const o=(l,c,u)=>{const d=yM(l,r);return a()({mark:l,view:c,inline:u,editor:t,extension:n,HTMLAttributes:d,updateAttributes:f=>{jGe(l,t,f)}})};return[n.name,o]}))}setupExtensions(){const t=this.extensions;this.editor.extensionStorage=Object.fromEntries(t.map(e=>[e.name,e.storage])),t.forEach(e=>{var n;const r={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:Nj(e.name,this.schema)};e.type==="mark"&&((n=xr(Xt(e,"keepOnSplit",r)))==null||n)&&this.splittableMarks.push(e.name);const i=Xt(e,"onBeforeCreate",r),a=Xt(e,"onCreate",r),o=Xt(e,"onUpdate",r),l=Xt(e,"onSelectionUpdate",r),c=Xt(e,"onTransaction",r),u=Xt(e,"onFocus",r),d=Xt(e,"onBlur",r),f=Xt(e,"onDestroy",r);i&&this.editor.on("beforeCreate",i),a&&this.editor.on("create",a),o&&this.editor.on("update",o),l&&this.editor.on("selectionUpdate",l),c&&this.editor.on("transaction",c),u&&this.editor.on("focus",u),d&&this.editor.on("blur",d),f&&this.editor.on("destroy",f)})}};L2.resolve=sne;L2.sort=UL;L2.flatten=FL;var xGe={};DL(xGe,{ClipboardTextSerializer:()=>pne,Commands:()=>gne,Delete:()=>xne,Drop:()=>bne,Editable:()=>yne,FocusEvents:()=>wne,Keymap:()=>_ne,Paste:()=>Sne,Tabindex:()=>Mne,TextDirection:()=>Nne,focusEventsPluginKey:()=>vne});var jr=class mne extends BL{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new mne(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},pne=jr.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new ui({key:new oa("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:i}=e,{ranges:a}=i,o=Math.min(...a.map(d=>d.$from.pos)),l=Math.max(...a.map(d=>d.$to.pos)),c=lne(n);return one(r,{from:o,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:c})}}})]}}),gne=jr.create({name:"commands",addCommands(){return{...Yte}}}),xne=jr.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,r,i;const a=()=>{var o,l,c,u;if((u=(c=(l=(o=this.editor.options.coreExtensionOptions)==null?void 0:o.delete)==null?void 0:l.filterTransaction)==null?void 0:c.call(l,t))!=null?u:t.getMeta("y-sync$"))return;const d=rne(t.before,[t,...e]);une(d).forEach(m=>{d.mapping.mapResult(m.oldRange.from).deletedAfter&&d.mapping.mapResult(m.oldRange.to).deletedBefore&&d.before.nodesBetween(m.oldRange.from,m.oldRange.to,(x,b)=>{const y=b+x.nodeSize-2,v=m.oldRange.from<=b&&y<=m.oldRange.to;this.editor.emit("delete",{type:"node",node:x,from:b,to:y,newFrom:d.mapping.map(b),newTo:d.mapping.map(y),deletedRange:m.oldRange,newRange:m.newRange,partial:!v,editor:this.editor,transaction:t,combinedTransform:d})})});const p=d.mapping;d.steps.forEach((m,x)=>{var b,y;if(m instanceof Rl){const v=p.slice(x).map(m.from,-1),S=p.slice(x).map(m.to),N=p.invert().map(v,-1),T=p.invert().map(S),k=(b=d.doc.nodeAt(v-1))==null?void 0:b.marks.some(E=>E.eq(m.mark)),C=(y=d.doc.nodeAt(S))==null?void 0:y.marks.some(E=>E.eq(m.mark));this.editor.emit("delete",{type:"mark",mark:m.mark,from:m.from,to:m.to,deletedRange:{from:N,to:T},newRange:{from:v,to:S},partial:!!(C||k),editor:this.editor,transaction:t,combinedTransform:d})}})};(i=(r=(n=this.editor.options.coreExtensionOptions)==null?void 0:n.delete)==null?void 0:r.async)==null||i?setTimeout(a,0):a()}}),bne=jr.create({name:"drop",addProseMirrorPlugins(){return[new ui({key:new oa("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),yne=jr.create({name:"editable",addProseMirrorPlugins(){return[new ui({key:new oa("editable"),props:{editable:()=>this.editor.options.editable}})]}}),vne=new oa("focusEvents"),wne=jr.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new ui({key:vne,props:{handleDOMEvents:{focus:(e,n)=>{t.isFocused=!0;const r=t.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,n)=>{t.isFocused=!1;const r=t.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),_ne=jr.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:o})=>[()=>o.undoInputRule(),()=>o.command(({tr:l})=>{const{selection:c,doc:u}=l,{empty:d,$anchor:f}=c,{pos:p,parent:m}=f,x=f.parent.isTextblock&&p>0?l.doc.resolve(p-1):f,b=x.parent.type.spec.isolating,y=f.pos-f.parentOffset,v=b&&x.parent.childCount===1?y===f.pos:An.atStart(u).from===p;return!d||!m.type.isTextblock||m.textContent.length||!v||v&&f.parent.type.name==="paragraph"?!1:o.clearNodes()}),()=>o.deleteSelection(),()=>o.joinBackward(),()=>o.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:o})=>[()=>o.deleteSelection(),()=>o.deleteCurrentNode(),()=>o.joinForward(),()=>o.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:o})=>[()=>o.newlineInCode(),()=>o.createParagraphNear(),()=>o.liftEmptyBlock(),()=>o.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},i={...r},a={...r,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return LL()||tne()?a:i},addProseMirrorPlugins(){return[new ui({key:new oa("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(b=>b.getMeta("composition")))return;const r=t.some(b=>b.docChanged)&&!e.doc.eq(n.doc),i=t.some(b=>b.getMeta("preventClearDocument"));if(!r||i)return;const{empty:a,from:o,to:l}=e.selection,c=An.atStart(e.doc).from,u=An.atEnd(e.doc).to;if(a||!(o===c&&l===u)||!R2(n.doc))return;const p=n.tr,m=C2({state:n,transaction:p}),{commands:x}=new j2({editor:this.editor,state:m});if(x.clearNodes(),!!p.steps.length)return p}})]}}),Sne=jr.create({name:"paste",addProseMirrorPlugins(){return[new ui({key:new oa("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),Mne=jr.create({name:"tabindex",addProseMirrorPlugins(){return[new ui({key:new oa("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),Nne=jr.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=dx(this.extensions);return[{types:t.filter(e=>e.name!=="text").map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{const n=e.getAttribute("dir");return n&&(n==="ltr"||n==="rtl"||n==="auto")?n:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new ui({key:new oa("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),bGe=class ug{constructor(e,n,r=!1,i=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=n,this.currentNode=i}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!=null?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let n=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}n=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:n,to:r},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),n=this.resolvedPos.doc.resolve(e);return new ug(n,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new ug(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new ug(e,this.editor)}get children(){const e=[];return this.node.content.forEach((n,r)=>{const i=n.isBlock&&!n.isTextblock,a=n.isAtom&&!n.isText,o=this.pos+r+(a?0:1);if(o<0||o>this.resolvedPos.doc.nodeSize-2)return;const l=this.resolvedPos.doc.resolve(o);if(!i&&l.depth<=this.depth)return;const c=new ug(l,this.editor,i,i?n:null);i&&(c.actualDepth=this.depth+1),e.push(new ug(l,this.editor,i,i?n:null))}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,n={}){let r=null,i=this.parent;for(;i&&!r;){if(i.node.type.name===e)if(Object.keys(n).length>0){const a=i.node.attrs,o=Object.keys(n);for(let l=0;l<o.length;l+=1){const c=o[l];if(a[c]!==n[c])break}}else r=i;i=i.parent}return r}querySelector(e,n={}){return this.querySelectorAll(e,n,!0)[0]||null}querySelectorAll(e,n={},r=!1){let i=[];if(!this.children||this.children.length===0)return i;const a=Object.keys(n);return this.children.forEach(o=>{r&&i.length>0||(o.node.type.name===e&&a.every(c=>n[c]===o.node.attrs[c])&&i.push(o),!(r&&i.length>0)&&(i=i.concat(o.querySelectorAll(e,n,r))))}),i}setAttribute(e){const{tr:n}=this.editor.state;n.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(n)}},yGe=`.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 vGe(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 wGe=class extends oGe{constructor(t={}){super(),this.css=null,this.className="tiptap",this.editorView=null,this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.options={element:typeof document<"u"?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:r})=>{throw r},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(t),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("mount",this.options.onMount),this.on("unmount",this.options.onUnmount),this.on("contentError",this.options.onContentError),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:r,slice:i,moved:a})=>this.options.onDrop(r,i,a)),this.on("paste",({event:r,slice:i})=>this.options.onPaste(r,i)),this.on("delete",this.options.onDelete);const e=this.createDoc(),n=Jte(e,this.options.autofocus);this.editorState=vg.create({doc:e,schema:this.schema,selection:n||void 0}),this.options.element&&this.mount(this.options.element)}mount(t){if(typeof document>"u")throw new Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");this.createView(t),this.emit("mount",{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(()=>{this.isDestroyed||(this.options.autofocus!==!1&&this.options.autofocus!==null&&this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){const t=this.editorView.dom;t?.editor&&delete t.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{typeof this.css.remove=="function"?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(t){console.warn("Failed to remove CSS element:",t)}this.css=null,this.emit("unmount",{editor:this})}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&typeof document<"u"&&(this.css=vGe(yGe,this.options.injectNonce))}setOptions(t={}){this.options={...this.options,...t},!(!this.editorView||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(t,e=!0){this.setOptions({editable:t}),e&&this.emit("update",{editor:this,transaction:this.state.tr,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:t=>{this.editorState=t},dispatch:t=>{this.dispatchTransaction(t)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(t,e)=>{if(this.editorView)return this.editorView[e];if(e==="state")return this.editorState;if(e in t)return Reflect.get(t,e);throw new Error(`[tiptap error]: The editor view is not available. Cannot access view['${e}']. The editor may not be mounted yet.`)}})}get state(){return this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(t,e){const n=ine(e)?e(t,[...this.state.plugins]):[...this.state.plugins,t],r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}unregisterPlugin(t){if(this.isDestroyed)return;const e=this.state.plugins;let n=e;if([].concat(t).forEach(i=>{const a=typeof i=="string"?`${i}$`:i.key;n=n.filter(o=>!o.key.startsWith(a))}),e.length===n.length)return;const r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}createExtensionManager(){var t,e;const r=[...this.options.enableCoreExtensions?[yne,pne.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),gne,wne,_ne,Mne,bne,Sne,xne,Nne.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 L2(r,this)}createCommandManager(){this.commandManager=new j2({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=$D(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=$D(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return t}createView(t){var e;this.editorView=new Kte(t,{...this.options.editorProps,attributes:{role:"textbox",...(e=this.options.editorProps)==null?void 0:e.attributes},dispatchTransaction:this.dispatchTransaction.bind(this),state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});const n=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(n),this.prependClass(),this.injectCSS();const r=this.view.dom;r.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(t){this.isCapturingTransaction=!0,t(),this.isCapturingTransaction=!1;const e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(t){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=t;return}t.steps.forEach(u=>{var d;return(d=this.capturedTransaction)==null?void 0:d.step(u)});return}const{state:e,transactions:n}=this.state.applyTransaction(t),r=!this.state.selection.eq(e.selection),i=n.includes(t),a=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:t,nextState:e}),!i)return;this.view.updateState(e),this.emit("transaction",{editor:this,transaction:t,appendedTransactions:n.slice(1)}),r&&this.emit("selectionUpdate",{editor:this,transaction:t});const o=n.findLast(u=>u.getMeta("focus")||u.getMeta("blur")),l=o?.getMeta("focus"),c=o?.getMeta("blur");l&&this.emit("focus",{editor:this,event:l.event,transaction:o}),c&&this.emit("blur",{editor:this,event:c.event,transaction:o}),!(t.getMeta("preventUpdate")||!n.some(u=>u.docChanged)||a.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:t,appendedTransactions:n.slice(1)})}getAttributes(t){return cne(this.state,t)}isActive(t,e){const n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return FVe(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return IL(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=`
- `,textSerializers:n={}}=t||{};return jVe(this.state.doc,{blockSeparator:e,textSerializers:{...lne(this.schema),...n}})}get isEmpty(){return R2(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 bGe(e,this)}get $doc(){return this.$pos(0)}};function hx(t){return new O2({find:t.find,handler:({state:e,range:n,match:r})=>{const i=xr(t.getAttributes,void 0,r);if(i===!1||i===null)return null;const{tr:a}=e,o=r[r.length-1],l=r[0];if(o){const c=l.search(/\S/),u=n.from+l.indexOf(o),d=u+o.length;if(zL(n.from,n.to,e.doc).filter(m=>m.mark.type.excluded.find(b=>b===t.type&&b!==m.mark.type)).filter(m=>m.to>u).length)return null;d<n.to&&a.delete(d,n.to),u>n.from&&a.delete(n.from+c,u);const p=n.from+c+o.length;a.addMark(n.from+c,p,t.type.create(i||{})),a.removeStoredMark(t.type)}},undoable:t.undoable})}function kne(t){return new O2({find:t.find,handler:({state:e,range:n,match:r})=>{const i=xr(t.getAttributes,void 0,r)||{},{tr:a}=e,o=n.from;let l=n.to;const c=t.type.create(i);if(r[1]){const u=r[0].lastIndexOf(r[1]);let d=o+u;d>l?d=l:l=d+r[1].length;const f=r[0][r[0].length-1];a.insertText(f,o+r[0].length-1),a.replaceWith(d,l,c)}else if(r[0]){const u=t.type.isInline?o:o-1;a.insert(u,t.type.create(i)).delete(a.mapping.map(o),a.mapping.map(l))}a.scrollIntoView()},undoable:t.undoable})}function GD(t){return new O2({find:t.find,handler:({state:e,range:n,match:r})=>{const i=e.doc.resolve(n.from),a=xr(t.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,a)},undoable:t.undoable})}function fx(t){return new O2({find:t.find,handler:({state:e,range:n,match:r,chain:i})=>{const a=xr(t.getAttributes,void 0,r)||{},o=e.tr.delete(n.from,n.to),c=o.doc.resolve(n.from).blockRange(),u=c&&xL(c,t.type,a);if(!u)return null;if(o.wrap(c,u),t.keepMarks&&t.editor){const{selection:f,storedMarks:p}=e,{splittableMarks:m}=t.editor.extensionManager,x=p||f.$to.parentOffset&&f.$from.marks();if(x){const b=x.filter(y=>m.includes(y.type.name));o.ensureMarks(b)}}if(t.keepAttributes){const f=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";i().updateAttributes(f,a).run()}const d=o.doc.resolve(n.from-1).nodeBefore;d&&d.type===t.type&&zh(o.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,d))&&o.join(n.from-1)},undoable:t.undoable})}var _Ge=t=>"touches"in t,SGe=class{constructor(t){this.directions=["bottom-left","bottom-right","top-left","top-right"],this.minSize={height:8,width:8},this.preserveAspectRatio=!1,this.classNames={container:"",wrapper:"",handle:"",resizing:""},this.initialWidth=0,this.initialHeight=0,this.aspectRatio=1,this.isResizing=!1,this.activeHandle=null,this.startX=0,this.startY=0,this.startWidth=0,this.startHeight=0,this.isShiftKeyPressed=!1,this.handleMouseMove=o=>{if(!this.isResizing||!this.activeHandle)return;const l=o.clientX-this.startX,c=o.clientY-this.startY;this.handleResize(l,c)},this.handleTouchMove=o=>{if(!this.isResizing||!this.activeHandle)return;const l=o.touches[0];if(!l)return;const c=l.clientX-this.startX,u=l.clientY-this.startY;this.handleResize(c,u)},this.handleMouseUp=()=>{if(!this.isResizing)return;const o=this.element.offsetWidth,l=this.element.offsetHeight;this.onCommit(o,l),this.isResizing=!1,this.activeHandle=null,this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp)},this.handleKeyDown=o=>{o.key==="Shift"&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=o=>{o.key==="Shift"&&(this.isShiftKeyPressed=!1)};var e,n,r,i,a;this.node=t.node,this.element=t.element,this.contentElement=t.contentElement,this.getPos=t.getPos,this.onResize=t.onResize,this.onCommit=t.onCommit,this.onUpdate=t.onUpdate,(e=t.options)!=null&&e.min&&(this.minSize={...this.minSize,...t.options.min}),(n=t.options)!=null&&n.max&&(this.maxSize=t.options.max),(r=t?.options)!=null&&r.directions&&(this.directions=t.options.directions),(i=t.options)!=null&&i.preserveAspectRatio&&(this.preserveAspectRatio=t.options.preserveAspectRatio),(a=t.options)!=null&&a.className&&(this.classNames={container:t.options.className.container||"",wrapper:t.options.className.wrapper||"",handle:t.options.className.handle||"",resizing:t.options.className.resizing||""}),this.wrapper=this.createWrapper(),this.container=this.createContainer(),this.applyInitialSize(),this.attachHandles()}get dom(){return this.container}get contentDOM(){return this.contentElement}update(t,e,n){return t.type!==this.node.type?!1:(this.node=t,this.onUpdate?this.onUpdate(t,e,n):!0)}destroy(){this.isResizing&&(this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp),this.isResizing=!1,this.activeHandle=null),this.container.remove()}createContainer(){const t=document.createElement("div");return t.dataset.resizeContainer="",t.dataset.node=this.node.type.name,t.style.display="flex",t.style.justifyContent="flex-start",t.style.alignItems="flex-start",this.classNames.container&&(t.className=this.classNames.container),t.appendChild(this.wrapper),t}createWrapper(){const t=document.createElement("div");return t.style.position="relative",t.style.display="block",t.dataset.resizeWrapper="",this.classNames.wrapper&&(t.className=this.classNames.wrapper),t.appendChild(this.element),t}createHandle(t){const e=document.createElement("div");return e.dataset.resizeHandle=t,e.style.position="absolute",this.classNames.handle&&(e.className=this.classNames.handle),e}positionHandle(t,e){const n=e.includes("top"),r=e.includes("bottom"),i=e.includes("left"),a=e.includes("right");n&&(t.style.top="0"),r&&(t.style.bottom="0"),i&&(t.style.left="0"),a&&(t.style.right="0"),(e==="top"||e==="bottom")&&(t.style.left="0",t.style.right="0"),(e==="left"||e==="right")&&(t.style.top="0",t.style.bottom="0")}attachHandles(){this.directions.forEach(t=>{const e=this.createHandle(t);this.positionHandle(e,t),e.addEventListener("mousedown",n=>this.handleResizeStart(n,t)),e.addEventListener("touchstart",n=>this.handleResizeStart(n,t)),this.wrapper.appendChild(e)})}applyInitialSize(){const t=this.node.attrs.width,e=this.node.attrs.height;t?(this.element.style.width=`${t}px`,this.initialWidth=t):this.initialWidth=this.element.offsetWidth,e?(this.element.style.height=`${e}px`,this.initialHeight=e):this.initialHeight=this.element.offsetHeight,this.initialWidth>0&&this.initialHeight>0&&(this.aspectRatio=this.initialWidth/this.initialHeight)}handleResizeStart(t,e){t.preventDefault(),t.stopPropagation(),this.isResizing=!0,this.activeHandle=e,_Ge(t)?(this.startX=t.touches[0].clientX,this.startY=t.touches[0].clientY):(this.startX=t.clientX,this.startY=t.clientY),this.startWidth=this.element.offsetWidth,this.startHeight=this.element.offsetHeight,this.startWidth>0&&this.startHeight>0&&(this.aspectRatio=this.startWidth/this.startHeight),this.getPos(),this.container.dataset.resizeState="true",this.classNames.resizing&&this.container.classList.add(this.classNames.resizing),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("touchmove",this.handleTouchMove),document.addEventListener("mouseup",this.handleMouseUp),document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keyup",this.handleKeyUp)}handleResize(t,e){if(!this.activeHandle)return;const n=this.preserveAspectRatio||this.isShiftKeyPressed,{width:r,height:i}=this.calculateNewDimensions(this.activeHandle,t,e),a=this.applyConstraints(r,i,n);this.element.style.width=`${a.width}px`,this.element.style.height=`${a.height}px`,this.onResize&&this.onResize(a.width,a.height)}calculateNewDimensions(t,e,n){let r=this.startWidth,i=this.startHeight;const a=t.includes("right"),o=t.includes("left"),l=t.includes("bottom"),c=t.includes("top");return a?r=this.startWidth+e:o&&(r=this.startWidth-e),l?i=this.startHeight+n:c&&(i=this.startHeight-n),(t==="right"||t==="left")&&(r=this.startWidth+(a?e:-e)),(t==="top"||t==="bottom")&&(i=this.startHeight+(l?n:-n)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(r,i,t):{width:r,height:i}}applyConstraints(t,e,n){var r,i,a,o;if(!n){let u=Math.max(this.minSize.width,t),d=Math.max(this.minSize.height,e);return(r=this.maxSize)!=null&&r.width&&(u=Math.min(this.maxSize.width,u)),(i=this.maxSize)!=null&&i.height&&(d=Math.min(this.maxSize.height,d)),{width:u,height:d}}let l=t,c=e;return l<this.minSize.width&&(l=this.minSize.width,c=l/this.aspectRatio),c<this.minSize.height&&(c=this.minSize.height,l=c*this.aspectRatio),(a=this.maxSize)!=null&&a.width&&l>this.maxSize.width&&(l=this.maxSize.width,c=l/this.aspectRatio),(o=this.maxSize)!=null&&o.height&&c>this.maxSize.height&&(c=this.maxSize.height,l=c*this.aspectRatio),{width:l,height:c}}applyAspectRatio(t,e,n){const r=n==="left"||n==="right",i=n==="top"||n==="bottom";return r?{width:t,height:t/this.aspectRatio}:i?{width:e*this.aspectRatio,height:e}:{width:t,height:t/this.aspectRatio}}};function MGe(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof Qt){const a=r.index();return r.parent.canReplaceWith(a,a+1,e)}let i=r.depth;for(;i>=0;){const a=r.index(i);if(r.node(i).contentMatchAt(a).matchType(e))return!0;i-=1}return!1}var NGe={};DL(NGe,{createAtomBlockMarkdownSpec:()=>kGe,createBlockMarkdownSpec:()=>EGe,createInlineMarkdownSpec:()=>CGe,parseAttributes:()=>HL,parseIndentedBlocks:()=>qD,renderNestedMarkdownContent:()=>VL,serializeAttributes:()=>$L});function HL(t){if(!t?.trim())return{};const e={},n=[],r=t.replace(/["']([^"']*)["']/g,u=>(n.push(u),`__QUOTED_${n.length-1}__`)),i=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(i){const u=i.map(d=>d.trim().slice(1));e.class=u.join(" ")}const a=r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);a&&(e.id=a[1]);const o=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(r.matchAll(o)).forEach(([,u,d])=>{var f;const p=parseInt(((f=d.match(/__QUOTED_(\d+)__/))==null?void 0:f[1])||"0",10),m=n[p];m&&(e[u]=m.slice(1,-1))});const c=r.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,"").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();return c&&c.split(/\s+/).filter(Boolean).forEach(d=>{d.match(/^[a-zA-Z][\w-]*$/)&&(e[d]=!0)}),e}function $L(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 kGe(t){const{nodeName:e,name:n,parseAttributes:r=HL,serializeAttributes:i=$L,defaultAttributes:a={},requiredAttributes:o=[],allowedAttributes:l}=t,c=n||e,u=d=>{if(!l)return d;const f={};return l.forEach(p=>{p in d&&(f[p]=d[p])}),f};return{parseMarkdown:(d,f)=>{const p={...a,...d.attributes};return f.createNode(e,p,[])},markdownTokenizer:{name:e,level:"block",start(d){var f;const p=new RegExp(`^:::${c}(?:\\s|$)`,"m"),m=(f=d.match(p))==null?void 0:f.index;return m!==void 0?m:-1},tokenize(d,f,p){const m=new RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),x=d.match(m);if(!x)return;const b=x[1]||"",y=r(b);if(!o.find(S=>!(S in y)))return{type:e,raw:x[0],attributes:y}}},renderMarkdown:d=>{const f=u(d.attrs||{}),p=i(f),m=p?` {${p}}`:"";return`:::${c}${m} :::`}}}function EGe(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=HL,serializeAttributes:a=$L,defaultAttributes:o={},content:l="block",allowedAttributes:c}=t,u=n||e,d=f=>{if(!c)return f;const p={};return c.forEach(m=>{m in f&&(p[m]=f[m])}),p};return{parseMarkdown:(f,p)=>{let m;if(r){const b=r(f);m=typeof b=="string"?[{type:"text",text:b}]:b}else l==="block"?m=p.parseChildren(f.tokens||[]):m=p.parseInline(f.tokens||[]);const x={...o,...f.attributes};return p.createNode(e,x,m)},markdownTokenizer:{name:e,level:"block",start(f){var p;const m=new RegExp(`^:::${u}`,"m"),x=(p=f.match(m))==null?void 0:p.index;return x!==void 0?x:-1},tokenize(f,p,m){var x;const b=new RegExp(`^:::${u}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),y=f.match(b);if(!y)return;const[v,S=""]=y,N=i(S);let T=1;const k=v.length;let C="";const E=/^:::([\w-]*)(\s.*)?/gm,D=f.slice(k);for(E.lastIndex=0;;){const A=E.exec(D);if(A===null)break;const R=A.index,U=A[1];if(!((x=A[2])!=null&&x.endsWith(":::"))){if(U)T+=1;else if(T-=1,T===0){const F=D.slice(0,R);C=F.trim();const $=f.slice(0,k+R+A[0].length);let j=[];if(C)if(l==="block")for(j=m.blockTokens(F),j.forEach(H=>{H.text&&(!H.tokens||H.tokens.length===0)&&(H.tokens=m.inlineTokens(H.text))});j.length>0;){const H=j[j.length-1];if(H.type==="paragraph"&&(!H.text||H.text.trim()===""))j.pop();else break}else j=m.inlineTokens(C);return{type:e,raw:$,attributes:N,content:C,tokens:j}}}}}},renderMarkdown:(f,p)=>{const m=d(f.attrs||{}),x=a(m),b=x?` {${x}}`:"",y=p.renderChildren(f.content||[],`
- `);return`:::${u}${b}
- ${y}
- :::`}}}function TGe(t){if(!t.trim())return{};const e={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=n.exec(t);for(;r!==null;){const[,i,a,o]=r;e[i]=a||o,r=n.exec(t)}return e}function AGe(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function CGe(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=TGe,serializeAttributes:a=AGe,defaultAttributes:o={},selfClosing:l=!1,allowedAttributes:c}=t,u=n||e,d=p=>{if(!c)return p;const m={};return c.forEach(x=>{x in p&&(m[x]=p[x])}),m},f=u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(p,m)=>{const x={...o,...p.attributes};if(l)return m.createNode(e,x);const b=r?r(p):p.content||"";return b?m.createNode(e,x,[m.createTextNode(b)]):m.createNode(e,x,[])},markdownTokenizer:{name:e,level:"inline",start(p){const m=l?new RegExp(`\\[${f}\\s*[^\\]]*\\]`):new RegExp(`\\[${f}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${f}\\]`),x=p.match(m),b=x?.index;return b!==void 0?b:-1},tokenize(p,m,x){const b=l?new RegExp(`^\\[${f}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${f}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${f}\\]`),y=p.match(b);if(!y)return;let v="",S="";if(l){const[,T]=y;S=T}else{const[,T,k]=y;S=T,v=k||""}const N=i(S.trim());return{type:e,raw:y[0],content:v.trim(),attributes:N}}},renderMarkdown:p=>{let m="";r?m=r(p):p.content&&p.content.length>0&&(m=p.content.filter(v=>v.type==="text").map(v=>v.text).join(""));const x=d(p.attrs||{}),b=a(x),y=b?` ${b}`:"";return l?`[${u}${y}]`:`[${u}${y}]${m}[/${u}]`}}}function qD(t,e,n){var r,i,a,o;const l=t.split(`
- `),c=[];let u="",d=0;const f=e.baseIndentSize||2;for(;d<l.length;){const p=l[d],m=p.match(e.itemPattern);if(!m){if(c.length>0)break;if(p.trim()===""){d+=1,u=`${u}${p}
- `;continue}else return}const x=e.extractItemData(m),{indentLevel:b,mainContent:y}=x;u=`${u}${p}
- `;const v=[y];for(d+=1;d<l.length;){const k=l[d];if(k.trim()===""){const E=l.slice(d+1).findIndex(R=>R.trim()!=="");if(E===-1)break;if((((i=(r=l[d+1+E].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:i.length)||0)>b){v.push(k),u=`${u}${k}
- `,d+=1;continue}else break}if((((o=(a=k.match(/^(\s*)/))==null?void 0:a[1])==null?void 0:o.length)||0)>b)v.push(k),u=`${u}${k}
- `,d+=1;else break}let S;const N=v.slice(1);if(N.length>0){const k=N.map(C=>C.slice(b+f)).join(`
- `);k.trim()&&(e.customNestedParser?S=e.customNestedParser(k):S=n.blockTokens(k))}const T=e.createToken(x,S);c.push(T)}if(c.length!==0)return{items:c,raw:u}}function VL(t,e,n,r){if(!t||!Array.isArray(t.content))return"";const i=typeof n=="function"?n(r):n,[a,...o]=t.content,l=e.renderChildren([a]),c=[`${i}${l}`];return o&&o.length>0&&o.forEach(u=>{const d=e.renderChildren([u]);if(d){const f=d.split(`
- `).map(p=>p?e.indent(p):"").join(`
- `);c.push(f)}}),c.join(`
- `)}function jGe(t,e,n={}){const{state:r}=e,{doc:i,tr:a}=r,o=t;i.descendants((l,c)=>{const u=a.mapping.map(c),d=a.mapping.map(c)+l.nodeSize;let f=null;if(l.marks.forEach(m=>{if(m!==o)return!1;f=m}),!f)return;let p=!1;if(Object.keys(n).forEach(m=>{n[m]!==f.attrs[m]&&(p=!0)}),p){const m=t.type.create({...t.attrs,...n});a.removeMark(u,d,t.type),a.addMark(u,d,m)}}),a.docChanged&&e.view.dispatch(a)}var Gs=class Ene extends BL{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new Ene(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function Nm(t){return new hGe({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:i})=>{const a=xr(t.getAttributes,void 0,r,i);if(a===!1||a===null)return null;const{tr:o}=e,l=r[r.length-1],c=r[0];let u=n.to;if(l){const d=c.search(/\S/),f=n.from+c.indexOf(l),p=f+l.length;if(zL(n.from,n.to,e.doc).filter(x=>x.mark.type.excluded.find(y=>y===t.type&&y!==x.mark.type)).filter(x=>x.to>f).length)return null;p<n.to&&o.delete(p,n.to),f>n.from&&o.delete(n.from+d,f),u=n.from+d+l.length,o.addMark(n.from+d,u,t.type.create(a||{})),o.removeStoredMark(t.type)}}})}var Tj,F9;function PGe(){return F9||(F9=1,Tj=function t(e,n){if(e===n)return!0;if(e&&n&&typeof e=="object"&&typeof n=="object"){if(e.constructor!==n.constructor)return!1;var r,i,a;if(Array.isArray(e)){if(r=e.length,r!=n.length)return!1;for(i=r;i--!==0;)if(!t(e[i],n[i]))return!1;return!0}if(e instanceof Map&&n instanceof Map){if(e.size!==n.size)return!1;for(i of e.entries())if(!n.has(i[0]))return!1;for(i of e.entries())if(!t(i[1],n.get(i[0])))return!1;return!0}if(e instanceof Set&&n instanceof Set){if(e.size!==n.size)return!1;for(i of e.entries())if(!n.has(i[0]))return!1;return!0}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(n)){if(r=e.length,r!=n.length)return!1;for(i=r;i--!==0;)if(e[i]!==n[i])return!1;return!0}if(e.constructor===RegExp)return e.source===n.source&&e.flags===n.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===n.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===n.toString();if(a=Object.keys(e),r=a.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,a[i]))return!1;for(i=r;i--!==0;){var o=a[i];if(!(o==="_owner"&&e.$$typeof)&&!t(e[o],n[o]))return!1}return!0}return e!==e&&n!==n}),Tj}var DGe=PGe();const RGe=hl(DGe);var OGe=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},LGe=({contentComponent:t})=>{const e=fR.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return s.jsx(s.Fragment,{children:Object.values(e)})};function FGe(){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]:_le.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 IGe=class extends Jr.Component{constructor(t){var e;super(t),this.editorContentRef=Jr.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:!!((e=t.editor)!=null&&e.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){const t=this.props.editor;if(t&&!t.isDestroyed&&t.options.element){if(t.contentComponent)return;const e=this.editorContentRef.current;e.append(t.view.dom),t.setOptions({element:e}),t.contentComponent=FGe(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=t.contentComponent.subscribe(()=>{this.setState(n=>n.hasContentComponentInitialized?n:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),t.createNodeViews(),this.initialized=!0}}componentWillUnmount(){var t;const e=this.props.editor;if(e){this.initialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),e.contentComponent=null;try{if(!((t=e.view.dom)!=null&&t.firstChild))return;const n=document.createElement("div");n.append(e.view.dom),e.setOptions({element:n})}catch{}}}render(){const{editor:t,innerRef:e,...n}=this.props;return s.jsxs(s.Fragment,{children:[s.jsx("div",{ref:OGe(e,this.editorContentRef),...n}),t?.contentComponent&&s.jsx(LGe,{contentComponent:t.contentComponent})]})}},UGe=_.forwardRef((t,e)=>{const n=Jr.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return Jr.createElement(IGe,{key:n,innerRef:e,...t})}),zGe=Jr.memo(UGe),BGe=typeof window<"u"?_.useLayoutEffect:_.useEffect,HGe=class{constructor(t){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=t,this.lastSnapshot={editor:t,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(t){return this.subscribers.add(t),()=>{this.subscribers.delete(t)}}watch(t){if(this.editor=t,this.editor){const e=()=>{this.transactionNumber+=1,this.subscribers.forEach(r=>r())},n=this.editor;return n.on("transaction",e),()=>{n.off("transaction",e)}}}};function $Ge(t){var e;const[n]=_.useState(()=>new HGe(t.editor)),r=xK.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:RGe);return BGe(()=>n.watch(t.editor),[t.editor,n]),_.useDebugValue(r),r}var VGe=!1,WD=typeof window>"u",GGe=WD||!!(typeof window<"u"&&window.next),qGe=class Tne{constructor(e){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=e,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(e){this.editor=e,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(n=>n())}getInitialEditor(){return this.options.current.immediatelyRender===void 0?WD||GGe?null:this.createEditor():(this.options.current.immediatelyRender,this.options.current.immediatelyRender?this.createEditor():null)}createEditor(){const e={...this.options.current,onBeforeCreate:(...r)=>{var i,a;return(a=(i=this.options.current).onBeforeCreate)==null?void 0:a.call(i,...r)},onBlur:(...r)=>{var i,a;return(a=(i=this.options.current).onBlur)==null?void 0:a.call(i,...r)},onCreate:(...r)=>{var i,a;return(a=(i=this.options.current).onCreate)==null?void 0:a.call(i,...r)},onDestroy:(...r)=>{var i,a;return(a=(i=this.options.current).onDestroy)==null?void 0:a.call(i,...r)},onFocus:(...r)=>{var i,a;return(a=(i=this.options.current).onFocus)==null?void 0:a.call(i,...r)},onSelectionUpdate:(...r)=>{var i,a;return(a=(i=this.options.current).onSelectionUpdate)==null?void 0:a.call(i,...r)},onTransaction:(...r)=>{var i,a;return(a=(i=this.options.current).onTransaction)==null?void 0:a.call(i,...r)},onUpdate:(...r)=>{var i,a;return(a=(i=this.options.current).onUpdate)==null?void 0:a.call(i,...r)},onContentError:(...r)=>{var i,a;return(a=(i=this.options.current).onContentError)==null?void 0:a.call(i,...r)},onDrop:(...r)=>{var i,a;return(a=(i=this.options.current).onDrop)==null?void 0:a.call(i,...r)},onPaste:(...r)=>{var i,a;return(a=(i=this.options.current).onPaste)==null?void 0:a.call(i,...r)},onDelete:(...r)=>{var i,a;return(a=(i=this.options.current).onDelete)==null?void 0:a.call(i,...r)}};return new wGe(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,n){return Object.keys(e).every(r=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(r)?!0:r==="extensions"&&e.extensions&&n.extensions?e.extensions.length!==n.extensions.length?!1:e.extensions.every((i,a)=>{var o;return i===((o=n.extensions)==null?void 0:o[a])}):e[r]===n[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?Tne.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(e),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(e){if(this.editor&&!this.editor.isDestroyed){if(this.previousDeps===null){this.previousDeps=e;return}if(this.previousDeps.length===e.length&&this.previousDeps.every((r,i)=>r===e[i]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){const e=this.instanceId,n=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){n&&n.setOptions(this.options.current);return}n&&!n.isDestroyed&&(n.destroy(),this.instanceId===e&&this.setEditor(null))},1)}};function WGe(t={},e=[]){const n=_.useRef(t);n.current=t;const[r]=_.useState(()=>new qGe(n)),i=fR.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return _.useDebugValue(i),_.useEffect(r.onRender(e)),$Ge({editor:i,selector:({transactionNumber:a})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&a===0?0:a+1}),i}var KGe=_.createContext({editor:null});KGe.Consumer;var XGe=_.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),YGe=()=>_.useContext(XGe);Jr.forwardRef((t,e)=>{const{onDragStart:n}=YGe(),r=t.as||"div";return s.jsx(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});Jr.createContext({markViewContentRef:()=>{}});var vM=(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]},QGe=/^\s*>\s$/,ZGe=Gs.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return vM("blockquote",{...vi(this.options.HTMLAttributes,t),children:vM("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[fx({find:QGe,type:this.type})]}}),JGe=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,e7e=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,t7e=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,n7e=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,r7e=Hh.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 vM("strong",{...vi(this.options.HTMLAttributes,t),children:vM("slot",{})})},markdownTokenName:"strong",parseMarkdown:(t,e)=>e.applyMark("bold",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`**${e.renderChildren(t)}**`,addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[hx({find:JGe,type:this.type}),hx({find:t7e,type:this.type})]},addPasteRules(){return[Nm({find:e7e,type:this.type}),Nm({find:n7e,type:this.type})]}}),i7e=/(^|[^`])`([^`]+)`(?!`)$/,a7e=/(^|[^`])`([^`]+)`(?!`)/g,s7e=Hh.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",vi(this.options.HTMLAttributes,t),0]},markdownTokenName:"codespan",parseMarkdown:(t,e)=>e.applyMark("code",[{type:"text",text:t.text||""}]),renderMarkdown:(t,e)=>t.content?`\`${e.renderChildren(t.content)}\``:"",addCommands(){return{setCode:()=>({commands:t})=>t.setMark(this.name),toggleCode:()=>({commands:t})=>t.toggleMark(this.name),unsetCode:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[hx({find:i7e,type:this.type})]},addPasteRules(){return[Nm({find:a7e,type:this.type})]}}),Aj=4,o7e=/^```([a-z]+)?[\s\n]$/,l7e=/^~~~([a-z]+)?[\s\n]$/,c7e=Gs.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:Aj,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:t=>{var e;const{languageClassPrefix:n}=this.options;if(!n)return null;const a=[...((e=t.firstElementChild)==null?void 0:e.classList)||[]].filter(o=>o.startsWith(n)).map(o=>o.replace(n,""))[0];return a||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",vi(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(t,e)=>{var n;return((n=t.raw)==null?void 0:n.startsWith("```"))===!1&&t.codeBlockStyle!=="indented"?[]:e.createNode("codeBlock",{language:t.lang||null},t.text?[e.createTextNode(t.text)]:[])},renderMarkdown:(t,e)=>{var n;let r="";const i=((n=t.attrs)==null?void 0:n.language)||"";return t.content?r=[`\`\`\`${i}`,e.renderChildren(t.content),"```"].join(`
- `):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:Aj,{state:r}=t,{selection:i}=r,{$from:a,empty:o}=i;if(a.parent.type!==this.type)return!1;const l=" ".repeat(n);return o?t.commands.insertContent(l):t.commands.command(({tr:c})=>{const{from:u,to:d}=i,m=r.doc.textBetween(u,d,`
- `,`
- `).split(`
- `).map(x=>l+x).join(`
- `);return c.replaceWith(u,d,r.schema.text(m)),!0})},"Shift-Tab":({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:Aj,{state:r}=t,{selection:i}=r,{$from:a,empty:o}=i;return a.parent.type!==this.type?!1:o?t.commands.command(({tr:l})=>{var c;const{pos:u}=a,d=a.start(),f=a.end(),m=r.doc.textBetween(d,f,`
- `,`
- `).split(`
- `);let x=0,b=0;const y=u-d;for(let C=0;C<m.length;C+=1){if(b+m[C].length>=y){x=C;break}b+=m[C].length+1}const S=((c=m[x].match(/^ */))==null?void 0:c[0])||"",N=Math.min(S.length,n);if(N===0)return!0;let T=d;for(let C=0;C<x;C+=1)T+=m[C].length+1;return l.delete(T,T+N),u-T<=N&&l.setSelection(mn.create(l.doc,T)),!0}):t.commands.command(({tr:l})=>{const{from:c,to:u}=i,p=r.doc.textBetween(c,u,`
- `,`
- `).split(`
- `).map(m=>{var x;const b=((x=m.match(/^ */))==null?void 0:x[0])||"",y=Math.min(b.length,n);return m.slice(y)}).join(`
- `);return l.replaceWith(c,u,r.schema.text(p)),!0})},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=t,{selection:n}=e,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type)return!1;const a=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(`
- `);return!a||!o?!1:t.chain().command(({tr:l})=>(l.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=t,{selection:n,doc:r}=e,{$from:i,empty:a}=n;if(!a||i.parent.type!==this.type||!(i.parentOffset===i.parent.nodeSize-2))return!1;const l=i.after();return l===void 0?!1:r.nodeAt(l)?t.commands.command(({tr:u})=>(u.setSelection(An.near(r.resolve(l))),!0)):t.commands.exitCode()}}},addInputRules(){return[GD({find:o7e,type:this.type,getAttributes:t=>({language:t[1]})}),GD({find:l7e,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new ui({key:new oa("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const n=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),i=r?JSON.parse(r):void 0,a=i?.mode;if(!n||!a)return!1;const{tr:o,schema:l}=t.state,c=l.text(n.replace(/\r\n?/g,`
- `));return o.replaceSelectionWith(this.type.create({language:a},c)),o.selection.$from.parent.type!==this.type&&o.setSelection(mn.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),t.dispatch(o),!0}}})]}}),u7e=Gs.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
- `):""}),d7e=Gs.create({name:"hardBreak",markdownTokenName:"br",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:t}){return["br",vi(this.options.HTMLAttributes,t)]},renderText(){return`
- `},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:a}=n;if(i.$from.parent.type.spec.isolating)return!1;const{keepMarks:o}=this.options,{splittableMarks:l}=r.extensionManager,c=a||i.$to.parentOffset&&i.$from.marks();return e().insertContent({type:this.name}).command(({tr:u,dispatch:d})=>{if(d&&c&&o){const f=c.filter(p=>l.includes(p.type.name));u.ensureMarks(f)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),h7e=Gs.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(t=>({tag:`h${t}`,attrs:{level:t}}))},renderHTML({node:t,HTMLAttributes:e}){return[`h${this.options.levels.includes(t.attrs.level)?t.attrs.level:this.options.levels[0]}`,vi(this.options.HTMLAttributes,e),0]},parseMarkdown:(t,e)=>e.createNode("heading",{level:t.depth||1},e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>{var n;const r=(n=t.attrs)!=null&&n.level?parseInt(t.attrs.level,10):1,i="#".repeat(r);return t.content?`${i} ${e.renderChildren(t.content)}`:""},addCommands(){return{setHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.setNode(this.name,t):!1,toggleHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.toggleNode(this.name,"paragraph",t):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((t,e)=>({...t,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(t=>GD({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),f7e=Gs.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",vi(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!MGe(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,i=t();return dne(n)?i.insertContentAt(r.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({state:a,tr:o,dispatch:l})=>{if(l){const{$to:c}=o.selection,u=c.end();if(c.nodeAfter)c.nodeAfter.isTextblock?o.setSelection(mn.create(o.doc,c.pos+1)):c.nodeAfter.isBlock?o.setSelection(Qt.create(o.doc,c.pos)):o.setSelection(mn.create(o.doc,c.pos));else{const d=a.schema.nodes[this.options.nextNodeType]||c.parent.type.contentMatch.defaultType,f=d?.create();f&&(o.insert(u,f),o.setSelection(mn.create(o.doc,u+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[kne({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),m7e=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,p7e=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,g7e=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,x7e=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,b7e=Hh.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:t=>t.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",vi(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(t,e)=>e.applyMark("italic",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`*${e.renderChildren(t)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[hx({find:m7e,type:this.type}),hx({find:g7e,type:this.type})]},addPasteRules(){return[Nm({find:p7e,type:this.type}),Nm({find:x7e,type:this.type})]}});const y7e="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",v7e="ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2",KD="numeric",XD="ascii",YD="alpha",j0="asciinumeric",m0="alphanumeric",QD="domain",Ane="emoji",w7e="scheme",_7e="slashscheme",Cj="whitespace";function S7e(t,e){return t in e||(e[t]=[]),e[t]}function Uf(t,e,n){e[KD]&&(e[j0]=!0,e[m0]=!0),e[XD]&&(e[j0]=!0,e[YD]=!0),e[j0]&&(e[m0]=!0),e[YD]&&(e[m0]=!0),e[m0]&&(e[QD]=!0),e[Ane]&&(e[QD]=!0);for(const r in e){const i=S7e(r,n);i.indexOf(t)<0&&i.push(t)}}function M7e(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function Os(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}Os.groups={};Os.prototype={accepts(){return!!this.t},go(t){const e=this,n=e.j[t];if(n)return n;for(let r=0;r<e.jr.length;r++){const i=e.jr[r][0],a=e.jr[r][1];if(a&&i.test(t))return a}return e.jd},has(t,e=!1){return e?t in this.j:!!this.go(t)},ta(t,e,n,r){for(let i=0;i<t.length;i++)this.tt(t[i],e,n,r)},tr(t,e,n,r){r=r||Os.groups;let i;return e&&e.j?i=e:(i=new Os(e),n&&r&&Uf(e,n,r)),this.jr.push([t,i]),i},ts(t,e,n,r){let i=this;const a=t.length;if(!a)return i;for(let o=0;o<a-1;o++)i=i.tt(t[o]);return i.tt(t[a-1],e,n,r)},tt(t,e,n,r){r=r||Os.groups;const i=this;if(e&&e.j)return i.j[t]=e,e;const a=e;let o,l=i.go(t);if(l?(o=new Os,Object.assign(o.j,l.j),o.jr.push.apply(o.jr,l.jr),o.jd=l.jd,o.t=l.t):o=new Os,a){if(r)if(o.t&&typeof o.t=="string"){const c=Object.assign(M7e(o.t,r),n);Uf(a,c,r)}else n&&Uf(a,n,r);o.t=a}return i.j[t]=o,o}};const Nn=(t,e,n,r,i)=>t.ta(e,n,r,i),fi=(t,e,n,r,i)=>t.tr(e,n,r,i),I9=(t,e,n,r,i)=>t.ts(e,n,r,i),Ct=(t,e,n,r,i)=>t.tt(e,n,r,i),cu="WORD",ZD="UWORD",Cne="ASCIINUMERICAL",jne="ALPHANUMERICAL",Ay="LOCALHOST",JD="TLD",eR="UTLD",L1="SCHEME",dg="SLASH_SCHEME",GL="NUM",tR="WS",qL="NL",P0="OPENBRACE",D0="CLOSEBRACE",wM="OPENBRACKET",_M="CLOSEBRACKET",SM="OPENPAREN",MM="CLOSEPAREN",NM="OPENANGLEBRACKET",kM="CLOSEANGLEBRACKET",EM="FULLWIDTHLEFTPAREN",TM="FULLWIDTHRIGHTPAREN",AM="LEFTCORNERBRACKET",CM="RIGHTCORNERBRACKET",jM="LEFTWHITECORNERBRACKET",PM="RIGHTWHITECORNERBRACKET",DM="FULLWIDTHLESSTHAN",RM="FULLWIDTHGREATERTHAN",OM="AMPERSAND",LM="APOSTROPHE",FM="ASTERISK",Vd="AT",IM="BACKSLASH",UM="BACKTICK",zM="CARET",Yd="COLON",WL="COMMA",BM="DOLLAR",Jl="DOT",HM="EQUALS",KL="EXCLAMATION",Bo="HYPHEN",R0="PERCENT",$M="PIPE",VM="PLUS",GM="POUND",O0="QUERY",XL="QUOTE",Pne="FULLWIDTHMIDDLEDOT",YL="SEMI",ec="SLASH",L0="TILDE",qM="UNDERSCORE",Dne="EMOJI",WM="SYM";var Rne=Object.freeze({__proto__:null,ALPHANUMERICAL:jne,AMPERSAND:OM,APOSTROPHE:LM,ASCIINUMERICAL:Cne,ASTERISK:FM,AT:Vd,BACKSLASH:IM,BACKTICK:UM,CARET:zM,CLOSEANGLEBRACKET:kM,CLOSEBRACE:D0,CLOSEBRACKET:_M,CLOSEPAREN:MM,COLON:Yd,COMMA:WL,DOLLAR:BM,DOT:Jl,EMOJI:Dne,EQUALS:HM,EXCLAMATION:KL,FULLWIDTHGREATERTHAN:RM,FULLWIDTHLEFTPAREN:EM,FULLWIDTHLESSTHAN:DM,FULLWIDTHMIDDLEDOT:Pne,FULLWIDTHRIGHTPAREN:TM,HYPHEN:Bo,LEFTCORNERBRACKET:AM,LEFTWHITECORNERBRACKET:jM,LOCALHOST:Ay,NL:qL,NUM:GL,OPENANGLEBRACKET:NM,OPENBRACE:P0,OPENBRACKET:wM,OPENPAREN:SM,PERCENT:R0,PIPE:$M,PLUS:VM,POUND:GM,QUERY:O0,QUOTE:XL,RIGHTCORNERBRACKET:CM,RIGHTWHITECORNERBRACKET:PM,SCHEME:L1,SEMI:YL,SLASH:ec,SLASH_SCHEME:dg,SYM:WM,TILDE:L0,TLD:JD,UNDERSCORE:qM,UTLD:eR,UWORD:ZD,WORD:cu,WS:tR});const iu=/[a-z]/,e0=new RegExp("\\p{L}","u"),jj=new RegExp("\\p{Emoji}","u"),au=/\d/,Pj=/\s/,U9="\r",Dj=`
- `,N7e="️",k7e="",Rj="";let a1=null,s1=null;function E7e(t=[]){const e={};Os.groups=e;const n=new Os;a1==null&&(a1=z9(y7e)),s1==null&&(s1=z9(v7e)),Ct(n,"'",LM),Ct(n,"{",P0),Ct(n,"}",D0),Ct(n,"[",wM),Ct(n,"]",_M),Ct(n,"(",SM),Ct(n,")",MM),Ct(n,"<",NM),Ct(n,">",kM),Ct(n,"(",EM),Ct(n,")",TM),Ct(n,"「",AM),Ct(n,"」",CM),Ct(n,"『",jM),Ct(n,"』",PM),Ct(n,"<",DM),Ct(n,">",RM),Ct(n,"&",OM),Ct(n,"*",FM),Ct(n,"@",Vd),Ct(n,"`",UM),Ct(n,"^",zM),Ct(n,":",Yd),Ct(n,",",WL),Ct(n,"$",BM),Ct(n,".",Jl),Ct(n,"=",HM),Ct(n,"!",KL),Ct(n,"-",Bo),Ct(n,"%",R0),Ct(n,"|",$M),Ct(n,"+",VM),Ct(n,"#",GM),Ct(n,"?",O0),Ct(n,'"',XL),Ct(n,"/",ec),Ct(n,";",YL),Ct(n,"~",L0),Ct(n,"_",qM),Ct(n,"\\",IM),Ct(n,"・",Pne);const r=fi(n,au,GL,{[KD]:!0});fi(r,au,r);const i=fi(r,iu,Cne,{[j0]:!0}),a=fi(r,e0,jne,{[m0]:!0}),o=fi(n,iu,cu,{[XD]:!0});fi(o,au,i),fi(o,iu,o),fi(i,au,i),fi(i,iu,i);const l=fi(n,e0,ZD,{[YD]:!0});fi(l,iu),fi(l,au,a),fi(l,e0,l),fi(a,au,a),fi(a,iu),fi(a,e0,a);const c=Ct(n,Dj,qL,{[Cj]:!0}),u=Ct(n,U9,tR,{[Cj]:!0}),d=fi(n,Pj,tR,{[Cj]:!0});Ct(n,Rj,d),Ct(u,Dj,c),Ct(u,Rj,d),fi(u,Pj,d),Ct(d,U9),Ct(d,Dj),fi(d,Pj,d),Ct(d,Rj,d);const f=fi(n,jj,Dne,{[Ane]:!0});Ct(f,"#"),fi(f,jj,f),Ct(f,N7e,f);const p=Ct(f,k7e);Ct(p,"#"),fi(p,jj,f);const m=[[iu,o],[au,i]],x=[[iu,null],[e0,l],[au,a]];for(let b=0;b<a1.length;b++)Ld(n,a1[b],JD,cu,m);for(let b=0;b<s1.length;b++)Ld(n,s1[b],eR,ZD,x);Uf(JD,{tld:!0,ascii:!0},e),Uf(eR,{utld:!0,alpha:!0},e),Ld(n,"file",L1,cu,m),Ld(n,"mailto",L1,cu,m),Ld(n,"http",dg,cu,m),Ld(n,"https",dg,cu,m),Ld(n,"ftp",dg,cu,m),Ld(n,"ftps",dg,cu,m),Uf(L1,{scheme:!0,ascii:!0},e),Uf(dg,{slashscheme:!0,ascii:!0},e),t=t.sort((b,y)=>b[0]>y[0]?1:-1);for(let b=0;b<t.length;b++){const y=t[b][0],S=t[b][1]?{[w7e]:!0}:{[_7e]:!0};y.indexOf("-")>=0?S[QD]=!0:iu.test(y)?au.test(y)?S[j0]=!0:S[XD]=!0:S[KD]=!0,I9(n,y,y,S)}return I9(n,"localhost",Ay,{ascii:!0}),n.jd=new Os(WM),{start:n,tokens:Object.assign({groups:e},Rne)}}function One(t,e){const n=T7e(e.replace(/[A-Z]/g,l=>l.toLowerCase())),r=n.length,i=[];let a=0,o=0;for(;o<r;){let l=t,c=null,u=0,d=null,f=-1,p=-1;for(;o<r&&(c=l.go(n[o]));)l=c,l.accepts()?(f=0,p=0,d=l):f>=0&&(f+=n[o].length,p++),u+=n[o].length,a+=n[o].length,o++;a-=f,o-=p,u-=f,i.push({t:d.t,v:e.slice(a-u,a),s:a-u,e:a})}return i}function T7e(t){const e=[],n=t.length;let r=0;for(;r<n;){let i=t.charCodeAt(r),a,o=i<55296||i>56319||r+1===n||(a=t.charCodeAt(r+1))<56320||a>57343?t[r]:t.slice(r,r+2);e.push(o),r+=o.length}return e}function Ld(t,e,n,r,i){let a;const o=e.length;for(let l=0;l<o-1;l++){const c=e[l];t.j[c]?a=t.j[c]:(a=new Os(r),a.jr=i.slice(),t.j[c]=a),t=a}return a=new Os(n),a.jr=i.slice(),t.j[e[o-1]]=a,a}function z9(t){const e=[],n=[];let r=0,i="0123456789";for(;r<t.length;){let a=0;for(;i.indexOf(t[r+a])>=0;)a++;if(a>0){e.push(n.join(""));for(let o=parseInt(t.substring(r,r+a),10);o>0;o--)n.pop();r+=a}else n.push(t[r]),r++}return e}const Cy={defaultProtocol:"http",events:null,format:B9,formatHref:B9,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function QL(t,e=null){let n=Object.assign({},Cy);t&&(n=Object.assign(n,t instanceof QL?t.o:t));const r=n.ignoreTags,i=[];for(let a=0;a<r.length;a++)i.push(r[a].toUpperCase());this.o=n,e&&(this.defaultRender=e),this.ignoreTags=i}QL.prototype={o:Cy,ignoreTags:[],defaultRender(t){return t},check(t){return this.get("validate",t.toString(),t)},get(t,e,n){const r=e!=null;let i=this.o[t];return i&&(typeof i=="object"?(i=n.t in i?i[n.t]:Cy[t],typeof i=="function"&&r&&(i=i(e,n))):typeof i=="function"&&r&&(i=i(e,n.t,n)),i)},getObj(t,e,n){let r=this.o[t];return typeof r=="function"&&e!=null&&(r=r(e,n.t,n)),r},render(t){const e=t.render(this);return(this.get("render",null,t)||this.defaultRender)(e,t.t,t)}};function B9(t){return t}function Lne(t,e){this.t="token",this.v=t,this.tk=e}Lne.prototype={isLink:!1,toString(){return this.v},toHref(t){return this.toString()},toFormattedString(t){const e=this.toString(),n=t.get("truncate",e,this),r=t.get("format",e,this);return n&&r.length>n?r.substring(0,n)+"…":r},toFormattedHref(t){return t.get("formatHref",this.toHref(t.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(t=Cy.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){const e=this,n=this.toHref(t.get("defaultProtocol")),r=t.get("formatHref",n,this),i=t.get("tagName",n,e),a=this.toFormattedString(t),o={},l=t.get("className",n,e),c=t.get("target",n,e),u=t.get("rel",n,e),d=t.getObj("attributes",n,e),f=t.getObj("events",n,e);return o.href=r,l&&(o.class=l),c&&(o.target=c),u&&(o.rel=u),d&&Object.assign(o,d),{tagName:i,attributes:o,content:a,eventListeners:f}}};function F2(t,e){class n extends Lne{constructor(i,a){super(i,a),this.t=t}}for(const r in e)n.prototype[r]=e[r];return n.t=t,n}const H9=F2("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),$9=F2("text"),A7e=F2("nl"),o1=F2("url",{isLink:!0,toHref(t=Cy.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==Ay&&t[1].t===Yd}}),Io=t=>new Os(t);function C7e({groups:t}){const e=t.domain.concat([OM,FM,Vd,IM,UM,zM,BM,HM,Bo,GL,R0,$M,VM,GM,ec,WM,L0,qM]),n=[LM,Yd,WL,Jl,KL,R0,O0,XL,YL,NM,kM,P0,D0,_M,wM,SM,MM,EM,TM,AM,CM,jM,PM,DM,RM],r=[OM,LM,FM,IM,UM,zM,BM,HM,Bo,P0,D0,R0,$M,VM,GM,O0,ec,WM,L0,qM],i=Io(),a=Ct(i,L0);Nn(a,r,a),Nn(a,t.domain,a);const o=Io(),l=Io(),c=Io();Nn(i,t.domain,o),Nn(i,t.scheme,l),Nn(i,t.slashscheme,c),Nn(o,r,a),Nn(o,t.domain,o);const u=Ct(o,Vd);Ct(a,Vd,u),Ct(l,Vd,u),Ct(c,Vd,u);const d=Ct(a,Jl);Nn(d,r,a),Nn(d,t.domain,a);const f=Io();Nn(u,t.domain,f),Nn(f,t.domain,f);const p=Ct(f,Jl);Nn(p,t.domain,f);const m=Io(H9);Nn(p,t.tld,m),Nn(p,t.utld,m),Ct(u,Ay,m);const x=Ct(f,Bo);Ct(x,Bo,x),Nn(x,t.domain,f),Nn(m,t.domain,f),Ct(m,Jl,p),Ct(m,Bo,x);const b=Ct(m,Yd);Nn(b,t.numeric,H9);const y=Ct(o,Bo),v=Ct(o,Jl);Ct(y,Bo,y),Nn(y,t.domain,o),Nn(v,r,a),Nn(v,t.domain,o);const S=Io(o1);Nn(v,t.tld,S),Nn(v,t.utld,S),Nn(S,t.domain,o),Nn(S,r,a),Ct(S,Jl,v),Ct(S,Bo,y),Ct(S,Vd,u);const N=Ct(S,Yd),T=Io(o1);Nn(N,t.numeric,T);const k=Io(o1),C=Io();Nn(k,e,k),Nn(k,n,C),Nn(C,e,k),Nn(C,n,C),Ct(S,ec,k),Ct(T,ec,k);const E=Ct(l,Yd),D=Ct(c,Yd),A=Ct(D,ec),R=Ct(A,ec);Nn(l,t.domain,o),Ct(l,Jl,v),Ct(l,Bo,y),Nn(c,t.domain,o),Ct(c,Jl,v),Ct(c,Bo,y),Nn(E,t.domain,k),Ct(E,ec,k),Ct(E,O0,k),Nn(R,t.domain,k),Nn(R,e,k),Ct(R,ec,k);const U=[[P0,D0],[wM,_M],[SM,MM],[NM,kM],[EM,TM],[AM,CM],[jM,PM],[DM,RM]];for(let F=0;F<U.length;F++){const[$,j]=U[F],H=Ct(k,$);Ct(C,$,H),Ct(H,j,k);const K=Io(o1);Nn(H,e,K);const V=Io();Nn(H,n),Nn(K,e,K),Nn(K,n,V),Nn(V,e,K),Nn(V,n,V),Ct(K,j,k),Ct(V,j,k)}return Ct(i,Ay,S),Ct(i,qL,A7e),{start:i,tokens:Rne}}function j7e(t,e,n){let r=n.length,i=0,a=[],o=[];for(;i<r;){let l=t,c=null,u=null,d=0,f=null,p=-1;for(;i<r&&!(c=l.go(n[i].t));)o.push(n[i++]);for(;i<r&&(u=c||l.go(n[i].t));)c=null,l=u,l.accepts()?(p=0,f=l):p>=0&&p++,i++,d++;if(p<0)i-=d,i<r&&(o.push(n[i]),i++);else{o.length>0&&(a.push(Oj($9,e,o)),o=[]),i-=p,d-=p;const m=f.t,x=n.slice(i-d,i);a.push(Oj(m,e,x))}}return o.length>0&&a.push(Oj($9,e,o)),a}function Oj(t,e,n){const r=n[0].s,i=n[n.length-1].e,a=e.slice(r,i);return new t(a,n)}const P7e=typeof console<"u"&&console&&console.warn||(()=>{}),D7e="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",qr={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function R7e(){return Os.groups={},qr.scanner=null,qr.parser=null,qr.tokenQueue=[],qr.pluginQueue=[],qr.customSchemes=[],qr.initialized=!1,qr}function V9(t,e=!1){if(qr.initialized&&P7e(`linkifyjs: already initialized - will not register custom scheme "${t}" ${D7e}`),!/^[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`);qr.customSchemes.push([t,e])}function O7e(){qr.scanner=E7e(qr.customSchemes);for(let t=0;t<qr.tokenQueue.length;t++)qr.tokenQueue[t][1]({scanner:qr.scanner});qr.parser=C7e(qr.scanner.tokens);for(let t=0;t<qr.pluginQueue.length;t++)qr.pluginQueue[t][1]({scanner:qr.scanner,parser:qr.parser});return qr.initialized=!0,qr}function ZL(t){return qr.initialized||O7e(),j7e(qr.parser.start,t,One(qr.scanner.start,t))}ZL.scan=One;function Fne(t,e=null,n=null){if(e&&typeof e=="object"){if(n)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);n=e,e=null}const r=new QL(n),i=ZL(t),a=[];for(let o=0;o<i.length;o++){const l=i[o];l.isLink&&(!e||l.t===e)&&r.check(l)&&a.push(l.toFormattedObject(r))}return a}var JL="[\0- -\u2029 ]",L7e=new RegExp(JL),F7e=new RegExp(`${JL}$`),I7e=new RegExp(JL,"g");function U7e(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function z7e(t){return new ui({key:new oa("autolink"),appendTransaction:(e,n,r)=>{const i=e.some(u=>u.docChanged)&&!n.doc.eq(r.doc),a=e.some(u=>u.getMeta("preventAutolink"));if(!i||a)return;const{tr:o}=r,l=rne(n.doc,[...e]);if(une(l).forEach(({newRange:u})=>{const d=NVe(r.doc,u,m=>m.isTextblock);let f,p;if(d.length>1)f=d[0],p=r.doc.textBetween(f.pos,f.pos+f.node.nodeSize,void 0," ");else if(d.length){const m=r.doc.textBetween(u.from,u.to," "," ");if(!F7e.test(m))return;f=d[0],p=r.doc.textBetween(f.pos,u.to,void 0," ")}if(f&&p){const m=p.split(L7e).filter(Boolean);if(m.length<=0)return!1;const x=m[m.length-1],b=f.pos+p.lastIndexOf(x);if(!x)return!1;const y=ZL(x).map(v=>v.toObject(t.defaultProtocol));if(!U7e(y))return!1;y.filter(v=>v.isLink).map(v=>({...v,from:b+v.start+1,to:b+v.end+1})).filter(v=>r.schema.marks.code?!r.doc.rangeHasMark(v.from,v.to,r.schema.marks.code):!0).filter(v=>t.validate(v.value)).filter(v=>t.shouldAutoLink(v.value)).forEach(v=>{zL(v.from,v.to,r.doc).some(S=>S.mark.type===t.type)||o.addMark(v.from,v.to,t.type.create({href:v.href}))})}}),!!o.steps.length)return o}})}function B7e(t){return new ui({key:new oa("handleClickLink"),props:{handleClick:(e,n,r)=>{var i,a;if(r.button!==0||!e.editable)return!1;let o=null;if(r.target instanceof HTMLAnchorElement)o=r.target;else{let d=r.target;const f=[];for(;d.nodeName!=="DIV";)f.push(d),d=d.parentNode;o=f.find(p=>p.nodeName==="A")}if(!o)return!1;const l=cne(e.state,t.type.name),c=(i=o?.href)!=null?i:l.href,u=(a=o?.target)!=null?a:l.target;return t.enableClickSelection&&t.editor.commands.extendMarkRange(t.type.name),o&&c?(window.open(c,u),!0):!1}}})}function H7e(t){return new ui({key:new oa("handlePasteLink"),props:{handlePaste:(e,n,r)=>{const{shouldAutoLink:i}=t,{state:a}=e,{selection:o}=a,{empty:l}=o;if(l)return!1;let c="";r.content.forEach(d=>{c+=d.textContent});const u=Fne(c,{defaultProtocol:t.defaultProtocol}).find(d=>d.isLink&&d.value===c);return!c||!u||i!==void 0&&!i(u.href)?!1:t.editor.commands.setMark(t.type,{href:u.href})}}})}function bf(t,e){const n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{const i=typeof r=="string"?r:r.scheme;i&&n.push(i)}),!t||t.replace(I7e,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var Ine=Hh.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(t=>{if(typeof t=="string"){V9(t);return}V9(t.scheme,t.optionalSlashes)})},onDestroy(){R7e()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(t,e)=>!!bf(t,e.protocols),validate:t=>!!t,shouldAutoLink:t=>!!t}},addAttributes(){return{href:{default:null,parseHTML(t){return t.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:"a[href]",getAttrs:t=>{const e=t.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:n=>!!bf(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:t}){return this.options.isAllowedUri(t.href,{defaultValidate:e=>!!bf(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",vi(this.options.HTMLAttributes,t),0]:["a",vi(this.options.HTMLAttributes,{...t,href:""}),0]},markdownTokenName:"link",parseMarkdown:(t,e)=>e.applyMark("link",e.parseInline(t.tokens||[]),{href:t.href,title:t.title||null}),renderMarkdown:(t,e)=>{var n;const r=((n=t.attrs)==null?void 0:n.href)||"";return`[${e.renderChildren(t)}](${r})`},addCommands(){return{setLink:t=>({chain:e})=>{const{href:n}=t;return this.options.isAllowedUri(n,{defaultValidate:r=>!!bf(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,t).setMeta("preventAutolink",!0).run():!1},toggleLink:t=>({chain:e})=>{const{href:n}=t||{};return n&&!this.options.isAllowedUri(n,{defaultValidate:r=>!!bf(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:e().toggleMark(this.name,t,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:t})=>t().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[Nm({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options,i=Fne(t).filter(a=>a.isLink&&this.options.isAllowedUri(a.value,{defaultValidate:o=>!!bf(o,n),protocols:n,defaultProtocol:r}));i.length&&i.forEach(a=>{this.options.shouldAutoLink(a.value)&&e.push({text:a.value,data:{href:a.href},index:a.start})})}return e},type:this.type,getAttributes:t=>{var e;return{href:(e=t.data)==null?void 0:e.href}}})]},addProseMirrorPlugins(){const t=[],{protocols:e,defaultProtocol:n}=this.options;return this.options.autolink&&t.push(z7e({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:i=>!!bf(i,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&t.push(B7e({type:this.type,editor:this.editor,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(H7e({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),$7e=Ine,V7e=Object.defineProperty,G7e=(t,e)=>{for(var n in e)V7e(t,n,{get:e[n],enumerable:!0})},q7e="listItem",G9="textStyle",q9=/^\s*([-+*])\s$/,Une=Gs.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:t}){return["ul",vi(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>t.type!=="list"||t.ordered?[]:{type:"bulletList",content:t.items?e.parseChildren(t.items):[]},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
- `):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(q7e,this.editor.getAttributes(G9)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=fx({find:q9,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=fx({find:q9,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(G9),editor:this.editor})),[t]}}),zne=Gs.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",vi(this.options.HTMLAttributes,t),0]},markdownTokenName:"list_item",parseMarkdown:(t,e)=>{if(t.type!=="list_item")return[];let n=[];if(t.tokens&&t.tokens.length>0)if(t.tokens.some(i=>i.type==="paragraph"))n=e.parseChildren(t.tokens);else{const i=t.tokens[0];if(i&&i.type==="text"&&i.tokens&&i.tokens.length>0){if(n=[{type:"paragraph",content:e.parseInline(i.tokens)}],t.tokens.length>1){const o=t.tokens.slice(1),l=e.parseChildren(o);n.push(...l)}}else n=e.parseChildren(t.tokens)}return n.length===0&&(n=[{type:"paragraph",content:[]}]),{type:"listItem",content:n}},renderMarkdown:(t,e,n)=>VL(t,e,r=>r.parentType==="bulletList"?"- ":r.parentType==="orderedList"?`${r.index+1}. `:"- ",n),addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),W7e={};G7e(W7e,{findListItemPos:()=>yv,getNextListDepth:()=>eF,handleBackspace:()=>nR,handleDelete:()=>rR,hasListBefore:()=>Bne,hasListItemAfter:()=>K7e,hasListItemBefore:()=>Hne,listItemHasSubList:()=>$ne,nextListIsDeeper:()=>Vne,nextListIsHigher:()=>Gne});var yv=(t,e)=>{const{$from:n}=e.selection,r=Gi(t,e.schema);let i=null,a=n.depth,o=n.pos,l=null;for(;a>0&&l===null;)i=n.node(a),i.type===r?l=a:(a-=1,o-=1);return l===null?null:{$pos:e.doc.resolve(o),depth:l}},eF=(t,e)=>{const n=yv(t,e);if(!n)return!1;const[,r]=OVe(e,t,n.$pos.pos+4);return r},Bne=(t,e,n)=>{const{$anchor:r}=t.selection,i=Math.max(0,r.pos-2),a=t.doc.resolve(i).node();return!(!a||!n.includes(a.type.name))},Hne=(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)},$ne=(t,e,n)=>{if(!n)return!1;const r=Gi(t,e.schema);let i=!1;return n.descendants(a=>{a.type===r&&(i=!0)}),i},nR=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!Dh(t.state,e)&&Bne(t.state,e,n)){const{$anchor:l}=t.state.selection,c=t.state.doc.resolve(l.before()-1),u=[];c.node().descendants((p,m)=>{p.type.name===e&&u.push({node:p,pos:m})});const d=u.at(-1);if(!d)return!1;const f=t.state.doc.resolve(c.start()+d.pos+1);return t.chain().cut({from:l.start()-1,to:l.end()+1},f.end()).joinForward().run()}if(!Dh(t.state,e)||!UVe(t.state))return!1;const r=yv(e,t.state);if(!r)return!1;const a=t.state.doc.resolve(r.$pos.pos-2).node(r.depth),o=$ne(e,t.state,a);return Hne(e,t.state)&&!o?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},Vne=(t,e)=>{const n=eF(t,e),r=yv(t,e);return!r||!n?!1:n>r.depth},Gne=(t,e)=>{const n=eF(t,e),r=yv(t,e);return!r||!n?!1:n<r.depth},rR=(t,e)=>{if(!Dh(t.state,e)||!IVe(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:i}=n;return!n.empty&&r.sameParent(i)?!1:Vne(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():Gne(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},K7e=(t,e)=>{var n;const{$anchor:r}=e.selection,i=e.doc.resolve(r.pos-r.parentOffset-2);return!(i.index()===i.parent.childCount-1||((n=i.nodeAfter)==null?void 0:n.type.name)!==t)},qne=jr.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&rR(t,n)&&(e=!0)}),e},"Mod-Delete":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&rR(t,n)&&(e=!0)}),e},Backspace:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&nR(t,n,r)&&(e=!0)}),e},"Mod-Backspace":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&nR(t,n,r)&&(e=!0)}),e}}}}),W9=/^(\s*)(\d+)\.\s+(.*)$/,X7e=/^\s/;function Y7e(t){const e=[];let n=0,r=0;for(;n<t.length;){const i=t[n],a=i.match(W9);if(!a)break;const[,o,l,c]=a,u=o.length;let d=c,f=n+1;const p=[i];for(;f<t.length;){const m=t[f];if(m.match(W9))break;if(m.trim()==="")p.push(m),d+=`
- `,f+=1;else if(m.match(X7e))p.push(m),d+=`
- ${m.slice(u+2)}`,f+=1;else break}e.push({indent:u,number:parseInt(l,10),content:d.trim(),raw:p.join(`
- `)}),r=f,n=f}return[e,r]}function Wne(t,e,n){var r;const i=[];let a=0;for(;a<t.length;){const o=t[a];if(o.indent===e){const l=o.content.split(`
- `),c=((r=l[0])==null?void 0:r.trim())||"",u=[];c&&u.push({type:"paragraph",raw:c,tokens:n.inlineTokens(c)});const d=l.slice(1).join(`
- `).trim();if(d){const m=n.blockTokens(d);u.push(...m)}let f=a+1;const p=[];for(;f<t.length&&t[f].indent>e;)p.push(t[f]),f+=1;if(p.length>0){const m=Math.min(...p.map(b=>b.indent)),x=Wne(p,m,n);u.push({type:"list",ordered:!0,start:p[0].number,items:x,raw:p.map(b=>b.raw).join(`
- `)})}i.push({type:"list_item",raw:o.raw,tokens:u}),a=f}else a+=1}return i}function Q7e(t,e){return t.map(n=>{if(n.type!=="list_item")return e.parseChildren([n])[0];const r=[];return n.tokens&&n.tokens.length>0&&n.tokens.forEach(i=>{if(i.type==="paragraph"||i.type==="list"||i.type==="blockquote"||i.type==="code")r.push(...e.parseChildren([i]));else if(i.type==="text"&&i.tokens){const a=e.parseChildren([i]);r.push({type:"paragraph",content:a})}else{const a=e.parseChildren([i]);a.length>0&&r.push(...a)}}),{type:"listItem",content:r}})}var Z7e="listItem",K9="textStyle",X9=/^(\d+)\.\s$/,Kne=Gs.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1},type:{default:null,parseHTML:t=>t.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:t}){const{start:e,...n}=t;return e===1?["ol",vi(this.options.HTMLAttributes,n),0]:["ol",vi(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>{if(t.type!=="list"||!t.ordered)return[];const n=t.start||1,r=t.items?Q7e(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(`
- `),[a,o]=Y7e(i);if(a.length===0)return;const l=Wne(a,0,n);return l.length===0?void 0:{type:"list",ordered:!0,start:((r=a[0])==null?void 0:r.number)||1,items:l,raw:i.slice(0,o).join(`
- `)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Z7e,this.editor.getAttributes(K9)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=fx({find:X9,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(t=fx({find:X9,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(K9)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),J7e=/^\s*(\[([( |x])?\])\s$/,e9e=Gs.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:t=>{const e=t.getAttribute("data-checked");return e===""||e==="true"},renderHTML:t=>({"data-checked":t.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:t,HTMLAttributes:e}){return["li",vi(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:t.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(t,e)=>{const n=[];if(t.tokens&&t.tokens.length>0?n.push(e.createNode("paragraph",{},e.parseInline(t.tokens))):t.text?n.push(e.createNode("paragraph",{},[e.createNode("text",{text:t.text})])):n.push(e.createNode("paragraph",{},[])),t.nestedTokens&&t.nestedTokens.length>0){const r=e.parseChildren(t.nestedTokens);n.push(...r)}return e.createNode("taskItem",{checked:t.checked||!1},n)},renderMarkdown:(t,e)=>{var n;const i=`- [${(n=t.attrs)!=null&&n.checked?"x":" "}] `;return VL(t,e,i)},addKeyboardShortcuts(){const t={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...t,Tab:()=>this.editor.commands.sinkListItem(this.name)}:t},addNodeView(){return({node:t,HTMLAttributes:e,getPos:n,editor:r})=>{const i=document.createElement("li"),a=document.createElement("label"),o=document.createElement("span"),l=document.createElement("input"),c=document.createElement("div"),u=d=>{var f,p;l.ariaLabel=((p=(f=this.options.a11y)==null?void 0:f.checkboxLabel)==null?void 0:p.call(f,d,l.checked))||`Task item checkbox for ${d.textContent||"empty task item"}`};return u(t),a.contentEditable="false",l.type="checkbox",l.addEventListener("mousedown",d=>d.preventDefault()),l.addEventListener("change",d=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){l.checked=!l.checked;return}const{checked:f}=d.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:p})=>{const m=n();if(typeof m!="number")return!1;const x=p.doc.nodeAt(m);return p.setNodeMarkup(m,void 0,{...x?.attrs,checked:f}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,f)||(l.checked=!l.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([d,f])=>{i.setAttribute(d,f)}),i.dataset.checked=t.attrs.checked,l.checked=t.attrs.checked,a.append(l,o),i.append(a,c),Object.entries(e).forEach(([d,f])=>{i.setAttribute(d,f)}),{dom:i,contentDOM:c,update:d=>d.type!==this.type?!1:(i.dataset.checked=d.attrs.checked,l.checked=d.attrs.checked,u(d),!0)}}},addInputRules(){return[fx({find:J7e,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),t9e=Gs.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:t}){return["ul",vi(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},parseMarkdown:(t,e)=>e.createNode("taskList",{},e.parseChildren(t.items||[])),renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
- `):"",markdownTokenizer:{name:"taskList",level:"block",start(t){var e;const n=(e=t.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:e.index;return n!==void 0?n:-1},tokenize(t,e,n){const r=a=>{const o=qD(a,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:l=>({indentLevel:l[1].length,mainContent:l[4],checked:l[3].toLowerCase()==="x"}),createToken:(l,c)=>({type:"taskItem",raw:"",mainContent:l.mainContent,indentLevel:l.indentLevel,checked:l.checked,text:l.mainContent,tokens:n.inlineTokens(l.mainContent),nestedTokens:c}),customNestedParser:r},n);return o?[{type:"taskList",raw:o.raw,items:o.items}]:n.blockTokens(a)},i=qD(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:a=>({indentLevel:a[1].length,mainContent:a[4],checked:a[3].toLowerCase()==="x"}),createToken:(a,o)=>({type:"taskItem",raw:"",mainContent:a.mainContent,indentLevel:a.indentLevel,checked:a.checked,text:a.mainContent,tokens:n.inlineTokens(a.mainContent),nestedTokens:o}),customNestedParser:r},n);if(i)return{type:"taskList",raw:i.raw,items:i.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});jr.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(Une.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(zne.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(qne.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(Kne.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(e9e.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(t9e.configure(this.options.taskList)),t}});var n9e=Gs.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",vi(this.options.HTMLAttributes,t),0]},parseMarkdown:(t,e)=>{const n=t.tokens||[];return n.length===1&&n[0].type==="image"?e.parseChildren([n[0]]):e.createNode("paragraph",void 0,e.parseInline(n))},renderMarkdown:(t,e)=>!t||!Array.isArray(t.content)?"":e.renderChildren(t.content),addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),r9e=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,i9e=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,a9e=Hh.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["s",vi(this.options.HTMLAttributes,t),0]},markdownTokenName:"del",parseMarkdown:(t,e)=>e.applyMark("strike",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`~~${e.renderChildren(t)}~~`,addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[hx({find:r9e,type:this.type})]},addPasteRules(){return[Nm({find:i9e,type:this.type})]}}),s9e=Gs.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),Xne=Hh.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["u",vi(this.options.HTMLAttributes,t),0]},parseMarkdown(t,e){return e.applyMark(this.name||"underline",e.parseInline(t.tokens||[]))},renderMarkdown(t,e){return`++${e.renderChildren(t)}++`},markdownTokenizer:{name:"underline",level:"inline",start(t){return t.indexOf("++")},tokenize(t,e,n){const i=/^(\+\+)([\s\S]+?)(\+\+)/.exec(t);if(!i)return;const a=i[2].trim();return{type:"underline",raw:i[0],text:a,tokens:n.inlineTokens(a)}}},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),o9e=Xne;function l9e(t={}){return new ui({view(e){return new c9e(e,t)}})}class c9e{constructor(e,n){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(i=>{let a=o=>{this[i](o)};return e.dom.addEventListener(i,a),{name:i,handler:a}})}destroy(){this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){this.cursorPos!=null&&n.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent,r,i=this.editorView.dom,a=i.getBoundingClientRect(),o=a.width/i.offsetWidth,l=a.height/i.offsetHeight;if(n){let f=e.nodeBefore,p=e.nodeAfter;if(f||p){let m=this.editorView.nodeDOM(this.cursorPos-(f?f.nodeSize:0));if(m){let x=m.getBoundingClientRect(),b=f?x.bottom:x.top;f&&p&&(b=(b+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let y=this.width/2*l;r={left:x.left,right:x.right,top:b-y,bottom:b+y}}}}if(!r){let f=this.editorView.coordsAtPos(this.cursorPos),p=this.width/2*o;r={left:f.left-p,right:f.left+p,top:f.top,bottom:f.bottom}}let c=this.editorView.dom.offsetParent;this.element||(this.element=c.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let u,d;if(!c||c==document.body&&getComputedStyle(c).position=="static")u=-pageXOffset,d=-pageYOffset;else{let f=c.getBoundingClientRect(),p=f.width/c.offsetWidth,m=f.height/c.offsetHeight;u=f.left-c.scrollLeft*p,d=f.top-c.scrollTop*m}this.element.style.left=(r.left-u)/o+"px",this.element.style.top=(r.top-d)/l+"px",this.element.style.width=(r.right-r.left)/o+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),i=r&&r.type.spec.disableDropCursor,a=typeof i=="function"?i(this.editorView,n,e):i;if(n&&!a){let o=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=Xee(this.editorView.state.doc,o,this.editorView.dragging.slice);l!=null&&(o=l)}this.setCursor(o),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class gi extends An{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return gi.valid(r)?new gi(r):An.near(r)}content(){return Ut.empty}eq(e){return e instanceof gi&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new gi(e.resolve(n.pos))}getBookmark(){return new tF(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!u9e(e)||!d9e(e))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let i=n.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,n,r=!1){e:for(;;){if(!r&&gi.valid(e))return e;let i=e.pos,a=null;for(let o=e.depth;;o--){let l=e.node(o);if(n>0?e.indexAfter(o)<l.childCount:e.index(o)>0){a=l.child(n>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;i+=n;let c=e.doc.resolve(i);if(gi.valid(c))return c}for(;;){let o=n>0?a.firstChild:a.lastChild;if(!o){if(a.isAtom&&!a.isText&&!Qt.isSelectable(a)){e=e.doc.resolve(i+a.nodeSize*n),r=!1;continue e}break}a=o,i+=n;let l=e.doc.resolve(i);if(gi.valid(l))return l}return null}}}gi.prototype.visible=!1;gi.findFrom=gi.findGapCursorFrom;An.jsonID("gapcursor",gi);class tF{constructor(e){this.pos=e}map(e){return new tF(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return gi.valid(n)?new gi(n):An.near(n)}}function Yne(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function u9e(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),r=t.node(e);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(n-1);;i=i.lastChild){if(i.childCount==0&&!i.inlineContent||Yne(i.type))return!0;if(i.inlineContent)return!1}}return!0}function d9e(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),r=t.node(e);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(n);;i=i.firstChild){if(i.childCount==0&&!i.inlineContent||Yne(i.type))return!0;if(i.inlineContent)return!1}}return!0}function h9e(){return new ui({props:{decorations:g9e,createSelectionBetween(t,e,n){return e.pos==n.pos&&gi.valid(n)?new gi(n):null},handleClick:m9e,handleKeyDown:f9e,handleDOMEvents:{beforeinput:p9e}}})}const f9e=Xte({ArrowLeft:l1("horiz",-1),ArrowRight:l1("horiz",1),ArrowUp:l1("vert",-1),ArrowDown:l1("vert",1)});function l1(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,i,a){let o=r.selection,l=e>0?o.$to:o.$from,c=o.empty;if(o instanceof mn){if(!a.endOfTextblock(n)||l.depth==0)return!1;c=!1,l=r.doc.resolve(e>0?l.after():l.before())}let u=gi.findGapCursorFrom(l,e,c);return u?(i&&i(r.tr.setSelection(new gi(u))),!0):!1}}function m9e(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!gi.valid(r))return!1;let i=t.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&Qt.isSelectable(t.state.doc.nodeAt(i.inside))?!1:(t.dispatch(t.state.tr.setSelection(new gi(r))),!0)}function p9e(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof gi))return!1;let{$from:n}=t.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!r)return!1;let i=kt.empty;for(let o=r.length-1;o>=0;o--)i=kt.from(r[o].createAndFill(null,i));let a=t.state.tr.replace(n.pos,n.pos,new Ut(i,0,0));return a.setSelection(mn.near(a.doc.resolve(n.pos+1))),t.dispatch(a),!1}function g9e(t){if(!(t.selection instanceof gi))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",ai.create(t.doc,[ms.widget(t.selection.head,e,{key:"gapcursor"})])}var KM=200,_a=function(){};_a.prototype.append=function(e){return e.length?(e=_a.from(e),!this.length&&e||e.length<KM&&this.leafAppend(e)||this.length<KM&&e.leafPrepend(this)||this.appendInner(e)):this};_a.prototype.prepend=function(e){return e.length?_a.from(e).append(this):this};_a.prototype.appendInner=function(e){return new x9e(this,e)};_a.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?_a.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};_a.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};_a.prototype.forEach=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length),n<=r?this.forEachInner(e,n,r,0):this.forEachInvertedInner(e,n,r,0)};_a.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(a,o){return i.push(e(a,o))},n,r),i};_a.from=function(e){return e instanceof _a?e:e&&e.length?new Qne(e):_a.empty};var Qne=(function(t){function e(r){t.call(this),this.values=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,a){return i==0&&a==this.length?this:new e(this.values.slice(i,a))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,a,o,l){for(var c=a;c<o;c++)if(i(this.values[c],l+c)===!1)return!1},e.prototype.forEachInvertedInner=function(i,a,o,l){for(var c=a-1;c>=o;c--)if(i(this.values[c],l+c)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=KM)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=KM)return new e(i.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e})(_a);_a.empty=new Qne([]);var x9e=(function(t){function e(n,r){t.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,i,a,o){var l=this.left.length;if(i<l&&this.left.forEachInner(r,i,Math.min(a,l),o)===!1||a>l&&this.right.forEachInner(r,Math.max(i-l,0),Math.min(this.length,a)-l,o+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,i,a,o){var l=this.left.length;if(i>l&&this.right.forEachInvertedInner(r,i-l,Math.max(a,l)-l,o+l)===!1||a<l&&this.left.forEachInvertedInner(r,Math.min(i,l),a,o)===!1)return!1},e.prototype.sliceInner=function(r,i){if(r==0&&i==this.length)return this;var a=this.left.length;return i<=a?this.left.slice(r,i):r>=a?this.right.slice(r-a,i-a):this.left.slice(r,a).append(this.right.slice(0,i-a))},e.prototype.leafAppend=function(r){var i=this.right.leafAppend(r);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(r){var i=this.left.leafPrepend(r);if(i)return new e(i,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(_a);const b9e=500;class jl{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,a;n&&(i=this.remapping(r,this.items.length),a=i.maps.length);let o=e.tr,l,c,u=[],d=[];return this.items.forEach((f,p)=>{if(!f.step){i||(i=this.remapping(r,p+1),a=i.maps.length),a--,d.push(f);return}if(i){d.push(new tc(f.map));let m=f.step.map(i.slice(a)),x;m&&o.maybeStep(m).doc&&(x=o.mapping.maps[o.mapping.maps.length-1],u.push(new tc(x,void 0,void 0,u.length+d.length))),a--,x&&i.appendMap(x,a)}else o.maybeStep(f.step);if(f.selection)return l=i?f.selection.map(i.slice(a)):f.selection,c=new jl(this.items.slice(0,r).append(d.reverse().concat(u)),this.eventCount-1),!1},this.items.length,0),{remaining:c,transform:o,selection:l}}addTransform(e,n,r,i){let a=[],o=this.eventCount,l=this.items,c=!i&&l.length?l.get(l.length-1):null;for(let d=0;d<e.steps.length;d++){let f=e.steps[d].invert(e.docs[d]),p=new tc(e.mapping.maps[d],f,n),m;(m=c&&c.merge(p))&&(p=m,d?a.pop():l=l.slice(0,l.length-1)),a.push(p),n&&(o++,n=void 0),i||(c=p)}let u=o-r.depth;return u>v9e&&(l=y9e(l,u),o-=u),new jl(l.append(a),o)}remapping(e,n){let r=new Sy;return this.items.forEach((i,a)=>{let o=i.mirrorOffset!=null&&a-i.mirrorOffset>=e?r.maps.length-i.mirrorOffset:void 0;r.appendMap(i.map,o)},e,n),r}addMaps(e){return this.eventCount==0?this:new jl(this.items.append(e.map(n=>new tc(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),a=e.mapping,o=e.steps.length,l=this.eventCount;this.items.forEach(p=>{p.selection&&l--},i);let c=n;this.items.forEach(p=>{let m=a.getMirror(--c);if(m==null)return;o=Math.min(o,m);let x=a.maps[m];if(p.step){let b=e.steps[m].invert(e.docs[m]),y=p.selection&&p.selection.map(a.slice(c+1,m));y&&l++,r.push(new tc(x,b,y))}else r.push(new tc(x))},i);let u=[];for(let p=n;p<o;p++)u.push(new tc(a.maps[p]));let d=this.items.slice(0,i).append(u).append(r),f=new jl(d,l);return f.emptyItemCount()>b9e&&(f=f.compress(this.items.length-r.length)),f}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),r=n.maps.length,i=[],a=0;return this.items.forEach((o,l)=>{if(l>=e)i.push(o),o.selection&&a++;else if(o.step){let c=o.step.map(n.slice(r)),u=c&&c.getMap();if(r--,u&&n.appendMap(u,r),c){let d=o.selection&&o.selection.map(n.slice(r));d&&a++;let f=new tc(u.invert(),c,d),p,m=i.length-1;(p=i.length&&i[m].merge(f))?i[m]=p:i.push(f)}}else o.map&&r--},this.items.length,0),new jl(_a.from(i.reverse()),a)}}jl.empty=new jl(_a.empty,0);function y9e(t,e){let n;return t.forEach((r,i)=>{if(r.selection&&e--==0)return n=i,!1}),t.slice(n)}class tc{constructor(e,n,r,i){this.map=e,this.step=n,this.selection=r,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new tc(n.getMap().invert(),n,this.selection)}}}class Gd{constructor(e,n,r,i,a){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=i,this.prevComposition=a}}const v9e=20;function w9e(t,e,n,r){let i=n.getMeta(Jf),a;if(i)return i.historyState;n.getMeta(M9e)&&(t=new Gd(t.done,t.undone,null,0,-1));let o=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(o&&o.getMeta(Jf))return o.getMeta(Jf).redo?new Gd(t.done.addTransform(n,void 0,r,F1(e)),t.undone,Y9(n.mapping.maps),t.prevTime,t.prevComposition):new Gd(t.done,t.undone.addTransform(n,void 0,r,F1(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(o&&o.getMeta("addToHistory")===!1)){let l=n.getMeta("composition"),c=t.prevTime==0||!o&&t.prevComposition!=l&&(t.prevTime<(n.time||0)-r.newGroupDelay||!_9e(n,t.prevRanges)),u=o?Lj(t.prevRanges,n.mapping):Y9(n.mapping.maps);return new Gd(t.done.addTransform(n,c?e.selection.getBookmark():void 0,r,F1(e)),jl.empty,u,n.time,l??t.prevComposition)}else return(a=n.getMeta("rebased"))?new Gd(t.done.rebased(n,a),t.undone.rebased(n,a),Lj(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new Gd(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),Lj(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function _9e(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,i)=>{for(let a=0;a<e.length;a+=2)r<=e[a+1]&&i>=e[a]&&(n=!0)}),n}function Y9(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,i,a,o)=>e.push(a,o));return e}function Lj(t,e){if(!t)return null;let n=[];for(let r=0;r<t.length;r+=2){let i=e.map(t[r],1),a=e.map(t[r+1],-1);i<=a&&n.push(i,a)}return n}function S9e(t,e,n){let r=F1(e),i=Jf.get(e).spec.config,a=(n?t.undone:t.done).popEvent(e,r);if(!a)return null;let o=a.selection.resolve(a.transform.doc),l=(n?t.done:t.undone).addTransform(a.transform,e.selection.getBookmark(),i,r),c=new Gd(n?l:a.remaining,n?a.remaining:l,null,0,-1);return a.transform.setSelection(o).setMeta(Jf,{redo:n,historyState:c})}let Fj=!1,Q9=null;function F1(t){let e=t.plugins;if(Q9!=e){Fj=!1,Q9=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){Fj=!0;break}}return Fj}const Jf=new oa("history"),M9e=new oa("closeHistory");function N9e(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new ui({key:Jf,state:{init(){return new Gd(jl.empty,jl.empty,null,0,-1)},apply(e,n,r){return w9e(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,i=r=="historyUndo"?Jne:r=="historyRedo"?ere:null;return!i||!e.editable?!1:(n.preventDefault(),i(e.state,e.dispatch))}}}})}function Zne(t,e){return(n,r)=>{let i=Jf.getState(n);if(!i||(t?i.undone:i.done).eventCount==0)return!1;if(r){let a=S9e(i,n,t);a&&r(e?a.scrollIntoView():a)}return!0}}const Jne=Zne(!1,!0),ere=Zne(!0,!0);jr.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:t=>t.length,wordCounter:t=>t.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=t=>{const e=t?.node||this.editor.state.doc;if((t?.mode||this.options.mode)==="textSize"){const r=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(r)}return e.nodeSize},this.storage.words=t=>{const e=t?.node||this.editor.state.doc,n=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let t=!1;return[new ui({key:new oa("characterCount"),appendTransaction:(e,n,r)=>{if(t)return;const i=this.options.limit;if(i==null||i===0){t=!0;return}const a=this.storage.characters({node:r.doc});if(a>i){const o=a-i,l=0,c=o;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);const u=r.tr.deleteRange(l,c);return t=!0,u}t=!0},filterTransaction:(e,n)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const i=this.storage.characters({node:n.doc}),a=this.storage.characters({node:e.doc});if(a<=r||i>r&&a>r&&a<=i)return!0;if(i>r&&a>r&&a>i||!e.getMeta("paste"))return!1;const l=e.selection.$head.pos,c=a-r,u=l-c,d=l;return e.deleteRange(u,d),!(this.storage.characters({node:e.doc})>r)}})]}});var k9e=jr.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[l9e(this.options)]}});jr.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new ui({key:new oa("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:i}=e,a=[];if(!n||!r)return ai.create(t,[]);let o=0;this.options.mode==="deepest"&&t.descendants((c,u)=>{if(c.isText)return;if(!(i>=u&&i<=u+c.nodeSize-1))return!1;o+=1});let l=0;return t.descendants((c,u)=>{if(c.isText||!(i>=u&&i<=u+c.nodeSize-1))return!1;if(l+=1,this.options.mode==="deepest"&&o-l>0||this.options.mode==="shallowest"&&l>1)return this.options.mode==="deepest";a.push(ms.node(u,u+c.nodeSize,{class:this.options.className}))}),ai.create(t,a)}}})]}});var E9e=jr.create({name:"gapCursor",addProseMirrorPlugins(){return[h9e()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=xr(Xt(t,"allowGapCursor",n)))!=null?e:null}}});jr.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new ui({key:new oa("placeholder"),props:{decorations:({doc:t,selection:e})=>{const n=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=e,i=[];if(!n)return null;const a=this.editor.isEmpty;return t.descendants((o,l)=>{const c=r>=l&&r<=l+o.nodeSize,u=!o.isLeaf&&R2(o);if((c||!this.options.showOnlyCurrent)&&u){const d=[this.options.emptyNodeClass];a&&d.push(this.options.emptyEditorClass);const f=ms.node(l,l+o.nodeSize,{class:d.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:o,pos:l,hasAnchor:c}):this.options.placeholder});i.push(f)}return this.options.includeChildren}),ai.create(t,i)}}})]}});jr.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new ui({key:new oa("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||dne(n.selection)||t.view.dragging?null:ai.create(n.doc,[ms.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function Z9({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||e?.type===t}var T9e=jr.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new oa(this.name),n=this.options.node||((t=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:t.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,i])=>i).filter(i=>(this.options.notAfter||[]).concat(n).includes(i.name));return[new ui({key:e,appendTransaction:(i,a,o)=>{const{doc:l,tr:c,schema:u}=o,d=e.getState(o),f=l.content.size,p=u.nodes[n];if(d)return c.insert(f,p.create())},state:{init:(i,a)=>{const o=a.tr.doc.lastChild;return!Z9({node:o,types:r})},apply:(i,a)=>{if(!i.docChanged||i.getMeta("__uniqueIDTransaction"))return a;const o=i.doc.lastChild;return!Z9({node:o,types:r})}}})]}}),A9e=jr.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>Jne(t,e),redo:()=>({state:t,dispatch:e})=>ere(t,e)}},addProseMirrorPlugins(){return[N9e(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),C9e=jr.create({name:"starterKit",addExtensions(){var t,e,n,r;const i=[];return this.options.bold!==!1&&i.push(r7e.configure(this.options.bold)),this.options.blockquote!==!1&&i.push(ZGe.configure(this.options.blockquote)),this.options.bulletList!==!1&&i.push(Une.configure(this.options.bulletList)),this.options.code!==!1&&i.push(s7e.configure(this.options.code)),this.options.codeBlock!==!1&&i.push(c7e.configure(this.options.codeBlock)),this.options.document!==!1&&i.push(u7e.configure(this.options.document)),this.options.dropcursor!==!1&&i.push(k9e.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&i.push(E9e.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&i.push(d7e.configure(this.options.hardBreak)),this.options.heading!==!1&&i.push(h7e.configure(this.options.heading)),this.options.undoRedo!==!1&&i.push(A9e.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&i.push(f7e.configure(this.options.horizontalRule)),this.options.italic!==!1&&i.push(b7e.configure(this.options.italic)),this.options.listItem!==!1&&i.push(zne.configure(this.options.listItem)),this.options.listKeymap!==!1&&i.push(qne.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&i.push(Ine.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&i.push(Kne.configure(this.options.orderedList)),this.options.paragraph!==!1&&i.push(n9e.configure(this.options.paragraph)),this.options.strike!==!1&&i.push(a9e.configure(this.options.strike)),this.options.text!==!1&&i.push(s9e.configure(this.options.text)),this.options.underline!==!1&&i.push(Xne.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&i.push(T9e.configure((r=this.options)==null?void 0:r.trailingNode)),i}}),j9e=C9e,P9e=jr.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:t=>{const e=t.style.textAlign;return this.options.alignments.includes(e)?e:this.options.defaultAlignment},renderHTML:t=>t.textAlign?{style:`text-align: ${t.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:t=>({commands:e})=>this.options.alignments.includes(t)?this.options.types.map(n=>e.updateAttributes(n,{textAlign:t})).some(n=>n):!1,unsetTextAlign:()=>({commands:t})=>this.options.types.map(e=>t.resetAttributes(e,"textAlign")).some(e=>e),toggleTextAlign:t=>({editor:e,commands:n})=>this.options.alignments.includes(t)?e.isActive({textAlign:t})?n.unsetTextAlign():n.setTextAlign(t):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),D9e=P9e,R9e=20,tre=(t,e=0)=>{const n=[];return!t.children.length||e>R9e||Array.from(t.children).forEach(r=>{r.tagName==="SPAN"?n.push(r):r.children.length&&n.push(...tre(r,e+1))}),n},O9e=t=>{if(!t.children.length)return;const e=tre(t);e&&e.forEach(n=>{var r,i;const a=n.getAttribute("style"),o=(i=(r=n.parentElement)==null?void 0:r.closest("span"))==null?void 0:i.getAttribute("style");n.setAttribute("style",`${o};${a}`)})},nre=Hh.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&O9e(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",vi(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleTextStyle:t=>({commands:e})=>e.toggleMark(this.name,t),removeEmptyTextStyle:()=>({tr:t})=>{const{selection:e}=t;return t.doc.nodesBetween(e.from,e.to,(n,r)=>{if(n.isTextblock)return!0;n.marks.filter(i=>i.type===this.type).some(i=>Object.values(i.attrs).some(a=>!!a))||t.removeMark(r,r+n.nodeSize,this.type)}),!0}}}}),L9e=jr.create({name:"backgroundColor",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{default:null,parseHTML:t=>{var e;const n=t.getAttribute("style");if(n){const r=n.split(";").map(i=>i.trim()).filter(Boolean);for(let i=r.length-1;i>=0;i-=1){const a=r[i].split(":");if(a.length>=2){const o=a[0].trim().toLowerCase(),l=a.slice(1).join(":").trim();if(o==="background-color")return l.replace(/['"]+/g,"")}}}return(e=t.style.backgroundColor)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.backgroundColor?{style:`background-color: ${t.backgroundColor}`}:{}}}}]},addCommands(){return{setBackgroundColor:t=>({chain:e})=>e().setMark("textStyle",{backgroundColor:t}).run(),unsetBackgroundColor:()=>({chain:t})=>t().setMark("textStyle",{backgroundColor:null}).removeEmptyTextStyle().run()}}}),rre=jr.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:t=>{var e;const n=t.getAttribute("style");if(n){const r=n.split(";").map(i=>i.trim()).filter(Boolean);for(let i=r.length-1;i>=0;i-=1){const a=r[i].split(":");if(a.length>=2){const o=a[0].trim().toLowerCase(),l=a.slice(1).join(":").trim();if(o==="color")return l.replace(/['"]+/g,"")}}}return(e=t.style.color)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.color?{style:`color: ${t.color}`}:{}}}}]},addCommands(){return{setColor:t=>({chain:e})=>e().setMark("textStyle",{color:t}).run(),unsetColor:()=>({chain:t})=>t().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}}),F9e=jr.create({name:"fontFamily",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontFamily:{default:null,parseHTML:t=>t.style.fontFamily,renderHTML:t=>t.fontFamily?{style:`font-family: ${t.fontFamily}`}:{}}}}]},addCommands(){return{setFontFamily:t=>({chain:e})=>e().setMark("textStyle",{fontFamily:t}).run(),unsetFontFamily:()=>({chain:t})=>t().setMark("textStyle",{fontFamily:null}).removeEmptyTextStyle().run()}}}),I9e=jr.create({name:"fontSize",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:t=>t.style.fontSize,renderHTML:t=>t.fontSize?{style:`font-size: ${t.fontSize}`}:{}}}}]},addCommands(){return{setFontSize:t=>({chain:e})=>e().setMark("textStyle",{fontSize:t}).run(),unsetFontSize:()=>({chain:t})=>t().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}}),U9e=jr.create({name:"lineHeight",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:null,parseHTML:t=>t.style.lineHeight,renderHTML:t=>t.lineHeight?{style:`line-height: ${t.lineHeight}`}:{}}}}]},addCommands(){return{setLineHeight:t=>({chain:e})=>e().setMark("textStyle",{lineHeight:t}).run(),unsetLineHeight:()=>({chain:t})=>t().setMark("textStyle",{lineHeight:null}).removeEmptyTextStyle().run()}}});jr.create({name:"textStyleKit",addExtensions(){const t=[];return this.options.backgroundColor!==!1&&t.push(L9e.configure(this.options.backgroundColor)),this.options.color!==!1&&t.push(rre.configure(this.options.color)),this.options.fontFamily!==!1&&t.push(F9e.configure(this.options.fontFamily)),this.options.fontSize!==!1&&t.push(I9e.configure(this.options.fontSize)),this.options.lineHeight!==!1&&t.push(U9e.configure(this.options.lineHeight)),this.options.textStyle!==!1&&t.push(nre.configure(this.options.textStyle)),t}});var z9e=rre,B9e=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,H9e=Gs.create({name:"image",addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{},resize:!1}},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:t}){return["img",vi(this.options.HTMLAttributes,t)]},parseMarkdown:(t,e)=>e.createNode("image",{src:t.href,title:t.title,alt:t.text}),renderMarkdown:t=>{var e,n,r,i,a,o;const l=(n=(e=t.attrs)==null?void 0:e.src)!=null?n:"",c=(i=(r=t.attrs)==null?void 0:r.alt)!=null?i:"",u=(o=(a=t.attrs)==null?void 0:a.title)!=null?o:"";return u?``:``},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||typeof document>"u"||!this.editor.isEditable)return null;const{directions:t,minWidth:e,minHeight:n,alwaysPreserveAspectRatio:r}=this.options.resize;return({node:i,getPos:a,HTMLAttributes:o})=>{const l=document.createElement("img");Object.entries(o).forEach(([d,f])=>{if(f!=null)switch(d){case"width":case"height":break;default:l.setAttribute(d,f);break}}),l.src=o.src;const c=new SGe({element:l,node:i,getPos:a,onResize:(d,f)=>{l.style.width=`${d}px`,l.style.height=`${f}px`},onCommit:(d,f)=>{const p=a();p!==void 0&&this.editor.chain().setNodeSelection(p).updateAttributes(this.name,{width:d,height:f}).run()},onUpdate:(d,f,p)=>d.type===i.type,options:{directions:t,min:{width:e,height:n},preserveAspectRatio:r===!0}}),u=c.dom;return u.style.visibility="hidden",u.style.pointerEvents="none",l.onload=()=>{u.style.visibility="",u.style.pointerEvents=""},c}},addCommands(){return{setImage:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}},addInputRules(){return[kne({find:B9e,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}),$9e=H9e;function iR({content:t,onChange:e,placeholder:n}){const r=WGe({extensions:[j9e.configure({heading:!1,codeBlock:!1,code:!1}),o9e,$7e.configure({openOnClick:!1,HTMLAttributes:{target:"_blank",rel:"noopener noreferrer"}}),D9e.configure({types:["paragraph"]}),nre,z9e,$9e.configure({HTMLAttributes:{style:"max-width: 100%; height: auto;"}})],content:t,onUpdate:({editor:o})=>{e(o.getHTML())},editorProps:{attributes:{class:"prose prose-invert prose-sm max-w-none focus:outline-none min-h-[120px] px-3 py-2",placeholder:n||""}}});if(!r)return null;const i=({onClick:o,isActive:l=!1,children:c,title:u})=>s.jsx("button",{type:"button",onClick:o,title:u,className:`p-1.5 rounded hover:bg-bambu-dark-tertiary transition-colors ${l?"bg-bambu-dark-tertiary text-bambu-green":"text-bambu-gray"}`,children:c}),a=()=>{const o=window.prompt("Enter URL:");o&&r.chain().focus().setLink({href:o}).run()};return s.jsxs("div",{className:"border border-bambu-dark-tertiary rounded-lg overflow-hidden bg-bambu-dark",children:[s.jsxs("div",{className:"flex items-center gap-0.5 p-1.5 border-b border-bambu-dark-tertiary bg-bambu-dark-secondary",children:[s.jsx(i,{onClick:()=>r.chain().focus().toggleBold().run(),isActive:r.isActive("bold"),title:"Bold",children:s.jsx(xce,{className:"w-4 h-4"})}),s.jsx(i,{onClick:()=>r.chain().focus().toggleItalic().run(),isActive:r.isActive("italic"),title:"Italic",children:s.jsx(ude,{className:"w-4 h-4"})}),s.jsx(i,{onClick:()=>r.chain().focus().toggleUnderline().run(),isActive:r.isActive("underline"),title:"Underline",children:s.jsx(efe,{className:"w-4 h-4"})}),s.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary mx-1"}),s.jsx(i,{onClick:()=>r.chain().focus().toggleBulletList().run(),isActive:r.isActive("bulletList"),title:"Bullet List",children:s.jsx(pN,{className:"w-4 h-4"})}),s.jsx(i,{onClick:()=>r.chain().focus().toggleOrderedList().run(),isActive:r.isActive("orderedList"),title:"Numbered List",children:s.jsx(yW,{className:"w-4 h-4"})}),s.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary mx-1"}),s.jsx(i,{onClick:()=>r.chain().focus().setTextAlign("left").run(),isActive:r.isActive({textAlign:"left"}),title:"Align Left",children:s.jsx(qhe,{className:"w-4 h-4"})}),s.jsx(i,{onClick:()=>r.chain().focus().setTextAlign("center").run(),isActive:r.isActive({textAlign:"center"}),title:"Align Center",children:s.jsx(Hhe,{className:"w-4 h-4"})}),s.jsx(i,{onClick:()=>r.chain().focus().setTextAlign("right").run(),isActive:r.isActive({textAlign:"right"}),title:"Align Right",children:s.jsx(Vhe,{className:"w-4 h-4"})}),s.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary mx-1"}),s.jsx(i,{onClick:a,isActive:r.isActive("link"),title:"Add Link",children:s.jsx(Fy,{className:"w-4 h-4"})}),r.isActive("link")&&s.jsx(i,{onClick:()=>r.chain().focus().unsetLink().run(),title:"Remove Link",children:s.jsx(RR,{className:"w-4 h-4"})})]}),s.jsx(zGe,{editor:r})]})}function ire({archiveId:t,archiveName:e,onClose:n}){const r=an(),[i,a]=_.useState(!1),[o,l]=_.useState(null),[c,u]=_.useState({}),{data:d,isLoading:f,error:p}=at({queryKey:["archive-project-page",t],queryFn:()=>ue.getArchiveProjectPage(t)}),m=mt({mutationFn:k=>ue.updateArchiveProjectPage(t,k),onSuccess:()=>{r.invalidateQueries({queryKey:["archive-project-page",t]}),a(!1),u({})}});_.useEffect(()=>{const k=C=>{C.key==="Escape"&&(o!==null?l(null):i?v():n())};return document.addEventListener("keydown",k),()=>document.removeEventListener("keydown",k)},[o,i,n]);const x=[...d?.model_pictures||[],...d?.profile_pictures||[]],b=()=>{u({title:d?.title||"",description:d?.description||"",designer:d?.designer||"",license:d?.license||"",profile_title:d?.profile_title||"",profile_description:d?.profile_description||""}),a(!0)},y=()=>{m.mutate(c)},v=()=>{a(!1),u({})},S=k=>{const C=["p","br","b","strong","i","em","u","a","ul","ol","li","figure","img"],E=new DOMParser().parseFromString(k,"text/html"),D=A=>{if(A.nodeType===Node.TEXT_NODE)return A.textContent||"";if(A.nodeType===Node.ELEMENT_NODE){const R=A,U=R.tagName.toLowerCase();if(!C.includes(U))return Array.from(R.childNodes).map(D).join("");let F="";if(U==="a"&&R.getAttribute("href")){const j=R.getAttribute("href");j?.toLowerCase().startsWith("http")&&(F=` href="${j}" target="_blank" rel="noopener noreferrer"`)}if(U==="img"){const j=R.getAttribute("src");if(!j?.toLowerCase().startsWith("http"))return"";F=` src="${j}" style="max-width: 100%; height: auto;"`}const $=Array.from(R.childNodes).map(D).join("");return["br","img"].includes(U)?`<${U}${F} />`:`<${U}${F}>${$}</${U}>`}return""};return Array.from(E.body.childNodes).map(D).join("")},N=d&&(d.title||d.description||d.designer||d.profile_title||x.length>0),T=k=>{k.target===k.currentTarget&&n()};return s.jsxs("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:T,children:[s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl max-w-4xl w-full max-h-[90vh] overflow-hidden flex flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Ls,{className:"w-5 h-5 text-bambu-green"}),s.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Project Page",e&&s.jsxs("span",{className:"text-bambu-gray ml-2",children:["- ",e]})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[!i&&N&&s.jsxs(Te,{variant:"ghost",size:"sm",onClick:b,children:[s.jsx(rm,{className:"w-4 h-4 mr-1"}),"Edit"]}),i&&s.jsxs(s.Fragment,{children:[s.jsx(Te,{variant:"ghost",size:"sm",onClick:v,children:"Cancel"}),s.jsxs(Te,{variant:"primary",size:"sm",onClick:y,disabled:m.isPending,children:[s.jsx(hs,{className:"w-4 h-4 mr-1"}),"Save"]})]}),s.jsx("button",{onClick:n,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:s.jsx(Rt,{className:"w-5 h-5 text-bambu-gray"})})]})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto p-6",children:[f&&s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-2 border-bambu-green border-t-transparent"})}),p&&s.jsx("div",{className:"text-red-400 text-center py-12",children:"Failed to load project page data"}),d&&!N&&s.jsxs("div",{className:"text-bambu-gray text-center py-12",children:[s.jsx(Ls,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),s.jsx("p",{children:"No project page data found in this 3MF file."}),s.jsx("p",{className:"text-sm mt-2",children:"Project pages are typically included in files downloaded from MakerWorld."})]}),d&&N&&s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"space-y-4",children:[i?s.jsx("input",{type:"text",value:c.title||"",onChange:k=>u({...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"}):d.title&&s.jsx("h3",{className:"text-xl font-semibold text-white",children:d.title}),s.jsxs("div",{className:"flex flex-wrap gap-4 text-sm",children:[i?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(am,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",value:c.designer||"",onChange:k=>u({...c,designer:k.target.value}),placeholder:"Designer",className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1 text-white"})]}):d.designer&&s.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[s.jsx(am,{className:"w-4 h-4"}),s.jsx("span",{children:d.designer}),d.designer_user_id&&s.jsx("a",{href:`https://makerworld.com/en/@${d.designer_user_id}`,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-green hover:underline",children:s.jsx(Kr,{className:"w-3 h-3"})})]}),d.creation_date&&s.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[s.jsx(si,{className:"w-4 h-4"}),s.jsx("span",{children:d.creation_date})]}),i?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ls,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",value:c.license||"",onChange:k=>u({...c,license:k.target.value}),placeholder:"License",className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1 text-white"})]}):d.license&&s.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[s.jsx(Ls,{className:"w-4 h-4"}),s.jsx("span",{children:d.license})]}),d.origin&&s.jsx("span",{className:"px-2 py-0.5 bg-bambu-dark rounded text-bambu-gray",children:d.origin})]})]}),(d.description||i)&&s.jsxs("div",{className:"space-y-2",children:[s.jsx("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide",children:"Description"}),i?s.jsx(iR,{content:c.description||"",onChange:k=>u({...c,description:k}),placeholder:"Enter description..."}):s.jsx("div",{className:"prose prose-invert prose-sm max-w-none text-bambu-gray-light",dangerouslySetInnerHTML:{__html:S(d.description||"")}})]}),(d.profile_title||d.profile_description||i)&&s.jsxs("div",{className:"space-y-2 p-4 bg-bambu-dark rounded-lg",children:[s.jsx("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide",children:"Print Profile"}),i?s.jsxs("div",{className:"space-y-2",children:[s.jsx("input",{type:"text",value:c.profile_title||"",onChange:k=>u({...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"}),s.jsx(iR,{content:c.profile_description||"",onChange:k=>u({...c,profile_description:k}),placeholder:"Profile description..."})]}):s.jsxs(s.Fragment,{children:[d.profile_title&&s.jsx("p",{className:"text-white font-medium",children:d.profile_title}),d.profile_description&&s.jsx("div",{className:"prose prose-invert prose-sm max-w-none text-bambu-gray-light",dangerouslySetInnerHTML:{__html:S(d.profile_description)}}),d.profile_user_name&&s.jsxs("p",{className:"text-sm text-bambu-gray",children:["by ",d.profile_user_name]})]})]}),x.length>0&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide flex items-center gap-2",children:[s.jsx(Ou,{className:"w-4 h-4"}),"Images (",x.length,")"]}),s.jsx("div",{className:"grid grid-cols-3 sm:grid-cols-4 md:grid-cols-5 gap-2",children:x.map((k,C)=>s.jsx("button",{onClick:()=>l(C),className:"aspect-square rounded-lg overflow-hidden border border-bambu-dark-tertiary hover:border-bambu-green transition-colors",children:s.jsx("img",{src:k.url,alt:k.name,className:"w-full h-full object-cover"})},k.path))})]}),d.design_model_id&&s.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:s.jsxs("a",{href:`https://makerworld.com/en/models/${d.design_model_id}`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-bambu-green hover:underline",children:[s.jsx(Kr,{className:"w-4 h-4"}),"View on MakerWorld"]})})]})]})]}),o!==null&&x[o]&&s.jsxs("div",{className:"fixed inset-0 bg-black/90 flex items-center justify-center z-60",onClick:()=>l(null),children:[s.jsx("button",{onClick: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:s.jsx(gh,{className:"w-6 h-6 text-white"})}),s.jsx("img",{src:x[o].url,alt:x[o].name,className:"max-w-[90vw] max-h-[90vh] object-contain",onClick:k=>k.stopPropagation()}),s.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:s.jsx(gs,{className:"w-6 h-6 text-white"})}),s.jsx("button",{onClick:()=>l(null),className:"absolute top-4 right-4 p-2 bg-bambu-dark-secondary rounded-full hover:bg-bambu-dark-tertiary",children:s.jsx(Rt,{className:"w-6 h-6 text-white"})}),s.jsxs("div",{className:"absolute bottom-4 text-white text-sm",children:[o+1," / ",x.length]})]})]})}const V9e=[.25,.5,.75,1,1.5,2,3,4];function ng(t){const e=Math.floor(t/60),n=Math.floor(t%60);return`${e}:${n.toString().padStart(2,"0")}`}function G9e({archiveId:t,timelapseSrc:e,onClose:n,onSave:r}){const{showToast:i}=$n(),a=_.useRef(null),o=_.useRef(null),[l,c]=_.useState(!1),[u,d]=_.useState(0),[f,p]=_.useState(0),[m,x]=_.useState(0),[b,y]=_.useState(0),[v,S]=_.useState(1),[N,T]=_.useState(null),[k,C]=_.useState(null),[E,D]=_.useState(.8),[A,R]=_.useState(!1),{data:U,isLoading:F}=at({queryKey:["timelapse-info",t],queryFn:()=>ue.getTimelapseInfo(t)}),{data:$}=at({queryKey:["timelapse-thumbnails",t],queryFn:()=>ue.getTimelapseThumbnails(t,15)}),j=mt({mutationFn:()=>ue.processTimelapse(t,{trimStart:m,trimEnd:b,speed:v,saveMode:"replace"},N||void 0),onSuccess:B=>{i(B.message,"success"),r?.(),n()},onError:B=>{i(B.message||"Processing failed","error")}});_.useEffect(()=>{U?.duration&&b===0&&y(U.duration)},[U?.duration,b]),_.useEffect(()=>{const B=X=>{X.key==="Escape"&&n()};return window.addEventListener("keydown",B),()=>window.removeEventListener("keydown",B)},[n]),_.useEffect(()=>{const B=a.current;if(!B)return;const X=()=>{const xe=B.currentTime;d(xe),xe>=b&&(B.currentTime=m)},ne=()=>{p(B.duration),b===0&&y(B.duration)},se=()=>c(!0),be=()=>c(!1);return B.addEventListener("timeupdate",X),B.addEventListener("durationchange",ne),B.addEventListener("play",se),B.addEventListener("pause",be),()=>{B.removeEventListener("timeupdate",X),B.removeEventListener("durationchange",ne),B.removeEventListener("play",se),B.removeEventListener("pause",be)}},[m,b]),_.useEffect(()=>{const B=o.current,X=a.current;!B||!X||!k||(B.currentTime=X.currentTime,B.playbackRate=X.playbackRate,l&&!A?B.play().catch(()=>{}):B.pause())},[l,k,A]),_.useEffect(()=>{o.current&&(o.current.volume=A?0:E)},[E,A]),_.useEffect(()=>{a.current&&(a.current.playbackRate=v),o.current&&(o.current.playbackRate=v)},[v]);const H=_.useCallback(()=>{const B=a.current;B&&(l?B.pause():(B.currentTime<m&&(B.currentTime=m),B.play()))},[l,m]),K=B=>{const X=a.current;X&&(X.currentTime=Math.max(m,Math.min(b,B)))},V=B=>{const X=B.target.files?.[0];X&&(k&&URL.revokeObjectURL(k),T(X),C(URL.createObjectURL(X)))},Q=()=>{k&&URL.revokeObjectURL(k),T(null),C(null)};_.useEffect(()=>()=>{k&&URL.revokeObjectURL(k)},[k]);const Z=b-m,ae=Z/v;return F?s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",children:s.jsxs("div",{className:"flex items-center gap-3 text-white",children:[s.jsx(ht,{className:"w-6 h-6 animate-spin"}),"Loading video info..."]})}):s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",children:s.jsxs("div",{className:"relative bg-bambu-dark-secondary rounded-xl max-w-5xl w-full mx-4 max-h-[90vh] overflow-hidden flex flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary shrink-0",children:[s.jsxs("h3",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(ah,{className:"w-5 h-5 text-bambu-green"}),"Edit Timelapse"]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Te,{variant:"primary",size:"sm",onClick:()=>j.mutate(),disabled:j.isPending,children:j.isPending?s.jsxs(s.Fragment,{children:[s.jsx(ht,{className:"w-4 h-4 animate-spin"}),"Processing..."]}):s.jsxs(s.Fragment,{children:[s.jsx(hs,{className:"w-4 h-4"}),"Save"]})}),s.jsx("button",{onClick:n,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",children:s.jsx(Rt,{className:"w-5 h-5 text-bambu-gray"})})]})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-4",children:[s.jsxs("div",{className:"relative",children:[s.jsx("video",{ref:a,src:e,className:"w-full rounded-lg bg-black",onClick:H,muted:!!k}),!l&&s.jsx("button",{onClick:H,className:"absolute inset-0 flex items-center justify-center bg-black/30 hover:bg-black/40 transition-colors",children:s.jsx("div",{className:"p-4 bg-bambu-green rounded-full",children:s.jsx(Is,{className:"w-8 h-8 text-white"})})}),k&&s.jsx("audio",{ref:o,src:k,loop:!0})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[s.jsx(ghe,{className:"w-4 h-4"}),s.jsx("span",{children:"Trim"}),s.jsxs("span",{className:"ml-auto",children:[ng(m)," - ",ng(b)," (",ng(Z),")"]})]}),s.jsxs("div",{className:"relative h-16 bg-bambu-dark rounded-lg overflow-hidden",children:[s.jsx("div",{className:"absolute inset-0 flex",children:$?.thumbnails.map((B,X)=>s.jsx("div",{className:"flex-1 bg-cover bg-center",style:{backgroundImage:`url(data:image/jpeg;base64,${B})`}},X))}),s.jsx("div",{className:"absolute inset-y-0 left-0 bg-black/60",style:{width:`${m/f*100}%`}}),s.jsx("div",{className:"absolute inset-y-0 right-0 bg-black/60",style:{width:`${(f-b)/f*100}%`}}),s.jsx("div",{className:"absolute inset-y-0 border-2 border-bambu-green",style:{left:`${m/f*100}%`,right:`${(f-b)/f*100}%`}}),s.jsx("div",{className:"absolute top-0 bottom-0 w-0.5 bg-white shadow-lg",style:{left:`${u/f*100}%`}}),s.jsx("input",{type:"range",min:0,max:f,step:.1,value:m,onChange:B=>{const X=parseFloat(B.target.value);X<b-1&&(x(X),a.current&&a.current.currentTime<X&&(a.current.currentTime=X))},className:"absolute inset-0 w-full opacity-0 cursor-ew-resize",style:{clipPath:"inset(0 50% 0 0)"}}),s.jsx("input",{type:"range",min:0,max:f,step:.1,value:b,onChange:B=>{const X=parseFloat(B.target.value);X>m+1&&y(X)},className:"absolute inset-0 w-full opacity-0 cursor-ew-resize",style:{clipPath:"inset(0 0 0 50%)"}})]}),s.jsx("input",{type:"range",min:0,max:f,step:.1,value:u,onChange:B=>K(parseFloat(B.target.value)),className:`w-full h-1 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer
- [&::-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`}),s.jsx("div",{className:"flex items-center justify-center gap-2",children:s.jsx("button",{onClick:H,className:"p-2 bg-bambu-green hover:bg-bambu-green-dark rounded-lg transition-colors",children:l?s.jsx(CR,{className:"w-5 h-5 text-white"}):s.jsx(Is,{className:"w-5 h-5 text-white"})})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[s.jsx(dN,{className:"w-4 h-4"}),s.jsx("span",{children:"Speed"}),s.jsxs("span",{className:"ml-auto",children:[v,"x (output: ",ng(ae),")"]})]}),s.jsx("div",{className:"flex gap-1",children:V9e.map(B=>s.jsxs("button",{onClick:()=>S(B),className:`flex-1 px-2 py-2 text-sm rounded transition-colors ${v===B?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:[B,"x"]},B))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[s.jsx(bP,{className:"w-4 h-4"}),s.jsx("span",{children:"Music Overlay"})]}),N?s.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[s.jsx(bP,{className:"w-5 h-5 text-bambu-green"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-sm text-white truncate",children:N.name}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[(N.size/1024/1024).toFixed(1)," MB"]})]}),s.jsx("button",{onClick:()=>R(!A),className:"p-2 hover:bg-bambu-dark-tertiary rounded transition-colors",children:A?s.jsx(cfe,{className:"w-4 h-4 text-bambu-gray"}):s.jsx(ofe,{className:"w-4 h-4 text-bambu-green"})}),s.jsx("input",{type:"range",min:0,max:1,step:.1,value:E,onChange:B=>D(parseFloat(B.target.value)),className:`w-20 h-1 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer
- [&::-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`}),s.jsx("button",{onClick:Q,className:"p-2 hover:bg-red-500/20 rounded transition-colors",children:s.jsx(rn,{className:"w-4 h-4 text-red-400"})})]}):s.jsxs("label",{className:"flex flex-col items-center justify-center gap-2 p-6 border-2 border-dashed border-bambu-dark-tertiary rounded-lg cursor-pointer hover:border-bambu-green/50 transition-colors",children:[s.jsx(Ua,{className:"w-8 h-8 text-bambu-gray"}),s.jsx("span",{className:"text-sm text-bambu-gray",children:"Drop audio file or click to upload"}),s.jsx("span",{className:"text-xs text-bambu-gray/60",children:"MP3, WAV, M4A, AAC, OGG"}),s.jsx("input",{type:"file",accept:".mp3,.wav,.m4a,.aac,.ogg,audio/*",onChange:V,className:"hidden"})]})]}),s.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg text-sm space-y-1",children:[s.jsxs("p",{className:"text-bambu-gray",children:[s.jsx("span",{className:"text-white",children:"Original:"})," ",ng(f)," @ ",U?.width,"x",U?.height]}),s.jsxs("p",{className:"text-bambu-gray",children:[s.jsx("span",{className:"text-white",children:"Output:"})," ",ng(ae)," @ ",v,"x speed",N&&" + music overlay"]})]})]}),j.isPending&&s.jsxs("div",{className:"absolute inset-0 bg-black/80 flex flex-col items-center justify-center gap-4",children:[s.jsx(ht,{className:"w-12 h-12 text-bambu-green animate-spin"}),s.jsx("p",{className:"text-white text-lg",children:"Processing timelapse..."}),s.jsx("p",{className:"text-bambu-gray text-sm",children:"This may take a few moments"})]})]})})}const q9e=[.25,.5,.75,1,1.5,2,3,4];function are({src:t,title:e,downloadFilename:n,archiveId:r,onClose:i,onEdit:a}){const o=_.useRef(null),[l,c]=_.useState(!0),[u,d]=_.useState(1),[f,p]=_.useState(0),[m,x]=_.useState(0),[b,y]=_.useState(!1);_.useEffect(()=>{const E=o.current;E&&(E.playbackRate=u)},[u]),_.useEffect(()=>{const E=D=>{D.key==="Escape"&&i()};return window.addEventListener("keydown",E),()=>window.removeEventListener("keydown",E)},[i]),_.useEffect(()=>{const E=o.current;if(!E)return;const D=()=>p(E.currentTime),A=()=>x(E.duration),R=()=>c(!0),U=()=>c(!1);return E.addEventListener("timeupdate",D),E.addEventListener("durationchange",A),E.addEventListener("play",R),E.addEventListener("pause",U),()=>{E.removeEventListener("timeupdate",D),E.removeEventListener("durationchange",A),E.removeEventListener("play",R),E.removeEventListener("pause",U)}},[]);const v=()=>{const E=o.current;E&&(l?E.pause():E.play())},S=E=>{const D=o.current;D&&(D.currentTime=parseFloat(E.target.value))},N=()=>{const E=o.current;E&&(E.currentTime=Math.max(0,E.currentTime-5))},T=()=>{const E=o.current;E&&(E.currentTime=Math.min(m,E.currentTime+5))},k=E=>{const D=Math.floor(E/60),A=Math.floor(E%60);return`${D}:${A.toString().padStart(2,"0")}`},C=()=>{const E=document.createElement("a");E.href=t,E.download=n,E.click()};return s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",children:[s.jsxs("div",{className:"relative bg-bambu-dark-secondary rounded-xl max-w-4xl w-full mx-4 overflow-hidden",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("h3",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(ah,{className:"w-5 h-5 text-bambu-green"}),e]}),s.jsxs("div",{className:"flex items-center gap-2",children:[r&&s.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>y(!0),children:[s.jsx(Qi,{className:"w-4 h-4"}),"Edit"]}),s.jsxs(Te,{variant:"secondary",size:"sm",onClick:C,children:[s.jsx(yi,{className:"w-4 h-4"}),"Download"]}),s.jsx("button",{onClick:i,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",children:s.jsx(Rt,{className:"w-5 h-5 text-bambu-gray"})})]})]}),s.jsxs("div",{className:"p-4",children:[s.jsx("video",{ref:o,src:t,autoPlay:!0,className:"w-full rounded-lg",onClick:v}),s.jsxs("div",{className:"mt-4 space-y-3",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("span",{className:"text-xs text-bambu-gray w-12 text-right",children:k(f)}),s.jsx("input",{type:"range",min:0,max:m||100,value:f,onChange:S,className:`flex-1 h-1 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer
- [&::-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`}),s.jsx("span",{className:"text-xs text-bambu-gray w-12",children:k(m)})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{onClick:N,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",title:"Skip back 5s",children:s.jsx(Ehe,{className:"w-5 h-5 text-bambu-gray"})}),s.jsx("button",{onClick:v,className:"p-2 bg-bambu-green hover:bg-bambu-green-dark rounded-lg transition-colors",children:l?s.jsx(CR,{className:"w-5 h-5 text-white"}):s.jsx(Is,{className:"w-5 h-5 text-white"})}),s.jsx("button",{onClick:T,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",title:"Skip forward 5s",children:s.jsx(DR,{className:"w-5 h-5 text-bambu-gray"})})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-sm text-bambu-gray",children:"Speed:"}),s.jsx("div",{className:"flex gap-1",children:q9e.map(E=>s.jsxs("button",{onClick:()=>d(E),className:`px-2 py-1 text-xs rounded transition-colors ${u===E?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:bg-bambu-dark-tertiary/80"}`,children:[E,"x"]},E))})]})]})]})]})]}),b&&r&&s.jsx(G9e,{archiveId:r,timelapseSrc:t,onClose:()=>y(!1),onSave:a})]})}function W9e({archiveIds:t,onClose:e}){_.useEffect(()=>{const a=o=>{o.key==="Escape"&&e()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[e]);const{data:n,isLoading:r,error:i}=at({queryKey:["archive-comparison",t],queryFn:()=>ue.compareArchives(t)});return s.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",onClick:e,children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg max-w-4xl w-full max-h-[90vh] flex flex-col border border-bambu-dark-tertiary",onClick:a=>a.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("h3",{className:"text-lg font-semibold text-white",children:["Compare Archives (",t.length,")"]}),s.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white p-1",children:s.jsx(Rt,{className:"w-5 h-5"})})]}),s.jsx("div",{className:"flex-1 overflow-auto p-4 bg-bambu-dark-secondary",children:r?s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx(ht,{className:"w-8 h-8 text-bambu-green animate-spin"})}):i?s.jsxs("div",{className:"text-center py-12 text-red-400",children:[s.jsx(Cn,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),s.jsx("p",{children:"Failed to load comparison"}),s.jsx("p",{className:"text-sm text-bambu-gray mt-2",children:i instanceof Error?i.message:"Unknown error"})]}):n?s.jsx(K9e,{comparison:n}):null}),s.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:s.jsx(Te,{variant:"secondary",onClick:e,className:"w-full",children:"Close"})})]})})}function K9e({comparison:t}){return s.jsxs("div",{className:"space-y-6",children:[s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full",children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{className:"text-left text-sm text-bambu-gray font-medium pb-2 pr-4 min-w-[150px]",children:"Setting"}),t.archives.map(e=>s.jsxs("th",{className:"text-left text-sm font-medium pb-2 px-2 min-w-[120px]",children:[s.jsx("div",{className:"text-white truncate max-w-[150px]",title:e.print_name,children:e.print_name}),s.jsx("div",{className:`text-xs ${e.status==="completed"?"text-status-ok":e.status==="failed"?"text-status-error":"text-bambu-gray"}`,children:e.status})]},e.id))]})}),s.jsx("tbody",{className:"divide-y divide-bambu-gray/20",children:t.comparison.map(e=>s.jsxs("tr",{className:e.has_difference?"bg-yellow-500/5":"",children:[s.jsx("td",{className:"py-2 pr-4 text-sm",children:s.jsxs("div",{className:"flex items-center gap-2",children:[e.has_difference&&s.jsx(Cn,{className:"w-3 h-3 text-yellow-400 flex-shrink-0"}),s.jsx("span",{className:e.has_difference?"text-yellow-400":"text-bambu-gray",children:e.label})]})}),e.values.map((n,r)=>s.jsxs("td",{className:"py-2 px-2 text-sm text-white",children:[n??s.jsx("span",{className:"text-bambu-gray/50",children:"-"}),e.unit&&n!==null&&s.jsx("span",{className:"text-bambu-gray ml-1",children:e.unit})]},r))]},e.field))})]})}),t.differences.length>0&&s.jsxs("div",{className:"p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[s.jsxs("h4",{className:"text-sm font-medium text-yellow-400 mb-2 flex items-center gap-2",children:[s.jsx(Cn,{className:"w-4 h-4"}),t.differences.length," Difference",t.differences.length>1?"s":""," Found"]}),s.jsxs("ul",{className:"text-sm text-white/80 space-y-1",children:[t.differences.slice(0,5).map(e=>s.jsxs("li",{children:[s.jsx("span",{className:"text-yellow-400",children:e.label}),": ",e.values.join(" vs ")," ",e.unit||""]},e.field)),t.differences.length>5&&s.jsxs("li",{className:"text-bambu-gray",children:["...and ",t.differences.length-5," more"]})]})]}),t.success_correlation.has_both_outcomes?s.jsxs("div",{className:"p-4 bg-bambu-dark rounded-lg",children:[s.jsxs("h4",{className:"text-sm font-medium text-white mb-3 flex items-center gap-2",children:[s.jsx(Ia,{className:"w-4 h-4 text-bambu-green"}),"Success/Failure Analysis"]}),s.jsxs("div",{className:"flex items-center gap-4 text-sm mb-3",children:[s.jsxs("span",{className:"text-bambu-green",children:[t.success_correlation.successful_count," successful"]}),s.jsxs("span",{className:"text-red-400",children:[t.success_correlation.failed_count," failed"]})]}),t.success_correlation.insights&&t.success_correlation.insights.length>0?s.jsx("div",{className:"space-y-2",children:t.success_correlation.insights.map(e=>s.jsxs("div",{className:"text-sm p-2 bg-bambu-dark-secondary rounded",children:[s.jsxs("span",{className:"text-white font-medium",children:[e.label,":"]})," ",s.jsx("span",{className:"text-white/80",children:e.insight})]},e.field))}):s.jsx("p",{className:"text-sm text-bambu-gray",children:"No clear correlations found between settings and outcomes."})]}):s.jsx("div",{className:"p-4 bg-bambu-dark rounded-lg text-sm text-bambu-gray",children:s.jsx("p",{children:t.success_correlation.message||"Need both successful and failed prints for correlation analysis."})})]})}function X9e(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function Y9e(t){const e=new Date(t),r=new Date().getTime()-e.getTime(),i=Math.floor(r/6e4);if(i<1)return"Just now";if(i<60)return`${i}m ago`;const a=Math.floor(i/60);return a<24?`${a}h ago`:`${Math.floor(a/24)}d ago`}function Q9e({upload:t,projects:e,onArchive:n,onDiscard:r,isArchiving:i,isDiscarding:a}){const[o,l]=_.useState(!1),[c,u]=_.useState(t.tags||""),[d,f]=_.useState(t.notes||""),[p,m]=_.useState(t.project_id),[x,b]=_.useState(!1);return s.jsx(_t,{children:s.jsxs(Mt,{className:"py-3",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(zf,{className:"w-8 h-8 text-bambu-green flex-shrink-0"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-white font-medium",children:t.filename}),s.jsxs("div",{className:"flex items-center gap-2 text-xs text-bambu-gray",children:[s.jsx("span",{children:X9e(t.file_size)}),s.jsx("span",{children:"·"}),s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(er,{className:"w-3 h-3"}),Y9e(t.uploaded_at)]}),t.source_ip&&s.jsxs(s.Fragment,{children:[s.jsx("span",{children:"·"}),s.jsxs("span",{children:["from ",t.source_ip]})]})]})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{onClick:()=>l(!o),className:"p-1 text-bambu-gray hover:text-white transition-colors",children:o?s.jsx(xh,{className:"w-5 h-5"}):s.jsx(ei,{className:"w-5 h-5"})}),s.jsx(Te,{variant:"primary",size:"sm",onClick:()=>n(t.id,{tags:c,notes:d,project_id:p||void 0}),disabled:i,children:i?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsxs(s.Fragment,{children:[s.jsx(fo,{className:"w-4 h-4"}),"Archive"]})}),s.jsx(Te,{variant:"secondary",size:"sm",onClick:()=>b(!0),disabled:a,children:a?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(rn,{className:"w-4 h-4 text-red-400"})})]})]}),x&&s.jsx(Zn,{title:"Discard Upload",message:`Are you sure you want to discard "${t.filename}"? This cannot be undone.`,confirmText:"Discard",variant:"danger",onConfirm:()=>{r(t.id),b(!1)},onCancel:()=>b(!1)}),o&&s.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary space-y-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Tags"}),s.jsx("input",{type:"text",value:c,onChange:y=>u(y.target.value),placeholder:"e.g., functional, prototype, gift",className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-2 text-white placeholder-bambu-gray text-sm"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Notes"}),s.jsx("textarea",{value:d,onChange:y=>f(y.target.value),placeholder:"Add notes about this print...",rows:2,className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-2 text-white placeholder-bambu-gray text-sm resize-none"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Project"}),s.jsxs("select",{value:p||"",onChange:y=>m(y.target.value?Number(y.target.value):null),className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-2 text-white text-sm",children:[s.jsx("option",{value:"",children:"No project"}),e.map(y=>s.jsx("option",{value:y.id,children:y.name},y.id))]})]})]})]})})}function Z9e(){const t=an(),{showToast:e}=$n(),[n,r]=_.useState(!1),[i,a]=_.useState(!1),[o,l]=_.useState(new Set),[c,u]=_.useState(new Set),{data:d,isLoading:f}=at({queryKey:["pending-uploads"],queryFn:ag.list,refetchInterval:1e4}),{data:p}=at({queryKey:["projects"],queryFn:()=>ue.getProjects()}),m=mt({mutationFn:({id:v,data:S})=>ag.archive(v,S),onMutate:({id:v})=>{l(S=>new Set(S).add(v))},onSettled:(v,S,{id:N})=>{l(T=>{const k=new Set(T);return k.delete(N),k})},onSuccess:v=>{t.invalidateQueries({queryKey:["pending-uploads"]}),t.invalidateQueries({queryKey:["archives"]}),e(`Archived: ${v.print_name}`)},onError:v=>{e(v.message||"Failed to archive","error")}}),x=mt({mutationFn:v=>ag.discard(v),onMutate:v=>{u(S=>new Set(S).add(v))},onSettled:(v,S,N)=>{u(T=>{const k=new Set(T);return k.delete(N),k})},onSuccess:()=>{t.invalidateQueries({queryKey:["pending-uploads"]}),e("Upload discarded")},onError:v=>{e(v.message||"Failed to discard","error")}}),b=mt({mutationFn:ag.archiveAll,onSuccess:v=>{t.invalidateQueries({queryKey:["pending-uploads"]}),t.invalidateQueries({queryKey:["archives"]}),e(`Archived ${v.archived} files${v.failed>0?`, ${v.failed} failed`:""}`)},onError:v=>{e(v.message||"Failed to archive all","error")}}),y=mt({mutationFn:ag.discardAll,onSuccess:v=>{t.invalidateQueries({queryKey:["pending-uploads"]}),e(`Discarded ${v.discarded} files`)},onError:v=>{e(v.message||"Failed to discard all","error")}});return f?s.jsx(_t,{children:s.jsx(Mt,{className:"py-8 flex justify-center",children:s.jsx(ht,{className:"w-6 h-6 animate-spin text-bambu-green"})})}):!d||d.length===0?null:s.jsxs("div",{className:"mb-6",children:[s.jsxs(_t,{className:"border-l-4 border-l-yellow-500",children:[s.jsx(Kn,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ua,{className:"w-5 h-5 text-yellow-500"}),s.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Pending Uploads (",d.length,")"]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Te,{variant:"primary",size:"sm",onClick:()=>r(!0),disabled:b.isPending,children:b.isPending?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsxs(s.Fragment,{children:[s.jsx(fo,{className:"w-4 h-4"}),"Archive All"]})}),s.jsx(Te,{variant:"secondary",size:"sm",onClick:()=>a(!0),disabled:y.isPending,children:y.isPending?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsxs(s.Fragment,{children:[s.jsx(rn,{className:"w-4 h-4"}),"Discard All"]})})]})]})}),s.jsxs(Mt,{children:[s.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:"These files were uploaded via the virtual printer. Review and archive them to add to your collection."}),s.jsx("div",{className:"space-y-3",children:d.map(v=>s.jsx(Q9e,{upload:v,projects:p||[],onArchive:(S,N)=>m.mutate({id:S,data:N}),onDiscard:S=>x.mutate(S),isArchiving:o.has(v.id),isDiscarding:c.has(v.id)},v.id))})]})]}),n&&s.jsx(Zn,{title:"Archive All Uploads",message:`Are you sure you want to archive all ${d.length} pending uploads?`,confirmText:"Archive All",onConfirm:()=>{b.mutate(),r(!1)},onCancel:()=>r(!1)}),i&&s.jsx(Zn,{title:"Discard All Uploads",message:`Are you sure you want to discard all ${d.length} pending uploads? This cannot be undone.`,confirmText:"Discard All",variant:"danger",onConfirm:()=>{y.mutate(),a(!1)},onCancel:()=>a(!1)})]})}function J9e({onClose:t}){const e=an(),{showToast:n}=$n(),[r,i]=_.useState(""),[a,o]=_.useState(null),[l,c]=_.useState(""),[u,d]=_.useState(null),[f,p]=_.useState("count");_.useEffect(()=>{const A=R=>{R.key==="Escape"&&(a?o(null):u?d(null):t())};return window.addEventListener("keydown",A),()=>window.removeEventListener("keydown",A)},[t,a,u]);const{data:m,isLoading:x}=at({queryKey:["tags"],queryFn:ue.getTags}),b=mt({mutationFn:({oldName:A,newName:R})=>ue.renameTag(A,R),onSuccess:(A,{oldName:R,newName:U})=>{e.invalidateQueries({queryKey:["tags"]}),e.invalidateQueries({queryKey:["archives"]}),n(`Renamed "${R}" to "${U}" in ${A.affected} archive${A.affected!==1?"s":""}`),o(null)},onError:A=>{n(A.message||"Failed to rename tag","error")}}),y=mt({mutationFn:A=>ue.deleteTag(A),onSuccess:(A,R)=>{e.invalidateQueries({queryKey:["tags"]}),e.invalidateQueries({queryKey:["archives"]}),n(`Deleted "${R}" from ${A.affected} archive${A.affected!==1?"s":""}`),d(null)},onError:A=>{n(A.message||"Failed to delete tag","error")}}),v=A=>{o(A.name),c(A.name),d(null)},S=()=>{o(null),c("")},N=()=>{if(!a||!l.trim())return;const A=l.trim();if(A===a){S();return}b.mutate({oldName:a,newName:A})},T=A=>{A.key==="Enter"?(A.preventDefault(),N()):A.key==="Escape"&&(A.preventDefault(),S())},k=A=>{d(A),o(null)},C=()=>{u&&y.mutate(u)},E=m?.filter(A=>A.name.toLowerCase().includes(r.toLowerCase())).sort((A,R)=>f==="count"&&R.count-A.count||A.name.localeCompare(R.name)),D=m?.reduce((A,R)=>A+R.count,0)||0;return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:s.jsx(_t,{className:"w-full max-w-lg max-h-[80vh] flex flex-col",children:s.jsxs(Mt,{className:"p-0 flex flex-col min-h-0",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary flex-shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(yh,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-xl font-semibold text-white",children:"Manage Tags"})]}),s.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(Rt,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary flex-shrink-0",children:[s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsx(ba,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",placeholder:"Search tags...",className:"w-full pl-9 pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",value:r,onChange:A=>i(A.target.value)})]}),s.jsxs("select",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",value:f,onChange:A=>p(A.target.value),children:[s.jsx("option",{value:"count",children:"Sort by Count"}),s.jsx("option",{value:"name",children:"Sort by Name"})]})]}),m&&s.jsxs("p",{className:"text-xs text-bambu-gray mt-2",children:[m.length," tag",m.length!==1?"s":""," across ",D," usage",D!==1?"s":""]})]}),s.jsx("div",{className:"flex-1 overflow-y-auto min-h-0 p-4",children:x?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx(ht,{className:"w-6 h-6 animate-spin text-bambu-gray"})}):E?.length?s.jsx("div",{className:"space-y-2",children:E.map(A=>s.jsx("div",{className:"flex items-center gap-2 p-2 rounded-lg bg-bambu-dark hover:bg-bambu-dark-tertiary transition-colors group",children:a===A.name?s.jsxs("div",{className:"flex-1 flex items-center gap-2",children:[s.jsx("input",{type:"text",className:"flex-1 px-2 py-1 bg-bambu-dark-tertiary border border-bambu-green rounded text-white text-sm focus:outline-none",value:l,onChange:R=>c(R.target.value),onKeyDown:T,autoFocus:!0}),s.jsx(Te,{size:"sm",variant:"primary",onClick:N,disabled:!l.trim()||b.isPending,className:"p-1.5",children:b.isPending?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(Ia,{className:"w-4 h-4"})}),s.jsx(Te,{size:"sm",variant:"ghost",onClick:S,className:"p-1.5",children:s.jsx(Rt,{className:"w-4 h-4"})})]}):u===A.name?s.jsxs("div",{className:"flex-1 flex items-center gap-2",children:[s.jsx(Cn,{className:"w-4 h-4 text-yellow-400 flex-shrink-0"}),s.jsxs("span",{className:"text-sm text-bambu-gray-light flex-1",children:['Delete "',A.name,'" from ',A.count," archive",A.count!==1?"s":"","?"]}),s.jsx(Te,{size:"sm",variant:"danger",onClick:C,disabled:y.isPending,className:"p-1.5",children:y.isPending?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(rn,{className:"w-4 h-4"})}),s.jsx(Te,{size:"sm",variant:"ghost",onClick:()=>d(null),className:"p-1.5",children:s.jsx(Rt,{className:"w-4 h-4"})})]}):s.jsxs(s.Fragment,{children:[s.jsx(yh,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),s.jsx("span",{className:"text-white flex-1 truncate",children:A.name}),s.jsx("span",{className:"px-2 py-0.5 rounded-full bg-bambu-dark-tertiary text-bambu-gray text-xs",children:A.count}),s.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[s.jsx("button",{onClick:()=>v(A),className:"p-1.5 rounded hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors",title:"Rename tag",children:s.jsx(Qi,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>k(A.name),className:"p-1.5 rounded hover:bg-bambu-dark text-bambu-gray hover:text-red-400 transition-colors",title:"Delete tag",children:s.jsx(rn,{className:"w-4 h-4"})})]})]})},A.name))}):s.jsx("div",{className:"text-center py-8 text-bambu-gray",children:r?"No tags match your search":"No tags found"})}),s.jsx("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary flex-shrink-0",children:s.jsx(Te,{variant:"secondary",onClick:t,className:"flex-1",children:"Close"})})]})})})}function XM(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function t0(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function Cf(t){if(!t)return!1;const e=t.toLowerCase();return e.endsWith(".gcode")||e.includes(".gcode.")}function eqe({archive:t,printerName:e,isSelected:n,onSelect:r,selectionMode:i,projects:a,isHighlighted:o,timeFormat:l="system",t:c}){o&&console.log("ArchiveCard isHighlighted=true for archive:",t.id);const u=an(),{showToast:d}=$n(),{hasPermission:f,canModify:p}=Ai(),m=IR(),[x,b]=_.useState(!1),[y,v]=_.useState(!1),[S,N]=_.useState(!1),[T,k]=_.useState(!1),[C,E]=_.useState(!1),[D,A]=_.useState(!1),[R,U]=_.useState([]),[F,$]=_.useState(!1),[j,H]=_.useState(!1),[K,V]=_.useState(!1),[Q,Z]=_.useState(!1),[ae,B]=_.useState(!1),[X,ne]=_.useState(!1),[se,be]=_.useState(null),[xe,de]=_.useState(null),[Pe,ie]=_.useState(!1),Ne=_.useRef(null),Oe=_.useRef(null),{data:ge}=at({queryKey:["archive-plates",t.id],queryFn:()=>ue.getArchivePlates(t.id),enabled:Pe,staleTime:300*1e3}),Ke=ge?.plates??[],G=ge?.is_multi_plate??!1,Y=xe??0,ce=mt({mutationFn:re=>ue.uploadSource3mf(t.id,re),onSuccess:re=>{u.invalidateQueries({queryKey:["archives"]}),d(c("archives.toast.source3mfAttached",{filename:re.filename}))},onError:re=>{d(re.message||c("archives.toast.failedUploadSource3mf"),"error")}}),q=mt({mutationFn:()=>ue.deleteSource3mf(t.id),onSuccess:()=>{u.invalidateQueries({queryKey:["archives"]}),d(c("archives.toast.source3mfRemoved"))},onError:re=>{d(re.message||c("archives.toast.failedRemoveSource3mf"),"error")}}),te=mt({mutationFn:re=>ue.uploadF3d(t.id,re),onSuccess:re=>{u.invalidateQueries({queryKey:["archives"]}),d(c("archives.toast.f3dAttached",{filename:re.filename}))},onError:re=>{d(re.message||c("archives.toast.failedUploadF3d"),"error")}}),I=mt({mutationFn:()=>ue.deleteF3d(t.id),onSuccess:()=>{u.invalidateQueries({queryKey:["archives"]}),d(c("archives.toast.f3dRemoved"))},onError:re=>{d(re.message||c("archives.toast.failedRemoveF3d"),"error")}}),fe=mt({mutationFn:()=>ue.scanArchiveTimelapse(t.id),onSuccess:re=>{re.status==="attached"?(u.invalidateQueries({queryKey:["archives"]}),d(c("archives.toast.timelapseAttached",{filename:re.filename}))):re.status==="exists"?d(c("archives.toast.timelapseAlreadyAttached")):re.status==="not_found"&&re.available_files&&re.available_files.length>0?(U(re.available_files),A(!0)):d(re.message||c("archives.toast.noMatchingTimelapse"),"warning")},onError:re=>{d(re.message||c("archives.toast.failedScanTimelapse"),"error")}}),me=mt({mutationFn:re=>ue.selectArchiveTimelapse(t.id,re),onSuccess:re=>{u.invalidateQueries({queryKey:["archives"]}),d(c("archives.toast.timelapseAttached",{filename:re.filename})),A(!1),U([])},onError:re=>{d(re.message||c("archives.toast.failedAttachTimelapse"),"error")}}),Ee=mt({mutationFn:()=>ue.deleteArchive(t.id),onSuccess:()=>{u.invalidateQueries({queryKey:["archives"]}),d(c("archives.toast.archiveDeleted"))},onError:()=>{d(c("archives.toast.failedDeleteArchive"),"error")}}),z=mt({mutationFn:()=>ue.toggleFavorite(t.id),onSuccess:re=>{u.invalidateQueries({queryKey:["archives"]}),d(re.is_favorite?c("archives.toast.addedToFavorites"):c("archives.toast.removedFromFavorites"))}}),{data:O}=at({queryKey:["archive-folders",t.id],queryFn:()=>ue.getLibraryFoldersByArchive(t.id)}),ee=mt({mutationFn:re=>ue.updateArchive(t.id,{project_id:re}),onSuccess:()=>{u.invalidateQueries({queryKey:["archives"]}),u.invalidateQueries({queryKey:["projects"]}),d(c("archives.toast.projectUpdated"))},onError:()=>{d(c("archives.toast.failedUpdateProject"),"error")}}),le=re=>{re.preventDefault(),be({x:re.clientX,y:re.clientY})},we=[...Cf(t.filename)?[{label:c("archives.menu.print"),icon:s.jsx(Ur,{className:"w-4 h-4"}),onClick:()=>v(!0),disabled:!p("archives","reprint",t.created_by_id),title:p("archives","reprint",t.created_by_id)?void 0:c("archives.permission.noReprint")},{label:c("archives.menu.schedule"),icon:s.jsx(si,{className:"w-4 h-4"}),onClick:()=>Z(!0),disabled:!f("queue:create"),title:f("queue:create")?void 0:c("archives.permission.noAddToQueue")},{label:c("archives.menu.openInBambuStudio"),icon:s.jsx(Kr,{className:"w-4 h-4"}),onClick:()=>{const re=t.print_name||t.filename||"model",Fe=`${window.location.origin}${ue.getArchiveForSlicer(t.id,re)}`;mu(Fe)}}]:[{label:c("archives.menu.slice"),icon:s.jsx(Kr,{className:"w-4 h-4"}),onClick:()=>{const re=t.print_name||t.filename||"model",Fe=`${window.location.origin}${ue.getArchiveForSlicer(t.id,re)}`;mu(Fe)}}],{label:t.external_url?c("archives.menu.externalLink"):c("archives.menu.viewOnMakerWorld"),icon:s.jsx(sh,{className:"w-4 h-4"}),onClick:()=>{const re=t.external_url||t.makerworld_url;re&&window.open(re,"_blank")},disabled:!t.external_url&&!t.makerworld_url},{label:"",divider:!0,onClick:()=>{}},{label:c("archives.menu.preview3d"),icon:s.jsx(lo,{className:"w-4 h-4"}),onClick:()=>b(!0)},{label:c("archives.menu.viewTimelapse"),icon:s.jsx(ah,{className:"w-4 h-4"}),onClick:()=>E(!0),disabled:!t.timelapse_path},{label:c("archives.menu.scanForTimelapse"),icon:s.jsx(K1,{className:"w-4 h-4"}),onClick:()=>fe.mutate(),disabled:!t.printer_id||!!t.timelapse_path||fe.isPending||!p("archives","update",t.created_by_id),title:p("archives","update",t.created_by_id)?void 0:c("archives.permission.noUpdateArchives")},{label:"",divider:!0,onClick:()=>{}},{label:t.source_3mf_path?c("archives.menu.downloadSource3mf"):c("archives.menu.uploadSource3mf"),icon:s.jsx(G1,{className:"w-4 h-4"}),onClick:()=>{if(t.source_3mf_path){const re=document.createElement("a");re.href=ue.getSource3mfDownloadUrl(t.id),re.download=`${t.print_name||t.filename}_source.3mf`,re.click()}else Ne.current?.click()},disabled:!t.source_3mf_path&&!p("archives","update",t.created_by_id),title:!t.source_3mf_path&&!p("archives","update",t.created_by_id)?c("archives.permission.noUploadFiles"):void 0},...t.source_3mf_path?[{label:c("archives.menu.replaceSource3mf"),icon:s.jsx(Ua,{className:"w-4 h-4"}),onClick:()=>Ne.current?.click(),disabled:!p("archives","update",t.created_by_id),title:p("archives","update",t.created_by_id)?void 0:c("archives.permission.noUpdateArchives")},{label:c("archives.menu.removeSource3mf"),icon:s.jsx(rn,{className:"w-4 h-4"}),onClick:()=>B(!0),danger:!0,disabled:!p("archives","update",t.created_by_id),title:p("archives","update",t.created_by_id)?void 0:c("archives.permission.noUpdateArchives")}]:[],{label:t.f3d_path?c("archives.menu.replaceF3d"):c("archives.menu.uploadF3d"),icon:s.jsx(lo,{className:"w-4 h-4"}),onClick:()=>Oe.current?.click(),disabled:!p("archives","update",t.created_by_id),title:p("archives","update",t.created_by_id)?void 0:c("archives.permission.noUpdateArchives")},...t.f3d_path?[{label:c("archives.menu.downloadF3d"),icon:s.jsx(yi,{className:"w-4 h-4"}),onClick:()=>{const re=document.createElement("a");re.href=ue.getF3dDownloadUrl(t.id),re.download=`${t.print_name||t.filename}.f3d`,re.click()}},{label:c("archives.menu.removeF3d"),icon:s.jsx(rn,{className:"w-4 h-4"}),onClick:()=>ne(!0),danger:!0,disabled:!p("archives","update",t.created_by_id),title:p("archives","update",t.created_by_id)?void 0:c("archives.permission.noUpdateArchives")}]:[],{label:"",divider:!0,onClick:()=>{}},{label:c("archives.menu.download"),icon:s.jsx(yi,{className:"w-4 h-4"}),onClick:()=>{const re=document.createElement("a");re.href=ue.getArchiveDownload(t.id),re.download=`${t.print_name||t.filename}.3mf`,re.click()},disabled:!f("archives:read"),title:f("archives:read")?void 0:c("archives.permission.noDownload")},{label:c("archives.menu.copyDownloadLink"),icon:s.jsx(Fl,{className:"w-4 h-4"}),onClick:()=>{const re=`${window.location.origin}${ue.getArchiveDownload(t.id)}`;navigator.clipboard.writeText(re).then(()=>{d(c("archives.toast.linkCopied"))}).catch(()=>{d(c("archives.toast.failedCopyLink"),"error")})},disabled:!f("archives:read"),title:f("archives:read")?void 0:c("archives.permission.noCopyLink")},{label:c("archives.menu.qrCode"),icon:s.jsx(MW,{className:"w-4 h-4"}),onClick:()=>$(!0)},{label:t.photos?.length?c("archives.menu.viewPhotosCount",{count:t.photos.length}):c("archives.menu.viewPhotos"),icon:s.jsx(Ug,{className:"w-4 h-4"}),onClick:()=>H(!0),disabled:!t.photos?.length},{label:c("archives.menu.projectPage"),icon:s.jsx(Ls,{className:"w-4 h-4"}),onClick:()=>V(!0)},{label:"",divider:!0,onClick:()=>{}},{label:t.is_favorite?c("archives.menu.removeFromFavorites"):c("archives.menu.addToFavorites"),icon:s.jsx(im,{className:`w-4 h-4 ${t.is_favorite?"fill-yellow-400 text-yellow-400":""}`}),onClick:()=>z.mutate(),disabled:!p("archives","update",t.created_by_id),title:p("archives","update",t.created_by_id)?void 0:c("archives.permission.noUpdateArchives")},{label:c("archives.menu.edit"),icon:s.jsx(Qi,{className:"w-4 h-4"}),onClick:()=>k(!0),disabled:!p("archives","update",t.created_by_id),title:p("archives","update",t.created_by_id)?void 0:c("archives.permission.noUpdateArchives")},...t.project_id&&t.project_name?[{label:c("archives.menu.goToProject",{name:t.project_name}),icon:s.jsx(Ja,{className:"w-4 h-4 text-bambu-green"}),onClick:()=>window.location.href="/projects"}]:[],{label:c("archives.menu.addToProject"),icon:s.jsx(Ja,{className:"w-4 h-4"}),onClick:()=>{},disabled:!p("archives","update",t.created_by_id),title:p("archives","update",t.created_by_id)?void 0:c("archives.permission.noUpdateArchives"),submenu:(()=>{const re=[];if(t.project_id&&re.push({label:c("archives.menu.removeFromProject"),icon:s.jsx(Rt,{className:"w-4 h-4"}),onClick:()=>ee.mutate(null),disabled:!p("archives","update",t.created_by_id)}),!a)re.push({label:c("archives.menu.loading"),icon:s.jsx(ht,{className:"w-4 h-4 animate-spin"}),onClick:()=>{},disabled:!0});else{const Fe=a.filter(He=>He.status==="active");Fe.length===0?re.push({label:c("archives.menu.noProjectsAvailable"),icon:s.jsx(Ja,{className:"w-4 h-4 opacity-50"}),onClick:()=>{},disabled:!0}):Fe.forEach(He=>{re.push({label:He.name,icon:s.jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:He.color||"#888"}}),onClick:()=>ee.mutate(He.id),disabled:t.project_id===He.id||!p("archives","update",t.created_by_id)})})}return re})()},{label:c(n?"archives.menu.deselect":"archives.menu.select"),icon:n?s.jsx(ol,{className:"w-4 h-4"}):s.jsx(ll,{className:"w-4 h-4"}),onClick:()=>r(t.id)},{label:"",divider:!0,onClick:()=>{}},{label:c("archives.menu.delete"),icon:s.jsx(rn,{className:"w-4 h-4"}),onClick:()=>N(!0),danger:!0,disabled:!p("archives","delete",t.created_by_id),title:p("archives","delete",t.created_by_id)?void 0:c("archives.permission.noDelete")}];return s.jsxs(_t,{"data-archive-id":t.id,className:`relative flex flex-col group ${n?"ring-2 ring-bambu-green":""} ${i?"cursor-pointer":""}`,style:o?{outline:"4px solid #facc15",outlineOffset:"2px"}:void 0,onContextMenu:le,onClick:i?()=>r(t.id):void 0,children:[i&&s.jsx("button",{className:"absolute top-2 left-2 z-10 p-1 rounded bg-black/50 hover:bg-black/70 transition-colors",onClick:re=>{re.stopPropagation(),r(t.id)},children:n?s.jsx(ol,{className:"w-5 h-5 text-bambu-green"}):s.jsx(ll,{className:"w-5 h-5 text-white"})}),s.jsxs("div",{className:"aspect-video bg-bambu-dark relative flex-shrink-0 overflow-hidden rounded-t-xl",onMouseEnter:()=>ie(!0),onMouseLeave:()=>ie(!1),children:[t.thumbnail_path?s.jsx("img",{src:xe!==null&&Ke.length>0?ue.getArchivePlateThumbnail(t.id,Ke[Y]?.index??0):ue.getArchiveThumbnail(t.id),alt:t.print_name||t.filename,className:"w-full h-full object-cover"}):s.jsx("div",{className:"w-full h-full flex items-center justify-center",children:s.jsx(Ou,{className:"w-12 h-12 text-bambu-dark-tertiary"})}),G&&Ke.length>1&&s.jsxs(s.Fragment,{children:[s.jsx("button",{className:`absolute left-1 top-1/2 -translate-y-1/2 p-1 rounded-full bg-black/60 hover:bg-black/80 transition-all ${m?"opacity-100":"opacity-0 group-hover:opacity-100"}`,onClick:re=>{re.stopPropagation(),de(Fe=>{const He=Fe??0;return He>0?He-1:Ke.length-1})},title:c("archives.card.previousPlate"),children:s.jsx(gh,{className:"w-4 h-4 text-white"})}),s.jsx("button",{className:`absolute right-1 top-1/2 -translate-y-1/2 p-1 rounded-full bg-black/60 hover:bg-black/80 transition-all ${m?"opacity-100":"opacity-0 group-hover:opacity-100"}`,onClick:re=>{re.stopPropagation(),de(Fe=>{const He=Fe??0;return He<Ke.length-1?He+1:0})},title:c("archives.card.nextPlate"),children:s.jsx(gs,{className:"w-4 h-4 text-white"})}),s.jsx("div",{className:`absolute bottom-1 left-1/2 -translate-x-1/2 flex gap-1 px-2 py-1 rounded-full bg-black/50 transition-all ${m?"opacity-100":"opacity-0 group-hover:opacity-100"}`,children:Ke.map((re,Fe)=>s.jsx("button",{className:`w-2 h-2 rounded-full transition-colors ${Fe===Y?"bg-bambu-green":"bg-white/50 hover:bg-white/80"}`,onClick:He=>{He.stopPropagation(),de(Fe)},title:re.name||c("archives.card.plateNumber",{index:re.index})},re.index))})]}),s.jsx("button",{className:`absolute top-2 left-2 p-1.5 rounded bg-black/50 hover:bg-black/70 transition-all ${m?"opacity-100":"opacity-0 group-hover:opacity-100"} ${i?"left-10":""}`,onClick:re=>{re.stopPropagation();const Fe=re.currentTarget.getBoundingClientRect();be({x:Fe.left,y:Fe.bottom+4})},title:c("archives.card.moreOptions"),children:s.jsx(ih,{className:"w-5 h-5 text-white"})}),s.jsx("button",{className:`absolute top-2 right-2 p-1 rounded transition-colors ${p("archives","update",t.created_by_id)?"bg-black/50 hover:bg-black/70":"bg-black/30 cursor-not-allowed"}`,onClick:re=>{re.stopPropagation(),p("archives","update",t.created_by_id)&&z.mutate()},disabled:!p("archives","update",t.created_by_id),title:p("archives","update",t.created_by_id)?t.is_favorite?c("archives.card.removeFromFavorites"):c("archives.card.addToFavorites"):c("archives.permission.noUpdateArchives"),children:s.jsx(im,{className:`w-5 h-5 ${t.is_favorite?"text-yellow-400 fill-yellow-400":"text-white"} ${p("archives","update",t.created_by_id)?"":"opacity-50"}`})}),(t.status==="failed"||t.status==="aborted")&&s.jsx("div",{className:"absolute top-2 left-12 px-2 py-1 rounded text-xs bg-status-error/80 text-white",children:t.status==="aborted"?c("archives.card.cancelled"):c("archives.card.failed")}),t.duplicate_count>0&&s.jsxs("div",{className:"absolute top-2 right-2 px-2 py-1 rounded text-xs bg-purple-500/80 text-white flex items-center gap-1",title:c("archives.card.duplicateTitle"),children:[s.jsx(Fl,{className:"w-3 h-3"}),c("archives.card.duplicate")]}),t.source_3mf_path&&s.jsx("button",{className:"absolute bottom-2 left-2 p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors",onClick:re=>{re.stopPropagation();const Fe=(t.print_name||t.filename||"source").replace(/\.gcode\.3mf$/i,"")+"_source",He=`${window.location.origin}${ue.getSource3mfForSlicer(t.id,Fe)}`;mu(He)},title:c("archives.card.openSource3mf"),children:s.jsx(G1,{className:"w-4 h-4 text-orange-400"})}),t.f3d_path&&s.jsx("button",{className:`absolute bottom-2 ${t.source_3mf_path?"left-12":"left-2"} p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors`,onClick:re=>{re.stopPropagation(),window.location.href=ue.getF3dDownloadUrl(t.id)},title:c("archives.card.downloadF3d"),children:s.jsx(lo,{className:"w-4 h-4 text-cyan-400"})}),t.timelapse_path&&s.jsx("button",{className:"absolute bottom-2 right-2 p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors",onClick:re=>{re.stopPropagation(),E(!0)},title:c("archives.card.viewTimelapse"),children:s.jsx(ah,{className:"w-4 h-4 text-bambu-green"})}),t.photos&&t.photos.length>0&&s.jsxs("button",{className:`absolute bottom-2 ${t.timelapse_path?"right-12":"right-2"} p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors`,onClick:re=>{re.stopPropagation(),H(!0)},title:t.photos.length===1?c("archives.card.viewPhoto"):c("archives.card.viewPhotos",{count:t.photos.length}),children:[s.jsx(Ug,{className:"w-4 h-4 text-blue-400"}),t.photos.length>1&&s.jsx("span",{className:"absolute -top-1 -right-1 w-4 h-4 bg-blue-500 rounded-full text-[10px] text-white flex items-center justify-center",children:t.photos.length})]}),O&&O.length>0&&s.jsx(Ds,{to:`/files?folder=${O[0].id}`,className:"absolute bottom-2 p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors",onClick:re=>re.stopPropagation(),title:c("archives.card.openFolder",{name:O[0].name}),style:{left:t.source_3mf_path?t.f3d_path?"5.5rem":"3rem":t.f3d_path?"3rem":"0.5rem"},children:s.jsx(Il,{className:"w-4 h-4 text-yellow-400"})})]}),s.jsxs(Mt,{className:"p-4 flex-1 flex flex-col",children:[s.jsx("h3",{className:"font-medium text-white mb-1 truncate",children:t.print_name||t.filename}),s.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-wrap",children:[s.jsx("p",{className:"text-xs text-bambu-gray",children:e}),s.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium ${Cf(t.filename)?"bg-bambu-green/20 text-bambu-green":"bg-orange-500/20 text-orange-400"}`,title:Cf(t.filename)?c("archives.card.slicedFile"):c("archives.card.sourceFile"),children:Cf(t.filename)?c("archives.card.gcode"):c("archives.card.source")}),t.project_name&&s.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded-full truncate max-w-[120px]",style:{backgroundColor:`${a?.find(re=>re.id===t.project_id)?.color||"#6b7280"}20`,color:a?.find(re=>re.id===t.project_id)?.color||"#6b7280"},title:c("archives.card.project",{name:t.project_name}),children:t.project_name})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs mb-4 min-h-[48px]",children:[(t.print_time_seconds||t.actual_time_seconds)&&s.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",title:t.time_accuracy?`Estimated: ${t0(t.print_time_seconds||0)}
- Actual: ${t0(t.actual_time_seconds||0)}
- Accuracy: ${t.time_accuracy.toFixed(0)}%`:t.actual_time_seconds?`Actual: ${t0(t.actual_time_seconds)}`:`Estimated: ${t0(t.print_time_seconds||0)}`,children:[s.jsx(er,{className:"w-3 h-3"}),t0(t.actual_time_seconds||t.print_time_seconds||0),t.time_accuracy&&s.jsxs("span",{className:`text-[10px] px-1 rounded ${t.time_accuracy>=95&&t.time_accuracy<=105?"bg-bambu-green/20 text-bambu-green":t.time_accuracy>105?"bg-blue-500/20 text-blue-400":"bg-orange-500/20 text-orange-400"}`,children:[t.time_accuracy>100?"+":"",(t.time_accuracy-100).toFixed(0),"%"]})]}),t.filament_used_grams&&s.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",children:[s.jsx(mc,{className:"w-3 h-3"}),t.filament_used_grams.toFixed(1),"g"]}),(t.layer_height||t.total_layers)&&s.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",children:[s.jsx(sl,{className:"w-3 h-3"}),t.total_layers&&s.jsx("span",{children:t.total_layers===1?c("archives.card.layer",{count:t.total_layers}):c("archives.card.layers",{count:t.total_layers})}),t.total_layers&&t.layer_height&&s.jsx("span",{className:"text-bambu-gray/50",children:"·"}),t.layer_height&&s.jsxs("span",{children:[t.layer_height,"mm"]})]}),t.object_count!=null&&t.object_count>0&&s.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",title:t.object_count===1?c("archives.card.object",{count:t.object_count}):c("archives.card.objects",{count:t.object_count}),children:[s.jsx(lo,{className:"w-3 h-3"}),t.object_count===1?c("archives.card.object",{count:t.object_count}):c("archives.card.objects",{count:t.object_count})]}),t.sliced_for_model&&s.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",title:c("archives.card.slicedFor",{model:t.sliced_for_model}),children:[s.jsx(Ur,{className:"w-3 h-3"}),t.sliced_for_model]}),t.filament_type&&s.jsxs("div",{className:"flex items-center gap-1.5 col-span-2",children:[s.jsx("span",{className:"text-bambu-gray text-xs",children:t.filament_type}),t.filament_color&&s.jsx("div",{className:"flex items-center gap-0.5 flex-wrap",children:t.filament_color.split(",").map((re,Fe)=>s.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:re},title:re},Fe))})]})]}),(t.tags||t.notes)&&s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 mb-3",children:[t.notes&&s.jsx("div",{className:"flex items-center gap-1 px-1.5 py-0.5 bg-blue-500/20 text-blue-400 rounded text-xs",title:t.notes,children:s.jsx(kW,{className:"w-3 h-3"})}),t.tags?.split(",").map((re,Fe)=>s.jsx("span",{className:"px-1.5 py-0.5 bg-bambu-dark-tertiary text-bambu-gray-light rounded text-xs",children:re.trim()},Fe))]}),s.jsx("div",{className:"flex-1"}),s.jsxs("div",{className:"flex items-center justify-between text-xs text-bambu-gray border-t border-bambu-dark-tertiary pt-3",children:[s.jsx("span",{children:Hg(t.created_at,l)}),s.jsxs("div",{className:"flex items-center gap-2",children:[t.created_by_username&&s.jsxs("span",{className:"flex items-center gap-1",title:c("archives.card.uploadedBy",{name:t.created_by_username}),children:[s.jsx(am,{className:"w-3 h-3"}),t.created_by_username]}),s.jsx("span",{children:XM(t.file_size)})]})]}),s.jsxs("div",{className:"flex gap-1 mt-3",children:[Cf(t.filename)?s.jsxs(s.Fragment,{children:[s.jsxs(Te,{variant:"primary",size:"sm",className:"flex-1 min-w-0",onClick:()=>v(!0),disabled:!p("archives","reprint",t.created_by_id),title:p("archives","reprint",t.created_by_id)?void 0:c("archives.card.noPermissionReprint"),children:[s.jsx(Ur,{className:"w-3 h-3 flex-shrink-0"}),s.jsx("span",{className:"hidden sm:inline",children:c("archives.card.reprint")})]}),s.jsxs(Te,{variant:"secondary",size:"sm",className:"flex-1 min-w-0",onClick:()=>Z(!0),disabled:!f("queue:create"),title:f("queue:create")?c("archives.card.schedulePrint"):c("archives.permission.noAddToQueue"),children:[s.jsx(si,{className:"w-3 h-3 flex-shrink-0"}),s.jsx("span",{className:"hidden sm:inline",children:c("archives.card.schedule")})]}),s.jsx(Te,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const re=t.print_name||t.filename||"model",Fe=`${window.location.origin}${ue.getArchiveForSlicer(t.id,re)}`;mu(Fe)},title:c("archives.card.openInBambuStudio"),children:s.jsx(Kr,{className:"w-3 h-3 sm:w-4 sm:h-4"})})]}):s.jsxs(Te,{variant:"primary",size:"sm",className:"flex-1 min-w-0",onClick:()=>{const re=t.print_name||t.filename||"model",Fe=`${window.location.origin}${ue.getArchiveForSlicer(t.id,re)}`;mu(Fe)},title:c("archives.card.openInBambuStudioToSlice"),children:[s.jsx(Kr,{className:"w-3 h-3 flex-shrink-0"}),s.jsx("span",{className:"hidden sm:inline",children:c("archives.card.slice")})]}),s.jsx(Te,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const re=t.external_url||t.makerworld_url;re&&window.open(re,"_blank")},disabled:!t.external_url&&!t.makerworld_url,title:t.external_url?c("archives.card.externalLink"):t.makerworld_url?c("archives.card.makerWorld",{designer:t.designer||c("archives.card.viewProject")}):c("archives.card.noExternalLink"),children:s.jsx(sh,{className:`w-3 h-3 sm:w-4 sm:h-4 ${!t.external_url&&!t.makerworld_url?"opacity-20":""}`})}),s.jsx(Te,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>b(!0),title:c("archives.card.preview3d"),children:s.jsx(lo,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),s.jsx(Te,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const re=document.createElement("a");re.href=ue.getArchiveDownload(t.id),re.download=`${t.print_name||t.filename}.3mf`,re.click()},title:c("archives.card.download"),children:s.jsx(yi,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),s.jsx(Te,{variant:"ghost",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>k(!0),disabled:!p("archives","update",t.created_by_id),title:p("archives","update",t.created_by_id)?c("archives.card.edit"):c("archives.card.noPermissionEdit"),children:s.jsx(Qi,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),s.jsx(Te,{variant:"ghost",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>N(!0),disabled:!p("archives","delete",t.created_by_id),title:p("archives","delete",t.created_by_id)?c("archives.card.delete"):c("archives.card.noPermissionDelete"),children:s.jsx(rn,{className:"w-3 h-3 sm:w-4 sm:h-4 text-red-400"})})]})]}),T&&s.jsx(yee,{archive:t,onClose:()=>k(!1)}),x&&s.jsx(pee,{archiveId:t.id,title:t.print_name||t.filename,onClose:()=>b(!1)}),y&&s.jsx(jh,{mode:"reprint",archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>v(!1)}),S&&s.jsx(Zn,{title:c("archives.modal.deleteArchive"),message:c("archives.modal.deleteConfirm",{name:t.print_name||t.filename}),confirmText:c("archives.modal.deleteButton"),variant:"danger",onConfirm:()=>{Ee.mutate(),N(!1)},onCancel:()=>N(!1)}),ae&&s.jsx(Zn,{title:c("archives.modal.removeSource3mf"),message:c("archives.modal.removeSource3mfConfirm",{name:t.print_name||t.filename}),confirmText:c("archives.modal.removeButton"),variant:"danger",onConfirm:()=>{q.mutate(),B(!1)},onCancel:()=>B(!1)}),X&&s.jsx(Zn,{title:c("archives.modal.removeF3d"),message:c("archives.modal.removeF3dConfirm",{name:t.print_name||t.filename}),confirmText:c("archives.modal.removeButton"),variant:"danger",onConfirm:()=>{I.mutate(),ne(!1)},onCancel:()=>ne(!1)}),se&&s.jsx(vee,{x:se.x,y:se.y,items:we,onClose:()=>be(null)}),C&&t.timelapse_path&&s.jsx(are,{src:ue.getArchiveTimelapse(t.id),title:c("archives.modal.timelapse",{name:t.print_name||t.filename}),downloadFilename:`${t.print_name||t.filename}_timelapse.mp4`,archiveId:t.id,onClose:()=>E(!1),onEdit:()=>{u.invalidateQueries({queryKey:["archives"]}),E(!1)}}),D&&R.length>0&&s.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",children:s.jsxs("div",{className:"bg-card-dark rounded-lg max-w-lg w-full max-h-[80vh] flex flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-700",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-semibold text-white",children:"Select Timelapse"}),s.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"No auto-match found. Select the timelapse for this print:"})]}),s.jsx("button",{onClick:()=>{A(!1),U([])},className:"text-gray-400 hover:text-white p-1",children:s.jsx(Rt,{className:"w-5 h-5"})})]}),s.jsx("div",{className:"overflow-y-auto flex-1 p-2",children:R.map(re=>s.jsxs("button",{onClick:()=>me.mutate(re.name),disabled:me.isPending,className:"w-full text-left p-3 rounded-lg hover:bg-gray-700 transition-colors flex items-center gap-3 disabled:opacity-50",children:[s.jsx(ah,{className:"w-8 h-8 text-bambu-green flex-shrink-0"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-white font-medium truncate",children:re.name}),s.jsxs("p",{className:"text-sm text-gray-400",children:[XM(re.size),re.mtime&&` • ${Hg(re.mtime,l)}`]})]})]},re.name))}),s.jsx("div",{className:"p-4 border-t border-gray-700",children:s.jsx(Te,{variant:"secondary",onClick:()=>{A(!1),U([])},className:"w-full",children:"Cancel"})})]})}),F&&s.jsx(wee,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>$(!1)}),j&&t.photos&&t.photos.length>0&&s.jsx(_ee,{archiveId:t.id,archiveName:t.print_name||t.filename,photos:t.photos,onClose:()=>H(!1),onDelete:async re=>{try{await ue.deleteArchivePhoto(t.id,re),u.invalidateQueries({queryKey:["archives"]}),d(c("archives.toast.photoDeleted"))}catch{d(c("archives.toast.failedDeletePhoto"),"error")}}}),K&&s.jsx(ire,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>V(!1)}),Q&&s.jsx(jh,{mode:"add-to-queue",archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>Z(!1)}),s.jsx("input",{ref:Ne,type:"file",accept:".3mf",className:"hidden",onChange:re=>{const Fe=re.target.files?.[0];Fe&&ce.mutate(Fe),re.target.value=""}}),s.jsx("input",{ref:Oe,type:"file",accept:".f3d",className:"hidden",onChange:re=>{const Fe=re.target.files?.[0];Fe&&te.mutate(Fe),re.target.value=""}})]})}function tqe({archive:t,printerName:e,isSelected:n,onSelect:r,selectionMode:i,projects:a,isHighlighted:o,t:l}){const c=an(),{showToast:u}=$n(),{hasPermission:d,canModify:f}=Ai(),[p,m]=_.useState(!1),[x,b]=_.useState(!1),[y,v]=_.useState(!1),[S,N]=_.useState(!1),[T,k]=_.useState(!1),[C,E]=_.useState(!1),[D,A]=_.useState(!1),[R,U]=_.useState([]),[F,$]=_.useState(!1),[j,H]=_.useState(!1),[K,V]=_.useState(!1),[Q,Z]=_.useState(!1),[ae,B]=_.useState(!1),[X,ne]=_.useState(null),se=_.useRef(null),be=_.useRef(null),xe=mt({mutationFn:I=>ue.uploadSource3mf(t.id,I),onSuccess:I=>{c.invalidateQueries({queryKey:["archives"]}),u(l("archives.toast.source3mfAttached",{filename:I.filename}))},onError:I=>{u(I.message||l("archives.toast.failedUploadSource3mf"),"error")}}),de=mt({mutationFn:()=>ue.deleteSource3mf(t.id),onSuccess:()=>{c.invalidateQueries({queryKey:["archives"]}),u(l("archives.toast.source3mfRemoved"))},onError:I=>{u(I.message||l("archives.toast.failedRemoveSource3mf"),"error")}}),Pe=mt({mutationFn:I=>ue.uploadF3d(t.id,I),onSuccess:I=>{c.invalidateQueries({queryKey:["archives"]}),u(l("archives.toast.f3dAttached",{filename:I.filename}))},onError:I=>{u(I.message||l("archives.toast.failedUploadF3d"),"error")}}),ie=mt({mutationFn:()=>ue.deleteF3d(t.id),onSuccess:()=>{c.invalidateQueries({queryKey:["archives"]}),u(l("archives.toast.f3dRemoved"))},onError:I=>{u(I.message||l("archives.toast.failedRemoveF3d"),"error")}}),Ne=mt({mutationFn:()=>ue.scanArchiveTimelapse(t.id),onSuccess:I=>{I.status==="attached"?(c.invalidateQueries({queryKey:["archives"]}),u(l("archives.toast.timelapseAttached",{filename:I.filename}))):I.status==="exists"?u(l("archives.toast.timelapseAlreadyAttached")):I.status==="not_found"&&I.available_files&&I.available_files.length>0?(U(I.available_files),A(!0)):u(I.message||l("archives.toast.noMatchingTimelapse"),"warning")},onError:I=>{u(I.message||l("archives.toast.failedScanTimelapse"),"error")}}),Oe=mt({mutationFn:I=>ue.selectArchiveTimelapse(t.id,I),onSuccess:I=>{c.invalidateQueries({queryKey:["archives"]}),u(l("archives.toast.timelapseAttached",{filename:I.filename})),A(!1),U([])},onError:I=>{u(I.message||l("archives.toast.failedAttachTimelapse"),"error")}}),ge=mt({mutationFn:()=>ue.deleteArchive(t.id),onSuccess:()=>{c.invalidateQueries({queryKey:["archives"]}),u(l("archives.toast.archiveDeleted"))},onError:()=>{u(l("archives.toast.failedDeleteArchive"),"error")}}),Ke=mt({mutationFn:()=>ue.toggleFavorite(t.id),onSuccess:I=>{c.invalidateQueries({queryKey:["archives"]}),u(I.is_favorite?l("archives.toast.addedToFavorites"):l("archives.toast.removedFromFavorites"))}}),{data:G}=at({queryKey:["archive-folders",t.id],queryFn:()=>ue.getLibraryFoldersByArchive(t.id)}),Y=mt({mutationFn:I=>ue.updateArchive(t.id,{project_id:I}),onSuccess:()=>{c.invalidateQueries({queryKey:["archives"]}),c.invalidateQueries({queryKey:["projects"]}),u(l("archives.toast.projectUpdated"))},onError:()=>{u(l("archives.toast.failedUpdateProject"),"error")}}),ce=I=>{I.preventDefault(),ne({x:I.clientX,y:I.clientY})},te=[...Cf(t.filename)?[{label:l("archives.menu.print"),icon:s.jsx(Ur,{className:"w-4 h-4"}),onClick:()=>v(!0),disabled:!f("archives","reprint",t.created_by_id),title:f("archives","reprint",t.created_by_id)?void 0:l("archives.permission.noReprint")},{label:l("archives.menu.schedule"),icon:s.jsx(si,{className:"w-4 h-4"}),onClick:()=>N(!0),disabled:!d("queue:create"),title:d("queue:create")?void 0:l("archives.permission.noAddToQueue")},{label:l("archives.menu.openInBambuStudio"),icon:s.jsx(Kr,{className:"w-4 h-4"}),onClick:()=>{const I=t.print_name||t.filename||"model",fe=`${window.location.origin}${ue.getArchiveForSlicer(t.id,I)}`;mu(fe)}}]:[{label:l("archives.menu.slice"),icon:s.jsx(Kr,{className:"w-4 h-4"}),onClick:()=>{const I=t.print_name||t.filename||"model",fe=`${window.location.origin}${ue.getArchiveForSlicer(t.id,I)}`;mu(fe)}}],{label:t.external_url?l("archives.menu.externalLink"):l("archives.menu.viewOnMakerWorld"),icon:s.jsx(sh,{className:"w-4 h-4"}),onClick:()=>{const I=t.external_url||t.makerworld_url;I&&window.open(I,"_blank")},disabled:!t.external_url&&!t.makerworld_url},{label:"",divider:!0,onClick:()=>{}},{label:l("archives.menu.preview3d"),icon:s.jsx(lo,{className:"w-4 h-4"}),onClick:()=>k(!0)},{label:l("archives.menu.viewTimelapse"),icon:s.jsx(ah,{className:"w-4 h-4"}),onClick:()=>E(!0),disabled:!t.timelapse_path},{label:l("archives.menu.scanForTimelapse"),icon:s.jsx(K1,{className:"w-4 h-4"}),onClick:()=>Ne.mutate(),disabled:!t.printer_id||!!t.timelapse_path||Ne.isPending||!f("archives","update",t.created_by_id),title:f("archives","update",t.created_by_id)?void 0:l("archives.permission.noUpdateArchives")},{label:"",divider:!0,onClick:()=>{}},{label:t.source_3mf_path?l("archives.menu.downloadSource3mf"):l("archives.menu.uploadSource3mf"),icon:s.jsx(G1,{className:"w-4 h-4"}),onClick:()=>{if(t.source_3mf_path){const I=document.createElement("a");I.href=ue.getSource3mfDownloadUrl(t.id),I.download=`${t.print_name||t.filename}_source.3mf`,I.click()}else se.current?.click()},disabled:!t.source_3mf_path&&!f("archives","update",t.created_by_id),title:!t.source_3mf_path&&!f("archives","update",t.created_by_id)?l("archives.permission.noUploadFiles"):void 0},...t.source_3mf_path?[{label:l("archives.menu.replaceSource3mf"),icon:s.jsx(Ua,{className:"w-4 h-4"}),onClick:()=>se.current?.click(),disabled:!f("archives","update",t.created_by_id),title:f("archives","update",t.created_by_id)?void 0:l("archives.permission.noUpdateArchives")},{label:l("archives.menu.removeSource3mf"),icon:s.jsx(rn,{className:"w-4 h-4"}),onClick:()=>Z(!0),danger:!0,disabled:!f("archives","update",t.created_by_id),title:f("archives","update",t.created_by_id)?void 0:l("archives.permission.noUpdateArchives")}]:[],{label:t.f3d_path?l("archives.menu.replaceF3d"):l("archives.menu.uploadF3d"),icon:s.jsx(lo,{className:"w-4 h-4"}),onClick:()=>be.current?.click(),disabled:!f("archives","update",t.created_by_id),title:f("archives","update",t.created_by_id)?void 0:l("archives.permission.noUpdateArchives")},...t.f3d_path?[{label:l("archives.menu.downloadF3d"),icon:s.jsx(yi,{className:"w-4 h-4"}),onClick:()=>{const I=document.createElement("a");I.href=ue.getF3dDownloadUrl(t.id),I.download=`${t.print_name||t.filename}.f3d`,I.click()}},{label:l("archives.menu.removeF3d"),icon:s.jsx(rn,{className:"w-4 h-4"}),onClick:()=>B(!0),danger:!0,disabled:!f("archives","update",t.created_by_id),title:f("archives","update",t.created_by_id)?void 0:l("archives.permission.noUpdateArchives")}]:[],{label:"",divider:!0,onClick:()=>{}},{label:l("archives.menu.download"),icon:s.jsx(yi,{className:"w-4 h-4"}),onClick:()=>{const I=document.createElement("a");I.href=ue.getArchiveDownload(t.id),I.download=`${t.print_name||t.filename}.3mf`,I.click()},disabled:!d("archives:read"),title:d("archives:read")?void 0:l("archives.permission.noDownload")},{label:l("archives.menu.copyDownloadLink"),icon:s.jsx(Fl,{className:"w-4 h-4"}),onClick:()=>{const I=`${window.location.origin}${ue.getArchiveDownload(t.id)}`;navigator.clipboard.writeText(I).then(()=>{u(l("archives.toast.linkCopied"))}).catch(()=>{u(l("archives.toast.failedCopyLink"),"error")})},disabled:!d("archives:read"),title:d("archives:read")?void 0:l("archives.permission.noCopyLink")},{label:l("archives.menu.qrCode"),icon:s.jsx(MW,{className:"w-4 h-4"}),onClick:()=>$(!0)},{label:t.photos?.length?l("archives.menu.viewPhotosCount",{count:t.photos.length}):l("archives.menu.viewPhotos"),icon:s.jsx(Ug,{className:"w-4 h-4"}),onClick:()=>H(!0),disabled:!t.photos?.length},{label:l("archives.menu.projectPage"),icon:s.jsx(Ls,{className:"w-4 h-4"}),onClick:()=>V(!0)},{label:"",divider:!0,onClick:()=>{}},{label:t.is_favorite?l("archives.menu.removeFromFavorites"):l("archives.menu.addToFavorites"),icon:s.jsx(im,{className:`w-4 h-4 ${t.is_favorite?"fill-yellow-400 text-yellow-400":""}`}),onClick:()=>Ke.mutate(),disabled:!f("archives","update",t.created_by_id),title:f("archives","update",t.created_by_id)?void 0:l("archives.permission.noUpdateArchives")},{label:l("archives.menu.edit"),icon:s.jsx(Qi,{className:"w-4 h-4"}),onClick:()=>m(!0),disabled:!f("archives","update",t.created_by_id),title:f("archives","update",t.created_by_id)?void 0:l("archives.permission.noUpdateArchives")},...t.project_id&&t.project_name?[{label:l("archives.menu.goToProject",{name:t.project_name}),icon:s.jsx(Ja,{className:"w-4 h-4 text-bambu-green"}),onClick:()=>window.location.href="/projects"}]:[],{label:l("archives.menu.addToProject"),icon:s.jsx(Ja,{className:"w-4 h-4"}),onClick:()=>{},submenu:(()=>{const I=[];if(t.project_id&&I.push({label:l("archives.menu.removeFromProject"),icon:s.jsx(Rt,{className:"w-4 h-4"}),onClick:()=>Y.mutate(null)}),!a)I.push({label:l("archives.menu.loading"),icon:s.jsx(ht,{className:"w-4 h-4 animate-spin"}),onClick:()=>{},disabled:!0});else{const fe=a.filter(me=>me.status==="active");fe.length===0?I.push({label:l("archives.menu.noProjectsAvailable"),icon:s.jsx(Ja,{className:"w-4 h-4 opacity-50"}),onClick:()=>{},disabled:!0}):fe.forEach(me=>{I.push({label:me.name,icon:s.jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:me.color||"#888"}}),onClick:()=>Y.mutate(me.id),disabled:t.project_id===me.id})})}return I})()},{label:l(n?"archives.menu.deselect":"archives.menu.select"),icon:n?s.jsx(ol,{className:"w-4 h-4"}):s.jsx(ll,{className:"w-4 h-4"}),onClick:()=>r(t.id)},{label:"",divider:!0,onClick:()=>{}},{label:l("archives.menu.delete"),icon:s.jsx(rn,{className:"w-4 h-4"}),onClick:()=>b(!0),danger:!0,disabled:!f("archives","delete",t.created_by_id),title:f("archives","delete",t.created_by_id)?void 0:l("archives.permission.noDelete")}];return s.jsxs(s.Fragment,{children:[s.jsxs("div",{"data-archive-id":t.id,className:`grid grid-cols-12 gap-4 px-4 py-3 items-center hover:bg-bambu-dark-tertiary/30 ${n?"bg-bambu-green/10":""}`,style:o?{outline:"4px solid #facc15",outlineOffset:"-4px"}:void 0,onContextMenu:ce,children:[s.jsxs("div",{className:"col-span-1 flex items-center gap-2",children:[i&&s.jsx("button",{onClick:()=>r(t.id),children:n?s.jsx(ol,{className:"w-4 h-4 text-bambu-green"}):s.jsx(ll,{className:"w-4 h-4 text-bambu-gray"})}),t.thumbnail_path?s.jsx("img",{src:ue.getArchiveThumbnail(t.id),alt:"",className:"w-10 h-10 object-cover rounded"}):s.jsx("div",{className:"w-10 h-10 bg-bambu-dark rounded flex items-center justify-center",children:s.jsx(Ou,{className:"w-5 h-5 text-bambu-dark-tertiary"})})]}),s.jsxs("div",{className:"col-span-4",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("p",{className:"text-white text-sm truncate",children:t.print_name||t.filename}),t.timelapse_path&&s.jsx("span",{title:l("archives.list.hasTimelapse"),children:s.jsx(ah,{className:"w-3.5 h-3.5 text-bambu-green flex-shrink-0"})}),G&&G.length>0&&s.jsx(Ds,{to:`/files?folder=${G[0].id}`,className:"flex-shrink-0",title:l("archives.card.openFolder",{name:G[0].name}),onClick:I=>I.stopPropagation(),children:s.jsx(Il,{className:"w-3.5 h-3.5 text-yellow-400"})})]}),(t.filament_type||t.sliced_for_model)&&s.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[t.sliced_for_model&&s.jsxs("span",{className:"text-xs text-bambu-gray flex items-center gap-1",title:l("archives.card.slicedFor",{model:t.sliced_for_model}),children:[s.jsx(Ur,{className:"w-2.5 h-2.5"}),t.sliced_for_model]}),t.sliced_for_model&&t.filament_type&&s.jsx("span",{className:"text-bambu-gray/50",children:"·"}),t.filament_type&&s.jsx("span",{className:"text-xs text-bambu-gray",children:t.filament_type}),t.filament_color&&s.jsx("div",{className:"flex items-center gap-0.5 flex-wrap",children:t.filament_color.split(",").map((I,fe)=>s.jsx("div",{className:"w-2.5 h-2.5 rounded-full border border-white/20",style:{backgroundColor:I},title:I},fe))})]})]}),s.jsx("div",{className:"col-span-2 text-sm text-bambu-gray truncate",children:e}),s.jsxs("div",{className:"col-span-2 text-sm text-bambu-gray",children:[s.jsx("div",{children:Bg(t.created_at)}),t.created_by_username&&s.jsxs("div",{className:"flex items-center gap-1 text-xs opacity-75",title:l("archives.card.uploadedBy",{name:t.created_by_username}),children:[s.jsx(am,{className:"w-3 h-3"}),t.created_by_username]})]}),s.jsx("div",{className:"col-span-1 text-sm text-bambu-gray",children:XM(t.file_size)}),s.jsxs("div",{className:"col-span-2 flex justify-end gap-1",children:[s.jsx(Te,{variant:"ghost",size:"sm",onClick:()=>{const I=t.print_name||t.filename||"model",fe=`${window.location.origin}${ue.getArchiveForSlicer(t.id,I)}`;mu(fe)},title:l("archives.card.openInBambuStudio"),children:s.jsx(Kr,{className:"w-4 h-4"})}),(t.external_url||t.makerworld_url)&&s.jsx(Te,{variant:"ghost",size:"sm",onClick:()=>window.open(t.external_url||t.makerworld_url,"_blank"),title:t.external_url?l("archives.card.externalLink"):"MakerWorld",children:s.jsx(sh,{className:"w-4 h-4"})}),s.jsx(Te,{variant:"ghost",size:"sm",onClick:()=>{const I=document.createElement("a");I.href=ue.getArchiveDownload(t.id),I.download=`${t.print_name||t.filename}.3mf`,I.click()},title:l("archives.card.download"),children:s.jsx(yi,{className:"w-4 h-4"})}),s.jsx(Te,{variant:"ghost",size:"sm",onClick:()=>m(!0),disabled:!f("archives","update",t.created_by_id),title:f("archives","update",t.created_by_id)?l("archives.card.edit"):l("archives.card.noPermissionEdit"),children:s.jsx(Qi,{className:"w-4 h-4"})}),s.jsx(Te,{variant:"ghost",size:"sm",onClick:()=>b(!0),disabled:!f("archives","delete",t.created_by_id),title:f("archives","delete",t.created_by_id)?l("archives.card.delete"):l("archives.card.noPermissionDelete"),children:s.jsx(rn,{className:"w-4 h-4 text-red-400"})}),s.jsx(Te,{variant:"ghost",size:"sm",onClick:I=>{const fe=I.currentTarget.getBoundingClientRect();ne({x:fe.left,y:fe.bottom+4})},title:l("archives.card.moreOptions"),children:s.jsx(ih,{className:"w-4 h-4"})})]})]}),p&&s.jsx(yee,{archive:t,onClose:()=>m(!1)}),T&&s.jsx(pee,{archiveId:t.id,title:t.print_name||t.filename,onClose:()=>k(!1)}),y&&s.jsx(jh,{mode:"reprint",archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>v(!1)}),x&&s.jsx(Zn,{title:l("archives.modal.deleteArchive"),message:l("archives.modal.deleteConfirm",{name:t.print_name||t.filename}),confirmText:l("archives.modal.deleteButton"),variant:"danger",onConfirm:()=>{ge.mutate(),b(!1)},onCancel:()=>b(!1)}),Q&&s.jsx(Zn,{title:l("archives.modal.removeSource3mf"),message:l("archives.modal.removeSource3mfConfirm",{name:t.print_name||t.filename}),confirmText:l("archives.modal.removeButton"),variant:"danger",onConfirm:()=>{de.mutate(),Z(!1)},onCancel:()=>Z(!1)}),ae&&s.jsx(Zn,{title:l("archives.modal.removeF3d"),message:l("archives.modal.removeF3dConfirm",{name:t.print_name||t.filename}),confirmText:l("archives.modal.removeButton"),variant:"danger",onConfirm:()=>{ie.mutate(),B(!1)},onCancel:()=>B(!1)}),X&&s.jsx(vee,{x:X.x,y:X.y,items:te,onClose:()=>ne(null)}),C&&t.timelapse_path&&s.jsx(are,{src:ue.getArchiveTimelapse(t.id),title:l("archives.modal.timelapse",{name:t.print_name||t.filename}),downloadFilename:`${t.print_name||t.filename}_timelapse.mp4`,archiveId:t.id,onClose:()=>E(!1),onEdit:()=>{c.invalidateQueries({queryKey:["archives"]}),E(!1)}}),D&&R.length>0&&s.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",children:s.jsxs("div",{className:"bg-card-dark rounded-lg max-w-lg w-full max-h-[80vh] flex flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-700",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-semibold text-white",children:"Select Timelapse"}),s.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"No auto-match found. Select the timelapse for this print:"})]}),s.jsx("button",{onClick:()=>{A(!1),U([])},className:"text-gray-400 hover:text-white p-1",children:s.jsx(Rt,{className:"w-5 h-5"})})]}),s.jsx("div",{className:"overflow-y-auto flex-1 p-2",children:R.map(I=>s.jsxs("button",{onClick:()=>Oe.mutate(I.name),disabled:Oe.isPending,className:"w-full text-left p-3 rounded-lg hover:bg-gray-700 transition-colors mb-1",children:[s.jsx("div",{className:"font-medium text-white",children:I.name}),s.jsxs("div",{className:"text-sm text-gray-400 flex gap-3",children:[s.jsx("span",{children:XM(I.size)}),I.mtime&&s.jsx("span",{children:Bg(I.mtime)})]})]},I.name))})]})}),F&&s.jsx(wee,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>$(!1)}),j&&t.photos&&s.jsx(_ee,{archiveId:t.id,archiveName:t.print_name||t.filename,photos:t.photos,onClose:()=>H(!1),onDelete:async I=>{try{await ue.deleteArchivePhoto(t.id,I),c.invalidateQueries({queryKey:["archives"]}),u(l("archives.toast.photoDeleted"))}catch{u(l("archives.toast.failedDeletePhoto"),"error")}}}),K&&s.jsx(ire,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>V(!1)}),S&&s.jsx(jh,{mode:"add-to-queue",archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>N(!1)}),s.jsx("input",{ref:se,type:"file",accept:".3mf",className:"hidden",onChange:I=>{const fe=I.target.files?.[0];fe&&xe.mutate(fe),I.target.value=""}}),s.jsx("input",{ref:be,type:"file",accept:".f3d",className:"hidden",onChange:I=>{const fe=I.target.files?.[0];fe&&Pe.mutate(fe),I.target.value=""}})]})}const nqe=[{id:"all",label:"All Archives",icon:s.jsx(Il,{className:"w-4 h-4"})},{id:"recent",label:"Last 24 Hours",icon:s.jsx(er,{className:"w-4 h-4"})},{id:"this-week",label:"This Week",icon:s.jsx(si,{className:"w-4 h-4"})},{id:"this-month",label:"This Month",icon:s.jsx(si,{className:"w-4 h-4"})},{id:"favorites",label:"Favorites",icon:s.jsx(im,{className:"w-4 h-4"})},{id:"failed",label:"Failed Prints",icon:s.jsx(Hi,{className:"w-4 h-4"})},{id:"duplicates",label:"Duplicates",icon:s.jsx(Fl,{className:"w-4 h-4"})}];function rqe(){const{t}=Hn(),e=an(),{showToast:n}=$n(),{hasPermission:r,hasAnyPermission:i}=Ai(),a=_.useRef(null),[o,l]=_.useState(""),[c,u]=_.useState(()=>{const W=localStorage.getItem("archiveFilterPrinter");return W?Number(W):null}),[d,f]=_.useState(()=>localStorage.getItem("archiveFilterMaterial")),[p,m]=_.useState(()=>{const W=localStorage.getItem("archiveFilterColors");return W?new Set(JSON.parse(W)):new Set}),[x,b]=_.useState(()=>localStorage.getItem("archiveColorFilterMode")||"or"),[y,v]=_.useState(()=>localStorage.getItem("archiveFilterFavorites")==="true"),[S,N]=_.useState(()=>localStorage.getItem("archiveHideFailed")==="true"),[T,k]=_.useState(()=>localStorage.getItem("archiveFilterTag")),[C,E]=_.useState(()=>localStorage.getItem("archiveFilterFileType")||"all"),[D,A]=_.useState(!1),[R,U]=_.useState([]),[F,$]=_.useState(!1),[j,H]=_.useState(new Set),[K,V]=_.useState(!1),[Q,Z]=_.useState(!1),[ae,B]=_.useState(!1),[X,ne]=_.useState(!1),[se,be]=_.useState(()=>localStorage.getItem("archiveViewMode")||"grid"),[xe,de]=_.useState(()=>localStorage.getItem("archiveSortBy")||"date-desc"),[Pe,ie]=_.useState(()=>localStorage.getItem("archiveCollection")||"all"),[Ne,Oe]=_.useState(!1),[ge,Ke]=_.useState(!1),[G,Y]=_.useState(!1),[ce,q]=_.useState(!1),[te,I]=_.useState(null);_.useEffect(()=>{if(te){const W=setTimeout(()=>{const Ye=document.querySelector(`[data-archive-id="${te}"]`);Ye&&Ye.scrollIntoView({behavior:"smooth",block:"center"})},100),De=setTimeout(()=>I(null),5e3);return()=>{clearTimeout(W),clearTimeout(De)}}},[te]);const{data:fe,isLoading:me}=at({queryKey:["archives",c],queryFn:()=>ue.getArchives(c||void 0)}),{data:Ee}=at({queryKey:["printers"],queryFn:ue.getPrinters}),{data:z}=at({queryKey:["projects"],queryFn:()=>ue.getProjects()}),{data:O}=at({queryKey:["settings"],queryFn:ue.getSettings}),ee=O?.time_format||"system",le=mt({mutationFn:async W=>(await Promise.all(W.map(De=>ue.deleteArchive(De))),W.length),onSuccess:W=>{e.invalidateQueries({queryKey:["archives"]}),H(new Set),n(`${W} archive${W!==1?"s":""} deleted`)},onError:()=>{n(t("archives.toast.failedDeleteArchives"),"error")}});_.useEffect(()=>{c!==null?localStorage.setItem("archiveFilterPrinter",c.toString()):localStorage.removeItem("archiveFilterPrinter")},[c]),_.useEffect(()=>{d?localStorage.setItem("archiveFilterMaterial",d):localStorage.removeItem("archiveFilterMaterial")},[d]),_.useEffect(()=>{localStorage.setItem("archiveFilterColors",JSON.stringify([...p]))},[p]),_.useEffect(()=>{localStorage.setItem("archiveColorFilterMode",x)},[x]),_.useEffect(()=>{localStorage.setItem("archiveFilterFavorites",y.toString())},[y]),_.useEffect(()=>{localStorage.setItem("archiveHideFailed",S.toString())},[S]),_.useEffect(()=>{T?localStorage.setItem("archiveFilterTag",T):localStorage.removeItem("archiveFilterTag")},[T]),_.useEffect(()=>{localStorage.setItem("archiveFilterFileType",C)},[C]),_.useEffect(()=>{localStorage.setItem("archiveViewMode",se)},[se]),_.useEffect(()=>{localStorage.setItem("archiveSortBy",xe)},[xe]),_.useEffect(()=>{localStorage.setItem("archiveCollection",Pe)},[Pe]);const _e=new Map(Ee?.map(W=>[W.id,W.name])||[]),we=[...new Set(fe?.flatMap(W=>W.filament_type?.split(", ")||[]).filter(Boolean)||[])].sort(),re=[...new Set(fe?.flatMap(W=>W.filament_color?.split(",")||[]).filter(Boolean)||[])],Fe=[...new Set(fe?.flatMap(W=>W.tags?.split(",").map(De=>De.trim())||[]).filter(Boolean)||[])].sort(),He=fe?.filter(W=>{const De=new Date,Ye=Ii(W.created_at)||new Date(0);let xt=!0;switch(Pe){case"recent":xt=De.getTime()-Ye.getTime()<1440*60*1e3;break;case"this-week":xt=De.getTime()-Ye.getTime()<10080*60*1e3;break;case"this-month":xt=Ye.getMonth()===De.getMonth()&&Ye.getFullYear()===De.getFullYear();break;case"favorites":xt=W.is_favorite===!0;break;case"failed":xt=W.status==="failed"||W.status==="aborted";break;case"duplicates":xt=W.duplicate_count>0;break}const ft=(W.print_name||W.filename).toLowerCase().includes(o.toLowerCase()),Bt=!d||W.filament_type?.split(", ").includes(d),Lt=W.filament_color?.split(",")||[],vn=p.size===0||(x==="or"?Lt.some(Fn=>p.has(Fn)):[...p].every(Fn=>Lt.includes(Fn))),Jt=Pe==="favorites"||!y||W.is_favorite,ir=Pe==="failed"||!S||W.status!=="failed"&&W.status!=="aborted",fr=W.tags?.split(",").map(Fn=>Fn.trim())||[],Dn=!T||fr.includes(T),ln=Cf(W.filename);return xt&&ft&&Bt&&vn&&Jt&&ir&&Dn&&(C==="all"||C==="gcode"&&ln||C==="source"&&!ln)}).sort((W,De)=>{switch(xe){case"date-desc":return(Ii(De.created_at)?.getTime()||0)-(Ii(W.created_at)?.getTime()||0);case"date-asc":return(Ii(W.created_at)?.getTime()||0)-(Ii(De.created_at)?.getTime()||0);case"name-asc":return(W.print_name||W.filename).localeCompare(De.print_name||De.filename);case"name-desc":return(De.print_name||De.filename).localeCompare(W.print_name||W.filename);case"size-desc":return De.file_size-W.file_size;case"size-asc":return W.file_size-De.file_size;default:return 0}}),Ve=K||j.size>0,$e=W=>{H(De=>{const Ye=new Set(De);return Ye.has(W)?Ye.delete(W):Ye.add(W),Ye})},ye=()=>{He&&H(new Set(He.map(W=>W.id)))},je=()=>{H(new Set),V(!1)},Be=W=>{m(De=>{const Ye=new Set(De);return Ye.has(W)?Ye.delete(W):Ye.add(W),Ye})},Se=()=>{m(new Set)},Xe=()=>{l(""),u(null),f(null),v(!1),N(!1),k(null),E("all")},Me=o||c||d||y||S||T||C!=="all",tt=_.useCallback(W=>{W.preventDefault(),W.dataTransfer.types.includes("Files")&&$(!0)},[]),ke=_.useCallback(W=>{W.preventDefault(),W.currentTarget===W.target&&$(!1)},[]),We=_.useCallback(W=>{W.preventDefault(),$(!1);const De=Array.from(W.dataTransfer.files).filter(Ye=>Ye.name.endsWith(".3mf"));De.length>0?(U(De),A(!0)):W.dataTransfer.files.length>0&&n(t("archives.page.only3mfSupported"),"warning")},[n,t]),ze=_.useCallback(W=>{const De=W.target;if(De.tagName==="INPUT"||De.tagName==="TEXTAREA"||De.isContentEditable){W.key==="Escape"&&De.blur();return}switch(W.key){case"/":W.preventDefault(),a.current?.focus();break;case"u":case"U":!W.metaKey&&!W.ctrlKey&&(W.preventDefault(),A(!0));break;case"Escape":Ve&&je();break}},[Ve]);return _.useEffect(()=>(document.addEventListener("keydown",ze),()=>document.removeEventListener("keydown",ze)),[ze]),s.jsxs("div",{className:"p-4 md:p-8 relative min-h-full",onDragOver:tt,onDragLeave:ke,onDrop:We,children:[F&&s.jsx("div",{className:"fixed inset-0 z-50 bg-bambu-dark/90 flex items-center justify-center pointer-events-none",children:s.jsxs("div",{className:"border-4 border-dashed border-bambu-green rounded-xl p-12 text-center",children:[s.jsx(Ua,{className:"w-16 h-16 mx-auto mb-4 text-bambu-green"}),s.jsx("p",{className:"text-2xl font-semibold text-white mb-2",children:"Drop .3mf files here"}),s.jsx("p",{className:"text-bambu-gray",children:t("archives.releaseToUpload")})]})}),Ve&&s.jsxs("div",{className:"fixed bottom-6 left-1/2 -translate-x-1/2 z-40 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl px-4 py-3 flex items-center gap-4",children:[s.jsxs(Te,{variant:"secondary",size:"sm",onClick:je,children:[s.jsx(Rt,{className:"w-4 h-4"}),"Close"]}),s.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),s.jsxs("span",{className:"text-white font-medium",children:[j.size," selected"]}),s.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),s.jsx(Te,{variant:"secondary",size:"sm",onClick:ye,children:"Select All"}),s.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),s.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>B(!0),disabled:!i("archives:update_own","archives:update_all"),title:i("archives:update_own","archives:update_all")?void 0:t("archives.permission.noUpdateArchives"),children:[s.jsx(yh,{className:"w-4 h-4"}),"Tags"]}),s.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>ne(!0),disabled:!i("archives:update_own","archives:update_all"),title:i("archives:update_own","archives:update_all")?void 0:t("archives.permission.noUpdateArchives"),children:[s.jsx(Ja,{className:"w-4 h-4"}),"Project"]}),s.jsxs(Te,{variant:"secondary",size:"sm",disabled:!i("archives:update_own","archives:update_all"),title:i("archives:update_own","archives:update_all")?void 0:t("archives.permission.noUpdateArchives"),onClick:()=>{const W=Array.from(j);Promise.all(W.map(De=>ue.toggleFavorite(De))).then(()=>{e.invalidateQueries({queryKey:["archives"]}),n(`Toggled favorites for ${W.length} archive${W.length!==1?"s":""}`)}).catch(()=>{n(t("archives.toast.failedUpdateFavorites"),"error")})},children:[s.jsx(im,{className:"w-4 h-4"}),"Favorite"]}),s.jsxs(Te,{size:"sm",className:"bg-red-500 hover:bg-red-600",onClick:()=>Z(!0),disabled:!i("archives:delete_own","archives:delete_all"),title:i("archives:delete_own","archives:delete_all")?void 0:t("archives.permission.noDelete"),children:[s.jsx(rn,{className:"w-4 h-4"}),"Delete"]})]}),s.jsxs("div",{className:"flex items-center justify-between mb-8",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("h1",{className:"text-2xl font-bold text-white",children:"Archives"}),s.jsx("select",{className:"px-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray-light text-sm focus:border-bambu-green focus:outline-none",value:Pe,onChange:W=>ie(W.target.value),children:nqe.map(W=>s.jsx("option",{value:W.id,children:W.label},W.id))})]}),s.jsxs("p",{className:"text-bambu-gray",children:[He?.length||0," of ",fe?.length||0," prints"]})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("div",{className:"relative",children:[s.jsxs(Te,{variant:"secondary",onClick:()=>Oe(!Ne),disabled:ge,children:[ge?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(q1,{className:"w-4 h-4"}),"Export"]}),Ne&&s.jsxs("div",{className:"absolute right-0 top-full mt-1 w-48 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl z-20",children:[s.jsxs("button",{className:"w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-t-lg",onClick:async()=>{Oe(!1),Ke(!0);try{const{blob:W,filename:De}=await ue.exportArchives({format:"csv",printerId:c||void 0,status:Pe==="failed"?"failed":void 0,search:o||void 0}),Ye=URL.createObjectURL(W),xt=document.createElement("a");xt.href=Ye,xt.download=De,xt.click(),URL.revokeObjectURL(Ye),n(t("archives.toast.exportDownloaded"))}catch{n(t("archives.toast.exportFailed"),"error")}finally{Ke(!1)}},children:[s.jsx(Ls,{className:"w-4 h-4"}),"Export as CSV"]}),s.jsxs("button",{className:"w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-b-lg",onClick:async()=>{Oe(!1),Ke(!0);try{const{blob:W,filename:De}=await ue.exportArchives({format:"xlsx",printerId:c||void 0,status:Pe==="failed"?"failed":void 0,search:o||void 0}),Ye=URL.createObjectURL(W),xt=document.createElement("a");xt.href=Ye,xt.download=De,xt.click(),URL.revokeObjectURL(Ye),n(t("archives.toast.exportDownloaded"))}catch{n(t("archives.toast.exportFailed"),"error")}finally{Ke(!1)}},children:[s.jsx(q1,{className:"w-4 h-4"}),"Export as Excel"]})]})]}),j.size>=2&&j.size<=5&&s.jsxs(Te,{variant:"secondary",onClick:()=>Y(!0),children:[s.jsx(_g,{className:"w-4 h-4"}),"Compare (",j.size,")"]}),!Ve&&s.jsxs(Te,{variant:"secondary",onClick:()=>V(!0),children:[s.jsx(ol,{className:"w-4 h-4"}),"Select"]}),s.jsxs(Te,{onClick:()=>A(!0),disabled:!r("archives:create"),title:r("archives:create")?void 0:t("archives.permission.noCreate"),children:[s.jsx(Ua,{className:"w-4 h-4"}),"Upload 3MF"]})]})]}),s.jsx(_t,{className:"mb-6",children:s.jsxs(Mt,{className:"py-4",children:[s.jsxs("div",{className:"flex flex-col md:flex-row gap-3 md:gap-4 md:items-center md:flex-wrap",children:[s.jsxs("div",{className:"w-full md:flex-1 relative md:min-w-[200px]",children:[s.jsx(ba,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),s.jsx("input",{ref:a,type:"text",placeholder:t("archives.searchPlaceholder"),className:"w-full pl-10 pr-4 py-3 md:py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:o,onChange:W=>l(W.target.value)})]}),s.jsxs("div",{className:"flex gap-2 md:gap-4 overflow-x-auto pb-1 md:pb-0 -mx-4 px-4 md:mx-0 md:px-0 md:flex-wrap scrollbar-hide",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx(uN,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),s.jsxs("select",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:c||"",onChange:W=>u(W.target.value?Number(W.target.value):null),children:[s.jsx("option",{value:"",children:"All Printers"}),Ee?.map(W=>s.jsx("option",{value:W.id,children:W.name},W.id))]})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx(mc,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),s.jsxs("select",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:d||"",onChange:W=>f(W.target.value||null),children:[s.jsx("option",{value:"",children:"All Materials"}),we.map(W=>s.jsx("option",{value:W,children:W},W))]})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx(G1,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),s.jsxs("select",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:C,onChange:W=>E(W.target.value),children:[s.jsx("option",{value:"all",children:"All Files"}),s.jsx("option",{value:"gcode",children:"Sliced (GCODE)"}),s.jsx("option",{value:"source",children:"Source Only"})]})]}),s.jsxs("button",{onClick:()=>v(!y),className:`flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors flex-shrink-0 ${y?"bg-yellow-500/20 border-yellow-500 text-yellow-400":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:t(y?"archives.showAll":"archives.showFavoritesOnly"),children:[s.jsx(im,{className:`w-4 h-4 ${y?"fill-yellow-400":""}`}),s.jsx("span",{className:"text-sm hidden md:inline",children:"Favorites"})]}),s.jsxs("button",{onClick:()=>N(!S),className:`flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors flex-shrink-0 ${S?"bg-red-500/20 border-red-500 text-red-400":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:t(S?"archives.showFailedPrints":"archives.hideFailedPrints"),children:[s.jsx(Hi,{className:"w-4 h-4 "}),s.jsx("span",{className:"text-sm hidden md:inline",children:"Hide Failed"})]}),Fe.length>0&&s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx(yh,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),s.jsxs("select",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:T||"",onChange:W=>k(W.target.value||null),children:[s.jsx("option",{value:"",children:"All Tags"}),Fe.map(W=>s.jsx("option",{value:W,children:W},W))]}),s.jsx("button",{onClick:()=>q(!0),className:"p-2 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary text-bambu-gray hover:text-white hover:border-bambu-green transition-colors",title:t("archives.manageTags"),children:s.jsx(xN,{className:"w-4 h-4"})})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx(fW,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),s.jsxs("select",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:xe,onChange:W=>de(W.target.value),children:[s.jsx("option",{value:"date-desc",children:t("archives.sortNewest")}),s.jsx("option",{value:"date-asc",children:t("archives.sortOldest")}),s.jsxs("option",{value:"name-asc",children:[t("archives.sortName")," A-Z"]}),s.jsxs("option",{value:"name-desc",children:[t("archives.sortName")," Z-A"]}),s.jsx("option",{value:"size-desc",children:t("archives.sortLargest")}),s.jsx("option",{value:"size-asc",children:t("archives.sortSmallest")})]})]}),s.jsxs("div",{className:"flex items-center border border-bambu-dark-tertiary rounded-lg overflow-hidden flex-shrink-0",children:[s.jsx("button",{className:`p-2 ${se==="grid"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>be("grid"),title:t("archives.gridView"),children:s.jsx(mN,{className:"w-4 h-4"})}),s.jsx("button",{className:`p-2 ${se==="list"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>be("list"),title:t("archives.listView"),children:s.jsx(pN,{className:"w-4 h-4"})}),s.jsx("button",{className:`p-2 ${se==="calendar"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>be("calendar"),title:t("archives.calendarView"),children:s.jsx(Cce,{className:"w-4 h-4"})})]})]}),Me&&s.jsxs(Te,{variant:"ghost",size:"sm",onClick:Xe,className:"text-bambu-gray hover:text-white",children:[s.jsx(Rt,{className:"w-4 h-4"}),"Reset"]})]}),re.length>0&&s.jsxs("div",{className:"flex items-center gap-3 mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[s.jsx("span",{className:"text-xs text-bambu-gray",children:"Colors:"}),p.size>1&&s.jsx("button",{onClick:()=>b(W=>W==="or"?"and":"or"),className:`px-2 py-0.5 text-xs rounded transition-colors ${x==="and"?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:x==="or"?"Match ANY selected color":"Match ALL selected colors",children:x.toUpperCase()}),s.jsx("div",{className:"flex items-center gap-1.5 flex-wrap",children:re.map(W=>s.jsx("button",{onClick:()=>Be(W),className:`w-6 h-6 rounded-full border-2 transition-all ${p.has(W)?"border-bambu-green scale-110":"border-white/20 hover:border-white/40"}`,style:{backgroundColor:W},title:W},W))}),p.size>0&&s.jsxs("button",{onClick:Se,className:"text-xs text-bambu-gray hover:text-white flex items-center gap-1",children:[s.jsx(Rt,{className:"w-3 h-3"}),"Clear"]})]})]})}),s.jsx(Z9e,{}),me?s.jsx("div",{className:"text-center py-12 text-bambu-gray",children:t("archives.loadingArchives")}):He?.length===0?s.jsx(_t,{children:s.jsxs(Mt,{className:"text-center py-12",children:[s.jsx("p",{className:"text-bambu-gray",children:t(o?"archives.noArchivesSearch":"archives.noArchivesYet")}),s.jsx("p",{className:"text-sm text-bambu-gray mt-2",children:"Archives are created automatically when prints complete"})]})}):se==="calendar"?s.jsx(_t,{className:"p-6",children:s.jsx(A8e,{archives:He||[],onArchiveClick:W=>{l(""),be("grid"),I(W.id)},highlightedArchiveId:te})}):se==="grid"?s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:He?.map(W=>s.jsx(eqe,{archive:W,printerName:W.printer_id?_e.get(W.printer_id)||"Unknown":W.sliced_for_model?`Sliced for ${W.sliced_for_model}`:"No Printer",isSelected:j.has(W.id),onSelect:$e,selectionMode:Ve,projects:z,isHighlighted:W.id===te,timeFormat:ee,t},W.id))}):se==="list"?s.jsx(_t,{children:s.jsxs("div",{className:"divide-y divide-bambu-dark-tertiary",children:[s.jsxs("div",{className:"grid grid-cols-12 gap-4 px-4 py-3 text-xs text-bambu-gray font-medium",children:[s.jsx("div",{className:"col-span-1"}),s.jsx("div",{className:"col-span-4",children:"Name"}),s.jsx("div",{className:"col-span-2",children:"Printer"}),s.jsx("div",{className:"col-span-2",children:"Date"}),s.jsx("div",{className:"col-span-1",children:"Size"}),s.jsx("div",{className:"col-span-2 text-right",children:"Actions"})]}),He?.map(W=>s.jsx(tqe,{archive:W,printerName:W.printer_id?_e.get(W.printer_id)||"Unknown":W.sliced_for_model?`Sliced for ${W.sliced_for_model}`:"No Printer",isSelected:j.has(W.id),onSelect:$e,selectionMode:Ve,projects:z,isHighlighted:W.id===te,t},W.id))]})}):null,D&&s.jsx(v8e,{onClose:()=>{A(!1),U([])},initialFiles:R}),Q&&s.jsx(Zn,{title:t("archives.modal.deleteArchives"),message:t("archives.modal.deleteArchivesConfirm",{count:j.size}),confirmText:t("archives.modal.deleteCount",{count:j.size}),variant:"danger",onConfirm:()=>{le.mutate(Array.from(j)),Z(!1)},onCancel:()=>Z(!1)}),ae&&s.jsx(S8e,{selectedIds:Array.from(j),existingTags:Fe,onClose:()=>B(!1)}),X&&s.jsx(M8e,{selectedIds:Array.from(j),onClose:()=>ne(!1)}),G&&j.size>=2&&j.size<=5&&s.jsx(W9e,{archiveIds:Array.from(j),onClose:()=>{Y(!1),H(new Set),V(!1)}}),ce&&s.jsx(J9e,{onClose:()=>q(!1)})]})}function iqe(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return _.useMemo(()=>r=>{e.forEach(i=>i(r))},e)}const I2=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Lx(t){const e=Object.prototype.toString.call(t);return e==="[object Window]"||e==="[object global]"}function nF(t){return"nodeType"in t}function qs(t){var e,n;return t?Lx(t)?t:nF(t)&&(e=(n=t.ownerDocument)==null?void 0:n.defaultView)!=null?e:window:window}function rF(t){const{Document:e}=qs(t);return t instanceof e}function vv(t){return Lx(t)?!1:t instanceof qs(t).HTMLElement}function sre(t){return t instanceof qs(t).SVGElement}function Fx(t){return t?Lx(t)?t.document:nF(t)?rF(t)?t:vv(t)||sre(t)?t.ownerDocument:document:document:document}const Sc=I2?_.useLayoutEffect:_.useEffect;function iF(t){const e=_.useRef(t);return Sc(()=>{e.current=t}),_.useCallback(function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return e.current==null?void 0:e.current(...r)},[])}function aqe(){const t=_.useRef(null),e=_.useCallback((r,i)=>{t.current=setInterval(r,i)},[]),n=_.useCallback(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[]);return[e,n]}function jy(t,e){e===void 0&&(e=[t]);const n=_.useRef(t);return Sc(()=>{n.current!==t&&(n.current=t)},e),n}function wv(t,e){const n=_.useRef();return _.useMemo(()=>{const r=t(n.current);return n.current=r,r},[...e])}function YM(t){const e=iF(t),n=_.useRef(null),r=_.useCallback(i=>{i!==n.current&&e?.(i,n.current),n.current=i},[]);return[n,r]}function aR(t){const e=_.useRef();return _.useEffect(()=>{e.current=t},[t]),e.current}let Ij={};function _v(t,e){return _.useMemo(()=>{if(e)return e;const n=Ij[t]==null?0:Ij[t]+1;return Ij[t]=n,t+"-"+n},[t,e])}function ore(t){return function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return r.reduce((a,o)=>{const l=Object.entries(o);for(const[c,u]of l){const d=a[c];d!=null&&(a[c]=d+t*u)}return a},{...e})}}const Lg=ore(1),Py=ore(-1);function sqe(t){return"clientX"in t&&"clientY"in t}function aF(t){if(!t)return!1;const{KeyboardEvent:e}=qs(t.target);return e&&t instanceof e}function oqe(t){if(!t)return!1;const{TouchEvent:e}=qs(t.target);return e&&t instanceof e}function sR(t){if(oqe(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 sqe(t)?{x:t.clientX,y:t.clientY}:null}const mx=Object.freeze({Translate:{toString(t){if(!t)return;const{x:e,y:n}=t;return"translate3d("+(e?Math.round(e):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(t){if(!t)return;const{scaleX:e,scaleY:n}=t;return"scaleX("+e+") scaleY("+n+")"}},Transform:{toString(t){if(t)return[mx.Translate.toString(t),mx.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:e,duration:n,easing:r}=t;return e+" "+n+"ms "+r}}}),J9="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function lqe(t){return t.matches(J9)?t:t.querySelector(J9)}const cqe={display:"none"};function uqe(t){let{id:e,value:n}=t;return Jr.createElement("div",{id:e,style:cqe},n)}function dqe(t){let{id:e,announcement:n,ariaLiveType:r="assertive"}=t;const i={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return Jr.createElement("div",{id:e,style:i,role:"status","aria-live":r,"aria-atomic":!0},n)}function hqe(){const[t,e]=_.useState("");return{announce:_.useCallback(r=>{r!=null&&e(r)},[]),announcement:t}}const lre=_.createContext(null);function fqe(t){const e=_.useContext(lre);_.useEffect(()=>{if(!e)throw new Error("useDndMonitor must be used within a children of <DndContext>");return e(t)},[t,e])}function mqe(){const[t]=_.useState(()=>new Set),e=_.useCallback(r=>(t.add(r),()=>t.delete(r)),[t]);return[_.useCallback(r=>{let{type:i,event:a}=r;t.forEach(o=>{var l;return(l=o[i])==null?void 0:l.call(o,a)})},[t]),e]}const pqe={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.
- `},gqe={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 xqe(t){let{announcements:e=gqe,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=pqe}=t;const{announce:a,announcement:o}=hqe(),l=_v("DndLiveRegion"),[c,u]=_.useState(!1);if(_.useEffect(()=>{u(!0)},[]),fqe(_.useMemo(()=>({onDragStart(f){let{active:p}=f;a(e.onDragStart({active:p}))},onDragMove(f){let{active:p,over:m}=f;e.onDragMove&&a(e.onDragMove({active:p,over:m}))},onDragOver(f){let{active:p,over:m}=f;a(e.onDragOver({active:p,over:m}))},onDragEnd(f){let{active:p,over:m}=f;a(e.onDragEnd({active:p,over:m}))},onDragCancel(f){let{active:p,over:m}=f;a(e.onDragCancel({active:p,over:m}))}}),[a,e])),!c)return null;const d=Jr.createElement(Jr.Fragment,null,Jr.createElement(uqe,{id:r,value:i.draggable}),Jr.createElement(dqe,{id:l,announcement:o}));return n?gu.createPortal(d,n):d}var Xi;(function(t){t.DragStart="dragStart",t.DragMove="dragMove",t.DragEnd="dragEnd",t.DragCancel="dragCancel",t.DragOver="dragOver",t.RegisterDroppable="registerDroppable",t.SetDroppableDisabled="setDroppableDisabled",t.UnregisterDroppable="unregisterDroppable"})(Xi||(Xi={}));function QM(){}function ZM(t,e){return _.useMemo(()=>({sensor:t,options:e??{}}),[t,e])}function cre(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return _.useMemo(()=>[...e].filter(r=>r!=null),[...e])}const zl=Object.freeze({x:0,y:0});function ure(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function dre(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return n-r}function bqe(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return r-n}function eq(t){let{left:e,top:n,height:r,width:i}=t;return[{x:e,y:n},{x:e+i,y:n},{x:e,y:n+r},{x:e+i,y:n+r}]}function hre(t,e){if(!t||t.length===0)return null;const[n]=t;return n[e]}function tq(t,e,n){return e===void 0&&(e=t.left),n===void 0&&(n=t.top),{x:e+t.width*.5,y:n+t.height*.5}}const fre=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=tq(e,e.left,e.top),a=[];for(const o of r){const{id:l}=o,c=n.get(l);if(c){const u=ure(tq(c),i);a.push({id:l,data:{droppableContainer:o,value:u}})}}return a.sort(dre)},yqe=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=eq(e),a=[];for(const o of r){const{id:l}=o,c=n.get(l);if(c){const u=eq(c),d=i.reduce((p,m,x)=>p+ure(u[x],m),0),f=Number((d/4).toFixed(4));a.push({id:l,data:{droppableContainer:o,value:f}})}}return a.sort(dre)};function vqe(t,e){const n=Math.max(e.top,t.top),r=Math.max(e.left,t.left),i=Math.min(e.left+e.width,t.left+t.width),a=Math.min(e.top+e.height,t.top+t.height),o=i-r,l=a-n;if(r<i&&n<a){const c=e.width*e.height,u=t.width*t.height,d=o*l,f=d/(c+u-d);return Number(f.toFixed(4))}return 0}const wqe=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=[];for(const a of r){const{id:o}=a,l=n.get(o);if(l){const c=vqe(l,e);c>0&&i.push({id:o,data:{droppableContainer:a,value:c}})}}return i.sort(bqe)};function _qe(t,e,n){return{...t,scaleX:e&&n?e.width/n.width:1,scaleY:e&&n?e.height/n.height:1}}function mre(t,e){return t&&e?{x:t.left-e.left,y:t.top-e.top}:zl}function Sqe(t){return function(n){for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++)i[a-1]=arguments[a];return i.reduce((o,l)=>({...o,top:o.top+t*l.y,bottom:o.bottom+t*l.y,left:o.left+t*l.x,right:o.right+t*l.x}),{...n})}}const Mqe=Sqe(1);function Nqe(t){if(t.startsWith("matrix3d(")){const e=t.slice(9,-1).split(/, /);return{x:+e[12],y:+e[13],scaleX:+e[0],scaleY:+e[5]}}else if(t.startsWith("matrix(")){const e=t.slice(7,-1).split(/, /);return{x:+e[4],y:+e[5],scaleX:+e[0],scaleY:+e[3]}}return null}function kqe(t,e,n){const r=Nqe(e);if(!r)return t;const{scaleX:i,scaleY:a,x:o,y:l}=r,c=t.left-o-(1-i)*parseFloat(n),u=t.top-l-(1-a)*parseFloat(n.slice(n.indexOf(" ")+1)),d=i?t.width/i:t.width,f=a?t.height/a:t.height;return{width:d,height:f,top:u,right:c+d,bottom:u+f,left:c}}const Eqe={ignoreTransform:!1};function Ix(t,e){e===void 0&&(e=Eqe);let n=t.getBoundingClientRect();if(e.ignoreTransform){const{transform:u,transformOrigin:d}=qs(t).getComputedStyle(t);u&&(n=kqe(n,u,d))}const{top:r,left:i,width:a,height:o,bottom:l,right:c}=n;return{top:r,left:i,width:a,height:o,bottom:l,right:c}}function nq(t){return Ix(t,{ignoreTransform:!0})}function Tqe(t){const e=t.innerWidth,n=t.innerHeight;return{top:0,left:0,right:e,bottom:n,width:e,height:n}}function Aqe(t,e){return e===void 0&&(e=qs(t).getComputedStyle(t)),e.position==="fixed"}function Cqe(t,e){e===void 0&&(e=qs(t).getComputedStyle(t));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(i=>{const a=e[i];return typeof a=="string"?n.test(a):!1})}function U2(t,e){const n=[];function r(i){if(e!=null&&n.length>=e||!i)return n;if(rF(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!vv(i)||sre(i)||n.includes(i))return n;const a=qs(t).getComputedStyle(i);return i!==t&&Cqe(i,a)&&n.push(i),Aqe(i,a)?n:r(i.parentNode)}return t?r(t):n}function pre(t){const[e]=U2(t,1);return e??null}function Uj(t){return!I2||!t?null:Lx(t)?t:nF(t)?rF(t)||t===Fx(t).scrollingElement?window:vv(t)?t:null:null}function gre(t){return Lx(t)?t.scrollX:t.scrollLeft}function xre(t){return Lx(t)?t.scrollY:t.scrollTop}function oR(t){return{x:gre(t),y:xre(t)}}var ga;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(ga||(ga={}));function bre(t){return!I2||!t?!1:t===document.scrollingElement}function yre(t){const e={x:0,y:0},n=bre(t)?{height:window.innerHeight,width:window.innerWidth}:{height:t.clientHeight,width:t.clientWidth},r={x:t.scrollWidth-n.width,y:t.scrollHeight-n.height},i=t.scrollTop<=e.y,a=t.scrollLeft<=e.x,o=t.scrollTop>=r.y,l=t.scrollLeft>=r.x;return{isTop:i,isLeft:a,isBottom:o,isRight:l,maxScroll:r,minScroll:e}}const jqe={x:.2,y:.2};function Pqe(t,e,n,r,i){let{top:a,left:o,right:l,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=jqe);const{isTop:u,isBottom:d,isLeft:f,isRight:p}=yre(t),m={x:0,y:0},x={x:0,y:0},b={height:e.height*i.y,width:e.width*i.x};return!u&&a<=e.top+b.height?(m.y=ga.Backward,x.y=r*Math.abs((e.top+b.height-a)/b.height)):!d&&c>=e.bottom-b.height&&(m.y=ga.Forward,x.y=r*Math.abs((e.bottom-b.height-c)/b.height)),!p&&l>=e.right-b.width?(m.x=ga.Forward,x.x=r*Math.abs((e.right-b.width-l)/b.width)):!f&&o<=e.left+b.width&&(m.x=ga.Backward,x.x=r*Math.abs((e.left+b.width-o)/b.width)),{direction:m,speed:x}}function Dqe(t){if(t===document.scrollingElement){const{innerWidth:a,innerHeight:o}=window;return{top:0,left:0,right:a,bottom:o,width:a,height:o}}const{top:e,left:n,right:r,bottom:i}=t.getBoundingClientRect();return{top:e,left:n,right:r,bottom:i,width:t.clientWidth,height:t.clientHeight}}function vre(t){return t.reduce((e,n)=>Lg(e,oR(n)),zl)}function Rqe(t){return t.reduce((e,n)=>e+gre(n),0)}function Oqe(t){return t.reduce((e,n)=>e+xre(n),0)}function Lqe(t,e){if(e===void 0&&(e=Ix),!t)return;const{top:n,left:r,bottom:i,right:a}=e(t);pre(t)&&(i<=0||a<=0||n>=window.innerHeight||r>=window.innerWidth)&&t.scrollIntoView({block:"center",inline:"center"})}const Fqe=[["x",["left","right"],Rqe],["y",["top","bottom"],Oqe]];class sF{constructor(e,n){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const r=U2(n),i=vre(r);this.rect={...e},this.width=e.width,this.height=e.height;for(const[a,o,l]of Fqe)for(const c of o)Object.defineProperty(this,c,{get:()=>{const u=l(r),d=i[a]-u;return this.rect[c]+d},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class F0{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var r;return(r=this.target)==null?void 0:r.removeEventListener(...n)})},this.target=e}add(e,n,r){var i;(i=this.target)==null||i.addEventListener(e,n,r),this.listeners.push([e,n,r])}}function Iqe(t){const{EventTarget:e}=qs(t);return t instanceof e?t:Fx(t)}function zj(t,e){const n=Math.abs(t.x),r=Math.abs(t.y);return typeof e=="number"?Math.sqrt(n**2+r**2)>e:"x"in e&&"y"in e?n>e.x&&r>e.y:"x"in e?n>e.x:"y"in e?r>e.y:!1}var qo;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(qo||(qo={}));function rq(t){t.preventDefault()}function Uqe(t){t.stopPropagation()}var Qn;(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"})(Qn||(Qn={}));const wre={start:[Qn.Space,Qn.Enter],cancel:[Qn.Esc],end:[Qn.Space,Qn.Enter,Qn.Tab]},zqe=(t,e)=>{let{currentCoordinates:n}=e;switch(t.code){case Qn.Right:return{...n,x:n.x+25};case Qn.Left:return{...n,x:n.x-25};case Qn.Down:return{...n,y:n.y+25};case Qn.Up:return{...n,y:n.y-25}}};class z2{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;const{event:{target:n}}=e;this.props=e,this.listeners=new F0(Fx(n)),this.windowListeners=new F0(qs(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(qo.Resize,this.handleCancel),this.windowListeners.add(qo.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(qo.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:e,onStart:n}=this.props,r=e.node.current;r&&Lqe(r),n(zl)}handleKeyDown(e){if(aF(e)){const{active:n,context:r,options:i}=this.props,{keyboardCodes:a=wre,coordinateGetter:o=zqe,scrollBehavior:l="smooth"}=i,{code:c}=e;if(a.end.includes(c)){this.handleEnd(e);return}if(a.cancel.includes(c)){this.handleCancel(e);return}const{collisionRect:u}=r.current,d=u?{x:u.left,y:u.top}:zl;this.referenceCoordinates||(this.referenceCoordinates=d);const f=o(e,{active:n,context:r.current,currentCoordinates:d});if(f){const p=Py(f,d),m={x:0,y:0},{scrollableAncestors:x}=r.current;for(const b of x){const y=e.code,{isTop:v,isRight:S,isLeft:N,isBottom:T,maxScroll:k,minScroll:C}=yre(b),E=Dqe(b),D={x:Math.min(y===Qn.Right?E.right-E.width/2:E.right,Math.max(y===Qn.Right?E.left:E.left+E.width/2,f.x)),y:Math.min(y===Qn.Down?E.bottom-E.height/2:E.bottom,Math.max(y===Qn.Down?E.top:E.top+E.height/2,f.y))},A=y===Qn.Right&&!S||y===Qn.Left&&!N,R=y===Qn.Down&&!T||y===Qn.Up&&!v;if(A&&D.x!==f.x){const U=b.scrollLeft+p.x,F=y===Qn.Right&&U<=k.x||y===Qn.Left&&U>=C.x;if(F&&!p.y){b.scrollTo({left:U,behavior:l});return}F?m.x=b.scrollLeft-U:m.x=y===Qn.Right?b.scrollLeft-k.x:b.scrollLeft-C.x,m.x&&b.scrollBy({left:-m.x,behavior:l});break}else if(R&&D.y!==f.y){const U=b.scrollTop+p.y,F=y===Qn.Down&&U<=k.y||y===Qn.Up&&U>=C.y;if(F&&!p.x){b.scrollTo({top:U,behavior:l});return}F?m.y=b.scrollTop-U:m.y=y===Qn.Down?b.scrollTop-k.y:b.scrollTop-C.y,m.y&&b.scrollBy({top:-m.y,behavior:l});break}}this.handleMove(e,Lg(Py(f,this.referenceCoordinates),m))}}}handleMove(e,n){const{onMove:r}=this.props;e.preventDefault(),r(n)}handleEnd(e){const{onEnd:n}=this.props;e.preventDefault(),this.detach(),n()}handleCancel(e){const{onCancel:n}=this.props;e.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}z2.activators=[{eventName:"onKeyDown",handler:(t,e,n)=>{let{keyboardCodes:r=wre,onActivation:i}=e,{active:a}=n;const{code:o}=t.nativeEvent;if(r.start.includes(o)){const l=a.activatorNode.current;return l&&t.target!==l?!1:(t.preventDefault(),i?.({event:t.nativeEvent}),!0)}return!1}}];function iq(t){return!!(t&&"distance"in t)}function aq(t){return!!(t&&"delay"in t)}class oF{constructor(e,n,r){var i;r===void 0&&(r=Iqe(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=n;const{event:a}=e,{target:o}=a;this.props=e,this.events=n,this.document=Fx(o),this.documentListeners=new F0(this.document),this.listeners=new F0(r),this.windowListeners=new F0(qs(o)),this.initialCoordinates=(i=sR(a))!=null?i:zl,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:e,props:{options:{activationConstraint:n,bypassActivationConstraint:r}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(qo.Resize,this.handleCancel),this.windowListeners.add(qo.DragStart,rq),this.windowListeners.add(qo.VisibilityChange,this.handleCancel),this.windowListeners.add(qo.ContextMenu,rq),this.documentListeners.add(qo.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(aq(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(iq(n)){this.handlePending(n);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,n){const{active:r,onPending:i}=this.props;i(r,e,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:e}=this,{onStart:n}=this.props;e&&(this.activated=!0,this.documentListeners.add(qo.Click,Uqe,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(qo.SelectionChange,this.removeTextSelection),n(e))}handleMove(e){var n;const{activated:r,initialCoordinates:i,props:a}=this,{onMove:o,options:{activationConstraint:l}}=a;if(!i)return;const c=(n=sR(e))!=null?n:zl,u=Py(i,c);if(!r&&l){if(iq(l)){if(l.tolerance!=null&&zj(u,l.tolerance))return this.handleCancel();if(zj(u,l.distance))return this.handleStart()}if(aq(l)&&zj(u,l.tolerance))return this.handleCancel();this.handlePending(l,u);return}e.cancelable&&e.preventDefault(),o(c)}handleEnd(){const{onAbort:e,onEnd:n}=this.props;this.detach(),this.activated||e(this.props.active),n()}handleCancel(){const{onAbort:e,onCancel:n}=this.props;this.detach(),this.activated||e(this.props.active),n()}handleKeydown(e){e.code===Qn.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}}const Bqe={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class B2 extends oF{constructor(e){const{event:n}=e,r=Fx(n.target);super(e,Bqe,r)}}B2.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 Hqe={move:{name:"mousemove"},end:{name:"mouseup"}};var lR;(function(t){t[t.RightClick=2]="RightClick"})(lR||(lR={}));class $qe extends oF{constructor(e){super(e,Hqe,Fx(e.event.target))}}$qe.activators=[{eventName:"onMouseDown",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:r}=e;return n.button===lR.RightClick?!1:(r?.({event:n}),!0)}}];const Bj={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class Vqe extends oF{constructor(e){super(e,Bj)}static setup(){return window.addEventListener(Bj.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(Bj.move.name,e)};function e(){}}}Vqe.activators=[{eventName:"onTouchStart",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:r}=e;const{touches:i}=n;return i.length>1?!1:(r?.({event:n}),!0)}}];var I0;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(I0||(I0={}));var JM;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(JM||(JM={}));function Gqe(t){let{acceleration:e,activator:n=I0.Pointer,canScroll:r,draggingRect:i,enabled:a,interval:o=5,order:l=JM.TreeOrder,pointerCoordinates:c,scrollableAncestors:u,scrollableAncestorRects:d,delta:f,threshold:p}=t;const m=Wqe({delta:f,disabled:!a}),[x,b]=aqe(),y=_.useRef({x:0,y:0}),v=_.useRef({x:0,y:0}),S=_.useMemo(()=>{switch(n){case I0.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case I0.DraggableRect:return i}},[n,i,c]),N=_.useRef(null),T=_.useCallback(()=>{const C=N.current;if(!C)return;const E=y.current.x*v.current.x,D=y.current.y*v.current.y;C.scrollBy(E,D)},[]),k=_.useMemo(()=>l===JM.TreeOrder?[...u].reverse():u,[l,u]);_.useEffect(()=>{if(!a||!u.length||!S){b();return}for(const C of k){if(r?.(C)===!1)continue;const E=u.indexOf(C),D=d[E];if(!D)continue;const{direction:A,speed:R}=Pqe(C,D,S,e,p);for(const U of["x","y"])m[U][A[U]]||(R[U]=0,A[U]=0);if(R.x>0||R.y>0){b(),N.current=C,x(T,o),y.current=R,v.current=A;return}}y.current={x:0,y:0},v.current={x:0,y:0},b()},[e,T,r,b,a,o,JSON.stringify(S),JSON.stringify(m),x,u,k,d,JSON.stringify(p)])}const qqe={x:{[ga.Backward]:!1,[ga.Forward]:!1},y:{[ga.Backward]:!1,[ga.Forward]:!1}};function Wqe(t){let{delta:e,disabled:n}=t;const r=aR(e);return wv(i=>{if(n||!r||!i)return qqe;const a={x:Math.sign(e.x-r.x),y:Math.sign(e.y-r.y)};return{x:{[ga.Backward]:i.x[ga.Backward]||a.x===-1,[ga.Forward]:i.x[ga.Forward]||a.x===1},y:{[ga.Backward]:i.y[ga.Backward]||a.y===-1,[ga.Forward]:i.y[ga.Forward]||a.y===1}}},[n,e,r])}function Kqe(t,e){const n=e!=null?t.get(e):void 0,r=n?n.node.current:null;return wv(i=>{var a;return e==null?null:(a=r??i)!=null?a:null},[r,e])}function Xqe(t,e){return _.useMemo(()=>t.reduce((n,r)=>{const{sensor:i}=r,a=i.activators.map(o=>({eventName:o.eventName,handler:e(o.handler,r)}));return[...n,...a]},[]),[t,e])}var Dy;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(Dy||(Dy={}));var cR;(function(t){t.Optimized="optimized"})(cR||(cR={}));const sq=new Map;function Yqe(t,e){let{dragging:n,dependencies:r,config:i}=e;const[a,o]=_.useState(null),{frequency:l,measure:c,strategy:u}=i,d=_.useRef(t),f=y(),p=jy(f),m=_.useCallback(function(v){v===void 0&&(v=[]),!p.current&&o(S=>S===null?v:S.concat(v.filter(N=>!S.includes(N))))},[p]),x=_.useRef(null),b=wv(v=>{if(f&&!n)return sq;if(!v||v===sq||d.current!==t||a!=null){const S=new Map;for(let N of t){if(!N)continue;if(a&&a.length>0&&!a.includes(N.id)&&N.rect.current){S.set(N.id,N.rect.current);continue}const T=N.node.current,k=T?new sF(c(T),T):null;N.rect.current=k,k&&S.set(N.id,k)}return S}return v},[t,a,n,f,c]);return _.useEffect(()=>{d.current=t},[t]),_.useEffect(()=>{f||m()},[n,f]),_.useEffect(()=>{a&&a.length>0&&o(null)},[JSON.stringify(a)]),_.useEffect(()=>{f||typeof l!="number"||x.current!==null||(x.current=setTimeout(()=>{m(),x.current=null},l))},[l,f,m,...r]),{droppableRects:b,measureDroppableContainers:m,measuringScheduled:a!=null};function y(){switch(u){case Dy.Always:return!1;case Dy.BeforeDragging:return n;default:return!n}}}function _re(t,e){return wv(n=>t?n||(typeof e=="function"?e(t):t):null,[e,t])}function Qqe(t,e){return _re(t,e)}function Zqe(t){let{callback:e,disabled:n}=t;const r=iF(e),i=_.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:a}=window;return new a(r)},[r,n]);return _.useEffect(()=>()=>i?.disconnect(),[i]),i}function H2(t){let{callback:e,disabled:n}=t;const r=iF(e),i=_.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:a}=window;return new a(r)},[n]);return _.useEffect(()=>()=>i?.disconnect(),[i]),i}function Jqe(t){return new sF(Ix(t),t)}function oq(t,e,n){e===void 0&&(e=Jqe);const[r,i]=_.useState(null);function a(){i(c=>{if(!t)return null;if(t.isConnected===!1){var u;return(u=c??n)!=null?u:null}const d=e(t);return JSON.stringify(c)===JSON.stringify(d)?c:d})}const o=Zqe({callback(c){if(t)for(const u of c){const{type:d,target:f}=u;if(d==="childList"&&f instanceof HTMLElement&&f.contains(t)){a();break}}}}),l=H2({callback:a});return Sc(()=>{a(),t?(l?.observe(t),o?.observe(document.body,{childList:!0,subtree:!0})):(l?.disconnect(),o?.disconnect())},[t]),r}function eWe(t){const e=_re(t);return mre(t,e)}const lq=[];function tWe(t){const e=_.useRef(t),n=wv(r=>t?r&&r!==lq&&t&&e.current&&t.parentNode===e.current.parentNode?r:U2(t):lq,[t]);return _.useEffect(()=>{e.current=t},[t]),n}function nWe(t){const[e,n]=_.useState(null),r=_.useRef(t),i=_.useCallback(a=>{const o=Uj(a.target);o&&n(l=>l?(l.set(o,oR(o)),new Map(l)):null)},[]);return _.useEffect(()=>{const a=r.current;if(t!==a){o(a);const l=t.map(c=>{const u=Uj(c);return u?(u.addEventListener("scroll",i,{passive:!0}),[u,oR(u)]):null}).filter(c=>c!=null);n(l.length?new Map(l):null),r.current=t}return()=>{o(t),o(a)};function o(l){l.forEach(c=>{const u=Uj(c);u?.removeEventListener("scroll",i)})}},[i,t]),_.useMemo(()=>t.length?e?Array.from(e.values()).reduce((a,o)=>Lg(a,o),zl):vre(t):zl,[t,e])}function cq(t,e){e===void 0&&(e=[]);const n=_.useRef(null);return _.useEffect(()=>{n.current=null},e),_.useEffect(()=>{const r=t!==zl;r&&!n.current&&(n.current=t),!r&&n.current&&(n.current=null)},[t]),n.current?Py(t,n.current):zl}function rWe(t){_.useEffect(()=>{if(!I2)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 iWe(t,e){return _.useMemo(()=>t.reduce((n,r)=>{let{eventName:i,handler:a}=r;return n[i]=o=>{a(o,e)},n},{}),[t,e])}function Sre(t){return _.useMemo(()=>t?Tqe(t):null,[t])}const uq=[];function aWe(t,e){e===void 0&&(e=Ix);const[n]=t,r=Sre(n?qs(n):null),[i,a]=_.useState(uq);function o(){a(()=>t.length?t.map(c=>bre(c)?r:new sF(e(c),c)):uq)}const l=H2({callback:o});return Sc(()=>{l?.disconnect(),o(),t.forEach(c=>l?.observe(c))},[t]),i}function sWe(t){if(!t)return null;if(t.children.length>1)return t;const e=t.children[0];return vv(e)?e:t}function oWe(t){let{measure:e}=t;const[n,r]=_.useState(null),i=_.useCallback(u=>{for(const{target:d}of u)if(vv(d)){r(f=>{const p=e(d);return f?{...f,width:p.width,height:p.height}:p});break}},[e]),a=H2({callback:i}),o=_.useCallback(u=>{const d=sWe(u);a?.disconnect(),d&&a?.observe(d),r(d?e(d):null)},[e,a]),[l,c]=YM(o);return _.useMemo(()=>({nodeRef:l,rect:n,setRef:c}),[n,l,c])}const lWe=[{sensor:B2,options:{}},{sensor:z2,options:{}}],cWe={current:{}},I1={draggable:{measure:nq},droppable:{measure:nq,strategy:Dy.WhileDragging,frequency:cR.Optimized},dragOverlay:{measure:Ix}};class U0 extends Map{get(e){var n;return e!=null&&(n=super.get(e))!=null?n:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:n}=e;return!n})}getNodeFor(e){var n,r;return(n=(r=this.get(e))==null?void 0:r.node.current)!=null?n:void 0}}const uWe={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new U0,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:QM},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:I1,measureDroppableContainers:QM,windowRect:null,measuringScheduled:!1},dWe={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:QM,draggableNodes:new Map,over:null,measureDroppableContainers:QM},$2=_.createContext(dWe),Mre=_.createContext(uWe);function hWe(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new U0}}}function fWe(t,e){switch(e.type){case Xi.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:e.initialCoordinates,active:e.active}};case Xi.DragMove:return t.draggable.active==null?t:{...t,draggable:{...t.draggable,translate:{x:e.coordinates.x-t.draggable.initialCoordinates.x,y:e.coordinates.y-t.draggable.initialCoordinates.y}}};case Xi.DragEnd:case Xi.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Xi.RegisterDroppable:{const{element:n}=e,{id:r}=n,i=new U0(t.droppable.containers);return i.set(r,n),{...t,droppable:{...t.droppable,containers:i}}}case Xi.SetDroppableDisabled:{const{id:n,key:r,disabled:i}=e,a=t.droppable.containers.get(n);if(!a||r!==a.key)return t;const o=new U0(t.droppable.containers);return o.set(n,{...a,disabled:i}),{...t,droppable:{...t.droppable,containers:o}}}case Xi.UnregisterDroppable:{const{id:n,key:r}=e,i=t.droppable.containers.get(n);if(!i||r!==i.key)return t;const a=new U0(t.droppable.containers);return a.delete(n),{...t,droppable:{...t.droppable,containers:a}}}default:return t}}function mWe(t){let{disabled:e}=t;const{active:n,activatorEvent:r,draggableNodes:i}=_.useContext($2),a=aR(r),o=aR(n?.id);return _.useEffect(()=>{if(!e&&!r&&a&&o!=null){if(!aF(a)||document.activeElement===a.target)return;const l=i.get(o);if(!l)return;const{activatorNode:c,node:u}=l;if(!c.current&&!u.current)return;requestAnimationFrame(()=>{for(const d of[c.current,u.current]){if(!d)continue;const f=lqe(d);if(f){f.focus();break}}})}},[r,e,i,o,a]),null}function pWe(t,e){let{transform:n,...r}=e;return t!=null&&t.length?t.reduce((i,a)=>a({transform:i,...r}),n):n}function gWe(t){return _.useMemo(()=>({draggable:{...I1.draggable,...t?.draggable},droppable:{...I1.droppable,...t?.droppable},dragOverlay:{...I1.dragOverlay,...t?.dragOverlay}}),[t?.draggable,t?.droppable,t?.dragOverlay])}function xWe(t){let{activeNode:e,measure:n,initialRect:r,config:i=!0}=t;const a=_.useRef(!1),{x:o,y:l}=typeof i=="boolean"?{x:i,y:i}:i;Sc(()=>{if(!o&&!l||!e){a.current=!1;return}if(a.current||!r)return;const u=e?.node.current;if(!u||u.isConnected===!1)return;const d=n(u),f=mre(d,r);if(o||(f.x=0),l||(f.y=0),a.current=!0,Math.abs(f.x)>0||Math.abs(f.y)>0){const p=pre(u);p&&p.scrollBy({top:f.y,left:f.x})}},[e,o,l,r,n])}const Nre=_.createContext({...zl,scaleX:1,scaleY:1});var qd;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(qd||(qd={}));const kre=_.memo(function(e){var n,r,i,a;let{id:o,accessibility:l,autoScroll:c=!0,children:u,sensors:d=lWe,collisionDetection:f=wqe,measuring:p,modifiers:m,...x}=e;const b=_.useReducer(fWe,void 0,hWe),[y,v]=b,[S,N]=mqe(),[T,k]=_.useState(qd.Uninitialized),C=T===qd.Initialized,{draggable:{active:E,nodes:D,translate:A},droppable:{containers:R}}=y,U=E!=null?D.get(E):null,F=_.useRef({initial:null,translated:null}),$=_.useMemo(()=>{var We;return E!=null?{id:E,data:(We=U?.data)!=null?We:cWe,rect:F}:null},[E,U]),j=_.useRef(null),[H,K]=_.useState(null),[V,Q]=_.useState(null),Z=jy(x,Object.values(x)),ae=_v("DndDescribedBy",o),B=_.useMemo(()=>R.getEnabled(),[R]),X=gWe(p),{droppableRects:ne,measureDroppableContainers:se,measuringScheduled:be}=Yqe(B,{dragging:C,dependencies:[A.x,A.y],config:X.droppable}),xe=Kqe(D,E),de=_.useMemo(()=>V?sR(V):null,[V]),Pe=ke(),ie=Qqe(xe,X.draggable.measure);xWe({activeNode:E!=null?D.get(E):null,config:Pe.layoutShiftCompensation,initialRect:ie,measure:X.draggable.measure});const Ne=oq(xe,X.draggable.measure,ie),Oe=oq(xe?xe.parentElement:null),ge=_.useRef({activatorEvent:null,active:null,activeNode:xe,collisionRect:null,collisions:null,droppableRects:ne,draggableNodes:D,draggingNode:null,draggingNodeRect:null,droppableContainers:R,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),Ke=R.getNodeFor((n=ge.current.over)==null?void 0:n.id),G=oWe({measure:X.dragOverlay.measure}),Y=(r=G.nodeRef.current)!=null?r:xe,ce=C?(i=G.rect)!=null?i:Ne:null,q=!!(G.nodeRef.current&&G.rect),te=eWe(q?null:Ne),I=Sre(Y?qs(Y):null),fe=tWe(C?Ke??xe:null),me=aWe(fe),Ee=pWe(m,{transform:{x:A.x-te.x,y:A.y-te.y,scaleX:1,scaleY:1},activatorEvent:V,active:$,activeNodeRect:Ne,containerNodeRect:Oe,draggingNodeRect:ce,over:ge.current.over,overlayNodeRect:G.rect,scrollableAncestors:fe,scrollableAncestorRects:me,windowRect:I}),z=de?Lg(de,A):null,O=nWe(fe),ee=cq(O),le=cq(O,[Ne]),_e=Lg(Ee,ee),we=ce?Mqe(ce,Ee):null,re=$&&we?f({active:$,collisionRect:we,droppableRects:ne,droppableContainers:B,pointerCoordinates:z}):null,Fe=hre(re,"id"),[He,Ve]=_.useState(null),$e=q?Ee:Lg(Ee,le),ye=_qe($e,(a=He?.rect)!=null?a:null,Ne),je=_.useRef(null),Be=_.useCallback((We,ze)=>{let{sensor:W,options:De}=ze;if(j.current==null)return;const Ye=D.get(j.current);if(!Ye)return;const xt=We.nativeEvent,ft=new W({active:j.current,activeNode:Ye,event:xt,options:De,context:ge,onAbort(Lt){if(!D.get(Lt))return;const{onDragAbort:Jt}=Z.current,ir={id:Lt};Jt?.(ir),S({type:"onDragAbort",event:ir})},onPending(Lt,vn,Jt,ir){if(!D.get(Lt))return;const{onDragPending:Dn}=Z.current,ln={id:Lt,constraint:vn,initialCoordinates:Jt,offset:ir};Dn?.(ln),S({type:"onDragPending",event:ln})},onStart(Lt){const vn=j.current;if(vn==null)return;const Jt=D.get(vn);if(!Jt)return;const{onDragStart:ir}=Z.current,fr={activatorEvent:xt,active:{id:vn,data:Jt.data,rect:F}};gu.unstable_batchedUpdates(()=>{ir?.(fr),k(qd.Initializing),v({type:Xi.DragStart,initialCoordinates:Lt,active:vn}),S({type:"onDragStart",event:fr}),K(je.current),Q(xt)})},onMove(Lt){v({type:Xi.DragMove,coordinates:Lt})},onEnd:Bt(Xi.DragEnd),onCancel:Bt(Xi.DragCancel)});je.current=ft;function Bt(Lt){return async function(){const{active:Jt,collisions:ir,over:fr,scrollAdjustedTranslate:Dn}=ge.current;let ln=null;if(Jt&&Dn){const{cancelDrop:mr}=Z.current;ln={activatorEvent:xt,active:Jt,collisions:ir,delta:Dn,over:fr},Lt===Xi.DragEnd&&typeof mr=="function"&&await Promise.resolve(mr(ln))&&(Lt=Xi.DragCancel)}j.current=null,gu.unstable_batchedUpdates(()=>{v({type:Lt}),k(qd.Uninitialized),Ve(null),K(null),Q(null),je.current=null;const mr=Lt===Xi.DragEnd?"onDragEnd":"onDragCancel";if(ln){const Fn=Z.current[mr];Fn?.(ln),S({type:mr,event:ln})}})}}},[D]),Se=_.useCallback((We,ze)=>(W,De)=>{const Ye=W.nativeEvent,xt=D.get(De);if(j.current!==null||!xt||Ye.dndKit||Ye.defaultPrevented)return;const ft={active:xt};We(W,ze.options,ft)===!0&&(Ye.dndKit={capturedBy:ze.sensor},j.current=De,Be(W,ze))},[D,Be]),Xe=Xqe(d,Se);rWe(d),Sc(()=>{Ne&&T===qd.Initializing&&k(qd.Initialized)},[Ne,T]),_.useEffect(()=>{const{onDragMove:We}=Z.current,{active:ze,activatorEvent:W,collisions:De,over:Ye}=ge.current;if(!ze||!W)return;const xt={active:ze,activatorEvent:W,collisions:De,delta:{x:_e.x,y:_e.y},over:Ye};gu.unstable_batchedUpdates(()=>{We?.(xt),S({type:"onDragMove",event:xt})})},[_e.x,_e.y]),_.useEffect(()=>{const{active:We,activatorEvent:ze,collisions:W,droppableContainers:De,scrollAdjustedTranslate:Ye}=ge.current;if(!We||j.current==null||!ze||!Ye)return;const{onDragOver:xt}=Z.current,ft=De.get(Fe),Bt=ft&&ft.rect.current?{id:ft.id,rect:ft.rect.current,data:ft.data,disabled:ft.disabled}:null,Lt={active:We,activatorEvent:ze,collisions:W,delta:{x:Ye.x,y:Ye.y},over:Bt};gu.unstable_batchedUpdates(()=>{Ve(Bt),xt?.(Lt),S({type:"onDragOver",event:Lt})})},[Fe]),Sc(()=>{ge.current={activatorEvent:V,active:$,activeNode:xe,collisionRect:we,collisions:re,droppableRects:ne,draggableNodes:D,draggingNode:Y,draggingNodeRect:ce,droppableContainers:R,over:He,scrollableAncestors:fe,scrollAdjustedTranslate:_e},F.current={initial:ce,translated:we}},[$,xe,re,we,D,Y,ce,ne,R,He,fe,_e]),Gqe({...Pe,delta:A,draggingRect:we,pointerCoordinates:z,scrollableAncestors:fe,scrollableAncestorRects:me});const Me=_.useMemo(()=>({active:$,activeNode:xe,activeNodeRect:Ne,activatorEvent:V,collisions:re,containerNodeRect:Oe,dragOverlay:G,draggableNodes:D,droppableContainers:R,droppableRects:ne,over:He,measureDroppableContainers:se,scrollableAncestors:fe,scrollableAncestorRects:me,measuringConfiguration:X,measuringScheduled:be,windowRect:I}),[$,xe,Ne,V,re,Oe,G,D,R,ne,He,se,fe,me,X,be,I]),tt=_.useMemo(()=>({activatorEvent:V,activators:Xe,active:$,activeNodeRect:Ne,ariaDescribedById:{draggable:ae},dispatch:v,draggableNodes:D,over:He,measureDroppableContainers:se}),[V,Xe,$,Ne,v,ae,D,He,se]);return Jr.createElement(lre.Provider,{value:N},Jr.createElement($2.Provider,{value:tt},Jr.createElement(Mre.Provider,{value:Me},Jr.createElement(Nre.Provider,{value:ye},u)),Jr.createElement(mWe,{disabled:l?.restoreFocus===!1})),Jr.createElement(xqe,{...l,hiddenTextDescribedById:ae}));function ke(){const We=H?.autoScrollEnabled===!1,ze=typeof c=="object"?c.enabled===!1:c===!1,W=C&&!We&&!ze;return typeof c=="object"?{...c,enabled:W}:{enabled:W}}}),bWe=_.createContext(null),dq="button",yWe="Draggable";function vWe(t){let{id:e,data:n,disabled:r=!1,attributes:i}=t;const a=_v(yWe),{activators:o,activatorEvent:l,active:c,activeNodeRect:u,ariaDescribedById:d,draggableNodes:f,over:p}=_.useContext($2),{role:m=dq,roleDescription:x="draggable",tabIndex:b=0}=i??{},y=c?.id===e,v=_.useContext(y?Nre:bWe),[S,N]=YM(),[T,k]=YM(),C=iWe(o,e),E=jy(n);Sc(()=>(f.set(e,{id:e,key:a,node:S,activatorNode:T,data:E}),()=>{const A=f.get(e);A&&A.key===a&&f.delete(e)}),[f,e]);const D=_.useMemo(()=>({role:m,tabIndex:b,"aria-disabled":r,"aria-pressed":y&&m===dq?!0:void 0,"aria-roledescription":x,"aria-describedby":d.draggable}),[r,m,b,y,x,d.draggable]);return{active:c,activatorEvent:l,activeNodeRect:u,attributes:D,isDragging:y,listeners:r?void 0:C,node:S,over:p,setNodeRef:N,setActivatorNodeRef:k,transform:v}}function wWe(){return _.useContext(Mre)}const _We="Droppable",SWe={timeout:25};function MWe(t){let{data:e,disabled:n=!1,id:r,resizeObserverConfig:i}=t;const a=_v(_We),{active:o,dispatch:l,over:c,measureDroppableContainers:u}=_.useContext($2),d=_.useRef({disabled:n}),f=_.useRef(!1),p=_.useRef(null),m=_.useRef(null),{disabled:x,updateMeasurementsFor:b,timeout:y}={...SWe,...i},v=jy(b??r),S=_.useCallback(()=>{if(!f.current){f.current=!0;return}m.current!=null&&clearTimeout(m.current),m.current=setTimeout(()=>{u(Array.isArray(v.current)?v.current:[v.current]),m.current=null},y)},[y]),N=H2({callback:S,disabled:x||!o}),T=_.useCallback((D,A)=>{N&&(A&&(N.unobserve(A),f.current=!1),D&&N.observe(D))},[N]),[k,C]=YM(T),E=jy(e);return _.useEffect(()=>{!N||!k.current||(N.disconnect(),f.current=!1,N.observe(k.current))},[k,N]),_.useEffect(()=>(l({type:Xi.RegisterDroppable,element:{id:r,key:a,disabled:n,node:k,rect:p,data:E}}),()=>l({type:Xi.UnregisterDroppable,key:a,id:r})),[r]),_.useEffect(()=>{n!==d.current.disabled&&(l({type:Xi.SetDroppableDisabled,id:r,key:a,disabled:n}),d.current.disabled=n)},[r,a,n,l]),{active:o,rect:p,isOver:c?.id===r,node:k,over:c,setNodeRef:C}}function V2(t,e,n){const r=t.slice();return r.splice(n<0?r.length+n:n,0,r.splice(e,1)[0]),r}function NWe(t,e){return t.reduce((n,r,i)=>{const a=e.get(r);return a&&(n[i]=a),n},Array(t.length))}function c1(t){return t!==null&&t>=0}function kWe(t,e){if(t===e)return!0;if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(t[n]!==e[n])return!1;return!0}function EWe(t){return typeof t=="boolean"?{draggable:t,droppable:t}:t}const lF=t=>{let{rects:e,activeIndex:n,overIndex:r,index:i}=t;const a=V2(e,r,n),o=e[i],l=a[i];return!l||!o?null:{x:l.left-o.left,y:l.top-o.top,scaleX:l.width/o.width,scaleY:l.height/o.height}},u1={scaleX:1,scaleY:1},TWe=t=>{var e;let{activeIndex:n,activeNodeRect:r,index:i,rects:a,overIndex:o}=t;const l=(e=a[n])!=null?e:r;if(!l)return null;if(i===n){const u=a[o];return u?{x:0,y:n<o?u.top+u.height-(l.top+l.height):u.top-l.top,...u1}:null}const c=AWe(a,i,n);return i>n&&i<=o?{x:0,y:-l.height-c,...u1}:i<n&&i>=o?{x:0,y:l.height+c,...u1}:{x:0,y:0,...u1}};function AWe(t,e,n){const r=t[e],i=t[e-1],a=t[e+1];return r?n<e?i?r.top-(i.top+i.height):a?a.top-(r.top+r.height):0:a?a.top-(r.top+r.height):i?r.top-(i.top+i.height):0:0}const Ere="Sortable",Tre=Jr.createContext({activeIndex:-1,containerId:Ere,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:lF,disabled:{draggable:!1,droppable:!1}});function Are(t){let{children:e,id:n,items:r,strategy:i=lF,disabled:a=!1}=t;const{active:o,dragOverlay:l,droppableRects:c,over:u,measureDroppableContainers:d}=wWe(),f=_v(Ere,n),p=l.rect!==null,m=_.useMemo(()=>r.map(C=>typeof C=="object"&&"id"in C?C.id:C),[r]),x=o!=null,b=o?m.indexOf(o.id):-1,y=u?m.indexOf(u.id):-1,v=_.useRef(m),S=!kWe(m,v.current),N=y!==-1&&b===-1||S,T=EWe(a);Sc(()=>{S&&x&&d(m)},[S,m,x,d]),_.useEffect(()=>{v.current=m},[m]);const k=_.useMemo(()=>({activeIndex:b,containerId:f,disabled:T,disableTransforms:N,items:m,overIndex:y,useDragOverlay:p,sortedRects:NWe(m,c),strategy:i}),[b,f,T.draggable,T.droppable,N,m,y,c,p,i]);return Jr.createElement(Tre.Provider,{value:k},e)}const CWe=t=>{let{id:e,items:n,activeIndex:r,overIndex:i}=t;return V2(n,r,i).indexOf(e)},jWe=t=>{let{containerId:e,isSorting:n,wasDragging:r,index:i,items:a,newIndex:o,previousItems:l,previousContainerId:c,transition:u}=t;return!u||!r||l!==a&&i===o?!1:n?!0:o!==i&&e===c},PWe={duration:200,easing:"ease"},Cre="transform",DWe=mx.Transition.toString({property:Cre,duration:0,easing:"linear"}),RWe={roleDescription:"sortable"};function OWe(t){let{disabled:e,index:n,node:r,rect:i}=t;const[a,o]=_.useState(null),l=_.useRef(n);return Sc(()=>{if(!e&&n!==l.current&&r.current){const c=i.current;if(c){const u=Ix(r.current,{ignoreTransform:!0}),d={x:c.left-u.left,y:c.top-u.top,scaleX:c.width/u.width,scaleY:c.height/u.height};(d.x||d.y)&&o(d)}}n!==l.current&&(l.current=n)},[e,n,r,i]),_.useEffect(()=>{a&&o(null)},[a]),a}function jre(t){let{animateLayoutChanges:e=jWe,attributes:n,disabled:r,data:i,getNewIndex:a=CWe,id:o,strategy:l,resizeObserverConfig:c,transition:u=PWe}=t;const{items:d,containerId:f,activeIndex:p,disabled:m,disableTransforms:x,sortedRects:b,overIndex:y,useDragOverlay:v,strategy:S}=_.useContext(Tre),N=LWe(r,m),T=d.indexOf(o),k=_.useMemo(()=>({sortable:{containerId:f,index:T,items:d},...i}),[f,i,T,d]),C=_.useMemo(()=>d.slice(d.indexOf(o)),[d,o]),{rect:E,node:D,isOver:A,setNodeRef:R}=MWe({id:o,data:k,disabled:N.droppable,resizeObserverConfig:{updateMeasurementsFor:C,...c}}),{active:U,activatorEvent:F,activeNodeRect:$,attributes:j,setNodeRef:H,listeners:K,isDragging:V,over:Q,setActivatorNodeRef:Z,transform:ae}=vWe({id:o,data:k,attributes:{...RWe,...n},disabled:N.draggable}),B=iqe(R,H),X=!!U,ne=X&&!x&&c1(p)&&c1(y),se=!v&&V,be=se&&ne?ae:null,de=ne?be??(l??S)({rects:b,activeNodeRect:$,activeIndex:p,overIndex:y,index:T}):null,Pe=c1(p)&&c1(y)?a({id:o,items:d,activeIndex:p,overIndex:y}):T,ie=U?.id,Ne=_.useRef({activeId:ie,items:d,newIndex:Pe,containerId:f}),Oe=d!==Ne.current.items,ge=e({active:U,containerId:f,isDragging:V,isSorting:X,id:o,index:T,items:d,newIndex:Ne.current.newIndex,previousItems:Ne.current.items,previousContainerId:Ne.current.containerId,transition:u,wasDragging:Ne.current.activeId!=null}),Ke=OWe({disabled:!ge,index:T,node:D,rect:E});return _.useEffect(()=>{X&&Ne.current.newIndex!==Pe&&(Ne.current.newIndex=Pe),f!==Ne.current.containerId&&(Ne.current.containerId=f),d!==Ne.current.items&&(Ne.current.items=d)},[X,Pe,f,d]),_.useEffect(()=>{if(ie===Ne.current.activeId)return;if(ie!=null&&Ne.current.activeId==null){Ne.current.activeId=ie;return}const Y=setTimeout(()=>{Ne.current.activeId=ie},50);return()=>clearTimeout(Y)},[ie]),{active:U,activeIndex:p,attributes:j,data:k,rect:E,index:T,newIndex:Pe,items:d,isOver:A,isSorting:X,isDragging:V,listeners:K,node:D,overIndex:y,over:Q,setNodeRef:B,setActivatorNodeRef:Z,setDroppableNodeRef:R,setDraggableNodeRef:H,transform:Ke??de,transition:G()};function G(){if(Ke||Oe&&Ne.current.newIndex===T)return DWe;if(!(se&&!aF(F)||!u)&&(X||ge))return mx.Transition.toString({...u,property:Cre})}}function LWe(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 eN(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 FWe=[Qn.Down,Qn.Right,Qn.Up,Qn.Left],Pre=(t,e)=>{let{context:{active:n,collisionRect:r,droppableRects:i,droppableContainers:a,over:o,scrollableAncestors:l}}=e;if(FWe.includes(t.code)){if(t.preventDefault(),!n||!r)return;const c=[];a.getEnabled().forEach(f=>{if(!f||f!=null&&f.disabled)return;const p=i.get(f.id);if(p)switch(t.code){case Qn.Down:r.top<p.top&&c.push(f);break;case Qn.Up:r.top>p.top&&c.push(f);break;case Qn.Left:r.left>p.left&&c.push(f);break;case Qn.Right:r.left<p.left&&c.push(f);break}});const u=yqe({collisionRect:r,droppableRects:i,droppableContainers:c});let d=hre(u,"id");if(d===o?.id&&u.length>1&&(d=u[1].id),d!=null){const f=a.get(n.id),p=a.get(d),m=p?i.get(p.id):null,x=p?.node.current;if(x&&m&&f&&p){const y=U2(x).some((C,E)=>l[E]!==C),v=Dre(f,p),S=IWe(f,p),N=y||!v?{x:0,y:0}:{x:S?r.width-m.width:0,y:S?r.height-m.height:0},T={x:m.left,y:m.top};return N.x&&N.y?T:Py(T,N)}}}};function Dre(t,e){return!eN(t)||!eN(e)?!1:t.data.current.sortable.containerId===e.data.current.sortable.containerId}function IWe(t,e){return!eN(t)||!eN(e)||!Dre(t,e)?!1:t.data.current.sortable.index<e.data.current.sortable.index}function Rre(t){if(!t)return"--";const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function UWe(t,e="system",n){if(!t)return n?.("queue.time.asap")??"ASAP";const r=Ii(t);if(!r)return n?.("queue.time.asap")??"ASAP";const i=new Date,a=r.getTime()-i.getTime();return a<-6e4?n?.("queue.time.overdue")??"Overdue":a<0?n?.("queue.time.now")??"Now":a<6e4?n?.("queue.time.lessThanMinute")??"In less than a minute":a<36e5?n?.("queue.time.inMinutes",{count:Math.round(a/6e4)})??`In ${Math.round(a/6e4)} min`:a<864e5?n?.("queue.time.inHours",{count:Math.round(a/36e5)})??`In ${Math.round(a/36e5)} hours`:Hg(t,e)}function zWe({status:t,waitingReason:e,t:n}){if(t==="pending"&&e)return s.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium border text-purple-400 bg-purple-400/10 border-purple-400/20",children:[s.jsx(er,{className:"w-3.5 h-3.5"}),n("queue.status.waiting")]});const r={pending:{icon:er,color:"text-status-warning bg-status-warning/10 border-status-warning/20",label:n("queue.status.pending")},printing:{icon:Is,color:"text-blue-400 bg-blue-400/10 border-blue-400/20",label:n("queue.status.printing")},completed:{icon:Ar,color:"text-status-ok bg-status-ok/10 border-status-ok/20",label:n("queue.status.completed")},failed:{icon:Yi,color:"text-status-error bg-status-error/10 border-status-error/20",label:n("queue.status.failed")},skipped:{icon:DR,color:"text-orange-400 bg-orange-400/10 border-orange-400/20",label:n("queue.status.skipped")},cancelled:{icon:Rt,color:"text-gray-400 bg-gray-400/10 border-gray-400/20",label:n("queue.status.cancelled")}},{icon:i,color:a,label:o}=r[t];return s.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium border ${a}`,children:[s.jsx(i,{className:"w-3.5 h-3.5"}),o]})}function BWe({selectedCount:t,printers:e,onSave:n,onClose:r,isSaving:i,t:a}){const[o,l]=_.useState("unchanged"),[c,u]=_.useState("unchanged"),[d,f]=_.useState("unchanged"),[p,m]=_.useState("unchanged"),[x,b]=_.useState("unchanged"),[y,v]=_.useState("unchanged"),[S,N]=_.useState("unchanged"),[T,k]=_.useState("unchanged"),[C,E]=_.useState("unchanged"),[D,A]=_.useState("unchanged"),R=()=>{const F={};o!=="unchanged"&&(F.printer_id=o),c!=="unchanged"&&(F.manual_start=c),d!=="unchanged"&&(F.auto_off_after=d),p!=="unchanged"&&(F.require_previous_success=p),x!=="unchanged"&&(F.bed_levelling=x),y!=="unchanged"&&(F.flow_cali=y),S!=="unchanged"&&(F.vibration_cali=S),T!=="unchanged"&&(F.layer_inspect=T),C!=="unchanged"&&(F.timelapse=C),D!=="unchanged"&&(F.use_ams=D),n(F)},U=o!=="unchanged"||c!=="unchanged"||d!=="unchanged"||p!=="unchanged"||x!=="unchanged"||y!=="unchanged"||S!=="unchanged"||T!=="unchanged"||C!=="unchanged"||D!=="unchanged";return s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-lg max-h-[90vh] overflow-y-auto",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:a("queue.bulkEdit.title",{count:t})}),s.jsx("button",{onClick:r,className:"p-1 hover:bg-bambu-dark rounded",children:s.jsx(Rt,{className:"w-5 h-5 text-bambu-gray"})})]}),s.jsxs("div",{className:"p-4 space-y-4",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:a("queue.bulkEdit.description")}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:a("queue.bulkEdit.printer")}),s.jsxs("select",{value:o===null?"null":o==="unchanged"?"unchanged":String(o),onChange:F=>{const $=F.target.value;l($==="unchanged"?"unchanged":$==="null"?null:Number($))},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"unchanged",children:a("queue.bulkEdit.noChange")}),s.jsx("option",{value:"null",children:a("queue.filter.unassigned")}),e.map(F=>s.jsx("option",{value:F.id,children:F.name},F.id))]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:a("queue.bulkEdit.queueOptions")}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(su,{label:a("queue.bulkEdit.staged"),value:c,onChange:u,t:a}),s.jsx(su,{label:a("queue.bulkEdit.autoPowerOff"),value:d,onChange:f,t:a}),s.jsx(su,{label:a("queue.bulkEdit.requirePrevious"),value:p,onChange:m,t:a})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:a("queue.bulkEdit.printOptions")}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(su,{label:a("queue.bulkEdit.bedLevelling"),value:x,onChange:b,t:a}),s.jsx(su,{label:a("queue.bulkEdit.flowCalibration"),value:y,onChange:v,t:a}),s.jsx(su,{label:a("queue.bulkEdit.vibrationCalibration"),value:S,onChange:N,t:a}),s.jsx(su,{label:a("queue.bulkEdit.layerInspection"),value:T,onChange:k,t:a}),s.jsx(su,{label:a("queue.bulkEdit.timelapse"),value:C,onChange:E,t:a}),s.jsx(su,{label:a("queue.bulkEdit.useAms"),value:D,onChange:A,t:a})]})]})]}),s.jsxs("div",{className:"flex justify-end gap-3 p-4 border-t border-bambu-dark-tertiary",children:[s.jsx(Te,{variant:"secondary",onClick:r,children:a("common.cancel")}),s.jsx(Te,{onClick:R,disabled:!U||i,children:a(i?"common.saving":"queue.bulkEdit.applyChanges")})]})]})})}function su({label:t,value:e,onChange:n,t:r}){return s.jsxs("div",{className:"flex items-center justify-between py-1",children:[s.jsx("span",{className:"text-sm text-bambu-gray",children:t}),s.jsxs("div",{className:"flex items-center gap-1 bg-bambu-dark rounded-lg p-0.5",children:[s.jsx("button",{onClick:()=>n("unchanged"),className:`px-2 py-1 text-xs rounded ${e==="unchanged"?"bg-bambu-dark-tertiary text-white":"text-bambu-gray hover:text-white"}`,children:"—"}),s.jsx("button",{onClick:()=>n(!1),className:`px-2 py-1 text-xs rounded ${e===!1?"bg-red-500/20 text-red-400":"text-bambu-gray hover:text-white"}`,children:r("common.off")}),s.jsx("button",{onClick:()=>n(!0),className:`px-2 py-1 text-xs rounded ${e===!0?"bg-bambu-green/20 text-bambu-green":"text-bambu-gray hover:text-white"}`,children:r("common.on")})]})]})}function Hj({item:t,position:e,onEdit:n,onCancel:r,onRemove:i,onStop:a,onRequeue:o,onStart:l,timeFormat:c="system",isSelected:u=!1,onToggleSelect:d,hasPermission:f,canModify:p,t:m}){const x=f("queue:reorder"),{attributes:b,listeners:y,setNodeRef:v,transform:S,transition:N,isDragging:T}=jre({id:t.id,disabled:t.status!=="pending"||!x}),k={transform:mx.Transform.toString(S),transition:N},C=t.status==="printing",E=t.status==="pending",D=["completed","failed","skipped","cancelled"].includes(t.status);return s.jsx("div",{ref:v,style:k,className:`
- group relative bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary
- transition-all duration-200 hover:border-bambu-dark-tertiary/80
- ${T?"opacity-50 scale-[1.02] shadow-xl z-50":""}
- ${C?"border-blue-500/30 bg-gradient-to-r from-blue-500/5 to-transparent":""}
- `,children:s.jsxs("div",{className:"flex items-center gap-4 p-4",children:[E&&d&&s.jsx("button",{onClick:A=>{A.stopPropagation(),d()},className:`flex items-center justify-center w-6 h-6 rounded border transition-colors ${u?"bg-bambu-green border-bambu-green text-white":"border-white/30 bg-black/30 hover:border-bambu-green/50"}`,children:u&&s.jsx(Ia,{className:"w-4 h-4"})}),E?s.jsx("div",{...b,...y,className:"flex items-center justify-center w-10 h-10 md:w-8 md:h-8 rounded-lg bg-bambu-dark cursor-grab active:cursor-grabbing hover:bg-bambu-dark-tertiary transition-colors touch-manipulation",children:s.jsx(zg,{className:"w-6 h-6 md:w-4 md:h-4 text-bambu-gray"})}):e!==void 0?s.jsxs("div",{className:"flex items-center justify-center w-8 h-8 rounded-lg bg-bambu-dark text-bambu-gray text-sm font-medium",children:["#",e]}):s.jsx("div",{className:"w-8"}),s.jsx("div",{className:"w-14 h-14 flex-shrink-0 bg-bambu-dark rounded-lg overflow-hidden",children:t.archive_thumbnail?s.jsx("img",{src:t.plate_id!=null?ue.getArchivePlateThumbnail(t.archive_id,t.plate_id):ue.getArchiveThumbnail(t.archive_id),alt:"",className:"w-full h-full object-cover"}):t.library_file_thumbnail?s.jsx("img",{src:t.plate_id!=null?ue.getLibraryFilePlateThumbnail(t.library_file_id,t.plate_id):ue.getLibraryFileThumbnailUrl(t.library_file_id),alt:"",className:"w-full h-full object-cover"}):s.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:s.jsx(sl,{className:"w-6 h-6"})})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[s.jsx("p",{className:"text-white font-medium truncate",children:t.archive_name||t.library_file_name||`File #${t.archive_id||t.library_file_id}`}),t.archive_id?s.jsx(Ds,{to:`/archives?highlight=${t.archive_id}`,className:"text-bambu-gray hover:text-bambu-green transition-colors flex-shrink-0",title:m("queue.viewArchive"),children:s.jsx(Kr,{className:"w-3.5 h-3.5"})}):t.library_file_id?s.jsx(Ds,{to:`/library?highlight=${t.library_file_id}`,className:"text-bambu-gray hover:text-bambu-green transition-colors flex-shrink-0",title:m("queue.viewInFileManager"),children:s.jsx(Kr,{className:"w-3.5 h-3.5"})}):null]}),s.jsxs("div",{className:"flex items-center gap-3 text-sm text-bambu-gray",children:[s.jsxs("span",{className:`flex items-center gap-1.5 ${t.printer_id===null&&!t.target_model?"text-orange-400":""} ${t.target_model?"text-blue-400":""}`,children:[s.jsx(Ur,{className:"w-3.5 h-3.5"}),t.target_model?`${m("queue.filter.any")} ${t.target_model}${t.target_location?` @ ${t.target_location}`:""}${t.required_filament_types?.length?` (${t.required_filament_types.join(", ")})`:""}`:t.printer_id===null?m("queue.filter.unassigned"):t.printer_name||`${m("common.printer")} #${t.printer_id}`]}),t.print_time_seconds&&s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsx(xu,{className:"w-3.5 h-3.5"}),Rre(t.print_time_seconds)]}),t.created_by_username&&s.jsxs("span",{className:"flex items-center gap-1.5",title:m("queue.addedBy",{name:t.created_by_username}),children:[s.jsx(am,{className:"w-3.5 h-3.5"}),t.created_by_username]}),E&&!t.manual_start&&s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsx(er,{className:"w-3.5 h-3.5"}),UWe(t.scheduled_time,c,m)]})]}),s.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[t.manual_start&&s.jsxs("span",{className:"text-xs px-2 py-0.5 bg-purple-500/10 text-purple-400 rounded-full border border-purple-500/20 flex items-center gap-1",children:[s.jsx(bW,{className:"w-3 h-3"}),m("queue.badges.staged")]}),t.require_previous_success&&s.jsx("span",{className:"text-xs px-2 py-0.5 bg-orange-500/10 text-orange-400 rounded-full border border-orange-500/20",children:m("queue.badges.requiresPrevious")}),t.auto_off_after&&s.jsxs("span",{className:"text-xs px-2 py-0.5 bg-blue-500/10 text-blue-400 rounded-full border border-blue-500/20 flex items-center gap-1",children:[s.jsx(Gu,{className:"w-3 h-3"}),m("queue.badges.autoPowerOff")]})]}),C&&s.jsxs("div",{className:"mt-3",children:[s.jsx("div",{className:"h-2 bg-bambu-dark rounded-full overflow-hidden",children:s.jsx("div",{className:"h-full bg-gradient-to-r from-blue-500 to-blue-400 animate-pulse w-full opacity-50"})}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:m("queue.printingInProgress")})]}),t.waiting_reason&&t.status==="pending"&&s.jsxs("p",{className:"text-xs text-purple-400 mt-2 flex items-start gap-1",children:[s.jsx(Hi,{className:"w-3 h-3 mt-0.5 flex-shrink-0"}),s.jsx("span",{children:t.waiting_reason})]}),t.error_message&&s.jsxs("p",{className:"text-xs text-red-400 mt-2 flex items-center gap-1",children:[s.jsx(Hi,{className:"w-3 h-3"}),t.error_message]})]}),s.jsx(zWe,{status:t.status,waitingReason:t.waiting_reason,t:m}),s.jsxs("div",{className:"flex items-center gap-1",children:[C&&s.jsx(Te,{variant:"ghost",size:"sm",onClick:a,disabled:!f("printers:control"),title:f("printers:control")?m("queue.actions.stopPrint"):m("queue.permissions.noStopPrint"),className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:s.jsx(Xce,{className:"w-4 h-4"})}),E&&s.jsxs(s.Fragment,{children:[t.manual_start&&s.jsx(Te,{variant:"ghost",size:"sm",onClick:l,disabled:!f("printers:control"),title:f("printers:control")?m("queue.actions.startPrint"):m("queue.permissions.noStartPrint"),className:"text-bambu-green hover:text-bambu-green-light hover:bg-bambu-green/10",children:s.jsx(Is,{className:"w-4 h-4"})}),s.jsx(Te,{variant:"ghost",size:"sm",onClick:n,disabled:!p("queue","update",t.created_by_id),title:p("queue","update",t.created_by_id)?m("common.edit"):m("queue.permissions.noEdit"),children:s.jsx(Qi,{className:"w-4 h-4"})}),s.jsx(Te,{variant:"ghost",size:"sm",onClick:r,disabled:!p("queue","delete",t.created_by_id),title:p("queue","delete",t.created_by_id)?m("common.cancel"):m("queue.permissions.noCancel"),className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:s.jsx(Rt,{className:"w-4 h-4"})})]}),D&&s.jsxs(s.Fragment,{children:[s.jsx(Te,{variant:"ghost",size:"sm",onClick:o,disabled:!f("queue:create"),title:f("queue:create")?m("queue.actions.requeue"):m("queue.permissions.noRequeue"),className:"text-bambu-green hover:text-bambu-green/80 hover:bg-bambu-green/10",children:s.jsx(Dr,{className:"w-4 h-4"})}),s.jsx(Te,{variant:"ghost",size:"sm",onClick:i,disabled:!p("queue","delete",t.created_by_id),title:p("queue","delete",t.created_by_id)?m("common.remove"):m("queue.permissions.noRemove"),children:s.jsx(rn,{className:"w-4 h-4"})})]})]})]})})}function HWe(){const{t}=Hn(),e=an(),{showToast:n}=$n(),{hasPermission:r,hasAnyPermission:i,canModify:a}=Ai(),[o,l]=_.useState(null),[c,u]=_.useState(""),[d,f]=_.useState(""),[p,m]=_.useState(!1),[x,b]=_.useState(null),[y,v]=_.useState(null),[S,N]=_.useState(null),[T,k]=_.useState([]),[C,E]=_.useState(!1),[D,A]=_.useState(()=>localStorage.getItem("queue.historySortBy")||"date"),[R,U]=_.useState(()=>{const I=localStorage.getItem("queue.historySortAsc");return I!==null?I==="true":!1}),[F,$]=_.useState(()=>localStorage.getItem("queue.pendingSortBy")||"position"),[j,H]=_.useState(()=>{const I=localStorage.getItem("queue.pendingSortAsc");return I!==null?I==="true":!0});_.useEffect(()=>{localStorage.setItem("queue.historySortBy",D)},[D]),_.useEffect(()=>{localStorage.setItem("queue.historySortAsc",String(R))},[R]),_.useEffect(()=>{localStorage.setItem("queue.pendingSortBy",F)},[F]),_.useEffect(()=>{localStorage.setItem("queue.pendingSortAsc",String(j))},[j]);const K=cre(ZM(B2,{activationConstraint:{distance:8}}),ZM(z2,{coordinateGetter:Pre})),{data:V}=at({queryKey:["settings"],queryFn:ue.getSettings}),Q=V?.time_format||"system",{data:Z,isLoading:ae}=at({queryKey:["queue",o,c],queryFn:()=>ue.getQueue(o||void 0,c||void 0),refetchInterval:5e3}),{data:B}=at({queryKey:["printers"],queryFn:()=>ue.getPrinters()}),X=mt({mutationFn:I=>ue.cancelQueueItem(I),onSuccess:()=>{e.invalidateQueries({queryKey:["queue"]}),n(t("queue.toast.cancelled"))},onError:()=>n(t("queue.toast.cancelFailed"),"error")}),ne=mt({mutationFn:I=>ue.removeFromQueue(I),onSuccess:()=>{e.invalidateQueries({queryKey:["queue"]}),n(t("queue.toast.removed"))},onError:()=>n(t("queue.toast.removeFailed"),"error")}),se=mt({mutationFn:I=>ue.stopQueueItem(I),onSuccess:()=>{e.invalidateQueries({queryKey:["queue"]}),n(t("queue.toast.stopped"))},onError:()=>n(t("queue.toast.stopFailed"),"error")}),be=mt({mutationFn:I=>ue.startQueueItem(I),onSuccess:()=>{e.invalidateQueries({queryKey:["queue"]}),n(t("queue.toast.released"))},onError:()=>n(t("queue.toast.startFailed"),"error")}),xe=mt({mutationFn:I=>ue.reorderQueue(I),onSuccess:()=>{e.invalidateQueries({queryKey:["queue"]})},onError:()=>n(t("queue.toast.reorderFailed"),"error")}),de=mt({mutationFn:async()=>{const I=Z?.filter(fe=>["completed","failed","skipped","cancelled"].includes(fe.status))||[];for(const fe of I)await ue.removeFromQueue(fe.id);return I.length},onSuccess:I=>{e.invalidateQueries({queryKey:["queue"]}),n(t("queue.toast.historyCleared",{count:I}))},onError:()=>n(t("queue.toast.clearHistoryFailed"),"error")}),Pe=mt({mutationFn:I=>ue.bulkUpdateQueue(I),onSuccess:I=>{e.invalidateQueries({queryKey:["queue"]}),k([]),E(!1),n(I.message)},onError:()=>n(t("queue.toast.updateFailed"),"error")}),ie=mt({mutationFn:async I=>{for(const fe of I)await ue.cancelQueueItem(fe);return I.length},onSuccess:I=>{e.invalidateQueries({queryKey:["queue"]}),k([]),n(t("queue.toast.bulkCancelled",{count:I}))},onError:()=>n(t("queue.toast.bulkCancelFailed"),"error")}),Ne=I=>{k(fe=>fe.includes(I)?fe.filter(me=>me!==I):[...fe,I])},Oe=_.useMemo(()=>{const I=new Set;return B?.forEach(fe=>{fe.location&&I.add(fe.location)}),Z?.forEach(fe=>{fe.target_location&&I.add(fe.target_location)}),Array.from(I).sort()},[B,Z]),ge=_.useCallback(I=>d?I.target_location?I.target_location===d:I.printer_id?B?.find(me=>me.id===I.printer_id)?.location===d:!1:!0,[d,B]),Ke=_.useMemo(()=>{let I=Z?.filter(me=>me.status==="pending")||[];d&&(I=I.filter(ge));const fe=me=>{if(!me.scheduled_time)return 0;const Ee=new Date(me.scheduled_time).getTime(),z=Date.now()+4320*60*60*1e3;return Ee>z?0:Ee};return[...I].sort((me,Ee)=>{let z;if(F==="name"){const O=me.archive_name||me.library_file_name||"",ee=Ee.archive_name||Ee.library_file_name||"";z=O.localeCompare(ee)}else F==="printer"?z=(me.printer_name||"").localeCompare(Ee.printer_name||""):F==="time"?z=fe(me)-fe(Ee):z=me.position-Ee.position;return j?z:-z})},[Z,F,j,ge,d]),G=()=>{const I=Ke.map(fe=>fe.id);T.length===I.length?k([]):k(I)},Y=_.useMemo(()=>{let I=Z?.filter(fe=>fe.status==="printing")||[];return d&&(I=I.filter(ge)),I},[Z,d,ge]),ce=_.useMemo(()=>{let I=Z?.filter(fe=>["completed","failed","skipped","cancelled"].includes(fe.status))||[];return d&&(I=I.filter(ge)),[...I].sort((fe,me)=>{let Ee;if(D==="name"){const z=fe.archive_name||fe.library_file_name||"",O=me.archive_name||me.library_file_name||"";Ee=z.localeCompare(O)}else D==="printer"?Ee=(fe.printer_name||"").localeCompare(me.printer_name||""):Ee=new Date(me.completed_at||me.created_at).getTime()-new Date(fe.completed_at||fe.created_at).getTime();return R?-Ee:Ee})},[Z,D,R,ge,d]),q=_.useMemo(()=>Ke.reduce((I,fe)=>I+(fe.print_time_seconds||0),0),[Ke]),te=I=>{const{active:fe,over:me}=I;if(!me||fe.id===me.id)return;const Ee=Ke.findIndex(O=>O.id===fe.id),z=Ke.findIndex(O=>O.id===me.id);if(Ee!==-1&&z!==-1){const ee=V2(Ke,Ee,z).map((le,_e)=>({id:le.id,position:_e+1}));xe.mutate(ee)}};return s.jsxs("div",{className:"p-4 md:p-8",children:[s.jsx("div",{className:"flex items-center justify-between mb-8",children:s.jsxs("div",{children:[s.jsxs("h1",{className:"text-2xl font-bold text-white flex items-center gap-3",children:[s.jsx(yW,{className:"w-7 h-7 text-bambu-green"}),t("queue.title")]}),s.jsx("p",{className:"text-bambu-gray mt-1",children:t("queue.subtitle")})]})}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4 mb-8",children:[s.jsx(_t,{className:"bg-gradient-to-br from-blue-500/10 to-transparent border-blue-500/20",children:s.jsx(Mt,{className:"p-4",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-10 h-10 rounded-lg bg-blue-500/20 flex items-center justify-center",children:s.jsx(Is,{className:"w-5 h-5 text-blue-400"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl font-bold text-white",children:Y.length}),s.jsx("p",{className:"text-sm text-bambu-gray",children:t("queue.summary.printing")})]})]})})}),s.jsx(_t,{className:"bg-gradient-to-br from-yellow-500/10 to-transparent border-yellow-500/20",children:s.jsx(Mt,{className:"p-4",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-10 h-10 rounded-lg bg-yellow-500/20 flex items-center justify-center",children:s.jsx(er,{className:"w-5 h-5 text-yellow-400"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl font-bold text-white",children:Ke.length}),s.jsx("p",{className:"text-sm text-bambu-gray",children:t("queue.summary.queued")})]})]})})}),s.jsx(_t,{className:"bg-gradient-to-br from-bambu-green/10 to-transparent border-bambu-green/20",children:s.jsx(Mt,{className:"p-4",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-10 h-10 rounded-lg bg-bambu-green/20 flex items-center justify-center",children:s.jsx(xu,{className:"w-5 h-5 text-bambu-green"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl font-bold text-white",children:Rre(q)}),s.jsx("p",{className:"text-sm text-bambu-gray",children:t("queue.summary.totalTime")})]})]})})}),s.jsx(_t,{className:"bg-gradient-to-br from-gray-500/10 to-transparent border-gray-500/20",children:s.jsx(Mt,{className:"p-4",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-10 h-10 rounded-lg bg-gray-500/20 flex items-center justify-center",children:s.jsx(Ar,{className:"w-5 h-5 text-gray-400"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl font-bold text-white",children:ce.length}),s.jsx("p",{className:"text-sm text-bambu-gray",children:t("queue.summary.history")})]})]})})})]}),s.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[s.jsxs("select",{className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:o===-1?"unassigned":o||"",onChange:I=>{const fe=I.target.value;l(fe==="unassigned"?-1:fe===""?null:Number(fe))},children:[s.jsx("option",{value:"",children:t("queue.filter.allPrinters")}),s.jsx("option",{value:"unassigned",children:t("queue.filter.unassigned")}),B?.map(I=>s.jsx("option",{value:I.id,children:I.name},I.id))]}),s.jsxs("select",{className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:c,onChange:I=>u(I.target.value),children:[s.jsx("option",{value:"",children:t("queue.filter.allStatus")}),s.jsx("option",{value:"pending",children:t("queue.status.pending")}),s.jsx("option",{value:"printing",children:t("queue.status.printing")}),s.jsx("option",{value:"completed",children:t("queue.status.completed")}),s.jsx("option",{value:"failed",children:t("queue.status.failed")}),s.jsx("option",{value:"skipped",children:t("queue.status.skipped")}),s.jsx("option",{value:"cancelled",children:t("queue.status.cancelled")})]}),Oe.length>0&&s.jsxs("select",{className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:d,onChange:I=>f(I.target.value),children:[s.jsx("option",{value:"",children:t("queue.filter.allLocations")}),Oe.map(I=>s.jsx("option",{value:I,children:I},I))]}),s.jsx("div",{className:"flex-1"}),ce.length>0&&s.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>m(!0),disabled:!r("queue:delete_all"),title:r("queue:delete_all")?void 0:t("queue.permissions.noClearHistory"),children:[s.jsx(rn,{className:"w-4 h-4"}),t("queue.clearHistory")]})]}),ae?s.jsx("div",{className:"text-center py-12 text-bambu-gray",children:t("common.loading")}):Z?.length===0?s.jsxs(_t,{className:"p-12 text-center border-dashed",children:[s.jsx(si,{className:"w-16 h-16 text-bambu-gray mx-auto mb-4 opacity-50"}),s.jsx("h3",{className:"text-xl font-medium text-white mb-2",children:t("queue.empty.title")}),s.jsx("p",{className:"text-bambu-gray max-w-md mx-auto",children:t("queue.empty.description")})]}):s.jsxs("div",{className:"space-y-8",children:[Y.length>0&&s.jsxs("div",{children:[s.jsxs("h2",{className:"text-lg font-semibold text-white mb-4 flex items-center gap-2",children:[s.jsx("div",{className:"w-2 h-2 rounded-full bg-blue-400 animate-pulse"}),t("queue.sections.currentlyPrinting")]}),s.jsx("div",{className:"space-y-3",children:Y.map(I=>s.jsx(Hj,{item:I,onEdit:()=>{},onCancel:()=>{},onRemove:()=>{},onStop:()=>N({type:"stop",item:I}),onRequeue:()=>{},onStart:()=>{},timeFormat:Q,hasPermission:r,canModify:a,t},I.id))})]}),Ke.length>0&&s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(er,{className:"w-5 h-5 text-yellow-400"}),t("queue.sections.queued"),s.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",t("queue.itemCount",{count:Ke.length}),")"]}),s.jsx("span",{className:"text-xs text-bambu-gray ml-2",title:t("queue.reorderHint"),children:t("queue.dragToReorder")})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("select",{className:"px-3 py-1.5 text-sm bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:F,onChange:I=>$(I.target.value),children:[s.jsx("option",{value:"position",children:t("queue.sort.byPosition")}),s.jsx("option",{value:"name",children:t("queue.sort.byName")}),s.jsx("option",{value:"printer",children:t("queue.sort.byPrinter")}),s.jsx("option",{value:"time",children:t("queue.sort.bySchedule")})]}),s.jsx(Te,{variant:"ghost",size:"sm",onClick:()=>H(!j),title:t(j?"common.ascending":"common.descending"),className:"px-2",children:j?s.jsx(Ig,{className:"w-4 h-4"}):s.jsx(G0,{className:"w-4 h-4"})})]})]}),s.jsxs("div",{className:"flex items-center gap-3 mb-4 p-3 bg-bambu-dark rounded-lg",children:[s.jsxs(Te,{variant:"ghost",size:"sm",onClick:G,className:"flex items-center gap-2",children:[T.length===Ke.length&&Ke.length>0?s.jsx(ol,{className:"w-4 h-4 text-bambu-green"}):s.jsx(ll,{className:"w-4 h-4"}),T.length===Ke.length&&Ke.length>0?t("queue.bulkEdit.deselectAll"):t("queue.bulkEdit.selectAll")]}),T.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-sm text-bambu-gray",children:t("queue.bulkEdit.selected",{count:T.length})}),s.jsx("div",{className:"h-4 w-px bg-bambu-dark-tertiary"}),s.jsxs(Te,{variant:"ghost",size:"sm",onClick:()=>E(!0),className:"flex items-center gap-2 text-bambu-green hover:text-bambu-green-light",disabled:!i("queue:update_own","queue:update_all"),title:i("queue:update_own","queue:update_all")?void 0:t("queue.permissions.noEditItems"),children:[s.jsx(Qi,{className:"w-4 h-4"}),t("queue.bulkEdit.editSelected")]}),s.jsxs(Te,{variant:"ghost",size:"sm",onClick:()=>ie.mutate(T),className:"flex items-center gap-2 text-red-400 hover:text-red-300",disabled:ie.isPending||!i("queue:delete_own","queue:delete_all"),title:i("queue:delete_own","queue:delete_all")?void 0:t("queue.permissions.noCancelItems"),children:[s.jsx(Rt,{className:"w-4 h-4"}),t("queue.bulkEdit.cancelSelected")]})]})]}),s.jsx(kre,{sensors:K,collisionDetection:fre,onDragEnd:te,children:s.jsx(Are,{items:Ke.map(I=>I.id),strategy:TWe,children:s.jsx("div",{className:"space-y-3",children:Ke.map((I,fe)=>s.jsx(Hj,{item:I,position:fe+1,onEdit:()=>b(I),onCancel:()=>N({type:"cancel",item:I}),onRemove:()=>{},onStop:()=>{},onRequeue:()=>{},onStart:()=>be.mutate(I.id),timeFormat:Q,isSelected:T.includes(I.id),onToggleSelect:()=>Ne(I.id),hasPermission:r,canModify:a,t},I.id))})})})]}),ce.length>0&&s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(Ar,{className:"w-5 h-5 text-bambu-gray"}),t("queue.sections.history"),s.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",t("queue.itemCount",{count:ce.length}),")"]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("select",{className:"px-3 py-1.5 text-sm bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:D,onChange:I=>A(I.target.value),children:[s.jsx("option",{value:"date",children:t("queue.sort.byDate")}),s.jsx("option",{value:"name",children:t("queue.sort.byName")}),s.jsx("option",{value:"printer",children:t("queue.sort.byPrinter")})]}),s.jsx(Te,{variant:"ghost",size:"sm",onClick:()=>U(!R),title:t(R?"queue.sort.ascendingOldest":"queue.sort.descendingNewest"),className:"px-2",children:R?s.jsx(Ig,{className:"w-4 h-4"}):s.jsx(G0,{className:"w-4 h-4"})})]})]}),s.jsx("div",{className:"space-y-3",children:ce.slice(0,20).map((I,fe)=>s.jsx(Hj,{item:I,position:fe+1,onEdit:()=>{},onCancel:()=>{},onRemove:()=>N({type:"remove",item:I}),onStop:()=>{},onRequeue:()=>v(I),onStart:()=>{},timeFormat:Q,hasPermission:r,canModify:a,t},I.id))})]})]}),x&&s.jsx(jh,{mode:"edit-queue-item",archiveId:x.archive_id??void 0,libraryFileId:x.library_file_id??void 0,archiveName:x.archive_name||x.library_file_name||`File #${x.archive_id||x.library_file_id}`,queueItem:x,onClose:()=>b(null)}),y&&s.jsx(jh,{mode:"add-to-queue",archiveId:y.archive_id??void 0,libraryFileId:y.library_file_id??void 0,archiveName:y.archive_name||y.library_file_name||`File #${y.archive_id||y.library_file_id}`,onClose:()=>v(null)}),S&&s.jsx(Zn,{title:S.type==="cancel"?t("queue.confirm.cancelTitle"):S.type==="stop"?t("queue.confirm.stopTitle"):t("queue.confirm.removeTitle"),message:S.type==="cancel"?t("queue.confirm.cancelMessage",{name:S.item.archive_name||S.item.library_file_name||t("queue.confirm.thisPrint")}):S.type==="stop"?t("queue.confirm.stopMessage",{name:S.item.archive_name||S.item.library_file_name||t("queue.confirm.thisPrint")}):t("queue.confirm.removeMessage",{name:S.item.archive_name||S.item.library_file_name||t("queue.confirm.thisItem")}),confirmText:S.type==="cancel"?t("queue.confirm.cancelButton"):S.type==="stop"?t("queue.confirm.stopButton"):t("common.remove"),variant:"danger",onConfirm:()=>{S.type==="cancel"?X.mutate(S.item.id):S.type==="stop"?se.mutate(S.item.id):ne.mutate(S.item.id),N(null)},onCancel:()=>N(null)}),p&&s.jsx(Zn,{title:t("queue.confirm.clearHistoryTitle"),message:t("queue.confirm.clearHistoryMessage",{count:ce.length}),confirmText:t("queue.clearHistory"),variant:"danger",onConfirm:()=>{de.mutate(),m(!1)},onCancel:()=>m(!1)}),C&&s.jsx(BWe,{selectedCount:T.length,printers:B?.map(I=>({id:I.id,name:I.name}))||[],onSave:I=>{Object.keys(I).length>0&&Pe.mutate({item_ids:T,...I})},onClose:()=>E(!1),isSaving:Pe.isPending,t})]})}function $We({printDates:t,months:e=3}){const n=_.useRef(null),[r,i]=_.useState(0);_.useEffect(()=>{const S=n.current;if(!S)return;const N=new ResizeObserver(T=>{const k=T[0]?.contentRect.width||0;i(k)});return N.observe(S),()=>N.disconnect()},[]);const{weeks:a,monthLabels:o,printCounts:l}=_.useMemo(()=>{const S={};t.forEach(U=>{const F=U.split("T")[0];S[F]=(S[F]||0)+1});const N=new Date,T=new Date(N);T.setMonth(T.getMonth()-e),T.setDate(T.getDate()-T.getDay());const k=[],C=[];let E=[],D=-1;const A=new Date(T);let R=0;for(;A<=N;)A.getDay()===0&&E.length>0&&(k.push(E),E=[],R++),A.getMonth()!==D&&(C.push({month:A.toLocaleDateString("en-US",{month:"short"}),weekIndex:R}),D=A.getMonth()),E.push(new Date(A)),A.setDate(A.getDate()+1);return E.length>0&&k.push(E),{weeks:k,monthLabels:C,printCounts:S}},[t,e]),c=Math.max(1,...Object.values(l)),u=S=>{if(S===0)return"bg-bambu-dark";const N=S/c;return N<=.25?"bg-bambu-green/30":N<=.5?"bg-bambu-green/50":N<=.75?"bg-bambu-green/75":"bg-bambu-green"},d=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],f=a.length,p=32,m=2,x=r-p-16,b=f>0?Math.floor((x-(f-1)*m)/f):12,y=Math.max(8,Math.min(20,b)),v=y<=10?10:12;return s.jsx("div",{ref:n,className:"w-full flex justify-center",children:r>0&&s.jsxs("div",{children:[s.jsx("div",{className:"flex mb-1",style:{marginLeft:p+4},children:o.map(({month:S,weekIndex:N},T)=>s.jsx("div",{className:"text-bambu-gray",style:{fontSize:v,marginLeft:T===0?0:`${(N-(o[T-1]?.weekIndex||0))*(y+m)-24}px`},children:S},T))}),s.jsxs("div",{className:"flex",style:{gap:m},children:[s.jsx("div",{className:"flex flex-col",style:{gap:m,marginRight:4,width:p},children:d.map((S,N)=>s.jsx("div",{className:"text-bambu-gray flex items-center",style:{width:p,height:y,fontSize:v,visibility:N%2===1?"visible":"hidden"},children:S},S))}),a.map((S,N)=>s.jsx("div",{className:"flex flex-col",style:{gap:m},children:[0,1,2,3,4,5,6].map(T=>{const k=S.find(A=>A.getDay()===T);if(!k)return s.jsx("div",{style:{width:y,height:y}},T);const C=k.toISOString().split("T")[0],E=l[C]||0,D=C===new Date().toISOString().split("T")[0];return s.jsx("div",{className:`rounded-sm ${u(E)} ${D?"ring-1 ring-white":""}`,style:{width:y,height:y},title:`${k.toLocaleDateString()}: ${E} print${E!==1?"s":""}`},T)})},N))]}),s.jsxs("div",{className:"flex items-center gap-2 mt-3 text-bambu-gray",style:{fontSize:v},children:[s.jsx("span",{children:"Less"}),s.jsxs("div",{className:"flex",style:{gap:m},children:[s.jsx("div",{className:"rounded-sm bg-bambu-dark",style:{width:y,height:y}}),s.jsx("div",{className:"rounded-sm bg-bambu-green/30",style:{width:y,height:y}}),s.jsx("div",{className:"rounded-sm bg-bambu-green/50",style:{width:y,height:y}}),s.jsx("div",{className:"rounded-sm bg-bambu-green/75",style:{width:y,height:y}}),s.jsx("div",{className:"rounded-sm bg-bambu-green",style:{width:y,height:y}})]}),s.jsx("span",{children:"More"})]})]})})}const d1=["#00ae42","#3b82f6","#f59e0b","#ef4444","#8b5cf6","#ec4899","#14b8a6","#f97316"];function VWe(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 GWe({archives:t,currency:e="$"}){const[n,r]=_.useState("30d"),i=_.useMemo(()=>{const m=VWe(n);return t.filter(x=>(Ii(x.completed_at||x.created_at)||new Date(0))>=m)},[t,n]),a=_.useMemo(()=>{const m=new Map;return i.forEach(x=>{const b=Ii(x.completed_at||x.created_at)||new Date,y=`${b.getFullYear()}-${String(b.getMonth()+1).padStart(2,"0")}-${String(b.getDate()).padStart(2,"0")}`,v=m.get(y)||{date:y,filament:0,cost:0,prints:0},S=x.quantity||1;v.filament+=(x.filament_used_grams||0)*S,v.cost+=x.cost||0,v.prints+=S,m.set(y,v)}),Array.from(m.values()).sort((x,b)=>x.date.localeCompare(b.date)).map(x=>({...x,dateLabel:new Date(x.date).toLocaleDateString("en-US",{month:"short",day:"numeric"})}))},[i]),o=_.useMemo(()=>{if(n==="7d"||n==="30d")return a;const m=new Map;return i.forEach(x=>{const b=Ii(x.completed_at||x.created_at)||new Date,y=new Date(b);y.setDate(b.getDate()-b.getDay());const v=`${y.getFullYear()}-${String(y.getMonth()+1).padStart(2,"0")}-${String(y.getDate()).padStart(2,"0")}`,S=m.get(v)||{week:v,filament:0,cost:0,prints:0},N=x.quantity||1;S.filament+=(x.filament_used_grams||0)*N,S.cost+=x.cost||0,S.prints+=N,m.set(v,S)}),Array.from(m.values()).sort((x,b)=>x.week.localeCompare(b.week)).map(x=>({date:x.week,dateLabel:`Week of ${new Date(x.week).toLocaleDateString("en-US",{month:"short",day:"numeric"})}`,...x}))},[i,a,n]),l=_.useMemo(()=>{const m=new Map;return i.forEach(x=>{const b=x.filament_type||"Unknown",y=x.quantity||1,v=b.split(", ");v.forEach(S=>{const N=(x.filament_used_grams||0)*y/v.length;m.set(S,(m.get(S)||0)+N)})}),Array.from(m.entries()).map(([x,b])=>({name:x,value:Math.round(b)})).sort((x,b)=>b.value-x.value)},[i]),c=_.useMemo(()=>{const m=new Date,x=[];for(let b=5;b>=0;b--){const y=new Date(m.getFullYear(),m.getMonth()-b,1),v=new Date(m.getFullYear(),m.getMonth()-b+1,0),S=y.toLocaleDateString("en-US",{month:"short",year:"2-digit"}),N=t.filter(T=>{const k=Ii(T.completed_at||T.created_at)||new Date(0);return k>=y&&k<=v});x.push({month:S,filament:Math.round(N.reduce((T,k)=>T+(k.filament_used_grams||0)*(k.quantity||1),0)),cost:N.reduce((T,k)=>T+(k.cost||0),0),prints:N.reduce((T,k)=>T+(k.quantity||1),0)})}return x},[t]),u=n==="7d"||n==="30d"?a:o,d=i.reduce((m,x)=>m+(x.filament_used_grams||0)*(x.quantity||1),0),f=i.reduce((m,x)=>m+(x.cost||0),0),p=i.reduce((m,x)=>m+(x.quantity||1),0);return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("h3",{className:"text-lg font-semibold text-white",children:"Filament Usage Trends"}),s.jsx("div",{className:"flex gap-1 bg-bambu-dark rounded-lg p-1",children:["7d","30d","90d","365d","all"].map(m=>s.jsx("button",{onClick:()=>r(m),className:`px-3 py-1 text-sm rounded-md transition-colors ${n===m?"bg-bambu-green text-white":"text-bambu-gray hover:text-white"}`,children:m==="all"?"All":m.replace("d","D")},m))})]}),s.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Period Filament"}),s.jsxs("p",{className:"text-2xl font-bold text-white",children:[(d/1e3).toFixed(2),"kg"]}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[d.toFixed(0),"g total"]})]}),s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Period Cost"}),s.jsxs("p",{className:"text-2xl font-bold text-white",children:[e,f.toFixed(2)]}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[p," prints"]})]}),s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Avg per Print"}),s.jsxs("p",{className:"text-2xl font-bold text-white",children:[p>0?(d/p).toFixed(0):0,"g"]}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[e,p>0?(f/p).toFixed(2):"0.00"," avg"]})]})]}),u.length>0?s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[s.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"Usage Over Time"}),s.jsx(v1,{width:"100%",height:250,children:s.jsxs(zCe,{data:u,children:[s.jsx("defs",{children:s.jsxs("linearGradient",{id:"colorFilament",x1:"0",y1:"0",x2:"0",y2:"1",children:[s.jsx("stop",{offset:"5%",stopColor:"#00ae42",stopOpacity:.3}),s.jsx("stop",{offset:"95%",stopColor:"#00ae42",stopOpacity:0})]})}),s.jsx(BS,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),s.jsx($S,{dataKey:"dateLabel",stroke:"#9ca3af",tick:{fontSize:12},interval:"preserveStartEnd"}),s.jsx(VS,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:m=>`${m}g`}),s.jsx(_1,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},labelStyle:{color:"#fff"},formatter:m=>[`${Number(m??0).toFixed(0)}g`,"Filament"]}),s.jsx(PZ,{type:"monotone",dataKey:"filament",stroke:"#00ae42",strokeWidth:2,fillOpacity:1,fill:"url(#colorFilament)"})]})})]}):s.jsx("div",{className:"bg-bambu-dark rounded-lg p-8 text-center text-bambu-gray",children:"No data for selected time range"}),s.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[s.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"By Filament Type"}),l.length>0?s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx(v1,{width:160,height:160,children:s.jsxs(ICe,{children:[s.jsx(nZ,{data:l,cx:"50%",cy:"50%",innerRadius:40,outerRadius:70,paddingAngle:2,dataKey:"value",children:l.map((m,x)=>s.jsx(cv,{fill:d1[x%d1.length]},`cell-${x}`))}),s.jsx(_1,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},formatter:m=>[`${m??0}g`,"Usage"]})]})}),s.jsx("div",{className:"flex-1 space-y-2 overflow-hidden",children:l.map((m,x)=>{const b=l.reduce((v,S)=>v+S.value,0),y=b>0?(m.value/b*100).toFixed(0):0;return s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx("div",{className:"w-3 h-3 rounded-sm flex-shrink-0",style:{backgroundColor:d1[x%d1.length]}}),s.jsx("span",{className:"text-white truncate flex-1",children:m.name}),s.jsxs("span",{className:"text-bambu-gray flex-shrink-0",children:[y,"%"]})]},m.name)})})]}):s.jsx("div",{className:"h-[160px] flex items-center justify-center text-bambu-gray",children:"No filament data"})]}),s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[s.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"Monthly Comparison"}),s.jsx(v1,{width:"100%",height:200,children:s.jsxs(kCe,{data:c,children:[s.jsx(BS,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),s.jsx($S,{dataKey:"month",stroke:"#9ca3af",tick:{fontSize:12}}),s.jsx(VS,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:m=>`${m}g`}),s.jsx(_1,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},formatter:(m,x)=>[x==="filament"?`${m??0}g`:x==="cost"?`${e}${Number(m??0).toFixed(2)}`:m??0,x==="filament"?"Filament":x==="cost"?"Cost":"Prints"]}),s.jsx(dO,{}),s.jsx(lZ,{dataKey:"filament",name:"Filament (g)",fill:"#00ae42",radius:[4,4,0,0]})]})})]})]})]})}function qWe({id:t,title:e,component:n,isHidden:r,size:i,onToggleVisibility:a,onToggleSize:o}){const{attributes:l,listeners:c,setNodeRef:u,transform:d,transition:f,isDragging:p}=jre({id:t}),m={transform:mx.Transform.toString(d),transition:f,opacity:p?.5:1};return r?null:s.jsxs("div",{ref:u,style:{...m,gridColumn:`span ${i}`},className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary overflow-hidden ${p?"ring-2 ring-bambu-green shadow-lg":""}`,children:[s.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-bambu-dark-tertiary bg-bambu-dark/30",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{...l,...c,className:"cursor-grab active:cursor-grabbing p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:"Drag to reorder",children:s.jsx(zg,{className:"w-6 h-6 md:w-4 md:h-4 text-bambu-gray"})}),s.jsx("h3",{className:"text-sm font-medium text-white",children:e})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("button",{onClick:o,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:`Size: ${i===1?"1/4":i===2?"1/2":"Full"} - Click to cycle`,children:i===4?s.jsx(wW,{className:"w-4 h-4 text-bambu-gray hover:text-white"}):s.jsx(vW,{className:"w-4 h-4 text-bambu-gray hover:text-white"})}),s.jsx("button",{onClick:a,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:"Hide widget",children:s.jsx(lN,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]})]}),s.jsx("div",{className:"p-4",children:typeof n=="function"?n(i):n})]})}function WWe({widgets:t,storageKey:e,columns:n=4,hideControls:r=!1,onResetLayout:i,renderControls:a}){const o=()=>{const T={};return t.forEach(k=>{T[k.id]=k.defaultSize||4}),T},[l,c]=_.useState(()=>{const T=localStorage.getItem(e);if(T)try{const k=JSON.parse(T);return k.sizes||(k.sizes=o()),k}catch{}return{order:t.map(k=>k.id),hidden:t.filter(k=>k.defaultVisible===!1).map(k=>k.id),sizes:o()}}),[u,d]=_.useState(!1);_.useEffect(()=>{const T=()=>d(k=>!k);return window.addEventListener("toggle-hidden-panel",T),()=>window.removeEventListener("toggle-hidden-panel",T)},[]),_.useEffect(()=>{localStorage.setItem(e,JSON.stringify(l))},[l,e]),_.useEffect(()=>{const k=t.map(C=>C.id).filter(C=>!l.order.includes(C));k.length>0&&c(C=>({...C,order:[...C.order,...k]}))},[t,l.order]);const f=cre(ZM(B2,{activationConstraint:{distance:8}}),ZM(z2,{coordinateGetter:Pre})),p=T=>{const{active:k,over:C}=T;C&&k.id!==C.id&&c(E=>{const D=E.order.indexOf(k.id),A=E.order.indexOf(C.id);return{...E,order:V2(E.order,D,A)}})},m=T=>{c(k=>({...k,hidden:k.hidden.includes(T)?k.hidden.filter(C=>C!==T):[...k.hidden,T]}))},x=T=>{c(k=>{const C=k.sizes[T]||4,E=C===1?2:C===2?4:1;return{...k,sizes:{...k.sizes,[T]:E}}})},b=()=>{const T={order:t.map(k=>k.id),hidden:t.filter(k=>k.defaultVisible===!1).map(k=>k.id),sizes:o()};c(T),i?.()},y=l.order.map(T=>t.find(k=>k.id===T)).filter(Boolean),v=y.filter(T=>!l.hidden.includes(T.id)),S=y.filter(T=>l.hidden.includes(T.id)),N=a?.({hiddenCount:S.length,showHiddenPanel:u,setShowHiddenPanel:d,resetLayout:b});return s.jsxs("div",{className:"space-y-4",children:[N,!r&&!a&&s.jsxs("div",{className:"flex items-center justify-end gap-2",children:[s.jsxs(Te,{variant:"secondary",size:"sm",onClick:b,children:[s.jsx(Rh,{className:"w-4 h-4"}),"Reset Layout"]}),S.length>0&&s.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>d(!u),children:[s.jsx(Ru,{className:"w-4 h-4"}),S.length," Hidden"]})]}),u&&S.length>0&&s.jsxs("div",{className:"p-4 bg-bambu-dark rounded-xl border border-bambu-dark-tertiary",children:[s.jsx("p",{className:"text-sm text-bambu-gray mb-3",children:"Hidden widgets (click to show):"}),s.jsx("div",{className:"flex flex-wrap gap-2",children:S.map(T=>s.jsxs("button",{onClick:()=>m(T.id),className:"px-3 py-1.5 bg-bambu-dark-tertiary hover:bg-bambu-green/20 rounded-lg text-sm text-white transition-colors flex items-center gap-2",children:[s.jsx(Ru,{className:"w-3 h-3"}),T.title]},T.id))})]}),s.jsx(kre,{sensors:f,collisionDetection:fre,onDragEnd:p,children:s.jsx(Are,{items:v.map(T=>T.id),strategy:lF,children:s.jsx("div",{className:"grid gap-6",style:{gridTemplateColumns:`repeat(${n}, minmax(0, 1fr))`},children:v.map(T=>s.jsx(qWe,{id:T.id,title:T.title,component:T.component,isHidden:l.hidden.includes(T.id),size:l.sizes[T.id]||2,onToggleVisibility:()=>m(T.id),onToggleSize:()=>x(T.id)},T.id))})})}),v.length===0&&s.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[s.jsx("p",{children:"All widgets are hidden."}),s.jsx(Te,{className:"mt-4",onClick:b,children:"Reset Layout"})]})]})}function KWe({stats:t,currency:e,t:n}){return s.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-4",children:[s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-bambu-green",children:s.jsx(mc,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray",children:n("stats.totalPrints")}),s.jsx("p",{className:"text-xl font-bold text-white",children:t?.total_prints||0})]})]}),s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-blue-400",children:s.jsx(er,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray",children:n("stats.printTime")}),s.jsxs("p",{className:"text-xl font-bold text-white",children:[t?.total_print_time_hours.toFixed(1)||0,"h"]})]})]}),s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-orange-400",children:s.jsx(mc,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray",children:n("stats.filamentUsed")}),s.jsxs("p",{className:"text-xl font-bold text-white",children:[((t?.total_filament_grams||0)/1e3).toFixed(2),"kg"]})]})]}),s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-green-400",children:s.jsx(hP,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray",children:n("stats.filamentCost")}),s.jsxs("p",{className:"text-xl font-bold text-white",children:[e," ",t?.total_cost.toFixed(2)||"0.00"]})]})]}),s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-yellow-400",children:s.jsx(vh,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray",children:n("stats.energyUsed")}),s.jsxs("p",{className:"text-xl font-bold text-white",children:[t?.total_energy_kwh.toFixed(2)||"0.00"," kWh"]})]})]}),s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-yellow-500",children:s.jsx(hP,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray",children:n("stats.energyCost")}),s.jsxs("p",{className:"text-xl font-bold text-white",children:[e," ",t?.total_energy_cost.toFixed(2)||"0.00"]})]})]})]})}function XWe({stats:t,printerMap:e,size:n=1,t:r}){const i=t?.total_prints?Math.round(t.successful_prints/t.total_prints*100):0,a=n===1?112:n===2?128:144,o=a/2-8,l=o*2*Math.PI;return s.jsxs("div",{className:"flex items-center gap-6",children:[s.jsxs("div",{className:"relative flex-shrink-0",style:{width:a,height:a},children:[s.jsxs("svg",{className:"w-full h-full -rotate-90",children:[s.jsx("circle",{cx:a/2,cy:a/2,r:o,fill:"none",stroke:"#3d3d3d",strokeWidth:"10"}),s.jsx("circle",{cx:a/2,cy:a/2,r:o,fill:"none",stroke:"#00ae42",strokeWidth:"10",strokeLinecap:"round",strokeDasharray:`${i/100*l} ${l}`})]}),s.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:s.jsxs("span",{className:`font-bold text-white ${n>=2?"text-2xl":"text-xl"}`,children:[i,"%"]})})]}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ar,{className:"w-4 h-4 text-status-ok flex-shrink-0"}),s.jsx("span",{className:"text-sm text-bambu-gray",children:r("stats.successful")}),s.jsx("span",{className:"text-sm text-white font-medium",children:t?.successful_prints||0})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Yi,{className:"w-4 h-4 text-status-error flex-shrink-0"}),s.jsx("span",{className:"text-sm text-bambu-gray",children:r("stats.failed")}),s.jsx("span",{className:"text-sm text-white font-medium",children:t?.failed_prints||0})]})]}),n>=2&&t?.prints_by_printer&&Object.keys(t.prints_by_printer).length>0&&s.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[s.jsx("p",{className:"text-xs text-bambu-gray font-medium mb-2",children:r("stats.printsByPrinter")}),s.jsx("div",{className:`grid gap-x-6 gap-y-1 ${n===4?"grid-cols-3":"grid-cols-2"}`,style:{width:"fit-content"},children:Object.entries(t.prints_by_printer).map(([c,u])=>s.jsxs("div",{className:"flex items-center gap-3 text-sm",children:[s.jsx("span",{className:"text-bambu-gray truncate max-w-[120px]",children:e.get(c)||`${r("common.printer")} ${c}`}),s.jsx("span",{className:"text-white font-medium",children:u})]},c))})]})]})]})}function YWe({stats:t,printerMap:e,size:n=1,t:r}){const i=t?.average_time_accuracy;if(i==null)return s.jsx("div",{className:"flex items-center justify-center h-full",children:s.jsx("p",{className:"text-bambu-gray text-center py-4",children:r("stats.noTimeAccuracyData")})});const o=(Math.min(150,Math.max(50,i))-50)/100*100,c=(b=>b>=95&&b<=105?"#00ae42":b>105?"#3b82f6":"#f97316")(i),u=i-100,d=n===1?112:n===2?128:144,f=d/2-8,p=f*2*Math.PI,m=n===1?3:n===2?6:999,x=t?.time_accuracy_by_printer?Object.entries(t.time_accuracy_by_printer).slice(0,m):[];return s.jsxs("div",{className:"flex items-center gap-6",children:[s.jsxs("div",{className:"relative flex-shrink-0",style:{width:d,height:d},children:[s.jsxs("svg",{className:"w-full h-full -rotate-90",children:[s.jsx("circle",{cx:d/2,cy:d/2,r:f,fill:"none",stroke:"#3d3d3d",strokeWidth:"10"}),s.jsx("circle",{cx:d/2,cy:d/2,r:f,fill:"none",stroke:c,strokeWidth:"10",strokeLinecap:"round",strokeDasharray:`${o/100*p} ${p}`})]}),s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[s.jsxs("span",{className:`font-bold text-white ${n>=2?"text-2xl":"text-xl"}`,children:[i.toFixed(0),"%"]}),s.jsxs("span",{className:`text-xs ${u>=0?"text-blue-400":"text-orange-400"}`,children:[u>=0?"+":"",u.toFixed(0),"%"]})]})]}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 text-xs text-bambu-gray",children:[s.jsx(EW,{className:"w-3 h-3 flex-shrink-0"}),s.jsx("span",{children:r("stats.perfectEstimate")})]}),x.length>0&&s.jsx("div",{className:`mt-2 ${n===4?"grid grid-cols-3 gap-x-6 gap-y-1":n===2?"grid grid-cols-2 gap-x-6 gap-y-1":"space-y-1"}`,style:{width:"fit-content"},children:x.map(([b,y])=>s.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[s.jsx("span",{className:"text-bambu-gray truncate max-w-[100px]",children:e.get(b)||`${r("common.printer")} ${b}`}),s.jsxs("span",{className:`font-medium ${y>=95&&y<=105?"text-status-ok":y>105?"text-blue-400":"text-status-warning"}`,children:[y.toFixed(0),"%"]})]},b))})]})]})}function QWe({stats:t,size:e=1,t:n}){if(!t?.prints_by_filament_type||Object.keys(t.prints_by_filament_type).length===0)return s.jsx("p",{className:"text-bambu-gray text-center py-4",children:n("stats.noFilamentData")});const r=Object.entries(t.prints_by_filament_type).sort(([,l],[,c])=>c-l),i=e===1?5:e===2?8:999,a=r.slice(0,i),o=r.length>i;return e===4&&a.length>4?s.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-3 gap-4",children:a.map(([l,c])=>{const u=Math.round(c/(t.total_prints||1)*100);return s.jsxs("div",{children:[s.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[s.jsx("span",{className:"text-white truncate max-w-[120px]",children:l}),s.jsx("span",{className:"text-bambu-gray",children:c})]}),s.jsx("div",{className:"h-2 bg-bambu-dark rounded-full",children:s.jsx("div",{className:"h-full bg-bambu-green rounded-full transition-all",style:{width:`${u}%`}})})]},l)})}):s.jsxs("div",{className:"space-y-3",children:[a.map(([l,c])=>{const u=Math.round(c/(t.total_prints||1)*100);return s.jsxs("div",{children:[s.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[s.jsx("span",{className:"text-white",children:l}),s.jsxs("span",{className:"text-bambu-gray",children:[c," ",n("common.prints")]})]}),s.jsx("div",{className:"h-2 bg-bambu-dark rounded-full",children:s.jsx("div",{className:"h-full bg-bambu-green rounded-full transition-all",style:{width:`${u}%`}})})]},l)}),o&&s.jsx("p",{className:"text-xs text-bambu-gray text-center pt-1",children:n("common.more",{count:r.length-i})})]})}function ZWe({printDates:t,size:e=2}){const n=e===1?3:e===2?6:12;return s.jsx($We,{printDates:t,months:n})}function JWe({stats:t,printerMap:e,t:n}){return!t?.prints_by_printer||Object.keys(t.prints_by_printer).length===0?s.jsx("p",{className:"text-bambu-gray text-center py-4",children:n("stats.noPrinterData")}):s.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:Object.entries(t.prints_by_printer).map(([r,i])=>s.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[s.jsx("div",{className:"p-2 bg-bambu-dark-tertiary rounded-lg",children:s.jsx(Ur,{className:"w-4 h-4 text-bambu-green"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-white font-medium text-sm",children:e.get(r)||`${n("common.printer")} ${r}`}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[i," ",n("common.prints")]})]})]},r))})}function eKe({archives:t,currency:e,t:n}){return!t||t.length===0?s.jsx("p",{className:"text-bambu-gray text-center py-4",children:n("stats.noPrintData")}):s.jsx(GWe,{archives:t,currency:e})}function tKe({size:t=1,t:e}){const{data:n,isLoading:r}=at({queryKey:["failureAnalysis"],queryFn:()=>ue.getFailureAnalysis({days:30})});if(r)return s.jsx("div",{className:"flex justify-center py-4",children:s.jsx(ht,{className:"w-6 h-6 text-bambu-green animate-spin"})});if(!n||n.total_prints===0)return s.jsx("p",{className:"text-bambu-gray text-center py-4",children:e("stats.noPrintDataLast30Days")});const i=t===1?5:t===2?8:999,a=Object.entries(n.failures_by_reason).sort(([,c],[,u])=>u-c),o=a.slice(0,i),l=a.length>i;return s.jsxs("div",{className:`${t>=2?"flex gap-8":"space-y-4"}`,children:[s.jsxs("div",{className:t>=2?"flex-shrink-0":"",children:[s.jsx("div",{className:"flex items-center gap-4",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Cn,{className:`w-5 h-5 ${n.failure_rate>20?"text-status-error":n.failure_rate>10?"text-status-warning":"text-status-ok"}`}),s.jsxs("span",{className:`font-bold text-white ${t>=2?"text-3xl":"text-2xl"}`,children:[n.failure_rate.toFixed(1),"%"]})]})}),s.jsx("div",{className:"text-sm text-bambu-gray mt-1",children:e("stats.failedPrintsCount",{failed:n.failed_prints,total:n.total_prints})}),n.trend&&n.trend.length>=2&&s.jsx("div",{className:`${t>=2?"mt-4":"mt-2 pt-2 border-t border-bambu-dark-tertiary"}`,children:s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx(AW,{className:`w-4 h-4 ${n.trend[n.trend.length-1].failure_rate<n.trend[n.trend.length-2].failure_rate?"text-status-ok":"text-status-error"}`}),s.jsx("span",{className:"text-bambu-gray",children:e("stats.lastWeekRate",{rate:n.trend[n.trend.length-1].failure_rate.toFixed(1)})})]})})]}),o.length>0&&s.jsxs("div",{className:`flex-1 ${t>=2?"border-l border-bambu-dark-tertiary pl-8":"pt-2"}`,children:[s.jsx("p",{className:"text-xs text-bambu-gray font-medium mb-2",children:t>=2?e("stats.failureReasons"):e("stats.topFailureReasons")}),s.jsx("div",{className:`${t===4?"grid grid-cols-2 gap-x-6 gap-y-1":"space-y-1"}`,children:o.map(([c,u])=>s.jsxs("div",{className:"flex items-center justify-between text-sm",children:[s.jsx("span",{className:`text-white truncate ${t===4?"max-w-[200px]":"max-w-[160px]"}`,children:c||e("common.unknown")}),s.jsx("span",{className:"text-bambu-gray ml-2",children:u})]},c))}),l&&s.jsx("p",{className:"text-xs text-bambu-gray mt-2",children:e("common.more",{count:a.length-i})})]})]})}function nKe(){const{t}=Hn(),{showToast:e}=$n(),{hasPermission:n}=Ai(),[r,i]=_.useState(!1),[a,o]=_.useState(!1),[l,c]=_.useState(0),[u,d]=_.useState(0),[f,p]=_.useState(!1);_.useEffect(()=>{const A=()=>{try{const U=localStorage.getItem("bambusy-dashboard-layout");if(U){const F=JSON.parse(U);d(F.hidden?.length||0)}}catch{d(0)}};A(),window.addEventListener("storage",A);const R=setInterval(A,500);return()=>{window.removeEventListener("storage",A),clearInterval(R)}},[l]);const{data:m,isLoading:x,refetch:b}=at({queryKey:["archiveStats"],queryFn:ue.getArchiveStats}),{data:y}=at({queryKey:["printers"],queryFn:ue.getPrinters}),{data:v}=at({queryKey:["archives"],queryFn:()=>ue.getArchives(void 0,void 0,1e3,0)}),{data:S}=at({queryKey:["settings"],queryFn:ue.getSettings}),N=async A=>{o(!1),i(!0);try{const{blob:R,filename:U}=await ue.exportStats({format:A,days:90}),F=URL.createObjectURL(R),$=document.createElement("a");$.href=F,$.download=U,$.click(),URL.revokeObjectURL(F),e(t("stats.exportDownloaded"))}catch{e(t("stats.exportFailed"),"error")}finally{i(!1)}},T=async()=>{p(!0);try{const A=await ue.recalculateCosts();await b(),e(t("stats.recalculatedCosts",{count:A.updated}))}catch{e(t("stats.recalculateFailed"),"error")}finally{p(!1)}},k=S?.currency||"$",C=new Map(y?.map(A=>[String(A.id),A.name])||[]),E=v?.map(A=>A.created_at)||[];if(x)return s.jsx("div",{className:"p-4 md:p-8",children:s.jsx("div",{className:"text-center py-12 text-bambu-gray",children:t("stats.loadingStats")})});const D=[{id:"quick-stats",title:t("stats.quickStats"),component:s.jsx(KWe,{stats:m,currency:k,t}),defaultSize:2},{id:"success-rate",title:t("stats.successRate"),component:A=>s.jsx(XWe,{stats:m,printerMap:C,size:A,t}),defaultSize:1},{id:"time-accuracy",title:t("stats.timeAccuracy"),component:A=>s.jsx(YWe,{stats:m,printerMap:C,size:A,t}),defaultSize:1},{id:"filament-types",title:t("stats.filamentTypes"),component:A=>s.jsx(QWe,{stats:m,size:A,t}),defaultSize:1},{id:"failure-analysis",title:t("stats.failureAnalysis"),component:A=>s.jsx(tKe,{size:A,t}),defaultSize:1},{id:"print-activity",title:t("stats.printActivity"),component:A=>s.jsx(ZWe,{printDates:E,size:A}),defaultSize:2},{id:"prints-by-printer",title:t("stats.printsByPrinter"),component:s.jsx(JWe,{stats:m,printerMap:C,t}),defaultSize:2},{id:"filament-trends",title:t("stats.filamentTrends"),component:s.jsx(eKe,{archives:v||[],currency:k,t}),defaultSize:4}];return s.jsxs("div",{className:"p-4 md:p-8",children:[s.jsxs("div",{className:"flex items-center justify-between mb-6",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold text-white",children:t("stats.title")}),s.jsx("p",{className:"text-bambu-gray",children:t("stats.subtitle")})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[u>0&&s.jsxs(Te,{variant:"secondary",onClick:()=>{window.dispatchEvent(new CustomEvent("toggle-hidden-panel"))},children:[s.jsx(Ru,{className:"w-4 h-4"}),t("stats.hiddenCount",{count:u})]}),s.jsxs(Te,{variant:"secondary",onClick:()=>{localStorage.removeItem("bambusy-dashboard-layout"),c(A=>A+1),e(t("stats.layoutReset"))},disabled:!n("settings:update"),title:n("settings:update")?void 0:t("stats.noPermissionResetLayout"),children:[s.jsx(Rh,{className:"w-4 h-4"}),t("stats.resetLayout")]}),s.jsxs(Te,{variant:"secondary",onClick:T,disabled:f||!n("archives:update_all"),title:n("archives:update_all")?t("stats.recalculateCostsHint"):t("stats.noPermissionRecalculate"),children:[f?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(Tce,{className:"w-4 h-4"}),t("stats.recalculateCosts")]}),s.jsxs("div",{className:"relative",children:[s.jsxs(Te,{variant:"secondary",onClick:()=>o(!a),disabled:r,children:[r?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(q1,{className:"w-4 h-4"}),t("stats.exportStats")]}),a&&s.jsxs("div",{className:"absolute right-0 top-full mt-1 w-48 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl z-20",children:[s.jsxs("button",{className:"w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-t-lg",onClick:()=>N("csv"),children:[s.jsx(Ls,{className:"w-4 h-4"}),t("stats.exportAsCsv")]}),s.jsxs("button",{className:"w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-b-lg",onClick:()=>N("xlsx"),children:[s.jsx(q1,{className:"w-4 h-4"}),t("stats.exportAsExcel")]})]})]})]})]}),s.jsx(WWe,{widgets:D,storageKey:"bambusy-dashboard-layout",hideControls:!0},l)]})}function rKe({plug:t,onEdit:e}){const n=an(),{showToast:r}=$n(),[i,a]=_.useState(!1),[o,l]=_.useState(!1),[c,u]=_.useState(!1),[d,f]=_.useState(!1),{data:p,isLoading:m}=at({queryKey:["smart-plug-status",t.id],queryFn:()=>ue.getSmartPlugStatus(t.id),refetchInterval:3e4}),{data:x}=at({queryKey:["printers"],queryFn:ue.getPrinters}),b=x?.find(A=>A.id===t.printer_id),y=mt({mutationFn:A=>ue.controlSmartPlug(t.id,A),onMutate:async A=>{await n.cancelQueries({queryKey:["smart-plug-status",t.id]});const R=n.getQueryData(["smart-plug-status",t.id]),U=A==="on"?"ON":A==="off"||p?.state==="ON"?"OFF":"ON";return n.setQueryData(["smart-plug-status",t.id],F=>({...F,state:U})),{previousStatus:R}},onError:(A,R,U)=>{U?.previousStatus&&n.setQueryData(["smart-plug-status",t.id],U.previousStatus),r(`Failed to turn ${R} "${t.name}"`,"error")},onSettled:()=>{setTimeout(()=>{n.invalidateQueries({queryKey:["smart-plug-status",t.id]}),n.invalidateQueries({queryKey:["smart-plugs"]})},1e3)}}),v=mt({mutationFn:A=>ue.updateSmartPlug(t.id,A),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),t.printer_id&&n.invalidateQueries({queryKey:["smartPlugByPrinter",t.printer_id]})}}),S=mt({mutationFn:()=>ue.deleteSmartPlug(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]})}}),N=p?.state==="ON",T=t.plug_type==="mqtt"&&p?.energy?.power!==null&&p?.energy?.power!==void 0,k=(p?.reachable??!1)||T,C=y.isPending,D=(()=>{if(t.plug_type!=="tasmota"||!t.ip_address)return null;const A=t.ip_address;return t.username&&t.password?`http://${encodeURIComponent(t.username)}:${encodeURIComponent(t.password)}@${A}/`:`http://${A}/`})();return s.jsxs(s.Fragment,{children:[s.jsx(_t,{className:"relative",children:s.jsxs(Mt,{className:"p-4",children:[s.jsxs("div",{className:"flex items-start justify-between gap-2 mb-3",children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[s.jsx("div",{className:`p-2 rounded-lg flex-shrink-0 ${t.plug_type==="mqtt"?k?"bg-teal-500/20":"bg-red-500/20":k?N?"bg-bambu-green/20":"bg-bambu-dark":"bg-red-500/20"}`,children:t.plug_type==="mqtt"?s.jsx(jR,{className:`w-5 h-5 ${k?"text-teal-400":"text-red-400"}`}):t.plug_type==="homeassistant"?s.jsx(fN,{className:`w-5 h-5 ${k?N?"text-bambu-green":"text-bambu-gray":"text-red-400"}`}):s.jsx(tl,{className:`w-5 h-5 ${k?N?"text-bambu-green":"text-bambu-gray":"text-red-400"}`})}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("h3",{className:"font-medium text-white truncate",children:t.name}),s.jsx("p",{className:"text-sm text-bambu-gray truncate",title:t.plug_type==="mqtt"?t.mqtt_topic??void 0:t.plug_type==="homeassistant"?t.ha_entity_id??void 0:t.ip_address??void 0,children:t.plug_type==="mqtt"?t.mqtt_topic:t.plug_type==="homeassistant"?t.ha_entity_id:t.ip_address})]})]}),s.jsxs("div",{className:"flex flex-col items-end gap-1 flex-shrink-0",children:[m?s.jsx(ht,{className:"w-4 h-4 text-bambu-gray animate-spin"}):t.plug_type==="mqtt"?s.jsxs("div",{className:"flex items-center gap-1.5 text-sm whitespace-nowrap",children:[s.jsx("span",{className:"px-1.5 py-0.5 bg-teal-500/20 text-teal-400 text-[10px] font-medium rounded flex-shrink-0",children:"MQTT"}),k&&s.jsx("span",{className:"text-status-ok",children:"✓"})]}):t.plug_type==="homeassistant"?s.jsxs("div",{className:"flex items-center gap-1 text-sm",children:[s.jsx("span",{className:"px-1 py-0.5 bg-blue-500/20 text-blue-400 text-[10px] font-medium rounded",children:"HA"}),s.jsx("span",{className:k?N?"text-status-ok":"text-bambu-gray":"text-status-error",children:k?p?.state||"?":"Offline"})]}):k?s.jsxs("div",{className:"flex items-center gap-1 text-sm",children:[s.jsx(Sg,{className:"w-4 h-4 text-status-ok"}),s.jsx("span",{className:N?"text-status-ok":"text-bambu-gray",children:p?.state||"Unknown"})]}):s.jsxs("div",{className:"flex items-center gap-1 text-sm text-status-error",children:[s.jsx(sm,{className:"w-4 h-4"}),s.jsx("span",{children:"Offline"})]}),D&&s.jsxs("a",{href:D,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 px-2 py-0.5 bg-bambu-dark hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white text-xs rounded-full transition-colors",title:"Open plug admin page",children:[s.jsx(Kr,{className:"w-3 h-3"}),"Admin"]})]})]}),b&&s.jsxs("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:[s.jsx("span",{className:"text-xs text-bambu-gray",children:"Linked to: "}),s.jsx("span",{className:"text-sm text-white",children:b.name})]}),(t.power_alert_enabled||t.schedule_enabled||t.plug_type==="mqtt")&&s.jsxs("div",{className:"flex flex-wrap gap-1.5 mb-3",children:[t.plug_type==="mqtt"&&s.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 bg-teal-500/20 text-teal-400 text-xs rounded-full",children:[s.jsx(Ru,{className:"w-3 h-3"}),"Monitor Only"]}),t.power_alert_enabled&&s.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 bg-yellow-500/20 text-yellow-400 text-xs rounded-full",children:[s.jsx(wg,{className:"w-3 h-3"}),"Alerts"]}),t.schedule_enabled&&s.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 bg-blue-500/20 text-blue-400 text-xs rounded-full",children:[s.jsx(si,{className:"w-3 h-3"}),t.schedule_on_time&&t.schedule_off_time?`${t.schedule_on_time} - ${t.schedule_off_time}`:t.schedule_on_time?`On ${t.schedule_on_time}`:`Off ${t.schedule_off_time}`]})]}),t.plug_type!=="mqtt"&&s.jsxs("div",{className:"flex gap-2 mb-3",children:[s.jsxs(Te,{size:"sm",variant:N?"primary":"secondary",disabled:!k||C,onClick:()=>l(!0),className:"flex-1",children:[C?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(Gu,{className:"w-4 h-4"}),"On"]}),s.jsxs(Te,{size:"sm",variant:N?"secondary":"primary",disabled:!k||C,onClick:()=>u(!0),className:"flex-1",children:[C?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(gN,{className:"w-4 h-4"}),"Off"]})]}),t.plug_type==="mqtt"&&p?.energy&&s.jsxs("div",{className:"flex gap-2 mb-3 px-3 py-2 bg-bambu-dark rounded-lg",children:[p.energy.power!==null&&p.energy.power!==void 0&&s.jsxs("div",{className:"flex-1 text-center",children:[s.jsxs("p",{className:"text-lg font-semibold text-white",children:[Math.round(p.energy.power),"W"]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Power"})]}),p.energy.today!==null&&p.energy.today!==void 0&&s.jsxs("div",{className:"flex-1 text-center border-l border-bambu-dark-tertiary",children:[s.jsx("p",{className:"text-lg font-semibold text-white",children:p.energy.today.toFixed(2)}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"kWh Today"})]})]}),s.jsxs("button",{onClick:()=>f(!d),className:"w-full flex items-center justify-between py-2 text-sm text-bambu-gray hover:text-white transition-colors",children:[s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx(bh,{className:"w-4 h-4"}),t.plug_type==="mqtt"?"Settings":"Automation Settings"]}),s.jsx("span",{children:d?"-":"+"})]}),d&&s.jsxs("div",{className:"pt-3 border-t border-bambu-dark-tertiary space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(mN,{className:"w-4 h-4 text-bambu-green"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Show in Switchbar"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Quick access from sidebar"})]})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:t.show_in_switchbar,onChange:A=>v.mutate({show_in_switchbar:A.target.checked}),className:"sr-only peer"}),s.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),t.plug_type!=="mqtt"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Enabled"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Enable automation for this plug"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:t.enabled,onChange:A=>v.mutate({enabled:A.target.checked}),className:"sr-only peer"}),s.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Auto On"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Turn on when print starts"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:t.auto_on,onChange:A=>v.mutate({auto_on:A.target.checked}),className:"sr-only peer"}),s.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Auto Off"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Turn off when print completes (one-shot)"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:t.auto_off,onChange:A=>v.mutate({auto_off:A.target.checked}),className:"sr-only peer"}),s.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),t.auto_off&&s.jsxs("div",{className:"space-y-3 pl-4 border-l-2 border-bambu-dark-tertiary",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white mb-2",children:"Turn Off Delay Mode"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("button",{onClick:()=>v.mutate({off_delay_mode:"time"}),className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors ${t.off_delay_mode==="time"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:[s.jsx(er,{className:"w-4 h-4"}),"Time"]}),s.jsxs("button",{onClick:()=>v.mutate({off_delay_mode:"temperature"}),className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors ${t.off_delay_mode==="temperature"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:[s.jsx(bN,{className:"w-4 h-4"}),"Temp"]})]})]}),t.off_delay_mode==="time"?s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Delay (minutes)"}),s.jsx("input",{type:"number",min:"1",max:"60",value:t.off_delay_minutes,onChange:A=>v.mutate({off_delay_minutes:parseInt(A.target.value)||5}),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none"})]}):s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Temperature threshold (C)"}),s.jsx("input",{type:"number",min:"30",max:"100",value:t.off_temp_threshold,onChange:A=>v.mutate({off_temp_threshold:parseInt(A.target.value)||70}),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Turns off when nozzle cools below this temperature"})]})]})]}),s.jsxs("div",{className:"flex gap-2 pt-2",children:[s.jsxs(Te,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[s.jsx(fg,{className:"w-4 h-4"}),"Edit"]}),s.jsx(Te,{size:"sm",variant:"secondary",onClick:()=>a(!0),className:"text-red-400 hover:text-red-300",children:s.jsx(rn,{className:"w-4 h-4"})})]})]})]})}),i&&s.jsx(Zn,{title:"Delete Smart Plug",message:`Are you sure you want to delete "${t.name}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{S.mutate(),a(!1)},onCancel:()=>a(!1)}),o&&s.jsx(Zn,{title:"Turn On Smart Plug",message:`Are you sure you want to turn on "${t.name}"?`,confirmText:"Turn On",variant:"default",onConfirm:()=>{y.mutate("on"),l(!1)},onCancel:()=>l(!1)}),c&&s.jsx(Zn,{title:"Turn Off Smart Plug",message:`Are you sure you want to turn off "${t.name}"? This will cut power to the connected device.`,confirmText:"Turn Off",variant:"danger",onConfirm:()=>{y.mutate("off"),u(!1)},onCancel:()=>u(!1)})]})}function iKe({plug:t,onClose:e}){const n=an(),r=!!t,[i,a]=_.useState(t?.plug_type||"tasmota"),[o,l]=_.useState(t?.name||""),[c,u]=_.useState(t?.ip_address||""),[d,f]=_.useState(t?.username||""),[p,m]=_.useState(t?.password||""),[x,b]=_.useState(t?.ha_entity_id||""),[y,v]=_.useState(t?.mqtt_power_topic||t?.mqtt_topic||""),[S,N]=_.useState(t?.mqtt_power_path||""),[T,k]=_.useState((t?.mqtt_power_multiplier??t?.mqtt_multiplier??1).toString()),[C,E]=_.useState(t?.mqtt_energy_topic||""),[D,A]=_.useState(t?.mqtt_energy_path||""),[R,U]=_.useState((t?.mqtt_energy_multiplier??1).toString()),[F,$]=_.useState(t?.mqtt_state_topic||""),[j,H]=_.useState(t?.mqtt_state_path||""),[K,V]=_.useState(t?.mqtt_state_on_value||""),[Q,Z]=_.useState(t?.ha_power_entity||""),[ae,B]=_.useState(t?.ha_energy_today_entity||""),[X,ne]=_.useState(t?.ha_energy_total_entity||""),[se,be]=_.useState(""),[xe,de]=_.useState(""),[Pe,ie]=_.useState(!1),Ne=_.useRef(null),[Oe,ge]=_.useState(""),[Ke,G]=_.useState(!1),Y=_.useRef(null),[ce,q]=_.useState(""),[te,I]=_.useState(!1),fe=_.useRef(null),[me,Ee]=_.useState(""),[z,O]=_.useState(!1),ee=_.useRef(null),[le,_e]=_.useState(t?.printer_id||null),[we,re]=_.useState(null),[Fe,He]=_.useState(null),[Ve,$e]=_.useState(t?.power_alert_enabled||!1),[ye,je]=_.useState(t?.power_alert_high?.toString()||""),[Be,Se]=_.useState(t?.power_alert_low?.toString()||""),[Xe,Me]=_.useState(t?.schedule_enabled||!1),[tt,ke]=_.useState(t?.schedule_on_time||""),[We,ze]=_.useState(t?.schedule_off_time||""),[W,De]=_.useState(t?.show_in_switchbar||!1),[Ye,xt]=_.useState(!1),[ft,Bt]=_.useState({scanned:0,total:0}),[Lt,vn]=_.useState([]),Jt=_.useRef(null),{data:ir}=at({queryKey:["printers"],queryFn:ue.getPrinters}),{data:fr}=at({queryKey:["smart-plugs"],queryFn:ue.getSmartPlugs}),{data:Dn}=at({queryKey:["settings"],queryFn:ue.getSettings}),ln=!!(Dn?.ha_enabled&&Dn?.ha_url&&Dn?.ha_token);_.useEffect(()=>{const pe=setTimeout(()=>{de(se)},300);return()=>clearTimeout(pe)},[se]),_.useEffect(()=>{const pe=Ie=>{Ne.current&&!Ne.current.contains(Ie.target)&&ie(!1),Y.current&&!Y.current.contains(Ie.target)&&G(!1),fe.current&&!fe.current.contains(Ie.target)&&I(!1),ee.current&&!ee.current.contains(Ie.target)&&O(!1)};return document.addEventListener("mousedown",pe),()=>document.removeEventListener("mousedown",pe)},[]);const{data:mr,isLoading:Fn,error:Xn}=at({queryKey:["ha-entities",xe],queryFn:()=>ue.getHAEntities(xe||void 0),enabled:i==="homeassistant"&&ln,retry:!1,staleTime:0}),{data:bn}=at({queryKey:["ha-sensor-entities"],queryFn:ue.getHASensorEntities,enabled:i==="homeassistant"&&ln,retry:!1,staleTime:0});_.useEffect(()=>{const pe=Ie=>{Ie.key==="Escape"&&e()};return window.addEventListener("keydown",pe),()=>{window.removeEventListener("keydown",pe),Jt.current&&clearInterval(Jt.current)}},[e]);const wi=async()=>{xt(!0),vn([]),Bt({scanned:0,total:0}),He(null);try{await ue.startTasmotaScan();const pe=async()=>{try{const Ie=await ue.getTasmotaScanStatus();Bt({scanned:Ie.scanned,total:Ie.total});const Le=await ue.getDiscoveredTasmotaDevices();vn(Le),Ie.running||(xt(!1),Jt.current&&(clearInterval(Jt.current),Jt.current=null))}catch(Ie){console.error("Polling error:",Ie)}};await pe(),Jt.current=setInterval(pe,500)}catch(pe){xt(!1);const Ie=pe instanceof Error?pe.message:typeof pe=="string"?pe:JSON.stringify(pe);He(Ie||"Failed to start scan")}},Ba=async()=>{try{await ue.stopTasmotaScan()}catch{}xt(!1),Jt.current&&(clearInterval(Jt.current),Jt.current=null)},Ae=pe=>{u(pe.ip_address),l(pe.name),re(null)},Ze=mt({mutationFn:()=>ue.testSmartPlugConnection(c,d||null,p||null),onSuccess:pe=>{re(pe),He(null),!o&&pe.device_name&&l(pe.device_name)},onError:pe=>{re(null),He(pe.message)}}),st=mt({mutationFn:pe=>ue.createSmartPlug(pe),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),e()},onError:pe=>{He(pe.message)}}),lt=mt({mutationFn:pe=>ue.updateSmartPlug(t.id,pe),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),e()},onError:pe=>{He(pe.message)}}),ot=ir?.filter(pe=>!fr?.some(Le=>Le.printer_id===pe.id&&Le.id!==t?.id)),Et=pe=>{if(pe.preventDefault(),He(null),!o.trim()){He("Name is required");return}if(i==="tasmota"&&!c.trim()){He("IP address is required for Tasmota plugs");return}if(i==="homeassistant"&&!x){He("Entity is required for Home Assistant plugs");return}if(i==="mqtt"){const Le=y.trim(),Ce=C.trim(),ut=F.trim();if(!Le&&!Ce&&!ut){He("At least one MQTT topic must be configured for power, energy, or state monitoring");return}}const Ie={name:o.trim(),plug_type:i,ip_address:i==="tasmota"?c.trim():null,ha_entity_id:i==="homeassistant"?x:null,ha_power_entity:i==="homeassistant"&&Q||null,ha_energy_today_entity:i==="homeassistant"&&ae||null,ha_energy_total_entity:i==="homeassistant"&&X||null,mqtt_power_topic:i==="mqtt"&&y.trim()||null,mqtt_power_path:i==="mqtt"&&S.trim()||null,mqtt_power_multiplier:i==="mqtt"&&parseFloat(T)||1,mqtt_energy_topic:i==="mqtt"&&C.trim()||null,mqtt_energy_path:i==="mqtt"&&D.trim()||null,mqtt_energy_multiplier:i==="mqtt"&&parseFloat(R)||1,mqtt_state_topic:i==="mqtt"&&F.trim()||null,mqtt_state_path:i==="mqtt"&&j.trim()||null,mqtt_state_on_value:i==="mqtt"&&K.trim()||null,username:i==="tasmota"&&d.trim()||null,password:i==="tasmota"&&p.trim()||null,printer_id:le,power_alert_enabled:Ve,power_alert_high:ye?parseFloat(ye):null,power_alert_low:Be?parseFloat(Be):null,schedule_enabled:Xe,schedule_on_time:tt||null,schedule_off_time:We||null,show_in_switchbar:W};r?lt.mutate(Ie):st.mutate(Ie)},he=st.isPending||lt.isPending;return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-md max-h-[90vh] flex flex-col",onClick:pe=>pe.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary flex-shrink-0",children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:r?"Edit Smart Plug":"Add Smart Plug"}),s.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(Rt,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:Et,className:"p-6 space-y-4 overflow-y-auto",children:[Fe&&s.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:Fe}),!r&&s.jsxs("div",{className:"flex gap-2 mb-2",children:[s.jsxs("button",{type:"button",onClick:()=>{a("tasmota"),re(null),He(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2.5 rounded-lg font-medium transition-colors ${i==="tasmota"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white border border-bambu-dark-tertiary"}`,children:[s.jsx(tl,{className:"w-4 h-4"}),"Tasmota"]}),s.jsxs("button",{type:"button",onClick:()=>{a("homeassistant"),re(null),He(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2.5 rounded-lg font-medium transition-colors ${i==="homeassistant"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white border border-bambu-dark-tertiary"}`,children:[s.jsx(fN,{className:"w-4 h-4"}),"HA"]}),s.jsxs("button",{type:"button",onClick:()=>{a("mqtt"),re(null),He(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2.5 rounded-lg font-medium transition-colors ${i==="mqtt"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white border border-bambu-dark-tertiary"}`,children:[s.jsx(jR,{className:"w-4 h-4"}),"MQTT"]})]}),!r&&i==="tasmota"&&s.jsxs("div",{className:"space-y-3",children:[Ye?s.jsxs(Te,{type:"button",variant:"secondary",onClick:Ba,className:"w-full",children:[s.jsx(Rt,{className:"w-4 h-4"}),"Stop Scanning"]}):s.jsxs(Te,{type:"button",variant:"primary",onClick:wi,className:"w-full",children:[s.jsx(ba,{className:"w-4 h-4"}),"Discover Tasmota Devices"]}),Ye&&ft.total>0&&s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"flex justify-between text-xs text-bambu-gray",children:[s.jsx("span",{children:"Scanning network..."}),s.jsxs("span",{children:[ft.scanned," / ",ft.total]})]}),s.jsx("div",{className:"w-full bg-bambu-dark-tertiary rounded-full h-2",children:s.jsx("div",{className:"bg-bambu-green h-2 rounded-full transition-all duration-300",style:{width:`${ft.scanned/ft.total*100}%`}})})]}),Lt.length>0&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("p",{className:"text-xs text-bambu-gray",children:["Found ",Lt.length," device(s) - click to select:"]}),s.jsx("div",{className:"max-h-40 overflow-y-auto space-y-1",children:Lt.map(pe=>s.jsxs("button",{type:"button",onClick:()=>Ae(pe),className:"w-full flex items-center justify-between p-2 bg-bambu-dark hover:bg-bambu-dark-tertiary rounded-lg transition-colors text-left border border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(tl,{className:"w-4 h-4 text-bambu-green"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:pe.name}),s.jsx("p",{className:"text-xs text-bambu-gray",children:pe.ip_address})]})]}),pe.state&&s.jsxs("span",{className:`flex items-center gap-1 text-xs ${pe.state==="ON"?"text-bambu-green":"text-bambu-gray"}`,children:[s.jsx(Gu,{className:"w-3 h-3"}),pe.state]})]},pe.ip_address))})]}),!Ye&&Lt.length===0&&ft.total>0&&s.jsx("p",{className:"text-xs text-bambu-gray text-center py-2",children:"No Tasmota devices found on your network"})]}),i==="homeassistant"&&s.jsxs("div",{className:"space-y-3",children:[!ln&&s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"p-3 bg-yellow-500/20 border border-yellow-500/50 rounded-lg text-sm text-yellow-400",children:["Home Assistant is not configured. Set it up in"," ",s.jsx("span",{className:"font-medium",children:"Settings → Network → Home Assistant"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1 opacity-50",children:"Select Entity *"}),s.jsx("select",{disabled:!0,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray cursor-not-allowed opacity-50",children:s.jsx("option",{children:"Choose an entity..."})})]})]}),ln&&s.jsxs(s.Fragment,{children:[Fn&&s.jsxs("div",{className:"flex items-center justify-center py-4 text-bambu-gray",children:[s.jsx(ht,{className:"w-5 h-5 animate-spin mr-2"}),"Loading entities..."]}),Xn&&s.jsxs("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:["Failed to load entities: ",Xn.message]}),(()=>{const pe=fr?.filter(Ce=>Ce.ha_entity_id&&Ce.id!==t?.id).map(Ce=>Ce.ha_entity_id)||[],Ie=(mr||[]).filter(Ce=>!pe.includes(Ce.entity_id)),Le=mr?.find(Ce=>Ce.entity_id===x);return s.jsxs("div",{ref:Ne,className:"relative",children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Select Entity *"}),s.jsxs("div",{className:"relative",children:[s.jsx(ba,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"}),s.jsx("input",{type:"text",value:Pe?se:Le?`${Le.friendly_name} (${Le.entity_id})`:"",onChange:Ce=>{be(Ce.target.value),Pe||ie(!0)},onFocus:()=>{ie(!0),be("")},placeholder:"Search entities...",className:"w-full pl-9 pr-8 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"}),x&&!Pe&&s.jsx("button",{type:"button",onClick:()=>{b(""),be("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:s.jsx(Rt,{className:"w-4 h-4 text-bambu-gray hover:text-white"})}),Fn&&s.jsx(ht,{className:"absolute right-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray animate-spin"})]}),Pe&&s.jsxs("div",{className:"absolute z-50 w-full mt-1 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-60 overflow-y-auto",children:[Fn&&s.jsxs("div",{className:"px-3 py-2 text-sm text-bambu-gray flex items-center gap-2",children:[s.jsx(ht,{className:"w-4 h-4 animate-spin"}),"Loading..."]}),!Fn&&Ie.length===0&&s.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:xe?`No entities found matching "${xe}"`:"No entities available"}),!Fn&&Ie.map(Ce=>s.jsxs("button",{type:"button",onClick:()=>{b(Ce.entity_id),ie(!1),be(""),o||l(Ce.friendly_name)},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary transition-colors ${Ce.entity_id===x?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[s.jsx("div",{className:"font-medium",children:Ce.friendly_name}),s.jsxs("div",{className:"text-xs text-bambu-gray flex items-center justify-between",children:[s.jsx("span",{children:Ce.entity_id}),s.jsx("span",{className:Ce.state==="on"?"text-bambu-green":"",children:Ce.state})]})]},Ce.entity_id))]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:xe?`Searching all entities (${Ie.length} found)`:`Showing switch, light, input_boolean (${Ie.length} available)`})]})})(),x&&bn&&bn.length>0&&s.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4 mt-4 space-y-3",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white font-medium mb-1",children:"Energy Monitoring (Optional)"}),s.jsx("p",{className:"text-xs text-bambu-gray mb-3",children:"Search and select sensors that provide power/energy data."})]}),(()=>{const pe=bn.filter(Ce=>Ce.unit_of_measurement==="W"||Ce.unit_of_measurement==="kW"||Ce.unit_of_measurement==="mW"),Ie=Oe?pe.filter(Ce=>Ce.entity_id.toLowerCase().includes(Oe.toLowerCase())||Ce.friendly_name.toLowerCase().includes(Oe.toLowerCase())):pe,Le=bn.find(Ce=>Ce.entity_id===Q);return s.jsxs("div",{ref:Y,className:"relative",children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Power Sensor (W)"}),s.jsxs("div",{className:"relative",children:[s.jsx(ba,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"}),s.jsx("input",{type:"text",value:Ke?Oe:Le?`${Le.friendly_name} (${Le.state} ${Le.unit_of_measurement})`:"",onChange:Ce=>{ge(Ce.target.value),Ke||G(!0)},onFocus:()=>{G(!0),ge("")},placeholder:"Search power sensors...",className:"w-full pl-9 pr-8 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"}),Q&&!Ke&&s.jsx("button",{type:"button",onClick:()=>{Z(""),ge("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:s.jsx(Rt,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]}),Ke&&s.jsxs("div",{className:"absolute z-50 w-full mt-1 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-48 overflow-y-auto",children:[s.jsx("button",{type:"button",onClick:()=>{Z(""),G(!1),ge("")},className:"w-full px-3 py-2 text-left text-sm text-bambu-gray hover:bg-bambu-dark-tertiary",children:"None"}),Ie.map(Ce=>s.jsxs("button",{type:"button",onClick:()=>{Z(Ce.entity_id),G(!1),ge("")},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${Ce.entity_id===Q?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[s.jsx("div",{className:"font-medium",children:Ce.friendly_name}),s.jsxs("div",{className:"text-xs text-bambu-gray",children:[Ce.entity_id," • ",Ce.state," ",Ce.unit_of_measurement]})]},Ce.entity_id)),Ie.length===0&&s.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No matching sensors"})]})]})})(),(()=>{const pe=bn.filter(Ce=>Ce.unit_of_measurement==="kWh"||Ce.unit_of_measurement==="Wh"||Ce.unit_of_measurement==="MWh"),Ie=ce?pe.filter(Ce=>Ce.entity_id.toLowerCase().includes(ce.toLowerCase())||Ce.friendly_name.toLowerCase().includes(ce.toLowerCase())):pe,Le=bn.find(Ce=>Ce.entity_id===ae);return s.jsxs("div",{ref:fe,className:"relative",children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Energy Today (kWh)"}),s.jsxs("div",{className:"relative",children:[s.jsx(ba,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"}),s.jsx("input",{type:"text",value:te?ce:Le?`${Le.friendly_name} (${Le.state} ${Le.unit_of_measurement})`:"",onChange:Ce=>{q(Ce.target.value),te||I(!0)},onFocus:()=>{I(!0),q("")},placeholder:"Search energy sensors...",className:"w-full pl-9 pr-8 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"}),ae&&!te&&s.jsx("button",{type:"button",onClick:()=>{B(""),q("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:s.jsx(Rt,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]}),te&&s.jsxs("div",{className:"absolute z-50 w-full mt-1 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-48 overflow-y-auto",children:[s.jsx("button",{type:"button",onClick:()=>{B(""),I(!1),q("")},className:"w-full px-3 py-2 text-left text-sm text-bambu-gray hover:bg-bambu-dark-tertiary",children:"None"}),Ie.map(Ce=>s.jsxs("button",{type:"button",onClick:()=>{B(Ce.entity_id),I(!1),q("")},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${Ce.entity_id===ae?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[s.jsx("div",{className:"font-medium",children:Ce.friendly_name}),s.jsxs("div",{className:"text-xs text-bambu-gray",children:[Ce.entity_id," • ",Ce.state," ",Ce.unit_of_measurement]})]},Ce.entity_id)),Ie.length===0&&s.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No matching sensors"})]})]})})(),(()=>{const pe=bn.filter(Ce=>Ce.unit_of_measurement==="kWh"||Ce.unit_of_measurement==="Wh"||Ce.unit_of_measurement==="MWh"),Ie=me?pe.filter(Ce=>Ce.entity_id.toLowerCase().includes(me.toLowerCase())||Ce.friendly_name.toLowerCase().includes(me.toLowerCase())):pe,Le=bn.find(Ce=>Ce.entity_id===X);return s.jsxs("div",{ref:ee,className:"relative",children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Total Energy (kWh)"}),s.jsxs("div",{className:"relative",children:[s.jsx(ba,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"}),s.jsx("input",{type:"text",value:z?me:Le?`${Le.friendly_name} (${Le.state} ${Le.unit_of_measurement})`:"",onChange:Ce=>{Ee(Ce.target.value),z||O(!0)},onFocus:()=>{O(!0),Ee("")},placeholder:"Search energy sensors...",className:"w-full pl-9 pr-8 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"}),X&&!z&&s.jsx("button",{type:"button",onClick:()=>{ne(""),Ee("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:s.jsx(Rt,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]}),z&&s.jsxs("div",{className:"absolute z-50 w-full mt-1 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-48 overflow-y-auto",children:[s.jsx("button",{type:"button",onClick:()=>{ne(""),O(!1),Ee("")},className:"w-full px-3 py-2 text-left text-sm text-bambu-gray hover:bg-bambu-dark-tertiary",children:"None"}),Ie.map(Ce=>s.jsxs("button",{type:"button",onClick:()=>{ne(Ce.entity_id),O(!1),Ee("")},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${Ce.entity_id===X?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[s.jsx("div",{className:"font-medium",children:Ce.friendly_name}),s.jsxs("div",{className:"text-xs text-bambu-gray",children:[Ce.entity_id," • ",Ce.state," ",Ce.unit_of_measurement]})]},Ce.entity_id)),Ie.length===0&&s.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No matching sensors"})]})]})})()]})]})]}),i==="mqtt"&&s.jsxs("div",{className:"space-y-3",children:[!Dn?.mqtt_broker&&s.jsxs("div",{className:"p-3 bg-yellow-500/20 border border-yellow-500/50 rounded-lg text-sm text-yellow-400",children:["MQTT broker not configured. Set broker address in"," ",s.jsx("span",{className:"font-medium",children:"Settings → Network → MQTT Publishing"})," ","(you don't need to enable publishing, just fill in the broker details)."]}),Dn?.mqtt_broker&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg text-sm text-blue-300",children:[s.jsx("p",{className:"font-medium mb-1",children:"Monitor Only"}),s.jsx("p",{className:"text-xs opacity-80",children:"MQTT plugs receive power/energy data via MQTT subscription. On/off control is not available - use your MQTT broker or home automation system."})]}),s.jsxs("div",{className:"space-y-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[s.jsx("p",{className:"text-white font-medium text-sm",children:"Power Monitoring"}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Topic"}),s.jsx("input",{type:"text",value:y,onChange:pe=>v(pe.target.value),placeholder:"zigbee2mqtt/shelly-working-room",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"JSON Path"}),s.jsx("input",{type:"text",value:S,onChange:pe=>N(pe.target.value),placeholder:"power_l1",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Multiplier"}),s.jsx("input",{type:"text",value:T,onChange:pe=>k(pe.target.value),placeholder:"1",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]})]}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:['JSON path extracts value from JSON payload (e.g., "power_l1"). Leave empty if topic publishes raw numeric values.',s.jsx("br",{}),"Use multiplier 0.001 for mW→W, 1000 for kW→W."]})]}),s.jsxs("div",{className:"space-y-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[s.jsxs("p",{className:"text-white font-medium text-sm",children:["Energy Monitoring ",s.jsx("span",{className:"text-bambu-gray font-normal",children:"(optional)"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Topic"}),s.jsx("input",{type:"text",value:C,onChange:pe=>E(pe.target.value),placeholder:"Same as power topic, or different",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"JSON Path"}),s.jsx("input",{type:"text",value:D,onChange:pe=>A(pe.target.value),placeholder:"energy_l1",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Multiplier"}),s.jsx("input",{type:"text",value:R,onChange:pe=>U(pe.target.value),placeholder:"1",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]})]}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:["JSON path extracts value from JSON payload. Leave empty for raw values.",s.jsx("br",{}),"Use multiplier 0.001 for Wh→kWh, 1000 for MWh→kWh."]})]}),s.jsxs("div",{className:"space-y-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[s.jsxs("p",{className:"text-white font-medium text-sm",children:["State Monitoring ",s.jsx("span",{className:"text-bambu-gray font-normal",children:"(optional)"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Topic"}),s.jsx("input",{type:"text",value:F,onChange:pe=>$(pe.target.value),placeholder:"Same as power topic, or different",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"JSON Path"}),s.jsx("input",{type:"text",value:j,onChange:pe=>H(pe.target.value),placeholder:"state_l1",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"ON Value"}),s.jsx("input",{type:"text",value:K,onChange:pe=>V(pe.target.value),placeholder:"ON, true, 1",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]})]}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:["JSON path extracts value from JSON payload. Leave empty for raw values.",s.jsx("br",{}),'ON value: the exact string that means "ON". Leave empty for auto-detect (ON, true, 1).']})]})]})]}),i==="tasmota"&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"IP Address *"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{type:"text",value:c,onChange:pe=>{u(pe.target.value),re(null)},placeholder:"192.168.1.100",className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),s.jsxs(Te,{type:"button",variant:"secondary",onClick:()=>Ze.mutate(),disabled:!c.trim()||Ze.isPending,children:[Ze.isPending?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(Sg,{className:"w-4 h-4"}),"Test"]})]})]}),i==="tasmota"&&we&&s.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${we.success?"bg-bambu-green/20 border border-bambu-green/50 text-bambu-green":"bg-red-500/20 border border-red-500/50 text-red-400"}`,children:we.success?s.jsxs(s.Fragment,{children:[s.jsx(Ar,{className:"w-5 h-5"}),s.jsxs("div",{children:[s.jsx("p",{className:"font-medium",children:"Connected!"}),s.jsxs("p",{className:"text-sm opacity-80",children:[we.device_name&&`Device: ${we.device_name} - `,"State: ",we.state]})]})]}):s.jsxs(s.Fragment,{children:[s.jsx(sm,{className:"w-5 h-5"}),s.jsx("span",{children:"Connection failed"})]})}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),s.jsx("input",{type:"text",value:o,onChange:pe=>l(pe.target.value),placeholder:"Living Room Plug",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),i==="tasmota"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Username"}),s.jsx("input",{type:"text",value:d,onChange:pe=>f(pe.target.value),placeholder:"admin",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Password"}),s.jsx("input",{type:"password",value:p,onChange:pe=>m(pe.target.value),placeholder:"********",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]})]}),s.jsx("p",{className:"text-xs text-bambu-gray -mt-2",children:"Leave empty if your Tasmota device doesn't require authentication"})]}),i!=="mqtt"&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Link to Printer"}),s.jsxs("select",{value:le??"",onChange:pe=>_e(pe.target.value?Number(pe.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"",children:"No printer (manual control only)"}),ot?.map(pe=>s.jsx("option",{value:pe.id,children:pe.name},pe.id))]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Linking enables automatic on/off when prints start/complete"})]}),s.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(wg,{className:"w-4 h-4 text-bambu-green"}),s.jsx("span",{className:"text-white font-medium",children:"Power Alerts"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:Ve,onChange:pe=>$e(pe.target.checked),className:"sr-only peer"}),s.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),Ve&&s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Alert if above (W)"}),s.jsx("input",{type:"number",value:ye,onChange:pe=>je(pe.target.value),placeholder:"e.g. 200",min:"0",max:"5000",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Alert if below (W)"}),s.jsx("input",{type:"number",value:Be,onChange:pe=>Se(pe.target.value),placeholder:"e.g. 10",min:"0",max:"5000",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Get notified when power consumption crosses these thresholds. Leave empty to disable that direction."})]})]}),i!=="mqtt"&&s.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(er,{className:"w-4 h-4 text-bambu-green"}),s.jsx("span",{className:"text-white font-medium",children:"Daily Schedule"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:Xe,onChange:pe=>Me(pe.target.checked),className:"sr-only peer"}),s.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),Xe&&s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Turn On at"}),s.jsx("input",{type:"time",value:tt,onChange:pe=>ke(pe.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Turn Off at"}),s.jsx("input",{type:"time",value:We,onChange:pe=>ze(pe.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Automatically turn the plug on/off at these times daily. Leave empty to skip that action."})]})]}),s.jsx("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(mN,{className:"w-4 h-4 text-bambu-green"}),s.jsxs("div",{children:[s.jsx("span",{className:"text-white font-medium",children:"Show in Switchbar"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Quick access from sidebar"})]})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:W,onChange:pe=>De(pe.target.checked),className:"sr-only peer"}),s.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]})}),s.jsxs("div",{className:"flex gap-3 pt-2",children:[s.jsx(Te,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),s.jsxs(Te,{type:"submit",disabled:he,className:"flex-1",children:[he?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(hs,{className:"w-4 h-4"}),r?"Save":"Add"]})]})]})]})})}function On({checked:t,onChange:e,disabled:n}){const r=i=>{i.preventDefault(),i.stopPropagation(),n||e(!t)};return s.jsx("button",{type:"button",role:"switch","aria-checked":t,disabled:n,onClick:r,className:`relative inline-flex w-11 h-7 md:w-9 md:h-5 rounded-full transition-colors flex-shrink-0 focus:outline-none focus:ring-2 focus:ring-bambu-green focus:ring-offset-2 focus:ring-offset-bambu-dark ${n?"bg-bambu-dark-tertiary/50 cursor-not-allowed opacity-50":t?"bg-bambu-green cursor-pointer":"bg-bambu-dark-tertiary cursor-pointer hover:bg-bambu-dark-tertiary/80"}`,children:s.jsx("span",{className:`pointer-events-none absolute top-[3px] md:top-[2px] left-[3px] md:left-[2px] w-5 h-5 md:w-4 md:h-4 bg-white rounded-full shadow transition-transform duration-200 ease-in-out ${t?"translate-x-4":"translate-x-0"}`})})}const aKe={callmebot:"CallMeBot/WhatsApp",ntfy:"ntfy",pushover:"Pushover",telegram:"Telegram",email:"Email",discord:"Discord",webhook:"Webhook"};function sKe({provider:t,onEdit:e}){const n=an(),[r,i]=_.useState(!1),[a,o]=_.useState(!1),[l,c]=_.useState(null),{data:u}=at({queryKey:["printers"],queryFn:ue.getPrinters}),d=u?.find(b=>b.id===t.printer_id),f=mt({mutationFn:b=>ue.updateNotificationProvider(t.id,b),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),p=mt({mutationFn:()=>ue.deleteNotificationProvider(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),m=mt({mutationFn:()=>ue.testNotificationProvider(t.id),onSuccess:b=>{c(b),n.invalidateQueries({queryKey:["notification-providers"]})},onError:b=>{c({success:!1,message:b.message})}}),x=b=>b||"";return s.jsxs(s.Fragment,{children:[s.jsx(_t,{className:"relative",children:s.jsxs(Mt,{className:"p-4",children:[s.jsxs("div",{className:"flex items-start justify-between mb-3",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:`p-2 rounded-lg ${t.enabled?"bg-bambu-green/20":"bg-bambu-dark"}`,children:s.jsx(wg,{className:`w-5 h-5 ${t.enabled?"text-bambu-green":"text-bambu-gray"}`})}),s.jsxs("div",{children:[s.jsx("h3",{className:"font-medium text-white",children:t.name}),s.jsx("p",{className:"text-sm text-bambu-gray",children:aKe[t.provider_type]||t.provider_type})]})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[t.last_success&&s.jsxs("span",{className:"text-xs text-status-ok hidden sm:inline",children:["Last: ",Bg(t.last_success)]}),t.last_error&&t.last_error_at&&(!t.last_success||(Ii(t.last_error_at)?.getTime()||0)>(Ii(t.last_success)?.getTime()||0))&&s.jsx("span",{className:"text-xs text-status-error",title:t.last_error,children:"Error"}),s.jsx(On,{checked:t.enabled,onChange:b=>f.mutate({enabled:b})})]})]}),d&&s.jsxs("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:[s.jsx("span",{className:"text-xs text-bambu-gray",children:"Printer: "}),s.jsx("span",{className:"text-sm text-white",children:d.name})]}),!d&&!t.printer_id&&s.jsx("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:s.jsx("span",{className:"text-xs text-bambu-gray",children:"All printers"})}),s.jsxs("div",{className:"mb-3 flex flex-wrap gap-1",children:[t.on_print_start&&s.jsx("span",{className:"px-2 py-0.5 bg-blue-500/20 text-blue-400 text-xs rounded",children:"Start"}),t.on_plate_not_empty&&s.jsx("span",{className:"px-2 py-0.5 bg-rose-600/20 text-rose-300 text-xs rounded",children:"Plate Check"}),t.on_print_complete&&s.jsx("span",{className:"px-2 py-0.5 bg-bambu-green/20 text-bambu-green text-xs rounded",children:"Complete"}),t.on_print_failed&&s.jsx("span",{className:"px-2 py-0.5 bg-red-500/20 text-red-400 text-xs rounded",children:"Failed"}),t.on_print_stopped&&s.jsx("span",{className:"px-2 py-0.5 bg-orange-500/20 text-orange-400 text-xs rounded",children:"Stopped"}),t.on_print_progress&&s.jsx("span",{className:"px-2 py-0.5 bg-yellow-500/20 text-yellow-400 text-xs rounded",children:"Progress"}),t.on_printer_offline&&s.jsx("span",{className:"px-2 py-0.5 bg-gray-500/20 text-gray-400 text-xs rounded",children:"Offline"}),t.on_printer_error&&s.jsx("span",{className:"px-2 py-0.5 bg-rose-500/20 text-rose-400 text-xs rounded",children:"Error"}),t.on_filament_low&&s.jsx("span",{className:"px-2 py-0.5 bg-cyan-500/20 text-cyan-400 text-xs rounded",children:"Low Filament"}),t.on_maintenance_due&&s.jsx("span",{className:"px-2 py-0.5 bg-purple-500/20 text-purple-400 text-xs rounded",children:"Maintenance"}),t.on_ams_humidity_high&&s.jsx("span",{className:"px-2 py-0.5 bg-blue-600/20 text-blue-300 text-xs rounded",children:"AMS Humidity"}),t.on_ams_temperature_high&&s.jsx("span",{className:"px-2 py-0.5 bg-orange-600/20 text-orange-300 text-xs rounded",children:"AMS Temp"}),t.on_ams_ht_humidity_high&&s.jsx("span",{className:"px-2 py-0.5 bg-cyan-600/20 text-cyan-300 text-xs rounded",children:"AMS-HT Humidity"}),t.on_ams_ht_temperature_high&&s.jsx("span",{className:"px-2 py-0.5 bg-amber-600/20 text-amber-300 text-xs rounded",children:"AMS-HT Temp"}),t.quiet_hours_enabled&&s.jsxs("span",{className:"px-2 py-0.5 bg-indigo-500/20 text-indigo-400 text-xs rounded flex items-center gap-1",children:[s.jsx(W1,{className:"w-3 h-3"}),"Quiet"]}),t.daily_digest_enabled&&s.jsxs("span",{className:"px-2 py-0.5 bg-emerald-500/20 text-emerald-400 text-xs rounded flex items-center gap-1",children:[s.jsx(si,{className:"w-3 h-3"}),"Digest ",t.daily_digest_time]})]}),s.jsx("div",{className:"mb-3",children:s.jsxs(Te,{size:"sm",variant:"secondary",disabled:m.isPending,onClick:()=>{c(null),m.mutate()},className:"w-full",children:[m.isPending?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(PR,{className:"w-4 h-4"}),"Send Test Notification"]})}),l&&s.jsxs("div",{className:`mb-3 p-2 rounded-lg flex items-center gap-2 text-sm ${l.success?"bg-bambu-green/20 text-bambu-green":"bg-red-500/20 text-red-400"}`,children:[l.success?s.jsx(Ar,{className:"w-4 h-4"}):s.jsx(Yi,{className:"w-4 h-4"}),s.jsx("span",{children:l.message})]}),s.jsxs("button",{onClick:()=>o(!a),className:"w-full flex items-center justify-between py-2 text-sm text-bambu-gray hover:text-white transition-colors border-t border-bambu-dark-tertiary",children:[s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx(bh,{className:"w-4 h-4"}),"Event Settings"]}),a?s.jsx(xh,{className:"w-4 h-4"}):s.jsx(ei,{className:"w-4 h-4"})]}),a&&s.jsxs("div",{className:"pt-3 border-t border-bambu-dark-tertiary space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Enabled"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Send notifications from this provider"})]}),s.jsx(On,{checked:t.enabled,onChange:b=>f.mutate({enabled:b})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"Print Events"}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("p",{className:"text-sm text-white",children:"Print Started"}),s.jsx(On,{checked:t.on_print_start,onChange:b=>f.mutate({on_print_start:b})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Plate Not Empty"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Objects detected before print"})]}),s.jsx(On,{checked:t.on_plate_not_empty??!0,onChange:b=>f.mutate({on_plate_not_empty:b})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("p",{className:"text-sm text-white",children:"Print Completed"}),s.jsx(On,{checked:t.on_print_complete,onChange:b=>f.mutate({on_print_complete:b})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("p",{className:"text-sm text-white",children:"Print Failed"}),s.jsx(On,{checked:t.on_print_failed,onChange:b=>f.mutate({on_print_failed:b})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("p",{className:"text-sm text-white",children:"Print Stopped"}),s.jsx(On,{checked:t.on_print_stopped,onChange:b=>f.mutate({on_print_stopped:b})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Progress Milestones"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Notify at 25%, 50%, 75%"})]}),s.jsx(On,{checked:t.on_print_progress,onChange:b=>f.mutate({on_print_progress:b})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"Printer Status"}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("p",{className:"text-sm text-white",children:"Printer Offline"}),s.jsx(On,{checked:t.on_printer_offline,onChange:b=>f.mutate({on_printer_offline:b})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("p",{className:"text-sm text-white",children:"Printer Error"}),s.jsx(On,{checked:t.on_printer_error,onChange:b=>f.mutate({on_printer_error:b})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("p",{className:"text-sm text-white",children:"Low Filament"}),s.jsx(On,{checked:t.on_filament_low,onChange:b=>f.mutate({on_filament_low:b})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Maintenance Due"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Notify when maintenance is needed"})]}),s.jsx(On,{checked:t.on_maintenance_due??!1,onChange:b=>f.mutate({on_maintenance_due:b})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"AMS Alarms"}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"AMS Humidity High"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Regular AMS humidity exceeds threshold"})]}),s.jsx(On,{checked:t.on_ams_humidity_high??!1,onChange:b=>f.mutate({on_ams_humidity_high:b})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"AMS Temperature High"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Regular AMS temperature exceeds threshold"})]}),s.jsx(On,{checked:t.on_ams_temperature_high??!1,onChange:b=>f.mutate({on_ams_temperature_high:b})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"AMS-HT Alarms"}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"AMS-HT Humidity High"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"AMS-HT humidity exceeds threshold"})]}),s.jsx(On,{checked:t.on_ams_ht_humidity_high??!1,onChange:b=>f.mutate({on_ams_ht_humidity_high:b})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"AMS-HT Temperature High"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"AMS-HT temperature exceeds threshold"})]}),s.jsx(On,{checked:t.on_ams_ht_temperature_high??!1,onChange:b=>f.mutate({on_ams_ht_temperature_high:b})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"Print Queue"}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Job Added"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Job added to queue"})]}),s.jsx(On,{checked:t.on_queue_job_added??!1,onChange:b=>f.mutate({on_queue_job_added:b})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Job Assigned"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Model-based job assigned to printer"})]}),s.jsx(On,{checked:t.on_queue_job_assigned??!1,onChange:b=>f.mutate({on_queue_job_assigned:b})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Job Started"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Queue job started printing"})]}),s.jsx(On,{checked:t.on_queue_job_started??!1,onChange:b=>f.mutate({on_queue_job_started:b})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Job Waiting"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Job waiting for filament"})]}),s.jsx(On,{checked:t.on_queue_job_waiting??!0,onChange:b=>f.mutate({on_queue_job_waiting:b})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Job Skipped"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Job skipped (previous failed)"})]}),s.jsx(On,{checked:t.on_queue_job_skipped??!0,onChange:b=>f.mutate({on_queue_job_skipped:b})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Job Failed"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Job failed to start"})]}),s.jsx(On,{checked:t.on_queue_job_failed??!0,onChange:b=>f.mutate({on_queue_job_failed:b})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Queue Complete"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"All queue jobs finished"})]}),s.jsx(On,{checked:t.on_queue_completed??!1,onChange:b=>f.mutate({on_queue_completed:b})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(W1,{className:"w-4 h-4 text-purple-400"}),s.jsx("p",{className:"text-sm text-white",children:"Quiet Hours"})]}),s.jsx(On,{checked:t.quiet_hours_enabled,onChange:b=>f.mutate({quiet_hours_enabled:b})})]}),t.quiet_hours_enabled&&s.jsxs("div",{className:"pl-4 border-l-2 border-bambu-dark-tertiary space-y-2",children:[s.jsx("p",{className:"text-xs text-bambu-gray",children:"No notifications during these hours"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(er,{className:"w-4 h-4 text-bambu-gray"}),s.jsxs("span",{className:"text-sm text-white",children:[x(t.quiet_hours_start)||"22:00"," - ",x(t.quiet_hours_end)||"07:00"]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Edit provider to change quiet hours"})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(si,{className:"w-4 h-4 text-emerald-400"}),s.jsx("p",{className:"text-sm text-white",children:"Daily Digest"})]}),s.jsx(On,{checked:t.daily_digest_enabled,onChange:b=>f.mutate({daily_digest_enabled:b})})]}),t.daily_digest_enabled&&s.jsxs("div",{className:"pl-4 border-l-2 border-bambu-dark-tertiary space-y-2",children:[s.jsx("p",{className:"text-xs text-bambu-gray",children:"Batch notifications into a single daily summary"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(er,{className:"w-4 h-4 text-bambu-gray"}),s.jsxs("span",{className:"text-sm text-white",children:["Send at ",x(t.daily_digest_time)||"08:00"]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Edit provider to change digest time"})]})]}),s.jsxs("div",{className:"flex gap-2 pt-2",children:[s.jsxs(Te,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[s.jsx(fg,{className:"w-4 h-4"}),"Edit"]}),s.jsx(Te,{size:"sm",variant:"secondary",onClick:()=>i(!0),className:"text-red-400 hover:text-red-300",children:s.jsx(rn,{className:"w-4 h-4"})})]})]})]})}),r&&s.jsx(Zn,{title:"Delete Notification Provider",message:`Are you sure you want to delete "${t.name}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{p.mutate(),i(!1)},onCancel:()=>i(!1)})]})}const hq=[{value:"email",label:"Email",description:"SMTP email notifications"},{value:"telegram",label:"Telegram",description:"Notifications via Telegram bot"},{value:"discord",label:"Discord",description:"Send to Discord channel via webhook"},{value:"ntfy",label:"ntfy",description:"Free, self-hostable push notifications"},{value:"pushover",label:"Pushover",description:"Simple, reliable push notifications"},{value:"callmebot",label:"CallMeBot/WhatsApp",description:"Free WhatsApp notifications via CallMeBot"},{value:"webhook",label:"Webhook",description:"Generic HTTP POST to any URL"}];function oKe({provider:t,onClose:e}){const n=an(),r=!!t,[i,a]=_.useState(t?.name||""),[o,l]=_.useState(t?.provider_type||"email"),[c,u]=_.useState(t?.printer_id||null),[d,f]=_.useState(t?.quiet_hours_enabled||!1),[p,m]=_.useState(t?.quiet_hours_start||"22:00"),[x,b]=_.useState(t?.quiet_hours_end||"07:00"),[y,v]=_.useState(t?.daily_digest_enabled||!1),[S,N]=_.useState(t?.daily_digest_time||"08:00"),[T,k]=_.useState(t?.on_print_start??!1),[C,E]=_.useState(t?.on_print_complete??!0),[D,A]=_.useState(t?.on_print_failed??!0),[R,U]=_.useState(t?.on_print_stopped??!0),[F,$]=_.useState(t?.on_print_progress??!1),[j,H]=_.useState(t?.on_printer_offline??!1),[K,V]=_.useState(t?.on_printer_error??!1),[Q,Z]=_.useState(t?.on_filament_low??!1),[ae,B]=_.useState(t?.on_maintenance_due??!1),[X,ne]=_.useState(t?.config?Object.fromEntries(Object.entries(t.config).map(([q,te])=>[q,String(te)])):{}),[se,be]=_.useState(null),[xe,de]=_.useState(null),{data:Pe}=at({queryKey:["printers"],queryFn:ue.getPrinters});_.useEffect(()=>{const q=te=>{te.key==="Escape"&&e()};return window.addEventListener("keydown",q),()=>window.removeEventListener("keydown",q)},[e]);const ie=mt({mutationFn:()=>ue.testNotificationConfig({provider_type:o,config:X}),onSuccess:q=>{be(q),de(null)},onError:q=>{be({success:!1,message:q.message})}}),Ne=mt({mutationFn:q=>ue.createNotificationProvider(q),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:q=>{de(q.message)}}),Oe=mt({mutationFn:q=>ue.updateNotificationProvider(t.id,q),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:q=>{de(q.message)}}),ge=q=>{if(q.preventDefault(),de(null),!i.trim()){de("Name is required");return}const te=Y(o);for(const fe of te)if(!X[fe.key]?.trim()){de(`${fe.label} is required`);return}const I={name:i.trim(),provider_type:o,config:X,printer_id:c,quiet_hours_enabled:d,quiet_hours_start:d?p:null,quiet_hours_end:d?x:null,daily_digest_enabled:y,daily_digest_time:y?S:null,on_print_start:T,on_print_complete:C,on_print_failed:D,on_print_stopped:R,on_print_progress:F,on_printer_offline:j,on_printer_error:K,on_filament_low:Q,on_maintenance_due:ae};r?Oe.mutate(I):Ne.mutate(I)},Ke=Ne.isPending||Oe.isPending,G=q=>{switch(q){case"callmebot":return[{key:"phone",label:"Phone Number",placeholder:"+1234567890",type:"text",required:!0},{key:"apikey",label:"API Key",placeholder:"Your CallMeBot API key",type:"text",required:!0}];case"ntfy":return[{key:"server",label:"Server URL",placeholder:"https://ntfy.sh",type:"text",required:!1},{key:"topic",label:"Topic",placeholder:"my-bambuddy",type:"text",required:!0},{key:"auth_token",label:"Auth Token",placeholder:"Optional authentication",type:"password",required:!1}];case"pushover":return[{key:"user_key",label:"User Key",placeholder:"Your Pushover user key",type:"text",required:!0},{key:"app_token",label:"App Token",placeholder:"Your Pushover app token",type:"text",required:!0},{key:"priority",label:"Priority",placeholder:"0 (normal)",type:"number",required:!1}];case"telegram":return[{key:"bot_token",label:"Bot Token",placeholder:"Bot token from @BotFather",type:"password",required:!0},{key:"chat_id",label:"Chat ID",placeholder:"Your chat or group ID",type:"text",required:!0}];case"email":return[{key:"smtp_server",label:"SMTP Server",placeholder:"smtp.gmail.com",type:"text",required:!0},{key:"smtp_port",label:"SMTP Port",placeholder:"587",type:"number",required:!1},{key:"security",label:"Security",type:"select",required:!1,options:[{value:"starttls",label:"STARTTLS (Port 587)"},{value:"ssl",label:"SSL/TLS (Port 465)"},{value:"none",label:"None (Port 25)"}]},{key:"auth_enabled",label:"Authentication",type:"select",required:!1,options:[{value:"true",label:"Enabled"},{value:"false",label:"Disabled"}]},{key:"username",label:"Username",placeholder:"your@email.com",type:"text",required:!1},{key:"password",label:"Password",placeholder:"App password",type:"password",required:!1},{key:"from_email",label:"From Email",placeholder:"your@email.com",type:"text",required:!0},{key:"to_email",label:"To Email",placeholder:"recipient@email.com",type:"text",required:!0}];case"discord":return[{key:"webhook_url",label:"Webhook URL",placeholder:"https://discord.com/api/webhooks/...",type:"text",required:!0}];case"webhook":return[{key:"webhook_url",label:"Webhook URL",placeholder:"https://example.com/webhook",type:"text",required:!0},{key:"payload_format",label:"Payload Format",type:"select",required:!1,options:[{value:"generic",label:"Generic JSON"},{value:"slack",label:"Slack / Mattermost"}]},{key:"auth_header",label:"Authorization",placeholder:"Bearer token (optional)",type:"password",required:!1},{key:"field_title",label:"Title Field Name",placeholder:"title",type:"text",required:!1,showIf:te=>te.payload_format!=="slack"},{key:"field_message",label:"Message Field Name",placeholder:"message",type:"text",required:!1,showIf:te=>te.payload_format!=="slack"}];default:return[]}},Y=q=>G(q).filter(te=>te.required),ce=G(o);return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4 overflow-y-auto",onClick:e,children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-lg my-8 max-h-[90vh] overflow-y-auto",onClick:q=>q.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:r?"Edit Notification Provider":"Add Notification Provider"}),s.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(Rt,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:ge,className:"p-6 space-y-4",children:[xe&&s.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:xe}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),s.jsx("input",{type:"text",value:i,onChange:q=>a(q.target.value),placeholder:"My Notifications",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Provider Type *"}),s.jsx("select",{value:o,onChange:q=>{l(q.target.value),ne({}),be(null)},disabled:r,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none disabled:opacity-50",children:hq.map(q=>s.jsx("option",{value:q.value,children:q.label},q.value))}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:hq.find(q=>q.value===o)?.description})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Configuration"}),ce.filter(q=>!("showIf"in q)||q.showIf?.(X)!==!1).map(q=>s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[q.label," ",q.required&&"*"]}),q.type==="select"&&"options"in q&&q.options?s.jsx("select",{value:X[q.key]||q.options[0]?.value||"",onChange:te=>{ne({...X,[q.key]:te.target.value}),be(null)},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:q.options.map(te=>s.jsx("option",{value:te.value,children:te.label},te.value))}):s.jsx("input",{type:q.type,value:X[q.key]||"",onChange:te=>{ne({...X,[q.key]:te.target.value}),be(null)},placeholder:q.placeholder,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]},q.key))]}),s.jsx("div",{className:"flex gap-2",children:s.jsxs(Te,{type:"button",variant:"secondary",onClick:()=>{be(null),ie.mutate()},disabled:ie.isPending||!X[Y(o)[0]?.key],className:"flex-1",children:[ie.isPending?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(PR,{className:"w-4 h-4"}),"Test Configuration"]})}),se&&s.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${se.success?"bg-bambu-green/20 border border-bambu-green/50 text-bambu-green":"bg-red-500/20 border border-red-500/50 text-red-400"}`,children:se.success?s.jsxs(s.Fragment,{children:[s.jsx(Ar,{className:"w-5 h-5"}),s.jsx("span",{children:se.message})]}):s.jsxs(s.Fragment,{children:[s.jsx(Yi,{className:"w-5 h-5"}),s.jsx("span",{children:se.message})]})}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer Filter"}),s.jsxs("select",{value:c??"",onChange:q=>u(q.target.value?Number(q.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"",children:"All printers"}),Pe?.map(q=>s.jsx("option",{value:q.id,children:q.name},q.id))]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Only send notifications for events from this printer"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("label",{className:"text-sm text-white",children:"Quiet Hours (Do Not Disturb)"}),s.jsx(On,{checked:d,onChange:f})]}),d&&s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Start"}),s.jsx("input",{type:"time",value:p,onChange:q=>m(q.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"End"}),s.jsx("input",{type:"time",value:x,onChange:q=>b(q.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-sm text-white",children:"Daily Digest"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Batch notifications into a single daily summary"})]}),s.jsx(On,{checked:y,onChange:v})]}),y&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Send digest at"}),s.jsx("input",{type:"time",value:S,onChange:q=>N(q.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Events will be collected and sent as a single summary at this time"})]})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Notification Events"}),s.jsxs("div",{className:"space-y-2 p-3 bg-bambu-dark rounded-lg",children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide mb-2",children:"Print Events"}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Start"}),s.jsx(On,{checked:T,onChange:k})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Complete"}),s.jsx(On,{checked:C,onChange:E})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Failed"}),s.jsx(On,{checked:D,onChange:A})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Stopped"}),s.jsx(On,{checked:R,onChange:U})]}),s.jsxs("div",{className:"flex items-center justify-between col-span-2",children:[s.jsxs("div",{children:[s.jsx("span",{className:"text-sm text-white",children:"Progress"}),s.jsx("span",{className:"text-xs text-bambu-gray ml-1",children:"(25%, 50%, 75%)"})]}),s.jsx(On,{checked:F,onChange:$})]})]})]}),s.jsxs("div",{className:"space-y-2 p-3 bg-bambu-dark rounded-lg",children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide mb-2",children:"Printer Status"}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Offline"}),s.jsx(On,{checked:j,onChange:H})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Error"}),s.jsx(On,{checked:K,onChange:V})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Low Filament"}),s.jsx(On,{checked:Q,onChange:Z})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Maintenance"}),s.jsx(On,{checked:ae,onChange:B})]})]})]})]}),s.jsxs("div",{className:"flex gap-3 pt-2",children:[s.jsx(Te,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),s.jsxs(Te,{type:"submit",disabled:Ke,className:"flex-1",children:[Ke?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(hs,{className:"w-4 h-4"}),r?"Save":"Add"]})]})]})]})})}function lKe({template:t,onClose:e}){const n=an(),r=_.useRef(null),[i,a]=_.useState(t.title_template),[o,l]=_.useState(t.body_template),[c,u]=_.useState(null),[d,f]=_.useState(!0),{data:p}=at({queryKey:["template-variables"],queryFn:ue.getTemplateVariables}),m=p?.find(k=>k.event_type===t.event_type),{data:x,isLoading:b}=at({queryKey:["template-preview",t.event_type,i,o],queryFn:()=>ue.previewTemplate({event_type:t.event_type,title_template:i,body_template:o}),enabled:d&&i.length>0&&o.length>0});_.useEffect(()=>{const k=C=>{C.key==="Escape"&&e()};return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[e]);const y=mt({mutationFn:k=>ue.updateNotificationTemplate(t.id,k),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-templates"]}),e()},onError:k=>{u(k.message)}}),v=mt({mutationFn:()=>ue.resetNotificationTemplate(t.id),onSuccess:k=>{a(k.title_template),l(k.body_template),n.invalidateQueries({queryKey:["notification-templates"]})},onError:k=>{u(k.message)}}),S=k=>{if(k.preventDefault(),u(null),!i.trim()){u("Title is required");return}if(!o.trim()){u("Body is required");return}y.mutate({title_template:i,body_template:o})},N=k=>{const C=r.current;if(!C)return;const E=C.selectionStart,D=C.selectionEnd,A=o,R=A.substring(0,E),U=A.substring(D),F=R+`{${k}}`+U;l(F),setTimeout(()=>{C.focus();const $=E+k.length+2;C.setSelectionRange($,$)},0)},T=i!==t.title_template||o!==t.body_template;return s.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-2xl max-h-[90vh] flex flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary shrink-0",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Edit Template: ",t.name]}),s.jsx("button",{onClick:e,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",children:s.jsx(Rt,{className:"w-5 h-5 text-bambu-gray"})})]}),s.jsxs("form",{onSubmit:S,className:"flex-1 overflow-y-auto p-4 space-y-4",children:[c&&s.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded text-red-400 text-sm",children:c}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:"Title"}),s.jsx("input",{type:"text",value:i,onChange:k=>a(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..."})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:"Body"}),s.jsx("textarea",{ref:r,value:o,onChange: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..."})]}),m&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-2",children:"Available Variables"}),s.jsx("div",{className:"flex flex-wrap gap-2",children:m.variables.map(k=>s.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:[s.jsx(dr,{className:"w-3 h-3"}),k]},k))}),s.jsx("p",{className:"text-xs text-bambu-gray/60 mt-1",children:"Click to insert at cursor position in body"})]}),s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsxs("label",{className:"text-sm font-medium text-bambu-gray flex items-center gap-2",children:[s.jsx(Ru,{className:"w-4 h-4"}),"Live Preview"]}),s.jsx("button",{type:"button",onClick:()=>f(!d),className:"text-xs text-bambu-green hover:text-bambu-green-light",children:d?"Hide":"Show"})]}),d&&s.jsx("div",{className:"bg-bambu-dark border border-bambu-dark-tertiary rounded p-3 space-y-2",children:b?s.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-sm",children:[s.jsx(ht,{className:"w-4 h-4 animate-spin"}),"Loading preview..."]}):x?s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("span",{className:"text-xs text-bambu-gray",children:"Title:"}),s.jsx("div",{className:"text-white font-medium",children:x.title})]}),s.jsxs("div",{children:[s.jsx("span",{className:"text-xs text-bambu-gray",children:"Body:"}),s.jsx("div",{className:"text-white whitespace-pre-wrap text-sm",children:x.body})]})]}):s.jsx("div",{className:"text-bambu-gray text-sm",children:"Enter template content to see preview"})})]})]}),s.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary shrink-0",children:[s.jsxs(Te,{type:"button",variant:"ghost",onClick:()=>v.mutate(),disabled:v.isPending,className:"text-orange-400 hover:text-orange-300",children:[v.isPending?s.jsx(ht,{className:"w-4 h-4 animate-spin mr-2"}):s.jsx(Rh,{className:"w-4 h-4 mr-2"}),"Reset to Default"]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Te,{type:"button",variant:"secondary",onClick:e,children:"Cancel"}),s.jsxs(Te,{onClick:S,disabled:y.isPending||!T,children:[y.isPending?s.jsx(ht,{className:"w-4 h-4 animate-spin mr-2"}):s.jsx(hs,{className:"w-4 h-4 mr-2"}),"Save"]})]})]})]})})}const cKe={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"},uKe={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 dKe({onClose:t}){const e=an(),{showToast:n}=$n(),[r,i]=_.useState(7),[a,o]=_.useState(null),[l,c]=_.useState(!1),{data:u}=at({queryKey:["settings"],queryFn:ue.getSettings}),d=u?.time_format||"system",{data:f,isLoading:p,refetch:m,isRefetching:x}=at({queryKey:["notification-logs",r,l],queryFn:()=>ue.getNotificationLogs({days:r,limit:100,success:l?!1:void 0})}),{data:b}=at({queryKey:["notification-log-stats",r],queryFn:()=>ue.getNotificationLogStats(r)}),y=mt({mutationFn:()=>ue.clearNotificationLogs(30),onSuccess:S=>{n(S.message,"success"),e.invalidateQueries({queryKey:["notification-logs"]}),e.invalidateQueries({queryKey:["notification-log-stats"]})},onError:S=>{n(`Failed to clear logs: ${S.message}`,"error")}}),v=S=>{const N=Ii(S);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()+" "+Dfe(N,d)};return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:s.jsxs("div",{className:"bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg w-full max-w-3xl max-h-[85vh] flex flex-col",children:[s.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(q0,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Notification Log"})]}),s.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:"×"})]}),b&&s.jsx("div",{className:"px-4 py-3 border-b border-bambu-dark-tertiary bg-bambu-dark/50",children:s.jsxs("div",{className:"flex items-center gap-6 text-sm",children:[s.jsxs("span",{className:"text-bambu-gray",children:["Last ",r," days: ",s.jsx("span",{className:"text-white font-medium",children:b.total})," notifications"]}),s.jsxs("span",{className:"flex items-center gap-1 text-bambu-green",children:[s.jsx(Ar,{className:"w-4 h-4"}),b.success_count," sent"]}),b.failure_count>0&&s.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[s.jsx(Yi,{className:"w-4 h-4"}),b.failure_count," failed"]})]})}),s.jsxs("div",{className:"px-4 py-3 border-b border-bambu-dark-tertiary flex items-center gap-4",children:[s.jsxs("select",{value:r,onChange:S=>i(Number(S.target.value)),className:"px-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:outline-none focus:ring-1 focus:ring-bambu-green",children:[s.jsx("option",{value:1,children:"Last 24 hours"}),s.jsx("option",{value:7,children:"Last 7 days"}),s.jsx("option",{value:30,children:"Last 30 days"}),s.jsx("option",{value:90,children:"Last 90 days"})]}),s.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:l,onChange:S=>c(S.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),"Show failed only"]}),s.jsx("div",{className:"flex-1"}),s.jsxs(Te,{size:"sm",variant:"secondary",onClick:()=>m(),disabled:x,children:[x?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(Dr,{className:"w-4 h-4"}),"Refresh"]}),s.jsxs(Te,{size:"sm",variant:"secondary",onClick:()=>y.mutate(),disabled:y.isPending,className:"text-red-400 hover:text-red-300",children:[y.isPending?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(rn,{className:"w-4 h-4"}),"Clear Old"]})]}),s.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:p?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(ht,{className:"w-6 h-6 text-bambu-green animate-spin"})}):f&&f.length>0?s.jsx("div",{className:"space-y-2",children:f.map(S=>s.jsx(hKe,{log:S,isExpanded:a===S.id,onToggle:()=>o(a===S.id?null:S.id),formatDate:v,formatFullDate:N=>Hg(N,d)},S.id))}):s.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[s.jsx(q0,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),s.jsx("p",{className:"text-sm",children:l?"No failed notifications":"No notifications logged"})]})})]})})}function hKe({log:t,isExpanded:e,onToggle:n,formatDate:r,formatFullDate:i}){return s.jsxs("div",{className:`border rounded-lg overflow-hidden transition-colors ${t.success?"border-bambu-dark-tertiary bg-bambu-dark/30":"border-red-500/30 bg-red-500/5"}`,children:[s.jsxs("button",{className:"w-full px-3 py-2 flex items-center gap-3 text-left hover:bg-bambu-dark/50 transition-colors",onClick:n,children:[t.success?s.jsx(Ar,{className:"w-4 h-4 text-bambu-green shrink-0"}):s.jsx(Yi,{className:"w-4 h-4 text-red-400 shrink-0"}),s.jsx("span",{className:`text-xs font-medium ${uKe[t.event_type]||"text-bambu-gray"}`,children:cKe[t.event_type]||t.event_type}),s.jsx("span",{className:"text-sm text-white truncate flex-1",children:t.provider_name||"Unknown Provider"}),t.printer_name&&s.jsx("span",{className:"text-xs text-bambu-gray",children:t.printer_name}),s.jsx("span",{className:"text-xs text-bambu-gray shrink-0",children:r(t.created_at)}),e?s.jsx(xh,{className:"w-4 h-4 text-bambu-gray shrink-0"}):s.jsx(ei,{className:"w-4 h-4 text-bambu-gray shrink-0"})]}),e&&s.jsxs("div",{className:"px-3 py-2 border-t border-bambu-dark-tertiary bg-bambu-dark/20 space-y-2",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Title"}),s.jsx("p",{className:"text-sm text-white",children:t.title})]}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Message"}),s.jsx("p",{className:"text-sm text-white whitespace-pre-wrap",children:t.message})]}),!t.success&&t.error_message&&s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-red-400 mb-1",children:"Error"}),s.jsx("p",{className:"text-sm text-red-300",children:t.error_message})]}),s.jsxs("div",{className:"flex gap-4 text-xs text-bambu-gray pt-1",children:[s.jsxs("span",{children:["Provider: ",t.provider_type]}),s.jsxs("span",{children:["Time: ",i(t.created_at)]})]})]})]})}async function fKe(){const t=await fetch("/api/v1/settings/spoolman");if(!t.ok)throw new Error("Failed to load Spoolman settings");return t.json()}async function mKe(t){const e=await fetch("/api/v1/settings/spoolman",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!e.ok)throw new Error("Failed to save Spoolman settings");return e.json()}function pKe(){const t=an(),[e,n]=_.useState(!1),[r,i]=_.useState(""),[a,o]=_.useState("auto"),[l,c]=_.useState(!1),[u,d]=_.useState("all"),[f,p]=_.useState(!1),[m,x]=_.useState(!1),{data:b,isLoading:y}=at({queryKey:["spoolman-settings"],queryFn:fKe}),{data:v,isLoading:S,refetch:N}=at({queryKey:["spoolman-status"],queryFn:ue.getSpoolmanStatus,refetchInterval:3e4}),{data:T}=at({queryKey:["printers"],queryFn:ue.getPrinters});_.useEffect(()=>{b&&(n(b.spoolman_enabled==="true"),i(b.spoolman_url||""),o(b.spoolman_sync_mode||"auto"),p(!0))},[b]),_.useEffect(()=>{if(!f||!b)return;if(b.spoolman_enabled==="true"!==e||(b.spoolman_url||"")!==r||(b.spoolman_sync_mode||"auto")!==a){const H=setTimeout(()=>{k.mutate()},500);return()=>clearTimeout(H)}},[e,r,a,f]);const k=mt({mutationFn:()=>mKe({spoolman_enabled:e?"true":"false",spoolman_url:r,spoolman_sync_mode:a}),onSuccess:()=>{t.invalidateQueries({queryKey:["spoolman-settings"]}),t.invalidateQueries({queryKey:["spoolman-status"]}),c(!0),setTimeout(()=>c(!1),2e3)}}),C=mt({mutationFn:ue.connectSpoolman,onSuccess:()=>{N()}}),E=mt({mutationFn:ue.disconnectSpoolman,onSuccess:()=>{N()}}),D=mt({mutationFn:ue.syncAllPrintersAms,onSuccess:j=>{j.success}}),A=mt({mutationFn:j=>ue.syncPrinterAms(j),onSuccess:j=>{j.success}}),R=()=>{u==="all"?D.mutate():A.mutate(u)},U=D.isPending||A.isPending,F=u==="all"?D.data:A.data,$=u==="all"?D.isSuccess:A.isSuccess;return y?s.jsxs(_t,{children:[s.jsx(Kn,{children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Nu,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Spoolman Integration"})]})}),s.jsx(Mt,{children:s.jsx("div",{className:"flex justify-center py-8",children:s.jsx(ht,{className:"w-6 h-6 text-bambu-green animate-spin"})})})]}):s.jsxs(_t,{children:[s.jsx(Kn,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Nu,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Spoolman Integration"})]}),k.isPending&&s.jsx(ht,{className:"w-4 h-4 text-bambu-green animate-spin"}),l&&s.jsx(Ia,{className:"w-4 h-4 text-bambu-green"})]})}),s.jsxs(Mt,{className:"space-y-4",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Connect to Spoolman for filament inventory tracking. AMS data will sync automatically."}),s.jsx("div",{className:"p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg",children:s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Zo,{className:"w-4 h-4 text-blue-400 flex-shrink-0 mt-0.5"}),s.jsxs("div",{className:"text-xs text-blue-300",children:[s.jsx("p",{className:"font-medium mb-1",children:"How Sync Works"}),s.jsxs("ul",{className:"list-disc list-inside space-y-0.5 text-blue-300/80",children:[s.jsx("li",{children:"Only official Bambu Lab spools with RFID are synced"}),s.jsx("li",{children:"New spools are auto-created in Spoolman on first sync"}),s.jsx("li",{children:"Non-Bambu Lab spools (third-party, refilled) are skipped"})]}),s.jsx("p",{className:"font-medium mt-2 mb-1",children:"Linking Existing Spools"}),s.jsx("p",{className:"text-blue-300/80",children:'To link existing Spoolman spools to your AMS, hover over an AMS slot and click "Link to Spoolman".'})]})]})}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:"Enable Spoolman"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Sync filament data with Spoolman server"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:e,onChange:j=>n(j.target.checked),className:"sr-only peer"}),s.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Spoolman URL"}),s.jsx("input",{type:"text",placeholder:"http://192.168.1.100:7912",value:r,onChange:j=>i(j.target.value),disabled:!e,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray/50 focus:border-bambu-green focus:outline-none disabled:opacity-50"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"URL of your Spoolman server (e.g., http://localhost:7912)"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Sync Mode"}),s.jsxs("select",{value:a,onChange:j=>o(j.target.value),disabled:!e,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none disabled:opacity-50",children:[s.jsx("option",{value:"auto",children:"Automatic"}),s.jsx("option",{value:"manual",children:"Manual Only"})]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:a==="auto"?"AMS data syncs automatically when changes are detected":"Only sync when manually triggered"})]}),e&&s.jsxs("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-sm text-bambu-gray",children:"Status:"}),S?s.jsx(ht,{className:"w-4 h-4 text-bambu-gray animate-spin"}):v?.connected?s.jsxs("span",{className:"flex items-center gap-1 text-sm text-green-500",children:[s.jsx(Ia,{className:"w-4 h-4"}),"Connected"]}):s.jsxs("span",{className:"flex items-center gap-1 text-sm text-red-500",children:[s.jsx(Rt,{className:"w-4 h-4"}),"Disconnected"]})]}),s.jsx("div",{className:"flex gap-2",children:v?.connected?s.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>E.mutate(),disabled:E.isPending,children:[E.isPending?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(gde,{className:"w-4 h-4"}),"Disconnect"]}):s.jsxs(Te,{size:"sm",onClick:()=>C.mutate(),disabled:C.isPending||!r,children:[C.isPending?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(uc,{className:"w-4 h-4"}),"Connect"]})})]}),C.isError&&s.jsx("div",{className:"mb-3 p-2 bg-red-500/20 border border-red-500/50 rounded text-sm text-red-400",children:C.error.message}),v?.connected&&s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Sync AMS Data"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Manually sync printer AMS data to Spoolman"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsxs("select",{value:u,onChange:j=>d(j.target.value==="all"?"all":Number(j.target.value)),className:"w-full px-3 py-2 pr-8 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none appearance-none cursor-pointer",children:[s.jsx("option",{value:"all",children:"All Printers"}),T?.map(j=>s.jsx("option",{value:j.id,children:j.name},j.id))]}),s.jsx(ei,{className:"absolute right-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),s.jsxs(Te,{variant:"secondary",size:"sm",onClick:R,disabled:U,children:[U?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(Dr,{className:"w-4 h-4"}),"Sync"]})]})]}),$&&F&&s.jsxs("div",{className:"mt-3 space-y-2",children:[s.jsx("div",{className:`p-2 rounded text-sm ${F.success?"bg-green-500/20 border border-green-500/50 text-green-400":"bg-yellow-500/20 border border-yellow-500/50 text-yellow-400"}`,children:F.success?`Synced ${F.synced_count} spool${F.synced_count!==1?"s":""} successfully`:`Synced ${F.synced_count} spool${F.synced_count!==1?"s":""} with ${F.errors.length} error${F.errors.length!==1?"s":""}`}),F.skipped_count>0&&s.jsxs("div",{className:"p-2 bg-amber-500/10 border border-amber-500/30 rounded text-sm",children:[s.jsxs("div",{className:"flex items-center justify-between text-amber-400 mb-1",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(Cn,{className:"w-3.5 h-3.5"}),s.jsxs("span",{className:"font-medium",children:[F.skipped_count," spool",F.skipped_count!==1?"s":""," skipped"]})]}),F.skipped_count>5&&s.jsx("button",{onClick:()=>x(!m),className:"text-xs text-amber-400 hover:text-amber-300 underline",children:m?"Show less":"Show all"})]}),s.jsxs("ul",{className:"text-xs text-amber-300/80 space-y-0.5",children:[(m?F.skipped:F.skipped.slice(0,5)).map((j,H)=>s.jsxs("li",{className:"flex items-center gap-2",children:[j.color&&s.jsx("span",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:`#${j.color}`}}),s.jsx("span",{children:j.location}),s.jsxs("span",{className:"text-amber-300/60",children:["- ",j.reason]})]},H)),!m&&F.skipped_count>5&&s.jsxs("li",{className:"text-amber-300/60 italic",children:["...and ",F.skipped_count-5," more"]})]})]}),F.errors.length>0&&s.jsxs("div",{className:"p-2 bg-red-500/10 border border-red-500/30 rounded text-sm",children:[s.jsx("div",{className:"text-red-400 font-medium mb-1",children:"Errors:"}),s.jsx("ul",{className:"text-xs text-red-300/80 space-y-0.5",children:F.errors.map((j,H)=>s.jsx("li",{children:j},H))})]})]})]})]})]})}function gKe({link:t,onClose:e}){const n=an(),{mode:r}=Oh(),i=!!t,a=_.useRef(null),[o,l]=_.useState(t?.name||""),[c,u]=_.useState(t?.url||""),[d,f]=_.useState(t?.icon||"link"),[p,m]=_.useState(!!t?.custom_icon),[x,b]=_.useState(t?.custom_icon?ue.getExternalLinkIconUrl(t.id):null),[y,v]=_.useState(null),[S,N]=_.useState(null);_.useEffect(()=>{const U=F=>{F.key==="Escape"&&e()};return window.addEventListener("keydown",U),()=>window.removeEventListener("keydown",U)},[e]);const T=mt({mutationFn:async U=>{const F=await ue.createExternalLink(U);return y?await ue.uploadExternalLinkIcon(F.id,y):F},onSuccess:()=>{n.invalidateQueries({queryKey:["external-links"]}),e()},onError:U=>{N(U.message)}}),k=mt({mutationFn:async U=>{let F=await ue.updateExternalLink(t.id,U);return y?F=await ue.uploadExternalLinkIcon(t.id,y):!p&&t?.custom_icon&&(F=await ue.deleteExternalLinkIcon(t.id)),F},onSuccess:()=>{n.invalidateQueries({queryKey:["external-links"]}),e()},onError:U=>{N(U.message)}}),C=U=>{const F=U.target.files?.[0];if(F){if(!["image/png","image/jpeg","image/gif","image/svg+xml","image/webp","image/x-icon"].includes(F.type)){N("Please select a valid image file (PNG, JPG, GIF, SVG, WebP, or ICO)");return}if(F.size>1024*1024){N("Image file must be less than 1MB");return}v(F),m(!0);const j=new FileReader;j.onload=H=>{b(H.target?.result)},j.readAsDataURL(F)}},E=()=>{v(null),b(null),m(!1),a.current&&(a.current.value="")},D=U=>{if(U.preventDefault(),N(null),!o.trim()){N("Name is required");return}if(!c.trim()){N("URL is required");return}if(!c.startsWith("http://")&&!c.startsWith("https://")){N("URL must start with http:// or https://");return}const F={name:o.trim(),url:c.trim(),icon:d};i?k.mutate(F):T.mutate(F)},A=T.isPending||k.isPending,R=yN(d);return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-md",onClick:U=>U.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2 rounded-full bg-bambu-green/20 text-bambu-green",children:p&&x?s.jsx("img",{src:x,alt:"",className:`w-5 h-5 rounded ${r==="dark"?"invert opacity-[0.65]":"opacity-60"}`}):s.jsx(R,{className:"w-5 h-5"})}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:i?"Edit Link":"Add External Link"})]}),s.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(Rt,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:D,className:"p-6 space-y-4",children:[S&&s.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:S}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),s.jsx("input",{type:"text",value:o,onChange:U=>l(U.target.value),placeholder:"My Link",maxLength:50,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"URL *"}),s.jsx("input",{type:"text",value:c,onChange:U=>u(U.target.value),placeholder:"https://example.com",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsx("label",{className:"block text-sm text-bambu-gray",children:"Icon"}),s.jsxs("div",{className:"p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("span",{className:"text-sm text-white",children:"Custom Icon"}),s.jsx("input",{ref:a,type:"file",accept:"image/png,image/jpeg,image/gif,image/svg+xml,image/webp,image/x-icon",className:"hidden",onChange:C}),p&&x?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("img",{src:x,alt:"Custom icon",className:`w-8 h-8 rounded border border-bambu-dark-tertiary ${r==="dark"?"invert opacity-[0.65]":"opacity-60"}`}),s.jsx("button",{type:"button",onClick:E,className:"p-1 text-red-400 hover:text-red-300 transition-colors",title:"Remove custom icon",children:s.jsx(rn,{className:"w-4 h-4"})})]}):s.jsxs(Te,{type:"button",variant:"secondary",size:"sm",onClick:()=>a.current?.click(),children:[s.jsx(Ua,{className:"w-4 h-4"}),"Upload"]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"PNG, JPG, GIF, SVG, WebP, or ICO. Max 1MB."})]}),!p&&s.jsxs("div",{children:[s.jsx("span",{className:"text-sm text-bambu-gray block mb-2",children:"Or choose a preset icon"}),s.jsx(Mfe,{value:d,onChange:f})]})]}),s.jsxs("div",{className:"flex gap-3 pt-2",children:[s.jsx(Te,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),s.jsxs(Te,{type:"submit",disabled:A,className:"flex-1",children:[A?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(hs,{className:"w-4 h-4"}),i?"Save":"Add"]})]})]})]})})}function xKe(){const t=an(),[e,n]=_.useState(!1),[r,i]=_.useState(null),[a,o]=_.useState(null),[l,c]=_.useState(null),{data:u,isLoading:d}=at({queryKey:["external-links"],queryFn:ue.getExternalLinks}),f=mt({mutationFn:S=>ue.deleteExternalLink(S),onSuccess:()=>{t.invalidateQueries({queryKey:["external-links"]})}}),p=mt({mutationFn:S=>ue.reorderExternalLinks(S),onSuccess:()=>{t.invalidateQueries({queryKey:["external-links"]})}}),m=(S,N)=>{c(N),S.dataTransfer.effectAllowed="move"},x=S=>{S.preventDefault(),S.dataTransfer.dropEffect="move"},b=(S,N)=>{if(S.preventDefault(),l===null||l===N||!u)return;const T=u.map(D=>D.id),k=T.indexOf(l),C=T.indexOf(N);if(k===-1||C===-1)return;const E=[...T];E.splice(k,1),E.splice(C,0,l),p.mutate(E),c(null)},y=S=>{o(S)},v=()=>{a&&(f.mutate(a.id),o(null))};return s.jsxs(s.Fragment,{children:[s.jsxs(_t,{children:[s.jsx(Kn,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(uc,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Sidebar Links"})]}),s.jsxs(Te,{size:"sm",onClick:()=>n(!0),children:[s.jsx(dr,{className:"w-4 h-4"}),"Add Link"]})]})}),s.jsxs(Mt,{children:[s.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:"Add external links to the sidebar navigation. Drag to reorder."}),d?s.jsx("div",{className:"flex justify-center py-8",children:s.jsx(ht,{className:"w-6 h-6 text-bambu-green animate-spin"})}):u&&u.length>0?s.jsx("div",{className:"space-y-2",children:u.map(S=>{const N=yN(S.icon);return s.jsxs("div",{draggable:!0,onDragStart:T=>m(T,S.id),onDragOver:x,onDrop:T=>b(T,S.id),className:`flex items-center gap-3 p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary transition-colors ${l===S.id?"opacity-50":""}`,children:[s.jsx(zg,{className:"w-6 h-6 md:w-4 md:h-4 text-bambu-gray cursor-grab flex-shrink-0"}),s.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark-tertiary text-bambu-gray",children:s.jsx(N,{className:"w-4 h-4"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-white font-medium truncate",children:S.name}),s.jsx(Kr,{className:"w-3 h-3 text-bambu-gray flex-shrink-0"})]}),s.jsx("span",{className:"text-sm text-bambu-gray truncate block",children:S.url})]}),s.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[s.jsx("button",{onClick:()=>i(S),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white transition-colors",title:"Edit",children:s.jsx(Qi,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>y(S),disabled:f.isPending,className:"p-2 rounded-lg hover:bg-red-500/20 text-bambu-gray hover:text-red-400 transition-colors disabled:opacity-50",title:"Delete",children:s.jsx(rn,{className:"w-4 h-4"})})]})]},S.id)})}):s.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[s.jsx(uc,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),s.jsx("p",{children:"No external links configured"}),s.jsx("p",{className:"text-sm",children:'Click "Add Link" to add one'})]})]})]}),(e||r)&&s.jsx(gKe,{link:r,onClose:()=>{n(!1),i(null)}}),a&&s.jsx(Zn,{title:"Delete Link",message:`Are you sure you want to delete "${a.name}"? This action cannot be undone.`,confirmText:"Delete",cancelText:"Cancel",variant:"danger",onConfirm:v,onCancel:()=>o(null)})]})}function bKe(){const t=an(),{showToast:e}=$n(),[n,r]=_.useState(!1),[i,a]=_.useState(""),[o,l]=_.useState("immediate"),[c,u]=_.useState("3DPrinter-X1-Carbon"),[d,f]=_.useState(!1),[p,m]=_.useState(null),{data:x,isLoading:b}=at({queryKey:["virtual-printer-settings"],queryFn:p1.getSettings,refetchInterval:1e4}),{data:y}=at({queryKey:["virtual-printer-models"],queryFn:p1.getModels});_.useEffect(()=>{if(x){r(x.enabled);let D=x.mode==="queue"?"review":x.mode;D!=="immediate"&&D!=="review"&&D!=="print_queue"&&(D="immediate"),l(D),u(x.model)}},[x]);const v=mt({mutationFn:D=>p1.updateSettings(D),onSuccess:()=>{t.invalidateQueries({queryKey:["virtual-printer-settings"]}),e("Virtual printer settings updated"),m(null)},onError:D=>{if(e(D.message||"Failed to update settings","error"),x){r(x.enabled);const A=x.mode==="queue"?"review":x.mode;l(A==="print_queue"||A==="review"?A:"immediate"),u(x.model)}m(null)}}),S=()=>{const D=!n;if(D&&!i&&!x?.access_code_set){e("Please set an access code first","error");return}r(D),m("toggle"),v.mutate({enabled:D,access_code:i||void 0,mode:o})},N=()=>{if(!i){e("Access code cannot be empty","error");return}if(i.length!==8){e("Access code must be exactly 8 characters","error");return}m("accessCode"),v.mutate({access_code:i}),a("")},T=D=>{l(D),m("mode"),v.mutate({mode:D})},k=D=>{u(D),m("model"),v.mutate({model:D})};if(b)return s.jsx(_t,{children:s.jsx(Mt,{className:"py-8 flex justify-center",children:s.jsx(ht,{className:"w-6 h-6 animate-spin text-bambu-green"})})});const C=x?.status,E=C?.running||!1;return s.jsxs("div",{className:"flex flex-col lg:flex-row gap-6 lg:gap-8",children:[s.jsx("div",{className:"space-y-6 lg:w-[480px] lg:flex-shrink-0",children:s.jsxs(_t,{children:[s.jsx(Kn,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ur,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Virtual Printer"})]}),C&&s.jsxs("div",{className:`flex items-center gap-2 text-sm ${E?"text-green-400":"text-bambu-gray"}`,children:[s.jsx("span",{className:`w-2 h-2 rounded-full ${E?"bg-green-400 animate-pulse":"bg-gray-500"}`}),E?"Running":"Stopped"]})]})}),s.jsxs(Mt,{className:"space-y-4",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Enable a virtual printer that appears in Bambu Studio and OrcaSlicer. Files sent to this printer will be archived directly without printing."}),s.jsxs("div",{className:"flex items-center justify-between py-3 border-t border-bambu-dark-tertiary",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-white font-medium",children:"Enable Virtual Printer"}),s.jsx("div",{className:"text-sm text-bambu-gray",children:E?'Visible as "Bambuddy" in slicer discovery':"Not visible to slicers"})]}),s.jsx("button",{onClick:S,disabled:p==="toggle",className:`relative w-12 h-6 rounded-full transition-colors ${n?"bg-bambu-green":"bg-bambu-dark-tertiary"} ${p==="toggle"?"opacity-50":""}`,children:s.jsx("span",{className:`absolute top-1 left-1 w-4 h-4 bg-white rounded-full transition-transform ${n?"translate-x-6":""}`})})]}),s.jsxs("div",{className:"py-3 border-t border-bambu-dark-tertiary",children:[s.jsx("div",{className:"text-white font-medium mb-2",children:"Printer Model"}),s.jsx("div",{className:"text-sm text-bambu-gray mb-3",children:"Select which printer model to emulate."}),s.jsxs("div",{className:"relative",children:[s.jsx("select",{value:c,onChange:D=>k(D.target.value),disabled:p==="model",className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-2 text-white appearance-none cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed pr-10",children:y?.models&&Object.entries(y.models).sort(([,D],[,A])=>D.localeCompare(A)).map(([D,A])=>s.jsx("option",{value:D,children:A},D))}),s.jsx(ei,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),n&&E&&s.jsxs("p",{className:"text-xs text-bambu-gray mt-2",children:[s.jsx(Zo,{className:"w-3 h-3 inline mr-1"}),"Changing the model will restart the virtual printer"]})]}),s.jsxs("div",{className:"py-3 border-t border-bambu-dark-tertiary",children:[s.jsx("div",{className:"text-white font-medium mb-2",children:"Access Code"}),s.jsx("div",{className:"text-sm text-bambu-gray mb-3",children:x?.access_code_set?s.jsxs("span",{className:"flex items-center gap-1 text-green-400",children:[s.jsx(Ia,{className:"w-4 h-4"}),"Access code is set"]}):s.jsxs("span",{className:"flex items-center gap-1 text-yellow-400",children:[s.jsx(Cn,{className:"w-4 h-4"}),"No access code set - required to enable"]})}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsx("input",{type:d?"text":"password",value:i,onChange:D=>a(D.target.value),placeholder:x?.access_code_set?"Enter new code to change":"Enter 8-char code",maxLength:8,className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-2 text-white placeholder-bambu-gray pr-10 font-mono"}),s.jsx("button",{onClick:()=>f(!d),className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",children:d?s.jsx(lN,{className:"w-4 h-4"}):s.jsx(Ru,{className:"w-4 h-4"})})]}),s.jsx(Te,{onClick:N,disabled:!i||p==="accessCode",variant:"primary",children:p==="accessCode"?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):"Save"})]}),s.jsxs("p",{className:"text-xs text-bambu-gray mt-2",children:["Must be exactly 8 characters. Used by slicers to authenticate.",i&&s.jsxs("span",{className:i.length===8?"text-green-400":"text-yellow-400",children:[" ","(",i.length,"/8)"]})]})]}),s.jsxs("div",{className:"py-3 border-t border-bambu-dark-tertiary",children:[s.jsx("div",{className:"text-white font-medium mb-2",children:"Mode"}),s.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[s.jsxs("button",{onClick:()=>T("immediate"),disabled:p==="mode",className:`p-3 rounded-lg border text-left transition-colors ${o==="immediate"?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:[s.jsx("div",{className:"text-white font-medium",children:"Archive"}),s.jsx("div",{className:"text-xs text-bambu-gray",children:"Archive files immediately"})]}),s.jsxs("button",{onClick:()=>T("review"),disabled:p==="mode",className:`p-3 rounded-lg border text-left transition-colors ${o==="review"?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:[s.jsx("div",{className:"text-white font-medium",children:"Review"}),s.jsx("div",{className:"text-xs text-bambu-gray",children:"Review and tag before archiving"})]}),s.jsxs("button",{onClick:()=>T("print_queue"),disabled:p==="mode",className:`p-3 rounded-lg border text-left transition-colors ${o==="print_queue"?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:[s.jsx("div",{className:"text-white font-medium",children:"Queue"}),s.jsx("div",{className:"text-xs text-bambu-gray",children:"Archive and add to print queue"})]})]})]})]})]})}),s.jsxs("div",{className:"space-y-6 lg:w-[480px] lg:flex-shrink-0",children:[s.jsx(_t,{className:"border-l-4 border-l-yellow-500",children:s.jsx(Mt,{className:"py-4",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(Cn,{className:"w-5 h-5 text-yellow-500 flex-shrink-0 mt-0.5"}),s.jsxs("div",{className:"text-sm",children:[s.jsx("p",{className:"text-white font-medium mb-2",children:"Setup Required"}),s.jsx("p",{className:"text-bambu-gray mb-3",children:"The virtual printer feature requires additional system configuration before it will work. This includes port forwarding, firewall rules, and platform-specific settings."}),s.jsxs("a",{href:"https://wiki.bambuddy.cool/features/virtual-printer/",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 px-4 py-2 bg-yellow-500/20 border border-yellow-500/50 rounded-md text-yellow-400 hover:bg-yellow-500/30 transition-colors",children:[s.jsx(Kr,{className:"w-4 h-4"}),"Read the setup guide before enabling"]})]})]})})}),s.jsx(_t,{children:s.jsx(Mt,{className:"py-4",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(Zo,{className:"w-5 h-5 text-blue-400 flex-shrink-0 mt-0.5"}),s.jsxs("div",{className:"text-sm text-bambu-gray",children:[s.jsx("p",{className:"mb-2",children:s.jsx("strong",{className:"text-white",children:"How it works:"})}),s.jsxs("ol",{className:"list-decimal list-inside space-y-1",children:[s.jsx("li",{children:"Complete the setup guide for your platform"}),s.jsx("li",{children:"Enable the virtual printer and set an access code"}),s.jsx("li",{children:'In Bambu Studio or OrcaSlicer, go to "Add Printer"'}),s.jsx("li",{children:'The "Bambuddy" printer should appear in the discovery list'}),s.jsx("li",{children:"Connect using the access code you set"}),s.jsx("li",{children:'When you "print" to Bambuddy, the 3MF file is archived instead'})]})]})]})})}),C&&E&&s.jsxs(_t,{children:[s.jsx(Kn,{children:s.jsx("h3",{className:"text-md font-semibold text-white",children:"Status Details"})}),s.jsx(Mt,{children:s.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-bambu-gray",children:"Printer Name"}),s.jsx("div",{className:"text-white",children:C.name})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-bambu-gray",children:"Model"}),s.jsx("div",{className:"text-white",children:C.model_name||C.model})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-bambu-gray",children:"Serial Number"}),s.jsx("div",{className:"text-white font-mono",children:C.serial})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-bambu-gray",children:"Mode"}),s.jsx("div",{className:"text-white capitalize",children:C.mode})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-bambu-gray",children:"Pending Files"}),s.jsx("div",{className:"text-white",children:C.pending_files})]})]})})]})]})]})}function fq({status:t}){if(!t)return null;const e={success:"bg-green-500/20 text-green-400",failed:"bg-red-500/20 text-red-400",skipped:"bg-yellow-500/20 text-yellow-400",running:"bg-blue-500/20 text-blue-400"},n={success:s.jsx(Ar,{className:"w-3 h-3"}),failed:s.jsx(Yi,{className:"w-3 h-3"}),skipped:s.jsx(DR,{className:"w-3 h-3"}),running:s.jsx(ht,{className:"w-3 h-3 animate-spin"})};return s.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded text-xs font-medium ${e[t]||"bg-gray-500/20 text-gray-400"}`,children:[n[t],t.charAt(0).toUpperCase()+t.slice(1)]})}function yKe(t){return t?new Date(t).toLocaleString():"-"}function mq(t){if(!t)return"-";const e=new Date(t),n=new Date,r=e.getTime()-n.getTime(),i=Math.round(r/6e4);if(i<0){const a=Math.abs(i);if(a<60)return`${a}m ago`;const o=Math.floor(a/60);return o<24?`${o}h ago`:`${Math.floor(o/24)}d ago`}else{if(i<60)return`in ${i}m`;const a=Math.floor(i/60);return a<24?`in ${a}h`:`in ${Math.floor(a/24)}d`}}function vKe(){const t=an(),{showToast:e}=$n(),[n,r]=_.useState(""),[i,a]=_.useState(""),[o,l]=_.useState("main"),[c,u]=_.useState(!1),[d,f]=_.useState("daily"),[p,m]=_.useState(!0),[x,b]=_.useState(!0),[y,v]=_.useState(!1),[S,N]=_.useState(!0),[T,k]=_.useState(!1),[C,E]=_.useState(!1),[D,A]=_.useState(""),[R,U]=_.useState(!1),[F,$]=_.useState(null),[j,H]=_.useState(null),K=_.useRef(null);_.useEffect(()=>{if(T||C){const Ee=z=>(z.preventDefault(),z.returnValue="A backup operation is in progress. Are you sure you want to leave?",z.returnValue);return window.addEventListener("beforeunload",Ee),()=>window.removeEventListener("beforeunload",Ee)}},[T,C]);const[V,Q]=_.useState(!1),[Z,ae]=_.useState(null),B=_.useRef(null),X=_.useRef(!1),{data:ne,isLoading:se}=at({queryKey:["github-backup-config"],queryFn:ue.getGitHubBackupConfig}),{data:be}=at({queryKey:["github-backup-status"],queryFn:ue.getGitHubBackupStatus,refetchInterval:me=>me.state.data?.is_running?500:1e4}),{data:xe}=at({queryKey:["github-backup-logs"],queryFn:()=>ue.getGitHubBackupLogs(20)}),{data:de}=at({queryKey:["cloud-status"],queryFn:ue.getCloudStatus}),{data:Pe}=at({queryKey:["printers"],queryFn:ue.getPrinters}),ie=dW({queries:(Pe??[]).map(me=>({queryKey:["printerStatus",me.id],queryFn:()=>ue.getPrinterStatus(me.id),staleTime:1e4,refetchInterval:3e4}))}),Ne=(Pe??[]).map((me,Ee)=>({printer:me,connected:ie[Ee]?.data?.connected??!1})),Oe=Ne.length,ge=Ne.filter(me=>me.connected).length,Ke=Oe>0&&ge===0,G=ge>0&&ge<Oe;_.useEffect(()=>{ne&&(r(ne.repository_url),l(ne.branch),u(ne.schedule_enabled),f(ne.schedule_type),m(ne.backup_kprofiles),b(ne.backup_cloud_profiles),v(ne.backup_settings),N(ne.enabled),a(""),setTimeout(()=>{X.current=!0},100))},[ne]);const Y=_.useCallback(async(me=!1)=>{if(ne?.has_token)try{me&&i?(await ue.saveGitHubBackupConfig({repository_url:n,access_token:i,branch:o,schedule_enabled:c,schedule_type:d,backup_kprofiles:p,backup_cloud_profiles:x,backup_settings:y,enabled:S}),a(""),e("Token updated")):(await ue.updateGitHubBackupConfig({repository_url:n,branch:o,schedule_enabled:c,schedule_type:d,backup_kprofiles:p,backup_cloud_profiles:x,backup_settings:y,enabled:S}),e("Settings saved")),t.invalidateQueries({queryKey:["github-backup-config"]}),t.invalidateQueries({queryKey:["github-backup-status"]})}catch(Ee){e(`Failed to save: ${Ee.message}`,"error")}},[ne?.has_token,n,i,o,c,d,p,x,y,S,t,e]);_.useEffect(()=>{if(!(!X.current||!ne?.has_token))return B.current&&clearTimeout(B.current),B.current=setTimeout(()=>{Y(!1)},500),()=>{B.current&&clearTimeout(B.current)}},[n,o,c,d,p,x,y,S,Y,ne?.has_token]),_.useEffect(()=>{if(!(!X.current||!ne?.has_token||!i))return B.current&&clearTimeout(B.current),B.current=setTimeout(()=>{Y(!0)},1e3),()=>{B.current&&clearTimeout(B.current)}},[i,Y,ne?.has_token]);const ce=mt({mutationFn:me=>ue.saveGitHubBackupConfig(me),onSuccess:()=>{t.invalidateQueries({queryKey:["github-backup-config"]}),t.invalidateQueries({queryKey:["github-backup-status"]}),e("GitHub backup enabled"),a(""),X.current=!0},onError:me=>{e(`Failed to save: ${me.message}`,"error")}}),q=mt({mutationFn:ue.triggerGitHubBackup,onSuccess:me=>{t.invalidateQueries({queryKey:["github-backup-status"]}),t.invalidateQueries({queryKey:["github-backup-logs"]}),me.success?me.files_changed>0?e(`Backup complete - ${me.files_changed} files updated`):e("Backup skipped - no changes"):e(`Backup failed: ${me.message}`,"error")},onError:me=>{e(`Backup failed: ${me.message}`,"error")}}),te=mt({mutationFn:()=>ue.clearGitHubBackupLogs(0),onSuccess:me=>{t.invalidateQueries({queryKey:["github-backup-logs"]}),e(`Cleared ${me.deleted} logs`)},onError:me=>{e(`Failed to clear logs: ${me.message}`,"error")}}),I=async()=>{Q(!0),ae(null);try{let me;if(i){if(!n){e("Enter repository URL","error"),Q(!1);return}me=await ue.testGitHubConnection(n,i)}else if(ne?.has_token)me=await ue.testGitHubStoredConnection();else{e("Enter repository URL and access token","error"),Q(!1);return}ae({success:me.success,message:me.message})}catch(me){ae({success:!1,message:me.message})}finally{Q(!1)}},fe=()=>{if(!n){e("Repository URL is required","error");return}if(!i){e("Access token is required","error");return}ce.mutate({repository_url:n,access_token:i,branch:o,schedule_enabled:c,schedule_type:d,backup_kprofiles:p,backup_cloud_profiles:x,backup_settings:y,enabled:S})};return se?s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx(ht,{className:"w-8 h-8 animate-spin text-bambu-green"})}):s.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[s.jsxs("div",{className:"space-y-6",children:[s.jsxs(_t,{children:[s.jsx(Kn,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(fP,{className:"w-5 h-5 text-gray-400"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"GitHub Backup"})]}),ne&&de?.is_authenticated&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-sm text-bambu-gray",children:"Enabled"}),s.jsx(On,{checked:S,onChange:N})]})]})}),s.jsx(Mt,{className:"space-y-4",children:de?.is_authenticated?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically sync your profiles to a private GitHub repository for backup and version history."}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Repository URL"}),s.jsx("input",{type:"text",value:n,onChange:me=>{r(me.target.value),ae(null)},placeholder:"https://github.com/username/bambuddy-backup",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:["Personal Access Token ",ne?.has_token&&s.jsx("span",{className:"text-green-400",children:"(saved)"})]}),s.jsx("input",{type:"password",value:i,onChange:me=>{a(me.target.value),ae(null)},placeholder:ne?.has_token?"Enter new token to update":"ghp_xxxxxxxxxxxx",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Fine-grained token with Contents read/write permission"})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Branch"}),s.jsx("input",{type:"text",value:o,onChange:me=>l(me.target.value),placeholder:"main",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Auto-backup"}),s.jsxs("select",{value:c?d:"disabled",onChange:me=>{me.target.value==="disabled"?u(!1):(u(!0),f(me.target.value))},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"disabled",children:"Manual only"}),s.jsx("option",{value:"hourly",children:"Hourly"}),s.jsx("option",{value:"daily",children:"Daily"}),s.jsx("option",{value:"weekly",children:"Weekly"})]})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"Include in backup"}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("label",{className:`flex items-start gap-2 ${Ke?"cursor-not-allowed opacity-60":"cursor-pointer"}`,children:[s.jsx("input",{type:"checkbox",checked:p,onChange:me=>m(me.target.checked),className:"w-4 h-4 mt-0.5 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green",disabled:Ke}),s.jsxs("div",{className:"flex-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`text-sm ${Ke?"text-bambu-gray":"text-white"}`,children:"K-Profiles"}),Ke&&s.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-xs bg-yellow-500/20 text-yellow-400",children:[s.jsx(Cn,{className:"w-3 h-3"}),"No printers connected"]}),G&&s.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-xs bg-yellow-500/20 text-yellow-400",children:[s.jsx(Cn,{className:"w-3 h-3"}),ge,"/",Oe," connected"]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Pressure advance calibration from connected printers"})]})]}),s.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:x,onChange:me=>b(me.target.checked),className:"w-4 h-4 mt-0.5 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green",disabled:!de?.is_authenticated}),s.jsxs("div",{children:[s.jsx("span",{className:`text-sm ${de?.is_authenticated?"text-white":"text-bambu-gray"}`,children:"Cloud Profiles"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Filament, printer, and process presets from Bambu Cloud"})]})]}),s.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:y,onChange:me=>v(me.target.checked),className:"w-4 h-4 mt-0.5 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),s.jsxs("div",{children:[s.jsx("span",{className:"text-white text-sm",children:"App Settings"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Bambuddy configuration (excludes sensitive data)"})]})]})]})]}),s.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4 space-y-3",children:[be?.configured&&s.jsxs("div",{className:"flex items-center justify-between text-sm",children:[s.jsx("div",{className:"flex items-center gap-2 text-bambu-gray",children:be.last_backup_at?s.jsxs(s.Fragment,{children:[s.jsxs("span",{children:["Last backup: ",mq(be.last_backup_at)]}),s.jsx(fq,{status:be.last_backup_status})]}):s.jsx("span",{children:"No backups yet"})}),be.next_scheduled_run&&s.jsxs("span",{className:"text-bambu-gray",children:[s.jsx(er,{className:"w-3 h-3 inline mr-1"}),"Next: ",mq(be.next_scheduled_run)]})]}),Z&&s.jsxs("div",{className:`text-sm flex items-center gap-1 ${Z.success?"text-green-400":"text-red-400"}`,children:[Z.success?s.jsx(Ar,{className:"w-4 h-4"}):s.jsx(Yi,{className:"w-4 h-4"}),Z.message]}),s.jsx("div",{className:"flex flex-wrap items-center gap-2",children:be?.configured?s.jsx(s.Fragment,{children:q.isPending||be.is_running?s.jsxs("div",{className:"flex items-center gap-2 text-bambu-green",children:[s.jsx(ht,{className:"w-4 h-4 animate-spin"}),s.jsx("span",{className:"text-sm",children:be.progress||"Starting backup..."})]}):s.jsxs(s.Fragment,{children:[s.jsxs(Te,{variant:"primary",size:"sm",onClick:()=>q.mutate(),disabled:!ne?.enabled,children:[s.jsx(Is,{className:"w-4 h-4"}),"Backup Now"]}),s.jsxs(Te,{variant:"secondary",size:"sm",onClick:I,disabled:V,children:[V?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(Dr,{className:"w-4 h-4"}),"Test"]})]})}):s.jsxs(s.Fragment,{children:[s.jsxs(Te,{variant:"primary",size:"sm",onClick:fe,disabled:ce.isPending||!n||!i,children:[ce.isPending?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(Ar,{className:"w-4 h-4"}),"Enable Backup"]}),s.jsxs(Te,{variant:"secondary",size:"sm",onClick:I,disabled:V||!n||!i,children:[V?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(Dr,{className:"w-4 h-4"}),"Test Connection"]})]})})]})]}):s.jsxs("div",{className:"flex items-start gap-2 p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[s.jsx(Cn,{className:"w-4 h-4 text-yellow-400 mt-0.5 flex-shrink-0"}),s.jsx("p",{className:"text-sm text-yellow-400",children:"Bambu Cloud login required. Sign in under Profiles → Cloud Profiles to enable GitHub backup."})]})})]}),xe&&xe.length>0&&s.jsxs(_t,{children:[s.jsx(Kn,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(q0,{className:"w-5 h-5 text-gray-400"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"History"})]}),s.jsxs(Te,{variant:"ghost",size:"sm",onClick:()=>te.mutate(),disabled:te.isPending,children:[s.jsx(rn,{className:"w-4 h-4"}),"Clear"]})]})}),s.jsx(Mt,{children:s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"text-bambu-gray border-b border-bambu-dark-tertiary",children:[s.jsx("th",{className:"text-left py-2 px-2",children:"Date"}),s.jsx("th",{className:"text-left py-2 px-2",children:"Status"}),s.jsx("th",{className:"text-left py-2 px-2",children:"Commit"})]})}),s.jsx("tbody",{children:xe.slice(0,10).map(me=>s.jsxs("tr",{className:"border-b border-bambu-dark-tertiary/50 hover:bg-bambu-dark-secondary",children:[s.jsx("td",{className:"py-2 px-2 text-white",children:yKe(me.started_at)}),s.jsx("td",{className:"py-2 px-2",children:s.jsx(fq,{status:me.status})}),s.jsx("td",{className:"py-2 px-2",children:me.commit_sha?s.jsxs("a",{href:`${ne?.repository_url}/commit/${me.commit_sha}`,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-green hover:underline inline-flex items-center gap-1",children:[me.commit_sha.substring(0,7),s.jsx(Kr,{className:"w-3 h-3"})]}):s.jsx("span",{className:"text-bambu-gray",children:"-"})})]},me.id))})]})})})]})]}),s.jsx("div",{className:"space-y-6",children:s.jsxs(_t,{children:[s.jsx(Kn,{children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Nu,{className:"w-5 h-5 text-gray-400"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Local Backup"})]})}),s.jsxs(Mt,{className:"space-y-4",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Create a complete backup of your Bambuddy data including the database, archives, uploads, and all files."}),s.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:"Download Backup"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Complete backup: database + all files (ZIP)"})]}),s.jsxs(Te,{variant:"secondary",size:"sm",disabled:T||C,onClick:async()=>{k(!0),A("Preparing backup...");try{A("Creating backup archive... This may take a while for large archives.");const{blob:me,filename:Ee}=await ue.exportBackup();A("Downloading backup file...");const z=URL.createObjectURL(me),O=document.createElement("a");O.href=z,O.download=Ee,O.click(),URL.revokeObjectURL(z),e("Backup downloaded successfully")}catch(me){e(`Failed to create backup: ${me instanceof Error?me.message:"Unknown error"}`,"error")}finally{k(!1),A("")}},children:[s.jsx(yi,{className:"w-4 h-4"}),"Download"]})]}),s.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:"Restore Backup"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Replace all data from a backup file"})]}),s.jsx("input",{ref:K,type:"file",accept:".zip",className:"hidden",onChange:me=>{const Ee=me.target.files?.[0];Ee&&($(Ee),U(!0)),me.target.value=""}}),s.jsxs(Te,{variant:"secondary",size:"sm",disabled:C||T,onClick:()=>K.current?.click(),children:[s.jsx(Ua,{className:"w-4 h-4"}),"Restore"]})]}),j&&s.jsx("div",{className:`p-3 rounded-lg ${j.success?"bg-green-500/10 border border-green-500/30":"bg-red-500/10 border border-red-500/30"}`,children:s.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[j.success?s.jsx(Ar,{className:"w-4 h-4 text-green-400 mt-0.5 flex-shrink-0"}):s.jsx(Yi,{className:"w-4 h-4 text-red-400 mt-0.5 flex-shrink-0"}),s.jsxs("div",{className:j.success?"text-green-200":"text-red-200",children:[j.message,j.success&&s.jsx("div",{className:"mt-2",children:s.jsxs(Te,{size:"sm",onClick:()=>window.location.reload(),children:[s.jsx(Rh,{className:"w-3 h-3"}),"Reload Now"]})})]})]})}),s.jsx("div",{className:"p-3 rounded-lg bg-yellow-500/10 border border-yellow-500/30",children:s.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[s.jsx(Cn,{className:"w-4 h-4 text-yellow-400 mt-0.5 flex-shrink-0"}),s.jsxs("div",{className:"text-yellow-200",children:[s.jsx("span",{className:"font-medium",children:"Restore replaces all data."})," ",s.jsx("span",{className:"text-yellow-200/70",children:"Your current database and files will be completely replaced. A restart is required after restore."})]})]})})]})]})}),R&&F&&s.jsx(Zn,{title:"Restore Backup",message:`Are you sure you want to restore from "${F.name}"? This will completely replace your current database and all files. The application will need to be restarted after restore.`,confirmText:"Restore Backup",variant:"danger",onConfirm:async()=>{U(!1),E(!0),H(null);try{A("Uploading backup file...");const me=await ue.importBackup(F);H(me),me.success?e("Backup restored. Please restart Bambuddy.","success"):e(me.message,"error")}catch(me){const Ee=me instanceof Error?me.message:"Failed to restore backup";H({success:!1,message:Ee}),e(Ee,"error")}finally{E(!1),A(""),$(null)}},onCancel:()=>{U(!1),$(null)}}),(T||C)&&s.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-[100]",children:s.jsxs("div",{className:"bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl p-8 max-w-md w-full mx-4 text-center",children:[s.jsx("div",{className:"flex justify-center mb-4",children:s.jsxs("div",{className:"relative",children:[s.jsx("div",{className:"w-16 h-16 border-4 border-bambu-dark-tertiary rounded-full"}),s.jsx("div",{className:"w-16 h-16 border-4 border-bambu-green border-t-transparent rounded-full absolute inset-0 animate-spin"})]})}),s.jsx("h3",{className:"text-xl font-semibold text-white mb-2",children:T?"Creating Backup":"Restoring Backup"}),s.jsx("p",{className:"text-bambu-gray mb-4",children:D||(T?"Preparing...":"Processing...")}),s.jsx("div",{className:"p-3 rounded-lg bg-yellow-500/10 border border-yellow-500/30",children:s.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[s.jsx(Cn,{className:"w-4 h-4 text-yellow-400 mt-0.5 flex-shrink-0"}),s.jsx("p",{className:"text-yellow-200 text-left",children:"Please do not close this page or navigate away. This operation may take several minutes for large backups."})]})})]})})]})}const wKe={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 _Ke(t,e){const n=e.replace("#/","").split("/");let r=t;for(const i of n)r=r[i];return r}function p0(t,e,n=0){if(n>5)return"...";if(e.$ref)return p0(t,_Ke(t,e.$ref),n+1);if(e.allOf){const r={};for(const i of e.allOf){const a=p0(t,i,n+1);typeof a=="object"&&a!==null&&Object.assign(r,a)}return r}if(e.example!==void 0)return e.example;if(e.default!==void 0)return e.default;switch(e.type){case"string":return e.enum?e.enum[0]:"string";case"integer":case"number":return 0;case"boolean":return!1;case"array":return e.items?[p0(t,e.items,n+1)]:[];case"object":if(e.properties){const r={};for(const[i,a]of Object.entries(e.properties))r[i]=p0(t,a,n+1);return r}return{};default:return null}}function SKe({path:t,method:e,spec:n,schema:r,apiKey:i}){const[a,o]=_.useState(!1),[l,c]=_.useState({}),[u,d]=_.useState(""),[f,p]=_.useState(null),[m,x]=_.useState(!1),[b,y]=_.useState(!1);_.useEffect(()=>{if(a&&n.parameters){const D={};for(const A of n.parameters)A.schema?.default!==void 0&&(D[A.name]=String(A.schema.default));c(A=>({...D,...A}))}},[a,n.parameters]),_.useEffect(()=>{if(a&&n.requestBody?.content?.["application/json"]?.schema&&!u){const D=n.requestBody.content["application/json"].schema,A=p0(r,D);d(JSON.stringify(A,null,2))}},[a,n.requestBody,r,u]);const S=(()=>{const D=[];for(const A of n.parameters||[])if(A.in==="path"||A.required){const R=l[A.name];(R===void 0||R==="")&&D.push(A.name)}return D})(),N=async()=>{if(S.length>0){p({status:0,statusText:"Validation Error",headers:{},body:`Missing required parameters: ${S.join(", ")}`,duration:0});return}x(!0),p(null);try{let D=t;const A=new URLSearchParams;for(const ae of n.parameters||[]){const B=l[ae.name];B!==void 0&&B!==""&&(ae.in==="path"?D=D.replace(`{${ae.name}}`,encodeURIComponent(B)):ae.in==="query"&&A.append(ae.name,B))}const R=A.toString(),U=`${D}${R?`?${R}`:""}`,F={"Content-Type":"application/json"};i&&(F["X-API-Key"]=i);const $={method:e.toUpperCase(),headers:F};["post","put","patch"].includes(e)&&u&&($.body=u);const j=performance.now(),H=await fetch(U,$),K=Math.round(performance.now()-j),V={};H.headers.forEach((ae,B)=>{V[B]=ae});let Q;H.headers.get("content-type")?.includes("application/json")?Q=await H.json():Q=await H.text(),p({status:H.status,statusText:H.statusText,headers:V,body:Q,duration:K})}catch(D){p({status:0,statusText:"Network Error",headers:{},body:D instanceof Error?D.message:"Unknown error",duration:0})}finally{x(!1)}},T=async()=>{if(f){const D=typeof f.body=="string"?f.body:JSON.stringify(f.body,null,2);try{await navigator.clipboard.writeText(D),y(!0),setTimeout(()=>y(!1),2e3)}catch{const A=document.createElement("textarea");A.value=D,A.style.position="fixed",A.style.left="-999999px",document.body.appendChild(A),A.select(),document.execCommand("copy"),document.body.removeChild(A),y(!0),setTimeout(()=>y(!1),2e3)}}},k=(n.parameters||[]).filter(D=>D.in==="path"),C=(n.parameters||[]).filter(D=>D.in==="query"),E=["post","put","patch"].includes(e)&&n.requestBody;return s.jsxs("div",{className:"border border-bambu-dark-tertiary rounded-lg overflow-hidden",children:[s.jsxs("button",{onClick:()=>o(!a),className:"w-full flex items-center gap-3 p-3 hover:bg-bambu-dark-tertiary/50 transition-colors text-left",children:[a?s.jsx(ei,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}):s.jsx(gs,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),s.jsx("span",{className:`px-2 py-0.5 text-xs font-mono font-semibold uppercase rounded border ${wKe[e]||"bg-gray-500/20 text-gray-400"}`,children:e}),s.jsx("code",{className:"text-sm text-white font-mono flex-1 truncate",children:t}),n.summary&&s.jsx("span",{className:"text-sm text-bambu-gray truncate max-w-[40%]",children:n.summary})]}),a&&s.jsxs("div",{className:"border-t border-bambu-dark-tertiary p-4 space-y-4 bg-bambu-dark/50",children:[n.description&&s.jsx("p",{className:"text-sm text-bambu-gray",children:n.description}),k.length>0&&s.jsxs("div",{className:"space-y-2",children:[s.jsx("h4",{className:"text-sm font-medium text-white",children:"Path Parameters"}),s.jsx("div",{className:"space-y-2",children:k.map(D=>s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("label",{className:"text-sm text-bambu-gray w-32 flex-shrink-0",children:[D.name,D.required&&s.jsx("span",{className:"text-red-400 ml-1",children:"*"})]}),s.jsx("input",{type:"text",value:l[D.name]||"",onChange:A=>c(R=>({...R,[D.name]:A.target.value})),placeholder:D.description||D.schema?.type||"value",className:"flex-1 px-2 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm font-mono focus:border-bambu-green focus:outline-none"})]},D.name))})]}),C.length>0&&s.jsxs("div",{className:"space-y-2",children:[s.jsx("h4",{className:"text-sm font-medium text-white",children:"Query Parameters"}),s.jsx("div",{className:"space-y-2",children:C.map(D=>s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("label",{className:"text-sm text-bambu-gray w-32 flex-shrink-0",children:[D.name,D.required&&s.jsx("span",{className:"text-red-400 ml-1",children:"*"})]}),D.schema?.enum?s.jsxs("select",{value:l[D.name]||"",onChange:A=>c(R=>({...R,[D.name]:A.target.value})),className:"flex-1 px-2 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"",children:"-- Select --"}),D.schema.enum.map(A=>s.jsx("option",{value:A,children:A},A))]}):s.jsx("input",{type:"text",value:l[D.name]||"",onChange:A=>c(R=>({...R,[D.name]:A.target.value})),placeholder:D.description||D.schema?.type||"value",className:"flex-1 px-2 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm font-mono focus:border-bambu-green focus:outline-none"})]},D.name))})]}),E&&s.jsxs("div",{className:"space-y-2",children:[s.jsx("h4",{className:"text-sm font-medium text-white",children:"Request Body"}),s.jsx("textarea",{value:u,onChange:D=>d(D.target.value),rows:8,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm font-mono focus:border-bambu-green focus:outline-none resize-y",placeholder:"JSON request body..."})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(Te,{onClick:N,disabled:m,children:[m?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(Is,{className:"w-4 h-4"}),"Execute"]}),S.length>0&&s.jsxs("span",{className:"text-xs text-yellow-400 flex items-center gap-1",children:[s.jsx(Hi,{className:"w-3 h-3"}),"Fill in: ",S.join(", ")]})]}),f&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("h4",{className:"text-sm font-medium text-white flex items-center gap-2",children:["Response",s.jsxs("span",{className:`px-2 py-0.5 text-xs rounded ${f.status>=200&&f.status<300?"bg-green-500/20 text-green-400":f.status>=400?"bg-red-500/20 text-red-400":"bg-yellow-500/20 text-yellow-400"}`,children:[f.status," ",f.statusText]}),s.jsxs("span",{className:"text-xs text-bambu-gray",children:[f.duration,"ms"]})]}),s.jsx(Te,{variant:"secondary",size:"sm",onClick:T,children:b?s.jsx(Ar,{className:"w-3 h-3 text-green-400"}):s.jsx(Fl,{className:"w-3 h-3"})})]}),s.jsx("pre",{className:"p-3 bg-bambu-dark rounded-lg text-sm font-mono text-white overflow-auto max-h-96 border border-bambu-dark-tertiary",children:typeof f.body=="string"?f.body:JSON.stringify(f.body,null,2)})]})]})]})}function MKe({apiKey:t=""}){const[e,n]=_.useState(null),[r,i]=_.useState(!0),[a,o]=_.useState(null),[l,c]=_.useState(new Set),[u,d]=_.useState("");if(_.useEffect(()=>{async function y(){try{const v=await fetch("/openapi.json");if(!v.ok)throw new Error("Failed to fetch OpenAPI schema");const S=await v.json();n(S)}catch(v){o(v instanceof Error?v.message:"Unknown error")}finally{i(!1)}}y()},[]),r)return s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(ht,{className:"w-8 h-8 text-bambu-green animate-spin"})});if(a||!e)return s.jsx(_t,{children:s.jsx(Mt,{className:"py-8",children:s.jsxs("div",{className:"text-center text-red-400",children:[s.jsx(Hi,{className:"w-12 h-12 mx-auto mb-3 opacity-50"}),s.jsx("p",{children:"Failed to load API schema"}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:a})]})})});const f={};for(const[y,v]of Object.entries(e.paths))for(const[S,N]of Object.entries(v)){if(S==="parameters")continue;const T=N.tags||["Other"];for(const k of T)f[k]||(f[k]=[]),f[k].push({path:y,method:S,spec:N})}const p=Object.entries(f).map(([y,v])=>{if(!u)return{tag:y,endpoints:v};const S=v.filter(({path:N,method:T,spec:k})=>{const C=u.toLowerCase();return N.toLowerCase().includes(C)||T.toLowerCase().includes(C)||(k.summary?.toLowerCase()||"").includes(C)||(k.description?.toLowerCase()||"").includes(C)});return{tag:y,endpoints:S}}).filter(({endpoints:y})=>y.length>0).sort((y,v)=>y.tag.localeCompare(v.tag)),m=y=>{c(v=>{const S=new Set(v);return S.has(y)?S.delete(y):S.add(y),S})},x=()=>{c(new Set(p.map(y=>y.tag)))},b=()=>{c(new Set)};return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between gap-4",children:[s.jsx("div",{className:"flex-1",children:s.jsx("input",{type:"text",value:u,onChange:y=>d(y.target.value),placeholder:"Search endpoints...",className:"w-full max-w-md px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Te,{variant:"secondary",size:"sm",onClick:x,children:"Expand All"}),s.jsx(Te,{variant:"secondary",size:"sm",onClick:b,children:"Collapse All"}),s.jsxs("a",{href:"/docs",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-sm text-bambu-green hover:underline",children:[s.jsx(Kr,{className:"w-4 h-4"}),"Swagger UI"]})]})]}),s.jsxs("p",{className:"text-sm text-bambu-gray",children:[p.reduce((y,v)=>y+v.endpoints.length,0)," endpoints in ",p.length," categories"]}),s.jsx("div",{className:"space-y-3",children:p.map(({tag:y,endpoints:v})=>s.jsxs(_t,{children:[s.jsx("button",{onClick:()=>m(y),className:"w-full flex items-center justify-between p-4 hover:bg-bambu-dark-tertiary/30 transition-colors text-left",children:s.jsxs("div",{className:"flex items-center gap-2",children:[l.has(y)?s.jsx(ei,{className:"w-5 h-5 text-bambu-gray"}):s.jsx(gs,{className:"w-5 h-5 text-bambu-gray"}),s.jsx("h3",{className:"text-base font-semibold text-white capitalize",children:y.replace(/-/g," ")}),s.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-2 py-0.5 rounded-full text-bambu-gray",children:v.length})]})}),l.has(y)&&s.jsx(Mt,{className:"pt-0 space-y-2",children:v.map(({path:S,method:N,spec:T})=>s.jsx(SKe,{path:S,method:N,spec:T,schema:e,apiKey:t},`${N}-${S}`))})]},y))})]})}const NKe=["general","network","plugs","notifications","filament","apikeys","virtual-printer","users","backup"];function kKe(){const t=an(),e=Nc(),[n,r]=wR(),{t:i,i18n:a}=Hn(),{showToast:o}=$n(),{authEnabled:l,user:c,refreshAuth:u}=Ai(),{mode:d,darkStyle:f,darkBackground:p,darkAccent:m,lightStyle:x,lightBackground:b,lightAccent:y,setDarkStyle:v,setDarkBackground:S,setDarkAccent:N,setLightStyle:T,setLightBackground:k,setLightAccent:C}=Oh(),[E,D]=_.useState(null),[A,R]=_.useState(!1),[U,F]=_.useState(null),[$,j]=_.useState(!1),[H,K]=_.useState(null),[V,Q]=_.useState(null),[Z,ae]=_.useState(!1),[B,X]=_.useState(OW()),ne=n.get("tab"),se=ne&&NKe.includes(ne)?ne:"general",[be,xe]=_.useState(se),de=oe=>{xe(oe),oe==="general"?n.delete("tab"):n.set("tab",oe),r(n,{replace:!0})},[Pe,ie]=_.useState(!1),[Ne,Oe]=_.useState(""),[ge,Ke]=_.useState({can_queue:!0,can_control_printer:!1,can_read_status:!0}),[G,Y]=_.useState(null),[ce,q]=_.useState(null),[te,I]=_.useState(""),[fe,me]=_.useState(!1),[Ee,z]=_.useState(!1),[O,ee]=_.useState(null),[le,_e]=_.useState(!1),[we,re]=_.useState(!1),[Fe,He]=_.useState(!1),[Ve,$e]=_.useState({currentPassword:"",newPassword:"",confirmPassword:""}),[ye,je]=_.useState(!1),[Be,Se]=_.useState(!1),[Xe,Me]=_.useState(!1),[tt,ke]=_.useState(null),[We,ze]=_.useState(null),[W,De]=_.useState(null),[Ye,xt]=_.useState(!1),[ft,Bt]=_.useState({username:"",password:"",confirmPassword:"",role:"user",group_ids:[]}),[Lt,vn]=_.useState(!1),[Jt,ir]=_.useState(null),[fr,Dn]=_.useState(null),[ln,mr]=_.useState({name:"",description:"",permissions:[]}),[Fn,Xn]=_.useState(new Set),[bn,wi]=_.useState(null),[Ba,Ae]=_.useState(!1),[Ze,st]=_.useState({}),[lt,ot]=_.useState({}),Et=oe=>{X(oe),jfe(oe),o(i("settings.toast.settingsSaved"),"success")},he=()=>{localStorage.removeItem("sidebarOrder"),window.location.reload()},{data:pe,isLoading:Ie}=at({queryKey:["settings"],queryFn:ue.getSettings}),{data:Le,isLoading:Ce}=at({queryKey:["smart-plugs"],queryFn:ue.getSmartPlugs}),{data:ut,isLoading:St}=at({queryKey:["smart-plugs-energy",Le?.map(oe=>oe.id)],queryFn:async()=>{if(!Le||Le.length===0)return null;const oe=await Promise.all(Le.filter(is=>is.enabled).map(async is=>{try{const as=await ue.getSmartPlugStatus(is.id);return{plug:is,status:as}}catch{return{plug:is,status:null}}}));let wt=0,Rn=0,Jn=0,No=0,Ju=0;for(const{plug:is,status:as}of oe){const $x=is.plug_type==="mqtt"&&as?.energy?.power!=null;(as?.reachable||$x)&&as?.energy&&(Ju++,as.energy?.power!=null&&(wt+=as.energy.power),as.energy?.today!=null&&(Rn+=as.energy.today),as.energy?.yesterday!=null&&(Jn+=as.energy.yesterday),as.energy?.total!=null&&(No+=as.energy.total))}return{totalPower:wt,totalToday:Rn,totalYesterday:Jn,totalLifetime:No,reachableCount:Ju,totalPlugs:Le.filter(is=>is.enabled).length}},enabled:be==="plugs"&&!!Le&&Le.length>0,refetchInterval:be==="plugs"?1e4:!1}),{data:At,isLoading:Tt}=at({queryKey:["notification-providers"],queryFn:ue.getNotificationProviders}),{data:Ft,isLoading:Pt}=at({queryKey:["api-keys"],queryFn:ue.getAPIKeys}),Nt=mt({mutationFn:oe=>ue.createAPIKey(oe),onSuccess:oe=>{Y(oe.key||null),ie(!1),Oe(""),t.invalidateQueries({queryKey:["api-keys"]}),o(i("settings.toast.apiKeyCreated"))},onError:oe=>{o(`Failed to create API key: ${oe.message}`,"error")}}),en=mt({mutationFn:oe=>ue.deleteAPIKey(oe),onSuccess:()=>{t.invalidateQueries({queryKey:["api-keys"]}),o(i("settings.toast.apiKeyDeleted"))},onError:oe=>{o(`Failed to delete API key: ${oe.message}`,"error")}}),{data:Ht}=at({queryKey:["printers"],queryFn:ue.getPrinters}),{data:dn,isLoading:cn}=at({queryKey:["notification-templates"],queryFn:ue.getNotificationTemplates}),{data:Sn}=at({queryKey:["virtual-printer-settings"],queryFn:p1.getSettings,refetchInterval:1e4}),Gt=Sn?.status?.running??!1,{data:sn}=at({queryKey:["ffmpeg-status"],queryFn:ue.checkFfmpeg}),{data:un}=at({queryKey:["version"],queryFn:ue.getVersion}),{data:Yt,refetch:nr,isRefetching:jn}=at({queryKey:["updateCheck"],queryFn:ue.checkForUpdates,staleTime:300*1e3}),{data:ii,refetch:rr}=at({queryKey:["updateStatus"],queryFn:ue.getUpdateStatus,refetchInterval:oe=>{const wt=oe.state.data;return wt?.status==="downloading"||wt?.status==="installing"?1e3:!1}}),{data:cr}=at({queryKey:["mqtt-status"],queryFn:ue.getMQTTStatus,refetchInterval:be==="network"?5e3:!1}),{data:et}=at({queryKey:["github-backup-status"],queryFn:ue.getGitHubBackupStatus}),{data:jt}=at({queryKey:["cloud-status"],queryFn:ue.getCloudStatus}),{hasPermission:qt}=Ai(),{data:yt=[],isLoading:wn}=at({queryKey:["users"],queryFn:()=>ue.getUsers(),enabled:l&&qt("users:read")}),{data:Fr=[],isLoading:Yr}=at({queryKey:["groups"],queryFn:()=>ue.getGroups(),enabled:l&&qt("groups:read")}),{data:Br}=at({queryKey:["permissions"],queryFn:()=>ue.getPermissions(),enabled:l&&qt("groups:read")}),Ws=mt({mutationFn:oe=>ue.createUser(oe),onSuccess:()=>{t.invalidateQueries({queryKey:["users"]}),t.invalidateQueries({queryKey:["groups"]}),Se(!1),Bt({username:"",password:"",confirmPassword:"",role:"user",group_ids:[]}),o(i("settings.toast.userCreated"))},onError:oe=>{o(oe.message,"error")}}),tn=mt({mutationFn:({id:oe,data:wt})=>ue.updateUser(oe,wt),onSuccess:()=>{t.invalidateQueries({queryKey:["users"]}),t.invalidateQueries({queryKey:["groups"]}),Me(!1),ke(null),Bt({username:"",password:"",confirmPassword:"",role:"user",group_ids:[]}),o(i("settings.toast.userUpdated"))},onError:oe=>{o(oe.message,"error")}}),on=mt({mutationFn:({id:oe,deleteItems:wt})=>ue.deleteUser(oe,wt),onSuccess:()=>{t.invalidateQueries({queryKey:["users"]}),o(i("settings.toast.userDeleted")),ze(null),De(null)},onError:oe=>{o(oe.message,"error")}}),_i=async oe=>{ze(oe),xt(!0);try{const wt=await ue.getUserItemsCount(oe);De(wt)}catch{De({archives:0,queue_items:0,library_files:0})}finally{xt(!1)}},Ss=mt({mutationFn:oe=>ue.createGroup(oe),onSuccess:()=>{t.invalidateQueries({queryKey:["groups"]}),vn(!1),la(),o(i("settings.toast.groupCreated"))},onError:oe=>{o(oe.message,"error")}}),_o=mt({mutationFn:({id:oe,data:wt})=>ue.updateGroup(oe,wt),onSuccess:()=>{t.invalidateQueries({queryKey:["groups"]}),ir(null),la(),o(i("settings.toast.groupUpdated"))},onError:oe=>{o(oe.message,"error")}}),So=mt({mutationFn:oe=>ue.deleteGroup(oe),onSuccess:()=>{t.invalidateQueries({queryKey:["groups"]}),o(i("settings.toast.groupDeleted"))},onError:oe=>{o(oe.message,"error")}}),Mo=()=>{if(!ft.username||!ft.password){o(i("settings.toast.fillRequiredFields"),"error");return}if(ft.password!==ft.confirmPassword){o(i("settings.toast.passwordsDoNotMatch"),"error");return}if(ft.password.length<6){o(i("settings.toast.passwordTooShort"),"error");return}Ws.mutate({username:ft.username,password:ft.password,role:ft.role,group_ids:ft.group_ids.length>0?ft.group_ids:void 0})},Ms=oe=>{if(ft.password){if(ft.password!==ft.confirmPassword){o(i("settings.toast.passwordsDoNotMatch"),"error");return}if(ft.password.length<6){o(i("settings.toast.passwordTooShort"),"error");return}}const wt={username:ft.username||void 0,password:ft.password||void 0,role:ft.role,group_ids:ft.group_ids};wt.password||delete wt.password,tn.mutate({id:oe,data:wt})},Si=oe=>{ke(oe.id),Bt({username:oe.username,password:"",confirmPassword:"",role:oe.role,group_ids:oe.groups?.map(wt=>wt.id)||[]}),Me(!0)},Ks=oe=>{Bt(wt=>({...wt,group_ids:wt.group_ids.includes(oe)?wt.group_ids.filter(Rn=>Rn!==oe):[...wt.group_ids,oe]}))},la=()=>{mr({name:"",description:"",permissions:[]}),Xn(new Set)},Hr=()=>{if(!ln.name.trim()){o(i("settings.toast.enterGroupName"),"error");return}Ss.mutate({name:ln.name,description:ln.description||void 0,permissions:ln.permissions})},Ux=()=>{if(Jt){if(!ln.name.trim()){o(i("settings.toast.enterGroupName"),"error");return}_o.mutate({id:Jt.id,data:{name:ln.name!==Jt.name?ln.name:void 0,description:ln.description,permissions:ln.permissions}})}},$h=oe=>{ir(oe),mr({name:oe.name,description:oe.description||"",permissions:oe.permissions});const wt=new Set;Br?.categories.forEach(Rn=>{Rn.permissions.some(Jn=>oe.permissions.includes(Jn.value))&&wt.add(Rn.name)}),Xn(wt)},$l=oe=>{Xn(wt=>{const Rn=new Set(wt);return Rn.has(oe)?Rn.delete(oe):Rn.add(oe),Rn})},zx=oe=>{mr(wt=>{const Rn=wt.permissions.includes(oe)?wt.permissions.filter(Jn=>Jn!==oe):[...wt.permissions,oe];return{...wt,permissions:Rn}})},Dm=(oe,wt)=>{mr(Rn=>{const Jn=oe.permissions.map(is=>is.value),No=Rn.permissions.filter(is=>!Jn.includes(is)),Ju=wt?[...No,...Jn]:No;return{...Rn,permissions:Ju}})},Rm=oe=>oe.permissions.every(wt=>ln.permissions.includes(wt.value)),Vh=oe=>{const wt=oe.permissions.filter(Rn=>ln.permissions.includes(Rn.value));return wt.length>0&&wt.length<oe.permissions.length},Qu=mt({mutationFn:ue.applyUpdate,onSuccess:oe=>{oe.is_docker?o(oe.message,"error"):rr()}}),[Cc,ca]=_.useState(null),pl=mt({mutationFn:ue.testAllNotificationProviders,onSuccess:oe=>{ca(oe),t.invalidateQueries({queryKey:["notification-providers"]}),oe.failed===0?o(`All ${oe.tested} providers tested successfully!`,"success"):o(`${oe.success}/${oe.tested} providers succeeded`,oe.failed>0?"error":"success")},onError:oe=>{o(`Failed to test providers: ${oe.message}`,"error")}}),Vl=mt({mutationFn:async oe=>{if(!Le)return{success:0,failed:0};const wt=Le.filter(Jn=>Jn.enabled),Rn=await Promise.all(wt.map(async Jn=>{try{return await ue.controlSmartPlug(Jn.id,oe),{success:!0}}catch{return{success:!1}}}));return{success:Rn.filter(Jn=>Jn.success).length,failed:Rn.filter(Jn=>!Jn.success).length}},onSuccess:(oe,wt)=>{t.invalidateQueries({queryKey:["smart-plugs"]}),t.invalidateQueries({queryKey:["smart-plugs-energy"]}),oe.failed===0?o(`All ${oe.success} plugs turned ${wt}`,"success"):o(`${oe.success} plugs turned ${wt}, ${oe.failed} failed`,"error")},onError:oe=>{o(`Failed: ${oe.message}`,"error")}}),gl=_.useRef(null),Om=_.useRef(!1),Lm=_.useRef(!0);_.useEffect(()=>{if(pe&&!E){const oe={...pe,external_url:pe.external_url||window.location.origin};D(oe),setTimeout(()=>{Lm.current=!1},100)}},[pe,E]);const Fm=mt({mutationFn:ue.updateSettings,onSuccess:oe=>{t.setQueryData(["settings"],oe),D(oe),t.invalidateQueries({queryKey:["archiveStats"]}),o(i("settings.toast.settingsSaved"),"success")},onError:oe=>{o(`Failed to save: ${oe.message}`,"error")},onSettled:()=>{Om.current=!1}}),Zu=mt({mutationFn:({id:oe,data:wt})=>ue.updatePrinter(oe,wt),onSuccess:()=>{t.invalidateQueries({queryKey:["printers"]}),o(i("settings.toast.cameraSettingsSaved"),"success")},onError:oe=>{o(`Failed to update printer: ${oe.message}`,"error")}});_.useEffect(()=>{if(!(Lm.current||!E||!pe||!(pe.auto_archive!==E.auto_archive||pe.save_thumbnails!==E.save_thumbnails||pe.capture_finish_photo!==E.capture_finish_photo||pe.default_filament_cost!==E.default_filament_cost||pe.currency!==E.currency||pe.energy_cost_per_kwh!==E.energy_cost_per_kwh||pe.energy_tracking_mode!==E.energy_tracking_mode||pe.check_updates!==E.check_updates||(pe.check_printer_firmware??!0)!==(E.check_printer_firmware??!0)||pe.notification_language!==E.notification_language||pe.ams_humidity_good!==E.ams_humidity_good||pe.ams_humidity_fair!==E.ams_humidity_fair||pe.ams_temp_good!==E.ams_temp_good||pe.ams_temp_fair!==E.ams_temp_fair||pe.ams_history_retention_days!==E.ams_history_retention_days||pe.per_printer_mapping_expanded!==E.per_printer_mapping_expanded||pe.date_format!==E.date_format||pe.time_format!==E.time_format||pe.default_printer_id!==E.default_printer_id||pe.ftp_retry_enabled!==E.ftp_retry_enabled||pe.ftp_retry_count!==E.ftp_retry_count||pe.ftp_retry_delay!==E.ftp_retry_delay||pe.ftp_timeout!==E.ftp_timeout||pe.mqtt_enabled!==E.mqtt_enabled||pe.mqtt_broker!==E.mqtt_broker||pe.mqtt_port!==E.mqtt_port||pe.mqtt_username!==E.mqtt_username||pe.mqtt_password!==E.mqtt_password||pe.mqtt_topic_prefix!==E.mqtt_topic_prefix||pe.mqtt_use_tls!==E.mqtt_use_tls||pe.external_url!==E.external_url||pe.ha_enabled!==E.ha_enabled||pe.ha_url!==E.ha_url||pe.ha_token!==E.ha_token||(pe.library_archive_mode??"ask")!==(E.library_archive_mode??"ask")||Number(pe.library_disk_warning_gb??5)!==Number(E.library_disk_warning_gb??5)||(pe.camera_view_mode??"window")!==(E.camera_view_mode??"window")||pe.prometheus_enabled!==E.prometheus_enabled||pe.prometheus_token!==E.prometheus_token))&&!Om.current)return gl.current&&clearTimeout(gl.current),gl.current=setTimeout(()=>{if(Om.current)return;Om.current=!0;const wt={auto_archive:E.auto_archive,save_thumbnails:E.save_thumbnails,capture_finish_photo:E.capture_finish_photo,default_filament_cost:E.default_filament_cost,currency:E.currency,energy_cost_per_kwh:E.energy_cost_per_kwh,energy_tracking_mode:E.energy_tracking_mode,check_updates:E.check_updates,check_printer_firmware:E.check_printer_firmware,notification_language:E.notification_language,ams_humidity_good:E.ams_humidity_good,ams_humidity_fair:E.ams_humidity_fair,ams_temp_good:E.ams_temp_good,ams_temp_fair:E.ams_temp_fair,ams_history_retention_days:E.ams_history_retention_days,per_printer_mapping_expanded:E.per_printer_mapping_expanded,date_format:E.date_format,time_format:E.time_format,default_printer_id:E.default_printer_id,ftp_retry_enabled:E.ftp_retry_enabled,ftp_retry_count:E.ftp_retry_count,ftp_retry_delay:E.ftp_retry_delay,ftp_timeout:E.ftp_timeout,mqtt_enabled:E.mqtt_enabled,mqtt_broker:E.mqtt_broker,mqtt_port:E.mqtt_port,mqtt_username:E.mqtt_username,mqtt_password:E.mqtt_password,mqtt_topic_prefix:E.mqtt_topic_prefix,mqtt_use_tls:E.mqtt_use_tls,external_url:E.external_url,ha_enabled:E.ha_enabled,ha_url:E.ha_url,ha_token:E.ha_token,library_archive_mode:E.library_archive_mode,library_disk_warning_gb:E.library_disk_warning_gb,camera_view_mode:E.camera_view_mode,prometheus_enabled:E.prometheus_enabled,prometheus_token:E.prometheus_token};Fm.mutate(wt)},500),()=>{gl.current&&clearTimeout(gl.current)}},[E,pe,Fm]);const hn=_.useCallback((oe,wt)=>{D(Rn=>Rn?{...Rn,[oe]:wt}:null)},[]),Sv=async(oe,wt,Rn)=>{if(!wt){o(i("settings.toast.enterCameraUrl"),"error");return}ot(Jn=>({...Jn,[oe]:!0})),st(Jn=>({...Jn,[oe]:null}));try{const Jn=await ue.testExternalCamera(oe,wt,Rn);st(No=>({...No,[oe]:Jn})),Jn.success?o(i("settings.toast.cameraConnected",{resolution:Jn.resolution||""}),"success"):o(Jn.error||i("settings.toast.connectionFailed"),"error")}catch(Jn){const No=Jn instanceof Error?Jn.message:i("settings.toast.testFailed");st(Ju=>({...Ju,[oe]:{success:!1,error:No}})),o(No,"error")}finally{ot(Jn=>({...Jn,[oe]:!1}))}},[Bx,Mv]=_.useState({}),Hx=_.useRef({}),Im=_.useRef(new Set);_.useEffect(()=>{if(Ht){const oe={};Ht.forEach(wt=>{wt.external_camera_url&&!Im.current.has(wt.id)&&(oe[wt.id]=wt.external_camera_url,Im.current.add(wt.id))}),Object.keys(oe).length>0&&Mv(wt=>({...wt,...oe}))}},[Ht]);const G2=(oe,wt)=>{Mv(Rn=>({...Rn,[oe]:wt})),Hx.current[oe]&&clearTimeout(Hx.current[oe]),Hx.current[oe]=setTimeout(()=>{Zu.mutate({id:oe,data:{external_camera_url:wt||null}})},800)},Nv=(oe,wt)=>{const Rn={};wt.type!==void 0&&(Rn.external_camera_type=wt.type||null),wt.enabled!==void 0&&(Rn.external_camera_enabled=wt.enabled),Zu.mutate({id:oe,data:Rn})};return Ie||!E?s.jsx("div",{className:"p-4 md:p-8 flex justify-center",children:s.jsx(ht,{className:"w-8 h-8 text-bambu-green animate-spin"})}):s.jsxs("div",{className:"p-4 md:p-8",children:[s.jsxs("div",{className:"mb-8",children:[s.jsx("h1",{className:"text-2xl font-bold text-white",children:i("settings.title")}),s.jsx("p",{className:"text-bambu-gray",children:i("settings.configureBambuddy")})]}),s.jsxs("div",{className:"flex gap-1 mb-6 border-b border-bambu-dark-tertiary overflow-x-auto",children:[s.jsx("button",{onClick:()=>de("general"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px ${be==="general"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:i("settings.tabs.general")}),s.jsxs("button",{onClick:()=>de("plugs"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${be==="plugs"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(tl,{className:"w-4 h-4"}),i("settings.tabs.smartPlugs"),Le&&Le.length>0&&s.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:Le.length})]}),s.jsxs("button",{onClick:()=>de("notifications"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${be==="notifications"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(wg,{className:"w-4 h-4"}),i("settings.tabs.notifications"),At&&At.length>0&&s.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:At.length})]}),s.jsxs("button",{onClick:()=>de("filament"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${be==="filament"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(hue,{className:"w-4 h-4"}),i("settings.tabs.filament")]}),s.jsxs("button",{onClick:()=>de("network"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${be==="network"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(Sg,{className:"w-4 h-4"}),i("settings.tabs.network"),s.jsx("span",{className:`w-2 h-2 rounded-full ${cr?.enabled?"bg-green-400":"bg-gray-500"}`})]}),s.jsxs("button",{onClick:()=>de("apikeys"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${be==="apikeys"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx($o,{className:"w-4 h-4"}),i("settings.tabs.apiKeys"),Ft&&Ft.length>0&&s.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:Ft.length})]}),s.jsxs("button",{onClick:()=>de("virtual-printer"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${be==="virtual-printer"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(Ur,{className:"w-4 h-4"}),i("settings.tabs.virtualPrinter"),s.jsx("span",{className:`w-2 h-2 rounded-full ${Gt?"bg-green-400":"bg-gray-500"}`})]}),s.jsxs("button",{onClick:()=>de("users"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${be==="users"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(mg,{className:"w-4 h-4"}),i("settings.tabs.users"),l&&s.jsx("span",{className:`w-2 h-2 rounded-full ${l?"bg-green-400":"bg-gray-500"}`})]}),s.jsxs("button",{onClick:()=>de("backup"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${be==="backup"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(Nu,{className:"w-4 h-4"}),i("settings.tabs.backup"),s.jsx("span",{className:`w-2 h-2 rounded-full ${jt?.is_authenticated&&et?.configured&&et?.enabled?"bg-green-400":"bg-gray-500"}`})]})]}),be==="general"&&s.jsxs("div",{className:"flex flex-col lg:flex-row gap-6 lg:gap-8",children:[s.jsxs("div",{className:"space-y-6 flex-1 lg:max-w-xl",children:[s.jsxs(_t,{children:[s.jsx(Kn,{children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.general")})}),s.jsxs(Mt,{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[s.jsx(sh,{className:"w-4 h-4 inline mr-1"}),i("settings.language")]}),s.jsxs("div",{className:"relative",children:[s.jsx("select",{value:a.language,onChange:oe=>{a.changeLanguage(oe.target.value),o(i("settings.toast.settingsSaved"),"success")},className:"w-full px-3 py-2 pr-10 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none appearance-none cursor-pointer",children:mz.map(oe=>s.jsxs("option",{value:oe.code,children:[oe.nativeName," (",oe.name,")"]},oe.code))}),s.jsx(ei,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:i("settings.languageDescription")})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:i("settings.defaultView")}),s.jsxs("div",{className:"relative",children:[s.jsx("select",{value:B,onChange:oe=>Et(oe.target.value),className:"w-full px-3 py-2 pr-10 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none appearance-none cursor-pointer",children:K0.map(oe=>s.jsx("option",{value:oe.to,children:i(oe.labelKey)},oe.id))}),s.jsx(ei,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:i("settings.defaultViewDescription")})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Date Format"}),s.jsxs("div",{className:"relative",children:[s.jsxs("select",{value:E.date_format||"system",onChange:oe=>hn("date_format",oe.target.value),className:"w-full px-3 py-2 pr-10 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none appearance-none cursor-pointer",children:[s.jsx("option",{value:"system",children:i("settings.systemDefault")}),s.jsx("option",{value:"us",children:"US (MM/DD/YYYY)"}),s.jsx("option",{value:"eu",children:"EU (DD/MM/YYYY)"}),s.jsx("option",{value:"iso",children:"ISO (YYYY-MM-DD)"})]}),s.jsx(ei,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Time Format"}),s.jsxs("div",{className:"relative",children:[s.jsxs("select",{value:E.time_format||"system",onChange:oe=>hn("time_format",oe.target.value),className:"w-full px-3 py-2 pr-10 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none appearance-none cursor-pointer",children:[s.jsx("option",{value:"system",children:i("settings.systemDefault")}),s.jsx("option",{value:"12h",children:"12-hour (3:30 PM)"}),s.jsx("option",{value:"24h",children:"24-hour (15:30)"})]}),s.jsx(ei,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Default Printer"}),s.jsxs("div",{className:"relative",children:[s.jsxs("select",{value:E.default_printer_id??"",onChange:oe=>hn("default_printer_id",oe.target.value?Number(oe.target.value):null),className:"w-full px-3 py-2 pr-10 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none appearance-none cursor-pointer",children:[s.jsx("option",{value:"",children:i("settings.noDefaultPrinter")}),Ht?.map(oe=>s.jsx("option",{value:oe.id,children:oe.name},oe.id))]}),s.jsx(ei,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Pre-select this printer for uploads, reprints, and other operations."})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:i("settings.sidebarOrder")}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Drag items in the sidebar to reorder. Reset to default order here."})]}),s.jsxs(Te,{variant:"secondary",size:"sm",onClick:he,children:[s.jsx(Rh,{className:"w-4 h-4"}),"Reset"]})]})]})]}),s.jsxs(_t,{children:[s.jsx(Kn,{children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(SW,{className:"w-5 h-5"}),"Appearance"]})}),s.jsxs(Mt,{className:"space-y-6",children:[s.jsxs("div",{className:`space-y-3 p-4 rounded-lg border ${d==="dark"?"border-bambu-green bg-bambu-green/5":"border-bambu-dark-tertiary"}`,children:[s.jsxs("h3",{className:"text-sm font-medium text-white flex items-center gap-2",children:["Dark Mode",d==="dark"&&s.jsx("span",{className:"text-xs text-bambu-green",children:"(active)"})]}),s.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Background"}),s.jsxs("select",{value:p,onChange:oe=>{S(oe.target.value),o(i("settings.toast.settingsSaved"),"success")},className:"w-full px-2 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"neutral",children:"Neutral"}),s.jsx("option",{value:"warm",children:"Warm"}),s.jsx("option",{value:"cool",children:"Cool"}),s.jsx("option",{value:"oled",children:"OLED Black"}),s.jsx("option",{value:"slate",children:"Slate Blue"}),s.jsx("option",{value:"forest",children:"Forest Green"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Accent"}),s.jsxs("select",{value:m,onChange:oe=>{N(oe.target.value),o(i("settings.toast.settingsSaved"),"success")},className:"w-full px-2 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"green",children:"Green"}),s.jsx("option",{value:"teal",children:"Teal"}),s.jsx("option",{value:"blue",children:"Blue"}),s.jsx("option",{value:"orange",children:"Orange"}),s.jsx("option",{value:"purple",children:"Purple"}),s.jsx("option",{value:"red",children:"Red"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Style"}),s.jsxs("select",{value:f,onChange:oe=>{v(oe.target.value),o(i("settings.toast.settingsSaved"),"success")},className:"w-full px-2 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"classic",children:"Classic"}),s.jsx("option",{value:"glow",children:"Glow"}),s.jsx("option",{value:"vibrant",children:"Vibrant"})]})]})]})]}),s.jsxs("div",{className:`space-y-3 p-4 rounded-lg border ${d==="light"?"border-bambu-green bg-bambu-green/5":"border-bambu-dark-tertiary"}`,children:[s.jsxs("h3",{className:"text-sm font-medium text-white flex items-center gap-2",children:["Light Mode",d==="light"&&s.jsx("span",{className:"text-xs text-bambu-green",children:"(active)"})]}),s.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Background"}),s.jsxs("select",{value:b,onChange:oe=>{k(oe.target.value),o(i("settings.toast.settingsSaved"),"success")},className:"w-full px-2 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"neutral",children:"Neutral"}),s.jsx("option",{value:"warm",children:"Warm"}),s.jsx("option",{value:"cool",children:"Cool"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Accent"}),s.jsxs("select",{value:y,onChange:oe=>{C(oe.target.value),o(i("settings.toast.settingsSaved"),"success")},className:"w-full px-2 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"green",children:"Green"}),s.jsx("option",{value:"teal",children:"Teal"}),s.jsx("option",{value:"blue",children:"Blue"}),s.jsx("option",{value:"orange",children:"Orange"}),s.jsx("option",{value:"purple",children:"Purple"}),s.jsx("option",{value:"red",children:"Red"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Style"}),s.jsxs("select",{value:x,onChange:oe=>{T(oe.target.value),o(i("settings.toast.settingsSaved"),"success")},className:"w-full px-2 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"classic",children:"Classic"}),s.jsx("option",{value:"glow",children:"Glow"}),s.jsx("option",{value:"vibrant",children:"Vibrant"})]})]})]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Toggle between dark and light mode using the sun/moon icon in the sidebar."})]})]}),s.jsxs(_t,{children:[s.jsx(Kn,{children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.archiveSettings")})}),s.jsxs(Mt,{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:"Auto-archive prints"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically save 3MF files when prints complete"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:E.auto_archive,onChange:oe=>hn("auto_archive",oe.target.checked),className:"sr-only peer"}),s.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:i("settings.saveThumbnails")}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Extract and save preview images from 3MF files"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:E.save_thumbnails,onChange:oe=>hn("save_thumbnails",oe.target.checked),className:"sr-only peer"}),s.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:i("settings.captureFinishPhoto")}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Take a photo from printer camera when print completes"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:E.capture_finish_photo,onChange:oe=>hn("capture_finish_photo",oe.target.checked),className:"sr-only peer"}),s.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),E.capture_finish_photo&&sn&&!sn.installed&&s.jsxs("div",{className:"flex items-start gap-2 p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[s.jsx(Cn,{className:"w-5 h-5 text-yellow-500 flex-shrink-0 mt-0.5"}),s.jsxs("div",{className:"text-sm",children:[s.jsx("p",{className:"text-yellow-500 font-medium",children:"ffmpeg not installed"}),s.jsxs("p",{className:"text-bambu-gray mt-1",children:["Camera capture requires ffmpeg. Install it via"," ",s.jsx("code",{className:"bg-bambu-dark-tertiary px-1 rounded",children:"brew install ffmpeg"})," (macOS) or"," ",s.jsx("code",{className:"bg-bambu-dark-tertiary px-1 rounded",children:"apt install ffmpeg"})," (Linux)."]})]})]})]})]})]}),s.jsxs("div",{className:"space-y-6 flex-1 lg:max-w-md",children:[s.jsxs(_t,{children:[s.jsx(Kn,{children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(OR,{className:"w-5 h-5 text-bambu-green"}),"Camera"]})}),s.jsxs(Mt,{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Camera View Mode"}),s.jsxs("select",{value:E.camera_view_mode??"window",onChange:oe=>hn("camera_view_mode",oe.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"window",children:i("settings.newWindow")}),s.jsx("option",{value:"embedded",children:i("settings.embeddedOverlay")})]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:E.camera_view_mode==="embedded"?"Camera opens in a resizable overlay on the main screen":"Camera opens in a separate browser window"})]}),s.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4 mt-4",children:[s.jsx("h3",{className:"text-sm font-medium text-white mb-2",children:i("settings.externalCameras")}),s.jsx("p",{className:"text-xs text-bambu-gray mb-3",children:"Configure external cameras to replace the built-in printer camera. Supports MJPEG streams, RTSP, HTTP snapshots, and USB cameras (V4L2). When enabled, the external camera is used for live view and finish photos."}),Ht&&Ht.length>0?s.jsx("div",{className:"space-y-3",children:Ht.map(oe=>s.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("span",{className:"text-white font-medium text-sm",children:oe.name}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:oe.external_camera_enabled,onChange:wt=>Nv(oe.id,{enabled:wt.target.checked}),className:"sr-only peer"}),s.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),oe.external_camera_enabled&&s.jsxs("div",{className:"space-y-2 mt-2",children:[s.jsx("input",{type:"text",placeholder:oe.external_camera_type==="usb"?"Device path (/dev/video0)":"Camera URL (rtsp://... or http://...)",value:Bx[oe.id]??oe.external_camera_url??"",onChange:wt=>G2(oe.id,wt.target.value),className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("select",{value:oe.external_camera_type||"mjpeg",onChange:wt=>Nv(oe.id,{type:wt.target.value}),className:"flex-1 px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"mjpeg",children:"MJPEG Stream"}),s.jsx("option",{value:"rtsp",children:"RTSP Stream"}),s.jsx("option",{value:"snapshot",children:"HTTP Snapshot"}),s.jsx("option",{value:"usb",children:"USB Camera (V4L2)"})]}),s.jsx(Te,{size:"sm",variant:"secondary",onClick:()=>Sv(oe.id,Bx[oe.id]??oe.external_camera_url??"",oe.external_camera_type||"mjpeg"),disabled:lt[oe.id]||!(Bx[oe.id]??oe.external_camera_url),children:lt[oe.id]?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):"Test"})]}),Ze[oe.id]&&s.jsx("div",{className:`text-xs flex items-center gap-1 ${Ze[oe.id]?.success?"text-green-500":"text-red-500"}`,children:Ze[oe.id]?.success?s.jsxs(s.Fragment,{children:[s.jsx(Ar,{className:"w-3 h-3"}),"Connected",Ze[oe.id]?.resolution&&` (${Ze[oe.id]?.resolution})`]}):s.jsxs(s.Fragment,{children:[s.jsx(Yi,{className:"w-3 h-3"}),Ze[oe.id]?.error||i("settings.toast.connectionFailed")]})})]})]},oe.id))}):s.jsx("p",{className:"text-xs text-bambu-gray italic",children:i("settings.noPrintersConfigured")})]})]})]}),s.jsxs(_t,{children:[s.jsx(Kn,{children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.costTracking")})}),s.jsxs(Mt,{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Default filament cost (per kg)"}),s.jsx("input",{type:"number",step:"0.01",min:"0",value:E.default_filament_cost,onChange:oe=>hn("default_filament_cost",parseFloat(oe.target.value)||0),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Currency"}),s.jsxs("select",{value:E.currency,onChange:oe=>hn("currency",oe.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"USD",children:"USD ($)"}),s.jsx("option",{value:"EUR",children:"EUR (€)"}),s.jsx("option",{value:"GBP",children:"GBP (£)"}),s.jsx("option",{value:"CHF",children:"CHF (Fr.)"}),s.jsx("option",{value:"JPY",children:"JPY (¥)"}),s.jsx("option",{value:"CNY",children:"CNY (¥)"}),s.jsx("option",{value:"CAD",children:"CAD ($)"}),s.jsx("option",{value:"AUD",children:"AUD ($)"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Electricity cost per kWh"}),s.jsx("input",{type:"number",step:"0.01",min:"0",value:E.energy_cost_per_kwh,onChange:oe=>hn("energy_cost_per_kwh",parseFloat(oe.target.value)||0),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Energy display mode"}),s.jsxs("select",{value:E.energy_tracking_mode||"total",onChange:oe=>hn("energy_tracking_mode",oe.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"print",children:i("settings.printsOnly")}),s.jsx("option",{value:"total",children:i("settings.totalConsumption")})]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:E.energy_tracking_mode==="print"?"Dashboard shows sum of energy used during prints":"Dashboard shows lifetime energy from smart plugs"})]})]})]}),s.jsxs(_t,{children:[s.jsx(Kn,{children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(Ls,{className:"w-5 h-5 text-bambu-green"}),"File Manager"]})}),s.jsxs(Mt,{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Create Archive Entry When Printing"}),s.jsxs("select",{value:E.library_archive_mode??"ask",onChange:oe=>hn("library_archive_mode",oe.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"always",children:i("settings.archiveMode.always")}),s.jsx("option",{value:"never",children:i("settings.archiveMode.never")}),s.jsx("option",{value:"ask",children:i("settings.archiveMode.ask")})]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"When printing from File Manager, optionally create an archive entry"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Low Disk Space Warning"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",min:"0.5",max:"100",step:"0.5",value:E.library_disk_warning_gb??5,onChange:oe=>hn("library_disk_warning_gb",parseFloat(oe.target.value)||5),className:"w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),s.jsx("span",{className:"text-bambu-gray",children:"GB"})]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Show warning when free disk space falls below this threshold"})]})]})]})]}),s.jsxs("div",{className:"space-y-6 flex-1 lg:max-w-sm",children:[s.jsx(xKe,{}),s.jsxs(_t,{children:[s.jsx(Kn,{children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Updates"})}),s.jsxs(Mt,{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:i("settings.checkForUpdatesLabel")}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically check for new versions on startup"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:E.check_updates,onChange:oe=>hn("check_updates",oe.target.checked),className:"sr-only peer"}),s.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:i("settings.checkPrinterFirmware")}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Check for printer firmware updates from Bambu Lab"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:E.check_printer_firmware??!0,onChange:oe=>hn("check_printer_firmware",oe.target.checked),className:"sr-only peer"}),s.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),s.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:i("settings.currentVersion")}),s.jsxs("p",{className:"text-sm text-bambu-gray",children:["v",un?.version||"..."]})]}),s.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>nr(),disabled:jn,children:[jn?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(Dr,{className:"w-4 h-4"}),"Check now"]})]}),Yt?.update_available?s.jsxs("div",{className:"mt-4 p-3 bg-bambu-green/10 border border-bambu-green/30 rounded-lg",children:[s.jsxs("div",{className:"flex items-start justify-between",children:[s.jsxs("div",{children:[s.jsxs("p",{className:"text-bambu-green font-medium",children:["Update available: v",Yt.latest_version]}),Yt.release_name&&Yt.release_name!==Yt.latest_version&&s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:Yt.release_name})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[Yt.release_notes&&s.jsx("button",{onClick:()=>_e(!0),className:"text-bambu-gray hover:text-white transition-colors text-sm underline",children:"Release Notes"}),Yt.release_url&&s.jsx("a",{href:Yt.release_url,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-gray hover:text-white transition-colors",title:i("settings.viewReleaseOnGitHub"),children:s.jsx(Kr,{className:"w-4 h-4"})})]})]}),ii?.status==="downloading"||ii?.status==="installing"?s.jsxs("div",{className:"mt-3",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[s.jsx(ht,{className:"w-4 h-4 animate-spin"}),s.jsx("span",{children:ii.message})]}),s.jsx("div",{className:"mt-2 w-full bg-bambu-dark-tertiary rounded-full h-2",children:s.jsx("div",{className:"bg-bambu-green h-2 rounded-full transition-all duration-300",style:{width:`${ii.progress}%`}})})]}):ii?.status==="complete"?s.jsx("div",{className:"mt-3 p-2 bg-bambu-green/20 rounded text-sm text-bambu-green",children:ii.message}):ii?.status==="error"?s.jsx("div",{className:"mt-3 p-2 bg-red-500/20 rounded text-sm text-red-400",children:ii.error||ii.message}):Yt?.is_docker?s.jsxs("div",{className:"mt-3 p-3 bg-bambu-dark-tertiary rounded-lg",children:[s.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:"Update via Docker Compose:"}),s.jsx("code",{className:"block text-xs bg-bambu-dark p-2 rounded text-bambu-green font-mono",children:"docker compose pull && docker compose up -d"})]}):s.jsxs(Te,{className:"mt-3",onClick:()=>Qu.mutate(),disabled:Qu.isPending,children:[Qu.isPending?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(yi,{className:"w-4 h-4"}),"Install Update"]})]}):Yt?.error?s.jsxs("div",{className:"mt-2 p-2 bg-red-500/10 border border-red-500/30 rounded text-sm text-red-400",children:["Failed to check for updates: ",Yt.error]}):Yt&&!Yt.update_available?s.jsx("p",{className:"mt-2 text-sm text-bambu-gray",children:"You're running the latest version"}):null]})]})]}),s.jsxs(_t,{children:[s.jsx(Kn,{children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.dataManagement")})}),s.jsxs(Mt,{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:i("settings.clearNotificationLogs")}),s.jsx("p",{className:"text-sm text-bambu-gray",children:i("settings.clearNotificationLogsDescription")})]}),s.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>me(!0),children:[s.jsx(rn,{className:"w-4 h-4"}),i("common.clear")]})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:i("settings.resetUiPreferences")}),s.jsx("p",{className:"text-sm text-bambu-gray",children:i("settings.resetUiPreferencesDescription")})]}),s.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>z(!0),children:[s.jsx(rn,{className:"w-4 h-4"}),"Reset"]})]}),s.jsxs("div",{className:"flex items-center justify-between pt-4 border-t border-bambu-dark-tertiary",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:"Backup & Restore"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Export/import settings and configure GitHub backup"})]}),s.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>de("backup"),children:[s.jsx(Nu,{className:"w-4 h-4"}),"Go to Backup"]})]})]})]})]})]}),be==="network"&&E&&s.jsxs("div",{className:"flex flex-col lg:flex-row gap-6",children:[s.jsxs("div",{className:"flex-1 lg:max-w-xl space-y-4",children:[s.jsxs(_t,{children:[s.jsx(Kn,{children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(sh,{className:"w-5 h-5 text-blue-400"}),"External URL"]})}),s.jsxs(Mt,{className:"space-y-4",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"The external URL where Bambuddy is accessible. Used for notification images and external integrations."}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Bambuddy URL"}),s.jsx("input",{type:"text",value:E.external_url??"",onChange:oe=>hn("external_url",oe.target.value),placeholder:"http://192.168.1.100:8000",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Include protocol and port (e.g., http://192.168.1.100:8000)"})]})]})]}),s.jsxs(_t,{children:[s.jsx(Kn,{children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(Dr,{className:"w-5 h-5 text-blue-400"}),"FTP Retry"]})}),s.jsxs(Mt,{className:"space-y-4",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Retry FTP operations when printer WiFi is unreliable. Applies to 3MF downloads, print uploads, timelapse downloads, and firmware updates."}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:i("settings.enableRetry")}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically retry failed FTP operations"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:E.ftp_retry_enabled??!0,onChange:oe=>hn("ftp_retry_enabled",oe.target.checked),className:"sr-only peer"}),s.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),E.ftp_retry_enabled&&s.jsxs("div",{className:"space-y-4 pt-2 border-t border-bambu-dark-tertiary",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Retry attempts"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",min:"1",max:"10",value:E.ftp_retry_count??3,onChange:oe=>hn("ftp_retry_count",Math.min(10,Math.max(1,parseInt(oe.target.value)||3))),className:"w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),s.jsx("span",{className:"text-bambu-gray",children:"times"})]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Number of retry attempts before giving up (1-10)"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Retry delay"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",min:"1",max:"30",value:E.ftp_retry_delay??2,onChange:oe=>hn("ftp_retry_delay",Math.min(30,Math.max(1,parseInt(oe.target.value)||2))),className:"w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),s.jsx("span",{className:"text-bambu-gray",children:"seconds"})]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Wait time between retries (1-30)"})]})]}),s.jsxs("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Connection timeout"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",min:"10",max:"120",value:E.ftp_timeout??30,onChange:oe=>hn("ftp_timeout",Math.min(120,Math.max(10,parseInt(oe.target.value)||30))),className:"w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),s.jsx("span",{className:"text-bambu-gray",children:"seconds"})]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Socket timeout for slow connections. Increase for A1/A1 Mini printers with weak WiFi (10-120)"})]})]})]})]}),s.jsxs("div",{className:"flex-1 lg:max-w-xl space-y-4",children:[s.jsxs(_t,{children:[s.jsx(Kn,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(fN,{className:"w-5 h-5 text-bambu-green"}),"Home Assistant"]}),E.ha_enabled&&bn&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${bn.success?"bg-green-400":"bg-red-400"}`}),s.jsx("span",{className:`text-sm ${bn.success?"text-green-400":"text-red-400"}`,children:bn.success?"Connected":"Disconnected"})]})]})}),s.jsxs(Mt,{className:"space-y-4",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Connect to Home Assistant to control smart plugs via HA's REST API. Supports switch, light, input_boolean, and script entities."}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:i("settings.enableHomeAssistant")}),s.jsx("p",{className:"text-xs text-bambu-gray",children:i("settings.homeAssistantDescription")})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:E.ha_enabled??!1,onChange:oe=>hn("ha_enabled",oe.target.checked),className:"sr-only peer"}),s.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),E.ha_enabled&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Home Assistant URL"}),s.jsx("input",{type:"text",value:E.ha_url??"",onChange:oe=>hn("ha_url",oe.target.value),placeholder:"http://192.168.1.100:8123",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Long-Lived Access Token"}),s.jsx("input",{type:"password",value:E.ha_token??"",onChange:oe=>hn("ha_token",oe.target.value),placeholder:"eyJ0eXAiOiJKV1QiLC...",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Create a token in HA: Profile → Long-Lived Access Tokens → Create Token"})]}),E.ha_url&&E.ha_token&&s.jsx("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:s.jsxs(Te,{variant:"secondary",size:"sm",disabled:Ba,onClick:async()=>{Ae(!0),wi(null);try{const oe=await ue.testHAConnection(E.ha_url,E.ha_token);wi(oe)}catch(oe){wi({success:!1,message:null,error:oe instanceof Error?oe.message:i("common.unknownError")})}finally{Ae(!1)}},children:[Ba?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(Sg,{className:"w-4 h-4"}),i("settings.testConnection")]})})]})]})]}),s.jsxs(_t,{children:[s.jsx(Kn,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(Sg,{className:"w-5 h-5 text-blue-400"}),"MQTT Publishing"]}),cr?.enabled&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${cr.connected?"bg-green-400":"bg-red-400"}`}),s.jsx("span",{className:`text-sm ${cr.connected?"text-green-400":"text-red-400"}`,children:cr.connected?"Connected":"Disconnected"})]})]})}),s.jsxs(Mt,{className:"space-y-4",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Publish BamBuddy events to an external MQTT broker for integration with Node-RED, Home Assistant, and other automation systems."}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:i("settings.enableMqtt")}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Publish events to external MQTT broker"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:E.mqtt_enabled??!1,onChange:oe=>hn("mqtt_enabled",oe.target.checked),className:"sr-only peer"}),s.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),E.mqtt_enabled&&s.jsxs("div",{className:"space-y-4 pt-2 border-t border-bambu-dark-tertiary",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Broker hostname"}),s.jsx("input",{type:"text",value:E.mqtt_broker??"",onChange:oe=>hn("mqtt_broker",oe.target.value),placeholder:"mqtt.example.com or 192.168.1.100",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{className:"flex items-end gap-4",children:[s.jsxs("div",{className:"flex-1",children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Port"}),s.jsx("input",{type:"number",min:"1",max:"65535",value:E.mqtt_port??1883,onChange:oe=>hn("mqtt_port",Math.min(65535,Math.max(1,parseInt(oe.target.value)||1883))),className:"w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{className:"flex items-center gap-3 pb-2",children:[s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:E.mqtt_use_tls??!1,onChange:oe=>{const wt=oe.target.checked;hn("mqtt_use_tls",wt);const Rn=E.mqtt_port??1883;wt&&Rn===1883?hn("mqtt_port",8883):!wt&&Rn===8883&&hn("mqtt_port",1883)},className:"sr-only peer"}),s.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]}),s.jsx("span",{className:"text-white text-sm",children:i("settings.useTls")})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Username (optional)"}),s.jsx("input",{type:"text",value:E.mqtt_username??"",onChange:oe=>hn("mqtt_username",oe.target.value),placeholder:i("settings.leaveEmptyForAnonymous"),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Password (optional)"}),s.jsx("input",{type:"password",value:E.mqtt_password??"",onChange:oe=>hn("mqtt_password",oe.target.value),placeholder:i("settings.leaveEmptyForAnonymous"),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Topic prefix"}),s.jsx("input",{type:"text",value:E.mqtt_topic_prefix??"bambuddy",onChange:oe=>hn("mqtt_topic_prefix",oe.target.value),placeholder:"bambuddy",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),s.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:["Topics will be: ",E.mqtt_topic_prefix||"bambuddy","/printers/<serial>/status, etc."]})]}),cr&&s.jsx("div",{className:"pt-3 mt-3 border-t border-bambu-dark-tertiary",children:s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx("span",{className:`w-2 h-2 rounded-full ${cr.connected?"bg-green-400":"bg-red-400"}`}),s.jsx("span",{className:"text-bambu-gray",children:cr.connected?s.jsxs(s.Fragment,{children:[i("settings.mqttConnectedTo")," ",s.jsxs("span",{className:"text-white",children:[cr.broker,":",cr.port]})]}):i("settings.spoolmanDisconnected")})]})})]})]})]})]}),s.jsx("div",{className:"flex-1 lg:max-w-md space-y-4",children:s.jsxs(_t,{children:[s.jsx(Kn,{children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(yP,{className:"w-5 h-5 text-orange-400"}),"Prometheus Metrics"]})}),s.jsxs(Mt,{className:"space-y-4",children:[s.jsxs("p",{className:"text-sm text-bambu-gray",children:["Expose printer metrics at ",s.jsx("code",{className:"bg-bambu-dark px-1 rounded",children:"/api/v1/metrics"})," for Prometheus/Grafana monitoring."]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:i("settings.enableMetricsEndpoint")}),s.jsx("p",{className:"text-xs text-bambu-gray",children:i("settings.prometheusDescription")})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:E.prometheus_enabled??!1,onChange:oe=>hn("prometheus_enabled",oe.target.checked),className:"sr-only peer"}),s.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),E.prometheus_enabled&&s.jsxs("div",{className:"space-y-4 pt-2 border-t border-bambu-dark-tertiary",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Bearer Token (optional)"}),s.jsx("input",{type:"password",value:E.prometheus_token??"",onChange:oe=>hn("prometheus_token",oe.target.value),placeholder:i("settings.leaveEmptyForNoAuth"),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),s.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:["If set, requests must include ",s.jsx("code",{className:"bg-bambu-dark px-1 rounded",children:"Authorization: Bearer <token>"})]})]}),s.jsxs("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:[s.jsx("p",{className:"text-sm text-white mb-2",children:i("settings.availableMetrics")}),s.jsxs("div",{className:"text-xs text-bambu-gray space-y-1",children:[s.jsxs("p",{children:[s.jsx("code",{className:"text-orange-400",children:"bambuddy_printer_connected"})," - Connection status"]}),s.jsxs("p",{children:[s.jsx("code",{className:"text-orange-400",children:"bambuddy_printer_state"})," - Printer state (idle/printing/etc)"]}),s.jsxs("p",{children:[s.jsx("code",{className:"text-orange-400",children:"bambuddy_print_progress"})," - Print progress 0-100%"]}),s.jsxs("p",{children:[s.jsx("code",{className:"text-orange-400",children:"bambuddy_bed_temp_celsius"})," - Bed temperature"]}),s.jsxs("p",{children:[s.jsx("code",{className:"text-orange-400",children:"bambuddy_nozzle_temp_celsius"})," - Nozzle temperature"]}),s.jsxs("p",{children:[s.jsx("code",{className:"text-orange-400",children:"bambuddy_prints_total"})," - Total prints by result"]}),s.jsx("p",{className:"text-bambu-gray/70 italic",children:"...and more (layers, fans, queue, filament usage)"})]})]})]})]})]})})]}),bn&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg p-6 max-w-md w-full mx-4",children:[s.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[bn.success?s.jsx(Ar,{className:"w-8 h-8 text-green-400"}):s.jsx(Yi,{className:"w-8 h-8 text-red-400"}),s.jsx("h3",{className:"text-lg font-medium text-white",children:bn.success?"Connection Successful":"Connection Failed"})]}),s.jsx("p",{className:"text-bambu-gray mb-6",children:bn.success?bn.message||"Successfully connected to Home Assistant.":bn.error||"Failed to connect to Home Assistant."}),s.jsx("div",{className:"flex justify-end",children:s.jsx(Te,{variant:"primary",onClick:()=>wi(null),children:"OK"})})]})}),be==="plugs"&&s.jsxs("div",{className:"max-w-4xl",children:[s.jsxs("div",{className:"flex items-start justify-between mb-6",children:[s.jsxs("div",{children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(tl,{className:"w-5 h-5 text-bambu-green"}),"Smart Plugs"]}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Connect smart plugs (Tasmota or Home Assistant) to automate power control and track energy usage for your printers."})]}),s.jsxs("div",{className:"flex items-center gap-2 pt-1 shrink-0",children:[Le&&Le.filter(oe=>oe.enabled).length>1&&s.jsxs(s.Fragment,{children:[s.jsxs(Te,{variant:"secondary",size:"sm",className:"whitespace-nowrap",onClick:()=>ee("on"),disabled:Vl.isPending,title:i("settings.turnAllPlugsOn"),children:[Vl.isPending?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(Gu,{className:"w-4 h-4 text-bambu-green"}),"All On"]}),s.jsxs(Te,{variant:"secondary",size:"sm",className:"whitespace-nowrap",onClick:()=>ee("off"),disabled:Vl.isPending,title:i("settings.turnAllPlugsOff"),children:[Vl.isPending?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(gN,{className:"w-4 h-4 text-red-400"}),"All Off"]})]}),s.jsxs(Te,{className:"whitespace-nowrap",onClick:()=>{F(null),R(!0)},children:[s.jsx(dr,{className:"w-4 h-4"}),"Add Smart Plug"]})]})]}),Le&&Le.length>0&&s.jsxs(_t,{className:"mb-6",children:[s.jsx(Kn,{children:s.jsxs("h3",{className:"text-base font-semibold text-white flex items-center gap-2",children:[s.jsx(vh,{className:"w-4 h-4 text-yellow-400"}),"Energy Summary",St&&s.jsx(ht,{className:"w-4 h-4 animate-spin text-bambu-gray ml-2"})]})}),s.jsx(Mt,{children:ut?s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[s.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[s.jsx(vh,{className:"w-3 h-3"}),"Current Power"]}),s.jsxs("div",{className:"text-xl font-bold text-white",children:[ut.totalPower.toFixed(1),s.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"W"})]}),s.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:[ut.reachableCount,"/",ut.totalPlugs," plugs online"]})]}),s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[s.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[s.jsx(si,{className:"w-3 h-3"}),"Today"]}),s.jsxs("div",{className:"text-xl font-bold text-white",children:[ut.totalToday.toFixed(2),s.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),E&&E.energy_cost_per_kwh>0&&s.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(ut.totalToday*E.energy_cost_per_kwh).toFixed(2)," ",E.currency]})]}),s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[s.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[s.jsx(yP,{className:"w-3 h-3"}),"Yesterday"]}),s.jsxs("div",{className:"text-xl font-bold text-white",children:[ut.totalYesterday.toFixed(2),s.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),E&&E.energy_cost_per_kwh>0&&s.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(ut.totalYesterday*E.energy_cost_per_kwh).toFixed(2)," ",E.currency]})]}),s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[s.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[s.jsx(hP,{className:"w-3 h-3"}),"Total"]}),s.jsxs("div",{className:"text-xl font-bold text-white",children:[ut.totalLifetime.toFixed(1),s.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),E&&E.energy_cost_per_kwh>0&&s.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(ut.totalLifetime*E.energy_cost_per_kwh).toFixed(2)," ",E.currency]})]})]}):St?null:s.jsx("p",{className:"text-sm text-bambu-gray",children:"Enable plugs to see energy summary"})})]}),Ce?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(ht,{className:"w-8 h-8 text-bambu-green animate-spin"})}):Le&&Le.length>0?s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Le.map(oe=>s.jsx(rKe,{plug:oe,onEdit:wt=>{F(wt),R(!0)}},oe.id))}):s.jsx(_t,{children:s.jsx(Mt,{className:"py-12",children:s.jsxs("div",{className:"text-center text-bambu-gray",children:[s.jsx(tl,{className:"w-16 h-16 mx-auto mb-4 opacity-30"}),s.jsx("p",{className:"text-lg font-medium text-white mb-2",children:i("settings.noSmartPlugsTitle")}),s.jsx("p",{className:"text-sm mb-4",children:i("settings.noSmartPlugsDescription")}),s.jsxs(Te,{onClick:()=>{F(null),R(!0)},children:[s.jsx(dr,{className:"w-4 h-4"}),i("settings.addFirstSmartPlug")]})]})})})]}),be==="notifications"&&s.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(wg,{className:"w-5 h-5 text-bambu-green"}),i("settings.providers")]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(Te,{size:"sm",variant:"secondary",onClick:()=>ae(!0),children:[s.jsx(q0,{className:"w-4 h-4"}),i("settings.log")]}),At&&At.length>0&&s.jsxs(Te,{size:"sm",variant:"secondary",onClick:()=>{ca(null),pl.mutate()},disabled:pl.isPending,children:[pl.isPending?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(PR,{className:"w-4 h-4"}),i("settings.testAll")]}),s.jsxs(Te,{size:"sm",onClick:()=>{K(null),j(!0)},children:[s.jsx(dr,{className:"w-4 h-4"}),"Add"]})]})]}),s.jsx(_t,{className:"mb-4",children:s.jsx(Mt,{className:"py-3",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white text-sm font-medium",children:i("settings.notificationLanguage")}),s.jsx("p",{className:"text-xs text-bambu-gray",children:i("settings.notificationLanguageDescription")})]}),s.jsx("select",{value:E.notification_language||"en",onChange:oe=>hn("notification_language",oe.target.value),className:"px-2 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:outline-none focus:ring-1 focus:ring-bambu-green",children:mz.map(oe=>s.jsx("option",{value:oe.code,children:oe.nativeName},oe.code))})]})})}),Cc&&s.jsx(_t,{className:"mb-4",children:s.jsxs(Mt,{className:"py-3",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("span",{className:"text-sm font-medium text-white",children:i("settings.testResults")}),s.jsx("button",{onClick:()=>ca(null),className:"text-bambu-gray hover:text-white text-xs",children:i("common.dismiss")})]}),s.jsxs("div",{className:"flex items-center gap-4 text-sm mb-2",children:[s.jsxs("span",{className:"flex items-center gap-1 text-bambu-green",children:[s.jsx(Ar,{className:"w-4 h-4"}),i("settings.testPassedCount",{count:Cc.success})]}),Cc.failed>0&&s.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[s.jsx(Yi,{className:"w-4 h-4"}),i("settings.testFailedCount",{count:Cc.failed})]})]}),Cc.results.filter(oe=>!oe.success).length>0&&s.jsx("div",{className:"space-y-1 mt-2 pt-2 border-t border-bambu-dark-tertiary",children:Cc.results.filter(oe=>!oe.success).map(oe=>s.jsxs("div",{className:"text-xs text-red-400",children:[s.jsxs("span",{className:"font-medium",children:[oe.provider_name,":"]})," ",oe.message]},oe.provider_id))})]})}),Tt?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(ht,{className:"w-6 h-6 text-bambu-green animate-spin"})}):At&&At.length>0?s.jsx("div",{className:"space-y-3",children:At.map(oe=>s.jsx(sKe,{provider:oe,onEdit:wt=>{K(wt),j(!0)}},oe.id))}):s.jsx(_t,{children:s.jsx(Mt,{className:"py-8",children:s.jsxs("div",{className:"text-center text-bambu-gray",children:[s.jsx(wg,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),s.jsx("p",{className:"text-sm font-medium text-white mb-2",children:i("settings.noProvidersTitle")}),s.jsx("p",{className:"text-xs mb-3",children:i("settings.noProvidersDescription")}),s.jsxs(Te,{size:"sm",onClick:()=>{K(null),j(!0)},children:[s.jsx(dr,{className:"w-4 h-4"}),i("settings.addProvider")]})]})})})]}),s.jsxs("div",{children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2 mb-4",children:[s.jsx(Ls,{className:"w-5 h-5 text-bambu-green"}),i("settings.messageTemplates")]}),s.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:i("settings.messageTemplatesDescription")}),cn?s.jsx("div",{className:"flex justify-center py-8",children:s.jsx(ht,{className:"w-6 h-6 text-bambu-green animate-spin"})}):dn&&dn.length>0?s.jsx("div",{className:"space-y-2",children:dn.map(oe=>s.jsx(_t,{className:"cursor-pointer hover:border-bambu-green/50 transition-colors",onClick:()=>Q(oe),children:s.jsx(Mt,{className:"py-2.5 px-3",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"text-white font-medium text-sm truncate",children:oe.name}),s.jsx("p",{className:"text-bambu-gray text-xs truncate mt-0.5",children:oe.title_template})]}),s.jsx("button",{className:"p-1.5 hover:bg-bambu-dark-tertiary rounded transition-colors shrink-0 ml-2",onClick:wt=>{wt.stopPropagation(),Q(oe)},children:s.jsx(fg,{className:"w-4 h-4 text-bambu-gray"})})]})})},oe.id))}):s.jsx(_t,{children:s.jsx(Mt,{className:"py-8",children:s.jsxs("div",{className:"text-center text-bambu-gray",children:[s.jsx(Ls,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),s.jsx("p",{className:"text-sm",children:i("settings.noTemplatesAvailable")})]})})})]})]}),be==="apikeys"&&s.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-2 gap-8",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-start justify-between gap-4 mb-6",children:[s.jsxs("div",{className:"flex-1",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx($o,{className:"w-5 h-5 text-bambu-green"}),i("settings.apiKeys")]}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:i("settings.apiKeysDescription")})]}),s.jsxs(Te,{size:"sm",onClick:()=>ie(!0),className:"flex-shrink-0",children:[s.jsx(dr,{className:"w-4 h-4"}),i("settings.createKey")]})]}),G&&s.jsx(_t,{className:"mb-6 border-bambu-green",children:s.jsx(Mt,{className:"py-4",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(Ar,{className:"w-5 h-5 text-bambu-green flex-shrink-0 mt-0.5"}),s.jsxs("div",{className:"flex-1",children:[s.jsx("p",{className:"text-white font-medium mb-1",children:i("settings.apiKeyCreated")}),s.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:i("settings.apiKeyCopyWarning")}),s.jsxs("div",{className:"flex items-center gap-2 bg-bambu-dark rounded-lg p-2",children:[s.jsx("code",{className:"flex-1 text-sm text-bambu-green font-mono break-all",children:G}),s.jsx(Te,{variant:"secondary",size:"sm",onClick:async()=>{try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(G);else{const oe=document.createElement("textarea");oe.value=G,oe.style.position="fixed",oe.style.left="-999999px",document.body.appendChild(oe),oe.select(),document.execCommand("copy"),document.body.removeChild(oe)}o(i("settings.toast.keyCopied"))}catch{o(i("settings.toast.copyFailed"),"error")}},children:s.jsx(Fl,{className:"w-4 h-4"})})]}),s.jsxs("div",{className:"flex gap-2 mt-3",children:[s.jsx(Te,{variant:"secondary",size:"sm",onClick:()=>{I(G),o(i("settings.toast.keyAddedToBrowser"))},children:i("settings.useInApiBrowser")}),s.jsx(Te,{variant:"secondary",size:"sm",onClick:()=>Y(null),children:i("common.dismiss")})]})]})]})})}),Pe&&s.jsxs(_t,{className:"mb-6",children:[s.jsx(Kn,{children:s.jsx("h3",{className:"text-base font-semibold text-white",children:i("settings.createNewApiKey")})}),s.jsxs(Mt,{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:i("settings.keyName")}),s.jsx("input",{type:"text",value:Ne,onChange:oe=>Oe(oe.target.value),placeholder:i("settings.keyNamePlaceholder"),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:i("common.permissions")}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:ge.can_read_status,onChange:oe=>Ke(wt=>({...wt,can_read_status:oe.target.checked})),className:"w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green"}),s.jsxs("div",{children:[s.jsx("span",{className:"text-white",children:i("settings.readStatus")}),s.jsx("p",{className:"text-xs text-bambu-gray",children:i("settings.readStatusDescription")})]})]}),s.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:ge.can_queue,onChange:oe=>Ke(wt=>({...wt,can_queue:oe.target.checked})),className:"w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green"}),s.jsxs("div",{children:[s.jsx("span",{className:"text-white",children:i("settings.manageQueue")}),s.jsx("p",{className:"text-xs text-bambu-gray",children:i("settings.manageQueueDescription")})]})]}),s.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:ge.can_control_printer,onChange:oe=>Ke(wt=>({...wt,can_control_printer:oe.target.checked})),className:"w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green"}),s.jsxs("div",{children:[s.jsx("span",{className:"text-white",children:i("settings.controlPrinter")}),s.jsx("p",{className:"text-xs text-bambu-gray",children:i("settings.controlPrinterDescription")})]})]})]})]}),s.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[s.jsxs(Te,{onClick:()=>Nt.mutate({name:Ne||i("settings.unnamedKey"),...ge}),disabled:Nt.isPending,children:[Nt.isPending?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(dr,{className:"w-4 h-4"}),i("settings.createKey")]}),s.jsx(Te,{variant:"secondary",onClick:()=>ie(!1),children:i("common.cancel")})]})]})]}),Pt?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(ht,{className:"w-8 h-8 text-bambu-green animate-spin"})}):Ft&&Ft.length>0?s.jsx("div",{className:"space-y-3",children:Ft.map(oe=>s.jsx(_t,{children:s.jsx(Mt,{className:"py-3",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx($o,{className:`w-5 h-5 ${oe.enabled?"text-bambu-green":"text-bambu-gray"}`}),s.jsxs("div",{children:[s.jsx("p",{className:"text-white font-medium",children:oe.name}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[oe.key_prefix,"••••••••",oe.last_used&&` · ${i("settings.lastUsed")}: ${Bg(oe.last_used)}`]})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"flex gap-1 text-xs",children:[oe.can_read_status&&s.jsx("span",{className:"px-1.5 py-0.5 bg-blue-500/20 text-blue-400 rounded",children:i("settings.read")}),oe.can_queue&&s.jsx("span",{className:"px-1.5 py-0.5 bg-green-500/20 text-green-400 rounded",children:i("queue.title")}),oe.can_control_printer&&s.jsx("span",{className:"px-1.5 py-0.5 bg-orange-500/20 text-orange-400 rounded",children:i("settings.control")})]}),s.jsx(Te,{variant:"secondary",size:"sm",onClick:()=>q(oe.id),children:s.jsx(rn,{className:"w-4 h-4 text-red-400"})})]})]})})},oe.id))}):s.jsx(_t,{children:s.jsx(Mt,{className:"py-12",children:s.jsxs("div",{className:"text-center text-bambu-gray",children:[s.jsx($o,{className:"w-16 h-16 mx-auto mb-4 opacity-30"}),s.jsx("p",{className:"text-lg font-medium text-white mb-2",children:i("settings.apiKeysEmptyTitle")}),s.jsx("p",{className:"text-sm mb-4",children:i("settings.apiKeysEmptyDescription")}),s.jsxs(Te,{onClick:()=>ie(!0),children:[s.jsx(dr,{className:"w-4 h-4"}),i("settings.createFirstKey")]})]})})}),s.jsxs(_t,{className:"mt-6",children:[s.jsx(Kn,{children:s.jsx("h3",{className:"text-base font-semibold text-white",children:i("settings.webhookEndpoints")})}),s.jsxs(Mt,{className:"space-y-3 text-sm",children:[s.jsx("p",{className:"text-bambu-gray",children:i("settings.webhookApiKeyHint")}),s.jsxs("div",{className:"space-y-2 font-mono text-xs",children:[s.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[s.jsx("span",{className:"text-blue-400",children:"GET"})," ",s.jsx("span",{className:"text-white",children:"/api/v1/webhook/status"}),s.jsxs("span",{className:"text-bambu-gray",children:[" - ",i("settings.webhook.getAllStatus")]})]}),s.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[s.jsx("span",{className:"text-blue-400",children:"GET"})," ",s.jsx("span",{className:"text-white",children:"/api/v1/webhook/status/:id"}),s.jsxs("span",{className:"text-bambu-gray",children:[" - ",i("settings.webhook.getSpecificStatus")]})]}),s.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[s.jsx("span",{className:"text-green-400",children:"POST"})," ",s.jsx("span",{className:"text-white",children:"/api/v1/webhook/queue"}),s.jsxs("span",{className:"text-bambu-gray",children:[" - ",i("settings.webhook.addToQueue")]})]}),s.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[s.jsx("span",{className:"text-orange-400",children:"POST"})," ",s.jsx("span",{className:"text-white",children:"/api/v1/webhook/printer/:id/pause"}),s.jsxs("span",{className:"text-bambu-gray",children:[" - ",i("settings.webhook.pausePrint")]})]}),s.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[s.jsx("span",{className:"text-orange-400",children:"POST"})," ",s.jsx("span",{className:"text-white",children:"/api/v1/webhook/printer/:id/resume"}),s.jsxs("span",{className:"text-bambu-gray",children:[" - ",i("settings.webhook.resumePrint")]})]}),s.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[s.jsx("span",{className:"text-red-400",children:"POST"})," ",s.jsx("span",{className:"text-white",children:"/api/v1/webhook/printer/:id/stop"}),s.jsxs("span",{className:"text-bambu-gray",children:[" - ",i("settings.webhook.stopPrint")]})]})]})]})]})]}),s.jsxs("div",{children:[s.jsxs("div",{className:"mb-6",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(sh,{className:"w-5 h-5 text-bambu-green"}),i("settings.apiBrowser")]}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:i("settings.apiBrowserDescription")})]}),s.jsx(_t,{className:"mb-4",children:s.jsxs(Mt,{className:"py-3",children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:i("settings.apiKeyForTesting")}),s.jsx("input",{type:"text",value:te,onChange:oe=>I(oe.target.value),placeholder:i("settings.apiKeyPlaceholder"),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white font-mono text-sm focus:border-bambu-green focus:outline-none"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-2",children:i("settings.apiKeyHint")})]})}),s.jsx(MKe,{apiKey:te})]})]}),be==="virtual-printer"&&s.jsx(bKe,{}),be==="filament"&&E&&s.jsxs("div",{className:"flex flex-col lg:flex-row gap-6 lg:gap-8",children:[s.jsx("div",{className:"flex-1 lg:max-w-xl",children:s.jsxs(_t,{children:[s.jsx(Kn,{children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.amsDisplayThresholds")})}),s.jsxs(Mt,{className:"space-y-4",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:i("settings.amsThresholdsDescription")}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center gap-2 text-white",children:[s.jsx(AR,{className:"w-4 h-4 text-blue-400"}),s.jsx("span",{className:"font-medium",children:i("settings.humidity")})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[i("settings.goodGreen")," ≤"]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",min:"0",max:"100",value:E.ams_humidity_good??40,onChange:oe=>hn("ams_humidity_good",parseInt(oe.target.value)||40),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),s.jsx("span",{className:"text-bambu-gray",children:"%"})]})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[i("settings.fairOrange")," ≤"]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",min:"0",max:"100",value:E.ams_humidity_fair??60,onChange:oe=>hn("ams_humidity_fair",parseInt(oe.target.value)||60),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),s.jsx("span",{className:"text-bambu-gray",children:"%"})]})]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:i("settings.aboveFairBad")})]}),s.jsxs("div",{className:"space-y-3 pt-2 border-t border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2 text-white",children:[s.jsx(bN,{className:"w-4 h-4 text-orange-400"}),s.jsx("span",{className:"font-medium",children:i("settings.temperature")})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[i("settings.goodBlue")," ≤"]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",step:"0.5",min:"0",max:"60",value:E.ams_temp_good??28,onChange:oe=>hn("ams_temp_good",parseFloat(oe.target.value)||28),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),s.jsx("span",{className:"text-bambu-gray",children:"°C"})]})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[i("settings.fairOrange")," ≤"]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",step:"0.5",min:"0",max:"60",value:E.ams_temp_fair??35,onChange:oe=>hn("ams_temp_fair",parseFloat(oe.target.value)||35),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),s.jsx("span",{className:"text-bambu-gray",children:"°C"})]})]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:i("settings.aboveFairHot")})]}),s.jsxs("div",{className:"space-y-3 pt-4 border-t border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2 text-white",children:[s.jsx(Nu,{className:"w-4 h-4 text-purple-400"}),s.jsx("span",{className:"font-medium",children:i("settings.historyRetention")})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:i("settings.keepSensorHistory")}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",min:"1",max:"365",value:E.ams_history_retention_days??30,onChange:oe=>hn("ams_history_retention_days",parseInt(oe.target.value)||30),className:"w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),s.jsx("span",{className:"text-bambu-gray",children:i("common.days")})]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:i("settings.historyRetentionDescription")})]}),s.jsxs("div",{className:"space-y-3 pt-4 border-t border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2 text-white",children:[s.jsx(Ur,{className:"w-4 h-4 text-bambu-green"}),s.jsx("span",{className:"font-medium",children:i("settings.printModal")})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-white",children:i("settings.expandCustomMapping")}),s.jsx("p",{className:"text-xs text-bambu-gray mt-0.5",children:i("settings.expandCustomMappingDescription")})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:E.per_printer_mapping_expanded??!1,onChange:oe=>hn("per_printer_mapping_expanded",oe.target.checked),className:"sr-only peer"}),s.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]})]})]})]})}),s.jsx("div",{className:"flex-1 lg:max-w-xl",children:s.jsx(pKe,{})})]}),ce!==null&&s.jsx(Zn,{title:i("settings.deleteApiKeyTitle"),message:i("settings.deleteApiKeyMessage"),confirmText:i("settings.deleteKey"),variant:"danger",onConfirm:()=>{en.mutate(ce),q(null)},onCancel:()=>q(null)}),A&&s.jsx(iKe,{plug:U,onClose:()=>{R(!1),F(null)}}),$&&s.jsx(oKe,{provider:H,onClose:()=>{j(!1),K(null)}}),V&&s.jsx(lKe,{template:V,onClose:()=>Q(null)}),Z&&s.jsx(dKe,{onClose:()=>ae(!1)}),fe&&s.jsx(Zn,{title:i("settings.clearNotificationLogs"),message:i("settings.clearLogsMessage"),confirmText:i("settings.clearLogs"),variant:"warning",onConfirm:async()=>{me(!1);try{const oe=await ue.clearNotificationLogs(30);o(oe.message,"success")}catch{o(i("settings.toast.clearLogsFailed"),"error")}},onCancel:()=>me(!1)}),Ee&&s.jsx(Zn,{title:i("settings.resetUiPreferences"),message:i("settings.resetUiPreferencesMessage"),confirmText:i("settings.resetPreferences"),variant:"default",onConfirm:()=>{z(!1),localStorage.clear(),o(i("settings.toast.uiPreferencesReset"),"success"),setTimeout(()=>window.location.reload(),1e3)},onCancel:()=>z(!1)}),O&&s.jsx(Zn,{title:`Turn All Plugs ${O==="on"?"On":"Off"}`,message:`This will turn ${O==="on"?"ON":"OFF"} all ${Le?.filter(oe=>oe.enabled).length||0} enabled smart plugs. ${O==="off"?"Any running printers may be affected!":""}`,confirmText:`Turn All ${O==="on"?"On":"Off"}`,variant:O==="off"?"danger":"warning",onConfirm:()=>{const oe=O;ee(null),Vl.mutate(oe)},onCancel:()=>ee(null)}),le&&Yt?.release_notes&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:()=>_e(!1),children:s.jsxs(_t,{className:"w-full max-w-2xl max-h-[80vh] flex flex-col",onClick:oe=>oe.stopPropagation(),children:[s.jsxs(Kn,{className:"flex flex-row items-center justify-between shrink-0",children:[s.jsxs("div",{children:[s.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Release Notes - v",Yt.latest_version]}),Yt.release_name&&Yt.release_name!==Yt.latest_version&&s.jsx("p",{className:"text-sm text-bambu-gray",children:Yt.release_name})]}),s.jsx("button",{onClick:()=>_e(!1),className:"p-1 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white",children:s.jsx(Rt,{className:"w-5 h-5"})})]}),s.jsx(Mt,{className:"overflow-y-auto flex-1",children:s.jsx("pre",{className:"text-sm text-bambu-gray whitespace-pre-wrap font-sans",children:Yt.release_notes})}),s.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary shrink-0 flex gap-2",children:[Yt.release_url&&s.jsx("a",{href:Yt.release_url,target:"_blank",rel:"noopener noreferrer",className:"flex-1",children:s.jsxs(Te,{variant:"secondary",className:"w-full",children:[s.jsx(Kr,{className:"w-4 h-4"}),"View on GitHub"]})}),s.jsx(Te,{onClick:()=>_e(!1),className:"flex-1",children:"Close"})]})]})}),be==="users"&&s.jsxs("div",{className:"space-y-6",children:[s.jsx(_t,{children:s.jsx(Mt,{className:"py-4",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:`w-10 h-10 rounded-full flex items-center justify-center ${l?"bg-green-500/20":"bg-gray-500/20"}`,children:l?s.jsx(nT,{className:"w-5 h-5 text-green-400"}):s.jsx(tT,{className:"w-5 h-5 text-gray-400"})}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-white font-medium",children:i("settings.authentication")}),s.jsx("p",{className:"text-sm text-bambu-gray",children:i(l?"settings.authEnabledDescription":"settings.authDisabledDescription")})]})]}),l?c?.is_admin&&s.jsxs(Te,{variant:"secondary",onClick:()=>re(!0),children:[s.jsx(tT,{className:"w-4 h-4"}),i("common.disable")]}):s.jsxs(Te,{onClick:()=>e("/setup"),children:[s.jsx(nT,{className:"w-4 h-4"}),i("common.enable")]})]})})}),l&&s.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-2 gap-6",children:[s.jsxs("div",{className:"space-y-6",children:[c&&s.jsxs(_t,{children:[s.jsx(Kn,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("h3",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(mg,{className:"w-5 h-5 text-bambu-green"}),i("settings.currentUser")]}),s.jsxs(Te,{size:"sm",variant:"ghost",onClick:()=>He(!0),children:[s.jsx($o,{className:"w-4 h-4"}),i("settings.changePassword")]})]})}),s.jsx(Mt,{children:s.jsx("div",{className:"flex items-center justify-between",children:s.jsxs("div",{children:[s.jsx("p",{className:"text-white font-medium text-lg",children:c.username}),s.jsxs("div",{className:"flex flex-wrap gap-1 mt-2",children:[c.is_admin&&s.jsx("span",{className:"px-2 py-0.5 rounded-full text-xs font-medium bg-purple-500/20 text-purple-300",children:i("settings.admin")}),c.groups?.map(oe=>s.jsx("span",{className:`px-2 py-0.5 rounded-full text-xs font-medium ${oe.name==="Administrators"?"bg-purple-500/20 text-purple-300":oe.name==="Operators"?"bg-blue-500/20 text-blue-300":oe.name==="Viewers"?"bg-green-500/20 text-green-300":"bg-gray-500/20 text-gray-300"}`,children:oe.name},oe.id))]})]})})})]}),s.jsxs(_t,{children:[s.jsx(Kn,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("h3",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(mg,{className:"w-5 h-5 text-bambu-green"}),i("settings.users")]}),qt("users:create")&&s.jsxs(Te,{size:"sm",onClick:()=>{Se(!0),Bt({username:"",password:"",confirmPassword:"",role:"user",group_ids:[]})},children:[s.jsx(dr,{className:"w-4 h-4"}),i("settings.addUser")]})]})}),s.jsx(Mt,{children:wn?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx(ht,{className:"w-6 h-6 text-bambu-green animate-spin"})}):yt.length===0?s.jsx("p",{className:"text-center text-bambu-gray py-8",children:i("settings.noUsersFound")}):s.jsx("div",{className:"divide-y divide-bambu-dark-tertiary",children:yt.map(oe=>s.jsxs("div",{className:"py-3 flex items-center justify-between",children:[s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-white font-medium truncate",children:oe.username}),s.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[oe.is_admin&&s.jsx("span",{className:"px-2 py-0.5 rounded-full text-xs font-medium bg-purple-500/20 text-purple-300",children:i("settings.admin")}),oe.groups?.map(wt=>s.jsx("span",{className:`px-2 py-0.5 rounded-full text-xs font-medium ${wt.name==="Administrators"?"bg-purple-500/20 text-purple-300":wt.name==="Operators"?"bg-blue-500/20 text-blue-300":wt.name==="Viewers"?"bg-green-500/20 text-green-300":"bg-gray-500/20 text-gray-300"}`,children:wt.name},wt.id))]})]}),s.jsxs("div",{className:"flex items-center gap-1 ml-4",children:[qt("users:update")&&s.jsx(Te,{size:"sm",variant:"ghost",onClick:()=>Si(oe),children:s.jsx(fg,{className:"w-4 h-4"})}),qt("users:delete")&&oe.id!==c?.id&&s.jsx(Te,{size:"sm",variant:"ghost",onClick:()=>_i(oe.id),children:s.jsx(rn,{className:"w-4 h-4"})})]})]},oe.id))})})]})]}),s.jsx("div",{children:s.jsxs(_t,{children:[s.jsx(Kn,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("h3",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(rT,{className:"w-5 h-5 text-bambu-green"}),i("settings.groups")]}),qt("groups:create")&&s.jsxs(Te,{size:"sm",onClick:()=>{vn(!0),la()},children:[s.jsx(dr,{className:"w-4 h-4"}),i("settings.addGroup")]})]})}),s.jsx(Mt,{children:Yr?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx(ht,{className:"w-6 h-6 text-bambu-green animate-spin"})}):Fr.length===0?s.jsx("p",{className:"text-center text-bambu-gray py-8",children:i("settings.noGroupsFound")}):s.jsx("div",{className:"divide-y divide-bambu-dark-tertiary",children:Fr.map(oe=>s.jsxs("div",{className:"py-3",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(rT,{className:`w-4 h-4 ${oe.name==="Administrators"?"text-purple-400":oe.name==="Operators"?"text-blue-400":oe.name==="Viewers"?"text-green-400":"text-bambu-gray"}`}),s.jsx("span",{className:"text-white font-medium",children:oe.name}),oe.is_system&&s.jsx("span",{className:"px-2 py-0.5 rounded text-xs bg-yellow-500/20 text-yellow-400",children:i("settings.system")})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[qt("groups:update")&&s.jsx(Te,{size:"sm",variant:"ghost",onClick:()=>$h(oe),children:s.jsx(fg,{className:"w-4 h-4"})}),qt("groups:delete")&&!oe.is_system&&s.jsx(Te,{size:"sm",variant:"ghost",onClick:()=>Dn(oe.id),children:s.jsx(rn,{className:"w-4 h-4"})})]})]}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1 ml-6",children:oe.description||i("settings.noDescription")}),s.jsxs("div",{className:"flex items-center gap-4 mt-2 ml-6 text-xs text-bambu-gray",children:[s.jsx("span",{children:i("settings.userCount",{count:oe.user_count})}),s.jsx("span",{children:i("settings.permissionCount",{count:oe.permissions.length})})]})]},oe.id))})})]})})]}),!l&&s.jsx(_t,{children:s.jsx(Mt,{className:"py-6",children:s.jsxs("div",{className:"text-center",children:[s.jsx(tT,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),s.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:i("settings.authDisabledTitle")}),s.jsx("p",{className:"text-sm text-bambu-gray mb-4 max-w-md mx-auto",children:i("settings.authDisabledMessage")}),s.jsxs("ul",{className:"space-y-2 text-sm text-bambu-gray mb-6 text-left max-w-xs mx-auto",children:[s.jsxs("li",{className:"flex items-start gap-2",children:[s.jsx(Ar,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),s.jsx("span",{children:i("settings.authDisabledFeature1")})]}),s.jsxs("li",{className:"flex items-start gap-2",children:[s.jsx(Ar,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),s.jsx("span",{children:i("settings.authDisabledFeature2")})]}),s.jsxs("li",{className:"flex items-start gap-2",children:[s.jsx(Ar,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),s.jsx("span",{children:i("settings.authDisabledFeature3")})]})]}),s.jsxs(Te,{onClick:()=>e("/setup"),children:[s.jsx(nT,{className:"w-4 h-4"}),i("settings.enableAuthentication")]})]})})})]}),Be&&s.jsx("div",{className:"fixed inset-0 bg-black flex items-center justify-center z-50 p-4",onClick:()=>{Se(!1),Bt({username:"",password:"",confirmPassword:"",role:"user",group_ids:[]})},children:s.jsxs(_t,{className:"w-full max-w-md",onClick:oe=>oe.stopPropagation(),children:[s.jsx(Kn,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(mg,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.createUser")})]}),s.jsx(Te,{variant:"ghost",size:"sm",onClick:()=>{Se(!1),Bt({username:"",password:"",confirmPassword:"",role:"user",group_ids:[]})},children:s.jsx(Rt,{className:"w-5 h-5"})})]})}),s.jsxs(Mt,{children:[s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:i("settings.username")}),s.jsx("input",{type:"text",value:ft.username,onChange:oe=>Bt({...ft,username:oe.target.value}),className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:i("settings.enterUsername"),autoComplete:"username"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:i("settings.password")}),s.jsx("input",{type:"password",value:ft.password,onChange:oe=>Bt({...ft,password:oe.target.value}),className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:i("settings.enterPassword"),autoComplete:"new-password",minLength:6})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:i("settings.confirmPassword")}),s.jsx("input",{type:"password",value:ft.confirmPassword,onChange:oe=>Bt({...ft,confirmPassword:oe.target.value}),className:`w-full px-4 py-3 bg-bambu-dark-secondary border rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors ${ft.confirmPassword&&ft.password!==ft.confirmPassword?"border-red-500":"border-bambu-dark-tertiary"}`,placeholder:i("settings.confirmPasswordPlaceholder"),autoComplete:"new-password",minLength:6}),ft.confirmPassword&&ft.password!==ft.confirmPassword&&s.jsx("p",{className:"text-red-400 text-xs mt-1",children:i("settings.passwordsDoNotMatch")})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Groups"}),s.jsxs("div",{className:"space-y-2 max-h-40 overflow-y-auto p-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg",children:[Fr.map(oe=>s.jsxs("label",{className:"flex items-center gap-3 px-2 py-1.5 rounded hover:bg-bambu-dark-tertiary cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:ft.group_ids.includes(oe.id),onChange:()=>Ks(oe.id),className:"w-4 h-4 rounded border-bambu-gray text-bambu-green focus:ring-bambu-green focus:ring-offset-0 bg-bambu-dark"}),s.jsx("span",{className:"text-sm text-white",children:oe.name}),oe.is_system&&s.jsx("span",{className:"text-xs text-yellow-400",children:"(System)"})]},oe.id)),Fr.length===0&&s.jsx("p",{className:"text-sm text-bambu-gray",children:i("settings.noGroupsAvailable")})]})]})]}),s.jsxs("div",{className:"mt-6 flex justify-end gap-3",children:[s.jsx(Te,{variant:"secondary",onClick:()=>{Se(!1),Bt({username:"",password:"",confirmPassword:"",role:"user",group_ids:[]})},children:"Cancel"}),s.jsx(Te,{onClick:Mo,disabled:Ws.isPending||!ft.username||!ft.password||ft.password!==ft.confirmPassword||ft.password.length<6,children:Ws.isPending?s.jsxs(s.Fragment,{children:[s.jsx(ht,{className:"w-4 h-4 animate-spin"}),"Creating..."]}):s.jsxs(s.Fragment,{children:[s.jsx(dr,{className:"w-4 h-4"}),"Create User"]})})]})]})]})}),Xe&&tt!==null&&s.jsx("div",{className:"fixed inset-0 bg-black flex items-center justify-center z-50 p-4",onClick:()=>{Me(!1),ke(null),Bt({username:"",password:"",confirmPassword:"",role:"user",group_ids:[]})},children:s.jsxs(_t,{className:"w-full max-w-md",onClick:oe=>oe.stopPropagation(),children:[s.jsx(Kn,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(fg,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.editUser")})]}),s.jsx(Te,{variant:"ghost",size:"sm",onClick:()=>{Me(!1),ke(null),Bt({username:"",password:"",confirmPassword:"",role:"user",group_ids:[]})},children:s.jsx(Rt,{className:"w-5 h-5"})})]})}),s.jsxs(Mt,{children:[s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:i("settings.username")}),s.jsx("input",{type:"text",value:ft.username,onChange:oe=>Bt({...ft,username:oe.target.value}),className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:i("settings.enterUsername"),autoComplete:"username"})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm font-medium text-white mb-2",children:["Password ",s.jsx("span",{className:"text-bambu-gray font-normal",children:"(leave blank to keep current)"})]}),s.jsx("input",{type:"password",value:ft.password,onChange:oe=>Bt({...ft,password:oe.target.value,confirmPassword:""}),className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:i("settings.enterNewPassword"),autoComplete:"new-password",minLength:6})]}),ft.password&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:i("settings.confirmPassword")}),s.jsx("input",{type:"password",value:ft.confirmPassword,onChange:oe=>Bt({...ft,confirmPassword:oe.target.value}),className:`w-full px-4 py-3 bg-bambu-dark-secondary border rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors ${ft.confirmPassword&&ft.password!==ft.confirmPassword?"border-red-500":"border-bambu-dark-tertiary"}`,placeholder:i("settings.confirmNewPassword"),autoComplete:"new-password",minLength:6}),ft.confirmPassword&&ft.password!==ft.confirmPassword&&s.jsx("p",{className:"text-red-400 text-xs mt-1",children:i("settings.passwordsDoNotMatch")})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Groups"}),s.jsx("div",{className:"space-y-2 max-h-40 overflow-y-auto p-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg",children:Fr.map(oe=>s.jsxs("label",{className:"flex items-center gap-3 px-2 py-1.5 rounded hover:bg-bambu-dark-tertiary cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:ft.group_ids.includes(oe.id),onChange:()=>Ks(oe.id),className:"w-4 h-4 rounded border-bambu-gray text-bambu-green focus:ring-bambu-green focus:ring-offset-0 bg-bambu-dark"}),s.jsx("span",{className:"text-sm text-white",children:oe.name}),oe.is_system&&s.jsx("span",{className:"text-xs text-yellow-400",children:"(System)"})]},oe.id))})]})]}),s.jsxs("div",{className:"mt-6 flex justify-end gap-3",children:[s.jsx(Te,{variant:"secondary",onClick:()=>{Me(!1),ke(null),Bt({username:"",password:"",confirmPassword:"",role:"user",group_ids:[]})},children:"Cancel"}),s.jsx(Te,{onClick:()=>Ms(tt),disabled:tn.isPending||!ft.username||!!(ft.password&&(ft.password!==ft.confirmPassword||ft.password.length<6)),children:tn.isPending?s.jsxs(s.Fragment,{children:[s.jsx(ht,{className:"w-4 h-4 animate-spin"}),"Saving..."]}):s.jsxs(s.Fragment,{children:[s.jsx(hs,{className:"w-4 h-4"}),"Save Changes"]})})]})]})]})}),We!==null&&s.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",onClick:()=>{ze(null),De(null)},children:s.jsxs(_t,{className:"w-full max-w-md",onClick:oe=>oe.stopPropagation(),children:[s.jsx(Kn,{children:s.jsxs("div",{className:"flex items-center gap-2 text-red-400",children:[s.jsx(rn,{className:"w-5 h-5"}),s.jsx("h3",{className:"text-lg font-semibold",children:i("settings.deleteUserTitle")})]})}),s.jsx(Mt,{className:"space-y-4",children:Ye?s.jsx("div",{className:"flex items-center justify-center py-4",children:s.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-2 border-bambu-green border-t-transparent"})}):W&&W.archives+W.queue_items+W.library_files>0?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-white",children:i("settings.userHasCreated")}),s.jsxs("ul",{className:"list-disc list-inside text-bambu-gray space-y-1",children:[W.archives>0&&s.jsxs("li",{children:[W.archives," archive",W.archives!==1?"s":""]}),W.queue_items>0&&s.jsxs("li",{children:[W.queue_items," queue item",W.queue_items!==1?"s":""]}),W.library_files>0&&s.jsxs("li",{children:[W.library_files," library file",W.library_files!==1?"s":""]})]}),s.jsx("p",{className:"text-bambu-gray text-sm",children:i("settings.userItemsQuestion")}),s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(Te,{variant:"danger",onClick:()=>on.mutate({id:We,deleteItems:!0}),disabled:on.isPending,className:"justify-center",children:"Delete user AND their items"}),s.jsx(Te,{variant:"secondary",onClick:()=>on.mutate({id:We,deleteItems:!1}),disabled:on.isPending,className:"justify-center",children:"Delete user, keep items (become ownerless)"}),s.jsx(Te,{variant:"ghost",onClick:()=>{ze(null),De(null)},disabled:on.isPending,className:"justify-center",children:"Cancel"})]})]}):s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-white",children:i("settings.deleteUserConfirm")}),s.jsx("p",{className:"text-bambu-gray text-sm",children:i("settings.actionCannotBeUndone")}),s.jsxs("div",{className:"flex gap-2 justify-end",children:[s.jsx(Te,{variant:"ghost",onClick:()=>{ze(null),De(null)},disabled:on.isPending,children:"Cancel"}),s.jsx(Te,{variant:"danger",onClick:()=>on.mutate({id:We,deleteItems:!1}),disabled:on.isPending,children:"Delete User"})]})]})})]})}),(Lt||Jt)&&s.jsx("div",{className:"fixed inset-0 bg-black flex items-center justify-center z-50 p-4",onClick:()=>{vn(!1),ir(null),la()},children:s.jsxs(_t,{className:"w-full max-w-2xl max-h-[90vh] overflow-y-auto",onClick:oe=>oe.stopPropagation(),children:[s.jsx(Kn,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(rT,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:Jt?"Edit Group":"Create Group"})]}),s.jsx(Te,{variant:"ghost",size:"sm",onClick:()=>{vn(!1),ir(null),la()},children:s.jsx(Rt,{className:"w-5 h-5"})})]})}),s.jsxs(Mt,{children:[s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:i("settings.groupName")}),s.jsx("input",{type:"text",value:ln.name,onChange:oe=>mr({...ln,name:oe.target.value}),disabled:Jt?.is_system,className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors disabled:opacity-50",placeholder:i("settings.enterGroupName")}),Jt?.is_system&&s.jsx("p",{className:"text-xs text-yellow-400 mt-1",children:i("settings.systemGroupWarning")})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Description"}),s.jsx("textarea",{value:ln.description,onChange:oe=>mr({...ln,description:oe.target.value}),rows:2,className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors resize-none",placeholder:i("settings.enterDescriptionOptional")})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm font-medium text-white mb-2",children:["Permissions (",ln.permissions.length," selected)"]}),s.jsx("div",{className:"space-y-2 max-h-96 overflow-y-auto",children:Br?.categories.map(oe=>s.jsxs("div",{className:"border border-bambu-dark-tertiary rounded-lg overflow-hidden",children:[s.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-bambu-dark-secondary cursor-pointer hover:bg-bambu-dark-tertiary transition-colors",onClick:()=>$l(oe.name),children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("button",{type:"button",onClick:wt=>{wt.stopPropagation(),Dm(oe,!Rm(oe))},className:`w-5 h-5 rounded border flex items-center justify-center transition-colors ${Rm(oe)?"bg-bambu-green border-bambu-green":Vh(oe)?"bg-bambu-green/50 border-bambu-green":"border-bambu-gray hover:border-white"}`,children:(Rm(oe)||Vh(oe))&&s.jsx(Ia,{className:"w-3 h-3 text-white"})}),s.jsx("span",{className:"text-white font-medium",children:oe.name}),s.jsxs("span",{className:"text-xs text-bambu-gray",children:["(",oe.permissions.filter(wt=>ln.permissions.includes(wt.value)).length,"/",oe.permissions.length,")"]})]}),Fn.has(oe.name)?s.jsx(ei,{className:"w-4 h-4 text-bambu-gray"}):s.jsx(gs,{className:"w-4 h-4 text-bambu-gray"})]}),Fn.has(oe.name)&&s.jsx("div",{className:"p-3 bg-bambu-dark space-y-2",children:oe.permissions.map(wt=>s.jsxs("label",{className:"flex items-center gap-3 px-2 py-1.5 rounded hover:bg-bambu-dark-secondary cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:ln.permissions.includes(wt.value),onChange:()=>zx(wt.value),className:"w-4 h-4 rounded border-bambu-gray text-bambu-green focus:ring-bambu-green focus:ring-offset-0 bg-bambu-dark-secondary"}),s.jsx("span",{className:"text-sm text-bambu-gray",children:wt.label})]},wt.value))})]},oe.name))})]})]}),s.jsxs("div",{className:"mt-6 flex justify-end gap-3",children:[s.jsx(Te,{variant:"secondary",onClick:()=>{vn(!1),ir(null),la()},children:"Cancel"}),s.jsx(Te,{onClick:Jt?Ux:Hr,disabled:Ss.isPending||_o.isPending||!ln.name.trim(),children:Ss.isPending||_o.isPending?s.jsxs(s.Fragment,{children:[s.jsx(ht,{className:"w-4 h-4 animate-spin"}),Jt?"Saving...":"Creating..."]}):s.jsxs(s.Fragment,{children:[s.jsx(hs,{className:"w-4 h-4"}),Jt?"Save Changes":"Create Group"]})})]})]})]})}),fr!==null&&s.jsx(Zn,{title:i("settings.deleteGroupTitle"),message:i("settings.deleteGroupMessage"),confirmText:i("settings.deleteGroup"),variant:"danger",onConfirm:()=>{So.mutate(fr),Dn(null)},onCancel:()=>Dn(null)}),be==="backup"&&s.jsx(vKe,{}),we&&s.jsx(Zn,{title:i("settings.disableAuthenticationTitle"),message:i("settings.disableAuthenticationMessage"),confirmText:i("settings.disableAuthentication"),variant:"danger",onConfirm:async()=>{try{await ue.disableAuth(),o(i("settings.toast.authDisabled"),"success"),await u(),re(!1),window.location.href="/"}catch(oe){const wt=oe instanceof Error?oe.message:i("settings.toast.authDisableFailed");o(wt,"error")}},onCancel:()=>re(!1)}),Fe&&s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:()=>{He(!1),$e({currentPassword:"",newPassword:"",confirmPassword:""})},children:s.jsxs(_t,{className:"w-full max-w-md",onClick:oe=>oe.stopPropagation(),children:[s.jsx(Kn,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx($o,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.changePassword")})]}),s.jsx(Te,{variant:"ghost",size:"sm",onClick:()=>{He(!1),$e({currentPassword:"",newPassword:"",confirmPassword:""})},children:s.jsx(Rt,{className:"w-5 h-5"})})]})}),s.jsxs(Mt,{children:[s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Current Password"}),s.jsx("input",{type:"password",value:Ve.currentPassword,onChange:oe=>$e({...Ve,currentPassword:oe.target.value}),className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:i("settings.enterCurrentPassword"),autoComplete:"current-password"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"New Password"}),s.jsx("input",{type:"password",value:Ve.newPassword,onChange:oe=>$e({...Ve,newPassword:oe.target.value}),className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:i("settings.enterNewPasswordMin6"),autoComplete:"new-password",minLength:6})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Confirm New Password"}),s.jsx("input",{type:"password",value:Ve.confirmPassword,onChange:oe=>$e({...Ve,confirmPassword:oe.target.value}),className:`w-full px-4 py-3 bg-bambu-dark-secondary border rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors ${Ve.confirmPassword&&Ve.newPassword!==Ve.confirmPassword?"border-red-500":"border-bambu-dark-tertiary"}`,placeholder:i("settings.confirmNewPassword"),autoComplete:"new-password",minLength:6}),Ve.confirmPassword&&Ve.newPassword!==Ve.confirmPassword&&s.jsx("p",{className:"text-red-400 text-xs mt-1",children:i("settings.passwordsDoNotMatch")})]})]}),s.jsxs("div",{className:"mt-6 flex justify-end gap-3",children:[s.jsx(Te,{variant:"secondary",onClick:()=>{He(!1),$e({currentPassword:"",newPassword:"",confirmPassword:""})},children:"Cancel"}),s.jsx(Te,{onClick:async()=>{if(Ve.newPassword!==Ve.confirmPassword){o(i("settings.toast.passwordsDoNotMatch"),"error");return}if(Ve.newPassword.length<6){o(i("settings.toast.passwordTooShort"),"error");return}je(!0);try{await ue.changePassword(Ve.currentPassword,Ve.newPassword),o(i("settings.toast.passwordChanged"),"success"),He(!1),$e({currentPassword:"",newPassword:"",confirmPassword:""})}catch(oe){const wt=oe instanceof Error?oe.message:"Failed to change password";o(wt,"error")}finally{je(!1)}},disabled:ye||!Ve.currentPassword||!Ve.newPassword||Ve.newPassword!==Ve.confirmPassword||Ve.newPassword.length<6,children:ye?s.jsxs(s.Fragment,{children:[s.jsx(ht,{className:"w-4 h-4 animate-spin"}),"Changing..."]}):s.jsxs(s.Fragment,{children:[s.jsx($o,{className:"w-4 h-4"}),"Change Password"]})})]})]})]})})]})}const Ore=t=>{const e=parseFloat(t);return(Math.trunc(e*1e3)/1e3).toFixed(3)},EKe=t=>t.startsWith("HH")?"HF":"S",TKe=t=>{const e=t.match(/^([A-Z]{2}\d{2})/);return e?e[1]:"HH00"},uR=t=>{const e=["High Flow_","High Flow ","Standard_","Standard ","HF_","HF ","S_","S "];for(const r of e)if(t.startsWith(r))return t.slice(r.length);const n=t.indexOf("_");return n>0?t.slice(n+1):t};function $j({profile:t,onEdit:e,onCopy:n,selectionMode:r,isSelected:i,onToggleSelect:a,note:o}){const l=EKe(t.nozzle_id),c=t.nozzle_diameter,u=()=>{r&&a?a():e()};return s.jsxs("div",{className:"flex items-center gap-2",children:[r&&s.jsx("button",{onClick:a,className:"text-bambu-gray hover:text-white transition-colors p-1",children:i?s.jsx(ol,{className:"w-4 h-4 text-bambu-green"}):s.jsx(ll,{className:"w-4 h-4"})}),s.jsxs("button",{onClick:u,className:`flex-1 text-left px-3 py-2 bg-bambu-dark rounded hover:bg-bambu-dark-tertiary transition-colors ${i?"ring-1 ring-bambu-green":""}`,children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-bambu-green font-mono text-sm font-bold whitespace-nowrap",children:Ore(t.k_value)}),s.jsx("span",{className:"text-white text-sm truncate flex-1",title:t.name,children:t.name||"Unnamed"}),o&&s.jsx("span",{title:"Has note",children:s.jsx(kW,{className:"w-3 h-3 text-yellow-500"})}),s.jsxs("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:[l," ",c]})]}),o&&s.jsxs("div",{className:"text-xs mt-0.5 truncate text-yellow-500/70",title:o,children:["Note: ",o.length>50?o.substring(0,50)+"...":o]})]}),!r&&n&&s.jsx("button",{onClick:d=>{d.stopPropagation(),n()},className:"text-bambu-gray hover:text-white transition-colors p-1",title:"Copy profile",children:s.jsx(Fl,{className:"w-4 h-4"})})]})}function Vj({profile:t,printerId:e,nozzleDiameter:n,existingProfiles:r=[],isDualNozzle:i=!1,initialNote:a="",initialNoteKey:o=null,onClose:l,onSave:c,onSaveNote:u,hasPermission:d}){const{t:f}=Hn(),{showToast:p}=$n(),[m,x]=_.useState(t?.name||""),[b,y]=_.useState(t?.k_value?Ore(t.k_value):"0.020"),[v,S]=_.useState(t?.filament_id||""),[N,T]=_.useState(t?.nozzle_id?TKe(t.nozzle_id):"HH00"),[k,C]=_.useState(t?.nozzle_diameter||n),[E,D]=_.useState(t?[t.extruder_id]:i?[0,1]:[0]),[A,R]=_.useState(!1),[U,F]=_.useState({current:0,total:0}),[$,j]=_.useState(a),H=Jr.useMemo(()=>{const X=new Map;for(const ne of r)if(ne.filament_id&&!X.has(ne.filament_id)){const se=uR(ne.name||"");X.set(ne.filament_id,{id:ne.filament_id,name:se||ne.filament_id})}return Array.from(X.values()).sort((ne,se)=>ne.name.localeCompare(se.name))},[r]),K=mt({mutationFn:X=>(console.log("[KProfile] Calling API..."),ue.setKProfile(e,X)),onSuccess:X=>{if(console.log("[KProfile] Save success:",X),p(f("kProfiles.toast.profileSaved")),u&&$!==a){let ne;$===""&&o?ne=o:t&&t.slot_id>0?ne=t.setting_id||`slot_${t.slot_id}_${t.filament_id}_${t.extruder_id}`:ne=`name_${m}_${v}`,u(ne,$)}R(!0),setTimeout(()=>{R(!1),c()},2500)},onError:X=>{console.error("[KProfile] Save error:",X),p(X.message,"error"),R(!1)}}),V=mt({mutationFn:X=>(console.log("[KProfile] Deleting profile..."),ue.deleteKProfile(e,X)),onSuccess:X=>{console.log("[KProfile] Delete success:",X),p(f("kProfiles.toast.profileDeleted")),R(!0),setTimeout(()=>{R(!1),l()},4e3)},onError:X=>{console.error("[KProfile] Delete error:",X),p(X.message,"error"),R(!1)}}),[Q,Z]=_.useState(!1),ae=()=>{t&&V.mutate({slot_id:t.slot_id,extruder_id:t.extruder_id,nozzle_id:t.nozzle_id,nozzle_diameter:t.nozzle_diameter,filament_id:t.filament_id,setting_id:t.setting_id})},B=async X=>{if(X.preventDefault(),i&&!t&&E.length===0){p(f("kProfiles.toast.selectAtLeastOneExtruder"),"error");return}const ne=parseFloat(b).toFixed(6),se=`${N}-${k}`;if(t||E.length===1){const xe={name:m,k_value:ne,filament_id:v,nozzle_id:se,nozzle_diameter:k,extruder_id:t?t.extruder_id:E[0],setting_id:t?.setting_id,slot_id:t?.slot_id??0};console.log("[KProfile] Saving profile:",xe),K.mutate(xe);return}R(!0),F({current:1,total:E.length});const be=E.map(xe=>({name:m,k_value:ne,filament_id:v,nozzle_id:se,nozzle_diameter:k,extruder_id:xe,setting_id:void 0,slot_id:0}));console.log(`[KProfile] Saving ${be.length} profiles in batch:`,be);try{if(await ue.setKProfilesBatch(e,be),p(f("kProfiles.toast.profilesSaved",{count:E.length})),u&&$){const xe=`name_${m}_${v}`;u(xe,$)}}catch(xe){console.error("[KProfile] Failed to save batch:",xe),p(f("kProfiles.toast.failedToSaveBatch"),"error"),R(!1),F({current:0,total:0});return}F({current:E.length,total:E.length}),setTimeout(()=>{R(!1),F({current:0,total:0}),c()},3e3)};return s.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:[s.jsxs(_t,{className:"w-full max-w-md relative",children:[A&&s.jsxs("div",{className:"absolute inset-0 bg-bambu-dark-secondary/90 flex flex-col items-center justify-center z-10 rounded-lg",children:[s.jsx(ht,{className:"w-8 h-8 text-bambu-green animate-spin mb-3"}),s.jsx("p",{className:"text-white font-medium",children:U.total>1?f("kProfiles.modal.savingExtruder",{current:U.current,total:U.total}):f("kProfiles.modal.syncing")}),s.jsx("p",{className:"text-bambu-gray text-sm mt-1",children:f("kProfiles.modal.pleaseWait")})]}),s.jsxs(Mt,{className:"p-0",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsx("h2",{className:"text-xl font-semibold text-white",children:f(t?"kProfiles.modal.editTitle":"kProfiles.modal.addTitle")}),s.jsx("button",{onClick:l,className:"text-bambu-gray hover:text-white transition-colors",disabled:A,children:s.jsx(Rt,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:B,className:"p-4 space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:f("kProfiles.modal.profileName")}),s.jsx("input",{type:"text",value:m,onChange:X=>x(X.target.value),disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,placeholder:f("kProfiles.modal.profileNamePlaceholder"),required:!t})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:f("kProfiles.modal.kValue")}),s.jsx("input",{type:"text",inputMode:"decimal",value:b,onChange:X=>{const ne=X.target.value;(ne===""||/^\d*\.?\d*$/.test(ne))&&y(ne)},onBlur:X=>{const ne=parseFloat(X.target.value);isNaN(ne)||y((Math.trunc(ne*1e3)/1e3).toFixed(3))},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none font-mono",placeholder:f("kProfiles.modal.kValuePlaceholder"),required:!0}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:f("kProfiles.modal.kValueHelp")})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:f("kProfiles.modal.filament")}),s.jsxs("select",{value:v,onChange:X=>{const ne=X.target.value;if(S(ne),!t&&ne&&!m){const se=H.find(be=>be.id===ne);se&&x(`${N==="HH00"?"HF":"S"} ${se.name}`)}},disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,required:!t,children:[s.jsx("option",{value:"",children:f("kProfiles.modal.selectFilament")}),t?.filament_id&&s.jsx("option",{value:t.filament_id,children:H.find(X=>X.id===t.filament_id)?.name||t.filament_id},t.filament_id),!t&&H.map(X=>s.jsx("option",{value:X.id,children:X.name},X.id))]}),!t&&H.length===0&&s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:f("kProfiles.modal.noFilamentsHelp")})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:f("kProfiles.modal.flowType")}),s.jsxs("select",{value:N,onChange:X=>{const ne=X.target.value;if(T(ne),!t&&v&&!m){const se=H.find(be=>be.id===v);se&&x(`${ne==="HS00"?"HF":"S"} ${se.name}`)}},disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,children:[s.jsx("option",{value:"HH00",children:f("kProfiles.modal.highFlow")}),s.jsx("option",{value:"HS00",children:f("kProfiles.modal.standard")})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:f("kProfiles.modal.nozzleSize")}),s.jsxs("select",{value:k,onChange:X=>C(X.target.value),disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,children:[s.jsx("option",{value:"0.2",children:"0.2mm"}),s.jsx("option",{value:"0.4",children:"0.4mm"}),s.jsx("option",{value:"0.6",children:"0.6mm"}),s.jsx("option",{value:"0.8",children:"0.8mm"})]})]})]}),i&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:f(t?"kProfiles.modal.extruder":"kProfiles.modal.extruders")}),t?s.jsx("div",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white opacity-60",children:t.extruder_id===1?f("kProfiles.modal.left"):f("kProfiles.modal.right")}):s.jsxs("div",{className:"flex gap-4",children:[s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:E.includes(1),onChange:X=>{X.target.checked?D([...E,1]):D(E.filter(ne=>ne!==1))},className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green focus:ring-offset-0 accent-bambu-green"}),s.jsx("span",{className:"text-white",children:f("kProfiles.modal.left")})]}),s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:E.includes(0),onChange:X=>{X.target.checked?D([...E,0]):D(E.filter(ne=>ne!==0))},className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green focus:ring-offset-0 accent-bambu-green"}),s.jsx("span",{className:"text-white",children:f("kProfiles.modal.right")})]})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:f("kProfiles.modal.notes")}),s.jsx("textarea",{value:$,onChange:X=>j(X.target.value),placeholder:f("kProfiles.modal.notesPlaceholder"),rows:2,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none resize-none"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:f("kProfiles.modal.notesHelp")})]}),s.jsxs("div",{className:"flex gap-2 pt-4",children:[t&&s.jsx(Te,{type:"button",variant:"secondary",onClick:()=>Z(!0),disabled:V.isPending||A||!d("kprofiles:delete"),title:d("kprofiles:delete")?void 0:f("kProfiles.permission.noDelete"),className:"text-red-500 hover:bg-red-500/10",children:V.isPending?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(rn,{className:"w-4 h-4"})}),s.jsx(Te,{type:"button",variant:"secondary",onClick:l,disabled:A,className:"flex-1",children:f("common.cancel")}),s.jsxs(Te,{type:"submit",disabled:K.isPending||A||!d(t?"kprofiles:update":"kprofiles:create"),title:d(t?"kprofiles:update":"kprofiles:create")?void 0:f(t?"kProfiles.permission.noUpdate":"kProfiles.permission.noCreate"),className:"flex-1",children:[K.isPending?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(dN,{className:"w-4 h-4"}),f("common.save")]})]})]})]})]}),Q&&s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-[60]",children:s.jsx(_t,{className:"w-full max-w-sm",children:s.jsxs(Mt,{className:"p-6",children:[s.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[s.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/20 flex items-center justify-center",children:s.jsx(rn,{className:"w-5 h-5 text-red-500"})}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-semibold text-white",children:f("kProfiles.deleteConfirm.title")}),s.jsx("p",{className:"text-sm text-bambu-gray",children:f("kProfiles.deleteConfirm.cannotUndo")})]})]}),s.jsx("p",{className:"text-bambu-gray mb-6",children:f("kProfiles.deleteConfirm.message",{name:t?.name})}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx(Te,{variant:"secondary",onClick:()=>Z(!1),className:"flex-1",children:f("common.cancel")}),s.jsxs(Te,{onClick:()=>{Z(!1),ae()},disabled:V.isPending,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[V.isPending?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(rn,{className:"w-4 h-4"}),f("common.delete")]})]})]})})})]})}const h1={NOZZLE_DIAMETER:"bambusy_kprofiles_nozzle",SORT_OPTION:"bambusy_kprofiles_sort"};function AKe(){const{t}=Hn(),{showToast:e}=$n(),{hasPermission:n}=Ai(),[r,i]=_.useState(null),[a,o]=_.useState(()=>localStorage.getItem(h1.NOZZLE_DIAMETER)||"0.4"),[l,c]=_.useState(null),[u,d]=_.useState(!1),[f,p]=_.useState(null),[m,x]=_.useState(""),[b,y]=_.useState("all"),[v,S]=_.useState("all"),[N,T]=_.useState(()=>localStorage.getItem(h1.SORT_OPTION)||"name"),[k,C]=_.useState(!1),[E,D]=_.useState(new Set),[A,R]=_.useState(!1),[U,F]=_.useState(!1),$=_.useCallback(I=>`${I.slot_id}_${I.extruder_id}`,[]);_.useEffect(()=>{localStorage.setItem(h1.NOZZLE_DIAMETER,a)},[a]),_.useEffect(()=>{localStorage.setItem(h1.SORT_OPTION,N)},[N]);const{data:j,isLoading:H}=at({queryKey:["printers"],queryFn:ue.getPrinters}),{data:K,isLoading:V,isFetching:Q,error:Z,refetch:ae}=at({queryKey:["kprofiles",r,a],queryFn:async()=>{console.log("[KProfiles] Fetching profiles for printer",r,"nozzle",a);const I=await ue.getKProfiles(r,a);return console.log("[KProfiles] Received profiles:",I?.profiles?.length||0,"profiles"),I},enabled:!!r,retry:!1,staleTime:0,gcTime:0,refetchOnMount:"always"}),{data:B}=at({queryKey:["kprofiles",r,"0.4"],queryFn:()=>ue.getKProfiles(r,"0.4"),enabled:!!r,staleTime:6e4}),{data:X,refetch:ne}=at({queryKey:["kprofile-notes",r],queryFn:()=>ue.getKProfileNotes(r),enabled:!!r,staleTime:3e4}),se=Z?.message?.includes("not connected");_.useEffect(()=>{if(!r&&j&&j.length>0){const I=j.find(fe=>fe.is_active);I&&i(I.id)}},[r,j]),_.useEffect(()=>{if(r){const I=setTimeout(()=>{ae()},150);return()=>clearTimeout(I)}},[r,a]);const be=j?.filter(I=>I.is_active)||[],xe=Jr.useMemo(()=>K?.profiles?K.profiles.filter(fe=>{const me=m.toLowerCase(),Ee=!me||fe.name.toLowerCase().includes(me)||fe.filament_id.toLowerCase().includes(me),z=b==="all"||b==="left"&&fe.extruder_id===1||b==="right"&&fe.extruder_id===0,O=v==="all"||v==="hf"&&fe.nozzle_id.startsWith("HH")||v==="s"&&fe.nozzle_id.startsWith("HS");return Ee&&z&&O}).sort((fe,me)=>{switch(N){case"k_value":return parseFloat(fe.k_value)-parseFloat(me.k_value);case"filament":return uR(fe.name).localeCompare(uR(me.name));case"name":default:return fe.name.localeCompare(me.name)}}):[],[K?.profiles,m,b,v,N]),de=j?.find(I=>I.id===r),Pe=de?.nozzle_count===2;_.useEffect(()=>{const I=fe=>{fe.target instanceof HTMLInputElement||fe.target instanceof HTMLTextAreaElement||fe.target instanceof HTMLSelectElement||l||u||f||(fe.key==="r"||fe.key==="R"?(fe.preventDefault(),ae()):fe.key==="n"||fe.key==="N"?(fe.preventDefault(),d(!0)):fe.key==="Escape"&&k&&(fe.preventDefault(),C(!1),D(new Set)))};return window.addEventListener("keydown",I),()=>window.removeEventListener("keydown",I)},[l,u,f,k,ae]);const ie=_.useCallback(()=>{if(!K?.profiles||K.profiles.length===0){e(t("kProfiles.toast.noProfilesToExport"),"error");return}const I={version:1,exported_at:new Date().toISOString(),printer:de?.name||"Unknown",nozzle_diameter:a,profiles:K.profiles.map(z=>({name:z.name,k_value:z.k_value,filament_id:z.filament_id,nozzle_id:z.nozzle_id,nozzle_diameter:z.nozzle_diameter,extruder_id:z.extruder_id}))},fe=new Blob([JSON.stringify(I,null,2)],{type:"application/json"}),me=URL.createObjectURL(fe),Ee=document.createElement("a");Ee.href=me,Ee.download=`kprofiles_${de?.name||"printer"}_${a}mm_${new Date().toISOString().split("T")[0]}.json`,document.body.appendChild(Ee),Ee.click(),document.body.removeChild(Ee),URL.revokeObjectURL(me),e(t("kProfiles.toast.exportedProfiles",{count:K.profiles.length}))},[K?.profiles,de,a,e,t]),Ne=_.useCallback(()=>{const I=document.createElement("input");I.type="file",I.accept=".json",I.onchange=async fe=>{const me=fe.target.files?.[0];if(me)try{const Ee=await me.text(),z=JSON.parse(Ee);if(!z.profiles||!Array.isArray(z.profiles)){e(t("kProfiles.toast.invalidFileFormat"),"error");return}let O=0;for(const ee of z.profiles)if(!(!ee.name||!ee.k_value||!ee.filament_id))try{await ue.setKProfile(r,{name:ee.name,k_value:parseFloat(ee.k_value).toFixed(6),filament_id:ee.filament_id,nozzle_id:ee.nozzle_id||`HH00-${a}`,nozzle_diameter:ee.nozzle_diameter||a,extruder_id:ee.extruder_id??0,slot_id:0}),O++,await new Promise(le=>setTimeout(le,500))}catch(le){console.error("Failed to import profile:",ee.name,le)}e(t("kProfiles.toast.importedProfiles",{count:O,total:z.profiles.length})),ae()}catch(Ee){console.error("Import error:",Ee),e(t("kProfiles.toast.failedToParseImport"),"error")}},I.click()},[r,a,e,ae,t]),Oe=_.useCallback(I=>{D(fe=>{const me=new Set(fe);return me.has(I)?me.delete(I):me.add(I),me})},[]),ge=_.useCallback(()=>{D(new Set(xe.map(I=>$(I))))},[xe,$]),Ke=_.useCallback(()=>{E.size!==0&&R(!0)},[E.size]),G=_.useCallback(async()=>{const I=xe.filter(me=>E.has($(me)));F(!0);let fe=0;for(const me of I)try{await ue.deleteKProfile(r,{slot_id:me.slot_id,extruder_id:me.extruder_id,nozzle_id:me.nozzle_id,nozzle_diameter:me.nozzle_diameter,filament_id:me.filament_id,setting_id:me.setting_id}),fe++,await new Promise(Ee=>setTimeout(Ee,300))}catch(Ee){console.error("Failed to delete profile:",me.name,Ee)}e(t("kProfiles.toast.profilesDeleted",{count:fe})),F(!1),R(!1),C(!1),D(new Set),ae()},[r,E,xe,e,ae,$,t]),Y=_.useCallback(I=>{const fe=[];return I.setting_id&&fe.push(I.setting_id),fe.push(`slot_${I.slot_id}_${I.filament_id}_${I.extruder_id}`),fe.push(`name_${I.name}_${I.filament_id}`),fe},[]),ce=_.useCallback(async(I,fe)=>{if(r)try{await ue.setKProfileNote(r,I,fe),ne()}catch(me){console.error("Failed to save note:",me),e(t("kProfiles.toast.failedToSaveNote"),"error")}},[r,ne,e,t]),q=_.useCallback(I=>{if(!X?.notes)return{note:"",key:null};const fe=Y(I);for(const me of fe)if(X.notes[me])return{note:X.notes[me],key:me};return{note:"",key:null}},[X,Y]),te=_.useCallback(I=>q(I).note,[q]);return H?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(ht,{className:"w-8 h-8 text-bambu-green animate-spin"})}):!j||j.length===0?s.jsx(_t,{children:s.jsxs(Mt,{className:"py-12 text-center",children:[s.jsx(Hi,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),s.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:t("kProfiles.noPrintersConfigured")}),s.jsx("p",{className:"text-bambu-gray",children:t("kProfiles.addPrinterInSettings")})]})}):be.length===0?s.jsx(_t,{children:s.jsxs(Mt,{className:"py-12 text-center",children:[s.jsx(Ur,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),s.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:t("kProfiles.noActivePrinters")}),s.jsx("p",{className:"text-bambu-gray",children:t("kProfiles.enablePrinterConnection")})]})}):s.jsxs(s.Fragment,{children:[Q&&!V&&s.jsxs("div",{className:"fixed inset-0 bg-black/50 flex flex-col items-center justify-center z-40",children:[s.jsx(ht,{className:"w-10 h-10 text-bambu-green animate-spin mb-3"}),s.jsx("p",{className:"text-white font-medium",children:t("kProfiles.loadingProfiles")})]}),s.jsxs("div",{className:"flex flex-wrap gap-4 mb-6",children:[s.jsxs("div",{className:"flex-1 min-w-48",children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:t("kProfiles.printer")}),s.jsx("select",{value:r||"",onChange:I=>i(parseInt(I.target.value)),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:be.map(I=>s.jsx("option",{value:I.id,children:I.name},I.id))})]}),s.jsxs("div",{className:"w-32",children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:t("kProfiles.nozzle")}),s.jsxs("select",{value:a,onChange:I=>o(I.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"0.2",children:"0.2mm"}),s.jsx("option",{value:"0.4",children:"0.4mm"}),s.jsx("option",{value:"0.6",children:"0.6mm"}),s.jsx("option",{value:"0.8",children:"0.8mm"})]})]}),s.jsxs("div",{className:"flex items-end gap-2",children:[s.jsxs(Te,{variant:"secondary",onClick:()=>ae(),disabled:Q||!n("kprofiles:read"),title:n("kprofiles:read")?void 0:t("kProfiles.permission.noRead"),children:[s.jsx(Dr,{className:`w-4 h-4 ${Q?"animate-spin":""}`}),t("kProfiles.refresh")]}),s.jsxs(Te,{onClick:()=>d(!0),disabled:!n("kprofiles:create"),title:n("kprofiles:create")?void 0:t("kProfiles.permission.noCreate"),children:[s.jsx(dr,{className:"w-4 h-4"}),t("kProfiles.addProfile")]})]})]}),s.jsxs("div",{className:"flex flex-wrap gap-4 mb-4",children:[s.jsxs("div",{className:"flex-1 min-w-48 relative",children:[s.jsx(ba,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",value:m,onChange:I=>x(I.target.value),placeholder:t("kProfiles.searchPlaceholder"),className:"w-full pl-10 pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]}),Pe&&s.jsx("div",{className:"w-36",children:s.jsxs("select",{value:b,onChange:I=>y(I.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"all",children:t("kProfiles.allExtruders")}),s.jsx("option",{value:"left",children:t("kProfiles.leftOnly")}),s.jsx("option",{value:"right",children:t("kProfiles.rightOnly")})]})}),s.jsx("div",{className:"w-32",children:s.jsxs("select",{value:v,onChange:I=>S(I.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"all",children:t("kProfiles.allFlow")}),s.jsx("option",{value:"hf",children:t("kProfiles.hfOnly")}),s.jsx("option",{value:"s",children:t("kProfiles.sOnly")})]})}),s.jsx("div",{className:"w-32",children:s.jsxs("select",{value:N,onChange:I=>T(I.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"name",children:t("kProfiles.sortName")}),s.jsx("option",{value:"k_value",children:t("kProfiles.sortKValue")}),s.jsx("option",{value:"filament",children:t("kProfiles.sortFilament")})]})})]}),s.jsxs("div",{className:"flex flex-wrap gap-2 mb-6",children:[s.jsxs(Te,{variant:"secondary",onClick:ie,disabled:!K?.profiles?.length||!n("kprofiles:read"),title:n("kprofiles:read")?void 0:t("kProfiles.permission.noExport"),children:[s.jsx(yi,{className:"w-4 h-4"}),t("kProfiles.export")]}),s.jsxs(Te,{variant:"secondary",onClick:Ne,disabled:!n("kprofiles:create"),title:n("kprofiles:create")?void 0:t("kProfiles.permission.noImport"),children:[s.jsx(Ua,{className:"w-4 h-4"}),t("kProfiles.import")]}),s.jsx("div",{className:"flex-1"}),k?s.jsxs(s.Fragment,{children:[s.jsxs(Te,{variant:"secondary",onClick:ge,children:[s.jsx(ol,{className:"w-4 h-4"}),t("kProfiles.selectAll")]}),s.jsxs(Te,{variant:"secondary",onClick:Ke,disabled:E.size===0||!n("kprofiles:delete"),className:"text-red-500 hover:bg-red-500/10",title:n("kprofiles:delete")?void 0:t("kProfiles.permission.noDelete"),children:[s.jsx(rn,{className:"w-4 h-4"}),t("kProfiles.delete")," (",E.size,")"]}),s.jsxs(Te,{variant:"secondary",onClick:()=>{C(!1),D(new Set)},children:[s.jsx(Rt,{className:"w-4 h-4"}),t("common.cancel")]})]}):s.jsxs(Te,{variant:"secondary",onClick:()=>C(!0),disabled:!xe.length||!n("kprofiles:delete"),title:n("kprofiles:delete")?void 0:t("kProfiles.permission.noDelete"),children:[s.jsx(ol,{className:"w-4 h-4"}),t("kProfiles.select")]})]}),V?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(ht,{className:"w-8 h-8 text-bambu-green animate-spin"})}):se?s.jsx(_t,{children:s.jsxs(Mt,{className:"py-12 text-center",children:[s.jsx(sm,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),s.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:t("kProfiles.printerOffline")}),s.jsx("p",{className:"text-bambu-gray mb-4",children:t("kProfiles.printerOfflineDesc")}),s.jsxs(Te,{variant:"secondary",onClick:()=>ae(),children:[s.jsx(Dr,{className:"w-4 h-4"}),t("common.refresh")]})]})}):xe.length>0?Pe?s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-2 px-1",children:t("kProfiles.leftExtruder")}),s.jsx("div",{className:"space-y-1",children:xe.filter(I=>I.extruder_id===1).map(I=>s.jsx($j,{profile:I,onEdit:()=>c(I),onCopy:()=>p(I),selectionMode:k,isSelected:E.has($(I)),onToggleSelect:()=>Oe($(I)),note:te(I)},$(I)))})]}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-2 px-1",children:t("kProfiles.rightExtruder")}),s.jsx("div",{className:"space-y-1",children:xe.filter(I=>I.extruder_id===0).map(I=>s.jsx($j,{profile:I,onEdit:()=>c(I),onCopy:()=>p(I),selectionMode:k,isSelected:E.has($(I)),onToggleSelect:()=>Oe($(I)),note:te(I)},$(I)))})]})]}):s.jsx("div",{className:"space-y-1",children:xe.map(I=>s.jsx($j,{profile:I,onEdit:()=>c(I),onCopy:()=>p(I),selectionMode:k,isSelected:E.has($(I)),onToggleSelect:()=>Oe($(I)),note:te(I)},$(I)))}):m||b!=="all"||v!=="all"?s.jsx(_t,{children:s.jsxs(Mt,{className:"py-12 text-center",children:[s.jsx(ba,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),s.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:t("kProfiles.noMatchingProfiles")}),s.jsx("p",{className:"text-bambu-gray",children:t("kProfiles.noMatchingProfilesDesc")})]})}):s.jsx(_t,{children:s.jsxs(Mt,{className:"py-12 text-center",children:[s.jsx(dN,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),s.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:t("kProfiles.noKProfiles")}),s.jsx("p",{className:"text-bambu-gray mb-4",children:t("kProfiles.noKProfilesDesc",{diameter:a})}),s.jsxs(Te,{onClick:()=>d(!0),children:[s.jsx(dr,{className:"w-4 h-4"}),t("kProfiles.createFirstProfile")]})]})}),l&&r&&(()=>{const{note:I,key:fe}=q(l);return s.jsx(Vj,{profile:l,printerId:r,nozzleDiameter:a,existingProfiles:B?.profiles||K?.profiles,isDualNozzle:Pe,initialNote:I,initialNoteKey:fe,onSaveNote:ce,hasPermission:n,onClose:()=>{console.log("[KProfiles] Edit modal onClose - refetching profiles..."),c(null),ae()},onSave:()=>{c(null),ae()}})})(),u&&r&&s.jsx(Vj,{printerId:r,nozzleDiameter:a,existingProfiles:B?.profiles||K?.profiles,isDualNozzle:Pe,onSaveNote:ce,hasPermission:n,onClose:()=>{d(!1),ae()},onSave:()=>{d(!1),ae()}}),f&&r&&s.jsx(Vj,{printerId:r,nozzleDiameter:a,existingProfiles:B?.profiles||K?.profiles,isDualNozzle:Pe,onSaveNote:ce,hasPermission:n,profile:{...f,slot_id:0,name:`${f.name} (Copy)`},onClose:()=>{p(null),ae()},onSave:()=>{p(null),ae()}}),A&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:s.jsx(_t,{className:"w-full max-w-sm",children:s.jsxs(Mt,{className:"p-6",children:[s.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[s.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/20 flex items-center justify-center",children:s.jsx(rn,{className:"w-5 h-5 text-red-500"})}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-semibold text-white",children:t("kProfiles.bulkDelete.title")}),s.jsx("p",{className:"text-sm text-bambu-gray",children:t("kProfiles.bulkDelete.cannotUndo")})]})]}),s.jsx("p",{className:"text-bambu-gray mb-6",children:t("kProfiles.bulkDelete.message",{count:E.size})}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx(Te,{variant:"secondary",onClick:()=>R(!1),disabled:U,className:"flex-1",children:t("common.cancel")}),s.jsxs(Te,{onClick:G,disabled:U,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[U?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(rn,{className:"w-4 h-4"}),t("common.delete")]})]})]})})})]})}function cF(t,e){const n=`${t} ${e||""}`,r=n.match(/@?\s*(?:BBL\s+)?(?:Bambu\s+Lab\s+)?([XPAH][1-9][A-Z]?(?:\s*(?:Carbon|mini))?|H2D)/i),i=r?r[1].trim():null,a=n.match(/(\d+\.?\d*)\s*(?:mm\s*)?nozzle|nozzle\s*(\d+\.?\d*)/i),o=a?(a[1]||a[2])+"mm":null,l=n.match(/(\d+\.?\d*)mm\s*(?:Standard|Fine|Extra Fine|Draft|Quality)?/i),c=l?l[1]+"mm":null,u=n.match(/\b(PLA|PETG|ABS|ASA|TPU|PC|PA|PVA|HIPS|PP|PET(?:-?CF)?|PA(?:-?CF)?|PLA(?:-?CF)?)\b/i),d=u?u[1].toUpperCase():null;return{printer:i,nozzle:o,layerHeight:c,filamentType:d}}function Ry(t){return/^(P[FPM]US|PF\d|PP\d)/.test(t)}function CKe(t,e){const n=Ii(t);if(!n)return"";const i=new Date().getTime()-n.getTime(),a=Math.floor(i/6e4),o=Math.floor(i/36e5),l=Math.floor(i/864e5);return a<1?e("profiles.time.justNow"):a<60?e("profiles.time.minsAgo",{count:a}):o<24?e("profiles.time.hoursAgo",{count:o}):l<7?e("profiles.time.daysAgo",{count:l}):n.toLocaleDateString()}function jKe({onSuccess:t,t:e}){const{showToast:n}=$n(),[r,i]=_.useState("email"),[a,o]=_.useState(""),[l,c]=_.useState(""),[u,d]=_.useState(""),[f,p]=_.useState(""),[m,x]=_.useState("global"),[b,y]=_.useState(null),[v,S]=_.useState(null),N=mt({mutationFn:()=>ue.cloudLogin(a,l,m),onSuccess:D=>{D.success?(n(e("profiles.login.toast.loggedIn")),t()):D.needs_verification?(y(D.verification_type||"email"),S(D.tfa_key||null),D.verification_type==="totp"?n(e("profiles.login.toast.enterTotp")):n(e("profiles.login.toast.codeSent")),i("code")):n(D.message,"error")},onError:D=>n(D.message,"error")}),T=mt({mutationFn:()=>ue.cloudVerify(a,u,v||void 0),onSuccess:D=>{D.success?(n(e("profiles.login.toast.loggedIn")),t()):n(D.message,"error")},onError:D=>n(D.message,"error")}),k=mt({mutationFn:()=>ue.cloudSetToken(f),onSuccess:()=>{n(e("profiles.login.toast.tokenSet")),t()},onError:D=>n(D.message,"error")}),C=D=>{D.preventDefault(),r==="email"?N.mutate():r==="code"?T.mutate():r==="token"&&k.mutate()},E=N.isPending||T.isPending||k.isPending;return s.jsx(_t,{className:"max-w-md mx-auto",children:s.jsxs(Mt,{children:[s.jsxs("div",{className:"text-center mb-6",children:[s.jsx("div",{className:"inline-flex items-center justify-center w-12 h-12 rounded-xl bg-bambu-green/20 mb-3",children:s.jsx(oN,{className:"w-6 h-6 text-bambu-green"})}),s.jsx("h2",{className:"text-xl font-semibold text-white",children:e("profiles.login.title")}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:e("profiles.login.subtitle")})]}),s.jsxs("form",{onSubmit:C,className:"space-y-4",children:[r==="email"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:e("profiles.login.email")}),s.jsx("input",{type:"email",value:a,onChange:D=>o(D.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none",placeholder:"your@email.com",required:!0})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:e("profiles.login.password")}),s.jsx("input",{type:"password",value:l,onChange:D=>c(D.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none",placeholder:"••••••••",required:!0})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:e("profiles.login.region")}),s.jsxs("select",{value:m,onChange:D=>x(D.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"global",children:e("profiles.login.regionGlobal")}),s.jsx("option",{value:"china",children:e("profiles.login.regionChina")})]})]})]}),r==="code"&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:e(b==="totp"?"profiles.login.totpCode":"profiles.login.verificationCode")}),s.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:b==="totp"?e("profiles.login.enterTotpHint"):e("profiles.login.checkEmail",{email:a})}),s.jsx("input",{type:"text",value:u,onChange:D=>d(D.target.value.replace(/\D/g,"").slice(0,6)),className:"w-full px-3 py-3 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-center text-2xl tracking-widest font-mono focus:border-bambu-green focus:outline-none",placeholder:"000000",maxLength:6,required:!0})]}),r==="token"&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:e("profiles.login.accessToken")}),s.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:e("profiles.login.accessTokenHint")}),s.jsx("textarea",{value:f,onChange:D=>p(D.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-xs font-mono placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none resize-none",placeholder:"eyJ...",rows:4,required:!0})]}),s.jsxs("div",{className:"flex gap-2",children:[r==="code"&&s.jsx(Te,{type:"button",variant:"secondary",onClick:()=>i("email"),className:"flex-1",children:e("profiles.login.back")}),s.jsxs(Te,{type:"submit",disabled:E,className:"flex-1",children:[E?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(Dz,{className:"w-4 h-4"}),e(r==="email"?"profiles.login.loginButton":r==="code"?"profiles.login.verifyButton":"profiles.login.setTokenButton")]})]}),r==="email"&&s.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:s.jsxs("button",{type:"button",onClick:()=>i("token"),className:"text-sm text-bambu-gray hover:text-white flex items-center gap-2 transition-colors",children:[s.jsx($o,{className:"w-4 h-4"}),e("profiles.login.useToken")]})}),r==="token"&&s.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:s.jsxs("button",{type:"button",onClick:()=>i("email"),className:"text-sm text-bambu-gray hover:text-white flex items-center gap-2 transition-colors",children:[s.jsx(Dz,{className:"w-4 h-4"}),e("profiles.login.useEmail")]})})]})]})})}function rg({label:t,value:e,options:n,onChange:r}){const[i,a]=_.useState(!1),o=n.find(l=>l.value===e);return s.jsxs("div",{className:"relative",children:[s.jsxs("button",{onClick:()=>a(!i),className:"flex items-center gap-2 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-sm text-white hover:border-bambu-gray-dark transition-colors",children:[s.jsxs("span",{className:"text-bambu-gray",children:[t,":"]}),s.jsx("span",{children:o?.label||"All"}),s.jsx(ei,{className:`w-4 h-4 text-bambu-gray transition-transform ${i?"rotate-180":""}`})]}),i&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>a(!1)}),s.jsx("div",{className:"absolute top-full left-0 mt-1 min-w-[160px] bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl z-20 py-1 max-h-60 overflow-y-auto",children:n.map(l=>s.jsxs("button",{onClick:()=>{r(l.value),a(!1)},className:`w-full px-3 py-2 text-left text-sm flex items-center justify-between hover:bg-bambu-dark-tertiary transition-colors ${e===l.value?"text-bambu-green":"text-white"}`,children:[s.jsx("span",{children:l.label}),l.count!==void 0&&s.jsx("span",{className:"text-bambu-gray text-xs",children:l.count})]},l.value))})]})]})}function PKe(){const[t,e]=_.useState(!1);_.useEffect(()=>{const r=()=>{e(window.scrollY>300)};return window.addEventListener("scroll",r),()=>window.removeEventListener("scroll",r)},[]);const n=()=>{window.scrollTo({top:0,behavior:"smooth"})};return t?s.jsx("button",{onClick:n,className:"fixed bottom-6 right-6 p-3 bg-bambu-green hover:bg-bambu-green-light text-white rounded-full shadow-lg shadow-bambu-green/25 transition-all z-40","aria-label":"Scroll to top",children:s.jsx(Ig,{className:"w-5 h-5"})}):null}function Gj({setting:t,onClick:e,onDuplicate:n,compareMode:r,isCompareSelected:i,compareIndex:a,compareDisabled:o,t:l}){const c=cF(t.name),u=Ry(t.setting_id);return s.jsxs("div",{className:"flex items-center gap-2 group",children:[s.jsx("button",{onClick:e,disabled:o,className:`flex-1 text-left px-3 py-2 rounded transition-colors ${i?"bg-blue-500/20 border border-blue-500/50":o?"bg-bambu-dark/50 opacity-40 cursor-not-allowed":"bg-bambu-dark hover:bg-bambu-dark-tertiary"} ${r&&!o?"cursor-pointer":""}`,children:s.jsxs("div",{className:"flex items-center gap-2",children:[i&&a!==void 0&&s.jsx("span",{className:"flex-shrink-0 w-5 h-5 rounded-full bg-blue-500 text-white text-xs flex items-center justify-center font-medium",children:a+1}),!i&&u&&s.jsx("span",{className:"flex-shrink-0 w-1.5 h-1.5 rounded-full bg-bambu-green",title:l("profiles.presets.myPreset")}),s.jsx("span",{className:"text-white text-sm truncate flex-1",title:t.name,children:t.name}),c.filamentType&&t.type==="filament"&&s.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:c.filamentType}),c.layerHeight&&t.type==="process"&&s.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:c.layerHeight}),c.printer&&s.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:c.printer})]})}),s.jsx("button",{onClick:d=>{d.stopPropagation(),n()},className:"opacity-0 group-hover:opacity-100 text-bambu-gray hover:text-white transition-all p-1",title:l("profiles.presets.duplicate"),children:s.jsx(Fl,{className:"w-4 h-4"})})]})}function dR(t,e=0){const n=" ".repeat(e);if(t===null)return"null";if(t===void 0)return"undefined";if(typeof t=="string"){if(t.includes("\\n")||t.includes(`
- `)){const i=t.replace(/\\n/g,`
- `).replace(/\\"/g,'"').replace(/\\t/g," ").split(`
- `);if(i.length>1)return`"""
- `+i.map(a=>n+" "+a).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+" "+dR(i,e+1)).join(`,
- `)+`
- `+n+"]";if(typeof t=="object"){const r=Object.entries(t);return r.length===0?"{}":`{
- `+r.map(([a,o])=>n+" "+JSON.stringify(a)+": "+dR(o,e+1)).join(`,
- `)+`
- `+n+"}"}return String(t)}function DKe({setting:t,onClose:e,onDeleted:n,onDuplicate:r,onEdit:i,hasPermission:a,t:o}){const{showToast:l}=$n(),c=an(),[u,d]=_.useState(!1),{data:f,isLoading:p}=at({queryKey:["cloudSettingDetail",t.setting_id],queryFn:()=>ue.getCloudSettingDetail(t.setting_id)}),m=mt({mutationFn:()=>ue.deleteCloudSetting(t.setting_id),onSuccess:()=>{l(o("profiles.presets.toast.deleted")),c.invalidateQueries({queryKey:["cloudSettings"]}),n()},onError:y=>l(y.message,"error")}),x=Ry(t.setting_id),b=cF(t.name,f?.setting?.inherits);return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:s.jsx(_t,{className:"w-full max-w-3xl max-h-[90vh] flex flex-col overflow-hidden",children:s.jsxs(Mt,{className:"p-0 flex flex-col min-h-0 flex-1",children:[s.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("h2",{className:"text-xl font-semibold text-white truncate",children:t.name}),x&&s.jsx("span",{className:"px-2 py-0.5 text-xs font-medium bg-bambu-green/20 text-bambu-green rounded-full",children:o("profiles.presets.editable")})]}),s.jsxs("div",{className:"flex items-center gap-2 mt-1 text-sm text-bambu-gray",children:[s.jsx("span",{className:"capitalize",children:o(`profiles.presets.types.${t.type}`)}),b.printer&&s.jsxs(s.Fragment,{children:[s.jsx("span",{children:"•"}),s.jsx("span",{children:b.printer})]})]})]}),s.jsx("button",{onClick:e,className:"p-2 text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:s.jsx(Rt,{className:"w-5 h-5"})})]}),s.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto p-4",children:p?s.jsx("div",{className:"flex items-center justify-center py-16",children:s.jsx(ht,{className:"w-8 h-8 text-bambu-green animate-spin"})}):f?s.jsx("pre",{className:"text-xs text-bambu-gray font-mono whitespace-pre-wrap break-all bg-bambu-dark p-4 rounded-lg border border-bambu-dark-tertiary overflow-x-auto max-w-full",children:dR(f)}):s.jsx("div",{className:"text-center py-16 text-bambu-gray",children:o("profiles.presets.failedToLoadDetails")})}),u?s.jsxs("div",{className:"flex-shrink-0 p-4 border-t border-bambu-dark-tertiary bg-red-500/5",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3 text-red-400",children:[s.jsx(Cn,{className:"w-5 h-5"}),s.jsx("span",{className:"font-medium",children:o("profiles.presets.deleteConfirm")})]}),s.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:o("profiles.presets.deleteWarning",{name:t.name})}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Te,{variant:"secondary",onClick:()=>d(!1),disabled:m.isPending,className:"flex-1",children:o("common.cancel")}),s.jsxs(Te,{variant:"danger",onClick:()=>m.mutate(),disabled:m.isPending,className:"flex-1",children:[m.isPending?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):s.jsx(rn,{className:"w-4 h-4"}),o("common.delete")]})]})]}):s.jsx("div",{className:"flex-shrink-0 p-4 border-t border-bambu-dark-tertiary",children:s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Te,{variant:"secondary",onClick:e,className:"flex-1",children:o("common.close")}),s.jsxs(Te,{variant:"secondary",onClick:r,disabled:!a("cloud:auth"),title:a("cloud:auth")?void 0:o("profiles.presets.noDuplicatePermission"),children:[s.jsx(Fl,{className:"w-4 h-4"}),o("profiles.presets.duplicate")]}),x&&s.jsxs(s.Fragment,{children:[s.jsxs(Te,{variant:"secondary",onClick:i,disabled:p||!f||!a("cloud:auth"),title:a("cloud:auth")?void 0:o("profiles.presets.noEditPermission"),children:[s.jsx(Qi,{className:"w-4 h-4"}),o("common.edit")]}),s.jsx(Te,{variant:"danger",onClick:()=>d(!0),disabled:!a("cloud:auth"),title:a("cloud:auth")?void 0:o("profiles.presets.noDeletePermission"),children:s.jsx(rn,{className:"w-4 h-4"})})]})]})})]})})})}function Lre(){try{const t=localStorage.getItem("bambusy_preset_templates");return t?JSON.parse(t):[]}catch{return[]}}function Fre(t){localStorage.setItem("bambusy_preset_templates",JSON.stringify(t))}function RKe({onClose:t,onApply:e,t:n}){const{showToast:r}=$n(),[i,a]=_.useState(Lre),[o,l]=_.useState("all"),[c,u]=_.useState(null),[d,f]=_.useState(""),[p,m]=_.useState(""),[x,b]=_.useState("{}"),[y,v]=_.useState(null),[S,N]=_.useState(null),T=o==="all"?i:i.filter($=>$.type===o),k=$=>{a($),Fre($)},C=$=>{const j=i.filter(H=>H.id!==$);k(j),N(null),r(n("profiles.templates.toast.deleted"))},E=$=>{u($.id),f($.name),m($.description),b(JSON.stringify($.settings,null,2)),v(null)},D=()=>{if(!(!c||!d.trim()))try{const $=JSON.parse(x),j=i.map(H=>H.id===c?{...H,name:d.trim(),description:p.trim(),settings:$}:H);k(j),u(null),r(n("profiles.templates.toast.updated"))}catch($){v($.message)}},A=()=>{u(null),f(""),m(""),b("{}"),v(null)},R=$=>{const j=i.map(H=>H.id===$?{...H,showInModal:!H.showInModal}:H);k(j)},U={filament:{label:n("profiles.presets.types.filament"),icon:TR,color:"text-amber-400"},print:{label:n("profiles.presets.types.process"),icon:bh,color:"text-blue-400"},printer:{label:n("profiles.presets.types.printer"),icon:Ur,color:"text-purple-400"}},F=S?i.find($=>$.id===S):null;return _.useEffect(()=>{const $=j=>{j.key==="Escape"&&(S?N(null):c?A():t())};return window.addEventListener("keydown",$),()=>window.removeEventListener("keydown",$)},[S,c,t]),s.jsxs("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:[F&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-60",children:s.jsx(_t,{className:"w-full max-w-md",children:s.jsxs(Mt,{className:"p-6",children:[s.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[s.jsx("div",{className:"p-2 bg-red-500/20 rounded-lg",children:s.jsx(Cn,{className:"w-6 h-6 text-red-400"})}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-semibold text-white",children:n("profiles.templates.deleteTitle")}),s.jsx("p",{className:"text-sm text-bambu-gray",children:n("profiles.templates.deleteWarning")})]})]}),s.jsx("p",{className:"text-white mb-6",children:n("profiles.templates.deleteConfirm",{name:F.name})}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Te,{variant:"secondary",onClick:()=>N(null),className:"flex-1",children:n("common.cancel")}),s.jsxs(Te,{onClick:()=>C(S),className:"flex-1 bg-red-500 hover:bg-red-600",children:[s.jsx(rn,{className:"w-4 h-4"}),n("common.delete")]})]})]})})}),s.jsx(_t,{className:"w-full max-w-2xl max-h-[80vh] flex flex-col",children:s.jsxs(Mt,{className:"p-0 flex flex-col h-full",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(W0,{className:"w-5 h-5 text-amber-400"}),n("profiles.templates.title")]}),s.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white",children:s.jsx(Rt,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"flex items-center gap-2 p-4 border-b border-bambu-dark-tertiary",children:[s.jsx("span",{className:"text-sm text-bambu-gray",children:n("profiles.templates.typeFilter")}),["all","filament","print","printer"].map($=>s.jsx("button",{onClick:()=>l($),className:`px-3 py-1 text-sm rounded-lg transition-colors ${o===$?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:$==="all"?n("common.all"):U[$].label},$))]}),s.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:T.length===0?s.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[s.jsx(W0,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),s.jsx("p",{children:n("profiles.templates.noTemplates")}),s.jsx("p",{className:"text-sm mt-1",children:n("profiles.templates.createFirst")})]}):s.jsx("div",{className:"space-y-2",children:T.map($=>{const j=U[$.type],H=j.icon;return c===$.id?s.jsxs("div",{className:"p-4 bg-bambu-dark rounded-lg border border-bambu-green",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-3 mb-3",children:[s.jsx("input",{type:"text",value:d,onChange:K=>f(K.target.value),placeholder:n("profiles.templates.namePlaceholder"),className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",autoFocus:!0}),s.jsx("input",{type:"text",value:p,onChange:K=>m(K.target.value),placeholder:n("profiles.templates.descriptionPlaceholder"),className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{className:"mb-3",children:[s.jsx("label",{className:"text-xs text-bambu-gray mb-1 block",children:n("profiles.templates.settingsJson")}),s.jsx("textarea",{value:x,onChange:K=>{b(K.target.value),v(null)},rows:6,className:`w-full px-3 py-2 bg-bambu-dark-secondary border rounded text-white text-sm font-mono focus:outline-none ${y?"border-red-500":"border-bambu-dark-tertiary focus:border-bambu-green"}`}),y&&s.jsx("p",{className:"text-xs text-red-400 mt-1",children:y})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(Te,{size:"sm",onClick:D,disabled:!d.trim(),children:[s.jsx(hs,{className:"w-4 h-4"}),"Save"]}),s.jsx(Te,{size:"sm",variant:"secondary",onClick:A,children:"Cancel"})]})]},$.id):s.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary hover:border-bambu-gray-dark transition-colors",children:[s.jsx(H,{className:`w-5 h-5 ${j.color} flex-shrink-0`}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-sm font-medium text-white",children:$.name}),s.jsx("p",{className:"text-xs text-bambu-gray truncate",children:$.description})]}),s.jsx("span",{className:"text-xs text-bambu-gray-dark px-2 py-1 bg-bambu-dark-secondary rounded",children:n("profiles.templates.fieldsCount",{count:Object.keys($.settings).length})}),s.jsx("button",{onClick:()=>R($.id),className:`p-1 transition-colors ${$.showInModal?"text-bambu-green hover:text-bambu-green/70":"text-bambu-gray hover:text-white"}`,title:$.showInModal?n("profiles.templates.shownInModals"):n("profiles.templates.hiddenInModals"),children:$.showInModal?s.jsx(Ru,{className:"w-4 h-4"}):s.jsx(lN,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>e($),className:"px-3 py-1 text-xs bg-bambu-green/20 text-bambu-green rounded hover:bg-bambu-green/30 transition-colors",children:n("profiles.templates.apply")}),s.jsx("button",{onClick:()=>E($),className:"p-1 text-bambu-gray hover:text-white",title:n("common.edit"),children:s.jsx(Qi,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>N($.id),className:"p-1 text-bambu-gray hover:text-red-400",title:n("common.delete"),children:s.jsx(rn,{className:"w-4 h-4"})})]},$.id)})})})]})})]})}function Ire({onClose:t,leftPreset:e,rightPreset:n,leftLabel:r,rightLabel:i,t:a}){const[o,l]=_.useState("changes"),[c,u]=_.useState(""),d=_.useMemo(()=>{const x=new Set([...Object.keys(e),...Object.keys(n)]),b=[];for(const y of x){if(y==="inherits"||y==="version")continue;const v=e[y],S=n[y],N=y in e,T=y in n;let k;!N&&T?k="added":N&&!T?k="removed":JSON.stringify(v)!==JSON.stringify(S)?k="changed":k="same",b.push({key:y,left:v,right:S,status:k})}return b.sort((y,v)=>{const S={changed:0,added:1,removed:2,same:3};return S[y.status]!==S[v.status]?S[y.status]-S[v.status]:y.key.localeCompare(v.key)})},[e,n]),f=_.useMemo(()=>{let x=[...d];if(o==="changes"&&(x=x.filter(b=>b.status!=="same")),c){const b=c.toLowerCase();x=x.filter(y=>y.key.toLowerCase().includes(b)||String(y.left).toLowerCase().includes(b)||String(y.right).toLowerCase().includes(b))}return x},[d,o,c]),p=_.useMemo(()=>({added:d.filter(x=>x.status==="added").length,removed:d.filter(x=>x.status==="removed").length,changed:d.filter(x=>x.status==="changed").length,same:d.filter(x=>x.status==="same").length}),[d]),m=x=>{if(x===void 0)return"—";if(x===null)return"null";if(Array.isArray(x))return x.length===0?"[]":x.length===1?String(x[0]):x.join(", ");if(typeof x=="object")return JSON.stringify(x);const b=String(x);if(b.includes("\\n")||b.length>100){const y=b.split("\\n").length;if(y>1)return`[${y} lines of G-code/script]`;if(b.length>100)return b.substring(0,100)+"…"}return b};return _.useEffect(()=>{const x=b=>{b.key==="Escape"&&t()};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[t]),s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:s.jsx(_t,{className:"w-full max-w-4xl max-h-[85vh] flex flex-col overflow-hidden",children:s.jsxs(Mt,{className:"p-0 flex flex-col min-h-0 flex-1",children:[s.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(_g,{className:"w-5 h-5 text-blue-400"}),a("profiles.diff.title")]}),s.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white",children:s.jsx(Rt,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"flex-shrink-0 grid grid-cols-2 gap-4 p-4 border-b border-bambu-dark-tertiary bg-bambu-dark",children:[s.jsxs("div",{className:"text-center",children:[s.jsx("span",{className:"text-sm text-bambu-gray",children:a("profiles.diff.left")}),s.jsx("p",{className:"text-white font-medium truncate",children:r})]}),s.jsxs("div",{className:"text-center",children:[s.jsx("span",{className:"text-sm text-bambu-gray",children:a("profiles.diff.right")}),s.jsx("p",{className:"text-white font-medium truncate",children:i})]})]}),s.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[s.jsxs("span",{className:"flex items-center gap-1 text-green-400",children:[s.jsx(dr,{className:"w-3.5 h-3.5"}),p.added," ",a("profiles.diff.added")]}),s.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[s.jsx(xP,{className:"w-3.5 h-3.5"}),p.removed," ",a("profiles.diff.removed")]}),s.jsxs("span",{className:"flex items-center gap-1 text-amber-400",children:[s.jsx(uP,{className:"w-3.5 h-3.5"}),p.changed," ",a("profiles.diff.changed")]}),s.jsxs("span",{className:"flex items-center gap-1 text-bambu-gray",children:[s.jsx(eT,{className:"w-3.5 h-3.5"}),p.same," ",a("profiles.diff.same")]})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("div",{className:"relative",children:[s.jsx(ba,{className:"absolute left-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",value:c,onChange:x=>u(x.target.value),placeholder:a("profiles.diff.searchFields"),className:"pl-8 pr-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none w-48"})]}),p.same>0&&s.jsxs("div",{className:"flex rounded overflow-hidden border border-bambu-dark-tertiary",children:[s.jsx("button",{onClick:()=>l("changes"),className:`px-3 py-1.5 text-sm transition-colors ${o==="changes"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:a("profiles.diff.changes")}),s.jsx("button",{onClick:()=>l("all"),className:`px-3 py-1.5 text-sm transition-colors ${o==="all"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:a("common.all")})]})]})]}),s.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:f.length===0?s.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[s.jsx(eT,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),s.jsx("p",{children:a(o==="changes"?"profiles.diff.noDifferences":"profiles.diff.noFieldsMatch")})]}):s.jsxs("table",{className:"w-full",children:[s.jsx("thead",{className:"sticky top-0 bg-bambu-dark-secondary",children:s.jsxs("tr",{className:"text-sm text-bambu-gray border-b border-bambu-dark-tertiary",children:[s.jsx("th",{className:"text-left p-3 w-1/3",children:a("profiles.diff.field")}),s.jsx("th",{className:"text-left p-3 w-1/3",children:r}),s.jsx("th",{className:"text-left p-3 w-1/3",children:i})]})}),s.jsx("tbody",{children:f.map(x=>{const b={added:"bg-green-500/10",removed:"bg-red-500/10",changed:"bg-amber-500/10",same:""}[x.status],y={added:s.jsx(dr,{className:"w-3.5 h-3.5 text-green-400"}),removed:s.jsx(xP,{className:"w-3.5 h-3.5 text-red-400"}),changed:s.jsx(uP,{className:"w-3.5 h-3.5 text-amber-400"}),same:s.jsx(eT,{className:"w-3.5 h-3.5 text-bambu-gray-dark"})}[x.status];return s.jsxs("tr",{className:`border-b border-bambu-dark-tertiary ${b}`,children:[s.jsx("td",{className:"p-3",children:s.jsxs("div",{className:"flex items-center gap-2",children:[y,s.jsx("span",{className:"text-sm text-white font-mono",children:x.key})]})}),s.jsx("td",{className:"p-3",children:s.jsx("span",{className:`text-sm font-mono break-all ${x.status==="removed"?"text-red-300":x.status==="changed"?"text-white":"text-bambu-gray"}`,children:m(x.left)})}),s.jsx("td",{className:"p-3",children:s.jsx("span",{className:`text-sm font-mono break-all ${x.status==="added"?"text-green-300":x.status==="changed"?"text-white":"text-bambu-gray"}`,children:m(x.right)})})]},x.key)})})]})})]})})})}function OKe({onClose:t,initialData:e,allPresets:n,t:r}){const{showToast:i}=$n(),a=an(),o=!!e?.setting_id,[l,c]=_.useState("common"),[u,d]=_.useState(e?.type||"filament"),[f,p]=_.useState(e?.name?o?e.name:`${e.name} (Copy)`:""),[m,x]=_.useState(e?.base_id||""),[b,y]=_.useState(""),[v,S]=_.useState(e?.setting||{inherits:""}),[N,T]=_.useState(JSON.stringify(e?.setting||{inherits:""},null,2)),[k,C]=_.useState(null),[E,D]=_.useState(""),[A,R]=_.useState(!1),[U,F]=_.useState(""),[$,j]=_.useState(!1),[H,K]=_.useState(Lre),[V,Q]=_.useState(!1),[Z,ae]=_.useState(""),[B,X]=_.useState(""),[ne,se]=_.useState(!0),[be,xe]=_.useState(null),[de,Pe]=_.useState(!1),ie=_.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer})[u]||[],[n,u]),Ne=_.useMemo(()=>ie.filter(je=>Ry(je.setting_id)),[ie]),{data:Oe}=at({queryKey:["cloudFields",u],queryFn:()=>ue.getCloudFields(u==="print"?"process":u),staleTime:1e3*60*60}),{data:ge}=at({queryKey:["allPresetDetails",u,Ne.map(je=>je.setting_id).join(",")],queryFn:async()=>{const je={};for(let Se=0;Se<Ne.length;Se+=5){const Xe=Ne.slice(Se,Se+5);(await Promise.all(Xe.map(async tt=>{try{const ke=await ue.getCloudSettingDetail(tt.setting_id);return{id:tt.setting_id,detail:ke}}catch{return null}}))).forEach(tt=>{tt&&(je[tt.id]=tt.detail)})}return je},enabled:Ne.length>0,staleTime:1e3*60*10}),{data:Ke,isLoading:G}=at({queryKey:["cloudSettingDetail",m],queryFn:()=>ue.getCloudSettingDetail(m),enabled:!!m});_.useEffect(()=>{l!=="json"&&T(JSON.stringify(v,null,2))},[v,l]);const Y=_.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer}[u]||[]).filter(Be=>!Ry(Be.setting_id)).sort((Be,Se)=>Be.name.localeCompare(Se.name)),[n,u]);_.useEffect(()=>{if(!m)return;const je=Y.find(Be=>Be.setting_id===m);je&&(y(je.name),o||(S({inherits:je.name}),T(JSON.stringify({inherits:je.name},null,2))))},[m,Y,o]);const ce=_.useMemo(()=>{const je=Oe?.fields||[],Be=new Set(je.map(tt=>tt.key)),Se=new Set,Xe=new Set(["inherits","updated_time","compatible_printers","compatible_prints"]);ge&&Object.values(ge).forEach(tt=>{tt?.setting&&Object.keys(tt.setting).forEach(ke=>{!Be.has(ke)&&!Xe.has(ke)&&Se.add(ke)})}),Object.keys(v).forEach(tt=>{!Be.has(tt)&&!Xe.has(tt)&&Se.add(tt)});const Me=Array.from(Se).sort().map(tt=>({key:tt,label:tt.replace(/_/g," ").replace(/\b\w/g,ke=>ke.toUpperCase()),type:"text",category:"discovered",description:r("profiles.presets.discoveredFromPresets")}));return[...je,...Me]},[Oe,ge,v,r]),q=ce.filter(je=>je.label.toLowerCase().includes(E.toLowerCase())||je.key.toLowerCase().includes(E.toLowerCase())),te=()=>{if(U.trim()){const je=U.trim().toLowerCase().replace(/\s+/g,"_");I(je,""),F(""),j(!1),i(r("profiles.presets.toast.fieldAdded",{key:je}))}},I=(je,Be)=>{S(Se=>{const Xe={...Se};return Be===""||Be===void 0?delete Xe[je]:Xe[je]=Be,Xe})},fe=je=>{S(Be=>({...Be,...je.settings})),xe(je.name),i(r("profiles.templates.toast.applied"))},me=()=>{if(!Z.trim())return;const je={...v};if(delete je.inherits,Object.keys(je).length===0){i(r("profiles.presets.noOverridesToSave"),"error");return}const Be={id:Date.now().toString(),name:Z.trim(),description:B.trim()||r("profiles.presets.customTemplate"),type:u,settings:je,showInModal:ne},Se=[...H,Be];K(Se),Fre(Se),Q(!1),ae(""),X(""),se(!0),i(r("profiles.templates.toast.created"))},Ee=_.useMemo(()=>H.filter(je=>je.type===u&&je.showInModal),[u,H]),z=je=>{T(je);try{const Be=JSON.parse(je);S(Be),C(null)}catch(Be){C(Be.message)}},O=je=>{je.preventDefault(),R(!1);const Be=je.dataTransfer.files[0];if(Be&&Be.name.endsWith(".json")){const Se=new FileReader;Se.onload=Xe=>{try{const Me=Xe.target?.result,tt=JSON.parse(Me),ke=tt.setting||tt;S(We=>({...We,...ke})),T(JSON.stringify({...v,...ke},null,2)),i(r("profiles.presets.fileImported"))}catch{i(r("profiles.presets.invalidJsonFile"),"error")}},Se.readAsText(Be)}},ee=mt({mutationFn:()=>{const je={...v},Be=u==="filament"?"filament_settings_id":u==="print"?"print_settings_id":"printer_settings_id";je[Be]=`"${f}"`;const Se={type:u,name:f,base_id:m,setting:je};return ue.createCloudSetting(Se)},onSuccess:async()=>{i(r("profiles.presets.toast.created")),await a.refetchQueries({queryKey:["cloudSettings"]}),t()},onError:je=>i(je.message,"error")}),le=mt({mutationFn:()=>{if(!e?.setting_id)throw new Error(r("profiles.presets.noSettingId"));return ue.updateCloudSetting(e.setting_id,{name:f,setting:v})},onSuccess:async()=>{i(r("profiles.presets.toast.updated")),a.removeQueries({queryKey:["cloudSettingDetail"]}),await a.refetchQueries({queryKey:["cloudSettings"]}),t()},onError:je=>i(je.message,"error")}),_e=o?le:ee,we=Ke?.setting?.inherits,re=we?Y.find(je=>je.name===we):void 0,{data:Fe}=at({queryKey:["cloudSettingDetail",re?.setting_id],queryFn:()=>ue.getCloudSettingDetail(re.setting_id),enabled:!!re?.setting_id}),He=_.useMemo(()=>{const je=Fe?.setting||{},Be=Ke?.setting||{},Se=m&&ge?.[m]?.setting?ge[m].setting:{};return{...je,...Be,...Se}},[m,Ke,Fe,ge]),Ve=je=>{if(je==null)return"";if(Array.isArray(je)){const Be=[...new Set(je.map(Se=>String(Se)))];return Be.length===1?Be[0]:je.join(", ")}return String(je)},$e=je=>{const Be=v[je.key],Se=He[je.key],Xe=Ve(Se),Me=G?r("common.loading"):Xe||"",tt="w-full px-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none";if(je.type==="boolean"){const ke=Be==="1"||Be===void 0&&Se==="1";return s.jsx("button",{type:"button",onClick:()=>I(je.key,Be==="1"?"0":"1"),className:`w-8 h-5 rounded-full transition-colors ${ke?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,children:s.jsx("div",{className:`w-4 h-4 rounded-full bg-white shadow transition-transform ${ke?"translate-x-3.5":"translate-x-0.5"}`})})}return je.type==="select"?s.jsxs("select",{value:Be||"",onChange:ke=>I(je.key,ke.target.value),className:tt,children:[s.jsx("option",{value:"",children:Me}),je.options?.map(ke=>s.jsx("option",{value:ke.value,children:ke.label},ke.value))]}):s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:je.type==="number"?"number":"text",value:Be!==void 0?String(Be):"",onChange:ke=>I(je.key,ke.target.value),step:je.step,min:je.min,max:je.max,placeholder:Me,className:tt}),je.unit&&s.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:je.unit})]})},ye=_.useMemo(()=>Ke?.setting?Ke.setting:{},[Ke]);return s.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onDragOver:je=>{je.preventDefault(),R(!0)},onDragLeave:()=>R(!1),onDrop:O,children:[de&&m&&s.jsx(Ire,{onClose:()=>Pe(!1),leftPreset:ye,rightPreset:v,leftLabel:r("profiles.presets.baseLabel",{name:b||m}),rightLabel:r("profiles.presets.currentLabel",{name:f||r("profiles.presets.newPreset")}),t:r}),s.jsx(_t,{className:"w-full max-w-6xl max-h-[90vh] flex flex-col",children:s.jsxs(Mt,{className:"p-0 flex flex-col h-full",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-xl font-semibold text-white",children:r(o?"profiles.presets.editPreset":e?"profiles.presets.duplicatePreset":"profiles.presets.createNewPreset")}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:r("profiles.presets.customizeSettings")})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[m&&s.jsxs("button",{onClick:()=>Pe(!0),className:"flex items-center gap-2 px-3 py-2 text-sm text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors",title:r("profiles.presets.compareWithBase"),children:[s.jsx(_g,{className:"w-4 h-4"}),r("profiles.presets.compare")]}),s.jsx("button",{onClick:t,className:"p-2 text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:s.jsx(Rt,{className:"w-5 h-5"})})]})]}),A&&s.jsx("div",{className:"absolute inset-0 bg-bambu-green/10 border-2 border-dashed border-bambu-green rounded-lg flex items-center justify-center z-10",children:s.jsxs("div",{className:"text-center",children:[s.jsx(Ua,{className:"w-12 h-12 text-bambu-green mx-auto mb-2"}),s.jsx("p",{className:"text-bambu-green font-medium",children:r("profiles.presets.dropJsonToImport")})]})}),s.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("common.type")}),s.jsxs("select",{value:u,onChange:je=>{d(je.target.value),x("")},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"filament",children:r("profiles.presets.types.filament")}),s.jsx("option",{value:"print",children:r("profiles.presets.types.process")}),s.jsx("option",{value:"printer",children:r("profiles.presets.types.printer")})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("profiles.presets.basePreset")}),s.jsxs("select",{value:m,onChange:je=>x(je.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"",children:r("profiles.presets.selectBasePreset")}),Y.map(je=>s.jsx("option",{value:je.setting_id,children:je.name},je.setting_id))]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("profiles.presets.presetName")}),s.jsx("input",{type:"text",value:f,onChange:je=>p(je.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",placeholder:r("profiles.presets.myCustomPreset")})]})]}),b&&s.jsx("div",{className:"text-xs text-bambu-gray",children:s.jsxs("p",{className:"flex items-center gap-1",children:[s.jsx(Ia,{className:"w-3 h-3 text-bambu-green"}),r("profiles.presets.inheritsFrom")," ",s.jsx("span",{className:"text-white",children:b}),G&&s.jsx(ht,{className:"w-3 h-3 animate-spin ml-1"})]})})]}),s.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary",children:[s.jsxs("button",{onClick:()=>c("common"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${l==="common"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[s.jsx(Rz,{className:"w-4 h-4"}),r("profiles.presets.tabs.common")]}),s.jsxs("button",{onClick:()=>c("fields"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${l==="fields"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[s.jsx(pN,{className:"w-4 h-4"}),r("profiles.presets.tabs.allFields")]}),s.jsxs("button",{onClick:()=>c("json"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${l==="json"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[s.jsx(pW,{className:"w-4 h-4"}),"JSON",k&&s.jsx(Hi,{className:"w-3 h-3 text-red-400"})]}),s.jsx("div",{className:"flex-1"}),s.jsxs("button",{onClick:()=>{const je={name:f,type:u,base_id:m,setting:v},Be=new Blob([JSON.stringify(je,null,2)],{type:"application/json"}),Se=URL.createObjectURL(Be),Xe=document.createElement("a");Xe.href=Se,Xe.download=`${f||"preset"}.json`,document.body.appendChild(Xe),Xe.click(),document.body.removeChild(Xe),URL.revokeObjectURL(Se),i(r("profiles.presets.toast.exported"))},className:"flex items-center gap-2 px-4 py-3 text-sm text-bambu-gray hover:text-white transition-colors",title:r("profiles.presets.exportToJson"),children:[s.jsx(yi,{className:"w-4 h-4"}),r("common.download")]}),s.jsxs("button",{onClick:()=>document.getElementById("file-import")?.click(),className:"flex items-center gap-2 px-4 py-3 text-sm text-bambu-gray hover:text-white transition-colors",title:r("profiles.presets.importFromJson"),children:[s.jsx(Ua,{className:"w-4 h-4"}),r("common.upload")]}),s.jsx("input",{id:"file-import",type:"file",accept:".json",className:"hidden",onChange:je=>{const Be=je.target.files?.[0];if(Be){const Se=new FileReader;Se.onload=Xe=>{try{const Me=JSON.parse(Xe.target?.result),tt=Me.setting||Me;S(ke=>({...ke,...tt})),i(r("profiles.presets.fileImported"))}catch{i(r("profiles.presets.invalidJson"),"error")}},Se.readAsText(Be)}}})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto p-4",children:[l==="common"&&s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsxs("h3",{className:"text-sm font-medium text-white flex items-center gap-2",children:[s.jsx(W0,{className:"w-4 h-4 text-amber-400"}),r("profiles.templates.title")]}),Object.keys(v).filter(je=>je!=="inherits").length>0&&s.jsxs("button",{onClick:()=>Q(!V),className:"text-xs text-bambu-gray hover:text-white flex items-center gap-1 transition-colors",children:[s.jsx(hs,{className:"w-3 h-3"}),r("profiles.presets.saveAsTemplate")]})]}),V&&s.jsxs("div",{className:"mb-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-2 mb-2",children:[s.jsx("input",{type:"text",value:Z,onChange:je=>ae(je.target.value),placeholder:r("profiles.templates.namePlaceholder"),className:"px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",autoFocus:!0}),s.jsx("input",{type:"text",value:B,onChange:je=>X(je.target.value),placeholder:r("profiles.templates.descriptionPlaceholder"),className:"px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(Te,{size:"sm",onClick:me,disabled:!Z.trim(),children:[s.jsx(hs,{className:"w-3 h-3"}),r("common.save")]}),s.jsx(Te,{size:"sm",variant:"secondary",onClick:()=>Q(!1),children:r("common.cancel")})]}),s.jsxs("button",{onClick:()=>se(!ne),className:`flex items-center gap-1.5 text-xs transition-colors ${ne?"text-bambu-green":"text-bambu-gray hover:text-white"}`,children:[ne?s.jsx(Ru,{className:"w-3.5 h-3.5"}):s.jsx(lN,{className:"w-3.5 h-3.5"}),r(ne?"profiles.templates.shownInModals":"profiles.templates.hiddenInModals")]})]})]}),be&&s.jsxs("div",{className:"mb-3 px-3 py-2 bg-bambu-green/10 border border-bambu-green/30 rounded-lg flex items-center gap-2",children:[s.jsx(Ia,{className:"w-4 h-4 text-bambu-green"}),s.jsxs("span",{className:"text-sm text-bambu-green",children:[r("profiles.presets.templateApplied")," ",s.jsx("span",{className:"font-medium",children:be})]}),s.jsx("button",{onClick:()=>xe(null),className:"ml-auto text-bambu-green/70 hover:text-bambu-green",children:s.jsx(Rt,{className:"w-4 h-4"})})]}),s.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[Ee.map(je=>s.jsxs("button",{onClick:()=>fe(je),className:"p-3 text-left bg-bambu-dark border border-bambu-dark-tertiary rounded-lg hover:border-bambu-gray-dark transition-colors",children:[s.jsx("p",{className:"text-sm font-medium text-white",children:je.name}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:je.description})]},je.id)),Ee.length===0&&s.jsx("p",{className:"col-span-3 text-center text-bambu-gray text-sm py-4",children:r("profiles.presets.noTemplatesSelected")})]}),s.jsx("p",{className:"text-xs text-bambu-gray-dark mt-2 text-center",children:r("profiles.presets.manageTemplatesHint")})]}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:r("profiles.presets.commonSettings")}),s.jsx("div",{className:"grid grid-cols-2 gap-x-6 gap-y-3",children:ce.slice(0,10).map(je=>s.jsxs("div",{className:"flex items-center justify-between gap-4",children:[s.jsx("label",{className:"text-sm text-bambu-gray flex-shrink-0",children:je.label}),s.jsx("div",{className:"w-48",children:$e(je)})]},je.key))})]}),Object.keys(v).length>1&&s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:r("profiles.presets.currentOverrides")}),s.jsx("div",{className:"flex flex-wrap gap-2",children:Object.entries(v).filter(([je])=>je!=="inherits").map(([je,Be])=>s.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-green/10 text-bambu-green text-xs rounded",children:[je,": ",String(Be).slice(0,20),s.jsx("button",{onClick:()=>I(je,void 0),className:"hover:text-white",children:s.jsx(Rt,{className:"w-3 h-3"})})]},je))})]})]}),l==="fields"&&s.jsxs("div",{className:"grid grid-cols-2 gap-6",style:{height:"400px"},children:[s.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3 flex-shrink-0",children:[s.jsx("h3",{className:"text-sm font-medium text-white",children:r("profiles.presets.availableFields")}),s.jsx("span",{className:"text-xs text-bambu-gray",children:ge?r("profiles.templates.fieldsCount",{count:ce.length}):r("common.loading")})]}),s.jsxs("div",{className:"relative mb-3 flex-shrink-0",children:[s.jsx(ba,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",value:E,onChange:je=>D(je.target.value),placeholder:r("profiles.presets.searchFieldsPlaceholder"),className:"w-full pl-10 pr-4 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto space-y-1 pr-2 min-h-0",children:[q.filter(je=>!(je.key in v)).map(je=>{const Be=He[je.key],Se=Ve(Be);return s.jsxs("div",{onClick:()=>{S(Xe=>({...Xe,[je.key]:Se||""}))},className:"flex items-center justify-between gap-2 p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors cursor-pointer group",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"text-sm text-white truncate",children:je.label}),s.jsx("p",{className:"text-xs text-bambu-gray-dark truncate",children:je.key})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[Se&&s.jsxs("span",{className:"text-xs text-bambu-gray bg-bambu-dark px-2 py-0.5 rounded max-w-32 truncate",title:Se,children:[Se.slice(0,20),Se.length>20?"...":""]}),s.jsx("div",{className:"w-6 h-6 flex items-center justify-center rounded bg-bambu-dark-tertiary group-hover:bg-bambu-green/20 transition-colors",children:s.jsx(dr,{className:"w-4 h-4 text-bambu-gray group-hover:text-bambu-green transition-colors"})})]})]},je.key)}),q.filter(je=>!(je.key in v)).length===0&&s.jsx("p",{className:"text-center text-bambu-gray py-4 text-sm",children:r(E?"profiles.presets.noMatchingFields":"profiles.presets.allFieldsAdded")})]}),s.jsx("div",{className:"pt-3 mt-3 border-t border-bambu-dark-tertiary flex-shrink-0",children:$?s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{type:"text",value:U,onChange:je=>F(je.target.value),onKeyDown:je=>je.key==="Enter"&&te(),placeholder:"custom_field_name",className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white font-mono text-sm placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none",autoFocus:!0}),s.jsx(Te,{size:"sm",onClick:te,disabled:!U.trim(),children:s.jsx(dr,{className:"w-4 h-4"})}),s.jsx(Te,{size:"sm",variant:"secondary",onClick:()=>{j(!1),F("")},children:s.jsx(Rt,{className:"w-4 h-4"})})]}):s.jsxs("button",{onClick:()=>j(!0),className:"w-full flex items-center justify-center gap-2 p-2 text-sm text-bambu-gray hover:text-white border border-dashed border-bambu-dark-tertiary hover:border-bambu-gray-dark rounded-lg transition-colors",children:[s.jsx(dr,{className:"w-4 h-4"}),r("profiles.presets.addCustomField")]})})]}),s.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3 flex-shrink-0",children:[s.jsx("h3",{className:"text-sm font-medium text-white",children:r("profiles.presets.yourOverrides")}),s.jsx("span",{className:"text-xs text-bambu-gray",children:r("profiles.templates.fieldsCount",{count:Object.keys(v).filter(je=>je!=="inherits").length})})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto space-y-2 pr-2 min-h-0",children:[Object.entries(v).filter(([je])=>je!=="inherits").map(([je,Be])=>{const Se=ce.find(Xe=>Xe.key===je);return s.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-white",children:Se?.label||je}),s.jsx("p",{className:"text-xs text-bambu-gray-dark",children:je})]}),s.jsx("button",{onClick:()=>I(je,void 0),className:"p-1 text-bambu-gray hover:text-red-400 transition-colors",children:s.jsx(Rt,{className:"w-4 h-4"})})]}),Se?$e(Se):s.jsx("input",{type:"text",value:String(Be),onChange:Xe=>I(je,Xe.target.value),className:"w-full px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none"})]},je)}),Object.keys(v).filter(je=>je!=="inherits").length===0&&s.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[s.jsx(Rz,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),s.jsx("p",{className:"text-sm",children:r("profiles.presets.noOverridesYet")}),s.jsx("p",{className:"text-xs mt-1",children:r("profiles.presets.clickFieldsToAdd")})]})]}),Object.keys(v).filter(je=>je!=="inherits").length>0&&s.jsx("div",{className:"pt-3 mt-3 border-t border-bambu-dark-tertiary flex-shrink-0",children:s.jsxs("button",{onClick:()=>{Q(!0),c("common")},className:"w-full flex items-center justify-center gap-2 p-2 text-sm text-bambu-gray hover:text-white border border-dashed border-bambu-dark-tertiary hover:border-bambu-gray-dark rounded-lg transition-colors",children:[s.jsx(hs,{className:"w-4 h-4"}),r("profiles.presets.saveAsTemplate")]})})]})]}),l==="json"&&s.jsxs("div",{className:"space-y-2",children:[k&&s.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[s.jsx(Hi,{className:"w-4 h-4"}),k]}),s.jsx("textarea",{value:N,onChange:je=>z(je.target.value),className:`w-full h-80 px-3 py-2 bg-bambu-dark border rounded-lg text-white text-xs font-mono focus:outline-none resize-none ${k?"border-red-500 focus:border-red-500":"border-bambu-dark-tertiary focus:border-bambu-green"}`,spellCheck:!1}),s.jsx("p",{className:"text-xs text-bambu-gray",children:r("profiles.presets.jsonTip")})]})]}),s.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary flex gap-2",children:[s.jsx(Te,{variant:"secondary",onClick:t,className:"flex-1",children:r("common.cancel")}),s.jsxs(Te,{onClick:()=>_e.mutate(),disabled:_e.isPending||!f.trim()||!o&&!m||!!k,className:"flex-1",children:[_e.isPending?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):o?s.jsx(hs,{className:"w-4 h-4"}):s.jsx(dr,{className:"w-4 h-4"}),r(o?"common.save":e?"common.duplicate":"common.create")]})]})]})})]})}function LKe({settings:t,lastSyncTime:e,onRefresh:n,isRefreshing:r,printers:i,hasPermission:a,t:o}){const[l,c]=_.useState(""),[u,d]=_.useState("all"),[f,p]=_.useState("all"),[m,x]=_.useState("all"),[b,y]=_.useState("all"),[v,S]=_.useState("all"),[N,T]=_.useState("all"),[k,C]=_.useState(null),[E,D]=_.useState(!1),[A,R]=_.useState(!1),[U,F]=_.useState(null),[$,j]=_.useState(null),[H,K]=_.useState(null),[V,Q]=_.useState(!1),[Z,ae]=_.useState([null,null]),[B,X]=_.useState(!1),[ne,se]=_.useState(null),be=an(),xe=_.useMemo(()=>[...t.filament.map(te=>({...te,type:"filament"})),...t.printer.map(te=>({...te,type:"printer"})),...t.process.map(te=>({...te,type:"process"}))].map(te=>({...te,meta:cF(te.name)})),[t]),de=_.useMemo(()=>{const q=new Set,te=new Set,I=new Set;return xe.forEach(fe=>{fe.meta.nozzle&&q.add(fe.meta.nozzle),fe.meta.filamentType&&te.add(fe.meta.filamentType),fe.meta.layerHeight&&I.add(fe.meta.layerHeight)}),{printers:i.map(fe=>({id:fe.id.toString(),name:fe.name})),nozzles:Array.from(q).sort((fe,me)=>parseFloat(fe)-parseFloat(me)),filaments:Array.from(te).sort(),layerHeights:Array.from(I).sort((fe,me)=>parseFloat(fe)-parseFloat(me))}},[xe,i]),Pe=_.useMemo(()=>m==="all"?null:i.find(te=>te.id.toString()===m)?.model||null,[m,i]),ie=_.useMemo(()=>xe.filter(q=>u==="all"||q.type===u).filter(q=>{if(f==="all")return!0;const te=Ry(q.setting_id);return f==="custom"?te:!te}).filter(q=>{if(m==="all"||!Pe)return!0;const te=q.meta.printer?.toLowerCase()||"",I=Pe.toLowerCase();return te.includes(I)||I.includes(te)}).filter(q=>b==="all"||q.meta.nozzle===b).filter(q=>v==="all"||q.meta.filamentType===v).filter(q=>N==="all"||q.meta.layerHeight===N).filter(q=>l===""||q.name.toLowerCase().includes(l.toLowerCase())).sort((q,te)=>q.name.localeCompare(te.name)),[xe,u,f,m,Pe,b,v,N,l]),Ne=q=>{if(V){const te=Z[0]?.setting_id===q.setting_id,I=Z[1]?.setting_id===q.setting_id;if(te)ae([Z[1],null]);else if(I)ae([Z[0],null]);else if(!Z[0])ae([q,null]);else if(Z[1]){if(Z[0].type!==q.type)return;ae([Z[0],q])}else{if(Z[0].type!==q.type)return;ae([Z[0],q])}}else C(q)},Oe=q=>{if(Z[0]?.setting_id===q.setting_id)return 0;if(Z[1]?.setting_id===q.setting_id)return 1},ge=async q=>{try{const te=await ue.getCloudSettingDetail(q.setting_id),I=q.type==="process"?"print":q.type;F({type:I,name:q.name,base_id:te.base_id||"GFSA00",setting:te.setting||{}}),C(null)}catch(te){console.error("Failed to fetch preset details for duplication:",te)}},Ke=async q=>{try{be.removeQueries({queryKey:["cloudSettingDetail",q.setting_id]});const te=await ue.getCloudSettingDetail(q.setting_id),I=q.type==="process"?"print":q.type;j({type:I,name:q.name,base_id:te.base_id||"GFSA00",setting:te.setting||{},setting_id:q.setting_id}),C(null)}catch(te){console.error("Failed to fetch preset details for editing:",te)}},G=()=>{d("all"),p("all"),x("all"),y("all"),S("all"),T("all"),c("")},Y=u!=="all"||f!=="all"||m!=="all"||b!=="all"||v!=="all"||N!=="all"||l!=="",ce=t.filament.length+t.printer.length+t.process.length;return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"space-y-4 mb-6",children:[s.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsx(ba,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",value:l,onChange:q=>c(q.target.value),placeholder:o("profiles.cloudView.searchPlaceholder"),className:"w-full pl-10 pr-4 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(Te,{variant:V?"primary":"secondary",onClick:()=>{V?(Q(!1),ae([null,null])):Q(!0)},children:[s.jsx(_g,{className:"w-4 h-4"}),o(V?"common.cancel":"profiles.presets.compare")]}),s.jsxs(Te,{variant:"secondary",onClick:()=>R(!0),disabled:!a("cloud:auth"),title:a("cloud:auth")?void 0:o("profiles.cloudView.noTemplatesPermission"),children:[s.jsx(W0,{className:"w-4 h-4"}),o("profiles.cloudView.templates")]}),s.jsxs(Te,{variant:"secondary",onClick:n,disabled:r||!a("cloud:auth"),title:a("cloud:auth")?void 0:o("profiles.cloudView.noRefreshPermission"),children:[s.jsx(Dr,{className:`w-4 h-4 ${r?"animate-spin":""}`}),o("profiles.cloudView.refresh")]}),s.jsxs(Te,{onClick:()=>D(!0),disabled:!a("cloud:auth"),title:a("cloud:auth")?void 0:o("profiles.cloudView.noCreatePermission"),children:[s.jsx(dr,{className:"w-4 h-4"}),o("profiles.cloudView.newPreset")]})]})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx(uN,{className:"w-4 h-4 text-bambu-gray"}),s.jsx(rg,{label:o("profiles.cloudView.filters.type"),value:u,options:[{value:"all",label:o("profiles.cloudView.filters.all"),count:ce},{value:"filament",label:o("profiles.cloudView.filters.filament"),count:t.filament.length},{value:"printer",label:o("profiles.cloudView.filters.printer"),count:t.printer.length},{value:"process",label:o("profiles.cloudView.filters.process"),count:t.process.length}],onChange:q=>d(q)}),s.jsx(rg,{label:o("profiles.cloudView.filters.owner"),value:f,options:[{value:"all",label:o("profiles.cloudView.filters.all")},{value:"custom",label:o("profiles.cloudView.filters.myPresets")},{value:"builtin",label:o("profiles.cloudView.filters.builtIn")}],onChange:q=>p(q)}),de.printers.length>0&&s.jsx(rg,{label:o("profiles.cloudView.filters.printer"),value:m,options:[{value:"all",label:o("profiles.cloudView.filters.all")},...de.printers.map(q=>({value:q.id,label:q.name}))],onChange:x}),de.nozzles.length>0&&s.jsx(rg,{label:o("profiles.cloudView.filters.nozzle"),value:b,options:[{value:"all",label:o("profiles.cloudView.filters.all")},...de.nozzles.map(q=>({value:q,label:q}))],onChange:y}),de.filaments.length>0&&(u==="all"||u==="filament")&&s.jsx(rg,{label:o("profiles.cloudView.filters.filament"),value:v,options:[{value:"all",label:o("profiles.cloudView.filters.all")},...de.filaments.map(q=>({value:q,label:q}))],onChange:S}),de.layerHeights.length>0&&(u==="all"||u==="process")&&s.jsx(rg,{label:o("profiles.cloudView.filters.layer"),value:N,options:[{value:"all",label:o("profiles.cloudView.filters.all")},...de.layerHeights.map(q=>({value:q,label:q}))],onChange:T}),Y&&s.jsx("button",{onClick:G,className:"px-3 py-2 text-sm text-bambu-gray hover:text-white transition-colors",children:o("profiles.cloudView.clearFilters")})]})]}),V&&s.jsx("div",{className:"mb-4 p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx(_g,{className:"w-5 h-5 text-blue-400"}),s.jsx("span",{className:"text-white font-medium",children:o("profiles.cloudView.compareMode")}),s.jsx("span",{className:"text-bambu-gray",children:Z[0]?o("profiles.cloudView.selectAnotherPreset",{type:Z[0].type}):o("profiles.cloudView.clickTwoPresets")})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`px-2 py-1 text-sm rounded truncate max-w-[200px] ${Z[0]?"bg-blue-500/30 text-blue-700 dark:text-blue-300":"bg-bambu-dark text-bambu-gray"}`,children:Z[0]?Z[0].name:o("profiles.cloudView.selectFirst")}),s.jsx(uP,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("span",{className:`px-2 py-1 text-sm rounded truncate max-w-[200px] ${Z[1]?"bg-blue-500/30 text-blue-700 dark:text-blue-300":"bg-bambu-dark text-bambu-gray"}`,children:Z[1]?Z[1].name:o("profiles.cloudView.selectSecond")})]}),Z[0]&&Z[1]&&s.jsxs(Te,{size:"sm",onClick:async()=>{try{const[q,te]=await Promise.all([ue.getCloudSettingDetail(Z[0].setting_id),ue.getCloudSettingDetail(Z[1].setting_id)]);se([q.setting||{},te.setting||{}]),X(!0)}catch{}},children:[s.jsx(_g,{className:"w-4 h-4"}),o("profiles.cloudView.compareNow")]})]})]})}),s.jsxs("div",{className:"flex flex-wrap items-center gap-4 mb-4 text-sm text-bambu-gray",children:[e&&s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(er,{className:"w-3 h-3"}),o("profiles.cloudView.lastSynced")," ",CKe(e.toISOString(),o)]}),s.jsx("span",{children:o("profiles.cloudView.showingCount",{showing:ie.length,total:ce})}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-bambu-green"}),s.jsxs("span",{children:["= ",o("profiles.presets.myPreset")]})]})]}),ie.length===0?s.jsxs("div",{className:"text-center py-16",children:[s.jsx(sl,{className:"w-12 h-12 text-bambu-gray-dark mx-auto mb-4"}),s.jsx("p",{className:"text-bambu-gray",children:o("profiles.cloudView.noPresetsFound")}),Y&&s.jsx("button",{onClick:G,className:"mt-2 text-sm text-bambu-green hover:text-bambu-green-light",children:o("profiles.cloudView.clearFilters")})]}):s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[s.jsx(TR,{className:"w-4 h-4 text-amber-400"}),s.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:o("profiles.cloudView.columns.filament")}),s.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",ie.filter(q=>q.type==="filament").length,")"]})]}),s.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[ie.filter(q=>q.type==="filament").map(q=>s.jsx(Gj,{setting:q,onClick:()=>Ne(q),onDuplicate:()=>ge(q),compareMode:V,isCompareSelected:Oe(q)!==void 0,compareIndex:Oe(q),compareDisabled:V&&!!Z[0]&&Z[0].type!==q.type,t:o},q.setting_id)),ie.filter(q=>q.type==="filament").length===0&&s.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:o("profiles.cloudView.noFilamentPresets")})]})]}),s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[s.jsx(bh,{className:"w-4 h-4 text-blue-400"}),s.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:o("profiles.cloudView.columns.process")}),s.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",ie.filter(q=>q.type==="process").length,")"]})]}),s.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[ie.filter(q=>q.type==="process").map(q=>s.jsx(Gj,{setting:q,onClick:()=>Ne(q),onDuplicate:()=>ge(q),compareMode:V,isCompareSelected:Oe(q)!==void 0,compareIndex:Oe(q),compareDisabled:V&&!!Z[0]&&Z[0].type!==q.type,t:o},q.setting_id)),ie.filter(q=>q.type==="process").length===0&&s.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:o("profiles.cloudView.noProcessPresets")})]})]}),s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[s.jsx(Ur,{className:"w-4 h-4 text-purple-400"}),s.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:o("profiles.cloudView.columns.printer")}),s.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",ie.filter(q=>q.type==="printer").length,")"]})]}),s.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[ie.filter(q=>q.type==="printer").map(q=>s.jsx(Gj,{setting:q,onClick:()=>Ne(q),onDuplicate:()=>ge(q),compareMode:V,isCompareSelected:Oe(q)!==void 0,compareIndex:Oe(q),compareDisabled:V&&!!Z[0]&&Z[0].type!==q.type,t:o},q.setting_id)),ie.filter(q=>q.type==="printer").length===0&&s.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:o("profiles.cloudView.noPrinterPresets")})]})]})]}),k&&s.jsx(DKe,{setting:k,onClose:()=>C(null),onDeleted:()=>C(null),onDuplicate:()=>ge(k),onEdit:()=>Ke(k),hasPermission:a,t:o}),(E||U||$||H)&&s.jsx(OKe,{onClose:()=>{D(!1),F(null),j(null),K(null)},initialData:$||U||(H?{type:H.type,name:"",base_id:"",setting:H.setting}:void 0),allPresets:t,t:o}),A&&s.jsx(RKe,{onClose:()=>R(!1),onApply:q=>{K({type:q.type,setting:q.settings}),R(!1)},t:o}),B&&ne&&Z[0]&&Z[1]&&s.jsx(Ire,{onClose:()=>{X(!1),se(null)},leftPreset:ne[0],rightPreset:ne[1],leftLabel:Z[0].name,rightLabel:Z[1].name,t:o})]})}function FKe(){const{t}=Hn(),e=an(),{showToast:n}=$n(),{hasPermission:r}=Ai(),[i,a]=_.useState("cloud"),[o,l]=_.useState(),{data:c,isLoading:u}=at({queryKey:["cloudStatus"],queryFn:ue.getCloudStatus}),{data:d=[]}=at({queryKey:["printers"],queryFn:ue.getPrinters}),{data:f,isLoading:p,refetch:m,dataUpdatedAt:x}=at({queryKey:["cloudSettings"],queryFn:()=>ue.getCloudSettings(),enabled:!!c?.is_authenticated,retry:!1,staleTime:1e3*60*5});_.useEffect(()=>{x&&l(new Date(x))},[x]);const b=mt({mutationFn:ue.cloudLogout,onSuccess:()=>{e.invalidateQueries({queryKey:["cloudStatus"]}),e.removeQueries({queryKey:["cloudSettings"]}),n(t("profiles.toast.loggedOut"))}}),y=()=>{e.invalidateQueries({queryKey:["cloudStatus"]})};return u?s.jsx("div",{className:"p-4 md:p-8 flex items-center justify-center min-h-[400px]",children:s.jsx(ht,{className:"w-8 h-8 text-bambu-green animate-spin"})}):s.jsxs("div",{className:"p-6 lg:p-8",children:[s.jsxs("div",{className:"mb-6",children:[s.jsx("h1",{className:"text-2xl font-bold text-white",children:t("profiles.title")}),s.jsx("p",{className:"text-bambu-gray",children:t("profiles.subtitle")})]}),s.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary mb-6",children:[s.jsxs("button",{onClick:()=>a("cloud"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${i==="cloud"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[s.jsx(oN,{className:"w-4 h-4"}),t("profiles.tabs.cloud")]}),s.jsxs("button",{onClick:()=>a("kprofiles"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${i==="kprofiles"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[s.jsx(dN,{className:"w-4 h-4"}),t("profiles.tabs.kprofiles")]})]}),i==="cloud"&&s.jsxs(s.Fragment,{children:[c?.is_authenticated&&s.jsxs("div",{className:"flex items-center justify-between p-3 mb-6 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-2 h-2 rounded-full bg-bambu-green animate-pulse"}),s.jsxs("span",{className:"text-sm text-bambu-gray",children:[t("profiles.connectedAs")," ",s.jsx("span",{className:"text-white",children:c.email})]})]}),s.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>b.mutate(),disabled:b.isPending||!r("cloud:auth"),title:r("cloud:auth")?void 0:t("profiles.noLogoutPermission"),children:[s.jsx(gP,{className:"w-4 h-4"}),t("profiles.logout")]})]}),c?.is_authenticated?p?s.jsx("div",{className:"flex items-center justify-center py-16",children:s.jsx(ht,{className:"w-8 h-8 text-bambu-green animate-spin"})}):f?s.jsx(LKe,{settings:f,lastSyncTime:o,onRefresh:()=>m(),isRefreshing:p,printers:d,hasPermission:r,t}):s.jsxs("div",{className:"text-center py-16",children:[s.jsx("p",{className:"text-bambu-gray mb-4",children:t("profiles.failedToLoad")}),s.jsx(Te,{onClick:()=>m(),children:t("profiles.retry")})]}):s.jsx(jKe,{onSuccess:y,t})]}),i==="kprofiles"&&s.jsx(AKe,{}),s.jsx(PKe,{})]})}const g0={Droplet:TR,Flame:Due,Ruler:hhe,Sparkles:W0,Square:ll,Cable:kce,Wrench:om,Calendar:si,Timer:xu,Cog:sue,Fan:gW,Zap:vh,Wind:CW,Thermometer:bN,Layers:sl,Box:lo,Target:EW,RefreshCw:Dr,Settings:xN,Filter:uN,CircleDot:Gce};function z0(t){return t&&g0[t]||om}function ig(t,e,n){if(e==="days"){if(t<1)return n?n("common.today"):"Today";if(t===1)return n?n("maintenance.day"):"1 day";if(t<7){const i=Math.round(t);return n?n("maintenance.days",{count:i}):`${i} days`}if(t<180){const i=Math.round(t/7);return i===1?n?n("maintenance.week"):"1 week":n?n("maintenance.weeks",{count:i}):`${i} weeks`}const r=Math.round(t/30);return r===1?n?n("maintenance.month"):"1 month":n?n("maintenance.months",{count:r}):`${r} months`}else{if(t<1)return`${Math.round(t*60)}m`;if(t<24)return`${t<10?t.toFixed(1):Math.round(t)}h`;const r=t/24;if(r<7)return`${r<2?r.toFixed(1):Math.round(r)}d`;const i=r/7;return i<12?`${i<2?i.toFixed(1):Math.round(i)}w`:`${Math.round(i/4)}mo`}}function qj(t,e,n){return e==="days"?t===1?n?n("maintenance.day"):"1 day":t===7?n?n("maintenance.week"):"1 week":t===14?n?n("maintenance.weeks",{count:2}):"2 weeks":t===30?n?n("maintenance.month"):"1 month":t===60?n?n("maintenance.months",{count:2}):"2 months":t===90?n?n("maintenance.months",{count:3}):"3 months":t===180?n?n("maintenance.months",{count:6}):"6 months":t===365?n?n("maintenance.year"):"1 year":n?n("maintenance.days",{count:t}):`${t} days`:`${t}h`}function IKe(t,e){const n=(e||"").toUpperCase().replace(/[- ]/g,""),r=n.includes("X1"),i=n.includes("P1"),a=n.includes("A1MINI"),o=n.includes("A1")&&!a,l=n.includes("H2D"),c=n.includes("H2C"),u=n.includes("H2S"),d=l||c||u,f=n.includes("P2S");switch(t){case"Lubricate Linear Rails":return r?"https://wiki.bambulab.com/en/x1/maintenance/basic-maintenance":i?"https://wiki.bambulab.com/en/p1/maintenance/p1p-maintenance":a?"https://wiki.bambulab.com/en/a1-mini/maintenance/lubricate-y-axis":o?"https://wiki.bambulab.com/en/a1/maintenance/lubricate-y-axis":d?"https://wiki.bambulab.com/en/h2/maintenance/x-axis-lubrication":f?"https://wiki.bambulab.com/en/p2s/maintenance/belt-tension":"https://wiki.bambulab.com/en/general/lead-screws-lubrication";case"Clean Nozzle/Hotend":return r||i?"https://wiki.bambulab.com/en/x1/troubleshooting/nozzle-clog":a||o?"https://wiki.bambulab.com/en/a1-mini/troubleshooting/nozzle-clog":d?"https://wiki.bambulab.com/en/h2/maintenance/nozzl-cold-pull-maintenance-and-cleaning":f?"https://wiki.bambulab.com/en/p2s/maintenance/cold-pull-maintenance-hotend":"https://wiki.bambulab.com/en/x1/troubleshooting/nozzle-clog";case"Check Belt Tension":return r?"https://wiki.bambulab.com/en/x1/maintenance/belt-tension":i?"https://wiki.bambulab.com/en/p1/maintenance/p1p-maintenance":a?"https://wiki.bambulab.com/en/a1-mini/maintenance/belt_tension":o?"https://wiki.bambulab.com/en/a1/maintenance/belt_tension":l?"https://wiki.bambulab.com/en/h2/maintenance/belt-tension":c?"https://wiki.bambulab.com/en/h2c/maintenance/belt-tension":u?"https://wiki.bambulab.com/en/h2s/maintenance/belt-tension":f?"https://wiki.bambulab.com/en/p2s/maintenance/belt-tension":"https://wiki.bambulab.com/en/x1/maintenance/belt-tension";case"Clean Carbon Rods":return r||i?"https://wiki.bambulab.com/en/general/carbon-rods-clearance":a||o||d||f?null:"https://wiki.bambulab.com/en/general/carbon-rods-clearance";case"Clean Build Plate":return"https://wiki.bambulab.com/en/filament-acc/acc/pei-plate-clean-guide";case"Check PTFE Tube":return r||i?"https://wiki.bambulab.com/en/x1/maintenance/replace-ptfe-tube":a||o?"https://wiki.bambulab.com/en/a1-mini/maintenance/ptfe-tube":l?"https://wiki.bambulab.com/en/h2/maintenance/replace-ptfe-tube-on-h2d-printer":u?"https://wiki.bambulab.com/en/h2s/maintenance/replace-ptfe-tube-on-h2s-printer":c?"https://wiki.bambulab.com/en/h2/maintenance/replace-ptfe-tube-on-h2d-printer":"https://wiki.bambulab.com/en/x1/maintenance/replace-ptfe-tube";case"Replace HEPA Filter":case"HEPA Filter":case"Replace Carbon Filter":case"Carbon Filter":return d?"https://wiki.bambulab.com/en/h2/maintenance/replace-smoke-purifier-air-filte":"https://wiki.bambulab.com/en/x1/maintenance/replace-carbon-filter";case"Lubricate Left Nozzle Rail":case"Left Nozzle Rail":return d?"https://wiki.bambulab.com/en/h2/maintenance/x-axis-lubrication":null;default:return null}}function UKe({item:t,onPerform:e,onToggle:n,hasPermission:r,t:i}){const a=z0(t.maintenance_type_icon),o=t.interval_type||"hours",c=(()=>{if(o==="days"){const m=t.days_since_maintenance??0;return Math.max(0,Math.min(100,m/t.interval_hours*100))}return Math.max(0,Math.min(100,(t.interval_hours-t.hours_until_due)/t.interval_hours*100))})(),u=()=>t.enabled?t.is_due?"text-red-400":t.is_warning?"text-amber-400":"text-bambu-green":"text-bambu-gray",d=()=>t.enabled?t.is_due?"bg-red-500":t.is_warning?"bg-amber-500":"bg-bambu-green":"bg-bambu-gray/30",f=()=>t.enabled?t.is_due?"bg-red-500/5 border-red-500/20":t.is_warning?"bg-amber-500/5 border-amber-500/20":"bg-bambu-dark-secondary border-bambu-dark-tertiary":"bg-bambu-dark-secondary/50",p=()=>{if(!t.enabled)return i("common.disabled");if(o==="days"){const m=t.days_until_due??0;return t.is_due?i("maintenance.overdueBy",{duration:ig(Math.abs(m),"days",i)}):t.is_warning?i("maintenance.dueIn",{duration:ig(m,"days",i)}):i("maintenance.timeLeft",{duration:ig(m,"days",i)})}else return t.is_due?i("maintenance.overdueBy",{duration:ig(Math.abs(t.hours_until_due),"hours",i)}):t.is_warning?i("maintenance.dueIn",{duration:ig(t.hours_until_due,"hours",i)}):i("maintenance.timeLeft",{duration:ig(t.hours_until_due,"hours",i)})};return s.jsx("div",{className:`rounded-xl border p-4 transition-all ${f()}`,children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsxs("div",{className:`relative p-2.5 rounded-lg ${t.is_due?"bg-red-500/20":t.is_warning?"bg-amber-500/20":t.enabled?"bg-bambu-dark":"bg-bambu-dark/50"}`,children:[s.jsx(a,{className:`w-5 h-5 ${u()}`}),t.enabled&&(t.is_due||t.is_warning)&&s.jsx("span",{className:`absolute -top-1 -right-1 w-2.5 h-2.5 rounded-full ${t.is_due?"bg-red-500":"bg-amber-500"} animate-pulse`})]}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("h3",{className:`font-medium truncate ${t.enabled?"text-white":"text-bambu-gray"}`,children:t.maintenance_type_name}),o==="days"&&s.jsx("span",{title:i("maintenance.timeBasedInterval"),children:s.jsx(si,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"})}),(()=>{const m=t.maintenance_type_wiki_url||IKe(t.maintenance_type_name,t.printer_model);return m?s.jsx("a",{href:m,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-gray hover:text-bambu-green transition-colors shrink-0",title:i("maintenance.viewDocumentation"),onClick:x=>x.stopPropagation(),children:s.jsx(Kr,{className:"w-3.5 h-3.5"})}):null})()]}),s.jsx("div",{className:"mt-2 mb-1.5",children:s.jsx("div",{className:"w-full h-1.5 bg-bambu-dark rounded-full overflow-hidden",children:s.jsx("div",{className:`h-full rounded-full transition-all duration-500 ${d()}`,style:{width:`${c}%`}})})}),s.jsxs("div",{className:`text-xs flex items-center gap-1 ${u()}`,children:[t.is_due&&s.jsx(Cn,{className:"w-3 h-3"}),t.is_warning&&!t.is_due&&s.jsx(er,{className:"w-3 h-3"}),!t.is_due&&!t.is_warning&&t.enabled&&s.jsx(Ia,{className:"w-3 h-3"}),p()]})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s.jsx("span",{title:r("maintenance:update")?void 0:i("maintenance.noPermissionUpdate"),children:s.jsx(On,{checked:t.enabled,onChange:m=>n(t.id,m),disabled:!r("maintenance:update")})}),s.jsxs(Te,{size:"sm",variant:t.is_due?"primary":"secondary",onClick:()=>e(t.id),disabled:!t.enabled||!r("maintenance:update"),title:r("maintenance:update")?void 0:i("maintenance.noPermissionPerform"),className:"!px-3",children:[s.jsx(Rh,{className:"w-3.5 h-3.5"}),i("common.reset")]})]})]})})}function zKe({overview:t,onPerform:e,onToggle:n,onSetHours:r,hasPermission:i,t:a}){const[o,l]=_.useState(!0),[c,u]=_.useState(!1),[d,f]=_.useState(t.total_print_hours.toFixed(1)),p=[...t.maintenance_items].sort((b,y)=>b.is_due&&!y.is_due?-1:!b.is_due&&y.is_due?1:b.is_warning&&!y.is_warning?-1:!b.is_warning&&y.is_warning?1:b.maintenance_type_id-y.maintenance_type_id),m=p.find(b=>b.enabled&&(b.is_due||b.is_warning)),x=()=>{const b=parseFloat(d);!isNaN(b)&&b>=0&&(r(t.printer_id,b),u(!1))};return s.jsxs(_t,{className:"overflow-hidden",children:[s.jsxs("div",{className:"p-5",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx("h2",{className:"text-xl font-semibold text-white",children:t.printer_name}),s.jsxs("div",{className:"flex items-center gap-2",children:[t.due_count>0&&s.jsxs("span",{className:"px-2.5 py-1 bg-red-500/20 text-red-400 text-xs font-medium rounded-full flex items-center gap-1.5",children:[s.jsx(Cn,{className:"w-3 h-3"}),a("maintenance.overdueCount",{count:t.due_count})]}),t.warning_count>0&&s.jsxs("span",{className:"px-2.5 py-1 bg-amber-500/20 text-amber-400 text-xs font-medium rounded-full flex items-center gap-1.5",children:[s.jsx(er,{className:"w-3 h-3"}),a("maintenance.dueSoonCount",{count:t.warning_count})]}),t.due_count===0&&t.warning_count===0&&s.jsxs("span",{className:"px-2.5 py-1 bg-bambu-green/20 text-bambu-green text-xs font-medium rounded-full flex items-center gap-1.5",children:[s.jsx(Ia,{className:"w-3 h-3"}),a("maintenance.allGood")]})]})]}),s.jsxs("button",{onClick:()=>l(!o),className:"flex items-center gap-1.5 px-3 py-1.5 text-sm text-bambu-gray hover:text-white hover:bg-bambu-dark rounded-lg transition-colors",children:[o?s.jsx(xh,{className:"w-4 h-4"}):s.jsx(ei,{className:"w-4 h-4"}),a(o?"common.collapse":"common.expand")]})]}),s.jsxs("div",{className:"flex items-center gap-6 mt-4",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2 bg-bambu-dark/50 rounded-lg",children:s.jsx(xu,{className:"w-4 h-4 text-bambu-gray"})}),c?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",value:d,onChange:b=>f(b.target.value),onKeyDown:b=>{b.key==="Enter"&&x(),b.key==="Escape"&&u(!1)},className:"w-24 px-2 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm",min:"0",step:"1",autoFocus:!0}),s.jsx("span",{className:"text-xs text-bambu-gray",children:a("common.hours")}),s.jsx(Te,{size:"sm",onClick:x,children:a("common.save")}),s.jsx(Te,{size:"sm",variant:"secondary",onClick:()=>u(!1),children:a("common.cancel")})]}):s.jsxs("button",{onClick:()=>{i("maintenance:update")&&(f(Math.round(t.total_print_hours).toString()),u(!0))},className:`group ${i("maintenance:update")?"":"cursor-not-allowed opacity-60"}`,title:i("maintenance:update")?void 0:a("maintenance.noPermissionEditHours"),children:[s.jsxs("div",{className:`text-sm font-medium text-white ${i("maintenance:update")?"group-hover:text-bambu-green":""} transition-colors flex items-center gap-1`,children:[Math.round(t.total_print_hours)," ",a("common.hours"),s.jsx(rm,{className:`w-3 h-3 text-bambu-gray ${i("maintenance:update")?"group-hover:text-bambu-green":""}`})]}),s.jsx("div",{className:"text-xs text-bambu-gray",children:a("maintenance.totalPrintTime")})]})]}),s.jsx("div",{className:"w-px h-10 bg-bambu-dark-tertiary"}),m&&s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:`p-2 rounded-lg ${m.is_due?"bg-red-500/20":"bg-amber-500/20"}`,children:(()=>{const b=z0(m.maintenance_type_icon);return s.jsx(b,{className:`w-4 h-4 ${m.is_due?"text-red-400":"text-amber-400"}`})})()}),s.jsxs("div",{children:[s.jsx("div",{className:`text-sm font-medium ${m.is_due?"text-red-400":"text-amber-400"}`,children:m.maintenance_type_name}),s.jsx("div",{className:`text-xs ${m.is_due?"text-red-400/70":"text-amber-400/70"}`,children:m.is_due?a("common.overdue"):a("maintenance.dueSoon")})]})]})]})]}),o&&s.jsx(Mt,{className:"pt-0 border-t border-bambu-dark-tertiary",children:s.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-3 pt-4",children:p.map(b=>s.jsx(UKe,{item:b,onPerform:e,onToggle:n,hasPermission:i,t:a},b.id))})})]})}function BKe({overview:t,types:e,onUpdateInterval:n,onAddType:r,onUpdateType:i,onDeleteType:a,onAssignType:o,onRemoveItem:l,hasPermission:c,t:u}){const[d,f]=_.useState(null),[p,m]=_.useState(""),[x,b]=_.useState("hours"),[y,v]=_.useState(!1),[S,N]=_.useState(""),[T,k]=_.useState("100"),[C,E]=_.useState("hours"),[D,A]=_.useState("Wrench"),[R,U]=_.useState(""),[F,$]=_.useState(new Set),[j,H]=_.useState(null),K=_.useMemo(()=>t?t.map(I=>({id:I.printer_id,name:I.printer_name})):[],[t]),V=I=>t?t.filter(fe=>fe.maintenance_items.some(me=>me.maintenance_type_id===I)).map(fe=>({printerId:fe.printer_id,printerName:fe.printer_name,itemId:fe.maintenance_items.find(me=>me.maintenance_type_id===I)?.id})):[],Q=I=>{if(!t)return[];const fe=new Set(V(I).map(me=>me.printerId));return K.filter(me=>!fe.has(me.id))},[Z,ae]=_.useState(null),[B,X]=_.useState(""),[ne,se]=_.useState(""),[be,xe]=_.useState("hours"),[de,Pe]=_.useState("Wrench"),[ie,Ne]=_.useState(""),Oe=I=>{ae(I),X(I.name),se(I.default_interval_hours.toString()),xe(I.interval_type||"hours"),Pe(I.icon||"Wrench"),Ne(I.wiki_url||"")},ge=()=>{Z&&B.trim()&&parseFloat(ne)>0&&(i(Z.id,{name:B.trim(),default_interval_hours:parseFloat(ne),interval_type:be,icon:de,wiki_url:ie.trim()||null}),ae(null))},Ke=(I,fe,me)=>{const Ee=parseFloat(p);if(!isNaN(Ee)&&Ee>0){const z=Math.abs(Ee-fe)<.01?null:Ee;n(I,{custom_interval_hours:z,custom_interval_type:x!==me?x:null})}f(null)},G=I=>{I.preventDefault(),S.trim()&&parseFloat(T)>0&&F.size>0&&(r({name:S.trim(),default_interval_hours:parseFloat(T),interval_type:C,icon:D,wiki_url:R.trim()||null},Array.from(F)),N(""),k("100"),E("hours"),U(""),$(new Set),v(!1))},Y=I=>{$(fe=>{const me=new Set(fe);return me.has(I)?me.delete(I):me.add(I),me})},ce=t?.map(I=>({printerId:I.printer_id,printerName:I.printer_name,items:I.maintenance_items.sort((fe,me)=>fe.maintenance_type_id-me.maintenance_type_id)})).sort((I,fe)=>I.printerName.localeCompare(fe.printerName))||[],q=e.filter(I=>I.is_system),te=e.filter(I=>!I.is_system);return s.jsxs("div",{className:"space-y-8",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:u("maintenance.maintenanceTypes")}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:u("maintenance.maintenanceTypesDescription")})]}),s.jsxs(Te,{onClick:()=>v(!y),disabled:!c("maintenance:create"),title:c("maintenance:create")?void 0:u("maintenance.noPermissionEditTypes"),children:[s.jsx(dr,{className:"w-4 h-4"}),u("maintenance.addCustomType")]})]}),y&&s.jsx(_t,{className:"mb-6",children:s.jsx(Mt,{className:"py-4",children:s.jsxs("form",{onSubmit:G,children:[s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[s.jsxs("div",{className:"lg:col-span-2",children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:u("common.name")}),s.jsx("input",{type:"text",value:S,onChange:I=>N(I.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",placeholder:u("maintenance.exampleName"),autoFocus:!0})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:u("maintenance.intervalType")}),s.jsxs("select",{value:C,onChange:I=>{E(I.target.value),I.target.value==="days"?k("30"):k("100")},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"hours",children:u("maintenance.printHours")}),s.jsx("option",{value:"days",children:u("maintenance.calendarDays")})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:u("maintenance.intervalValue",{type:C==="days"?u("maintenance.calendarDays").toLowerCase():u("common.hours")})}),s.jsx("input",{type:"number",value:T,onChange:I=>k(I.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",min:"1"})]})]}),s.jsx("div",{className:"mt-4 flex items-end justify-between",children:s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:u("maintenance.icon")}),s.jsx("div",{className:"flex gap-1",children:Object.keys(g0).map(I=>{const fe=g0[I];return s.jsx("button",{type:"button",onClick:()=>A(I),className:`p-2 rounded-lg transition-colors ${D===I?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:s.jsx(fe,{className:"w-4 h-4"})},I)})})]})}),s.jsxs("div",{className:"mt-4",children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:u("maintenance.documentationLink")}),s.jsx("input",{type:"url",value:R,onChange:I=>U(I.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",placeholder:"https://wiki.bambulab.com/..."})]}),s.jsxs("div",{className:"mt-4",children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:u("maintenance.assignToPrinters")}),s.jsx("div",{className:"flex flex-wrap gap-2",children:K.map(I=>s.jsx("button",{type:"button",onClick:()=>Y(I.id),className:`px-3 py-1.5 rounded-lg text-sm transition-colors ${F.has(I.id)?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:I.name},I.id))}),F.size===0&&s.jsx("p",{className:"text-xs text-orange-400 mt-1",children:u("maintenance.selectAtLeastOnePrinter")})]}),s.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[s.jsx(Te,{type:"button",variant:"secondary",onClick:()=>{v(!1),$(new Set)},children:u("common.cancel")}),s.jsx(Te,{type:"submit",disabled:!S.trim()||F.size===0,children:u("maintenance.addType")})]})]})})}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:[q.map(I=>{const fe=z0(I.icon),me=I.interval_type||"hours";return s.jsx("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-dark-tertiary",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2.5 bg-bambu-dark rounded-lg",children:s.jsx(fe,{className:"w-5 h-5 text-bambu-gray"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm font-medium text-white truncate",children:I.name}),s.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5 flex items-center gap-1",children:[me==="days"?s.jsx(si,{className:"w-3 h-3"}):s.jsx(xu,{className:"w-3 h-3"}),qj(I.default_interval_hours,me,u)]})]})]})},I.id)}),te.map(I=>{const fe=z0(I.icon),me=I.interval_type||"hours";if(Z?.id===I.id)return s.jsx("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-green",children:s.jsxs("div",{className:"space-y-3",children:[s.jsx("input",{type:"text",value:B,onChange:le=>X(le.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",placeholder:u("common.name"),autoFocus:!0}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("select",{value:be,onChange:le=>xe(le.target.value),className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"hours",children:u("maintenance.printHours")}),s.jsx("option",{value:"days",children:u("maintenance.calendarDays")})]}),s.jsx("input",{type:"number",value:ne,onChange:le=>se(le.target.value),className:"w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",min:"1"})]}),s.jsx("div",{className:"flex flex-wrap gap-1",children:Object.keys(g0).map(le=>{const _e=g0[le];return s.jsx("button",{type:"button",onClick:()=>Pe(le),className:`p-1.5 rounded transition-colors ${de===le?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:s.jsx(_e,{className:"w-3.5 h-3.5"})},le)})}),s.jsx("input",{type:"url",value:ie,onChange:le=>Ne(le.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",placeholder:u("maintenance.documentationLink")}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Te,{size:"sm",onClick:ge,disabled:!B.trim(),children:u("common.save")}),s.jsx(Te,{size:"sm",variant:"secondary",onClick:()=>ae(null),children:u("common.cancel")})]})]})},I.id);const z=V(I.id),O=Q(I.id),ee=j===I.id;return s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-green/30",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2.5 bg-bambu-green/20 rounded-lg",children:s.jsx(fe,{className:"w-5 h-5 text-bambu-green"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-sm font-medium text-white truncate",children:I.name}),s.jsx("span",{className:"px-1.5 py-0.5 bg-bambu-green/20 text-bambu-green text-[10px] font-medium rounded",children:u("maintenance.custom")})]}),s.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5 flex items-center gap-1",children:[me==="days"?s.jsx(si,{className:"w-3 h-3"}):s.jsx(xu,{className:"w-3 h-3"}),qj(I.default_interval_hours,me,u)]})]}),s.jsxs("button",{onClick:()=>H(ee?null:I.id),className:`px-2 py-1 rounded-lg border transition-colors flex items-center gap-1 ${z.length>0?"border-bambu-green/50 bg-bambu-green/10 text-bambu-green hover:bg-bambu-green/20":"border-orange-400/50 bg-orange-400/10 text-orange-400 hover:bg-orange-400/20"}`,title:u("maintenance.printersAssignedClick",{count:z.length}),children:[s.jsx(Ur,{className:"w-3 h-3"}),s.jsx("span",{className:"text-xs font-medium",children:z.length}),s.jsx(ei,{className:`w-3 h-3 transition-transform ${ee?"rotate-180":""}`})]}),s.jsx("button",{onClick:()=>Oe(I),disabled:!c("maintenance:update"),title:c("maintenance:update")?void 0:u("maintenance.noPermissionEditTypes"),className:`p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors ${c("maintenance:update")?"":"opacity-50 cursor-not-allowed"}`,children:s.jsx(rm,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>{confirm(u("maintenance.deleteTypeConfirm",{name:I.name}))&&a(I.id)},disabled:!c("maintenance:delete"),title:c("maintenance:delete")?void 0:u("maintenance.noPermissionDeleteTypes"),className:`p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-red-400 transition-colors ${c("maintenance:delete")?"":"opacity-50 cursor-not-allowed"}`,children:s.jsx(rn,{className:"w-4 h-4"})})]}),ee&&s.jsxs("div",{className:"mt-3 pt-3 border-t border-bambu-dark-tertiary",children:[s.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:u("maintenance.assignedToPrinters")}),z.length===0?s.jsx("p",{className:"text-xs text-orange-400",children:u("maintenance.noPrintersAssigned")}):s.jsx("div",{className:"flex flex-wrap gap-1 mb-2",children:z.map(le=>s.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-dark rounded text-xs text-white",children:[le.printerName,s.jsx("button",{onClick:()=>le.itemId&&l(le.itemId),disabled:!c("maintenance:delete"),title:c("maintenance:delete")?u("maintenance.removeFromPrinter"):u("maintenance.noPermissionRemovePrinter"),className:`ml-1 ${c("maintenance:delete")?"hover:text-red-400":"opacity-50 cursor-not-allowed"}`,children:"×"})]},le.printerId))}),O.length>0&&s.jsxs("div",{className:"flex flex-wrap gap-1",children:[s.jsx("span",{className:"text-xs text-bambu-gray mr-1",children:u("maintenance.addPrinterShort")}),O.map(le=>s.jsxs("button",{onClick:()=>o(le.id,I.id),disabled:!c("maintenance:create"),title:c("maintenance:create")?void 0:u("maintenance.noPermissionAssignPrinter"),className:`px-2 py-1 bg-bambu-dark rounded text-xs transition-colors ${c("maintenance:create")?"hover:bg-bambu-green/20 text-bambu-gray hover:text-bambu-green":"opacity-50 cursor-not-allowed text-bambu-gray"}`,children:["+ ",le.name]},le.id))]})]})]},I.id)})]})]}),ce.length>0&&s.jsxs("div",{children:[s.jsxs("div",{className:"mb-4",children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:u("maintenance.intervalOverrides")}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:u("maintenance.intervalOverridesDescription")})]}),s.jsx("div",{className:"space-y-4",children:ce.map(I=>s.jsx(_t,{children:s.jsxs(Mt,{className:"py-4",children:[s.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:I.printerName}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-2",children:I.items.map(fe=>{const me=z0(fe.maintenance_type_icon),Ee=e.find(_e=>_e.id===fe.maintenance_type_id),z=Ee?.default_interval_hours||fe.interval_hours,O=Ee?.interval_type||"hours",ee=fe.interval_type||"hours",le=d===fe.id;return s.jsxs("div",{className:"flex items-center gap-2 p-2.5 bg-bambu-dark rounded-lg",children:[s.jsx(me,{className:"w-4 h-4 text-bambu-gray shrink-0"}),s.jsx("span",{className:"text-xs text-bambu-gray flex-1 truncate",children:fe.maintenance_type_name}),le?s.jsxs("div",{className:"flex items-center gap-1",children:[x==="days"?s.jsx(si,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"}):s.jsx(xu,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"}),s.jsxs("select",{value:x,onChange:_e=>b(_e.target.value),className:"px-1.5 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-xs",children:[s.jsx("option",{value:"hours",children:u("maintenance.printHours")}),s.jsx("option",{value:"days",children:u("maintenance.calendarDays")})]}),s.jsx("input",{type:"number",value:p,onChange:_e=>m(_e.target.value),onKeyDown:_e=>{_e.key==="Enter"&&Ke(fe.id,z,O),_e.key==="Escape"&&f(null)},className:"w-16 px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-xs",min:"1"}),s.jsx(Te,{size:"sm",onClick:()=>Ke(fe.id,z,O),children:"OK"})]}):s.jsxs("button",{onClick:()=>{c("maintenance:update")&&(f(fe.id),m(fe.interval_hours.toString()),b(ee))},disabled:!c("maintenance:update"),title:c("maintenance:update")?void 0:u("maintenance.noPermissionEditIntervals"),className:`px-2 py-1 bg-bambu-dark-tertiary border border-bambu-dark-tertiary rounded text-xs font-medium text-white transition-colors flex items-center gap-1 ${c("maintenance:update")?"hover:bg-bambu-dark-secondary hover:border-bambu-green":"opacity-50 cursor-not-allowed"}`,children:[ee==="days"?s.jsx(si,{className:"w-3 h-3"}):s.jsx(xu,{className:"w-3 h-3"}),qj(fe.interval_hours,ee,u),s.jsx(rm,{className:"w-3 h-3 text-bambu-gray"})]})]},fe.id)})})]})},I.printerId))})]}),ce.length===0&&s.jsx(_t,{children:s.jsxs(Mt,{className:"text-center py-12",children:[s.jsx(er,{className:"w-12 h-12 mx-auto mb-4 text-bambu-gray/30"}),s.jsx("p",{className:"text-bambu-gray",children:u("common.noPrinters")}),s.jsx("p",{className:"text-sm text-bambu-gray/70 mt-1",children:u("maintenance.intervalOverridesDescription")})]})})]})}function HKe(){const{t}=Hn(),e=an(),{showToast:n}=$n(),{hasPermission:r}=Ai(),[i,a]=_.useState("status"),{data:o,isLoading:l}=at({queryKey:["maintenanceOverview"],queryFn:ue.getMaintenanceOverview}),{data:c}=at({queryKey:["maintenanceTypes"],queryFn:ue.getMaintenanceTypes}),u=mt({mutationFn:({id:k,notes:C})=>ue.performMaintenance(k,C),onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceOverview"]}),e.invalidateQueries({queryKey:["maintenanceSummary"]}),n(t("maintenance.maintenanceComplete"))},onError:k=>{n(k.message,"error")}}),d=mt({mutationFn:({id:k,data:C})=>ue.updateMaintenanceItem(k,C),onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceOverview"]})},onError:k=>{n(k.message,"error")}}),f=mt({mutationFn:({id:k,data:C})=>ue.updateMaintenanceType(k,C),onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceTypes"]}),e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.typeUpdated"))},onError:k=>{n(k.message,"error")}}),p=mt({mutationFn:ue.deleteMaintenanceType,onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceTypes"]}),e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.typeDeleted"))},onError:k=>{n(k.message,"error")}}),m=mt({mutationFn:({printerId:k,hours:C})=>ue.setPrinterHours(k,C),onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceOverview"]}),e.invalidateQueries({queryKey:["maintenanceSummary"]}),n(t("maintenance.printHoursUpdated"))},onError:k=>{n(k.message,"error")}}),x=mt({mutationFn:({printerId:k,typeId:C})=>ue.assignMaintenanceType(k,C),onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.printerAssigned"))},onError:k=>{n(k.message,"error")}}),b=mt({mutationFn:ue.removeMaintenanceItem,onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.printerRemoved"))},onError:k=>{n(k.message,"error")}}),y=k=>{u.mutate({id:k})},v=(k,C)=>{d.mutate({id:k,data:{enabled:C}})},S=(k,C)=>{m.mutate({printerId:k,hours:C})};if(l)return s.jsx("div",{className:"p-4 md:p-8 flex justify-center",children:s.jsx(ht,{className:"w-8 h-8 text-bambu-green animate-spin"})});const N=o?.reduce((k,C)=>k+C.due_count,0)||0,T=o?.reduce((k,C)=>k+C.warning_count,0)||0;return s.jsxs("div",{className:"p-4 md:p-8",children:[s.jsxs("div",{className:"mb-6",children:[s.jsx("h1",{className:"text-2xl font-bold text-white",children:t("maintenance.title")}),s.jsx("p",{className:"text-bambu-gray text-sm mt-1",children:i==="status"?s.jsxs(s.Fragment,{children:[N>0&&s.jsx("span",{className:"text-red-400",children:t("maintenance.dueCount",{count:N})}),N>0&&T>0&&" · ",T>0&&s.jsx("span",{className:"text-amber-400",children:t("maintenance.warningCount",{count:T})}),N===0&&T===0&&s.jsx("span",{className:"text-bambu-green",children:t("maintenance.allOk")})]}):t("maintenance.configureSettings")})]}),s.jsxs("div",{className:"flex gap-1 mb-6 border-b border-bambu-dark-tertiary",children:[s.jsx("button",{onClick:()=>a("status"),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${i==="status"?"text-bambu-green border-bambu-green":"text-bambu-gray border-transparent hover:text-white"}`,children:t("maintenance.statusTab")}),s.jsx("button",{onClick:()=>a("settings"),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${i==="settings"?"text-bambu-green border-bambu-green":"text-bambu-gray border-transparent hover:text-white"}`,children:t("maintenance.settingsTab")})]}),i==="status"?s.jsx("div",{className:"space-y-6",children:o&&o.length>0?[...o].sort((k,C)=>{const E=k.due_count*10+k.warning_count,D=C.due_count*10+C.warning_count;return E!==D?D-E:k.printer_name.localeCompare(C.printer_name)}).map(k=>s.jsx(zKe,{overview:k,onPerform:y,onToggle:v,onSetHours:S,hasPermission:r,t},k.printer_id)):s.jsx(_t,{children:s.jsxs(Mt,{className:"text-center py-16",children:[s.jsx(om,{className:"w-16 h-16 mx-auto mb-4 text-bambu-gray/30"}),s.jsx("p",{className:"text-lg font-medium text-white mb-2",children:t("common.noPrinters")}),s.jsx("p",{className:"text-bambu-gray",children:t("maintenance.configureSettings")})]})})}):s.jsx(BKe,{overview:o,types:c||[],onUpdateInterval:(k,C)=>d.mutate({id:k,data:C}),onAddType:async(k,C)=>{const E=await ue.createMaintenanceType(k);for(const D of C)await ue.assignMaintenanceType(D,E.id);e.invalidateQueries({queryKey:["maintenanceTypes"]}),e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.typeUpdated"))},onUpdateType:(k,C)=>f.mutate({id:k,data:C}),onDeleteType:k=>p.mutate(k),onAssignType:(k,C)=>x.mutate({printerId:k,typeId:C}),onRemoveItem:k=>b.mutate(k),hasPermission:r,t})]})}const pq=["#ef4444","#f97316","#eab308","#22c55e","#06b6d4","#3b82f6","#8b5cf6","#ec4899","#6b7280"];function Ure({project:t,onClose:e,onSave:n,isLoading:r,t:i}){const[a,o]=_.useState(t?.name||""),[l,c]=_.useState(t?.description||""),[u,d]=_.useState(t?.color||pq[0]),[f,p]=_.useState(t?.target_count?.toString()||""),[m,x]=_.useState(t?.target_parts_count?.toString()||""),[b,y]=_.useState(t?.status||"active"),[v,S]=_.useState(t?.tags||""),[N,T]=_.useState(t?.due_date?.split("T")[0]||""),[k,C]=_.useState(t?.priority||"normal"),E=D=>{D.preventDefault(),n({name:a.trim(),description:l.trim()||void 0,color:u,target_count:f?parseInt(f,10):void 0,target_parts_count:m?parseInt(m,10):void 0,tags:v.trim()||void 0,due_date:N||void 0,priority:k,...t&&{status:b}})};return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-md border border-bambu-dark-tertiary",children:[s.jsx("div",{className:"p-4 border-b border-bambu-dark-tertiary",children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:i(t?"projects.editProject":"projects.newProject")})}),s.jsxs("form",{onSubmit:E,className:"p-4 space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("common.name")}),s.jsx("input",{type:"text",value:a,onChange:D=>o(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",placeholder:i("projects.namePlaceholder"),required:!0})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("common.description")}),s.jsx("textarea",{value:l,onChange:D=>c(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 resize-none",placeholder:i("projects.descriptionPlaceholder"),rows:2})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("projects.color")}),s.jsx("div",{className:"flex gap-2 flex-wrap",children:pq.map(D=>s.jsx("button",{type:"button",onClick:()=>d(D),className:`w-8 h-8 rounded-full transition-transform ${u===D?"ring-2 ring-white ring-offset-2 ring-offset-bambu-dark-secondary scale-110":""}`,style:{backgroundColor:D}},D))})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("projects.targetPlates")}),s.jsx("input",{type:"number",value:f,onChange:D=>p(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",placeholder:i("projects.targetPlatesPlaceholder"),min:"1"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:i("projects.targetPlatesHelp")})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("projects.targetParts")}),s.jsx("input",{type:"number",value:m,onChange:D=>x(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",placeholder:i("projects.targetPartsPlaceholder"),min:"1"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:i("projects.targetPartsHelp")})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("projects.tagsLabel")}),s.jsx("input",{type:"text",value:v,onChange:D=>S(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",placeholder:i("projects.tagsPlaceholder")})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("projects.dueDate")}),s.jsx("input",{type:"date",value:N,onChange:D=>T(D.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white focus:outline-none focus:border-bambu-green"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("projects.priority")}),s.jsxs("select",{value:k,onChange:D=>C(D.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white focus:outline-none focus:border-bambu-green",children:[s.jsx("option",{value:"low",children:i("projects.priorityLow")}),s.jsx("option",{value:"normal",children:i("projects.priorityNormal")}),s.jsx("option",{value:"high",children:i("projects.priorityHigh")}),s.jsx("option",{value:"urgent",children:i("projects.priorityUrgent")})]})]})]}),t&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("common.status")}),s.jsxs("select",{value:b,onChange:D=>y(D.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white focus:outline-none focus:border-bambu-green",children:[s.jsx("option",{value:"active",children:i("projects.statusActive")}),s.jsx("option",{value:"completed",children:i("projects.statusCompleted")}),s.jsx("option",{value:"archived",children:i("projects.statusArchived")})]})]}),s.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[s.jsx(Te,{type:"button",variant:"secondary",onClick:e,children:i("common.cancel")}),s.jsx(Te,{type:"submit",disabled:!a.trim()||r,children:r?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):i(t?"common.save":"projects.create")})]})]})]})})}function $Ke({project:t,onClick:e,onEdit:n,onDelete:r,hasPermission:i,t:a}){const o=t.target_count?Math.round(t.archive_count/t.target_count*100):0,l=t.target_parts_count?Math.round(t.completed_count/t.target_parts_count*100):0,c=t.status==="completed",u=t.status==="archived",[d,f]=_.useState(!1),m=c?{icon:sN,color:"text-bambu-green",bg:"bg-bambu-green/10"}:u?{icon:fo,color:"text-bambu-gray",bg:"bg-bambu-gray/10"}:t.queue_count>0?{icon:er,color:"text-blue-400",bg:"bg-blue-400/10"}:{icon:Ja,color:"text-bambu-gray",bg:"bg-bambu-gray/10"};return s.jsxs("div",{className:"group relative bg-gradient-to-br from-bambu-card to-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary hover:border-bambu-green/50 hover:shadow-lg hover:shadow-bambu-green/5 transition-all duration-300 cursor-pointer overflow-hidden",onClick:e,children:[s.jsx("div",{className:"absolute top-0 left-0 w-1.5 h-full",style:{backgroundColor:t.color||"#6b7280",boxShadow:`0 0 12px ${t.color||"#6b7280"}40`}}),s.jsxs("div",{className:"p-5 pl-6",children:[s.jsxs("div",{className:"flex items-start justify-between mb-4",children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[s.jsx("div",{className:`p-2 rounded-lg ${m.bg} flex-shrink-0`,children:s.jsx(m.icon,{className:`w-5 h-5 ${m.color}`})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx("h3",{className:"font-semibold text-white truncate",children:t.name}),t.target_parts_count?s.jsxs("span",{className:`text-xs px-2 py-0.5 rounded-full whitespace-nowrap font-medium ${l>=100?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark text-bambu-gray"}`,children:[t.completed_count,"/",t.target_parts_count," ",a("projects.parts")]}):t.target_count?s.jsxs("span",{className:`text-xs px-2 py-0.5 rounded-full whitespace-nowrap font-medium ${o>=100?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark text-bambu-gray"}`,children:[t.archive_count,"/",t.target_count," ",a("projects.plates")]}):t.completed_count>0?s.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full whitespace-nowrap font-medium bg-bambu-dark text-bambu-gray",children:[t.completed_count," ",a("projects.parts")]}):null,c&&s.jsx("span",{className:"text-xs bg-bambu-green/20 text-bambu-green px-2 py-0.5 rounded-full whitespace-nowrap",children:a("projects.done")}),u&&s.jsx("span",{className:"text-xs bg-bambu-gray/20 text-bambu-gray px-2 py-0.5 rounded-full whitespace-nowrap",children:a("projects.statusArchived")})]}),t.description&&s.jsx("p",{className:"text-sm text-bambu-gray/70 mt-1 line-clamp-1",children:t.description}),t.archives&&t.archives.length>0&&(()=>{const x=t.archives.map(S=>S.filament_type).filter(Boolean).flatMap(S=>S.split(",").map(N=>N.trim())).filter(Boolean),b=[...new Set(x)],y=t.archives.map(S=>S.filament_color).filter(Boolean).flatMap(S=>S.split(",").map(N=>N.trim())).filter(S=>S.startsWith("#")||/^[0-9A-Fa-f]{6}$/.test(S)),v=[...new Set(y)];return b.length===0&&v.length===0?null:s.jsxs("div",{className:"flex items-center gap-2 mt-1.5",children:[b.slice(0,3).map(S=>s.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-bambu-dark text-bambu-gray rounded",children:S},S)),v.length>0&&s.jsxs("div",{className:"flex items-center gap-0.5",children:[v.slice(0,5).map(S=>s.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:S.startsWith("#")?S:`#${S}`},title:S},S)),v.length>5&&s.jsxs("span",{className:"text-[10px] text-bambu-gray ml-0.5",children:["+",v.length-5]})]})]})})()]})]}),s.jsxs("div",{className:"relative",onClick:x=>x.stopPropagation(),children:[s.jsx("button",{className:"p-1.5 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors opacity-0 group-hover:opacity-100",onClick:()=>f(!d),children:s.jsx(ih,{className:"w-4 h-4"})}),d&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>f(!1)}),s.jsxs("div",{className:"absolute right-0 top-8 z-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 min-w-[120px]",children:[s.jsxs("button",{className:`w-full px-3 py-2 text-left text-sm flex items-center gap-2 ${i("projects:update")?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{i("projects:update")&&(n(),f(!1))},disabled:!i("projects:update"),title:i("projects:update")?void 0:a("projects.noEditPermission"),children:[s.jsx(rm,{className:"w-4 h-4"}),a("common.edit")]}),s.jsxs("button",{className:`w-full px-3 py-2 text-left text-sm flex items-center gap-2 ${i("projects:delete")?"text-red-400 hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{i("projects:delete")&&(r(),f(!1))},disabled:!i("projects:delete"),title:i("projects:delete")?void 0:a("projects.noDeletePermission"),children:[s.jsx(rn,{className:"w-4 h-4"}),a("common.delete")]})]})]})]})]}),s.jsx("div",{className:"mb-4",children:t.target_count||t.target_parts_count?s.jsxs("div",{className:"space-y-3",children:[t.target_count&&s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between text-xs mb-1",children:[s.jsx("span",{className:"text-bambu-gray",children:a("projects.plates")}),s.jsxs("span",{className:o>=100?"text-bambu-green font-medium":"text-white",children:[t.archive_count," / ",t.target_count]})]}),s.jsx("div",{className:"h-2 bg-bambu-dark/80 rounded-full overflow-hidden backdrop-blur-sm",children:s.jsx("div",{className:"h-full transition-all duration-500 ease-out rounded-full relative",style:{width:`${Math.min(o,100)}%`,background:o>=100?"linear-gradient(90deg, #22c55e, #4ade80)":`linear-gradient(90deg, ${t.color||"#6b7280"}, ${t.color||"#6b7280"}cc)`,boxShadow:`0 0 8px ${o>=100?"#22c55e":t.color||"#6b7280"}60`}})})]}),t.target_parts_count&&s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between text-xs mb-1",children:[s.jsx("span",{className:"text-bambu-gray",children:a("projects.parts")}),s.jsxs("span",{className:l>=100?"text-bambu-green font-medium":"text-white",children:[t.completed_count," / ",t.target_parts_count]})]}),s.jsx("div",{className:"h-2 bg-bambu-dark/80 rounded-full overflow-hidden backdrop-blur-sm",children:s.jsx("div",{className:"h-full transition-all duration-500 ease-out rounded-full relative",style:{width:`${Math.min(l,100)}%`,background:l>=100?"linear-gradient(90deg, #22c55e, #4ade80)":`linear-gradient(90deg, ${t.color||"#6b7280"}, ${t.color||"#6b7280"}cc)`,boxShadow:`0 0 8px ${l>=100?"#22c55e":t.color||"#6b7280"}60`}})})]}),t.failed_count>0&&s.jsxs("div",{className:"text-xs text-red-400",children:[t.failed_count," ",a("projects.failed")]})]}):t.completed_count>0||t.failed_count>0?s.jsxs("div",{className:"flex items-center gap-4 text-xs",children:[t.completed_count>0&&s.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",children:[s.jsx(fo,{className:"w-3.5 h-3.5"}),s.jsxs("span",{children:[t.completed_count," ",a("projects.completed")]})]}),t.failed_count>0&&s.jsxs("div",{className:"flex items-center gap-1.5 text-red-400",children:[s.jsx(Cn,{className:"w-3.5 h-3.5"}),s.jsxs("span",{children:[t.failed_count," ",a("projects.failed")]})]}),t.queue_count>0&&s.jsxs("div",{className:"flex items-center gap-1.5 text-blue-400",children:[s.jsx(er,{className:"w-3.5 h-3.5"}),s.jsxs("span",{children:[t.queue_count," ",a("projects.inQueue")]})]})]}):s.jsx("div",{className:"text-xs text-bambu-gray/60 italic",children:a("projects.noPrintsYet")})}),t.archives&&t.archives.length>0&&s.jsxs("div",{className:"mb-4",children:[s.jsx("div",{className:"grid grid-cols-4 gap-1.5",children:t.archives.slice(0,4).map(x=>s.jsxs("div",{className:"relative aspect-square rounded-lg bg-bambu-dark overflow-hidden border border-bambu-dark-tertiary",title:x.print_name||"Unknown",children:[x.thumbnail_path?s.jsx("img",{src:ue.getArchiveThumbnail(x.id),alt:x.print_name||"",className:"w-full h-full object-cover"}):s.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray/50",children:s.jsx(mc,{className:"w-6 h-6"})}),x.status==="failed"&&s.jsx("div",{className:"absolute inset-0 bg-red-500/40 flex items-center justify-center",children:s.jsx(Cn,{className:"w-4 h-4 text-white"})})]},x.id))}),t.archive_count>4&&s.jsx("p",{className:"text-xs text-bambu-gray mt-1.5 text-center",children:a("common.more",{count:t.archive_count-4})})]}),s.jsxs("div",{className:"flex items-center justify-between pt-3 border-t border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-4 text-xs text-bambu-gray",children:[s.jsxs("div",{className:"flex items-center gap-1.5",title:a("projects.printJobs"),children:[s.jsx(sl,{className:"w-3.5 h-3.5 text-blue-400"}),s.jsxs("span",{children:[t.archive_count," ",a("projects.plates")]})]}),s.jsxs("div",{className:"flex items-center gap-1.5",title:a("projects.partsPrinted"),children:[s.jsx(mc,{className:"w-3.5 h-3.5 text-bambu-green"}),s.jsxs("span",{children:[t.completed_count," ",a("projects.parts")]})]}),t.failed_count>0&&s.jsxs("div",{className:"flex items-center gap-1.5 text-red-400",title:a("projects.failedParts"),children:[s.jsx(Cn,{className:"w-3.5 h-3.5"}),s.jsx("span",{children:t.failed_count})]}),t.queue_count>0&&s.jsxs("div",{className:"flex items-center gap-1.5 text-yellow-400",title:a("projects.inQueue"),children:[s.jsx(pP,{className:"w-3.5 h-3.5"}),s.jsx("span",{children:t.queue_count})]})]}),s.jsx(gs,{className:"w-4 h-4 text-bambu-gray/50 group-hover:text-bambu-gray transition-colors"})]})]})]})}function VKe(){const{t}=Hn(),e=Nc(),n=an(),{showToast:r}=$n(),{hasPermission:i}=Ai(),[a,o]=_.useState(!1),[l,c]=_.useState(),[u,d]=_.useState("active"),[f,p]=_.useState(null),{data:m,isLoading:x}=at({queryKey:["projects",u==="all"?void 0:u],queryFn:()=>ue.getProjects(u==="all"?void 0:u)}),b=mt({mutationFn:$=>ue.createProject($),onSuccess:()=>{n.invalidateQueries({queryKey:["projects"]}),o(!1),r(t("projects.toast.created"),"success")},onError:$=>{r($.message,"error")}}),y=mt({mutationFn:({id:$,data:j})=>ue.updateProject($,j),onSuccess:()=>{n.invalidateQueries({queryKey:["projects"]}),o(!1),c(void 0),r(t("projects.toast.updated"),"success")},onError:$=>{r($.message,"error")}}),v=mt({mutationFn:$=>ue.deleteProject($),onSuccess:()=>{p(null),r(t("projects.toast.deleted"),"success"),setTimeout(()=>window.location.reload(),100)},onError:$=>{p(null),r($.message,"error")}}),S=mt({mutationFn:$=>ue.importProject($),onSuccess:()=>{n.invalidateQueries({queryKey:["projects"]}),r(t("projects.toast.imported"),"success")},onError:$=>{r($.message,"error")}}),N=_.useRef(null),T=async()=>{try{const $=await ue.getProjects(),j=await Promise.all($.map(async Q=>await ue.exportProjectJson(Q.id))),H=new Blob([JSON.stringify(j,null,2)],{type:"application/json"}),K=URL.createObjectURL(H),V=document.createElement("a");V.href=K,V.download=`bambuddy_projects_${new Date().toISOString().split("T")[0]}.json`,V.click(),URL.revokeObjectURL(K),r(t("projects.toast.exported"),"success")}catch($){r($.message,"error")}},k=()=>{N.current?.click()},C=async $=>{const j=$.target.files?.[0];if(j){try{if(j.name.toLowerCase().endsWith(".zip")){const K=new FormData;K.append("file",j);const V=await fetch("/api/v1/projects/import/file",{method:"POST",body:K});if(!V.ok){const Q=await V.json();throw new Error(Q.detail||"Import failed")}n.invalidateQueries({queryKey:["projects"]}),r(t("projects.toast.imported"),"success")}else{const K=await j.text(),V=JSON.parse(K),Q=Array.isArray(V)?V:[V];for(const Z of Q)await S.mutateAsync(Z);Q.length>1&&r(t("projects.toast.multipleImported",{count:Q.length}),"success")}}catch(H){r(`${t("projects.toast.importFailed")}: ${H.message}`,"error")}$.target.value=""}},E=$=>{l?y.mutate({id:l.id,data:$}):b.mutate($)},D=$=>{c($),o(!0)},A=$=>{e(`/projects/${$.id}`)},R=$=>{p($)},U=()=>{f!==null&&v.mutate(f)},F=m?.reduce(($,j)=>($[j.status]=($[j.status]||0)+1,$.all=($.all||0)+1,$),{})||{};return s.jsxs("div",{className:"p-4 md:p-8 space-y-8",children:[s.jsx("input",{ref:N,type:"file",accept:".json,.zip",onChange:C,className:"hidden"}),s.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[s.jsxs("div",{children:[s.jsxs("h1",{className:"text-2xl font-bold text-white flex items-center gap-3",children:[s.jsx("div",{className:"p-2.5 bg-bambu-green/10 rounded-xl",children:s.jsx(Ja,{className:"w-6 h-6 text-bambu-green"})}),t("projects.title")]}),s.jsx("p",{className:"text-sm text-bambu-gray mt-2 ml-14",children:t("projects.subtitle")})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(Te,{variant:"secondary",onClick:k,disabled:!i("projects:create"),title:i("projects:create")?t("projects.importProject"):t("projects.noImportPermission"),children:[s.jsx(Ua,{className:"w-4 h-4 mr-2"}),t("projects.import")]}),s.jsxs(Te,{variant:"secondary",onClick:T,disabled:!i("projects:read"),title:i("projects:read")?t("projects.exportAll"):t("projects.noExportPermission"),children:[s.jsx(yi,{className:"w-4 h-4 mr-2"}),t("projects.export")]}),s.jsxs(Te,{onClick:()=>o(!0),className:"sm:w-auto w-full",disabled:!i("projects:create"),title:i("projects:create")?void 0:t("projects.noCreatePermission"),children:[s.jsx(dr,{className:"w-4 h-4 mr-2"}),t("projects.newProject")]})]})]}),s.jsx("div",{className:"flex gap-1 p-1 bg-bambu-dark rounded-xl w-fit",children:[{key:"active",label:t("projects.statusActive"),icon:er},{key:"completed",label:t("projects.statusCompleted"),icon:sN},{key:"archived",label:t("projects.statusArchived"),icon:fo},{key:"all",label:t("common.all"),icon:Ja}].map(({key:$,label:j,icon:H})=>s.jsxs("button",{onClick:()=>d($),className:`flex items-center gap-2 px-4 py-2 text-sm rounded-lg transition-all ${u===$?"bg-bambu-card text-white shadow-sm":"text-bambu-gray hover:text-white"}`,children:[s.jsx(H,{className:"w-4 h-4"}),s.jsx("span",{children:j}),F[$]>0&&s.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded-full ${u===$?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark-tertiary"}`,children:F[$]})]},$))}),x?s.jsx("div",{className:"flex items-center justify-center py-20",children:s.jsxs("div",{className:"flex flex-col items-center gap-3",children:[s.jsx(ht,{className:"w-8 h-8 animate-spin text-bambu-green"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:t("projects.loading")})]})}):m?.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center py-20 px-4",children:[s.jsx("div",{className:"p-4 bg-bambu-dark rounded-2xl mb-4",children:s.jsx(Ja,{className:"w-12 h-12 text-bambu-gray/50"})}),s.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:u==="all"?t("projects.noProjects"):t("projects.noProjectsFiltered",{status:u})}),s.jsx("p",{className:"text-bambu-gray text-center max-w-md mb-6",children:u==="all"?t("projects.createFirst"):t("projects.noProjectsFilteredHelp",{status:u})}),u==="all"&&s.jsxs(Te,{onClick:()=>o(!0),disabled:!i("projects:create"),title:i("projects:create")?void 0:t("projects.noCreatePermission"),children:[s.jsx(dr,{className:"w-4 h-4 mr-2"}),t("projects.createFirstButton")]})]}):s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-8",children:m?.map($=>s.jsx($Ke,{project:$,onClick:()=>A($),onEdit:()=>D($),onDelete:()=>R($.id),hasPermission:i,t},$.id))}),f!==null&&s.jsx(Zn,{title:t("projects.deleteProject"),message:t("projects.deleteConfirm"),confirmText:t("projects.deleteProject"),variant:"danger",onConfirm:U,onCancel:()=>p(null)}),a&&s.jsx(Ure,{project:l,onClose:()=>{o(!1),c(void 0)},onSave:E,isLoading:b.isPending||y.isPending,t})]})}function GKe(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 qKe(t){return t>=1e3?`${(t/1e3).toFixed(2)}kg`:`${Math.round(t)}g`}function WKe({status:t,t:e}){const n={active:"bg-bambu-green/20 text-bambu-green",completed:"bg-blue-500/20 text-blue-400",archived:"bg-bambu-gray/20 text-bambu-gray"},r=n[t]||n.active,i={active:e("projectDetail.status.active"),completed:e("projectDetail.status.completed"),archived:e("projectDetail.status.archived")};return s.jsx("span",{className:`px-2 py-1 rounded text-sm font-medium ${r}`,children:i[t]||t.charAt(0).toUpperCase()+t.slice(1)})}function gq({icon:t,label:e,value:n,subValue:r,hint:i,color:a="text-bambu-gray"}){return s.jsx(_t,{children:s.jsx(Mt,{className:"p-4",children:s.jsxs("div",{className:"flex items-center gap-3",title:i,children:[s.jsx("div",{className:`p-2 rounded-lg bg-bambu-dark ${a}`,children:s.jsx(t,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:e}),s.jsx("p",{className:"text-xl font-semibold text-white",children:n}),r&&s.jsx("p",{className:"text-xs text-bambu-gray/70",children:r})]})]})})})}function KKe({archives:t,t:e}){return t.length===0?s.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[s.jsx(mc,{className:"w-12 h-12 mx-auto mb-2 opacity-50"}),s.jsx("p",{children:e("projectDetail.noPrints")})]}):s.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6 gap-3",children:t.map(n=>s.jsxs(Ds,{to:`/archives?search=${encodeURIComponent(n.print_name||"")}`,className:"group relative aspect-square rounded-lg bg-bambu-dark border border-bambu-dark-tertiary overflow-hidden hover:border-bambu-green transition-colors",children:[n.thumbnail_path?s.jsx("img",{src:ue.getArchiveThumbnail(n.id),alt:n.print_name||"Print",className:"w-full h-full object-cover"}):s.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:s.jsx(mc,{className:"w-8 h-8"})}),n.status==="failed"&&s.jsx("div",{className:"absolute inset-0 bg-red-500/30 flex items-center justify-center",children:s.jsx(Yi,{className:"w-8 h-8 text-white"})}),n.status==="completed"&&s.jsx("div",{className:"absolute top-1 right-1",children:s.jsx(Ar,{className:"w-4 h-4 text-bambu-green"})}),s.jsx("div",{className:"absolute inset-x-0 bottom-0 bg-gradient-to-t from-black/80 to-transparent p-2 opacity-0 group-hover:opacity-100 transition-opacity",children:s.jsx("p",{className:"text-xs text-white truncate",children:n.print_name||"Unknown"})})]},n.id))})}function XKe({priority:t,t:e}){const n={low:{color:"bg-gray-500/20 text-gray-400",label:e("projectDetail.priority.low")},normal:{color:"bg-blue-500/20 text-blue-400",label:e("projectDetail.priority.normal")},high:{color:"bg-orange-500/20 text-orange-400",label:e("projectDetail.priority.high")},urgent:{color:"bg-red-500/20 text-red-400",label:e("projectDetail.priority.urgent")}},{color:r,label:i}=n[t]||n.normal;return s.jsxs("span",{className:`px-2 py-1 rounded text-xs font-medium flex items-center gap-1 ${r}`,children:[t==="urgent"&&s.jsx(Cn,{className:"w-3 h-3"}),i]})}function YKe(t){return t?Bg(t,{year:"numeric",month:"short",day:"numeric"}):""}function Wj(t,e){if(!t)return null;const n=Ii(t);if(!n)return null;const r=new Date,i=Math.ceil((n.getTime()-r.getTime())/(1e3*60*60*24));return i<0?{color:"text-red-400",label:e("projectDetail.dueDate.overdue")}:i===0?{color:"text-orange-400",label:e("projectDetail.dueDate.today")}:i<=3?{color:"text-yellow-400",label:e("projectDetail.dueDate.daysLeft",{count:i})}:{color:"text-bambu-gray",label:e("projectDetail.dueDate.daysLeft",{count:i})}}function QKe(){const{id:t}=rN(),e=Nc(),{t:n}=Hn(),r=an(),{showToast:i}=$n(),{hasPermission:a}=Ai(),[o,l]=_.useState(!1),[c,u]=_.useState(!1),[d,f]=_.useState(""),p=parseInt(t||"0",10),{data:m,isLoading:x,error:b}=at({queryKey:["project",p],queryFn:()=>ue.getProject(p),enabled:p>0}),{data:y,isLoading:v}=at({queryKey:["project-archives",p],queryFn:()=>ue.getProjectArchives(p),enabled:p>0}),{data:S,isLoading:N}=at({queryKey:["project-bom",p],queryFn:()=>ue.getProjectBOM(p),enabled:p>0}),{data:T,isLoading:k}=at({queryKey:["project-timeline",p],queryFn:()=>ue.getProjectTimeline(p,20),enabled:p>0}),{data:C}=at({queryKey:["settings"],queryFn:ue.getSettings}),{data:E}=at({queryKey:["project-folders",p],queryFn:()=>ue.getLibraryFoldersByProject(p),enabled:p>0}),D=C?.currency||"$",A=C?.time_format||"system",R=mt({mutationFn:Se=>ue.updateProject(p,Se),onSuccess:()=>{r.invalidateQueries({queryKey:["project",p]}),r.invalidateQueries({queryKey:["projects"]}),l(!1),u(!1),i(n("projectDetail.toast.projectUpdated"),"success")},onError:Se=>{i(Se.message,"error")}}),U=()=>{f(m?.notes||""),u(!0)},F=()=>{R.mutate({notes:d})},$=()=>{u(!1),f("")},[j,H]=_.useState(""),[K,V]=_.useState(1),[Q,Z]=_.useState(""),[ae,B]=_.useState(""),[X,ne]=_.useState(""),[se,be]=_.useState(!1),[xe,de]=_.useState(!1),[Pe,ie]=_.useState(null),[Ne,Oe]=_.useState(""),[ge,Ke]=_.useState(1),[G,Y]=_.useState(""),[ce,q]=_.useState(""),[te,I]=_.useState(""),[fe,me]=_.useState({isOpen:!1,title:"",message:"",onConfirm:()=>{}}),Ee=mt({mutationFn:Se=>ue.createBOMItem(p,Se),onSuccess:()=>{r.invalidateQueries({queryKey:["project-bom",p]}),r.invalidateQueries({queryKey:["project",p]}),H(""),V(1),Z(""),B(""),ne(""),be(!1),i(n("projectDetail.toast.partAdded"),"success")},onError:Se=>i(Se.message,"error")}),z=mt({mutationFn:({itemId:Se,data:Xe})=>ue.updateBOMItem(p,Se,Xe),onSuccess:()=>{r.invalidateQueries({queryKey:["project-bom",p]}),r.invalidateQueries({queryKey:["project",p]}),ie(null)},onError:Se=>i(Se.message,"error")}),O=mt({mutationFn:Se=>ue.deleteBOMItem(p,Se),onSuccess:()=>{r.invalidateQueries({queryKey:["project-bom",p]}),r.invalidateQueries({queryKey:["project",p]}),i(n("projectDetail.toast.partRemoved"),"success")},onError:Se=>i(Se.message,"error")}),ee=Se=>{Se.preventDefault(),j.trim()&&Ee.mutate({name:j.trim(),quantity_needed:K,unit_price:Q?parseFloat(Q):void 0,sourcing_url:ae.trim()||void 0,remarks:X.trim()||void 0})},le=Se=>{const Xe=Se.is_complete?0:Se.quantity_needed;z.mutate({itemId:Se.id,data:{quantity_acquired:Xe}})},_e=(Se,Xe)=>{me({isOpen:!0,title:n("projectDetail.bom.deletePart"),message:n("projectDetail.bom.deleteConfirm",{name:Xe}),onConfirm:()=>{me(Me=>({...Me,isOpen:!1})),O.mutate(Se)}})},we=Se=>{ie(Se),Oe(Se.name),Ke(Se.quantity_needed),Y(Se.unit_price?.toString()||""),q(Se.sourcing_url||""),I(Se.remarks||"")},re=Se=>{Se.preventDefault(),!(!Pe||!Ne.trim())&&z.mutate({itemId:Pe.id,data:{name:Ne.trim(),quantity_needed:ge,unit_price:G?parseFloat(G):void 0,sourcing_url:ce.trim()||void 0,remarks:te.trim()||void 0}})},Fe=()=>{ie(null)},He=async()=>{try{const Se=await fetch(`/api/v1/projects/${p}/export`);if(!Se.ok)throw new Error(n("projectDetail.toast.exportFailed"));const Xe=await Se.blob(),Me=URL.createObjectURL(Xe),tt=document.createElement("a");tt.href=Me;const We=Se.headers.get("Content-Disposition")?.match(/filename="(.+)"/);tt.download=We?.[1]||`${m?.name||"project"}_${new Date().toISOString().split("T")[0]}.zip`,tt.click(),URL.revokeObjectURL(Me),i(n("projectDetail.toast.projectExported"),"success")}catch(Se){i(Se.message,"error")}},Ve=mt({mutationFn:()=>ue.createTemplateFromProject(p),onSuccess:()=>{r.invalidateQueries({queryKey:["projects"]}),i(n("projectDetail.toast.templateCreated"),"success")},onError:Se=>i(Se.message,"error")}),$e=Se=>Hg(Se,A,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});if(x)return s.jsx("div",{className:"flex items-center justify-center py-24",children:s.jsx(ht,{className:"w-8 h-8 animate-spin text-bambu-green"})});if(b||!m)return s.jsxs("div",{className:"text-center py-24",children:[s.jsx("p",{className:"text-bambu-gray",children:b?`${n("common.error")}: ${b.message}`:n("projectDetail.notFound")}),s.jsx(Te,{variant:"secondary",className:"mt-4",onClick:()=>e("/projects"),children:n("projectDetail.backToProjects")})]});const ye=m.stats,je=ye?.progress_percent??0,Be=ye?.parts_progress_percent??0;return s.jsxs("div",{className:"p-4 md:p-8 space-y-8",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[s.jsx(Ds,{to:"/projects",className:"hover:text-white transition-colors",children:n("navigation.projects")}),s.jsx(gs,{className:"w-4 h-4"}),s.jsx("span",{className:"text-white",children:m.name})]}),s.jsxs("div",{className:"flex items-start justify-between",children:[s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx("button",{onClick:()=>e("/projects"),className:"p-2 rounded-lg bg-bambu-card hover:bg-bambu-dark-tertiary transition-colors",children:s.jsx(cce,{className:"w-5 h-5 text-bambu-gray"})}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-4 h-4 rounded-full flex-shrink-0",style:{backgroundColor:m.color||"#6b7280"}}),s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold text-white",children:m.name}),m.description&&s.jsx("p",{className:"text-bambu-gray mt-1",children:m.description})]})]}),s.jsx(WKe,{status:m.status,t:n})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(Te,{variant:"secondary",onClick:He,disabled:!a("projects:read"),title:a("projects:read")?n("projectDetail.exportProject"):n("projectDetail.noExportPermission"),children:[s.jsx(yi,{className:"w-4 h-4 mr-2"}),n("projectDetail.export")]}),s.jsxs(Te,{onClick:()=>l(!0),disabled:!a("projects:update"),title:a("projects:update")?void 0:n("projectDetail.noEditPermission"),children:[s.jsx(rm,{className:"w-4 h-4 mr-2"}),n("common.edit")]})]})]}),(m.target_count||m.target_parts_count)&&s.jsx(_t,{children:s.jsxs(Mt,{className:"p-4 space-y-4",children:[m.target_count&&s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("span",{className:"text-sm text-bambu-gray",children:n("projectDetail.progress.platesProgress")}),s.jsxs("span",{className:"text-sm font-medium text-white",children:[ye?.total_archives||0," / ",m.target_count," ",n("projectDetail.progress.printJobs")]})]}),s.jsx("div",{className:"h-3 bg-bambu-dark rounded-full overflow-hidden",children:s.jsx("div",{className:"h-full transition-all duration-500",style:{width:`${Math.min(je,100)}%`,backgroundColor:je>=100?"#22c55e":m.color||"#6b7280"}})}),s.jsxs("div",{className:"flex justify-between mt-1",children:[s.jsx("span",{className:"text-xs text-bambu-gray/70",children:n("projectDetail.progress.percentComplete",{percent:je.toFixed(0)})}),ye?.remaining_prints!=null&&ye.remaining_prints>0&&s.jsx("span",{className:"text-xs text-bambu-gray/70",children:n("projectDetail.progress.remaining",{count:ye.remaining_prints})})]})]}),m.target_parts_count&&s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("span",{className:"text-sm text-bambu-gray",children:n("projectDetail.progress.partsProgress")}),s.jsxs("span",{className:"text-sm font-medium text-white",children:[ye?.completed_prints||0," / ",m.target_parts_count," ",n("projectDetail.progress.parts")]})]}),s.jsx("div",{className:"h-3 bg-bambu-dark rounded-full overflow-hidden",children:s.jsx("div",{className:"h-full transition-all duration-500",style:{width:`${Math.min(Be,100)}%`,backgroundColor:Be>=100?"#22c55e":m.color||"#6b7280"}})}),s.jsxs("div",{className:"flex justify-between mt-1",children:[s.jsx("span",{className:"text-xs text-bambu-gray/70",children:n("projectDetail.progress.percentComplete",{percent:Be.toFixed(0)})}),ye?.remaining_parts!=null&&ye.remaining_parts>0&&s.jsx("span",{className:"text-xs text-bambu-gray/70",children:n("projectDetail.progress.remaining",{count:ye.remaining_parts})})]})]})]})}),ye&&s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[s.jsx(_t,{children:s.jsx(Mt,{className:"p-4",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-bambu-green",children:s.jsx(mc,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:n("projectDetail.stats.printJobs")}),s.jsxs("p",{className:"text-xl font-semibold text-white",children:[ye.total_archives," ",s.jsx("span",{className:"text-sm font-normal text-bambu-gray",children:n("projectDetail.stats.total")})]}),ye.failed_prints>0&&s.jsx("p",{className:"text-sm text-status-error",children:n("projectDetail.stats.failed",{count:ye.failed_prints})}),s.jsx("p",{className:"text-sm text-bambu-gray",children:n("projectDetail.stats.partsPrinted",{count:ye.completed_prints})})]})]})})}),s.jsx(gq,{icon:er,label:n("projectDetail.stats.printTime"),value:GKe(ye.total_print_time_hours),color:"text-yellow-400"}),s.jsx(gq,{icon:Ur,label:n("projectDetail.stats.filamentUsed"),value:qKe(ye.total_filament_grams),color:"text-purple-400"})]}),ye&&(ye.estimated_cost>0||m.budget)&&s.jsx(_t,{children:s.jsxs(Mt,{className:"p-4",children:[s.jsx("h2",{className:"text-lg font-semibold text-white mb-3",children:n("projectDetail.cost.title")}),s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:n("projectDetail.cost.filamentCost")}),s.jsxs("p",{className:"text-lg font-semibold text-white",children:[D,ye.estimated_cost.toFixed(2)]})]}),ye.total_energy_kwh>0&&s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:n("projectDetail.cost.energy")}),s.jsxs("p",{className:"text-lg font-semibold text-white",children:[ye.total_energy_kwh.toFixed(2)," kWh",ye.total_energy_cost>0&&s.jsxs("span",{className:"text-sm text-bambu-gray ml-1",children:["(",D,ye.total_energy_cost.toFixed(2),")"]})]})]}),m.budget&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:n("projectDetail.cost.budget")}),s.jsxs("p",{className:"text-lg font-semibold text-white",children:[D,m.budget.toFixed(2)]})]}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:n("projectDetail.cost.remaining")}),s.jsxs("p",{className:`text-lg font-semibold ${m.budget-ye.estimated_cost>=0?"text-bambu-green":"text-red-400"}`,children:[D,(m.budget-ye.estimated_cost).toFixed(2)]})]})]})]})]})}),m.children&&m.children.length>0&&s.jsx(_t,{children:s.jsxs(Mt,{className:"p-4",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2 mb-3",children:[s.jsx(Uue,{className:"w-5 h-5"}),n("projectDetail.subProjects.title",{count:m.children.length})]}),s.jsx("div",{className:"space-y-2",children:m.children.map(Se=>s.jsxs(Ds,{to:`/projects/${Se.id}`,className:"flex items-center justify-between p-3 bg-bambu-dark rounded-lg hover:bg-bambu-dark-tertiary transition-colors",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:Se.color||"#6b7280"}}),s.jsx("span",{className:"text-white",children:Se.name}),s.jsx("span",{className:`text-xs px-2 py-0.5 rounded ${Se.status==="completed"?"bg-status-ok/20 text-status-ok":Se.status==="archived"?"bg-bambu-gray/20 text-bambu-gray":"bg-blue-500/20 text-blue-400"}`,children:Se.status})]}),Se.progress_percent!==null&&s.jsxs("span",{className:"text-sm text-bambu-gray",children:[Se.progress_percent.toFixed(0),"%"]})]},Se.id))})]})}),m.parent_id&&m.parent_name&&s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx(sl,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("span",{className:"text-bambu-gray",children:n("projectDetail.partOf")}),s.jsx(Ds,{to:`/projects/${m.parent_id}`,className:"text-bambu-green hover:underline",children:m.parent_name})]}),(m.tags||m.due_date||m.priority!=="normal")&&s.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[m.priority&&m.priority!=="normal"&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-xs text-bambu-gray uppercase",children:n("projectDetail.priorityLabel")}),s.jsx(XKe,{priority:m.priority,t:n})]}),m.due_date&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(si,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("span",{className:"text-sm text-white",children:YKe(m.due_date)}),Wj(m.due_date,n)&&s.jsxs("span",{className:`text-xs ${Wj(m.due_date,n).color}`,children:["(",Wj(m.due_date,n).label,")"]})]}),m.tags&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(yh,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("div",{className:"flex flex-wrap gap-1",children:m.tags.split(",").map((Se,Xe)=>s.jsx("span",{className:"px-2 py-0.5 bg-bambu-dark-tertiary text-bambu-gray text-xs rounded",children:Se.trim()},Xe))})]})]}),s.jsx(_t,{children:s.jsxs(Mt,{className:"p-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(Ls,{className:"w-5 h-5"}),n("projectDetail.notes.title")]}),c?s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(Te,{variant:"secondary",size:"sm",onClick:$,disabled:R.isPending,children:[s.jsx(Rt,{className:"w-4 h-4 mr-1"}),n("common.cancel")]}),s.jsxs(Te,{size:"sm",onClick:F,disabled:R.isPending,children:[R.isPending?s.jsx(ht,{className:"w-4 h-4 animate-spin mr-1"}):s.jsx(hs,{className:"w-4 h-4 mr-1"}),n("common.save")]})]}):s.jsxs(Te,{variant:"secondary",size:"sm",onClick:U,disabled:!a("projects:update"),title:a("projects:update")?void 0:n("projectDetail.notes.noEditPermission"),children:[s.jsx(rm,{className:"w-4 h-4 mr-1"}),n("common.edit")]})]}),c?s.jsx(iR,{content:d,onChange:f,placeholder:n("projectDetail.notes.placeholder")}):m.notes?s.jsx("div",{className:"prose prose-invert prose-sm max-w-none",dangerouslySetInnerHTML:{__html:m.notes}}):s.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:n("projectDetail.notes.empty")})]})}),s.jsx(_t,{children:s.jsxs(Mt,{className:"p-4",children:[s.jsx("div",{className:"flex items-center justify-between mb-3",children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(Il,{className:"w-5 h-5"}),n("projectDetail.files.title")]})}),s.jsxs("p",{className:"text-xs text-bambu-gray mb-3",children:[s.jsx(Ds,{to:"/files",className:"text-bambu-green hover:underline",children:n("projectDetail.files.linkFolders")})," ",n("projectDetail.files.forQuickAccess")]}),E&&E.length>0?s.jsx("div",{className:"space-y-2",children:E.map(Se=>s.jsxs(Ds,{to:`/files?folder=${Se.id}`,className:"flex items-center justify-between p-3 bg-bambu-dark rounded-lg hover:bg-bambu-dark-tertiary transition-colors",children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[s.jsx(Il,{className:"w-5 h-5 text-bambu-green flex-shrink-0"}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:"text-sm text-white truncate",children:Se.name}),s.jsx("p",{className:"text-xs text-bambu-gray",children:n("projectDetail.files.fileCount",{count:Se.file_count})})]})]}),s.jsx(gs,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"})]},Se.id))}):s.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:n("projectDetail.files.empty")})]})}),s.jsx(_t,{children:s.jsxs(Mt,{className:"p-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(NW,{className:"w-5 h-5"}),n("projectDetail.bom.title"),ye&&ye.bom_total_items>0&&s.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",n("projectDetail.bom.acquired",{completed:ye.bom_completed_items,total:ye.bom_total_items}),")"]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[S&&S.some(Se=>Se.is_complete)&&s.jsx("button",{onClick:()=>de(!xe),className:`text-xs px-2 py-1 rounded transition-colors ${xe?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:n(xe?"projectDetail.bom.showAll":"projectDetail.bom.hideDone")}),!se&&s.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>be(!0),disabled:!a("projects:update"),title:a("projects:update")?void 0:n("projectDetail.bom.noAddPermission"),children:[s.jsx(dr,{className:"w-4 h-4 mr-1"}),n("projectDetail.bom.addPart")]})]})]}),se&&s.jsxs("form",{onSubmit:ee,className:"bg-bambu-dark rounded-lg p-4 mb-4 space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[s.jsx("input",{type:"text",value:j,onChange:Se=>H(Se.target.value),className:"bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:n("projectDetail.bom.partNamePlaceholder"),autoFocus:!0}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{type:"number",value:K,onChange:Se=>V(parseInt(Se.target.value)||1),className:"w-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white focus:outline-none focus:border-bambu-green",min:"1",placeholder:n("projectDetail.bom.qty")}),s.jsx("input",{type:"number",step:"0.01",value:Q,onChange:Se=>Z(Se.target.value),className:"flex-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:n("projectDetail.bom.price",{currency:D})})]})]}),s.jsx("input",{type:"url",value:ae,onChange:Se=>B(Se.target.value),className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:n("projectDetail.bom.sourcingUrlPlaceholder")}),s.jsx("input",{type:"text",value:X,onChange:Se=>ne(Se.target.value),className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:n("projectDetail.bom.remarksPlaceholder")}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(Te,{type:"button",variant:"secondary",size:"sm",onClick:()=>be(!1),children:n("common.cancel")}),s.jsx(Te,{type:"submit",size:"sm",disabled:!j.trim()||Ee.isPending,children:Ee.isPending?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):n("projectDetail.bom.addPart")})]})]}),N?s.jsx("div",{className:"flex items-center justify-center py-4",children:s.jsx(ht,{className:"w-6 h-6 animate-spin text-bambu-green"})}):S&&S.length>0?s.jsxs("div",{className:"space-y-2",children:[S.filter(Se=>!xe||!Se.is_complete).map(Se=>s.jsx("div",{className:`p-3 rounded-lg transition-colors ${Se.is_complete?"bg-status-ok/10":"bg-bambu-dark"}`,children:Pe?.id===Se.id?s.jsxs("form",{onSubmit:re,className:"space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[s.jsx("input",{type:"text",value:Ne,onChange:Xe=>Oe(Xe.target.value),className:"bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:n("projectDetail.bom.partName"),autoFocus:!0}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{type:"number",value:ge,onChange:Xe=>Ke(parseInt(Xe.target.value)||1),className:"w-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white focus:outline-none focus:border-bambu-green",min:"1",placeholder:n("projectDetail.bom.qty")}),s.jsx("input",{type:"number",step:"0.01",value:G,onChange:Xe=>Y(Xe.target.value),className:"flex-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:n("projectDetail.bom.price",{currency:D})})]})]}),s.jsx("input",{type:"url",value:ce,onChange:Xe=>q(Xe.target.value),className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:n("projectDetail.bom.sourcingUrlPlaceholder")}),s.jsx("input",{type:"text",value:te,onChange:Xe=>I(Xe.target.value),className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:n("projectDetail.bom.remarksPlaceholder")}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(Te,{type:"button",variant:"secondary",size:"sm",onClick:Fe,children:n("common.cancel")}),s.jsx(Te,{type:"submit",size:"sm",disabled:!Ne.trim()||z.isPending,children:z.isPending?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):n("common.save")})]})]}):s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("button",{onClick:()=>a("projects:update")&&le(Se),disabled:z.isPending||!a("projects:update"),title:a("projects:update")?void 0:n("projectDetail.bom.noUpdatePermission"),className:`w-5 h-5 mt-0.5 rounded border-2 flex items-center justify-center transition-colors flex-shrink-0 ${Se.is_complete?"bg-status-ok border-status-ok text-white":a("projects:update")?"border-bambu-gray hover:border-bambu-green":"border-bambu-gray/50 cursor-not-allowed"}`,children:Se.is_complete&&s.jsx(Ar,{className:"w-3 h-3"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsxs("p",{className:`text-sm font-medium ${Se.is_complete?"text-bambu-gray line-through":"text-white"}`,children:[Se.name,s.jsxs("span",{className:"text-bambu-gray font-normal ml-2",children:["x",Se.quantity_needed]})]}),Se.unit_price!==null&&s.jsxs("span",{className:"text-xs text-bambu-green whitespace-nowrap",children:[D,(Se.unit_price*Se.quantity_needed).toFixed(2)]})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("button",{onClick:()=>a("projects:update")&&we(Se),disabled:!a("projects:update"),className:`p-1 rounded transition-colors flex-shrink-0 ${a("projects:update")?"hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white":"text-bambu-gray/50 cursor-not-allowed"}`,title:a("projects:update")?n("common.edit"):n("projectDetail.bom.noEditPermission"),children:s.jsx(Qi,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>a("projects:update")&&_e(Se.id,Se.name),disabled:!a("projects:update"),className:`p-1 rounded transition-colors flex-shrink-0 ${a("projects:update")?"hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-red-400":"text-bambu-gray/50 cursor-not-allowed"}`,title:a("projects:update")?n("common.delete"):n("projectDetail.bom.noDeletePermission"),children:s.jsx(rn,{className:"w-4 h-4"})})]})]}),Se.sourcing_url&&s.jsxs("a",{href:Se.sourcing_url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 mt-1 text-xs text-blue-400 hover:text-blue-300 transition-colors",onClick:Xe=>Xe.stopPropagation(),children:[s.jsx(Kr,{className:"w-3 h-3 flex-shrink-0"}),s.jsx("span",{className:"truncate",children:(()=>{try{return new URL(Se.sourcing_url).hostname.replace("www.","")}catch{return Se.sourcing_url}})()})]}),Se.remarks&&s.jsx("p",{className:"mt-1 text-xs text-bambu-gray/80 italic",children:Se.remarks})]})]})},Se.id)),S.some(Se=>Se.unit_price!==null)&&s.jsxs("div",{className:"pt-2 mt-2 border-t border-bambu-dark-tertiary flex justify-between text-sm",children:[s.jsx("span",{className:"text-bambu-gray",children:n("projectDetail.bom.totalCost")}),s.jsxs("span",{className:"text-white font-medium",children:[D,S.reduce((Se,Xe)=>Se+(Xe.unit_price||0)*Xe.quantity_needed,0).toFixed(2)]})]})]}):s.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:n("projectDetail.bom.empty")})]})}),s.jsx(_t,{children:s.jsxs(Mt,{className:"p-4",children:[s.jsx("div",{className:"flex items-center justify-between mb-3",children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(q0,{className:"w-5 h-5"}),n("projectDetail.timeline.title")]})}),k?s.jsx("div",{className:"flex items-center justify-center py-4",children:s.jsx(ht,{className:"w-6 h-6 animate-spin text-bambu-green"})}):T&&T.length>0?s.jsx("div",{className:"space-y-3",children:T.slice(0,10).map((Se,Xe)=>s.jsxs("div",{className:"flex gap-3",children:[s.jsxs("div",{className:`w-8 h-8 rounded-full flex items-center justify-center flex-shrink-0 ${Se.event_type==="print_completed"?"bg-status-ok/20 text-status-ok":Se.event_type==="print_failed"?"bg-status-error/20 text-status-error":Se.event_type==="print_started"?"bg-yellow-500/20 text-yellow-400":"bg-bambu-dark-tertiary text-bambu-gray"}`,children:[Se.event_type==="print_completed"&&s.jsx(Ar,{className:"w-4 h-4"}),Se.event_type==="print_failed"&&s.jsx(Yi,{className:"w-4 h-4"}),Se.event_type==="print_started"&&s.jsx(Ur,{className:"w-4 h-4"}),Se.event_type==="queued"&&s.jsx(pP,{className:"w-4 h-4"}),Se.event_type==="project_created"&&s.jsx(dr,{className:"w-4 h-4"})]}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-sm text-white",children:Se.title}),Se.description&&s.jsx("p",{className:"text-xs text-bambu-gray truncate",children:Se.description}),s.jsx("p",{className:"text-xs text-bambu-gray/70",children:$e(Se.timestamp)})]})]},Xe))}):s.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:n("projectDetail.timeline.empty")})]})}),!m.is_template&&s.jsx("div",{className:"flex justify-end",children:s.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>Ve.mutate(),disabled:Ve.isPending||!a("projects:create"),title:a("projects:create")?void 0:n("projectDetail.template.noCreatePermission"),children:[Ve.isPending?s.jsx(ht,{className:"w-4 h-4 animate-spin mr-2"}):s.jsx(Fl,{className:"w-4 h-4 mr-2"}),n("projectDetail.template.saveAsTemplate")]})}),ye&&(ye.queued_prints>0||ye.in_progress_prints>0)&&s.jsx(_t,{children:s.jsxs(Mt,{className:"p-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(pP,{className:"w-5 h-5"}),n("projectDetail.queue.title")]}),s.jsx(Ds,{to:`/queue?project=${p}`,className:"text-sm text-bambu-green hover:underline",children:n("projectDetail.queue.viewAll")})]}),s.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[ye.in_progress_prints>0&&s.jsx("span",{className:"text-yellow-400",children:n("projectDetail.queue.printing",{count:ye.in_progress_prints})}),ye.queued_prints>0&&s.jsx("span",{className:"text-bambu-gray",children:n("projectDetail.queue.queued",{count:ye.queued_prints})})]})]})}),s.jsxs("div",{children:[s.jsx("div",{className:"flex items-center justify-between mb-4",children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(mc,{className:"w-5 h-5"}),n("projectDetail.prints.title",{count:y?.length||0})]})}),v?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx(ht,{className:"w-6 h-6 animate-spin text-bambu-green"})}):s.jsx(KKe,{archives:y||[],t:n})]}),o&&s.jsx(Ure,{t:n,project:{...m,archive_count:ye?.total_archives||0,total_items:ye?.total_items||0,completed_count:ye?.completed_prints||0,failed_count:ye?.failed_prints||0,queue_count:ye?.queued_prints||0,progress_percent:ye?.progress_percent||null,archives:[]},onClose:()=>l(!1),onSave:Se=>R.mutate(Se),isLoading:R.isPending}),fe.isOpen&&s.jsx(Zn,{title:fe.title,message:fe.message,confirmText:n("common.delete"),variant:"danger",onConfirm:fe.onConfirm,onCancel:()=>me(Se=>({...Se,isOpen:!1}))})]})}function hg(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:t<1024*1024*1024?`${(t/(1024*1024)).toFixed(1)} MB`:`${(t/(1024*1024*1024)).toFixed(2)} GB`}function ZKe(t){if(!t)return"-";const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function JKe({parentId:t,onClose:e,onSave:n,isLoading:r,t:i}){const[a,o]=_.useState(""),l=c=>{c.preventDefault(),n({name:a.trim(),parent_id:t})};return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-sm border border-bambu-dark-tertiary",children:[s.jsx("div",{className:"p-4 border-b border-bambu-dark-tertiary",children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:i("fileManager.newFolder")})}),s.jsxs("form",{onSubmit:l,className:"p-4 space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("fileManager.folderName")}),s.jsx("input",{type:"text",value:a,onChange:c=>o(c.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:i("fileManager.folderNamePlaceholder"),autoFocus:!0,required:!0})]}),s.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[s.jsx(Te,{type:"button",variant:"secondary",onClick:e,children:i("common.cancel")}),s.jsx(Te,{type:"submit",disabled:!a.trim()||r,children:r?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):i("common.create")})]})]})]})})}function eXe({type:t,currentName:e,onClose:n,onSave:r,isLoading:i,t:a}){const[o,l]=_.useState(e),c=u=>{u.preventDefault(),o.trim()&&o.trim()!==e&&r(o.trim())};return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-sm border border-bambu-dark-tertiary",children:[s.jsx("div",{className:"p-4 border-b border-bambu-dark-tertiary",children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:a(t==="file"?"fileManager.renameFile":"fileManager.renameFolder")})}),s.jsxs("form",{onSubmit:c,className:"p-4 space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:a("common.name")}),s.jsx("input",{type:"text",value:o,onChange:u=>l(u.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",autoFocus:!0,required:!0})]}),s.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[s.jsx(Te,{type:"button",variant:"secondary",onClick:n,children:a("common.cancel")}),s.jsx(Te,{type:"submit",disabled:!o.trim()||o.trim()===e||i,children:i?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):a("common.rename")})]})]})]})})}function tXe({folders:t,selectedFiles:e,currentFolderId:n,onClose:r,onMove:i,isLoading:a,t:o}){const[l,c]=_.useState(null),u=(f,p=0)=>{const m=[];for(const x of f)m.push({id:x.id,name:x.name,depth:p}),x.children.length>0&&m.push(...u(x.children,p+1));return m},d=[{id:null,name:o("fileManager.rootNoFolder"),depth:0},...u(t)];return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-sm border border-bambu-dark-tertiary",children:[s.jsx("div",{className:"p-4 border-b border-bambu-dark-tertiary",children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:o("fileManager.moveFiles",{count:e.length})})}),s.jsxs("div",{className:"p-4 space-y-4",children:[s.jsx("div",{className:"max-h-64 overflow-y-auto space-y-1",children:d.map(f=>s.jsxs("button",{onClick:()=>c(f.id),disabled:f.id===n,className:`w-full text-left px-3 py-2 rounded transition-colors flex items-center gap-2 ${l===f.id?"bg-bambu-green/20 text-bambu-green":f.id===n?"opacity-50 cursor-not-allowed text-bambu-gray":"hover:bg-bambu-dark text-white"}`,style:{paddingLeft:`${12+f.depth*16}px`},children:[s.jsx(Il,{className:"w-4 h-4"}),f.name,f.id===n&&s.jsxs("span",{className:"text-xs text-bambu-gray ml-auto",children:["(",o("fileManager.current"),")"]})]},f.id??"root"))}),s.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[s.jsx(Te,{type:"button",variant:"secondary",onClick:r,children:o("common.cancel")}),s.jsx(Te,{onClick:()=>i(l),disabled:a,children:a?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):o("common.move")})]})]})]})})}function nXe({folder:t,onClose:e,onLink:n,isLoading:r,t:i}){const[a,o]=_.useState("project"),[l,c]=_.useState(t.project_id||t.archive_id||null);_.useState(()=>{t.archive_id&&o("archive")});const{data:u}=at({queryKey:["projects"],queryFn:()=>ue.getProjects()}),{data:d}=at({queryKey:["archives-for-link"],queryFn:()=>ue.getArchives(void 0,void 0,100)}),f=()=>{n(a==="project"?{project_id:l,archive_id:0}:{project_id:0,archive_id:l})},p=()=>{n({project_id:0,archive_id:0})},m=t.project_id||t.archive_id;return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-md border border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary flex items-center justify-between",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(uc,{className:"w-5 h-5 text-bambu-green"}),i("fileManager.linkFolder")]}),s.jsx("button",{onClick:e,className:"p-1 hover:bg-bambu-dark rounded",children:s.jsx(Rt,{className:"w-5 h-5 text-bambu-gray"})})]}),s.jsxs("div",{className:"p-4 space-y-4",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:i("fileManager.linkFolderDescription",{name:t.name})}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("button",{onClick:()=>{o("project"),c(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg border transition-colors ${a==="project"?"border-bambu-green bg-bambu-green/10 text-bambu-green":"border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,children:[s.jsx(mW,{className:"w-4 h-4"}),i("fileManager.project")]}),s.jsxs("button",{onClick:()=>{o("archive"),c(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg border transition-colors ${a==="archive"?"border-bambu-green bg-bambu-green/10 text-bambu-green":"border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,children:[s.jsx(fo,{className:"w-4 h-4"}),i("fileManager.archive")]})]}),s.jsx("div",{className:"max-h-64 overflow-y-auto space-y-1 bg-bambu-dark rounded-lg p-2",children:a==="project"?u&&u.length>0?u.map(x=>s.jsxs("button",{onClick:()=>c(x.id),className:`w-full text-left px-3 py-2 rounded transition-colors flex items-center gap-2 ${l===x.id?"bg-bambu-green/20 text-bambu-green":"hover:bg-bambu-dark-tertiary text-white"}`,children:[s.jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:x.color||"#00ae42"}}),s.jsx("span",{className:"truncate",children:x.name})]},x.id)):s.jsx("p",{className:"text-sm text-bambu-gray text-center py-4",children:i("fileManager.noProjectsFound")}):d&&d.length>0?d.map(x=>s.jsxs("button",{onClick:()=>c(x.id),className:`w-full text-left px-3 py-2 rounded transition-colors flex items-center gap-2 ${l===x.id?"bg-bambu-green/20 text-bambu-green":"hover:bg-bambu-dark-tertiary text-white"}`,children:[s.jsx(zf,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),s.jsx("span",{className:"truncate",children:x.print_name||x.filename})]},x.id)):s.jsx("p",{className:"text-sm text-bambu-gray text-center py-4",children:i("fileManager.noArchivesFound")})})]}),s.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary flex justify-between",children:[m&&s.jsxs(Te,{variant:"danger",onClick:p,disabled:r,children:[s.jsx(RR,{className:"w-4 h-4 mr-2"}),i("fileManager.unlink")]}),s.jsxs("div",{className:`flex gap-2 ${m?"":"ml-auto"}`,children:[s.jsx(Te,{variant:"secondary",onClick:e,children:i("common.cancel")}),s.jsx(Te,{onClick:f,disabled:!l||r,children:r?s.jsx(ht,{className:"w-4 h-4 animate-spin"}):i("fileManager.link")})]})]})]})})}function rXe({folderId:t,onClose:e,onUploadComplete:n,t:r}){const[i,a]=_.useState([]),[o,l]=_.useState(!1),[c,u]=_.useState(!1),[d,f]=_.useState(!0),[p,m]=_.useState(!1),[x,b]=_.useState(!0),y=_.useRef(null),v=j=>{j.preventDefault(),l(!0)},S=j=>{j.preventDefault(),l(!1)},N=j=>{j.preventDefault(),l(!1);const H=Array.from(j.dataTransfer.files);k(H)},T=j=>{j.target.files&&k(Array.from(j.target.files))},k=j=>{const H=j.map(K=>({file:K,status:"pending",isZip:K.name.toLowerCase().endsWith(".zip")}));a(K=>[...K,...H])},C=j=>{a(H=>H.filter((K,V)=>V!==j))},E=i.some(j=>j.isZip&&j.status==="pending"),D=i.some(j=>j.file.name.toLowerCase().endsWith(".stl")&&j.status==="pending"),A=async()=>{if(i.length!==0){u(!0);for(let j=0;j<i.length;j++)if(i[j].status==="pending"){a(H=>H.map((K,V)=>V===j?{...K,status:"uploading"}:K));try{if(i[j].isZip){const H=await ue.extractZipFile(i[j].file,t,d,p,x);a(K=>K.map((V,Q)=>Q===j?{...V,status:H.errors.length>0&&H.extracted===0?"error":"success",extractedCount:H.extracted,error:H.errors.length>0?`${H.errors.length} files failed`:void 0}:V))}else await ue.uploadLibraryFile(i[j].file,t,x),a(H=>H.map((K,V)=>V===j?{...K,status:"success"}:K))}catch(H){a(K=>K.map((V,Q)=>Q===j?{...V,status:"error",error:H instanceof Error?H.message:"Upload failed"}:V))}}u(!1),n(),e()}},R=i.filter(j=>j.status==="pending").length,U=i.filter(j=>j.status==="success").length,F=i.filter(j=>j.status==="error").length,$=i.length>0&&R===0&&!c;return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-lg border border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary flex items-center justify-between",children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:r("fileManager.uploadFiles")}),s.jsx("button",{onClick:e,className:"p-1 hover:bg-bambu-dark rounded",children:s.jsx(Rt,{className:"w-5 h-5 text-bambu-gray"})})]}),s.jsxs("div",{className:"p-4 space-y-4",children:[s.jsxs("div",{onDragOver:v,onDragLeave:S,onDrop:N,onClick:()=>y.current?.click(),className:`border-2 border-dashed rounded-lg p-8 text-center cursor-pointer transition-colors ${o?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-green/50"}`,children:[s.jsx(Ua,{className:`w-10 h-10 mx-auto mb-3 ${o?"text-bambu-green":"text-bambu-gray"}`}),s.jsx("p",{className:"text-white font-medium",children:r(o?"fileManager.dropFilesHere":"fileManager.dragDropFiles")}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:r("fileManager.orClickToBrowse")}),s.jsx("p",{className:"text-xs text-bambu-gray/70 mt-2",children:r("fileManager.allFileTypesSupported")})]}),s.jsx("input",{ref:y,type:"file",multiple:!0,className:"hidden",onChange:T}),E&&s.jsx("div",{className:"p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(fo,{className:"w-5 h-5 text-blue-400 mt-0.5 flex-shrink-0"}),s.jsxs("div",{className:"flex-1",children:[s.jsx("p",{className:"text-sm text-blue-300 font-medium",children:r("fileManager.zipFilesDetected")}),s.jsx("p",{className:"text-xs text-blue-300/70 mt-1",children:r("fileManager.zipExtractOptions")}),s.jsxs("label",{className:"flex items-center gap-2 mt-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:d,onChange:j=>f(j.target.checked),className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),s.jsx("span",{className:"text-sm text-white",children:r("fileManager.preserveZipStructure")})]}),s.jsxs("label",{className:"flex items-center gap-2 mt-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:p,onChange:j=>m(j.target.checked),className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),s.jsx("span",{className:"text-sm text-white",children:r("fileManager.createFolderFromZip")})]})]})]})}),(D||E)&&s.jsx("div",{className:"p-3 bg-bambu-green/10 border border-bambu-green/30 rounded-lg",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(Ou,{className:"w-5 h-5 text-bambu-green mt-0.5 flex-shrink-0"}),s.jsxs("div",{className:"flex-1",children:[s.jsx("p",{className:"text-sm text-bambu-green font-medium",children:r("fileManager.stlThumbnailGeneration")}),s.jsx("p",{className:"text-xs text-bambu-green/70 mt-1",children:r(E&&!D?"fileManager.zipMayContainStl":"fileManager.thumbnailsCanBeGenerated")}),s.jsxs("label",{className:"flex items-center gap-2 mt-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:x,onChange:j=>b(j.target.checked),className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),s.jsx("span",{className:"text-sm text-white",children:r("fileManager.generateThumbnailsForStl")})]})]})]})}),i.length>0&&s.jsx("div",{className:"max-h-48 overflow-y-auto space-y-2",children:i.map((j,H)=>s.jsxs("div",{className:"flex items-center gap-3 p-2 bg-bambu-dark rounded-lg",children:[j.isZip?s.jsx(fo,{className:"w-4 h-4 text-blue-400 flex-shrink-0"}):s.jsx(cN,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-sm text-white truncate",children:j.file.name}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[(j.file.size/1024/1024).toFixed(2)," MB",j.isZip&&j.status==="pending"&&s.jsxs("span",{className:"text-blue-400 ml-2",children:["• ",r("fileManager.willBeExtracted")]}),j.extractedCount!==void 0&&s.jsxs("span",{className:"text-green-400 ml-2",children:["• ",r("fileManager.filesExtracted",{count:j.extractedCount})]})]})]}),j.status==="pending"&&s.jsx("button",{onClick:()=>C(H),className:"p-1 hover:bg-bambu-dark-tertiary rounded",children:s.jsx(Rt,{className:"w-4 h-4 text-bambu-gray"})}),j.status==="uploading"&&s.jsx(ht,{className:"w-4 h-4 text-bambu-green animate-spin"}),j.status==="success"&&s.jsx(Ar,{className:"w-4 h-4 text-green-500"}),j.status==="error"&&s.jsx("span",{title:j.error,children:s.jsx(Yi,{className:"w-4 h-4 text-red-500"})})]},H))}),$&&s.jsx("div",{className:"p-3 bg-bambu-dark rounded-lg",children:s.jsxs("p",{className:"text-sm text-white",children:[r("fileManager.uploadComplete",{succeeded:U}),F>0&&s.jsxs("span",{className:"text-red-400",children:[", ",r("fileManager.uploadFailed",{count:F})]})]})})]}),s.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary flex justify-end gap-2",children:[s.jsx(Te,{variant:"secondary",onClick:e,children:r($?"common.close":"common.cancel")}),!$&&s.jsx(Te,{onClick:A,disabled:R===0||c,children:c?s.jsxs(s.Fragment,{children:[s.jsx(ht,{className:"w-4 h-4 mr-2 animate-spin"}),r("fileManager.uploading")]}):s.jsxs(s.Fragment,{children:[s.jsx(Ua,{className:"w-4 h-4 mr-2"}),r("common.upload")," ",R>0?`(${R})`:""]})})]})]})})}function zre({folder:t,selectedFolderId:e,onSelect:n,onDelete:r,onLink:i,onRename:a,depth:o=0,wrapNames:l=!1,hasPermission:c,t:u}){const[d,f]=_.useState(!0),[p,m]=_.useState(!1),x=t.children.length>0,b=t.project_id||t.archive_id;return s.jsxs("div",{children:[s.jsxs("div",{className:`group flex items-center gap-1 px-2 py-1.5 rounded cursor-pointer transition-colors ${e===t.id?"bg-bambu-green/20 text-bambu-green":"hover:bg-bambu-dark text-white"}`,style:{paddingLeft:`${8+o*12}px`},onClick:()=>n(t.id),children:[x?s.jsx("button",{onClick:y=>{y.stopPropagation(),f(!d)},className:"p-0.5 hover:bg-bambu-dark-tertiary rounded",children:s.jsx(gs,{className:`w-3.5 h-3.5 transition-transform ${d?"rotate-90":""}`})}):s.jsx("div",{className:"w-4.5"}),s.jsx(Il,{className:"w-4 h-4 text-bambu-green flex-shrink-0"}),s.jsx("span",{className:`text-sm flex-1 min-w-0 ${l?"break-all":"truncate"}`,title:t.name,children:t.name}),b&&s.jsxs("button",{onClick:y=>{y.stopPropagation(),i(t)},className:"flex-shrink-0 flex items-center gap-1 text-xs px-1.5 py-0.5 rounded bg-blue-500/20 text-blue-400 hover:bg-blue-500/30 transition-colors",title:`${t.project_name?`Project: ${t.project_name}`:`Archive: ${t.archive_name}`} (click to change)`,children:[s.jsx(uc,{className:"w-3 h-3"}),t.project_name?s.jsx(mW,{className:"w-3 h-3"}):s.jsx(fo,{className:"w-3 h-3"})]}),t.file_count>0&&s.jsx("span",{className:"flex-shrink-0 text-xs text-bambu-gray",children:t.file_count}),!b&&s.jsx("button",{onClick:y=>{y.stopPropagation(),i(t)},className:"flex-shrink-0 p-1 rounded hover:bg-bambu-dark-tertiary",title:u("fileManager.linkToProjectOrArchive"),children:s.jsx(uc,{className:"w-3.5 h-3.5 text-bambu-gray hover:text-bambu-green"})}),s.jsx("div",{className:`flex-shrink-0 flex items-center gap-0.5 transition-opacity ${l?"":"opacity-0 group-hover:opacity-100"}`,onClick:y=>y.stopPropagation(),children:s.jsxs("div",{className:"relative",children:[s.jsx("button",{onClick:()=>m(!p),className:"p-1 rounded hover:bg-bambu-dark-tertiary",children:s.jsx(ih,{className:"w-3.5 h-3.5 text-bambu-gray"})}),p&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>m(!1)}),s.jsxs("div",{className:"absolute right-0 top-full mt-1 z-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 min-w-[120px]",children:[s.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${c("library:update_all")?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{c("library:update_all")&&(a(t),m(!1))},disabled:!c("library:update_all"),title:c("library:update_all")?void 0:u("fileManager.noPermissionRenameFolder"),children:[s.jsx(Qi,{className:"w-3.5 h-3.5"}),u("common.rename")]}),s.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${c("library:update_all")?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{c("library:update_all")&&(i(t),m(!1))},disabled:!c("library:update_all"),title:c("library:update_all")?void 0:u("fileManager.noPermissionLinkFolder"),children:[s.jsx(uc,{className:"w-3.5 h-3.5"}),u(b?"fileManager.changeLink":"fileManager.linkTo")]}),s.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${c("library:delete_all")?"text-red-400 hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{c("library:delete_all")&&(r(t.id),m(!1))},disabled:!c("library:delete_all"),title:c("library:delete_all")?void 0:u("fileManager.noPermissionDeleteFolder"),children:[s.jsx(rn,{className:"w-3.5 h-3.5"}),u("common.delete")]})]})]})]})})]}),x&&d&&s.jsx("div",{children:t.children.map(y=>s.jsx(zre,{folder:y,selectedFolderId:e,onSelect:n,onDelete:r,onLink:i,onRename:a,depth:o+1,wrapNames:l,hasPermission:c,t:u},y.id))})]})}function hR(t){const e=t.toLowerCase();return e.endsWith(".gcode")||e.includes(".gcode.")}function iXe({file:t,isSelected:e,isMobile:n,onSelect:r,onDelete:i,onDownload:a,onAddToQueue:o,onPrint:l,onRename:c,onGenerateThumbnail:u,thumbnailVersion:d,hasPermission:f,canModify:p,t:m}){const[x,b]=_.useState(!1);return s.jsxs("div",{className:`group relative bg-bambu-card rounded-lg border transition-all cursor-pointer overflow-hidden ${e?"border-bambu-green ring-1 ring-bambu-green":"border-bambu-dark-tertiary hover:border-bambu-green/50"}`,onClick:()=>r(t.id),children:[s.jsxs("div",{className:"aspect-square bg-bambu-dark flex items-center justify-center overflow-hidden",children:[t.thumbnail_path?s.jsx("img",{src:`${ue.getLibraryFileThumbnailUrl(t.id)}${d?`?v=${d}`:""}`,alt:t.filename,className:"w-full h-full object-cover"}):s.jsx(zf,{className:"w-12 h-12 text-bambu-gray/30"}),s.jsx("div",{className:`absolute top-2 right-2 text-xs px-1.5 py-0.5 rounded font-medium ${t.file_type==="3mf"?"bg-bambu-green/90 text-white":t.file_type==="gcode"?"bg-blue-500/90 text-white":t.file_type==="stl"?"bg-purple-500/90 text-white":"bg-bambu-gray/90 text-white"}`,children:t.file_type.toUpperCase()})]}),s.jsxs("div",{className:"p-3",children:[s.jsx("h3",{className:"text-sm font-medium text-white truncate",title:t.print_name||t.filename,children:t.print_name||t.filename}),s.jsxs("div",{className:"flex items-center gap-3 mt-1 text-xs text-bambu-gray",children:[s.jsx("span",{children:hg(t.file_size)}),t.print_time_seconds&&s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(er,{className:"w-3 h-3"}),ZKe(t.print_time_seconds)]})]}),t.print_count>0&&s.jsx("div",{className:"mt-1 text-xs text-bambu-green",children:m("fileManager.printedCount",{count:t.print_count})}),t.created_by_username&&s.jsx("div",{className:"mt-1 text-xs text-bambu-gray",children:m("fileManager.uploadedBy",{name:t.created_by_username})})]}),s.jsxs("div",{className:`absolute bottom-2 right-2 transition-opacity ${n?"opacity-100":"opacity-0 group-hover:opacity-100"}`,onClick:y=>y.stopPropagation(),children:[s.jsx("button",{onClick:()=>b(!x),className:"p-1.5 rounded bg-bambu-dark-secondary/90 hover:bg-bambu-dark-tertiary",children:s.jsx(ih,{className:"w-4 h-4 text-bambu-gray"})}),x&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>b(!1)}),s.jsxs("div",{className:"absolute right-0 bottom-8 z-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 min-w-[140px]",children:[l&&hR(t.filename)&&s.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${f("printers:control")?"text-bambu-green hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{f("printers:control")&&(l(t),b(!1))},disabled:!f("printers:control"),title:f("printers:control")?void 0:m("fileManager.noPermissionPrint"),children:[s.jsx(Ur,{className:"w-3.5 h-3.5"}),m("common.print")]}),o&&hR(t.filename)&&s.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${f("queue:create")?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{f("queue:create")&&(o(t.id),b(!1))},disabled:!f("queue:create"),title:f("queue:create")?void 0:m("fileManager.noPermissionAddToQueue"),children:[s.jsx(er,{className:"w-3.5 h-3.5"}),m("fileManager.addToQueue")]}),s.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${f("library:read")?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{f("library:read")&&(a(t.id),b(!1))},disabled:!f("library:read"),title:f("library:read")?void 0:m("fileManager.noPermissionDownload"),children:[s.jsx(yi,{className:"w-3.5 h-3.5"}),m("common.download")]}),c&&s.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${p("library","update",t.created_by_id)?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{p("library","update",t.created_by_id)&&(c(t),b(!1))},disabled:!p("library","update",t.created_by_id),title:p("library","update",t.created_by_id)?void 0:m("fileManager.noPermissionRenameFile"),children:[s.jsx(Qi,{className:"w-3.5 h-3.5"}),m("common.rename")]}),u&&t.file_type==="stl"&&s.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${p("library","update",t.created_by_id)?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{p("library","update",t.created_by_id)&&(u(t),b(!1))},disabled:!p("library","update",t.created_by_id),title:p("library","update",t.created_by_id)?void 0:m("fileManager.noPermissionGenerateThumbnail"),children:[s.jsx(Ou,{className:"w-3.5 h-3.5"}),m("fileManager.generateThumbnail")]}),s.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${p("library","delete",t.created_by_id)?"text-red-400 hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{p("library","delete",t.created_by_id)&&(i(t.id),b(!1))},disabled:!p("library","delete",t.created_by_id),title:p("library","delete",t.created_by_id)?void 0:m("fileManager.noPermissionDeleteFile"),children:[s.jsx(rn,{className:"w-3.5 h-3.5"}),m("common.delete")]})]})]})]}),s.jsx("div",{className:`absolute top-2 left-2 w-5 h-5 rounded border-2 flex items-center justify-center transition-all ${e?"bg-bambu-green border-bambu-green":`border-white/30 bg-black/30 ${n?"opacity-100":"opacity-0 group-hover:opacity-100"}`}`,children:e&&s.jsx("div",{className:"w-2 h-2 bg-white rounded-sm"})})]})}function aXe(){const{t}=Hn(),e=an(),{showToast:n}=$n(),{hasPermission:r,hasAnyPermission:i,canModify:a}=Ai(),[o]=wR(),l=o.get("folder"),c=l?parseInt(l,10):null,[u,d]=_.useState(c),[f,p]=_.useState([]),[m,x]=_.useState(!1),[b,y]=_.useState(!1),[v,S]=_.useState(!1),[N,T]=_.useState(null),[k,C]=_.useState(null),[E,D]=_.useState(null),[A,R]=_.useState(null),[U,F]=_.useState(null),[$,j]=_.useState({}),[H,K]=_.useState(()=>localStorage.getItem("library-view-mode")||"grid"),[V,Q]=_.useState(()=>localStorage.getItem("library-wrap-folders")==="true"),[Z,ae]=_.useState(()=>{const W=localStorage.getItem("library-sidebar-width");return W?parseInt(W,10):256}),[B,X]=_.useState(!1),ne=_.useRef(null);_.useEffect(()=>{if(!B)return;document.body.style.userSelect="none",document.body.style.cursor="col-resize";const W=Ye=>{if(!ne.current)return;const xt=ne.current.parentElement?.getBoundingClientRect();if(!xt)return;const ft=Ye.clientX-xt.left,Bt=Math.min(500,Math.max(200,ft));ae(Bt)},De=()=>{X(!1),document.body.style.userSelect="",document.body.style.cursor="",localStorage.setItem("library-sidebar-width",String(Z))};return document.addEventListener("mousemove",W),document.addEventListener("mouseup",De),()=>{document.removeEventListener("mousemove",W),document.removeEventListener("mouseup",De),document.body.style.userSelect="",document.body.style.cursor=""}},[B,Z]);const[se,be]=_.useState(""),[xe,de]=_.useState("all"),[Pe,ie]=_.useState(()=>localStorage.getItem("library-sort-field")||"name"),[Ne,Oe]=_.useState(()=>localStorage.getItem("library-sort-direction")||"asc"),ge=IR();_.useEffect(()=>{const W=o.get("folder");if(W){const De=parseInt(W,10);d(De)}},[o]);const{data:Ke}=at({queryKey:["settings"],queryFn:()=>ue.getSettings()}),{data:G,isLoading:Y}=at({queryKey:["library-folders"],queryFn:()=>ue.getLibraryFolders()}),{data:ce,isLoading:q}=at({queryKey:["library-files",u],queryFn:()=>ue.getLibraryFiles(u,u===null)}),{data:te}=at({queryKey:["library-stats"],queryFn:()=>ue.getLibraryStats()}),I=_.useMemo(()=>{if(!ce)return[];const W=new Set(ce.map(De=>De.file_type));return Array.from(W).sort()},[ce]),fe=_.useMemo(()=>{if(!ce)return[];let W=[...ce];if(se.trim()){const De=se.toLowerCase();W=W.filter(Ye=>Ye.filename.toLowerCase().includes(De)||Ye.print_name&&Ye.print_name.toLowerCase().includes(De))}return xe!=="all"&&(W=W.filter(De=>De.file_type===xe)),W.sort((De,Ye)=>{let xt=0;switch(Pe){case"name":xt=(De.print_name||De.filename).localeCompare(Ye.print_name||Ye.filename);break;case"date":xt=new Date(De.created_at).getTime()-new Date(Ye.created_at).getTime();break;case"size":xt=De.file_size-Ye.file_size;break;case"type":xt=De.file_type.localeCompare(Ye.file_type);break;case"prints":xt=De.print_count-Ye.print_count;break}return Ne==="asc"?xt:-xt}),W},[ce,se,xe,Pe,Ne]),me=_.useMemo(()=>{if(!te||!Ke)return!1;const W=(Ke.library_disk_warning_gb||5)*1024*1024*1024;return te.disk_free_bytes<W},[te,Ke]),Ee=mt({mutationFn:W=>ue.createLibraryFolder(W),onSuccess:()=>{e.invalidateQueries({queryKey:["library-folders"]}),x(!1),n(t("fileManager.toast.folderCreated"),"success")},onError:W=>n(W.message,"error")}),z=mt({mutationFn:W=>ue.deleteLibraryFolder(W),onSuccess:()=>{e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["library-stats"]}),u===k?.id&&d(null),C(null),n(t("fileManager.toast.folderDeleted"),"success")},onError:W=>{C(null),n(W.message,"error")}}),O=mt({mutationFn:W=>ue.deleteLibraryFile(W),onSuccess:()=>{e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["library-stats"]}),p(W=>W.filter(De=>De!==k?.id)),C(null),n(t("fileManager.toast.fileDeleted"),"success")},onError:W=>{C(null),n(W.message,"error")}}),ee=mt({mutationFn:W=>ue.bulkDeleteLibrary(W,[]),onSuccess:(W,De)=>{e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["library-stats"]}),n(t("fileManager.toast.filesDeleted",{count:De.length}),"success"),p([]),C(null)},onError:W=>{C(null),n(W.message,"error")}}),le=mt({mutationFn:({fileIds:W,folderId:De})=>ue.moveLibraryFiles(W,De),onSuccess:()=>{e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["library-folders"]}),p([]),y(!1),n(t("fileManager.toast.filesMoved"),"success")},onError:W=>n(W.message,"error")}),_e=mt({mutationFn:({id:W,data:De})=>ue.updateLibraryFolder(W,De),onSuccess:(W,De)=>{e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["project-folders"]}),e.invalidateQueries({queryKey:["archive-folders"]}),T(null);const Ye=De.data.project_id===0&&De.data.archive_id===0;n(t(Ye?"fileManager.toast.folderUnlinked":"fileManager.toast.folderLinked"),"success")},onError:W=>n(W.message,"error")}),we=mt({mutationFn:W=>ue.addLibraryFilesToQueue(W),onSuccess:W=>{e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["queue"]}),e.invalidateQueries({queryKey:["archives"]}),p([]),W.added.length>0&&W.errors.length===0?n(t("fileManager.toast.addedToQueue",{count:W.added.length}),"success"):W.added.length>0&&W.errors.length>0?n(t("fileManager.toast.addedToQueuePartial",{added:W.added.length,failed:W.errors.length}),"success"):n(t("fileManager.toast.failedToAddToQueue",{error:W.errors[0]?.error||"Unknown error"}),"error")},onError:W=>n(W.message,"error")}),re=mt({mutationFn:({id:W,filename:De})=>ue.updateLibraryFile(W,{filename:De}),onSuccess:()=>{e.invalidateQueries({queryKey:["library-files"]}),F(null),n(t("fileManager.toast.fileRenamed"),"success")},onError:W=>{F(null),n(W.message,"error")}}),Fe=mt({mutationFn:({id:W,name:De})=>ue.updateLibraryFolder(W,{name:De}),onSuccess:()=>{e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["library-files"]}),F(null),n(t("fileManager.toast.folderRenamed"),"success")},onError:W=>{F(null),n(W.message,"error")}}),He=mt({mutationFn:()=>ue.batchGenerateStlThumbnails({all_missing:!0}),onSuccess:W=>{if(e.invalidateQueries({queryKey:["library-files"]}),W.succeeded>0){const De=Date.now(),Ye={};W.results.forEach(xt=>{xt.success&&(Ye[xt.file_id]=De)}),j(xt=>({...xt,...Ye}))}W.succeeded>0&&W.failed===0?n(t("fileManager.toast.thumbnailsGenerated",{count:W.succeeded}),"success"):W.succeeded>0&&W.failed>0?n(t("fileManager.toast.thumbnailsGeneratedPartial",{succeeded:W.succeeded,failed:W.failed}),"success"):W.processed===0?n(t("fileManager.toast.noStlMissingThumbnails"),"info"):n(t("fileManager.toast.failedToGenerateThumbnails",{error:W.results[0]?.error||"Unknown error"}),"error")},onError:W=>n(W.message,"error")}),Ve=mt({mutationFn:W=>ue.batchGenerateStlThumbnails({file_ids:[W]}),onSuccess:W=>{if(e.invalidateQueries({queryKey:["library-files"]}),W.succeeded>0){const De=W.results[0]?.file_id;De&&j(Ye=>({...Ye,[De]:Date.now()})),n(t("fileManager.toast.thumbnailGenerated"),"success")}else n(t("fileManager.toast.failedToGenerateThumbnail",{error:W.results[0]?.error||"Unknown error"}),"error")},onError:W=>n(W.message,"error")}),$e=_.useCallback(W=>{const De=W.toLowerCase();return De.endsWith(".gcode")||De.includes(".gcode.")},[]),ye=_.useMemo(()=>ce?ce.filter(W=>f.includes(W.id)&&$e(W.filename)):[],[ce,f,$e]),je=_.useCallback(W=>{p(De=>De.includes(W)?De.filter(Ye=>Ye!==W):[...De,W])},[]),Be=_.useCallback(()=>{fe.length>0&&p(fe.map(W=>W.id))},[fe]),Se=_.useCallback(()=>{p([])},[]),Xe=()=>{e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["library-stats"]})},Me=W=>{window.open(ue.getLibraryFileDownloadUrl(W),"_blank")},tt=()=>{k&&(k.type==="file"?O.mutate(k.id):k.type==="folder"?z.mutate(k.id):k.type==="bulk"&&ee.mutate(f))},ke=z.isPending||O.isPending||ee.isPending,We=W=>{K(W),localStorage.setItem("library-view-mode",W)},ze=Y||q;return s.jsxs("div",{className:"p-4 md:p-8 min-h-[calc(100vh-64px)] lg:h-[calc(100vh-64px)] flex flex-col",children:[s.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4 mb-6",children:[s.jsxs("div",{children:[s.jsxs("h1",{className:"text-2xl font-bold text-white flex items-center gap-3",children:[s.jsx("div",{className:"p-2.5 bg-bambu-green/10 rounded-xl",children:s.jsx(Il,{className:"w-6 h-6 text-bambu-green"})}),t("fileManager.title")]}),s.jsx("p",{className:"text-sm text-bambu-gray mt-2 ml-14",children:t("fileManager.subtitle")})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"flex items-center bg-bambu-dark rounded-lg p-1",children:[s.jsx("button",{onClick:()=>We("grid"),className:`p-1.5 rounded transition-colors ${H==="grid"?"bg-bambu-card text-white":"text-bambu-gray hover:text-white"}`,title:t("fileManager.gridView"),children:s.jsx(mN,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>We("list"),className:`p-1.5 rounded transition-colors ${H==="list"?"bg-bambu-card text-white":"text-bambu-gray hover:text-white"}`,title:t("fileManager.listView"),children:s.jsx(pN,{className:"w-4 h-4"})})]}),s.jsxs(Te,{variant:"secondary",onClick:()=>He.mutate(),disabled:He.isPending||!i("library:update_own","library:update_all"),title:i("library:update_own","library:update_all")?t("fileManager.generateThumbnailsForMissing"):t("fileManager.noPermissionGenerateThumbnail"),children:[He.isPending?s.jsx(ht,{className:"w-4 h-4 mr-2 animate-spin"}):s.jsx(Ou,{className:"w-4 h-4 mr-2"}),t("fileManager.generateThumbnails")]}),s.jsxs(Te,{variant:"secondary",onClick:()=>x(!0),disabled:!r("library:upload"),title:r("library:upload")?void 0:t("fileManager.noPermissionCreateFolder"),children:[s.jsx(Fue,{className:"w-4 h-4 mr-2"}),t("fileManager.newFolder")]}),s.jsxs(Te,{onClick:()=>S(!0),disabled:!r("library:upload"),title:r("library:upload")?void 0:t("fileManager.noPermissionUpload"),children:[s.jsx(Ua,{className:"w-4 h-4 mr-2"}),t("common.upload")]})]})]}),me&&te&&Ke&&s.jsxs("div",{className:"flex items-center gap-3 mb-4 p-3 bg-amber-500/10 border border-amber-500/30 rounded-lg",children:[s.jsx(Cn,{className:"w-5 h-5 text-amber-500 flex-shrink-0"}),s.jsxs("div",{className:"flex-1",children:[s.jsx("p",{className:"text-sm text-amber-500 font-medium",children:t("fileManager.lowDiskSpaceWarning")}),s.jsx("p",{className:"text-xs text-amber-500/80",children:t("fileManager.lowDiskSpaceDetails",{free:hg(te.disk_free_bytes),total:hg(te.disk_total_bytes),threshold:Ke.library_disk_warning_gb})})]})]}),te&&s.jsxs("div",{className:"flex flex-wrap items-center gap-3 sm:gap-6 mb-6 p-3 bg-bambu-card rounded-lg border border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx(cN,{className:"w-4 h-4 text-bambu-green"}),s.jsxs("span",{className:"text-bambu-gray",children:[t("fileManager.files"),":"]}),s.jsx("span",{className:"text-white font-medium",children:te.total_files})]}),s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx(Il,{className:"w-4 h-4 text-blue-400"}),s.jsxs("span",{className:"text-bambu-gray",children:[t("fileManager.folders"),":"]}),s.jsx("span",{className:"text-white font-medium",children:te.total_folders})]}),s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx(hN,{className:"w-4 h-4 text-amber-400"}),s.jsxs("span",{className:"text-bambu-gray",children:[t("fileManager.size"),":"]}),s.jsx("span",{className:"text-white font-medium",children:hg(te.total_size_bytes)})]}),s.jsxs("div",{className:"flex items-center gap-2 text-sm sm:ml-auto",children:[s.jsxs("span",{className:"text-bambu-gray",children:[t("fileManager.free"),":"]}),s.jsx("span",{className:`font-medium ${me?"text-amber-500":"text-white"}`,children:hg(te.disk_free_bytes)})]})]}),s.jsxs("div",{className:"flex-1 flex flex-col lg:flex-row gap-4 lg:gap-6 min-h-0",children:[s.jsx("div",{className:"lg:hidden",children:s.jsxs("select",{value:u??"",onChange:W=>d(W.target.value?parseInt(W.target.value,10):null),className:"w-full bg-bambu-card border border-bambu-dark-tertiary rounded-lg px-3 py-2.5 text-white focus:outline-none focus:border-bambu-green",children:[s.jsxs("option",{value:"",children:["📁 ",t("fileManager.allFiles")]}),G&&(()=>{const W=(De,Ye=0)=>{const xt=[];for(const ft of De)xt.push({id:ft.id,name:ft.name,fileCount:ft.file_count,depth:Ye}),ft.children.length>0&&xt.push(...W(ft.children,Ye+1));return xt};return W(G).map(De=>s.jsxs("option",{value:De.id,children:["│ ".repeat(De.depth),"📂 ",De.name," ",De.fileCount>0?`(${De.fileCount})`:""]},De.id))})()]})}),s.jsxs("div",{ref:ne,className:"hidden lg:flex flex-shrink-0 bg-bambu-card rounded-lg border border-bambu-dark-tertiary overflow-hidden flex-col relative",style:{width:`${Z}px`},children:[s.jsx("div",{className:`absolute right-0 top-0 bottom-0 w-1.5 cursor-col-resize z-10 group/resize flex items-center justify-center transition-colors ${B?"bg-bambu-green":"hover:bg-bambu-green/50"}`,onMouseDown:W=>{W.preventDefault(),X(!0)},onDoubleClick:()=>{ae(256),localStorage.setItem("library-sidebar-width","256")},title:t("fileManager.dragToResizeTooltip"),children:s.jsxs("div",{className:`flex flex-col gap-1 opacity-0 group-hover/resize:opacity-100 transition-opacity ${B?"opacity-100":""}`,children:[s.jsx("div",{className:"w-0.5 h-0.5 rounded-full bg-white/70"}),s.jsx("div",{className:"w-0.5 h-0.5 rounded-full bg-white/70"}),s.jsx("div",{className:"w-0.5 h-0.5 rounded-full bg-white/70"})]})}),s.jsxs("div",{className:"p-3 border-b border-bambu-dark-tertiary flex items-center justify-between",children:[s.jsx("h2",{className:"text-sm font-medium text-white",children:t("fileManager.folders")}),s.jsx("button",{onClick:()=>{const W=!V;Q(W),localStorage.setItem("library-wrap-folders",String(W))},className:`text-xs px-1.5 py-0.5 rounded transition-colors ${V?"bg-bambu-green/20 text-bambu-green":"text-bambu-gray hover:text-white hover:bg-bambu-dark"}`,title:t(V?"fileManager.disableTextWrapping":"fileManager.enableTextWrapping"),children:t("fileManager.wrap")})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto p-2",children:[s.jsxs("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded cursor-pointer transition-colors ${u===null?"bg-bambu-green/20 text-bambu-green":"hover:bg-bambu-dark text-white"}`,onClick:()=>d(null),children:[s.jsx(zf,{className:"w-4 h-4"}),s.jsx("span",{className:"text-sm",children:t("fileManager.allFiles")})]}),G?.map(W=>s.jsx(zre,{folder:W,selectedFolderId:u,onSelect:d,onDelete:De=>C({type:"folder",id:De}),onLink:T,onRename:De=>F({type:"folder",id:De.id,name:De.name}),wrapNames:V,hasPermission:r,t},W.id))]})]}),s.jsxs("div",{className:"flex-1 flex flex-col min-w-0 min-h-0",children:[ce&&ce.length>0&&s.jsxs("div",{className:"flex flex-wrap items-center gap-2 sm:gap-3 mb-4 p-2 sm:p-3 bg-bambu-card rounded-lg border border-bambu-dark-tertiary sticky top-0 z-10 lg:static",children:[s.jsxs("div",{className:"relative w-full sm:w-auto sm:flex-1 sm:max-w-xs",children:[s.jsx(ba,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",placeholder:t("fileManager.searchFiles"),value:se,onChange:W=>be(W.target.value),className:"w-full pl-9 pr-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(uN,{className:"w-4 h-4 text-bambu-gray hidden sm:block"}),s.jsxs("select",{value:xe,onChange:W=>de(W.target.value),className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1.5 text-sm text-white focus:outline-none focus:border-bambu-green",children:[s.jsx("option",{value:"all",children:t("fileManager.allTypes")}),I.map(W=>s.jsx("option",{value:W,children:W.toUpperCase()},W))]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("select",{value:Pe,onChange:W=>{const De=W.target.value;ie(De),localStorage.setItem("library-sort-field",De)},className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1.5 text-sm text-white focus:outline-none focus:border-bambu-green",children:[s.jsx("option",{value:"name",children:t("common.name")}),s.jsx("option",{value:"date",children:t("common.date")}),s.jsx("option",{value:"size",children:t("fileManager.size")}),s.jsx("option",{value:"type",children:t("common.type")}),s.jsx("option",{value:"prints",children:t("fileManager.prints")})]}),s.jsx("button",{onClick:()=>Oe(W=>{const De=W==="asc"?"desc":"asc";return localStorage.setItem("library-sort-direction",De),De}),className:"p-1.5 rounded bg-bambu-dark border border-bambu-dark-tertiary hover:border-bambu-green transition-colors",title:t(Ne==="asc"?"fileManager.ascending":"fileManager.descending"),children:Ne==="asc"?s.jsx(fce,{className:"w-4 h-4 text-white"}):s.jsx(sce,{className:"w-4 h-4 text-white"})})]}),(se||xe!=="all")&&s.jsx("span",{className:"text-sm text-bambu-gray hidden sm:inline",children:t("fileManager.resultsCount",{showing:fe.length,total:ce.length})})]}),fe.length>0&&s.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-4 p-2 bg-bambu-card rounded-lg border border-bambu-dark-tertiary sticky top-[52px] z-10 lg:static",children:[f.length===fe.length&&f.length>0?s.jsxs(Te,{variant:"secondary",size:"sm",onClick:Se,children:[s.jsx(ll,{className:"w-4 h-4 sm:mr-1"}),s.jsx("span",{className:"hidden sm:inline",children:t("fileManager.deselectAll")})]}):s.jsxs(Te,{variant:"secondary",size:"sm",onClick:Be,children:[s.jsx(ol,{className:"w-4 h-4 sm:mr-1"}),s.jsx("span",{className:"hidden sm:inline",children:t("fileManager.selectAll")})]}),f.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-sm text-bambu-gray ml-2",children:t("fileManager.selected",{count:f.length})}),s.jsx("div",{className:"hidden sm:block flex-1"}),s.jsxs("div",{className:"w-full sm:w-auto flex flex-wrap items-center gap-2 mt-2 sm:mt-0",children:[ye.length===1&&s.jsxs(Te,{variant:"primary",size:"sm",onClick:()=>R(ye[0]),disabled:!r("printers:control"),title:r("printers:control")?void 0:t("fileManager.noPermissionPrint"),children:[s.jsx(Is,{className:"w-4 h-4 sm:mr-1"}),s.jsx("span",{className:"hidden sm:inline",children:t("common.print")})]}),ye.length>0&&s.jsxs(Te,{variant:ye.length===1?"secondary":"primary",size:"sm",onClick:()=>we.mutate(ye.map(W=>W.id)),disabled:we.isPending||!r("queue:create"),title:r("queue:create")?void 0:t("fileManager.noPermissionAddToQueue"),children:[s.jsx(er,{className:"w-4 h-4 sm:mr-1"}),s.jsx("span",{className:"hidden sm:inline",children:we.isPending?t("fileManager.adding"):`${t("fileManager.addToQueue")}${ye.length<f.length?` (${ye.length})`:""}`})]}),s.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>y(!0),disabled:!i("library:update_own","library:update_all"),title:i("library:update_own","library:update_all")?void 0:t("fileManager.noPermissionMoveFiles"),children:[s.jsx(Gde,{className:"w-4 h-4 sm:mr-1"}),s.jsx("span",{className:"hidden sm:inline",children:t("common.move")})]}),s.jsxs(Te,{variant:"danger",size:"sm",onClick:()=>{f.length===1?C({type:"file",id:f[0]}):C({type:"bulk",id:0,count:f.length})},disabled:!i("library:delete_own","library:delete_all"),title:i("library:delete_own","library:delete_all")?void 0:t("fileManager.noPermissionDeleteFiles"),children:[s.jsx(rn,{className:"w-4 h-4 sm:mr-1"}),s.jsx("span",{className:"hidden sm:inline",children:t("common.delete")})]}),s.jsxs(Te,{variant:"secondary",size:"sm",onClick:Se,children:[s.jsx(Rt,{className:"w-4 h-4 sm:mr-1"}),s.jsx("span",{className:"hidden sm:inline",children:t("common.clear")})]})]})]})]}),ze?s.jsx("div",{className:"flex-1 flex items-center justify-center",children:s.jsxs("div",{className:"flex flex-col items-center gap-3",children:[s.jsx(ht,{className:"w-8 h-8 animate-spin text-bambu-green"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:t("fileManager.loadingFiles")})]})}):ce?.length===0?s.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center",children:[s.jsx("div",{className:"p-4 bg-bambu-dark rounded-2xl mb-4",children:s.jsx(zf,{className:"w-12 h-12 text-bambu-gray/50"})}),s.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:t(u!==null?"fileManager.folderIsEmpty":"fileManager.noFilesYet")}),s.jsx("p",{className:"text-bambu-gray text-center max-w-md mb-6",children:t(u!==null?"fileManager.folderEmptyDescription":"fileManager.noFilesDescription")}),s.jsxs(Te,{onClick:()=>S(!0),disabled:!r("library:upload"),title:r("library:upload")?void 0:t("fileManager.noPermissionUpload"),children:[s.jsx(dr,{className:"w-4 h-4 mr-2"}),t("fileManager.uploadFiles")]})]}):fe.length===0?s.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center",children:[s.jsx("div",{className:"p-4 bg-bambu-dark rounded-2xl mb-4",children:s.jsx(ba,{className:"w-12 h-12 text-bambu-gray/50"})}),s.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:t("fileManager.noMatchingFiles")}),s.jsx("p",{className:"text-bambu-gray text-center max-w-md mb-6",children:t("fileManager.noMatchingFilesDescription")}),s.jsx(Te,{variant:"secondary",onClick:()=>{be(""),de("all")},children:t("fileManager.clearFilters")})]}):H==="grid"?s.jsx("div",{className:"flex-1 lg:overflow-y-auto",children:s.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 2xl:grid-cols-6 gap-4",children:fe.map(W=>s.jsx(iXe,{file:W,isSelected:f.includes(W.id),isMobile:ge,t,onSelect:je,onDelete:De=>C({type:"file",id:De}),onDownload:Me,onAddToQueue:De=>we.mutate([De]),onPrint:D,onRename:De=>F({type:"file",id:De.id,name:De.filename}),onGenerateThumbnail:De=>Ve.mutate(De.id),thumbnailVersion:$[W.id],hasPermission:r,canModify:a},W.id))})}):s.jsx("div",{className:"flex-1 lg:overflow-y-auto",children:s.jsxs("div",{className:"bg-bambu-card rounded-lg border border-bambu-dark-tertiary overflow-hidden",children:[s.jsxs("div",{className:"hidden sm:grid grid-cols-[auto_1fr_100px_100px_100px_80px] gap-4 px-4 py-2 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary text-xs text-bambu-gray font-medium",children:[s.jsx("div",{className:"w-6"}),s.jsx("div",{children:t("common.name")}),s.jsx("div",{children:t("common.type")}),s.jsx("div",{children:t("fileManager.size")}),s.jsx("div",{children:t("fileManager.prints")}),s.jsx("div",{})]}),fe.map(W=>s.jsxs("div",{className:`grid grid-cols-[auto_1fr_100px_100px_100px_80px] gap-4 px-4 py-3 items-center border-b border-bambu-dark-tertiary last:border-b-0 cursor-pointer hover:bg-bambu-dark/50 transition-colors ${f.includes(W.id)?"bg-bambu-green/10":""}`,onClick:()=>je(W.id),children:[s.jsx("div",{className:`w-5 h-5 rounded border-2 flex items-center justify-center ${f.includes(W.id)?"bg-bambu-green border-bambu-green":"border-bambu-gray/50"}`,children:f.includes(W.id)&&s.jsx("div",{className:"w-2 h-2 bg-white rounded-sm"})}),s.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[s.jsxs("div",{className:"relative group/thumb",children:[s.jsx("div",{className:"w-10 h-10 rounded bg-bambu-dark flex-shrink-0 overflow-hidden",children:W.thumbnail_path?s.jsx("img",{src:`${ue.getLibraryFileThumbnailUrl(W.id)}${$[W.id]?`?v=${$[W.id]}`:""}`,alt:"",className:"w-full h-full object-cover"}):s.jsx("div",{className:"w-full h-full flex items-center justify-center",children:s.jsx(zf,{className:"w-5 h-5 text-bambu-gray/50"})})}),W.thumbnail_path&&s.jsx("div",{className:"absolute left-0 top-full mt-2 z-50 hidden group-hover/thumb:block",children:s.jsx("div",{className:"w-48 h-48 rounded-lg bg-bambu-dark-secondary border border-bambu-dark-tertiary shadow-xl overflow-hidden",children:s.jsx("img",{src:`${ue.getLibraryFileThumbnailUrl(W.id)}${$[W.id]?`?v=${$[W.id]}`:""}`,alt:W.filename,className:"w-full h-full object-contain"})})})]}),s.jsx("div",{className:"min-w-0",children:s.jsx("div",{className:"text-sm text-white truncate",children:W.print_name||W.filename})})]}),s.jsx("div",{children:s.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded font-medium ${W.file_type==="3mf"?"bg-bambu-green/20 text-bambu-green":W.file_type==="gcode"?"bg-blue-500/20 text-blue-400":W.file_type==="stl"?"bg-purple-500/20 text-purple-400":"bg-bambu-gray/20 text-bambu-gray"}`,children:W.file_type.toUpperCase()})}),s.jsx("div",{className:"text-sm text-bambu-gray",children:hg(W.file_size)}),s.jsx("div",{className:"text-sm text-bambu-gray",children:W.print_count>0?`${W.print_count}x`:"-"}),s.jsxs("div",{className:"flex items-center gap-1",onClick:De=>De.stopPropagation(),children:[hR(W.filename)&&s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:()=>r("printers:control")&&D(W),className:`p-1.5 rounded transition-colors ${r("printers:control")?"hover:bg-bambu-dark text-bambu-gray hover:text-bambu-green":"text-bambu-gray/50 cursor-not-allowed"}`,title:r("printers:control")?t("common.print"):t("fileManager.noPermissionPrint"),disabled:!r("printers:control"),children:s.jsx(Ur,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>r("queue:create")&&we.mutate([W.id]),className:`p-1.5 rounded transition-colors ${r("queue:create")?"hover:bg-bambu-dark text-bambu-gray hover:text-white":"text-bambu-gray/50 cursor-not-allowed"}`,title:r("queue:create")?t("fileManager.addToQueue"):t("fileManager.noPermissionAddToQueue"),disabled:we.isPending||!r("queue:create"),children:s.jsx(er,{className:"w-4 h-4"})})]}),s.jsx("button",{onClick:()=>r("library:read")&&Me(W.id),className:`p-1.5 rounded transition-colors ${r("library:read")?"hover:bg-bambu-dark text-bambu-gray hover:text-white":"text-bambu-gray/50 cursor-not-allowed"}`,title:r("library:read")?t("common.download"):t("fileManager.noPermissionDownload"),disabled:!r("library:read"),children:s.jsx(yi,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>a("library","update",W.created_by_id)&&F({type:"file",id:W.id,name:W.filename}),className:`p-1.5 rounded transition-colors ${a("library","update",W.created_by_id)?"hover:bg-bambu-dark text-bambu-gray hover:text-white":"text-bambu-gray/50 cursor-not-allowed"}`,title:a("library","update",W.created_by_id)?t("common.rename"):t("fileManager.noPermissionRenameFile"),disabled:!a("library","update",W.created_by_id),children:s.jsx(Qi,{className:"w-4 h-4"})}),W.file_type==="stl"&&s.jsx("button",{onClick:()=>a("library","update",W.created_by_id)&&Ve.mutate(W.id),className:`p-1.5 rounded transition-colors ${a("library","update",W.created_by_id)?"hover:bg-bambu-dark text-bambu-gray hover:text-bambu-green":"text-bambu-gray/50 cursor-not-allowed"}`,title:a("library","update",W.created_by_id)?t("fileManager.generateThumbnail"):t("fileManager.noPermissionGenerateThumbnail"),disabled:Ve.isPending||!a("library","update",W.created_by_id),children:s.jsx(Ou,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>a("library","delete",W.created_by_id)&&C({type:"file",id:W.id}),className:`p-1.5 rounded transition-colors ${a("library","delete",W.created_by_id)?"hover:bg-bambu-dark text-bambu-gray hover:text-red-400":"text-bambu-gray/50 cursor-not-allowed"}`,title:a("library","delete",W.created_by_id)?t("common.delete"):t("fileManager.noPermissionDeleteFile"),disabled:!a("library","delete",W.created_by_id),children:s.jsx(rn,{className:"w-4 h-4"})})]})]},W.id))]})})]})]}),m&&s.jsx(JKe,{parentId:u,onClose:()=>x(!1),onSave:W=>Ee.mutate(W),isLoading:Ee.isPending,t}),b&&G&&s.jsx(tXe,{folders:G,selectedFiles:f,currentFolderId:u,onClose:()=>y(!1),onMove:W=>le.mutate({fileIds:f,folderId:W}),isLoading:le.isPending,t}),v&&s.jsx(rXe,{folderId:u,onClose:()=>S(!1),onUploadComplete:Xe,t}),N&&s.jsx(nXe,{folder:N,onClose:()=>T(null),onLink:W=>_e.mutate({id:N.id,data:W}),isLoading:_e.isPending,t}),k&&s.jsx(Zn,{title:k.type==="folder"?t("fileManager.deleteFolder"):k.type==="bulk"?t("fileManager.deleteFilesCount",{count:k.count}):t("fileManager.deleteFile"),message:k.type==="folder"?t("fileManager.deleteFolderConfirm"):k.type==="bulk"?t("fileManager.deleteFilesConfirm",{count:k.count}):t("fileManager.deleteFileConfirm"),confirmText:t("common.delete"),variant:"danger",isLoading:ke,loadingText:t("fileManager.deleting"),onConfirm:tt,onCancel:()=>C(null)}),E&&s.jsx(jh,{mode:"reprint",libraryFileId:E.id,archiveName:E.print_name||E.filename,onClose:()=>D(null),onSuccess:()=>{D(null),e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["archives"]})}}),A&&s.jsx(jh,{mode:"reprint",libraryFileId:A.id,archiveName:A.print_name||A.filename,onClose:()=>R(null),onSuccess:()=>{R(null),p([]),e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["archives"]})}}),U&&s.jsx(eXe,{type:U.type,currentName:U.name,onClose:()=>F(null),onSave:W=>{U.type==="file"?re.mutate({id:U.id,filename:W}):Fe.mutate({id:U.id,name:W})},isLoading:re.isPending||Fe.isPending,t})]})}const Kj=5,sXe=2e3,oXe=3e4,lXe=5e3;function cXe(){const{t}=Hn(),{printerId:e}=rN(),n=parseInt(e||"0",10),[r,i]=_.useState("stream"),[a,o]=_.useState(!1),[l,c]=_.useState(!0),[u,d]=_.useState(Date.now()),[f,p]=_.useState(!1),[m,x]=_.useState(!1),[b,y]=_.useState(0),[v,S]=_.useState(!1),[N,T]=_.useState(0),[k,C]=_.useState(1),[E,D]=_.useState({x:0,y:0}),[A,R]=_.useState(!1),[U,F]=_.useState({x:0,y:0}),[$,j]=_.useState(null),[H,K]=_.useState(null),V=_.useRef(null),Q=_.useRef(null),Z=_.useRef(null),ae=_.useRef(null),B=_.useRef(null),{data:X}=at({queryKey:["printer",n],queryFn:()=>ue.getPrinter(n),enabled:n>0});_.useEffect(()=>(X&&(document.title=`${X.name} - Camera`),()=>{document.title="Bambuddy"}),[X]);const ne=_.useRef(!1);_.useEffect(()=>{const le=`/api/v1/printers/${n}/camera/stop`;ne.current=!1;const _e=()=>{n>0&&!ne.current&&(ne.current=!0,navigator.sendBeacon(le))},we=()=>{_e()};window.addEventListener("beforeunload",we);const re=V.current;return()=>{window.removeEventListener("beforeunload",we),re&&(re.src=""),_e()}},[n]),_.useEffect(()=>{if(l&&!f){const _e=setTimeout(()=>{c(!1)},r==="stream"?3e3:2e4);return()=>clearTimeout(_e)}},[r,l,u,f]),_.useEffect(()=>{const le=()=>{const _e=!!document.fullscreenElement;x(_e),C(1),D({x:0,y:0}),r==="stream"&&!f&&(V.current&&(V.current.src=""),setTimeout(()=>{c(!0),d(Date.now())},200))};return document.addEventListener("fullscreenchange",le),()=>document.removeEventListener("fullscreenchange",le)},[r,f]),_.useEffect(()=>{let le;const _e=()=>{clearTimeout(le),le=setTimeout(()=>{localStorage.setItem("cameraWindowState",JSON.stringify({width:window.outerWidth,height:window.outerHeight,left:window.screenX,top:window.screenY}))},500)};return window.addEventListener("resize",_e),()=>{clearTimeout(le),window.removeEventListener("resize",_e)}},[]),_.useEffect(()=>()=>{Z.current&&clearTimeout(Z.current),ae.current&&clearInterval(ae.current),B.current&&clearInterval(B.current)},[]);const se=_.useCallback(()=>{if(b>=Kj){S(!1),o(!0);return}const le=Math.min(sXe*Math.pow(2,b),oXe);S(!0),T(Math.ceil(le/1e3)),ae.current=setInterval(()=>{T(_e=>_e<=1?(ae.current&&clearInterval(ae.current),0):_e-1)},1e3),Z.current=setTimeout(()=>{y(_e=>_e+1),S(!1),c(!0),o(!1),V.current&&(V.current.src=""),d(Date.now())},le)},[b]);_.useEffect(()=>{if(r!=="stream"||l||v||f){B.current&&(clearInterval(B.current),B.current=null);return}return B.current=setInterval(async()=>{try{const le=await fetch(`/api/v1/printers/${n}/camera/status`);if(le.ok){const _e=await le.json();(_e.stalled||!_e.active&&!a)&&(console.log(`Stream issue detected: stalled=${_e.stalled}, active=${_e.active}, reconnecting...`),B.current&&(clearInterval(B.current),B.current=null),c(!1),se())}}catch{}},lXe),()=>{B.current&&(clearInterval(B.current),B.current=null)}},[r,l,a,v,f,n,se]);const be=()=>{c(!1),r==="stream"&&b<Kj?se():o(!0)},xe=()=>{if(c(!1),o(!1),y(0),S(!1),Z.current&&clearTimeout(Z.current),ae.current&&clearInterval(ae.current),V.current&&!localStorage.getItem("cameraWindowState")){const le=V.current,_e=le.naturalWidth,we=le.naturalHeight;if(_e>0&&we>0){const He=window.outerWidth-window.innerWidth,Ve=window.outerHeight-window.innerHeight,$e=_e+16+He,ye=we+45+16+Ve;try{window.resizeTo($e,ye)}catch{}}}},de=()=>{n>0&&fetch(`/api/v1/printers/${n}/camera/stop`).catch(()=>{})},Pe=le=>{r===le||f||(p(!0),c(!0),o(!1),y(0),S(!1),C(1),D({x:0,y:0}),Z.current&&clearTimeout(Z.current),ae.current&&clearInterval(ae.current),V.current&&(V.current.src=""),r==="stream"&&de(),setTimeout(()=>{i(le),d(Date.now()),p(!1)},100))},ie=()=>{f||(p(!0),c(!0),o(!1),y(0),S(!1),Z.current&&clearTimeout(Z.current),ae.current&&clearInterval(ae.current),V.current&&(V.current.src=""),r==="stream"&&de(),setTimeout(()=>{d(Date.now()),p(!1)},100))},Ne=()=>{Q.current&&(document.fullscreenElement?document.exitFullscreen():Q.current.requestFullscreen())},Oe=()=>{C(le=>Math.min(le+.5,4))},ge=()=>{C(le=>{const _e=Math.max(le-.5,1);return _e===1&&D({x:0,y:0}),_e})},Ke=le=>{le.preventDefault(),le.deltaY<0?Oe():ge()},G=le=>{k>1&&(le.preventDefault(),R(!0),F({x:le.clientX-E.x,y:le.clientY-E.y}))},Y=_.useCallback(()=>{if(!Q.current)return{x:300,y:200};const le=Q.current.getBoundingClientRect(),_e=le.width*(k-1)/2,we=le.height*(k-1)/2;return{x:Math.max(50,_e),y:Math.max(50,we)}},[k]),ce=le=>{if(A&&k>1){const _e=le.clientX-U.x,we=le.clientY-U.y,re=Y();D({x:Math.max(-re.x,Math.min(re.x,_e)),y:Math.max(-re.y,Math.min(re.y,we))})}},q=()=>{R(!1)},te=le=>{if(le.length<2)return 0;const _e=le[0].clientX-le[1].clientX,we=le[0].clientY-le[1].clientY;return Math.sqrt(_e*_e+we*we)},I=le=>le.length<2?{x:le[0].clientX,y:le[0].clientY}:{x:(le[0].clientX+le[1].clientX)/2,y:(le[0].clientY+le[1].clientY)/2},fe=le=>{le.touches.length===2?(le.preventDefault(),j(te(le.touches)),K(I(le.touches))):le.touches.length===1&&k>1&&(le.preventDefault(),R(!0),F({x:le.touches[0].clientX-E.x,y:le.touches[0].clientY-E.y}))},me=le=>{if(le.touches.length===2&&$!==null){le.preventDefault();const _e=te(le.touches),we=_e/$;C(Fe=>{const He=Math.max(1,Math.min(4,Fe*we));return He===1&&D({x:0,y:0}),He}),j(_e);const re=I(le.touches);if(H){const Fe=Y();D(He=>({x:Math.max(-Fe.x,Math.min(Fe.x,He.x+(re.x-H.x))),y:Math.max(-Fe.y,Math.min(Fe.y,He.y+(re.y-H.y)))}))}K(re)}else if(le.touches.length===1&&A&&k>1){le.preventDefault();const _e=le.touches[0].clientX-U.x,we=le.touches[0].clientY-U.y,re=Y();D({x:Math.max(-re.x,Math.min(re.x,_e)),y:Math.max(-re.y,Math.min(re.y,we))})}},Ee=le=>{le.touches.length<2&&(j(null),K(null)),le.touches.length===0&&R(!1)},z=()=>{C(1),D({x:0,y:0})},O=f?"":r==="stream"?`/api/v1/printers/${n}/camera/stream?fps=15&t=${u}`:`/api/v1/printers/${n}/camera/snapshot?t=${u}`,ee=l||f||v;return n?s.jsxs("div",{ref:Q,className:"min-h-screen bg-black flex flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary",children:[s.jsxs("h1",{className:"text-sm font-medium text-white flex items-center gap-2",children:[s.jsx(Ug,{className:"w-4 h-4"}),X?.name||`Printer ${n}`]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"flex bg-bambu-dark rounded p-0.5",children:[s.jsx("button",{onClick:()=>Pe("stream"),disabled:ee,className:`px-3 py-1 text-xs rounded transition-colors ${r==="stream"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white disabled:opacity-50"}`,children:t("camera.live")}),s.jsx("button",{onClick:()=>Pe("snapshot"),disabled:ee,className:`px-3 py-1 text-xs rounded transition-colors ${r==="snapshot"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white disabled:opacity-50"}`,children:t("camera.snapshot")})]}),s.jsx("button",{onClick:ie,disabled:ee,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded disabled:opacity-50",title:t(r==="stream"?"camera.restartStream":"camera.refreshSnapshot"),children:s.jsx(Dr,{className:`w-4 h-4 text-bambu-gray ${ee?"animate-spin":""}`})}),s.jsx("button",{onClick:Ne,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded",title:t(m?"camera.exitFullscreen":"camera.fullscreen"),children:m?s.jsx(_W,{className:"w-4 h-4 text-bambu-gray"}):s.jsx(Dde,{className:"w-4 h-4 text-bambu-gray"})})]})]}),s.jsx("div",{className:"flex-1 flex items-center justify-center p-2 overflow-hidden",onWheel:Ke,onMouseMove:ce,onMouseUp:q,onMouseLeave:q,onTouchStart:fe,onTouchMove:me,onTouchEnd:Ee,style:{touchAction:"none"},children:s.jsxs("div",{className:"relative w-full h-full flex items-center justify-center",children:[(l||f)&&!v&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50 z-10",children:s.jsxs("div",{className:"text-center",children:[s.jsx(Dr,{className:"w-8 h-8 text-bambu-gray animate-spin mx-auto mb-2"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:t(r==="stream"?"camera.connectingToCamera":"camera.capturingSnapshot")})]})}),v&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/80 z-10",children:s.jsxs("div",{className:"text-center p-4",children:[s.jsx(sm,{className:"w-10 h-10 text-orange-400 mx-auto mb-3"}),s.jsx("p",{className:"text-white mb-2",children:t("camera.connectionLost")}),s.jsx("p",{className:"text-sm text-bambu-gray mb-3",children:t("camera.reconnecting",{countdown:N,attempt:b+1,max:Kj})}),s.jsx("button",{onClick:ie,className:"px-4 py-2 bg-bambu-green text-white text-sm rounded hover:bg-bambu-green/80 transition-colors",children:t("camera.reconnectNow")})]})}),a&&!v&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black z-10",children:s.jsxs("div",{className:"text-center p-4",children:[s.jsx(Cn,{className:"w-12 h-12 text-orange-400 mx-auto mb-3"}),s.jsx("p",{className:"text-white mb-2",children:t("camera.cameraUnavailable")}),s.jsx("p",{className:"text-xs text-bambu-gray mb-4 max-w-md",children:t("camera.cameraUnavailableDesc")}),s.jsx("button",{onClick:ie,className:"px-4 py-2 bg-bambu-green text-white rounded hover:bg-bambu-green/80 transition-colors",children:t("camera.retry")})]})}),s.jsx("img",{ref:V,src:O,alt:t("camera.cameraStream"),className:"max-w-full max-h-full object-contain select-none",style:{transform:`scale(${k}) translate(${E.x/k}px, ${E.y/k}px)`,cursor:k>1?A?"grabbing":"grab":"default"},onError:O?be:void 0,onLoad:O?xe:void 0,onMouseDown:G,draggable:!1},u),s.jsxs("div",{className:"absolute bottom-4 left-4 flex items-center gap-1.5 bg-black/60 rounded-lg px-2 py-1.5",children:[s.jsx("button",{onClick:ge,disabled:k<=1,className:"p-1.5 hover:bg-white/10 rounded disabled:opacity-30",title:t("camera.zoomOut"),children:s.jsx(FR,{className:"w-4 h-4 text-white"})}),s.jsxs("button",{onClick:z,className:"px-2 py-1 text-sm text-white hover:bg-white/10 rounded min-w-[48px]",title:t("camera.resetZoom"),children:[Math.round(k*100),"%"]}),s.jsx("button",{onClick:Oe,disabled:k>=4,className:"p-1.5 hover:bg-white/10 rounded disabled:opacity-30",title:t("camera.zoomIn"),children:s.jsx(LR,{className:"w-4 h-4 text-white"})})]})]})})]}):s.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:s.jsx("p",{className:"text-white",children:t("camera.invalidPrinterId")})})}function uXe(t){const e=t.get("show")?.split(",")||["progress","layers","eta","filename","status"],n=parseInt(t.get("fps")||"15",10),r=Math.min(Math.max(isNaN(n)?15:n,1),30),i=t.get("camera"),a=i!=="false"&&i!=="0";return{size:t.get("size")||"medium",fps:r,showCamera:a,showProgress:e.includes("progress"),showLayers:e.includes("layers"),showEta:e.includes("eta"),showFilename:e.includes("filename"),showStatus:e.includes("status"),showPrinter:e.includes("printer")}}function dXe(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function hXe(t,e){const n=new Date,r=new Date(n.getTime()+t*60*1e3),i=new Date;i.setHours(0,0,0,0);const a=new Date(r);a.setHours(0,0,0,0);const o=r.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});return a.getTime()===i.getTime()?o:a.getTime()===i.getTime()+864e5?`${e("streamOverlay.tomorrow")} ${o}`:r.toLocaleDateString([],{weekday:"short"})+" "+o}function fXe(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 mXe(t){switch(t){case"small":return{container:"p-3",text:"text-sm",textLarge:"text-lg",progressHeight:"h-2",icon:"w-3 h-3",gap:"gap-2",logoHeight:"h-12"};case"large":return{container:"p-6",text:"text-xl",textLarge:"text-3xl",progressHeight:"h-4",icon:"w-6 h-6",gap:"gap-4",logoHeight:"h-24"};case"medium":default:return{container:"p-4",text:"text-base",textLarge:"text-xl",progressHeight:"h-3",icon:"w-4 h-4",gap:"gap-3",logoHeight:"h-16"}}}function pXe(){const{printerId:t}=rN(),[e]=wR(),{t:n}=Hn(),r=an(),i=parseInt(t||"0",10),[a,o]=_.useState(Date.now()),l=_.useMemo(()=>uXe(e),[e]),c=mXe(l.size),{data:u}=at({queryKey:["printer",i],queryFn:()=>ue.getPrinter(i),enabled:i>0}),{data:d}=at({queryKey:["printerStatus",i],queryFn:()=>ue.getPrinterStatus(i),enabled:i>0,refetchInterval:2e3});_.useEffect(()=>{if(!i)return;const y=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/api/v1/ws`,v=new WebSocket(y);return v.onmessage=S=>{try{const N=JSON.parse(S.data);N.type==="printer_status"&&N.printer_id===i&&r.setQueryData(["printerStatus",i],N.status)}catch{}},v.onerror=()=>{},()=>{v.close()}},[i,r]),_.useEffect(()=>(document.title=u?`${u.name} - ${n("streamOverlay.title")}`:n("streamOverlay.title"),()=>{document.title="Bambuddy"}),[u,n]);const f=()=>{setTimeout(()=>{o(Date.now())},3e3)};if(!i)return s.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:s.jsx("p",{className:"text-white",children:n("streamOverlay.invalidPrinterId")})});if(!d)return s.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:s.jsx("p",{className:"text-gray-400",children:n("common.loading")})});const p=d.state==="RUNNING"||d.state==="PAUSE",m=d.progress||0,x=`/api/v1/printers/${i}/camera/stream?fps=${l.fps}&t=${a}`;return s.jsxs("div",{className:"min-h-screen bg-black relative overflow-hidden",children:[l.showCamera&&s.jsx("img",{src:x,alt:n("streamOverlay.cameraStream"),className:"absolute inset-0 w-full h-full object-contain",onError:f},a),s.jsx("a",{href:"https://github.com/maziggy/bambuddy",target:"_blank",rel:"noopener noreferrer",className:"absolute top-4 right-4 z-10",children:s.jsx("img",{src:"/img/bambuddy_logo_dark_transparent.png",alt:"Bambuddy",className:`${c.logoHeight} object-contain drop-shadow-lg hover:scale-105 transition-transform`})}),s.jsx("div",{className:"absolute bottom-0 left-0 right-0 z-10 bg-gradient-to-t from-black/80 via-black/60 to-transparent",children:s.jsxs("div",{className:`${c.container}`,children:[l.showPrinter&&u&&s.jsxs("div",{className:`flex items-center ${c.gap} mb-2`,children:[s.jsx(Ur,{className:`${c.icon} text-white/70`}),s.jsx("span",{className:`${c.text} text-white font-medium`,children:u.name})]}),l.showFilename&&d.current_print&&s.jsx("div",{className:`${c.textLarge} text-white font-semibold mb-2 truncate drop-shadow-md`,children:d.current_print.replace(/\.gcode\.3mf$|\.3mf$|\.gcode$/i,"")}),l.showStatus&&s.jsx("div",{className:`${c.text} text-white/70 mb-2`,children:fXe(d,n)}),l.showProgress&&p&&s.jsxs("div",{className:"mb-3",children:[s.jsxs("div",{className:`flex items-center justify-between mb-1 ${c.text}`,children:[s.jsx("span",{className:"text-white/70",children:n("streamOverlay.progress")}),s.jsxs("span",{className:"text-white font-bold",children:[Math.round(m),"%"]})]}),s.jsx("div",{className:`w-full bg-white/20 rounded-full ${c.progressHeight}`,children:s.jsx("div",{className:`bg-bambu-green ${c.progressHeight} rounded-full transition-all duration-500`,style:{width:`${m}%`}})})]}),p&&(l.showLayers||l.showEta)&&s.jsxs("div",{className:`flex items-center ${c.gap} flex-wrap`,children:[l.showLayers&&d.layer_num!=null&&d.total_layers!=null&&d.total_layers>0&&s.jsxs("div",{className:`flex items-center ${c.gap} text-white/70`,children:[s.jsx(sl,{className:c.icon}),s.jsxs("span",{className:c.text,children:[s.jsx("span",{className:"text-white",children:d.layer_num}),s.jsx("span",{className:"mx-1",children:"/"}),s.jsx("span",{children:d.total_layers})]})]}),l.showEta&&d.remaining_time!=null&&d.remaining_time>0&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:`flex items-center ${c.gap} text-white/70`,children:[s.jsx(xu,{className:c.icon}),s.jsx("span",{className:`${c.text} text-white`,children:dXe(d.remaining_time*60)})]}),s.jsxs("div",{className:`flex items-center ${c.gap} text-white/70`,children:[s.jsx(er,{className:c.icon}),s.jsxs("span",{className:`${c.text} text-white`,children:[n("streamOverlay.eta")," ",hXe(d.remaining_time,n)]})]})]})]}),!p&&s.jsx("div",{className:`${c.text} text-white/70 py-2`,children:d.connected?n("streamOverlay.printerIdle"):n("streamOverlay.printerOffline")})]})})]})}function gXe(){const{t}=Hn(),{id:e}=rN(),{mode:n}=Oh(),{data:r,isLoading:i,error:a}=at({queryKey:["external-link",e],queryFn:()=>ue.getExternalLink(Number(e)),enabled:!!e});return i?s.jsx("div",{className:"flex items-center justify-center h-full",children:s.jsx(ht,{className:"w-8 h-8 text-bambu-green animate-spin"})}):a||!r?s.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4 text-bambu-gray",children:[s.jsx(Cn,{className:"w-12 h-12"}),s.jsx("p",{children:t("common.linkNotFound")})]}):s.jsx("iframe",{src:r.url,className:"h-full w-full border-0",style:{colorScheme:n},title:r.name,sandbox:"allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox"})}const xq=["DEBUG","INFO","WARNING","ERROR"],Xj={DEBUG:"text-gray-400",INFO:"text-blue-400",WARNING:"text-yellow-400",ERROR:"text-red-400"},xXe={DEBUG:aN,INFO:Zo,WARNING:Cn,ERROR:Hi};function bXe(){const t=an(),[e,n]=_.useState(!0),[r,i]=_.useState(new Set),[a,o]=_.useState(""),[l,c]=_.useState("ALL"),[u,d]=_.useState(!1),[f,p]=_.useState(!1),m=_.useRef(null),{data:x,isLoading:b,refetch:y}=at({queryKey:["application-logs",l,a],queryFn:()=>Mg.getLogs({limit:200,level:l==="ALL"?void 0:l,search:a||void 0}),refetchInterval:f?2e3:!1,enabled:u});_.useEffect(()=>{u||p(!1)},[u]);const v=mt({mutationFn:()=>Mg.clearLogs(),onSuccess:()=>{t.invalidateQueries({queryKey:["application-logs"]})}});_.useEffect(()=>{e&&m.current&&x?.entries&&(m.current.scrollTop=m.current.scrollHeight)},[x?.entries,e]);const S=E=>{i(D=>{const A=new Set(D);return A.has(E)?A.delete(E):A.add(E),A})},N=E=>{const D=E.split(" ");return D.length>=2?D[1]:E},T=_.useMemo(()=>x?.entries??[],[x?.entries]),k=_.useMemo(()=>[...T].reverse(),[T]),C=({level:E})=>{const D=xXe[E]||Zo;return s.jsx(D,{className:`w-3.5 h-3.5 ${Xj[E]||"text-gray-400"}`})};return s.jsxs("div",{className:"bg-bambu-dark rounded-lg overflow-hidden",children:[s.jsxs("button",{onClick:()=>d(!u),className:"w-full flex items-center justify-between p-4 hover:bg-bambu-dark-tertiary/50 transition-colors",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:`p-2 rounded-lg ${f?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark-tertiary text-bambu-gray"}`,children:s.jsx(aN,{className:"w-5 h-5"})}),s.jsxs("div",{className:"text-left",children:[s.jsx("p",{className:"font-medium text-white",children:"Application Logs"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:f?`Live streaming - ${x?.filtered_count??0} entries`:"View and filter application logs"})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[f&&s.jsxs("span",{className:"flex items-center gap-1.5 px-2 py-1 bg-bambu-green/20 rounded text-bambu-green text-xs",children:[s.jsx("span",{className:"w-1.5 h-1.5 bg-bambu-green rounded-full animate-pulse"}),"Live"]}),u?s.jsx(xh,{className:"w-5 h-5 text-bambu-gray"}):s.jsx(ei,{className:"w-5 h-5 text-bambu-gray"})]})]}),u&&s.jsxs("div",{className:"border-t border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex flex-col gap-2 p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[f?s.jsxs("button",{onClick:E=>{E.stopPropagation(),p(!1)},className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-red-500/20 text-red-400 hover:bg-red-500/30 rounded transition-colors",children:[s.jsx(ll,{className:"w-4 h-4"}),"Stop"]}):s.jsxs("button",{onClick:E=>{E.stopPropagation(),p(!0),y()},className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-bambu-green/20 text-bambu-green hover:bg-bambu-green/30 rounded transition-colors",children:[s.jsx(Is,{className:"w-4 h-4"}),"Start"]}),s.jsxs("button",{onClick:()=>v.mutate(),disabled:v.isPending||T.length===0,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-bambu-dark-tertiary text-bambu-gray hover:text-white hover:bg-bambu-dark-secondary rounded transition-colors disabled:opacity-50",children:[s.jsx(rn,{className:"w-4 h-4"}),"Clear"]}),s.jsx("button",{onClick:()=>y(),disabled:b,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-bambu-dark-tertiary text-bambu-gray hover:text-white hover:bg-bambu-dark-secondary rounded transition-colors disabled:opacity-50",children:s.jsx(Dr,{className:`w-4 h-4 ${b?"animate-spin":""}`})}),s.jsx("div",{className:"flex-1"}),s.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:e,onChange:E=>n(E.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark-tertiary"}),"Auto-scroll"]}),s.jsxs("span",{className:"text-sm text-bambu-gray",children:[x?.filtered_count??0,"/",x?.total_in_file??0]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsx(ba,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",placeholder:"Search message or logger name...",value:a,onChange:E=>o(E.target.value),className:"w-full pl-8 pr-8 py-1.5 text-sm bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"}),a&&s.jsx("button",{onClick:()=>o(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",children:s.jsx(Rt,{className:"w-4 h-4"})})]}),s.jsxs("div",{className:"flex items-center gap-1 bg-bambu-dark-secondary rounded border border-bambu-dark-tertiary",children:[s.jsx("button",{onClick:()=>c("ALL"),className:`px-2 py-1.5 text-xs rounded-l transition-colors ${l==="ALL"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white"}`,children:"All"}),xq.map((E,D)=>s.jsx("button",{onClick:()=>c(E),className:`px-2 py-1.5 text-xs transition-colors flex items-center gap-1 ${D===xq.length-1?"rounded-r":""} ${l===E?`${Xj[E]} bg-bambu-dark-tertiary`:"text-bambu-gray hover:text-white"}`,children:E},E))]})]})]}),s.jsx("div",{ref:m,className:"overflow-auto font-mono text-xs bg-black min-h-[300px] max-h-[500px]",children:T.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center h-[300px] text-bambu-gray",children:[s.jsx("p",{className:"mb-2",children:"No log entries found"}),s.jsx("p",{className:"text-sm",children:"Log file may be empty or cleared"})]}):s.jsx("div",{className:"divide-y divide-bambu-dark-tertiary/30",children:k.map((E,D)=>{const A=r.has(D),R=E.message.includes(`
- `);return s.jsx("div",{className:`p-2 cursor-pointer hover:bg-bambu-dark-secondary/50 transition-colors ${A?"bg-bambu-dark-secondary/30":""}`,onClick:()=>R&&S(D),children:s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("span",{className:"text-bambu-gray/70 shrink-0 w-20",children:N(E.timestamp)}),s.jsx("span",{className:"shrink-0",children:s.jsx(C,{level:E.level})}),s.jsxs("span",{className:"text-purple-400/80 shrink-0 max-w-[200px] truncate",title:E.logger_name,children:["[",E.logger_name,"]"]}),s.jsx("span",{className:`flex-1 ${Xj[E.level]||"text-white/80"} ${!A&&R?"truncate":""}`,children:A?s.jsx("pre",{className:"whitespace-pre-wrap break-all",children:E.message}):E.message.split(`
- `)[0]}),R&&s.jsx("span",{className:"text-bambu-gray/50 shrink-0",children:A?s.jsx(xh,{className:"w-3.5 h-3.5"}):s.jsx(ei,{className:"w-3.5 h-3.5"})})]})},D)})})}),s.jsx("div",{className:"flex items-center justify-between p-3 border-t border-bambu-dark-tertiary text-sm text-bambu-gray",children:f?s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"}),"Auto-refreshing every 2 seconds"]}):s.jsx("span",{children:"Click Start to enable live log streaming"})})]})]})}function yXe(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:t<1024*1024*1024?`${(t/(1024*1024)).toFixed(1)} MB`:`${(t/(1024*1024*1024)).toFixed(2)} GB`}function mi({icon:t,label:e,value:n,subValue:r,color:i="text-bambu-green"}){return s.jsxs("div",{className:"flex items-start gap-3 p-4 bg-bambu-dark rounded-lg",children:[s.jsx("div",{className:`p-2 rounded-lg bg-bambu-dark-tertiary ${i}`,children:s.jsx(t,{className:"w-5 h-5"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:e}),s.jsx("p",{className:"text-lg font-semibold text-white truncate",children:n}),r&&s.jsx("p",{className:"text-xs text-bambu-gray mt-0.5",children:r})]})]})}function bq({percent:t,color:e="bg-bambu-green"}){return s.jsx("div",{className:"w-full h-2 bg-bambu-dark rounded-full overflow-hidden",children:s.jsx("div",{className:`h-full ${e} transition-all duration-300`,style:{width:`${Math.min(100,t)}%`}})})}function Fd({title:t,icon:e,children:n}){return s.jsxs(_t,{className:"p-6",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[s.jsx(e,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:t})]}),n]})}function vXe(){const{t}=Hn(),e=an(),[n,r]=_.useState(null),[i,a]=_.useState(!1),[o,l]=_.useState(!1),{data:c,isLoading:u,refetch:d,isFetching:f}=at({queryKey:["systemInfo"],queryFn:ue.getSystemInfo,refetchInterval:3e4}),{data:p}=at({queryKey:["debugLogging"],queryFn:Mg.getDebugLoggingState,staleTime:10*1e3,refetchInterval:10*1e3}),{data:m}=at({queryKey:["settings"],queryFn:ue.getSettings}),{data:x}=at({queryKey:["library-stats"],queryFn:ue.getLibraryStats}),b=m?.time_format||"system",y=async()=>{l(!0);try{const T=await Mg.setDebugLogging(!p?.enabled);e.setQueryData(["debugLogging"],T)}catch(T){console.error("Failed to toggle debug logging:",T)}finally{l(!1)}},v=async()=>{r(null),a(!0);try{await Mg.downloadSupportBundle()}catch(T){r(T instanceof Error?T.message:"Failed to download support bundle")}finally{a(!1)}};if(u)return s.jsx("div",{className:"flex items-center justify-center h-64",children:s.jsx(ht,{className:"w-8 h-8 text-bambu-green animate-spin"})});if(!c)return s.jsx("div",{className:"p-6 text-center text-bambu-gray",children:t("system.failedToLoad","Failed to load system information")});const S=c.storage.disk_percent_used>90?"bg-red-500":c.storage.disk_percent_used>75?"bg-yellow-500":"bg-bambu-green",N=c.memory.percent_used>90?"bg-red-500":c.memory.percent_used>75?"bg-yellow-500":"bg-bambu-green";return s.jsxs("div",{className:"p-6 space-y-6",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold text-white",children:t("system.title","System Information")}),s.jsx("p",{className:"text-bambu-gray mt-1",children:t("system.subtitle","Monitor system resources and database statistics")})]}),s.jsxs("button",{onClick:()=>d(),disabled:f,className:"flex items-center gap-2 px-4 py-2 bg-bambu-dark-secondary hover:bg-bambu-dark-tertiary rounded-lg transition-colors disabled:opacity-50",children:[s.jsx(Dr,{className:`w-4 h-4 ${f?"animate-spin":""}`}),t("common.refresh","Refresh")]})]}),s.jsx(Fd,{title:t("system.application","Application"),icon:yf,children:s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[s.jsx(mi,{icon:yf,label:t("system.version","Version"),value:`v${c.app.version}`}),s.jsx(mi,{icon:er,label:t("system.uptime","System Uptime"),value:c.system.uptime_formatted}),s.jsx(mi,{icon:yf,label:t("system.hostname","Hostname"),value:c.system.hostname})]})}),s.jsx(Fd,{title:t("support.title","Support & Troubleshooting"),icon:nde,children:s.jsxs("div",{className:"space-y-4",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:t("support.description","Enable debug logging to capture detailed information, then download a support bundle to share when reporting issues.")}),s.jsxs("div",{className:"flex items-center justify-between p-4 bg-bambu-dark rounded-lg",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:`p-2 rounded-lg ${p?.enabled?"bg-amber-500/20 text-amber-500":"bg-bambu-dark-tertiary text-bambu-gray"}`,children:s.jsx(aN,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"font-medium text-white",children:t("support.debugLogging","Debug Logging")}),s.jsxs("p",{className:"text-sm text-bambu-gray",children:[p?.enabled?t("support.debugLoggingEnabled","Capturing detailed logs"):t("support.debugLoggingDisabled","Normal logging level"),p?.enabled&&p.duration_seconds!==null&&s.jsxs("span",{className:"text-amber-400 ml-2",children:["(",Math.floor(p.duration_seconds/60),"m ",p.duration_seconds%60,"s)"]})]})]})]}),s.jsxs("button",{onClick:y,disabled:o,className:`px-4 py-2 rounded-lg font-medium transition-colors flex items-center gap-2 ${p?.enabled?"bg-amber-500/20 text-amber-400 hover:bg-amber-500/30":"bg-bambu-green/20 text-bambu-green hover:bg-bambu-green/30"} disabled:opacity-50`,children:[o&&s.jsx(ht,{className:"w-4 h-4 animate-spin"}),p?.enabled?t("support.disableDebug","Disable"):t("support.enableDebug","Enable")]})]}),s.jsxs("div",{className:"flex items-center justify-between p-4 bg-bambu-dark rounded-lg",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark-tertiary text-bambu-green",children:s.jsx(yi,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"font-medium text-white",children:t("support.supportBundle","Support Bundle")}),s.jsx("p",{className:"text-sm text-bambu-gray",children:t("support.supportBundleDescription","Download system info and logs as a ZIP file")})]})]}),s.jsxs("button",{onClick:v,disabled:i||!p?.enabled,className:"px-4 py-2 rounded-lg font-medium bg-bambu-green/20 text-bambu-green hover:bg-bambu-green/30 transition-colors flex items-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed",title:p?.enabled?void 0:t("support.enableDebugFirst","Enable debug logging first"),children:[i&&s.jsx(ht,{className:"w-4 h-4 animate-spin"}),t("common.download","Download")]})]}),n&&s.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/30 rounded-lg text-red-400 text-sm",children:n}),!p?.enabled&&s.jsx("div",{className:"p-4 bg-bambu-dark-tertiary/50 rounded-lg",children:s.jsxs("p",{className:"text-sm text-bambu-gray",children:[s.jsx("span",{className:"text-amber-400 font-medium",children:t("support.instructions","To report an issue:")}),s.jsx("br",{}),"1. ",t("support.step1","Enable debug logging"),s.jsx("br",{}),"2. ",t("support.step2","Reproduce the issue"),s.jsx("br",{}),"3. ",t("support.step3","Download the support bundle"),s.jsx("br",{}),"4. ",t("support.step4","Attach the ZIP file to your issue report")]})}),s.jsxs("div",{className:"p-4 bg-bambu-dark rounded-lg space-y-3",children:[s.jsx("p",{className:"text-sm font-medium text-white",children:t("support.privacyTitle","What's in the support bundle?")}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 text-sm",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-bambu-green font-medium mb-1",children:t("support.collected","Collected:")}),s.jsxs("ul",{className:"text-bambu-gray space-y-0.5",children:[s.jsxs("li",{children:["• ",t("support.collectItem1","App version and debug mode")]}),s.jsxs("li",{children:["• ",t("support.collectItem2","OS, architecture, Python version")]}),s.jsxs("li",{children:["• ",t("support.collectItem3","Database statistics (counts only)")]}),s.jsxs("li",{children:["• ",t("support.collectItem4","Printer models and nozzle counts")]}),s.jsxs("li",{children:["• ",t("support.collectItem5","Non-sensitive settings (themes, formats)")]}),s.jsxs("li",{children:["• ",t("support.collectItem6","Debug logs (sanitized)")]})]})]}),s.jsxs("div",{children:[s.jsx("p",{className:"text-red-400 font-medium mb-1",children:t("support.notCollected","NOT collected:")}),s.jsxs("ul",{className:"text-bambu-gray space-y-0.5",children:[s.jsxs("li",{children:["• ",t("support.notItem1","Printer names, IPs, serial numbers")]}),s.jsxs("li",{children:["• ",t("support.notItem2","Access codes and passwords")]}),s.jsxs("li",{children:["• ",t("support.notItem3","Email addresses")]}),s.jsxs("li",{children:["• ",t("support.notItem4","API keys and tokens")]}),s.jsxs("li",{children:["• ",t("support.notItem5","Webhook URLs")]}),s.jsxs("li",{children:["• ",t("support.notItem6","Your hostname or username")]})]})]})]}),s.jsx("p",{className:"text-xs text-bambu-gray/70",children:t("support.privacyNote","IP addresses in logs are replaced with [IP] and email addresses with [EMAIL].")})]}),s.jsx(bXe,{})]})}),s.jsxs(Fd,{title:t("system.database","Database"),icon:Nu,children:[s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mb-4",children:[s.jsx(mi,{icon:fo,label:t("system.totalArchives","Total Archives"),value:c.database.archives}),s.jsx(mi,{icon:sN,label:t("system.completed","Completed"),value:c.database.archives_completed,color:"text-green-500"}),s.jsx(mi,{icon:Yi,label:t("system.failed","Failed"),value:c.database.archives_failed,color:"text-red-500"}),s.jsx(mi,{icon:ht,label:t("system.printing","Printing"),value:c.database.archives_printing,color:"text-yellow-500"})]}),s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[s.jsx(mi,{icon:Ur,label:t("system.printers","Printers"),value:c.database.printers}),s.jsx(mi,{icon:SW,label:t("system.filaments","Filaments"),value:c.database.filaments}),s.jsx(mi,{icon:Ja,label:t("system.projects","Projects"),value:c.database.projects}),s.jsx(mi,{icon:tl,label:t("system.smartPlugs","Smart Plugs"),value:c.database.smart_plugs})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mt-4",children:[s.jsx(mi,{icon:er,label:t("system.totalPrintTime","Total Print Time"),value:c.database.total_print_time_formatted}),s.jsx(mi,{icon:fo,label:t("system.totalFilament","Total Filament Used"),value:`${c.database.total_filament_kg} kg`,subValue:`${c.database.total_filament_grams.toLocaleString()} g`})]})]}),s.jsxs(Fd,{title:t("system.connectedPrinters","Connected Printers"),icon:Ur,children:[s.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[s.jsx("div",{className:"text-3xl font-bold text-bambu-green",children:c.printers.connected}),s.jsx("div",{className:"text-bambu-gray",children:t("system.ofTotal","of {{total}} printers connected",{total:c.printers.total})})]}),c.printers.connected_list.length>0?s.jsx("div",{className:"space-y-2",children:c.printers.connected_list.map(T=>s.jsxs("div",{className:"flex items-center justify-between p-3 bg-bambu-dark rounded-lg",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-2 h-2 rounded-full bg-bambu-green"}),s.jsx("span",{className:"font-medium text-white",children:T.name})]}),s.jsxs("div",{className:"flex items-center gap-4 text-sm text-bambu-gray",children:[s.jsx("span",{children:T.model}),s.jsx("span",{className:`px-2 py-0.5 rounded ${T.state==="RUNNING"?"bg-bambu-green/20 text-bambu-green":T.state==="IDLE"?"bg-blue-500/20 text-blue-400":"bg-bambu-dark-tertiary"}`,children:T.state})]})]},T.id))}):s.jsx("p",{className:"text-bambu-gray",children:t("system.noPrintersConnected","No printers connected")})]}),s.jsx(Fd,{title:t("system.storage","Storage"),icon:hN,children:s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[s.jsx("span",{className:"text-bambu-gray",children:t("system.diskUsage","Disk Usage")}),s.jsxs("span",{className:"text-white",children:[c.storage.disk_used_formatted," / ",c.storage.disk_total_formatted]})]}),s.jsx(bq,{percent:c.storage.disk_percent_used,color:S}),s.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:[c.storage.disk_free_formatted," ",t("system.free","free")," (",(100-c.storage.disk_percent_used).toFixed(1),"%)"]})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[s.jsx(mi,{icon:fo,label:t("system.archiveStorage","Archive Storage"),value:c.storage.archive_size_formatted}),s.jsx(mi,{icon:Nu,label:t("system.databaseSize","Database Size"),value:c.storage.database_size_formatted}),x&&s.jsx(mi,{icon:Il,label:t("system.fileManagerStorage","File Manager"),value:yXe(x.total_size_bytes),subValue:`${x.total_files} files, ${x.total_folders} folders`})]})]})}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[s.jsx(Fd,{title:t("system.memory","Memory"),icon:Ode,children:s.jsx("div",{className:"space-y-4",children:s.jsxs("div",{children:[s.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[s.jsx("span",{className:"text-bambu-gray",children:t("system.memoryUsage","Memory Usage")}),s.jsxs("span",{className:"text-white",children:[c.memory.used_formatted," / ",c.memory.total_formatted]})]}),s.jsx(bq,{percent:c.memory.percent_used,color:N}),s.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:[c.memory.available_formatted," ",t("system.available","available")]})]})})}),s.jsx(Fd,{title:t("system.cpu","CPU"),icon:Dw,children:s.jsx("div",{className:"space-y-4",children:s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsx(mi,{icon:Dw,label:t("system.cores","Cores"),value:c.cpu.count,subValue:`${c.cpu.count_logical} logical`}),s.jsx(mi,{icon:Dw,label:t("system.usage","Usage"),value:`${c.cpu.percent}%`})]})})})]}),s.jsx(Fd,{title:t("system.systemDetails","System Details"),icon:yf,children:s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[s.jsx(mi,{icon:yf,label:t("system.os","Operating System"),value:c.system.platform,subValue:c.system.platform_release}),s.jsx(mi,{icon:Dw,label:t("system.architecture","Architecture"),value:c.system.architecture}),s.jsx(mi,{icon:yf,label:t("system.python","Python"),value:c.system.python_version}),s.jsx(mi,{icon:er,label:t("system.bootTime","Boot Time"),value:Hg(c.system.boot_time,b)})]})})]})}function wXe(){const t=Nc(),{t:e}=Hn(),{login:n}=Ai(),{showToast:r}=$n(),{mode:i}=Oh(),[a,o]=_.useState(""),[l,c]=_.useState(""),[u,d]=_.useState(!1),f=mt({mutationFn:()=>n(a,l),onSuccess:()=>{r(e("login.loginSuccess")),t("/")},onError:m=>{r(m.message||e("login.loginFailed"),"error")}}),p=m=>{if(m.preventDefault(),!a||!l){r(e("login.enterCredentials"),"error");return}f.mutate()};return s.jsxs("div",{className:"min-h-screen flex items-center justify-center bg-bambu-dark p-4",children:[s.jsxs("div",{className:"max-w-md w-full space-y-8 p-8 bg-gradient-to-br from-bambu-card to-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary shadow-lg",children:[s.jsxs("div",{className:"text-center",children:[s.jsx("div",{className:"flex items-center justify-center mb-6",children:s.jsx("img",{src:i==="dark"?"/img/bambuddy_logo_dark_transparent.png":"/img/bambuddy_logo_light.png",alt:"Bambuddy",className:"h-16"})}),s.jsx("h2",{className:"text-3xl font-bold text-white",children:e("login.title")}),s.jsx("p",{className:"mt-2 text-sm text-bambu-gray",children:e("login.subtitle")})]}),s.jsxs("form",{className:"mt-8 space-y-6",onSubmit:p,children:[s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{htmlFor:"username",className:"block text-sm font-medium text-white mb-2",children:e("login.username")}),s.jsx("input",{id:"username",type:"text",required:!0,value:a,onChange:m=>o(m.target.value),className:"block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:e("login.usernamePlaceholder"),autoComplete:"username"})]}),s.jsxs("div",{children:[s.jsx("label",{htmlFor:"password",className:"block text-sm font-medium text-white mb-2",children:e("login.password")}),s.jsx("input",{id:"password",type:"password",required:!0,value:l,onChange:m=>c(m.target.value),className:"block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:e("login.passwordPlaceholder"),autoComplete:"current-password"})]})]}),s.jsx("div",{children:s.jsx("button",{type:"submit",disabled:f.isPending,className:"w-full flex justify-center py-3 px-4 bg-bambu-green hover:bg-bambu-green-light text-white font-medium rounded-lg shadow-lg shadow-bambu-green/20 hover:shadow-bambu-green/30 focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:ring-offset-2 focus:ring-offset-bambu-dark-secondary transition-all disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-bambu-green",children:f.isPending?e("login.signingIn"):e("login.signIn")})}),s.jsx("div",{className:"text-center",children:s.jsx("button",{type:"button",onClick:()=>d(!0),className:"text-sm text-bambu-gray hover:text-bambu-green transition-colors",children:e("login.forgotPassword")})})]})]}),u&&s.jsx("div",{className:"fixed inset-0 bg-black flex items-center justify-center z-50 p-4",onClick:()=>d(!1),children:s.jsxs("div",{className:"w-full max-w-md bg-bambu-card rounded-xl border border-bambu-dark-tertiary shadow-lg p-6",onClick:m=>m.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Wce,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:e("login.forgotPasswordTitle")})]}),s.jsx("button",{onClick:()=>d(!1),className:"p-1 rounded-lg hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white transition-colors",children:s.jsx(Rt,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsx("p",{className:"text-bambu-gray",children:e("login.forgotPasswordMessage")}),s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4 space-y-2",children:[s.jsx("p",{className:"text-sm text-white font-medium",children:e("login.howToReset")}),s.jsxs("ol",{className:"text-sm text-bambu-gray space-y-1 list-decimal list-inside",children:[s.jsx("li",{children:e("login.resetStep1")}),s.jsx("li",{children:e("login.resetStep2")}),s.jsx("li",{children:e("login.resetStep3")}),s.jsx("li",{children:e("login.resetStep4")})]})]}),s.jsx("button",{onClick:()=>d(!1),className:"w-full py-2 px-4 bg-bambu-dark-tertiary hover:bg-bambu-dark text-white rounded-lg transition-colors",children:e("login.gotIt")})]})]})})]})}function _Xe(){const t=Nc(),{t:e}=Hn(),{showToast:n}=$n(),{mode:r}=Oh(),{refreshAuth:i}=Ai(),[a,o]=_.useState(!1),[l,c]=_.useState(""),[u,d]=_.useState(""),[f,p]=_.useState(""),m=mt({mutationFn:()=>ue.setupAuth({auth_enabled:a,admin_username:a?l:void 0,admin_password:a?u:void 0}),onSuccess:async b=>{await i(),b.auth_enabled?b.admin_created?(n(e("setup.toast.authEnabledAdminCreated")),t("/login")):(n(e("setup.toast.authEnabledExistingAdmins")),t("/login")):(n(e("setup.toast.setupCompleted")),t("/"))},onError:b=>{n(b.message,"error")}}),x=b=>{if(b.preventDefault(),a&&(l||u)){if(!l||!u){n(e("setup.toast.enterBothCredentials"),"error");return}if(u!==f){n(e("setup.toast.passwordsDoNotMatch"),"error");return}if(u.length<6){n(e("setup.toast.passwordTooShort"),"error");return}}m.mutate()};return s.jsx("div",{className:"min-h-screen flex items-center justify-center bg-bambu-dark p-4",children:s.jsxs("div",{className:"max-w-md w-full space-y-8 p-8 bg-gradient-to-br from-bambu-card to-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary shadow-lg",children:[s.jsxs("div",{className:"text-center",children:[s.jsx("div",{className:"flex items-center justify-center mb-6",children:s.jsx("img",{src:r==="dark"?"/img/bambuddy_logo_dark_transparent.png":"/img/bambuddy_logo_light.png",alt:"Bambuddy",className:"h-16"})}),s.jsx("h2",{className:"text-3xl font-bold text-white",children:e("setup.title")}),s.jsx("p",{className:"mt-2 text-sm text-bambu-gray",children:e("setup.subtitle")})]}),s.jsxs("form",{className:"mt-8 space-y-6",onSubmit:x,children:[s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center p-4 bg-bambu-dark-secondary/50 rounded-lg border border-bambu-dark-tertiary",children:[s.jsx("input",{id:"auth-enabled",type:"checkbox",checked:a,onChange:b=>o(b.target.checked),className:"h-4 w-4 text-bambu-green focus:ring-bambu-green border-bambu-dark-tertiary rounded bg-bambu-dark-secondary"}),s.jsx("label",{htmlFor:"auth-enabled",className:"ml-3 block text-sm font-medium text-white",children:e("setup.enableAuth")})]}),a&&s.jsxs("div",{className:"space-y-4 mt-4",children:[s.jsx("div",{className:"p-3 bg-bambu-dark-secondary/50 border border-bambu-dark-tertiary rounded-lg",children:s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx(Zo,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),s.jsxs("div",{className:"text-sm text-bambu-gray",children:[s.jsx("p",{className:"text-white font-medium mb-1",children:e("setup.adminAccount")}),s.jsx("p",{children:e("setup.adminAccountDesc")})]})]})}),s.jsxs("div",{children:[s.jsxs("label",{htmlFor:"admin-username",className:"block text-sm font-medium text-white mb-2",children:[e("setup.adminUsername")," ",s.jsx("span",{className:"text-bambu-gray text-xs",children:e("setup.optionalIfAdminExists")})]}),s.jsx("input",{id:"admin-username",type:"text",value:l,onChange:b=>c(b.target.value),className:"block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:e("setup.adminUsernamePlaceholder"),autoComplete:"username"})]}),s.jsxs("div",{children:[s.jsxs("label",{htmlFor:"admin-password",className:"block text-sm font-medium text-white mb-2",children:[e("setup.adminPassword")," ",s.jsx("span",{className:"text-bambu-gray text-xs",children:e("setup.optionalIfAdminExists")})]}),s.jsx("input",{id:"admin-password",type:"password",value:u,onChange:b=>d(b.target.value),className:"block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:e("setup.adminPasswordPlaceholder"),minLength:6,autoComplete:"new-password"})]}),u&&s.jsxs("div",{children:[s.jsx("label",{htmlFor:"confirm-password",className:"block text-sm font-medium text-white mb-2",children:e("setup.confirmPassword")}),s.jsx("input",{id:"confirm-password",type:"password",value:f,onChange:b=>p(b.target.value),className:"block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:e("setup.confirmPasswordPlaceholder"),minLength:6,autoComplete:"new-password"})]})]})]}),s.jsx("div",{children:s.jsx("button",{type:"submit",disabled:m.isPending,className:"w-full flex justify-center py-3 px-4 bg-bambu-green hover:bg-bambu-green-light text-white font-medium rounded-lg shadow-lg shadow-bambu-green/20 hover:shadow-bambu-green/30 focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:ring-offset-2 focus:ring-offset-bambu-dark-secondary transition-all disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-bambu-green",children:m.isPending?e("setup.settingUp"):e("setup.completeSetup")})})]})]})})}function SXe(){const t=_.useRef(null),e=_.useRef(null),n=an(),[r,i]=_.useState(!1),a=_.useRef(new Set),o=_.useRef(null),l=_.useRef(new Map),c=_.useRef(null),u=_.useRef([]),d=_.useRef(!1),f=_.useRef(()=>{}),p=_.useCallback(()=>{if(d.current||u.current.length===0)return;d.current=!0;const S=()=>{const N=u.current.shift();N?requestAnimationFrame(()=>{f.current(N),u.current.length>0?setTimeout(S,16):d.current=!1}):d.current=!1};S()},[]),m=_.useCallback(()=>{if(t.current?.readyState===WebSocket.OPEN)return;const N=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/api/v1/ws`,T=new WebSocket(N);let k=null;T.onopen=()=>{console.log("[WebSocket] Connected"),i(!0),k=window.setInterval(()=>{T.readyState===WebSocket.OPEN&&T.send(JSON.stringify({type:"ping"}))},3e4)},T.onmessage=C=>{try{const E=JSON.parse(C.data);E.type==="printer_status"&&E.printer_id!==void 0&&E.data?f.current(E):(u.current.push(E),p())}catch{}},T.onclose=C=>{console.log("[WebSocket] Closed",C.code,C.reason),k&&(clearInterval(k),k=null),i(!1),t.current=null,e.current=window.setTimeout(()=>{m()},3e3)},T.onerror=C=>{console.error("[WebSocket] Error",C),T.close()},t.current=T},[p]),x=_.useCallback((S,N)=>{const T=l.current.get(S)||{};l.current.set(S,{...T,...N}),c.current||(c.current=window.setTimeout(()=>{const k=new Map(l.current);l.current.clear(),c.current=null,requestAnimationFrame(()=>{k.forEach((C,E)=>{n.setQueryData(["printerStatus",E],D=>{const A={...D,...C};return A.wifi_signal==null&&D?.wifi_signal!=null&&(A.wifi_signal=D.wifi_signal),A})})})},100))},[n]),b=_.useCallback(S=>{a.current.add(S),o.current&&clearTimeout(o.current),o.current=window.setTimeout(()=>{const N=Array.from(a.current);a.current.clear(),o.current=null;let T=0;N.forEach(k=>{setTimeout(()=>{requestAnimationFrame(()=>{n.invalidateQueries({queryKey:[k]})})},T),T+=500})},3e3)},[n]),y=_.useCallback(S=>{switch(S.type){case"printer_status":S.printer_id!==void 0&&S.data&&x(S.printer_id,S.data);break;case"print_start":S.printer_id!==void 0&&n.invalidateQueries({queryKey:["printerStatus",S.printer_id]});break;case"print_complete":b("archives"),b("archiveStats");break;case"archive_created":b("archives"),b("archiveStats");break;case"archive_updated":b("archives");break;case"pong":break;case"plate_not_empty":window.dispatchEvent(new CustomEvent("plate-not-empty",{detail:{printer_id:S.printer_id,printer_name:S.printer_name,message:S.message}}));break}},[n,b,x]);_.useEffect(()=>{f.current=y},[y]),_.useEffect(()=>(m(),()=>{e.current&&clearTimeout(e.current),o.current&&clearTimeout(o.current),c.current&&clearTimeout(c.current),t.current&&t.current.close()}),[m]);const v=_.useCallback(S=>{t.current?.readyState===WebSocket.OPEN&&t.current.send(JSON.stringify(S))},[]);return{isConnected:r,sendMessage:v}}const MXe=new qle({defaultOptions:{queries:{staleTime:1e3*60,retry:1}}});function NXe({children:t}){return SXe(),s.jsx(s.Fragment,{children:t})}function kXe({children:t}){const{authEnabled:e,loading:n,user:r}=Ai();return n?s.jsx("div",{className:"min-h-screen flex items-center justify-center",children:"Loading..."}):e&&!r?s.jsx(Fg,{to:"/login",replace:!0}):s.jsx(s.Fragment,{children:t})}function EXe({children:t}){const{authEnabled:e,loading:n,user:r,isAdmin:i}=Ai();return n?s.jsx("div",{className:"min-h-screen flex items-center justify-center",children:"Loading..."}):e?r?i?s.jsx(s.Fragment,{children:t}):s.jsx(Fg,{to:"/",replace:!0}):s.jsx(Fg,{to:"/login",replace:!0}):s.jsx(s.Fragment,{children:t})}function TXe({children:t}){const{authEnabled:e,loading:n}=Ai();return n?s.jsx("div",{className:"min-h-screen flex items-center justify-center",children:"Loading..."}):e?s.jsx(Fg,{to:"/login",replace:!0}):s.jsx(s.Fragment,{children:t})}function AXe(){return s.jsx(vfe,{children:s.jsx(Tfe,{children:s.jsx(Wle,{client:MXe,children:s.jsx(Nfe,{children:s.jsx(fle,{children:s.jsxs(Hoe,{children:[s.jsx(Li,{path:"/setup",element:s.jsx(TXe,{children:s.jsx(_Xe,{})})}),s.jsx(Li,{path:"/login",element:s.jsx(wXe,{})}),s.jsx(Li,{path:"/camera/:printerId",element:s.jsx(cXe,{})}),s.jsx(Li,{path:"/overlay/:printerId",element:s.jsx(pXe,{})}),s.jsxs(Li,{element:s.jsx(kXe,{children:s.jsx(NXe,{children:s.jsx(Pfe,{})})}),children:[s.jsx(Li,{index:!0,element:s.jsx(mje,{})}),s.jsx(Li,{path:"archives",element:s.jsx(rqe,{})}),s.jsx(Li,{path:"queue",element:s.jsx(HWe,{})}),s.jsx(Li,{path:"stats",element:s.jsx(nKe,{})}),s.jsx(Li,{path:"profiles",element:s.jsx(FKe,{})}),s.jsx(Li,{path:"maintenance",element:s.jsx(HKe,{})}),s.jsx(Li,{path:"projects",element:s.jsx(VKe,{})}),s.jsx(Li,{path:"projects/:id",element:s.jsx(QKe,{})}),s.jsx(Li,{path:"files",element:s.jsx(aXe,{})}),s.jsx(Li,{path:"settings",element:s.jsx(EXe,{children:s.jsx(kKe,{})})}),s.jsx(Li,{path:"users",element:s.jsx(Fg,{to:"/settings?tab=users",replace:!0})}),s.jsx(Li,{path:"groups",element:s.jsx(Fg,{to:"/settings?tab=users",replace:!0})}),s.jsx(Li,{path:"system",element:s.jsx(vXe,{})}),s.jsx(Li,{path:"external/:id",element:s.jsx(gXe,{})})]})]})})})})})})}Uae.createRoot(document.getElementById("root")).render(s.jsx(_.StrictMode,{children:s.jsx(AXe,{})}));
|