index-CeGzUNH5.js 3.3 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665
  1. function kae(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 Jv=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Fo(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var _T={exports:{}},Kx={};var _U;function jae(){if(_U)return Kx;_U=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 Kx.Fragment=e,Kx.jsx=n,Kx.jsxs=n,Kx}var wU;function Pae(){return wU||(wU=1,_T.exports=jae()),_T.exports}var s=Pae(),wT={exports:{}},gn={};var SU;function Rae(){if(SU)return gn;SU=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),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"),m=Symbol.iterator;function p(z){return z===null||typeof z!="object"?null:(z=m&&z[m]||z["@@iterator"],typeof z=="function"?z:null)}var x={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},y=Object.assign,b={};function v(z,G,ae){this.props=z,this.context=G,this.refs=b,this.updater=ae||x}v.prototype.isReactComponent={},v.prototype.setState=function(z,G){if(typeof z!="object"&&typeof z!="function"&&z!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,z,G,"setState")},v.prototype.forceUpdate=function(z){this.updater.enqueueForceUpdate(this,z,"forceUpdate")};function N(){}N.prototype=v.prototype;function S(z,G,ae){this.props=z,this.context=G,this.refs=b,this.updater=ae||x}var T=S.prototype=new N;T.constructor=S,y(T,v.prototype),T.isPureReactComponent=!0;var E=Array.isArray;function C(){}var A={H:null,A:null,T:null,S:null},O=Object.prototype.hasOwnProperty;function k(z,G,ae){var se=ae.ref;return{$$typeof:t,type:z,key:G,ref:se!==void 0?se:null,props:ae}}function R(z,G){return k(z.type,G,z.props)}function F(z){return typeof z=="object"&&z!==null&&z.$$typeof===t}function L(z){var G={"=":"=0",":":"=2"};return"$"+z.replace(/[=:]/g,function(ae){return G[ae]})}var K=/\/+/g;function j(z,G){return typeof z=="object"&&z!==null&&z.key!=null?L(""+z.key):G.toString(36)}function W(z){switch(z.status){case"fulfilled":return z.value;case"rejected":throw z.reason;default:switch(typeof z.status=="string"?z.then(C,C):(z.status="pending",z.then(function(G){z.status==="pending"&&(z.status="fulfilled",z.value=G)},function(G){z.status==="pending"&&(z.status="rejected",z.reason=G)})),z.status){case"fulfilled":return z.value;case"rejected":throw z.reason}}throw z}function Y(z,G,ae,se,ue){var pe=typeof z;(pe==="undefined"||pe==="boolean")&&(z=null);var ce=!1;if(z===null)ce=!0;else switch(pe){case"bigint":case"string":case"number":ce=!0;break;case"object":switch(z.$$typeof){case t:case e:ce=!0;break;case d:return ce=z._init,Y(ce(z._payload),G,ae,se,ue)}}if(ce)return ue=ue(z),ce=se===""?"."+j(z,0):se,E(ue)?(ae="",ce!=null&&(ae=ce.replace(K,"$&/")+"/"),Y(ue,G,ae,"",function(Ee){return Ee})):ue!=null&&(F(ue)&&(ue=R(ue,ae+(ue.key==null||z&&z.key===ue.key?"":(""+ue.key).replace(K,"$&/")+"/")+ce)),G.push(ue)),1;ce=0;var Me=se===""?".":se+":";if(E(z))for(var me=0;me<z.length;me++)se=z[me],pe=Me+j(se,me),ce+=Y(se,G,ae,pe,ue);else if(me=p(z),typeof me=="function")for(z=me.call(z),me=0;!(se=z.next()).done;)se=se.value,pe=Me+j(se,me++),ce+=Y(se,G,ae,pe,ue);else if(pe==="object"){if(typeof z.then=="function")return Y(W(z),G,ae,se,ue);throw G=String(z),Error("Objects are not valid as a React child (found: "+(G==="[object Object]"?"object with keys {"+Object.keys(z).join(", ")+"}":G)+"). If you meant to render a collection of children, use an array instead.")}return ce}function q(z,G,ae){if(z==null)return z;var se=[],ue=0;return Y(z,se,"","",function(pe){return G.call(ae,pe,ue++)}),se}function Q(z){if(z._status===-1){var G=z._result;G=G(),G.then(function(ae){(z._status===0||z._status===-1)&&(z._status=1,z._result=ae)},function(ae){(z._status===0||z._status===-1)&&(z._status=2,z._result=ae)}),z._status===-1&&(z._status=0,z._result=G)}if(z._status===1)return z._result.default;throw z._result}var ee=typeof reportError=="function"?reportError:function(z){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var G=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof z=="object"&&z!==null&&typeof z.message=="string"?String(z.message):String(z),error:z});if(!window.dispatchEvent(G))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",z);return}console.error(z)},re={map:q,forEach:function(z,G,ae){q(z,function(){G.apply(this,arguments)},ae)},count:function(z){var G=0;return q(z,function(){G++}),G},toArray:function(z){return q(z,function(G){return G})||[]},only:function(z){if(!F(z))throw Error("React.Children.only expected to receive a single React element child.");return z}};return gn.Activity=f,gn.Children=re,gn.Component=v,gn.Fragment=n,gn.Profiler=i,gn.PureComponent=S,gn.StrictMode=r,gn.Suspense=c,gn.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=A,gn.__COMPILER_RUNTIME={__proto__:null,c:function(z){return A.H.useMemoCache(z)}},gn.cache=function(z){return function(){return z.apply(null,arguments)}},gn.cacheSignal=function(){return null},gn.cloneElement=function(z,G,ae){if(z==null)throw Error("The argument must be a React element, but you passed "+z+".");var se=y({},z.props),ue=z.key;if(G!=null)for(pe in G.key!==void 0&&(ue=""+G.key),G)!O.call(G,pe)||pe==="key"||pe==="__self"||pe==="__source"||pe==="ref"&&G.ref===void 0||(se[pe]=G[pe]);var pe=arguments.length-2;if(pe===1)se.children=ae;else if(1<pe){for(var ce=Array(pe),Me=0;Me<pe;Me++)ce[Me]=arguments[Me+2];se.children=ce}return k(z.type,ue,se)},gn.createContext=function(z){return z={$$typeof:o,_currentValue:z,_currentValue2:z,_threadCount:0,Provider:null,Consumer:null},z.Provider=z,z.Consumer={$$typeof:a,_context:z},z},gn.createElement=function(z,G,ae){var se,ue={},pe=null;if(G!=null)for(se in G.key!==void 0&&(pe=""+G.key),G)O.call(G,se)&&se!=="key"&&se!=="__self"&&se!=="__source"&&(ue[se]=G[se]);var ce=arguments.length-2;if(ce===1)ue.children=ae;else if(1<ce){for(var Me=Array(ce),me=0;me<ce;me++)Me[me]=arguments[me+2];ue.children=Me}if(z&&z.defaultProps)for(se in ce=z.defaultProps,ce)ue[se]===void 0&&(ue[se]=ce[se]);return k(z,pe,ue)},gn.createRef=function(){return{current:null}},gn.forwardRef=function(z){return{$$typeof:l,render:z}},gn.isValidElement=F,gn.lazy=function(z){return{$$typeof:d,_payload:{_status:-1,_result:z},_init:Q}},gn.memo=function(z,G){return{$$typeof:u,type:z,compare:G===void 0?null:G}},gn.startTransition=function(z){var G=A.T,ae={};A.T=ae;try{var se=z(),ue=A.S;ue!==null&&ue(ae,se),typeof se=="object"&&se!==null&&typeof se.then=="function"&&se.then(C,ee)}catch(pe){ee(pe)}finally{G!==null&&ae.types!==null&&(G.types=ae.types),A.T=G}},gn.unstable_useCacheRefresh=function(){return A.H.useCacheRefresh()},gn.use=function(z){return A.H.use(z)},gn.useActionState=function(z,G,ae){return A.H.useActionState(z,G,ae)},gn.useCallback=function(z,G){return A.H.useCallback(z,G)},gn.useContext=function(z){return A.H.useContext(z)},gn.useDebugValue=function(){},gn.useDeferredValue=function(z,G){return A.H.useDeferredValue(z,G)},gn.useEffect=function(z,G){return A.H.useEffect(z,G)},gn.useEffectEvent=function(z){return A.H.useEffectEvent(z)},gn.useId=function(){return A.H.useId()},gn.useImperativeHandle=function(z,G,ae){return A.H.useImperativeHandle(z,G,ae)},gn.useInsertionEffect=function(z,G){return A.H.useInsertionEffect(z,G)},gn.useLayoutEffect=function(z,G){return A.H.useLayoutEffect(z,G)},gn.useMemo=function(z,G){return A.H.useMemo(z,G)},gn.useOptimistic=function(z,G){return A.H.useOptimistic(z,G)},gn.useReducer=function(z,G,ae){return A.H.useReducer(z,G,ae)},gn.useRef=function(z){return A.H.useRef(z)},gn.useState=function(z){return A.H.useState(z)},gn.useSyncExternalStore=function(z,G,ae){return A.H.useSyncExternalStore(z,G,ae)},gn.useTransition=function(){return A.H.useTransition()},gn.version="19.2.0",gn}var NU;function Dg(){return NU||(NU=1,wT.exports=Rae()),wT.exports}var w=Dg();const Fr=Fo(w),Dae=kae({__proto__:null,default:Fr},[w]);var ST={exports:{}},Xx={},NT={exports:{}},MT={};var MU;function Oae(){return MU||(MU=1,(function(t){function e(Y,q){var Q=Y.length;Y.push(q);e:for(;0<Q;){var ee=Q-1>>>1,re=Y[ee];if(0<i(re,q))Y[ee]=q,Y[Q]=re,Q=ee;else break e}}function n(Y){return Y.length===0?null:Y[0]}function r(Y){if(Y.length===0)return null;var q=Y[0],Q=Y.pop();if(Q!==q){Y[0]=Q;e:for(var ee=0,re=Y.length,z=re>>>1;ee<z;){var G=2*(ee+1)-1,ae=Y[G],se=G+1,ue=Y[se];if(0>i(ae,Q))se<re&&0>i(ue,ae)?(Y[ee]=ue,Y[se]=Q,ee=se):(Y[ee]=ae,Y[G]=Q,ee=G);else if(se<re&&0>i(ue,Q))Y[ee]=ue,Y[se]=Q,ee=se;else break e}}return q}function i(Y,q){var Q=Y.sortIndex-q.sortIndex;return Q!==0?Q:Y.id-q.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,m=3,p=!1,x=!1,y=!1,b=!1,v=typeof setTimeout=="function"?setTimeout:null,N=typeof clearTimeout=="function"?clearTimeout:null,S=typeof setImmediate<"u"?setImmediate:null;function T(Y){for(var q=n(u);q!==null;){if(q.callback===null)r(u);else if(q.startTime<=Y)r(u),q.sortIndex=q.expirationTime,e(c,q);else break;q=n(u)}}function E(Y){if(y=!1,T(Y),!x)if(n(c)!==null)x=!0,C||(C=!0,L());else{var q=n(u);q!==null&&W(E,q.startTime-Y)}}var C=!1,A=-1,O=5,k=-1;function R(){return b?!0:!(t.unstable_now()-k<O)}function F(){if(b=!1,C){var Y=t.unstable_now();k=Y;var q=!0;try{e:{x=!1,y&&(y=!1,N(A),A=-1),p=!0;var Q=m;try{t:{for(T(Y),f=n(c);f!==null&&!(f.expirationTime>Y&&R());){var ee=f.callback;if(typeof ee=="function"){f.callback=null,m=f.priorityLevel;var re=ee(f.expirationTime<=Y);if(Y=t.unstable_now(),typeof re=="function"){f.callback=re,T(Y),q=!0;break t}f===n(c)&&r(c),T(Y)}else r(c);f=n(c)}if(f!==null)q=!0;else{var z=n(u);z!==null&&W(E,z.startTime-Y),q=!1}}break e}finally{f=null,m=Q,p=!1}q=void 0}}finally{q?L():C=!1}}}var L;if(typeof S=="function")L=function(){S(F)};else if(typeof MessageChannel<"u"){var K=new MessageChannel,j=K.port2;K.port1.onmessage=F,L=function(){j.postMessage(null)}}else L=function(){v(F,0)};function W(Y,q){A=v(function(){Y(t.unstable_now())},q)}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(Y){Y.callback=null},t.unstable_forceFrameRate=function(Y){0>Y||125<Y?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):O=0<Y?Math.floor(1e3/Y):5},t.unstable_getCurrentPriorityLevel=function(){return m},t.unstable_next=function(Y){switch(m){case 1:case 2:case 3:var q=3;break;default:q=m}var Q=m;m=q;try{return Y()}finally{m=Q}},t.unstable_requestPaint=function(){b=!0},t.unstable_runWithPriority=function(Y,q){switch(Y){case 1:case 2:case 3:case 4:case 5:break;default:Y=3}var Q=m;m=Y;try{return q()}finally{m=Q}},t.unstable_scheduleCallback=function(Y,q,Q){var ee=t.unstable_now();switch(typeof Q=="object"&&Q!==null?(Q=Q.delay,Q=typeof Q=="number"&&0<Q?ee+Q:ee):Q=ee,Y){case 1:var re=-1;break;case 2:re=250;break;case 5:re=1073741823;break;case 4:re=1e4;break;default:re=5e3}return re=Q+re,Y={id:d++,callback:q,priorityLevel:Y,startTime:Q,expirationTime:re,sortIndex:-1},Q>ee?(Y.sortIndex=Q,e(u,Y),n(c)===null&&Y===n(u)&&(y?(N(A),A=-1):y=!0,W(E,Q-ee))):(Y.sortIndex=re,e(c,Y),x||p||(x=!0,C||(C=!0,L()))),Y},t.unstable_shouldYield=R,t.unstable_wrapCallback=function(Y){var q=m;return function(){var Q=m;m=q;try{return Y.apply(this,arguments)}finally{m=Q}}}})(MT)),MT}var EU;function Lae(){return EU||(EU=1,NT.exports=Oae()),NT.exports}var ET={exports:{}},Na={};var TU;function Iae(){if(TU)return Na;TU=1;var t=Dg();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 Na.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,Na.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)},Na.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()}},Na.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))},Na.prefetchDNS=function(c){typeof c=="string"&&r.d.D(c)},Na.preinit=function(c,u){if(typeof c=="string"&&u&&typeof u.as=="string"){var d=u.as,f=l(d,u.crossOrigin),m=typeof u.integrity=="string"?u.integrity:void 0,p=typeof u.fetchPriority=="string"?u.fetchPriority:void 0;d==="style"?r.d.S(c,typeof u.precedence=="string"?u.precedence:void 0,{crossOrigin:f,integrity:m,fetchPriority:p}):d==="script"&&r.d.X(c,{crossOrigin:f,integrity:m,fetchPriority:p,nonce:typeof u.nonce=="string"?u.nonce:void 0})}},Na.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)},Na.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})}},Na.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)},Na.requestFormReset=function(c){r.d.r(c)},Na.unstable_batchedUpdates=function(c,u){return c(u)},Na.useFormState=function(c,u,d){return o.H.useFormState(c,u,d)},Na.useFormStatus=function(){return o.H.useHostTransitionStatus()},Na.version="19.2.0",Na}var AU;function aW(){if(AU)return ET.exports;AU=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(),ET.exports=Iae(),ET.exports}var CU;function Fae(){if(CU)return Xx;CU=1;var t=Lae(),e=Dg(),n=aW();function r(h){var g="https://react.dev/errors/"+h;if(1<arguments.length){g+="?args[]="+encodeURIComponent(arguments[1]);for(var _=2;_<arguments.length;_++)g+="&args[]="+encodeURIComponent(arguments[_])}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,_=h;if(h.alternate)for(;g.return;)g=g.return;else{h=g;do g=h,(g.flags&4098)!==0&&(_=g.return),h=g.return;while(h)}return g.tag===3?_: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 _=h,M=g;;){var P=_.return;if(P===null)break;var I=P.alternate;if(I===null){if(M=P.return,M!==null){_=M;continue}break}if(P.child===I.child){for(I=P.child;I;){if(I===_)return c(P),h;if(I===M)return c(P),g;I=I.sibling}throw Error(r(188))}if(_.return!==M.return)_=P,M=I;else{for(var J=!1,ge=P.child;ge;){if(ge===_){J=!0,_=P,M=I;break}if(ge===M){J=!0,M=P,_=I;break}ge=ge.sibling}if(!J){for(ge=I.child;ge;){if(ge===_){J=!0,_=I,M=P;break}if(ge===M){J=!0,M=I,_=P;break}ge=ge.sibling}if(!J)throw Error(r(189))}}if(_.alternate!==M)throw Error(r(190))}if(_.tag!==3)throw Error(r(188));return _.stateNode.current===_?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,m=Symbol.for("react.element"),p=Symbol.for("react.transitional.element"),x=Symbol.for("react.portal"),y=Symbol.for("react.fragment"),b=Symbol.for("react.strict_mode"),v=Symbol.for("react.profiler"),N=Symbol.for("react.consumer"),S=Symbol.for("react.context"),T=Symbol.for("react.forward_ref"),E=Symbol.for("react.suspense"),C=Symbol.for("react.suspense_list"),A=Symbol.for("react.memo"),O=Symbol.for("react.lazy"),k=Symbol.for("react.activity"),R=Symbol.for("react.memo_cache_sentinel"),F=Symbol.iterator;function L(h){return h===null||typeof h!="object"?null:(h=F&&h[F]||h["@@iterator"],typeof h=="function"?h:null)}var K=Symbol.for("react.client.reference");function j(h){if(h==null)return null;if(typeof h=="function")return h.$$typeof===K?null:h.displayName||h.name||null;if(typeof h=="string")return h;switch(h){case y:return"Fragment";case v:return"Profiler";case b:return"StrictMode";case E:return"Suspense";case C:return"SuspenseList";case k:return"Activity"}if(typeof h=="object")switch(h.$$typeof){case x:return"Portal";case S:return h.displayName||"Context";case N: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 A:return g=h.displayName||null,g!==null?g:j(h.type)||"Memo";case O:g=h._payload,h=h._init;try{return j(h(g))}catch{}}return null}var W=Array.isArray,Y=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,q=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Q={pending:!1,data:null,method:null,action:null},ee=[],re=-1;function z(h){return{current:h}}function G(h){0>re||(h.current=ee[re],ee[re]=null,re--)}function ae(h,g){re++,ee[re]=h.current,h.current=g}var se=z(null),ue=z(null),pe=z(null),ce=z(null);function Me(h,g){switch(ae(pe,g),ae(ue,h),ae(se,null),g.nodeType){case 9:case 11:h=(h=g.documentElement)&&(h=h.namespaceURI)?VF(h):0;break;default:if(h=g.tagName,g=g.namespaceURI)g=VF(g),h=GF(g,h);else switch(h){case"svg":h=1;break;case"math":h=2;break;default:h=0}}G(se),ae(se,h)}function me(){G(se),G(ue),G(pe)}function Ee(h){h.memoizedState!==null&&ae(ce,h);var g=se.current,_=GF(g,h.type);g!==_&&(ae(ue,h),ae(se,_))}function fe(h){ue.current===h&&(G(se),G(ue)),ce.current===h&&(G(ce),Vx._currentValue=Q)}var le,Be;function V(h){if(le===void 0)try{throw Error()}catch(_){var g=_.stack.trim().match(/\n( *(at )?)/);le=g&&g[1]||"",Be=-1<_.stack.indexOf(`
  2. at`)?" (<anonymous>)":-1<_.stack.indexOf("@")?"@unknown:0:0":""}return`
  3. `+le+h+Be}var $=!1;function X(h,g){if(!h||$)return"";$=!0;var _=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var M={DetermineComponentFrameRoot:function(){try{if(g){var _t=function(){throw Error()};if(Object.defineProperty(_t.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(_t,[])}catch(ft){var st=ft}Reflect.construct(h,[],_t)}else{try{_t.call()}catch(ft){st=ft}h.call(_t.prototype)}}else{try{throw Error()}catch(ft){st=ft}(_t=h())&&typeof _t.catch=="function"&&_t.catch(function(){})}}catch(ft){if(ft&&st&&typeof ft.stack=="string")return[ft.stack,st.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 I=M.DetermineComponentFrameRoot(),J=I[0],ge=I[1];if(J&&ge){var Ie=J.split(`
  4. `),it=ge.split(`
  5. `);for(P=M=0;M<Ie.length&&!Ie[M].includes("DetermineComponentFrameRoot");)M++;for(;P<it.length&&!it[P].includes("DetermineComponentFrameRoot");)P++;if(M===Ie.length||P===it.length)for(M=Ie.length-1,P=it.length-1;1<=M&&0<=P&&Ie[M]!==it[P];)P--;for(;1<=M&&0<=P;M--,P--)if(Ie[M]!==it[P]){if(M!==1||P!==1)do if(M--,P--,0>P||Ie[M]!==it[P]){var yt=`
  6. `+Ie[M].replace(" at new "," at ");return h.displayName&&yt.includes("<anonymous>")&&(yt=yt.replace("<anonymous>",h.displayName)),yt}while(1<=M&&0<=P);break}}}finally{$=!1,Error.prepareStackTrace=_}return(_=h?h.displayName||h.name:"")?V(_):""}function U(h,g){switch(h.tag){case 26:case 27:case 5:return V(h.type);case 16:return V("Lazy");case 13:return h.child!==g&&g!==null?V("Suspense Fallback"):V("Suspense");case 19:return V("SuspenseList");case 0:case 15:return X(h.type,!1);case 11:return X(h.type.render,!1);case 1:return X(h.type,!0);case 31:return V("Activity");default:return""}}function B(h){try{var g="",_=null;do g+=U(h,_),_=h,h=h.return;while(h);return g}catch(M){return`
  7. Error generating stack: `+M.message+`
  8. `+M.stack}}var oe=Object.prototype.hasOwnProperty,Te=t.unstable_scheduleCallback,je=t.unstable_cancelCallback,Ce=t.unstable_shouldYield,H=t.unstable_requestPaint,D=t.unstable_now,Z=t.unstable_getCurrentPriorityLevel,xe=t.unstable_ImmediatePriority,Ne=t.unstable_UserBlockingPriority,ve=t.unstable_NormalPriority,$e=t.unstable_LowPriority,Le=t.unstable_IdlePriority,qe=t.log,Ke=t.unstable_setDisableYieldValue,Ye=null,ie=null;function te(h){if(typeof qe=="function"&&Ke(h),ie&&typeof ie.setStrictMode=="function")try{ie.setStrictMode(Ye,h)}catch{}}var Se=Math.clz32?Math.clz32:ne,ze=Math.log,nt=Math.LN2;function ne(h){return h>>>=0,h===0?32:31-(ze(h)/nt|0)|0}var Pe=256,be=262144,Oe=4194304;function Ue(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 Ae(h,g,_){var M=h.pendingLanes;if(M===0)return 0;var P=0,I=h.suspendedLanes,J=h.pingedLanes;h=h.warmLanes;var ge=M&134217727;return ge!==0?(M=ge&~I,M!==0?P=Ue(M):(J&=ge,J!==0?P=Ue(J):_||(_=ge&~h,_!==0&&(P=Ue(_))))):(ge=M&~I,ge!==0?P=Ue(ge):J!==0?P=Ue(J):_||(_=M&~h,_!==0&&(P=Ue(_)))),P===0?0:g!==0&&g!==P&&(g&I)===0&&(I=P&-P,_=g&-g,I>=_||I===32&&(_&4194048)!==0)?g:P}function Je(h,g){return(h.pendingLanes&~(h.suspendedLanes&~h.pingedLanes)&g)===0}function gt(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 Pt(){var h=Oe;return Oe<<=1,(Oe&62914560)===0&&(Oe=4194304),h}function Ot(h){for(var g=[],_=0;31>_;_++)g.push(h);return g}function cn(h,g){h.pendingLanes|=g,g!==268435456&&(h.suspendedLanes=0,h.pingedLanes=0,h.warmLanes=0)}function It(h,g,_,M,P,I){var J=h.pendingLanes;h.pendingLanes=_,h.suspendedLanes=0,h.pingedLanes=0,h.warmLanes=0,h.expiredLanes&=_,h.entangledLanes&=_,h.errorRecoveryDisabledLanes&=_,h.shellSuspendCounter=0;var ge=h.entanglements,Ie=h.expirationTimes,it=h.hiddenUpdates;for(_=J&~_;0<_;){var yt=31-Se(_),_t=1<<yt;ge[yt]=0,Ie[yt]=-1;var st=it[yt];if(st!==null)for(it[yt]=null,yt=0;yt<st.length;yt++){var ft=st[yt];ft!==null&&(ft.lane&=-536870913)}_&=~_t}M!==0&&_n(h,M,0),I!==0&&P===0&&h.tag!==0&&(h.suspendedLanes|=I&~(J&~g))}function _n(h,g,_){h.pendingLanes|=g,h.suspendedLanes&=~g;var M=31-Se(g);h.entangledLanes|=g,h.entanglements[M]=h.entanglements[M]|1073741824|_&261930}function bt(h,g){var _=h.entangledLanes|=g;for(h=h.entanglements;_;){var M=31-Se(_),P=1<<M;P&g|h[M]&g&&(h[M]|=g),_&=~P}}function Gt(h,g){var _=g&-g;return _=(_&42)!==0?1:ln(_),(_&(h.suspendedLanes|g))!==0?0:_}function ln(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 Tt(h){return h&=-h,2<h?8<h?(h&134217727)!==0?32:268435456:8:2}function Rr(){var h=q.p;return h!==0?h:(h=window.event,h===void 0?32:mU(h.type))}function Xr(h,g){var _=q.p;try{return q.p=h,g()}finally{q.p=_}}var An=Math.random().toString(36).slice(2),sn="__reactFiber$"+An,Sr="__reactProps$"+An,si="__reactContainer$"+An,Dr="__reactEvents$"+An,_e="__reactListeners$"+An,Xe="__reactHandles$"+An,ot="__reactResources$"+An,ct="__reactMarker$"+An;function rt(h){delete h[sn],delete h[Sr],delete h[Dr],delete h[_e],delete h[Xe]}function Rt(h){var g=h[sn];if(g)return g;for(var _=h.parentNode;_;){if(g=_[si]||_[sn]){if(_=g.alternate,g.child!==null||_!==null&&_.child!==null)for(h=ZF(h);h!==null;){if(_=h[sn])return _;h=ZF(h)}return g}h=_,_=h.parentNode}return null}function de(h){if(h=h[sn]||h[si]){var g=h.tag;if(g===5||g===6||g===13||g===31||g===26||g===27||g===3)return h}return null}function Re(h){var g=h.tag;if(g===5||g===26||g===27||g===6)return h.stateNode;throw Error(r(33))}function Ve(h){var g=h[ot];return g||(g=h[ot]={hoistableStyles:new Map,hoistableScripts:new Map}),g}function He(h){h[ct]=!0}var Fe=new Set,mt={};function St(h,g){kt(h,g),kt(h+"Capture",g)}function kt(h,g){for(mt[h]=g,h=0;h<g.length;h++)Fe.add(g[h])}var xt=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]*$"),$t={},jt={};function wt(h){return oe.call(jt,h)?!0:oe.call($t,h)?!1:xt.test(h)?jt[h]=!0:($t[h]=!0,!1)}function Qt(h,g,_){if(wt(g))if(_===null)h.removeAttribute(g);else{switch(typeof _){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,""+_)}}function Kt(h,g,_){if(_===null)h.removeAttribute(g);else{switch(typeof _){case"undefined":case"function":case"symbol":case"boolean":h.removeAttribute(g);return}h.setAttribute(g,""+_)}}function fn(h,g,_,M){if(M===null)h.removeAttribute(_);else{switch(typeof M){case"undefined":case"function":case"symbol":case"boolean":h.removeAttribute(_);return}h.setAttributeNS(g,_,""+M)}}function ye(h){switch(typeof h){case"bigint":case"boolean":case"number":case"string":case"undefined":return h;case"object":return h;default:return""}}function De(h){var g=h.type;return(h=h.nodeName)&&h.toLowerCase()==="input"&&(g==="checkbox"||g==="radio")}function ht(h,g,_){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,I=M.set;return Object.defineProperty(h,g,{configurable:!0,get:function(){return P.call(this)},set:function(J){_=""+J,I.call(this,J)}}),Object.defineProperty(h,g,{enumerable:M.enumerable}),{getValue:function(){return _},setValue:function(J){_=""+J},stopTracking:function(){h._valueTracker=null,delete h[g]}}}}function Mt(h){if(!h._valueTracker){var g=De(h)?"checked":"value";h._valueTracker=ht(h,g,""+h[g])}}function at(h){if(!h)return!1;var g=h._valueTracker;if(!g)return!0;var _=g.getValue(),M="";return h&&(M=De(h)?h.checked?"true":"false":h.value),h=M,h!==_?(g.setValue(h),!0):!1}function Xt(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 Yt=/[\n"\\]/g;function rn(h){return h.replace(Yt,function(g){return"\\"+g.charCodeAt(0).toString(16)+" "})}function sr(h,g,_,M,P,I,J,ge){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=""+ye(g)):h.value!==""+ye(g)&&(h.value=""+ye(g)):J!=="submit"&&J!=="reset"||h.removeAttribute("value"),g!=null?Wt(h,J,ye(g)):_!=null?Wt(h,J,ye(_)):M!=null&&h.removeAttribute("value"),P==null&&I!=null&&(h.defaultChecked=!!I),P!=null&&(h.checked=P&&typeof P!="function"&&typeof P!="symbol"),ge!=null&&typeof ge!="function"&&typeof ge!="symbol"&&typeof ge!="boolean"?h.name=""+ye(ge):h.removeAttribute("name")}function kn(h,g,_,M,P,I,J,ge){if(I!=null&&typeof I!="function"&&typeof I!="symbol"&&typeof I!="boolean"&&(h.type=I),g!=null||_!=null){if(!(I!=="submit"&&I!=="reset"||g!=null)){Mt(h);return}_=_!=null?""+ye(_):"",g=g!=null?""+ye(g):_,ge||g===h.value||(h.value=g),h.defaultValue=g}M=M??P,M=typeof M!="function"&&typeof M!="symbol"&&!!M,h.checked=ge?h.checked:!!M,h.defaultChecked=!!M,J!=null&&typeof J!="function"&&typeof J!="symbol"&&typeof J!="boolean"&&(h.name=J),Mt(h)}function Wt(h,g,_){g==="number"&&Xt(h.ownerDocument)===h||h.defaultValue===""+_||(h.defaultValue=""+_)}function en(h,g,_,M){if(h=h.options,g){g={};for(var P=0;P<_.length;P++)g["$"+_[P]]=!0;for(_=0;_<h.length;_++)P=g.hasOwnProperty("$"+h[_].value),h[_].selected!==P&&(h[_].selected=P),P&&M&&(h[_].defaultSelected=!0)}else{for(_=""+ye(_),g=null,P=0;P<h.length;P++){if(h[P].value===_){h[P].selected=!0,M&&(h[P].defaultSelected=!0);return}g!==null||h[P].disabled||(g=h[P])}g!==null&&(g.selected=!0)}}function or(h,g,_){if(g!=null&&(g=""+ye(g),g!==h.value&&(h.value=g),_==null)){h.defaultValue!==g&&(h.defaultValue=g);return}h.defaultValue=_!=null?""+ye(_):""}function Or(h,g,_,M){if(g==null){if(M!=null){if(_!=null)throw Error(r(92));if(W(M)){if(1<M.length)throw Error(r(93));M=M[0]}_=M}_==null&&(_=""),g=_}_=ye(g),h.defaultValue=_,M=h.textContent,M===_&&M!==""&&M!==null&&(h.value=M),Mt(h)}function Ua(h,g){if(g){var _=h.firstChild;if(_&&_===h.lastChild&&_.nodeType===3){_.nodeValue=g;return}}h.textContent=g}var Es=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 am(h,g,_){var M=g.indexOf("--")===0;_==null||typeof _=="boolean"||_===""?M?h.setProperty(g,""):g==="float"?h.cssFloat="":h[g]="":M?h.setProperty(g,_):typeof _!="number"||_===0||Es.has(g)?g==="float"?h.cssFloat=_:h[g]=(""+_).trim():h[g]=_+"px"}function pl(h,g,_){if(g!=null&&typeof g!="object")throw Error(r(62));if(h=h.style,_!=null){for(var M in _)!_.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)&&_[P]!==M&&am(h,P,M)}else for(var I in g)g.hasOwnProperty(I)&&am(h,I,g[I])}function sa(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 tc=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"]]),dh=/^[\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 Hi(h){return dh.test(""+h)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":h}function nc(){}var bM=null;function yM(h){return h=h.target||h.srcElement||window,h.correspondingUseElement&&(h=h.correspondingUseElement),h.nodeType===3?h.parentNode:h}var sm=null,om=null;function HL(h){var g=de(h);if(g&&(h=g.stateNode)){var _=h[Sr]||null;e:switch(h=g.stateNode,g.type){case"input":if(sr(h,_.value,_.defaultValue,_.defaultValue,_.checked,_.defaultChecked,_.type,_.name),g=_.name,_.type==="radio"&&g!=null){for(_=h;_.parentNode;)_=_.parentNode;for(_=_.querySelectorAll('input[name="'+rn(""+g)+'"][type="radio"]'),g=0;g<_.length;g++){var M=_[g];if(M!==h&&M.form===h.form){var P=M[Sr]||null;if(!P)throw Error(r(90));sr(M,P.value,P.defaultValue,P.defaultValue,P.checked,P.defaultChecked,P.type,P.name)}}for(g=0;g<_.length;g++)M=_[g],M.form===h.form&&at(M)}break e;case"textarea":or(h,_.value,_.defaultValue);break e;case"select":g=_.value,g!=null&&en(h,!!_.multiple,g,!1)}}}var vM=!1;function VL(h,g,_){if(vM)return h(g,_);vM=!0;try{var M=h(g);return M}finally{if(vM=!1,(sm!==null||om!==null)&&(jv(),sm&&(g=sm,h=om,om=sm=null,HL(g),h)))for(g=0;g<h.length;g++)HL(h[g])}}function ox(h,g){var _=h.stateNode;if(_===null)return null;var M=_[Sr]||null;if(M===null)return null;_=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(_&&typeof _!="function")throw Error(r(231,g,typeof _));return _}var rc=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),_M=!1;if(rc)try{var lx={};Object.defineProperty(lx,"passive",{get:function(){_M=!0}}),window.addEventListener("test",lx,lx),window.removeEventListener("test",lx,lx)}catch{_M=!1}var wu=null,wM=null,Gy=null;function GL(){if(Gy)return Gy;var h,g=wM,_=g.length,M,P="value"in wu?wu.value:wu.textContent,I=P.length;for(h=0;h<_&&g[h]===P[h];h++);var J=_-h;for(M=1;M<=J&&g[_-M]===P[I-M];M++);return Gy=P.slice(h,1<M?1-M:void 0)}function Wy(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 qy(){return!0}function WL(){return!1}function rs(h){function g(_,M,P,I,J){this._reactName=_,this._targetInst=P,this.type=M,this.nativeEvent=I,this.target=J,this.currentTarget=null;for(var ge in h)h.hasOwnProperty(ge)&&(_=h[ge],this[ge]=_?_(I):I[ge]);return this.isDefaultPrevented=(I.defaultPrevented!=null?I.defaultPrevented:I.returnValue===!1)?qy:WL,this.isPropagationStopped=WL,this}return f(g.prototype,{preventDefault:function(){this.defaultPrevented=!0;var _=this.nativeEvent;_&&(_.preventDefault?_.preventDefault():typeof _.returnValue!="unknown"&&(_.returnValue=!1),this.isDefaultPrevented=qy)},stopPropagation:function(){var _=this.nativeEvent;_&&(_.stopPropagation?_.stopPropagation():typeof _.cancelBubble!="unknown"&&(_.cancelBubble=!0),this.isPropagationStopped=qy)},persist:function(){},isPersistent:qy}),g}var hh={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(h){return h.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Ky=rs(hh),cx=f({},hh,{view:0,detail:0}),Are=rs(cx),SM,NM,ux,Xy=f({},cx,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:EM,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!==ux&&(ux&&h.type==="mousemove"?(SM=h.screenX-ux.screenX,NM=h.screenY-ux.screenY):NM=SM=0,ux=h),SM)},movementY:function(h){return"movementY"in h?h.movementY:NM}}),qL=rs(Xy),Cre=f({},Xy,{dataTransfer:0}),kre=rs(Cre),jre=f({},cx,{relatedTarget:0}),MM=rs(jre),Pre=f({},hh,{animationName:0,elapsedTime:0,pseudoElement:0}),Rre=rs(Pre),Dre=f({},hh,{clipboardData:function(h){return"clipboardData"in h?h.clipboardData:window.clipboardData}}),Ore=rs(Dre),Lre=f({},hh,{data:0}),KL=rs(Lre),Ire={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Fre={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"},Ure={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function zre(h){var g=this.nativeEvent;return g.getModifierState?g.getModifierState(h):(h=Ure[h])?!!g[h]:!1}function EM(){return zre}var Bre=f({},cx,{key:function(h){if(h.key){var g=Ire[h.key]||h.key;if(g!=="Unidentified")return g}return h.type==="keypress"?(h=Wy(h),h===13?"Enter":String.fromCharCode(h)):h.type==="keydown"||h.type==="keyup"?Fre[h.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:EM,charCode:function(h){return h.type==="keypress"?Wy(h):0},keyCode:function(h){return h.type==="keydown"||h.type==="keyup"?h.keyCode:0},which:function(h){return h.type==="keypress"?Wy(h):h.type==="keydown"||h.type==="keyup"?h.keyCode:0}}),$re=rs(Bre),Hre=f({},Xy,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),XL=rs(Hre),Vre=f({},cx,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:EM}),Gre=rs(Vre),Wre=f({},hh,{propertyName:0,elapsedTime:0,pseudoElement:0}),qre=rs(Wre),Kre=f({},Xy,{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}),Xre=rs(Kre),Yre=f({},hh,{newState:0,oldState:0}),Qre=rs(Yre),Zre=[9,13,27,32],TM=rc&&"CompositionEvent"in window,dx=null;rc&&"documentMode"in document&&(dx=document.documentMode);var Jre=rc&&"TextEvent"in window&&!dx,YL=rc&&(!TM||dx&&8<dx&&11>=dx),QL=" ",ZL=!1;function JL(h,g){switch(h){case"keyup":return Zre.indexOf(g.keyCode)!==-1;case"keydown":return g.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function eI(h){return h=h.detail,typeof h=="object"&&"data"in h?h.data:null}var lm=!1;function eie(h,g){switch(h){case"compositionend":return eI(g);case"keypress":return g.which!==32?null:(ZL=!0,QL);case"textInput":return h=g.data,h===QL&&ZL?null:h;default:return null}}function tie(h,g){if(lm)return h==="compositionend"||!TM&&JL(h,g)?(h=GL(),Gy=wM=wu=null,lm=!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 YL&&g.locale!=="ko"?null:g.data;default:return null}}var nie={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 tI(h){var g=h&&h.nodeName&&h.nodeName.toLowerCase();return g==="input"?!!nie[h.type]:g==="textarea"}function nI(h,g,_,M){sm?om?om.push(M):om=[M]:sm=M,g=Fv(g,"onChange"),0<g.length&&(_=new Ky("onChange","change",null,_,M),h.push({event:_,listeners:g}))}var hx=null,fx=null;function rie(h){FF(h,0)}function Yy(h){var g=Re(h);if(at(g))return h}function rI(h,g){if(h==="change")return g}var iI=!1;if(rc){var AM;if(rc){var CM="oninput"in document;if(!CM){var aI=document.createElement("div");aI.setAttribute("oninput","return;"),CM=typeof aI.oninput=="function"}AM=CM}else AM=!1;iI=AM&&(!document.documentMode||9<document.documentMode)}function sI(){hx&&(hx.detachEvent("onpropertychange",oI),fx=hx=null)}function oI(h){if(h.propertyName==="value"&&Yy(fx)){var g=[];nI(g,fx,h,yM(h)),VL(rie,g)}}function iie(h,g,_){h==="focusin"?(sI(),hx=g,fx=_,hx.attachEvent("onpropertychange",oI)):h==="focusout"&&sI()}function aie(h){if(h==="selectionchange"||h==="keyup"||h==="keydown")return Yy(fx)}function sie(h,g){if(h==="click")return Yy(g)}function oie(h,g){if(h==="input"||h==="change")return Yy(g)}function lie(h,g){return h===g&&(h!==0||1/h===1/g)||h!==h&&g!==g}var Ts=typeof Object.is=="function"?Object.is:lie;function mx(h,g){if(Ts(h,g))return!0;if(typeof h!="object"||h===null||typeof g!="object"||g===null)return!1;var _=Object.keys(h),M=Object.keys(g);if(_.length!==M.length)return!1;for(M=0;M<_.length;M++){var P=_[M];if(!oe.call(g,P)||!Ts(h[P],g[P]))return!1}return!0}function lI(h){for(;h&&h.firstChild;)h=h.firstChild;return h}function cI(h,g){var _=lI(h);h=0;for(var M;_;){if(_.nodeType===3){if(M=h+_.textContent.length,h<=g&&M>=g)return{node:_,offset:g-h};h=M}e:{for(;_;){if(_.nextSibling){_=_.nextSibling;break e}_=_.parentNode}_=void 0}_=lI(_)}}function uI(h,g){return h&&g?h===g?!0:h&&h.nodeType===3?!1:g&&g.nodeType===3?uI(h,g.parentNode):"contains"in h?h.contains(g):h.compareDocumentPosition?!!(h.compareDocumentPosition(g)&16):!1:!1}function dI(h){h=h!=null&&h.ownerDocument!=null&&h.ownerDocument.defaultView!=null?h.ownerDocument.defaultView:window;for(var g=Xt(h.document);g instanceof h.HTMLIFrameElement;){try{var _=typeof g.contentWindow.location.href=="string"}catch{_=!1}if(_)h=g.contentWindow;else break;g=Xt(h.document)}return g}function kM(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 cie=rc&&"documentMode"in document&&11>=document.documentMode,cm=null,jM=null,px=null,PM=!1;function hI(h,g,_){var M=_.window===_?_.document:_.nodeType===9?_:_.ownerDocument;PM||cm==null||cm!==Xt(M)||(M=cm,"selectionStart"in M&&kM(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}),px&&mx(px,M)||(px=M,M=Fv(jM,"onSelect"),0<M.length&&(g=new Ky("onSelect","select",null,g,_),h.push({event:g,listeners:M}),g.target=cm)))}function fh(h,g){var _={};return _[h.toLowerCase()]=g.toLowerCase(),_["Webkit"+h]="webkit"+g,_["Moz"+h]="moz"+g,_}var um={animationend:fh("Animation","AnimationEnd"),animationiteration:fh("Animation","AnimationIteration"),animationstart:fh("Animation","AnimationStart"),transitionrun:fh("Transition","TransitionRun"),transitionstart:fh("Transition","TransitionStart"),transitioncancel:fh("Transition","TransitionCancel"),transitionend:fh("Transition","TransitionEnd")},RM={},fI={};rc&&(fI=document.createElement("div").style,"AnimationEvent"in window||(delete um.animationend.animation,delete um.animationiteration.animation,delete um.animationstart.animation),"TransitionEvent"in window||delete um.transitionend.transition);function mh(h){if(RM[h])return RM[h];if(!um[h])return h;var g=um[h],_;for(_ in g)if(g.hasOwnProperty(_)&&_ in fI)return RM[h]=g[_];return h}var mI=mh("animationend"),pI=mh("animationiteration"),gI=mh("animationstart"),uie=mh("transitionrun"),die=mh("transitionstart"),hie=mh("transitioncancel"),xI=mh("transitionend"),bI=new Map,DM="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(" ");DM.push("scrollEnd");function Bo(h,g){bI.set(h,g),St(g,[h])}var Qy=typeof reportError=="function"?reportError:function(h){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var g=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof h=="object"&&h!==null&&typeof h.message=="string"?String(h.message):String(h),error:h});if(!window.dispatchEvent(g))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",h);return}console.error(h)},eo=[],dm=0,OM=0;function Zy(){for(var h=dm,g=OM=dm=0;g<h;){var _=eo[g];eo[g++]=null;var M=eo[g];eo[g++]=null;var P=eo[g];eo[g++]=null;var I=eo[g];if(eo[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}I!==0&&yI(_,P,I)}}function Jy(h,g,_,M){eo[dm++]=h,eo[dm++]=g,eo[dm++]=_,eo[dm++]=M,OM|=M,h.lanes|=M,h=h.alternate,h!==null&&(h.lanes|=M)}function LM(h,g,_,M){return Jy(h,g,_,M),ev(h)}function ph(h,g){return Jy(h,null,null,g),ev(h)}function yI(h,g,_){h.lanes|=_;var M=h.alternate;M!==null&&(M.lanes|=_);for(var P=!1,I=h.return;I!==null;)I.childLanes|=_,M=I.alternate,M!==null&&(M.childLanes|=_),I.tag===22&&(h=I.stateNode,h===null||h._visibility&1||(P=!0)),h=I,I=I.return;return h.tag===3?(I=h.stateNode,P&&g!==null&&(P=31-Se(_),h=I.hiddenUpdates,M=h[P],M===null?h[P]=[g]:M.push(g),g.lane=_|536870912),I):null}function ev(h){if(50<Ix)throw Ix=0,GE=null,Error(r(185));for(var g=h.return;g!==null;)h=g,g=h.return;return h.tag===3?h.stateNode:null}var hm={};function fie(h,g,_,M){this.tag=h,this.key=_,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 As(h,g,_,M){return new fie(h,g,_,M)}function IM(h){return h=h.prototype,!(!h||!h.isReactComponent)}function ic(h,g){var _=h.alternate;return _===null?(_=As(h.tag,g,h.key,h.mode),_.elementType=h.elementType,_.type=h.type,_.stateNode=h.stateNode,_.alternate=h,h.alternate=_):(_.pendingProps=g,_.type=h.type,_.flags=0,_.subtreeFlags=0,_.deletions=null),_.flags=h.flags&65011712,_.childLanes=h.childLanes,_.lanes=h.lanes,_.child=h.child,_.memoizedProps=h.memoizedProps,_.memoizedState=h.memoizedState,_.updateQueue=h.updateQueue,g=h.dependencies,_.dependencies=g===null?null:{lanes:g.lanes,firstContext:g.firstContext},_.sibling=h.sibling,_.index=h.index,_.ref=h.ref,_.refCleanup=h.refCleanup,_}function vI(h,g){h.flags&=65011714;var _=h.alternate;return _===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=_.childLanes,h.lanes=_.lanes,h.child=_.child,h.subtreeFlags=0,h.deletions=null,h.memoizedProps=_.memoizedProps,h.memoizedState=_.memoizedState,h.updateQueue=_.updateQueue,h.type=_.type,g=_.dependencies,h.dependencies=g===null?null:{lanes:g.lanes,firstContext:g.firstContext}),h}function tv(h,g,_,M,P,I){var J=0;if(M=h,typeof h=="function")IM(h)&&(J=1);else if(typeof h=="string")J=bae(h,_,se.current)?26:h==="html"||h==="head"||h==="body"?27:5;else e:switch(h){case k:return h=As(31,_,g,P),h.elementType=k,h.lanes=I,h;case y:return gh(_.children,P,I,g);case b:J=8,P|=24;break;case v:return h=As(12,_,g,P|2),h.elementType=v,h.lanes=I,h;case E:return h=As(13,_,g,P),h.elementType=E,h.lanes=I,h;case C:return h=As(19,_,g,P),h.elementType=C,h.lanes=I,h;default:if(typeof h=="object"&&h!==null)switch(h.$$typeof){case S:J=10;break e;case N:J=9;break e;case T:J=11;break e;case A:J=14;break e;case O:J=16,M=null;break e}J=29,_=Error(r(130,h===null?"null":typeof h,"")),M=null}return g=As(J,_,g,P),g.elementType=h,g.type=M,g.lanes=I,g}function gh(h,g,_,M){return h=As(7,h,M,g),h.lanes=_,h}function FM(h,g,_){return h=As(6,h,null,g),h.lanes=_,h}function _I(h){var g=As(18,null,null,0);return g.stateNode=h,g}function UM(h,g,_){return g=As(4,h.children!==null?h.children:[],h.key,g),g.lanes=_,g.stateNode={containerInfo:h.containerInfo,pendingChildren:null,implementation:h.implementation},g}var wI=new WeakMap;function to(h,g){if(typeof h=="object"&&h!==null){var _=wI.get(h);return _!==void 0?_:(g={value:h,source:g,stack:B(g)},wI.set(h,g),g)}return{value:h,source:g,stack:B(g)}}var fm=[],mm=0,nv=null,gx=0,no=[],ro=0,Su=null,gl=1,xl="";function ac(h,g){fm[mm++]=gx,fm[mm++]=nv,nv=h,gx=g}function SI(h,g,_){no[ro++]=gl,no[ro++]=xl,no[ro++]=Su,Su=h;var M=gl;h=xl;var P=32-Se(M)-1;M&=~(1<<P),_+=1;var I=32-Se(g)+P;if(30<I){var J=P-P%5;I=(M&(1<<J)-1).toString(32),M>>=J,P-=J,gl=1<<32-Se(g)+P|_<<P|M,xl=I+h}else gl=1<<I|_<<P|M,xl=h}function zM(h){h.return!==null&&(ac(h,1),SI(h,1,0))}function BM(h){for(;h===nv;)nv=fm[--mm],fm[mm]=null,gx=fm[--mm],fm[mm]=null;for(;h===Su;)Su=no[--ro],no[ro]=null,xl=no[--ro],no[ro]=null,gl=no[--ro],no[ro]=null}function NI(h,g){no[ro++]=gl,no[ro++]=xl,no[ro++]=Su,gl=g.id,xl=g.overflow,Su=h}var oa=null,Tr=null,Un=!1,Nu=null,io=!1,$M=Error(r(519));function Mu(h){var g=Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw xx(to(g,h)),$M}function MI(h){var g=h.stateNode,_=h.type,M=h.memoizedProps;switch(g[sn]=h,g[Sr]=M,_){case"dialog":Pn("cancel",g),Pn("close",g);break;case"iframe":case"object":case"embed":Pn("load",g);break;case"video":case"audio":for(_=0;_<Ux.length;_++)Pn(Ux[_],g);break;case"source":Pn("error",g);break;case"img":case"image":case"link":Pn("error",g),Pn("load",g);break;case"details":Pn("toggle",g);break;case"input":Pn("invalid",g),kn(g,M.value,M.defaultValue,M.checked,M.defaultChecked,M.type,M.name,!0);break;case"select":Pn("invalid",g);break;case"textarea":Pn("invalid",g),Or(g,M.value,M.defaultValue,M.children)}_=M.children,typeof _!="string"&&typeof _!="number"&&typeof _!="bigint"||g.textContent===""+_||M.suppressHydrationWarning===!0||$F(g.textContent,_)?(M.popover!=null&&(Pn("beforetoggle",g),Pn("toggle",g)),M.onScroll!=null&&Pn("scroll",g),M.onScrollEnd!=null&&Pn("scrollend",g),M.onClick!=null&&(g.onclick=nc),g=!0):g=!1,g||Mu(h,!0)}function EI(h){for(oa=h.return;oa;)switch(oa.tag){case 5:case 31:case 13:io=!1;return;case 27:case 3:io=!0;return;default:oa=oa.return}}function pm(h){if(h!==oa)return!1;if(!Un)return EI(h),Un=!0,!1;var g=h.tag,_;if((_=g!==3&&g!==27)&&((_=g===5)&&(_=h.type,_=!(_!=="form"&&_!=="button")||sT(h.type,h.memoizedProps)),_=!_),_&&Tr&&Mu(h),EI(h),g===13){if(h=h.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(r(317));Tr=QF(h)}else if(g===31){if(h=h.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(r(317));Tr=QF(h)}else g===27?(g=Tr,Uu(h.type)?(h=dT,dT=null,Tr=h):Tr=g):Tr=oa?so(h.stateNode.nextSibling):null;return!0}function xh(){Tr=oa=null,Un=!1}function HM(){var h=Nu;return h!==null&&(ls===null?ls=h:ls.push.apply(ls,h),Nu=null),h}function xx(h){Nu===null?Nu=[h]:Nu.push(h)}var VM=z(null),bh=null,sc=null;function Eu(h,g,_){ae(VM,g._currentValue),g._currentValue=_}function oc(h){h._currentValue=VM.current,G(VM)}function GM(h,g,_){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===_)break;h=h.return}}function WM(h,g,_,M){var P=h.child;for(P!==null&&(P.return=h);P!==null;){var I=P.dependencies;if(I!==null){var J=P.child;I=I.firstContext;e:for(;I!==null;){var ge=I;I=P;for(var Ie=0;Ie<g.length;Ie++)if(ge.context===g[Ie]){I.lanes|=_,ge=I.alternate,ge!==null&&(ge.lanes|=_),GM(I.return,_,h),M||(J=null);break e}I=ge.next}}else if(P.tag===18){if(J=P.return,J===null)throw Error(r(341));J.lanes|=_,I=J.alternate,I!==null&&(I.lanes|=_),GM(J,_,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 gm(h,g,_,M){h=null;for(var P=g,I=!1;P!==null;){if(!I){if((P.flags&524288)!==0)I=!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 ge=P.type;Ts(P.pendingProps.value,J.value)||(h!==null?h.push(ge):h=[ge])}}else if(P===ce.current){if(J=P.alternate,J===null)throw Error(r(387));J.memoizedState.memoizedState!==P.memoizedState.memoizedState&&(h!==null?h.push(Vx):h=[Vx])}P=P.return}h!==null&&WM(g,h,_,M),g.flags|=262144}function rv(h){for(h=h.firstContext;h!==null;){if(!Ts(h.context._currentValue,h.memoizedValue))return!0;h=h.next}return!1}function yh(h){bh=h,sc=null,h=h.dependencies,h!==null&&(h.firstContext=null)}function la(h){return TI(bh,h)}function iv(h,g){return bh===null&&yh(h),TI(h,g)}function TI(h,g){var _=g._currentValue;if(g={context:g,memoizedValue:_,next:null},sc===null){if(h===null)throw Error(r(308));sc=g,h.dependencies={lanes:0,firstContext:g},h.flags|=524288}else sc=sc.next=g;return _}var mie=typeof AbortController<"u"?AbortController:function(){var h=[],g=this.signal={aborted:!1,addEventListener:function(_,M){h.push(M)}};this.abort=function(){g.aborted=!0,h.forEach(function(_){return _()})}},pie=t.unstable_scheduleCallback,gie=t.unstable_NormalPriority,fi={$$typeof:S,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function qM(){return{controller:new mie,data:new Map,refCount:0}}function bx(h){h.refCount--,h.refCount===0&&pie(gie,function(){h.controller.abort()})}var yx=null,KM=0,xm=0,bm=null;function xie(h,g){if(yx===null){var _=yx=[];KM=0,xm=QE(),bm={status:"pending",value:void 0,then:function(M){_.push(M)}}}return KM++,g.then(AI,AI),g}function AI(){if(--KM===0&&yx!==null){bm!==null&&(bm.status="fulfilled");var h=yx;yx=null,xm=0,bm=null;for(var g=0;g<h.length;g++)(0,h[g])()}}function bie(h,g){var _=[],M={status:"pending",value:null,reason:null,then:function(P){_.push(P)}};return h.then(function(){M.status="fulfilled",M.value=g;for(var P=0;P<_.length;P++)(0,_[P])(g)},function(P){for(M.status="rejected",M.reason=P,P=0;P<_.length;P++)(0,_[P])(void 0)}),M}var CI=Y.S;Y.S=function(h,g){hF=D(),typeof g=="object"&&g!==null&&typeof g.then=="function"&&xie(h,g),CI!==null&&CI(h,g)};var vh=z(null);function XM(){var h=vh.current;return h!==null?h:yr.pooledCache}function av(h,g){g===null?ae(vh,vh.current):ae(vh,g.pool)}function kI(){var h=XM();return h===null?null:{parent:fi._currentValue,pool:h}}var ym=Error(r(460)),YM=Error(r(474)),sv=Error(r(542)),ov={then:function(){}};function jI(h){return h=h.status,h==="fulfilled"||h==="rejected"}function PI(h,g,_){switch(_=h[_],_===void 0?h.push(g):_!==g&&(g.then(nc,nc),g=_),g.status){case"fulfilled":return g.value;case"rejected":throw h=g.reason,DI(h),h;default:if(typeof g.status=="string")g.then(nc,nc);else{if(h=yr,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,DI(h),h}throw wh=g,ym}}function _h(h){try{var g=h._init;return g(h._payload)}catch(_){throw _!==null&&typeof _=="object"&&typeof _.then=="function"?(wh=_,ym):_}}var wh=null;function RI(){if(wh===null)throw Error(r(459));var h=wh;return wh=null,h}function DI(h){if(h===ym||h===sv)throw Error(r(483))}var vm=null,vx=0;function lv(h){var g=vx;return vx+=1,vm===null&&(vm=[]),PI(vm,h,g)}function _x(h,g){g=g.props.ref,h.ref=g!==void 0?g:null}function cv(h,g){throw g.$$typeof===m?Error(r(525)):(h=Object.prototype.toString.call(g),Error(r(31,h==="[object Object]"?"object with keys {"+Object.keys(g).join(", ")+"}":h)))}function OI(h){function g(Ze,Ge){if(h){var tt=Ze.deletions;tt===null?(Ze.deletions=[Ge],Ze.flags|=16):tt.push(Ge)}}function _(Ze,Ge){if(!h)return null;for(;Ge!==null;)g(Ze,Ge),Ge=Ge.sibling;return null}function M(Ze){for(var Ge=new Map;Ze!==null;)Ze.key!==null?Ge.set(Ze.key,Ze):Ge.set(Ze.index,Ze),Ze=Ze.sibling;return Ge}function P(Ze,Ge){return Ze=ic(Ze,Ge),Ze.index=0,Ze.sibling=null,Ze}function I(Ze,Ge,tt){return Ze.index=tt,h?(tt=Ze.alternate,tt!==null?(tt=tt.index,tt<Ge?(Ze.flags|=67108866,Ge):tt):(Ze.flags|=67108866,Ge)):(Ze.flags|=1048576,Ge)}function J(Ze){return h&&Ze.alternate===null&&(Ze.flags|=67108866),Ze}function ge(Ze,Ge,tt,vt){return Ge===null||Ge.tag!==6?(Ge=FM(tt,Ze.mode,vt),Ge.return=Ze,Ge):(Ge=P(Ge,tt),Ge.return=Ze,Ge)}function Ie(Ze,Ge,tt,vt){var Zt=tt.type;return Zt===y?yt(Ze,Ge,tt.props.children,vt,tt.key):Ge!==null&&(Ge.elementType===Zt||typeof Zt=="object"&&Zt!==null&&Zt.$$typeof===O&&_h(Zt)===Ge.type)?(Ge=P(Ge,tt.props),_x(Ge,tt),Ge.return=Ze,Ge):(Ge=tv(tt.type,tt.key,tt.props,null,Ze.mode,vt),_x(Ge,tt),Ge.return=Ze,Ge)}function it(Ze,Ge,tt,vt){return Ge===null||Ge.tag!==4||Ge.stateNode.containerInfo!==tt.containerInfo||Ge.stateNode.implementation!==tt.implementation?(Ge=UM(tt,Ze.mode,vt),Ge.return=Ze,Ge):(Ge=P(Ge,tt.children||[]),Ge.return=Ze,Ge)}function yt(Ze,Ge,tt,vt,Zt){return Ge===null||Ge.tag!==7?(Ge=gh(tt,Ze.mode,vt,Zt),Ge.return=Ze,Ge):(Ge=P(Ge,tt),Ge.return=Ze,Ge)}function _t(Ze,Ge,tt){if(typeof Ge=="string"&&Ge!==""||typeof Ge=="number"||typeof Ge=="bigint")return Ge=FM(""+Ge,Ze.mode,tt),Ge.return=Ze,Ge;if(typeof Ge=="object"&&Ge!==null){switch(Ge.$$typeof){case p:return tt=tv(Ge.type,Ge.key,Ge.props,null,Ze.mode,tt),_x(tt,Ge),tt.return=Ze,tt;case x:return Ge=UM(Ge,Ze.mode,tt),Ge.return=Ze,Ge;case O:return Ge=_h(Ge),_t(Ze,Ge,tt)}if(W(Ge)||L(Ge))return Ge=gh(Ge,Ze.mode,tt,null),Ge.return=Ze,Ge;if(typeof Ge.then=="function")return _t(Ze,lv(Ge),tt);if(Ge.$$typeof===S)return _t(Ze,iv(Ze,Ge),tt);cv(Ze,Ge)}return null}function st(Ze,Ge,tt,vt){var Zt=Ge!==null?Ge.key:null;if(typeof tt=="string"&&tt!==""||typeof tt=="number"||typeof tt=="bigint")return Zt!==null?null:ge(Ze,Ge,""+tt,vt);if(typeof tt=="object"&&tt!==null){switch(tt.$$typeof){case p:return tt.key===Zt?Ie(Ze,Ge,tt,vt):null;case x:return tt.key===Zt?it(Ze,Ge,tt,vt):null;case O:return tt=_h(tt),st(Ze,Ge,tt,vt)}if(W(tt)||L(tt))return Zt!==null?null:yt(Ze,Ge,tt,vt,null);if(typeof tt.then=="function")return st(Ze,Ge,lv(tt),vt);if(tt.$$typeof===S)return st(Ze,Ge,iv(Ze,tt),vt);cv(Ze,tt)}return null}function ft(Ze,Ge,tt,vt,Zt){if(typeof vt=="string"&&vt!==""||typeof vt=="number"||typeof vt=="bigint")return Ze=Ze.get(tt)||null,ge(Ge,Ze,""+vt,Zt);if(typeof vt=="object"&&vt!==null){switch(vt.$$typeof){case p:return Ze=Ze.get(vt.key===null?tt:vt.key)||null,Ie(Ge,Ze,vt,Zt);case x:return Ze=Ze.get(vt.key===null?tt:vt.key)||null,it(Ge,Ze,vt,Zt);case O:return vt=_h(vt),ft(Ze,Ge,tt,vt,Zt)}if(W(vt)||L(vt))return Ze=Ze.get(tt)||null,yt(Ge,Ze,vt,Zt,null);if(typeof vt.then=="function")return ft(Ze,Ge,tt,lv(vt),Zt);if(vt.$$typeof===S)return ft(Ze,Ge,tt,iv(Ge,vt),Zt);cv(Ge,vt)}return null}function Vt(Ze,Ge,tt,vt){for(var Zt=null,Gn=null,qt=Ge,vn=Ge=0,In=null;qt!==null&&vn<tt.length;vn++){qt.index>vn?(In=qt,qt=null):In=qt.sibling;var Wn=st(Ze,qt,tt[vn],vt);if(Wn===null){qt===null&&(qt=In);break}h&&qt&&Wn.alternate===null&&g(Ze,qt),Ge=I(Wn,Ge,vn),Gn===null?Zt=Wn:Gn.sibling=Wn,Gn=Wn,qt=In}if(vn===tt.length)return _(Ze,qt),Un&&ac(Ze,vn),Zt;if(qt===null){for(;vn<tt.length;vn++)qt=_t(Ze,tt[vn],vt),qt!==null&&(Ge=I(qt,Ge,vn),Gn===null?Zt=qt:Gn.sibling=qt,Gn=qt);return Un&&ac(Ze,vn),Zt}for(qt=M(qt);vn<tt.length;vn++)In=ft(qt,Ze,vn,tt[vn],vt),In!==null&&(h&&In.alternate!==null&&qt.delete(In.key===null?vn:In.key),Ge=I(In,Ge,vn),Gn===null?Zt=In:Gn.sibling=In,Gn=In);return h&&qt.forEach(function(Vu){return g(Ze,Vu)}),Un&&ac(Ze,vn),Zt}function an(Ze,Ge,tt,vt){if(tt==null)throw Error(r(151));for(var Zt=null,Gn=null,qt=Ge,vn=Ge=0,In=null,Wn=tt.next();qt!==null&&!Wn.done;vn++,Wn=tt.next()){qt.index>vn?(In=qt,qt=null):In=qt.sibling;var Vu=st(Ze,qt,Wn.value,vt);if(Vu===null){qt===null&&(qt=In);break}h&&qt&&Vu.alternate===null&&g(Ze,qt),Ge=I(Vu,Ge,vn),Gn===null?Zt=Vu:Gn.sibling=Vu,Gn=Vu,qt=In}if(Wn.done)return _(Ze,qt),Un&&ac(Ze,vn),Zt;if(qt===null){for(;!Wn.done;vn++,Wn=tt.next())Wn=_t(Ze,Wn.value,vt),Wn!==null&&(Ge=I(Wn,Ge,vn),Gn===null?Zt=Wn:Gn.sibling=Wn,Gn=Wn);return Un&&ac(Ze,vn),Zt}for(qt=M(qt);!Wn.done;vn++,Wn=tt.next())Wn=ft(qt,Ze,vn,Wn.value,vt),Wn!==null&&(h&&Wn.alternate!==null&&qt.delete(Wn.key===null?vn:Wn.key),Ge=I(Wn,Ge,vn),Gn===null?Zt=Wn:Gn.sibling=Wn,Gn=Wn);return h&&qt.forEach(function(Cae){return g(Ze,Cae)}),Un&&ac(Ze,vn),Zt}function ur(Ze,Ge,tt,vt){if(typeof tt=="object"&&tt!==null&&tt.type===y&&tt.key===null&&(tt=tt.props.children),typeof tt=="object"&&tt!==null){switch(tt.$$typeof){case p:e:{for(var Zt=tt.key;Ge!==null;){if(Ge.key===Zt){if(Zt=tt.type,Zt===y){if(Ge.tag===7){_(Ze,Ge.sibling),vt=P(Ge,tt.props.children),vt.return=Ze,Ze=vt;break e}}else if(Ge.elementType===Zt||typeof Zt=="object"&&Zt!==null&&Zt.$$typeof===O&&_h(Zt)===Ge.type){_(Ze,Ge.sibling),vt=P(Ge,tt.props),_x(vt,tt),vt.return=Ze,Ze=vt;break e}_(Ze,Ge);break}else g(Ze,Ge);Ge=Ge.sibling}tt.type===y?(vt=gh(tt.props.children,Ze.mode,vt,tt.key),vt.return=Ze,Ze=vt):(vt=tv(tt.type,tt.key,tt.props,null,Ze.mode,vt),_x(vt,tt),vt.return=Ze,Ze=vt)}return J(Ze);case x:e:{for(Zt=tt.key;Ge!==null;){if(Ge.key===Zt)if(Ge.tag===4&&Ge.stateNode.containerInfo===tt.containerInfo&&Ge.stateNode.implementation===tt.implementation){_(Ze,Ge.sibling),vt=P(Ge,tt.children||[]),vt.return=Ze,Ze=vt;break e}else{_(Ze,Ge);break}else g(Ze,Ge);Ge=Ge.sibling}vt=UM(tt,Ze.mode,vt),vt.return=Ze,Ze=vt}return J(Ze);case O:return tt=_h(tt),ur(Ze,Ge,tt,vt)}if(W(tt))return Vt(Ze,Ge,tt,vt);if(L(tt)){if(Zt=L(tt),typeof Zt!="function")throw Error(r(150));return tt=Zt.call(tt),an(Ze,Ge,tt,vt)}if(typeof tt.then=="function")return ur(Ze,Ge,lv(tt),vt);if(tt.$$typeof===S)return ur(Ze,Ge,iv(Ze,tt),vt);cv(Ze,tt)}return typeof tt=="string"&&tt!==""||typeof tt=="number"||typeof tt=="bigint"?(tt=""+tt,Ge!==null&&Ge.tag===6?(_(Ze,Ge.sibling),vt=P(Ge,tt),vt.return=Ze,Ze=vt):(_(Ze,Ge),vt=FM(tt,Ze.mode,vt),vt.return=Ze,Ze=vt),J(Ze)):_(Ze,Ge)}return function(Ze,Ge,tt,vt){try{vx=0;var Zt=ur(Ze,Ge,tt,vt);return vm=null,Zt}catch(qt){if(qt===ym||qt===sv)throw qt;var Gn=As(29,qt,null,Ze.mode);return Gn.lanes=vt,Gn.return=Ze,Gn}finally{}}}var Sh=OI(!0),LI=OI(!1),Tu=!1;function QM(h){h.updateQueue={baseState:h.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function ZM(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 Au(h){return{lane:h,tag:0,payload:null,callback:null,next:null}}function Cu(h,g,_){var M=h.updateQueue;if(M===null)return null;if(M=M.shared,(Yn&2)!==0){var P=M.pending;return P===null?g.next=g:(g.next=P.next,P.next=g),M.pending=g,g=ev(h),yI(h,null,_),g}return Jy(h,M,g,_),ev(h)}function wx(h,g,_){if(g=g.updateQueue,g!==null&&(g=g.shared,(_&4194048)!==0)){var M=g.lanes;M&=h.pendingLanes,_|=M,g.lanes=_,bt(h,_)}}function JM(h,g){var _=h.updateQueue,M=h.alternate;if(M!==null&&(M=M.updateQueue,_===M)){var P=null,I=null;if(_=_.firstBaseUpdate,_!==null){do{var J={lane:_.lane,tag:_.tag,payload:_.payload,callback:null,next:null};I===null?P=I=J:I=I.next=J,_=_.next}while(_!==null);I===null?P=I=g:I=I.next=g}else P=I=g;_={baseState:M.baseState,firstBaseUpdate:P,lastBaseUpdate:I,shared:M.shared,callbacks:M.callbacks},h.updateQueue=_;return}h=_.lastBaseUpdate,h===null?_.firstBaseUpdate=g:h.next=g,_.lastBaseUpdate=g}var eE=!1;function Sx(){if(eE){var h=bm;if(h!==null)throw h}}function Nx(h,g,_,M){eE=!1;var P=h.updateQueue;Tu=!1;var I=P.firstBaseUpdate,J=P.lastBaseUpdate,ge=P.shared.pending;if(ge!==null){P.shared.pending=null;var Ie=ge,it=Ie.next;Ie.next=null,J===null?I=it:J.next=it,J=Ie;var yt=h.alternate;yt!==null&&(yt=yt.updateQueue,ge=yt.lastBaseUpdate,ge!==J&&(ge===null?yt.firstBaseUpdate=it:ge.next=it,yt.lastBaseUpdate=Ie))}if(I!==null){var _t=P.baseState;J=0,yt=it=Ie=null,ge=I;do{var st=ge.lane&-536870913,ft=st!==ge.lane;if(ft?(Ln&st)===st:(M&st)===st){st!==0&&st===xm&&(eE=!0),yt!==null&&(yt=yt.next={lane:0,tag:ge.tag,payload:ge.payload,callback:null,next:null});e:{var Vt=h,an=ge;st=g;var ur=_;switch(an.tag){case 1:if(Vt=an.payload,typeof Vt=="function"){_t=Vt.call(ur,_t,st);break e}_t=Vt;break e;case 3:Vt.flags=Vt.flags&-65537|128;case 0:if(Vt=an.payload,st=typeof Vt=="function"?Vt.call(ur,_t,st):Vt,st==null)break e;_t=f({},_t,st);break e;case 2:Tu=!0}}st=ge.callback,st!==null&&(h.flags|=64,ft&&(h.flags|=8192),ft=P.callbacks,ft===null?P.callbacks=[st]:ft.push(st))}else ft={lane:st,tag:ge.tag,payload:ge.payload,callback:ge.callback,next:null},yt===null?(it=yt=ft,Ie=_t):yt=yt.next=ft,J|=st;if(ge=ge.next,ge===null){if(ge=P.shared.pending,ge===null)break;ft=ge,ge=ft.next,ft.next=null,P.lastBaseUpdate=ft,P.shared.pending=null}}while(!0);yt===null&&(Ie=_t),P.baseState=Ie,P.firstBaseUpdate=it,P.lastBaseUpdate=yt,I===null&&(P.shared.lanes=0),Du|=J,h.lanes=J,h.memoizedState=_t}}function II(h,g){if(typeof h!="function")throw Error(r(191,h));h.call(g)}function FI(h,g){var _=h.callbacks;if(_!==null)for(h.callbacks=null,h=0;h<_.length;h++)II(_[h],g)}var _m=z(null),uv=z(0);function UI(h,g){h=gc,ae(uv,h),ae(_m,g),gc=h|g.baseLanes}function tE(){ae(uv,gc),ae(_m,_m.current)}function nE(){gc=uv.current,G(_m),G(uv)}var Cs=z(null),ao=null;function ku(h){var g=h.alternate;ae(oi,oi.current&1),ae(Cs,h),ao===null&&(g===null||_m.current!==null||g.memoizedState!==null)&&(ao=h)}function rE(h){ae(oi,oi.current),ae(Cs,h),ao===null&&(ao=h)}function zI(h){h.tag===22?(ae(oi,oi.current),ae(Cs,h),ao===null&&(ao=h)):ju()}function ju(){ae(oi,oi.current),ae(Cs,Cs.current)}function ks(h){G(Cs),ao===h&&(ao=null),G(oi)}var oi=z(0);function dv(h){for(var g=h;g!==null;){if(g.tag===13){var _=g.memoizedState;if(_!==null&&(_=_.dehydrated,_===null||cT(_)||uT(_)))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 lc=0,bn=null,lr=null,mi=null,hv=!1,wm=!1,Nh=!1,fv=0,Mx=0,Sm=null,yie=0;function Yr(){throw Error(r(321))}function iE(h,g){if(g===null)return!1;for(var _=0;_<g.length&&_<h.length;_++)if(!Ts(h[_],g[_]))return!1;return!0}function aE(h,g,_,M,P,I){return lc=I,bn=g,g.memoizedState=null,g.updateQueue=null,g.lanes=0,Y.H=h===null||h.memoizedState===null?S5:vE,Nh=!1,I=_(M,P),Nh=!1,wm&&(I=$I(g,_,M,P)),BI(h),I}function BI(h){Y.H=Ax;var g=lr!==null&&lr.next!==null;if(lc=0,mi=lr=bn=null,hv=!1,Mx=0,Sm=null,g)throw Error(r(300));h===null||pi||(h=h.dependencies,h!==null&&rv(h)&&(pi=!0))}function $I(h,g,_,M){bn=h;var P=0;do{if(wm&&(Sm=null),Mx=0,wm=!1,25<=P)throw Error(r(301));if(P+=1,mi=lr=null,h.updateQueue!=null){var I=h.updateQueue;I.lastEffect=null,I.events=null,I.stores=null,I.memoCache!=null&&(I.memoCache.index=0)}Y.H=N5,I=g(_,M)}while(wm);return I}function vie(){var h=Y.H,g=h.useState()[0];return g=typeof g.then=="function"?Ex(g):g,h=h.useState()[0],(lr!==null?lr.memoizedState:null)!==h&&(bn.flags|=1024),g}function sE(){var h=fv!==0;return fv=0,h}function oE(h,g,_){g.updateQueue=h.updateQueue,g.flags&=-2053,h.lanes&=~_}function lE(h){if(hv){for(h=h.memoizedState;h!==null;){var g=h.queue;g!==null&&(g.pending=null),h=h.next}hv=!1}lc=0,mi=lr=bn=null,wm=!1,Mx=fv=0,Sm=null}function za(){var h={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return mi===null?bn.memoizedState=mi=h:mi=mi.next=h,mi}function li(){if(lr===null){var h=bn.alternate;h=h!==null?h.memoizedState:null}else h=lr.next;var g=mi===null?bn.memoizedState:mi.next;if(g!==null)mi=g,lr=h;else{if(h===null)throw bn.alternate===null?Error(r(467)):Error(r(310));lr=h,h={memoizedState:lr.memoizedState,baseState:lr.baseState,baseQueue:lr.baseQueue,queue:lr.queue,next:null},mi===null?bn.memoizedState=mi=h:mi=mi.next=h}return mi}function mv(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Ex(h){var g=Mx;return Mx+=1,Sm===null&&(Sm=[]),h=PI(Sm,h,g),g=bn,(mi===null?g.memoizedState:mi.next)===null&&(g=g.alternate,Y.H=g===null||g.memoizedState===null?S5:vE),h}function pv(h){if(h!==null&&typeof h=="object"){if(typeof h.then=="function")return Ex(h);if(h.$$typeof===S)return la(h)}throw Error(r(438,String(h)))}function cE(h){var g=null,_=bn.updateQueue;if(_!==null&&(g=_.memoCache),g==null){var M=bn.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}),_===null&&(_=mv(),bn.updateQueue=_),_.memoCache=g,_=g.data[g.index],_===void 0)for(_=g.data[g.index]=Array(h),M=0;M<h;M++)_[M]=R;return g.index++,_}function cc(h,g){return typeof g=="function"?g(h):g}function gv(h){var g=li();return uE(g,lr,h)}function uE(h,g,_){var M=h.queue;if(M===null)throw Error(r(311));M.lastRenderedReducer=_;var P=h.baseQueue,I=M.pending;if(I!==null){if(P!==null){var J=P.next;P.next=I.next,I.next=J}g.baseQueue=P=I,M.pending=null}if(I=h.baseState,P===null)h.memoizedState=I;else{g=P.next;var ge=J=null,Ie=null,it=g,yt=!1;do{var _t=it.lane&-536870913;if(_t!==it.lane?(Ln&_t)===_t:(lc&_t)===_t){var st=it.revertLane;if(st===0)Ie!==null&&(Ie=Ie.next={lane:0,revertLane:0,gesture:null,action:it.action,hasEagerState:it.hasEagerState,eagerState:it.eagerState,next:null}),_t===xm&&(yt=!0);else if((lc&st)===st){it=it.next,st===xm&&(yt=!0);continue}else _t={lane:0,revertLane:it.revertLane,gesture:null,action:it.action,hasEagerState:it.hasEagerState,eagerState:it.eagerState,next:null},Ie===null?(ge=Ie=_t,J=I):Ie=Ie.next=_t,bn.lanes|=st,Du|=st;_t=it.action,Nh&&_(I,_t),I=it.hasEagerState?it.eagerState:_(I,_t)}else st={lane:_t,revertLane:it.revertLane,gesture:it.gesture,action:it.action,hasEagerState:it.hasEagerState,eagerState:it.eagerState,next:null},Ie===null?(ge=Ie=st,J=I):Ie=Ie.next=st,bn.lanes|=_t,Du|=_t;it=it.next}while(it!==null&&it!==g);if(Ie===null?J=I:Ie.next=ge,!Ts(I,h.memoizedState)&&(pi=!0,yt&&(_=bm,_!==null)))throw _;h.memoizedState=I,h.baseState=J,h.baseQueue=Ie,M.lastRenderedState=I}return P===null&&(M.lanes=0),[h.memoizedState,M.dispatch]}function dE(h){var g=li(),_=g.queue;if(_===null)throw Error(r(311));_.lastRenderedReducer=h;var M=_.dispatch,P=_.pending,I=g.memoizedState;if(P!==null){_.pending=null;var J=P=P.next;do I=h(I,J.action),J=J.next;while(J!==P);Ts(I,g.memoizedState)||(pi=!0),g.memoizedState=I,g.baseQueue===null&&(g.baseState=I),_.lastRenderedState=I}return[I,M]}function HI(h,g,_){var M=bn,P=li(),I=Un;if(I){if(_===void 0)throw Error(r(407));_=_()}else _=g();var J=!Ts((lr||P).memoizedState,_);if(J&&(P.memoizedState=_,pi=!0),P=P.queue,mE(WI.bind(null,M,P,h),[h]),P.getSnapshot!==g||J||mi!==null&&mi.memoizedState.tag&1){if(M.flags|=2048,Nm(9,{destroy:void 0},GI.bind(null,M,P,_,g),null),yr===null)throw Error(r(349));I||(lc&127)!==0||VI(M,g,_)}return _}function VI(h,g,_){h.flags|=16384,h={getSnapshot:g,value:_},g=bn.updateQueue,g===null?(g=mv(),bn.updateQueue=g,g.stores=[h]):(_=g.stores,_===null?g.stores=[h]:_.push(h))}function GI(h,g,_,M){g.value=_,g.getSnapshot=M,qI(g)&&KI(h)}function WI(h,g,_){return _(function(){qI(g)&&KI(h)})}function qI(h){var g=h.getSnapshot;h=h.value;try{var _=g();return!Ts(h,_)}catch{return!0}}function KI(h){var g=ph(h,2);g!==null&&cs(g,h,2)}function hE(h){var g=za();if(typeof h=="function"){var _=h;if(h=_(),Nh){te(!0);try{_()}finally{te(!1)}}}return g.memoizedState=g.baseState=h,g.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:cc,lastRenderedState:h},g}function XI(h,g,_,M){return h.baseState=_,uE(h,lr,typeof M=="function"?M:cc)}function _ie(h,g,_,M,P){if(yv(h))throw Error(r(485));if(h=g.action,h!==null){var I={payload:P,action:h,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(J){I.listeners.push(J)}};Y.T!==null?_(!0):I.isTransition=!1,M(I),_=g.pending,_===null?(I.next=g.pending=I,YI(g,I)):(I.next=_.next,g.pending=_.next=I)}}function YI(h,g){var _=g.action,M=g.payload,P=h.state;if(g.isTransition){var I=Y.T,J={};Y.T=J;try{var ge=_(P,M),Ie=Y.S;Ie!==null&&Ie(J,ge),QI(h,g,ge)}catch(it){fE(h,g,it)}finally{I!==null&&J.types!==null&&(I.types=J.types),Y.T=I}}else try{I=_(P,M),QI(h,g,I)}catch(it){fE(h,g,it)}}function QI(h,g,_){_!==null&&typeof _=="object"&&typeof _.then=="function"?_.then(function(M){ZI(h,g,M)},function(M){return fE(h,g,M)}):ZI(h,g,_)}function ZI(h,g,_){g.status="fulfilled",g.value=_,JI(g),h.state=_,g=h.pending,g!==null&&(_=g.next,_===g?h.pending=null:(_=_.next,g.next=_,YI(h,_)))}function fE(h,g,_){var M=h.pending;if(h.pending=null,M!==null){M=M.next;do g.status="rejected",g.reason=_,JI(g),g=g.next;while(g!==M)}h.action=null}function JI(h){h=h.listeners;for(var g=0;g<h.length;g++)(0,h[g])()}function e5(h,g){return g}function t5(h,g){if(Un){var _=yr.formState;if(_!==null){e:{var M=bn;if(Un){if(Tr){t:{for(var P=Tr,I=io;P.nodeType!==8;){if(!I){P=null;break t}if(P=so(P.nextSibling),P===null){P=null;break t}}I=P.data,P=I==="F!"||I==="F"?P:null}if(P){Tr=so(P.nextSibling),M=P.data==="F!";break e}}Mu(M)}M=!1}M&&(g=_[0])}}return _=za(),_.memoizedState=_.baseState=g,M={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e5,lastRenderedState:g},_.queue=M,_=v5.bind(null,bn,M),M.dispatch=_,M=hE(!1),I=yE.bind(null,bn,!1,M.queue),M=za(),P={state:g,dispatch:null,action:h,pending:null},M.queue=P,_=_ie.bind(null,bn,P,I,_),P.dispatch=_,M.memoizedState=h,[g,_,!1]}function n5(h){var g=li();return r5(g,lr,h)}function r5(h,g,_){if(g=uE(h,g,e5)[0],h=gv(cc)[0],typeof g=="object"&&g!==null&&typeof g.then=="function")try{var M=Ex(g)}catch(J){throw J===ym?sv:J}else M=g;g=li();var P=g.queue,I=P.dispatch;return _!==g.memoizedState&&(bn.flags|=2048,Nm(9,{destroy:void 0},wie.bind(null,P,_),null)),[M,I,h]}function wie(h,g){h.action=g}function i5(h){var g=li(),_=lr;if(_!==null)return r5(g,_,h);li(),g=g.memoizedState,_=li();var M=_.queue.dispatch;return _.memoizedState=h,[g,M,!1]}function Nm(h,g,_,M){return h={tag:h,create:_,deps:M,inst:g,next:null},g=bn.updateQueue,g===null&&(g=mv(),bn.updateQueue=g),_=g.lastEffect,_===null?g.lastEffect=h.next=h:(M=_.next,_.next=h,h.next=M,g.lastEffect=h),h}function a5(){return li().memoizedState}function xv(h,g,_,M){var P=za();bn.flags|=h,P.memoizedState=Nm(1|g,{destroy:void 0},_,M===void 0?null:M)}function bv(h,g,_,M){var P=li();M=M===void 0?null:M;var I=P.memoizedState.inst;lr!==null&&M!==null&&iE(M,lr.memoizedState.deps)?P.memoizedState=Nm(g,I,_,M):(bn.flags|=h,P.memoizedState=Nm(1|g,I,_,M))}function s5(h,g){xv(8390656,8,h,g)}function mE(h,g){bv(2048,8,h,g)}function Sie(h){bn.flags|=4;var g=bn.updateQueue;if(g===null)g=mv(),bn.updateQueue=g,g.events=[h];else{var _=g.events;_===null?g.events=[h]:_.push(h)}}function o5(h){var g=li().memoizedState;return Sie({ref:g,nextImpl:h}),function(){if((Yn&2)!==0)throw Error(r(440));return g.impl.apply(void 0,arguments)}}function l5(h,g){return bv(4,2,h,g)}function c5(h,g){return bv(4,4,h,g)}function u5(h,g){if(typeof g=="function"){h=h();var _=g(h);return function(){typeof _=="function"?_():g(null)}}if(g!=null)return h=h(),g.current=h,function(){g.current=null}}function d5(h,g,_){_=_!=null?_.concat([h]):null,bv(4,4,u5.bind(null,g,h),_)}function pE(){}function h5(h,g){var _=li();g=g===void 0?null:g;var M=_.memoizedState;return g!==null&&iE(g,M[1])?M[0]:(_.memoizedState=[h,g],h)}function f5(h,g){var _=li();g=g===void 0?null:g;var M=_.memoizedState;if(g!==null&&iE(g,M[1]))return M[0];if(M=h(),Nh){te(!0);try{h()}finally{te(!1)}}return _.memoizedState=[M,g],M}function gE(h,g,_){return _===void 0||(lc&1073741824)!==0&&(Ln&261930)===0?h.memoizedState=g:(h.memoizedState=_,h=mF(),bn.lanes|=h,Du|=h,_)}function m5(h,g,_,M){return Ts(_,g)?_:_m.current!==null?(h=gE(h,_,M),Ts(h,g)||(pi=!0),h):(lc&42)===0||(lc&1073741824)!==0&&(Ln&261930)===0?(pi=!0,h.memoizedState=_):(h=mF(),bn.lanes|=h,Du|=h,g)}function p5(h,g,_,M,P){var I=q.p;q.p=I!==0&&8>I?I:8;var J=Y.T,ge={};Y.T=ge,yE(h,!1,g,_);try{var Ie=P(),it=Y.S;if(it!==null&&it(ge,Ie),Ie!==null&&typeof Ie=="object"&&typeof Ie.then=="function"){var yt=bie(Ie,M);Tx(h,g,yt,Rs(h))}else Tx(h,g,M,Rs(h))}catch(_t){Tx(h,g,{then:function(){},status:"rejected",reason:_t},Rs())}finally{q.p=I,J!==null&&ge.types!==null&&(J.types=ge.types),Y.T=J}}function Nie(){}function xE(h,g,_,M){if(h.tag!==5)throw Error(r(476));var P=g5(h).queue;p5(h,P,g,Q,_===null?Nie:function(){return x5(h),_(M)})}function g5(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:cc,lastRenderedState:Q},next:null};var _={};return g.next={memoizedState:_,baseState:_,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:cc,lastRenderedState:_},next:null},h.memoizedState=g,h=h.alternate,h!==null&&(h.memoizedState=g),g}function x5(h){var g=g5(h);g.next===null&&(g=h.alternate.memoizedState),Tx(h,g.next.queue,{},Rs())}function bE(){return la(Vx)}function b5(){return li().memoizedState}function y5(){return li().memoizedState}function Mie(h){for(var g=h.return;g!==null;){switch(g.tag){case 24:case 3:var _=Rs();h=Au(_);var M=Cu(g,h,_);M!==null&&(cs(M,g,_),wx(M,g,_)),g={cache:qM()},h.payload=g;return}g=g.return}}function Eie(h,g,_){var M=Rs();_={lane:M,revertLane:0,gesture:null,action:_,hasEagerState:!1,eagerState:null,next:null},yv(h)?_5(g,_):(_=LM(h,g,_,M),_!==null&&(cs(_,h,M),w5(_,g,M)))}function v5(h,g,_){var M=Rs();Tx(h,g,_,M)}function Tx(h,g,_,M){var P={lane:M,revertLane:0,gesture:null,action:_,hasEagerState:!1,eagerState:null,next:null};if(yv(h))_5(g,P);else{var I=h.alternate;if(h.lanes===0&&(I===null||I.lanes===0)&&(I=g.lastRenderedReducer,I!==null))try{var J=g.lastRenderedState,ge=I(J,_);if(P.hasEagerState=!0,P.eagerState=ge,Ts(ge,J))return Jy(h,g,P,0),yr===null&&Zy(),!1}catch{}finally{}if(_=LM(h,g,P,M),_!==null)return cs(_,h,M),w5(_,g,M),!0}return!1}function yE(h,g,_,M){if(M={lane:2,revertLane:QE(),gesture:null,action:M,hasEagerState:!1,eagerState:null,next:null},yv(h)){if(g)throw Error(r(479))}else g=LM(h,_,M,2),g!==null&&cs(g,h,2)}function yv(h){var g=h.alternate;return h===bn||g!==null&&g===bn}function _5(h,g){wm=hv=!0;var _=h.pending;_===null?g.next=g:(g.next=_.next,_.next=g),h.pending=g}function w5(h,g,_){if((_&4194048)!==0){var M=g.lanes;M&=h.pendingLanes,_|=M,g.lanes=_,bt(h,_)}}var Ax={readContext:la,use:pv,useCallback:Yr,useContext:Yr,useEffect:Yr,useImperativeHandle:Yr,useLayoutEffect:Yr,useInsertionEffect:Yr,useMemo:Yr,useReducer:Yr,useRef:Yr,useState:Yr,useDebugValue:Yr,useDeferredValue:Yr,useTransition:Yr,useSyncExternalStore:Yr,useId:Yr,useHostTransitionStatus:Yr,useFormState:Yr,useActionState:Yr,useOptimistic:Yr,useMemoCache:Yr,useCacheRefresh:Yr};Ax.useEffectEvent=Yr;var S5={readContext:la,use:pv,useCallback:function(h,g){return za().memoizedState=[h,g===void 0?null:g],h},useContext:la,useEffect:s5,useImperativeHandle:function(h,g,_){_=_!=null?_.concat([h]):null,xv(4194308,4,u5.bind(null,g,h),_)},useLayoutEffect:function(h,g){return xv(4194308,4,h,g)},useInsertionEffect:function(h,g){xv(4,2,h,g)},useMemo:function(h,g){var _=za();g=g===void 0?null:g;var M=h();if(Nh){te(!0);try{h()}finally{te(!1)}}return _.memoizedState=[M,g],M},useReducer:function(h,g,_){var M=za();if(_!==void 0){var P=_(g);if(Nh){te(!0);try{_(g)}finally{te(!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=Eie.bind(null,bn,h),[M.memoizedState,h]},useRef:function(h){var g=za();return h={current:h},g.memoizedState=h},useState:function(h){h=hE(h);var g=h.queue,_=v5.bind(null,bn,g);return g.dispatch=_,[h.memoizedState,_]},useDebugValue:pE,useDeferredValue:function(h,g){var _=za();return gE(_,h,g)},useTransition:function(){var h=hE(!1);return h=p5.bind(null,bn,h.queue,!0,!1),za().memoizedState=h,[!1,h]},useSyncExternalStore:function(h,g,_){var M=bn,P=za();if(Un){if(_===void 0)throw Error(r(407));_=_()}else{if(_=g(),yr===null)throw Error(r(349));(Ln&127)!==0||VI(M,g,_)}P.memoizedState=_;var I={value:_,getSnapshot:g};return P.queue=I,s5(WI.bind(null,M,I,h),[h]),M.flags|=2048,Nm(9,{destroy:void 0},GI.bind(null,M,I,_,g),null),_},useId:function(){var h=za(),g=yr.identifierPrefix;if(Un){var _=xl,M=gl;_=(M&~(1<<32-Se(M)-1)).toString(32)+_,g="_"+g+"R_"+_,_=fv++,0<_&&(g+="H"+_.toString(32)),g+="_"}else _=yie++,g="_"+g+"r_"+_.toString(32)+"_";return h.memoizedState=g},useHostTransitionStatus:bE,useFormState:t5,useActionState:t5,useOptimistic:function(h){var g=za();g.memoizedState=g.baseState=h;var _={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return g.queue=_,g=yE.bind(null,bn,!0,_),_.dispatch=g,[h,g]},useMemoCache:cE,useCacheRefresh:function(){return za().memoizedState=Mie.bind(null,bn)},useEffectEvent:function(h){var g=za(),_={impl:h};return g.memoizedState=_,function(){if((Yn&2)!==0)throw Error(r(440));return _.impl.apply(void 0,arguments)}}},vE={readContext:la,use:pv,useCallback:h5,useContext:la,useEffect:mE,useImperativeHandle:d5,useInsertionEffect:l5,useLayoutEffect:c5,useMemo:f5,useReducer:gv,useRef:a5,useState:function(){return gv(cc)},useDebugValue:pE,useDeferredValue:function(h,g){var _=li();return m5(_,lr.memoizedState,h,g)},useTransition:function(){var h=gv(cc)[0],g=li().memoizedState;return[typeof h=="boolean"?h:Ex(h),g]},useSyncExternalStore:HI,useId:b5,useHostTransitionStatus:bE,useFormState:n5,useActionState:n5,useOptimistic:function(h,g){var _=li();return XI(_,lr,h,g)},useMemoCache:cE,useCacheRefresh:y5};vE.useEffectEvent=o5;var N5={readContext:la,use:pv,useCallback:h5,useContext:la,useEffect:mE,useImperativeHandle:d5,useInsertionEffect:l5,useLayoutEffect:c5,useMemo:f5,useReducer:dE,useRef:a5,useState:function(){return dE(cc)},useDebugValue:pE,useDeferredValue:function(h,g){var _=li();return lr===null?gE(_,h,g):m5(_,lr.memoizedState,h,g)},useTransition:function(){var h=dE(cc)[0],g=li().memoizedState;return[typeof h=="boolean"?h:Ex(h),g]},useSyncExternalStore:HI,useId:b5,useHostTransitionStatus:bE,useFormState:i5,useActionState:i5,useOptimistic:function(h,g){var _=li();return lr!==null?XI(_,lr,h,g):(_.baseState=h,[h,_.queue.dispatch])},useMemoCache:cE,useCacheRefresh:y5};N5.useEffectEvent=o5;function _E(h,g,_,M){g=h.memoizedState,_=_(M,g),_=_==null?g:f({},g,_),h.memoizedState=_,h.lanes===0&&(h.updateQueue.baseState=_)}var wE={enqueueSetState:function(h,g,_){h=h._reactInternals;var M=Rs(),P=Au(M);P.payload=g,_!=null&&(P.callback=_),g=Cu(h,P,M),g!==null&&(cs(g,h,M),wx(g,h,M))},enqueueReplaceState:function(h,g,_){h=h._reactInternals;var M=Rs(),P=Au(M);P.tag=1,P.payload=g,_!=null&&(P.callback=_),g=Cu(h,P,M),g!==null&&(cs(g,h,M),wx(g,h,M))},enqueueForceUpdate:function(h,g){h=h._reactInternals;var _=Rs(),M=Au(_);M.tag=2,g!=null&&(M.callback=g),g=Cu(h,M,_),g!==null&&(cs(g,h,_),wx(g,h,_))}};function M5(h,g,_,M,P,I,J){return h=h.stateNode,typeof h.shouldComponentUpdate=="function"?h.shouldComponentUpdate(M,I,J):g.prototype&&g.prototype.isPureReactComponent?!mx(_,M)||!mx(P,I):!0}function E5(h,g,_,M){h=g.state,typeof g.componentWillReceiveProps=="function"&&g.componentWillReceiveProps(_,M),typeof g.UNSAFE_componentWillReceiveProps=="function"&&g.UNSAFE_componentWillReceiveProps(_,M),g.state!==h&&wE.enqueueReplaceState(g,g.state,null)}function Mh(h,g){var _=g;if("ref"in g){_={};for(var M in g)M!=="ref"&&(_[M]=g[M])}if(h=h.defaultProps){_===g&&(_=f({},_));for(var P in h)_[P]===void 0&&(_[P]=h[P])}return _}function T5(h){Qy(h)}function A5(h){console.error(h)}function C5(h){Qy(h)}function vv(h,g){try{var _=h.onUncaughtError;_(g.value,{componentStack:g.stack})}catch(M){setTimeout(function(){throw M})}}function k5(h,g,_){try{var M=h.onCaughtError;M(_.value,{componentStack:_.stack,errorBoundary:g.tag===1?g.stateNode:null})}catch(P){setTimeout(function(){throw P})}}function SE(h,g,_){return _=Au(_),_.tag=3,_.payload={element:null},_.callback=function(){vv(h,g)},_}function j5(h){return h=Au(h),h.tag=3,h}function P5(h,g,_,M){var P=_.type.getDerivedStateFromError;if(typeof P=="function"){var I=M.value;h.payload=function(){return P(I)},h.callback=function(){k5(g,_,M)}}var J=_.stateNode;J!==null&&typeof J.componentDidCatch=="function"&&(h.callback=function(){k5(g,_,M),typeof P!="function"&&(Ou===null?Ou=new Set([this]):Ou.add(this));var ge=M.stack;this.componentDidCatch(M.value,{componentStack:ge!==null?ge:""})})}function Tie(h,g,_,M,P){if(_.flags|=32768,M!==null&&typeof M=="object"&&typeof M.then=="function"){if(g=_.alternate,g!==null&&gm(g,_,P,!0),_=Cs.current,_!==null){switch(_.tag){case 31:case 13:return ao===null?Pv():_.alternate===null&&Qr===0&&(Qr=3),_.flags&=-257,_.flags|=65536,_.lanes=P,M===ov?_.flags|=16384:(g=_.updateQueue,g===null?_.updateQueue=new Set([M]):g.add(M),KE(h,M,P)),!1;case 22:return _.flags|=65536,M===ov?_.flags|=16384:(g=_.updateQueue,g===null?(g={transitions:null,markerInstances:null,retryQueue:new Set([M])},_.updateQueue=g):(_=g.retryQueue,_===null?g.retryQueue=new Set([M]):_.add(M)),KE(h,M,P)),!1}throw Error(r(435,_.tag))}return KE(h,M,P),Pv(),!1}if(Un)return g=Cs.current,g!==null?((g.flags&65536)===0&&(g.flags|=256),g.flags|=65536,g.lanes=P,M!==$M&&(h=Error(r(422),{cause:M}),xx(to(h,_)))):(M!==$M&&(g=Error(r(423),{cause:M}),xx(to(g,_))),h=h.current.alternate,h.flags|=65536,P&=-P,h.lanes|=P,M=to(M,_),P=SE(h.stateNode,M,P),JM(h,P),Qr!==4&&(Qr=2)),!1;var I=Error(r(520),{cause:M});if(I=to(I,_),Lx===null?Lx=[I]:Lx.push(I),Qr!==4&&(Qr=2),g===null)return!0;M=to(M,_),_=g;do{switch(_.tag){case 3:return _.flags|=65536,h=P&-P,_.lanes|=h,h=SE(_.stateNode,M,h),JM(_,h),!1;case 1:if(g=_.type,I=_.stateNode,(_.flags&128)===0&&(typeof g.getDerivedStateFromError=="function"||I!==null&&typeof I.componentDidCatch=="function"&&(Ou===null||!Ou.has(I))))return _.flags|=65536,P&=-P,_.lanes|=P,P=j5(P),P5(P,h,_,M),JM(_,P),!1}_=_.return}while(_!==null);return!1}var NE=Error(r(461)),pi=!1;function ca(h,g,_,M){g.child=h===null?LI(g,null,_,M):Sh(g,h.child,_,M)}function R5(h,g,_,M,P){_=_.render;var I=g.ref;if("ref"in M){var J={};for(var ge in M)ge!=="ref"&&(J[ge]=M[ge])}else J=M;return yh(g),M=aE(h,g,_,J,I,P),ge=sE(),h!==null&&!pi?(oE(h,g,P),uc(h,g,P)):(Un&&ge&&zM(g),g.flags|=1,ca(h,g,M,P),g.child)}function D5(h,g,_,M,P){if(h===null){var I=_.type;return typeof I=="function"&&!IM(I)&&I.defaultProps===void 0&&_.compare===null?(g.tag=15,g.type=I,O5(h,g,I,M,P)):(h=tv(_.type,null,M,g,g.mode,P),h.ref=g.ref,h.return=g,g.child=h)}if(I=h.child,!PE(h,P)){var J=I.memoizedProps;if(_=_.compare,_=_!==null?_:mx,_(J,M)&&h.ref===g.ref)return uc(h,g,P)}return g.flags|=1,h=ic(I,M),h.ref=g.ref,h.return=g,g.child=h}function O5(h,g,_,M,P){if(h!==null){var I=h.memoizedProps;if(mx(I,M)&&h.ref===g.ref)if(pi=!1,g.pendingProps=M=I,PE(h,P))(h.flags&131072)!==0&&(pi=!0);else return g.lanes=h.lanes,uc(h,g,P)}return ME(h,g,_,M,P)}function L5(h,g,_,M){var P=M.children,I=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(I=I!==null?I.baseLanes|_:_,h!==null){for(M=g.child=h.child,P=0;M!==null;)P=P|M.lanes|M.childLanes,M=M.sibling;M=P&~I}else M=0,g.child=null;return I5(h,g,I,_,M)}if((_&536870912)!==0)g.memoizedState={baseLanes:0,cachePool:null},h!==null&&av(g,I!==null?I.cachePool:null),I!==null?UI(g,I):tE(),zI(g);else return M=g.lanes=536870912,I5(h,g,I!==null?I.baseLanes|_:_,_,M)}else I!==null?(av(g,I.cachePool),UI(g,I),ju(),g.memoizedState=null):(h!==null&&av(g,null),tE(),ju());return ca(h,g,P,_),g.child}function Cx(h,g){return h!==null&&h.tag===22||g.stateNode!==null||(g.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),g.sibling}function I5(h,g,_,M,P){var I=XM();return I=I===null?null:{parent:fi._currentValue,pool:I},g.memoizedState={baseLanes:_,cachePool:I},h!==null&&av(g,null),tE(),zI(g),h!==null&&gm(h,g,M,!0),g.childLanes=P,null}function _v(h,g){return g=Sv({mode:g.mode,children:g.children},h.mode),g.ref=h.ref,h.child=g,g.return=h,g}function F5(h,g,_){return Sh(g,h.child,null,_),h=_v(g,g.pendingProps),h.flags|=2,ks(g),g.memoizedState=null,h}function Aie(h,g,_){var M=g.pendingProps,P=(g.flags&128)!==0;if(g.flags&=-129,h===null){if(Un){if(M.mode==="hidden")return h=_v(g,M),g.lanes=536870912,Cx(null,h);if(rE(g),(h=Tr)?(h=YF(h,io),h=h!==null&&h.data==="&"?h:null,h!==null&&(g.memoizedState={dehydrated:h,treeContext:Su!==null?{id:gl,overflow:xl}:null,retryLane:536870912,hydrationErrors:null},_=_I(h),_.return=g,g.child=_,oa=g,Tr=null)):h=null,h===null)throw Mu(g);return g.lanes=536870912,null}return _v(g,M)}var I=h.memoizedState;if(I!==null){var J=I.dehydrated;if(rE(g),P)if(g.flags&256)g.flags&=-257,g=F5(h,g,_);else if(g.memoizedState!==null)g.child=h.child,g.flags|=128,g=null;else throw Error(r(558));else if(pi||gm(h,g,_,!1),P=(_&h.childLanes)!==0,pi||P){if(M=yr,M!==null&&(J=Gt(M,_),J!==0&&J!==I.retryLane))throw I.retryLane=J,ph(h,J),cs(M,h,J),NE;Pv(),g=F5(h,g,_)}else h=I.treeContext,Tr=so(J.nextSibling),oa=g,Un=!0,Nu=null,io=!1,h!==null&&NI(g,h),g=_v(g,M),g.flags|=4096;return g}return h=ic(h.child,{mode:M.mode,children:M.children}),h.ref=g.ref,g.child=h,h.return=g,h}function wv(h,g){var _=g.ref;if(_===null)h!==null&&h.ref!==null&&(g.flags|=4194816);else{if(typeof _!="function"&&typeof _!="object")throw Error(r(284));(h===null||h.ref!==_)&&(g.flags|=4194816)}}function ME(h,g,_,M,P){return yh(g),_=aE(h,g,_,M,void 0,P),M=sE(),h!==null&&!pi?(oE(h,g,P),uc(h,g,P)):(Un&&M&&zM(g),g.flags|=1,ca(h,g,_,P),g.child)}function U5(h,g,_,M,P,I){return yh(g),g.updateQueue=null,_=$I(g,M,_,P),BI(h),M=sE(),h!==null&&!pi?(oE(h,g,I),uc(h,g,I)):(Un&&M&&zM(g),g.flags|=1,ca(h,g,_,I),g.child)}function z5(h,g,_,M,P){if(yh(g),g.stateNode===null){var I=hm,J=_.contextType;typeof J=="object"&&J!==null&&(I=la(J)),I=new _(M,I),g.memoizedState=I.state!==null&&I.state!==void 0?I.state:null,I.updater=wE,g.stateNode=I,I._reactInternals=g,I=g.stateNode,I.props=M,I.state=g.memoizedState,I.refs={},QM(g),J=_.contextType,I.context=typeof J=="object"&&J!==null?la(J):hm,I.state=g.memoizedState,J=_.getDerivedStateFromProps,typeof J=="function"&&(_E(g,_,J,M),I.state=g.memoizedState),typeof _.getDerivedStateFromProps=="function"||typeof I.getSnapshotBeforeUpdate=="function"||typeof I.UNSAFE_componentWillMount!="function"&&typeof I.componentWillMount!="function"||(J=I.state,typeof I.componentWillMount=="function"&&I.componentWillMount(),typeof I.UNSAFE_componentWillMount=="function"&&I.UNSAFE_componentWillMount(),J!==I.state&&wE.enqueueReplaceState(I,I.state,null),Nx(g,M,I,P),Sx(),I.state=g.memoizedState),typeof I.componentDidMount=="function"&&(g.flags|=4194308),M=!0}else if(h===null){I=g.stateNode;var ge=g.memoizedProps,Ie=Mh(_,ge);I.props=Ie;var it=I.context,yt=_.contextType;J=hm,typeof yt=="object"&&yt!==null&&(J=la(yt));var _t=_.getDerivedStateFromProps;yt=typeof _t=="function"||typeof I.getSnapshotBeforeUpdate=="function",ge=g.pendingProps!==ge,yt||typeof I.UNSAFE_componentWillReceiveProps!="function"&&typeof I.componentWillReceiveProps!="function"||(ge||it!==J)&&E5(g,I,M,J),Tu=!1;var st=g.memoizedState;I.state=st,Nx(g,M,I,P),Sx(),it=g.memoizedState,ge||st!==it||Tu?(typeof _t=="function"&&(_E(g,_,_t,M),it=g.memoizedState),(Ie=Tu||M5(g,_,Ie,M,st,it,J))?(yt||typeof I.UNSAFE_componentWillMount!="function"&&typeof I.componentWillMount!="function"||(typeof I.componentWillMount=="function"&&I.componentWillMount(),typeof I.UNSAFE_componentWillMount=="function"&&I.UNSAFE_componentWillMount()),typeof I.componentDidMount=="function"&&(g.flags|=4194308)):(typeof I.componentDidMount=="function"&&(g.flags|=4194308),g.memoizedProps=M,g.memoizedState=it),I.props=M,I.state=it,I.context=J,M=Ie):(typeof I.componentDidMount=="function"&&(g.flags|=4194308),M=!1)}else{I=g.stateNode,ZM(h,g),J=g.memoizedProps,yt=Mh(_,J),I.props=yt,_t=g.pendingProps,st=I.context,it=_.contextType,Ie=hm,typeof it=="object"&&it!==null&&(Ie=la(it)),ge=_.getDerivedStateFromProps,(it=typeof ge=="function"||typeof I.getSnapshotBeforeUpdate=="function")||typeof I.UNSAFE_componentWillReceiveProps!="function"&&typeof I.componentWillReceiveProps!="function"||(J!==_t||st!==Ie)&&E5(g,I,M,Ie),Tu=!1,st=g.memoizedState,I.state=st,Nx(g,M,I,P),Sx();var ft=g.memoizedState;J!==_t||st!==ft||Tu||h!==null&&h.dependencies!==null&&rv(h.dependencies)?(typeof ge=="function"&&(_E(g,_,ge,M),ft=g.memoizedState),(yt=Tu||M5(g,_,yt,M,st,ft,Ie)||h!==null&&h.dependencies!==null&&rv(h.dependencies))?(it||typeof I.UNSAFE_componentWillUpdate!="function"&&typeof I.componentWillUpdate!="function"||(typeof I.componentWillUpdate=="function"&&I.componentWillUpdate(M,ft,Ie),typeof I.UNSAFE_componentWillUpdate=="function"&&I.UNSAFE_componentWillUpdate(M,ft,Ie)),typeof I.componentDidUpdate=="function"&&(g.flags|=4),typeof I.getSnapshotBeforeUpdate=="function"&&(g.flags|=1024)):(typeof I.componentDidUpdate!="function"||J===h.memoizedProps&&st===h.memoizedState||(g.flags|=4),typeof I.getSnapshotBeforeUpdate!="function"||J===h.memoizedProps&&st===h.memoizedState||(g.flags|=1024),g.memoizedProps=M,g.memoizedState=ft),I.props=M,I.state=ft,I.context=Ie,M=yt):(typeof I.componentDidUpdate!="function"||J===h.memoizedProps&&st===h.memoizedState||(g.flags|=4),typeof I.getSnapshotBeforeUpdate!="function"||J===h.memoizedProps&&st===h.memoizedState||(g.flags|=1024),M=!1)}return I=M,wv(h,g),M=(g.flags&128)!==0,I||M?(I=g.stateNode,_=M&&typeof _.getDerivedStateFromError!="function"?null:I.render(),g.flags|=1,h!==null&&M?(g.child=Sh(g,h.child,null,P),g.child=Sh(g,null,_,P)):ca(h,g,_,P),g.memoizedState=I.state,h=g.child):h=uc(h,g,P),h}function B5(h,g,_,M){return xh(),g.flags|=256,ca(h,g,_,M),g.child}var EE={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function TE(h){return{baseLanes:h,cachePool:kI()}}function AE(h,g,_){return h=h!==null?h.childLanes&~_:0,g&&(h|=Ps),h}function $5(h,g,_){var M=g.pendingProps,P=!1,I=(g.flags&128)!==0,J;if((J=I)||(J=h!==null&&h.memoizedState===null?!1:(oi.current&2)!==0),J&&(P=!0,g.flags&=-129),J=(g.flags&32)!==0,g.flags&=-33,h===null){if(Un){if(P?ku(g):ju(),(h=Tr)?(h=YF(h,io),h=h!==null&&h.data!=="&"?h:null,h!==null&&(g.memoizedState={dehydrated:h,treeContext:Su!==null?{id:gl,overflow:xl}:null,retryLane:536870912,hydrationErrors:null},_=_I(h),_.return=g,g.child=_,oa=g,Tr=null)):h=null,h===null)throw Mu(g);return uT(h)?g.lanes=32:g.lanes=536870912,null}var ge=M.children;return M=M.fallback,P?(ju(),P=g.mode,ge=Sv({mode:"hidden",children:ge},P),M=gh(M,P,_,null),ge.return=g,M.return=g,ge.sibling=M,g.child=ge,M=g.child,M.memoizedState=TE(_),M.childLanes=AE(h,J,_),g.memoizedState=EE,Cx(null,M)):(ku(g),CE(g,ge))}var Ie=h.memoizedState;if(Ie!==null&&(ge=Ie.dehydrated,ge!==null)){if(I)g.flags&256?(ku(g),g.flags&=-257,g=kE(h,g,_)):g.memoizedState!==null?(ju(),g.child=h.child,g.flags|=128,g=null):(ju(),ge=M.fallback,P=g.mode,M=Sv({mode:"visible",children:M.children},P),ge=gh(ge,P,_,null),ge.flags|=2,M.return=g,ge.return=g,M.sibling=ge,g.child=M,Sh(g,h.child,null,_),M=g.child,M.memoizedState=TE(_),M.childLanes=AE(h,J,_),g.memoizedState=EE,g=Cx(null,M));else if(ku(g),uT(ge)){if(J=ge.nextSibling&&ge.nextSibling.dataset,J)var it=J.dgst;J=it,M=Error(r(419)),M.stack="",M.digest=J,xx({value:M,source:null,stack:null}),g=kE(h,g,_)}else if(pi||gm(h,g,_,!1),J=(_&h.childLanes)!==0,pi||J){if(J=yr,J!==null&&(M=Gt(J,_),M!==0&&M!==Ie.retryLane))throw Ie.retryLane=M,ph(h,M),cs(J,h,M),NE;cT(ge)||Pv(),g=kE(h,g,_)}else cT(ge)?(g.flags|=192,g.child=h.child,g=null):(h=Ie.treeContext,Tr=so(ge.nextSibling),oa=g,Un=!0,Nu=null,io=!1,h!==null&&NI(g,h),g=CE(g,M.children),g.flags|=4096);return g}return P?(ju(),ge=M.fallback,P=g.mode,Ie=h.child,it=Ie.sibling,M=ic(Ie,{mode:"hidden",children:M.children}),M.subtreeFlags=Ie.subtreeFlags&65011712,it!==null?ge=ic(it,ge):(ge=gh(ge,P,_,null),ge.flags|=2),ge.return=g,M.return=g,M.sibling=ge,g.child=M,Cx(null,M),M=g.child,ge=h.child.memoizedState,ge===null?ge=TE(_):(P=ge.cachePool,P!==null?(Ie=fi._currentValue,P=P.parent!==Ie?{parent:Ie,pool:Ie}:P):P=kI(),ge={baseLanes:ge.baseLanes|_,cachePool:P}),M.memoizedState=ge,M.childLanes=AE(h,J,_),g.memoizedState=EE,Cx(h.child,M)):(ku(g),_=h.child,h=_.sibling,_=ic(_,{mode:"visible",children:M.children}),_.return=g,_.sibling=null,h!==null&&(J=g.deletions,J===null?(g.deletions=[h],g.flags|=16):J.push(h)),g.child=_,g.memoizedState=null,_)}function CE(h,g){return g=Sv({mode:"visible",children:g},h.mode),g.return=h,h.child=g}function Sv(h,g){return h=As(22,h,null,g),h.lanes=0,h}function kE(h,g,_){return Sh(g,h.child,null,_),h=CE(g,g.pendingProps.children),h.flags|=2,g.memoizedState=null,h}function H5(h,g,_){h.lanes|=g;var M=h.alternate;M!==null&&(M.lanes|=g),GM(h.return,g,_)}function jE(h,g,_,M,P,I){var J=h.memoizedState;J===null?h.memoizedState={isBackwards:g,rendering:null,renderingStartTime:0,last:M,tail:_,tailMode:P,treeForkCount:I}:(J.isBackwards=g,J.rendering=null,J.renderingStartTime=0,J.last=M,J.tail=_,J.tailMode=P,J.treeForkCount=I)}function V5(h,g,_){var M=g.pendingProps,P=M.revealOrder,I=M.tail;M=M.children;var J=oi.current,ge=(J&2)!==0;if(ge?(J=J&1|2,g.flags|=128):J&=1,ae(oi,J),ca(h,g,M,_),M=Un?gx:0,!ge&&h!==null&&(h.flags&128)!==0)e:for(h=g.child;h!==null;){if(h.tag===13)h.memoizedState!==null&&H5(h,_,g);else if(h.tag===19)H5(h,_,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(_=g.child,P=null;_!==null;)h=_.alternate,h!==null&&dv(h)===null&&(P=_),_=_.sibling;_=P,_===null?(P=g.child,g.child=null):(P=_.sibling,_.sibling=null),jE(g,!1,P,_,I,M);break;case"backwards":case"unstable_legacy-backwards":for(_=null,P=g.child,g.child=null;P!==null;){if(h=P.alternate,h!==null&&dv(h)===null){g.child=P;break}h=P.sibling,P.sibling=_,_=P,P=h}jE(g,!0,_,null,I,M);break;case"together":jE(g,!1,null,null,void 0,M);break;default:g.memoizedState=null}return g.child}function uc(h,g,_){if(h!==null&&(g.dependencies=h.dependencies),Du|=g.lanes,(_&g.childLanes)===0)if(h!==null){if(gm(h,g,_,!1),(_&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,_=ic(h,h.pendingProps),g.child=_,_.return=g;h.sibling!==null;)h=h.sibling,_=_.sibling=ic(h,h.pendingProps),_.return=g;_.sibling=null}return g.child}function PE(h,g){return(h.lanes&g)!==0?!0:(h=h.dependencies,!!(h!==null&&rv(h)))}function Cie(h,g,_){switch(g.tag){case 3:Me(g,g.stateNode.containerInfo),Eu(g,fi,h.memoizedState.cache),xh();break;case 27:case 5:Ee(g);break;case 4:Me(g,g.stateNode.containerInfo);break;case 10:Eu(g,g.type,g.memoizedProps.value);break;case 31:if(g.memoizedState!==null)return g.flags|=128,rE(g),null;break;case 13:var M=g.memoizedState;if(M!==null)return M.dehydrated!==null?(ku(g),g.flags|=128,null):(_&g.child.childLanes)!==0?$5(h,g,_):(ku(g),h=uc(h,g,_),h!==null?h.sibling:null);ku(g);break;case 19:var P=(h.flags&128)!==0;if(M=(_&g.childLanes)!==0,M||(gm(h,g,_,!1),M=(_&g.childLanes)!==0),P){if(M)return V5(h,g,_);g.flags|=128}if(P=g.memoizedState,P!==null&&(P.rendering=null,P.tail=null,P.lastEffect=null),ae(oi,oi.current),M)break;return null;case 22:return g.lanes=0,L5(h,g,_,g.pendingProps);case 24:Eu(g,fi,h.memoizedState.cache)}return uc(h,g,_)}function G5(h,g,_){if(h!==null)if(h.memoizedProps!==g.pendingProps)pi=!0;else{if(!PE(h,_)&&(g.flags&128)===0)return pi=!1,Cie(h,g,_);pi=(h.flags&131072)!==0}else pi=!1,Un&&(g.flags&1048576)!==0&&SI(g,gx,g.index);switch(g.lanes=0,g.tag){case 16:e:{var M=g.pendingProps;if(h=_h(g.elementType),g.type=h,typeof h=="function")IM(h)?(M=Mh(h,M),g.tag=1,g=z5(null,g,h,M,_)):(g.tag=0,g=ME(null,g,h,M,_));else{if(h!=null){var P=h.$$typeof;if(P===T){g.tag=11,g=R5(null,g,h,M,_);break e}else if(P===A){g.tag=14,g=D5(null,g,h,M,_);break e}}throw g=j(h)||h,Error(r(306,g,""))}}return g;case 0:return ME(h,g,g.type,g.pendingProps,_);case 1:return M=g.type,P=Mh(M,g.pendingProps),z5(h,g,M,P,_);case 3:e:{if(Me(g,g.stateNode.containerInfo),h===null)throw Error(r(387));M=g.pendingProps;var I=g.memoizedState;P=I.element,ZM(h,g),Nx(g,M,null,_);var J=g.memoizedState;if(M=J.cache,Eu(g,fi,M),M!==I.cache&&WM(g,[fi],_,!0),Sx(),M=J.element,I.isDehydrated)if(I={element:M,isDehydrated:!1,cache:J.cache},g.updateQueue.baseState=I,g.memoizedState=I,g.flags&256){g=B5(h,g,M,_);break e}else if(M!==P){P=to(Error(r(424)),g),xx(P),g=B5(h,g,M,_);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(Tr=so(h.firstChild),oa=g,Un=!0,Nu=null,io=!0,_=LI(g,null,M,_),g.child=_;_;)_.flags=_.flags&-3|4096,_=_.sibling}else{if(xh(),M===P){g=uc(h,g,_);break e}ca(h,g,M,_)}g=g.child}return g;case 26:return wv(h,g),h===null?(_=nU(g.type,null,g.pendingProps,null))?g.memoizedState=_:Un||(_=g.type,h=g.pendingProps,M=Uv(pe.current).createElement(_),M[sn]=g,M[Sr]=h,ua(M,_,h),He(M),g.stateNode=M):g.memoizedState=nU(g.type,h.memoizedProps,g.pendingProps,h.memoizedState),null;case 27:return Ee(g),h===null&&Un&&(M=g.stateNode=JF(g.type,g.pendingProps,pe.current),oa=g,io=!0,P=Tr,Uu(g.type)?(dT=P,Tr=so(M.firstChild)):Tr=P),ca(h,g,g.pendingProps.children,_),wv(h,g),h===null&&(g.flags|=4194304),g.child;case 5:return h===null&&Un&&((P=M=Tr)&&(M=aae(M,g.type,g.pendingProps,io),M!==null?(g.stateNode=M,oa=g,Tr=so(M.firstChild),io=!1,P=!0):P=!1),P||Mu(g)),Ee(g),P=g.type,I=g.pendingProps,J=h!==null?h.memoizedProps:null,M=I.children,sT(P,I)?M=null:J!==null&&sT(P,J)&&(g.flags|=32),g.memoizedState!==null&&(P=aE(h,g,vie,null,null,_),Vx._currentValue=P),wv(h,g),ca(h,g,M,_),g.child;case 6:return h===null&&Un&&((h=_=Tr)&&(_=sae(_,g.pendingProps,io),_!==null?(g.stateNode=_,oa=g,Tr=null,h=!0):h=!1),h||Mu(g)),null;case 13:return $5(h,g,_);case 4:return Me(g,g.stateNode.containerInfo),M=g.pendingProps,h===null?g.child=Sh(g,null,M,_):ca(h,g,M,_),g.child;case 11:return R5(h,g,g.type,g.pendingProps,_);case 7:return ca(h,g,g.pendingProps,_),g.child;case 8:return ca(h,g,g.pendingProps.children,_),g.child;case 12:return ca(h,g,g.pendingProps.children,_),g.child;case 10:return M=g.pendingProps,Eu(g,g.type,M.value),ca(h,g,M.children,_),g.child;case 9:return P=g.type._context,M=g.pendingProps.children,yh(g),P=la(P),M=M(P),g.flags|=1,ca(h,g,M,_),g.child;case 14:return D5(h,g,g.type,g.pendingProps,_);case 15:return O5(h,g,g.type,g.pendingProps,_);case 19:return V5(h,g,_);case 31:return Aie(h,g,_);case 22:return L5(h,g,_,g.pendingProps);case 24:return yh(g),M=la(fi),h===null?(P=XM(),P===null&&(P=yr,I=qM(),P.pooledCache=I,I.refCount++,I!==null&&(P.pooledCacheLanes|=_),P=I),g.memoizedState={parent:M,cache:P},QM(g),Eu(g,fi,P)):((h.lanes&_)!==0&&(ZM(h,g),Nx(g,null,null,_),Sx()),P=h.memoizedState,I=g.memoizedState,P.parent!==M?(P={parent:M,cache:M},g.memoizedState=P,g.lanes===0&&(g.memoizedState=g.updateQueue.baseState=P),Eu(g,fi,M)):(M=I.cache,Eu(g,fi,M),M!==P.cache&&WM(g,[fi],_,!0))),ca(h,g,g.pendingProps.children,_),g.child;case 29:throw g.pendingProps}throw Error(r(156,g.tag))}function dc(h){h.flags|=4}function RE(h,g,_,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(bF())h.flags|=8192;else throw wh=ov,YM}else h.flags&=-16777217}function W5(h,g){if(g.type!=="stylesheet"||(g.state.loading&4)!==0)h.flags&=-16777217;else if(h.flags|=16777216,!oU(g))if(bF())h.flags|=8192;else throw wh=ov,YM}function Nv(h,g){g!==null&&(h.flags|=4),h.flags&16384&&(g=h.tag!==22?Pt():536870912,h.lanes|=g,Am|=g)}function kx(h,g){if(!Un)switch(h.tailMode){case"hidden":g=h.tail;for(var _=null;g!==null;)g.alternate!==null&&(_=g),g=g.sibling;_===null?h.tail=null:_.sibling=null;break;case"collapsed":_=h.tail;for(var M=null;_!==null;)_.alternate!==null&&(M=_),_=_.sibling;M===null?g||h.tail===null?h.tail=null:h.tail.sibling=null:M.sibling=null}}function Ar(h){var g=h.alternate!==null&&h.alternate.child===h.child,_=0,M=0;if(g)for(var P=h.child;P!==null;)_|=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;)_|=P.lanes|P.childLanes,M|=P.subtreeFlags,M|=P.flags,P.return=h,P=P.sibling;return h.subtreeFlags|=M,h.childLanes=_,g}function kie(h,g,_){var M=g.pendingProps;switch(BM(g),g.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Ar(g),null;case 1:return Ar(g),null;case 3:return _=g.stateNode,M=null,h!==null&&(M=h.memoizedState.cache),g.memoizedState.cache!==M&&(g.flags|=2048),oc(fi),me(),_.pendingContext&&(_.context=_.pendingContext,_.pendingContext=null),(h===null||h.child===null)&&(pm(g)?dc(g):h===null||h.memoizedState.isDehydrated&&(g.flags&256)===0||(g.flags|=1024,HM())),Ar(g),null;case 26:var P=g.type,I=g.memoizedState;return h===null?(dc(g),I!==null?(Ar(g),W5(g,I)):(Ar(g),RE(g,P,null,M,_))):I?I!==h.memoizedState?(dc(g),Ar(g),W5(g,I)):(Ar(g),g.flags&=-16777217):(h=h.memoizedProps,h!==M&&dc(g),Ar(g),RE(g,P,h,M,_)),null;case 27:if(fe(g),_=pe.current,P=g.type,h!==null&&g.stateNode!=null)h.memoizedProps!==M&&dc(g);else{if(!M){if(g.stateNode===null)throw Error(r(166));return Ar(g),null}h=se.current,pm(g)?MI(g):(h=JF(P,M,_),g.stateNode=h,dc(g))}return Ar(g),null;case 5:if(fe(g),P=g.type,h!==null&&g.stateNode!=null)h.memoizedProps!==M&&dc(g);else{if(!M){if(g.stateNode===null)throw Error(r(166));return Ar(g),null}if(I=se.current,pm(g))MI(g);else{var J=Uv(pe.current);switch(I){case 1:I=J.createElementNS("http://www.w3.org/2000/svg",P);break;case 2:I=J.createElementNS("http://www.w3.org/1998/Math/MathML",P);break;default:switch(P){case"svg":I=J.createElementNS("http://www.w3.org/2000/svg",P);break;case"math":I=J.createElementNS("http://www.w3.org/1998/Math/MathML",P);break;case"script":I=J.createElement("div"),I.innerHTML="<script><\/script>",I=I.removeChild(I.firstChild);break;case"select":I=typeof M.is=="string"?J.createElement("select",{is:M.is}):J.createElement("select"),M.multiple?I.multiple=!0:M.size&&(I.size=M.size);break;default:I=typeof M.is=="string"?J.createElement(P,{is:M.is}):J.createElement(P)}}I[sn]=g,I[Sr]=M;e:for(J=g.child;J!==null;){if(J.tag===5||J.tag===6)I.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=I;e:switch(ua(I,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&&dc(g)}}return Ar(g),RE(g,g.type,h===null?null:h.memoizedProps,g.pendingProps,_),null;case 6:if(h&&g.stateNode!=null)h.memoizedProps!==M&&dc(g);else{if(typeof M!="string"&&g.stateNode===null)throw Error(r(166));if(h=pe.current,pm(g)){if(h=g.stateNode,_=g.memoizedProps,M=null,P=oa,P!==null)switch(P.tag){case 27:case 5:M=P.memoizedProps}h[sn]=g,h=!!(h.nodeValue===_||M!==null&&M.suppressHydrationWarning===!0||$F(h.nodeValue,_)),h||Mu(g,!0)}else h=Uv(h).createTextNode(M),h[sn]=g,g.stateNode=h}return Ar(g),null;case 31:if(_=g.memoizedState,h===null||h.memoizedState!==null){if(M=pm(g),_!==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[sn]=g}else xh(),(g.flags&128)===0&&(g.memoizedState=null),g.flags|=4;Ar(g),h=!1}else _=HM(),h!==null&&h.memoizedState!==null&&(h.memoizedState.hydrationErrors=_),h=!0;if(!h)return g.flags&256?(ks(g),g):(ks(g),null);if((g.flags&128)!==0)throw Error(r(558))}return Ar(g),null;case 13:if(M=g.memoizedState,h===null||h.memoizedState!==null&&h.memoizedState.dehydrated!==null){if(P=pm(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[sn]=g}else xh(),(g.flags&128)===0&&(g.memoizedState=null),g.flags|=4;Ar(g),P=!1}else P=HM(),h!==null&&h.memoizedState!==null&&(h.memoizedState.hydrationErrors=P),P=!0;if(!P)return g.flags&256?(ks(g),g):(ks(g),null)}return ks(g),(g.flags&128)!==0?(g.lanes=_,g):(_=M!==null,h=h!==null&&h.memoizedState!==null,_&&(M=g.child,P=null,M.alternate!==null&&M.alternate.memoizedState!==null&&M.alternate.memoizedState.cachePool!==null&&(P=M.alternate.memoizedState.cachePool.pool),I=null,M.memoizedState!==null&&M.memoizedState.cachePool!==null&&(I=M.memoizedState.cachePool.pool),I!==P&&(M.flags|=2048)),_!==h&&_&&(g.child.flags|=8192),Nv(g,g.updateQueue),Ar(g),null);case 4:return me(),h===null&&tT(g.stateNode.containerInfo),Ar(g),null;case 10:return oc(g.type),Ar(g),null;case 19:if(G(oi),M=g.memoizedState,M===null)return Ar(g),null;if(P=(g.flags&128)!==0,I=M.rendering,I===null)if(P)kx(M,!1);else{if(Qr!==0||h!==null&&(h.flags&128)!==0)for(h=g.child;h!==null;){if(I=dv(h),I!==null){for(g.flags|=128,kx(M,!1),h=I.updateQueue,g.updateQueue=h,Nv(g,h),g.subtreeFlags=0,h=_,_=g.child;_!==null;)vI(_,h),_=_.sibling;return ae(oi,oi.current&1|2),Un&&ac(g,M.treeForkCount),g.child}h=h.sibling}M.tail!==null&&D()>Cv&&(g.flags|=128,P=!0,kx(M,!1),g.lanes=4194304)}else{if(!P)if(h=dv(I),h!==null){if(g.flags|=128,P=!0,h=h.updateQueue,g.updateQueue=h,Nv(g,h),kx(M,!0),M.tail===null&&M.tailMode==="hidden"&&!I.alternate&&!Un)return Ar(g),null}else 2*D()-M.renderingStartTime>Cv&&_!==536870912&&(g.flags|=128,P=!0,kx(M,!1),g.lanes=4194304);M.isBackwards?(I.sibling=g.child,g.child=I):(h=M.last,h!==null?h.sibling=I:g.child=I,M.last=I)}return M.tail!==null?(h=M.tail,M.rendering=h,M.tail=h.sibling,M.renderingStartTime=D(),h.sibling=null,_=oi.current,ae(oi,P?_&1|2:_&1),Un&&ac(g,M.treeForkCount),h):(Ar(g),null);case 22:case 23:return ks(g),nE(),M=g.memoizedState!==null,h!==null?h.memoizedState!==null!==M&&(g.flags|=8192):M&&(g.flags|=8192),M?(_&536870912)!==0&&(g.flags&128)===0&&(Ar(g),g.subtreeFlags&6&&(g.flags|=8192)):Ar(g),_=g.updateQueue,_!==null&&Nv(g,_.retryQueue),_=null,h!==null&&h.memoizedState!==null&&h.memoizedState.cachePool!==null&&(_=h.memoizedState.cachePool.pool),M=null,g.memoizedState!==null&&g.memoizedState.cachePool!==null&&(M=g.memoizedState.cachePool.pool),M!==_&&(g.flags|=2048),h!==null&&G(vh),null;case 24:return _=null,h!==null&&(_=h.memoizedState.cache),g.memoizedState.cache!==_&&(g.flags|=2048),oc(fi),Ar(g),null;case 25:return null;case 30:return null}throw Error(r(156,g.tag))}function jie(h,g){switch(BM(g),g.tag){case 1:return h=g.flags,h&65536?(g.flags=h&-65537|128,g):null;case 3:return oc(fi),me(),h=g.flags,(h&65536)!==0&&(h&128)===0?(g.flags=h&-65537|128,g):null;case 26:case 27:case 5:return fe(g),null;case 31:if(g.memoizedState!==null){if(ks(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(ks(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 G(oi),null;case 4:return me(),null;case 10:return oc(g.type),null;case 22:case 23:return ks(g),nE(),h!==null&&G(vh),h=g.flags,h&65536?(g.flags=h&-65537|128,g):null;case 24:return oc(fi),null;case 25:return null;default:return null}}function q5(h,g){switch(BM(g),g.tag){case 3:oc(fi),me();break;case 26:case 27:case 5:fe(g);break;case 4:me();break;case 31:g.memoizedState!==null&&ks(g);break;case 13:ks(g);break;case 19:G(oi);break;case 10:oc(g.type);break;case 22:case 23:ks(g),nE(),h!==null&&G(vh);break;case 24:oc(fi)}}function jx(h,g){try{var _=g.updateQueue,M=_!==null?_.lastEffect:null;if(M!==null){var P=M.next;_=P;do{if((_.tag&h)===h){M=void 0;var I=_.create,J=_.inst;M=I(),J.destroy=M}_=_.next}while(_!==P)}}catch(ge){tr(g,g.return,ge)}}function Pu(h,g,_){try{var M=g.updateQueue,P=M!==null?M.lastEffect:null;if(P!==null){var I=P.next;M=I;do{if((M.tag&h)===h){var J=M.inst,ge=J.destroy;if(ge!==void 0){J.destroy=void 0,P=g;var Ie=_,it=ge;try{it()}catch(yt){tr(P,Ie,yt)}}}M=M.next}while(M!==I)}}catch(yt){tr(g,g.return,yt)}}function K5(h){var g=h.updateQueue;if(g!==null){var _=h.stateNode;try{FI(g,_)}catch(M){tr(h,h.return,M)}}}function X5(h,g,_){_.props=Mh(h.type,h.memoizedProps),_.state=h.memoizedState;try{_.componentWillUnmount()}catch(M){tr(h,g,M)}}function Px(h,g){try{var _=h.ref;if(_!==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 _=="function"?h.refCleanup=_(M):_.current=M}}catch(P){tr(h,g,P)}}function bl(h,g){var _=h.ref,M=h.refCleanup;if(_!==null)if(typeof M=="function")try{M()}catch(P){tr(h,g,P)}finally{h.refCleanup=null,h=h.alternate,h!=null&&(h.refCleanup=null)}else if(typeof _=="function")try{_(null)}catch(P){tr(h,g,P)}else _.current=null}function Y5(h){var g=h.type,_=h.memoizedProps,M=h.stateNode;try{e:switch(g){case"button":case"input":case"select":case"textarea":_.autoFocus&&M.focus();break e;case"img":_.src?M.src=_.src:_.srcSet&&(M.srcset=_.srcSet)}}catch(P){tr(h,h.return,P)}}function DE(h,g,_){try{var M=h.stateNode;Jie(M,h.type,_,g),M[Sr]=g}catch(P){tr(h,h.return,P)}}function Q5(h){return h.tag===5||h.tag===3||h.tag===26||h.tag===27&&Uu(h.type)||h.tag===4}function OE(h){e:for(;;){for(;h.sibling===null;){if(h.return===null||Q5(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&&Uu(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 LE(h,g,_){var M=h.tag;if(M===5||M===6)h=h.stateNode,g?(_.nodeType===9?_.body:_.nodeName==="HTML"?_.ownerDocument.body:_).insertBefore(h,g):(g=_.nodeType===9?_.body:_.nodeName==="HTML"?_.ownerDocument.body:_,g.appendChild(h),_=_._reactRootContainer,_!=null||g.onclick!==null||(g.onclick=nc));else if(M!==4&&(M===27&&Uu(h.type)&&(_=h.stateNode,g=null),h=h.child,h!==null))for(LE(h,g,_),h=h.sibling;h!==null;)LE(h,g,_),h=h.sibling}function Mv(h,g,_){var M=h.tag;if(M===5||M===6)h=h.stateNode,g?_.insertBefore(h,g):_.appendChild(h);else if(M!==4&&(M===27&&Uu(h.type)&&(_=h.stateNode),h=h.child,h!==null))for(Mv(h,g,_),h=h.sibling;h!==null;)Mv(h,g,_),h=h.sibling}function Z5(h){var g=h.stateNode,_=h.memoizedProps;try{for(var M=h.type,P=g.attributes;P.length;)g.removeAttributeNode(P[0]);ua(g,M,_),g[sn]=h,g[Sr]=_}catch(I){tr(h,h.return,I)}}var hc=!1,gi=!1,IE=!1,J5=typeof WeakSet=="function"?WeakSet:Set,Vi=null;function Pie(h,g){if(h=h.containerInfo,iT=Wv,h=dI(h),kM(h)){if("selectionStart"in h)var _={start:h.selectionStart,end:h.selectionEnd};else e:{_=(_=h.ownerDocument)&&_.defaultView||window;var M=_.getSelection&&_.getSelection();if(M&&M.rangeCount!==0){_=M.anchorNode;var P=M.anchorOffset,I=M.focusNode;M=M.focusOffset;try{_.nodeType,I.nodeType}catch{_=null;break e}var J=0,ge=-1,Ie=-1,it=0,yt=0,_t=h,st=null;t:for(;;){for(var ft;_t!==_||P!==0&&_t.nodeType!==3||(ge=J+P),_t!==I||M!==0&&_t.nodeType!==3||(Ie=J+M),_t.nodeType===3&&(J+=_t.nodeValue.length),(ft=_t.firstChild)!==null;)st=_t,_t=ft;for(;;){if(_t===h)break t;if(st===_&&++it===P&&(ge=J),st===I&&++yt===M&&(Ie=J),(ft=_t.nextSibling)!==null)break;_t=st,st=_t.parentNode}_t=ft}_=ge===-1||Ie===-1?null:{start:ge,end:Ie}}else _=null}_=_||{start:0,end:0}}else _=null;for(aT={focusedElem:h,selectionRange:_},Wv=!1,Vi=g;Vi!==null;)if(g=Vi,h=g.child,(g.subtreeFlags&1028)!==0&&h!==null)h.return=g,Vi=h;else for(;Vi!==null;){switch(g=Vi,I=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(_=0;_<h.length;_++)P=h[_],P.ref.impl=P.nextImpl;break;case 11:case 15:break;case 1:if((h&1024)!==0&&I!==null){h=void 0,_=g,P=I.memoizedProps,I=I.memoizedState,M=_.stateNode;try{var Vt=Mh(_.type,P);h=M.getSnapshotBeforeUpdate(Vt,I),M.__reactInternalSnapshotBeforeUpdate=h}catch(an){tr(_,_.return,an)}}break;case 3:if((h&1024)!==0){if(h=g.stateNode.containerInfo,_=h.nodeType,_===9)lT(h);else if(_===1)switch(h.nodeName){case"HEAD":case"HTML":case"BODY":lT(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,Vi=h;break}Vi=g.return}}function eF(h,g,_){var M=_.flags;switch(_.tag){case 0:case 11:case 15:mc(h,_),M&4&&jx(5,_);break;case 1:if(mc(h,_),M&4)if(h=_.stateNode,g===null)try{h.componentDidMount()}catch(J){tr(_,_.return,J)}else{var P=Mh(_.type,g.memoizedProps);g=g.memoizedState;try{h.componentDidUpdate(P,g,h.__reactInternalSnapshotBeforeUpdate)}catch(J){tr(_,_.return,J)}}M&64&&K5(_),M&512&&Px(_,_.return);break;case 3:if(mc(h,_),M&64&&(h=_.updateQueue,h!==null)){if(g=null,_.child!==null)switch(_.child.tag){case 27:case 5:g=_.child.stateNode;break;case 1:g=_.child.stateNode}try{FI(h,g)}catch(J){tr(_,_.return,J)}}break;case 27:g===null&&M&4&&Z5(_);case 26:case 5:mc(h,_),g===null&&M&4&&Y5(_),M&512&&Px(_,_.return);break;case 12:mc(h,_);break;case 31:mc(h,_),M&4&&rF(h,_);break;case 13:mc(h,_),M&4&&iF(h,_),M&64&&(h=_.memoizedState,h!==null&&(h=h.dehydrated,h!==null&&(_=Bie.bind(null,_),oae(h,_))));break;case 22:if(M=_.memoizedState!==null||hc,!M){g=g!==null&&g.memoizedState!==null||gi,P=hc;var I=gi;hc=M,(gi=g)&&!I?pc(h,_,(_.subtreeFlags&8772)!==0):mc(h,_),hc=P,gi=I}break;case 30:break;default:mc(h,_)}}function tF(h){var g=h.alternate;g!==null&&(h.alternate=null,tF(g)),h.child=null,h.deletions=null,h.sibling=null,h.tag===5&&(g=h.stateNode,g!==null&&rt(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 Lr=null,is=!1;function fc(h,g,_){for(_=_.child;_!==null;)nF(h,g,_),_=_.sibling}function nF(h,g,_){if(ie&&typeof ie.onCommitFiberUnmount=="function")try{ie.onCommitFiberUnmount(Ye,_)}catch{}switch(_.tag){case 26:gi||bl(_,g),fc(h,g,_),_.memoizedState?_.memoizedState.count--:_.stateNode&&(_=_.stateNode,_.parentNode.removeChild(_));break;case 27:gi||bl(_,g);var M=Lr,P=is;Uu(_.type)&&(Lr=_.stateNode,is=!1),fc(h,g,_),Bx(_.stateNode),Lr=M,is=P;break;case 5:gi||bl(_,g);case 6:if(M=Lr,P=is,Lr=null,fc(h,g,_),Lr=M,is=P,Lr!==null)if(is)try{(Lr.nodeType===9?Lr.body:Lr.nodeName==="HTML"?Lr.ownerDocument.body:Lr).removeChild(_.stateNode)}catch(I){tr(_,g,I)}else try{Lr.removeChild(_.stateNode)}catch(I){tr(_,g,I)}break;case 18:Lr!==null&&(is?(h=Lr,KF(h.nodeType===9?h.body:h.nodeName==="HTML"?h.ownerDocument.body:h,_.stateNode),Lm(h)):KF(Lr,_.stateNode));break;case 4:M=Lr,P=is,Lr=_.stateNode.containerInfo,is=!0,fc(h,g,_),Lr=M,is=P;break;case 0:case 11:case 14:case 15:Pu(2,_,g),gi||Pu(4,_,g),fc(h,g,_);break;case 1:gi||(bl(_,g),M=_.stateNode,typeof M.componentWillUnmount=="function"&&X5(_,g,M)),fc(h,g,_);break;case 21:fc(h,g,_);break;case 22:gi=(M=gi)||_.memoizedState!==null,fc(h,g,_),gi=M;break;default:fc(h,g,_)}}function rF(h,g){if(g.memoizedState===null&&(h=g.alternate,h!==null&&(h=h.memoizedState,h!==null))){h=h.dehydrated;try{Lm(h)}catch(_){tr(g,g.return,_)}}}function iF(h,g){if(g.memoizedState===null&&(h=g.alternate,h!==null&&(h=h.memoizedState,h!==null&&(h=h.dehydrated,h!==null))))try{Lm(h)}catch(_){tr(g,g.return,_)}}function Rie(h){switch(h.tag){case 31:case 13:case 19:var g=h.stateNode;return g===null&&(g=h.stateNode=new J5),g;case 22:return h=h.stateNode,g=h._retryCache,g===null&&(g=h._retryCache=new J5),g;default:throw Error(r(435,h.tag))}}function Ev(h,g){var _=Rie(h);g.forEach(function(M){if(!_.has(M)){_.add(M);var P=$ie.bind(null,h,M);M.then(P,P)}})}function as(h,g){var _=g.deletions;if(_!==null)for(var M=0;M<_.length;M++){var P=_[M],I=h,J=g,ge=J;e:for(;ge!==null;){switch(ge.tag){case 27:if(Uu(ge.type)){Lr=ge.stateNode,is=!1;break e}break;case 5:Lr=ge.stateNode,is=!1;break e;case 3:case 4:Lr=ge.stateNode.containerInfo,is=!0;break e}ge=ge.return}if(Lr===null)throw Error(r(160));nF(I,J,P),Lr=null,is=!1,I=P.alternate,I!==null&&(I.return=null),P.return=null}if(g.subtreeFlags&13886)for(g=g.child;g!==null;)aF(g,h),g=g.sibling}var $o=null;function aF(h,g){var _=h.alternate,M=h.flags;switch(h.tag){case 0:case 11:case 14:case 15:as(g,h),ss(h),M&4&&(Pu(3,h,h.return),jx(3,h),Pu(5,h,h.return));break;case 1:as(g,h),ss(h),M&512&&(gi||_===null||bl(_,_.return)),M&64&&hc&&(h=h.updateQueue,h!==null&&(M=h.callbacks,M!==null&&(_=h.shared.hiddenCallbacks,h.shared.hiddenCallbacks=_===null?M:_.concat(M))));break;case 26:var P=$o;if(as(g,h),ss(h),M&512&&(gi||_===null||bl(_,_.return)),M&4){var I=_!==null?_.memoizedState:null;if(M=h.memoizedState,_===null)if(M===null)if(h.stateNode===null){e:{M=h.type,_=h.memoizedProps,P=P.ownerDocument||P;t:switch(M){case"title":I=P.getElementsByTagName("title")[0],(!I||I[ct]||I[sn]||I.namespaceURI==="http://www.w3.org/2000/svg"||I.hasAttribute("itemprop"))&&(I=P.createElement(M),P.head.insertBefore(I,P.querySelector("head > title"))),ua(I,M,_),I[sn]=h,He(I),M=I;break e;case"link":var J=aU("link","href",P).get(M+(_.href||""));if(J){for(var ge=0;ge<J.length;ge++)if(I=J[ge],I.getAttribute("href")===(_.href==null||_.href===""?null:_.href)&&I.getAttribute("rel")===(_.rel==null?null:_.rel)&&I.getAttribute("title")===(_.title==null?null:_.title)&&I.getAttribute("crossorigin")===(_.crossOrigin==null?null:_.crossOrigin)){J.splice(ge,1);break t}}I=P.createElement(M),ua(I,M,_),P.head.appendChild(I);break;case"meta":if(J=aU("meta","content",P).get(M+(_.content||""))){for(ge=0;ge<J.length;ge++)if(I=J[ge],I.getAttribute("content")===(_.content==null?null:""+_.content)&&I.getAttribute("name")===(_.name==null?null:_.name)&&I.getAttribute("property")===(_.property==null?null:_.property)&&I.getAttribute("http-equiv")===(_.httpEquiv==null?null:_.httpEquiv)&&I.getAttribute("charset")===(_.charSet==null?null:_.charSet)){J.splice(ge,1);break t}}I=P.createElement(M),ua(I,M,_),P.head.appendChild(I);break;default:throw Error(r(468,M))}I[sn]=h,He(I),M=I}h.stateNode=M}else sU(P,h.type,h.stateNode);else h.stateNode=iU(P,M,h.memoizedProps);else I!==M?(I===null?_.stateNode!==null&&(_=_.stateNode,_.parentNode.removeChild(_)):I.count--,M===null?sU(P,h.type,h.stateNode):iU(P,M,h.memoizedProps)):M===null&&h.stateNode!==null&&DE(h,h.memoizedProps,_.memoizedProps)}break;case 27:as(g,h),ss(h),M&512&&(gi||_===null||bl(_,_.return)),_!==null&&M&4&&DE(h,h.memoizedProps,_.memoizedProps);break;case 5:if(as(g,h),ss(h),M&512&&(gi||_===null||bl(_,_.return)),h.flags&32){P=h.stateNode;try{Ua(P,"")}catch(Vt){tr(h,h.return,Vt)}}M&4&&h.stateNode!=null&&(P=h.memoizedProps,DE(h,P,_!==null?_.memoizedProps:P)),M&1024&&(IE=!0);break;case 6:if(as(g,h),ss(h),M&4){if(h.stateNode===null)throw Error(r(162));M=h.memoizedProps,_=h.stateNode;try{_.nodeValue=M}catch(Vt){tr(h,h.return,Vt)}}break;case 3:if($v=null,P=$o,$o=zv(g.containerInfo),as(g,h),$o=P,ss(h),M&4&&_!==null&&_.memoizedState.isDehydrated)try{Lm(g.containerInfo)}catch(Vt){tr(h,h.return,Vt)}IE&&(IE=!1,sF(h));break;case 4:M=$o,$o=zv(h.stateNode.containerInfo),as(g,h),ss(h),$o=M;break;case 12:as(g,h),ss(h);break;case 31:as(g,h),ss(h),M&4&&(M=h.updateQueue,M!==null&&(h.updateQueue=null,Ev(h,M)));break;case 13:as(g,h),ss(h),h.child.flags&8192&&h.memoizedState!==null!=(_!==null&&_.memoizedState!==null)&&(Av=D()),M&4&&(M=h.updateQueue,M!==null&&(h.updateQueue=null,Ev(h,M)));break;case 22:P=h.memoizedState!==null;var Ie=_!==null&&_.memoizedState!==null,it=hc,yt=gi;if(hc=it||P,gi=yt||Ie,as(g,h),gi=yt,hc=it,ss(h),M&8192)e:for(g=h.stateNode,g._visibility=P?g._visibility&-2:g._visibility|1,P&&(_===null||Ie||hc||gi||Eh(h)),_=null,g=h;;){if(g.tag===5||g.tag===26){if(_===null){Ie=_=g;try{if(I=Ie.stateNode,P)J=I.style,typeof J.setProperty=="function"?J.setProperty("display","none","important"):J.display="none";else{ge=Ie.stateNode;var _t=Ie.memoizedProps.style,st=_t!=null&&_t.hasOwnProperty("display")?_t.display:null;ge.style.display=st==null||typeof st=="boolean"?"":(""+st).trim()}}catch(Vt){tr(Ie,Ie.return,Vt)}}}else if(g.tag===6){if(_===null){Ie=g;try{Ie.stateNode.nodeValue=P?"":Ie.memoizedProps}catch(Vt){tr(Ie,Ie.return,Vt)}}}else if(g.tag===18){if(_===null){Ie=g;try{var ft=Ie.stateNode;P?XF(ft,!0):XF(Ie.stateNode,!1)}catch(Vt){tr(Ie,Ie.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;_===g&&(_=null),g=g.return}_===g&&(_=null),g.sibling.return=g.return,g=g.sibling}M&4&&(M=h.updateQueue,M!==null&&(_=M.retryQueue,_!==null&&(M.retryQueue=null,Ev(h,_))));break;case 19:as(g,h),ss(h),M&4&&(M=h.updateQueue,M!==null&&(h.updateQueue=null,Ev(h,M)));break;case 30:break;case 21:break;default:as(g,h),ss(h)}}function ss(h){var g=h.flags;if(g&2){try{for(var _,M=h.return;M!==null;){if(Q5(M)){_=M;break}M=M.return}if(_==null)throw Error(r(160));switch(_.tag){case 27:var P=_.stateNode,I=OE(h);Mv(h,I,P);break;case 5:var J=_.stateNode;_.flags&32&&(Ua(J,""),_.flags&=-33);var ge=OE(h);Mv(h,ge,J);break;case 3:case 4:var Ie=_.stateNode.containerInfo,it=OE(h);LE(h,it,Ie);break;default:throw Error(r(161))}}catch(yt){tr(h,h.return,yt)}h.flags&=-3}g&4096&&(h.flags&=-4097)}function sF(h){if(h.subtreeFlags&1024)for(h=h.child;h!==null;){var g=h;sF(g),g.tag===5&&g.flags&1024&&g.stateNode.reset(),h=h.sibling}}function mc(h,g){if(g.subtreeFlags&8772)for(g=g.child;g!==null;)eF(h,g.alternate,g),g=g.sibling}function Eh(h){for(h=h.child;h!==null;){var g=h;switch(g.tag){case 0:case 11:case 14:case 15:Pu(4,g,g.return),Eh(g);break;case 1:bl(g,g.return);var _=g.stateNode;typeof _.componentWillUnmount=="function"&&X5(g,g.return,_),Eh(g);break;case 27:Bx(g.stateNode);case 26:case 5:bl(g,g.return),Eh(g);break;case 22:g.memoizedState===null&&Eh(g);break;case 30:Eh(g);break;default:Eh(g)}h=h.sibling}}function pc(h,g,_){for(_=_&&(g.subtreeFlags&8772)!==0,g=g.child;g!==null;){var M=g.alternate,P=h,I=g,J=I.flags;switch(I.tag){case 0:case 11:case 15:pc(P,I,_),jx(4,I);break;case 1:if(pc(P,I,_),M=I,P=M.stateNode,typeof P.componentDidMount=="function")try{P.componentDidMount()}catch(it){tr(M,M.return,it)}if(M=I,P=M.updateQueue,P!==null){var ge=M.stateNode;try{var Ie=P.shared.hiddenCallbacks;if(Ie!==null)for(P.shared.hiddenCallbacks=null,P=0;P<Ie.length;P++)II(Ie[P],ge)}catch(it){tr(M,M.return,it)}}_&&J&64&&K5(I),Px(I,I.return);break;case 27:Z5(I);case 26:case 5:pc(P,I,_),_&&M===null&&J&4&&Y5(I),Px(I,I.return);break;case 12:pc(P,I,_);break;case 31:pc(P,I,_),_&&J&4&&rF(P,I);break;case 13:pc(P,I,_),_&&J&4&&iF(P,I);break;case 22:I.memoizedState===null&&pc(P,I,_),Px(I,I.return);break;case 30:break;default:pc(P,I,_)}g=g.sibling}}function FE(h,g){var _=null;h!==null&&h.memoizedState!==null&&h.memoizedState.cachePool!==null&&(_=h.memoizedState.cachePool.pool),h=null,g.memoizedState!==null&&g.memoizedState.cachePool!==null&&(h=g.memoizedState.cachePool.pool),h!==_&&(h!=null&&h.refCount++,_!=null&&bx(_))}function UE(h,g){h=null,g.alternate!==null&&(h=g.alternate.memoizedState.cache),g=g.memoizedState.cache,g!==h&&(g.refCount++,h!=null&&bx(h))}function Ho(h,g,_,M){if(g.subtreeFlags&10256)for(g=g.child;g!==null;)oF(h,g,_,M),g=g.sibling}function oF(h,g,_,M){var P=g.flags;switch(g.tag){case 0:case 11:case 15:Ho(h,g,_,M),P&2048&&jx(9,g);break;case 1:Ho(h,g,_,M);break;case 3:Ho(h,g,_,M),P&2048&&(h=null,g.alternate!==null&&(h=g.alternate.memoizedState.cache),g=g.memoizedState.cache,g!==h&&(g.refCount++,h!=null&&bx(h)));break;case 12:if(P&2048){Ho(h,g,_,M),h=g.stateNode;try{var I=g.memoizedProps,J=I.id,ge=I.onPostCommit;typeof ge=="function"&&ge(J,g.alternate===null?"mount":"update",h.passiveEffectDuration,-0)}catch(Ie){tr(g,g.return,Ie)}}else Ho(h,g,_,M);break;case 31:Ho(h,g,_,M);break;case 13:Ho(h,g,_,M);break;case 23:break;case 22:I=g.stateNode,J=g.alternate,g.memoizedState!==null?I._visibility&2?Ho(h,g,_,M):Rx(h,g):I._visibility&2?Ho(h,g,_,M):(I._visibility|=2,Mm(h,g,_,M,(g.subtreeFlags&10256)!==0||!1)),P&2048&&FE(J,g);break;case 24:Ho(h,g,_,M),P&2048&&UE(g.alternate,g);break;default:Ho(h,g,_,M)}}function Mm(h,g,_,M,P){for(P=P&&((g.subtreeFlags&10256)!==0||!1),g=g.child;g!==null;){var I=h,J=g,ge=_,Ie=M,it=J.flags;switch(J.tag){case 0:case 11:case 15:Mm(I,J,ge,Ie,P),jx(8,J);break;case 23:break;case 22:var yt=J.stateNode;J.memoizedState!==null?yt._visibility&2?Mm(I,J,ge,Ie,P):Rx(I,J):(yt._visibility|=2,Mm(I,J,ge,Ie,P)),P&&it&2048&&FE(J.alternate,J);break;case 24:Mm(I,J,ge,Ie,P),P&&it&2048&&UE(J.alternate,J);break;default:Mm(I,J,ge,Ie,P)}g=g.sibling}}function Rx(h,g){if(g.subtreeFlags&10256)for(g=g.child;g!==null;){var _=h,M=g,P=M.flags;switch(M.tag){case 22:Rx(_,M),P&2048&&FE(M.alternate,M);break;case 24:Rx(_,M),P&2048&&UE(M.alternate,M);break;default:Rx(_,M)}g=g.sibling}}var Dx=8192;function Em(h,g,_){if(h.subtreeFlags&Dx)for(h=h.child;h!==null;)lF(h,g,_),h=h.sibling}function lF(h,g,_){switch(h.tag){case 26:Em(h,g,_),h.flags&Dx&&h.memoizedState!==null&&yae(_,$o,h.memoizedState,h.memoizedProps);break;case 5:Em(h,g,_);break;case 3:case 4:var M=$o;$o=zv(h.stateNode.containerInfo),Em(h,g,_),$o=M;break;case 22:h.memoizedState===null&&(M=h.alternate,M!==null&&M.memoizedState!==null?(M=Dx,Dx=16777216,Em(h,g,_),Dx=M):Em(h,g,_));break;default:Em(h,g,_)}}function cF(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 Ox(h){var g=h.deletions;if((h.flags&16)!==0){if(g!==null)for(var _=0;_<g.length;_++){var M=g[_];Vi=M,dF(M,h)}cF(h)}if(h.subtreeFlags&10256)for(h=h.child;h!==null;)uF(h),h=h.sibling}function uF(h){switch(h.tag){case 0:case 11:case 15:Ox(h),h.flags&2048&&Pu(9,h,h.return);break;case 3:Ox(h);break;case 12:Ox(h);break;case 22:var g=h.stateNode;h.memoizedState!==null&&g._visibility&2&&(h.return===null||h.return.tag!==13)?(g._visibility&=-3,Tv(h)):Ox(h);break;default:Ox(h)}}function Tv(h){var g=h.deletions;if((h.flags&16)!==0){if(g!==null)for(var _=0;_<g.length;_++){var M=g[_];Vi=M,dF(M,h)}cF(h)}for(h=h.child;h!==null;){switch(g=h,g.tag){case 0:case 11:case 15:Pu(8,g,g.return),Tv(g);break;case 22:_=g.stateNode,_._visibility&2&&(_._visibility&=-3,Tv(g));break;default:Tv(g)}h=h.sibling}}function dF(h,g){for(;Vi!==null;){var _=Vi;switch(_.tag){case 0:case 11:case 15:Pu(8,_,g);break;case 23:case 22:if(_.memoizedState!==null&&_.memoizedState.cachePool!==null){var M=_.memoizedState.cachePool.pool;M!=null&&M.refCount++}break;case 24:bx(_.memoizedState.cache)}if(M=_.child,M!==null)M.return=_,Vi=M;else e:for(_=h;Vi!==null;){M=Vi;var P=M.sibling,I=M.return;if(tF(M),M===_){Vi=null;break e}if(P!==null){P.return=I,Vi=P;break e}Vi=I}}}var Die={getCacheForType:function(h){var g=la(fi),_=g.data.get(h);return _===void 0&&(_=h(),g.data.set(h,_)),_},cacheSignal:function(){return la(fi).controller.signal}},Oie=typeof WeakMap=="function"?WeakMap:Map,Yn=0,yr=null,jn=null,Ln=0,er=0,js=null,Ru=!1,Tm=!1,zE=!1,gc=0,Qr=0,Du=0,Th=0,BE=0,Ps=0,Am=0,Lx=null,ls=null,$E=!1,Av=0,hF=0,Cv=1/0,kv=null,Ou=null,Ti=0,Lu=null,Cm=null,xc=0,HE=0,VE=null,fF=null,Ix=0,GE=null;function Rs(){return(Yn&2)!==0&&Ln!==0?Ln&-Ln:Y.T!==null?QE():Rr()}function mF(){if(Ps===0)if((Ln&536870912)===0||Un){var h=be;be<<=1,(be&3932160)===0&&(be=262144),Ps=h}else Ps=536870912;return h=Cs.current,h!==null&&(h.flags|=32),Ps}function cs(h,g,_){(h===yr&&(er===2||er===9)||h.cancelPendingCommit!==null)&&(km(h,0),Iu(h,Ln,Ps,!1)),cn(h,_),((Yn&2)===0||h!==yr)&&(h===yr&&((Yn&2)===0&&(Th|=_),Qr===4&&Iu(h,Ln,Ps,!1)),yl(h))}function pF(h,g,_){if((Yn&6)!==0)throw Error(r(327));var M=!_&&(g&127)===0&&(g&h.expiredLanes)===0||Je(h,g),P=M?Fie(h,g):qE(h,g,!0),I=M;do{if(P===0){Tm&&!M&&Iu(h,g,0,!1);break}else{if(_=h.current.alternate,I&&!Lie(_)){P=qE(h,g,!1),I=!1;continue}if(P===2){if(I=g,h.errorRecoveryDisabledLanes&I)var J=0;else J=h.pendingLanes&-536870913,J=J!==0?J:J&536870912?536870912:0;if(J!==0){g=J;e:{var ge=h;P=Lx;var Ie=ge.current.memoizedState.isDehydrated;if(Ie&&(km(ge,J).flags|=256),J=qE(ge,J,!1),J!==2){if(zE&&!Ie){ge.errorRecoveryDisabledLanes|=I,Th|=I,P=4;break e}I=ls,ls=P,I!==null&&(ls===null?ls=I:ls.push.apply(ls,I))}P=J}if(I=!1,P!==2)continue}}if(P===1){km(h,0),Iu(h,g,0,!0);break}e:{switch(M=h,I=P,I){case 0:case 1:throw Error(r(345));case 4:if((g&4194048)!==g)break;case 6:Iu(M,g,Ps,!Ru);break e;case 2:ls=null;break;case 3:case 5:break;default:throw Error(r(329))}if((g&62914560)===g&&(P=Av+300-D(),10<P)){if(Iu(M,g,Ps,!Ru),Ae(M,0,!0)!==0)break e;xc=g,M.timeoutHandle=WF(gF.bind(null,M,_,ls,kv,$E,g,Ps,Th,Am,Ru,I,"Throttled",-0,0),P);break e}gF(M,_,ls,kv,$E,g,Ps,Th,Am,Ru,I,null,-0,0)}}break}while(!0);yl(h)}function gF(h,g,_,M,P,I,J,ge,Ie,it,yt,_t,st,ft){if(h.timeoutHandle=-1,_t=g.subtreeFlags,_t&8192||(_t&16785408)===16785408){_t={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:nc},lF(g,I,_t);var Vt=(I&62914560)===I?Av-D():(I&4194048)===I?hF-D():0;if(Vt=vae(_t,Vt),Vt!==null){xc=I,h.cancelPendingCommit=Vt(NF.bind(null,h,g,I,_,M,P,J,ge,Ie,yt,_t,null,st,ft)),Iu(h,I,J,!it);return}}NF(h,g,I,_,M,P,J,ge,Ie)}function Lie(h){for(var g=h;;){var _=g.tag;if((_===0||_===11||_===15)&&g.flags&16384&&(_=g.updateQueue,_!==null&&(_=_.stores,_!==null)))for(var M=0;M<_.length;M++){var P=_[M],I=P.getSnapshot;P=P.value;try{if(!Ts(I(),P))return!1}catch{return!1}}if(_=g.child,g.subtreeFlags&16384&&_!==null)_.return=g,g=_;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 Iu(h,g,_,M){g&=~BE,g&=~Th,h.suspendedLanes|=g,h.pingedLanes&=~g,M&&(h.warmLanes|=g),M=h.expirationTimes;for(var P=g;0<P;){var I=31-Se(P),J=1<<I;M[I]=-1,P&=~J}_!==0&&_n(h,_,g)}function jv(){return(Yn&6)===0?(Fx(0),!1):!0}function WE(){if(jn!==null){if(er===0)var h=jn.return;else h=jn,sc=bh=null,lE(h),vm=null,vx=0,h=jn;for(;h!==null;)q5(h.alternate,h),h=h.return;jn=null}}function km(h,g){var _=h.timeoutHandle;_!==-1&&(h.timeoutHandle=-1,nae(_)),_=h.cancelPendingCommit,_!==null&&(h.cancelPendingCommit=null,_()),xc=0,WE(),yr=h,jn=_=ic(h.current,null),Ln=g,er=0,js=null,Ru=!1,Tm=Je(h,g),zE=!1,Am=Ps=BE=Th=Du=Qr=0,ls=Lx=null,$E=!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-Se(M),I=1<<P;g|=h[P],M&=~I}return gc=g,Zy(),_}function xF(h,g){bn=null,Y.H=Ax,g===ym||g===sv?(g=RI(),er=3):g===YM?(g=RI(),er=4):er=g===NE?8:g!==null&&typeof g=="object"&&typeof g.then=="function"?6:1,js=g,jn===null&&(Qr=1,vv(h,to(g,h.current)))}function bF(){var h=Cs.current;return h===null?!0:(Ln&4194048)===Ln?ao===null:(Ln&62914560)===Ln||(Ln&536870912)!==0?h===ao:!1}function yF(){var h=Y.H;return Y.H=Ax,h===null?Ax:h}function vF(){var h=Y.A;return Y.A=Die,h}function Pv(){Qr=4,Ru||(Ln&4194048)!==Ln&&Cs.current!==null||(Tm=!0),(Du&134217727)===0&&(Th&134217727)===0||yr===null||Iu(yr,Ln,Ps,!1)}function qE(h,g,_){var M=Yn;Yn|=2;var P=yF(),I=vF();(yr!==h||Ln!==g)&&(kv=null,km(h,g)),g=!1;var J=Qr;e:do try{if(er!==0&&jn!==null){var ge=jn,Ie=js;switch(er){case 8:WE(),J=6;break e;case 3:case 2:case 9:case 6:Cs.current===null&&(g=!0);var it=er;if(er=0,js=null,jm(h,ge,Ie,it),_&&Tm){J=0;break e}break;default:it=er,er=0,js=null,jm(h,ge,Ie,it)}}Iie(),J=Qr;break}catch(yt){xF(h,yt)}while(!0);return g&&h.shellSuspendCounter++,sc=bh=null,Yn=M,Y.H=P,Y.A=I,jn===null&&(yr=null,Ln=0,Zy()),J}function Iie(){for(;jn!==null;)_F(jn)}function Fie(h,g){var _=Yn;Yn|=2;var M=yF(),P=vF();yr!==h||Ln!==g?(kv=null,Cv=D()+500,km(h,g)):Tm=Je(h,g);e:do try{if(er!==0&&jn!==null){g=jn;var I=js;t:switch(er){case 1:er=0,js=null,jm(h,g,I,1);break;case 2:case 9:if(jI(I)){er=0,js=null,wF(g);break}g=function(){er!==2&&er!==9||yr!==h||(er=7),yl(h)},I.then(g,g);break e;case 3:er=7;break e;case 4:er=5;break e;case 7:jI(I)?(er=0,js=null,wF(g)):(er=0,js=null,jm(h,g,I,7));break;case 5:var J=null;switch(jn.tag){case 26:J=jn.memoizedState;case 5:case 27:var ge=jn;if(J?oU(J):ge.stateNode.complete){er=0,js=null;var Ie=ge.sibling;if(Ie!==null)jn=Ie;else{var it=ge.return;it!==null?(jn=it,Rv(it)):jn=null}break t}}er=0,js=null,jm(h,g,I,5);break;case 6:er=0,js=null,jm(h,g,I,6);break;case 8:WE(),Qr=6;break e;default:throw Error(r(462))}}Uie();break}catch(yt){xF(h,yt)}while(!0);return sc=bh=null,Y.H=M,Y.A=P,Yn=_,jn!==null?0:(yr=null,Ln=0,Zy(),Qr)}function Uie(){for(;jn!==null&&!Ce();)_F(jn)}function _F(h){var g=G5(h.alternate,h,gc);h.memoizedProps=h.pendingProps,g===null?Rv(h):jn=g}function wF(h){var g=h,_=g.alternate;switch(g.tag){case 15:case 0:g=U5(_,g,g.pendingProps,g.type,void 0,Ln);break;case 11:g=U5(_,g,g.pendingProps,g.type.render,g.ref,Ln);break;case 5:lE(g);default:q5(_,g),g=jn=vI(g,gc),g=G5(_,g,gc)}h.memoizedProps=h.pendingProps,g===null?Rv(h):jn=g}function jm(h,g,_,M){sc=bh=null,lE(g),vm=null,vx=0;var P=g.return;try{if(Tie(h,P,g,_,Ln)){Qr=1,vv(h,to(_,h.current)),jn=null;return}}catch(I){if(P!==null)throw jn=P,I;Qr=1,vv(h,to(_,h.current)),jn=null;return}g.flags&32768?(Un||M===1?h=!0:Tm||(Ln&536870912)!==0?h=!1:(Ru=h=!0,(M===2||M===9||M===3||M===6)&&(M=Cs.current,M!==null&&M.tag===13&&(M.flags|=16384))),SF(g,h)):Rv(g)}function Rv(h){var g=h;do{if((g.flags&32768)!==0){SF(g,Ru);return}h=g.return;var _=kie(g.alternate,g,gc);if(_!==null){jn=_;return}if(g=g.sibling,g!==null){jn=g;return}jn=g=h}while(g!==null);Qr===0&&(Qr=5)}function SF(h,g){do{var _=jie(h.alternate,h);if(_!==null){_.flags&=32767,jn=_;return}if(_=h.return,_!==null&&(_.flags|=32768,_.subtreeFlags=0,_.deletions=null),!g&&(h=h.sibling,h!==null)){jn=h;return}jn=h=_}while(h!==null);Qr=6,jn=null}function NF(h,g,_,M,P,I,J,ge,Ie){h.cancelPendingCommit=null;do Dv();while(Ti!==0);if((Yn&6)!==0)throw Error(r(327));if(g!==null){if(g===h.current)throw Error(r(177));if(I=g.lanes|g.childLanes,I|=OM,It(h,_,I,J,ge,Ie),h===yr&&(jn=yr=null,Ln=0),Cm=g,Lu=h,xc=_,HE=I,VE=P,fF=M,(g.subtreeFlags&10256)!==0||(g.flags&10256)!==0?(h.callbackNode=null,h.callbackPriority=0,Hie(ve,function(){return CF(),null})):(h.callbackNode=null,h.callbackPriority=0),M=(g.flags&13878)!==0,(g.subtreeFlags&13878)!==0||M){M=Y.T,Y.T=null,P=q.p,q.p=2,J=Yn,Yn|=4;try{Pie(h,g,_)}finally{Yn=J,q.p=P,Y.T=M}}Ti=1,MF(),EF(),TF()}}function MF(){if(Ti===1){Ti=0;var h=Lu,g=Cm,_=(g.flags&13878)!==0;if((g.subtreeFlags&13878)!==0||_){_=Y.T,Y.T=null;var M=q.p;q.p=2;var P=Yn;Yn|=4;try{aF(g,h);var I=aT,J=dI(h.containerInfo),ge=I.focusedElem,Ie=I.selectionRange;if(J!==ge&&ge&&ge.ownerDocument&&uI(ge.ownerDocument.documentElement,ge)){if(Ie!==null&&kM(ge)){var it=Ie.start,yt=Ie.end;if(yt===void 0&&(yt=it),"selectionStart"in ge)ge.selectionStart=it,ge.selectionEnd=Math.min(yt,ge.value.length);else{var _t=ge.ownerDocument||document,st=_t&&_t.defaultView||window;if(st.getSelection){var ft=st.getSelection(),Vt=ge.textContent.length,an=Math.min(Ie.start,Vt),ur=Ie.end===void 0?an:Math.min(Ie.end,Vt);!ft.extend&&an>ur&&(J=ur,ur=an,an=J);var Ze=cI(ge,an),Ge=cI(ge,ur);if(Ze&&Ge&&(ft.rangeCount!==1||ft.anchorNode!==Ze.node||ft.anchorOffset!==Ze.offset||ft.focusNode!==Ge.node||ft.focusOffset!==Ge.offset)){var tt=_t.createRange();tt.setStart(Ze.node,Ze.offset),ft.removeAllRanges(),an>ur?(ft.addRange(tt),ft.extend(Ge.node,Ge.offset)):(tt.setEnd(Ge.node,Ge.offset),ft.addRange(tt))}}}}for(_t=[],ft=ge;ft=ft.parentNode;)ft.nodeType===1&&_t.push({element:ft,left:ft.scrollLeft,top:ft.scrollTop});for(typeof ge.focus=="function"&&ge.focus(),ge=0;ge<_t.length;ge++){var vt=_t[ge];vt.element.scrollLeft=vt.left,vt.element.scrollTop=vt.top}}Wv=!!iT,aT=iT=null}finally{Yn=P,q.p=M,Y.T=_}}h.current=g,Ti=2}}function EF(){if(Ti===2){Ti=0;var h=Lu,g=Cm,_=(g.flags&8772)!==0;if((g.subtreeFlags&8772)!==0||_){_=Y.T,Y.T=null;var M=q.p;q.p=2;var P=Yn;Yn|=4;try{eF(h,g.alternate,g)}finally{Yn=P,q.p=M,Y.T=_}}Ti=3}}function TF(){if(Ti===4||Ti===3){Ti=0,H();var h=Lu,g=Cm,_=xc,M=fF;(g.subtreeFlags&10256)!==0||(g.flags&10256)!==0?Ti=5:(Ti=0,Cm=Lu=null,AF(h,h.pendingLanes));var P=h.pendingLanes;if(P===0&&(Ou=null),Tt(_),g=g.stateNode,ie&&typeof ie.onCommitFiberRoot=="function")try{ie.onCommitFiberRoot(Ye,g,void 0,(g.current.flags&128)===128)}catch{}if(M!==null){g=Y.T,P=q.p,q.p=2,Y.T=null;try{for(var I=h.onRecoverableError,J=0;J<M.length;J++){var ge=M[J];I(ge.value,{componentStack:ge.stack})}}finally{Y.T=g,q.p=P}}(xc&3)!==0&&Dv(),yl(h),P=h.pendingLanes,(_&261930)!==0&&(P&42)!==0?h===GE?Ix++:(Ix=0,GE=h):Ix=0,Fx(0)}}function AF(h,g){(h.pooledCacheLanes&=g)===0&&(g=h.pooledCache,g!=null&&(h.pooledCache=null,bx(g)))}function Dv(){return MF(),EF(),TF(),CF()}function CF(){if(Ti!==5)return!1;var h=Lu,g=HE;HE=0;var _=Tt(xc),M=Y.T,P=q.p;try{q.p=32>_?32:_,Y.T=null,_=VE,VE=null;var I=Lu,J=xc;if(Ti=0,Cm=Lu=null,xc=0,(Yn&6)!==0)throw Error(r(331));var ge=Yn;if(Yn|=4,uF(I.current),oF(I,I.current,J,_),Yn=ge,Fx(0,!1),ie&&typeof ie.onPostCommitFiberRoot=="function")try{ie.onPostCommitFiberRoot(Ye,I)}catch{}return!0}finally{q.p=P,Y.T=M,AF(h,g)}}function kF(h,g,_){g=to(_,g),g=SE(h.stateNode,g,2),h=Cu(h,g,2),h!==null&&(cn(h,2),yl(h))}function tr(h,g,_){if(h.tag===3)kF(h,h,_);else for(;g!==null;){if(g.tag===3){kF(g,h,_);break}else if(g.tag===1){var M=g.stateNode;if(typeof g.type.getDerivedStateFromError=="function"||typeof M.componentDidCatch=="function"&&(Ou===null||!Ou.has(M))){h=to(_,h),_=j5(2),M=Cu(g,_,2),M!==null&&(P5(_,M,g,h),cn(M,2),yl(M));break}}g=g.return}}function KE(h,g,_){var M=h.pingCache;if(M===null){M=h.pingCache=new Oie;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(_)||(zE=!0,P.add(_),h=zie.bind(null,h,g,_),g.then(h,h))}function zie(h,g,_){var M=h.pingCache;M!==null&&M.delete(g),h.pingedLanes|=h.suspendedLanes&_,h.warmLanes&=~_,yr===h&&(Ln&_)===_&&(Qr===4||Qr===3&&(Ln&62914560)===Ln&&300>D()-Av?(Yn&2)===0&&km(h,0):BE|=_,Am===Ln&&(Am=0)),yl(h)}function jF(h,g){g===0&&(g=Pt()),h=ph(h,g),h!==null&&(cn(h,g),yl(h))}function Bie(h){var g=h.memoizedState,_=0;g!==null&&(_=g.retryLane),jF(h,_)}function $ie(h,g){var _=0;switch(h.tag){case 31:case 13:var M=h.stateNode,P=h.memoizedState;P!==null&&(_=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),jF(h,_)}function Hie(h,g){return Te(h,g)}var Ov=null,Pm=null,XE=!1,Lv=!1,YE=!1,Fu=0;function yl(h){h!==Pm&&h.next===null&&(Pm===null?Ov=Pm=h:Pm=Pm.next=h),Lv=!0,XE||(XE=!0,Gie())}function Fx(h,g){if(!YE&&Lv){YE=!0;do for(var _=!1,M=Ov;M!==null;){if(h!==0){var P=M.pendingLanes;if(P===0)var I=0;else{var J=M.suspendedLanes,ge=M.pingedLanes;I=(1<<31-Se(42|h)+1)-1,I&=P&~(J&~ge),I=I&201326741?I&201326741|1:I?I|2:0}I!==0&&(_=!0,OF(M,I))}else I=Ln,I=Ae(M,M===yr?I:0,M.cancelPendingCommit!==null||M.timeoutHandle!==-1),(I&3)===0||Je(M,I)||(_=!0,OF(M,I));M=M.next}while(_);YE=!1}}function Vie(){PF()}function PF(){Lv=XE=!1;var h=0;Fu!==0&&tae()&&(h=Fu);for(var g=D(),_=null,M=Ov;M!==null;){var P=M.next,I=RF(M,g);I===0?(M.next=null,_===null?Ov=P:_.next=P,P===null&&(Pm=_)):(_=M,(h!==0||(I&3)!==0)&&(Lv=!0)),M=P}Ti!==0&&Ti!==5||Fx(h),Fu!==0&&(Fu=0)}function RF(h,g){for(var _=h.suspendedLanes,M=h.pingedLanes,P=h.expirationTimes,I=h.pendingLanes&-62914561;0<I;){var J=31-Se(I),ge=1<<J,Ie=P[J];Ie===-1?((ge&_)===0||(ge&M)!==0)&&(P[J]=gt(ge,g)):Ie<=g&&(h.expiredLanes|=ge),I&=~ge}if(g=yr,_=Ln,_=Ae(h,h===g?_:0,h.cancelPendingCommit!==null||h.timeoutHandle!==-1),M=h.callbackNode,_===0||h===g&&(er===2||er===9)||h.cancelPendingCommit!==null)return M!==null&&M!==null&&je(M),h.callbackNode=null,h.callbackPriority=0;if((_&3)===0||Je(h,_)){if(g=_&-_,g===h.callbackPriority)return g;switch(M!==null&&je(M),Tt(_)){case 2:case 8:_=Ne;break;case 32:_=ve;break;case 268435456:_=Le;break;default:_=ve}return M=DF.bind(null,h),_=Te(_,M),h.callbackPriority=g,h.callbackNode=_,g}return M!==null&&M!==null&&je(M),h.callbackPriority=2,h.callbackNode=null,2}function DF(h,g){if(Ti!==0&&Ti!==5)return h.callbackNode=null,h.callbackPriority=0,null;var _=h.callbackNode;if(Dv()&&h.callbackNode!==_)return null;var M=Ln;return M=Ae(h,h===yr?M:0,h.cancelPendingCommit!==null||h.timeoutHandle!==-1),M===0?null:(pF(h,M,g),RF(h,D()),h.callbackNode!=null&&h.callbackNode===_?DF.bind(null,h):null)}function OF(h,g){if(Dv())return null;pF(h,g,!0)}function Gie(){rae(function(){(Yn&6)!==0?Te(xe,Vie):PF()})}function QE(){if(Fu===0){var h=xm;h===0&&(h=Pe,Pe<<=1,(Pe&261888)===0&&(Pe=256)),Fu=h}return Fu}function LF(h){return h==null||typeof h=="symbol"||typeof h=="boolean"?null:typeof h=="function"?h:Hi(""+h)}function IF(h,g){var _=g.ownerDocument.createElement("input");return _.name=g.name,_.value=g.value,h.id&&_.setAttribute("form",h.id),g.parentNode.insertBefore(_,g),h=new FormData(h),_.parentNode.removeChild(_),h}function Wie(h,g,_,M,P){if(g==="submit"&&_&&_.stateNode===P){var I=LF((P[Sr]||null).action),J=M.submitter;J&&(g=(g=J[Sr]||null)?LF(g.formAction):J.getAttribute("formAction"),g!==null&&(I=g,J=null));var ge=new Ky("action","action",null,M,P);h.push({event:ge,listeners:[{instance:null,listener:function(){if(M.defaultPrevented){if(Fu!==0){var Ie=J?IF(P,J):new FormData(P);xE(_,{pending:!0,data:Ie,method:P.method,action:I},null,Ie)}}else typeof I=="function"&&(ge.preventDefault(),Ie=J?IF(P,J):new FormData(P),xE(_,{pending:!0,data:Ie,method:P.method,action:I},I,Ie))},currentTarget:P}]})}}for(var ZE=0;ZE<DM.length;ZE++){var JE=DM[ZE],qie=JE.toLowerCase(),Kie=JE[0].toUpperCase()+JE.slice(1);Bo(qie,"on"+Kie)}Bo(mI,"onAnimationEnd"),Bo(pI,"onAnimationIteration"),Bo(gI,"onAnimationStart"),Bo("dblclick","onDoubleClick"),Bo("focusin","onFocus"),Bo("focusout","onBlur"),Bo(uie,"onTransitionRun"),Bo(die,"onTransitionStart"),Bo(hie,"onTransitionCancel"),Bo(xI,"onTransitionEnd"),kt("onMouseEnter",["mouseout","mouseover"]),kt("onMouseLeave",["mouseout","mouseover"]),kt("onPointerEnter",["pointerout","pointerover"]),kt("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 Ux="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(" "),Xie=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Ux));function FF(h,g){g=(g&4)!==0;for(var _=0;_<h.length;_++){var M=h[_],P=M.event;M=M.listeners;e:{var I=void 0;if(g)for(var J=M.length-1;0<=J;J--){var ge=M[J],Ie=ge.instance,it=ge.currentTarget;if(ge=ge.listener,Ie!==I&&P.isPropagationStopped())break e;I=ge,P.currentTarget=it;try{I(P)}catch(yt){Qy(yt)}P.currentTarget=null,I=Ie}else for(J=0;J<M.length;J++){if(ge=M[J],Ie=ge.instance,it=ge.currentTarget,ge=ge.listener,Ie!==I&&P.isPropagationStopped())break e;I=ge,P.currentTarget=it;try{I(P)}catch(yt){Qy(yt)}P.currentTarget=null,I=Ie}}}}function Pn(h,g){var _=g[Dr];_===void 0&&(_=g[Dr]=new Set);var M=h+"__bubble";_.has(M)||(UF(g,h,2,!1),_.add(M))}function eT(h,g,_){var M=0;g&&(M|=4),UF(_,h,M,g)}var Iv="_reactListening"+Math.random().toString(36).slice(2);function tT(h){if(!h[Iv]){h[Iv]=!0,Fe.forEach(function(_){_!=="selectionchange"&&(Xie.has(_)||eT(_,!1,h),eT(_,!0,h))});var g=h.nodeType===9?h:h.ownerDocument;g===null||g[Iv]||(g[Iv]=!0,eT("selectionchange",!1,g))}}function UF(h,g,_,M){switch(mU(g)){case 2:var P=Sae;break;case 8:P=Nae;break;default:P=gT}_=P.bind(null,g,_,h),P=void 0,!_M||g!=="touchstart"&&g!=="touchmove"&&g!=="wheel"||(P=!0),M?P!==void 0?h.addEventListener(g,_,{capture:!0,passive:P}):h.addEventListener(g,_,!0):P!==void 0?h.addEventListener(g,_,{passive:P}):h.addEventListener(g,_,!1)}function nT(h,g,_,M,P){var I=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 ge=M.stateNode.containerInfo;if(ge===P)break;if(J===4)for(J=M.return;J!==null;){var Ie=J.tag;if((Ie===3||Ie===4)&&J.stateNode.containerInfo===P)return;J=J.return}for(;ge!==null;){if(J=Rt(ge),J===null)return;if(Ie=J.tag,Ie===5||Ie===6||Ie===26||Ie===27){M=I=J;continue e}ge=ge.parentNode}}M=M.return}VL(function(){var it=I,yt=yM(_),_t=[];e:{var st=bI.get(h);if(st!==void 0){var ft=Ky,Vt=h;switch(h){case"keypress":if(Wy(_)===0)break e;case"keydown":case"keyup":ft=$re;break;case"focusin":Vt="focus",ft=MM;break;case"focusout":Vt="blur",ft=MM;break;case"beforeblur":case"afterblur":ft=MM;break;case"click":if(_.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":ft=qL;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ft=kre;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ft=Gre;break;case mI:case pI:case gI:ft=Rre;break;case xI:ft=qre;break;case"scroll":case"scrollend":ft=Are;break;case"wheel":ft=Xre;break;case"copy":case"cut":case"paste":ft=Ore;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ft=XL;break;case"toggle":case"beforetoggle":ft=Qre}var an=(g&4)!==0,ur=!an&&(h==="scroll"||h==="scrollend"),Ze=an?st!==null?st+"Capture":null:st;an=[];for(var Ge=it,tt;Ge!==null;){var vt=Ge;if(tt=vt.stateNode,vt=vt.tag,vt!==5&&vt!==26&&vt!==27||tt===null||Ze===null||(vt=ox(Ge,Ze),vt!=null&&an.push(zx(Ge,vt,tt))),ur)break;Ge=Ge.return}0<an.length&&(st=new ft(st,Vt,null,_,yt),_t.push({event:st,listeners:an}))}}if((g&7)===0){e:{if(st=h==="mouseover"||h==="pointerover",ft=h==="mouseout"||h==="pointerout",st&&_!==bM&&(Vt=_.relatedTarget||_.fromElement)&&(Rt(Vt)||Vt[si]))break e;if((ft||st)&&(st=yt.window===yt?yt:(st=yt.ownerDocument)?st.defaultView||st.parentWindow:window,ft?(Vt=_.relatedTarget||_.toElement,ft=it,Vt=Vt?Rt(Vt):null,Vt!==null&&(ur=a(Vt),an=Vt.tag,Vt!==ur||an!==5&&an!==27&&an!==6)&&(Vt=null)):(ft=null,Vt=it),ft!==Vt)){if(an=qL,vt="onMouseLeave",Ze="onMouseEnter",Ge="mouse",(h==="pointerout"||h==="pointerover")&&(an=XL,vt="onPointerLeave",Ze="onPointerEnter",Ge="pointer"),ur=ft==null?st:Re(ft),tt=Vt==null?st:Re(Vt),st=new an(vt,Ge+"leave",ft,_,yt),st.target=ur,st.relatedTarget=tt,vt=null,Rt(yt)===it&&(an=new an(Ze,Ge+"enter",Vt,_,yt),an.target=tt,an.relatedTarget=ur,vt=an),ur=vt,ft&&Vt)t:{for(an=Yie,Ze=ft,Ge=Vt,tt=0,vt=Ze;vt;vt=an(vt))tt++;vt=0;for(var Zt=Ge;Zt;Zt=an(Zt))vt++;for(;0<tt-vt;)Ze=an(Ze),tt--;for(;0<vt-tt;)Ge=an(Ge),vt--;for(;tt--;){if(Ze===Ge||Ge!==null&&Ze===Ge.alternate){an=Ze;break t}Ze=an(Ze),Ge=an(Ge)}an=null}else an=null;ft!==null&&zF(_t,st,ft,an,!1),Vt!==null&&ur!==null&&zF(_t,ur,Vt,an,!0)}}e:{if(st=it?Re(it):window,ft=st.nodeName&&st.nodeName.toLowerCase(),ft==="select"||ft==="input"&&st.type==="file")var Gn=rI;else if(tI(st))if(iI)Gn=oie;else{Gn=aie;var qt=iie}else ft=st.nodeName,!ft||ft.toLowerCase()!=="input"||st.type!=="checkbox"&&st.type!=="radio"?it&&sa(it.elementType)&&(Gn=rI):Gn=sie;if(Gn&&(Gn=Gn(h,it))){nI(_t,Gn,_,yt);break e}qt&&qt(h,st,it),h==="focusout"&&it&&st.type==="number"&&it.memoizedProps.value!=null&&Wt(st,"number",st.value)}switch(qt=it?Re(it):window,h){case"focusin":(tI(qt)||qt.contentEditable==="true")&&(cm=qt,jM=it,px=null);break;case"focusout":px=jM=cm=null;break;case"mousedown":PM=!0;break;case"contextmenu":case"mouseup":case"dragend":PM=!1,hI(_t,_,yt);break;case"selectionchange":if(cie)break;case"keydown":case"keyup":hI(_t,_,yt)}var vn;if(TM)e:{switch(h){case"compositionstart":var In="onCompositionStart";break e;case"compositionend":In="onCompositionEnd";break e;case"compositionupdate":In="onCompositionUpdate";break e}In=void 0}else lm?JL(h,_)&&(In="onCompositionEnd"):h==="keydown"&&_.keyCode===229&&(In="onCompositionStart");In&&(YL&&_.locale!=="ko"&&(lm||In!=="onCompositionStart"?In==="onCompositionEnd"&&lm&&(vn=GL()):(wu=yt,wM="value"in wu?wu.value:wu.textContent,lm=!0)),qt=Fv(it,In),0<qt.length&&(In=new KL(In,h,null,_,yt),_t.push({event:In,listeners:qt}),vn?In.data=vn:(vn=eI(_),vn!==null&&(In.data=vn)))),(vn=Jre?eie(h,_):tie(h,_))&&(In=Fv(it,"onBeforeInput"),0<In.length&&(qt=new KL("onBeforeInput","beforeinput",null,_,yt),_t.push({event:qt,listeners:In}),qt.data=vn)),Wie(_t,h,it,_,yt)}FF(_t,g)})}function zx(h,g,_){return{instance:h,listener:g,currentTarget:_}}function Fv(h,g){for(var _=g+"Capture",M=[];h!==null;){var P=h,I=P.stateNode;if(P=P.tag,P!==5&&P!==26&&P!==27||I===null||(P=ox(h,_),P!=null&&M.unshift(zx(h,P,I)),P=ox(h,g),P!=null&&M.push(zx(h,P,I))),h.tag===3)return M;h=h.return}return[]}function Yie(h){if(h===null)return null;do h=h.return;while(h&&h.tag!==5&&h.tag!==27);return h||null}function zF(h,g,_,M,P){for(var I=g._reactName,J=[];_!==null&&_!==M;){var ge=_,Ie=ge.alternate,it=ge.stateNode;if(ge=ge.tag,Ie!==null&&Ie===M)break;ge!==5&&ge!==26&&ge!==27||it===null||(Ie=it,P?(it=ox(_,I),it!=null&&J.unshift(zx(_,it,Ie))):P||(it=ox(_,I),it!=null&&J.push(zx(_,it,Ie)))),_=_.return}J.length!==0&&h.push({event:g,listeners:J})}var Qie=/\r\n?/g,Zie=/\u0000|\uFFFD/g;function BF(h){return(typeof h=="string"?h:""+h).replace(Qie,`
  9. `).replace(Zie,"")}function $F(h,g){return g=BF(g),BF(h)===g}function cr(h,g,_,M,P,I){switch(_){case"children":typeof M=="string"?g==="body"||g==="textarea"&&M===""||Ua(h,M):(typeof M=="number"||typeof M=="bigint")&&g!=="body"&&Ua(h,""+M);break;case"className":Kt(h,"class",M);break;case"tabIndex":Kt(h,"tabindex",M);break;case"dir":case"role":case"viewBox":case"width":case"height":Kt(h,_,M);break;case"style":pl(h,M,I);break;case"data":if(g!=="object"){Kt(h,"data",M);break}case"src":case"href":if(M===""&&(g!=="a"||_!=="href")){h.removeAttribute(_);break}if(M==null||typeof M=="function"||typeof M=="symbol"||typeof M=="boolean"){h.removeAttribute(_);break}M=Hi(""+M),h.setAttribute(_,M);break;case"action":case"formAction":if(typeof M=="function"){h.setAttribute(_,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof I=="function"&&(_==="formAction"?(g!=="input"&&cr(h,g,"name",P.name,P,null),cr(h,g,"formEncType",P.formEncType,P,null),cr(h,g,"formMethod",P.formMethod,P,null),cr(h,g,"formTarget",P.formTarget,P,null)):(cr(h,g,"encType",P.encType,P,null),cr(h,g,"method",P.method,P,null),cr(h,g,"target",P.target,P,null)));if(M==null||typeof M=="symbol"||typeof M=="boolean"){h.removeAttribute(_);break}M=Hi(""+M),h.setAttribute(_,M);break;case"onClick":M!=null&&(h.onclick=nc);break;case"onScroll":M!=null&&Pn("scroll",h);break;case"onScrollEnd":M!=null&&Pn("scrollend",h);break;case"dangerouslySetInnerHTML":if(M!=null){if(typeof M!="object"||!("__html"in M))throw Error(r(61));if(_=M.__html,_!=null){if(P.children!=null)throw Error(r(60));h.innerHTML=_}}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}_=Hi(""+M),h.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",_);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(_,""+M):h.removeAttribute(_);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(_,""):h.removeAttribute(_);break;case"capture":case"download":M===!0?h.setAttribute(_,""):M!==!1&&M!=null&&typeof M!="function"&&typeof M!="symbol"?h.setAttribute(_,M):h.removeAttribute(_);break;case"cols":case"rows":case"size":case"span":M!=null&&typeof M!="function"&&typeof M!="symbol"&&!isNaN(M)&&1<=M?h.setAttribute(_,M):h.removeAttribute(_);break;case"rowSpan":case"start":M==null||typeof M=="function"||typeof M=="symbol"||isNaN(M)?h.removeAttribute(_):h.setAttribute(_,M);break;case"popover":Pn("beforetoggle",h),Pn("toggle",h),Qt(h,"popover",M);break;case"xlinkActuate":fn(h,"http://www.w3.org/1999/xlink","xlink:actuate",M);break;case"xlinkArcrole":fn(h,"http://www.w3.org/1999/xlink","xlink:arcrole",M);break;case"xlinkRole":fn(h,"http://www.w3.org/1999/xlink","xlink:role",M);break;case"xlinkShow":fn(h,"http://www.w3.org/1999/xlink","xlink:show",M);break;case"xlinkTitle":fn(h,"http://www.w3.org/1999/xlink","xlink:title",M);break;case"xlinkType":fn(h,"http://www.w3.org/1999/xlink","xlink:type",M);break;case"xmlBase":fn(h,"http://www.w3.org/XML/1998/namespace","xml:base",M);break;case"xmlLang":fn(h,"http://www.w3.org/XML/1998/namespace","xml:lang",M);break;case"xmlSpace":fn(h,"http://www.w3.org/XML/1998/namespace","xml:space",M);break;case"is":Qt(h,"is",M);break;case"innerText":case"textContent":break;default:(!(2<_.length)||_[0]!=="o"&&_[0]!=="O"||_[1]!=="n"&&_[1]!=="N")&&(_=tc.get(_)||_,Qt(h,_,M))}}function rT(h,g,_,M,P,I){switch(_){case"style":pl(h,M,I);break;case"dangerouslySetInnerHTML":if(M!=null){if(typeof M!="object"||!("__html"in M))throw Error(r(61));if(_=M.__html,_!=null){if(P.children!=null)throw Error(r(60));h.innerHTML=_}}break;case"children":typeof M=="string"?Ua(h,M):(typeof M=="number"||typeof M=="bigint")&&Ua(h,""+M);break;case"onScroll":M!=null&&Pn("scroll",h);break;case"onScrollEnd":M!=null&&Pn("scrollend",h);break;case"onClick":M!=null&&(h.onclick=nc);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!mt.hasOwnProperty(_))e:{if(_[0]==="o"&&_[1]==="n"&&(P=_.endsWith("Capture"),g=_.slice(2,P?_.length-7:void 0),I=h[Sr]||null,I=I!=null?I[_]:null,typeof I=="function"&&h.removeEventListener(g,I,P),typeof M=="function")){typeof I!="function"&&I!==null&&(_ in h?h[_]=null:h.hasAttribute(_)&&h.removeAttribute(_)),h.addEventListener(g,M,P);break e}_ in h?h[_]=M:M===!0?h.setAttribute(_,""):Qt(h,_,M)}}}function ua(h,g,_){switch(g){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Pn("error",h),Pn("load",h);var M=!1,P=!1,I;for(I in _)if(_.hasOwnProperty(I)){var J=_[I];if(J!=null)switch(I){case"src":M=!0;break;case"srcSet":P=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,g));default:cr(h,g,I,J,_,null)}}P&&cr(h,g,"srcSet",_.srcSet,_,null),M&&cr(h,g,"src",_.src,_,null);return;case"input":Pn("invalid",h);var ge=I=J=P=null,Ie=null,it=null;for(M in _)if(_.hasOwnProperty(M)){var yt=_[M];if(yt!=null)switch(M){case"name":P=yt;break;case"type":J=yt;break;case"checked":Ie=yt;break;case"defaultChecked":it=yt;break;case"value":I=yt;break;case"defaultValue":ge=yt;break;case"children":case"dangerouslySetInnerHTML":if(yt!=null)throw Error(r(137,g));break;default:cr(h,g,M,yt,_,null)}}kn(h,I,ge,Ie,it,J,P,!1);return;case"select":Pn("invalid",h),M=J=I=null;for(P in _)if(_.hasOwnProperty(P)&&(ge=_[P],ge!=null))switch(P){case"value":I=ge;break;case"defaultValue":J=ge;break;case"multiple":M=ge;default:cr(h,g,P,ge,_,null)}g=I,_=J,h.multiple=!!M,g!=null?en(h,!!M,g,!1):_!=null&&en(h,!!M,_,!0);return;case"textarea":Pn("invalid",h),I=P=M=null;for(J in _)if(_.hasOwnProperty(J)&&(ge=_[J],ge!=null))switch(J){case"value":M=ge;break;case"defaultValue":P=ge;break;case"children":I=ge;break;case"dangerouslySetInnerHTML":if(ge!=null)throw Error(r(91));break;default:cr(h,g,J,ge,_,null)}Or(h,M,P,I);return;case"option":for(Ie in _)if(_.hasOwnProperty(Ie)&&(M=_[Ie],M!=null))switch(Ie){case"selected":h.selected=M&&typeof M!="function"&&typeof M!="symbol";break;default:cr(h,g,Ie,M,_,null)}return;case"dialog":Pn("beforetoggle",h),Pn("toggle",h),Pn("cancel",h),Pn("close",h);break;case"iframe":case"object":Pn("load",h);break;case"video":case"audio":for(M=0;M<Ux.length;M++)Pn(Ux[M],h);break;case"image":Pn("error",h),Pn("load",h);break;case"details":Pn("toggle",h);break;case"embed":case"source":case"link":Pn("error",h),Pn("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 _)if(_.hasOwnProperty(it)&&(M=_[it],M!=null))switch(it){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,g));default:cr(h,g,it,M,_,null)}return;default:if(sa(g)){for(yt in _)_.hasOwnProperty(yt)&&(M=_[yt],M!==void 0&&rT(h,g,yt,M,_,void 0));return}}for(ge in _)_.hasOwnProperty(ge)&&(M=_[ge],M!=null&&cr(h,g,ge,M,_,null))}function Jie(h,g,_,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,I=null,J=null,ge=null,Ie=null,it=null,yt=null;for(ft in _){var _t=_[ft];if(_.hasOwnProperty(ft)&&_t!=null)switch(ft){case"checked":break;case"value":break;case"defaultValue":Ie=_t;default:M.hasOwnProperty(ft)||cr(h,g,ft,null,M,_t)}}for(var st in M){var ft=M[st];if(_t=_[st],M.hasOwnProperty(st)&&(ft!=null||_t!=null))switch(st){case"type":I=ft;break;case"name":P=ft;break;case"checked":it=ft;break;case"defaultChecked":yt=ft;break;case"value":J=ft;break;case"defaultValue":ge=ft;break;case"children":case"dangerouslySetInnerHTML":if(ft!=null)throw Error(r(137,g));break;default:ft!==_t&&cr(h,g,st,ft,M,_t)}}sr(h,J,ge,Ie,it,yt,I,P);return;case"select":ft=J=ge=st=null;for(I in _)if(Ie=_[I],_.hasOwnProperty(I)&&Ie!=null)switch(I){case"value":break;case"multiple":ft=Ie;default:M.hasOwnProperty(I)||cr(h,g,I,null,M,Ie)}for(P in M)if(I=M[P],Ie=_[P],M.hasOwnProperty(P)&&(I!=null||Ie!=null))switch(P){case"value":st=I;break;case"defaultValue":ge=I;break;case"multiple":J=I;default:I!==Ie&&cr(h,g,P,I,M,Ie)}g=ge,_=J,M=ft,st!=null?en(h,!!_,st,!1):!!M!=!!_&&(g!=null?en(h,!!_,g,!0):en(h,!!_,_?[]:"",!1));return;case"textarea":ft=st=null;for(ge in _)if(P=_[ge],_.hasOwnProperty(ge)&&P!=null&&!M.hasOwnProperty(ge))switch(ge){case"value":break;case"children":break;default:cr(h,g,ge,null,M,P)}for(J in M)if(P=M[J],I=_[J],M.hasOwnProperty(J)&&(P!=null||I!=null))switch(J){case"value":st=P;break;case"defaultValue":ft=P;break;case"children":break;case"dangerouslySetInnerHTML":if(P!=null)throw Error(r(91));break;default:P!==I&&cr(h,g,J,P,M,I)}or(h,st,ft);return;case"option":for(var Vt in _)if(st=_[Vt],_.hasOwnProperty(Vt)&&st!=null&&!M.hasOwnProperty(Vt))switch(Vt){case"selected":h.selected=!1;break;default:cr(h,g,Vt,null,M,st)}for(Ie in M)if(st=M[Ie],ft=_[Ie],M.hasOwnProperty(Ie)&&st!==ft&&(st!=null||ft!=null))switch(Ie){case"selected":h.selected=st&&typeof st!="function"&&typeof st!="symbol";break;default:cr(h,g,Ie,st,M,ft)}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 an in _)st=_[an],_.hasOwnProperty(an)&&st!=null&&!M.hasOwnProperty(an)&&cr(h,g,an,null,M,st);for(it in M)if(st=M[it],ft=_[it],M.hasOwnProperty(it)&&st!==ft&&(st!=null||ft!=null))switch(it){case"children":case"dangerouslySetInnerHTML":if(st!=null)throw Error(r(137,g));break;default:cr(h,g,it,st,M,ft)}return;default:if(sa(g)){for(var ur in _)st=_[ur],_.hasOwnProperty(ur)&&st!==void 0&&!M.hasOwnProperty(ur)&&rT(h,g,ur,void 0,M,st);for(yt in M)st=M[yt],ft=_[yt],!M.hasOwnProperty(yt)||st===ft||st===void 0&&ft===void 0||rT(h,g,yt,st,M,ft);return}}for(var Ze in _)st=_[Ze],_.hasOwnProperty(Ze)&&st!=null&&!M.hasOwnProperty(Ze)&&cr(h,g,Ze,null,M,st);for(_t in M)st=M[_t],ft=_[_t],!M.hasOwnProperty(_t)||st===ft||st==null&&ft==null||cr(h,g,_t,st,M,ft)}function HF(h){switch(h){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function eae(){if(typeof performance.getEntriesByType=="function"){for(var h=0,g=0,_=performance.getEntriesByType("resource"),M=0;M<_.length;M++){var P=_[M],I=P.transferSize,J=P.initiatorType,ge=P.duration;if(I&&ge&&HF(J)){for(J=0,ge=P.responseEnd,M+=1;M<_.length;M++){var Ie=_[M],it=Ie.startTime;if(it>ge)break;var yt=Ie.transferSize,_t=Ie.initiatorType;yt&&HF(_t)&&(Ie=Ie.responseEnd,J+=yt*(Ie<ge?1:(ge-it)/(Ie-it)))}if(--M,g+=8*(I+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 iT=null,aT=null;function Uv(h){return h.nodeType===9?h:h.ownerDocument}function VF(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 GF(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 sT(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 oT=null;function tae(){var h=window.event;return h&&h.type==="popstate"?h===oT?!1:(oT=h,!0):(oT=null,!1)}var WF=typeof setTimeout=="function"?setTimeout:void 0,nae=typeof clearTimeout=="function"?clearTimeout:void 0,qF=typeof Promise=="function"?Promise:void 0,rae=typeof queueMicrotask=="function"?queueMicrotask:typeof qF<"u"?function(h){return qF.resolve(null).then(h).catch(iae)}:WF;function iae(h){setTimeout(function(){throw h})}function Uu(h){return h==="head"}function KF(h,g){var _=g,M=0;do{var P=_.nextSibling;if(h.removeChild(_),P&&P.nodeType===8)if(_=P.data,_==="/$"||_==="/&"){if(M===0){h.removeChild(P),Lm(g);return}M--}else if(_==="$"||_==="$?"||_==="$~"||_==="$!"||_==="&")M++;else if(_==="html")Bx(h.ownerDocument.documentElement);else if(_==="head"){_=h.ownerDocument.head,Bx(_);for(var I=_.firstChild;I;){var J=I.nextSibling,ge=I.nodeName;I[ct]||ge==="SCRIPT"||ge==="STYLE"||ge==="LINK"&&I.rel.toLowerCase()==="stylesheet"||_.removeChild(I),I=J}}else _==="body"&&Bx(h.ownerDocument.body);_=P}while(_);Lm(g)}function XF(h,g){var _=h;h=0;do{var M=_.nextSibling;if(_.nodeType===1?g?(_._stashedDisplay=_.style.display,_.style.display="none"):(_.style.display=_._stashedDisplay||"",_.getAttribute("style")===""&&_.removeAttribute("style")):_.nodeType===3&&(g?(_._stashedText=_.nodeValue,_.nodeValue=""):_.nodeValue=_._stashedText||""),M&&M.nodeType===8)if(_=M.data,_==="/$"){if(h===0)break;h--}else _!=="$"&&_!=="$?"&&_!=="$~"&&_!=="$!"||h++;_=M}while(_)}function lT(h){var g=h.firstChild;for(g&&g.nodeType===10&&(g=g.nextSibling);g;){var _=g;switch(g=g.nextSibling,_.nodeName){case"HTML":case"HEAD":case"BODY":lT(_),rt(_);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(_.rel.toLowerCase()==="stylesheet")continue}h.removeChild(_)}}function aae(h,g,_,M){for(;h.nodeType===1;){var P=_;if(h.nodeName.toLowerCase()!==g.toLowerCase()){if(!M&&(h.nodeName!=="INPUT"||h.type!=="hidden"))break}else if(M){if(!h[ct])switch(g){case"meta":if(!h.hasAttribute("itemprop"))break;return h;case"link":if(I=h.getAttribute("rel"),I==="stylesheet"&&h.hasAttribute("data-precedence"))break;if(I!==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(I=h.getAttribute("src"),(I!==(P.src==null?null:P.src)||h.getAttribute("type")!==(P.type==null?null:P.type)||h.getAttribute("crossorigin")!==(P.crossOrigin==null?null:P.crossOrigin))&&I&&h.hasAttribute("async")&&!h.hasAttribute("itemprop"))break;return h;default:return h}}else if(g==="input"&&h.type==="hidden"){var I=P.name==null?null:""+P.name;if(P.type==="hidden"&&h.getAttribute("name")===I)return h}else return h;if(h=so(h.nextSibling),h===null)break}return null}function sae(h,g,_){if(g==="")return null;for(;h.nodeType!==3;)if((h.nodeType!==1||h.nodeName!=="INPUT"||h.type!=="hidden")&&!_||(h=so(h.nextSibling),h===null))return null;return h}function YF(h,g){for(;h.nodeType!==8;)if((h.nodeType!==1||h.nodeName!=="INPUT"||h.type!=="hidden")&&!g||(h=so(h.nextSibling),h===null))return null;return h}function cT(h){return h.data==="$?"||h.data==="$~"}function uT(h){return h.data==="$!"||h.data==="$?"&&h.ownerDocument.readyState!=="loading"}function oae(h,g){var _=h.ownerDocument;if(h.data==="$~")h._reactRetry=g;else if(h.data!=="$?"||_.readyState!=="loading")g();else{var M=function(){g(),_.removeEventListener("DOMContentLoaded",M)};_.addEventListener("DOMContentLoaded",M),h._reactRetry=M}}function so(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 dT=null;function QF(h){h=h.nextSibling;for(var g=0;h;){if(h.nodeType===8){var _=h.data;if(_==="/$"||_==="/&"){if(g===0)return so(h.nextSibling);g--}else _!=="$"&&_!=="$!"&&_!=="$?"&&_!=="$~"&&_!=="&"||g++}h=h.nextSibling}return null}function ZF(h){h=h.previousSibling;for(var g=0;h;){if(h.nodeType===8){var _=h.data;if(_==="$"||_==="$!"||_==="$?"||_==="$~"||_==="&"){if(g===0)return h;g--}else _!=="/$"&&_!=="/&"||g++}h=h.previousSibling}return null}function JF(h,g,_){switch(g=Uv(_),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 Bx(h){for(var g=h.attributes;g.length;)h.removeAttributeNode(g[0]);rt(h)}var oo=new Map,eU=new Set;function zv(h){return typeof h.getRootNode=="function"?h.getRootNode():h.nodeType===9?h:h.ownerDocument}var bc=q.d;q.d={f:lae,r:cae,D:uae,C:dae,L:hae,m:fae,X:pae,S:mae,M:gae};function lae(){var h=bc.f(),g=jv();return h||g}function cae(h){var g=de(h);g!==null&&g.tag===5&&g.type==="form"?x5(g):bc.r(h)}var Rm=typeof document>"u"?null:document;function tU(h,g,_){var M=Rm;if(M&&typeof g=="string"&&g){var P=rn(g);P='link[rel="'+h+'"][href="'+P+'"]',typeof _=="string"&&(P+='[crossorigin="'+_+'"]'),eU.has(P)||(eU.add(P),h={rel:h,crossOrigin:_,href:g},M.querySelector(P)===null&&(g=M.createElement("link"),ua(g,"link",h),He(g),M.head.appendChild(g)))}}function uae(h){bc.D(h),tU("dns-prefetch",h,null)}function dae(h,g){bc.C(h,g),tU("preconnect",h,g)}function hae(h,g,_){bc.L(h,g,_);var M=Rm;if(M&&h&&g){var P='link[rel="preload"][as="'+rn(g)+'"]';g==="image"&&_&&_.imageSrcSet?(P+='[imagesrcset="'+rn(_.imageSrcSet)+'"]',typeof _.imageSizes=="string"&&(P+='[imagesizes="'+rn(_.imageSizes)+'"]')):P+='[href="'+rn(h)+'"]';var I=P;switch(g){case"style":I=Dm(h);break;case"script":I=Om(h)}oo.has(I)||(h=f({rel:"preload",href:g==="image"&&_&&_.imageSrcSet?void 0:h,as:g},_),oo.set(I,h),M.querySelector(P)!==null||g==="style"&&M.querySelector($x(I))||g==="script"&&M.querySelector(Hx(I))||(g=M.createElement("link"),ua(g,"link",h),He(g),M.head.appendChild(g)))}}function fae(h,g){bc.m(h,g);var _=Rm;if(_&&h){var M=g&&typeof g.as=="string"?g.as:"script",P='link[rel="modulepreload"][as="'+rn(M)+'"][href="'+rn(h)+'"]',I=P;switch(M){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":I=Om(h)}if(!oo.has(I)&&(h=f({rel:"modulepreload",href:h},g),oo.set(I,h),_.querySelector(P)===null)){switch(M){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(_.querySelector(Hx(I)))return}M=_.createElement("link"),ua(M,"link",h),He(M),_.head.appendChild(M)}}}function mae(h,g,_){bc.S(h,g,_);var M=Rm;if(M&&h){var P=Ve(M).hoistableStyles,I=Dm(h);g=g||"default";var J=P.get(I);if(!J){var ge={loading:0,preload:null};if(J=M.querySelector($x(I)))ge.loading=5;else{h=f({rel:"stylesheet",href:h,"data-precedence":g},_),(_=oo.get(I))&&hT(h,_);var Ie=J=M.createElement("link");He(Ie),ua(Ie,"link",h),Ie._p=new Promise(function(it,yt){Ie.onload=it,Ie.onerror=yt}),Ie.addEventListener("load",function(){ge.loading|=1}),Ie.addEventListener("error",function(){ge.loading|=2}),ge.loading|=4,Bv(J,g,M)}J={type:"stylesheet",instance:J,count:1,state:ge},P.set(I,J)}}}function pae(h,g){bc.X(h,g);var _=Rm;if(_&&h){var M=Ve(_).hoistableScripts,P=Om(h),I=M.get(P);I||(I=_.querySelector(Hx(P)),I||(h=f({src:h,async:!0},g),(g=oo.get(P))&&fT(h,g),I=_.createElement("script"),He(I),ua(I,"link",h),_.head.appendChild(I)),I={type:"script",instance:I,count:1,state:null},M.set(P,I))}}function gae(h,g){bc.M(h,g);var _=Rm;if(_&&h){var M=Ve(_).hoistableScripts,P=Om(h),I=M.get(P);I||(I=_.querySelector(Hx(P)),I||(h=f({src:h,async:!0,type:"module"},g),(g=oo.get(P))&&fT(h,g),I=_.createElement("script"),He(I),ua(I,"link",h),_.head.appendChild(I)),I={type:"script",instance:I,count:1,state:null},M.set(P,I))}}function nU(h,g,_,M){var P=(P=pe.current)?zv(P):null;if(!P)throw Error(r(446));switch(h){case"meta":case"title":return null;case"style":return typeof _.precedence=="string"&&typeof _.href=="string"?(g=Dm(_.href),_=Ve(P).hoistableStyles,M=_.get(g),M||(M={type:"style",instance:null,count:0,state:null},_.set(g,M)),M):{type:"void",instance:null,count:0,state:null};case"link":if(_.rel==="stylesheet"&&typeof _.href=="string"&&typeof _.precedence=="string"){h=Dm(_.href);var I=Ve(P).hoistableStyles,J=I.get(h);if(J||(P=P.ownerDocument||P,J={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},I.set(h,J),(I=P.querySelector($x(h)))&&!I._p&&(J.instance=I,J.state.loading=5),oo.has(h)||(_={rel:"preload",as:"style",href:_.href,crossOrigin:_.crossOrigin,integrity:_.integrity,media:_.media,hrefLang:_.hrefLang,referrerPolicy:_.referrerPolicy},oo.set(h,_),I||xae(P,h,_,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=_.async,_=_.src,typeof _=="string"&&g&&typeof g!="function"&&typeof g!="symbol"?(g=Om(_),_=Ve(P).hoistableScripts,M=_.get(g),M||(M={type:"script",instance:null,count:0,state:null},_.set(g,M)),M):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,h))}}function Dm(h){return'href="'+rn(h)+'"'}function $x(h){return'link[rel="stylesheet"]['+h+"]"}function rU(h){return f({},h,{"data-precedence":h.precedence,precedence:null})}function xae(h,g,_,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}),ua(g,"link",_),He(g),h.head.appendChild(g))}function Om(h){return'[src="'+rn(h)+'"]'}function Hx(h){return"script[async]"+h}function iU(h,g,_){if(g.count++,g.instance===null)switch(g.type){case"style":var M=h.querySelector('style[data-href~="'+rn(_.href)+'"]');if(M)return g.instance=M,He(M),M;var P=f({},_,{"data-href":_.href,"data-precedence":_.precedence,href:null,precedence:null});return M=(h.ownerDocument||h).createElement("style"),He(M),ua(M,"style",P),Bv(M,_.precedence,h),g.instance=M;case"stylesheet":P=Dm(_.href);var I=h.querySelector($x(P));if(I)return g.state.loading|=4,g.instance=I,He(I),I;M=rU(_),(P=oo.get(P))&&hT(M,P),I=(h.ownerDocument||h).createElement("link"),He(I);var J=I;return J._p=new Promise(function(ge,Ie){J.onload=ge,J.onerror=Ie}),ua(I,"link",M),g.state.loading|=4,Bv(I,_.precedence,h),g.instance=I;case"script":return I=Om(_.src),(P=h.querySelector(Hx(I)))?(g.instance=P,He(P),P):(M=_,(P=oo.get(I))&&(M=f({},_),fT(M,P)),h=h.ownerDocument||h,P=h.createElement("script"),He(P),ua(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,Bv(M,_.precedence,h));return g.instance}function Bv(h,g,_){for(var M=_.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),P=M.length?M[M.length-1]:null,I=P,J=0;J<M.length;J++){var ge=M[J];if(ge.dataset.precedence===g)I=ge;else if(I!==P)break}I?I.parentNode.insertBefore(h,I.nextSibling):(g=_.nodeType===9?_.head:_,g.insertBefore(h,g.firstChild))}function hT(h,g){h.crossOrigin==null&&(h.crossOrigin=g.crossOrigin),h.referrerPolicy==null&&(h.referrerPolicy=g.referrerPolicy),h.title==null&&(h.title=g.title)}function fT(h,g){h.crossOrigin==null&&(h.crossOrigin=g.crossOrigin),h.referrerPolicy==null&&(h.referrerPolicy=g.referrerPolicy),h.integrity==null&&(h.integrity=g.integrity)}var $v=null;function aU(h,g,_){if($v===null){var M=new Map,P=$v=new Map;P.set(_,M)}else P=$v,M=P.get(_),M||(M=new Map,P.set(_,M));if(M.has(h))return M;for(M.set(h,null),_=_.getElementsByTagName(h),P=0;P<_.length;P++){var I=_[P];if(!(I[ct]||I[sn]||h==="link"&&I.getAttribute("rel")==="stylesheet")&&I.namespaceURI!=="http://www.w3.org/2000/svg"){var J=I.getAttribute(g)||"";J=h+J;var ge=M.get(J);ge?ge.push(I):M.set(J,[I])}}return M}function sU(h,g,_){h=h.ownerDocument||h,h.head.insertBefore(_,g==="title"?h.querySelector("head > title"):null)}function bae(h,g,_){if(_===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 oU(h){return!(h.type==="stylesheet"&&(h.state.loading&3)===0)}function yae(h,g,_,M){if(_.type==="stylesheet"&&(typeof M.media!="string"||matchMedia(M.media).matches!==!1)&&(_.state.loading&4)===0){if(_.instance===null){var P=Dm(M.href),I=g.querySelector($x(P));if(I){g=I._p,g!==null&&typeof g=="object"&&typeof g.then=="function"&&(h.count++,h=Hv.bind(h),g.then(h,h)),_.state.loading|=4,_.instance=I,He(I);return}I=g.ownerDocument||g,M=rU(M),(P=oo.get(P))&&hT(M,P),I=I.createElement("link"),He(I);var J=I;J._p=new Promise(function(ge,Ie){J.onload=ge,J.onerror=Ie}),ua(I,"link",M),_.instance=I}h.stylesheets===null&&(h.stylesheets=new Map),h.stylesheets.set(_,g),(g=_.state.preload)&&(_.state.loading&3)===0&&(h.count++,_=Hv.bind(h),g.addEventListener("load",_),g.addEventListener("error",_))}}var mT=0;function vae(h,g){return h.stylesheets&&h.count===0&&Gv(h,h.stylesheets),0<h.count||0<h.imgCount?function(_){var M=setTimeout(function(){if(h.stylesheets&&Gv(h,h.stylesheets),h.unsuspend){var I=h.unsuspend;h.unsuspend=null,I()}},6e4+g);0<h.imgBytes&&mT===0&&(mT=62500*eae());var P=setTimeout(function(){if(h.waitingForImages=!1,h.count===0&&(h.stylesheets&&Gv(h,h.stylesheets),h.unsuspend)){var I=h.unsuspend;h.unsuspend=null,I()}},(h.imgBytes>mT?50:800)+g);return h.unsuspend=_,function(){h.unsuspend=null,clearTimeout(M),clearTimeout(P)}}:null}function Hv(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Gv(this,this.stylesheets);else if(this.unsuspend){var h=this.unsuspend;this.unsuspend=null,h()}}}var Vv=null;function Gv(h,g){h.stylesheets=null,h.unsuspend!==null&&(h.count++,Vv=new Map,g.forEach(_ae,h),Vv=null,Hv.call(h))}function _ae(h,g){if(!(g.state.loading&4)){var _=Vv.get(h);if(_)var M=_.get(null);else{_=new Map,Vv.set(h,_);for(var P=h.querySelectorAll("link[data-precedence],style[data-precedence]"),I=0;I<P.length;I++){var J=P[I];(J.nodeName==="LINK"||J.getAttribute("media")!=="not all")&&(_.set(J.dataset.precedence,J),M=J)}M&&_.set(null,M)}P=g.instance,J=P.getAttribute("data-precedence"),I=_.get(J)||M,I===M&&_.set(null,P),_.set(J,P),this.count++,M=Hv.bind(this),P.addEventListener("load",M),P.addEventListener("error",M),I?I.parentNode.insertBefore(P,I.nextSibling):(h=h.nodeType===9?h.head:h,h.insertBefore(P,h.firstChild)),g.state.loading|=4}}var Vx={$$typeof:S,Provider:null,Consumer:null,_currentValue:Q,_currentValue2:Q,_threadCount:0};function wae(h,g,_,M,P,I,J,ge,Ie){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=Ot(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ot(0),this.hiddenUpdates=Ot(null),this.identifierPrefix=M,this.onUncaughtError=P,this.onCaughtError=I,this.onRecoverableError=J,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=Ie,this.incompleteTransitions=new Map}function lU(h,g,_,M,P,I,J,ge,Ie,it,yt,_t){return h=new wae(h,g,_,J,Ie,it,yt,_t,ge),g=1,I===!0&&(g|=24),I=As(3,null,null,g),h.current=I,I.stateNode=h,g=qM(),g.refCount++,h.pooledCache=g,g.refCount++,I.memoizedState={element:M,isDehydrated:_,cache:g},QM(I),h}function cU(h){return h?(h=hm,h):hm}function uU(h,g,_,M,P,I){P=cU(P),M.context===null?M.context=P:M.pendingContext=P,M=Au(g),M.payload={element:_},I=I===void 0?null:I,I!==null&&(M.callback=I),_=Cu(h,M,g),_!==null&&(cs(_,h,g),wx(_,h,g))}function dU(h,g){if(h=h.memoizedState,h!==null&&h.dehydrated!==null){var _=h.retryLane;h.retryLane=_!==0&&_<g?_:g}}function pT(h,g){dU(h,g),(h=h.alternate)&&dU(h,g)}function hU(h){if(h.tag===13||h.tag===31){var g=ph(h,67108864);g!==null&&cs(g,h,67108864),pT(h,67108864)}}function fU(h){if(h.tag===13||h.tag===31){var g=Rs();g=ln(g);var _=ph(h,g);_!==null&&cs(_,h,g),pT(h,g)}}var Wv=!0;function Sae(h,g,_,M){var P=Y.T;Y.T=null;var I=q.p;try{q.p=2,gT(h,g,_,M)}finally{q.p=I,Y.T=P}}function Nae(h,g,_,M){var P=Y.T;Y.T=null;var I=q.p;try{q.p=8,gT(h,g,_,M)}finally{q.p=I,Y.T=P}}function gT(h,g,_,M){if(Wv){var P=xT(M);if(P===null)nT(h,g,M,qv,_),pU(h,M);else if(Eae(P,h,g,_,M))M.stopPropagation();else if(pU(h,M),g&4&&-1<Mae.indexOf(h)){for(;P!==null;){var I=de(P);if(I!==null)switch(I.tag){case 3:if(I=I.stateNode,I.current.memoizedState.isDehydrated){var J=Ue(I.pendingLanes);if(J!==0){var ge=I;for(ge.pendingLanes|=2,ge.entangledLanes|=2;J;){var Ie=1<<31-Se(J);ge.entanglements[1]|=Ie,J&=~Ie}yl(I),(Yn&6)===0&&(Cv=D()+500,Fx(0))}}break;case 31:case 13:ge=ph(I,2),ge!==null&&cs(ge,I,2),jv(),pT(I,2)}if(I=xT(M),I===null&&nT(h,g,M,qv,_),I===P)break;P=I}P!==null&&M.stopPropagation()}else nT(h,g,M,null,_)}}function xT(h){return h=yM(h),bT(h)}var qv=null;function bT(h){if(qv=null,h=Rt(h),h!==null){var g=a(h);if(g===null)h=null;else{var _=g.tag;if(_===13){if(h=o(g),h!==null)return h;h=null}else if(_===31){if(h=l(g),h!==null)return h;h=null}else if(_===3){if(g.stateNode.current.memoizedState.isDehydrated)return g.tag===3?g.stateNode.containerInfo:null;h=null}else g!==h&&(h=null)}}return qv=h,null}function mU(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(Z()){case xe:return 2;case Ne:return 8;case ve:case $e:return 32;case Le:return 268435456;default:return 32}default:return 32}}var yT=!1,zu=null,Bu=null,$u=null,Gx=new Map,Wx=new Map,Hu=[],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 pU(h,g){switch(h){case"focusin":case"focusout":zu=null;break;case"dragenter":case"dragleave":Bu=null;break;case"mouseover":case"mouseout":$u=null;break;case"pointerover":case"pointerout":Gx.delete(g.pointerId);break;case"gotpointercapture":case"lostpointercapture":Wx.delete(g.pointerId)}}function qx(h,g,_,M,P,I){return h===null||h.nativeEvent!==I?(h={blockedOn:g,domEventName:_,eventSystemFlags:M,nativeEvent:I,targetContainers:[P]},g!==null&&(g=de(g),g!==null&&hU(g)),h):(h.eventSystemFlags|=M,g=h.targetContainers,P!==null&&g.indexOf(P)===-1&&g.push(P),h)}function Eae(h,g,_,M,P){switch(g){case"focusin":return zu=qx(zu,h,g,_,M,P),!0;case"dragenter":return Bu=qx(Bu,h,g,_,M,P),!0;case"mouseover":return $u=qx($u,h,g,_,M,P),!0;case"pointerover":var I=P.pointerId;return Gx.set(I,qx(Gx.get(I)||null,h,g,_,M,P)),!0;case"gotpointercapture":return I=P.pointerId,Wx.set(I,qx(Wx.get(I)||null,h,g,_,M,P)),!0}return!1}function gU(h){var g=Rt(h.target);if(g!==null){var _=a(g);if(_!==null){if(g=_.tag,g===13){if(g=o(_),g!==null){h.blockedOn=g,Xr(h.priority,function(){fU(_)});return}}else if(g===31){if(g=l(_),g!==null){h.blockedOn=g,Xr(h.priority,function(){fU(_)});return}}else if(g===3&&_.stateNode.current.memoizedState.isDehydrated){h.blockedOn=_.tag===3?_.stateNode.containerInfo:null;return}}}h.blockedOn=null}function Kv(h){if(h.blockedOn!==null)return!1;for(var g=h.targetContainers;0<g.length;){var _=xT(h.nativeEvent);if(_===null){_=h.nativeEvent;var M=new _.constructor(_.type,_);bM=M,_.target.dispatchEvent(M),bM=null}else return g=de(_),g!==null&&hU(g),h.blockedOn=_,!1;g.shift()}return!0}function xU(h,g,_){Kv(h)&&_.delete(g)}function Tae(){yT=!1,zu!==null&&Kv(zu)&&(zu=null),Bu!==null&&Kv(Bu)&&(Bu=null),$u!==null&&Kv($u)&&($u=null),Gx.forEach(xU),Wx.forEach(xU)}function Xv(h,g){h.blockedOn===g&&(h.blockedOn=null,yT||(yT=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Tae)))}var Yv=null;function bU(h){Yv!==h&&(Yv=h,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){Yv===h&&(Yv=null);for(var g=0;g<h.length;g+=3){var _=h[g],M=h[g+1],P=h[g+2];if(typeof M!="function"){if(bT(M||_)===null)continue;break}var I=de(_);I!==null&&(h.splice(g,3),g-=3,xE(I,{pending:!0,data:P,method:_.method,action:M},M,P))}}))}function Lm(h){function g(Ie){return Xv(Ie,h)}zu!==null&&Xv(zu,h),Bu!==null&&Xv(Bu,h),$u!==null&&Xv($u,h),Gx.forEach(g),Wx.forEach(g);for(var _=0;_<Hu.length;_++){var M=Hu[_];M.blockedOn===h&&(M.blockedOn=null)}for(;0<Hu.length&&(_=Hu[0],_.blockedOn===null);)gU(_),_.blockedOn===null&&Hu.shift();if(_=(h.ownerDocument||h).$$reactFormReplay,_!=null)for(M=0;M<_.length;M+=3){var P=_[M],I=_[M+1],J=P[Sr]||null;if(typeof I=="function")J||bU(_);else if(J){var ge=null;if(I&&I.hasAttribute("formAction")){if(P=I,J=I[Sr]||null)ge=J.formAction;else if(bT(P)!==null)continue}else ge=J.action;typeof ge=="function"?_[M+1]=ge:(_.splice(M,3),M-=3),bU(_)}}}function yU(){function h(I){I.canIntercept&&I.info==="react-transition"&&I.intercept({handler:function(){return new Promise(function(J){return P=J})},focusReset:"manual",scroll:"manual"})}function g(){P!==null&&(P(),P=null),M||setTimeout(_,20)}function _(){if(!M&&!navigation.transition){var I=navigation.currentEntry;I&&I.url!=null&&navigation.navigate(I.url,{state:I.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var M=!1,P=null;return navigation.addEventListener("navigate",h),navigation.addEventListener("navigatesuccess",g),navigation.addEventListener("navigateerror",g),setTimeout(_,100),function(){M=!0,navigation.removeEventListener("navigate",h),navigation.removeEventListener("navigatesuccess",g),navigation.removeEventListener("navigateerror",g),P!==null&&(P(),P=null)}}}function vT(h){this._internalRoot=h}Qv.prototype.render=vT.prototype.render=function(h){var g=this._internalRoot;if(g===null)throw Error(r(409));var _=g.current,M=Rs();uU(_,M,h,g,null,null)},Qv.prototype.unmount=vT.prototype.unmount=function(){var h=this._internalRoot;if(h!==null){this._internalRoot=null;var g=h.containerInfo;uU(h.current,2,null,h,null,null),jv(),g[si]=null}};function Qv(h){this._internalRoot=h}Qv.prototype.unstable_scheduleHydration=function(h){if(h){var g=Rr();h={blockedOn:null,target:h,priority:g};for(var _=0;_<Hu.length&&g!==0&&g<Hu[_].priority;_++);Hu.splice(_,0,h),_===0&&gU(h)}};var vU=e.version;if(vU!=="19.2.0")throw Error(r(527,vU,"19.2.0"));q.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 Aae={bundleType:0,version:"19.2.0",rendererPackageName:"react-dom",currentDispatcherRef:Y,reconcilerVersion:"19.2.0"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Zv=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Zv.isDisabled&&Zv.supportsFiber)try{Ye=Zv.inject(Aae),ie=Zv}catch{}}return Xx.createRoot=function(h,g){if(!i(h))throw Error(r(299));var _=!1,M="",P=T5,I=A5,J=C5;return g!=null&&(g.unstable_strictMode===!0&&(_=!0),g.identifierPrefix!==void 0&&(M=g.identifierPrefix),g.onUncaughtError!==void 0&&(P=g.onUncaughtError),g.onCaughtError!==void 0&&(I=g.onCaughtError),g.onRecoverableError!==void 0&&(J=g.onRecoverableError)),g=lU(h,1,!1,null,null,_,M,null,P,I,J,yU),h[si]=g.current,tT(h),new vT(g)},Xx.hydrateRoot=function(h,g,_){if(!i(h))throw Error(r(299));var M=!1,P="",I=T5,J=A5,ge=C5,Ie=null;return _!=null&&(_.unstable_strictMode===!0&&(M=!0),_.identifierPrefix!==void 0&&(P=_.identifierPrefix),_.onUncaughtError!==void 0&&(I=_.onUncaughtError),_.onCaughtError!==void 0&&(J=_.onCaughtError),_.onRecoverableError!==void 0&&(ge=_.onRecoverableError),_.formState!==void 0&&(Ie=_.formState)),g=lU(h,1,!0,g,_??null,M,P,Ie,I,J,ge,yU),g.context=cU(null),_=g.current,M=Rs(),M=ln(M),P=Au(M),P.callback=null,Cu(_,P,M),_=M,g.current.lanes=_,cn(g,_),yl(g),h[si]=g.current,tT(h),new Qv(g)},Xx.version="19.2.0",Xx}var kU;function Uae(){if(kU)return ST.exports;kU=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),ST.exports=Fae(),ST.exports}var zae=Uae();const dn=t=>typeof t=="string",Yx=()=>{let t,e;const n=new Promise((r,i)=>{t=r,e=i});return n.resolve=t,n.reject=e,n},jU=t=>t==null?"":""+t,Bae=(t,e,n)=>{t.forEach(r=>{e[r]&&(n[r]=e[r])})},$ae=/###/g,PU=t=>t&&t.indexOf("###")>-1?t.replace($ae,"."):t,RU=t=>!t||dn(t),Fb=(t,e,n)=>{const r=dn(e)?e.split("."):e;let i=0;for(;i<r.length-1;){if(RU(t))return{};const a=PU(r[i]);!t[a]&&n&&(t[a]=new n),Object.prototype.hasOwnProperty.call(t,a)?t=t[a]:t={},++i}return RU(t)?{}:{obj:t,k:PU(r[i])}},DU=(t,e,n)=>{const{obj:r,k:i}=Fb(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=Fb(t,o,Object);for(;l.obj===void 0&&o.length;)a=`${o[o.length-1]}.${a}`,o=o.slice(0,o.length-1),l=Fb(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}=Fb(t,e,Object);i[a]=i[a]||[],i[a].push(n)},uw=(t,e)=>{const{obj:n,k:r}=Fb(t,e);if(n&&Object.prototype.hasOwnProperty.call(n,r))return n[r]},Vae=(t,e,n)=>{const r=uw(t,n);return r!==void 0?r:uw(e,n)},sW=(t,e,n)=>{for(const r in e)r!=="__proto__"&&r!=="constructor"&&(r in t?dn(t[r])||t[r]instanceof String||dn(e[r])||e[r]instanceof String?n&&(t[r]=e[r]):sW(t[r],e[r],n):t[r]=e[r]);return t},Im=t=>t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var Gae={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};const Wae=t=>dn(t)?t.replace(/[&<>"'\/]/g,e=>Gae[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 Kae=[" ",",","?","!",";"],Xae=new qae(20),Yae=(t,e,n)=>{e=e||"",n=n||"";const r=Kae.filter(o=>e.indexOf(o)<0&&n.indexOf(o)<0);if(r.length===0)return!0;const i=Xae.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},Cj=(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},l0=t=>t?.replace("_","-"),Qae={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 dw{constructor(e,n={}){this.init(e,n)}init(e,n={}){this.prefix=n.prefix||"i18next:",this.logger=e||Qae,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:(dn(e[0])&&(e[0]=`${r}${this.prefix} ${e[0]}`),this.logger[n](e))}create(e){return new dw(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new dw(this.logger,e)}}var jl=new dw;let A2=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 OU extends A2{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):dn(r)&&a?l.push(...r.split(a)):l.push(r)));const c=uw(this.data,l);return!c&&!n&&!r&&e.indexOf(".")>-1&&(e=l[0],n=l[1],r=l.slice(2).join(".")),c||!o||!dn(r)?c:Cj(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),DU(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)(dn(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=uw(this.data,l)||{};o.skipCopy||(r=JSON.parse(JSON.stringify(r))),i?sW(c,r,a):c={...c,...r},DU(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 oW={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 lW=Symbol("i18next/PATH_KEY");function Zae(){const t=[],e=Object.create(null);let n;return e.get=(r,i)=>(n?.revoke?.(),i===lW?t:(t.push(i),n=Proxy.revocable(r,e),n.proxy)),Proxy.revocable(Object.create(null),e).proxy}function kj(t,e){const{[lW]:n}=t(Zae());return n.join(e?.keySeparator??".")}const LU={},TT=t=>!dn(t)&&typeof t!="boolean"&&typeof t!="number";class hw extends A2{constructor(e,n={}){super(),Bae(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=jl.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=TT(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&&!Yae(e,r,i);if(o&&!l){const c=e.match(this.interpolator.nestingRegexp);if(c&&c.length>0)return{key:e,namespaces:dn(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:dn(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=kj(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,m=i.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(f?.toLowerCase()==="cimode")return m?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 p=this.resolve(e,i);let x=p?.res;const y=p?.usedKey||l,b=p?.exactUsedKey||l,v=["[object Number]","[object Function]","[object RegExp]"],N=i.joinArrays!==void 0?i.joinArrays:this.options.joinArrays,S=!this.i18nFormat||this.i18nFormat.handleAsObject,T=i.count!==void 0&&!dn(i.count),E=hw.hasDefaultValue(i),C=T?this.pluralResolver.getSuffix(f,i.count,i):"",A=i.ordinal&&T?this.pluralResolver.getSuffix(f,i.count,{ordinal:!1}):"",O=T&&!i.ordinal&&i.count===0,k=O&&i[`defaultValue${this.options.pluralSeparator}zero`]||i[`defaultValue${C}`]||i[`defaultValue${A}`]||i.defaultValue;let R=x;S&&!x&&E&&(R=k);const F=TT(R),L=Object.prototype.toString.apply(R);if(S&&R&&F&&v.indexOf(L)<0&&!(dn(N)&&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 K=this.options.returnedObjectHandler?this.options.returnedObjectHandler(y,R,{...i,ns:c}):`key '${l} (${this.language})' returned an object instead of string.`;return a?(p.res=K,p.usedParams=this.getUsedParamsDetails(i),p):K}if(o){const K=Array.isArray(R),j=K?[]:{},W=K?b:y;for(const Y in R)if(Object.prototype.hasOwnProperty.call(R,Y)){const q=`${W}${o}${Y}`;E&&!x?j[Y]=this.translate(q,{...i,defaultValue:TT(k)?k[Y]:void 0,joinArrays:!1,ns:c}):j[Y]=this.translate(q,{...i,joinArrays:!1,ns:c}),j[Y]===q&&(j[Y]=R[Y])}x=j}}else if(S&&dn(N)&&Array.isArray(x))x=x.join(N),x&&(x=this.extendTranslation(x,e,i,r));else{let K=!1,j=!1;!this.isValidLookup(x)&&E&&(K=!0,x=k),this.isValidLookup(x)||(j=!0,x=l);const Y=(i.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&j?void 0:x,q=E&&k!==x&&this.options.updateMissing;if(j||K||q){if(this.logger.log(q?"updateKey":"missingKey",f,u,l,q?k:x),o){const z=this.resolve(l,{...i,keySeparator:!1});z&&z.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let Q=[];const ee=this.languageUtils.getFallbackCodes(this.options.fallbackLng,i.lng||this.language);if(this.options.saveMissingTo==="fallback"&&ee&&ee[0])for(let z=0;z<ee.length;z++)Q.push(ee[z]);else this.options.saveMissingTo==="all"?Q=this.languageUtils.toResolveHierarchy(i.lng||this.language):Q.push(i.lng||this.language);const re=(z,G,ae)=>{const se=E&&ae!==x?ae:Y;this.options.missingKeyHandler?this.options.missingKeyHandler(z,u,G,se,q,i):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(z,u,G,se,q,i),this.emit("missingKey",z,u,G,x)};this.options.saveMissing&&(this.options.saveMissingPlurals&&T?Q.forEach(z=>{const G=this.pluralResolver.getSuffixes(z,i);O&&i[`defaultValue${this.options.pluralSeparator}zero`]&&G.indexOf(`${this.options.pluralSeparator}zero`)<0&&G.push(`${this.options.pluralSeparator}zero`),G.forEach(ae=>{re([z],l+ae,i[`defaultValue${ae}`]||k)})}):re(Q,l,k))}x=this.extendTranslation(x,e,i,p,r),j&&x===l&&this.options.appendNamespaceToMissingKey&&(x=`${u}${d}${l}`),(j||K)&&this.options.parseMissingKeyHandler&&(x=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${u}${d}${l}`:l,K?x:void 0,i))}return a?(p.res=x,p.usedParams=this.getUsedParamsDetails(i),p):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=dn(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&&!dn(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),m=f&&f.length;u<m&&(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=dn(o)?[o]:o;return e!=null&&l?.length&&r.applyPostProcessor!==!1&&(e=oW.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 dn(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 m=n.count!==void 0&&!dn(n.count),p=m&&!n.ordinal&&n.count===0,x=n.context!==void 0&&(dn(n.context)||typeof n.context=="number")&&n.context!=="",y=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);f.forEach(b=>{this.isValidLookup(r)||(l=b,!LU[`${y[0]}-${b}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(l)&&(LU[`${y[0]}-${b}`]=!0,this.logger.warn(`key "${i}" for languages "${y.join(", ")}" won't get resolved as namespace "${l}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),y.forEach(v=>{if(this.isValidLookup(r))return;o=v;const N=[d];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(N,d,v,b,n);else{let T;m&&(T=this.pluralResolver.getSuffix(v,n.count,n));const E=`${this.options.pluralSeparator}zero`,C=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(m&&(n.ordinal&&T.indexOf(C)===0&&N.push(d+T.replace(C,this.options.pluralSeparator)),N.push(d+T),p&&N.push(d+E)),x){const A=`${d}${this.options.contextSeparator||"_"}${n.context}`;N.push(A),m&&(n.ordinal&&T.indexOf(C)===0&&N.push(A+T.replace(C,this.options.pluralSeparator)),N.push(A+T),p&&N.push(A+E))}}let S;for(;S=N.pop();)this.isValidLookup(r)||(a=S,r=this.getResource(v,b,S,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&&!dn(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 IU{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=jl.create("languageUtils")}getScriptPartFromCode(e){if(e=l0(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=l0(e),!e||e.indexOf("-")<0)return e;const n=e.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(e){if(dn(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)),dn(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 dn(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))):dn(e)&&a(this.formatLanguageCode(e)),r.forEach(o=>{i.indexOf(o)<0&&a(this.formatLanguageCode(o))}),i}}const FU={zero:0,one:1,two:2,few:3,many:4,other:5},UU={select:t=>t===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class Jae{constructor(e,n={}){this.languageUtils=e,this.options=n,this.logger=jl.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,n){this.rules[e]=n}clearCache(){this.pluralRulesCache={}}getRule(e,n={}){const r=l0(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!"),UU;if(!e.match(/-|_/))return UU;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)=>FU[i]-FU[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 zU=(t,e,n,r=".",i=!0)=>{let a=Vae(t,e,n);return!a&&i&&dn(n)&&(a=Cj(t,n,r),a===void 0&&(a=Cj(e,n,r))),a},AT=t=>t.replace(/\$/g,"$$$$");class ese{constructor(e={}){this.logger=jl.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:m,nestingPrefixEscaped:p,nestingSuffix:x,nestingSuffixEscaped:y,nestingOptionsSeparator:b,maxReplaces:v,alwaysFormat:N}=e.interpolation;this.escape=n!==void 0?n:Wae,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=i!==void 0?i:!1,this.prefix=a?Im(a):o||"{{",this.suffix=l?Im(l):c||"}}",this.formatSeparator=u||",",this.unescapePrefix=d?"":f||"-",this.unescapeSuffix=this.unescapePrefix?"":d||"",this.nestingPrefix=m?Im(m):p||Im("$t("),this.nestingSuffix=x?Im(x):y||Im(")"),this.nestingOptionsSeparator=b||",",this.maxReplaces=v||1e3,this.alwaysFormat=N!==void 0?N:!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=p=>{if(p.indexOf(this.formatSeparator)<0){const v=zU(n,c,p,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(v,void 0,r,{...i,...n,interpolationkey:p}):v}const x=p.split(this.formatSeparator),y=x.shift().trim(),b=x.join(this.formatSeparator).trim();return this.format(zU(n,c,y,this.options.keySeparator,this.options.ignoreJSONStructure),b,r,{...i,...n,interpolationkey:y})};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:p=>AT(p)},{regex:this.regexp,safeValue:p=>this.escapeValue?AT(this.escape(p)):AT(p)}].forEach(p=>{for(l=0;a=p.regex.exec(e);){const x=a[1].trim();if(o=u(x),o===void 0)if(typeof d=="function"){const b=d(e,a,i);o=dn(b)?b:""}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!dn(o)&&!this.useRawValueToEscape&&(o=jU(o));const y=p.safeValue(o);if(e=e.replace(a[0],y),f?(p.regex.lastIndex+=o.length,p.regex.lastIndex-=a[0].length):p.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 m=`{${f[1]}`;c=f[0],m=this.interpolate(m,o);const p=m.match(/'/g),x=m.match(/"/g);((p?.length??0)%2===0&&!x||x.length%2!==0)&&(m=m.replace(/'/g,'"'));try{o=JSON.parse(m),u&&(o={...u,...o})}catch(y){return this.logger.warn(`failed parsing options string in nesting for key ${c}`,y),`${c}${d}${m}`}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&&!dn(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&&!dn(a))return a;dn(a)||(a=jU(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 tse=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}},BU=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(l0(r),i),e[o]=l),l(n)}},nse=t=>(e,n,r)=>t(l0(n),r)(e);class rse{constructor(e={}){this.logger=jl.create("formatter"),this.options=e,this.init(e)}init(e,n={interpolation:{}}){this.formatSeparator=n.interpolation.formatSeparator||",";const r=n.cacheInBuiltFormats?BU:nse;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()]=BU(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}=tse(c);if(this.formats[u]){let f=l;try{const m=i?.formatParams?.[i.interpolationkey]||{},p=m.locale||m.lng||i.locale||i.lng||r;f=this.formats[u](l,p,{...d,...i,...m})}catch(m){this.logger.warn(m)}return f}else this.logger.warn(`there was no format function for ${u}`);return l},e)}}const ise=(t,e)=>{t.pending[e]!==void 0&&(delete t.pending[e],t.pendingCount--)};class ase extends A2{constructor(e,n,r,i={}){super(),this.backend=e,this.store=n,this.services=r,this.languageUtils=r.languageUtils,this.options=i,this.logger=jl.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 m=`${u}|${f}`;!r.reload&&this.store.hasResourceBundle(u,f)?this.state[m]=2:this.state[m]<0||(this.state[m]===1?o[m]===void 0&&(o[m]=!0):(this.state[m]=1,d=!1,o[m]===void 0&&(o[m]=!0),a[m]===void 0&&(a[m]=!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),ise(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();dn(e)&&(e=this.languageUtils.toResolveHierarchy(e)),dn(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 $U=()=>({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]),dn(t[1])&&(e.defaultValue=t[1]),dn(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}),HU=t=>(dn(t.ns)&&(t.ns=[t.ns]),dn(t.fallbackLng)&&(t.fallbackLng=[t.fallbackLng]),dn(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),e_=()=>{},sse=t=>{Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(n=>{typeof t[n]=="function"&&(t[n]=t[n].bind(t))})};class Ub extends A2{constructor(e={},n){if(super(),this.options=HU(e),this.services={},this.logger=jl,this.modules={external:[]},sse(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&&(dn(e.ns)?e.defaultNS=e.ns:e.ns.indexOf("translation")<0&&(e.defaultNS=e.ns[0]));const r=$U();this.options={...r,...this.options,...HU(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?jl.init(i(this.modules.logger),this.options):jl.init(null,this.options);let u;this.modules.formatter?u=this.modules.formatter:u=rse;const d=new IU(this.options);this.store=new OU(this.options.resources,this.options);const f=this.services;f.logger=jl,f.resourceStore=this.store,f.languageUtils=d,f.pluralResolver=new Jae(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 ese(this.options),f.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},f.backendConnector=new ase(i(this.modules.backend),f.resourceStore,f,this.options),f.backendConnector.on("*",(p,...x)=>{this.emit(p,...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 hw(this.services,this.options),this.translator.on("*",(p,...x)=>{this.emit(p,...x)}),this.modules.external.forEach(p=>{p.init&&p.init(this)})}if(this.format=this.options.interpolation.format,n||(n=e_),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=Yx(),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=e_){let r=n;const i=dn(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=Yx();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=e_),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"&&oW.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=Yx();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=dn(l)?l:l&&l[0],u=this.store.hasLanguageSomeTranslations(c)?c:this.services.languageUtils.getBestMatchFromCodes(dn(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=kj(f,{...this.options,...o})),`${c.keyPrefix}${u}${f}`)):(typeof a=="function"&&(a=kj(a,{...this.options,...o})),d=c.keyPrefix?`${c.keyPrefix}${u}${a}`:a),this.t(d,c)};return dn(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=Yx();return this.options.ns?(dn(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=Yx();dn(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 IU($U());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 Ub(e,n);return r.createInstance=Ub.createInstance,r}cloneInstance(e={},n=e_){const r=e.forkResourceStore;r&&delete e.forkResourceStore;const i={...this.options,...e,isClone:!0},a=new Ub(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 OU(l,i),a.services.resourceStore=a.store}return a.translator=new hw(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 ns=Ub.createInstance();ns.createInstance;ns.dir;ns.init;ns.loadResources;ns.reloadResources;ns.use;ns.changeLanguage;ns.getFixedT;ns.t;ns.exists;ns.setDefaultNamespace;ns.hasLoadedNamespace;ns.loadNamespaces;ns.loadLanguages;const ose=(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);Nf(i[0])&&(i[0]=`react-i18next:: ${i[0]}`),t?.services?.logger?.warn?t.services.logger.warn(...i):console?.warn&&console.warn(...i)},VU={},cW=(t,e,n,r)=>{Nf(n)&&VU[n]||(Nf(n)&&(VU[n]=new Date),ose(t,e,n,r))},uW=(t,e)=>()=>{if(t.isInitialized)e();else{const n=()=>{setTimeout(()=>{t.off("initialized",n)},0),e()};t.on("initialized",n)}},jj=(t,e,n)=>{t.loadNamespaces(e,uW(t,n))},GU=(t,e,n,r)=>{if(Nf(n)&&(n=[n]),t.options.preload&&t.options.preload.indexOf(e)>-1)return jj(t,n,r);n.forEach(i=>{t.options.ns.indexOf(i)<0&&t.options.ns.push(i)}),t.loadLanguages(e,uW(t,r))},lse=(t,e,n={})=>!e.languages||!e.languages.length?(cW(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}}),Nf=t=>typeof t=="string",cse=t=>typeof t=="object"&&t!==null,use=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,dse={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"',"&nbsp;":" ","&#160;":" ","&copy;":"©","&#169;":"©","&reg;":"®","&#174;":"®","&hellip;":"…","&#8230;":"…","&#x2F;":"/","&#47;":"/"},hse=t=>dse[t],fse=t=>t.replace(use,hse);let Pj={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:fse};const mse=(t={})=>{Pj={...Pj,...t}},pse=()=>Pj;let dW;const gse=t=>{dW=t},xse=()=>dW,bse={type:"3rdParty",init(t){mse(t.options.react),gse(t)}},yse=w.createContext();class vse{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach(n=>{this.usedNamespaces[n]||(this.usedNamespaces[n]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}var CT={exports:{}},kT={};var WU;function _se(){if(WU)return kT;WU=1;var t=Dg();function e(f,m){return f===m&&(f!==0||1/f===1/m)||f!==f&&m!==m}var n=typeof Object.is=="function"?Object.is:e,r=t.useState,i=t.useEffect,a=t.useLayoutEffect,o=t.useDebugValue;function l(f,m){var p=m(),x=r({inst:{value:p,getSnapshot:m}}),y=x[0].inst,b=x[1];return a(function(){y.value=p,y.getSnapshot=m,c(y)&&b({inst:y})},[f,p,m]),i(function(){return c(y)&&b({inst:y}),f(function(){c(y)&&b({inst:y})})},[f]),o(p),p}function c(f){var m=f.getSnapshot;f=f.value;try{var p=m();return!n(f,p)}catch{return!0}}function u(f,m){return m()}var d=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?u:l;return kT.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:d,kT}var qU;function hW(){return qU||(qU=1,CT.exports=_se()),CT.exports}var KR=hW();const wse=(t,e)=>Nf(e)?e:cse(e)&&Nf(e.defaultValue)?e.defaultValue:Array.isArray(t)?t[t.length-1]:t,Sse={t:wse,ready:!1},Nse=()=>()=>{},Og=(t,e={})=>{const{i18n:n}=e,{i18n:r,defaultNS:i}=w.useContext(yse)||{},a=n||r||xse();a&&!a.reportNamespaces&&(a.reportNamespaces=new vse),a||cW(a,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const o=w.useMemo(()=>({...pse(),...a?.options?.react,...e}),[a,e]),{useSuspense:l,keyPrefix:c}=o,u=i||a?.options?.defaultNS,d=Nf(u)?[u]:u||["translation"],f=w.useMemo(()=>d,d);a?.reportNamespaces?.addUsedNamespaces?.(f);const m=w.useRef(0),p=w.useCallback(k=>{if(!a)return Nse;const{bindI18n:R,bindI18nStore:F}=o,L=()=>{m.current+=1,k()};return R&&a.on(R,L),F&&a.store.on(F,L),()=>{R&&R.split(" ").forEach(K=>a.off(K,L)),F&&F.split(" ").forEach(K=>a.store.off(K,L))}},[a,o]),x=w.useRef(),y=w.useCallback(()=>{if(!a)return Sse;const k=!!(a.isInitialized||a.initializedStoreOnce)&&f.every(W=>lse(W,a,o)),R=e.lng||a.language,F=m.current,L=x.current;if(L&&L.ready===k&&L.lng===R&&L.keyPrefix===c&&L.revision===F)return L;const j={t:a.getFixedT(R,o.nsMode==="fallback"?f:f[0],c),ready:k,lng:R,keyPrefix:c,revision:F};return x.current=j,j},[a,f,c,o,e.lng]),[b,v]=w.useState(0),{t:N,ready:S}=KR.useSyncExternalStore(p,y,y);w.useEffect(()=>{if(a&&!S&&!l){const k=()=>v(R=>R+1);e.lng?GU(a,e.lng,f,k):jj(a,f,k)}},[a,e.lng,f,S,l,b]);const T=a||{},E=w.useRef(null),C=w.useRef(),A=k=>{const R=Object.getOwnPropertyDescriptors(k);R.__original&&delete R.__original;const F=Object.create(Object.getPrototypeOf(k),R);if(!Object.prototype.hasOwnProperty.call(F,"__original"))try{Object.defineProperty(F,"__original",{value:k,writable:!1,enumerable:!1,configurable:!1})}catch{}return F},O=w.useMemo(()=>{const k=T,R=k?.language;let F=k;k&&(E.current&&E.current.__original===k?C.current!==R?(F=A(k),E.current=F,C.current=R):F=E.current:(F=A(k),E.current=F,C.current=R));const L=[N,F,S];return L.t=N,L.i18n=F,L.ready=S,L},[N,T,S,T.resolvedLanguage,T.language,T.languages]);if(a&&l&&!S)throw new Promise(k=>{const R=()=>k();e.lng?GU(a,e.lng,f,R):jj(a,f,R)});return O},{slice:Mse,forEach:Ese}=[];function Tse(t){return Ese.call(Mse.call(arguments,1),e=>{if(e)for(const n in e)t[n]===void 0&&(t[n]=e[n])}),t}function Ase(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 KU=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,Cse=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(!KU.test(r.domain))throw new TypeError("option domain is invalid");a+=`; Domain=${r.domain}`}if(r.path){if(!KU.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},XU={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=Cse(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 kse={name:"cookie",lookup(t){let{lookupCookie:e}=t;if(e&&typeof document<"u")return XU.read(e)||void 0},cacheUserLanguage(t,e){let{lookupCookie:n,cookieMinutes:r,cookieDomain:i,cookieOptions:a}=e;n&&typeof document<"u"&&XU.create(n,t,r,i,a)}},jse={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}},Pse={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 Fm=null;const YU=()=>{if(Fm!==null)return Fm;try{if(Fm=typeof window<"u"&&window.localStorage!==null,!Fm)return!1;const t="i18next.translate.boo";window.localStorage.setItem(t,"foo"),window.localStorage.removeItem(t)}catch{Fm=!1}return Fm};var Rse={name:"localStorage",lookup(t){let{lookupLocalStorage:e}=t;if(e&&YU())return window.localStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupLocalStorage:n}=e;n&&YU()&&window.localStorage.setItem(n,t)}};let Um=null;const QU=()=>{if(Um!==null)return Um;try{if(Um=typeof window<"u"&&window.sessionStorage!==null,!Um)return!1;const t="i18next.translate.boo";window.sessionStorage.setItem(t,"foo"),window.sessionStorage.removeItem(t)}catch{Um=!1}return Um};var Dse={name:"sessionStorage",lookup(t){let{lookupSessionStorage:e}=t;if(e&&QU())return window.sessionStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupSessionStorage:n}=e;n&&QU()&&window.sessionStorage.setItem(n,t)}},Ose={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}},Lse={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}},Ise={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 fW=!1;try{document.cookie,fW=!0}catch{}const mW=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];fW||mW.splice(1,1);const Use=()=>({order:mW,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:t=>t});class pW{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=Tse(n,this.options||{},Use()),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(kse),this.addDetector(jse),this.addDetector(Rse),this.addDetector(Dse),this.addDetector(Ose),this.addDetector(Lse),this.addDetector(Ise),this.addDetector(Fse),this.addDetector(Pse)}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&&!Ase(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)}))}}pW.type="languageDetector";const zse={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}}",viewOnGithub:"View on GitHub",keyboardShortcuts:"Keyboard shortcuts (?)",switchToLight:"Switch to light mode",switchToDark:"Switch to dark mode"},common:{save:"Save",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",noPrinters:"No printers configured",noData:"No data available",required:"Required",optional:"Optional"},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"},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",noArchives:"No archives found",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"}},queue:{title:"Print Queue",addToQueue:"Add to Queue",clearQueue:"Clear Queue",emptyQueue:"Queue is empty",position:"Position",scheduledTime:"Scheduled Time",moveUp:"Move Up",moveDown:"Move Down",remove:"Remove",startNow:"Start Now",status:{pending:"Pending",printing:"Printing",completed:"Completed",failed:"Failed",cancelled:"Cancelled"}},stats:{title:"Statistics",overview:"Overview",totalPrints:"Total Prints",successRate:"Success Rate",totalPrintTime:"Total Print Time",totalFilament:"Total Filament Used",totalCost:"Total Cost",averagePrintTime:"Average Print Time",printsPerDay:"Prints per Day",byPrinter:"By Printer",byMaterial:"By Material",byMonth:"By Month",last7Days:"Last 7 Days",last30Days:"Last 30 Days",last90Days:"Last 90 Days",allTime:"All Time"},profiles:{title:"Filament Profiles",addProfile:"Add Profile",editProfile:"Edit Profile",deleteProfile:"Delete Profile",material:"Material",brand:"Brand",color:"Color",diameter:"Diameter",density:"Density",costPerKg:"Cost per kg",spoolWeight:"Spool Weight",noProfiles:"No profiles configured",deleteConfirm:"Are you sure you want to delete this profile?"},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",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"}},settings:{title:"Settings",general:"General",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"},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"},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?"}},Bse={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}}",viewOnGithub:"Auf GitHub ansehen",keyboardShortcuts:"Tastaturkürzel (?)",switchToLight:"Zum hellen Modus wechseln",switchToDark:"Zum dunklen Modus wechseln"},common:{save:"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",noPrinters:"Keine Drucker konfiguriert",noData:"Keine Daten verfügbar",required:"Erforderlich",optional:"Optional"},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"},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",noArchives:"Keine Archive gefunden",printTime:"Druckzeit",filamentUsed:"Verbrauchtes Filament",cost:"Kosten",reprint:"Erneut 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"}},queue:{title:"Druckwarteschlange",addToQueue:"Zur Warteschlange hinzufügen",clearQueue:"Warteschlange leeren",emptyQueue:"Warteschlange ist leer",position:"Position",scheduledTime:"Geplante Zeit",moveUp:"Nach oben",moveDown:"Nach unten",remove:"Entfernen",startNow:"Jetzt starten",status:{pending:"Ausstehend",printing:"Druckt",completed:"Abgeschlossen",failed:"Fehlgeschlagen",cancelled:"Abgebrochen"}},stats:{title:"Statistiken",overview:"Übersicht",totalPrints:"Gesamtdrucke",successRate:"Erfolgsrate",totalPrintTime:"Gesamtdruckzeit",totalFilament:"Gesamtverbrauch Filament",totalCost:"Gesamtkosten",averagePrintTime:"Durchschnittliche Druckzeit",printsPerDay:"Drucke pro Tag",byPrinter:"Nach Drucker",byMaterial:"Nach Material",byMonth:"Nach Monat",last7Days:"Letzte 7 Tage",last30Days:"Letzte 30 Tage",last90Days:"Letzte 90 Tage",allTime:"Gesamt"},profiles:{title:"Filament-Profile",addProfile:"Profil hinzufügen",editProfile:"Profil bearbeiten",deleteProfile:"Profil löschen",material:"Material",brand:"Marke",color:"Farbe",diameter:"Durchmesser",density:"Dichte",costPerKg:"Kosten pro kg",spoolWeight:"Spulengewicht",noProfiles:"Keine Profile konfiguriert",deleteConfirm:"Möchten Sie dieses Profil wirklich löschen?"},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",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"}},settings:{title:"Einstellungen",general:"Allgemein",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"},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"},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?"}},$se={en:{translation:zse},de:{translation:Bse}};ns.use(pW).use(bse).init({resources:$se,fallbackLng:"en",supportedLngs:["en","de"],detection:{order:["localStorage","navigator","htmlTag"],lookupLocalStorage:"bambutrack_language",caches:["localStorage"]},interpolation:{escapeValue:!1},react:{useSuspense:!1}});const ZU=[{code:"en",name:"English",nativeName:"English"},{code:"de",name:"German",nativeName:"Deutsch"}];var JU="popstate";function Hse(t={}){function e(r,i){let{pathname:a,search:o,hash:l}=r.location;return Rj("",{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:c0(i)}return Gse(e,n,null,t)}function Br(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function Xs(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 ez(t,e){return{usr:t.state,key:t.key,idx:e}}function Rj(t,e,n=null,r){return{pathname:typeof t=="string"?t:t.pathname,search:"",hash:"",...typeof e=="string"?Lg(e):e,state:n,key:e&&e.key||r||Vse()}}function c0({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 Lg(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 b=d(),v=b==null?null:b-u;u=b,c&&c({action:l,location:y.location,delta:v})}function m(b,v){l="PUSH";let N=Rj(y.location,b,v);u=d()+1;let S=ez(N,u),T=y.createHref(N);try{o.pushState(S,"",T)}catch(E){if(E instanceof DOMException&&E.name==="DataCloneError")throw E;i.location.assign(T)}a&&c&&c({action:l,location:y.location,delta:1})}function p(b,v){l="REPLACE";let N=Rj(y.location,b,v);u=d();let S=ez(N,u),T=y.createHref(N);o.replaceState(S,"",T),a&&c&&c({action:l,location:y.location,delta:0})}function x(b){return Wse(b)}let y={get action(){return l},get location(){return t(i,o)},listen(b){if(c)throw new Error("A history only accepts one active listener");return i.addEventListener(JU,f),c=b,()=>{i.removeEventListener(JU,f),c=null}},createHref(b){return e(i,b)},createURL:x,encodeLocation(b){let v=x(b);return{pathname:v.pathname,search:v.search,hash:v.hash}},push:m,replace:p,go(b){return o.go(b)}};return y}function Wse(t,e=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),Br(n,"No window.location.(origin|href) available to create URL");let r=typeof t=="string"?t:c0(t);return r=r.replace(/ $/,"%20"),!e&&r.startsWith("//")&&(r=n+r),new URL(r,n)}function gW(t,e,n="/"){return qse(t,e,n,!1)}function qse(t,e,n,r){let i=typeof e=="string"?Lg(e):e,a=au(i.pathname||"/",n);if(a==null)return null;let o=xW(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 xW(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;Br(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=Yc([r,d.relativePath]),m=n.concat(d);o.children&&o.children.length>0&&(Br(o.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${f}".`),xW(o.children,e,m,f,c)),!(o.path==null&&!o.index)&&e.push({path:f,score:toe(f,o.index),routesMeta:m})};return t.forEach((o,l)=>{if(o.path===""||!o.path?.includes("?"))a(o,l);else for(let c of bW(o.path))a(o,l,!0,c)}),e}function bW(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=bW(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,tz=t=>t==="*";function toe(t,e){let n=t.split("/"),r=n.length;return n.some(tz)&&(r+=eoe),e&&(r+=Qse),n.filter(i=>!tz(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=fw({path:c.relativePath,caseSensitive:c.caseSensitive,end:u},d),m=c.route;if(!f&&u&&n&&!r[r.length-1].route.index&&(f=fw({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},d)),!f)return null;Object.assign(i,f.params),o.push({params:i,pathname:Yc([a,f.pathname]),pathnameBase:coe(Yc([a,f.pathnameBase])),route:m}),f.pathnameBase!=="/"&&(a=Yc([a,f.pathnameBase]))}return o}function fw(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},m)=>{if(d==="*"){let x=l[m]||"";o=a.slice(0,a.length-x.length).replace(/(.)\/+$/,"$1")}const p=l[m];return f&&!p?u[d]=void 0:u[d]=(p||"").replace(/%2F/g,"/"),u},{}),pathname:a,pathnameBase:o,pattern:t}}function ioe(t,e=!1,n=!0){Xs(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 Xs(!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 au(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 yW=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,soe=t=>yW.test(t);function ooe(t,e="/"){let{pathname:n,search:r="",hash:i=""}=typeof t=="string"?Lg(t):t,a;if(n)if(soe(n))a=n;else{if(n.includes("//")){let o=n;n=n.replace(/\/\/+/g,"/"),Xs(!1,`Pathnames cannot have embedded double slashes - normalizing ${o} -> ${n}`)}n.startsWith("/")?a=nz(n.substring(1),"/"):a=nz(n,e)}else a=e;return{pathname:a,search:uoe(r),hash:doe(i)}}function nz(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 jT(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 XR(t){let e=loe(t);return e.map((n,r)=>r===e.length-1?n.pathname:n.pathnameBase)}function YR(t,e,n,r=!1){let i;typeof t=="string"?i=Lg(t):(i={...t},Br(!i.pathname||!i.pathname.includes("?"),jT("?","pathname","search",i)),Br(!i.pathname||!i.pathname.includes("#"),jT("#","pathname","hash",i)),Br(!i.search||!i.search.includes("#"),jT("#","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 m=o.split("/");for(;m[0]==="..";)m.shift(),f-=1;i.pathname=m.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 Yc=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 vW=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function _W(t,e){let n=t;if(typeof n!="string"||!yW.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,i=!1;if(vW)try{let a=new URL(window.location.href),o=n.startsWith("//")?new URL(a.protocol+n):new URL(n),l=au(o.pathname,e);o.origin===a.origin&&l!=null?n=l+o.search+o.hash:i=!0}catch{Xs(!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 wW=["POST","PUT","PATCH","DELETE"];new Set(wW);var poe=["GET",...wW];new Set(poe);var Ig=w.createContext(null);Ig.displayName="DataRouter";var C2=w.createContext(null);C2.displayName="DataRouterState";var goe=w.createContext(!1),SW=w.createContext({isTransitioning:!1});SW.displayName="ViewTransition";var xoe=w.createContext(new Map);xoe.displayName="Fetchers";var boe=w.createContext(null);boe.displayName="Await";var Js=w.createContext(null);Js.displayName="Navigation";var ry=w.createContext(null);ry.displayName="Location";var Uo=w.createContext({outlet:null,matches:[],isDataRoute:!1});Uo.displayName="Route";var QR=w.createContext(null);QR.displayName="RouteError";var NW="REACT_ROUTER_ERROR",yoe="REDIRECT",voe="ROUTE_ERROR_RESPONSE";function _oe(t){if(t.startsWith(`${NW}:${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 woe(t){if(t.startsWith(`${NW}:${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}={}){Br(Fg(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:r}=w.useContext(Js),{hash:i,pathname:a,search:o}=iy(t,{relative:e}),l=a;return n!=="/"&&(l=a==="/"?n:Yc([n,a])),r.createHref({pathname:l,search:o,hash:i})}function Fg(){return w.useContext(ry)!=null}function Yl(){return Br(Fg(),"useLocation() may be used only in the context of a <Router> component."),w.useContext(ry).location}var MW="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function EW(t){w.useContext(Js).static||w.useLayoutEffect(t)}function hl(){let{isDataRoute:t}=w.useContext(Uo);return t?Foe():Noe()}function Noe(){Br(Fg(),"useNavigate() may be used only in the context of a <Router> component.");let t=w.useContext(Ig),{basename:e,navigator:n}=w.useContext(Js),{matches:r}=w.useContext(Uo),{pathname:i}=Yl(),a=JSON.stringify(XR(r)),o=w.useRef(!1);return EW(()=>{o.current=!0}),w.useCallback((c,u={})=>{if(Xs(o.current,MW),!o.current)return;if(typeof c=="number"){n.go(c);return}let d=YR(c,JSON.parse(a),i,u.relative==="path");t==null&&e!=="/"&&(d.pathname=d.pathname==="/"?e:Yc([e,d.pathname])),(u.replace?n.replace:n.push)(d,u.state,u)},[e,n,a,i,t])}var Moe=w.createContext(null);function Eoe(t){let e=w.useContext(Uo).outlet;return w.useMemo(()=>e&&w.createElement(Moe.Provider,{value:t},e),[e,t])}function ZR(){let{matches:t}=w.useContext(Uo),e=t[t.length-1];return e?e.params:{}}function iy(t,{relative:e}={}){let{matches:n}=w.useContext(Uo),{pathname:r}=Yl(),i=JSON.stringify(XR(n));return w.useMemo(()=>YR(t,JSON.parse(i),r,e==="path"),[t,i,r,e])}function Toe(t,e){return TW(t,e)}function TW(t,e,n,r,i){Br(Fg(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:a}=w.useContext(Js),{matches:o}=w.useContext(Uo),l=o[o.length-1],c=l?l.params:{},u=l?l.pathname:"/",d=l?l.pathnameBase:"/",f=l&&l.route;{let N=f&&f.path||"";CW(u,!f||N.endsWith("*")||N.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${u}" (under <Route path="${N}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
  10. Please change the parent <Route path="${N}"> to <Route path="${N==="/"?"*":`${N}/*`}">.`)}let m=Yl(),p;if(e){let N=typeof e=="string"?Lg(e):e;Br(d==="/"||N.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 "${N.pathname}" was given in the \`location\` prop.`),p=N}else p=m;let x=p.pathname||"/",y=x;if(d!=="/"){let N=d.replace(/^\//,"").split("/");y="/"+x.replace(/^\//,"").split("/").slice(N.length).join("/")}let b=gW(t,{pathname:y});Xs(f||b!=null,`No routes matched location "${p.pathname}${p.search}${p.hash}" `),Xs(b==null||b[b.length-1].route.element!==void 0||b[b.length-1].route.Component!==void 0||b[b.length-1].route.lazy!==void 0,`Matched leaf route at location "${p.pathname}${p.search}${p.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let v=Poe(b&&b.map(N=>Object.assign({},N,{params:Object.assign({},c,N.params),pathname:Yc([d,a.encodeLocation?a.encodeLocation(N.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:N.pathname]),pathnameBase:N.pathnameBase==="/"?d:Yc([d,a.encodeLocation?a.encodeLocation(N.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:N.pathnameBase])})),o,n,r,i);return e&&v?w.createElement(ry.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...p},navigationType:"POP"}},v):v}function Aoe(){let t=Ioe(),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=w.createElement(w.Fragment,null,w.createElement("p",null,"💿 Hey developer 👋"),w.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",w.createElement("code",{style:a},"ErrorBoundary")," or"," ",w.createElement("code",{style:a},"errorElement")," prop on your route.")),w.createElement(w.Fragment,null,w.createElement("h2",null,"Unexpected Application Error!"),w.createElement("h3",{style:{fontStyle:"italic"}},e),n?w.createElement("pre",{style:i},n):null,o)}var Coe=w.createElement(Aoe,null),AW=class extends w.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,e){return e.location!==t.location||e.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:e.error,location:e.location,revalidation:t.revalidation||e.revalidation}}componentDidCatch(t,e){this.props.onError?this.props.onError(t,e):console.error("React Router caught the following error during render",t)}render(){let t=this.state.error;if(this.context&&typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){const n=woe(t.digest);n&&(t=n)}let e=t!==void 0?w.createElement(Uo.Provider,{value:this.props.routeContext},w.createElement(QR.Provider,{value:t,children:this.props.component})):this.props.children;return this.context?w.createElement(koe,{error:t},e):e}};AW.contextType=goe;var PT=new WeakMap;function koe({children:t,error:e}){let{basename:n}=w.useContext(Js);if(typeof e=="object"&&e&&"digest"in e&&typeof e.digest=="string"){let r=_oe(e.digest);if(r){let i=PT.get(e);if(i)throw i;let a=_W(r.location,n);if(vW&&!PT.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 PT.set(e,o),o}return w.createElement("meta",{httpEquiv:"refresh",content:`0;url=${a.absoluteURL||a.to}`})}}return t}function joe({routeContext:t,match:e,children:n}){let r=w.useContext(Ig);return r&&r.static&&r.staticContext&&(e.route.errorElement||e.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=e.route.id),w.createElement(Uo.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);Br(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:m,errors:p}=n,x=f.route.loader&&!m.hasOwnProperty(f.route.id)&&(!p||p[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,m)=>{let p,x=!1,y=null,b=null;n&&(p=o&&f.route.id?o[f.route.id]:void 0,y=f.route.errorElement||Coe,l&&(c<0&&m===0?(CW("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),x=!0,b=null):c===m&&(x=!0,b=f.route.hydrateFallbackElement||null)));let v=e.concat(a.slice(0,m+1)),N=()=>{let S;return p?S=y:x?S=b:f.route.Component?S=w.createElement(f.route.Component,null):f.route.element?S=f.route.element:S=d,w.createElement(joe,{match:f,routeContext:{outlet:d,matches:v,isDataRoute:n!=null},children:S})};return n&&(f.route.ErrorBoundary||f.route.errorElement||m===0)?w.createElement(AW,{location:n.location,revalidation:n.revalidation,component:y,error:p,children:N(),routeContext:{outlet:null,matches:v,isDataRoute:!0},onError:u}):N()},null)}function JR(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Roe(t){let e=w.useContext(Ig);return Br(e,JR(t)),e}function Doe(t){let e=w.useContext(C2);return Br(e,JR(t)),e}function Ooe(t){let e=w.useContext(Uo);return Br(e,JR(t)),e}function eD(t){let e=Ooe(t),n=e.matches[e.matches.length-1];return Br(n.route.id,`${t} can only be used on routes that contain a unique "id"`),n.route.id}function Loe(){return eD("useRouteId")}function Ioe(){let t=w.useContext(QR),e=Doe("useRouteError"),n=eD("useRouteError");return t!==void 0?t:e.errors?.[n]}function Foe(){let{router:t}=Roe("useNavigate"),e=eD("useNavigate"),n=w.useRef(!1);return EW(()=>{n.current=!0}),w.useCallback(async(i,a={})=>{Xs(n.current,MW),n.current&&(typeof i=="number"?await t.navigate(i):await t.navigate(i,{fromRouteId:e,...a}))},[t,e])}var rz={};function CW(t,e,n){!e&&!rz[t]&&(rz[t]=!0,Xs(!1,n))}w.memo(Uoe);function Uoe({routes:t,future:e,state:n,onError:r}){return TW(t,void 0,n,r,e)}function mw({to:t,replace:e,state:n,relative:r}){Br(Fg(),"<Navigate> may be used only in the context of a <Router> component.");let{static:i}=w.useContext(Js);Xs(!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}=w.useContext(Uo),{pathname:o}=Yl(),l=hl(),c=YR(t,XR(a),o,r==="path"),u=JSON.stringify(c);return w.useEffect(()=>{l(JSON.parse(u),{replace:e,state:n,relative:r})},[l,u,r,e,n]),null}function zoe(t){return Eoe(t.context)}function qi(t){Br(!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}){Br(!Fg(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let l=t.replace(/^\/*/,"/"),c=w.useMemo(()=>({basename:l,navigator:i,static:a,unstable_useTransitions:o,future:{}}),[l,i,a,o]);typeof n=="string"&&(n=Lg(n));let{pathname:u="/",search:d="",hash:f="",state:m=null,key:p="default"}=n,x=w.useMemo(()=>{let y=au(u,l);return y==null?null:{location:{pathname:y,search:d,hash:f,state:m,key:p},navigationType:r}},[l,u,d,f,m,p,r]);return Xs(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:w.createElement(Js.Provider,{value:c},w.createElement(ry.Provider,{children:e,value:x}))}function $oe({children:t,location:e}){return Toe(Dj(t),e)}function Dj(t,e=[]){let n=[];return w.Children.forEach(t,(r,i)=>{if(!w.isValidElement(r))return;let a=[...e,i];if(r.type===w.Fragment){n.push.apply(n,Dj(r.props.children,a));return}Br(r.type===qi,`[${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>`),Br(!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=Dj(r.props.children,a)),n.push(o)}),n}var F1="get",U1="application/x-www-form-urlencoded";function k2(t){return typeof HTMLElement<"u"&&t instanceof HTMLElement}function Hoe(t){return k2(t)&&t.tagName.toLowerCase()==="button"}function Voe(t){return k2(t)&&t.tagName.toLowerCase()==="form"}function Goe(t){return k2(t)&&t.tagName.toLowerCase()==="input"}function Woe(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function qoe(t,e){return t.button===0&&(!e||e==="_self")&&!Woe(t)}function Oj(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=Oj(t);return e&&e.forEach((r,i)=>{n.has(i)||e.getAll(i).forEach(a=>{n.append(i,a)})}),n}var t_=null;function Xoe(){if(t_===null)try{new FormData(document.createElement("form"),0),t_=!1}catch{t_=!0}return t_}var Yoe=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function RT(t){return t!=null&&!Yoe.has(t)?(Xs(!1,`"${t}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${U1}"`),null):t}function Qoe(t,e){let n,r,i,a,o;if(Voe(t)){let l=t.getAttribute("action");r=l?au(l,e):null,n=t.getAttribute("method")||F1,i=RT(t.getAttribute("enctype"))||U1,a=new FormData(t)}else if(Hoe(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?au(c,e):null,n=t.getAttribute("formmethod")||l.getAttribute("method")||F1,i=RT(t.getAttribute("formenctype"))||RT(l.getAttribute("enctype"))||U1,a=new FormData(l,t),!Xoe()){let{name:u,type:d,value:f}=t;if(d==="image"){let m=u?`${u}.`:"";a.append(`${m}x`,"0"),a.append(`${m}y`,"0")}else u&&a.append(u,f)}}else{if(k2(t))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=F1,r=null,i=U1,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 tD(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&&au(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 iz(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 kW(){let t=w.useContext(Ig);return tD(t,"You must render this element inside a <DataRouterContext.Provider> element"),t}function sle(){let t=w.useContext(C2);return tD(t,"You must render this element inside a <DataRouterStateContext.Provider> element"),t}var nD=w.createContext(void 0);nD.displayName="FrameworkContext";function jW(){let t=w.useContext(nD);return tD(t,"You must render this element inside a <HydratedRouter> element"),t}function ole(t,e){let n=w.useContext(nD),[r,i]=w.useState(!1),[a,o]=w.useState(!1),{onFocus:l,onBlur:c,onMouseEnter:u,onMouseLeave:d,onTouchStart:f}=e,m=w.useRef(null);w.useEffect(()=>{if(t==="render"&&o(!0),t==="viewport"){let y=v=>{v.forEach(N=>{o(N.isIntersecting)})},b=new IntersectionObserver(y,{threshold:.5});return m.current&&b.observe(m.current),()=>{b.disconnect()}}},[t]),w.useEffect(()=>{if(r){let y=setTimeout(()=>{o(!0)},100);return()=>{clearTimeout(y)}}},[r]);let p=()=>{i(!0)},x=()=>{i(!1),o(!1)};return n?t!=="intent"?[a,m,{}]:[a,m,{onFocus:Qx(l,p),onBlur:Qx(c,x),onMouseEnter:Qx(u,p),onMouseLeave:Qx(d,x),onTouchStart:Qx(f,p)}]:[!1,m,{}]}function Qx(t,e){return n=>{t&&t(n),n.defaultPrevented||e(n)}}function lle({page:t,...e}){let{router:n}=kW(),r=w.useMemo(()=>gW(n.routes,t,n.basename),[n.routes,t,n.basename]);return r?w.createElement(ule,{page:t,matches:r,...e}):null}function cle(t){let{manifest:e,routeModules:n}=jW(),[r,i]=w.useState([]);return w.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=Yl(),{future:i,manifest:a,routeModules:o}=jW(),{basename:l}=kW(),{loaderData:c,matches:u}=sle(),d=w.useMemo(()=>iz(t,e,u,a,r,"data"),[t,e,u,a,r]),f=w.useMemo(()=>iz(t,e,u,a,r,"assets"),[t,e,u,a,r]),m=w.useMemo(()=>{if(t===r.pathname+r.search+r.hash)return[];let y=new Set,b=!1;if(e.forEach(N=>{let S=a.routes[N.route.id];!S||!S.hasLoader||(!d.some(T=>T.route.id===N.route.id)&&N.route.id in c&&o[N.route.id]?.shouldRevalidate||S.hasClientLoader?b=!0:y.add(N.route.id))}),y.size===0)return[];let v=Zoe(t,l,i.unstable_trailingSlashAwareDataRequests,"data");return b&&y.size>0&&v.searchParams.set("_routes",e.filter(N=>y.has(N.route.id)).map(N=>N.route.id).join(",")),[v.pathname+v.search]},[l,i.unstable_trailingSlashAwareDataRequests,c,r,a,d,e,t,o]),p=w.useMemo(()=>nle(f,a),[f,a]),x=cle(f);return w.createElement(w.Fragment,null,m.map(y=>w.createElement("link",{key:y,rel:"prefetch",as:"fetch",href:y,...n})),p.map(y=>w.createElement("link",{key:y,rel:"modulepreload",href:y,...n})),x.map(({key:y,link:b})=>w.createElement("link",{key:y,nonce:n.nonce,...b})))}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=w.useRef();i.current==null&&(i.current=Hse({window:r,v5Compat:!0}));let a=i.current,[o,l]=w.useState({action:a.action,location:a.location}),c=w.useCallback(u=>{n===!1?l(u):w.startTransition(()=>l(u))},[n]);return w.useLayoutEffect(()=>a.listen(c),[a,c]),w.createElement(Boe,{basename:t,children:e,location:o.location,navigationType:o.action,navigator:a,unstable_useTransitions:n})}var PW=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,fs=w.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:m,...p},x){let{basename:y,unstable_useTransitions:b}=w.useContext(Js),v=typeof u=="string"&&PW.test(u),N=_W(u,y);u=N.to;let S=Soe(u,{relative:i}),[T,E,C]=ole(r,p),A=gle(u,{replace:o,state:l,target:c,preventScrollReset:d,relative:i,viewTransition:f,unstable_defaultShouldRevalidate:m,unstable_useTransitions:b});function O(R){e&&e(R),R.defaultPrevented||A(R)}let k=w.createElement("a",{...p,...C,href:N.absoluteURL||S,onClick:N.isExternal||a?e:O,ref:dle(x,E),target:c,"data-discover":!v&&n==="render"?"true":void 0});return T&&!v?w.createElement(w.Fragment,null,k,w.createElement(lle,{page:S})):k});fs.displayName="Link";var Sb=w.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=iy(o,{relative:u.relative}),m=Yl(),p=w.useContext(C2),{navigator:x,basename:y}=w.useContext(Js),b=p!=null&&_le(f)&&l===!0,v=x.encodeLocation?x.encodeLocation(f).pathname:f.pathname,N=m.pathname,S=p&&p.navigation&&p.navigation.location?p.navigation.location.pathname:null;n||(N=N.toLowerCase(),S=S?S.toLowerCase():null,v=v.toLowerCase()),S&&y&&(S=au(S,y)||S);const T=v!=="/"&&v.endsWith("/")?v.length-1:v.length;let E=N===v||!i&&N.startsWith(v)&&N.charAt(T)==="/",C=S!=null&&(S===v||!i&&S.startsWith(v)&&S.charAt(v.length)==="/"),A={isActive:E,isPending:C,isTransitioning:b},O=E?e:void 0,k;typeof r=="function"?k=r(A):k=[r,E?"active":null,C?"pending":null,b?"transitioning":null].filter(Boolean).join(" ");let R=typeof a=="function"?a(A):a;return w.createElement(fs,{...u,"aria-current":O,className:k,ref:d,style:R,to:o,viewTransition:l},typeof c=="function"?c(A):c)});Sb.displayName="NavLink";var mle=w.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:m,...p},x)=>{let{unstable_useTransitions:y}=w.useContext(Js),b=yle(),v=vle(l,{relative:u}),N=o.toLowerCase()==="get"?"get":"post",S=typeof l=="string"&&PW.test(l),T=E=>{if(c&&c(E),E.defaultPrevented)return;E.preventDefault();let C=E.nativeEvent.submitter,A=C?.getAttribute("formmethod")||o,O=()=>b(C||E.currentTarget,{fetcherKey:e,method:A,navigate:n,replace:i,state:a,relative:u,preventScrollReset:d,viewTransition:f,unstable_defaultShouldRevalidate:m});y&&n!==!1?w.startTransition(()=>O()):O()};return w.createElement("form",{ref:x,method:N,action:v,onSubmit:r?c:T,...p,"data-discover":!S&&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 RW(t){let e=w.useContext(Ig);return Br(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=hl(),d=Yl(),f=iy(t,{relative:a});return w.useCallback(m=>{if(qoe(m,e)){m.preventDefault();let p=n!==void 0?n:c0(d)===c0(f),x=()=>u(t,{replace:p,state:r,preventScrollReset:i,relative:a,viewTransition:o,unstable_defaultShouldRevalidate:l});c?w.startTransition(()=>x()):x()}},[d,u,f,n,r,e,t,i,a,o,l,c])}function DW(t){Xs(typeof URLSearchParams<"u","You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.");let e=w.useRef(Oj(t)),n=w.useRef(!1),r=Yl(),i=w.useMemo(()=>Koe(r.search,n.current?null:e.current),[r.search]),a=hl(),o=w.useCallback((l,c)=>{const u=Oj(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}=RW("useSubmit"),{basename:e}=w.useContext(Js),n=Loe(),r=t.fetch,i=t.navigate;return w.useCallback(async(a,o={})=>{let{action:l,method:c,encType:u,formData:d,body:f}=Qoe(a,e);if(o.navigate===!1){let m=o.fetcherKey||ble();await r(m,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}=w.useContext(Js),r=w.useContext(Uo);Br(r,"useFormAction must be used inside a RouteContext");let[i]=r.matches.slice(-1),a={...iy(t||".",{relative:e})},o=Yl();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:Yc([n,a.pathname])),c0(a)}function _le(t,{relative:e}={}){let n=w.useContext(SW);Br(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=RW("useViewTransitionState"),i=iy(t,{relative:e});if(!n.isTransitioning)return!1;let a=au(n.currentLocation.pathname,r)||n.currentLocation.pathname,o=au(n.nextLocation.pathname,r)||n.nextLocation.pathname;return fw(i.pathname,o)!=null||fw(i.pathname,a)!=null}var Hc=aW();const wle=Fo(Hc);var Qf=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)},Nle=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)}},Zh=new Nle;function Mle(t){setTimeout(t,0)}var Mf=typeof window>"u"||"Deno"in globalThis;function Pa(){}function Ele(t,e){return typeof t=="function"?t(e):t}function Lj(t){return typeof t=="number"&&t>=0&&t!==1/0}function OW(t,e){return Math.max(t+(e||0)-Date.now(),0)}function Ad(t,e){return typeof t=="function"?t(e):t}function xo(t,e){return typeof t=="function"?t(e):t}function az(t,e){const{type:n="all",exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:l}=t;if(o){if(r){if(e.queryHash!==rD(o,e.options))return!1}else if(!u0(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 sz(t,e){const{exact:n,status:r,predicate:i,mutationKey:a}=t;if(a){if(!e.options.mutationKey)return!1;if(n){if(Ef(e.options.mutationKey)!==Ef(a))return!1}else if(!u0(e.options.mutationKey,a))return!1}return!(r&&e.state.status!==r||i&&!i(e))}function rD(t,e){return(e?.queryKeyHashFn||Ef)(t)}function Ef(t){return JSON.stringify(t,(e,n)=>Ij(n)?Object.keys(n).sort().reduce((r,i)=>(r[i]=n[i],r),{}):n)}function u0(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?Object.keys(e).every(n=>u0(t[n],e[n])):!1}var Tle=Object.prototype.hasOwnProperty;function iD(t,e){if(t===e)return t;const n=oz(t)&&oz(e);if(!n&&!(Ij(t)&&Ij(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],m=e[d];if(f===m){l[d]=f,(n?u<i:Tle.call(t,d))&&c++;continue}if(f===null||m===null||typeof f!="object"||typeof m!="object"){l[d]=m;continue}const p=iD(f,m);l[d]=p,p===f&&c++}return i===o&&c===i?t:l}function d0(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 oz(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function Ij(t){if(!lz(t))return!1;const e=t.constructor;if(e===void 0)return!0;const n=e.prototype;return!(!lz(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}function lz(t){return Object.prototype.toString.call(t)==="[object Object]"}function Ale(t){return new Promise(e=>{Zh.setTimeout(e,t)})}function Fj(t,e,n){return typeof n.structuralSharing=="function"?n.structuralSharing(t,e):n.structuralSharing!==!1?iD(t,e):e}function Cle(t,e,n=0){const r=[...t,e];return n&&r.length>n?r.slice(1):r}function kle(t,e,n=0){const r=[e,...t];return n&&r.length>n?r.slice(0,-1):r}var aD=Symbol();function LW(t,e){return!t.queryFn&&e?.initialPromise?()=>e.initialPromise:!t.queryFn||t.queryFn===aD?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function IW(t,e){return typeof t=="function"?t(...e):!!t}var jle=class extends Qf{#t;#e;#n;constructor(){super(),this.#n=t=>{if(!Mf&&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"}},sD=new jle;function Uj(){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=Mle;function Rle(){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 ni=Rle(),Dle=class extends Qf{#t=!0;#e;#n;constructor(){super(),this.#n=t=>{if(!Mf&&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}},pw=new Dle;function Ole(t){return Math.min(1e3*2**t,3e4)}function FW(t){return(t??"online")==="online"?pw.isOnline():!0}var zj=class extends Error{constructor(t){super("CancelledError"),this.revert=t?.revert,this.silent=t?.silent}};function UW(t){let e=!1,n=0,r;const i=Uj(),a=()=>i.status!=="pending",o=y=>{if(!a()){const b=new zj(y);m(b),t.onCancel?.(b)}},l=()=>{e=!0},c=()=>{e=!1},u=()=>sD.isFocused()&&(t.networkMode==="always"||pw.isOnline())&&t.canRun(),d=()=>FW(t.networkMode)&&t.canRun(),f=y=>{a()||(r?.(),i.resolve(y))},m=y=>{a()||(r?.(),i.reject(y))},p=()=>new Promise(y=>{r=b=>{(a()||u())&&y(b)},t.onPause?.()}).then(()=>{r=void 0,a()||t.onContinue?.()}),x=()=>{if(a())return;let y;const b=n===0?t.initialPromise:void 0;try{y=b??t.fn()}catch(v){y=Promise.reject(v)}Promise.resolve(y).then(f).catch(v=>{if(a())return;const N=t.retry??(Mf?0:3),S=t.retryDelay??Ole,T=typeof S=="function"?S(n,v):S,E=N===!0||typeof N=="number"&&n<N||typeof N=="function"&&N(n,v);if(e||!E){m(v);return}n++,t.onFail?.(n,v),Ale(T).then(()=>u()?void 0:p()).then(()=>{e?m(v):x()})})};return{promise:i,status:()=>i.status,cancel:o,continue:()=>(r?.(),i),cancelRetry:l,continueRetry:c,canStart:d,start:()=>(d()?x():p().then(x),i)}}var zW=class{#t;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Lj(this.gcTime)&&(this.#t=Zh.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(Mf?1/0:300*1e3))}clearGcTimeout(){this.#t&&(Zh.clearTimeout(this.#t),this.#t=void 0)}},Lle=class extends zW{#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=uz(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=uz(this.options);e.data!==void 0&&(this.setState(cz(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#n.remove(this)}setData(t,e){const n=Fj(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(Pa).catch(Pa):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#t)}isActive(){return this.observers.some(t=>xo(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===aD||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>Ad(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:!OW(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=LW(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=UW({initialPromise:e?.initialPromise,fn:o.fetchFn,onCancel:l=>{l instanceof zj&&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 zj){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,...BW(n.data,this.options),fetchMeta:t.meta??null};case"success":const r={...n,...cz(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),ni.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),this.#n.notify({query:this,type:"updated",action:t})})}};function BW(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:FW(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function cz(t,e){return{data:t,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}function uz(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 oD=class extends Qf{constructor(t,e){super(),this.options=e,this.#t=t,this.#s=null,this.#o=Uj(),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),dz(this.#e,this.options)?this.#m():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Bj(this.#e,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Bj(this.#e,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#v(),this.#_(),this.#e.removeObserver(this)}setOptions(t){const e=this.options,n=this.#e;if(this.options=this.#t.defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof xo(this.options.enabled,this.#e)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#w(),this.#e.setOptions(this.options),e._defaulted&&!d0(this.options,e)&&this.#t.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#e,observer:this});const r=this.hasListeners();r&&hz(this.#e,n,this.options,e)&&this.#m(),this.updateResult(),r&&(this.#e!==n||xo(this.options.enabled,this.#e)!==xo(e.enabled,this.#e)||Ad(this.options.staleTime,this.#e)!==Ad(e.staleTime,this.#e))&&this.#g();const i=this.#x();r&&(this.#e!==n||xo(this.options.enabled,this.#e)!==xo(e.enabled,this.#e)||i!==this.#l)&&this.#b(i)}getOptimisticResult(t){const e=this.#t.getQueryCache().build(this.#t,t),n=this.createResult(e,t);return Fle(this,n)&&(this.#i=n,this.#a=this.options,this.#r=this.#e.state),n}getCurrentResult(){return this.#i}trackResult(t,e){return new Proxy(t,{get:(n,r)=>(this.trackProp(r),e?.(r),r==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&this.#o.status==="pending"&&this.#o.reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(n,r))})}trackProp(t){this.#p.add(t)}getCurrentQuery(){return this.#e}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const e=this.#t.defaultQueryOptions(t),n=this.#t.getQueryCache().build(this.#t,e);return n.fetch().then(()=>this.createResult(n,e))}fetch(t){return this.#m({...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#i))}#m(t){this.#w();let e=this.#e.fetch(this.options,t);return t?.throwOnError||(e=e.catch(Pa)),e}#g(){this.#v();const t=Ad(this.options.staleTime,this.#e);if(Mf||this.#i.isStale||!Lj(t))return;const n=OW(this.#i.dataUpdatedAt,t)+1;this.#c=Zh.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.#_(),this.#l=t,!(Mf||xo(this.options.enabled,this.#e)===!1||!Lj(this.#l)||this.#l===0)&&(this.#u=Zh.setInterval(()=>{(this.options.refetchIntervalInBackground||sD.isFocused())&&this.#m()},this.#l))}#y(){this.#g(),this.#b(this.#x())}#v(){this.#c&&(Zh.clearTimeout(this.#c),this.#c=void 0)}#_(){this.#u&&(Zh.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,m;if(e._optimisticResults){const O=this.hasListeners(),k=!O&&dz(t,e),R=O&&hz(t,n,e,r);(k||R)&&(d={...d,...BW(u.data,t.options)}),e._optimisticResults==="isRestoring"&&(d.fetchStatus="idle")}let{error:p,errorUpdatedAt:x,status:y}=d;m=d.data;let b=!1;if(e.placeholderData!==void 0&&m===void 0&&y==="pending"){let O;i?.isPlaceholderData&&e.placeholderData===o?.placeholderData?(O=i.data,b=!0):O=typeof e.placeholderData=="function"?e.placeholderData(this.#h?.state.data,this.#h):e.placeholderData,O!==void 0&&(y="success",m=Fj(i?.data,O,e),f=!0)}if(e.select&&m!==void 0&&!b)if(i&&m===a?.data&&e.select===this.#f)m=this.#d;else try{this.#f=e.select,m=e.select(m),m=Fj(i?.data,m,e),this.#d=m,this.#s=null}catch(O){this.#s=O}this.#s&&(p=this.#s,m=this.#d,x=Date.now(),y="error");const v=d.fetchStatus==="fetching",N=y==="pending",S=y==="error",T=N&&v,E=m!==void 0,A={status:y,fetchStatus:d.fetchStatus,isPending:N,isSuccess:y==="success",isError:S,isInitialLoading:T,isLoading:T,data:m,dataUpdatedAt:d.dataUpdatedAt,error:p,errorUpdatedAt:x,failureCount:d.fetchFailureCount,failureReason:d.fetchFailureReason,errorUpdateCount:d.errorUpdateCount,isFetched:d.dataUpdateCount>0||d.errorUpdateCount>0,isFetchedAfterMount:d.dataUpdateCount>c.dataUpdateCount||d.errorUpdateCount>c.errorUpdateCount,isFetching:v,isRefetching:v&&!N,isLoadingError:S&&!E,isPaused:d.fetchStatus==="paused",isPlaceholderData:f,isRefetchError:S&&E,isStale:lD(t,e),refetch:this.refetch,promise:this.#o,isEnabled:xo(e.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const O=F=>{A.status==="error"?F.reject(A.error):A.data!==void 0&&F.resolve(A.data)},k=()=>{const F=this.#o=A.promise=Uj();O(F)},R=this.#o;switch(R.status){case"pending":t.queryHash===n.queryHash&&O(R);break;case"fulfilled":(A.status==="error"||A.data!==R.value)&&k();break;case"rejected":(A.status!=="error"||A.error!==R.reason)&&k();break}}return A}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),d0(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()})}#w(){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){ni.batch(()=>{t.listeners&&this.listeners.forEach(e=>{e(this.#i)}),this.#t.getQueryCache().notify({query:this.#e,type:"observerResultsUpdated"})})}};function Ile(t,e){return xo(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&e.retryOnMount===!1)}function dz(t,e){return Ile(t,e)||t.state.data!==void 0&&Bj(t,e,e.refetchOnMount)}function Bj(t,e,n){if(xo(e.enabled,t)!==!1&&Ad(e.staleTime,t)!=="static"){const r=typeof n=="function"?n(t):n;return r==="always"||r!==!1&&lD(t,e)}return!1}function hz(t,e,n,r){return(t!==e||xo(r.enabled,t)===!1)&&(!n.suspense||t.state.status!=="error")&&lD(t,n)}function lD(t,e){return xo(e.enabled,t)!==!1&&t.isStaleByTime(Ad(e.staleTime,t))}function Fle(t,e){return!d0(t.getCurrentResult(),e)}function fz(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)})},m=LW(e.options,e.fetchOptions),p=async(x,y,b)=>{if(d)return Promise.reject();if(y==null&&x.pages.length)return Promise.resolve(x);const N=(()=>{const C={client:e.client,queryKey:e.queryKey,pageParam:y,direction:b?"backward":"forward",meta:e.options.meta};return f(C),C})(),S=await m(N),{maxPages:T}=e.options,E=b?kle:Cle;return{pages:E(x.pages,S,T),pageParams:E(x.pageParams,y,T)}};if(i&&a.length){const x=i==="backward",y=x?Ule:mz,b={pages:a,pageParams:o},v=y(r,b);l=await p(b,v,x)}else{const x=t??a.length;do{const y=c===0?o[0]??r.initialPageParam:mz(r,l);if(c>0&&y==null)break;l=await p(l,y),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 mz(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 zW{#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||$W(),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=UW({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),ni.batch(()=>{this.#e.forEach(n=>{n.onMutationUpdate(t)}),this.#n.notify({mutation:this,type:"updated",action:t})})}};function $W(){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 Qf{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=n_(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=n_(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=n_(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=n_(t);return typeof e=="string"?this.#e.get(e)?.find(r=>r!==t&&r.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){ni.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=>sz(e,n))}findAll(t={}){return this.getAll().filter(e=>sz(t,e))}notify(t){ni.batch(()=>{this.listeners.forEach(e=>{e(t)})})}resumePausedMutations(){const t=this.getAll().filter(e=>e.state.isPaused);return ni.batch(()=>Promise.all(t.map(e=>e.continue().catch(Pa))))}};function n_(t){return t.options.scope?.id}var $le=class extends Qf{#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),d0(this.options,n)||this.#t.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#n,observer:this}),n?.mutationKey&&this.options.mutationKey&&Ef(n.mutationKey)!==Ef(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??$W();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){ni.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 pz(t,e){const n=new Set(e);return t.filter(r=>!n.has(r))}function Hle(t,e,n){const r=t.slice(0);return r[e]=n,r}var Vle=class extends Qf{#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,ni.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 m=this.#e[f];return!m||!d0(d,m)});!c&&!u||(c&&(this.#r=i),this.#e=a,this.hasListeners()&&(c&&(pz(n,i).forEach(d=>{d.destroy()}),pz(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=iD(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 oD(this.#t,i);n.push({defaultedQueryOptions:i,observer:o})}),n}#u(t,e){const n=this.#r.indexOf(t);n!==-1&&(this.#e=Hle(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&&ni.batch(()=>{this.listeners.forEach(r=>{r(this.#e)})})}}},Gle=class extends Qf{constructor(t={}){super(),this.config=t,this.#t=new Map}#t;build(t,e,n){const r=e.queryKey,i=e.queryHash??rD(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(){ni.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=>az(e,n))}findAll(t={}){const e=this.getAll();return Object.keys(t).length>0?e.filter(n=>az(t,n)):e}notify(t){ni.batch(()=>{this.listeners.forEach(e=>{e(t)})})}onFocus(){ni.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){ni.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Wle=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=sD.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#t.onFocus())}),this.#s=pw.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(Ad(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=Ele(e,a);if(o!==void 0)return this.#t.build(this,r).setData(o,{...n,manual:!0})}setQueriesData(t,e,n){return ni.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;ni.batch(()=>{e.findAll(t).forEach(n=>{e.remove(n)})})}resetQueries(t,e){const n=this.#t;return ni.batch(()=>(n.findAll(t).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){const n={revert:!0,...e},r=ni.batch(()=>this.#t.findAll(t).map(i=>i.cancel(n)));return Promise.all(r).then(Pa).catch(Pa)}invalidateQueries(t,e={}){return ni.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=ni.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(Pa)),i.state.fetchStatus==="paused"?Promise.resolve():a}));return Promise.all(r).then(Pa)}fetchQuery(t){const e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);const n=this.#t.build(this,e);return n.isStaleByTime(Ad(e.staleTime,n))?n.fetch(e):Promise.resolve(n.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(Pa).catch(Pa)}fetchInfiniteQuery(t){return t.behavior=fz(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(Pa).catch(Pa)}ensureInfiniteQueryData(t){return t.behavior=fz(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return pw.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(Ef(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...this.#i.values()],n={};return e.forEach(r=>{u0(t,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(t,e){this.#r.set(Ef(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...this.#r.values()],n={};return e.forEach(r=>{u0(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=rD(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===aD&&(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()}},HW=w.createContext(void 0),on=t=>{const e=w.useContext(HW);if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},qle=({client:t,children:e})=>(w.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),s.jsx(HW.Provider,{value:t,children:e})),VW=w.createContext(!1),GW=()=>w.useContext(VW);VW.Provider;function Kle(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var Xle=w.createContext(Kle()),WW=()=>w.useContext(Xle),qW=(t,e)=>{(t.suspense||t.throwOnError||t.experimental_prefetchInRender)&&(e.isReset()||(t.retryOnMount=!1))},KW=t=>{w.useEffect(()=>{t.clearReset()},[t])},XW=({result:t,errorResetBoundary:e,throwOnError:n,query:r,suspense:i})=>t.isError&&!e.isReset()&&!t.isFetching&&r&&(i&&t.data===void 0||IW(n,[t.error,r])),YW=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))}},QW=(t,e)=>t.isLoading&&t.isFetching&&!e,$j=(t,e)=>t?.suspense&&e.isPending,gw=(t,e,n)=>e.fetchOptimistic(t).catch(()=>{n.clearReset()});function Yle({queries:t,...e},n){const r=on(),i=GW(),a=WW(),o=w.useMemo(()=>t.map(y=>{const b=r.defaultQueryOptions(y);return b._optimisticResults=i?"isRestoring":"optimistic",b}),[t,r,i]);o.forEach(y=>{YW(y),qW(y,a)}),KW(a);const[l]=w.useState(()=>new Vle(r,o,e)),[c,u,d]=l.getOptimisticResult(o,e.combine),f=!i&&e.subscribed!==!1;w.useSyncExternalStore(w.useCallback(y=>f?l.subscribe(ni.batchCalls(y)):Pa,[l,f]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),w.useEffect(()=>{l.setQueries(o,e)},[o,e,l]);const p=c.some((y,b)=>$j(o[b],y))?c.flatMap((y,b)=>{const v=o[b];if(v){const N=new oD(r,v);if($j(v,y))return gw(v,N,a);QW(y,i)&&gw(v,N,a)}return[]}):[];if(p.length>0)throw Promise.all(p);const x=c.find((y,b)=>{const v=o[b];return v&&XW({result:y,errorResetBoundary:a,throwOnError:v.throwOnError,query:r.getQueryCache().get(v.queryHash),suspense:v.suspense})});if(x?.error)throw x.error;return u(d())}function Qle(t,e,n){const r=GW(),i=WW(),a=on(),o=a.defaultQueryOptions(t);a.getDefaultOptions().queries?._experimental_beforeQuery?.(o),o._optimisticResults=r?"isRestoring":"optimistic",YW(o),qW(o,i),KW(i);const l=!a.getQueryCache().get(o.queryHash),[c]=w.useState(()=>new e(a,o)),u=c.getOptimisticResult(o),d=!r&&t.subscribed!==!1;if(w.useSyncExternalStore(w.useCallback(f=>{const m=d?c.subscribe(ni.batchCalls(f)):Pa;return c.updateResult(),m},[c,d]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),w.useEffect(()=>{c.setOptions(o)},[o,c]),$j(o,u))throw gw(o,c,i);if(XW({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&&!Mf&&QW(u,r)&&(l?gw(o,c,i):a.getQueryCache().get(o.queryHash)?.promise)?.catch(Pa).finally(()=>{c.updateResult()}),o.notifyOnChangeProps?u:c.trackResult(u)}function ut(t,e){return Qle(t,oD)}function pt(t,e){const n=on(),[r]=w.useState(()=>new $le(n,t));w.useEffect(()=>{r.setOptions(t)},[r,t]);const i=w.useSyncExternalStore(w.useCallback(o=>r.subscribe(ni.batchCalls(o)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=w.useCallback((o,l)=>{r.mutate(o,l).catch(Pa)},[r]);if(i.error&&IW(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}const Zle=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Jle=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase()),gz=t=>{const e=Jle(t);return e.charAt(0).toUpperCase()+e.slice(1)},ZW=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim(),ece=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var tce={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 nce=w.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i="",children:a,iconNode:o,...l},c)=>w.createElement("svg",{ref:c,...tce,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:ZW("lucide",i),...!a&&!ece(l)&&{"aria-hidden":"true"},...l},[...o.map(([u,d])=>w.createElement(u,d)),...Array.isArray(a)?a:[a]]));const Qe=(t,e)=>{const n=w.forwardRef(({className:r,...i},a)=>w.createElement(nce,{ref:a,iconNode:e,className:ZW(`lucide-${Zle(gz(t))}`,`lucide-${t}`,r),...i}));return n.displayName=gz(t),n};const rce=[["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"}]],ice=Qe("air-vent",rce);const ace=[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]],Ka=Qe("archive",ace);const sce=[["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"}]],oce=Qe("arrow-down-wide-narrow",sce);const lce=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],h0=Qe("arrow-down",lce);const cce=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],JW=Qe("arrow-left",cce);const uce=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],Hj=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"}]],eq=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"}]],rg=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"}]],cf=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"}]],_ce=Qe("bookmark",vce);const wce=[["path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z",key:"hh9hay"}],["path",{d:"m3.3 7 8.7 5 8.7-5",key:"g66t2b"}],["path",{d:"M12 22V12",key:"d0xqtd"}]],zs=Qe("box",wce);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"}]],tq=Qe("briefcase",Sce);const Nce=[["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"}]],j2=Qe("bug",Nce);const Mce=[["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"}]],Ece=Qe("cable",Mce);const Tce=[["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"}]],Ace=Qe("calculator",Tce);const Cce=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}],["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"}]],kce=Qe("calendar-days",Cce);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"}]],ri=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"}]],Tf=Qe("camera",Pce);const Rce=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]],Dce=Qe("chart-column",Rce);const Oce=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Ya=Qe("check",Oce);const Lce=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Pi=Qe("chevron-down",Lce);const Ice=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Ys=Qe("chevron-right",Ice);const Fce=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Af=Qe("chevron-left",Fce);const Uce=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],su=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"}]],ji=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"}]],DT=Qe("circle-arrow-up",Bce);const $ce=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],Fn=Qe("circle-check-big",$ce);const Hce=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],P2=Qe("circle-check",Hce);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 Wce=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]],qce=Qe("circle-stop",Wce);const Kce=[["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"}]],ta=Qe("circle-x",Kce);const Xce=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Vj=Qe("circle",Xce);const Yce=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Kn=Qe("clock",Yce);const Qce=[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]],R2=Qe("cloud",Qce);const Zce=[["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"}]],Jce=Qe("code-xml",Zce);const eue=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],nq=Qe("code",eue);const tue=[["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"}]],nue=Qe("coffee",tue);const rue=[["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"}]],iue=Qe("cog",rue);const aue=[["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"}]],sue=Qe("compass",aue);const oue=[["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"}]],ol=Qe("copy",oue);const lue=[["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"}]],r_=Qe("cpu",lue);const cue=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5v14a9 3 0 0 0 18 0V5",key:"aqi0yr"}]],uue=Qe("cylinder",cue);const due=[["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"}]],Qc=Qe("database",due);const hue=[["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"}]],Gj=Qe("dollar-sign",hue);const fue=[["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"}]],$r=Qe("download",fue);const mue=[["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"}]],cD=Qe("droplet",mue);const pue=[["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"}]],uD=Qe("droplets",pue);const gue=[["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"}]],Cd=Qe("ellipsis-vertical",gue);const xue=[["line",{x1:"5",x2:"19",y1:"9",y2:"9",key:"1nwqeh"}],["line",{x1:"5",x2:"19",y1:"15",y2:"15",key:"g8yjpy"}]],OT=Qe("equal",xue);const bue=[["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"}]],Ur=Qe("external-link",bue);const yue=[["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"}]],D2=Qe("eye-off",yue);const vue=[["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"}]],Cf=Qe("eye",vue);const _ue=[["path",{d:"M10.827 16.379a6.082 6.082 0 0 1-8.618-7.002l5.412 1.45a6.082 6.082 0 0 1 7.002-8.618l-1.45 5.412a6.082 6.082 0 0 1 8.618 7.002l-5.412-1.45a6.082 6.082 0 0 1-7.002 8.618l1.45-5.412Z",key:"484a7f"}],["path",{d:"M12 12v.01",key:"u5ubse"}]],rq=Qe("fan",_ue);const wue=[["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"}]],uf=Qe("file-box",wue);const Sue=[["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"}]],xw=Qe("file-code",Sue);const Nue=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Mue=Qe("file-exclamation-point",Nue);const Eue=[["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"}]],bw=Qe("file-spreadsheet",Eue);const Tue=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],Ga=Qe("file-text",Tue);const Aue=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}]],O2=Qe("file",Aue);const Cue=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 3v18",key:"bbkbws"}],["path",{d:"M3 7.5h4",key:"zfgn84"}],["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 16.5h4",key:"1230mu"}],["path",{d:"M17 3v18",key:"in4fa5"}],["path",{d:"M17 7.5h4",key:"myr1c1"}],["path",{d:"M17 16.5h4",key:"go4c1d"}]],kd=Qe("film",Cue);const kue=[["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"}]],jue=Qe("flame",kue);const Pue=[["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"}]],wa=Qe("folder-kanban",Pue);const Rue=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],ll=Qe("folder-open",Rue);const Due=[["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"}]],Oue=Qe("folder-plus",Due);const Lue=[["path",{d:"M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"hod4my"}],["path",{d:"M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"w4yl2u"}],["path",{d:"M3 5a2 2 0 0 0 2 2h3",key:"f2jnh7"}],["path",{d:"M3 3v13a2 2 0 0 0 2 2h3",key:"k8epm1"}]],Iue=Qe("folder-tree",Lue);const Fue=[["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"}]],iq=Qe("folder",Fue);const Uue=[["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"}]],zue=Qe("fullscreen",Uue);const Bue=[["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"}]],L2=Qe("funnel",Bue);const $ue=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],I2=Qe("gauge",$ue);const Hue=[["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"}]],Vue=Qe("gift",Hue);const Gue=[["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"}]],$p=Qe("git-compare",Gue);const Wue=[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]],Wj=Qe("github",Wue);const que=[["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"}]],jd=Qe("globe",que);const Kue=[["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"}]],ig=Qe("grip-vertical",Kue);const Xue=[["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"}]],aq=Qe("hand",Xue);const Yue=[["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"}]],F2=Qe("hard-drive",Yue);const Que=[["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"}]],Zue=Qe("hash",Que);const Jue=[["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"}]],ede=Qe("headphones",Jue);const tde=[["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"}]],nde=Qe("heart",tde);const rde=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],f0=Qe("history",rde);const ide=[["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"}]],U2=Qe("house",ide);const ade=[["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"}]],ay=Qe("image",ade);const sde=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Ul=Qe("info",sde);const ode=[["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"}]],lde=Qe("italic",ode);const cde=[["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"}]],Jh=Qe("key",cde);const ude=[["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"}]],qj=Qe("keyboard",ude);const dde=[["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"}]],cl=Qe("layers",dde);const hde=[["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"}]],z2=Qe("layout-grid",hde);const fde=[["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"}]],mde=Qe("link-2-off",fde);const pde=[["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"}]],Ol=Qe("link-2",pde);const gde=[["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"}]],Ug=Qe("link",gde);const xde=[["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"}]],sq=Qe("list-ordered",xde);const bde=[["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"}]],Kj=Qe("list-todo",bde);const yde=[["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"}]],B2=Qe("list",yde);const vde=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],dt=Qe("loader-circle",vde);const _de=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 9.9-1",key:"1mm8w8"}]],xz=Qe("lock-open",_de);const wde=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],LT=Qe("lock",wde);const Sde=[["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"}]],bz=Qe("log-in",Sde);const Nde=[["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"}]],Xj=Qe("log-out",Nde);const Mde=[["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"}]],Ede=Qe("mail",Mde);const Tde=[["path",{d:"M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z",key:"169xi5"}],["path",{d:"M15 5.764v15",key:"1pn4in"}],["path",{d:"M9 3.236v15",key:"1uimfh"}]],Ade=Qe("map",Tde);const Cde=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],oq=Qe("maximize-2",Cde);const kde=[["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"}]],jde=Qe("maximize",kde);const Pde=[["path",{d:"M6 19v-3",key:"1nvgqn"}],["path",{d:"M10 19v-3",key:"iu8nkm"}],["path",{d:"M14 19v-3",key:"kcehxu"}],["path",{d:"M18 19v-3",key:"1vh91z"}],["path",{d:"M8 11V9",key:"63erz4"}],["path",{d:"M16 11V9",key:"fru6f3"}],["path",{d:"M12 11V9",key:"ha00sb"}],["path",{d:"M2 15h20",key:"16ne18"}],["path",{d:"M2 7a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v1.1a2 2 0 0 0 0 3.837V17a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-5.1a2 2 0 0 0 0-3.837Z",key:"lhddv3"}]],Rde=Qe("memory-stick",Pde);const Dde=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],Ode=Qe("menu",Dde);const Lde=[["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"}]],lq=Qe("minimize-2",Lde);const Ide=[["path",{d:"M8 3v3a2 2 0 0 1-2 2H3",key:"hohbtr"}],["path",{d:"M21 8h-3a2 2 0 0 1-2-2V3",key:"5jw1f3"}],["path",{d:"M3 16h3a2 2 0 0 1 2 2v3",key:"198tvr"}],["path",{d:"M16 21v-3a2 2 0 0 1 2-2h3",key:"ph8mxp"}]],cq=Qe("minimize",Ide);const Fde=[["path",{d:"M5 12h14",key:"1ays0h"}]],Yj=Qe("minus",Fde);const Ude=[["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"}]],zde=Qe("monitor",Ude);const Bde=[["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"}]],yw=Qe("moon",Bde);const $de=[["path",{d:"M18 8L22 12L18 16",key:"1r0oui"}],["path",{d:"M2 12H22",key:"1m8cig"}]],Hde=Qe("move-right",$de);const Vde=[["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"}]],Qj=Qe("music",Vde);const Gde=[["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"}]],zl=Qe("package",Gde);const Wde=[["path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",key:"e79jfc"}],["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}]],dD=Qe("palette",Wde);const qde=[["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"}]],hD=Qe("pause",qde);const Kde=[["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"}]],kf=Qe("pen-line",Kde);const Xde=[["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"}]],$2=Qe("pen",Xde);const Yde=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],ia=Qe("pencil",Yde);const Qde=[["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"}]],Zde=Qe("phone",Qde);const Jde=[["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"}]],Po=Qe("play",Jde);const ehe=[["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"}]],Vs=Qe("plug",ehe);const the=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Jn=Qe("plus",the);const nhe=[["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"}]],H2=Qe("power-off",nhe);const rhe=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],gu=Qe("power",rhe);const ihe=[["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"}]],Mr=Qe("printer",ihe);const ahe=[["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"}]],uq=Qe("qr-code",ahe);const she=[["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"}]],xr=Qe("refresh-cw",she);const ohe=[["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"}]],Zf=Qe("rotate-ccw",ohe);const lhe=[["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"}]],che=Qe("ruler",lhe);const uhe=[["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"}]],gs=Qe("save",uhe);const dhe=[["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"}]],vw=Qe("scan-search",dhe);const hhe=[["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"}]],fhe=Qe("scissors",hhe);const mhe=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],_a=Qe("search",mhe);const phe=[["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"}]],fD=Qe("send",phe);const ghe=[["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"}]],zh=Qe("server",ghe);const xhe=[["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"}]],Bd=Qe("settings-2",xhe);const bhe=[["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"}]],V2=Qe("settings",bhe);const yhe=[["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"}]],Zj=Qe("shield",yhe);const vhe=[["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"}]],dq=Qe("shopping-cart",vhe);const _he=[["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"}]],whe=Qe("signal",_he);const She=[["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"}]],Nhe=Qe("skip-back",She);const Mhe=[["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"}]],m0=Qe("skip-forward",Mhe);const Ehe=[["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"}]],yz=Qe("sliders-vertical",Ehe);const The=[["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"}]],p0=Qe("sparkles",The);const Ahe=[["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"}]],Ro=Qe("square-check-big",Ahe);const Che=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 12h8",key:"1wcyev"}]],khe=Qe("square-minus",Che);const jhe=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],Do=Qe("square",jhe);const Phe=[["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"}]],jf=Qe("star",Phe);const Rhe=[["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"}]],hq=Qe("sticky-note",Rhe);const Dhe=[["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"}]],vz=Qe("sun",Dhe);const Ohe=[["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"}]],ag=Qe("tag",Ohe);const Lhe=[["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"}]],fq=Qe("target",Lhe);const Ihe=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],mq=Qe("terminal",Ihe);const Fhe=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 19H5",key:"vjpgq2"}]],Uhe=Qe("text-align-center",Fhe);const zhe=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 19H7",key:"4cu937"}]],Bhe=Qe("text-align-end",zhe);const $he=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]],Hhe=Qe("text-align-start",$he);const Vhe=[["path",{d:"M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"17jzev"}]],G2=Qe("thermometer",Vhe);const Ghe=[["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"}]],vd=Qe("timer",Ghe);const Whe=[["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"}]],un=Qe("trash-2",Whe);const qhe=[["path",{d:"M16 17h6v-6",key:"t6n2it"}],["path",{d:"m22 17-8.5-8.5-5 5L2 7",key:"x473p"}]],pq=Qe("trending-down",qhe);const Khe=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],Jj=Qe("trending-up",Khe);const Xhe=[["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"}]],yn=Qe("triangle-alert",Xhe);const Yhe=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],Qhe=Qe("underline",Yhe);const Zhe=[["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"}]],mD=Qe("unlink",Zhe);const Jhe=[["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"}]],di=Qe("upload",Jhe);const efe=[["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"}]],e3=Qe("user",efe);const tfe=[["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"}]],_d=Qe("users",tfe);const nfe=[["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"}]],pD=Qe("video",nfe);const rfe=[["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"}]],ife=Qe("volume-2",rfe);const afe=[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["line",{x1:"22",x2:"16",y1:"9",y2:"15",key:"1ewh16"}],["line",{x1:"16",x2:"22",y1:"9",y2:"15",key:"5ykzw1"}]],sfe=Qe("volume-x",afe);const ofe=[["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"}]],lfe=Qe("wand-sparkles",ofe);const cfe=[["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"}]],zg=Qe("wifi-off",cfe);const ufe=[["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"}]],Hp=Qe("wifi",ufe);const dfe=[["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"}]],gq=Qe("wind",dfe);const hfe=[["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"}]],$d=Qe("wrench",hfe);const ffe=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],zt=Qe("x",ffe);const mfe=[["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"}]],gD=Qe("zoom-in",mfe);const pfe=[["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"}]],Pf=Qe("zap",pfe);const gfe=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],xD=Qe("zoom-out",gfe),xn="/api/v1";let _w=localStorage.getItem("auth_token");function Nb(t){_w=t,t?localStorage.setItem("auth_token",t):localStorage.removeItem("auth_token")}function _z(){return _w}async function ke(t,e={}){const n={"Content-Type":"application/json",...e.headers};_w&&(n.Authorization=`Bearer ${_w}`);const r=await fetch(`${xn}${t}`,{...e,cache:"no-store",headers:n});if(!r.ok){r.status===401&&Nb(null);const a=(await r.json().catch(()=>({}))).detail,o=typeof a=="string"?a:a?JSON.stringify(a):`HTTP ${r.status}`;throw new Error(o)}return await r.json()}const he={getAuthStatus:()=>ke("/auth/status"),setupAuth:t=>ke("/auth/setup",{method:"POST",body:JSON.stringify(t)}),login:t=>ke("/auth/login",{method:"POST",body:JSON.stringify(t)}),logout:()=>ke("/auth/logout",{method:"POST"}),getCurrentUser:()=>ke("/auth/me"),disableAuth:()=>ke("/auth/disable",{method:"POST"}),getUsers:()=>ke("/users/"),getUser:t=>ke(`/users/${t}`),createUser:t=>ke("/users/",{method:"POST",body:JSON.stringify(t)}),updateUser:(t,e)=>ke(`/users/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteUser:t=>ke(`/users/${t}`,{method:"DELETE"}),getPrinters:()=>ke("/printers/"),getPrinter:t=>ke(`/printers/${t}`),createPrinter:t=>ke("/printers/",{method:"POST",body:JSON.stringify(t)}),updatePrinter:(t,e)=>ke(`/printers/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deletePrinter:(t,e=!0)=>ke(`/printers/${t}?delete_archives=${e}`,{method:"DELETE"}),getPrinterStatus:t=>ke(`/printers/${t}/status`),refreshPrinterStatus:t=>ke(`/printers/${t}/refresh-status`,{method:"POST"}),connectPrinter:t=>ke(`/printers/${t}/connect`,{method:"POST"}),disconnectPrinter:t=>ke(`/printers/${t}/disconnect`,{method:"POST"}),testExternalCamera:(t,e,n)=>ke(`/printers/${t}/camera/external/test?url=${encodeURIComponent(e)}&camera_type=${encodeURIComponent(n)}`,{method:"POST"}),stopPrint:t=>ke(`/printers/${t}/print/stop`,{method:"POST"}),pausePrint:t=>ke(`/printers/${t}/print/pause`,{method:"POST"}),resumePrint:t=>ke(`/printers/${t}/print/resume`,{method:"POST"}),setChamberLight:(t,e)=>ke(`/printers/${t}/chamber-light?on=${e}`,{method:"POST"}),getPrintableObjects:t=>ke(`/printers/${t}/print/objects`),skipObjects:(t,e)=>ke(`/printers/${t}/print/skip-objects`,{method:"POST",body:JSON.stringify(e)}),refreshAmsSlot:(t,e,n)=>ke(`/printers/${t}/ams/${e}/slot/${n}/refresh`,{method:"POST"}),enableMQTTLogging:t=>ke(`/printers/${t}/logging/enable`,{method:"POST"}),disableMQTTLogging:t=>ke(`/printers/${t}/logging/disable`,{method:"POST"}),getMQTTLogs:t=>ke(`/printers/${t}/logging`),clearMQTTLogs:t=>ke(`/printers/${t}/logging`,{method:"DELETE"}),getPrinterFiles:(t,e="/")=>ke(`/printers/${t}/files?path=${encodeURIComponent(e)}`),getPrinterFileDownloadUrl:(t,e)=>`${xn}/printers/${t}/files/download?path=${encodeURIComponent(e)}`,downloadPrinterFilesAsZip:async(t,e)=>{const n=await fetch(`${xn}/printers/${t}/files/download-zip`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({paths:e})});if(!n.ok){const r=await n.json().catch(()=>({}));throw new Error(r.detail||`HTTP ${n.status}`)}return n.blob()},deletePrinterFile:(t,e)=>ke(`/printers/${t}/files?path=${encodeURIComponent(e)}`,{method:"DELETE"}),getPrinterStorage:t=>ke(`/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)),ke(`/archives/?${i}`)},getArchive:t=>ke(`/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)),ke(`/archives/search?${n}`)},rebuildSearchIndex:()=>ke("/archives/search/rebuild-index",{method:"POST"}),updateArchive:(t,e)=>ke(`/archives/${t}`,{method:"PATCH",body:JSON.stringify(e)}),toggleFavorite:t=>ke(`/archives/${t}/favorite`,{method:"POST"}),deleteArchive:t=>ke(`/archives/${t}`,{method:"DELETE"}),getArchiveStats:()=>ke("/archives/stats"),recalculateCosts:()=>ke("/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)),ke(`/archives/analysis/failures?${e}`)},compareArchives:t=>ke(`/archives/compare?archive_ids=${t.join(",")}`),findSimilarArchives:(t,e=10)=>ke(`/archives/${t}/similar?limit=${e}`),exportArchives:async t=>{const e=new URLSearchParams;t?.format&&e.set("format",t.format),t?.fields&&e.set("fields",t.fields.join(",")),t?.printerId&&e.set("printer_id",String(t.printerId)),t?.projectId&&e.set("project_id",String(t.projectId)),t?.status&&e.set("status",t.status),t?.dateFrom&&e.set("date_from",t.dateFrom),t?.dateTo&&e.set("date_to",t.dateTo),t?.search&&e.set("search",t.search);const n=await fetch(`${xn}/archives/export?${e}`);if(!n.ok){const o=await n.json().catch(()=>({}));throw new Error(o.detail||`HTTP ${n.status}`)}const r=n.headers.get("Content-Disposition");let i=t?.format==="xlsx"?"archives_export.xlsx":"archives_export.csv";if(r){const o=r.match(/filename="?([^"]+)"?/);o&&(i=o[1])}return{blob:await n.blob(),filename:i}},exportStats:async t=>{const e=new URLSearchParams;t?.format&&e.set("format",t.format),t?.days&&e.set("days",String(t.days)),t?.printerId&&e.set("printer_id",String(t.printerId)),t?.projectId&&e.set("project_id",String(t.projectId));const n=await fetch(`${xn}/archives/stats/export?${e}`);if(!n.ok){const o=await n.json().catch(()=>({}));throw new Error(o.detail||`HTTP ${n.status}`)}const r=n.headers.get("Content-Disposition");let i=t?.format==="xlsx"?"stats_export.xlsx":"stats_export.csv";if(r){const o=r.match(/filename="?([^"]+)"?/);o&&(i=o[1])}return{blob:await n.blob(),filename:i}},getArchiveDuplicates:t=>ke(`/archives/${t}/duplicates`),backfillContentHashes:()=>ke("/archives/backfill-hashes",{method:"POST"}),getArchiveThumbnail:t=>`${xn}/archives/${t}/thumbnail?v=${Date.now()}`,getArchiveDownload:t=>`${xn}/archives/${t}/download`,getArchiveGcode:t=>`${xn}/archives/${t}/gcode`,getArchivePlatePreview:t=>`${xn}/archives/${t}/plate-preview`,getArchiveTimelapse:t=>`${xn}/archives/${t}/timelapse?v=${Date.now()}`,scanArchiveTimelapse:t=>ke(`/archives/${t}/timelapse/scan`,{method:"POST"}),selectArchiveTimelapse:(t,e)=>ke(`/archives/${t}/timelapse/select?filename=${encodeURIComponent(e)}`,{method:"POST"}),uploadArchiveTimelapse:async(t,e)=>{const n=new FormData;n.append("file",e);const r=await fetch(`${xn}/archives/${t}/timelapse/upload`,{method:"POST",body:n});if(!r.ok){const i=await r.json().catch(()=>({}));throw new Error(i.detail||`HTTP ${r.status}`)}return r.json()},getTimelapseInfo:t=>ke(`/archives/${t}/timelapse/info`),getTimelapseThumbnails:(t,e=10)=>ke(`/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=await fetch(`${xn}/archives/${t}/timelapse/process`,{method:"POST",body:r});if(!i.ok){const a=await i.json().catch(()=>({}));throw new Error(a.detail||`HTTP ${i.status}`)}return i.json()},getArchivePhotoUrl:(t,e)=>`${xn}/archives/${t}/photos/${encodeURIComponent(e)}`,uploadArchivePhoto:async(t,e)=>{const n=new FormData;n.append("file",e);const r=await fetch(`${xn}/archives/${t}/photos`,{method:"POST",body:n});if(!r.ok){const i=await r.json().catch(()=>({}));throw new Error(i.detail||`HTTP ${r.status}`)}return r.json()},deleteArchivePhoto:(t,e)=>ke(`/archives/${t}/photos/${encodeURIComponent(e)}`,{method:"DELETE"}),getSource3mfDownloadUrl:t=>`${xn}/archives/${t}/source`,getSource3mfForSlicer:(t,e)=>`${xn}/archives/${t}/source/${encodeURIComponent(e.endsWith(".3mf")?e:e+".3mf")}`,uploadSource3mf:async(t,e)=>{const n=new FormData;n.append("file",e);const r=await fetch(`${xn}/archives/${t}/source`,{method:"POST",body:n});if(!r.ok){const i=await r.json().catch(()=>({}));throw new Error(i.detail||`HTTP ${r.status}`)}return r.json()},deleteSource3mf:t=>ke(`/archives/${t}/source`,{method:"DELETE"}),getF3dDownloadUrl:t=>`${xn}/archives/${t}/f3d`,uploadF3d:async(t,e)=>{const n=new FormData;n.append("file",e);const r=await fetch(`${xn}/archives/${t}/f3d`,{method:"POST",body:n});if(!r.ok){const i=await r.json().catch(()=>({}));throw new Error(i.detail||`HTTP ${r.status}`)}return r.json()},deleteF3d:t=>ke(`/archives/${t}/f3d`,{method:"DELETE"}),getArchiveQRCodeUrl:(t,e=200)=>`${xn}/archives/${t}/qrcode?size=${e}`,getArchiveCapabilities:t=>ke(`/archives/${t}/capabilities`),getArchiveProjectPage:t=>ke(`/archives/${t}/project-page`),updateArchiveProjectPage:(t,e)=>ke(`/archives/${t}/project-page`,{method:"PATCH",body:JSON.stringify(e)}),getArchiveProjectImageUrl:(t,e)=>`${xn}/archives/${t}/project-image/${encodeURIComponent(e)}`,getArchiveForSlicer:(t,e)=>`${xn}/archives/${t}/file/${encodeURIComponent(e.endsWith(".3mf")?e:e+".3mf")}`,getArchivePlates:t=>ke(`/archives/${t}/plates`),getArchiveFilamentRequirements:(t,e)=>ke(`/archives/${t}/filament-requirements${e!==void 0?`?plate_id=${e}`:""}`),reprintArchive:(t,e,n)=>ke(`/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?`${xn}/archives/upload?printer_id=${e}`:`${xn}/archives/upload`,i=await fetch(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()},uploadArchivesBulk:async(t,e)=>{const n=new FormData;t.forEach(a=>n.append("files",a));const r=e?`${xn}/archives/upload-bulk?printer_id=${e}`:`${xn}/archives/upload-bulk`,i=await fetch(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()},getSettings:()=>ke("/settings/"),updateSettings:t=>ke("/settings/",{method:"PUT",body:JSON.stringify(t)}),getMQTTStatus:()=>ke("/settings/mqtt/status"),resetSettings:()=>ke("/settings/reset",{method:"POST"}),exportBackup:async t=>{const e=new URLSearchParams;t&&(t.settings!==void 0&&e.set("include_settings",String(t.settings)),t.notifications!==void 0&&e.set("include_notifications",String(t.notifications)),t.templates!==void 0&&e.set("include_templates",String(t.templates)),t.smart_plugs!==void 0&&e.set("include_smart_plugs",String(t.smart_plugs)),t.external_links!==void 0&&e.set("include_external_links",String(t.external_links)),t.printers!==void 0&&e.set("include_printers",String(t.printers)),t.plate_calibration!==void 0&&e.set("include_plate_calibration",String(t.plate_calibration)),t.filaments!==void 0&&e.set("include_filaments",String(t.filaments)),t.maintenance!==void 0&&e.set("include_maintenance",String(t.maintenance)),t.archives!==void 0&&e.set("include_archives",String(t.archives)),t.projects!==void 0&&e.set("include_projects",String(t.projects)),t.pending_uploads!==void 0&&e.set("include_pending_uploads",String(t.pending_uploads)),t.access_codes!==void 0&&e.set("include_access_codes",String(t.access_codes)),t.api_keys!==void 0&&e.set("include_api_keys",String(t.api_keys)));const n=`${xn}/settings/backup${e.toString()?"?"+e.toString():""}`,r=await fetch(n);if(!r.ok){const l=await r.text();throw new Error(l||`Backup failed with status ${r.status}`)}const i=r.headers.get("Content-Disposition");let a="bambuddy-backup.json";if(i){const l=i.match(/filename=([^;]+)/);l&&(a=l[1].trim())}return{blob:await r.blob(),filename:a}},importBackup:async(t,e=!1)=>{const n=new FormData;n.append("file",t);const r=`${xn}/settings/restore${e?"?overwrite=true":""}`;return(await fetch(r,{method:"POST",body:n})).json()},checkFfmpeg:()=>ke("/settings/check-ffmpeg"),getCloudStatus:()=>ke("/cloud/status"),cloudLogin:(t,e,n="global")=>ke("/cloud/login",{method:"POST",body:JSON.stringify({email:t,password:e,region:n})}),cloudVerify:(t,e)=>ke("/cloud/verify",{method:"POST",body:JSON.stringify({email:t,code:e})}),cloudSetToken:t=>ke("/cloud/token",{method:"POST",body:JSON.stringify({access_token:t})}),cloudLogout:()=>ke("/cloud/logout",{method:"POST"}),getCloudSettings:(t="02.04.00.70")=>ke(`/cloud/settings?version=${t}`),getCloudSettingDetail:t=>ke(`/cloud/settings/${t}`),createCloudSetting:t=>ke("/cloud/settings",{method:"POST",body:JSON.stringify(t)}),updateCloudSetting:(t,e)=>ke(`/cloud/settings/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteCloudSetting:t=>ke(`/cloud/settings/${t}`,{method:"DELETE"}),getCloudDevices:()=>ke("/cloud/devices"),getCloudFields:t=>ke(`/cloud/fields/${t}`),getAllCloudFields:()=>ke("/cloud/fields"),getFilamentInfo:t=>ke("/cloud/filament-info",{method:"POST",body:JSON.stringify(t)}),getSmartPlugs:()=>ke("/smart-plugs/"),getSmartPlug:t=>ke(`/smart-plugs/${t}`),getSmartPlugByPrinter:t=>ke(`/smart-plugs/by-printer/${t}`),createSmartPlug:t=>ke("/smart-plugs/",{method:"POST",body:JSON.stringify(t)}),updateSmartPlug:(t,e)=>ke(`/smart-plugs/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteSmartPlug:t=>ke(`/smart-plugs/${t}`,{method:"DELETE"}),controlSmartPlug:(t,e)=>ke(`/smart-plugs/${t}/control`,{method:"POST",body:JSON.stringify({action:e})}),getSmartPlugStatus:t=>ke(`/smart-plugs/${t}/status`),testSmartPlugConnection:(t,e,n)=>ke("/smart-plugs/test-connection",{method:"POST",body:JSON.stringify({ip_address:t,username:e,password:n})}),startTasmotaScan:()=>fetch(`${xn}/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:()=>ke("/smart-plugs/discover/status"),stopTasmotaScan:()=>fetch(`${xn}/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:()=>ke("/smart-plugs/discover/devices"),testHAConnection:(t,e)=>ke("/smart-plugs/ha/test-connection",{method:"POST",body:JSON.stringify({url:t,token:e})}),getHAEntities:t=>{const e=t?`?search=${encodeURIComponent(t)}`:"";return ke(`/smart-plugs/ha/entities${e}`)},getHASensorEntities:()=>ke("/smart-plugs/ha/sensors"),getQueue:(t,e)=>{const n=new URLSearchParams;return t&&n.set("printer_id",String(t)),e&&n.set("status",e),ke(`/queue/?${n}`)},getQueueItem:t=>ke(`/queue/${t}`),addToQueue:t=>ke("/queue/",{method:"POST",body:JSON.stringify(t)}),updateQueueItem:(t,e)=>ke(`/queue/${t}`,{method:"PATCH",body:JSON.stringify(e)}),removeFromQueue:t=>ke(`/queue/${t}`,{method:"DELETE"}),reorderQueue:t=>ke("/queue/reorder",{method:"POST",body:JSON.stringify({items:t})}),cancelQueueItem:t=>ke(`/queue/${t}/cancel`,{method:"POST"}),stopQueueItem:t=>ke(`/queue/${t}/stop`,{method:"POST"}),startQueueItem:t=>ke(`/queue/${t}/start`,{method:"POST"}),bulkUpdateQueue:t=>ke("/queue/bulk",{method:"PATCH",body:JSON.stringify(t)}),getKProfiles:(t,e="0.4")=>ke(`/printers/${t}/kprofiles/?nozzle_diameter=${e}`),setKProfile:(t,e)=>ke(`/printers/${t}/kprofiles/`,{method:"POST",body:JSON.stringify(e)}),deleteKProfile:(t,e)=>ke(`/printers/${t}/kprofiles/`,{method:"DELETE",body:JSON.stringify(e)}),setKProfilesBatch:(t,e)=>ke(`/printers/${t}/kprofiles/batch`,{method:"POST",body:JSON.stringify(e)}),getKProfileNotes:t=>ke(`/printers/${t}/kprofiles/notes`),setKProfileNote:(t,e,n)=>ke(`/printers/${t}/kprofiles/notes`,{method:"PUT",body:JSON.stringify({setting_id:e,note:n})}),deleteKProfileNote:(t,e)=>ke(`/printers/${t}/kprofiles/notes/${encodeURIComponent(e)}`,{method:"DELETE"}),getSlotPresets:t=>ke(`/printers/${t}/slot-presets`),getSlotPreset:(t,e,n)=>ke(`/printers/${t}/slot-presets/${e}/${n}`),saveSlotPreset:(t,e,n,r,i)=>ke(`/printers/${t}/slot-presets/${e}/${n}?preset_id=${encodeURIComponent(r)}&preset_name=${encodeURIComponent(i)}`,{method:"PUT"}),deleteSlotPreset:(t,e,n)=>ke(`/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()),ke(`/printers/${t}/slots/${e}/${n}/configure?${i}`,{method:"POST"})},resetAmsSlot:(t,e,n)=>ke(`/printers/${t}/ams/${e}/tray/${n}/reset`,{method:"POST"}),listFilaments:()=>ke("/filaments/"),getFilament:t=>ke(`/filaments/${t}`),getFilamentsByType:t=>ke(`/filaments/by-type/${t}`),getNotificationProviders:()=>ke("/notifications/"),getNotificationProvider:t=>ke(`/notifications/${t}`),createNotificationProvider:t=>ke("/notifications/",{method:"POST",body:JSON.stringify(t)}),updateNotificationProvider:(t,e)=>ke(`/notifications/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteNotificationProvider:t=>ke(`/notifications/${t}`,{method:"DELETE"}),testNotificationProvider:t=>ke(`/notifications/${t}/test`,{method:"POST"}),testNotificationConfig:t=>ke("/notifications/test-config",{method:"POST",body:JSON.stringify(t)}),testAllNotificationProviders:()=>ke("/notifications/test-all",{method:"POST"}),getNotificationTemplates:()=>ke("/notification-templates"),getNotificationTemplate:t=>ke(`/notification-templates/${t}`),updateNotificationTemplate:(t,e)=>ke(`/notification-templates/${t}`,{method:"PUT",body:JSON.stringify(e)}),resetNotificationTemplate:t=>ke(`/notification-templates/${t}/reset`,{method:"POST"}),getTemplateVariables:()=>ke("/notification-templates/variables"),previewTemplate:t=>ke("/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)),ke(`/notifications/logs?${e}`)},getNotificationLogStats:(t=7)=>ke(`/notifications/logs/stats?days=${t}`),clearNotificationLogs:(t=30)=>ke(`/notifications/logs?older_than_days=${t}`,{method:"DELETE"}),getSpoolmanStatus:()=>ke("/spoolman/status"),connectSpoolman:()=>ke("/spoolman/connect",{method:"POST"}),disconnectSpoolman:()=>ke("/spoolman/disconnect",{method:"POST"}),syncPrinterAms:t=>ke(`/spoolman/sync/${t}`,{method:"POST"}),syncAllPrintersAms:()=>ke("/spoolman/sync-all",{method:"POST"}),getSpoolmanSpools:()=>ke("/spoolman/spools"),getSpoolmanFilaments:()=>ke("/spoolman/filaments"),getUnlinkedSpools:()=>ke("/spoolman/spools/unlinked"),linkSpool:(t,e)=>ke(`/spoolman/spools/${t}/link`,{method:"POST",body:JSON.stringify({tray_uuid:e})}),getVersion:()=>ke("/updates/version"),checkForUpdates:()=>ke("/updates/check"),applyUpdate:()=>ke("/updates/apply",{method:"POST"}),getUpdateStatus:()=>ke("/updates/status"),getMaintenanceTypes:()=>ke("/maintenance/types"),createMaintenanceType:t=>ke("/maintenance/types",{method:"POST",body:JSON.stringify(t)}),updateMaintenanceType:(t,e)=>ke(`/maintenance/types/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteMaintenanceType:t=>ke(`/maintenance/types/${t}`,{method:"DELETE"}),getMaintenanceOverview:()=>ke("/maintenance/overview"),getPrinterMaintenance:t=>ke(`/maintenance/printers/${t}`),updateMaintenanceItem:(t,e)=>ke(`/maintenance/items/${t}`,{method:"PATCH",body:JSON.stringify(e)}),performMaintenance:(t,e)=>ke(`/maintenance/items/${t}/perform`,{method:"POST",body:JSON.stringify({notes:e})}),getMaintenanceHistory:t=>ke(`/maintenance/items/${t}/history`),getMaintenanceSummary:()=>ke("/maintenance/summary"),setPrinterHours:(t,e)=>ke(`/maintenance/printers/${t}/hours?total_hours=${e}`,{method:"PATCH"}),assignMaintenanceType:(t,e)=>ke(`/maintenance/printers/${t}/assign/${e}`,{method:"POST"}),removeMaintenanceItem:t=>ke(`/maintenance/items/${t}`,{method:"DELETE"}),getCameraStreamUrl:(t,e=10)=>`${xn}/printers/${t}/camera/stream?fps=${e}`,getCameraSnapshotUrl:t=>`${xn}/printers/${t}/camera/snapshot`,testCameraConnection:t=>ke(`/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)),ke(`/printers/${t}/camera/check-plate?${n.toString()}`)},getPlateDetectionStatus:t=>ke(`/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)),ke(`/printers/${t}/camera/plate-detection/calibrate?${n.toString()}`,{method:"POST"})},deletePlateCalibration:t=>ke(`/printers/${t}/camera/plate-detection/calibrate`,{method:"DELETE"}),getPlateReferences:t=>ke(`/printers/${t}/camera/plate-detection/references`),getPlateReferenceThumbnailUrl:(t,e)=>`${xn}/printers/${t}/camera/plate-detection/references/${e}/thumbnail`,updatePlateReferenceLabel:(t,e,n)=>{const r=new URLSearchParams;return r.set("label",n),ke(`/printers/${t}/camera/plate-detection/references/${e}?${r.toString()}`,{method:"PUT"})},deletePlateReference:(t,e)=>ke(`/printers/${t}/camera/plate-detection/references/${e}`,{method:"DELETE"}),getExternalLinks:()=>ke("/external-links/"),getExternalLink:t=>ke(`/external-links/${t}`),createExternalLink:t=>ke("/external-links/",{method:"POST",body:JSON.stringify(t)}),updateExternalLink:(t,e)=>ke(`/external-links/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteExternalLink:t=>ke(`/external-links/${t}`,{method:"DELETE"}),reorderExternalLinks:t=>ke("/external-links/reorder",{method:"PUT",body:JSON.stringify({ids:t})}),uploadExternalLinkIcon:async(t,e)=>{const n=new FormData;n.append("file",e);const r=await fetch(`${xn}/external-links/${t}/icon`,{method:"POST",body:n});if(!r.ok){const i=await r.json().catch(()=>({}));throw new Error(i.detail||`HTTP ${r.status}`)}return r.json()},deleteExternalLinkIcon:t=>ke(`/external-links/${t}/icon`,{method:"DELETE"}),getExternalLinkIconUrl:t=>`${xn}/external-links/${t}/icon`,getProjects:t=>{const e=new URLSearchParams;return t&&e.set("status",t),ke(`/projects/?${e}`)},getProject:t=>ke(`/projects/${t}`),createProject:t=>ke("/projects/",{method:"POST",body:JSON.stringify(t)}),updateProject:(t,e)=>ke(`/projects/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteProject:t=>ke(`/projects/${t}`,{method:"DELETE"}),getProjectArchives:(t,e=100,n=0)=>ke(`/projects/${t}/archives?limit=${e}&offset=${n}`),addArchivesToProject:(t,e)=>ke(`/projects/${t}/add-archives`,{method:"POST",body:JSON.stringify({archive_ids:e})}),removeArchivesFromProject:(t,e)=>ke(`/projects/${t}/remove-archives`,{method:"POST",body:JSON.stringify({archive_ids:e})}),addQueueItemsToProject:(t,e)=>ke(`/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=await fetch(`${xn}/projects/${t}/attachments`,{method:"POST",body:n});if(!r.ok){const i=await r.json().catch(()=>({}));throw new Error(i.detail||`HTTP ${r.status}`)}return r.json()},getProjectAttachmentUrl:(t,e)=>`${xn}/projects/${t}/attachments/${encodeURIComponent(e)}`,deleteProjectAttachment:(t,e)=>ke(`/projects/${t}/attachments/${encodeURIComponent(e)}`,{method:"DELETE"}),getProjectBOM:t=>ke(`/projects/${t}/bom`),createBOMItem:(t,e)=>ke(`/projects/${t}/bom`,{method:"POST",body:JSON.stringify(e)}),updateBOMItem:(t,e,n)=>ke(`/projects/${t}/bom/${e}`,{method:"PATCH",body:JSON.stringify(n)}),deleteBOMItem:(t,e)=>ke(`/projects/${t}/bom/${e}`,{method:"DELETE"}),getTemplates:()=>ke("/projects/templates/"),createTemplateFromProject:t=>ke(`/projects/${t}/create-template`,{method:"POST"}),createProjectFromTemplate:(t,e)=>ke(`/projects/from-template/${t}${e?`?name=${encodeURIComponent(e)}`:""}`,{method:"POST"}),getProjectTimeline:(t,e=50)=>ke(`/projects/${t}/timeline?limit=${e}`),exportProjectJson:t=>ke(`/projects/${t}/export?format=json`),importProject:t=>ke("/projects/import",{method:"POST",body:JSON.stringify(t)}),getAPIKeys:()=>ke("/api-keys/"),createAPIKey:t=>ke("/api-keys/",{method:"POST",body:JSON.stringify(t)}),updateAPIKey:(t,e)=>ke(`/api-keys/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteAPIKey:t=>ke(`/api-keys/${t}`,{method:"DELETE"}),getAMSHistory:(t,e,n=24)=>ke(`/ams-history/${t}/${e}?hours=${n}`),getSystemInfo:()=>ke("/system/info"),getLibraryFolders:()=>ke("/library/folders"),createLibraryFolder:t=>ke("/library/folders",{method:"POST",body:JSON.stringify(t)}),updateLibraryFolder:(t,e)=>ke(`/library/folders/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteLibraryFolder:t=>ke(`/library/folders/${t}`,{method:"DELETE"}),getLibraryFoldersByProject:t=>ke(`/library/folders/by-project/${t}`),getLibraryFoldersByArchive:t=>ke(`/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)),ke(`/library/files?${n}`)},getLibraryFile:t=>ke(`/library/files/${t}`),uploadLibraryFile:async(t,e)=>{const n=new FormData;n.append("file",t);const r=e?`?folder_id=${e}`:"",i=await fetch(`${xn}/library/files${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()},extractZipFile:async(t,e,n=!0,r=!1)=>{const i=new FormData;i.append("file",t);const a=new URLSearchParams;e&&a.set("folder_id",String(e)),a.set("preserve_structure",String(n)),a.set("create_folder_from_zip",String(r));const o=await fetch(`${xn}/library/files/extract-zip?${a}`,{method:"POST",body:i});if(!o.ok){const l=await o.json().catch(()=>({}));throw new Error(l.detail||`HTTP ${o.status}`)}return o.json()},updateLibraryFile:(t,e)=>ke(`/library/files/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteLibraryFile:t=>ke(`/library/files/${t}`,{method:"DELETE"}),getLibraryFileDownloadUrl:t=>`${xn}/library/files/${t}/download`,getLibraryFileThumbnailUrl:t=>`${xn}/library/files/${t}/thumbnail`,getLibraryFileGcodeUrl:t=>`${xn}/library/files/${t}/gcode`,moveLibraryFiles:(t,e)=>ke("/library/files/move",{method:"POST",body:JSON.stringify({file_ids:t,folder_id:e})}),bulkDeleteLibrary:(t,e)=>ke("/library/bulk-delete",{method:"POST",body:JSON.stringify({file_ids:t,folder_ids:e})}),getLibraryStats:()=>ke("/library/stats"),addLibraryFilesToQueue:t=>ke("/library/files/add-to-queue",{method:"POST",body:JSON.stringify({file_ids:t})}),printLibraryFile:(t,e,n)=>ke(`/library/files/${t}/print?printer_id=${e}`,{method:"POST",body:n?JSON.stringify(n):void 0}),getLibraryFilePlates:t=>ke(`/library/files/${t}/plates`),getLibraryFileFilamentRequirements:(t,e)=>ke(`/library/files/${t}/filament-requirements${e!==void 0?`?plate_id=${e}`:""}`),getGitHubBackupConfig:()=>ke("/github-backup/config"),saveGitHubBackupConfig:t=>ke("/github-backup/config",{method:"POST",body:JSON.stringify(t)}),updateGitHubBackupConfig:t=>ke("/github-backup/config",{method:"PATCH",body:JSON.stringify(t)}),deleteGitHubBackupConfig:()=>ke("/github-backup/config",{method:"DELETE"}),testGitHubConnection:(t,e)=>ke(`/github-backup/test?repo_url=${encodeURIComponent(t)}&token=${encodeURIComponent(e)}`,{method:"POST"}),testGitHubStoredConnection:()=>ke("/github-backup/test-stored",{method:"POST"}),triggerGitHubBackup:()=>ke("/github-backup/run",{method:"POST"}),getGitHubBackupStatus:()=>ke("/github-backup/status"),getGitHubBackupLogs:(t=50)=>ke(`/github-backup/logs?limit=${t}`),clearGitHubBackupLogs:(t=10)=>ke(`/github-backup/logs?keep_last=${t}`,{method:"DELETE"})},vl={getInfo:()=>ke("/discovery/info"),getStatus:()=>ke("/discovery/status"),startDiscovery:(t=10)=>ke(`/discovery/start?duration=${t}`,{method:"POST"}),stopDiscovery:()=>ke("/discovery/stop",{method:"POST"}),getDiscoveredPrinters:()=>ke("/discovery/printers"),startSubnetScan:(t,e=1)=>ke("/discovery/scan",{method:"POST",body:JSON.stringify({subnet:t,timeout:e})}),getScanStatus:()=>ke("/discovery/scan/status"),stopSubnetScan:()=>ke("/discovery/scan/stop",{method:"POST"})},z1={getSettings:()=>ke("/settings/virtual-printer"),getModels:()=>ke("/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),ke(`/settings/virtual-printer?${e.toString()}`,{method:"PUT"})}},Ap={list:()=>ke("/pending-uploads/"),getCount:()=>ke("/pending-uploads/count"),get:t=>ke(`/pending-uploads/${t}`),archive:(t,e)=>ke(`/pending-uploads/${t}/archive`,{method:"POST",body:JSON.stringify(e||{})}),discard:t=>ke(`/pending-uploads/${t}`,{method:"DELETE"}),archiveAll:()=>ke("/pending-uploads/archive-all",{method:"POST"}),discardAll:()=>ke("/pending-uploads/discard-all",{method:"DELETE"})},B1={checkUpdates:()=>ke("/firmware/updates"),checkPrinterUpdate:t=>ke(`/firmware/updates/${t}`),prepareUpload:t=>ke(`/firmware/updates/${t}/prepare`),startUpload:t=>ke(`/firmware/updates/${t}/upload`,{method:"POST"}),getUploadStatus:t=>ke(`/firmware/updates/${t}/upload/status`)},Vp={getDebugLoggingState:()=>ke("/support/debug-logging"),setDebugLogging:t=>ke("/support/debug-logging",{method:"POST",body:JSON.stringify({enabled:t})}),downloadSupportBundle:async()=>{const t=await fetch(`${xn}/support/bundle`);if(!t.ok){const l=await t.json().catch(()=>({}));throw new Error(l.detail||`HTTP ${t.status}`)}const n=t.headers.get("Content-Disposition")?.match(/filename=(.+)/),r=n?n[1]:"bambuddy-support.zip",i=await t.blob(),a=window.URL.createObjectURL(i),o=document.createElement("a");o.href=a,o.download=r,document.body.appendChild(o),o.click(),document.body.removeChild(o),window.URL.revokeObjectURL(a)},getLogs:t=>{const e=new URLSearchParams;t?.limit&&e.set("limit",t.limit.toString()),t?.level&&e.set("level",t.level),t?.search&&e.set("search",t.search);const n=e.toString();return ke(`/support/logs${n?`?${n}`:""}`)},clearLogs:()=>ke("/support/logs",{method:"DELETE"})},xq=w.createContext(void 0);function xfe({children:t}){const[e,n]=w.useState(()=>{const A=localStorage.getItem("theme-mode"),O=localStorage.getItem("theme");return A||O||"dark"}),[r,i]=w.useState(()=>localStorage.getItem("dark-style")||"classic"),[a,o]=w.useState(()=>localStorage.getItem("dark-background")||"neutral"),[l,c]=w.useState(()=>localStorage.getItem("dark-accent")||"green"),[u,d]=w.useState(()=>localStorage.getItem("light-style")||"classic"),[f,m]=w.useState(()=>localStorage.getItem("light-background")||"neutral"),[p,x]=w.useState(()=>localStorage.getItem("light-accent")||"green");w.useEffect(()=>{he.getSettings().then(A=>{A.dark_style&&(i(A.dark_style),localStorage.setItem("dark-style",A.dark_style)),A.dark_background&&(o(A.dark_background),localStorage.setItem("dark-background",A.dark_background)),A.dark_accent&&(c(A.dark_accent),localStorage.setItem("dark-accent",A.dark_accent)),A.light_style&&(d(A.light_style),localStorage.setItem("light-style",A.light_style)),A.light_background&&(m(A.light_background),localStorage.setItem("light-background",A.light_background)),A.light_accent&&(x(A.light_accent),localStorage.setItem("light-accent",A.light_accent))}).catch(()=>{})},[]),w.useEffect(()=>{const A=document.documentElement;A.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"?(A.classList.add("dark"),A.classList.add(`style-${r}`),A.classList.add(`bg-${a}`),A.classList.add(`accent-${l}`)):(A.classList.add(`style-${u}`),A.classList.add(`bg-${f}`),A.classList.add(`accent-${p}`)),localStorage.setItem("theme-mode",e),localStorage.removeItem("theme")},[e,r,a,l,u,f,p]);const y=()=>n(A=>A==="dark"?"light":"dark"),b=A=>n(A),v=A=>{i(A),localStorage.setItem("dark-style",A),he.updateSettings({dark_style:A}).catch(()=>{})},N=A=>{o(A),localStorage.setItem("dark-background",A),he.updateSettings({dark_background:A}).catch(()=>{})},S=A=>{c(A),localStorage.setItem("dark-accent",A),he.updateSettings({dark_accent:A}).catch(()=>{})},T=A=>{d(A),localStorage.setItem("light-style",A),he.updateSettings({light_style:A}).catch(()=>{})},E=A=>{m(A),localStorage.setItem("light-background",A),he.updateSettings({light_background:A}).catch(()=>{})},C=A=>{x(A),localStorage.setItem("light-accent",A),he.updateSettings({light_accent:A}).catch(()=>{})};return s.jsx(xq.Provider,{value:{mode:e,darkStyle:r,darkBackground:a,darkAccent:l,lightStyle:u,lightBackground:f,lightAccent:p,toggleMode:y,setMode:b,setDarkStyle:v,setDarkBackground:N,setDarkAccent:S,setLightStyle:T,setLightBackground:E,setLightAccent:C},children:t})}function nh(){const t=w.useContext(xq);if(!t)throw new Error("useTheme must be used within ThemeProvider");return t}function Nt({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 Qn({children:t,className:e=""}){return s.jsx("div",{className:`px-6 py-4 border-b border-bambu-dark-tertiary ${e}`,children:t})}function Et({children:t,className:e=""}){return s.jsx("div",{className:`p-6 ${e}`,children:t})}function bfe(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 wz({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 yfe({onClose:t,navItems:e,sidebarItems:n}){const{t:r}=Og(),i=bfe(n,e,r);return w.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(Nt,{className:"w-full max-w-md",onClick:a=>a.stopPropagation(),children:s.jsxs(Et,{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(qj,{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(zt,{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(Ur,{className:"w-3 h-3 text-bambu-gray"})]}),s.jsx("div",{className:"flex gap-1",children:o.keys.map(l=>s.jsx(wz,{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(wz,{children:"Esc"})," or click outside to close"]})})]})})})}function we({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 Bn({title:t,message:e,confirmText:n="Confirm",cancelText:r="Cancel",variant:i="default",isLoading:a=!1,loadingText:o,onConfirm:l,onCancel:c}){w.useEffect(()=>{const f=m=>{m.key==="Escape"&&!a&&c()};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[c,a]);const d={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(Nt,{className:"w-full max-w-md",onClick:f=>f.stopPropagation(),children:s.jsxs(Et,{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 ${d.icon}`,children:s.jsx(yn,{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(we,{variant:"secondary",onClick:c,className:"flex-1",disabled:a,children:r}),s.jsx(we,{onClick:l,className:`flex-1 ${d.button}`,disabled:a,children:a?s.jsxs(s.Fragment,{children:[s.jsx(dt,{className:"w-4 h-4 mr-2 animate-spin"}),o||"Processing..."]}):n})]})]})})})}function vfe({plug:t}){const e=on(),[n,r]=w.useState(null),{data:i,isLoading:a}=ut({queryKey:["smart-plug-status",t.id],queryFn:()=>he.getSmartPlugStatus(t.id),refetchInterval:1e4}),o=pt({mutationFn:f=>he.controlSmartPlug(t.id,f),onSuccess:()=>{e.invalidateQueries({queryKey:["smart-plug-status",t.id]})}}),l=i?.state==="ON",c=i?.reachable??!1,u=o.isPending,d=()=>{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 ${c?l?"bg-bambu-green/20":"bg-bambu-dark":"bg-red-500/20"}`,children:s.jsx(Vs,{className:`w-4 h-4 ${c?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(dt,{className:"w-3 h-3 text-bambu-gray animate-spin"}):c?s.jsxs(s.Fragment,{children:[s.jsx(Hp,{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(Pf,{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(zg,{className:"w-3 h-3 text-status-error"}),s.jsx("span",{className:"text-status-error",children:"Offline"})]})})]})]}),s.jsxs("div",{className:"flex gap-1",children:[s.jsx("button",{onClick:()=>r("on"),disabled:!c||u,className:`p-1.5 rounded transition-colors ${l?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"} disabled:opacity-50 disabled:cursor-not-allowed`,title:"Turn On",children:u?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(gu,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>r("off"),disabled:!c||u,className:`p-1.5 rounded transition-colors ${!l&&c?"bg-bambu-dark-tertiary text-white":"bg-bambu-dark text-bambu-gray hover:text-white"} disabled:opacity-50 disabled:cursor-not-allowed`,title:"Turn Off",children:u?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(H2,{className:"w-4 h-4"})})]})]}),n&&s.jsx(Bn,{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:d,onCancel:()=>r(null)})]})}function Sz({onClose:t}){const{data:e,isLoading:n}=ut({queryKey:["smart-plugs"],queryFn:he.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(Vs,{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(dt,{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(Vs,{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(vfe,{plug:i},i.id))})})]})}const bq=[{name:"globe",icon:jd},{name:"link",icon:Ug},{name:"external-link",icon:Ur},{name:"book",icon:yce},{name:"file-text",icon:Ga},{name:"home",icon:U2},{name:"star",icon:jf},{name:"heart",icon:nde},{name:"bookmark",icon:_ce},{name:"shopping-cart",icon:dq},{name:"music",icon:Qj},{name:"video",icon:pD},{name:"image",icon:ay},{name:"camera",icon:Tf},{name:"map",icon:Ade},{name:"compass",icon:sue},{name:"coffee",icon:nue},{name:"gift",icon:Vue},{name:"wrench",icon:$d},{name:"zap",icon:Pf},{name:"cloud",icon:R2},{name:"database",icon:Qc},{name:"folder",icon:iq},{name:"mail",icon:Ede},{name:"phone",icon:Zde},{name:"user",icon:e3},{name:"users",icon:_d},{name:"server",icon:zh},{name:"terminal",icon:mq},{name:"code",icon:nq}];function W2(t){return bq.find(n=>n.name===t)?.icon||Ug}function _fe({value:t,onChange:e}){const[n,r]=w.useState(!1),i=W2(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:bq.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 Nz=768;function yq(){const[t,e]=w.useState(()=>typeof window<"u"?window.innerWidth<Nz:!1);return w.useEffect(()=>{const n=window.matchMedia(`(max-width: ${Nz-1}px)`),r=i=>{e(i.matches)};return e(n.matches),n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[]),t}const vq=w.createContext(void 0);function wfe({children:t}){const[e,n]=w.useState(null),[r,i]=w.useState(!1),[a,o]=w.useState(!1),[l,c]=w.useState(!0),u=w.useRef(!1),d=w.useRef(!0),f=async()=>{try{const b=await he.getAuthStatus();if(!d.current)return;if(i(b.auth_enabled),o(b.requires_setup),b.auth_enabled)if(_z())try{const N=await he.getCurrentUser();if(!d.current)return;n(N)}catch{if(Nb(null),!d.current)return;n(null)}else n(null);else n(null)}catch{if(!d.current)return;i(!1),n(null)}finally{d.current&&c(!1)}};w.useEffect(()=>(d.current=!0,f(),()=>{d.current=!1}),[]),w.useEffect(()=>{if(!l&&a&&!r){const b=window.location.pathname;b!=="/setup"&&!b.startsWith("/camera/")&&!u.current&&(u.current=!0,window.location.href="/setup")}else a||(u.current=!1)},[l,a,r]);const m=async(b,v)=>{const N=await he.login({username:b,password:v});Nb(N.access_token),n(N.user)},p=()=>{Nb(null),n(null),he.logout().catch(()=>{}),window.location.href="/login"},x=async()=>{if(r&&_z())try{const b=await he.getCurrentUser();d.current&&n(b)}catch{Nb(null),d.current&&n(null)}},y=async()=>{await f()};return s.jsx(vq.Provider,{value:{user:e,authEnabled:r,requiresSetup:a,loading:l,login:m,logout:p,refreshUser:x,refreshAuth:y},children:t})}function rh(){const t=w.useContext(vq);if(t===void 0)throw new Error("useAuth must be used within an AuthProvider");return t}const g0=[{id:"printers",to:"/",icon:Mr,labelKey:"nav.printers"},{id:"archives",to:"/archives",icon:Ka,labelKey:"nav.archives"},{id:"queue",to:"/queue",icon:ri,labelKey:"nav.queue"},{id:"stats",to:"/stats",icon:Dce,labelKey:"nav.stats"},{id:"profiles",to:"/profiles",icon:R2,labelKey:"nav.profiles"},{id:"maintenance",to:"/maintenance",icon:$d,labelKey:"nav.maintenance"},{id:"projects",to:"/projects",icon:wa,labelKey:"nav.projects"},{id:"files",to:"/files",icon:ll,labelKey:"nav.files"},{id:"settings",to:"/settings",icon:V2,labelKey:"nav.settings"}];function Sfe(){const t=localStorage.getItem("sidebarOrder");if(t)try{return JSON.parse(t)}catch{return g0.map(e=>e.id)}return g0.map(e=>e.id)}function Nfe(t){localStorage.setItem("sidebarOrder",JSON.stringify(t))}function IT(t){return t.startsWith("ext-")}function _q(){return localStorage.getItem("defaultView")||"/"}function Mfe(t){localStorage.setItem("defaultView",t)}function Efe(){const t=hl(),e=Yl(),{mode:n,toggleMode:r}=nh(),{t:i}=Og(),a=yq(),{user:o,authEnabled:l,logout:c}=rh(),[u,d]=w.useState(()=>localStorage.getItem("sidebarExpanded")!=="false"),[f,m]=w.useState(!1),[p,x]=w.useState(!1),[y,b]=w.useState(!1),[v,N]=w.useState(Sfe),[S,T]=w.useState(null),[E,C]=w.useState(null),A=w.useRef(!1),[O,k]=w.useState(()=>sessionStorage.getItem("dismissedUpdateVersion")),[R,F]=w.useState(null),{data:L}=ut({queryKey:["version"],queryFn:he.getVersion,staleTime:1/0}),{data:K}=ut({queryKey:["settings"],queryFn:he.getSettings,staleTime:300*1e3}),{data:j}=ut({queryKey:["updateCheck"],queryFn:he.checkForUpdates,enabled:K?.check_updates!==!1,staleTime:3600*1e3,refetchInterval:3600*1e3}),{data:W}=ut({queryKey:["external-links"],queryFn:he.getExternalLinks}),{data:Y}=ut({queryKey:["smart-plugs"],queryFn:he.getSmartPlugs,staleTime:30*1e3}),q=Y?.some(X=>X.show_in_switchbar)??!1,{data:Q}=ut({queryKey:["debugLogging"],queryFn:Vp.getDebugLoggingState,staleTime:60*1e3,refetchInterval:60*1e3}),{data:ee}=ut({queryKey:["queue","pending"],queryFn:()=>he.getQueue(void 0,"pending"),staleTime:5*1e3,refetchInterval:5*1e3,refetchOnWindowFocus:!0}),re=ee?.length??0,{data:z}=ut({queryKey:["pending-uploads","count"],queryFn:Ap.getCount,staleTime:5*1e3,refetchInterval:5*1e3,refetchOnWindowFocus:!0}),G=z?.count??0,[ae,se]=w.useState(null);w.useEffect(()=>{if(!Q?.enabled||!Q.enabled_at){se(null);return}const X=new Date(Q.enabled_at).getTime(),U=()=>{se(Math.floor((Date.now()-X)/1e3))};U();const B=setInterval(U,1e3);return()=>clearInterval(B)},[Q?.enabled,Q?.enabled_at]);const ue=w.useMemo(()=>new Map(g0.map(X=>[X.id,X])),[]),pe=w.useMemo(()=>new Map((W||[]).map(X=>[`ext-${X.id}`,X])),[W]),ce=(()=>{const X=[],U=new Set,B=l&&o?.role==="user";for(const oe of v)B&&oe==="settings"||(ue.has(oe)||pe.has(oe))&&(X.push(oe),U.add(oe));for(const oe of g0)B&&oe.id==="settings"||U.has(oe.id)||(X.push(oe.id),U.add(oe.id));for(const oe of W||[]){const Te=`ext-${oe.id}`;U.has(Te)||(X.push(Te),U.add(Te))}return X})(),Me=(X,U)=>{T(U),X.dataTransfer.effectAllowed="move",X.dataTransfer.setData("text/plain",U)},me=(X,U)=>{X.preventDefault(),X.dataTransfer.dropEffect="move",C(U)},Ee=()=>{C(null)},fe=(X,U)=>{if(X.preventDefault(),S===null||S===U){T(null),C(null);return}const B=[...ce],oe=B.indexOf(S),Te=B.indexOf(U);if(oe===-1||Te===-1){T(null),C(null);return}B.splice(oe,1),B.splice(Te,0,S),N(B),Nfe(B),T(null),C(null)},le=()=>{T(null),C(null)},Be=j?.update_available&&j.latest_version&&j.latest_version!==O,V=()=>{j?.latest_version&&(sessionStorage.setItem("dismissedUpdateVersion",j.latest_version),k(j.latest_version))};w.useEffect(()=>{if(!A.current&&e.pathname==="/"){const X=_q();X!=="/"&&(A.current=!0,t(X,{replace:!0}))}},[e.pathname,t]),w.useEffect(()=>{localStorage.setItem("sidebarExpanded",String(u))},[u]),w.useEffect(()=>{a&&m(!1)},[e.pathname,a]),w.useEffect(()=>{const X=U=>{const B=U.detail;F({printer_id:B.printer_id,printer_name:B.printer_name,message:B.message})};return window.addEventListener("plate-not-empty",X),()=>window.removeEventListener("plate-not-empty",X)},[]);const $=w.useCallback(X=>{const U=X.target;if(!(U.tagName==="INPUT"||U.tagName==="TEXTAREA"||U.isContentEditable)&&!X.metaKey&&!X.ctrlKey&&!X.altKey){const B=parseInt(X.key);if(B>=1&&B<=ce.length&&B<=9){const oe=ce[B-1];if(X.preventDefault(),IT(oe)){const Te=oe.replace("ext-","");t(`/external/${Te}`)}else{const Te=ue.get(oe);Te&&t(Te.to)}return}switch(X.key){case"?":X.preventDefault(),x(!0);break;case"Escape":x(!1);break}}},[t,ce,ue]);return w.useEffect(()=>(document.addEventListener("keydown",$),()=>document.removeEventListener("keydown",$)),[$]),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:()=>m(!0),className:"p-2 -ml-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors","aria-label":"Open menu",children:s.jsx(Ode,{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&&f&&s.jsx("div",{className:"fixed inset-0 bg-black/60 z-40 transition-opacity",onClick:()=>m(!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 ${f?"translate-x-0":"-translate-x-full"}`:`fixed inset-y-0 left-0 z-30 ${u?"w-64":"w-16"}`}`,children:[s.jsx("div",{className:`border-b border-bambu-dark-tertiary flex items-center justify-center ${a||u?"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||u?"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:ce.map(X=>{if(IT(X)){const B=pe.get(X);if(!B)return null;const oe=B.custom_icon?null:W2(B.icon);return s.jsx("li",{draggable:!0,onDragStart:Te=>Me(Te,X),onDragOver:Te=>me(Te,X),onDragLeave:Ee,onDrop:Te=>fe(Te,X),onDragEnd:le,className:`relative ${S===X?"opacity-50":""} ${E===X&&S!==X?"before:absolute before:left-0 before:right-0 before:top-0 before:h-0.5 before:bg-bambu-green":""}`,children:s.jsxs(Sb,{to:`/external/${B.id}`,className:({isActive:Te})=>`flex items-center ${a||u?"gap-3 px-4":"justify-center px-2"} py-3 rounded-lg transition-colors group ${Te?"bg-bambu-green text-white":"text-bambu-gray-light hover:bg-bambu-dark-tertiary hover:text-white"}`,title:!a&&!u?B.name:void 0,children:[u&&!a&&s.jsx(ig,{className:"w-4 h-4 flex-shrink-0 opacity-0 group-hover:opacity-50 cursor-grab active:cursor-grabbing -ml-1"}),B.custom_icon?s.jsx("img",{src:`/api/v1/external-links/${B.id}/icon`,alt:"",className:`w-5 h-5 flex-shrink-0 ${n==="dark"?"invert opacity-[0.65]":"opacity-60"}`}):oe&&s.jsx(oe,{className:"w-5 h-5 flex-shrink-0"}),(a||u)&&s.jsx("span",{children:B.name})]})},X)}else{const B=ue.get(X);if(!B)return null;const{to:oe,icon:Te,labelKey:je}=B,Ce=X==="queue"&&re>0,H=X==="archives"&&G>0,D=Ce?re:H?G:0,Z=Ce||H;return s.jsx("li",{draggable:!0,onDragStart:xe=>Me(xe,X),onDragOver:xe=>me(xe,X),onDragLeave:Ee,onDrop:xe=>fe(xe,X),onDragEnd:le,className:`relative ${S===X?"opacity-50":""} ${E===X&&S!==X?"before:absolute before:left-0 before:right-0 before:top-0 before:h-0.5 before:bg-bambu-green":""}`,children:s.jsxs(Sb,{to:oe,className:({isActive:xe})=>`flex items-center ${a||u?"gap-3 px-4":"justify-center px-2"} py-3 rounded-lg transition-colors group ${xe?"bg-bambu-green text-white":"text-bambu-gray-light hover:bg-bambu-dark-tertiary hover:text-white"}`,title:!a&&!u?i(je):void 0,children:[u&&!a&&s.jsx(ig,{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(Te,{className:"w-5 h-5 flex-shrink-0"}),Z&&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 ${H?"bg-blue-500 text-white":"bg-yellow-500 text-black"}`,children:D>99?"99+":D})]}),(a||u)&&s.jsx("span",{children:i(je)})]})},X)}})})}),!a&&s.jsx("button",{onClick:()=>d(!u),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(u?"nav.collapseSidebar":"nav.expandSidebar"),children:u?s.jsx(Af,{className:"w-5 h-5"}):s.jsx(Ys,{className:"w-5 h-5"})}),s.jsx("div",{className:"p-2 border-t border-bambu-dark-tertiary",children:a||u?s.jsxs("div",{className:"flex flex-col gap-2 px-2",children:[s.jsxs("div",{className:"flex items-center justify-center gap-1",children:[q&&s.jsxs("div",{className:"relative",children:[s.jsx("button",{onMouseEnter:()=>b(!0),className:`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${y?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.smartSwitches",{defaultValue:"Smart Switches"}),children:s.jsx(Vs,{className:"w-5 h-5"})}),y&&s.jsx(Sz,{onClose:()=>b(!1)})]}),s.jsx(Sb,{to:"/system",className:({isActive:X})=>`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${X?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.system"),children:s.jsx(Ul,{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(Wj,{className:"w-5 h-5"})}),s.jsx("button",{onClick:()=>x(!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(qj,{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(vz,{className:"w-5 h-5"}):s.jsx(yw,{className:"w-5 h-5"})}),l&&o&&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(Xj,{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",L?.version||"..."]}),j?.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:j.latest_version}),children:[s.jsx(DT,{className:"w-4 h-4"}),s.jsx("span",{children:i("nav.update")})]})]})]}):s.jsxs("div",{className:"flex flex-col items-center gap-1",children:[j?.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:j.latest_version}),children:s.jsx(DT,{className:"w-5 h-5"})}),q&&s.jsxs("div",{className:"relative",children:[s.jsx("button",{onMouseEnter:()=>b(!0),className:`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${y?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.smartSwitches",{defaultValue:"Smart Switches"}),children:s.jsx(Vs,{className:"w-5 h-5"})}),y&&s.jsx(Sz,{onClose:()=>b(!1)})]}),s.jsx(Sb,{to:"/system",className:({isActive:X})=>`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${X?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.system"),children:s.jsx(Ul,{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(Wj,{className:"w-5 h-5"})}),s.jsx("button",{onClick:()=>x(!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(qj,{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(vz,{className:"w-5 h-5"}):s.jsx(yw,{className:"w-5 h-5"})}),l&&o&&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(Xj,{className:"w-5 h-5"})})]})})]}),s.jsxs("main",{className:`flex-1 bg-bambu-dark overflow-auto transition-all duration-300 ${a?"mt-14":u?"ml-64":"ml-16"}`,children:[Q?.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(j2,{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"}),ae!==null&&s.jsxs("span",{className:"text-amber-300/70 ml-2",children:["(",Math.floor(ae/60),"m ",ae%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"})})]})}),Be&&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(DT,{className:"w-4 h-4 text-bambu-green"}),s.jsx("span",{children:i("nav.updateAvailableBanner",{version:j?.latest_version,defaultValue:`Version ${j?.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:V,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:i("common.dismiss",{defaultValue:"Dismiss"}),children:s.jsx(zt,{className:"w-4 h-4"})})]}),s.jsx(zoe,{})]}),p&&s.jsx(yfe,{onClose:()=>x(!1),sidebarItems:ce.map(X=>{if(IT(X)){const U=pe.get(X);return U?{type:"external",label:U.name}:null}else{const U=ue.get(X);return U?{type:"nav",label:U.labelKey,labelKey:U.labelKey}:null}}).filter(Boolean)}),R&&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:"Print Paused!"}),s.jsx("p",{className:"text-lg text-white mb-2",children:R.printer_name}),s.jsx("p",{className:"text-bambu-gray mb-6",children:"Objects detected on build plate. The print has been automatically paused. Please clear the plate and resume the print."}),s.jsx("button",{onClick:()=>F(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 Understand"})]})})})]})}function zb(t,e="system"){return e==="12h"?t.hour12=!0:e==="24h"&&(t.hour12=!1),t}function vi(t){return t?t.endsWith("Z")||/[+-]\d{2}:\d{2}$/.test(t)?new Date(t):new Date(t+"Z"):null}function sg(t,e){const n=vi(t);if(!n)return"";const r={year:"numeric",month:"short",day:"numeric"};return n.toLocaleDateString(void 0,e??r)}function og(t,e="system",n){const r=vi(t);if(!r)return"";const a=zb(n??{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"},e);return r.toLocaleString(void 0,a)}function Tfe(t,e="system",n){const i=zb({...{hour:"2-digit",minute:"2-digit"},...n},e);return t.toLocaleTimeString([],i)}const wq=w.createContext(void 0);function Vn(){const t=w.useContext(wq);if(!t)throw new Error("useToast must be used within a ToastProvider");return t}const Afe={success:s.jsx(Fn,{className:"w-5 h-5 text-green-400"}),error:s.jsx(ta,{className:"w-5 h-5 text-red-400"}),warning:s.jsx(ji,{className:"w-5 h-5 text-yellow-400"}),info:s.jsx(Ul,{className:"w-5 h-5 text-blue-400"}),loading:s.jsx(dt,{className:"w-5 h-5 text-bambu-green animate-spin"})},Cfe={success:"bg-green-500/10 border-green-500/30",error:"bg-red-500/10 border-red-500/30",warning:"bg-yellow-500/10 border-yellow-500/30",info:"bg-blue-500/10 border-blue-500/30",loading:"bg-bambu-green/10 border-bambu-green/30"};function kfe({children:t}){const[e,n]=w.useState([]),r=w.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=w.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=w.useCallback(o=>{n(l=>l.filter(c=>c.id!==o))},[]);return s.jsxs(wq.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 ${Cfe[o.type]}`,children:[Afe[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(zt,{className:"w-4 h-4"})})]},o.id))})]})}function jfe(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 Mz(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 Pfe(t,e){if(e)return iq;switch(t.toLowerCase().split(".").pop()||""){case"3mf":return uf;case"gcode":return Ga;case"mp4":case"avi":return kd;case"png":case"jpg":case"jpeg":return ay;default:return O2}}const Rfe=[{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 Dfe({printerId:t,printerName:e,onClose:n}){const{showToast:r}=Vn(),i=on(),[a,o]=w.useState("/"),[l,c]=w.useState(new Set),[u,d]=w.useState(""),[f,m]=w.useState([]),[p,x]=w.useState("name-asc"),[y,b]=w.useState(null);w.useEffect(()=>{const j=W=>{W.key==="Escape"&&n()};return window.addEventListener("keydown",j),()=>window.removeEventListener("keydown",j)},[n]);const{data:v,isLoading:N,refetch:S}=ut({queryKey:["printerFiles",t,a],queryFn:()=>he.getPrinterFiles(t,a)}),{data:T}=ut({queryKey:["printerStorage",t],queryFn:()=>he.getPrinterStorage(t),staleTime:3e4}),E=pt({mutationFn:async j=>{for(const W of j)await he.deletePrinterFile(t,W)},onSuccess:()=>{r(`Deleted ${f.length} file${f.length>1?"s":""}`),i.invalidateQueries({queryKey:["printerFiles",t]}),c(new Set),m([])},onError:j=>{r(`Delete failed: ${j.message}`,"error")}}),C=j=>{o(j),c(new Set)},A=()=>{if(a==="/")return;const j=a.split("/").filter(Boolean);j.pop(),o(j.length?"/"+j.join("/"):"/"),c(new Set)},O=(j,W)=>{W.stopPropagation(),c(Y=>{const q=new Set(Y);return q.has(j)?q.delete(j):q.add(j),q})},k=()=>{if(!v?.files)return;const j=v.files.filter(W=>!W.is_directory&&(!u||W.name.toLowerCase().includes(u.toLowerCase()))).map(W=>W.path);c(new Set(j))},R=()=>{c(new Set)},F=async()=>{if(l.size===0)return;const j=Array.from(l);if(j.length===1){window.open(he.getPrinterFileDownloadUrl(t,j[0]),"_blank"),c(new Set);return}b({current:0,total:j.length});try{const W=await he.downloadPrinterFilesAsZip(t,j),Y=URL.createObjectURL(W),q=document.createElement("a");q.href=Y,q.download=`${e.replace(/[^a-zA-Z0-9]/g,"_")}-files.zip`,document.body.appendChild(q),q.click(),document.body.removeChild(q),URL.revokeObjectURL(Y),r(`Downloaded ${j.length} files as ZIP`),c(new Set)}catch(W){r(`Download failed: ${W instanceof Error?W.message:"Unknown error"}`,"error")}finally{b(null)}},L=()=>{l.size!==0&&m(Array.from(l))},K=[{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:j=>j.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(F2,{className:"w-5 h-5 text-bambu-green"}),s.jsxs("div",{children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:"File Manager"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:e})]})]}),s.jsxs("div",{className:"flex items-center gap-4",children:[T&&(T.used_bytes!=null||T.free_bytes!=null)&&s.jsxs("div",{className:"text-sm text-bambu-gray flex items-center gap-2",children:[T.used_bytes!=null&&s.jsxs("span",{children:["Used: ",Mz(T.used_bytes)]}),T.used_bytes!=null&&T.free_bytes!=null&&s.jsx("span",{className:"text-bambu-dark-tertiary",children:"|"}),T.free_bytes!=null&&s.jsxs("span",{children:["Free: ",Mz(T.free_bytes)]})]}),s.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(zt,{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:[K.map(j=>s.jsx("button",{onClick:()=>{C(j.path),d("")},className:`px-3 py-1 text-sm rounded-full transition-colors ${a===j.path?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,children:j.label},j.path)),s.jsx("div",{className:"flex-1"}),s.jsxs("div",{className:"relative",children:[s.jsx(_a,{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:"Filter files...",value:u,onChange:j=>d(j.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(eq,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("select",{value:p,onChange:j=>x(j.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:Rfe.map(j=>s.jsx("option",{value:j.value,children:j.label},j.value))})]}),s.jsx(we,{variant:"secondary",size:"sm",onClick:()=>S(),disabled:N,children:s.jsx(xr,{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:A,disabled:a==="/",className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-50 disabled:cursor-not-allowed",children:s.jsx(Af,{className:"w-4 h-4"})}),s.jsx("span",{className:"text-bambu-gray font-mono",children:a})]}),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(dt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):v?.files?.length?s.jsx("div",{className:"space-y-1",children:[...v.files].filter(j=>!u||j.name.toLowerCase().includes(u.toLowerCase())).sort((j,W)=>{if(j.is_directory&&!W.is_directory)return-1;if(!j.is_directory&&W.is_directory)return 1;switch(p){case"name-asc":return j.name.localeCompare(W.name);case"name-desc":return W.name.localeCompare(j.name);case"size-asc":return j.size-W.size;case"size-desc":return W.size-j.size;case"date-asc":{const Y=j.mtime?new Date(j.mtime).getTime():0,q=W.mtime?new Date(W.mtime).getTime():0;return Y-q}case"date-desc":{const Y=j.mtime?new Date(j.mtime).getTime():0;return(W.mtime?new Date(W.mtime).getTime():0)-Y}default:return j.name.localeCompare(W.name)}}).map(j=>{const W=Pfe(j.name,j.is_directory),Y=l.has(j.path);return s.jsxs("div",{className:`flex items-center gap-3 p-2 rounded-lg cursor-pointer transition-colors ${Y?"bg-bambu-green/20 border border-bambu-green/50":"hover:bg-bambu-dark-tertiary"}`,onClick:()=>{j.is_directory&&C(j.path)},children:[j.is_directory?null:s.jsx("button",{onClick:q=>O(j.path,q),className:"flex-shrink-0 text-bambu-gray hover:text-white",children:Y?s.jsx(Ro,{className:"w-5 h-5 text-bambu-green"}):s.jsx(Do,{className:"w-5 h-5"})}),s.jsx(W,{className:`w-5 h-5 flex-shrink-0 ${j.is_directory?"text-bambu-green":"text-bambu-gray"}`}),s.jsx("span",{className:"flex-1 text-white truncate",children:j.name}),!j.is_directory&&s.jsx("span",{className:"text-sm text-bambu-gray",children:jfe(j.size)}),j.is_directory&&s.jsx(Af,{className:"w-4 h-4 text-bambu-gray rotate-180"})]},j.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:l.size>0?`${l.size} selected`:u?`${v?.files?.filter(j=>j.name.toLowerCase().includes(u.toLowerCase())).length||0} of ${v?.files?.length||0} items`:`${v?.files?.length||0} items`}),v?.files?.some(j=>!j.is_directory)&&s.jsx("div",{className:"flex items-center gap-2",children:l.size>0?s.jsxs("button",{onClick:R,className:"flex items-center gap-1 text-xs text-bambu-gray hover:text-white transition-colors",children:[s.jsx(khe,{className:"w-4 h-4"}),"Deselect All"]}):s.jsxs("button",{onClick:k,className:"flex items-center gap-1 text-xs text-bambu-gray hover:text-white transition-colors",children:[s.jsx(Ro,{className:"w-4 h-4"}),"Select All"]})})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(we,{variant:"secondary",disabled:l.size===0||y!==null,onClick:F,children:y?s.jsxs(s.Fragment,{children:[s.jsx(dt,{className:"w-4 h-4 animate-spin"}),y.current,"/",y.total]}):s.jsxs(s.Fragment,{children:[s.jsx($r,{className:"w-4 h-4"}),"Download",l.size>1?` (${l.size})`:""]})}),s.jsxs(we,{variant:"secondary",disabled:l.size===0||E.isPending,onClick:L,className:"text-red-400 hover:text-red-300",children:[E.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(un,{className:"w-4 h-4"}),"Delete",l.size>1?` (${l.size})`:""]})]})]})]}),f.length>0&&s.jsx(Bn,{title:f.length>1?`Delete ${f.length} Files`:"Delete File",message:f.length>1?`Delete ${f.length} selected files? This cannot be undone.`:`Delete "${f[0].split("/").pop()}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{E.mutate(f)},onCancel:()=>m([])})]})}const Ofe="embeddedCameraState_",Ez=5,Lfe=2e3,Ife=3e4,Ffe=5e3,FT={x:window.innerWidth-420,y:20,width:400,height:300};function Ufe({printerId:t,printerName:e,viewerIndex:n=0,onClose:r}){const i=`${Ofe}${t}`,a=()=>{try{const te=localStorage.getItem(i);if(te){const Se=JSON.parse(te);return{x:Math.min(Math.max(0,Se.x),window.innerWidth-100),y:Math.min(Math.max(0,Se.y),window.innerHeight-100),width:Math.max(200,Math.min(Se.width,window.innerWidth-20)),height:Math.max(150,Math.min(Se.height,window.innerHeight-20))}}}catch{}const ie=n*30;return{...FT,x:Math.max(0,FT.x-ie),y:Math.max(0,FT.y+ie)}},[o,l]=w.useState(a),[c,u]=w.useState(!1),[d,f]=w.useState(!1),[m,p]=w.useState({x:0,y:0}),[x,y]=w.useState(!1),[b,v]=w.useState(!1),[N,S]=w.useState(1),[T,E]=w.useState({x:0,y:0}),[C,A]=w.useState(!1),[O,k]=w.useState({x:0,y:0}),[R,F]=w.useState(null),[L,K]=w.useState(null),[j,W]=w.useState(!1),[Y,q]=w.useState(!0),[Q,ee]=w.useState(Date.now()),[re,z]=w.useState(0),[G,ae]=w.useState(!1),[se,ue]=w.useState(0),pe=w.useRef(null),ce=w.useRef(null),Me=w.useRef(null),me=w.useRef(null),Ee=w.useRef(null),{data:fe}=ut({queryKey:["printer",t],queryFn:()=>he.getPrinter(t),enabled:t>0});w.useEffect(()=>{const ie=setTimeout(()=>{localStorage.setItem(i,JSON.stringify(o))},500);return()=>clearTimeout(ie)},[o,i]);const le=w.useRef(!1);w.useEffect(()=>{le.current=!1;const ie=`/api/v1/printers/${t}/camera/stop`,te=()=>{t>0&&!le.current&&(le.current=!0,navigator.sendBeacon(ie))},Se=ce.current;return()=>{Se&&(Se.src=""),te(),Me.current&&clearTimeout(Me.current),me.current&&clearInterval(me.current),Ee.current&&clearInterval(Ee.current)}},[t]),w.useEffect(()=>{if(Y){const ie=setTimeout(()=>q(!1),3e3);return()=>clearTimeout(ie)}},[Y,Q]);const Be=w.useCallback(()=>{if(re>=Ez){ae(!1),W(!0);return}const ie=Math.min(Lfe*Math.pow(2,re),Ife);ae(!0),ue(Math.ceil(ie/1e3)),me.current=setInterval(()=>{ue(te=>te<=1?(me.current&&clearInterval(me.current),0):te-1)},1e3),Me.current=setTimeout(()=>{z(te=>te+1),ae(!1),q(!0),W(!1),ce.current&&(ce.current.src=""),ee(Date.now())},ie)},[re]);w.useEffect(()=>{if(Y||G||x){Ee.current&&(clearInterval(Ee.current),Ee.current=null);return}return Ee.current=setInterval(async()=>{try{const ie=await fetch(`/api/v1/printers/${t}/camera/status`);if(ie.ok){const te=await ie.json();(te.stalled||!te.active&&!j)&&(Ee.current&&(clearInterval(Ee.current),Ee.current=null),q(!1),Be())}}catch{}},Ffe),()=>{Ee.current&&(clearInterval(Ee.current),Ee.current=null)}},[Y,j,G,x,t,Be]),w.useEffect(()=>{const ie=()=>{const te=!!document.fullscreenElement;v(te),te||(S(1),E({x:0,y:0}))};return document.addEventListener("fullscreenchange",ie),()=>document.removeEventListener("fullscreenchange",ie)},[]);const V=()=>{pe.current&&(document.fullscreenElement?document.exitFullscreen():pe.current.requestFullscreen())},$=()=>{S(ie=>Math.min(ie+.5,4))},X=()=>{S(ie=>{const te=Math.max(ie-.5,1);return te===1&&E({x:0,y:0}),te})},U=ie=>{ie.preventDefault(),ie.deltaY<0?$():X()},B=ie=>{N>1&&(ie.preventDefault(),A(!0),k({x:ie.clientX-T.x,y:ie.clientY-T.y}))},oe=w.useCallback(()=>{if(!pe.current||!ce.current)return{x:200,y:150};const ie=pe.current.getBoundingClientRect(),te=ie.width*(N-1)/2,Se=ie.height*(N-1)/2;return{x:Math.max(50,te),y:Math.max(50,Se)}},[N]),Te=ie=>{if(C&&N>1){const te=ie.clientX-O.x,Se=ie.clientY-O.y,ze=oe();E({x:Math.max(-ze.x,Math.min(ze.x,te)),y:Math.max(-ze.y,Math.min(ze.y,Se))})}},je=()=>{A(!1)},Ce=ie=>{if(ie.length<2)return 0;const te=ie[0].clientX-ie[1].clientX,Se=ie[0].clientY-ie[1].clientY;return Math.sqrt(te*te+Se*Se)},H=ie=>ie.length<2?{x:ie[0].clientX,y:ie[0].clientY}:{x:(ie[0].clientX+ie[1].clientX)/2,y:(ie[0].clientY+ie[1].clientY)/2},D=ie=>{ie.touches.length===2?(ie.preventDefault(),F(Ce(ie.touches)),K(H(ie.touches))):ie.touches.length===1&&N>1&&(ie.preventDefault(),A(!0),k({x:ie.touches[0].clientX-T.x,y:ie.touches[0].clientY-T.y}))},Z=ie=>{if(ie.touches.length===2&&R!==null){ie.preventDefault();const te=Ce(ie.touches),Se=te/R;S(nt=>{const ne=Math.max(1,Math.min(4,nt*Se));return ne===1&&E({x:0,y:0}),ne}),F(te);const ze=H(ie.touches);if(L){const nt=oe();E(ne=>({x:Math.max(-nt.x,Math.min(nt.x,ne.x+(ze.x-L.x))),y:Math.max(-nt.y,Math.min(nt.y,ne.y+(ze.y-L.y)))}))}K(ze)}else if(ie.touches.length===1&&C&&N>1){ie.preventDefault();const te=ie.touches[0].clientX-O.x,Se=ie.touches[0].clientY-O.y,ze=oe();E({x:Math.max(-ze.x,Math.min(ze.x,te)),y:Math.max(-ze.y,Math.min(ze.y,Se))})}},xe=ie=>{ie.touches.length<2&&(F(null),K(null)),ie.touches.length===0&&A(!1)},Ne=()=>{S(1),E({x:0,y:0})},ve=()=>{q(!1),re<Ez?Be():W(!0)},$e=()=>{q(!1),W(!1),z(0),ae(!1),Me.current&&clearTimeout(Me.current),me.current&&clearInterval(me.current)},Le=()=>{q(!0),W(!1),z(0),ae(!1),Me.current&&clearTimeout(Me.current),me.current&&clearInterval(me.current),fetch(`/api/v1/printers/${t}/camera/stop`).catch(()=>{}),ce.current&&(ce.current.src=""),setTimeout(()=>ee(Date.now()),100)},qe=ie=>{ie.target.closest(".no-drag")||(u(!0),p({x:ie.clientX-o.x,y:ie.clientY-o.y}))},Ke=ie=>{ie.stopPropagation(),f(!0)};w.useEffect(()=>{const ie=Se=>{if(c)l(ze=>({...ze,x:Math.max(0,Math.min(Se.clientX-m.x,window.innerWidth-ze.width)),y:Math.max(0,Math.min(Se.clientY-m.y,window.innerHeight-ze.height))}));else if(d&&pe.current){const ze=pe.current.getBoundingClientRect();l(nt=>({...nt,width:Math.max(200,Math.min(Se.clientX-ze.left,window.innerWidth-nt.x-10)),height:Math.max(150,Math.min(Se.clientY-ze.top,window.innerHeight-nt.y-10))}))}},te=()=>{u(!1),f(!1)};if(c||d)return document.addEventListener("mousemove",ie),document.addEventListener("mouseup",te),()=>{document.removeEventListener("mousemove",ie),document.removeEventListener("mouseup",te)}},[c,d,m]);const Ye=`/api/v1/printers/${t}/camera/stream?fps=10&t=${Q}`;return s.jsxs("div",{ref:pe,className:`${b?"fixed inset-0 z-[100]":"fixed z-50 rounded-lg shadow-2xl border border-bambu-dark-tertiary"} bg-bambu-dark-secondary overflow-hidden`,style:b?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:qe,children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm text-white truncate",children:[s.jsx(ig,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),s.jsx("span",{className:"truncate",children:fe?.name||e})]}),s.jsxs("div",{className:"flex items-center gap-1 no-drag",children:[s.jsx("button",{onClick:Le,disabled:Y||G,className:"p-1 hover:bg-bambu-dark-tertiary rounded disabled:opacity-50",title:"Refresh stream",children:s.jsx(xr,{className:`w-3.5 h-3.5 text-bambu-gray ${Y?"animate-spin":""}`})}),s.jsx("button",{onClick:V,className:"p-1 hover:bg-bambu-dark-tertiary rounded",title:b?"Exit fullscreen":"Fullscreen",children:b?s.jsx(cq,{className:"w-3.5 h-3.5 text-bambu-gray"}):s.jsx(zue,{className:"w-3.5 h-3.5 text-bambu-gray"})}),s.jsx("button",{onClick:()=>y(!x),className:"p-1 hover:bg-bambu-dark-tertiary rounded",title:x?"Expand":"Minimize",children:x?s.jsx(oq,{className:"w-3.5 h-3.5 text-bambu-gray"}):s.jsx(lq,{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(zt,{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:U,onMouseMove:Te,onMouseUp:je,onMouseLeave:je,onTouchStart:D,onTouchMove:Z,onTouchEnd:xe,style:{touchAction:"none"},children:[Y&&!G&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50 z-10",children:s.jsx(xr,{className:"w-6 h-6 text-bambu-gray animate-spin"})}),G&&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(zg,{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&&!G&&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(yn,{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:Le,className:"px-2 py-1 text-xs bg-bambu-green text-white rounded hover:bg-bambu-green/80",children:"Retry"})]})}),s.jsx("img",{ref:ce,src:Ye,alt:"Camera stream",className:"max-w-full max-h-full object-contain select-none",style:{transform:`scale(${N}) translate(${T.x/N}px, ${T.y/N}px)`,cursor:N>1?C?"grabbing":"grab":"default"},onError:ve,onLoad:$e,onMouseDown:B,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:X,disabled:N<=1,className:"p-1 hover:bg-white/10 rounded disabled:opacity-30",title:"Zoom out",children:s.jsx(xD,{className:"w-3.5 h-3.5 text-white"})}),s.jsxs("button",{onClick:Ne,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(N*100),"%"]}),s.jsx("button",{onClick:$,disabled:N>=4,className:"p-1 hover:bg-white/10 rounded disabled:opacity-30",title:"Zoom in",children:s.jsx(gD,{className:"w-3.5 h-3.5 text-white"})})]}),!b&&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:Ke,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 zfe({printerId:t,printerName:e,onClose:n}){const r=on(),[i,a]=w.useState(!0),[o,l]=w.useState(new Set),[c,u]=w.useState(""),[d,f]=w.useState("all"),m=w.useRef(null),{data:p,isLoading:x,refetch:y}=ut({queryKey:["mqtt-logs",t],queryFn:()=>he.getMQTTLogs(t),refetchInterval:1e3}),b=pt({mutationFn:()=>he.enableMQTTLogging(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}}),v=pt({mutationFn:()=>he.disableMQTTLogging(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}}),N=pt({mutationFn:()=>he.clearMQTTLogs(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}});w.useEffect(()=>{const k=R=>{R.key==="Escape"&&n()};return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[n]),w.useEffect(()=>{i&&m.current&&(m.current.scrollTop=m.current.scrollHeight)},[p?.logs,i]);const S=k=>{l(R=>{const F=new Set(R);return F.has(k)?F.delete(k):F.add(k),F})},T=k=>new Date(k).toLocaleTimeString("en-US",{hour12:!1,fractionalSecondDigits:3}),E=(k,R)=>{if(k==null)return"<empty>";const F=typeof k=="string"?JSON.parse(k):k,L=JSON.stringify(F,null,R?2:0);return!R&&L.length>100?L.substring(0,100)+"...":L},C=p?.logging_enabled??!1,A=w.useMemo(()=>p?.logs??[],[p?.logs]),O=w.useMemo(()=>A.filter(k=>{if(d!=="all"&&k.direction!==d)return!1;if(c.trim()){const R=c.toLowerCase(),F=k.topic.toLowerCase().includes(R),K=JSON.stringify(k.payload).toLowerCase().includes(R);return F||K}return!0}),[A,c,d]);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:"MQTT Debug Log"}),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(zt,{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:[C?s.jsxs(we,{size:"sm",variant:"secondary",onClick:()=>v.mutate(),disabled:v.isPending,children:[s.jsx(Do,{className:"w-4 h-4"}),"Stop"]}):s.jsxs(we,{size:"sm",onClick:()=>b.mutate(),disabled:b.isPending,children:[s.jsx(Po,{className:"w-4 h-4"}),"Start Logging"]}),s.jsxs(we,{size:"sm",variant:"secondary",onClick:()=>N.mutate(),disabled:N.isPending||A.length===0,children:[s.jsx(un,{className:"w-4 h-4"}),"Clear"]}),s.jsx(we,{size:"sm",variant:"secondary",onClick:()=>y(),disabled:x,children:s.jsx(xr,{className:`w-4 h-4 ${x?"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:i,onChange:k=>a(k.target.checked),className:"rounded border-bambu-dark-tertiary"}),"Auto-scroll"]}),s.jsxs("span",{className:"text-sm text-bambu-gray",children:[O.length,"/",A.length]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsx(_a,{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 topic or payload...",value:c,onChange:k=>u(k.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"}),c&&s.jsx("button",{onClick:()=>u(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",children:s.jsx(zt,{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:()=>f("all"),className:`px-2 py-1.5 text-xs rounded-l transition-colors ${d==="all"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white"}`,children:"All"}),s.jsxs("button",{onClick:()=>f("in"),className:`px-2 py-1.5 text-xs transition-colors flex items-center gap-1 ${d==="in"?"bg-blue-500 text-white":"text-bambu-gray hover:text-white"}`,children:[s.jsx(h0,{className:"w-3 h-3"}),"In"]}),s.jsxs("button",{onClick:()=>f("out"),className:`px-2 py-1.5 text-xs rounded-r transition-colors flex items-center gap-1 ${d==="out"?"bg-green-500 text-white":"text-bambu-gray hover:text-white"}`,children:[s.jsx(rg,{className:"w-3 h-3"}),"Out"]})]})]})]}),s.jsx("div",{ref:m,className:"flex-1 overflow-auto p-4 font-mono text-xs bg-black min-h-[400px]",children: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:"No messages logged yet"}),!C&&s.jsx("p",{className:"text-sm",children:'Click "Start Logging" to begin capturing MQTT messages'})]}):O.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:"No messages match your filter"}),s.jsx("p",{className:"text-sm",children:"Try adjusting your search or filter criteria"})]}):s.jsx("div",{className:"space-y-1",children:O.map((k,R)=>{const F=o.has(R),L=k.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:()=>S(R),children:[s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("span",{className:"text-bambu-gray shrink-0",children:T(k.timestamp)}),s.jsx("span",{className:`shrink-0 ${L?"text-blue-400":"text-green-400"}`,title:L?"Incoming":"Outgoing",children:L?s.jsx(h0,{className:"w-3 h-3"}):s.jsx(rg,{className:"w-3 h-3"})}),s.jsx("span",{className:"text-purple-400 shrink-0",children:k.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:E(k.payload,!0)}):s.jsx("pre",{className:"mt-1 text-white/80 truncate",children:E(k.payload,!1)})]},R)})})}),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:C?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"}),"Logging active - messages will auto-refresh"]}):s.jsx("span",{children:"Logging stopped"})}),s.jsx(we,{variant:"secondary",onClick:n,children:"Close"})]})]})})}const t3={"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 Bfe(t){switch(t){case 1:return{label:"Fatal",color:"text-red-500",bgColor:"bg-red-500/20",Icon:yn};case 2:return{label:"Serious",color:"text-red-400",bgColor:"bg-red-500/15",Icon:yn};case 3:return{label:"Warning",color:"text-orange-400",bgColor:"bg-orange-500/20",Icon:ji};case 4:default:return{label:"Info",color:"text-blue-400",bgColor:"bg-blue-500/20",Icon:Ul}}}function n3(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 $fe(t){return t.filter(e=>{const n=parseInt(e.code.replace("0x",""),16)||0,r=n3(e.attr,n);return t3[r]!==void 0})}function Hfe(){return"https://wiki.bambulab.com/en/hms/home"}function Vfe({printerName:t,errors:e,onClose:n}){console.log("HMSErrorModal errors:",JSON.stringify(e,null,2));const r=e.filter(i=>{const a=parseInt(i.code.replace("0x",""),16)||0,o=n3(i.attr,a);return t3[o]!==void 0});return w.useEffect(()=>{const i=a=>{a.key==="Escape"&&n()};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[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(yn,{className:"w-5 h-5 text-orange-400"}),s.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Errors - ",t]})]}),s.jsx("button",{onClick:n,className:"p-1 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:s.jsx(zt,{className:"w-5 h-5 text-bambu-gray"})})]}),s.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:r.length===0?s.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[s.jsx(ji,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),s.jsx("p",{children:"No errors"})]}):s.jsx("div",{className:"space-y-3",children:r.map((i,a)=>{const{label:o,color:l,bgColor:c,Icon:u}=Bfe(i.severity),d=parseInt(i.code.replace("0x",""),16)||0,f=n3(i.attr,d),m=t3[f],p=Hfe(),x=f.replace("_","-");return s.jsx("div",{className:`p-4 rounded-lg ${c} border border-white/10`,children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(u,{className:`w-5 h-5 ${l} 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 ${l}`,children:["[",x,"]"]}),s.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full ${c} ${l}`,children:o})]}),s.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:m}),s.jsxs("a",{href:p,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-bambu-green hover:underline",children:[s.jsx(Ur,{className:"w-3 h-3"}),"View on Bambu Lab Wiki"]})]})]})},`${i.code}-${a}`)})})}),s.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:s.jsx("p",{className:"text-xs text-bambu-gray",children:"Clear errors on the printer to dismiss them here."})})]})})}function Gfe(t){if(!t)return"ASAP";const e=vi(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 Wfe({printerId:t}){const{data:e}=ut({queryKey:["queue",t,"pending"],queryFn:()=>he.getQueue(t,"pending"),refetchInterval:3e4}),n=e?.[0],r=e?.length||0;return r===0?null:s.jsx(fs,{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(ri,{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(Kn,{className:"w-3 h-3"}),Gfe(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(Ys,{className:"w-4 h-4 text-bambu-gray"})]})]})})}function Sq(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=Sq(t[e]))&&(r&&(r+=" "),r+=n)}else for(n in t)t[n]&&(r&&(r+=" "),r+=n);return r}function $n(){for(var t,e,n=0,r="",i=arguments.length;n<i;n++)(t=arguments[n])&&(e=Sq(t))&&(r&&(r+=" "),r+=e);return r}var qfe=["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 bD(t){if(typeof t!="string")return!1;var e=qfe;return e.includes(t)}var Kfe=["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"],Xfe=new Set(Kfe);function Nq(t){return typeof t!="string"?!1:Xfe.has(t)}function Mq(t){return typeof t=="string"&&t.startsWith("data-")}function Qa(t){if(typeof t!="object"||t===null)return{};var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(Nq(n)||Mq(n))&&(e[n]=t[n]);return e}function Rf(t){if(t==null)return null;if(w.isValidElement(t)&&typeof t.props=="object"&&t.props!==null){var e=t.props;return Qa(e)}return typeof t=="object"&&!Array.isArray(t)?Qa(t):null}function Sa(t){var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(Nq(n)||Mq(n)||bD(n))&&(e[n]=t[n]);return e}function Yfe(t){return t==null?null:w.isValidElement(t)?Sa(t.props):typeof t=="object"&&!Array.isArray(t)?Sa(t):null}var Qfe=["children","width","height","viewBox","className","style","title","desc"];function r3(){return r3=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},r3.apply(null,arguments)}function Zfe(t,e){if(t==null)return{};var n,r,i=Jfe(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 Jfe(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 yD=w.forwardRef((t,e)=>{var{children:n,width:r,height:i,viewBox:a,className:o,style:l,title:c,desc:u}=t,d=Zfe(t,Qfe),f=a||{width:r,height:i,x:0,y:0},m=$n("recharts-surface",o);return w.createElement("svg",r3({},Sa(d),{className:m,width:r,height:i,style:l,viewBox:"".concat(f.x," ").concat(f.y," ").concat(f.width," ").concat(f.height),ref:e}),w.createElement("title",null,c),w.createElement("desc",null,u),n)}),eme=["children","className"];function i3(){return i3=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},i3.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 Gr=w.forwardRef((t,e)=>{var{children:n,className:r}=t,i=tme(t,eme),a=$n("recharts-layer",r);return w.createElement("g",i3({className:a},Sa(i),{ref:e}),n)}),Eq=w.createContext(null),rme=()=>w.useContext(Eq);function Nr(t){return function(){return t}}const Tq=Math.cos,ww=Math.sin,fl=Math.sqrt,Sw=Math.PI,q2=2*Sw,a3=Math.PI,s3=2*a3,Bh=1e-6,ime=s3-Bh;function Aq(t){this._+=t[0];for(let e=1,n=t.length;e<n;++e)this._+=arguments[e]+t[e]}function ame(t){let e=Math.floor(t);if(!(e>=0))throw new Error(`invalid digits: ${t}`);if(e>15)return Aq;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 sme{constructor(e){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=e==null?Aq:ame(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,m=d*d+f*f;if(this._x1===null)this._append`M${this._x1=e},${this._y1=n}`;else if(m>Bh)if(!(Math.abs(f*c-u*d)>Bh)||!a)this._append`L${this._x1=e},${this._y1=n}`;else{let p=r-o,x=i-l,y=c*c+u*u,b=p*p+x*x,v=Math.sqrt(y),N=Math.sqrt(m),S=a*Math.tan((a3-Math.acos((y+m-b)/(2*v*N)))/2),T=S/N,E=S/v;Math.abs(T-1)>Bh&&this._append`L${e+T*d},${n+T*f}`,this._append`A${a},${a},0,0,${+(f*p>d*x)},${this._x1=e+E*c},${this._y1=n+E*u}`}}arc(e,n,r,i,a,o){if(e=+e,n=+n,r=+r,o=!!o,r<0)throw new Error(`negative radius: ${r}`);let l=r*Math.cos(i),c=r*Math.sin(i),u=e+l,d=n+c,f=1^o,m=o?i-a:a-i;this._x1===null?this._append`M${u},${d}`:(Math.abs(this._x1-u)>Bh||Math.abs(this._y1-d)>Bh)&&this._append`L${u},${d}`,r&&(m<0&&(m=m%s3+s3),m>ime?this._append`A${r},${r},0,1,${f},${e-l},${n-c}A${r},${r},0,1,${f},${this._x1=u},${this._y1=d}`:m>Bh&&this._append`A${r},${r},0,${+(m>=a3)},${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 vD(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 sme(e)}function _D(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function Cq(t){this._context=t}Cq.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 K2(t){return new Cq(t)}function kq(t){return t[0]}function jq(t){return t[1]}function Pq(t,e){var n=Nr(!0),r=null,i=K2,a=null,o=vD(l);t=typeof t=="function"?t:t===void 0?kq:Nr(t),e=typeof e=="function"?e:e===void 0?jq:Nr(e);function l(c){var u,d=(c=_D(c)).length,f,m=!1,p;for(r==null&&(a=i(p=o())),u=0;u<=d;++u)!(u<d&&n(f=c[u],u,c))===m&&((m=!m)?a.lineStart():a.lineEnd()),m&&a.point(+t(f,u,c),+e(f,u,c));if(p)return a=null,p+""||null}return l.x=function(c){return arguments.length?(t=typeof c=="function"?c:Nr(+c),l):t},l.y=function(c){return arguments.length?(e=typeof c=="function"?c:Nr(+c),l):e},l.defined=function(c){return arguments.length?(n=typeof c=="function"?c:Nr(!!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 i_(t,e,n){var r=null,i=Nr(!0),a=null,o=K2,l=null,c=vD(u);t=typeof t=="function"?t:t===void 0?kq:Nr(+t),e=typeof e=="function"?e:Nr(e===void 0?0:+e),n=typeof n=="function"?n:n===void 0?jq:Nr(+n);function u(f){var m,p,x,y=(f=_D(f)).length,b,v=!1,N,S=new Array(y),T=new Array(y);for(a==null&&(l=o(N=c())),m=0;m<=y;++m){if(!(m<y&&i(b=f[m],m,f))===v)if(v=!v)p=m,l.areaStart(),l.lineStart();else{for(l.lineEnd(),l.lineStart(),x=m-1;x>=p;--x)l.point(S[x],T[x]);l.lineEnd(),l.areaEnd()}v&&(S[m]=+t(b,m,f),T[m]=+e(b,m,f),l.point(r?+r(b,m,f):S[m],n?+n(b,m,f):T[m]))}if(N)return l=null,N+""||null}function d(){return Pq().defined(i).curve(o).context(a)}return u.x=function(f){return arguments.length?(t=typeof f=="function"?f:Nr(+f),r=null,u):t},u.x0=function(f){return arguments.length?(t=typeof f=="function"?f:Nr(+f),u):t},u.x1=function(f){return arguments.length?(r=f==null?null:typeof f=="function"?f:Nr(+f),u):r},u.y=function(f){return arguments.length?(e=typeof f=="function"?f:Nr(+f),n=null,u):e},u.y0=function(f){return arguments.length?(e=typeof f=="function"?f:Nr(+f),u):e},u.y1=function(f){return arguments.length?(n=f==null?null:typeof f=="function"?f:Nr(+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:Nr(!!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 Rq{constructor(e,n){this._context=e,this._x=n}areaStart(){this._line=0}areaEnd(){this._line=NaN}lineStart(){this._point=0}lineEnd(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line}point(e,n){switch(e=+e,n=+n,this._point){case 0:{this._point=1,this._line?this._context.lineTo(e,n):this._context.moveTo(e,n);break}case 1:this._point=2;default:{this._x?this._context.bezierCurveTo(this._x0=(this._x0+e)/2,this._y0,this._x0,n,e,n):this._context.bezierCurveTo(this._x0,this._y0=(this._y0+n)/2,e,this._y0,e,n);break}}this._x0=e,this._y0=n}}function ome(t){return new Rq(t,!0)}function lme(t){return new Rq(t,!1)}const wD={draw(t,e){const n=fl(e/Sw);t.moveTo(n,0),t.arc(0,0,n,0,q2)}},cme={draw(t,e){const n=fl(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()}},Dq=fl(1/3),ume=Dq*2,dme={draw(t,e){const n=fl(e/ume),r=n*Dq;t.moveTo(0,-n),t.lineTo(r,0),t.lineTo(0,n),t.lineTo(-r,0),t.closePath()}},hme={draw(t,e){const n=fl(e),r=-n/2;t.rect(r,r,n,n)}},fme=.8908130915292852,Oq=ww(Sw/10)/ww(7*Sw/10),mme=ww(q2/10)*Oq,pme=-Tq(q2/10)*Oq,gme={draw(t,e){const n=fl(e*fme),r=mme*n,i=pme*n;t.moveTo(0,-n),t.lineTo(r,i);for(let a=1;a<5;++a){const o=q2*a/5,l=Tq(o),c=ww(o);t.lineTo(c*n,-l*n),t.lineTo(l*r-c*i,c*r+l*i)}t.closePath()}},UT=fl(3),xme={draw(t,e){const n=-fl(e/(UT*3));t.moveTo(0,n*2),t.lineTo(-UT*n,-n),t.lineTo(UT*n,-n),t.closePath()}},lo=-.5,co=fl(3)/2,o3=1/fl(12),bme=(o3/2+1)*3,yme={draw(t,e){const n=fl(e/bme),r=n/2,i=n*o3,a=r,o=n*o3+n,l=-a,c=o;t.moveTo(r,i),t.lineTo(a,o),t.lineTo(l,c),t.lineTo(lo*r-co*i,co*r+lo*i),t.lineTo(lo*a-co*o,co*a+lo*o),t.lineTo(lo*l-co*c,co*l+lo*c),t.lineTo(lo*r+co*i,lo*i-co*r),t.lineTo(lo*a+co*o,lo*o-co*a),t.lineTo(lo*l+co*c,lo*c-co*l),t.closePath()}};function vme(t,e){let n=null,r=vD(i);t=typeof t=="function"?t:Nr(t||wD),e=typeof e=="function"?e:Nr(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:Nr(a),i):t},i.size=function(a){return arguments.length?(e=typeof a=="function"?a:Nr(+a),i):e},i.context=function(a){return arguments.length?(n=a??null,i):n},i}function Nw(){}function Mw(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 Lq(t){this._context=t}Lq.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:Mw(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:Mw(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function _me(t){return new Lq(t)}function Iq(t){this._context=t}Iq.prototype={areaStart:Nw,areaEnd:Nw,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:Mw(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function wme(t){return new Iq(t)}function Fq(t){this._context=t}Fq.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:Mw(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function Sme(t){return new Fq(t)}function Uq(t){this._context=t}Uq.prototype={areaStart:Nw,areaEnd:Nw,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 Nme(t){return new Uq(t)}function Tz(t){return t<0?-1:1}function Az(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(Tz(a)+Tz(o))*Math.min(Math.abs(a),Math.abs(o),.5*Math.abs(l))||0}function Cz(t,e){var n=t._x1-t._x0;return n?(3*(t._y1-t._y0)/n-e)/2:e}function zT(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 Ew(t){this._context=t}Ew.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:zT(this,this._t0,Cz(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,zT(this,Cz(this,n=Az(this,t,e)),n);break;default:zT(this,this._t0,n=Az(this,t,e));break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e,this._t0=n}}};function zq(t){this._context=new Bq(t)}(zq.prototype=Object.create(Ew.prototype)).point=function(t,e){Ew.prototype.point.call(this,e,t)};function Bq(t){this._context=t}Bq.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 Mme(t){return new Ew(t)}function Eme(t){return new zq(t)}function $q(t){this._context=t}$q.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=[],this._y=[]},lineEnd:function(){var t=this._x,e=this._y,n=t.length;if(n)if(this._line?this._context.lineTo(t[0],e[0]):this._context.moveTo(t[0],e[0]),n===2)this._context.lineTo(t[1],e[1]);else for(var r=kz(t),i=kz(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 kz(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 Tme(t){return new $q(t)}function X2(t,e){this._context=t,this._t=e}X2.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 Ame(t){return new X2(t,.5)}function Cme(t){return new X2(t,0)}function kme(t){return new X2(t,1)}function lg(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 l3(t){for(var e=t.length,n=new Array(e);--e>=0;)n[e]=e;return n}function jme(t,e){return t[e]}function Pme(t){const e=[];return e.key=t,e}function Rme(){var t=Nr([]),e=l3,n=lg,r=jme;function i(a){var o=Array.from(t.apply(this,arguments),Pme),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=_D(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:Nr(Array.from(a)),i):t},i.value=function(a){return arguments.length?(r=typeof a=="function"?a:Nr(+a),i):r},i.order=function(a){return arguments.length?(e=a==null?l3:typeof a=="function"?a:Nr(Array.from(a)),i):e},i.offset=function(a){return arguments.length?(n=a??lg,i):n},i}function Dme(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}lg(t,e)}}function Ome(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}lg(t,e)}}function Lme(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,m=d[r-1][1]||0,p=(f-m)/2,x=0;x<l;++x){var y=t[e[x]],b=y[r][1]||0,v=y[r-1][1]||0;p+=b-v}c+=f,u+=p*f}i[r-1][1]+=i[r-1][0]=n,c&&(n-=u/c)}i[r-1][1]+=i[r-1][0]=n,lg(t,e)}}var BT={},$T={},jz;function Ime(){return jz||(jz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n==="__proto__"}t.isUnsafeProperty=e})($T)),$T}var HT={},Pz;function Hq(){return Pz||(Pz=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})(HT)),HT}var VT={},Rz;function SD(){return Rz||(Rz=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})(VT)),VT}var GT={},WT={},Dz;function Fme(){return Dz||(Dz=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})(WT)),WT}var Oz;function ND(){return Oz||(Oz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Fme(),n=SD();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})(GT)),GT}var Lz;function MD(){return Lz||(Lz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Ime(),n=Hq(),r=SD(),i=ND();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})(BT)),BT}var qT,Iz;function Ume(){return Iz||(Iz=1,qT=MD().get),qT}var zme=Ume();const Df=Fo(zme);var Ji=t=>t===0?0:t>0?1:-1,ws=t=>typeof t=="number"&&t!=+t,ou=t=>typeof t=="string"&&t.indexOf("%")===t.length-1,Bt=t=>(typeof t=="number"||t instanceof Number)&&!ws(t),Oo=t=>Bt(t)||typeof t=="string",Bme=0,x0=t=>{var e=++Bme;return"".concat(t||"").concat(e)},Oa=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(!Bt(e)&&typeof e!="string")return r;var a;if(ou(e)){if(n==null)return r;var o=e.indexOf("%");a=n*parseFloat(e.slice(0,o))/100}else a=+e;return ws(a)&&(a=r),i&&n!=null&&a>n&&(a=n),a},Vq=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 Zn(t,e,n){return Bt(t)&&Bt(e)?t+n*(e-t):e}function Gq(t,e,n){if(!(!t||!t.length))return t.find(r=>r&&(typeof e=="function"?e(r):Df(r,e))===n)}var Pr=t=>t===null||typeof t>"u",sy=t=>Pr(t)?t:"".concat(t.charAt(0).toUpperCase()).concat(t.slice(1));function $me(t){return t!=null}function oy(){}var Hme=["type","size","sizeType"];function c3(){return c3=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},c3.apply(null,arguments)}function Fz(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 Uz(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Fz(Object(n),!0).forEach(function(r){Vme(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Fz(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Vme(t,e,n){return(e=Gme(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Gme(t){var e=Wme(t,"string");return typeof e=="symbol"?e:e+""}function Wme(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 qme(t,e){if(t==null)return{};var n,r,i=Kme(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function Kme(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var Wq={symbolCircle:wD,symbolCross:cme,symbolDiamond:dme,symbolSquare:hme,symbolStar:gme,symbolTriangle:xme,symbolWye:yme},Xme=Math.PI/180,Yme=t=>{var e="symbol".concat(sy(t));return Wq[e]||wD},Qme=(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*Xme;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}},Zme=(t,e)=>{Wq["symbol".concat(sy(t))]=e},ED=t=>{var{type:e="circle",size:n=64,sizeType:r="area"}=t,i=qme(t,Hme),a=Uz(Uz({},i),{},{type:e,size:n,sizeType:r}),o="circle";typeof e=="string"&&(o=e);var l=()=>{var m=Yme(o),p=vme().type(m).size(Qme(n,r,o)),x=p();if(x!==null)return x},{className:c,cx:u,cy:d}=a,f=Sa(a);return Bt(u)&&Bt(d)&&Bt(n)?w.createElement("path",c3({},f,{className:$n("recharts-symbols",c),transform:"translate(".concat(u,", ").concat(d,")"),d:l()})):null};ED.registerSymbol=Zme;var qq=t=>"radius"in t&&"startAngle"in t&&"endAngle"in t,TD=(t,e)=>{if(!t||typeof t=="function"||typeof t=="boolean")return null;var n=t;if(w.isValidElement(t)&&(n=t.props),typeof n!="object"&&typeof n!="function")return null;var r={};return Object.keys(n).forEach(i=>{bD(i)&&(r[i]=(a=>n[i](n,a)))}),r},Jme=(t,e,n)=>r=>(t(e,n,r),null),ly=(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];bD(i)&&typeof a=="function"&&(r||(r={}),r[i]=Jme(a,e,n))}),r};function zz(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 epe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?zz(Object(n),!0).forEach(function(r){tpe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):zz(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function tpe(t,e,n){return(e=npe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function npe(t){var e=rpe(t,"string");return typeof e=="symbol"?e:e+""}function rpe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Wr(t,e){var n=epe({},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 Tw(){return Tw=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},Tw.apply(null,arguments)}function Bz(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 ipe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Bz(Object(n),!0).forEach(function(r){ape(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Bz(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function ape(t,e,n){return(e=spe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function spe(t){var e=ope(t,"string");return typeof e=="symbol"?e:e+""}function ope(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 po=32,lpe={align:"center",iconSize:14,inactiveColor:"#ccc",layout:"horizontal",verticalAlign:"middle"};function cpe(t){var{data:e,iconType:n,inactiveColor:r}=t,i=po/2,a=po/6,o=po/3,l=e.inactive?r:e.color,c=n??e.type;if(c==="none")return null;if(c==="plainline"){var u;return w.createElement("line",{strokeWidth:4,fill:"none",stroke:l,strokeDasharray:(u=e.payload)===null||u===void 0?void 0:u.strokeDasharray,x1:0,y1:i,x2:po,y2:i,className:"recharts-legend-icon"})}if(c==="line")return w.createElement("path",{strokeWidth:4,fill:"none",stroke:l,d:"M0,".concat(i,"h").concat(o,`
  11. A`).concat(a,",").concat(a,",0,1,1,").concat(2*o,",").concat(i,`
  12. H`).concat(po,"M").concat(2*o,",").concat(i,`
  13. A`).concat(a,",").concat(a,",0,1,1,").concat(o,",").concat(i),className:"recharts-legend-icon"});if(c==="rect")return w.createElement("path",{stroke:"none",fill:l,d:"M0,".concat(po/8,"h").concat(po,"v").concat(po*3/4,"h").concat(-po,"z"),className:"recharts-legend-icon"});if(w.isValidElement(e.legendIcon)){var d=ipe({},e);return delete d.legendIcon,w.cloneElement(e.legendIcon,d)}return w.createElement(ED,{fill:l,cx:i,cy:i,size:po,sizeType:"diameter",type:c})}function upe(t){var{payload:e,iconSize:n,layout:r,formatter:i,inactiveColor:a,iconType:o}=t,l={x:0,y:0,width:po,height:po},c={display:r==="horizontal"?"inline-block":"block",marginRight:10},u={display:"inline-block",verticalAlign:"middle",marginRight:4};return e.map((d,f)=>{var m=d.formatter||i,p=$n({"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,y=m?m(d.value,d,f):d.value;return w.createElement("li",Tw({className:p,style:c,key:"legend-item-".concat(f)},ly(t,d,f)),w.createElement(yD,{width:n,height:n,viewBox:l,style:u,"aria-label":"".concat(y," legend icon")},w.createElement(cpe,{data:d,iconType:o,inactiveColor:a})),w.createElement("span",{className:"recharts-legend-item-text",style:{color:x}},y))})}var dpe=t=>{var e=Wr(t,lpe),{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 w.createElement("ul",{className:"recharts-default-legend",style:a},w.createElement(upe,Tw({},e,{payload:n})))},KT={},XT={},$z;function hpe(){return $z||($z=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})(XT)),XT}var YT={},Hz;function Kq(){return Hz||(Hz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n}t.identity=e})(YT)),YT}var QT={},ZT={},JT={},Vz;function fpe(){return Vz||(Vz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Number.isSafeInteger(n)&&n>=0}t.isLength=e})(JT)),JT}var Gz;function AD(){return Gz||(Gz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=fpe();function n(r){return r!=null&&typeof r!="function"&&e.isLength(r.length)}t.isArrayLike=n})(ZT)),ZT}var eA={},Wz;function mpe(){return Wz||(Wz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return typeof n=="object"&&n!==null}t.isObjectLike=e})(eA)),eA}var qz;function ppe(){return qz||(qz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=AD(),n=mpe();function r(i){return n.isObjectLike(i)&&e.isArrayLike(i)}t.isArrayLikeObject=r})(QT)),QT}var tA={},nA={},Kz;function gpe(){return Kz||(Kz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=MD();function n(r){return function(i){return e.get(i,r)}}t.property=n})(nA)),nA}var rA={},iA={},aA={},sA={},Xz;function Xq(){return Xz||(Xz=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})(sA)),sA}var oA={},Yz;function Yq(){return Yz||(Yz=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})(oA)),oA}var lA={},Qz;function Qq(){return Qz||(Qz=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})(lA)),lA}var Zz;function xpe(){return Zz||(Zz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Xq(),n=Yq(),r=Qq();function i(d,f,m){return typeof m!="function"?i(d,f,()=>{}):a(d,f,function p(x,y,b,v,N,S){const T=m(x,y,b,v,N,S);return T!==void 0?!!T:a(x,y,p,S)},new Map)}function a(d,f,m,p){if(f===d)return!0;switch(typeof f){case"object":return o(d,f,m,p);case"function":return Object.keys(f).length>0?a(d,{...f},m,p):r.eq(d,f);default:return e.isObject(d)?typeof f=="string"?f==="":!0:r.eq(d,f)}}function o(d,f,m,p){if(f==null)return!0;if(Array.isArray(f))return c(d,f,m,p);if(f instanceof Map)return l(d,f,m,p);if(f instanceof Set)return u(d,f,m,p);const x=Object.keys(f);if(d==null)return x.length===0;if(x.length===0)return!0;if(p?.has(f))return p.get(f)===d;p?.set(f,d);try{for(let y=0;y<x.length;y++){const b=x[y];if(!n.isPrimitive(d)&&!(b in d)||f[b]===void 0&&d[b]!==void 0||f[b]===null&&d[b]!==null||!m(d[b],f[b],b,d,f,p))return!1}return!0}finally{p?.delete(f)}}function l(d,f,m,p){if(f.size===0)return!0;if(!(d instanceof Map))return!1;for(const[x,y]of f.entries()){const b=d.get(x);if(m(b,y,x,d,f,p)===!1)return!1}return!0}function c(d,f,m,p){if(f.length===0)return!0;if(!Array.isArray(d))return!1;const x=new Set;for(let y=0;y<f.length;y++){const b=f[y];let v=!1;for(let N=0;N<d.length;N++){if(x.has(N))continue;const S=d[N];let T=!1;if(m(S,b,y,d,f,p)&&(T=!0),T){x.add(N),v=!0;break}}if(!v)return!1}return!0}function u(d,f,m,p){return f.size===0?!0:d instanceof Set?c([...d],[...f],m,p):!1}t.isMatchWith=i,t.isSetMatch=u})(aA)),aA}var Jz;function Zq(){return Jz||(Jz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=xpe();function n(r,i){return e.isMatchWith(r,i,()=>{})}t.isMatch=n})(iA)),iA}var cA={},uA={},dA={},eB;function bpe(){return eB||(eB=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})(dA)),dA}var hA={},tB;function Jq(){return tB||(tB=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})(hA)),hA}var fA={},nB;function eK(){return nB||(nB=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]",m="[object ArrayBuffer]",p="[object Object]",x="[object Error]",y="[object DataView]",b="[object Uint8Array]",v="[object Uint8ClampedArray]",N="[object Uint16Array]",S="[object Uint32Array]",T="[object BigUint64Array]",E="[object Int8Array]",C="[object Int16Array]",A="[object Int32Array]",O="[object BigInt64Array]",k="[object Float32Array]",R="[object Float64Array]";t.argumentsTag=a,t.arrayBufferTag=m,t.arrayTag=d,t.bigInt64ArrayTag=O,t.bigUint64ArrayTag=T,t.booleanTag=i,t.dataViewTag=y,t.dateTag=l,t.errorTag=x,t.float32ArrayTag=k,t.float64ArrayTag=R,t.functionTag=f,t.int16ArrayTag=C,t.int32ArrayTag=A,t.int8ArrayTag=E,t.mapTag=c,t.numberTag=r,t.objectTag=p,t.regexpTag=e,t.setTag=u,t.stringTag=n,t.symbolTag=o,t.uint16ArrayTag=N,t.uint32ArrayTag=S,t.uint8ArrayTag=b,t.uint8ClampedArrayTag=v})(fA)),fA}var mA={},rB;function ype(){return rB||(rB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}t.isTypedArray=e})(mA)),mA}var iB;function tK(){return iB||(iB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=bpe(),n=Jq(),r=eK(),i=Yq(),a=ype();function o(d,f){return l(d,void 0,d,new Map,f)}function l(d,f,m,p=new Map,x=void 0){const y=x?.(d,f,m,p);if(y!==void 0)return y;if(i.isPrimitive(d))return d;if(p.has(d))return p.get(d);if(Array.isArray(d)){const b=new Array(d.length);p.set(d,b);for(let v=0;v<d.length;v++)b[v]=l(d[v],v,m,p,x);return Object.hasOwn(d,"index")&&(b.index=d.index),Object.hasOwn(d,"input")&&(b.input=d.input),b}if(d instanceof Date)return new Date(d.getTime());if(d instanceof RegExp){const b=new RegExp(d.source,d.flags);return b.lastIndex=d.lastIndex,b}if(d instanceof Map){const b=new Map;p.set(d,b);for(const[v,N]of d)b.set(v,l(N,v,m,p,x));return b}if(d instanceof Set){const b=new Set;p.set(d,b);for(const v of d)b.add(l(v,void 0,m,p,x));return b}if(typeof Buffer<"u"&&Buffer.isBuffer(d))return d.subarray();if(a.isTypedArray(d)){const b=new(Object.getPrototypeOf(d)).constructor(d.length);p.set(d,b);for(let v=0;v<d.length;v++)b[v]=l(d[v],v,m,p,x);return b}if(d instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&d instanceof SharedArrayBuffer)return d.slice(0);if(d instanceof DataView){const b=new DataView(d.buffer.slice(0),d.byteOffset,d.byteLength);return p.set(d,b),c(b,d,m,p,x),b}if(typeof File<"u"&&d instanceof File){const b=new File([d],d.name,{type:d.type});return p.set(d,b),c(b,d,m,p,x),b}if(typeof Blob<"u"&&d instanceof Blob){const b=new Blob([d],{type:d.type});return p.set(d,b),c(b,d,m,p,x),b}if(d instanceof Error){const b=new d.constructor;return p.set(d,b),b.message=d.message,b.name=d.name,b.stack=d.stack,b.cause=d.cause,c(b,d,m,p,x),b}if(d instanceof Boolean){const b=new Boolean(d.valueOf());return p.set(d,b),c(b,d,m,p,x),b}if(d instanceof Number){const b=new Number(d.valueOf());return p.set(d,b),c(b,d,m,p,x),b}if(d instanceof String){const b=new String(d.valueOf());return p.set(d,b),c(b,d,m,p,x),b}if(typeof d=="object"&&u(d)){const b=Object.create(Object.getPrototypeOf(d));return p.set(d,b),c(b,d,m,p,x),b}return d}function c(d,f,m=d,p,x){const y=[...Object.keys(f),...e.getSymbols(f)];for(let b=0;b<y.length;b++){const v=y[b],N=Object.getOwnPropertyDescriptor(d,v);(N==null||N.writable)&&(d[v]=l(f[v],v,m,p,x))}}function u(d){switch(n.getTag(d)){case r.argumentsTag:case r.arrayTag:case r.arrayBufferTag:case r.dataViewTag:case r.booleanTag:case r.dateTag:case r.float32ArrayTag:case r.float64ArrayTag:case r.int8ArrayTag:case r.int16ArrayTag:case r.int32ArrayTag:case r.mapTag:case r.numberTag:case r.objectTag:case r.regexpTag:case r.setTag:case r.stringTag:case r.symbolTag:case r.uint8ArrayTag:case r.uint8ClampedArrayTag:case r.uint16ArrayTag:case r.uint32ArrayTag:return!0;default:return!1}}t.cloneDeepWith=o,t.cloneDeepWithImpl=l,t.copyProperties=c})(uA)),uA}var aB;function vpe(){return aB||(aB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=tK();function n(r){return e.cloneDeepWithImpl(r,void 0,r,new Map,void 0)}t.cloneDeep=n})(cA)),cA}var sB;function _pe(){return sB||(sB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Zq(),n=vpe();function r(i){return i=n.cloneDeep(i),a=>e.isMatch(a,i)}t.matches=r})(rA)),rA}var pA={},gA={},xA={},oB;function wpe(){return oB||(oB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=tK(),n=eK();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})(xA)),xA}var lB;function Spe(){return lB||(lB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=wpe();function n(r){return e.cloneDeepWith(r)}t.cloneDeep=n})(gA)),gA}var bA={},yA={},cB;function nK(){return cB||(cB=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})(yA)),yA}var vA={},uB;function Npe(){return uB||(uB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Jq();function n(r){return r!==null&&typeof r=="object"&&e.getTag(r)==="[object Arguments]"}t.isArguments=n})(vA)),vA}var dB;function Mpe(){return dB||(dB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Hq(),n=nK(),r=Npe(),i=ND();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})(bA)),bA}var hB;function Epe(){return hB||(hB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Zq(),n=SD(),r=Spe(),i=MD(),a=Mpe();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})(pA)),pA}var fB;function Tpe(){return fB||(fB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Kq(),n=gpe(),r=_pe(),i=Epe();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})(tA)),tA}var mB;function Ape(){return mB||(mB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=hpe(),n=Kq(),r=ppe(),i=Tpe();function a(o,l=n.identity){return r.isArrayLikeObject(o)?e.uniqBy(Array.from(o),i.iteratee(l)):[]}t.uniqBy=a})(KT)),KT}var _A,pB;function Cpe(){return pB||(pB=1,_A=Ape().uniqBy),_A}var kpe=Cpe();const gB=Fo(kpe);function rK(t,e,n){return e===!0?gB(t,n):typeof e=="function"?gB(t,e):t}var wA={exports:{}},SA={};var xB;function jpe(){if(xB)return SA;xB=1;var t=Dg(),e=hW();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 SA.useSyncExternalStoreWithSelector=function(u,d,f,m,p){var x=a(null);if(x.current===null){var y={hasValue:!1,value:null};x.current=y}else y=x.current;x=l(function(){function v(C){if(!N){if(N=!0,S=C,C=m(C),p!==void 0&&y.hasValue){var A=y.value;if(p(A,C))return T=A}return T=C}if(A=T,r(S,C))return A;var O=m(C);return p!==void 0&&p(A,O)?(S=C,A):(S=C,T=O)}var N=!1,S,T,E=f===void 0?null:f;return[function(){return v(d())},E===null?void 0:function(){return v(E())}]},[d,f,m,p]);var b=i(u,x[0],x[1]);return o(function(){y.hasValue=!0,y.value=b},[b]),c(b),b},SA}var bB;function Ppe(){return bB||(bB=1,wA.exports=jpe()),wA.exports}var iK=Ppe(),CD=w.createContext(null),Rpe=t=>t,wr=()=>{var t=w.useContext(CD);return t?t.store.dispatch:Rpe},$1=()=>{},Dpe=()=>$1,Ope=(t,e)=>t===e;function Ft(t){var e=w.useContext(CD);return iK.useSyncExternalStoreWithSelector(e?e.subscription.addNestedSub:Dpe,e?e.store.getState:$1,e?e.store.getState:$1,e?t:$1,Ope)}function Lpe(t,e=`expected a function, instead received ${typeof t}`){if(typeof t!="function")throw new TypeError(e)}function Ipe(t,e=`expected an object, instead received ${typeof t}`){if(typeof t!="object")throw new TypeError(e)}function Fpe(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 yB=t=>Array.isArray(t)?t:[t];function Upe(t){const e=Array.isArray(t[0])?t[0]:t;return Fpe(e,"createSelector expects all input-selectors to be functions, but received the following types: "),e}function zpe(t,e){const n=[],{length:r}=t;for(let i=0;i<r;i++)n.push(t[i].apply(null,e));return n}var Bpe=class{constructor(t){this.value=t}deref(){return this.value}},$pe=typeof WeakRef<"u"?WeakRef:Bpe,Hpe=0,vB=1;function a_(){return{s:Hpe,v:void 0,o:null,p:null}}function aK(t,e={}){let n=a_();const{resultEqualityCheck:r}=e;let i,a=0;function o(){let l=n;const{length:c}=arguments;for(let f=0,m=c;f<m;f++){const p=arguments[f];if(typeof p=="function"||typeof p=="object"&&p!==null){let x=l.o;x===null&&(l.o=x=new WeakMap);const y=x.get(p);y===void 0?(l=a_(),x.set(p,l)):l=y}else{let x=l.p;x===null&&(l.p=x=new Map);const y=x.get(p);y===void 0?(l=a_(),x.set(p,l)):l=y}}const u=l;let d;if(l.s===vB)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 $pe(d):d}return u.s=vB,u.v=d,d}return o.clearCache=()=>{n=a_(),o.resetResultsCount()},o.resultsCount=()=>a,o.resetResultsCount=()=>{a=0},o}function Vpe(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()),Lpe(u,`createSelector expects an output function after the inputs, but received: [${typeof u}]`);const d={...n,...c},{memoize:f,memoizeOptions:m=[],argsMemoize:p=aK,argsMemoizeOptions:x=[]}=d,y=yB(m),b=yB(x),v=Upe(i),N=f(function(){return a++,u.apply(null,arguments)},...y),S=p(function(){o++;const E=zpe(v,arguments);return l=N.apply(null,E),l},...b);return Object.assign(S,{resultFunc:u,memoizedResultFunc:N,dependencies:v,dependencyRecomputations:()=>o,resetDependencyRecomputations:()=>{o=0},lastResult:()=>l,recomputations:()=>a,resetRecomputations:()=>{a=0},memoize:f,argsMemoize:p})};return Object.assign(r,{withTypes:()=>r}),r}var et=Vpe(aK),Gpe=Object.assign((t,e=et)=>{Ipe(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:()=>Gpe}),NA={},MA={},EA={},_B;function Wpe(){return _B||(_B=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})(EA)),EA}var TA={},AA={},wB;function sK(){return wB||(wB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return typeof n=="symbol"||n instanceof Symbol}t.isSymbol=e})(AA)),AA}var SB;function qpe(){return SB||(SB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=sK(),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})(TA)),TA}var NB;function Kpe(){return NB||(NB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Wpe(),n=qpe(),r=ND();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(p=>String(p));const u=(p,x)=>{let y=p;for(let b=0;b<x.length&&y!=null;++b)y=y[x[b]];return y},d=(p,x)=>x==null||p==null?x:typeof p=="object"&&"key"in p?Object.hasOwn(x,p.key)?x[p.key]:u(x,p.path):typeof p=="function"?p(x):Array.isArray(p)?u(x,p):typeof x=="object"?x[p]:x,f=o.map(p=>(Array.isArray(p)&&p.length===1&&(p=p[0]),p==null||typeof p=="function"||Array.isArray(p)||n.isKey(p)?p:{key:p,path:r.toPath(p)}));return a.map(p=>({original:p,criteria:f.map(x=>d(x,p))})).slice().sort((p,x)=>{for(let y=0;y<f.length;y++){const b=e.compareValues(p.criteria[y],x.criteria[y],l[y]);if(b!==0)return b}return 0}).map(p=>p.original)}t.orderBy=i})(MA)),MA}var CA={},MB;function Xpe(){return MB||(MB=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})(CA)),CA}var kA={},EB;function oK(){return EB||(EB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=nK(),n=AD(),r=Xq(),i=Qq();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})(kA)),kA}var TB;function Ype(){return TB||(TB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Kpe(),n=Xpe(),r=oK();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})(NA)),NA}var jA,AB;function Qpe(){return AB||(AB=1,jA=Ype().sortBy),jA}var Zpe=Qpe();const Y2=Fo(Zpe);var lK=t=>t.legend.settings,Jpe=t=>t.legend.size,ege=t=>t.legend.payload,tge=et([ege,lK],(t,e)=>{var{itemSorter:n}=e,r=t.flat(1);return n?Y2(r,n):r});function nge(){return Ft(tge)}var s_=1;function cK(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],[e,n]=w.useState({height:0,left:0,top:0,width:0}),r=w.useCallback(i=>{if(i!=null){var a=i.getBoundingClientRect(),o={height:a.height,left:a.left,top:a.top,width:a.width};(Math.abs(o.height-e.height)>s_||Math.abs(o.left-e.left)>s_||Math.abs(o.top-e.top)>s_||Math.abs(o.width-e.width)>s_)&&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 ma(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 rge=typeof Symbol=="function"&&Symbol.observable||"@@observable",CB=rge,PA=()=>Math.random().toString(36).substring(7).split("").join("."),ige={INIT:`@@redux/INIT${PA()}`,REPLACE:`@@redux/REPLACE${PA()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${PA()}`},Aw=ige;function kD(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 uK(t,e,n){if(typeof t!="function")throw new Error(ma(2));if(typeof e=="function"&&typeof n=="function"||typeof n=="function"&&typeof arguments[3]=="function")throw new Error(ma(0));if(typeof e=="function"&&typeof n>"u"&&(n=e,e=void 0),typeof n<"u"){if(typeof n!="function")throw new Error(ma(1));return n(uK)(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((b,v)=>{o.set(v,b)}))}function d(){if(c)throw new Error(ma(3));return i}function f(b){if(typeof b!="function")throw new Error(ma(4));if(c)throw new Error(ma(5));let v=!0;u();const N=l++;return o.set(N,b),function(){if(v){if(c)throw new Error(ma(6));v=!1,u(),o.delete(N),a=null}}}function m(b){if(!kD(b))throw new Error(ma(7));if(typeof b.type>"u")throw new Error(ma(8));if(typeof b.type!="string")throw new Error(ma(17));if(c)throw new Error(ma(9));try{c=!0,i=r(i,b)}finally{c=!1}return(a=o).forEach(N=>{N()}),b}function p(b){if(typeof b!="function")throw new Error(ma(10));r=b,m({type:Aw.REPLACE})}function x(){const b=f;return{subscribe(v){if(typeof v!="object"||v===null)throw new Error(ma(11));function N(){const T=v;T.next&&T.next(d())}return N(),{unsubscribe:b(N)}},[CB](){return this}}}return m({type:Aw.INIT}),{dispatch:m,subscribe:f,getState:d,replaceReducer:p,[CB]:x}}function age(t){Object.keys(t).forEach(e=>{const n=t[e];if(typeof n(void 0,{type:Aw.INIT})>"u")throw new Error(ma(12));if(typeof n(void 0,{type:Aw.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(ma(13))})}function dK(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{age(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],m=n[f],p=o[f],x=m(p,l);if(typeof x>"u")throw l&&l.type,new Error(ma(14));u[f]=x,c=c||x!==p}return c=c||r.length!==Object.keys(o).length,c?u:o}}function Cw(...t){return t.length===0?e=>e:t.length===1?t[0]:t.reduce((e,n)=>(...r)=>e(n(...r)))}function sge(...t){return e=>(n,r)=>{const i=e(n,r);let a=()=>{throw new Error(ma(15))};const o={getState:i.getState,dispatch:(c,...u)=>a(c,...u)},l=t.map(c=>c(o));return a=Cw(...l)(i.dispatch),{...i,dispatch:a}}}function hK(t){return kD(t)&&"type"in t&&typeof t.type=="string"}var fK=Symbol.for("immer-nothing"),kB=Symbol.for("immer-draftable"),Za=Symbol.for("immer-state");function Qo(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var Hs=Object,cg=Hs.getPrototypeOf,kw="constructor",Q2="prototype",u3="configurable",jw="enumerable",H1="writable",b0="value",lu=t=>!!t&&!!t[Za];function ul(t){return t?mK(t)||Z2(t)||!!t[kB]||!!t[kw]?.[kB]||J2(t)||eN(t):!1}var oge=Hs[Q2][kw].toString(),jB=new WeakMap;function mK(t){if(!t||!jD(t))return!1;const e=cg(t);if(e===null||e===Hs[Q2])return!0;const n=Hs.hasOwnProperty.call(e,kw)&&e[kw];if(n===Object)return!0;if(!Cp(n))return!1;let r=jB.get(n);return r===void 0&&(r=Function.toString.call(n),jB.set(n,r)),r===oge}function cy(t,e,n=!0){uy(t)===0?(n?Reflect.ownKeys(t):Hs.keys(t)).forEach(i=>{e(i,t[i],t)}):t.forEach((r,i)=>e(i,r,t))}function uy(t){const e=t[Za];return e?e.type_:Z2(t)?1:J2(t)?2:eN(t)?3:0}var PB=(t,e,n=uy(t))=>n===2?t.has(e):Hs[Q2].hasOwnProperty.call(t,e),d3=(t,e,n=uy(t))=>n===2?t.get(e):t[e],Pw=(t,e,n,r=uy(t))=>{r===2?t.set(e,n):r===3?t.add(n):t[e]=n};function lge(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}var Z2=Array.isArray,J2=t=>t instanceof Map,eN=t=>t instanceof Set,jD=t=>typeof t=="object",Cp=t=>typeof t=="function",RA=t=>typeof t=="boolean",Fc=t=>t.copy_||t.base_,PD=t=>t.modified_?t.copy_:t.base_;function h3(t,e){if(J2(t))return new Map(t);if(eN(t))return new Set(t);if(Z2(t))return Array[Q2].slice.call(t);const n=mK(t);if(e===!0||e==="class_only"&&!n){const r=Hs.getOwnPropertyDescriptors(t);delete r[Za];let i=Reflect.ownKeys(r);for(let a=0;a<i.length;a++){const o=i[a],l=r[o];l[H1]===!1&&(l[H1]=!0,l[u3]=!0),(l.get||l.set)&&(r[o]={[u3]:!0,[H1]:!0,[jw]:l[jw],[b0]:t[o]})}return Hs.create(cg(t),r)}else{const r=cg(t);if(r!==null&&n)return{...t};const i=Hs.create(r);return Hs.assign(i,t)}}function RD(t,e=!1){return tN(t)||lu(t)||!ul(t)||(uy(t)>1&&Hs.defineProperties(t,{set:o_,add:o_,clear:o_,delete:o_}),Hs.freeze(t),e&&cy(t,(n,r)=>{RD(r,!0)},!1)),t}function cge(){Qo(2)}var o_={[b0]:cge};function tN(t){return t===null||!jD(t)?!0:Hs.isFrozen(t)}var Rw="MapSet",f3="Patches",pK={};function ug(t){const e=pK[t];return e||Qo(0,t),e}var uge=t=>!!pK[t],y0,gK=()=>y0,dge=(t,e)=>({drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:uge(Rw)?ug(Rw):void 0});function RB(t,e){e&&(t.patchPlugin_=ug(f3),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function m3(t){p3(t),t.drafts_.forEach(hge),t.drafts_=null}function p3(t){t===y0&&(y0=t.parent_)}var DB=t=>y0=dge(y0,t);function hge(t){const e=t[Za];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function OB(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];if(t!==void 0&&t!==n){n[Za].modified_&&(m3(e),Qo(4)),ul(t)&&(t=LB(e,t));const{patchPlugin_:i}=e;i&&i.generateReplacementPatches_(n[Za].base_,t,e)}else t=LB(e,n);return fge(e,t,!0),m3(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==fK?t:void 0}function LB(t,e){if(tN(e))return e;const n=e[Za];if(!n)return DD(e,t.handledSet_,t);if(!nN(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);yK(n,t)}return n.copy_}function fge(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&RD(e,n)}function xK(t){t.finalized_=!0,t.scope_.unfinalizedDrafts_--}var nN=(t,e)=>t.scope_===e,mge=[];function bK(t,e,n,r){const i=Fc(t),a=t.type_;if(r!==void 0&&d3(i,r,a)===e){Pw(i,r,n,a);return}if(!t.draftLocations_){const l=t.draftLocations_=new Map;cy(i,(c,u)=>{if(lu(u)){const d=l.get(u)||[];d.push(c),l.set(u,d)}})}const o=t.draftLocations_.get(e)??mge;for(const l of o)Pw(i,l,n,a)}function pge(t,e,n){t.callbacks_.push(function(i){const a=e;if(!a||!nN(a,i))return;i.mapSetPlugin_?.fixSetContents(a);const o=PD(a);bK(t,a.draft_??a,o,n),yK(a,i)})}function yK(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)}xK(t)}}function gge(t,e,n){const{scope_:r}=t;if(lu(n)){const i=n[Za];nN(i,r)&&i.callbacks_.push(function(){V1(t);const o=PD(i);bK(t,n,o,e)})}else ul(n)&&t.callbacks_.push(function(){const a=Fc(t);d3(a,e,t.type_)===n&&r.drafts_.length>1&&(t.assigned_.get(e)??!1)===!0&&t.copy_&&DD(d3(t.copy_,e,t.type_),r.handledSet_,r)})}function DD(t,e,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||lu(t)||e.has(t)||!ul(t)||tN(t)||(e.add(t),cy(t,(r,i)=>{if(lu(i)){const a=i[Za];if(nN(a,n)){const o=PD(a);Pw(t,r,o,t.type_),xK(a)}}else ul(i)&&DD(i,e,n)})),t}function xge(t,e){const n=Z2(t),r={type_:n?1:0,scope_:e?e.scope_:gK(),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=OD;n&&(i=[r],a=v0);const{revoke:o,proxy:l}=Proxy.revocable(i,a);return r.draft_=l,r.revoke_=o,[l,r]}var OD={get(t,e){if(e===Za)return t;const n=Fc(t);if(!PB(n,e,t.type_))return bge(t,n,e);const r=n[e];if(t.finalized_||!ul(r))return r;if(r===DA(t.base_,e)){V1(t);const i=t.type_===1?+e:e,a=x3(t.scope_,r,t,i);return t.copy_[i]=a}return r},has(t,e){return e in Fc(t)},ownKeys(t){return Reflect.ownKeys(Fc(t))},set(t,e,n){const r=vK(Fc(t),e);if(r?.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const i=DA(Fc(t),e),a=i?.[Za];if(a&&a.base_===n)return t.copy_[e]=n,t.assigned_.set(e,!1),!0;if(lge(n,i)&&(n!==void 0||PB(t.base_,e,t.type_)))return!0;V1(t),g3(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),gge(t,e,n)),!0},deleteProperty(t,e){return V1(t),DA(t.base_,e)!==void 0||e in t.base_?(t.assigned_.set(e,!1),g3(t)):t.assigned_.delete(e),t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const n=Fc(t),r=Reflect.getOwnPropertyDescriptor(n,e);return r&&{[H1]:!0,[u3]:t.type_!==1||e!=="length",[jw]:r[jw],[b0]:n[e]}},defineProperty(){Qo(11)},getPrototypeOf(t){return cg(t.base_)},setPrototypeOf(){Qo(12)}},v0={};cy(OD,(t,e)=>{v0[t]=function(){const n=arguments;return n[0]=n[0][0],e.apply(this,n)}});v0.deleteProperty=function(t,e){return v0.set.call(this,t,e,void 0)};v0.set=function(t,e,n){return OD.set.call(this,t[0],e,n,t[0])};function DA(t,e){const n=t[Za];return(n?Fc(n):t)[e]}function bge(t,e,n){const r=vK(e,n);return r?b0 in r?r[b0]:r.get?.call(t.draft_):void 0}function vK(t,e){if(!(e in t))return;let n=cg(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,e);if(r)return r;n=cg(n)}}function g3(t){t.modified_||(t.modified_=!0,t.parent_&&g3(t.parent_))}function V1(t){t.copy_||(t.assigned_=new Map,t.copy_=h3(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var yge=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(n,r,i)=>{if(Cp(n)&&!Cp(r)){const o=r;r=n;const l=this;return function(u=o,...d){return l.produce(u,f=>r.call(this,f,...d))}}Cp(r)||Qo(6),i!==void 0&&!Cp(i)&&Qo(7);let a;if(ul(n)){const o=DB(this),l=x3(o,n,void 0);let c=!0;try{a=r(l),c=!1}finally{c?m3(o):p3(o)}return RB(o,i),OB(a,o)}else if(!n||!jD(n)){if(a=r(n),a===void 0&&(a=n),a===fK&&(a=void 0),this.autoFreeze_&&RD(a,!0),i){const o=[],l=[];ug(f3).generateReplacementPatches_(n,a,{patches_:o,inversePatches_:l}),i(o,l)}return a}else Qo(1,n)},this.produceWithPatches=(n,r)=>{if(Cp(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]},RA(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),RA(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),RA(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){ul(e)||Qo(8),lu(e)&&(e=al(e));const n=DB(this),r=x3(n,e,void 0);return r[Za].isManual_=!0,p3(n),r}finishDraft(e,n){const r=e&&e[Za];(!r||!r.isManual_)&&Qo(9);const{scope_:i}=r;return RB(i,n),OB(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=ug(f3).applyPatches_;return lu(e)?i(e,n):this.produce(e,a=>i(a,n))}};function x3(t,e,n,r){const[i,a]=J2(e)?ug(Rw).proxyMap_(e,n):eN(e)?ug(Rw).proxySet_(e,n):xge(e,n);return(n?.scope_??gK()).drafts_.push(i),a.callbacks_=n?.callbacks_??[],a.key_=r,n&&r!==void 0?pge(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 al(t){return lu(t)||Qo(10,t),_K(t)}function _K(t){if(!ul(t)||tN(t))return t;const e=t[Za];let n,r=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=h3(t,e.scope_.immer_.useStrictShallowCopy_),r=e.scope_.immer_.shouldUseStrictIteration()}else n=h3(t,!0);return cy(n,(i,a)=>{Pw(n,i,_K(a))},r),e&&(e.finalized_=!1),n}var vge=new yge,wK=vge.produce;function SK(t){return({dispatch:n,getState:r})=>i=>a=>typeof a=="function"?a(n,r,t):i(a)}var _ge=SK(),wge=SK,Sge=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?Cw:Cw.apply(null,arguments)};function Lo(t,e){function n(...r){if(e){let i=e(...r);if(!i)throw new Error(Gs(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=>hK(r)&&r.type===t,n}var NK=class Mb extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,Mb.prototype)}static get[Symbol.species](){return Mb}concat(...e){return super.concat.apply(this,e)}prepend(...e){return e.length===1&&Array.isArray(e[0])?new Mb(...e[0].concat(this)):new Mb(...e.concat(this))}};function IB(t){return ul(t)?wK(t,()=>{}):t}function l_(t,e,n){return t.has(e)?t.get(e):t.set(e,n(e)).get(e)}function Nge(t){return typeof t=="boolean"}var Mge=()=>function(e){const{thunk:n=!0,immutableCheck:r=!0,serializableCheck:i=!0,actionCreatorCheck:a=!0}=e??{};let o=new NK;return n&&(Nge(n)?o.push(_ge):o.push(wge(n.extraArgument))),o},MK="RTK_autoBatch",Ir=()=>t=>({payload:t,meta:{[MK]:!0}}),FB=t=>e=>{setTimeout(e,t)},EK=(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:FB(10):t.type==="callback"?t.queueNotification:FB(t.timeout),u=()=>{o=!1,a&&(a=!1,l.forEach(d=>d()))};return Object.assign({},r,{subscribe(d){const f=()=>i&&d(),m=r.subscribe(f);return l.add(d),()=>{m(),l.delete(d)}},dispatch(d){try{return i=!d?.meta?.[MK],a=!i,a&&(o||(o=!0,c(u))),r.dispatch(d)}finally{i=!0}}})},Ege=t=>function(n){const{autoBatch:r=!0}=n??{};let i=new NK(t);return r&&i.push(EK(typeof r=="object"?r:void 0)),i};function Tge(t){const e=Mge(),{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(kD(n))l=dK(n);else throw new Error(Gs(1));let c;typeof r=="function"?c=r(e):c=e();let u=Cw;i&&(u=Sge({trace:!1,...typeof i=="object"&&i}));const d=sge(...c),f=Ege(d);let m=typeof o=="function"?o(f):f();const p=u(...m);return uK(l,a,p)}function TK(t){const e={},n=[];let r;const i={addCase(a,o){const l=typeof a=="string"?a:a.type;if(!l)throw new Error(Gs(28));if(l in e)throw new Error(Gs(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 Age(t){return typeof t=="function"}function Cge(t,e){let[n,r,i]=TK(e),a;if(Age(t))a=()=>IB(t());else{const l=IB(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(lu(d)){const p=f(d,c);return p===void 0?d:p}else{if(ul(d))return wK(d,m=>f(m,c));{const m=f(d,c);if(m===void 0){if(d===null)return d;throw Error("A case reducer on a non-draftable value must not return undefined")}return m}}return d},l)}return o.getInitialState=a,o}var kge="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",jge=(t=21)=>{let e="",n=t;for(;n--;)e+=kge[Math.random()*64|0];return e},Pge=Symbol.for("rtk-slice-createasyncthunk");function Rge(t,e){return`${t}/${e}`}function Dge({creators:t}={}){const e=t?.asyncThunk?.[Pge];return function(r){const{name:i,reducerPath:a=i}=r;if(!i)throw new Error(Gs(11));const o=(typeof r.reducers=="function"?r.reducers(Lge()):r.reducers)||{},l=Object.keys(o),c={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},u={addCase(S,T){const E=typeof S=="string"?S:S.type;if(!E)throw new Error(Gs(12));if(E in c.sliceCaseReducersByType)throw new Error(Gs(13));return c.sliceCaseReducersByType[E]=T,u},addMatcher(S,T){return c.sliceMatchers.push({matcher:S,reducer:T}),u},exposeAction(S,T){return c.actionCreators[S]=T,u},exposeCaseReducer(S,T){return c.sliceCaseReducersByName[S]=T,u}};l.forEach(S=>{const T=o[S],E={reducerName:S,type:Rge(i,S),createNotation:typeof r.reducers=="function"};Fge(T)?zge(E,T,u,e):Ige(E,T,u)});function d(){const[S={},T=[],E=void 0]=typeof r.extraReducers=="function"?TK(r.extraReducers):[r.extraReducers],C={...S,...c.sliceCaseReducersByType};return Cge(r.initialState,A=>{for(let O in C)A.addCase(O,C[O]);for(let O of c.sliceMatchers)A.addMatcher(O.matcher,O.reducer);for(let O of T)A.addMatcher(O.matcher,O.reducer);E&&A.addDefaultCase(E)})}const f=S=>S,m=new Map,p=new WeakMap;let x;function y(S,T){return x||(x=d()),x(S,T)}function b(){return x||(x=d()),x.getInitialState()}function v(S,T=!1){function E(A){let O=A[S];return typeof O>"u"&&T&&(O=l_(p,E,b)),O}function C(A=f){const O=l_(m,T,()=>new WeakMap);return l_(O,A,()=>{const k={};for(const[R,F]of Object.entries(r.selectors??{}))k[R]=Oge(F,A,()=>l_(p,A,b),T);return k})}return{reducerPath:S,getSelectors:C,get selectors(){return C(E)},selectSlice:E}}const N={name:i,reducer:y,actions:c.actionCreators,caseReducers:c.sliceCaseReducersByName,getInitialState:b,...v(a),injectInto(S,{reducerPath:T,...E}={}){const C=T??a;return S.inject({reducerPath:C,reducer:y},E),{...N,...v(C,!0)}}};return N}}function Oge(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 Ss=Dge();function Lge(){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 Ige({type:t,reducerName:e,createNotation:n},r,i){let a,o;if("reducer"in r){if(n&&!Uge(r))throw new Error(Gs(17));a=r.reducer,o=r.prepare}else a=r;i.addCase(t,a).exposeCaseReducer(e,a).exposeAction(e,o?Lo(t,o):Lo(t))}function Fge(t){return t._reducerDefinitionType==="asyncThunk"}function Uge(t){return t._reducerDefinitionType==="reducerWithPrepare"}function zge({type:t,reducerName:e},n,r,i){if(!i)throw new Error(Gs(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||c_,pending:l||c_,rejected:c||c_,settled:u||c_})}function c_(){}var Bge="task",AK="listener",CK="completed",LD="cancelled",$ge=`task-${LD}`,Hge=`task-${CK}`,b3=`${AK}-${LD}`,Vge=`${AK}-${CK}`,rN=class{constructor(t){this.code=t,this.message=`${Bge} ${LD} (reason: ${t})`}name="TaskAbortError";message},ID=(t,e)=>{if(typeof t!="function")throw new TypeError(Gs(32))},Dw=()=>{},kK=(t,e=Dw)=>(t.catch(e),t),jK=(t,e)=>(t.addEventListener("abort",e,{once:!0}),()=>t.removeEventListener("abort",e)),df=(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 rN(e)}};function PK(t,e){let n=Dw;return new Promise((r,i)=>{const a=()=>i(new rN(t.reason));if(t.aborted){a();return}n=jK(t,a),e.finally(()=>n()).then(r,i)}).finally(()=>{n=Dw})}var Gge=async(t,e)=>{try{return await Promise.resolve(),{status:"ok",value:await t()}}catch(n){return{status:n instanceof rN?"cancelled":"rejected",error:n}}finally{e?.()}},Ow=t=>e=>kK(PK(t,e).then(n=>(hf(t),n))),RK=t=>{const e=Ow(t);return n=>e(new Promise(r=>setTimeout(r,n)))},{assign:Gp}=Object,UB={},iN="listenerMiddleware",Wge=(t,e)=>{const n=r=>jK(t,()=>df(r,t.reason));return(r,i)=>{ID(r);const a=new AbortController;n(a);const o=Gge(async()=>{hf(t),hf(a.signal);const l=await r({pause:Ow(a.signal),delay:RK(a.signal),signal:a.signal});return hf(a.signal),l},()=>df(a,Hge));return i?.autoJoin&&e.push(o.catch(Dw)),{result:Ow(t)(o),cancel(){df(a,$ge)}}}},qge=(t,e)=>{const n=async(r,i)=>{hf(e);let a=()=>{};const l=[new Promise((c,u)=>{let d=t({predicate:r,effect:(f,m)=>{m.unsubscribe(),c([f,m.getState(),m.getOriginalState()])}});a=()=>{d(),u()}})];i!=null&&l.push(new Promise(c=>setTimeout(c,i,null)));try{const c=await PK(e,Promise.race(l));return hf(e),c}finally{a()}};return(r,i)=>kK(n(r,i))},DK=t=>{let{type:e,actionCreator:n,matcher:r,predicate:i,effect:a}=t;if(e)i=Lo(e).match;else if(n)e=n.type,i=n.match;else if(r)i=r;else if(!i)throw new Error(Gs(21));return ID(a),{predicate:i,type:e,effect:a}},OK=Gp(t=>{const{type:e,predicate:n,effect:r}=DK(t);return{id:jge(),effect:r,type:e,predicate:n,pending:new Set,unsubscribe:()=>{throw new Error(Gs(22))}}},{withTypes:()=>OK}),zB=(t,e)=>{const{type:n,effect:r,predicate:i}=DK(e);return Array.from(t.values()).find(a=>(typeof n=="string"?a.type===n:a.predicate===i)&&a.effect===r)},y3=t=>{t.pending.forEach(e=>{df(e,b3)})},Kge=(t,e)=>()=>{for(const n of e.keys())y3(n);t.clear()},BB=(t,e,n)=>{try{t(e,n)}catch(r){setTimeout(()=>{throw r},0)}},LK=Gp(Lo(`${iN}/add`),{withTypes:()=>LK}),Xge=Lo(`${iN}/removeAll`),IK=Gp(Lo(`${iN}/remove`),{withTypes:()=>IK}),Yge=(...t)=>{console.error(`${iN}/error`,...t)},dy=(t={})=>{const e=new Map,n=new Map,r=p=>{const x=n.get(p)??0;n.set(p,x+1)},i=p=>{const x=n.get(p)??1;x===1?n.delete(p):n.set(p,x-1)},{extra:a,onError:o=Yge}=t;ID(o);const l=p=>(p.unsubscribe=()=>e.delete(p.id),e.set(p.id,p),x=>{p.unsubscribe(),x?.cancelActive&&y3(p)}),c=p=>{const x=zB(e,p)??OK(p);return l(x)};Gp(c,{withTypes:()=>c});const u=p=>{const x=zB(e,p);return x&&(x.unsubscribe(),p.cancelActive&&y3(x)),!!x};Gp(u,{withTypes:()=>u});const d=async(p,x,y,b)=>{const v=new AbortController,N=qge(c,v.signal),S=[];try{p.pending.add(v),r(p),await Promise.resolve(p.effect(x,Gp({},y,{getOriginalState:b,condition:(T,E)=>N(T,E).then(Boolean),take:N,delay:RK(v.signal),pause:Ow(v.signal),extra:a,signal:v.signal,fork:Wge(v.signal,S),unsubscribe:p.unsubscribe,subscribe:()=>{e.set(p.id,p)},cancelActiveListeners:()=>{p.pending.forEach((T,E,C)=>{T!==v&&(df(T,b3),C.delete(T))})},cancel:()=>{df(v,b3),p.pending.delete(v)},throwIfCancelled:()=>{hf(v.signal)}})))}catch(T){T instanceof rN||BB(o,T,{raisedBy:"effect"})}finally{await Promise.all(S),df(v,Vge),i(p),p.pending.delete(v)}},f=Kge(e,n);return{middleware:p=>x=>y=>{if(!hK(y))return x(y);if(LK.match(y))return c(y.payload);if(Xge.match(y)){f();return}if(IK.match(y))return u(y.payload);let b=p.getState();const v=()=>{if(b===UB)throw new Error(Gs(23));return b};let N;try{if(N=x(y),e.size>0){const S=p.getState(),T=Array.from(e.values());for(const E of T){let C=!1;try{C=E.predicate(y,S,b)}catch(A){C=!1,BB(o,A,{raisedBy:"predicate"})}C&&d(E,y,p,v)}}}finally{b=UB}return N},startListening:c,stopListening:u,clearListeners:f}};function Gs(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 Qge={layoutType:"horizontal",width:0,height:0,margin:{top:5,right:5,bottom:5,left:5},scale:1},FK=Ss({name:"chartLayout",initialState:Qge,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:Zge,setLayout:Jge,setChartSize:exe,setScale:txe}=FK.actions,nxe=FK.reducer;function UK(t,e,n){return Array.isArray(t)&&t&&e+n!==0?t.slice(e,n+1):t}function $B(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 Lp(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?$B(Object(n),!0).forEach(function(r){rxe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):$B(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function rxe(t,e,n){return(e=ixe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function ixe(t){var e=axe(t,"string");return typeof e=="symbol"?e:e+""}function axe(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 ir(t,e,n){return Pr(t)||Pr(e)?n:Oo(e)?Df(t,e,n):typeof e=="function"?e(t):n}var sxe=(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"&&Bt(t[a]))return Lp(Lp({},t),{},{[a]:t[a]+(r||0)});if((l==="horizontal"||l==="vertical"&&a==="center")&&o!=="middle"&&Bt(t[o]))return Lp(Lp({},t),{},{[o]:t[o]+(i||0)})}return t},Ql=(t,e)=>t==="horizontal"&&e==="xAxis"||t==="vertical"&&e==="yAxis"||t==="centric"&&e==="angleAxis"||t==="radial"&&e==="radiusAxis",zK=(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},BK=(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:m,axisType:p}=t;if(!o)return null;var x=l==="scaleBand"&&o.bandwidth?o.bandwidth()/2:2,y=i==="category"&&o.bandwidth?o.bandwidth()/x:0;if(y=p==="angleAxis"&&a&&a.length>=2?Ji(a[0]-a[1])*2*y:y,f||m){var b=(f||m||[]).map((v,N)=>{var S=r?r.indexOf(v):v;return{coordinate:o(S)+y,value:v,offset:y,index:N}});return b.filter(v=>!ws(v.coordinate))}return c&&u?u.map((v,N)=>({coordinate:o(v)+y,value:v,index:N,offset:y})):o.ticks&&d!=null?o.ticks(d).map((v,N)=>({coordinate:o(v)+y,value:v,offset:y,index:N})):o.domain().map((v,N)=>({coordinate:o(v)+y,value:r?r[v]:v,index:N,offset:y}))},HB=1e-4,oxe=t=>{var e=t.domain();if(!(!e||e.length<=2)){var n=e.length,r=t.range(),i=Math.min(r[0],r[1])-HB,a=Math.max(r[0],r[1])+HB,o=t(e[0]),l=t(e[n-1]);(o<i||o>a||l<i||l>a)&&t.domain([e[0],e[n-1]])}},lxe=(t,e)=>{if(!e||e.length!==2||!Bt(e[0])||!Bt(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(!Bt(t[0])||t[0]<n)&&(i[0]=n),(!Bt(t[1])||t[1]>r)&&(i[1]=r),i[0]>r&&(i[0]=r),i[1]<n&&(i[1]=n),i},cxe=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=ws(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])}},uxe=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=ws(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)}},dxe={sign:cxe,expand:Dme,none:lg,silhouette:Ome,wiggle:Lme,positive:uxe},hxe=(t,e,n)=>{var r=dxe[n],i=Rme().keys(e).value((a,o)=>Number(ir(a,o,0))).order(l3).offset(r);return i(t)};function $K(t){return t==null?void 0:String(t)}function Lw(t){var{axis:e,ticks:n,bandSize:r,entry:i,index:a,dataKey:o}=t;if(e.type==="category"){if(!e.allowDuplicatedCategory&&e.dataKey&&!Pr(i[e.dataKey])){var l=Gq(n,"value",i[e.dataKey]);if(l)return l.coordinate+r/2}return n[a]?n[a].coordinate+r/2:null}var c=ir(i,Pr(o)?e.dataKey:o);return Pr(c)?null:e.scale(c)}var VB=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=ir(a,e.dataKey,e.scale.domain()[o]);return Pr(l)?null:e.scale(l)-i/2+r},fxe=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]},mxe=t=>{var e=t.flat(2).filter(Bt);return[Math.min(...e),Math.max(...e)]},pxe=t=>[t[0]===1/0?0:t[0],t[1]===-1/0?0:t[1]],gxe=(t,e,n)=>{if(t!=null)return pxe(Object.keys(t).reduce((r,i)=>{var a=t[i],{stackedData:o}=a,l=o.reduce((c,u)=>{var d=UK(u,e,n),f=mxe(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]))},GB=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,WB=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,Hd=(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=Y2(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 qB(t){var{tooltipEntrySettings:e,dataKey:n,payload:r,value:i,name:a}=t;return Lp(Lp({},e),{},{dataKey:n,payload:r,value:i,name:a})}function ih(t,e){if(t)return String(t);if(typeof e=="string")return e}var xxe=(t,e)=>{if(e==="horizontal")return t.chartX;if(e==="vertical")return t.chartY},bxe=(t,e)=>e==="centric"?t.angle:t.radius,xu=t=>t.layout.width,bu=t=>t.layout.height,yxe=t=>t.layout.scale,HK=t=>t.layout.margin,aN=et(t=>t.cartesianAxis.xAxis,t=>Object.values(t)),sN=et(t=>t.cartesianAxis.yAxis,t=>Object.values(t)),VK="data-recharts-item-index",GK="data-recharts-item-data-key",hy=60;function KB(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function u_(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?KB(Object(n),!0).forEach(function(r){vxe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):KB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function vxe(t,e,n){return(e=_xe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function _xe(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 Sxe=t=>t.brush.height;function Nxe(t){var e=sN(t);return e.reduce((n,r)=>{if(r.orientation==="left"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:hy;return n+i}return n},0)}function Mxe(t){var e=sN(t);return e.reduce((n,r)=>{if(r.orientation==="right"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:hy;return n+i}return n},0)}function Exe(t){var e=aN(t);return e.reduce((n,r)=>r.orientation==="top"&&!r.mirror&&!r.hide?n+r.height:n,0)}function Txe(t){var e=aN(t);return e.reduce((n,r)=>r.orientation==="bottom"&&!r.mirror&&!r.hide?n+r.height:n,0)}var Ii=et([xu,bu,HK,Sxe,Nxe,Mxe,Exe,Txe,lK,Jpe],(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},m=u_(u_({},f),d),p=m.bottom;m.bottom+=r,m=sxe(m,c,u);var x=t-m.left-m.right,y=e-m.top-m.bottom;return u_(u_({brushBottom:p},m),{},{width:Math.max(x,0),height:Math.max(y,0)})}),Axe=et(Ii,t=>({x:t.left,y:t.top,width:t.width,height:t.height})),FD=et(xu,bu,(t,e)=>({x:0,y:0,width:t,height:e})),Cxe=w.createContext(null),Fi=()=>w.useContext(Cxe)!=null,oN=t=>t.brush,lN=et([oN,Ii,HK],(t,e,n)=>({height:t.height,x:Bt(t.x)?t.x:e.left,y:Bt(t.y)?t.y:e.top+e.height+e.brushBottom-(n?.bottom||0),width:Bt(t.width)?t.width:e.width})),OA={},LA={},IA={},XB;function kxe(){return XB||(XB=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(),y()};let m=null;const p=()=>{m!=null&&clearTimeout(m),m=setTimeout(()=>{m=null,f()},r)},x=()=>{m!==null&&(clearTimeout(m),m=null)},y=()=>{x(),o=void 0,l=null},b=()=>{d()},v=function(...N){if(i?.aborted)return;o=this,l=N;const S=m==null;p(),c&&S&&d()};return v.schedule=p,v.cancel=y,v.flush=b,i?.addEventListener("abort",y,{once:!0}),v}t.debounce=e})(IA)),IA}var YB;function jxe(){return YB||(YB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=kxe();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 m=e.debounce(function(...y){d=r.apply(this,y),f=null},i,{edges:u}),p=function(...y){return c!=null&&(f===null&&(f=Date.now()),Date.now()-f>=c)?(d=r.apply(this,y),f=Date.now(),m.cancel(),m.schedule(),d):(m.apply(this,y),d)},x=()=>(m.flush(),d);return p.cancel=m.cancel,p.flush=x,p}t.debounce=n})(LA)),LA}var QB;function Pxe(){return QB||(QB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=jxe();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})(OA)),OA}var FA,ZB;function Rxe(){return ZB||(ZB=1,FA=Pxe().throttle),FA}var Dxe=Rxe();const Oxe=Fo(Dxe);var Iw=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++]))}},WK=(t,e,n)=>{var{width:r="100%",height:i="100%",aspect:a,maxHeight:o}=n,l=ou(r)?t:Number(r),c=ou(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}},Lxe={width:0,height:0,overflow:"visible"},Ixe={width:0,overflowX:"visible"},Fxe={height:0,overflowY:"visible"},Uxe={},zxe=t=>{var{width:e,height:n}=t,r=ou(e),i=ou(n);return r&&i?Lxe:r?Ixe:i?Fxe:Uxe};function Bxe(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 ar(t){return Number.isFinite(t)}function Bl(t){return typeof t=="number"&&t>0&&Number.isFinite(t)}function v3(){return v3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},v3.apply(null,arguments)}function JB(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 e8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?JB(Object(n),!0).forEach(function(r){$xe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):JB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function $xe(t,e,n){return(e=Hxe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Hxe(t){var e=Vxe(t,"string");return typeof e=="symbol"?e:e+""}function Vxe(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 qK=w.createContext({width:-1,height:-1});function Gxe(t){return Bl(t.width)&&Bl(t.height)}function KK(t){var{children:e,width:n,height:r}=t,i=w.useMemo(()=>({width:n,height:r}),[n,r]);return Gxe(i)?w.createElement(qK.Provider,{value:i},e):null}var UD=()=>w.useContext(qK),Wxe=w.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:m,onResize:p,style:x={}}=t,y=w.useRef(null),b=w.useRef();b.current=p,w.useImperativeHandle(e,()=>y.current);var[v,N]=w.useState({containerWidth:r.width,containerHeight:r.height}),S=w.useCallback((O,k)=>{N(R=>{var F=Math.round(O),L=Math.round(k);return R.containerWidth===F&&R.containerHeight===L?R:{containerWidth:F,containerHeight:L}})},[]);w.useEffect(()=>{if(y.current==null||typeof ResizeObserver>"u")return oy;var O=L=>{var K,{width:j,height:W}=L[0].contentRect;S(j,W),(K=b.current)===null||K===void 0||K.call(b,j,W)};d>0&&(O=Oxe(O,d,{trailing:!0,leading:!1}));var k=new ResizeObserver(O),{width:R,height:F}=y.current.getBoundingClientRect();return S(R,F),k.observe(y.current),()=>{k.disconnect()}},[S,d]);var{containerWidth:T,containerHeight:E}=v;Iw(!n||n>0,"The aspect(%s) must be greater than zero.",n);var{calculatedWidth:C,calculatedHeight:A}=WK(T,E,{width:i,height:a,aspect:n,maxHeight:c});return Iw(C!=null&&C>0||A!=null&&A>0,`The width(%s) and height(%s) of chart should be greater than 0,
  14. please check the style of container, or the props width(%s) and height(%s),
  15. or add a minWidth(%s) or minHeight(%s) or use aspect(%s) to control the
  16. height and width.`,C,A,i,a,o,l,n),w.createElement("div",{id:f?"".concat(f):void 0,className:$n("recharts-responsive-container",m),style:e8(e8({},x),{},{width:i,height:a,minWidth:o,minHeight:l,maxHeight:c}),ref:y},w.createElement("div",{style:zxe({width:i,height:a})},w.createElement(KK,{width:C,height:A},u)))}),G1=w.forwardRef((t,e)=>{var n=UD();if(Bl(n.width)&&Bl(n.height))return t.children;var{width:r,height:i}=Bxe({width:t.width,height:t.height,aspect:t.aspect}),{calculatedWidth:a,calculatedHeight:o}=WK(void 0,void 0,{width:r,height:i,aspect:t.aspect,maxHeight:t.maxHeight});return Bt(a)&&Bt(o)?w.createElement(KK,{width:a,height:o},t.children):w.createElement(Wxe,v3({},t,{width:r,height:i,ref:e}))});function XK(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 fy=()=>{var t,e=Fi(),n=Ft(Axe),r=Ft(lN),i=(t=Ft(oN))===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}},qxe={top:0,bottom:0,left:0,right:0,width:0,height:0,brushBottom:0},YK=()=>{var t;return(t=Ft(Ii))!==null&&t!==void 0?t:qxe},zD=()=>Ft(xu),BD=()=>Ft(bu),Kxe=()=>Ft(t=>t.layout.margin),On=t=>t.layout.layoutType,Jf=()=>Ft(On),Xxe=()=>{var t=Jf();if(t==="horizontal"||t==="vertical")return t},Yxe=()=>{var t=Jf();return t!==void 0},cN=t=>{var e=wr(),n=Fi(),{width:r,height:i}=t,a=UD(),o=r,l=i;return a&&(o=a.width>0?a.width:r,l=a.height>0?a.height:i),w.useEffect(()=>{!n&&Bl(o)&&Bl(l)&&e(exe({width:o,height:l}))},[e,n,o,l]),null},QK=Symbol.for("immer-nothing"),t8=Symbol.for("immer-draftable"),Qs=Symbol.for("immer-state");function Zo(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var _0=Object.getPrototypeOf;function dg(t){return!!t&&!!t[Qs]}function Of(t){return t?ZK(t)||Array.isArray(t)||!!t[t8]||!!t.constructor?.[t8]||my(t)||dN(t):!1}var Qxe=Object.prototype.constructor.toString(),n8=new WeakMap;function ZK(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=n8.get(n);return r===void 0&&(r=Function.toString.call(n),n8.set(n,r)),r===Qxe}function Fw(t,e,n=!0){uN(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 uN(t){const e=t[Qs];return e?e.type_:Array.isArray(t)?1:my(t)?2:dN(t)?3:0}function _3(t,e){return uN(t)===2?t.has(e):Object.prototype.hasOwnProperty.call(t,e)}function JK(t,e,n){const r=uN(t);r===2?t.set(e,n):r===3?t.add(n):t[e]=n}function Zxe(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}function my(t){return t instanceof Map}function dN(t){return t instanceof Set}function $h(t){return t.copy_||t.base_}function w3(t,e){if(my(t))return new Map(t);if(dN(t))return new Set(t);if(Array.isArray(t))return Array.prototype.slice.call(t);const n=ZK(t);if(e===!0||e==="class_only"&&!n){const r=Object.getOwnPropertyDescriptors(t);delete r[Qs];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(_0(t),r)}else{const r=_0(t);if(r!==null&&n)return{...t};const i=Object.create(r);return Object.assign(i,t)}}function $D(t,e=!1){return hN(t)||dg(t)||!Of(t)||(uN(t)>1&&Object.defineProperties(t,{set:d_,add:d_,clear:d_,delete:d_}),Object.freeze(t),e&&Object.values(t).forEach(n=>$D(n,!0))),t}function Jxe(){Zo(2)}var d_={value:Jxe};function hN(t){return t===null||typeof t!="object"?!0:Object.isFrozen(t)}var ebe={};function Lf(t){const e=ebe[t];return e||Zo(0,t),e}var w0;function eX(){return w0}function tbe(t,e){return{drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function r8(t,e){e&&(Lf("Patches"),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function S3(t){N3(t),t.drafts_.forEach(nbe),t.drafts_=null}function N3(t){t===w0&&(w0=t.parent_)}function i8(t){return w0=tbe(w0,t)}function nbe(t){const e=t[Qs];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function a8(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];return t!==void 0&&t!==n?(n[Qs].modified_&&(S3(e),Zo(4)),Of(t)&&(t=Uw(e,t),e.parent_||zw(e,t)),e.patches_&&Lf("Patches").generateReplacementPatches_(n[Qs].base_,t,e.patches_,e.inversePatches_)):t=Uw(e,n,[]),S3(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==QK?t:void 0}function Uw(t,e,n){if(hN(e))return e;const r=t.immer_.shouldUseStrictIteration(),i=e[Qs];if(!i)return Fw(e,(a,o)=>s8(t,i,e,a,o,n),r),e;if(i.scope_!==t)return e;if(!i.modified_)return zw(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),Fw(o,(c,u)=>s8(t,i,a,c,u,n,l),r),zw(t,a,!1),n&&t.patches_&&Lf("Patches").generatePatches_(i,n,t.patches_,t.inversePatches_)}return i.copy_}function s8(t,e,n,r,i,a,o){if(i==null||typeof i!="object"&&!o)return;const l=hN(i);if(!(l&&!o)){if(dg(i)){const c=a&&e&&e.type_!==3&&!_3(e.assigned_,r)?a.concat(r):void 0,u=Uw(t,i,c);if(JK(n,r,u),dg(u))t.canAutoFreeze_=!1;else return}else o&&n.add(i);if(Of(i)&&!l){if(!t.immer_.autoFreeze_&&t.unfinalizedDrafts_<1||e&&e.base_&&e.base_[r]===i&&l)return;Uw(t,i),(!e||!e.scope_.parent_)&&typeof r!="symbol"&&(my(n)?n.has(r):Object.prototype.propertyIsEnumerable.call(n,r))&&zw(t,i)}}}function zw(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&$D(e,n)}function rbe(t,e){const n=Array.isArray(t),r={type_:n?1:0,scope_:e?e.scope_:eX(),modified_:!1,finalized_:!1,assigned_:{},parent_:e,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=r,a=HD;n&&(i=[r],a=S0);const{revoke:o,proxy:l}=Proxy.revocable(i,a);return r.draft_=l,r.revoke_=o,l}var HD={get(t,e){if(e===Qs)return t;const n=$h(t);if(!_3(n,e))return ibe(t,n,e);const r=n[e];return t.finalized_||!Of(r)?r:r===UA(t.base_,e)?(zA(t),t.copy_[e]=E3(r,t)):r},has(t,e){return e in $h(t)},ownKeys(t){return Reflect.ownKeys($h(t))},set(t,e,n){const r=tX($h(t),e);if(r?.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const i=UA($h(t),e),a=i?.[Qs];if(a&&a.base_===n)return t.copy_[e]=n,t.assigned_[e]=!1,!0;if(Zxe(n,i)&&(n!==void 0||_3(t.base_,e)))return!0;zA(t),M3(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 UA(t.base_,e)!==void 0||e in t.base_?(t.assigned_[e]=!1,zA(t),M3(t)):delete t.assigned_[e],t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const n=$h(t),r=Reflect.getOwnPropertyDescriptor(n,e);return r&&{writable:!0,configurable:t.type_!==1||e!=="length",enumerable:r.enumerable,value:n[e]}},defineProperty(){Zo(11)},getPrototypeOf(t){return _0(t.base_)},setPrototypeOf(){Zo(12)}},S0={};Fw(HD,(t,e)=>{S0[t]=function(){return arguments[0]=arguments[0][0],e.apply(this,arguments)}});S0.deleteProperty=function(t,e){return S0.set.call(this,t,e,void 0)};S0.set=function(t,e,n){return HD.set.call(this,t[0],e,n,t[0])};function UA(t,e){const n=t[Qs];return(n?$h(n):t)[e]}function ibe(t,e,n){const r=tX(e,n);return r?"value"in r?r.value:r.get?.call(t.draft_):void 0}function tX(t,e){if(!(e in t))return;let n=_0(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,e);if(r)return r;n=_0(n)}}function M3(t){t.modified_||(t.modified_=!0,t.parent_&&M3(t.parent_))}function zA(t){t.copy_||(t.copy_=w3(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var abe=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"&&Zo(6),r!==void 0&&typeof r!="function"&&Zo(7);let i;if(Of(e)){const a=i8(this),o=E3(e,void 0);let l=!0;try{i=n(o),l=!1}finally{l?S3(a):N3(a)}return r8(a,r),a8(i,a)}else if(!e||typeof e!="object"){if(i=n(e),i===void 0&&(i=e),i===QK&&(i=void 0),this.autoFreeze_&&$D(i,!0),r){const a=[],o=[];Lf("Patches").generateReplacementPatches_(e,i,a,o),r(a,o)}return i}else Zo(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){Of(t)||Zo(8),dg(t)&&(t=sbe(t));const e=i8(this),n=E3(t,void 0);return n[Qs].isManual_=!0,N3(e),n}finishDraft(t,e){const n=t&&t[Qs];(!n||!n.isManual_)&&Zo(9);const{scope_:r}=n;return r8(r,e),a8(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=Lf("Patches").applyPatches_;return dg(t)?r(t,e):this.produce(t,i=>r(i,e))}};function E3(t,e){const n=my(t)?Lf("MapSet").proxyMap_(t,e):dN(t)?Lf("MapSet").proxySet_(t,e):rbe(t,e);return(e?e.scope_:eX()).drafts_.push(n),n}function sbe(t){return dg(t)||Zo(10,t),nX(t)}function nX(t){if(!Of(t)||hN(t))return t;const e=t[Qs];let n,r=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=w3(t,e.scope_.immer_.useStrictShallowCopy_),r=e.scope_.immer_.shouldUseStrictIteration()}else n=w3(t,!0);return Fw(n,(i,a)=>{JK(n,i,nX(a))},r),e&&(e.finalized_=!1),n}var obe=new abe;obe.produce;var lbe={settings:{layout:"horizontal",align:"center",verticalAlign:"middle",itemSorter:"value"},size:{width:0,height:0},payload:[]},rX=Ss({name:"legend",initialState:lbe,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:Ir()},replaceLegendPayload:{reducer(t,e){var{prev:n,next:r}=e.payload,i=al(t).payload.indexOf(n);i>-1&&(t.payload[i]=r)},prepare:Ir()},removeLegendPayload:{reducer(t,e){var n=al(t).payload.indexOf(e.payload);n>-1&&t.payload.splice(n,1)},prepare:Ir()}}}),{setLegendSize:o8,setLegendSettings:cbe,addLegendPayload:iX,replaceLegendPayload:aX,removeLegendPayload:sX}=rX.actions,ube=rX.reducer,dbe=["contextPayload"];function T3(){return T3=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},T3.apply(null,arguments)}function l8(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 hg(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?l8(Object(n),!0).forEach(function(r){hbe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):l8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function hbe(t,e,n){return(e=fbe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function fbe(t){var e=mbe(t,"string");return typeof e=="symbol"?e:e+""}function mbe(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 pbe(t,e){if(t==null)return{};var n,r,i=gbe(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 gbe(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 xbe(t){return t.value}function bbe(t){var{contextPayload:e}=t,n=pbe(t,dbe),r=rK(e,t.payloadUniqBy,xbe),i=hg(hg({},n),{},{payload:r});return w.isValidElement(t.content)?w.cloneElement(t.content,i):typeof t.content=="function"?w.createElement(t.content,i):w.createElement(dpe,i)}function ybe(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}),hg(hg({},u),d)}function vbe(t){var e=wr();return w.useEffect(()=>{e(cbe(t))},[e,t]),null}function _be(t){var e=wr();return w.useEffect(()=>(e(o8(t)),()=>{e(o8({width:0,height:0}))}),[e,t]),null}function wbe(t,e,n,r){return t==="vertical"&&Bt(e)?{height:e}:t==="horizontal"?{width:n||r}:null}var Sbe={align:"center",iconSize:14,itemSorter:"value",layout:"horizontal",verticalAlign:"bottom"};function VD(t){var e=Wr(t,Sbe),n=nge(),r=rme(),i=Kxe(),{width:a,height:o,wrapperStyle:l,portal:c}=e,[u,d]=cK([n]),f=zD(),m=BD();if(f==null||m==null)return null;var p=f-(i?.left||0)-(i?.right||0),x=wbe(e.layout,o,a,p),y=c?l:hg(hg({position:"absolute",width:x?.width||a||"auto",height:x?.height||o||"auto"},ybe(l,e,i,f,m,u)),l),b=c??r;if(b==null||n==null)return null;var v=w.createElement("div",{className:"recharts-legend-wrapper",style:y,ref:d},w.createElement(vbe,{layout:e.layout,align:e.align,verticalAlign:e.verticalAlign,itemSorter:e.itemSorter}),!c&&w.createElement(_be,{width:u.width,height:u.height}),w.createElement(bbe,T3({},e,x,{margin:i,chartWidth:f,chartHeight:m,contextPayload:n})));return Hc.createPortal(v,b)}VD.displayName="Legend";function A3(){return A3=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},A3.apply(null,arguments)}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 BA(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){Nbe(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 Nbe(t,e,n){return(e=Mbe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Mbe(t){var e=Ebe(t,"string");return typeof e=="symbol"?e:e+""}function Ebe(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 Tbe(t){return Array.isArray(t)&&Oo(t[0])&&Oo(t[1])?t.join(" ~ "):t}var Abe=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:m=!1}=t,p=()=>{if(a&&a.length){var E={padding:0,margin:0},C=(l?Y2(a,l):a).map((A,O)=>{if(A.type==="none")return null;var k=A.formatter||o||Tbe,{value:R,name:F}=A,L=R,K=F;if(k){var j=k(R,F,A,O,a);if(Array.isArray(j))[L,K]=j;else if(j!=null)L=j;else return null}var W=BA({display:"block",paddingTop:4,paddingBottom:4,color:A.color||"#000"},r);return w.createElement("li",{className:"recharts-tooltip-item",key:"tooltip-item-".concat(O),style:W},Oo(K)?w.createElement("span",{className:"recharts-tooltip-item-name"},K):null,Oo(K)?w.createElement("span",{className:"recharts-tooltip-item-separator"},e):null,w.createElement("span",{className:"recharts-tooltip-item-value"},L),w.createElement("span",{className:"recharts-tooltip-item-unit"},A.unit||""))});return w.createElement("ul",{className:"recharts-tooltip-item-list",style:E},C)}return null},x=BA({margin:0,padding:10,backgroundColor:"#fff",border:"1px solid #ccc",whiteSpace:"nowrap"},n),y=BA({margin:0},i),b=!Pr(d),v=b?d:"",N=$n("recharts-default-tooltip",c),S=$n("recharts-tooltip-label",u);b&&f&&a!==void 0&&a!==null&&(v=f(d,a));var T=m?{role:"status","aria-live":"assertive"}:{};return w.createElement("div",A3({className:N,style:x},T),w.createElement("p",{className:S,style:y},w.isValidElement(v)?v:"".concat(v)),p())},Zx="recharts-tooltip-wrapper",Cbe={visibility:"hidden"};function kbe(t){var{coordinate:e,translateX:n,translateY:r}=t;return $n(Zx,{["".concat(Zx,"-right")]:Bt(n)&&e&&Bt(e.x)&&n>=e.x,["".concat(Zx,"-left")]:Bt(n)&&e&&Bt(e.x)&&n<e.x,["".concat(Zx,"-bottom")]:Bt(r)&&e&&Bt(e.y)&&r>=e.y,["".concat(Zx,"-top")]:Bt(r)&&e&&Bt(e.y)&&r<e.y})}function u8(t){var{allowEscapeViewBox:e,coordinate:n,key:r,offsetTopLeft:i,position:a,reverseDirection:o,tooltipDimension:l,viewBox:c,viewBoxDimension:u}=t;if(a&&Bt(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 m=c[r];if(m==null)return 0;if(o[r]){var p=d,x=m;return p<x?Math.max(f,m):Math.max(d,m)}if(u==null)return 0;var y=f+l,b=m+u;return y>b?Math.max(d,m):Math.max(f,m)}function jbe(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 Pbe(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=u8({allowEscapeViewBox:e,coordinate:n,key:"x",offsetTopLeft:r,position:i,reverseDirection:a,tooltipDimension:o.width,viewBox:c,viewBoxDimension:c.width}),f=u8({allowEscapeViewBox:e,coordinate:n,key:"y",offsetTopLeft:r,position:i,reverseDirection:a,tooltipDimension:o.height,viewBox:c,viewBoxDimension:c.height}),u=jbe({translateX:d,translateY:f,useTranslate3d:l})):u=Cbe,{cssProperties:u,cssClasses:kbe({translateX:d,translateY:f,coordinate:n})}}function d8(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?d8(Object(n),!0).forEach(function(r){C3(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):d8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function C3(t,e,n){return(e=Rbe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Rbe(t){var e=Dbe(t,"string");return typeof e=="symbol"?e:e+""}function Dbe(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 Obe extends w.PureComponent{constructor(){super(...arguments),C3(this,"state",{dismissed:!1,dismissedAtCoordinate:{x:0,y:0}}),C3(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:m,viewBox:p,wrapperStyle:x,lastBoundingBox:y,innerRef:b,hasPortalFromProps:v}=this.props,{cssClasses:N,cssProperties:S}=Pbe({allowEscapeViewBox:n,coordinate:o,offsetTopLeft:u,position:d,reverseDirection:f,tooltipBox:{height:y.height,width:y.width},useTranslate3d:m,viewBox:p}),T=v?{}:h_(h_({transition:c&&e?"transform ".concat(r,"ms ").concat(i):void 0},S),{},{pointerEvents:"none",visibility:!this.state.dismissed&&e&&l?"visible":"hidden",position:"absolute",top:0,left:0}),E=h_(h_({},T),{},{visibility:!this.state.dismissed&&e&&l?"visible":"hidden"},x);return w.createElement("div",{xmlns:"http://www.w3.org/1999/xhtml",tabIndex:-1,className:N,style:E,ref:b},a)}}var oX=()=>{var t;return(t=Ft(e=>e.rootProps.accessibilityLayer))!==null&&t!==void 0?t:!0};function k3(){return k3=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},k3.apply(null,arguments)}function h8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function f8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?h8(Object(n),!0).forEach(function(r){Lbe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):h8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Lbe(t,e,n){return(e=Ibe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Ibe(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)}var m8={curveBasisClosed:wme,curveBasisOpen:Sme,curveBasis:_me,curveBumpX:ome,curveBumpY:lme,curveLinearClosed:Nme,curveLinear:K2,curveMonotoneX:Mme,curveMonotoneY:Eme,curveNatural:Tme,curveStep:Ame,curveStepAfter:kme,curveStepBefore:Cme},Bw=t=>ar(t.x)&&ar(t.y),p8=t=>t.base!=null&&Bw(t.base)&&Bw(t),Jx=t=>t.x,eb=t=>t.y,Ube=(t,e)=>{if(typeof t=="function")return t;var n="curve".concat(sy(t));return(n==="curveMonotone"||n==="curveBump")&&e?m8["".concat(n).concat(e==="vertical"?"Y":"X")]:m8[n]||K2},zbe=t=>{var{type:e="linear",points:n=[],baseLine:r,layout:i,connectNulls:a=!1}=t,o=Ube(e,i),l=a?n.filter(Bw):n,c;if(Array.isArray(r)){var u=n.map((p,x)=>f8(f8({},p),{},{base:r[x]}));i==="vertical"?c=i_().y(eb).x1(Jx).x0(p=>p.base.x):c=i_().x(Jx).y1(eb).y0(p=>p.base.y);var d=c.defined(p8).curve(o),f=a?u.filter(p8):u;return d(f)}i==="vertical"&&Bt(r)?c=i_().y(eb).x1(Jx).x0(r):Bt(r)?c=i_().x(Jx).y1(eb).y0(r):c=Pq().x(Jx).y(eb);var m=c.defined(Bw).curve(o);return m(l)},Wp=t=>{var{className:e,points:n,path:r,pathRef:i}=t;if((!n||!n.length)&&!r)return null;var a=n&&n.length?zbe(t):r;return w.createElement("path",k3({},Qa(t),TD(t),{className:$n("recharts-curve",e),d:a===null?void 0:a,ref:i}))},Bbe=["x","y","top","left","width","height","className"];function j3(){return j3=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},j3.apply(null,arguments)}function g8(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 $be(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?g8(Object(n),!0).forEach(function(r){Hbe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):g8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Hbe(t,e,n){return(e=Vbe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Vbe(t){var e=Gbe(t,"string");return typeof e=="symbol"?e:e+""}function Gbe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Wbe(t,e){if(t==null)return{};var n,r,i=qbe(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 qbe(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 Kbe=(t,e,n,r,i,a)=>"M".concat(t,",").concat(i,"v").concat(r,"M").concat(a,",").concat(e,"h").concat(n),Xbe=t=>{var{x:e=0,y:n=0,top:r=0,left:i=0,width:a=0,height:o=0,className:l}=t,c=Wbe(t,Bbe),u=$be({x:e,y:n,top:r,left:i,width:a,height:o},c);return!Bt(e)||!Bt(n)||!Bt(a)||!Bt(o)||!Bt(r)||!Bt(i)?null:w.createElement("path",j3({},Sa(u),{className:$n("recharts-cross",l),d:Kbe(e,n,a,o,r,i)}))};function Ybe(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 x8(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 b8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?x8(Object(n),!0).forEach(function(r){Qbe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):x8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Qbe(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=Jbe(t,"string");return typeof e=="symbol"?e:e+""}function Jbe(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 e0e=t=>t.replace(/([A-Z])/g,e=>"-".concat(e.toLowerCase())),lX=(t,e,n)=>t.map(r=>"".concat(e0e(r)," ").concat(e,"ms ").concat(n)).join(","),t0e=(t,e)=>[Object.keys(t),Object.keys(e)].reduce((n,r)=>n.filter(i=>r.includes(i))),N0=(t,e)=>Object.keys(e).reduce((n,r)=>b8(b8({},n),{},{[r]:t(r,e[r])}),{});function y8(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 Ci(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?y8(Object(n),!0).forEach(function(r){n0e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):y8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function n0e(t,e,n){return(e=r0e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function r0e(t){var e=i0e(t,"string");return typeof e=="symbol"?e:e+""}function i0e(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 $w=(t,e,n)=>t+(e-t)*n,P3=t=>{var{from:e,to:n}=t;return e!==n},cX=(t,e,n)=>{var r=N0((i,a)=>{if(P3(a)){var[o,l]=t(a.from,a.to,a.velocity);return Ci(Ci({},a),{},{from:o,velocity:l})}return a},e);return n<1?N0((i,a)=>P3(a)?Ci(Ci({},a),{},{velocity:$w(a.velocity,r[i].velocity,n),from:$w(a.from,r[i].from,n)}):a,e):cX(t,r,n-1)};function a0e(t,e,n,r,i,a){var o,l=r.reduce((m,p)=>Ci(Ci({},m),{},{[p]:{from:t[p],velocity:0,to:e[p]}}),{}),c=()=>N0((m,p)=>p.from,l),u=()=>!Object.values(l).filter(P3).length,d=null,f=m=>{o||(o=m);var p=m-o,x=p/n.dt;l=cX(n,l,x),i(Ci(Ci(Ci({},t),e),c())),o=m,u()||(d=a.setTimeout(f))};return()=>(d=a.setTimeout(f),()=>{var m;(m=d)===null||m===void 0||m()})}function s0e(t,e,n,r,i,a,o){var l=null,c=i.reduce((f,m)=>Ci(Ci({},f),{},{[m]:[t[m],e[m]]}),{}),u,d=f=>{u||(u=f);var m=(f-u)/r,p=N0((y,b)=>$w(...b,n(m)),c);if(a(Ci(Ci(Ci({},t),e),p)),m<1)l=o.setTimeout(d);else{var x=N0((y,b)=>$w(...b,n(1)),c);a(Ci(Ci(Ci({},t),e),x))}};return()=>(l=o.setTimeout(d),()=>{var f;(f=l)===null||f===void 0||f()})}const o0e=(t,e,n,r,i,a)=>{var o=t0e(t,e);return n==null?()=>(i(Ci(Ci({},t),e)),()=>{}):n.isStepper===!0?a0e(t,e,n,o,i,a):s0e(t,e,n,r,o,i,a)};var Hw=1e-4,uX=(t,e)=>[0,3*t,3*e-6*t,3*t-3*e+1],dX=(t,e)=>t.map((n,r)=>n*e**r).reduce((n,r)=>n+r),v8=(t,e)=>n=>{var r=uX(t,e);return dX(r,n)},l0e=(t,e)=>n=>{var r=uX(t,e),i=[...r.map((a,o)=>a*o).slice(1),0];return dX(i,n)},c0e=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]},u0e=(t,e,n,r)=>{var i=v8(t,n),a=v8(e,r),o=l0e(t,n),l=u=>u>1?1:u<0?0:u,c=u=>{for(var d=u>1?1:u,f=d,m=0;m<8;++m){var p=i(f)-d,x=o(f);if(Math.abs(p-d)<Hw||x<Hw)return a(f);f=l(f-p/x)}return a(f)};return c.isStepper=!1,c},_8=function(){return u0e(...c0e(...arguments))},d0e=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,m=c*i/1e3+o;return Math.abs(m-l)<Hw&&Math.abs(f)<Hw?[l,0]:[m,f]};return a.isStepper=!0,a.dt=i,a},h0e=t=>{if(typeof t=="string")switch(t){case"ease":case"ease-in-out":case"ease-out":case"ease-in":case"linear":return _8(t);case"spring":return d0e();default:if(t.split("(")[0]==="cubic-bezier")return _8(t)}return typeof t=="function"?t:null};function f0e(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 m0e{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 p0e(){return f0e(new m0e)}var g0e=w.createContext(p0e);function x0e(t,e){var n=w.useContext(g0e);return w.useMemo(()=>e??n(t),[t,e,n])}var b0e=()=>!(typeof window<"u"&&window.document&&window.document.createElement&&window.setTimeout),Bg={devToolsEnabled:!1,isSsr:b0e()},y0e={begin:0,duration:1e3,easing:"ease",isActive:!0,canBegin:!0,onAnimationEnd:()=>{},onAnimationStart:()=>{}},w8={t:0},$A={t:1};function $g(t){var e=Wr(t,y0e),{isActive:n,canBegin:r,duration:i,easing:a,begin:o,onAnimationEnd:l,onAnimationStart:c,children:u}=e,d=n==="auto"?!Bg.isSsr:n,f=x0e(e.animationId,e.animationManager),[m,p]=w.useState(d?w8:$A),x=w.useRef(null);return w.useEffect(()=>{d||p($A)},[d]),w.useEffect(()=>{if(!d||!r)return oy;var y=o0e(w8,$A,h0e(a),i,p,f.getTimeoutController()),b=()=>{x.current=y()};return f.start([c,o,b,i,l]),()=>{f.stop(),x.current&&x.current(),l()}},[d,r,i,a,o,c,l,f]),u(m.t)}function Hg(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"animation-",n=w.useRef(x0(e)),r=w.useRef(t);return r.current!==t&&(n.current=x0(e),r.current=t),n.current}var v0e=["radius"],_0e=["radius"];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 N8(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){w0e(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 w0e(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=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)}function Vw(){return Vw=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},Vw.apply(null,arguments)}function M8(t,e){if(t==null)return{};var n,r,i=M0e(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 M0e(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 E8=(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,m=4;f<m;f++)d[f]=i[f]>a?a:i[f];u="M".concat(t,",").concat(e+o*d[0]),d[0]>0&&(u+="A ".concat(d[0],",").concat(d[0],",0,0,").concat(c,",").concat(t+l*d[0],",").concat(e)),u+="L ".concat(t+n-l*d[1],",").concat(e),d[1]>0&&(u+="A ".concat(d[1],",").concat(d[1],",0,0,").concat(c,`,
  17. `).concat(t+n,",").concat(e+o*d[1])),u+="L ".concat(t+n,",").concat(e+r-o*d[2]),d[2]>0&&(u+="A ".concat(d[2],",").concat(d[2],",0,0,").concat(c,`,
  18. `).concat(t+n-l*d[2],",").concat(e+r)),u+="L ".concat(t+l*d[3],",").concat(e+r),d[3]>0&&(u+="A ".concat(d[3],",").concat(d[3],",0,0,").concat(c,`,
  19. `).concat(t,",").concat(e+r-o*d[3])),u+="Z"}else if(a>0&&i===+i&&i>0){var p=Math.min(a,i);u="M ".concat(t,",").concat(e+o*p,`
  20. A `).concat(p,",").concat(p,",0,0,").concat(c,",").concat(t+l*p,",").concat(e,`
  21. L `).concat(t+n-l*p,",").concat(e,`
  22. A `).concat(p,",").concat(p,",0,0,").concat(c,",").concat(t+n,",").concat(e+o*p,`
  23. L `).concat(t+n,",").concat(e+r-o*p,`
  24. A `).concat(p,",").concat(p,",0,0,").concat(c,",").concat(t+n-l*p,",").concat(e+r,`
  25. L `).concat(t+l*p,",").concat(e+r,`
  26. A `).concat(p,",").concat(p,",0,0,").concat(c,",").concat(t,",").concat(e+r-o*p," Z")}else u="M ".concat(t,",").concat(e," h ").concat(n," v ").concat(r," h ").concat(-n," Z");return u},T8={x:0,y:0,width:0,height:0,radius:0,isAnimationActive:!1,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},hX=t=>{var e=Wr(t,T8),n=w.useRef(null),[r,i]=w.useState(-1);w.useEffect(()=>{if(n.current&&n.current.getTotalLength)try{var q=n.current.getTotalLength();q&&i(q)}catch{}},[]);var{x:a,y:o,width:l,height:c,radius:u,className:d}=e,{animationEasing:f,animationDuration:m,animationBegin:p,isAnimationActive:x,isUpdateAnimationActive:y}=e,b=w.useRef(l),v=w.useRef(c),N=w.useRef(a),S=w.useRef(o),T=w.useMemo(()=>({x:a,y:o,width:l,height:c,radius:u}),[a,o,l,c,u]),E=Hg(T,"rectangle-");if(a!==+a||o!==+o||l!==+l||c!==+c||l===0||c===0)return null;var C=$n("recharts-rectangle",d);if(!y){var A=Sa(e),{radius:O}=A,k=M8(A,v0e);return w.createElement("path",Vw({},k,{radius:typeof u=="number"?u:void 0,className:C,d:E8(a,o,l,c,u)}))}var R=b.current,F=v.current,L=N.current,K=S.current,j="0px ".concat(r===-1?1:r,"px"),W="".concat(r,"px 0px"),Y=lX(["strokeDasharray"],m,typeof f=="string"?f:T8.animationEasing);return w.createElement($g,{animationId:E,key:E,canBegin:r>0,duration:m,easing:f,isActive:y,begin:p},q=>{var Q=Zn(R,l,q),ee=Zn(F,c,q),re=Zn(L,a,q),z=Zn(K,o,q);n.current&&(b.current=Q,v.current=ee,N.current=re,S.current=z);var G;x?q>0?G={transition:Y,strokeDasharray:W}:G={strokeDasharray:j}:G={strokeDasharray:W};var ae=Sa(e),{radius:se}=ae,ue=M8(ae,_0e);return w.createElement("path",Vw({},ue,{radius:typeof u=="number"?u:void 0,className:C,d:E8(re,z,Q,ee,u),ref:n,style:N8(N8({},G),e.style)}))})};function A8(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 C8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?A8(Object(n),!0).forEach(function(r){E0e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):A8(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=A0e(t,"string");return typeof e=="symbol"?e:e+""}function A0e(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 Gw=Math.PI/180,C0e=t=>t*180/Math.PI,wi=(t,e,n,r)=>({x:t+Math.cos(-Gw*r)*n,y:e+Math.sin(-Gw*r)*n}),fX=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},k0e=(t,e)=>{var{x:n,y:r}=t,{x:i,y:a}=e;return Math.sqrt((n-i)**2+(r-a)**2)},j0e=(t,e)=>{var{x:n,y:r}=t,{cx:i,cy:a}=e,o=k0e({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:C0e(c),angleInRadian:c}},P0e=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}},R0e=(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},D0e=(t,e)=>{var{chartX:n,chartY:r}=t,{radius:i,angle:a}=j0e({x:n,y:r},e),{innerRadius:o,outerRadius:l}=e;if(i<o||i>l||i===0)return null;var{startAngle:c,endAngle:u}=P0e(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?C8(C8({},e),{},{radius:i,angle:R0e(d,e)}):null};function mX(t){var{cx:e,cy:n,radius:r,startAngle:i,endAngle:a}=t,o=wi(e,n,r,i),l=wi(e,n,r,a);return{points:[o,l],cx:e,cy:n,radius:r,startAngle:i,endAngle:a}}function R3(){return R3=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},R3.apply(null,arguments)}var O0e=(t,e)=>{var n=Ji(e-t),r=Math.min(Math.abs(e-t),359.999);return n*r},f_=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)/Gw,f=c?i:i+a*d,m=wi(e,n,u,f),p=wi(e,n,r,f),x=c?i-a*d:i,y=wi(e,n,u*Math.cos(d*Gw),x);return{center:m,circleTangency:p,lineTangency:y,theta:d}},pX=t=>{var{cx:e,cy:n,innerRadius:r,outerRadius:i,startAngle:a,endAngle:o}=t,l=O0e(a,o),c=a+l,u=wi(e,n,i,a),d=wi(e,n,i,c),f="M ".concat(u.x,",").concat(u.y,`
  27. A `).concat(i,",").concat(i,`,0,
  28. `).concat(+(Math.abs(l)>180),",").concat(+(a>c),`,
  29. `).concat(d.x,",").concat(d.y,`
  30. `);if(r>0){var m=wi(e,n,r,a),p=wi(e,n,r,c);f+="L ".concat(p.x,",").concat(p.y,`
  31. A `).concat(r,",").concat(r,`,0,
  32. `).concat(+(Math.abs(l)>180),",").concat(+(a<=c),`,
  33. `).concat(m.x,",").concat(m.y," Z")}else f+="L ".concat(e,",").concat(n," Z");return f},L0e=t=>{var{cx:e,cy:n,innerRadius:r,outerRadius:i,cornerRadius:a,forceCornerRadius:o,cornerIsExternal:l,startAngle:c,endAngle:u}=t,d=Ji(u-c),{circleTangency:f,lineTangency:m,theta:p}=f_({cx:e,cy:n,radius:i,angle:c,sign:d,cornerRadius:a,cornerIsExternal:l}),{circleTangency:x,lineTangency:y,theta:b}=f_({cx:e,cy:n,radius:i,angle:u,sign:-d,cornerRadius:a,cornerIsExternal:l}),v=l?Math.abs(c-u):Math.abs(c-u)-p-b;if(v<0)return o?"M ".concat(m.x,",").concat(m.y,`
  34. a`).concat(a,",").concat(a,",0,0,1,").concat(a*2,`,0
  35. a`).concat(a,",").concat(a,",0,0,1,").concat(-a*2,`,0
  36. `):pX({cx:e,cy:n,innerRadius:r,outerRadius:i,startAngle:c,endAngle:u});var N="M ".concat(m.x,",").concat(m.y,`
  37. A`).concat(a,",").concat(a,",0,0,").concat(+(d<0),",").concat(f.x,",").concat(f.y,`
  38. A`).concat(i,",").concat(i,",0,").concat(+(v>180),",").concat(+(d<0),",").concat(x.x,",").concat(x.y,`
  39. A`).concat(a,",").concat(a,",0,0,").concat(+(d<0),",").concat(y.x,",").concat(y.y,`
  40. `);if(r>0){var{circleTangency:S,lineTangency:T,theta:E}=f_({cx:e,cy:n,radius:r,angle:c,sign:d,isExternal:!0,cornerRadius:a,cornerIsExternal:l}),{circleTangency:C,lineTangency:A,theta:O}=f_({cx:e,cy:n,radius:r,angle:u,sign:-d,isExternal:!0,cornerRadius:a,cornerIsExternal:l}),k=l?Math.abs(c-u):Math.abs(c-u)-E-O;if(k<0&&a===0)return"".concat(N,"L").concat(e,",").concat(n,"Z");N+="L".concat(A.x,",").concat(A.y,`
  41. A`).concat(a,",").concat(a,",0,0,").concat(+(d<0),",").concat(C.x,",").concat(C.y,`
  42. A`).concat(r,",").concat(r,",0,").concat(+(k>180),",").concat(+(d>0),",").concat(S.x,",").concat(S.y,`
  43. A`).concat(a,",").concat(a,",0,0,").concat(+(d<0),",").concat(T.x,",").concat(T.y,"Z")}else N+="L".concat(e,",").concat(n,"Z");return N},I0e={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},gX=t=>{var e=Wr(t,I0e),{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 m=$n("recharts-sector",f),p=a-i,x=Oa(o,p,0,!0),y;return x>0&&Math.abs(u-d)<360?y=L0e({cx:n,cy:r,innerRadius:i,outerRadius:a,cornerRadius:Math.min(x,p/2),forceCornerRadius:l,cornerIsExternal:c,startAngle:u,endAngle:d}):y=pX({cx:n,cy:r,innerRadius:i,outerRadius:a,startAngle:u,endAngle:d}),w.createElement("path",R3({},Sa(e),{className:m,d:y}))};function F0e(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(qq(e)){if(t==="centric"){var{cx:r,cy:i,innerRadius:a,outerRadius:o,angle:l}=e,c=wi(r,i,a,l),u=wi(r,i,o,l);return[{x:c.x,y:c.y},{x:u.x,y:u.y}]}return mX(e)}}var HA={},VA={},GA={},k8;function U0e(){return k8||(k8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=sK();function n(r){return e.isSymbol(r)?NaN:Number(r)}t.toNumber=n})(GA)),GA}var j8;function z0e(){return j8||(j8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=U0e();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})(VA)),VA}var P8;function B0e(){return P8||(P8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=oK(),n=z0e();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})(HA)),HA}var WA,R8;function $0e(){return R8||(R8=1,WA=B0e().range),WA}var H0e=$0e();const xX=Fo(H0e);function Pd(t,e){return t==null||e==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function V0e(t,e){return t==null||e==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function GD(t){let e,n,r;t.length!==2?(e=Pd,n=(l,c)=>Pd(t(l),c),r=(l,c)=>t(l)-c):(e=t===Pd||t===V0e?t:G0e,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 G0e(){return 0}function bX(t){return t===null?NaN:+t}function*W0e(t,e){for(let n of t)n!=null&&(n=+n)>=n&&(yield n)}const q0e=GD(Pd),py=q0e.right;GD(bX).center;class D8 extends Map{constructor(e,n=Y0e){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(O8(this,e))}has(e){return super.has(O8(this,e))}set(e,n){return super.set(K0e(this,e),n)}delete(e){return super.delete(X0e(this,e))}}function O8({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):n}function K0e({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):(t.set(r,n),n)}function X0e({_intern:t,_key:e},n){const r=e(n);return t.has(r)&&(n=t.get(r),t.delete(r)),n}function Y0e(t){return t!==null&&typeof t=="object"?t.valueOf():t}function Q0e(t=Pd){if(t===Pd)return yX;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 yX(t,e){return(t==null||!(t>=t))-(e==null||!(e>=e))||(t<e?-1:t>e?1:0)}const Z0e=Math.sqrt(50),J0e=Math.sqrt(10),eye=Math.sqrt(2);function Ww(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>=Z0e?10:a>=J0e?5:a>=eye?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?Ww(t,e,n*2):[l,c,u]}function D3(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?Ww(e,t,n):Ww(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 O3(t,e,n){return e=+e,t=+t,n=+n,Ww(t,e,n)[2]}function L3(t,e,n){e=+e,t=+t,n=+n;const r=e<t,i=r?O3(e,t,n):O3(t,e,n);return(r?-1:1)*(i<0?1/-i:i)}function L8(t,e){let n;for(const r of t)r!=null&&(n<r||n===void 0&&r>=r)&&(n=r);return n}function I8(t,e){let n;for(const r of t)r!=null&&(n>r||n===void 0&&r>=r)&&(n=r);return n}function vX(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?yX:Q0e(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),m=.5*Math.sqrt(d*f*(c-f)/c)*(u-c/2<0?-1:1),p=Math.max(n,Math.floor(e-u*f/c+m)),x=Math.min(r,Math.floor(e+(c-u)*f/c+m));vX(t,e,p,x,i)}const a=t[e];let o=n,l=r;for(tb(t,n,e),i(t[r],a)>0&&tb(t,n,r);o<l;){for(tb(t,o,l),++o,--l;i(t[o],a)<0;)++o;for(;i(t[l],a)>0;)--l}i(t[n],a)===0?tb(t,n,l):(++l,tb(t,l,r)),l<=e&&(n=l+1),e<=l&&(r=l-1)}return t}function tb(t,e,n){const r=t[e];t[e]=t[n],t[n]=r}function tye(t,e,n){if(t=Float64Array.from(W0e(t)),!(!(r=t.length)||isNaN(e=+e))){if(e<=0||r<2)return I8(t);if(e>=1)return L8(t);var r,i=(r-1)*e,a=Math.floor(i),o=L8(vX(t,a).subarray(0,a+1)),l=I8(t.subarray(a+1));return o+(l-o)*(i-a)}}function nye(t,e,n=bX){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 rye(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 zo(t,e){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(e).domain(t);break}return this}function yu(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 I3=Symbol("implicit");function WD(){var t=new D8,e=[],n=[],r=I3;function i(a){let o=t.get(a);if(o===void 0){if(r!==I3)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 D8;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 WD(e,n).unknown(r)},zo.apply(i,arguments),i}function qD(){var t=WD().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 m=e().length,p=i<r,x=p?i:r,y=p?r:i;a=(y-x)/Math.max(1,m-c+u*2),l&&(a=Math.floor(a)),x+=(y-x-a*(m-c))*d,o=a*(1-c),l&&(x=Math.round(x),o=Math.round(o));var b=rye(m).map(function(v){return x+a*v});return n(p?b.reverse():b)}return t.domain=function(m){return arguments.length?(e(m),f()):e()},t.range=function(m){return arguments.length?([r,i]=m,r=+r,i=+i,f()):[r,i]},t.rangeRound=function(m){return[r,i]=m,r=+r,i=+i,l=!0,f()},t.bandwidth=function(){return o},t.step=function(){return a},t.round=function(m){return arguments.length?(l=!!m,f()):l},t.padding=function(m){return arguments.length?(c=Math.min(1,u=+m),f()):c},t.paddingInner=function(m){return arguments.length?(c=Math.min(1,m),f()):c},t.paddingOuter=function(m){return arguments.length?(u=+m,f()):u},t.align=function(m){return arguments.length?(d=Math.max(0,Math.min(1,m)),f()):d},t.copy=function(){return qD(e(),[r,i]).round(l).paddingInner(c).paddingOuter(u).align(d)},zo.apply(f(),arguments)}function _X(t){var e=t.copy;return t.padding=t.paddingOuter,delete t.paddingInner,delete t.paddingOuter,t.copy=function(){return _X(e())},t}function iye(){return _X(qD.apply(null,arguments).paddingInner(1))}function KD(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function wX(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function gy(){}var M0=.7,qw=1/M0,qp="\\s*([+-]?\\d+)\\s*",E0="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Ll="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",aye=/^#([0-9a-f]{3,8})$/,sye=new RegExp(`^rgb\\(${qp},${qp},${qp}\\)$`),oye=new RegExp(`^rgb\\(${Ll},${Ll},${Ll}\\)$`),lye=new RegExp(`^rgba\\(${qp},${qp},${qp},${E0}\\)$`),cye=new RegExp(`^rgba\\(${Ll},${Ll},${Ll},${E0}\\)$`),uye=new RegExp(`^hsl\\(${E0},${Ll},${Ll}\\)$`),dye=new RegExp(`^hsla\\(${E0},${Ll},${Ll},${E0}\\)$`),F8={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};KD(gy,T0,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:U8,formatHex:U8,formatHex8:hye,formatHsl:fye,formatRgb:z8,toString:z8});function U8(){return this.rgb().formatHex()}function hye(){return this.rgb().formatHex8()}function fye(){return SX(this).formatHsl()}function z8(){return this.rgb().formatRgb()}function T0(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=aye.exec(t))?(n=e[1].length,e=parseInt(e[1],16),n===6?B8(e):n===3?new xs(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):n===8?m_(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):n===4?m_(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|e&240,((e&15)<<4|e&15)/255):null):(e=sye.exec(t))?new xs(e[1],e[2],e[3],1):(e=oye.exec(t))?new xs(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=lye.exec(t))?m_(e[1],e[2],e[3],e[4]):(e=cye.exec(t))?m_(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=uye.exec(t))?V8(e[1],e[2]/100,e[3]/100,1):(e=dye.exec(t))?V8(e[1],e[2]/100,e[3]/100,e[4]):F8.hasOwnProperty(t)?B8(F8[t]):t==="transparent"?new xs(NaN,NaN,NaN,0):null}function B8(t){return new xs(t>>16&255,t>>8&255,t&255,1)}function m_(t,e,n,r){return r<=0&&(t=e=n=NaN),new xs(t,e,n,r)}function mye(t){return t instanceof gy||(t=T0(t)),t?(t=t.rgb(),new xs(t.r,t.g,t.b,t.opacity)):new xs}function F3(t,e,n,r){return arguments.length===1?mye(t):new xs(t,e,n,r??1)}function xs(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}KD(xs,F3,wX(gy,{brighter(t){return t=t==null?qw:Math.pow(qw,t),new xs(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?M0:Math.pow(M0,t),new xs(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new xs(ff(this.r),ff(this.g),ff(this.b),Kw(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:$8,formatHex:$8,formatHex8:pye,formatRgb:H8,toString:H8}));function $8(){return`#${ef(this.r)}${ef(this.g)}${ef(this.b)}`}function pye(){return`#${ef(this.r)}${ef(this.g)}${ef(this.b)}${ef((isNaN(this.opacity)?1:this.opacity)*255)}`}function H8(){const t=Kw(this.opacity);return`${t===1?"rgb(":"rgba("}${ff(this.r)}, ${ff(this.g)}, ${ff(this.b)}${t===1?")":`, ${t})`}`}function Kw(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function ff(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function ef(t){return t=ff(t),(t<16?"0":"")+t.toString(16)}function V8(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new Jo(t,e,n,r)}function SX(t){if(t instanceof Jo)return new Jo(t.h,t.s,t.l,t.opacity);if(t instanceof gy||(t=T0(t)),!t)return new Jo;if(t instanceof Jo)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 Jo(o,l,c,t.opacity)}function gye(t,e,n,r){return arguments.length===1?SX(t):new Jo(t,e,n,r??1)}function Jo(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}KD(Jo,gye,wX(gy,{brighter(t){return t=t==null?qw:Math.pow(qw,t),new Jo(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?M0:Math.pow(M0,t),new Jo(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 xs(qA(t>=240?t-240:t+120,i,r),qA(t,i,r),qA(t<120?t+240:t-120,i,r),this.opacity)},clamp(){return new Jo(G8(this.h),p_(this.s),p_(this.l),Kw(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=Kw(this.opacity);return`${t===1?"hsl(":"hsla("}${G8(this.h)}, ${p_(this.s)*100}%, ${p_(this.l)*100}%${t===1?")":`, ${t})`}`}}));function G8(t){return t=(t||0)%360,t<0?t+360:t}function p_(t){return Math.max(0,Math.min(1,t||0))}function qA(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 XD=t=>()=>t;function xye(t,e){return function(n){return t+n*e}}function bye(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 yye(t){return(t=+t)==1?NX:function(e,n){return n-e?bye(e,n,t):XD(isNaN(e)?n:e)}}function NX(t,e){var n=e-t;return n?xye(t,n):XD(isNaN(t)?e:t)}const W8=(function t(e){var n=yye(e);function r(i,a){var o=n((i=F3(i)).r,(a=F3(a)).r),l=n(i.g,a.g),c=n(i.b,a.b),u=NX(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 vye(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 _ye(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function wye(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]=Vg(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 Sye(t,e){var n=new Date;return t=+t,e=+e,function(r){return n.setTime(t*(1-r)+e*r),n}}function Xw(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}function Nye(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]=Vg(t[i],e[i]):r[i]=e[i];return function(a){for(i in n)r[i]=n[i](a);return r}}var U3=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,KA=new RegExp(U3.source,"g");function Mye(t){return function(){return t}}function Eye(t){return function(e){return t(e)+""}}function Tye(t,e){var n=U3.lastIndex=KA.lastIndex=0,r,i,a,o=-1,l=[],c=[];for(t=t+"",e=e+"";(r=U3.exec(t))&&(i=KA.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:Xw(r,i)})),n=KA.lastIndex;return n<e.length&&(a=e.slice(n),l[o]?l[o]+=a:l[++o]=a),l.length<2?c[0]?Eye(c[0].x):Mye(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 Vg(t,e){var n=typeof e,r;return e==null||n==="boolean"?XD(e):(n==="number"?Xw:n==="string"?(r=T0(e))?(e=r,W8):Tye:e instanceof T0?W8:e instanceof Date?Sye:_ye(e)?vye:Array.isArray(e)?wye:typeof e.valueOf!="function"&&typeof e.toString!="function"||isNaN(e)?Nye:Xw)(t,e)}function YD(t,e){return t=+t,e=+e,function(n){return Math.round(t*(1-n)+e*n)}}function Aye(t,e){e===void 0&&(e=t,t=Vg);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 Cye(t){return function(){return t}}function Yw(t){return+t}var q8=[0,1];function Wa(t){return t}function z3(t,e){return(e-=t=+t)?function(n){return(n-t)/e}:Cye(isNaN(e)?NaN:.5)}function kye(t,e){var n;return t>e&&(n=t,t=e,e=n),function(r){return Math.max(t,Math.min(e,r))}}function jye(t,e,n){var r=t[0],i=t[1],a=e[0],o=e[1];return i<r?(r=z3(i,r),a=n(o,a)):(r=z3(r,i),a=n(a,o)),function(l){return a(r(l))}}function Pye(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]=z3(t[o],t[o+1]),a[o]=n(e[o],e[o+1]);return function(l){var c=py(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 fN(){var t=q8,e=q8,n=Vg,r,i,a,o=Wa,l,c,u;function d(){var m=Math.min(t.length,e.length);return o!==Wa&&(o=kye(t[0],t[m-1])),l=m>2?Pye:jye,c=u=null,f}function f(m){return m==null||isNaN(m=+m)?a:(c||(c=l(t.map(r),e,n)))(r(o(m)))}return f.invert=function(m){return o(i((u||(u=l(e,t.map(r),Xw)))(m)))},f.domain=function(m){return arguments.length?(t=Array.from(m,Yw),d()):t.slice()},f.range=function(m){return arguments.length?(e=Array.from(m),d()):e.slice()},f.rangeRound=function(m){return e=Array.from(m),n=YD,d()},f.clamp=function(m){return arguments.length?(o=m?!0:Wa,d()):o!==Wa},f.interpolate=function(m){return arguments.length?(n=m,d()):n},f.unknown=function(m){return arguments.length?(a=m,f):a},function(m,p){return r=m,i=p,d()}}function QD(){return fN()(Wa,Wa)}function Rye(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)}function Qw(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 fg(t){return t=Qw(Math.abs(t)),t?t[1]:NaN}function Dye(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 Oye(t){return function(e){return e.replace(/[0-9]/g,function(n){return t[+n]})}}var Lye=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function A0(t){if(!(e=Lye.exec(t)))throw new Error("invalid format: "+t);var e;return new ZD({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]})}A0.prototype=ZD.prototype;function ZD(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+""}ZD.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 Iye(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 MX;function Fye(t,e){var n=Qw(t,e);if(!n)return t+"";var r=n[0],i=n[1],a=i-(MX=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")+Qw(t,Math.max(0,e+a-1))[0]}function K8(t,e){var n=Qw(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 X8={"%":(t,e)=>(t*100).toFixed(e),b:t=>Math.round(t).toString(2),c:t=>t+"",d:Rye,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)=>K8(t*100,e),r:K8,s:Fye,X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function Y8(t){return t}var Q8=Array.prototype.map,Z8=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function Uye(t){var e=t.grouping===void 0||t.thousands===void 0?Y8:Dye(Q8.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?Y8:Oye(Q8.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=A0(f);var m=f.fill,p=f.align,x=f.sign,y=f.symbol,b=f.zero,v=f.width,N=f.comma,S=f.precision,T=f.trim,E=f.type;E==="n"?(N=!0,E="g"):X8[E]||(S===void 0&&(S=12),T=!0,E="g"),(b||m==="0"&&p==="=")&&(b=!0,m="0",p="=");var C=y==="$"?n:y==="#"&&/[boxX]/.test(E)?"0"+E.toLowerCase():"",A=y==="$"?r:/[%p]/.test(E)?o:"",O=X8[E],k=/[defgprs%]/.test(E);S=S===void 0?6:/[gprs]/.test(E)?Math.max(1,Math.min(21,S)):Math.max(0,Math.min(20,S));function R(F){var L=C,K=A,j,W,Y;if(E==="c")K=O(F)+K,F="";else{F=+F;var q=F<0||1/F<0;if(F=isNaN(F)?c:O(Math.abs(F),S),T&&(F=Iye(F)),q&&+F==0&&x!=="+"&&(q=!1),L=(q?x==="("?x:l:x==="-"||x==="("?"":x)+L,K=(E==="s"?Z8[8+MX/3]:"")+K+(q&&x==="("?")":""),k){for(j=-1,W=F.length;++j<W;)if(Y=F.charCodeAt(j),48>Y||Y>57){K=(Y===46?i+F.slice(j+1):F.slice(j))+K,F=F.slice(0,j);break}}}N&&!b&&(F=e(F,1/0));var Q=L.length+F.length+K.length,ee=Q<v?new Array(v-Q+1).join(m):"";switch(N&&b&&(F=e(ee+F,ee.length?v-K.length:1/0),ee=""),p){case"<":F=L+F+K+ee;break;case"=":F=L+ee+F+K;break;case"^":F=ee.slice(0,Q=ee.length>>1)+L+F+K+ee.slice(Q);break;default:F=ee+L+F+K;break}return a(F)}return R.toString=function(){return f+""},R}function d(f,m){var p=u((f=A0(f),f.type="f",f)),x=Math.max(-8,Math.min(8,Math.floor(fg(m)/3)))*3,y=Math.pow(10,-x),b=Z8[8+x/3];return function(v){return p(y*v)+b}}return{format:u,formatPrefix:d}}var g_,JD,EX;zye({thousands:",",grouping:[3],currency:["$",""]});function zye(t){return g_=Uye(t),JD=g_.format,EX=g_.formatPrefix,g_}function Bye(t){return Math.max(0,-fg(Math.abs(t)))}function $ye(t,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(fg(e)/3)))*3-fg(Math.abs(t)))}function Hye(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,fg(e)-fg(t))+1}function TX(t,e,n,r){var i=L3(t,e,n),a;switch(r=A0(r??",f"),r.type){case"s":{var o=Math.max(Math.abs(t),Math.abs(e));return r.precision==null&&!isNaN(a=$ye(i,o))&&(r.precision=a),EX(r,o)}case"":case"e":case"g":case"p":case"r":{r.precision==null&&!isNaN(a=Hye(i,Math.max(Math.abs(t),Math.abs(e))))&&(r.precision=a-(r.type==="e"));break}case"f":case"%":{r.precision==null&&!isNaN(a=Bye(i))&&(r.precision=a-(r.type==="%")*2);break}}return JD(r)}function ah(t){var e=t.domain;return t.ticks=function(n){var r=e();return D3(r[0],r[r.length-1],n??10)},t.tickFormat=function(n,r){var i=e();return TX(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=O3(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 AX(){var t=QD();return t.copy=function(){return xy(t,AX())},zo.apply(t,arguments),ah(t)}function CX(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,Yw),n):t.slice()},n.unknown=function(r){return arguments.length?(e=r,n):e},n.copy=function(){return CX(t).unknown(e)},t=arguments.length?Array.from(t,Yw):[0,1],ah(n)}function kX(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 J8(t){return Math.log(t)}function e6(t){return Math.exp(t)}function Vye(t){return-Math.log(-t)}function Gye(t){return-Math.exp(-t)}function Wye(t){return isFinite(t)?+("1e"+t):t<0?0:t}function qye(t){return t===10?Wye:t===Math.E?Math.exp:e=>Math.pow(t,e)}function Kye(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 t6(t){return(e,n)=>-t(-e,n)}function e4(t){const e=t(J8,e6),n=e.domain;let r=10,i,a;function o(){return i=Kye(r),a=qye(r),n()[0]<0?(i=t6(i),a=t6(a),t(Vye,Gye)):t(J8,e6),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 m=i(u),p=i(d),x,y;const b=l==null?10:+l;let v=[];if(!(r%1)&&p-m<b){if(m=Math.floor(m),p=Math.ceil(p),u>0){for(;m<=p;++m)for(x=1;x<r;++x)if(y=m<0?x/a(-m):x*a(m),!(y<u)){if(y>d)break;v.push(y)}}else for(;m<=p;++m)for(x=r-1;x>=1;--x)if(y=m>0?x/a(-m):x*a(m),!(y<u)){if(y>d)break;v.push(y)}v.length*2<b&&(v=D3(u,d,b))}else v=D3(m,p,Math.min(p-m,b)).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=A0(c)).precision==null&&(c.trim=!0),c=JD(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(kX(n(),{floor:l=>a(Math.floor(i(l))),ceil:l=>a(Math.ceil(i(l)))})),e}function jX(){const t=e4(fN()).domain([1,10]);return t.copy=()=>xy(t,jX()).base(t.base()),zo.apply(t,arguments),t}function n6(t){return function(e){return Math.sign(e)*Math.log1p(Math.abs(e/t))}}function r6(t){return function(e){return Math.sign(e)*Math.expm1(Math.abs(e))*t}}function t4(t){var e=1,n=t(n6(e),r6(e));return n.constant=function(r){return arguments.length?t(n6(e=+r),r6(e)):e},ah(n)}function PX(){var t=t4(fN());return t.copy=function(){return xy(t,PX()).constant(t.constant())},zo.apply(t,arguments)}function i6(t){return function(e){return e<0?-Math.pow(-e,t):Math.pow(e,t)}}function Xye(t){return t<0?-Math.sqrt(-t):Math.sqrt(t)}function Yye(t){return t<0?-t*t:t*t}function n4(t){var e=t(Wa,Wa),n=1;function r(){return n===1?t(Wa,Wa):n===.5?t(Xye,Yye):t(i6(n),i6(1/n))}return e.exponent=function(i){return arguments.length?(n=+i,r()):n},ah(e)}function r4(){var t=n4(fN());return t.copy=function(){return xy(t,r4()).exponent(t.exponent())},zo.apply(t,arguments),t}function Qye(){return r4.apply(null,arguments).exponent(.5)}function a6(t){return Math.sign(t)*t*t}function Zye(t){return Math.sign(t)*Math.sqrt(Math.abs(t))}function RX(){var t=QD(),e=[0,1],n=!1,r;function i(a){var o=Zye(t(a));return isNaN(o)?r:n?Math.round(o):o}return i.invert=function(a){return t.invert(a6(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,Yw)).map(a6)),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 RX(t.domain(),e).round(n).clamp(t.clamp()).unknown(r)},zo.apply(i,arguments),ah(i)}function DX(){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]=nye(t,o/l);return a}function a(o){return o==null||isNaN(o=+o)?r:e[py(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(Pd),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 DX().domain(t).range(e).unknown(r)},zo.apply(a,arguments)}function OX(){var t=0,e=1,n=1,r=[.5],i=[0,1],a;function o(c){return c!=null&&c<=c?i[py(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 OX().domain([t,e]).range(i).unknown(a)},zo.apply(ah(o),arguments)}function LX(){var t=[.5],e=[0,1],n,r=1;function i(a){return a!=null&&a<=a?e[py(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 LX().domain(t).range(e).unknown(n)},zo.apply(i,arguments)}const XA=new Date,YA=new Date;function Ui(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=>Ui(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)=>(XA.setTime(+a),YA.setTime(+o),t(XA),t(YA),Math.floor(n(XA,YA))),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 Zw=Ui(()=>{},(t,e)=>{t.setTime(+t+e)},(t,e)=>e-t);Zw.every=t=>(t=Math.floor(t),!isFinite(t)||!(t>0)?null:t>1?Ui(e=>{e.setTime(Math.floor(e/t)*t)},(e,n)=>{e.setTime(+e+n*t)},(e,n)=>(n-e)/t):Zw);Zw.range;const Vc=1e3,Eo=Vc*60,Gc=Eo*60,cu=Gc*24,i4=cu*7,s6=cu*30,QA=cu*365,tf=Ui(t=>{t.setTime(t-t.getMilliseconds())},(t,e)=>{t.setTime(+t+e*Vc)},(t,e)=>(e-t)/Vc,t=>t.getUTCSeconds());tf.range;const a4=Ui(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*Vc)},(t,e)=>{t.setTime(+t+e*Eo)},(t,e)=>(e-t)/Eo,t=>t.getMinutes());a4.range;const s4=Ui(t=>{t.setUTCSeconds(0,0)},(t,e)=>{t.setTime(+t+e*Eo)},(t,e)=>(e-t)/Eo,t=>t.getUTCMinutes());s4.range;const o4=Ui(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*Vc-t.getMinutes()*Eo)},(t,e)=>{t.setTime(+t+e*Gc)},(t,e)=>(e-t)/Gc,t=>t.getHours());o4.range;const l4=Ui(t=>{t.setUTCMinutes(0,0,0)},(t,e)=>{t.setTime(+t+e*Gc)},(t,e)=>(e-t)/Gc,t=>t.getUTCHours());l4.range;const by=Ui(t=>t.setHours(0,0,0,0),(t,e)=>t.setDate(t.getDate()+e),(t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*Eo)/cu,t=>t.getDate()-1);by.range;const mN=Ui(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/cu,t=>t.getUTCDate()-1);mN.range;const IX=Ui(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/cu,t=>Math.floor(t/cu));IX.range;function em(t){return Ui(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())*Eo)/i4)}const pN=em(0),Jw=em(1),Jye=em(2),eve=em(3),mg=em(4),tve=em(5),nve=em(6);pN.range;Jw.range;Jye.range;eve.range;mg.range;tve.range;nve.range;function tm(t){return Ui(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)/i4)}const gN=tm(0),eS=tm(1),rve=tm(2),ive=tm(3),pg=tm(4),ave=tm(5),sve=tm(6);gN.range;eS.range;rve.range;ive.range;pg.range;ave.range;sve.range;const c4=Ui(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());c4.range;const u4=Ui(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());u4.range;const uu=Ui(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:Ui(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 du=Ui(t=>{t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCFullYear(t.getUTCFullYear()+e)},(t,e)=>e.getUTCFullYear()-t.getUTCFullYear(),t=>t.getUTCFullYear());du.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:Ui(e=>{e.setUTCFullYear(Math.floor(e.getUTCFullYear()/t)*t),e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)},(e,n)=>{e.setUTCFullYear(e.getUTCFullYear()+n*t)});du.range;function FX(t,e,n,r,i,a){const o=[[tf,1,Vc],[tf,5,5*Vc],[tf,15,15*Vc],[tf,30,30*Vc],[a,1,Eo],[a,5,5*Eo],[a,15,15*Eo],[a,30,30*Eo],[i,1,Gc],[i,3,3*Gc],[i,6,6*Gc],[i,12,12*Gc],[r,1,cu],[r,2,2*cu],[n,1,i4],[e,1,s6],[e,3,3*s6],[t,1,QA]];function l(u,d,f){const m=d<u;m&&([u,d]=[d,u]);const p=f&&typeof f.range=="function"?f:c(u,d,f),x=p?p.range(u,+d+1):[];return m?x.reverse():x}function c(u,d,f){const m=Math.abs(d-u)/f,p=GD(([,,b])=>b).right(o,m);if(p===o.length)return t.every(L3(u/QA,d/QA,f));if(p===0)return Zw.every(Math.max(L3(u,d,f),1));const[x,y]=o[m/o[p-1][2]<o[p][2]/m?p-1:p];return x.every(y)}return[l,c]}const[ove,lve]=FX(du,u4,gN,IX,l4,s4),[cve,uve]=FX(uu,c4,pN,by,o4,a4);function ZA(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 JA(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 nb(t,e,n){return{y:t,m:e,d:n,H:0,M:0,S:0,L:0}}function dve(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=rb(i),d=ib(i),f=rb(a),m=ib(a),p=rb(o),x=ib(o),y=rb(l),b=ib(l),v=rb(c),N=ib(c),S={a:q,A:Q,b:ee,B:re,c:null,d:h6,e:h6,f:Dve,g:Vve,G:Wve,H:jve,I:Pve,j:Rve,L:UX,m:Ove,M:Lve,p:z,q:G,Q:p6,s:g6,S:Ive,u:Fve,U:Uve,V:zve,w:Bve,W:$ve,x:null,X:null,y:Hve,Y:Gve,Z:qve,"%":m6},T={a:ae,A:se,b:ue,B:pe,c:null,d:f6,e:f6,f:Qve,g:o_e,G:c_e,H:Kve,I:Xve,j:Yve,L:BX,m:Zve,M:Jve,p:ce,q:Me,Q:p6,s:g6,S:e_e,u:t_e,U:n_e,V:r_e,w:i_e,W:a_e,x:null,X:null,y:s_e,Y:l_e,Z:u_e,"%":m6},E={a:R,A:F,b:L,B:K,c:j,d:u6,e:u6,f:Tve,g:c6,G:l6,H:d6,I:d6,j:Sve,L:Eve,m:wve,M:Nve,p:k,q:_ve,Q:Cve,s:kve,S:Mve,u:gve,U:xve,V:bve,w:pve,W:yve,x:W,X:Y,y:c6,Y:l6,Z:vve,"%":Ave};S.x=C(n,S),S.X=C(r,S),S.c=C(e,S),T.x=C(n,T),T.X=C(r,T),T.c=C(e,T);function C(me,Ee){return function(fe){var le=[],Be=-1,V=0,$=me.length,X,U,B;for(fe instanceof Date||(fe=new Date(+fe));++Be<$;)me.charCodeAt(Be)===37&&(le.push(me.slice(V,Be)),(U=o6[X=me.charAt(++Be)])!=null?X=me.charAt(++Be):U=X==="e"?" ":"0",(B=Ee[X])&&(X=B(fe,U)),le.push(X),V=Be+1);return le.push(me.slice(V,Be)),le.join("")}}function A(me,Ee){return function(fe){var le=nb(1900,void 0,1),Be=O(le,me,fe+="",0),V,$;if(Be!=fe.length)return null;if("Q"in le)return new Date(le.Q);if("s"in le)return new Date(le.s*1e3+("L"in le?le.L:0));if(Ee&&!("Z"in le)&&(le.Z=0),"p"in le&&(le.H=le.H%12+le.p*12),le.m===void 0&&(le.m="q"in le?le.q:0),"V"in le){if(le.V<1||le.V>53)return null;"w"in le||(le.w=1),"Z"in le?(V=JA(nb(le.y,0,1)),$=V.getUTCDay(),V=$>4||$===0?eS.ceil(V):eS(V),V=mN.offset(V,(le.V-1)*7),le.y=V.getUTCFullYear(),le.m=V.getUTCMonth(),le.d=V.getUTCDate()+(le.w+6)%7):(V=ZA(nb(le.y,0,1)),$=V.getDay(),V=$>4||$===0?Jw.ceil(V):Jw(V),V=by.offset(V,(le.V-1)*7),le.y=V.getFullYear(),le.m=V.getMonth(),le.d=V.getDate()+(le.w+6)%7)}else("W"in le||"U"in le)&&("w"in le||(le.w="u"in le?le.u%7:"W"in le?1:0),$="Z"in le?JA(nb(le.y,0,1)).getUTCDay():ZA(nb(le.y,0,1)).getDay(),le.m=0,le.d="W"in le?(le.w+6)%7+le.W*7-($+5)%7:le.w+le.U*7-($+6)%7);return"Z"in le?(le.H+=le.Z/100|0,le.M+=le.Z%100,JA(le)):ZA(le)}}function O(me,Ee,fe,le){for(var Be=0,V=Ee.length,$=fe.length,X,U;Be<V;){if(le>=$)return-1;if(X=Ee.charCodeAt(Be++),X===37){if(X=Ee.charAt(Be++),U=E[X in o6?Ee.charAt(Be++):X],!U||(le=U(me,fe,le))<0)return-1}else if(X!=fe.charCodeAt(le++))return-1}return le}function k(me,Ee,fe){var le=u.exec(Ee.slice(fe));return le?(me.p=d.get(le[0].toLowerCase()),fe+le[0].length):-1}function R(me,Ee,fe){var le=p.exec(Ee.slice(fe));return le?(me.w=x.get(le[0].toLowerCase()),fe+le[0].length):-1}function F(me,Ee,fe){var le=f.exec(Ee.slice(fe));return le?(me.w=m.get(le[0].toLowerCase()),fe+le[0].length):-1}function L(me,Ee,fe){var le=v.exec(Ee.slice(fe));return le?(me.m=N.get(le[0].toLowerCase()),fe+le[0].length):-1}function K(me,Ee,fe){var le=y.exec(Ee.slice(fe));return le?(me.m=b.get(le[0].toLowerCase()),fe+le[0].length):-1}function j(me,Ee,fe){return O(me,e,Ee,fe)}function W(me,Ee,fe){return O(me,n,Ee,fe)}function Y(me,Ee,fe){return O(me,r,Ee,fe)}function q(me){return o[me.getDay()]}function Q(me){return a[me.getDay()]}function ee(me){return c[me.getMonth()]}function re(me){return l[me.getMonth()]}function z(me){return i[+(me.getHours()>=12)]}function G(me){return 1+~~(me.getMonth()/3)}function ae(me){return o[me.getUTCDay()]}function se(me){return a[me.getUTCDay()]}function ue(me){return c[me.getUTCMonth()]}function pe(me){return l[me.getUTCMonth()]}function ce(me){return i[+(me.getUTCHours()>=12)]}function Me(me){return 1+~~(me.getUTCMonth()/3)}return{format:function(me){var Ee=C(me+="",S);return Ee.toString=function(){return me},Ee},parse:function(me){var Ee=A(me+="",!1);return Ee.toString=function(){return me},Ee},utcFormat:function(me){var Ee=C(me+="",T);return Ee.toString=function(){return me},Ee},utcParse:function(me){var Ee=A(me+="",!0);return Ee.toString=function(){return me},Ee}}}var o6={"-":"",_:" ",0:"0"},aa=/^\s*\d+/,hve=/^%/,fve=/[\\^$*+?|[\]().{}]/g;function Xn(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 mve(t){return t.replace(fve,"\\$&")}function rb(t){return new RegExp("^(?:"+t.map(mve).join("|")+")","i")}function ib(t){return new Map(t.map((e,n)=>[e.toLowerCase(),n]))}function pve(t,e,n){var r=aa.exec(e.slice(n,n+1));return r?(t.w=+r[0],n+r[0].length):-1}function gve(t,e,n){var r=aa.exec(e.slice(n,n+1));return r?(t.u=+r[0],n+r[0].length):-1}function xve(t,e,n){var r=aa.exec(e.slice(n,n+2));return r?(t.U=+r[0],n+r[0].length):-1}function bve(t,e,n){var r=aa.exec(e.slice(n,n+2));return r?(t.V=+r[0],n+r[0].length):-1}function yve(t,e,n){var r=aa.exec(e.slice(n,n+2));return r?(t.W=+r[0],n+r[0].length):-1}function l6(t,e,n){var r=aa.exec(e.slice(n,n+4));return r?(t.y=+r[0],n+r[0].length):-1}function c6(t,e,n){var r=aa.exec(e.slice(n,n+2));return r?(t.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function vve(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 _ve(t,e,n){var r=aa.exec(e.slice(n,n+1));return r?(t.q=r[0]*3-3,n+r[0].length):-1}function wve(t,e,n){var r=aa.exec(e.slice(n,n+2));return r?(t.m=r[0]-1,n+r[0].length):-1}function u6(t,e,n){var r=aa.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1}function Sve(t,e,n){var r=aa.exec(e.slice(n,n+3));return r?(t.m=0,t.d=+r[0],n+r[0].length):-1}function d6(t,e,n){var r=aa.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1}function Nve(t,e,n){var r=aa.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1}function Mve(t,e,n){var r=aa.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1}function Eve(t,e,n){var r=aa.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1}function Tve(t,e,n){var r=aa.exec(e.slice(n,n+6));return r?(t.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function Ave(t,e,n){var r=hve.exec(e.slice(n,n+1));return r?n+r[0].length:-1}function Cve(t,e,n){var r=aa.exec(e.slice(n));return r?(t.Q=+r[0],n+r[0].length):-1}function kve(t,e,n){var r=aa.exec(e.slice(n));return r?(t.s=+r[0],n+r[0].length):-1}function h6(t,e){return Xn(t.getDate(),e,2)}function jve(t,e){return Xn(t.getHours(),e,2)}function Pve(t,e){return Xn(t.getHours()%12||12,e,2)}function Rve(t,e){return Xn(1+by.count(uu(t),t),e,3)}function UX(t,e){return Xn(t.getMilliseconds(),e,3)}function Dve(t,e){return UX(t,e)+"000"}function Ove(t,e){return Xn(t.getMonth()+1,e,2)}function Lve(t,e){return Xn(t.getMinutes(),e,2)}function Ive(t,e){return Xn(t.getSeconds(),e,2)}function Fve(t){var e=t.getDay();return e===0?7:e}function Uve(t,e){return Xn(pN.count(uu(t)-1,t),e,2)}function zX(t){var e=t.getDay();return e>=4||e===0?mg(t):mg.ceil(t)}function zve(t,e){return t=zX(t),Xn(mg.count(uu(t),t)+(uu(t).getDay()===4),e,2)}function Bve(t){return t.getDay()}function $ve(t,e){return Xn(Jw.count(uu(t)-1,t),e,2)}function Hve(t,e){return Xn(t.getFullYear()%100,e,2)}function Vve(t,e){return t=zX(t),Xn(t.getFullYear()%100,e,2)}function Gve(t,e){return Xn(t.getFullYear()%1e4,e,4)}function Wve(t,e){var n=t.getDay();return t=n>=4||n===0?mg(t):mg.ceil(t),Xn(t.getFullYear()%1e4,e,4)}function qve(t){var e=t.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+Xn(e/60|0,"0",2)+Xn(e%60,"0",2)}function f6(t,e){return Xn(t.getUTCDate(),e,2)}function Kve(t,e){return Xn(t.getUTCHours(),e,2)}function Xve(t,e){return Xn(t.getUTCHours()%12||12,e,2)}function Yve(t,e){return Xn(1+mN.count(du(t),t),e,3)}function BX(t,e){return Xn(t.getUTCMilliseconds(),e,3)}function Qve(t,e){return BX(t,e)+"000"}function Zve(t,e){return Xn(t.getUTCMonth()+1,e,2)}function Jve(t,e){return Xn(t.getUTCMinutes(),e,2)}function e_e(t,e){return Xn(t.getUTCSeconds(),e,2)}function t_e(t){var e=t.getUTCDay();return e===0?7:e}function n_e(t,e){return Xn(gN.count(du(t)-1,t),e,2)}function $X(t){var e=t.getUTCDay();return e>=4||e===0?pg(t):pg.ceil(t)}function r_e(t,e){return t=$X(t),Xn(pg.count(du(t),t)+(du(t).getUTCDay()===4),e,2)}function i_e(t){return t.getUTCDay()}function a_e(t,e){return Xn(eS.count(du(t)-1,t),e,2)}function s_e(t,e){return Xn(t.getUTCFullYear()%100,e,2)}function o_e(t,e){return t=$X(t),Xn(t.getUTCFullYear()%100,e,2)}function l_e(t,e){return Xn(t.getUTCFullYear()%1e4,e,4)}function c_e(t,e){var n=t.getUTCDay();return t=n>=4||n===0?pg(t):pg.ceil(t),Xn(t.getUTCFullYear()%1e4,e,4)}function u_e(){return"+0000"}function m6(){return"%"}function p6(t){return+t}function g6(t){return Math.floor(+t/1e3)}var zm,HX,VX;d_e({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 d_e(t){return zm=dve(t),HX=zm.format,zm.parse,VX=zm.utcFormat,zm.utcParse,zm}function h_e(t){return new Date(t)}function f_e(t){return t instanceof Date?+t:+new Date(+t)}function d4(t,e,n,r,i,a,o,l,c,u){var d=QD(),f=d.invert,m=d.domain,p=u(".%L"),x=u(":%S"),y=u("%I:%M"),b=u("%I %p"),v=u("%a %d"),N=u("%b %d"),S=u("%B"),T=u("%Y");function E(C){return(c(C)<C?p:l(C)<C?x:o(C)<C?y:a(C)<C?b:r(C)<C?i(C)<C?v:N:n(C)<C?S:T)(C)}return d.invert=function(C){return new Date(f(C))},d.domain=function(C){return arguments.length?m(Array.from(C,f_e)):m().map(h_e)},d.ticks=function(C){var A=m();return t(A[0],A[A.length-1],C??10)},d.tickFormat=function(C,A){return A==null?E:u(A)},d.nice=function(C){var A=m();return(!C||typeof C.range!="function")&&(C=e(A[0],A[A.length-1],C??10)),C?m(kX(A,C)):d},d.copy=function(){return xy(d,d4(t,e,n,r,i,a,o,l,c,u))},d}function m_e(){return zo.apply(d4(cve,uve,uu,c4,pN,by,o4,a4,tf,HX).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)}function p_e(){return zo.apply(d4(ove,lve,du,u4,gN,mN,l4,s4,tf,VX).domain([Date.UTC(2e3,0,1),Date.UTC(2e3,0,2)]),arguments)}function xN(){var t=0,e=1,n,r,i,a,o=Wa,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(m){var p,x;return arguments.length?([p,x]=m,o=f(p,x),u):[o(0),o(1)]}}return u.range=d(Vg),u.rangeRound=d(YD),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 sh(t,e){return e.domain(t.domain()).interpolator(t.interpolator()).clamp(t.clamp()).unknown(t.unknown())}function GX(){var t=ah(xN()(Wa));return t.copy=function(){return sh(t,GX())},yu.apply(t,arguments)}function WX(){var t=e4(xN()).domain([1,10]);return t.copy=function(){return sh(t,WX()).base(t.base())},yu.apply(t,arguments)}function qX(){var t=t4(xN());return t.copy=function(){return sh(t,qX()).constant(t.constant())},yu.apply(t,arguments)}function h4(){var t=n4(xN());return t.copy=function(){return sh(t,h4()).exponent(t.exponent())},yu.apply(t,arguments)}function g_e(){return h4.apply(null,arguments).exponent(.5)}function KX(){var t=[],e=Wa;function n(r){if(r!=null&&!isNaN(r=+r))return e((py(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(Pd),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)=>tye(t,a/r))},n.copy=function(){return KX(e).domain(t)},yu.apply(n,arguments)}function bN(){var t=0,e=.5,n=1,r=1,i,a,o,l,c,u=Wa,d,f=!1,m;function p(y){return isNaN(y=+y)?m:(y=.5+((y=+d(y))-a)*(r*y<r*a?l:c),u(f?Math.max(0,Math.min(1,y)):y))}p.domain=function(y){return arguments.length?([t,e,n]=y,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,p):[t,e,n]},p.clamp=function(y){return arguments.length?(f=!!y,p):f},p.interpolator=function(y){return arguments.length?(u=y,p):u};function x(y){return function(b){var v,N,S;return arguments.length?([v,N,S]=b,u=Aye(y,[v,N,S]),p):[u(0),u(.5),u(1)]}}return p.range=x(Vg),p.rangeRound=x(YD),p.unknown=function(y){return arguments.length?(m=y,p):m},function(y){return d=y,i=y(t),a=y(e),o=y(n),l=i===a?0:.5/(a-i),c=a===o?0:.5/(o-a),r=a<i?-1:1,p}}function XX(){var t=ah(bN()(Wa));return t.copy=function(){return sh(t,XX())},yu.apply(t,arguments)}function YX(){var t=e4(bN()).domain([.1,1,10]);return t.copy=function(){return sh(t,YX()).base(t.base())},yu.apply(t,arguments)}function QX(){var t=t4(bN());return t.copy=function(){return sh(t,QX()).constant(t.constant())},yu.apply(t,arguments)}function f4(){var t=n4(bN());return t.copy=function(){return sh(t,f4()).exponent(t.exponent())},yu.apply(t,arguments)}function x_e(){return f4.apply(null,arguments).exponent(.5)}const Eb=Object.freeze(Object.defineProperty({__proto__:null,scaleBand:qD,scaleDiverging:XX,scaleDivergingLog:YX,scaleDivergingPow:f4,scaleDivergingSqrt:x_e,scaleDivergingSymlog:QX,scaleIdentity:CX,scaleImplicit:I3,scaleLinear:AX,scaleLog:jX,scaleOrdinal:WD,scalePoint:iye,scalePow:r4,scaleQuantile:DX,scaleQuantize:OX,scaleRadial:RX,scaleSequential:GX,scaleSequentialLog:WX,scaleSequentialPow:h4,scaleSequentialQuantile:KX,scaleSequentialSqrt:g_e,scaleSequentialSymlog:qX,scaleSqrt:Qye,scaleSymlog:PX,scaleThreshold:LX,scaleTime:m_e,scaleUtc:p_e,tickFormat:TX},Symbol.toStringTag,{value:"Module"}));var oh=t=>t.chartData,m4=et([oh],t=>{var e=t.chartData!=null?t.chartData.length-1:0;return{chartData:t.chartData,computedData:t.computedData,dataEndIndex:e,dataStartIndex:0}}),yy=(t,e,n,r)=>r?m4(t):oh(t);function Vd(t){if(Array.isArray(t)&&t.length===2){var[e,n]=t;if(ar(e)&&ar(n))return!0}return!1}function x6(t,e,n){return n?t:[Math.min(t[0],e[0]),Math.max(t[1],e[1])]}function ZX(t,e){if(e&&typeof t!="function"&&Array.isArray(t)&&t.length===2){var[n,r]=t,i,a;if(ar(n))i=n;else if(typeof n=="function")return;if(ar(r))a=r;else if(typeof r=="function")return;var o=[i,a];if(Vd(o))return o}}function b_e(t,e,n){if(!(!n&&e==null)){if(typeof t=="function"&&e!=null)try{var r=t(e,n);if(Vd(r))return x6(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(Bt(i))o=i;else if(typeof i=="function")try{e!=null&&(o=i(e?.[0]))}catch{}else if(typeof i=="string"&&GB.test(i)){var c=GB.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(Bt(a))l=a;else if(typeof a=="function")try{e!=null&&(l=a(e?.[1]))}catch{}else if(typeof a=="string"&&WB.test(a)){var d=WB.exec(a);if(d==null||e==null)l=void 0;else{var f=+d[1];l=e[1]+f}}else l=e?.[1];var m=[o,l];if(Vd(m))return e==null?m:x6(m,e,n)}}}var Gg=1e9,y_e={precision:20,rounding:4,toExpNeg:-7,toExpPos:21,LN10:"2.302585092994045684017991454684364207601101488628772976033327900967572609677352480235997205089598298341967784042286"},g4,zr=!0,Io="[DecimalError] ",mf=Io+"Invalid argument: ",p4=Io+"Exponent out of range: ",Wg=Math.floor,Hh=Math.pow,v_e=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,Bs,Yi=1e7,jr=7,JX=9007199254740991,tS=Wg(JX/jr),Ht={};Ht.absoluteValue=Ht.abs=function(){var t=new this.constructor(this);return t.s&&(t.s=1),t};Ht.comparedTo=Ht.cmp=function(t){var e,n,r,i,a=this;if(t=new a.constructor(t),a.s!==t.s)return a.s||-t.s;if(a.e!==t.e)return a.e>t.e^a.s<0?1:-1;for(r=a.d.length,i=t.d.length,e=0,n=r<i?r:i;e<n;++e)if(a.d[e]!==t.d[e])return a.d[e]>t.d[e]^a.s<0?1:-1;return r===i?0:r>i^a.s<0?1:-1};Ht.decimalPlaces=Ht.dp=function(){var t=this,e=t.d.length-1,n=(e-t.e)*jr;if(e=t.d[e],e)for(;e%10==0;e/=10)n--;return n<0?0:n};Ht.dividedBy=Ht.div=function(t){return Zc(this,new this.constructor(t))};Ht.dividedToIntegerBy=Ht.idiv=function(t){var e=this,n=e.constructor;return _r(Zc(e,new n(t),0,1),n.precision)};Ht.equals=Ht.eq=function(t){return!this.cmp(t)};Ht.exponent=function(){return Ni(this)};Ht.greaterThan=Ht.gt=function(t){return this.cmp(t)>0};Ht.greaterThanOrEqualTo=Ht.gte=function(t){return this.cmp(t)>=0};Ht.isInteger=Ht.isint=function(){return this.e>this.d.length-2};Ht.isNegative=Ht.isneg=function(){return this.s<0};Ht.isPositive=Ht.ispos=function(){return this.s>0};Ht.isZero=function(){return this.s===0};Ht.lessThan=Ht.lt=function(t){return this.cmp(t)<0};Ht.lessThanOrEqualTo=Ht.lte=function(t){return this.cmp(t)<1};Ht.logarithm=Ht.log=function(t){var e,n=this,r=n.constructor,i=r.precision,a=i+5;if(t===void 0)t=new r(10);else if(t=new r(t),t.s<1||t.eq(Bs))throw Error(Io+"NaN");if(n.s<1)throw Error(Io+(n.s?"NaN":"-Infinity"));return n.eq(Bs)?new r(0):(zr=!1,e=Zc(C0(n,a),C0(t,a),a),zr=!0,_r(e,i))};Ht.minus=Ht.sub=function(t){var e=this;return t=new e.constructor(t),e.s==t.s?nY(e,t):eY(e,(t.s=-t.s,t))};Ht.modulo=Ht.mod=function(t){var e,n=this,r=n.constructor,i=r.precision;if(t=new r(t),!t.s)throw Error(Io+"NaN");return n.s?(zr=!1,e=Zc(n,t,0,1).times(t),zr=!0,n.minus(e)):_r(new r(n),i)};Ht.naturalExponential=Ht.exp=function(){return tY(this)};Ht.naturalLogarithm=Ht.ln=function(){return C0(this)};Ht.negated=Ht.neg=function(){var t=new this.constructor(this);return t.s=-t.s||0,t};Ht.plus=Ht.add=function(t){var e=this;return t=new e.constructor(t),e.s==t.s?eY(e,t):nY(e,(t.s=-t.s,t))};Ht.precision=Ht.sd=function(t){var e,n,r,i=this;if(t!==void 0&&t!==!!t&&t!==1&&t!==0)throw Error(mf+t);if(e=Ni(i)+1,r=i.d.length-1,n=r*jr+1,r=i.d[r],r){for(;r%10==0;r/=10)n--;for(r=i.d[0];r>=10;r/=10)n++}return t&&e>n?e:n};Ht.squareRoot=Ht.sqrt=function(){var t,e,n,r,i,a,o,l=this,c=l.constructor;if(l.s<1){if(!l.s)return new c(0);throw Error(Io+"NaN")}for(t=Ni(l),zr=!1,i=Math.sqrt(+l),i==0||i==1/0?(e=Pl(l.d),(e.length+t)%2==0&&(e+="0"),i=Math.sqrt(e),t=Wg((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(Zc(l,a,o+2)).times(.5),Pl(a.d).slice(0,o)===(e=Pl(r.d)).slice(0,o)){if(e=e.slice(o-3,o+1),i==o&&e=="4999"){if(_r(a,n+1,0),a.times(a).eq(l)){r=a;break}}else if(e!="9999")break;o+=4}return zr=!0,_r(r,n)};Ht.times=Ht.mul=function(t){var e,n,r,i,a,o,l,c,u,d=this,f=d.constructor,m=d.d,p=(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=m.length,u=p.length,c<u&&(a=m,m=p,p=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]+p[r]*m[i-r-1]+e,a[i--]=l%Yi|0,e=l/Yi|0;a[i]=(a[i]+e)%Yi|0}for(;!a[--o];)a.pop();return e?++n:a.shift(),t.d=a,t.e=n,zr?_r(t,f.precision):t};Ht.toDecimalPlaces=Ht.todp=function(t,e){var n=this,r=n.constructor;return n=new r(n),t===void 0?n:($l(t,0,Gg),e===void 0?e=r.rounding:$l(e,0,8),_r(n,t+Ni(n)+1,e))};Ht.toExponential=function(t,e){var n,r=this,i=r.constructor;return t===void 0?n=If(r,!0):($l(t,0,Gg),e===void 0?e=i.rounding:$l(e,0,8),r=_r(new i(r),t+1,e),n=If(r,!0,t+1)),n};Ht.toFixed=function(t,e){var n,r,i=this,a=i.constructor;return t===void 0?If(i):($l(t,0,Gg),e===void 0?e=a.rounding:$l(e,0,8),r=_r(new a(i),t+Ni(i)+1,e),n=If(r.abs(),!1,t+Ni(r)+1),i.isneg()&&!i.isZero()?"-"+n:n)};Ht.toInteger=Ht.toint=function(){var t=this,e=t.constructor;return _r(new e(t),Ni(t)+1,e.rounding)};Ht.toNumber=function(){return+this};Ht.toPower=Ht.pow=function(t){var e,n,r,i,a,o,l=this,c=l.constructor,u=12,d=+(t=new c(t));if(!t.s)return new c(Bs);if(l=new c(l),!l.s){if(t.s<1)throw Error(Io+"Infinity");return l}if(l.eq(Bs))return l;if(r=c.precision,t.eq(Bs))return _r(l,r);if(e=t.e,n=t.d.length-1,o=e>=n,a=l.s,o){if((n=d<0?-d:d)<=JX){for(i=new c(Bs),e=Math.ceil(r/jr+4),zr=!1;n%2&&(i=i.times(l),y6(i.d,e)),n=Wg(n/2),n!==0;)l=l.times(l),y6(l.d,e);return zr=!0,t.s<0?new c(Bs).div(i):_r(i,r)}}else if(a<0)throw Error(Io+"NaN");return a=a<0&&t.d[Math.max(e,n)]&1?-1:1,l.s=1,zr=!1,i=t.times(C0(l,r+u)),zr=!0,i=tY(i),i.s=a,i};Ht.toPrecision=function(t,e){var n,r,i=this,a=i.constructor;return t===void 0?(n=Ni(i),r=If(i,n<=a.toExpNeg||n>=a.toExpPos)):($l(t,1,Gg),e===void 0?e=a.rounding:$l(e,0,8),i=_r(new a(i),t,e),n=Ni(i),r=If(i,t<=n||n<=a.toExpNeg,t)),r};Ht.toSignificantDigits=Ht.tosd=function(t,e){var n=this,r=n.constructor;return t===void 0?(t=r.precision,e=r.rounding):($l(t,1,Gg),e===void 0?e=r.rounding:$l(e,0,8)),_r(new r(n),t,e)};Ht.toString=Ht.valueOf=Ht.val=Ht.toJSON=Ht[Symbol.for("nodejs.util.inspect.custom")]=function(){var t=this,e=Ni(t),n=t.constructor;return If(t,e<=n.toExpNeg||e>=n.toExpPos)};function eY(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)),zr?_r(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/jr),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)/Yi|0,c[a]%=Yi;for(n&&(c.unshift(n),++i),l=c.length;c[--l]==0;)c.pop();return e.d=c,e.e=i,zr?_r(e,f):e}function $l(t,e,n){if(t!==~~t||t<e||t>n)throw Error(mf+t)}function Pl(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=jr-r.length,n&&(a+=ld(n)),a+=r;o=t[e],r=o+"",n=jr-r.length,n&&(a+=ld(n))}else if(o===0)return"0";for(;o%10===0;)o/=10;return a+o}var Zc=(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%Yi|0,o=a/Yi|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*Yi+r[a]-i[a];for(;!r[0]&&r.length>1;)r.shift()}return function(r,i,a,o){var l,c,u,d,f,m,p,x,y,b,v,N,S,T,E,C,A,O,k=r.constructor,R=r.s==i.s?1:-1,F=r.d,L=i.d;if(!r.s)return new k(r);if(!i.s)throw Error(Io+"Division by zero");for(c=r.e-i.e,A=L.length,E=F.length,p=new k(R),x=p.d=[],u=0;L[u]==(F[u]||0);)++u;if(L[u]>(F[u]||0)&&--c,a==null?N=a=k.precision:o?N=a+(Ni(r)-Ni(i))+1:N=a,N<0)return new k(0);if(N=N/jr+2|0,u=0,A==1)for(d=0,L=L[0],N++;(u<E||d)&&N--;u++)S=d*Yi+(F[u]||0),x[u]=S/L|0,d=S%L|0;else{for(d=Yi/(L[0]+1)|0,d>1&&(L=t(L,d),F=t(F,d),A=L.length,E=F.length),T=A,y=F.slice(0,A),b=y.length;b<A;)y[b++]=0;O=L.slice(),O.unshift(0),C=L[0],L[1]>=Yi/2&&++C;do d=0,l=e(L,y,A,b),l<0?(v=y[0],A!=b&&(v=v*Yi+(y[1]||0)),d=v/C|0,d>1?(d>=Yi&&(d=Yi-1),f=t(L,d),m=f.length,b=y.length,l=e(f,y,m,b),l==1&&(d--,n(f,A<m?O:L,m))):(d==0&&(l=d=1),f=L.slice()),m=f.length,m<b&&f.unshift(0),n(y,f,b),l==-1&&(b=y.length,l=e(L,y,A,b),l<1&&(d++,n(y,A<b?O:L,b))),b=y.length):l===0&&(d++,y=[0]),x[u++]=d,l&&y[0]?y[b++]=F[T]||0:(y=[F[T]],b=1);while((T++<E||y[0]!==void 0)&&N--)}return x[0]||x.shift(),p.e=c,_r(p,o?a+Ni(p)+1:a)}})();function tY(t,e){var n,r,i,a,o,l,c=0,u=0,d=t.constructor,f=d.precision;if(Ni(t)>16)throw Error(p4+Ni(t));if(!t.s)return new d(Bs);for(zr=!1,l=f,o=new d(.03125);t.abs().gte(.1);)t=t.times(o),u+=5;for(r=Math.log(Hh(2,u))/Math.LN10*2+5|0,l+=r,n=i=a=new d(Bs),d.precision=l;;){if(i=_r(i.times(t),l),n=n.times(++c),o=a.plus(Zc(i,n,l)),Pl(o.d).slice(0,l)===Pl(a.d).slice(0,l)){for(;u--;)a=_r(a.times(a),l);return d.precision=f,e==null?(zr=!0,_r(a,f)):a}a=o}}function Ni(t){for(var e=t.e*jr,n=t.d[0];n>=10;n/=10)e++;return e}function eC(t,e,n){if(e>t.LN10.sd())throw zr=!0,n&&(t.precision=n),Error(Io+"LN10 precision limit exceeded");return _r(new t(t.LN10),e)}function ld(t){for(var e="";t--;)e+="0";return e}function C0(t,e){var n,r,i,a,o,l,c,u,d,f=1,m=10,p=t,x=p.d,y=p.constructor,b=y.precision;if(p.s<1)throw Error(Io+(p.s?"NaN":"-Infinity"));if(p.eq(Bs))return new y(0);if(e==null?(zr=!1,u=b):u=e,p.eq(10))return e==null&&(zr=!0),eC(y,u);if(u+=m,y.precision=u,n=Pl(x),r=n.charAt(0),a=Ni(p),Math.abs(a)<15e14){for(;r<7&&r!=1||r==1&&n.charAt(1)>3;)p=p.times(t),n=Pl(p.d),r=n.charAt(0),f++;a=Ni(p),r>1?(p=new y("0."+n),a++):p=new y(r+"."+n.slice(1))}else return c=eC(y,u+2,b).times(a+""),p=C0(new y(r+"."+n.slice(1)),u-m).plus(c),y.precision=b,e==null?(zr=!0,_r(p,b)):p;for(l=o=p=Zc(p.minus(Bs),p.plus(Bs),u),d=_r(p.times(p),u),i=3;;){if(o=_r(o.times(d),u),c=l.plus(Zc(o,new y(i),u)),Pl(c.d).slice(0,u)===Pl(l.d).slice(0,u))return l=l.times(2),a!==0&&(l=l.plus(eC(y,u+2,b).times(a+""))),l=Zc(l,new y(f),u),y.precision=b,e==null?(zr=!0,_r(l,b)):l;l=c,i+=2}}function b6(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=Wg(n/jr),t.d=[],r=(n+1)%jr,n<0&&(r+=jr),r<i){for(r&&t.d.push(+e.slice(0,r)),i-=jr;r<i;)t.d.push(+e.slice(r,r+=jr));e=e.slice(r),r=jr-e.length}else r-=i;for(;r--;)e+="0";if(t.d.push(+e),zr&&(t.e>tS||t.e<-tS))throw Error(p4+n)}else t.s=0,t.e=0,t.d=[0];return t}function _r(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+=jr,i=e,u=f[d=0];else{if(d=Math.ceil((r+1)/jr),a=f.length,d>=a)return t;for(u=a=f[d],o=1;a>=10;a/=10)o++;r%=jr,i=r-jr+o}if(n!==void 0&&(a=Hh(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/Hh(10,o-i):0:f[d-1])%10&1||n==(t.s<0?8:7))),e<1||!f[0])return c?(a=Ni(t),f.length=1,e=e-a-1,f[0]=Hh(10,(jr-e%jr)%jr),t.e=Wg(-e/jr)||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=Hh(10,jr-r),f[d]=i>0?(u/Hh(10,o-i)%Hh(10,i)|0)*a:0),c)for(;;)if(d==0){(f[0]+=a)==Yi&&(f[0]=1,++t.e);break}else{if(f[d]+=a,f[d]!=Yi)break;f[d--]=0,a=1}for(r=f.length;f[--r]===0;)f.pop();if(zr&&(t.e>tS||t.e<-tS))throw Error(p4+Ni(t));return t}function nY(t,e){var n,r,i,a,o,l,c,u,d,f,m=t.constructor,p=m.precision;if(!t.s||!e.s)return e.s?e.s=-e.s:e=new m(t),zr?_r(e,p):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(p/jr),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]=Yi-1;--c[a],c[i]+=Yi}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,zr?_r(e,p):e):new m(0)}function If(t,e,n){var r,i=Ni(t),a=Pl(t.d),o=a.length;return e?(n&&(r=n-o)>0?a=a.charAt(0)+"."+a.slice(1)+ld(r):o>1&&(a=a.charAt(0)+"."+a.slice(1)),a=a+(i<0?"e":"e+")+i):i<0?(a="0."+ld(-i-1)+a,n&&(r=n-o)>0&&(a+=ld(r))):i>=o?(a+=ld(i+1-o),n&&(r=n-i-1)>0&&(a=a+"."+ld(r))):((r=i+1)<o&&(a=a.slice(0,r)+"."+a.slice(r)),n&&(r=n-o)>0&&(i+1===o&&(a+="."),a+=ld(r))),t.s<0?"-"+a:a}function y6(t,e){if(t.length>e)return t.length=e,!0}function rY(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(mf+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 b6(o,a.toString())}else if(typeof a!="string")throw Error(mf+a);if(a.charCodeAt(0)===45?(a=a.slice(1),o.s=-1):o.s=1,v_e.test(a))b6(o,a);else throw Error(mf+a)}if(i.prototype=Ht,i.ROUND_UP=0,i.ROUND_DOWN=1,i.ROUND_CEIL=2,i.ROUND_FLOOR=3,i.ROUND_HALF_UP=4,i.ROUND_HALF_DOWN=5,i.ROUND_HALF_EVEN=6,i.ROUND_HALF_CEIL=7,i.ROUND_HALF_FLOOR=8,i.clone=rY,i.config=i.set=__e,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 __e(t){if(!t||typeof t!="object")throw Error(Io+"Object expected");var e,n,r,i=["precision",1,Gg,"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(Wg(r)===r&&r>=i[e+1]&&r<=i[e+2])this[n]=r;else throw Error(mf+n+": "+r);if((r=t[n="LN10"])!==void 0)if(r==Math.LN10)this[n]=new this(r);else throw Error(mf+n+": "+r);return this}var g4=rY(y_e);Bs=new g4(1);const rr=g4;var w_e=t=>t,iY={},aY=t=>t===iY,v6=t=>function e(){return arguments.length===0||arguments.length===1&&aY(arguments.length<=0?void 0:arguments[0])?e:t(...arguments)},sY=(t,e)=>t===1?e:v6(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!==iY).length;return a>=t?e(...r):sY(t-a,v6(function(){for(var o=arguments.length,l=new Array(o),c=0;c<o;c++)l[c]=arguments[c];var u=r.map(d=>aY(d)?l.shift():d);return e(...u,...l)}))}),S_e=t=>sY(t.length,t),B3=(t,e)=>{for(var n=[],r=t;r<e;++r)n[r-t]=r;return n},N_e=S_e((t,e)=>Array.isArray(e)?e.map(t):Object.keys(e).map(n=>e[n]).map(t)),M_e=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];if(!n.length)return w_e;var i=n.reverse(),a=i[0],o=i.slice(1);return function(){return o.reduce((l,c)=>c(l),a(...arguments))}},$3=t=>Array.isArray(t)?t.reverse():t.split("").reverse().join("");function oY(t){var e;return t===0?e=1:e=Math.floor(new rr(t).abs().log(10).toNumber())+1,e}function lY(t,e,n){for(var r=new rr(t),i=0,a=[];r.lt(e)&&i<1e5;)a.push(r.toNumber()),r=r.add(n),i++;return a}var cY=t=>{var[e,n]=t,[r,i]=[e,n];return e>n&&([r,i]=[n,e]),[r,i]},uY=(t,e,n)=>{if(t.lte(0))return new rr(0);var r=oY(t.toNumber()),i=new rr(10).pow(r),a=t.div(i),o=r!==1?.05:.1,l=new rr(Math.ceil(a.div(o).toNumber())).add(n).mul(o),c=l.mul(i);return e?new rr(c.toNumber()):new rr(Math.ceil(c.toNumber()))},E_e=(t,e,n)=>{var r=new rr(1),i=new rr(t);if(!i.isint()&&n){var a=Math.abs(t);a<1?(r=new rr(10).pow(oY(t)-1),i=new rr(Math.floor(i.div(r).toNumber())).mul(r)):a>1&&(i=new rr(Math.floor(t)))}else t===0?i=new rr(Math.floor((e-1)/2)):n||(i=new rr(Math.floor(t)));var o=Math.floor((e-1)/2),l=M_e(N_e(c=>i.add(new rr(c-o).mul(r)).toNumber()),B3);return l(0,e)},dY=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 rr(0),tickMin:new rr(0),tickMax:new rr(0)};var o=uY(new rr(n).sub(e).div(r-1),i,a),l;e<=0&&n>=0?l=new rr(0):(l=new rr(e).add(n).div(2),l=l.sub(new rr(l).mod(o)));var c=Math.ceil(l.sub(e).div(o).toNumber()),u=Math.ceil(new rr(n).sub(l).div(o).toNumber()),d=c+u+1;return d>r?dY(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 rr(c).mul(o)),tickMax:l.add(new rr(u).mul(o))})},T_e=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]=cY([n,r]);if(l===-1/0||c===1/0){var u=c===1/0?[l,...B3(0,i-1).map(()=>1/0)]:[...B3(0,i-1).map(()=>-1/0),c];return n>r?$3(u):u}if(l===c)return E_e(l,i,a);var{step:d,tickMin:f,tickMax:m}=dY(l,c,o,a,0),p=lY(f,m.add(new rr(.1).mul(d)),d);return n>r?$3(p):p},A_e=function(e,n){var[r,i]=e,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,[o,l]=cY([r,i]);if(o===-1/0||l===1/0)return[r,i];if(o===l)return[o];var c=Math.max(n,2),u=uY(new rr(l).sub(o).div(c-1),a,0),d=[...lY(new rr(o),new rr(l),u),l];return a===!1&&(d=d.map(f=>Math.round(f))),r>i?$3(d):d},hY=t=>t.rootProps.maxBarSize,C_e=t=>t.rootProps.barGap,fY=t=>t.rootProps.barCategoryGap,k_e=t=>t.rootProps.barSize,vy=t=>t.rootProps.stackOffset,mY=t=>t.rootProps.reverseStackOrder,x4=t=>t.options.chartName,b4=t=>t.rootProps.syncId,pY=t=>t.rootProps.syncMethod,y4=t=>t.options.eventEmitter,j_e=t=>t.rootProps.baseValue,ii={grid:-100,barBackground:-50,area:100,cursorRectangle:200,bar:300,line:400,axis:500,scatter:600,activeBar:1e3,cursorLine:1100,activeDot:1200,label:2e3},Uc={allowDuplicatedCategory:!0,angleAxisId:0,reversed:!1,scale:"auto",tick:!0,type:"category"},Fs={allowDataOverflow:!1,allowDuplicatedCategory:!0,radiusAxisId:0,scale:"auto",tick:!0,tickCount:5,type:"number"},yN=(t,e)=>{if(!(!t||!e))return t!=null&&t.reversed?[e[1],e[0]]:e},P_e={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:!1,dataKey:void 0,domain:void 0,id:Uc.angleAxisId,includeHidden:!1,name:void 0,reversed:Uc.reversed,scale:Uc.scale,tick:Uc.tick,tickCount:void 0,ticks:void 0,type:Uc.type,unit:void 0},R_e={allowDataOverflow:Fs.allowDataOverflow,allowDecimals:!1,allowDuplicatedCategory:Fs.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:Fs.radiusAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:Fs.scale,tick:Fs.tick,tickCount:Fs.tickCount,ticks:void 0,type:Fs.type,unit:void 0},D_e={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:Uc.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:Uc.angleAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:Uc.scale,tick:Uc.tick,tickCount:void 0,ticks:void 0,type:"number",unit:void 0},O_e={allowDataOverflow:Fs.allowDataOverflow,allowDecimals:!1,allowDuplicatedCategory:Fs.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:Fs.radiusAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:Fs.scale,tick:Fs.tick,tickCount:Fs.tickCount,ticks:void 0,type:"category",unit:void 0},v4=(t,e)=>t.polarAxis.angleAxis[e]!=null?t.polarAxis.angleAxis[e]:t.layout.layoutType==="radial"?D_e:P_e,_4=(t,e)=>t.polarAxis.radiusAxis[e]!=null?t.polarAxis.radiusAxis[e]:t.layout.layoutType==="radial"?O_e:R_e,vN=t=>t.polarOptions,w4=et([xu,bu,Ii],fX),gY=et([vN,w4],(t,e)=>{if(t!=null)return Oa(t.innerRadius,e,0)}),xY=et([vN,w4],(t,e)=>{if(t!=null)return Oa(t.outerRadius,e,e*.8)}),L_e=t=>{if(t==null)return[0,0];var{startAngle:e,endAngle:n}=t;return[e,n]},bY=et([vN],L_e);et([v4,bY],yN);var yY=et([w4,gY,xY],(t,e,n)=>{if(!(t==null||e==null||n==null))return[e,n]});et([_4,yY],yN);var vY=et([On,vN,gY,xY,xu,bu],(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:Oa(o,i,i/2),cy:Oa(l,a,a/2),innerRadius:n,outerRadius:r,startAngle:c,endAngle:u,clockWise:!1}}}),Hr=(t,e)=>e,_y=(t,e,n)=>n;function _N(t){return t?.id}function _Y(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=_N(l);u.forEach((f,m)=>{var p=a==null||i?m:String(ir(f,a,null)),x=ir(f,l.dataKey,0),y;o.has(p)?y=o.get(p):y={},Object.assign(y,{[d]:x}),o.set(p,y)})}}),Array.from(o.values())}function wN(t){return t.stackId!=null&&t.dataKey!=null}var SN=(t,e)=>t===e?!0:t==null||e==null?!1:t[0]===e[0]&&t[1]===e[1];function NN(t,e){return Array.isArray(t)&&Array.isArray(e)&&t.length===0&&e.length===0?!0:t===e}function I_e(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 zi=t=>{var e=On(t);return e==="horizontal"?"xAxis":e==="vertical"?"yAxis":e==="centric"?"angleAxis":"radiusAxis"},qg=t=>t.tooltip.settings.axisId;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 nS(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){F_e(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 F_e(t,e,n){return(e=U_e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function U_e(t){var e=z_e(t,"string");return typeof e=="symbol"?e:e+""}function z_e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var H3=[0,"auto"],Ki={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},wY=(t,e)=>t.cartesianAxis.xAxis[e],Zl=(t,e)=>{var n=wY(t,e);return n??Ki},Xi={allowDataOverflow:!1,allowDecimals:!0,allowDuplicatedCategory:!0,angle:0,dataKey:void 0,domain:H3,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:hy},SY=(t,e)=>t.cartesianAxis.yAxis[e],Jl=(t,e)=>{var n=SY(t,e);return n??Xi},B_e={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:""},S4=(t,e)=>{var n=t.cartesianAxis.zAxis[e];return n??B_e},qr=(t,e,n)=>{switch(e){case"xAxis":return Zl(t,n);case"yAxis":return Jl(t,n);case"zAxis":return S4(t,n);case"angleAxis":return v4(t,n);case"radiusAxis":return _4(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},$_e=(t,e,n)=>{switch(e){case"xAxis":return Zl(t,n);case"yAxis":return Jl(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},wy=(t,e,n)=>{switch(e){case"xAxis":return Zl(t,n);case"yAxis":return Jl(t,n);case"angleAxis":return v4(t,n);case"radiusAxis":return _4(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},NY=t=>t.graphicalItems.cartesianItems.some(e=>e.type==="bar")||t.graphicalItems.polarItems.some(e=>e.type==="radialBar");function N4(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 Sy=t=>t.graphicalItems.cartesianItems,H_e=et([Hr,_y],N4),M4=(t,e,n)=>t.filter(n).filter(r=>e?.includeHidden===!0?!0:!r.hide),Ny=et([Sy,qr,H_e],M4,{memoizeOptions:{resultEqualityCheck:NN}}),MY=et([Ny],t=>t.filter(e=>e.type==="area"||e.type==="bar").filter(wN)),EY=t=>t.filter(e=>!("stackId"in e)||e.stackId===void 0),V_e=et([Ny],EY),E4=t=>t.map(e=>e.data).filter(Boolean).flat(1),G_e=et([Ny],E4,{memoizeOptions:{resultEqualityCheck:NN}}),T4=(t,e)=>{var{chartData:n=[],dataStartIndex:r,dataEndIndex:i}=e;return t.length>0?t:n.slice(r,i+1)},A4=et([G_e,yy],T4),C4=(t,e,n)=>e?.dataKey!=null?t.map(r=>({value:ir(r,e.dataKey)})):n.length>0?n.map(r=>r.dataKey).flatMap(r=>t.map(i=>({value:ir(i,r)}))):t.map(r=>({value:r})),MN=et([A4,qr,Ny],C4);function TY(t,e){switch(t){case"xAxis":return e.direction==="x";case"yAxis":return e.direction==="y";default:return!1}}function W1(t){if(Oo(t)||t instanceof Date){var e=Number(t);if(ar(e))return e}}function w6(t){if(Array.isArray(t)){var e=[W1(t[0]),W1(t[1])];return Vd(e)?e:void 0}var n=W1(t);if(n!=null)return[n,n]}function hu(t){return t.map(W1).filter($me)}function W_e(t,e,n){return!n||typeof e!="number"||ws(e)?[]:n.length?hu(n.flatMap(r=>{var i=ir(t,r.dataKey),a,o;if(Array.isArray(i)?[a,o]=i:a=o=i,!(!ar(a)||!ar(o)))return[e-a,e+o]})):[]}var Bi=t=>{var e=zi(t),n=qg(t);return wy(t,e,n)},My=et([Bi],t=>t?.dataKey),q_e=et([MY,yy,Bi],_Y),AY=(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(_N);return[l,{stackedData:hxe(t,d,n),graphicalItems:u}]}))},k0=et([q_e,MY,vy,mY],AY),CY=(t,e,n,r)=>{var{dataStartIndex:i,dataEndIndex:a}=e;if(r==null&&n!=="zAxis"){var o=gxe(t,i,a);if(!(o!=null&&o[0]===0&&o[1]===0))return o}},K_e=et([qr],t=>t.allowDataOverflow),k4=t=>{var e;if(t==null||!("domain"in t))return H3;if(t.domain!=null)return t.domain;if(t.ticks!=null){if(t.type==="number"){var n=hu(t.ticks);return[Math.min(...n),Math.max(...n)]}if(t.type==="category")return t.ticks.map(String)}return(e=t?.domain)!==null&&e!==void 0?e:H3},j4=et([qr],k4),P4=et([j4,K_e],ZX),X_e=et([k0,oh,Hr,P4],CY,{memoizeOptions:{resultEqualityCheck:SN}}),EN=t=>t.errorBars,Y_e=(t,e,n)=>t.flatMap(r=>e[r.id]).filter(Boolean).filter(r=>TY(n,r)),rS=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]}},R4=(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=>TY(i,v)),m=ir(l,(d=e.dataKey)!==null&&d!==void 0?d:c.dataKey),p=W_e(l,m,f);if(p.length>=2){var x=Math.min(...p),y=Math.max(...p);(a==null||x<a)&&(a=x),(o==null||y>o)&&(o=y)}var b=w6(m);b!=null&&(a=a==null?b[0]:Math.min(a,b[0]),o=o==null?b[1]:Math.max(o,b[1]))})}),e?.dataKey!=null&&t.forEach(l=>{var c=w6(ir(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]))}),ar(a)&&ar(o))return[a,o]},Q_e=et([A4,qr,V_e,EN,Hr],R4,{memoizeOptions:{resultEqualityCheck:SN}});function Z_e(t){var{value:e}=t;if(Oo(e)||e instanceof Date)return e}var J_e=(t,e,n)=>{var r=t.map(Z_e).filter(i=>i!=null);return n&&(e.dataKey==null||e.allowDuplicatedCategory&&Vq(r))?xX(0,t.length):e.allowDuplicatedCategory?r:Array.from(new Set(r))},kY=t=>t.referenceElements.dots,Kg=(t,e,n)=>t.filter(r=>r.ifOverflow==="extendDomain").filter(r=>e==="xAxis"?r.xAxisId===n:r.yAxisId===n),e1e=et([kY,Hr,_y],Kg),jY=t=>t.referenceElements.areas,t1e=et([jY,Hr,_y],Kg),PY=t=>t.referenceElements.lines,n1e=et([PY,Hr,_y],Kg),RY=(t,e)=>{var n=hu(t.map(r=>e==="xAxis"?r.x:r.y));if(n.length!==0)return[Math.min(...n),Math.max(...n)]},r1e=et(e1e,Hr,RY),DY=(t,e)=>{var n=hu(t.flatMap(r=>[e==="xAxis"?r.x1:r.y1,e==="xAxis"?r.x2:r.y2]));if(n.length!==0)return[Math.min(...n),Math.max(...n)]},i1e=et([t1e,Hr],DY);function a1e(t){var e;if(t.x!=null)return hu([t.x]);var n=(e=t.segment)===null||e===void 0?void 0:e.map(r=>r.x);return n==null||n.length===0?[]:hu(n)}function s1e(t){var e;if(t.y!=null)return hu([t.y]);var n=(e=t.segment)===null||e===void 0?void 0:e.map(r=>r.y);return n==null||n.length===0?[]:hu(n)}var OY=(t,e)=>{var n=t.flatMap(r=>e==="xAxis"?a1e(r):s1e(r));if(n.length!==0)return[Math.min(...n),Math.max(...n)]},o1e=et([n1e,Hr],OY),l1e=et(r1e,o1e,i1e,(t,e,n)=>rS(t,n,e)),D4=(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?rS(r,a,i):rS(a,i);return b_e(e,u,t.allowDataOverflow)},c1e=et([qr,j4,P4,X_e,Q_e,l1e,On,Hr],D4,{memoizeOptions:{resultEqualityCheck:SN}}),u1e=[0,1],O4=(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=Ql(e,a);if(u&&l==null){var d;return xX(0,(d=n?.length)!==null&&d!==void 0?d:0)}return c==="category"?J_e(r,t,u):i==="expand"?u1e:o}},L4=et([qr,On,A4,MN,vy,Hr,c1e],O4),LY=(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(sy(a));return l in Eb?l:"point"}}},Xg=et([qr,On,NY,x4,Hr],LY);function d1e(t){if(t!=null){if(t in Eb)return Eb[t]();var e="scale".concat(sy(t));if(e in Eb)return Eb[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=d1e(e);if(i!=null){var a=i.domain(n).range(r);return oxe(a),a}}}var F4=(t,e,n)=>{var r=k4(e);if(!(n!=="auto"&&n!=="linear")){if(e!=null&&e.tickCount&&Array.isArray(r)&&(r[0]==="auto"||r[1]==="auto")&&Vd(t))return T_e(t,e.tickCount,e.allowDecimals);if(e!=null&&e.tickCount&&e.type==="number"&&Vd(t))return A_e(t,e.tickCount,e.allowDecimals)}},U4=et([L4,wy,Xg],F4),z4=(t,e,n,r)=>{if(r!=="angleAxis"&&t?.type==="number"&&Vd(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},h1e=et([qr,L4,U4,Hr],z4),f1e=et(MN,qr,(t,e)=>{if(!(!e||e.type!=="number")){var n=1/0,r=Array.from(hu(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}}),IY=et(f1e,On,fY,Ii,(t,e,n,r)=>r,(t,e,n,r,i)=>{if(!ar(t))return 0;var a=e==="vertical"?r.height:r.width;if(i==="gap")return t*a/2;if(i==="no-gap"){var o=Oa(n,t*a),l=t*a/2;return l-o-(l-o)/a*o}return 0}),m1e=(t,e)=>{var n=Zl(t,e);return n==null||typeof n.padding!="string"?0:IY(t,"xAxis",e,n.padding)},p1e=(t,e)=>{var n=Jl(t,e);return n==null||typeof n.padding!="string"?0:IY(t,"yAxis",e,n.padding)},g1e=et(Zl,m1e,(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}}),x1e=et(Jl,p1e,(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}}),b1e=et([Ii,g1e,lN,oN,(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]}),y1e=et([Ii,On,x1e,lN,oN,(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]}),Ey=(t,e,n,r)=>{var i;switch(e){case"xAxis":return b1e(t,n,r);case"yAxis":return y1e(t,n,r);case"zAxis":return(i=S4(t,n))===null||i===void 0?void 0:i.range;case"angleAxis":return bY(t);case"radiusAxis":return yY(t,n);default:return}},FY=et([qr,Ey],yN),Gd=et([qr,Xg,h1e,FY],I4);et([Ny,EN,Hr],Y_e);function UY(t,e){return t.id<e.id?-1:t.id>e.id?1:0}var TN=(t,e)=>e,AN=(t,e,n)=>n,v1e=et(aN,TN,AN,(t,e,n)=>t.filter(r=>r.orientation===e).filter(r=>r.mirror===n).sort(UY)),_1e=et(sN,TN,AN,(t,e,n)=>t.filter(r=>r.orientation===e).filter(r=>r.mirror===n).sort(UY)),zY=(t,e)=>({width:t.width,height:e.height}),w1e=(t,e)=>{var n=typeof e.width=="number"?e.width:hy;return{width:n,height:t.height}},BY=et(Ii,Zl,zY),S1e=(t,e,n)=>{switch(e){case"top":return t.top;case"bottom":return n-t.bottom;default:return 0}},N1e=(t,e,n)=>{switch(e){case"left":return t.left;case"right":return n-t.right;default:return 0}},M1e=et(bu,Ii,v1e,TN,AN,(t,e,n,r,i)=>{var a={},o;return n.forEach(l=>{var c=zY(e,l);o==null&&(o=S1e(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}),E1e=et(xu,Ii,_1e,TN,AN,(t,e,n,r,i)=>{var a={},o;return n.forEach(l=>{var c=w1e(e,l);o==null&&(o=N1e(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}),T1e=(t,e)=>{var n=Zl(t,e);if(n!=null)return M1e(t,n.orientation,n.mirror)},A1e=et([Ii,Zl,T1e,(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}}}),C1e=(t,e)=>{var n=Jl(t,e);if(n!=null)return E1e(t,n.orientation,n.mirror)},k1e=et([Ii,Jl,C1e,(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}}}),$Y=et(Ii,Jl,(t,e)=>{var n=typeof e.width=="number"?e.width:hy;return{width:n,height:t.height}}),S6=(t,e,n)=>{switch(e){case"xAxis":return BY(t,n).width;case"yAxis":return $Y(t,n).height;default:return}},HY=(t,e,n,r)=>{if(n!=null){var{allowDuplicatedCategory:i,type:a,dataKey:o}=n,l=Ql(t,r),c=e.map(u=>u.value);if(o&&l&&a==="category"&&i&&Vq(c))return c}},B4=et([On,MN,qr,Hr],HY),VY=(t,e,n,r)=>{if(!(n==null||n.dataKey==null)){var{type:i,scale:a}=n,o=Ql(t,r);if(o&&(i==="number"||a!=="auto"))return e.map(l=>l.value)}},$4=et([On,MN,wy,Hr],VY),N6=et([On,$_e,Xg,Gd,B4,$4,Ey,U4,Hr],(t,e,n,r,i,a,o,l,c)=>{if(e!=null){var u=Ql(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}}}),j1e=(t,e,n,r,i,a,o,l,c)=>{if(!(e==null||r==null)){var u=Ql(t,c),{type:d,ticks:f,tickCount:m}=e,p=n==="scaleBand"&&typeof r.bandwidth=="function"?r.bandwidth()/2:2,x=d==="category"&&r.bandwidth?r.bandwidth()/p:0;x=c==="angleAxis"&&a!=null&&a.length>=2?Ji(a[0]-a[1])*2*x:x;var y=f||i;if(y){var b=y.map((v,N)=>{var S=o?o.indexOf(v):v;return{index:N,coordinate:r(S)+x,value:v,offset:x}});return b.filter(v=>ar(v.coordinate))}return u&&l?l.map((v,N)=>({coordinate:r(v)+x,value:v,index:N,offset:x})).filter(v=>ar(v.coordinate)):r.ticks?r.ticks(m).map(v=>({coordinate:r(v)+x,value:v,offset:x})):r.domain().map((v,N)=>({coordinate:r(v)+x,value:o?o[v]:v,index:N,offset:x}))}},GY=et([On,wy,Xg,Gd,U4,Ey,B4,$4,Hr],j1e),P1e=(t,e,n,r,i,a,o)=>{if(!(e==null||n==null||r==null||r[0]===r[1])){var l=Ql(t,o),{tickCount:c}=e,u=0;return u=o==="angleAxis"&&r?.length>=2?Ji(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}))}},Hl=et([On,wy,Gd,Ey,B4,$4,Hr],P1e),Vl=et(qr,Gd,(t,e)=>{if(!(t==null||e==null))return nS(nS({},t),{},{scale:e})}),R1e=et([qr,Xg,L4,FY],I4);et((t,e,n)=>S4(t,n),R1e,(t,e)=>{if(!(t==null||e==null))return nS(nS({},t),{},{scale:e})});var D1e=et([On,aN,sN],(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}}),WY=t=>t.options.defaultTooltipEventType,qY=t=>t.options.validateTooltipEventTypes;function KY(t,e,n){if(t==null)return e;var r=t?"axis":"item";return n==null?e:n.includes(r)?r:e}function H4(t,e){var n=WY(t),r=qY(t);return KY(e,n,r)}function O1e(t){return Ft(e=>H4(e,t))}var XY=(t,e)=>{var n,r=Number(e);if(!(ws(r)||e==null))return r>=0?t==null||(n=t[r])===null||n===void 0?void 0:n.value:void 0},L1e=t=>t.tooltip.settings,gd={active:!1,index:null,dataKey:void 0,graphicalItemId:void 0,coordinate:void 0},I1e={itemInteraction:{click:gd,hover:gd},axisInteraction:{click:gd,hover:gd},keyboardInteraction:gd,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}},YY=Ss({name:"tooltip",initialState:I1e,reducers:{addTooltipEntrySettings:{reducer(t,e){t.tooltipItemPayloads.push(e.payload)},prepare:Ir()},replaceTooltipEntrySettings:{reducer(t,e){var{prev:n,next:r}=e.payload,i=al(t).tooltipItemPayloads.indexOf(n);i>-1&&(t.tooltipItemPayloads[i]=r)},prepare:Ir()},removeTooltipEntrySettings:{reducer(t,e){var n=al(t).tooltipItemPayloads.indexOf(e.payload);n>-1&&t.tooltipItemPayloads.splice(n,1)},prepare:Ir()},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:F1e,replaceTooltipEntrySettings:U1e,removeTooltipEntrySettings:z1e,setTooltipSettingsState:B1e,setActiveMouseOverItemIndex:QY,mouseLeaveItem:$1e,mouseLeaveChart:ZY,setActiveClickItemIndex:H1e,setMouseOverAxisIndex:JY,setMouseClickAxisIndex:V1e,setSyncInteraction:V3,setKeyboardInteraction:G3}=YY.actions,G1e=YY.reducer;function M6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function x_(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?M6(Object(n),!0).forEach(function(r){W1e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):M6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function W1e(t,e,n){return(e=q1e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function q1e(t){var e=K1e(t,"string");return typeof e=="symbol"?e:e+""}function K1e(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 X1e(t,e,n){return e==="axis"?n==="click"?t.axisInteraction.click:t.axisInteraction.hover:n==="click"?t.itemInteraction.click:t.itemInteraction.hover}function Y1e(t){return t.index!=null}var eQ=(t,e,n,r)=>{if(e==null)return gd;var i=X1e(t,e,n);if(i==null)return gd;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(Y1e(i)){if(a)return x_(x_({},i),{},{active:!0})}else if(r!=null)return{active:!0,coordinate:void 0,dataKey:void 0,index:r,graphicalItemId:void 0};return x_(x_({},gd),{},{coordinate:i.coordinate})};function Q1e(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 Z1e(t,e){var n=Q1e(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 J1e(t,e,n){if(n==null||e==null)return!0;var r=ir(t,e);return r==null||!Vd(n)?!0:Z1e(r,n)}var V4=(t,e,n,r)=>{var i=t?.index;if(i==null)return null;var a=Number(i);if(!ar(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||J1e(u,n,r)?String(c):null},tQ=(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}}}},nQ=(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})},Ty=t=>t.options.tooltipPayloadSearcher,Yg=t=>t.tooltip;function E6(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 T6(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?E6(Object(n),!0).forEach(function(r){ewe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):E6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function ewe(t,e,n){return(e=twe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function twe(t){var e=nwe(t,"string");return typeof e=="symbol"?e:e+""}function nwe(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 rwe(t,e){return t??e}var rQ=(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((m,p)=>{var x,{dataDefinedOnItem:y,settings:b}=p,v=rwe(y,l),N=Array.isArray(v)?UK(v,u,d):v,S=(x=b?.dataKey)!==null&&x!==void 0?x:r,T=b?.nameKey,E;if(r&&Array.isArray(N)&&!Array.isArray(N[0])&&o==="axis"?E=Gq(N,r,i):E=a(N,e,c,T),Array.isArray(E))E.forEach(A=>{var O=T6(T6({},b),{},{name:A.name,unit:A.unit,color:void 0,fill:void 0});m.push(qB({tooltipEntrySettings:O,dataKey:A.dataKey,payload:A.payload,value:ir(A.payload,A.dataKey),name:A.name}))});else{var C;m.push(qB({tooltipEntrySettings:b,dataKey:S,payload:E,value:ir(E,S),name:(C=ir(E,T))!==null&&C!==void 0?C:b?.name}))}return m},f)}},G4=et([Bi,On,NY,x4,zi],LY),iwe=et([t=>t.graphicalItems.cartesianItems,t=>t.graphicalItems.polarItems],(t,e)=>[...t,...e]),awe=et([zi,qg],N4),Ay=et([iwe,Bi,awe],M4,{memoizeOptions:{resultEqualityCheck:NN}}),swe=et([Ay],t=>t.filter(wN)),owe=et([Ay],E4,{memoizeOptions:{resultEqualityCheck:NN}}),Qg=et([owe,oh],T4),lwe=et([swe,oh,Bi],_Y),W4=et([Qg,Bi,Ay],C4),iQ=et([Bi],k4),cwe=et([Bi],t=>t.allowDataOverflow),aQ=et([iQ,cwe],ZX),uwe=et([Ay],t=>t.filter(wN)),dwe=et([lwe,uwe,vy,mY],AY),hwe=et([dwe,oh,zi,aQ],CY),fwe=et([Ay],EY),mwe=et([Qg,Bi,fwe,EN,zi],R4,{memoizeOptions:{resultEqualityCheck:SN}}),pwe=et([kY,zi,qg],Kg),gwe=et([pwe,zi],RY),xwe=et([jY,zi,qg],Kg),bwe=et([xwe,zi],DY),ywe=et([PY,zi,qg],Kg),vwe=et([ywe,zi],OY),_we=et([gwe,vwe,bwe],rS),wwe=et([Bi,iQ,aQ,hwe,mwe,_we,On,zi],D4),Cy=et([Bi,On,Qg,W4,vy,zi,wwe],O4),Swe=et([Cy,Bi,G4],F4),Nwe=et([Bi,Cy,Swe,zi],z4),sQ=t=>{var e=zi(t),n=qg(t),r=!1;return Ey(t,e,n,r)},oQ=et([Bi,sQ],yN),lQ=et([Bi,G4,Nwe,oQ],I4),Mwe=et([On,W4,Bi,zi],HY),Ewe=et([On,W4,Bi,zi],VY),Twe=(t,e,n,r,i,a,o,l)=>{if(e){var{type:c}=e,u=Ql(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?Ji(i[0]-i[1])*2*f:f,u&&o?o.map((m,p)=>({coordinate:r(m)+f,value:m,index:p,offset:f})):r.domain().map((m,p)=>({coordinate:r(m)+f,value:a?a[m]:m,index:p,offset:f}))}}},vu=et([On,Bi,G4,lQ,sQ,Mwe,Ewe,zi],Twe),q4=et([WY,qY,L1e],(t,e,n)=>KY(n.shared,t,e)),cQ=t=>t.tooltip.settings.trigger,K4=t=>t.tooltip.settings.defaultIndex,ky=et([Yg,q4,cQ,K4],eQ),Wd=et([ky,Qg,My,Cy],V4),uQ=et([vu,Wd],XY),X4=et([ky],t=>{if(t)return t.dataKey}),Awe=et([ky],t=>{if(t)return t.graphicalItemId}),dQ=et([Yg,q4,cQ,K4],nQ),Cwe=et([xu,bu,On,Ii,vu,K4,dQ,Ty],tQ),kwe=et([ky,Cwe],(t,e)=>t!=null&&t.coordinate?t.coordinate:e),jwe=et([ky],t=>t.active),Pwe=et([dQ,Wd,oh,My,uQ,Ty,q4],rQ),Rwe=et([Pwe],t=>{if(t!=null){var e=t.map(n=>n.payload).filter(n=>n!=null);return Array.from(new Set(e))}});function A6(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 C6(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?A6(Object(n),!0).forEach(function(r){Dwe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):A6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Dwe(t,e,n){return(e=Owe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Owe(t){var e=Lwe(t,"string");return typeof e=="symbol"?e:e+""}function Lwe(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 Iwe=()=>Ft(Bi),Fwe=()=>{var t=Iwe(),e=Ft(vu),n=Ft(lQ);return Hd(!t||!n?void 0:C6(C6({},t),{},{scale:n}),e)};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 Bm(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){Uwe(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 Uwe(t,e,n){return(e=zwe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function zwe(t){var e=Bwe(t,"string");return typeof e=="symbol"?e:e+""}function Bwe(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 $we=(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}},Hwe=(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 Bm(Bm(Bm({},r),wi(r.cx,r.cy,o,a)),{},{angle:a,radius:o})}var l=i.coordinate,{angle:c}=r;return Bm(Bm(Bm({},r),wi(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 Vwe(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 hQ=(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,m=void 0;if(Ji(d-u)!==Ji(f-d)){var p=[];if(Ji(f-d)===Ji(i[1]-i[0])){m=f;var x=d+i[1]-i[0];p[0]=Math.min(x,(x+u)/2),p[1]=Math.max(x,(x+u)/2)}else{m=u;var y=f+i[1]-i[0];p[0]=Math.min(d,(y+d)/2),p[1]=Math.max(d,(y+d)/2)}var b=[Math.min(d,(m+d)/2),Math.max(d,(m+d)/2)];if(t>b[0]&&t<=b[1]||t>=p[0]&&t<=p[1]){({index:o}=n[c]);break}}else{var v=Math.min(u,f),N=Math.max(u,f);if(t>(v+d)/2&&t<=(N+d)/2){({index:o}=n[c]);break}}}else if(e){for(var S=0;S<l;S++)if(S===0&&t<=(e[S].coordinate+e[S+1].coordinate)/2||S>0&&S<l-1&&t>(e[S].coordinate+e[S-1].coordinate)/2&&t<=(e[S].coordinate+e[S+1].coordinate)/2||S===l-1&&t>(e[S].coordinate+e[S-1].coordinate)/2){({index:o}=e[S]);break}}return o},fQ=()=>Ft(x4),Y4=(t,e)=>e,mQ=(t,e,n)=>n,Q4=(t,e,n,r)=>r,Gwe=et(vu,t=>Y2(t,e=>e.coordinate)),Z4=et([Yg,Y4,mQ,Q4],eQ),J4=et([Z4,Qg,My,Cy],V4),Wwe=(t,e,n)=>{if(e!=null){var r=Yg(t);return e==="axis"?n==="hover"?r.axisInteraction.hover.dataKey:r.axisInteraction.click.dataKey:n==="hover"?r.itemInteraction.hover.dataKey:r.itemInteraction.click.dataKey}},pQ=et([Yg,Y4,mQ,Q4],nQ),iS=et([xu,bu,On,Ii,vu,Q4,pQ,Ty],tQ),qwe=et([Z4,iS],(t,e)=>{var n;return(n=t.coordinate)!==null&&n!==void 0?n:e}),gQ=et([vu,J4],XY),Kwe=et([pQ,J4,oh,My,gQ,Ty,Y4],rQ),Xwe=et([Z4,J4],(t,e)=>({isActive:t.active&&e!=null,activeIndex:e})),Ywe=(t,e,n,r,i,a,o)=>{if(!(!t||!n||!r||!i)&&Vwe(t,o)){var l=xxe(t,e),c=hQ(l,a,i,n,r),u=$we(e,i,c,t);return{activeIndex:String(c),activeCoordinate:u}}},Qwe=(t,e,n,r,i,a,o)=>{if(!(!t||!r||!i||!a||!n)){var l=D0e(t,n);if(l){var c=bxe(l,e),u=hQ(c,o,a,r,i),d=Hwe(e,a,u,l);return{activeIndex:String(u),activeCoordinate:d}}}},Zwe=(t,e,n,r,i,a,o,l)=>{if(!(!t||!e||!r||!i||!a))return e==="horizontal"||e==="vertical"?Ywe(t,e,r,i,a,o,l):Qwe(t,e,n,r,i,a,o)},Jwe=et(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}}),eSe=et(t=>t.zIndex.zIndexMap,t=>{var e=Object.keys(t).map(r=>parseInt(r,10)).concat(Object.values(ii)),n=Array.from(new Set(e));return n.sort((r,i)=>r-i)},{memoizeOptions:{resultEqualityCheck:I_e}});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 P6(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){tSe(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 tSe(t,e,n){return(e=nSe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function nSe(t){var e=rSe(t,"string");return typeof e=="symbol"?e:e+""}function rSe(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 iSe={},aSe={zIndexMap:Object.values(ii).reduce((t,e)=>P6(P6({},t),{},{[e]:{elementId:void 0,panoramaElementId:void 0,consumers:0}}),iSe)},sSe=new Set(Object.values(ii));function oSe(t){return sSe.has(t)}var xQ=Ss({name:"zIndex",initialState:aSe,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:Ir()},unregisterZIndexPortal:{reducer:(t,e)=>{var{zIndex:n}=e.payload;t.zIndexMap[n]&&(t.zIndexMap[n].consumers-=1,t.zIndexMap[n].consumers<=0&&!oSe(n)&&delete t.zIndexMap[n])},prepare:Ir()},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:Ir()},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:Ir()}}}),{registerZIndexPortal:lSe,unregisterZIndexPortal:cSe,registerZIndexPortalId:uSe,unregisterZIndexPortalId:dSe}=xQ.actions,hSe=xQ.reducer;function La(t){var{zIndex:e,children:n}=t,r=Yxe(),i=r&&e!==void 0&&e!==0,a=Fi(),o=wr();w.useLayoutEffect(()=>i?(o(lSe({zIndex:e})),()=>{o(cSe({zIndex:e}))}):oy,[o,e,i]);var l=Ft(u=>Jwe(u,e,a));if(!i)return n;if(!l)return null;var c=document.getElementById(l);return c?Hc.createPortal(n,c):null}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)}function R6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function b_(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?R6(Object(n),!0).forEach(function(r){fSe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):R6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function fSe(t,e,n){return(e=mSe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function mSe(t){var e=pSe(t,"string");return typeof e=="symbol"?e:e+""}function pSe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function gSe(t){var{cursor:e,cursorComp:n,cursorProps:r}=t;return w.isValidElement(e)?w.cloneElement(e,r):w.createElement(n,r)}function xSe(t){var e,{coordinate:n,payload:r,index:i,offset:a,tooltipAxisBandSize:o,layout:l,cursor:c,tooltipEventType:u,chartName:d}=t,f=n,m=r,p=i;if(!c||!f||d!=="ScatterChart"&&u!=="axis")return null;var x,y,b;if(d==="ScatterChart")x=f,y=Xbe,b=ii.cursorLine;else if(d==="BarChart")x=Ybe(l,f,a,o),y=hX,b=ii.cursorRectangle;else if(l==="radial"&&qq(f)){var{cx:v,cy:N,radius:S,startAngle:T,endAngle:E}=mX(f);x={cx:v,cy:N,startAngle:T,endAngle:E,innerRadius:S,outerRadius:S},y=gX,b=ii.cursorLine}else x={points:F0e(l,f,a)},y=Wp,b=ii.cursorLine;var C=typeof c=="object"&&"className"in c?c.className:void 0,A=b_(b_(b_(b_({stroke:"#ccc",pointerEvents:"none"},a),x),Rf(c)),{},{payload:m,payloadIndex:p,className:$n("recharts-tooltip-cursor",C)});return w.createElement(La,{zIndex:(e=t.zIndex)!==null&&e!==void 0?e:b},w.createElement(gSe,{cursor:c,cursorComp:y,cursorProps:A}))}function bSe(t){var e=Fwe(),n=YK(),r=Jf(),i=fQ();return e==null||n==null||r==null||i==null?null:w.createElement(xSe,W3({},t,{offset:n,layout:r,tooltipAxisBandSize:e,chartName:i}))}var bQ=w.createContext(null),ySe=()=>w.useContext(bQ),tC={exports:{}},D6;function vSe(){return D6||(D6=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,m){if(typeof d!="function")throw new TypeError("The listener must be a function");var p=new i(d,f||c,m),x=n?n+u:u;return c._events[x]?c._events[x].fn?c._events[x]=[c._events[x],p]:c._events[x].push(p):(c._events[x]=p,c._eventsCount++),c}function o(c,u){--c._eventsCount===0?c._events=new r:delete c._events[u]}function l(){this._events=new r,this._eventsCount=0}l.prototype.eventNames=function(){var u=[],d,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 m=0,p=f.length,x=new Array(p);m<p;m++)x[m]=f[m].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,m,p,x){var y=n?n+u:u;if(!this._events[y])return!1;var b=this._events[y],v=arguments.length,N,S;if(b.fn){switch(b.once&&this.removeListener(u,b.fn,void 0,!0),v){case 1:return b.fn.call(b.context),!0;case 2:return b.fn.call(b.context,d),!0;case 3:return b.fn.call(b.context,d,f),!0;case 4:return b.fn.call(b.context,d,f,m),!0;case 5:return b.fn.call(b.context,d,f,m,p),!0;case 6:return b.fn.call(b.context,d,f,m,p,x),!0}for(S=1,N=new Array(v-1);S<v;S++)N[S-1]=arguments[S];b.fn.apply(b.context,N)}else{var T=b.length,E;for(S=0;S<T;S++)switch(b[S].once&&this.removeListener(u,b[S].fn,void 0,!0),v){case 1:b[S].fn.call(b[S].context);break;case 2:b[S].fn.call(b[S].context,d);break;case 3:b[S].fn.call(b[S].context,d,f);break;case 4:b[S].fn.call(b[S].context,d,f,m);break;default:if(!N)for(E=1,N=new Array(v-1);E<v;E++)N[E-1]=arguments[E];b[S].fn.apply(b[S].context,N)}}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,m){var p=n?n+u:u;if(!this._events[p])return this;if(!d)return o(this,p),this;var x=this._events[p];if(x.fn)x.fn===d&&(!m||x.once)&&(!f||x.context===f)&&o(this,p);else{for(var y=0,b=[],v=x.length;y<v;y++)(x[y].fn!==d||m&&!x[y].once||f&&x[y].context!==f)&&b.push(x[y]);b.length?this._events[p]=b.length===1?b[0]:b:o(this,p)}return this},l.prototype.removeAllListeners=function(u){var d;return u?(d=n?n+u:u,this._events[d]&&o(this,d)):(this._events=new r,this._eventsCount=0),this},l.prototype.off=l.prototype.removeListener,l.prototype.addListener=l.prototype.on,l.prefixed=n,l.EventEmitter=l,t.exports=l})(tC)),tC.exports}var _Se=vSe();const wSe=Fo(_Se);var j0=new wSe,q3="recharts.syncEvent.tooltip",O6="recharts.syncEvent.brush";function CN(t,e){if(e){var n=Number.parseInt(e,10);if(!ws(n))return t?.[n]}}var SSe={chartName:"",tooltipPayloadSearcher:void 0,eventEmitter:void 0,defaultTooltipEventType:"axis"},yQ=Ss({name:"options",initialState:SSe,reducers:{createEventEmitter:t=>{t.eventEmitter==null&&(t.eventEmitter=Symbol("rechartsEventEmitter"))}}}),NSe=yQ.reducer,{createEventEmitter:MSe}=yQ.actions;function ESe(t){return t.tooltip.syncInteraction}var TSe={chartData:void 0,computedData:void 0,dataStartIndex:0,dataEndIndex:0},vQ=Ss({name:"chartData",initialState:TSe,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:L6,setDataStartEndIndexes:ASe,setComputedData:EXe}=vQ.actions,CSe=vQ.reducer,kSe=["x","y"];function I6(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 $m(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?I6(Object(n),!0).forEach(function(r){jSe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):I6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function jSe(t,e,n){return(e=PSe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function PSe(t){var e=RSe(t,"string");return typeof e=="symbol"?e:e+""}function RSe(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 DSe(t,e){if(t==null)return{};var n,r,i=OSe(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 OSe(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 LSe(){var t=Ft(b4),e=Ft(y4),n=wr(),r=Ft(pY),i=Ft(vu),a=Jf(),o=fy(),l=Ft(c=>c.rootProps.className);w.useEffect(()=>{if(t==null)return oy;var c=(u,d,f)=>{if(e!==f&&t===u){if(r==="index"){var m;if(o&&d!==null&&d!==void 0&&(m=d.payload)!==null&&m!==void 0&&m.coordinate&&d.payload.sourceViewBox){var p=d.payload.coordinate,{x,y}=p,b=DSe(p,kSe),{x:v,y:N,width:S,height:T}=d.payload.sourceViewBox,E=$m($m({},b),{},{x:o.x+(S?(x-v)/S:0)*o.width,y:o.y+(T?(y-N)/T:0)*o.height});n($m($m({},d),{},{payload:$m($m({},d.payload),{},{coordinate:E})}))}else n(d);return}if(i!=null){var C;if(typeof r=="function"){var A={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},O=r(i,A);C=i[O]}else r==="value"&&(C=i.find(Y=>String(Y.value)===d.payload.label));var{coordinate:k}=d.payload;if(C==null||d.payload.active===!1||k==null||o==null){n(V3({active:!1,coordinate:void 0,dataKey:void 0,index:null,label:void 0,sourceViewBox:void 0,graphicalItemId:void 0}));return}var{x:R,y:F}=k,L=Math.min(R,o.x+o.width),K=Math.min(F,o.y+o.height),j={x:a==="horizontal"?C.coordinate:L,y:a==="horizontal"?K:C.coordinate},W=V3({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(W)}}};return j0.on(q3,c),()=>{j0.off(q3,c)}},[l,n,e,t,r,i,a,o])}function ISe(){var t=Ft(b4),e=Ft(y4),n=wr();w.useEffect(()=>{if(t==null)return oy;var r=(i,a,o)=>{e!==o&&t===i&&n(ASe(a))};return j0.on(O6,r),()=>{j0.off(O6,r)}},[n,e,t])}function FSe(){var t=wr();w.useEffect(()=>{t(MSe())},[t]),LSe(),ISe()}function USe(t,e,n,r,i,a){var o=Ft(p=>Wwe(p,t,e)),l=Ft(y4),c=Ft(b4),u=Ft(pY),d=Ft(ESe),f=d?.active,m=fy();w.useEffect(()=>{if(!f&&c!=null&&l!=null){var p=V3({active:a,coordinate:n,dataKey:o,index:i,label:typeof r=="number"?String(r):r,sourceViewBox:m,graphicalItemId:void 0});j0.emit(q3,c,p,l)}},[f,n,o,i,r,l,c,u,a,m])}function F6(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 U6(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?F6(Object(n),!0).forEach(function(r){zSe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):F6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function zSe(t,e,n){return(e=BSe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function BSe(t){var e=$Se(t,"string");return typeof e=="symbol"?e:e+""}function $Se(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 HSe(t){return t.dataKey}function VSe(t,e){return w.isValidElement(t)?w.cloneElement(t,e):typeof t=="function"?w.createElement(t,e):w.createElement(Abe,e)}var z6=[],GSe={allowEscapeViewBox:{x:!1,y:!1},animationDuration:400,animationEasing:"ease",axisId:0,contentStyle:{},cursor:!0,filterNull:!0,isAnimationActive:"auto",itemSorter:"name",itemStyle:{},labelStyle:{},offset:10,reverseDirection:{x:!1,y:!1},separator:" : ",trigger:"hover",useTranslate3d:!1,wrapperStyle:{}};function q1(t){var e,n,r=Wr(t,GSe),{active:i,allowEscapeViewBox:a,animationDuration:o,animationEasing:l,content:c,filterNull:u,isAnimationActive:d,offset:f,payloadUniqBy:m,position:p,reverseDirection:x,useTranslate3d:y,wrapperStyle:b,cursor:v,shared:N,trigger:S,defaultIndex:T,portal:E,axisId:C}=r,A=wr(),O=typeof T=="number"?String(T):T;w.useEffect(()=>{A(B1e({shared:N,trigger:S,axisId:C,active:i,defaultIndex:O}))},[A,N,S,C,i,O]);var k=fy(),R=oX(),F=O1e(N),{activeIndex:L,isActive:K}=(e=Ft(ce=>Xwe(ce,F,S,O)))!==null&&e!==void 0?e:{},j=Ft(ce=>Kwe(ce,F,S,O)),W=Ft(ce=>gQ(ce,F,S,O)),Y=Ft(ce=>qwe(ce,F,S,O)),q=j,Q=ySe(),ee=(n=i??K)!==null&&n!==void 0?n:!1,[re,z]=cK([q,ee]),G=F==="axis"?W:void 0;USe(F,S,Y,G,L,ee);var ae=E??Q;if(ae==null||k==null||F==null)return null;var se=q??z6;ee||(se=z6),u&&se.length&&(se=rK(se.filter(ce=>ce.value!=null&&(ce.hide!==!0||r.includeHidden)),m,HSe));var ue=se.length>0,pe=w.createElement(Obe,{allowEscapeViewBox:a,animationDuration:o,animationEasing:l,isAnimationActive:d,active:ee,coordinate:Y,hasPayload:ue,offset:f,position:p,reverseDirection:x,useTranslate3d:y,viewBox:k,wrapperStyle:b,lastBoundingBox:re,innerRef:z,hasPortalFromProps:!!E},VSe(c,U6(U6({},r),{},{payload:se,label:G,active:ee,activeIndex:L,coordinate:Y,accessibilityLayer:R})));return w.createElement(w.Fragment,null,Hc.createPortal(pe,ae),ee&&w.createElement(bSe,{cursor:v,tooltipEventType:F,coordinate:Y,payload:se,index:L}))}var jy=t=>null;jy.displayName="Cell";function WSe(t,e,n){return(e=qSe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function qSe(t){var e=KSe(t,"string");return typeof e=="symbol"?e:e+""}function KSe(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 XSe{constructor(e){WSe(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 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 YSe(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){QSe(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 QSe(t,e,n){return(e=ZSe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function ZSe(t){var e=JSe(t,"string");return typeof e=="symbol"?e:e+""}function JSe(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 e2e={cacheSize:2e3,enableCache:!0},_Q=YSe({},e2e),$6=new XSe(_Q.cacheSize),t2e={position:"absolute",top:"-20000px",left:0,padding:0,margin:0,border:"none",whiteSpace:"pre"},H6="recharts_measurement_span";function n2e(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 V6=(t,e)=>{try{var n=document.getElementById(H6);n||(n=document.createElement("span"),n.setAttribute("id",H6),n.setAttribute("aria-hidden","true"),document.body.appendChild(n)),Object.assign(n.style,t2e,e),n.textContent="".concat(t);var r=n.getBoundingClientRect();return{width:r.width,height:r.height}}catch{return{width:0,height:0}}},Bb=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(e==null||Bg.isSsr)return{width:0,height:0};if(!_Q.enableCache)return V6(e,n);var r=n2e(e,n),i=$6.get(r);if(i)return i;var a=V6(e,n);return $6.set(r,a),a},G6=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([*/])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,W6=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([+-])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,r2e=/^px|cm|vh|vw|em|rem|%|mm|in|pt|pc|ex|ch|vmin|vmax|Q$/,i2e=/(-?\d+(?:\.\d+)?)([a-zA-Z%]+)?/,wQ={cm:96/2.54,mm:96/25.4,pt:96/72,pc:96/6,in:96,Q:96/(2.54*40),px:1},a2e=Object.keys(wQ),Ip="NaN";function s2e(t,e){return t*wQ[e]}class hs{static parse(e){var n,[,r,i]=(n=i2e.exec(e))!==null&&n!==void 0?n:[];return new hs(parseFloat(r),i??"")}constructor(e,n){this.num=e,this.unit=n,this.num=e,this.unit=n,ws(e)&&(this.unit=""),n!==""&&!r2e.test(n)&&(this.num=NaN,this.unit=""),a2e.includes(n)&&(this.num=s2e(e,n),this.unit="px")}add(e){return this.unit!==e.unit?new hs(NaN,""):new hs(this.num+e.num,this.unit)}subtract(e){return this.unit!==e.unit?new hs(NaN,""):new hs(this.num-e.num,this.unit)}multiply(e){return this.unit!==""&&e.unit!==""&&this.unit!==e.unit?new hs(NaN,""):new hs(this.num*e.num,this.unit||e.unit)}divide(e){return this.unit!==""&&e.unit!==""&&this.unit!==e.unit?new hs(NaN,""):new hs(this.num/e.num,this.unit||e.unit)}toString(){return"".concat(this.num).concat(this.unit)}isNaN(){return ws(this.num)}}function SQ(t){if(t.includes(Ip))return Ip;for(var e=t;e.includes("*")||e.includes("/");){var n,[,r,i,a]=(n=G6.exec(e))!==null&&n!==void 0?n:[],o=hs.parse(r??""),l=hs.parse(a??""),c=i==="*"?o.multiply(l):o.divide(l);if(c.isNaN())return Ip;e=e.replace(G6,c.toString())}for(;e.includes("+")||/.-\d+(?:\.\d+)?/.test(e);){var u,[,d,f,m]=(u=W6.exec(e))!==null&&u!==void 0?u:[],p=hs.parse(d??""),x=hs.parse(m??""),y=f==="+"?p.add(x):p.subtract(x);if(y.isNaN())return Ip;e=e.replace(W6,y.toString())}return e}var q6=/\(([^()]*)\)/;function o2e(t){for(var e=t,n;(n=q6.exec(e))!=null;){var[,r]=n;e=e.replace(q6,SQ(r))}return e}function l2e(t){var e=t.replace(/\s+/g,"");return e=o2e(e),e=SQ(e),e}function c2e(t){try{return l2e(t)}catch{return Ip}}function nC(t){var e=c2e(t.slice(5,-1));return e===Ip?"":e}var u2e=["x","y","lineHeight","capHeight","fill","scaleToFit","textAnchor","verticalAnchor"],d2e=["dx","dy","angle","className","breakAll"];function K3(){return K3=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},K3.apply(null,arguments)}function K6(t,e){if(t==null)return{};var n,r,i=h2e(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 h2e(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 NQ=/[ \f\n\r\t\v\u2028\u2029]+/,MQ=t=>{var{children:e,breakAll:n,style:r}=t;try{var i=[];Pr(e)||(n?i=e.toString().split(""):i=e.toString().split(NQ));var a=i.map(l=>({word:l,width:Bb(l,r).width})),o=n?0:Bb(" ",r).width;return{wordsWithComputedWidth:a,spaceWidth:o}}catch{return null}};function f2e(t){return t==="start"||t==="middle"||t==="end"||t==="inherit"}var EQ=(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},[]),TQ=t=>t.reduce((e,n)=>e.width>n.width?e:n),m2e="…",X6=(t,e,n,r,i,a,o,l)=>{var c=t.slice(0,e),u=MQ({breakAll:n,style:r,children:c+m2e});if(!u)return[!1,[]];var d=EQ(u.wordsWithComputedWidth,a,o,l),f=d.length>i||TQ(d).width>Number(a);return[f,d]},p2e=(t,e,n,r,i)=>{var{maxLines:a,children:o,style:l,breakAll:c}=t,u=Bt(a),d=String(o),f=EQ(e,r,n,i);if(!u||i)return f;var m=f.length>a||TQ(f).width>Number(r);if(!m)return f;for(var p=0,x=d.length-1,y=0,b;p<=x&&y<=d.length-1;){var v=Math.floor((p+x)/2),N=v-1,[S,T]=X6(d,N,c,l,a,r,n,i),[E]=X6(d,v,c,l,a,r,n,i);if(!S&&!E&&(p=v+1),S&&E&&(x=v-1),!S&&E){b=T;break}y++}return b||f},Y6=t=>{var e=Pr(t)?[]:t.toString().split(NQ);return[{words:e,width:void 0}]},g2e=t=>{var{width:e,scaleToFit:n,children:r,style:i,breakAll:a,maxLines:o}=t;if((e||n)&&!Bg.isSsr){var l,c,u=MQ({breakAll:a,children:r,style:i});if(u){var{wordsWithComputedWidth:d,spaceWidth:f}=u;l=d,c=f}else return Y6(r);return p2e({breakAll:a,children:r,maxLines:o,style:i},l,c,e,!!n)}return Y6(r)},AQ="#808080",x2e={angle:0,breakAll:!1,capHeight:"0.71em",fill:AQ,lineHeight:"1em",scaleToFit:!1,textAnchor:"start",verticalAnchor:"end",x:0,y:0},kN=w.forwardRef((t,e)=>{var n=Wr(t,x2e),{x:r,y:i,lineHeight:a,capHeight:o,fill:l,scaleToFit:c,textAnchor:u,verticalAnchor:d}=n,f=K6(n,u2e),m=w.useMemo(()=>g2e({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:p,dy:x,angle:y,className:b,breakAll:v}=f,N=K6(f,d2e);if(!Oo(r)||!Oo(i)||m.length===0)return null;var S=Number(r)+(Bt(p)?p:0),T=Number(i)+(Bt(x)?x:0);if(!ar(S)||!ar(T))return null;var E;switch(d){case"start":E=nC("calc(".concat(o,")"));break;case"middle":E=nC("calc(".concat((m.length-1)/2," * -").concat(a," + (").concat(o," / 2))"));break;default:E=nC("calc(".concat(m.length-1," * -").concat(a,")"));break}var C=[];if(c){var A=m[0].width,{width:O}=f;C.push("scale(".concat(Bt(O)&&Bt(A)?O/A:1,")"))}return y&&C.push("rotate(".concat(y,", ").concat(S,", ").concat(T,")")),C.length&&(N.transform=C.join(" ")),w.createElement("text",K3({},Sa(N),{ref:e,x:S,y:T,className:$n("recharts-text",b),textAnchor:u,fill:l.includes("url")?AQ:l}),m.map((k,R)=>{var F=k.words.join(v?"":" ");return w.createElement("tspan",{x:S,dy:R===0?E:a,key:"".concat(F,"-").concat(R)},F)}))});kN.displayName="Text";var b2e=["labelRef"];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 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 ci(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){_2e(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 _2e(t,e,n){return(e=w2e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function w2e(t){var e=S2e(t,"string");return typeof e=="symbol"?e:e+""}function S2e(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 zc(){return zc=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},zc.apply(null,arguments)}var CQ=w.createContext(null),kQ=t=>{var{x:e,y:n,upperWidth:r,lowerWidth:i,width:a,height:o,children:l}=t,c=w.useMemo(()=>({x:e,y:n,upperWidth:r,lowerWidth:i,width:a,height:o}),[e,n,r,i,a,o]);return w.createElement(CQ.Provider,{value:c},l)},jQ=()=>{var t=w.useContext(CQ),e=fy();return t||XK(e)},N2e=w.createContext(null),M2e=()=>{var t=w.useContext(N2e),e=Ft(vY);return t||e},E2e=t=>{var{value:e,formatter:n}=t,r=Pr(t.children)?e:t.children;return typeof n=="function"?n(r):r},eO=t=>t!=null&&typeof t=="function",T2e=(t,e)=>{var n=Ji(e-t),r=Math.min(Math.abs(e-t),360);return n*r},A2e=(t,e,n,r,i)=>{var{offset:a,className:o}=t,{cx:l,cy:c,innerRadius:u,outerRadius:d,startAngle:f,endAngle:m,clockWise:p}=i,x=(u+d)/2,y=T2e(f,m),b=y>=0?1:-1,v,N;switch(e){case"insideStart":v=f+b*a,N=p;break;case"insideEnd":v=m-b*a,N=!p;break;case"end":v=m+b*a,N=p;break;default:throw new Error("Unsupported position ".concat(e))}N=y<=0?N:!N;var S=wi(l,c,x,v),T=wi(l,c,x,v+(N?1:-1)*359),E="M".concat(S.x,",").concat(S.y,`
  44. A`).concat(x,",").concat(x,",0,1,").concat(N?0:1,`,
  45. `).concat(T.x,",").concat(T.y),C=Pr(t.id)?x0("recharts-radial-line-"):t.id;return w.createElement("text",zc({},r,{dominantBaseline:"central",className:$n("recharts-radial-bar-label",o)}),w.createElement("defs",null,w.createElement("path",{id:C,d:E})),w.createElement("textPath",{xlinkHref:"#".concat(C)},n))},C2e=(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}=wi(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 m=(a+o)/2,{x:p,y:x}=wi(r,i,m,u);return{x:p,y:x,textAnchor:"middle",verticalAnchor:"middle"}},X3=t=>"cx"in t&&Bt(t.cx),k2e=(t,e)=>{var{parentViewBox:n,offset:r,position:i}=t,a;n!=null&&!X3(n)&&(a=n);var{x:o,y:l,upperWidth:c,lowerWidth:u,height:d}=e,f=o,m=o+(c-u)/2,p=(f+m)/2,x=(c+u)/2,y=f+c/2,b=d>=0?1:-1,v=b*r,N=b>0?"end":"start",S=b>0?"start":"end",T=c>=0?1:-1,E=T*r,C=T>0?"end":"start",A=T>0?"start":"end";if(i==="top"){var O={x:f+c/2,y:l-v,textAnchor:"middle",verticalAnchor:N};return ci(ci({},O),a?{height:Math.max(l-a.y,0),width:c}:{})}if(i==="bottom"){var k={x:m+u/2,y:l+d+v,textAnchor:"middle",verticalAnchor:S};return ci(ci({},k),a?{height:Math.max(a.y+a.height-(l+d),0),width:u}:{})}if(i==="left"){var R={x:p-E,y:l+d/2,textAnchor:C,verticalAnchor:"middle"};return ci(ci({},R),a?{width:Math.max(R.x-a.x,0),height:d}:{})}if(i==="right"){var F={x:p+x+E,y:l+d/2,textAnchor:A,verticalAnchor:"middle"};return ci(ci({},F),a?{width:Math.max(a.x+a.width-F.x,0),height:d}:{})}var L=a?{width:x,height:d}:{};return i==="insideLeft"?ci({x:p+E,y:l+d/2,textAnchor:A,verticalAnchor:"middle"},L):i==="insideRight"?ci({x:p+x-E,y:l+d/2,textAnchor:C,verticalAnchor:"middle"},L):i==="insideTop"?ci({x:f+c/2,y:l+v,textAnchor:"middle",verticalAnchor:S},L):i==="insideBottom"?ci({x:m+u/2,y:l+d-v,textAnchor:"middle",verticalAnchor:N},L):i==="insideTopLeft"?ci({x:f+E,y:l+v,textAnchor:A,verticalAnchor:S},L):i==="insideTopRight"?ci({x:f+c-E,y:l+v,textAnchor:C,verticalAnchor:S},L):i==="insideBottomLeft"?ci({x:m+E,y:l+d-v,textAnchor:A,verticalAnchor:N},L):i==="insideBottomRight"?ci({x:m+u-E,y:l+d-v,textAnchor:C,verticalAnchor:N},L):i&&typeof i=="object"&&(Bt(i.x)||ou(i.x))&&(Bt(i.y)||ou(i.y))?ci({x:o+Oa(i.x,x),y:l+Oa(i.y,d),textAnchor:"end",verticalAnchor:"end"},L):ci({x:y,y:l+d/2,textAnchor:"middle",verticalAnchor:"middle"},L)},j2e={angle:0,offset:5,zIndex:ii.label,position:"middle",textBreakAll:!1};function cd(t){var e=Wr(t,j2e),{viewBox:n,position:r,value:i,children:a,content:o,className:l="",textBreakAll:c,labelRef:u}=e,d=M2e(),f=jQ(),m=r==="center"?f:d??f,p,x,y;if(n==null?p=m:X3(n)?p=n:p=XK(n),!p||Pr(i)&&Pr(a)&&!w.isValidElement(o)&&typeof o!="function")return null;var b=ci(ci({},e),{},{viewBox:p});if(w.isValidElement(o)){var{labelRef:v}=b,N=y2e(b,b2e);return w.cloneElement(o,N)}if(typeof o=="function"){if(x=w.createElement(o,b),w.isValidElement(x))return x}else x=E2e(e);var S=Sa(e);if(X3(p)){if(r==="insideStart"||r==="insideEnd"||r==="end")return A2e(e,r,x,S,p);y=C2e(p,e.offset,e.position)}else y=k2e(e,p);return w.createElement(La,{zIndex:e.zIndex},w.createElement(kN,zc({ref:u,className:$n("recharts-label",l)},S,y,{textAnchor:f2e(S.textAnchor)?S.textAnchor:y.textAnchor,breakAll:c}),x))}cd.displayName="Label";var P2e=(t,e,n)=>{if(!t)return null;var r={viewBox:e,labelRef:n};return t===!0?w.createElement(cd,zc({key:"label-implicit"},r)):Oo(t)?w.createElement(cd,zc({key:"label-implicit",value:t},r)):w.isValidElement(t)?t.type===cd?w.cloneElement(t,ci({key:"label-implicit"},r)):w.createElement(cd,zc({key:"label-implicit",content:t},r)):eO(t)?w.createElement(cd,zc({key:"label-implicit",content:t},r)):t&&typeof t=="object"?w.createElement(cd,zc({},t,{key:"label-implicit"},r)):null};function PQ(t){var{label:e,labelRef:n}=t,r=jQ();return P2e(e,r,n)||null}var rC={},iC={},Z6;function R2e(){return Z6||(Z6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n[n.length-1]}t.last=e})(iC)),iC}var aC={},J6;function D2e(){return J6||(J6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Array.isArray(n)?n:Array.from(n)}t.toArray=e})(aC)),aC}var e$;function O2e(){return e$||(e$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=R2e(),n=D2e(),r=AD();function i(a){if(r.isArrayLike(a))return e.last(n.toArray(a))}t.last=i})(rC)),rC}var sC,t$;function L2e(){return t$||(t$=1,sC=O2e().last),sC}var I2e=L2e();const F2e=Fo(I2e);var U2e=["valueAccessor"],z2e=["dataKey","clockWise","id","textBreakAll","zIndex"];function aS(){return aS=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},aS.apply(null,arguments)}function n$(t,e){if(t==null)return{};var n,r,i=B2e(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 B2e(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var $2e=t=>Array.isArray(t.value)?F2e(t.value):t.value,RQ=w.createContext(void 0),tO=RQ.Provider,DQ=w.createContext(void 0),H2e=DQ.Provider;function V2e(){return w.useContext(RQ)}function G2e(){return w.useContext(DQ)}function K1(t){var{valueAccessor:e=$2e}=t,n=n$(t,U2e),{dataKey:r,clockWise:i,id:a,textBreakAll:o,zIndex:l}=n,c=n$(n,z2e),u=V2e(),d=G2e(),f=u||d;return!f||!f.length?null:w.createElement(La,{zIndex:l??ii.label},w.createElement(Gr,{className:"recharts-label-list"},f.map((m,p)=>{var x,y=Pr(r)?e(m,p):ir(m&&m.payload,r),b=Pr(a)?{}:{id:"".concat(a,"-").concat(p)};return w.createElement(cd,aS({key:"label-".concat(p)},Sa(m),c,b,{fill:(x=n.fill)!==null&&x!==void 0?x:m.fill,parentViewBox:m.parentViewBox,value:y,textBreakAll:o,viewBox:m.viewBox,index:p,zIndex:0}))})))}K1.displayName="LabelList";function jN(t){var{label:e}=t;return e?e===!0?w.createElement(K1,{key:"labelList-implicit"}):w.isValidElement(e)||eO(e)?w.createElement(K1,{key:"labelList-implicit",content:e}):typeof e=="object"?w.createElement(K1,aS({key:"labelList-implicit"},e,{type:String(e.type)})):null:null}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)}var OQ=t=>{var{cx:e,cy:n,r,className:i}=t,a=$n("recharts-dot",i);return Bt(e)&&Bt(n)&&Bt(r)?w.createElement("circle",Y3({},Qa(t),TD(t),{className:a,cx:e,cy:n,r})):null},LQ=t=>t.graphicalItems.polarItems,W2e=et([Hr,_y],N4),PN=et([LQ,qr,W2e],M4),q2e=et([PN],E4),RN=et([q2e,m4],T4),K2e=et([RN,qr,PN],C4);et([RN,qr,PN],(t,e,n)=>n.length>0?t.flatMap(r=>n.flatMap(i=>{var a,o=ir(r,(a=e.dataKey)!==null&&a!==void 0?a:i.dataKey);return{value:o,errorDomain:[]}})).filter(Boolean):e?.dataKey!=null?t.map(r=>({value:ir(r,e.dataKey),errorDomain:[]})):t.map(r=>({value:r,errorDomain:[]})));var r$=()=>{},X2e=et([RN,qr,PN,EN,Hr],R4),Y2e=et([qr,j4,P4,r$,X2e,r$,On,Hr],D4),IQ=et([qr,On,RN,K2e,vy,Hr,Y2e],O4),Q2e=et([IQ,qr,Xg],F4);et([qr,IQ,Q2e,Hr],z4);var Z2e={radiusAxis:{},angleAxis:{}},FQ=Ss({name:"polarAxis",initialState:Z2e,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:TXe,removeRadiusAxis:AXe,addAngleAxis:CXe,removeAngleAxis:kXe}=FQ.actions,J2e=FQ.reducer;function i$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function a$(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?i$(Object(n),!0).forEach(function(r){eNe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):i$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function eNe(t,e,n){return(e=tNe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function tNe(t){var e=nNe(t,"string");return typeof e=="symbol"?e:e+""}function nNe(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 rNe=(t,e)=>e,nO=et([LQ,rNe],(t,e)=>t.filter(n=>n.type==="pie").find(n=>n.id===e)),iNe=[],rO=(t,e,n)=>n?.length===0?iNe:n,UQ=et([m4,nO,rO],(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=>a$(a$({},e.presentationProps),a.props))),i!=null)return i}}),aNe=et([UQ,nO,rO],(t,e,n)=>{if(!(t==null||e==null))return t.map((r,i)=>{var a,o=ir(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:ih(o,e.dataKey),color:l,payload:r,type:e.legendType}})}),sNe=et([UQ,nO,rO,Ii],(t,e,n,r)=>{if(!(e==null||t==null))return oMe({offset:r,pieSettings:e,displayedData:t,cells:n})}),oC={exports:{}},dr={};var s$;function oNe(){if(s$)return dr;s$=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"),m=Symbol.for("react.view_transition"),p=Symbol.for("react.client.reference");function x(y){if(typeof y=="object"&&y!==null){var b=y.$$typeof;switch(b){case t:switch(y=y.type,y){case n:case i:case r:case c:case u:case m:return y;default:switch(y=y&&y.$$typeof,y){case o:case l:case f:case d:return y;case a:return y;default:return b}}case e:return b}}}return dr.ContextConsumer=a,dr.ContextProvider=o,dr.Element=t,dr.ForwardRef=l,dr.Fragment=n,dr.Lazy=f,dr.Memo=d,dr.Portal=e,dr.Profiler=i,dr.StrictMode=r,dr.Suspense=c,dr.SuspenseList=u,dr.isContextConsumer=function(y){return x(y)===a},dr.isContextProvider=function(y){return x(y)===o},dr.isElement=function(y){return typeof y=="object"&&y!==null&&y.$$typeof===t},dr.isForwardRef=function(y){return x(y)===l},dr.isFragment=function(y){return x(y)===n},dr.isLazy=function(y){return x(y)===f},dr.isMemo=function(y){return x(y)===d},dr.isPortal=function(y){return x(y)===e},dr.isProfiler=function(y){return x(y)===i},dr.isStrictMode=function(y){return x(y)===r},dr.isSuspense=function(y){return x(y)===c},dr.isSuspenseList=function(y){return x(y)===u},dr.isValidElementType=function(y){return typeof y=="string"||typeof y=="function"||y===n||y===i||y===r||y===c||y===u||typeof y=="object"&&y!==null&&(y.$$typeof===f||y.$$typeof===d||y.$$typeof===o||y.$$typeof===a||y.$$typeof===l||y.$$typeof===p||y.getModuleId!==void 0)},dr.typeOf=x,dr}var o$;function lNe(){return o$||(o$=1,oC.exports=oNe()),oC.exports}var cNe=lNe(),l$=t=>typeof t=="string"?t:t?t.displayName||t.name||"Component":"",c$=null,lC=null,zQ=t=>{if(t===c$&&Array.isArray(lC))return lC;var e=[];return w.Children.forEach(t,n=>{Pr(n)||(cNe.isFragment(n)?e=e.concat(zQ(n.props.children)):e.push(n))}),lC=e,c$=t,e};function iO(t,e){var n=[],r=[];return Array.isArray(e)?r=e.map(i=>l$(i)):r=[l$(e)],zQ(t).forEach(i=>{var a=Df(i,"type.displayName")||Df(i,"type.name");a&&r.indexOf(a)!==-1&&n.push(i)}),n}var aO=t=>t&&typeof t=="object"&&"clipDot"in t?!!t.clipDot:!0,cC={},u$;function uNe(){return u$||(u$=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})(cC)),cC}var uC,d$;function dNe(){return d$||(d$=1,uC=uNe().isPlainObject),uC}var hNe=dNe();const fNe=Fo(hNe);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 f$(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){mNe(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 mNe(t,e,n){return(e=pNe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function pNe(t){var e=gNe(t,"string");return typeof e=="symbol"?e:e+""}function gNe(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 sS(){return sS=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},sS.apply(null,arguments)}var m$=(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},xNe={x:0,y:0,upperWidth:0,lowerWidth:0,height:0,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},bNe=t=>{var e=Wr(t,xNe),{x:n,y:r,upperWidth:i,lowerWidth:a,height:o,className:l}=e,{animationEasing:c,animationDuration:u,animationBegin:d,isUpdateAnimationActive:f}=e,m=w.useRef(null),[p,x]=w.useState(-1),y=w.useRef(i),b=w.useRef(a),v=w.useRef(o),N=w.useRef(n),S=w.useRef(r),T=Hg(t,"trapezoid-");if(w.useEffect(()=>{if(m.current&&m.current.getTotalLength)try{var j=m.current.getTotalLength();j&&x(j)}catch{}},[]),n!==+n||r!==+r||i!==+i||a!==+a||o!==+o||i===0&&a===0||o===0)return null;var E=$n("recharts-trapezoid",l);if(!f)return w.createElement("g",null,w.createElement("path",sS({},Sa(e),{className:E,d:m$(n,r,i,a,o)})));var C=y.current,A=b.current,O=v.current,k=N.current,R=S.current,F="0px ".concat(p===-1?1:p,"px"),L="".concat(p,"px 0px"),K=lX(["strokeDasharray"],u,c);return w.createElement($g,{animationId:T,key:T,canBegin:p>0,duration:u,easing:c,isActive:f,begin:d},j=>{var W=Zn(C,i,j),Y=Zn(A,a,j),q=Zn(O,o,j),Q=Zn(k,n,j),ee=Zn(R,r,j);m.current&&(y.current=W,b.current=Y,v.current=q,N.current=Q,S.current=ee);var re=j>0?{transition:K,strokeDasharray:L}:{strokeDasharray:F};return w.createElement("path",sS({},Sa(e),{className:E,d:m$(Q,ee,W,Y,q),ref:m,style:f$(f$({},re),e.style)}))})},yNe=["option","shapeType","propTransformer","activeClassName"];function vNe(t,e){if(t==null)return{};var n,r,i=_Ne(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function _Ne(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function p$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function oS(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?p$(Object(n),!0).forEach(function(r){wNe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):p$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function wNe(t,e,n){return(e=SNe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function SNe(t){var e=NNe(t,"string");return typeof e=="symbol"?e:e+""}function NNe(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 MNe(t,e){return oS(oS({},e),t)}function ENe(t,e){return t==="symbols"}function g$(t){var{shapeType:e,elementProps:n}=t;switch(e){case"rectangle":return w.createElement(hX,n);case"trapezoid":return w.createElement(bNe,n);case"sector":return w.createElement(gX,n);case"symbols":if(ENe(e))return w.createElement(ED,n);break;case"curve":return w.createElement(Wp,n);default:return null}}function TNe(t){return w.isValidElement(t)?t.props:t}function sO(t){var{option:e,shapeType:n,propTransformer:r=MNe,activeClassName:i="recharts-active-shape"}=t,a=vNe(t,yNe),o;if(w.isValidElement(e))o=w.cloneElement(e,oS(oS({},a),TNe(e)));else if(typeof e=="function")o=e(a,a.index);else if(fNe(e)&&typeof e!="boolean"){var l=r(e,a);o=w.createElement(g$,{shapeType:n,elementProps:l})}else{var c=a;o=w.createElement(g$,{shapeType:n,elementProps:c})}return a.isActive?w.createElement(Gr,{className:i},o):o}var oO=(t,e,n)=>{var r=wr();return(i,a)=>o=>{t?.(i,a,o),r(QY({activeIndex:String(a),activeDataKey:e,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}},lO=t=>{var e=wr();return(n,r)=>i=>{t?.(n,r,i),e($1e())}},cO=(t,e,n)=>{var r=wr();return(i,a)=>o=>{t?.(i,a,o),r(H1e({activeIndex:String(a),activeDataKey:e,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}};function DN(t){var{tooltipEntrySettings:e}=t,n=wr(),r=Fi(),i=w.useRef(null);return w.useLayoutEffect(()=>{r||(i.current===null?n(F1e(e)):i.current!==e&&n(U1e({prev:i.current,next:e})),i.current=e)},[e,n,r]),w.useLayoutEffect(()=>()=>{i.current&&(n(z1e(i.current)),i.current=null)},[n]),null}function uO(t){var{legendPayload:e}=t,n=wr(),r=Fi(),i=w.useRef(null);return w.useLayoutEffect(()=>{r||(i.current===null?n(iX(e)):i.current!==e&&n(aX({prev:i.current,next:e})),i.current=e)},[n,r,e]),w.useLayoutEffect(()=>()=>{i.current&&(n(sX(i.current)),i.current=null)},[n]),null}function ANe(t){var{legendPayload:e}=t,n=wr(),r=Ft(On),i=w.useRef(null);return w.useLayoutEffect(()=>{r!=="centric"&&r!=="radial"||(i.current===null?n(iX(e)):i.current!==e&&n(aX({prev:i.current,next:e})),i.current=e)},[n,r,e]),w.useLayoutEffect(()=>()=>{i.current&&(n(sX(i.current)),i.current=null)},[n]),null}var dC,CNe=()=>{var[t]=w.useState(()=>x0("uid-"));return t},kNe=(dC=Dae.useId)!==null&&dC!==void 0?dC:CNe;function BQ(t,e){var n=kNe();return e||(t?"".concat(t,"-").concat(n):n)}var jNe=w.createContext(void 0),ON=t=>{var{id:e,type:n,children:r}=t,i=BQ("recharts-".concat(n),e);return w.createElement(jNe.Provider,{value:i},r(i))},PNe={cartesianItems:[],polarItems:[]},$Q=Ss({name:"graphicalItems",initialState:PNe,reducers:{addCartesianGraphicalItem:{reducer(t,e){t.cartesianItems.push(e.payload)},prepare:Ir()},replaceCartesianGraphicalItem:{reducer(t,e){var{prev:n,next:r}=e.payload,i=al(t).cartesianItems.indexOf(n);i>-1&&(t.cartesianItems[i]=r)},prepare:Ir()},removeCartesianGraphicalItem:{reducer(t,e){var n=al(t).cartesianItems.indexOf(e.payload);n>-1&&t.cartesianItems.splice(n,1)},prepare:Ir()},addPolarGraphicalItem:{reducer(t,e){t.polarItems.push(e.payload)},prepare:Ir()},removePolarGraphicalItem:{reducer(t,e){var n=al(t).polarItems.indexOf(e.payload);n>-1&&t.polarItems.splice(n,1)},prepare:Ir()}}}),{addCartesianGraphicalItem:RNe,replaceCartesianGraphicalItem:DNe,removeCartesianGraphicalItem:ONe,addPolarGraphicalItem:LNe,removePolarGraphicalItem:INe}=$Q.actions,FNe=$Q.reducer,UNe=t=>{var e=wr(),n=w.useRef(null);return w.useLayoutEffect(()=>{n.current===null?e(RNe(t)):n.current!==t&&e(DNe({prev:n.current,next:t})),n.current=t},[e,t]),w.useLayoutEffect(()=>()=>{n.current&&(e(ONe(n.current)),n.current=null)},[e]),null},dO=w.memo(UNe);function zNe(t){var e=wr();return w.useLayoutEffect(()=>(e(LNe(t)),()=>{e(INe(t))}),[e,t]),null}var BNe=["key"],$Ne=["onMouseEnter","onClick","onMouseLeave"],HNe=["id"],VNe=["id"];function x$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function ei(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?x$(Object(n),!0).forEach(function(r){GNe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):x$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function GNe(t,e,n){return(e=WNe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function WNe(t){var e=qNe(t,"string");return typeof e=="symbol"?e:e+""}function qNe(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 qd(){return qd=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},qd.apply(null,arguments)}function LN(t,e){if(t==null)return{};var n,r,i=KNe(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 KNe(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 XNe(t){var e=w.useMemo(()=>iO(t.children,jy),[t.children]),n=Ft(r=>aNe(r,t.id,e));return n==null?null:w.createElement(ANe,{legendPayload:n})}var YNe=w.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:ih(l,e),hide:c,type:u,color:o,unit:""}};return w.createElement(DN,{tooltipEntrySettings:d})}),QNe=(t,e)=>t>e?"start":t<e?"end":"middle",ZNe=(t,e,n)=>Oa(typeof e=="function"?e(t):e,n,n*.8),JNe=(t,e,n)=>{var{top:r,left:i,width:a,height:o}=e,l=fX(a,o),c=i+Oa(t.cx,a,a/2),u=r+Oa(t.cy,o,o/2),d=Oa(t.innerRadius,l,0),f=ZNe(n,t.outerRadius,l),m=t.maxRadius||Math.sqrt(a*a+o*o)/2;return{cx:c,cy:u,innerRadius:d,outerRadius:f,maxRadius:m}},eMe=(t,e)=>{var n=Ji(e-t),r=Math.min(Math.abs(e-t),360);return n*r};function tMe(t){return t&&typeof t=="object"&&"className"in t&&typeof t.className=="string"?t.className:""}var nMe=(t,e)=>{if(w.isValidElement(t))return w.cloneElement(t,e);if(typeof t=="function")return t(e);var n=$n("recharts-pie-label-line",typeof t!="boolean"?t.className:""),{key:r}=e,i=LN(e,BNe);return w.createElement(Wp,qd({},i,{type:"linear",className:n}))},rMe=(t,e,n)=>{if(w.isValidElement(t))return w.cloneElement(t,e);var r=n;if(typeof t=="function"&&(r=t(e),w.isValidElement(r)))return r;var i=$n("recharts-pie-label-text",tMe(t));return w.createElement(kN,qd({},e,{alignmentBaseline:"middle",className:i}),r)};function iMe(t){var{sectors:e,props:n,showLabels:r}=t,{label:i,labelLine:a,dataKey:o}=n;if(!r||!i||!e)return null;var l=Qa(n),c=Rf(i),u=Rf(a),d=typeof i=="object"&&"offsetRadius"in i&&typeof i.offsetRadius=="number"&&i.offsetRadius||20,f=e.map((m,p)=>{var x=(m.startAngle+m.endAngle)/2,y=wi(m.cx,m.cy,m.outerRadius+d,x),b=ei(ei(ei(ei({},l),m),{},{stroke:"none"},c),{},{index:p,textAnchor:QNe(y.x,m.cx)},y),v=ei(ei(ei(ei({},l),m),{},{fill:"none",stroke:m.fill},u),{},{index:p,points:[wi(m.cx,m.cy,m.outerRadius,x),y],key:"line"});return w.createElement(La,{zIndex:ii.label,key:"label-".concat(m.startAngle,"-").concat(m.endAngle,"-").concat(m.midAngle,"-").concat(p)},w.createElement(Gr,null,a&&nMe(a,v),rMe(i,b,ir(m,o))))});return w.createElement(Gr,{className:"recharts-pie-labels"},f)}function aMe(t){var{sectors:e,props:n,showLabels:r}=t,{label:i}=n;return typeof i=="object"&&i!=null&&"position"in i?w.createElement(jN,{label:i}):w.createElement(iMe,{sectors:e,props:n,showLabels:r})}function sMe(t){var{sectors:e,activeShape:n,inactiveShape:r,allOtherPieProps:i,shape:a,id:o}=t,l=Ft(Wd),c=Ft(X4),u=Ft(Awe),{onMouseEnter:d,onClick:f,onMouseLeave:m}=i,p=LN(i,$Ne),x=oO(d,i.dataKey,o),y=lO(m),b=cO(f,i.dataKey,o);return e==null||e.length===0?null:w.createElement(w.Fragment,null,e.map((v,N)=>{if(v?.startAngle===0&&v?.endAngle===0&&e.length!==1)return null;var S=u==null||u===o,T=String(N)===l&&(c==null||i.dataKey===c)&&S,E=l?r:null,C=n&&T?n:E,A=ei(ei({},v),{},{stroke:v.stroke,tabIndex:-1,[VK]:N,[GK]:i.dataKey});return w.createElement(Gr,qd({key:"sector-".concat(v?.startAngle,"-").concat(v?.endAngle,"-").concat(v.midAngle,"-").concat(N),tabIndex:-1,className:"recharts-pie-sector"},ly(p,v,N),{onMouseEnter:x(v,N),onMouseLeave:y(v,N),onClick:b(v,N)}),w.createElement(sO,qd({option:a??C,index:N,shapeType:"sector",isActive:T},A)))}))}function oMe(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,m=Math.abs(n.minAngle),p=eMe(l,c),x=Math.abs(p),y=r.length<=1?0:(e=n.paddingAngle)!==null&&e!==void 0?e:0,b=r.filter(C=>ir(C,u,0)!==0).length,v=(x>=360?b:b-1)*y,N=x-b*m-v,S=r.reduce((C,A)=>{var O=ir(A,u,0);return C+(Bt(O)?O:0)},0),T;if(S>0){var E;T=r.map((C,A)=>{var O=ir(C,u,0),k=ir(C,d,A),R=JNe(n,a,C),F=(Bt(O)?O:0)/S,L,K=ei(ei({},C),i&&i[A]&&i[A].props);A?L=E.endAngle+Ji(p)*y*(O!==0?1:0):L=l;var j=L+Ji(p)*((O!==0?m:0)+F*N),W=(L+j)/2,Y=(R.innerRadius+R.outerRadius)/2,q=[{name:k,value:O,payload:K,dataKey:u,type:f}],Q=wi(R.cx,R.cy,Y,W);return E=ei(ei(ei(ei({},n.presentationProps),{},{percent:F,cornerRadius:typeof o=="string"?parseFloat(o):o,name:k,tooltipPayload:q,midAngle:W,middleRadius:Y,tooltipPosition:Q},K),R),{},{value:O,dataKey:u,startAngle:L,endAngle:j,payload:K,paddingAngle:Ji(p)*y}),E})}return T}function lMe(t){var{showLabels:e,sectors:n,children:r}=t,i=w.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 w.createElement(H2e,{value:e?i:void 0},r)}function cMe(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:m}=e,p=Hg(e,"recharts-pie-"),x=n.current,[y,b]=w.useState(!1),v=w.useCallback(()=>{typeof m=="function"&&m(),b(!1)},[m]),N=w.useCallback(()=>{typeof f=="function"&&f(),b(!0)},[f]);return w.createElement(lMe,{showLabels:!y,sectors:i},w.createElement($g,{animationId:p,begin:o,duration:l,isActive:a,easing:c,onAnimationStart:N,onAnimationEnd:v,key:p},S=>{var T=[],E=i&&i[0],C=E?.startAngle;return i?.forEach((A,O)=>{var k=x&&x[O],R=O>0?Df(A,"paddingAngle",0):0;if(k){var F=Zn(k.endAngle-k.startAngle,A.endAngle-A.startAngle,S),L=ei(ei({},A),{},{startAngle:C+R,endAngle:C+F+R});T.push(L),C=L.endAngle}else{var{endAngle:K,startAngle:j}=A,W=Zn(0,K-j,S),Y=ei(ei({},A),{},{startAngle:C+R,endAngle:C+W+R});T.push(Y),C=Y.endAngle}}),n.current=T,w.createElement(Gr,null,w.createElement(sMe,{sectors:T,activeShape:u,inactiveShape:d,allOtherPieProps:e,shape:e.shape,id:r}))}),w.createElement(aMe,{showLabels:!y,sectors:i,props:e}),e.children)}var uMe={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:ii.area};function dMe(t){var{id:e}=t,n=LN(t,HNe),{hide:r,className:i,rootTabIndex:a}=t,o=w.useMemo(()=>iO(t.children,jy),[t.children]),l=Ft(d=>sNe(d,e,o)),c=w.useRef(null),u=$n("recharts-pie",i);return r||l==null?(c.current=null,w.createElement(Gr,{tabIndex:a,className:u})):w.createElement(La,{zIndex:t.zIndex},w.createElement(YNe,{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}),w.createElement(Gr,{tabIndex:a,className:u},w.createElement(cMe,{props:ei(ei({},n),{},{sectors:l}),previousSectorsRef:c,id:e})))}function HQ(t){var e=Wr(t,uMe),{id:n}=e,r=LN(e,VNe),i=Qa(r);return w.createElement(ON,{id:n,type:"pie"},a=>w.createElement(w.Fragment,null,w.createElement(zNe,{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}),w.createElement(XNe,qd({},r,{id:a})),w.createElement(dMe,qd({},r,{id:a}))))}HQ.displayName="Pie";var hMe=["points"];function b$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function hC(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?b$(Object(n),!0).forEach(function(r){fMe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):b$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function fMe(t,e,n){return(e=mMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function mMe(t){var e=pMe(t,"string");return typeof e=="symbol"?e:e+""}function pMe(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 lS(){return lS=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},lS.apply(null,arguments)}function gMe(t,e){if(t==null)return{};var n,r,i=xMe(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 xMe(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 bMe(t){var{option:e,dotProps:n,className:r}=t;if(w.isValidElement(e))return w.cloneElement(e,n);if(typeof e=="function")return e(n);var i=$n(r,typeof e!="boolean"?e.className:""),a=n??{},{points:o}=a,l=gMe(a,hMe);return w.createElement(OQ,lS({},l,{className:i}))}function yMe(t,e){return t==null?!1:e?!0:t.length===1}function VQ(t){var{points:e,dot:n,className:r,dotClassName:i,dataKey:a,baseProps:o,needClip:l,clipPathId:c,zIndex:u=ii.scatter}=t;if(!yMe(e,n))return null;var d=aO(n),f=Yfe(n),m=e.map((x,y)=>{var b,v,N=hC(hC(hC({r:3},o),f),{},{index:y,cx:(b=x.x)!==null&&b!==void 0?b:void 0,cy:(v=x.y)!==null&&v!==void 0?v:void 0,dataKey:a,value:x.value,payload:x.payload,points:e});return w.createElement(bMe,{key:"dot-".concat(y),option:n,dotProps:N,className:i})}),p={};return l&&c!=null&&(p.clipPath="url(#clipPath-".concat(d?"":"dots-").concat(c,")")),w.createElement(La,{zIndex:u},w.createElement(Gr,lS({className:r},p),m))}function y$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function v$(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?y$(Object(n),!0).forEach(function(r){vMe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):y$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function vMe(t,e,n){return(e=_Me(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function _Me(t){var e=wMe(t,"string");return typeof e=="symbol"?e:e+""}function wMe(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 SMe={xAxis:{},yAxis:{},zAxis:{}},GQ=Ss({name:"cartesianAxis",initialState:SMe,reducers:{addXAxis:{reducer(t,e){t.xAxis[e.payload.id]=e.payload},prepare:Ir()},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:Ir()},removeXAxis:{reducer(t,e){delete t.xAxis[e.payload.id]},prepare:Ir()},addYAxis:{reducer(t,e){t.yAxis[e.payload.id]=e.payload},prepare:Ir()},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:Ir()},removeYAxis:{reducer(t,e){delete t.yAxis[e.payload.id]},prepare:Ir()},addZAxis:{reducer(t,e){t.zAxis[e.payload.id]=e.payload},prepare:Ir()},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:Ir()},removeZAxis:{reducer(t,e){delete t.zAxis[e.payload.id]},prepare:Ir()},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]=v$(v$({},t.yAxis[n]),{},{width:r,widthHistory:o})}}}}),{addXAxis:NMe,replaceXAxis:MMe,removeXAxis:EMe,addYAxis:TMe,replaceYAxis:AMe,removeYAxis:CMe,addZAxis:jXe,replaceZAxis:PXe,removeZAxis:RXe,updateYAxisWidth:kMe}=GQ.actions,jMe=GQ.reducer,PMe=et([Ii],t=>({top:t.top,bottom:t.bottom,left:t.left,right:t.right})),RMe=et([PMe,xu,bu],(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)}}),IN=()=>Ft(RMe),DMe=()=>Ft(Rwe);function _$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function fC(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?_$(Object(n),!0).forEach(function(r){OMe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):_$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function OMe(t,e,n){return(e=LMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function LMe(t){var e=IMe(t,"string");return typeof e=="symbol"?e:e+""}function IMe(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 FMe=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=fC(fC(fC({},l),Rf(i)),TD(i)),u;return w.isValidElement(i)?u=w.cloneElement(i,c):typeof i=="function"?u=i(c):u=w.createElement(OQ,c),w.createElement(Gr,{className:"recharts-active-dot",clipPath:o},u)};function Q3(t){var{points:e,mainColor:n,activeDot:r,itemDataKey:i,clipPath:a,zIndex:o=ii.activeDot}=t,l=Ft(Wd),c=DMe();if(e==null||c==null)return null;var u=e.find(d=>c.includes(d.payload));return Pr(u)?null:w.createElement(La,{zIndex:o},w.createElement(FMe,{point:u,childIndex:Number(l),mainColor:n,dataKey:i,activeDot:r,clipPath:a}))}var UMe="Invariant failed";function zMe(t,e){throw new Error(UMe)}var BMe=["x","y"];function Z3(){return Z3=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},Z3.apply(null,arguments)}function w$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function ab(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?w$(Object(n),!0).forEach(function(r){$Me(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):w$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function $Me(t,e,n){return(e=HMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function HMe(t){var e=VMe(t,"string");return typeof e=="symbol"?e:e+""}function VMe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function GMe(t,e){if(t==null)return{};var n,r,i=WMe(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 WMe(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 qMe(t,e){var{x:n,y:r}=t,i=GMe(t,BMe),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),m=parseInt(f,10);return ab(ab(ab(ab(ab({},e),i),o?{x:o}:{}),c?{y:c}:{}),{},{height:d,width:m,name:e.name,radius:e.radius})}function cS(t){return w.createElement(sO,Z3({shapeType:"rectangle",propTransformer:qMe,activeClassName:"recharts-active-bar"},t))}var KMe=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return(r,i)=>{if(Bt(e))return e;var a=Bt(r)||Pr(r);return a?e(r,i):(a||zMe(),n)}},XMe={},WQ=Ss({name:"errorBars",initialState:XMe,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:DXe,replaceErrorBar:OXe,removeErrorBar:LXe}=WQ.actions,YMe=WQ.reducer,QMe=["children"];function ZMe(t,e){if(t==null)return{};var n,r,i=JMe(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 JMe(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 eEe={data:[],xAxisId:"xAxis-0",yAxisId:"yAxis-0",dataPointFormatter:()=>({x:0,y:0,value:0}),errorBarOffset:0},tEe=w.createContext(eEe);function qQ(t){var{children:e}=t,n=ZMe(t,QMe);return w.createElement(tEe.Provider,{value:n},e)}function FN(t,e){var n,r,i=Ft(u=>Zl(u,t)),a=Ft(u=>Jl(u,e)),o=(n=i?.allowDataOverflow)!==null&&n!==void 0?n:Ki.allowDataOverflow,l=(r=a?.allowDataOverflow)!==null&&r!==void 0?r:Xi.allowDataOverflow,c=o||l;return{needClip:c,needClipX:o,needClipY:l}}function hO(t){var{xAxisId:e,yAxisId:n,clipPathId:r}=t,i=IN(),{needClipX:a,needClipY:o,needClip:l}=FN(e,n);if(!l||!i)return null;var{x:c,y:u,width:d,height:f}=i;return w.createElement("clipPath",{id:"clipPath-".concat(r)},w.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 nEe(t,e){return t&&typeof t=="object"&&"zIndex"in t&&typeof t.zIndex=="number"&&ar(t.zIndex)?t.zIndex:e}var mC={exports:{}},pC={};var S$;function rEe(){if(S$)return pC;S$=1;var t=Dg();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 pC.useSyncExternalStoreWithSelector=function(c,u,d,f,m){var p=i(null);if(p.current===null){var x={hasValue:!1,value:null};p.current=x}else x=p.current;p=o(function(){function b(E){if(!v){if(v=!0,N=E,E=f(E),m!==void 0&&x.hasValue){var C=x.value;if(m(C,E))return S=C}return S=E}if(C=S,n(N,E))return C;var A=f(E);return m!==void 0&&m(C,A)?(N=E,C):(N=E,S=A)}var v=!1,N,S,T=d===void 0?null:d;return[function(){return b(u())},T===null?void 0:function(){return b(T())}]},[u,d,f,m]);var y=r(c,p[0],p[1]);return a(function(){x.hasValue=!0,x.value=y},[y]),l(y),y},pC}var N$;function iEe(){return N$||(N$=1,mC.exports=rEe()),mC.exports}iEe();function aEe(t){t()}function sEe(){let t=null,e=null;return{clear(){t=null,e=null},notify(){aEe(()=>{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 M$={notify(){},get:()=>[]};function oEe(t,e){let n,r=M$,i=0,a=!1;function o(y){d();const b=r.subscribe(y);let v=!1;return()=>{v||(v=!0,b(),f())}}function l(){r.notify()}function c(){x.onStateChange&&x.onStateChange()}function u(){return a}function d(){i++,n||(n=t.subscribe(c),r=sEe())}function f(){i--,n&&i===0&&(n(),n=void 0,r.clear(),r=M$)}function m(){a||(a=!0,d())}function p(){a&&(a=!1,f())}const x={addNestedSub:o,notifyNestedSubs:l,handleChangeWrapper:c,isSubscribed:u,trySubscribe:m,tryUnsubscribe:p,getListeners:()=>r};return x}var lEe=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",cEe=lEe(),uEe=()=>typeof navigator<"u"&&navigator.product==="ReactNative",dEe=uEe(),hEe=()=>cEe||dEe?w.useLayoutEffect:w.useEffect,fEe=hEe();function E$(t,e){return t===e?t!==0||e!==0||1/t===1/e:t!==t&&e!==e}function mEe(t,e){if(E$(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])||!E$(t[n[i]],e[n[i]]))return!1;return!0}var pEe=Symbol.for("react-redux-context"),gEe=typeof globalThis<"u"?globalThis:{};function xEe(){if(!w.createContext)return{};const t=gEe[pEe]??=new Map;let e=t.get(w.createContext);return e||(e=w.createContext(null),t.set(w.createContext,e)),e}var bEe=xEe();function yEe(t){const{children:e,context:n,serverState:r,store:i}=t,a=w.useMemo(()=>{const c=oEe(i);return{store:i,subscription:c,getServerState:r?()=>r:void 0}},[i,r]),o=w.useMemo(()=>i.getState(),[i]);fEe(()=>{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||bEe;return w.createElement(l.Provider,{value:a},e)}var vEe=yEe,_Ee=new Set(["axisLine","tickLine","activeBar","activeDot","activeLabel","activeShape","allowEscapeViewBox","background","cursor","dot","label","line","margin","padding","position","shape","style","tick","wrapperStyle"]);function wEe(t,e){return t==null&&e==null?!0:typeof t=="number"&&typeof e=="number"?t===e||t!==t&&e!==e:t===e}function Py(t,e){var n=new Set([...Object.keys(t),...Object.keys(e)]);for(var r of n)if(_Ee.has(r)){if(t[r]==null&&e[r]==null)continue;if(!mEe(t[r],e[r]))return!1}else if(!wEe(t[r],e[r]))return!1;return!0}var SEe=["onMouseEnter","onMouseLeave","onClick"],NEe=["value","background","tooltipPosition"],MEe=["id"],EEe=["onMouseEnter","onClick","onMouseLeave"];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)}function T$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Va(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?T$(Object(n),!0).forEach(function(r){TEe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):T$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function TEe(t,e,n){return(e=AEe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function AEe(t){var e=CEe(t,"string");return typeof e=="symbol"?e:e+""}function CEe(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 uS(t,e){if(t==null)return{};var n,r,i=kEe(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 kEe(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 jEe=t=>{var{dataKey:e,name:n,fill:r,legendType:i,hide:a}=t;return[{inactive:a,dataKey:e,type:i,color:r,value:ih(n,e),payload:t}]},PEe=w.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:ih(a,e),hide:o,type:c,color:i,unit:l}};return w.createElement(DN,{tooltipEntrySettings:u})});function REe(t){var e=Ft(Wd),{data:n,dataKey:r,background:i,allOtherBarProps:a}=t,{onMouseEnter:o,onMouseLeave:l,onClick:c}=a,u=uS(a,SEe),d=oO(o,r),f=lO(l),m=cO(c,r);if(!i||n==null)return null;var p=Rf(i);return w.createElement(La,{zIndex:nEe(i,ii.barBackground)},n.map((x,y)=>{var{value:b,background:v,tooltipPosition:N}=x,S=uS(x,NEe);if(!v)return null;var T=d(x,y),E=f(x,y),C=m(x,y),A=Va(Va(Va(Va(Va({option:i,isActive:String(y)===e},S),{},{fill:"#eee"},v),p),ly(u,x,y)),{},{onMouseEnter:T,onMouseLeave:E,onClick:C,dataKey:r,index:y,className:"recharts-bar-background-rectangle"});return w.createElement(cS,fu({key:"background-bar-".concat(y)},A))}))}function DEe(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 Va(Va({},o),{},{value:a.value,payload:a.payload,parentViewBox:a.parentViewBox,viewBox:o,fill:a.fill})});return w.createElement(tO,{value:e?i:void 0},n)}function OEe(t){var{shape:e,activeBar:n,baseProps:r,entry:i,index:a,dataKey:o}=t,l=Ft(Wd),c=Ft(X4),u=n&&String(a)===l&&(c==null||o===c),d=u?n:e;return u?w.createElement(La,{zIndex:ii.activeBar},w.createElement(cS,fu({},r,{name:String(r.name)},i,{isActive:u,option:d,index:a,dataKey:o}))):w.createElement(cS,fu({},r,{name:String(r.name)},i,{isActive:u,option:d,index:a,dataKey:o}))}function LEe(t){var{shape:e,baseProps:n,entry:r,index:i,dataKey:a}=t;return w.createElement(cS,fu({},n,{name:String(n.name)},r,{isActive:!1,option:e,index:i,dataKey:a}))}function IEe(t){var e,{data:n,props:r}=t,i=(e=Qa(r))!==null&&e!==void 0?e:{},{id:a}=i,o=uS(i,MEe),{shape:l,dataKey:c,activeBar:u}=r,{onMouseEnter:d,onClick:f,onMouseLeave:m}=r,p=uS(r,EEe),x=oO(d,c),y=lO(m),b=cO(f,c);return n?w.createElement(w.Fragment,null,n.map((v,N)=>w.createElement(Gr,fu({key:"rectangle-".concat(v?.x,"-").concat(v?.y,"-").concat(v?.value,"-").concat(N),className:"recharts-bar-rectangle"},ly(p,v,N),{onMouseEnter:x(v,N),onMouseLeave:y(v,N),onClick:b(v,N)}),u?w.createElement(OEe,{shape:l,activeBar:u,baseProps:o,entry:v,index:N,dataKey:c}):w.createElement(LEe,{shape:l,baseProps:o,entry:v,index:N,dataKey:c})))):null}function FEe(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,m=Hg(e,"recharts-bar-"),[p,x]=w.useState(!1),y=!p,b=w.useCallback(()=>{typeof u=="function"&&u(),x(!1)},[u]),v=w.useCallback(()=>{typeof d=="function"&&d(),x(!0)},[d]);return w.createElement(DEe,{showLabels:y,rects:r},w.createElement($g,{animationId:m,begin:o,duration:l,isActive:a,easing:c,onAnimationEnd:b,onAnimationStart:v,key:m},N=>{var S=N===1?r:r?.map((T,E)=>{var C=f&&f[E];if(C)return Va(Va({},T),{},{x:Zn(C.x,T.x,N),y:Zn(C.y,T.y,N),width:Zn(C.width,T.width,N),height:Zn(C.height,T.height,N)});if(i==="horizontal"){var A=Zn(0,T.height,N),O=Zn(T.stackedBarStart,T.y,N);return Va(Va({},T),{},{y:O,height:A})}var k=Zn(0,T.width,N),R=Zn(T.stackedBarStart,T.x,N);return Va(Va({},T),{},{width:k,x:R})});return N>0&&(n.current=S??null),S==null?null:w.createElement(Gr,null,w.createElement(IEe,{props:e,data:S}))}),w.createElement(jN,{label:e.label}),e.children)}function UEe(t){var e=w.useRef(null);return w.createElement(FEe,{previousRectanglesRef:e,props:t})}var KQ=0,zEe=(t,e)=>{var n=Array.isArray(t.value)?t.value[1]:t.value;return{x:t.x,y:t.y,value:n,errorVal:ir(t,e)}};class BEe extends w.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=$n("recharts-bar",i),f=u;return w.createElement(Gr,{className:d,id:u},l&&w.createElement("defs",null,w.createElement(hO,{clipPathId:f,xAxisId:a,yAxisId:o})),w.createElement(Gr,{className:"recharts-bar-rectangles",clipPath:l?"url(#clipPath-".concat(f,")"):void 0},w.createElement(REe,{data:n,dataKey:r,background:c,allOtherBarProps:this.props}),w.createElement(UEe,this.props)))}}var $Ee={activeBar:!1,animationBegin:0,animationDuration:400,animationEasing:"ease",background:!1,hide:!1,isAnimationActive:"auto",label:!1,legendType:"rect",minPointSize:KQ,xAxisId:0,yAxisId:0,zIndex:ii.bar};function HEe(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}=FN(e,n),m=Jf(),p=Fi(),x=iO(t.children,jy),y=Ft(N=>xTe(N,e,n,p,t.id,x));if(m!=="vertical"&&m!=="horizontal")return null;var b,v=y?.[0];return v==null||v.height==null||v.width==null?b=0:b=m==="vertical"?v.height/2:v.width/2,w.createElement(qQ,{xAxisId:e,yAxisId:n,data:y,dataPointFormatter:zEe,errorBarOffset:b},w.createElement(BEe,fu({},t,{layout:m,needClip:f,data:y,xAxisId:e,yAxisId:n,hide:r,legendType:i,minPointSize:a,activeBar:o,animationBegin:l,animationDuration:c,animationEasing:u,isAnimationActive:d})))}function VEe(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:m,cells:p,parentViewBox:x,dataStartIndex:y}=t,b=e==="horizontal"?l:o,v=d?b.scale.domain():null,N=fxe({numericAxis:b}),S=b.scale(N);return f.map((T,E)=>{var C,A,O,k,R,F;d?C=lxe(d[E+y],v):(C=ir(T,n),Array.isArray(C)||(C=[N,C]));var L=KMe(r,KQ)(C[1],E);if(e==="horizontal"){var K,[j,W]=[l.scale(C[0]),l.scale(C[1])];A=VB({axis:o,ticks:c,bandSize:a,offset:i.offset,entry:T,index:E}),O=(K=W??j)!==null&&K!==void 0?K:void 0,k=i.size;var Y=j-W;if(R=ws(Y)?0:Y,F={x:A,y:m.top,width:k,height:m.height},Math.abs(L)>0&&Math.abs(R)<Math.abs(L)){var q=Ji(R||L)*(Math.abs(L)-Math.abs(R));O-=q,R+=q}}else{var[Q,ee]=[o.scale(C[0]),o.scale(C[1])];if(A=Q,O=VB({axis:l,ticks:u,bandSize:a,offset:i.offset,entry:T,index:E}),k=ee-Q,R=i.size,F={x:m.left,y:O,width:m.width,height:R},Math.abs(L)>0&&Math.abs(k)<Math.abs(L)){var re=Ji(k||L)*(Math.abs(L)-Math.abs(k));k+=re}}if(A==null||O==null||k==null||R==null)return null;var z=Va(Va({},T),{},{stackedBarStart:S,x:A,y:O,width:k,height:R,value:d?C:C[1],payload:T,background:F,tooltipPosition:{x:A+k/2,y:O+R/2},parentViewBox:x},p&&p[E]&&p[E].props);return z}).filter(Boolean)}function GEe(t){var e=Wr(t,$Ee),n=Fi();return w.createElement(ON,{id:e.id,type:"bar"},r=>w.createElement(w.Fragment,null,w.createElement(uO,{legendPayload:jEe(e)}),w.createElement(PEe,{dataKey:e.dataKey,stroke:e.stroke,strokeWidth:e.strokeWidth,fill:e.fill,name:e.name,hide:e.hide,unit:e.unit,tooltipType:e.tooltipType}),w.createElement(dO,{type:"bar",id:r,data:void 0,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,dataKey:e.dataKey,stackId:$K(e.stackId),hide:e.hide,barSize:e.barSize,minPointSize:e.minPointSize,maxBarSize:e.maxBarSize,isPanorama:n}),w.createElement(La,{zIndex:e.zIndex},w.createElement(HEe,fu({},e,{id:r})))))}var XQ=w.memo(GEe,Py);XQ.displayName="Bar";function A$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function y_(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?A$(Object(n),!0).forEach(function(r){WEe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):A$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function WEe(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=KEe(t,"string");return typeof e=="symbol"?e:e+""}function KEe(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 XEe=(t,e)=>e,YEe=(t,e,n)=>n,QEe=(t,e,n,r)=>r,ZEe=(t,e,n,r,i)=>i,Ry=et([Sy,ZEe],(t,e)=>t.filter(n=>n.type==="bar").find(n=>n.id===e)),JEe=et([Ry],t=>t?.maxBarSize),eTe=(t,e,n,r,i,a)=>a,C$=(t,e,n)=>{var r=n??t;if(!Pr(r))return Oa(r,e,0)},tTe=et([On,Sy,XEe,YEe,QEe],(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")),nTe=(t,e,n,r)=>{var i=On(t);return i==="horizontal"?k0(t,"yAxis",n,r):k0(t,"xAxis",e,r)},rTe=(t,e,n)=>{var r=On(t);return r==="horizontal"?S6(t,"xAxis",e):S6(t,"yAxis",n)},iTe=(t,e,n)=>{var r={},i=t.filter(wN),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,m=f.map(x=>x.dataKey),p=C$(e,n,f[0].barSize);return{stackId:d,dataKeys:m,barSize:p}}),c=a.map(u=>{var d=[u.dataKey].filter(m=>m!=null),f=C$(e,n,u.barSize);return{stackId:void 0,dataKeys:d,barSize:f}});return[...l,...c]},aTe=et([tTe,k_e,rTe],iTe),sTe=(t,e,n,r,i)=>{var a,o,l=Ry(t,e,n,r,i);if(l!=null){var c=On(t),u=hY(t),{maxBarSize:d}=l,f=Pr(d)?u:d,m,p;return c==="horizontal"?(m=Vl(t,"xAxis",e,r),p=Hl(t,"xAxis",e,r)):(m=Vl(t,"yAxis",n,r),p=Hl(t,"yAxis",n,r)),(a=(o=Hd(m,p,!0))!==null&&o!==void 0?o:f)!==null&&a!==void 0?a:0}},YQ=(t,e,n,r)=>{var i=On(t),a,o;return i==="horizontal"?(a=Vl(t,"xAxis",e,r),o=Hl(t,"xAxis",e,r)):(a=Vl(t,"yAxis",n,r),o=Hl(t,"yAxis",n,r)),Hd(a,o)};function oTe(t,e,n,r,i){var a=r.length;if(!(a<1)){var o=Oa(t,n,0,!0),l,c=[];if(ar(r[0].barSize)){var u=!1,d=n/a,f=r.reduce((v,N)=>v+(N.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 m=(n-f)/2>>0,p={offset:m-o,size:0};l=r.reduce((v,N)=>{var S,T={stackId:N.stackId,dataKeys:N.dataKeys,position:{offset:p.offset+p.size+o,size:u?d:(S=N.barSize)!==null&&S!==void 0?S:0}},E=[...v,T];return p=E[E.length-1].position,E},c)}else{var x=Oa(e,n,0,!0);n-2*x-(a-1)*o<=0&&(o=0);var y=(n-2*x-(a-1)*o)/a;y>1&&(y>>=0);var b=ar(i)?Math.min(y,i):y;l=r.reduce((v,N,S)=>[...v,{stackId:N.stackId,dataKeys:N.dataKeys,position:{offset:x+(y+o)*S+(y-b)/2,size:b}}],c)}return l}}var lTe=(t,e,n,r,i,a,o)=>{var l=Pr(o)?e:o,c=oTe(n,r,i!==a?i:a,t,l);return i!==a&&c!=null&&(c=c.map(u=>y_(y_({},u),{},{position:y_(y_({},u.position),{},{offset:u.position.offset-i/2})}))),c},cTe=et([aTe,hY,C_e,fY,sTe,YQ,JEe],lTe),uTe=(t,e,n,r)=>Vl(t,"xAxis",e,r),dTe=(t,e,n,r)=>Vl(t,"yAxis",n,r),hTe=(t,e,n,r)=>Hl(t,"xAxis",e,r),fTe=(t,e,n,r)=>Hl(t,"yAxis",n,r),mTe=et([cTe,Ry],(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}}),pTe=(t,e)=>{var n=_N(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)}}}},gTe=et([nTe,Ry],pTe),xTe=et([Ii,FD,uTe,dTe,hTe,fTe,mTe,On,yy,YQ,gTe,Ry,eTe],(t,e,n,r,i,a,o,l,c,u,d,f,m)=>{var{chartData:p,dataStartIndex:x,dataEndIndex:y}=c;if(!(f==null||o==null||e==null||l!=="horizontal"&&l!=="vertical"||n==null||r==null||i==null||a==null||u==null)){var{data:b}=f,v;if(b!=null&&b.length>0?v=b:v=p?.slice(x,y+1),v!=null)return VEe({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:m,dataStartIndex:x})}}),QQ=t=>{var{chartData:e}=t,n=wr(),r=Fi();return w.useEffect(()=>r?()=>{}:(n(L6(e)),()=>{n(L6(void 0))}),[e,n,r]),null},k$={x:0,y:0,width:0,height:0,padding:{top:0,right:0,bottom:0,left:0}},ZQ=Ss({name:"brush",initialState:k$,reducers:{setBrushSettings(t,e){return e.payload==null?k$:e.payload}}}),{setBrushSettings:IXe}=ZQ.actions,bTe=ZQ.reducer;function j$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function v_(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?j$(Object(n),!0).forEach(function(r){JQ(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):j$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function JQ(t,e,n){return(e=yTe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function yTe(t){var e=vTe(t,"string");return typeof e=="symbol"?e:e+""}function vTe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var _Te=(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)}},wTe=t=>{var{x1:e,y1:n,x2:r,y2:i}=t;return _Te({x:e,y:n},{x:r,y:i})};class UN{static create(e){return new UN(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}}JQ(UN,"EPS",1e-4);var STe=t=>{var e=Object.keys(t).reduce((n,r)=>v_(v_({},n),{},{[r]:UN.create(t[r])}),{});return v_(v_({},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 NTe(t){return(t%180+180)%180}var MTe=function(e){var{width:n,height:r}=e,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,a=NTe(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)},ETe={dots:[],areas:[],lines:[]},eZ=Ss({name:"referenceElements",initialState:ETe,reducers:{addDot:(t,e)=>{t.dots.push(e.payload)},removeDot:(t,e)=>{var n=al(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=al(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=al(t).lines.findIndex(r=>r===e.payload);n!==-1&&t.lines.splice(n,1)}}}),{addDot:FXe,removeDot:UXe,addArea:zXe,removeArea:BXe,addLine:TTe,removeLine:ATe}=eZ.actions,CTe=eZ.reducer,tZ=w.createContext(void 0),kTe=t=>{var{children:e}=t,[n]=w.useState("".concat(x0("recharts"),"-clip")),r=IN();if(r==null)return null;var{x:i,y:a,width:o,height:l}=r;return w.createElement(tZ.Provider,{value:n},w.createElement("defs",null,w.createElement("clipPath",{id:n},w.createElement("rect",{x:i,y:a,height:l,width:o}))),e)},jTe=()=>w.useContext(tZ);function P$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function R$(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?P$(Object(n),!0).forEach(function(r){PTe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):P$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function PTe(t,e,n){return(e=RTe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function RTe(t){var e=DTe(t,"string");return typeof e=="symbol"?e:e+""}function DTe(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 OTe=(t,e)=>{var n;if(w.isValidElement(t))n=w.cloneElement(t,e);else if(typeof t=="function")n=t(e);else{if(!ar(e.x1)||!ar(e.y1)||!ar(e.x2)||!ar(e.y2))return null;n=w.createElement("line",dS({},e,{className:"recharts-reference-line-line"}))}return n},LTe=(t,e,n,r,i,a)=>{var{x:o,width:l}=a,c=i.y.apply(t,{position:n});if(ws(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},ITe=(t,e,n,r,i,a)=>{var{y:o,height:l}=a,c=i.x.apply(t,{position:n});if(ws(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},FTe=(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},UTe=(t,e,n,r,i,a)=>{var{x:o,y:l,segment:c,ifOverflow:u}=a,d=Oo(o),f=Oo(l);return f?LTe(l,u,n,i,t,e):d?ITe(o,u,n,r,t,e):c!=null&&c.length===2?FTe(c,u,n,t):null};function zTe(t){var e=wr();return w.useEffect(()=>(e(TTe(t)),()=>{e(ATe(t))})),null}function BTe(t){var{xAxisId:e,yAxisId:n,shape:r,className:i,ifOverflow:a}=t,o=Fi(),l=jTe(),c=Ft(C=>Zl(C,e)),u=Ft(C=>Jl(C,n)),d=Ft(C=>Gd(C,"xAxis",e,o)),f=Ft(C=>Gd(C,"yAxis",n,o)),m=fy();if(!l||!m||c==null||u==null||d==null||f==null)return null;var p=STe({x:d,y:f}),x=UTe(p,m,t.position,c.orientation,u.orientation,t);if(!x)return null;var[{x:y,y:b},{x:v,y:N}]=x,S=a==="hidden"?"url(#".concat(l,")"):void 0,T=R$(R$({clipPath:S},Sa(t)),{},{x1:y,y1:b,x2:v,y2:N}),E=wTe({x1:y,y1:b,x2:v,y2:N});return w.createElement(La,{zIndex:t.zIndex},w.createElement(Gr,{className:$n("recharts-reference-line",i)},OTe(r,T),w.createElement(kQ,dS({},E,{lowerWidth:E.width,upperWidth:E.width}),w.createElement(PQ,{label:t.label}),t.children)))}var $Te={ifOverflow:"discard",xAxisId:0,yAxisId:0,fill:"none",stroke:"#ccc",fillOpacity:1,strokeWidth:1,position:"middle",zIndex:ii.line};function Tb(t){var e=Wr(t,$Te);return w.createElement(w.Fragment,null,w.createElement(zTe,{yAxisId:e.yAxisId,xAxisId:e.xAxisId,ifOverflow:e.ifOverflow,x:e.x,y:e.y,segment:e.segment}),w.createElement(BTe,e))}Tb.displayName="ReferenceLine";function nZ(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 HTe(t,e,n){var r={width:t.width+e.width,height:t.height+e.height};return MTe(r,n)}function VTe(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 hS(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 GTe(t,e){return nZ(t,e+1)}function WTe(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:nZ(r,u)};var y=c,b,v=()=>(b===void 0&&(b=n(x,y)),b),N=x.coordinate,S=c===0||hS(t,N,v,d,l);S||(c=0,d=o,u+=1),S&&(d=N+t*(v()/2+i),c+=u)},m;u<=a.length;)if(m=f(),m)return m.v;return[]}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 ka(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){qTe(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 qTe(t,e,n){return(e=KTe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function KTe(t){var e=XTe(t,"string");return typeof e=="symbol"?e:e+""}function XTe(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 YTe(t,e,n,r,i){for(var a=(r||[]).slice(),o=a.length,{start:l}=e,{end:c}=e,u=function(m){var p=a[m],x,y=()=>(x===void 0&&(x=n(p,m)),x);if(m===o-1){var b=t*(p.coordinate+t*y()/2-c);a[m]=p=ka(ka({},p),{},{tickCoord:b>0?p.coordinate-b*t:p.coordinate})}else a[m]=p=ka(ka({},p),{},{tickCoord:p.coordinate});if(p.tickCoord!=null){var v=hS(t,p.tickCoord,y,l,c);v&&(c=p.tickCoord-t*(y()/2+i),a[m]=ka(ka({},p),{},{isShow:!0}))}},d=o-1;d>=0;d--)u(d);return a}function QTe(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),m=t*(d.coordinate+t*f/2-u);if(o[l-1]=d=ka(ka({},d),{},{tickCoord:m>0?d.coordinate-m*t:d.coordinate}),d.tickCoord!=null){var p=hS(t,d.tickCoord,()=>f,c,u);p&&(u=d.tickCoord-t*(f/2+i),o[l-1]=ka(ka({},d),{},{isShow:!0}))}}for(var x=a?l-1:l,y=function(N){var S=o[N],T,E=()=>(T===void 0&&(T=n(S,N)),T);if(N===0){var C=t*(S.coordinate-t*E()/2-c);o[N]=S=ka(ka({},S),{},{tickCoord:C<0?S.coordinate-C*t:S.coordinate})}else o[N]=S=ka(ka({},S),{},{tickCoord:S.coordinate});if(S.tickCoord!=null){var A=hS(t,S.tickCoord,E,c,u);A&&(c=S.tickCoord+t*(E()/2+i),o[N]=ka(ka({},S),{},{isShow:!0}))}},b=0;b<x;b++)y(b);return o}function fO(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(Bt(c)||Bg.isSsr){var m;return(m=GTe(i,Bt(c)?c:0))!==null&&m!==void 0?m:[]}var p=[],x=l==="top"||l==="bottom"?"width":"height",y=d&&x==="width"?Bb(d,{fontSize:e,letterSpacing:n}):{width:0,height:0},b=(S,T)=>{var E=typeof u=="function"?u(S.value,T):S.value;return x==="width"?HTe(Bb(E,{fontSize:e,letterSpacing:n}),y,f):Bb(E,{fontSize:e,letterSpacing:n})[x]},v=i.length>=2?Ji(i[1].coordinate-i[0].coordinate):1,N=VTe(a,v,x);return c==="equidistantPreserveStart"?WTe(v,N,b,i,o):(c==="preserveStart"||c==="preserveStartEnd"?p=QTe(v,N,b,i,o,c==="preserveStartEnd"):p=YTe(v,N,b,i,o),p.filter(S=>S.isShow))}var ZTe=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},JTe=["axisLine","width","height","className","hide","ticks","axisType"];function eAe(t,e){if(t==null)return{};var n,r,i=tAe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function tAe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function Ff(){return Ff=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},Ff.apply(null,arguments)}function O$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function yi(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?O$(Object(n),!0).forEach(function(r){nAe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):O$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function nAe(t,e,n){return(e=rAe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function rAe(t){var e=iAe(t,"string");return typeof e=="symbol"?e:e+""}function iAe(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 Jc={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:ii.axis};function aAe(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=yi(yi(yi({},c),Qa(l)),{},{fill:"none"});if(a==="top"||a==="bottom"){var d=+(a==="top"&&!o||a==="bottom"&&o);u=yi(yi({},u),{},{x1:e,y1:n+d*i,x2:e+r,y2:n+d*i})}else{var f=+(a==="left"&&!o||a==="right"&&o);u=yi(yi({},u),{},{x1:e+f*r,y1:n,x2:e+f*r,y2:n+i})}return w.createElement("line",Ff({},u,{className:$n("recharts-cartesian-axis-line",Df(l,"className"))}))}function sAe(t,e,n,r,i,a,o,l,c){var u,d,f,m,p,x,y=l?-1:1,b=t.tickSize||o,v=Bt(t.tickCoord)?t.tickCoord:t.coordinate;switch(a){case"top":u=d=t.coordinate,m=n+ +!l*i,f=m-y*b,x=f-y*c,p=v;break;case"left":f=m=t.coordinate,d=e+ +!l*r,u=d-y*b,p=u-y*c,x=v;break;case"right":f=m=t.coordinate,d=e+ +l*r,u=d+y*b,p=u+y*c,x=v;break;default:u=d=t.coordinate,m=n+ +l*i,f=m+y*b,x=f+y*c,p=v;break}return{line:{x1:u,y1:f,x2:d,y2:m},tick:{x:p,y:x}}}function oAe(t,e){switch(t){case"left":return e?"start":"end";case"right":return e?"end":"start";default:return"middle"}}function lAe(t,e){switch(t){case"left":case"right":return"middle";case"top":return e?"start":"end";default:return e?"end":"start"}}function cAe(t){var{option:e,tickProps:n,value:r}=t,i,a=$n(n.className,"recharts-cartesian-axis-tick-value");if(w.isValidElement(e))i=w.cloneElement(e,yi(yi({},n),{},{className:a}));else if(typeof e=="function")i=e(yi(yi({},n),{},{className:a}));else{var o="recharts-cartesian-axis-tick-value";typeof e!="boolean"&&(o=$n(o,e?.className)),i=w.createElement(kN,Ff({},n,{className:o}),r)}return i}var uAe=w.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:m,y:p,width:x,height:y,tickSize:b,tickMargin:v,fontSize:N,letterSpacing:S,getTicksConfig:T,events:E,axisType:C}=t,A=fO(yi(yi({},T),{},{ticks:n}),N,S),O=oAe(d,f),k=lAe(d,f),R=Qa(T),F=Rf(r),L={};typeof i=="object"&&(L=i);var K=yi(yi({},R),{},{fill:"none"},L),j=A.map(q=>yi({entry:q},sAe(q,m,p,x,y,d,b,f,v))),W=j.map(q=>{var{entry:Q,line:ee}=q;return w.createElement(Gr,{className:"recharts-cartesian-axis-tick",key:"tick-".concat(Q.value,"-").concat(Q.coordinate,"-").concat(Q.tickCoord)},i&&w.createElement("line",Ff({},K,ee,{className:$n("recharts-cartesian-axis-tick-line",Df(i,"className"))})))}),Y=j.map((q,Q)=>{var{entry:ee,tick:re}=q,z=yi(yi(yi(yi({textAnchor:O,verticalAnchor:k},R),{},{stroke:"none",fill:a},F),re),{},{index:Q,payload:ee,visibleTicksCount:A.length,tickFormatter:o,padding:c},u);return w.createElement(Gr,Ff({className:"recharts-cartesian-axis-tick-label",key:"tick-label-".concat(ee.value,"-").concat(ee.coordinate,"-").concat(ee.tickCoord)},ly(E,ee,Q)),r&&w.createElement(cAe,{option:r,tickProps:z,value:"".concat(typeof o=="function"?o(ee.value,Q):ee.value).concat(l||"")}))});return w.createElement("g",{className:"recharts-cartesian-axis-ticks recharts-".concat(C,"-ticks")},Y.length>0&&w.createElement(La,{zIndex:ii.label},w.createElement("g",{className:"recharts-cartesian-axis-tick-labels recharts-".concat(C,"-tick-labels"),ref:e},Y)),W.length>0&&w.createElement("g",{className:"recharts-cartesian-axis-tick-lines recharts-".concat(C,"-tick-lines")},W))}),dAe=w.forwardRef((t,e)=>{var{axisLine:n,width:r,height:i,className:a,hide:o,ticks:l,axisType:c}=t,u=eAe(t,JTe),[d,f]=w.useState(""),[m,p]=w.useState(""),x=w.useRef(null);w.useImperativeHandle(e,()=>({getCalculatedWidth:()=>{var b;return ZTe({ticks:x.current,label:(b=t.labelRef)===null||b===void 0?void 0:b.current,labelGapWithTick:5,tickSize:t.tickSize,tickMargin:t.tickMargin})}}));var y=w.useCallback(b=>{if(b){var v=b.getElementsByClassName("recharts-cartesian-axis-tick-value");x.current=v;var N=v[0];if(N){var S=window.getComputedStyle(N),T=S.fontSize,E=S.letterSpacing;(T!==d||E!==m)&&(f(T),p(E))}}},[d,m]);return o||r!=null&&r<=0||i!=null&&i<=0?null:w.createElement(La,{zIndex:t.zIndex},w.createElement(Gr,{className:$n("recharts-cartesian-axis",a)},w.createElement(aAe,{x:t.x,y:t.y,width:r,height:i,orientation:t.orientation,mirror:t.mirror,axisLine:n,otherSvgProps:Qa(t)}),w.createElement(uAe,{ref:y,axisType:c,events:u,fontSize:d,getTicksConfig:t,height:t.height,letterSpacing:m,mirror:t.mirror,orientation:t.orientation,padding:t.padding,stroke:t.stroke,tick:t.tick,tickFormatter:t.tickFormatter,tickLine:t.tickLine,tickMargin:t.tickMargin,tickSize:t.tickSize,tickTextProps:t.tickTextProps,ticks:l,unit:t.unit,width:t.width,x:t.x,y:t.y}),w.createElement(kQ,{x:t.x,y:t.y,width:t.width,height:t.height,lowerWidth:t.width,upperWidth:t.width},w.createElement(PQ,{label:t.label,labelRef:t.labelRef}),t.children)))}),mO=w.forwardRef((t,e)=>{var n=Wr(t,Jc);return w.createElement(dAe,Ff({},n,{ref:e}))});mO.displayName="CartesianAxis";var hAe=["x1","y1","x2","y2","key"],fAe=["offset"],mAe=["xAxisId","yAxisId"],pAe=["xAxisId","yAxisId"];function L$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Ra(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?L$(Object(n),!0).forEach(function(r){gAe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):L$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function gAe(t,e,n){return(e=xAe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function xAe(t){var e=bAe(t,"string");return typeof e=="symbol"?e:e+""}function bAe(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 nf(){return nf=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},nf.apply(null,arguments)}function fS(t,e){if(t==null)return{};var n,r,i=yAe(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 yAe(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 vAe=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 w.createElement("rect",{x:r,y:i,ry:l,width:a,height:o,stroke:"none",fill:e,fillOpacity:n,className:"recharts-cartesian-grid-bg"})};function rZ(t){var{option:e,lineItemProps:n}=t,r;if(w.isValidElement(e))r=w.cloneElement(e,n);else if(typeof e=="function")r=e(n);else{var i,{x1:a,y1:o,x2:l,y2:c,key:u}=n,d=fS(n,hAe),f=(i=Qa(d))!==null&&i!==void 0?i:{},{offset:m}=f,p=fS(f,fAe);r=w.createElement("line",nf({},p,{x1:a,y1:o,x2:l,y2:c,fill:"none",key:u}))}return r}function _Ae(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=fS(t,mAe),c=i.map((u,d)=>{var f=Ra(Ra({},l),{},{x1:e,y1:u,x2:e+n,y2:u,key:"line-".concat(d),index:d});return w.createElement(rZ,{key:"line-".concat(d),option:r,lineItemProps:f})});return w.createElement("g",{className:"recharts-cartesian-grid-horizontal"},c)}function wAe(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=fS(t,pAe),c=i.map((u,d)=>{var f=Ra(Ra({},l),{},{x1:u,y1:e,x2:u,y2:e+n,key:"line-".concat(d),index:d});return w.createElement(rZ,{option:r,lineItemProps:f,key:"line-".concat(d)})});return w.createElement("g",{className:"recharts-cartesian-grid-vertical"},c)}function SAe(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,m)=>f-m);i!==u[0]&&u.unshift(0);var d=u.map((f,m)=>{var p=!u[m+1],x=p?i+o-f:u[m+1]-f;if(x<=0)return null;var y=m%e.length;return w.createElement("rect",{key:"react-".concat(m),y:f,x:r,height:x,width:a,stroke:"none",fill:e[y],fillOpacity:n,className:"recharts-cartesian-grid-bg"})});return w.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},d)}function NAe(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,m)=>f-m);i!==u[0]&&u.unshift(0);var d=u.map((f,m)=>{var p=!u[m+1],x=p?i+o-f:u[m+1]-f;if(x<=0)return null;var y=m%n.length;return w.createElement("rect",{key:"react-".concat(m),x:f,y:a,width:x,height:l,stroke:"none",fill:n[y],fillOpacity:r,className:"recharts-cartesian-grid-bg"})});return w.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},d)}var MAe=(t,e)=>{var{xAxis:n,width:r,height:i,offset:a}=t;return zK(fO(Ra(Ra(Ra({},Jc),n),{},{ticks:BK(n),viewBox:{x:0,y:0,width:r,height:i}})),a.left,a.left+a.width,e)},EAe=(t,e)=>{var{yAxis:n,width:r,height:i,offset:a}=t;return zK(fO(Ra(Ra(Ra({},Jc),n),{},{ticks:BK(n),viewBox:{x:0,y:0,width:r,height:i}})),a.top,a.top+a.height,e)},TAe={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[],xAxisId:0,yAxisId:0,syncWithTicks:!1,zIndex:ii.grid};function mS(t){var e=zD(),n=BD(),r=YK(),i=Ra(Ra({},Wr(t,TAe)),{},{x:Bt(t.x)?t.x:r.left,y:Bt(t.y)?t.y:r.top,width:Bt(t.width)?t.width:r.width,height:Bt(t.height)?t.height:r.height}),{xAxisId:a,yAxisId:o,x:l,y:c,width:u,height:d,syncWithTicks:f,horizontalValues:m,verticalValues:p}=i,x=Fi(),y=Ft(k=>N6(k,"xAxis",a,x)),b=Ft(k=>N6(k,"yAxis",o,x));if(!Bl(u)||!Bl(d)||!Bt(l)||!Bt(c))return null;var v=i.verticalCoordinatesGenerator||MAe,N=i.horizontalCoordinatesGenerator||EAe,{horizontalPoints:S,verticalPoints:T}=i;if((!S||!S.length)&&typeof N=="function"){var E=m&&m.length,C=N({yAxis:b?Ra(Ra({},b),{},{ticks:E?m:b.ticks}):void 0,width:e??u,height:n??d,offset:r},E?!0:f);Iw(Array.isArray(C),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(typeof C,"]")),Array.isArray(C)&&(S=C)}if((!T||!T.length)&&typeof v=="function"){var A=p&&p.length,O=v({xAxis:y?Ra(Ra({},y),{},{ticks:A?p:y.ticks}):void 0,width:e??u,height:n??d,offset:r},A?!0:f);Iw(Array.isArray(O),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(typeof O,"]")),Array.isArray(O)&&(T=O)}return w.createElement(La,{zIndex:i.zIndex},w.createElement("g",{className:"recharts-cartesian-grid"},w.createElement(vAe,{fill:i.fill,fillOpacity:i.fillOpacity,x:i.x,y:i.y,width:i.width,height:i.height,ry:i.ry}),w.createElement(SAe,nf({},i,{horizontalPoints:S})),w.createElement(NAe,nf({},i,{verticalPoints:T})),w.createElement(_Ae,nf({},i,{offset:r,horizontalPoints:S,xAxis:y,yAxis:b})),w.createElement(wAe,nf({},i,{offset:r,verticalPoints:T,xAxis:y,yAxis:b}))))}mS.displayName="CartesianGrid";var iZ=(t,e,n,r)=>Vl(t,"xAxis",e,r),aZ=(t,e,n,r)=>Hl(t,"xAxis",e,r),sZ=(t,e,n,r)=>Vl(t,"yAxis",n,r),oZ=(t,e,n,r)=>Hl(t,"yAxis",n,r),AAe=et([On,iZ,sZ,aZ,oZ],(t,e,n,r,i)=>Ql(t,"xAxis")?Hd(e,r,!1):Hd(n,i,!1)),CAe=(t,e,n,r,i)=>i;function kAe(t){return t.type==="line"}var jAe=et([Sy,CAe],(t,e)=>t.filter(kAe).find(n=>n.id===e)),PAe=et([On,iZ,sZ,aZ,oZ,jAe,AAe,yy],(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:m}=a,p;if(m!=null&&m.length>0?p=m:p=c?.slice(u,d+1),p!=null)return ZAe({layout:t,xAxis:e,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataKey:f,bandSize:o,displayedData:p})}});function lZ(t){var e=Rf(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 RAe=["id"],DAe=["type","layout","connectNulls","needClip","shape"],OAe=["activeDot","animateNewValues","animationBegin","animationDuration","animationEasing","connectNulls","dot","hide","isAnimationActive","label","legendType","xAxisId","yAxisId","id"];function P0(){return P0=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},P0.apply(null,arguments)}function I$(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 Tl(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?I$(Object(n),!0).forEach(function(r){LAe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):I$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function LAe(t,e,n){return(e=IAe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function IAe(t){var e=FAe(t,"string");return typeof e=="symbol"?e:e+""}function FAe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function pO(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}var zAe=t=>{var{dataKey:e,name:n,stroke:r,legendType:i,hide:a}=t;return[{inactive:a,dataKey:e,type:i,color:r,value:ih(n,e),payload:t}]},BAe=w.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:ih(o,e),hide:l,type:u,color:r,unit:c}};return w.createElement(DN,{tooltipEntrySettings:d})}),cZ=(t,e)=>"".concat(e,"px ").concat(t-e,"px");function $Ae(t,e){for(var n=t.length%2!==0?[...t,0]:t,r=[],i=0;i<e;++i)r=[...r,...n];return r}var HAe=(t,e,n)=>{var r=n.reduce((f,m)=>f+m);if(!r)return cZ(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[...$Ae(n,i),...l,...d].map(f=>"".concat(f,"px")).join(", ")};function VAe(t){var{clipPathId:e,points:n,props:r}=t,{dot:i,dataKey:a,needClip:o}=r,{id:l}=r,c=pO(r,RAe),u=Qa(c);return w.createElement(VQ,{points:n,dot:i,className:"recharts-line-dots",dotClassName:"recharts-line-dot",dataKey:a,baseProps:u,needClip:o,clipPathId:e})}function GAe(t){var{showLabels:e,children:n,points:r}=t,i=w.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 Tl(Tl({},c),{},{value:a.value,payload:a.payload,viewBox:c,parentViewBox:void 0,fill:void 0})}),[r]);return w.createElement(tO,{value:e?i:void 0},n)}function F$(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=pO(a,DAe),m=Tl(Tl({},Sa(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 w.createElement(w.Fragment,null,r?.length>1&&w.createElement(sO,P0({shapeType:"curve",option:d},m,{pathRef:n})),w.createElement(VAe,{points:r,clipPathId:e,props:a}))}function WAe(t){try{return t&&t.getTotalLength&&t.getTotalLength()||0}catch{return 0}}function qAe(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:m,width:p,height:x,onAnimationEnd:y,onAnimationStart:b}=n,v=i.current,N=Hg(o,"recharts-line-"),S=w.useRef(N),[T,E]=w.useState(!1),C=!T,A=w.useCallback(()=>{typeof y=="function"&&y(),E(!1)},[y]),O=w.useCallback(()=>{typeof b=="function"&&b(),E(!0)},[b]),k=WAe(r.current),R=w.useRef(0);S.current!==N&&(R.current=a.current,S.current=N);var F=R.current;return w.createElement(GAe,{points:o,showLabels:C},n.children,w.createElement($g,{animationId:N,begin:u,duration:d,isActive:c,easing:f,onAnimationEnd:A,onAnimationStart:O,key:N},L=>{var K=Zn(F,k+F,L),j=Math.min(K,k),W;if(c)if(l){var Y="".concat(l).split(/[,\s]+/gim).map(ee=>parseFloat(ee));W=HAe(j,k,Y)}else W=cZ(k,j);else W=l==null?void 0:String(l);if(L>0&&k>0&&(i.current=o,a.current=Math.max(a.current,j)),v){var q=v.length/o.length,Q=L===1?o:o.map((ee,re)=>{var z=Math.floor(re*q);if(v[z]){var G=v[z];return Tl(Tl({},ee),{},{x:Zn(G.x,ee.x,L),y:Zn(G.y,ee.y,L)})}return m?Tl(Tl({},ee),{},{x:Zn(p*2,ee.x,L),y:Zn(x/2,ee.y,L)}):Tl(Tl({},ee),{},{x:ee.x,y:ee.y})});return i.current=Q,w.createElement(F$,{props:n,points:Q,clipPathId:e,pathRef:r,strokeDasharray:W})}return w.createElement(F$,{props:n,points:o,clipPathId:e,pathRef:r,strokeDasharray:W})}),w.createElement(jN,{label:n.label}))}function KAe(t){var{clipPathId:e,props:n}=t,r=w.useRef(null),i=w.useRef(0),a=w.useRef(null);return w.createElement(qAe,{props:n,clipPathId:e,previousPointsRef:r,longestAnimatedLengthRef:i,pathRef:a})}var XAe=(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:ir(t.payload,e)}};class YAe extends w.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:m,zIndex:p}=this.props;if(e)return null;var x=$n("recharts-line",i),y=f,{r:b,strokeWidth:v}=lZ(n),N=aO(n),S=b*2+v,T=m?"url(#clipPath-".concat(N?"":"dots-").concat(y,")"):void 0;return w.createElement(La,{zIndex:p},w.createElement(Gr,{className:x},m&&w.createElement("defs",null,w.createElement(hO,{clipPathId:y,xAxisId:a,yAxisId:o}),!N&&w.createElement("clipPath",{id:"clipPath-dots-".concat(y)},w.createElement("rect",{x:c-S/2,y:l-S/2,width:u+S,height:d+S}))),w.createElement(qQ,{xAxisId:a,yAxisId:o,data:r,dataPointFormatter:XAe,errorBarOffset:0},w.createElement(KAe,{props:this.props,clipPathId:y}))),w.createElement(Q3,{activeDot:this.props.activeDot,points:r,mainColor:this.props.stroke,itemDataKey:this.props.dataKey,clipPath:T}))}}var uZ={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:ii.line,type:"linear"};function QAe(t){var e=Wr(t,uZ),{activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:a,animationEasing:o,connectNulls:l,dot:c,hide:u,isAnimationActive:d,label:f,legendType:m,xAxisId:p,yAxisId:x,id:y}=e,b=pO(e,OAe),{needClip:v}=FN(p,x),N=IN(),S=Jf(),T=Fi(),E=Ft(R=>PAe(R,p,x,T,y));if(S!=="horizontal"&&S!=="vertical"||E==null||N==null)return null;var{height:C,width:A,x:O,y:k}=N;return w.createElement(YAe,P0({},b,{id:y,connectNulls:l,dot:c,activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:a,animationEasing:o,isAnimationActive:d,hide:u,label:f,legendType:m,xAxisId:p,yAxisId:x,points:E,layout:S,height:C,width:A,left:O,top:k,needClip:v}))}function ZAe(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=ir(u,o);if(e==="horizontal"){var m=Lw({axis:n,ticks:i,bandSize:l,entry:u,index:d}),p=Pr(f)?null:r.scale(f);return{x:m,y:p,value:f,payload:u}}var x=Pr(f)?null:n.scale(f),y=Lw({axis:r,ticks:a,bandSize:l,entry:u,index:d});return x==null||y==null?null:{x,y,value:f,payload:u}}).filter(Boolean)}function JAe(t){var e=Wr(t,uZ),n=Fi();return w.createElement(ON,{id:e.id,type:"line"},r=>w.createElement(w.Fragment,null,w.createElement(uO,{legendPayload:zAe(e)}),w.createElement(BAe,{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}),w.createElement(dO,{type:"line",id:r,data:e.data,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,dataKey:e.dataKey,hide:e.hide,isPanorama:n}),w.createElement(QAe,P0({},e,{id:r}))))}var dZ=w.memo(JAe,Py);dZ.displayName="Line";var hZ=(t,e,n,r)=>Vl(t,"xAxis",e,r),fZ=(t,e,n,r)=>Hl(t,"xAxis",e,r),mZ=(t,e,n,r)=>Vl(t,"yAxis",n,r),pZ=(t,e,n,r)=>Hl(t,"yAxis",n,r),eCe=et([On,hZ,mZ,fZ,pZ],(t,e,n,r,i)=>Ql(t,"xAxis")?Hd(e,r,!1):Hd(n,i,!1)),tCe=(t,e,n,r,i)=>i,gZ=et([Sy,tCe],(t,e)=>t.filter(n=>n.type==="area").find(n=>n.id===e)),nCe=(t,e,n,r,i)=>{var a,o=gZ(t,e,n,r,i);if(o!=null){var l=On(t),c=Ql(l,"xAxis"),u;if(c?u=k0(t,"yAxis",n,r):u=k0(t,"xAxis",e,r),u!=null){var{stackId:d}=o,f=_N(o);if(!(d==null||f==null)){var m=(a=u[d])===null||a===void 0?void 0:a.stackedData;return m?.find(p=>p.key===f)}}}},rCe=et([On,hZ,mZ,fZ,pZ,nCe,yy,eCe,gZ,j_e],(t,e,n,r,i,a,o,l,c,u)=>{var{chartData:d,dataStartIndex:f,dataEndIndex:m}=o;if(!(c==null||t!=="horizontal"&&t!=="vertical"||e==null||n==null||r==null||i==null||r.length===0||i.length===0||l==null)){var{data:p}=c,x;if(p&&p.length>0?x=p:x=d?.slice(f,m+1),x!=null)return wCe({layout:t,xAxis:e,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataStartIndex:f,areaSettings:c,stackedData:a,displayedData:x,chartBaseValue:u,bandSize:l})}}),iCe=["id"],aCe=["activeDot","animationBegin","animationDuration","animationEasing","connectNulls","dot","fill","fillOpacity","hide","isAnimationActive","legendType","stroke","xAxisId","yAxisId"];function pf(){return pf=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},pf.apply(null,arguments)}function xZ(t,e){if(t==null)return{};var n,r,i=sCe(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 sCe(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 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 Fp(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){oCe(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 oCe(t,e,n){return(e=lCe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function lCe(t){var e=cCe(t,"string");return typeof e=="symbol"?e:e+""}function cCe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function pS(t,e){return t&&t!=="none"?t:e}var uCe=t=>{var{dataKey:e,name:n,stroke:r,fill:i,legendType:a,hide:o}=t;return[{inactive:o,dataKey:e,type:a,color:pS(r,i),value:ih(n,e),payload:t}]},dCe=w.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:ih(o,e),hide:l,type:u,color:pS(r,a),unit:c}};return w.createElement(DN,{tooltipEntrySettings:d})});function hCe(t){var{clipPathId:e,points:n,props:r}=t,{needClip:i,dot:a,dataKey:o}=r,l=Qa(r);return w.createElement(VQ,{points:n,dot:a,className:"recharts-area-dots",dotClassName:"recharts-area-dot",dataKey:o,baseProps:l,needClip:i,clipPathId:e})}function fCe(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 Fp(Fp({},c),{},{value:a.value,payload:a.payload,parentViewBox:void 0,viewBox:c,fill:void 0})});return w.createElement(tO,{value:e?i:void 0},n)}function z$(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,m=xZ(a,iCe),p=Qa(m),x=Sa(m);return w.createElement(w.Fragment,null,e?.length>1&&w.createElement(Gr,{clipPath:r?"url(#clipPath-".concat(i,")"):void 0},w.createElement(Wp,pf({},x,{id:f,points:e,connectNulls:u,type:l,baseLine:n,layout:o,stroke:"none",className:"recharts-area-area"})),c!=="none"&&w.createElement(Wp,pf({},p,{className:"recharts-area-curve",layout:o,type:l,connectNulls:u,fill:"none",points:e})),c!=="none"&&d&&w.createElement(Wp,pf({},p,{className:"recharts-area-curve",layout:o,type:l,connectNulls:u,fill:"none",points:n}))),w.createElement(hCe,{points:e,props:m,clipPathId:i}))}function mCe(t){var{alpha:e,baseLine:n,points:r,strokeWidth:i}=t,a=r[0].y,o=r[r.length-1].y;if(!ar(a)||!ar(o))return null;var l=e*Math.abs(a-o),c=Math.max(...r.map(u=>u.x||0));return Bt(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(u=>u.x||0),c)),Bt(c)?w.createElement("rect",{x:0,y:a<o?a:a-l,width:c+(i?parseInt("".concat(i),10):1),height:Math.floor(l)}):null}function pCe(t){var{alpha:e,baseLine:n,points:r,strokeWidth:i}=t,a=r[0].x,o=r[r.length-1].x;if(!ar(a)||!ar(o))return null;var l=e*Math.abs(a-o),c=Math.max(...r.map(u=>u.y||0));return Bt(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(u=>u.y||0),c)),Bt(c)?w.createElement("rect",{x:a<o?a:a-l,y:0,width:l,height:Math.floor(c+(i?parseInt("".concat(i),10):1))}):null}function gCe(t){var{alpha:e,layout:n,points:r,baseLine:i,strokeWidth:a}=t;return n==="vertical"?w.createElement(mCe,{alpha:e,points:r,baseLine:i,strokeWidth:a}):w.createElement(pCe,{alpha:e,points:r,baseLine:i,strokeWidth:a})}function xCe(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:m,onAnimationEnd:p}=r,x=w.useMemo(()=>({points:o,baseLine:l}),[o,l]),y=Hg(x,"recharts-area-"),b=Xxe(),[v,N]=w.useState(!1),S=!v,T=w.useCallback(()=>{typeof p=="function"&&p(),N(!1)},[p]),E=w.useCallback(()=>{typeof m=="function"&&m(),N(!0)},[m]);if(b==null)return null;var C=i.current,A=a.current;return w.createElement(fCe,{showLabels:S,points:o},r.children,w.createElement($g,{animationId:y,begin:u,duration:d,isActive:c,easing:f,onAnimationEnd:T,onAnimationStart:E,key:y},O=>{if(C){var k=C.length/o.length,R=O===1?o:o.map((L,K)=>{var j=Math.floor(K*k);if(C[j]){var W=C[j];return Fp(Fp({},L),{},{x:Zn(W.x,L.x,O),y:Zn(W.y,L.y,O)})}return L}),F;return Bt(l)?F=Zn(A,l,O):Pr(l)||ws(l)?F=Zn(A,0,O):F=l.map((L,K)=>{var j=Math.floor(K*k);if(Array.isArray(A)&&A[j]){var W=A[j];return Fp(Fp({},L),{},{x:Zn(W.x,L.x,O),y:Zn(W.y,L.y,O)})}return L}),O>0&&(i.current=R,a.current=F),w.createElement(z$,{points:R,baseLine:F,needClip:e,clipPathId:n,props:r})}return O>0&&(i.current=o,a.current=l),w.createElement(Gr,null,c&&w.createElement("defs",null,w.createElement("clipPath",{id:"animationClipPath-".concat(n)},w.createElement(gCe,{alpha:O,points:o,baseLine:l,layout:b,strokeWidth:r.strokeWidth}))),w.createElement(Gr,{clipPath:"url(#animationClipPath-".concat(n,")")},w.createElement(z$,{points:o,baseLine:l,needClip:e,clipPathId:n,props:r})))}),w.createElement(jN,{label:r.label}))}function bCe(t){var{needClip:e,clipPathId:n,props:r}=t,i=w.useRef(null),a=w.useRef();return w.createElement(xCe,{needClip:e,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:a})}class yCe extends w.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:m,baseLine:p,zIndex:x}=this.props;if(e)return null;var y=$n("recharts-area",i),b=m,{r:v,strokeWidth:N}=lZ(n),S=aO(n),T=v*2+N,E=l?"url(#clipPath-".concat(S?"":"dots-").concat(b,")"):void 0;return w.createElement(La,{zIndex:x},w.createElement(Gr,{className:y},l&&w.createElement("defs",null,w.createElement(hO,{clipPathId:b,xAxisId:c,yAxisId:u}),!S&&w.createElement("clipPath",{id:"clipPath-dots-".concat(b)},w.createElement("rect",{x:o-T/2,y:a-T/2,width:d+T,height:f+T}))),w.createElement(bCe,{needClip:l,clipPathId:b,props:this.props})),w.createElement(Q3,{points:r,mainColor:pS(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:E}),this.props.isRange&&Array.isArray(p)&&w.createElement(Q3,{points:p,mainColor:pS(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:E}))}}var bZ={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:ii.area};function vCe(t){var e,n=Wr(t,bZ),{activeDot:r,animationBegin:i,animationDuration:a,animationEasing:o,connectNulls:l,dot:c,fill:u,fillOpacity:d,hide:f,isAnimationActive:m,legendType:p,stroke:x,xAxisId:y,yAxisId:b}=n,v=xZ(n,aCe),N=Jf(),S=fQ(),{needClip:T}=FN(y,b),E=Fi(),{points:C,isRange:A,baseLine:O}=(e=Ft(j=>rCe(j,y,b,E,t.id)))!==null&&e!==void 0?e:{},k=IN();if(N!=="horizontal"&&N!=="vertical"||k==null||S!=="AreaChart"&&S!=="ComposedChart")return null;var{height:R,width:F,x:L,y:K}=k;return!C||!C.length?null:w.createElement(yCe,pf({},v,{activeDot:r,animationBegin:i,animationDuration:a,animationEasing:o,baseLine:O,connectNulls:l,dot:c,fill:u,fillOpacity:d,height:R,hide:f,layout:N,isAnimationActive:m==="auto"?!Bg.isSsr:m,isRange:A,legendType:p,needClip:T,points:C,stroke:x,width:F,left:L,top:K,xAxisId:y,yAxisId:b}))}var _Ce=(t,e,n,r,i)=>{var a=n??e;if(Bt(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 wCe(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:m,bandSize:p}=t,x=i&&i.length,y=_Ce(a,o,n,l,c),b=a==="horizontal",v=!1,N=u.map((T,E)=>{var C;x?C=i[d+E]:(C=ir(T,r),Array.isArray(C)?v=!0:C=[y,C]);var A=C[1]==null||x&&!e&&ir(T,r)==null;return b?{x:Lw({axis:l,ticks:f,bandSize:p,entry:T,index:E}),y:A?null:c.scale(C[1]),value:C,payload:T}:{x:A?null:l.scale(C[1]),y:Lw({axis:c,ticks:m,bandSize:p,entry:T,index:E}),value:C,payload:T}}),S;return x||v?S=N.map(T=>{var E=Array.isArray(T.value)?T.value[0]:null;return b?{x:T.x,y:E!=null&&T.y!=null?c.scale(E):null,payload:T.payload}:{x:E!=null?l.scale(E):null,y:T.y,payload:T.payload}}):S=b?c.scale(y):l.scale(y),{points:N,baseLine:S,isRange:v}}function SCe(t){var e=Wr(t,bZ),n=Fi();return w.createElement(ON,{id:e.id,type:"area"},r=>w.createElement(w.Fragment,null,w.createElement(uO,{legendPayload:uCe(e)}),w.createElement(dCe,{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}),w.createElement(dO,{type:"area",id:r,data:e.data,dataKey:e.dataKey,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,stackId:$K(e.stackId),hide:e.hide,barSize:void 0,baseValue:e.baseValue,isPanorama:n,connectNulls:e.connectNulls}),w.createElement(vCe,pf({},e,{id:r}))))}var yZ=w.memo(SCe,Py);yZ.displayName="Area";var NCe=["domain","range"],MCe=["domain","range"];function B$(t,e){if(t==null)return{};var n,r,i=ECe(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 ECe(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 $$(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 vZ(t,e){if(t===e)return!0;var{domain:n,range:r}=t,i=B$(t,NCe),{domain:a,range:o}=e,l=B$(e,MCe);return!$$(n,a)||!$$(r,o)?!1:Py(i,l)}var TCe=["dangerouslySetInnerHTML","ticks"],ACe=["id"];function J3(){return J3=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},J3.apply(null,arguments)}function H$(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}function kCe(t){var e=wr(),n=w.useRef(null);return w.useLayoutEffect(()=>{n.current===null?e(NMe(t)):n.current!==t&&e(MMe({prev:n.current,next:t})),n.current=t},[t,e]),w.useLayoutEffect(()=>()=>{n.current&&(e(EMe(n.current)),n.current=null)},[e]),null}var jCe=t=>{var{xAxisId:e,className:n}=t,r=Ft(FD),i=Fi(),a="xAxis",o=Ft(b=>Gd(b,a,e,i)),l=Ft(b=>GY(b,a,e,i)),c=Ft(b=>BY(b,e)),u=Ft(b=>A1e(b,e)),d=Ft(b=>wY(b,e));if(c==null||u==null||d==null)return null;var{dangerouslySetInnerHTML:f,ticks:m}=t,p=H$(t,TCe),{id:x}=d,y=H$(d,ACe);return w.createElement(mO,J3({},p,y,{scale:o,x:u.x,y:u.y,width:c.width,height:c.height,className:$n("recharts-".concat(a," ").concat(a),n),viewBox:r,ticks:l,axisType:a}))},PCe={allowDataOverflow:Ki.allowDataOverflow,allowDecimals:Ki.allowDecimals,allowDuplicatedCategory:Ki.allowDuplicatedCategory,angle:Ki.angle,axisLine:Jc.axisLine,height:Ki.height,hide:!1,includeHidden:Ki.includeHidden,interval:Ki.interval,minTickGap:Ki.minTickGap,mirror:Ki.mirror,orientation:Ki.orientation,padding:Ki.padding,reversed:Ki.reversed,scale:Ki.scale,tick:Ki.tick,tickCount:Ki.tickCount,tickLine:Jc.tickLine,tickSize:Jc.tickSize,type:Ki.type,xAxisId:0},RCe=t=>{var e=Wr(t,PCe);return w.createElement(w.Fragment,null,w.createElement(kCe,{allowDataOverflow:e.allowDataOverflow,allowDecimals:e.allowDecimals,allowDuplicatedCategory:e.allowDuplicatedCategory,angle:e.angle,dataKey:e.dataKey,domain:e.domain,height:e.height,hide:e.hide,id:e.xAxisId,includeHidden:e.includeHidden,interval:e.interval,minTickGap:e.minTickGap,mirror:e.mirror,name:e.name,orientation:e.orientation,padding:e.padding,reversed:e.reversed,scale:e.scale,tick:e.tick,tickCount:e.tickCount,tickFormatter:e.tickFormatter,ticks:e.ticks,type:e.type,unit:e.unit}),w.createElement(jCe,e))},gS=w.memo(RCe,vZ);gS.displayName="XAxis";var DCe=["dangerouslySetInnerHTML","ticks"],OCe=["id"];function eP(){return eP=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},eP.apply(null,arguments)}function V$(t,e){if(t==null)return{};var n,r,i=LCe(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 LCe(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 ICe(t){var e=wr(),n=w.useRef(null);return w.useLayoutEffect(()=>{n.current===null?e(TMe(t)):n.current!==t&&e(AMe({prev:n.current,next:t})),n.current=t},[t,e]),w.useLayoutEffect(()=>()=>{n.current&&(e(CMe(n.current)),n.current=null)},[e]),null}var FCe=t=>{var{yAxisId:e,className:n,width:r,label:i}=t,a=w.useRef(null),o=w.useRef(null),l=Ft(FD),c=Fi(),u=wr(),d="yAxis",f=Ft(E=>Gd(E,d,e,c)),m=Ft(E=>$Y(E,e)),p=Ft(E=>k1e(E,e)),x=Ft(E=>GY(E,d,e,c)),y=Ft(E=>SY(E,e));if(w.useLayoutEffect(()=>{if(!(r!=="auto"||!m||eO(i)||w.isValidElement(i)||y==null)){var E=a.current;if(E){var C=E.getCalculatedWidth();Math.round(m.width)!==Math.round(C)&&u(kMe({id:e,width:C}))}}},[x,m,u,i,e,r,y]),m==null||p==null||y==null)return null;var{dangerouslySetInnerHTML:b,ticks:v}=t,N=V$(t,DCe),{id:S}=y,T=V$(y,OCe);return w.createElement(mO,eP({},N,T,{ref:a,labelRef:o,scale:f,x:p.x,y:p.y,tickTextProps:r==="auto"?{width:void 0}:{width:r},width:m.width,height:m.height,className:$n("recharts-".concat(d," ").concat(d),n),viewBox:l,ticks:x,axisType:d}))},UCe={allowDataOverflow:Xi.allowDataOverflow,allowDecimals:Xi.allowDecimals,allowDuplicatedCategory:Xi.allowDuplicatedCategory,angle:Xi.angle,axisLine:Jc.axisLine,hide:!1,includeHidden:Xi.includeHidden,interval:Xi.interval,minTickGap:Xi.minTickGap,mirror:Xi.mirror,orientation:Xi.orientation,padding:Xi.padding,reversed:Xi.reversed,scale:Xi.scale,tick:Xi.tick,tickCount:Xi.tickCount,tickLine:Jc.tickLine,tickSize:Jc.tickSize,type:Xi.type,width:Xi.width,yAxisId:0},zCe=t=>{var e=Wr(t,UCe);return w.createElement(w.Fragment,null,w.createElement(ICe,{interval:e.interval,id:e.yAxisId,scale:e.scale,type:e.type,domain:e.domain,allowDataOverflow:e.allowDataOverflow,dataKey:e.dataKey,allowDuplicatedCategory:e.allowDuplicatedCategory,allowDecimals:e.allowDecimals,tickCount:e.tickCount,padding:e.padding,includeHidden:e.includeHidden,reversed:e.reversed,ticks:e.ticks,width:e.width,orientation:e.orientation,mirror:e.mirror,hide:e.hide,unit:e.unit,name:e.name,angle:e.angle,minTickGap:e.minTickGap,tick:e.tick,tickFormatter:e.tickFormatter}),w.createElement(FCe,e))},xS=w.memo(zCe,vZ);xS.displayName="YAxis";var BCe=(t,e)=>e,gO=et([BCe,On,vY,zi,oQ,vu,Gwe,Ii],Zwe),xO=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)}},_Z=Lo("mouseClick"),wZ=dy();wZ.startListening({actionCreator:_Z,effect:(t,e)=>{var n=t.payload,r=gO(e.getState(),xO(n));r?.activeIndex!=null&&e.dispatch(V1e({activeIndex:r.activeIndex,activeDataKey:void 0,activeCoordinate:r.activeCoordinate}))}});var tP=Lo("mouseMove"),SZ=dy(),__=null;SZ.startListening({actionCreator:tP,effect:(t,e)=>{var n=t.payload;__!==null&&cancelAnimationFrame(__);var r=xO(n);__=requestAnimationFrame(()=>{var i=e.getState(),a=H4(i,i.tooltip.settings.shared);if(a==="axis"){var o=gO(i,r);o?.activeIndex!=null?e.dispatch(JY({activeIndex:o.activeIndex,activeDataKey:void 0,activeCoordinate:o.activeCoordinate})):e.dispatch(ZY())}__=null})}});var G$={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},NZ=Ss({name:"rootProps",initialState:G$,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:G$.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}}}),$Ce=NZ.reducer,{updateOptions:HCe}=NZ.actions,MZ=Ss({name:"polarOptions",initialState:null,reducers:{updatePolarOptions:(t,e)=>e.payload}}),{updatePolarOptions:VCe}=MZ.actions,GCe=MZ.reducer,EZ=Lo("keyDown"),TZ=Lo("focus"),bO=dy();bO.startListening({actionCreator:EZ,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=V4(i,Qg(n),My(n),Cy(n)),l=o==null?-1:Number(o);if(!(!Number.isFinite(l)||l<0)){var c=vu(n);if(a==="Enter"){var u=iS(n,"axis","hover",String(i.index));e.dispatch(G3({active:!i.active,activeIndex:i.index,activeDataKey:i.dataKey,activeCoordinate:u}));return}var d=D1e(n),f=d==="left-to-right"?1:-1,m=a==="ArrowRight"?1:-1,p=l+m*f;if(!(c==null||p>=c.length||p<0)){var x=iS(n,"axis","hover",String(p));e.dispatch(G3({active:!0,activeIndex:p.toString(),activeDataKey:void 0,activeCoordinate:x}))}}}}}});bO.startListening({actionCreator:TZ,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=iS(n,"axis","hover",String(a));e.dispatch(G3({activeDataKey:void 0,active:!0,activeIndex:a,activeCoordinate:o}))}}}});var mo=Lo("externalEvent"),AZ=dy(),gC=new Map;AZ.startListening({actionCreator:mo,effect:(t,e)=>{var{handler:n,reactEvent:r}=t.payload;if(n!=null){r.persist();var i=r.type,a=gC.get(i);a!==void 0&&cancelAnimationFrame(a);var o=requestAnimationFrame(()=>{try{var l=e.getState(),c={activeCoordinate:kwe(l),activeDataKey:X4(l),activeIndex:Wd(l),activeLabel:uQ(l),activeTooltipIndex:Wd(l),isTooltipActive:jwe(l)};n(c,r)}finally{gC.delete(i)}});gC.set(i,o)}}});var WCe=et([Yg],t=>t.tooltipItemPayloads),qCe=et([WCe,Ty,(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}}}),CZ=Lo("touchMove"),kZ=dy();kZ.startListening({actionCreator:CZ,effect:(t,e)=>{var n=t.payload;if(!(n.touches==null||n.touches.length===0)){var r=e.getState(),i=H4(r,r.tooltip.settings.shared);if(i==="axis"){var a=gO(r,xO({clientX:n.touches[0].clientX,clientY:n.touches[0].clientY,currentTarget:n.currentTarget}));a?.activeIndex!=null&&e.dispatch(JY({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(VK),d=(o=c.getAttribute(GK))!==null&&o!==void 0?o:void 0,f=qCe(e.getState(),u,d);e.dispatch(QY({activeDataKey:d,activeIndex:u,activeCoordinate:f}))}}}});var KCe=dK({brush:bTe,cartesianAxis:jMe,chartData:CSe,errorBars:YMe,graphicalItems:FNe,layout:nxe,legend:ube,options:NSe,polarAxis:J2e,polarOptions:GCe,referenceElements:CTe,rootProps:$Ce,tooltip:G1e,zIndex:hSe}),XCe=function(e){return Tge({reducer:KCe,preloadedState:e,middleware:n=>{var r;return n({serializableCheck:!1,immutableCheck:!["commonjs","es6","production"].includes((r="es6")!==null&&r!==void 0?r:"")}).concat([wZ.middleware,SZ.middleware,bO.middleware,AZ.middleware,kZ.middleware])},enhancers:n=>{var r=n;return typeof n=="function"&&(r=n()),r.concat(EK({type:"raf"}))},devTools:Bg.devToolsEnabled})};function jZ(t){var{preloadedState:e,children:n,reduxStoreName:r}=t,i=Fi(),a=w.useRef(null);if(i)return n;a.current==null&&(a.current=XCe(e));var o=CD;return w.createElement(vEe,{context:o,store:a.current},n)}function YCe(t){var{layout:e,margin:n}=t,r=wr(),i=Fi();return w.useEffect(()=>{i||(r(Jge(e)),r(Zge(n)))},[r,i,e,n]),null}var PZ=w.memo(YCe,Py);function RZ(t){var e=wr();return w.useEffect(()=>{e(HCe(t))},[e,t]),null}function W$(t){var{zIndex:e,isPanorama:n}=t,r=n?"recharts-zindex-panorama-":"recharts-zindex-",i=BQ("".concat(r).concat(e)),a=wr();return w.useLayoutEffect(()=>(a(uSe({zIndex:e,elementId:i,isPanorama:n})),()=>{a(dSe({zIndex:e,isPanorama:n}))}),[a,e,i,n]),w.createElement("g",{tabIndex:-1,id:i})}function q$(t){var{children:e,isPanorama:n}=t,r=Ft(eSe);if(!r||r.length===0)return e;var i=r.filter(o=>o<0),a=r.filter(o=>o>0);return w.createElement(w.Fragment,null,i.map(o=>w.createElement(W$,{key:o,zIndex:o,isPanorama:n})),e,a.map(o=>w.createElement(W$,{key:o,zIndex:o,isPanorama:n})))}var QCe=["children"];function ZCe(t,e){if(t==null)return{};var n,r,i=JCe(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 JCe(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 bS(){return bS=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},bS.apply(null,arguments)}var eke={width:"100%",height:"100%",display:"block"},tke=w.forwardRef((t,e)=>{var n=zD(),r=BD(),i=oX();if(!Bl(n)||!Bl(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),w.createElement(yD,bS({},o,{title:l,desc:c,role:d,tabIndex:u,width:n,height:r,style:eke,ref:e}),a)}),nke=t=>{var{children:e}=t,n=Ft(lN);if(!n)return null;var{width:r,height:i,y:a,x:o}=n;return w.createElement(yD,{width:r,height:i,x:o,y:a},e)},K$=w.forwardRef((t,e)=>{var{children:n}=t,r=ZCe(t,QCe),i=Fi();return i?w.createElement(nke,null,w.createElement(q$,{isPanorama:!0},n)):w.createElement(tke,bS({ref:e},r),w.createElement(q$,{isPanorama:!1},n))});function rke(){var t=wr(),[e,n]=w.useState(null),r=Ft(yxe);return w.useEffect(()=>{if(e!=null){var i=e.getBoundingClientRect(),a=i.width/e.offsetWidth;ar(a)&&a!==r&&t(txe(a))}},[e,t,r]),n}function X$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function ike(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?X$(Object(n),!0).forEach(function(r){ake(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):X$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function ake(t,e,n){return(e=ske(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function ske(t){var e=oke(t,"string");return typeof e=="symbol"?e:e+""}function oke(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Uf(){return Uf=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Uf.apply(null,arguments)}var lke=()=>(FSe(),null);function yS(t){if(typeof t=="number")return t;if(typeof t=="string"){var e=parseFloat(t);if(!Number.isNaN(e))return e}return 0}var cke=w.forwardRef((t,e)=>{var n,r,i=w.useRef(null),[a,o]=w.useState({containerWidth:yS((n=t.style)===null||n===void 0?void 0:n.width),containerHeight:yS((r=t.style)===null||r===void 0?void 0:r.height)}),l=w.useCallback((u,d)=>{o(f=>{var m=Math.round(u),p=Math.round(d);return f.containerWidth===m&&f.containerHeight===p?f:{containerWidth:m,containerHeight:p}})},[]),c=w.useCallback(u=>{if(typeof e=="function"&&e(u),u!=null&&typeof ResizeObserver<"u"){var{width:d,height:f}=u.getBoundingClientRect();l(d,f);var m=x=>{var{width:y,height:b}=x[0].contentRect;l(y,b)},p=new ResizeObserver(m);p.observe(u),i.current=p}},[e,l]);return w.useEffect(()=>()=>{var u=i.current;u?.disconnect()},[l]),w.createElement(w.Fragment,null,w.createElement(cN,{width:a.containerWidth,height:a.containerHeight}),w.createElement("div",Uf({ref:c},t)))}),uke=w.forwardRef((t,e)=>{var{width:n,height:r}=t,[i,a]=w.useState({containerWidth:yS(n),containerHeight:yS(r)}),o=w.useCallback((c,u)=>{a(d=>{var f=Math.round(c),m=Math.round(u);return d.containerWidth===f&&d.containerHeight===m?d:{containerWidth:f,containerHeight:m}})},[]),l=w.useCallback(c=>{if(typeof e=="function"&&e(c),c!=null){var{width:u,height:d}=c.getBoundingClientRect();o(u,d)}},[e,o]);return w.createElement(w.Fragment,null,w.createElement(cN,{width:i.containerWidth,height:i.containerHeight}),w.createElement("div",Uf({ref:l},t)))}),dke=w.forwardRef((t,e)=>{var{width:n,height:r}=t;return w.createElement(w.Fragment,null,w.createElement(cN,{width:n,height:r}),w.createElement("div",Uf({ref:e},t)))}),hke=w.forwardRef((t,e)=>{var{width:n,height:r}=t;return ou(n)||ou(r)?w.createElement(uke,Uf({},t,{ref:e})):w.createElement(dke,Uf({},t,{ref:e}))});function fke(t){return t===!0?cke:hke}var mke=w.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:m,onTouchEnd:p,onTouchMove:x,onTouchStart:y,style:b,width:v,responsive:N,dispatchTouchEvents:S=!0}=t,T=w.useRef(null),E=wr(),[C,A]=w.useState(null),[O,k]=w.useState(null),R=rke(),F=UD(),L=F?.width>0?F.width:v,K=F?.height>0?F.height:i,j=w.useCallback(me=>{R(me),typeof e=="function"&&e(me),A(me),k(me),me!=null&&(T.current=me)},[R,e,A,k]),W=w.useCallback(me=>{E(_Z(me)),E(mo({handler:a,reactEvent:me}))},[E,a]),Y=w.useCallback(me=>{E(tP(me)),E(mo({handler:u,reactEvent:me}))},[E,u]),q=w.useCallback(me=>{E(ZY()),E(mo({handler:d,reactEvent:me}))},[E,d]),Q=w.useCallback(me=>{E(tP(me)),E(mo({handler:f,reactEvent:me}))},[E,f]),ee=w.useCallback(()=>{E(TZ())},[E]),re=w.useCallback(me=>{E(EZ(me.key))},[E]),z=w.useCallback(me=>{E(mo({handler:o,reactEvent:me}))},[E,o]),G=w.useCallback(me=>{E(mo({handler:l,reactEvent:me}))},[E,l]),ae=w.useCallback(me=>{E(mo({handler:c,reactEvent:me}))},[E,c]),se=w.useCallback(me=>{E(mo({handler:m,reactEvent:me}))},[E,m]),ue=w.useCallback(me=>{E(mo({handler:y,reactEvent:me}))},[E,y]),pe=w.useCallback(me=>{S&&E(CZ(me)),E(mo({handler:x,reactEvent:me}))},[E,S,x]),ce=w.useCallback(me=>{E(mo({handler:p,reactEvent:me}))},[E,p]),Me=fke(N);return w.createElement(bQ.Provider,{value:C},w.createElement(Eq.Provider,{value:O},w.createElement(Me,{width:L??b?.width,height:K??b?.height,className:$n("recharts-wrapper",r),style:ike({position:"relative",cursor:"default",width:L,height:K},b),onClick:W,onContextMenu:z,onDoubleClick:G,onFocus:ee,onKeyDown:re,onMouseDown:ae,onMouseEnter:Y,onMouseLeave:q,onMouseMove:Q,onMouseUp:se,onTouchEnd:ce,onTouchMove:pe,onTouchStart:ue,ref:j},w.createElement(lke,null),n)))}),pke=["width","height","responsive","children","className","style","compact","title","desc"];function gke(t,e){if(t==null)return{};var n,r,i=xke(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 xke(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 DZ=w.forwardRef((t,e)=>{var{width:n,height:r,responsive:i,children:a,className:o,style:l,compact:c,title:u,desc:d}=t,f=gke(t,pke),m=Qa(f);return c?w.createElement(w.Fragment,null,w.createElement(cN,{width:n,height:r}),w.createElement(K$,{otherAttributes:m,title:u,desc:d},a)):w.createElement(mke,{className:o,style:l,width:n,height:r,responsive:i??!1,onClick:t.onClick,onMouseLeave:t.onMouseLeave,onMouseEnter:t.onMouseEnter,onMouseMove:t.onMouseMove,onMouseDown:t.onMouseDown,onMouseUp:t.onMouseUp,onContextMenu:t.onContextMenu,onDoubleClick:t.onDoubleClick,onTouchStart:t.onTouchStart,onTouchMove:t.onTouchMove,onTouchEnd:t.onTouchEnd},w.createElement(K$,{otherAttributes:m,title:u,desc:d,ref:e},w.createElement(kTe,null,a)))});function nP(){return nP=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},nP.apply(null,arguments)}var bke={top:5,right:5,bottom:5,left:5},yke={accessibilityLayer:!0,barCategoryGap:"10%",barGap:4,layout:"horizontal",margin:bke,responsive:!1,reverseStackOrder:!1,stackOffset:"none",syncMethod:"index"},yO=w.forwardRef(function(e,n){var r,i=Wr(e.categoricalChartProps,yke),{chartName:a,defaultTooltipEventType:o,validateTooltipEventTypes:l,tooltipPayloadSearcher:c,categoricalChartProps:u}=e,d={chartName:a,defaultTooltipEventType:o,validateTooltipEventTypes:l,tooltipPayloadSearcher:c,eventEmitter:void 0};return w.createElement(jZ,{preloadedState:{options:d},reduxStoreName:(r=u.id)!==null&&r!==void 0?r:a},w.createElement(QQ,{chartData:u.data}),w.createElement(PZ,{layout:i.layout,margin:i.margin}),w.createElement(RZ,{baseValue:i.baseValue,accessibilityLayer:i.accessibilityLayer,barCategoryGap:i.barCategoryGap,maxBarSize:i.maxBarSize,stackOffset:i.stackOffset,barGap:i.barGap,barSize:i.barSize,syncId:i.syncId,syncMethod:i.syncMethod,className:i.className,reverseStackOrder:i.reverseStackOrder}),w.createElement(DZ,nP({},i,{ref:n})))}),vke=["axis"],_ke=w.forwardRef((t,e)=>w.createElement(yO,{chartName:"LineChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:vke,tooltipPayloadSearcher:CN,categoricalChartProps:t,ref:e})),wke=["axis","item"],Ske=w.forwardRef((t,e)=>w.createElement(yO,{chartName:"BarChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:wke,tooltipPayloadSearcher:CN,categoricalChartProps:t,ref:e}));function Nke(t){var e=wr();return w.useEffect(()=>{e(VCe(t))},[e,t]),null}var Mke=["layout"];function rP(){return rP=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},rP.apply(null,arguments)}function Eke(t,e){if(t==null)return{};var n,r,i=Tke(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 Tke(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 Ake={top:5,right:5,bottom:5,left:5},OZ={accessibilityLayer:!0,stackOffset:"none",barCategoryGap:"10%",barGap:4,margin:Ake,reverseStackOrder:!1,syncMethod:"index",layout:"radial",responsive:!1,cx:"50%",cy:"50%",innerRadius:0,outerRadius:"80%"},Cke=w.forwardRef(function(e,n){var r,i=Wr(e.categoricalChartProps,OZ),{layout:a}=i,o=Eke(i,Mke),{chartName:l,defaultTooltipEventType:c,validateTooltipEventTypes:u,tooltipPayloadSearcher:d}=e,f={chartName:l,defaultTooltipEventType:c,validateTooltipEventTypes:u,tooltipPayloadSearcher:d,eventEmitter:void 0};return w.createElement(jZ,{preloadedState:{options:f},reduxStoreName:(r=i.id)!==null&&r!==void 0?r:l},w.createElement(QQ,{chartData:i.data}),w.createElement(PZ,{layout:a,margin:i.margin}),w.createElement(RZ,{baseValue:void 0,accessibilityLayer:i.accessibilityLayer,barCategoryGap:i.barCategoryGap,maxBarSize:i.maxBarSize,stackOffset:i.stackOffset,barGap:i.barGap,barSize:i.barSize,syncId:i.syncId,syncMethod:i.syncMethod,className:i.className,reverseStackOrder:i.reverseStackOrder}),w.createElement(Nke,{cx:i.cx,cy:i.cy,startAngle:i.startAngle,endAngle:i.endAngle,innerRadius:i.innerRadius,outerRadius:i.outerRadius}),w.createElement(DZ,rP({},o,{ref:n})))});function Y$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Q$(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Y$(Object(n),!0).forEach(function(r){kke(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Y$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function kke(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)}var Rke=["item"],Dke=Q$(Q$({},OZ),{},{layout:"centric",startAngle:0,endAngle:360}),Oke=w.forwardRef((t,e)=>{var n=Wr(t,Dke);return w.createElement(Cke,{chartName:"PieChart",defaultTooltipEventType:"item",validateTooltipEventTypes:Rke,tooltipPayloadSearcher:CN,categoricalChartProps:n,ref:e})}),Lke=["axis"],Ike=w.forwardRef((t,e)=>w.createElement(yO,{chartName:"AreaChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:Lke,tooltipPayloadSearcher:CN,categoricalChartProps:t,ref:e}));const Z$=[{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 Fke({isOpen:t,onClose:e,printerId:n,printerName:r,amsId:i,amsLabel:a,initialMode:o="humidity",thresholds:l}){const{t:c}=Og(),{mode:u}=nh(),[d,f]=w.useState("24h"),[m,p]=w.useState(o),x=u==="dark",{data:y}=ut({queryKey:["settings"],queryFn:he.getSettings}),b=y?.time_format||"system";w.useEffect(()=>{if(!t)return;const se=ue=>{ue.key==="Escape"&&e()};return window.addEventListener("keydown",se),()=>window.removeEventListener("keydown",se)},[t,e]);const v=Z$.find(se=>se.value===d)?.hours||24,{data:N,isLoading:S,error:T}=ut({queryKey:["ams-history",n,i,v],queryFn:()=>he.getAMSHistory(n,i,v),enabled:t,refetchInterval:6e4});if(!t)return null;const E=N?.data.map(se=>{const ue=vi(se.recorded_at)||new Date,pe={hour:"2-digit",minute:"2-digit",...v>24?{day:"numeric",month:"short"}:{}};return{time:ue.getTime(),humidity:se.humidity,temperature:se.temperature,timeLabel:ue.toLocaleTimeString([],zb(pe,b))}})||[],C=l?.humidityGood||40,A=l?.humidityFair||60,O=l?.tempGood||30,k=l?.tempFair||35,R=E[E.length-1],F=R?.humidity,L=R?.temperature,K=se=>{const ue=se.filter(fe=>fe!=null);if(ue.length<4)return"stable";const pe=ue.slice(0,Math.floor(ue.length/4)),ce=ue.slice(-Math.floor(ue.length/4)),Me=pe.reduce((fe,le)=>fe+le,0)/pe.length,Ee=ce.reduce((fe,le)=>fe+le,0)/ce.length-Me;return Math.abs(Ee)<2?"stable":Ee>0?"up":"down"},j=K(E.map(se=>se.humidity)),W=K(E.map(se=>se.temperature)),Y=({trend:se})=>se==="up"?s.jsx(Jj,{className:"w-4 h-4 text-red-400"}):se==="down"?s.jsx(pq,{className:"w-4 h-4 text-green-400"}):s.jsx(Yj,{className:"w-4 h-4 text-gray-400 dark:text-bambu-gray"}),q=se=>se==null?"#9ca3af":se<=C?"#22a352":se<=A?"#d4a017":"#c62828",Q=se=>se==null?"#9ca3af":se<=O?"#22a352":se<=k?"#d4a017":"#c62828",ee=x?"#2d2d2d":"#ffffff",re=x?"#1d1d1d":"#f3f4f6",z=x?"#3d3d3d":"#e5e7eb",G=x?"#ffffff":"#111827",ae=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:ee},onClick:se=>se.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b",style:{borderColor:z},children:[s.jsxs("div",{children:[s.jsxs("h2",{className:"text-lg font-semibold",style:{color:G},children:[a," ",c("common.history","History")]}),s.jsx("p",{className:"text-sm",style:{color:ae},children:r})]}),s.jsx("button",{onClick:e,className:"p-2 rounded-lg transition-colors",style:{color:ae},children:s.jsx(zt,{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:re},children:[s.jsxs("button",{onClick:()=>p("humidity"),className:`flex items-center gap-2 px-3 py-1.5 text-sm rounded-md transition-colors ${m==="humidity"?"bg-blue-600 text-white":""}`,style:m!=="humidity"?{color:ae}:void 0,children:[s.jsx(uD,{className:"w-4 h-4"}),c("common.humidity","Humidity")]}),s.jsxs("button",{onClick:()=>p("temperature"),className:`flex items-center gap-2 px-3 py-1.5 text-sm rounded-md transition-colors ${m==="temperature"?"bg-orange-600 text-white":""}`,style:m!=="temperature"?{color:ae}:void 0,children:[s.jsx(G2,{className:"w-4 h-4"}),c("common.temperature","Temperature")]})]}),s.jsx("div",{className:"flex gap-1 rounded-lg p-1",style:{backgroundColor:re},children:Z$.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:ae}:void 0,children:se.label},se.value))})]}),s.jsx("div",{className:"grid grid-cols-4 gap-4",children:m==="humidity"?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:re},children:[s.jsx("p",{className:"text-xs",style:{color:ae},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}%`:"—"}),s.jsx(Y,{trend:j})]})]}),s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:re},children:[s.jsx("p",{className:"text-xs",style:{color:ae},children:c("common.average","Average")}),s.jsx("p",{className:"text-2xl font-bold",style:{color:G},children:N?.avg_humidity!=null?`${N.avg_humidity}%`:"—"})]}),s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:re},children:[s.jsx("p",{className:"text-xs",style:{color:ae},children:c("common.min","Min")}),s.jsx("p",{className:"text-2xl font-bold text-green-500",children:N?.min_humidity!=null?`${N.min_humidity}%`:"—"})]}),s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:re},children:[s.jsx("p",{className:"text-xs",style:{color:ae},children:c("common.max","Max")}),s.jsx("p",{className:"text-2xl font-bold text-red-500",children:N?.max_humidity!=null?`${N.max_humidity}%`:"—"})]})]}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:re},children:[s.jsx("p",{className:"text-xs",style:{color:ae},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(L)},children:L!=null?`${L}°C`:"—"}),s.jsx(Y,{trend:W})]})]}),s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:re},children:[s.jsx("p",{className:"text-xs",style:{color:ae},children:c("common.average","Average")}),s.jsx("p",{className:"text-2xl font-bold",style:{color:G},children:N?.avg_temperature!=null?`${N.avg_temperature}°C`:"—"})]}),s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:re},children:[s.jsx("p",{className:"text-xs",style:{color:ae},children:c("common.min","Min")}),s.jsx("p",{className:"text-2xl font-bold text-blue-500",children:N?.min_temperature!=null?`${N.min_temperature}°C`:"—"})]}),s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:re},children:[s.jsx("p",{className:"text-xs",style:{color:ae},children:c("common.max","Max")}),s.jsx("p",{className:"text-2xl font-bold text-red-500",children:N?.max_temperature!=null?`${N.max_temperature}°C`:"—"})]})]})}),s.jsx("div",{className:"rounded-lg p-4",style:{backgroundColor:re},children:S?s.jsx("div",{className:"h-[300px] flex items-center justify-center",style:{color:ae},children:c("common.loading","Loading...")}):T?s.jsx("div",{className:"h-[300px] flex items-center justify-center text-red-500",children:c("common.error","Error loading data")}):E.length===0?s.jsx("div",{className:"h-[300px] flex items-center justify-center",style:{color:ae},children:c("common.noData","No data available for this time range")}):s.jsx(G1,{width:"100%",height:300,children:s.jsxs(_ke,{data:E,children:[s.jsx(mS,{strokeDasharray:"3 3",stroke:x?"#3d3d3d":"#e5e7eb"}),s.jsx(gS,{dataKey:"time",type:"number",domain:["dataMin","dataMax"],tickFormatter:se=>{const ue=new Date(se);return v>24?ue.toLocaleDateString([],{day:"numeric",month:"short"}):ue.toLocaleTimeString([],zb({hour:"2-digit",minute:"2-digit"},b))},stroke:x?"#9ca3af":"#6b7280",tick:{fontSize:12}}),s.jsx(xS,{stroke:x?"#9ca3af":"#6b7280",tick:{fontSize:12},domain:m==="humidity"?[0,100]:["auto","auto"],tickFormatter:se=>m==="humidity"?`${se}%`:`${se}°C`}),s.jsx(q1,{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,zb({year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"},b)),formatter:se=>[m==="humidity"?`${se??0}%`:`${se??0}°C`,m==="humidity"?"Humidity":"Temperature"]}),s.jsx(VD,{}),m==="humidity"?s.jsxs(s.Fragment,{children:[s.jsx(Tb,{y:C,stroke:"#22a352",strokeDasharray:"5 5",label:{value:"Good",fill:"#22a352",fontSize:10}}),s.jsx(Tb,{y:A,stroke:"#d4a017",strokeDasharray:"5 5",label:{value:"Fair",fill:"#d4a017",fontSize:10}})]}):s.jsxs(s.Fragment,{children:[s.jsx(Tb,{y:O,stroke:"#22a352",strokeDasharray:"5 5",label:{value:"Good",fill:"#22a352",fontSize:10}}),s.jsx(Tb,{y:k,stroke:"#d4a017",strokeDasharray:"5 5",label:{value:"Fair",fill:"#d4a017",fontSize:10}})]}),s.jsx(dZ,{type:"monotone",dataKey:m,name:m==="humidity"?"Humidity":"Temperature",stroke:m==="humidity"?"#3b82f6":"#f97316",strokeWidth:2,dot:!1,activeDot:{r:4}})]})})}),s.jsx("div",{className:"text-xs text-center",style:{color:ae},children:c("amsHistory.recordingInfo","Data is recorded every 5 minutes while the printer is connected")})]})]})})}function xC({data:t,children:e,disabled:n,className:r="",spoolman:i,configureSlot:a}){const[o,l]=w.useState(!1),[c,u]=w.useState("top"),[d,f]=w.useState(!1),m=w.useRef(null),p=w.useRef(null),x=w.useRef(null),y=()=>{const C=t.trayUuid;C&&(navigator.clipboard&&window.isSecureContext?navigator.clipboard.writeText(C).then(()=>{f(!0),setTimeout(()=>f(!1),2e3)}).catch(()=>{b(C)}):b(C))},b=C=>{const A=document.createElement("textarea");A.value=C,A.style.position="fixed",A.style.opacity="0",document.body.appendChild(A),A.select();try{document.execCommand("copy"),f(!0),setTimeout(()=>f(!1),2e3)}catch{console.error("Failed to copy to clipboard")}document.body.removeChild(A)};w.useEffect(()=>{if(o&&m.current&&p.current){const C=m.current.getBoundingClientRect(),A=p.current.offsetHeight,O=C.top,k=window.innerHeight-C.bottom;O<A+12&&k>O?u("bottom"):u("top")}},[o]);const v=()=>{n||(x.current&&clearTimeout(x.current),x.current=setTimeout(()=>l(!0),80))},N=()=>{x.current&&clearTimeout(x.current),x.current=setTimeout(()=>l(!1),100)};w.useEffect(()=>()=>{x.current&&clearTimeout(x.current)},[]);const S=C=>C<=15?"#ef4444":C<=30?"#f97316":C<=50?"#eab308":"#22c55e",T=C=>{if(!C)return!1;const A=C.replace("#",""),O=parseInt(A.slice(0,2),16),k=parseInt(A.slice(2,4),16),R=parseInt(A.slice(4,6),16);return(.299*O+.587*k+.114*R)/255>.6},E=t.colorHex?`#${t.colorHex.replace("#","")}`:null;return s.jsxs("div",{ref:m,className:`relative ${r}`,onMouseEnter:v,onMouseLeave:N,children:[e,o&&s.jsxs("div",{ref:p,className:`
  46. absolute left-1/2 -translate-x-1/2 z-50
  47. ${c==="top"?"bottom-full mb-2":"top-full mt-2"}
  48. animate-in fade-in-0 zoom-in-95 duration-150
  49. `,style:{maxWidth:"calc(100vw - 24px)"},children:[s.jsxs("div",{className:`
  50. w-52 bg-bambu-dark-secondary border border-bambu-dark-tertiary
  51. rounded-lg shadow-xl overflow-hidden
  52. backdrop-blur-sm
  53. `,children:[s.jsxs("div",{className:"h-12 relative overflow-hidden",style:{backgroundColor:E||"#3d3d3d"},children:[s.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-white/10 to-transparent"}),s.jsx("div",{className:`
  54. absolute inset-0 flex items-center justify-center
  55. font-semibold text-sm tracking-wide
  56. ${T(E)?"text-black/80":"text-white/90"}
  57. `,children:t.colorName}),s.jsx("div",{className:`
  58. absolute top-1.5 right-1.5 px-1.5 py-0.5 rounded text-[9px] font-bold uppercase tracking-wider
  59. ${t.vendor==="Bambu Lab"?"bg-black/60 text-white":"bg-black/50 text-white/90"}
  60. `,children:t.vendor==="Bambu Lab"?"BBL":"GEN"})]}),s.jsxs("div",{className:"p-3 space-y-2.5",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:"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:"K Factor"}),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(uD,{className:"w-3 h-3"}),"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:S(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:"Spool ID"}),s.jsxs("button",{onClick:C=>{C.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),"..."]}),d?s.jsx(Ya,{className:"w-3 h-3 text-bambu-green"}):s.jsx(ol,{className:"w-3 h-3"})]})]}),i.onLinkSpool&&s.jsxs("button",{onClick:C=>{C.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?"No unlinked spools available":"Link this spool to a Spoolman spool",children:[s.jsx(Ol,{className:"w-3.5 h-3.5"}),"Link to Spoolman"]})]}),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:C=>{C.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:"Configure slot with filament profile and K value",children:[s.jsx(Bd,{className:"w-3.5 h-3.5"}),"Configure"]})})]})]}),s.jsx("div",{className:`
  61. absolute left-1/2 -translate-x-1/2 w-0 h-0
  62. border-l-[6px] border-l-transparent
  63. border-r-[6px] border-r-transparent
  64. ${c==="top"?"top-full border-t-[6px] border-t-bambu-dark-tertiary":"bottom-full border-b-[6px] border-b-bambu-dark-tertiary"}
  65. `})]})]})}function J$({children:t,className:e="",configureSlot:n}){const[r,i]=w.useState(!1),a=w.useRef(null),o=()=>{a.current&&clearTimeout(a.current),a.current=setTimeout(()=>i(!0),80)},l=()=>{a.current&&clearTimeout(a.current),a.current=setTimeout(()=>i(!1),100)};return w.useEffect(()=>()=>{a.current&&clearTimeout(a.current)},[]),s.jsxs("div",{className:`relative ${e}`,onMouseEnter:o,onMouseLeave:l,children:[t,r&&s.jsxs("div",{className:`
  66. absolute left-1/2 -translate-x-1/2 bottom-full mb-2 z-50
  67. animate-in fade-in-0 zoom-in-95 duration-150
  68. `,children:[s.jsxs("div",{className:`
  69. bg-bambu-dark-secondary border border-bambu-dark-tertiary
  70. rounded-md shadow-lg overflow-hidden
  71. `,children:[s.jsx("div",{className:"px-3 py-1.5 text-xs text-bambu-gray whitespace-nowrap",children:"Empty slot"}),n?.enabled&&s.jsx("div",{className:"px-2 pb-2",children:s.jsxs("button",{onClick:c=>{c.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:"Configure slot with filament profile and K value",children:[s.jsx(Bd,{className:"w-3.5 h-3.5"}),"Configure"]})})]}),s.jsx("div",{className:`
  72. absolute left-1/2 -translate-x-1/2 top-full w-0 h-0
  73. border-l-[5px] border-l-transparent
  74. border-r-[5px] border-r-transparent
  75. border-t-[5px] border-t-bambu-dark-tertiary
  76. `})]})]})}function Uke({isOpen:t,onClose:e,trayUuid:n,trayInfo:r}){const i=on(),[a,o]=w.useState(null),{data:l,isLoading:c}=ut({queryKey:["unlinked-spools"],queryFn:he.getUnlinkedSpools,enabled:t}),u=pt({mutationFn:f=>he.linkSpool(f,n),onSuccess:()=>{i.invalidateQueries({queryKey:["unlinked-spools"]}),i.invalidateQueries({queryKey:["spoolman-status"]}),e()}});if(!t)return null;const d=()=>{a&&u.mutate(a)};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(Ol,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Link to Spoolman"})]}),s.jsx("button",{onClick:e,className:"p-1 text-bambu-gray hover:text-white rounded transition-colors",children:s.jsx(zt,{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.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Spool UUID:"}),s.jsx("code",{className:"text-xs text-bambu-green font-mono break-all",children:n})]}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:"Select a Spoolman spool to link:"}),c?s.jsx("div",{className:"flex justify-center py-8",children:s.jsx(dt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):l&&l.length>0?s.jsx("div",{className:"max-h-64 overflow-y-auto space-y-2",children:l.map(f=>s.jsx("button",{onClick:()=>o(f.id),className:`w-full p-3 rounded-lg border text-left transition-colors ${a===f.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:[f.filament_color_hex&&s.jsx("span",{className:"w-4 h-4 rounded-full border border-white/20 flex-shrink-0",style:{backgroundColor:`#${f.filament_color_hex}`}}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-white font-medium truncate",children:f.filament_name||"Unknown filament"}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[f.filament_material||"Unknown",f.remaining_weight!==null&&` - ${Math.round(f.remaining_weight)}g`,f.location&&` - ${f.location}`]})]}),a===f.id&&s.jsx(Ya,{className:"w-4 h-4 text-bambu-green flex-shrink-0"})]})},f.id))}):s.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[s.jsx("p",{children:"No unlinked spools found in Spoolman."}),s.jsx("p",{className:"text-xs mt-1",children:"All spools are already linked to AMS trays."})]})]})]}),s.jsxs("div",{className:"flex justify-end gap-2 p-4 border-t border-bambu-dark-tertiary",children:[s.jsx(we,{variant:"secondary",onClick:e,children:"Cancel"}),s.jsx(we,{onClick:d,disabled:!a||u.isPending,children:u.isPending?s.jsxs(s.Fragment,{children:[s.jsx(dt,{className:"w-4 h-4 animate-spin"}),"Linking..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Ol,{className:"w-4 h-4"}),"Link Spool"]})})]}),u.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:u.error.message})]})]})}function zke(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 eH(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 Bke=["PLA","PETG","ABS","ASA","TPU","PC","PA","NYLON","PVA","HIPS","PP","PET"];function tH(t){const e=t.replace(/@.+$/,"").trim(),n=e.toUpperCase();for(const i of Bke){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 bC(t){return!t.startsWith("GF")&&!t.startsWith("P1")}const $ke={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"},Hke=[{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"}],Vke=[{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 Gke(t){const e=t.toLowerCase().trim();return $ke[e]||null}function Wke({isOpen:t,onClose:e,printerId:n,slotInfo:r,nozzleDiameter:i="0.4",onSuccess:a}){const[o,l]=w.useState(""),[c,u]=w.useState(null),[d,f]=w.useState(""),[m,p]=w.useState(""),[x,y]=w.useState(""),[b,v]=w.useState(!1),[N,S]=w.useState(!1),{data:T,isLoading:E}=ut({queryKey:["cloudSettings"],queryFn:()=>he.getCloudSettings(),enabled:t}),{data:C,isLoading:A}=ut({queryKey:["kprofiles",n,i],queryFn:()=>he.getKProfiles(n,i),enabled:t&&!!n}),O=pt({mutationFn:async()=>{if(!o)throw new Error("No filament preset selected");const Q=T?.filament.find(me=>me.setting_id===o);if(!Q)throw new Error("Selected preset not found");const ee=tH(Q.name),re=c?.slot_id??-1,z=d||r.trayColor?.slice(0,6)||"FFFFFF",G=Q.name.replace(/@.+$/,"").trim();let ae=eH(o);if(!o.startsWith("GFS"))try{const me=await he.getCloudSettingDetail(o);me.filament_id?ae=me.filament_id:me.base_id&&(ae=eH(me.base_id),console.log(`Derived tray_info_idx from base_id: ${me.base_id} -> ${ae}`))}catch(me){console.warn("Failed to fetch preset detail for filament_id:",me)}let se=190,ue=230;const pe=ee.material.toUpperCase();pe.includes("PLA")?(se=190,ue=230):pe.includes("PETG")?(se=220,ue=260):pe.includes("ABS")||pe.includes("ASA")?(se=240,ue=280):pe.includes("TPU")?(se=200,ue=240):pe.includes("PC")?(se=260,ue=300):(pe.includes("PA")||pe.includes("NYLON"))&&(se=250,ue=290);const ce=c?.k_value?parseFloat(c.k_value):0,Me=await he.configureAmsSlot(n,r.amsId,r.trayId,{tray_info_idx:ae,tray_type:ee.material||"PLA",tray_sub_brands:G,tray_color:z+"FF",nozzle_temp_min:se,nozzle_temp_max:ue,cali_idx:re,nozzle_diameter:i,setting_id:o,kprofile_filament_id:c?.filament_id,kprofile_setting_id:c?.setting_id||void 0,k_value:ce});try{await he.saveSlotPreset(n,r.amsId,r.trayId,o,G)}catch(me){console.warn("Failed to save slot preset mapping:",me)}return Me},onSuccess:()=>{v(!0),a?.(),setTimeout(()=>{v(!1),e()},1500)}}),k=pt({mutationFn:async()=>he.resetAmsSlot(n,r.amsId,r.trayId),onSuccess:()=>{v(!0),a?.(),setTimeout(()=>{v(!1),e()},1500)}}),R=w.useMemo(()=>{if(!T?.filament)return[];const Q=x.toLowerCase();return T.filament.filter(ee=>Q?ee.name.toLowerCase().includes(Q):!0).sort((ee,re)=>{const z=bC(ee.setting_id),G=bC(re.setting_id);return z&&!G?-1:!z&&G?1:ee.name.localeCompare(re.name)})},[T?.filament,x]),F=w.useMemo(()=>{if(!o||!T?.filament)return null;const Q=T.filament.find(z=>z.setting_id===o);if(!Q)return null;let ee=Q.name.replace(/@.+$/,"").trim();ee.startsWith("# ")&&(ee=ee.slice(2).trim());const re=tH(ee);return{fullName:ee,material:re.material,brand:re.brand}},[o,T?.filament]),L=F?.fullName||"",K=w.useMemo(()=>{if(!C?.profiles||!F)return[];const{fullName:Q,material:ee,brand:re}=F,z=Q.toUpperCase(),G=ee.toUpperCase(),ae=re.toUpperCase();if(!G||G.length<2)return[];const se=C.profiles.filter(pe=>{const ce=pe.name.toUpperCase();if(ae)return!(!ce.includes(ae)||!ce.includes(G));if(ce.includes(z)||ce.includes(G))return!0;const me={NYLON:["PA","PA-CF","PA6"],PA:["NYLON"]}[G]||[];for(const Ee of me)if(ce.includes(Ee))return!0;return!1}),ue=new Map;for(const pe of se){const ce=`${pe.name}|${pe.k_value}`,Me=ue.get(ce);Me?pe.extruder_id===1&&Me.extruder_id===0&&ue.set(ce,pe):ue.set(ce,pe)}return Array.from(ue.values())},[C?.profiles,F]);w.useEffect(()=>{if(t&&T?.filament){if(r.trayInfoIdx){const Q=T.filament.find(ee=>ee.setting_id===r.trayInfoIdx);Q&&l(Q.setting_id)}}else t||(l(""),u(null),f(""),p(""),y(""),v(!1))},[t,T?.filament,r.trayInfoIdx]),w.useEffect(()=>{K.length>0?u(K[0]):u(null)},[o,K]);const j=w.useCallback(Q=>{Q.key==="Escape"&&e()},[e]);if(w.useEffect(()=>{if(t)return document.addEventListener("keydown",j),()=>document.removeEventListener("keydown",j)},[t,j]),!t)return null;const W=E||A,Y=o&&!O.isPending,q=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(Bd,{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(zt,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"p-4 space-y-4 max-h-[60vh] overflow-y-auto",children:[b&&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(P2,{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:[zke(r.amsId,r.trayCount)," Slot ",r.trayId+1]}),r.traySubBrands&&s.jsxs("span",{className:"text-bambu-gray",children:["(",r.traySubBrands,")"]})]})]}),W?s.jsx("div",{className:"flex justify-center py-8",children:s.jsx(dt,{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=>y(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}),bC(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)",L&&s.jsxs("span",{className:"ml-2 text-xs text-bambu-blue",children:["Filtering for: ",L]})]}),K.length>0?s.jsxs("div",{className:"relative",children:[s.jsxs("select",{value:c?.name||"",onChange:Q=>{const ee=K.find(re=>re.name===Q.target.value);u(ee||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)"}),K.map(Q=>s.jsxs("option",{value:Q.name,children:[Q.name," (K=",Q.k_value,")"]},`${Q.name}-${Q.extruder_id}`))]}),s.jsx(Pi,{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:[Hke.map(Q=>s.jsx("button",{onClick:()=>{f(Q.hex),p(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:()=>S(!N),className:"w-7 h-7 rounded-md border-2 border-white/20 hover:border-white/40 flex items-center justify-center text-white/60 hover:text-white/80 transition-all text-xs",title:N?"Show less colors":"Show more colors",children:N?"−":"+"})]}),N&&s.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:Vke.map(Q=>s.jsx("button",{onClick:()=>{f(Q.hex),p(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:`#${q}`}}),s.jsx("input",{type:"text",placeholder:"Color name or hex (e.g., brown, FF8800)",value:m,onChange:Q=>{const ee=Q.target.value;p(ee);const re=Gke(ee);if(re)f(re);else{const z=ee.replace(/[^0-9A-Fa-f]/g,"").toUpperCase();z.length===6?f(z):z.length===3&&f(z.split("").map(G=>G+G).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(""),p("")},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(we,{variant:"secondary",onClick:()=>k.mutate(),disabled:k.isPending||O.isPending,className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:k.isPending?s.jsxs(s.Fragment,{children:[s.jsx(dt,{className:"w-4 h-4 animate-spin"}),"Resetting..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Zf,{className:"w-4 h-4"}),"Reset Slot"]})}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(we,{variant:"secondary",onClick:e,children:"Cancel"}),s.jsx(we,{onClick:()=>O.mutate(),disabled:!Y,children:O.isPending?s.jsxs(s.Fragment,{children:[s.jsx(dt,{className:"w-4 h-4 animate-spin"}),"Configuring..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Bd,{className:"w-4 h-4"}),"Configure Slot"]})})]})]}),(O.isError||k.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:O.error?.message||k.error?.message})]})]})}function qke({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 nH=({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"})]}),rH={"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"},Kke={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 yC(t){if(!t)return null;if(rH[t])return rH[t];const e=t.split("-");if(e.length<2)return null;const n=e[1];return Kke[n]||null}function vC(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,m=r/255;i===d?l=((f-m)/u+(f<m?6:0))/6:i===f?l=((m-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 _C(t){return(t??.02).toFixed(3)}function iH({side:t}){const{mode:e}=nh(),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 aH({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 Xke({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 Yke({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 Qke({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 Zke({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 Jke({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 wC({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 sH({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=aH:a<=l?d=Xke:d=Yke,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 oH({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=Qke):t<=o?(l="#d4a017",c="Fair",u=Zke):(l="#c62828",c="Bad",u=Jke),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 Gu(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 lH(t){return t>50?"#00ae42":t>=15?"#f59e0b":"#ef4444"}function eje(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function tje(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 nje(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 rje(t){return t==null?{label:"",color:"text-bambu-gray",bars:0}:t>=-50?{label:"Excellent",color:"text-bambu-green",bars:4}:t>=-60?{label:"Good",color:"text-bambu-green",bars:3}:t>=-70?{label:"Fair",color:"text-yellow-400",bars:2}:t>=-80?{label:"Weak",color:"text-orange-400",bars:1}:{label:"Very weak",color:"text-red-400",bars:1}}function SC(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 ije({url:t,printName:e}){const[n,r]=w.useState(!1),[i,a]=w.useState(!1),[o,l]=w.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&&n?"cursor-pointer":""}`,onClick:()=>t&&n&&l(!0),children:t&&!i?s.jsxs(s.Fragment,{children:[s.jsx("img",{src:t,alt:"Print preview",className:`w-full h-full object-cover ${n?"block":"hidden"}`,onLoad:()=>r(!0),onError:()=>a(!0)}),!n&&s.jsx(zs,{className:"w-8 h-8 text-bambu-gray"})]}):s.jsx(zs,{className:"w-8 h-8 text-bambu-gray"})}),o&&t&&s.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-8",onClick:()=>l(!1),children:s.jsxs("div",{className:"relative max-w-2xl max-h-full",children:[s.jsx("img",{src:t,alt:"Print preview",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 aje({printers:t}){const e=on(),n=w.useMemo(()=>{let i=0,a=0,o=0,l=0;return t?.forEach(c=>{const u=e.getQueryData(["printerStatus",c.id]);u===void 0?l++:u.connected?u.state==="RUNNING"?i++:a++:o++}),{printing:i,idle:a,offline:o,loading:l,total:t?.length||0}},[t,e]),[,r]=w.useState(0);return w.useEffect(()=>{let i=!1;const a=e.getQueryCache().subscribe(()=>{i||(i=!0,requestAnimationFrame(()=>{r(o=>o+1),i=!1}))});return()=>a()},[e]),t?.length?s.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[n.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:n.printing})," printing"]})]}),n.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:n.idle})," idle"]})]}),n.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:n.offline})," offline"]})]})]}):null}function cH(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 uH({printer:t,hideIfDisconnected:e,maintenanceInfo:n,viewMode:r="expanded",cardSize:i=2,amsThresholds:a,spoolmanEnabled:o=!1,hasUnlinkedSpools:l=!1,timeFormat:c="system",cameraViewMode:u="window",onOpenEmbeddedCamera:d}){const f=on(),m=hl(),{showToast:p}=Vn(),[x,y]=w.useState(!1),[b,v]=w.useState(!1),[N,S]=w.useState(!0),[T,E]=w.useState(!1),[C,A]=w.useState(!1),[O,k]=w.useState(!1),[R,F]=w.useState(!1),[L,K]=w.useState(!1),[j,W]=w.useState(!1),[Y,q]=w.useState(!1),[Q,ee]=w.useState(!1),[re,z]=w.useState(!1),[G,ae]=w.useState(!1),[se,ue]=w.useState(null),[pe,ce]=w.useState(null),[Me,me]=w.useState(null),[Ee,fe]=w.useState(!1),[le,Be]=w.useState(null),[V,$]=w.useState(!1),[X,U]=w.useState(!1),[B,oe]=w.useState(null),[Te,je]=w.useState(!1),[Ce,H]=w.useState(!1),{data:D}=ut({queryKey:["printerStatus",t.id],queryFn:()=>he.getPrinterStatus(t.id),refetchInterval:3e4}),{data:Z}=ut({queryKey:["firmwareUpdate",t.id],queryFn:()=>B1.checkPrinterUpdate(t.id),staleTime:300*1e3,refetchInterval:300*1e3}),xe=w.useMemo(()=>{const De=new Set;if(D?.ams)for(const ht of D.ams)for(const Mt of ht.tray||[])Mt.tray_info_idx&&De.add(Mt.tray_info_idx);return D?.vt_tray?.tray_info_idx&&De.add(D.vt_tray.tray_info_idx),Array.from(De)},[D?.ams,D?.vt_tray]),{data:Ne}=ut({queryKey:["filamentInfo",xe],queryFn:()=>he.getFilamentInfo(xe),enabled:xe.length>0,staleTime:300*1e3}),{data:ve}=ut({queryKey:["slotPresets",t.id],queryFn:()=>he.getSlotPresets(t.id),staleTime:120*1e3}),[$e,Le]=w.useState(null);w.useEffect(()=>{D?.wifi_signal!=null&&Le(D.wifi_signal)},[D?.wifi_signal]);const qe=D?.wifi_signal??$e,Ke=w.useRef(void 0);w.useEffect(()=>{D?.connected!==void 0&&(Ke.current=D.connected)},[D?.connected]);const Ye=D?.connected??Ke.current,ie=w.useRef({});w.useEffect(()=>{D?.ams_extruder_map&&Object.keys(D.ams_extruder_map).length>0&&(ie.current=D.ams_extruder_map)},[D?.ams_extruder_map]);const te=D?.ams_extruder_map&&Object.keys(D.ams_extruder_map).length>0?D.ams_extruder_map:ie.current,Se=w.useRef([]);w.useEffect(()=>{D?.ams&&D.ams.length>0&&(Se.current=D.ams)},[D?.ams]);const ze=D?.ams&&D.ams.length>0?D.ams:Se.current,nt=w.useRef(255),ne=D?.tray_now;ne!==void 0&&ne!==255&&(nt.current=ne);const Pe=ne===void 0||ne===255?nt.current:ne,{data:be}=ut({queryKey:["smartPlugByPrinter",t.id],queryFn:()=>he.getSmartPlugByPrinter(t.id)}),{data:Oe}=ut({queryKey:["smartPlugStatus",be?.id],queryFn:()=>be?he.getSmartPlugStatus(be.id):null,enabled:!!be,refetchInterval:1e4}),{data:Ue}=ut({queryKey:["queue",t.id,"pending"],queryFn:()=>he.getQueue(t.id,"pending")}),Ae=Ue?.length||0,{data:Je}=ut({queryKey:["archives",t.id,"last"],queryFn:()=>he.getArchives(t.id,1,0),enabled:D?.connected&&D?.state!=="RUNNING"}),gt=Je?.[0],Pt=e&&Ye===!1,Ot=pt({mutationFn:De=>he.deletePrinter(t.id,De.deleteArchives),onSuccess:()=>{f.invalidateQueries({queryKey:["printers"]}),f.invalidateQueries({queryKey:["archives"]}),f.invalidateQueries({queryKey:["maintenanceOverview"]})}}),cn=pt({mutationFn:()=>he.connectPrinter(t.id),onSuccess:()=>{f.invalidateQueries({queryKey:["printerStatus",t.id]})}}),It=pt({mutationFn:De=>be?he.controlSmartPlug(be.id,De):Promise.reject("No plug"),onSuccess:()=>{f.invalidateQueries({queryKey:["smartPlugStatus",be?.id]})}}),_n=pt({mutationFn:De=>be?he.updateSmartPlug(be.id,{auto_off:De}):Promise.reject("No plug"),onSuccess:()=>{f.invalidateQueries({queryKey:["smartPlugByPrinter",t.id]}),f.invalidateQueries({queryKey:["smart-plugs"]})}}),bt=pt({mutationFn:()=>he.stopPrint(t.id),onSuccess:()=>{p("Print stopped"),f.invalidateQueries({queryKey:["printerStatus",t.id]})},onError:De=>p(De.message||"Failed to stop print","error")}),Gt=pt({mutationFn:()=>he.pausePrint(t.id),onSuccess:()=>{p("Print paused"),f.invalidateQueries({queryKey:["printerStatus",t.id]})},onError:De=>p(De.message||"Failed to pause print","error")}),ln=pt({mutationFn:()=>he.resumePrint(t.id),onSuccess:()=>{p("Print resumed"),f.invalidateQueries({queryKey:["printerStatus",t.id]})},onError:De=>p(De.message||"Failed to resume print","error")}),Tt=pt({mutationFn:De=>he.setChamberLight(t.id,De),onMutate:async De=>{await f.cancelQueries({queryKey:["printerStatus",t.id]});const ht=f.getQueryData(["printerStatus",t.id]);return f.setQueryData(["printerStatus",t.id],Mt=>({...Mt,chamber_light:De})),{previousStatus:ht}},onSuccess:(De,ht)=>{p(`Chamber light ${ht?"on":"off"}`)},onError:(De,ht,Mt)=>{Mt?.previousStatus&&f.setQueryData(["printerStatus",t.id],Mt.previousStatus),p(De.message||"Failed to control chamber light","error")}}),Rr=pt({mutationFn:De=>he.updatePrinter(t.id,{plate_detection_enabled:De}),onSuccess:()=>{f.invalidateQueries({queryKey:["printers"]}),p(Rr.variables?"Plate check enabled":"Plate check disabled")},onError:De=>p(De.message||"Failed to update setting","error")}),Xr=(D?.state==="RUNNING"||D?.state==="PAUSE"||D?.state==="PAUSED")&&(D?.printable_objects_count??0)>=2,{data:An,refetch:sn}=ut({queryKey:["printableObjects",t.id],queryFn:()=>he.getPrintableObjects(t.id),enabled:G||Xr,refetchInterval:G?5e3:Xr?3e4:!1}),Sr=pt({mutationFn:De=>he.skipObjects(t.id,De),onSuccess:De=>{p(De.message||"Objects skipped"),sn()},onError:De=>p(De.message||"Failed to skip objects","error")}),[si,Dr]=w.useState(null),_e=w.useRef(!1),Xe=w.useRef(null),ot=w.useRef(!1),ct=pt({mutationFn:({amsId:De,slotId:ht})=>he.refreshAmsSlot(t.id,De,ht),onMutate:({amsId:De,slotId:ht})=>{Xe.current&&clearTimeout(Xe.current),_e.current=!1,ot.current=!1,Dr({amsId:De,slotId:ht}),setTimeout(()=>{ot.current=!0},2e3),Xe.current=setTimeout(()=>{Dr(null)},3e4)},onSuccess:De=>{p(De.message||"RFID re-read initiated")},onError:De=>{p(De.message||"Failed to re-read RFID","error"),Xe.current&&clearTimeout(Xe.current),Dr(null)}}),[rt,Rt]=w.useState(null),[de,Re]=w.useState(null),Ve=async()=>{try{const De=await he.getPlateReferences(t.id);Rt(De)}catch{}},He=()=>{Rr.mutate(!t.plate_detection_enabled)},Fe=async()=>{$(!0),Be(null);const De=D?.chamber_light===!1;H(De),De&&(await he.setChamberLight(t.id,!0),await new Promise(ht=>setTimeout(ht,2500)));try{const ht=await he.checkPlateEmpty(t.id,{includeDebugImage:!0});Be(ht),Ve()}catch(ht){p(ht instanceof Error?ht.message:"Failed to check plate","error"),De&&(await he.setChamberLight(t.id,!1),H(!1))}finally{$(!1)}},mt=w.useCallback(async()=>{Be(null),Ce&&(await he.setChamberLight(t.id,!1),H(!1))},[Ce,t.id]),St=async De=>{U(!0);try{const ht=await he.calibratePlateDetection(t.id,{label:De});if(ht.success){p(ht.message||"Calibration saved!","success"),Ve();const Mt=await he.checkPlateEmpty(t.id,{includeDebugImage:!0});Be(Mt)}else p(ht.message||"Calibration failed","error")}catch(ht){p(ht instanceof Error?ht.message:"Calibration failed","error")}finally{U(!1)}},kt=async(De,ht)=>{try{await he.updatePlateReferenceLabel(t.id,De,ht),Re(null),Ve()}catch(Mt){p(Mt instanceof Error?Mt.message:"Failed to update label","error")}},xt=async De=>{try{await he.deletePlateReference(t.id,De),p("Reference deleted","success"),Ve();const ht=await he.checkPlateEmpty(t.id,{includeDebugImage:!0});Be(ht)}catch(ht){p(ht instanceof Error?ht.message:"Failed to delete reference","error")}},$t=async()=>{if(B){je(!0);try{await he.updatePrinter(t.id,{plate_detection_roi:B}),p("Detection area saved","success"),oe(null);const De=await he.checkPlateEmpty(t.id,{includeDebugImage:!0});Be(De)}catch(De){p(De instanceof Error?De.message:"Failed to save detection area","error")}finally{je(!1)}}};w.useEffect(()=>{const De=ht=>{ht.key==="Escape"&&le&&mt()};return window.addEventListener("keydown",De),()=>window.removeEventListener("keydown",De)},[le,mt]);const jt=w.useRef(null);w.useEffect(()=>{if(!si)return;const De=D?.ams_status_main??0;return De!==0&&(_e.current=!0,jt.current&&(clearTimeout(jt.current),jt.current=null)),_e.current&&De===0&&(ot.current?(Xe.current&&clearTimeout(Xe.current),Dr(null)):jt.current||(jt.current=setTimeout(()=>{Xe.current&&clearTimeout(Xe.current),Dr(null)},2e3))),()=>{jt.current&&clearTimeout(jt.current)}},[D?.ams_status_main,si]);const[wt,Qt]=w.useState(null);if(Pt)return null;const Kt=()=>{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"}},fn=()=>{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"}},ye=()=>{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(Nt,{className:"relative",children:[s.jsxs(Et,{className:i>=3?"p-5":"",children:[s.jsxs("div",{className:ye(),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:nje(t.model),alt:t.model||"Printer",className:`object-contain rounded-lg bg-bambu-dark flex-shrink-0 ${Kt()}`}),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 ${fn()}`,children:t.name}),r==="compact"&&s.jsx("div",{className:`w-2 h-2 rounded-full flex-shrink-0 ${D?.connected?"bg-status-ok":"bg-status-error"}`,title:D?.connected?"Connected":"Offline"})]}),s.jsxs("p",{className:"text-sm text-bambu-gray",children:[t.model||"Unknown Model",r==="expanded"&&D?.nozzles&&D.nozzles[0]?.nozzle_diameter&&s.jsxs("span",{className:"ml-1.5 text-bambu-gray",title:D.nozzles[0].nozzle_type||"Nozzle",children:["• ",D.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(Kn,{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(we,{variant:"ghost",size:"sm",onClick:()=>y(!x),children:s.jsx(Cd,{className:"w-4 h-4"})}),x&&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 hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:()=>{E(!0),y(!1)},children:[s.jsx(ia,{className:"w-4 h-4"}),"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:()=>{cn.mutate(),y(!1)},children:[s.jsx(xr,{className:"w-4 h-4"}),"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:()=>{k(!0),y(!1)},children:[s.jsx(mq,{className:"w-4 h-4"}),"MQTT Debug"]}),s.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm text-red-400 hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:()=>{v(!0),y(!1)},children:[s.jsx(un,{className:"w-4 h-4"}),"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 ${D?.connected?"bg-status-ok/20 text-status-ok":"bg-status-error/20 text-status-error"}`,children:[D?.connected?s.jsx(Ug,{className:"w-3 h-3"}):s.jsx(mD,{className:"w-3 h-3"}),D?.connected?"Connected":"Offline"]}),D?.connected&&qe!=null&&s.jsxs("span",{className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs ${qe>=-50||qe>=-60?"bg-status-ok/20 text-status-ok":qe>=-70?"bg-status-warning/20 text-status-warning":qe>=-80?"bg-orange-500/20 text-orange-600":"bg-status-error/20 text-status-error"}`,title:`WiFi: ${qe} dBm - ${rje(qe).label}`,children:[s.jsx(whe,{className:"w-3 h-3"}),qe,"dBm"]}),D?.connected&&(()=>{const De=D.hms_errors?$fe(D.hms_errors):[];return s.jsxs("button",{onClick:()=>W(!0),className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs cursor-pointer hover:opacity-80 transition-opacity ${De.length>0?De.some(ht=>ht.severity<=2)?"bg-status-error/20 text-status-error":"bg-status-warning/20 text-status-warning":"bg-status-ok/20 text-status-ok"}`,title:"Click to view HMS errors",children:[s.jsx(yn,{className:"w-3 h-3"}),De.length>0?De.length:"OK"]})})(),n&&s.jsxs("button",{onClick:()=>m("/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`:"All maintenance up to date - Click to view",children:[s.jsx($d,{className:"w-3 h-3"}),n.due_count>0||n.warning_count>0?n.due_count+n.warning_count:"OK"]}),Ae>0&&s.jsxs("button",{onClick:()=>m("/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:`${Ae} print${Ae>1?"s":""} in queue`,children:[s.jsx(cl,{className:"w-3 h-3"}),Ae]}),Z?.update_available&&s.jsxs("button",{onClick:()=>fe(!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:`Firmware update available: ${Z.current_version} → ${Z.latest_version}`,children:[s.jsx($r,{className:"w-3 h-3"}),"Update"]})]})]}),b&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:s.jsx(Nt,{className:"w-full max-w-md mx-4",children:s.jsxs(Et,{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(yn,{className:"w-5 h-5 text-red-400"})}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-semibold text-white",children:"Delete Printer"}),s.jsxs("p",{className:"text-sm text-bambu-gray mt-1",children:['Are you sure you want to delete "',t.name,'"? This will remove all connection settings.']})]})]}),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:N,onChange:De=>S(De.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:"Delete print archives"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-0.5",children:N?"All print history for this printer will be permanently deleted.":"Print history will be kept but no longer associated with this printer."})]})]})}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(we,{variant:"secondary",onClick:()=>{v(!1),S(!0)},children:"Cancel"}),s.jsx(we,{variant:"danger",onClick:()=>{Ot.mutate({deleteArchives:N}),v(!1),S(!0)},children:"Delete"})]})]})})}),D?.connected&&s.jsxs(s.Fragment,{children:[r==="compact"?s.jsx("div",{className:"mt-2",children:D.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:`${D.progress||0}%`}})}),s.jsxs("span",{className:"text-xs text-white",children:[Math.round(D.progress||0),"%"]})]}):s.jsx("p",{className:"text-xs text-bambu-gray",children:cH(D.state,D.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:()=>ae(!0),disabled:!(D.state==="RUNNING"||D.state==="PAUSE"||D.state==="PAUSED")||(D.printable_objects_count??0)<2,className:`absolute top-2 right-2 p-1.5 rounded transition-colors z-10 ${(D.state==="RUNNING"||D.state==="PAUSE"||D.state==="PAUSED")&&(D.printable_objects_count??0)>=2?"text-bambu-gray hover:text-white hover:bg-white/10":"text-bambu-gray/30 cursor-not-allowed"}`,title:D.state==="RUNNING"||D.state==="PAUSE"||D.state==="PAUSED"?(D.printable_objects_count??0)>=2?"Skip objects":"Skip objects (requires 2+ objects)":"Skip objects (only while printing)",children:[s.jsx(nH,{className:"w-4 h-4"}),An&&An.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:An.skipped_count})]}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx(ije,{url:D.state==="RUNNING"?D.cover_url:null,printName:D.state==="RUNNING"&&(D.subtask_name||D.current_print)||void 0}),s.jsx("div",{className:"flex-1 min-w-0",children:D.current_print&&D.state==="RUNNING"?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-sm text-bambu-gray mb-1",children:D.stg_cur_name||"Printing"}),s.jsx("p",{className:"text-white text-sm mb-2 truncate",children:D.subtask_name||D.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:`${D.progress||0}%`}})}),s.jsxs("span",{className:"text-white",children:[Math.round(D.progress||0),"%"]})]}),s.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-bambu-gray",children:[D.remaining_time!=null&&D.remaining_time>0&&s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(Kn,{className:"w-3 h-3"}),eje(D.remaining_time*60)]}),s.jsxs("span",{className:"text-bambu-green font-medium",title:"Estimated completion time",children:["ETA ",tje(D.remaining_time,c)]})]}),D.layer_num!=null&&D.total_layers!=null&&D.total_layers>0&&s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(cl,{className:"w-3 h-3"}),D.layer_num,"/",D.total_layers]})]})]}):s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-sm text-bambu-gray mb-1",children:"Status"}),s.jsx("p",{className:"text-white text-sm mb-2",children:cH(D.state,D.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:"—"})]}),gt?s.jsxs("p",{className:"text-xs text-bambu-gray mt-2 truncate",title:gt.print_name||gt.filename,children:["Last: ",gt.print_name||gt.filename,gt.completed_at&&s.jsxs("span",{className:"ml-1 text-bambu-gray/60",children:["• ",sg(gt.completed_at,{month:"short",day:"numeric"})]})]}):s.jsx("p",{className:"text-xs text-bambu-gray mt-2",children:"Ready to print"})]})})]})]}),D.state!=="RUNNING"&&s.jsx(Wfe,{printerId:t.id})]}),D.temperatures&&r==="expanded"&&(()=>{const De=D.temperatures.nozzle_heating||D.temperatures.nozzle_2_heating||!1,ht=D.temperatures.bed_heating||!1,Mt=D.temperatures.chamber_heating||!1,at=t.nozzle_count===2||D.temperatures.nozzle_2!==void 0,Xt=D.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(wC,{className:"w-3.5 h-3.5 mx-auto mb-0.5",color:"text-orange-400",isHeating:De}),D.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(D.temperatures.nozzle||0),"° / ",Math.round(D.temperatures.nozzle_2||0),"°"]})]}):s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-[9px] text-bambu-gray",children:"Nozzle"}),s.jsxs("p",{className:"text-[11px] text-white",children:[Math.round(D.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(wC,{className:"w-3.5 h-3.5 mx-auto mb-0.5",color:"text-blue-400",isHeating:ht}),s.jsx("p",{className:"text-[9px] text-bambu-gray",children:"Bed"}),s.jsxs("p",{className:"text-[11px] text-white",children:[Math.round(D.temperatures.bed||0),"°C"]})]}),D.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(wC,{className:"w-3.5 h-3.5 mx-auto mb-0.5",color:"text-green-400",isHeating:Mt}),s.jsx("p",{className:"text-[9px] text-bambu-gray",children:"Chamber"}),s.jsxs("p",{className:"text-[11px] text-white",children:[Math.round(D.temperatures.chamber||0),"°C"]})]}),at&&s.jsxs("div",{className:"text-center px-2 py-1.5 bg-bambu-dark rounded-lg",title:`Active: ${Xt==="L"?"Left":"Right"} nozzle`,children:[s.jsx("p",{className:`text-[11px] font-bold ${Xt==="L"?"text-amber-400":"text-gray-500"}`,children:"L"}),s.jsx("p",{className:"text-[9px] text-bambu-gray",children:"Nozzle"}),s.jsx("p",{className:`text-[11px] font-bold ${Xt==="R"?"text-amber-400":"text-gray-500"}`,children:"R"})]})]})})(),r==="expanded"&&(()=>{const De=D.state==="RUNNING",ht=D.state==="PAUSED"||D.state==="PAUSE",Mt=De||ht,at=bt.isPending||Gt.isPending||ln.isPending,Xt=D.cooling_fan_speed,Yt=D.big_fan1_speed,rn=D.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:"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 ${Xt&&Xt>0?"bg-cyan-500/10":"bg-bambu-dark"}`,title:"Part Cooling Fan",children:[s.jsx(rq,{className:`w-3.5 h-3.5 ${Xt&&Xt>0?"text-cyan-400":"text-bambu-gray/50"}`}),s.jsxs("span",{className:`text-[10px] ${Xt&&Xt>0?"text-cyan-400":"text-bambu-gray/50"}`,children:[Xt??0,"%"]})]}),s.jsxs("div",{className:`flex items-center gap-1 px-1.5 py-1 rounded ${Yt&&Yt>0?"bg-blue-500/10":"bg-bambu-dark"}`,title:"Auxiliary Fan",children:[s.jsx(gq,{className:`w-3.5 h-3.5 ${Yt&&Yt>0?"text-blue-400":"text-bambu-gray/50"}`}),s.jsxs("span",{className:`text-[10px] ${Yt&&Yt>0?"text-blue-400":"text-bambu-gray/50"}`,children:[Yt??0,"%"]})]}),s.jsxs("div",{className:`flex items-center gap-1 px-1.5 py-1 rounded ${rn&&rn>0?"bg-green-500/10":"bg-bambu-dark"}`,title:"Chamber Fan",children:[s.jsx(ice,{className:`w-3.5 h-3.5 ${rn&&rn>0?"text-green-400":"text-bambu-gray/50"}`}),s.jsxs("span",{className:`text-[10px] ${rn&&rn>0?"text-green-400":"text-bambu-gray/50"}`,children:[rn??0,"%"]})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("button",{onClick:()=>q(!0),disabled:!Mt||at,className:`
  77. flex items-center justify-center gap-1 px-3 py-1.5 rounded-lg text-xs font-medium
  78. transition-colors
  79. ${Mt?"bg-red-500/20 text-red-400 hover:bg-red-500/30":"bg-bambu-dark text-bambu-gray/50 cursor-not-allowed"}
  80. `,title:"Stop print",children:[s.jsx(Do,{className:"w-3 h-3"}),"Stop"]}),s.jsxs("button",{onClick:()=>ht?z(!0):ee(!0),disabled:!Mt||at,className:`
  81. flex items-center justify-center gap-1 px-3 py-1.5 rounded-lg text-xs font-medium
  82. transition-colors
  83. ${Mt?ht?"bg-bambu-green/20 text-bambu-green hover:bg-bambu-green/30":"bg-yellow-500/20 text-yellow-400 hover:bg-yellow-500/30":"bg-bambu-dark text-bambu-gray/50 cursor-not-allowed"}
  84. `,title:ht?"Resume print":"Pause print",children:[ht?s.jsx(Po,{className:"w-3 h-3"}):s.jsx(hD,{className:"w-3 h-3"}),ht?"Resume":"Pause"]})]})]})]})})(),ze&&ze.length>0&&r==="expanded"&&(()=>{const De=ze.filter(at=>at.tray.length>1),ht=ze.filter(at=>at.tray.length===1),Mt=t.nozzle_count===2||D?.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:"Filaments"}),s.jsx("div",{className:"flex-1 h-px bg-bambu-dark-tertiary/30"})]}),s.jsxs("div",{className:"space-y-3",children:[De.length>0&&s.jsx("div",{className:"grid grid-cols-2 gap-3",children:De.map(at=>{const Xt=te[String(at.id)],Yt=at.id>=128?at.id-128:at.id,rn=Xt!==void 0?Xt:Yt,sr=rn===1,kn=rn===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:Gu(at.id,at.tray.length)}),Mt&&(sr||kn)&&s.jsx(iH,{side:sr?"L":"R"})]}),(at.humidity!=null||at.temp!=null)&&s.jsxs("div",{className:"flex items-center gap-1.5",children:[at.humidity!=null&&s.jsx(sH,{humidity:at.humidity,goodThreshold:a?.humidityGood,fairThreshold:a?.humidityFair,onClick:()=>ue({amsId:at.id,amsLabel:Gu(at.id,at.tray.length),mode:"humidity"}),compact:!0}),at.temp!=null&&s.jsx(oH,{temp:at.temp,goodThreshold:a?.tempGood,fairThreshold:a?.tempFair,onClick:()=>ue({amsId:at.id,amsLabel:Gu(at.id,at.tray.length),mode:"temperature"}),compact:!0})]})]}),s.jsx("div",{className:"grid grid-cols-4 gap-1.5",children:[0,1,2,3].map(Wt=>{const en=at.tray[Wt]||at.tray.find(Hi=>Hi.id===Wt),or=en?.tray_type&&en.remain>=0,Or=!en?.tray_type,Ua=at.id*4+Wt,Es=Pe===Ua,am=en?.tray_info_idx?Ne?.[en.tray_info_idx]:null,pl=ve?.[Ua],sa=en?.tray_type?{vendor:SC(en)?"Bambu Lab":"Generic",profile:am?.name||pl?.preset_name||en.tray_sub_brands||en.tray_type,colorName:yC(en.tray_id_name)||vC(en.tray_color),colorHex:en.tray_color||null,kFactor:_C(en.k),fillLevel:or?en.remain:null,trayUuid:en.tray_uuid||null}:null,tc=si?.amsId===at.id&&si?.slotId===Wt,dh=s.jsxs("div",{className:`bg-bambu-dark-tertiary rounded p-1 text-center ${Or?"opacity-50":""} ${Es?"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:en?.tray_color?`#${en.tray_color}`:en?.tray_type?"#333":"transparent",borderColor:Or?"#666":"rgba(255,255,255,0.1)",borderStyle:Or?"dashed":"solid"}}),s.jsx("div",{className:"text-[9px] text-white font-bold truncate",children:en?.tray_type||"—"}),s.jsx("div",{className:"mt-1 h-1.5 bg-black/30 rounded-full overflow-hidden",children:or&&en?s.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${en.remain}%`,backgroundColor:lH(en.remain)}}):en?.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:[tc&&s.jsx("div",{className:"absolute inset-0 bg-bambu-dark-tertiary/80 rounded flex items-center justify-center z-20",children:s.jsx(xr,{className:"w-4 h-4 text-bambu-green animate-spin"})}),D?.state!=="RUNNING"&&s.jsx("button",{onClick:Hi=>{Hi.stopPropagation(),Qt(wt?.amsId===at.id&&wt?.slotId===Wt?null:{amsId:at.id,slotId:Wt})},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:"Slot options",children:s.jsx(Cd,{className:"w-2.5 h-2.5 text-bambu-gray"})}),D?.state!=="RUNNING"&&wt?.amsId===at.id&&wt?.slotId===Wt&&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 text-white hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:Hi=>{Hi.stopPropagation(),ct.mutate({amsId:at.id,slotId:Wt}),Qt(null)},disabled:tc,children:[s.jsx(xr,{className:`w-3 h-3 ${tc?"animate-spin":""}`}),"Re-read RFID"]})}),sa?s.jsx(xC,{data:sa,spoolman:{enabled:o,hasUnlinkedSpools:l,onLinkSpool:o&&sa.trayUuid?Hi=>{ce({trayUuid:Hi,trayInfo:{type:sa.profile,color:sa.colorHex||"",location:`${Gu(at.id,at.tray.length)} Slot ${Wt+1}`}})}:void 0},configureSlot:{enabled:!0,onConfigure:()=>me({amsId:at.id,trayId:Wt,trayCount:at.tray.length,trayType:en?.tray_type||void 0,trayColor:en?.tray_color||void 0,traySubBrands:en?.tray_sub_brands||void 0,trayInfoIdx:en?.tray_info_idx||void 0})},children:dh}):s.jsx(J$,{configureSlot:{enabled:!0,onConfigure:()=>me({amsId:at.id,trayId:Wt,trayCount:at.tray.length})},children:dh})]},Wt)})})]},at.id)})}),(ht.length>0||D.vt_tray&&D.vt_tray.tray_type)&&s.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[ht.map(at=>{const Xt=te[String(at.id)],Yt=at.id>=128?at.id-128:at.id,rn=Xt!==void 0?Xt:Yt,sr=rn===1,kn=rn===0,Wt=at.tray[0],en=Wt?.tray_type&&Wt.remain>=0,or=!Wt?.tray_type,Or=at.id*4+(Wt?.id??0),Ua=Pe===Or,Es=Wt?.tray_info_idx?Ne?.[Wt.tray_info_idx]:null,am=ve?.[Or],pl=Wt?.tray_type?{vendor:SC(Wt)?"Bambu Lab":"Generic",profile:Es?.name||am?.preset_name||Wt.tray_sub_brands||Wt.tray_type,colorName:yC(Wt.tray_id_name)||vC(Wt.tray_color),colorHex:Wt.tray_color||null,kFactor:_C(Wt.k),fillLevel:en?Wt.remain:null,trayUuid:Wt.tray_uuid||null}:null,sa=Wt?.id??0,tc=si?.amsId===at.id&&si?.slotId===sa,dh=s.jsxs("div",{className:`bg-bambu-dark-tertiary rounded p-1 text-center ${or?"opacity-50":""} ${Ua?"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:Wt?.tray_color?`#${Wt.tray_color}`:Wt?.tray_type?"#333":"transparent",borderColor:or?"#666":"rgba(255,255,255,0.1)",borderStyle:or?"dashed":"solid"}}),s.jsx("div",{className:"text-[9px] text-white font-bold truncate",children:Wt?.tray_type||"—"}),s.jsx("div",{className:"mt-1 h-1.5 bg-black/30 rounded-full overflow-hidden",children:en?s.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${Wt.remain}%`,backgroundColor:lH(Wt.remain)}}):Wt?.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:Gu(at.id,at.tray.length)}),Mt&&(sr||kn)&&s.jsx(iH,{side:sr?"L":"R"})]}),s.jsxs("div",{className:"flex gap-1.5",children:[s.jsxs("div",{className:"relative group flex-1",children:[tc&&s.jsx("div",{className:"absolute inset-0 bg-bambu-dark-tertiary/80 rounded flex items-center justify-center z-20",children:s.jsx(xr,{className:"w-4 h-4 text-bambu-green animate-spin"})}),D?.state!=="RUNNING"&&s.jsx("button",{onClick:Hi=>{Hi.stopPropagation(),Qt(wt?.amsId===at.id&&wt?.slotId===sa?null:{amsId:at.id,slotId:sa})},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:"Slot options",children:s.jsx(Cd,{className:"w-2.5 h-2.5 text-bambu-gray"})}),D?.state!=="RUNNING"&&wt?.amsId===at.id&&wt?.slotId===sa&&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 text-white hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:Hi=>{Hi.stopPropagation(),ct.mutate({amsId:at.id,slotId:sa}),Qt(null)},disabled:tc,children:[s.jsx(xr,{className:`w-3 h-3 ${tc?"animate-spin":""}`}),"Re-read RFID"]})}),pl?s.jsx(xC,{data:pl,spoolman:{enabled:o,hasUnlinkedSpools:l,onLinkSpool:o&&pl.trayUuid?Hi=>{ce({trayUuid:Hi,trayInfo:{type:pl.profile,color:pl.colorHex||"",location:Gu(at.id,at.tray.length)}})}:void 0},configureSlot:{enabled:!0,onConfigure:()=>me({amsId:at.id,trayId:sa,trayCount:at.tray.length,trayType:Wt?.tray_type||void 0,trayColor:Wt?.tray_color||void 0,traySubBrands:Wt?.tray_sub_brands||void 0,trayInfoIdx:Wt?.tray_info_idx||void 0})},children:dh}):s.jsx(J$,{configureSlot:{enabled:!0,onConfigure:()=>me({amsId:at.id,trayId:sa,trayCount:at.tray.length})},children:dh})]}),(at.humidity!=null||at.temp!=null)&&s.jsxs("div",{className:"flex flex-col justify-center gap-1 shrink-0",children:[at.temp!=null&&s.jsx(oH,{temp:at.temp,goodThreshold:a?.tempGood,fairThreshold:a?.tempFair,onClick:()=>ue({amsId:at.id,amsLabel:Gu(at.id,at.tray.length),mode:"temperature"}),compact:!0}),at.humidity!=null&&s.jsx(sH,{humidity:at.humidity,goodThreshold:a?.humidityGood,fairThreshold:a?.humidityFair,onClick:()=>ue({amsId:at.id,amsLabel:Gu(at.id,at.tray.length),mode:"humidity"}),compact:!0})]})]})]},at.id)}),D.vt_tray&&D.vt_tray.tray_type&&(()=>{const at=D.vt_tray,Xt=Pe===254,Yt=at.tray_info_idx?Ne?.[at.tray_info_idx]:null,rn=ve?.[1020],sr={vendor:SC(at)?"Bambu Lab":"Generic",profile:Yt?.name||rn?.preset_name||at.tray_sub_brands||at.tray_type||"Unknown",colorName:yC(at.tray_id_name)||vC(at.tray_color),colorHex:at.tray_color||null,kFactor:_C(at.k),fillLevel:null,trayUuid:at.tray_uuid||null},kn=s.jsxs("div",{className:`bg-bambu-dark-tertiary rounded p-1 text-center cursor-default ${Xt?"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:at.tray_color?`#${at.tray_color}`:"#333",borderColor:Xt?"var(--accent)":"rgba(255,255,255,0.1)"}}),s.jsx("div",{className:"text-[9px] text-white font-bold truncate",children:at.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:"External"})}),s.jsx(xC,{data:sr,spoolman:{enabled:o,hasUnlinkedSpools:l,onLinkSpool:o&&sr.trayUuid?Wt=>{ce({trayUuid:Wt,trayInfo:{type:sr.profile,color:sr.colorHex||"",location:"External Spool"}})}:void 0},configureSlot:{enabled:!0,onConfigure:()=>me({amsId:255,trayId:0,trayCount:1,trayType:at.tray_type||void 0,trayColor:at.tray_color||void 0,traySubBrands:at.tray_sub_brands||void 0,trayInfoIdx:at.tray_info_idx||void 0})},children:kn})]})})()]})]})]})})()]}),be&&r==="expanded"&&s.jsx("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(Pf,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),s.jsx("span",{className:"text-sm text-white truncate",children:be.name}),Oe&&s.jsxs("span",{className:`text-xs px-1.5 py-0.5 rounded flex-shrink-0 ${Oe.state==="ON"?"bg-bambu-green/20 text-bambu-green":Oe.state==="OFF"?"bg-red-500/20 text-red-400":"bg-bambu-gray/20 text-bambu-gray"}`,children:[Oe.state||"?",Oe.state==="ON"&&Oe.energy?.power!=null&&s.jsxs("span",{className:"text-yellow-400 ml-1.5",children:["· ",Oe.energy.power,"W"]})]})]}),s.jsx("div",{className:"flex-1"}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsxs("button",{onClick:()=>F(!0),disabled:It.isPending||Oe?.state==="ON",className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${Oe?.state==="ON"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:[s.jsx(gu,{className:"w-3 h-3"}),"On"]}),s.jsxs("button",{onClick:()=>K(!0),disabled:It.isPending||Oe?.state==="OFF",className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${Oe?.state==="OFF"?"bg-red-500/30 text-red-400":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:[s.jsx(H2,{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 ${be.auto_off_executed?"text-bambu-green":"text-bambu-gray"}`,children:be.auto_off_executed?"Auto-off done":"Auto-off"}),s.jsx("button",{onClick:()=>_n.mutate(!be.auto_off),disabled:_n.isPending||be.auto_off_executed,title:be.auto_off_executed?"Auto-off was executed - turn printer on to reset":"Auto power-off after print",className:`relative w-9 h-5 rounded-full transition-colors flex-shrink-0 ${be.auto_off_executed?"bg-bambu-green/50 cursor-not-allowed":be.auto_off?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,children:s.jsx("span",{className:`absolute top-[2px] left-[2px] w-4 h-4 bg-white rounded-full transition-transform ${be.auto_off||be.auto_off_executed?"translate-x-4":"translate-x-0"}`})})]})]})}),r==="expanded"&&s.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary flex items-center justify-between",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",children:[s.jsx(we,{variant:"secondary",size:"sm",onClick:()=>Tt.mutate(!D?.chamber_light),disabled:!D?.connected||Tt.isPending,title:D?.chamber_light?"Turn off chamber light":"Turn on chamber light",className:D?.chamber_light?"bg-yellow-500/20 hover:bg-yellow-500/30 border-yellow-500/30":"",children:s.jsx(qke,{on:D?.chamber_light??!1,className:"w-4 h-4"})}),s.jsx(we,{variant:"secondary",size:"sm",onClick:()=>{if(u==="embedded"&&d)d(t.id,t.name);else{const De=localStorage.getItem("cameraWindowState"),ht=De?JSON.parse(De):{width:640,height:400},Mt=[`width=${ht.width}`,`height=${ht.height}`,ht.left!==void 0?`left=${ht.left}`:"",ht.top!==void 0?`top=${ht.top}`:"","menubar=no,toolbar=no,location=no,status=no,noopener"].filter(Boolean).join(",");window.open(`/camera/${t.id}`,`camera-${t.id}`,Mt)}},disabled:!D?.connected,title:u==="embedded"?"Open camera overlay":"Open camera in new window",children:s.jsx(pD,{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(we,{variant:"secondary",size:"sm",onClick:He,disabled:!D?.connected||Rr.isPending,title:t.plate_detection_enabled?"Plate check enabled - Click to disable":"Plate check disabled - Click to enable",className:`!rounded-r-none !border-r-0 ${t.plate_detection_enabled?"!border-green-500 !text-green-400 hover:!bg-green-500/20":""}`,children:Rr.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(vw,{className:"w-4 h-4"})}),s.jsx(we,{variant:"secondary",size:"sm",onClick:Fe,disabled:!D?.connected||V,title:"Manage plate detection calibration",className:`!rounded-l-none !px-1.5 ${t.plate_detection_enabled?"!border-green-500 !text-green-400 hover:!bg-green-500/20":""}`,children:V?s.jsx(dt,{className:"w-3 h-3 animate-spin"}):s.jsx(Pi,{className:"w-3 h-3"})})]}),s.jsxs(we,{variant:"secondary",size:"sm",onClick:()=>A(!0),title:"Browse printer files",children:[s.jsx(F2,{className:"w-4 h-4"}),"Files"]})]})]})]}),C&&s.jsx(Dfe,{printerId:t.id,printerName:t.name,onClose:()=>A(!1)}),O&&s.jsx(zfe,{printerId:t.id,printerName:t.name,onClose:()=>k(!1)}),le&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:()=>mt(),children:s.jsxs("div",{className:"bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl shadow-2xl max-w-lg w-full",onClick:De=>De.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:[le.needs_calibration?s.jsx(vw,{className:"w-5 h-5 text-blue-500"}):le.is_empty?s.jsx(Fn,{className:"w-5 h-5 text-green-500"}):s.jsx(ta,{className:"w-5 h-5 text-yellow-500"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Build Plate Check"}),le.reference_count!==void 0&&le.max_references&&s.jsxs("span",{className:"text-xs text-bambu-gray bg-bambu-dark-tertiary px-2 py-1 rounded",children:[le.reference_count,"/",le.max_references," refs"]})]}),s.jsx("button",{onClick:()=>mt(),className:"p-1 text-bambu-gray hover:text-white rounded transition-colors",children:s.jsx(zt,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"p-4 space-y-4",children:[le.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:"Calibration Required"}),s.jsxs("p",{className:"text-sm text-bambu-gray mt-1",children:["Please ensure the build plate is ",s.jsx("strong",{children:"completely empty"}),", then click Calibrate."]})]}),s.jsxs("div",{className:"text-sm text-bambu-gray space-y-2",children:[s.jsx("p",{children:"Calibration captures a reference image of the empty plate. Future checks will compare against this reference to detect objects."}),s.jsxs("p",{children:[s.jsx("strong",{children:"Tip:"})," You can store up to 5 calibrations for different plates. The system automatically uses the best match when checking."]})]})]}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:`p-3 rounded-lg ${le.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 ${le.is_empty?"text-green-400":"text-yellow-400"}`,children:le.is_empty?"Plate appears empty":"Objects detected on plate"}),s.jsxs("p",{className:"text-sm text-bambu-gray mt-1",children:["Confidence: ",Math.round(le.confidence*100),"% | Difference: ",le.difference_percent.toFixed(1),"%"]})]}),le.debug_image_url&&s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:"Analysis preview:"}),s.jsx("img",{src:le.debug_image_url,alt:"Plate detection analysis",className:"w-full rounded-lg border border-bambu-dark-tertiary"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-2",children:"Green box = detection area, Red overlay = differences from calibration"})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:le.message})]}),rt&&rt.references.length>0&&s.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[s.jsxs("p",{className:"text-sm font-medium text-white mb-2",children:["Saved References (",rt.references.length,"/",rt.max_references,")"]}),s.jsx("div",{className:"grid grid-cols-5 gap-2",children:rt.references.map(De=>s.jsxs("div",{className:"relative group",children:[s.jsx("img",{src:he.getPlateReferenceThumbnailUrl(t.id,De.index),alt:De.label||`Reference ${De.index+1}`,className:"w-full aspect-video object-cover rounded border border-bambu-dark-tertiary"}),s.jsx("button",{onClick:()=>xt(De.index),className:"absolute top-1 right-1 p-0.5 bg-red-500/80 rounded opacity-0 group-hover:opacity-100 transition-opacity",title:"Delete reference",children:s.jsx(zt,{className:"w-3 h-3 text-white"})}),de?.index===De.index?s.jsx("input",{type:"text",value:de.label,onChange:ht=>Re({...de,label:ht.target.value}),onBlur:()=>kt(De.index,de.label),onKeyDown:ht=>{ht.key==="Enter"&&kt(De.index,de.label),ht.key==="Escape"&&Re(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:"Label..."}):s.jsx("p",{className:"text-xs text-bambu-gray mt-1 truncate cursor-pointer hover:text-white",onClick:()=>Re({index:De.index,label:De.label}),title:De.label?`${De.label} - Click to edit`:"Click to add label",children:De.label||s.jsx("span",{className:"italic opacity-50",children:"No label"})}),s.jsx("p",{className:"text-[10px] text-bambu-gray/60",children:De.timestamp?new Date(De.timestamp).toLocaleDateString():""})]},De.index))})]}),!le.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:"Detection Area (ROI)"}),B?s.jsxs("div",{className:"flex gap-1",children:[s.jsx(we,{variant:"ghost",size:"sm",onClick:()=>oe(null),disabled:Te,children:"Cancel"}),s.jsx(we,{size:"sm",onClick:$t,disabled:Te,children:Te?s.jsx(dt,{className:"w-3 h-3 animate-spin"}):"Save"})]}):s.jsxs(we,{variant:"ghost",size:"sm",onClick:()=>oe(le.roi||{x:.15,y:.35,w:.7,h:.55}),children:[s.jsx(ia,{className:"w-3 h-3 mr-1"}),"Edit"]})]}),B?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 Start"}),s.jsx("input",{type:"range",min:"0",max:"0.9",step:"0.01",value:B.x,onChange:De=>oe({...B,x:parseFloat(De.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(B.x*100),"%"]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-bambu-gray",children:"Y Start"}),s.jsx("input",{type:"range",min:"0",max:"0.9",step:"0.01",value:B.y,onChange:De=>oe({...B,y:parseFloat(De.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(B.y*100),"%"]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-bambu-gray",children:"Width"}),s.jsx("input",{type:"range",min:"0.1",max:"1",step:"0.01",value:B.w,onChange:De=>oe({...B,w:parseFloat(De.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(B.w*100),"%"]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-bambu-gray",children:"Height"}),s.jsx("input",{type:"range",min:"0.1",max:"1",step:"0.01",value:B.h,onChange:De=>oe({...B,h:parseFloat(De.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(B.h*100),"%"]})]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Adjust the detection area to focus on the build plate. The green box in the preview shows the current area."})]}):s.jsxs("p",{className:"text-xs text-bambu-gray",children:["Current: X=",Math.round((le.roi?.x||.15)*100),"%, Y=",Math.round((le.roi?.y||.35)*100),"%, W=",Math.round((le.roi?.w||.7)*100),"%, H=",Math.round((le.roi?.h||.55)*100),"%"]})]})]}),s.jsx("div",{className:"flex justify-end gap-2 p-4 border-t border-bambu-dark-tertiary",children:le.needs_calibration?s.jsxs(s.Fragment,{children:[s.jsx(we,{variant:"ghost",onClick:()=>mt(),children:"Cancel"}),s.jsx(we,{onClick:()=>St(),disabled:X,children:X?s.jsxs(s.Fragment,{children:[s.jsx(dt,{className:"w-4 h-4 mr-2 animate-spin"}),"Calibrating..."]}):"Calibrate Empty Plate"})]}):s.jsxs(s.Fragment,{children:[s.jsx(we,{variant:"ghost",onClick:()=>St(),disabled:X,children:X?"Adding...":`Add Reference (${rt?.references.length||0}/${rt?.max_references||5})`}),s.jsx(we,{onClick:()=>mt(),children:"Close"})]})})]})}),R&&be&&s.jsx(Bn,{title:"Power On Printer",message:`Are you sure you want to turn ON the power for "${t.name}"?`,confirmText:"Power On",variant:"default",onConfirm:()=>{It.mutate("on"),F(!1)},onCancel:()=>F(!1)}),L&&be&&s.jsx(Bn,{title:"Power Off Printer",message:D?.state==="RUNNING"?`WARNING: "${t.name}" is currently printing! Are you sure you want to turn OFF the power? This will interrupt the print and may damage the printer.`:`Are you sure you want to turn OFF the power for "${t.name}"?`,confirmText:"Power Off",variant:"danger",onConfirm:()=>{It.mutate("off"),K(!1)},onCancel:()=>K(!1)}),Y&&s.jsx(Bn,{title:"Stop Print",message:`Are you sure you want to stop the current print on "${t.name}"? This will cancel the print job.`,confirmText:"Stop Print",variant:"danger",onConfirm:()=>{bt.mutate(),q(!1)},onCancel:()=>q(!1)}),Q&&s.jsx(Bn,{title:"Pause Print",message:`Are you sure you want to pause the current print on "${t.name}"?`,confirmText:"Pause Print",variant:"default",onConfirm:()=>{Gt.mutate(),ee(!1)},onCancel:()=>ee(!1)}),re&&s.jsx(Bn,{title:"Resume Print",message:`Are you sure you want to resume the print on "${t.name}"?`,confirmText:"Resume Print",variant:"default",onConfirm:()=>{ln.mutate(),z(!1)},onCancel:()=>z(!1)}),G&&s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",onClick:()=>ae(!1),onKeyDown:De=>De.key==="Escape"&&ae(!1),tabIndex:-1,ref:De=>De?.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:De=>De.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(nH,{className:"w-4 h-4 text-bambu-green"}),s.jsx("span",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Skip Objects"})]}),s.jsx("button",{onClick:()=>ae(!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(zt,{className:"w-4 h-4"})})]}),An?An.objects.length===0?s.jsxs("div",{className:"text-center py-8 px-4 text-bambu-gray",children:[s.jsx("p",{className:"text-sm",children:"No objects found"}),s.jsx("p",{className:"text-xs mt-1 opacity-70",children:"Objects are loaded when a print starts"})]}):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(zde,{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:"Match IDs with your printer display"}),s.jsx("p",{className:"text-[10px] text-blue-500/70 dark:text-blue-300/60",children:"The printer screen shows object IDs on the build plate"})]}),s.jsxs("div",{className:"flex-shrink-0 text-xs text-gray-500 dark:text-bambu-gray",children:[An.skipped_count,"/",An.total," skipped"]})]}),(D?.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(ji,{className:"w-4 h-4 text-amber-500 dark:text-amber-400 flex-shrink-0"}),s.jsxs("p",{className:"text-xs text-amber-600 dark:text-amber-400",children:["Wait for layer 2+ to skip objects (currently layer ",D?.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:[D?.cover_url?s.jsx("img",{src:`${D.cover_url}?view=top`,alt:"Print preview",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(zs,{className:"w-8 h-8 text-gray-300 dark:text-bambu-gray/30"})}),An.objects.length>0&&s.jsx("div",{className:"absolute inset-0 pointer-events-none",children:An.objects.map((De,ht)=>{let Mt,at;if(De.x!=null&&De.y!=null&&An.bbox_all){const[Xt,Yt,rn,sr]=An.bbox_all,kn=rn-Xt,Wt=sr-Yt,en=8,or=100-en*2;Mt=en+(De.x-Xt)/kn*or,at=en+(sr-De.y)/Wt*or,Mt=Math.max(5,Math.min(95,Mt)),at=Math.max(5,Math.min(95,at))}else if(De.x!=null&&De.y!=null)Mt=De.x/256*100,at=100-De.y/256*100,Mt=Math.max(5,Math.min(95,Mt)),at=Math.max(5,Math.min(95,at));else{const Xt=Math.ceil(Math.sqrt(An.objects.length)),Yt=Math.floor(ht/Xt),rn=ht%Xt,sr=Math.ceil(An.objects.length/Xt);Mt=15+rn*(70/Xt)+35/Xt,at=15+Yt*(70/sr)+35/sr}return s.jsx("div",{className:`absolute flex items-center justify-center w-6 h-6 rounded-full text-[10px] font-bold shadow-lg ${De.skipped?"bg-red-500 text-white line-through":"bg-bambu-green text-black"}`,style:{left:`${Mt}%`,top:`${at}%`,transform:"translate(-50%, -50%)"},title:De.name,children:De.id},De.id)})}),s.jsxs("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:[An.objects.filter(De=>!De.skipped).length," active"]})]})}),s.jsx("div",{className:"flex-1 min-w-0 overflow-y-auto",children:An.objects.map(De=>s.jsxs("div",{className:`
  85. flex items-center gap-3 px-4 py-3 border-b border-gray-200 dark:border-bambu-dark-tertiary/50 last:border-0
  86. ${De.skipped?"bg-red-50 dark:bg-red-500/10":"hover:bg-gray-50 dark:hover:bg-bambu-dark/50"}
  87. `,children:[s.jsxs("div",{className:`
  88. w-12 h-12 flex-shrink-0 rounded-lg flex flex-col items-center justify-center
  89. ${De.skipped?"bg-red-100 dark:bg-red-500/20 border border-red-300 dark:border-red-500/40":"bg-green-100 dark:bg-bambu-green/20 border border-green-300 dark:border-bambu-green/40"}
  90. `,children:[s.jsx("span",{className:`text-lg font-mono font-bold ${De.skipped?"text-red-500 dark:text-red-400":"text-green-600 dark:text-bambu-green"}`,children:De.id}),s.jsx("span",{className:`text-[8px] uppercase tracking-wider ${De.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 ${De.skipped?"text-red-500 dark:text-red-400 line-through":"text-gray-900 dark:text-white"}`,children:De.name}),De.skipped&&s.jsx("span",{className:"text-[10px] text-red-400/60",children:"Will be skipped"})]}),De.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:"Skipped"}):s.jsx("button",{onClick:()=>Sr.mutate([De.id]),disabled:Sr.isPending||(D?.layer_num??0)<=1,className:`px-4 py-2 text-xs font-medium rounded-lg transition-colors ${(D?.layer_num??0)<=1?"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:(D?.layer_num??0)<=1?"Wait for layer 2+":"Skip this object",children:"Skip"})]},De.id))})]})]}):s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx(dt,{className:"w-5 h-5 animate-spin text-bambu-gray"})})]})]}),j&&s.jsx(Vfe,{printerName:t.name,errors:D?.hms_errors||[],onClose:()=>W(!1)}),se&&s.jsx(Fke,{isOpen:!!se,onClose:()=>ue(null),printerId:t.id,printerName:t.name,amsId:se.amsId,amsLabel:se.amsLabel,initialMode:se.mode,thresholds:a}),pe&&s.jsx(Uke,{isOpen:!!pe,onClose:()=>ce(null),trayUuid:pe.trayUuid,trayInfo:pe.trayInfo}),Me&&s.jsx(Wke,{isOpen:!!Me,onClose:()=>me(null),printerId:t.id,slotInfo:Me,onSuccess:()=>{f.invalidateQueries({queryKey:["slotPresets",t.id]}),f.invalidateQueries({queryKey:["printerStatus",t.id]})}}),T&&s.jsx(lje,{printer:t,onClose:()=>E(!1)}),Ee&&Z&&s.jsx(oje,{printer:t,firmwareInfo:Z,onClose:()=>fe(!1)}),wt&&s.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>Qt(null)})]})}function sje({onClose:t,onAdd:e,existingSerials:n}){const[r,i]=w.useState({name:"",serial_number:"",ip_address:"",access_code:"",model:"",auto_archive:!0}),[a,o]=w.useState(!1),[l,c]=w.useState([]),[u,d]=w.useState(""),[f,m]=w.useState(!1),[p,x]=w.useState(!1),[y,b]=w.useState("192.168.1.0/24"),[v,N]=w.useState({scanned:0,total:0});w.useEffect(()=>{vl.getInfo().then(A=>{x(A.is_docker)}).catch(()=>{})},[]);const S=l.filter(A=>!n.includes(A.serial)),T=async()=>{d(""),c([]),o(!0),m(!1),N({scanned:0,total:0});try{if(p){await vl.startSubnetScan(y);const A=setInterval(async()=>{try{const O=await vl.getScanStatus();N({scanned:O.scanned,total:O.total});const k=await vl.getDiscoveredPrinters();c(k),O.running||(clearInterval(A),o(!1),m(!0))}catch(O){console.error("Failed to get scan status:",O)}},500)}else{await vl.startDiscovery(10);const A=setInterval(async()=>{try{const O=await vl.getDiscoveredPrinters();c(O)}catch(O){console.error("Failed to get discovered printers:",O)}},1e3);setTimeout(async()=>{clearInterval(A);try{await vl.stopDiscovery()}catch{}o(!1),m(!0);try{const O=await vl.getDiscoveredPrinters();c(O)}catch(O){console.error("Failed to get final discovered printers:",O)}},1e4)}}catch(A){console.error("Failed to start discovery:",A),d(A instanceof Error?A.message:"Failed to start discovery"),o(!1),m(!0)}},E=A=>A?{O1D:"H2D",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",H2C:"H2C",H2S:"H2S"}[A]||A:"",C=A=>{const O=A.serial.startsWith("unknown-")?"":A.serial;i({...r,name:A.name||"",serial_number:O,ip_address:A.ip_address,model:E(A.model)}),c([])};return w.useEffect(()=>()=>{vl.stopDiscovery().catch(()=>{}),vl.stopSubnetScan().catch(()=>{})},[]),w.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",onClick:t,children:s.jsx(Nt,{className:"w-full max-w-md",onClick:A=>A.stopPropagation(),children:s.jsxs(Et,{children:[s.jsx("h2",{className:"text-xl font-semibold mb-4",children:"Add Printer"}),s.jsxs("div",{className:"mb-4 pb-4 border-b border-bambu-dark-tertiary",children:[p&&s.jsxs("div",{className:"mb-3",children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Subnet to scan"}),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:A=>b(A.target.value),placeholder:"192.168.1.0/24",disabled:a}),s.jsxs("p",{className:"mt-1 text-xs text-bambu-gray",children:["Docker detected. Enter your printer's subnet in CIDR notation. Requires ",s.jsx("code",{className:"text-bambu-green",children:"network_mode: host"})," in docker-compose.yml."]})]}),s.jsx(we,{type:"button",variant:"secondary",onClick:T,disabled:a,className:"w-full",children:a?s.jsxs(s.Fragment,{children:[s.jsx(dt,{className:"w-4 h-4 animate-spin"}),p&&v.total>0?`Scanning... ${v.scanned}/${v.total}`:"Scanning..."]}):s.jsxs(s.Fragment,{children:[s.jsx(_a,{className:"w-4 h-4"}),p?"Scan Subnet for Printers":"Discover Printers on Network"]})}),u&&s.jsx("div",{className:"mt-2 text-sm text-red-400",children:u}),S.length>0&&s.jsx("div",{className:"mt-3 space-y-2 max-h-40 overflow-y-auto",children:S.map(A=>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:()=>C(A),children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"font-medium text-white text-sm truncate",children:A.name||A.serial}),s.jsxs("p",{className:"text-xs text-bambu-gray truncate",children:[E(A.model)||"Unknown"," • ",A.ip_address,A.serial.startsWith("unknown-")&&s.jsx("span",{className:"text-yellow-500",children:" • Serial required"})]})]}),s.jsx(Pi,{className:"w-4 h-4 text-bambu-gray -rotate-90 flex-shrink-0 ml-2"})]},A.serial))}),a&&s.jsx("p",{className:"mt-2 text-sm text-bambu-gray text-center",children:p?"Scanning subnet for Bambu printers...":"Scanning network..."}),f&&!a&&l.length===0&&s.jsxs("p",{className:"mt-2 text-sm text-bambu-gray text-center",children:["No printers found",p?" in the specified subnet":" on the network","."]}),f&&!a&&l.length>0&&S.length===0&&s.jsx("p",{className:"mt-2 text-sm text-bambu-gray text-center",children:"All discovered printers are already configured."})]}),s.jsxs("form",{onSubmit:A=>{A.preventDefault(),e(r)},className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"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:r.name,onChange:A=>i({...r,name:A.target.value}),placeholder:"My Printer"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"IP Address"}),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:r.ip_address,onChange:A=>i({...r,ip_address:A.target.value}),placeholder:"192.168.1.100"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Serial Number"}),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:r.serial_number,onChange:A=>i({...r,serial_number:A.target.value}),placeholder:"01P00A000000000"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Access Code"}),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:r.access_code,onChange:A=>i({...r,access_code:A.target.value}),placeholder:"From printer settings"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Model (optional)"}),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:r.model||"",onChange:A=>i({...r,model:A.target.value}),children:[s.jsx("option",{value:"",children:"Select model..."}),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:"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",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",id:"auto_archive",checked:r.auto_archive,onChange:A=>i({...r,auto_archive:A.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:"Auto-archive completed prints"})]}),s.jsxs("div",{className:"flex gap-3 pt-4",children:[s.jsx(we,{type:"button",variant:"secondary",onClick:t,className:"flex-1",children:"Cancel"}),s.jsx(we,{type:"submit",className:"flex-1",children:"Add Printer"})]})]})]})})})}function oje({printer:t,firmwareInfo:e,onClose:n}){const r=on(),{showToast:i}=Vn(),[a,o]=w.useState(null),[l,c]=w.useState(!1),[u,d]=w.useState(null),{data:f,isLoading:m}=ut({queryKey:["firmwarePrepare",t.id],queryFn:()=>B1.prepareUpload(t.id),staleTime:3e4}),p=pt({mutationFn:()=>B1.startUpload(t.id),onSuccess:()=>{c(!0);const y=setInterval(async()=>{try{const b=await B1.getUploadStatus(t.id);o(b),(b.status==="complete"||b.status==="error")&&(clearInterval(y),d(null),c(!1),b.status==="complete"&&(i("Firmware uploaded! Trigger update from printer screen.","success"),r.invalidateQueries({queryKey:["firmwareUpdate",t.id]})))}catch{}},2e3);d(y)},onError:y=>{i(`Failed to start upload: ${y.message}`,"error"),c(!1)}});w.useEffect(()=>()=>{u&&clearInterval(u)},[u]);const x=()=>{o(null),p.mutate()};return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:s.jsx(Nt,{className:"w-full max-w-md mx-4",children:s.jsxs(Et,{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($r,{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:"Firmware Update"}),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:"Current:"}),s.jsx("span",{className:"text-white font-mono",children:e.current_version||"Unknown"})]}),s.jsxs("div",{className:"flex justify-between items-center text-sm mt-1",children:[s.jsx("span",{className:"text-bambu-gray",children:"Latest:"}),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:"Release Notes"}),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(dt,{className:"w-4 h-4 animate-spin"}),"Checking prerequisites..."]}):f&&!l&&!a?s.jsx("div",{className:"mb-4",children:f.can_proceed?s.jsxs("div",{className:"flex items-center gap-2 text-bambu-green text-sm",children:[s.jsx(zs,{className:"w-4 h-4"}),"SD card ready. Click below to upload firmware."]}):s.jsx("div",{className:"space-y-1",children:f.errors.map((y,b)=>s.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[s.jsx(ji,{className:"w-4 h-4 flex-shrink-0"}),y]},b))})}):null,(l||a)&&a&&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:a.status}),s.jsxs("span",{className:"text-white",children:[a.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 ${a.status==="error"?"bg-status-error":a.status==="complete"?"bg-status-ok":"bg-orange-500"} ${a.status==="uploading"?"animate-pulse":""}`,style:{width:`${a.progress}%`}})}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:a.message}),a.error&&s.jsx("p",{className:"text-xs text-red-400 mt-1",children:a.error})]}),a?.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:"Firmware uploaded to SD card!"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"To apply the update on your printer:"}),s.jsxs("ol",{className:"text-xs text-bambu-gray mt-1 list-decimal list-inside space-y-1",children:[s.jsxs("li",{children:["On the printer's touchscreen, go to ",s.jsx("strong",{className:"text-white",children:"Settings"})]}),s.jsxs("li",{children:["Navigate to ",s.jsx("strong",{className:"text-white",children:"Firmware"})]}),s.jsxs("li",{children:["Select ",s.jsx("strong",{className:"text-white",children:"Update from SD card"})]}),s.jsx("li",{children:"The update will take 10-20 minutes"})]})]}),s.jsxs("div",{className:"flex gap-2 justify-end",children:[s.jsx(we,{variant:"secondary",onClick:n,children:a?.status==="complete"?"Done":"Cancel"}),f?.can_proceed&&!l&&a?.status!=="complete"&&s.jsx(we,{onClick:x,disabled:p.isPending,children:p.isPending?s.jsxs(s.Fragment,{children:[s.jsx(dt,{className:"w-4 h-4 animate-spin mr-2"}),"Starting..."]}):s.jsxs(s.Fragment,{children:[s.jsx($r,{className:"w-4 h-4 mr-2"}),"Upload Firmware"]})})]})]})})})}function lje({printer:t,onClose:e}){const n=on(),[r,i]=w.useState({name:t.name,ip_address:t.ip_address,access_code:"",model:t.model||"",location:t.location||"",auto_archive:t.auto_archive}),a=pt({mutationFn:l=>he.updatePrinter(t.id,l),onSuccess:()=>{n.invalidateQueries({queryKey:["printers"]}),n.invalidateQueries({queryKey:["printerStatus",t.id]}),e()}});w.useEffect(()=>{const l=c=>{c.key==="Escape"&&e()};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[e]);const o=l=>{l.preventDefault();const c={name:r.name,ip_address:r.ip_address,model:r.model||void 0,location:r.location||void 0,auto_archive:r.auto_archive};r.access_code&&(c.access_code=r.access_code),a.mutate(c)};return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:e,children:s.jsx(Nt,{className:"w-full max-w-md",onClick:l=>l.stopPropagation(),children:s.jsxs(Et,{children:[s.jsx("h2",{className:"text-xl font-semibold mb-4",children:"Edit Printer"}),s.jsxs("form",{onSubmit:o,className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"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:r.name,onChange:l=>i({...r,name:l.target.value}),placeholder:"My Printer"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"IP Address"}),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:r.ip_address,onChange:l=>i({...r,ip_address:l.target.value}),placeholder:"192.168.1.100"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Serial Number"}),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:"Serial number cannot be changed"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Access Code"}),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:r.access_code,onChange:l=>i({...r,access_code:l.target.value}),placeholder:"Leave empty to keep current"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"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:r.model,onChange:l=>i({...r,model:l.target.value}),children:[s.jsx("option",{value:"",children:"Select model..."}),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:"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:r.location,onChange:l=>i({...r,location:l.target.value}),placeholder:"e.g., Workshop, Office, Basement"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Used to group printers on the dashboard"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",id:"edit_auto_archive",checked:r.auto_archive,onChange:l=>i({...r,auto_archive:l.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:"Auto-archive completed prints"})]}),s.jsxs("div",{className:"flex gap-3 pt-4",children:[s.jsx(we,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),s.jsx(we,{type:"submit",className:"flex-1",disabled:a.isPending,children:a.isPending?"Saving...":"Save Changes"})]})]})]})})})}function cje(t){const{data:e}=ut({queryKey:["printerStatus",t],queryFn:()=>he.getPrinterStatus(t),refetchInterval:3e4});return!e?.connected}function uje({printer:t,plug:e,onPowerOn:n,isPowering:r}){const i=cje(t.id),{data:a}=ut({queryKey:["smartPlugStatus",e.id],queryFn:()=>he.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 dje(){const[t,e]=w.useState(!1),[n,r]=w.useState(()=>localStorage.getItem("hideDisconnectedPrinters")==="true"),[i,a]=w.useState(!1),[o,l]=w.useState(null),[c,u]=w.useState(()=>localStorage.getItem("printerSortBy")||"name"),[d,f]=w.useState(()=>localStorage.getItem("printerSortAsc")!=="false"),[m,p]=w.useState(()=>{const G=localStorage.getItem("printerCardSize");return G?parseInt(G,10):2}),x=m===1?"compact":"expanded",y=on(),[b,v]=w.useState(()=>{const G=localStorage.getItem("openEmbeddedCameras");if(G)try{const ae=JSON.parse(G);return new Map(ae.map(se=>[se.id,se]))}catch{return new Map}return new Map});w.useEffect(()=>{const G=Array.from(b.values());G.length>0?localStorage.setItem("openEmbeddedCameras",JSON.stringify(G)):localStorage.removeItem("openEmbeddedCameras")},[b]);const{data:N,isLoading:S}=ut({queryKey:["printers"],queryFn:he.getPrinters}),{data:T}=ut({queryKey:["settings"],queryFn:he.getSettings});w.useEffect(()=>{T?.camera_view_mode==="window"&&b.size>0&&v(new Map)},[T?.camera_view_mode,b.size]);const{data:E}=ut({queryKey:["smart-plugs"],queryFn:he.getSmartPlugs}),{data:C}=ut({queryKey:["maintenanceOverview"],queryFn:he.getMaintenanceOverview,staleTime:60*1e3}),{data:A}=ut({queryKey:["spoolman-status"],queryFn:he.getSpoolmanStatus,staleTime:60*1e3}),O=A?.enabled&&A?.connected,{data:k}=ut({queryKey:["unlinked-spools"],queryFn:he.getUnlinkedSpools,enabled:!!O,staleTime:30*1e3}),R=k&&k.length>0,F=C?.reduce((G,ae)=>(G[ae.printer_id]={due_count:ae.due_count,warning_count:ae.warning_count,total_print_hours:ae.total_print_hours},G),{})||{},L=E?.reduce((G,ae)=>(ae.printer_id&&(G[ae.printer_id]=ae),G),{})||{},K=pt({mutationFn:he.createPrinter,onSuccess:()=>{y.invalidateQueries({queryKey:["printers"]}),y.invalidateQueries({queryKey:["maintenanceOverview"]}),e(!1)}}),j=pt({mutationFn:G=>he.controlSmartPlug(G,"on"),onSuccess:()=>{y.invalidateQueries({queryKey:["smart-plugs"]}),l(null)},onError:()=>{l(null)}}),W=()=>{const G=!n;r(G),localStorage.setItem("hideDisconnectedPrinters",String(G))},Y=G=>{u(G),localStorage.setItem("printerSortBy",G)},q=()=>{const G=!d;f(G),localStorage.setItem("printerSortAsc",String(G))},Q=()=>{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"}},ee=["S","M","L","XL"],re=w.useMemo(()=>{if(!N)return[];const G=[...N];switch(c){case"name":G.sort((ae,se)=>ae.name.localeCompare(se.name));break;case"model":G.sort((ae,se)=>(ae.model||"").localeCompare(se.model||""));break;case"location":G.sort((ae,se)=>{const ue=ae.location||"",pe=se.location||"";return!ue&&pe?1:ue&&!pe?-1:ue.localeCompare(pe)||ae.name.localeCompare(se.name)});break;case"status":G.sort((ae,se)=>{const ue=y.getQueryData(["printerStatus",ae.id]),pe=y.getQueryData(["printerStatus",se.id]),ce=Me=>Me?.connected?Me.state==="RUNNING"?0:1:2;return ce(ue)-ce(pe)});break}return d||G.reverse(),G},[N,c,d,y]),z=w.useMemo(()=>{if(c!=="location")return null;const G={};return re.forEach(ae=>{const se=ae.location||"Ungrouped";G[se]||(G[se]=[]),G[se].push(ae)}),G},[c,re]);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:"Printers"}),s.jsx(aje,{printers:N})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsxs("select",{value:c,onChange:G=>Y(G.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:"Name"}),s.jsx("option",{value:"status",children:"Status"}),s.jsx("option",{value:"model",children:"Model"}),s.jsx("option",{value:"location",children:"Location"})]}),s.jsx("button",{onClick:q,className:"p-1.5 rounded-lg hover:bg-bambu-dark-tertiary transition-colors",title:d?"Sort descending":"Sort ascending",children:d?s.jsx(rg,{className:"w-4 h-4 text-bambu-gray"}):s.jsx(h0,{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:ee.map((G,ae)=>{const se=ae+1,ue=m===se;return s.jsx("button",{onClick:()=>{p(se),localStorage.setItem("printerCardSize",String(se))},className:`px-2 py-1.5 text-xs font-medium transition-colors ${ae===0?"rounded-l-lg":""} ${ae===ee.length-1?"rounded-r-lg":""} ${ue?"bg-bambu-green text-white":"text-bambu-gray hover:bg-bambu-dark-tertiary hover:text-white"}`,title:`${G==="S"?"Small":G==="M"?"Medium":G==="L"?"Large":"Extra large"} cards`,children:G},G)})}),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:n,onChange:W,className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),"Hide offline"]}),n&&Object.keys(L).length>0&&s.jsxs("div",{className:"relative",children:[s.jsxs("button",{onClick:()=>a(!i),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"}),"Power On",s.jsx(Pi,{className:`w-3 h-3 transition-transform ${i?"rotate-180":""}`})]}),i&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>a(!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:"Offline printers with smart plugs"}),N?.filter(G=>L[G.id]).map(G=>s.jsx(uje,{printer:G,plug:L[G.id],onPowerOn:ae=>{l(ae),j.mutate(ae)},isPowering:o===L[G.id]?.id},G.id)),N?.filter(G=>L[G.id]).length===0&&s.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No printers with smart plugs"})]})]})]}),s.jsxs(we,{onClick:()=>e(!0),children:[s.jsx(Jn,{className:"w-4 h-4"}),"Add Printer"]})]})]}),S?s.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading printers..."}):N?.length===0?s.jsx(Nt,{children:s.jsxs(Et,{className:"text-center py-12",children:[s.jsx("p",{className:"text-bambu-gray mb-4",children:"No printers configured yet"}),s.jsxs(we,{onClick:()=>e(!0),children:[s.jsx(Jn,{className:"w-4 h-4"}),"Add Your First Printer"]})]})}):z?s.jsx("div",{className:"space-y-6",children:Object.entries(z).map(([G,ae])=>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"}),G,s.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",ae.length,")"]})]}),s.jsx("div",{className:`grid gap-4 ${m>=3?"gap-6":""} ${Q()}`,children:ae.map(se=>s.jsx(uH,{printer:se,hideIfDisconnected:n,maintenanceInfo:F[se.id],viewMode:x,cardSize:m,amsThresholds:T?{humidityGood:Number(T.ams_humidity_good)||40,humidityFair:Number(T.ams_humidity_fair)||60,tempGood:Number(T.ams_temp_good)||28,tempFair:Number(T.ams_temp_fair)||35}:void 0,spoolmanEnabled:O,hasUnlinkedSpools:R,timeFormat:T?.time_format||"system",cameraViewMode:T?.camera_view_mode||"window",onOpenEmbeddedCamera:(ue,pe)=>v(ce=>new Map(ce).set(ue,{id:ue,name:pe}))},se.id))})]},G))}):s.jsx("div",{className:`grid gap-4 ${m>=3?"gap-6":""} ${Q()}`,children:re.map(G=>s.jsx(uH,{printer:G,hideIfDisconnected:n,maintenanceInfo:F[G.id],viewMode:x,cardSize:m,spoolmanEnabled:O,hasUnlinkedSpools:R,amsThresholds:T?{humidityGood:Number(T.ams_humidity_good)||40,humidityFair:Number(T.ams_humidity_fair)||60,tempGood:Number(T.ams_temp_good)||28,tempFair:Number(T.ams_temp_fair)||35}:void 0,timeFormat:T?.time_format||"system",cameraViewMode:T?.camera_view_mode||"window",onOpenEmbeddedCamera:(ae,se)=>v(ue=>new Map(ue).set(ae,{id:ae,name:se}))},G.id))}),t&&s.jsx(sje,{onClose:()=>e(!1),onAdd:G=>K.mutate(G),existingSerials:N?.map(G=>G.serial_number)||[]}),Array.from(b.values()).map((G,ae)=>s.jsx(Ufe,{printerId:G.id,printerName:G.name,viewerIndex:ae,onClose:()=>v(se=>{const ue=new Map(se);return ue.delete(G.id),ue})},G.id))]})}function hje(){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 fje(){switch(hje()){case"windows":return"bambustudio://";case"macos":case"linux":default:return"bambustudioopen://"}}function Bc(t){const e=fje();window.location.href=`${e}${encodeURIComponent(t)}`}const vO="181",Kp={ROTATE:0,DOLLY:1,PAN:2},Up={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},mje=0,dH=1,pje=2,LZ=1,gje=2,Dc=3,Kd=0,bs=1,Cl=2,eu=0,Xp=1,hH=2,fH=3,mH=4,xje=5,Gh=100,bje=101,yje=102,vje=103,_je=104,wje=200,Sje=201,Nje=202,Mje=203,iP=204,aP=205,Eje=206,Tje=207,Aje=208,Cje=209,kje=210,jje=211,Pje=212,Rje=213,Dje=214,sP=0,oP=1,lP=2,gg=3,cP=4,uP=5,dP=6,hP=7,_O=0,Oje=1,Lje=2,Rd=0,Ije=1,Fje=2,Uje=3,zje=4,Bje=5,$je=6,Hje=7,IZ=300,xg=301,bg=302,fP=303,mP=304,zN=306,pP=1e3,Wc=1001,gP=1002,Ws=1003,Vje=1004,w_=1005,To=1006,NC=1007,rf=1008,Gl=1009,FZ=1010,UZ=1011,R0=1012,wO=1013,zf=1014,qc=1015,Zg=1016,SO=1017,NO=1018,D0=1020,zZ=35902,BZ=35899,$Z=1021,HZ=1022,nl=1023,O0=1026,L0=1027,VZ=1028,MO=1029,EO=1030,TO=1031,AO=1033,X1=33776,Y1=33777,Q1=33778,Z1=33779,xP=35840,bP=35841,yP=35842,vP=35843,_P=36196,wP=37492,SP=37496,NP=37808,MP=37809,EP=37810,TP=37811,AP=37812,CP=37813,kP=37814,jP=37815,PP=37816,RP=37817,DP=37818,OP=37819,LP=37820,IP=37821,FP=36492,UP=36494,zP=36495,BP=36283,$P=36284,HP=36285,VP=36286,Gje=3200,Wje=3201,GZ=0,qje=1,xd="",bo="srgb",yg="srgb-linear",vS="linear",hr="srgb",Hm=7680,pH=519,Kje=512,Xje=513,Yje=514,WZ=515,Qje=516,Zje=517,Jje=518,e3e=519,gH=35044,xH="300 es",Rl=2e3,_S=2001;function qZ(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function wS(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function t3e(){const t=wS("canvas");return t.style.display="block",t}const bH={};function yH(...t){const e="THREE."+t.shift();console.log(e,...t)}function mn(...t){const e="THREE."+t.shift();console.warn(e,...t)}function ui(...t){const e="THREE."+t.shift();console.error(e,...t)}function I0(...t){const e=t.join(" ");e in bH||(bH[e]=!0,mn(...t))}function n3e(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 nm=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 Ma=["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"],J1=Math.PI/180,GP=180/Math.PI;function Dy(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(Ma[t&255]+Ma[t>>8&255]+Ma[t>>16&255]+Ma[t>>24&255]+"-"+Ma[e&255]+Ma[e>>8&255]+"-"+Ma[e>>16&15|64]+Ma[e>>24&255]+"-"+Ma[n&63|128]+Ma[n>>8&255]+"-"+Ma[n>>16&255]+Ma[n>>24&255]+Ma[r&255]+Ma[r>>8&255]+Ma[r>>16&255]+Ma[r>>24&255]).toLowerCase()}function Rn(t,e,n){return Math.max(e,Math.min(n,t))}function r3e(t,e){return(t%e+e)%e}function MC(t,e,n){return(1-n)*t+n*e}function sb(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 us(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 i3e={DEG2RAD:J1};let Mn=class KZ{constructor(e=0,n=0){KZ.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=Rn(this.x,e.x,n.x),this.y=Rn(this.y,e.y,n.y),this}clampScalar(e,n){return this.x=Rn(this.x,e,n),this.y=Rn(this.y,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Rn(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(Rn(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}},Bf=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],m=a[o+0],p=a[o+1],x=a[o+2],y=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]=m,e[n+1]=p,e[n+2]=x,e[n+3]=y;return}if(f!==y||c!==m||u!==p||d!==x){let b=c*m+u*p+d*x+f*y;b<0&&(m=-m,p=-p,x=-x,y=-y,b=-b);let v=1-l;if(b<.9995){const N=Math.acos(b),S=Math.sin(N);v=Math.sin(v*N)/S,l=Math.sin(l*N)/S,c=c*v+m*l,u=u*v+p*l,d=d*v+x*l,f=f*v+y*l}else{c=c*v+m*l,u=u*v+p*l,d=d*v+x*l,f=f*v+y*l;const N=1/Math.sqrt(c*c+u*u+d*d+f*f);c*=N,u*=N,d*=N,f*=N}}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],m=a[o+1],p=a[o+2],x=a[o+3];return e[n]=l*x+d*f+c*p-u*m,e[n+1]=c*x+d*m+u*f-l*p,e[n+2]=u*x+d*p+l*m-c*f,e[n+3]=d*x-l*f-c*m-u*p,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,n,r,i){return this._x=e,this._y=n,this._z=r,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,n=!0){const r=e._x,i=e._y,a=e._z,o=e._order,l=Math.cos,c=Math.sin,u=l(r/2),d=l(i/2),f=l(a/2),m=c(r/2),p=c(i/2),x=c(a/2);switch(o){case"XYZ":this._x=m*d*f+u*p*x,this._y=u*p*f-m*d*x,this._z=u*d*x+m*p*f,this._w=u*d*f-m*p*x;break;case"YXZ":this._x=m*d*f+u*p*x,this._y=u*p*f-m*d*x,this._z=u*d*x-m*p*f,this._w=u*d*f+m*p*x;break;case"ZXY":this._x=m*d*f-u*p*x,this._y=u*p*f+m*d*x,this._z=u*d*x+m*p*f,this._w=u*d*f-m*p*x;break;case"ZYX":this._x=m*d*f-u*p*x,this._y=u*p*f+m*d*x,this._z=u*d*x-m*p*f,this._w=u*d*f+m*p*x;break;case"YZX":this._x=m*d*f+u*p*x,this._y=u*p*f+m*d*x,this._z=u*d*x-m*p*f,this._w=u*d*f-m*p*x;break;case"XZY":this._x=m*d*f-u*p*x,this._y=u*p*f-m*d*x,this._z=u*d*x+m*p*f,this._w=u*d*f+m*p*x;break;default:mn("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],m=r+l+f;if(m>0){const p=.5/Math.sqrt(m+1);this._w=.25/p,this._x=(d-c)*p,this._y=(a-u)*p,this._z=(o-i)*p}else if(r>l&&r>f){const p=2*Math.sqrt(1+r-l-f);this._w=(d-c)/p,this._x=.25*p,this._y=(i+o)/p,this._z=(a+u)/p}else if(l>f){const p=2*Math.sqrt(1+l-r-f);this._w=(a-u)/p,this._x=(i+o)/p,this._y=.25*p,this._z=(c+d)/p}else{const p=2*Math.sqrt(1+f-r-l);this._w=(o-i)/p,this._x=(a+u)/p,this._y=(c+d)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(e,n){let r=e.dot(n)+1;return r<1e-8?(r=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=r):(this._x=0,this._y=-e.z,this._z=e.y,this._w=r)):(this._x=e.y*n.z-e.z*n.y,this._y=e.z*n.x-e.x*n.z,this._z=e.x*n.y-e.y*n.x,this._w=r),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Rn(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}},lt=class XZ{constructor(e=0,n=0,r=0){XZ.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(vH.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(vH.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=Rn(this.x,e.x,n.x),this.y=Rn(this.y,e.y,n.y),this.z=Rn(this.z,e.z,n.z),this}clampScalar(e,n){return this.x=Rn(this.x,e,n),this.y=Rn(this.y,e,n),this.z=Rn(this.z,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Rn(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 EC.copy(this).projectOnVector(e),this.sub(EC)}reflect(e){return this.sub(EC.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(Rn(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 EC=new lt,vH=new Bf;let Tn=class YZ{constructor(e,n,r,i,a,o,l,c,u){YZ.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],m=r[2],p=r[5],x=r[8],y=i[0],b=i[3],v=i[6],N=i[1],S=i[4],T=i[7],E=i[2],C=i[5],A=i[8];return a[0]=o*y+l*N+c*E,a[3]=o*b+l*S+c*C,a[6]=o*v+l*T+c*A,a[1]=u*y+d*N+f*E,a[4]=u*b+d*S+f*C,a[7]=u*v+d*T+f*A,a[2]=m*y+p*N+x*E,a[5]=m*b+p*S+x*C,a[8]=m*v+p*T+x*A,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,m=l*c-d*a,p=u*a-o*c,x=n*f+r*m+i*p;if(x===0)return this.set(0,0,0,0,0,0,0,0,0);const y=1/x;return e[0]=f*y,e[1]=(i*u-d*r)*y,e[2]=(l*r-i*o)*y,e[3]=m*y,e[4]=(d*n-i*c)*y,e[5]=(i*a-l*n)*y,e[6]=p*y,e[7]=(r*c-u*n)*y,e[8]=(o*n-r*a)*y,this}transpose(){let e;const n=this.elements;return e=n[1],n[1]=n[3],n[3]=e,e=n[2],n[2]=n[6],n[6]=e,e=n[5],n[5]=n[7],n[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const n=this.elements;return e[0]=n[0],e[1]=n[3],e[2]=n[6],e[3]=n[1],e[4]=n[4],e[5]=n[7],e[6]=n[2],e[7]=n[5],e[8]=n[8],this}setUvTransform(e,n,r,i,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(TC.makeScale(e,n)),this}rotate(e){return this.premultiply(TC.makeRotation(-e)),this}translate(e,n){return this.premultiply(TC.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 TC=new Tn,_H=new Tn().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),wH=new Tn().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function a3e(){const t={enabled:!0,workingColorSpace:yg,spaces:{},convert:function(i,a,o){return this.enabled===!1||a===o||!a||!o||(this.spaces[a].transfer===hr&&(i.r=tu(i.r),i.g=tu(i.g),i.b=tu(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===hr&&(i.r=Yp(i.r),i.g=Yp(i.g),i.b=Yp(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===xd?vS: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 I0("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),t.workingToColorSpace(i,a)},toWorkingColorSpace:function(i,a){return I0("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({[yg]:{primaries:e,whitePoint:r,transfer:vS,toXYZ:_H,fromXYZ:wH,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:bo},outputColorSpaceConfig:{drawingBufferColorSpace:bo}},[bo]:{primaries:e,whitePoint:r,transfer:hr,toXYZ:_H,fromXYZ:wH,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:bo}}}),t}const qn=a3e();function tu(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function Yp(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let Vm,s3e=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{Vm===void 0&&(Vm=wS("canvas")),Vm.width=e.width,Vm.height=e.height;const i=Vm.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),r=Vm}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=wS("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]=tu(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(tu(n[r]/255)*255):n[r]=tu(n[r]);return{data:n,width:e.width,height:e.height}}else return mn("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},o3e=0,CO=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:o3e++}),this.uuid=Dy(),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(AC(i[o].image)):a.push(AC(i[o]))}else a=AC(i);r.url=a}return n||(e.images[this.uuid]=r),r}};function AC(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?s3e.getDataURL(t):t.data?{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(mn("Texture: Unable to serialize Texture."),{})}let l3e=0;const CC=new lt;let ml=class ew extends nm{constructor(e=ew.DEFAULT_IMAGE,n=ew.DEFAULT_MAPPING,r=Wc,i=Wc,a=To,o=rf,l=nl,c=Gl,u=ew.DEFAULT_ANISOTROPY,d=xd){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:l3e++}),this.uuid=Dy(),this.name="",this.source=new CO(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 Mn(0,0),this.repeat=new Mn(1,1),this.center=new Mn(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Tn,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(CC).x}get height(){return this.source.getSize(CC).y}get depth(){return this.source.getSize(CC).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){mn(`Texture.setValues(): parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){mn(`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!==IZ)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case pP:e.x=e.x-Math.floor(e.x);break;case Wc:e.x=e.x<0?0:1;break;case gP: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 pP:e.y=e.y-Math.floor(e.y);break;case Wc:e.y=e.y<0?0:1;break;case gP: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++}};ml.DEFAULT_IMAGE=null;ml.DEFAULT_MAPPING=IZ;ml.DEFAULT_ANISOTROPY=1;let _i=class QZ{constructor(e=0,n=0,r=0,i=1){QZ.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],m=c[1],p=c[5],x=c[9],y=c[2],b=c[6],v=c[10];if(Math.abs(d-m)<.01&&Math.abs(f-y)<.01&&Math.abs(x-b)<.01){if(Math.abs(d+m)<.1&&Math.abs(f+y)<.1&&Math.abs(x+b)<.1&&Math.abs(u+p+v-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const S=(u+1)/2,T=(p+1)/2,E=(v+1)/2,C=(d+m)/4,A=(f+y)/4,O=(x+b)/4;return S>T&&S>E?S<.01?(r=0,i=.707106781,a=.707106781):(r=Math.sqrt(S),i=C/r,a=A/r):T>E?T<.01?(r=.707106781,i=0,a=.707106781):(i=Math.sqrt(T),r=C/i,a=O/i):E<.01?(r=.707106781,i=.707106781,a=0):(a=Math.sqrt(E),r=A/a,i=O/a),this.set(r,i,a,n),this}let N=Math.sqrt((b-x)*(b-x)+(f-y)*(f-y)+(m-d)*(m-d));return Math.abs(N)<.001&&(N=1),this.x=(b-x)/N,this.y=(f-y)/N,this.z=(m-d)/N,this.w=Math.acos((u+p+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=Rn(this.x,e.x,n.x),this.y=Rn(this.y,e.y,n.y),this.z=Rn(this.z,e.z,n.z),this.w=Rn(this.w,e.w,n.w),this}clampScalar(e,n){return this.x=Rn(this.x,e,n),this.y=Rn(this.y,e,n),this.z=Rn(this.z,e,n),this.w=Rn(this.w,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Rn(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}},c3e=class extends nm{constructor(e=1,n=1,r={}){super(),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:To,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 _i(0,0,e,n),this.scissorTest=!1,this.viewport=new _i(0,0,e,n);const i={width:e,height:n,depth:r.depth},a=new ml(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:To,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 CO(i)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}},$f=class extends c3e{constructor(e=1,n=1,r={}){super(e,n,r),this.isWebGLRenderTarget=!0}},ZZ=class extends ml{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=Ws,this.minFilter=Ws,this.wrapR=Wc,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},u3e=class extends ml{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=Ws,this.minFilter=Ws,this.wrapR=Wc,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},Hf=class{constructor(e=new lt(1/0,1/0,1/0),n=new lt(-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(Vo.fromArray(e,n));return this}setFromBufferAttribute(e){this.makeEmpty();for(let n=0,r=e.count;n<r;n++)this.expandByPoint(Vo.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=Vo.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,Vo):Vo.fromBufferAttribute(a,o),Vo.applyMatrix4(e.matrixWorld),this.expandByPoint(Vo);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,Vo),Vo.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(ob),N_.subVectors(this.max,ob),Gm.subVectors(e.a,ob),Wm.subVectors(e.b,ob),qm.subVectors(e.c,ob),Wu.subVectors(Wm,Gm),qu.subVectors(qm,Wm),Ah.subVectors(Gm,qm);let n=[0,-Wu.z,Wu.y,0,-qu.z,qu.y,0,-Ah.z,Ah.y,Wu.z,0,-Wu.x,qu.z,0,-qu.x,Ah.z,0,-Ah.x,-Wu.y,Wu.x,0,-qu.y,qu.x,0,-Ah.y,Ah.x,0];return!kC(n,Gm,Wm,qm,N_)||(n=[1,0,0,0,1,0,0,0,1],!kC(n,Gm,Wm,qm,N_))?!1:(M_.crossVectors(Wu,qu),n=[M_.x,M_.y,M_.z],kC(n,Gm,Wm,qm,N_))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Vo).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Vo).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:(yc[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),yc[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),yc[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),yc[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),yc[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),yc[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),yc[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),yc[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(yc),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 yc=[new lt,new lt,new lt,new lt,new lt,new lt,new lt,new lt],Vo=new lt,S_=new Hf,Gm=new lt,Wm=new lt,qm=new lt,Wu=new lt,qu=new lt,Ah=new lt,ob=new lt,N_=new lt,M_=new lt,Ch=new lt;function kC(t,e,n,r,i){for(let a=0,o=t.length-3;a<=o;a+=3){Ch.fromArray(t,a);const l=i.x*Math.abs(Ch.x)+i.y*Math.abs(Ch.y)+i.z*Math.abs(Ch.z),c=e.dot(Ch),u=n.dot(Ch),d=r.dot(Ch);if(Math.max(-Math.max(c,u,d),Math.min(c,u,d))>l)return!1}return!0}const d3e=new Hf,lb=new lt,jC=new lt;let BN=class{constructor(e=new lt,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):d3e.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;lb.subVectors(e,this.center);const n=lb.lengthSq();if(n>this.radius*this.radius){const r=Math.sqrt(n),i=(r-this.radius)*.5;this.center.addScaledVector(lb,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):(jC.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(lb.copy(e.center).add(jC)),this.expandByPoint(lb.copy(e.center).sub(jC))),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 vc=new lt,PC=new lt,E_=new lt,Ku=new lt,RC=new lt,T_=new lt,DC=new lt;let kO=class{constructor(e=new lt,n=new lt(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,vc)),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=vc.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(vc.copy(this.origin).addScaledVector(this.direction,n),vc.distanceToSquared(e))}distanceSqToSegment(e,n,r,i){PC.copy(e).add(n).multiplyScalar(.5),E_.copy(n).sub(e).normalize(),Ku.copy(this.origin).sub(PC);const a=e.distanceTo(n)*.5,o=-this.direction.dot(E_),l=Ku.dot(this.direction),c=-Ku.dot(E_),u=Ku.lengthSq(),d=Math.abs(1-o*o);let f,m,p,x;if(d>0)if(f=o*c-l,m=o*l-c,x=a*d,f>=0)if(m>=-x)if(m<=x){const y=1/d;f*=y,m*=y,p=f*(f+o*m+2*l)+m*(o*f+m+2*c)+u}else m=a,f=Math.max(0,-(o*m+l)),p=-f*f+m*(m+2*c)+u;else m=-a,f=Math.max(0,-(o*m+l)),p=-f*f+m*(m+2*c)+u;else m<=-x?(f=Math.max(0,-(-o*a+l)),m=f>0?-a:Math.min(Math.max(-a,-c),a),p=-f*f+m*(m+2*c)+u):m<=x?(f=0,m=Math.min(Math.max(-a,-c),a),p=m*(m+2*c)+u):(f=Math.max(0,-(o*a+l)),m=f>0?a:Math.min(Math.max(-a,-c),a),p=-f*f+m*(m+2*c)+u);else m=o>0?-a:a,f=Math.max(0,-(o*m+l)),p=-f*f+m*(m+2*c)+u;return r&&r.copy(this.origin).addScaledVector(this.direction,f),i&&i.copy(PC).addScaledVector(E_,m),p}intersectSphere(e,n){vc.subVectors(e.center,this.origin);const r=vc.dot(this.direction),i=vc.dot(vc)-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,m=this.origin;return u>=0?(r=(e.min.x-m.x)*u,i=(e.max.x-m.x)*u):(r=(e.max.x-m.x)*u,i=(e.min.x-m.x)*u),d>=0?(a=(e.min.y-m.y)*d,o=(e.max.y-m.y)*d):(a=(e.max.y-m.y)*d,o=(e.min.y-m.y)*d),r>o||a>i||((a>r||isNaN(r))&&(r=a),(o<i||isNaN(i))&&(i=o),f>=0?(l=(e.min.z-m.z)*f,c=(e.max.z-m.z)*f):(l=(e.max.z-m.z)*f,c=(e.min.z-m.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,vc)!==null}intersectTriangle(e,n,r,i,a){RC.subVectors(n,e),T_.subVectors(r,e),DC.crossVectors(RC,T_);let o=this.direction.dot(DC),l;if(o>0){if(i)return null;l=1}else if(o<0)l=-1,o=-o;else return null;Ku.subVectors(this.origin,e);const c=l*this.direction.dot(T_.crossVectors(Ku,T_));if(c<0)return null;const u=l*this.direction.dot(RC.cross(Ku));if(u<0||c+u>o)return null;const d=-l*Ku.dot(DC);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)}},Mi=class WP{constructor(e,n,r,i,a,o,l,c,u,d,f,m,p,x,y,b){WP.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,m,p,x,y,b)}set(e,n,r,i,a,o,l,c,u,d,f,m,p,x,y,b){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]=m,v[3]=p,v[7]=x,v[11]=y,v[15]=b,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 WP().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/Km.setFromMatrixColumn(e,0).length(),a=1/Km.setFromMatrixColumn(e,1).length(),o=1/Km.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 m=o*d,p=o*f,x=l*d,y=l*f;n[0]=c*d,n[4]=-c*f,n[8]=u,n[1]=p+x*u,n[5]=m-y*u,n[9]=-l*c,n[2]=y-m*u,n[6]=x+p*u,n[10]=o*c}else if(e.order==="YXZ"){const m=c*d,p=c*f,x=u*d,y=u*f;n[0]=m+y*l,n[4]=x*l-p,n[8]=o*u,n[1]=o*f,n[5]=o*d,n[9]=-l,n[2]=p*l-x,n[6]=y+m*l,n[10]=o*c}else if(e.order==="ZXY"){const m=c*d,p=c*f,x=u*d,y=u*f;n[0]=m-y*l,n[4]=-o*f,n[8]=x+p*l,n[1]=p+x*l,n[5]=o*d,n[9]=y-m*l,n[2]=-o*u,n[6]=l,n[10]=o*c}else if(e.order==="ZYX"){const m=o*d,p=o*f,x=l*d,y=l*f;n[0]=c*d,n[4]=x*u-p,n[8]=m*u+y,n[1]=c*f,n[5]=y*u+m,n[9]=p*u-x,n[2]=-u,n[6]=l*c,n[10]=o*c}else if(e.order==="YZX"){const m=o*c,p=o*u,x=l*c,y=l*u;n[0]=c*d,n[4]=y-m*f,n[8]=x*f+p,n[1]=f,n[5]=o*d,n[9]=-l*d,n[2]=-u*d,n[6]=p*f+x,n[10]=m-y*f}else if(e.order==="XZY"){const m=o*c,p=o*u,x=l*c,y=l*u;n[0]=c*d,n[4]=-f,n[8]=u*d,n[1]=m*f+y,n[5]=o*d,n[9]=p*f-x,n[2]=x*f-p,n[6]=l*d,n[10]=y*f+m}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(h3e,e,f3e)}lookAt(e,n,r){const i=this.elements;return Ds.subVectors(e,n),Ds.lengthSq()===0&&(Ds.z=1),Ds.normalize(),Xu.crossVectors(r,Ds),Xu.lengthSq()===0&&(Math.abs(r.z)===1?Ds.x+=1e-4:Ds.z+=1e-4,Ds.normalize(),Xu.crossVectors(r,Ds)),Xu.normalize(),A_.crossVectors(Ds,Xu),i[0]=Xu.x,i[4]=A_.x,i[8]=Ds.x,i[1]=Xu.y,i[5]=A_.y,i[9]=Ds.y,i[2]=Xu.z,i[6]=A_.z,i[10]=Ds.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],m=r[9],p=r[13],x=r[2],y=r[6],b=r[10],v=r[14],N=r[3],S=r[7],T=r[11],E=r[15],C=i[0],A=i[4],O=i[8],k=i[12],R=i[1],F=i[5],L=i[9],K=i[13],j=i[2],W=i[6],Y=i[10],q=i[14],Q=i[3],ee=i[7],re=i[11],z=i[15];return a[0]=o*C+l*R+c*j+u*Q,a[4]=o*A+l*F+c*W+u*ee,a[8]=o*O+l*L+c*Y+u*re,a[12]=o*k+l*K+c*q+u*z,a[1]=d*C+f*R+m*j+p*Q,a[5]=d*A+f*F+m*W+p*ee,a[9]=d*O+f*L+m*Y+p*re,a[13]=d*k+f*K+m*q+p*z,a[2]=x*C+y*R+b*j+v*Q,a[6]=x*A+y*F+b*W+v*ee,a[10]=x*O+y*L+b*Y+v*re,a[14]=x*k+y*K+b*q+v*z,a[3]=N*C+S*R+T*j+E*Q,a[7]=N*A+S*F+T*W+E*ee,a[11]=N*O+S*L+T*Y+E*re,a[15]=N*k+S*K+T*q+E*z,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[4]*=e,n[8]*=e,n[12]*=e,n[1]*=e,n[5]*=e,n[9]*=e,n[13]*=e,n[2]*=e,n[6]*=e,n[10]*=e,n[14]*=e,n[3]*=e,n[7]*=e,n[11]*=e,n[15]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[4],i=e[8],a=e[12],o=e[1],l=e[5],c=e[9],u=e[13],d=e[2],f=e[6],m=e[10],p=e[14],x=e[3],y=e[7],b=e[11],v=e[15];return x*(+a*c*f-i*u*f-a*l*m+r*u*m+i*l*p-r*c*p)+y*(+n*c*p-n*u*m+a*o*m-i*o*p+i*u*d-a*c*d)+b*(+n*u*f-n*l*p-a*o*f+r*o*p+a*l*d-r*u*d)+v*(-i*l*d-n*c*f+n*l*m+i*o*f-r*o*m+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],m=e[10],p=e[11],x=e[12],y=e[13],b=e[14],v=e[15],N=f*b*u-y*m*u+y*c*p-l*b*p-f*c*v+l*m*v,S=x*m*u-d*b*u-x*c*p+o*b*p+d*c*v-o*m*v,T=d*y*u-x*f*u+x*l*p-o*y*p-d*l*v+o*f*v,E=x*f*c-d*y*c-x*l*m+o*y*m+d*l*b-o*f*b,C=n*N+r*S+i*T+a*E;if(C===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const A=1/C;return e[0]=N*A,e[1]=(y*m*a-f*b*a-y*i*p+r*b*p+f*i*v-r*m*v)*A,e[2]=(l*b*a-y*c*a+y*i*u-r*b*u-l*i*v+r*c*v)*A,e[3]=(f*c*a-l*m*a-f*i*u+r*m*u+l*i*p-r*c*p)*A,e[4]=S*A,e[5]=(d*b*a-x*m*a+x*i*p-n*b*p-d*i*v+n*m*v)*A,e[6]=(x*c*a-o*b*a-x*i*u+n*b*u+o*i*v-n*c*v)*A,e[7]=(o*m*a-d*c*a+d*i*u-n*m*u-o*i*p+n*c*p)*A,e[8]=T*A,e[9]=(x*f*a-d*y*a-x*r*p+n*y*p+d*r*v-n*f*v)*A,e[10]=(o*y*a-x*l*a+x*r*u-n*y*u-o*r*v+n*l*v)*A,e[11]=(d*l*a-o*f*a-d*r*u+n*f*u+o*r*p-n*l*p)*A,e[12]=E*A,e[13]=(d*y*i-x*f*i+x*r*m-n*y*m-d*r*b+n*f*b)*A,e[14]=(x*l*i-o*y*i-x*r*c+n*y*c+o*r*b-n*l*b)*A,e[15]=(o*f*i-d*l*i+d*r*c-n*f*c-o*r*m+n*l*m)*A,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,m=a*u,p=a*d,x=a*f,y=o*d,b=o*f,v=l*f,N=c*u,S=c*d,T=c*f,E=r.x,C=r.y,A=r.z;return i[0]=(1-(y+v))*E,i[1]=(p+T)*E,i[2]=(x-S)*E,i[3]=0,i[4]=(p-T)*C,i[5]=(1-(m+v))*C,i[6]=(b+N)*C,i[7]=0,i[8]=(x+S)*A,i[9]=(b-N)*A,i[10]=(1-(m+y))*A,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=Km.set(i[0],i[1],i[2]).length();const o=Km.set(i[4],i[5],i[6]).length(),l=Km.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],Go.copy(this);const u=1/a,d=1/o,f=1/l;return Go.elements[0]*=u,Go.elements[1]*=u,Go.elements[2]*=u,Go.elements[4]*=d,Go.elements[5]*=d,Go.elements[6]*=d,Go.elements[8]*=f,Go.elements[9]*=f,Go.elements[10]*=f,n.setFromRotationMatrix(Go),r.x=a,r.y=o,r.z=l,this}makePerspective(e,n,r,i,a,o,l=Rl,c=!1){const u=this.elements,d=2*a/(n-e),f=2*a/(r-i),m=(n+e)/(n-e),p=(r+i)/(r-i);let x,y;if(c)x=a/(o-a),y=o*a/(o-a);else if(l===Rl)x=-(o+a)/(o-a),y=-2*o*a/(o-a);else if(l===_S)x=-o/(o-a),y=-o*a/(o-a);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+l);return u[0]=d,u[4]=0,u[8]=m,u[12]=0,u[1]=0,u[5]=f,u[9]=p,u[13]=0,u[2]=0,u[6]=0,u[10]=x,u[14]=y,u[3]=0,u[7]=0,u[11]=-1,u[15]=0,this}makeOrthographic(e,n,r,i,a,o,l=Rl,c=!1){const u=this.elements,d=2/(n-e),f=2/(r-i),m=-(n+e)/(n-e),p=-(r+i)/(r-i);let x,y;if(c)x=1/(o-a),y=o/(o-a);else if(l===Rl)x=-2/(o-a),y=-(o+a)/(o-a);else if(l===_S)x=-1/(o-a),y=-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]=m,u[1]=0,u[5]=f,u[9]=0,u[13]=p,u[2]=0,u[6]=0,u[10]=x,u[14]=y,u[3]=0,u[7]=0,u[11]=0,u[15]=1,this}equals(e){const n=this.elements,r=e.elements;for(let i=0;i<16;i++)if(n[i]!==r[i])return!1;return!0}fromArray(e,n=0){for(let r=0;r<16;r++)this.elements[r]=e[r+n];return this}toArray(e=[],n=0){const r=this.elements;return e[n]=r[0],e[n+1]=r[1],e[n+2]=r[2],e[n+3]=r[3],e[n+4]=r[4],e[n+5]=r[5],e[n+6]=r[6],e[n+7]=r[7],e[n+8]=r[8],e[n+9]=r[9],e[n+10]=r[10],e[n+11]=r[11],e[n+12]=r[12],e[n+13]=r[13],e[n+14]=r[14],e[n+15]=r[15],e}};const Km=new lt,Go=new Mi,h3e=new lt(0,0,0),f3e=new lt(1,1,1),Xu=new lt,A_=new lt,Ds=new lt,SH=new Mi,NH=new Bf;let Xd=class JZ{constructor(e=0,n=0,r=0,i=JZ.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],m=i[6],p=i[10];switch(n){case"XYZ":this._y=Math.asin(Rn(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-d,p),this._z=Math.atan2(-o,a)):(this._x=Math.atan2(m,u),this._z=0);break;case"YXZ":this._x=Math.asin(-Rn(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(l,p),this._z=Math.atan2(c,u)):(this._y=Math.atan2(-f,a),this._z=0);break;case"ZXY":this._x=Math.asin(Rn(m,-1,1)),Math.abs(m)<.9999999?(this._y=Math.atan2(-f,p),this._z=Math.atan2(-o,u)):(this._y=0,this._z=Math.atan2(c,a));break;case"ZYX":this._y=Math.asin(-Rn(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(m,p),this._z=Math.atan2(c,a)):(this._x=0,this._z=Math.atan2(-o,u));break;case"YZX":this._z=Math.asin(Rn(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,p));break;case"XZY":this._z=Math.asin(-Rn(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(m,u),this._y=Math.atan2(l,a)):(this._x=Math.atan2(-d,p),this._y=0);break;default:mn("Euler: .setFromRotationMatrix() encountered an unknown order: "+n)}return this._order=n,r===!0&&this._onChangeCallback(),this}setFromQuaternion(e,n,r){return SH.makeRotationFromQuaternion(e),this.setFromRotationMatrix(SH,n,r)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return NH.setFromEuler(this),this.setFromQuaternion(NH,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}};Xd.DEFAULT_ORDER="XYZ";let eJ=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}},m3e=0;const MH=new lt,Xm=new Bf,_c=new Mi,C_=new lt,cb=new lt,p3e=new lt,g3e=new Bf,EH=new lt(1,0,0),TH=new lt(0,1,0),AH=new lt(0,0,1),CH={type:"added"},x3e={type:"removed"},Ym={type:"childadded",child:null},OC={type:"childremoved",child:null};let Zs=class tw extends nm{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:m3e++}),this.uuid=Dy(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=tw.DEFAULT_UP.clone();const e=new lt,n=new Xd,r=new Bf,i=new lt(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 Mi},normalMatrix:{value:new Tn}}),this.matrix=new Mi,this.matrixWorld=new Mi,this.matrixAutoUpdate=tw.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=tw.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new eJ,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 Xm.setFromAxisAngle(e,n),this.quaternion.multiply(Xm),this}rotateOnWorldAxis(e,n){return Xm.setFromAxisAngle(e,n),this.quaternion.premultiply(Xm),this}rotateX(e){return this.rotateOnAxis(EH,e)}rotateY(e){return this.rotateOnAxis(TH,e)}rotateZ(e){return this.rotateOnAxis(AH,e)}translateOnAxis(e,n){return MH.copy(e).applyQuaternion(this.quaternion),this.position.add(MH.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(EH,e)}translateY(e){return this.translateOnAxis(TH,e)}translateZ(e){return this.translateOnAxis(AH,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(_c.copy(this.matrixWorld).invert())}lookAt(e,n,r){e.isVector3?C_.copy(e):C_.set(e,n,r);const i=this.parent;this.updateWorldMatrix(!0,!1),cb.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?_c.lookAt(cb,C_,this.up):_c.lookAt(C_,cb,this.up),this.quaternion.setFromRotationMatrix(_c),i&&(_c.extractRotation(i.matrixWorld),Xm.setFromRotationMatrix(_c),this.quaternion.premultiply(Xm.invert()))}add(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.add(arguments[n]);return this}return e===this?(ui("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(CH),Ym.child=e,this.dispatchEvent(Ym),Ym.child=null):ui("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(x3e),OC.child=e,this.dispatchEvent(OC),OC.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),_c.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),_c.multiply(e.parent.matrixWorld)),e.applyMatrix4(_c),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(CH),Ym.child=e,this.dispatchEvent(Ym),Ym.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(cb,e,p3e),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(cb,g3e,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),m=o(e.skeletons),p=o(e.animations),x=o(e.nodes);l.length>0&&(r.geometries=l),c.length>0&&(r.materials=c),u.length>0&&(r.textures=u),d.length>0&&(r.images=d),f.length>0&&(r.shapes=f),m.length>0&&(r.skeletons=m),p.length>0&&(r.animations=p),x.length>0&&(r.nodes=x)}return r.object=i,r;function o(l){const c=[];for(const u in l){const d=l[u];delete d.metadata,c.push(d)}return c}}clone(e){return new this.constructor().copy(this,e)}copy(e,n=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),n===!0)for(let r=0;r<e.children.length;r++){const i=e.children[r];this.add(i.clone())}return this}};Zs.DEFAULT_UP=new lt(0,1,0);Zs.DEFAULT_MATRIX_AUTO_UPDATE=!0;Zs.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Wo=new lt,wc=new lt,LC=new lt,Sc=new lt,Qm=new lt,Zm=new lt,kH=new lt,IC=new lt,FC=new lt,UC=new lt,zC=new _i,BC=new _i,$C=new _i;let ub=class kp{constructor(e=new lt,n=new lt,r=new lt){this.a=e,this.b=n,this.c=r}static getNormal(e,n,r,i){i.subVectors(r,n),Wo.subVectors(e,n),i.cross(Wo);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){Wo.subVectors(i,n),wc.subVectors(r,n),LC.subVectors(e,n);const o=Wo.dot(Wo),l=Wo.dot(wc),c=Wo.dot(LC),u=wc.dot(wc),d=wc.dot(LC),f=o*u-l*l;if(f===0)return a.set(0,0,0),null;const m=1/f,p=(u*c-l*d)*m,x=(o*d-l*c)*m;return a.set(1-p-x,x,p)}static containsPoint(e,n,r,i){return this.getBarycoord(e,n,r,i,Sc)===null?!1:Sc.x>=0&&Sc.y>=0&&Sc.x+Sc.y<=1}static getInterpolation(e,n,r,i,a,o,l,c){return this.getBarycoord(e,n,r,i,Sc)===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,Sc.x),c.addScaledVector(o,Sc.y),c.addScaledVector(l,Sc.z),c)}static getInterpolatedAttribute(e,n,r,i,a,o){return zC.setScalar(0),BC.setScalar(0),$C.setScalar(0),zC.fromBufferAttribute(e,n),BC.fromBufferAttribute(e,r),$C.fromBufferAttribute(e,i),o.setScalar(0),o.addScaledVector(zC,a.x),o.addScaledVector(BC,a.y),o.addScaledVector($C,a.z),o}static isFrontFacing(e,n,r,i){return Wo.subVectors(r,n),wc.subVectors(e,n),Wo.cross(wc).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 Wo.subVectors(this.c,this.b),wc.subVectors(this.a,this.b),Wo.cross(wc).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return kp.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return kp.getBarycoord(e,this.a,this.b,this.c,n)}getInterpolation(e,n,r,i,a){return kp.getInterpolation(e,this.a,this.b,this.c,n,r,i,a)}containsPoint(e){return kp.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return kp.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;Qm.subVectors(i,r),Zm.subVectors(a,r),IC.subVectors(e,r);const c=Qm.dot(IC),u=Zm.dot(IC);if(c<=0&&u<=0)return n.copy(r);FC.subVectors(e,i);const d=Qm.dot(FC),f=Zm.dot(FC);if(d>=0&&f<=d)return n.copy(i);const m=c*f-d*u;if(m<=0&&c>=0&&d<=0)return o=c/(c-d),n.copy(r).addScaledVector(Qm,o);UC.subVectors(e,a);const p=Qm.dot(UC),x=Zm.dot(UC);if(x>=0&&p<=x)return n.copy(a);const y=p*u-c*x;if(y<=0&&u>=0&&x<=0)return l=u/(u-x),n.copy(r).addScaledVector(Zm,l);const b=d*x-p*f;if(b<=0&&f-d>=0&&p-x>=0)return kH.subVectors(a,i),l=(f-d)/(f-d+(p-x)),n.copy(i).addScaledVector(kH,l);const v=1/(b+y+m);return o=y*v,l=m*v,n.copy(r).addScaledVector(Qm,o).addScaledVector(Zm,l)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}};const tJ={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},Yu={h:0,s:0,l:0},k_={h:0,s:0,l:0};function HC(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+(e-t)*6*n:n<1/2?e:n<2/3?t+(e-t)*6*(2/3-n):t}let Dn=class{constructor(e,n,r){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,n,r)}set(e,n,r){if(n===void 0&&r===void 0){const i=e;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(e,n,r);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,n=bo){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,qn.colorSpaceToWorking(this,n),this}setRGB(e,n,r,i=qn.workingColorSpace){return this.r=e,this.g=n,this.b=r,qn.colorSpaceToWorking(this,i),this}setHSL(e,n,r,i=qn.workingColorSpace){if(e=r3e(e,1),n=Rn(n,0,1),r=Rn(r,0,1),n===0)this.r=this.g=this.b=r;else{const a=r<=.5?r*(1+n):r+n-r*n,o=2*r-a;this.r=HC(o,a,e+1/3),this.g=HC(o,a,e),this.b=HC(o,a,e-1/3)}return qn.colorSpaceToWorking(this,i),this}setStyle(e,n=bo){function r(a){a!==void 0&&parseFloat(a)<1&&mn("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:mn("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);mn("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,n);return this}setColorName(e,n=bo){const r=tJ[e.toLowerCase()];return r!==void 0?this.setHex(r,n):mn("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=tu(e.r),this.g=tu(e.g),this.b=tu(e.b),this}copyLinearToSRGB(e){return this.r=Yp(e.r),this.g=Yp(e.g),this.b=Yp(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=bo){return qn.workingToColorSpace(Ea.copy(this),e),Math.round(Rn(Ea.r*255,0,255))*65536+Math.round(Rn(Ea.g*255,0,255))*256+Math.round(Rn(Ea.b*255,0,255))}getHexString(e=bo){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=qn.workingColorSpace){qn.workingToColorSpace(Ea.copy(this),n);const r=Ea.r,i=Ea.g,a=Ea.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=qn.workingColorSpace){return qn.workingToColorSpace(Ea.copy(this),n),e.r=Ea.r,e.g=Ea.g,e.b=Ea.b,e}getStyle(e=bo){qn.workingToColorSpace(Ea.copy(this),e);const n=Ea.r,r=Ea.g,i=Ea.b;return e!==bo?`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(Yu),this.setHSL(Yu.h+e,Yu.s+n,Yu.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(Yu),e.getHSL(k_);const r=MC(Yu.h,k_.h,n),i=MC(Yu.s,k_.s,n),a=MC(Yu.l,k_.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 Ea=new Dn;Dn.NAMES=tJ;let b3e=0,Jg=class extends nm{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:b3e++}),this.uuid=Dy(),this.name="",this.type="Material",this.blending=Xp,this.side=Kd,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=iP,this.blendDst=aP,this.blendEquation=Gh,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Dn(0,0,0),this.blendAlpha=0,this.depthFunc=gg,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=pH,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Hm,this.stencilZFail=Hm,this.stencilZPass=Hm,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){mn(`Material: parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){mn(`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!==Xp&&(r.blending=this.blending),this.side!==Kd&&(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!==iP&&(r.blendSrc=this.blendSrc),this.blendDst!==aP&&(r.blendDst=this.blendDst),this.blendEquation!==Gh&&(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!==gg&&(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!==pH&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Hm&&(r.stencilFail=this.stencilFail),this.stencilZFail!==Hm&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==Hm&&(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++}},jO=class extends Jg{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Dn(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Xd,this.combine=_O,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 xi=new lt,j_=new Mn;let y3e=0,Ao=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:y3e++}),this.name="",this.array=e,this.itemSize=n,this.count=e!==void 0?e.length/n:0,this.normalized=r,this.usage=gH,this.updateRanges=[],this.gpuType=qc,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++)j_.fromBufferAttribute(this,n),j_.applyMatrix3(e),this.setXY(n,j_.x,j_.y);else if(this.itemSize===3)for(let n=0,r=this.count;n<r;n++)xi.fromBufferAttribute(this,n),xi.applyMatrix3(e),this.setXYZ(n,xi.x,xi.y,xi.z);return this}applyMatrix4(e){for(let n=0,r=this.count;n<r;n++)xi.fromBufferAttribute(this,n),xi.applyMatrix4(e),this.setXYZ(n,xi.x,xi.y,xi.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)xi.fromBufferAttribute(this,n),xi.applyNormalMatrix(e),this.setXYZ(n,xi.x,xi.y,xi.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)xi.fromBufferAttribute(this,n),xi.transformDirection(e),this.setXYZ(n,xi.x,xi.y,xi.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=sb(r,this.array)),r}setComponent(e,n,r){return this.normalized&&(r=us(r,this.array)),this.array[e*this.itemSize+n]=r,this}getX(e){let n=this.array[e*this.itemSize];return this.normalized&&(n=sb(n,this.array)),n}setX(e,n){return this.normalized&&(n=us(n,this.array)),this.array[e*this.itemSize]=n,this}getY(e){let n=this.array[e*this.itemSize+1];return this.normalized&&(n=sb(n,this.array)),n}setY(e,n){return this.normalized&&(n=us(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=sb(n,this.array)),n}setZ(e,n){return this.normalized&&(n=us(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=sb(n,this.array)),n}setW(e,n){return this.normalized&&(n=us(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,r){return e*=this.itemSize,this.normalized&&(n=us(n,this.array),r=us(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=us(n,this.array),r=us(r,this.array),i=us(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=us(n,this.array),r=us(r,this.array),i=us(i,this.array),a=us(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!==gH&&(e.usage=this.usage),e}},nJ=class extends Ao{constructor(e,n,r){super(new Uint16Array(e),n,r)}},rJ=class extends Ao{constructor(e,n,r){super(new Uint32Array(e),n,r)}},sl=class extends Ao{constructor(e,n,r){super(new Float32Array(e),n,r)}},v3e=0;const uo=new Mi,VC=new Zs,Jm=new lt,Os=new Hf,db=new Hf,Gi=new lt;let ec=class iJ extends nm{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:v3e++}),this.uuid=Dy(),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(qZ(e)?rJ:nJ)(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 Tn().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 uo.makeRotationFromQuaternion(e),this.applyMatrix4(uo),this}rotateX(e){return uo.makeRotationX(e),this.applyMatrix4(uo),this}rotateY(e){return uo.makeRotationY(e),this.applyMatrix4(uo),this}rotateZ(e){return uo.makeRotationZ(e),this.applyMatrix4(uo),this}translate(e,n,r){return uo.makeTranslation(e,n,r),this.applyMatrix4(uo),this}scale(e,n,r){return uo.makeScale(e,n,r),this.applyMatrix4(uo),this}lookAt(e){return VC.lookAt(e),VC.updateMatrix(),this.applyMatrix4(VC.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Jm).negate(),this.translate(Jm.x,Jm.y,Jm.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 sl(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&&mn("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 Hf);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){ui("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new lt(-1/0,-1/0,-1/0),new lt(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];Os.setFromBufferAttribute(a),this.morphTargetsRelative?(Gi.addVectors(this.boundingBox.min,Os.min),this.boundingBox.expandByPoint(Gi),Gi.addVectors(this.boundingBox.max,Os.max),this.boundingBox.expandByPoint(Gi)):(this.boundingBox.expandByPoint(Os.min),this.boundingBox.expandByPoint(Os.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&ui('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 BN);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){ui("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new lt,1/0);return}if(e){const r=this.boundingSphere.center;if(Os.setFromBufferAttribute(e),n)for(let a=0,o=n.length;a<o;a++){const l=n[a];db.setFromBufferAttribute(l),this.morphTargetsRelative?(Gi.addVectors(Os.min,db.min),Os.expandByPoint(Gi),Gi.addVectors(Os.max,db.max),Os.expandByPoint(Gi)):(Os.expandByPoint(db.min),Os.expandByPoint(db.max))}Os.getCenter(r);let i=0;for(let a=0,o=e.count;a<o;a++)Gi.fromBufferAttribute(e,a),i=Math.max(i,r.distanceToSquared(Gi));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++)Gi.fromBufferAttribute(l,u),c&&(Jm.fromBufferAttribute(e,u),Gi.add(Jm)),i=Math.max(i,r.distanceToSquared(Gi))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&ui('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){ui("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 Ao(new Float32Array(4*r.count),4));const o=this.getAttribute("tangent"),l=[],c=[];for(let O=0;O<r.count;O++)l[O]=new lt,c[O]=new lt;const u=new lt,d=new lt,f=new lt,m=new Mn,p=new Mn,x=new Mn,y=new lt,b=new lt;function v(O,k,R){u.fromBufferAttribute(r,O),d.fromBufferAttribute(r,k),f.fromBufferAttribute(r,R),m.fromBufferAttribute(a,O),p.fromBufferAttribute(a,k),x.fromBufferAttribute(a,R),d.sub(u),f.sub(u),p.sub(m),x.sub(m);const F=1/(p.x*x.y-x.x*p.y);isFinite(F)&&(y.copy(d).multiplyScalar(x.y).addScaledVector(f,-p.y).multiplyScalar(F),b.copy(f).multiplyScalar(p.x).addScaledVector(d,-x.x).multiplyScalar(F),l[O].add(y),l[k].add(y),l[R].add(y),c[O].add(b),c[k].add(b),c[R].add(b))}let N=this.groups;N.length===0&&(N=[{start:0,count:e.count}]);for(let O=0,k=N.length;O<k;++O){const R=N[O],F=R.start,L=R.count;for(let K=F,j=F+L;K<j;K+=3)v(e.getX(K+0),e.getX(K+1),e.getX(K+2))}const S=new lt,T=new lt,E=new lt,C=new lt;function A(O){E.fromBufferAttribute(i,O),C.copy(E);const k=l[O];S.copy(k),S.sub(E.multiplyScalar(E.dot(k))).normalize(),T.crossVectors(C,k);const F=T.dot(c[O])<0?-1:1;o.setXYZW(O,S.x,S.y,S.z,F)}for(let O=0,k=N.length;O<k;++O){const R=N[O],F=R.start,L=R.count;for(let K=F,j=F+L;K<j;K+=3)A(e.getX(K+0)),A(e.getX(K+1)),A(e.getX(K+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 Ao(new Float32Array(n.count*3),3),this.setAttribute("normal",r);else for(let m=0,p=r.count;m<p;m++)r.setXYZ(m,0,0,0);const i=new lt,a=new lt,o=new lt,l=new lt,c=new lt,u=new lt,d=new lt,f=new lt;if(e)for(let m=0,p=e.count;m<p;m+=3){const x=e.getX(m+0),y=e.getX(m+1),b=e.getX(m+2);i.fromBufferAttribute(n,x),a.fromBufferAttribute(n,y),o.fromBufferAttribute(n,b),d.subVectors(o,a),f.subVectors(i,a),d.cross(f),l.fromBufferAttribute(r,x),c.fromBufferAttribute(r,y),u.fromBufferAttribute(r,b),l.add(d),c.add(d),u.add(d),r.setXYZ(x,l.x,l.y,l.z),r.setXYZ(y,c.x,c.y,c.z),r.setXYZ(b,u.x,u.y,u.z)}else for(let m=0,p=n.count;m<p;m+=3)i.fromBufferAttribute(n,m+0),a.fromBufferAttribute(n,m+1),o.fromBufferAttribute(n,m+2),d.subVectors(o,a),f.subVectors(i,a),d.cross(f),r.setXYZ(m+0,d.x,d.y,d.z),r.setXYZ(m+1,d.x,d.y,d.z),r.setXYZ(m+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++)Gi.fromBufferAttribute(e,n),Gi.normalize(),e.setXYZ(n,Gi.x,Gi.y,Gi.z)}toNonIndexed(){function e(l,c){const u=l.array,d=l.itemSize,f=l.normalized,m=new u.constructor(c.length*d);let p=0,x=0;for(let y=0,b=c.length;y<b;y++){l.isInterleavedBufferAttribute?p=c[y]*l.data.stride+l.offset:p=c[y]*d;for(let v=0;v<d;v++)m[x++]=u[p++]}return new Ao(m,d,f)}if(this.index===null)return mn("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new iJ,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 m=u[d],p=e(m,r);c.push(p)}n.morphAttributes[l]=c}n.morphTargetsRelative=this.morphTargetsRelative;const o=this.groups;for(let l=0,c=o.length;l<c;l++){const u=o[l];n.addGroup(u.start,u.count,u.materialIndex)}return n}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const c=this.parameters;for(const u in c)c[u]!==void 0&&(e[u]=c[u]);return e}e.data={attributes:{}};const n=this.index;n!==null&&(e.data.index={type:n.array.constructor.name,array:Array.prototype.slice.call(n.array)});const r=this.attributes;for(const c in r){const u=r[c];e.data.attributes[c]=u.toJSON(e.data)}const i={};let a=!1;for(const c in this.morphAttributes){const u=this.morphAttributes[c],d=[];for(let f=0,m=u.length;f<m;f++){const p=u[f];d.push(p.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 m=0,p=f.length;m<p;m++)d.push(f[m].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 jH=new Mi,kh=new kO,P_=new BN,PH=new lt,R_=new lt,D_=new lt,O_=new lt,GC=new lt,L_=new lt,RH=new lt,I_=new lt;let Wl=class extends Zs{constructor(e=new ec,n=new jO){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){L_.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?L_.addScaledVector(GC,d):L_.addScaledVector(GC.sub(n),d))}n.add(L_)}return n}raycast(e,n){const r=this.geometry,i=this.material,a=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),P_.copy(r.boundingSphere),P_.applyMatrix4(a),kh.copy(e.ray).recast(e.near),!(P_.containsPoint(kh.origin)===!1&&(kh.intersectSphere(P_,PH)===null||kh.origin.distanceToSquared(PH)>(e.far-e.near)**2))&&(jH.copy(a).invert(),kh.copy(e.ray).applyMatrix4(jH),!(r.boundingBox!==null&&kh.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,n,kh)))}_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,m=a.groups,p=a.drawRange;if(l!==null)if(Array.isArray(o))for(let x=0,y=m.length;x<y;x++){const b=m[x],v=o[b.materialIndex],N=Math.max(b.start,p.start),S=Math.min(l.count,Math.min(b.start+b.count,p.start+p.count));for(let T=N,E=S;T<E;T+=3){const C=l.getX(T),A=l.getX(T+1),O=l.getX(T+2);i=F_(this,v,e,r,u,d,f,C,A,O),i&&(i.faceIndex=Math.floor(T/3),i.face.materialIndex=b.materialIndex,n.push(i))}}else{const x=Math.max(0,p.start),y=Math.min(l.count,p.start+p.count);for(let b=x,v=y;b<v;b+=3){const N=l.getX(b),S=l.getX(b+1),T=l.getX(b+2);i=F_(this,o,e,r,u,d,f,N,S,T),i&&(i.faceIndex=Math.floor(b/3),n.push(i))}}else if(c!==void 0)if(Array.isArray(o))for(let x=0,y=m.length;x<y;x++){const b=m[x],v=o[b.materialIndex],N=Math.max(b.start,p.start),S=Math.min(c.count,Math.min(b.start+b.count,p.start+p.count));for(let T=N,E=S;T<E;T+=3){const C=T,A=T+1,O=T+2;i=F_(this,v,e,r,u,d,f,C,A,O),i&&(i.faceIndex=Math.floor(T/3),i.face.materialIndex=b.materialIndex,n.push(i))}}else{const x=Math.max(0,p.start),y=Math.min(c.count,p.start+p.count);for(let b=x,v=y;b<v;b+=3){const N=b,S=b+1,T=b+2;i=F_(this,o,e,r,u,d,f,N,S,T),i&&(i.faceIndex=Math.floor(b/3),n.push(i))}}}};function _3e(t,e,n,r,i,a,o,l){let c;if(e.side===bs?c=r.intersectTriangle(o,a,i,!0,l):c=r.intersectTriangle(i,a,o,e.side===Kd,l),c===null)return null;I_.copy(l),I_.applyMatrix4(t.matrixWorld);const u=n.ray.origin.distanceTo(I_);return u<n.near||u>n.far?null:{distance:u,point:I_.clone(),object:t}}function F_(t,e,n,r,i,a,o,l,c,u){t.getVertexPosition(l,R_),t.getVertexPosition(c,D_),t.getVertexPosition(u,O_);const d=_3e(t,e,n,r,R_,D_,O_,RH);if(d){const f=new lt;ub.getBarycoord(RH,R_,D_,O_,f),i&&(d.uv=ub.getInterpolatedAttribute(i,l,c,u,f,new Mn)),a&&(d.uv1=ub.getInterpolatedAttribute(a,l,c,u,f,new Mn)),o&&(d.normal=ub.getInterpolatedAttribute(o,l,c,u,f,new lt),d.normal.dot(r.direction)>0&&d.normal.multiplyScalar(-1));const m={a:l,b:c,c:u,normal:new lt,materialIndex:0};ub.getNormal(R_,D_,O_,m.normal),d.face=m,d.barycoord=f}return d}let PO=class aJ extends ec{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 m=0,p=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 sl(u,3)),this.setAttribute("normal",new sl(d,3)),this.setAttribute("uv",new sl(f,2));function x(y,b,v,N,S,T,E,C,A,O,k){const R=T/A,F=E/O,L=T/2,K=E/2,j=C/2,W=A+1,Y=O+1;let q=0,Q=0;const ee=new lt;for(let re=0;re<Y;re++){const z=re*F-K;for(let G=0;G<W;G++){const ae=G*R-L;ee[y]=ae*N,ee[b]=z*S,ee[v]=j,u.push(ee.x,ee.y,ee.z),ee[y]=0,ee[b]=0,ee[v]=C>0?1:-1,d.push(ee.x,ee.y,ee.z),f.push(G/A),f.push(1-re/O),q+=1}}for(let re=0;re<O;re++)for(let z=0;z<A;z++){const G=m+z+W*re,ae=m+z+W*(re+1),se=m+(z+1)+W*(re+1),ue=m+(z+1)+W*re;c.push(G,ae,ue),c.push(ae,se,ue),Q+=6}l.addGroup(p,Q,k),p+=Q,m+=q}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new aJ(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};function vg(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?(mn("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 $a(t){const e={};for(let n=0;n<t.length;n++){const r=vg(t[n]);for(const i in r)e[i]=r[i]}return e}function w3e(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function sJ(t){const e=t.getRenderTarget();return e===null?t.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:qn.workingColorSpace}const S3e={clone:vg,merge:$a};var N3e=`void main() {
  91. gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
  92. }`,M3e=`void main() {
  93. gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
  94. }`;let mu=class extends Jg{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=N3e,this.fragmentShader=M3e,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=vg(e.uniforms),this.uniformsGroups=w3e(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}},oJ=class extends Zs{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Mi,this.projectionMatrix=new Mi,this.projectionMatrixInverse=new Mi,this.coordinateSystem=Rl,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 Qu=new lt,DH=new Mn,OH=new Mn;let _o=class extends oJ{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=GP*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(J1*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return GP*2*Math.atan(Math.tan(J1*.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){Qu.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(Qu.x,Qu.y).multiplyScalar(-e/Qu.z),Qu.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),r.set(Qu.x,Qu.y).multiplyScalar(-e/Qu.z)}getViewSize(e,n){return this.getViewBounds(e,DH,OH),n.subVectors(OH,DH)}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(J1*.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 ep=-90,tp=1;let E3e=class extends Zs{constructor(e,n,r){super(),this.type="CubeCamera",this.renderTarget=r,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new _o(ep,tp,e,n);i.layers=this.layers,this.add(i);const a=new _o(ep,tp,e,n);a.layers=this.layers,this.add(a);const o=new _o(ep,tp,e,n);o.layers=this.layers,this.add(o);const l=new _o(ep,tp,e,n);l.layers=this.layers,this.add(l);const c=new _o(ep,tp,e,n);c.layers=this.layers,this.add(c);const u=new _o(ep,tp,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===Rl)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===_S)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(),m=e.getActiveCubeFace(),p=e.getActiveMipmapLevel(),x=e.xr.enabled;e.xr.enabled=!1;const y=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=y,e.setRenderTarget(r,5,i),e.render(n,d),e.setRenderTarget(f,m,p),e.xr.enabled=x,r.texture.needsPMREMUpdate=!0}},lJ=class extends ml{constructor(e=[],n=xg,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}},T3e=class extends $f{constructor(e=1,n={}){super(e,e,n),this.isWebGLCubeRenderTarget=!0;const r={width:e,height:e,depth:1},i=[r,r,r,r,r,r];this.texture=new lJ(i),this._setTextureOptions(n),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,n){this.texture.type=n.type,this.texture.colorSpace=n.colorSpace,this.texture.generateMipmaps=n.generateMipmaps,this.texture.minFilter=n.minFilter,this.texture.magFilter=n.magFilter;const r={uniforms:{tEquirect:{value:null}},vertexShader:`
  95. varying vec3 vWorldDirection;
  96. vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
  97. return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
  98. }
  99. void main() {
  100. vWorldDirection = transformDirection( position, modelMatrix );
  101. #include <begin_vertex>
  102. #include <project_vertex>
  103. }
  104. `,fragmentShader:`
  105. uniform sampler2D tEquirect;
  106. varying vec3 vWorldDirection;
  107. #include <common>
  108. void main() {
  109. vec3 direction = normalize( vWorldDirection );
  110. vec2 sampleUV = equirectUv( direction );
  111. gl_FragColor = texture2D( tEquirect, sampleUV );
  112. }
  113. `},i=new PO(5,5,5),a=new mu({name:"CubemapFromEquirect",uniforms:vg(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:bs,blending:eu});a.uniforms.tEquirect.value=n;const o=new Wl(i,a),l=n.minFilter;return n.minFilter===rf&&(n.minFilter=To),new E3e(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)}},Ab=class extends Zs{constructor(){super(),this.isGroup=!0,this.type="Group"}};const A3e={type:"move"};let WC=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Ab,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 Ab,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new lt,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new lt),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Ab,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new lt,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new lt),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 y of e.hand.values()){const b=n.getJointPose(y,r),v=this._getHandJoint(u,y);b!==null&&(v.matrix.fromArray(b.transform.matrix),v.matrix.decompose(v.position,v.rotation,v.scale),v.matrixWorldNeedsUpdate=!0,v.jointRadius=b.radius),v.visible=b!==null}const d=u.joints["index-finger-tip"],f=u.joints["thumb-tip"],m=d.position.distanceTo(f.position),p=.02,x=.005;u.inputState.pinching&&m>p+x?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!u.inputState.pinching&&m<=p-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(A3e)))}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 Ab;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[n.jointName]=r,e.add(r)}return e.joints[n.jointName]}},C3e=class extends Zs{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 Xd,this.environmentIntensity=1,this.environmentRotation=new Xd,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}},k3e=class extends ml{constructor(e=null,n=1,r=1,i,a,o,l,c,u=Ws,d=Ws,f,m){super(null,o,l,c,u,d,i,a,f,m),this.isDataTexture=!0,this.image={data:e,width:n,height:r},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};const qC=new lt,j3e=new lt,P3e=new Tn;let ud=class{constructor(e=new lt(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(j3e.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||P3e.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 jh=new BN,R3e=new Mn(.5,.5),U_=new lt;let RO=class{constructor(e=new ud,n=new ud,r=new ud,i=new ud,a=new ud,o=new ud){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=Rl,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],m=a[6],p=a[7],x=a[8],y=a[9],b=a[10],v=a[11],N=a[12],S=a[13],T=a[14],E=a[15];if(i[0].setComponents(u-o,p-d,v-x,E-N).normalize(),i[1].setComponents(u+o,p+d,v+x,E+N).normalize(),i[2].setComponents(u+l,p+f,v+y,E+S).normalize(),i[3].setComponents(u-l,p-f,v-y,E-S).normalize(),r)i[4].setComponents(c,m,b,T).normalize(),i[5].setComponents(u-c,p-m,v-b,E-T).normalize();else if(i[4].setComponents(u-c,p-m,v-b,E-T).normalize(),n===Rl)i[5].setComponents(u+c,p+m,v+b,E+T).normalize();else if(n===_S)i[5].setComponents(c,m,b,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(),jh.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),jh.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(jh)}intersectsSprite(e){jh.center.set(0,0,0);const n=R3e.distanceTo(e.center);return jh.radius=.7071067811865476+n,jh.applyMatrix4(e.matrixWorld),this.intersectsSphere(jh)}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(U_.x=i.normal.x>0?e.max.x:e.min.x,U_.y=i.normal.y>0?e.max.y:e.min.y,U_.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(U_)<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)}},cJ=class extends Jg{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Dn(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}};const SS=new lt,NS=new lt,LH=new Mi,hb=new kO,z_=new BN,KC=new lt,IH=new lt;let D3e=class extends Zs{constructor(e=new ec,n=new cJ){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++)SS.fromBufferAttribute(n,i-1),NS.fromBufferAttribute(n,i),r[i]=r[i-1],r[i]+=SS.distanceTo(NS);e.setAttribute("lineDistance",new sl(r,1))}else mn("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(),z_.copy(r.boundingSphere),z_.applyMatrix4(i),z_.radius+=a,e.ray.intersectsSphere(z_)===!1)return;LH.copy(i).invert(),hb.copy(e.ray).applyMatrix4(LH);const l=a/((this.scale.x+this.scale.y+this.scale.z)/3),c=l*l,u=this.isLineSegments?2:1,d=r.index,m=r.attributes.position;if(d!==null){const p=Math.max(0,o.start),x=Math.min(d.count,o.start+o.count);for(let y=p,b=x-1;y<b;y+=u){const v=d.getX(y),N=d.getX(y+1),S=B_(this,e,hb,c,v,N,y);S&&n.push(S)}if(this.isLineLoop){const y=d.getX(x-1),b=d.getX(p),v=B_(this,e,hb,c,y,b,x-1);v&&n.push(v)}}else{const p=Math.max(0,o.start),x=Math.min(m.count,o.start+o.count);for(let y=p,b=x-1;y<b;y+=u){const v=B_(this,e,hb,c,y,y+1,y);v&&n.push(v)}if(this.isLineLoop){const y=B_(this,e,hb,c,x-1,p,x-1);y&&n.push(y)}}}updateMorphTargets(){const n=this.geometry.morphAttributes,r=Object.keys(n);if(r.length>0){const i=n[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let a=0,o=i.length;a<o;a++){const l=i[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[l]=a}}}}};function B_(t,e,n,r,i,a,o){const l=t.geometry.attributes.position;if(SS.fromBufferAttribute(l,i),NS.fromBufferAttribute(l,a),n.distanceSqToSegment(SS,NS,KC,IH)>r)return;KC.applyMatrix4(t.matrixWorld);const u=e.ray.origin.distanceTo(KC);if(!(u<e.near||u>e.far))return{distance:u,point:IH.clone().applyMatrix4(t.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:t}}const FH=new lt,UH=new lt;let O3e=class extends D3e{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)FH.fromBufferAttribute(n,i),UH.fromBufferAttribute(n,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+FH.distanceTo(UH);e.setAttribute("lineDistance",new sl(r,1))}else mn("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},uJ=class extends ml{constructor(e,n,r=zf,i,a,o,l=Ws,c=Ws,u,d=O0,f=1){if(d!==O0&&d!==L0)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const m={width:e,height:n,depth:f};super(m,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 CO(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 dJ extends ml{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}let DO=class hJ extends ec{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,m=n/c,p=[],x=[],y=[],b=[];for(let v=0;v<d;v++){const N=v*m-o;for(let S=0;S<u;S++){const T=S*f-a;x.push(T,-N,0),y.push(0,0,1),b.push(S/l),b.push(1-v/c)}}for(let v=0;v<c;v++)for(let N=0;N<l;N++){const S=N+u*v,T=N+u*(v+1),E=N+1+u*(v+1),C=N+1+u*v;p.push(S,T,C),p.push(T,E,C)}this.setIndex(p),this.setAttribute("position",new sl(x,3)),this.setAttribute("normal",new sl(y,3)),this.setAttribute("uv",new sl(b,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new hJ(e.width,e.height,e.widthSegments,e.heightSegments)}};class L3e extends Jg{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Dn(16777215),this.specular=new Dn(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Dn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=GZ,this.normalScale=new Mn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Xd,this.combine=_O,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 I3e=class extends Jg{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Gje,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}},F3e=class extends Jg{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}},fJ=class extends Zs{constructor(e,n=1){super(),this.isLight=!0,this.type="Light",this.color=new Dn(e),this.intensity=n}dispose(){}copy(e,n){return super.copy(e,n),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const n=super.toJSON(e);return n.object.color=this.color.getHex(),n.object.intensity=this.intensity,this.groundColor!==void 0&&(n.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(n.object.distance=this.distance),this.angle!==void 0&&(n.object.angle=this.angle),this.decay!==void 0&&(n.object.decay=this.decay),this.penumbra!==void 0&&(n.object.penumbra=this.penumbra),this.shadow!==void 0&&(n.object.shadow=this.shadow.toJSON()),this.target!==void 0&&(n.object.target=this.target.uuid),n}};const XC=new Mi,zH=new lt,BH=new lt;let U3e=class{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Mn(512,512),this.mapType=Gl,this.map=null,this.mapPass=null,this.matrix=new Mi,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new RO,this._frameExtents=new Mn(1,1),this._viewportCount=1,this._viewports=[new _i(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const n=this.camera,r=this.matrix;zH.setFromMatrixPosition(e.matrixWorld),n.position.copy(zH),BH.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(BH),n.updateMatrixWorld(),XC.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(XC,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(XC)}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}},mJ=class extends oJ{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 z3e extends U3e{constructor(){super(new mJ(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class $H extends fJ{constructor(e,n){super(e,n),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Zs.DEFAULT_UP),this.updateMatrix(),this.target=new Zs,this.shadow=new z3e}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}let B3e=class extends fJ{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}},$3e=class extends _o{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}},HH=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=Rn(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(Rn(n/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};class H3e extends O3e{constructor(e=10,n=10,r=4473924,i=8947848){r=new Dn(r),i=new Dn(i);const a=n/2,o=e/n,l=e/2,c=[],u=[];for(let m=0,p=0,x=-l;m<=n;m++,x+=o){c.push(-l,0,x,l,0,x),c.push(x,0,-l,x,0,l);const y=m===a?r:i;y.toArray(u,p),p+=3,y.toArray(u,p),p+=3,y.toArray(u,p),p+=3,y.toArray(u,p),p+=3}const d=new ec;d.setAttribute("position",new sl(c,3)),d.setAttribute("color",new sl(u,3));const f=new cJ({vertexColors:!0,toneMapped:!1});super(d,f),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class V3e extends nm{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){mn("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function VH(t,e,n,r){const i=G3e(r);switch(n){case $Z:return t*e;case VZ:return t*e/i.components*i.byteLength;case MO:return t*e/i.components*i.byteLength;case EO:return t*e*2/i.components*i.byteLength;case TO:return t*e*2/i.components*i.byteLength;case HZ:return t*e*3/i.components*i.byteLength;case nl:return t*e*4/i.components*i.byteLength;case AO:return t*e*4/i.components*i.byteLength;case X1:case Y1:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case Q1:case Z1:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case bP:case vP:return Math.max(t,16)*Math.max(e,8)/4;case xP:case yP:return Math.max(t,8)*Math.max(e,8)/2;case _P:case wP:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case SP:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case NP:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case MP:return Math.floor((t+4)/5)*Math.floor((e+3)/4)*16;case EP:return Math.floor((t+4)/5)*Math.floor((e+4)/5)*16;case TP:return Math.floor((t+5)/6)*Math.floor((e+4)/5)*16;case AP:return Math.floor((t+5)/6)*Math.floor((e+5)/6)*16;case CP:return Math.floor((t+7)/8)*Math.floor((e+4)/5)*16;case kP:return Math.floor((t+7)/8)*Math.floor((e+5)/6)*16;case jP:return Math.floor((t+7)/8)*Math.floor((e+7)/8)*16;case PP:return Math.floor((t+9)/10)*Math.floor((e+4)/5)*16;case RP:return Math.floor((t+9)/10)*Math.floor((e+5)/6)*16;case DP:return Math.floor((t+9)/10)*Math.floor((e+7)/8)*16;case OP:return Math.floor((t+9)/10)*Math.floor((e+9)/10)*16;case LP:return Math.floor((t+11)/12)*Math.floor((e+9)/10)*16;case IP:return Math.floor((t+11)/12)*Math.floor((e+11)/12)*16;case FP:case UP:case zP:return Math.ceil(t/4)*Math.ceil(e/4)*16;case BP:case $P:return Math.ceil(t/4)*Math.ceil(e/4)*8;case HP:case VP:return Math.ceil(t/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${n} format.`)}function G3e(t){switch(t){case Gl:case FZ:return{byteLength:1,components:1};case R0:case UZ:case Zg:return{byteLength:2,components:1};case SO:case NO:return{byteLength:2,components:4};case zf:case wO:case qc:return{byteLength:4,components:1};case zZ:case BZ:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${t}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:vO}}));typeof window<"u"&&(window.__THREE__?mn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=vO);function pJ(){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 W3e(t){const e=new WeakMap;function n(l,c){const u=l.array,d=l.usage,f=u.byteLength,m=t.createBuffer();t.bindBuffer(c,m),t.bufferData(c,u,d),l.onUploadCallback();let p;if(u instanceof Float32Array)p=t.FLOAT;else if(typeof Float16Array<"u"&&u instanceof Float16Array)p=t.HALF_FLOAT;else if(u instanceof Uint16Array)l.isFloat16BufferAttribute?p=t.HALF_FLOAT:p=t.UNSIGNED_SHORT;else if(u instanceof Int16Array)p=t.SHORT;else if(u instanceof Uint32Array)p=t.UNSIGNED_INT;else if(u instanceof Int32Array)p=t.INT;else if(u instanceof Int8Array)p=t.BYTE;else if(u instanceof Uint8Array)p=t.UNSIGNED_BYTE;else if(u instanceof Uint8ClampedArray)p=t.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+u);return{buffer:m,type:p,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((p,x)=>p.start-x.start);let m=0;for(let p=1;p<f.length;p++){const x=f[m],y=f[p];y.start<=x.start+x.count+1?x.count=Math.max(x.count,y.start+y.count-x.start):(++m,f[m]=y)}f.length=m+1;for(let p=0,x=f.length;p<x;p++){const y=f[p];t.bufferSubData(u,y.start*d.BYTES_PER_ELEMENT,d,y.start,y.count)}c.clearUpdateRanges()}c.onUploadCallback()}function i(l){return l.isInterleavedBufferAttribute&&(l=l.data),e.get(l)}function 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 q3e=`#ifdef USE_ALPHAHASH
  114. if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
  115. #endif`,K3e=`#ifdef USE_ALPHAHASH
  116. const float ALPHA_HASH_SCALE = 0.05;
  117. float hash2D( vec2 value ) {
  118. return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
  119. }
  120. float hash3D( vec3 value ) {
  121. return hash2D( vec2( hash2D( value.xy ), value.z ) );
  122. }
  123. float getAlphaHashThreshold( vec3 position ) {
  124. float maxDeriv = max(
  125. length( dFdx( position.xyz ) ),
  126. length( dFdy( position.xyz ) )
  127. );
  128. float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
  129. vec2 pixScales = vec2(
  130. exp2( floor( log2( pixScale ) ) ),
  131. exp2( ceil( log2( pixScale ) ) )
  132. );
  133. vec2 alpha = vec2(
  134. hash3D( floor( pixScales.x * position.xyz ) ),
  135. hash3D( floor( pixScales.y * position.xyz ) )
  136. );
  137. float lerpFactor = fract( log2( pixScale ) );
  138. float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
  139. float a = min( lerpFactor, 1.0 - lerpFactor );
  140. vec3 cases = vec3(
  141. x * x / ( 2.0 * a * ( 1.0 - a ) ),
  142. ( x - 0.5 * a ) / ( 1.0 - a ),
  143. 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
  144. );
  145. float threshold = ( x < ( 1.0 - a ) )
  146. ? ( ( x < a ) ? cases.x : cases.y )
  147. : cases.z;
  148. return clamp( threshold , 1.0e-6, 1.0 );
  149. }
  150. #endif`,X3e=`#ifdef USE_ALPHAMAP
  151. diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
  152. #endif`,Y3e=`#ifdef USE_ALPHAMAP
  153. uniform sampler2D alphaMap;
  154. #endif`,Q3e=`#ifdef USE_ALPHATEST
  155. #ifdef ALPHA_TO_COVERAGE
  156. diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
  157. if ( diffuseColor.a == 0.0 ) discard;
  158. #else
  159. if ( diffuseColor.a < alphaTest ) discard;
  160. #endif
  161. #endif`,Z3e=`#ifdef USE_ALPHATEST
  162. uniform float alphaTest;
  163. #endif`,J3e=`#ifdef USE_AOMAP
  164. float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
  165. reflectedLight.indirectDiffuse *= ambientOcclusion;
  166. #if defined( USE_CLEARCOAT )
  167. clearcoatSpecularIndirect *= ambientOcclusion;
  168. #endif
  169. #if defined( USE_SHEEN )
  170. sheenSpecularIndirect *= ambientOcclusion;
  171. #endif
  172. #if defined( USE_ENVMAP ) && defined( STANDARD )
  173. float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
  174. reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
  175. #endif
  176. #endif`,ePe=`#ifdef USE_AOMAP
  177. uniform sampler2D aoMap;
  178. uniform float aoMapIntensity;
  179. #endif`,tPe=`#ifdef USE_BATCHING
  180. #if ! defined( GL_ANGLE_multi_draw )
  181. #define gl_DrawID _gl_DrawID
  182. uniform int _gl_DrawID;
  183. #endif
  184. uniform highp sampler2D batchingTexture;
  185. uniform highp usampler2D batchingIdTexture;
  186. mat4 getBatchingMatrix( const in float i ) {
  187. int size = textureSize( batchingTexture, 0 ).x;
  188. int j = int( i ) * 4;
  189. int x = j % size;
  190. int y = j / size;
  191. vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
  192. vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
  193. vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
  194. vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
  195. return mat4( v1, v2, v3, v4 );
  196. }
  197. float getIndirectIndex( const in int i ) {
  198. int size = textureSize( batchingIdTexture, 0 ).x;
  199. int x = i % size;
  200. int y = i / size;
  201. return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );
  202. }
  203. #endif
  204. #ifdef USE_BATCHING_COLOR
  205. uniform sampler2D batchingColorTexture;
  206. vec3 getBatchingColor( const in float i ) {
  207. int size = textureSize( batchingColorTexture, 0 ).x;
  208. int j = int( i );
  209. int x = j % size;
  210. int y = j / size;
  211. return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;
  212. }
  213. #endif`,nPe=`#ifdef USE_BATCHING
  214. mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
  215. #endif`,rPe=`vec3 transformed = vec3( position );
  216. #ifdef USE_ALPHAHASH
  217. vPosition = vec3( position );
  218. #endif`,iPe=`vec3 objectNormal = vec3( normal );
  219. #ifdef USE_TANGENT
  220. vec3 objectTangent = vec3( tangent.xyz );
  221. #endif`,aPe=`float G_BlinnPhong_Implicit( ) {
  222. return 0.25;
  223. }
  224. float D_BlinnPhong( const in float shininess, const in float dotNH ) {
  225. return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
  226. }
  227. vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
  228. vec3 halfDir = normalize( lightDir + viewDir );
  229. float dotNH = saturate( dot( normal, halfDir ) );
  230. float dotVH = saturate( dot( viewDir, halfDir ) );
  231. vec3 F = F_Schlick( specularColor, 1.0, dotVH );
  232. float G = G_BlinnPhong_Implicit( );
  233. float D = D_BlinnPhong( shininess, dotNH );
  234. return F * ( G * D );
  235. } // validated`,sPe=`#ifdef USE_IRIDESCENCE
  236. const mat3 XYZ_TO_REC709 = mat3(
  237. 3.2404542, -0.9692660, 0.0556434,
  238. -1.5371385, 1.8760108, -0.2040259,
  239. -0.4985314, 0.0415560, 1.0572252
  240. );
  241. vec3 Fresnel0ToIor( vec3 fresnel0 ) {
  242. vec3 sqrtF0 = sqrt( fresnel0 );
  243. return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
  244. }
  245. vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
  246. return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
  247. }
  248. float IorToFresnel0( float transmittedIor, float incidentIor ) {
  249. return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
  250. }
  251. vec3 evalSensitivity( float OPD, vec3 shift ) {
  252. float phase = 2.0 * PI * OPD * 1.0e-9;
  253. vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
  254. vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
  255. vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
  256. vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
  257. xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );
  258. xyz /= 1.0685e-7;
  259. vec3 rgb = XYZ_TO_REC709 * xyz;
  260. return rgb;
  261. }
  262. vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
  263. vec3 I;
  264. float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
  265. float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
  266. float cosTheta2Sq = 1.0 - sinTheta2Sq;
  267. if ( cosTheta2Sq < 0.0 ) {
  268. return vec3( 1.0 );
  269. }
  270. float cosTheta2 = sqrt( cosTheta2Sq );
  271. float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
  272. float R12 = F_Schlick( R0, 1.0, cosTheta1 );
  273. float T121 = 1.0 - R12;
  274. float phi12 = 0.0;
  275. if ( iridescenceIOR < outsideIOR ) phi12 = PI;
  276. float phi21 = PI - phi12;
  277. vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
  278. vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
  279. vec3 phi23 = vec3( 0.0 );
  280. if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
  281. if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
  282. if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
  283. float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
  284. vec3 phi = vec3( phi21 ) + phi23;
  285. vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
  286. vec3 r123 = sqrt( R123 );
  287. vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
  288. vec3 C0 = R12 + Rs;
  289. I = C0;
  290. vec3 Cm = Rs - T121;
  291. for ( int m = 1; m <= 2; ++ m ) {
  292. Cm *= r123;
  293. vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
  294. I += Cm * Sm;
  295. }
  296. return max( I, vec3( 0.0 ) );
  297. }
  298. #endif`,oPe=`#ifdef USE_BUMPMAP
  299. uniform sampler2D bumpMap;
  300. uniform float bumpScale;
  301. vec2 dHdxy_fwd() {
  302. vec2 dSTdx = dFdx( vBumpMapUv );
  303. vec2 dSTdy = dFdy( vBumpMapUv );
  304. float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
  305. float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
  306. float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
  307. return vec2( dBx, dBy );
  308. }
  309. vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
  310. vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
  311. vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
  312. vec3 vN = surf_norm;
  313. vec3 R1 = cross( vSigmaY, vN );
  314. vec3 R2 = cross( vN, vSigmaX );
  315. float fDet = dot( vSigmaX, R1 ) * faceDirection;
  316. vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
  317. return normalize( abs( fDet ) * surf_norm - vGrad );
  318. }
  319. #endif`,lPe=`#if NUM_CLIPPING_PLANES > 0
  320. vec4 plane;
  321. #ifdef ALPHA_TO_COVERAGE
  322. float distanceToPlane, distanceGradient;
  323. float clipOpacity = 1.0;
  324. #pragma unroll_loop_start
  325. for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
  326. plane = clippingPlanes[ i ];
  327. distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
  328. distanceGradient = fwidth( distanceToPlane ) / 2.0;
  329. clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
  330. if ( clipOpacity == 0.0 ) discard;
  331. }
  332. #pragma unroll_loop_end
  333. #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
  334. float unionClipOpacity = 1.0;
  335. #pragma unroll_loop_start
  336. for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
  337. plane = clippingPlanes[ i ];
  338. distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
  339. distanceGradient = fwidth( distanceToPlane ) / 2.0;
  340. unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
  341. }
  342. #pragma unroll_loop_end
  343. clipOpacity *= 1.0 - unionClipOpacity;
  344. #endif
  345. diffuseColor.a *= clipOpacity;
  346. if ( diffuseColor.a == 0.0 ) discard;
  347. #else
  348. #pragma unroll_loop_start
  349. for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
  350. plane = clippingPlanes[ i ];
  351. if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
  352. }
  353. #pragma unroll_loop_end
  354. #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
  355. bool clipped = true;
  356. #pragma unroll_loop_start
  357. for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
  358. plane = clippingPlanes[ i ];
  359. clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
  360. }
  361. #pragma unroll_loop_end
  362. if ( clipped ) discard;
  363. #endif
  364. #endif
  365. #endif`,cPe=`#if NUM_CLIPPING_PLANES > 0
  366. varying vec3 vClipPosition;
  367. uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
  368. #endif`,uPe=`#if NUM_CLIPPING_PLANES > 0
  369. varying vec3 vClipPosition;
  370. #endif`,dPe=`#if NUM_CLIPPING_PLANES > 0
  371. vClipPosition = - mvPosition.xyz;
  372. #endif`,hPe=`#if defined( USE_COLOR_ALPHA )
  373. diffuseColor *= vColor;
  374. #elif defined( USE_COLOR )
  375. diffuseColor.rgb *= vColor;
  376. #endif`,fPe=`#if defined( USE_COLOR_ALPHA )
  377. varying vec4 vColor;
  378. #elif defined( USE_COLOR )
  379. varying vec3 vColor;
  380. #endif`,mPe=`#if defined( USE_COLOR_ALPHA )
  381. varying vec4 vColor;
  382. #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
  383. varying vec3 vColor;
  384. #endif`,pPe=`#if defined( USE_COLOR_ALPHA )
  385. vColor = vec4( 1.0 );
  386. #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
  387. vColor = vec3( 1.0 );
  388. #endif
  389. #ifdef USE_COLOR
  390. vColor *= color;
  391. #endif
  392. #ifdef USE_INSTANCING_COLOR
  393. vColor.xyz *= instanceColor.xyz;
  394. #endif
  395. #ifdef USE_BATCHING_COLOR
  396. vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );
  397. vColor.xyz *= batchingColor.xyz;
  398. #endif`,gPe=`#define PI 3.141592653589793
  399. #define PI2 6.283185307179586
  400. #define PI_HALF 1.5707963267948966
  401. #define RECIPROCAL_PI 0.3183098861837907
  402. #define RECIPROCAL_PI2 0.15915494309189535
  403. #define EPSILON 1e-6
  404. #ifndef saturate
  405. #define saturate( a ) clamp( a, 0.0, 1.0 )
  406. #endif
  407. #define whiteComplement( a ) ( 1.0 - saturate( a ) )
  408. float pow2( const in float x ) { return x*x; }
  409. vec3 pow2( const in vec3 x ) { return x*x; }
  410. float pow3( const in float x ) { return x*x*x; }
  411. float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
  412. float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
  413. float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
  414. highp float rand( const in vec2 uv ) {
  415. const highp float a = 12.9898, b = 78.233, c = 43758.5453;
  416. highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
  417. return fract( sin( sn ) * c );
  418. }
  419. #ifdef HIGH_PRECISION
  420. float precisionSafeLength( vec3 v ) { return length( v ); }
  421. #else
  422. float precisionSafeLength( vec3 v ) {
  423. float maxComponent = max3( abs( v ) );
  424. return length( v / maxComponent ) * maxComponent;
  425. }
  426. #endif
  427. struct IncidentLight {
  428. vec3 color;
  429. vec3 direction;
  430. bool visible;
  431. };
  432. struct ReflectedLight {
  433. vec3 directDiffuse;
  434. vec3 directSpecular;
  435. vec3 indirectDiffuse;
  436. vec3 indirectSpecular;
  437. };
  438. #ifdef USE_ALPHAHASH
  439. varying vec3 vPosition;
  440. #endif
  441. vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
  442. return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
  443. }
  444. vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
  445. return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
  446. }
  447. bool isPerspectiveMatrix( mat4 m ) {
  448. return m[ 2 ][ 3 ] == - 1.0;
  449. }
  450. vec2 equirectUv( in vec3 dir ) {
  451. float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
  452. float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
  453. return vec2( u, v );
  454. }
  455. vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
  456. return RECIPROCAL_PI * diffuseColor;
  457. }
  458. vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
  459. float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
  460. return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
  461. }
  462. float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
  463. float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
  464. return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
  465. } // validated`,xPe=`#ifdef ENVMAP_TYPE_CUBE_UV
  466. #define cubeUV_minMipLevel 4.0
  467. #define cubeUV_minTileSize 16.0
  468. float getFace( vec3 direction ) {
  469. vec3 absDirection = abs( direction );
  470. float face = - 1.0;
  471. if ( absDirection.x > absDirection.z ) {
  472. if ( absDirection.x > absDirection.y )
  473. face = direction.x > 0.0 ? 0.0 : 3.0;
  474. else
  475. face = direction.y > 0.0 ? 1.0 : 4.0;
  476. } else {
  477. if ( absDirection.z > absDirection.y )
  478. face = direction.z > 0.0 ? 2.0 : 5.0;
  479. else
  480. face = direction.y > 0.0 ? 1.0 : 4.0;
  481. }
  482. return face;
  483. }
  484. vec2 getUV( vec3 direction, float face ) {
  485. vec2 uv;
  486. if ( face == 0.0 ) {
  487. uv = vec2( direction.z, direction.y ) / abs( direction.x );
  488. } else if ( face == 1.0 ) {
  489. uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
  490. } else if ( face == 2.0 ) {
  491. uv = vec2( - direction.x, direction.y ) / abs( direction.z );
  492. } else if ( face == 3.0 ) {
  493. uv = vec2( - direction.z, direction.y ) / abs( direction.x );
  494. } else if ( face == 4.0 ) {
  495. uv = vec2( - direction.x, direction.z ) / abs( direction.y );
  496. } else {
  497. uv = vec2( direction.x, direction.y ) / abs( direction.z );
  498. }
  499. return 0.5 * ( uv + 1.0 );
  500. }
  501. vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
  502. float face = getFace( direction );
  503. float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
  504. mipInt = max( mipInt, cubeUV_minMipLevel );
  505. float faceSize = exp2( mipInt );
  506. highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
  507. if ( face > 2.0 ) {
  508. uv.y += faceSize;
  509. face -= 3.0;
  510. }
  511. uv.x += face * faceSize;
  512. uv.x += filterInt * 3.0 * cubeUV_minTileSize;
  513. uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
  514. uv.x *= CUBEUV_TEXEL_WIDTH;
  515. uv.y *= CUBEUV_TEXEL_HEIGHT;
  516. #ifdef texture2DGradEXT
  517. return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
  518. #else
  519. return texture2D( envMap, uv ).rgb;
  520. #endif
  521. }
  522. #define cubeUV_r0 1.0
  523. #define cubeUV_m0 - 2.0
  524. #define cubeUV_r1 0.8
  525. #define cubeUV_m1 - 1.0
  526. #define cubeUV_r4 0.4
  527. #define cubeUV_m4 2.0
  528. #define cubeUV_r5 0.305
  529. #define cubeUV_m5 3.0
  530. #define cubeUV_r6 0.21
  531. #define cubeUV_m6 4.0
  532. float roughnessToMip( float roughness ) {
  533. float mip = 0.0;
  534. if ( roughness >= cubeUV_r1 ) {
  535. mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
  536. } else if ( roughness >= cubeUV_r4 ) {
  537. mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
  538. } else if ( roughness >= cubeUV_r5 ) {
  539. mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
  540. } else if ( roughness >= cubeUV_r6 ) {
  541. mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
  542. } else {
  543. mip = - 2.0 * log2( 1.16 * roughness ); }
  544. return mip;
  545. }
  546. vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
  547. float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
  548. float mipF = fract( mip );
  549. float mipInt = floor( mip );
  550. vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
  551. if ( mipF == 0.0 ) {
  552. return vec4( color0, 1.0 );
  553. } else {
  554. vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
  555. return vec4( mix( color0, color1, mipF ), 1.0 );
  556. }
  557. }
  558. #endif`,bPe=`vec3 transformedNormal = objectNormal;
  559. #ifdef USE_TANGENT
  560. vec3 transformedTangent = objectTangent;
  561. #endif
  562. #ifdef USE_BATCHING
  563. mat3 bm = mat3( batchingMatrix );
  564. transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
  565. transformedNormal = bm * transformedNormal;
  566. #ifdef USE_TANGENT
  567. transformedTangent = bm * transformedTangent;
  568. #endif
  569. #endif
  570. #ifdef USE_INSTANCING
  571. mat3 im = mat3( instanceMatrix );
  572. transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
  573. transformedNormal = im * transformedNormal;
  574. #ifdef USE_TANGENT
  575. transformedTangent = im * transformedTangent;
  576. #endif
  577. #endif
  578. transformedNormal = normalMatrix * transformedNormal;
  579. #ifdef FLIP_SIDED
  580. transformedNormal = - transformedNormal;
  581. #endif
  582. #ifdef USE_TANGENT
  583. transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
  584. #ifdef FLIP_SIDED
  585. transformedTangent = - transformedTangent;
  586. #endif
  587. #endif`,yPe=`#ifdef USE_DISPLACEMENTMAP
  588. uniform sampler2D displacementMap;
  589. uniform float displacementScale;
  590. uniform float displacementBias;
  591. #endif`,vPe=`#ifdef USE_DISPLACEMENTMAP
  592. transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
  593. #endif`,_Pe=`#ifdef USE_EMISSIVEMAP
  594. vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
  595. #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
  596. emissiveColor = sRGBTransferEOTF( emissiveColor );
  597. #endif
  598. totalEmissiveRadiance *= emissiveColor.rgb;
  599. #endif`,wPe=`#ifdef USE_EMISSIVEMAP
  600. uniform sampler2D emissiveMap;
  601. #endif`,SPe="gl_FragColor = linearToOutputTexel( gl_FragColor );",NPe=`vec4 LinearTransferOETF( in vec4 value ) {
  602. return value;
  603. }
  604. vec4 sRGBTransferEOTF( in vec4 value ) {
  605. return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );
  606. }
  607. vec4 sRGBTransferOETF( in vec4 value ) {
  608. return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
  609. }`,MPe=`#ifdef USE_ENVMAP
  610. #ifdef ENV_WORLDPOS
  611. vec3 cameraToFrag;
  612. if ( isOrthographic ) {
  613. cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
  614. } else {
  615. cameraToFrag = normalize( vWorldPosition - cameraPosition );
  616. }
  617. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  618. #ifdef ENVMAP_MODE_REFLECTION
  619. vec3 reflectVec = reflect( cameraToFrag, worldNormal );
  620. #else
  621. vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
  622. #endif
  623. #else
  624. vec3 reflectVec = vReflect;
  625. #endif
  626. #ifdef ENVMAP_TYPE_CUBE
  627. vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
  628. #else
  629. vec4 envColor = vec4( 0.0 );
  630. #endif
  631. #ifdef ENVMAP_BLENDING_MULTIPLY
  632. outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
  633. #elif defined( ENVMAP_BLENDING_MIX )
  634. outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
  635. #elif defined( ENVMAP_BLENDING_ADD )
  636. outgoingLight += envColor.xyz * specularStrength * reflectivity;
  637. #endif
  638. #endif`,EPe=`#ifdef USE_ENVMAP
  639. uniform float envMapIntensity;
  640. uniform float flipEnvMap;
  641. uniform mat3 envMapRotation;
  642. #ifdef ENVMAP_TYPE_CUBE
  643. uniform samplerCube envMap;
  644. #else
  645. uniform sampler2D envMap;
  646. #endif
  647. #endif`,TPe=`#ifdef USE_ENVMAP
  648. uniform float reflectivity;
  649. #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
  650. #define ENV_WORLDPOS
  651. #endif
  652. #ifdef ENV_WORLDPOS
  653. varying vec3 vWorldPosition;
  654. uniform float refractionRatio;
  655. #else
  656. varying vec3 vReflect;
  657. #endif
  658. #endif`,APe=`#ifdef USE_ENVMAP
  659. #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
  660. #define ENV_WORLDPOS
  661. #endif
  662. #ifdef ENV_WORLDPOS
  663. varying vec3 vWorldPosition;
  664. #else
  665. varying vec3 vReflect;
  666. uniform float refractionRatio;
  667. #endif
  668. #endif`,CPe=`#ifdef USE_ENVMAP
  669. #ifdef ENV_WORLDPOS
  670. vWorldPosition = worldPosition.xyz;
  671. #else
  672. vec3 cameraToVertex;
  673. if ( isOrthographic ) {
  674. cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
  675. } else {
  676. cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
  677. }
  678. vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
  679. #ifdef ENVMAP_MODE_REFLECTION
  680. vReflect = reflect( cameraToVertex, worldNormal );
  681. #else
  682. vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
  683. #endif
  684. #endif
  685. #endif`,kPe=`#ifdef USE_FOG
  686. vFogDepth = - mvPosition.z;
  687. #endif`,jPe=`#ifdef USE_FOG
  688. varying float vFogDepth;
  689. #endif`,PPe=`#ifdef USE_FOG
  690. #ifdef FOG_EXP2
  691. float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
  692. #else
  693. float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
  694. #endif
  695. gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
  696. #endif`,RPe=`#ifdef USE_FOG
  697. uniform vec3 fogColor;
  698. varying float vFogDepth;
  699. #ifdef FOG_EXP2
  700. uniform float fogDensity;
  701. #else
  702. uniform float fogNear;
  703. uniform float fogFar;
  704. #endif
  705. #endif`,DPe=`#ifdef USE_GRADIENTMAP
  706. uniform sampler2D gradientMap;
  707. #endif
  708. vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
  709. float dotNL = dot( normal, lightDirection );
  710. vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
  711. #ifdef USE_GRADIENTMAP
  712. return vec3( texture2D( gradientMap, coord ).r );
  713. #else
  714. vec2 fw = fwidth( coord ) * 0.5;
  715. return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
  716. #endif
  717. }`,OPe=`#ifdef USE_LIGHTMAP
  718. uniform sampler2D lightMap;
  719. uniform float lightMapIntensity;
  720. #endif`,LPe=`LambertMaterial material;
  721. material.diffuseColor = diffuseColor.rgb;
  722. material.specularStrength = specularStrength;`,IPe=`varying vec3 vViewPosition;
  723. struct LambertMaterial {
  724. vec3 diffuseColor;
  725. float specularStrength;
  726. };
  727. void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
  728. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  729. vec3 irradiance = dotNL * directLight.color;
  730. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  731. }
  732. void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
  733. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  734. }
  735. #define RE_Direct RE_Direct_Lambert
  736. #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,FPe=`uniform bool receiveShadow;
  737. uniform vec3 ambientLightColor;
  738. #if defined( USE_LIGHT_PROBES )
  739. uniform vec3 lightProbe[ 9 ];
  740. #endif
  741. vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
  742. float x = normal.x, y = normal.y, z = normal.z;
  743. vec3 result = shCoefficients[ 0 ] * 0.886227;
  744. result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
  745. result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
  746. result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
  747. result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
  748. result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
  749. result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
  750. result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
  751. result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
  752. return result;
  753. }
  754. vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
  755. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  756. vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
  757. return irradiance;
  758. }
  759. vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
  760. vec3 irradiance = ambientLightColor;
  761. return irradiance;
  762. }
  763. float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
  764. float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
  765. if ( cutoffDistance > 0.0 ) {
  766. distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
  767. }
  768. return distanceFalloff;
  769. }
  770. float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
  771. return smoothstep( coneCosine, penumbraCosine, angleCosine );
  772. }
  773. #if NUM_DIR_LIGHTS > 0
  774. struct DirectionalLight {
  775. vec3 direction;
  776. vec3 color;
  777. };
  778. uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
  779. void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
  780. light.color = directionalLight.color;
  781. light.direction = directionalLight.direction;
  782. light.visible = true;
  783. }
  784. #endif
  785. #if NUM_POINT_LIGHTS > 0
  786. struct PointLight {
  787. vec3 position;
  788. vec3 color;
  789. float distance;
  790. float decay;
  791. };
  792. uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
  793. void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
  794. vec3 lVector = pointLight.position - geometryPosition;
  795. light.direction = normalize( lVector );
  796. float lightDistance = length( lVector );
  797. light.color = pointLight.color;
  798. light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
  799. light.visible = ( light.color != vec3( 0.0 ) );
  800. }
  801. #endif
  802. #if NUM_SPOT_LIGHTS > 0
  803. struct SpotLight {
  804. vec3 position;
  805. vec3 direction;
  806. vec3 color;
  807. float distance;
  808. float decay;
  809. float coneCos;
  810. float penumbraCos;
  811. };
  812. uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
  813. void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
  814. vec3 lVector = spotLight.position - geometryPosition;
  815. light.direction = normalize( lVector );
  816. float angleCos = dot( light.direction, spotLight.direction );
  817. float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
  818. if ( spotAttenuation > 0.0 ) {
  819. float lightDistance = length( lVector );
  820. light.color = spotLight.color * spotAttenuation;
  821. light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
  822. light.visible = ( light.color != vec3( 0.0 ) );
  823. } else {
  824. light.color = vec3( 0.0 );
  825. light.visible = false;
  826. }
  827. }
  828. #endif
  829. #if NUM_RECT_AREA_LIGHTS > 0
  830. struct RectAreaLight {
  831. vec3 color;
  832. vec3 position;
  833. vec3 halfWidth;
  834. vec3 halfHeight;
  835. };
  836. uniform sampler2D ltc_1; uniform sampler2D ltc_2;
  837. uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
  838. #endif
  839. #if NUM_HEMI_LIGHTS > 0
  840. struct HemisphereLight {
  841. vec3 direction;
  842. vec3 skyColor;
  843. vec3 groundColor;
  844. };
  845. uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
  846. vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
  847. float dotNL = dot( normal, hemiLight.direction );
  848. float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
  849. vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
  850. return irradiance;
  851. }
  852. #endif`,UPe=`#ifdef USE_ENVMAP
  853. vec3 getIBLIrradiance( const in vec3 normal ) {
  854. #ifdef ENVMAP_TYPE_CUBE_UV
  855. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  856. vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );
  857. return PI * envMapColor.rgb * envMapIntensity;
  858. #else
  859. return vec3( 0.0 );
  860. #endif
  861. }
  862. vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
  863. #ifdef ENVMAP_TYPE_CUBE_UV
  864. vec3 reflectVec = reflect( - viewDir, normal );
  865. reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) );
  866. reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
  867. vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );
  868. return envMapColor.rgb * envMapIntensity;
  869. #else
  870. return vec3( 0.0 );
  871. #endif
  872. }
  873. #ifdef USE_ANISOTROPY
  874. vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
  875. #ifdef ENVMAP_TYPE_CUBE_UV
  876. vec3 bentNormal = cross( bitangent, viewDir );
  877. bentNormal = normalize( cross( bentNormal, bitangent ) );
  878. bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
  879. return getIBLRadiance( viewDir, bentNormal, roughness );
  880. #else
  881. return vec3( 0.0 );
  882. #endif
  883. }
  884. #endif
  885. #endif`,zPe=`ToonMaterial material;
  886. material.diffuseColor = diffuseColor.rgb;`,BPe=`varying vec3 vViewPosition;
  887. struct ToonMaterial {
  888. vec3 diffuseColor;
  889. };
  890. void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
  891. vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
  892. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  893. }
  894. void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
  895. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  896. }
  897. #define RE_Direct RE_Direct_Toon
  898. #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,$Pe=`BlinnPhongMaterial material;
  899. material.diffuseColor = diffuseColor.rgb;
  900. material.specularColor = specular;
  901. material.specularShininess = shininess;
  902. material.specularStrength = specularStrength;`,HPe=`varying vec3 vViewPosition;
  903. struct BlinnPhongMaterial {
  904. vec3 diffuseColor;
  905. vec3 specularColor;
  906. float specularShininess;
  907. float specularStrength;
  908. };
  909. void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
  910. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  911. vec3 irradiance = dotNL * directLight.color;
  912. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  913. reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
  914. }
  915. void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
  916. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  917. }
  918. #define RE_Direct RE_Direct_BlinnPhong
  919. #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,VPe=`PhysicalMaterial material;
  920. material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
  921. vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
  922. float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
  923. material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
  924. material.roughness = min( material.roughness, 1.0 );
  925. #ifdef IOR
  926. material.ior = ior;
  927. #ifdef USE_SPECULAR
  928. float specularIntensityFactor = specularIntensity;
  929. vec3 specularColorFactor = specularColor;
  930. #ifdef USE_SPECULAR_COLORMAP
  931. specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
  932. #endif
  933. #ifdef USE_SPECULAR_INTENSITYMAP
  934. specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
  935. #endif
  936. material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
  937. #else
  938. float specularIntensityFactor = 1.0;
  939. vec3 specularColorFactor = vec3( 1.0 );
  940. material.specularF90 = 1.0;
  941. #endif
  942. material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
  943. #else
  944. material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
  945. material.specularF90 = 1.0;
  946. #endif
  947. #ifdef USE_CLEARCOAT
  948. material.clearcoat = clearcoat;
  949. material.clearcoatRoughness = clearcoatRoughness;
  950. material.clearcoatF0 = vec3( 0.04 );
  951. material.clearcoatF90 = 1.0;
  952. #ifdef USE_CLEARCOATMAP
  953. material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
  954. #endif
  955. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  956. material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
  957. #endif
  958. material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
  959. material.clearcoatRoughness += geometryRoughness;
  960. material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
  961. #endif
  962. #ifdef USE_DISPERSION
  963. material.dispersion = dispersion;
  964. #endif
  965. #ifdef USE_IRIDESCENCE
  966. material.iridescence = iridescence;
  967. material.iridescenceIOR = iridescenceIOR;
  968. #ifdef USE_IRIDESCENCEMAP
  969. material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
  970. #endif
  971. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  972. material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
  973. #else
  974. material.iridescenceThickness = iridescenceThicknessMaximum;
  975. #endif
  976. #endif
  977. #ifdef USE_SHEEN
  978. material.sheenColor = sheenColor;
  979. #ifdef USE_SHEEN_COLORMAP
  980. material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
  981. #endif
  982. material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
  983. #ifdef USE_SHEEN_ROUGHNESSMAP
  984. material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
  985. #endif
  986. #endif
  987. #ifdef USE_ANISOTROPY
  988. #ifdef USE_ANISOTROPYMAP
  989. mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
  990. vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
  991. vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
  992. #else
  993. vec2 anisotropyV = anisotropyVector;
  994. #endif
  995. material.anisotropy = length( anisotropyV );
  996. if( material.anisotropy == 0.0 ) {
  997. anisotropyV = vec2( 1.0, 0.0 );
  998. } else {
  999. anisotropyV /= material.anisotropy;
  1000. material.anisotropy = saturate( material.anisotropy );
  1001. }
  1002. material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
  1003. material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
  1004. material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
  1005. #endif`,GPe=`uniform sampler2D dfgLUT;
  1006. struct PhysicalMaterial {
  1007. vec3 diffuseColor;
  1008. float roughness;
  1009. vec3 specularColor;
  1010. float specularF90;
  1011. float dispersion;
  1012. #ifdef USE_CLEARCOAT
  1013. float clearcoat;
  1014. float clearcoatRoughness;
  1015. vec3 clearcoatF0;
  1016. float clearcoatF90;
  1017. #endif
  1018. #ifdef USE_IRIDESCENCE
  1019. float iridescence;
  1020. float iridescenceIOR;
  1021. float iridescenceThickness;
  1022. vec3 iridescenceFresnel;
  1023. vec3 iridescenceF0;
  1024. #endif
  1025. #ifdef USE_SHEEN
  1026. vec3 sheenColor;
  1027. float sheenRoughness;
  1028. #endif
  1029. #ifdef IOR
  1030. float ior;
  1031. #endif
  1032. #ifdef USE_TRANSMISSION
  1033. float transmission;
  1034. float transmissionAlpha;
  1035. float thickness;
  1036. float attenuationDistance;
  1037. vec3 attenuationColor;
  1038. #endif
  1039. #ifdef USE_ANISOTROPY
  1040. float anisotropy;
  1041. float alphaT;
  1042. vec3 anisotropyT;
  1043. vec3 anisotropyB;
  1044. #endif
  1045. };
  1046. vec3 clearcoatSpecularDirect = vec3( 0.0 );
  1047. vec3 clearcoatSpecularIndirect = vec3( 0.0 );
  1048. vec3 sheenSpecularDirect = vec3( 0.0 );
  1049. vec3 sheenSpecularIndirect = vec3(0.0 );
  1050. vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
  1051. float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
  1052. float x2 = x * x;
  1053. float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
  1054. return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
  1055. }
  1056. float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
  1057. float a2 = pow2( alpha );
  1058. float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
  1059. float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
  1060. return 0.5 / max( gv + gl, EPSILON );
  1061. }
  1062. float D_GGX( const in float alpha, const in float dotNH ) {
  1063. float a2 = pow2( alpha );
  1064. float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
  1065. return RECIPROCAL_PI * a2 / pow2( denom );
  1066. }
  1067. #ifdef USE_ANISOTROPY
  1068. float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {
  1069. float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
  1070. float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
  1071. float v = 0.5 / ( gv + gl );
  1072. return saturate(v);
  1073. }
  1074. float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
  1075. float a2 = alphaT * alphaB;
  1076. highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
  1077. highp float v2 = dot( v, v );
  1078. float w2 = a2 / v2;
  1079. return RECIPROCAL_PI * a2 * pow2 ( w2 );
  1080. }
  1081. #endif
  1082. #ifdef USE_CLEARCOAT
  1083. vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
  1084. vec3 f0 = material.clearcoatF0;
  1085. float f90 = material.clearcoatF90;
  1086. float roughness = material.clearcoatRoughness;
  1087. float alpha = pow2( roughness );
  1088. vec3 halfDir = normalize( lightDir + viewDir );
  1089. float dotNL = saturate( dot( normal, lightDir ) );
  1090. float dotNV = saturate( dot( normal, viewDir ) );
  1091. float dotNH = saturate( dot( normal, halfDir ) );
  1092. float dotVH = saturate( dot( viewDir, halfDir ) );
  1093. vec3 F = F_Schlick( f0, f90, dotVH );
  1094. float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
  1095. float D = D_GGX( alpha, dotNH );
  1096. return F * ( V * D );
  1097. }
  1098. #endif
  1099. vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
  1100. vec3 f0 = material.specularColor;
  1101. float f90 = material.specularF90;
  1102. float roughness = material.roughness;
  1103. float alpha = pow2( roughness );
  1104. vec3 halfDir = normalize( lightDir + viewDir );
  1105. float dotNL = saturate( dot( normal, lightDir ) );
  1106. float dotNV = saturate( dot( normal, viewDir ) );
  1107. float dotNH = saturate( dot( normal, halfDir ) );
  1108. float dotVH = saturate( dot( viewDir, halfDir ) );
  1109. vec3 F = F_Schlick( f0, f90, dotVH );
  1110. #ifdef USE_IRIDESCENCE
  1111. F = mix( F, material.iridescenceFresnel, material.iridescence );
  1112. #endif
  1113. #ifdef USE_ANISOTROPY
  1114. float dotTL = dot( material.anisotropyT, lightDir );
  1115. float dotTV = dot( material.anisotropyT, viewDir );
  1116. float dotTH = dot( material.anisotropyT, halfDir );
  1117. float dotBL = dot( material.anisotropyB, lightDir );
  1118. float dotBV = dot( material.anisotropyB, viewDir );
  1119. float dotBH = dot( material.anisotropyB, halfDir );
  1120. float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
  1121. float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
  1122. #else
  1123. float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
  1124. float D = D_GGX( alpha, dotNH );
  1125. #endif
  1126. return F * ( V * D );
  1127. }
  1128. vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
  1129. const float LUT_SIZE = 64.0;
  1130. const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
  1131. const float LUT_BIAS = 0.5 / LUT_SIZE;
  1132. float dotNV = saturate( dot( N, V ) );
  1133. vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
  1134. uv = uv * LUT_SCALE + LUT_BIAS;
  1135. return uv;
  1136. }
  1137. float LTC_ClippedSphereFormFactor( const in vec3 f ) {
  1138. float l = length( f );
  1139. return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
  1140. }
  1141. vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
  1142. float x = dot( v1, v2 );
  1143. float y = abs( x );
  1144. float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
  1145. float b = 3.4175940 + ( 4.1616724 + y ) * y;
  1146. float v = a / b;
  1147. float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
  1148. return cross( v1, v2 ) * theta_sintheta;
  1149. }
  1150. vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
  1151. vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
  1152. vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
  1153. vec3 lightNormal = cross( v1, v2 );
  1154. if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
  1155. vec3 T1, T2;
  1156. T1 = normalize( V - N * dot( V, N ) );
  1157. T2 = - cross( N, T1 );
  1158. mat3 mat = mInv * transpose( mat3( T1, T2, N ) );
  1159. vec3 coords[ 4 ];
  1160. coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
  1161. coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
  1162. coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
  1163. coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
  1164. coords[ 0 ] = normalize( coords[ 0 ] );
  1165. coords[ 1 ] = normalize( coords[ 1 ] );
  1166. coords[ 2 ] = normalize( coords[ 2 ] );
  1167. coords[ 3 ] = normalize( coords[ 3 ] );
  1168. vec3 vectorFormFactor = vec3( 0.0 );
  1169. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
  1170. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
  1171. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
  1172. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
  1173. float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
  1174. return vec3( result );
  1175. }
  1176. #if defined( USE_SHEEN )
  1177. float D_Charlie( float roughness, float dotNH ) {
  1178. float alpha = pow2( roughness );
  1179. float invAlpha = 1.0 / alpha;
  1180. float cos2h = dotNH * dotNH;
  1181. float sin2h = max( 1.0 - cos2h, 0.0078125 );
  1182. return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
  1183. }
  1184. float V_Neubelt( float dotNV, float dotNL ) {
  1185. return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
  1186. }
  1187. vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
  1188. vec3 halfDir = normalize( lightDir + viewDir );
  1189. float dotNL = saturate( dot( normal, lightDir ) );
  1190. float dotNV = saturate( dot( normal, viewDir ) );
  1191. float dotNH = saturate( dot( normal, halfDir ) );
  1192. float D = D_Charlie( sheenRoughness, dotNH );
  1193. float V = V_Neubelt( dotNV, dotNL );
  1194. return sheenColor * ( D * V );
  1195. }
  1196. #endif
  1197. float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
  1198. float dotNV = saturate( dot( normal, viewDir ) );
  1199. float r2 = roughness * roughness;
  1200. float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
  1201. float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
  1202. float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
  1203. return saturate( DG * RECIPROCAL_PI );
  1204. }
  1205. vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
  1206. float dotNV = saturate( dot( normal, viewDir ) );
  1207. vec2 uv = vec2( roughness, dotNV );
  1208. return texture2D( dfgLUT, uv ).rg;
  1209. }
  1210. vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
  1211. vec2 fab = DFGApprox( normal, viewDir, roughness );
  1212. return specularColor * fab.x + specularF90 * fab.y;
  1213. }
  1214. #ifdef USE_IRIDESCENCE
  1215. void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
  1216. #else
  1217. void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
  1218. #endif
  1219. vec2 fab = DFGApprox( normal, viewDir, roughness );
  1220. #ifdef USE_IRIDESCENCE
  1221. vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
  1222. #else
  1223. vec3 Fr = specularColor;
  1224. #endif
  1225. vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
  1226. float Ess = fab.x + fab.y;
  1227. float Ems = 1.0 - Ess;
  1228. vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
  1229. singleScatter += FssEss;
  1230. multiScatter += Fms * Ems;
  1231. }
  1232. vec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
  1233. vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material );
  1234. float dotNL = saturate( dot( normal, lightDir ) );
  1235. float dotNV = saturate( dot( normal, viewDir ) );
  1236. vec2 dfgV = DFGApprox( vec3(0.0, 0.0, 1.0), vec3(sqrt(1.0 - dotNV * dotNV), 0.0, dotNV), material.roughness );
  1237. vec2 dfgL = DFGApprox( vec3(0.0, 0.0, 1.0), vec3(sqrt(1.0 - dotNL * dotNL), 0.0, dotNL), material.roughness );
  1238. vec3 FssEss_V = material.specularColor * dfgV.x + material.specularF90 * dfgV.y;
  1239. vec3 FssEss_L = material.specularColor * dfgL.x + material.specularF90 * dfgL.y;
  1240. float Ess_V = dfgV.x + dfgV.y;
  1241. float Ess_L = dfgL.x + dfgL.y;
  1242. float Ems_V = 1.0 - Ess_V;
  1243. float Ems_L = 1.0 - Ess_L;
  1244. vec3 Favg = material.specularColor + ( 1.0 - material.specularColor ) * 0.047619;
  1245. vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg * Favg + EPSILON );
  1246. float compensationFactor = Ems_V * Ems_L;
  1247. vec3 multiScatter = Fms * compensationFactor;
  1248. return singleScatter + multiScatter;
  1249. }
  1250. #if NUM_RECT_AREA_LIGHTS > 0
  1251. void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
  1252. vec3 normal = geometryNormal;
  1253. vec3 viewDir = geometryViewDir;
  1254. vec3 position = geometryPosition;
  1255. vec3 lightPos = rectAreaLight.position;
  1256. vec3 halfWidth = rectAreaLight.halfWidth;
  1257. vec3 halfHeight = rectAreaLight.halfHeight;
  1258. vec3 lightColor = rectAreaLight.color;
  1259. float roughness = material.roughness;
  1260. vec3 rectCoords[ 4 ];
  1261. rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
  1262. rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
  1263. rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
  1264. vec2 uv = LTC_Uv( normal, viewDir, roughness );
  1265. vec4 t1 = texture2D( ltc_1, uv );
  1266. vec4 t2 = texture2D( ltc_2, uv );
  1267. mat3 mInv = mat3(
  1268. vec3( t1.x, 0, t1.y ),
  1269. vec3( 0, 1, 0 ),
  1270. vec3( t1.z, 0, t1.w )
  1271. );
  1272. vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
  1273. reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
  1274. reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
  1275. }
  1276. #endif
  1277. void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
  1278. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  1279. vec3 irradiance = dotNL * directLight.color;
  1280. #ifdef USE_CLEARCOAT
  1281. float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
  1282. vec3 ccIrradiance = dotNLcc * directLight.color;
  1283. clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
  1284. #endif
  1285. #ifdef USE_SHEEN
  1286. sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
  1287. #endif
  1288. reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material );
  1289. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  1290. }
  1291. void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
  1292. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  1293. }
  1294. void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
  1295. #ifdef USE_CLEARCOAT
  1296. clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
  1297. #endif
  1298. #ifdef USE_SHEEN
  1299. sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
  1300. #endif
  1301. vec3 singleScattering = vec3( 0.0 );
  1302. vec3 multiScattering = vec3( 0.0 );
  1303. vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
  1304. #ifdef USE_IRIDESCENCE
  1305. computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
  1306. #else
  1307. computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
  1308. #endif
  1309. vec3 totalScattering = singleScattering + multiScattering;
  1310. vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
  1311. reflectedLight.indirectSpecular += radiance * singleScattering;
  1312. reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
  1313. reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
  1314. }
  1315. #define RE_Direct RE_Direct_Physical
  1316. #define RE_Direct_RectArea RE_Direct_RectArea_Physical
  1317. #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
  1318. #define RE_IndirectSpecular RE_IndirectSpecular_Physical
  1319. float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
  1320. return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
  1321. }`,WPe=`
  1322. vec3 geometryPosition = - vViewPosition;
  1323. vec3 geometryNormal = normal;
  1324. vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
  1325. vec3 geometryClearcoatNormal = vec3( 0.0 );
  1326. #ifdef USE_CLEARCOAT
  1327. geometryClearcoatNormal = clearcoatNormal;
  1328. #endif
  1329. #ifdef USE_IRIDESCENCE
  1330. float dotNVi = saturate( dot( normal, geometryViewDir ) );
  1331. if ( material.iridescenceThickness == 0.0 ) {
  1332. material.iridescence = 0.0;
  1333. } else {
  1334. material.iridescence = saturate( material.iridescence );
  1335. }
  1336. if ( material.iridescence > 0.0 ) {
  1337. material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
  1338. material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
  1339. }
  1340. #endif
  1341. IncidentLight directLight;
  1342. #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
  1343. PointLight pointLight;
  1344. #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
  1345. PointLightShadow pointLightShadow;
  1346. #endif
  1347. #pragma unroll_loop_start
  1348. for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
  1349. pointLight = pointLights[ i ];
  1350. getPointLightInfo( pointLight, geometryPosition, directLight );
  1351. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
  1352. pointLightShadow = pointLightShadows[ i ];
  1353. directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
  1354. #endif
  1355. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1356. }
  1357. #pragma unroll_loop_end
  1358. #endif
  1359. #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
  1360. SpotLight spotLight;
  1361. vec4 spotColor;
  1362. vec3 spotLightCoord;
  1363. bool inSpotLightMap;
  1364. #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
  1365. SpotLightShadow spotLightShadow;
  1366. #endif
  1367. #pragma unroll_loop_start
  1368. for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
  1369. spotLight = spotLights[ i ];
  1370. getSpotLightInfo( spotLight, geometryPosition, directLight );
  1371. #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
  1372. #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
  1373. #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  1374. #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
  1375. #else
  1376. #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
  1377. #endif
  1378. #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
  1379. spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
  1380. inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
  1381. spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
  1382. directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
  1383. #endif
  1384. #undef SPOT_LIGHT_MAP_INDEX
  1385. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  1386. spotLightShadow = spotLightShadows[ i ];
  1387. directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
  1388. #endif
  1389. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1390. }
  1391. #pragma unroll_loop_end
  1392. #endif
  1393. #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
  1394. DirectionalLight directionalLight;
  1395. #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
  1396. DirectionalLightShadow directionalLightShadow;
  1397. #endif
  1398. #pragma unroll_loop_start
  1399. for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
  1400. directionalLight = directionalLights[ i ];
  1401. getDirectionalLightInfo( directionalLight, directLight );
  1402. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
  1403. directionalLightShadow = directionalLightShadows[ i ];
  1404. directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
  1405. #endif
  1406. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1407. }
  1408. #pragma unroll_loop_end
  1409. #endif
  1410. #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
  1411. RectAreaLight rectAreaLight;
  1412. #pragma unroll_loop_start
  1413. for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
  1414. rectAreaLight = rectAreaLights[ i ];
  1415. RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1416. }
  1417. #pragma unroll_loop_end
  1418. #endif
  1419. #if defined( RE_IndirectDiffuse )
  1420. vec3 iblIrradiance = vec3( 0.0 );
  1421. vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
  1422. #if defined( USE_LIGHT_PROBES )
  1423. irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
  1424. #endif
  1425. #if ( NUM_HEMI_LIGHTS > 0 )
  1426. #pragma unroll_loop_start
  1427. for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
  1428. irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
  1429. }
  1430. #pragma unroll_loop_end
  1431. #endif
  1432. #endif
  1433. #if defined( RE_IndirectSpecular )
  1434. vec3 radiance = vec3( 0.0 );
  1435. vec3 clearcoatRadiance = vec3( 0.0 );
  1436. #endif`,qPe=`#if defined( RE_IndirectDiffuse )
  1437. #ifdef USE_LIGHTMAP
  1438. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  1439. vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
  1440. irradiance += lightMapIrradiance;
  1441. #endif
  1442. #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
  1443. iblIrradiance += getIBLIrradiance( geometryNormal );
  1444. #endif
  1445. #endif
  1446. #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
  1447. #ifdef USE_ANISOTROPY
  1448. radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
  1449. #else
  1450. radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
  1451. #endif
  1452. #ifdef USE_CLEARCOAT
  1453. clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
  1454. #endif
  1455. #endif`,KPe=`#if defined( RE_IndirectDiffuse )
  1456. RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1457. #endif
  1458. #if defined( RE_IndirectSpecular )
  1459. RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1460. #endif`,XPe=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
  1461. gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
  1462. #endif`,YPe=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
  1463. uniform float logDepthBufFC;
  1464. varying float vFragDepth;
  1465. varying float vIsPerspective;
  1466. #endif`,QPe=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
  1467. varying float vFragDepth;
  1468. varying float vIsPerspective;
  1469. #endif`,ZPe=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
  1470. vFragDepth = 1.0 + gl_Position.w;
  1471. vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
  1472. #endif`,JPe=`#ifdef USE_MAP
  1473. vec4 sampledDiffuseColor = texture2D( map, vMapUv );
  1474. #ifdef DECODE_VIDEO_TEXTURE
  1475. sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
  1476. #endif
  1477. diffuseColor *= sampledDiffuseColor;
  1478. #endif`,eRe=`#ifdef USE_MAP
  1479. uniform sampler2D map;
  1480. #endif`,tRe=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
  1481. #if defined( USE_POINTS_UV )
  1482. vec2 uv = vUv;
  1483. #else
  1484. vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
  1485. #endif
  1486. #endif
  1487. #ifdef USE_MAP
  1488. diffuseColor *= texture2D( map, uv );
  1489. #endif
  1490. #ifdef USE_ALPHAMAP
  1491. diffuseColor.a *= texture2D( alphaMap, uv ).g;
  1492. #endif`,nRe=`#if defined( USE_POINTS_UV )
  1493. varying vec2 vUv;
  1494. #else
  1495. #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
  1496. uniform mat3 uvTransform;
  1497. #endif
  1498. #endif
  1499. #ifdef USE_MAP
  1500. uniform sampler2D map;
  1501. #endif
  1502. #ifdef USE_ALPHAMAP
  1503. uniform sampler2D alphaMap;
  1504. #endif`,rRe=`float metalnessFactor = metalness;
  1505. #ifdef USE_METALNESSMAP
  1506. vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
  1507. metalnessFactor *= texelMetalness.b;
  1508. #endif`,iRe=`#ifdef USE_METALNESSMAP
  1509. uniform sampler2D metalnessMap;
  1510. #endif`,aRe=`#ifdef USE_INSTANCING_MORPH
  1511. float morphTargetInfluences[ MORPHTARGETS_COUNT ];
  1512. float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
  1513. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  1514. morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
  1515. }
  1516. #endif`,sRe=`#if defined( USE_MORPHCOLORS )
  1517. vColor *= morphTargetBaseInfluence;
  1518. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  1519. #if defined( USE_COLOR_ALPHA )
  1520. if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
  1521. #elif defined( USE_COLOR )
  1522. if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
  1523. #endif
  1524. }
  1525. #endif`,oRe=`#ifdef USE_MORPHNORMALS
  1526. objectNormal *= morphTargetBaseInfluence;
  1527. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  1528. if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
  1529. }
  1530. #endif`,lRe=`#ifdef USE_MORPHTARGETS
  1531. #ifndef USE_INSTANCING_MORPH
  1532. uniform float morphTargetBaseInfluence;
  1533. uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
  1534. #endif
  1535. uniform sampler2DArray morphTargetsTexture;
  1536. uniform ivec2 morphTargetsTextureSize;
  1537. vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
  1538. int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
  1539. int y = texelIndex / morphTargetsTextureSize.x;
  1540. int x = texelIndex - y * morphTargetsTextureSize.x;
  1541. ivec3 morphUV = ivec3( x, y, morphTargetIndex );
  1542. return texelFetch( morphTargetsTexture, morphUV, 0 );
  1543. }
  1544. #endif`,cRe=`#ifdef USE_MORPHTARGETS
  1545. transformed *= morphTargetBaseInfluence;
  1546. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  1547. if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
  1548. }
  1549. #endif`,uRe=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
  1550. #ifdef FLAT_SHADED
  1551. vec3 fdx = dFdx( vViewPosition );
  1552. vec3 fdy = dFdy( vViewPosition );
  1553. vec3 normal = normalize( cross( fdx, fdy ) );
  1554. #else
  1555. vec3 normal = normalize( vNormal );
  1556. #ifdef DOUBLE_SIDED
  1557. normal *= faceDirection;
  1558. #endif
  1559. #endif
  1560. #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
  1561. #ifdef USE_TANGENT
  1562. mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
  1563. #else
  1564. mat3 tbn = getTangentFrame( - vViewPosition, normal,
  1565. #if defined( USE_NORMALMAP )
  1566. vNormalMapUv
  1567. #elif defined( USE_CLEARCOAT_NORMALMAP )
  1568. vClearcoatNormalMapUv
  1569. #else
  1570. vUv
  1571. #endif
  1572. );
  1573. #endif
  1574. #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
  1575. tbn[0] *= faceDirection;
  1576. tbn[1] *= faceDirection;
  1577. #endif
  1578. #endif
  1579. #ifdef USE_CLEARCOAT_NORMALMAP
  1580. #ifdef USE_TANGENT
  1581. mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
  1582. #else
  1583. mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
  1584. #endif
  1585. #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
  1586. tbn2[0] *= faceDirection;
  1587. tbn2[1] *= faceDirection;
  1588. #endif
  1589. #endif
  1590. vec3 nonPerturbedNormal = normal;`,dRe=`#ifdef USE_NORMALMAP_OBJECTSPACE
  1591. normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
  1592. #ifdef FLIP_SIDED
  1593. normal = - normal;
  1594. #endif
  1595. #ifdef DOUBLE_SIDED
  1596. normal = normal * faceDirection;
  1597. #endif
  1598. normal = normalize( normalMatrix * normal );
  1599. #elif defined( USE_NORMALMAP_TANGENTSPACE )
  1600. vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
  1601. mapN.xy *= normalScale;
  1602. normal = normalize( tbn * mapN );
  1603. #elif defined( USE_BUMPMAP )
  1604. normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
  1605. #endif`,hRe=`#ifndef FLAT_SHADED
  1606. varying vec3 vNormal;
  1607. #ifdef USE_TANGENT
  1608. varying vec3 vTangent;
  1609. varying vec3 vBitangent;
  1610. #endif
  1611. #endif`,fRe=`#ifndef FLAT_SHADED
  1612. varying vec3 vNormal;
  1613. #ifdef USE_TANGENT
  1614. varying vec3 vTangent;
  1615. varying vec3 vBitangent;
  1616. #endif
  1617. #endif`,mRe=`#ifndef FLAT_SHADED
  1618. vNormal = normalize( transformedNormal );
  1619. #ifdef USE_TANGENT
  1620. vTangent = normalize( transformedTangent );
  1621. vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
  1622. #endif
  1623. #endif`,pRe=`#ifdef USE_NORMALMAP
  1624. uniform sampler2D normalMap;
  1625. uniform vec2 normalScale;
  1626. #endif
  1627. #ifdef USE_NORMALMAP_OBJECTSPACE
  1628. uniform mat3 normalMatrix;
  1629. #endif
  1630. #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
  1631. mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
  1632. vec3 q0 = dFdx( eye_pos.xyz );
  1633. vec3 q1 = dFdy( eye_pos.xyz );
  1634. vec2 st0 = dFdx( uv.st );
  1635. vec2 st1 = dFdy( uv.st );
  1636. vec3 N = surf_norm;
  1637. vec3 q1perp = cross( q1, N );
  1638. vec3 q0perp = cross( N, q0 );
  1639. vec3 T = q1perp * st0.x + q0perp * st1.x;
  1640. vec3 B = q1perp * st0.y + q0perp * st1.y;
  1641. float det = max( dot( T, T ), dot( B, B ) );
  1642. float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
  1643. return mat3( T * scale, B * scale, N );
  1644. }
  1645. #endif`,gRe=`#ifdef USE_CLEARCOAT
  1646. vec3 clearcoatNormal = nonPerturbedNormal;
  1647. #endif`,xRe=`#ifdef USE_CLEARCOAT_NORMALMAP
  1648. vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
  1649. clearcoatMapN.xy *= clearcoatNormalScale;
  1650. clearcoatNormal = normalize( tbn2 * clearcoatMapN );
  1651. #endif`,bRe=`#ifdef USE_CLEARCOATMAP
  1652. uniform sampler2D clearcoatMap;
  1653. #endif
  1654. #ifdef USE_CLEARCOAT_NORMALMAP
  1655. uniform sampler2D clearcoatNormalMap;
  1656. uniform vec2 clearcoatNormalScale;
  1657. #endif
  1658. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  1659. uniform sampler2D clearcoatRoughnessMap;
  1660. #endif`,yRe=`#ifdef USE_IRIDESCENCEMAP
  1661. uniform sampler2D iridescenceMap;
  1662. #endif
  1663. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  1664. uniform sampler2D iridescenceThicknessMap;
  1665. #endif`,vRe=`#ifdef OPAQUE
  1666. diffuseColor.a = 1.0;
  1667. #endif
  1668. #ifdef USE_TRANSMISSION
  1669. diffuseColor.a *= material.transmissionAlpha;
  1670. #endif
  1671. gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,_Re=`vec3 packNormalToRGB( const in vec3 normal ) {
  1672. return normalize( normal ) * 0.5 + 0.5;
  1673. }
  1674. vec3 unpackRGBToNormal( const in vec3 rgb ) {
  1675. return 2.0 * rgb.xyz - 1.0;
  1676. }
  1677. const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;
  1678. const float Inv255 = 1. / 255.;
  1679. const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );
  1680. const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );
  1681. const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );
  1682. const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );
  1683. vec4 packDepthToRGBA( const in float v ) {
  1684. if( v <= 0.0 )
  1685. return vec4( 0., 0., 0., 0. );
  1686. if( v >= 1.0 )
  1687. return vec4( 1., 1., 1., 1. );
  1688. float vuf;
  1689. float af = modf( v * PackFactors.a, vuf );
  1690. float bf = modf( vuf * ShiftRight8, vuf );
  1691. float gf = modf( vuf * ShiftRight8, vuf );
  1692. return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );
  1693. }
  1694. vec3 packDepthToRGB( const in float v ) {
  1695. if( v <= 0.0 )
  1696. return vec3( 0., 0., 0. );
  1697. if( v >= 1.0 )
  1698. return vec3( 1., 1., 1. );
  1699. float vuf;
  1700. float bf = modf( v * PackFactors.b, vuf );
  1701. float gf = modf( vuf * ShiftRight8, vuf );
  1702. return vec3( vuf * Inv255, gf * PackUpscale, bf );
  1703. }
  1704. vec2 packDepthToRG( const in float v ) {
  1705. if( v <= 0.0 )
  1706. return vec2( 0., 0. );
  1707. if( v >= 1.0 )
  1708. return vec2( 1., 1. );
  1709. float vuf;
  1710. float gf = modf( v * 256., vuf );
  1711. return vec2( vuf * Inv255, gf );
  1712. }
  1713. float unpackRGBAToDepth( const in vec4 v ) {
  1714. return dot( v, UnpackFactors4 );
  1715. }
  1716. float unpackRGBToDepth( const in vec3 v ) {
  1717. return dot( v, UnpackFactors3 );
  1718. }
  1719. float unpackRGToDepth( const in vec2 v ) {
  1720. return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;
  1721. }
  1722. vec4 pack2HalfToRGBA( const in vec2 v ) {
  1723. vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
  1724. return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
  1725. }
  1726. vec2 unpackRGBATo2Half( const in vec4 v ) {
  1727. return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
  1728. }
  1729. float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
  1730. return ( viewZ + near ) / ( near - far );
  1731. }
  1732. float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
  1733. return depth * ( near - far ) - near;
  1734. }
  1735. float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
  1736. return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
  1737. }
  1738. float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
  1739. return ( near * far ) / ( ( far - near ) * depth - far );
  1740. }`,wRe=`#ifdef PREMULTIPLIED_ALPHA
  1741. gl_FragColor.rgb *= gl_FragColor.a;
  1742. #endif`,SRe=`vec4 mvPosition = vec4( transformed, 1.0 );
  1743. #ifdef USE_BATCHING
  1744. mvPosition = batchingMatrix * mvPosition;
  1745. #endif
  1746. #ifdef USE_INSTANCING
  1747. mvPosition = instanceMatrix * mvPosition;
  1748. #endif
  1749. mvPosition = modelViewMatrix * mvPosition;
  1750. gl_Position = projectionMatrix * mvPosition;`,NRe=`#ifdef DITHERING
  1751. gl_FragColor.rgb = dithering( gl_FragColor.rgb );
  1752. #endif`,MRe=`#ifdef DITHERING
  1753. vec3 dithering( vec3 color ) {
  1754. float grid_position = rand( gl_FragCoord.xy );
  1755. vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
  1756. dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
  1757. return color + dither_shift_RGB;
  1758. }
  1759. #endif`,ERe=`float roughnessFactor = roughness;
  1760. #ifdef USE_ROUGHNESSMAP
  1761. vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
  1762. roughnessFactor *= texelRoughness.g;
  1763. #endif`,TRe=`#ifdef USE_ROUGHNESSMAP
  1764. uniform sampler2D roughnessMap;
  1765. #endif`,ARe=`#if NUM_SPOT_LIGHT_COORDS > 0
  1766. varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
  1767. #endif
  1768. #if NUM_SPOT_LIGHT_MAPS > 0
  1769. uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
  1770. #endif
  1771. #ifdef USE_SHADOWMAP
  1772. #if NUM_DIR_LIGHT_SHADOWS > 0
  1773. uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
  1774. varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
  1775. struct DirectionalLightShadow {
  1776. float shadowIntensity;
  1777. float shadowBias;
  1778. float shadowNormalBias;
  1779. float shadowRadius;
  1780. vec2 shadowMapSize;
  1781. };
  1782. uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
  1783. #endif
  1784. #if NUM_SPOT_LIGHT_SHADOWS > 0
  1785. uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
  1786. struct SpotLightShadow {
  1787. float shadowIntensity;
  1788. float shadowBias;
  1789. float shadowNormalBias;
  1790. float shadowRadius;
  1791. vec2 shadowMapSize;
  1792. };
  1793. uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
  1794. #endif
  1795. #if NUM_POINT_LIGHT_SHADOWS > 0
  1796. uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
  1797. varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
  1798. struct PointLightShadow {
  1799. float shadowIntensity;
  1800. float shadowBias;
  1801. float shadowNormalBias;
  1802. float shadowRadius;
  1803. vec2 shadowMapSize;
  1804. float shadowCameraNear;
  1805. float shadowCameraFar;
  1806. };
  1807. uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
  1808. #endif
  1809. float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
  1810. float depth = unpackRGBAToDepth( texture2D( depths, uv ) );
  1811. #ifdef USE_REVERSED_DEPTH_BUFFER
  1812. return step( depth, compare );
  1813. #else
  1814. return step( compare, depth );
  1815. #endif
  1816. }
  1817. vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
  1818. return unpackRGBATo2Half( texture2D( shadow, uv ) );
  1819. }
  1820. float VSMShadow( sampler2D shadow, vec2 uv, float compare ) {
  1821. float occlusion = 1.0;
  1822. vec2 distribution = texture2DDistribution( shadow, uv );
  1823. #ifdef USE_REVERSED_DEPTH_BUFFER
  1824. float hard_shadow = step( distribution.x, compare );
  1825. #else
  1826. float hard_shadow = step( compare, distribution.x );
  1827. #endif
  1828. if ( hard_shadow != 1.0 ) {
  1829. float distance = compare - distribution.x;
  1830. float variance = max( 0.00000, distribution.y * distribution.y );
  1831. float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );
  1832. }
  1833. return occlusion;
  1834. }
  1835. float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
  1836. float shadow = 1.0;
  1837. shadowCoord.xyz /= shadowCoord.w;
  1838. shadowCoord.z += shadowBias;
  1839. bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
  1840. bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
  1841. if ( frustumTest ) {
  1842. #if defined( SHADOWMAP_TYPE_PCF )
  1843. vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
  1844. float dx0 = - texelSize.x * shadowRadius;
  1845. float dy0 = - texelSize.y * shadowRadius;
  1846. float dx1 = + texelSize.x * shadowRadius;
  1847. float dy1 = + texelSize.y * shadowRadius;
  1848. float dx2 = dx0 / 2.0;
  1849. float dy2 = dy0 / 2.0;
  1850. float dx3 = dx1 / 2.0;
  1851. float dy3 = dy1 / 2.0;
  1852. shadow = (
  1853. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
  1854. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
  1855. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
  1856. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
  1857. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
  1858. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
  1859. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
  1860. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
  1861. texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
  1862. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
  1863. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
  1864. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
  1865. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
  1866. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
  1867. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
  1868. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
  1869. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
  1870. ) * ( 1.0 / 17.0 );
  1871. #elif defined( SHADOWMAP_TYPE_PCF_SOFT )
  1872. vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
  1873. float dx = texelSize.x;
  1874. float dy = texelSize.y;
  1875. vec2 uv = shadowCoord.xy;
  1876. vec2 f = fract( uv * shadowMapSize + 0.5 );
  1877. uv -= f * texelSize;
  1878. shadow = (
  1879. texture2DCompare( shadowMap, uv, shadowCoord.z ) +
  1880. texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
  1881. texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
  1882. texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
  1883. mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
  1884. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
  1885. f.x ) +
  1886. mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
  1887. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
  1888. f.x ) +
  1889. mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
  1890. texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
  1891. f.y ) +
  1892. mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
  1893. texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
  1894. f.y ) +
  1895. mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
  1896. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
  1897. f.x ),
  1898. mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
  1899. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
  1900. f.x ),
  1901. f.y )
  1902. ) * ( 1.0 / 9.0 );
  1903. #elif defined( SHADOWMAP_TYPE_VSM )
  1904. shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
  1905. #else
  1906. shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
  1907. #endif
  1908. }
  1909. return mix( 1.0, shadow, shadowIntensity );
  1910. }
  1911. vec2 cubeToUV( vec3 v, float texelSizeY ) {
  1912. vec3 absV = abs( v );
  1913. float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
  1914. absV *= scaleToCube;
  1915. v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
  1916. vec2 planar = v.xy;
  1917. float almostATexel = 1.5 * texelSizeY;
  1918. float almostOne = 1.0 - almostATexel;
  1919. if ( absV.z >= almostOne ) {
  1920. if ( v.z > 0.0 )
  1921. planar.x = 4.0 - v.x;
  1922. } else if ( absV.x >= almostOne ) {
  1923. float signX = sign( v.x );
  1924. planar.x = v.z * signX + 2.0 * signX;
  1925. } else if ( absV.y >= almostOne ) {
  1926. float signY = sign( v.y );
  1927. planar.x = v.x + 2.0 * signY + 2.0;
  1928. planar.y = v.z * signY - 2.0;
  1929. }
  1930. return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
  1931. }
  1932. float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
  1933. float shadow = 1.0;
  1934. vec3 lightToPosition = shadowCoord.xyz;
  1935. float lightToPositionLength = length( lightToPosition );
  1936. if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {
  1937. float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
  1938. vec3 bd3D = normalize( lightToPosition );
  1939. vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
  1940. #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
  1941. vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
  1942. shadow = (
  1943. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
  1944. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
  1945. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
  1946. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
  1947. texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
  1948. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
  1949. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
  1950. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
  1951. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
  1952. ) * ( 1.0 / 9.0 );
  1953. #else
  1954. shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
  1955. #endif
  1956. }
  1957. return mix( 1.0, shadow, shadowIntensity );
  1958. }
  1959. #endif`,CRe=`#if NUM_SPOT_LIGHT_COORDS > 0
  1960. uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
  1961. varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
  1962. #endif
  1963. #ifdef USE_SHADOWMAP
  1964. #if NUM_DIR_LIGHT_SHADOWS > 0
  1965. uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
  1966. varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
  1967. struct DirectionalLightShadow {
  1968. float shadowIntensity;
  1969. float shadowBias;
  1970. float shadowNormalBias;
  1971. float shadowRadius;
  1972. vec2 shadowMapSize;
  1973. };
  1974. uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
  1975. #endif
  1976. #if NUM_SPOT_LIGHT_SHADOWS > 0
  1977. struct SpotLightShadow {
  1978. float shadowIntensity;
  1979. float shadowBias;
  1980. float shadowNormalBias;
  1981. float shadowRadius;
  1982. vec2 shadowMapSize;
  1983. };
  1984. uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
  1985. #endif
  1986. #if NUM_POINT_LIGHT_SHADOWS > 0
  1987. uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
  1988. varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
  1989. struct PointLightShadow {
  1990. float shadowIntensity;
  1991. float shadowBias;
  1992. float shadowNormalBias;
  1993. float shadowRadius;
  1994. vec2 shadowMapSize;
  1995. float shadowCameraNear;
  1996. float shadowCameraFar;
  1997. };
  1998. uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
  1999. #endif
  2000. #endif`,kRe=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
  2001. vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
  2002. vec4 shadowWorldPosition;
  2003. #endif
  2004. #if defined( USE_SHADOWMAP )
  2005. #if NUM_DIR_LIGHT_SHADOWS > 0
  2006. #pragma unroll_loop_start
  2007. for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
  2008. shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
  2009. vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
  2010. }
  2011. #pragma unroll_loop_end
  2012. #endif
  2013. #if NUM_POINT_LIGHT_SHADOWS > 0
  2014. #pragma unroll_loop_start
  2015. for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
  2016. shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
  2017. vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
  2018. }
  2019. #pragma unroll_loop_end
  2020. #endif
  2021. #endif
  2022. #if NUM_SPOT_LIGHT_COORDS > 0
  2023. #pragma unroll_loop_start
  2024. for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
  2025. shadowWorldPosition = worldPosition;
  2026. #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  2027. shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
  2028. #endif
  2029. vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
  2030. }
  2031. #pragma unroll_loop_end
  2032. #endif`,jRe=`float getShadowMask() {
  2033. float shadow = 1.0;
  2034. #ifdef USE_SHADOWMAP
  2035. #if NUM_DIR_LIGHT_SHADOWS > 0
  2036. DirectionalLightShadow directionalLight;
  2037. #pragma unroll_loop_start
  2038. for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
  2039. directionalLight = directionalLightShadows[ i ];
  2040. shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
  2041. }
  2042. #pragma unroll_loop_end
  2043. #endif
  2044. #if NUM_SPOT_LIGHT_SHADOWS > 0
  2045. SpotLightShadow spotLight;
  2046. #pragma unroll_loop_start
  2047. for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
  2048. spotLight = spotLightShadows[ i ];
  2049. shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
  2050. }
  2051. #pragma unroll_loop_end
  2052. #endif
  2053. #if NUM_POINT_LIGHT_SHADOWS > 0
  2054. PointLightShadow pointLight;
  2055. #pragma unroll_loop_start
  2056. for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
  2057. pointLight = pointLightShadows[ i ];
  2058. shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
  2059. }
  2060. #pragma unroll_loop_end
  2061. #endif
  2062. #endif
  2063. return shadow;
  2064. }`,PRe=`#ifdef USE_SKINNING
  2065. mat4 boneMatX = getBoneMatrix( skinIndex.x );
  2066. mat4 boneMatY = getBoneMatrix( skinIndex.y );
  2067. mat4 boneMatZ = getBoneMatrix( skinIndex.z );
  2068. mat4 boneMatW = getBoneMatrix( skinIndex.w );
  2069. #endif`,RRe=`#ifdef USE_SKINNING
  2070. uniform mat4 bindMatrix;
  2071. uniform mat4 bindMatrixInverse;
  2072. uniform highp sampler2D boneTexture;
  2073. mat4 getBoneMatrix( const in float i ) {
  2074. int size = textureSize( boneTexture, 0 ).x;
  2075. int j = int( i ) * 4;
  2076. int x = j % size;
  2077. int y = j / size;
  2078. vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
  2079. vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
  2080. vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
  2081. vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
  2082. return mat4( v1, v2, v3, v4 );
  2083. }
  2084. #endif`,DRe=`#ifdef USE_SKINNING
  2085. vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
  2086. vec4 skinned = vec4( 0.0 );
  2087. skinned += boneMatX * skinVertex * skinWeight.x;
  2088. skinned += boneMatY * skinVertex * skinWeight.y;
  2089. skinned += boneMatZ * skinVertex * skinWeight.z;
  2090. skinned += boneMatW * skinVertex * skinWeight.w;
  2091. transformed = ( bindMatrixInverse * skinned ).xyz;
  2092. #endif`,ORe=`#ifdef USE_SKINNING
  2093. mat4 skinMatrix = mat4( 0.0 );
  2094. skinMatrix += skinWeight.x * boneMatX;
  2095. skinMatrix += skinWeight.y * boneMatY;
  2096. skinMatrix += skinWeight.z * boneMatZ;
  2097. skinMatrix += skinWeight.w * boneMatW;
  2098. skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
  2099. objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
  2100. #ifdef USE_TANGENT
  2101. objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
  2102. #endif
  2103. #endif`,LRe=`float specularStrength;
  2104. #ifdef USE_SPECULARMAP
  2105. vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
  2106. specularStrength = texelSpecular.r;
  2107. #else
  2108. specularStrength = 1.0;
  2109. #endif`,IRe=`#ifdef USE_SPECULARMAP
  2110. uniform sampler2D specularMap;
  2111. #endif`,FRe=`#if defined( TONE_MAPPING )
  2112. gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
  2113. #endif`,URe=`#ifndef saturate
  2114. #define saturate( a ) clamp( a, 0.0, 1.0 )
  2115. #endif
  2116. uniform float toneMappingExposure;
  2117. vec3 LinearToneMapping( vec3 color ) {
  2118. return saturate( toneMappingExposure * color );
  2119. }
  2120. vec3 ReinhardToneMapping( vec3 color ) {
  2121. color *= toneMappingExposure;
  2122. return saturate( color / ( vec3( 1.0 ) + color ) );
  2123. }
  2124. vec3 CineonToneMapping( vec3 color ) {
  2125. color *= toneMappingExposure;
  2126. color = max( vec3( 0.0 ), color - 0.004 );
  2127. return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
  2128. }
  2129. vec3 RRTAndODTFit( vec3 v ) {
  2130. vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
  2131. vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
  2132. return a / b;
  2133. }
  2134. vec3 ACESFilmicToneMapping( vec3 color ) {
  2135. const mat3 ACESInputMat = mat3(
  2136. vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
  2137. vec3( 0.04823, 0.01566, 0.83777 )
  2138. );
  2139. const mat3 ACESOutputMat = mat3(
  2140. vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
  2141. vec3( -0.07367, -0.00605, 1.07602 )
  2142. );
  2143. color *= toneMappingExposure / 0.6;
  2144. color = ACESInputMat * color;
  2145. color = RRTAndODTFit( color );
  2146. color = ACESOutputMat * color;
  2147. return saturate( color );
  2148. }
  2149. const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(
  2150. vec3( 1.6605, - 0.1246, - 0.0182 ),
  2151. vec3( - 0.5876, 1.1329, - 0.1006 ),
  2152. vec3( - 0.0728, - 0.0083, 1.1187 )
  2153. );
  2154. const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(
  2155. vec3( 0.6274, 0.0691, 0.0164 ),
  2156. vec3( 0.3293, 0.9195, 0.0880 ),
  2157. vec3( 0.0433, 0.0113, 0.8956 )
  2158. );
  2159. vec3 agxDefaultContrastApprox( vec3 x ) {
  2160. vec3 x2 = x * x;
  2161. vec3 x4 = x2 * x2;
  2162. return + 15.5 * x4 * x2
  2163. - 40.14 * x4 * x
  2164. + 31.96 * x4
  2165. - 6.868 * x2 * x
  2166. + 0.4298 * x2
  2167. + 0.1191 * x
  2168. - 0.00232;
  2169. }
  2170. vec3 AgXToneMapping( vec3 color ) {
  2171. const mat3 AgXInsetMatrix = mat3(
  2172. vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),
  2173. vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),
  2174. vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )
  2175. );
  2176. const mat3 AgXOutsetMatrix = mat3(
  2177. vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),
  2178. vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),
  2179. vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )
  2180. );
  2181. const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069;
  2182. color *= toneMappingExposure;
  2183. color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;
  2184. color = AgXInsetMatrix * color;
  2185. color = max( color, 1e-10 ); color = log2( color );
  2186. color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );
  2187. color = clamp( color, 0.0, 1.0 );
  2188. color = agxDefaultContrastApprox( color );
  2189. color = AgXOutsetMatrix * color;
  2190. color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );
  2191. color = LINEAR_REC2020_TO_LINEAR_SRGB * color;
  2192. color = clamp( color, 0.0, 1.0 );
  2193. return color;
  2194. }
  2195. vec3 NeutralToneMapping( vec3 color ) {
  2196. const float StartCompression = 0.8 - 0.04;
  2197. const float Desaturation = 0.15;
  2198. color *= toneMappingExposure;
  2199. float x = min( color.r, min( color.g, color.b ) );
  2200. float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;
  2201. color -= offset;
  2202. float peak = max( color.r, max( color.g, color.b ) );
  2203. if ( peak < StartCompression ) return color;
  2204. float d = 1. - StartCompression;
  2205. float newPeak = 1. - d * d / ( peak + d - StartCompression );
  2206. color *= newPeak / peak;
  2207. float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
  2208. return mix( color, vec3( newPeak ), g );
  2209. }
  2210. vec3 CustomToneMapping( vec3 color ) { return color; }`,zRe=`#ifdef USE_TRANSMISSION
  2211. material.transmission = transmission;
  2212. material.transmissionAlpha = 1.0;
  2213. material.thickness = thickness;
  2214. material.attenuationDistance = attenuationDistance;
  2215. material.attenuationColor = attenuationColor;
  2216. #ifdef USE_TRANSMISSIONMAP
  2217. material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
  2218. #endif
  2219. #ifdef USE_THICKNESSMAP
  2220. material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
  2221. #endif
  2222. vec3 pos = vWorldPosition;
  2223. vec3 v = normalize( cameraPosition - pos );
  2224. vec3 n = inverseTransformDirection( normal, viewMatrix );
  2225. vec4 transmitted = getIBLVolumeRefraction(
  2226. n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
  2227. pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,
  2228. material.attenuationColor, material.attenuationDistance );
  2229. material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
  2230. totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
  2231. #endif`,BRe=`#ifdef USE_TRANSMISSION
  2232. uniform float transmission;
  2233. uniform float thickness;
  2234. uniform float attenuationDistance;
  2235. uniform vec3 attenuationColor;
  2236. #ifdef USE_TRANSMISSIONMAP
  2237. uniform sampler2D transmissionMap;
  2238. #endif
  2239. #ifdef USE_THICKNESSMAP
  2240. uniform sampler2D thicknessMap;
  2241. #endif
  2242. uniform vec2 transmissionSamplerSize;
  2243. uniform sampler2D transmissionSamplerMap;
  2244. uniform mat4 modelMatrix;
  2245. uniform mat4 projectionMatrix;
  2246. varying vec3 vWorldPosition;
  2247. float w0( float a ) {
  2248. return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
  2249. }
  2250. float w1( float a ) {
  2251. return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
  2252. }
  2253. float w2( float a ){
  2254. return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
  2255. }
  2256. float w3( float a ) {
  2257. return ( 1.0 / 6.0 ) * ( a * a * a );
  2258. }
  2259. float g0( float a ) {
  2260. return w0( a ) + w1( a );
  2261. }
  2262. float g1( float a ) {
  2263. return w2( a ) + w3( a );
  2264. }
  2265. float h0( float a ) {
  2266. return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
  2267. }
  2268. float h1( float a ) {
  2269. return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
  2270. }
  2271. vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
  2272. uv = uv * texelSize.zw + 0.5;
  2273. vec2 iuv = floor( uv );
  2274. vec2 fuv = fract( uv );
  2275. float g0x = g0( fuv.x );
  2276. float g1x = g1( fuv.x );
  2277. float h0x = h0( fuv.x );
  2278. float h1x = h1( fuv.x );
  2279. float h0y = h0( fuv.y );
  2280. float h1y = h1( fuv.y );
  2281. vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
  2282. vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
  2283. vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
  2284. vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
  2285. return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
  2286. g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
  2287. }
  2288. vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
  2289. vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
  2290. vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
  2291. vec2 fLodSizeInv = 1.0 / fLodSize;
  2292. vec2 cLodSizeInv = 1.0 / cLodSize;
  2293. vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
  2294. vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
  2295. return mix( fSample, cSample, fract( lod ) );
  2296. }
  2297. vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
  2298. vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
  2299. vec3 modelScale;
  2300. modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
  2301. modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
  2302. modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
  2303. return normalize( refractionVector ) * thickness * modelScale;
  2304. }
  2305. float applyIorToRoughness( const in float roughness, const in float ior ) {
  2306. return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
  2307. }
  2308. vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
  2309. float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
  2310. return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
  2311. }
  2312. vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
  2313. if ( isinf( attenuationDistance ) ) {
  2314. return vec3( 1.0 );
  2315. } else {
  2316. vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
  2317. vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
  2318. }
  2319. }
  2320. vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
  2321. const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
  2322. const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,
  2323. const in vec3 attenuationColor, const in float attenuationDistance ) {
  2324. vec4 transmittedLight;
  2325. vec3 transmittance;
  2326. #ifdef USE_DISPERSION
  2327. float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;
  2328. vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );
  2329. for ( int i = 0; i < 3; i ++ ) {
  2330. vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );
  2331. vec3 refractedRayExit = position + transmissionRay;
  2332. vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
  2333. vec2 refractionCoords = ndcPos.xy / ndcPos.w;
  2334. refractionCoords += 1.0;
  2335. refractionCoords /= 2.0;
  2336. vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );
  2337. transmittedLight[ i ] = transmissionSample[ i ];
  2338. transmittedLight.a += transmissionSample.a;
  2339. transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];
  2340. }
  2341. transmittedLight.a /= 3.0;
  2342. #else
  2343. vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
  2344. vec3 refractedRayExit = position + transmissionRay;
  2345. vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
  2346. vec2 refractionCoords = ndcPos.xy / ndcPos.w;
  2347. refractionCoords += 1.0;
  2348. refractionCoords /= 2.0;
  2349. transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
  2350. transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
  2351. #endif
  2352. vec3 attenuatedColor = transmittance * transmittedLight.rgb;
  2353. vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
  2354. float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
  2355. return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
  2356. }
  2357. #endif`,$Re=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  2358. varying vec2 vUv;
  2359. #endif
  2360. #ifdef USE_MAP
  2361. varying vec2 vMapUv;
  2362. #endif
  2363. #ifdef USE_ALPHAMAP
  2364. varying vec2 vAlphaMapUv;
  2365. #endif
  2366. #ifdef USE_LIGHTMAP
  2367. varying vec2 vLightMapUv;
  2368. #endif
  2369. #ifdef USE_AOMAP
  2370. varying vec2 vAoMapUv;
  2371. #endif
  2372. #ifdef USE_BUMPMAP
  2373. varying vec2 vBumpMapUv;
  2374. #endif
  2375. #ifdef USE_NORMALMAP
  2376. varying vec2 vNormalMapUv;
  2377. #endif
  2378. #ifdef USE_EMISSIVEMAP
  2379. varying vec2 vEmissiveMapUv;
  2380. #endif
  2381. #ifdef USE_METALNESSMAP
  2382. varying vec2 vMetalnessMapUv;
  2383. #endif
  2384. #ifdef USE_ROUGHNESSMAP
  2385. varying vec2 vRoughnessMapUv;
  2386. #endif
  2387. #ifdef USE_ANISOTROPYMAP
  2388. varying vec2 vAnisotropyMapUv;
  2389. #endif
  2390. #ifdef USE_CLEARCOATMAP
  2391. varying vec2 vClearcoatMapUv;
  2392. #endif
  2393. #ifdef USE_CLEARCOAT_NORMALMAP
  2394. varying vec2 vClearcoatNormalMapUv;
  2395. #endif
  2396. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  2397. varying vec2 vClearcoatRoughnessMapUv;
  2398. #endif
  2399. #ifdef USE_IRIDESCENCEMAP
  2400. varying vec2 vIridescenceMapUv;
  2401. #endif
  2402. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  2403. varying vec2 vIridescenceThicknessMapUv;
  2404. #endif
  2405. #ifdef USE_SHEEN_COLORMAP
  2406. varying vec2 vSheenColorMapUv;
  2407. #endif
  2408. #ifdef USE_SHEEN_ROUGHNESSMAP
  2409. varying vec2 vSheenRoughnessMapUv;
  2410. #endif
  2411. #ifdef USE_SPECULARMAP
  2412. varying vec2 vSpecularMapUv;
  2413. #endif
  2414. #ifdef USE_SPECULAR_COLORMAP
  2415. varying vec2 vSpecularColorMapUv;
  2416. #endif
  2417. #ifdef USE_SPECULAR_INTENSITYMAP
  2418. varying vec2 vSpecularIntensityMapUv;
  2419. #endif
  2420. #ifdef USE_TRANSMISSIONMAP
  2421. uniform mat3 transmissionMapTransform;
  2422. varying vec2 vTransmissionMapUv;
  2423. #endif
  2424. #ifdef USE_THICKNESSMAP
  2425. uniform mat3 thicknessMapTransform;
  2426. varying vec2 vThicknessMapUv;
  2427. #endif`,HRe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  2428. varying vec2 vUv;
  2429. #endif
  2430. #ifdef USE_MAP
  2431. uniform mat3 mapTransform;
  2432. varying vec2 vMapUv;
  2433. #endif
  2434. #ifdef USE_ALPHAMAP
  2435. uniform mat3 alphaMapTransform;
  2436. varying vec2 vAlphaMapUv;
  2437. #endif
  2438. #ifdef USE_LIGHTMAP
  2439. uniform mat3 lightMapTransform;
  2440. varying vec2 vLightMapUv;
  2441. #endif
  2442. #ifdef USE_AOMAP
  2443. uniform mat3 aoMapTransform;
  2444. varying vec2 vAoMapUv;
  2445. #endif
  2446. #ifdef USE_BUMPMAP
  2447. uniform mat3 bumpMapTransform;
  2448. varying vec2 vBumpMapUv;
  2449. #endif
  2450. #ifdef USE_NORMALMAP
  2451. uniform mat3 normalMapTransform;
  2452. varying vec2 vNormalMapUv;
  2453. #endif
  2454. #ifdef USE_DISPLACEMENTMAP
  2455. uniform mat3 displacementMapTransform;
  2456. varying vec2 vDisplacementMapUv;
  2457. #endif
  2458. #ifdef USE_EMISSIVEMAP
  2459. uniform mat3 emissiveMapTransform;
  2460. varying vec2 vEmissiveMapUv;
  2461. #endif
  2462. #ifdef USE_METALNESSMAP
  2463. uniform mat3 metalnessMapTransform;
  2464. varying vec2 vMetalnessMapUv;
  2465. #endif
  2466. #ifdef USE_ROUGHNESSMAP
  2467. uniform mat3 roughnessMapTransform;
  2468. varying vec2 vRoughnessMapUv;
  2469. #endif
  2470. #ifdef USE_ANISOTROPYMAP
  2471. uniform mat3 anisotropyMapTransform;
  2472. varying vec2 vAnisotropyMapUv;
  2473. #endif
  2474. #ifdef USE_CLEARCOATMAP
  2475. uniform mat3 clearcoatMapTransform;
  2476. varying vec2 vClearcoatMapUv;
  2477. #endif
  2478. #ifdef USE_CLEARCOAT_NORMALMAP
  2479. uniform mat3 clearcoatNormalMapTransform;
  2480. varying vec2 vClearcoatNormalMapUv;
  2481. #endif
  2482. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  2483. uniform mat3 clearcoatRoughnessMapTransform;
  2484. varying vec2 vClearcoatRoughnessMapUv;
  2485. #endif
  2486. #ifdef USE_SHEEN_COLORMAP
  2487. uniform mat3 sheenColorMapTransform;
  2488. varying vec2 vSheenColorMapUv;
  2489. #endif
  2490. #ifdef USE_SHEEN_ROUGHNESSMAP
  2491. uniform mat3 sheenRoughnessMapTransform;
  2492. varying vec2 vSheenRoughnessMapUv;
  2493. #endif
  2494. #ifdef USE_IRIDESCENCEMAP
  2495. uniform mat3 iridescenceMapTransform;
  2496. varying vec2 vIridescenceMapUv;
  2497. #endif
  2498. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  2499. uniform mat3 iridescenceThicknessMapTransform;
  2500. varying vec2 vIridescenceThicknessMapUv;
  2501. #endif
  2502. #ifdef USE_SPECULARMAP
  2503. uniform mat3 specularMapTransform;
  2504. varying vec2 vSpecularMapUv;
  2505. #endif
  2506. #ifdef USE_SPECULAR_COLORMAP
  2507. uniform mat3 specularColorMapTransform;
  2508. varying vec2 vSpecularColorMapUv;
  2509. #endif
  2510. #ifdef USE_SPECULAR_INTENSITYMAP
  2511. uniform mat3 specularIntensityMapTransform;
  2512. varying vec2 vSpecularIntensityMapUv;
  2513. #endif
  2514. #ifdef USE_TRANSMISSIONMAP
  2515. uniform mat3 transmissionMapTransform;
  2516. varying vec2 vTransmissionMapUv;
  2517. #endif
  2518. #ifdef USE_THICKNESSMAP
  2519. uniform mat3 thicknessMapTransform;
  2520. varying vec2 vThicknessMapUv;
  2521. #endif`,VRe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  2522. vUv = vec3( uv, 1 ).xy;
  2523. #endif
  2524. #ifdef USE_MAP
  2525. vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
  2526. #endif
  2527. #ifdef USE_ALPHAMAP
  2528. vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
  2529. #endif
  2530. #ifdef USE_LIGHTMAP
  2531. vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
  2532. #endif
  2533. #ifdef USE_AOMAP
  2534. vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
  2535. #endif
  2536. #ifdef USE_BUMPMAP
  2537. vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
  2538. #endif
  2539. #ifdef USE_NORMALMAP
  2540. vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
  2541. #endif
  2542. #ifdef USE_DISPLACEMENTMAP
  2543. vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
  2544. #endif
  2545. #ifdef USE_EMISSIVEMAP
  2546. vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
  2547. #endif
  2548. #ifdef USE_METALNESSMAP
  2549. vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
  2550. #endif
  2551. #ifdef USE_ROUGHNESSMAP
  2552. vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
  2553. #endif
  2554. #ifdef USE_ANISOTROPYMAP
  2555. vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
  2556. #endif
  2557. #ifdef USE_CLEARCOATMAP
  2558. vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
  2559. #endif
  2560. #ifdef USE_CLEARCOAT_NORMALMAP
  2561. vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
  2562. #endif
  2563. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  2564. vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
  2565. #endif
  2566. #ifdef USE_IRIDESCENCEMAP
  2567. vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
  2568. #endif
  2569. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  2570. vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
  2571. #endif
  2572. #ifdef USE_SHEEN_COLORMAP
  2573. vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
  2574. #endif
  2575. #ifdef USE_SHEEN_ROUGHNESSMAP
  2576. vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
  2577. #endif
  2578. #ifdef USE_SPECULARMAP
  2579. vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
  2580. #endif
  2581. #ifdef USE_SPECULAR_COLORMAP
  2582. vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
  2583. #endif
  2584. #ifdef USE_SPECULAR_INTENSITYMAP
  2585. vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
  2586. #endif
  2587. #ifdef USE_TRANSMISSIONMAP
  2588. vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
  2589. #endif
  2590. #ifdef USE_THICKNESSMAP
  2591. vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
  2592. #endif`,GRe=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
  2593. vec4 worldPosition = vec4( transformed, 1.0 );
  2594. #ifdef USE_BATCHING
  2595. worldPosition = batchingMatrix * worldPosition;
  2596. #endif
  2597. #ifdef USE_INSTANCING
  2598. worldPosition = instanceMatrix * worldPosition;
  2599. #endif
  2600. worldPosition = modelMatrix * worldPosition;
  2601. #endif`;const WRe=`varying vec2 vUv;
  2602. uniform mat3 uvTransform;
  2603. void main() {
  2604. vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
  2605. gl_Position = vec4( position.xy, 1.0, 1.0 );
  2606. }`,qRe=`uniform sampler2D t2D;
  2607. uniform float backgroundIntensity;
  2608. varying vec2 vUv;
  2609. void main() {
  2610. vec4 texColor = texture2D( t2D, vUv );
  2611. #ifdef DECODE_VIDEO_TEXTURE
  2612. texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );
  2613. #endif
  2614. texColor.rgb *= backgroundIntensity;
  2615. gl_FragColor = texColor;
  2616. #include <tonemapping_fragment>
  2617. #include <colorspace_fragment>
  2618. }`,KRe=`varying vec3 vWorldDirection;
  2619. #include <common>
  2620. void main() {
  2621. vWorldDirection = transformDirection( position, modelMatrix );
  2622. #include <begin_vertex>
  2623. #include <project_vertex>
  2624. gl_Position.z = gl_Position.w;
  2625. }`,XRe=`#ifdef ENVMAP_TYPE_CUBE
  2626. uniform samplerCube envMap;
  2627. #elif defined( ENVMAP_TYPE_CUBE_UV )
  2628. uniform sampler2D envMap;
  2629. #endif
  2630. uniform float flipEnvMap;
  2631. uniform float backgroundBlurriness;
  2632. uniform float backgroundIntensity;
  2633. uniform mat3 backgroundRotation;
  2634. varying vec3 vWorldDirection;
  2635. #include <cube_uv_reflection_fragment>
  2636. void main() {
  2637. #ifdef ENVMAP_TYPE_CUBE
  2638. vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
  2639. #elif defined( ENVMAP_TYPE_CUBE_UV )
  2640. vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );
  2641. #else
  2642. vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
  2643. #endif
  2644. texColor.rgb *= backgroundIntensity;
  2645. gl_FragColor = texColor;
  2646. #include <tonemapping_fragment>
  2647. #include <colorspace_fragment>
  2648. }`,YRe=`varying vec3 vWorldDirection;
  2649. #include <common>
  2650. void main() {
  2651. vWorldDirection = transformDirection( position, modelMatrix );
  2652. #include <begin_vertex>
  2653. #include <project_vertex>
  2654. gl_Position.z = gl_Position.w;
  2655. }`,QRe=`uniform samplerCube tCube;
  2656. uniform float tFlip;
  2657. uniform float opacity;
  2658. varying vec3 vWorldDirection;
  2659. void main() {
  2660. vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
  2661. gl_FragColor = texColor;
  2662. gl_FragColor.a *= opacity;
  2663. #include <tonemapping_fragment>
  2664. #include <colorspace_fragment>
  2665. }`,ZRe=`#include <common>
  2666. #include <batching_pars_vertex>
  2667. #include <uv_pars_vertex>
  2668. #include <displacementmap_pars_vertex>
  2669. #include <morphtarget_pars_vertex>
  2670. #include <skinning_pars_vertex>
  2671. #include <logdepthbuf_pars_vertex>
  2672. #include <clipping_planes_pars_vertex>
  2673. varying vec2 vHighPrecisionZW;
  2674. void main() {
  2675. #include <uv_vertex>
  2676. #include <batching_vertex>
  2677. #include <skinbase_vertex>
  2678. #include <morphinstance_vertex>
  2679. #ifdef USE_DISPLACEMENTMAP
  2680. #include <beginnormal_vertex>
  2681. #include <morphnormal_vertex>
  2682. #include <skinnormal_vertex>
  2683. #endif
  2684. #include <begin_vertex>
  2685. #include <morphtarget_vertex>
  2686. #include <skinning_vertex>
  2687. #include <displacementmap_vertex>
  2688. #include <project_vertex>
  2689. #include <logdepthbuf_vertex>
  2690. #include <clipping_planes_vertex>
  2691. vHighPrecisionZW = gl_Position.zw;
  2692. }`,JRe=`#if DEPTH_PACKING == 3200
  2693. uniform float opacity;
  2694. #endif
  2695. #include <common>
  2696. #include <packing>
  2697. #include <uv_pars_fragment>
  2698. #include <map_pars_fragment>
  2699. #include <alphamap_pars_fragment>
  2700. #include <alphatest_pars_fragment>
  2701. #include <alphahash_pars_fragment>
  2702. #include <logdepthbuf_pars_fragment>
  2703. #include <clipping_planes_pars_fragment>
  2704. varying vec2 vHighPrecisionZW;
  2705. void main() {
  2706. vec4 diffuseColor = vec4( 1.0 );
  2707. #include <clipping_planes_fragment>
  2708. #if DEPTH_PACKING == 3200
  2709. diffuseColor.a = opacity;
  2710. #endif
  2711. #include <map_fragment>
  2712. #include <alphamap_fragment>
  2713. #include <alphatest_fragment>
  2714. #include <alphahash_fragment>
  2715. #include <logdepthbuf_fragment>
  2716. #ifdef USE_REVERSED_DEPTH_BUFFER
  2717. float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ];
  2718. #else
  2719. float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5;
  2720. #endif
  2721. #if DEPTH_PACKING == 3200
  2722. gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
  2723. #elif DEPTH_PACKING == 3201
  2724. gl_FragColor = packDepthToRGBA( fragCoordZ );
  2725. #elif DEPTH_PACKING == 3202
  2726. gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );
  2727. #elif DEPTH_PACKING == 3203
  2728. gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
  2729. #endif
  2730. }`,eDe=`#define DISTANCE
  2731. varying vec3 vWorldPosition;
  2732. #include <common>
  2733. #include <batching_pars_vertex>
  2734. #include <uv_pars_vertex>
  2735. #include <displacementmap_pars_vertex>
  2736. #include <morphtarget_pars_vertex>
  2737. #include <skinning_pars_vertex>
  2738. #include <clipping_planes_pars_vertex>
  2739. void main() {
  2740. #include <uv_vertex>
  2741. #include <batching_vertex>
  2742. #include <skinbase_vertex>
  2743. #include <morphinstance_vertex>
  2744. #ifdef USE_DISPLACEMENTMAP
  2745. #include <beginnormal_vertex>
  2746. #include <morphnormal_vertex>
  2747. #include <skinnormal_vertex>
  2748. #endif
  2749. #include <begin_vertex>
  2750. #include <morphtarget_vertex>
  2751. #include <skinning_vertex>
  2752. #include <displacementmap_vertex>
  2753. #include <project_vertex>
  2754. #include <worldpos_vertex>
  2755. #include <clipping_planes_vertex>
  2756. vWorldPosition = worldPosition.xyz;
  2757. }`,tDe=`#define DISTANCE
  2758. uniform vec3 referencePosition;
  2759. uniform float nearDistance;
  2760. uniform float farDistance;
  2761. varying vec3 vWorldPosition;
  2762. #include <common>
  2763. #include <packing>
  2764. #include <uv_pars_fragment>
  2765. #include <map_pars_fragment>
  2766. #include <alphamap_pars_fragment>
  2767. #include <alphatest_pars_fragment>
  2768. #include <alphahash_pars_fragment>
  2769. #include <clipping_planes_pars_fragment>
  2770. void main () {
  2771. vec4 diffuseColor = vec4( 1.0 );
  2772. #include <clipping_planes_fragment>
  2773. #include <map_fragment>
  2774. #include <alphamap_fragment>
  2775. #include <alphatest_fragment>
  2776. #include <alphahash_fragment>
  2777. float dist = length( vWorldPosition - referencePosition );
  2778. dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
  2779. dist = saturate( dist );
  2780. gl_FragColor = packDepthToRGBA( dist );
  2781. }`,nDe=`varying vec3 vWorldDirection;
  2782. #include <common>
  2783. void main() {
  2784. vWorldDirection = transformDirection( position, modelMatrix );
  2785. #include <begin_vertex>
  2786. #include <project_vertex>
  2787. }`,rDe=`uniform sampler2D tEquirect;
  2788. varying vec3 vWorldDirection;
  2789. #include <common>
  2790. void main() {
  2791. vec3 direction = normalize( vWorldDirection );
  2792. vec2 sampleUV = equirectUv( direction );
  2793. gl_FragColor = texture2D( tEquirect, sampleUV );
  2794. #include <tonemapping_fragment>
  2795. #include <colorspace_fragment>
  2796. }`,iDe=`uniform float scale;
  2797. attribute float lineDistance;
  2798. varying float vLineDistance;
  2799. #include <common>
  2800. #include <uv_pars_vertex>
  2801. #include <color_pars_vertex>
  2802. #include <fog_pars_vertex>
  2803. #include <morphtarget_pars_vertex>
  2804. #include <logdepthbuf_pars_vertex>
  2805. #include <clipping_planes_pars_vertex>
  2806. void main() {
  2807. vLineDistance = scale * lineDistance;
  2808. #include <uv_vertex>
  2809. #include <color_vertex>
  2810. #include <morphinstance_vertex>
  2811. #include <morphcolor_vertex>
  2812. #include <begin_vertex>
  2813. #include <morphtarget_vertex>
  2814. #include <project_vertex>
  2815. #include <logdepthbuf_vertex>
  2816. #include <clipping_planes_vertex>
  2817. #include <fog_vertex>
  2818. }`,aDe=`uniform vec3 diffuse;
  2819. uniform float opacity;
  2820. uniform float dashSize;
  2821. uniform float totalSize;
  2822. varying float vLineDistance;
  2823. #include <common>
  2824. #include <color_pars_fragment>
  2825. #include <uv_pars_fragment>
  2826. #include <map_pars_fragment>
  2827. #include <fog_pars_fragment>
  2828. #include <logdepthbuf_pars_fragment>
  2829. #include <clipping_planes_pars_fragment>
  2830. void main() {
  2831. vec4 diffuseColor = vec4( diffuse, opacity );
  2832. #include <clipping_planes_fragment>
  2833. if ( mod( vLineDistance, totalSize ) > dashSize ) {
  2834. discard;
  2835. }
  2836. vec3 outgoingLight = vec3( 0.0 );
  2837. #include <logdepthbuf_fragment>
  2838. #include <map_fragment>
  2839. #include <color_fragment>
  2840. outgoingLight = diffuseColor.rgb;
  2841. #include <opaque_fragment>
  2842. #include <tonemapping_fragment>
  2843. #include <colorspace_fragment>
  2844. #include <fog_fragment>
  2845. #include <premultiplied_alpha_fragment>
  2846. }`,sDe=`#include <common>
  2847. #include <batching_pars_vertex>
  2848. #include <uv_pars_vertex>
  2849. #include <envmap_pars_vertex>
  2850. #include <color_pars_vertex>
  2851. #include <fog_pars_vertex>
  2852. #include <morphtarget_pars_vertex>
  2853. #include <skinning_pars_vertex>
  2854. #include <logdepthbuf_pars_vertex>
  2855. #include <clipping_planes_pars_vertex>
  2856. void main() {
  2857. #include <uv_vertex>
  2858. #include <color_vertex>
  2859. #include <morphinstance_vertex>
  2860. #include <morphcolor_vertex>
  2861. #include <batching_vertex>
  2862. #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
  2863. #include <beginnormal_vertex>
  2864. #include <morphnormal_vertex>
  2865. #include <skinbase_vertex>
  2866. #include <skinnormal_vertex>
  2867. #include <defaultnormal_vertex>
  2868. #endif
  2869. #include <begin_vertex>
  2870. #include <morphtarget_vertex>
  2871. #include <skinning_vertex>
  2872. #include <project_vertex>
  2873. #include <logdepthbuf_vertex>
  2874. #include <clipping_planes_vertex>
  2875. #include <worldpos_vertex>
  2876. #include <envmap_vertex>
  2877. #include <fog_vertex>
  2878. }`,oDe=`uniform vec3 diffuse;
  2879. uniform float opacity;
  2880. #ifndef FLAT_SHADED
  2881. varying vec3 vNormal;
  2882. #endif
  2883. #include <common>
  2884. #include <dithering_pars_fragment>
  2885. #include <color_pars_fragment>
  2886. #include <uv_pars_fragment>
  2887. #include <map_pars_fragment>
  2888. #include <alphamap_pars_fragment>
  2889. #include <alphatest_pars_fragment>
  2890. #include <alphahash_pars_fragment>
  2891. #include <aomap_pars_fragment>
  2892. #include <lightmap_pars_fragment>
  2893. #include <envmap_common_pars_fragment>
  2894. #include <envmap_pars_fragment>
  2895. #include <fog_pars_fragment>
  2896. #include <specularmap_pars_fragment>
  2897. #include <logdepthbuf_pars_fragment>
  2898. #include <clipping_planes_pars_fragment>
  2899. void main() {
  2900. vec4 diffuseColor = vec4( diffuse, opacity );
  2901. #include <clipping_planes_fragment>
  2902. #include <logdepthbuf_fragment>
  2903. #include <map_fragment>
  2904. #include <color_fragment>
  2905. #include <alphamap_fragment>
  2906. #include <alphatest_fragment>
  2907. #include <alphahash_fragment>
  2908. #include <specularmap_fragment>
  2909. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  2910. #ifdef USE_LIGHTMAP
  2911. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  2912. reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
  2913. #else
  2914. reflectedLight.indirectDiffuse += vec3( 1.0 );
  2915. #endif
  2916. #include <aomap_fragment>
  2917. reflectedLight.indirectDiffuse *= diffuseColor.rgb;
  2918. vec3 outgoingLight = reflectedLight.indirectDiffuse;
  2919. #include <envmap_fragment>
  2920. #include <opaque_fragment>
  2921. #include <tonemapping_fragment>
  2922. #include <colorspace_fragment>
  2923. #include <fog_fragment>
  2924. #include <premultiplied_alpha_fragment>
  2925. #include <dithering_fragment>
  2926. }`,lDe=`#define LAMBERT
  2927. varying vec3 vViewPosition;
  2928. #include <common>
  2929. #include <batching_pars_vertex>
  2930. #include <uv_pars_vertex>
  2931. #include <displacementmap_pars_vertex>
  2932. #include <envmap_pars_vertex>
  2933. #include <color_pars_vertex>
  2934. #include <fog_pars_vertex>
  2935. #include <normal_pars_vertex>
  2936. #include <morphtarget_pars_vertex>
  2937. #include <skinning_pars_vertex>
  2938. #include <shadowmap_pars_vertex>
  2939. #include <logdepthbuf_pars_vertex>
  2940. #include <clipping_planes_pars_vertex>
  2941. void main() {
  2942. #include <uv_vertex>
  2943. #include <color_vertex>
  2944. #include <morphinstance_vertex>
  2945. #include <morphcolor_vertex>
  2946. #include <batching_vertex>
  2947. #include <beginnormal_vertex>
  2948. #include <morphnormal_vertex>
  2949. #include <skinbase_vertex>
  2950. #include <skinnormal_vertex>
  2951. #include <defaultnormal_vertex>
  2952. #include <normal_vertex>
  2953. #include <begin_vertex>
  2954. #include <morphtarget_vertex>
  2955. #include <skinning_vertex>
  2956. #include <displacementmap_vertex>
  2957. #include <project_vertex>
  2958. #include <logdepthbuf_vertex>
  2959. #include <clipping_planes_vertex>
  2960. vViewPosition = - mvPosition.xyz;
  2961. #include <worldpos_vertex>
  2962. #include <envmap_vertex>
  2963. #include <shadowmap_vertex>
  2964. #include <fog_vertex>
  2965. }`,cDe=`#define LAMBERT
  2966. uniform vec3 diffuse;
  2967. uniform vec3 emissive;
  2968. uniform float opacity;
  2969. #include <common>
  2970. #include <packing>
  2971. #include <dithering_pars_fragment>
  2972. #include <color_pars_fragment>
  2973. #include <uv_pars_fragment>
  2974. #include <map_pars_fragment>
  2975. #include <alphamap_pars_fragment>
  2976. #include <alphatest_pars_fragment>
  2977. #include <alphahash_pars_fragment>
  2978. #include <aomap_pars_fragment>
  2979. #include <lightmap_pars_fragment>
  2980. #include <emissivemap_pars_fragment>
  2981. #include <envmap_common_pars_fragment>
  2982. #include <envmap_pars_fragment>
  2983. #include <fog_pars_fragment>
  2984. #include <bsdfs>
  2985. #include <lights_pars_begin>
  2986. #include <normal_pars_fragment>
  2987. #include <lights_lambert_pars_fragment>
  2988. #include <shadowmap_pars_fragment>
  2989. #include <bumpmap_pars_fragment>
  2990. #include <normalmap_pars_fragment>
  2991. #include <specularmap_pars_fragment>
  2992. #include <logdepthbuf_pars_fragment>
  2993. #include <clipping_planes_pars_fragment>
  2994. void main() {
  2995. vec4 diffuseColor = vec4( diffuse, opacity );
  2996. #include <clipping_planes_fragment>
  2997. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  2998. vec3 totalEmissiveRadiance = emissive;
  2999. #include <logdepthbuf_fragment>
  3000. #include <map_fragment>
  3001. #include <color_fragment>
  3002. #include <alphamap_fragment>
  3003. #include <alphatest_fragment>
  3004. #include <alphahash_fragment>
  3005. #include <specularmap_fragment>
  3006. #include <normal_fragment_begin>
  3007. #include <normal_fragment_maps>
  3008. #include <emissivemap_fragment>
  3009. #include <lights_lambert_fragment>
  3010. #include <lights_fragment_begin>
  3011. #include <lights_fragment_maps>
  3012. #include <lights_fragment_end>
  3013. #include <aomap_fragment>
  3014. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
  3015. #include <envmap_fragment>
  3016. #include <opaque_fragment>
  3017. #include <tonemapping_fragment>
  3018. #include <colorspace_fragment>
  3019. #include <fog_fragment>
  3020. #include <premultiplied_alpha_fragment>
  3021. #include <dithering_fragment>
  3022. }`,uDe=`#define MATCAP
  3023. varying vec3 vViewPosition;
  3024. #include <common>
  3025. #include <batching_pars_vertex>
  3026. #include <uv_pars_vertex>
  3027. #include <color_pars_vertex>
  3028. #include <displacementmap_pars_vertex>
  3029. #include <fog_pars_vertex>
  3030. #include <normal_pars_vertex>
  3031. #include <morphtarget_pars_vertex>
  3032. #include <skinning_pars_vertex>
  3033. #include <logdepthbuf_pars_vertex>
  3034. #include <clipping_planes_pars_vertex>
  3035. void main() {
  3036. #include <uv_vertex>
  3037. #include <color_vertex>
  3038. #include <morphinstance_vertex>
  3039. #include <morphcolor_vertex>
  3040. #include <batching_vertex>
  3041. #include <beginnormal_vertex>
  3042. #include <morphnormal_vertex>
  3043. #include <skinbase_vertex>
  3044. #include <skinnormal_vertex>
  3045. #include <defaultnormal_vertex>
  3046. #include <normal_vertex>
  3047. #include <begin_vertex>
  3048. #include <morphtarget_vertex>
  3049. #include <skinning_vertex>
  3050. #include <displacementmap_vertex>
  3051. #include <project_vertex>
  3052. #include <logdepthbuf_vertex>
  3053. #include <clipping_planes_vertex>
  3054. #include <fog_vertex>
  3055. vViewPosition = - mvPosition.xyz;
  3056. }`,dDe=`#define MATCAP
  3057. uniform vec3 diffuse;
  3058. uniform float opacity;
  3059. uniform sampler2D matcap;
  3060. varying vec3 vViewPosition;
  3061. #include <common>
  3062. #include <dithering_pars_fragment>
  3063. #include <color_pars_fragment>
  3064. #include <uv_pars_fragment>
  3065. #include <map_pars_fragment>
  3066. #include <alphamap_pars_fragment>
  3067. #include <alphatest_pars_fragment>
  3068. #include <alphahash_pars_fragment>
  3069. #include <fog_pars_fragment>
  3070. #include <normal_pars_fragment>
  3071. #include <bumpmap_pars_fragment>
  3072. #include <normalmap_pars_fragment>
  3073. #include <logdepthbuf_pars_fragment>
  3074. #include <clipping_planes_pars_fragment>
  3075. void main() {
  3076. vec4 diffuseColor = vec4( diffuse, opacity );
  3077. #include <clipping_planes_fragment>
  3078. #include <logdepthbuf_fragment>
  3079. #include <map_fragment>
  3080. #include <color_fragment>
  3081. #include <alphamap_fragment>
  3082. #include <alphatest_fragment>
  3083. #include <alphahash_fragment>
  3084. #include <normal_fragment_begin>
  3085. #include <normal_fragment_maps>
  3086. vec3 viewDir = normalize( vViewPosition );
  3087. vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
  3088. vec3 y = cross( viewDir, x );
  3089. vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
  3090. #ifdef USE_MATCAP
  3091. vec4 matcapColor = texture2D( matcap, uv );
  3092. #else
  3093. vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
  3094. #endif
  3095. vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
  3096. #include <opaque_fragment>
  3097. #include <tonemapping_fragment>
  3098. #include <colorspace_fragment>
  3099. #include <fog_fragment>
  3100. #include <premultiplied_alpha_fragment>
  3101. #include <dithering_fragment>
  3102. }`,hDe=`#define NORMAL
  3103. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  3104. varying vec3 vViewPosition;
  3105. #endif
  3106. #include <common>
  3107. #include <batching_pars_vertex>
  3108. #include <uv_pars_vertex>
  3109. #include <displacementmap_pars_vertex>
  3110. #include <normal_pars_vertex>
  3111. #include <morphtarget_pars_vertex>
  3112. #include <skinning_pars_vertex>
  3113. #include <logdepthbuf_pars_vertex>
  3114. #include <clipping_planes_pars_vertex>
  3115. void main() {
  3116. #include <uv_vertex>
  3117. #include <batching_vertex>
  3118. #include <beginnormal_vertex>
  3119. #include <morphinstance_vertex>
  3120. #include <morphnormal_vertex>
  3121. #include <skinbase_vertex>
  3122. #include <skinnormal_vertex>
  3123. #include <defaultnormal_vertex>
  3124. #include <normal_vertex>
  3125. #include <begin_vertex>
  3126. #include <morphtarget_vertex>
  3127. #include <skinning_vertex>
  3128. #include <displacementmap_vertex>
  3129. #include <project_vertex>
  3130. #include <logdepthbuf_vertex>
  3131. #include <clipping_planes_vertex>
  3132. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  3133. vViewPosition = - mvPosition.xyz;
  3134. #endif
  3135. }`,fDe=`#define NORMAL
  3136. uniform float opacity;
  3137. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  3138. varying vec3 vViewPosition;
  3139. #endif
  3140. #include <packing>
  3141. #include <uv_pars_fragment>
  3142. #include <normal_pars_fragment>
  3143. #include <bumpmap_pars_fragment>
  3144. #include <normalmap_pars_fragment>
  3145. #include <logdepthbuf_pars_fragment>
  3146. #include <clipping_planes_pars_fragment>
  3147. void main() {
  3148. vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );
  3149. #include <clipping_planes_fragment>
  3150. #include <logdepthbuf_fragment>
  3151. #include <normal_fragment_begin>
  3152. #include <normal_fragment_maps>
  3153. gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );
  3154. #ifdef OPAQUE
  3155. gl_FragColor.a = 1.0;
  3156. #endif
  3157. }`,mDe=`#define PHONG
  3158. varying vec3 vViewPosition;
  3159. #include <common>
  3160. #include <batching_pars_vertex>
  3161. #include <uv_pars_vertex>
  3162. #include <displacementmap_pars_vertex>
  3163. #include <envmap_pars_vertex>
  3164. #include <color_pars_vertex>
  3165. #include <fog_pars_vertex>
  3166. #include <normal_pars_vertex>
  3167. #include <morphtarget_pars_vertex>
  3168. #include <skinning_pars_vertex>
  3169. #include <shadowmap_pars_vertex>
  3170. #include <logdepthbuf_pars_vertex>
  3171. #include <clipping_planes_pars_vertex>
  3172. void main() {
  3173. #include <uv_vertex>
  3174. #include <color_vertex>
  3175. #include <morphcolor_vertex>
  3176. #include <batching_vertex>
  3177. #include <beginnormal_vertex>
  3178. #include <morphinstance_vertex>
  3179. #include <morphnormal_vertex>
  3180. #include <skinbase_vertex>
  3181. #include <skinnormal_vertex>
  3182. #include <defaultnormal_vertex>
  3183. #include <normal_vertex>
  3184. #include <begin_vertex>
  3185. #include <morphtarget_vertex>
  3186. #include <skinning_vertex>
  3187. #include <displacementmap_vertex>
  3188. #include <project_vertex>
  3189. #include <logdepthbuf_vertex>
  3190. #include <clipping_planes_vertex>
  3191. vViewPosition = - mvPosition.xyz;
  3192. #include <worldpos_vertex>
  3193. #include <envmap_vertex>
  3194. #include <shadowmap_vertex>
  3195. #include <fog_vertex>
  3196. }`,pDe=`#define PHONG
  3197. uniform vec3 diffuse;
  3198. uniform vec3 emissive;
  3199. uniform vec3 specular;
  3200. uniform float shininess;
  3201. uniform float opacity;
  3202. #include <common>
  3203. #include <packing>
  3204. #include <dithering_pars_fragment>
  3205. #include <color_pars_fragment>
  3206. #include <uv_pars_fragment>
  3207. #include <map_pars_fragment>
  3208. #include <alphamap_pars_fragment>
  3209. #include <alphatest_pars_fragment>
  3210. #include <alphahash_pars_fragment>
  3211. #include <aomap_pars_fragment>
  3212. #include <lightmap_pars_fragment>
  3213. #include <emissivemap_pars_fragment>
  3214. #include <envmap_common_pars_fragment>
  3215. #include <envmap_pars_fragment>
  3216. #include <fog_pars_fragment>
  3217. #include <bsdfs>
  3218. #include <lights_pars_begin>
  3219. #include <normal_pars_fragment>
  3220. #include <lights_phong_pars_fragment>
  3221. #include <shadowmap_pars_fragment>
  3222. #include <bumpmap_pars_fragment>
  3223. #include <normalmap_pars_fragment>
  3224. #include <specularmap_pars_fragment>
  3225. #include <logdepthbuf_pars_fragment>
  3226. #include <clipping_planes_pars_fragment>
  3227. void main() {
  3228. vec4 diffuseColor = vec4( diffuse, opacity );
  3229. #include <clipping_planes_fragment>
  3230. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  3231. vec3 totalEmissiveRadiance = emissive;
  3232. #include <logdepthbuf_fragment>
  3233. #include <map_fragment>
  3234. #include <color_fragment>
  3235. #include <alphamap_fragment>
  3236. #include <alphatest_fragment>
  3237. #include <alphahash_fragment>
  3238. #include <specularmap_fragment>
  3239. #include <normal_fragment_begin>
  3240. #include <normal_fragment_maps>
  3241. #include <emissivemap_fragment>
  3242. #include <lights_phong_fragment>
  3243. #include <lights_fragment_begin>
  3244. #include <lights_fragment_maps>
  3245. #include <lights_fragment_end>
  3246. #include <aomap_fragment>
  3247. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
  3248. #include <envmap_fragment>
  3249. #include <opaque_fragment>
  3250. #include <tonemapping_fragment>
  3251. #include <colorspace_fragment>
  3252. #include <fog_fragment>
  3253. #include <premultiplied_alpha_fragment>
  3254. #include <dithering_fragment>
  3255. }`,gDe=`#define STANDARD
  3256. varying vec3 vViewPosition;
  3257. #ifdef USE_TRANSMISSION
  3258. varying vec3 vWorldPosition;
  3259. #endif
  3260. #include <common>
  3261. #include <batching_pars_vertex>
  3262. #include <uv_pars_vertex>
  3263. #include <displacementmap_pars_vertex>
  3264. #include <color_pars_vertex>
  3265. #include <fog_pars_vertex>
  3266. #include <normal_pars_vertex>
  3267. #include <morphtarget_pars_vertex>
  3268. #include <skinning_pars_vertex>
  3269. #include <shadowmap_pars_vertex>
  3270. #include <logdepthbuf_pars_vertex>
  3271. #include <clipping_planes_pars_vertex>
  3272. void main() {
  3273. #include <uv_vertex>
  3274. #include <color_vertex>
  3275. #include <morphinstance_vertex>
  3276. #include <morphcolor_vertex>
  3277. #include <batching_vertex>
  3278. #include <beginnormal_vertex>
  3279. #include <morphnormal_vertex>
  3280. #include <skinbase_vertex>
  3281. #include <skinnormal_vertex>
  3282. #include <defaultnormal_vertex>
  3283. #include <normal_vertex>
  3284. #include <begin_vertex>
  3285. #include <morphtarget_vertex>
  3286. #include <skinning_vertex>
  3287. #include <displacementmap_vertex>
  3288. #include <project_vertex>
  3289. #include <logdepthbuf_vertex>
  3290. #include <clipping_planes_vertex>
  3291. vViewPosition = - mvPosition.xyz;
  3292. #include <worldpos_vertex>
  3293. #include <shadowmap_vertex>
  3294. #include <fog_vertex>
  3295. #ifdef USE_TRANSMISSION
  3296. vWorldPosition = worldPosition.xyz;
  3297. #endif
  3298. }`,xDe=`#define STANDARD
  3299. #ifdef PHYSICAL
  3300. #define IOR
  3301. #define USE_SPECULAR
  3302. #endif
  3303. uniform vec3 diffuse;
  3304. uniform vec3 emissive;
  3305. uniform float roughness;
  3306. uniform float metalness;
  3307. uniform float opacity;
  3308. #ifdef IOR
  3309. uniform float ior;
  3310. #endif
  3311. #ifdef USE_SPECULAR
  3312. uniform float specularIntensity;
  3313. uniform vec3 specularColor;
  3314. #ifdef USE_SPECULAR_COLORMAP
  3315. uniform sampler2D specularColorMap;
  3316. #endif
  3317. #ifdef USE_SPECULAR_INTENSITYMAP
  3318. uniform sampler2D specularIntensityMap;
  3319. #endif
  3320. #endif
  3321. #ifdef USE_CLEARCOAT
  3322. uniform float clearcoat;
  3323. uniform float clearcoatRoughness;
  3324. #endif
  3325. #ifdef USE_DISPERSION
  3326. uniform float dispersion;
  3327. #endif
  3328. #ifdef USE_IRIDESCENCE
  3329. uniform float iridescence;
  3330. uniform float iridescenceIOR;
  3331. uniform float iridescenceThicknessMinimum;
  3332. uniform float iridescenceThicknessMaximum;
  3333. #endif
  3334. #ifdef USE_SHEEN
  3335. uniform vec3 sheenColor;
  3336. uniform float sheenRoughness;
  3337. #ifdef USE_SHEEN_COLORMAP
  3338. uniform sampler2D sheenColorMap;
  3339. #endif
  3340. #ifdef USE_SHEEN_ROUGHNESSMAP
  3341. uniform sampler2D sheenRoughnessMap;
  3342. #endif
  3343. #endif
  3344. #ifdef USE_ANISOTROPY
  3345. uniform vec2 anisotropyVector;
  3346. #ifdef USE_ANISOTROPYMAP
  3347. uniform sampler2D anisotropyMap;
  3348. #endif
  3349. #endif
  3350. varying vec3 vViewPosition;
  3351. #include <common>
  3352. #include <packing>
  3353. #include <dithering_pars_fragment>
  3354. #include <color_pars_fragment>
  3355. #include <uv_pars_fragment>
  3356. #include <map_pars_fragment>
  3357. #include <alphamap_pars_fragment>
  3358. #include <alphatest_pars_fragment>
  3359. #include <alphahash_pars_fragment>
  3360. #include <aomap_pars_fragment>
  3361. #include <lightmap_pars_fragment>
  3362. #include <emissivemap_pars_fragment>
  3363. #include <iridescence_fragment>
  3364. #include <cube_uv_reflection_fragment>
  3365. #include <envmap_common_pars_fragment>
  3366. #include <envmap_physical_pars_fragment>
  3367. #include <fog_pars_fragment>
  3368. #include <lights_pars_begin>
  3369. #include <normal_pars_fragment>
  3370. #include <lights_physical_pars_fragment>
  3371. #include <transmission_pars_fragment>
  3372. #include <shadowmap_pars_fragment>
  3373. #include <bumpmap_pars_fragment>
  3374. #include <normalmap_pars_fragment>
  3375. #include <clearcoat_pars_fragment>
  3376. #include <iridescence_pars_fragment>
  3377. #include <roughnessmap_pars_fragment>
  3378. #include <metalnessmap_pars_fragment>
  3379. #include <logdepthbuf_pars_fragment>
  3380. #include <clipping_planes_pars_fragment>
  3381. void main() {
  3382. vec4 diffuseColor = vec4( diffuse, opacity );
  3383. #include <clipping_planes_fragment>
  3384. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  3385. vec3 totalEmissiveRadiance = emissive;
  3386. #include <logdepthbuf_fragment>
  3387. #include <map_fragment>
  3388. #include <color_fragment>
  3389. #include <alphamap_fragment>
  3390. #include <alphatest_fragment>
  3391. #include <alphahash_fragment>
  3392. #include <roughnessmap_fragment>
  3393. #include <metalnessmap_fragment>
  3394. #include <normal_fragment_begin>
  3395. #include <normal_fragment_maps>
  3396. #include <clearcoat_normal_fragment_begin>
  3397. #include <clearcoat_normal_fragment_maps>
  3398. #include <emissivemap_fragment>
  3399. #include <lights_physical_fragment>
  3400. #include <lights_fragment_begin>
  3401. #include <lights_fragment_maps>
  3402. #include <lights_fragment_end>
  3403. #include <aomap_fragment>
  3404. vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
  3405. vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
  3406. #include <transmission_fragment>
  3407. vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
  3408. #ifdef USE_SHEEN
  3409. float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
  3410. outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
  3411. #endif
  3412. #ifdef USE_CLEARCOAT
  3413. float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
  3414. vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
  3415. outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
  3416. #endif
  3417. #include <opaque_fragment>
  3418. #include <tonemapping_fragment>
  3419. #include <colorspace_fragment>
  3420. #include <fog_fragment>
  3421. #include <premultiplied_alpha_fragment>
  3422. #include <dithering_fragment>
  3423. }`,bDe=`#define TOON
  3424. varying vec3 vViewPosition;
  3425. #include <common>
  3426. #include <batching_pars_vertex>
  3427. #include <uv_pars_vertex>
  3428. #include <displacementmap_pars_vertex>
  3429. #include <color_pars_vertex>
  3430. #include <fog_pars_vertex>
  3431. #include <normal_pars_vertex>
  3432. #include <morphtarget_pars_vertex>
  3433. #include <skinning_pars_vertex>
  3434. #include <shadowmap_pars_vertex>
  3435. #include <logdepthbuf_pars_vertex>
  3436. #include <clipping_planes_pars_vertex>
  3437. void main() {
  3438. #include <uv_vertex>
  3439. #include <color_vertex>
  3440. #include <morphinstance_vertex>
  3441. #include <morphcolor_vertex>
  3442. #include <batching_vertex>
  3443. #include <beginnormal_vertex>
  3444. #include <morphnormal_vertex>
  3445. #include <skinbase_vertex>
  3446. #include <skinnormal_vertex>
  3447. #include <defaultnormal_vertex>
  3448. #include <normal_vertex>
  3449. #include <begin_vertex>
  3450. #include <morphtarget_vertex>
  3451. #include <skinning_vertex>
  3452. #include <displacementmap_vertex>
  3453. #include <project_vertex>
  3454. #include <logdepthbuf_vertex>
  3455. #include <clipping_planes_vertex>
  3456. vViewPosition = - mvPosition.xyz;
  3457. #include <worldpos_vertex>
  3458. #include <shadowmap_vertex>
  3459. #include <fog_vertex>
  3460. }`,yDe=`#define TOON
  3461. uniform vec3 diffuse;
  3462. uniform vec3 emissive;
  3463. uniform float opacity;
  3464. #include <common>
  3465. #include <packing>
  3466. #include <dithering_pars_fragment>
  3467. #include <color_pars_fragment>
  3468. #include <uv_pars_fragment>
  3469. #include <map_pars_fragment>
  3470. #include <alphamap_pars_fragment>
  3471. #include <alphatest_pars_fragment>
  3472. #include <alphahash_pars_fragment>
  3473. #include <aomap_pars_fragment>
  3474. #include <lightmap_pars_fragment>
  3475. #include <emissivemap_pars_fragment>
  3476. #include <gradientmap_pars_fragment>
  3477. #include <fog_pars_fragment>
  3478. #include <bsdfs>
  3479. #include <lights_pars_begin>
  3480. #include <normal_pars_fragment>
  3481. #include <lights_toon_pars_fragment>
  3482. #include <shadowmap_pars_fragment>
  3483. #include <bumpmap_pars_fragment>
  3484. #include <normalmap_pars_fragment>
  3485. #include <logdepthbuf_pars_fragment>
  3486. #include <clipping_planes_pars_fragment>
  3487. void main() {
  3488. vec4 diffuseColor = vec4( diffuse, opacity );
  3489. #include <clipping_planes_fragment>
  3490. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  3491. vec3 totalEmissiveRadiance = emissive;
  3492. #include <logdepthbuf_fragment>
  3493. #include <map_fragment>
  3494. #include <color_fragment>
  3495. #include <alphamap_fragment>
  3496. #include <alphatest_fragment>
  3497. #include <alphahash_fragment>
  3498. #include <normal_fragment_begin>
  3499. #include <normal_fragment_maps>
  3500. #include <emissivemap_fragment>
  3501. #include <lights_toon_fragment>
  3502. #include <lights_fragment_begin>
  3503. #include <lights_fragment_maps>
  3504. #include <lights_fragment_end>
  3505. #include <aomap_fragment>
  3506. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
  3507. #include <opaque_fragment>
  3508. #include <tonemapping_fragment>
  3509. #include <colorspace_fragment>
  3510. #include <fog_fragment>
  3511. #include <premultiplied_alpha_fragment>
  3512. #include <dithering_fragment>
  3513. }`,vDe=`uniform float size;
  3514. uniform float scale;
  3515. #include <common>
  3516. #include <color_pars_vertex>
  3517. #include <fog_pars_vertex>
  3518. #include <morphtarget_pars_vertex>
  3519. #include <logdepthbuf_pars_vertex>
  3520. #include <clipping_planes_pars_vertex>
  3521. #ifdef USE_POINTS_UV
  3522. varying vec2 vUv;
  3523. uniform mat3 uvTransform;
  3524. #endif
  3525. void main() {
  3526. #ifdef USE_POINTS_UV
  3527. vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
  3528. #endif
  3529. #include <color_vertex>
  3530. #include <morphinstance_vertex>
  3531. #include <morphcolor_vertex>
  3532. #include <begin_vertex>
  3533. #include <morphtarget_vertex>
  3534. #include <project_vertex>
  3535. gl_PointSize = size;
  3536. #ifdef USE_SIZEATTENUATION
  3537. bool isPerspective = isPerspectiveMatrix( projectionMatrix );
  3538. if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
  3539. #endif
  3540. #include <logdepthbuf_vertex>
  3541. #include <clipping_planes_vertex>
  3542. #include <worldpos_vertex>
  3543. #include <fog_vertex>
  3544. }`,_De=`uniform vec3 diffuse;
  3545. uniform float opacity;
  3546. #include <common>
  3547. #include <color_pars_fragment>
  3548. #include <map_particle_pars_fragment>
  3549. #include <alphatest_pars_fragment>
  3550. #include <alphahash_pars_fragment>
  3551. #include <fog_pars_fragment>
  3552. #include <logdepthbuf_pars_fragment>
  3553. #include <clipping_planes_pars_fragment>
  3554. void main() {
  3555. vec4 diffuseColor = vec4( diffuse, opacity );
  3556. #include <clipping_planes_fragment>
  3557. vec3 outgoingLight = vec3( 0.0 );
  3558. #include <logdepthbuf_fragment>
  3559. #include <map_particle_fragment>
  3560. #include <color_fragment>
  3561. #include <alphatest_fragment>
  3562. #include <alphahash_fragment>
  3563. outgoingLight = diffuseColor.rgb;
  3564. #include <opaque_fragment>
  3565. #include <tonemapping_fragment>
  3566. #include <colorspace_fragment>
  3567. #include <fog_fragment>
  3568. #include <premultiplied_alpha_fragment>
  3569. }`,wDe=`#include <common>
  3570. #include <batching_pars_vertex>
  3571. #include <fog_pars_vertex>
  3572. #include <morphtarget_pars_vertex>
  3573. #include <skinning_pars_vertex>
  3574. #include <logdepthbuf_pars_vertex>
  3575. #include <shadowmap_pars_vertex>
  3576. void main() {
  3577. #include <batching_vertex>
  3578. #include <beginnormal_vertex>
  3579. #include <morphinstance_vertex>
  3580. #include <morphnormal_vertex>
  3581. #include <skinbase_vertex>
  3582. #include <skinnormal_vertex>
  3583. #include <defaultnormal_vertex>
  3584. #include <begin_vertex>
  3585. #include <morphtarget_vertex>
  3586. #include <skinning_vertex>
  3587. #include <project_vertex>
  3588. #include <logdepthbuf_vertex>
  3589. #include <worldpos_vertex>
  3590. #include <shadowmap_vertex>
  3591. #include <fog_vertex>
  3592. }`,SDe=`uniform vec3 color;
  3593. uniform float opacity;
  3594. #include <common>
  3595. #include <packing>
  3596. #include <fog_pars_fragment>
  3597. #include <bsdfs>
  3598. #include <lights_pars_begin>
  3599. #include <logdepthbuf_pars_fragment>
  3600. #include <shadowmap_pars_fragment>
  3601. #include <shadowmask_pars_fragment>
  3602. void main() {
  3603. #include <logdepthbuf_fragment>
  3604. gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
  3605. #include <tonemapping_fragment>
  3606. #include <colorspace_fragment>
  3607. #include <fog_fragment>
  3608. }`,NDe=`uniform float rotation;
  3609. uniform vec2 center;
  3610. #include <common>
  3611. #include <uv_pars_vertex>
  3612. #include <fog_pars_vertex>
  3613. #include <logdepthbuf_pars_vertex>
  3614. #include <clipping_planes_pars_vertex>
  3615. void main() {
  3616. #include <uv_vertex>
  3617. vec4 mvPosition = modelViewMatrix[ 3 ];
  3618. vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );
  3619. #ifndef USE_SIZEATTENUATION
  3620. bool isPerspective = isPerspectiveMatrix( projectionMatrix );
  3621. if ( isPerspective ) scale *= - mvPosition.z;
  3622. #endif
  3623. vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
  3624. vec2 rotatedPosition;
  3625. rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
  3626. rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
  3627. mvPosition.xy += rotatedPosition;
  3628. gl_Position = projectionMatrix * mvPosition;
  3629. #include <logdepthbuf_vertex>
  3630. #include <clipping_planes_vertex>
  3631. #include <fog_vertex>
  3632. }`,MDe=`uniform vec3 diffuse;
  3633. uniform float opacity;
  3634. #include <common>
  3635. #include <uv_pars_fragment>
  3636. #include <map_pars_fragment>
  3637. #include <alphamap_pars_fragment>
  3638. #include <alphatest_pars_fragment>
  3639. #include <alphahash_pars_fragment>
  3640. #include <fog_pars_fragment>
  3641. #include <logdepthbuf_pars_fragment>
  3642. #include <clipping_planes_pars_fragment>
  3643. void main() {
  3644. vec4 diffuseColor = vec4( diffuse, opacity );
  3645. #include <clipping_planes_fragment>
  3646. vec3 outgoingLight = vec3( 0.0 );
  3647. #include <logdepthbuf_fragment>
  3648. #include <map_fragment>
  3649. #include <alphamap_fragment>
  3650. #include <alphatest_fragment>
  3651. #include <alphahash_fragment>
  3652. outgoingLight = diffuseColor.rgb;
  3653. #include <opaque_fragment>
  3654. #include <tonemapping_fragment>
  3655. #include <colorspace_fragment>
  3656. #include <fog_fragment>
  3657. }`,Sn={alphahash_fragment:q3e,alphahash_pars_fragment:K3e,alphamap_fragment:X3e,alphamap_pars_fragment:Y3e,alphatest_fragment:Q3e,alphatest_pars_fragment:Z3e,aomap_fragment:J3e,aomap_pars_fragment:ePe,batching_pars_vertex:tPe,batching_vertex:nPe,begin_vertex:rPe,beginnormal_vertex:iPe,bsdfs:aPe,iridescence_fragment:sPe,bumpmap_pars_fragment:oPe,clipping_planes_fragment:lPe,clipping_planes_pars_fragment:cPe,clipping_planes_pars_vertex:uPe,clipping_planes_vertex:dPe,color_fragment:hPe,color_pars_fragment:fPe,color_pars_vertex:mPe,color_vertex:pPe,common:gPe,cube_uv_reflection_fragment:xPe,defaultnormal_vertex:bPe,displacementmap_pars_vertex:yPe,displacementmap_vertex:vPe,emissivemap_fragment:_Pe,emissivemap_pars_fragment:wPe,colorspace_fragment:SPe,colorspace_pars_fragment:NPe,envmap_fragment:MPe,envmap_common_pars_fragment:EPe,envmap_pars_fragment:TPe,envmap_pars_vertex:APe,envmap_physical_pars_fragment:UPe,envmap_vertex:CPe,fog_vertex:kPe,fog_pars_vertex:jPe,fog_fragment:PPe,fog_pars_fragment:RPe,gradientmap_pars_fragment:DPe,lightmap_pars_fragment:OPe,lights_lambert_fragment:LPe,lights_lambert_pars_fragment:IPe,lights_pars_begin:FPe,lights_toon_fragment:zPe,lights_toon_pars_fragment:BPe,lights_phong_fragment:$Pe,lights_phong_pars_fragment:HPe,lights_physical_fragment:VPe,lights_physical_pars_fragment:GPe,lights_fragment_begin:WPe,lights_fragment_maps:qPe,lights_fragment_end:KPe,logdepthbuf_fragment:XPe,logdepthbuf_pars_fragment:YPe,logdepthbuf_pars_vertex:QPe,logdepthbuf_vertex:ZPe,map_fragment:JPe,map_pars_fragment:eRe,map_particle_fragment:tRe,map_particle_pars_fragment:nRe,metalnessmap_fragment:rRe,metalnessmap_pars_fragment:iRe,morphinstance_vertex:aRe,morphcolor_vertex:sRe,morphnormal_vertex:oRe,morphtarget_pars_vertex:lRe,morphtarget_vertex:cRe,normal_fragment_begin:uRe,normal_fragment_maps:dRe,normal_pars_fragment:hRe,normal_pars_vertex:fRe,normal_vertex:mRe,normalmap_pars_fragment:pRe,clearcoat_normal_fragment_begin:gRe,clearcoat_normal_fragment_maps:xRe,clearcoat_pars_fragment:bRe,iridescence_pars_fragment:yRe,opaque_fragment:vRe,packing:_Re,premultiplied_alpha_fragment:wRe,project_vertex:SRe,dithering_fragment:NRe,dithering_pars_fragment:MRe,roughnessmap_fragment:ERe,roughnessmap_pars_fragment:TRe,shadowmap_pars_fragment:ARe,shadowmap_pars_vertex:CRe,shadowmap_vertex:kRe,shadowmask_pars_fragment:jRe,skinbase_vertex:PRe,skinning_pars_vertex:RRe,skinning_vertex:DRe,skinnormal_vertex:ORe,specularmap_fragment:LRe,specularmap_pars_fragment:IRe,tonemapping_fragment:FRe,tonemapping_pars_fragment:URe,transmission_fragment:zRe,transmission_pars_fragment:BRe,uv_pars_fragment:$Re,uv_pars_vertex:HRe,uv_vertex:VRe,worldpos_vertex:GRe,background_vert:WRe,background_frag:qRe,backgroundCube_vert:KRe,backgroundCube_frag:XRe,cube_vert:YRe,cube_frag:QRe,depth_vert:ZRe,depth_frag:JRe,distanceRGBA_vert:eDe,distanceRGBA_frag:tDe,equirect_vert:nDe,equirect_frag:rDe,linedashed_vert:iDe,linedashed_frag:aDe,meshbasic_vert:sDe,meshbasic_frag:oDe,meshlambert_vert:lDe,meshlambert_frag:cDe,meshmatcap_vert:uDe,meshmatcap_frag:dDe,meshnormal_vert:hDe,meshnormal_frag:fDe,meshphong_vert:mDe,meshphong_frag:pDe,meshphysical_vert:gDe,meshphysical_frag:xDe,meshtoon_vert:bDe,meshtoon_frag:yDe,points_vert:vDe,points_frag:_De,shadow_vert:wDe,shadow_frag:SDe,sprite_vert:NDe,sprite_frag:MDe},Lt={common:{diffuse:{value:new Dn(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Tn},alphaMap:{value:null},alphaMapTransform:{value:new Tn},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Tn}},envmap:{envMap:{value:null},envMapRotation:{value:new Tn},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 Tn}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Tn}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Tn},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Tn},normalScale:{value:new Mn(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Tn},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Tn}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Tn}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Tn}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Dn(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{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 Dn(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Tn},alphaTest:{value:0},uvTransform:{value:new Tn}},sprite:{diffuse:{value:new Dn(16777215)},opacity:{value:1},center:{value:new Mn(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Tn},alphaMap:{value:null},alphaMapTransform:{value:new Tn},alphaTest:{value:0}}},Al={basic:{uniforms:$a([Lt.common,Lt.specularmap,Lt.envmap,Lt.aomap,Lt.lightmap,Lt.fog]),vertexShader:Sn.meshbasic_vert,fragmentShader:Sn.meshbasic_frag},lambert:{uniforms:$a([Lt.common,Lt.specularmap,Lt.envmap,Lt.aomap,Lt.lightmap,Lt.emissivemap,Lt.bumpmap,Lt.normalmap,Lt.displacementmap,Lt.fog,Lt.lights,{emissive:{value:new Dn(0)}}]),vertexShader:Sn.meshlambert_vert,fragmentShader:Sn.meshlambert_frag},phong:{uniforms:$a([Lt.common,Lt.specularmap,Lt.envmap,Lt.aomap,Lt.lightmap,Lt.emissivemap,Lt.bumpmap,Lt.normalmap,Lt.displacementmap,Lt.fog,Lt.lights,{emissive:{value:new Dn(0)},specular:{value:new Dn(1118481)},shininess:{value:30}}]),vertexShader:Sn.meshphong_vert,fragmentShader:Sn.meshphong_frag},standard:{uniforms:$a([Lt.common,Lt.envmap,Lt.aomap,Lt.lightmap,Lt.emissivemap,Lt.bumpmap,Lt.normalmap,Lt.displacementmap,Lt.roughnessmap,Lt.metalnessmap,Lt.fog,Lt.lights,{emissive:{value:new Dn(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Sn.meshphysical_vert,fragmentShader:Sn.meshphysical_frag},toon:{uniforms:$a([Lt.common,Lt.aomap,Lt.lightmap,Lt.emissivemap,Lt.bumpmap,Lt.normalmap,Lt.displacementmap,Lt.gradientmap,Lt.fog,Lt.lights,{emissive:{value:new Dn(0)}}]),vertexShader:Sn.meshtoon_vert,fragmentShader:Sn.meshtoon_frag},matcap:{uniforms:$a([Lt.common,Lt.bumpmap,Lt.normalmap,Lt.displacementmap,Lt.fog,{matcap:{value:null}}]),vertexShader:Sn.meshmatcap_vert,fragmentShader:Sn.meshmatcap_frag},points:{uniforms:$a([Lt.points,Lt.fog]),vertexShader:Sn.points_vert,fragmentShader:Sn.points_frag},dashed:{uniforms:$a([Lt.common,Lt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Sn.linedashed_vert,fragmentShader:Sn.linedashed_frag},depth:{uniforms:$a([Lt.common,Lt.displacementmap]),vertexShader:Sn.depth_vert,fragmentShader:Sn.depth_frag},normal:{uniforms:$a([Lt.common,Lt.bumpmap,Lt.normalmap,Lt.displacementmap,{opacity:{value:1}}]),vertexShader:Sn.meshnormal_vert,fragmentShader:Sn.meshnormal_frag},sprite:{uniforms:$a([Lt.sprite,Lt.fog]),vertexShader:Sn.sprite_vert,fragmentShader:Sn.sprite_frag},background:{uniforms:{uvTransform:{value:new Tn},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Sn.background_vert,fragmentShader:Sn.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Tn}},vertexShader:Sn.backgroundCube_vert,fragmentShader:Sn.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Sn.cube_vert,fragmentShader:Sn.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Sn.equirect_vert,fragmentShader:Sn.equirect_frag},distanceRGBA:{uniforms:$a([Lt.common,Lt.displacementmap,{referencePosition:{value:new lt},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Sn.distanceRGBA_vert,fragmentShader:Sn.distanceRGBA_frag},shadow:{uniforms:$a([Lt.lights,Lt.fog,{color:{value:new Dn(0)},opacity:{value:1}}]),vertexShader:Sn.shadow_vert,fragmentShader:Sn.shadow_frag}};Al.physical={uniforms:$a([Al.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Tn},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Tn},clearcoatNormalScale:{value:new Mn(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Tn},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Tn},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Tn},sheen:{value:0},sheenColor:{value:new Dn(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Tn},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Tn},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Tn},transmissionSamplerSize:{value:new Mn},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Tn},attenuationDistance:{value:0},attenuationColor:{value:new Dn(0)},specularColor:{value:new Dn(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Tn},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Tn},anisotropyVector:{value:new Mn},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Tn}}]),vertexShader:Sn.meshphysical_vert,fragmentShader:Sn.meshphysical_frag};const $_={r:0,b:0,g:0},Ph=new Xd,EDe=new Mi;function TDe(t,e,n,r,i,a,o){const l=new Dn(0);let c=a===!0?0:1,u,d,f=null,m=0,p=null;function x(S){let T=S.isScene===!0?S.background:null;return T&&T.isTexture&&(T=(S.backgroundBlurriness>0?n:e).get(T)),T}function y(S){let T=!1;const E=x(S);E===null?v(l,c):E&&E.isColor&&(v(E,1),T=!0);const C=t.xr.getEnvironmentBlendMode();C==="additive"?r.buffers.color.setClear(0,0,0,1,o):C==="alpha-blend"&&r.buffers.color.setClear(0,0,0,0,o),(t.autoClear||T)&&(r.buffers.depth.setTest(!0),r.buffers.depth.setMask(!0),r.buffers.color.setMask(!0),t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil))}function b(S,T){const E=x(T);E&&(E.isCubeTexture||E.mapping===zN)?(d===void 0&&(d=new Wl(new PO(1,1,1),new mu({name:"BackgroundCubeMaterial",uniforms:vg(Al.backgroundCube.uniforms),vertexShader:Al.backgroundCube.vertexShader,fragmentShader:Al.backgroundCube.fragmentShader,side:bs,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),d.geometry.deleteAttribute("normal"),d.geometry.deleteAttribute("uv"),d.onBeforeRender=function(C,A,O){this.matrixWorld.copyPosition(O.matrixWorld)},Object.defineProperty(d.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(d)),Ph.copy(T.backgroundRotation),Ph.x*=-1,Ph.y*=-1,Ph.z*=-1,E.isCubeTexture&&E.isRenderTargetTexture===!1&&(Ph.y*=-1,Ph.z*=-1),d.material.uniforms.envMap.value=E,d.material.uniforms.flipEnvMap.value=E.isCubeTexture&&E.isRenderTargetTexture===!1?-1:1,d.material.uniforms.backgroundBlurriness.value=T.backgroundBlurriness,d.material.uniforms.backgroundIntensity.value=T.backgroundIntensity,d.material.uniforms.backgroundRotation.value.setFromMatrix4(EDe.makeRotationFromEuler(Ph)),d.material.toneMapped=qn.getTransfer(E.colorSpace)!==hr,(f!==E||m!==E.version||p!==t.toneMapping)&&(d.material.needsUpdate=!0,f=E,m=E.version,p=t.toneMapping),d.layers.enableAll(),S.unshift(d,d.geometry,d.material,0,0,null)):E&&E.isTexture&&(u===void 0&&(u=new Wl(new DO(2,2),new mu({name:"BackgroundMaterial",uniforms:vg(Al.background.uniforms),vertexShader:Al.background.vertexShader,fragmentShader:Al.background.fragmentShader,side:Kd,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),u.geometry.deleteAttribute("normal"),Object.defineProperty(u.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(u)),u.material.uniforms.t2D.value=E,u.material.uniforms.backgroundIntensity.value=T.backgroundIntensity,u.material.toneMapped=qn.getTransfer(E.colorSpace)!==hr,E.matrixAutoUpdate===!0&&E.updateMatrix(),u.material.uniforms.uvTransform.value.copy(E.matrix),(f!==E||m!==E.version||p!==t.toneMapping)&&(u.material.needsUpdate=!0,f=E,m=E.version,p=t.toneMapping),u.layers.enableAll(),S.unshift(u,u.geometry,u.material,0,0,null))}function v(S,T){S.getRGB($_,sJ(t)),r.buffers.color.setClear($_.r,$_.g,$_.b,T,o)}function N(){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(S,T=1){l.set(S),c=T,v(l,c)},getClearAlpha:function(){return c},setClearAlpha:function(S){c=S,v(l,c)},render:y,addToRenderList:b,dispose:N}}function ADe(t,e){const n=t.getParameter(t.MAX_VERTEX_ATTRIBS),r={},i=m(null);let a=i,o=!1;function l(R,F,L,K,j){let W=!1;const Y=f(K,L,F);a!==Y&&(a=Y,u(a.object)),W=p(R,K,L,j),W&&x(R,K,L,j),j!==null&&e.update(j,t.ELEMENT_ARRAY_BUFFER),(W||o)&&(o=!1,T(R,F,L,K),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,F,L){const K=L.wireframe===!0;let j=r[R.id];j===void 0&&(j={},r[R.id]=j);let W=j[F.id];W===void 0&&(W={},j[F.id]=W);let Y=W[K];return Y===void 0&&(Y=m(c()),W[K]=Y),Y}function m(R){const F=[],L=[],K=[];for(let j=0;j<n;j++)F[j]=0,L[j]=0,K[j]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:F,enabledAttributes:L,attributeDivisors:K,object:R,attributes:{},index:null}}function p(R,F,L,K){const j=a.attributes,W=F.attributes;let Y=0;const q=L.getAttributes();for(const Q in q)if(q[Q].location>=0){const re=j[Q];let z=W[Q];if(z===void 0&&(Q==="instanceMatrix"&&R.instanceMatrix&&(z=R.instanceMatrix),Q==="instanceColor"&&R.instanceColor&&(z=R.instanceColor)),re===void 0||re.attribute!==z||z&&re.data!==z.data)return!0;Y++}return a.attributesNum!==Y||a.index!==K}function x(R,F,L,K){const j={},W=F.attributes;let Y=0;const q=L.getAttributes();for(const Q in q)if(q[Q].location>=0){let re=W[Q];re===void 0&&(Q==="instanceMatrix"&&R.instanceMatrix&&(re=R.instanceMatrix),Q==="instanceColor"&&R.instanceColor&&(re=R.instanceColor));const z={};z.attribute=re,re&&re.data&&(z.data=re.data),j[Q]=z,Y++}a.attributes=j,a.attributesNum=Y,a.index=K}function y(){const R=a.newAttributes;for(let F=0,L=R.length;F<L;F++)R[F]=0}function b(R){v(R,0)}function v(R,F){const L=a.newAttributes,K=a.enabledAttributes,j=a.attributeDivisors;L[R]=1,K[R]===0&&(t.enableVertexAttribArray(R),K[R]=1),j[R]!==F&&(t.vertexAttribDivisor(R,F),j[R]=F)}function N(){const R=a.newAttributes,F=a.enabledAttributes;for(let L=0,K=F.length;L<K;L++)F[L]!==R[L]&&(t.disableVertexAttribArray(L),F[L]=0)}function S(R,F,L,K,j,W,Y){Y===!0?t.vertexAttribIPointer(R,F,L,j,W):t.vertexAttribPointer(R,F,L,K,j,W)}function T(R,F,L,K){y();const j=K.attributes,W=L.getAttributes(),Y=F.defaultAttributeValues;for(const q in W){const Q=W[q];if(Q.location>=0){let ee=j[q];if(ee===void 0&&(q==="instanceMatrix"&&R.instanceMatrix&&(ee=R.instanceMatrix),q==="instanceColor"&&R.instanceColor&&(ee=R.instanceColor)),ee!==void 0){const re=ee.normalized,z=ee.itemSize,G=e.get(ee);if(G===void 0)continue;const ae=G.buffer,se=G.type,ue=G.bytesPerElement,pe=se===t.INT||se===t.UNSIGNED_INT||ee.gpuType===wO;if(ee.isInterleavedBufferAttribute){const ce=ee.data,Me=ce.stride,me=ee.offset;if(ce.isInstancedInterleavedBuffer){for(let Ee=0;Ee<Q.locationSize;Ee++)v(Q.location+Ee,ce.meshPerAttribute);R.isInstancedMesh!==!0&&K._maxInstanceCount===void 0&&(K._maxInstanceCount=ce.meshPerAttribute*ce.count)}else for(let Ee=0;Ee<Q.locationSize;Ee++)b(Q.location+Ee);t.bindBuffer(t.ARRAY_BUFFER,ae);for(let Ee=0;Ee<Q.locationSize;Ee++)S(Q.location+Ee,z/Q.locationSize,se,re,Me*ue,(me+z/Q.locationSize*Ee)*ue,pe)}else{if(ee.isInstancedBufferAttribute){for(let ce=0;ce<Q.locationSize;ce++)v(Q.location+ce,ee.meshPerAttribute);R.isInstancedMesh!==!0&&K._maxInstanceCount===void 0&&(K._maxInstanceCount=ee.meshPerAttribute*ee.count)}else for(let ce=0;ce<Q.locationSize;ce++)b(Q.location+ce);t.bindBuffer(t.ARRAY_BUFFER,ae);for(let ce=0;ce<Q.locationSize;ce++)S(Q.location+ce,z/Q.locationSize,se,re,z*ue,z/Q.locationSize*ce*ue,pe)}}else if(Y!==void 0){const re=Y[q];if(re!==void 0)switch(re.length){case 2:t.vertexAttrib2fv(Q.location,re);break;case 3:t.vertexAttrib3fv(Q.location,re);break;case 4:t.vertexAttrib4fv(Q.location,re);break;default:t.vertexAttrib1fv(Q.location,re)}}}}N()}function E(){O();for(const R in r){const F=r[R];for(const L in F){const K=F[L];for(const j in K)d(K[j].object),delete K[j];delete F[L]}delete r[R]}}function C(R){if(r[R.id]===void 0)return;const F=r[R.id];for(const L in F){const K=F[L];for(const j in K)d(K[j].object),delete K[j];delete F[L]}delete r[R.id]}function A(R){for(const F in r){const L=r[F];if(L[R.id]===void 0)continue;const K=L[R.id];for(const j in K)d(K[j].object),delete K[j];delete L[R.id]}}function O(){k(),o=!0,a!==i&&(a=i,u(a.object))}function k(){i.geometry=null,i.program=null,i.wireframe=!1}return{setup:l,reset:O,resetDefaultState:k,dispose:E,releaseStatesOfGeometry:C,releaseStatesOfProgram:A,initAttributes:y,enableAttribute:b,disableUnusedAttributes:N}}function CDe(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 p=0;for(let x=0;x<f;x++)p+=d[x];n.update(p,r,1)}function c(u,d,f,m){if(f===0)return;const p=e.get("WEBGL_multi_draw");if(p===null)for(let x=0;x<u.length;x++)o(u[x],d[x],m[x]);else{p.multiDrawArraysInstancedWEBGL(r,u,0,d,0,m,0,f);let x=0;for(let y=0;y<f;y++)x+=d[y]*m[y];n.update(x,r,1)}}this.setMode=i,this.render=a,this.renderInstances=o,this.renderMultiDraw=l,this.renderMultiDrawInstances=c}function kDe(t,e,n,r){let i;function a(){if(i!==void 0)return i;if(e.has("EXT_texture_filter_anisotropic")===!0){const A=e.get("EXT_texture_filter_anisotropic");i=t.getParameter(A.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i}function o(A){return!(A!==nl&&r.convert(A)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_FORMAT))}function l(A){const O=A===Zg&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(A!==Gl&&r.convert(A)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_TYPE)&&A!==qc&&!O)}function c(A){if(A==="highp"){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";A="mediump"}return A==="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&&(mn("WebGLRenderer:",u,"not supported, using",d,"instead."),u=d);const f=n.logarithmicDepthBuffer===!0,m=n.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),p=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),x=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),y=t.getParameter(t.MAX_TEXTURE_SIZE),b=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),v=t.getParameter(t.MAX_VERTEX_ATTRIBS),N=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),S=t.getParameter(t.MAX_VARYING_VECTORS),T=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),E=x>0,C=t.getParameter(t.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:a,getMaxPrecision:c,textureFormatReadable:o,textureTypeReadable:l,precision:u,logarithmicDepthBuffer:f,reversedDepthBuffer:m,maxTextures:p,maxVertexTextures:x,maxTextureSize:y,maxCubemapSize:b,maxAttributes:v,maxVertexUniforms:N,maxVaryings:S,maxFragmentUniforms:T,vertexTextures:E,maxSamples:C}}function jDe(t){const e=this;let n=null,r=0,i=!1,a=!1;const o=new ud,l=new Tn,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(f,m){const p=f.length!==0||m||r!==0||i;return i=m,r=f.length,p},this.beginShadows=function(){a=!0,d(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(f,m){n=d(f,m,0)},this.setState=function(f,m,p){const x=f.clippingPlanes,y=f.clipIntersection,b=f.clipShadows,v=t.get(f);if(!i||x===null||x.length===0||a&&!b)a?d(null):u();else{const N=a?0:r,S=N*4;let T=v.clippingState||null;c.value=T,T=d(x,m,S,p);for(let E=0;E!==S;++E)T[E]=n[E];v.clippingState=T,this.numIntersection=y?this.numPlanes:0,this.numPlanes+=N}};function u(){c.value!==n&&(c.value=n,c.needsUpdate=r>0),e.numPlanes=r,e.numIntersection=0}function d(f,m,p,x){const y=f!==null?f.length:0;let b=null;if(y!==0){if(b=c.value,x!==!0||b===null){const v=p+y*4,N=m.matrixWorldInverse;l.getNormalMatrix(N),(b===null||b.length<v)&&(b=new Float32Array(v));for(let S=0,T=p;S!==y;++S,T+=4)o.copy(f[S]).applyMatrix4(N,l),o.normal.toArray(b,T),b[T+3]=o.constant}c.value=b,c.needsUpdate=!0}return e.numPlanes=y,e.numIntersection=0,b}}function PDe(t){let e=new WeakMap;function n(o,l){return l===fP?o.mapping=xg:l===mP&&(o.mapping=bg),o}function r(o){if(o&&o.isTexture){const l=o.mapping;if(l===fP||l===mP)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 T3e(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 wd=4,GH=[.125,.215,.35,.446,.526,.582],Wh=20,RDe=256,fb=new mJ,WH=new Dn;let YC=null,QC=0,ZC=0,JC=!1;const DDe=new lt;let qH=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=DDe}=a;YC=this._renderer.getRenderTarget(),QC=this._renderer.getActiveCubeFace(),ZC=this._renderer.getActiveMipmapLevel(),JC=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=YH(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=XH(),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(YC,QC,ZC),this._renderer.xr.enabled=JC,e.scissorTest=!1,np(e,0,0,e.width,e.height)}_fromTexture(e,n){e.mapping===xg||e.mapping===bg?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),YC=this._renderer.getRenderTarget(),QC=this._renderer.getActiveCubeFace(),ZC=this._renderer.getActiveMipmapLevel(),JC=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:To,minFilter:To,generateMipmaps:!1,type:Zg,format:nl,colorSpace:yg,depthBuffer:!1},i=KH(e,n,r);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==n){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=KH(e,n,r);const{_lodMax:a}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=ODe(a)),this._blurMaterial=IDe(a,e,n),this._ggxMaterial=LDe(a,e,n)}return i}_compileMaterial(e){const n=new Wl(new ec,e);this._renderer.compile(n,fb)}_sceneToCubeUV(e,n,r,i,a){const c=new _o(90,1,n,r),u=[1,-1,1,1,1,1],d=[1,1,1,-1,-1,-1],f=this._renderer,m=f.autoClear,p=f.toneMapping;f.getClearColor(WH),f.toneMapping=Rd,f.autoClear=!1,f.state.buffers.depth.getReversed()&&(f.setRenderTarget(i),f.clearDepth(),f.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new Wl(new PO,new jO({name:"PMREM.Background",side:bs,depthWrite:!1,depthTest:!1})));const y=this._backgroundBox,b=y.material;let v=!1;const N=e.background;N?N.isColor&&(b.color.copy(N),e.background=null,v=!0):(b.color.copy(WH),v=!0);for(let S=0;S<6;S++){const T=S%3;T===0?(c.up.set(0,u[S],0),c.position.set(a.x,a.y,a.z),c.lookAt(a.x+d[S],a.y,a.z)):T===1?(c.up.set(0,0,u[S]),c.position.set(a.x,a.y,a.z),c.lookAt(a.x,a.y+d[S],a.z)):(c.up.set(0,u[S],0),c.position.set(a.x,a.y,a.z),c.lookAt(a.x,a.y,a.z+d[S]));const E=this._cubeSize;np(i,T*E,S>2?E:0,E,E),f.setRenderTarget(i),v&&f.render(y,c),f.render(e,c)}f.toneMapping=p,f.autoClear=m,e.background=N}_textureToCubeUV(e,n){const r=this._renderer,i=e.mapping===xg||e.mapping===bg;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=YH()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=XH());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;np(n,0,0,3*c,2*c),r.setRenderTarget(n),r.render(o,fb)}_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),m=.05+u*.95,p=f*m,{_lodMax:x}=this,y=this._sizeLods[r],b=3*y*(r>x-wd?r-x+wd:0),v=4*(this._cubeSize-y);c.envMap.value=e.texture,c.roughness.value=p,c.mipInt.value=x-n,np(a,b,v,3*y,2*y),i.setRenderTarget(a),i.render(l,fb),c.envMap.value=a.texture,c.roughness.value=0,c.mipInt.value=x-r,np(e,b,v,3*y,2*y),i.setRenderTarget(e),i.render(l,fb)}_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"&&ui("blur direction must be either latitudinal or longitudinal!");const d=3,f=this._lodMeshes[i];f.material=u;const m=u.uniforms,p=this._sizeLods[r]-1,x=isFinite(a)?Math.PI/(2*p):2*Math.PI/(2*Wh-1),y=a/x,b=isFinite(a)?1+Math.floor(d*y):Wh;b>Wh&&mn(`sigmaRadians, ${a}, is too large and will clip, as it requested ${b} samples when the maximum is set to ${Wh}`);const v=[];let N=0;for(let A=0;A<Wh;++A){const O=A/y,k=Math.exp(-O*O/2);v.push(k),A===0?N+=k:A<b&&(N+=2*k)}for(let A=0;A<v.length;A++)v[A]=v[A]/N;m.envMap.value=e.texture,m.samples.value=b,m.weights.value=v,m.latitudinal.value=o==="latitudinal",l&&(m.poleAxis.value=l);const{_lodMax:S}=this;m.dTheta.value=x,m.mipInt.value=S-r;const T=this._sizeLods[i],E=3*T*(i>S-wd?i-S+wd:0),C=4*(this._cubeSize-T);np(n,E,C,3*T,2*T),c.setRenderTarget(n),c.render(f,fb)}};function ODe(t){const e=[],n=[],r=[];let i=t;const a=t-wd+1+GH.length;for(let o=0;o<a;o++){const l=Math.pow(2,i);e.push(l);let c=1/l;o>t-wd?c=GH[o-t+wd-1]:o===0&&(c=0),n.push(c);const u=1/(l-2),d=-u,f=1+u,m=[d,d,f,d,f,f,d,d,f,f,d,f],p=6,x=6,y=3,b=2,v=1,N=new Float32Array(y*x*p),S=new Float32Array(b*x*p),T=new Float32Array(v*x*p);for(let C=0;C<p;C++){const A=C%3*2/3-1,O=C>2?0:-1,k=[A,O,0,A+2/3,O,0,A+2/3,O+1,0,A,O,0,A+2/3,O+1,0,A,O+1,0];N.set(k,y*x*C),S.set(m,b*x*C);const R=[C,C,C,C,C,C];T.set(R,v*x*C)}const E=new ec;E.setAttribute("position",new Ao(N,y)),E.setAttribute("uv",new Ao(S,b)),E.setAttribute("faceIndex",new Ao(T,v)),r.push(new Wl(E,null)),i>wd&&i--}return{lodMeshes:r,sizeLods:e,sigmas:n}}function KH(t,e,n){const r=new $f(t,e,n);return r.texture.mapping=zN,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function np(t,e,n,r,i){t.viewport.set(e,n,r,i),t.scissor.set(e,n,r,i)}function LDe(t,e,n){return new mu({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:RDe,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:$N(),fragmentShader:`
  3658. precision highp float;
  3659. precision highp int;
  3660. varying vec3 vOutputDirection;
  3661. uniform sampler2D envMap;
  3662. uniform float roughness;
  3663. uniform float mipInt;
  3664. #define ENVMAP_TYPE_CUBE_UV
  3665. #include <cube_uv_reflection_fragment>
  3666. #define PI 3.14159265359
  3667. // Van der Corput radical inverse
  3668. float radicalInverse_VdC(uint bits) {
  3669. bits = (bits << 16u) | (bits >> 16u);
  3670. bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);
  3671. bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);
  3672. bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);
  3673. bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);
  3674. return float(bits) * 2.3283064365386963e-10; // / 0x100000000
  3675. }
  3676. // Hammersley sequence
  3677. vec2 hammersley(uint i, uint N) {
  3678. return vec2(float(i) / float(N), radicalInverse_VdC(i));
  3679. }
  3680. // GGX VNDF importance sampling (Eric Heitz 2018)
  3681. // "Sampling the GGX Distribution of Visible Normals"
  3682. // https://jcgt.org/published/0007/04/01/
  3683. vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) {
  3684. float alpha = roughness * roughness;
  3685. // Section 3.2: Transform view direction to hemisphere configuration
  3686. vec3 Vh = normalize(vec3(alpha * V.x, alpha * V.y, V.z));
  3687. // Section 4.1: Orthonormal basis
  3688. float lensq = Vh.x * Vh.x + Vh.y * Vh.y;
  3689. vec3 T1 = lensq > 0.0 ? vec3(-Vh.y, Vh.x, 0.0) / sqrt(lensq) : vec3(1.0, 0.0, 0.0);
  3690. vec3 T2 = cross(Vh, T1);
  3691. // Section 4.2: Parameterization of projected area
  3692. float r = sqrt(Xi.x);
  3693. float phi = 2.0 * PI * Xi.y;
  3694. float t1 = r * cos(phi);
  3695. float t2 = r * sin(phi);
  3696. float s = 0.5 * (1.0 + Vh.z);
  3697. t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2;
  3698. // Section 4.3: Reprojection onto hemisphere
  3699. vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * Vh;
  3700. // Section 3.4: Transform back to ellipsoid configuration
  3701. return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z)));
  3702. }
  3703. void main() {
  3704. vec3 N = normalize(vOutputDirection);
  3705. vec3 V = N; // Assume view direction equals normal for pre-filtering
  3706. vec3 prefilteredColor = vec3(0.0);
  3707. float totalWeight = 0.0;
  3708. // For very low roughness, just sample the environment directly
  3709. if (roughness < 0.001) {
  3710. gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0);
  3711. return;
  3712. }
  3713. // Tangent space basis for VNDF sampling
  3714. vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);
  3715. vec3 tangent = normalize(cross(up, N));
  3716. vec3 bitangent = cross(N, tangent);
  3717. for(uint i = 0u; i < uint(GGX_SAMPLES); i++) {
  3718. vec2 Xi = hammersley(i, uint(GGX_SAMPLES));
  3719. // For PMREM, V = N, so in tangent space V is always (0, 0, 1)
  3720. vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness);
  3721. // Transform H back to world space
  3722. vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z);
  3723. vec3 L = normalize(2.0 * dot(V, H) * H - V);
  3724. float NdotL = max(dot(N, L), 0.0);
  3725. if(NdotL > 0.0) {
  3726. // Sample environment at fixed mip level
  3727. // VNDF importance sampling handles the distribution filtering
  3728. vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt);
  3729. // Weight by NdotL for the split-sum approximation
  3730. // VNDF PDF naturally accounts for the visible microfacet distribution
  3731. prefilteredColor += sampleColor * NdotL;
  3732. totalWeight += NdotL;
  3733. }
  3734. }
  3735. if (totalWeight > 0.0) {
  3736. prefilteredColor = prefilteredColor / totalWeight;
  3737. }
  3738. gl_FragColor = vec4(prefilteredColor, 1.0);
  3739. }
  3740. `,blending:eu,depthTest:!1,depthWrite:!1})}function IDe(t,e,n){const r=new Float32Array(Wh),i=new lt(0,1,0);return new mu({name:"SphericalGaussianBlur",defines:{n:Wh,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:$N(),fragmentShader:`
  3741. precision mediump float;
  3742. precision mediump int;
  3743. varying vec3 vOutputDirection;
  3744. uniform sampler2D envMap;
  3745. uniform int samples;
  3746. uniform float weights[ n ];
  3747. uniform bool latitudinal;
  3748. uniform float dTheta;
  3749. uniform float mipInt;
  3750. uniform vec3 poleAxis;
  3751. #define ENVMAP_TYPE_CUBE_UV
  3752. #include <cube_uv_reflection_fragment>
  3753. vec3 getSample( float theta, vec3 axis ) {
  3754. float cosTheta = cos( theta );
  3755. // Rodrigues' axis-angle rotation
  3756. vec3 sampleDirection = vOutputDirection * cosTheta
  3757. + cross( axis, vOutputDirection ) * sin( theta )
  3758. + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
  3759. return bilinearCubeUV( envMap, sampleDirection, mipInt );
  3760. }
  3761. void main() {
  3762. vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
  3763. if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
  3764. axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
  3765. }
  3766. axis = normalize( axis );
  3767. gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
  3768. gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
  3769. for ( int i = 1; i < n; i++ ) {
  3770. if ( i >= samples ) {
  3771. break;
  3772. }
  3773. float theta = dTheta * float( i );
  3774. gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
  3775. gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
  3776. }
  3777. }
  3778. `,blending:eu,depthTest:!1,depthWrite:!1})}function XH(){return new mu({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:$N(),fragmentShader:`
  3779. precision mediump float;
  3780. precision mediump int;
  3781. varying vec3 vOutputDirection;
  3782. uniform sampler2D envMap;
  3783. #include <common>
  3784. void main() {
  3785. vec3 outputDirection = normalize( vOutputDirection );
  3786. vec2 uv = equirectUv( outputDirection );
  3787. gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
  3788. }
  3789. `,blending:eu,depthTest:!1,depthWrite:!1})}function YH(){return new mu({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:$N(),fragmentShader:`
  3790. precision mediump float;
  3791. precision mediump int;
  3792. uniform float flipEnvMap;
  3793. varying vec3 vOutputDirection;
  3794. uniform samplerCube envMap;
  3795. void main() {
  3796. gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
  3797. }
  3798. `,blending:eu,depthTest:!1,depthWrite:!1})}function $N(){return`
  3799. precision mediump float;
  3800. precision mediump int;
  3801. attribute float faceIndex;
  3802. varying vec3 vOutputDirection;
  3803. // RH coordinate system; PMREM face-indexing convention
  3804. vec3 getDirection( vec2 uv, float face ) {
  3805. uv = 2.0 * uv - 1.0;
  3806. vec3 direction = vec3( uv, 1.0 );
  3807. if ( face == 0.0 ) {
  3808. direction = direction.zyx; // ( 1, v, u ) pos x
  3809. } else if ( face == 1.0 ) {
  3810. direction = direction.xzy;
  3811. direction.xz *= -1.0; // ( -u, 1, -v ) pos y
  3812. } else if ( face == 2.0 ) {
  3813. direction.x *= -1.0; // ( -u, v, 1 ) pos z
  3814. } else if ( face == 3.0 ) {
  3815. direction = direction.zyx;
  3816. direction.xz *= -1.0; // ( -1, v, -u ) neg x
  3817. } else if ( face == 4.0 ) {
  3818. direction = direction.xzy;
  3819. direction.xy *= -1.0; // ( -u, -1, v ) neg y
  3820. } else if ( face == 5.0 ) {
  3821. direction.z *= -1.0; // ( u, v, -1 ) neg z
  3822. }
  3823. return direction;
  3824. }
  3825. void main() {
  3826. vOutputDirection = getDirection( uv, faceIndex );
  3827. gl_Position = vec4( position, 1.0 );
  3828. }
  3829. `}function FDe(t){let e=new WeakMap,n=null;function r(l){if(l&&l.isTexture){const c=l.mapping,u=c===fP||c===mP,d=c===xg||c===bg;if(u||d){let f=e.get(l);const m=f!==void 0?f.texture.pmremVersion:0;if(l.isRenderTargetTexture&&l.pmremVersion!==m)return n===null&&(n=new qH(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 p=l.image;return u&&p&&p.height>0||d&&p&&i(p)?(n===null&&(n=new qH(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 UDe(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&&I0("WebGLRenderer: "+r+" extension not supported."),i}}}function zDe(t,e,n,r){const i={},a=new WeakMap;function o(f){const m=f.target;m.index!==null&&e.remove(m.index);for(const x in m.attributes)e.remove(m.attributes[x]);m.removeEventListener("dispose",o),delete i[m.id];const p=a.get(m);p&&(e.remove(p),a.delete(m)),r.releaseStatesOfGeometry(m),m.isInstancedBufferGeometry===!0&&delete m._maxInstanceCount,n.memory.geometries--}function l(f,m){return i[m.id]===!0||(m.addEventListener("dispose",o),i[m.id]=!0,n.memory.geometries++),m}function c(f){const m=f.attributes;for(const p in m)e.update(m[p],t.ARRAY_BUFFER)}function u(f){const m=[],p=f.index,x=f.attributes.position;let y=0;if(p!==null){const N=p.array;y=p.version;for(let S=0,T=N.length;S<T;S+=3){const E=N[S+0],C=N[S+1],A=N[S+2];m.push(E,C,C,A,A,E)}}else if(x!==void 0){const N=x.array;y=x.version;for(let S=0,T=N.length/3-1;S<T;S+=3){const E=S+0,C=S+1,A=S+2;m.push(E,C,C,A,A,E)}}else return;const b=new(qZ(m)?rJ:nJ)(m,1);b.version=y;const v=a.get(f);v&&e.remove(v),a.set(f,b)}function d(f){const m=a.get(f);if(m){const p=f.index;p!==null&&m.version<p.version&&u(f)}else u(f);return a.get(f)}return{get:l,update:c,getWireframeAttribute:d}}function BDe(t,e,n){let r;function i(m){r=m}let a,o;function l(m){a=m.type,o=m.bytesPerElement}function c(m,p){t.drawElements(r,p,a,m*o),n.update(p,r,1)}function u(m,p,x){x!==0&&(t.drawElementsInstanced(r,p,a,m*o,x),n.update(p,r,x))}function d(m,p,x){if(x===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(r,p,0,a,m,0,x);let b=0;for(let v=0;v<x;v++)b+=p[v];n.update(b,r,1)}function f(m,p,x,y){if(x===0)return;const b=e.get("WEBGL_multi_draw");if(b===null)for(let v=0;v<m.length;v++)u(m[v]/o,p[v],y[v]);else{b.multiDrawElementsInstancedWEBGL(r,p,0,a,m,0,y,0,x);let v=0;for(let N=0;N<x;N++)v+=p[N]*y[N];n.update(v,r,1)}}this.setMode=i,this.setIndex=l,this.render=c,this.renderInstances=u,this.renderMultiDraw=d,this.renderMultiDrawInstances=f}function $De(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:ui("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 HDe(t,e,n){const r=new WeakMap,i=new _i;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 m=r.get(l);if(m===void 0||m.count!==f){let R=function(){O.dispose(),r.delete(l),l.removeEventListener("dispose",R)};var p=R;m!==void 0&&m.texture.dispose();const x=l.morphAttributes.position!==void 0,y=l.morphAttributes.normal!==void 0,b=l.morphAttributes.color!==void 0,v=l.morphAttributes.position||[],N=l.morphAttributes.normal||[],S=l.morphAttributes.color||[];let T=0;x===!0&&(T=1),y===!0&&(T=2),b===!0&&(T=3);let E=l.attributes.position.count*T,C=1;E>e.maxTextureSize&&(C=Math.ceil(E/e.maxTextureSize),E=e.maxTextureSize);const A=new Float32Array(E*C*4*f),O=new ZZ(A,E,C,f);O.type=qc,O.needsUpdate=!0;const k=T*4;for(let F=0;F<f;F++){const L=v[F],K=N[F],j=S[F],W=E*C*4*F;for(let Y=0;Y<L.count;Y++){const q=Y*k;x===!0&&(i.fromBufferAttribute(L,Y),A[W+q+0]=i.x,A[W+q+1]=i.y,A[W+q+2]=i.z,A[W+q+3]=0),y===!0&&(i.fromBufferAttribute(K,Y),A[W+q+4]=i.x,A[W+q+5]=i.y,A[W+q+6]=i.z,A[W+q+7]=0),b===!0&&(i.fromBufferAttribute(j,Y),A[W+q+8]=i.x,A[W+q+9]=i.y,A[W+q+10]=i.z,A[W+q+11]=j.itemSize===4?i.w:1)}}m={count:f,texture:O,size:new Mn(E,C)},r.set(l,m),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 b=0;b<u.length;b++)x+=u[b];const y=l.morphTargetsRelative?1:1-x;c.getUniforms().setValue(t,"morphTargetBaseInfluence",y),c.getUniforms().setValue(t,"morphTargetInfluences",u)}c.getUniforms().setValue(t,"morphTargetsTexture",m.texture,n),c.getUniforms().setValue(t,"morphTargetsTextureSize",m.size)}return{update:a}}function VDe(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 m=c.skeleton;i.get(m)!==u&&(m.update(),i.set(m,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 gJ=new ml,QH=new uJ(1,1),xJ=new ZZ,bJ=new u3e,yJ=new lJ,ZH=[],JH=[],eV=new Float32Array(16),tV=new Float32Array(9),nV=new Float32Array(4);function ex(t,e,n){const r=t[0];if(r<=0||r>0)return t;const i=e*n;let a=ZH[i];if(a===void 0&&(a=new Float32Array(i),ZH[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 Ri(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 Di(t,e){for(let n=0,r=e.length;n<r;n++)t[n]=e[n]}function HN(t,e){let n=JH[e];n===void 0&&(n=new Int32Array(e),JH[e]=n);for(let r=0;r!==e;++r)n[r]=t.allocateTextureUnit();return n}function GDe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function WDe(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(Ri(n,e))return;t.uniform2fv(this.addr,e),Di(n,e)}}function qDe(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(Ri(n,e))return;t.uniform3fv(this.addr,e),Di(n,e)}}function KDe(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(Ri(n,e))return;t.uniform4fv(this.addr,e),Di(n,e)}}function XDe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Ri(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),Di(n,e)}else{if(Ri(n,r))return;nV.set(r),t.uniformMatrix2fv(this.addr,!1,nV),Di(n,r)}}function YDe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Ri(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),Di(n,e)}else{if(Ri(n,r))return;tV.set(r),t.uniformMatrix3fv(this.addr,!1,tV),Di(n,r)}}function QDe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Ri(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),Di(n,e)}else{if(Ri(n,r))return;eV.set(r),t.uniformMatrix4fv(this.addr,!1,eV),Di(n,r)}}function ZDe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function JDe(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(Ri(n,e))return;t.uniform2iv(this.addr,e),Di(n,e)}}function e4e(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(Ri(n,e))return;t.uniform3iv(this.addr,e),Di(n,e)}}function t4e(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(Ri(n,e))return;t.uniform4iv(this.addr,e),Di(n,e)}}function n4e(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function r4e(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(Ri(n,e))return;t.uniform2uiv(this.addr,e),Di(n,e)}}function i4e(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(Ri(n,e))return;t.uniform3uiv(this.addr,e),Di(n,e)}}function a4e(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(Ri(n,e))return;t.uniform4uiv(this.addr,e),Di(n,e)}}function s4e(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?(QH.compareFunction=WZ,a=QH):a=gJ,n.setTexture2D(e||a,i)}function o4e(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(e||bJ,i)}function l4e(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTextureCube(e||yJ,i)}function c4e(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(e||xJ,i)}function u4e(t){switch(t){case 5126:return GDe;case 35664:return WDe;case 35665:return qDe;case 35666:return KDe;case 35674:return XDe;case 35675:return YDe;case 35676:return QDe;case 5124:case 35670:return ZDe;case 35667:case 35671:return JDe;case 35668:case 35672:return e4e;case 35669:case 35673:return t4e;case 5125:return n4e;case 36294:return r4e;case 36295:return i4e;case 36296:return a4e;case 35678:case 36198:case 36298:case 36306:case 35682:return s4e;case 35679:case 36299:case 36307:return o4e;case 35680:case 36300:case 36308:case 36293:return l4e;case 36289:case 36303:case 36311:case 36292:return c4e}}function d4e(t,e){t.uniform1fv(this.addr,e)}function h4e(t,e){const n=ex(e,this.size,2);t.uniform2fv(this.addr,n)}function f4e(t,e){const n=ex(e,this.size,3);t.uniform3fv(this.addr,n)}function m4e(t,e){const n=ex(e,this.size,4);t.uniform4fv(this.addr,n)}function p4e(t,e){const n=ex(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function g4e(t,e){const n=ex(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function x4e(t,e){const n=ex(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function b4e(t,e){t.uniform1iv(this.addr,e)}function y4e(t,e){t.uniform2iv(this.addr,e)}function v4e(t,e){t.uniform3iv(this.addr,e)}function _4e(t,e){t.uniform4iv(this.addr,e)}function w4e(t,e){t.uniform1uiv(this.addr,e)}function S4e(t,e){t.uniform2uiv(this.addr,e)}function N4e(t,e){t.uniform3uiv(this.addr,e)}function M4e(t,e){t.uniform4uiv(this.addr,e)}function E4e(t,e,n){const r=this.cache,i=e.length,a=HN(n,i);Ri(r,a)||(t.uniform1iv(this.addr,a),Di(r,a));for(let o=0;o!==i;++o)n.setTexture2D(e[o]||gJ,a[o])}function T4e(t,e,n){const r=this.cache,i=e.length,a=HN(n,i);Ri(r,a)||(t.uniform1iv(this.addr,a),Di(r,a));for(let o=0;o!==i;++o)n.setTexture3D(e[o]||bJ,a[o])}function A4e(t,e,n){const r=this.cache,i=e.length,a=HN(n,i);Ri(r,a)||(t.uniform1iv(this.addr,a),Di(r,a));for(let o=0;o!==i;++o)n.setTextureCube(e[o]||yJ,a[o])}function C4e(t,e,n){const r=this.cache,i=e.length,a=HN(n,i);Ri(r,a)||(t.uniform1iv(this.addr,a),Di(r,a));for(let o=0;o!==i;++o)n.setTexture2DArray(e[o]||xJ,a[o])}function k4e(t){switch(t){case 5126:return d4e;case 35664:return h4e;case 35665:return f4e;case 35666:return m4e;case 35674:return p4e;case 35675:return g4e;case 35676:return x4e;case 5124:case 35670:return b4e;case 35667:case 35671:return y4e;case 35668:case 35672:return v4e;case 35669:case 35673:return _4e;case 5125:return w4e;case 36294:return S4e;case 36295:return N4e;case 36296:return M4e;case 35678:case 36198:case 36298:case 36306:case 35682:return E4e;case 35679:case 36299:case 36307:return T4e;case 35680:case 36300:case 36308:case 36293:return A4e;case 36289:case 36303:case 36311:case 36292:return C4e}}let j4e=class{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.setValue=u4e(n.type)}},P4e=class{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.size=n.size,this.setValue=k4e(n.type)}},R4e=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 ek=/(\w+)(\])?(\[|\.)?/g;function rV(t,e){t.seq.push(e),t.map[e.id]=e}function D4e(t,e,n){const r=t.name,i=r.length;for(ek.lastIndex=0;;){const a=ek.exec(r),o=ek.lastIndex;let l=a[1];const c=a[2]==="]",u=a[3];if(c&&(l=l|0),u===void 0||u==="["&&o+2===i){rV(n,u===void 0?new j4e(l,t,e):new P4e(l,t,e));break}else{let f=n.map[l];f===void 0&&(f=new R4e(l),rV(n,f)),n=f}}}let nw=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);D4e(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 iV(t,e,n){const r=t.createShader(e);return t.shaderSource(r,n),t.compileShader(r),r}const O4e=37297;let L4e=0;function I4e(t,e){const n=t.split(`
  3830. `),r=[],i=Math.max(e-6,0),a=Math.min(e+6,n.length);for(let o=i;o<a;o++){const l=o+1;r.push(`${l===e?">":" "} ${l}: ${n[o]}`)}return r.join(`
  3831. `)}const aV=new Tn;function F4e(t){qn._getMatrix(aV,qn.workingColorSpace,t);const e=`mat3( ${aV.elements.map(n=>n.toFixed(4))} )`;switch(qn.getTransfer(t)){case vS:return[e,"LinearTransferOETF"];case hr:return[e,"sRGBTransferOETF"];default:return mn("WebGLProgram: Unsupported color space: ",t),[e,"LinearTransferOETF"]}}function sV(t,e,n){const r=t.getShaderParameter(e,t.COMPILE_STATUS),a=(t.getShaderInfoLog(e)||"").trim();if(r&&a==="")return"";const o=/ERROR: 0:(\d+)/.exec(a);if(o){const l=parseInt(o[1]);return n.toUpperCase()+`
  3832. `+a+`
  3833. `+I4e(t.getShaderSource(e),l)}else return a}function U4e(t,e){const n=F4e(e);return[`vec4 ${t}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join(`
  3834. `)}function z4e(t,e){let n;switch(e){case Ije:n="Linear";break;case Fje:n="Reinhard";break;case Uje:n="Cineon";break;case zje:n="ACESFilmic";break;case $je:n="AgX";break;case Hje:n="Neutral";break;case Bje:n="Custom";break;default:mn("WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}const H_=new lt;function B4e(){qn.getLuminanceCoefficients(H_);const t=H_.x.toFixed(4),e=H_.y.toFixed(4),n=H_.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${t}, ${e}, ${n} );`," return dot( weights, rgb );","}"].join(`
  3835. `)}function $4e(t){return[t.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",t.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Cb).join(`
  3836. `)}function H4e(t){const e=[];for(const n in t){const r=t[n];r!==!1&&e.push("#define "+n+" "+r)}return e.join(`
  3837. `)}function V4e(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 Cb(t){return t!==""}function oV(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 lV(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const G4e=/^[ \t]*#include +<([\w\d./]+)>/gm;function qP(t){return t.replace(G4e,q4e)}const W4e=new Map;function q4e(t,e){let n=Sn[e];if(n===void 0){const r=W4e.get(e);if(r!==void 0)n=Sn[r],mn('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,r);else throw new Error("Can not resolve #include <"+e+">")}return qP(n)}const K4e=/#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 cV(t){return t.replace(K4e,X4e)}function X4e(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 uV(t){let e=`precision ${t.precision} float;
  3838. precision ${t.precision} int;
  3839. precision ${t.precision} sampler2D;
  3840. precision ${t.precision} samplerCube;
  3841. precision ${t.precision} sampler3D;
  3842. precision ${t.precision} sampler2DArray;
  3843. precision ${t.precision} sampler2DShadow;
  3844. precision ${t.precision} samplerCubeShadow;
  3845. precision ${t.precision} sampler2DArrayShadow;
  3846. precision ${t.precision} isampler2D;
  3847. precision ${t.precision} isampler3D;
  3848. precision ${t.precision} isamplerCube;
  3849. precision ${t.precision} isampler2DArray;
  3850. precision ${t.precision} usampler2D;
  3851. precision ${t.precision} usampler3D;
  3852. precision ${t.precision} usamplerCube;
  3853. precision ${t.precision} usampler2DArray;
  3854. `;return t.precision==="highp"?e+=`
  3855. #define HIGH_PRECISION`:t.precision==="mediump"?e+=`
  3856. #define MEDIUM_PRECISION`:t.precision==="lowp"&&(e+=`
  3857. #define LOW_PRECISION`),e}function Y4e(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===LZ?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===gje?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===Dc&&(e="SHADOWMAP_TYPE_VSM"),e}function Q4e(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case xg:case bg:e="ENVMAP_TYPE_CUBE";break;case zN:e="ENVMAP_TYPE_CUBE_UV";break}return e}function Z4e(t){let e="ENVMAP_MODE_REFLECTION";if(t.envMap)switch(t.envMapMode){case bg:e="ENVMAP_MODE_REFRACTION";break}return e}function J4e(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case _O:e="ENVMAP_BLENDING_MULTIPLY";break;case Oje:e="ENVMAP_BLENDING_MIX";break;case Lje:e="ENVMAP_BLENDING_ADD";break}return e}function eOe(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 tOe(t,e,n,r){const i=t.getContext(),a=n.defines;let o=n.vertexShader,l=n.fragmentShader;const c=Y4e(n),u=Q4e(n),d=Z4e(n),f=J4e(n),m=eOe(n),p=$4e(n),x=H4e(a),y=i.createProgram();let b,v,N=n.glslVersion?"#version "+n.glslVersion+`
  3858. `:"";n.isRawShaderMaterial?(b=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(Cb).join(`
  3859. `),b.length>0&&(b+=`
  3860. `),v=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(Cb).join(`
  3861. `),v.length>0&&(v+=`
  3862. `)):(b=[uV(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+d:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&n.flatShading===!1?"#define USE_MORPHNORMALS":"",n.morphColors?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
  3863. `].filter(Cb).join(`
  3864. `),v=[uV(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:"",m?"#define CUBEUV_TEXEL_WIDTH "+m.texelWidth:"",m?"#define CUBEUV_TEXEL_HEIGHT "+m.texelHeight:"",m?"#define CUBEUV_MAX_MIP "+m.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!==Rd?"#define TONE_MAPPING":"",n.toneMapping!==Rd?Sn.tonemapping_pars_fragment:"",n.toneMapping!==Rd?z4e("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",Sn.colorspace_pars_fragment,U4e("linearToOutputTexel",n.outputColorSpace),B4e(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
  3865. `].filter(Cb).join(`
  3866. `)),o=qP(o),o=oV(o,n),o=lV(o,n),l=qP(l),l=oV(l,n),l=lV(l,n),o=cV(o),l=cV(l),n.isRawShaderMaterial!==!0&&(N=`#version 300 es
  3867. `,b=[p,"#define attribute in","#define varying out","#define texture2D texture"].join(`
  3868. `)+`
  3869. `+b,v=["#define varying in",n.glslVersion===xH?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===xH?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`
  3870. `)+`
  3871. `+v);const S=N+b+o,T=N+v+l,E=iV(i,i.VERTEX_SHADER,S),C=iV(i,i.FRAGMENT_SHADER,T);i.attachShader(y,E),i.attachShader(y,C),n.index0AttributeName!==void 0?i.bindAttribLocation(y,0,n.index0AttributeName):n.morphTargets===!0&&i.bindAttribLocation(y,0,"position"),i.linkProgram(y);function A(F){if(t.debug.checkShaderErrors){const L=i.getProgramInfoLog(y)||"",K=i.getShaderInfoLog(E)||"",j=i.getShaderInfoLog(C)||"",W=L.trim(),Y=K.trim(),q=j.trim();let Q=!0,ee=!0;if(i.getProgramParameter(y,i.LINK_STATUS)===!1)if(Q=!1,typeof t.debug.onShaderError=="function")t.debug.onShaderError(i,y,E,C);else{const re=sV(i,E,"vertex"),z=sV(i,C,"fragment");ui("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(y,i.VALIDATE_STATUS)+`
  3872. Material Name: `+F.name+`
  3873. Material Type: `+F.type+`
  3874. Program Info Log: `+W+`
  3875. `+re+`
  3876. `+z)}else W!==""?mn("WebGLProgram: Program Info Log:",W):(Y===""||q==="")&&(ee=!1);ee&&(F.diagnostics={runnable:Q,programLog:W,vertexShader:{log:Y,prefix:b},fragmentShader:{log:q,prefix:v}})}i.deleteShader(E),i.deleteShader(C),O=new nw(i,y),k=V4e(i,y)}let O;this.getUniforms=function(){return O===void 0&&A(this),O};let k;this.getAttributes=function(){return k===void 0&&A(this),k};let R=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return R===!1&&(R=i.getProgramParameter(y,O4e)),R},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(y),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=L4e++,this.cacheKey=e,this.usedTimes=1,this.program=y,this.vertexShader=E,this.fragmentShader=C,this}let nOe=0,rOe=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 iOe(e),n.set(e,r)),r}},iOe=class{constructor(e){this.id=nOe++,this.code=e,this.usedTimes=0}};function aOe(t,e,n,r,i,a,o){const l=new eJ,c=new rOe,u=new Set,d=[],f=i.logarithmicDepthBuffer,m=i.vertexTextures;let p=i.precision;const x={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function y(k){return u.add(k),k===0?"uv":`uv${k}`}function b(k,R,F,L,K){const j=L.fog,W=K.geometry,Y=k.isMeshStandardMaterial?L.environment:null,q=(k.isMeshStandardMaterial?n:e).get(k.envMap||Y),Q=q&&q.mapping===zN?q.image.height:null,ee=x[k.type];k.precision!==null&&(p=i.getMaxPrecision(k.precision),p!==k.precision&&mn("WebGLProgram.getParameters:",k.precision,"not supported, using",p,"instead."));const re=W.morphAttributes.position||W.morphAttributes.normal||W.morphAttributes.color,z=re!==void 0?re.length:0;let G=0;W.morphAttributes.position!==void 0&&(G=1),W.morphAttributes.normal!==void 0&&(G=2),W.morphAttributes.color!==void 0&&(G=3);let ae,se,ue,pe;if(ee){const Ot=Al[ee];ae=Ot.vertexShader,se=Ot.fragmentShader}else ae=k.vertexShader,se=k.fragmentShader,c.update(k),ue=c.getVertexShaderID(k),pe=c.getFragmentShaderID(k);const ce=t.getRenderTarget(),Me=t.state.buffers.depth.getReversed(),me=K.isInstancedMesh===!0,Ee=K.isBatchedMesh===!0,fe=!!k.map,le=!!k.matcap,Be=!!q,V=!!k.aoMap,$=!!k.lightMap,X=!!k.bumpMap,U=!!k.normalMap,B=!!k.displacementMap,oe=!!k.emissiveMap,Te=!!k.metalnessMap,je=!!k.roughnessMap,Ce=k.anisotropy>0,H=k.clearcoat>0,D=k.dispersion>0,Z=k.iridescence>0,xe=k.sheen>0,Ne=k.transmission>0,ve=Ce&&!!k.anisotropyMap,$e=H&&!!k.clearcoatMap,Le=H&&!!k.clearcoatNormalMap,qe=H&&!!k.clearcoatRoughnessMap,Ke=Z&&!!k.iridescenceMap,Ye=Z&&!!k.iridescenceThicknessMap,ie=xe&&!!k.sheenColorMap,te=xe&&!!k.sheenRoughnessMap,Se=!!k.specularMap,ze=!!k.specularColorMap,nt=!!k.specularIntensityMap,ne=Ne&&!!k.transmissionMap,Pe=Ne&&!!k.thicknessMap,be=!!k.gradientMap,Oe=!!k.alphaMap,Ue=k.alphaTest>0,Ae=!!k.alphaHash,Je=!!k.extensions;let gt=Rd;k.toneMapped&&(ce===null||ce.isXRRenderTarget===!0)&&(gt=t.toneMapping);const Pt={shaderID:ee,shaderType:k.type,shaderName:k.name,vertexShader:ae,fragmentShader:se,defines:k.defines,customVertexShaderID:ue,customFragmentShaderID:pe,isRawShaderMaterial:k.isRawShaderMaterial===!0,glslVersion:k.glslVersion,precision:p,batching:Ee,batchingColor:Ee&&K._colorsTexture!==null,instancing:me,instancingColor:me&&K.instanceColor!==null,instancingMorph:me&&K.morphTexture!==null,supportsVertexTextures:m,outputColorSpace:ce===null?t.outputColorSpace:ce.isXRRenderTarget===!0?ce.texture.colorSpace:yg,alphaToCoverage:!!k.alphaToCoverage,map:fe,matcap:le,envMap:Be,envMapMode:Be&&q.mapping,envMapCubeUVHeight:Q,aoMap:V,lightMap:$,bumpMap:X,normalMap:U,displacementMap:m&&B,emissiveMap:oe,normalMapObjectSpace:U&&k.normalMapType===qje,normalMapTangentSpace:U&&k.normalMapType===GZ,metalnessMap:Te,roughnessMap:je,anisotropy:Ce,anisotropyMap:ve,clearcoat:H,clearcoatMap:$e,clearcoatNormalMap:Le,clearcoatRoughnessMap:qe,dispersion:D,iridescence:Z,iridescenceMap:Ke,iridescenceThicknessMap:Ye,sheen:xe,sheenColorMap:ie,sheenRoughnessMap:te,specularMap:Se,specularColorMap:ze,specularIntensityMap:nt,transmission:Ne,transmissionMap:ne,thicknessMap:Pe,gradientMap:be,opaque:k.transparent===!1&&k.blending===Xp&&k.alphaToCoverage===!1,alphaMap:Oe,alphaTest:Ue,alphaHash:Ae,combine:k.combine,mapUv:fe&&y(k.map.channel),aoMapUv:V&&y(k.aoMap.channel),lightMapUv:$&&y(k.lightMap.channel),bumpMapUv:X&&y(k.bumpMap.channel),normalMapUv:U&&y(k.normalMap.channel),displacementMapUv:B&&y(k.displacementMap.channel),emissiveMapUv:oe&&y(k.emissiveMap.channel),metalnessMapUv:Te&&y(k.metalnessMap.channel),roughnessMapUv:je&&y(k.roughnessMap.channel),anisotropyMapUv:ve&&y(k.anisotropyMap.channel),clearcoatMapUv:$e&&y(k.clearcoatMap.channel),clearcoatNormalMapUv:Le&&y(k.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:qe&&y(k.clearcoatRoughnessMap.channel),iridescenceMapUv:Ke&&y(k.iridescenceMap.channel),iridescenceThicknessMapUv:Ye&&y(k.iridescenceThicknessMap.channel),sheenColorMapUv:ie&&y(k.sheenColorMap.channel),sheenRoughnessMapUv:te&&y(k.sheenRoughnessMap.channel),specularMapUv:Se&&y(k.specularMap.channel),specularColorMapUv:ze&&y(k.specularColorMap.channel),specularIntensityMapUv:nt&&y(k.specularIntensityMap.channel),transmissionMapUv:ne&&y(k.transmissionMap.channel),thicknessMapUv:Pe&&y(k.thicknessMap.channel),alphaMapUv:Oe&&y(k.alphaMap.channel),vertexTangents:!!W.attributes.tangent&&(U||Ce),vertexColors:k.vertexColors,vertexAlphas:k.vertexColors===!0&&!!W.attributes.color&&W.attributes.color.itemSize===4,pointsUvs:K.isPoints===!0&&!!W.attributes.uv&&(fe||Oe),fog:!!j,useFog:k.fog===!0,fogExp2:!!j&&j.isFogExp2,flatShading:k.flatShading===!0&&k.wireframe===!1,sizeAttenuation:k.sizeAttenuation===!0,logarithmicDepthBuffer:f,reversedDepthBuffer:Me,skinning:K.isSkinnedMesh===!0,morphTargets:W.morphAttributes.position!==void 0,morphNormals:W.morphAttributes.normal!==void 0,morphColors:W.morphAttributes.color!==void 0,morphTargetsCount:z,morphTextureStride:G,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:k.dithering,shadowMapEnabled:t.shadowMap.enabled&&F.length>0,shadowMapType:t.shadowMap.type,toneMapping:gt,decodeVideoTexture:fe&&k.map.isVideoTexture===!0&&qn.getTransfer(k.map.colorSpace)===hr,decodeVideoTextureEmissive:oe&&k.emissiveMap.isVideoTexture===!0&&qn.getTransfer(k.emissiveMap.colorSpace)===hr,premultipliedAlpha:k.premultipliedAlpha,doubleSided:k.side===Cl,flipSided:k.side===bs,useDepthPacking:k.depthPacking>=0,depthPacking:k.depthPacking||0,index0AttributeName:k.index0AttributeName,extensionClipCullDistance:Je&&k.extensions.clipCullDistance===!0&&r.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(Je&&k.extensions.multiDraw===!0||Ee)&&r.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:r.has("KHR_parallel_shader_compile"),customProgramCacheKey:k.customProgramCacheKey()};return Pt.vertexUv1s=u.has(1),Pt.vertexUv2s=u.has(2),Pt.vertexUv3s=u.has(3),u.clear(),Pt}function v(k){const R=[];if(k.shaderID?R.push(k.shaderID):(R.push(k.customVertexShaderID),R.push(k.customFragmentShaderID)),k.defines!==void 0)for(const F in k.defines)R.push(F),R.push(k.defines[F]);return k.isRawShaderMaterial===!1&&(N(R,k),S(R,k),R.push(t.outputColorSpace)),R.push(k.customProgramCacheKey),R.join()}function N(k,R){k.push(R.precision),k.push(R.outputColorSpace),k.push(R.envMapMode),k.push(R.envMapCubeUVHeight),k.push(R.mapUv),k.push(R.alphaMapUv),k.push(R.lightMapUv),k.push(R.aoMapUv),k.push(R.bumpMapUv),k.push(R.normalMapUv),k.push(R.displacementMapUv),k.push(R.emissiveMapUv),k.push(R.metalnessMapUv),k.push(R.roughnessMapUv),k.push(R.anisotropyMapUv),k.push(R.clearcoatMapUv),k.push(R.clearcoatNormalMapUv),k.push(R.clearcoatRoughnessMapUv),k.push(R.iridescenceMapUv),k.push(R.iridescenceThicknessMapUv),k.push(R.sheenColorMapUv),k.push(R.sheenRoughnessMapUv),k.push(R.specularMapUv),k.push(R.specularColorMapUv),k.push(R.specularIntensityMapUv),k.push(R.transmissionMapUv),k.push(R.thicknessMapUv),k.push(R.combine),k.push(R.fogExp2),k.push(R.sizeAttenuation),k.push(R.morphTargetsCount),k.push(R.morphAttributeCount),k.push(R.numDirLights),k.push(R.numPointLights),k.push(R.numSpotLights),k.push(R.numSpotLightMaps),k.push(R.numHemiLights),k.push(R.numRectAreaLights),k.push(R.numDirLightShadows),k.push(R.numPointLightShadows),k.push(R.numSpotLightShadows),k.push(R.numSpotLightShadowsWithMaps),k.push(R.numLightProbes),k.push(R.shadowMapType),k.push(R.toneMapping),k.push(R.numClippingPlanes),k.push(R.numClipIntersection),k.push(R.depthPacking)}function S(k,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),k.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),k.push(l.mask)}function T(k){const R=x[k.type];let F;if(R){const L=Al[R];F=S3e.clone(L.uniforms)}else F=k.uniforms;return F}function E(k,R){let F;for(let L=0,K=d.length;L<K;L++){const j=d[L];if(j.cacheKey===R){F=j,++F.usedTimes;break}}return F===void 0&&(F=new tOe(t,R,k,a),d.push(F)),F}function C(k){if(--k.usedTimes===0){const R=d.indexOf(k);d[R]=d[d.length-1],d.pop(),k.destroy()}}function A(k){c.remove(k)}function O(){c.dispose()}return{getParameters:b,getProgramCacheKey:v,getUniforms:T,acquireProgram:E,releaseProgram:C,releaseShaderCache:A,programs:d,dispose:O}}function sOe(){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 oOe(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 dV(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 hV(){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,m,p,x,y,b){let v=t[e];return v===void 0?(v={id:f.id,object:f,geometry:m,material:p,groupOrder:x,renderOrder:f.renderOrder,z:y,group:b},t[e]=v):(v.id=f.id,v.object=f,v.geometry=m,v.material=p,v.groupOrder=x,v.renderOrder=f.renderOrder,v.z=y,v.group=b),e++,v}function l(f,m,p,x,y,b){const v=o(f,m,p,x,y,b);p.transmission>0?r.push(v):p.transparent===!0?i.push(v):n.push(v)}function c(f,m,p,x,y,b){const v=o(f,m,p,x,y,b);p.transmission>0?r.unshift(v):p.transparent===!0?i.unshift(v):n.unshift(v)}function u(f,m){n.length>1&&n.sort(f||oOe),r.length>1&&r.sort(m||dV),i.length>1&&i.sort(m||dV)}function d(){for(let f=e,m=t.length;f<m;f++){const p=t[f];if(p.id===null)break;p.id=null,p.object=null,p.geometry=null,p.material=null,p.group=null}}return{opaque:n,transmissive:r,transparent:i,init:a,push:l,unshift:c,finish:d,sort:u}}function lOe(){let t=new WeakMap;function e(r,i){const a=t.get(r);let o;return a===void 0?(o=new hV,t.set(r,[o])):i>=a.length?(o=new hV,a.push(o)):o=a[i],o}function n(){t=new WeakMap}return{get:e,dispose:n}}function cOe(){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 lt,color:new Dn};break;case"SpotLight":n={position:new lt,direction:new lt,color:new Dn,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new lt,color:new Dn,distance:0,decay:0};break;case"HemisphereLight":n={direction:new lt,skyColor:new Dn,groundColor:new Dn};break;case"RectAreaLight":n={color:new Dn,position:new lt,halfWidth:new lt,halfHeight:new lt};break}return t[e.id]=n,n}}}function uOe(){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 Mn};break;case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Mn};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Mn,shadowCameraNear:1,shadowCameraFar:1e3};break}return t[e.id]=n,n}}}let dOe=0;function hOe(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function fOe(t){const e=new cOe,n=uOe(),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 lt);const i=new lt,a=new Mi,o=new Mi;function l(u){let d=0,f=0,m=0;for(let k=0;k<9;k++)r.probe[k].set(0,0,0);let p=0,x=0,y=0,b=0,v=0,N=0,S=0,T=0,E=0,C=0,A=0;u.sort(hOe);for(let k=0,R=u.length;k<R;k++){const F=u[k],L=F.color,K=F.intensity,j=F.distance,W=F.shadow&&F.shadow.map?F.shadow.map.texture:null;if(F.isAmbientLight)d+=L.r*K,f+=L.g*K,m+=L.b*K;else if(F.isLightProbe){for(let Y=0;Y<9;Y++)r.probe[Y].addScaledVector(F.sh.coefficients[Y],K);A++}else if(F.isDirectionalLight){const Y=e.get(F);if(Y.color.copy(F.color).multiplyScalar(F.intensity),F.castShadow){const q=F.shadow,Q=n.get(F);Q.shadowIntensity=q.intensity,Q.shadowBias=q.bias,Q.shadowNormalBias=q.normalBias,Q.shadowRadius=q.radius,Q.shadowMapSize=q.mapSize,r.directionalShadow[p]=Q,r.directionalShadowMap[p]=W,r.directionalShadowMatrix[p]=F.shadow.matrix,N++}r.directional[p]=Y,p++}else if(F.isSpotLight){const Y=e.get(F);Y.position.setFromMatrixPosition(F.matrixWorld),Y.color.copy(L).multiplyScalar(K),Y.distance=j,Y.coneCos=Math.cos(F.angle),Y.penumbraCos=Math.cos(F.angle*(1-F.penumbra)),Y.decay=F.decay,r.spot[y]=Y;const q=F.shadow;if(F.map&&(r.spotLightMap[E]=F.map,E++,q.updateMatrices(F),F.castShadow&&C++),r.spotLightMatrix[y]=q.matrix,F.castShadow){const Q=n.get(F);Q.shadowIntensity=q.intensity,Q.shadowBias=q.bias,Q.shadowNormalBias=q.normalBias,Q.shadowRadius=q.radius,Q.shadowMapSize=q.mapSize,r.spotShadow[y]=Q,r.spotShadowMap[y]=W,T++}y++}else if(F.isRectAreaLight){const Y=e.get(F);Y.color.copy(L).multiplyScalar(K),Y.halfWidth.set(F.width*.5,0,0),Y.halfHeight.set(0,F.height*.5,0),r.rectArea[b]=Y,b++}else if(F.isPointLight){const Y=e.get(F);if(Y.color.copy(F.color).multiplyScalar(F.intensity),Y.distance=F.distance,Y.decay=F.decay,F.castShadow){const q=F.shadow,Q=n.get(F);Q.shadowIntensity=q.intensity,Q.shadowBias=q.bias,Q.shadowNormalBias=q.normalBias,Q.shadowRadius=q.radius,Q.shadowMapSize=q.mapSize,Q.shadowCameraNear=q.camera.near,Q.shadowCameraFar=q.camera.far,r.pointShadow[x]=Q,r.pointShadowMap[x]=W,r.pointShadowMatrix[x]=F.shadow.matrix,S++}r.point[x]=Y,x++}else if(F.isHemisphereLight){const Y=e.get(F);Y.skyColor.copy(F.color).multiplyScalar(K),Y.groundColor.copy(F.groundColor).multiplyScalar(K),r.hemi[v]=Y,v++}}b>0&&(t.has("OES_texture_float_linear")===!0?(r.rectAreaLTC1=Lt.LTC_FLOAT_1,r.rectAreaLTC2=Lt.LTC_FLOAT_2):(r.rectAreaLTC1=Lt.LTC_HALF_1,r.rectAreaLTC2=Lt.LTC_HALF_2)),r.ambient[0]=d,r.ambient[1]=f,r.ambient[2]=m;const O=r.hash;(O.directionalLength!==p||O.pointLength!==x||O.spotLength!==y||O.rectAreaLength!==b||O.hemiLength!==v||O.numDirectionalShadows!==N||O.numPointShadows!==S||O.numSpotShadows!==T||O.numSpotMaps!==E||O.numLightProbes!==A)&&(r.directional.length=p,r.spot.length=y,r.rectArea.length=b,r.point.length=x,r.hemi.length=v,r.directionalShadow.length=N,r.directionalShadowMap.length=N,r.pointShadow.length=S,r.pointShadowMap.length=S,r.spotShadow.length=T,r.spotShadowMap.length=T,r.directionalShadowMatrix.length=N,r.pointShadowMatrix.length=S,r.spotLightMatrix.length=T+E-C,r.spotLightMap.length=E,r.numSpotLightShadowsWithMaps=C,r.numLightProbes=A,O.directionalLength=p,O.pointLength=x,O.spotLength=y,O.rectAreaLength=b,O.hemiLength=v,O.numDirectionalShadows=N,O.numPointShadows=S,O.numSpotShadows=T,O.numSpotMaps=E,O.numLightProbes=A,r.version=dOe++)}function c(u,d){let f=0,m=0,p=0,x=0,y=0;const b=d.matrixWorldInverse;for(let v=0,N=u.length;v<N;v++){const S=u[v];if(S.isDirectionalLight){const T=r.directional[f];T.direction.setFromMatrixPosition(S.matrixWorld),i.setFromMatrixPosition(S.target.matrixWorld),T.direction.sub(i),T.direction.transformDirection(b),f++}else if(S.isSpotLight){const T=r.spot[p];T.position.setFromMatrixPosition(S.matrixWorld),T.position.applyMatrix4(b),T.direction.setFromMatrixPosition(S.matrixWorld),i.setFromMatrixPosition(S.target.matrixWorld),T.direction.sub(i),T.direction.transformDirection(b),p++}else if(S.isRectAreaLight){const T=r.rectArea[x];T.position.setFromMatrixPosition(S.matrixWorld),T.position.applyMatrix4(b),o.identity(),a.copy(S.matrixWorld),a.premultiply(b),o.extractRotation(a),T.halfWidth.set(S.width*.5,0,0),T.halfHeight.set(0,S.height*.5,0),T.halfWidth.applyMatrix4(o),T.halfHeight.applyMatrix4(o),x++}else if(S.isPointLight){const T=r.point[m];T.position.setFromMatrixPosition(S.matrixWorld),T.position.applyMatrix4(b),m++}else if(S.isHemisphereLight){const T=r.hemi[y];T.direction.setFromMatrixPosition(S.matrixWorld),T.direction.transformDirection(b),y++}}}return{setup:l,setupView:c,state:r}}function fV(t){const e=new fOe(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 mOe(t){let e=new WeakMap;function n(i,a=0){const o=e.get(i);let l;return o===void 0?(l=new fV(t),e.set(i,[l])):a>=o.length?(l=new fV(t),o.push(l)):l=o[a],l}function r(){e=new WeakMap}return{get:n,dispose:r}}const pOe=`void main() {
  3877. gl_Position = vec4( position, 1.0 );
  3878. }`,gOe=`uniform sampler2D shadow_pass;
  3879. uniform vec2 resolution;
  3880. uniform float radius;
  3881. #include <packing>
  3882. void main() {
  3883. const float samples = float( VSM_SAMPLES );
  3884. float mean = 0.0;
  3885. float squared_mean = 0.0;
  3886. float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
  3887. float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
  3888. for ( float i = 0.0; i < samples; i ++ ) {
  3889. float uvOffset = uvStart + i * uvStride;
  3890. #ifdef HORIZONTAL_PASS
  3891. vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
  3892. mean += distribution.x;
  3893. squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
  3894. #else
  3895. float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
  3896. mean += depth;
  3897. squared_mean += depth * depth;
  3898. #endif
  3899. }
  3900. mean = mean / samples;
  3901. squared_mean = squared_mean / samples;
  3902. float std_dev = sqrt( squared_mean - mean * mean );
  3903. gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
  3904. }`;function xOe(t,e,n){let r=new RO;const i=new Mn,a=new Mn,o=new _i,l=new I3e({depthPacking:Wje}),c=new F3e,u={},d=n.maxTextureSize,f={[Kd]:bs,[bs]:Kd,[Cl]:Cl},m=new mu({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Mn},radius:{value:4}},vertexShader:pOe,fragmentShader:gOe}),p=m.clone();p.defines.HORIZONTAL_PASS=1;const x=new ec;x.setAttribute("position",new Ao(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const y=new Wl(x,m),b=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=LZ;let v=this.type;this.render=function(C,A,O){if(b.enabled===!1||b.autoUpdate===!1&&b.needsUpdate===!1||C.length===0)return;const k=t.getRenderTarget(),R=t.getActiveCubeFace(),F=t.getActiveMipmapLevel(),L=t.state;L.setBlending(eu),L.buffers.depth.getReversed()===!0?L.buffers.color.setClear(0,0,0,0):L.buffers.color.setClear(1,1,1,1),L.buffers.depth.setTest(!0),L.setScissorTest(!1);const K=v!==Dc&&this.type===Dc,j=v===Dc&&this.type!==Dc;for(let W=0,Y=C.length;W<Y;W++){const q=C[W],Q=q.shadow;if(Q===void 0){mn("WebGLShadowMap:",q,"has no shadow.");continue}if(Q.autoUpdate===!1&&Q.needsUpdate===!1)continue;i.copy(Q.mapSize);const ee=Q.getFrameExtents();if(i.multiply(ee),a.copy(Q.mapSize),(i.x>d||i.y>d)&&(i.x>d&&(a.x=Math.floor(d/ee.x),i.x=a.x*ee.x,Q.mapSize.x=a.x),i.y>d&&(a.y=Math.floor(d/ee.y),i.y=a.y*ee.y,Q.mapSize.y=a.y)),Q.map===null||K===!0||j===!0){const z=this.type!==Dc?{minFilter:Ws,magFilter:Ws}:{};Q.map!==null&&Q.map.dispose(),Q.map=new $f(i.x,i.y,z),Q.map.texture.name=q.name+".shadowMap",Q.camera.updateProjectionMatrix()}t.setRenderTarget(Q.map),t.clear();const re=Q.getViewportCount();for(let z=0;z<re;z++){const G=Q.getViewport(z);o.set(a.x*G.x,a.y*G.y,a.x*G.z,a.y*G.w),L.viewport(o),Q.updateMatrices(q,z),r=Q.getFrustum(),T(A,O,Q.camera,q,this.type)}Q.isPointLightShadow!==!0&&this.type===Dc&&N(Q,O),Q.needsUpdate=!1}v=this.type,b.needsUpdate=!1,t.setRenderTarget(k,R,F)};function N(C,A){const O=e.update(y);m.defines.VSM_SAMPLES!==C.blurSamples&&(m.defines.VSM_SAMPLES=C.blurSamples,p.defines.VSM_SAMPLES=C.blurSamples,m.needsUpdate=!0,p.needsUpdate=!0),C.mapPass===null&&(C.mapPass=new $f(i.x,i.y)),m.uniforms.shadow_pass.value=C.map.texture,m.uniforms.resolution.value=C.mapSize,m.uniforms.radius.value=C.radius,t.setRenderTarget(C.mapPass),t.clear(),t.renderBufferDirect(A,null,O,m,y,null),p.uniforms.shadow_pass.value=C.mapPass.texture,p.uniforms.resolution.value=C.mapSize,p.uniforms.radius.value=C.radius,t.setRenderTarget(C.map),t.clear(),t.renderBufferDirect(A,null,O,p,y,null)}function S(C,A,O,k){let R=null;const F=O.isPointLight===!0?C.customDistanceMaterial:C.customDepthMaterial;if(F!==void 0)R=F;else if(R=O.isPointLight===!0?c:l,t.localClippingEnabled&&A.clipShadows===!0&&Array.isArray(A.clippingPlanes)&&A.clippingPlanes.length!==0||A.displacementMap&&A.displacementScale!==0||A.alphaMap&&A.alphaTest>0||A.map&&A.alphaTest>0||A.alphaToCoverage===!0){const L=R.uuid,K=A.uuid;let j=u[L];j===void 0&&(j={},u[L]=j);let W=j[K];W===void 0&&(W=R.clone(),j[K]=W,A.addEventListener("dispose",E)),R=W}if(R.visible=A.visible,R.wireframe=A.wireframe,k===Dc?R.side=A.shadowSide!==null?A.shadowSide:A.side:R.side=A.shadowSide!==null?A.shadowSide:f[A.side],R.alphaMap=A.alphaMap,R.alphaTest=A.alphaToCoverage===!0?.5:A.alphaTest,R.map=A.map,R.clipShadows=A.clipShadows,R.clippingPlanes=A.clippingPlanes,R.clipIntersection=A.clipIntersection,R.displacementMap=A.displacementMap,R.displacementScale=A.displacementScale,R.displacementBias=A.displacementBias,R.wireframeLinewidth=A.wireframeLinewidth,R.linewidth=A.linewidth,O.isPointLight===!0&&R.isMeshDistanceMaterial===!0){const L=t.properties.get(R);L.light=O}return R}function T(C,A,O,k,R){if(C.visible===!1)return;if(C.layers.test(A.layers)&&(C.isMesh||C.isLine||C.isPoints)&&(C.castShadow||C.receiveShadow&&R===Dc)&&(!C.frustumCulled||r.intersectsObject(C))){C.modelViewMatrix.multiplyMatrices(O.matrixWorldInverse,C.matrixWorld);const K=e.update(C),j=C.material;if(Array.isArray(j)){const W=K.groups;for(let Y=0,q=W.length;Y<q;Y++){const Q=W[Y],ee=j[Q.materialIndex];if(ee&&ee.visible){const re=S(C,ee,k,R);C.onBeforeShadow(t,C,A,O,K,re,Q),t.renderBufferDirect(O,null,K,re,C,Q),C.onAfterShadow(t,C,A,O,K,re,Q)}}}else if(j.visible){const W=S(C,j,k,R);C.onBeforeShadow(t,C,A,O,K,W,null),t.renderBufferDirect(O,null,K,W,C,null),C.onAfterShadow(t,C,A,O,K,W,null)}}const L=C.children;for(let K=0,j=L.length;K<j;K++)T(L[K],A,O,k,R)}function E(C){C.target.removeEventListener("dispose",E);for(const O in u){const k=u[O],R=C.target.uuid;R in k&&(k[R].dispose(),delete k[R])}}}const bOe={[sP]:oP,[lP]:dP,[cP]:hP,[gg]:uP,[oP]:sP,[dP]:lP,[hP]:cP,[uP]:gg};function yOe(t,e){function n(){let ne=!1;const Pe=new _i;let be=null;const Oe=new _i(0,0,0,0);return{setMask:function(Ue){be!==Ue&&!ne&&(t.colorMask(Ue,Ue,Ue,Ue),be=Ue)},setLocked:function(Ue){ne=Ue},setClear:function(Ue,Ae,Je,gt,Pt){Pt===!0&&(Ue*=gt,Ae*=gt,Je*=gt),Pe.set(Ue,Ae,Je,gt),Oe.equals(Pe)===!1&&(t.clearColor(Ue,Ae,Je,gt),Oe.copy(Pe))},reset:function(){ne=!1,be=null,Oe.set(-1,0,0,0)}}}function r(){let ne=!1,Pe=!1,be=null,Oe=null,Ue=null;return{setReversed:function(Ae){if(Pe!==Ae){const Je=e.get("EXT_clip_control");Ae?Je.clipControlEXT(Je.LOWER_LEFT_EXT,Je.ZERO_TO_ONE_EXT):Je.clipControlEXT(Je.LOWER_LEFT_EXT,Je.NEGATIVE_ONE_TO_ONE_EXT),Pe=Ae;const gt=Ue;Ue=null,this.setClear(gt)}},getReversed:function(){return Pe},setTest:function(Ae){Ae?ce(t.DEPTH_TEST):Me(t.DEPTH_TEST)},setMask:function(Ae){be!==Ae&&!ne&&(t.depthMask(Ae),be=Ae)},setFunc:function(Ae){if(Pe&&(Ae=bOe[Ae]),Oe!==Ae){switch(Ae){case sP:t.depthFunc(t.NEVER);break;case oP:t.depthFunc(t.ALWAYS);break;case lP:t.depthFunc(t.LESS);break;case gg:t.depthFunc(t.LEQUAL);break;case cP:t.depthFunc(t.EQUAL);break;case uP:t.depthFunc(t.GEQUAL);break;case dP:t.depthFunc(t.GREATER);break;case hP:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}Oe=Ae}},setLocked:function(Ae){ne=Ae},setClear:function(Ae){Ue!==Ae&&(Pe&&(Ae=1-Ae),t.clearDepth(Ae),Ue=Ae)},reset:function(){ne=!1,be=null,Oe=null,Ue=null,Pe=!1}}}function i(){let ne=!1,Pe=null,be=null,Oe=null,Ue=null,Ae=null,Je=null,gt=null,Pt=null;return{setTest:function(Ot){ne||(Ot?ce(t.STENCIL_TEST):Me(t.STENCIL_TEST))},setMask:function(Ot){Pe!==Ot&&!ne&&(t.stencilMask(Ot),Pe=Ot)},setFunc:function(Ot,cn,It){(be!==Ot||Oe!==cn||Ue!==It)&&(t.stencilFunc(Ot,cn,It),be=Ot,Oe=cn,Ue=It)},setOp:function(Ot,cn,It){(Ae!==Ot||Je!==cn||gt!==It)&&(t.stencilOp(Ot,cn,It),Ae=Ot,Je=cn,gt=It)},setLocked:function(Ot){ne=Ot},setClear:function(Ot){Pt!==Ot&&(t.clearStencil(Ot),Pt=Ot)},reset:function(){ne=!1,Pe=null,be=null,Oe=null,Ue=null,Ae=null,Je=null,gt=null,Pt=null}}}const a=new n,o=new r,l=new i,c=new WeakMap,u=new WeakMap;let d={},f={},m=new WeakMap,p=[],x=null,y=!1,b=null,v=null,N=null,S=null,T=null,E=null,C=null,A=new Dn(0,0,0),O=0,k=!1,R=null,F=null,L=null,K=null,j=null;const W=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let Y=!1,q=0;const Q=t.getParameter(t.VERSION);Q.indexOf("WebGL")!==-1?(q=parseFloat(/^WebGL (\d)/.exec(Q)[1]),Y=q>=1):Q.indexOf("OpenGL ES")!==-1&&(q=parseFloat(/^OpenGL ES (\d)/.exec(Q)[1]),Y=q>=2);let ee=null,re={};const z=t.getParameter(t.SCISSOR_BOX),G=t.getParameter(t.VIEWPORT),ae=new _i().fromArray(z),se=new _i().fromArray(G);function ue(ne,Pe,be,Oe){const Ue=new Uint8Array(4),Ae=t.createTexture();t.bindTexture(ne,Ae),t.texParameteri(ne,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(ne,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let Je=0;Je<be;Je++)ne===t.TEXTURE_3D||ne===t.TEXTURE_2D_ARRAY?t.texImage3D(Pe,0,t.RGBA,1,1,Oe,0,t.RGBA,t.UNSIGNED_BYTE,Ue):t.texImage2D(Pe+Je,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,Ue);return Ae}const pe={};pe[t.TEXTURE_2D]=ue(t.TEXTURE_2D,t.TEXTURE_2D,1),pe[t.TEXTURE_CUBE_MAP]=ue(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),pe[t.TEXTURE_2D_ARRAY]=ue(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),pe[t.TEXTURE_3D]=ue(t.TEXTURE_3D,t.TEXTURE_3D,1,1),a.setClear(0,0,0,1),o.setClear(1),l.setClear(0),ce(t.DEPTH_TEST),o.setFunc(gg),X(!1),U(dH),ce(t.CULL_FACE),V(eu);function ce(ne){d[ne]!==!0&&(t.enable(ne),d[ne]=!0)}function Me(ne){d[ne]!==!1&&(t.disable(ne),d[ne]=!1)}function me(ne,Pe){return f[ne]!==Pe?(t.bindFramebuffer(ne,Pe),f[ne]=Pe,ne===t.DRAW_FRAMEBUFFER&&(f[t.FRAMEBUFFER]=Pe),ne===t.FRAMEBUFFER&&(f[t.DRAW_FRAMEBUFFER]=Pe),!0):!1}function Ee(ne,Pe){let be=p,Oe=!1;if(ne){be=m.get(Pe),be===void 0&&(be=[],m.set(Pe,be));const Ue=ne.textures;if(be.length!==Ue.length||be[0]!==t.COLOR_ATTACHMENT0){for(let Ae=0,Je=Ue.length;Ae<Je;Ae++)be[Ae]=t.COLOR_ATTACHMENT0+Ae;be.length=Ue.length,Oe=!0}}else be[0]!==t.BACK&&(be[0]=t.BACK,Oe=!0);Oe&&t.drawBuffers(be)}function fe(ne){return x!==ne?(t.useProgram(ne),x=ne,!0):!1}const le={[Gh]:t.FUNC_ADD,[bje]:t.FUNC_SUBTRACT,[yje]:t.FUNC_REVERSE_SUBTRACT};le[vje]=t.MIN,le[_je]=t.MAX;const Be={[wje]:t.ZERO,[Sje]:t.ONE,[Nje]:t.SRC_COLOR,[iP]:t.SRC_ALPHA,[kje]:t.SRC_ALPHA_SATURATE,[Aje]:t.DST_COLOR,[Eje]:t.DST_ALPHA,[Mje]:t.ONE_MINUS_SRC_COLOR,[aP]:t.ONE_MINUS_SRC_ALPHA,[Cje]:t.ONE_MINUS_DST_COLOR,[Tje]:t.ONE_MINUS_DST_ALPHA,[jje]:t.CONSTANT_COLOR,[Pje]:t.ONE_MINUS_CONSTANT_COLOR,[Rje]:t.CONSTANT_ALPHA,[Dje]:t.ONE_MINUS_CONSTANT_ALPHA};function V(ne,Pe,be,Oe,Ue,Ae,Je,gt,Pt,Ot){if(ne===eu){y===!0&&(Me(t.BLEND),y=!1);return}if(y===!1&&(ce(t.BLEND),y=!0),ne!==xje){if(ne!==b||Ot!==k){if((v!==Gh||T!==Gh)&&(t.blendEquation(t.FUNC_ADD),v=Gh,T=Gh),Ot)switch(ne){case Xp:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case hH:t.blendFunc(t.ONE,t.ONE);break;case fH:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case mH:t.blendFuncSeparate(t.DST_COLOR,t.ONE_MINUS_SRC_ALPHA,t.ZERO,t.ONE);break;default:ui("WebGLState: Invalid blending: ",ne);break}else switch(ne){case Xp:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case hH:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE,t.ONE,t.ONE);break;case fH:ui("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case mH:ui("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:ui("WebGLState: Invalid blending: ",ne);break}N=null,S=null,E=null,C=null,A.set(0,0,0),O=0,b=ne,k=Ot}return}Ue=Ue||Pe,Ae=Ae||be,Je=Je||Oe,(Pe!==v||Ue!==T)&&(t.blendEquationSeparate(le[Pe],le[Ue]),v=Pe,T=Ue),(be!==N||Oe!==S||Ae!==E||Je!==C)&&(t.blendFuncSeparate(Be[be],Be[Oe],Be[Ae],Be[Je]),N=be,S=Oe,E=Ae,C=Je),(gt.equals(A)===!1||Pt!==O)&&(t.blendColor(gt.r,gt.g,gt.b,Pt),A.copy(gt),O=Pt),b=ne,k=!1}function $(ne,Pe){ne.side===Cl?Me(t.CULL_FACE):ce(t.CULL_FACE);let be=ne.side===bs;Pe&&(be=!be),X(be),ne.blending===Xp&&ne.transparent===!1?V(eu):V(ne.blending,ne.blendEquation,ne.blendSrc,ne.blendDst,ne.blendEquationAlpha,ne.blendSrcAlpha,ne.blendDstAlpha,ne.blendColor,ne.blendAlpha,ne.premultipliedAlpha),o.setFunc(ne.depthFunc),o.setTest(ne.depthTest),o.setMask(ne.depthWrite),a.setMask(ne.colorWrite);const Oe=ne.stencilWrite;l.setTest(Oe),Oe&&(l.setMask(ne.stencilWriteMask),l.setFunc(ne.stencilFunc,ne.stencilRef,ne.stencilFuncMask),l.setOp(ne.stencilFail,ne.stencilZFail,ne.stencilZPass)),oe(ne.polygonOffset,ne.polygonOffsetFactor,ne.polygonOffsetUnits),ne.alphaToCoverage===!0?ce(t.SAMPLE_ALPHA_TO_COVERAGE):Me(t.SAMPLE_ALPHA_TO_COVERAGE)}function X(ne){R!==ne&&(ne?t.frontFace(t.CW):t.frontFace(t.CCW),R=ne)}function U(ne){ne!==mje?(ce(t.CULL_FACE),ne!==F&&(ne===dH?t.cullFace(t.BACK):ne===pje?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):Me(t.CULL_FACE),F=ne}function B(ne){ne!==L&&(Y&&t.lineWidth(ne),L=ne)}function oe(ne,Pe,be){ne?(ce(t.POLYGON_OFFSET_FILL),(K!==Pe||j!==be)&&(t.polygonOffset(Pe,be),K=Pe,j=be)):Me(t.POLYGON_OFFSET_FILL)}function Te(ne){ne?ce(t.SCISSOR_TEST):Me(t.SCISSOR_TEST)}function je(ne){ne===void 0&&(ne=t.TEXTURE0+W-1),ee!==ne&&(t.activeTexture(ne),ee=ne)}function Ce(ne,Pe,be){be===void 0&&(ee===null?be=t.TEXTURE0+W-1:be=ee);let Oe=re[be];Oe===void 0&&(Oe={type:void 0,texture:void 0},re[be]=Oe),(Oe.type!==ne||Oe.texture!==Pe)&&(ee!==be&&(t.activeTexture(be),ee=be),t.bindTexture(ne,Pe||pe[ne]),Oe.type=ne,Oe.texture=Pe)}function H(){const ne=re[ee];ne!==void 0&&ne.type!==void 0&&(t.bindTexture(ne.type,null),ne.type=void 0,ne.texture=void 0)}function D(){try{t.compressedTexImage2D(...arguments)}catch(ne){ne("WebGLState:",ne)}}function Z(){try{t.compressedTexImage3D(...arguments)}catch(ne){ne("WebGLState:",ne)}}function xe(){try{t.texSubImage2D(...arguments)}catch(ne){ne("WebGLState:",ne)}}function Ne(){try{t.texSubImage3D(...arguments)}catch(ne){ne("WebGLState:",ne)}}function ve(){try{t.compressedTexSubImage2D(...arguments)}catch(ne){ne("WebGLState:",ne)}}function $e(){try{t.compressedTexSubImage3D(...arguments)}catch(ne){ne("WebGLState:",ne)}}function Le(){try{t.texStorage2D(...arguments)}catch(ne){ne("WebGLState:",ne)}}function qe(){try{t.texStorage3D(...arguments)}catch(ne){ne("WebGLState:",ne)}}function Ke(){try{t.texImage2D(...arguments)}catch(ne){ne("WebGLState:",ne)}}function Ye(){try{t.texImage3D(...arguments)}catch(ne){ne("WebGLState:",ne)}}function ie(ne){ae.equals(ne)===!1&&(t.scissor(ne.x,ne.y,ne.z,ne.w),ae.copy(ne))}function te(ne){se.equals(ne)===!1&&(t.viewport(ne.x,ne.y,ne.z,ne.w),se.copy(ne))}function Se(ne,Pe){let be=u.get(Pe);be===void 0&&(be=new WeakMap,u.set(Pe,be));let Oe=be.get(ne);Oe===void 0&&(Oe=t.getUniformBlockIndex(Pe,ne.name),be.set(ne,Oe))}function ze(ne,Pe){const Oe=u.get(Pe).get(ne);c.get(Pe)!==Oe&&(t.uniformBlockBinding(Pe,Oe,ne.__bindingPointIndex),c.set(Pe,Oe))}function nt(){t.disable(t.BLEND),t.disable(t.CULL_FACE),t.disable(t.DEPTH_TEST),t.disable(t.POLYGON_OFFSET_FILL),t.disable(t.SCISSOR_TEST),t.disable(t.STENCIL_TEST),t.disable(t.SAMPLE_ALPHA_TO_COVERAGE),t.blendEquation(t.FUNC_ADD),t.blendFunc(t.ONE,t.ZERO),t.blendFuncSeparate(t.ONE,t.ZERO,t.ONE,t.ZERO),t.blendColor(0,0,0,0),t.colorMask(!0,!0,!0,!0),t.clearColor(0,0,0,0),t.depthMask(!0),t.depthFunc(t.LESS),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={},ee=null,re={},f={},m=new WeakMap,p=[],x=null,y=!1,b=null,v=null,N=null,S=null,T=null,E=null,C=null,A=new Dn(0,0,0),O=0,k=!1,R=null,F=null,L=null,K=null,j=null,ae.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:ce,disable:Me,bindFramebuffer:me,drawBuffers:Ee,useProgram:fe,setBlending:V,setMaterial:$,setFlipSided:X,setCullFace:U,setLineWidth:B,setPolygonOffset:oe,setScissorTest:Te,activeTexture:je,bindTexture:Ce,unbindTexture:H,compressedTexImage2D:D,compressedTexImage3D:Z,texImage2D:Ke,texImage3D:Ye,updateUBOMapping:Se,uniformBlockBinding:ze,texStorage2D:Le,texStorage3D:qe,texSubImage2D:xe,texSubImage3D:Ne,compressedTexSubImage2D:ve,compressedTexSubImage3D:$e,scissor:ie,viewport:te,reset:nt}}function vOe(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 Mn,d=new WeakMap;let f;const m=new WeakMap;let p=!1;try{p=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function x(H,D){return p?new OffscreenCanvas(H,D):wS("canvas")}function y(H,D,Z){let xe=1;const Ne=Ce(H);if((Ne.width>Z||Ne.height>Z)&&(xe=Z/Math.max(Ne.width,Ne.height)),xe<1)if(typeof HTMLImageElement<"u"&&H instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&H instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&H instanceof ImageBitmap||typeof VideoFrame<"u"&&H instanceof VideoFrame){const ve=Math.floor(xe*Ne.width),$e=Math.floor(xe*Ne.height);f===void 0&&(f=x(ve,$e));const Le=D?x(ve,$e):f;return Le.width=ve,Le.height=$e,Le.getContext("2d").drawImage(H,0,0,ve,$e),mn("WebGLRenderer: Texture has been resized from ("+Ne.width+"x"+Ne.height+") to ("+ve+"x"+$e+")."),Le}else return"data"in H&&mn("WebGLRenderer: Image in DataTexture is too big ("+Ne.width+"x"+Ne.height+")."),H;return H}function b(H){return H.generateMipmaps}function v(H){t.generateMipmap(H)}function N(H){return H.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:H.isWebGL3DRenderTarget?t.TEXTURE_3D:H.isWebGLArrayRenderTarget||H.isCompressedArrayTexture?t.TEXTURE_2D_ARRAY:t.TEXTURE_2D}function S(H,D,Z,xe,Ne=!1){if(H!==null){if(t[H]!==void 0)return t[H];mn("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+H+"'")}let ve=D;if(D===t.RED&&(Z===t.FLOAT&&(ve=t.R32F),Z===t.HALF_FLOAT&&(ve=t.R16F),Z===t.UNSIGNED_BYTE&&(ve=t.R8)),D===t.RED_INTEGER&&(Z===t.UNSIGNED_BYTE&&(ve=t.R8UI),Z===t.UNSIGNED_SHORT&&(ve=t.R16UI),Z===t.UNSIGNED_INT&&(ve=t.R32UI),Z===t.BYTE&&(ve=t.R8I),Z===t.SHORT&&(ve=t.R16I),Z===t.INT&&(ve=t.R32I)),D===t.RG&&(Z===t.FLOAT&&(ve=t.RG32F),Z===t.HALF_FLOAT&&(ve=t.RG16F),Z===t.UNSIGNED_BYTE&&(ve=t.RG8)),D===t.RG_INTEGER&&(Z===t.UNSIGNED_BYTE&&(ve=t.RG8UI),Z===t.UNSIGNED_SHORT&&(ve=t.RG16UI),Z===t.UNSIGNED_INT&&(ve=t.RG32UI),Z===t.BYTE&&(ve=t.RG8I),Z===t.SHORT&&(ve=t.RG16I),Z===t.INT&&(ve=t.RG32I)),D===t.RGB_INTEGER&&(Z===t.UNSIGNED_BYTE&&(ve=t.RGB8UI),Z===t.UNSIGNED_SHORT&&(ve=t.RGB16UI),Z===t.UNSIGNED_INT&&(ve=t.RGB32UI),Z===t.BYTE&&(ve=t.RGB8I),Z===t.SHORT&&(ve=t.RGB16I),Z===t.INT&&(ve=t.RGB32I)),D===t.RGBA_INTEGER&&(Z===t.UNSIGNED_BYTE&&(ve=t.RGBA8UI),Z===t.UNSIGNED_SHORT&&(ve=t.RGBA16UI),Z===t.UNSIGNED_INT&&(ve=t.RGBA32UI),Z===t.BYTE&&(ve=t.RGBA8I),Z===t.SHORT&&(ve=t.RGBA16I),Z===t.INT&&(ve=t.RGBA32I)),D===t.RGB&&(Z===t.UNSIGNED_INT_5_9_9_9_REV&&(ve=t.RGB9_E5),Z===t.UNSIGNED_INT_10F_11F_11F_REV&&(ve=t.R11F_G11F_B10F)),D===t.RGBA){const $e=Ne?vS:qn.getTransfer(xe);Z===t.FLOAT&&(ve=t.RGBA32F),Z===t.HALF_FLOAT&&(ve=t.RGBA16F),Z===t.UNSIGNED_BYTE&&(ve=$e===hr?t.SRGB8_ALPHA8:t.RGBA8),Z===t.UNSIGNED_SHORT_4_4_4_4&&(ve=t.RGBA4),Z===t.UNSIGNED_SHORT_5_5_5_1&&(ve=t.RGB5_A1)}return(ve===t.R16F||ve===t.R32F||ve===t.RG16F||ve===t.RG32F||ve===t.RGBA16F||ve===t.RGBA32F)&&e.get("EXT_color_buffer_float"),ve}function T(H,D){let Z;return H?D===null||D===zf||D===D0?Z=t.DEPTH24_STENCIL8:D===qc?Z=t.DEPTH32F_STENCIL8:D===R0&&(Z=t.DEPTH24_STENCIL8,mn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):D===null||D===zf||D===D0?Z=t.DEPTH_COMPONENT24:D===qc?Z=t.DEPTH_COMPONENT32F:D===R0&&(Z=t.DEPTH_COMPONENT16),Z}function E(H,D){return b(H)===!0||H.isFramebufferTexture&&H.minFilter!==Ws&&H.minFilter!==To?Math.log2(Math.max(D.width,D.height))+1:H.mipmaps!==void 0&&H.mipmaps.length>0?H.mipmaps.length:H.isCompressedTexture&&Array.isArray(H.image)?D.mipmaps.length:1}function C(H){const D=H.target;D.removeEventListener("dispose",C),O(D),D.isVideoTexture&&d.delete(D)}function A(H){const D=H.target;D.removeEventListener("dispose",A),R(D)}function O(H){const D=r.get(H);if(D.__webglInit===void 0)return;const Z=H.source,xe=m.get(Z);if(xe){const Ne=xe[D.__cacheKey];Ne.usedTimes--,Ne.usedTimes===0&&k(H),Object.keys(xe).length===0&&m.delete(Z)}r.remove(H)}function k(H){const D=r.get(H);t.deleteTexture(D.__webglTexture);const Z=H.source,xe=m.get(Z);delete xe[D.__cacheKey],o.memory.textures--}function R(H){const D=r.get(H);if(H.depthTexture&&(H.depthTexture.dispose(),r.remove(H.depthTexture)),H.isWebGLCubeRenderTarget)for(let xe=0;xe<6;xe++){if(Array.isArray(D.__webglFramebuffer[xe]))for(let Ne=0;Ne<D.__webglFramebuffer[xe].length;Ne++)t.deleteFramebuffer(D.__webglFramebuffer[xe][Ne]);else t.deleteFramebuffer(D.__webglFramebuffer[xe]);D.__webglDepthbuffer&&t.deleteRenderbuffer(D.__webglDepthbuffer[xe])}else{if(Array.isArray(D.__webglFramebuffer))for(let xe=0;xe<D.__webglFramebuffer.length;xe++)t.deleteFramebuffer(D.__webglFramebuffer[xe]);else t.deleteFramebuffer(D.__webglFramebuffer);if(D.__webglDepthbuffer&&t.deleteRenderbuffer(D.__webglDepthbuffer),D.__webglMultisampledFramebuffer&&t.deleteFramebuffer(D.__webglMultisampledFramebuffer),D.__webglColorRenderbuffer)for(let xe=0;xe<D.__webglColorRenderbuffer.length;xe++)D.__webglColorRenderbuffer[xe]&&t.deleteRenderbuffer(D.__webglColorRenderbuffer[xe]);D.__webglDepthRenderbuffer&&t.deleteRenderbuffer(D.__webglDepthRenderbuffer)}const Z=H.textures;for(let xe=0,Ne=Z.length;xe<Ne;xe++){const ve=r.get(Z[xe]);ve.__webglTexture&&(t.deleteTexture(ve.__webglTexture),o.memory.textures--),r.remove(Z[xe])}r.remove(H)}let F=0;function L(){F=0}function K(){const H=F;return H>=i.maxTextures&&mn("WebGLTextures: Trying to use "+H+" texture units while this GPU supports only "+i.maxTextures),F+=1,H}function j(H){const D=[];return D.push(H.wrapS),D.push(H.wrapT),D.push(H.wrapR||0),D.push(H.magFilter),D.push(H.minFilter),D.push(H.anisotropy),D.push(H.internalFormat),D.push(H.format),D.push(H.type),D.push(H.generateMipmaps),D.push(H.premultiplyAlpha),D.push(H.flipY),D.push(H.unpackAlignment),D.push(H.colorSpace),D.join()}function W(H,D){const Z=r.get(H);if(H.isVideoTexture&&Te(H),H.isRenderTargetTexture===!1&&H.isExternalTexture!==!0&&H.version>0&&Z.__version!==H.version){const xe=H.image;if(xe===null)mn("WebGLRenderer: Texture marked for update but no image data found.");else if(xe.complete===!1)mn("WebGLRenderer: Texture marked for update but image is incomplete");else{pe(Z,H,D);return}}else H.isExternalTexture&&(Z.__webglTexture=H.sourceTexture?H.sourceTexture:null);n.bindTexture(t.TEXTURE_2D,Z.__webglTexture,t.TEXTURE0+D)}function Y(H,D){const Z=r.get(H);if(H.isRenderTargetTexture===!1&&H.version>0&&Z.__version!==H.version){pe(Z,H,D);return}else H.isExternalTexture&&(Z.__webglTexture=H.sourceTexture?H.sourceTexture:null);n.bindTexture(t.TEXTURE_2D_ARRAY,Z.__webglTexture,t.TEXTURE0+D)}function q(H,D){const Z=r.get(H);if(H.isRenderTargetTexture===!1&&H.version>0&&Z.__version!==H.version){pe(Z,H,D);return}n.bindTexture(t.TEXTURE_3D,Z.__webglTexture,t.TEXTURE0+D)}function Q(H,D){const Z=r.get(H);if(H.version>0&&Z.__version!==H.version){ce(Z,H,D);return}n.bindTexture(t.TEXTURE_CUBE_MAP,Z.__webglTexture,t.TEXTURE0+D)}const ee={[pP]:t.REPEAT,[Wc]:t.CLAMP_TO_EDGE,[gP]:t.MIRRORED_REPEAT},re={[Ws]:t.NEAREST,[Vje]:t.NEAREST_MIPMAP_NEAREST,[w_]:t.NEAREST_MIPMAP_LINEAR,[To]:t.LINEAR,[NC]:t.LINEAR_MIPMAP_NEAREST,[rf]:t.LINEAR_MIPMAP_LINEAR},z={[Kje]:t.NEVER,[e3e]:t.ALWAYS,[Xje]:t.LESS,[WZ]:t.LEQUAL,[Yje]:t.EQUAL,[Jje]:t.GEQUAL,[Qje]:t.GREATER,[Zje]:t.NOTEQUAL};function G(H,D){if(D.type===qc&&e.has("OES_texture_float_linear")===!1&&(D.magFilter===To||D.magFilter===NC||D.magFilter===w_||D.magFilter===rf||D.minFilter===To||D.minFilter===NC||D.minFilter===w_||D.minFilter===rf)&&mn("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),t.texParameteri(H,t.TEXTURE_WRAP_S,ee[D.wrapS]),t.texParameteri(H,t.TEXTURE_WRAP_T,ee[D.wrapT]),(H===t.TEXTURE_3D||H===t.TEXTURE_2D_ARRAY)&&t.texParameteri(H,t.TEXTURE_WRAP_R,ee[D.wrapR]),t.texParameteri(H,t.TEXTURE_MAG_FILTER,re[D.magFilter]),t.texParameteri(H,t.TEXTURE_MIN_FILTER,re[D.minFilter]),D.compareFunction&&(t.texParameteri(H,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(H,t.TEXTURE_COMPARE_FUNC,z[D.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(D.magFilter===Ws||D.minFilter!==w_&&D.minFilter!==rf||D.type===qc&&e.has("OES_texture_float_linear")===!1)return;if(D.anisotropy>1||r.get(D).__currentAnisotropy){const Z=e.get("EXT_texture_filter_anisotropic");t.texParameterf(H,Z.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(D.anisotropy,i.getMaxAnisotropy())),r.get(D).__currentAnisotropy=D.anisotropy}}}function ae(H,D){let Z=!1;H.__webglInit===void 0&&(H.__webglInit=!0,D.addEventListener("dispose",C));const xe=D.source;let Ne=m.get(xe);Ne===void 0&&(Ne={},m.set(xe,Ne));const ve=j(D);if(ve!==H.__cacheKey){Ne[ve]===void 0&&(Ne[ve]={texture:t.createTexture(),usedTimes:0},o.memory.textures++,Z=!0),Ne[ve].usedTimes++;const $e=Ne[H.__cacheKey];$e!==void 0&&(Ne[H.__cacheKey].usedTimes--,$e.usedTimes===0&&k(D)),H.__cacheKey=ve,H.__webglTexture=Ne[ve].texture}return Z}function se(H,D,Z){return Math.floor(Math.floor(H/Z)/D)}function ue(H,D,Z,xe){const ve=H.updateRanges;if(ve.length===0)n.texSubImage2D(t.TEXTURE_2D,0,0,0,D.width,D.height,Z,xe,D.data);else{ve.sort((Ye,ie)=>Ye.start-ie.start);let $e=0;for(let Ye=1;Ye<ve.length;Ye++){const ie=ve[$e],te=ve[Ye],Se=ie.start+ie.count,ze=se(te.start,D.width,4),nt=se(ie.start,D.width,4);te.start<=Se+1&&ze===nt&&se(te.start+te.count-1,D.width,4)===ze?ie.count=Math.max(ie.count,te.start+te.count-ie.start):(++$e,ve[$e]=te)}ve.length=$e+1;const Le=t.getParameter(t.UNPACK_ROW_LENGTH),qe=t.getParameter(t.UNPACK_SKIP_PIXELS),Ke=t.getParameter(t.UNPACK_SKIP_ROWS);t.pixelStorei(t.UNPACK_ROW_LENGTH,D.width);for(let Ye=0,ie=ve.length;Ye<ie;Ye++){const te=ve[Ye],Se=Math.floor(te.start/4),ze=Math.ceil(te.count/4),nt=Se%D.width,ne=Math.floor(Se/D.width),Pe=ze,be=1;t.pixelStorei(t.UNPACK_SKIP_PIXELS,nt),t.pixelStorei(t.UNPACK_SKIP_ROWS,ne),n.texSubImage2D(t.TEXTURE_2D,0,nt,ne,Pe,be,Z,xe,D.data)}H.clearUpdateRanges(),t.pixelStorei(t.UNPACK_ROW_LENGTH,Le),t.pixelStorei(t.UNPACK_SKIP_PIXELS,qe),t.pixelStorei(t.UNPACK_SKIP_ROWS,Ke)}}function pe(H,D,Z){let xe=t.TEXTURE_2D;(D.isDataArrayTexture||D.isCompressedArrayTexture)&&(xe=t.TEXTURE_2D_ARRAY),D.isData3DTexture&&(xe=t.TEXTURE_3D);const Ne=ae(H,D),ve=D.source;n.bindTexture(xe,H.__webglTexture,t.TEXTURE0+Z);const $e=r.get(ve);if(ve.version!==$e.__version||Ne===!0){n.activeTexture(t.TEXTURE0+Z);const Le=qn.getPrimaries(qn.workingColorSpace),qe=D.colorSpace===xd?null:qn.getPrimaries(D.colorSpace),Ke=D.colorSpace===xd||Le===qe?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,D.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,D.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,D.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ke);let Ye=y(D.image,!1,i.maxTextureSize);Ye=je(D,Ye);const ie=a.convert(D.format,D.colorSpace),te=a.convert(D.type);let Se=S(D.internalFormat,ie,te,D.colorSpace,D.isVideoTexture);G(xe,D);let ze;const nt=D.mipmaps,ne=D.isVideoTexture!==!0,Pe=$e.__version===void 0||Ne===!0,be=ve.dataReady,Oe=E(D,Ye);if(D.isDepthTexture)Se=T(D.format===L0,D.type),Pe&&(ne?n.texStorage2D(t.TEXTURE_2D,1,Se,Ye.width,Ye.height):n.texImage2D(t.TEXTURE_2D,0,Se,Ye.width,Ye.height,0,ie,te,null));else if(D.isDataTexture)if(nt.length>0){ne&&Pe&&n.texStorage2D(t.TEXTURE_2D,Oe,Se,nt[0].width,nt[0].height);for(let Ue=0,Ae=nt.length;Ue<Ae;Ue++)ze=nt[Ue],ne?be&&n.texSubImage2D(t.TEXTURE_2D,Ue,0,0,ze.width,ze.height,ie,te,ze.data):n.texImage2D(t.TEXTURE_2D,Ue,Se,ze.width,ze.height,0,ie,te,ze.data);D.generateMipmaps=!1}else ne?(Pe&&n.texStorage2D(t.TEXTURE_2D,Oe,Se,Ye.width,Ye.height),be&&ue(D,Ye,ie,te)):n.texImage2D(t.TEXTURE_2D,0,Se,Ye.width,Ye.height,0,ie,te,Ye.data);else if(D.isCompressedTexture)if(D.isCompressedArrayTexture){ne&&Pe&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Oe,Se,nt[0].width,nt[0].height,Ye.depth);for(let Ue=0,Ae=nt.length;Ue<Ae;Ue++)if(ze=nt[Ue],D.format!==nl)if(ie!==null)if(ne){if(be)if(D.layerUpdates.size>0){const Je=VH(ze.width,ze.height,D.format,D.type);for(const gt of D.layerUpdates){const Pt=ze.data.subarray(gt*Je/ze.data.BYTES_PER_ELEMENT,(gt+1)*Je/ze.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,Ue,0,0,gt,ze.width,ze.height,1,ie,Pt)}D.clearLayerUpdates()}else n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,Ue,0,0,0,ze.width,ze.height,Ye.depth,ie,ze.data)}else n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,Ue,Se,ze.width,ze.height,Ye.depth,0,ze.data,0,0);else mn("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else ne?be&&n.texSubImage3D(t.TEXTURE_2D_ARRAY,Ue,0,0,0,ze.width,ze.height,Ye.depth,ie,te,ze.data):n.texImage3D(t.TEXTURE_2D_ARRAY,Ue,Se,ze.width,ze.height,Ye.depth,0,ie,te,ze.data)}else{ne&&Pe&&n.texStorage2D(t.TEXTURE_2D,Oe,Se,nt[0].width,nt[0].height);for(let Ue=0,Ae=nt.length;Ue<Ae;Ue++)ze=nt[Ue],D.format!==nl?ie!==null?ne?be&&n.compressedTexSubImage2D(t.TEXTURE_2D,Ue,0,0,ze.width,ze.height,ie,ze.data):n.compressedTexImage2D(t.TEXTURE_2D,Ue,Se,ze.width,ze.height,0,ze.data):mn("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):ne?be&&n.texSubImage2D(t.TEXTURE_2D,Ue,0,0,ze.width,ze.height,ie,te,ze.data):n.texImage2D(t.TEXTURE_2D,Ue,Se,ze.width,ze.height,0,ie,te,ze.data)}else if(D.isDataArrayTexture)if(ne){if(Pe&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Oe,Se,Ye.width,Ye.height,Ye.depth),be)if(D.layerUpdates.size>0){const Ue=VH(Ye.width,Ye.height,D.format,D.type);for(const Ae of D.layerUpdates){const Je=Ye.data.subarray(Ae*Ue/Ye.data.BYTES_PER_ELEMENT,(Ae+1)*Ue/Ye.data.BYTES_PER_ELEMENT);n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,Ae,Ye.width,Ye.height,1,ie,te,Je)}D.clearLayerUpdates()}else n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,Ye.width,Ye.height,Ye.depth,ie,te,Ye.data)}else n.texImage3D(t.TEXTURE_2D_ARRAY,0,Se,Ye.width,Ye.height,Ye.depth,0,ie,te,Ye.data);else if(D.isData3DTexture)ne?(Pe&&n.texStorage3D(t.TEXTURE_3D,Oe,Se,Ye.width,Ye.height,Ye.depth),be&&n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,Ye.width,Ye.height,Ye.depth,ie,te,Ye.data)):n.texImage3D(t.TEXTURE_3D,0,Se,Ye.width,Ye.height,Ye.depth,0,ie,te,Ye.data);else if(D.isFramebufferTexture){if(Pe)if(ne)n.texStorage2D(t.TEXTURE_2D,Oe,Se,Ye.width,Ye.height);else{let Ue=Ye.width,Ae=Ye.height;for(let Je=0;Je<Oe;Je++)n.texImage2D(t.TEXTURE_2D,Je,Se,Ue,Ae,0,ie,te,null),Ue>>=1,Ae>>=1}}else if(nt.length>0){if(ne&&Pe){const Ue=Ce(nt[0]);n.texStorage2D(t.TEXTURE_2D,Oe,Se,Ue.width,Ue.height)}for(let Ue=0,Ae=nt.length;Ue<Ae;Ue++)ze=nt[Ue],ne?be&&n.texSubImage2D(t.TEXTURE_2D,Ue,0,0,ie,te,ze):n.texImage2D(t.TEXTURE_2D,Ue,Se,ie,te,ze);D.generateMipmaps=!1}else if(ne){if(Pe){const Ue=Ce(Ye);n.texStorage2D(t.TEXTURE_2D,Oe,Se,Ue.width,Ue.height)}be&&n.texSubImage2D(t.TEXTURE_2D,0,0,0,ie,te,Ye)}else n.texImage2D(t.TEXTURE_2D,0,Se,ie,te,Ye);b(D)&&v(xe),$e.__version=ve.version,D.onUpdate&&D.onUpdate(D)}H.__version=D.version}function ce(H,D,Z){if(D.image.length!==6)return;const xe=ae(H,D),Ne=D.source;n.bindTexture(t.TEXTURE_CUBE_MAP,H.__webglTexture,t.TEXTURE0+Z);const ve=r.get(Ne);if(Ne.version!==ve.__version||xe===!0){n.activeTexture(t.TEXTURE0+Z);const $e=qn.getPrimaries(qn.workingColorSpace),Le=D.colorSpace===xd?null:qn.getPrimaries(D.colorSpace),qe=D.colorSpace===xd||$e===Le?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,D.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,D.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,D.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,qe);const Ke=D.isCompressedTexture||D.image[0].isCompressedTexture,Ye=D.image[0]&&D.image[0].isDataTexture,ie=[];for(let Ae=0;Ae<6;Ae++)!Ke&&!Ye?ie[Ae]=y(D.image[Ae],!0,i.maxCubemapSize):ie[Ae]=Ye?D.image[Ae].image:D.image[Ae],ie[Ae]=je(D,ie[Ae]);const te=ie[0],Se=a.convert(D.format,D.colorSpace),ze=a.convert(D.type),nt=S(D.internalFormat,Se,ze,D.colorSpace),ne=D.isVideoTexture!==!0,Pe=ve.__version===void 0||xe===!0,be=Ne.dataReady;let Oe=E(D,te);G(t.TEXTURE_CUBE_MAP,D);let Ue;if(Ke){ne&&Pe&&n.texStorage2D(t.TEXTURE_CUBE_MAP,Oe,nt,te.width,te.height);for(let Ae=0;Ae<6;Ae++){Ue=ie[Ae].mipmaps;for(let Je=0;Je<Ue.length;Je++){const gt=Ue[Je];D.format!==nl?Se!==null?ne?be&&n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,Je,0,0,gt.width,gt.height,Se,gt.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,Je,nt,gt.width,gt.height,0,gt.data):mn("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):ne?be&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,Je,0,0,gt.width,gt.height,Se,ze,gt.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,Je,nt,gt.width,gt.height,0,Se,ze,gt.data)}}}else{if(Ue=D.mipmaps,ne&&Pe){Ue.length>0&&Oe++;const Ae=Ce(ie[0]);n.texStorage2D(t.TEXTURE_CUBE_MAP,Oe,nt,Ae.width,Ae.height)}for(let Ae=0;Ae<6;Ae++)if(Ye){ne?be&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,0,0,0,ie[Ae].width,ie[Ae].height,Se,ze,ie[Ae].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,0,nt,ie[Ae].width,ie[Ae].height,0,Se,ze,ie[Ae].data);for(let Je=0;Je<Ue.length;Je++){const Pt=Ue[Je].image[Ae].image;ne?be&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,Je+1,0,0,Pt.width,Pt.height,Se,ze,Pt.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,Je+1,nt,Pt.width,Pt.height,0,Se,ze,Pt.data)}}else{ne?be&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,0,0,0,Se,ze,ie[Ae]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,0,nt,Se,ze,ie[Ae]);for(let Je=0;Je<Ue.length;Je++){const gt=Ue[Je];ne?be&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,Je+1,0,0,Se,ze,gt.image[Ae]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,Je+1,nt,Se,ze,gt.image[Ae])}}}b(D)&&v(t.TEXTURE_CUBE_MAP),ve.__version=Ne.version,D.onUpdate&&D.onUpdate(D)}H.__version=D.version}function Me(H,D,Z,xe,Ne,ve){const $e=a.convert(Z.format,Z.colorSpace),Le=a.convert(Z.type),qe=S(Z.internalFormat,$e,Le,Z.colorSpace),Ke=r.get(D),Ye=r.get(Z);if(Ye.__renderTarget=D,!Ke.__hasExternalTextures){const ie=Math.max(1,D.width>>ve),te=Math.max(1,D.height>>ve);Ne===t.TEXTURE_3D||Ne===t.TEXTURE_2D_ARRAY?n.texImage3D(Ne,ve,qe,ie,te,D.depth,0,$e,Le,null):n.texImage2D(Ne,ve,qe,ie,te,0,$e,Le,null)}n.bindFramebuffer(t.FRAMEBUFFER,H),oe(D)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,xe,Ne,Ye.__webglTexture,0,B(D)):(Ne===t.TEXTURE_2D||Ne>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&Ne<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,xe,Ne,Ye.__webglTexture,ve),n.bindFramebuffer(t.FRAMEBUFFER,null)}function me(H,D,Z){if(t.bindRenderbuffer(t.RENDERBUFFER,H),D.depthBuffer){const xe=D.depthTexture,Ne=xe&&xe.isDepthTexture?xe.type:null,ve=T(D.stencilBuffer,Ne),$e=D.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,Le=B(D);oe(D)?l.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,Le,ve,D.width,D.height):Z?t.renderbufferStorageMultisample(t.RENDERBUFFER,Le,ve,D.width,D.height):t.renderbufferStorage(t.RENDERBUFFER,ve,D.width,D.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,$e,t.RENDERBUFFER,H)}else{const xe=D.textures;for(let Ne=0;Ne<xe.length;Ne++){const ve=xe[Ne],$e=a.convert(ve.format,ve.colorSpace),Le=a.convert(ve.type),qe=S(ve.internalFormat,$e,Le,ve.colorSpace),Ke=B(D);Z&&oe(D)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,Ke,qe,D.width,D.height):oe(D)?l.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,Ke,qe,D.width,D.height):t.renderbufferStorage(t.RENDERBUFFER,qe,D.width,D.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function Ee(H,D){if(D&&D.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(t.FRAMEBUFFER,H),!(D.depthTexture&&D.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const xe=r.get(D.depthTexture);xe.__renderTarget=D,(!xe.__webglTexture||D.depthTexture.image.width!==D.width||D.depthTexture.image.height!==D.height)&&(D.depthTexture.image.width=D.width,D.depthTexture.image.height=D.height,D.depthTexture.needsUpdate=!0),W(D.depthTexture,0);const Ne=xe.__webglTexture,ve=B(D);if(D.depthTexture.format===O0)oe(D)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,Ne,0,ve):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,Ne,0);else if(D.depthTexture.format===L0)oe(D)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,Ne,0,ve):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,Ne,0);else throw new Error("Unknown depthTexture format")}function fe(H){const D=r.get(H),Z=H.isWebGLCubeRenderTarget===!0;if(D.__boundDepthTexture!==H.depthTexture){const xe=H.depthTexture;if(D.__depthDisposeCallback&&D.__depthDisposeCallback(),xe){const Ne=()=>{delete D.__boundDepthTexture,delete D.__depthDisposeCallback,xe.removeEventListener("dispose",Ne)};xe.addEventListener("dispose",Ne),D.__depthDisposeCallback=Ne}D.__boundDepthTexture=xe}if(H.depthTexture&&!D.__autoAllocateDepthBuffer){if(Z)throw new Error("target.depthTexture not supported in Cube render targets");const xe=H.texture.mipmaps;xe&&xe.length>0?Ee(D.__webglFramebuffer[0],H):Ee(D.__webglFramebuffer,H)}else if(Z){D.__webglDepthbuffer=[];for(let xe=0;xe<6;xe++)if(n.bindFramebuffer(t.FRAMEBUFFER,D.__webglFramebuffer[xe]),D.__webglDepthbuffer[xe]===void 0)D.__webglDepthbuffer[xe]=t.createRenderbuffer(),me(D.__webglDepthbuffer[xe],H,!1);else{const Ne=H.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,ve=D.__webglDepthbuffer[xe];t.bindRenderbuffer(t.RENDERBUFFER,ve),t.framebufferRenderbuffer(t.FRAMEBUFFER,Ne,t.RENDERBUFFER,ve)}}else{const xe=H.texture.mipmaps;if(xe&&xe.length>0?n.bindFramebuffer(t.FRAMEBUFFER,D.__webglFramebuffer[0]):n.bindFramebuffer(t.FRAMEBUFFER,D.__webglFramebuffer),D.__webglDepthbuffer===void 0)D.__webglDepthbuffer=t.createRenderbuffer(),me(D.__webglDepthbuffer,H,!1);else{const Ne=H.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,ve=D.__webglDepthbuffer;t.bindRenderbuffer(t.RENDERBUFFER,ve),t.framebufferRenderbuffer(t.FRAMEBUFFER,Ne,t.RENDERBUFFER,ve)}}n.bindFramebuffer(t.FRAMEBUFFER,null)}function le(H,D,Z){const xe=r.get(H);D!==void 0&&Me(xe.__webglFramebuffer,H,H.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),Z!==void 0&&fe(H)}function Be(H){const D=H.texture,Z=r.get(H),xe=r.get(D);H.addEventListener("dispose",A);const Ne=H.textures,ve=H.isWebGLCubeRenderTarget===!0,$e=Ne.length>1;if($e||(xe.__webglTexture===void 0&&(xe.__webglTexture=t.createTexture()),xe.__version=D.version,o.memory.textures++),ve){Z.__webglFramebuffer=[];for(let Le=0;Le<6;Le++)if(D.mipmaps&&D.mipmaps.length>0){Z.__webglFramebuffer[Le]=[];for(let qe=0;qe<D.mipmaps.length;qe++)Z.__webglFramebuffer[Le][qe]=t.createFramebuffer()}else Z.__webglFramebuffer[Le]=t.createFramebuffer()}else{if(D.mipmaps&&D.mipmaps.length>0){Z.__webglFramebuffer=[];for(let Le=0;Le<D.mipmaps.length;Le++)Z.__webglFramebuffer[Le]=t.createFramebuffer()}else Z.__webglFramebuffer=t.createFramebuffer();if($e)for(let Le=0,qe=Ne.length;Le<qe;Le++){const Ke=r.get(Ne[Le]);Ke.__webglTexture===void 0&&(Ke.__webglTexture=t.createTexture(),o.memory.textures++)}if(H.samples>0&&oe(H)===!1){Z.__webglMultisampledFramebuffer=t.createFramebuffer(),Z.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,Z.__webglMultisampledFramebuffer);for(let Le=0;Le<Ne.length;Le++){const qe=Ne[Le];Z.__webglColorRenderbuffer[Le]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,Z.__webglColorRenderbuffer[Le]);const Ke=a.convert(qe.format,qe.colorSpace),Ye=a.convert(qe.type),ie=S(qe.internalFormat,Ke,Ye,qe.colorSpace,H.isXRRenderTarget===!0),te=B(H);t.renderbufferStorageMultisample(t.RENDERBUFFER,te,ie,H.width,H.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Le,t.RENDERBUFFER,Z.__webglColorRenderbuffer[Le])}t.bindRenderbuffer(t.RENDERBUFFER,null),H.depthBuffer&&(Z.__webglDepthRenderbuffer=t.createRenderbuffer(),me(Z.__webglDepthRenderbuffer,H,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(ve){n.bindTexture(t.TEXTURE_CUBE_MAP,xe.__webglTexture),G(t.TEXTURE_CUBE_MAP,D);for(let Le=0;Le<6;Le++)if(D.mipmaps&&D.mipmaps.length>0)for(let qe=0;qe<D.mipmaps.length;qe++)Me(Z.__webglFramebuffer[Le][qe],H,D,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Le,qe);else Me(Z.__webglFramebuffer[Le],H,D,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Le,0);b(D)&&v(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if($e){for(let Le=0,qe=Ne.length;Le<qe;Le++){const Ke=Ne[Le],Ye=r.get(Ke);let ie=t.TEXTURE_2D;(H.isWebGL3DRenderTarget||H.isWebGLArrayRenderTarget)&&(ie=H.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(ie,Ye.__webglTexture),G(ie,Ke),Me(Z.__webglFramebuffer,H,Ke,t.COLOR_ATTACHMENT0+Le,ie,0),b(Ke)&&v(ie)}n.unbindTexture()}else{let Le=t.TEXTURE_2D;if((H.isWebGL3DRenderTarget||H.isWebGLArrayRenderTarget)&&(Le=H.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(Le,xe.__webglTexture),G(Le,D),D.mipmaps&&D.mipmaps.length>0)for(let qe=0;qe<D.mipmaps.length;qe++)Me(Z.__webglFramebuffer[qe],H,D,t.COLOR_ATTACHMENT0,Le,qe);else Me(Z.__webglFramebuffer,H,D,t.COLOR_ATTACHMENT0,Le,0);b(D)&&v(Le),n.unbindTexture()}H.depthBuffer&&fe(H)}function V(H){const D=H.textures;for(let Z=0,xe=D.length;Z<xe;Z++){const Ne=D[Z];if(b(Ne)){const ve=N(H),$e=r.get(Ne).__webglTexture;n.bindTexture(ve,$e),v(ve),n.unbindTexture()}}}const $=[],X=[];function U(H){if(H.samples>0){if(oe(H)===!1){const D=H.textures,Z=H.width,xe=H.height;let Ne=t.COLOR_BUFFER_BIT;const ve=H.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,$e=r.get(H),Le=D.length>1;if(Le)for(let Ke=0;Ke<D.length;Ke++)n.bindFramebuffer(t.FRAMEBUFFER,$e.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ke,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,$e.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ke,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,$e.__webglMultisampledFramebuffer);const qe=H.texture.mipmaps;qe&&qe.length>0?n.bindFramebuffer(t.DRAW_FRAMEBUFFER,$e.__webglFramebuffer[0]):n.bindFramebuffer(t.DRAW_FRAMEBUFFER,$e.__webglFramebuffer);for(let Ke=0;Ke<D.length;Ke++){if(H.resolveDepthBuffer&&(H.depthBuffer&&(Ne|=t.DEPTH_BUFFER_BIT),H.stencilBuffer&&H.resolveStencilBuffer&&(Ne|=t.STENCIL_BUFFER_BIT)),Le){t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,$e.__webglColorRenderbuffer[Ke]);const Ye=r.get(D[Ke]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,Ye,0)}t.blitFramebuffer(0,0,Z,xe,0,0,Z,xe,Ne,t.NEAREST),c===!0&&($.length=0,X.length=0,$.push(t.COLOR_ATTACHMENT0+Ke),H.depthBuffer&&H.resolveDepthBuffer===!1&&($.push(ve),X.push(ve),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,X)),t.invalidateFramebuffer(t.READ_FRAMEBUFFER,$))}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),Le)for(let Ke=0;Ke<D.length;Ke++){n.bindFramebuffer(t.FRAMEBUFFER,$e.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ke,t.RENDERBUFFER,$e.__webglColorRenderbuffer[Ke]);const Ye=r.get(D[Ke]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,$e.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ke,t.TEXTURE_2D,Ye,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,$e.__webglMultisampledFramebuffer)}else if(H.depthBuffer&&H.resolveDepthBuffer===!1&&c){const D=H.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[D])}}}function B(H){return Math.min(i.maxSamples,H.samples)}function oe(H){const D=r.get(H);return H.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&D.__useRenderToTexture!==!1}function Te(H){const D=o.render.frame;d.get(H)!==D&&(d.set(H,D),H.update())}function je(H,D){const Z=H.colorSpace,xe=H.format,Ne=H.type;return H.isCompressedTexture===!0||H.isVideoTexture===!0||Z!==yg&&Z!==xd&&(qn.getTransfer(Z)===hr?(xe!==nl||Ne!==Gl)&&mn("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):ui("WebGLTextures: Unsupported texture color space:",Z)),D}function Ce(H){return typeof HTMLImageElement<"u"&&H instanceof HTMLImageElement?(u.width=H.naturalWidth||H.width,u.height=H.naturalHeight||H.height):typeof VideoFrame<"u"&&H instanceof VideoFrame?(u.width=H.displayWidth,u.height=H.displayHeight):(u.width=H.width,u.height=H.height),u}this.allocateTextureUnit=K,this.resetTextureUnits=L,this.setTexture2D=W,this.setTexture2DArray=Y,this.setTexture3D=q,this.setTextureCube=Q,this.rebindTextures=le,this.setupRenderTarget=Be,this.updateRenderTargetMipmap=V,this.updateMultisampleRenderTarget=U,this.setupDepthRenderbuffer=fe,this.setupFrameBufferTexture=Me,this.useMultisampledRTT=oe}function _Oe(t,e){function n(r,i=xd){let a;const o=qn.getTransfer(i);if(r===Gl)return t.UNSIGNED_BYTE;if(r===SO)return t.UNSIGNED_SHORT_4_4_4_4;if(r===NO)return t.UNSIGNED_SHORT_5_5_5_1;if(r===zZ)return t.UNSIGNED_INT_5_9_9_9_REV;if(r===BZ)return t.UNSIGNED_INT_10F_11F_11F_REV;if(r===FZ)return t.BYTE;if(r===UZ)return t.SHORT;if(r===R0)return t.UNSIGNED_SHORT;if(r===wO)return t.INT;if(r===zf)return t.UNSIGNED_INT;if(r===qc)return t.FLOAT;if(r===Zg)return t.HALF_FLOAT;if(r===$Z)return t.ALPHA;if(r===HZ)return t.RGB;if(r===nl)return t.RGBA;if(r===O0)return t.DEPTH_COMPONENT;if(r===L0)return t.DEPTH_STENCIL;if(r===VZ)return t.RED;if(r===MO)return t.RED_INTEGER;if(r===EO)return t.RG;if(r===TO)return t.RG_INTEGER;if(r===AO)return t.RGBA_INTEGER;if(r===X1||r===Y1||r===Q1||r===Z1)if(o===hr)if(a=e.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(r===X1)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(r===Y1)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(r===Q1)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(r===Z1)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=e.get("WEBGL_compressed_texture_s3tc"),a!==null){if(r===X1)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(r===Y1)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(r===Q1)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(r===Z1)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(r===xP||r===bP||r===yP||r===vP)if(a=e.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(r===xP)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(r===bP)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(r===yP)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(r===vP)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(r===_P||r===wP||r===SP)if(a=e.get("WEBGL_compressed_texture_etc"),a!==null){if(r===_P||r===wP)return o===hr?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(r===SP)return o===hr?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(r===NP||r===MP||r===EP||r===TP||r===AP||r===CP||r===kP||r===jP||r===PP||r===RP||r===DP||r===OP||r===LP||r===IP)if(a=e.get("WEBGL_compressed_texture_astc"),a!==null){if(r===NP)return o===hr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(r===MP)return o===hr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(r===EP)return o===hr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(r===TP)return o===hr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(r===AP)return o===hr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(r===CP)return o===hr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(r===kP)return o===hr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(r===jP)return o===hr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(r===PP)return o===hr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(r===RP)return o===hr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(r===DP)return o===hr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(r===OP)return o===hr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(r===LP)return o===hr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(r===IP)return o===hr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(r===FP||r===UP||r===zP)if(a=e.get("EXT_texture_compression_bptc"),a!==null){if(r===FP)return o===hr?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(r===UP)return a.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(r===zP)return a.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(r===BP||r===$P||r===HP||r===VP)if(a=e.get("EXT_texture_compression_rgtc"),a!==null){if(r===BP)return a.COMPRESSED_RED_RGTC1_EXT;if(r===$P)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(r===HP)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(r===VP)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return r===D0?t.UNSIGNED_INT_24_8:t[r]!==void 0?t[r]:null}return{convert:n}}const wOe=`
  3905. void main() {
  3906. gl_Position = vec4( position, 1.0 );
  3907. }`,SOe=`
  3908. uniform sampler2DArray depthColor;
  3909. uniform float depthWidth;
  3910. uniform float depthHeight;
  3911. void main() {
  3912. vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );
  3913. if ( coord.x >= 1.0 ) {
  3914. gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;
  3915. } else {
  3916. gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;
  3917. }
  3918. }`;class NOe{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,n){if(this.texture===null){const r=new dJ(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 mu({vertexShader:wOe,fragmentShader:SOe,uniforms:{depthColor:{value:this.texture},depthWidth:{value:n.z},depthHeight:{value:n.w}}});this.mesh=new Wl(new DO(20,20),r)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}let MOe=class extends nm{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,m=null,p=null,x=null;const y=typeof XRWebGLBinding<"u",b=new NOe,v={},N=n.getContextAttributes();let S=null,T=null;const E=[],C=[],A=new Mn;let O=null;const k=new _o;k.viewport=new _i;const R=new _o;R.viewport=new _i;const F=[k,R],L=new $3e;let K=null,j=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(pe){let ce=E[pe];return ce===void 0&&(ce=new WC,E[pe]=ce),ce.getTargetRaySpace()},this.getControllerGrip=function(pe){let ce=E[pe];return ce===void 0&&(ce=new WC,E[pe]=ce),ce.getGripSpace()},this.getHand=function(pe){let ce=E[pe];return ce===void 0&&(ce=new WC,E[pe]=ce),ce.getHandSpace()};function W(pe){const ce=C.indexOf(pe.inputSource);if(ce===-1)return;const Me=E[ce];Me!==void 0&&(Me.update(pe.inputSource,pe.frame,u||o),Me.dispatchEvent({type:pe.type,data:pe.inputSource}))}function Y(){i.removeEventListener("select",W),i.removeEventListener("selectstart",W),i.removeEventListener("selectend",W),i.removeEventListener("squeeze",W),i.removeEventListener("squeezestart",W),i.removeEventListener("squeezeend",W),i.removeEventListener("end",Y),i.removeEventListener("inputsourceschange",q);for(let pe=0;pe<E.length;pe++){const ce=C[pe];ce!==null&&(C[pe]=null,E[pe].disconnect(ce))}K=null,j=null,b.reset();for(const pe in v)delete v[pe];e.setRenderTarget(S),p=null,m=null,f=null,i=null,T=null,ue.stop(),r.isPresenting=!1,e.setPixelRatio(O),e.setSize(A.width,A.height,!1),r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(pe){a=pe,r.isPresenting===!0&&mn("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(pe){l=pe,r.isPresenting===!0&&mn("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return u||o},this.setReferenceSpace=function(pe){u=pe},this.getBaseLayer=function(){return m!==null?m:p},this.getBinding=function(){return f===null&&y&&(f=new XRWebGLBinding(i,n)),f},this.getFrame=function(){return x},this.getSession=function(){return i},this.setSession=async function(pe){if(i=pe,i!==null){if(S=e.getRenderTarget(),i.addEventListener("select",W),i.addEventListener("selectstart",W),i.addEventListener("selectend",W),i.addEventListener("squeeze",W),i.addEventListener("squeezestart",W),i.addEventListener("squeezeend",W),i.addEventListener("end",Y),i.addEventListener("inputsourceschange",q),N.xrCompatible!==!0&&await n.makeXRCompatible(),O=e.getPixelRatio(),e.getSize(A),y&&"createProjectionLayer"in XRWebGLBinding.prototype){let Me=null,me=null,Ee=null;N.depth&&(Ee=N.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,Me=N.stencil?L0:O0,me=N.stencil?D0:zf);const fe={colorFormat:n.RGBA8,depthFormat:Ee,scaleFactor:a};f=this.getBinding(),m=f.createProjectionLayer(fe),i.updateRenderState({layers:[m]}),e.setPixelRatio(1),e.setSize(m.textureWidth,m.textureHeight,!1),T=new $f(m.textureWidth,m.textureHeight,{format:nl,type:Gl,depthTexture:new uJ(m.textureWidth,m.textureHeight,me,void 0,void 0,void 0,void 0,void 0,void 0,Me),stencilBuffer:N.stencil,colorSpace:e.outputColorSpace,samples:N.antialias?4:0,resolveDepthBuffer:m.ignoreDepthValues===!1,resolveStencilBuffer:m.ignoreDepthValues===!1})}else{const Me={antialias:N.antialias,alpha:!0,depth:N.depth,stencil:N.stencil,framebufferScaleFactor:a};p=new XRWebGLLayer(i,n,Me),i.updateRenderState({baseLayer:p}),e.setPixelRatio(1),e.setSize(p.framebufferWidth,p.framebufferHeight,!1),T=new $f(p.framebufferWidth,p.framebufferHeight,{format:nl,type:Gl,colorSpace:e.outputColorSpace,stencilBuffer:N.stencil,resolveDepthBuffer:p.ignoreDepthValues===!1,resolveStencilBuffer:p.ignoreDepthValues===!1})}T.isXRRenderTarget=!0,this.setFoveation(c),u=null,o=await i.requestReferenceSpace(l),ue.setContext(i),ue.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return b.getDepthTexture()};function q(pe){for(let ce=0;ce<pe.removed.length;ce++){const Me=pe.removed[ce],me=C.indexOf(Me);me>=0&&(C[me]=null,E[me].disconnect(Me))}for(let ce=0;ce<pe.added.length;ce++){const Me=pe.added[ce];let me=C.indexOf(Me);if(me===-1){for(let fe=0;fe<E.length;fe++)if(fe>=C.length){C.push(Me),me=fe;break}else if(C[fe]===null){C[fe]=Me,me=fe;break}if(me===-1)break}const Ee=E[me];Ee&&Ee.connect(Me)}}const Q=new lt,ee=new lt;function re(pe,ce,Me){Q.setFromMatrixPosition(ce.matrixWorld),ee.setFromMatrixPosition(Me.matrixWorld);const me=Q.distanceTo(ee),Ee=ce.projectionMatrix.elements,fe=Me.projectionMatrix.elements,le=Ee[14]/(Ee[10]-1),Be=Ee[14]/(Ee[10]+1),V=(Ee[9]+1)/Ee[5],$=(Ee[9]-1)/Ee[5],X=(Ee[8]-1)/Ee[0],U=(fe[8]+1)/fe[0],B=le*X,oe=le*U,Te=me/(-X+U),je=Te*-X;if(ce.matrixWorld.decompose(pe.position,pe.quaternion,pe.scale),pe.translateX(je),pe.translateZ(Te),pe.matrixWorld.compose(pe.position,pe.quaternion,pe.scale),pe.matrixWorldInverse.copy(pe.matrixWorld).invert(),Ee[10]===-1)pe.projectionMatrix.copy(ce.projectionMatrix),pe.projectionMatrixInverse.copy(ce.projectionMatrixInverse);else{const Ce=le+Te,H=Be+Te,D=B-je,Z=oe+(me-je),xe=V*Be/H*Ce,Ne=$*Be/H*Ce;pe.projectionMatrix.makePerspective(D,Z,xe,Ne,Ce,H),pe.projectionMatrixInverse.copy(pe.projectionMatrix).invert()}}function z(pe,ce){ce===null?pe.matrixWorld.copy(pe.matrix):pe.matrixWorld.multiplyMatrices(ce.matrixWorld,pe.matrix),pe.matrixWorldInverse.copy(pe.matrixWorld).invert()}this.updateCamera=function(pe){if(i===null)return;let ce=pe.near,Me=pe.far;b.texture!==null&&(b.depthNear>0&&(ce=b.depthNear),b.depthFar>0&&(Me=b.depthFar)),L.near=R.near=k.near=ce,L.far=R.far=k.far=Me,(K!==L.near||j!==L.far)&&(i.updateRenderState({depthNear:L.near,depthFar:L.far}),K=L.near,j=L.far),L.layers.mask=pe.layers.mask|6,k.layers.mask=L.layers.mask&3,R.layers.mask=L.layers.mask&5;const me=pe.parent,Ee=L.cameras;z(L,me);for(let fe=0;fe<Ee.length;fe++)z(Ee[fe],me);Ee.length===2?re(L,k,R):L.projectionMatrix.copy(k.projectionMatrix),G(pe,L,me)};function G(pe,ce,Me){Me===null?pe.matrix.copy(ce.matrixWorld):(pe.matrix.copy(Me.matrixWorld),pe.matrix.invert(),pe.matrix.multiply(ce.matrixWorld)),pe.matrix.decompose(pe.position,pe.quaternion,pe.scale),pe.updateMatrixWorld(!0),pe.projectionMatrix.copy(ce.projectionMatrix),pe.projectionMatrixInverse.copy(ce.projectionMatrixInverse),pe.isPerspectiveCamera&&(pe.fov=GP*2*Math.atan(1/pe.projectionMatrix.elements[5]),pe.zoom=1)}this.getCamera=function(){return L},this.getFoveation=function(){if(!(m===null&&p===null))return c},this.setFoveation=function(pe){c=pe,m!==null&&(m.fixedFoveation=pe),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=pe)},this.hasDepthSensing=function(){return b.texture!==null},this.getDepthSensingMesh=function(){return b.getMesh(L)},this.getCameraTexture=function(pe){return v[pe]};let ae=null;function se(pe,ce){if(d=ce.getViewerPose(u||o),x=ce,d!==null){const Me=d.views;p!==null&&(e.setRenderTargetFramebuffer(T,p.framebuffer),e.setRenderTarget(T));let me=!1;Me.length!==L.cameras.length&&(L.cameras.length=0,me=!0);for(let Be=0;Be<Me.length;Be++){const V=Me[Be];let $=null;if(p!==null)$=p.getViewport(V);else{const U=f.getViewSubImage(m,V);$=U.viewport,Be===0&&(e.setRenderTargetTextures(T,U.colorTexture,U.depthStencilTexture),e.setRenderTarget(T))}let X=F[Be];X===void 0&&(X=new _o,X.layers.enable(Be),X.viewport=new _i,F[Be]=X),X.matrix.fromArray(V.transform.matrix),X.matrix.decompose(X.position,X.quaternion,X.scale),X.projectionMatrix.fromArray(V.projectionMatrix),X.projectionMatrixInverse.copy(X.projectionMatrix).invert(),X.viewport.set($.x,$.y,$.width,$.height),Be===0&&(L.matrix.copy(X.matrix),L.matrix.decompose(L.position,L.quaternion,L.scale)),me===!0&&L.cameras.push(X)}const Ee=i.enabledFeatures;if(Ee&&Ee.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&y){f=r.getBinding();const Be=f.getDepthInformation(Me[0]);Be&&Be.isValid&&Be.texture&&b.init(Be,i.renderState)}if(Ee&&Ee.includes("camera-access")&&y){e.state.unbindTexture(),f=r.getBinding();for(let Be=0;Be<Me.length;Be++){const V=Me[Be].camera;if(V){let $=v[V];$||($=new dJ,v[V]=$);const X=f.getCameraImage(V);$.sourceTexture=X}}}}for(let Me=0;Me<E.length;Me++){const me=C[Me],Ee=E[Me];me!==null&&Ee!==void 0&&Ee.update(me,ce,u||o)}ae&&ae(pe,ce),ce.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:ce}),x=null}const ue=new pJ;ue.setAnimationLoop(se),this.setAnimationLoop=function(pe){ae=pe},this.dispose=function(){}}};const Rh=new Xd,EOe=new Mi;function TOe(t,e){function n(b,v){b.matrixAutoUpdate===!0&&b.updateMatrix(),v.value.copy(b.matrix)}function r(b,v){v.color.getRGB(b.fogColor.value,sJ(t)),v.isFog?(b.fogNear.value=v.near,b.fogFar.value=v.far):v.isFogExp2&&(b.fogDensity.value=v.density)}function i(b,v,N,S,T){v.isMeshBasicMaterial||v.isMeshLambertMaterial?a(b,v):v.isMeshToonMaterial?(a(b,v),f(b,v)):v.isMeshPhongMaterial?(a(b,v),d(b,v)):v.isMeshStandardMaterial?(a(b,v),m(b,v),v.isMeshPhysicalMaterial&&p(b,v,T)):v.isMeshMatcapMaterial?(a(b,v),x(b,v)):v.isMeshDepthMaterial?a(b,v):v.isMeshDistanceMaterial?(a(b,v),y(b,v)):v.isMeshNormalMaterial?a(b,v):v.isLineBasicMaterial?(o(b,v),v.isLineDashedMaterial&&l(b,v)):v.isPointsMaterial?c(b,v,N,S):v.isSpriteMaterial?u(b,v):v.isShadowMaterial?(b.color.value.copy(v.color),b.opacity.value=v.opacity):v.isShaderMaterial&&(v.uniformsNeedUpdate=!1)}function a(b,v){b.opacity.value=v.opacity,v.color&&b.diffuse.value.copy(v.color),v.emissive&&b.emissive.value.copy(v.emissive).multiplyScalar(v.emissiveIntensity),v.map&&(b.map.value=v.map,n(v.map,b.mapTransform)),v.alphaMap&&(b.alphaMap.value=v.alphaMap,n(v.alphaMap,b.alphaMapTransform)),v.bumpMap&&(b.bumpMap.value=v.bumpMap,n(v.bumpMap,b.bumpMapTransform),b.bumpScale.value=v.bumpScale,v.side===bs&&(b.bumpScale.value*=-1)),v.normalMap&&(b.normalMap.value=v.normalMap,n(v.normalMap,b.normalMapTransform),b.normalScale.value.copy(v.normalScale),v.side===bs&&b.normalScale.value.negate()),v.displacementMap&&(b.displacementMap.value=v.displacementMap,n(v.displacementMap,b.displacementMapTransform),b.displacementScale.value=v.displacementScale,b.displacementBias.value=v.displacementBias),v.emissiveMap&&(b.emissiveMap.value=v.emissiveMap,n(v.emissiveMap,b.emissiveMapTransform)),v.specularMap&&(b.specularMap.value=v.specularMap,n(v.specularMap,b.specularMapTransform)),v.alphaTest>0&&(b.alphaTest.value=v.alphaTest);const N=e.get(v),S=N.envMap,T=N.envMapRotation;S&&(b.envMap.value=S,Rh.copy(T),Rh.x*=-1,Rh.y*=-1,Rh.z*=-1,S.isCubeTexture&&S.isRenderTargetTexture===!1&&(Rh.y*=-1,Rh.z*=-1),b.envMapRotation.value.setFromMatrix4(EOe.makeRotationFromEuler(Rh)),b.flipEnvMap.value=S.isCubeTexture&&S.isRenderTargetTexture===!1?-1:1,b.reflectivity.value=v.reflectivity,b.ior.value=v.ior,b.refractionRatio.value=v.refractionRatio),v.lightMap&&(b.lightMap.value=v.lightMap,b.lightMapIntensity.value=v.lightMapIntensity,n(v.lightMap,b.lightMapTransform)),v.aoMap&&(b.aoMap.value=v.aoMap,b.aoMapIntensity.value=v.aoMapIntensity,n(v.aoMap,b.aoMapTransform))}function o(b,v){b.diffuse.value.copy(v.color),b.opacity.value=v.opacity,v.map&&(b.map.value=v.map,n(v.map,b.mapTransform))}function l(b,v){b.dashSize.value=v.dashSize,b.totalSize.value=v.dashSize+v.gapSize,b.scale.value=v.scale}function c(b,v,N,S){b.diffuse.value.copy(v.color),b.opacity.value=v.opacity,b.size.value=v.size*N,b.scale.value=S*.5,v.map&&(b.map.value=v.map,n(v.map,b.uvTransform)),v.alphaMap&&(b.alphaMap.value=v.alphaMap,n(v.alphaMap,b.alphaMapTransform)),v.alphaTest>0&&(b.alphaTest.value=v.alphaTest)}function u(b,v){b.diffuse.value.copy(v.color),b.opacity.value=v.opacity,b.rotation.value=v.rotation,v.map&&(b.map.value=v.map,n(v.map,b.mapTransform)),v.alphaMap&&(b.alphaMap.value=v.alphaMap,n(v.alphaMap,b.alphaMapTransform)),v.alphaTest>0&&(b.alphaTest.value=v.alphaTest)}function d(b,v){b.specular.value.copy(v.specular),b.shininess.value=Math.max(v.shininess,1e-4)}function f(b,v){v.gradientMap&&(b.gradientMap.value=v.gradientMap)}function m(b,v){b.metalness.value=v.metalness,v.metalnessMap&&(b.metalnessMap.value=v.metalnessMap,n(v.metalnessMap,b.metalnessMapTransform)),b.roughness.value=v.roughness,v.roughnessMap&&(b.roughnessMap.value=v.roughnessMap,n(v.roughnessMap,b.roughnessMapTransform)),v.envMap&&(b.envMapIntensity.value=v.envMapIntensity)}function p(b,v,N){b.ior.value=v.ior,v.sheen>0&&(b.sheenColor.value.copy(v.sheenColor).multiplyScalar(v.sheen),b.sheenRoughness.value=v.sheenRoughness,v.sheenColorMap&&(b.sheenColorMap.value=v.sheenColorMap,n(v.sheenColorMap,b.sheenColorMapTransform)),v.sheenRoughnessMap&&(b.sheenRoughnessMap.value=v.sheenRoughnessMap,n(v.sheenRoughnessMap,b.sheenRoughnessMapTransform))),v.clearcoat>0&&(b.clearcoat.value=v.clearcoat,b.clearcoatRoughness.value=v.clearcoatRoughness,v.clearcoatMap&&(b.clearcoatMap.value=v.clearcoatMap,n(v.clearcoatMap,b.clearcoatMapTransform)),v.clearcoatRoughnessMap&&(b.clearcoatRoughnessMap.value=v.clearcoatRoughnessMap,n(v.clearcoatRoughnessMap,b.clearcoatRoughnessMapTransform)),v.clearcoatNormalMap&&(b.clearcoatNormalMap.value=v.clearcoatNormalMap,n(v.clearcoatNormalMap,b.clearcoatNormalMapTransform),b.clearcoatNormalScale.value.copy(v.clearcoatNormalScale),v.side===bs&&b.clearcoatNormalScale.value.negate())),v.dispersion>0&&(b.dispersion.value=v.dispersion),v.iridescence>0&&(b.iridescence.value=v.iridescence,b.iridescenceIOR.value=v.iridescenceIOR,b.iridescenceThicknessMinimum.value=v.iridescenceThicknessRange[0],b.iridescenceThicknessMaximum.value=v.iridescenceThicknessRange[1],v.iridescenceMap&&(b.iridescenceMap.value=v.iridescenceMap,n(v.iridescenceMap,b.iridescenceMapTransform)),v.iridescenceThicknessMap&&(b.iridescenceThicknessMap.value=v.iridescenceThicknessMap,n(v.iridescenceThicknessMap,b.iridescenceThicknessMapTransform))),v.transmission>0&&(b.transmission.value=v.transmission,b.transmissionSamplerMap.value=N.texture,b.transmissionSamplerSize.value.set(N.width,N.height),v.transmissionMap&&(b.transmissionMap.value=v.transmissionMap,n(v.transmissionMap,b.transmissionMapTransform)),b.thickness.value=v.thickness,v.thicknessMap&&(b.thicknessMap.value=v.thicknessMap,n(v.thicknessMap,b.thicknessMapTransform)),b.attenuationDistance.value=v.attenuationDistance,b.attenuationColor.value.copy(v.attenuationColor)),v.anisotropy>0&&(b.anisotropyVector.value.set(v.anisotropy*Math.cos(v.anisotropyRotation),v.anisotropy*Math.sin(v.anisotropyRotation)),v.anisotropyMap&&(b.anisotropyMap.value=v.anisotropyMap,n(v.anisotropyMap,b.anisotropyMapTransform))),b.specularIntensity.value=v.specularIntensity,b.specularColor.value.copy(v.specularColor),v.specularColorMap&&(b.specularColorMap.value=v.specularColorMap,n(v.specularColorMap,b.specularColorMapTransform)),v.specularIntensityMap&&(b.specularIntensityMap.value=v.specularIntensityMap,n(v.specularIntensityMap,b.specularIntensityMapTransform))}function x(b,v){v.matcap&&(b.matcap.value=v.matcap)}function y(b,v){const N=e.get(v).light;b.referencePosition.value.setFromMatrixPosition(N.matrixWorld),b.nearDistance.value=N.shadow.camera.near,b.farDistance.value=N.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function AOe(t,e,n,r){let i={},a={},o=[];const l=t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS);function c(N,S){const T=S.program;r.uniformBlockBinding(N,T)}function u(N,S){let T=i[N.id];T===void 0&&(x(N),T=d(N),i[N.id]=T,N.addEventListener("dispose",b));const E=S.program;r.updateUBOMapping(N,E);const C=e.render.frame;a[N.id]!==C&&(m(N),a[N.id]=C)}function d(N){const S=f();N.__bindingPointIndex=S;const T=t.createBuffer(),E=N.__size,C=N.usage;return t.bindBuffer(t.UNIFORM_BUFFER,T),t.bufferData(t.UNIFORM_BUFFER,E,C),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,S,T),T}function f(){for(let N=0;N<l;N++)if(o.indexOf(N)===-1)return o.push(N),N;return ui("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function m(N){const S=i[N.id],T=N.uniforms,E=N.__cache;t.bindBuffer(t.UNIFORM_BUFFER,S);for(let C=0,A=T.length;C<A;C++){const O=Array.isArray(T[C])?T[C]:[T[C]];for(let k=0,R=O.length;k<R;k++){const F=O[k];if(p(F,C,k,E)===!0){const L=F.__offset,K=Array.isArray(F.value)?F.value:[F.value];let j=0;for(let W=0;W<K.length;W++){const Y=K[W],q=y(Y);typeof Y=="number"||typeof Y=="boolean"?(F.__data[0]=Y,t.bufferSubData(t.UNIFORM_BUFFER,L+j,F.__data)):Y.isMatrix3?(F.__data[0]=Y.elements[0],F.__data[1]=Y.elements[1],F.__data[2]=Y.elements[2],F.__data[3]=0,F.__data[4]=Y.elements[3],F.__data[5]=Y.elements[4],F.__data[6]=Y.elements[5],F.__data[7]=0,F.__data[8]=Y.elements[6],F.__data[9]=Y.elements[7],F.__data[10]=Y.elements[8],F.__data[11]=0):(Y.toArray(F.__data,j),j+=q.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,L,F.__data)}}}t.bindBuffer(t.UNIFORM_BUFFER,null)}function p(N,S,T,E){const C=N.value,A=S+"_"+T;if(E[A]===void 0)return typeof C=="number"||typeof C=="boolean"?E[A]=C:E[A]=C.clone(),!0;{const O=E[A];if(typeof C=="number"||typeof C=="boolean"){if(O!==C)return E[A]=C,!0}else if(O.equals(C)===!1)return O.copy(C),!0}return!1}function x(N){const S=N.uniforms;let T=0;const E=16;for(let A=0,O=S.length;A<O;A++){const k=Array.isArray(S[A])?S[A]:[S[A]];for(let R=0,F=k.length;R<F;R++){const L=k[R],K=Array.isArray(L.value)?L.value:[L.value];for(let j=0,W=K.length;j<W;j++){const Y=K[j],q=y(Y),Q=T%E,ee=Q%q.boundary,re=Q+ee;T+=ee,re!==0&&E-re<q.storage&&(T+=E-re),L.__data=new Float32Array(q.storage/Float32Array.BYTES_PER_ELEMENT),L.__offset=T,T+=q.storage}}}const C=T%E;return C>0&&(T+=E-C),N.__size=T,N.__cache={},this}function y(N){const S={boundary:0,storage:0};return typeof N=="number"||typeof N=="boolean"?(S.boundary=4,S.storage=4):N.isVector2?(S.boundary=8,S.storage=8):N.isVector3||N.isColor?(S.boundary=16,S.storage=12):N.isVector4?(S.boundary=16,S.storage=16):N.isMatrix3?(S.boundary=48,S.storage=48):N.isMatrix4?(S.boundary=64,S.storage=64):N.isTexture?mn("WebGLRenderer: Texture samplers can not be part of an uniforms group."):mn("WebGLRenderer: Unsupported uniform value type.",N),S}function b(N){const S=N.target;S.removeEventListener("dispose",b);const T=o.indexOf(S.__bindingPointIndex);o.splice(T,1),t.deleteBuffer(i[S.id]),delete i[S.id],delete a[S.id]}function v(){for(const N in i)t.deleteBuffer(i[N]);o=[],i={},a={}}return{bind:c,update:u,dispose:v}}const COe=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 Nc=null;function kOe(){return Nc===null&&(Nc=new k3e(COe,32,32,EO,Zg),Nc.minFilter=To,Nc.magFilter=To,Nc.wrapS=Wc,Nc.wrapT=Wc,Nc.generateMipmaps=!1,Nc.needsUpdate=!0),Nc}let jOe=class{constructor(e={}){const{canvas:n=t3e(),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:m=!1}=e;this.isWebGLRenderer=!0;let p;if(r!==null){if(typeof WebGLRenderingContext<"u"&&r instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");p=r.getContextAttributes().alpha}else p=o;const x=new Set([AO,TO,MO]),y=new Set([Gl,zf,R0,D0,SO,NO]),b=new Uint32Array(4),v=new Int32Array(4);let N=null,S=null;const T=[],E=[];this.domElement=n,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=Rd,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const C=this;let A=!1;this._outputColorSpace=bo;let O=0,k=0,R=null,F=-1,L=null;const K=new _i,j=new _i;let W=null;const Y=new Dn(0);let q=0,Q=n.width,ee=n.height,re=1,z=null,G=null;const ae=new _i(0,0,Q,ee),se=new _i(0,0,Q,ee);let ue=!1;const pe=new RO;let ce=!1,Me=!1;const me=new Mi,Ee=new lt,fe=new _i,le={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Be=!1;function V(){return R===null?re:1}let $=r;function X(de,Re){return n.getContext(de,Re)}try{const de={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${vO}`),n.addEventListener("webglcontextlost",Ue,!1),n.addEventListener("webglcontextrestored",Ae,!1),n.addEventListener("webglcontextcreationerror",Je,!1),$===null){const Re="webgl2";if($=X(Re,de),$===null)throw X(Re)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(de){throw de("WebGLRenderer: "+de.message),de}let U,B,oe,Te,je,Ce,H,D,Z,xe,Ne,ve,$e,Le,qe,Ke,Ye,ie,te,Se,ze,nt,ne,Pe;function be(){U=new UDe($),U.init(),nt=new _Oe($,U),B=new kDe($,U,e,nt),oe=new yOe($,U),B.reversedDepthBuffer&&m&&oe.buffers.depth.setReversed(!0),Te=new $De($),je=new sOe,Ce=new vOe($,U,oe,je,B,nt,Te),H=new PDe(C),D=new FDe(C),Z=new W3e($),ne=new ADe($,Z),xe=new zDe($,Z,Te,ne),Ne=new VDe($,xe,Z,Te),te=new HDe($,B,Ce),Ke=new jDe(je),ve=new aOe(C,H,D,U,B,ne,Ke),$e=new TOe(C,je),Le=new lOe,qe=new mOe(U),ie=new TDe(C,H,D,oe,Ne,p,c),Ye=new xOe(C,Ne,B),Pe=new AOe($,Te,B,oe),Se=new CDe($,U,Te),ze=new BDe($,U,Te),Te.programs=ve.programs,C.capabilities=B,C.extensions=U,C.properties=je,C.renderLists=Le,C.shadowMap=Ye,C.state=oe,C.info=Te}be();const Oe=new MOe(C,$);this.xr=Oe,this.getContext=function(){return $},this.getContextAttributes=function(){return $.getContextAttributes()},this.forceContextLoss=function(){const de=U.get("WEBGL_lose_context");de&&de.loseContext()},this.forceContextRestore=function(){const de=U.get("WEBGL_lose_context");de&&de.restoreContext()},this.getPixelRatio=function(){return re},this.setPixelRatio=function(de){de!==void 0&&(re=de,this.setSize(Q,ee,!1))},this.getSize=function(de){return de.set(Q,ee)},this.setSize=function(de,Re,Ve=!0){if(Oe.isPresenting){mn("WebGLRenderer: Can't change size while VR device is presenting.");return}Q=de,ee=Re,n.width=Math.floor(de*re),n.height=Math.floor(Re*re),Ve===!0&&(n.style.width=de+"px",n.style.height=Re+"px"),this.setViewport(0,0,de,Re)},this.getDrawingBufferSize=function(de){return de.set(Q*re,ee*re).floor()},this.setDrawingBufferSize=function(de,Re,Ve){Q=de,ee=Re,re=Ve,n.width=Math.floor(de*Ve),n.height=Math.floor(Re*Ve),this.setViewport(0,0,de,Re)},this.getCurrentViewport=function(de){return de.copy(K)},this.getViewport=function(de){return de.copy(ae)},this.setViewport=function(de,Re,Ve,He){de.isVector4?ae.set(de.x,de.y,de.z,de.w):ae.set(de,Re,Ve,He),oe.viewport(K.copy(ae).multiplyScalar(re).round())},this.getScissor=function(de){return de.copy(se)},this.setScissor=function(de,Re,Ve,He){de.isVector4?se.set(de.x,de.y,de.z,de.w):se.set(de,Re,Ve,He),oe.scissor(j.copy(se).multiplyScalar(re).round())},this.getScissorTest=function(){return ue},this.setScissorTest=function(de){oe.setScissorTest(ue=de)},this.setOpaqueSort=function(de){z=de},this.setTransparentSort=function(de){G=de},this.getClearColor=function(de){return de.copy(ie.getClearColor())},this.setClearColor=function(){ie.setClearColor(...arguments)},this.getClearAlpha=function(){return ie.getClearAlpha()},this.setClearAlpha=function(){ie.setClearAlpha(...arguments)},this.clear=function(de=!0,Re=!0,Ve=!0){let He=0;if(de){let Fe=!1;if(R!==null){const mt=R.texture.format;Fe=x.has(mt)}if(Fe){const mt=R.texture.type,St=y.has(mt),kt=ie.getClearColor(),xt=ie.getClearAlpha(),$t=kt.r,jt=kt.g,wt=kt.b;St?(b[0]=$t,b[1]=jt,b[2]=wt,b[3]=xt,$.clearBufferuiv($.COLOR,0,b)):(v[0]=$t,v[1]=jt,v[2]=wt,v[3]=xt,$.clearBufferiv($.COLOR,0,v))}else He|=$.COLOR_BUFFER_BIT}Re&&(He|=$.DEPTH_BUFFER_BIT),Ve&&(He|=$.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),$.clear(He)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){n.removeEventListener("webglcontextlost",Ue,!1),n.removeEventListener("webglcontextrestored",Ae,!1),n.removeEventListener("webglcontextcreationerror",Je,!1),ie.dispose(),Le.dispose(),qe.dispose(),je.dispose(),H.dispose(),D.dispose(),Ne.dispose(),ne.dispose(),Pe.dispose(),ve.dispose(),Oe.dispose(),Oe.removeEventListener("sessionstart",bt),Oe.removeEventListener("sessionend",Gt),ln.stop()};function Ue(de){de.preventDefault(),yH("WebGLRenderer: Context Lost."),A=!0}function Ae(){yH("WebGLRenderer: Context Restored."),A=!1;const de=Te.autoReset,Re=Ye.enabled,Ve=Ye.autoUpdate,He=Ye.needsUpdate,Fe=Ye.type;be(),Te.autoReset=de,Ye.enabled=Re,Ye.autoUpdate=Ve,Ye.needsUpdate=He,Ye.type=Fe}function Je(de){ui("WebGLRenderer: A WebGL context could not be created. Reason: ",de.statusMessage)}function gt(de){const Re=de.target;Re.removeEventListener("dispose",gt),Pt(Re)}function Pt(de){Ot(de),je.remove(de)}function Ot(de){const Re=je.get(de).programs;Re!==void 0&&(Re.forEach(function(Ve){ve.releaseProgram(Ve)}),de.isShaderMaterial&&ve.releaseShaderCache(de))}this.renderBufferDirect=function(de,Re,Ve,He,Fe,mt){Re===null&&(Re=le);const St=Fe.isMesh&&Fe.matrixWorld.determinant()<0,kt=_e(de,Re,Ve,He,Fe);oe.setMaterial(He,St);let xt=Ve.index,$t=1;if(He.wireframe===!0){if(xt=xe.getWireframeAttribute(Ve),xt===void 0)return;$t=2}const jt=Ve.drawRange,wt=Ve.attributes.position;let Qt=jt.start*$t,Kt=(jt.start+jt.count)*$t;mt!==null&&(Qt=Math.max(Qt,mt.start*$t),Kt=Math.min(Kt,(mt.start+mt.count)*$t)),xt!==null?(Qt=Math.max(Qt,0),Kt=Math.min(Kt,xt.count)):wt!=null&&(Qt=Math.max(Qt,0),Kt=Math.min(Kt,wt.count));const fn=Kt-Qt;if(fn<0||fn===1/0)return;ne.setup(Fe,He,kt,Ve,xt);let ye,De=Se;if(xt!==null&&(ye=Z.get(xt),De=ze,De.setIndex(ye)),Fe.isMesh)He.wireframe===!0?(oe.setLineWidth(He.wireframeLinewidth*V()),De.setMode($.LINES)):De.setMode($.TRIANGLES);else if(Fe.isLine){let ht=He.linewidth;ht===void 0&&(ht=1),oe.setLineWidth(ht*V()),Fe.isLineSegments?De.setMode($.LINES):Fe.isLineLoop?De.setMode($.LINE_LOOP):De.setMode($.LINE_STRIP)}else Fe.isPoints?De.setMode($.POINTS):Fe.isSprite&&De.setMode($.TRIANGLES);if(Fe.isBatchedMesh)if(Fe._multiDrawInstances!==null)I0("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),De.renderMultiDrawInstances(Fe._multiDrawStarts,Fe._multiDrawCounts,Fe._multiDrawCount,Fe._multiDrawInstances);else if(U.get("WEBGL_multi_draw"))De.renderMultiDraw(Fe._multiDrawStarts,Fe._multiDrawCounts,Fe._multiDrawCount);else{const ht=Fe._multiDrawStarts,Mt=Fe._multiDrawCounts,at=Fe._multiDrawCount,Xt=xt?Z.get(xt).bytesPerElement:1,Yt=je.get(He).currentProgram.getUniforms();for(let rn=0;rn<at;rn++)Yt.setValue($,"_gl_DrawID",rn),De.render(ht[rn]/Xt,Mt[rn])}else if(Fe.isInstancedMesh)De.renderInstances(Qt,fn,Fe.count);else if(Ve.isInstancedBufferGeometry){const ht=Ve._maxInstanceCount!==void 0?Ve._maxInstanceCount:1/0,Mt=Math.min(Ve.instanceCount,ht);De.renderInstances(Qt,fn,Mt)}else De.render(Qt,fn)};function cn(de,Re,Ve){de.transparent===!0&&de.side===Cl&&de.forceSinglePass===!1?(de.side=bs,de.needsUpdate=!0,Sr(de,Re,Ve),de.side=Kd,de.needsUpdate=!0,Sr(de,Re,Ve),de.side=Cl):Sr(de,Re,Ve)}this.compile=function(de,Re,Ve=null){Ve===null&&(Ve=de),S=qe.get(Ve),S.init(Re),E.push(S),Ve.traverseVisible(function(Fe){Fe.isLight&&Fe.layers.test(Re.layers)&&(S.pushLight(Fe),Fe.castShadow&&S.pushShadow(Fe))}),de!==Ve&&de.traverseVisible(function(Fe){Fe.isLight&&Fe.layers.test(Re.layers)&&(S.pushLight(Fe),Fe.castShadow&&S.pushShadow(Fe))}),S.setupLights();const He=new Set;return de.traverse(function(Fe){if(!(Fe.isMesh||Fe.isPoints||Fe.isLine||Fe.isSprite))return;const mt=Fe.material;if(mt)if(Array.isArray(mt))for(let St=0;St<mt.length;St++){const kt=mt[St];cn(kt,Ve,Fe),He.add(kt)}else cn(mt,Ve,Fe),He.add(mt)}),S=E.pop(),He},this.compileAsync=function(de,Re,Ve=null){const He=this.compile(de,Re,Ve);return new Promise(Fe=>{function mt(){if(He.forEach(function(St){je.get(St).currentProgram.isReady()&&He.delete(St)}),He.size===0){Fe(de);return}setTimeout(mt,10)}U.get("KHR_parallel_shader_compile")!==null?mt():setTimeout(mt,10)})};let It=null;function _n(de){It&&It(de)}function bt(){ln.stop()}function Gt(){ln.start()}const ln=new pJ;ln.setAnimationLoop(_n),typeof self<"u"&&ln.setContext(self),this.setAnimationLoop=function(de){It=de,Oe.setAnimationLoop(de),de===null?ln.stop():ln.start()},Oe.addEventListener("sessionstart",bt),Oe.addEventListener("sessionend",Gt),this.render=function(de,Re){if(Re!==void 0&&Re.isCamera!==!0){ui("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(A===!0)return;if(de.matrixWorldAutoUpdate===!0&&de.updateMatrixWorld(),Re.parent===null&&Re.matrixWorldAutoUpdate===!0&&Re.updateMatrixWorld(),Oe.enabled===!0&&Oe.isPresenting===!0&&(Oe.cameraAutoUpdate===!0&&Oe.updateCamera(Re),Re=Oe.getCamera()),de.isScene===!0&&de.onBeforeRender(C,de,Re,R),S=qe.get(de,E.length),S.init(Re),E.push(S),me.multiplyMatrices(Re.projectionMatrix,Re.matrixWorldInverse),pe.setFromProjectionMatrix(me,Rl,Re.reversedDepth),Me=this.localClippingEnabled,ce=Ke.init(this.clippingPlanes,Me),N=Le.get(de,T.length),N.init(),T.push(N),Oe.enabled===!0&&Oe.isPresenting===!0){const mt=C.xr.getDepthSensingMesh();mt!==null&&Tt(mt,Re,-1/0,C.sortObjects)}Tt(de,Re,0,C.sortObjects),N.finish(),C.sortObjects===!0&&N.sort(z,G),Be=Oe.enabled===!1||Oe.isPresenting===!1||Oe.hasDepthSensing()===!1,Be&&ie.addToRenderList(N,de),this.info.render.frame++,ce===!0&&Ke.beginShadows();const Ve=S.state.shadowsArray;Ye.render(Ve,de,Re),ce===!0&&Ke.endShadows(),this.info.autoReset===!0&&this.info.reset();const He=N.opaque,Fe=N.transmissive;if(S.setupLights(),Re.isArrayCamera){const mt=Re.cameras;if(Fe.length>0)for(let St=0,kt=mt.length;St<kt;St++){const xt=mt[St];Xr(He,Fe,de,xt)}Be&&ie.render(de);for(let St=0,kt=mt.length;St<kt;St++){const xt=mt[St];Rr(N,de,xt,xt.viewport)}}else Fe.length>0&&Xr(He,Fe,de,Re),Be&&ie.render(de),Rr(N,de,Re);R!==null&&k===0&&(Ce.updateMultisampleRenderTarget(R),Ce.updateRenderTargetMipmap(R)),de.isScene===!0&&de.onAfterRender(C,de,Re),ne.resetDefaultState(),F=-1,L=null,E.pop(),E.length>0?(S=E[E.length-1],ce===!0&&Ke.setGlobalState(C.clippingPlanes,S.state.camera)):S=null,T.pop(),T.length>0?N=T[T.length-1]:N=null};function Tt(de,Re,Ve,He){if(de.visible===!1)return;if(de.layers.test(Re.layers)){if(de.isGroup)Ve=de.renderOrder;else if(de.isLOD)de.autoUpdate===!0&&de.update(Re);else if(de.isLight)S.pushLight(de),de.castShadow&&S.pushShadow(de);else if(de.isSprite){if(!de.frustumCulled||pe.intersectsSprite(de)){He&&fe.setFromMatrixPosition(de.matrixWorld).applyMatrix4(me);const St=Ne.update(de),kt=de.material;kt.visible&&N.push(de,St,kt,Ve,fe.z,null)}}else if((de.isMesh||de.isLine||de.isPoints)&&(!de.frustumCulled||pe.intersectsObject(de))){const St=Ne.update(de),kt=de.material;if(He&&(de.boundingSphere!==void 0?(de.boundingSphere===null&&de.computeBoundingSphere(),fe.copy(de.boundingSphere.center)):(St.boundingSphere===null&&St.computeBoundingSphere(),fe.copy(St.boundingSphere.center)),fe.applyMatrix4(de.matrixWorld).applyMatrix4(me)),Array.isArray(kt)){const xt=St.groups;for(let $t=0,jt=xt.length;$t<jt;$t++){const wt=xt[$t],Qt=kt[wt.materialIndex];Qt&&Qt.visible&&N.push(de,St,Qt,Ve,fe.z,wt)}}else kt.visible&&N.push(de,St,kt,Ve,fe.z,null)}}const mt=de.children;for(let St=0,kt=mt.length;St<kt;St++)Tt(mt[St],Re,Ve,He)}function Rr(de,Re,Ve,He){const{opaque:Fe,transmissive:mt,transparent:St}=de;S.setupLightsView(Ve),ce===!0&&Ke.setGlobalState(C.clippingPlanes,Ve),He&&oe.viewport(K.copy(He)),Fe.length>0&&An(Fe,Re,Ve),mt.length>0&&An(mt,Re,Ve),St.length>0&&An(St,Re,Ve),oe.buffers.depth.setTest(!0),oe.buffers.depth.setMask(!0),oe.buffers.color.setMask(!0),oe.setPolygonOffset(!1)}function Xr(de,Re,Ve,He){if((Ve.isScene===!0?Ve.overrideMaterial:null)!==null)return;S.state.transmissionRenderTarget[He.id]===void 0&&(S.state.transmissionRenderTarget[He.id]=new $f(1,1,{generateMipmaps:!0,type:U.has("EXT_color_buffer_half_float")||U.has("EXT_color_buffer_float")?Zg:Gl,minFilter:rf,samples:4,stencilBuffer:a,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:qn.workingColorSpace}));const mt=S.state.transmissionRenderTarget[He.id],St=He.viewport||K;mt.setSize(St.z*C.transmissionResolutionScale,St.w*C.transmissionResolutionScale);const kt=C.getRenderTarget(),xt=C.getActiveCubeFace(),$t=C.getActiveMipmapLevel();C.setRenderTarget(mt),C.getClearColor(Y),q=C.getClearAlpha(),q<1&&C.setClearColor(16777215,.5),C.clear(),Be&&ie.render(Ve);const jt=C.toneMapping;C.toneMapping=Rd;const wt=He.viewport;if(He.viewport!==void 0&&(He.viewport=void 0),S.setupLightsView(He),ce===!0&&Ke.setGlobalState(C.clippingPlanes,He),An(de,Ve,He),Ce.updateMultisampleRenderTarget(mt),Ce.updateRenderTargetMipmap(mt),U.has("WEBGL_multisampled_render_to_texture")===!1){let Qt=!1;for(let Kt=0,fn=Re.length;Kt<fn;Kt++){const ye=Re[Kt],{object:De,geometry:ht,material:Mt,group:at}=ye;if(Mt.side===Cl&&De.layers.test(He.layers)){const Xt=Mt.side;Mt.side=bs,Mt.needsUpdate=!0,sn(De,Ve,He,ht,Mt,at),Mt.side=Xt,Mt.needsUpdate=!0,Qt=!0}}Qt===!0&&(Ce.updateMultisampleRenderTarget(mt),Ce.updateRenderTargetMipmap(mt))}C.setRenderTarget(kt,xt,$t),C.setClearColor(Y,q),wt!==void 0&&(He.viewport=wt),C.toneMapping=jt}function An(de,Re,Ve){const He=Re.isScene===!0?Re.overrideMaterial:null;for(let Fe=0,mt=de.length;Fe<mt;Fe++){const St=de[Fe],{object:kt,geometry:xt,group:$t}=St;let jt=St.material;jt.allowOverride===!0&&He!==null&&(jt=He),kt.layers.test(Ve.layers)&&sn(kt,Re,Ve,xt,jt,$t)}}function sn(de,Re,Ve,He,Fe,mt){de.onBeforeRender(C,Re,Ve,He,Fe,mt),de.modelViewMatrix.multiplyMatrices(Ve.matrixWorldInverse,de.matrixWorld),de.normalMatrix.getNormalMatrix(de.modelViewMatrix),Fe.onBeforeRender(C,Re,Ve,He,de,mt),Fe.transparent===!0&&Fe.side===Cl&&Fe.forceSinglePass===!1?(Fe.side=bs,Fe.needsUpdate=!0,C.renderBufferDirect(Ve,Re,He,Fe,de,mt),Fe.side=Kd,Fe.needsUpdate=!0,C.renderBufferDirect(Ve,Re,He,Fe,de,mt),Fe.side=Cl):C.renderBufferDirect(Ve,Re,He,Fe,de,mt),de.onAfterRender(C,Re,Ve,He,Fe,mt)}function Sr(de,Re,Ve){Re.isScene!==!0&&(Re=le);const He=je.get(de),Fe=S.state.lights,mt=S.state.shadowsArray,St=Fe.state.version,kt=ve.getParameters(de,Fe.state,mt,Re,Ve),xt=ve.getProgramCacheKey(kt);let $t=He.programs;He.environment=de.isMeshStandardMaterial?Re.environment:null,He.fog=Re.fog,He.envMap=(de.isMeshStandardMaterial?D:H).get(de.envMap||He.environment),He.envMapRotation=He.environment!==null&&de.envMap===null?Re.environmentRotation:de.envMapRotation,$t===void 0&&(de.addEventListener("dispose",gt),$t=new Map,He.programs=$t);let jt=$t.get(xt);if(jt!==void 0){if(He.currentProgram===jt&&He.lightsStateVersion===St)return Dr(de,kt),jt}else kt.uniforms=ve.getUniforms(de),de.onBeforeCompile(kt,C),jt=ve.acquireProgram(kt,xt),$t.set(xt,jt),He.uniforms=kt.uniforms;const wt=He.uniforms;return(!de.isShaderMaterial&&!de.isRawShaderMaterial||de.clipping===!0)&&(wt.clippingPlanes=Ke.uniform),Dr(de,kt),He.needsLights=ot(de),He.lightsStateVersion=St,He.needsLights&&(wt.ambientLightColor.value=Fe.state.ambient,wt.lightProbe.value=Fe.state.probe,wt.directionalLights.value=Fe.state.directional,wt.directionalLightShadows.value=Fe.state.directionalShadow,wt.spotLights.value=Fe.state.spot,wt.spotLightShadows.value=Fe.state.spotShadow,wt.rectAreaLights.value=Fe.state.rectArea,wt.ltc_1.value=Fe.state.rectAreaLTC1,wt.ltc_2.value=Fe.state.rectAreaLTC2,wt.pointLights.value=Fe.state.point,wt.pointLightShadows.value=Fe.state.pointShadow,wt.hemisphereLights.value=Fe.state.hemi,wt.directionalShadowMap.value=Fe.state.directionalShadowMap,wt.directionalShadowMatrix.value=Fe.state.directionalShadowMatrix,wt.spotShadowMap.value=Fe.state.spotShadowMap,wt.spotLightMatrix.value=Fe.state.spotLightMatrix,wt.spotLightMap.value=Fe.state.spotLightMap,wt.pointShadowMap.value=Fe.state.pointShadowMap,wt.pointShadowMatrix.value=Fe.state.pointShadowMatrix),He.currentProgram=jt,He.uniformsList=null,jt}function si(de){if(de.uniformsList===null){const Re=de.currentProgram.getUniforms();de.uniformsList=nw.seqWithValue(Re.seq,de.uniforms)}return de.uniformsList}function Dr(de,Re){const Ve=je.get(de);Ve.outputColorSpace=Re.outputColorSpace,Ve.batching=Re.batching,Ve.batchingColor=Re.batchingColor,Ve.instancing=Re.instancing,Ve.instancingColor=Re.instancingColor,Ve.instancingMorph=Re.instancingMorph,Ve.skinning=Re.skinning,Ve.morphTargets=Re.morphTargets,Ve.morphNormals=Re.morphNormals,Ve.morphColors=Re.morphColors,Ve.morphTargetsCount=Re.morphTargetsCount,Ve.numClippingPlanes=Re.numClippingPlanes,Ve.numIntersection=Re.numClipIntersection,Ve.vertexAlphas=Re.vertexAlphas,Ve.vertexTangents=Re.vertexTangents,Ve.toneMapping=Re.toneMapping}function _e(de,Re,Ve,He,Fe){Re.isScene!==!0&&(Re=le),Ce.resetTextureUnits();const mt=Re.fog,St=He.isMeshStandardMaterial?Re.environment:null,kt=R===null?C.outputColorSpace:R.isXRRenderTarget===!0?R.texture.colorSpace:yg,xt=(He.isMeshStandardMaterial?D:H).get(He.envMap||St),$t=He.vertexColors===!0&&!!Ve.attributes.color&&Ve.attributes.color.itemSize===4,jt=!!Ve.attributes.tangent&&(!!He.normalMap||He.anisotropy>0),wt=!!Ve.morphAttributes.position,Qt=!!Ve.morphAttributes.normal,Kt=!!Ve.morphAttributes.color;let fn=Rd;He.toneMapped&&(R===null||R.isXRRenderTarget===!0)&&(fn=C.toneMapping);const ye=Ve.morphAttributes.position||Ve.morphAttributes.normal||Ve.morphAttributes.color,De=ye!==void 0?ye.length:0,ht=je.get(He),Mt=S.state.lights;if(ce===!0&&(Me===!0||de!==L)){const or=de===L&&He.id===F;Ke.setState(He,de,or)}let at=!1;He.version===ht.__version?(ht.needsLights&&ht.lightsStateVersion!==Mt.state.version||ht.outputColorSpace!==kt||Fe.isBatchedMesh&&ht.batching===!1||!Fe.isBatchedMesh&&ht.batching===!0||Fe.isBatchedMesh&&ht.batchingColor===!0&&Fe.colorTexture===null||Fe.isBatchedMesh&&ht.batchingColor===!1&&Fe.colorTexture!==null||Fe.isInstancedMesh&&ht.instancing===!1||!Fe.isInstancedMesh&&ht.instancing===!0||Fe.isSkinnedMesh&&ht.skinning===!1||!Fe.isSkinnedMesh&&ht.skinning===!0||Fe.isInstancedMesh&&ht.instancingColor===!0&&Fe.instanceColor===null||Fe.isInstancedMesh&&ht.instancingColor===!1&&Fe.instanceColor!==null||Fe.isInstancedMesh&&ht.instancingMorph===!0&&Fe.morphTexture===null||Fe.isInstancedMesh&&ht.instancingMorph===!1&&Fe.morphTexture!==null||ht.envMap!==xt||He.fog===!0&&ht.fog!==mt||ht.numClippingPlanes!==void 0&&(ht.numClippingPlanes!==Ke.numPlanes||ht.numIntersection!==Ke.numIntersection)||ht.vertexAlphas!==$t||ht.vertexTangents!==jt||ht.morphTargets!==wt||ht.morphNormals!==Qt||ht.morphColors!==Kt||ht.toneMapping!==fn||ht.morphTargetsCount!==De)&&(at=!0):(at=!0,ht.__version=He.version);let Xt=ht.currentProgram;at===!0&&(Xt=Sr(He,Re,Fe));let Yt=!1,rn=!1,sr=!1;const kn=Xt.getUniforms(),Wt=ht.uniforms;if(oe.useProgram(Xt.program)&&(Yt=!0,rn=!0,sr=!0),He.id!==F&&(F=He.id,rn=!0),Yt||L!==de){oe.buffers.depth.getReversed()&&de.reversedDepth!==!0&&(de._reversedDepth=!0,de.updateProjectionMatrix()),kn.setValue($,"projectionMatrix",de.projectionMatrix),kn.setValue($,"viewMatrix",de.matrixWorldInverse);const Or=kn.map.cameraPosition;Or!==void 0&&Or.setValue($,Ee.setFromMatrixPosition(de.matrixWorld)),B.logarithmicDepthBuffer&&kn.setValue($,"logDepthBufFC",2/(Math.log(de.far+1)/Math.LN2)),(He.isMeshPhongMaterial||He.isMeshToonMaterial||He.isMeshLambertMaterial||He.isMeshBasicMaterial||He.isMeshStandardMaterial||He.isShaderMaterial)&&kn.setValue($,"isOrthographic",de.isOrthographicCamera===!0),L!==de&&(L=de,rn=!0,sr=!0)}if(Fe.isSkinnedMesh){kn.setOptional($,Fe,"bindMatrix"),kn.setOptional($,Fe,"bindMatrixInverse");const or=Fe.skeleton;or&&(or.boneTexture===null&&or.computeBoneTexture(),kn.setValue($,"boneTexture",or.boneTexture,Ce))}Fe.isBatchedMesh&&(kn.setOptional($,Fe,"batchingTexture"),kn.setValue($,"batchingTexture",Fe._matricesTexture,Ce),kn.setOptional($,Fe,"batchingIdTexture"),kn.setValue($,"batchingIdTexture",Fe._indirectTexture,Ce),kn.setOptional($,Fe,"batchingColorTexture"),Fe._colorsTexture!==null&&kn.setValue($,"batchingColorTexture",Fe._colorsTexture,Ce));const en=Ve.morphAttributes;if((en.position!==void 0||en.normal!==void 0||en.color!==void 0)&&te.update(Fe,Ve,Xt),(rn||ht.receiveShadow!==Fe.receiveShadow)&&(ht.receiveShadow=Fe.receiveShadow,kn.setValue($,"receiveShadow",Fe.receiveShadow)),He.isMeshGouraudMaterial&&He.envMap!==null&&(Wt.envMap.value=xt,Wt.flipEnvMap.value=xt.isCubeTexture&&xt.isRenderTargetTexture===!1?-1:1),He.isMeshStandardMaterial&&He.envMap===null&&Re.environment!==null&&(Wt.envMapIntensity.value=Re.environmentIntensity),Wt.dfgLUT!==void 0&&(Wt.dfgLUT.value=kOe()),rn&&(kn.setValue($,"toneMappingExposure",C.toneMappingExposure),ht.needsLights&&Xe(Wt,sr),mt&&He.fog===!0&&$e.refreshFogUniforms(Wt,mt),$e.refreshMaterialUniforms(Wt,He,re,ee,S.state.transmissionRenderTarget[de.id]),nw.upload($,si(ht),Wt,Ce)),He.isShaderMaterial&&He.uniformsNeedUpdate===!0&&(nw.upload($,si(ht),Wt,Ce),He.uniformsNeedUpdate=!1),He.isSpriteMaterial&&kn.setValue($,"center",Fe.center),kn.setValue($,"modelViewMatrix",Fe.modelViewMatrix),kn.setValue($,"normalMatrix",Fe.normalMatrix),kn.setValue($,"modelMatrix",Fe.matrixWorld),He.isShaderMaterial||He.isRawShaderMaterial){const or=He.uniformsGroups;for(let Or=0,Ua=or.length;Or<Ua;Or++){const Es=or[Or];Pe.update(Es,Xt),Pe.bind(Es,Xt)}}return Xt}function Xe(de,Re){de.ambientLightColor.needsUpdate=Re,de.lightProbe.needsUpdate=Re,de.directionalLights.needsUpdate=Re,de.directionalLightShadows.needsUpdate=Re,de.pointLights.needsUpdate=Re,de.pointLightShadows.needsUpdate=Re,de.spotLights.needsUpdate=Re,de.spotLightShadows.needsUpdate=Re,de.rectAreaLights.needsUpdate=Re,de.hemisphereLights.needsUpdate=Re}function ot(de){return de.isMeshLambertMaterial||de.isMeshToonMaterial||de.isMeshPhongMaterial||de.isMeshStandardMaterial||de.isShadowMaterial||de.isShaderMaterial&&de.lights===!0}this.getActiveCubeFace=function(){return O},this.getActiveMipmapLevel=function(){return k},this.getRenderTarget=function(){return R},this.setRenderTargetTextures=function(de,Re,Ve){const He=je.get(de);He.__autoAllocateDepthBuffer=de.resolveDepthBuffer===!1,He.__autoAllocateDepthBuffer===!1&&(He.__useRenderToTexture=!1),je.get(de.texture).__webglTexture=Re,je.get(de.depthTexture).__webglTexture=He.__autoAllocateDepthBuffer?void 0:Ve,He.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(de,Re){const Ve=je.get(de);Ve.__webglFramebuffer=Re,Ve.__useDefaultFramebuffer=Re===void 0};const ct=$.createFramebuffer();this.setRenderTarget=function(de,Re=0,Ve=0){R=de,O=Re,k=Ve;let He=!0,Fe=null,mt=!1,St=!1;if(de){const xt=je.get(de);if(xt.__useDefaultFramebuffer!==void 0)oe.bindFramebuffer($.FRAMEBUFFER,null),He=!1;else if(xt.__webglFramebuffer===void 0)Ce.setupRenderTarget(de);else if(xt.__hasExternalTextures)Ce.rebindTextures(de,je.get(de.texture).__webglTexture,je.get(de.depthTexture).__webglTexture);else if(de.depthBuffer){const wt=de.depthTexture;if(xt.__boundDepthTexture!==wt){if(wt!==null&&je.has(wt)&&(de.width!==wt.image.width||de.height!==wt.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");Ce.setupDepthRenderbuffer(de)}}const $t=de.texture;($t.isData3DTexture||$t.isDataArrayTexture||$t.isCompressedArrayTexture)&&(St=!0);const jt=je.get(de).__webglFramebuffer;de.isWebGLCubeRenderTarget?(Array.isArray(jt[Re])?Fe=jt[Re][Ve]:Fe=jt[Re],mt=!0):de.samples>0&&Ce.useMultisampledRTT(de)===!1?Fe=je.get(de).__webglMultisampledFramebuffer:Array.isArray(jt)?Fe=jt[Ve]:Fe=jt,K.copy(de.viewport),j.copy(de.scissor),W=de.scissorTest}else K.copy(ae).multiplyScalar(re).floor(),j.copy(se).multiplyScalar(re).floor(),W=ue;if(Ve!==0&&(Fe=ct),oe.bindFramebuffer($.FRAMEBUFFER,Fe)&&He&&oe.drawBuffers(de,Fe),oe.viewport(K),oe.scissor(j),oe.setScissorTest(W),mt){const xt=je.get(de.texture);$.framebufferTexture2D($.FRAMEBUFFER,$.COLOR_ATTACHMENT0,$.TEXTURE_CUBE_MAP_POSITIVE_X+Re,xt.__webglTexture,Ve)}else if(St){const xt=Re;for(let $t=0;$t<de.textures.length;$t++){const jt=je.get(de.textures[$t]);$.framebufferTextureLayer($.FRAMEBUFFER,$.COLOR_ATTACHMENT0+$t,jt.__webglTexture,Ve,xt)}}else if(de!==null&&Ve!==0){const xt=je.get(de.texture);$.framebufferTexture2D($.FRAMEBUFFER,$.COLOR_ATTACHMENT0,$.TEXTURE_2D,xt.__webglTexture,Ve)}F=-1},this.readRenderTargetPixels=function(de,Re,Ve,He,Fe,mt,St,kt=0){if(!(de&&de.isWebGLRenderTarget)){ui("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let xt=je.get(de).__webglFramebuffer;if(de.isWebGLCubeRenderTarget&&St!==void 0&&(xt=xt[St]),xt){oe.bindFramebuffer($.FRAMEBUFFER,xt);try{const $t=de.textures[kt],jt=$t.format,wt=$t.type;if(!B.textureFormatReadable(jt)){ui("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!B.textureTypeReadable(wt)){ui("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}Re>=0&&Re<=de.width-He&&Ve>=0&&Ve<=de.height-Fe&&(de.textures.length>1&&$.readBuffer($.COLOR_ATTACHMENT0+kt),$.readPixels(Re,Ve,He,Fe,nt.convert(jt),nt.convert(wt),mt))}finally{const $t=R!==null?je.get(R).__webglFramebuffer:null;oe.bindFramebuffer($.FRAMEBUFFER,$t)}}},this.readRenderTargetPixelsAsync=async function(de,Re,Ve,He,Fe,mt,St,kt=0){if(!(de&&de.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let xt=je.get(de).__webglFramebuffer;if(de.isWebGLCubeRenderTarget&&St!==void 0&&(xt=xt[St]),xt)if(Re>=0&&Re<=de.width-He&&Ve>=0&&Ve<=de.height-Fe){oe.bindFramebuffer($.FRAMEBUFFER,xt);const $t=de.textures[kt],jt=$t.format,wt=$t.type;if(!B.textureFormatReadable(jt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!B.textureTypeReadable(wt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Qt=$.createBuffer();$.bindBuffer($.PIXEL_PACK_BUFFER,Qt),$.bufferData($.PIXEL_PACK_BUFFER,mt.byteLength,$.STREAM_READ),de.textures.length>1&&$.readBuffer($.COLOR_ATTACHMENT0+kt),$.readPixels(Re,Ve,He,Fe,nt.convert(jt),nt.convert(wt),0);const Kt=R!==null?je.get(R).__webglFramebuffer:null;oe.bindFramebuffer($.FRAMEBUFFER,Kt);const fn=$.fenceSync($.SYNC_GPU_COMMANDS_COMPLETE,0);return $.flush(),await n3e($,fn,4),$.bindBuffer($.PIXEL_PACK_BUFFER,Qt),$.getBufferSubData($.PIXEL_PACK_BUFFER,0,mt),$.deleteBuffer(Qt),$.deleteSync(fn),mt}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(de,Re=null,Ve=0){const He=Math.pow(2,-Ve),Fe=Math.floor(de.image.width*He),mt=Math.floor(de.image.height*He),St=Re!==null?Re.x:0,kt=Re!==null?Re.y:0;Ce.setTexture2D(de,0),$.copyTexSubImage2D($.TEXTURE_2D,Ve,0,0,St,kt,Fe,mt),oe.unbindTexture()};const rt=$.createFramebuffer(),Rt=$.createFramebuffer();this.copyTextureToTexture=function(de,Re,Ve=null,He=null,Fe=0,mt=null){mt===null&&(Fe!==0?(I0("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),mt=Fe,Fe=0):mt=0);let St,kt,xt,$t,jt,wt,Qt,Kt,fn;const ye=de.isCompressedTexture?de.mipmaps[mt]:de.image;if(Ve!==null)St=Ve.max.x-Ve.min.x,kt=Ve.max.y-Ve.min.y,xt=Ve.isBox3?Ve.max.z-Ve.min.z:1,$t=Ve.min.x,jt=Ve.min.y,wt=Ve.isBox3?Ve.min.z:0;else{const en=Math.pow(2,-Fe);St=Math.floor(ye.width*en),kt=Math.floor(ye.height*en),de.isDataArrayTexture?xt=ye.depth:de.isData3DTexture?xt=Math.floor(ye.depth*en):xt=1,$t=0,jt=0,wt=0}He!==null?(Qt=He.x,Kt=He.y,fn=He.z):(Qt=0,Kt=0,fn=0);const De=nt.convert(Re.format),ht=nt.convert(Re.type);let Mt;Re.isData3DTexture?(Ce.setTexture3D(Re,0),Mt=$.TEXTURE_3D):Re.isDataArrayTexture||Re.isCompressedArrayTexture?(Ce.setTexture2DArray(Re,0),Mt=$.TEXTURE_2D_ARRAY):(Ce.setTexture2D(Re,0),Mt=$.TEXTURE_2D),$.pixelStorei($.UNPACK_FLIP_Y_WEBGL,Re.flipY),$.pixelStorei($.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Re.premultiplyAlpha),$.pixelStorei($.UNPACK_ALIGNMENT,Re.unpackAlignment);const at=$.getParameter($.UNPACK_ROW_LENGTH),Xt=$.getParameter($.UNPACK_IMAGE_HEIGHT),Yt=$.getParameter($.UNPACK_SKIP_PIXELS),rn=$.getParameter($.UNPACK_SKIP_ROWS),sr=$.getParameter($.UNPACK_SKIP_IMAGES);$.pixelStorei($.UNPACK_ROW_LENGTH,ye.width),$.pixelStorei($.UNPACK_IMAGE_HEIGHT,ye.height),$.pixelStorei($.UNPACK_SKIP_PIXELS,$t),$.pixelStorei($.UNPACK_SKIP_ROWS,jt),$.pixelStorei($.UNPACK_SKIP_IMAGES,wt);const kn=de.isDataArrayTexture||de.isData3DTexture,Wt=Re.isDataArrayTexture||Re.isData3DTexture;if(de.isDepthTexture){const en=je.get(de),or=je.get(Re),Or=je.get(en.__renderTarget),Ua=je.get(or.__renderTarget);oe.bindFramebuffer($.READ_FRAMEBUFFER,Or.__webglFramebuffer),oe.bindFramebuffer($.DRAW_FRAMEBUFFER,Ua.__webglFramebuffer);for(let Es=0;Es<xt;Es++)kn&&($.framebufferTextureLayer($.READ_FRAMEBUFFER,$.COLOR_ATTACHMENT0,je.get(de).__webglTexture,Fe,wt+Es),$.framebufferTextureLayer($.DRAW_FRAMEBUFFER,$.COLOR_ATTACHMENT0,je.get(Re).__webglTexture,mt,fn+Es)),$.blitFramebuffer($t,jt,St,kt,Qt,Kt,St,kt,$.DEPTH_BUFFER_BIT,$.NEAREST);oe.bindFramebuffer($.READ_FRAMEBUFFER,null),oe.bindFramebuffer($.DRAW_FRAMEBUFFER,null)}else if(Fe!==0||de.isRenderTargetTexture||je.has(de)){const en=je.get(de),or=je.get(Re);oe.bindFramebuffer($.READ_FRAMEBUFFER,rt),oe.bindFramebuffer($.DRAW_FRAMEBUFFER,Rt);for(let Or=0;Or<xt;Or++)kn?$.framebufferTextureLayer($.READ_FRAMEBUFFER,$.COLOR_ATTACHMENT0,en.__webglTexture,Fe,wt+Or):$.framebufferTexture2D($.READ_FRAMEBUFFER,$.COLOR_ATTACHMENT0,$.TEXTURE_2D,en.__webglTexture,Fe),Wt?$.framebufferTextureLayer($.DRAW_FRAMEBUFFER,$.COLOR_ATTACHMENT0,or.__webglTexture,mt,fn+Or):$.framebufferTexture2D($.DRAW_FRAMEBUFFER,$.COLOR_ATTACHMENT0,$.TEXTURE_2D,or.__webglTexture,mt),Fe!==0?$.blitFramebuffer($t,jt,St,kt,Qt,Kt,St,kt,$.COLOR_BUFFER_BIT,$.NEAREST):Wt?$.copyTexSubImage3D(Mt,mt,Qt,Kt,fn+Or,$t,jt,St,kt):$.copyTexSubImage2D(Mt,mt,Qt,Kt,$t,jt,St,kt);oe.bindFramebuffer($.READ_FRAMEBUFFER,null),oe.bindFramebuffer($.DRAW_FRAMEBUFFER,null)}else Wt?de.isDataTexture||de.isData3DTexture?$.texSubImage3D(Mt,mt,Qt,Kt,fn,St,kt,xt,De,ht,ye.data):Re.isCompressedArrayTexture?$.compressedTexSubImage3D(Mt,mt,Qt,Kt,fn,St,kt,xt,De,ye.data):$.texSubImage3D(Mt,mt,Qt,Kt,fn,St,kt,xt,De,ht,ye):de.isDataTexture?$.texSubImage2D($.TEXTURE_2D,mt,Qt,Kt,St,kt,De,ht,ye.data):de.isCompressedTexture?$.compressedTexSubImage2D($.TEXTURE_2D,mt,Qt,Kt,ye.width,ye.height,De,ye.data):$.texSubImage2D($.TEXTURE_2D,mt,Qt,Kt,St,kt,De,ht,ye);$.pixelStorei($.UNPACK_ROW_LENGTH,at),$.pixelStorei($.UNPACK_IMAGE_HEIGHT,Xt),$.pixelStorei($.UNPACK_SKIP_PIXELS,Yt),$.pixelStorei($.UNPACK_SKIP_ROWS,rn),$.pixelStorei($.UNPACK_SKIP_IMAGES,sr),mt===0&&Re.generateMipmaps&&$.generateMipmap(Mt),oe.unbindTexture()},this.initRenderTarget=function(de){je.get(de).__webglFramebuffer===void 0&&Ce.setupRenderTarget(de)},this.initTexture=function(de){de.isCubeTexture?Ce.setTextureCube(de,0):de.isData3DTexture?Ce.setTexture3D(de,0):de.isDataArrayTexture||de.isCompressedArrayTexture?Ce.setTexture2DArray(de,0):Ce.setTexture2D(de,0),oe.unbindTexture()},this.resetState=function(){O=0,k=0,R=null,oe.reset(),ne.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Rl}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const n=this.getContext();n.drawingBufferColorSpace=qn._getDrawingBufferColorSpace(e),n.unpackColorSpace=qn._getUnpackColorSpace()}};const mV={type:"change"},OO={type:"start"},vJ={type:"end"},V_=new kO,pV=new ud,POe=Math.cos(70*i3e.DEG2RAD),Ai=new lt,ds=2*Math.PI,pr={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},tk=1e-6;class ROe extends V3e{constructor(e,n=null){super(e,n),this.state=pr.NONE,this.target=new lt,this.cursor=new lt,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:Kp.ROTATE,MIDDLE:Kp.DOLLY,RIGHT:Kp.PAN},this.touches={ONE:Up.ROTATE,TWO:Up.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new lt,this._lastQuaternion=new Bf,this._lastTargetPosition=new lt,this._quat=new Bf().setFromUnitVectors(e.up,new lt(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new HH,this._sphericalDelta=new HH,this._scale=1,this._panOffset=new lt,this._rotateStart=new Mn,this._rotateEnd=new Mn,this._rotateDelta=new Mn,this._panStart=new Mn,this._panEnd=new Mn,this._panDelta=new Mn,this._dollyStart=new Mn,this._dollyEnd=new Mn,this._dollyDelta=new Mn,this._dollyDirection=new lt,this._mouse=new Mn,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=OOe.bind(this),this._onPointerDown=DOe.bind(this),this._onPointerUp=LOe.bind(this),this._onContextMenu=HOe.bind(this),this._onMouseWheel=UOe.bind(this),this._onKeyDown=zOe.bind(this),this._onTouchStart=BOe.bind(this),this._onTouchMove=$Oe.bind(this),this._onMouseDown=IOe.bind(this),this._onMouseMove=FOe.bind(this),this._interceptControlDown=VOe.bind(this),this._interceptControlUp=GOe.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(mV),this.update(),this.state=pr.NONE}update(e=null){const n=this.object.position;Ai.copy(n).sub(this.target),Ai.applyQuaternion(this._quat),this._spherical.setFromVector3(Ai),this.autoRotate&&this.state===pr.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let r=this.minAzimuthAngle,i=this.maxAzimuthAngle;isFinite(r)&&isFinite(i)&&(r<-Math.PI?r+=ds:r>Math.PI&&(r-=ds),i<-Math.PI?i+=ds:i>Math.PI&&(i-=ds),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(Ai.setFromSpherical(this._spherical),Ai.applyQuaternion(this._quatInverse),n.copy(this.target).add(Ai),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=Ai.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 lt(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 lt(this._mouse.x,this._mouse.y,0);u.unproject(this.object),this.object.position.sub(u).add(l),this.object.updateMatrixWorld(),o=Ai.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))<POe?this.object.lookAt(this.target):(pV.setFromNormalAndCoplanarPoint(this.object.up,this.target),V_.intersectPlane(pV,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)>tk||8*(1-this._lastQuaternion.dot(this.object.quaternion))>tk||this._lastTargetPosition.distanceToSquared(this.target)>tk?(this.dispatchEvent(mV),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?ds/60*this.autoRotateSpeed*e:ds/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){Ai.setFromMatrixColumn(n,0),Ai.multiplyScalar(-e),this._panOffset.add(Ai)}_panUp(e,n){this.screenSpacePanning===!0?Ai.setFromMatrixColumn(n,1):(Ai.setFromMatrixColumn(n,0),Ai.crossVectors(this.object.up,Ai)),Ai.multiplyScalar(e),this._panOffset.add(Ai)}_pan(e,n){const r=this.domElement;if(this.object.isPerspectiveCamera){const i=this.object.position;Ai.copy(i).sub(this.target);let a=Ai.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(ds*this._rotateDelta.x/n.clientHeight),this._rotateUp(ds*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(ds*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(-ds*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(ds*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(-ds*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(ds*this._rotateDelta.x/n.clientHeight),this._rotateUp(ds*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 Mn,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 DOe(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 OOe(t){this.enabled!==!1&&(t.pointerType==="touch"?this._onTouchMove(t):this._onMouseMove(t))}function LOe(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(vJ),this.state=pr.NONE;break;case 1:const e=this._pointers[0],n=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:n.x,pageY:n.y});break}}function IOe(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 Kp.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(t),this.state=pr.DOLLY;break;case Kp.ROTATE:if(t.ctrlKey||t.metaKey||t.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(t),this.state=pr.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(t),this.state=pr.ROTATE}break;case Kp.PAN:if(t.ctrlKey||t.metaKey||t.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(t),this.state=pr.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(t),this.state=pr.PAN}break;default:this.state=pr.NONE}this.state!==pr.NONE&&this.dispatchEvent(OO)}function FOe(t){switch(this.state){case pr.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(t);break;case pr.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(t);break;case pr.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(t);break}}function UOe(t){this.enabled===!1||this.enableZoom===!1||this.state!==pr.NONE||(t.preventDefault(),this.dispatchEvent(OO),this._handleMouseWheel(this._customWheelEvent(t)),this.dispatchEvent(vJ))}function zOe(t){this.enabled!==!1&&this._handleKeyDown(t)}function BOe(t){switch(this._trackPointer(t),this._pointers.length){case 1:switch(this.touches.ONE){case Up.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(t),this.state=pr.TOUCH_ROTATE;break;case Up.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(t),this.state=pr.TOUCH_PAN;break;default:this.state=pr.NONE}break;case 2:switch(this.touches.TWO){case Up.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(t),this.state=pr.TOUCH_DOLLY_PAN;break;case Up.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(t),this.state=pr.TOUCH_DOLLY_ROTATE;break;default:this.state=pr.NONE}break;default:this.state=pr.NONE}this.state!==pr.NONE&&this.dispatchEvent(OO)}function $Oe(t){switch(this._trackPointer(t),this.state){case pr.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(t),this.update();break;case pr.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(t),this.update();break;case pr.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(t),this.update();break;case pr.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(t),this.update();break;default:this.state=pr.NONE}}function HOe(t){this.enabled!==!1&&t.preventDefault()}function VOe(t){t.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function GOe(t){t.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function WOe(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 ec;let u=0;for(let d=0;d<t.length;++d){const f=t[d];let m=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 p in f.attributes){if(!r.has(p))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+'. All geometries must have compatible attributes; make sure "'+p+'" attribute exists among all geometries, or in none of them.'),null;a[p]===void 0&&(a[p]=[]),a[p].push(f.attributes[p]),m++}if(m!==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 p in f.morphAttributes){if(!i.has(p))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". .morphAttributes must be consistent throughout all geometries."),null;o[p]===void 0&&(o[p]=[]),o[p].push(f.morphAttributes[p])}if(e){let p;if(n)p=f.index.count;else if(f.attributes.position!==void 0)p=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,p,d),u+=p}}if(n){let d=0;const f=[];for(let m=0;m<t.length;++m){const p=t[m].index;for(let x=0;x<p.count;++x)f.push(p.getX(x)+d);d+=t[m].attributes.position.count}c.setIndex(f)}for(const d in a){const f=gV(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 m=0;m<f;++m){const p=[];for(let y=0;y<o[d].length;++y)p.push(o[d][y][m]);const x=gV(p);if(!x)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+d+" morphAttribute."),null;c.morphAttributes[d].push(x)}}return c}function gV(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 Ao(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 m=0,p=d.count;m<p;m++)for(let x=0;x<n;x++){const y=d.getComponent(m,x);l.setComponent(m+f,x,y)}}else o.set(d.array,c);c+=d.count*n}return i!==void 0&&(l.gpuType=i),l}function G_(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 nk={exports:{}};var xV;function qOe(){return xV||(xV=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 G_=="function"&&G_;if(!d&&f)return f(u,!0);if(l)return l(u,!0);var m=new Error("Cannot find module '"+u+"'");throw m.code="MODULE_NOT_FOUND",m}var p=i[u]={exports:{}};r[u][0].call(p.exports,function(x){var y=r[u][1][x];return o(y||x)},p,p.exports,n,r,i,a)}return i[u].exports}for(var l=typeof G_=="function"&&G_,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,m,p,x,y,b=[],v=0,N=c.length,S=N,T=a.getTypeOf(c)!=="string";v<c.length;)S=N-v,f=T?(u=c[v++],d=v<N?c[v++]:0,v<N?c[v++]:0):(u=c.charCodeAt(v++),d=v<N?c.charCodeAt(v++):0,v<N?c.charCodeAt(v++):0),m=u>>2,p=(3&u)<<4|d>>4,x=1<S?(15&d)<<2|f>>6:64,y=2<S?63&f:64,b.push(l.charAt(m)+l.charAt(p)+l.charAt(x)+l.charAt(y));return b.join("")},i.decode=function(c){var u,d,f,m,p,x,y=0,b=0,v="data:";if(c.substr(0,v.length)===v)throw new Error("Invalid base64 input, it looks like a data url.");var N,S=3*(c=c.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(c.charAt(c.length-1)===l.charAt(64)&&S--,c.charAt(c.length-2)===l.charAt(64)&&S--,S%1!=0)throw new Error("Invalid base64 input, bad content length.");for(N=o.uint8array?new Uint8Array(0|S):new Array(0|S);y<c.length;)u=l.indexOf(c.charAt(y++))<<2|(m=l.indexOf(c.charAt(y++)))>>4,d=(15&m)<<4|(p=l.indexOf(c.charAt(y++)))>>2,f=(3&p)<<6|(x=l.indexOf(c.charAt(y++))),N[b++]=u,p!==64&&(N[b++]=d),x!==64&&(N[b++]=f);return N}},{"./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,m,p,x){this.compressedSize=d,this.uncompressedSize=f,this.crc32=m,this.compression=p,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,m){return d.pipe(new l).pipe(new c("uncompressedSize")).pipe(f.compressWorker(m)).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,m){var p=o,x=m+f;u^=-1;for(var y=m;y<x;y++)u=u>>>8^p[255&(u^d[y])];return-1^u})(0|c,l,l.length,0):(function(u,d,f,m){var p=o,x=m+f;u^=-1;for(var y=m;y<x;y++)u=u>>>8^p[255&(u^d.charCodeAt(y))];return-1^u})(0|c,l,l.length,0):0}},{"./utils":32}],5:[function(n,r,i){i.base64=!1,i.binary=!1,i.dir=!1,i.createFolders=!0,i.date=null,i.compression=null,i.compressionOptions=null,i.comment=null,i.unixPermissions=null,i.dosPermissions=null},{}],6:[function(n,r,i){var 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,m){c.call(this,"FlateWorker/"+f),this._pako=null,this._pakoAction=f,this._pakoOptions=m,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(m){f.push({data:m,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(p,x){var y,b="";for(y=0;y<x;y++)b+=String.fromCharCode(255&p),p>>>=8;return b}function o(p,x,y,b,v,N){var S,T,E=p.file,C=p.compression,A=N!==u.utf8encode,O=l.transformTo("string",N(E.name)),k=l.transformTo("string",u.utf8encode(E.name)),R=E.comment,F=l.transformTo("string",N(R)),L=l.transformTo("string",u.utf8encode(R)),K=k.length!==E.name.length,j=L.length!==R.length,W="",Y="",q="",Q=E.dir,ee=E.date,re={crc32:0,compressedSize:0,uncompressedSize:0};x&&!y||(re.crc32=p.crc32,re.compressedSize=p.compressedSize,re.uncompressedSize=p.uncompressedSize);var z=0;x&&(z|=8),A||!K&&!j||(z|=2048);var G=0,ae=0;Q&&(G|=16),v==="UNIX"?(ae=798,G|=(function(ue,pe){var ce=ue;return ue||(ce=pe?16893:33204),(65535&ce)<<16})(E.unixPermissions,Q)):(ae=20,G|=(function(ue){return 63&(ue||0)})(E.dosPermissions)),S=ee.getUTCHours(),S<<=6,S|=ee.getUTCMinutes(),S<<=5,S|=ee.getUTCSeconds()/2,T=ee.getUTCFullYear()-1980,T<<=4,T|=ee.getUTCMonth()+1,T<<=5,T|=ee.getUTCDate(),K&&(Y=a(1,1)+a(d(O),4)+k,W+="up"+a(Y.length,2)+Y),j&&(q=a(1,1)+a(d(F),4)+L,W+="uc"+a(q.length,2)+q);var se="";return se+=`
  3919. \0`,se+=a(z,2),se+=C.magic,se+=a(S,2),se+=a(T,2),se+=a(re.crc32,4),se+=a(re.compressedSize,4),se+=a(re.uncompressedSize,4),se+=a(O.length,2),se+=a(W.length,2),{fileRecord:f.LOCAL_FILE_HEADER+se+O+W,dirRecord:f.CENTRAL_FILE_HEADER+a(ae,2)+se+a(F.length,2)+"\0\0\0\0"+a(G,4)+a(b,4)+O+W+F}}var l=n("../utils"),c=n("../stream/GenericWorker"),u=n("../utf8"),d=n("../crc32"),f=n("../signature");function m(p,x,y,b){c.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=x,this.zipPlatform=y,this.encodeFileName=b,this.streamFiles=p,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}l.inherits(m,c),m.prototype.push=function(p){var x=p.meta.percent||0,y=this.entriesCount,b=this._sources.length;this.accumulate?this.contentBuffer.push(p):(this.bytesWritten+=p.data.length,c.prototype.push.call(this,{data:p.data,meta:{currentFile:this.currentFile,percent:y?(x+100*(y-b-1))/y:100}}))},m.prototype.openedSource=function(p){this.currentSourceOffset=this.bytesWritten,this.currentFile=p.file.name;var x=this.streamFiles&&!p.file.dir;if(x){var y=o(p,x,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:y.fileRecord,meta:{percent:0}})}else this.accumulate=!0},m.prototype.closedSource=function(p){this.accumulate=!1;var x=this.streamFiles&&!p.file.dir,y=o(p,x,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(y.dirRecord),x)this.push({data:(function(b){return f.DATA_DESCRIPTOR+a(b.crc32,4)+a(b.compressedSize,4)+a(b.uncompressedSize,4)})(p),meta:{percent:100}});else for(this.push({data:y.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},m.prototype.flush=function(){for(var p=this.bytesWritten,x=0;x<this.dirRecords.length;x++)this.push({data:this.dirRecords[x],meta:{percent:100}});var y=this.bytesWritten-p,b=(function(v,N,S,T,E){var C=l.transformTo("string",E(T));return f.CENTRAL_DIRECTORY_END+"\0\0\0\0"+a(v,2)+a(v,2)+a(N,4)+a(S,4)+a(C.length,2)+C})(this.dirRecords.length,y,p,this.zipComment,this.encodeFileName);this.push({data:b,meta:{percent:100}})},m.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},m.prototype.registerPrevious=function(p){this._sources.push(p);var x=this;return p.on("data",function(y){x.processChunk(y)}),p.on("end",function(){x.closedSource(x.previous.streamInfo),x._sources.length?x.prepareNextSource():x.end()}),p.on("error",function(y){x.error(y)}),this},m.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))},m.prototype.error=function(p){var x=this._sources;if(!c.prototype.error.call(this,p))return!1;for(var y=0;y<x.length;y++)try{x[y].error(p)}catch{}return!0},m.prototype.lock=function(){c.prototype.lock.call(this);for(var p=this._sources,x=0;x<p.length;x++)p[x].lock()},r.exports=m},{"../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(m,p){f++;var x=(function(N,S){var T=N||S,E=a[T];if(!E)throw new Error(T+" is not a valid compression method !");return E})(p.options.compression,c.compression),y=p.options.compressionOptions||c.compressionOptions||{},b=p.dir,v=p.date;p._compressWorker(x,y).withStreamInfo("file",{name:m,dir:b,date:v,comment:p.comment||"",unixPermissions:p.unixPermissions,dosPermissions:p.dosPermissions}).pipe(d)}),d.entriesCount=f}catch(m){d.error(m)}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(m){return new o.Promise(function(p,x){var y=m.decompressed.getContentWorker().pipe(new u);y.on("error",function(b){x(b)}).on("end",function(){y.streamInfo.crc32!==m.decompressed.crc32?x(new Error("Corrupted zip : CRC32 mismatch")):p()}).resume()})}r.exports=function(m,p){var x=this;return p=a.extend(p||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:l.utf8decode}),d.isNode&&d.isStream(m)?o.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):a.prepareContent("the loaded zip file",m,!0,p.optimizedBinaryString,p.base64).then(function(y){var b=new c(p);return b.load(y),b}).then(function(y){var b=[o.Promise.resolve(y)],v=y.files;if(p.checkCRC32)for(var N=0;N<v.length;N++)b.push(f(v[N]));return o.Promise.all(b)}).then(function(y){for(var b=y.shift(),v=b.files,N=0;N<v.length;N++){var S=v[N],T=S.fileNameStr,E=a.resolve(S.fileNameStr);x.file(E,S.decompressed,{binary:!0,optimizedBinaryString:!0,date:S.date,dir:S.dir,comment:S.fileCommentStr.length?S.fileCommentStr:null,unixPermissions:S.unixPermissions,dosPermissions:S.dosPermissions,createFolders:p.createFolders}),S.dir||(x.file(E).unsafeOriginalName=T)}return b.zipComment.length&&(x.comment=b.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,m){d.push(f)||d._helper.pause(),u&&u(m)}).on("error",function(f){d.emit("error",f)}).on("end",function(){d.push(null)})}n("../utils").inherits(o,a),o.prototype._read=function(){this._helper.resume()},r.exports=o},{"../utils":32,"readable-stream":16}],14:[function(n,r,i){r.exports={isNode:typeof Buffer<"u",newBufferFrom:function(a,o){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(a,o);if(typeof a=="number")throw new Error('The "data" argument must not be a number');return new Buffer(a,o)},allocBuffer:function(a){if(Buffer.alloc)return Buffer.alloc(a);var o=new Buffer(a);return o.fill(0),o},isBuffer:function(a){return Buffer.isBuffer(a)},isStream:function(a){return a&&typeof a.on=="function"&&typeof a.pause=="function"&&typeof a.resume=="function"}}},{}],15:[function(n,r,i){function a(E,C,A){var O,k=l.getTypeOf(C),R=l.extend(A||{},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&&(E=v(E)),R.createFolders&&(O=b(E))&&N.call(this,O,!0);var F=k==="string"&&R.binary===!1&&R.base64===!1;A&&A.binary!==void 0||(R.binary=!F),(C instanceof f&&C.uncompressedSize===0||R.dir||!C||C.length===0)&&(R.base64=!1,R.binary=!0,C="",R.compression="STORE",k="string");var L=null;L=C instanceof f||C instanceof c?C:x.isNode&&x.isStream(C)?new y(E,C):l.prepareContent(E,C,R.binary,R.optimizedBinaryString,R.base64);var K=new m(E,L,R);this.files[E]=K}var o=n("./utf8"),l=n("./utils"),c=n("./stream/GenericWorker"),u=n("./stream/StreamHelper"),d=n("./defaults"),f=n("./compressedObject"),m=n("./zipObject"),p=n("./generate"),x=n("./nodejsUtils"),y=n("./nodejs/NodejsStreamInputAdapter"),b=function(E){E.slice(-1)==="/"&&(E=E.substring(0,E.length-1));var C=E.lastIndexOf("/");return 0<C?E.substring(0,C):""},v=function(E){return E.slice(-1)!=="/"&&(E+="/"),E},N=function(E,C){return C=C!==void 0?C:d.createFolders,E=v(E),this.files[E]||a.call(this,E,null,{dir:!0,createFolders:C}),this.files[E]};function S(E){return Object.prototype.toString.call(E)==="[object RegExp]"}var T={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(E){var C,A,O;for(C in this.files)O=this.files[C],(A=C.slice(this.root.length,C.length))&&C.slice(0,this.root.length)===this.root&&E(A,O)},filter:function(E){var C=[];return this.forEach(function(A,O){E(A,O)&&C.push(O)}),C},file:function(E,C,A){if(arguments.length!==1)return E=this.root+E,a.call(this,E,C,A),this;if(S(E)){var O=E;return this.filter(function(R,F){return!F.dir&&O.test(R)})}var k=this.files[this.root+E];return k&&!k.dir?k:null},folder:function(E){if(!E)return this;if(S(E))return this.filter(function(k,R){return R.dir&&E.test(k)});var C=this.root+E,A=N.call(this,C),O=this.clone();return O.root=A.name,O},remove:function(E){E=this.root+E;var C=this.files[E];if(C||(E.slice(-1)!=="/"&&(E+="/"),C=this.files[E]),C&&!C.dir)delete this.files[E];else for(var A=this.filter(function(k,R){return R.name.slice(0,E.length)===E}),O=0;O<A.length;O++)delete this.files[A[O].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(E){var C,A={};try{if((A=l.extend(E||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:o.utf8encode})).type=A.type.toLowerCase(),A.compression=A.compression.toUpperCase(),A.type==="binarystring"&&(A.type="string"),!A.type)throw new Error("No output type specified.");l.checkSupport(A.type),A.platform!=="darwin"&&A.platform!=="freebsd"&&A.platform!=="linux"&&A.platform!=="sunos"||(A.platform="UNIX"),A.platform==="win32"&&(A.platform="DOS");var O=A.comment||this.comment||"";C=p.generateWorker(this,A,O)}catch(k){(C=new c("error")).error(k)}return new u(C,A.type||"string",A.mimeType)},generateAsync:function(E,C){return this.generateInternalStream(E).accumulate(C)},generateNodeStream:function(E,C){return(E=E||{}).type||(E.type="nodebuffer"),this.generateInternalStream(E).toNodejsStream(C)}};r.exports=T},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(n,r,i){r.exports=n("stream")},{stream:void 0}],17:[function(n,r,i){var a=n("./DataReader");function o(l){a.call(this,l);for(var c=0;c<this.data.length;c++)l[c]=255&l[c]}n("../utils").inherits(o,a),o.prototype.byteAt=function(l){return this.data[this.zero+l]},o.prototype.lastIndexOfSignature=function(l){for(var c=l.charCodeAt(0),u=l.charCodeAt(1),d=l.charCodeAt(2),f=l.charCodeAt(3),m=this.length-4;0<=m;--m)if(this.data[m]===c&&this.data[m+1]===u&&this.data[m+2]===d&&this.data[m+3]===f)return m-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),m=this.readData(4);return c===m[0]&&u===m[1]&&d===m[2]&&f===m[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 m=a.getTypeOf(f);return a.checkSupport(m),m!=="string"||o.uint8array?m==="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 m(x,y){return new d.Promise(function(b,v){var N=[],S=x._internalType,T=x._outputType,E=x._mimeType;x.on("data",function(C,A){N.push(C),y&&y(A)}).on("error",function(C){N=[],v(C)}).on("end",function(){try{var C=(function(A,O,k){switch(A){case"blob":return a.newBlob(a.transformTo("arraybuffer",O),k);case"base64":return c.encode(O);default:return a.transformTo(A,O)}})(T,(function(A,O){var k,R=0,F=null,L=0;for(k=0;k<O.length;k++)L+=O[k].length;switch(A){case"string":return O.join("");case"array":return Array.prototype.concat.apply([],O);case"uint8array":for(F=new Uint8Array(L),k=0;k<O.length;k++)F.set(O[k],R),R+=O[k].length;return F;case"nodebuffer":return Buffer.concat(O);default:throw new Error("concat : unsupported type '"+A+"'")}})(S,N),E);b(C)}catch(A){v(A)}N=[]}).resume()})}function p(x,y,b){var v=y;switch(y){case"blob":case"arraybuffer":v="uint8array";break;case"base64":v="string"}try{this._internalType=v,this._outputType=y,this._mimeType=b,a.checkSupport(v),this._worker=x.pipe(new o(v)),x.lock()}catch(N){this._worker=new l("error"),this._worker.error(N)}}p.prototype={accumulate:function(x){return m(this,x)},on:function(x,y){var b=this;return x==="data"?this._worker.on(x,function(v){y.call(b,v.data,v.meta)}):this._worker.on(x,function(){a.delay(y,arguments,b)}),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=p},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(n,r,i){if(i.base64=!0,i.array=!0,i.string=!0,i.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",i.nodebuffer=typeof Buffer<"u",i.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")i.blob=!1;else{var 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 m(){c.call(this,"utf-8 encode")}i.utf8encode=function(p){return o.nodebuffer?l.newBufferFrom(p,"utf-8"):(function(x){var y,b,v,N,S,T=x.length,E=0;for(N=0;N<T;N++)(64512&(b=x.charCodeAt(N)))==55296&&N+1<T&&(64512&(v=x.charCodeAt(N+1)))==56320&&(b=65536+(b-55296<<10)+(v-56320),N++),E+=b<128?1:b<2048?2:b<65536?3:4;for(y=o.uint8array?new Uint8Array(E):new Array(E),N=S=0;S<E;N++)(64512&(b=x.charCodeAt(N)))==55296&&N+1<T&&(64512&(v=x.charCodeAt(N+1)))==56320&&(b=65536+(b-55296<<10)+(v-56320),N++),b<128?y[S++]=b:(b<2048?y[S++]=192|b>>>6:(b<65536?y[S++]=224|b>>>12:(y[S++]=240|b>>>18,y[S++]=128|b>>>12&63),y[S++]=128|b>>>6&63),y[S++]=128|63&b);return y})(p)},i.utf8decode=function(p){return o.nodebuffer?a.transformTo("nodebuffer",p).toString("utf-8"):(function(x){var y,b,v,N,S=x.length,T=new Array(2*S);for(y=b=0;y<S;)if((v=x[y++])<128)T[b++]=v;else if(4<(N=u[v]))T[b++]=65533,y+=N-1;else{for(v&=N===2?31:N===3?15:7;1<N&&y<S;)v=v<<6|63&x[y++],N--;1<N?T[b++]=65533:v<65536?T[b++]=v:(v-=65536,T[b++]=55296|v>>10&1023,T[b++]=56320|1023&v)}return T.length!==b&&(T.subarray?T=T.subarray(0,b):T.length=b),a.applyFromCharCode(T)})(p=a.transformTo(o.uint8array?"uint8array":"array",p))},a.inherits(f,c),f.prototype.processChunk=function(p){var x=a.transformTo(o.uint8array?"uint8array":"array",p.data);if(this.leftOver&&this.leftOver.length){if(o.uint8array){var y=x;(x=new Uint8Array(y.length+this.leftOver.length)).set(this.leftOver,0),x.set(y,this.leftOver.length)}else x=this.leftOver.concat(x);this.leftOver=null}var b=(function(N,S){var T;for((S=S||N.length)>N.length&&(S=N.length),T=S-1;0<=T&&(192&N[T])==128;)T--;return T<0||T===0?S:T+u[N[T]]>S?T:S})(x),v=x;b!==x.length&&(o.uint8array?(v=x.subarray(0,b),this.leftOver=x.subarray(b,x.length)):(v=x.slice(0,b),this.leftOver=x.slice(b,x.length))),this.push({data:i.utf8decode(v),meta:p.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(m,c),m.prototype.processChunk=function(p){this.push({data:i.utf8encode(p.data),meta:p.meta})},i.Utf8EncodeWorker=m},{"./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(y){return y}function d(y,b){for(var v=0;v<y.length;++v)b[v]=255&y.charCodeAt(v);return b}n("setimmediate"),i.newBlob=function(y,b){i.checkSupport("blob");try{return new Blob([y],{type:b})}catch{try{var v=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return v.append(y),v.getBlob(b)}catch{throw new Error("Bug : can't construct the Blob.")}}};var f={stringifyByChunk:function(y,b,v){var N=[],S=0,T=y.length;if(T<=v)return String.fromCharCode.apply(null,y);for(;S<T;)b==="array"||b==="nodebuffer"?N.push(String.fromCharCode.apply(null,y.slice(S,Math.min(S+v,T)))):N.push(String.fromCharCode.apply(null,y.subarray(S,Math.min(S+v,T)))),S+=v;return N.join("")},stringifyByChar:function(y){for(var b="",v=0;v<y.length;v++)b+=String.fromCharCode(y[v]);return b},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 m(y){var b=65536,v=i.getTypeOf(y),N=!0;if(v==="uint8array"?N=f.applyCanBeUsed.uint8array:v==="nodebuffer"&&(N=f.applyCanBeUsed.nodebuffer),N)for(;1<b;)try{return f.stringifyByChunk(y,v,b)}catch{b=Math.floor(b/2)}return f.stringifyByChar(y)}function p(y,b){for(var v=0;v<y.length;v++)b[v]=y[v];return b}i.applyFromCharCode=m;var x={};x.string={string:u,array:function(y){return d(y,new Array(y.length))},arraybuffer:function(y){return x.string.uint8array(y).buffer},uint8array:function(y){return d(y,new Uint8Array(y.length))},nodebuffer:function(y){return d(y,l.allocBuffer(y.length))}},x.array={string:m,array:u,arraybuffer:function(y){return new Uint8Array(y).buffer},uint8array:function(y){return new Uint8Array(y)},nodebuffer:function(y){return l.newBufferFrom(y)}},x.arraybuffer={string:function(y){return m(new Uint8Array(y))},array:function(y){return p(new Uint8Array(y),new Array(y.byteLength))},arraybuffer:u,uint8array:function(y){return new Uint8Array(y)},nodebuffer:function(y){return l.newBufferFrom(new Uint8Array(y))}},x.uint8array={string:m,array:function(y){return p(y,new Array(y.length))},arraybuffer:function(y){return y.buffer},uint8array:u,nodebuffer:function(y){return l.newBufferFrom(y)}},x.nodebuffer={string:m,array:function(y){return p(y,new Array(y.length))},arraybuffer:function(y){return x.nodebuffer.uint8array(y).buffer},uint8array:function(y){return p(y,new Uint8Array(y.length))},nodebuffer:u},i.transformTo=function(y,b){if(b=b||"",!y)return b;i.checkSupport(y);var v=i.getTypeOf(b);return x[v][y](b)},i.resolve=function(y){for(var b=y.split("/"),v=[],N=0;N<b.length;N++){var S=b[N];S==="."||S===""&&N!==0&&N!==b.length-1||(S===".."?v.pop():v.push(S))}return v.join("/")},i.getTypeOf=function(y){return typeof y=="string"?"string":Object.prototype.toString.call(y)==="[object Array]"?"array":a.nodebuffer&&l.isBuffer(y)?"nodebuffer":a.uint8array&&y instanceof Uint8Array?"uint8array":a.arraybuffer&&y instanceof ArrayBuffer?"arraybuffer":void 0},i.checkSupport=function(y){if(!a[y.toLowerCase()])throw new Error(y+" is not supported by this platform")},i.MAX_VALUE_16BITS=65535,i.MAX_VALUE_32BITS=-1,i.pretty=function(y){var b,v,N="";for(v=0;v<(y||"").length;v++)N+="\\x"+((b=y.charCodeAt(v))<16?"0":"")+b.toString(16).toUpperCase();return N},i.delay=function(y,b,v){setImmediate(function(){y.apply(v||null,b||[])})},i.inherits=function(y,b){function v(){}v.prototype=b.prototype,y.prototype=new v},i.extend=function(){var y,b,v={};for(y=0;y<arguments.length;y++)for(b in arguments[y])Object.prototype.hasOwnProperty.call(arguments[y],b)&&v[b]===void 0&&(v[b]=arguments[y][b]);return v},i.prepareContent=function(y,b,v,N,S){return c.Promise.resolve(b).then(function(T){return a.blob&&(T instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(T))!==-1)&&typeof FileReader<"u"?new c.Promise(function(E,C){var A=new FileReader;A.onload=function(O){E(O.target.result)},A.onerror=function(O){C(O.target.error)},A.readAsArrayBuffer(T)}):T}).then(function(T){var E=i.getTypeOf(T);return E?(E==="arraybuffer"?T=i.transformTo("uint8array",T):E==="string"&&(S?T=o.decode(T):v&&N!==!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 '"+y+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(n,r,i){var 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 m=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+o.pretty(m)+", expected "+o.pretty(f)+")")}},isSignature:function(f,m){var p=this.reader.index;this.reader.setIndex(f);var x=this.reader.readString(4)===m;return this.reader.setIndex(p),x},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var f=this.reader.readData(this.zipCommentLength),m=u.uint8array?"uint8array":"array",p=o.transformTo(m,f);this.zipComment=this.loadOptions.decodeFileName(p)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var f,m,p,x=this.zip64EndOfCentralSize-44;0<x;)f=this.reader.readInt(2),m=this.reader.readInt(4),p=this.reader.readData(m),this.zip64ExtensibleData[f]={id:f,length:m,value:p}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var f,m;for(f=0;f<this.files.length;f++)m=this.files[f],this.reader.setIndex(m.localHeaderOffset),this.checkSignature(l.LOCAL_FILE_HEADER),m.readLocalPart(this.reader),m.handleUTF8(),m.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 m=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 p=this.centralDirOffset+this.centralDirSize;this.zip64&&(p+=20,p+=12+this.zip64EndOfCentralSize);var x=m-p;if(0<x)this.isSignature(m,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 m(p,x){this.options=p,this.loadOptions=x}m.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(p){var x,y;if(p.skip(22),this.fileNameLength=p.readInt(2),y=p.readInt(2),this.fileName=p.readData(this.fileNameLength),p.skip(y),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((x=(function(b){for(var v in d)if(Object.prototype.hasOwnProperty.call(d,v)&&d[v].magic===b)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,p.readData(this.compressedSize))},readCentralPart:function(p){this.versionMadeBy=p.readInt(2),p.skip(2),this.bitFlag=p.readInt(2),this.compressionMethod=p.readString(2),this.date=p.readDate(),this.crc32=p.readInt(4),this.compressedSize=p.readInt(4),this.uncompressedSize=p.readInt(4);var x=p.readInt(2);if(this.extraFieldsLength=p.readInt(2),this.fileCommentLength=p.readInt(2),this.diskNumberStart=p.readInt(2),this.internalFileAttributes=p.readInt(2),this.externalFileAttributes=p.readInt(4),this.localHeaderOffset=p.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");p.skip(x),this.readExtraFields(p),this.parseZIP64ExtraField(p),this.fileComment=p.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var p=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),p==0&&(this.dosPermissions=63&this.externalFileAttributes),p==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var p=a(this.extraFields[1].value);this.uncompressedSize===o.MAX_VALUE_32BITS&&(this.uncompressedSize=p.readInt(8)),this.compressedSize===o.MAX_VALUE_32BITS&&(this.compressedSize=p.readInt(8)),this.localHeaderOffset===o.MAX_VALUE_32BITS&&(this.localHeaderOffset=p.readInt(8)),this.diskNumberStart===o.MAX_VALUE_32BITS&&(this.diskNumberStart=p.readInt(4))}},readExtraFields:function(p){var x,y,b,v=p.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});p.index+4<v;)x=p.readInt(2),y=p.readInt(2),b=p.readData(y),this.extraFields[x]={id:x,length:y,value:b};p.setIndex(v)},handleUTF8:function(){var p=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 y=o.transformTo(p,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(y)}var b=this.findExtraFieldUnicodeComment();if(b!==null)this.fileCommentStr=b;else{var v=o.transformTo(p,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(v)}}},findExtraFieldUnicodePath:function(){var p=this.extraFields[28789];if(p){var x=a(p.value);return x.readInt(1)!==1||c(this.fileName)!==x.readInt(4)?null:u.utf8decode(x.readData(p.length-5))}return null},findExtraFieldUnicodeComment:function(){var p=this.extraFields[25461];if(p){var x=a(p.value);return x.readInt(1)!==1||c(this.fileComment)!==x.readInt(4)?null:u.utf8decode(x.readData(p.length-5))}return null}},r.exports=m},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(n,r,i){function a(x,y,b){this.name=x,this.dir=b.dir,this.date=b.date,this.comment=b.comment,this.unixPermissions=b.unixPermissions,this.dosPermissions=b.dosPermissions,this._data=y,this._dataBinary=b.binary,this.options={compression:b.compression,compressionOptions:b.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 y=null,b="string";try{if(!x)throw new Error("No output type specified.");var v=(b=x.toLowerCase())==="string"||b==="text";b!=="binarystring"&&b!=="text"||(b="string"),y=this._decompressWorker();var N=!this._dataBinary;N&&!v&&(y=y.pipe(new c.Utf8EncodeWorker)),!N&&v&&(y=y.pipe(new c.Utf8DecodeWorker))}catch(S){(y=new d("error")).error(S)}return new o(y,b,"")},async:function(x,y){return this.internalStream(x).accumulate(y)},nodeStream:function(x,y){return this.internalStream(x||"nodebuffer").toNodejsStream(y)},_compressWorker:function(x,y){if(this._data instanceof u&&this._data.compression.magic===x.magic)return this._data.getCompressedWorker();var b=this._decompressWorker();return this._dataBinary||(b=b.pipe(new c.Utf8EncodeWorker)),u.createWorkerFrom(b,x,y)},_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"],m=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},p=0;p<f.length;p++)a.prototype[f[p]]=m;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 y=a.document.createElement("script");y.onreadystatechange=function(){x(),y.onreadystatechange=null,y.parentNode.removeChild(y),y=null},a.document.documentElement.appendChild(y)}:function(){setTimeout(x,0)};else{var m=new a.MessageChannel;m.port1.onmessage=x,o=function(){m.port2.postMessage(0)}}var p=[];function x(){var y,b;l=!0;for(var v=p.length;v;){for(b=p,p=[],y=-1;++y<v;)b[y]();v=p.length}l=!1}r.exports=function(y){p.push(y)!==1||l||o()}}).call(this,typeof Jv<"u"?Jv: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&&y(this,v)}function m(v,N,S){this.promise=v,typeof N=="function"&&(this.onFulfilled=N,this.callFulfilled=this.otherCallFulfilled),typeof S=="function"&&(this.onRejected=S,this.callRejected=this.otherCallRejected)}function p(v,N,S){a(function(){var T;try{T=N(S)}catch(E){return l.reject(v,E)}T===v?l.reject(v,new TypeError("Cannot resolve promise with itself")):l.resolve(v,T)})}function x(v){var N=v&&v.then;if(v&&(typeof v=="object"||typeof v=="function")&&typeof N=="function")return function(){N.apply(v,arguments)}}function y(v,N){var S=!1;function T(A){S||(S=!0,l.reject(v,A))}function E(A){S||(S=!0,l.resolve(v,A))}var C=b(function(){N(E,T)});C.status==="error"&&T(C.value)}function b(v,N){var S={};try{S.value=v(N),S.status="success"}catch(T){S.status="error",S.value=T}return S}(r.exports=f).prototype.finally=function(v){if(typeof v!="function")return this;var N=this.constructor;return this.then(function(S){return N.resolve(v()).then(function(){return S})},function(S){return N.resolve(v()).then(function(){throw S})})},f.prototype.catch=function(v){return this.then(null,v)},f.prototype.then=function(v,N){if(typeof v!="function"&&this.state===u||typeof N!="function"&&this.state===c)return this;var S=new this.constructor(o);return this.state!==d?p(S,this.state===u?v:N,this.outcome):this.queue.push(new m(S,v,N)),S},m.prototype.callFulfilled=function(v){l.resolve(this.promise,v)},m.prototype.otherCallFulfilled=function(v){p(this.promise,this.onFulfilled,v)},m.prototype.callRejected=function(v){l.reject(this.promise,v)},m.prototype.otherCallRejected=function(v){p(this.promise,this.onRejected,v)},l.resolve=function(v,N){var S=b(x,N);if(S.status==="error")return l.reject(v,S.value);var T=S.value;if(T)y(v,T);else{v.state=u,v.outcome=N;for(var E=-1,C=v.queue.length;++E<C;)v.queue[E].callFulfilled(N)}return v},l.reject=function(v,N){v.state=c,v.outcome=N;for(var S=-1,T=v.queue.length;++S<T;)v.queue[S].callRejected(N);return v},f.resolve=function(v){return v instanceof this?v:l.resolve(new this(o),v)},f.reject=function(v){var N=new this(o);return l.reject(N,v)},f.all=function(v){var N=this;if(Object.prototype.toString.call(v)!=="[object Array]")return this.reject(new TypeError("must be an array"));var S=v.length,T=!1;if(!S)return this.resolve([]);for(var E=new Array(S),C=0,A=-1,O=new this(o);++A<S;)k(v[A],A);return O;function k(R,F){N.resolve(R).then(function(L){E[F]=L,++C!==S||T||(T=!0,l.resolve(O,E))},function(L){T||(T=!0,l.reject(O,L))})}},f.race=function(v){var N=this;if(Object.prototype.toString.call(v)!=="[object Array]")return this.reject(new TypeError("must be an array"));var S=v.length,T=!1;if(!S)return this.resolve([]);for(var E=-1,C=new this(o);++E<S;)A=v[E],N.resolve(A).then(function(O){T||(T=!0,l.resolve(C,O))},function(O){T||(T=!0,l.reject(C,O))});var A;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,m=-1,p=0,x=8;function y(v){if(!(this instanceof y))return new y(v);this.options=o.assign({level:m,method:x,chunkSize:16384,windowBits:15,memLevel:8,strategy:p,to:""},v||{});var N=this.options;N.raw&&0<N.windowBits?N.windowBits=-N.windowBits:N.gzip&&0<N.windowBits&&N.windowBits<16&&(N.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new u,this.strm.avail_out=0;var S=a.deflateInit2(this.strm,N.level,N.method,N.windowBits,N.memLevel,N.strategy);if(S!==f)throw new Error(c[S]);if(N.header&&a.deflateSetHeader(this.strm,N.header),N.dictionary){var T;if(T=typeof N.dictionary=="string"?l.string2buf(N.dictionary):d.call(N.dictionary)==="[object ArrayBuffer]"?new Uint8Array(N.dictionary):N.dictionary,(S=a.deflateSetDictionary(this.strm,T))!==f)throw new Error(c[S]);this._dict_set=!0}}function b(v,N){var S=new y(N);if(S.push(v,!0),S.err)throw S.msg||c[S.err];return S.result}y.prototype.push=function(v,N){var S,T,E=this.strm,C=this.options.chunkSize;if(this.ended)return!1;T=N===~~N?N:N===!0?4:0,typeof v=="string"?E.input=l.string2buf(v):d.call(v)==="[object ArrayBuffer]"?E.input=new Uint8Array(v):E.input=v,E.next_in=0,E.avail_in=E.input.length;do{if(E.avail_out===0&&(E.output=new o.Buf8(C),E.next_out=0,E.avail_out=C),(S=a.deflate(E,T))!==1&&S!==f)return this.onEnd(S),!(this.ended=!0);E.avail_out!==0&&(E.avail_in!==0||T!==4&&T!==2)||(this.options.to==="string"?this.onData(l.buf2binstring(o.shrinkBuf(E.output,E.next_out))):this.onData(o.shrinkBuf(E.output,E.next_out)))}while((0<E.avail_in||E.avail_out===0)&&S!==1);return T===4?(S=a.deflateEnd(this.strm),this.onEnd(S),this.ended=!0,S===f):T!==2||(this.onEnd(f),!(E.avail_out=0))},y.prototype.onData=function(v){this.chunks.push(v)},y.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=y,i.deflate=b,i.deflateRaw=function(v,N){return(N=N||{}).raw=!0,b(v,N)},i.gzip=function(v,N){return(N=N||{}).gzip=!0,b(v,N)}},{"./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"),m=Object.prototype.toString;function p(y){if(!(this instanceof p))return new p(y);this.options=o.assign({chunkSize:16384,windowBits:0,to:""},y||{});var b=this.options;b.raw&&0<=b.windowBits&&b.windowBits<16&&(b.windowBits=-b.windowBits,b.windowBits===0&&(b.windowBits=-15)),!(0<=b.windowBits&&b.windowBits<16)||y&&y.windowBits||(b.windowBits+=32),15<b.windowBits&&b.windowBits<48&&(15&b.windowBits)==0&&(b.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,b.windowBits);if(v!==c.Z_OK)throw new Error(u[v]);this.header=new f,a.inflateGetHeader(this.strm,this.header)}function x(y,b){var v=new p(b);if(v.push(y,!0),v.err)throw v.msg||u[v.err];return v.result}p.prototype.push=function(y,b){var v,N,S,T,E,C,A=this.strm,O=this.options.chunkSize,k=this.options.dictionary,R=!1;if(this.ended)return!1;N=b===~~b?b:b===!0?c.Z_FINISH:c.Z_NO_FLUSH,typeof y=="string"?A.input=l.binstring2buf(y):m.call(y)==="[object ArrayBuffer]"?A.input=new Uint8Array(y):A.input=y,A.next_in=0,A.avail_in=A.input.length;do{if(A.avail_out===0&&(A.output=new o.Buf8(O),A.next_out=0,A.avail_out=O),(v=a.inflate(A,c.Z_NO_FLUSH))===c.Z_NEED_DICT&&k&&(C=typeof k=="string"?l.string2buf(k):m.call(k)==="[object ArrayBuffer]"?new Uint8Array(k):k,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);A.next_out&&(A.avail_out!==0&&v!==c.Z_STREAM_END&&(A.avail_in!==0||N!==c.Z_FINISH&&N!==c.Z_SYNC_FLUSH)||(this.options.to==="string"?(S=l.utf8border(A.output,A.next_out),T=A.next_out-S,E=l.buf2string(A.output,S),A.next_out=T,A.avail_out=O-T,T&&o.arraySet(A.output,A.output,S,T,0),this.onData(E)):this.onData(o.shrinkBuf(A.output,A.next_out)))),A.avail_in===0&&A.avail_out===0&&(R=!0)}while((0<A.avail_in||A.avail_out===0)&&v!==c.Z_STREAM_END);return v===c.Z_STREAM_END&&(N=c.Z_FINISH),N===c.Z_FINISH?(v=a.inflateEnd(this.strm),this.onEnd(v),this.ended=!0,v===c.Z_OK):N!==c.Z_SYNC_FLUSH||(this.onEnd(c.Z_OK),!(A.avail_out=0))},p.prototype.onData=function(y){this.chunks.push(y)},p.prototype.onEnd=function(y){y===c.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=o.flattenChunks(this.chunks)),this.chunks=[],this.err=y,this.msg=this.strm.msg},i.Inflate=p,i.inflate=x,i.inflateRaw=function(y,b){return(b=b||{}).raw=!0,x(y,b)},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,m){if(u.subarray&&c.subarray)c.set(u.subarray(d,d+f),m);else for(var p=0;p<f;p++)c[m+p]=u[d+p]},flattenChunks:function(c){var u,d,f,m,p,x;for(u=f=0,d=c.length;u<d;u++)f+=c[u].length;for(x=new Uint8Array(f),u=m=0,d=c.length;u<d;u++)p=c[u],x.set(p,m),m+=p.length;return x}},l={arraySet:function(c,u,d,f,m){for(var p=0;p<f;p++)c[m+p]=u[d+p]},flattenChunks:function(c){return[].concat.apply([],c)}};i.setTyped=function(c){c?(i.Buf8=Uint8Array,i.Buf16=Uint16Array,i.Buf32=Int32Array,i.assign(i,o)):(i.Buf8=Array,i.Buf16=Array,i.Buf32=Array,i.assign(i,l))},i.setTyped(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,m){if(m<65537&&(f.subarray&&l||!f.subarray&&o))return String.fromCharCode.apply(null,a.shrinkBuf(f,m));for(var p="",x=0;x<m;x++)p+=String.fromCharCode(f[x]);return p}c[254]=c[254]=1,i.string2buf=function(f){var m,p,x,y,b,v=f.length,N=0;for(y=0;y<v;y++)(64512&(p=f.charCodeAt(y)))==55296&&y+1<v&&(64512&(x=f.charCodeAt(y+1)))==56320&&(p=65536+(p-55296<<10)+(x-56320),y++),N+=p<128?1:p<2048?2:p<65536?3:4;for(m=new a.Buf8(N),y=b=0;b<N;y++)(64512&(p=f.charCodeAt(y)))==55296&&y+1<v&&(64512&(x=f.charCodeAt(y+1)))==56320&&(p=65536+(p-55296<<10)+(x-56320),y++),p<128?m[b++]=p:(p<2048?m[b++]=192|p>>>6:(p<65536?m[b++]=224|p>>>12:(m[b++]=240|p>>>18,m[b++]=128|p>>>12&63),m[b++]=128|p>>>6&63),m[b++]=128|63&p);return m},i.buf2binstring=function(f){return d(f,f.length)},i.binstring2buf=function(f){for(var m=new a.Buf8(f.length),p=0,x=m.length;p<x;p++)m[p]=f.charCodeAt(p);return m},i.buf2string=function(f,m){var p,x,y,b,v=m||f.length,N=new Array(2*v);for(p=x=0;p<v;)if((y=f[p++])<128)N[x++]=y;else if(4<(b=c[y]))N[x++]=65533,p+=b-1;else{for(y&=b===2?31:b===3?15:7;1<b&&p<v;)y=y<<6|63&f[p++],b--;1<b?N[x++]=65533:y<65536?N[x++]=y:(y-=65536,N[x++]=55296|y>>10&1023,N[x++]=56320|1023&y)}return d(N,x)},i.utf8border=function(f,m){var p;for((m=m||f.length)>f.length&&(m=f.length),p=m-1;0<=p&&(192&f[p])==128;)p--;return p<0||p===0?m:p+c[f[p]]>m?p:m}},{"./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 m=u;m<f;m++)o=o>>>8^d[255&(o^l[m])];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,m=4,p=0,x=-2,y=-1,b=4,v=2,N=8,S=9,T=286,E=30,C=19,A=2*T+1,O=15,k=3,R=258,F=R+k+1,L=42,K=113,j=1,W=2,Y=3,q=4;function Q(V,$){return V.msg=d[$],$}function ee(V){return(V<<1)-(4<V?9:0)}function re(V){for(var $=V.length;0<=--$;)V[$]=0}function z(V){var $=V.state,X=$.pending;X>V.avail_out&&(X=V.avail_out),X!==0&&(o.arraySet(V.output,$.pending_buf,$.pending_out,X,V.next_out),V.next_out+=X,$.pending_out+=X,V.total_out+=X,V.avail_out-=X,$.pending-=X,$.pending===0&&($.pending_out=0))}function G(V,$){l._tr_flush_block(V,0<=V.block_start?V.block_start:-1,V.strstart-V.block_start,$),V.block_start=V.strstart,z(V.strm)}function ae(V,$){V.pending_buf[V.pending++]=$}function se(V,$){V.pending_buf[V.pending++]=$>>>8&255,V.pending_buf[V.pending++]=255&$}function ue(V,$){var X,U,B=V.max_chain_length,oe=V.strstart,Te=V.prev_length,je=V.nice_match,Ce=V.strstart>V.w_size-F?V.strstart-(V.w_size-F):0,H=V.window,D=V.w_mask,Z=V.prev,xe=V.strstart+R,Ne=H[oe+Te-1],ve=H[oe+Te];V.prev_length>=V.good_match&&(B>>=2),je>V.lookahead&&(je=V.lookahead);do if(H[(X=$)+Te]===ve&&H[X+Te-1]===Ne&&H[X]===H[oe]&&H[++X]===H[oe+1]){oe+=2,X++;do;while(H[++oe]===H[++X]&&H[++oe]===H[++X]&&H[++oe]===H[++X]&&H[++oe]===H[++X]&&H[++oe]===H[++X]&&H[++oe]===H[++X]&&H[++oe]===H[++X]&&H[++oe]===H[++X]&&oe<xe);if(U=R-(xe-oe),oe=xe-R,Te<U){if(V.match_start=$,je<=(Te=U))break;Ne=H[oe+Te-1],ve=H[oe+Te]}}while(($=Z[$&D])>Ce&&--B!=0);return Te<=V.lookahead?Te:V.lookahead}function pe(V){var $,X,U,B,oe,Te,je,Ce,H,D,Z=V.w_size;do{if(B=V.window_size-V.lookahead-V.strstart,V.strstart>=Z+(Z-F)){for(o.arraySet(V.window,V.window,Z,Z,0),V.match_start-=Z,V.strstart-=Z,V.block_start-=Z,$=X=V.hash_size;U=V.head[--$],V.head[$]=Z<=U?U-Z:0,--X;);for($=X=Z;U=V.prev[--$],V.prev[$]=Z<=U?U-Z:0,--X;);B+=Z}if(V.strm.avail_in===0)break;if(Te=V.strm,je=V.window,Ce=V.strstart+V.lookahead,H=B,D=void 0,D=Te.avail_in,H<D&&(D=H),X=D===0?0:(Te.avail_in-=D,o.arraySet(je,Te.input,Te.next_in,D,Ce),Te.state.wrap===1?Te.adler=c(Te.adler,je,D,Ce):Te.state.wrap===2&&(Te.adler=u(Te.adler,je,D,Ce)),Te.next_in+=D,Te.total_in+=D,D),V.lookahead+=X,V.lookahead+V.insert>=k)for(oe=V.strstart-V.insert,V.ins_h=V.window[oe],V.ins_h=(V.ins_h<<V.hash_shift^V.window[oe+1])&V.hash_mask;V.insert&&(V.ins_h=(V.ins_h<<V.hash_shift^V.window[oe+k-1])&V.hash_mask,V.prev[oe&V.w_mask]=V.head[V.ins_h],V.head[V.ins_h]=oe,oe++,V.insert--,!(V.lookahead+V.insert<k)););}while(V.lookahead<F&&V.strm.avail_in!==0)}function ce(V,$){for(var X,U;;){if(V.lookahead<F){if(pe(V),V.lookahead<F&&$===f)return j;if(V.lookahead===0)break}if(X=0,V.lookahead>=k&&(V.ins_h=(V.ins_h<<V.hash_shift^V.window[V.strstart+k-1])&V.hash_mask,X=V.prev[V.strstart&V.w_mask]=V.head[V.ins_h],V.head[V.ins_h]=V.strstart),X!==0&&V.strstart-X<=V.w_size-F&&(V.match_length=ue(V,X)),V.match_length>=k)if(U=l._tr_tally(V,V.strstart-V.match_start,V.match_length-k),V.lookahead-=V.match_length,V.match_length<=V.max_lazy_match&&V.lookahead>=k){for(V.match_length--;V.strstart++,V.ins_h=(V.ins_h<<V.hash_shift^V.window[V.strstart+k-1])&V.hash_mask,X=V.prev[V.strstart&V.w_mask]=V.head[V.ins_h],V.head[V.ins_h]=V.strstart,--V.match_length!=0;);V.strstart++}else V.strstart+=V.match_length,V.match_length=0,V.ins_h=V.window[V.strstart],V.ins_h=(V.ins_h<<V.hash_shift^V.window[V.strstart+1])&V.hash_mask;else U=l._tr_tally(V,0,V.window[V.strstart]),V.lookahead--,V.strstart++;if(U&&(G(V,!1),V.strm.avail_out===0))return j}return V.insert=V.strstart<k-1?V.strstart:k-1,$===m?(G(V,!0),V.strm.avail_out===0?Y:q):V.last_lit&&(G(V,!1),V.strm.avail_out===0)?j:W}function Me(V,$){for(var X,U,B;;){if(V.lookahead<F){if(pe(V),V.lookahead<F&&$===f)return j;if(V.lookahead===0)break}if(X=0,V.lookahead>=k&&(V.ins_h=(V.ins_h<<V.hash_shift^V.window[V.strstart+k-1])&V.hash_mask,X=V.prev[V.strstart&V.w_mask]=V.head[V.ins_h],V.head[V.ins_h]=V.strstart),V.prev_length=V.match_length,V.prev_match=V.match_start,V.match_length=k-1,X!==0&&V.prev_length<V.max_lazy_match&&V.strstart-X<=V.w_size-F&&(V.match_length=ue(V,X),V.match_length<=5&&(V.strategy===1||V.match_length===k&&4096<V.strstart-V.match_start)&&(V.match_length=k-1)),V.prev_length>=k&&V.match_length<=V.prev_length){for(B=V.strstart+V.lookahead-k,U=l._tr_tally(V,V.strstart-1-V.prev_match,V.prev_length-k),V.lookahead-=V.prev_length-1,V.prev_length-=2;++V.strstart<=B&&(V.ins_h=(V.ins_h<<V.hash_shift^V.window[V.strstart+k-1])&V.hash_mask,X=V.prev[V.strstart&V.w_mask]=V.head[V.ins_h],V.head[V.ins_h]=V.strstart),--V.prev_length!=0;);if(V.match_available=0,V.match_length=k-1,V.strstart++,U&&(G(V,!1),V.strm.avail_out===0))return j}else if(V.match_available){if((U=l._tr_tally(V,0,V.window[V.strstart-1]))&&G(V,!1),V.strstart++,V.lookahead--,V.strm.avail_out===0)return j}else V.match_available=1,V.strstart++,V.lookahead--}return V.match_available&&(U=l._tr_tally(V,0,V.window[V.strstart-1]),V.match_available=0),V.insert=V.strstart<k-1?V.strstart:k-1,$===m?(G(V,!0),V.strm.avail_out===0?Y:q):V.last_lit&&(G(V,!1),V.strm.avail_out===0)?j:W}function me(V,$,X,U,B){this.good_length=V,this.max_lazy=$,this.nice_length=X,this.max_chain=U,this.func=B}function Ee(){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=N,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*A),this.dyn_dtree=new o.Buf16(2*(2*E+1)),this.bl_tree=new o.Buf16(2*(2*C+1)),re(this.dyn_ltree),re(this.dyn_dtree),re(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new o.Buf16(O+1),this.heap=new o.Buf16(2*T+1),re(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new o.Buf16(2*T+1),re(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function fe(V){var $;return V&&V.state?(V.total_in=V.total_out=0,V.data_type=v,($=V.state).pending=0,$.pending_out=0,$.wrap<0&&($.wrap=-$.wrap),$.status=$.wrap?L:K,V.adler=$.wrap===2?0:1,$.last_flush=f,l._tr_init($),p):Q(V,x)}function le(V){var $=fe(V);return $===p&&(function(X){X.window_size=2*X.w_size,re(X.head),X.max_lazy_match=a[X.level].max_lazy,X.good_match=a[X.level].good_length,X.nice_match=a[X.level].nice_length,X.max_chain_length=a[X.level].max_chain,X.strstart=0,X.block_start=0,X.lookahead=0,X.insert=0,X.match_length=X.prev_length=k-1,X.match_available=0,X.ins_h=0})(V.state),$}function Be(V,$,X,U,B,oe){if(!V)return x;var Te=1;if($===y&&($=6),U<0?(Te=0,U=-U):15<U&&(Te=2,U-=16),B<1||S<B||X!==N||U<8||15<U||$<0||9<$||oe<0||b<oe)return Q(V,x);U===8&&(U=9);var je=new Ee;return(V.state=je).strm=V,je.wrap=Te,je.gzhead=null,je.w_bits=U,je.w_size=1<<je.w_bits,je.w_mask=je.w_size-1,je.hash_bits=B+7,je.hash_size=1<<je.hash_bits,je.hash_mask=je.hash_size-1,je.hash_shift=~~((je.hash_bits+k-1)/k),je.window=new o.Buf8(2*je.w_size),je.head=new o.Buf16(je.hash_size),je.prev=new o.Buf16(je.w_size),je.lit_bufsize=1<<B+6,je.pending_buf_size=4*je.lit_bufsize,je.pending_buf=new o.Buf8(je.pending_buf_size),je.d_buf=1*je.lit_bufsize,je.l_buf=3*je.lit_bufsize,je.level=$,je.strategy=oe,je.method=X,le(V)}a=[new me(0,0,0,0,function(V,$){var X=65535;for(X>V.pending_buf_size-5&&(X=V.pending_buf_size-5);;){if(V.lookahead<=1){if(pe(V),V.lookahead===0&&$===f)return j;if(V.lookahead===0)break}V.strstart+=V.lookahead,V.lookahead=0;var U=V.block_start+X;if((V.strstart===0||V.strstart>=U)&&(V.lookahead=V.strstart-U,V.strstart=U,G(V,!1),V.strm.avail_out===0)||V.strstart-V.block_start>=V.w_size-F&&(G(V,!1),V.strm.avail_out===0))return j}return V.insert=0,$===m?(G(V,!0),V.strm.avail_out===0?Y:q):(V.strstart>V.block_start&&(G(V,!1),V.strm.avail_out),j)}),new me(4,4,8,4,ce),new me(4,5,16,8,ce),new me(4,6,32,32,ce),new me(4,4,16,16,Me),new me(8,16,32,32,Me),new me(8,16,128,128,Me),new me(8,32,128,256,Me),new me(32,128,258,1024,Me),new me(32,258,258,4096,Me)],i.deflateInit=function(V,$){return Be(V,$,N,15,8,0)},i.deflateInit2=Be,i.deflateReset=le,i.deflateResetKeep=fe,i.deflateSetHeader=function(V,$){return V&&V.state?V.state.wrap!==2?x:(V.state.gzhead=$,p):x},i.deflate=function(V,$){var X,U,B,oe;if(!V||!V.state||5<$||$<0)return V?Q(V,x):x;if(U=V.state,!V.output||!V.input&&V.avail_in!==0||U.status===666&&$!==m)return Q(V,V.avail_out===0?-5:x);if(U.strm=V,X=U.last_flush,U.last_flush=$,U.status===L)if(U.wrap===2)V.adler=0,ae(U,31),ae(U,139),ae(U,8),U.gzhead?(ae(U,(U.gzhead.text?1:0)+(U.gzhead.hcrc?2:0)+(U.gzhead.extra?4:0)+(U.gzhead.name?8:0)+(U.gzhead.comment?16:0)),ae(U,255&U.gzhead.time),ae(U,U.gzhead.time>>8&255),ae(U,U.gzhead.time>>16&255),ae(U,U.gzhead.time>>24&255),ae(U,U.level===9?2:2<=U.strategy||U.level<2?4:0),ae(U,255&U.gzhead.os),U.gzhead.extra&&U.gzhead.extra.length&&(ae(U,255&U.gzhead.extra.length),ae(U,U.gzhead.extra.length>>8&255)),U.gzhead.hcrc&&(V.adler=u(V.adler,U.pending_buf,U.pending,0)),U.gzindex=0,U.status=69):(ae(U,0),ae(U,0),ae(U,0),ae(U,0),ae(U,0),ae(U,U.level===9?2:2<=U.strategy||U.level<2?4:0),ae(U,3),U.status=K);else{var Te=N+(U.w_bits-8<<4)<<8;Te|=(2<=U.strategy||U.level<2?0:U.level<6?1:U.level===6?2:3)<<6,U.strstart!==0&&(Te|=32),Te+=31-Te%31,U.status=K,se(U,Te),U.strstart!==0&&(se(U,V.adler>>>16),se(U,65535&V.adler)),V.adler=1}if(U.status===69)if(U.gzhead.extra){for(B=U.pending;U.gzindex<(65535&U.gzhead.extra.length)&&(U.pending!==U.pending_buf_size||(U.gzhead.hcrc&&U.pending>B&&(V.adler=u(V.adler,U.pending_buf,U.pending-B,B)),z(V),B=U.pending,U.pending!==U.pending_buf_size));)ae(U,255&U.gzhead.extra[U.gzindex]),U.gzindex++;U.gzhead.hcrc&&U.pending>B&&(V.adler=u(V.adler,U.pending_buf,U.pending-B,B)),U.gzindex===U.gzhead.extra.length&&(U.gzindex=0,U.status=73)}else U.status=73;if(U.status===73)if(U.gzhead.name){B=U.pending;do{if(U.pending===U.pending_buf_size&&(U.gzhead.hcrc&&U.pending>B&&(V.adler=u(V.adler,U.pending_buf,U.pending-B,B)),z(V),B=U.pending,U.pending===U.pending_buf_size)){oe=1;break}oe=U.gzindex<U.gzhead.name.length?255&U.gzhead.name.charCodeAt(U.gzindex++):0,ae(U,oe)}while(oe!==0);U.gzhead.hcrc&&U.pending>B&&(V.adler=u(V.adler,U.pending_buf,U.pending-B,B)),oe===0&&(U.gzindex=0,U.status=91)}else U.status=91;if(U.status===91)if(U.gzhead.comment){B=U.pending;do{if(U.pending===U.pending_buf_size&&(U.gzhead.hcrc&&U.pending>B&&(V.adler=u(V.adler,U.pending_buf,U.pending-B,B)),z(V),B=U.pending,U.pending===U.pending_buf_size)){oe=1;break}oe=U.gzindex<U.gzhead.comment.length?255&U.gzhead.comment.charCodeAt(U.gzindex++):0,ae(U,oe)}while(oe!==0);U.gzhead.hcrc&&U.pending>B&&(V.adler=u(V.adler,U.pending_buf,U.pending-B,B)),oe===0&&(U.status=103)}else U.status=103;if(U.status===103&&(U.gzhead.hcrc?(U.pending+2>U.pending_buf_size&&z(V),U.pending+2<=U.pending_buf_size&&(ae(U,255&V.adler),ae(U,V.adler>>8&255),V.adler=0,U.status=K)):U.status=K),U.pending!==0){if(z(V),V.avail_out===0)return U.last_flush=-1,p}else if(V.avail_in===0&&ee($)<=ee(X)&&$!==m)return Q(V,-5);if(U.status===666&&V.avail_in!==0)return Q(V,-5);if(V.avail_in!==0||U.lookahead!==0||$!==f&&U.status!==666){var je=U.strategy===2?(function(Ce,H){for(var D;;){if(Ce.lookahead===0&&(pe(Ce),Ce.lookahead===0)){if(H===f)return j;break}if(Ce.match_length=0,D=l._tr_tally(Ce,0,Ce.window[Ce.strstart]),Ce.lookahead--,Ce.strstart++,D&&(G(Ce,!1),Ce.strm.avail_out===0))return j}return Ce.insert=0,H===m?(G(Ce,!0),Ce.strm.avail_out===0?Y:q):Ce.last_lit&&(G(Ce,!1),Ce.strm.avail_out===0)?j:W})(U,$):U.strategy===3?(function(Ce,H){for(var D,Z,xe,Ne,ve=Ce.window;;){if(Ce.lookahead<=R){if(pe(Ce),Ce.lookahead<=R&&H===f)return j;if(Ce.lookahead===0)break}if(Ce.match_length=0,Ce.lookahead>=k&&0<Ce.strstart&&(Z=ve[xe=Ce.strstart-1])===ve[++xe]&&Z===ve[++xe]&&Z===ve[++xe]){Ne=Ce.strstart+R;do;while(Z===ve[++xe]&&Z===ve[++xe]&&Z===ve[++xe]&&Z===ve[++xe]&&Z===ve[++xe]&&Z===ve[++xe]&&Z===ve[++xe]&&Z===ve[++xe]&&xe<Ne);Ce.match_length=R-(Ne-xe),Ce.match_length>Ce.lookahead&&(Ce.match_length=Ce.lookahead)}if(Ce.match_length>=k?(D=l._tr_tally(Ce,1,Ce.match_length-k),Ce.lookahead-=Ce.match_length,Ce.strstart+=Ce.match_length,Ce.match_length=0):(D=l._tr_tally(Ce,0,Ce.window[Ce.strstart]),Ce.lookahead--,Ce.strstart++),D&&(G(Ce,!1),Ce.strm.avail_out===0))return j}return Ce.insert=0,H===m?(G(Ce,!0),Ce.strm.avail_out===0?Y:q):Ce.last_lit&&(G(Ce,!1),Ce.strm.avail_out===0)?j:W})(U,$):a[U.level].func(U,$);if(je!==Y&&je!==q||(U.status=666),je===j||je===Y)return V.avail_out===0&&(U.last_flush=-1),p;if(je===W&&($===1?l._tr_align(U):$!==5&&(l._tr_stored_block(U,0,0,!1),$===3&&(re(U.head),U.lookahead===0&&(U.strstart=0,U.block_start=0,U.insert=0))),z(V),V.avail_out===0))return U.last_flush=-1,p}return $!==m?p:U.wrap<=0?1:(U.wrap===2?(ae(U,255&V.adler),ae(U,V.adler>>8&255),ae(U,V.adler>>16&255),ae(U,V.adler>>24&255),ae(U,255&V.total_in),ae(U,V.total_in>>8&255),ae(U,V.total_in>>16&255),ae(U,V.total_in>>24&255)):(se(U,V.adler>>>16),se(U,65535&V.adler)),z(V),0<U.wrap&&(U.wrap=-U.wrap),U.pending!==0?p:1)},i.deflateEnd=function(V){var $;return V&&V.state?($=V.state.status)!==L&&$!==69&&$!==73&&$!==91&&$!==103&&$!==K&&$!==666?Q(V,x):(V.state=null,$===K?Q(V,-3):p):x},i.deflateSetDictionary=function(V,$){var X,U,B,oe,Te,je,Ce,H,D=$.length;if(!V||!V.state||(oe=(X=V.state).wrap)===2||oe===1&&X.status!==L||X.lookahead)return x;for(oe===1&&(V.adler=c(V.adler,$,D,0)),X.wrap=0,D>=X.w_size&&(oe===0&&(re(X.head),X.strstart=0,X.block_start=0,X.insert=0),H=new o.Buf8(X.w_size),o.arraySet(H,$,D-X.w_size,X.w_size,0),$=H,D=X.w_size),Te=V.avail_in,je=V.next_in,Ce=V.input,V.avail_in=D,V.next_in=0,V.input=$,pe(X);X.lookahead>=k;){for(U=X.strstart,B=X.lookahead-(k-1);X.ins_h=(X.ins_h<<X.hash_shift^X.window[U+k-1])&X.hash_mask,X.prev[U&X.w_mask]=X.head[X.ins_h],X.head[X.ins_h]=U,U++,--B;);X.strstart=U,X.lookahead=k-1,pe(X)}return X.strstart+=X.lookahead,X.block_start=X.strstart,X.insert=X.lookahead,X.lookahead=0,X.match_length=X.prev_length=k-1,X.match_available=0,V.next_in=je,V.input=Ce,V.avail_in=Te,X.wrap=oe,p},i.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(n,r,i){r.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(n,r,i){r.exports=function(a,o){var l,c,u,d,f,m,p,x,y,b,v,N,S,T,E,C,A,O,k,R,F,L,K,j,W;l=a.state,c=a.next_in,j=a.input,u=c+(a.avail_in-5),d=a.next_out,W=a.output,f=d-(o-a.avail_out),m=d+(a.avail_out-257),p=l.dmax,x=l.wsize,y=l.whave,b=l.wnext,v=l.window,N=l.hold,S=l.bits,T=l.lencode,E=l.distcode,C=(1<<l.lenbits)-1,A=(1<<l.distbits)-1;e:do{S<15&&(N+=j[c++]<<S,S+=8,N+=j[c++]<<S,S+=8),O=T[N&C];t:for(;;){if(N>>>=k=O>>>24,S-=k,(k=O>>>16&255)===0)W[d++]=65535&O;else{if(!(16&k)){if((64&k)==0){O=T[(65535&O)+(N&(1<<k)-1)];continue t}if(32&k){l.mode=12;break e}a.msg="invalid literal/length code",l.mode=30;break e}R=65535&O,(k&=15)&&(S<k&&(N+=j[c++]<<S,S+=8),R+=N&(1<<k)-1,N>>>=k,S-=k),S<15&&(N+=j[c++]<<S,S+=8,N+=j[c++]<<S,S+=8),O=E[N&A];n:for(;;){if(N>>>=k=O>>>24,S-=k,!(16&(k=O>>>16&255))){if((64&k)==0){O=E[(65535&O)+(N&(1<<k)-1)];continue n}a.msg="invalid distance code",l.mode=30;break e}if(F=65535&O,S<(k&=15)&&(N+=j[c++]<<S,(S+=8)<k&&(N+=j[c++]<<S,S+=8)),p<(F+=N&(1<<k)-1)){a.msg="invalid distance too far back",l.mode=30;break e}if(N>>>=k,S-=k,(k=d-f)<F){if(y<(k=F-k)&&l.sane){a.msg="invalid distance too far back",l.mode=30;break e}if(K=v,(L=0)===b){if(L+=x-k,k<R){for(R-=k;W[d++]=v[L++],--k;);L=d-F,K=W}}else if(b<k){if(L+=x+b-k,(k-=b)<R){for(R-=k;W[d++]=v[L++],--k;);if(L=0,b<R){for(R-=k=b;W[d++]=v[L++],--k;);L=d-F,K=W}}}else if(L+=b-k,k<R){for(R-=k;W[d++]=v[L++],--k;);L=d-F,K=W}for(;2<R;)W[d++]=K[L++],W[d++]=K[L++],W[d++]=K[L++],R-=3;R&&(W[d++]=K[L++],1<R&&(W[d++]=K[L++]))}else{for(L=d-F;W[d++]=W[L++],W[d++]=W[L++],W[d++]=W[L++],2<(R-=3););R&&(W[d++]=W[L++],1<R&&(W[d++]=W[L++]))}break}}break}}while(c<u&&d<m);c-=R=S>>3,N&=(1<<(S-=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<m?m-d+257:257-(d-m),l.hold=N,l.bits=S}},{}],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,m=0,p=-2,x=1,y=852,b=592;function v(L){return(L>>>24&255)+(L>>>8&65280)+((65280&L)<<8)+((255&L)<<24)}function N(){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 S(L){var K;return L&&L.state?(K=L.state,L.total_in=L.total_out=K.total=0,L.msg="",K.wrap&&(L.adler=1&K.wrap),K.mode=x,K.last=0,K.havedict=0,K.dmax=32768,K.head=null,K.hold=0,K.bits=0,K.lencode=K.lendyn=new a.Buf32(y),K.distcode=K.distdyn=new a.Buf32(b),K.sane=1,K.back=-1,m):p}function T(L){var K;return L&&L.state?((K=L.state).wsize=0,K.whave=0,K.wnext=0,S(L)):p}function E(L,K){var j,W;return L&&L.state?(W=L.state,K<0?(j=0,K=-K):(j=1+(K>>4),K<48&&(K&=15)),K&&(K<8||15<K)?p:(W.window!==null&&W.wbits!==K&&(W.window=null),W.wrap=j,W.wbits=K,T(L))):p}function C(L,K){var j,W;return L?(W=new N,(L.state=W).window=null,(j=E(L,K))!==m&&(L.state=null),j):p}var A,O,k=!0;function R(L){if(k){var K;for(A=new a.Buf32(512),O=new a.Buf32(32),K=0;K<144;)L.lens[K++]=8;for(;K<256;)L.lens[K++]=9;for(;K<280;)L.lens[K++]=7;for(;K<288;)L.lens[K++]=8;for(u(d,L.lens,0,288,A,0,L.work,{bits:9}),K=0;K<32;)L.lens[K++]=5;u(f,L.lens,0,32,O,0,L.work,{bits:5}),k=!1}L.lencode=A,L.lenbits=9,L.distcode=O,L.distbits=5}function F(L,K,j,W){var Y,q=L.state;return q.window===null&&(q.wsize=1<<q.wbits,q.wnext=0,q.whave=0,q.window=new a.Buf8(q.wsize)),W>=q.wsize?(a.arraySet(q.window,K,j-q.wsize,q.wsize,0),q.wnext=0,q.whave=q.wsize):(W<(Y=q.wsize-q.wnext)&&(Y=W),a.arraySet(q.window,K,j-W,Y,q.wnext),(W-=Y)?(a.arraySet(q.window,K,j-W,W,0),q.wnext=W,q.whave=q.wsize):(q.wnext+=Y,q.wnext===q.wsize&&(q.wnext=0),q.whave<q.wsize&&(q.whave+=Y))),0}i.inflateReset=T,i.inflateReset2=E,i.inflateResetKeep=S,i.inflateInit=function(L){return C(L,15)},i.inflateInit2=C,i.inflate=function(L,K){var j,W,Y,q,Q,ee,re,z,G,ae,se,ue,pe,ce,Me,me,Ee,fe,le,Be,V,$,X,U,B=0,oe=new a.Buf8(4),Te=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!L||!L.state||!L.output||!L.input&&L.avail_in!==0)return p;(j=L.state).mode===12&&(j.mode=13),Q=L.next_out,Y=L.output,re=L.avail_out,q=L.next_in,W=L.input,ee=L.avail_in,z=j.hold,G=j.bits,ae=ee,se=re,$=m;e:for(;;)switch(j.mode){case x:if(j.wrap===0){j.mode=13;break}for(;G<16;){if(ee===0)break e;ee--,z+=W[q++]<<G,G+=8}if(2&j.wrap&&z===35615){oe[j.check=0]=255&z,oe[1]=z>>>8&255,j.check=l(j.check,oe,2,0),G=z=0,j.mode=2;break}if(j.flags=0,j.head&&(j.head.done=!1),!(1&j.wrap)||(((255&z)<<8)+(z>>8))%31){L.msg="incorrect header check",j.mode=30;break}if((15&z)!=8){L.msg="unknown compression method",j.mode=30;break}if(G-=4,V=8+(15&(z>>>=4)),j.wbits===0)j.wbits=V;else if(V>j.wbits){L.msg="invalid window size",j.mode=30;break}j.dmax=1<<V,L.adler=j.check=1,j.mode=512&z?10:12,G=z=0;break;case 2:for(;G<16;){if(ee===0)break e;ee--,z+=W[q++]<<G,G+=8}if(j.flags=z,(255&j.flags)!=8){L.msg="unknown compression method",j.mode=30;break}if(57344&j.flags){L.msg="unknown header flags set",j.mode=30;break}j.head&&(j.head.text=z>>8&1),512&j.flags&&(oe[0]=255&z,oe[1]=z>>>8&255,j.check=l(j.check,oe,2,0)),G=z=0,j.mode=3;case 3:for(;G<32;){if(ee===0)break e;ee--,z+=W[q++]<<G,G+=8}j.head&&(j.head.time=z),512&j.flags&&(oe[0]=255&z,oe[1]=z>>>8&255,oe[2]=z>>>16&255,oe[3]=z>>>24&255,j.check=l(j.check,oe,4,0)),G=z=0,j.mode=4;case 4:for(;G<16;){if(ee===0)break e;ee--,z+=W[q++]<<G,G+=8}j.head&&(j.head.xflags=255&z,j.head.os=z>>8),512&j.flags&&(oe[0]=255&z,oe[1]=z>>>8&255,j.check=l(j.check,oe,2,0)),G=z=0,j.mode=5;case 5:if(1024&j.flags){for(;G<16;){if(ee===0)break e;ee--,z+=W[q++]<<G,G+=8}j.length=z,j.head&&(j.head.extra_len=z),512&j.flags&&(oe[0]=255&z,oe[1]=z>>>8&255,j.check=l(j.check,oe,2,0)),G=z=0}else j.head&&(j.head.extra=null);j.mode=6;case 6:if(1024&j.flags&&(ee<(ue=j.length)&&(ue=ee),ue&&(j.head&&(V=j.head.extra_len-j.length,j.head.extra||(j.head.extra=new Array(j.head.extra_len)),a.arraySet(j.head.extra,W,q,ue,V)),512&j.flags&&(j.check=l(j.check,W,ue,q)),ee-=ue,q+=ue,j.length-=ue),j.length))break e;j.length=0,j.mode=7;case 7:if(2048&j.flags){if(ee===0)break e;for(ue=0;V=W[q+ue++],j.head&&V&&j.length<65536&&(j.head.name+=String.fromCharCode(V)),V&&ue<ee;);if(512&j.flags&&(j.check=l(j.check,W,ue,q)),ee-=ue,q+=ue,V)break e}else j.head&&(j.head.name=null);j.length=0,j.mode=8;case 8:if(4096&j.flags){if(ee===0)break e;for(ue=0;V=W[q+ue++],j.head&&V&&j.length<65536&&(j.head.comment+=String.fromCharCode(V)),V&&ue<ee;);if(512&j.flags&&(j.check=l(j.check,W,ue,q)),ee-=ue,q+=ue,V)break e}else j.head&&(j.head.comment=null);j.mode=9;case 9:if(512&j.flags){for(;G<16;){if(ee===0)break e;ee--,z+=W[q++]<<G,G+=8}if(z!==(65535&j.check)){L.msg="header crc mismatch",j.mode=30;break}G=z=0}j.head&&(j.head.hcrc=j.flags>>9&1,j.head.done=!0),L.adler=j.check=0,j.mode=12;break;case 10:for(;G<32;){if(ee===0)break e;ee--,z+=W[q++]<<G,G+=8}L.adler=j.check=v(z),G=z=0,j.mode=11;case 11:if(j.havedict===0)return L.next_out=Q,L.avail_out=re,L.next_in=q,L.avail_in=ee,j.hold=z,j.bits=G,2;L.adler=j.check=1,j.mode=12;case 12:if(K===5||K===6)break e;case 13:if(j.last){z>>>=7&G,G-=7&G,j.mode=27;break}for(;G<3;){if(ee===0)break e;ee--,z+=W[q++]<<G,G+=8}switch(j.last=1&z,G-=1,3&(z>>>=1)){case 0:j.mode=14;break;case 1:if(R(j),j.mode=20,K!==6)break;z>>>=2,G-=2;break e;case 2:j.mode=17;break;case 3:L.msg="invalid block type",j.mode=30}z>>>=2,G-=2;break;case 14:for(z>>>=7&G,G-=7&G;G<32;){if(ee===0)break e;ee--,z+=W[q++]<<G,G+=8}if((65535&z)!=(z>>>16^65535)){L.msg="invalid stored block lengths",j.mode=30;break}if(j.length=65535&z,G=z=0,j.mode=15,K===6)break e;case 15:j.mode=16;case 16:if(ue=j.length){if(ee<ue&&(ue=ee),re<ue&&(ue=re),ue===0)break e;a.arraySet(Y,W,q,ue,Q),ee-=ue,q+=ue,re-=ue,Q+=ue,j.length-=ue;break}j.mode=12;break;case 17:for(;G<14;){if(ee===0)break e;ee--,z+=W[q++]<<G,G+=8}if(j.nlen=257+(31&z),z>>>=5,G-=5,j.ndist=1+(31&z),z>>>=5,G-=5,j.ncode=4+(15&z),z>>>=4,G-=4,286<j.nlen||30<j.ndist){L.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(;G<3;){if(ee===0)break e;ee--,z+=W[q++]<<G,G+=8}j.lens[Te[j.have++]]=7&z,z>>>=3,G-=3}for(;j.have<19;)j.lens[Te[j.have++]]=0;if(j.lencode=j.lendyn,j.lenbits=7,X={bits:j.lenbits},$=u(0,j.lens,0,19,j.lencode,0,j.work,X),j.lenbits=X.bits,$){L.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(;me=(B=j.lencode[z&(1<<j.lenbits)-1])>>>16&255,Ee=65535&B,!((Me=B>>>24)<=G);){if(ee===0)break e;ee--,z+=W[q++]<<G,G+=8}if(Ee<16)z>>>=Me,G-=Me,j.lens[j.have++]=Ee;else{if(Ee===16){for(U=Me+2;G<U;){if(ee===0)break e;ee--,z+=W[q++]<<G,G+=8}if(z>>>=Me,G-=Me,j.have===0){L.msg="invalid bit length repeat",j.mode=30;break}V=j.lens[j.have-1],ue=3+(3&z),z>>>=2,G-=2}else if(Ee===17){for(U=Me+3;G<U;){if(ee===0)break e;ee--,z+=W[q++]<<G,G+=8}G-=Me,V=0,ue=3+(7&(z>>>=Me)),z>>>=3,G-=3}else{for(U=Me+7;G<U;){if(ee===0)break e;ee--,z+=W[q++]<<G,G+=8}G-=Me,V=0,ue=11+(127&(z>>>=Me)),z>>>=7,G-=7}if(j.have+ue>j.nlen+j.ndist){L.msg="invalid bit length repeat",j.mode=30;break}for(;ue--;)j.lens[j.have++]=V}}if(j.mode===30)break;if(j.lens[256]===0){L.msg="invalid code -- missing end-of-block",j.mode=30;break}if(j.lenbits=9,X={bits:j.lenbits},$=u(d,j.lens,0,j.nlen,j.lencode,0,j.work,X),j.lenbits=X.bits,$){L.msg="invalid literal/lengths set",j.mode=30;break}if(j.distbits=6,j.distcode=j.distdyn,X={bits:j.distbits},$=u(f,j.lens,j.nlen,j.ndist,j.distcode,0,j.work,X),j.distbits=X.bits,$){L.msg="invalid distances set",j.mode=30;break}if(j.mode=20,K===6)break e;case 20:j.mode=21;case 21:if(6<=ee&&258<=re){L.next_out=Q,L.avail_out=re,L.next_in=q,L.avail_in=ee,j.hold=z,j.bits=G,c(L,se),Q=L.next_out,Y=L.output,re=L.avail_out,q=L.next_in,W=L.input,ee=L.avail_in,z=j.hold,G=j.bits,j.mode===12&&(j.back=-1);break}for(j.back=0;me=(B=j.lencode[z&(1<<j.lenbits)-1])>>>16&255,Ee=65535&B,!((Me=B>>>24)<=G);){if(ee===0)break e;ee--,z+=W[q++]<<G,G+=8}if(me&&(240&me)==0){for(fe=Me,le=me,Be=Ee;me=(B=j.lencode[Be+((z&(1<<fe+le)-1)>>fe)])>>>16&255,Ee=65535&B,!(fe+(Me=B>>>24)<=G);){if(ee===0)break e;ee--,z+=W[q++]<<G,G+=8}z>>>=fe,G-=fe,j.back+=fe}if(z>>>=Me,G-=Me,j.back+=Me,j.length=Ee,me===0){j.mode=26;break}if(32&me){j.back=-1,j.mode=12;break}if(64&me){L.msg="invalid literal/length code",j.mode=30;break}j.extra=15&me,j.mode=22;case 22:if(j.extra){for(U=j.extra;G<U;){if(ee===0)break e;ee--,z+=W[q++]<<G,G+=8}j.length+=z&(1<<j.extra)-1,z>>>=j.extra,G-=j.extra,j.back+=j.extra}j.was=j.length,j.mode=23;case 23:for(;me=(B=j.distcode[z&(1<<j.distbits)-1])>>>16&255,Ee=65535&B,!((Me=B>>>24)<=G);){if(ee===0)break e;ee--,z+=W[q++]<<G,G+=8}if((240&me)==0){for(fe=Me,le=me,Be=Ee;me=(B=j.distcode[Be+((z&(1<<fe+le)-1)>>fe)])>>>16&255,Ee=65535&B,!(fe+(Me=B>>>24)<=G);){if(ee===0)break e;ee--,z+=W[q++]<<G,G+=8}z>>>=fe,G-=fe,j.back+=fe}if(z>>>=Me,G-=Me,j.back+=Me,64&me){L.msg="invalid distance code",j.mode=30;break}j.offset=Ee,j.extra=15&me,j.mode=24;case 24:if(j.extra){for(U=j.extra;G<U;){if(ee===0)break e;ee--,z+=W[q++]<<G,G+=8}j.offset+=z&(1<<j.extra)-1,z>>>=j.extra,G-=j.extra,j.back+=j.extra}if(j.offset>j.dmax){L.msg="invalid distance too far back",j.mode=30;break}j.mode=25;case 25:if(re===0)break e;if(ue=se-re,j.offset>ue){if((ue=j.offset-ue)>j.whave&&j.sane){L.msg="invalid distance too far back",j.mode=30;break}pe=ue>j.wnext?(ue-=j.wnext,j.wsize-ue):j.wnext-ue,ue>j.length&&(ue=j.length),ce=j.window}else ce=Y,pe=Q-j.offset,ue=j.length;for(re<ue&&(ue=re),re-=ue,j.length-=ue;Y[Q++]=ce[pe++],--ue;);j.length===0&&(j.mode=21);break;case 26:if(re===0)break e;Y[Q++]=j.length,re--,j.mode=21;break;case 27:if(j.wrap){for(;G<32;){if(ee===0)break e;ee--,z|=W[q++]<<G,G+=8}if(se-=re,L.total_out+=se,j.total+=se,se&&(L.adler=j.check=j.flags?l(j.check,Y,se,Q-se):o(j.check,Y,se,Q-se)),se=re,(j.flags?z:v(z))!==j.check){L.msg="incorrect data check",j.mode=30;break}G=z=0}j.mode=28;case 28:if(j.wrap&&j.flags){for(;G<32;){if(ee===0)break e;ee--,z+=W[q++]<<G,G+=8}if(z!==(4294967295&j.total)){L.msg="incorrect length check",j.mode=30;break}G=z=0}j.mode=29;case 29:$=1;break e;case 30:$=-3;break e;case 31:return-4;case 32:default:return p}return L.next_out=Q,L.avail_out=re,L.next_in=q,L.avail_in=ee,j.hold=z,j.bits=G,(j.wsize||se!==L.avail_out&&j.mode<30&&(j.mode<27||K!==4))&&F(L,L.output,L.next_out,se-L.avail_out)?(j.mode=31,-4):(ae-=L.avail_in,se-=L.avail_out,L.total_in+=ae,L.total_out+=se,j.total+=se,j.wrap&&se&&(L.adler=j.check=j.flags?l(j.check,Y,se,L.next_out-se):o(j.check,Y,se,L.next_out-se)),L.data_type=j.bits+(j.last?64:0)+(j.mode===12?128:0)+(j.mode===20||j.mode===15?256:0),(ae==0&&se===0||K===4)&&$===m&&($=-5),$)},i.inflateEnd=function(L){if(!L||!L.state)return p;var K=L.state;return K.window&&(K.window=null),L.state=null,m},i.inflateGetHeader=function(L,K){var j;return L&&L.state?(2&(j=L.state).wrap)==0?p:((j.head=K).done=!1,m):p},i.inflateSetDictionary=function(L,K){var j,W=K.length;return L&&L.state?(j=L.state).wrap!==0&&j.mode!==11?p:j.mode===11&&o(1,K,W,0)!==j.check?-3:F(L,K,W,W)?(j.mode=31,-4):(j.havedict=1,m):p},i.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(n,r,i){var 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,m,p,x,y,b,v){var N,S,T,E,C,A,O,k,R,F=v.bits,L=0,K=0,j=0,W=0,Y=0,q=0,Q=0,ee=0,re=0,z=0,G=null,ae=0,se=new a.Buf16(16),ue=new a.Buf16(16),pe=null,ce=0;for(L=0;L<=15;L++)se[L]=0;for(K=0;K<p;K++)se[f[m+K]]++;for(Y=F,W=15;1<=W&&se[W]===0;W--);if(W<Y&&(Y=W),W===0)return x[y++]=20971520,x[y++]=20971520,v.bits=1,0;for(j=1;j<W&&se[j]===0;j++);for(Y<j&&(Y=j),L=ee=1;L<=15;L++)if(ee<<=1,(ee-=se[L])<0)return-1;if(0<ee&&(d===0||W!==1))return-1;for(ue[1]=0,L=1;L<15;L++)ue[L+1]=ue[L]+se[L];for(K=0;K<p;K++)f[m+K]!==0&&(b[ue[f[m+K]]++]=K);if(A=d===0?(G=pe=b,19):d===1?(G=o,ae-=257,pe=l,ce-=257,256):(G=c,pe=u,-1),L=j,C=y,Q=K=z=0,T=-1,E=(re=1<<(q=Y))-1,d===1&&852<re||d===2&&592<re)return 1;for(;;){for(O=L-Q,R=b[K]<A?(k=0,b[K]):b[K]>A?(k=pe[ce+b[K]],G[ae+b[K]]):(k=96,0),N=1<<L-Q,j=S=1<<q;x[C+(z>>Q)+(S-=N)]=O<<24|k<<16|R|0,S!==0;);for(N=1<<L-1;z&N;)N>>=1;if(N!==0?(z&=N-1,z+=N):z=0,K++,--se[L]==0){if(L===W)break;L=f[m+b[K]]}if(Y<L&&(z&E)!==T){for(Q===0&&(Q=Y),C+=j,ee=1<<(q=L-Q);q+Q<W&&!((ee-=se[q+Q])<=0);)q++,ee<<=1;if(re+=1<<q,d===1&&852<re||d===2&&592<re)return 1;x[T=z&E]=Y<<24|q<<16|C-y|0}}return z!==0&&(x[C+z]=L-Q<<24|64<<16|0),v.bits=Y,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(B){for(var oe=B.length;0<=--oe;)B[oe]=0}var u=0,d=29,f=256,m=f+1+d,p=30,x=19,y=2*m+1,b=15,v=16,N=7,S=256,T=16,E=17,C=18,A=[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],O=[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],k=[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],F=new Array(2*(m+2));c(F);var L=new Array(2*p);c(L);var K=new Array(512);c(K);var j=new Array(256);c(j);var W=new Array(d);c(W);var Y,q,Q,ee=new Array(p);function re(B,oe,Te,je,Ce){this.static_tree=B,this.extra_bits=oe,this.extra_base=Te,this.elems=je,this.max_length=Ce,this.has_stree=B&&B.length}function z(B,oe){this.dyn_tree=B,this.max_code=0,this.stat_desc=oe}function G(B){return B<256?K[B]:K[256+(B>>>7)]}function ae(B,oe){B.pending_buf[B.pending++]=255&oe,B.pending_buf[B.pending++]=oe>>>8&255}function se(B,oe,Te){B.bi_valid>v-Te?(B.bi_buf|=oe<<B.bi_valid&65535,ae(B,B.bi_buf),B.bi_buf=oe>>v-B.bi_valid,B.bi_valid+=Te-v):(B.bi_buf|=oe<<B.bi_valid&65535,B.bi_valid+=Te)}function ue(B,oe,Te){se(B,Te[2*oe],Te[2*oe+1])}function pe(B,oe){for(var Te=0;Te|=1&B,B>>>=1,Te<<=1,0<--oe;);return Te>>>1}function ce(B,oe,Te){var je,Ce,H=new Array(b+1),D=0;for(je=1;je<=b;je++)H[je]=D=D+Te[je-1]<<1;for(Ce=0;Ce<=oe;Ce++){var Z=B[2*Ce+1];Z!==0&&(B[2*Ce]=pe(H[Z]++,Z))}}function Me(B){var oe;for(oe=0;oe<m;oe++)B.dyn_ltree[2*oe]=0;for(oe=0;oe<p;oe++)B.dyn_dtree[2*oe]=0;for(oe=0;oe<x;oe++)B.bl_tree[2*oe]=0;B.dyn_ltree[2*S]=1,B.opt_len=B.static_len=0,B.last_lit=B.matches=0}function me(B){8<B.bi_valid?ae(B,B.bi_buf):0<B.bi_valid&&(B.pending_buf[B.pending++]=B.bi_buf),B.bi_buf=0,B.bi_valid=0}function Ee(B,oe,Te,je){var Ce=2*oe,H=2*Te;return B[Ce]<B[H]||B[Ce]===B[H]&&je[oe]<=je[Te]}function fe(B,oe,Te){for(var je=B.heap[Te],Ce=Te<<1;Ce<=B.heap_len&&(Ce<B.heap_len&&Ee(oe,B.heap[Ce+1],B.heap[Ce],B.depth)&&Ce++,!Ee(oe,je,B.heap[Ce],B.depth));)B.heap[Te]=B.heap[Ce],Te=Ce,Ce<<=1;B.heap[Te]=je}function le(B,oe,Te){var je,Ce,H,D,Z=0;if(B.last_lit!==0)for(;je=B.pending_buf[B.d_buf+2*Z]<<8|B.pending_buf[B.d_buf+2*Z+1],Ce=B.pending_buf[B.l_buf+Z],Z++,je===0?ue(B,Ce,oe):(ue(B,(H=j[Ce])+f+1,oe),(D=A[H])!==0&&se(B,Ce-=W[H],D),ue(B,H=G(--je),Te),(D=O[H])!==0&&se(B,je-=ee[H],D)),Z<B.last_lit;);ue(B,S,oe)}function Be(B,oe){var Te,je,Ce,H=oe.dyn_tree,D=oe.stat_desc.static_tree,Z=oe.stat_desc.has_stree,xe=oe.stat_desc.elems,Ne=-1;for(B.heap_len=0,B.heap_max=y,Te=0;Te<xe;Te++)H[2*Te]!==0?(B.heap[++B.heap_len]=Ne=Te,B.depth[Te]=0):H[2*Te+1]=0;for(;B.heap_len<2;)H[2*(Ce=B.heap[++B.heap_len]=Ne<2?++Ne:0)]=1,B.depth[Ce]=0,B.opt_len--,Z&&(B.static_len-=D[2*Ce+1]);for(oe.max_code=Ne,Te=B.heap_len>>1;1<=Te;Te--)fe(B,H,Te);for(Ce=xe;Te=B.heap[1],B.heap[1]=B.heap[B.heap_len--],fe(B,H,1),je=B.heap[1],B.heap[--B.heap_max]=Te,B.heap[--B.heap_max]=je,H[2*Ce]=H[2*Te]+H[2*je],B.depth[Ce]=(B.depth[Te]>=B.depth[je]?B.depth[Te]:B.depth[je])+1,H[2*Te+1]=H[2*je+1]=Ce,B.heap[1]=Ce++,fe(B,H,1),2<=B.heap_len;);B.heap[--B.heap_max]=B.heap[1],(function(ve,$e){var Le,qe,Ke,Ye,ie,te,Se=$e.dyn_tree,ze=$e.max_code,nt=$e.stat_desc.static_tree,ne=$e.stat_desc.has_stree,Pe=$e.stat_desc.extra_bits,be=$e.stat_desc.extra_base,Oe=$e.stat_desc.max_length,Ue=0;for(Ye=0;Ye<=b;Ye++)ve.bl_count[Ye]=0;for(Se[2*ve.heap[ve.heap_max]+1]=0,Le=ve.heap_max+1;Le<y;Le++)Oe<(Ye=Se[2*Se[2*(qe=ve.heap[Le])+1]+1]+1)&&(Ye=Oe,Ue++),Se[2*qe+1]=Ye,ze<qe||(ve.bl_count[Ye]++,ie=0,be<=qe&&(ie=Pe[qe-be]),te=Se[2*qe],ve.opt_len+=te*(Ye+ie),ne&&(ve.static_len+=te*(nt[2*qe+1]+ie)));if(Ue!==0){do{for(Ye=Oe-1;ve.bl_count[Ye]===0;)Ye--;ve.bl_count[Ye]--,ve.bl_count[Ye+1]+=2,ve.bl_count[Oe]--,Ue-=2}while(0<Ue);for(Ye=Oe;Ye!==0;Ye--)for(qe=ve.bl_count[Ye];qe!==0;)ze<(Ke=ve.heap[--Le])||(Se[2*Ke+1]!==Ye&&(ve.opt_len+=(Ye-Se[2*Ke+1])*Se[2*Ke],Se[2*Ke+1]=Ye),qe--)}})(B,oe),ce(H,Ne,B.bl_count)}function V(B,oe,Te){var je,Ce,H=-1,D=oe[1],Z=0,xe=7,Ne=4;for(D===0&&(xe=138,Ne=3),oe[2*(Te+1)+1]=65535,je=0;je<=Te;je++)Ce=D,D=oe[2*(je+1)+1],++Z<xe&&Ce===D||(Z<Ne?B.bl_tree[2*Ce]+=Z:Ce!==0?(Ce!==H&&B.bl_tree[2*Ce]++,B.bl_tree[2*T]++):Z<=10?B.bl_tree[2*E]++:B.bl_tree[2*C]++,H=Ce,Ne=(Z=0)===D?(xe=138,3):Ce===D?(xe=6,3):(xe=7,4))}function $(B,oe,Te){var je,Ce,H=-1,D=oe[1],Z=0,xe=7,Ne=4;for(D===0&&(xe=138,Ne=3),je=0;je<=Te;je++)if(Ce=D,D=oe[2*(je+1)+1],!(++Z<xe&&Ce===D)){if(Z<Ne)for(;ue(B,Ce,B.bl_tree),--Z!=0;);else Ce!==0?(Ce!==H&&(ue(B,Ce,B.bl_tree),Z--),ue(B,T,B.bl_tree),se(B,Z-3,2)):Z<=10?(ue(B,E,B.bl_tree),se(B,Z-3,3)):(ue(B,C,B.bl_tree),se(B,Z-11,7));H=Ce,Ne=(Z=0)===D?(xe=138,3):Ce===D?(xe=6,3):(xe=7,4)}}c(ee);var X=!1;function U(B,oe,Te,je){se(B,(u<<1)+(je?1:0),3),(function(Ce,H,D,Z){me(Ce),ae(Ce,D),ae(Ce,~D),a.arraySet(Ce.pending_buf,Ce.window,H,D,Ce.pending),Ce.pending+=D})(B,oe,Te)}i._tr_init=function(B){X||((function(){var oe,Te,je,Ce,H,D=new Array(b+1);for(Ce=je=0;Ce<d-1;Ce++)for(W[Ce]=je,oe=0;oe<1<<A[Ce];oe++)j[je++]=Ce;for(j[je-1]=Ce,Ce=H=0;Ce<16;Ce++)for(ee[Ce]=H,oe=0;oe<1<<O[Ce];oe++)K[H++]=Ce;for(H>>=7;Ce<p;Ce++)for(ee[Ce]=H<<7,oe=0;oe<1<<O[Ce]-7;oe++)K[256+H++]=Ce;for(Te=0;Te<=b;Te++)D[Te]=0;for(oe=0;oe<=143;)F[2*oe+1]=8,oe++,D[8]++;for(;oe<=255;)F[2*oe+1]=9,oe++,D[9]++;for(;oe<=279;)F[2*oe+1]=7,oe++,D[7]++;for(;oe<=287;)F[2*oe+1]=8,oe++,D[8]++;for(ce(F,m+1,D),oe=0;oe<p;oe++)L[2*oe+1]=5,L[2*oe]=pe(oe,5);Y=new re(F,A,f+1,m,b),q=new re(L,O,0,p,b),Q=new re(new Array(0),k,0,x,N)})(),X=!0),B.l_desc=new z(B.dyn_ltree,Y),B.d_desc=new z(B.dyn_dtree,q),B.bl_desc=new z(B.bl_tree,Q),B.bi_buf=0,B.bi_valid=0,Me(B)},i._tr_stored_block=U,i._tr_flush_block=function(B,oe,Te,je){var Ce,H,D=0;0<B.level?(B.strm.data_type===2&&(B.strm.data_type=(function(Z){var xe,Ne=4093624447;for(xe=0;xe<=31;xe++,Ne>>>=1)if(1&Ne&&Z.dyn_ltree[2*xe]!==0)return o;if(Z.dyn_ltree[18]!==0||Z.dyn_ltree[20]!==0||Z.dyn_ltree[26]!==0)return l;for(xe=32;xe<f;xe++)if(Z.dyn_ltree[2*xe]!==0)return l;return o})(B)),Be(B,B.l_desc),Be(B,B.d_desc),D=(function(Z){var xe;for(V(Z,Z.dyn_ltree,Z.l_desc.max_code),V(Z,Z.dyn_dtree,Z.d_desc.max_code),Be(Z,Z.bl_desc),xe=x-1;3<=xe&&Z.bl_tree[2*R[xe]+1]===0;xe--);return Z.opt_len+=3*(xe+1)+5+5+4,xe})(B),Ce=B.opt_len+3+7>>>3,(H=B.static_len+3+7>>>3)<=Ce&&(Ce=H)):Ce=H=Te+5,Te+4<=Ce&&oe!==-1?U(B,oe,Te,je):B.strategy===4||H===Ce?(se(B,2+(je?1:0),3),le(B,F,L)):(se(B,4+(je?1:0),3),(function(Z,xe,Ne,ve){var $e;for(se(Z,xe-257,5),se(Z,Ne-1,5),se(Z,ve-4,4),$e=0;$e<ve;$e++)se(Z,Z.bl_tree[2*R[$e]+1],3);$(Z,Z.dyn_ltree,xe-1),$(Z,Z.dyn_dtree,Ne-1)})(B,B.l_desc.max_code+1,B.d_desc.max_code+1,D+1),le(B,B.dyn_ltree,B.dyn_dtree)),Me(B),je&&me(B)},i._tr_tally=function(B,oe,Te){return B.pending_buf[B.d_buf+2*B.last_lit]=oe>>>8&255,B.pending_buf[B.d_buf+2*B.last_lit+1]=255&oe,B.pending_buf[B.l_buf+B.last_lit]=255&Te,B.last_lit++,oe===0?B.dyn_ltree[2*Te]++:(B.matches++,oe--,B.dyn_ltree[2*(j[Te]+f+1)]++,B.dyn_dtree[2*G(oe)]++),B.last_lit===B.lit_bufsize-1},i._tr_align=function(B){se(B,2,3),ue(B,S,F),(function(oe){oe.bi_valid===16?(ae(oe,oe.bi_buf),oe.bi_buf=0,oe.bi_valid=0):8<=oe.bi_valid&&(oe.pending_buf[oe.pending++]=255&oe.bi_buf,oe.bi_buf>>=8,oe.bi_valid-=8)})(B)}},{"../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,m=1,p={},x=!1,y=o.document,b=Object.getPrototypeOf&&Object.getPrototypeOf(o);b=b&&b.setTimeout?b:o,c={}.toString.call(o.process)==="[object process]"?function(T){process.nextTick(function(){N(T)})}:(function(){if(o.postMessage&&!o.importScripts){var T=!0,E=o.onmessage;return o.onmessage=function(){T=!1},o.postMessage("","*"),o.onmessage=E,T}})()?(f="setImmediate$"+Math.random()+"$",o.addEventListener?o.addEventListener("message",S,!1):o.attachEvent("onmessage",S),function(T){o.postMessage(f+T,"*")}):o.MessageChannel?((d=new MessageChannel).port1.onmessage=function(T){N(T.data)},function(T){d.port2.postMessage(T)}):y&&"onreadystatechange"in y.createElement("script")?(u=y.documentElement,function(T){var E=y.createElement("script");E.onreadystatechange=function(){N(T),E.onreadystatechange=null,u.removeChild(E),E=null},u.appendChild(E)}):function(T){setTimeout(N,0,T)},b.setImmediate=function(T){typeof T!="function"&&(T=new Function(""+T));for(var E=new Array(arguments.length-1),C=0;C<E.length;C++)E[C]=arguments[C+1];var A={callback:T,args:E};return p[m]=A,c(m),m++},b.clearImmediate=v}function v(T){delete p[T]}function N(T){if(x)setTimeout(N,0,T);else{var E=p[T];if(E){x=!0;try{(function(C){var A=C.callback,O=C.args;switch(O.length){case 0:A();break;case 1:A(O[0]);break;case 2:A(O[0],O[1]);break;case 3:A(O[0],O[1],O[2]);break;default:A.apply(l,O)}})(E)}finally{v(T),x=!1}}}}function S(T){T.source===o&&typeof T.data=="string"&&T.data.indexOf(f)===0&&N(+T.data.slice(f.length))}})(typeof self>"u"?a===void 0?this:a:self)}).call(this,typeof Jv<"u"?Jv:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(nk)),nk.exports}var KOe=qOe();const XOe=Fo(KOe);function YOe(t){const e=new Mi;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 bV=YOe;async function yV(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 QOe(t){const e=await XOe.loadAsync(t),n=new Map,r=[],i=new DOMParser;async function a(p){const x=p.startsWith("/")?p.slice(1):p,y=e.files[x];if(!y)return null;const b=await y.async("string");return i.parseFromString(b,"application/xml")}const o=new Map,l=new Map,c=e.files["Metadata/model_settings.config"];if(c)try{const p=await c.async("string"),y=i.parseFromString(p,"application/xml").getElementsByTagName("object");for(let b=0;b<y.length;b++){const v=y[b],N=v.getAttribute("id");if(!N)continue;const S=Array.from(v.children).filter(E=>E.tagName==="metadata"&&E.getAttribute("key")==="extruder");if(S.length>0){const E=S[0].getAttribute("value");E&&o.set(N,Math.max(0,parseInt(E,10)-1))}const T=v.getElementsByTagName("part");for(let E=0;E<T.length;E++){const C=T[E],A=C.getAttribute("id");if(!A)continue;const O=Array.from(C.children).filter(k=>k.tagName==="metadata"&&k.getAttribute("key")==="extruder");if(O.length>0){const k=O[0].getAttribute("value");k&&l.set(`${N}:${A}`,Math.max(0,parseInt(k,10)-1))}}}}catch{}const u=Object.keys(e.files).find(p=>p==="3D/3dmodel.model"||p.endsWith("/3dmodel.model"));if(!u){const p=Object.keys(e.files).find(x=>x.endsWith(".model"));if(p){const x=await a(p);if(x){const y=await yV(x,0);y.length>0&&n.set("1",{id:"1",meshes:y,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 p=0;p<f.length;p++){const x=f[p],y=x.getAttribute("id");if(!y)continue;let b=o.get(y)??-1;if(b<0){const T=x.getAttribute("p:extruder")||x.getAttributeNS("http://schemas.microsoft.com/3dmanufacturing/production/2015/06","extruder")||"1";b=Math.max(0,parseInt(T,10)-1)}const v=[],N=x.getElementsByTagName("mesh");for(let T=0;T<N.length;T++){const E=N[T],C=[],A=[],O=E.getElementsByTagName("vertex");for(let R=0;R<O.length;R++){const F=O[R];C.push(parseFloat(F.getAttribute("x")||"0"),parseFloat(F.getAttribute("y")||"0"),parseFloat(F.getAttribute("z")||"0"))}const k=E.getElementsByTagName("triangle");for(let R=0;R<k.length;R++){const F=k[R];A.push(parseInt(F.getAttribute("v1")||"0"),parseInt(F.getAttribute("v2")||"0"),parseInt(F.getAttribute("v3")||"0"))}C.length>0&&A.length>0&&v.push({vertices:C,triangles:A,extruder:b})}const S=x.getElementsByTagName("component");for(let T=0;T<S.length;T++){const E=S[T],C=E.getAttribute("p:path")||E.getAttributeNS("http://schemas.microsoft.com/3dmanufacturing/production/2015/06","path"),A=E.getAttribute("objectid");if(C){const O=await a(C);if(O){const k=A?`${y}:${A}`:null,R=k?l.get(k)??b:b,F=await yV(O,R),L=E.getAttribute("transform"),K=bV(L);for(const j of F)if(L){const W=[];for(let Y=0;Y<j.vertices.length;Y+=3){const q=new lt(j.vertices[Y],j.vertices[Y+1],j.vertices[Y+2]);q.applyMatrix4(K),W.push(q.x,q.y,q.z)}v.push({vertices:W,triangles:j.triangles,extruder:j.extruder})}else v.push(j)}}}v.length>0&&n.set(y,{id:y,meshes:v,defaultExtruder:b})}const m=d.getElementsByTagName("build");if(m.length>0){const p=m[0].getElementsByTagName("item");for(let x=0;x<p.length;x++){const y=p[x],b=y.getAttribute("objectid");if(!b)continue;const v=bV(y.getAttribute("transform"));r.push({objectId:b,transform:v})}}return{objects:n,buildItems:r}}function vV(t){const e=new ec,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 Ao(n,3)),e.setIndex(t.triangles),e.computeVertexNormals(),e}function ZOe({url:t,buildVolume:e={x:256,y:256,z:256},filamentColors:n,className:r=""}){const i=w.useRef(null),a=w.useRef(null),o=w.useRef(null),l=w.useRef(null),c=w.useRef(null),[u,d]=w.useState(!0),[f,m]=w.useState(null);w.useEffect(()=>{if(!i.current)return;const y=i.current,b=y.clientWidth,v=y.clientHeight,N=new C3e;N.background=new Dn(1710618),o.current=N;const S=new _o(45,b/v,.1,1e4);S.position.set(150,150,150),l.current=S;const T=new jOe({antialias:!0});T.setSize(b,v),T.setPixelRatio(window.devicePixelRatio),y.appendChild(T.domElement),a.current=T;const E=new ROe(S,T.domElement);E.enableDamping=!0,E.dampingFactor=.05,c.current=E;const C=new B3e(16777215,.6);N.add(C);const A=new $H(16777215,.8);A.position.set(100,100,100),N.add(A);const O=new $H(16777215,.4);O.position.set(-100,50,-100),N.add(O);const k=Math.max(e.x,e.y),R=Math.ceil(k/16),F=new H3e(k,R,4473924,3355443);N.add(F);const L=new DO(e.x,e.y),K=new jO({color:44610,transparent:!0,opacity:.15,side:Cl}),j=new Wl(L,K);j.rotation.x=-Math.PI/2,j.position.y=-.5,N.add(j);let W;const Y=()=>{W=requestAnimationFrame(Y),E.update(),T.render(N,S)};Y(),fetch(t).then(Q=>{if(!Q.ok)throw new Error("Failed to load file");return Q.arrayBuffer()}).then(QOe).then(({objects:Q,buildItems:ee})=>{if(Q.size===0)throw new Error("No meshes found in 3MF file");const re=Ee=>{const le=n?.[Ee]||"#00ae42",Be=new Dn(le);return new L3e({color:Be,shininess:30,flatShading:!1})},z=new Ab,G=new Map;if(ee.length>0)for(const Ee of ee){const fe=Q.get(Ee.objectId);if(fe)for(const le of fe.meshes){const Be=Ee.extruder??le.extruder,V=[];for(let X=0;X<le.vertices.length;X+=3){const U=new lt(le.vertices[X],le.vertices[X+1],le.vertices[X+2]);U.applyMatrix4(Ee.transform),V.push(U.x,U.y,U.z)}const $=vV({vertices:V,triangles:le.triangles});G.has(Be)||G.set(Be,[]),G.get(Be).push($)}}else for(const Ee of Q.values())for(const fe of Ee.meshes){const le=fe.extruder,Be=vV(fe);G.has(le)||G.set(le,[]),G.get(le).push(Be)}for(const[Ee,fe]of G){if(fe.length===0)continue;const le=fe.length===1?fe[0]:WOe(fe,!1);if(le){const Be=re(Ee),V=new Wl(le,Be);z.add(V)}if(fe.length>1)for(const Be of fe)Be.dispose()}const ae=new Hf().setFromObject(z),se=ae.getCenter(new lt);z.position.y=-ae.min.y,ee.length===0&&(z.position.x=-se.x,z.position.z=-se.z),N.add(z);const ue=new Hf().setFromObject(z),pe=ue.getCenter(new lt),ce=ue.getSize(new lt),me=Math.max(ce.x,ce.y,ce.z)*1.8;S.position.set(pe.x+me*.7,pe.y+me*.5,pe.z+me*.7),E.target.copy(pe),E.update(),d(!1)}).catch(Q=>{m(Q.message),d(!1)});const q=()=>{if(!y)return;const Q=y.clientWidth,ee=y.clientHeight;S.aspect=Q/ee,S.updateProjectionMatrix(),T.setSize(Q,ee)};return window.addEventListener("resize",q),()=>{window.removeEventListener("resize",q),cancelAnimationFrame(W),E.dispose(),T.dispose(),y.removeChild(T.domElement)}},[t,e,n]);const p=()=>{l.current&&c.current&&(l.current.position.set(150,150,150),c.current.target.set(0,50,0),c.current.update())},x=y=>{l.current&&l.current.position.multiplyScalar(y)};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(dt,{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(we,{variant:"secondary",size:"sm",onClick:()=>x(.8),children:s.jsx(gD,{className:"w-4 h-4"})}),s.jsx(we,{variant:"secondary",size:"sm",onClick:()=>x(1.25),children:s.jsx(xD,{className:"w-4 h-4"})}),s.jsx(we,{variant:"secondary",size:"sm",onClick:p,children:s.jsx(Zf,{className:"w-4 h-4"})})]})]})}const VN="159",rp={ROTATE:0,DOLLY:1,PAN:2},ip={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},JOe=0,_V=1,eLe=2,_J=1,tLe=2,Oc=3,Yd=0,ys=1,$c=2,Dd=0,Qp=1,wV=2,SV=3,NV=4,nLe=5,qh=100,rLe=101,iLe=102,MV=103,EV=104,aLe=200,sLe=201,oLe=202,lLe=203,KP=204,XP=205,cLe=206,uLe=207,dLe=208,hLe=209,fLe=210,mLe=211,pLe=212,gLe=213,xLe=214,bLe=0,yLe=1,vLe=2,MS=3,_Le=4,wLe=5,SLe=6,NLe=7,LO=0,MLe=1,ELe=2,Od=0,TLe=1,ALe=2,CLe=3,kLe=4,jLe=5,wJ=300,_g=301,wg=302,YP=303,QP=304,GN=306,ZP=1e3,el=1001,JP=1002,ga=1003,TV=1004,rk=1005,wo=1006,PLe=1007,F0=1008,Ld=1009,RLe=1010,DLe=1011,IO=1012,SJ=1013,Sd=1014,Kc=1015,U0=1016,NJ=1017,MJ=1018,gf=1020,OLe=1021,So=1023,LLe=1024,ILe=1025,xf=1026,Sg=1027,FLe=1028,EJ=1029,ULe=1030,TJ=1031,AJ=1033,ik=33776,ak=33777,sk=33778,ok=33779,AV=35840,CV=35841,kV=35842,jV=35843,CJ=36196,PV=37492,RV=37496,DV=37808,OV=37809,LV=37810,IV=37811,FV=37812,UV=37813,zV=37814,BV=37815,$V=37816,HV=37817,VV=37818,GV=37819,WV=37820,qV=37821,lk=36492,KV=36494,XV=36495,zLe=36283,YV=36284,QV=36285,ZV=36286,kJ=3e3,bf=3001,BLe=3200,$Le=3201,jJ=0,HLe=1,No="",xa="srgb",pu="srgb-linear",FO="display-p3",WN="display-p3-linear",ES="linear",Cr="srgb",TS="rec709",AS="p3",ap=7680,JV=519,VLe=512,GLe=513,WLe=514,PJ=515,qLe=516,KLe=517,XLe=518,YLe=519,eR=35044,e7="300 es",tR=1035,Dl=2e3,z0=2001;class rm{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 Ta=["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 t7=1234567;const $b=Math.PI/180,B0=180/Math.PI;function nu(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(Ta[t&255]+Ta[t>>8&255]+Ta[t>>16&255]+Ta[t>>24&255]+"-"+Ta[e&255]+Ta[e>>8&255]+"-"+Ta[e>>16&15|64]+Ta[e>>24&255]+"-"+Ta[n&63|128]+Ta[n>>8&255]+"-"+Ta[n>>16&255]+Ta[n>>24&255]+Ta[r&255]+Ta[r>>8&255]+Ta[r>>16&255]+Ta[r>>24&255]).toLowerCase()}function ba(t,e,n){return Math.max(e,Math.min(n,t))}function UO(t,e){return(t%e+e)%e}function QLe(t,e,n,r,i){return r+(t-e)*(i-r)/(n-e)}function ZLe(t,e,n){return t!==e?(n-t)/(e-t):0}function Hb(t,e,n){return(1-n)*t+n*e}function JLe(t,e,n,r){return Hb(t,e,1-Math.exp(-n*r))}function eIe(t,e=1){return e-Math.abs(UO(t,e*2)-e)}function tIe(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*(3-2*t))}function nIe(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*t*(t*(t*6-15)+10))}function rIe(t,e){return t+Math.floor(Math.random()*(e-t+1))}function iIe(t,e){return t+Math.random()*(e-t)}function aIe(t){return t*(.5-Math.random())}function sIe(t){t!==void 0&&(t7=t);let e=t7+=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 oIe(t){return t*$b}function lIe(t){return t*B0}function nR(t){return(t&t-1)===0&&t!==0}function cIe(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}function CS(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function uIe(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),m=o((e-r)/2),p=a((r-e)/2),x=o((r-e)/2);switch(i){case"XYX":t.set(l*d,c*f,c*m,l*u);break;case"YZY":t.set(c*m,l*d,c*f,l*u);break;case"ZXZ":t.set(c*f,c*m,l*d,l*u);break;case"XZX":t.set(l*d,c*x,c*p,l*u);break;case"YXY":t.set(c*p,l*d,c*x,l*u);break;case"ZYZ":t.set(c*x,c*p,l*d,l*u);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function kl(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 fr(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 RJ={DEG2RAD:$b,RAD2DEG:B0,generateUUID:nu,clamp:ba,euclideanModulo:UO,mapLinear:QLe,inverseLerp:ZLe,lerp:Hb,damp:JLe,pingpong:eIe,smoothstep:tIe,smootherstep:nIe,randInt:rIe,randFloat:iIe,randFloatSpread:aIe,seededRandom:sIe,degToRad:oIe,radToDeg:lIe,isPowerOfTwo:nR,ceilPowerOfTwo:cIe,floorPowerOfTwo:CS,setQuaternionFromProperEuler:uIe,normalize:fr,denormalize:kl};class pn{constructor(e=0,n=0){pn.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(ba(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 Cn{constructor(e,n,r,i,a,o,l,c,u){Cn.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],m=r[2],p=r[5],x=r[8],y=i[0],b=i[3],v=i[6],N=i[1],S=i[4],T=i[7],E=i[2],C=i[5],A=i[8];return a[0]=o*y+l*N+c*E,a[3]=o*b+l*S+c*C,a[6]=o*v+l*T+c*A,a[1]=u*y+d*N+f*E,a[4]=u*b+d*S+f*C,a[7]=u*v+d*T+f*A,a[2]=m*y+p*N+x*E,a[5]=m*b+p*S+x*C,a[8]=m*v+p*T+x*A,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,m=l*c-d*a,p=u*a-o*c,x=n*f+r*m+i*p;if(x===0)return this.set(0,0,0,0,0,0,0,0,0);const y=1/x;return e[0]=f*y,e[1]=(i*u-d*r)*y,e[2]=(l*r-i*o)*y,e[3]=m*y,e[4]=(d*n-i*c)*y,e[5]=(i*a-l*n)*y,e[6]=p*y,e[7]=(r*c-u*n)*y,e[8]=(o*n-r*a)*y,this}transpose(){let e;const n=this.elements;return e=n[1],n[1]=n[3],n[3]=e,e=n[2],n[2]=n[6],n[6]=e,e=n[5],n[5]=n[7],n[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const n=this.elements;return e[0]=n[0],e[1]=n[3],e[2]=n[6],e[3]=n[1],e[4]=n[4],e[5]=n[7],e[6]=n[2],e[7]=n[5],e[8]=n[8],this}setUvTransform(e,n,r,i,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(ck.makeScale(e,n)),this}rotate(e){return this.premultiply(ck.makeRotation(-e)),this}translate(e,n){return this.premultiply(ck.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 ck=new Cn;function DJ(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function kS(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function dIe(){const t=kS("canvas");return t.style.display="block",t}const n7={};function Vb(t){t in n7||(n7[t]=!0,console.warn(t))}const r7=new Cn().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),i7=new Cn().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),W_={[pu]:{transfer:ES,primaries:TS,toReference:t=>t,fromReference:t=>t},[xa]:{transfer:Cr,primaries:TS,toReference:t=>t.convertSRGBToLinear(),fromReference:t=>t.convertLinearToSRGB()},[WN]:{transfer:ES,primaries:AS,toReference:t=>t.applyMatrix3(i7),fromReference:t=>t.applyMatrix3(r7)},[FO]:{transfer:Cr,primaries:AS,toReference:t=>t.convertSRGBToLinear().applyMatrix3(i7),fromReference:t=>t.applyMatrix3(r7).convertLinearToSRGB()}},hIe=new Set([pu,WN]),mr={enabled:!0,_workingColorSpace:pu,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(!hIe.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=W_[e].toReference,i=W_[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 W_[t].primaries},getTransfer:function(t){return t===No?ES:W_[t].transfer}};function Zp(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function uk(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let sp;class OJ{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{sp===void 0&&(sp=kS("canvas")),sp.width=e.width,sp.height=e.height;const r=sp.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),n=sp}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=kS("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]=Zp(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(Zp(n[r]/255)*255):n[r]=Zp(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 fIe=0;class LJ{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:fIe++}),this.uuid=nu(),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(dk(i[o].image)):a.push(dk(i[o]))}else a=dk(i);r.url=a}return n||(e.images[this.uuid]=r),r}}function dk(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?OJ.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 mIe=0;class vs extends rm{constructor(e=vs.DEFAULT_IMAGE,n=vs.DEFAULT_MAPPING,r=el,i=el,a=wo,o=F0,l=So,c=Ld,u=vs.DEFAULT_ANISOTROPY,d=No){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:mIe++}),this.uuid=nu(),this.name="",this.source=new LJ(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 pn(0,0),this.repeat=new pn(1,1),this.center=new pn(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Cn,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,typeof d=="string"?this.colorSpace=d:(Vb("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=d===bf?xa:No),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!==wJ)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case ZP:e.x=e.x-Math.floor(e.x);break;case el:e.x=e.x<0?0:1;break;case JP: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 ZP:e.y=e.y-Math.floor(e.y);break;case el:e.y=e.y<0?0:1;break;case JP: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 Vb("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===xa?bf:kJ}set encoding(e){Vb("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=e===bf?xa:No}}vs.DEFAULT_IMAGE=null;vs.DEFAULT_MAPPING=wJ;vs.DEFAULT_ANISOTROPY=1;class gr{constructor(e=0,n=0,r=0,i=1){gr.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],m=c[1],p=c[5],x=c[9],y=c[2],b=c[6],v=c[10];if(Math.abs(d-m)<.01&&Math.abs(f-y)<.01&&Math.abs(x-b)<.01){if(Math.abs(d+m)<.1&&Math.abs(f+y)<.1&&Math.abs(x+b)<.1&&Math.abs(u+p+v-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const S=(u+1)/2,T=(p+1)/2,E=(v+1)/2,C=(d+m)/4,A=(f+y)/4,O=(x+b)/4;return S>T&&S>E?S<.01?(r=0,i=.707106781,a=.707106781):(r=Math.sqrt(S),i=C/r,a=A/r):T>E?T<.01?(r=.707106781,i=0,a=.707106781):(i=Math.sqrt(T),r=C/i,a=O/i):E<.01?(r=.707106781,i=.707106781,a=0):(a=Math.sqrt(E),r=A/a,i=O/a),this.set(r,i,a,n),this}let N=Math.sqrt((b-x)*(b-x)+(f-y)*(f-y)+(m-d)*(m-d));return Math.abs(N)<.001&&(N=1),this.x=(b-x)/N,this.y=(f-y)/N,this.z=(m-d)/N,this.w=Math.acos((u+p+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 pIe extends rm{constructor(e=1,n=1,r={}){super(),this.isRenderTarget=!0,this.width=e,this.height=n,this.depth=1,this.scissor=new gr(0,0,e,n),this.scissorTest=!1,this.viewport=new gr(0,0,e,n);const i={width:e,height:n,depth:1};r.encoding!==void 0&&(Vb("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),r.colorSpace=r.encoding===bf?xa:No),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:wo,depthBuffer:!0,stencilBuffer:!1,depthTexture:null,samples:0},r),this.texture=new vs(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 LJ(n),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Vf extends pIe{constructor(e=1,n=1,r={}){super(e,n,r),this.isWebGLRenderTarget=!0}}class IJ extends vs{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=ga,this.minFilter=ga,this.wrapR=el,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class gIe extends vs{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=ga,this.minFilter=ga,this.wrapR=el,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Gf{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 m=a[o+0],p=a[o+1],x=a[o+2],y=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]=m,e[n+1]=p,e[n+2]=x,e[n+3]=y;return}if(f!==y||c!==m||u!==p||d!==x){let b=1-l;const v=c*m+u*p+d*x+f*y,N=v>=0?1:-1,S=1-v*v;if(S>Number.EPSILON){const E=Math.sqrt(S),C=Math.atan2(E,v*N);b=Math.sin(b*C)/E,l=Math.sin(l*C)/E}const T=l*N;if(c=c*b+m*T,u=u*b+p*T,d=d*b+x*T,f=f*b+y*T,b===1-l){const E=1/Math.sqrt(c*c+u*u+d*d+f*f);c*=E,u*=E,d*=E,f*=E}}e[n]=c,e[n+1]=u,e[n+2]=d,e[n+3]=f}static multiplyQuaternionsFlat(e,n,r,i,a,o){const l=r[i],c=r[i+1],u=r[i+2],d=r[i+3],f=a[o],m=a[o+1],p=a[o+2],x=a[o+3];return e[n]=l*x+d*f+c*p-u*m,e[n+1]=c*x+d*m+u*f-l*p,e[n+2]=u*x+d*p+l*m-c*f,e[n+3]=d*x-l*f-c*m-u*p,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,n,r,i){return this._x=e,this._y=n,this._z=r,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,n){const r=e._x,i=e._y,a=e._z,o=e._order,l=Math.cos,c=Math.sin,u=l(r/2),d=l(i/2),f=l(a/2),m=c(r/2),p=c(i/2),x=c(a/2);switch(o){case"XYZ":this._x=m*d*f+u*p*x,this._y=u*p*f-m*d*x,this._z=u*d*x+m*p*f,this._w=u*d*f-m*p*x;break;case"YXZ":this._x=m*d*f+u*p*x,this._y=u*p*f-m*d*x,this._z=u*d*x-m*p*f,this._w=u*d*f+m*p*x;break;case"ZXY":this._x=m*d*f-u*p*x,this._y=u*p*f+m*d*x,this._z=u*d*x+m*p*f,this._w=u*d*f-m*p*x;break;case"ZYX":this._x=m*d*f-u*p*x,this._y=u*p*f+m*d*x,this._z=u*d*x-m*p*f,this._w=u*d*f+m*p*x;break;case"YZX":this._x=m*d*f+u*p*x,this._y=u*p*f+m*d*x,this._z=u*d*x-m*p*f,this._w=u*d*f-m*p*x;break;case"XZY":this._x=m*d*f-u*p*x,this._y=u*p*f-m*d*x,this._z=u*d*x+m*p*f,this._w=u*d*f+m*p*x;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return n!==!1&&this._onChangeCallback(),this}setFromAxisAngle(e,n){const r=n/2,i=Math.sin(r);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(r),this._onChangeCallback(),this}setFromRotationMatrix(e){const n=e.elements,r=n[0],i=n[4],a=n[8],o=n[1],l=n[5],c=n[9],u=n[2],d=n[6],f=n[10],m=r+l+f;if(m>0){const p=.5/Math.sqrt(m+1);this._w=.25/p,this._x=(d-c)*p,this._y=(a-u)*p,this._z=(o-i)*p}else if(r>l&&r>f){const p=2*Math.sqrt(1+r-l-f);this._w=(d-c)/p,this._x=.25*p,this._y=(i+o)/p,this._z=(a+u)/p}else if(l>f){const p=2*Math.sqrt(1+l-r-f);this._w=(a-u)/p,this._x=(i+o)/p,this._y=.25*p,this._z=(c+d)/p}else{const p=2*Math.sqrt(1+f-r-l);this._w=(o-i)/p,this._x=(a+u)/p,this._y=(c+d)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(e,n){let r=e.dot(n)+1;return r<Number.EPSILON?(r=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=r):(this._x=0,this._y=-e.z,this._z=e.y,this._w=r)):(this._x=e.y*n.z-e.z*n.y,this._y=e.z*n.x-e.x*n.z,this._z=e.x*n.y-e.y*n.x,this._w=r),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(ba(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 p=1-n;return this._w=p*o+n*this._w,this._x=p*r+n*this._x,this._y=p*i+n*this._y,this._z=p*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,m=Math.sin(n*d)/u;return this._w=o*f+this._w*m,this._x=r*f+this._x*m,this._y=i*f+this._y*m,this._z=a*f+this._z*m,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 We{constructor(e=0,n=0,r=0){We.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(a7.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(a7.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 hk.copy(this).projectOnVector(e),this.sub(hk)}reflect(e){return this.sub(hk.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(ba(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 hk=new We,a7=new Gf;class Co{constructor(e=new We(1/0,1/0,1/0),n=new We(-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(qo.fromArray(e,n));return this}setFromBufferAttribute(e){this.makeEmpty();for(let n=0,r=e.count;n<r;n++)this.expandByPoint(qo.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=qo.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,qo):qo.fromBufferAttribute(a,o),qo.applyMatrix4(e.matrixWorld),this.expandByPoint(qo);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),q_.copy(e.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),q_.copy(r.boundingBox)),q_.applyMatrix4(e.matrixWorld),this.union(q_)}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,qo),qo.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(mb),K_.subVectors(this.max,mb),op.subVectors(e.a,mb),lp.subVectors(e.b,mb),cp.subVectors(e.c,mb),Zu.subVectors(lp,op),Ju.subVectors(cp,lp),Dh.subVectors(op,cp);let n=[0,-Zu.z,Zu.y,0,-Ju.z,Ju.y,0,-Dh.z,Dh.y,Zu.z,0,-Zu.x,Ju.z,0,-Ju.x,Dh.z,0,-Dh.x,-Zu.y,Zu.x,0,-Ju.y,Ju.x,0,-Dh.y,Dh.x,0];return!fk(n,op,lp,cp,K_)||(n=[1,0,0,0,1,0,0,0,1],!fk(n,op,lp,cp,K_))?!1:(X_.crossVectors(Zu,Ju),n=[X_.x,X_.y,X_.z],fk(n,op,lp,cp,K_))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,qo).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(qo).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:(Mc[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Mc[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Mc[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Mc[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Mc[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Mc[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Mc[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Mc[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Mc),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 Mc=[new We,new We,new We,new We,new We,new We,new We,new We],qo=new We,q_=new Co,op=new We,lp=new We,cp=new We,Zu=new We,Ju=new We,Dh=new We,mb=new We,K_=new We,X_=new We,Oh=new We;function fk(t,e,n,r,i){for(let a=0,o=t.length-3;a<=o;a+=3){Oh.fromArray(t,a);const l=i.x*Math.abs(Oh.x)+i.y*Math.abs(Oh.y)+i.z*Math.abs(Oh.z),c=e.dot(Oh),u=n.dot(Oh),d=r.dot(Oh);if(Math.max(-Math.max(c,u,d),Math.min(c,u,d))>l)return!1}return!0}const xIe=new Co,pb=new We,mk=new We;class Il{constructor(e=new We,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):xIe.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;pb.subVectors(e,this.center);const n=pb.lengthSq();if(n>this.radius*this.radius){const r=Math.sqrt(n),i=(r-this.radius)*.5;this.center.addScaledVector(pb,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):(mk.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(pb.copy(e.center).add(mk)),this.expandByPoint(pb.copy(e.center).sub(mk))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const Ec=new We,pk=new We,Y_=new We,ed=new We,gk=new We,Q_=new We,xk=new We;class zO{constructor(e=new We,n=new We(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,Ec)),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=Ec.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(Ec.copy(this.origin).addScaledVector(this.direction,n),Ec.distanceToSquared(e))}distanceSqToSegment(e,n,r,i){pk.copy(e).add(n).multiplyScalar(.5),Y_.copy(n).sub(e).normalize(),ed.copy(this.origin).sub(pk);const a=e.distanceTo(n)*.5,o=-this.direction.dot(Y_),l=ed.dot(this.direction),c=-ed.dot(Y_),u=ed.lengthSq(),d=Math.abs(1-o*o);let f,m,p,x;if(d>0)if(f=o*c-l,m=o*l-c,x=a*d,f>=0)if(m>=-x)if(m<=x){const y=1/d;f*=y,m*=y,p=f*(f+o*m+2*l)+m*(o*f+m+2*c)+u}else m=a,f=Math.max(0,-(o*m+l)),p=-f*f+m*(m+2*c)+u;else m=-a,f=Math.max(0,-(o*m+l)),p=-f*f+m*(m+2*c)+u;else m<=-x?(f=Math.max(0,-(-o*a+l)),m=f>0?-a:Math.min(Math.max(-a,-c),a),p=-f*f+m*(m+2*c)+u):m<=x?(f=0,m=Math.min(Math.max(-a,-c),a),p=m*(m+2*c)+u):(f=Math.max(0,-(o*a+l)),m=f>0?a:Math.min(Math.max(-a,-c),a),p=-f*f+m*(m+2*c)+u);else m=o>0?-a:a,f=Math.max(0,-(o*m+l)),p=-f*f+m*(m+2*c)+u;return r&&r.copy(this.origin).addScaledVector(this.direction,f),i&&i.copy(pk).addScaledVector(Y_,m),p}intersectSphere(e,n){Ec.subVectors(e.center,this.origin);const r=Ec.dot(this.direction),i=Ec.dot(Ec)-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,m=this.origin;return u>=0?(r=(e.min.x-m.x)*u,i=(e.max.x-m.x)*u):(r=(e.max.x-m.x)*u,i=(e.min.x-m.x)*u),d>=0?(a=(e.min.y-m.y)*d,o=(e.max.y-m.y)*d):(a=(e.max.y-m.y)*d,o=(e.min.y-m.y)*d),r>o||a>i||((a>r||isNaN(r))&&(r=a),(o<i||isNaN(i))&&(i=o),f>=0?(l=(e.min.z-m.z)*f,c=(e.max.z-m.z)*f):(l=(e.max.z-m.z)*f,c=(e.min.z-m.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,Ec)!==null}intersectTriangle(e,n,r,i,a){gk.subVectors(n,e),Q_.subVectors(r,e),xk.crossVectors(gk,Q_);let o=this.direction.dot(xk),l;if(o>0){if(i)return null;l=1}else if(o<0)l=-1,o=-o;else return null;ed.subVectors(this.origin,e);const c=l*this.direction.dot(Q_.crossVectors(ed,Q_));if(c<0)return null;const u=l*this.direction.dot(gk.cross(ed));if(u<0||c+u>o)return null;const d=-l*ed.dot(xk);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 Er{constructor(e,n,r,i,a,o,l,c,u,d,f,m,p,x,y,b){Er.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,m,p,x,y,b)}set(e,n,r,i,a,o,l,c,u,d,f,m,p,x,y,b){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]=m,v[3]=p,v[7]=x,v[11]=y,v[15]=b,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 Er().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/up.setFromMatrixColumn(e,0).length(),a=1/up.setFromMatrixColumn(e,1).length(),o=1/up.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 m=o*d,p=o*f,x=l*d,y=l*f;n[0]=c*d,n[4]=-c*f,n[8]=u,n[1]=p+x*u,n[5]=m-y*u,n[9]=-l*c,n[2]=y-m*u,n[6]=x+p*u,n[10]=o*c}else if(e.order==="YXZ"){const m=c*d,p=c*f,x=u*d,y=u*f;n[0]=m+y*l,n[4]=x*l-p,n[8]=o*u,n[1]=o*f,n[5]=o*d,n[9]=-l,n[2]=p*l-x,n[6]=y+m*l,n[10]=o*c}else if(e.order==="ZXY"){const m=c*d,p=c*f,x=u*d,y=u*f;n[0]=m-y*l,n[4]=-o*f,n[8]=x+p*l,n[1]=p+x*l,n[5]=o*d,n[9]=y-m*l,n[2]=-o*u,n[6]=l,n[10]=o*c}else if(e.order==="ZYX"){const m=o*d,p=o*f,x=l*d,y=l*f;n[0]=c*d,n[4]=x*u-p,n[8]=m*u+y,n[1]=c*f,n[5]=y*u+m,n[9]=p*u-x,n[2]=-u,n[6]=l*c,n[10]=o*c}else if(e.order==="YZX"){const m=o*c,p=o*u,x=l*c,y=l*u;n[0]=c*d,n[4]=y-m*f,n[8]=x*f+p,n[1]=f,n[5]=o*d,n[9]=-l*d,n[2]=-u*d,n[6]=p*f+x,n[10]=m-y*f}else if(e.order==="XZY"){const m=o*c,p=o*u,x=l*c,y=l*u;n[0]=c*d,n[4]=-f,n[8]=u*d,n[1]=m*f+y,n[5]=o*d,n[9]=p*f-x,n[2]=x*f-p,n[6]=l*d,n[10]=y*f+m}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(bIe,e,yIe)}lookAt(e,n,r){const i=this.elements;return Ls.subVectors(e,n),Ls.lengthSq()===0&&(Ls.z=1),Ls.normalize(),td.crossVectors(r,Ls),td.lengthSq()===0&&(Math.abs(r.z)===1?Ls.x+=1e-4:Ls.z+=1e-4,Ls.normalize(),td.crossVectors(r,Ls)),td.normalize(),Z_.crossVectors(Ls,td),i[0]=td.x,i[4]=Z_.x,i[8]=Ls.x,i[1]=td.y,i[5]=Z_.y,i[9]=Ls.y,i[2]=td.z,i[6]=Z_.z,i[10]=Ls.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],m=r[9],p=r[13],x=r[2],y=r[6],b=r[10],v=r[14],N=r[3],S=r[7],T=r[11],E=r[15],C=i[0],A=i[4],O=i[8],k=i[12],R=i[1],F=i[5],L=i[9],K=i[13],j=i[2],W=i[6],Y=i[10],q=i[14],Q=i[3],ee=i[7],re=i[11],z=i[15];return a[0]=o*C+l*R+c*j+u*Q,a[4]=o*A+l*F+c*W+u*ee,a[8]=o*O+l*L+c*Y+u*re,a[12]=o*k+l*K+c*q+u*z,a[1]=d*C+f*R+m*j+p*Q,a[5]=d*A+f*F+m*W+p*ee,a[9]=d*O+f*L+m*Y+p*re,a[13]=d*k+f*K+m*q+p*z,a[2]=x*C+y*R+b*j+v*Q,a[6]=x*A+y*F+b*W+v*ee,a[10]=x*O+y*L+b*Y+v*re,a[14]=x*k+y*K+b*q+v*z,a[3]=N*C+S*R+T*j+E*Q,a[7]=N*A+S*F+T*W+E*ee,a[11]=N*O+S*L+T*Y+E*re,a[15]=N*k+S*K+T*q+E*z,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[4]*=e,n[8]*=e,n[12]*=e,n[1]*=e,n[5]*=e,n[9]*=e,n[13]*=e,n[2]*=e,n[6]*=e,n[10]*=e,n[14]*=e,n[3]*=e,n[7]*=e,n[11]*=e,n[15]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[4],i=e[8],a=e[12],o=e[1],l=e[5],c=e[9],u=e[13],d=e[2],f=e[6],m=e[10],p=e[14],x=e[3],y=e[7],b=e[11],v=e[15];return x*(+a*c*f-i*u*f-a*l*m+r*u*m+i*l*p-r*c*p)+y*(+n*c*p-n*u*m+a*o*m-i*o*p+i*u*d-a*c*d)+b*(+n*u*f-n*l*p-a*o*f+r*o*p+a*l*d-r*u*d)+v*(-i*l*d-n*c*f+n*l*m+i*o*f-r*o*m+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],m=e[10],p=e[11],x=e[12],y=e[13],b=e[14],v=e[15],N=f*b*u-y*m*u+y*c*p-l*b*p-f*c*v+l*m*v,S=x*m*u-d*b*u-x*c*p+o*b*p+d*c*v-o*m*v,T=d*y*u-x*f*u+x*l*p-o*y*p-d*l*v+o*f*v,E=x*f*c-d*y*c-x*l*m+o*y*m+d*l*b-o*f*b,C=n*N+r*S+i*T+a*E;if(C===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const A=1/C;return e[0]=N*A,e[1]=(y*m*a-f*b*a-y*i*p+r*b*p+f*i*v-r*m*v)*A,e[2]=(l*b*a-y*c*a+y*i*u-r*b*u-l*i*v+r*c*v)*A,e[3]=(f*c*a-l*m*a-f*i*u+r*m*u+l*i*p-r*c*p)*A,e[4]=S*A,e[5]=(d*b*a-x*m*a+x*i*p-n*b*p-d*i*v+n*m*v)*A,e[6]=(x*c*a-o*b*a-x*i*u+n*b*u+o*i*v-n*c*v)*A,e[7]=(o*m*a-d*c*a+d*i*u-n*m*u-o*i*p+n*c*p)*A,e[8]=T*A,e[9]=(x*f*a-d*y*a-x*r*p+n*y*p+d*r*v-n*f*v)*A,e[10]=(o*y*a-x*l*a+x*r*u-n*y*u-o*r*v+n*l*v)*A,e[11]=(d*l*a-o*f*a-d*r*u+n*f*u+o*r*p-n*l*p)*A,e[12]=E*A,e[13]=(d*y*i-x*f*i+x*r*m-n*y*m-d*r*b+n*f*b)*A,e[14]=(x*l*i-o*y*i-x*r*c+n*y*c+o*r*b-n*l*b)*A,e[15]=(o*f*i-d*l*i+d*r*c-n*f*c-o*r*m+n*l*m)*A,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,m=a*u,p=a*d,x=a*f,y=o*d,b=o*f,v=l*f,N=c*u,S=c*d,T=c*f,E=r.x,C=r.y,A=r.z;return i[0]=(1-(y+v))*E,i[1]=(p+T)*E,i[2]=(x-S)*E,i[3]=0,i[4]=(p-T)*C,i[5]=(1-(m+v))*C,i[6]=(b+N)*C,i[7]=0,i[8]=(x+S)*A,i[9]=(b-N)*A,i[10]=(1-(m+y))*A,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=up.set(i[0],i[1],i[2]).length();const o=up.set(i[4],i[5],i[6]).length(),l=up.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],Ko.copy(this);const u=1/a,d=1/o,f=1/l;return Ko.elements[0]*=u,Ko.elements[1]*=u,Ko.elements[2]*=u,Ko.elements[4]*=d,Ko.elements[5]*=d,Ko.elements[6]*=d,Ko.elements[8]*=f,Ko.elements[9]*=f,Ko.elements[10]*=f,n.setFromRotationMatrix(Ko),r.x=a,r.y=o,r.z=l,this}makePerspective(e,n,r,i,a,o,l=Dl){const c=this.elements,u=2*a/(n-e),d=2*a/(r-i),f=(n+e)/(n-e),m=(r+i)/(r-i);let p,x;if(l===Dl)p=-(o+a)/(o-a),x=-2*o*a/(o-a);else if(l===z0)p=-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]=m,c[13]=0,c[2]=0,c[6]=0,c[10]=p,c[14]=x,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,n,r,i,a,o,l=Dl){const c=this.elements,u=1/(n-e),d=1/(r-i),f=1/(o-a),m=(n+e)*u,p=(r+i)*d;let x,y;if(l===Dl)x=(o+a)*f,y=-2*f;else if(l===z0)x=a*f,y=-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]=-m,c[1]=0,c[5]=2*d,c[9]=0,c[13]=-p,c[2]=0,c[6]=0,c[10]=y,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 up=new We,Ko=new Er,bIe=new We(0,0,0),yIe=new We(1,1,1),td=new We,Z_=new We,Ls=new We,s7=new Er,o7=new Gf;class Oy{constructor(e=0,n=0,r=0,i=Oy.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],m=i[6],p=i[10];switch(n){case"XYZ":this._y=Math.asin(ba(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-d,p),this._z=Math.atan2(-o,a)):(this._x=Math.atan2(m,u),this._z=0);break;case"YXZ":this._x=Math.asin(-ba(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(l,p),this._z=Math.atan2(c,u)):(this._y=Math.atan2(-f,a),this._z=0);break;case"ZXY":this._x=Math.asin(ba(m,-1,1)),Math.abs(m)<.9999999?(this._y=Math.atan2(-f,p),this._z=Math.atan2(-o,u)):(this._y=0,this._z=Math.atan2(c,a));break;case"ZYX":this._y=Math.asin(-ba(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(m,p),this._z=Math.atan2(c,a)):(this._x=0,this._z=Math.atan2(-o,u));break;case"YZX":this._z=Math.asin(ba(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,p));break;case"XZY":this._z=Math.asin(-ba(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(m,u),this._y=Math.atan2(l,a)):(this._x=Math.atan2(-d,p),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+n)}return this._order=n,r===!0&&this._onChangeCallback(),this}setFromQuaternion(e,n,r){return s7.makeRotationFromQuaternion(e),this.setFromRotationMatrix(s7,n,r)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return o7.setFromEuler(this),this.setFromQuaternion(o7,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}}Oy.DEFAULT_ORDER="XYZ";class FJ{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 vIe=0;const l7=new We,dp=new Gf,Tc=new Er,J_=new We,gb=new We,_Ie=new We,wIe=new Gf,c7=new We(1,0,0),u7=new We(0,1,0),d7=new We(0,0,1),SIe={type:"added"},NIe={type:"removed"};class Xa extends rm{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:vIe++}),this.uuid=nu(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Xa.DEFAULT_UP.clone();const e=new We,n=new Oy,r=new Gf,i=new We(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 Er},normalMatrix:{value:new Cn}}),this.matrix=new Er,this.matrixWorld=new Er,this.matrixAutoUpdate=Xa.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Xa.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.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 dp.setFromAxisAngle(e,n),this.quaternion.multiply(dp),this}rotateOnWorldAxis(e,n){return dp.setFromAxisAngle(e,n),this.quaternion.premultiply(dp),this}rotateX(e){return this.rotateOnAxis(c7,e)}rotateY(e){return this.rotateOnAxis(u7,e)}rotateZ(e){return this.rotateOnAxis(d7,e)}translateOnAxis(e,n){return l7.copy(e).applyQuaternion(this.quaternion),this.position.add(l7.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(c7,e)}translateY(e){return this.translateOnAxis(u7,e)}translateZ(e){return this.translateOnAxis(d7,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Tc.copy(this.matrixWorld).invert())}lookAt(e,n,r){e.isVector3?J_.copy(e):J_.set(e,n,r);const i=this.parent;this.updateWorldMatrix(!0,!1),gb.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Tc.lookAt(gb,J_,this.up):Tc.lookAt(J_,gb,this.up),this.quaternion.setFromRotationMatrix(Tc),i&&(Tc.extractRotation(i.matrixWorld),dp.setFromRotationMatrix(Tc),this.quaternion.premultiply(dp.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(SIe)):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(NIe)),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),Tc.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Tc.multiply(e.parent.matrixWorld)),e.applyMatrix4(Tc),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(gb,e,_Ie),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(gb,wIe,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),m=o(e.skeletons),p=o(e.animations),x=o(e.nodes);l.length>0&&(r.geometries=l),c.length>0&&(r.materials=c),u.length>0&&(r.textures=u),d.length>0&&(r.images=d),f.length>0&&(r.shapes=f),m.length>0&&(r.skeletons=m),p.length>0&&(r.animations=p),x.length>0&&(r.nodes=x)}return r.object=i,r;function o(l){const c=[];for(const u in l){const d=l[u];delete d.metadata,c.push(d)}return c}}clone(e){return new this.constructor().copy(this,e)}copy(e,n=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),n===!0)for(let r=0;r<e.children.length;r++){const i=e.children[r];this.add(i.clone())}return this}}Xa.DEFAULT_UP=new We(0,1,0);Xa.DEFAULT_MATRIX_AUTO_UPDATE=!0;Xa.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Xo=new We,Ac=new We,bk=new We,Cc=new We,hp=new We,fp=new We,h7=new We,yk=new We,vk=new We,_k=new We;let e1=!1;class Yo{constructor(e=new We,n=new We,r=new We){this.a=e,this.b=n,this.c=r}static getNormal(e,n,r,i){i.subVectors(r,n),Xo.subVectors(e,n),i.cross(Xo);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){Xo.subVectors(i,n),Ac.subVectors(r,n),bk.subVectors(e,n);const o=Xo.dot(Xo),l=Xo.dot(Ac),c=Xo.dot(bk),u=Ac.dot(Ac),d=Ac.dot(bk),f=o*u-l*l;if(f===0)return a.set(-2,-1,-1);const m=1/f,p=(u*c-l*d)*m,x=(o*d-l*c)*m;return a.set(1-p-x,x,p)}static containsPoint(e,n,r,i){return this.getBarycoord(e,n,r,i,Cc),Cc.x>=0&&Cc.y>=0&&Cc.x+Cc.y<=1}static getUV(e,n,r,i,a,o,l,c){return e1===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),e1=!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,Cc),c.setScalar(0),c.addScaledVector(a,Cc.x),c.addScaledVector(o,Cc.y),c.addScaledVector(l,Cc.z),c}static isFrontFacing(e,n,r,i){return Xo.subVectors(r,n),Ac.subVectors(e,n),Xo.cross(Ac).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 Xo.subVectors(this.c,this.b),Ac.subVectors(this.a,this.b),Xo.cross(Ac).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Yo.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return Yo.getBarycoord(e,this.a,this.b,this.c,n)}getUV(e,n,r,i,a){return e1===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),e1=!0),Yo.getInterpolation(e,this.a,this.b,this.c,n,r,i,a)}getInterpolation(e,n,r,i,a){return Yo.getInterpolation(e,this.a,this.b,this.c,n,r,i,a)}containsPoint(e){return Yo.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Yo.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,n){const r=this.a,i=this.b,a=this.c;let o,l;hp.subVectors(i,r),fp.subVectors(a,r),yk.subVectors(e,r);const c=hp.dot(yk),u=fp.dot(yk);if(c<=0&&u<=0)return n.copy(r);vk.subVectors(e,i);const d=hp.dot(vk),f=fp.dot(vk);if(d>=0&&f<=d)return n.copy(i);const m=c*f-d*u;if(m<=0&&c>=0&&d<=0)return o=c/(c-d),n.copy(r).addScaledVector(hp,o);_k.subVectors(e,a);const p=hp.dot(_k),x=fp.dot(_k);if(x>=0&&p<=x)return n.copy(a);const y=p*u-c*x;if(y<=0&&u>=0&&x<=0)return l=u/(u-x),n.copy(r).addScaledVector(fp,l);const b=d*x-p*f;if(b<=0&&f-d>=0&&p-x>=0)return h7.subVectors(a,i),l=(f-d)/(f-d+(p-x)),n.copy(i).addScaledVector(h7,l);const v=1/(b+y+m);return o=y*v,l=m*v,n.copy(r).addScaledVector(hp,o).addScaledVector(fp,l)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const UJ={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},nd={h:0,s:0,l:0},t1={h:0,s:0,l:0};function wk(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 nn=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=xa){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,mr.toWorkingColorSpace(this,n),this}setRGB(e,n,r,i=mr.workingColorSpace){return this.r=e,this.g=n,this.b=r,mr.toWorkingColorSpace(this,i),this}setHSL(e,n,r,i=mr.workingColorSpace){if(e=UO(e,1),n=ba(n,0,1),r=ba(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=wk(o,a,e+1/3),this.g=wk(o,a,e),this.b=wk(o,a,e-1/3)}return mr.toWorkingColorSpace(this,i),this}setStyle(e,n=xa){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=xa){const r=UJ[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=Zp(e.r),this.g=Zp(e.g),this.b=Zp(e.b),this}copyLinearToSRGB(e){return this.r=uk(e.r),this.g=uk(e.g),this.b=uk(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=xa){return mr.fromWorkingColorSpace(Aa.copy(this),e),Math.round(ba(Aa.r*255,0,255))*65536+Math.round(ba(Aa.g*255,0,255))*256+Math.round(ba(Aa.b*255,0,255))}getHexString(e=xa){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=mr.workingColorSpace){mr.fromWorkingColorSpace(Aa.copy(this),n);const r=Aa.r,i=Aa.g,a=Aa.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=mr.workingColorSpace){return mr.fromWorkingColorSpace(Aa.copy(this),n),e.r=Aa.r,e.g=Aa.g,e.b=Aa.b,e}getStyle(e=xa){mr.fromWorkingColorSpace(Aa.copy(this),e);const n=Aa.r,r=Aa.g,i=Aa.b;return e!==xa?`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(nd),this.setHSL(nd.h+e,nd.s+n,nd.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(nd),e.getHSL(t1);const r=Hb(nd.h,t1.h,n),i=Hb(nd.s,t1.s,n),a=Hb(nd.l,t1.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 Aa=new nn;nn.NAMES=UJ;let MIe=0;class tx extends rm{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:MIe++}),this.uuid=nu(),this.name="",this.type="Material",this.blending=Qp,this.side=Yd,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=KP,this.blendDst=XP,this.blendEquation=qh,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new nn(0,0,0),this.blendAlpha=0,this.depthFunc=MS,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=JV,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=ap,this.stencilZFail=ap,this.stencilZPass=ap,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!==Qp&&(r.blending=this.blending),this.side!==Yd&&(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!==KP&&(r.blendSrc=this.blendSrc),this.blendDst!==XP&&(r.blendDst=this.blendDst),this.blendEquation!==qh&&(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!==MS&&(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!==JV&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==ap&&(r.stencilFail=this.stencilFail),this.stencilZFail!==ap&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==ap&&(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 zJ extends tx{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new nn(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=LO,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 bi=new We,n1=new pn;class qs{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=eR,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=Kc,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++)n1.fromBufferAttribute(this,n),n1.applyMatrix3(e),this.setXY(n,n1.x,n1.y);else if(this.itemSize===3)for(let n=0,r=this.count;n<r;n++)bi.fromBufferAttribute(this,n),bi.applyMatrix3(e),this.setXYZ(n,bi.x,bi.y,bi.z);return this}applyMatrix4(e){for(let n=0,r=this.count;n<r;n++)bi.fromBufferAttribute(this,n),bi.applyMatrix4(e),this.setXYZ(n,bi.x,bi.y,bi.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)bi.fromBufferAttribute(this,n),bi.applyNormalMatrix(e),this.setXYZ(n,bi.x,bi.y,bi.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)bi.fromBufferAttribute(this,n),bi.transformDirection(e),this.setXYZ(n,bi.x,bi.y,bi.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=kl(r,this.array)),r}setComponent(e,n,r){return this.normalized&&(r=fr(r,this.array)),this.array[e*this.itemSize+n]=r,this}getX(e){let n=this.array[e*this.itemSize];return this.normalized&&(n=kl(n,this.array)),n}setX(e,n){return this.normalized&&(n=fr(n,this.array)),this.array[e*this.itemSize]=n,this}getY(e){let n=this.array[e*this.itemSize+1];return this.normalized&&(n=kl(n,this.array)),n}setY(e,n){return this.normalized&&(n=fr(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=kl(n,this.array)),n}setZ(e,n){return this.normalized&&(n=fr(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=kl(n,this.array)),n}setW(e,n){return this.normalized&&(n=fr(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,r){return e*=this.itemSize,this.normalized&&(n=fr(n,this.array),r=fr(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=fr(n,this.array),r=fr(r,this.array),i=fr(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=fr(n,this.array),r=fr(r,this.array),i=fr(i,this.array),a=fr(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!==eR&&(e.usage=this.usage),e}}class BJ extends qs{constructor(e,n,r){super(new Uint16Array(e),n,r)}}class $J extends qs{constructor(e,n,r){super(new Uint32Array(e),n,r)}}class hi extends qs{constructor(e,n,r){super(new Float32Array(e),n,r)}}let EIe=0;const ho=new Er,Sk=new Xa,mp=new We,Is=new Co,xb=new Co,Wi=new We;class Ia extends rm{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:EIe++}),this.uuid=nu(),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(DJ(e)?$J:BJ)(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 Cn().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 ho.makeRotationFromQuaternion(e),this.applyMatrix4(ho),this}rotateX(e){return ho.makeRotationX(e),this.applyMatrix4(ho),this}rotateY(e){return ho.makeRotationY(e),this.applyMatrix4(ho),this}rotateZ(e){return ho.makeRotationZ(e),this.applyMatrix4(ho),this}translate(e,n,r){return ho.makeTranslation(e,n,r),this.applyMatrix4(ho),this}scale(e,n,r){return ho.makeScale(e,n,r),this.applyMatrix4(ho),this}lookAt(e){return Sk.lookAt(e),Sk.updateMatrix(),this.applyMatrix4(Sk.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(mp).negate(),this.translate(mp.x,mp.y,mp.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 hi(n,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Co);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 We(-1/0,-1/0,-1/0),new We(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];Is.setFromBufferAttribute(a),this.morphTargetsRelative?(Wi.addVectors(this.boundingBox.min,Is.min),this.boundingBox.expandByPoint(Wi),Wi.addVectors(this.boundingBox.max,Is.max),this.boundingBox.expandByPoint(Wi)):(this.boundingBox.expandByPoint(Is.min),this.boundingBox.expandByPoint(Is.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 Il);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 We,1/0);return}if(e){const r=this.boundingSphere.center;if(Is.setFromBufferAttribute(e),n)for(let a=0,o=n.length;a<o;a++){const l=n[a];xb.setFromBufferAttribute(l),this.morphTargetsRelative?(Wi.addVectors(Is.min,xb.min),Is.expandByPoint(Wi),Wi.addVectors(Is.max,xb.max),Is.expandByPoint(Wi)):(Is.expandByPoint(xb.min),Is.expandByPoint(xb.max))}Is.getCenter(r);let i=0;for(let a=0,o=e.count;a<o;a++)Wi.fromBufferAttribute(e,a),i=Math.max(i,r.distanceToSquared(Wi));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++)Wi.fromBufferAttribute(l,u),c&&(mp.fromBufferAttribute(e,u),Wi.add(mp)),i=Math.max(i,r.distanceToSquared(Wi))}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 qs(new Float32Array(4*l),4));const c=this.getAttribute("tangent").array,u=[],d=[];for(let R=0;R<l;R++)u[R]=new We,d[R]=new We;const f=new We,m=new We,p=new We,x=new pn,y=new pn,b=new pn,v=new We,N=new We;function S(R,F,L){f.fromArray(i,R*3),m.fromArray(i,F*3),p.fromArray(i,L*3),x.fromArray(o,R*2),y.fromArray(o,F*2),b.fromArray(o,L*2),m.sub(f),p.sub(f),y.sub(x),b.sub(x);const K=1/(y.x*b.y-b.x*y.y);isFinite(K)&&(v.copy(m).multiplyScalar(b.y).addScaledVector(p,-y.y).multiplyScalar(K),N.copy(p).multiplyScalar(y.x).addScaledVector(m,-b.x).multiplyScalar(K),u[R].add(v),u[F].add(v),u[L].add(v),d[R].add(N),d[F].add(N),d[L].add(N))}let T=this.groups;T.length===0&&(T=[{start:0,count:r.length}]);for(let R=0,F=T.length;R<F;++R){const L=T[R],K=L.start,j=L.count;for(let W=K,Y=K+j;W<Y;W+=3)S(r[W+0],r[W+1],r[W+2])}const E=new We,C=new We,A=new We,O=new We;function k(R){A.fromArray(a,R*3),O.copy(A);const F=u[R];E.copy(F),E.sub(A.multiplyScalar(A.dot(F))).normalize(),C.crossVectors(O,F);const K=C.dot(d[R])<0?-1:1;c[R*4]=E.x,c[R*4+1]=E.y,c[R*4+2]=E.z,c[R*4+3]=K}for(let R=0,F=T.length;R<F;++R){const L=T[R],K=L.start,j=L.count;for(let W=K,Y=K+j;W<Y;W+=3)k(r[W+0]),k(r[W+1]),k(r[W+2])}}computeVertexNormals(){const e=this.index,n=this.getAttribute("position");if(n!==void 0){let r=this.getAttribute("normal");if(r===void 0)r=new qs(new Float32Array(n.count*3),3),this.setAttribute("normal",r);else for(let m=0,p=r.count;m<p;m++)r.setXYZ(m,0,0,0);const i=new We,a=new We,o=new We,l=new We,c=new We,u=new We,d=new We,f=new We;if(e)for(let m=0,p=e.count;m<p;m+=3){const x=e.getX(m+0),y=e.getX(m+1),b=e.getX(m+2);i.fromBufferAttribute(n,x),a.fromBufferAttribute(n,y),o.fromBufferAttribute(n,b),d.subVectors(o,a),f.subVectors(i,a),d.cross(f),l.fromBufferAttribute(r,x),c.fromBufferAttribute(r,y),u.fromBufferAttribute(r,b),l.add(d),c.add(d),u.add(d),r.setXYZ(x,l.x,l.y,l.z),r.setXYZ(y,c.x,c.y,c.z),r.setXYZ(b,u.x,u.y,u.z)}else for(let m=0,p=n.count;m<p;m+=3)i.fromBufferAttribute(n,m+0),a.fromBufferAttribute(n,m+1),o.fromBufferAttribute(n,m+2),d.subVectors(o,a),f.subVectors(i,a),d.cross(f),r.setXYZ(m+0,d.x,d.y,d.z),r.setXYZ(m+1,d.x,d.y,d.z),r.setXYZ(m+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++)Wi.fromBufferAttribute(e,n),Wi.normalize(),e.setXYZ(n,Wi.x,Wi.y,Wi.z)}toNonIndexed(){function e(l,c){const u=l.array,d=l.itemSize,f=l.normalized,m=new u.constructor(c.length*d);let p=0,x=0;for(let y=0,b=c.length;y<b;y++){l.isInterleavedBufferAttribute?p=c[y]*l.data.stride+l.offset:p=c[y]*d;for(let v=0;v<d;v++)m[x++]=u[p++]}return new qs(m,d,f)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new Ia,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 m=u[d],p=e(m,r);c.push(p)}n.morphAttributes[l]=c}n.morphTargetsRelative=this.morphTargetsRelative;const o=this.groups;for(let l=0,c=o.length;l<c;l++){const u=o[l];n.addGroup(u.start,u.count,u.materialIndex)}return n}toJSON(){const e={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const c=this.parameters;for(const u in c)c[u]!==void 0&&(e[u]=c[u]);return e}e.data={attributes:{}};const n=this.index;n!==null&&(e.data.index={type:n.array.constructor.name,array:Array.prototype.slice.call(n.array)});const r=this.attributes;for(const c in r){const u=r[c];e.data.attributes[c]=u.toJSON(e.data)}const i={};let a=!1;for(const c in this.morphAttributes){const u=this.morphAttributes[c],d=[];for(let f=0,m=u.length;f<m;f++){const p=u[f];d.push(p.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 m=0,p=f.length;m<p;m++)d.push(f[m].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 f7=new Er,Lh=new zO,r1=new Il,m7=new We,pp=new We,gp=new We,xp=new We,Nk=new We,i1=new We,a1=new pn,s1=new pn,o1=new pn,p7=new We,g7=new We,x7=new We,l1=new We,c1=new We;class rl extends Xa{constructor(e=new Ia,n=new zJ){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){i1.set(0,0,0);for(let c=0,u=a.length;c<u;c++){const d=l[c],f=a[c];d!==0&&(Nk.fromBufferAttribute(f,e),o?i1.addScaledVector(Nk,d):i1.addScaledVector(Nk.sub(n),d))}n.add(i1)}return n}raycast(e,n){const r=this.geometry,i=this.material,a=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),r1.copy(r.boundingSphere),r1.applyMatrix4(a),Lh.copy(e.ray).recast(e.near),!(r1.containsPoint(Lh.origin)===!1&&(Lh.intersectSphere(r1,m7)===null||Lh.origin.distanceToSquared(m7)>(e.far-e.near)**2))&&(f7.copy(a).invert(),Lh.copy(e.ray).applyMatrix4(f7),!(r.boundingBox!==null&&Lh.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,n,Lh)))}_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,m=a.groups,p=a.drawRange;if(l!==null)if(Array.isArray(o))for(let x=0,y=m.length;x<y;x++){const b=m[x],v=o[b.materialIndex],N=Math.max(b.start,p.start),S=Math.min(l.count,Math.min(b.start+b.count,p.start+p.count));for(let T=N,E=S;T<E;T+=3){const C=l.getX(T),A=l.getX(T+1),O=l.getX(T+2);i=u1(this,v,e,r,u,d,f,C,A,O),i&&(i.faceIndex=Math.floor(T/3),i.face.materialIndex=b.materialIndex,n.push(i))}}else{const x=Math.max(0,p.start),y=Math.min(l.count,p.start+p.count);for(let b=x,v=y;b<v;b+=3){const N=l.getX(b),S=l.getX(b+1),T=l.getX(b+2);i=u1(this,o,e,r,u,d,f,N,S,T),i&&(i.faceIndex=Math.floor(b/3),n.push(i))}}else if(c!==void 0)if(Array.isArray(o))for(let x=0,y=m.length;x<y;x++){const b=m[x],v=o[b.materialIndex],N=Math.max(b.start,p.start),S=Math.min(c.count,Math.min(b.start+b.count,p.start+p.count));for(let T=N,E=S;T<E;T+=3){const C=T,A=T+1,O=T+2;i=u1(this,v,e,r,u,d,f,C,A,O),i&&(i.faceIndex=Math.floor(T/3),i.face.materialIndex=b.materialIndex,n.push(i))}}else{const x=Math.max(0,p.start),y=Math.min(c.count,p.start+p.count);for(let b=x,v=y;b<v;b+=3){const N=b,S=b+1,T=b+2;i=u1(this,o,e,r,u,d,f,N,S,T),i&&(i.faceIndex=Math.floor(b/3),n.push(i))}}}}function TIe(t,e,n,r,i,a,o,l){let c;if(e.side===ys?c=r.intersectTriangle(o,a,i,!0,l):c=r.intersectTriangle(i,a,o,e.side===Yd,l),c===null)return null;c1.copy(l),c1.applyMatrix4(t.matrixWorld);const u=n.ray.origin.distanceTo(c1);return u<n.near||u>n.far?null:{distance:u,point:c1.clone(),object:t}}function u1(t,e,n,r,i,a,o,l,c,u){t.getVertexPosition(l,pp),t.getVertexPosition(c,gp),t.getVertexPosition(u,xp);const d=TIe(t,e,n,r,pp,gp,xp,l1);if(d){i&&(a1.fromBufferAttribute(i,l),s1.fromBufferAttribute(i,c),o1.fromBufferAttribute(i,u),d.uv=Yo.getInterpolation(l1,pp,gp,xp,a1,s1,o1,new pn)),a&&(a1.fromBufferAttribute(a,l),s1.fromBufferAttribute(a,c),o1.fromBufferAttribute(a,u),d.uv1=Yo.getInterpolation(l1,pp,gp,xp,a1,s1,o1,new pn),d.uv2=d.uv1),o&&(p7.fromBufferAttribute(o,l),g7.fromBufferAttribute(o,c),x7.fromBufferAttribute(o,u),d.normal=Yo.getInterpolation(l1,pp,gp,xp,p7,g7,x7,new We),d.normal.dot(r.direction)>0&&d.normal.multiplyScalar(-1));const f={a:l,b:c,c:u,normal:new We,materialIndex:0};Yo.getNormal(pp,gp,xp,f.normal),d.face=f}return d}class Ly extends Ia{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 m=0,p=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 hi(u,3)),this.setAttribute("normal",new hi(d,3)),this.setAttribute("uv",new hi(f,2));function x(y,b,v,N,S,T,E,C,A,O,k){const R=T/A,F=E/O,L=T/2,K=E/2,j=C/2,W=A+1,Y=O+1;let q=0,Q=0;const ee=new We;for(let re=0;re<Y;re++){const z=re*F-K;for(let G=0;G<W;G++){const ae=G*R-L;ee[y]=ae*N,ee[b]=z*S,ee[v]=j,u.push(ee.x,ee.y,ee.z),ee[y]=0,ee[b]=0,ee[v]=C>0?1:-1,d.push(ee.x,ee.y,ee.z),f.push(G/A),f.push(1-re/O),q+=1}}for(let re=0;re<O;re++)for(let z=0;z<A;z++){const G=m+z+W*re,ae=m+z+W*(re+1),se=m+(z+1)+W*(re+1),ue=m+(z+1)+W*re;c.push(G,ae,ue),c.push(ae,se,ue),Q+=6}l.addGroup(p,Q,k),p+=Q,m+=q}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ly(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function Ng(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 Ha(t){const e={};for(let n=0;n<t.length;n++){const r=Ng(t[n]);for(const i in r)e[i]=r[i]}return e}function AIe(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function HJ(t){return t.getRenderTarget()===null?t.outputColorSpace:mr.workingColorSpace}const BO={clone:Ng,merge:Ha};var CIe=`void main() {
  3920. gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
  3921. }`,kIe=`void main() {
  3922. gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
  3923. }`;class Qd extends tx{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=CIe,this.fragmentShader=kIe,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=Ng(e.uniforms),this.uniformsGroups=AIe(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 VJ extends Xa{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Er,this.projectionMatrix=new Er,this.projectionMatrixInverse=new Er,this.coordinateSystem=Dl}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 Us 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=B0*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan($b*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return B0*2*Math.atan(Math.tan($b*.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($b*.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 bp=-90,yp=1;class jIe extends Xa{constructor(e,n,r){super(),this.type="CubeCamera",this.renderTarget=r,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new Us(bp,yp,e,n);i.layers=this.layers,this.add(i);const a=new Us(bp,yp,e,n);a.layers=this.layers,this.add(a);const o=new Us(bp,yp,e,n);o.layers=this.layers,this.add(o);const l=new Us(bp,yp,e,n);l.layers=this.layers,this.add(l);const c=new Us(bp,yp,e,n);c.layers=this.layers,this.add(c);const u=new Us(bp,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===Dl)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===z0)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(),m=e.getActiveCubeFace(),p=e.getActiveMipmapLevel(),x=e.xr.enabled;e.xr.enabled=!1;const y=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=y,e.setRenderTarget(r,5,i),e.render(n,d),e.setRenderTarget(f,m,p),e.xr.enabled=x,r.texture.needsPMREMUpdate=!0}}class GJ extends vs{constructor(e,n,r,i,a,o,l,c,u,d){e=e!==void 0?e:[],n=n!==void 0?n:_g,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 PIe extends Vf{constructor(e=1,n={}){super(e,e,n),this.isWebGLCubeRenderTarget=!0;const r={width:e,height:e,depth:1},i=[r,r,r,r,r,r];n.encoding!==void 0&&(Vb("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),n.colorSpace=n.encoding===bf?xa:No),this.texture=new GJ(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:wo}fromEquirectangularTexture(e,n){this.texture.type=n.type,this.texture.colorSpace=n.colorSpace,this.texture.generateMipmaps=n.generateMipmaps,this.texture.minFilter=n.minFilter,this.texture.magFilter=n.magFilter;const r={uniforms:{tEquirect:{value:null}},vertexShader:`
  3924. varying vec3 vWorldDirection;
  3925. vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
  3926. return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
  3927. }
  3928. void main() {
  3929. vWorldDirection = transformDirection( position, modelMatrix );
  3930. #include <begin_vertex>
  3931. #include <project_vertex>
  3932. }
  3933. `,fragmentShader:`
  3934. uniform sampler2D tEquirect;
  3935. varying vec3 vWorldDirection;
  3936. #include <common>
  3937. void main() {
  3938. vec3 direction = normalize( vWorldDirection );
  3939. vec2 sampleUV = equirectUv( direction );
  3940. gl_FragColor = texture2D( tEquirect, sampleUV );
  3941. }
  3942. `},i=new Ly(5,5,5),a=new Qd({name:"CubemapFromEquirect",uniforms:Ng(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:ys,blending:Dd});a.uniforms.tEquirect.value=n;const o=new rl(i,a),l=n.minFilter;return n.minFilter===F0&&(n.minFilter=wo),new jIe(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 Mk=new We,RIe=new We,DIe=new Cn;class dd{constructor(e=new We(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=Mk.subVectors(r,n).cross(RIe.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(Mk),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||DIe.getNormalMatrix(e),i=this.coplanarPoint(Mk).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 Ih=new Il,d1=new We;class qN{constructor(e=new dd,n=new dd,r=new dd,i=new dd,a=new dd,o=new dd){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=Dl){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],m=i[7],p=i[8],x=i[9],y=i[10],b=i[11],v=i[12],N=i[13],S=i[14],T=i[15];if(r[0].setComponents(c-a,m-u,b-p,T-v).normalize(),r[1].setComponents(c+a,m+u,b+p,T+v).normalize(),r[2].setComponents(c+o,m+d,b+x,T+N).normalize(),r[3].setComponents(c-o,m-d,b-x,T-N).normalize(),r[4].setComponents(c-l,m-f,b-y,T-S).normalize(),n===Dl)r[5].setComponents(c+l,m+f,b+y,T+S).normalize();else if(n===z0)r[5].setComponents(l,f,y,S).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(),Ih.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),Ih.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Ih)}intersectsSprite(e){return Ih.center.set(0,0,0),Ih.radius=.7071067811865476,Ih.applyMatrix4(e.matrixWorld),this.intersectsSphere(Ih)}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(d1.x=i.normal.x>0?e.max.x:e.min.x,d1.y=i.normal.y>0?e.max.y:e.min.y,d1.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(d1)<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 WJ(){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 OIe(t,e){const n=e.isWebGL2,r=new WeakMap;function i(u,d){const f=u.array,m=u.usage,p=f.byteLength,x=t.createBuffer();t.bindBuffer(d,x),t.bufferData(d,f,m),u.onUploadCallback();let y;if(f instanceof Float32Array)y=t.FLOAT;else if(f instanceof Uint16Array)if(u.isFloat16BufferAttribute)if(n)y=t.HALF_FLOAT;else throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");else y=t.UNSIGNED_SHORT;else if(f instanceof Int16Array)y=t.SHORT;else if(f instanceof Uint32Array)y=t.UNSIGNED_INT;else if(f instanceof Int32Array)y=t.INT;else if(f instanceof Int8Array)y=t.BYTE;else if(f instanceof Uint8Array)y=t.UNSIGNED_BYTE;else if(f instanceof Uint8ClampedArray)y=t.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+f);return{buffer:x,type:y,bytesPerElement:f.BYTES_PER_ELEMENT,version:u.version,size:p}}function a(u,d,f){const m=d.array,p=d._updateRange,x=d.updateRanges;if(t.bindBuffer(f,u),p.count===-1&&x.length===0&&t.bufferSubData(f,0,m),x.length!==0){for(let y=0,b=x.length;y<b;y++){const v=x[y];n?t.bufferSubData(f,v.start*m.BYTES_PER_ELEMENT,m,v.start,v.count):t.bufferSubData(f,v.start*m.BYTES_PER_ELEMENT,m.subarray(v.start,v.start+v.count))}d.clearUpdateRanges()}p.count!==-1&&(n?t.bufferSubData(f,p.offset*m.BYTES_PER_ELEMENT,m,p.offset,p.count):t.bufferSubData(f,p.offset*m.BYTES_PER_ELEMENT,m.subarray(p.offset,p.offset+p.count)),p.count=-1),d.onUploadCallback()}function o(u){return u.isInterleavedBufferAttribute&&(u=u.data),r.get(u)}function l(u){u.isInterleavedBufferAttribute&&(u=u.data);const d=r.get(u);d&&(t.deleteBuffer(d.buffer),r.delete(u))}function c(u,d){if(u.isGLBufferAttribute){const m=r.get(u);(!m||m.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 $O extends Ia{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,m=n/c,p=[],x=[],y=[],b=[];for(let v=0;v<d;v++){const N=v*m-o;for(let S=0;S<u;S++){const T=S*f-a;x.push(T,-N,0),y.push(0,0,1),b.push(S/l),b.push(1-v/c)}}for(let v=0;v<c;v++)for(let N=0;N<l;N++){const S=N+u*v,T=N+u*(v+1),E=N+1+u*(v+1),C=N+1+u*v;p.push(S,T,C),p.push(T,E,C)}this.setIndex(p),this.setAttribute("position",new hi(x,3)),this.setAttribute("normal",new hi(y,3)),this.setAttribute("uv",new hi(b,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new $O(e.width,e.height,e.widthSegments,e.heightSegments)}}var LIe=`#ifdef USE_ALPHAHASH
  3943. if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
  3944. #endif`,IIe=`#ifdef USE_ALPHAHASH
  3945. const float ALPHA_HASH_SCALE = 0.05;
  3946. float hash2D( vec2 value ) {
  3947. return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
  3948. }
  3949. float hash3D( vec3 value ) {
  3950. return hash2D( vec2( hash2D( value.xy ), value.z ) );
  3951. }
  3952. float getAlphaHashThreshold( vec3 position ) {
  3953. float maxDeriv = max(
  3954. length( dFdx( position.xyz ) ),
  3955. length( dFdy( position.xyz ) )
  3956. );
  3957. float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
  3958. vec2 pixScales = vec2(
  3959. exp2( floor( log2( pixScale ) ) ),
  3960. exp2( ceil( log2( pixScale ) ) )
  3961. );
  3962. vec2 alpha = vec2(
  3963. hash3D( floor( pixScales.x * position.xyz ) ),
  3964. hash3D( floor( pixScales.y * position.xyz ) )
  3965. );
  3966. float lerpFactor = fract( log2( pixScale ) );
  3967. float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
  3968. float a = min( lerpFactor, 1.0 - lerpFactor );
  3969. vec3 cases = vec3(
  3970. x * x / ( 2.0 * a * ( 1.0 - a ) ),
  3971. ( x - 0.5 * a ) / ( 1.0 - a ),
  3972. 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
  3973. );
  3974. float threshold = ( x < ( 1.0 - a ) )
  3975. ? ( ( x < a ) ? cases.x : cases.y )
  3976. : cases.z;
  3977. return clamp( threshold , 1.0e-6, 1.0 );
  3978. }
  3979. #endif`,FIe=`#ifdef USE_ALPHAMAP
  3980. diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
  3981. #endif`,UIe=`#ifdef USE_ALPHAMAP
  3982. uniform sampler2D alphaMap;
  3983. #endif`,zIe=`#ifdef USE_ALPHATEST
  3984. if ( diffuseColor.a < alphaTest ) discard;
  3985. #endif`,BIe=`#ifdef USE_ALPHATEST
  3986. uniform float alphaTest;
  3987. #endif`,$Ie=`#ifdef USE_AOMAP
  3988. float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
  3989. reflectedLight.indirectDiffuse *= ambientOcclusion;
  3990. #if defined( USE_CLEARCOAT )
  3991. clearcoatSpecularIndirect *= ambientOcclusion;
  3992. #endif
  3993. #if defined( USE_SHEEN )
  3994. sheenSpecularIndirect *= ambientOcclusion;
  3995. #endif
  3996. #if defined( USE_ENVMAP ) && defined( STANDARD )
  3997. float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
  3998. reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
  3999. #endif
  4000. #endif`,HIe=`#ifdef USE_AOMAP
  4001. uniform sampler2D aoMap;
  4002. uniform float aoMapIntensity;
  4003. #endif`,VIe=`#ifdef USE_BATCHING
  4004. attribute float batchId;
  4005. uniform highp sampler2D batchingTexture;
  4006. mat4 getBatchingMatrix( const in float i ) {
  4007. int size = textureSize( batchingTexture, 0 ).x;
  4008. int j = int( i ) * 4;
  4009. int x = j % size;
  4010. int y = j / size;
  4011. vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
  4012. vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
  4013. vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
  4014. vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
  4015. return mat4( v1, v2, v3, v4 );
  4016. }
  4017. #endif`,GIe=`#ifdef USE_BATCHING
  4018. mat4 batchingMatrix = getBatchingMatrix( batchId );
  4019. #endif`,WIe=`vec3 transformed = vec3( position );
  4020. #ifdef USE_ALPHAHASH
  4021. vPosition = vec3( position );
  4022. #endif`,qIe=`vec3 objectNormal = vec3( normal );
  4023. #ifdef USE_TANGENT
  4024. vec3 objectTangent = vec3( tangent.xyz );
  4025. #endif`,KIe=`float G_BlinnPhong_Implicit( ) {
  4026. return 0.25;
  4027. }
  4028. float D_BlinnPhong( const in float shininess, const in float dotNH ) {
  4029. return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
  4030. }
  4031. vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
  4032. vec3 halfDir = normalize( lightDir + viewDir );
  4033. float dotNH = saturate( dot( normal, halfDir ) );
  4034. float dotVH = saturate( dot( viewDir, halfDir ) );
  4035. vec3 F = F_Schlick( specularColor, 1.0, dotVH );
  4036. float G = G_BlinnPhong_Implicit( );
  4037. float D = D_BlinnPhong( shininess, dotNH );
  4038. return F * ( G * D );
  4039. } // validated`,XIe=`#ifdef USE_IRIDESCENCE
  4040. const mat3 XYZ_TO_REC709 = mat3(
  4041. 3.2404542, -0.9692660, 0.0556434,
  4042. -1.5371385, 1.8760108, -0.2040259,
  4043. -0.4985314, 0.0415560, 1.0572252
  4044. );
  4045. vec3 Fresnel0ToIor( vec3 fresnel0 ) {
  4046. vec3 sqrtF0 = sqrt( fresnel0 );
  4047. return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
  4048. }
  4049. vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
  4050. return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
  4051. }
  4052. float IorToFresnel0( float transmittedIor, float incidentIor ) {
  4053. return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
  4054. }
  4055. vec3 evalSensitivity( float OPD, vec3 shift ) {
  4056. float phase = 2.0 * PI * OPD * 1.0e-9;
  4057. vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
  4058. vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
  4059. vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
  4060. vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
  4061. xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );
  4062. xyz /= 1.0685e-7;
  4063. vec3 rgb = XYZ_TO_REC709 * xyz;
  4064. return rgb;
  4065. }
  4066. vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
  4067. vec3 I;
  4068. float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
  4069. float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
  4070. float cosTheta2Sq = 1.0 - sinTheta2Sq;
  4071. if ( cosTheta2Sq < 0.0 ) {
  4072. return vec3( 1.0 );
  4073. }
  4074. float cosTheta2 = sqrt( cosTheta2Sq );
  4075. float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
  4076. float R12 = F_Schlick( R0, 1.0, cosTheta1 );
  4077. float T121 = 1.0 - R12;
  4078. float phi12 = 0.0;
  4079. if ( iridescenceIOR < outsideIOR ) phi12 = PI;
  4080. float phi21 = PI - phi12;
  4081. vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
  4082. vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
  4083. vec3 phi23 = vec3( 0.0 );
  4084. if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
  4085. if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
  4086. if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
  4087. float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
  4088. vec3 phi = vec3( phi21 ) + phi23;
  4089. vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
  4090. vec3 r123 = sqrt( R123 );
  4091. vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
  4092. vec3 C0 = R12 + Rs;
  4093. I = C0;
  4094. vec3 Cm = Rs - T121;
  4095. for ( int m = 1; m <= 2; ++ m ) {
  4096. Cm *= r123;
  4097. vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
  4098. I += Cm * Sm;
  4099. }
  4100. return max( I, vec3( 0.0 ) );
  4101. }
  4102. #endif`,YIe=`#ifdef USE_BUMPMAP
  4103. uniform sampler2D bumpMap;
  4104. uniform float bumpScale;
  4105. vec2 dHdxy_fwd() {
  4106. vec2 dSTdx = dFdx( vBumpMapUv );
  4107. vec2 dSTdy = dFdy( vBumpMapUv );
  4108. float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
  4109. float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
  4110. float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
  4111. return vec2( dBx, dBy );
  4112. }
  4113. vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
  4114. vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
  4115. vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
  4116. vec3 vN = surf_norm;
  4117. vec3 R1 = cross( vSigmaY, vN );
  4118. vec3 R2 = cross( vN, vSigmaX );
  4119. float fDet = dot( vSigmaX, R1 ) * faceDirection;
  4120. vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
  4121. return normalize( abs( fDet ) * surf_norm - vGrad );
  4122. }
  4123. #endif`,QIe=`#if NUM_CLIPPING_PLANES > 0
  4124. vec4 plane;
  4125. #pragma unroll_loop_start
  4126. for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
  4127. plane = clippingPlanes[ i ];
  4128. if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
  4129. }
  4130. #pragma unroll_loop_end
  4131. #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
  4132. bool clipped = true;
  4133. #pragma unroll_loop_start
  4134. for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
  4135. plane = clippingPlanes[ i ];
  4136. clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
  4137. }
  4138. #pragma unroll_loop_end
  4139. if ( clipped ) discard;
  4140. #endif
  4141. #endif`,ZIe=`#if NUM_CLIPPING_PLANES > 0
  4142. varying vec3 vClipPosition;
  4143. uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
  4144. #endif`,JIe=`#if NUM_CLIPPING_PLANES > 0
  4145. varying vec3 vClipPosition;
  4146. #endif`,e5e=`#if NUM_CLIPPING_PLANES > 0
  4147. vClipPosition = - mvPosition.xyz;
  4148. #endif`,t5e=`#if defined( USE_COLOR_ALPHA )
  4149. diffuseColor *= vColor;
  4150. #elif defined( USE_COLOR )
  4151. diffuseColor.rgb *= vColor;
  4152. #endif`,n5e=`#if defined( USE_COLOR_ALPHA )
  4153. varying vec4 vColor;
  4154. #elif defined( USE_COLOR )
  4155. varying vec3 vColor;
  4156. #endif`,r5e=`#if defined( USE_COLOR_ALPHA )
  4157. varying vec4 vColor;
  4158. #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
  4159. varying vec3 vColor;
  4160. #endif`,i5e=`#if defined( USE_COLOR_ALPHA )
  4161. vColor = vec4( 1.0 );
  4162. #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
  4163. vColor = vec3( 1.0 );
  4164. #endif
  4165. #ifdef USE_COLOR
  4166. vColor *= color;
  4167. #endif
  4168. #ifdef USE_INSTANCING_COLOR
  4169. vColor.xyz *= instanceColor.xyz;
  4170. #endif`,a5e=`#define PI 3.141592653589793
  4171. #define PI2 6.283185307179586
  4172. #define PI_HALF 1.5707963267948966
  4173. #define RECIPROCAL_PI 0.3183098861837907
  4174. #define RECIPROCAL_PI2 0.15915494309189535
  4175. #define EPSILON 1e-6
  4176. #ifndef saturate
  4177. #define saturate( a ) clamp( a, 0.0, 1.0 )
  4178. #endif
  4179. #define whiteComplement( a ) ( 1.0 - saturate( a ) )
  4180. float pow2( const in float x ) { return x*x; }
  4181. vec3 pow2( const in vec3 x ) { return x*x; }
  4182. float pow3( const in float x ) { return x*x*x; }
  4183. float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
  4184. float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
  4185. float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
  4186. highp float rand( const in vec2 uv ) {
  4187. const highp float a = 12.9898, b = 78.233, c = 43758.5453;
  4188. highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
  4189. return fract( sin( sn ) * c );
  4190. }
  4191. #ifdef HIGH_PRECISION
  4192. float precisionSafeLength( vec3 v ) { return length( v ); }
  4193. #else
  4194. float precisionSafeLength( vec3 v ) {
  4195. float maxComponent = max3( abs( v ) );
  4196. return length( v / maxComponent ) * maxComponent;
  4197. }
  4198. #endif
  4199. struct IncidentLight {
  4200. vec3 color;
  4201. vec3 direction;
  4202. bool visible;
  4203. };
  4204. struct ReflectedLight {
  4205. vec3 directDiffuse;
  4206. vec3 directSpecular;
  4207. vec3 indirectDiffuse;
  4208. vec3 indirectSpecular;
  4209. };
  4210. #ifdef USE_ALPHAHASH
  4211. varying vec3 vPosition;
  4212. #endif
  4213. vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
  4214. return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
  4215. }
  4216. vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
  4217. return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
  4218. }
  4219. mat3 transposeMat3( const in mat3 m ) {
  4220. mat3 tmp;
  4221. tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
  4222. tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
  4223. tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
  4224. return tmp;
  4225. }
  4226. float luminance( const in vec3 rgb ) {
  4227. const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );
  4228. return dot( weights, rgb );
  4229. }
  4230. bool isPerspectiveMatrix( mat4 m ) {
  4231. return m[ 2 ][ 3 ] == - 1.0;
  4232. }
  4233. vec2 equirectUv( in vec3 dir ) {
  4234. float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
  4235. float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
  4236. return vec2( u, v );
  4237. }
  4238. vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
  4239. return RECIPROCAL_PI * diffuseColor;
  4240. }
  4241. vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
  4242. float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
  4243. return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
  4244. }
  4245. float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
  4246. float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
  4247. return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
  4248. } // validated`,s5e=`#ifdef ENVMAP_TYPE_CUBE_UV
  4249. #define cubeUV_minMipLevel 4.0
  4250. #define cubeUV_minTileSize 16.0
  4251. float getFace( vec3 direction ) {
  4252. vec3 absDirection = abs( direction );
  4253. float face = - 1.0;
  4254. if ( absDirection.x > absDirection.z ) {
  4255. if ( absDirection.x > absDirection.y )
  4256. face = direction.x > 0.0 ? 0.0 : 3.0;
  4257. else
  4258. face = direction.y > 0.0 ? 1.0 : 4.0;
  4259. } else {
  4260. if ( absDirection.z > absDirection.y )
  4261. face = direction.z > 0.0 ? 2.0 : 5.0;
  4262. else
  4263. face = direction.y > 0.0 ? 1.0 : 4.0;
  4264. }
  4265. return face;
  4266. }
  4267. vec2 getUV( vec3 direction, float face ) {
  4268. vec2 uv;
  4269. if ( face == 0.0 ) {
  4270. uv = vec2( direction.z, direction.y ) / abs( direction.x );
  4271. } else if ( face == 1.0 ) {
  4272. uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
  4273. } else if ( face == 2.0 ) {
  4274. uv = vec2( - direction.x, direction.y ) / abs( direction.z );
  4275. } else if ( face == 3.0 ) {
  4276. uv = vec2( - direction.z, direction.y ) / abs( direction.x );
  4277. } else if ( face == 4.0 ) {
  4278. uv = vec2( - direction.x, direction.z ) / abs( direction.y );
  4279. } else {
  4280. uv = vec2( direction.x, direction.y ) / abs( direction.z );
  4281. }
  4282. return 0.5 * ( uv + 1.0 );
  4283. }
  4284. vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
  4285. float face = getFace( direction );
  4286. float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
  4287. mipInt = max( mipInt, cubeUV_minMipLevel );
  4288. float faceSize = exp2( mipInt );
  4289. highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
  4290. if ( face > 2.0 ) {
  4291. uv.y += faceSize;
  4292. face -= 3.0;
  4293. }
  4294. uv.x += face * faceSize;
  4295. uv.x += filterInt * 3.0 * cubeUV_minTileSize;
  4296. uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
  4297. uv.x *= CUBEUV_TEXEL_WIDTH;
  4298. uv.y *= CUBEUV_TEXEL_HEIGHT;
  4299. #ifdef texture2DGradEXT
  4300. return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
  4301. #else
  4302. return texture2D( envMap, uv ).rgb;
  4303. #endif
  4304. }
  4305. #define cubeUV_r0 1.0
  4306. #define cubeUV_v0 0.339
  4307. #define cubeUV_m0 - 2.0
  4308. #define cubeUV_r1 0.8
  4309. #define cubeUV_v1 0.276
  4310. #define cubeUV_m1 - 1.0
  4311. #define cubeUV_r4 0.4
  4312. #define cubeUV_v4 0.046
  4313. #define cubeUV_m4 2.0
  4314. #define cubeUV_r5 0.305
  4315. #define cubeUV_v5 0.016
  4316. #define cubeUV_m5 3.0
  4317. #define cubeUV_r6 0.21
  4318. #define cubeUV_v6 0.0038
  4319. #define cubeUV_m6 4.0
  4320. float roughnessToMip( float roughness ) {
  4321. float mip = 0.0;
  4322. if ( roughness >= cubeUV_r1 ) {
  4323. mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
  4324. } else if ( roughness >= cubeUV_r4 ) {
  4325. mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
  4326. } else if ( roughness >= cubeUV_r5 ) {
  4327. mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
  4328. } else if ( roughness >= cubeUV_r6 ) {
  4329. mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
  4330. } else {
  4331. mip = - 2.0 * log2( 1.16 * roughness ); }
  4332. return mip;
  4333. }
  4334. vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
  4335. float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
  4336. float mipF = fract( mip );
  4337. float mipInt = floor( mip );
  4338. vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
  4339. if ( mipF == 0.0 ) {
  4340. return vec4( color0, 1.0 );
  4341. } else {
  4342. vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
  4343. return vec4( mix( color0, color1, mipF ), 1.0 );
  4344. }
  4345. }
  4346. #endif`,o5e=`vec3 transformedNormal = objectNormal;
  4347. #ifdef USE_TANGENT
  4348. vec3 transformedTangent = objectTangent;
  4349. #endif
  4350. #ifdef USE_BATCHING
  4351. mat3 bm = mat3( batchingMatrix );
  4352. transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
  4353. transformedNormal = bm * transformedNormal;
  4354. #ifdef USE_TANGENT
  4355. transformedTangent = bm * transformedTangent;
  4356. #endif
  4357. #endif
  4358. #ifdef USE_INSTANCING
  4359. mat3 im = mat3( instanceMatrix );
  4360. transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
  4361. transformedNormal = im * transformedNormal;
  4362. #ifdef USE_TANGENT
  4363. transformedTangent = im * transformedTangent;
  4364. #endif
  4365. #endif
  4366. transformedNormal = normalMatrix * transformedNormal;
  4367. #ifdef FLIP_SIDED
  4368. transformedNormal = - transformedNormal;
  4369. #endif
  4370. #ifdef USE_TANGENT
  4371. transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
  4372. #ifdef FLIP_SIDED
  4373. transformedTangent = - transformedTangent;
  4374. #endif
  4375. #endif`,l5e=`#ifdef USE_DISPLACEMENTMAP
  4376. uniform sampler2D displacementMap;
  4377. uniform float displacementScale;
  4378. uniform float displacementBias;
  4379. #endif`,c5e=`#ifdef USE_DISPLACEMENTMAP
  4380. transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
  4381. #endif`,u5e=`#ifdef USE_EMISSIVEMAP
  4382. vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
  4383. totalEmissiveRadiance *= emissiveColor.rgb;
  4384. #endif`,d5e=`#ifdef USE_EMISSIVEMAP
  4385. uniform sampler2D emissiveMap;
  4386. #endif`,h5e="gl_FragColor = linearToOutputTexel( gl_FragColor );",f5e=`
  4387. const mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3(
  4388. vec3( 0.8224621, 0.177538, 0.0 ),
  4389. vec3( 0.0331941, 0.9668058, 0.0 ),
  4390. vec3( 0.0170827, 0.0723974, 0.9105199 )
  4391. );
  4392. const mat3 LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = mat3(
  4393. vec3( 1.2249401, - 0.2249404, 0.0 ),
  4394. vec3( - 0.0420569, 1.0420571, 0.0 ),
  4395. vec3( - 0.0196376, - 0.0786361, 1.0982735 )
  4396. );
  4397. vec4 LinearSRGBToLinearDisplayP3( in vec4 value ) {
  4398. return vec4( value.rgb * LINEAR_SRGB_TO_LINEAR_DISPLAY_P3, value.a );
  4399. }
  4400. vec4 LinearDisplayP3ToLinearSRGB( in vec4 value ) {
  4401. return vec4( value.rgb * LINEAR_DISPLAY_P3_TO_LINEAR_SRGB, value.a );
  4402. }
  4403. vec4 LinearTransferOETF( in vec4 value ) {
  4404. return value;
  4405. }
  4406. vec4 sRGBTransferOETF( in vec4 value ) {
  4407. return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
  4408. }
  4409. vec4 LinearToLinear( in vec4 value ) {
  4410. return value;
  4411. }
  4412. vec4 LinearTosRGB( in vec4 value ) {
  4413. return sRGBTransferOETF( value );
  4414. }`,m5e=`#ifdef USE_ENVMAP
  4415. #ifdef ENV_WORLDPOS
  4416. vec3 cameraToFrag;
  4417. if ( isOrthographic ) {
  4418. cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
  4419. } else {
  4420. cameraToFrag = normalize( vWorldPosition - cameraPosition );
  4421. }
  4422. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  4423. #ifdef ENVMAP_MODE_REFLECTION
  4424. vec3 reflectVec = reflect( cameraToFrag, worldNormal );
  4425. #else
  4426. vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
  4427. #endif
  4428. #else
  4429. vec3 reflectVec = vReflect;
  4430. #endif
  4431. #ifdef ENVMAP_TYPE_CUBE
  4432. vec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
  4433. #else
  4434. vec4 envColor = vec4( 0.0 );
  4435. #endif
  4436. #ifdef ENVMAP_BLENDING_MULTIPLY
  4437. outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
  4438. #elif defined( ENVMAP_BLENDING_MIX )
  4439. outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
  4440. #elif defined( ENVMAP_BLENDING_ADD )
  4441. outgoingLight += envColor.xyz * specularStrength * reflectivity;
  4442. #endif
  4443. #endif`,p5e=`#ifdef USE_ENVMAP
  4444. uniform float envMapIntensity;
  4445. uniform float flipEnvMap;
  4446. #ifdef ENVMAP_TYPE_CUBE
  4447. uniform samplerCube envMap;
  4448. #else
  4449. uniform sampler2D envMap;
  4450. #endif
  4451. #endif`,g5e=`#ifdef USE_ENVMAP
  4452. uniform float reflectivity;
  4453. #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
  4454. #define ENV_WORLDPOS
  4455. #endif
  4456. #ifdef ENV_WORLDPOS
  4457. varying vec3 vWorldPosition;
  4458. uniform float refractionRatio;
  4459. #else
  4460. varying vec3 vReflect;
  4461. #endif
  4462. #endif`,x5e=`#ifdef USE_ENVMAP
  4463. #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
  4464. #define ENV_WORLDPOS
  4465. #endif
  4466. #ifdef ENV_WORLDPOS
  4467. varying vec3 vWorldPosition;
  4468. #else
  4469. varying vec3 vReflect;
  4470. uniform float refractionRatio;
  4471. #endif
  4472. #endif`,b5e=`#ifdef USE_ENVMAP
  4473. #ifdef ENV_WORLDPOS
  4474. vWorldPosition = worldPosition.xyz;
  4475. #else
  4476. vec3 cameraToVertex;
  4477. if ( isOrthographic ) {
  4478. cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
  4479. } else {
  4480. cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
  4481. }
  4482. vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
  4483. #ifdef ENVMAP_MODE_REFLECTION
  4484. vReflect = reflect( cameraToVertex, worldNormal );
  4485. #else
  4486. vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
  4487. #endif
  4488. #endif
  4489. #endif`,y5e=`#ifdef USE_FOG
  4490. vFogDepth = - mvPosition.z;
  4491. #endif`,v5e=`#ifdef USE_FOG
  4492. varying float vFogDepth;
  4493. #endif`,_5e=`#ifdef USE_FOG
  4494. #ifdef FOG_EXP2
  4495. float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
  4496. #else
  4497. float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
  4498. #endif
  4499. gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
  4500. #endif`,w5e=`#ifdef USE_FOG
  4501. uniform vec3 fogColor;
  4502. varying float vFogDepth;
  4503. #ifdef FOG_EXP2
  4504. uniform float fogDensity;
  4505. #else
  4506. uniform float fogNear;
  4507. uniform float fogFar;
  4508. #endif
  4509. #endif`,S5e=`#ifdef USE_GRADIENTMAP
  4510. uniform sampler2D gradientMap;
  4511. #endif
  4512. vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
  4513. float dotNL = dot( normal, lightDirection );
  4514. vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
  4515. #ifdef USE_GRADIENTMAP
  4516. return vec3( texture2D( gradientMap, coord ).r );
  4517. #else
  4518. vec2 fw = fwidth( coord ) * 0.5;
  4519. return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
  4520. #endif
  4521. }`,N5e=`#ifdef USE_LIGHTMAP
  4522. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  4523. vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
  4524. reflectedLight.indirectDiffuse += lightMapIrradiance;
  4525. #endif`,M5e=`#ifdef USE_LIGHTMAP
  4526. uniform sampler2D lightMap;
  4527. uniform float lightMapIntensity;
  4528. #endif`,E5e=`LambertMaterial material;
  4529. material.diffuseColor = diffuseColor.rgb;
  4530. material.specularStrength = specularStrength;`,T5e=`varying vec3 vViewPosition;
  4531. struct LambertMaterial {
  4532. vec3 diffuseColor;
  4533. float specularStrength;
  4534. };
  4535. void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
  4536. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  4537. vec3 irradiance = dotNL * directLight.color;
  4538. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4539. }
  4540. void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
  4541. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4542. }
  4543. #define RE_Direct RE_Direct_Lambert
  4544. #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,A5e=`uniform bool receiveShadow;
  4545. uniform vec3 ambientLightColor;
  4546. #if defined( USE_LIGHT_PROBES )
  4547. uniform vec3 lightProbe[ 9 ];
  4548. #endif
  4549. vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
  4550. float x = normal.x, y = normal.y, z = normal.z;
  4551. vec3 result = shCoefficients[ 0 ] * 0.886227;
  4552. result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
  4553. result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
  4554. result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
  4555. result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
  4556. result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
  4557. result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
  4558. result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
  4559. result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
  4560. return result;
  4561. }
  4562. vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
  4563. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  4564. vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
  4565. return irradiance;
  4566. }
  4567. vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
  4568. vec3 irradiance = ambientLightColor;
  4569. return irradiance;
  4570. }
  4571. float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
  4572. #if defined ( LEGACY_LIGHTS )
  4573. if ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {
  4574. return pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );
  4575. }
  4576. return 1.0;
  4577. #else
  4578. float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
  4579. if ( cutoffDistance > 0.0 ) {
  4580. distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
  4581. }
  4582. return distanceFalloff;
  4583. #endif
  4584. }
  4585. float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
  4586. return smoothstep( coneCosine, penumbraCosine, angleCosine );
  4587. }
  4588. #if NUM_DIR_LIGHTS > 0
  4589. struct DirectionalLight {
  4590. vec3 direction;
  4591. vec3 color;
  4592. };
  4593. uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
  4594. void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
  4595. light.color = directionalLight.color;
  4596. light.direction = directionalLight.direction;
  4597. light.visible = true;
  4598. }
  4599. #endif
  4600. #if NUM_POINT_LIGHTS > 0
  4601. struct PointLight {
  4602. vec3 position;
  4603. vec3 color;
  4604. float distance;
  4605. float decay;
  4606. };
  4607. uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
  4608. void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
  4609. vec3 lVector = pointLight.position - geometryPosition;
  4610. light.direction = normalize( lVector );
  4611. float lightDistance = length( lVector );
  4612. light.color = pointLight.color;
  4613. light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
  4614. light.visible = ( light.color != vec3( 0.0 ) );
  4615. }
  4616. #endif
  4617. #if NUM_SPOT_LIGHTS > 0
  4618. struct SpotLight {
  4619. vec3 position;
  4620. vec3 direction;
  4621. vec3 color;
  4622. float distance;
  4623. float decay;
  4624. float coneCos;
  4625. float penumbraCos;
  4626. };
  4627. uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
  4628. void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
  4629. vec3 lVector = spotLight.position - geometryPosition;
  4630. light.direction = normalize( lVector );
  4631. float angleCos = dot( light.direction, spotLight.direction );
  4632. float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
  4633. if ( spotAttenuation > 0.0 ) {
  4634. float lightDistance = length( lVector );
  4635. light.color = spotLight.color * spotAttenuation;
  4636. light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
  4637. light.visible = ( light.color != vec3( 0.0 ) );
  4638. } else {
  4639. light.color = vec3( 0.0 );
  4640. light.visible = false;
  4641. }
  4642. }
  4643. #endif
  4644. #if NUM_RECT_AREA_LIGHTS > 0
  4645. struct RectAreaLight {
  4646. vec3 color;
  4647. vec3 position;
  4648. vec3 halfWidth;
  4649. vec3 halfHeight;
  4650. };
  4651. uniform sampler2D ltc_1; uniform sampler2D ltc_2;
  4652. uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
  4653. #endif
  4654. #if NUM_HEMI_LIGHTS > 0
  4655. struct HemisphereLight {
  4656. vec3 direction;
  4657. vec3 skyColor;
  4658. vec3 groundColor;
  4659. };
  4660. uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
  4661. vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
  4662. float dotNL = dot( normal, hemiLight.direction );
  4663. float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
  4664. vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
  4665. return irradiance;
  4666. }
  4667. #endif`,C5e=`#ifdef USE_ENVMAP
  4668. vec3 getIBLIrradiance( const in vec3 normal ) {
  4669. #ifdef ENVMAP_TYPE_CUBE_UV
  4670. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  4671. vec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );
  4672. return PI * envMapColor.rgb * envMapIntensity;
  4673. #else
  4674. return vec3( 0.0 );
  4675. #endif
  4676. }
  4677. vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
  4678. #ifdef ENVMAP_TYPE_CUBE_UV
  4679. vec3 reflectVec = reflect( - viewDir, normal );
  4680. reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
  4681. reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
  4682. vec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );
  4683. return envMapColor.rgb * envMapIntensity;
  4684. #else
  4685. return vec3( 0.0 );
  4686. #endif
  4687. }
  4688. #ifdef USE_ANISOTROPY
  4689. vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
  4690. #ifdef ENVMAP_TYPE_CUBE_UV
  4691. vec3 bentNormal = cross( bitangent, viewDir );
  4692. bentNormal = normalize( cross( bentNormal, bitangent ) );
  4693. bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
  4694. return getIBLRadiance( viewDir, bentNormal, roughness );
  4695. #else
  4696. return vec3( 0.0 );
  4697. #endif
  4698. }
  4699. #endif
  4700. #endif`,k5e=`ToonMaterial material;
  4701. material.diffuseColor = diffuseColor.rgb;`,j5e=`varying vec3 vViewPosition;
  4702. struct ToonMaterial {
  4703. vec3 diffuseColor;
  4704. };
  4705. void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
  4706. vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
  4707. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4708. }
  4709. void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
  4710. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4711. }
  4712. #define RE_Direct RE_Direct_Toon
  4713. #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,P5e=`BlinnPhongMaterial material;
  4714. material.diffuseColor = diffuseColor.rgb;
  4715. material.specularColor = specular;
  4716. material.specularShininess = shininess;
  4717. material.specularStrength = specularStrength;`,R5e=`varying vec3 vViewPosition;
  4718. struct BlinnPhongMaterial {
  4719. vec3 diffuseColor;
  4720. vec3 specularColor;
  4721. float specularShininess;
  4722. float specularStrength;
  4723. };
  4724. void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
  4725. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  4726. vec3 irradiance = dotNL * directLight.color;
  4727. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4728. reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
  4729. }
  4730. void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
  4731. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4732. }
  4733. #define RE_Direct RE_Direct_BlinnPhong
  4734. #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,D5e=`PhysicalMaterial material;
  4735. material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
  4736. vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
  4737. float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
  4738. material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
  4739. material.roughness = min( material.roughness, 1.0 );
  4740. #ifdef IOR
  4741. material.ior = ior;
  4742. #ifdef USE_SPECULAR
  4743. float specularIntensityFactor = specularIntensity;
  4744. vec3 specularColorFactor = specularColor;
  4745. #ifdef USE_SPECULAR_COLORMAP
  4746. specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
  4747. #endif
  4748. #ifdef USE_SPECULAR_INTENSITYMAP
  4749. specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
  4750. #endif
  4751. material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
  4752. #else
  4753. float specularIntensityFactor = 1.0;
  4754. vec3 specularColorFactor = vec3( 1.0 );
  4755. material.specularF90 = 1.0;
  4756. #endif
  4757. material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
  4758. #else
  4759. material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
  4760. material.specularF90 = 1.0;
  4761. #endif
  4762. #ifdef USE_CLEARCOAT
  4763. material.clearcoat = clearcoat;
  4764. material.clearcoatRoughness = clearcoatRoughness;
  4765. material.clearcoatF0 = vec3( 0.04 );
  4766. material.clearcoatF90 = 1.0;
  4767. #ifdef USE_CLEARCOATMAP
  4768. material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
  4769. #endif
  4770. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  4771. material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
  4772. #endif
  4773. material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
  4774. material.clearcoatRoughness += geometryRoughness;
  4775. material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
  4776. #endif
  4777. #ifdef USE_IRIDESCENCE
  4778. material.iridescence = iridescence;
  4779. material.iridescenceIOR = iridescenceIOR;
  4780. #ifdef USE_IRIDESCENCEMAP
  4781. material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
  4782. #endif
  4783. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  4784. material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
  4785. #else
  4786. material.iridescenceThickness = iridescenceThicknessMaximum;
  4787. #endif
  4788. #endif
  4789. #ifdef USE_SHEEN
  4790. material.sheenColor = sheenColor;
  4791. #ifdef USE_SHEEN_COLORMAP
  4792. material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
  4793. #endif
  4794. material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
  4795. #ifdef USE_SHEEN_ROUGHNESSMAP
  4796. material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
  4797. #endif
  4798. #endif
  4799. #ifdef USE_ANISOTROPY
  4800. #ifdef USE_ANISOTROPYMAP
  4801. mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
  4802. vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
  4803. vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
  4804. #else
  4805. vec2 anisotropyV = anisotropyVector;
  4806. #endif
  4807. material.anisotropy = length( anisotropyV );
  4808. if( material.anisotropy == 0.0 ) {
  4809. anisotropyV = vec2( 1.0, 0.0 );
  4810. } else {
  4811. anisotropyV /= material.anisotropy;
  4812. material.anisotropy = saturate( material.anisotropy );
  4813. }
  4814. material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
  4815. material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
  4816. material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
  4817. #endif`,O5e=`struct PhysicalMaterial {
  4818. vec3 diffuseColor;
  4819. float roughness;
  4820. vec3 specularColor;
  4821. float specularF90;
  4822. #ifdef USE_CLEARCOAT
  4823. float clearcoat;
  4824. float clearcoatRoughness;
  4825. vec3 clearcoatF0;
  4826. float clearcoatF90;
  4827. #endif
  4828. #ifdef USE_IRIDESCENCE
  4829. float iridescence;
  4830. float iridescenceIOR;
  4831. float iridescenceThickness;
  4832. vec3 iridescenceFresnel;
  4833. vec3 iridescenceF0;
  4834. #endif
  4835. #ifdef USE_SHEEN
  4836. vec3 sheenColor;
  4837. float sheenRoughness;
  4838. #endif
  4839. #ifdef IOR
  4840. float ior;
  4841. #endif
  4842. #ifdef USE_TRANSMISSION
  4843. float transmission;
  4844. float transmissionAlpha;
  4845. float thickness;
  4846. float attenuationDistance;
  4847. vec3 attenuationColor;
  4848. #endif
  4849. #ifdef USE_ANISOTROPY
  4850. float anisotropy;
  4851. float alphaT;
  4852. vec3 anisotropyT;
  4853. vec3 anisotropyB;
  4854. #endif
  4855. };
  4856. vec3 clearcoatSpecularDirect = vec3( 0.0 );
  4857. vec3 clearcoatSpecularIndirect = vec3( 0.0 );
  4858. vec3 sheenSpecularDirect = vec3( 0.0 );
  4859. vec3 sheenSpecularIndirect = vec3(0.0 );
  4860. vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
  4861. float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
  4862. float x2 = x * x;
  4863. float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
  4864. return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
  4865. }
  4866. float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
  4867. float a2 = pow2( alpha );
  4868. float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
  4869. float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
  4870. return 0.5 / max( gv + gl, EPSILON );
  4871. }
  4872. float D_GGX( const in float alpha, const in float dotNH ) {
  4873. float a2 = pow2( alpha );
  4874. float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
  4875. return RECIPROCAL_PI * a2 / pow2( denom );
  4876. }
  4877. #ifdef USE_ANISOTROPY
  4878. float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {
  4879. float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
  4880. float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
  4881. float v = 0.5 / ( gv + gl );
  4882. return saturate(v);
  4883. }
  4884. float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
  4885. float a2 = alphaT * alphaB;
  4886. highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
  4887. highp float v2 = dot( v, v );
  4888. float w2 = a2 / v2;
  4889. return RECIPROCAL_PI * a2 * pow2 ( w2 );
  4890. }
  4891. #endif
  4892. #ifdef USE_CLEARCOAT
  4893. vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
  4894. vec3 f0 = material.clearcoatF0;
  4895. float f90 = material.clearcoatF90;
  4896. float roughness = material.clearcoatRoughness;
  4897. float alpha = pow2( roughness );
  4898. vec3 halfDir = normalize( lightDir + viewDir );
  4899. float dotNL = saturate( dot( normal, lightDir ) );
  4900. float dotNV = saturate( dot( normal, viewDir ) );
  4901. float dotNH = saturate( dot( normal, halfDir ) );
  4902. float dotVH = saturate( dot( viewDir, halfDir ) );
  4903. vec3 F = F_Schlick( f0, f90, dotVH );
  4904. float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
  4905. float D = D_GGX( alpha, dotNH );
  4906. return F * ( V * D );
  4907. }
  4908. #endif
  4909. vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
  4910. vec3 f0 = material.specularColor;
  4911. float f90 = material.specularF90;
  4912. float roughness = material.roughness;
  4913. float alpha = pow2( roughness );
  4914. vec3 halfDir = normalize( lightDir + viewDir );
  4915. float dotNL = saturate( dot( normal, lightDir ) );
  4916. float dotNV = saturate( dot( normal, viewDir ) );
  4917. float dotNH = saturate( dot( normal, halfDir ) );
  4918. float dotVH = saturate( dot( viewDir, halfDir ) );
  4919. vec3 F = F_Schlick( f0, f90, dotVH );
  4920. #ifdef USE_IRIDESCENCE
  4921. F = mix( F, material.iridescenceFresnel, material.iridescence );
  4922. #endif
  4923. #ifdef USE_ANISOTROPY
  4924. float dotTL = dot( material.anisotropyT, lightDir );
  4925. float dotTV = dot( material.anisotropyT, viewDir );
  4926. float dotTH = dot( material.anisotropyT, halfDir );
  4927. float dotBL = dot( material.anisotropyB, lightDir );
  4928. float dotBV = dot( material.anisotropyB, viewDir );
  4929. float dotBH = dot( material.anisotropyB, halfDir );
  4930. float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
  4931. float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
  4932. #else
  4933. float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
  4934. float D = D_GGX( alpha, dotNH );
  4935. #endif
  4936. return F * ( V * D );
  4937. }
  4938. vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
  4939. const float LUT_SIZE = 64.0;
  4940. const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
  4941. const float LUT_BIAS = 0.5 / LUT_SIZE;
  4942. float dotNV = saturate( dot( N, V ) );
  4943. vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
  4944. uv = uv * LUT_SCALE + LUT_BIAS;
  4945. return uv;
  4946. }
  4947. float LTC_ClippedSphereFormFactor( const in vec3 f ) {
  4948. float l = length( f );
  4949. return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
  4950. }
  4951. vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
  4952. float x = dot( v1, v2 );
  4953. float y = abs( x );
  4954. float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
  4955. float b = 3.4175940 + ( 4.1616724 + y ) * y;
  4956. float v = a / b;
  4957. float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
  4958. return cross( v1, v2 ) * theta_sintheta;
  4959. }
  4960. vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
  4961. vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
  4962. vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
  4963. vec3 lightNormal = cross( v1, v2 );
  4964. if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
  4965. vec3 T1, T2;
  4966. T1 = normalize( V - N * dot( V, N ) );
  4967. T2 = - cross( N, T1 );
  4968. mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );
  4969. vec3 coords[ 4 ];
  4970. coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
  4971. coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
  4972. coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
  4973. coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
  4974. coords[ 0 ] = normalize( coords[ 0 ] );
  4975. coords[ 1 ] = normalize( coords[ 1 ] );
  4976. coords[ 2 ] = normalize( coords[ 2 ] );
  4977. coords[ 3 ] = normalize( coords[ 3 ] );
  4978. vec3 vectorFormFactor = vec3( 0.0 );
  4979. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
  4980. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
  4981. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
  4982. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
  4983. float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
  4984. return vec3( result );
  4985. }
  4986. #if defined( USE_SHEEN )
  4987. float D_Charlie( float roughness, float dotNH ) {
  4988. float alpha = pow2( roughness );
  4989. float invAlpha = 1.0 / alpha;
  4990. float cos2h = dotNH * dotNH;
  4991. float sin2h = max( 1.0 - cos2h, 0.0078125 );
  4992. return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
  4993. }
  4994. float V_Neubelt( float dotNV, float dotNL ) {
  4995. return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
  4996. }
  4997. vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
  4998. vec3 halfDir = normalize( lightDir + viewDir );
  4999. float dotNL = saturate( dot( normal, lightDir ) );
  5000. float dotNV = saturate( dot( normal, viewDir ) );
  5001. float dotNH = saturate( dot( normal, halfDir ) );
  5002. float D = D_Charlie( sheenRoughness, dotNH );
  5003. float V = V_Neubelt( dotNV, dotNL );
  5004. return sheenColor * ( D * V );
  5005. }
  5006. #endif
  5007. float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
  5008. float dotNV = saturate( dot( normal, viewDir ) );
  5009. float r2 = roughness * roughness;
  5010. float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
  5011. float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
  5012. float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
  5013. return saturate( DG * RECIPROCAL_PI );
  5014. }
  5015. vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
  5016. float dotNV = saturate( dot( normal, viewDir ) );
  5017. const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
  5018. const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
  5019. vec4 r = roughness * c0 + c1;
  5020. float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
  5021. vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;
  5022. return fab;
  5023. }
  5024. vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
  5025. vec2 fab = DFGApprox( normal, viewDir, roughness );
  5026. return specularColor * fab.x + specularF90 * fab.y;
  5027. }
  5028. #ifdef USE_IRIDESCENCE
  5029. void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
  5030. #else
  5031. void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
  5032. #endif
  5033. vec2 fab = DFGApprox( normal, viewDir, roughness );
  5034. #ifdef USE_IRIDESCENCE
  5035. vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
  5036. #else
  5037. vec3 Fr = specularColor;
  5038. #endif
  5039. vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
  5040. float Ess = fab.x + fab.y;
  5041. float Ems = 1.0 - Ess;
  5042. vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
  5043. singleScatter += FssEss;
  5044. multiScatter += Fms * Ems;
  5045. }
  5046. #if NUM_RECT_AREA_LIGHTS > 0
  5047. void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
  5048. vec3 normal = geometryNormal;
  5049. vec3 viewDir = geometryViewDir;
  5050. vec3 position = geometryPosition;
  5051. vec3 lightPos = rectAreaLight.position;
  5052. vec3 halfWidth = rectAreaLight.halfWidth;
  5053. vec3 halfHeight = rectAreaLight.halfHeight;
  5054. vec3 lightColor = rectAreaLight.color;
  5055. float roughness = material.roughness;
  5056. vec3 rectCoords[ 4 ];
  5057. rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
  5058. rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
  5059. rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
  5060. vec2 uv = LTC_Uv( normal, viewDir, roughness );
  5061. vec4 t1 = texture2D( ltc_1, uv );
  5062. vec4 t2 = texture2D( ltc_2, uv );
  5063. mat3 mInv = mat3(
  5064. vec3( t1.x, 0, t1.y ),
  5065. vec3( 0, 1, 0 ),
  5066. vec3( t1.z, 0, t1.w )
  5067. );
  5068. vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
  5069. reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
  5070. reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
  5071. }
  5072. #endif
  5073. void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
  5074. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  5075. vec3 irradiance = dotNL * directLight.color;
  5076. #ifdef USE_CLEARCOAT
  5077. float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
  5078. vec3 ccIrradiance = dotNLcc * directLight.color;
  5079. clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
  5080. #endif
  5081. #ifdef USE_SHEEN
  5082. sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
  5083. #endif
  5084. reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );
  5085. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  5086. }
  5087. void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
  5088. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  5089. }
  5090. void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
  5091. #ifdef USE_CLEARCOAT
  5092. clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
  5093. #endif
  5094. #ifdef USE_SHEEN
  5095. sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
  5096. #endif
  5097. vec3 singleScattering = vec3( 0.0 );
  5098. vec3 multiScattering = vec3( 0.0 );
  5099. vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
  5100. #ifdef USE_IRIDESCENCE
  5101. computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
  5102. #else
  5103. computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
  5104. #endif
  5105. vec3 totalScattering = singleScattering + multiScattering;
  5106. vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
  5107. reflectedLight.indirectSpecular += radiance * singleScattering;
  5108. reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
  5109. reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
  5110. }
  5111. #define RE_Direct RE_Direct_Physical
  5112. #define RE_Direct_RectArea RE_Direct_RectArea_Physical
  5113. #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
  5114. #define RE_IndirectSpecular RE_IndirectSpecular_Physical
  5115. float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
  5116. return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
  5117. }`,L5e=`
  5118. vec3 geometryPosition = - vViewPosition;
  5119. vec3 geometryNormal = normal;
  5120. vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
  5121. vec3 geometryClearcoatNormal = vec3( 0.0 );
  5122. #ifdef USE_CLEARCOAT
  5123. geometryClearcoatNormal = clearcoatNormal;
  5124. #endif
  5125. #ifdef USE_IRIDESCENCE
  5126. float dotNVi = saturate( dot( normal, geometryViewDir ) );
  5127. if ( material.iridescenceThickness == 0.0 ) {
  5128. material.iridescence = 0.0;
  5129. } else {
  5130. material.iridescence = saturate( material.iridescence );
  5131. }
  5132. if ( material.iridescence > 0.0 ) {
  5133. material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
  5134. material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
  5135. }
  5136. #endif
  5137. IncidentLight directLight;
  5138. #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
  5139. PointLight pointLight;
  5140. #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
  5141. PointLightShadow pointLightShadow;
  5142. #endif
  5143. #pragma unroll_loop_start
  5144. for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
  5145. pointLight = pointLights[ i ];
  5146. getPointLightInfo( pointLight, geometryPosition, directLight );
  5147. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
  5148. pointLightShadow = pointLightShadows[ i ];
  5149. directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
  5150. #endif
  5151. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5152. }
  5153. #pragma unroll_loop_end
  5154. #endif
  5155. #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
  5156. SpotLight spotLight;
  5157. vec4 spotColor;
  5158. vec3 spotLightCoord;
  5159. bool inSpotLightMap;
  5160. #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
  5161. SpotLightShadow spotLightShadow;
  5162. #endif
  5163. #pragma unroll_loop_start
  5164. for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
  5165. spotLight = spotLights[ i ];
  5166. getSpotLightInfo( spotLight, geometryPosition, directLight );
  5167. #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
  5168. #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
  5169. #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  5170. #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
  5171. #else
  5172. #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
  5173. #endif
  5174. #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
  5175. spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
  5176. inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
  5177. spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
  5178. directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
  5179. #endif
  5180. #undef SPOT_LIGHT_MAP_INDEX
  5181. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  5182. spotLightShadow = spotLightShadows[ i ];
  5183. directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
  5184. #endif
  5185. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5186. }
  5187. #pragma unroll_loop_end
  5188. #endif
  5189. #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
  5190. DirectionalLight directionalLight;
  5191. #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
  5192. DirectionalLightShadow directionalLightShadow;
  5193. #endif
  5194. #pragma unroll_loop_start
  5195. for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
  5196. directionalLight = directionalLights[ i ];
  5197. getDirectionalLightInfo( directionalLight, directLight );
  5198. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
  5199. directionalLightShadow = directionalLightShadows[ i ];
  5200. directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
  5201. #endif
  5202. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5203. }
  5204. #pragma unroll_loop_end
  5205. #endif
  5206. #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
  5207. RectAreaLight rectAreaLight;
  5208. #pragma unroll_loop_start
  5209. for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
  5210. rectAreaLight = rectAreaLights[ i ];
  5211. RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5212. }
  5213. #pragma unroll_loop_end
  5214. #endif
  5215. #if defined( RE_IndirectDiffuse )
  5216. vec3 iblIrradiance = vec3( 0.0 );
  5217. vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
  5218. #if defined( USE_LIGHT_PROBES )
  5219. irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
  5220. #endif
  5221. #if ( NUM_HEMI_LIGHTS > 0 )
  5222. #pragma unroll_loop_start
  5223. for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
  5224. irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
  5225. }
  5226. #pragma unroll_loop_end
  5227. #endif
  5228. #endif
  5229. #if defined( RE_IndirectSpecular )
  5230. vec3 radiance = vec3( 0.0 );
  5231. vec3 clearcoatRadiance = vec3( 0.0 );
  5232. #endif`,I5e=`#if defined( RE_IndirectDiffuse )
  5233. #ifdef USE_LIGHTMAP
  5234. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  5235. vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
  5236. irradiance += lightMapIrradiance;
  5237. #endif
  5238. #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
  5239. iblIrradiance += getIBLIrradiance( geometryNormal );
  5240. #endif
  5241. #endif
  5242. #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
  5243. #ifdef USE_ANISOTROPY
  5244. radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
  5245. #else
  5246. radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
  5247. #endif
  5248. #ifdef USE_CLEARCOAT
  5249. clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
  5250. #endif
  5251. #endif`,F5e=`#if defined( RE_IndirectDiffuse )
  5252. RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5253. #endif
  5254. #if defined( RE_IndirectSpecular )
  5255. RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5256. #endif`,U5e=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
  5257. gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
  5258. #endif`,z5e=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
  5259. uniform float logDepthBufFC;
  5260. varying float vFragDepth;
  5261. varying float vIsPerspective;
  5262. #endif`,B5e=`#ifdef USE_LOGDEPTHBUF
  5263. #ifdef USE_LOGDEPTHBUF_EXT
  5264. varying float vFragDepth;
  5265. varying float vIsPerspective;
  5266. #else
  5267. uniform float logDepthBufFC;
  5268. #endif
  5269. #endif`,$5e=`#ifdef USE_LOGDEPTHBUF
  5270. #ifdef USE_LOGDEPTHBUF_EXT
  5271. vFragDepth = 1.0 + gl_Position.w;
  5272. vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
  5273. #else
  5274. if ( isPerspectiveMatrix( projectionMatrix ) ) {
  5275. gl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;
  5276. gl_Position.z *= gl_Position.w;
  5277. }
  5278. #endif
  5279. #endif`,H5e=`#ifdef USE_MAP
  5280. vec4 sampledDiffuseColor = texture2D( map, vMapUv );
  5281. #ifdef DECODE_VIDEO_TEXTURE
  5282. sampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w );
  5283. #endif
  5284. diffuseColor *= sampledDiffuseColor;
  5285. #endif`,V5e=`#ifdef USE_MAP
  5286. uniform sampler2D map;
  5287. #endif`,G5e=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
  5288. #if defined( USE_POINTS_UV )
  5289. vec2 uv = vUv;
  5290. #else
  5291. vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
  5292. #endif
  5293. #endif
  5294. #ifdef USE_MAP
  5295. diffuseColor *= texture2D( map, uv );
  5296. #endif
  5297. #ifdef USE_ALPHAMAP
  5298. diffuseColor.a *= texture2D( alphaMap, uv ).g;
  5299. #endif`,W5e=`#if defined( USE_POINTS_UV )
  5300. varying vec2 vUv;
  5301. #else
  5302. #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
  5303. uniform mat3 uvTransform;
  5304. #endif
  5305. #endif
  5306. #ifdef USE_MAP
  5307. uniform sampler2D map;
  5308. #endif
  5309. #ifdef USE_ALPHAMAP
  5310. uniform sampler2D alphaMap;
  5311. #endif`,q5e=`float metalnessFactor = metalness;
  5312. #ifdef USE_METALNESSMAP
  5313. vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
  5314. metalnessFactor *= texelMetalness.b;
  5315. #endif`,K5e=`#ifdef USE_METALNESSMAP
  5316. uniform sampler2D metalnessMap;
  5317. #endif`,X5e=`#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )
  5318. vColor *= morphTargetBaseInfluence;
  5319. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  5320. #if defined( USE_COLOR_ALPHA )
  5321. if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
  5322. #elif defined( USE_COLOR )
  5323. if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
  5324. #endif
  5325. }
  5326. #endif`,Y5e=`#ifdef USE_MORPHNORMALS
  5327. objectNormal *= morphTargetBaseInfluence;
  5328. #ifdef MORPHTARGETS_TEXTURE
  5329. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  5330. if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
  5331. }
  5332. #else
  5333. objectNormal += morphNormal0 * morphTargetInfluences[ 0 ];
  5334. objectNormal += morphNormal1 * morphTargetInfluences[ 1 ];
  5335. objectNormal += morphNormal2 * morphTargetInfluences[ 2 ];
  5336. objectNormal += morphNormal3 * morphTargetInfluences[ 3 ];
  5337. #endif
  5338. #endif`,Q5e=`#ifdef USE_MORPHTARGETS
  5339. uniform float morphTargetBaseInfluence;
  5340. #ifdef MORPHTARGETS_TEXTURE
  5341. uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
  5342. uniform sampler2DArray morphTargetsTexture;
  5343. uniform ivec2 morphTargetsTextureSize;
  5344. vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
  5345. int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
  5346. int y = texelIndex / morphTargetsTextureSize.x;
  5347. int x = texelIndex - y * morphTargetsTextureSize.x;
  5348. ivec3 morphUV = ivec3( x, y, morphTargetIndex );
  5349. return texelFetch( morphTargetsTexture, morphUV, 0 );
  5350. }
  5351. #else
  5352. #ifndef USE_MORPHNORMALS
  5353. uniform float morphTargetInfluences[ 8 ];
  5354. #else
  5355. uniform float morphTargetInfluences[ 4 ];
  5356. #endif
  5357. #endif
  5358. #endif`,Z5e=`#ifdef USE_MORPHTARGETS
  5359. transformed *= morphTargetBaseInfluence;
  5360. #ifdef MORPHTARGETS_TEXTURE
  5361. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  5362. if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
  5363. }
  5364. #else
  5365. transformed += morphTarget0 * morphTargetInfluences[ 0 ];
  5366. transformed += morphTarget1 * morphTargetInfluences[ 1 ];
  5367. transformed += morphTarget2 * morphTargetInfluences[ 2 ];
  5368. transformed += morphTarget3 * morphTargetInfluences[ 3 ];
  5369. #ifndef USE_MORPHNORMALS
  5370. transformed += morphTarget4 * morphTargetInfluences[ 4 ];
  5371. transformed += morphTarget5 * morphTargetInfluences[ 5 ];
  5372. transformed += morphTarget6 * morphTargetInfluences[ 6 ];
  5373. transformed += morphTarget7 * morphTargetInfluences[ 7 ];
  5374. #endif
  5375. #endif
  5376. #endif`,J5e=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
  5377. #ifdef FLAT_SHADED
  5378. vec3 fdx = dFdx( vViewPosition );
  5379. vec3 fdy = dFdy( vViewPosition );
  5380. vec3 normal = normalize( cross( fdx, fdy ) );
  5381. #else
  5382. vec3 normal = normalize( vNormal );
  5383. #ifdef DOUBLE_SIDED
  5384. normal *= faceDirection;
  5385. #endif
  5386. #endif
  5387. #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
  5388. #ifdef USE_TANGENT
  5389. mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
  5390. #else
  5391. mat3 tbn = getTangentFrame( - vViewPosition, normal,
  5392. #if defined( USE_NORMALMAP )
  5393. vNormalMapUv
  5394. #elif defined( USE_CLEARCOAT_NORMALMAP )
  5395. vClearcoatNormalMapUv
  5396. #else
  5397. vUv
  5398. #endif
  5399. );
  5400. #endif
  5401. #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
  5402. tbn[0] *= faceDirection;
  5403. tbn[1] *= faceDirection;
  5404. #endif
  5405. #endif
  5406. #ifdef USE_CLEARCOAT_NORMALMAP
  5407. #ifdef USE_TANGENT
  5408. mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
  5409. #else
  5410. mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
  5411. #endif
  5412. #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
  5413. tbn2[0] *= faceDirection;
  5414. tbn2[1] *= faceDirection;
  5415. #endif
  5416. #endif
  5417. vec3 nonPerturbedNormal = normal;`,eFe=`#ifdef USE_NORMALMAP_OBJECTSPACE
  5418. normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
  5419. #ifdef FLIP_SIDED
  5420. normal = - normal;
  5421. #endif
  5422. #ifdef DOUBLE_SIDED
  5423. normal = normal * faceDirection;
  5424. #endif
  5425. normal = normalize( normalMatrix * normal );
  5426. #elif defined( USE_NORMALMAP_TANGENTSPACE )
  5427. vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
  5428. mapN.xy *= normalScale;
  5429. normal = normalize( tbn * mapN );
  5430. #elif defined( USE_BUMPMAP )
  5431. normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
  5432. #endif`,tFe=`#ifndef FLAT_SHADED
  5433. varying vec3 vNormal;
  5434. #ifdef USE_TANGENT
  5435. varying vec3 vTangent;
  5436. varying vec3 vBitangent;
  5437. #endif
  5438. #endif`,nFe=`#ifndef FLAT_SHADED
  5439. varying vec3 vNormal;
  5440. #ifdef USE_TANGENT
  5441. varying vec3 vTangent;
  5442. varying vec3 vBitangent;
  5443. #endif
  5444. #endif`,rFe=`#ifndef FLAT_SHADED
  5445. vNormal = normalize( transformedNormal );
  5446. #ifdef USE_TANGENT
  5447. vTangent = normalize( transformedTangent );
  5448. vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
  5449. #endif
  5450. #endif`,iFe=`#ifdef USE_NORMALMAP
  5451. uniform sampler2D normalMap;
  5452. uniform vec2 normalScale;
  5453. #endif
  5454. #ifdef USE_NORMALMAP_OBJECTSPACE
  5455. uniform mat3 normalMatrix;
  5456. #endif
  5457. #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
  5458. mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
  5459. vec3 q0 = dFdx( eye_pos.xyz );
  5460. vec3 q1 = dFdy( eye_pos.xyz );
  5461. vec2 st0 = dFdx( uv.st );
  5462. vec2 st1 = dFdy( uv.st );
  5463. vec3 N = surf_norm;
  5464. vec3 q1perp = cross( q1, N );
  5465. vec3 q0perp = cross( N, q0 );
  5466. vec3 T = q1perp * st0.x + q0perp * st1.x;
  5467. vec3 B = q1perp * st0.y + q0perp * st1.y;
  5468. float det = max( dot( T, T ), dot( B, B ) );
  5469. float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
  5470. return mat3( T * scale, B * scale, N );
  5471. }
  5472. #endif`,aFe=`#ifdef USE_CLEARCOAT
  5473. vec3 clearcoatNormal = nonPerturbedNormal;
  5474. #endif`,sFe=`#ifdef USE_CLEARCOAT_NORMALMAP
  5475. vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
  5476. clearcoatMapN.xy *= clearcoatNormalScale;
  5477. clearcoatNormal = normalize( tbn2 * clearcoatMapN );
  5478. #endif`,oFe=`#ifdef USE_CLEARCOATMAP
  5479. uniform sampler2D clearcoatMap;
  5480. #endif
  5481. #ifdef USE_CLEARCOAT_NORMALMAP
  5482. uniform sampler2D clearcoatNormalMap;
  5483. uniform vec2 clearcoatNormalScale;
  5484. #endif
  5485. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  5486. uniform sampler2D clearcoatRoughnessMap;
  5487. #endif`,lFe=`#ifdef USE_IRIDESCENCEMAP
  5488. uniform sampler2D iridescenceMap;
  5489. #endif
  5490. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  5491. uniform sampler2D iridescenceThicknessMap;
  5492. #endif`,cFe=`#ifdef OPAQUE
  5493. diffuseColor.a = 1.0;
  5494. #endif
  5495. #ifdef USE_TRANSMISSION
  5496. diffuseColor.a *= material.transmissionAlpha;
  5497. #endif
  5498. gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,uFe=`vec3 packNormalToRGB( const in vec3 normal ) {
  5499. return normalize( normal ) * 0.5 + 0.5;
  5500. }
  5501. vec3 unpackRGBToNormal( const in vec3 rgb ) {
  5502. return 2.0 * rgb.xyz - 1.0;
  5503. }
  5504. const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;
  5505. const vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );
  5506. const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );
  5507. const float ShiftRight8 = 1. / 256.;
  5508. vec4 packDepthToRGBA( const in float v ) {
  5509. vec4 r = vec4( fract( v * PackFactors ), v );
  5510. r.yzw -= r.xyz * ShiftRight8; return r * PackUpscale;
  5511. }
  5512. float unpackRGBAToDepth( const in vec4 v ) {
  5513. return dot( v, UnpackFactors );
  5514. }
  5515. vec2 packDepthToRG( in highp float v ) {
  5516. return packDepthToRGBA( v ).yx;
  5517. }
  5518. float unpackRGToDepth( const in highp vec2 v ) {
  5519. return unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );
  5520. }
  5521. vec4 pack2HalfToRGBA( vec2 v ) {
  5522. vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
  5523. return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
  5524. }
  5525. vec2 unpackRGBATo2Half( vec4 v ) {
  5526. return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
  5527. }
  5528. float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
  5529. return ( viewZ + near ) / ( near - far );
  5530. }
  5531. float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
  5532. return depth * ( near - far ) - near;
  5533. }
  5534. float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
  5535. return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
  5536. }
  5537. float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
  5538. return ( near * far ) / ( ( far - near ) * depth - far );
  5539. }`,dFe=`#ifdef PREMULTIPLIED_ALPHA
  5540. gl_FragColor.rgb *= gl_FragColor.a;
  5541. #endif`,hFe=`vec4 mvPosition = vec4( transformed, 1.0 );
  5542. #ifdef USE_BATCHING
  5543. mvPosition = batchingMatrix * mvPosition;
  5544. #endif
  5545. #ifdef USE_INSTANCING
  5546. mvPosition = instanceMatrix * mvPosition;
  5547. #endif
  5548. mvPosition = modelViewMatrix * mvPosition;
  5549. gl_Position = projectionMatrix * mvPosition;`,fFe=`#ifdef DITHERING
  5550. gl_FragColor.rgb = dithering( gl_FragColor.rgb );
  5551. #endif`,mFe=`#ifdef DITHERING
  5552. vec3 dithering( vec3 color ) {
  5553. float grid_position = rand( gl_FragCoord.xy );
  5554. vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
  5555. dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
  5556. return color + dither_shift_RGB;
  5557. }
  5558. #endif`,pFe=`float roughnessFactor = roughness;
  5559. #ifdef USE_ROUGHNESSMAP
  5560. vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
  5561. roughnessFactor *= texelRoughness.g;
  5562. #endif`,gFe=`#ifdef USE_ROUGHNESSMAP
  5563. uniform sampler2D roughnessMap;
  5564. #endif`,xFe=`#if NUM_SPOT_LIGHT_COORDS > 0
  5565. varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
  5566. #endif
  5567. #if NUM_SPOT_LIGHT_MAPS > 0
  5568. uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
  5569. #endif
  5570. #ifdef USE_SHADOWMAP
  5571. #if NUM_DIR_LIGHT_SHADOWS > 0
  5572. uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
  5573. varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
  5574. struct DirectionalLightShadow {
  5575. float shadowBias;
  5576. float shadowNormalBias;
  5577. float shadowRadius;
  5578. vec2 shadowMapSize;
  5579. };
  5580. uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
  5581. #endif
  5582. #if NUM_SPOT_LIGHT_SHADOWS > 0
  5583. uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
  5584. struct SpotLightShadow {
  5585. float shadowBias;
  5586. float shadowNormalBias;
  5587. float shadowRadius;
  5588. vec2 shadowMapSize;
  5589. };
  5590. uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
  5591. #endif
  5592. #if NUM_POINT_LIGHT_SHADOWS > 0
  5593. uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
  5594. varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
  5595. struct PointLightShadow {
  5596. float shadowBias;
  5597. float shadowNormalBias;
  5598. float shadowRadius;
  5599. vec2 shadowMapSize;
  5600. float shadowCameraNear;
  5601. float shadowCameraFar;
  5602. };
  5603. uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
  5604. #endif
  5605. float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
  5606. return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );
  5607. }
  5608. vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
  5609. return unpackRGBATo2Half( texture2D( shadow, uv ) );
  5610. }
  5611. float VSMShadow (sampler2D shadow, vec2 uv, float compare ){
  5612. float occlusion = 1.0;
  5613. vec2 distribution = texture2DDistribution( shadow, uv );
  5614. float hard_shadow = step( compare , distribution.x );
  5615. if (hard_shadow != 1.0 ) {
  5616. float distance = compare - distribution.x ;
  5617. float variance = max( 0.00000, distribution.y * distribution.y );
  5618. float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );
  5619. }
  5620. return occlusion;
  5621. }
  5622. float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
  5623. float shadow = 1.0;
  5624. shadowCoord.xyz /= shadowCoord.w;
  5625. shadowCoord.z += shadowBias;
  5626. bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
  5627. bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
  5628. if ( frustumTest ) {
  5629. #if defined( SHADOWMAP_TYPE_PCF )
  5630. vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
  5631. float dx0 = - texelSize.x * shadowRadius;
  5632. float dy0 = - texelSize.y * shadowRadius;
  5633. float dx1 = + texelSize.x * shadowRadius;
  5634. float dy1 = + texelSize.y * shadowRadius;
  5635. float dx2 = dx0 / 2.0;
  5636. float dy2 = dy0 / 2.0;
  5637. float dx3 = dx1 / 2.0;
  5638. float dy3 = dy1 / 2.0;
  5639. shadow = (
  5640. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
  5641. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
  5642. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
  5643. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
  5644. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
  5645. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
  5646. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
  5647. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
  5648. texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
  5649. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
  5650. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
  5651. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
  5652. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
  5653. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
  5654. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
  5655. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
  5656. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
  5657. ) * ( 1.0 / 17.0 );
  5658. #elif defined( SHADOWMAP_TYPE_PCF_SOFT )
  5659. vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
  5660. float dx = texelSize.x;
  5661. float dy = texelSize.y;
  5662. vec2 uv = shadowCoord.xy;
  5663. vec2 f = fract( uv * shadowMapSize + 0.5 );
  5664. uv -= f * texelSize;
  5665. shadow = (
  5666. texture2DCompare( shadowMap, uv, shadowCoord.z ) +
  5667. texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
  5668. texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
  5669. texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
  5670. mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
  5671. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
  5672. f.x ) +
  5673. mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
  5674. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
  5675. f.x ) +
  5676. mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
  5677. texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
  5678. f.y ) +
  5679. mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
  5680. texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
  5681. f.y ) +
  5682. mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
  5683. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
  5684. f.x ),
  5685. mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
  5686. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
  5687. f.x ),
  5688. f.y )
  5689. ) * ( 1.0 / 9.0 );
  5690. #elif defined( SHADOWMAP_TYPE_VSM )
  5691. shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
  5692. #else
  5693. shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
  5694. #endif
  5695. }
  5696. return shadow;
  5697. }
  5698. vec2 cubeToUV( vec3 v, float texelSizeY ) {
  5699. vec3 absV = abs( v );
  5700. float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
  5701. absV *= scaleToCube;
  5702. v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
  5703. vec2 planar = v.xy;
  5704. float almostATexel = 1.5 * texelSizeY;
  5705. float almostOne = 1.0 - almostATexel;
  5706. if ( absV.z >= almostOne ) {
  5707. if ( v.z > 0.0 )
  5708. planar.x = 4.0 - v.x;
  5709. } else if ( absV.x >= almostOne ) {
  5710. float signX = sign( v.x );
  5711. planar.x = v.z * signX + 2.0 * signX;
  5712. } else if ( absV.y >= almostOne ) {
  5713. float signY = sign( v.y );
  5714. planar.x = v.x + 2.0 * signY + 2.0;
  5715. planar.y = v.z * signY - 2.0;
  5716. }
  5717. return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
  5718. }
  5719. float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
  5720. vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
  5721. vec3 lightToPosition = shadowCoord.xyz;
  5722. float dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
  5723. vec3 bd3D = normalize( lightToPosition );
  5724. #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
  5725. vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
  5726. return (
  5727. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
  5728. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
  5729. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
  5730. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
  5731. texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
  5732. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
  5733. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
  5734. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
  5735. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
  5736. ) * ( 1.0 / 9.0 );
  5737. #else
  5738. return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
  5739. #endif
  5740. }
  5741. #endif`,bFe=`#if NUM_SPOT_LIGHT_COORDS > 0
  5742. uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
  5743. varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
  5744. #endif
  5745. #ifdef USE_SHADOWMAP
  5746. #if NUM_DIR_LIGHT_SHADOWS > 0
  5747. uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
  5748. varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
  5749. struct DirectionalLightShadow {
  5750. float shadowBias;
  5751. float shadowNormalBias;
  5752. float shadowRadius;
  5753. vec2 shadowMapSize;
  5754. };
  5755. uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
  5756. #endif
  5757. #if NUM_SPOT_LIGHT_SHADOWS > 0
  5758. struct SpotLightShadow {
  5759. float shadowBias;
  5760. float shadowNormalBias;
  5761. float shadowRadius;
  5762. vec2 shadowMapSize;
  5763. };
  5764. uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
  5765. #endif
  5766. #if NUM_POINT_LIGHT_SHADOWS > 0
  5767. uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
  5768. varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
  5769. struct PointLightShadow {
  5770. float shadowBias;
  5771. float shadowNormalBias;
  5772. float shadowRadius;
  5773. vec2 shadowMapSize;
  5774. float shadowCameraNear;
  5775. float shadowCameraFar;
  5776. };
  5777. uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
  5778. #endif
  5779. #endif`,yFe=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
  5780. vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
  5781. vec4 shadowWorldPosition;
  5782. #endif
  5783. #if defined( USE_SHADOWMAP )
  5784. #if NUM_DIR_LIGHT_SHADOWS > 0
  5785. #pragma unroll_loop_start
  5786. for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
  5787. shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
  5788. vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
  5789. }
  5790. #pragma unroll_loop_end
  5791. #endif
  5792. #if NUM_POINT_LIGHT_SHADOWS > 0
  5793. #pragma unroll_loop_start
  5794. for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
  5795. shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
  5796. vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
  5797. }
  5798. #pragma unroll_loop_end
  5799. #endif
  5800. #endif
  5801. #if NUM_SPOT_LIGHT_COORDS > 0
  5802. #pragma unroll_loop_start
  5803. for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
  5804. shadowWorldPosition = worldPosition;
  5805. #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  5806. shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
  5807. #endif
  5808. vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
  5809. }
  5810. #pragma unroll_loop_end
  5811. #endif`,vFe=`float getShadowMask() {
  5812. float shadow = 1.0;
  5813. #ifdef USE_SHADOWMAP
  5814. #if NUM_DIR_LIGHT_SHADOWS > 0
  5815. DirectionalLightShadow directionalLight;
  5816. #pragma unroll_loop_start
  5817. for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
  5818. directionalLight = directionalLightShadows[ i ];
  5819. shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
  5820. }
  5821. #pragma unroll_loop_end
  5822. #endif
  5823. #if NUM_SPOT_LIGHT_SHADOWS > 0
  5824. SpotLightShadow spotLight;
  5825. #pragma unroll_loop_start
  5826. for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
  5827. spotLight = spotLightShadows[ i ];
  5828. shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
  5829. }
  5830. #pragma unroll_loop_end
  5831. #endif
  5832. #if NUM_POINT_LIGHT_SHADOWS > 0
  5833. PointLightShadow pointLight;
  5834. #pragma unroll_loop_start
  5835. for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
  5836. pointLight = pointLightShadows[ i ];
  5837. shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
  5838. }
  5839. #pragma unroll_loop_end
  5840. #endif
  5841. #endif
  5842. return shadow;
  5843. }`,_Fe=`#ifdef USE_SKINNING
  5844. mat4 boneMatX = getBoneMatrix( skinIndex.x );
  5845. mat4 boneMatY = getBoneMatrix( skinIndex.y );
  5846. mat4 boneMatZ = getBoneMatrix( skinIndex.z );
  5847. mat4 boneMatW = getBoneMatrix( skinIndex.w );
  5848. #endif`,wFe=`#ifdef USE_SKINNING
  5849. uniform mat4 bindMatrix;
  5850. uniform mat4 bindMatrixInverse;
  5851. uniform highp sampler2D boneTexture;
  5852. mat4 getBoneMatrix( const in float i ) {
  5853. int size = textureSize( boneTexture, 0 ).x;
  5854. int j = int( i ) * 4;
  5855. int x = j % size;
  5856. int y = j / size;
  5857. vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
  5858. vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
  5859. vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
  5860. vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
  5861. return mat4( v1, v2, v3, v4 );
  5862. }
  5863. #endif`,SFe=`#ifdef USE_SKINNING
  5864. vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
  5865. vec4 skinned = vec4( 0.0 );
  5866. skinned += boneMatX * skinVertex * skinWeight.x;
  5867. skinned += boneMatY * skinVertex * skinWeight.y;
  5868. skinned += boneMatZ * skinVertex * skinWeight.z;
  5869. skinned += boneMatW * skinVertex * skinWeight.w;
  5870. transformed = ( bindMatrixInverse * skinned ).xyz;
  5871. #endif`,NFe=`#ifdef USE_SKINNING
  5872. mat4 skinMatrix = mat4( 0.0 );
  5873. skinMatrix += skinWeight.x * boneMatX;
  5874. skinMatrix += skinWeight.y * boneMatY;
  5875. skinMatrix += skinWeight.z * boneMatZ;
  5876. skinMatrix += skinWeight.w * boneMatW;
  5877. skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
  5878. objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
  5879. #ifdef USE_TANGENT
  5880. objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
  5881. #endif
  5882. #endif`,MFe=`float specularStrength;
  5883. #ifdef USE_SPECULARMAP
  5884. vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
  5885. specularStrength = texelSpecular.r;
  5886. #else
  5887. specularStrength = 1.0;
  5888. #endif`,EFe=`#ifdef USE_SPECULARMAP
  5889. uniform sampler2D specularMap;
  5890. #endif`,TFe=`#if defined( TONE_MAPPING )
  5891. gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
  5892. #endif`,AFe=`#ifndef saturate
  5893. #define saturate( a ) clamp( a, 0.0, 1.0 )
  5894. #endif
  5895. uniform float toneMappingExposure;
  5896. vec3 LinearToneMapping( vec3 color ) {
  5897. return saturate( toneMappingExposure * color );
  5898. }
  5899. vec3 ReinhardToneMapping( vec3 color ) {
  5900. color *= toneMappingExposure;
  5901. return saturate( color / ( vec3( 1.0 ) + color ) );
  5902. }
  5903. vec3 OptimizedCineonToneMapping( vec3 color ) {
  5904. color *= toneMappingExposure;
  5905. color = max( vec3( 0.0 ), color - 0.004 );
  5906. return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
  5907. }
  5908. vec3 RRTAndODTFit( vec3 v ) {
  5909. vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
  5910. vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
  5911. return a / b;
  5912. }
  5913. vec3 ACESFilmicToneMapping( vec3 color ) {
  5914. const mat3 ACESInputMat = mat3(
  5915. vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
  5916. vec3( 0.04823, 0.01566, 0.83777 )
  5917. );
  5918. const mat3 ACESOutputMat = mat3(
  5919. vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
  5920. vec3( -0.07367, -0.00605, 1.07602 )
  5921. );
  5922. color *= toneMappingExposure / 0.6;
  5923. color = ACESInputMat * color;
  5924. color = RRTAndODTFit( color );
  5925. color = ACESOutputMat * color;
  5926. return saturate( color );
  5927. }
  5928. vec3 CustomToneMapping( vec3 color ) { return color; }`,CFe=`#ifdef USE_TRANSMISSION
  5929. material.transmission = transmission;
  5930. material.transmissionAlpha = 1.0;
  5931. material.thickness = thickness;
  5932. material.attenuationDistance = attenuationDistance;
  5933. material.attenuationColor = attenuationColor;
  5934. #ifdef USE_TRANSMISSIONMAP
  5935. material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
  5936. #endif
  5937. #ifdef USE_THICKNESSMAP
  5938. material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
  5939. #endif
  5940. vec3 pos = vWorldPosition;
  5941. vec3 v = normalize( cameraPosition - pos );
  5942. vec3 n = inverseTransformDirection( normal, viewMatrix );
  5943. vec4 transmitted = getIBLVolumeRefraction(
  5944. n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
  5945. pos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness,
  5946. material.attenuationColor, material.attenuationDistance );
  5947. material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
  5948. totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
  5949. #endif`,kFe=`#ifdef USE_TRANSMISSION
  5950. uniform float transmission;
  5951. uniform float thickness;
  5952. uniform float attenuationDistance;
  5953. uniform vec3 attenuationColor;
  5954. #ifdef USE_TRANSMISSIONMAP
  5955. uniform sampler2D transmissionMap;
  5956. #endif
  5957. #ifdef USE_THICKNESSMAP
  5958. uniform sampler2D thicknessMap;
  5959. #endif
  5960. uniform vec2 transmissionSamplerSize;
  5961. uniform sampler2D transmissionSamplerMap;
  5962. uniform mat4 modelMatrix;
  5963. uniform mat4 projectionMatrix;
  5964. varying vec3 vWorldPosition;
  5965. float w0( float a ) {
  5966. return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
  5967. }
  5968. float w1( float a ) {
  5969. return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
  5970. }
  5971. float w2( float a ){
  5972. return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
  5973. }
  5974. float w3( float a ) {
  5975. return ( 1.0 / 6.0 ) * ( a * a * a );
  5976. }
  5977. float g0( float a ) {
  5978. return w0( a ) + w1( a );
  5979. }
  5980. float g1( float a ) {
  5981. return w2( a ) + w3( a );
  5982. }
  5983. float h0( float a ) {
  5984. return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
  5985. }
  5986. float h1( float a ) {
  5987. return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
  5988. }
  5989. vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
  5990. uv = uv * texelSize.zw + 0.5;
  5991. vec2 iuv = floor( uv );
  5992. vec2 fuv = fract( uv );
  5993. float g0x = g0( fuv.x );
  5994. float g1x = g1( fuv.x );
  5995. float h0x = h0( fuv.x );
  5996. float h1x = h1( fuv.x );
  5997. float h0y = h0( fuv.y );
  5998. float h1y = h1( fuv.y );
  5999. vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
  6000. vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
  6001. vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
  6002. vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
  6003. return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
  6004. g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
  6005. }
  6006. vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
  6007. vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
  6008. vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
  6009. vec2 fLodSizeInv = 1.0 / fLodSize;
  6010. vec2 cLodSizeInv = 1.0 / cLodSize;
  6011. vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
  6012. vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
  6013. return mix( fSample, cSample, fract( lod ) );
  6014. }
  6015. vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
  6016. vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
  6017. vec3 modelScale;
  6018. modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
  6019. modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
  6020. modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
  6021. return normalize( refractionVector ) * thickness * modelScale;
  6022. }
  6023. float applyIorToRoughness( const in float roughness, const in float ior ) {
  6024. return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
  6025. }
  6026. vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
  6027. float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
  6028. return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
  6029. }
  6030. vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
  6031. if ( isinf( attenuationDistance ) ) {
  6032. return vec3( 1.0 );
  6033. } else {
  6034. vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
  6035. vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
  6036. }
  6037. }
  6038. vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
  6039. const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
  6040. const in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,
  6041. const in vec3 attenuationColor, const in float attenuationDistance ) {
  6042. vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
  6043. vec3 refractedRayExit = position + transmissionRay;
  6044. vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
  6045. vec2 refractionCoords = ndcPos.xy / ndcPos.w;
  6046. refractionCoords += 1.0;
  6047. refractionCoords /= 2.0;
  6048. vec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
  6049. vec3 transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
  6050. vec3 attenuatedColor = transmittance * transmittedLight.rgb;
  6051. vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
  6052. float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
  6053. return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
  6054. }
  6055. #endif`,jFe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  6056. varying vec2 vUv;
  6057. #endif
  6058. #ifdef USE_MAP
  6059. varying vec2 vMapUv;
  6060. #endif
  6061. #ifdef USE_ALPHAMAP
  6062. varying vec2 vAlphaMapUv;
  6063. #endif
  6064. #ifdef USE_LIGHTMAP
  6065. varying vec2 vLightMapUv;
  6066. #endif
  6067. #ifdef USE_AOMAP
  6068. varying vec2 vAoMapUv;
  6069. #endif
  6070. #ifdef USE_BUMPMAP
  6071. varying vec2 vBumpMapUv;
  6072. #endif
  6073. #ifdef USE_NORMALMAP
  6074. varying vec2 vNormalMapUv;
  6075. #endif
  6076. #ifdef USE_EMISSIVEMAP
  6077. varying vec2 vEmissiveMapUv;
  6078. #endif
  6079. #ifdef USE_METALNESSMAP
  6080. varying vec2 vMetalnessMapUv;
  6081. #endif
  6082. #ifdef USE_ROUGHNESSMAP
  6083. varying vec2 vRoughnessMapUv;
  6084. #endif
  6085. #ifdef USE_ANISOTROPYMAP
  6086. varying vec2 vAnisotropyMapUv;
  6087. #endif
  6088. #ifdef USE_CLEARCOATMAP
  6089. varying vec2 vClearcoatMapUv;
  6090. #endif
  6091. #ifdef USE_CLEARCOAT_NORMALMAP
  6092. varying vec2 vClearcoatNormalMapUv;
  6093. #endif
  6094. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  6095. varying vec2 vClearcoatRoughnessMapUv;
  6096. #endif
  6097. #ifdef USE_IRIDESCENCEMAP
  6098. varying vec2 vIridescenceMapUv;
  6099. #endif
  6100. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  6101. varying vec2 vIridescenceThicknessMapUv;
  6102. #endif
  6103. #ifdef USE_SHEEN_COLORMAP
  6104. varying vec2 vSheenColorMapUv;
  6105. #endif
  6106. #ifdef USE_SHEEN_ROUGHNESSMAP
  6107. varying vec2 vSheenRoughnessMapUv;
  6108. #endif
  6109. #ifdef USE_SPECULARMAP
  6110. varying vec2 vSpecularMapUv;
  6111. #endif
  6112. #ifdef USE_SPECULAR_COLORMAP
  6113. varying vec2 vSpecularColorMapUv;
  6114. #endif
  6115. #ifdef USE_SPECULAR_INTENSITYMAP
  6116. varying vec2 vSpecularIntensityMapUv;
  6117. #endif
  6118. #ifdef USE_TRANSMISSIONMAP
  6119. uniform mat3 transmissionMapTransform;
  6120. varying vec2 vTransmissionMapUv;
  6121. #endif
  6122. #ifdef USE_THICKNESSMAP
  6123. uniform mat3 thicknessMapTransform;
  6124. varying vec2 vThicknessMapUv;
  6125. #endif`,PFe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  6126. varying vec2 vUv;
  6127. #endif
  6128. #ifdef USE_MAP
  6129. uniform mat3 mapTransform;
  6130. varying vec2 vMapUv;
  6131. #endif
  6132. #ifdef USE_ALPHAMAP
  6133. uniform mat3 alphaMapTransform;
  6134. varying vec2 vAlphaMapUv;
  6135. #endif
  6136. #ifdef USE_LIGHTMAP
  6137. uniform mat3 lightMapTransform;
  6138. varying vec2 vLightMapUv;
  6139. #endif
  6140. #ifdef USE_AOMAP
  6141. uniform mat3 aoMapTransform;
  6142. varying vec2 vAoMapUv;
  6143. #endif
  6144. #ifdef USE_BUMPMAP
  6145. uniform mat3 bumpMapTransform;
  6146. varying vec2 vBumpMapUv;
  6147. #endif
  6148. #ifdef USE_NORMALMAP
  6149. uniform mat3 normalMapTransform;
  6150. varying vec2 vNormalMapUv;
  6151. #endif
  6152. #ifdef USE_DISPLACEMENTMAP
  6153. uniform mat3 displacementMapTransform;
  6154. varying vec2 vDisplacementMapUv;
  6155. #endif
  6156. #ifdef USE_EMISSIVEMAP
  6157. uniform mat3 emissiveMapTransform;
  6158. varying vec2 vEmissiveMapUv;
  6159. #endif
  6160. #ifdef USE_METALNESSMAP
  6161. uniform mat3 metalnessMapTransform;
  6162. varying vec2 vMetalnessMapUv;
  6163. #endif
  6164. #ifdef USE_ROUGHNESSMAP
  6165. uniform mat3 roughnessMapTransform;
  6166. varying vec2 vRoughnessMapUv;
  6167. #endif
  6168. #ifdef USE_ANISOTROPYMAP
  6169. uniform mat3 anisotropyMapTransform;
  6170. varying vec2 vAnisotropyMapUv;
  6171. #endif
  6172. #ifdef USE_CLEARCOATMAP
  6173. uniform mat3 clearcoatMapTransform;
  6174. varying vec2 vClearcoatMapUv;
  6175. #endif
  6176. #ifdef USE_CLEARCOAT_NORMALMAP
  6177. uniform mat3 clearcoatNormalMapTransform;
  6178. varying vec2 vClearcoatNormalMapUv;
  6179. #endif
  6180. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  6181. uniform mat3 clearcoatRoughnessMapTransform;
  6182. varying vec2 vClearcoatRoughnessMapUv;
  6183. #endif
  6184. #ifdef USE_SHEEN_COLORMAP
  6185. uniform mat3 sheenColorMapTransform;
  6186. varying vec2 vSheenColorMapUv;
  6187. #endif
  6188. #ifdef USE_SHEEN_ROUGHNESSMAP
  6189. uniform mat3 sheenRoughnessMapTransform;
  6190. varying vec2 vSheenRoughnessMapUv;
  6191. #endif
  6192. #ifdef USE_IRIDESCENCEMAP
  6193. uniform mat3 iridescenceMapTransform;
  6194. varying vec2 vIridescenceMapUv;
  6195. #endif
  6196. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  6197. uniform mat3 iridescenceThicknessMapTransform;
  6198. varying vec2 vIridescenceThicknessMapUv;
  6199. #endif
  6200. #ifdef USE_SPECULARMAP
  6201. uniform mat3 specularMapTransform;
  6202. varying vec2 vSpecularMapUv;
  6203. #endif
  6204. #ifdef USE_SPECULAR_COLORMAP
  6205. uniform mat3 specularColorMapTransform;
  6206. varying vec2 vSpecularColorMapUv;
  6207. #endif
  6208. #ifdef USE_SPECULAR_INTENSITYMAP
  6209. uniform mat3 specularIntensityMapTransform;
  6210. varying vec2 vSpecularIntensityMapUv;
  6211. #endif
  6212. #ifdef USE_TRANSMISSIONMAP
  6213. uniform mat3 transmissionMapTransform;
  6214. varying vec2 vTransmissionMapUv;
  6215. #endif
  6216. #ifdef USE_THICKNESSMAP
  6217. uniform mat3 thicknessMapTransform;
  6218. varying vec2 vThicknessMapUv;
  6219. #endif`,RFe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  6220. vUv = vec3( uv, 1 ).xy;
  6221. #endif
  6222. #ifdef USE_MAP
  6223. vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
  6224. #endif
  6225. #ifdef USE_ALPHAMAP
  6226. vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
  6227. #endif
  6228. #ifdef USE_LIGHTMAP
  6229. vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
  6230. #endif
  6231. #ifdef USE_AOMAP
  6232. vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
  6233. #endif
  6234. #ifdef USE_BUMPMAP
  6235. vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
  6236. #endif
  6237. #ifdef USE_NORMALMAP
  6238. vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
  6239. #endif
  6240. #ifdef USE_DISPLACEMENTMAP
  6241. vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
  6242. #endif
  6243. #ifdef USE_EMISSIVEMAP
  6244. vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
  6245. #endif
  6246. #ifdef USE_METALNESSMAP
  6247. vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
  6248. #endif
  6249. #ifdef USE_ROUGHNESSMAP
  6250. vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
  6251. #endif
  6252. #ifdef USE_ANISOTROPYMAP
  6253. vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
  6254. #endif
  6255. #ifdef USE_CLEARCOATMAP
  6256. vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
  6257. #endif
  6258. #ifdef USE_CLEARCOAT_NORMALMAP
  6259. vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
  6260. #endif
  6261. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  6262. vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
  6263. #endif
  6264. #ifdef USE_IRIDESCENCEMAP
  6265. vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
  6266. #endif
  6267. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  6268. vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
  6269. #endif
  6270. #ifdef USE_SHEEN_COLORMAP
  6271. vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
  6272. #endif
  6273. #ifdef USE_SHEEN_ROUGHNESSMAP
  6274. vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
  6275. #endif
  6276. #ifdef USE_SPECULARMAP
  6277. vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
  6278. #endif
  6279. #ifdef USE_SPECULAR_COLORMAP
  6280. vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
  6281. #endif
  6282. #ifdef USE_SPECULAR_INTENSITYMAP
  6283. vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
  6284. #endif
  6285. #ifdef USE_TRANSMISSIONMAP
  6286. vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
  6287. #endif
  6288. #ifdef USE_THICKNESSMAP
  6289. vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
  6290. #endif`,DFe=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
  6291. vec4 worldPosition = vec4( transformed, 1.0 );
  6292. #ifdef USE_BATCHING
  6293. worldPosition = batchingMatrix * worldPosition;
  6294. #endif
  6295. #ifdef USE_INSTANCING
  6296. worldPosition = instanceMatrix * worldPosition;
  6297. #endif
  6298. worldPosition = modelMatrix * worldPosition;
  6299. #endif`;const OFe=`varying vec2 vUv;
  6300. uniform mat3 uvTransform;
  6301. void main() {
  6302. vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
  6303. gl_Position = vec4( position.xy, 1.0, 1.0 );
  6304. }`,LFe=`uniform sampler2D t2D;
  6305. uniform float backgroundIntensity;
  6306. varying vec2 vUv;
  6307. void main() {
  6308. vec4 texColor = texture2D( t2D, vUv );
  6309. #ifdef DECODE_VIDEO_TEXTURE
  6310. texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );
  6311. #endif
  6312. texColor.rgb *= backgroundIntensity;
  6313. gl_FragColor = texColor;
  6314. #include <tonemapping_fragment>
  6315. #include <colorspace_fragment>
  6316. }`,IFe=`varying vec3 vWorldDirection;
  6317. #include <common>
  6318. void main() {
  6319. vWorldDirection = transformDirection( position, modelMatrix );
  6320. #include <begin_vertex>
  6321. #include <project_vertex>
  6322. gl_Position.z = gl_Position.w;
  6323. }`,FFe=`#ifdef ENVMAP_TYPE_CUBE
  6324. uniform samplerCube envMap;
  6325. #elif defined( ENVMAP_TYPE_CUBE_UV )
  6326. uniform sampler2D envMap;
  6327. #endif
  6328. uniform float flipEnvMap;
  6329. uniform float backgroundBlurriness;
  6330. uniform float backgroundIntensity;
  6331. varying vec3 vWorldDirection;
  6332. #include <cube_uv_reflection_fragment>
  6333. void main() {
  6334. #ifdef ENVMAP_TYPE_CUBE
  6335. vec4 texColor = textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
  6336. #elif defined( ENVMAP_TYPE_CUBE_UV )
  6337. vec4 texColor = textureCubeUV( envMap, vWorldDirection, backgroundBlurriness );
  6338. #else
  6339. vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
  6340. #endif
  6341. texColor.rgb *= backgroundIntensity;
  6342. gl_FragColor = texColor;
  6343. #include <tonemapping_fragment>
  6344. #include <colorspace_fragment>
  6345. }`,UFe=`varying vec3 vWorldDirection;
  6346. #include <common>
  6347. void main() {
  6348. vWorldDirection = transformDirection( position, modelMatrix );
  6349. #include <begin_vertex>
  6350. #include <project_vertex>
  6351. gl_Position.z = gl_Position.w;
  6352. }`,zFe=`uniform samplerCube tCube;
  6353. uniform float tFlip;
  6354. uniform float opacity;
  6355. varying vec3 vWorldDirection;
  6356. void main() {
  6357. vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
  6358. gl_FragColor = texColor;
  6359. gl_FragColor.a *= opacity;
  6360. #include <tonemapping_fragment>
  6361. #include <colorspace_fragment>
  6362. }`,BFe=`#include <common>
  6363. #include <batching_pars_vertex>
  6364. #include <uv_pars_vertex>
  6365. #include <displacementmap_pars_vertex>
  6366. #include <morphtarget_pars_vertex>
  6367. #include <skinning_pars_vertex>
  6368. #include <logdepthbuf_pars_vertex>
  6369. #include <clipping_planes_pars_vertex>
  6370. varying vec2 vHighPrecisionZW;
  6371. void main() {
  6372. #include <uv_vertex>
  6373. #include <batching_vertex>
  6374. #include <skinbase_vertex>
  6375. #ifdef USE_DISPLACEMENTMAP
  6376. #include <beginnormal_vertex>
  6377. #include <morphnormal_vertex>
  6378. #include <skinnormal_vertex>
  6379. #endif
  6380. #include <begin_vertex>
  6381. #include <morphtarget_vertex>
  6382. #include <skinning_vertex>
  6383. #include <displacementmap_vertex>
  6384. #include <project_vertex>
  6385. #include <logdepthbuf_vertex>
  6386. #include <clipping_planes_vertex>
  6387. vHighPrecisionZW = gl_Position.zw;
  6388. }`,$Fe=`#if DEPTH_PACKING == 3200
  6389. uniform float opacity;
  6390. #endif
  6391. #include <common>
  6392. #include <packing>
  6393. #include <uv_pars_fragment>
  6394. #include <map_pars_fragment>
  6395. #include <alphamap_pars_fragment>
  6396. #include <alphatest_pars_fragment>
  6397. #include <alphahash_pars_fragment>
  6398. #include <logdepthbuf_pars_fragment>
  6399. #include <clipping_planes_pars_fragment>
  6400. varying vec2 vHighPrecisionZW;
  6401. void main() {
  6402. #include <clipping_planes_fragment>
  6403. vec4 diffuseColor = vec4( 1.0 );
  6404. #if DEPTH_PACKING == 3200
  6405. diffuseColor.a = opacity;
  6406. #endif
  6407. #include <map_fragment>
  6408. #include <alphamap_fragment>
  6409. #include <alphatest_fragment>
  6410. #include <alphahash_fragment>
  6411. #include <logdepthbuf_fragment>
  6412. float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;
  6413. #if DEPTH_PACKING == 3200
  6414. gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
  6415. #elif DEPTH_PACKING == 3201
  6416. gl_FragColor = packDepthToRGBA( fragCoordZ );
  6417. #endif
  6418. }`,HFe=`#define DISTANCE
  6419. varying vec3 vWorldPosition;
  6420. #include <common>
  6421. #include <batching_pars_vertex>
  6422. #include <uv_pars_vertex>
  6423. #include <displacementmap_pars_vertex>
  6424. #include <morphtarget_pars_vertex>
  6425. #include <skinning_pars_vertex>
  6426. #include <clipping_planes_pars_vertex>
  6427. void main() {
  6428. #include <uv_vertex>
  6429. #include <batching_vertex>
  6430. #include <skinbase_vertex>
  6431. #ifdef USE_DISPLACEMENTMAP
  6432. #include <beginnormal_vertex>
  6433. #include <morphnormal_vertex>
  6434. #include <skinnormal_vertex>
  6435. #endif
  6436. #include <begin_vertex>
  6437. #include <morphtarget_vertex>
  6438. #include <skinning_vertex>
  6439. #include <displacementmap_vertex>
  6440. #include <project_vertex>
  6441. #include <worldpos_vertex>
  6442. #include <clipping_planes_vertex>
  6443. vWorldPosition = worldPosition.xyz;
  6444. }`,VFe=`#define DISTANCE
  6445. uniform vec3 referencePosition;
  6446. uniform float nearDistance;
  6447. uniform float farDistance;
  6448. varying vec3 vWorldPosition;
  6449. #include <common>
  6450. #include <packing>
  6451. #include <uv_pars_fragment>
  6452. #include <map_pars_fragment>
  6453. #include <alphamap_pars_fragment>
  6454. #include <alphatest_pars_fragment>
  6455. #include <alphahash_pars_fragment>
  6456. #include <clipping_planes_pars_fragment>
  6457. void main () {
  6458. #include <clipping_planes_fragment>
  6459. vec4 diffuseColor = vec4( 1.0 );
  6460. #include <map_fragment>
  6461. #include <alphamap_fragment>
  6462. #include <alphatest_fragment>
  6463. #include <alphahash_fragment>
  6464. float dist = length( vWorldPosition - referencePosition );
  6465. dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
  6466. dist = saturate( dist );
  6467. gl_FragColor = packDepthToRGBA( dist );
  6468. }`,GFe=`varying vec3 vWorldDirection;
  6469. #include <common>
  6470. void main() {
  6471. vWorldDirection = transformDirection( position, modelMatrix );
  6472. #include <begin_vertex>
  6473. #include <project_vertex>
  6474. }`,WFe=`uniform sampler2D tEquirect;
  6475. varying vec3 vWorldDirection;
  6476. #include <common>
  6477. void main() {
  6478. vec3 direction = normalize( vWorldDirection );
  6479. vec2 sampleUV = equirectUv( direction );
  6480. gl_FragColor = texture2D( tEquirect, sampleUV );
  6481. #include <tonemapping_fragment>
  6482. #include <colorspace_fragment>
  6483. }`,qFe=`uniform float scale;
  6484. attribute float lineDistance;
  6485. varying float vLineDistance;
  6486. #include <common>
  6487. #include <uv_pars_vertex>
  6488. #include <color_pars_vertex>
  6489. #include <fog_pars_vertex>
  6490. #include <morphtarget_pars_vertex>
  6491. #include <logdepthbuf_pars_vertex>
  6492. #include <clipping_planes_pars_vertex>
  6493. void main() {
  6494. vLineDistance = scale * lineDistance;
  6495. #include <uv_vertex>
  6496. #include <color_vertex>
  6497. #include <morphcolor_vertex>
  6498. #include <begin_vertex>
  6499. #include <morphtarget_vertex>
  6500. #include <project_vertex>
  6501. #include <logdepthbuf_vertex>
  6502. #include <clipping_planes_vertex>
  6503. #include <fog_vertex>
  6504. }`,KFe=`uniform vec3 diffuse;
  6505. uniform float opacity;
  6506. uniform float dashSize;
  6507. uniform float totalSize;
  6508. varying float vLineDistance;
  6509. #include <common>
  6510. #include <color_pars_fragment>
  6511. #include <uv_pars_fragment>
  6512. #include <map_pars_fragment>
  6513. #include <fog_pars_fragment>
  6514. #include <logdepthbuf_pars_fragment>
  6515. #include <clipping_planes_pars_fragment>
  6516. void main() {
  6517. #include <clipping_planes_fragment>
  6518. if ( mod( vLineDistance, totalSize ) > dashSize ) {
  6519. discard;
  6520. }
  6521. vec3 outgoingLight = vec3( 0.0 );
  6522. vec4 diffuseColor = vec4( diffuse, opacity );
  6523. #include <logdepthbuf_fragment>
  6524. #include <map_fragment>
  6525. #include <color_fragment>
  6526. outgoingLight = diffuseColor.rgb;
  6527. #include <opaque_fragment>
  6528. #include <tonemapping_fragment>
  6529. #include <colorspace_fragment>
  6530. #include <fog_fragment>
  6531. #include <premultiplied_alpha_fragment>
  6532. }`,XFe=`#include <common>
  6533. #include <batching_pars_vertex>
  6534. #include <uv_pars_vertex>
  6535. #include <envmap_pars_vertex>
  6536. #include <color_pars_vertex>
  6537. #include <fog_pars_vertex>
  6538. #include <morphtarget_pars_vertex>
  6539. #include <skinning_pars_vertex>
  6540. #include <logdepthbuf_pars_vertex>
  6541. #include <clipping_planes_pars_vertex>
  6542. void main() {
  6543. #include <uv_vertex>
  6544. #include <color_vertex>
  6545. #include <morphcolor_vertex>
  6546. #include <batching_vertex>
  6547. #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
  6548. #include <beginnormal_vertex>
  6549. #include <morphnormal_vertex>
  6550. #include <skinbase_vertex>
  6551. #include <skinnormal_vertex>
  6552. #include <defaultnormal_vertex>
  6553. #endif
  6554. #include <begin_vertex>
  6555. #include <morphtarget_vertex>
  6556. #include <skinning_vertex>
  6557. #include <project_vertex>
  6558. #include <logdepthbuf_vertex>
  6559. #include <clipping_planes_vertex>
  6560. #include <worldpos_vertex>
  6561. #include <envmap_vertex>
  6562. #include <fog_vertex>
  6563. }`,YFe=`uniform vec3 diffuse;
  6564. uniform float opacity;
  6565. #ifndef FLAT_SHADED
  6566. varying vec3 vNormal;
  6567. #endif
  6568. #include <common>
  6569. #include <dithering_pars_fragment>
  6570. #include <color_pars_fragment>
  6571. #include <uv_pars_fragment>
  6572. #include <map_pars_fragment>
  6573. #include <alphamap_pars_fragment>
  6574. #include <alphatest_pars_fragment>
  6575. #include <alphahash_pars_fragment>
  6576. #include <aomap_pars_fragment>
  6577. #include <lightmap_pars_fragment>
  6578. #include <envmap_common_pars_fragment>
  6579. #include <envmap_pars_fragment>
  6580. #include <fog_pars_fragment>
  6581. #include <specularmap_pars_fragment>
  6582. #include <logdepthbuf_pars_fragment>
  6583. #include <clipping_planes_pars_fragment>
  6584. void main() {
  6585. #include <clipping_planes_fragment>
  6586. vec4 diffuseColor = vec4( diffuse, opacity );
  6587. #include <logdepthbuf_fragment>
  6588. #include <map_fragment>
  6589. #include <color_fragment>
  6590. #include <alphamap_fragment>
  6591. #include <alphatest_fragment>
  6592. #include <alphahash_fragment>
  6593. #include <specularmap_fragment>
  6594. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  6595. #ifdef USE_LIGHTMAP
  6596. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  6597. reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
  6598. #else
  6599. reflectedLight.indirectDiffuse += vec3( 1.0 );
  6600. #endif
  6601. #include <aomap_fragment>
  6602. reflectedLight.indirectDiffuse *= diffuseColor.rgb;
  6603. vec3 outgoingLight = reflectedLight.indirectDiffuse;
  6604. #include <envmap_fragment>
  6605. #include <opaque_fragment>
  6606. #include <tonemapping_fragment>
  6607. #include <colorspace_fragment>
  6608. #include <fog_fragment>
  6609. #include <premultiplied_alpha_fragment>
  6610. #include <dithering_fragment>
  6611. }`,QFe=`#define LAMBERT
  6612. varying vec3 vViewPosition;
  6613. #include <common>
  6614. #include <batching_pars_vertex>
  6615. #include <uv_pars_vertex>
  6616. #include <displacementmap_pars_vertex>
  6617. #include <envmap_pars_vertex>
  6618. #include <color_pars_vertex>
  6619. #include <fog_pars_vertex>
  6620. #include <normal_pars_vertex>
  6621. #include <morphtarget_pars_vertex>
  6622. #include <skinning_pars_vertex>
  6623. #include <shadowmap_pars_vertex>
  6624. #include <logdepthbuf_pars_vertex>
  6625. #include <clipping_planes_pars_vertex>
  6626. void main() {
  6627. #include <uv_vertex>
  6628. #include <color_vertex>
  6629. #include <morphcolor_vertex>
  6630. #include <batching_vertex>
  6631. #include <beginnormal_vertex>
  6632. #include <morphnormal_vertex>
  6633. #include <skinbase_vertex>
  6634. #include <skinnormal_vertex>
  6635. #include <defaultnormal_vertex>
  6636. #include <normal_vertex>
  6637. #include <begin_vertex>
  6638. #include <morphtarget_vertex>
  6639. #include <skinning_vertex>
  6640. #include <displacementmap_vertex>
  6641. #include <project_vertex>
  6642. #include <logdepthbuf_vertex>
  6643. #include <clipping_planes_vertex>
  6644. vViewPosition = - mvPosition.xyz;
  6645. #include <worldpos_vertex>
  6646. #include <envmap_vertex>
  6647. #include <shadowmap_vertex>
  6648. #include <fog_vertex>
  6649. }`,ZFe=`#define LAMBERT
  6650. uniform vec3 diffuse;
  6651. uniform vec3 emissive;
  6652. uniform float opacity;
  6653. #include <common>
  6654. #include <packing>
  6655. #include <dithering_pars_fragment>
  6656. #include <color_pars_fragment>
  6657. #include <uv_pars_fragment>
  6658. #include <map_pars_fragment>
  6659. #include <alphamap_pars_fragment>
  6660. #include <alphatest_pars_fragment>
  6661. #include <alphahash_pars_fragment>
  6662. #include <aomap_pars_fragment>
  6663. #include <lightmap_pars_fragment>
  6664. #include <emissivemap_pars_fragment>
  6665. #include <envmap_common_pars_fragment>
  6666. #include <envmap_pars_fragment>
  6667. #include <fog_pars_fragment>
  6668. #include <bsdfs>
  6669. #include <lights_pars_begin>
  6670. #include <normal_pars_fragment>
  6671. #include <lights_lambert_pars_fragment>
  6672. #include <shadowmap_pars_fragment>
  6673. #include <bumpmap_pars_fragment>
  6674. #include <normalmap_pars_fragment>
  6675. #include <specularmap_pars_fragment>
  6676. #include <logdepthbuf_pars_fragment>
  6677. #include <clipping_planes_pars_fragment>
  6678. void main() {
  6679. #include <clipping_planes_fragment>
  6680. vec4 diffuseColor = vec4( diffuse, opacity );
  6681. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  6682. vec3 totalEmissiveRadiance = emissive;
  6683. #include <logdepthbuf_fragment>
  6684. #include <map_fragment>
  6685. #include <color_fragment>
  6686. #include <alphamap_fragment>
  6687. #include <alphatest_fragment>
  6688. #include <alphahash_fragment>
  6689. #include <specularmap_fragment>
  6690. #include <normal_fragment_begin>
  6691. #include <normal_fragment_maps>
  6692. #include <emissivemap_fragment>
  6693. #include <lights_lambert_fragment>
  6694. #include <lights_fragment_begin>
  6695. #include <lights_fragment_maps>
  6696. #include <lights_fragment_end>
  6697. #include <aomap_fragment>
  6698. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
  6699. #include <envmap_fragment>
  6700. #include <opaque_fragment>
  6701. #include <tonemapping_fragment>
  6702. #include <colorspace_fragment>
  6703. #include <fog_fragment>
  6704. #include <premultiplied_alpha_fragment>
  6705. #include <dithering_fragment>
  6706. }`,JFe=`#define MATCAP
  6707. varying vec3 vViewPosition;
  6708. #include <common>
  6709. #include <batching_pars_vertex>
  6710. #include <uv_pars_vertex>
  6711. #include <color_pars_vertex>
  6712. #include <displacementmap_pars_vertex>
  6713. #include <fog_pars_vertex>
  6714. #include <normal_pars_vertex>
  6715. #include <morphtarget_pars_vertex>
  6716. #include <skinning_pars_vertex>
  6717. #include <logdepthbuf_pars_vertex>
  6718. #include <clipping_planes_pars_vertex>
  6719. void main() {
  6720. #include <uv_vertex>
  6721. #include <color_vertex>
  6722. #include <morphcolor_vertex>
  6723. #include <batching_vertex>
  6724. #include <beginnormal_vertex>
  6725. #include <morphnormal_vertex>
  6726. #include <skinbase_vertex>
  6727. #include <skinnormal_vertex>
  6728. #include <defaultnormal_vertex>
  6729. #include <normal_vertex>
  6730. #include <begin_vertex>
  6731. #include <morphtarget_vertex>
  6732. #include <skinning_vertex>
  6733. #include <displacementmap_vertex>
  6734. #include <project_vertex>
  6735. #include <logdepthbuf_vertex>
  6736. #include <clipping_planes_vertex>
  6737. #include <fog_vertex>
  6738. vViewPosition = - mvPosition.xyz;
  6739. }`,eUe=`#define MATCAP
  6740. uniform vec3 diffuse;
  6741. uniform float opacity;
  6742. uniform sampler2D matcap;
  6743. varying vec3 vViewPosition;
  6744. #include <common>
  6745. #include <dithering_pars_fragment>
  6746. #include <color_pars_fragment>
  6747. #include <uv_pars_fragment>
  6748. #include <map_pars_fragment>
  6749. #include <alphamap_pars_fragment>
  6750. #include <alphatest_pars_fragment>
  6751. #include <alphahash_pars_fragment>
  6752. #include <fog_pars_fragment>
  6753. #include <normal_pars_fragment>
  6754. #include <bumpmap_pars_fragment>
  6755. #include <normalmap_pars_fragment>
  6756. #include <logdepthbuf_pars_fragment>
  6757. #include <clipping_planes_pars_fragment>
  6758. void main() {
  6759. #include <clipping_planes_fragment>
  6760. vec4 diffuseColor = vec4( diffuse, opacity );
  6761. #include <logdepthbuf_fragment>
  6762. #include <map_fragment>
  6763. #include <color_fragment>
  6764. #include <alphamap_fragment>
  6765. #include <alphatest_fragment>
  6766. #include <alphahash_fragment>
  6767. #include <normal_fragment_begin>
  6768. #include <normal_fragment_maps>
  6769. vec3 viewDir = normalize( vViewPosition );
  6770. vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
  6771. vec3 y = cross( viewDir, x );
  6772. vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
  6773. #ifdef USE_MATCAP
  6774. vec4 matcapColor = texture2D( matcap, uv );
  6775. #else
  6776. vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
  6777. #endif
  6778. vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
  6779. #include <opaque_fragment>
  6780. #include <tonemapping_fragment>
  6781. #include <colorspace_fragment>
  6782. #include <fog_fragment>
  6783. #include <premultiplied_alpha_fragment>
  6784. #include <dithering_fragment>
  6785. }`,tUe=`#define NORMAL
  6786. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  6787. varying vec3 vViewPosition;
  6788. #endif
  6789. #include <common>
  6790. #include <batching_pars_vertex>
  6791. #include <uv_pars_vertex>
  6792. #include <displacementmap_pars_vertex>
  6793. #include <normal_pars_vertex>
  6794. #include <morphtarget_pars_vertex>
  6795. #include <skinning_pars_vertex>
  6796. #include <logdepthbuf_pars_vertex>
  6797. #include <clipping_planes_pars_vertex>
  6798. void main() {
  6799. #include <uv_vertex>
  6800. #include <batching_vertex>
  6801. #include <beginnormal_vertex>
  6802. #include <morphnormal_vertex>
  6803. #include <skinbase_vertex>
  6804. #include <skinnormal_vertex>
  6805. #include <defaultnormal_vertex>
  6806. #include <normal_vertex>
  6807. #include <begin_vertex>
  6808. #include <morphtarget_vertex>
  6809. #include <skinning_vertex>
  6810. #include <displacementmap_vertex>
  6811. #include <project_vertex>
  6812. #include <logdepthbuf_vertex>
  6813. #include <clipping_planes_vertex>
  6814. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  6815. vViewPosition = - mvPosition.xyz;
  6816. #endif
  6817. }`,nUe=`#define NORMAL
  6818. uniform float opacity;
  6819. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  6820. varying vec3 vViewPosition;
  6821. #endif
  6822. #include <packing>
  6823. #include <uv_pars_fragment>
  6824. #include <normal_pars_fragment>
  6825. #include <bumpmap_pars_fragment>
  6826. #include <normalmap_pars_fragment>
  6827. #include <logdepthbuf_pars_fragment>
  6828. #include <clipping_planes_pars_fragment>
  6829. void main() {
  6830. #include <clipping_planes_fragment>
  6831. #include <logdepthbuf_fragment>
  6832. #include <normal_fragment_begin>
  6833. #include <normal_fragment_maps>
  6834. gl_FragColor = vec4( packNormalToRGB( normal ), opacity );
  6835. #ifdef OPAQUE
  6836. gl_FragColor.a = 1.0;
  6837. #endif
  6838. }`,rUe=`#define PHONG
  6839. varying vec3 vViewPosition;
  6840. #include <common>
  6841. #include <batching_pars_vertex>
  6842. #include <uv_pars_vertex>
  6843. #include <displacementmap_pars_vertex>
  6844. #include <envmap_pars_vertex>
  6845. #include <color_pars_vertex>
  6846. #include <fog_pars_vertex>
  6847. #include <normal_pars_vertex>
  6848. #include <morphtarget_pars_vertex>
  6849. #include <skinning_pars_vertex>
  6850. #include <shadowmap_pars_vertex>
  6851. #include <logdepthbuf_pars_vertex>
  6852. #include <clipping_planes_pars_vertex>
  6853. void main() {
  6854. #include <uv_vertex>
  6855. #include <color_vertex>
  6856. #include <morphcolor_vertex>
  6857. #include <batching_vertex>
  6858. #include <beginnormal_vertex>
  6859. #include <morphnormal_vertex>
  6860. #include <skinbase_vertex>
  6861. #include <skinnormal_vertex>
  6862. #include <defaultnormal_vertex>
  6863. #include <normal_vertex>
  6864. #include <begin_vertex>
  6865. #include <morphtarget_vertex>
  6866. #include <skinning_vertex>
  6867. #include <displacementmap_vertex>
  6868. #include <project_vertex>
  6869. #include <logdepthbuf_vertex>
  6870. #include <clipping_planes_vertex>
  6871. vViewPosition = - mvPosition.xyz;
  6872. #include <worldpos_vertex>
  6873. #include <envmap_vertex>
  6874. #include <shadowmap_vertex>
  6875. #include <fog_vertex>
  6876. }`,iUe=`#define PHONG
  6877. uniform vec3 diffuse;
  6878. uniform vec3 emissive;
  6879. uniform vec3 specular;
  6880. uniform float shininess;
  6881. uniform float opacity;
  6882. #include <common>
  6883. #include <packing>
  6884. #include <dithering_pars_fragment>
  6885. #include <color_pars_fragment>
  6886. #include <uv_pars_fragment>
  6887. #include <map_pars_fragment>
  6888. #include <alphamap_pars_fragment>
  6889. #include <alphatest_pars_fragment>
  6890. #include <alphahash_pars_fragment>
  6891. #include <aomap_pars_fragment>
  6892. #include <lightmap_pars_fragment>
  6893. #include <emissivemap_pars_fragment>
  6894. #include <envmap_common_pars_fragment>
  6895. #include <envmap_pars_fragment>
  6896. #include <fog_pars_fragment>
  6897. #include <bsdfs>
  6898. #include <lights_pars_begin>
  6899. #include <normal_pars_fragment>
  6900. #include <lights_phong_pars_fragment>
  6901. #include <shadowmap_pars_fragment>
  6902. #include <bumpmap_pars_fragment>
  6903. #include <normalmap_pars_fragment>
  6904. #include <specularmap_pars_fragment>
  6905. #include <logdepthbuf_pars_fragment>
  6906. #include <clipping_planes_pars_fragment>
  6907. void main() {
  6908. #include <clipping_planes_fragment>
  6909. vec4 diffuseColor = vec4( diffuse, opacity );
  6910. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  6911. vec3 totalEmissiveRadiance = emissive;
  6912. #include <logdepthbuf_fragment>
  6913. #include <map_fragment>
  6914. #include <color_fragment>
  6915. #include <alphamap_fragment>
  6916. #include <alphatest_fragment>
  6917. #include <alphahash_fragment>
  6918. #include <specularmap_fragment>
  6919. #include <normal_fragment_begin>
  6920. #include <normal_fragment_maps>
  6921. #include <emissivemap_fragment>
  6922. #include <lights_phong_fragment>
  6923. #include <lights_fragment_begin>
  6924. #include <lights_fragment_maps>
  6925. #include <lights_fragment_end>
  6926. #include <aomap_fragment>
  6927. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
  6928. #include <envmap_fragment>
  6929. #include <opaque_fragment>
  6930. #include <tonemapping_fragment>
  6931. #include <colorspace_fragment>
  6932. #include <fog_fragment>
  6933. #include <premultiplied_alpha_fragment>
  6934. #include <dithering_fragment>
  6935. }`,aUe=`#define STANDARD
  6936. varying vec3 vViewPosition;
  6937. #ifdef USE_TRANSMISSION
  6938. varying vec3 vWorldPosition;
  6939. #endif
  6940. #include <common>
  6941. #include <batching_pars_vertex>
  6942. #include <uv_pars_vertex>
  6943. #include <displacementmap_pars_vertex>
  6944. #include <color_pars_vertex>
  6945. #include <fog_pars_vertex>
  6946. #include <normal_pars_vertex>
  6947. #include <morphtarget_pars_vertex>
  6948. #include <skinning_pars_vertex>
  6949. #include <shadowmap_pars_vertex>
  6950. #include <logdepthbuf_pars_vertex>
  6951. #include <clipping_planes_pars_vertex>
  6952. void main() {
  6953. #include <uv_vertex>
  6954. #include <color_vertex>
  6955. #include <morphcolor_vertex>
  6956. #include <batching_vertex>
  6957. #include <beginnormal_vertex>
  6958. #include <morphnormal_vertex>
  6959. #include <skinbase_vertex>
  6960. #include <skinnormal_vertex>
  6961. #include <defaultnormal_vertex>
  6962. #include <normal_vertex>
  6963. #include <begin_vertex>
  6964. #include <morphtarget_vertex>
  6965. #include <skinning_vertex>
  6966. #include <displacementmap_vertex>
  6967. #include <project_vertex>
  6968. #include <logdepthbuf_vertex>
  6969. #include <clipping_planes_vertex>
  6970. vViewPosition = - mvPosition.xyz;
  6971. #include <worldpos_vertex>
  6972. #include <shadowmap_vertex>
  6973. #include <fog_vertex>
  6974. #ifdef USE_TRANSMISSION
  6975. vWorldPosition = worldPosition.xyz;
  6976. #endif
  6977. }`,sUe=`#define STANDARD
  6978. #ifdef PHYSICAL
  6979. #define IOR
  6980. #define USE_SPECULAR
  6981. #endif
  6982. uniform vec3 diffuse;
  6983. uniform vec3 emissive;
  6984. uniform float roughness;
  6985. uniform float metalness;
  6986. uniform float opacity;
  6987. #ifdef IOR
  6988. uniform float ior;
  6989. #endif
  6990. #ifdef USE_SPECULAR
  6991. uniform float specularIntensity;
  6992. uniform vec3 specularColor;
  6993. #ifdef USE_SPECULAR_COLORMAP
  6994. uniform sampler2D specularColorMap;
  6995. #endif
  6996. #ifdef USE_SPECULAR_INTENSITYMAP
  6997. uniform sampler2D specularIntensityMap;
  6998. #endif
  6999. #endif
  7000. #ifdef USE_CLEARCOAT
  7001. uniform float clearcoat;
  7002. uniform float clearcoatRoughness;
  7003. #endif
  7004. #ifdef USE_IRIDESCENCE
  7005. uniform float iridescence;
  7006. uniform float iridescenceIOR;
  7007. uniform float iridescenceThicknessMinimum;
  7008. uniform float iridescenceThicknessMaximum;
  7009. #endif
  7010. #ifdef USE_SHEEN
  7011. uniform vec3 sheenColor;
  7012. uniform float sheenRoughness;
  7013. #ifdef USE_SHEEN_COLORMAP
  7014. uniform sampler2D sheenColorMap;
  7015. #endif
  7016. #ifdef USE_SHEEN_ROUGHNESSMAP
  7017. uniform sampler2D sheenRoughnessMap;
  7018. #endif
  7019. #endif
  7020. #ifdef USE_ANISOTROPY
  7021. uniform vec2 anisotropyVector;
  7022. #ifdef USE_ANISOTROPYMAP
  7023. uniform sampler2D anisotropyMap;
  7024. #endif
  7025. #endif
  7026. varying vec3 vViewPosition;
  7027. #include <common>
  7028. #include <packing>
  7029. #include <dithering_pars_fragment>
  7030. #include <color_pars_fragment>
  7031. #include <uv_pars_fragment>
  7032. #include <map_pars_fragment>
  7033. #include <alphamap_pars_fragment>
  7034. #include <alphatest_pars_fragment>
  7035. #include <alphahash_pars_fragment>
  7036. #include <aomap_pars_fragment>
  7037. #include <lightmap_pars_fragment>
  7038. #include <emissivemap_pars_fragment>
  7039. #include <iridescence_fragment>
  7040. #include <cube_uv_reflection_fragment>
  7041. #include <envmap_common_pars_fragment>
  7042. #include <envmap_physical_pars_fragment>
  7043. #include <fog_pars_fragment>
  7044. #include <lights_pars_begin>
  7045. #include <normal_pars_fragment>
  7046. #include <lights_physical_pars_fragment>
  7047. #include <transmission_pars_fragment>
  7048. #include <shadowmap_pars_fragment>
  7049. #include <bumpmap_pars_fragment>
  7050. #include <normalmap_pars_fragment>
  7051. #include <clearcoat_pars_fragment>
  7052. #include <iridescence_pars_fragment>
  7053. #include <roughnessmap_pars_fragment>
  7054. #include <metalnessmap_pars_fragment>
  7055. #include <logdepthbuf_pars_fragment>
  7056. #include <clipping_planes_pars_fragment>
  7057. void main() {
  7058. #include <clipping_planes_fragment>
  7059. vec4 diffuseColor = vec4( diffuse, opacity );
  7060. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  7061. vec3 totalEmissiveRadiance = emissive;
  7062. #include <logdepthbuf_fragment>
  7063. #include <map_fragment>
  7064. #include <color_fragment>
  7065. #include <alphamap_fragment>
  7066. #include <alphatest_fragment>
  7067. #include <alphahash_fragment>
  7068. #include <roughnessmap_fragment>
  7069. #include <metalnessmap_fragment>
  7070. #include <normal_fragment_begin>
  7071. #include <normal_fragment_maps>
  7072. #include <clearcoat_normal_fragment_begin>
  7073. #include <clearcoat_normal_fragment_maps>
  7074. #include <emissivemap_fragment>
  7075. #include <lights_physical_fragment>
  7076. #include <lights_fragment_begin>
  7077. #include <lights_fragment_maps>
  7078. #include <lights_fragment_end>
  7079. #include <aomap_fragment>
  7080. vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
  7081. vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
  7082. #include <transmission_fragment>
  7083. vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
  7084. #ifdef USE_SHEEN
  7085. float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
  7086. outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
  7087. #endif
  7088. #ifdef USE_CLEARCOAT
  7089. float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
  7090. vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
  7091. outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
  7092. #endif
  7093. #include <opaque_fragment>
  7094. #include <tonemapping_fragment>
  7095. #include <colorspace_fragment>
  7096. #include <fog_fragment>
  7097. #include <premultiplied_alpha_fragment>
  7098. #include <dithering_fragment>
  7099. }`,oUe=`#define TOON
  7100. varying vec3 vViewPosition;
  7101. #include <common>
  7102. #include <batching_pars_vertex>
  7103. #include <uv_pars_vertex>
  7104. #include <displacementmap_pars_vertex>
  7105. #include <color_pars_vertex>
  7106. #include <fog_pars_vertex>
  7107. #include <normal_pars_vertex>
  7108. #include <morphtarget_pars_vertex>
  7109. #include <skinning_pars_vertex>
  7110. #include <shadowmap_pars_vertex>
  7111. #include <logdepthbuf_pars_vertex>
  7112. #include <clipping_planes_pars_vertex>
  7113. void main() {
  7114. #include <uv_vertex>
  7115. #include <color_vertex>
  7116. #include <morphcolor_vertex>
  7117. #include <batching_vertex>
  7118. #include <beginnormal_vertex>
  7119. #include <morphnormal_vertex>
  7120. #include <skinbase_vertex>
  7121. #include <skinnormal_vertex>
  7122. #include <defaultnormal_vertex>
  7123. #include <normal_vertex>
  7124. #include <begin_vertex>
  7125. #include <morphtarget_vertex>
  7126. #include <skinning_vertex>
  7127. #include <displacementmap_vertex>
  7128. #include <project_vertex>
  7129. #include <logdepthbuf_vertex>
  7130. #include <clipping_planes_vertex>
  7131. vViewPosition = - mvPosition.xyz;
  7132. #include <worldpos_vertex>
  7133. #include <shadowmap_vertex>
  7134. #include <fog_vertex>
  7135. }`,lUe=`#define TOON
  7136. uniform vec3 diffuse;
  7137. uniform vec3 emissive;
  7138. uniform float opacity;
  7139. #include <common>
  7140. #include <packing>
  7141. #include <dithering_pars_fragment>
  7142. #include <color_pars_fragment>
  7143. #include <uv_pars_fragment>
  7144. #include <map_pars_fragment>
  7145. #include <alphamap_pars_fragment>
  7146. #include <alphatest_pars_fragment>
  7147. #include <alphahash_pars_fragment>
  7148. #include <aomap_pars_fragment>
  7149. #include <lightmap_pars_fragment>
  7150. #include <emissivemap_pars_fragment>
  7151. #include <gradientmap_pars_fragment>
  7152. #include <fog_pars_fragment>
  7153. #include <bsdfs>
  7154. #include <lights_pars_begin>
  7155. #include <normal_pars_fragment>
  7156. #include <lights_toon_pars_fragment>
  7157. #include <shadowmap_pars_fragment>
  7158. #include <bumpmap_pars_fragment>
  7159. #include <normalmap_pars_fragment>
  7160. #include <logdepthbuf_pars_fragment>
  7161. #include <clipping_planes_pars_fragment>
  7162. void main() {
  7163. #include <clipping_planes_fragment>
  7164. vec4 diffuseColor = vec4( diffuse, opacity );
  7165. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  7166. vec3 totalEmissiveRadiance = emissive;
  7167. #include <logdepthbuf_fragment>
  7168. #include <map_fragment>
  7169. #include <color_fragment>
  7170. #include <alphamap_fragment>
  7171. #include <alphatest_fragment>
  7172. #include <alphahash_fragment>
  7173. #include <normal_fragment_begin>
  7174. #include <normal_fragment_maps>
  7175. #include <emissivemap_fragment>
  7176. #include <lights_toon_fragment>
  7177. #include <lights_fragment_begin>
  7178. #include <lights_fragment_maps>
  7179. #include <lights_fragment_end>
  7180. #include <aomap_fragment>
  7181. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
  7182. #include <opaque_fragment>
  7183. #include <tonemapping_fragment>
  7184. #include <colorspace_fragment>
  7185. #include <fog_fragment>
  7186. #include <premultiplied_alpha_fragment>
  7187. #include <dithering_fragment>
  7188. }`,cUe=`uniform float size;
  7189. uniform float scale;
  7190. #include <common>
  7191. #include <color_pars_vertex>
  7192. #include <fog_pars_vertex>
  7193. #include <morphtarget_pars_vertex>
  7194. #include <logdepthbuf_pars_vertex>
  7195. #include <clipping_planes_pars_vertex>
  7196. #ifdef USE_POINTS_UV
  7197. varying vec2 vUv;
  7198. uniform mat3 uvTransform;
  7199. #endif
  7200. void main() {
  7201. #ifdef USE_POINTS_UV
  7202. vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
  7203. #endif
  7204. #include <color_vertex>
  7205. #include <morphcolor_vertex>
  7206. #include <begin_vertex>
  7207. #include <morphtarget_vertex>
  7208. #include <project_vertex>
  7209. gl_PointSize = size;
  7210. #ifdef USE_SIZEATTENUATION
  7211. bool isPerspective = isPerspectiveMatrix( projectionMatrix );
  7212. if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
  7213. #endif
  7214. #include <logdepthbuf_vertex>
  7215. #include <clipping_planes_vertex>
  7216. #include <worldpos_vertex>
  7217. #include <fog_vertex>
  7218. }`,uUe=`uniform vec3 diffuse;
  7219. uniform float opacity;
  7220. #include <common>
  7221. #include <color_pars_fragment>
  7222. #include <map_particle_pars_fragment>
  7223. #include <alphatest_pars_fragment>
  7224. #include <alphahash_pars_fragment>
  7225. #include <fog_pars_fragment>
  7226. #include <logdepthbuf_pars_fragment>
  7227. #include <clipping_planes_pars_fragment>
  7228. void main() {
  7229. #include <clipping_planes_fragment>
  7230. vec3 outgoingLight = vec3( 0.0 );
  7231. vec4 diffuseColor = vec4( diffuse, opacity );
  7232. #include <logdepthbuf_fragment>
  7233. #include <map_particle_fragment>
  7234. #include <color_fragment>
  7235. #include <alphatest_fragment>
  7236. #include <alphahash_fragment>
  7237. outgoingLight = diffuseColor.rgb;
  7238. #include <opaque_fragment>
  7239. #include <tonemapping_fragment>
  7240. #include <colorspace_fragment>
  7241. #include <fog_fragment>
  7242. #include <premultiplied_alpha_fragment>
  7243. }`,dUe=`#include <common>
  7244. #include <batching_pars_vertex>
  7245. #include <fog_pars_vertex>
  7246. #include <morphtarget_pars_vertex>
  7247. #include <skinning_pars_vertex>
  7248. #include <logdepthbuf_pars_vertex>
  7249. #include <shadowmap_pars_vertex>
  7250. void main() {
  7251. #include <batching_vertex>
  7252. #include <beginnormal_vertex>
  7253. #include <morphnormal_vertex>
  7254. #include <skinbase_vertex>
  7255. #include <skinnormal_vertex>
  7256. #include <defaultnormal_vertex>
  7257. #include <begin_vertex>
  7258. #include <morphtarget_vertex>
  7259. #include <skinning_vertex>
  7260. #include <project_vertex>
  7261. #include <logdepthbuf_vertex>
  7262. #include <worldpos_vertex>
  7263. #include <shadowmap_vertex>
  7264. #include <fog_vertex>
  7265. }`,hUe=`uniform vec3 color;
  7266. uniform float opacity;
  7267. #include <common>
  7268. #include <packing>
  7269. #include <fog_pars_fragment>
  7270. #include <bsdfs>
  7271. #include <lights_pars_begin>
  7272. #include <logdepthbuf_pars_fragment>
  7273. #include <shadowmap_pars_fragment>
  7274. #include <shadowmask_pars_fragment>
  7275. void main() {
  7276. #include <logdepthbuf_fragment>
  7277. gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
  7278. #include <tonemapping_fragment>
  7279. #include <colorspace_fragment>
  7280. #include <fog_fragment>
  7281. }`,fUe=`uniform float rotation;
  7282. uniform vec2 center;
  7283. #include <common>
  7284. #include <uv_pars_vertex>
  7285. #include <fog_pars_vertex>
  7286. #include <logdepthbuf_pars_vertex>
  7287. #include <clipping_planes_pars_vertex>
  7288. void main() {
  7289. #include <uv_vertex>
  7290. vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );
  7291. vec2 scale;
  7292. scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );
  7293. scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );
  7294. #ifndef USE_SIZEATTENUATION
  7295. bool isPerspective = isPerspectiveMatrix( projectionMatrix );
  7296. if ( isPerspective ) scale *= - mvPosition.z;
  7297. #endif
  7298. vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
  7299. vec2 rotatedPosition;
  7300. rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
  7301. rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
  7302. mvPosition.xy += rotatedPosition;
  7303. gl_Position = projectionMatrix * mvPosition;
  7304. #include <logdepthbuf_vertex>
  7305. #include <clipping_planes_vertex>
  7306. #include <fog_vertex>
  7307. }`,mUe=`uniform vec3 diffuse;
  7308. uniform float opacity;
  7309. #include <common>
  7310. #include <uv_pars_fragment>
  7311. #include <map_pars_fragment>
  7312. #include <alphamap_pars_fragment>
  7313. #include <alphatest_pars_fragment>
  7314. #include <alphahash_pars_fragment>
  7315. #include <fog_pars_fragment>
  7316. #include <logdepthbuf_pars_fragment>
  7317. #include <clipping_planes_pars_fragment>
  7318. void main() {
  7319. #include <clipping_planes_fragment>
  7320. vec3 outgoingLight = vec3( 0.0 );
  7321. vec4 diffuseColor = vec4( diffuse, opacity );
  7322. #include <logdepthbuf_fragment>
  7323. #include <map_fragment>
  7324. #include <alphamap_fragment>
  7325. #include <alphatest_fragment>
  7326. #include <alphahash_fragment>
  7327. outgoingLight = diffuseColor.rgb;
  7328. #include <opaque_fragment>
  7329. #include <tonemapping_fragment>
  7330. #include <colorspace_fragment>
  7331. #include <fog_fragment>
  7332. }`,Nn={alphahash_fragment:LIe,alphahash_pars_fragment:IIe,alphamap_fragment:FIe,alphamap_pars_fragment:UIe,alphatest_fragment:zIe,alphatest_pars_fragment:BIe,aomap_fragment:$Ie,aomap_pars_fragment:HIe,batching_pars_vertex:VIe,batching_vertex:GIe,begin_vertex:WIe,beginnormal_vertex:qIe,bsdfs:KIe,iridescence_fragment:XIe,bumpmap_pars_fragment:YIe,clipping_planes_fragment:QIe,clipping_planes_pars_fragment:ZIe,clipping_planes_pars_vertex:JIe,clipping_planes_vertex:e5e,color_fragment:t5e,color_pars_fragment:n5e,color_pars_vertex:r5e,color_vertex:i5e,common:a5e,cube_uv_reflection_fragment:s5e,defaultnormal_vertex:o5e,displacementmap_pars_vertex:l5e,displacementmap_vertex:c5e,emissivemap_fragment:u5e,emissivemap_pars_fragment:d5e,colorspace_fragment:h5e,colorspace_pars_fragment:f5e,envmap_fragment:m5e,envmap_common_pars_fragment:p5e,envmap_pars_fragment:g5e,envmap_pars_vertex:x5e,envmap_physical_pars_fragment:C5e,envmap_vertex:b5e,fog_vertex:y5e,fog_pars_vertex:v5e,fog_fragment:_5e,fog_pars_fragment:w5e,gradientmap_pars_fragment:S5e,lightmap_fragment:N5e,lightmap_pars_fragment:M5e,lights_lambert_fragment:E5e,lights_lambert_pars_fragment:T5e,lights_pars_begin:A5e,lights_toon_fragment:k5e,lights_toon_pars_fragment:j5e,lights_phong_fragment:P5e,lights_phong_pars_fragment:R5e,lights_physical_fragment:D5e,lights_physical_pars_fragment:O5e,lights_fragment_begin:L5e,lights_fragment_maps:I5e,lights_fragment_end:F5e,logdepthbuf_fragment:U5e,logdepthbuf_pars_fragment:z5e,logdepthbuf_pars_vertex:B5e,logdepthbuf_vertex:$5e,map_fragment:H5e,map_pars_fragment:V5e,map_particle_fragment:G5e,map_particle_pars_fragment:W5e,metalnessmap_fragment:q5e,metalnessmap_pars_fragment:K5e,morphcolor_vertex:X5e,morphnormal_vertex:Y5e,morphtarget_pars_vertex:Q5e,morphtarget_vertex:Z5e,normal_fragment_begin:J5e,normal_fragment_maps:eFe,normal_pars_fragment:tFe,normal_pars_vertex:nFe,normal_vertex:rFe,normalmap_pars_fragment:iFe,clearcoat_normal_fragment_begin:aFe,clearcoat_normal_fragment_maps:sFe,clearcoat_pars_fragment:oFe,iridescence_pars_fragment:lFe,opaque_fragment:cFe,packing:uFe,premultiplied_alpha_fragment:dFe,project_vertex:hFe,dithering_fragment:fFe,dithering_pars_fragment:mFe,roughnessmap_fragment:pFe,roughnessmap_pars_fragment:gFe,shadowmap_pars_fragment:xFe,shadowmap_pars_vertex:bFe,shadowmap_vertex:yFe,shadowmask_pars_fragment:vFe,skinbase_vertex:_Fe,skinning_pars_vertex:wFe,skinning_vertex:SFe,skinnormal_vertex:NFe,specularmap_fragment:MFe,specularmap_pars_fragment:EFe,tonemapping_fragment:TFe,tonemapping_pars_fragment:AFe,transmission_fragment:CFe,transmission_pars_fragment:kFe,uv_pars_fragment:jFe,uv_pars_vertex:PFe,uv_vertex:RFe,worldpos_vertex:DFe,background_vert:OFe,background_frag:LFe,backgroundCube_vert:IFe,backgroundCube_frag:FFe,cube_vert:UFe,cube_frag:zFe,depth_vert:BFe,depth_frag:$Fe,distanceRGBA_vert:HFe,distanceRGBA_frag:VFe,equirect_vert:GFe,equirect_frag:WFe,linedashed_vert:qFe,linedashed_frag:KFe,meshbasic_vert:XFe,meshbasic_frag:YFe,meshlambert_vert:QFe,meshlambert_frag:ZFe,meshmatcap_vert:JFe,meshmatcap_frag:eUe,meshnormal_vert:tUe,meshnormal_frag:nUe,meshphong_vert:rUe,meshphong_frag:iUe,meshphysical_vert:aUe,meshphysical_frag:sUe,meshtoon_vert:oUe,meshtoon_frag:lUe,points_vert:cUe,points_frag:uUe,shadow_vert:dUe,shadow_frag:hUe,sprite_vert:fUe,sprite_frag:mUe},Dt={common:{diffuse:{value:new nn(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Cn},alphaMap:{value:null},alphaMapTransform:{value:new Cn},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Cn}},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 Cn}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Cn}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Cn},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Cn},normalScale:{value:new pn(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Cn},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Cn}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Cn}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Cn}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new nn(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 nn(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Cn},alphaTest:{value:0},uvTransform:{value:new Cn}},sprite:{diffuse:{value:new nn(16777215)},opacity:{value:1},center:{value:new pn(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Cn},alphaMap:{value:null},alphaMapTransform:{value:new Cn},alphaTest:{value:0}}},ms={basic:{uniforms:Ha([Dt.common,Dt.specularmap,Dt.envmap,Dt.aomap,Dt.lightmap,Dt.fog]),vertexShader:Nn.meshbasic_vert,fragmentShader:Nn.meshbasic_frag},lambert:{uniforms:Ha([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 nn(0)}}]),vertexShader:Nn.meshlambert_vert,fragmentShader:Nn.meshlambert_frag},phong:{uniforms:Ha([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 nn(0)},specular:{value:new nn(1118481)},shininess:{value:30}}]),vertexShader:Nn.meshphong_vert,fragmentShader:Nn.meshphong_frag},standard:{uniforms:Ha([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 nn(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Nn.meshphysical_vert,fragmentShader:Nn.meshphysical_frag},toon:{uniforms:Ha([Dt.common,Dt.aomap,Dt.lightmap,Dt.emissivemap,Dt.bumpmap,Dt.normalmap,Dt.displacementmap,Dt.gradientmap,Dt.fog,Dt.lights,{emissive:{value:new nn(0)}}]),vertexShader:Nn.meshtoon_vert,fragmentShader:Nn.meshtoon_frag},matcap:{uniforms:Ha([Dt.common,Dt.bumpmap,Dt.normalmap,Dt.displacementmap,Dt.fog,{matcap:{value:null}}]),vertexShader:Nn.meshmatcap_vert,fragmentShader:Nn.meshmatcap_frag},points:{uniforms:Ha([Dt.points,Dt.fog]),vertexShader:Nn.points_vert,fragmentShader:Nn.points_frag},dashed:{uniforms:Ha([Dt.common,Dt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Nn.linedashed_vert,fragmentShader:Nn.linedashed_frag},depth:{uniforms:Ha([Dt.common,Dt.displacementmap]),vertexShader:Nn.depth_vert,fragmentShader:Nn.depth_frag},normal:{uniforms:Ha([Dt.common,Dt.bumpmap,Dt.normalmap,Dt.displacementmap,{opacity:{value:1}}]),vertexShader:Nn.meshnormal_vert,fragmentShader:Nn.meshnormal_frag},sprite:{uniforms:Ha([Dt.sprite,Dt.fog]),vertexShader:Nn.sprite_vert,fragmentShader:Nn.sprite_frag},background:{uniforms:{uvTransform:{value:new Cn},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Nn.background_vert,fragmentShader:Nn.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:Nn.backgroundCube_vert,fragmentShader:Nn.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Nn.cube_vert,fragmentShader:Nn.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Nn.equirect_vert,fragmentShader:Nn.equirect_frag},distanceRGBA:{uniforms:Ha([Dt.common,Dt.displacementmap,{referencePosition:{value:new We},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Nn.distanceRGBA_vert,fragmentShader:Nn.distanceRGBA_frag},shadow:{uniforms:Ha([Dt.lights,Dt.fog,{color:{value:new nn(0)},opacity:{value:1}}]),vertexShader:Nn.shadow_vert,fragmentShader:Nn.shadow_frag}};ms.physical={uniforms:Ha([ms.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Cn},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Cn},clearcoatNormalScale:{value:new pn(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Cn},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Cn},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Cn},sheen:{value:0},sheenColor:{value:new nn(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Cn},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Cn},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Cn},transmissionSamplerSize:{value:new pn},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Cn},attenuationDistance:{value:0},attenuationColor:{value:new nn(0)},specularColor:{value:new nn(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Cn},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Cn},anisotropyVector:{value:new pn},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Cn}}]),vertexShader:Nn.meshphysical_vert,fragmentShader:Nn.meshphysical_frag};const h1={r:0,b:0,g:0};function pUe(t,e,n,r,i,a,o){const l=new nn(0);let c=a===!0?0:1,u,d,f=null,m=0,p=null;function x(b,v){let N=!1,S=v.isScene===!0?v.background:null;S&&S.isTexture&&(S=(v.backgroundBlurriness>0?n:e).get(S)),S===null?y(l,c):S&&S.isColor&&(y(S,1),N=!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||N)&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),S&&(S.isCubeTexture||S.mapping===GN)?(d===void 0&&(d=new rl(new Ly(1,1,1),new Qd({name:"BackgroundCubeMaterial",uniforms:Ng(ms.backgroundCube.uniforms),vertexShader:ms.backgroundCube.vertexShader,fragmentShader:ms.backgroundCube.fragmentShader,side:ys,depthTest:!1,depthWrite:!1,fog:!1})),d.geometry.deleteAttribute("normal"),d.geometry.deleteAttribute("uv"),d.onBeforeRender=function(E,C,A){this.matrixWorld.copyPosition(A.matrixWorld)},Object.defineProperty(d.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(d)),d.material.uniforms.envMap.value=S,d.material.uniforms.flipEnvMap.value=S.isCubeTexture&&S.isRenderTargetTexture===!1?-1:1,d.material.uniforms.backgroundBlurriness.value=v.backgroundBlurriness,d.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,d.material.toneMapped=mr.getTransfer(S.colorSpace)!==Cr,(f!==S||m!==S.version||p!==t.toneMapping)&&(d.material.needsUpdate=!0,f=S,m=S.version,p=t.toneMapping),d.layers.enableAll(),b.unshift(d,d.geometry,d.material,0,0,null)):S&&S.isTexture&&(u===void 0&&(u=new rl(new $O(2,2),new Qd({name:"BackgroundMaterial",uniforms:Ng(ms.background.uniforms),vertexShader:ms.background.vertexShader,fragmentShader:ms.background.fragmentShader,side:Yd,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=S,u.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,u.material.toneMapped=mr.getTransfer(S.colorSpace)!==Cr,S.matrixAutoUpdate===!0&&S.updateMatrix(),u.material.uniforms.uvTransform.value.copy(S.matrix),(f!==S||m!==S.version||p!==t.toneMapping)&&(u.material.needsUpdate=!0,f=S,m=S.version,p=t.toneMapping),u.layers.enableAll(),b.unshift(u,u.geometry,u.material,0,0,null))}function y(b,v){b.getRGB(h1,HJ(t)),r.buffers.color.setClear(h1.r,h1.g,h1.b,v,o)}return{getClearColor:function(){return l},setClearColor:function(b,v=1){l.set(b),c=v,y(l,c)},getClearAlpha:function(){return c},setClearAlpha:function(b){c=b,y(l,c)},render:x}}function gUe(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=b(null);let u=c,d=!1;function f(j,W,Y,q,Q){let ee=!1;if(o){const re=y(q,Y,W);u!==re&&(u=re,p(u.object)),ee=v(j,q,Y,Q),ee&&N(j,q,Y,Q)}else{const re=W.wireframe===!0;(u.geometry!==q.id||u.program!==Y.id||u.wireframe!==re)&&(u.geometry=q.id,u.program=Y.id,u.wireframe=re,ee=!0)}Q!==null&&n.update(Q,t.ELEMENT_ARRAY_BUFFER),(ee||d)&&(d=!1,O(j,W,Y,q),Q!==null&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,n.get(Q).buffer))}function m(){return r.isWebGL2?t.createVertexArray():a.createVertexArrayOES()}function p(j){return r.isWebGL2?t.bindVertexArray(j):a.bindVertexArrayOES(j)}function x(j){return r.isWebGL2?t.deleteVertexArray(j):a.deleteVertexArrayOES(j)}function y(j,W,Y){const q=Y.wireframe===!0;let Q=l[j.id];Q===void 0&&(Q={},l[j.id]=Q);let ee=Q[W.id];ee===void 0&&(ee={},Q[W.id]=ee);let re=ee[q];return re===void 0&&(re=b(m()),ee[q]=re),re}function b(j){const W=[],Y=[],q=[];for(let Q=0;Q<i;Q++)W[Q]=0,Y[Q]=0,q[Q]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:W,enabledAttributes:Y,attributeDivisors:q,object:j,attributes:{},index:null}}function v(j,W,Y,q){const Q=u.attributes,ee=W.attributes;let re=0;const z=Y.getAttributes();for(const G in z)if(z[G].location>=0){const se=Q[G];let ue=ee[G];if(ue===void 0&&(G==="instanceMatrix"&&j.instanceMatrix&&(ue=j.instanceMatrix),G==="instanceColor"&&j.instanceColor&&(ue=j.instanceColor)),se===void 0||se.attribute!==ue||ue&&se.data!==ue.data)return!0;re++}return u.attributesNum!==re||u.index!==q}function N(j,W,Y,q){const Q={},ee=W.attributes;let re=0;const z=Y.getAttributes();for(const G in z)if(z[G].location>=0){let se=ee[G];se===void 0&&(G==="instanceMatrix"&&j.instanceMatrix&&(se=j.instanceMatrix),G==="instanceColor"&&j.instanceColor&&(se=j.instanceColor));const ue={};ue.attribute=se,se&&se.data&&(ue.data=se.data),Q[G]=ue,re++}u.attributes=Q,u.attributesNum=re,u.index=q}function S(){const j=u.newAttributes;for(let W=0,Y=j.length;W<Y;W++)j[W]=0}function T(j){E(j,0)}function E(j,W){const Y=u.newAttributes,q=u.enabledAttributes,Q=u.attributeDivisors;Y[j]=1,q[j]===0&&(t.enableVertexAttribArray(j),q[j]=1),Q[j]!==W&&((r.isWebGL2?t:e.get("ANGLE_instanced_arrays"))[r.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](j,W),Q[j]=W)}function C(){const j=u.newAttributes,W=u.enabledAttributes;for(let Y=0,q=W.length;Y<q;Y++)W[Y]!==j[Y]&&(t.disableVertexAttribArray(Y),W[Y]=0)}function A(j,W,Y,q,Q,ee,re){re===!0?t.vertexAttribIPointer(j,W,Y,Q,ee):t.vertexAttribPointer(j,W,Y,q,Q,ee)}function O(j,W,Y,q){if(r.isWebGL2===!1&&(j.isInstancedMesh||q.isInstancedBufferGeometry)&&e.get("ANGLE_instanced_arrays")===null)return;S();const Q=q.attributes,ee=Y.getAttributes(),re=W.defaultAttributeValues;for(const z in ee){const G=ee[z];if(G.location>=0){let ae=Q[z];if(ae===void 0&&(z==="instanceMatrix"&&j.instanceMatrix&&(ae=j.instanceMatrix),z==="instanceColor"&&j.instanceColor&&(ae=j.instanceColor)),ae!==void 0){const se=ae.normalized,ue=ae.itemSize,pe=n.get(ae);if(pe===void 0)continue;const ce=pe.buffer,Me=pe.type,me=pe.bytesPerElement,Ee=r.isWebGL2===!0&&(Me===t.INT||Me===t.UNSIGNED_INT||ae.gpuType===SJ);if(ae.isInterleavedBufferAttribute){const fe=ae.data,le=fe.stride,Be=ae.offset;if(fe.isInstancedInterleavedBuffer){for(let V=0;V<G.locationSize;V++)E(G.location+V,fe.meshPerAttribute);j.isInstancedMesh!==!0&&q._maxInstanceCount===void 0&&(q._maxInstanceCount=fe.meshPerAttribute*fe.count)}else for(let V=0;V<G.locationSize;V++)T(G.location+V);t.bindBuffer(t.ARRAY_BUFFER,ce);for(let V=0;V<G.locationSize;V++)A(G.location+V,ue/G.locationSize,Me,se,le*me,(Be+ue/G.locationSize*V)*me,Ee)}else{if(ae.isInstancedBufferAttribute){for(let fe=0;fe<G.locationSize;fe++)E(G.location+fe,ae.meshPerAttribute);j.isInstancedMesh!==!0&&q._maxInstanceCount===void 0&&(q._maxInstanceCount=ae.meshPerAttribute*ae.count)}else for(let fe=0;fe<G.locationSize;fe++)T(G.location+fe);t.bindBuffer(t.ARRAY_BUFFER,ce);for(let fe=0;fe<G.locationSize;fe++)A(G.location+fe,ue/G.locationSize,Me,se,ue*me,ue/G.locationSize*fe*me,Ee)}}else if(re!==void 0){const se=re[z];if(se!==void 0)switch(se.length){case 2:t.vertexAttrib2fv(G.location,se);break;case 3:t.vertexAttrib3fv(G.location,se);break;case 4:t.vertexAttrib4fv(G.location,se);break;default:t.vertexAttrib1fv(G.location,se)}}}}C()}function k(){L();for(const j in l){const W=l[j];for(const Y in W){const q=W[Y];for(const Q in q)x(q[Q].object),delete q[Q];delete W[Y]}delete l[j]}}function R(j){if(l[j.id]===void 0)return;const W=l[j.id];for(const Y in W){const q=W[Y];for(const Q in q)x(q[Q].object),delete q[Q];delete W[Y]}delete l[j.id]}function F(j){for(const W in l){const Y=l[W];if(Y[j.id]===void 0)continue;const q=Y[j.id];for(const Q in q)x(q[Q].object),delete q[Q];delete Y[j.id]}}function L(){K(),d=!0,u!==c&&(u=c,p(u.object))}function K(){c.geometry=null,c.program=null,c.wireframe=!1}return{setup:f,reset:L,resetDefaultState:K,dispose:k,releaseStatesOfGeometry:R,releaseStatesOfProgram:F,initAttributes:S,enableAttribute:T,disableUnusedAttributes:C}}function xUe(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,m){if(m===0)return;let p,x;if(i)p=t,x="drawArraysInstanced";else if(p=e.get("ANGLE_instanced_arrays"),x="drawArraysInstancedANGLE",p===null){console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}p[x](a,d,f,m),n.update(f,a,m)}function u(d,f,m){if(m===0)return;const p=e.get("WEBGL_multi_draw");if(p===null)for(let x=0;x<m;x++)this.render(d[x],f[x]);else{p.multiDrawArraysWEBGL(a,d,0,f,0,m);let x=0;for(let y=0;y<m;y++)x+=f[y];n.update(x,a,1)}}this.setMode=o,this.render=l,this.renderInstances=c,this.renderMultiDraw=u}function bUe(t,e,n){let r;function i(){if(r!==void 0)return r;if(e.has("EXT_texture_filter_anisotropic")===!0){const A=e.get("EXT_texture_filter_anisotropic");r=t.getParameter(A.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function a(A){if(A==="highp"){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";A="mediump"}return A==="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),m=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),p=t.getParameter(t.MAX_TEXTURE_SIZE),x=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),y=t.getParameter(t.MAX_VERTEX_ATTRIBS),b=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),v=t.getParameter(t.MAX_VARYING_VECTORS),N=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),S=m>0,T=o||e.has("OES_texture_float"),E=S&&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:m,maxTextureSize:p,maxCubemapSize:x,maxAttributes:y,maxVertexUniforms:b,maxVaryings:v,maxFragmentUniforms:N,vertexTextures:S,floatFragmentTextures:T,floatVertexTextures:E,maxSamples:C}}function yUe(t){const e=this;let n=null,r=0,i=!1,a=!1;const o=new dd,l=new Cn,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(f,m){const p=f.length!==0||m||r!==0||i;return i=m,r=f.length,p},this.beginShadows=function(){a=!0,d(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(f,m){n=d(f,m,0)},this.setState=function(f,m,p){const x=f.clippingPlanes,y=f.clipIntersection,b=f.clipShadows,v=t.get(f);if(!i||x===null||x.length===0||a&&!b)a?d(null):u();else{const N=a?0:r,S=N*4;let T=v.clippingState||null;c.value=T,T=d(x,m,S,p);for(let E=0;E!==S;++E)T[E]=n[E];v.clippingState=T,this.numIntersection=y?this.numPlanes:0,this.numPlanes+=N}};function u(){c.value!==n&&(c.value=n,c.needsUpdate=r>0),e.numPlanes=r,e.numIntersection=0}function d(f,m,p,x){const y=f!==null?f.length:0;let b=null;if(y!==0){if(b=c.value,x!==!0||b===null){const v=p+y*4,N=m.matrixWorldInverse;l.getNormalMatrix(N),(b===null||b.length<v)&&(b=new Float32Array(v));for(let S=0,T=p;S!==y;++S,T+=4)o.copy(f[S]).applyMatrix4(N,l),o.normal.toArray(b,T),b[T+3]=o.constant}c.value=b,c.needsUpdate=!0}return e.numPlanes=y,e.numIntersection=0,b}}function vUe(t){let e=new WeakMap;function n(o,l){return l===YP?o.mapping=_g:l===QP&&(o.mapping=wg),o}function r(o){if(o&&o.isTexture){const l=o.mapping;if(l===YP||l===QP)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 PIe(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 _Ue 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.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 zp=4,b7=[.125,.215,.35,.446,.526,.582],Kh=20,Ek=new _Ue,y7=new nn;let Tk=null,Ak=0,Ck=0;const Vh=(1+Math.sqrt(5))/2,vp=1/Vh,v7=[new We(1,1,1),new We(-1,1,1),new We(1,1,-1),new We(-1,1,-1),new We(0,Vh,vp),new We(0,Vh,-vp),new We(vp,0,Vh),new We(-vp,0,Vh),new We(Vh,vp,0),new We(-Vh,vp,0)];class _7{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){Tk=this._renderer.getRenderTarget(),Ak=this._renderer.getActiveCubeFace(),Ck=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=N7(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=S7(),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(Tk,Ak,Ck),e.scissorTest=!1,f1(e,0,0,e.width,e.height)}_fromTexture(e,n){e.mapping===_g||e.mapping===wg?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Tk=this._renderer.getRenderTarget(),Ak=this._renderer.getActiveCubeFace(),Ck=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:wo,minFilter:wo,generateMipmaps:!1,type:U0,format:So,colorSpace:pu,depthBuffer:!1},i=w7(e,n,r);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==n){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=w7(e,n,r);const{_lodMax:a}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=wUe(a)),this._blurMaterial=SUe(a,e,n)}return i}_compileMaterial(e){const n=new rl(this._lodPlanes[0],e);this._renderer.compile(n,Ek)}_sceneToCubeUV(e,n,r,i){const l=new Us(90,1,n,r),c=[1,-1,1,1,1,1],u=[1,1,1,-1,-1,-1],d=this._renderer,f=d.autoClear,m=d.toneMapping;d.getClearColor(y7),d.toneMapping=Od,d.autoClear=!1;const p=new zJ({name:"PMREM.Background",side:ys,depthWrite:!1,depthTest:!1}),x=new rl(new Ly,p);let y=!1;const b=e.background;b?b.isColor&&(p.color.copy(b),e.background=null,y=!0):(p.color.copy(y7),y=!0);for(let v=0;v<6;v++){const N=v%3;N===0?(l.up.set(0,c[v],0),l.lookAt(u[v],0,0)):N===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 S=this._cubeSize;f1(i,N*S,v>2?S:0,S,S),d.setRenderTarget(i),y&&d.render(x,l),d.render(e,l)}x.geometry.dispose(),x.material.dispose(),d.toneMapping=m,d.autoClear=f,e.background=b}_textureToCubeUV(e,n){const r=this._renderer,i=e.mapping===_g||e.mapping===wg;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=N7()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=S7());const a=i?this._cubemapMaterial:this._equirectMaterial,o=new rl(this._lodPlanes[0],a),l=a.uniforms;l.envMap.value=e;const c=this._cubeSize;f1(n,0,0,3*c,2*c),r.setRenderTarget(n),r.render(o,Ek)}_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=v7[(i-1)%v7.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 rl(this._lodPlanes[i],u),m=u.uniforms,p=this._sizeLods[r]-1,x=isFinite(a)?Math.PI/(2*p):2*Math.PI/(2*Kh-1),y=a/x,b=isFinite(a)?1+Math.floor(d*y):Kh;b>Kh&&console.warn(`sigmaRadians, ${a}, is too large and will clip, as it requested ${b} samples when the maximum is set to ${Kh}`);const v=[];let N=0;for(let A=0;A<Kh;++A){const O=A/y,k=Math.exp(-O*O/2);v.push(k),A===0?N+=k:A<b&&(N+=2*k)}for(let A=0;A<v.length;A++)v[A]=v[A]/N;m.envMap.value=e.texture,m.samples.value=b,m.weights.value=v,m.latitudinal.value=o==="latitudinal",l&&(m.poleAxis.value=l);const{_lodMax:S}=this;m.dTheta.value=x,m.mipInt.value=S-r;const T=this._sizeLods[i],E=3*T*(i>S-zp?i-S+zp:0),C=4*(this._cubeSize-T);f1(n,E,C,3*T,2*T),c.setRenderTarget(n),c.render(f,Ek)}}function wUe(t){const e=[],n=[],r=[];let i=t;const a=t-zp+1+b7.length;for(let o=0;o<a;o++){const l=Math.pow(2,i);n.push(l);let c=1/l;o>t-zp?c=b7[o-t+zp-1]:o===0&&(c=0),r.push(c);const u=1/(l-2),d=-u,f=1+u,m=[d,d,f,d,f,f,d,d,f,f,d,f],p=6,x=6,y=3,b=2,v=1,N=new Float32Array(y*x*p),S=new Float32Array(b*x*p),T=new Float32Array(v*x*p);for(let C=0;C<p;C++){const A=C%3*2/3-1,O=C>2?0:-1,k=[A,O,0,A+2/3,O,0,A+2/3,O+1,0,A,O,0,A+2/3,O+1,0,A,O+1,0];N.set(k,y*x*C),S.set(m,b*x*C);const R=[C,C,C,C,C,C];T.set(R,v*x*C)}const E=new Ia;E.setAttribute("position",new qs(N,y)),E.setAttribute("uv",new qs(S,b)),E.setAttribute("faceIndex",new qs(T,v)),e.push(E),i>zp&&i--}return{lodPlanes:e,sizeLods:n,sigmas:r}}function w7(t,e,n){const r=new Vf(t,e,n);return r.texture.mapping=GN,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function f1(t,e,n,r,i){t.viewport.set(e,n,r,i),t.scissor.set(e,n,r,i)}function SUe(t,e,n){const r=new Float32Array(Kh),i=new We(0,1,0);return new Qd({name:"SphericalGaussianBlur",defines:{n:Kh,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:HO(),fragmentShader:`
  7333. precision mediump float;
  7334. precision mediump int;
  7335. varying vec3 vOutputDirection;
  7336. uniform sampler2D envMap;
  7337. uniform int samples;
  7338. uniform float weights[ n ];
  7339. uniform bool latitudinal;
  7340. uniform float dTheta;
  7341. uniform float mipInt;
  7342. uniform vec3 poleAxis;
  7343. #define ENVMAP_TYPE_CUBE_UV
  7344. #include <cube_uv_reflection_fragment>
  7345. vec3 getSample( float theta, vec3 axis ) {
  7346. float cosTheta = cos( theta );
  7347. // Rodrigues' axis-angle rotation
  7348. vec3 sampleDirection = vOutputDirection * cosTheta
  7349. + cross( axis, vOutputDirection ) * sin( theta )
  7350. + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
  7351. return bilinearCubeUV( envMap, sampleDirection, mipInt );
  7352. }
  7353. void main() {
  7354. vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
  7355. if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
  7356. axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
  7357. }
  7358. axis = normalize( axis );
  7359. gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
  7360. gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
  7361. for ( int i = 1; i < n; i++ ) {
  7362. if ( i >= samples ) {
  7363. break;
  7364. }
  7365. float theta = dTheta * float( i );
  7366. gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
  7367. gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
  7368. }
  7369. }
  7370. `,blending:Dd,depthTest:!1,depthWrite:!1})}function S7(){return new Qd({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:HO(),fragmentShader:`
  7371. precision mediump float;
  7372. precision mediump int;
  7373. varying vec3 vOutputDirection;
  7374. uniform sampler2D envMap;
  7375. #include <common>
  7376. void main() {
  7377. vec3 outputDirection = normalize( vOutputDirection );
  7378. vec2 uv = equirectUv( outputDirection );
  7379. gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
  7380. }
  7381. `,blending:Dd,depthTest:!1,depthWrite:!1})}function N7(){return new Qd({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:HO(),fragmentShader:`
  7382. precision mediump float;
  7383. precision mediump int;
  7384. uniform float flipEnvMap;
  7385. varying vec3 vOutputDirection;
  7386. uniform samplerCube envMap;
  7387. void main() {
  7388. gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
  7389. }
  7390. `,blending:Dd,depthTest:!1,depthWrite:!1})}function HO(){return`
  7391. precision mediump float;
  7392. precision mediump int;
  7393. attribute float faceIndex;
  7394. varying vec3 vOutputDirection;
  7395. // RH coordinate system; PMREM face-indexing convention
  7396. vec3 getDirection( vec2 uv, float face ) {
  7397. uv = 2.0 * uv - 1.0;
  7398. vec3 direction = vec3( uv, 1.0 );
  7399. if ( face == 0.0 ) {
  7400. direction = direction.zyx; // ( 1, v, u ) pos x
  7401. } else if ( face == 1.0 ) {
  7402. direction = direction.xzy;
  7403. direction.xz *= -1.0; // ( -u, 1, -v ) pos y
  7404. } else if ( face == 2.0 ) {
  7405. direction.x *= -1.0; // ( -u, v, 1 ) pos z
  7406. } else if ( face == 3.0 ) {
  7407. direction = direction.zyx;
  7408. direction.xz *= -1.0; // ( -1, v, -u ) neg x
  7409. } else if ( face == 4.0 ) {
  7410. direction = direction.xzy;
  7411. direction.xy *= -1.0; // ( -u, -1, v ) neg y
  7412. } else if ( face == 5.0 ) {
  7413. direction.z *= -1.0; // ( u, v, -1 ) neg z
  7414. }
  7415. return direction;
  7416. }
  7417. void main() {
  7418. vOutputDirection = getDirection( uv, faceIndex );
  7419. gl_Position = vec4( position, 1.0 );
  7420. }
  7421. `}function NUe(t){let e=new WeakMap,n=null;function r(l){if(l&&l.isTexture){const c=l.mapping,u=c===YP||c===QP,d=c===_g||c===wg;if(u||d)if(l.isRenderTargetTexture&&l.needsPMREMUpdate===!0){l.needsPMREMUpdate=!1;let f=e.get(l);return n===null&&(n=new _7(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 _7(t));const m=u?n.fromEquirectangular(l):n.fromCubemap(l);return e.set(l,m),l.addEventListener("dispose",a),m.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 MUe(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 EUe(t,e,n,r){const i={},a=new WeakMap;function o(f){const m=f.target;m.index!==null&&e.remove(m.index);for(const x in m.attributes)e.remove(m.attributes[x]);for(const x in m.morphAttributes){const y=m.morphAttributes[x];for(let b=0,v=y.length;b<v;b++)e.remove(y[b])}m.removeEventListener("dispose",o),delete i[m.id];const p=a.get(m);p&&(e.remove(p),a.delete(m)),r.releaseStatesOfGeometry(m),m.isInstancedBufferGeometry===!0&&delete m._maxInstanceCount,n.memory.geometries--}function l(f,m){return i[m.id]===!0||(m.addEventListener("dispose",o),i[m.id]=!0,n.memory.geometries++),m}function c(f){const m=f.attributes;for(const x in m)e.update(m[x],t.ARRAY_BUFFER);const p=f.morphAttributes;for(const x in p){const y=p[x];for(let b=0,v=y.length;b<v;b++)e.update(y[b],t.ARRAY_BUFFER)}}function u(f){const m=[],p=f.index,x=f.attributes.position;let y=0;if(p!==null){const N=p.array;y=p.version;for(let S=0,T=N.length;S<T;S+=3){const E=N[S+0],C=N[S+1],A=N[S+2];m.push(E,C,C,A,A,E)}}else if(x!==void 0){const N=x.array;y=x.version;for(let S=0,T=N.length/3-1;S<T;S+=3){const E=S+0,C=S+1,A=S+2;m.push(E,C,C,A,A,E)}}else return;const b=new(DJ(m)?$J:BJ)(m,1);b.version=y;const v=a.get(f);v&&e.remove(v),a.set(f,b)}function d(f){const m=a.get(f);if(m){const p=f.index;p!==null&&m.version<p.version&&u(f)}else u(f);return a.get(f)}return{get:l,update:c,getWireframeAttribute:d}}function TUe(t,e,n,r){const i=r.isWebGL2;let a;function o(p){a=p}let l,c;function u(p){l=p.type,c=p.bytesPerElement}function d(p,x){t.drawElements(a,x,l,p*c),n.update(x,a,1)}function f(p,x,y){if(y===0)return;let b,v;if(i)b=t,v="drawElementsInstanced";else if(b=e.get("ANGLE_instanced_arrays"),v="drawElementsInstancedANGLE",b===null){console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}b[v](a,x,l,p*c,y),n.update(x,a,y)}function m(p,x,y){if(y===0)return;const b=e.get("WEBGL_multi_draw");if(b===null)for(let v=0;v<y;v++)this.render(p[v]/c,x[v]);else{b.multiDrawElementsWEBGL(a,x,0,l,p,0,y);let v=0;for(let N=0;N<y;N++)v+=x[N];n.update(v,a,1)}}this.setMode=o,this.setIndex=u,this.render=d,this.renderInstances=f,this.renderMultiDraw=m}function AUe(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 CUe(t,e){return t[0]-e[0]}function kUe(t,e){return Math.abs(e[1])-Math.abs(t[1])}function jUe(t,e,n){const r={},i=new Float32Array(8),a=new WeakMap,o=new gr,l=[];for(let u=0;u<8;u++)l[u]=[u,0];function c(u,d,f){const m=u.morphTargetInfluences;if(e.isWebGL2===!0){const x=d.morphAttributes.position||d.morphAttributes.normal||d.morphAttributes.color,y=x!==void 0?x.length:0;let b=a.get(d);if(b===void 0||b.count!==y){let W=function(){K.dispose(),a.delete(d),d.removeEventListener("dispose",W)};var p=W;b!==void 0&&b.texture.dispose();const S=d.morphAttributes.position!==void 0,T=d.morphAttributes.normal!==void 0,E=d.morphAttributes.color!==void 0,C=d.morphAttributes.position||[],A=d.morphAttributes.normal||[],O=d.morphAttributes.color||[];let k=0;S===!0&&(k=1),T===!0&&(k=2),E===!0&&(k=3);let R=d.attributes.position.count*k,F=1;R>e.maxTextureSize&&(F=Math.ceil(R/e.maxTextureSize),R=e.maxTextureSize);const L=new Float32Array(R*F*4*y),K=new IJ(L,R,F,y);K.type=Kc,K.needsUpdate=!0;const j=k*4;for(let Y=0;Y<y;Y++){const q=C[Y],Q=A[Y],ee=O[Y],re=R*F*4*Y;for(let z=0;z<q.count;z++){const G=z*j;S===!0&&(o.fromBufferAttribute(q,z),L[re+G+0]=o.x,L[re+G+1]=o.y,L[re+G+2]=o.z,L[re+G+3]=0),T===!0&&(o.fromBufferAttribute(Q,z),L[re+G+4]=o.x,L[re+G+5]=o.y,L[re+G+6]=o.z,L[re+G+7]=0),E===!0&&(o.fromBufferAttribute(ee,z),L[re+G+8]=o.x,L[re+G+9]=o.y,L[re+G+10]=o.z,L[re+G+11]=ee.itemSize===4?o.w:1)}}b={count:y,texture:K,size:new pn(R,F)},a.set(d,b),d.addEventListener("dispose",W)}let v=0;for(let S=0;S<m.length;S++)v+=m[S];const N=d.morphTargetsRelative?1:1-v;f.getUniforms().setValue(t,"morphTargetBaseInfluence",N),f.getUniforms().setValue(t,"morphTargetInfluences",m),f.getUniforms().setValue(t,"morphTargetsTexture",b.texture,n),f.getUniforms().setValue(t,"morphTargetsTextureSize",b.size)}else{const x=m===void 0?0:m.length;let y=r[d.id];if(y===void 0||y.length!==x){y=[];for(let T=0;T<x;T++)y[T]=[T,0];r[d.id]=y}for(let T=0;T<x;T++){const E=y[T];E[0]=T,E[1]=m[T]}y.sort(kUe);for(let T=0;T<8;T++)T<x&&y[T][1]?(l[T][0]=y[T][0],l[T][1]=y[T][1]):(l[T][0]=Number.MAX_SAFE_INTEGER,l[T][1]=0);l.sort(CUe);const b=d.morphAttributes.position,v=d.morphAttributes.normal;let N=0;for(let T=0;T<8;T++){const E=l[T],C=E[0],A=E[1];C!==Number.MAX_SAFE_INTEGER&&A?(b&&d.getAttribute("morphTarget"+T)!==b[C]&&d.setAttribute("morphTarget"+T,b[C]),v&&d.getAttribute("morphNormal"+T)!==v[C]&&d.setAttribute("morphNormal"+T,v[C]),i[T]=A,N+=A):(b&&d.hasAttribute("morphTarget"+T)===!0&&d.deleteAttribute("morphTarget"+T),v&&d.hasAttribute("morphNormal"+T)===!0&&d.deleteAttribute("morphNormal"+T),i[T]=0)}const S=d.morphTargetsRelative?1:1-N;f.getUniforms().setValue(t,"morphTargetBaseInfluence",S),f.getUniforms().setValue(t,"morphTargetInfluences",i)}}return{update:c}}function PUe(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 m=c.skeleton;i.get(m)!==u&&(m.update(),i.set(m,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 qJ extends vs{constructor(e,n,r,i,a,o,l,c,u,d){if(d=d!==void 0?d:xf,d!==xf&&d!==Sg)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");r===void 0&&d===xf&&(r=Sd),r===void 0&&d===Sg&&(r=gf),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:ga,this.minFilter=c!==void 0?c:ga,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 KJ=new vs,XJ=new qJ(1,1);XJ.compareFunction=PJ;const YJ=new IJ,QJ=new gIe,ZJ=new GJ,M7=[],E7=[],T7=new Float32Array(16),A7=new Float32Array(9),C7=new Float32Array(4);function nx(t,e,n){const r=t[0];if(r<=0||r>0)return t;const i=e*n;let a=M7[i];if(a===void 0&&(a=new Float32Array(i),M7[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 Oi(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 Li(t,e){for(let n=0,r=e.length;n<r;n++)t[n]=e[n]}function KN(t,e){let n=E7[e];n===void 0&&(n=new Int32Array(e),E7[e]=n);for(let r=0;r!==e;++r)n[r]=t.allocateTextureUnit();return n}function RUe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function DUe(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(Oi(n,e))return;t.uniform2fv(this.addr,e),Li(n,e)}}function OUe(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(Oi(n,e))return;t.uniform3fv(this.addr,e),Li(n,e)}}function LUe(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(Oi(n,e))return;t.uniform4fv(this.addr,e),Li(n,e)}}function IUe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Oi(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),Li(n,e)}else{if(Oi(n,r))return;C7.set(r),t.uniformMatrix2fv(this.addr,!1,C7),Li(n,r)}}function FUe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Oi(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),Li(n,e)}else{if(Oi(n,r))return;A7.set(r),t.uniformMatrix3fv(this.addr,!1,A7),Li(n,r)}}function UUe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Oi(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),Li(n,e)}else{if(Oi(n,r))return;T7.set(r),t.uniformMatrix4fv(this.addr,!1,T7),Li(n,r)}}function zUe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function BUe(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(Oi(n,e))return;t.uniform2iv(this.addr,e),Li(n,e)}}function $Ue(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(Oi(n,e))return;t.uniform3iv(this.addr,e),Li(n,e)}}function HUe(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(Oi(n,e))return;t.uniform4iv(this.addr,e),Li(n,e)}}function VUe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function GUe(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(Oi(n,e))return;t.uniform2uiv(this.addr,e),Li(n,e)}}function WUe(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(Oi(n,e))return;t.uniform3uiv(this.addr,e),Li(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.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(Oi(n,e))return;t.uniform4uiv(this.addr,e),Li(n,e)}}function KUe(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?XJ:KJ;n.setTexture2D(e||a,i)}function XUe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(e||QJ,i)}function YUe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTextureCube(e||ZJ,i)}function QUe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(e||YJ,i)}function ZUe(t){switch(t){case 5126:return RUe;case 35664:return DUe;case 35665:return OUe;case 35666:return LUe;case 35674:return IUe;case 35675:return FUe;case 35676:return UUe;case 5124:case 35670:return zUe;case 35667:case 35671:return BUe;case 35668:case 35672:return $Ue;case 35669:case 35673:return HUe;case 5125:return VUe;case 36294:return GUe;case 36295:return WUe;case 36296:return qUe;case 35678:case 36198:case 36298:case 36306:case 35682:return KUe;case 35679:case 36299:case 36307:return XUe;case 35680:case 36300:case 36308:case 36293:return YUe;case 36289:case 36303:case 36311:case 36292:return QUe}}function JUe(t,e){t.uniform1fv(this.addr,e)}function eze(t,e){const n=nx(e,this.size,2);t.uniform2fv(this.addr,n)}function tze(t,e){const n=nx(e,this.size,3);t.uniform3fv(this.addr,n)}function nze(t,e){const n=nx(e,this.size,4);t.uniform4fv(this.addr,n)}function rze(t,e){const n=nx(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function ize(t,e){const n=nx(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function aze(t,e){const n=nx(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function sze(t,e){t.uniform1iv(this.addr,e)}function oze(t,e){t.uniform2iv(this.addr,e)}function lze(t,e){t.uniform3iv(this.addr,e)}function cze(t,e){t.uniform4iv(this.addr,e)}function uze(t,e){t.uniform1uiv(this.addr,e)}function dze(t,e){t.uniform2uiv(this.addr,e)}function hze(t,e){t.uniform3uiv(this.addr,e)}function fze(t,e){t.uniform4uiv(this.addr,e)}function mze(t,e,n){const r=this.cache,i=e.length,a=KN(n,i);Oi(r,a)||(t.uniform1iv(this.addr,a),Li(r,a));for(let o=0;o!==i;++o)n.setTexture2D(e[o]||KJ,a[o])}function pze(t,e,n){const r=this.cache,i=e.length,a=KN(n,i);Oi(r,a)||(t.uniform1iv(this.addr,a),Li(r,a));for(let o=0;o!==i;++o)n.setTexture3D(e[o]||QJ,a[o])}function gze(t,e,n){const r=this.cache,i=e.length,a=KN(n,i);Oi(r,a)||(t.uniform1iv(this.addr,a),Li(r,a));for(let o=0;o!==i;++o)n.setTextureCube(e[o]||ZJ,a[o])}function xze(t,e,n){const r=this.cache,i=e.length,a=KN(n,i);Oi(r,a)||(t.uniform1iv(this.addr,a),Li(r,a));for(let o=0;o!==i;++o)n.setTexture2DArray(e[o]||YJ,a[o])}function bze(t){switch(t){case 5126:return JUe;case 35664:return eze;case 35665:return tze;case 35666:return nze;case 35674:return rze;case 35675:return ize;case 35676:return aze;case 5124:case 35670:return sze;case 35667:case 35671:return oze;case 35668:case 35672:return lze;case 35669:case 35673:return cze;case 5125:return uze;case 36294:return dze;case 36295:return hze;case 36296:return fze;case 35678:case 36198:case 36298:case 36306:case 35682:return mze;case 35679:case 36299:case 36307:return pze;case 35680:case 36300:case 36308:case 36293:return gze;case 36289:case 36303:case 36311:case 36292:return xze}}class yze{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.setValue=ZUe(n.type)}}class vze{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.size=n.size,this.setValue=bze(n.type)}}class _ze{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 kk=/(\w+)(\])?(\[|\.)?/g;function k7(t,e){t.seq.push(e),t.map[e.id]=e}function wze(t,e,n){const r=t.name,i=r.length;for(kk.lastIndex=0;;){const a=kk.exec(r),o=kk.lastIndex;let l=a[1];const c=a[2]==="]",u=a[3];if(c&&(l=l|0),u===void 0||u==="["&&o+2===i){k7(n,u===void 0?new yze(l,t,e):new vze(l,t,e));break}else{let f=n.map[l];f===void 0&&(f=new _ze(l),k7(n,f)),n=f}}}class rw{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);wze(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 j7(t,e,n){const r=t.createShader(e);return t.shaderSource(r,n),t.compileShader(r),r}const Sze=37297;let Nze=0;function Mze(t,e){const n=t.split(`
  7422. `),r=[],i=Math.max(e-6,0),a=Math.min(e+6,n.length);for(let o=i;o<a;o++){const l=o+1;r.push(`${l===e?">":" "} ${l}: ${n[o]}`)}return r.join(`
  7423. `)}function Eze(t){const e=mr.getPrimaries(mr.workingColorSpace),n=mr.getPrimaries(t);let r;switch(e===n?r="":e===AS&&n===TS?r="LinearDisplayP3ToLinearSRGB":e===TS&&n===AS&&(r="LinearSRGBToLinearDisplayP3"),t){case pu:case WN:return[r,"LinearTransferOETF"];case xa:case FO:return[r,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",t),[r,"LinearTransferOETF"]}}function P7(t,e,n){const r=t.getShaderParameter(e,t.COMPILE_STATUS),i=t.getShaderInfoLog(e).trim();if(r&&i==="")return"";const a=/ERROR: 0:(\d+)/.exec(i);if(a){const o=parseInt(a[1]);return n.toUpperCase()+`
  7424. `+i+`
  7425. `+Mze(t.getShaderSource(e),o)}else return i}function Tze(t,e){const n=Eze(e);return`vec4 ${t}( vec4 value ) { return ${n[0]}( ${n[1]}( value ) ); }`}function Aze(t,e){let n;switch(e){case TLe:n="Linear";break;case ALe:n="Reinhard";break;case CLe:n="OptimizedCineon";break;case kLe:n="ACESFilmic";break;case jLe:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}function Cze(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(kb).join(`
  7426. `)}function kze(t){const e=[];for(const n in t){const r=t[n];r!==!1&&e.push("#define "+n+" "+r)}return e.join(`
  7427. `)}function jze(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 kb(t){return t!==""}function R7(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 D7(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const Pze=/^[ \t]*#include +<([\w\d./]+)>/gm;function rR(t){return t.replace(Pze,Dze)}const Rze=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function Dze(t,e){let n=Nn[e];if(n===void 0){const r=Rze.get(e);if(r!==void 0)n=Nn[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 rR(n)}const Oze=/#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 O7(t){return t.replace(Oze,Lze)}function Lze(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 L7(t){let e="precision "+t.precision+` float;
  7428. precision `+t.precision+" int;";return t.precision==="highp"?e+=`
  7429. #define HIGH_PRECISION`:t.precision==="mediump"?e+=`
  7430. #define MEDIUM_PRECISION`:t.precision==="lowp"&&(e+=`
  7431. #define LOW_PRECISION`),e}function Ize(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===_J?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===tLe?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===Oc&&(e="SHADOWMAP_TYPE_VSM"),e}function Fze(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case _g:case wg:e="ENVMAP_TYPE_CUBE";break;case GN:e="ENVMAP_TYPE_CUBE_UV";break}return e}function Uze(t){let e="ENVMAP_MODE_REFLECTION";if(t.envMap)switch(t.envMapMode){case wg:e="ENVMAP_MODE_REFRACTION";break}return e}function zze(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case LO:e="ENVMAP_BLENDING_MULTIPLY";break;case MLe:e="ENVMAP_BLENDING_MIX";break;case ELe:e="ENVMAP_BLENDING_ADD";break}return e}function Bze(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 $ze(t,e,n,r){const i=t.getContext(),a=n.defines;let o=n.vertexShader,l=n.fragmentShader;const c=Ize(n),u=Fze(n),d=Uze(n),f=zze(n),m=Bze(n),p=n.isWebGL2?"":Cze(n),x=kze(a),y=i.createProgram();let b,v,N=n.glslVersion?"#version "+n.glslVersion+`
  7432. `:"";n.isRawShaderMaterial?(b=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(kb).join(`
  7433. `),b.length>0&&(b+=`
  7434. `),v=[p,"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(kb).join(`
  7435. `),v.length>0&&(v+=`
  7436. `)):(b=[L7(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x,n.batching?"#define USE_BATCHING":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+d:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&n.flatShading===!1?"#define USE_MORPHNORMALS":"",n.morphColors&&n.isWebGL2?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.useLegacyLights?"#define LEGACY_LIGHTS":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )"," attribute vec3 morphTarget0;"," attribute vec3 morphTarget1;"," attribute vec3 morphTarget2;"," attribute vec3 morphTarget3;"," #ifdef USE_MORPHNORMALS"," attribute vec3 morphNormal0;"," attribute vec3 morphNormal1;"," attribute vec3 morphNormal2;"," attribute vec3 morphNormal3;"," #else"," attribute vec3 morphTarget4;"," attribute vec3 morphTarget5;"," attribute vec3 morphTarget6;"," attribute vec3 morphTarget7;"," #endif","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
  7437. `].filter(kb).join(`
  7438. `),v=[p,L7(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:"",m?"#define CUBEUV_TEXEL_WIDTH "+m.texelWidth:"",m?"#define CUBEUV_TEXEL_HEIGHT "+m.texelHeight:"",m?"#define CUBEUV_MAX_MIP "+m.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!==Od?"#define TONE_MAPPING":"",n.toneMapping!==Od?Nn.tonemapping_pars_fragment:"",n.toneMapping!==Od?Aze("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",Nn.colorspace_pars_fragment,Tze("linearToOutputTexel",n.outputColorSpace),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
  7439. `].filter(kb).join(`
  7440. `)),o=rR(o),o=R7(o,n),o=D7(o,n),l=rR(l),l=R7(l,n),l=D7(l,n),o=O7(o),l=O7(l),n.isWebGL2&&n.isRawShaderMaterial!==!0&&(N=`#version 300 es
  7441. `,b=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join(`
  7442. `)+`
  7443. `+b,v=["precision mediump sampler2DArray;","#define varying in",n.glslVersion===e7?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===e7?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`
  7444. `)+`
  7445. `+v);const S=N+b+o,T=N+v+l,E=j7(i,i.VERTEX_SHADER,S),C=j7(i,i.FRAGMENT_SHADER,T);i.attachShader(y,E),i.attachShader(y,C),n.index0AttributeName!==void 0?i.bindAttribLocation(y,0,n.index0AttributeName):n.morphTargets===!0&&i.bindAttribLocation(y,0,"position"),i.linkProgram(y);function A(F){if(t.debug.checkShaderErrors){const L=i.getProgramInfoLog(y).trim(),K=i.getShaderInfoLog(E).trim(),j=i.getShaderInfoLog(C).trim();let W=!0,Y=!0;if(i.getProgramParameter(y,i.LINK_STATUS)===!1)if(W=!1,typeof t.debug.onShaderError=="function")t.debug.onShaderError(i,y,E,C);else{const q=P7(i,E,"vertex"),Q=P7(i,C,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(y,i.VALIDATE_STATUS)+`
  7446. Program Info Log: `+L+`
  7447. `+q+`
  7448. `+Q)}else L!==""?console.warn("THREE.WebGLProgram: Program Info Log:",L):(K===""||j==="")&&(Y=!1);Y&&(F.diagnostics={runnable:W,programLog:L,vertexShader:{log:K,prefix:b},fragmentShader:{log:j,prefix:v}})}i.deleteShader(E),i.deleteShader(C),O=new rw(i,y),k=jze(i,y)}let O;this.getUniforms=function(){return O===void 0&&A(this),O};let k;this.getAttributes=function(){return k===void 0&&A(this),k};let R=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return R===!1&&(R=i.getProgramParameter(y,Sze)),R},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(y),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=Nze++,this.cacheKey=e,this.usedTimes=1,this.program=y,this.vertexShader=E,this.fragmentShader=C,this}let Hze=0;class Vze{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 Gze(e),n.set(e,r)),r}}class Gze{constructor(e){this.id=Hze++,this.code=e,this.usedTimes=0}}function Wze(t,e,n,r,i,a,o){const l=new FJ,c=new Vze,u=[],d=i.isWebGL2,f=i.logarithmicDepthBuffer,m=i.vertexTextures;let p=i.precision;const x={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function y(k){return k===0?"uv":`uv${k}`}function b(k,R,F,L,K){const j=L.fog,W=K.geometry,Y=k.isMeshStandardMaterial?L.environment:null,q=(k.isMeshStandardMaterial?n:e).get(k.envMap||Y),Q=q&&q.mapping===GN?q.image.height:null,ee=x[k.type];k.precision!==null&&(p=i.getMaxPrecision(k.precision),p!==k.precision&&console.warn("THREE.WebGLProgram.getParameters:",k.precision,"not supported, using",p,"instead."));const re=W.morphAttributes.position||W.morphAttributes.normal||W.morphAttributes.color,z=re!==void 0?re.length:0;let G=0;W.morphAttributes.position!==void 0&&(G=1),W.morphAttributes.normal!==void 0&&(G=2),W.morphAttributes.color!==void 0&&(G=3);let ae,se,ue,pe;if(ee){const cn=ms[ee];ae=cn.vertexShader,se=cn.fragmentShader}else ae=k.vertexShader,se=k.fragmentShader,c.update(k),ue=c.getVertexShaderID(k),pe=c.getFragmentShaderID(k);const ce=t.getRenderTarget(),Me=K.isInstancedMesh===!0,me=K.isBatchedMesh===!0,Ee=!!k.map,fe=!!k.matcap,le=!!q,Be=!!k.aoMap,V=!!k.lightMap,$=!!k.bumpMap,X=!!k.normalMap,U=!!k.displacementMap,B=!!k.emissiveMap,oe=!!k.metalnessMap,Te=!!k.roughnessMap,je=k.anisotropy>0,Ce=k.clearcoat>0,H=k.iridescence>0,D=k.sheen>0,Z=k.transmission>0,xe=je&&!!k.anisotropyMap,Ne=Ce&&!!k.clearcoatMap,ve=Ce&&!!k.clearcoatNormalMap,$e=Ce&&!!k.clearcoatRoughnessMap,Le=H&&!!k.iridescenceMap,qe=H&&!!k.iridescenceThicknessMap,Ke=D&&!!k.sheenColorMap,Ye=D&&!!k.sheenRoughnessMap,ie=!!k.specularMap,te=!!k.specularColorMap,Se=!!k.specularIntensityMap,ze=Z&&!!k.transmissionMap,nt=Z&&!!k.thicknessMap,ne=!!k.gradientMap,Pe=!!k.alphaMap,be=k.alphaTest>0,Oe=!!k.alphaHash,Ue=!!k.extensions,Ae=!!W.attributes.uv1,Je=!!W.attributes.uv2,gt=!!W.attributes.uv3;let Pt=Od;return k.toneMapped&&(ce===null||ce.isXRRenderTarget===!0)&&(Pt=t.toneMapping),{isWebGL2:d,shaderID:ee,shaderType:k.type,shaderName:k.name,vertexShader:ae,fragmentShader:se,defines:k.defines,customVertexShaderID:ue,customFragmentShaderID:pe,isRawShaderMaterial:k.isRawShaderMaterial===!0,glslVersion:k.glslVersion,precision:p,batching:me,instancing:Me,instancingColor:Me&&K.instanceColor!==null,supportsVertexTextures:m,outputColorSpace:ce===null?t.outputColorSpace:ce.isXRRenderTarget===!0?ce.texture.colorSpace:pu,map:Ee,matcap:fe,envMap:le,envMapMode:le&&q.mapping,envMapCubeUVHeight:Q,aoMap:Be,lightMap:V,bumpMap:$,normalMap:X,displacementMap:m&&U,emissiveMap:B,normalMapObjectSpace:X&&k.normalMapType===HLe,normalMapTangentSpace:X&&k.normalMapType===jJ,metalnessMap:oe,roughnessMap:Te,anisotropy:je,anisotropyMap:xe,clearcoat:Ce,clearcoatMap:Ne,clearcoatNormalMap:ve,clearcoatRoughnessMap:$e,iridescence:H,iridescenceMap:Le,iridescenceThicknessMap:qe,sheen:D,sheenColorMap:Ke,sheenRoughnessMap:Ye,specularMap:ie,specularColorMap:te,specularIntensityMap:Se,transmission:Z,transmissionMap:ze,thicknessMap:nt,gradientMap:ne,opaque:k.transparent===!1&&k.blending===Qp,alphaMap:Pe,alphaTest:be,alphaHash:Oe,combine:k.combine,mapUv:Ee&&y(k.map.channel),aoMapUv:Be&&y(k.aoMap.channel),lightMapUv:V&&y(k.lightMap.channel),bumpMapUv:$&&y(k.bumpMap.channel),normalMapUv:X&&y(k.normalMap.channel),displacementMapUv:U&&y(k.displacementMap.channel),emissiveMapUv:B&&y(k.emissiveMap.channel),metalnessMapUv:oe&&y(k.metalnessMap.channel),roughnessMapUv:Te&&y(k.roughnessMap.channel),anisotropyMapUv:xe&&y(k.anisotropyMap.channel),clearcoatMapUv:Ne&&y(k.clearcoatMap.channel),clearcoatNormalMapUv:ve&&y(k.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:$e&&y(k.clearcoatRoughnessMap.channel),iridescenceMapUv:Le&&y(k.iridescenceMap.channel),iridescenceThicknessMapUv:qe&&y(k.iridescenceThicknessMap.channel),sheenColorMapUv:Ke&&y(k.sheenColorMap.channel),sheenRoughnessMapUv:Ye&&y(k.sheenRoughnessMap.channel),specularMapUv:ie&&y(k.specularMap.channel),specularColorMapUv:te&&y(k.specularColorMap.channel),specularIntensityMapUv:Se&&y(k.specularIntensityMap.channel),transmissionMapUv:ze&&y(k.transmissionMap.channel),thicknessMapUv:nt&&y(k.thicknessMap.channel),alphaMapUv:Pe&&y(k.alphaMap.channel),vertexTangents:!!W.attributes.tangent&&(X||je),vertexColors:k.vertexColors,vertexAlphas:k.vertexColors===!0&&!!W.attributes.color&&W.attributes.color.itemSize===4,vertexUv1s:Ae,vertexUv2s:Je,vertexUv3s:gt,pointsUvs:K.isPoints===!0&&!!W.attributes.uv&&(Ee||Pe),fog:!!j,useFog:k.fog===!0,fogExp2:j&&j.isFogExp2,flatShading:k.flatShading===!0,sizeAttenuation:k.sizeAttenuation===!0,logarithmicDepthBuffer:f,skinning:K.isSkinnedMesh===!0,morphTargets:W.morphAttributes.position!==void 0,morphNormals:W.morphAttributes.normal!==void 0,morphColors:W.morphAttributes.color!==void 0,morphTargetsCount:z,morphTextureStride:G,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:k.dithering,shadowMapEnabled:t.shadowMap.enabled&&F.length>0,shadowMapType:t.shadowMap.type,toneMapping:Pt,useLegacyLights:t._useLegacyLights,decodeVideoTexture:Ee&&k.map.isVideoTexture===!0&&mr.getTransfer(k.map.colorSpace)===Cr,premultipliedAlpha:k.premultipliedAlpha,doubleSided:k.side===$c,flipSided:k.side===ys,useDepthPacking:k.depthPacking>=0,depthPacking:k.depthPacking||0,index0AttributeName:k.index0AttributeName,extensionDerivatives:Ue&&k.extensions.derivatives===!0,extensionFragDepth:Ue&&k.extensions.fragDepth===!0,extensionDrawBuffers:Ue&&k.extensions.drawBuffers===!0,extensionShaderTextureLOD:Ue&&k.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:k.customProgramCacheKey()}}function v(k){const R=[];if(k.shaderID?R.push(k.shaderID):(R.push(k.customVertexShaderID),R.push(k.customFragmentShaderID)),k.defines!==void 0)for(const F in k.defines)R.push(F),R.push(k.defines[F]);return k.isRawShaderMaterial===!1&&(N(R,k),S(R,k),R.push(t.outputColorSpace)),R.push(k.customProgramCacheKey),R.join()}function N(k,R){k.push(R.precision),k.push(R.outputColorSpace),k.push(R.envMapMode),k.push(R.envMapCubeUVHeight),k.push(R.mapUv),k.push(R.alphaMapUv),k.push(R.lightMapUv),k.push(R.aoMapUv),k.push(R.bumpMapUv),k.push(R.normalMapUv),k.push(R.displacementMapUv),k.push(R.emissiveMapUv),k.push(R.metalnessMapUv),k.push(R.roughnessMapUv),k.push(R.anisotropyMapUv),k.push(R.clearcoatMapUv),k.push(R.clearcoatNormalMapUv),k.push(R.clearcoatRoughnessMapUv),k.push(R.iridescenceMapUv),k.push(R.iridescenceThicknessMapUv),k.push(R.sheenColorMapUv),k.push(R.sheenRoughnessMapUv),k.push(R.specularMapUv),k.push(R.specularColorMapUv),k.push(R.specularIntensityMapUv),k.push(R.transmissionMapUv),k.push(R.thicknessMapUv),k.push(R.combine),k.push(R.fogExp2),k.push(R.sizeAttenuation),k.push(R.morphTargetsCount),k.push(R.morphAttributeCount),k.push(R.numDirLights),k.push(R.numPointLights),k.push(R.numSpotLights),k.push(R.numSpotLightMaps),k.push(R.numHemiLights),k.push(R.numRectAreaLights),k.push(R.numDirLightShadows),k.push(R.numPointLightShadows),k.push(R.numSpotLightShadows),k.push(R.numSpotLightShadowsWithMaps),k.push(R.numLightProbes),k.push(R.shadowMapType),k.push(R.toneMapping),k.push(R.numClippingPlanes),k.push(R.numClipIntersection),k.push(R.depthPacking)}function S(k,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),k.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),k.push(l.mask)}function T(k){const R=x[k.type];let F;if(R){const L=ms[R];F=BO.clone(L.uniforms)}else F=k.uniforms;return F}function E(k,R){let F;for(let L=0,K=u.length;L<K;L++){const j=u[L];if(j.cacheKey===R){F=j,++F.usedTimes;break}}return F===void 0&&(F=new $ze(t,R,k,a),u.push(F)),F}function C(k){if(--k.usedTimes===0){const R=u.indexOf(k);u[R]=u[u.length-1],u.pop(),k.destroy()}}function A(k){c.remove(k)}function O(){c.dispose()}return{getParameters:b,getProgramCacheKey:v,getUniforms:T,acquireProgram:E,releaseProgram:C,releaseShaderCache:A,programs:u,dispose:O}}function qze(){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 Kze(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 I7(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 F7(){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,m,p,x,y,b){let v=t[e];return v===void 0?(v={id:f.id,object:f,geometry:m,material:p,groupOrder:x,renderOrder:f.renderOrder,z:y,group:b},t[e]=v):(v.id=f.id,v.object=f,v.geometry=m,v.material=p,v.groupOrder=x,v.renderOrder=f.renderOrder,v.z=y,v.group=b),e++,v}function l(f,m,p,x,y,b){const v=o(f,m,p,x,y,b);p.transmission>0?r.push(v):p.transparent===!0?i.push(v):n.push(v)}function c(f,m,p,x,y,b){const v=o(f,m,p,x,y,b);p.transmission>0?r.unshift(v):p.transparent===!0?i.unshift(v):n.unshift(v)}function u(f,m){n.length>1&&n.sort(f||Kze),r.length>1&&r.sort(m||I7),i.length>1&&i.sort(m||I7)}function d(){for(let f=e,m=t.length;f<m;f++){const p=t[f];if(p.id===null)break;p.id=null,p.object=null,p.geometry=null,p.material=null,p.group=null}}return{opaque:n,transmissive:r,transparent:i,init:a,push:l,unshift:c,finish:d,sort:u}}function Xze(){let t=new WeakMap;function e(r,i){const a=t.get(r);let o;return a===void 0?(o=new F7,t.set(r,[o])):i>=a.length?(o=new F7,a.push(o)):o=a[i],o}function n(){t=new WeakMap}return{get:e,dispose:n}}function Yze(){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 We,color:new nn};break;case"SpotLight":n={position:new We,direction:new We,color:new nn,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new We,color:new nn,distance:0,decay:0};break;case"HemisphereLight":n={direction:new We,skyColor:new nn,groundColor:new nn};break;case"RectAreaLight":n={color:new nn,position:new We,halfWidth:new We,halfHeight:new We};break}return t[e.id]=n,n}}}function Qze(){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 pn};break;case"SpotLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new pn};break;case"PointLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new pn,shadowCameraNear:1,shadowCameraFar:1e3};break}return t[e.id]=n,n}}}let Zze=0;function Jze(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function eBe(t,e){const n=new Yze,r=Qze(),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 We);const a=new We,o=new Er,l=new Er;function c(d,f){let m=0,p=0,x=0;for(let L=0;L<9;L++)i.probe[L].set(0,0,0);let y=0,b=0,v=0,N=0,S=0,T=0,E=0,C=0,A=0,O=0,k=0;d.sort(Jze);const R=f===!0?Math.PI:1;for(let L=0,K=d.length;L<K;L++){const j=d[L],W=j.color,Y=j.intensity,q=j.distance,Q=j.shadow&&j.shadow.map?j.shadow.map.texture:null;if(j.isAmbientLight)m+=W.r*Y*R,p+=W.g*Y*R,x+=W.b*Y*R;else if(j.isLightProbe){for(let ee=0;ee<9;ee++)i.probe[ee].addScaledVector(j.sh.coefficients[ee],Y);k++}else if(j.isDirectionalLight){const ee=n.get(j);if(ee.color.copy(j.color).multiplyScalar(j.intensity*R),j.castShadow){const re=j.shadow,z=r.get(j);z.shadowBias=re.bias,z.shadowNormalBias=re.normalBias,z.shadowRadius=re.radius,z.shadowMapSize=re.mapSize,i.directionalShadow[y]=z,i.directionalShadowMap[y]=Q,i.directionalShadowMatrix[y]=j.shadow.matrix,T++}i.directional[y]=ee,y++}else if(j.isSpotLight){const ee=n.get(j);ee.position.setFromMatrixPosition(j.matrixWorld),ee.color.copy(W).multiplyScalar(Y*R),ee.distance=q,ee.coneCos=Math.cos(j.angle),ee.penumbraCos=Math.cos(j.angle*(1-j.penumbra)),ee.decay=j.decay,i.spot[v]=ee;const re=j.shadow;if(j.map&&(i.spotLightMap[A]=j.map,A++,re.updateMatrices(j),j.castShadow&&O++),i.spotLightMatrix[v]=re.matrix,j.castShadow){const z=r.get(j);z.shadowBias=re.bias,z.shadowNormalBias=re.normalBias,z.shadowRadius=re.radius,z.shadowMapSize=re.mapSize,i.spotShadow[v]=z,i.spotShadowMap[v]=Q,C++}v++}else if(j.isRectAreaLight){const ee=n.get(j);ee.color.copy(W).multiplyScalar(Y),ee.halfWidth.set(j.width*.5,0,0),ee.halfHeight.set(0,j.height*.5,0),i.rectArea[N]=ee,N++}else if(j.isPointLight){const ee=n.get(j);if(ee.color.copy(j.color).multiplyScalar(j.intensity*R),ee.distance=j.distance,ee.decay=j.decay,j.castShadow){const re=j.shadow,z=r.get(j);z.shadowBias=re.bias,z.shadowNormalBias=re.normalBias,z.shadowRadius=re.radius,z.shadowMapSize=re.mapSize,z.shadowCameraNear=re.camera.near,z.shadowCameraFar=re.camera.far,i.pointShadow[b]=z,i.pointShadowMap[b]=Q,i.pointShadowMatrix[b]=j.shadow.matrix,E++}i.point[b]=ee,b++}else if(j.isHemisphereLight){const ee=n.get(j);ee.skyColor.copy(j.color).multiplyScalar(Y*R),ee.groundColor.copy(j.groundColor).multiplyScalar(Y*R),i.hemi[S]=ee,S++}}N>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]=m,i.ambient[1]=p,i.ambient[2]=x;const F=i.hash;(F.directionalLength!==y||F.pointLength!==b||F.spotLength!==v||F.rectAreaLength!==N||F.hemiLength!==S||F.numDirectionalShadows!==T||F.numPointShadows!==E||F.numSpotShadows!==C||F.numSpotMaps!==A||F.numLightProbes!==k)&&(i.directional.length=y,i.spot.length=v,i.rectArea.length=N,i.point.length=b,i.hemi.length=S,i.directionalShadow.length=T,i.directionalShadowMap.length=T,i.pointShadow.length=E,i.pointShadowMap.length=E,i.spotShadow.length=C,i.spotShadowMap.length=C,i.directionalShadowMatrix.length=T,i.pointShadowMatrix.length=E,i.spotLightMatrix.length=C+A-O,i.spotLightMap.length=A,i.numSpotLightShadowsWithMaps=O,i.numLightProbes=k,F.directionalLength=y,F.pointLength=b,F.spotLength=v,F.rectAreaLength=N,F.hemiLength=S,F.numDirectionalShadows=T,F.numPointShadows=E,F.numSpotShadows=C,F.numSpotMaps=A,F.numLightProbes=k,i.version=Zze++)}function u(d,f){let m=0,p=0,x=0,y=0,b=0;const v=f.matrixWorldInverse;for(let N=0,S=d.length;N<S;N++){const T=d[N];if(T.isDirectionalLight){const E=i.directional[m];E.direction.setFromMatrixPosition(T.matrixWorld),a.setFromMatrixPosition(T.target.matrixWorld),E.direction.sub(a),E.direction.transformDirection(v),m++}else if(T.isSpotLight){const E=i.spot[x];E.position.setFromMatrixPosition(T.matrixWorld),E.position.applyMatrix4(v),E.direction.setFromMatrixPosition(T.matrixWorld),a.setFromMatrixPosition(T.target.matrixWorld),E.direction.sub(a),E.direction.transformDirection(v),x++}else if(T.isRectAreaLight){const E=i.rectArea[y];E.position.setFromMatrixPosition(T.matrixWorld),E.position.applyMatrix4(v),l.identity(),o.copy(T.matrixWorld),o.premultiply(v),l.extractRotation(o),E.halfWidth.set(T.width*.5,0,0),E.halfHeight.set(0,T.height*.5,0),E.halfWidth.applyMatrix4(l),E.halfHeight.applyMatrix4(l),y++}else if(T.isPointLight){const E=i.point[p];E.position.setFromMatrixPosition(T.matrixWorld),E.position.applyMatrix4(v),p++}else if(T.isHemisphereLight){const E=i.hemi[b];E.direction.setFromMatrixPosition(T.matrixWorld),E.direction.transformDirection(v),b++}}}return{setup:c,setupView:u,state:i}}function U7(t,e){const n=new eBe(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 tBe(t,e){let n=new WeakMap;function r(a,o=0){const l=n.get(a);let c;return l===void 0?(c=new U7(t,e),n.set(a,[c])):o>=l.length?(c=new U7(t,e),l.push(c)):c=l[o],c}function i(){n=new WeakMap}return{get:r,dispose:i}}class nBe extends tx{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=BLe,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 rBe extends tx{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 iBe=`void main() {
  7449. gl_Position = vec4( position, 1.0 );
  7450. }`,aBe=`uniform sampler2D shadow_pass;
  7451. uniform vec2 resolution;
  7452. uniform float radius;
  7453. #include <packing>
  7454. void main() {
  7455. const float samples = float( VSM_SAMPLES );
  7456. float mean = 0.0;
  7457. float squared_mean = 0.0;
  7458. float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
  7459. float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
  7460. for ( float i = 0.0; i < samples; i ++ ) {
  7461. float uvOffset = uvStart + i * uvStride;
  7462. #ifdef HORIZONTAL_PASS
  7463. vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
  7464. mean += distribution.x;
  7465. squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
  7466. #else
  7467. float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
  7468. mean += depth;
  7469. squared_mean += depth * depth;
  7470. #endif
  7471. }
  7472. mean = mean / samples;
  7473. squared_mean = squared_mean / samples;
  7474. float std_dev = sqrt( squared_mean - mean * mean );
  7475. gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
  7476. }`;function sBe(t,e,n){let r=new qN;const i=new pn,a=new pn,o=new gr,l=new nBe({depthPacking:$Le}),c=new rBe,u={},d=n.maxTextureSize,f={[Yd]:ys,[ys]:Yd,[$c]:$c},m=new Qd({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new pn},radius:{value:4}},vertexShader:iBe,fragmentShader:aBe}),p=m.clone();p.defines.HORIZONTAL_PASS=1;const x=new Ia;x.setAttribute("position",new qs(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const y=new rl(x,m),b=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=_J;let v=this.type;this.render=function(E,C,A){if(b.enabled===!1||b.autoUpdate===!1&&b.needsUpdate===!1||E.length===0)return;const O=t.getRenderTarget(),k=t.getActiveCubeFace(),R=t.getActiveMipmapLevel(),F=t.state;F.setBlending(Dd),F.buffers.color.setClear(1,1,1,1),F.buffers.depth.setTest(!0),F.setScissorTest(!1);const L=v!==Oc&&this.type===Oc,K=v===Oc&&this.type!==Oc;for(let j=0,W=E.length;j<W;j++){const Y=E[j],q=Y.shadow;if(q===void 0){console.warn("THREE.WebGLShadowMap:",Y,"has no shadow.");continue}if(q.autoUpdate===!1&&q.needsUpdate===!1)continue;i.copy(q.mapSize);const Q=q.getFrameExtents();if(i.multiply(Q),a.copy(q.mapSize),(i.x>d||i.y>d)&&(i.x>d&&(a.x=Math.floor(d/Q.x),i.x=a.x*Q.x,q.mapSize.x=a.x),i.y>d&&(a.y=Math.floor(d/Q.y),i.y=a.y*Q.y,q.mapSize.y=a.y)),q.map===null||L===!0||K===!0){const re=this.type!==Oc?{minFilter:ga,magFilter:ga}:{};q.map!==null&&q.map.dispose(),q.map=new Vf(i.x,i.y,re),q.map.texture.name=Y.name+".shadowMap",q.camera.updateProjectionMatrix()}t.setRenderTarget(q.map),t.clear();const ee=q.getViewportCount();for(let re=0;re<ee;re++){const z=q.getViewport(re);o.set(a.x*z.x,a.y*z.y,a.x*z.z,a.y*z.w),F.viewport(o),q.updateMatrices(Y,re),r=q.getFrustum(),T(C,A,q.camera,Y,this.type)}q.isPointLightShadow!==!0&&this.type===Oc&&N(q,A),q.needsUpdate=!1}v=this.type,b.needsUpdate=!1,t.setRenderTarget(O,k,R)};function N(E,C){const A=e.update(y);m.defines.VSM_SAMPLES!==E.blurSamples&&(m.defines.VSM_SAMPLES=E.blurSamples,p.defines.VSM_SAMPLES=E.blurSamples,m.needsUpdate=!0,p.needsUpdate=!0),E.mapPass===null&&(E.mapPass=new Vf(i.x,i.y)),m.uniforms.shadow_pass.value=E.map.texture,m.uniforms.resolution.value=E.mapSize,m.uniforms.radius.value=E.radius,t.setRenderTarget(E.mapPass),t.clear(),t.renderBufferDirect(C,null,A,m,y,null),p.uniforms.shadow_pass.value=E.mapPass.texture,p.uniforms.resolution.value=E.mapSize,p.uniforms.radius.value=E.radius,t.setRenderTarget(E.map),t.clear(),t.renderBufferDirect(C,null,A,p,y,null)}function S(E,C,A,O){let k=null;const R=A.isPointLight===!0?E.customDistanceMaterial:E.customDepthMaterial;if(R!==void 0)k=R;else if(k=A.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 F=k.uuid,L=C.uuid;let K=u[F];K===void 0&&(K={},u[F]=K);let j=K[L];j===void 0&&(j=k.clone(),K[L]=j),k=j}if(k.visible=C.visible,k.wireframe=C.wireframe,O===Oc?k.side=C.shadowSide!==null?C.shadowSide:C.side:k.side=C.shadowSide!==null?C.shadowSide:f[C.side],k.alphaMap=C.alphaMap,k.alphaTest=C.alphaTest,k.map=C.map,k.clipShadows=C.clipShadows,k.clippingPlanes=C.clippingPlanes,k.clipIntersection=C.clipIntersection,k.displacementMap=C.displacementMap,k.displacementScale=C.displacementScale,k.displacementBias=C.displacementBias,k.wireframeLinewidth=C.wireframeLinewidth,k.linewidth=C.linewidth,A.isPointLight===!0&&k.isMeshDistanceMaterial===!0){const F=t.properties.get(k);F.light=A}return k}function T(E,C,A,O,k){if(E.visible===!1)return;if(E.layers.test(C.layers)&&(E.isMesh||E.isLine||E.isPoints)&&(E.castShadow||E.receiveShadow&&k===Oc)&&(!E.frustumCulled||r.intersectsObject(E))){E.modelViewMatrix.multiplyMatrices(A.matrixWorldInverse,E.matrixWorld);const L=e.update(E),K=E.material;if(Array.isArray(K)){const j=L.groups;for(let W=0,Y=j.length;W<Y;W++){const q=j[W],Q=K[q.materialIndex];if(Q&&Q.visible){const ee=S(E,Q,O,k);E.onBeforeShadow(t,E,C,A,L,ee,q),t.renderBufferDirect(A,null,L,ee,E,q),E.onAfterShadow(t,E,C,A,L,ee,q)}}}else if(K.visible){const j=S(E,K,O,k);E.onBeforeShadow(t,E,C,A,L,j,null),t.renderBufferDirect(A,null,L,j,E,null),E.onAfterShadow(t,E,C,A,L,j,null)}}const F=E.children;for(let L=0,K=F.length;L<K;L++)T(F[L],C,A,O,k)}}function oBe(t,e,n){const r=n.isWebGL2;function i(){let be=!1;const Oe=new gr;let Ue=null;const Ae=new gr(0,0,0,0);return{setMask:function(Je){Ue!==Je&&!be&&(t.colorMask(Je,Je,Je,Je),Ue=Je)},setLocked:function(Je){be=Je},setClear:function(Je,gt,Pt,Ot,cn){cn===!0&&(Je*=Ot,gt*=Ot,Pt*=Ot),Oe.set(Je,gt,Pt,Ot),Ae.equals(Oe)===!1&&(t.clearColor(Je,gt,Pt,Ot),Ae.copy(Oe))},reset:function(){be=!1,Ue=null,Ae.set(-1,0,0,0)}}}function a(){let be=!1,Oe=null,Ue=null,Ae=null;return{setTest:function(Je){Je?me(t.DEPTH_TEST):Ee(t.DEPTH_TEST)},setMask:function(Je){Oe!==Je&&!be&&(t.depthMask(Je),Oe=Je)},setFunc:function(Je){if(Ue!==Je){switch(Je){case bLe:t.depthFunc(t.NEVER);break;case yLe:t.depthFunc(t.ALWAYS);break;case vLe:t.depthFunc(t.LESS);break;case MS:t.depthFunc(t.LEQUAL);break;case _Le:t.depthFunc(t.EQUAL);break;case wLe:t.depthFunc(t.GEQUAL);break;case SLe:t.depthFunc(t.GREATER);break;case NLe:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}Ue=Je}},setLocked:function(Je){be=Je},setClear:function(Je){Ae!==Je&&(t.clearDepth(Je),Ae=Je)},reset:function(){be=!1,Oe=null,Ue=null,Ae=null}}}function o(){let be=!1,Oe=null,Ue=null,Ae=null,Je=null,gt=null,Pt=null,Ot=null,cn=null;return{setTest:function(It){be||(It?me(t.STENCIL_TEST):Ee(t.STENCIL_TEST))},setMask:function(It){Oe!==It&&!be&&(t.stencilMask(It),Oe=It)},setFunc:function(It,_n,bt){(Ue!==It||Ae!==_n||Je!==bt)&&(t.stencilFunc(It,_n,bt),Ue=It,Ae=_n,Je=bt)},setOp:function(It,_n,bt){(gt!==It||Pt!==_n||Ot!==bt)&&(t.stencilOp(It,_n,bt),gt=It,Pt=_n,Ot=bt)},setLocked:function(It){be=It},setClear:function(It){cn!==It&&(t.clearStencil(It),cn=It)},reset:function(){be=!1,Oe=null,Ue=null,Ae=null,Je=null,gt=null,Pt=null,Ot=null,cn=null}}}const l=new i,c=new a,u=new o,d=new WeakMap,f=new WeakMap;let m={},p={},x=new WeakMap,y=[],b=null,v=!1,N=null,S=null,T=null,E=null,C=null,A=null,O=null,k=new nn(0,0,0),R=0,F=!1,L=null,K=null,j=null,W=null,Y=null;const q=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let Q=!1,ee=0;const re=t.getParameter(t.VERSION);re.indexOf("WebGL")!==-1?(ee=parseFloat(/^WebGL (\d)/.exec(re)[1]),Q=ee>=1):re.indexOf("OpenGL ES")!==-1&&(ee=parseFloat(/^OpenGL ES (\d)/.exec(re)[1]),Q=ee>=2);let z=null,G={};const ae=t.getParameter(t.SCISSOR_BOX),se=t.getParameter(t.VIEWPORT),ue=new gr().fromArray(ae),pe=new gr().fromArray(se);function ce(be,Oe,Ue,Ae){const Je=new Uint8Array(4),gt=t.createTexture();t.bindTexture(be,gt),t.texParameteri(be,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(be,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let Pt=0;Pt<Ue;Pt++)r&&(be===t.TEXTURE_3D||be===t.TEXTURE_2D_ARRAY)?t.texImage3D(Oe,0,t.RGBA,1,1,Ae,0,t.RGBA,t.UNSIGNED_BYTE,Je):t.texImage2D(Oe+Pt,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,Je);return gt}const Me={};Me[t.TEXTURE_2D]=ce(t.TEXTURE_2D,t.TEXTURE_2D,1),Me[t.TEXTURE_CUBE_MAP]=ce(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),r&&(Me[t.TEXTURE_2D_ARRAY]=ce(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),Me[t.TEXTURE_3D]=ce(t.TEXTURE_3D,t.TEXTURE_3D,1,1)),l.setClear(0,0,0,1),c.setClear(1),u.setClear(0),me(t.DEPTH_TEST),c.setFunc(MS),B(!1),oe(_V),me(t.CULL_FACE),X(Dd);function me(be){m[be]!==!0&&(t.enable(be),m[be]=!0)}function Ee(be){m[be]!==!1&&(t.disable(be),m[be]=!1)}function fe(be,Oe){return p[be]!==Oe?(t.bindFramebuffer(be,Oe),p[be]=Oe,r&&(be===t.DRAW_FRAMEBUFFER&&(p[t.FRAMEBUFFER]=Oe),be===t.FRAMEBUFFER&&(p[t.DRAW_FRAMEBUFFER]=Oe)),!0):!1}function le(be,Oe){let Ue=y,Ae=!1;if(be)if(Ue=x.get(Oe),Ue===void 0&&(Ue=[],x.set(Oe,Ue)),be.isWebGLMultipleRenderTargets){const Je=be.texture;if(Ue.length!==Je.length||Ue[0]!==t.COLOR_ATTACHMENT0){for(let gt=0,Pt=Je.length;gt<Pt;gt++)Ue[gt]=t.COLOR_ATTACHMENT0+gt;Ue.length=Je.length,Ae=!0}}else Ue[0]!==t.COLOR_ATTACHMENT0&&(Ue[0]=t.COLOR_ATTACHMENT0,Ae=!0);else Ue[0]!==t.BACK&&(Ue[0]=t.BACK,Ae=!0);Ae&&(n.isWebGL2?t.drawBuffers(Ue):e.get("WEBGL_draw_buffers").drawBuffersWEBGL(Ue))}function Be(be){return b!==be?(t.useProgram(be),b=be,!0):!1}const V={[qh]:t.FUNC_ADD,[rLe]:t.FUNC_SUBTRACT,[iLe]:t.FUNC_REVERSE_SUBTRACT};if(r)V[MV]=t.MIN,V[EV]=t.MAX;else{const be=e.get("EXT_blend_minmax");be!==null&&(V[MV]=be.MIN_EXT,V[EV]=be.MAX_EXT)}const $={[aLe]:t.ZERO,[sLe]:t.ONE,[oLe]:t.SRC_COLOR,[KP]:t.SRC_ALPHA,[fLe]:t.SRC_ALPHA_SATURATE,[dLe]:t.DST_COLOR,[cLe]:t.DST_ALPHA,[lLe]:t.ONE_MINUS_SRC_COLOR,[XP]:t.ONE_MINUS_SRC_ALPHA,[hLe]:t.ONE_MINUS_DST_COLOR,[uLe]:t.ONE_MINUS_DST_ALPHA,[mLe]:t.CONSTANT_COLOR,[pLe]:t.ONE_MINUS_CONSTANT_COLOR,[gLe]:t.CONSTANT_ALPHA,[xLe]:t.ONE_MINUS_CONSTANT_ALPHA};function X(be,Oe,Ue,Ae,Je,gt,Pt,Ot,cn,It){if(be===Dd){v===!0&&(Ee(t.BLEND),v=!1);return}if(v===!1&&(me(t.BLEND),v=!0),be!==nLe){if(be!==N||It!==F){if((S!==qh||C!==qh)&&(t.blendEquation(t.FUNC_ADD),S=qh,C=qh),It)switch(be){case Qp:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case wV:t.blendFunc(t.ONE,t.ONE);break;case SV:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case NV:t.blendFuncSeparate(t.ZERO,t.SRC_COLOR,t.ZERO,t.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",be);break}else switch(be){case Qp:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case wV:t.blendFunc(t.SRC_ALPHA,t.ONE);break;case SV:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case NV:t.blendFunc(t.ZERO,t.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",be);break}T=null,E=null,A=null,O=null,k.set(0,0,0),R=0,N=be,F=It}return}Je=Je||Oe,gt=gt||Ue,Pt=Pt||Ae,(Oe!==S||Je!==C)&&(t.blendEquationSeparate(V[Oe],V[Je]),S=Oe,C=Je),(Ue!==T||Ae!==E||gt!==A||Pt!==O)&&(t.blendFuncSeparate($[Ue],$[Ae],$[gt],$[Pt]),T=Ue,E=Ae,A=gt,O=Pt),(Ot.equals(k)===!1||cn!==R)&&(t.blendColor(Ot.r,Ot.g,Ot.b,cn),k.copy(Ot),R=cn),N=be,F=!1}function U(be,Oe){be.side===$c?Ee(t.CULL_FACE):me(t.CULL_FACE);let Ue=be.side===ys;Oe&&(Ue=!Ue),B(Ue),be.blending===Qp&&be.transparent===!1?X(Dd):X(be.blending,be.blendEquation,be.blendSrc,be.blendDst,be.blendEquationAlpha,be.blendSrcAlpha,be.blendDstAlpha,be.blendColor,be.blendAlpha,be.premultipliedAlpha),c.setFunc(be.depthFunc),c.setTest(be.depthTest),c.setMask(be.depthWrite),l.setMask(be.colorWrite);const Ae=be.stencilWrite;u.setTest(Ae),Ae&&(u.setMask(be.stencilWriteMask),u.setFunc(be.stencilFunc,be.stencilRef,be.stencilFuncMask),u.setOp(be.stencilFail,be.stencilZFail,be.stencilZPass)),je(be.polygonOffset,be.polygonOffsetFactor,be.polygonOffsetUnits),be.alphaToCoverage===!0?me(t.SAMPLE_ALPHA_TO_COVERAGE):Ee(t.SAMPLE_ALPHA_TO_COVERAGE)}function B(be){L!==be&&(be?t.frontFace(t.CW):t.frontFace(t.CCW),L=be)}function oe(be){be!==JOe?(me(t.CULL_FACE),be!==K&&(be===_V?t.cullFace(t.BACK):be===eLe?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):Ee(t.CULL_FACE),K=be}function Te(be){be!==j&&(Q&&t.lineWidth(be),j=be)}function je(be,Oe,Ue){be?(me(t.POLYGON_OFFSET_FILL),(W!==Oe||Y!==Ue)&&(t.polygonOffset(Oe,Ue),W=Oe,Y=Ue)):Ee(t.POLYGON_OFFSET_FILL)}function Ce(be){be?me(t.SCISSOR_TEST):Ee(t.SCISSOR_TEST)}function H(be){be===void 0&&(be=t.TEXTURE0+q-1),z!==be&&(t.activeTexture(be),z=be)}function D(be,Oe,Ue){Ue===void 0&&(z===null?Ue=t.TEXTURE0+q-1:Ue=z);let Ae=G[Ue];Ae===void 0&&(Ae={type:void 0,texture:void 0},G[Ue]=Ae),(Ae.type!==be||Ae.texture!==Oe)&&(z!==Ue&&(t.activeTexture(Ue),z=Ue),t.bindTexture(be,Oe||Me[be]),Ae.type=be,Ae.texture=Oe)}function Z(){const be=G[z];be!==void 0&&be.type!==void 0&&(t.bindTexture(be.type,null),be.type=void 0,be.texture=void 0)}function xe(){try{t.compressedTexImage2D.apply(t,arguments)}catch(be){console.error("THREE.WebGLState:",be)}}function Ne(){try{t.compressedTexImage3D.apply(t,arguments)}catch(be){console.error("THREE.WebGLState:",be)}}function ve(){try{t.texSubImage2D.apply(t,arguments)}catch(be){console.error("THREE.WebGLState:",be)}}function $e(){try{t.texSubImage3D.apply(t,arguments)}catch(be){console.error("THREE.WebGLState:",be)}}function Le(){try{t.compressedTexSubImage2D.apply(t,arguments)}catch(be){console.error("THREE.WebGLState:",be)}}function qe(){try{t.compressedTexSubImage3D.apply(t,arguments)}catch(be){console.error("THREE.WebGLState:",be)}}function Ke(){try{t.texStorage2D.apply(t,arguments)}catch(be){console.error("THREE.WebGLState:",be)}}function Ye(){try{t.texStorage3D.apply(t,arguments)}catch(be){console.error("THREE.WebGLState:",be)}}function ie(){try{t.texImage2D.apply(t,arguments)}catch(be){console.error("THREE.WebGLState:",be)}}function te(){try{t.texImage3D.apply(t,arguments)}catch(be){console.error("THREE.WebGLState:",be)}}function Se(be){ue.equals(be)===!1&&(t.scissor(be.x,be.y,be.z,be.w),ue.copy(be))}function ze(be){pe.equals(be)===!1&&(t.viewport(be.x,be.y,be.z,be.w),pe.copy(be))}function nt(be,Oe){let Ue=f.get(Oe);Ue===void 0&&(Ue=new WeakMap,f.set(Oe,Ue));let Ae=Ue.get(be);Ae===void 0&&(Ae=t.getUniformBlockIndex(Oe,be.name),Ue.set(be,Ae))}function ne(be,Oe){const Ae=f.get(Oe).get(be);d.get(Oe)!==Ae&&(t.uniformBlockBinding(Oe,Ae,be.__bindingPointIndex),d.set(Oe,Ae))}function Pe(){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),m={},z=null,G={},p={},x=new WeakMap,y=[],b=null,v=!1,N=null,S=null,T=null,E=null,C=null,A=null,O=null,k=new nn(0,0,0),R=0,F=!1,L=null,K=null,j=null,W=null,Y=null,ue.set(0,0,t.canvas.width,t.canvas.height),pe.set(0,0,t.canvas.width,t.canvas.height),l.reset(),c.reset(),u.reset()}return{buffers:{color:l,depth:c,stencil:u},enable:me,disable:Ee,bindFramebuffer:fe,drawBuffers:le,useProgram:Be,setBlending:X,setMaterial:U,setFlipSided:B,setCullFace:oe,setLineWidth:Te,setPolygonOffset:je,setScissorTest:Ce,activeTexture:H,bindTexture:D,unbindTexture:Z,compressedTexImage2D:xe,compressedTexImage3D:Ne,texImage2D:ie,texImage3D:te,updateUBOMapping:nt,uniformBlockBinding:ne,texStorage2D:Ke,texStorage3D:Ye,texSubImage2D:ve,texSubImage3D:$e,compressedTexSubImage2D:Le,compressedTexSubImage3D:qe,scissor:Se,viewport:ze,reset:Pe}}function lBe(t,e,n,r,i,a,o){const l=i.isWebGL2,c=i.maxTextures,u=i.maxCubemapSize,d=i.maxTextureSize,f=i.maxSamples,m=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,p=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),x=new WeakMap;let y;const b=new WeakMap;let v=!1;try{v=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function N(H,D){return v?new OffscreenCanvas(H,D):kS("canvas")}function S(H,D,Z,xe){let Ne=1;if((H.width>xe||H.height>xe)&&(Ne=xe/Math.max(H.width,H.height)),Ne<1||D===!0)if(typeof HTMLImageElement<"u"&&H instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&H instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&H instanceof ImageBitmap){const ve=D?CS:Math.floor,$e=ve(Ne*H.width),Le=ve(Ne*H.height);y===void 0&&(y=N($e,Le));const qe=Z?N($e,Le):y;return qe.width=$e,qe.height=Le,qe.getContext("2d").drawImage(H,0,0,$e,Le),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+H.width+"x"+H.height+") to ("+$e+"x"+Le+")."),qe}else return"data"in H&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+H.width+"x"+H.height+")."),H;return H}function T(H){return nR(H.width)&&nR(H.height)}function E(H){return l?!1:H.wrapS!==el||H.wrapT!==el||H.minFilter!==ga&&H.minFilter!==wo}function C(H,D){return H.generateMipmaps&&D&&H.minFilter!==ga&&H.minFilter!==wo}function A(H){t.generateMipmap(H)}function O(H,D,Z,xe,Ne=!1){if(l===!1)return D;if(H!==null){if(t[H]!==void 0)return t[H];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+H+"'")}let ve=D;if(D===t.RED&&(Z===t.FLOAT&&(ve=t.R32F),Z===t.HALF_FLOAT&&(ve=t.R16F),Z===t.UNSIGNED_BYTE&&(ve=t.R8)),D===t.RED_INTEGER&&(Z===t.UNSIGNED_BYTE&&(ve=t.R8UI),Z===t.UNSIGNED_SHORT&&(ve=t.R16UI),Z===t.UNSIGNED_INT&&(ve=t.R32UI),Z===t.BYTE&&(ve=t.R8I),Z===t.SHORT&&(ve=t.R16I),Z===t.INT&&(ve=t.R32I)),D===t.RG&&(Z===t.FLOAT&&(ve=t.RG32F),Z===t.HALF_FLOAT&&(ve=t.RG16F),Z===t.UNSIGNED_BYTE&&(ve=t.RG8)),D===t.RGBA){const $e=Ne?ES:mr.getTransfer(xe);Z===t.FLOAT&&(ve=t.RGBA32F),Z===t.HALF_FLOAT&&(ve=t.RGBA16F),Z===t.UNSIGNED_BYTE&&(ve=$e===Cr?t.SRGB8_ALPHA8:t.RGBA8),Z===t.UNSIGNED_SHORT_4_4_4_4&&(ve=t.RGBA4),Z===t.UNSIGNED_SHORT_5_5_5_1&&(ve=t.RGB5_A1)}return(ve===t.R16F||ve===t.R32F||ve===t.RG16F||ve===t.RG32F||ve===t.RGBA16F||ve===t.RGBA32F)&&e.get("EXT_color_buffer_float"),ve}function k(H,D,Z){return C(H,Z)===!0||H.isFramebufferTexture&&H.minFilter!==ga&&H.minFilter!==wo?Math.log2(Math.max(D.width,D.height))+1:H.mipmaps!==void 0&&H.mipmaps.length>0?H.mipmaps.length:H.isCompressedTexture&&Array.isArray(H.image)?D.mipmaps.length:1}function R(H){return H===ga||H===TV||H===rk?t.NEAREST:t.LINEAR}function F(H){const D=H.target;D.removeEventListener("dispose",F),K(D),D.isVideoTexture&&x.delete(D)}function L(H){const D=H.target;D.removeEventListener("dispose",L),W(D)}function K(H){const D=r.get(H);if(D.__webglInit===void 0)return;const Z=H.source,xe=b.get(Z);if(xe){const Ne=xe[D.__cacheKey];Ne.usedTimes--,Ne.usedTimes===0&&j(H),Object.keys(xe).length===0&&b.delete(Z)}r.remove(H)}function j(H){const D=r.get(H);t.deleteTexture(D.__webglTexture);const Z=H.source,xe=b.get(Z);delete xe[D.__cacheKey],o.memory.textures--}function W(H){const D=H.texture,Z=r.get(H),xe=r.get(D);if(xe.__webglTexture!==void 0&&(t.deleteTexture(xe.__webglTexture),o.memory.textures--),H.depthTexture&&H.depthTexture.dispose(),H.isWebGLCubeRenderTarget)for(let Ne=0;Ne<6;Ne++){if(Array.isArray(Z.__webglFramebuffer[Ne]))for(let ve=0;ve<Z.__webglFramebuffer[Ne].length;ve++)t.deleteFramebuffer(Z.__webglFramebuffer[Ne][ve]);else t.deleteFramebuffer(Z.__webglFramebuffer[Ne]);Z.__webglDepthbuffer&&t.deleteRenderbuffer(Z.__webglDepthbuffer[Ne])}else{if(Array.isArray(Z.__webglFramebuffer))for(let Ne=0;Ne<Z.__webglFramebuffer.length;Ne++)t.deleteFramebuffer(Z.__webglFramebuffer[Ne]);else t.deleteFramebuffer(Z.__webglFramebuffer);if(Z.__webglDepthbuffer&&t.deleteRenderbuffer(Z.__webglDepthbuffer),Z.__webglMultisampledFramebuffer&&t.deleteFramebuffer(Z.__webglMultisampledFramebuffer),Z.__webglColorRenderbuffer)for(let Ne=0;Ne<Z.__webglColorRenderbuffer.length;Ne++)Z.__webglColorRenderbuffer[Ne]&&t.deleteRenderbuffer(Z.__webglColorRenderbuffer[Ne]);Z.__webglDepthRenderbuffer&&t.deleteRenderbuffer(Z.__webglDepthRenderbuffer)}if(H.isWebGLMultipleRenderTargets)for(let Ne=0,ve=D.length;Ne<ve;Ne++){const $e=r.get(D[Ne]);$e.__webglTexture&&(t.deleteTexture($e.__webglTexture),o.memory.textures--),r.remove(D[Ne])}r.remove(D),r.remove(H)}let Y=0;function q(){Y=0}function Q(){const H=Y;return H>=c&&console.warn("THREE.WebGLTextures: Trying to use "+H+" texture units while this GPU supports only "+c),Y+=1,H}function ee(H){const D=[];return D.push(H.wrapS),D.push(H.wrapT),D.push(H.wrapR||0),D.push(H.magFilter),D.push(H.minFilter),D.push(H.anisotropy),D.push(H.internalFormat),D.push(H.format),D.push(H.type),D.push(H.generateMipmaps),D.push(H.premultiplyAlpha),D.push(H.flipY),D.push(H.unpackAlignment),D.push(H.colorSpace),D.join()}function re(H,D){const Z=r.get(H);if(H.isVideoTexture&&je(H),H.isRenderTargetTexture===!1&&H.version>0&&Z.__version!==H.version){const xe=H.image;if(xe===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(xe.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{me(Z,H,D);return}}n.bindTexture(t.TEXTURE_2D,Z.__webglTexture,t.TEXTURE0+D)}function z(H,D){const Z=r.get(H);if(H.version>0&&Z.__version!==H.version){me(Z,H,D);return}n.bindTexture(t.TEXTURE_2D_ARRAY,Z.__webglTexture,t.TEXTURE0+D)}function G(H,D){const Z=r.get(H);if(H.version>0&&Z.__version!==H.version){me(Z,H,D);return}n.bindTexture(t.TEXTURE_3D,Z.__webglTexture,t.TEXTURE0+D)}function ae(H,D){const Z=r.get(H);if(H.version>0&&Z.__version!==H.version){Ee(Z,H,D);return}n.bindTexture(t.TEXTURE_CUBE_MAP,Z.__webglTexture,t.TEXTURE0+D)}const se={[ZP]:t.REPEAT,[el]:t.CLAMP_TO_EDGE,[JP]:t.MIRRORED_REPEAT},ue={[ga]:t.NEAREST,[TV]:t.NEAREST_MIPMAP_NEAREST,[rk]:t.NEAREST_MIPMAP_LINEAR,[wo]:t.LINEAR,[PLe]:t.LINEAR_MIPMAP_NEAREST,[F0]:t.LINEAR_MIPMAP_LINEAR},pe={[VLe]:t.NEVER,[YLe]:t.ALWAYS,[GLe]:t.LESS,[PJ]:t.LEQUAL,[WLe]:t.EQUAL,[XLe]:t.GEQUAL,[qLe]:t.GREATER,[KLe]:t.NOTEQUAL};function ce(H,D,Z){if(Z?(t.texParameteri(H,t.TEXTURE_WRAP_S,se[D.wrapS]),t.texParameteri(H,t.TEXTURE_WRAP_T,se[D.wrapT]),(H===t.TEXTURE_3D||H===t.TEXTURE_2D_ARRAY)&&t.texParameteri(H,t.TEXTURE_WRAP_R,se[D.wrapR]),t.texParameteri(H,t.TEXTURE_MAG_FILTER,ue[D.magFilter]),t.texParameteri(H,t.TEXTURE_MIN_FILTER,ue[D.minFilter])):(t.texParameteri(H,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(H,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),(H===t.TEXTURE_3D||H===t.TEXTURE_2D_ARRAY)&&t.texParameteri(H,t.TEXTURE_WRAP_R,t.CLAMP_TO_EDGE),(D.wrapS!==el||D.wrapT!==el)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),t.texParameteri(H,t.TEXTURE_MAG_FILTER,R(D.magFilter)),t.texParameteri(H,t.TEXTURE_MIN_FILTER,R(D.minFilter)),D.minFilter!==ga&&D.minFilter!==wo&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),D.compareFunction&&(t.texParameteri(H,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(H,t.TEXTURE_COMPARE_FUNC,pe[D.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){const xe=e.get("EXT_texture_filter_anisotropic");if(D.magFilter===ga||D.minFilter!==rk&&D.minFilter!==F0||D.type===Kc&&e.has("OES_texture_float_linear")===!1||l===!1&&D.type===U0&&e.has("OES_texture_half_float_linear")===!1)return;(D.anisotropy>1||r.get(D).__currentAnisotropy)&&(t.texParameterf(H,xe.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(D.anisotropy,i.getMaxAnisotropy())),r.get(D).__currentAnisotropy=D.anisotropy)}}function Me(H,D){let Z=!1;H.__webglInit===void 0&&(H.__webglInit=!0,D.addEventListener("dispose",F));const xe=D.source;let Ne=b.get(xe);Ne===void 0&&(Ne={},b.set(xe,Ne));const ve=ee(D);if(ve!==H.__cacheKey){Ne[ve]===void 0&&(Ne[ve]={texture:t.createTexture(),usedTimes:0},o.memory.textures++,Z=!0),Ne[ve].usedTimes++;const $e=Ne[H.__cacheKey];$e!==void 0&&(Ne[H.__cacheKey].usedTimes--,$e.usedTimes===0&&j(D)),H.__cacheKey=ve,H.__webglTexture=Ne[ve].texture}return Z}function me(H,D,Z){let xe=t.TEXTURE_2D;(D.isDataArrayTexture||D.isCompressedArrayTexture)&&(xe=t.TEXTURE_2D_ARRAY),D.isData3DTexture&&(xe=t.TEXTURE_3D);const Ne=Me(H,D),ve=D.source;n.bindTexture(xe,H.__webglTexture,t.TEXTURE0+Z);const $e=r.get(ve);if(ve.version!==$e.__version||Ne===!0){n.activeTexture(t.TEXTURE0+Z);const Le=mr.getPrimaries(mr.workingColorSpace),qe=D.colorSpace===No?null:mr.getPrimaries(D.colorSpace),Ke=D.colorSpace===No||Le===qe?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,D.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,D.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,D.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ke);const Ye=E(D)&&T(D.image)===!1;let ie=S(D.image,Ye,!1,d);ie=Ce(D,ie);const te=T(ie)||l,Se=a.convert(D.format,D.colorSpace);let ze=a.convert(D.type),nt=O(D.internalFormat,Se,ze,D.colorSpace,D.isVideoTexture);ce(xe,D,te);let ne;const Pe=D.mipmaps,be=l&&D.isVideoTexture!==!0&&nt!==CJ,Oe=$e.__version===void 0||Ne===!0,Ue=k(D,ie,te);if(D.isDepthTexture)nt=t.DEPTH_COMPONENT,l?D.type===Kc?nt=t.DEPTH_COMPONENT32F:D.type===Sd?nt=t.DEPTH_COMPONENT24:D.type===gf?nt=t.DEPTH24_STENCIL8:nt=t.DEPTH_COMPONENT16:D.type===Kc&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),D.format===xf&&nt===t.DEPTH_COMPONENT&&D.type!==IO&&D.type!==Sd&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),D.type=Sd,ze=a.convert(D.type)),D.format===Sg&&nt===t.DEPTH_COMPONENT&&(nt=t.DEPTH_STENCIL,D.type!==gf&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),D.type=gf,ze=a.convert(D.type))),Oe&&(be?n.texStorage2D(t.TEXTURE_2D,1,nt,ie.width,ie.height):n.texImage2D(t.TEXTURE_2D,0,nt,ie.width,ie.height,0,Se,ze,null));else if(D.isDataTexture)if(Pe.length>0&&te){be&&Oe&&n.texStorage2D(t.TEXTURE_2D,Ue,nt,Pe[0].width,Pe[0].height);for(let Ae=0,Je=Pe.length;Ae<Je;Ae++)ne=Pe[Ae],be?n.texSubImage2D(t.TEXTURE_2D,Ae,0,0,ne.width,ne.height,Se,ze,ne.data):n.texImage2D(t.TEXTURE_2D,Ae,nt,ne.width,ne.height,0,Se,ze,ne.data);D.generateMipmaps=!1}else be?(Oe&&n.texStorage2D(t.TEXTURE_2D,Ue,nt,ie.width,ie.height),n.texSubImage2D(t.TEXTURE_2D,0,0,0,ie.width,ie.height,Se,ze,ie.data)):n.texImage2D(t.TEXTURE_2D,0,nt,ie.width,ie.height,0,Se,ze,ie.data);else if(D.isCompressedTexture)if(D.isCompressedArrayTexture){be&&Oe&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Ue,nt,Pe[0].width,Pe[0].height,ie.depth);for(let Ae=0,Je=Pe.length;Ae<Je;Ae++)ne=Pe[Ae],D.format!==So?Se!==null?be?n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,Ae,0,0,0,ne.width,ne.height,ie.depth,Se,ne.data,0,0):n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,Ae,nt,ne.width,ne.height,ie.depth,0,ne.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):be?n.texSubImage3D(t.TEXTURE_2D_ARRAY,Ae,0,0,0,ne.width,ne.height,ie.depth,Se,ze,ne.data):n.texImage3D(t.TEXTURE_2D_ARRAY,Ae,nt,ne.width,ne.height,ie.depth,0,Se,ze,ne.data)}else{be&&Oe&&n.texStorage2D(t.TEXTURE_2D,Ue,nt,Pe[0].width,Pe[0].height);for(let Ae=0,Je=Pe.length;Ae<Je;Ae++)ne=Pe[Ae],D.format!==So?Se!==null?be?n.compressedTexSubImage2D(t.TEXTURE_2D,Ae,0,0,ne.width,ne.height,Se,ne.data):n.compressedTexImage2D(t.TEXTURE_2D,Ae,nt,ne.width,ne.height,0,ne.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):be?n.texSubImage2D(t.TEXTURE_2D,Ae,0,0,ne.width,ne.height,Se,ze,ne.data):n.texImage2D(t.TEXTURE_2D,Ae,nt,ne.width,ne.height,0,Se,ze,ne.data)}else if(D.isDataArrayTexture)be?(Oe&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Ue,nt,ie.width,ie.height,ie.depth),n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,ie.width,ie.height,ie.depth,Se,ze,ie.data)):n.texImage3D(t.TEXTURE_2D_ARRAY,0,nt,ie.width,ie.height,ie.depth,0,Se,ze,ie.data);else if(D.isData3DTexture)be?(Oe&&n.texStorage3D(t.TEXTURE_3D,Ue,nt,ie.width,ie.height,ie.depth),n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,ie.width,ie.height,ie.depth,Se,ze,ie.data)):n.texImage3D(t.TEXTURE_3D,0,nt,ie.width,ie.height,ie.depth,0,Se,ze,ie.data);else if(D.isFramebufferTexture){if(Oe)if(be)n.texStorage2D(t.TEXTURE_2D,Ue,nt,ie.width,ie.height);else{let Ae=ie.width,Je=ie.height;for(let gt=0;gt<Ue;gt++)n.texImage2D(t.TEXTURE_2D,gt,nt,Ae,Je,0,Se,ze,null),Ae>>=1,Je>>=1}}else if(Pe.length>0&&te){be&&Oe&&n.texStorage2D(t.TEXTURE_2D,Ue,nt,Pe[0].width,Pe[0].height);for(let Ae=0,Je=Pe.length;Ae<Je;Ae++)ne=Pe[Ae],be?n.texSubImage2D(t.TEXTURE_2D,Ae,0,0,Se,ze,ne):n.texImage2D(t.TEXTURE_2D,Ae,nt,Se,ze,ne);D.generateMipmaps=!1}else be?(Oe&&n.texStorage2D(t.TEXTURE_2D,Ue,nt,ie.width,ie.height),n.texSubImage2D(t.TEXTURE_2D,0,0,0,Se,ze,ie)):n.texImage2D(t.TEXTURE_2D,0,nt,Se,ze,ie);C(D,te)&&A(xe),$e.__version=ve.version,D.onUpdate&&D.onUpdate(D)}H.__version=D.version}function Ee(H,D,Z){if(D.image.length!==6)return;const xe=Me(H,D),Ne=D.source;n.bindTexture(t.TEXTURE_CUBE_MAP,H.__webglTexture,t.TEXTURE0+Z);const ve=r.get(Ne);if(Ne.version!==ve.__version||xe===!0){n.activeTexture(t.TEXTURE0+Z);const $e=mr.getPrimaries(mr.workingColorSpace),Le=D.colorSpace===No?null:mr.getPrimaries(D.colorSpace),qe=D.colorSpace===No||$e===Le?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,D.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,D.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,D.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,qe);const Ke=D.isCompressedTexture||D.image[0].isCompressedTexture,Ye=D.image[0]&&D.image[0].isDataTexture,ie=[];for(let Ae=0;Ae<6;Ae++)!Ke&&!Ye?ie[Ae]=S(D.image[Ae],!1,!0,u):ie[Ae]=Ye?D.image[Ae].image:D.image[Ae],ie[Ae]=Ce(D,ie[Ae]);const te=ie[0],Se=T(te)||l,ze=a.convert(D.format,D.colorSpace),nt=a.convert(D.type),ne=O(D.internalFormat,ze,nt,D.colorSpace),Pe=l&&D.isVideoTexture!==!0,be=ve.__version===void 0||xe===!0;let Oe=k(D,te,Se);ce(t.TEXTURE_CUBE_MAP,D,Se);let Ue;if(Ke){Pe&&be&&n.texStorage2D(t.TEXTURE_CUBE_MAP,Oe,ne,te.width,te.height);for(let Ae=0;Ae<6;Ae++){Ue=ie[Ae].mipmaps;for(let Je=0;Je<Ue.length;Je++){const gt=Ue[Je];D.format!==So?ze!==null?Pe?n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,Je,0,0,gt.width,gt.height,ze,gt.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,Je,ne,gt.width,gt.height,0,gt.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):Pe?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,Je,0,0,gt.width,gt.height,ze,nt,gt.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,Je,ne,gt.width,gt.height,0,ze,nt,gt.data)}}}else{Ue=D.mipmaps,Pe&&be&&(Ue.length>0&&Oe++,n.texStorage2D(t.TEXTURE_CUBE_MAP,Oe,ne,ie[0].width,ie[0].height));for(let Ae=0;Ae<6;Ae++)if(Ye){Pe?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,0,0,0,ie[Ae].width,ie[Ae].height,ze,nt,ie[Ae].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,0,ne,ie[Ae].width,ie[Ae].height,0,ze,nt,ie[Ae].data);for(let Je=0;Je<Ue.length;Je++){const Pt=Ue[Je].image[Ae].image;Pe?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,Je+1,0,0,Pt.width,Pt.height,ze,nt,Pt.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,Je+1,ne,Pt.width,Pt.height,0,ze,nt,Pt.data)}}else{Pe?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,0,0,0,ze,nt,ie[Ae]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,0,ne,ze,nt,ie[Ae]);for(let Je=0;Je<Ue.length;Je++){const gt=Ue[Je];Pe?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,Je+1,0,0,ze,nt,gt.image[Ae]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,Je+1,ne,ze,nt,gt.image[Ae])}}}C(D,Se)&&A(t.TEXTURE_CUBE_MAP),ve.__version=Ne.version,D.onUpdate&&D.onUpdate(D)}H.__version=D.version}function fe(H,D,Z,xe,Ne,ve){const $e=a.convert(Z.format,Z.colorSpace),Le=a.convert(Z.type),qe=O(Z.internalFormat,$e,Le,Z.colorSpace);if(!r.get(D).__hasExternalTextures){const Ye=Math.max(1,D.width>>ve),ie=Math.max(1,D.height>>ve);Ne===t.TEXTURE_3D||Ne===t.TEXTURE_2D_ARRAY?n.texImage3D(Ne,ve,qe,Ye,ie,D.depth,0,$e,Le,null):n.texImage2D(Ne,ve,qe,Ye,ie,0,$e,Le,null)}n.bindFramebuffer(t.FRAMEBUFFER,H),Te(D)?m.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,xe,Ne,r.get(Z).__webglTexture,0,oe(D)):(Ne===t.TEXTURE_2D||Ne>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&Ne<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,xe,Ne,r.get(Z).__webglTexture,ve),n.bindFramebuffer(t.FRAMEBUFFER,null)}function le(H,D,Z){if(t.bindRenderbuffer(t.RENDERBUFFER,H),D.depthBuffer&&!D.stencilBuffer){let xe=l===!0?t.DEPTH_COMPONENT24:t.DEPTH_COMPONENT16;if(Z||Te(D)){const Ne=D.depthTexture;Ne&&Ne.isDepthTexture&&(Ne.type===Kc?xe=t.DEPTH_COMPONENT32F:Ne.type===Sd&&(xe=t.DEPTH_COMPONENT24));const ve=oe(D);Te(D)?m.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,ve,xe,D.width,D.height):t.renderbufferStorageMultisample(t.RENDERBUFFER,ve,xe,D.width,D.height)}else t.renderbufferStorage(t.RENDERBUFFER,xe,D.width,D.height);t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,H)}else if(D.depthBuffer&&D.stencilBuffer){const xe=oe(D);Z&&Te(D)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,xe,t.DEPTH24_STENCIL8,D.width,D.height):Te(D)?m.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,xe,t.DEPTH24_STENCIL8,D.width,D.height):t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_STENCIL,D.width,D.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,H)}else{const xe=D.isWebGLMultipleRenderTargets===!0?D.texture:[D.texture];for(let Ne=0;Ne<xe.length;Ne++){const ve=xe[Ne],$e=a.convert(ve.format,ve.colorSpace),Le=a.convert(ve.type),qe=O(ve.internalFormat,$e,Le,ve.colorSpace),Ke=oe(D);Z&&Te(D)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,Ke,qe,D.width,D.height):Te(D)?m.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,Ke,qe,D.width,D.height):t.renderbufferStorage(t.RENDERBUFFER,qe,D.width,D.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function Be(H,D){if(D&&D.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(t.FRAMEBUFFER,H),!(D.depthTexture&&D.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!r.get(D.depthTexture).__webglTexture||D.depthTexture.image.width!==D.width||D.depthTexture.image.height!==D.height)&&(D.depthTexture.image.width=D.width,D.depthTexture.image.height=D.height,D.depthTexture.needsUpdate=!0),re(D.depthTexture,0);const xe=r.get(D.depthTexture).__webglTexture,Ne=oe(D);if(D.depthTexture.format===xf)Te(D)?m.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,xe,0,Ne):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,xe,0);else if(D.depthTexture.format===Sg)Te(D)?m.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,xe,0,Ne):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,xe,0);else throw new Error("Unknown depthTexture format")}function V(H){const D=r.get(H),Z=H.isWebGLCubeRenderTarget===!0;if(H.depthTexture&&!D.__autoAllocateDepthBuffer){if(Z)throw new Error("target.depthTexture not supported in Cube render targets");Be(D.__webglFramebuffer,H)}else if(Z){D.__webglDepthbuffer=[];for(let xe=0;xe<6;xe++)n.bindFramebuffer(t.FRAMEBUFFER,D.__webglFramebuffer[xe]),D.__webglDepthbuffer[xe]=t.createRenderbuffer(),le(D.__webglDepthbuffer[xe],H,!1)}else n.bindFramebuffer(t.FRAMEBUFFER,D.__webglFramebuffer),D.__webglDepthbuffer=t.createRenderbuffer(),le(D.__webglDepthbuffer,H,!1);n.bindFramebuffer(t.FRAMEBUFFER,null)}function $(H,D,Z){const xe=r.get(H);D!==void 0&&fe(xe.__webglFramebuffer,H,H.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),Z!==void 0&&V(H)}function X(H){const D=H.texture,Z=r.get(H),xe=r.get(D);H.addEventListener("dispose",L),H.isWebGLMultipleRenderTargets!==!0&&(xe.__webglTexture===void 0&&(xe.__webglTexture=t.createTexture()),xe.__version=D.version,o.memory.textures++);const Ne=H.isWebGLCubeRenderTarget===!0,ve=H.isWebGLMultipleRenderTargets===!0,$e=T(H)||l;if(Ne){Z.__webglFramebuffer=[];for(let Le=0;Le<6;Le++)if(l&&D.mipmaps&&D.mipmaps.length>0){Z.__webglFramebuffer[Le]=[];for(let qe=0;qe<D.mipmaps.length;qe++)Z.__webglFramebuffer[Le][qe]=t.createFramebuffer()}else Z.__webglFramebuffer[Le]=t.createFramebuffer()}else{if(l&&D.mipmaps&&D.mipmaps.length>0){Z.__webglFramebuffer=[];for(let Le=0;Le<D.mipmaps.length;Le++)Z.__webglFramebuffer[Le]=t.createFramebuffer()}else Z.__webglFramebuffer=t.createFramebuffer();if(ve)if(i.drawBuffers){const Le=H.texture;for(let qe=0,Ke=Le.length;qe<Ke;qe++){const Ye=r.get(Le[qe]);Ye.__webglTexture===void 0&&(Ye.__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&&H.samples>0&&Te(H)===!1){const Le=ve?D:[D];Z.__webglMultisampledFramebuffer=t.createFramebuffer(),Z.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,Z.__webglMultisampledFramebuffer);for(let qe=0;qe<Le.length;qe++){const Ke=Le[qe];Z.__webglColorRenderbuffer[qe]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,Z.__webglColorRenderbuffer[qe]);const Ye=a.convert(Ke.format,Ke.colorSpace),ie=a.convert(Ke.type),te=O(Ke.internalFormat,Ye,ie,Ke.colorSpace,H.isXRRenderTarget===!0),Se=oe(H);t.renderbufferStorageMultisample(t.RENDERBUFFER,Se,te,H.width,H.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+qe,t.RENDERBUFFER,Z.__webglColorRenderbuffer[qe])}t.bindRenderbuffer(t.RENDERBUFFER,null),H.depthBuffer&&(Z.__webglDepthRenderbuffer=t.createRenderbuffer(),le(Z.__webglDepthRenderbuffer,H,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(Ne){n.bindTexture(t.TEXTURE_CUBE_MAP,xe.__webglTexture),ce(t.TEXTURE_CUBE_MAP,D,$e);for(let Le=0;Le<6;Le++)if(l&&D.mipmaps&&D.mipmaps.length>0)for(let qe=0;qe<D.mipmaps.length;qe++)fe(Z.__webglFramebuffer[Le][qe],H,D,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Le,qe);else fe(Z.__webglFramebuffer[Le],H,D,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Le,0);C(D,$e)&&A(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(ve){const Le=H.texture;for(let qe=0,Ke=Le.length;qe<Ke;qe++){const Ye=Le[qe],ie=r.get(Ye);n.bindTexture(t.TEXTURE_2D,ie.__webglTexture),ce(t.TEXTURE_2D,Ye,$e),fe(Z.__webglFramebuffer,H,Ye,t.COLOR_ATTACHMENT0+qe,t.TEXTURE_2D,0),C(Ye,$e)&&A(t.TEXTURE_2D)}n.unbindTexture()}else{let Le=t.TEXTURE_2D;if((H.isWebGL3DRenderTarget||H.isWebGLArrayRenderTarget)&&(l?Le=H.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),n.bindTexture(Le,xe.__webglTexture),ce(Le,D,$e),l&&D.mipmaps&&D.mipmaps.length>0)for(let qe=0;qe<D.mipmaps.length;qe++)fe(Z.__webglFramebuffer[qe],H,D,t.COLOR_ATTACHMENT0,Le,qe);else fe(Z.__webglFramebuffer,H,D,t.COLOR_ATTACHMENT0,Le,0);C(D,$e)&&A(Le),n.unbindTexture()}H.depthBuffer&&V(H)}function U(H){const D=T(H)||l,Z=H.isWebGLMultipleRenderTargets===!0?H.texture:[H.texture];for(let xe=0,Ne=Z.length;xe<Ne;xe++){const ve=Z[xe];if(C(ve,D)){const $e=H.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:t.TEXTURE_2D,Le=r.get(ve).__webglTexture;n.bindTexture($e,Le),A($e),n.unbindTexture()}}}function B(H){if(l&&H.samples>0&&Te(H)===!1){const D=H.isWebGLMultipleRenderTargets?H.texture:[H.texture],Z=H.width,xe=H.height;let Ne=t.COLOR_BUFFER_BIT;const ve=[],$e=H.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,Le=r.get(H),qe=H.isWebGLMultipleRenderTargets===!0;if(qe)for(let Ke=0;Ke<D.length;Ke++)n.bindFramebuffer(t.FRAMEBUFFER,Le.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ke,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,Le.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ke,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,Le.__webglMultisampledFramebuffer),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Le.__webglFramebuffer);for(let Ke=0;Ke<D.length;Ke++){ve.push(t.COLOR_ATTACHMENT0+Ke),H.depthBuffer&&ve.push($e);const Ye=Le.__ignoreDepthValues!==void 0?Le.__ignoreDepthValues:!1;if(Ye===!1&&(H.depthBuffer&&(Ne|=t.DEPTH_BUFFER_BIT),H.stencilBuffer&&(Ne|=t.STENCIL_BUFFER_BIT)),qe&&t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,Le.__webglColorRenderbuffer[Ke]),Ye===!0&&(t.invalidateFramebuffer(t.READ_FRAMEBUFFER,[$e]),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[$e])),qe){const ie=r.get(D[Ke]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,ie,0)}t.blitFramebuffer(0,0,Z,xe,0,0,Z,xe,Ne,t.NEAREST),p&&t.invalidateFramebuffer(t.READ_FRAMEBUFFER,ve)}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),qe)for(let Ke=0;Ke<D.length;Ke++){n.bindFramebuffer(t.FRAMEBUFFER,Le.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ke,t.RENDERBUFFER,Le.__webglColorRenderbuffer[Ke]);const Ye=r.get(D[Ke]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,Le.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ke,t.TEXTURE_2D,Ye,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Le.__webglMultisampledFramebuffer)}}function oe(H){return Math.min(f,H.samples)}function Te(H){const D=r.get(H);return l&&H.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&D.__useRenderToTexture!==!1}function je(H){const D=o.render.frame;x.get(H)!==D&&(x.set(H,D),H.update())}function Ce(H,D){const Z=H.colorSpace,xe=H.format,Ne=H.type;return H.isCompressedTexture===!0||H.isVideoTexture===!0||H.format===tR||Z!==pu&&Z!==No&&(mr.getTransfer(Z)===Cr?l===!1?e.has("EXT_sRGB")===!0&&xe===So?(H.format=tR,H.minFilter=wo,H.generateMipmaps=!1):D=OJ.sRGBToLinear(D):(xe!==So||Ne!==Ld)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",Z)),D}this.allocateTextureUnit=Q,this.resetTextureUnits=q,this.setTexture2D=re,this.setTexture2DArray=z,this.setTexture3D=G,this.setTextureCube=ae,this.rebindTextures=$,this.setupRenderTarget=X,this.updateRenderTargetMipmap=U,this.updateMultisampleRenderTarget=B,this.setupDepthRenderbuffer=V,this.setupFrameBufferTexture=fe,this.useMultisampledRTT=Te}function cBe(t,e,n){const r=n.isWebGL2;function i(a,o=No){let l;const c=mr.getTransfer(o);if(a===Ld)return t.UNSIGNED_BYTE;if(a===NJ)return t.UNSIGNED_SHORT_4_4_4_4;if(a===MJ)return t.UNSIGNED_SHORT_5_5_5_1;if(a===RLe)return t.BYTE;if(a===DLe)return t.SHORT;if(a===IO)return t.UNSIGNED_SHORT;if(a===SJ)return t.INT;if(a===Sd)return t.UNSIGNED_INT;if(a===Kc)return t.FLOAT;if(a===U0)return r?t.HALF_FLOAT:(l=e.get("OES_texture_half_float"),l!==null?l.HALF_FLOAT_OES:null);if(a===OLe)return t.ALPHA;if(a===So)return t.RGBA;if(a===LLe)return t.LUMINANCE;if(a===ILe)return t.LUMINANCE_ALPHA;if(a===xf)return t.DEPTH_COMPONENT;if(a===Sg)return t.DEPTH_STENCIL;if(a===tR)return l=e.get("EXT_sRGB"),l!==null?l.SRGB_ALPHA_EXT:null;if(a===FLe)return t.RED;if(a===EJ)return t.RED_INTEGER;if(a===ULe)return t.RG;if(a===TJ)return t.RG_INTEGER;if(a===AJ)return t.RGBA_INTEGER;if(a===ik||a===ak||a===sk||a===ok)if(c===Cr)if(l=e.get("WEBGL_compressed_texture_s3tc_srgb"),l!==null){if(a===ik)return l.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(a===ak)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(a===sk)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(a===ok)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(l=e.get("WEBGL_compressed_texture_s3tc"),l!==null){if(a===ik)return l.COMPRESSED_RGB_S3TC_DXT1_EXT;if(a===ak)return l.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(a===sk)return l.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(a===ok)return l.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(a===AV||a===CV||a===kV||a===jV)if(l=e.get("WEBGL_compressed_texture_pvrtc"),l!==null){if(a===AV)return l.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(a===CV)return l.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(a===kV)return l.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(a===jV)return l.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(a===CJ)return l=e.get("WEBGL_compressed_texture_etc1"),l!==null?l.COMPRESSED_RGB_ETC1_WEBGL:null;if(a===PV||a===RV)if(l=e.get("WEBGL_compressed_texture_etc"),l!==null){if(a===PV)return c===Cr?l.COMPRESSED_SRGB8_ETC2:l.COMPRESSED_RGB8_ETC2;if(a===RV)return c===Cr?l.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:l.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(a===DV||a===OV||a===LV||a===IV||a===FV||a===UV||a===zV||a===BV||a===$V||a===HV||a===VV||a===GV||a===WV||a===qV)if(l=e.get("WEBGL_compressed_texture_astc"),l!==null){if(a===DV)return c===Cr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:l.COMPRESSED_RGBA_ASTC_4x4_KHR;if(a===OV)return c===Cr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:l.COMPRESSED_RGBA_ASTC_5x4_KHR;if(a===LV)return c===Cr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:l.COMPRESSED_RGBA_ASTC_5x5_KHR;if(a===IV)return c===Cr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:l.COMPRESSED_RGBA_ASTC_6x5_KHR;if(a===FV)return c===Cr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:l.COMPRESSED_RGBA_ASTC_6x6_KHR;if(a===UV)return c===Cr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:l.COMPRESSED_RGBA_ASTC_8x5_KHR;if(a===zV)return c===Cr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:l.COMPRESSED_RGBA_ASTC_8x6_KHR;if(a===BV)return c===Cr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:l.COMPRESSED_RGBA_ASTC_8x8_KHR;if(a===$V)return c===Cr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:l.COMPRESSED_RGBA_ASTC_10x5_KHR;if(a===HV)return c===Cr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:l.COMPRESSED_RGBA_ASTC_10x6_KHR;if(a===VV)return c===Cr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:l.COMPRESSED_RGBA_ASTC_10x8_KHR;if(a===GV)return c===Cr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:l.COMPRESSED_RGBA_ASTC_10x10_KHR;if(a===WV)return c===Cr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:l.COMPRESSED_RGBA_ASTC_12x10_KHR;if(a===qV)return c===Cr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:l.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(a===lk||a===KV||a===XV)if(l=e.get("EXT_texture_compression_bptc"),l!==null){if(a===lk)return c===Cr?l.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:l.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(a===KV)return l.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(a===XV)return l.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(a===zLe||a===YV||a===QV||a===ZV)if(l=e.get("EXT_texture_compression_rgtc"),l!==null){if(a===lk)return l.COMPRESSED_RED_RGTC1_EXT;if(a===YV)return l.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(a===QV)return l.COMPRESSED_RED_GREEN_RGTC2_EXT;if(a===ZV)return l.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return a===gf?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 uBe extends Us{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class jb extends Xa{constructor(){super(),this.isGroup=!0,this.type="Group"}}const dBe={type:"move"};class jk{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new jb,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 jb,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new We,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new We),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new jb,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new We,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new We),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 y of e.hand.values()){const b=n.getJointPose(y,r),v=this._getHandJoint(u,y);b!==null&&(v.matrix.fromArray(b.transform.matrix),v.matrix.decompose(v.position,v.rotation,v.scale),v.matrixWorldNeedsUpdate=!0,v.jointRadius=b.radius),v.visible=b!==null}const d=u.joints["index-finger-tip"],f=u.joints["thumb-tip"],m=d.position.distanceTo(f.position),p=.02,x=.005;u.inputState.pinching&&m>p+x?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!u.inputState.pinching&&m<=p-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(dBe)))}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 jb;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[n.jointName]=r,e.add(r)}return e.joints[n.jointName]}}class hBe extends rm{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,m=null,p=null,x=null;const y=n.getContextAttributes();let b=null,v=null;const N=[],S=[],T=new pn;let E=null;const C=new Us;C.layers.enable(1),C.viewport=new gr;const A=new Us;A.layers.enable(2),A.viewport=new gr;const O=[C,A],k=new uBe;k.layers.enable(1),k.layers.enable(2);let R=null,F=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(ae){let se=N[ae];return se===void 0&&(se=new jk,N[ae]=se),se.getTargetRaySpace()},this.getControllerGrip=function(ae){let se=N[ae];return se===void 0&&(se=new jk,N[ae]=se),se.getGripSpace()},this.getHand=function(ae){let se=N[ae];return se===void 0&&(se=new jk,N[ae]=se),se.getHandSpace()};function L(ae){const se=S.indexOf(ae.inputSource);if(se===-1)return;const ue=N[se];ue!==void 0&&(ue.update(ae.inputSource,ae.frame,u||o),ue.dispatchEvent({type:ae.type,data:ae.inputSource}))}function K(){i.removeEventListener("select",L),i.removeEventListener("selectstart",L),i.removeEventListener("selectend",L),i.removeEventListener("squeeze",L),i.removeEventListener("squeezestart",L),i.removeEventListener("squeezeend",L),i.removeEventListener("end",K),i.removeEventListener("inputsourceschange",j);for(let ae=0;ae<N.length;ae++){const se=S[ae];se!==null&&(S[ae]=null,N[ae].disconnect(se))}R=null,F=null,e.setRenderTarget(b),p=null,m=null,f=null,i=null,v=null,G.stop(),r.isPresenting=!1,e.setPixelRatio(E),e.setSize(T.width,T.height,!1),r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(ae){a=ae,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(ae){l=ae,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return u||o},this.setReferenceSpace=function(ae){u=ae},this.getBaseLayer=function(){return m!==null?m:p},this.getBinding=function(){return f},this.getFrame=function(){return x},this.getSession=function(){return i},this.setSession=async function(ae){if(i=ae,i!==null){if(b=e.getRenderTarget(),i.addEventListener("select",L),i.addEventListener("selectstart",L),i.addEventListener("selectend",L),i.addEventListener("squeeze",L),i.addEventListener("squeezestart",L),i.addEventListener("squeezeend",L),i.addEventListener("end",K),i.addEventListener("inputsourceschange",j),y.xrCompatible!==!0&&await n.makeXRCompatible(),E=e.getPixelRatio(),e.getSize(T),i.renderState.layers===void 0||e.capabilities.isWebGL2===!1){const se={antialias:i.renderState.layers===void 0?y.antialias:!0,alpha:!0,depth:y.depth,stencil:y.stencil,framebufferScaleFactor:a};p=new XRWebGLLayer(i,n,se),i.updateRenderState({baseLayer:p}),e.setPixelRatio(1),e.setSize(p.framebufferWidth,p.framebufferHeight,!1),v=new Vf(p.framebufferWidth,p.framebufferHeight,{format:So,type:Ld,colorSpace:e.outputColorSpace,stencilBuffer:y.stencil})}else{let se=null,ue=null,pe=null;y.depth&&(pe=y.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,se=y.stencil?Sg:xf,ue=y.stencil?gf:Sd);const ce={colorFormat:n.RGBA8,depthFormat:pe,scaleFactor:a};f=new XRWebGLBinding(i,n),m=f.createProjectionLayer(ce),i.updateRenderState({layers:[m]}),e.setPixelRatio(1),e.setSize(m.textureWidth,m.textureHeight,!1),v=new Vf(m.textureWidth,m.textureHeight,{format:So,type:Ld,depthTexture:new qJ(m.textureWidth,m.textureHeight,ue,void 0,void 0,void 0,void 0,void 0,void 0,se),stencilBuffer:y.stencil,colorSpace:e.outputColorSpace,samples:y.antialias?4:0});const Me=e.properties.get(v);Me.__ignoreDepthValues=m.ignoreDepthValues}v.isXRRenderTarget=!0,this.setFoveation(c),u=null,o=await i.requestReferenceSpace(l),G.setContext(i),G.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode};function j(ae){for(let se=0;se<ae.removed.length;se++){const ue=ae.removed[se],pe=S.indexOf(ue);pe>=0&&(S[pe]=null,N[pe].disconnect(ue))}for(let se=0;se<ae.added.length;se++){const ue=ae.added[se];let pe=S.indexOf(ue);if(pe===-1){for(let Me=0;Me<N.length;Me++)if(Me>=S.length){S.push(ue),pe=Me;break}else if(S[Me]===null){S[Me]=ue,pe=Me;break}if(pe===-1)break}const ce=N[pe];ce&&ce.connect(ue)}}const W=new We,Y=new We;function q(ae,se,ue){W.setFromMatrixPosition(se.matrixWorld),Y.setFromMatrixPosition(ue.matrixWorld);const pe=W.distanceTo(Y),ce=se.projectionMatrix.elements,Me=ue.projectionMatrix.elements,me=ce[14]/(ce[10]-1),Ee=ce[14]/(ce[10]+1),fe=(ce[9]+1)/ce[5],le=(ce[9]-1)/ce[5],Be=(ce[8]-1)/ce[0],V=(Me[8]+1)/Me[0],$=me*Be,X=me*V,U=pe/(-Be+V),B=U*-Be;se.matrixWorld.decompose(ae.position,ae.quaternion,ae.scale),ae.translateX(B),ae.translateZ(U),ae.matrixWorld.compose(ae.position,ae.quaternion,ae.scale),ae.matrixWorldInverse.copy(ae.matrixWorld).invert();const oe=me+U,Te=Ee+U,je=$-B,Ce=X+(pe-B),H=fe*Ee/Te*oe,D=le*Ee/Te*oe;ae.projectionMatrix.makePerspective(je,Ce,H,D,oe,Te),ae.projectionMatrixInverse.copy(ae.projectionMatrix).invert()}function Q(ae,se){se===null?ae.matrixWorld.copy(ae.matrix):ae.matrixWorld.multiplyMatrices(se.matrixWorld,ae.matrix),ae.matrixWorldInverse.copy(ae.matrixWorld).invert()}this.updateCamera=function(ae){if(i===null)return;k.near=A.near=C.near=ae.near,k.far=A.far=C.far=ae.far,(R!==k.near||F!==k.far)&&(i.updateRenderState({depthNear:k.near,depthFar:k.far}),R=k.near,F=k.far);const se=ae.parent,ue=k.cameras;Q(k,se);for(let pe=0;pe<ue.length;pe++)Q(ue[pe],se);ue.length===2?q(k,C,A):k.projectionMatrix.copy(C.projectionMatrix),ee(ae,k,se)};function ee(ae,se,ue){ue===null?ae.matrix.copy(se.matrixWorld):(ae.matrix.copy(ue.matrixWorld),ae.matrix.invert(),ae.matrix.multiply(se.matrixWorld)),ae.matrix.decompose(ae.position,ae.quaternion,ae.scale),ae.updateMatrixWorld(!0),ae.projectionMatrix.copy(se.projectionMatrix),ae.projectionMatrixInverse.copy(se.projectionMatrixInverse),ae.isPerspectiveCamera&&(ae.fov=B0*2*Math.atan(1/ae.projectionMatrix.elements[5]),ae.zoom=1)}this.getCamera=function(){return k},this.getFoveation=function(){if(!(m===null&&p===null))return c},this.setFoveation=function(ae){c=ae,m!==null&&(m.fixedFoveation=ae),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=ae)};let re=null;function z(ae,se){if(d=se.getViewerPose(u||o),x=se,d!==null){const ue=d.views;p!==null&&(e.setRenderTargetFramebuffer(v,p.framebuffer),e.setRenderTarget(v));let pe=!1;ue.length!==k.cameras.length&&(k.cameras.length=0,pe=!0);for(let ce=0;ce<ue.length;ce++){const Me=ue[ce];let me=null;if(p!==null)me=p.getViewport(Me);else{const fe=f.getViewSubImage(m,Me);me=fe.viewport,ce===0&&(e.setRenderTargetTextures(v,fe.colorTexture,m.ignoreDepthValues?void 0:fe.depthStencilTexture),e.setRenderTarget(v))}let Ee=O[ce];Ee===void 0&&(Ee=new Us,Ee.layers.enable(ce),Ee.viewport=new gr,O[ce]=Ee),Ee.matrix.fromArray(Me.transform.matrix),Ee.matrix.decompose(Ee.position,Ee.quaternion,Ee.scale),Ee.projectionMatrix.fromArray(Me.projectionMatrix),Ee.projectionMatrixInverse.copy(Ee.projectionMatrix).invert(),Ee.viewport.set(me.x,me.y,me.width,me.height),ce===0&&(k.matrix.copy(Ee.matrix),k.matrix.decompose(k.position,k.quaternion,k.scale)),pe===!0&&k.cameras.push(Ee)}}for(let ue=0;ue<N.length;ue++){const pe=S[ue],ce=N[ue];pe!==null&&ce!==void 0&&ce.update(pe,se,u||o)}re&&re(ae,se),se.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:se}),x=null}const G=new WJ;G.setAnimationLoop(z),this.setAnimationLoop=function(ae){re=ae},this.dispose=function(){}}}function fBe(t,e){function n(b,v){b.matrixAutoUpdate===!0&&b.updateMatrix(),v.value.copy(b.matrix)}function r(b,v){v.color.getRGB(b.fogColor.value,HJ(t)),v.isFog?(b.fogNear.value=v.near,b.fogFar.value=v.far):v.isFogExp2&&(b.fogDensity.value=v.density)}function i(b,v,N,S,T){v.isMeshBasicMaterial||v.isMeshLambertMaterial?a(b,v):v.isMeshToonMaterial?(a(b,v),f(b,v)):v.isMeshPhongMaterial?(a(b,v),d(b,v)):v.isMeshStandardMaterial?(a(b,v),m(b,v),v.isMeshPhysicalMaterial&&p(b,v,T)):v.isMeshMatcapMaterial?(a(b,v),x(b,v)):v.isMeshDepthMaterial?a(b,v):v.isMeshDistanceMaterial?(a(b,v),y(b,v)):v.isMeshNormalMaterial?a(b,v):v.isLineBasicMaterial?(o(b,v),v.isLineDashedMaterial&&l(b,v)):v.isPointsMaterial?c(b,v,N,S):v.isSpriteMaterial?u(b,v):v.isShadowMaterial?(b.color.value.copy(v.color),b.opacity.value=v.opacity):v.isShaderMaterial&&(v.uniformsNeedUpdate=!1)}function a(b,v){b.opacity.value=v.opacity,v.color&&b.diffuse.value.copy(v.color),v.emissive&&b.emissive.value.copy(v.emissive).multiplyScalar(v.emissiveIntensity),v.map&&(b.map.value=v.map,n(v.map,b.mapTransform)),v.alphaMap&&(b.alphaMap.value=v.alphaMap,n(v.alphaMap,b.alphaMapTransform)),v.bumpMap&&(b.bumpMap.value=v.bumpMap,n(v.bumpMap,b.bumpMapTransform),b.bumpScale.value=v.bumpScale,v.side===ys&&(b.bumpScale.value*=-1)),v.normalMap&&(b.normalMap.value=v.normalMap,n(v.normalMap,b.normalMapTransform),b.normalScale.value.copy(v.normalScale),v.side===ys&&b.normalScale.value.negate()),v.displacementMap&&(b.displacementMap.value=v.displacementMap,n(v.displacementMap,b.displacementMapTransform),b.displacementScale.value=v.displacementScale,b.displacementBias.value=v.displacementBias),v.emissiveMap&&(b.emissiveMap.value=v.emissiveMap,n(v.emissiveMap,b.emissiveMapTransform)),v.specularMap&&(b.specularMap.value=v.specularMap,n(v.specularMap,b.specularMapTransform)),v.alphaTest>0&&(b.alphaTest.value=v.alphaTest);const N=e.get(v).envMap;if(N&&(b.envMap.value=N,b.flipEnvMap.value=N.isCubeTexture&&N.isRenderTargetTexture===!1?-1:1,b.reflectivity.value=v.reflectivity,b.ior.value=v.ior,b.refractionRatio.value=v.refractionRatio),v.lightMap){b.lightMap.value=v.lightMap;const S=t._useLegacyLights===!0?Math.PI:1;b.lightMapIntensity.value=v.lightMapIntensity*S,n(v.lightMap,b.lightMapTransform)}v.aoMap&&(b.aoMap.value=v.aoMap,b.aoMapIntensity.value=v.aoMapIntensity,n(v.aoMap,b.aoMapTransform))}function o(b,v){b.diffuse.value.copy(v.color),b.opacity.value=v.opacity,v.map&&(b.map.value=v.map,n(v.map,b.mapTransform))}function l(b,v){b.dashSize.value=v.dashSize,b.totalSize.value=v.dashSize+v.gapSize,b.scale.value=v.scale}function c(b,v,N,S){b.diffuse.value.copy(v.color),b.opacity.value=v.opacity,b.size.value=v.size*N,b.scale.value=S*.5,v.map&&(b.map.value=v.map,n(v.map,b.uvTransform)),v.alphaMap&&(b.alphaMap.value=v.alphaMap,n(v.alphaMap,b.alphaMapTransform)),v.alphaTest>0&&(b.alphaTest.value=v.alphaTest)}function u(b,v){b.diffuse.value.copy(v.color),b.opacity.value=v.opacity,b.rotation.value=v.rotation,v.map&&(b.map.value=v.map,n(v.map,b.mapTransform)),v.alphaMap&&(b.alphaMap.value=v.alphaMap,n(v.alphaMap,b.alphaMapTransform)),v.alphaTest>0&&(b.alphaTest.value=v.alphaTest)}function d(b,v){b.specular.value.copy(v.specular),b.shininess.value=Math.max(v.shininess,1e-4)}function f(b,v){v.gradientMap&&(b.gradientMap.value=v.gradientMap)}function m(b,v){b.metalness.value=v.metalness,v.metalnessMap&&(b.metalnessMap.value=v.metalnessMap,n(v.metalnessMap,b.metalnessMapTransform)),b.roughness.value=v.roughness,v.roughnessMap&&(b.roughnessMap.value=v.roughnessMap,n(v.roughnessMap,b.roughnessMapTransform)),e.get(v).envMap&&(b.envMapIntensity.value=v.envMapIntensity)}function p(b,v,N){b.ior.value=v.ior,v.sheen>0&&(b.sheenColor.value.copy(v.sheenColor).multiplyScalar(v.sheen),b.sheenRoughness.value=v.sheenRoughness,v.sheenColorMap&&(b.sheenColorMap.value=v.sheenColorMap,n(v.sheenColorMap,b.sheenColorMapTransform)),v.sheenRoughnessMap&&(b.sheenRoughnessMap.value=v.sheenRoughnessMap,n(v.sheenRoughnessMap,b.sheenRoughnessMapTransform))),v.clearcoat>0&&(b.clearcoat.value=v.clearcoat,b.clearcoatRoughness.value=v.clearcoatRoughness,v.clearcoatMap&&(b.clearcoatMap.value=v.clearcoatMap,n(v.clearcoatMap,b.clearcoatMapTransform)),v.clearcoatRoughnessMap&&(b.clearcoatRoughnessMap.value=v.clearcoatRoughnessMap,n(v.clearcoatRoughnessMap,b.clearcoatRoughnessMapTransform)),v.clearcoatNormalMap&&(b.clearcoatNormalMap.value=v.clearcoatNormalMap,n(v.clearcoatNormalMap,b.clearcoatNormalMapTransform),b.clearcoatNormalScale.value.copy(v.clearcoatNormalScale),v.side===ys&&b.clearcoatNormalScale.value.negate())),v.iridescence>0&&(b.iridescence.value=v.iridescence,b.iridescenceIOR.value=v.iridescenceIOR,b.iridescenceThicknessMinimum.value=v.iridescenceThicknessRange[0],b.iridescenceThicknessMaximum.value=v.iridescenceThicknessRange[1],v.iridescenceMap&&(b.iridescenceMap.value=v.iridescenceMap,n(v.iridescenceMap,b.iridescenceMapTransform)),v.iridescenceThicknessMap&&(b.iridescenceThicknessMap.value=v.iridescenceThicknessMap,n(v.iridescenceThicknessMap,b.iridescenceThicknessMapTransform))),v.transmission>0&&(b.transmission.value=v.transmission,b.transmissionSamplerMap.value=N.texture,b.transmissionSamplerSize.value.set(N.width,N.height),v.transmissionMap&&(b.transmissionMap.value=v.transmissionMap,n(v.transmissionMap,b.transmissionMapTransform)),b.thickness.value=v.thickness,v.thicknessMap&&(b.thicknessMap.value=v.thicknessMap,n(v.thicknessMap,b.thicknessMapTransform)),b.attenuationDistance.value=v.attenuationDistance,b.attenuationColor.value.copy(v.attenuationColor)),v.anisotropy>0&&(b.anisotropyVector.value.set(v.anisotropy*Math.cos(v.anisotropyRotation),v.anisotropy*Math.sin(v.anisotropyRotation)),v.anisotropyMap&&(b.anisotropyMap.value=v.anisotropyMap,n(v.anisotropyMap,b.anisotropyMapTransform))),b.specularIntensity.value=v.specularIntensity,b.specularColor.value.copy(v.specularColor),v.specularColorMap&&(b.specularColorMap.value=v.specularColorMap,n(v.specularColorMap,b.specularColorMapTransform)),v.specularIntensityMap&&(b.specularIntensityMap.value=v.specularIntensityMap,n(v.specularIntensityMap,b.specularIntensityMapTransform))}function x(b,v){v.matcap&&(b.matcap.value=v.matcap)}function y(b,v){const N=e.get(v).light;b.referencePosition.value.setFromMatrixPosition(N.matrixWorld),b.nearDistance.value=N.shadow.camera.near,b.farDistance.value=N.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function mBe(t,e,n,r){let i={},a={},o=[];const l=n.isWebGL2?t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS):0;function c(N,S){const T=S.program;r.uniformBlockBinding(N,T)}function u(N,S){let T=i[N.id];T===void 0&&(x(N),T=d(N),i[N.id]=T,N.addEventListener("dispose",b));const E=S.program;r.updateUBOMapping(N,E);const C=e.render.frame;a[N.id]!==C&&(m(N),a[N.id]=C)}function d(N){const S=f();N.__bindingPointIndex=S;const T=t.createBuffer(),E=N.__size,C=N.usage;return t.bindBuffer(t.UNIFORM_BUFFER,T),t.bufferData(t.UNIFORM_BUFFER,E,C),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,S,T),T}function f(){for(let N=0;N<l;N++)if(o.indexOf(N)===-1)return o.push(N),N;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function m(N){const S=i[N.id],T=N.uniforms,E=N.__cache;t.bindBuffer(t.UNIFORM_BUFFER,S);for(let C=0,A=T.length;C<A;C++){const O=T[C];if(p(O,C,E)===!0){const k=O.__offset,R=Array.isArray(O.value)?O.value:[O.value];let F=0;for(let L=0;L<R.length;L++){const K=R[L],j=y(K);typeof K=="number"?(O.__data[0]=K,t.bufferSubData(t.UNIFORM_BUFFER,k+F,O.__data)):K.isMatrix3?(O.__data[0]=K.elements[0],O.__data[1]=K.elements[1],O.__data[2]=K.elements[2],O.__data[3]=K.elements[0],O.__data[4]=K.elements[3],O.__data[5]=K.elements[4],O.__data[6]=K.elements[5],O.__data[7]=K.elements[0],O.__data[8]=K.elements[6],O.__data[9]=K.elements[7],O.__data[10]=K.elements[8],O.__data[11]=K.elements[0]):(K.toArray(O.__data,F),F+=j.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,k,O.__data)}}t.bindBuffer(t.UNIFORM_BUFFER,null)}function p(N,S,T){const E=N.value;if(T[S]===void 0){if(typeof E=="number")T[S]=E;else{const C=Array.isArray(E)?E:[E],A=[];for(let O=0;O<C.length;O++)A.push(C[O].clone());T[S]=A}return!0}else if(typeof E=="number"){if(T[S]!==E)return T[S]=E,!0}else{const C=Array.isArray(T[S])?T[S]:[T[S]],A=Array.isArray(E)?E:[E];for(let O=0;O<C.length;O++){const k=C[O];if(k.equals(A[O])===!1)return k.copy(A[O]),!0}}return!1}function x(N){const S=N.uniforms;let T=0;const E=16;let C=0;for(let A=0,O=S.length;A<O;A++){const k=S[A],R={boundary:0,storage:0},F=Array.isArray(k.value)?k.value:[k.value];for(let L=0,K=F.length;L<K;L++){const j=F[L],W=y(j);R.boundary+=W.boundary,R.storage+=W.storage}if(k.__data=new Float32Array(R.storage/Float32Array.BYTES_PER_ELEMENT),k.__offset=T,A>0){C=T%E;const L=E-C;C!==0&&L-R.boundary<0&&(T+=E-C,k.__offset=T)}T+=R.storage}return C=T%E,C>0&&(T+=E-C),N.__size=T,N.__cache={},this}function y(N){const S={boundary:0,storage:0};return typeof N=="number"?(S.boundary=4,S.storage=4):N.isVector2?(S.boundary=8,S.storage=8):N.isVector3||N.isColor?(S.boundary=16,S.storage=12):N.isVector4?(S.boundary=16,S.storage=16):N.isMatrix3?(S.boundary=48,S.storage=48):N.isMatrix4?(S.boundary=64,S.storage=64):N.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",N),S}function b(N){const S=N.target;S.removeEventListener("dispose",b);const T=o.indexOf(S.__bindingPointIndex);o.splice(T,1),t.deleteBuffer(i[S.id]),delete i[S.id],delete a[S.id]}function v(){for(const N in i)t.deleteBuffer(i[N]);o=[],i={},a={}}return{bind:c,update:u,dispose:v}}class iR{constructor(e={}){const{canvas:n=dIe(),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 m;r!==null?m=r.getContextAttributes().alpha:m=o;const p=new Uint32Array(4),x=new Int32Array(4);let y=null,b=null;const v=[],N=[];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=xa,this._useLegacyLights=!1,this.toneMapping=Od,this.toneMappingExposure=1;const S=this;let T=!1,E=0,C=0,A=null,O=-1,k=null;const R=new gr,F=new gr;let L=null;const K=new nn(0);let j=0,W=n.width,Y=n.height,q=1,Q=null,ee=null;const re=new gr(0,0,W,Y),z=new gr(0,0,W,Y);let G=!1;const ae=new qN;let se=!1,ue=!1,pe=null;const ce=new Er,Me=new pn,me=new We,Ee={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function fe(){return A===null?q:1}let le=r;function Be(_e,Xe){for(let ot=0;ot<_e.length;ot++){const ct=_e[ot],rt=n.getContext(ct,Xe);if(rt!==null)return rt}return null}try{const _e={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${VN}`),n.addEventListener("webglcontextlost",Pe,!1),n.addEventListener("webglcontextrestored",be,!1),n.addEventListener("webglcontextcreationerror",Oe,!1),le===null){const Xe=["webgl2","webgl","experimental-webgl"];if(S.isWebGL1Renderer===!0&&Xe.shift(),le=Be(Xe,_e),le===null)throw Be(Xe)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}typeof WebGLRenderingContext<"u"&&le instanceof WebGLRenderingContext&&console.warn("THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163."),le.getShaderPrecisionFormat===void 0&&(le.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(_e){throw console.error("THREE.WebGLRenderer: "+_e.message),_e}let V,$,X,U,B,oe,Te,je,Ce,H,D,Z,xe,Ne,ve,$e,Le,qe,Ke,Ye,ie,te,Se,ze;function nt(){V=new MUe(le),$=new bUe(le,V,e),V.init($),te=new cBe(le,V,$),X=new oBe(le,V,$),U=new AUe(le),B=new qze,oe=new lBe(le,V,X,B,$,te,U),Te=new vUe(S),je=new NUe(S),Ce=new OIe(le,$),Se=new gUe(le,V,Ce,$),H=new EUe(le,Ce,U,Se),D=new PUe(le,H,Ce,U),Ke=new jUe(le,$,oe),$e=new yUe(B),Z=new Wze(S,Te,je,V,$,Se,$e),xe=new fBe(S,B),Ne=new Xze,ve=new tBe(V,$),qe=new pUe(S,Te,je,X,D,m,c),Le=new sBe(S,D,$),ze=new mBe(le,U,$,X),Ye=new xUe(le,V,U,$),ie=new TUe(le,V,U,$),U.programs=Z.programs,S.capabilities=$,S.extensions=V,S.properties=B,S.renderLists=Ne,S.shadowMap=Le,S.state=X,S.info=U}nt();const ne=new hBe(S,le);this.xr=ne,this.getContext=function(){return le},this.getContextAttributes=function(){return le.getContextAttributes()},this.forceContextLoss=function(){const _e=V.get("WEBGL_lose_context");_e&&_e.loseContext()},this.forceContextRestore=function(){const _e=V.get("WEBGL_lose_context");_e&&_e.restoreContext()},this.getPixelRatio=function(){return q},this.setPixelRatio=function(_e){_e!==void 0&&(q=_e,this.setSize(W,Y,!1))},this.getSize=function(_e){return _e.set(W,Y)},this.setSize=function(_e,Xe,ot=!0){if(ne.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}W=_e,Y=Xe,n.width=Math.floor(_e*q),n.height=Math.floor(Xe*q),ot===!0&&(n.style.width=_e+"px",n.style.height=Xe+"px"),this.setViewport(0,0,_e,Xe)},this.getDrawingBufferSize=function(_e){return _e.set(W*q,Y*q).floor()},this.setDrawingBufferSize=function(_e,Xe,ot){W=_e,Y=Xe,q=ot,n.width=Math.floor(_e*ot),n.height=Math.floor(Xe*ot),this.setViewport(0,0,_e,Xe)},this.getCurrentViewport=function(_e){return _e.copy(R)},this.getViewport=function(_e){return _e.copy(re)},this.setViewport=function(_e,Xe,ot,ct){_e.isVector4?re.set(_e.x,_e.y,_e.z,_e.w):re.set(_e,Xe,ot,ct),X.viewport(R.copy(re).multiplyScalar(q).floor())},this.getScissor=function(_e){return _e.copy(z)},this.setScissor=function(_e,Xe,ot,ct){_e.isVector4?z.set(_e.x,_e.y,_e.z,_e.w):z.set(_e,Xe,ot,ct),X.scissor(F.copy(z).multiplyScalar(q).floor())},this.getScissorTest=function(){return G},this.setScissorTest=function(_e){X.setScissorTest(G=_e)},this.setOpaqueSort=function(_e){Q=_e},this.setTransparentSort=function(_e){ee=_e},this.getClearColor=function(_e){return _e.copy(qe.getClearColor())},this.setClearColor=function(){qe.setClearColor.apply(qe,arguments)},this.getClearAlpha=function(){return qe.getClearAlpha()},this.setClearAlpha=function(){qe.setClearAlpha.apply(qe,arguments)},this.clear=function(_e=!0,Xe=!0,ot=!0){let ct=0;if(_e){let rt=!1;if(A!==null){const Rt=A.texture.format;rt=Rt===AJ||Rt===TJ||Rt===EJ}if(rt){const Rt=A.texture.type,de=Rt===Ld||Rt===Sd||Rt===IO||Rt===gf||Rt===NJ||Rt===MJ,Re=qe.getClearColor(),Ve=qe.getClearAlpha(),He=Re.r,Fe=Re.g,mt=Re.b;de?(p[0]=He,p[1]=Fe,p[2]=mt,p[3]=Ve,le.clearBufferuiv(le.COLOR,0,p)):(x[0]=He,x[1]=Fe,x[2]=mt,x[3]=Ve,le.clearBufferiv(le.COLOR,0,x))}else ct|=le.COLOR_BUFFER_BIT}Xe&&(ct|=le.DEPTH_BUFFER_BIT),ot&&(ct|=le.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),le.clear(ct)},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",Pe,!1),n.removeEventListener("webglcontextrestored",be,!1),n.removeEventListener("webglcontextcreationerror",Oe,!1),Ne.dispose(),ve.dispose(),B.dispose(),Te.dispose(),je.dispose(),D.dispose(),Se.dispose(),ze.dispose(),Z.dispose(),ne.dispose(),ne.removeEventListener("sessionstart",cn),ne.removeEventListener("sessionend",It),pe&&(pe.dispose(),pe=null),_n.stop()};function Pe(_e){_e.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),T=!0}function be(){console.log("THREE.WebGLRenderer: Context Restored."),T=!1;const _e=U.autoReset,Xe=Le.enabled,ot=Le.autoUpdate,ct=Le.needsUpdate,rt=Le.type;nt(),U.autoReset=_e,Le.enabled=Xe,Le.autoUpdate=ot,Le.needsUpdate=ct,Le.type=rt}function Oe(_e){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",_e.statusMessage)}function Ue(_e){const Xe=_e.target;Xe.removeEventListener("dispose",Ue),Ae(Xe)}function Ae(_e){Je(_e),B.remove(_e)}function Je(_e){const Xe=B.get(_e).programs;Xe!==void 0&&(Xe.forEach(function(ot){Z.releaseProgram(ot)}),_e.isShaderMaterial&&Z.releaseShaderCache(_e))}this.renderBufferDirect=function(_e,Xe,ot,ct,rt,Rt){Xe===null&&(Xe=Ee);const de=rt.isMesh&&rt.matrixWorld.determinant()<0,Re=Sr(_e,Xe,ot,ct,rt);X.setMaterial(ct,de);let Ve=ot.index,He=1;if(ct.wireframe===!0){if(Ve=H.getWireframeAttribute(ot),Ve===void 0)return;He=2}const Fe=ot.drawRange,mt=ot.attributes.position;let St=Fe.start*He,kt=(Fe.start+Fe.count)*He;Rt!==null&&(St=Math.max(St,Rt.start*He),kt=Math.min(kt,(Rt.start+Rt.count)*He)),Ve!==null?(St=Math.max(St,0),kt=Math.min(kt,Ve.count)):mt!=null&&(St=Math.max(St,0),kt=Math.min(kt,mt.count));const xt=kt-St;if(xt<0||xt===1/0)return;Se.setup(rt,ct,Re,ot,Ve);let $t,jt=Ye;if(Ve!==null&&($t=Ce.get(Ve),jt=ie,jt.setIndex($t)),rt.isMesh)ct.wireframe===!0?(X.setLineWidth(ct.wireframeLinewidth*fe()),jt.setMode(le.LINES)):jt.setMode(le.TRIANGLES);else if(rt.isLine){let wt=ct.linewidth;wt===void 0&&(wt=1),X.setLineWidth(wt*fe()),rt.isLineSegments?jt.setMode(le.LINES):rt.isLineLoop?jt.setMode(le.LINE_LOOP):jt.setMode(le.LINE_STRIP)}else rt.isPoints?jt.setMode(le.POINTS):rt.isSprite&&jt.setMode(le.TRIANGLES);if(rt.isBatchedMesh)jt.renderMultiDraw(rt._multiDrawStarts,rt._multiDrawCounts,rt._multiDrawCount);else if(rt.isInstancedMesh)jt.renderInstances(St,xt,rt.count);else if(ot.isInstancedBufferGeometry){const wt=ot._maxInstanceCount!==void 0?ot._maxInstanceCount:1/0,Qt=Math.min(ot.instanceCount,wt);jt.renderInstances(St,xt,Qt)}else jt.render(St,xt)};function gt(_e,Xe,ot){_e.transparent===!0&&_e.side===$c&&_e.forceSinglePass===!1?(_e.side=ys,_e.needsUpdate=!0,Xr(_e,Xe,ot),_e.side=Yd,_e.needsUpdate=!0,Xr(_e,Xe,ot),_e.side=$c):Xr(_e,Xe,ot)}this.compile=function(_e,Xe,ot=null){ot===null&&(ot=_e),b=ve.get(ot),b.init(),N.push(b),ot.traverseVisible(function(rt){rt.isLight&&rt.layers.test(Xe.layers)&&(b.pushLight(rt),rt.castShadow&&b.pushShadow(rt))}),_e!==ot&&_e.traverseVisible(function(rt){rt.isLight&&rt.layers.test(Xe.layers)&&(b.pushLight(rt),rt.castShadow&&b.pushShadow(rt))}),b.setupLights(S._useLegacyLights);const ct=new Set;return _e.traverse(function(rt){const Rt=rt.material;if(Rt)if(Array.isArray(Rt))for(let de=0;de<Rt.length;de++){const Re=Rt[de];gt(Re,ot,rt),ct.add(Re)}else gt(Rt,ot,rt),ct.add(Rt)}),N.pop(),b=null,ct},this.compileAsync=function(_e,Xe,ot=null){const ct=this.compile(_e,Xe,ot);return new Promise(rt=>{function Rt(){if(ct.forEach(function(de){B.get(de).currentProgram.isReady()&&ct.delete(de)}),ct.size===0){rt(_e);return}setTimeout(Rt,10)}V.get("KHR_parallel_shader_compile")!==null?Rt():setTimeout(Rt,10)})};let Pt=null;function Ot(_e){Pt&&Pt(_e)}function cn(){_n.stop()}function It(){_n.start()}const _n=new WJ;_n.setAnimationLoop(Ot),typeof self<"u"&&_n.setContext(self),this.setAnimationLoop=function(_e){Pt=_e,ne.setAnimationLoop(_e),_e===null?_n.stop():_n.start()},ne.addEventListener("sessionstart",cn),ne.addEventListener("sessionend",It),this.render=function(_e,Xe){if(Xe!==void 0&&Xe.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(T===!0)return;_e.matrixWorldAutoUpdate===!0&&_e.updateMatrixWorld(),Xe.parent===null&&Xe.matrixWorldAutoUpdate===!0&&Xe.updateMatrixWorld(),ne.enabled===!0&&ne.isPresenting===!0&&(ne.cameraAutoUpdate===!0&&ne.updateCamera(Xe),Xe=ne.getCamera()),_e.isScene===!0&&_e.onBeforeRender(S,_e,Xe,A),b=ve.get(_e,N.length),b.init(),N.push(b),ce.multiplyMatrices(Xe.projectionMatrix,Xe.matrixWorldInverse),ae.setFromProjectionMatrix(ce),ue=this.localClippingEnabled,se=$e.init(this.clippingPlanes,ue),y=Ne.get(_e,v.length),y.init(),v.push(y),bt(_e,Xe,0,S.sortObjects),y.finish(),S.sortObjects===!0&&y.sort(Q,ee),this.info.render.frame++,se===!0&&$e.beginShadows();const ot=b.state.shadowsArray;if(Le.render(ot,_e,Xe),se===!0&&$e.endShadows(),this.info.autoReset===!0&&this.info.reset(),qe.render(y,_e),b.setupLights(S._useLegacyLights),Xe.isArrayCamera){const ct=Xe.cameras;for(let rt=0,Rt=ct.length;rt<Rt;rt++){const de=ct[rt];Gt(y,_e,de,de.viewport)}}else Gt(y,_e,Xe);A!==null&&(oe.updateMultisampleRenderTarget(A),oe.updateRenderTargetMipmap(A)),_e.isScene===!0&&_e.onAfterRender(S,_e,Xe),Se.resetDefaultState(),O=-1,k=null,N.pop(),N.length>0?b=N[N.length-1]:b=null,v.pop(),v.length>0?y=v[v.length-1]:y=null};function bt(_e,Xe,ot,ct){if(_e.visible===!1)return;if(_e.layers.test(Xe.layers)){if(_e.isGroup)ot=_e.renderOrder;else if(_e.isLOD)_e.autoUpdate===!0&&_e.update(Xe);else if(_e.isLight)b.pushLight(_e),_e.castShadow&&b.pushShadow(_e);else if(_e.isSprite){if(!_e.frustumCulled||ae.intersectsSprite(_e)){ct&&me.setFromMatrixPosition(_e.matrixWorld).applyMatrix4(ce);const de=D.update(_e),Re=_e.material;Re.visible&&y.push(_e,de,Re,ot,me.z,null)}}else if((_e.isMesh||_e.isLine||_e.isPoints)&&(!_e.frustumCulled||ae.intersectsObject(_e))){const de=D.update(_e),Re=_e.material;if(ct&&(_e.boundingSphere!==void 0?(_e.boundingSphere===null&&_e.computeBoundingSphere(),me.copy(_e.boundingSphere.center)):(de.boundingSphere===null&&de.computeBoundingSphere(),me.copy(de.boundingSphere.center)),me.applyMatrix4(_e.matrixWorld).applyMatrix4(ce)),Array.isArray(Re)){const Ve=de.groups;for(let He=0,Fe=Ve.length;He<Fe;He++){const mt=Ve[He],St=Re[mt.materialIndex];St&&St.visible&&y.push(_e,de,St,ot,me.z,mt)}}else Re.visible&&y.push(_e,de,Re,ot,me.z,null)}}const Rt=_e.children;for(let de=0,Re=Rt.length;de<Re;de++)bt(Rt[de],Xe,ot,ct)}function Gt(_e,Xe,ot,ct){const rt=_e.opaque,Rt=_e.transmissive,de=_e.transparent;b.setupLightsView(ot),se===!0&&$e.setGlobalState(S.clippingPlanes,ot),Rt.length>0&&ln(rt,Rt,Xe,ot),ct&&X.viewport(R.copy(ct)),rt.length>0&&Tt(rt,Xe,ot),Rt.length>0&&Tt(Rt,Xe,ot),de.length>0&&Tt(de,Xe,ot),X.buffers.depth.setTest(!0),X.buffers.depth.setMask(!0),X.buffers.color.setMask(!0),X.setPolygonOffset(!1)}function ln(_e,Xe,ot,ct){if((ot.isScene===!0?ot.overrideMaterial:null)!==null)return;const Rt=$.isWebGL2;pe===null&&(pe=new Vf(1,1,{generateMipmaps:!0,type:V.has("EXT_color_buffer_half_float")?U0:Ld,minFilter:F0,samples:Rt?4:0})),S.getDrawingBufferSize(Me),Rt?pe.setSize(Me.x,Me.y):pe.setSize(CS(Me.x),CS(Me.y));const de=S.getRenderTarget();S.setRenderTarget(pe),S.getClearColor(K),j=S.getClearAlpha(),j<1&&S.setClearColor(16777215,.5),S.clear();const Re=S.toneMapping;S.toneMapping=Od,Tt(_e,ot,ct),oe.updateMultisampleRenderTarget(pe),oe.updateRenderTargetMipmap(pe);let Ve=!1;for(let He=0,Fe=Xe.length;He<Fe;He++){const mt=Xe[He],St=mt.object,kt=mt.geometry,xt=mt.material,$t=mt.group;if(xt.side===$c&&St.layers.test(ct.layers)){const jt=xt.side;xt.side=ys,xt.needsUpdate=!0,Rr(St,ot,ct,kt,xt,$t),xt.side=jt,xt.needsUpdate=!0,Ve=!0}}Ve===!0&&(oe.updateMultisampleRenderTarget(pe),oe.updateRenderTargetMipmap(pe)),S.setRenderTarget(de),S.setClearColor(K,j),S.toneMapping=Re}function Tt(_e,Xe,ot){const ct=Xe.isScene===!0?Xe.overrideMaterial:null;for(let rt=0,Rt=_e.length;rt<Rt;rt++){const de=_e[rt],Re=de.object,Ve=de.geometry,He=ct===null?de.material:ct,Fe=de.group;Re.layers.test(ot.layers)&&Rr(Re,Xe,ot,Ve,He,Fe)}}function Rr(_e,Xe,ot,ct,rt,Rt){_e.onBeforeRender(S,Xe,ot,ct,rt,Rt),_e.modelViewMatrix.multiplyMatrices(ot.matrixWorldInverse,_e.matrixWorld),_e.normalMatrix.getNormalMatrix(_e.modelViewMatrix),rt.onBeforeRender(S,Xe,ot,ct,_e,Rt),rt.transparent===!0&&rt.side===$c&&rt.forceSinglePass===!1?(rt.side=ys,rt.needsUpdate=!0,S.renderBufferDirect(ot,Xe,ct,rt,_e,Rt),rt.side=Yd,rt.needsUpdate=!0,S.renderBufferDirect(ot,Xe,ct,rt,_e,Rt),rt.side=$c):S.renderBufferDirect(ot,Xe,ct,rt,_e,Rt),_e.onAfterRender(S,Xe,ot,ct,rt,Rt)}function Xr(_e,Xe,ot){Xe.isScene!==!0&&(Xe=Ee);const ct=B.get(_e),rt=b.state.lights,Rt=b.state.shadowsArray,de=rt.state.version,Re=Z.getParameters(_e,rt.state,Rt,Xe,ot),Ve=Z.getProgramCacheKey(Re);let He=ct.programs;ct.environment=_e.isMeshStandardMaterial?Xe.environment:null,ct.fog=Xe.fog,ct.envMap=(_e.isMeshStandardMaterial?je:Te).get(_e.envMap||ct.environment),He===void 0&&(_e.addEventListener("dispose",Ue),He=new Map,ct.programs=He);let Fe=He.get(Ve);if(Fe!==void 0){if(ct.currentProgram===Fe&&ct.lightsStateVersion===de)return sn(_e,Re),Fe}else Re.uniforms=Z.getUniforms(_e),_e.onBuild(ot,Re,S),_e.onBeforeCompile(Re,S),Fe=Z.acquireProgram(Re,Ve),He.set(Ve,Fe),ct.uniforms=Re.uniforms;const mt=ct.uniforms;return(!_e.isShaderMaterial&&!_e.isRawShaderMaterial||_e.clipping===!0)&&(mt.clippingPlanes=$e.uniform),sn(_e,Re),ct.needsLights=Dr(_e),ct.lightsStateVersion=de,ct.needsLights&&(mt.ambientLightColor.value=rt.state.ambient,mt.lightProbe.value=rt.state.probe,mt.directionalLights.value=rt.state.directional,mt.directionalLightShadows.value=rt.state.directionalShadow,mt.spotLights.value=rt.state.spot,mt.spotLightShadows.value=rt.state.spotShadow,mt.rectAreaLights.value=rt.state.rectArea,mt.ltc_1.value=rt.state.rectAreaLTC1,mt.ltc_2.value=rt.state.rectAreaLTC2,mt.pointLights.value=rt.state.point,mt.pointLightShadows.value=rt.state.pointShadow,mt.hemisphereLights.value=rt.state.hemi,mt.directionalShadowMap.value=rt.state.directionalShadowMap,mt.directionalShadowMatrix.value=rt.state.directionalShadowMatrix,mt.spotShadowMap.value=rt.state.spotShadowMap,mt.spotLightMatrix.value=rt.state.spotLightMatrix,mt.spotLightMap.value=rt.state.spotLightMap,mt.pointShadowMap.value=rt.state.pointShadowMap,mt.pointShadowMatrix.value=rt.state.pointShadowMatrix),ct.currentProgram=Fe,ct.uniformsList=null,Fe}function An(_e){if(_e.uniformsList===null){const Xe=_e.currentProgram.getUniforms();_e.uniformsList=rw.seqWithValue(Xe.seq,_e.uniforms)}return _e.uniformsList}function sn(_e,Xe){const ot=B.get(_e);ot.outputColorSpace=Xe.outputColorSpace,ot.batching=Xe.batching,ot.instancing=Xe.instancing,ot.instancingColor=Xe.instancingColor,ot.skinning=Xe.skinning,ot.morphTargets=Xe.morphTargets,ot.morphNormals=Xe.morphNormals,ot.morphColors=Xe.morphColors,ot.morphTargetsCount=Xe.morphTargetsCount,ot.numClippingPlanes=Xe.numClippingPlanes,ot.numIntersection=Xe.numClipIntersection,ot.vertexAlphas=Xe.vertexAlphas,ot.vertexTangents=Xe.vertexTangents,ot.toneMapping=Xe.toneMapping}function Sr(_e,Xe,ot,ct,rt){Xe.isScene!==!0&&(Xe=Ee),oe.resetTextureUnits();const Rt=Xe.fog,de=ct.isMeshStandardMaterial?Xe.environment:null,Re=A===null?S.outputColorSpace:A.isXRRenderTarget===!0?A.texture.colorSpace:pu,Ve=(ct.isMeshStandardMaterial?je:Te).get(ct.envMap||de),He=ct.vertexColors===!0&&!!ot.attributes.color&&ot.attributes.color.itemSize===4,Fe=!!ot.attributes.tangent&&(!!ct.normalMap||ct.anisotropy>0),mt=!!ot.morphAttributes.position,St=!!ot.morphAttributes.normal,kt=!!ot.morphAttributes.color;let xt=Od;ct.toneMapped&&(A===null||A.isXRRenderTarget===!0)&&(xt=S.toneMapping);const $t=ot.morphAttributes.position||ot.morphAttributes.normal||ot.morphAttributes.color,jt=$t!==void 0?$t.length:0,wt=B.get(ct),Qt=b.state.lights;if(se===!0&&(ue===!0||_e!==k)){const Yt=_e===k&&ct.id===O;$e.setState(ct,_e,Yt)}let Kt=!1;ct.version===wt.__version?(wt.needsLights&&wt.lightsStateVersion!==Qt.state.version||wt.outputColorSpace!==Re||rt.isBatchedMesh&&wt.batching===!1||!rt.isBatchedMesh&&wt.batching===!0||rt.isInstancedMesh&&wt.instancing===!1||!rt.isInstancedMesh&&wt.instancing===!0||rt.isSkinnedMesh&&wt.skinning===!1||!rt.isSkinnedMesh&&wt.skinning===!0||rt.isInstancedMesh&&wt.instancingColor===!0&&rt.instanceColor===null||rt.isInstancedMesh&&wt.instancingColor===!1&&rt.instanceColor!==null||wt.envMap!==Ve||ct.fog===!0&&wt.fog!==Rt||wt.numClippingPlanes!==void 0&&(wt.numClippingPlanes!==$e.numPlanes||wt.numIntersection!==$e.numIntersection)||wt.vertexAlphas!==He||wt.vertexTangents!==Fe||wt.morphTargets!==mt||wt.morphNormals!==St||wt.morphColors!==kt||wt.toneMapping!==xt||$.isWebGL2===!0&&wt.morphTargetsCount!==jt)&&(Kt=!0):(Kt=!0,wt.__version=ct.version);let fn=wt.currentProgram;Kt===!0&&(fn=Xr(ct,Xe,rt));let ye=!1,De=!1,ht=!1;const Mt=fn.getUniforms(),at=wt.uniforms;if(X.useProgram(fn.program)&&(ye=!0,De=!0,ht=!0),ct.id!==O&&(O=ct.id,De=!0),ye||k!==_e){Mt.setValue(le,"projectionMatrix",_e.projectionMatrix),Mt.setValue(le,"viewMatrix",_e.matrixWorldInverse);const Yt=Mt.map.cameraPosition;Yt!==void 0&&Yt.setValue(le,me.setFromMatrixPosition(_e.matrixWorld)),$.logarithmicDepthBuffer&&Mt.setValue(le,"logDepthBufFC",2/(Math.log(_e.far+1)/Math.LN2)),(ct.isMeshPhongMaterial||ct.isMeshToonMaterial||ct.isMeshLambertMaterial||ct.isMeshBasicMaterial||ct.isMeshStandardMaterial||ct.isShaderMaterial)&&Mt.setValue(le,"isOrthographic",_e.isOrthographicCamera===!0),k!==_e&&(k=_e,De=!0,ht=!0)}if(rt.isSkinnedMesh){Mt.setOptional(le,rt,"bindMatrix"),Mt.setOptional(le,rt,"bindMatrixInverse");const Yt=rt.skeleton;Yt&&($.floatVertexTextures?(Yt.boneTexture===null&&Yt.computeBoneTexture(),Mt.setValue(le,"boneTexture",Yt.boneTexture,oe)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}rt.isBatchedMesh&&(Mt.setOptional(le,rt,"batchingTexture"),Mt.setValue(le,"batchingTexture",rt._matricesTexture,oe));const Xt=ot.morphAttributes;if((Xt.position!==void 0||Xt.normal!==void 0||Xt.color!==void 0&&$.isWebGL2===!0)&&Ke.update(rt,ot,fn),(De||wt.receiveShadow!==rt.receiveShadow)&&(wt.receiveShadow=rt.receiveShadow,Mt.setValue(le,"receiveShadow",rt.receiveShadow)),ct.isMeshGouraudMaterial&&ct.envMap!==null&&(at.envMap.value=Ve,at.flipEnvMap.value=Ve.isCubeTexture&&Ve.isRenderTargetTexture===!1?-1:1),De&&(Mt.setValue(le,"toneMappingExposure",S.toneMappingExposure),wt.needsLights&&si(at,ht),Rt&&ct.fog===!0&&xe.refreshFogUniforms(at,Rt),xe.refreshMaterialUniforms(at,ct,q,Y,pe),rw.upload(le,An(wt),at,oe)),ct.isShaderMaterial&&ct.uniformsNeedUpdate===!0&&(rw.upload(le,An(wt),at,oe),ct.uniformsNeedUpdate=!1),ct.isSpriteMaterial&&Mt.setValue(le,"center",rt.center),Mt.setValue(le,"modelViewMatrix",rt.modelViewMatrix),Mt.setValue(le,"normalMatrix",rt.normalMatrix),Mt.setValue(le,"modelMatrix",rt.matrixWorld),ct.isShaderMaterial||ct.isRawShaderMaterial){const Yt=ct.uniformsGroups;for(let rn=0,sr=Yt.length;rn<sr;rn++)if($.isWebGL2){const kn=Yt[rn];ze.update(kn,fn),ze.bind(kn,fn)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return fn}function si(_e,Xe){_e.ambientLightColor.needsUpdate=Xe,_e.lightProbe.needsUpdate=Xe,_e.directionalLights.needsUpdate=Xe,_e.directionalLightShadows.needsUpdate=Xe,_e.pointLights.needsUpdate=Xe,_e.pointLightShadows.needsUpdate=Xe,_e.spotLights.needsUpdate=Xe,_e.spotLightShadows.needsUpdate=Xe,_e.rectAreaLights.needsUpdate=Xe,_e.hemisphereLights.needsUpdate=Xe}function Dr(_e){return _e.isMeshLambertMaterial||_e.isMeshToonMaterial||_e.isMeshPhongMaterial||_e.isMeshStandardMaterial||_e.isShadowMaterial||_e.isShaderMaterial&&_e.lights===!0}this.getActiveCubeFace=function(){return E},this.getActiveMipmapLevel=function(){return C},this.getRenderTarget=function(){return A},this.setRenderTargetTextures=function(_e,Xe,ot){B.get(_e.texture).__webglTexture=Xe,B.get(_e.depthTexture).__webglTexture=ot;const ct=B.get(_e);ct.__hasExternalTextures=!0,ct.__hasExternalTextures&&(ct.__autoAllocateDepthBuffer=ot===void 0,ct.__autoAllocateDepthBuffer||V.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),ct.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(_e,Xe){const ot=B.get(_e);ot.__webglFramebuffer=Xe,ot.__useDefaultFramebuffer=Xe===void 0},this.setRenderTarget=function(_e,Xe=0,ot=0){A=_e,E=Xe,C=ot;let ct=!0,rt=null,Rt=!1,de=!1;if(_e){const Ve=B.get(_e);Ve.__useDefaultFramebuffer!==void 0?(X.bindFramebuffer(le.FRAMEBUFFER,null),ct=!1):Ve.__webglFramebuffer===void 0?oe.setupRenderTarget(_e):Ve.__hasExternalTextures&&oe.rebindTextures(_e,B.get(_e.texture).__webglTexture,B.get(_e.depthTexture).__webglTexture);const He=_e.texture;(He.isData3DTexture||He.isDataArrayTexture||He.isCompressedArrayTexture)&&(de=!0);const Fe=B.get(_e).__webglFramebuffer;_e.isWebGLCubeRenderTarget?(Array.isArray(Fe[Xe])?rt=Fe[Xe][ot]:rt=Fe[Xe],Rt=!0):$.isWebGL2&&_e.samples>0&&oe.useMultisampledRTT(_e)===!1?rt=B.get(_e).__webglMultisampledFramebuffer:Array.isArray(Fe)?rt=Fe[ot]:rt=Fe,R.copy(_e.viewport),F.copy(_e.scissor),L=_e.scissorTest}else R.copy(re).multiplyScalar(q).floor(),F.copy(z).multiplyScalar(q).floor(),L=G;if(X.bindFramebuffer(le.FRAMEBUFFER,rt)&&$.drawBuffers&&ct&&X.drawBuffers(_e,rt),X.viewport(R),X.scissor(F),X.setScissorTest(L),Rt){const Ve=B.get(_e.texture);le.framebufferTexture2D(le.FRAMEBUFFER,le.COLOR_ATTACHMENT0,le.TEXTURE_CUBE_MAP_POSITIVE_X+Xe,Ve.__webglTexture,ot)}else if(de){const Ve=B.get(_e.texture),He=Xe||0;le.framebufferTextureLayer(le.FRAMEBUFFER,le.COLOR_ATTACHMENT0,Ve.__webglTexture,ot||0,He)}O=-1},this.readRenderTargetPixels=function(_e,Xe,ot,ct,rt,Rt,de){if(!(_e&&_e.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Re=B.get(_e).__webglFramebuffer;if(_e.isWebGLCubeRenderTarget&&de!==void 0&&(Re=Re[de]),Re){X.bindFramebuffer(le.FRAMEBUFFER,Re);try{const Ve=_e.texture,He=Ve.format,Fe=Ve.type;if(He!==So&&te.convert(He)!==le.getParameter(le.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const mt=Fe===U0&&(V.has("EXT_color_buffer_half_float")||$.isWebGL2&&V.has("EXT_color_buffer_float"));if(Fe!==Ld&&te.convert(Fe)!==le.getParameter(le.IMPLEMENTATION_COLOR_READ_TYPE)&&!(Fe===Kc&&($.isWebGL2||V.has("OES_texture_float")||V.has("WEBGL_color_buffer_float")))&&!mt){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}Xe>=0&&Xe<=_e.width-ct&&ot>=0&&ot<=_e.height-rt&&le.readPixels(Xe,ot,ct,rt,te.convert(He),te.convert(Fe),Rt)}finally{const Ve=A!==null?B.get(A).__webglFramebuffer:null;X.bindFramebuffer(le.FRAMEBUFFER,Ve)}}},this.copyFramebufferToTexture=function(_e,Xe,ot=0){const ct=Math.pow(2,-ot),rt=Math.floor(Xe.image.width*ct),Rt=Math.floor(Xe.image.height*ct);oe.setTexture2D(Xe,0),le.copyTexSubImage2D(le.TEXTURE_2D,ot,0,0,_e.x,_e.y,rt,Rt),X.unbindTexture()},this.copyTextureToTexture=function(_e,Xe,ot,ct=0){const rt=Xe.image.width,Rt=Xe.image.height,de=te.convert(ot.format),Re=te.convert(ot.type);oe.setTexture2D(ot,0),le.pixelStorei(le.UNPACK_FLIP_Y_WEBGL,ot.flipY),le.pixelStorei(le.UNPACK_PREMULTIPLY_ALPHA_WEBGL,ot.premultiplyAlpha),le.pixelStorei(le.UNPACK_ALIGNMENT,ot.unpackAlignment),Xe.isDataTexture?le.texSubImage2D(le.TEXTURE_2D,ct,_e.x,_e.y,rt,Rt,de,Re,Xe.image.data):Xe.isCompressedTexture?le.compressedTexSubImage2D(le.TEXTURE_2D,ct,_e.x,_e.y,Xe.mipmaps[0].width,Xe.mipmaps[0].height,de,Xe.mipmaps[0].data):le.texSubImage2D(le.TEXTURE_2D,ct,_e.x,_e.y,de,Re,Xe.image),ct===0&&ot.generateMipmaps&&le.generateMipmap(le.TEXTURE_2D),X.unbindTexture()},this.copyTextureToTexture3D=function(_e,Xe,ot,ct,rt=0){if(S.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const Rt=_e.max.x-_e.min.x+1,de=_e.max.y-_e.min.y+1,Re=_e.max.z-_e.min.z+1,Ve=te.convert(ct.format),He=te.convert(ct.type);let Fe;if(ct.isData3DTexture)oe.setTexture3D(ct,0),Fe=le.TEXTURE_3D;else if(ct.isDataArrayTexture)oe.setTexture2DArray(ct,0),Fe=le.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}le.pixelStorei(le.UNPACK_FLIP_Y_WEBGL,ct.flipY),le.pixelStorei(le.UNPACK_PREMULTIPLY_ALPHA_WEBGL,ct.premultiplyAlpha),le.pixelStorei(le.UNPACK_ALIGNMENT,ct.unpackAlignment);const mt=le.getParameter(le.UNPACK_ROW_LENGTH),St=le.getParameter(le.UNPACK_IMAGE_HEIGHT),kt=le.getParameter(le.UNPACK_SKIP_PIXELS),xt=le.getParameter(le.UNPACK_SKIP_ROWS),$t=le.getParameter(le.UNPACK_SKIP_IMAGES),jt=ot.isCompressedTexture?ot.mipmaps[0]:ot.image;le.pixelStorei(le.UNPACK_ROW_LENGTH,jt.width),le.pixelStorei(le.UNPACK_IMAGE_HEIGHT,jt.height),le.pixelStorei(le.UNPACK_SKIP_PIXELS,_e.min.x),le.pixelStorei(le.UNPACK_SKIP_ROWS,_e.min.y),le.pixelStorei(le.UNPACK_SKIP_IMAGES,_e.min.z),ot.isDataTexture||ot.isData3DTexture?le.texSubImage3D(Fe,rt,Xe.x,Xe.y,Xe.z,Rt,de,Re,Ve,He,jt.data):ot.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),le.compressedTexSubImage3D(Fe,rt,Xe.x,Xe.y,Xe.z,Rt,de,Re,Ve,jt.data)):le.texSubImage3D(Fe,rt,Xe.x,Xe.y,Xe.z,Rt,de,Re,Ve,He,jt),le.pixelStorei(le.UNPACK_ROW_LENGTH,mt),le.pixelStorei(le.UNPACK_IMAGE_HEIGHT,St),le.pixelStorei(le.UNPACK_SKIP_PIXELS,kt),le.pixelStorei(le.UNPACK_SKIP_ROWS,xt),le.pixelStorei(le.UNPACK_SKIP_IMAGES,$t),rt===0&&ct.generateMipmaps&&le.generateMipmap(Fe),X.unbindTexture()},this.initTexture=function(_e){_e.isCubeTexture?oe.setTextureCube(_e,0):_e.isData3DTexture?oe.setTexture3D(_e,0):_e.isDataArrayTexture||_e.isCompressedArrayTexture?oe.setTexture2DArray(_e,0):oe.setTexture2D(_e,0),X.unbindTexture()},this.resetState=function(){E=0,C=0,A=null,X.reset(),Se.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Dl}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const n=this.getContext();n.drawingBufferColorSpace=e===FO?"display-p3":"srgb",n.unpackColorSpace=mr.workingColorSpace===WN?"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===xa?bf:kJ}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===bf?xa:pu}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 pBe extends iR{}pBe.prototype.isWebGL1Renderer=!0;class VO{constructor(e,n=1,r=1e3){this.isFog=!0,this.name="",this.color=new nn(e),this.near=n,this.far=r}clone(){return new VO(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class gBe extends Xa{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 xBe{constructor(e,n){this.isInterleavedBuffer=!0,this.array=e,this.stride=n,this.count=e!==void 0?e.length/n:0,this.usage=eR,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=nu()}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=nu()),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=nu()),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 Ba=new We;class Nd{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++)Ba.fromBufferAttribute(this,n),Ba.applyMatrix4(e),this.setXYZ(n,Ba.x,Ba.y,Ba.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)Ba.fromBufferAttribute(this,n),Ba.applyNormalMatrix(e),this.setXYZ(n,Ba.x,Ba.y,Ba.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)Ba.fromBufferAttribute(this,n),Ba.transformDirection(e),this.setXYZ(n,Ba.x,Ba.y,Ba.z);return this}setX(e,n){return this.normalized&&(n=fr(n,this.array)),this.data.array[e*this.data.stride+this.offset]=n,this}setY(e,n){return this.normalized&&(n=fr(n,this.array)),this.data.array[e*this.data.stride+this.offset+1]=n,this}setZ(e,n){return this.normalized&&(n=fr(n,this.array)),this.data.array[e*this.data.stride+this.offset+2]=n,this}setW(e,n){return this.normalized&&(n=fr(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=kl(n,this.array)),n}getY(e){let n=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(n=kl(n,this.array)),n}getZ(e){let n=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(n=kl(n,this.array)),n}getW(e){let n=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(n=kl(n,this.array)),n}setXY(e,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(n=fr(n,this.array),r=fr(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=fr(n,this.array),r=fr(r,this.array),i=fr(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=fr(n,this.array),r=fr(r,this.array),i=fr(i,this.array),a=fr(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 qs(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 Nd(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 bBe extends vs{constructor(e=null,n=1,r=1,i,a,o,l,c,u=ga,d=ga,f,m){super(null,o,l,c,u,d,i,a,f,m),this.isDataTexture=!0,this.image={data:e,width:n,height:r},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}function yBe(t,e){return t.z-e.z}function vBe(t,e){return e.z-t.z}class _Be{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 _p="batchId",rd=new Er,z7=new Er,wBe=new Er,B7=new Er,Pk=new qN,m1=new Co,Fh=new Il,bb=new We,Rk=new _Be,Ca=new rl,p1=[];function SBe(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 NBe extends rl{get maxGeometryCount(){return this._maxGeometryCount}constructor(e,n,r=n*2,i){super(new Ia,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 bBe(n,e,e,So,Kc);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,m=new u.constructor(r*d),p=new c.constructor(m,d,f);p.setUsage(c.usage),n.setAttribute(l,p)}if(e.getIndex()!==null){const l=r>65536?new Uint32Array(a):new Uint16Array(a);n.setIndex(new qs(l,1))}const o=i>65536?new Uint32Array(r):new Uint16Array(r);n.setAttribute(_p,new qs(o,1)),this._geometryInitialized=!0}}_validateGeometry(e){if(e.getAttribute(_p))throw new Error(`BatchedMesh: Geometry cannot use attribute "${_p}"`);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===_p)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 Co);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,m1).applyMatrix4(rd),n.union(m1))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Il);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,Fh).applyMatrix4(rd),n.union(Fh))}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,m=this._active,p=this._matricesTexture,x=this._matricesTexture.image.data;f.push(!0),m.push(!0);const y=this._geometryCount;this._geometryCount++,wBe.toArray(x,y*16),p.needsUpdate=!0,o.push(i),l.push({start:d?i.indexStart:i.vertexStart,count:-1}),c.push({boxInitialized:!1,box:new Co,sphereInitialized:!1,sphere:new Il});const b=this.geometry.getAttribute(_p);for(let v=0;v<i.vertexCount;v++)b.setX(i.vertexStart+v,y);return b.needsUpdate=!0,this.setGeometryAt(y,e),y}setGeometryAt(e,n){if(e>=this._geometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");this._validateGeometry(n);const r=this.geometry,i=r.getIndex()!==null,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 p in r.attributes){if(p===_p)continue;const x=n.getAttribute(p),y=r.getAttribute(p);SBe(x,y,c);const b=x.itemSize;for(let v=x.count,N=u;v<N;v++){const S=c+v;for(let T=0;T<b;T++)y.setComponent(S,T,0)}y.needsUpdate=!0}if(i){const p=l.indexStart;for(let x=0;x<o.count;x++)a.setX(p+x,c+o.getX(x));for(let x=o.count,y=l.indexCount;x<y;x++)a.setX(p+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],m=n.getAttribute("position");return f.count=i?o.count:m.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 m=d;l&&(m=l.getX(m)),a.expandByPoint(bb.fromBufferAttribute(c,m))}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,m1),m1.getCenter(a.center);const l=o.index,c=o.attributes.position,u=this._drawRanges[e];let d=0;for(let f=u.start,m=u.start+u.count;f<m;f++){let p=f;l&&(p=l.getX(p)),bb.fromBufferAttribute(c,p),d=Math.max(d,a.center.distanceToSquared(bb))}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;Ca.material=this.material,Ca.geometry.index=c.index,Ca.geometry.attributes=c.attributes,Ca.geometry.boundingBox===null&&(Ca.geometry.boundingBox=new Co),Ca.geometry.boundingSphere===null&&(Ca.geometry.boundingSphere=new Il);for(let u=0;u<o;u++){if(!r[u]||!i[u])continue;const d=a[u];Ca.geometry.setDrawRange(d.start,d.count),this.getMatrixAt(u,Ca.matrixWorld).premultiply(l),this.getBoundingBoxAt(u,Ca.geometry.boundingBox),this.getBoundingSphereAt(u,Ca.geometry.boundingSphere),Ca.raycast(e,p1);for(let f=0,m=p1.length;f<m;f++){const p=p1[f];p.object=this,p.batchId=u,n.push(p)}p1.length=0}Ca.material=null,Ca.geometry.index=null,Ca.geometry.attributes={},Ca.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,m=this.perObjectFrustumCulled;m&&(B7.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse).multiply(this.matrixWorld),Pk.setFromProjectionMatrix(B7,e.isWebGPURenderer?z0:Dl));let p=0;if(this.sortObjects){z7.copy(this.matrixWorld).invert(),bb.setFromMatrixPosition(r.matrixWorld).applyMatrix4(z7);for(let b=0,v=c.length;b<v;b++)if(c[b]){this.getMatrixAt(b,rd),this.getBoundingSphereAt(b,Fh).applyMatrix4(rd);let N=!1;if(m&&(N=!Pk.intersectsSphere(Fh)),!N){const S=bb.distanceTo(Fh.center);Rk.push(f[b],S)}}const x=Rk.list,y=this.customSort;y===null?x.sort(a.transparent?vBe:yBe):y.call(this,x,r);for(let b=0,v=x.length;b<v;b++){const N=x[b];u[p]=N.start*l,d[p]=N.count,p++}Rk.reset()}else for(let x=0,y=c.length;x<y;x++)if(c[x]){let b=!1;if(m&&(this.getMatrixAt(x,rd),this.getBoundingSphereAt(x,Fh).applyMatrix4(rd),b=!Pk.intersectsSphere(Fh)),!b){const v=f[x];u[p]=v.start*l,d[p]=v.count,p++}}this._multiDrawCount=p,this._visibilityChanged=!1}onBeforeShadow(e,n,r,i,a,o){this.onBeforeRender(e,null,i,a,o)}}class Iy extends tx{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new nn(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 $7=new We,H7=new We,V7=new Er,Dk=new zO,g1=new Il;class MBe extends Xa{constructor(e=new Ia,n=new Iy){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++)$7.fromBufferAttribute(n,i-1),H7.fromBufferAttribute(n,i),r[i]=r[i-1],r[i]+=$7.distanceTo(H7);e.setAttribute("lineDistance",new hi(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(),g1.copy(r.boundingSphere),g1.applyMatrix4(i),g1.radius+=a,e.ray.intersectsSphere(g1)===!1)return;V7.copy(i).invert(),Dk.copy(e.ray).applyMatrix4(V7);const l=a/((this.scale.x+this.scale.y+this.scale.z)/3),c=l*l,u=new We,d=new We,f=new We,m=new We,p=this.isLineSegments?2:1,x=r.index,b=r.attributes.position;if(x!==null){const v=Math.max(0,o.start),N=Math.min(x.count,o.start+o.count);for(let S=v,T=N-1;S<T;S+=p){const E=x.getX(S),C=x.getX(S+1);if(u.fromBufferAttribute(b,E),d.fromBufferAttribute(b,C),Dk.distanceSqToSegment(u,d,m,f)>c)continue;m.applyMatrix4(this.matrixWorld);const O=e.ray.origin.distanceTo(m);O<e.near||O>e.far||n.push({distance:O,point:f.clone().applyMatrix4(this.matrixWorld),index:S,face:null,faceIndex:null,object:this})}}else{const v=Math.max(0,o.start),N=Math.min(b.count,o.start+o.count);for(let S=v,T=N-1;S<T;S+=p){if(u.fromBufferAttribute(b,S),d.fromBufferAttribute(b,S+1),Dk.distanceSqToSegment(u,d,m,f)>c)continue;m.applyMatrix4(this.matrixWorld);const C=e.ray.origin.distanceTo(m);C<e.near||C>e.far||n.push({distance:C,point:f.clone().applyMatrix4(this.matrixWorld),index:S,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 G7=new We,W7=new We;class XN extends MBe{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)G7.fromBufferAttribute(n,i),W7.fromBufferAttribute(n,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+G7.distanceTo(W7);e.setAttribute("lineDistance",new hi(r,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class EBe extends Ia{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const n=[],r=new Set,i=new We,a=new We;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],m=f.start,p=f.count;for(let x=m,y=m+p;x<y;x+=3)for(let b=0;b<3;b++){const v=l.getX(x+b),N=l.getX(x+(b+1)%3);i.fromBufferAttribute(o,v),a.fromBufferAttribute(o,N),q7(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),q7(i,a,r)===!0&&(n.push(i.x,i.y,i.z),n.push(a.x,a.y,a.z))}}this.setAttribute("position",new hi(n,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function q7(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 TBe extends tx{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new nn(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new nn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=jJ,this.normalScale=new pn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=LO,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 ABe extends Iy{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 JJ extends Xa{constructor(e,n=1){super(),this.isLight=!0,this.type="Light",this.color=new nn(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 Ok=new Er,K7=new We,X7=new We;class CBe{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new pn(512,512),this.map=null,this.mapPass=null,this.matrix=new Er,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new qN,this._frameExtents=new pn(1,1),this._viewportCount=1,this._viewports=[new gr(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const n=this.camera,r=this.matrix;K7.setFromMatrixPosition(e.matrixWorld),n.position.copy(K7),X7.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(X7),n.updateMatrixWorld(),Ok.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Ok),r.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),r.multiply(Ok)}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 Y7=new Er,yb=new We,Lk=new We;class kBe extends CBe{constructor(){super(new Us(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new pn(4,2),this._viewportCount=6,this._viewports=[new gr(2,1,1,1),new gr(0,1,1,1),new gr(3,1,1,1),new gr(1,1,1,1),new gr(3,0,1,1),new gr(1,0,1,1)],this._cubeDirections=[new We(1,0,0),new We(-1,0,0),new We(0,0,1),new We(0,0,-1),new We(0,1,0),new We(0,-1,0)],this._cubeUps=[new We(0,1,0),new We(0,1,0),new We(0,1,0),new We(0,1,0),new We(0,0,1),new We(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()),yb.setFromMatrixPosition(e.matrixWorld),r.position.copy(yb),Lk.copy(r.position),Lk.add(this._cubeDirections[n]),r.up.copy(this._cubeUps[n]),r.lookAt(Lk),r.updateMatrixWorld(),i.makeTranslation(-yb.x,-yb.y,-yb.z),Y7.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Y7)}}class jBe extends JJ{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 kBe}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 PBe extends JJ{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}}class RBe extends Ia{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 aR extends xBe{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 Q7{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(ba(n/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}const Z7=new We,x1=new We;class DBe{constructor(e=new We,n=new We){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){Z7.subVectors(e,this.start),x1.subVectors(this.end,this.start);const r=x1.dot(x1);let a=x1.dot(Z7)/r;return n&&(a=ba(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 OBe extends XN{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 Ia;i.setAttribute("position",new hi(n,3)),i.setAttribute("color",new hi(r,3));const a=new Iy({vertexColors:!0,toneMapped:!1});super(i,a),this.type="AxesHelper"}setColors(e,n,r){const i=new nn,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:VN}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=VN);class Fl{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"),Fl.nextNameID=Fl.nextNameID||0,this.$name.id=`lil-gui-name-${++Fl.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 LBe extends Fl{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 sR(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 IBe={isPrimitive:!0,match:t=>typeof t=="string",fromHexString:sR,toHexString:sR},$0={isPrimitive:!0,match:t=>typeof t=="number",fromHexString:t=>parseInt(t.substring(1),16),toHexString:t=>"#"+t.toString(16).padStart(6,0)},FBe={isPrimitive:!1,match:t=>Array.isArray(t),fromHexString(t,e,n=1){const r=$0.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 $0.toHexString(i)}},UBe={isPrimitive:!1,match:t=>Object(t)===t,fromHexString(t,e,n=1){const r=$0.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 $0.toHexString(i)}},zBe=[IBe,$0,FBe,UBe];function BBe(t){return zBe.find(e=>e.match(t))}class $Be extends Fl{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=BBe(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=sR(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 Ik extends Fl{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 HBe extends Fl{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 N=parseFloat(this.$input.value);isNaN(N)||(this._stepExplicit&&(N=this._snap(N)),this.setValue(this._clamp(N)))},r=N=>{const S=parseFloat(this.$input.value);isNaN(S)||(this._snapClampSetValue(S+N),this.$input.value=this.getValue())},i=N=>{N.key==="Enter"&&this.$input.blur(),N.code==="ArrowUp"&&(N.preventDefault(),r(this._step*this._arrowKeyMultiplier(N))),N.code==="ArrowDown"&&(N.preventDefault(),r(this._step*this._arrowKeyMultiplier(N)*-1))},a=N=>{this._inputFocused&&(N.preventDefault(),r(this._step*this._normalizeMouseWheel(N)))};let o=!1,l,c,u,d,f;const m=5,p=N=>{l=N.clientX,c=u=N.clientY,o=!0,d=this.getValue(),f=0,window.addEventListener("mousemove",x),window.addEventListener("mouseup",y)},x=N=>{if(o){const S=N.clientX-l,T=N.clientY-c;Math.abs(T)>m?(N.preventDefault(),this.$input.blur(),o=!1,this._setDraggingStyle(!0,"vertical")):Math.abs(S)>m&&y()}if(!o){const S=N.clientY-u;f-=S*this._step*this._arrowKeyMultiplier(N),d+f>this._max?f=this._max-d:d+f<this._min&&(f=this._min-d),this._snapClampSetValue(d+f)}u=N.clientY},y=()=>{this._setDraggingStyle(!1,"vertical"),this._callOnFinishChange(),window.removeEventListener("mousemove",x),window.removeEventListener("mouseup",y)},b=()=>{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",p),this.$input.addEventListener("focus",b),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,N,S,T,E)=>(v-N)/(S-N)*(E-T)+T,n=v=>{const N=this.$slider.getBoundingClientRect();let S=e(v,N.left,N.right,this._min,this._max);this._snapClampSetValue(S)},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",m))},f=v=>{if(o){const N=v.touches[0].clientX-l,S=v.touches[0].clientY-c;Math.abs(N)>Math.abs(S)?u(v):(window.removeEventListener("touchmove",f),window.removeEventListener("touchend",m))}else v.preventDefault(),n(v.touches[0].clientX)},m=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("touchmove",f),window.removeEventListener("touchend",m)},p=this._callOnFinishChange.bind(this),x=400;let y;const b=v=>{if(Math.abs(v.deltaX)<Math.abs(v.deltaY)&&this._hasScrollBar)return;v.preventDefault();const S=this._normalizeMouseWheel(v)*this._step;this._snapClampSetValue(this.getValue()+S),this.$input.value=this.getValue(),clearTimeout(y),y=setTimeout(p,x)};this.$slider.addEventListener("mousedown",r),this.$slider.addEventListener("touchstart",d,{passive:!1}),this.$slider.addEventListener("wheel",b,{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 VBe extends Fl{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 GBe extends Fl{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 WBe=`.lil-gui {
  7477. font-family: var(--font-family);
  7478. font-size: var(--font-size);
  7479. line-height: 1;
  7480. font-weight: normal;
  7481. font-style: normal;
  7482. text-align: left;
  7483. color: var(--text-color);
  7484. user-select: none;
  7485. -webkit-user-select: none;
  7486. touch-action: manipulation;
  7487. --background-color: #1f1f1f;
  7488. --text-color: #ebebeb;
  7489. --title-background-color: #111111;
  7490. --title-text-color: #ebebeb;
  7491. --widget-color: #424242;
  7492. --hover-color: #4f4f4f;
  7493. --focus-color: #595959;
  7494. --number-color: #2cc9ff;
  7495. --string-color: #a2db3c;
  7496. --font-size: 11px;
  7497. --input-font-size: 11px;
  7498. --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  7499. --font-family-mono: Menlo, Monaco, Consolas, "Droid Sans Mono", monospace;
  7500. --padding: 4px;
  7501. --spacing: 4px;
  7502. --widget-height: 20px;
  7503. --title-height: calc(var(--widget-height) + var(--spacing) * 1.25);
  7504. --name-width: 45%;
  7505. --slider-knob-width: 2px;
  7506. --slider-input-width: 27%;
  7507. --color-input-width: 27%;
  7508. --slider-input-min-width: 45px;
  7509. --color-input-min-width: 45px;
  7510. --folder-indent: 7px;
  7511. --widget-padding: 0 0 0 3px;
  7512. --widget-border-radius: 2px;
  7513. --checkbox-size: calc(0.75 * var(--widget-height));
  7514. --scrollbar-width: 5px;
  7515. }
  7516. .lil-gui, .lil-gui * {
  7517. box-sizing: border-box;
  7518. margin: 0;
  7519. padding: 0;
  7520. }
  7521. .lil-gui.root {
  7522. width: var(--width, 245px);
  7523. display: flex;
  7524. flex-direction: column;
  7525. background: var(--background-color);
  7526. }
  7527. .lil-gui.root > .title {
  7528. background: var(--title-background-color);
  7529. color: var(--title-text-color);
  7530. }
  7531. .lil-gui.root > .children {
  7532. overflow-x: hidden;
  7533. overflow-y: auto;
  7534. }
  7535. .lil-gui.root > .children::-webkit-scrollbar {
  7536. width: var(--scrollbar-width);
  7537. height: var(--scrollbar-width);
  7538. background: var(--background-color);
  7539. }
  7540. .lil-gui.root > .children::-webkit-scrollbar-thumb {
  7541. border-radius: var(--scrollbar-width);
  7542. background: var(--focus-color);
  7543. }
  7544. @media (pointer: coarse) {
  7545. .lil-gui.allow-touch-styles, .lil-gui.allow-touch-styles .lil-gui {
  7546. --widget-height: 28px;
  7547. --padding: 6px;
  7548. --spacing: 6px;
  7549. --font-size: 13px;
  7550. --input-font-size: 16px;
  7551. --folder-indent: 10px;
  7552. --scrollbar-width: 7px;
  7553. --slider-input-min-width: 50px;
  7554. --color-input-min-width: 65px;
  7555. }
  7556. }
  7557. .lil-gui.force-touch-styles, .lil-gui.force-touch-styles .lil-gui {
  7558. --widget-height: 28px;
  7559. --padding: 6px;
  7560. --spacing: 6px;
  7561. --font-size: 13px;
  7562. --input-font-size: 16px;
  7563. --folder-indent: 10px;
  7564. --scrollbar-width: 7px;
  7565. --slider-input-min-width: 50px;
  7566. --color-input-min-width: 65px;
  7567. }
  7568. .lil-gui.autoPlace {
  7569. max-height: 100%;
  7570. position: fixed;
  7571. top: 0;
  7572. right: 15px;
  7573. z-index: 1001;
  7574. }
  7575. .lil-gui .controller {
  7576. display: flex;
  7577. align-items: center;
  7578. padding: 0 var(--padding);
  7579. margin: var(--spacing) 0;
  7580. }
  7581. .lil-gui .controller.disabled {
  7582. opacity: 0.5;
  7583. }
  7584. .lil-gui .controller.disabled, .lil-gui .controller.disabled * {
  7585. pointer-events: none !important;
  7586. }
  7587. .lil-gui .controller > .name {
  7588. min-width: var(--name-width);
  7589. flex-shrink: 0;
  7590. white-space: pre;
  7591. padding-right: var(--spacing);
  7592. line-height: var(--widget-height);
  7593. }
  7594. .lil-gui .controller .widget {
  7595. position: relative;
  7596. display: flex;
  7597. align-items: center;
  7598. width: 100%;
  7599. min-height: var(--widget-height);
  7600. }
  7601. .lil-gui .controller.string input {
  7602. color: var(--string-color);
  7603. }
  7604. .lil-gui .controller.boolean {
  7605. cursor: pointer;
  7606. }
  7607. .lil-gui .controller.color .display {
  7608. width: 100%;
  7609. height: var(--widget-height);
  7610. border-radius: var(--widget-border-radius);
  7611. position: relative;
  7612. }
  7613. @media (hover: hover) {
  7614. .lil-gui .controller.color .display:hover:before {
  7615. content: " ";
  7616. display: block;
  7617. position: absolute;
  7618. border-radius: var(--widget-border-radius);
  7619. border: 1px solid #fff9;
  7620. top: 0;
  7621. right: 0;
  7622. bottom: 0;
  7623. left: 0;
  7624. }
  7625. }
  7626. .lil-gui .controller.color input[type=color] {
  7627. opacity: 0;
  7628. width: 100%;
  7629. height: 100%;
  7630. cursor: pointer;
  7631. }
  7632. .lil-gui .controller.color input[type=text] {
  7633. margin-left: var(--spacing);
  7634. font-family: var(--font-family-mono);
  7635. min-width: var(--color-input-min-width);
  7636. width: var(--color-input-width);
  7637. flex-shrink: 0;
  7638. }
  7639. .lil-gui .controller.option select {
  7640. opacity: 0;
  7641. position: absolute;
  7642. width: 100%;
  7643. max-width: 100%;
  7644. }
  7645. .lil-gui .controller.option .display {
  7646. position: relative;
  7647. pointer-events: none;
  7648. border-radius: var(--widget-border-radius);
  7649. height: var(--widget-height);
  7650. line-height: var(--widget-height);
  7651. max-width: 100%;
  7652. overflow: hidden;
  7653. word-break: break-all;
  7654. padding-left: 0.55em;
  7655. padding-right: 1.75em;
  7656. background: var(--widget-color);
  7657. }
  7658. @media (hover: hover) {
  7659. .lil-gui .controller.option .display.focus {
  7660. background: var(--focus-color);
  7661. }
  7662. }
  7663. .lil-gui .controller.option .display.active {
  7664. background: var(--focus-color);
  7665. }
  7666. .lil-gui .controller.option .display:after {
  7667. font-family: "lil-gui";
  7668. content: "↕";
  7669. position: absolute;
  7670. top: 0;
  7671. right: 0;
  7672. bottom: 0;
  7673. padding-right: 0.375em;
  7674. }
  7675. .lil-gui .controller.option .widget,
  7676. .lil-gui .controller.option select {
  7677. cursor: pointer;
  7678. }
  7679. @media (hover: hover) {
  7680. .lil-gui .controller.option .widget:hover .display {
  7681. background: var(--hover-color);
  7682. }
  7683. }
  7684. .lil-gui .controller.number input {
  7685. color: var(--number-color);
  7686. }
  7687. .lil-gui .controller.number.hasSlider input {
  7688. margin-left: var(--spacing);
  7689. width: var(--slider-input-width);
  7690. min-width: var(--slider-input-min-width);
  7691. flex-shrink: 0;
  7692. }
  7693. .lil-gui .controller.number .slider {
  7694. width: 100%;
  7695. height: var(--widget-height);
  7696. background: var(--widget-color);
  7697. border-radius: var(--widget-border-radius);
  7698. padding-right: var(--slider-knob-width);
  7699. overflow: hidden;
  7700. cursor: ew-resize;
  7701. touch-action: pan-y;
  7702. }
  7703. @media (hover: hover) {
  7704. .lil-gui .controller.number .slider:hover {
  7705. background: var(--hover-color);
  7706. }
  7707. }
  7708. .lil-gui .controller.number .slider.active {
  7709. background: var(--focus-color);
  7710. }
  7711. .lil-gui .controller.number .slider.active .fill {
  7712. opacity: 0.95;
  7713. }
  7714. .lil-gui .controller.number .fill {
  7715. height: 100%;
  7716. border-right: var(--slider-knob-width) solid var(--number-color);
  7717. box-sizing: content-box;
  7718. }
  7719. .lil-gui-dragging .lil-gui {
  7720. --hover-color: var(--widget-color);
  7721. }
  7722. .lil-gui-dragging * {
  7723. cursor: ew-resize !important;
  7724. }
  7725. .lil-gui-dragging.lil-gui-vertical * {
  7726. cursor: ns-resize !important;
  7727. }
  7728. .lil-gui .title {
  7729. height: var(--title-height);
  7730. line-height: calc(var(--title-height) - 4px);
  7731. font-weight: 600;
  7732. padding: 0 var(--padding);
  7733. -webkit-tap-highlight-color: transparent;
  7734. cursor: pointer;
  7735. outline: none;
  7736. text-decoration-skip: objects;
  7737. }
  7738. .lil-gui .title:before {
  7739. font-family: "lil-gui";
  7740. content: "▾";
  7741. padding-right: 2px;
  7742. display: inline-block;
  7743. }
  7744. .lil-gui .title:active {
  7745. background: var(--title-background-color);
  7746. opacity: 0.75;
  7747. }
  7748. @media (hover: hover) {
  7749. body:not(.lil-gui-dragging) .lil-gui .title:hover {
  7750. background: var(--title-background-color);
  7751. opacity: 0.85;
  7752. }
  7753. .lil-gui .title:focus {
  7754. text-decoration: underline var(--focus-color);
  7755. }
  7756. }
  7757. .lil-gui.root > .title:focus {
  7758. text-decoration: none !important;
  7759. }
  7760. .lil-gui.closed > .title:before {
  7761. content: "▸";
  7762. }
  7763. .lil-gui.closed > .children {
  7764. transform: translateY(-7px);
  7765. opacity: 0;
  7766. }
  7767. .lil-gui.closed:not(.transition) > .children {
  7768. display: none;
  7769. }
  7770. .lil-gui.transition > .children {
  7771. transition-duration: 300ms;
  7772. transition-property: height, opacity, transform;
  7773. transition-timing-function: cubic-bezier(0.2, 0.6, 0.35, 1);
  7774. overflow: hidden;
  7775. pointer-events: none;
  7776. }
  7777. .lil-gui .children:empty:before {
  7778. content: "Empty";
  7779. padding: 0 var(--padding);
  7780. margin: var(--spacing) 0;
  7781. display: block;
  7782. height: var(--widget-height);
  7783. font-style: italic;
  7784. line-height: var(--widget-height);
  7785. opacity: 0.5;
  7786. }
  7787. .lil-gui.root > .children > .lil-gui > .title {
  7788. border: 0 solid var(--widget-color);
  7789. border-width: 1px 0;
  7790. transition: border-color 300ms;
  7791. }
  7792. .lil-gui.root > .children > .lil-gui.closed > .title {
  7793. border-bottom-color: transparent;
  7794. }
  7795. .lil-gui + .controller {
  7796. border-top: 1px solid var(--widget-color);
  7797. margin-top: 0;
  7798. padding-top: var(--spacing);
  7799. }
  7800. .lil-gui .lil-gui .lil-gui > .title {
  7801. border: none;
  7802. }
  7803. .lil-gui .lil-gui .lil-gui > .children {
  7804. border: none;
  7805. margin-left: var(--folder-indent);
  7806. border-left: 2px solid var(--widget-color);
  7807. }
  7808. .lil-gui .lil-gui .controller {
  7809. border: none;
  7810. }
  7811. .lil-gui label, .lil-gui input, .lil-gui button {
  7812. -webkit-tap-highlight-color: transparent;
  7813. }
  7814. .lil-gui input {
  7815. border: 0;
  7816. outline: none;
  7817. font-family: var(--font-family);
  7818. font-size: var(--input-font-size);
  7819. border-radius: var(--widget-border-radius);
  7820. height: var(--widget-height);
  7821. background: var(--widget-color);
  7822. color: var(--text-color);
  7823. width: 100%;
  7824. }
  7825. @media (hover: hover) {
  7826. .lil-gui input:hover {
  7827. background: var(--hover-color);
  7828. }
  7829. .lil-gui input:active {
  7830. background: var(--focus-color);
  7831. }
  7832. }
  7833. .lil-gui input:disabled {
  7834. opacity: 1;
  7835. }
  7836. .lil-gui input[type=text],
  7837. .lil-gui input[type=number] {
  7838. padding: var(--widget-padding);
  7839. -moz-appearance: textfield;
  7840. }
  7841. .lil-gui input[type=text]:focus,
  7842. .lil-gui input[type=number]:focus {
  7843. background: var(--focus-color);
  7844. }
  7845. .lil-gui input[type=checkbox] {
  7846. appearance: none;
  7847. width: var(--checkbox-size);
  7848. height: var(--checkbox-size);
  7849. border-radius: var(--widget-border-radius);
  7850. text-align: center;
  7851. cursor: pointer;
  7852. }
  7853. .lil-gui input[type=checkbox]:checked:before {
  7854. font-family: "lil-gui";
  7855. content: "✓";
  7856. font-size: var(--checkbox-size);
  7857. line-height: var(--checkbox-size);
  7858. }
  7859. @media (hover: hover) {
  7860. .lil-gui input[type=checkbox]:focus {
  7861. box-shadow: inset 0 0 0 1px var(--focus-color);
  7862. }
  7863. }
  7864. .lil-gui button {
  7865. outline: none;
  7866. cursor: pointer;
  7867. font-family: var(--font-family);
  7868. font-size: var(--font-size);
  7869. color: var(--text-color);
  7870. width: 100%;
  7871. height: var(--widget-height);
  7872. text-transform: none;
  7873. background: var(--widget-color);
  7874. border-radius: var(--widget-border-radius);
  7875. border: none;
  7876. }
  7877. @media (hover: hover) {
  7878. .lil-gui button:hover {
  7879. background: var(--hover-color);
  7880. }
  7881. .lil-gui button:focus {
  7882. box-shadow: inset 0 0 0 1px var(--focus-color);
  7883. }
  7884. }
  7885. .lil-gui button:active {
  7886. background: var(--focus-color);
  7887. }
  7888. @font-face {
  7889. font-family: "lil-gui";
  7890. src: url("data:application/font-woff;charset=utf-8;base64,d09GRgABAAAAAAUsAAsAAAAACJwAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABHU1VCAAABCAAAAH4AAADAImwmYE9TLzIAAAGIAAAAPwAAAGBKqH5SY21hcAAAAcgAAAD0AAACrukyyJBnbHlmAAACvAAAAF8AAACEIZpWH2hlYWQAAAMcAAAAJwAAADZfcj2zaGhlYQAAA0QAAAAYAAAAJAC5AHhobXR4AAADXAAAABAAAABMAZAAAGxvY2EAAANsAAAAFAAAACgCEgIybWF4cAAAA4AAAAAeAAAAIAEfABJuYW1lAAADoAAAASIAAAIK9SUU/XBvc3QAAATEAAAAZgAAAJCTcMc2eJxVjbEOgjAURU+hFRBK1dGRL+ALnAiToyMLEzFpnPz/eAshwSa97517c/MwwJmeB9kwPl+0cf5+uGPZXsqPu4nvZabcSZldZ6kfyWnomFY/eScKqZNWupKJO6kXN3K9uCVoL7iInPr1X5baXs3tjuMqCtzEuagm/AAlzQgPAAB4nGNgYRBlnMDAysDAYM/gBiT5oLQBAwuDJAMDEwMrMwNWEJDmmsJwgCFeXZghBcjlZMgFCzOiKOIFAB71Bb8AeJy1kjFuwkAQRZ+DwRAwBtNQRUGKQ8OdKCAWUhAgKLhIuAsVSpWz5Bbkj3dEgYiUIszqWdpZe+Z7/wB1oCYmIoboiwiLT2WjKl/jscrHfGg/pKdMkyklC5Zs2LEfHYpjcRoPzme9MWWmk3dWbK9ObkWkikOetJ554fWyoEsmdSlt+uR0pCJR34b6t/TVg1SY3sYvdf8vuiKrpyaDXDISiegp17p7579Gp3p++y7HPAiY9pmTibljrr85qSidtlg4+l25GLCaS8e6rRxNBmsnERunKbaOObRz7N72ju5vdAjYpBXHgJylOAVsMseDAPEP8LYoUHicY2BiAAEfhiAGJgZWBgZ7RnFRdnVJELCQlBSRlATJMoLV2DK4glSYs6ubq5vbKrJLSbGrgEmovDuDJVhe3VzcXFwNLCOILB/C4IuQ1xTn5FPilBTj5FPmBAB4WwoqAHicY2BkYGAA4sk1sR/j+W2+MnAzpDBgAyEMQUCSg4EJxAEAwUgFHgB4nGNgZGBgSGFggJMhDIwMqEAYAByHATJ4nGNgAIIUNEwmAABl3AGReJxjYAACIQYlBiMGJ3wQAEcQBEV4nGNgZGBgEGZgY2BiAAEQyQWEDAz/wXwGAAsPATIAAHicXdBNSsNAHAXwl35iA0UQXYnMShfS9GPZA7T7LgIu03SSpkwzYTIt1BN4Ak/gKTyAeCxfw39jZkjymzcvAwmAW/wgwHUEGDb36+jQQ3GXGot79L24jxCP4gHzF/EIr4jEIe7wxhOC3g2TMYy4Q7+Lu/SHuEd/ivt4wJd4wPxbPEKMX3GI5+DJFGaSn4qNzk8mcbKSR6xdXdhSzaOZJGtdapd4vVPbi6rP+cL7TGXOHtXKll4bY1Xl7EGnPtp7Xy2n00zyKLVHfkHBa4IcJ2oD3cgggWvt/V/FbDrUlEUJhTn/0azVWbNTNr0Ens8de1tceK9xZmfB1CPjOmPH4kitmvOubcNpmVTN3oFJyjzCvnmrwhJTzqzVj9jiSX911FjeAAB4nG3HMRKCMBBA0f0giiKi4DU8k0V2GWbIZDOh4PoWWvq6J5V8If9NVNQcaDhyouXMhY4rPTcG7jwYmXhKq8Wz+p762aNaeYXom2n3m2dLTVgsrCgFJ7OTmIkYbwIbC6vIB7WmFfAAAA==") format("woff");
  7891. }`;function qBe(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 J7=!1;class jS{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"),!J7&&l&&(qBe(WBe),J7=!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 VBe(this,e,n,r);const o=e[n];switch(typeof o){case"number":return new HBe(this,e,n,r,i,a);case"boolean":return new LBe(this,e,n);case"string":return new GBe(this,e,n);case"function":return new Ik(this,e,n)}console.error(`gui.add failed
  7892. property:`,n,`
  7893. object:`,e,`
  7894. value:`,o)}addColor(e,n,r=1){return new $Be(this,e,n,r)}addFolder(e){const n=new jS({parent:this,title:e});return this.root._closeFolders&&n.close(),n}load(e,n=!0){return e.controllers&&this.controllers.forEach(r=>{r instanceof Ik||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 Ik)){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 Fk(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 GO{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 GO(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 WO{constructor(e,n,r,i){this.src=e,this.gcode=n,this.params=r,this.comment=i}}class e9 extends WO{constructor(e,n,r,i){super(e,n,r,i),this.params=r}}class id extends WO{constructor(e,n,r,i){super(e,n,void 0,r),this.toolIndex=i}}class t9{constructor(e,n,r,i=0){this.layer=e,this.commands=n,this.lineNumber=r,this.height=i}}class PS{constructor(e){this.lines=[],this.preamble=new t9(-1,[],0),this.layers=[],this.curZ=0,this.maxZ=0,this.metadata={thumbnails:{}},this.tolerance=0,this.tolerance=e??this.tolerance}parseGCode(e){const n=Array.isArray(e)?e:e.split(`
  7895. `);this.lines=this.lines.concat(n);const r=this.lines2commands(n);this.groupIntoLayers(r);const i=this.parseMetadata(r.filter((a=>a.comment))).thumbnails;for(const[a,o]of Object.entries(i))this.metadata.thumbnails[a]=o;return{layers:this.layers,metadata:this.metadata}}lines2commands(e){return e.map((n=>this.parseCommand(n)))}parseCommand(e,n=!0){var r;const i=e.trim().split(";"),a=i[0],o=n&&i[1]||void 0,l=a.split(/([a-zA-Z])/g).slice(1).map((d=>d.trim())),c=l.length?`${(r=l[0])===null||r===void 0?void 0:r.toLowerCase()}${l[1]}`:"",u=this.parseParams(l.slice(2));switch(c){case"g0":case"g00":case"g1":case"g01":case"g2":case"g02":case"g3":case"g03":return new e9(e,c,u,o);case"t0":return new id(e,c,o,0);case"t1":return new id(e,c,o,1);case"t2":return new id(e,c,o,2);case"t3":return new id(e,c,o,3);case"t4":return new id(e,c,o,4);case"t5":return new id(e,c,o,5);case"t6":return new id(e,c,o,6);case"t7":return new id(e,c,o,7);default:return new WO(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 e9){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 t9(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=GO.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}}}PS.prototype.parseGcode=PS.prototype.parseGCode;const n9={type:"change"},Uk={type:"start"},r9={type:"end"},b1=new zO,i9=new dd,KBe=Math.cos(70*RJ.DEG2RAD);class XBe extends rm{constructor(e,n){super(),this.object=e,this.domElement=n,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new We,this.cursor=new We,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:ip.ROTATE,TWO:ip.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($){$.addEventListener("keydown",fe),this._domElementKeyEvents=$},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",fe),this._domElementKeyEvents=null},this.saveState=function(){r.target0.copy(r.target),r.position0.copy(r.object.position),r.zoom0=r.object.zoom},this.reset=function(){r.target.copy(r.target0),r.object.position.copy(r.position0),r.object.zoom=r.zoom0,r.object.updateProjectionMatrix(),r.dispatchEvent(n9),r.update(),a=i.NONE},this.update=(function(){const $=new We,X=new Gf().setFromUnitVectors(e.up,new We(0,1,0)),U=X.clone().invert(),B=new We,oe=new Gf,Te=new We,je=2*Math.PI;return function(Ce=null){const H=r.object.position;$.copy(H).sub(r.target),$.applyQuaternion(X),l.setFromVector3($),r.autoRotate&&a===i.NONE&&R((function(Ne){return Ne!==null?2*Math.PI/60*r.autoRotateSpeed*Ne:2*Math.PI/60/60*r.autoRotateSpeed})(Ce)),r.enableDamping?(l.theta+=c.theta*r.dampingFactor,l.phi+=c.phi*r.dampingFactor):(l.theta+=c.theta,l.phi+=c.phi);let D=r.minAzimuthAngle,Z=r.maxAzimuthAngle;isFinite(D)&&isFinite(Z)&&(D<-Math.PI?D+=je:D>Math.PI&&(D-=je),Z<-Math.PI?Z+=je:Z>Math.PI&&(Z-=je),l.theta=D<=Z?Math.max(D,Math.min(Z,l.theta)):l.theta>(D+Z)/2?Math.max(D,l.theta):Math.min(Z,l.theta)),l.phi=Math.max(r.minPolarAngle,Math.min(r.maxPolarAngle,l.phi)),l.makeSafe(),r.enableDamping===!0?r.target.addScaledVector(d,r.dampingFactor):r.target.add(d),r.target.sub(r.cursor),r.target.clampLength(r.minTargetRadius,r.maxTargetRadius),r.target.add(r.cursor),r.zoomToCursor&&C||r.object.isOrthographicCamera?l.radius=Q(l.radius):l.radius=Q(l.radius*u),$.setFromSpherical(l),$.applyQuaternion(U),H.copy(r.target).add($),r.object.lookAt(r.target),r.enableDamping===!0?(c.theta*=1-r.dampingFactor,c.phi*=1-r.dampingFactor,d.multiplyScalar(1-r.dampingFactor)):(c.set(0,0,0),d.set(0,0,0));let xe=!1;if(r.zoomToCursor&&C){let Ne=null;if(r.object.isPerspectiveCamera){const ve=$.length();Ne=Q(ve*u);const $e=ve-Ne;r.object.position.addScaledVector(T,$e),r.object.updateMatrixWorld()}else if(r.object.isOrthographicCamera){const ve=new We(E.x,E.y,0);ve.unproject(r.object),r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom/u)),r.object.updateProjectionMatrix(),xe=!0;const $e=new We(E.x,E.y,0);$e.unproject(r.object),r.object.position.sub($e).add(ve),r.object.updateMatrixWorld(),Ne=$.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),r.zoomToCursor=!1;Ne!==null&&(this.screenSpacePanning?r.target.set(0,0,-1).transformDirection(r.object.matrix).multiplyScalar(Ne).add(r.object.position):(b1.origin.copy(r.object.position),b1.direction.set(0,0,-1).transformDirection(r.object.matrix),Math.abs(r.object.up.dot(b1.direction))<KBe?e.lookAt(r.target):(i9.setFromNormalAndCoplanarPoint(r.object.up,r.target),b1.intersectPlane(i9,r.target))))}else r.object.isOrthographicCamera&&(r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom/u)),r.object.updateProjectionMatrix(),xe=!0);return u=1,C=!1,!!(xe||B.distanceToSquared(r.object.position)>o||8*(1-oe.dot(r.object.quaternion))>o||Te.distanceToSquared(r.target)>0)&&(r.dispatchEvent(n9),B.copy(r.object.position),oe.copy(r.object.quaternion),Te.copy(r.target),!0)}})(),this.dispose=function(){r.domElement.removeEventListener("contextmenu",le),r.domElement.removeEventListener("pointerdown",ce),r.domElement.removeEventListener("pointercancel",me),r.domElement.removeEventListener("wheel",Ee),r.domElement.removeEventListener("pointermove",Me),r.domElement.removeEventListener("pointerup",me),r._domElementKeyEvents!==null&&(r._domElementKeyEvents.removeEventListener("keydown",fe),r._domElementKeyEvents=null)};const r=this,i={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let a=i.NONE;const o=1e-6,l=new Q7,c=new Q7;let u=1;const d=new We,f=new pn,m=new pn,p=new pn,x=new pn,y=new pn,b=new pn,v=new pn,N=new pn,S=new pn,T=new We,E=new pn;let C=!1;const A=[],O={};function k(){return Math.pow(.95,r.zoomSpeed)}function R($){c.theta-=$}function F($){c.phi-=$}const L=(function(){const $=new We;return function(X,U){$.setFromMatrixColumn(U,0),$.multiplyScalar(-X),d.add($)}})(),K=(function(){const $=new We;return function(X,U){r.screenSpacePanning===!0?$.setFromMatrixColumn(U,1):($.setFromMatrixColumn(U,0),$.crossVectors(r.object.up,$)),$.multiplyScalar(X),d.add($)}})(),j=(function(){const $=new We;return function(X,U){const B=r.domElement;if(r.object.isPerspectiveCamera){const oe=r.object.position;$.copy(oe).sub(r.target);let Te=$.length();Te*=Math.tan(r.object.fov/2*Math.PI/180),L(2*X*Te/B.clientHeight,r.object.matrix),K(2*U*Te/B.clientHeight,r.object.matrix)}else r.object.isOrthographicCamera?(L(X*(r.object.right-r.object.left)/r.object.zoom/B.clientWidth,r.object.matrix),K(U*(r.object.top-r.object.bottom)/r.object.zoom/B.clientHeight,r.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),r.enablePan=!1)}})();function W($){r.object.isPerspectiveCamera||r.object.isOrthographicCamera?u/=$:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),r.enableZoom=!1)}function Y($){r.object.isPerspectiveCamera||r.object.isOrthographicCamera?u*=$:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),r.enableZoom=!1)}function q($){if(!r.zoomToCursor)return;C=!0;const X=r.domElement.getBoundingClientRect(),U=$.clientX-X.left,B=$.clientY-X.top,oe=X.width,Te=X.height;E.x=U/oe*2-1,E.y=-B/Te*2+1,T.set(E.x,E.y,1).unproject(r.object).sub(r.object.position).normalize()}function Q($){return Math.max(r.minDistance,Math.min(r.maxDistance,$))}function ee($){f.set($.clientX,$.clientY)}function re($){x.set($.clientX,$.clientY)}function z(){if(A.length===1)f.set(A[0].pageX,A[0].pageY);else{const $=.5*(A[0].pageX+A[1].pageX),X=.5*(A[0].pageY+A[1].pageY);f.set($,X)}}function G(){if(A.length===1)x.set(A[0].pageX,A[0].pageY);else{const $=.5*(A[0].pageX+A[1].pageX),X=.5*(A[0].pageY+A[1].pageY);x.set($,X)}}function ae(){const $=A[0].pageX-A[1].pageX,X=A[0].pageY-A[1].pageY,U=Math.sqrt($*$+X*X);v.set(0,U)}function se($){if(A.length==1)m.set($.pageX,$.pageY);else{const U=V($),B=.5*($.pageX+U.x),oe=.5*($.pageY+U.y);m.set(B,oe)}p.subVectors(m,f).multiplyScalar(r.rotateSpeed);const X=r.domElement;R(2*Math.PI*p.x/X.clientHeight),F(2*Math.PI*p.y/X.clientHeight),f.copy(m)}function ue($){if(A.length===1)y.set($.pageX,$.pageY);else{const X=V($),U=.5*($.pageX+X.x),B=.5*($.pageY+X.y);y.set(U,B)}b.subVectors(y,x).multiplyScalar(r.panSpeed),j(b.x,b.y),x.copy(y)}function pe($){const X=V($),U=$.pageX-X.x,B=$.pageY-X.y,oe=Math.sqrt(U*U+B*B);N.set(0,oe),S.set(0,Math.pow(N.y/v.y,r.zoomSpeed)),W(S.y),v.copy(N)}function ce($){r.enabled!==!1&&(A.length===0&&(r.domElement.setPointerCapture($.pointerId),r.domElement.addEventListener("pointermove",Me),r.domElement.addEventListener("pointerup",me)),(function(X){A.push(X)})($),$.pointerType==="touch"?(function(X){switch(Be(X),A.length){case 1:switch(r.touches.ONE){case ip.ROTATE:if(r.enableRotate===!1)return;z(),a=i.TOUCH_ROTATE;break;case ip.PAN:if(r.enablePan===!1)return;G(),a=i.TOUCH_PAN;break;default:a=i.NONE}break;case 2:switch(r.touches.TWO){case ip.DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;r.enableZoom&&ae(),r.enablePan&&G(),a=i.TOUCH_DOLLY_PAN;break;case ip.DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;r.enableZoom&&ae(),r.enableRotate&&z(),a=i.TOUCH_DOLLY_ROTATE;break;default:a=i.NONE}break;default:a=i.NONE}a!==i.NONE&&r.dispatchEvent(Uk)})($):(function(X){let U;switch(X.button){case 0:U=r.mouseButtons.LEFT;break;case 1:U=r.mouseButtons.MIDDLE;break;case 2:U=r.mouseButtons.RIGHT;break;default:U=-1}switch(U){case rp.DOLLY:if(r.enableZoom===!1)return;(function(B){q(B),v.set(B.clientX,B.clientY)})(X),a=i.DOLLY;break;case rp.ROTATE:if(X.ctrlKey||X.metaKey||X.shiftKey){if(r.enablePan===!1)return;re(X),a=i.PAN}else{if(r.enableRotate===!1)return;ee(X),a=i.ROTATE}break;case rp.PAN:if(X.ctrlKey||X.metaKey||X.shiftKey){if(r.enableRotate===!1)return;ee(X),a=i.ROTATE}else{if(r.enablePan===!1)return;re(X),a=i.PAN}break;default:a=i.NONE}a!==i.NONE&&r.dispatchEvent(Uk)})($))}function Me($){r.enabled!==!1&&($.pointerType==="touch"?(function(X){switch(Be(X),a){case i.TOUCH_ROTATE:if(r.enableRotate===!1)return;se(X),r.update();break;case i.TOUCH_PAN:if(r.enablePan===!1)return;ue(X),r.update();break;case i.TOUCH_DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;(function(U){r.enableZoom&&pe(U),r.enablePan&&ue(U)})(X),r.update();break;case i.TOUCH_DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;(function(U){r.enableZoom&&pe(U),r.enableRotate&&se(U)})(X),r.update();break;default:a=i.NONE}})($):(function(X){switch(a){case i.ROTATE:if(r.enableRotate===!1)return;(function(U){m.set(U.clientX,U.clientY),p.subVectors(m,f).multiplyScalar(r.rotateSpeed);const B=r.domElement;R(2*Math.PI*p.x/B.clientHeight),F(2*Math.PI*p.y/B.clientHeight),f.copy(m),r.update()})(X);break;case i.DOLLY:if(r.enableZoom===!1)return;(function(U){N.set(U.clientX,U.clientY),S.subVectors(N,v),S.y>0?W(k()):S.y<0&&Y(k()),v.copy(N),r.update()})(X);break;case i.PAN:if(r.enablePan===!1)return;(function(U){y.set(U.clientX,U.clientY),b.subVectors(y,x).multiplyScalar(r.panSpeed),j(b.x,b.y),x.copy(y),r.update()})(X)}})($))}function me($){(function(X){delete O[X.pointerId];for(let U=0;U<A.length;U++)if(A[U].pointerId==X.pointerId)return void A.splice(U,1)})($),A.length===0&&(r.domElement.releasePointerCapture($.pointerId),r.domElement.removeEventListener("pointermove",Me),r.domElement.removeEventListener("pointerup",me)),r.dispatchEvent(r9),a=i.NONE}function Ee($){r.enabled!==!1&&r.enableZoom!==!1&&a===i.NONE&&($.preventDefault(),r.dispatchEvent(Uk),(function(X){q(X),X.deltaY<0?Y(k()):X.deltaY>0&&W(k()),r.update()})($),r.dispatchEvent(r9))}function fe($){r.enabled!==!1&&r.enablePan!==!1&&(function(X){let U=!1;switch(X.code){case r.keys.UP:X.ctrlKey||X.metaKey||X.shiftKey?F(2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):j(0,r.keyPanSpeed),U=!0;break;case r.keys.BOTTOM:X.ctrlKey||X.metaKey||X.shiftKey?F(-2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):j(0,-r.keyPanSpeed),U=!0;break;case r.keys.LEFT:X.ctrlKey||X.metaKey||X.shiftKey?R(2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):j(r.keyPanSpeed,0),U=!0;break;case r.keys.RIGHT:X.ctrlKey||X.metaKey||X.shiftKey?R(-2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):j(-r.keyPanSpeed,0),U=!0}U&&(X.preventDefault(),r.update())})($)}function le($){r.enabled!==!1&&$.preventDefault()}function Be($){let X=O[$.pointerId];X===void 0&&(X=new pn,O[$.pointerId]=X),X.set($.pageX,$.pageY)}function V($){const X=$.pointerId===A[0].pointerId?A[1]:A[0];return O[X.pointerId]}r.domElement.addEventListener("contextmenu",le),r.domElement.addEventListener("pointerdown",ce),r.domElement.addEventListener("pointercancel",me),r.domElement.addEventListener("wheel",Ee,{passive:!1}),this.update()}}Dt.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new pn(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},ms.line={uniforms:BO.merge([Dt.common,Dt.fog,Dt.line]),vertexShader:`
  7896. #include <common>
  7897. #include <color_pars_vertex>
  7898. #include <fog_pars_vertex>
  7899. #include <logdepthbuf_pars_vertex>
  7900. #include <clipping_planes_pars_vertex>
  7901. uniform float linewidth;
  7902. uniform vec2 resolution;
  7903. attribute vec3 instanceStart;
  7904. attribute vec3 instanceEnd;
  7905. attribute vec3 instanceColorStart;
  7906. attribute vec3 instanceColorEnd;
  7907. #ifdef WORLD_UNITS
  7908. varying vec4 worldPos;
  7909. varying vec3 worldStart;
  7910. varying vec3 worldEnd;
  7911. #ifdef USE_DASH
  7912. varying vec2 vUv;
  7913. #endif
  7914. #else
  7915. varying vec2 vUv;
  7916. #endif
  7917. #ifdef USE_DASH
  7918. uniform float dashScale;
  7919. attribute float instanceDistanceStart;
  7920. attribute float instanceDistanceEnd;
  7921. varying float vLineDistance;
  7922. #endif
  7923. void trimSegment( const in vec4 start, inout vec4 end ) {
  7924. // trim end segment so it terminates between the camera plane and the near plane
  7925. // conservative estimate of the near plane
  7926. float a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column
  7927. float b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column
  7928. float nearEstimate = - 0.5 * b / a;
  7929. float alpha = ( nearEstimate - start.z ) / ( end.z - start.z );
  7930. end.xyz = mix( start.xyz, end.xyz, alpha );
  7931. }
  7932. void main() {
  7933. #ifdef USE_COLOR
  7934. vColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;
  7935. #endif
  7936. #ifdef USE_DASH
  7937. vLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;
  7938. vUv = uv;
  7939. #endif
  7940. float aspect = resolution.x / resolution.y;
  7941. // camera space
  7942. vec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );
  7943. vec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );
  7944. #ifdef WORLD_UNITS
  7945. worldStart = start.xyz;
  7946. worldEnd = end.xyz;
  7947. #else
  7948. vUv = uv;
  7949. #endif
  7950. // special case for perspective projection, and segments that terminate either in, or behind, the camera plane
  7951. // clearly the gpu firmware has a way of addressing this issue when projecting into ndc space
  7952. // but we need to perform ndc-space calculations in the shader, so we must address this issue directly
  7953. // perhaps there is a more elegant solution -- WestLangley
  7954. bool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column
  7955. if ( perspective ) {
  7956. if ( start.z < 0.0 && end.z >= 0.0 ) {
  7957. trimSegment( start, end );
  7958. } else if ( end.z < 0.0 && start.z >= 0.0 ) {
  7959. trimSegment( end, start );
  7960. }
  7961. }
  7962. // clip space
  7963. vec4 clipStart = projectionMatrix * start;
  7964. vec4 clipEnd = projectionMatrix * end;
  7965. // ndc space
  7966. vec3 ndcStart = clipStart.xyz / clipStart.w;
  7967. vec3 ndcEnd = clipEnd.xyz / clipEnd.w;
  7968. // direction
  7969. vec2 dir = ndcEnd.xy - ndcStart.xy;
  7970. // account for clip-space aspect ratio
  7971. dir.x *= aspect;
  7972. dir = normalize( dir );
  7973. #ifdef WORLD_UNITS
  7974. // get the offset direction as perpendicular to the view vector
  7975. vec3 worldDir = normalize( end.xyz - start.xyz );
  7976. vec3 offset;
  7977. if ( position.y < 0.5 ) {
  7978. offset = normalize( cross( start.xyz, worldDir ) );
  7979. } else {
  7980. offset = normalize( cross( end.xyz, worldDir ) );
  7981. }
  7982. // sign flip
  7983. if ( position.x < 0.0 ) offset *= - 1.0;
  7984. float forwardOffset = dot( worldDir, vec3( 0.0, 0.0, 1.0 ) );
  7985. // don't extend the line if we're rendering dashes because we
  7986. // won't be rendering the endcaps
  7987. #ifndef USE_DASH
  7988. // extend the line bounds to encompass endcaps
  7989. start.xyz += - worldDir * linewidth * 0.5;
  7990. end.xyz += worldDir * linewidth * 0.5;
  7991. // shift the position of the quad so it hugs the forward edge of the line
  7992. offset.xy -= dir * forwardOffset;
  7993. offset.z += 0.5;
  7994. #endif
  7995. // endcaps
  7996. if ( position.y > 1.0 || position.y < 0.0 ) {
  7997. offset.xy += dir * 2.0 * forwardOffset;
  7998. }
  7999. // adjust for linewidth
  8000. offset *= linewidth * 0.5;
  8001. // set the world position
  8002. worldPos = ( position.y < 0.5 ) ? start : end;
  8003. worldPos.xyz += offset;
  8004. // project the worldpos
  8005. vec4 clip = projectionMatrix * worldPos;
  8006. // shift the depth of the projected points so the line
  8007. // segments overlap neatly
  8008. vec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd;
  8009. clip.z = clipPose.z * clip.w;
  8010. #else
  8011. vec2 offset = vec2( dir.y, - dir.x );
  8012. // undo aspect ratio adjustment
  8013. dir.x /= aspect;
  8014. offset.x /= aspect;
  8015. // sign flip
  8016. if ( position.x < 0.0 ) offset *= - 1.0;
  8017. // endcaps
  8018. if ( position.y < 0.0 ) {
  8019. offset += - dir;
  8020. } else if ( position.y > 1.0 ) {
  8021. offset += dir;
  8022. }
  8023. // adjust for linewidth
  8024. offset *= linewidth;
  8025. // adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...
  8026. offset /= resolution.y;
  8027. // select end
  8028. vec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;
  8029. // back to clip space
  8030. offset *= clip.w;
  8031. clip.xy += offset;
  8032. #endif
  8033. gl_Position = clip;
  8034. vec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation
  8035. #include <logdepthbuf_vertex>
  8036. #include <clipping_planes_vertex>
  8037. #include <fog_vertex>
  8038. }
  8039. `,fragmentShader:`
  8040. uniform vec3 diffuse;
  8041. uniform float opacity;
  8042. uniform float linewidth;
  8043. #ifdef USE_DASH
  8044. uniform float dashOffset;
  8045. uniform float dashSize;
  8046. uniform float gapSize;
  8047. #endif
  8048. varying float vLineDistance;
  8049. #ifdef WORLD_UNITS
  8050. varying vec4 worldPos;
  8051. varying vec3 worldStart;
  8052. varying vec3 worldEnd;
  8053. #ifdef USE_DASH
  8054. varying vec2 vUv;
  8055. #endif
  8056. #else
  8057. varying vec2 vUv;
  8058. #endif
  8059. #include <common>
  8060. #include <color_pars_fragment>
  8061. #include <fog_pars_fragment>
  8062. #include <logdepthbuf_pars_fragment>
  8063. #include <clipping_planes_pars_fragment>
  8064. vec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {
  8065. float mua;
  8066. float mub;
  8067. vec3 p13 = p1 - p3;
  8068. vec3 p43 = p4 - p3;
  8069. vec3 p21 = p2 - p1;
  8070. float d1343 = dot( p13, p43 );
  8071. float d4321 = dot( p43, p21 );
  8072. float d1321 = dot( p13, p21 );
  8073. float d4343 = dot( p43, p43 );
  8074. float d2121 = dot( p21, p21 );
  8075. float denom = d2121 * d4343 - d4321 * d4321;
  8076. float numer = d1343 * d4321 - d1321 * d4343;
  8077. mua = numer / denom;
  8078. mua = clamp( mua, 0.0, 1.0 );
  8079. mub = ( d1343 + d4321 * ( mua ) ) / d4343;
  8080. mub = clamp( mub, 0.0, 1.0 );
  8081. return vec2( mua, mub );
  8082. }
  8083. void main() {
  8084. #include <clipping_planes_fragment>
  8085. #ifdef USE_DASH
  8086. if ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps
  8087. if ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX
  8088. #endif
  8089. float alpha = opacity;
  8090. #ifdef WORLD_UNITS
  8091. // Find the closest points on the view ray and the line segment
  8092. vec3 rayEnd = normalize( worldPos.xyz ) * 1e5;
  8093. vec3 lineDir = worldEnd - worldStart;
  8094. vec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd );
  8095. vec3 p1 = worldStart + lineDir * params.x;
  8096. vec3 p2 = rayEnd * params.y;
  8097. vec3 delta = p1 - p2;
  8098. float len = length( delta );
  8099. float norm = len / linewidth;
  8100. #ifndef USE_DASH
  8101. #ifdef USE_ALPHA_TO_COVERAGE
  8102. float dnorm = fwidth( norm );
  8103. alpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm );
  8104. #else
  8105. if ( norm > 0.5 ) {
  8106. discard;
  8107. }
  8108. #endif
  8109. #endif
  8110. #else
  8111. #ifdef USE_ALPHA_TO_COVERAGE
  8112. // artifacts appear on some hardware if a derivative is taken within a conditional
  8113. float a = vUv.x;
  8114. float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
  8115. float len2 = a * a + b * b;
  8116. float dlen = fwidth( len2 );
  8117. if ( abs( vUv.y ) > 1.0 ) {
  8118. alpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );
  8119. }
  8120. #else
  8121. if ( abs( vUv.y ) > 1.0 ) {
  8122. float a = vUv.x;
  8123. float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
  8124. float len2 = a * a + b * b;
  8125. if ( len2 > 1.0 ) discard;
  8126. }
  8127. #endif
  8128. #endif
  8129. vec4 diffuseColor = vec4( diffuse, alpha );
  8130. #include <logdepthbuf_fragment>
  8131. #include <color_fragment>
  8132. gl_FragColor = vec4( diffuseColor.rgb, alpha );
  8133. #include <tonemapping_fragment>
  8134. #include <colorspace_fragment>
  8135. #include <fog_fragment>
  8136. #include <premultiplied_alpha_fragment>
  8137. }
  8138. `};class eee extends Qd{constructor(e){super({type:"LineMaterial",uniforms:BO.clone(ms.line.uniforms),vertexShader:ms.line.vertexShader,fragmentShader:ms.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 a9=new Co,y1=new We;class tee extends RBe{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 hi([-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 hi([-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 aR(n,6,1);return this.setAttribute("instanceStart",new Nd(r,3,0)),this.setAttribute("instanceEnd",new Nd(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 aR(n,6,1);return this.setAttribute("instanceColorStart",new Nd(r,3,0)),this.setAttribute("instanceColorEnd",new Nd(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 EBe(e.geometry)),this}fromLineSegments(e){const n=e.geometry;return this.setPositions(n.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Co);const e=this.attributes.instanceStart,n=this.attributes.instanceEnd;e!==void 0&&n!==void 0&&(this.boundingBox.setFromBufferAttribute(e),a9.setFromBufferAttribute(n),this.boundingBox.union(a9))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Il),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++)y1.fromBufferAttribute(e,a),i=Math.max(i,r.distanceToSquared(y1)),y1.fromBufferAttribute(n,a),i=Math.max(i,r.distanceToSquared(y1));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 s9=new We,o9=new We,da=new gr,ha=new gr,_l=new gr,zk=new We,Bk=new Er,fa=new DBe,l9=new We,v1=new Co,_1=new Il,wl=new gr;let Sl,Xh;function c9(t,e,n){return wl.set(0,0,-e,1).applyMatrix4(t.projectionMatrix),wl.multiplyScalar(1/wl.w),wl.x=Xh/n.width,wl.y=Xh/n.height,wl.applyMatrix4(t.projectionMatrixInverse),wl.multiplyScalar(1/wl.w),Math.abs(Math.max(wl.x,wl.y))}class YBe extends rl{constructor(e=new tee,n=new eee({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)s9.fromBufferAttribute(n,o),o9.fromBufferAttribute(r,o),i[l]=l===0?0:i[l-1],i[l+1]=i[l]+s9.distanceTo(o9);const a=new aR(i,2,1);return e.setAttribute("instanceDistanceStart",new Nd(a,1,0)),e.setAttribute("instanceDistanceEnd",new Nd(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;Sl=e.ray;const o=this.matrixWorld,l=this.geometry,c=this.material;let u,d;Xh=c.linewidth+a,l.boundingSphere===null&&l.computeBoundingSphere(),_1.copy(l.boundingSphere).applyMatrix4(o),r?u=.5*Xh:u=c9(i,Math.max(i.near,_1.distanceToPoint(Sl.origin)),c.resolution),_1.radius+=u,Sl.intersectsSphere(_1)!==!1&&(l.boundingBox===null&&l.computeBoundingBox(),v1.copy(l.boundingBox).applyMatrix4(o),r?d=.5*Xh:d=c9(i,Math.max(i.near,v1.distanceToPoint(Sl.origin)),c.resolution),v1.expandByScalar(d),Sl.intersectsBox(v1)!==!1&&(r?(function(f,m){const p=f.matrixWorld,x=f.geometry,y=x.attributes.instanceStart,b=x.attributes.instanceEnd;for(let v=0,N=Math.min(x.instanceCount,y.count);v<N;v++){fa.start.fromBufferAttribute(y,v),fa.end.fromBufferAttribute(b,v),fa.applyMatrix4(p);const S=new We,T=new We;Sl.distanceSqToSegment(fa.start,fa.end,T,S),T.distanceTo(S)<.5*Xh&&m.push({point:T,pointOnLine:S,distance:Sl.origin.distanceTo(T),object:f,face:null,faceIndex:v,uv:null,uv1:null})}})(this,n):(function(f,m,p){const x=m.projectionMatrix,y=f.material.resolution,b=f.matrixWorld,v=f.geometry,N=v.attributes.instanceStart,S=v.attributes.instanceEnd,T=Math.min(v.instanceCount,N.count),E=-m.near;Sl.at(1,_l),_l.w=1,_l.applyMatrix4(m.matrixWorldInverse),_l.applyMatrix4(x),_l.multiplyScalar(1/_l.w),_l.x*=y.x/2,_l.y*=y.y/2,_l.z=0,zk.copy(_l),Bk.multiplyMatrices(m.matrixWorldInverse,b);for(let C=0,A=T;C<A;C++){if(da.fromBufferAttribute(N,C),ha.fromBufferAttribute(S,C),da.w=1,ha.w=1,da.applyMatrix4(Bk),ha.applyMatrix4(Bk),da.z>E&&ha.z>E)continue;if(da.z>E){const L=da.z-ha.z,K=(da.z-E)/L;da.lerp(ha,K)}else if(ha.z>E){const L=ha.z-da.z,K=(ha.z-E)/L;ha.lerp(da,K)}da.applyMatrix4(x),ha.applyMatrix4(x),da.multiplyScalar(1/da.w),ha.multiplyScalar(1/ha.w),da.x*=y.x/2,da.y*=y.y/2,ha.x*=y.x/2,ha.y*=y.y/2,fa.start.copy(da),fa.start.z=0,fa.end.copy(ha),fa.end.z=0;const O=fa.closestPointToPointParameter(zk,!0);fa.at(O,l9);const k=RJ.lerp(da.z,ha.z,O),R=k>=-1&&k<=1,F=zk.distanceTo(l9)<.5*Xh;if(R&&F){fa.start.fromBufferAttribute(N,C),fa.end.fromBufferAttribute(S,C),fa.start.applyMatrix4(b),fa.end.applyMatrix4(b);const L=new We,K=new We;Sl.distanceSqToSegment(fa.start,fa.end,K,L),p.push({point:K,pointOnLine:L,distance:Sl.origin.distanceTo(K),object:f,face:null,faceIndex:C,uv:null,uv1:null})}}})(this,i,n)))}}class QBe extends XN{constructor(e,n,r,i,a=4473924,o=8947848){a=new nn(a),o=new nn(o);const l=Math.round(e/n);r=Math.round(r/i)*i/2;const c=[],u=[];let d=0;for(let m=-1*(e=l*n/2);m<=e;m+=n){c.push(m,0,-1*r,m,0,r);const p=m===0?a:o;p.toArray(u,d),d+=3,p.toArray(u,d),d+=3,p.toArray(u,d),d+=3,p.toArray(u,d),d+=3}for(let m=-1*r;m<=r;m+=i){c.push(-1*e,0,m,e,0,m);const p=m===0?a:o;p.toArray(u,d),d+=3,p.toArray(u,d),d+=3,p.toArray(u,d),d+=3,p.toArray(u,d),d+=3}const f=new Ia;f.setAttribute("position",new hi(c,3)),f.setAttribute("color",new hi(u,3)),super(f,new Iy({vertexColors:!0,toneMapped:!1}))}}function ZBe(t,e,n,r){const i=(function(o,l,c){o*=.5,l*=.5,c*=.5;const u=new Ia,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 hi(d,3)),u})(t,e,n),a=new XN(i,new ABe({color:new nn(r),dashSize:3,gapSize:1}));return a.computeLineDistances(),a}var Gb=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 Gb.Panel("FPS","#0ff","#002")),c=n(new Gb.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var u=n(new Gb.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}};Gb.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,m=15*o,p=74*o,x=30*o,y=document.createElement("canvas");y.width=l,y.height=c,y.style.cssText="width:80px;height:48px";var b=y.getContext("2d");return b.font="bold "+9*o+"px Helvetica,Arial,sans-serif",b.textBaseline="top",b.fillStyle=n,b.fillRect(0,0,l,c),b.fillStyle=e,b.fillText(t,u,d),b.fillRect(f,m,p,x),b.fillStyle=n,b.globalAlpha=.9,b.fillRect(f,m,p,x),{dom:y,update:function(v,N){r=Math.min(r,v),i=Math.max(i,v),b.fillStyle=n,b.globalAlpha=1,b.fillRect(0,0,l,m),b.fillStyle=e,b.fillText(a(v)+" "+t+" ("+a(r)+"-"+a(i)+")",u,d),b.drawImage(y,f+o,m,p-o,x,f,m,p-o,x),b.fillRect(f+p-o,m,o,x),b.fillStyle=n,b.globalAlpha=.9,b.fillRect(f+p-o,m,o,a((1-v/N)*x))}}};var JBe=Gb;class u9{constructor(e,n){this.openFolders=[],this.watchedObject=e,this.options=n,this.gui=new jS,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 jS,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 e8e extends Ia{constructor(e=[new We],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 We,o=new We,l=new pn,c=[],u=[],d=[],f=[];function m(p){const[x,y,b]=(function(v){const N=e[v],S=new We,T=new We,E=new We,C=new We;S.copy(N).sub(e[v-1]||N).normalize().add((e[v+1]||N).clone().sub(N).normalize()).normalize();let A=Number.MAX_VALUE;const O=Math.abs(S.x),k=Math.abs(S.y),R=Math.abs(S.z);return O<=A&&(A=O,T.set(1,0,0)),k<=A&&(A=k,T.set(0,1,0)),R<=A&&T.set(0,0,1),C.crossVectors(S,T).normalize(),T.crossVectors(S,C),E.crossVectors(S,T),[N,T,E]})(p);for(let v=0;v<=i;v++){const N=v/i*Math.PI*2,S=Math.sin(N),T=-Math.cos(N);o.x=T*y.x+S*b.x,o.y=T*y.y+S*b.y,o.z=T*y.z+S*b.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 p=0;p<e.length;p++)m(p);m(closed===!1?e.length-1:0),(function(){for(let p=0;p<e.length;p++)for(let x=0;x<=i;x++)l.x=p/e.length,l.y=x/i,d.push(l.x,l.y)})(),(function(){for(let p=1;p<e.length;p++)for(let x=1;x<=i;x++){const y=(i+1)*(p-1)+(x-1),b=(i+1)*p+(x-1),v=(i+1)*p+x,N=(i+1)*(p-1)+x;f.push(y,b,N),f.push(b,v,N)}})()})(),this.setIndex(f),this.setAttribute("position",new hi(c,3)),this.setAttribute("normal",new hi(u,3)),this.setAttribute("uv",new hi(d,2))}}class Wb{static get initial(){const e=new Wb;return Object.assign(e,{x:0,y:0,z:0,r:0,e:0,i:0,j:0,t:0}),e}}const $k={h:0,s:0,l:0};class Jp{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=Wb.initial,this.beyondFirstMove=!1,this.disposables=[],this._extrusionColor=Jp.defaultExtrusionColor,this.renderLayerIndex=0,this._geometries={},this._backgroundColor=new nn(14737632),this._travelColor=new nn(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 PS(this.minLayerThreshold),this.scene=new gBe,this.scene.background=this._backgroundColor,e.backgroundColor!==void 0&&(this.backgroundColor=new nn(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 JBe:void 0,e.extrusionColor!==void 0&&(this.extrusionColor=e.extrusionColor),e.travelColor!==void 0&&(this.travelColor=new nn(e.travelColor)),e.topLayerColor!==void 0&&(this.topLayerColor=new nn(e.topLayerColor)),e.lastSegmentColor!==void 0&&(this.lastSegmentColor=new nn(e.lastSegmentColor)),e.toolColors){this._toolColors={};for(const[p,x]of Object.entries(e.toolColors))this._toolColors[parseInt(p)]=new nn(x)}if(e.disableGradient!==void 0&&(this.disableGradient=e.disableGradient),console.info("Using THREE r"+VN),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 iR({canvas:this.canvas,preserveDrawingBuffer:!0});else{if(!this.targetId)throw Error("Set either opts.canvas or opts.targetId");const p=document.getElementById(this.targetId);if(!p)throw new Error("Unable to find element "+this.targetId);this.renderer=new iR({preserveDrawingBuffer:!0}),this.canvas=this.renderer.domElement,p.appendChild(this.canvas)}this.camera=new Us(25,this.canvas.offsetWidth/this.canvas.offsetHeight,10,5e3),this.camera.position.fromArray(this.initialCameraPosition);const f=this.camera.far,m=.8*f;this.scene.fog=new VO(this._backgroundColor,m,f),this.resize(),this.controls=new XBe(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 nn(r)}else this._extrusionColor=new nn(e)}get currentToolColor(){var e;return this._extrusionColor===void 0?Jp.defaultExtrusionColor:this._extrusionColor instanceof nn?this._extrusionColor:(e=this._extrusionColor[this.state.t])!==null&&e!==void 0?e:Jp.defaultExtrusionColor}get backgroundColor(){return this._backgroundColor}set backgroundColor(e){this._backgroundColor=new nn(e),this.scene.background=this._backgroundColor}get travelColor(){return this._travelColor}set travelColor(e){this._travelColor=new nn(e)}get topLayerColor(){return this._topLayerColor}set topLayerColor(e){this._topLayerColor=e!==void 0?new nn(e):void 0}get lastSegmentColor(){return this._lastSegmentColor}set lastSegmentColor(e){this._lastSegmentColor=e!==void 0?new nn(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 OBe(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 PBe(13421772,.3*Math.PI),n=new jBe(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 jb;return n.name=e,n.quaternion.setFromEuler(new Oy(-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=Wb.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 Fk(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 m of d.commands)if(m.gcode!="g20"){if(m.gcode.startsWith("t")){this.doRenderExtrusion(f,e),f.extrusion=[];const p=m;this.state.t=p.toolIndex}else if(["g0","g00","g1","g01","g2","g02","g3","g03"].indexOf(m.gcode)>-1){const p=m,x={x:(n=p.params.x)!==null&&n!==void 0?n:this.state.x,y:(r=p.params.y)!==null&&r!==void 0?r:this.state.y,z:(i=p.params.z)!==null&&i!==void 0?i:this.state.z,r:(a=p.params.r)!==null&&a!==void 0?a:this.state.r,e:(o=p.params.e)!==null&&o!==void 0?o:this.state.e,i:(l=p.params.i)!==null&&l!==void 0?l:this.state.i,j:(c=p.params.j)!==null&&c!==void 0?c:this.state.j,t:this.state.t};if(e>=this.minLayerIndex){const y=((u=p.params.e)!==null&&u!==void 0?u:0)>0||this.nonTravelmoves.indexOf(m.gcode)>-1;(x.x!=this.state.x||x.y!=this.state.y||x.z!=this.state.z)&&(y&&this.renderExtrusion||!y&&this.renderTravel)&&(m.gcode=="g2"||m.gcode=="g3"||m.gcode=="g02"||m.gcode=="g03"?this.addArcSegment(f,this.state,x,y,m.gcode=="g2"||m.gcode=="g02"):this.addLineSegment(f,this.state,x,y))}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($k),a=new nn().setHSL($k.h,$k.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 QBe(this.buildVolume.x,10,this.buildVolume.y,10));const e=ZBe(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 PS(this.minLayerThreshold)}resetState(){var e;this.startLayer=1,this.endLayer=1/0,this.singleLayerMode=!1,this.beyondFirstMove=!1,this.state=Wb.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,m=r.z;let p=r.r,x=r.i,y=r.j;if(p){const W=d-l,Y=f-c,q=Math.sqrt(Math.pow(W/2,2)+Math.pow(Y/2,2));p=Math.max(p,q);const Q=Math.pow(W,2)+Math.pow(Y,2),ee=Math.pow(p,2)-Q/4;let re=Math.sqrt(ee/Q);(a&&p<0||!a&&p>0)&&(re=-re),x=W/2+Y*re,y=Y/2-W*re}const b=l==d&&c==f,v=l+x,N=c+y,S=Math.sqrt(x*x+y*y),T=Math.atan2(-y,-x),E=Math.atan2(f-N,d-v);let C;b?C=2*Math.PI:(C=a?T-E:E-T,C<0&&(C+=2*Math.PI));let A=S*C/1.8;this.inches&&(A*=25),A<1&&(A=1);let O=C/A;O*=a?-1:1;const k=[];k.push({x:l,y:c,z:u});const R=(u-m)/A;let F=l,L=c,K=u,j=T;for(let W=0;W<A-1;W++)j+=O,F=v+S*Math.cos(j),L=N+S*Math.sin(j),K+=R,k.push({x:F,y:L,z:K});k.push({x:r.x,y:r.y,z:r.z});for(let W=0;W<k.length-1;W++)o.push(k[W].x,k[W].y,k[W].z,k[W+1].x,k[W+1].y,k[W+1].z)}addLine(e,n){var r;if(typeof this.lineWidth=="number"&&this.lineWidth>0)return void this.addThickLine(e,n);const i=new Ia;i.setAttribute("position",new hi(e,3)),this.disposables.push(i);const a=new Iy({color:n});this.disposables.push(a);const o=new XN(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 We(l[0],l[1],l[2]),u=new We(l[3],l[4],l[5]),d=new We(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 e8e(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 tee;this.disposables.push(i);const a=new eee({color:n,linewidth:this.lineWidth/(1e3*window.devicePixelRatio)});this.disposables.push(a),i.setPositions(e);const o=new YBe(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=>Fk(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 TBe({color:e,wireframe:this._wireframe});this.disposables.push(i);const a=r.reduce(((l,c)=>3*c.attributes.position.count+l),0),o=new NBe(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 Fk(this,void 0,void 0,(function*(){const i=e.getReader();let a,o="",l=0;do{console.debug("reading from stream"),a=yield i.read(),l+=(r=(n=a.value)===null||n===void 0?void 0:n.length)!==null&&r!==void 0?r:0;const u=(c=a.value,new TextDecoder("utf-8").decode(c)),d=u.lastIndexOf(`
  8139. `),f=u.slice(0,d);this.parser.parseGCode(o+f),o=u.slice(d)}while(!a.done);var c;console.debug("read from stream",l)}))}initGui(){typeof this.devMode=="boolean"&&this.devMode===!0?this.devGui=new u9(this):typeof this.devMode=="object"&&(this.devGui=new u9(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())}}Jp.defaultExtrusionColor=new nn("hotpink");function t8e({gcodeUrl:t,buildVolume:e={x:256,y:256,z:256},filamentColors:n,className:r=""}){const i=w.useRef(null),a=w.useRef(null),o=w.useRef(null),l=w.useRef(!1),[c,u]=w.useState(!0),[d,f]=w.useState(null),[m,p]=w.useState(!1),[x,y]=w.useState(0),[b,v]=w.useState(0),N=w.useMemo(()=>JSON.stringify(n),[n]);w.useEffect(()=>{if(!i.current||l.current)return;l.current=!0;const E=i.current,C=E.parentElement?.getBoundingClientRect();C&&(E.width=C.width,E.height=C.height);const A=n&&n.length>1,O=n?.[0]||"#00ae42",k=new Jp({canvas:E,buildVolume:e,backgroundColor:1710618,extrusionColor:A?n:O,disableGradient:!0,lineHeight:.2,lineWidth:2,renderTravel:!1,renderExtrusion:!0});a.current=k,fetch(t).then(async F=>{if(!F.ok)throw F.status===404&&(await F.json().catch(()=>({}))).detail?.includes("sliced")?(p(!0),new Error("not_sliced")):new Error("Failed to load G-code");return F.text()}).then(F=>{const L=new Set,K=/^(\s*)T(\d+)(\s*;.*)?$/gim;let j;for(;(j=K.exec(F))!==null;){const re=parseInt(j[2],10);re<=15&&L.add(re)}const W=new Map,Y=Array.from(L).sort((re,z)=>re-z);Y.forEach((re,z)=>{W.set(re,z%8)});const q=[];Y.forEach((re,z)=>{const G=n?.[re]||"#00ae42";q[z%8]=G});const Q=F.split(`
  8140. `).map(re=>{const z=re.match(/^(\s*)T(\d+)(\s*;.*)?$/i);if(z){const G=parseInt(z[2],10);if(G>15)return`; FILTERED: ${re.trim()}`;const ae=W.get(G)??0;return`${z[1]}T${ae}${z[3]||""}`}return re}).join(`
  8141. `);q.length>0&&(k.extrusionColor=q),k.processGCode(Q);const ee=k.layers?.length||0;v(ee),y(ee),k.render(),u(!1)}).catch(F=>{F.message!=="not_sliced"&&f(F.message),u(!1)});const R=()=>{if(E.parentElement&&a.current){const F=E.parentElement.getBoundingClientRect();E.width=F.width,E.height=F.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,N]);const S=w.useCallback(E=>{if(!a.current)return;const C=Math.max(1,Math.min(E,b));y(C),o.current&&cancelAnimationFrame(o.current),o.current=requestAnimationFrame(()=>{a.current&&(a.current.endLayer=C,a.current.render())})},[b]),T=E=>{S(parseInt(E.target.value,10))};return s.jsxs("div",{className:`relative flex flex-col h-full ${r}`,children:[s.jsxs("div",{className:"flex-1 relative bg-bambu-dark rounded-lg overflow-hidden",children:[s.jsx("canvas",{ref:i,className:"w-full h-full"}),c&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:s.jsxs("div",{className:"text-center",children:[s.jsx(dt,{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..."})]})}),m&&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(Mue,{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&&!m&&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&&!m&&b>0&&s.jsx("div",{className:"mt-4 px-2",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(cl,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),s.jsx("button",{onClick:()=>S(x-1),disabled:x<=1,className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-30 disabled:cursor-not-allowed",children:s.jsx(Af,{className:"w-4 h-4"})}),s.jsx("input",{type:"range",min:1,max:b,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:()=>S(x+1),disabled:x>=b,className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-30 disabled:cursor-not-allowed",children:s.jsx(Ys,{className:"w-4 h-4"})}),s.jsxs("span",{className:"text-sm text-bambu-gray min-w-[80px] text-right",children:[x," / ",b]})]})})]})}function nee({archiveId:t,title:e,onClose:n}){const[r,i]=w.useState(null),[a,o]=w.useState(null),[l,c]=w.useState(!0);w.useEffect(()=>{const d=f=>{f.key==="Escape"&&n()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[n]),w.useEffect(()=>{he.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}${he.getArchiveForSlicer(t,d)}`;Bc(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(we,{variant:"secondary",size:"sm",onClick:u,children:[s.jsx(Ur,{className:"w-4 h-4"}),"Open in Slicer"]}),s.jsx(we,{variant:"ghost",size:"sm",onClick:n,children:s.jsx(zt,{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(zs,{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(Jce,{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(dt,{className:"w-8 h-8 animate-spin text-bambu-green"})}):r==="3d"&&a?s.jsx(ZOe,{url:a.has_source?he.getSource3mfDownloadUrl(t):he.getArchiveDownload(t),buildVolume:a.build_volume,filamentColors:a.filament_colors,className:"w-full h-full"}):r==="gcode"&&a?s.jsx(t8e,{gcodeUrl:he.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 d9={"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 n8e(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,m=r/255,p=i/255;a===f?c=((m-p)/d+(m<p?6:0))/6:a===m?c=((p-f)/d+2)/6:c=((f-m)/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 Mg(t){const e=t.replace("#","").toLowerCase().substring(0,6);return d9[e]?d9[e]:n8e(t)}function RS(t){return t?`#${t.replace("#","").substring(0,6)}`:"#808080"}function ea(t){return t?t.replace("#","").toLowerCase().substring(0,6):""}function Zd(t,e,n=40){const r=ea(t),i=ea(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 ree(t,e,n,r){const i=String.fromCharCode(65+(t>=128?t-128:t));return n?`HT-${i}`:`AMS-${i} Slot ${e+1}`}function iee(t,e,n){return t*4+e}function r8e(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 i8e(){const t=new Date;return t.setMinutes(t.getMinutes()+1),t.toISOString().slice(0,16)}function h9(t){if(!t)return!1;const e=Date.now()+4320*60*60*1e3;return new Date(t).getTime()>e}function qO(t){const e=[];if(t?.ams?.forEach(n=>{const r=n.tray.length===1;n.tray.forEach(i=>{if(i.tray_type){const a=RS(i.tray_color);e.push({type:i.tray_type,color:a,colorName:Mg(a),amsId:n.id,trayId:i.id,isHt:r,isExternal:!1,label:ree(n.id,i.id,r),globalTrayId:iee(n.id,i.id)})}})}),t?.vt_tray?.tray_type){const n=RS(t.vt_tray.tray_color);e.push({type:t.vt_tray.tray_type,color:n,colorName:Mg(n),amsId:-1,trayId:0,isHt:!1,isExternal:!0,label:"External",globalTrayId:254})}return e}function f9(t,e){if(!t?.filaments||t.filaments.length===0)return;const n=qO(e);if(n.length===0)return;const r=new Set,i=t.filaments.map(l=>{const c=n.find(m=>!r.has(m.globalTrayId)&&m.type?.toUpperCase()===l.type?.toUpperCase()&&ea(m.color)===ea(l.color)),u=!c&&n.find(m=>!r.has(m.globalTrayId)&&m.type?.toUpperCase()===l.type?.toUpperCase()&&Zd(m.color,l.color)),d=!c&&!u&&n.find(m=>!r.has(m.globalTrayId)&&m.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 a8e(t){return w.useMemo(()=>{const e=[];if(t?.ams?.forEach(n=>{const r=n.tray.length===1;n.tray.forEach(i=>{if(i.tray_type){const a=RS(i.tray_color);e.push({type:i.tray_type,color:a,colorName:Mg(a),amsId:n.id,trayId:i.id,isHt:r,isExternal:!1,label:ree(n.id,i.id,r),globalTrayId:iee(n.id,i.id)})}})}),t?.vt_tray?.tray_type){const n=RS(t.vt_tray.tray_color);e.push({type:t.vt_tray.tray_type,color:n,colorName:Mg(n),amsId:-1,trayId:0,isHt:!1,isExternal:!0,label:"External",globalTrayId:254})}return e},[t])}function aee(t,e,n){const r=a8e(e),i=w.useMemo(()=>{if(!t?.filaments||t.filaments.length===0)return[];const c=new Set(Object.values(n));return t.filaments.map(u=>{const d=u.slot_id||0;if(d>0&&n[d]!==void 0){const S=n[d],T=r.find(E=>E.globalTrayId===S);if(T){const E=T.type?.toUpperCase()===u.type?.toUpperCase(),C=ea(T.color)===ea(u.color)||Zd(T.color,u.color);let A;return E&&C?A="match":E?A="type_only":A="mismatch",{...u,loaded:T,hasFilament:!0,typeMatch:E,colorMatch:C,status:A,isManual:!0}}}const f=r.find(S=>!c.has(S.globalTrayId)&&S.type?.toUpperCase()===u.type?.toUpperCase()&&ea(S.color)===ea(u.color)),m=!f&&r.find(S=>!c.has(S.globalTrayId)&&S.type?.toUpperCase()===u.type?.toUpperCase()&&Zd(S.color,u.color)),p=!f&&!m&&r.find(S=>!c.has(S.globalTrayId)&&S.type?.toUpperCase()===u.type?.toUpperCase()),x=f||m||p||void 0;x&&c.add(x.globalTrayId);const y=!!x,b=y,v=!!f||!!m;let N;return f||m?N="match":p?N="type_only":N="mismatch",{...u,loaded:x,hasFilament:y,typeMatch:b,colorMatch:v,status:N,isManual:!1}})},[t,r,n]),a=w.useMemo(()=>{if(i.length===0)return;const c=Math.max(...i.map(d=>d.slot_id||0));if(c<=0)return;const u=new Array(c).fill(-1);return i.forEach(d=>{d.slot_id&&d.slot_id>0&&(u[d.slot_id-1]=d.loaded?.globalTrayId??-1)}),u},[i]),o=i.some(c=>c.status==="mismatch"),l=i.some(c=>c.status==="type_only");return{loadedFilaments:r,filamentComparison:i,amsMapping:a,hasTypeMismatch:o,hasColorMismatch:l}}function s8e(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 y=n[d],b=e.find(v=>v.globalTrayId===y);if(b){const v=b.type?.toUpperCase()===u.type?.toUpperCase(),N=ea(b.color)===ea(u.color)||Zd(b.color,u.color);v&&N?r++:v?i++:a++;continue}}const f=e.find(y=>!o.has(y.globalTrayId)&&y.type?.toUpperCase()===u.type?.toUpperCase()&&ea(y.color)===ea(u.color)),m=f?void 0:e.find(y=>!o.has(y.globalTrayId)&&y.type?.toUpperCase()===u.type?.toUpperCase()&&Zd(y.color,u.color)),p=f||m?void 0:e.find(y=>!o.has(y.globalTrayId)&&y.type?.toUpperCase()===u.type?.toUpperCase()),x=f??m??p;x&&o.add(x.globalTrayId),f||m?r++:p?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 o8e(t,e,n){if(!t?.filaments||t.filaments.length===0)return;const r=qO(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()&&ea(x.color)===ea(c.color)),f=d?void 0:r.find(x=>!i.has(x.globalTrayId)&&x.type?.toUpperCase()===c.type?.toUpperCase()&&Zd(x.color,c.color)),m=d||f?void 0:r.find(x=>!i.has(x.globalTrayId)&&x.type?.toUpperCase()===c.type?.toUpperCase()),p=d??f??m;p&&i.add(p.globalTrayId),a.push({slot_id:u,globalTrayId:p?.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 m9={useDefault:!0,manualMappings:{},autoConfigured:!1};function l8e(t,e,n,r,i,a){const o=Yle({queries:t.map(x=>({queryKey:["printer-status",x],queryFn:()=>he.getPrinterStatus(x),enabled:t.length>0,staleTime:5e3}))}),l=w.useMemo(()=>t.map((x,y)=>{const b=o[y],v=b?.data,S=e?.find(R=>R.id===x)?.name||`Printer ${x}`,T=qO(v),E=i[x]||m9,C=f9(n,v),A=E.useDefault?r:E.manualMappings,O=o8e(n,v,A),k=s8e(n?.filaments,T,A);return{printerId:x,printerName:S,status:v,isLoading:b?.isLoading??!1,loadedFilaments:T,autoMapping:C,finalMapping:O,matchStatus:k.status,exactMatches:k.exactMatches,typeOnlyMatches:k.typeOnlyMatches,missingTypes:k.missingTypes,totalSlots:k.totalSlots,config:E}}),[t,o,e,n,i,r]),c=o.some(x=>x.isLoading),u=(x,y)=>{a(b=>({...b,[x]:{...b[x]||m9,...y}}))},d=x=>{const y=l.find(N=>N.printerId===x);if(!y||!y.status||!n?.filaments)return;const b=f9(n,y.status);if(!b)return;const v={};b.forEach((N,S)=>{N!==-1&&(v[S+1]=N)}),u(x,{useDefault:!1,manualMappings:v,autoConfigured:!0})},f=()=>{for(const x of t)d(x)},m=x=>l.find(b=>b.printerId===x)?.finalMapping,p=l.every(x=>x.matchStatus!=="missing");return{printerResults:l,isLoading:c,perPrinterConfigs:i,updatePrinterConfig:u,autoConfigureAll:f,autoConfigurePrinter:d,getFinalMapping:m,allPrintersReady:p}}function c8e({printerResult:t,filamentReqs:e,onUpdateConfig:n}){const r=on(),[i,a]=w.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 he.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 m,p=!1;if(f!==void 0)m=t.loadedFilaments.find(y=>y.globalTrayId===f),p=!0;else{const y=new Set(Object.values(t.config.manualMappings)),b=t.loadedFilaments.find(S=>!y.has(S.globalTrayId)&&S.type?.toUpperCase()===u.type?.toUpperCase()&&ea(S.color)===ea(u.color)),v=b?void 0:t.loadedFilaments.find(S=>!y.has(S.globalTrayId)&&S.type?.toUpperCase()===u.type?.toUpperCase()&&Zd(S.color,u.color)),N=b||v?void 0:t.loadedFilaments.find(S=>!y.has(S.globalTrayId)&&S.type?.toUpperCase()===u.type?.toUpperCase());m=b??v??N}let x="mismatch";if(m){const y=m.type?.toUpperCase()===u.type?.toUpperCase(),b=ea(m.color)===ea(u.color)||Zd(m.color,u.color);y&&b?x="match":y&&(x="type_only")}return{req:u,loaded:m,status:x,isManual:p}});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(xr,{className:`w-3 h-3 ${i?"animate-spin":""}`}),s.jsx("span",{children:"Re-read"})]})]}),c.map(({req:u,loaded:d,status:f,isManual:m},p)=>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} - ${Mg(u.color)}`,children:s.jsx(Vj,{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"} ${m?"ring-1 ring-blue-400/50":""}`,title:m?"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(Ya,{className:"w-3 h-3 text-bambu-green"}):f==="type_only"?s.jsx("span",{title:"Same type, different color",children:s.jsx(yn,{className:"w-3 h-3 text-yellow-400"})}):s.jsx("span",{title:"Filament type not loaded",children:s.jsx(yn,{className:"w-3 h-3 text-orange-400"})})]},p))]})}function u8e({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:m,onTargetModelChange:p,slicedForModel:x}){const[y,b]=w.useState(!1),v=a?t:t.filter(j=>j.is_active),N=w.useMemo(()=>{if(d!=="printer"||!x||y)return v;const j=v.filter(W=>W.model===x);return j.length>0?j:v},[v,d,x,y]),S=v.length-N.length,T=w.useMemo(()=>{const j=v.map(W=>W.model).filter(W=>!!W);return[...new Set(j)].sort()},[v]),E=f&&p&&T.length>0,C=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(dt,{className:"w-6 h-6 text-bambu-green animate-spin"})});if(N.length===0)return s.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm mb-4",children:[s.jsx(ji,{className:"w-4 h-4"}),"No ",a?"":"active ","printers available"]});const A=j=>{i?e.includes(j)?n(e.filter(W=>W!==j)):n([...e,j]):n([j])},O=()=>{n(N.map(j=>j.id))},k=()=>{n([])},R=(j,W,Y)=>{Y.stopPropagation(),!(!c||!u)&&(W?c(j):u(j,{useDefault:!0,manualMappings:{},autoConfigured:!1}))},F=j=>e.includes(j),L=e.length,K=j=>o?.find(W=>W.printerId===j);return s.jsxs("div",{className:"space-y-2 mb-6",children:[E&&s.jsxs("div",{className:"flex gap-2 mb-4",children:[s.jsxs("button",{type:"button",onClick:()=>{f("printer"),p(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg border transition-colors ${d==="printer"?"border-bambu-green bg-bambu-green/10 text-white":"border-bambu-dark-tertiary bg-bambu-dark text-bambu-gray hover:border-bambu-gray"}`,children:[s.jsx(Mr,{className:"w-4 h-4"}),s.jsx("span",{className:"text-sm",children:"Specific Printer"})]}),s.jsxs("button",{type:"button",onClick:()=>{f("model"),n([]);const j=x&&T.includes(x)?x:T[0];p(j)},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(_d,{className:"w-4 h-4"}),s.jsxs("span",{className:"text-sm",children:["Any ",x||"Model"]})]})]}),d==="model"&&E&&m&&s.jsxs("p",{className:"text-xs text-bambu-gray mb-4",children:["Scheduler will assign to first available idle ",m," printer"]}),d==="printer"&&i&&N.length>1&&s.jsxs("div",{className:"flex items-center justify-between text-xs text-bambu-gray mb-2",children:[s.jsx("span",{children:L===0?"Select printers":`${L} printer${L!==1?"s":""} selected`}),s.jsxs("div",{className:"flex gap-2",children:[L<N.length&&s.jsx("button",{type:"button",onClick:O,className:"text-bambu-green hover:text-bambu-green/80 transition-colors",children:"Select all"}),L>0&&s.jsx("button",{type:"button",onClick:k,className:"text-bambu-gray hover:text-white transition-colors",children:"Clear"})]})]}),d==="printer"&&N.map(j=>{const W=F(j.id),Y=K(j.id),q=Y&&!Y.config.useDefault;return s.jsxs("div",{children:[s.jsxs("button",{type:"button",onClick:()=>A(j.id),className:`w-full flex items-center gap-3 p-3 rounded-lg border transition-colors ${W?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary bg-bambu-dark hover:border-bambu-gray"} ${j.is_active?"":"opacity-60"}`,children:[s.jsx("div",{className:`p-2 rounded-lg ${W?"bg-bambu-green/20":"bg-bambu-dark-tertiary"}`,children:s.jsx(Mr,{className:`w-5 h-5 ${W?"text-bambu-green":"text-bambu-gray"}`})}),s.jsxs("div",{className:"text-left flex-1",children:[s.jsxs("p",{className:"text-white font-medium",children:[j.name,!j.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:[j.model||"Unknown model"," • ",j.ip_address]})]}),i&&s.jsx("div",{className:`w-5 h-5 rounded border-2 flex items-center justify-center transition-colors ${W?"bg-bambu-green border-bambu-green":"border-bambu-gray/50"}`,children:W&&s.jsx(Ya,{className:"w-3 h-3 text-white"})})]}),W&&C&&Y&&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:Q=>Q.stopPropagation(),children:[s.jsx("input",{type:"checkbox",checked:q,onChange:Q=>R(j.id,Q.target.checked,Q),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 ${Y.matchStatus==="full"?"text-bambu-green":Y.matchStatus==="partial"?"text-yellow-400":"text-orange-400"}`,children:["(",Y.exactMatches,"/",Y.totalSlots," matched)"]}),Y.isLoading&&s.jsx(xr,{className:"w-3 h-3 text-bambu-gray animate-spin"}),q&&s.jsxs("button",{type:"button",onClick:Q=>{Q.stopPropagation(),c(j.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(lfe,{className:"w-3 h-3"}),"Auto"]})]}),q&&s.jsx(c8e,{printerResult:Y,filamentReqs:l.filaments,onUpdateConfig:Q=>u(j.id,Q)})]})]},j.id)}),d==="printer"&&S>0&&!y&&s.jsxs("button",{type:"button",onClick:()=>b(!0),className:"text-xs text-bambu-gray hover:text-white transition-colors mt-2 flex items-center gap-1",children:[s.jsx(yn,{className:"w-3 h-3 text-yellow-400"}),S," other printer",S>1?"s":""," hidden (different model) —",s.jsx("span",{className:"underline",children:"show all"})]}),d==="printer"&&y&&x&&s.jsx("button",{type:"button",onClick:()=>b(!1),className:"text-xs text-bambu-gray hover:text-white transition-colors mt-2",children:s.jsxs("span",{className:"underline",children:["Show only ",x," printers"]})}),d==="printer"&&L===0&&s.jsxs("p",{className:"text-xs text-orange-400 mt-1 flex items-center gap-1",children:[s.jsx(ji,{className:"w-3 h-3"}),"Select at least one printer"]}),d==="model"&&!m&&s.jsxs("p",{className:"text-xs text-orange-400 mt-1 flex items-center gap-1",children:[s.jsx(ji,{className:"w-3 h-3"}),"Select a target printer model"]})]})}function d8e({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(cl,{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(yn,{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(cl,{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?` • ${r8e(i.print_time_seconds)}`:""]})]}),n===i.index&&s.jsx(Ya,{className:"w-4 h-4 text-bambu-green flex-shrink-0"})]},i.index))})]})}function h8e({printerId:t,filamentReqs:e,manualMappings:n,onManualMappingChange:r,defaultExpanded:i=!1}){const a=on(),[o,l]=w.useState(!1),[c,u]=w.useState(i),{data:d}=ut({queryKey:["printer-status",t],queryFn:()=>he.getPrinterStatus(t),enabled:!!t}),{loadedFilaments:f,filamentComparison:m,hasTypeMismatch:p,hasColorMismatch:x}=aee(e,d,n);if(!(e?.filaments&&e.filaments.length>0)||!d)return null;const b=p?"#f97316":x?"#facc15":"#00ae42",v=(S,T)=>{if(S>0)if(T===""){const E={...n};delete E[S],r(E)}else r({...n,[S]:parseInt(T,10)})},N=async()=>{l(!0);try{await he.refreshPrinterStatus(t),await new Promise(S=>setTimeout(S,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(Vj,{className:"w-4 h-4",fill:b,stroke:"none"}),s.jsx("span",{children:"Filament Mapping"}),p?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(su,{className:"w-4 h-4 ml-auto"}):s.jsx(Pi,{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:N,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(xr,{className:`w-3 h-3 ${o?"animate-spin":""}`}),s.jsx("span",{children:"Re-read"})]})]}),m.map((S,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: ${S.type} - ${Mg(S.color)}`,children:s.jsx(Vj,{className:"w-3 h-3",fill:S.color,stroke:S.color})}),s.jsxs("span",{className:"text-white truncate",children:[S.type," ",s.jsxs("span",{className:"text-bambu-gray",children:["(",S.used_grams,"g)"]})]}),s.jsx("span",{className:"text-bambu-gray",children:"→"}),s.jsxs("select",{value:S.loaded?.globalTrayId??"",onChange:E=>v(S.slot_id||0,E.target.value),className:`flex-1 px-2 py-1 rounded border text-xs bg-bambu-dark-secondary focus:outline-none focus:ring-1 focus:ring-bambu-green ${S.status==="match"?"border-bambu-green/50 text-bambu-green":S.status==="type_only"?"border-yellow-400/50 text-yellow-400":"border-orange-400/50 text-orange-400"} ${S.isManual?"ring-1 ring-blue-400/50":""}`,title:S.isManual?"Manually selected":"Auto-matched",children:[s.jsx("option",{value:"",className:"bg-bambu-dark text-bambu-gray",children:"-- Select slot --"}),f.map(E=>s.jsxs("option",{value:E.globalTrayId,className:"bg-bambu-dark text-white",children:[E.label,": ",E.type," (",E.colorName,")"]},E.globalTrayId))]}),S.status==="match"?s.jsx(Ya,{className:"w-3 h-3 text-bambu-green"}):S.status==="type_only"?s.jsx("span",{title:"Same type, different color",children:s.jsx(yn,{className:"w-3 h-3 text-yellow-400"})}):s.jsx("span",{title:"Filament type not loaded",children:s.jsx(yn,{className:"w-3 h-3 text-orange-400"})})]},T)),p&&s.jsx("p",{className:"text-xs text-orange-400 mt-2",children:"Required filament type not found in printer."})]})]})}const f8e=[{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 m8e({options:t,onChange:e,defaultExpanded:n=!1}){const[r,i]=w.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(V2,{className:"w-4 h-4"}),s.jsx("span",{children:"Print Options"}),r?s.jsx(su,{className:"w-4 h-4 ml-auto"}):s.jsx(Pi,{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:f8e.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 p8e({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(Kn,{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(ri,{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(aq,{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:i8e(),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 wp={bed_levelling:!0,flow_cali:!1,vibration_cali:!0,layer_inspect:!1,timelapse:!1},g8e={scheduleType:"asap",scheduledTime:"",requirePreviousSuccess:!1,autoOffAfter:!1};function Jd({mode:t,archiveId:e,libraryFileId:n,archiveName:r,queueItem:i,onClose:a,onSuccess:o}){const l=on(),{showToast:c}=Vn(),u=!!n&&!e,[d,f]=w.useState(()=>t==="edit-queue-item"&&i?.printer_id?[i.printer_id]:[]),[m,p]=w.useState(()=>t==="edit-queue-item"&&i?i.plate_id:null),[x,y]=w.useState(()=>t==="edit-queue-item"&&i?{bed_levelling:i.bed_levelling??wp.bed_levelling,flow_cali:i.flow_cali??wp.flow_cali,vibration_cali:i.vibration_cali??wp.vibration_cali,layer_inspect:i.layer_inspect??wp.layer_inspect,timelapse:i.timelapse??wp.timelapse}:wp),[b,v]=w.useState(()=>{if(t==="edit-queue-item"&&i){let $e="asap";i.manual_start?$e="manual":i.scheduled_time&&!h9(i.scheduled_time)&&($e="scheduled");let Le="";return i.scheduled_time&&!h9(i.scheduled_time)&&(Le=new Date(i.scheduled_time).toISOString().slice(0,16)),{scheduleType:$e,scheduledTime:Le,requirePreviousSuccess:i.require_previous_success,autoOffAfter:i.auto_off_after}}return g8e}),[N,S]=w.useState(()=>{if(t==="edit-queue-item"&&i?.ams_mapping&&Array.isArray(i.ams_mapping)){const $e={};return i.ams_mapping.forEach((Le,qe)=>{Le!==-1&&($e[qe+1]=Le)}),$e}return{}}),[T,E]=w.useState({}),[C,A]=w.useState(()=>t==="edit-queue-item"&&i?.target_model?"model":"printer"),[O,k]=w.useState(()=>t==="edit-queue-item"&&i?.target_model?i.target_model:null),[R]=w.useState(()=>t==="edit-queue-item"&&i?.printer_id?[i.printer_id]:[]),[F]=w.useState(()=>t==="edit-queue-item"&&i?i.plate_id:null),[L,K]=w.useState(!1),[j,W]=w.useState({current:0,total:0}),[Y,q]=w.useState(new Set),Q=d.length,ee=d.length>0?d[0]:null,{data:re}=ut({queryKey:["settings"],queryFn:he.getSettings}),{data:z,isLoading:G}=ut({queryKey:["printers"],queryFn:he.getPrinters}),{data:ae}=ut({queryKey:["archive",e],queryFn:()=>he.getArchive(e),enabled:!!e&&!u}),se=ae?.sliced_for_model||null,{data:ue,isError:pe}=ut({queryKey:["archive-plates",e],queryFn:()=>he.getArchivePlates(e),enabled:!!e&&!u,retry:!1}),{data:ce}=ut({queryKey:["library-file-plates",n],queryFn:()=>he.getLibraryFilePlates(n),enabled:u&&!!n}),Me=u?ce:ue,{data:me,isError:Ee}=ut({queryKey:["archive-filaments",e,m],queryFn:()=>he.getArchiveFilamentRequirements(e,m??void 0),enabled:!!e&&!u&&(m!==null||!Me?.is_multi_plate),retry:!1}),{data:fe}=ut({queryKey:["library-file-filaments",n,m],queryFn:()=>he.getLibraryFileFilamentRequirements(n,m??void 0),enabled:u&&!!n&&(m!==null||!Me?.is_multi_plate)}),le=!u&&(pe||Ee),Be=u?fe:me,{data:V}=ut({queryKey:["printer-status",ee],queryFn:()=>he.getPrinterStatus(ee),enabled:!!ee}),{amsMapping:$}=aee(Be,V,N),X=l8e(d,z,Be,N,T,E);w.useEffect(()=>{Me?.plates?.length===1&&!m&&p(Me.plates[0].index)},[Me,m]),w.useEffect(()=>{if(t==="edit-queue-item")return;const $e=z?.filter(Le=>Le.is_active)||[];$e.length===1&&d.length===0&&f([$e[0].id])},[t,z,d.length]),w.useEffect(()=>{t==="edit-queue-item"?(JSON.stringify(d.sort())!==JSON.stringify(R.sort())||m!==F)&&(S({}),E({}),q(new Set)):(S({}),E({}),q(new Set))},[t,d,m,R,F]),w.useEffect(()=>{if(!re?.per_printer_mapping_expanded||d.length<=1)return;const $e=d.filter(Le=>{if(Y.has(Le))return!1;const qe=X.printerResults.find(Ke=>Ke.printerId===Le);return qe&&qe.status&&!qe.isLoading});$e.length>0&&(q(Le=>{const qe=new Set(Le);return $e.forEach(Ke=>qe.add(Ke)),qe}),$e.forEach(Le=>{X.autoConfigurePrinter(Le)}))},[re?.per_printer_mapping_expanded,d,Y,X]),w.useEffect(()=>{const $e=Le=>{Le.key==="Escape"&&!L&&a()};return window.addEventListener("keydown",$e),()=>window.removeEventListener("keydown",$e)},[a,L]);const U=Me?.is_multi_plate??!1,B=Me?.plates??[],oe=pt({mutationFn:$e=>he.addToQueue($e)}),Te=pt({mutationFn:$e=>he.updateQueueItem(i.id,$e),onSuccess:()=>{l.invalidateQueries({queryKey:["queue"]}),c("Queue item updated"),o?.(),a()},onError:$e=>{c($e.message||"Failed to update queue item","error")}}),je=async $e=>{if($e?.preventDefault(),C==="printer"&&d.length===0){c("Please select at least one printer","error");return}if(C==="model"&&!O){c("Please select a target printer model","error");return}K(!0);const Le=C==="model"?1:d.length;W({current:0,total:Le});const qe={success:0,failed:0,errors:[]},Ke=ie=>{if(d.length>1){const te=T[ie];if(te&&!te.useDefault)return X.getFinalMapping(ie)}return $},Ye=ie=>({printer_id:C==="printer"?ie:null,target_model:C==="model"?O:null,archive_id:u?void 0:e,library_file_id:u?n:void 0,require_previous_success:b.requirePreviousSuccess,auto_off_after:b.autoOffAfter,manual_start:b.scheduleType==="manual",ams_mapping:ie?Ke(ie):void 0,plate_id:m,scheduled_time:b.scheduleType==="scheduled"&&b.scheduledTime?new Date(b.scheduledTime).toISOString():void 0,...x});if(C==="model"){W({current:1,total:1});try{if(t==="reprint"){c("Model-based assignment only works with queue mode","error"),K(!1);return}else if(t==="edit-queue-item"){const ie={printer_id:null,target_model:O,require_previous_success:b.requirePreviousSuccess,auto_off_after:b.autoOffAfter,manual_start:b.scheduleType==="manual",ams_mapping:void 0,plate_id:m,scheduled_time:b.scheduleType==="scheduled"&&b.scheduledTime?new Date(b.scheduledTime).toISOString():null,...x};await Te.mutateAsync(ie)}else await oe.mutateAsync(Ye(null));qe.success++}catch(ie){qe.failed++,qe.errors.push(ie.message)}}else for(let ie=0;ie<d.length;ie++){const te=d[ie];W({current:ie+1,total:d.length});try{if(t==="reprint"){const Se=Ke(te);u?await he.printLibraryFile(n,te,{ams_mapping:Se,...x}):await he.reprintArchive(e,te,{plate_id:m??void 0,ams_mapping:Se,...x})}else if(t==="edit-queue-item"&&ie===0){const Se=Ke(te),ze={printer_id:te,target_model:null,require_previous_success:b.requirePreviousSuccess,auto_off_after:b.autoOffAfter,manual_start:b.scheduleType==="manual",ams_mapping:Se,plate_id:m,scheduled_time:b.scheduleType==="scheduled"&&b.scheduledTime?new Date(b.scheduledTime).toISOString():null,...x};await Te.mutateAsync(ze)}else await oe.mutateAsync(Ye(te));qe.success++}catch(Se){qe.failed++;const ze=z?.find(nt=>nt.id===te)?.name||`Printer ${te}`;qe.errors.push(`${ze}: ${Se.message}`)}}if(K(!1),qe.failed===0){if(C==="model")c(t==="edit-queue-item"?"Queue item updated":`Queued for any ${O}`);else{const ie=t==="reprint"?"sent to":t==="edit-queue-item"?"updated/queued for":"queued for";qe.success===1?c(t==="edit-queue-item"?"Queue item updated":`Print ${ie} printer`):c(`Print ${ie} ${qe.success} printers`)}l.invalidateQueries({queryKey:["queue"]}),o?.(),a()}else qe.success===0?c(`Failed: ${qe.errors[0]}`,"error"):(c(`${qe.success} succeeded, ${qe.failed} failed`,"error"),l.invalidateQueries({queryKey:["queue"]}))},Ce=L||Te.isPending,H=w.useMemo(()=>!(Ce||C==="printer"&&d.length===0||C==="model"&&!O||C==="model"&&t==="reprint"||!u&&U&&!m),[d.length,C,O,t,U,m,Ce,u]),Z=(()=>{const $e=d.length;return t==="reprint"?{title:u?"Print":"Re-print",icon:Mr,submitText:$e>1?`Print to ${$e} Printers`:"Print",submitIcon:Mr,loadingText:j.total>1?`Sending ${j.current}/${j.total}...`:"Sending..."}:t==="add-to-queue"?{title:"Schedule Print",icon:ri,submitText:$e>1?`Queue to ${$e} Printers`:"Add to Queue",submitIcon:ri,loadingText:j.total>1?`Adding ${j.current}/${j.total}...`:"Adding..."}:{title:"Edit Queue Item",icon:ia,submitText:"Save",submitIcon:ia,loadingText:j.total>1?`Saving ${j.current}/${j.total}...`:"Saving..."}})(),xe=Z.icon,Ne=Z.submitIcon,ve=ee&&(u||(U?m!==null:!0));return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:L?void 0:a,children:s.jsx(Nt,{className:"w-full max-w-lg max-h-[90vh] overflow-y-auto",onClick:$e=>$e.stopPropagation(),children:s.jsxs(Et,{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(xe,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:Z.title})]}),s.jsx(we,{variant:"ghost",size:"sm",onClick:a,disabled:L,children:s.jsx(zt,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:je,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(d8e,{plates:B,isMultiPlate:U,selectedPlate:m,onSelect:p}),s.jsx(u8e,{printers:z||[],selectedPrinterIds:d,onMultiSelect:f,isLoading:G,allowMultiple:!0,showInactive:t==="edit-queue-item",printerMappingResults:X.printerResults,filamentReqs:Be,onAutoConfigurePrinter:X.autoConfigurePrinter,onUpdatePrinterConfig:X.updatePrinterConfig,assignmentMode:t==="reprint"?"printer":C,onAssignmentModeChange:t!=="reprint"?A:void 0,targetModel:O,onTargetModelChange:t!=="reprint"?k:void 0,slicedForModel:se}),se&&C==="printer"&&d.length===1&&(()=>{const $e=z?.find(Le=>Le.id===d[0]);return $e&&$e.model&&se!==$e.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(yn,{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 ",se,", but printing on ",$e.model]})]}):null})(),le&&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(ji,{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."})]}),ve&&!le&&d.length===1&&s.jsx(h8e,{printerId:ee,filamentReqs:Be,manualMappings:N,onManualMappingChange:S,defaultExpanded:re?.per_printer_mapping_expanded??!1}),(t==="reprint"||Q>0||C==="model"&&O)&&s.jsx(m8e,{options:x,onChange:y}),t!=="reprint"&&s.jsx(p8e,{options:b,onChange:v}),Te.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:Te.error?.message||"Failed to complete operation"}),s.jsxs("div",{className:`flex gap-3 ${t==="reprint"?"":"pt-2"}`,children:[s.jsx(we,{type:"button",variant:"secondary",onClick:a,className:"flex-1",disabled:L,children:"Cancel"}),s.jsx(we,{type:"submit",disabled:!H,className:"flex-1",children:Ce?s.jsxs(s.Fragment,{children:[s.jsx(dt,{className:"w-4 h-4 animate-spin"}),Z.loadingText]}):s.jsxs(s.Fragment,{children:[s.jsx(Ne,{className:"w-4 h-4"}),Z.submitText]})})]})]})]})})})}function x8e({onClose:t,initialFiles:e}){const n=on(),{showToast:r}=Vn(),i=w.useRef(null),[a,o]=w.useState(()=>e?.filter(T=>T.name.endsWith(".3mf")).map(T=>({file:T,status:"pending"}))||[]),[l,c]=w.useState(!1),[u,d]=w.useState(null);w.useEffect(()=>{const T=E=>{E.key==="Escape"&&t()};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[t]);const f=pt({mutationFn:T=>he.uploadArchivesBulk(T),onSuccess:T=>{d(T),n.invalidateQueries({queryKey:["archives"]}),n.invalidateQueries({queryKey:["archiveStats"]}),o(E=>E.map(C=>{const A=T.results.find(k=>k.filename===C.file.name),O=T.errors.find(k=>k.filename===C.file.name);return A?{...C,status:"success",archiveId:A.id}:O?{...C,status:"error",error:O.error}:C})),T.failed===0?r(`${T.uploaded} file${T.uploaded!==1?"s":""} uploaded`):T.uploaded===0?r(`Failed to upload ${T.failed} file${T.failed!==1?"s":""}`,"error"):r(`${T.uploaded} uploaded, ${T.failed} failed`,"warning")},onError:()=>{o(T=>T.map(E=>({...E,status:"error",error:"Upload failed"}))),r("Upload failed","error")}}),m=w.useCallback(T=>{T.preventDefault(),c(!0)},[]),p=w.useCallback(T=>{T.preventDefault(),c(!1)},[]),x=w.useCallback(T=>{T.preventDefault(),c(!1);const E=Array.from(T.dataTransfer.files).filter(C=>C.name.endsWith(".3mf"));E.length>0&&o(C=>[...C,...E.map(A=>({file:A,status:"pending"}))])},[]),y=w.useCallback(T=>{const E=Array.from(T.target.files||[]).filter(C=>C.name.endsWith(".3mf"));E.length>0&&o(C=>[...C,...E.map(A=>({file:A,status:"pending"}))]),i.current&&(i.current.value="")},[]),b=w.useCallback(T=>{o(E=>E.filter((C,A)=>A!==T))},[]),v=()=>{if(a.length===0)return;const T=a.filter(E=>E.status==="pending");T.length!==0&&(o(E=>E.map(C=>C.status==="pending"?{...C,status:"uploading"}:C)),f.mutate(T.map(E=>E.file)))},N=a.filter(T=>T.status==="pending").length,S=f.isPending;return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:s.jsx(Nt,{className:"w-full max-w-2xl max-h-[90vh] flex flex-col",children:s.jsxs(Et,{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:"Upload 3MF Files"}),s.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(zt,{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 ${l?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,onDragOver:m,onDragLeave:p,onDrop:x,children:[s.jsx(di,{className:"w-12 h-12 mx-auto mb-4 text-bambu-gray"}),s.jsx("p",{className:"text-white mb-2",children:"Drag & drop .3mf files here"}),s.jsx("p",{className:"text-bambu-gray text-sm mb-4",children:"or"}),s.jsx(we,{variant:"secondary",onClick:()=>i.current?.click(),disabled:S,children:"Browse Files"}),s.jsx("input",{ref:i,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:"The printer model will be automatically extracted from the 3MF file metadata."})}),a.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:a.map((T,E)=>s.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[s.jsx(O2,{className:"w-5 h-5 text-bambu-gray flex-shrink-0"}),s.jsx("span",{className:"flex-1 text-white text-sm truncate",children:T.file.name}),s.jsxs("span",{className:"text-xs text-bambu-gray",children:[(T.file.size/(1024*1024)).toFixed(1)," MB"]}),T.status==="pending"&&s.jsx("button",{onClick:()=>b(E),className:"text-bambu-gray hover:text-red-400 transition-colors",disabled:S,children:s.jsx(zt,{className:"w-4 h-4"})}),T.status==="uploading"&&s.jsx(dt,{className:"w-4 h-4 text-bambu-green animate-spin"}),T.status==="success"&&s.jsx(Fn,{className:"w-4 h-4 text-bambu-green"}),T.status==="error"&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-xs text-red-400",children:T.error}),s.jsx(ji,{className:"w-4 h-4 text-red-400"})]})]},`${T.file.name}-${E}`))})}),u&&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:u.uploaded})," uploaded",u.failed>0&&s.jsxs(s.Fragment,{children:[", ",s.jsx("span",{className:"text-red-400",children:u.failed})," failed"]})]})})}),s.jsxs("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary",children:[s.jsx(we,{variant:"secondary",onClick:t,className:"flex-1",children:u?"Close":"Cancel"}),!u&&s.jsx(we,{onClick:v,disabled:N===0||S,className:"flex-1",children:S?s.jsxs(s.Fragment,{children:[s.jsx(dt,{className:"w-4 h-4 animate-spin"}),"Uploading..."]}):s.jsxs(s.Fragment,{children:[s.jsx(di,{className:"w-4 h-4"}),"Upload ",N>0&&`(${N})`]})})]})]})})})}const b8e=["Adhesion failure","Spaghetti / Detached","Layer shift","Clogged nozzle","Filament runout","Warping","Stringing","Under-extrusion","Power failure","User cancelled","Other"],y8e=[{value:"completed",label:"Completed"},{value:"failed",label:"Failed"},{value:"aborted",label:"Cancelled"},{value:"printing",label:"Printing"}];function see({archive:t,onClose:e,existingTags:n=[]}){w.useEffect(()=>{const ce=Me=>{Me.key==="Escape"&&e()};return window.addEventListener("keydown",ce),()=>window.removeEventListener("keydown",ce)},[e]);const r=on(),[i,a]=w.useState(t.print_name||""),[o,l]=w.useState(t.printer_id),[c,u]=w.useState(t.project_id??null),[d,f]=w.useState(t.notes||""),[m,p]=w.useState(t.tags||""),[x,y]=w.useState(t.failure_reason||""),[b,v]=w.useState(t.status),[N,S]=w.useState(t.quantity??1),[T,E]=w.useState(t.photos||[]),[C,A]=w.useState(t.external_url||""),[O,k]=w.useState(!1),[R,F]=w.useState(!1),L=w.useRef(null),K=w.useRef(null),j=w.useRef(null),{data:W}=ut({queryKey:["printers"],queryFn:he.getPrinters}),{data:Y}=ut({queryKey:["projects"],queryFn:()=>he.getProjects()}),{data:q}=ut({queryKey:["archives"],queryFn:()=>he.getArchives(void 0,1e3,0),enabled:n.length===0}),Q=n.length>0?n:[...new Set(q?.flatMap(ce=>ce.tags?.split(",").map(Me=>Me.trim())||[]).filter(Boolean)||[])].sort(),ee=m.split(",").map(ce=>ce.trim()).filter(Boolean),re=Q.filter(ce=>!ee.includes(ce)),z=ce=>{if(!ee.includes(ce)){const Me=[...ee,ce].join(", ");p(Me)}j.current!==null&&clearTimeout(j.current),L.current?.focus()},G=ce=>{const Me=ee.filter(me=>me!==ce).join(", ");p(Me)},ae=pt({mutationFn:ce=>he.updateArchive(t.id,ce),onSuccess:()=>{r.invalidateQueries({queryKey:["archives"]}),r.invalidateQueries({queryKey:["projects"]}),e()}}),se=async ce=>{const Me=ce.target.files?.[0];if(Me){k(!0);try{const me=await he.uploadArchivePhoto(t.id,Me);E(me.photos),r.invalidateQueries({queryKey:["archives"]})}catch(me){console.error("Failed to upload photo:",me)}finally{k(!1),K.current&&(K.current.value="")}}},ue=async ce=>{try{const Me=await he.deleteArchivePhoto(t.id,ce);E(Me.photos||[]),r.invalidateQueries({queryKey:["archives"]})}catch(Me){console.error("Failed to delete photo:",Me)}},pe=ce=>{ce.preventDefault();const Me={print_name:i||void 0,printer_id:o,project_id:c,notes:d||void 0,tags:m||void 0,quantity:N,external_url:C||null};b!==t.status&&(Me.status=b),b==="failed"||b==="aborted"?Me.failure_reason=x||void 0:(t.status==="failed"||t.status==="aborted")&&(Me.failure_reason=null),ae.mutate(Me)};return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-md max-h-[90vh] flex flex-col",onClick:ce=>ce.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:"Edit Archive"}),s.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(zt,{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:"Name"}),s.jsx("input",{type:"text",value:i,onChange:ce=>a(ce.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:"Print name"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),s.jsxs("select",{value:o??"",onChange:ce=>l(ce.target.value?Number(ce.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"}),W?.map(ce=>s.jsx("option",{value:ce.id,children:ce.name},ce.id))]})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[s.jsx(wa,{className:"w-4 h-4 inline mr-1"}),"Project"]}),s.jsxs("select",{value:c??"",onChange:ce=>u(ce.target.value?Number(ce.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 project"}),Y?.map(ce=>s.jsx("option",{value:ce.id,children:ce.name},ce.id))]})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[s.jsx(Zue,{className:"w-4 h-4 inline mr-1"}),"Items Printed"]}),s.jsx("input",{type:"number",min:1,value:N,onChange:ce=>S(Math.max(1,parseInt(ce.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:"Number of items produced in this print job"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Notes"}),s.jsx("textarea",{value:d,onChange:ce=>f(ce.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:"Add notes about this print..."})]}),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"}),"External Link"]}),s.jsx("input",{type:"url",value:C,onChange:ce=>A(ce.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:"Link to Printables, Thingiverse, or other source"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Tags"}),ee.length>0&&s.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:ee.map(ce=>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(ag,{className:"w-3 h-3"}),ce,s.jsx("button",{type:"button",onClick:()=>G(ce),className:"ml-0.5 text-bambu-gray hover:text-white",children:s.jsx(zt,{className:"w-3 h-3"})})]},ce))}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{ref:L,type:"text",value:m,onChange:ce=>p(ce.target.value),onFocus:()=>{j.current!==null&&clearTimeout(j.current),F(!0)},onBlur:()=>{j.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:ee.length>0?"Add more tags...":"Add tags..."}),R&&re.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.jsx("div",{className:"p-2 text-xs text-bambu-gray border-b border-bambu-dark-tertiary",children:"Existing tags (click to add)"}),s.jsx("div",{className:"p-2 flex flex-wrap gap-1.5",children:re.map(ce=>s.jsx("button",{type:"button",onClick:()=>z(ce),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:ce},ce))})]})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Status"}),s.jsx("select",{value:b,onChange:ce=>{v(ce.target.value),ce.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:y8e.map(ce=>s.jsx("option",{value:ce.value,children:ce.label},ce.value))})]}),(b==="failed"||b==="aborted")&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Failure Reason"}),s.jsxs("select",{value:x,onChange:ce=>y(ce.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:"Select reason..."}),b8e.map(ce=>s.jsx("option",{value:ce,children:ce},ce))]})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[s.jsx(Tf,{className:"w-4 h-4 inline mr-1"}),"Photos of Printed Result"]}),s.jsxs("div",{className:"flex flex-wrap gap-2 mb-2",children:[T.map(ce=>s.jsxs("div",{className:"relative group",children:[s.jsx("img",{src:he.getArchivePhotoUrl(t.id,ce),alt:"Print result",className:"w-20 h-20 object-cover rounded-lg border border-bambu-dark-tertiary"}),s.jsx("button",{type:"button",onClick:()=>ue(ce),className:"absolute -top-1 -right-1 p-1 bg-red-500 rounded-full opacity-0 group-hover:opacity-100 transition-opacity",children:s.jsx(un,{className:"w-3 h-3 text-white"})})]},ce)),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:K,type:"file",accept:"image/jpeg,image/png,image/webp",onChange:se,className:"hidden",disabled:O}),O?s.jsx(dt,{className:"w-6 h-6 text-bambu-gray animate-spin"}):s.jsx(Jn,{className:"w-6 h-6 text-bambu-gray"})]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Click + to add photos of your printed result"})]}),s.jsxs("div",{className:"flex gap-3 pt-2",children:[s.jsx(we,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),s.jsxs(we,{type:"submit",disabled:ae.isPending,className:"flex-1",children:[s.jsx(gs,{className:"w-4 h-4"}),ae.isPending?"Saving...":"Save"]})]})]})]})})}function oee({x:t,y:e,items:n,onClose:r}){const i=w.useRef(null),[a,o]=w.useState(null),l=w.useRef(null),[c,u]=w.useState({x:t,y:e,visible:!1}),[d,f]=w.useState(!1),[m,p]=w.useState({});w.useEffect(()=>{const b=S=>{i.current&&!i.current.contains(S.target)&&r()},v=S=>{S.key==="Escape"&&r()},N=()=>{r()};return document.addEventListener("mousedown",b),document.addEventListener("keydown",v),document.addEventListener("scroll",N,!0),()=>{document.removeEventListener("mousedown",b),document.removeEventListener("keydown",v),document.removeEventListener("scroll",N,!0),l.current&&clearTimeout(l.current)}},[r]),w.useLayoutEffect(()=>{if(i.current){i.current.style.visibility="hidden",i.current.style.display="block";const b=i.current.getBoundingClientRect(),v=window.innerWidth,N=window.innerHeight,S=8;let T=t,E=e;t+b.width>v-S&&(T=Math.max(S,v-b.width-S)),T<S&&(T=S),e+b.height>N-S&&(E=Math.max(S,N-b.height-S)),E<S&&(E=S);const C=180,A=v-T-b.width,O=T;f(A<C&&O>C),u({x:T,y:E,visible:!0})}},[t,e]);const x=(b,v)=>{l.current&&(clearTimeout(l.current),l.current=null);const N=v.getBoundingClientRect(),S=window.innerHeight,T=300,A=S-N.top-8<T&&N.top>T;p(O=>({...O,[b]:A?"bottom":"top"})),o(b)},y=()=>{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((b,v)=>{if(b.divider)return s.jsx("div",{className:"my-1 border-t border-bambu-dark-tertiary"},v);const N=b.submenu&&b.submenu.length>0;return s.jsxs("div",{className:"relative",onMouseEnter:S=>N&&x(v,S.currentTarget),onMouseLeave:()=>N&&y(),children:[s.jsxs("button",{onMouseEnter:S=>N&&x(v,S.currentTarget.parentElement),onClick:()=>{N?o(a===v?null:v):b.disabled||(b.onClick(),r())},disabled:b.disabled,className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-left transition-colors ${b.disabled?"text-bambu-gray cursor-not-allowed":b.danger?"text-red-400 hover:bg-red-400/10":"text-white hover:bg-bambu-dark-tertiary"} ${N&&a===v?"bg-bambu-dark-tertiary":""}`,children:[b.icon&&s.jsx("span",{className:"w-4 h-4 flex-shrink-0 flex items-center justify-center",children:b.icon}),s.jsx("span",{className:"flex-1",children:b.label}),N&&s.jsx(Ys,{className:"w-4 h-4 text-bambu-gray"})]}),N&&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"} ${m[v]==="bottom"?"bottom-0":"top-0"}`,onMouseEnter:()=>{l.current&&(clearTimeout(l.current),l.current=null)},onMouseLeave:()=>y(),children:b.submenu.map((S,T)=>s.jsxs("button",{onClick:()=>{S.disabled||(S.onClick(),r())},disabled:S.disabled,className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-left transition-colors ${S.disabled?"text-bambu-gray cursor-not-allowed":S.danger?"text-red-400 hover:bg-red-400/10":"text-white hover:bg-bambu-dark-tertiary"}`,children:[S.icon&&s.jsx("span",{className:"w-4 h-4 flex-shrink-0 flex items-center justify-center",children:S.icon}),S.label]},T))})]},v)})})}function v8e({selectedIds:t,existingTags:e,onClose:n}){const r=on(),{showToast:i}=Vn(),[a,o]=w.useState(""),[l,c]=w.useState(new Set),[u,d]=w.useState("add");w.useEffect(()=>{const y=b=>{b.key==="Escape"&&n()};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[n]);const f=pt({mutationFn:async()=>{const y=Array.from(l);let b=0;for(const v of t)try{const N=await he.getArchive(v),S=N.tags?N.tags.split(",").map(E=>E.trim()).filter(Boolean):[];let T;u==="add"?T=[...new Set([...S,...y])]:T=S.filter(E=>!l.has(E)),await he.updateArchive(v,{tags:T.join(", ")}),b++}catch(N){throw console.error(`Failed to update archive ${v}:`,N),new Error(`Failed on archive ${v}: ${N instanceof Error?N.message:"Unknown error"}`)}return{count:b,mode:u,tags:y}},onSuccess:({count:y,mode:b,tags:v})=>{r.invalidateQueries({queryKey:["archives"]}),i(`${b==="add"?"Added":"Removed"} ${v.length} tag${v.length!==1?"s":""} ${b==="add"?"to":"from"} ${y} archive${y!==1?"s":""}`),n()},onError:y=>{i(y.message||"Failed to update tags","error")}}),m=y=>{c(b=>{const v=new Set(b);return v.has(y)?v.delete(y):v.add(y),v})},p=()=>{a.trim()&&!l.has(a.trim())&&(c(y=>new Set([...y,a.trim()])),o(""))},x=y=>{y.key==="Enter"&&(y.preventDefault(),p())};return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:s.jsx(Nt,{className:"w-full max-w-md",children:s.jsxs(Et,{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(ag,{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(zt,{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(we,{size:"sm",variant:u==="add"?"primary":"secondary",onClick:()=>d("add"),children:"Add Tags"}),s.jsx(we,{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:y=>o(y.target.value),onKeyDown:x}),s.jsx(we,{size:"sm",variant:"secondary",onClick:p,disabled:!a.trim(),children:s.jsx(Jn,{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(y=>s.jsx("button",{onClick:()=>m(y),className:`px-2 py-1 rounded text-sm transition-colors ${l.has(y)?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray-light hover:bg-bambu-dark"}`,children:y},y))})]}),l.size>0&&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(y=>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:[y,s.jsx("button",{onClick:()=>m(y),className:"hover:opacity-70",children:s.jsx(zt,{className:"w-3 h-3"})})]},y))})]})]}),s.jsxs("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary",children:[s.jsx(we,{variant:"secondary",onClick:n,className:"flex-1",children:"Cancel"}),s.jsx(we,{onClick:()=>f.mutate(),disabled:l.size===0||f.isPending,className:"flex-1",children:f.isPending?s.jsxs(s.Fragment,{children:[s.jsx(dt,{className:"w-4 h-4 animate-spin"}),"Processing..."]}):s.jsxs(s.Fragment,{children:[s.jsx(ag,{className:"w-4 h-4"}),u==="add"?"Add Tags":"Remove Tags"]})})]})]})})})}function _8e({selectedIds:t,onClose:e}){const n=on(),{showToast:r}=Vn(),{data:i,isLoading:a}=ut({queryKey:["projects"],queryFn:()=>he.getProjects()});w.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=pt({mutationFn:async d=>(await he.addArchivesToProject(d,t),d),onSuccess:d=>{const f=i?.find(m=>m.id===d);o(),r(`Added ${t.length} archive${t.length!==1?"s":""} to "${f?.name}"`),e()},onError:()=>{r("Failed to assign project","error")}}),c=pt({mutationFn:async()=>{for(const d of t)await he.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(Nt,{className:"w-full max-w-md max-h-[80vh] flex flex-col",children:s.jsxs(Et,{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(wa,{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(zt,{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(dt,{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(ta,{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(dt,{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(wa,{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(dt,{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(we,{variant:"secondary",onClick:e,className:"flex-1",disabled:u,children:"Cancel"})})]})})})}function w8e(t,e){return new Date(t,e+1,0).getDate()}function S8e(t,e){return new Date(t,e,1).getDay()}const N8e=["January","February","March","April","May","June","July","August","September","October","November","December"],M8e=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function E8e({archives:t,onArchiveClick:e,highlightedArchiveId:n}){const r=new Date,[i,a]=w.useState(r.getMonth()),[o,l]=w.useState(r.getFullYear()),[c,u]=w.useState(null),[d,f]=w.useState(null),m=w.useMemo(()=>{const E=new Map;return t.forEach(C=>{const A=vi(C.completed_at||C.created_at)||new Date,O=`${A.getFullYear()}-${String(A.getMonth()+1).padStart(2,"0")}-${String(A.getDate()).padStart(2,"0")}`,k=E.get(O)||[];k.push(C),E.set(O,k)}),E},[t]),p=w8e(o,i),x=S8e(o,i),y=()=>{i===0?(a(11),l(o-1)):a(i-1)},b=()=>{i===11?(a(0),l(o+1)):a(i+1)},v=()=>{a(r.getMonth()),l(r.getFullYear())},N=[];for(let E=0;E<x;E++)N.push(null);for(let E=1;E<=p;E++)N.push(E);const S=c?m.get(c)||[]:[],T=E=>{E!==c&&f(null),u(E)};return s.jsxs("div",{className:"flex flex-col lg:flex-row gap-6",children:[s.jsxs("div",{className:"flex-1",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsx("button",{onClick:y,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:s.jsx(Af,{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:[N8e[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:b,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:s.jsx(Ys,{className:"w-5 h-5 text-bambu-gray"})})]}),s.jsx("div",{className:"grid grid-cols-7 gap-1 mb-1",children:M8e.map(E=>s.jsx("div",{className:"text-center text-xs text-bambu-gray py-2",children:E},E))}),s.jsx("div",{className:"grid grid-cols-7 gap-1",children:N.map((E,C)=>{if(E===null)return s.jsx("div",{className:"aspect-square"},`empty-${C}`);const A=`${o}-${String(i+1).padStart(2,"0")}-${String(E).padStart(2,"0")}`,O=m.get(A)||[],k=O.length>0,R=E===r.getDate()&&i===r.getMonth()&&o===r.getFullYear(),F=A===c,L=O.filter(j=>j.status==="completed").length,K=O.filter(j=>j.status==="failed").length;return s.jsxs("button",{onClick:()=>T(F?null:A),className:`aspect-square rounded-lg p-1 flex flex-col items-center justify-center transition-colors relative ${F?"bg-bambu-green text-white":R?"bg-bambu-green/20 text-white ring-2 ring-bambu-green":k?"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&&!F?"text-bambu-green":""}`,children:E}),k&&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 ${K>0&&L===0?"bg-red-400":K>0?"bg-yellow-400":"bg-green-400"}`}),s.jsx("span",{className:"text-xs font-medium",children:O.length})]})]},E)})}),s.jsx("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:s.jsxs("div",{className:"grid grid-cols-3 gap-4 text-center",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-2xl font-bold text-white",children:t.filter(E=>{const C=new Date(E.completed_at||E.created_at);return C.getMonth()===i&&C.getFullYear()===o}).length}),s.jsx("div",{className:"text-xs text-bambu-gray",children:"Prints this month"})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-2xl font-bold text-green-400",children:t.filter(E=>{const C=new Date(E.completed_at||E.created_at);return C.getMonth()===i&&C.getFullYear()===o&&E.status==="completed"}).length}),s.jsx("div",{className:"text-xs text-bambu-gray",children:"Successful"})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-2xl font-bold text-red-400",children:t.filter(E=>{const C=new Date(E.completed_at||E.created_at);return C.getMonth()===i&&C.getFullYear()===o&&E.status==="failed"}).length}),s.jsx("div",{className:"text-xs text-bambu-gray",children:"Failed"})]})]})})]}),s.jsx("div",{className:"lg:w-80 bg-bambu-dark rounded-xl p-4",children:c?s.jsxs(s.Fragment,{children:[s.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-3",children:new Date(c+"T12:00:00").toLocaleDateString("en-US",{weekday:"long",month:"long",day:"numeric",year:"numeric"})}),S.length>0?s.jsx("div",{className:"space-y-2 max-h-96 overflow-y-auto",children:S.map(E=>{const C=E.id===d||E.id===n;return s.jsxs("button",{onClick:()=>{f(E.id),e?.(E)},className:`w-full flex items-center gap-3 p-2 rounded-lg transition-colors text-left ${C?"":"hover:bg-bambu-dark-tertiary"}`,style:C?{outline:"4px solid #facc15",outlineOffset:"2px"}:void 0,children:[E.thumbnail_path?s.jsx("img",{src:he.getArchiveThumbnail(E.id),alt:"",className:"w-12 h-12 rounded object-cover"}):s.jsx("div",{className:"w-12 h-12 rounded bg-bambu-dark-tertiary flex items-center justify-center",children:s.jsx("span",{className:"text-xs text-bambu-gray",children:"3MF"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-sm text-white truncate",children:E.print_name||E.filename}),s.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[s.jsx("span",{className:E.status==="failed"?"text-red-400":"text-green-400",children:E.status==="failed"?"Failed":"Completed"}),E.filament_color&&s.jsx("div",{className:"flex gap-0.5",children:E.filament_color.split(",").map((A,O)=>s.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:A}},O))})]})]})]},E.id)})}):s.jsx("p",{className:"text-sm text-bambu-gray",children:"No prints on this day"})]}):s.jsx("div",{className:"text-center py-8",children:s.jsx("p",{className:"text-sm text-bambu-gray",children:"Select a day to see prints"})})})]})}function lee({archiveId:t,archiveName:e,onClose:n}){const r=he.getArchiveQRCodeUrl(t,300);w.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(zt,{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(we,{onClick:i,className:"w-full",children:[s.jsx($r,{className:"w-4 h-4"}),"Download QR Code"]})]})]})})}function cee({archiveId:t,archiveName:e,photos:n,onClose:r,onDelete:i}){const[a,o]=w.useState(0),[l,c]=w.useState(!1);if(w.useEffect(()=>{const p=x=>{x.key==="Escape"&&r(),x.key==="ArrowLeft"&&o(y=>Math.max(0,y-1)),x.key==="ArrowRight"&&o(y=>Math.min(n.length-1,y+1))};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[r,n.length]),w.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=he.getArchivePhotoUrl(t,u),f=()=>{const p=document.createElement("a");p.href=d,p.download=`${e}_photo_${a+1}.jpg`,p.click()},m=()=>{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:p=>p.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(we,{variant:"secondary",size:"sm",onClick:f,children:[s.jsx($r,{className:"w-4 h-4"}),"Download"]}),i&&s.jsx(we,{variant:"secondary",size:"sm",onClick:m,className:"text-red-400 hover:text-red-300",children:s.jsx(un,{className:"w-4 h-4"})}),s.jsx("button",{onClick:r,className:"p-2 text-bambu-gray hover:text-white transition-colors",children:s.jsx(zt,{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(p=>p-1),className:"absolute left-4 z-10 p-3 bg-black/50 hover:bg-black/70 rounded-full transition-colors",children:s.jsx(Af,{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(p=>p+1),className:"absolute right-4 z-10 p-3 bg-black/50 hover:bg-black/70 rounded-full transition-colors",children:s.jsx(Ys,{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((p,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:he.getArchivePhotoUrl(t,p),alt:`Thumbnail ${x+1}`,className:"w-full h-full object-cover"})},p))})]}),l&&s.jsx(Bn,{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 uee(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=uee(i.content,a.content,n+1);if(o!=null)return o}n+=i.nodeSize}}function dee(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=dee(o.content,l.content,n-1,r-1);if(u)return u}n-=c,r-=c}}class At{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,n,r,i=0,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 At(i,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],i=0;if(n>e)for(let 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 At(r,i)}cutByIndex(e,n){return e==n?At.empty:e==0&&n==this.content.length?this:new At(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let i=this.content.slice(),a=this.size+n.nodeSize-r.nodeSize;return i[e]=n,new At(i,a)}addToStart(e){return new At([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new At(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(e.content[n]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let n=this.content[e];if(!n)throw new RangeError("Index "+e+" out of range for "+this);return n}maybeChild(e){return this.content[e]||null}forEach(e){for(let n=0,r=0;n<this.content.length;n++){let i=this.content[n];e(i,r,n),r+=i.nodeSize}}findDiffStart(e,n=0){return uee(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return dee(this,e,n,r)}findIndex(e){if(e==0)return w1(0,e);if(e==this.size)return w1(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?w1(n+1,a):w1(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 At.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new At(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return At.empty;let n,r=0;for(let i=0;i<e.length;i++){let 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 At(n||e,r)}static from(e){if(!e)return At.empty;if(e instanceof At)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new At([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}At.empty=new At([],0);const Hk={index:0,offset:0};function w1(t,e){return Hk.index=t,Hk.offset=e,Hk}function DS(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(!DS(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!DS(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let vr=class oR{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&&DS(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 oR.none;if(e instanceof oR)return[e];let n=e.slice();return n.sort((r,i)=>r.type.rank-i.type.rank),n}};vr.none=[];class OS 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=fee(this.content,e+this.openStart,n);return r&&new Ut(r,this.openStart,this.openEnd)}removeBetween(e,n){return new Ut(hee(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(At.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(At.empty,0,0);function hee(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(hee(a.content,e-i-1,n-i-1)))}function fee(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=fee(o.content,e-a-1,n,o);return l&&t.replaceChild(i,o.copy(l))}function T8e(t,e,n){if(n.openStart>t.depth)throw new OS("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new OS("Inconsistent open depths");return mee(t,e,n,0)}function mee(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=mee(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 vf(o,l.cut(0,t.parentOffset).append(n.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=A8e(n,t);return vf(a,gee(t,o,l,e,r))}else return vf(a,LS(t,e,r))}function pee(t,e){if(!e.type.compatibleContent(t.type))throw new OS("Cannot join "+e.type.name+" onto "+t.type.name)}function lR(t,e,n){let r=t.node(n);return pee(r,e.node(n)),r}function yf(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 qb(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&&(yf(t.nodeAfter,r),a++));for(let l=a;l<o;l++)yf(i.child(l),r);e&&e.depth==n&&e.textOffset&&yf(e.nodeBefore,r)}function vf(t,e){return t.type.checkContent(e),t.copy(e)}function gee(t,e,n,r,i){let a=t.depth>i&&lR(t,e,i+1),o=r.depth>i&&lR(n,r,i+1),l=[];return qb(null,t,i,l),a&&o&&e.index(i)==n.index(i)?(pee(a,o),yf(vf(a,gee(t,e,n,r,i+1)),l)):(a&&yf(vf(a,LS(t,e,i+1)),l),qb(e,n,i,l),o&&yf(vf(o,LS(n,r,i+1)),l)),qb(r,null,i,l),new At(l)}function LS(t,e,n){let r=[];if(qb(null,t,n,r),t.depth>n){let i=lR(t,e,n+1);yf(vf(i,LS(t,e,n+1)),r)}return qb(e,null,n,r),new At(r)}function A8e(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(At.from(i));return{start:i.resolveNoCache(t.openStart+n),end:i.resolveNoCache(i.content.size-t.openEnd-n)}}class H0{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 vr.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 IS(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 H0(n,r,a)}static resolveCached(e,n){let r=p9.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 p9.set(e,r=new C8e);let i=r.elts[r.i]=H0.resolve(e,n);return r.i=(r.i+1)%k8e,i}}class C8e{constructor(){this.elts=[],this.i=0}}const k8e=12,p9=new WeakMap;class IS{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 j8e=Object.create(null);let Id=class cR{constructor(e,n,r,i=vr.none){this.type=e,this.attrs=n,this.marks=i,this.content=r||At.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,n,r,i=0){this.content.nodesBetween(e,n,r,i,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,n,r,i){return this.content.textBetween(e,n,r,i)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,n,r){return this.type==e&&DS(this.attrs,n||e.defaultAttrs||j8e)&&vr.sameSet(this.marks,r||vr.none)}copy(e=null){return e==this.content?this:new cR(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new cR(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 T8e(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 H0.resolveCached(this,e)}resolveNoCache(e){return H0.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()+")"),xee(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(e,n,r=At.empty,i=0,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=vr.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(!vr.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(n=>n.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let r;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,r)}let i=At.fromJSON(e,n.content),a=e.nodeType(n.type).create(n.attrs,i,r);return a.type.checkAttrs(a.attrs),a}};Id.prototype.text=void 0;class FS extends Id{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):xee(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 FS(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new FS(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 xee(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class Wf{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new P8e(e,n);if(r.next==null)return Wf.empty;let i=bee(r);r.next&&r.err("Unexpected trailing text");let a=U8e(F8e(i));return z8e(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 At.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 m=a(f,l.concat(d));if(m)return m}}return null}return a(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}computeWrapping(e){let n=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let i=r.shift(),a=i.match;if(a.matchType(e)){let o=[];for(let l=i;l.type;l=l.via)o.push(l.type);return o.reverse()}for(let o=0;o<a.next.length;o++){let{type:l,next:c}=a.next[o];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in n)&&(!i.type||c.validEnd)&&(r.push({match:l.contentMatch,type:l,via:i}),n[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(r){e.push(r);for(let i=0;i<r.next.length;i++)e.indexOf(r.next[i].next)==-1&&n(r.next[i].next)}return n(this),e.map((r,i)=>{let a=i+(r.validEnd?"*":" ")+" ";for(let o=0;o<r.next.length;o++)a+=(o?", ":"")+r.next[o].type.name+"->"+e.indexOf(r.next[o].next);return a}).join(`
  8142. `)}}Wf.empty=new Wf(!0);class P8e{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 bee(t){let e=[];do e.push(R8e(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function R8e(t){let e=[];do e.push(D8e(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function D8e(t){let e=I8e(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=O8e(t,e);else break;return e}function g9(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function O8e(t,e){let n=g9(t),r=n;return t.eat(",")&&(t.next!="}"?r=g9(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function L8e(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 I8e(t){if(t.eat("(")){let e=bee(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=L8e(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 F8e(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 yee(t,e){return e-t}function x9(t,e){let n=[];return r(e),n.sort(yee);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 U8e(t){let e=Object.create(null);return n(x9(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]);x9(t,c).forEach(d=>{u||i.push([l,u=[]]),u.indexOf(d)==-1&&u.push(d)})})});let a=e[r.join(",")]=new Wf(r.indexOf(t.length-1)>-1);for(let o=0;o<i.length;o++){let l=i[o][1].sort(yee);a.next.push({type:i[o][0],next:e[l.join(",")]||n(l)})}return a}}function z8e(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 vee(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 _ee(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 wee(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 See(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new $8e(t,r,e[r]);return n}let b9=class Nee{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=See(e,r.attrs),this.defaultAttrs=vee(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==Wf.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:_ee(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Id(this,this.computeAttrs(e),At.from(n),vr.setFrom(r))}createChecked(e=null,n,r){return n=At.from(n),this.checkContent(n),new Id(this,this.computeAttrs(e),n,vr.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=At.from(n),n.size){let o=this.contentMatch.fillBefore(n);if(!o)return null;n=o.append(n)}let i=this.contentMatch.matchFragment(n),a=i&&i.fillBefore(At.empty,!0);return a?new Id(this,e,n.append(a),vr.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){wee(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:vr.none:e}static compile(e,n){let r=Object.create(null);e.forEach((a,o)=>r[a]=new Nee(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 B8e(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 $8e{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?B8e(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class YN{constructor(e,n,r,i){this.name=e,this.rank=n,this.schema=r,this.spec=i,this.attrs=See(e,i.attrs),this.excluded=null;let a=vee(this.attrs);this.instance=a?new vr(this,a):null}create(e=null){return!e&&this.instance?this.instance:new vr(this,_ee(this.attrs,e))}static compile(e,n){let r=Object.create(null),i=0;return e.forEach((a,o)=>r[a]=new YN(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){wee(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class Mee{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=b9.compile(this.spec.nodes,this),this.marks=YN.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]=Wf.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?y9(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==""?[]:y9(this,o.split(" "))}this.nodeFromJSON=i=>Id.fromJSON(this,i),this.markFromJSON=i=>vr.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 b9){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 FS(r,r.defaultAttrs,e,vr.setFrom(n))}mark(e,n){return typeof e=="string"&&(e=this.marks[e]),e.create(n)}nodeType(e){let n=this.nodes[e];if(!n)throw new RangeError("Unknown node type: "+e);return n}}function y9(t,e){let n=[];for(let r=0;r<e.length;r++){let i=e[r],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 H8e(t){return t.tag!=null}function V8e(t){return t.style!=null}let Kb=class uR{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(i=>{if(H8e(i))this.tags.push(i);else if(V8e(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 _9(this,n,!1);return r.addAll(e,vr.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new _9(this,n,!0);return r.addAll(e,vr.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(q8e(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=w9(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=w9(o)),o.node||o.ignore||o.mark||(o.node=i)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new uR(e,uR.schemaRules(e)))}};const Eee={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},G8e={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Tee={ol:!0,ul:!0},V0=1,dR=2,Xb=4;function v9(t,e,n){return e!=null?(e?V0:0)|(e==="full"?dR:0):t&&t.whitespace=="pre"?V0|dR:n&~Xb}class S1{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=vr.none,this.match=a||(o&Xb?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(At.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,i;return(i=r.findWrapping(e.type))?(this.match=r,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&V0)){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=At.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(At.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Eee.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class _9{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=v9(null,n.preserveWhitespace,0)|(r?Xb:0);i?a=new S1(i.type,i.attrs,vr.none,!0,n.topMatch||i.type.contentMatch,o):r?a=new S1(null,null,vr.none,!0,null,o):a=new S1(e.schema.topNodeType,null,vr.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&dR?"full":this.localPreserveWS||(i.options&V0)>0,{schema:o}=this.parser;if(a==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(a)if(a==="full")r=r.replace(/\r\n?/g,`
  8143. `);else if(o.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(o.linebreakReplacement.create())){let l=r.split(/\r?\n|\r/);for(let c=0;c<l.length;c++)c&&this.insertNode(o.linebreakReplacement.create(),n,!0),l[c]&&this.insertNode(o.text(l[c]),n,!/\S/.test(l[c]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let l=i.content[i.content.length-1],c=e.previousSibling;(!l||c&&c.nodeName=="BR"||l.isText&&/[ \t\r\n\u000c]$/.test(l.text))&&(r=r.slice(1))}r&&this.insertNode(o.text(r),n,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,n,r){let i=this.localPreserveWS,a=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let o=e.nodeName.toLowerCase(),l;Tee.hasOwnProperty(o)&&this.parser.normalizeLists&&W8e(e);let c=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(c?c.ignore:G8e.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(Eee.hasOwnProperty(o))a.content.length&&a.content[0].isInline&&this.open&&(this.open--,a=this.top),u=!0,a.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,n);break e}let f=c&&c.skip?n:this.readStyles(e,n);f&&this.addAll(e,f),u&&this.sync(a),this.needsBlock=d}else{let u=this.readStyles(e,n);u&&this.addElementByRule(e,c,u,c.consuming===!1?l:void 0)}this.localPreserveWS=i}leafFallback(e,n){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
  8144. `),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(e,n){let r=e.style;if(r&&r.length)for(let i=0;i<this.parser.matchedStyles.length;i++){let a=this.parser.matchedStyles[i],o=r.getPropertyValue(a);if(o)for(let l=void 0;;){let c=this.parser.matchStyle(a,o,this,l);if(!c)break;if(c.ignore)return null;if(c.clearMark?n=n.filter(u=>!c.clearMark(u)):n=n.concat(this.parser.schema.marks[c.mark].create(c.attrs)),c.consuming===!1)l=c;else break}}return n}addElementByRule(e,n,r,i){let a,o;if(n.node)if(o=this.parser.schema.nodes[n.node],o.isLeaf)this.insertNode(o.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let c=this.enter(o,n.attrs||null,r,n.preserveWhitespace);c&&(a=!0,r=c)}else{let c=this.parser.schema.marks[n.mark];r=r.concat(c.create(n.attrs))}let l=this.top;if(o&&o.isLeaf)this.findInside(e);else if(i)this.addElement(e,r,i);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(c=>this.insertNode(c,r,!1));else{let c=e;typeof n.contentElement=="string"?c=e.querySelector(n.contentElement):typeof n.contentElement=="function"?c=n.contentElement(e):n.contentElement&&(c=n.contentElement),this.findAround(e,c,!0),this.addAll(c,r),this.findAround(e,c,!1)}a&&this.sync(l)&&this.open--}addAll(e,n,r,i){let a=r||0;for(let o=r?e.childNodes[r]:e.firstChild,l=i==null?null:e.childNodes[i];o!=l;o=o.nextSibling,++a)this.findAtPoint(e,a),this.addDOM(o,n);this.findAtPoint(e,a)}findPlace(e,n,r){let i,a;for(let o=this.open,l=0;o>=0;o--){let c=this.nodes[o],u=c.findWrapping(e);if(u&&(!i||i.length>u.length+l)&&(i=u,a=c,!u.length))break;if(c.solid){if(r)break;l+=2}}if(!i)return null;this.sync(a);for(let o=0;o<i.length;o++)n=this.enterInner(i[o],null,n,!1);return n}insertNode(e,n,r){if(e.isInline&&this.needsBlock&&!this.top.type){let a=this.textblockFromContext();a&&(n=this.enterInner(a,null,n))}let i=this.findPlace(e,n,r);if(i){this.closeExtra();let a=this.top;a.match&&(a.match=a.match.matchType(e.type));let o=vr.none;for(let l of i.concat(e.marks))(a.type?a.type.allowsMarkType(l.type):S9(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=v9(e,a,o.options);o.options&Xb&&o.content.length==0&&(l|=Xb);let c=vr.none;return r=r.filter(u=>(o.type?o.type.allowsMarkType(u.type):S9(u.type,e))?(c=u.addToSet(c),!1):!0),this.nodes.push(new S1(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|=V0)}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 W8e(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Tee.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function q8e(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function w9(t){let e={};for(let n in t)e[n]=t[n];return e}function S9(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 im{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=Vk(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}=iw(Vk(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&&iw(Vk(r),i(e,n),null,e.attrs)}static renderSpec(e,n,r=null,i){return iw(e,n,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new im(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=N9(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return N9(e.marks)}}function N9(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function Vk(t){return t.document||window.document}const M9=new WeakMap;function K8e(t){let e=M9.get(t);return e===void 0&&M9.set(t,e=X8e(t)),e}function X8e(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 iw(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=K8e(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 m=f.indexOf(" ");m>0?c.setAttributeNS(f.slice(0,m),f.slice(m+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 m=e[f];if(m===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:p,contentDOM:x}=iw(t,m,n,r);if(c.appendChild(p),x){if(l)throw new RangeError("Multiple content holes");l=x}}}return{dom:c,contentDOM:l}}const Aee=65535,Cee=Math.pow(2,16);function Y8e(t,e){return t+e*Cee}function E9(t){return t&Aee}function Q8e(t){return(t-(t&Aee))/Cee}const kee=1,jee=2,aw=4,Pee=8;class hR{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&Pee)>0}get deletedBefore(){return(this.delInfo&(kee|aw))>0}get deletedAfter(){return(this.delInfo&(jee|aw))>0}get deletedAcross(){return(this.delInfo&aw)>0}}class $s{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&$s.empty)return $s.empty}recover(e){let n=0,r=E9(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+Q8e(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 m=u?e==c?-1:e==f?1:n:n,p=c+i+(m<0?0:d);if(r)return p;let x=e==(n<0?c:f)?null:Y8e(l/3,e-c),y=e==c?jee:e==f?kee:aw;return(n<0?e!=c:e!=f)&&(y|=Pee),new hR(p,y,x)}i+=d-u}return r?e+i:new hR(e+i,0,null)}touches(e,n){let r=0,i=E9(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 $s(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?$s.empty:new $s(e<0?[0,-e,0]:[0,0,e])}}$s.empty=new $s([]);class G0{constructor(e,n,r=0,i=e?e.length:0){this.mirror=n,this.from=r,this.to=i,this._maps=e||[],this.ownData=!(e||n)}get maps(){return this._maps}slice(e=0,n=this.maps.length){return new G0(this._maps,this.mirror,e,n)}appendMap(e,n){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),n!=null&&this.setMirror(this._maps.length-1,n)}appendMapping(e){for(let n=0,r=this._maps.length;n<e._maps.length;n++){let i=e.getMirror(n);this.appendMap(e._maps[n],i!=null&&i<n?r+i:void 0)}}getMirror(e){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==e)return this.mirror[n+(n%2?-1:1)]}}setMirror(e,n){this.mirror||(this.mirror=[]),this.mirror.push(e,n)}appendMappingInverted(e){for(let n=e.maps.length-1,r=this._maps.length+e._maps.length;n>=0;n--){let i=e.getMirror(n);this.appendMap(e._maps[n].invert(),i!=null&&i>n?r-i-1:void 0)}}invert(){let e=new G0;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,n);return e}mapResult(e,n=1){return this._map(e,n,!1)}_map(e,n,r){let i=0;for(let 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 hR(e,i,null)}}const Gk=Object.create(null);class Fa{getMap(){return $s.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Gk[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 Gk)throw new RangeError("Duplicate use of step JSON ID "+e);return Gk[e]=n,n.prototype.jsonID=e,n}}class Si{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new Si(e,null)}static fail(e){return new Si(null,e)}static fromReplace(e,n,r,i){try{return Si.ok(e.replace(n,r,i))}catch(a){if(a instanceof OS)return Si.fail(a.message);throw a}}}function KO(t,e,n){let r=[];for(let i=0;i<t.childCount;i++){let a=t.child(i);a.content.size&&(a=a.copy(KO(a.content,e,a))),a.isInline&&(a=e(a,n,i)),r.push(a)}return At.fromArray(r)}class Md extends Fa{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(KO(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 Si.fromReplace(e,this.from,this.to,a)}invert(){return new il(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 Md(n.pos,r.pos,this.mark)}merge(e){return e instanceof Md&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Md(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 Md(n.from,n.to,e.markFromJSON(n.mark))}}Fa.jsonID("addMark",Md);class il extends Fa{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(KO(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),n.openStart,n.openEnd);return Si.fromReplace(e,this.from,this.to,r)}invert(){return new Md(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 il(n.pos,r.pos,this.mark)}merge(e){return e instanceof il&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new il(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 il(n.from,n.to,e.markFromJSON(n.mark))}}Fa.jsonID("removeMark",il);class Ed extends Fa{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Si.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return Si.fromReplace(e,this.pos,this.pos+1,new Ut(At.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let i=0;i<n.marks.length;i++)if(!n.marks[i].isInSet(r))return new Ed(this.pos,n.marks[i]);return new Ed(this.pos,this.mark)}}return new qf(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Ed(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 Ed(n.pos,e.markFromJSON(n.mark))}}Fa.jsonID("addNodeMark",Ed);class qf extends Fa{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Si.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return Si.fromReplace(e,this.pos,this.pos+1,new Ut(At.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new Ed(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new qf(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 qf(n.pos,e.markFromJSON(n.mark))}}Fa.jsonID("removeNodeMark",qf);class Zi extends Fa{constructor(e,n,r,i=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=i}apply(e){return this.structure&&fR(e,this.from,this.to)?Si.fail("Structure replace would overwrite content"):Si.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new $s([this.from,this.to-this.from,this.slice.size])}invert(e){return new Zi(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 Zi(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof Zi)||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 Zi(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 Zi(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 Zi(n.from,n.to,Ut.fromJSON(e,n.slice),!!n.structure)}}Fa.jsonID("replace",Zi);class na extends Fa{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&&(fR(e,this.from,this.gapFrom)||fR(e,this.gapTo,this.to)))return Si.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return Si.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?Si.fromReplace(e,this.from,this.to,r):Si.fail("Content does not fit in gap")}getMap(){return new $s([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 na(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 na(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 na(n.from,n.to,n.gapFrom,n.gapTo,Ut.fromJSON(e,n.slice),n.insert,!!n.structure)}}Fa.jsonID("replaceAround",na);function fR(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 Z8e(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 m=Math.max(u,e),p=Math.min(u+c.nodeSize,n),x=r.addToSet(f);for(let y=0;y<f.length;y++)f[y].isInSet(x)||(o&&o.to==m&&o.mark.eq(f[y])?o.to=p:i.push(o=new il(m,p,f[y])));l&&l.to==m?l.to=p:a.push(l=new Md(m,p,r))}}),i.forEach(c=>t.step(c)),a.forEach(c=>t.step(c))}function J8e(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 YN){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],m;for(let p=0;p<i.length;p++){let x=i[p];x.step==a-1&&f.eq(i[p].style)&&(m=x)}m?(m.to=u,m.step=a):i.push({style:f,from:Math.max(l,e),to:u,step:a})}}}),i.forEach(o=>t.step(new il(o.from,o.to,o.style)))}function XO(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 Zi(l,d,Ut.empty));else{r=f;for(let m=0;m<u.marks.length;m++)n.allowsMarkType(u.marks[m].type)||t.step(new il(l,d,u.marks[m]));if(i&&u.isText&&n.whitespace!="pre"){let m,p=/\r?\n|\r/g,x;for(;m=p.exec(u.text);)x||(x=new Ut(At.from(n.schema.text(" ",n.allowedMarks(u.marks))),0,0)),o.push(new Zi(l+m.index,l+m.index+m[0].length,x))}}l=d}if(!r.validEnd){let c=r.fillBefore(At.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 e6e(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function rx(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||!e6e(o,l,c))break;l&&(i=1),c<o.childCount&&(a=1)}return null}function t6e(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=At.empty,f=0;for(let x=a,y=!1;x>n;x--)y||r.index(x)>0?(y=!0,d=At.from(r.node(x).copy(d)),f++):c--;let m=At.empty,p=0;for(let x=a,y=!1;x>n;x--)y||i.after(x+1)<i.end(x)?(y=!0,m=At.from(i.node(x).copy(m)),p++):u++;t.step(new na(c,u,o,l,new Ut(d.append(m),f,p),d.size-f,!0))}function YO(t,e,n=null,r=t){let i=n6e(t,e),a=i&&r6e(r,e);return a?i.map(T9).concat({type:e,attrs:n}).concat(a.map(T9)):null}function T9(t){return{type:t,attrs:null}}function n6e(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 r6e(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 i6e(t,e,n){let r=At.empty;for(let o=n.length-1;o>=0;o--){if(r.size){let l=n[o].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=At.from(n[o].type.create(n[o].attrs,r))}let i=e.start,a=e.end;t.step(new na(i,a,i,a,new Ut(r,0,0),n.length,!0))}function a6e(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)&&s6e(t.doc,t.mapping.slice(a).map(l),r)){let u=null;if(r.schema.linebreakReplacement){let p=r.whitespace=="pre",x=!!r.contentMatch.matchType(r.schema.linebreakReplacement);p&&!x?u=!1:!p&&x&&(u=!0)}u===!1&&Dee(t,o,l,a),XO(t,t.mapping.slice(a).map(l,1),r,void 0,u===null);let d=t.mapping.slice(a),f=d.map(l,1),m=d.map(l+o.nodeSize,1);return t.step(new na(f,m,f+1,m-1,new Ut(At.from(r.create(c,null,o.marks)),0,0),1,!0)),u===!0&&Ree(t,o,l,a),!1}})}function Ree(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 Dee(t,e,n,r){e.forEach((i,a)=>{if(i.type==i.type.schema.linebreakReplacement){let o=t.mapping.slice(r).map(n+1+a);t.replaceWith(o,o+1,e.type.schema.text(`
  8145. `))}})}function s6e(t,e,n){let r=t.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function o6e(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 na(e,e+a.nodeSize,e+1,e+a.nodeSize-1,new Ut(At.from(o),0,0),1,!0))}function ru(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),m=i.index(u);if(f.type.spec.isolating)return!1;let p=f.content.cutByIndex(m,f.childCount),x=r&&r[d+1];x&&(p=p.replaceChild(0,x.type.create(x.attrs)));let y=r&&r[d]||f;if(!f.canReplace(m+1,f.childCount)||!y.type.validContent(p))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 l6e(t,e,n=1,r){let i=t.doc.resolve(e),a=At.empty,o=At.empty;for(let l=i.depth,c=i.depth-n,u=n-1;l>c;l--,u--){a=At.from(i.node(l).copy(a));let d=r&&r[u];o=At.from(d?d.type.create(d.attrs,o):i.node(l).copy(o))}t.step(new Zi(e,e,new Ut(a.append(o),n,n),!0))}function lh(t,e){let n=t.resolve(e),r=n.index();return Oee(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function c6e(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 Oee(t,e){return!!(t&&e&&!t.isLeaf&&c6e(t,e))}function QN(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&&Oee(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 u6e(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);Dee(t,d.node(),d.before(),l)}o.inlineContent&&XO(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 Zi(u,c.map(e+n,-1),Ut.empty,!0)),r===!0){let d=t.doc.resolve(u);Ree(t,d.node(),d.before(),t.steps.length)}return t}function d6e(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 Lee(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 ZN(t,e,n=e,r=Ut.empty){if(e==n&&!r.size)return null;let i=t.resolve(e),a=t.resolve(n);return Iee(i,a,r)?new Zi(e,n,r):new h6e(i,a,r).fit()}function Iee(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class h6e{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=At.empty;for(let i=0;i<=e.depth;i++){let 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=At.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let u=this.findFittable();u?this.placeNodes(u):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(e<0?this.$to:r.doc.resolve(e));if(!i)return null;let 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 na(r.pos,e,this.$to.pos,this.$to.end(),c,n):c.size||r.pos!=this.$to.pos?new Zi(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=Wk(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(At.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=Wk(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=Wk(e,n);if(i.childCount<=1&&n>0){let a=e.size-n<=n+i.size;this.unplaced=new Ut(Pb(e,n-1,1),n-1,a?n-1:r)}else this.unplaced=new Ut(Pb(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 y=0;y<a.length;y++)this.openFrontierNode(a[y]);let o=this.unplaced,l=r?r.content:o.content,c=o.openStart-e,u=0,d=[],{match:f,type:m}=this.frontier[n];if(i){for(let y=0;y<i.childCount;y++)d.push(i.child(y));f=f.matchFragment(i)}let p=l.size+e-(o.content.size-o.openEnd);for(;u<l.childCount;){let y=l.child(u),b=f.matchType(y.type);if(!b)break;u++,(u>1||c==0||y.content.size)&&(f=b,d.push(Fee(y.mark(m.allowedMarks(y.marks)),u==1?c:0,u==l.childCount?p:-1)))}let x=u==l.childCount;x||(p=-1),this.placed=Rb(this.placed,n,At.from(d)),this.frontier[n].match=f,x&&p<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let y=0,b=l;y<p;y++){let v=b.lastChild;this.frontier.push({type:v.type,match:v.contentMatchAt(v.childCount)}),b=v.content}this.unplaced=x?e==0?Ut.empty:new Ut(Pb(o.content,e-1,1),e-1,p<0?o.openEnd:e-1):new Ut(Pb(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||!qk(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=qk(e,n,i,r,a);if(o){for(let l=n-1;l>=0;l--){let{match:c,type:u}=this.frontier[l],d=qk(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=Rb(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=Rb(this.placed,this.depth,At.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(At.empty,!0);n.childCount&&(this.placed=Rb(this.placed,this.frontier.length,n))}}function Pb(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(Pb(t.firstChild.content,e-1,n)))}function Rb(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(Rb(t.lastChild.content,e-1,n)))}function Wk(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function Fee(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,Fee(r.firstChild,e-1,r.childCount==1?n-1:0))),e>0&&(r=t.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(At.empty,!0)))),t.copy(r)}function qk(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&&!f6e(n,a.content,o)?l:null}function f6e(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function m6e(t){return t.spec.defining||t.spec.definingForContent}function p6e(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let i=t.doc.resolve(e),a=t.doc.resolve(n);if(Iee(i,a,r))return t.step(new Zi(e,n,r));let o=zee(i,a);o[o.length-1]==0&&o.pop();let l=-(i.depth+1);o.unshift(l);for(let m=i.depth,p=i.pos-1;m>0;m--,p--){let x=i.node(m).type.spec;if(x.defining||x.definingAsContext||x.isolating)break;o.indexOf(m)>-1?l=m:i.before(m)==p&&o.splice(1,0,-m)}let c=o.indexOf(l),u=[],d=r.openStart;for(let m=r.content,p=0;;p++){let x=m.firstChild;if(u.push(x),p==r.openStart)break;m=x.content}for(let m=d-1;m>=0;m--){let p=u[m],x=m6e(p.type);if(x&&!p.sameMarkup(i.node(Math.abs(l)-1)))d=m;else if(x||!p.type.isTextblock)break}for(let m=r.openStart;m>=0;m--){let p=(m+d+1)%(r.openStart+1),x=u[p];if(x)for(let y=0;y<o.length;y++){let b=o[(y+c)%o.length],v=!0;b<0&&(v=!1,b=-b);let N=i.node(b-1),S=i.index(b-1);if(N.canReplaceWith(S,S,x.type,x.marks))return t.replace(i.before(b),v?a.after(b):n,new Ut(Uee(r.content,0,r.openStart,p),p,r.openEnd))}}let f=t.steps.length;for(let m=o.length-1;m>=0&&(t.replace(e,n,r),!(t.steps.length>f));m--){let p=o[m];p<0||(e=i.before(p),n=a.after(p))}}function Uee(t,e,n,r,i){if(e<n){let a=t.firstChild;t=t.replaceChild(0,a.copy(Uee(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(At.empty,!0))}return t}function g6e(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let i=d6e(t.doc,e,r.type);i!=null&&(e=n=i)}t.replaceRange(e,n,new Ut(At.from(r),0,0))}function x6e(t,e,n){let r=t.doc.resolve(e),i=t.doc.resolve(n),a=zee(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 zee(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 eg extends Fa{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 Si.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 Si.fromReplace(e,this.pos,this.pos+1,new Ut(At.from(i),0,n.isLeaf?0:1))}getMap(){return $s.empty}invert(e){return new eg(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 eg(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 eg(n.pos,n.attr,n.value)}}Fa.jsonID("attr",eg);class W0 extends Fa{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 Si.ok(r)}getMap(){return $s.empty}invert(e){return new W0(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new W0(n.attr,n.value)}}Fa.jsonID("docAttr",W0);let Eg=class extends Error{};Eg=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};Eg.prototype=Object.create(Error.prototype);Eg.prototype.constructor=Eg;Eg.prototype.name="TransformError";class Bee{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new G0}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new Eg(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=ZN(this.doc,e,n,r);return i&&this.step(i),this}replaceWith(e,n,r){return this.replace(e,n,new Ut(At.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 p6e(this,e,n,r),this}replaceRangeWith(e,n,r){return g6e(this,e,n,r),this}deleteRange(e,n){return x6e(this,e,n),this}lift(e,n){return t6e(this,e,n),this}join(e,n=1){return u6e(this,e,n),this}wrap(e,n){return i6e(this,e,n),this}setBlockType(e,n=e,r,i=null){return a6e(this,e,n,r,i),this}setNodeMarkup(e,n,r=null,i){return o6e(this,e,n,r,i),this}setNodeAttribute(e,n,r){return this.step(new eg(e,n,r)),this}setDocAttribute(e,n){return this.step(new W0(e,n)),this}addNodeMark(e,n){return this.step(new Ed(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 vr)n.isInSet(r.marks)&&this.step(new qf(e,n));else{let i=r.marks,a,o=[];for(;a=n.isInSet(i);)o.push(new qf(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 l6e(this,e,n,r),this}addMark(e,n,r){return Z8e(this,e,n,r),this}removeMark(e,n,r){return J8e(this,e,n,r),this}clearIncompatible(e,n,r){return XO(this,e,n,r),this}}const Kk=Object.create(null);class En{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new b6e(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&&k9(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),k9(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let i=e.parent.inlineContent?new hn(e):jp(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?jp(e.node(0),e.node(a),e.before(a+1),e.index(a),n,r):jp(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 Ks(e.node(0))}static atStart(e){return jp(e,e,0,0,1)||new Ks(e)}static atEnd(e){return jp(e,e,e.content.size,e.childCount,-1)||new Ks(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Kk[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 Kk)throw new RangeError("Duplicate use of selection JSON ID "+e);return Kk[e]=n,n.prototype.jsonID=e,n}getBookmark(){return hn.between(this.$anchor,this.$head).getBookmark()}}En.prototype.visible=!0;class b6e{constructor(e,n){this.$from=e,this.$to=n}}let A9=!1;function C9(t){!A9&&!t.parent.inlineContent&&(A9=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class hn extends En{constructor(e,n=e){C9(e),C9(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 En.near(r);let i=e.resolve(n.map(this.anchor));return new hn(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 hn&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new JN(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 hn(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=En.findFrom(n,r,!0)||En.findFrom(n,-r,!0);if(a)n=a.$head;else return En.near(n,r)}return e.parent.inlineContent||(i==0?e=n:(e=(En.findFrom(e,-r,!0)||En.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=i<0&&(e=n))),new hn(e,n)}}En.jsonID("text",hn);class JN{constructor(e,n){this.anchor=e,this.head=n}map(e){return new JN(e.map(this.anchor),e.map(this.head))}resolve(e){return hn.between(e.resolve(this.anchor),e.resolve(this.head))}}class tn extends En{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?En.near(a):new tn(a)}content(){return new Ut(At.from(this.node),0,0)}eq(e){return e instanceof tn&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new QO(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new tn(e.resolve(n.anchor))}static create(e,n){return new tn(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}tn.prototype.visible=!1;En.jsonID("node",tn);class QO{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new JN(r,r):new QO(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&tn.isSelectable(r)?new tn(n):En.near(n)}}class Ks extends En{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=En.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new Ks(e)}map(e){return new Ks(e)}eq(e){return e instanceof Ks}getBookmark(){return y6e}}En.jsonID("all",Ks);const y6e={map(){return this},resolve(t){return new Ks(t)}};function jp(t,e,n,r,i,a=!1){if(e.inlineContent)return hn.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&&tn.isSelectable(l))return tn.create(t,n-(i<0?l.nodeSize:0))}else{let c=jp(t,l,n+i,i<0?l.childCount:0,i,a);if(c)return c}n+=l.nodeSize*i}return null}function k9(t,e,n){let r=t.steps.length-1;if(r<e)return;let i=t.steps[r];if(!(i instanceof Zi||i instanceof na))return;let a=t.mapping.maps[r],o;a.forEach((l,c,u,d)=>{o==null&&(o=d)}),t.setSelection(En.near(t.doc.resolve(o),n))}const j9=1,N1=2,P9=4;class v6e extends Bee{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|j9)&~N1,this.storedMarks=null,this}get selectionSet(){return(this.updated&j9)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=N1,this}ensureMarks(e){return vr.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&N1)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~N1,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)||vr.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(En.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|=P9,this}get scrolledIntoView(){return(this.updated&P9)>0}}function R9(t,e){return!e||!t?t:t.bind(e)}class Db{constructor(e,n,r){this.name=e,this.init=R9(n.init,r),this.apply=R9(n.apply,r)}}const _6e=[new Db("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Db("selection",{init(t,e){return t.selection||En.atStart(e.doc)},apply(t){return t.selection}}),new Db("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Db("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class Xk{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=_6e.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 Db(r.key,r.spec.state,r))})}}class Bp{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 Bp(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 v6e(this)}static create(e){let n=new Xk(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new Bp(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 Xk(this.schema,e.plugins),r=n.fields,i=new Bp(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 Xk(e.schema,e.plugins),a=new Bp(i);return i.fields.forEach(o=>{if(o.name=="doc")a.doc=Id.fromJSON(e.schema,n.doc);else if(o.name=="selection")a.selection=En.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 $ee(t,e,n){for(let r in t){let i=t[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=$ee(i,e,{})),n[r]=i}return n}class Kr{constructor(e){this.spec=e,this.props={},e.props&&$ee(e.props,this,this.props),this.key=e.key?e.key.key:Hee("plugin")}getState(e){return e[this.key]}}const Yk=Object.create(null);function Hee(t){return t in Yk?t+"$"+ ++Yk[t]:(Yk[t]=0,t+"$")}class $i{constructor(e="key"){this.key=Hee(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const ZO=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function Vee(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const Gee=(t,e,n)=>{let r=Vee(t,n);if(!r)return!1;let i=JO(r);if(!i){let o=r.blockRange(),l=o&&rx(o);return l==null?!1:(e&&e(t.tr.lift(o,l).scrollIntoView()),!0)}let a=i.nodeBefore;if(ete(t,i,e,-1))return!0;if(r.parent.content.size==0&&(Tg(a,"end")||tn.isSelectable(a)))for(let o=r.depth;;o--){let l=ZN(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(Tg(a,"end")?En.findFrom(c.doc.resolve(c.mapping.map(i.pos,-1)),-1):tn.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},w6e=(t,e,n)=>{let r=Vee(t,n);if(!r)return!1;let i=JO(r);return i?Wee(t,i,e):!1},S6e=(t,e,n)=>{let r=Kee(t,n);if(!r)return!1;let i=eL(r);return i?Wee(t,i,e):!1};function Wee(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=ZN(t.doc,a,c,Ut.empty);if(!u||u.from!=a||u instanceof Zi&&u.slice.size>=c-a)return!1;if(n){let d=t.tr.step(u);d.setSelection(hn.create(d.doc,a)),n(d.scrollIntoView())}return!0}function Tg(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 qee=(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=JO(r)}let o=a&&a.nodeBefore;return!o||!tn.isSelectable(o)?!1:(e&&e(t.tr.setSelection(tn.create(t.doc,a.pos-o.nodeSize)).scrollIntoView()),!0)};function JO(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 Kee(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const Xee=(t,e,n)=>{let r=Kee(t,n);if(!r)return!1;let i=eL(r);if(!i)return!1;let a=i.nodeAfter;if(ete(t,i,e,1))return!0;if(r.parent.content.size==0&&(Tg(a,"start")||tn.isSelectable(a))){let o=ZN(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(Tg(a,"start")?En.findFrom(l.doc.resolve(l.mapping.map(i.pos)),1):tn.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},Yee=(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=eL(r)}let o=a&&a.nodeAfter;return!o||!tn.isSelectable(o)?!1:(e&&e(t.tr.setSelection(tn.create(t.doc,a.pos)).scrollIntoView()),!0)};function eL(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 N6e=(t,e)=>{let n=t.selection,r=n instanceof tn,i;if(r){if(n.node.isTextblock||!lh(t.doc,n.from))return!1;i=n.from}else if(i=QN(t.doc,n.from,-1),i==null)return!1;if(e){let a=t.tr.join(i);r&&a.setSelection(tn.create(a.doc,i-t.doc.resolve(i).nodeBefore.nodeSize)),e(a.scrollIntoView())}return!0},M6e=(t,e)=>{let n=t.selection,r;if(n instanceof tn){if(n.node.isTextblock||!lh(t.doc,n.to))return!1;r=n.to}else if(r=QN(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},E6e=(t,e)=>{let{$from:n,$to:r}=t.selection,i=n.blockRange(r),a=i&&rx(i);return a==null?!1:(e&&e(t.tr.lift(i,a).scrollIntoView()),!0)},Qee=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(`
  8146. `).scrollIntoView()),!0)};function tL(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 T6e=(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=tL(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(En.near(c.doc.resolve(l),1)),e(c.scrollIntoView())}return!0},Zee=(t,e)=>{let n=t.selection,{$from:r,$to:i}=n;if(n instanceof Ks||r.parent.inlineContent||i.parent.inlineContent)return!1;let a=tL(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(hn.create(l.doc,o+1)),e(l.scrollIntoView())}return!0},Jee=(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(ru(t.doc,a))return e&&e(t.tr.split(a).scrollIntoView()),!0}let r=n.blockRange(),i=r&&rx(r);return i==null?!1:(e&&e(t.tr.lift(r,i).scrollIntoView()),!0)};function A6e(t){return(e,n)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof tn&&e.selection.node.isBlock)return!r.parentOffset||!ru(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 p=r.depth;;p--)if(r.node(p).isBlock){c=r.end(p)==r.pos+(r.depth-p),u=r.start(p)==r.pos-(r.depth-p),l=tL(r.node(p-1).contentMatchAt(r.indexAfter(p-1))),a.unshift(c&&l?{type:l}:null),o=p;break}else{if(p==1)return!1;a.unshift(null)}let d=e.tr;(e.selection instanceof hn||e.selection instanceof Ks)&&d.deleteSelection();let f=d.mapping.map(r.pos),m=ru(d.doc,f,a.length,a);if(m||(a[0]=l?{type:l}:null,m=ru(d.doc,f,a.length,a)),!m)return!1;if(d.split(f,a.length,a),!c&&u&&r.node(o).type!=l){let p=d.mapping.map(r.before(o)),x=d.doc.resolve(p);l&&r.node(o-1).canReplaceWith(x.index(),x.index()+1,l)&&d.setNodeMarkup(d.mapping.map(r.before(o)),l)}return n&&n(d.scrollIntoView()),!0}}const C6e=A6e(),k6e=(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(tn.create(t.doc,i))),!0)};function j6e(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||lh(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function ete(t,e,n,r){let i=e.nodeBefore,a=e.nodeAfter,o,l,c=i.type.spec.isolating||a.type.spec.isolating;if(!c&&j6e(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 p=e.pos+a.nodeSize,x=At.empty;for(let v=o.length-1;v>=0;v--)x=At.from(o[v].create(null,x));x=At.from(i.copy(x));let y=t.tr.step(new na(e.pos-1,p,e.pos,p,new Ut(x,1,0),o.length,!0)),b=y.doc.resolve(p+2*o.length);b.nodeAfter&&b.nodeAfter.type==i.type&&lh(y.doc,b.pos)&&y.join(b.pos),n(y.scrollIntoView())}return!0}let d=a.type.spec.isolating||r>0&&c?null:En.findFrom(e,1),f=d&&d.$from.blockRange(d.$to),m=f&&rx(f);if(m!=null&&m>=e.depth)return n&&n(t.tr.lift(f,m).scrollIntoView()),!0;if(u&&Tg(a,"start",!0)&&Tg(i,"end")){let p=i,x=[];for(;x.push(p),!p.isTextblock;)p=p.lastChild;let y=a,b=1;for(;!y.isTextblock;y=y.firstChild)b++;if(p.canReplace(p.childCount,p.childCount,y.content)){if(n){let v=At.empty;for(let S=x.length-1;S>=0;S--)v=At.from(x[S].copy(v));let N=t.tr.step(new na(e.pos-x.length,e.pos+a.nodeSize,e.pos+b,e.pos+a.nodeSize-b,new Ut(v,x.length,0),0,!0));n(N.scrollIntoView())}return!0}}return!1}function tte(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(hn.create(e.doc,t<0?i.start(a):i.end(a)))),!0):!1}}const P6e=tte(-1),R6e=tte(1);function D6e(t,e=null){return function(n,r){let{$from:i,$to:a}=n.selection,o=i.blockRange(a),l=o&&YO(o,t,e);return l?(r&&r(n.tr.wrap(o,l).scrollIntoView()),!0):!1}}function D9(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 nL(...t){return function(e,n,r){for(let i=0;i<t.length;i++)if(t[i](e,n,r))return!0;return!1}}nL(ZO,Gee,qee);nL(ZO,Xee,Yee);nL(Qee,Zee,Jee,C6e);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function O6e(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 L6e(l,o,t,e)?(r&&r(l.scrollIntoView()),!0):!1}}function L6e(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 IS(c,c,e.depth),e.endIndex<e.parent.childCount&&(e=new IS(e.$from,o.resolve(e.$to.end(e.depth)),e.depth)),i=!0}let l=YO(a,n,r,e);return l?(t&&I6e(t,e,l,i,n),!0):!1}function I6e(t,e,n,r,i){let a=At.empty;for(let d=n.length-1;d>=0;d--)a=At.from(n[d].type.create(n[d].attrs,a));t.step(new na(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,m=!0;d<f;d++,m=!1)!m&&ru(t.doc,c,l)&&(t.split(c,l),c+=2*l),c+=u.child(d).nodeSize;return t}function F6e(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?U6e(e,n,t,a):z6e(e,n,a):!0:!1}}function U6e(t,e,n,r){let i=t.tr,a=r.end,o=r.$to.end(r.depth);a<o&&(i.step(new na(a-1,o,a,o,new Ut(At.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new IS(i.doc.resolve(r.$from.pos),i.doc.resolve(o),r.depth));const l=rx(r);if(l==null)return!1;i.lift(r,l);let c=i.doc.resolve(i.mapping.map(a,-1)-1);return lh(i.doc,c.pos)&&c.nodeBefore.type==c.nodeAfter.type&&i.join(c.pos),e(i.scrollIntoView()),!0}function z6e(t,e,n){let r=t.tr,i=n.parent;for(let p=n.end,x=n.endIndex-1,y=n.startIndex;x>y;x--)p-=i.child(x).nodeSize,r.delete(p-1,p+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?At.empty:At.from(i))))return!1;let f=a.pos,m=f+o.nodeSize;return r.step(new na(f-(l?1:0),m+(c?1:0),f+1,m-1,new Ut((l?At.empty:At.from(i.copy(At.empty))).append(c?At.empty:At.from(i.copy(At.empty))),l?0:1,c?0:1),l?0:1)),e(r.scrollIntoView()),!0}function B6e(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=At.from(u?t.create():null),f=new Ut(At.from(t.create(null,At.from(l.type.create(null,d)))),u?3:1,0),m=a.start,p=a.end;n(e.tr.step(new na(m-(u?3:1),p,m,p,f,1,!0)).scrollIntoView())}return!0}}const ya=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},Ag=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let mR=null;const Ic=function(t,e,n){let r=mR||(mR=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},$6e=function(){mR=null},Kf=function(t,e,n,r){return n&&(O9(t,e,n,r,-1)||O9(t,e,n,r,1))},H6e=/^(img|br|input|textarea|hr)$/i;function O9(t,e,n,r,i){for(var a;;){if(t==n&&e==r)return!0;if(e==(i<0?0:Mo(t))){let o=t.parentNode;if(!o||o.nodeType!=1||Fy(t)||H6e.test(t.nodeName)||t.contentEditable=="false")return!1;e=ya(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?Mo(t):0}else return!1}}function Mo(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function V6e(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=Mo(t)}else if(t.parentNode&&!Fy(t))e=ya(t),t=t.parentNode;else return null}}function G6e(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&&!Fy(t))e=ya(t)+1,t=t.parentNode;else return null}}function W6e(t,e,n){for(let r=e==0,i=e==Mo(t);r||i;){if(t==n)return!0;let a=ya(t);if(t=t.parentNode,!t)return!1;r=r&&a==0,i=i&&a==Mo(t)}}function Fy(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 eM=function(t){return t.focusNode&&Kf(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function Yh(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function q6e(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function K6e(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(Mo(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(Mo(r.startContainer),r.startOffset)}}}const ql=typeof navigator<"u"?navigator:null,L9=typeof document<"u"?document:null,ch=ql&&ql.userAgent||"",pR=/Edge\/(\d+)/.exec(ch),nte=/MSIE \d/.exec(ch),gR=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(ch),_s=!!(nte||gR||pR),Fd=nte?document.documentMode:gR?+gR[1]:pR?+pR[1]:0,ko=!_s&&/gecko\/(\d+)/i.test(ch);ko&&+(/Firefox\/(\d+)/.exec(ch)||[0,0])[1];const xR=!_s&&/Chrome\/(\d+)/.exec(ch),Da=!!xR,rte=xR?+xR[1]:0,Ja=!_s&&!!ql&&/Apple Computer/.test(ql.vendor),Cg=Ja&&(/Mobile\/\w+/.test(ch)||!!ql&&ql.maxTouchPoints>2),yo=Cg||(ql?/Mac/.test(ql.platform):!1),X6e=ql?/Win/.test(ql.platform):!1,Xc=/Android \d/.test(ch),Uy=!!L9&&"webkitFontSmoothing"in L9.documentElement.style,Y6e=Uy?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Q6e(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 kc(t,e){return typeof t=="number"?t:t[e]}function Z6e(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 I9(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=Ag(o);continue}let l=o,c=l==a.body,u=c?Q6e(a):Z6e(l),d=0,f=0;if(e.top<u.top+kc(r,"top")?f=-(u.top-e.top+kc(i,"top")):e.bottom>u.bottom-kc(r,"bottom")&&(f=e.bottom-e.top>u.bottom-u.top?e.top+kc(i,"top")-u.top:e.bottom-u.bottom+kc(i,"bottom")),e.left<u.left+kc(r,"left")?d=-(u.left-e.left+kc(i,"left")):e.right>u.right-kc(r,"right")&&(d=e.right-u.right+kc(i,"right")),d||f)if(c)a.defaultView.scrollBy(d,f);else{let p=l.scrollLeft,x=l.scrollTop;f&&(l.scrollTop+=f),d&&(l.scrollLeft+=d);let y=l.scrollLeft-p,b=l.scrollTop-x;e={left:e.left-y,top:e.top-b,right:e.right-y,bottom:e.bottom-b}}let m=c?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(m))break;o=m=="absolute"?o.offsetParent:Ag(o)}}function J6e(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:ite(t.dom)}}function ite(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=Ag(r));return e}function e$e({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;ate(n,r==0?0:r-e)}function ate(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 Sp=null;function t$e(t){if(t.setActive)return t.setActive();if(Sp)return t.focus(Sp);let e=ite(t);t.focus(Sp==null?{get preventScroll(){return Sp={preventScroll:!0},!0}}:void 0),Sp||(Sp=!1,ate(e,0))}function ste(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 m;if(d.nodeType==1)m=d.getClientRects();else if(d.nodeType==3)m=Ic(d).getClientRects();else continue;for(let p=0;p<m.length;p++){let x=m[p];if(x.top<=o&&x.bottom>=l){o=Math.max(x.bottom,o),l=Math.min(x.top,l);let y=x.left>e.left?x.left-e.left:x.right<e.left?e.left-x.right:0;if(y<r){n=d,r=y,i=y&&n.nodeType==3?{left:x.right<e.left?x.right:x.left,top:e.top}:e,d.nodeType==1&&y&&(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?n$e(n,i):!n||r&&n.nodeType==1?{node:t,offset:a}:ste(n,i)}function n$e(t,e){let n=t.nodeValue.length,r=document.createRange();for(let i=0;i<n;i++){r.setEnd(t,i+1),r.setStart(t,i);let a=od(r,1);if(a.top!=a.bottom&&rL(e,a))return{node:t,offset:i+(e.left>=(a.left+a.right)/2?1:0)}}return{node:t,offset:0}}function rL(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function r$e(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function i$e(t,e,n){let{node:r,offset:i}=ste(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 a$e(t,e,n,r){let i=-1;for(let a=e,o=!1;a!=t.dom;){let l=t.docView.nearestDesc(a,!0),c;if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((c=l.dom.getBoundingClientRect()).width||c.height)&&(l.node.isBlock&&l.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(l.dom.nodeName)&&(!o&&c.left>r.left||c.top>r.top?i=l.posBefore:(!o&&c.right<r.left||c.bottom<r.top)&&(i=l.posAfter),o=!0),!l.contentDOM&&i<0&&!l.node.isText))return(l.node.isBlock?r.top<(c.top+c.bottom)/2:r.left<(c.left+c.right)/2)?l.posBefore:l.posAfter;a=l.dom.parentNode}return i>-1?i:t.docView.posFromDOM(e,n,-1)}function ote(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(rL(e,u))return ote(o,e,u)}}if((a=(a+1)%r)==i)break}return t}function s$e(t,e){let n=t.dom.ownerDocument,r,i=0,a=K6e(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(!rL(e,u)||(o=ote(t.dom,e,u),!o))return null}if(Ja)for(let u=o;r&&u;u=Ag(u))u.draggable&&(r=void 0);if(o=r$e(o,e),r){if(ko&&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;Uy&&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=a$e(t,r,i,e))}l==null&&(l=i$e(t,o,e));let c=t.docView.nearestDesc(o,!0);return{pos:l,inside:c?c.posAtStart-c.border:-1}}function F9(t){return t.top<t.bottom||t.left<t.right}function od(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(F9(r))return r}return Array.prototype.find.call(n,F9)||t.getBoundingClientRect()}const o$e=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function lte(t,e,n){let{node:r,offset:i,atom:a}=t.docView.domFromPos(e,n<0?-1:1),o=Uy||ko;if(r.nodeType==3)if(o&&(o$e.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let c=od(Ic(r,i,i),n);if(ko&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let u=od(Ic(r,i-1,i-1),-1);if(u.top==c.top){let d=od(Ic(r,i,i+1),-1);if(d.top!=c.top)return vb(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++,vb(od(Ic(r,c,u),d),d<0)}if(!t.state.doc.resolve(e-(a||0)).parent.inlineContent){if(a==null&&i&&(n<0||i==Mo(r))){let c=r.childNodes[i-1];if(c.nodeType==1)return Qk(c.getBoundingClientRect(),!1)}if(a==null&&i<Mo(r)){let c=r.childNodes[i];if(c.nodeType==1)return Qk(c.getBoundingClientRect(),!0)}return Qk(r.getBoundingClientRect(),n>=0)}if(a==null&&i&&(n<0||i==Mo(r))){let c=r.childNodes[i-1],u=c.nodeType==3?Ic(c,Mo(c)-(o?0:1)):c.nodeType==1&&(c.nodeName!="BR"||!c.nextSibling)?c:null;if(u)return vb(od(u,1),!1)}if(a==null&&i<Mo(r)){let c=r.childNodes[i];for(;c.pmViewDesc&&c.pmViewDesc.ignoreForCoords;)c=c.nextSibling;let u=c?c.nodeType==3?Ic(c,0,o?0:1):c.nodeType==1?c:null:null;if(u)return vb(od(u,-1),!0)}return vb(od(r.nodeType==3?Ic(r):r,-n),n>=0)}function vb(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 Qk(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 cte(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 l$e(t,e,n){let r=e.selection,i=n=="up"?r.$from:r.$to;return cte(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=lte(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=Ic(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 c$e=/[\u0590-\u08ac]/;function u$e(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,a=!i,o=i==r.parent.content.size,l=t.domSelection();return l?!c$e.test(r.parent.textContent)||!l.modify?n=="left"||n=="backward"?a:o:cte(t,e,()=>{let{focusNode:c,focusOffset:u,anchorNode:d,anchorOffset:f}=t.domSelectionRange(),m=l.caretBidiLevel;l.modify("move",n,"character");let p=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:x,focusOffset:y}=t.domSelectionRange(),b=x&&!p.contains(x.nodeType==1?x:x.parentNode)||c==x&&u==y;try{l.collapse(d,f),c&&(c!=d||u!=f)&&l.extend&&l.extend(c,u)}catch{}return m!=null&&(l.caretBidiLevel=m),b}):r.pos==r.start()||r.pos==r.end()}let U9=null,z9=null,B9=!1;function d$e(t,e,n){return U9==e&&z9==n?B9:(U9=e,z9=n,B9=n=="up"||n=="down"?l$e(t,e,n):u$e(t,e,n))}const jo=0,$9=1,af=2,Kl=3;class zy{constructor(e,n,r,i){this.parent=e,this.children=n,this.dom=r,this.contentDOM=i,this.dirty=jo,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>ya(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 dte){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 ute&&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?ya(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?ya(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 m=this.children[f-1];if(m.size&&m.dom.parentNode==this.contentDOM&&!m.emptyChildAt(1)){i=ya(m.dom)+1;break}e-=m.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=ya(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 p=0,x=0;p<this.children.length;p++){let y=this.children[p],b=x+y.size;if(a>x&&o<b)return y.setSelection(e-x-y.border,n-x-y.border,r,i);x=b}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((ko||Ja)&&e==n){let{node:p,offset:x}=l;if(p.nodeType==3){if(f=!!(x&&p.nodeValue[x-1]==`
  8147. `),f&&x==p.nodeValue.length)for(let y=p,b;y;y=y.parentNode){if(b=y.nextSibling){b.nodeName=="BR"&&(l=c={node:b.parentNode,offset:ya(b)+1});break}let v=y.pmViewDesc;if(v&&v.node&&v.node.isBlock)break}}else{let y=p.childNodes[x-1];f=y&&(y.nodeName=="BR"||y.contentEditable=="false")}}if(ko&&d.focusNode&&d.focusNode!=c.node&&d.focusNode.nodeType==1){let p=d.focusNode.childNodes[d.focusOffset];p&&p.contentEditable=="false"&&(i=!0)}if(!(i||f&&Ja)&&Kf(l.node,l.offset,d.anchorNode,d.anchorOffset)&&Kf(c.node,c.offset,d.focusNode,d.focusOffset))return;let m=!1;if((u.extend||e==n)&&!(f&&ko)){u.collapse(l.node,l.offset);try{e!=n&&u.extend(c.node,c.offset),m=!0}catch{}}if(!m){if(e>n){let x=l;l=c,c=x}let p=document.createRange();p.setEnd(c.node,c.offset),p.setStart(l.node,l.offset),u.removeAllRanges(),u.addRange(p)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let r=0,i=0;i<this.children.length;i++){let 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?af:$9,e==l&&n==c&&(a.contentLost||a.dom.parentNode!=this.contentDOM)?a.dirty=Kl:a.markDirty(e-l,n-l);return}else a.dirty=a.dom==a.contentDOM&&a.dom.parentNode==this.contentDOM&&!a.children.length?af:Kl}r=o}this.dirty=af}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?af:$9;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class ute extends zy{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==jo&&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 h$e extends zy{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 Xf extends zy{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=im.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new Xf(e,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&Kl||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Kl&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=jo){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=jo}}slice(e,n,r){let i=Xf.create(this.parent,this.mark,!0,r),a=this.children,o=this.size;n<o&&(a=yR(a,n,o,r)),e>0&&(a=yR(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 Ud extends zy{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}=im.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 m=d;return d=mte(d,r,n),u?c=new f$e(e,n,r,i,d,f||null,m,u,a,o+1):n.isText?new tM(e,n,r,i,d,m,a):new Ud(e,n,r,i,d,f||null,m,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=()=>At.empty)}return e}matchesNode(e,n,r){return this.dirty==jo&&e.eq(this.node)&&US(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 p$e(this,o&&o.node,e);b$e(this.node,this.innerDeco,(u,d,f)=>{u.spec.marks?c.syncToMarks(u.spec.marks,r,e):u.type.side>=0&&!f&&c.syncToMarks(d==this.node.childCount?vr.none:this.node.child(d).marks,r,e),c.placeWidget(u,e,i)},(u,d,f,m)=>{c.syncToMarks(u.marks,r,e);let p;c.findNodeMatch(u,d,f,m)||l&&e.state.selection.from>i&&e.state.selection.to<i+u.nodeSize&&(p=c.findIndexWithChild(a.node))>-1&&c.updateNodeAt(u,d,f,p,e)||c.updateNextNode(u,d,f,e,m,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==af)&&(o&&this.protectLocalComposition(e,o),hte(this.contentDOM,this.children,e),Cg&&y$e(this.dom))}localCompositionInfo(e,n){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof hn)||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=v$e(this.node.content,o,r-n,i-n);return l<0?null:{node:a,pos:l,text:o}}else return{node:a,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:i}){if(this.getDesc(n))return;let a=n;for(;a.parentNode!=this.contentDOM;a=a.parentNode){for(;a.previousSibling;)a.parentNode.removeChild(a.previousSibling);for(;a.nextSibling;)a.parentNode.removeChild(a.nextSibling);a.pmViewDesc&&(a.pmViewDesc=void 0)}let o=new h$e(this,a,n,i);e.input.compositionNodes.push(o),this.children=yR(this.children,r,r+i.length,e,o)}update(e,n,r,i){return this.dirty==Kl||!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=jo}updateOuterDeco(e){if(US(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=fte(this.dom,this.nodeDOM,bR(this.outerDeco,this.node,n),bR(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 H9(t,e,n,r,i){mte(r,e,t);let a=new Ud(void 0,t,e,n,r,r,r,i,0);return a.contentDOM&&a.updateChildren(i,0),a}class tM extends Ud{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==Kl||this.dirty!=jo&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=jo||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=jo,!0)}inParent(){let e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,r){let i=this.node.cut(e,n),a=document.createTextNode(i.text);return new tM(this.parent,i,this.outerDeco,this.innerDeco,a,a,r)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=Kl)}get domAtom(){return!1}isText(e){return this.node.text==e}}class dte extends zy{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==jo&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class f$e extends Ud{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==Kl)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 hte(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=V9(r),i=!0;r=r.nextSibling}else i=!0,t.insertBefore(l,r);if(o instanceof Xf){let c=r?r.previousSibling:t.lastChild;hte(o.contentDOM,o.children,n),r=c?c.nextSibling:t.firstChild}}for(;r;)r=V9(r),i=!0;i&&n.trackWrites==t&&(n.trackWrites=null)}const Yb=function(t){t&&(this.nodeName=t)};Yb.prototype=Object.create(null);const sf=[new Yb];function bR(t,e,n){if(t.length==0)return sf;let r=n?sf[0]:new Yb,i=[r];for(let a=0;a<t.length;a++){let o=t[a].type.attrs;if(o){o.nodeName&&i.push(r=new Yb(o.nodeName));for(let l in o){let c=o[l];c!=null&&(n&&i.length==1&&i.push(r=new Yb(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 fte(t,e,n,r){if(n==sf&&r==sf)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=sf[0]),i=c}m$e(i,l||sf[0],o)}return i}function m$e(t,e,n){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in n)&&t.removeAttribute(r);for(let r in n)r!="class"&&r!="style"&&r!="nodeName"&&n[r]!=e[r]&&t.setAttribute(r,n[r]);if(e.class!=n.class){let r=e.class?e.class.split(" ").filter(Boolean):[],i=n.class?n.class.split(" ").filter(Boolean):[];for(let a=0;a<r.length;a++)i.indexOf(r[a])==-1&&t.classList.remove(r[a]);for(let a=0;a<i.length;a++)r.indexOf(i[a])==-1&&t.classList.add(i[a]);t.classList.length==0&&t.removeAttribute("class")}if(e.style!=n.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,i;for(;i=r.exec(e.style);)t.style.removeProperty(i[1])}n.style&&(t.style.cssText+=n.style)}}function mte(t,e,n){return fte(t,t,sf,bR(e,n,t.nodeType!=1))}function US(t,e){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!t[n].type.eq(e[n].type))return!1;return!0}function V9(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class p$e{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=g$e(e.node.content,e)}destroyBetween(e,n){if(e!=n){for(let r=e;r<n;r++)this.top.children[r].destroy();this.top.children.splice(e,n-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,n,r){let i=0,a=this.stack.length>>1,o=Math.min(a,e.length);for(;i<o&&(i==a-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<a;)this.destroyRest(),this.top.dirty=jo,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=Xf.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==Kl&&o.dom==o.contentDOM&&(o.dirty=af),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 Ud){let u=this.preMatch.matched.get(c);if(u!=null&&u!=a)return!1;let d=c.dom,f,m=this.isLocked(d)&&!(e.isText&&c.node&&c.node.isText&&c.nodeDOM.nodeValue==e.text&&c.dirty!=Kl&&US(n,c.outerDeco));if(!m&&c.update(e,n,r,i))return this.destroyBetween(this.index,l),c.dom!=d&&(this.changed=!0),this.index++,!0;if(!m&&(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=af,f.updateChildren(i,o+1),f.dirty=jo),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)||!US(r,e.outerDeco)||!i.eq(e.innerDeco))return null;let l=Ud.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=Ud.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 ute(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 Xf;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof tM)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Ja||Da)&&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 dte(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 g$e(t,e){let n=e,r=n.children.length,i=t.childCount,a=new Map,o=[];e:for(;i>0;){let l;for(;;)if(r){let u=n.children[r-1];if(u instanceof Xf)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 x$e(t,e){return t.type.side-e.type.side}function b$e(t,e,n,r){let i=e.locals(t),a=0;if(i.length==0){for(let u=0;u<t.childCount;u++){let d=t.child(u);r(d,i,e.forChild(a,d),u),a+=d.nodeSize}return}let o=0,l=[],c=null;for(let u=0;;){let d,f;for(;o<i.length&&i[o].to==a;){let b=i[o++];b.widget&&(d?(f||(f=[d])).push(b):d=b)}if(d)if(f){f.sort(x$e);for(let b=0;b<f.length;b++)n(f[b],u,!!c)}else n(d,u,!!c);let m,p;if(c)p=-1,m=c,c=null;else if(u<t.childCount)p=u,m=t.child(u++);else break;for(let b=0;b<l.length;b++)l[b].to<=a&&l.splice(b--,1);for(;o<i.length&&i[o].from<=a&&i[o].to>a;)l.push(i[o++]);let x=a+m.nodeSize;if(m.isText){let b=x;o<i.length&&i[o].from<b&&(b=i[o].from);for(let v=0;v<l.length;v++)l[v].to<b&&(b=l[v].to);b<x&&(c=m.cut(b-a),m=m.cut(0,b-a),x=b,p=-1)}else for(;o<i.length&&i[o].to<x;)o++;let y=m.isInline&&!m.isLeaf?l.filter(b=>!b.inline):l.slice();r(m,y,e.forChild(a,m),p),a=x}}function y$e(t){if(t.nodeName=="UL"||t.nodeName=="OL"){let e=t.style.cssText;t.style.cssText=e+"; list-style: square !important",window.getComputedStyle(t).listStyle,t.style.cssText=e}}function v$e(t,e,n,r){for(let i=0,a=0;i<t.childCount&&a<=r;){let o=t.child(i++),l=a;if(a+=o.nodeSize,!o.isText)continue;let c=o.text;for(;i<t.childCount;){let u=t.child(i++);if(a+=u.nodeSize,!u.isText)break;c+=u.text}if(a>=n){if(a>=r&&c.slice(r-e.length-l,r-l)==e)return r-e.length;let u=l<r?c.lastIndexOf(e,r-l-1):-1;if(u>=0&&u+e.length+l>=n)return l+u;if(n==r&&c.length>=r+e.length-l&&c.slice(r-l,r-l+e.length)==e)return r}}return-1}function yR(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 iL(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(eM(n)){for(c=o;i&&!i.node;)i=i.parent;let f=i.node;if(i&&f.isAtom&&tn.isSelectable(f)&&i.parent&&!(f.isInline&&W6e(n.focusNode,n.focusOffset,i.dom))){let m=i.posBefore;u=new tn(o==m?l:r.resolve(m))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let f=o,m=o;for(let p=0;p<n.rangeCount;p++){let x=n.getRangeAt(p);f=Math.min(f,t.docView.posFromDOM(x.startContainer,x.startOffset,1)),m=Math.max(m,t.docView.posFromDOM(x.endContainer,x.endOffset,-1))}if(f<0)return null;[c,o]=m==t.state.selection.anchor?[m,f]:[f,m],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=aL(t,d,l,f)}return u}function pte(t){return t.editable?t.hasFocus():xte(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function iu(t,e=!1){let n=t.state.selection;if(gte(t,n),!!pte(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&Da){let r=t.domSelectionRange(),i=t.domObserver.currentSelection;if(r.anchorNode&&i.anchorNode&&Kf(r.anchorNode,r.anchorOffset,i.anchorNode,i.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)w$e(t);else{let{anchor:r,head:i}=n,a,o;G9&&!(n instanceof hn)&&(n.$from.parent.inlineContent||(a=W9(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(o=W9(t,n.to))),t.docView.setSelection(r,i,t,e),G9&&(a&&q9(a),o&&q9(o)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&_$e(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const G9=Ja||Da&&rte<63;function W9(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(Ja&&i&&i.contentEditable=="false")return Zk(i);if((!i||i.contentEditable=="false")&&(!a||a.contentEditable=="false")){if(i)return Zk(i);if(a)return Zk(a)}}function Zk(t){return t.contentEditable="true",Ja&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function q9(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function _$e(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let n=t.domSelectionRange(),r=n.anchorNode,i=n.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=i)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!pte(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function w$e(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,ya(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&_s&&Fd<=11&&(n.disabled=!0,n.disabled=!1)}function gte(t,e){if(e instanceof tn){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(K9(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else K9(t)}function K9(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function aL(t,e,n,r){return t.someProp("createSelectionBetween",i=>i(t,e,n))||hn.between(e,n,r)}function X9(t){return t.editable&&!t.hasFocus()?!1:xte(t)}function xte(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 S$e(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return Kf(e.node,e.offset,n.anchorNode,n.anchorOffset)}function vR(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&&En.findFrom(a,e)}function hd(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function Y9(t,e,n){let r=t.state.selection;if(r instanceof hn)if(n.indexOf("s")>-1){let{$head:i}=r,a=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!a||a.isText||!a.isLeaf)return!1;let o=t.state.doc.resolve(i.pos+a.nodeSize*(e<0?-1:1));return hd(t,new hn(r.$anchor,o))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let i=vR(t.state,e);return i&&i instanceof tn?hd(t,i):!1}else if(!(yo&&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?tn.isSelectable(a)?hd(t,new tn(e<0?t.state.doc.resolve(i.pos-a.nodeSize):i)):Uy?hd(t,new hn(t.state.doc.resolve(e<0?l:l+a.nodeSize))):!1:!1}}else return!1;else{if(r instanceof tn&&r.node.isInline)return hd(t,new hn(e>0?r.$to:r.$from));{let i=vR(t.state,e);return i?hd(t,i):!1}}}function zS(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Qb(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function Np(t,e){return e<0?N$e(t):M$e(t)}function N$e(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i,a,o=!1;for(ko&&n.nodeType==1&&r<zS(n)&&Qb(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(n.nodeType!=1)break;{let l=n.childNodes[r-1];if(Qb(l,-1))i=n,a=--r;else if(l.nodeType==3)n=l,r=n.nodeValue.length;else break}}else{if(bte(n))break;{let l=n.previousSibling;for(;l&&Qb(l,-1);)i=n.parentNode,a=ya(l),l=l.previousSibling;if(l)n=l,r=zS(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}o?_R(t,n,r):i&&_R(t,i,a)}function M$e(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i=zS(n),a,o;for(;;)if(r<i){if(n.nodeType!=1)break;let l=n.childNodes[r];if(Qb(l,1))a=n,o=++r;else break}else{if(bte(n))break;{let l=n.nextSibling;for(;l&&Qb(l,1);)a=l.parentNode,o=ya(l)+1,l=l.nextSibling;if(l)n=l,r=0,i=zS(n);else{if(n=n.parentNode,n==t.dom)break;r=i=0}}}a&&_R(t,a,o)}function bte(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function E$e(t,e){for(;t&&e==t.childNodes.length&&!Fy(t);)e=ya(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 T$e(t,e){for(;t&&!e&&!Fy(t);)e=ya(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 _R(t,e,n){if(e.nodeType!=3){let a,o;(o=E$e(e,n))?(e=o,n=0):(a=T$e(e,n))&&(e=a,n=a.nodeValue.length)}let r=t.domSelection();if(!r)return;if(eM(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&&iu(t)},50)}function Q9(t,e){let n=t.state.doc.resolve(e);if(!(Da||X6e)&&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 Z9(t,e,n){let r=t.state.selection;if(r instanceof hn&&!r.empty||n.indexOf("s")>-1||yo&&n.indexOf("m")>-1)return!1;let{$from:i,$to:a}=r;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let o=vR(t.state,e);if(o&&o instanceof tn)return hd(t,o)}if(!i.parent.inlineContent){let o=e<0?i:a,l=r instanceof Ks?En.near(o,e):En.findFrom(o,e);return l?hd(t,l):!1}return!1}function J9(t,e){if(!(t.state.selection instanceof hn))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 eG(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function A$e(t){if(!Ja||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;eG(t,r,"true"),setTimeout(()=>eG(t,r,"false"),20)}return!1}function C$e(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function k$e(t,e){let n=e.keyCode,r=C$e(e);if(n==8||yo&&n==72&&r=="c")return J9(t,-1)||Np(t,-1);if(n==46&&!e.shiftKey||yo&&n==68&&r=="c")return J9(t,1)||Np(t,1);if(n==13||n==27)return!0;if(n==37||yo&&n==66&&r=="c"){let i=n==37?Q9(t,t.state.selection.from)=="ltr"?-1:1:-1;return Y9(t,i,r)||Np(t,i)}else if(n==39||yo&&n==70&&r=="c"){let i=n==39?Q9(t,t.state.selection.from)=="ltr"?1:-1:1;return Y9(t,i,r)||Np(t,i)}else{if(n==38||yo&&n==80&&r=="c")return Z9(t,-1,r)||Np(t,-1);if(n==40||yo&&n==78&&r=="c")return A$e(t)||Z9(t,1,r)||Np(t,1);if(r==(yo?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function sL(t,e){t.someProp("transformCopied",p=>{e=p(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 p=r.firstChild;n.push(p.type.name,p.attrs!=p.type.defaultAttrs?p.attrs:null),r=p.content}let o=t.someProp("clipboardSerializer")||im.fromSchema(t.state.schema),l=Nte(),c=l.createElement("div");c.appendChild(o.serializeFragment(r,{document:l}));let u=c.firstChild,d,f=0;for(;u&&u.nodeType==1&&(d=Ste[u.nodeName.toLowerCase()]);){for(let p=d.length-1;p>=0;p--){let x=l.createElement(d[p]);for(;c.firstChild;)x.appendChild(c.firstChild);c.appendChild(x),f++}u=c.firstChild}u&&u.nodeType==1&&u.setAttribute("data-pm-slice",`${i} ${a}${f?` -${f}`:""} ${JSON.stringify(n)}`);let m=t.someProp("clipboardTextSerializer",p=>p(e,t))||e.content.textBetween(0,e.content.size,`
  8148. `);return{dom:c,text:m,slice:e}}function yte(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",m=>{e=m(e,a||r,t)}),a)return l=new Ut(At.from(t.state.schema.text(e.replace(/\r\n?/g,`
  8149. `))),0,0),t.someProp("transformPasted",m=>{l=m(l,t,!0)}),l;let f=t.someProp("clipboardTextParser",m=>m(e,i,r,t));if(f)l=f;else{let m=i.marks(),{schema:p}=t.state,x=im.fromSchema(p);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(y=>{let b=o.appendChild(document.createElement("p"));y&&b.appendChild(x.serializeNode(p.text(y,m)))})}}else t.someProp("transformPastedHTML",f=>{n=f(n,t)}),o=D$e(n),Uy&&O$e(o);let u=o&&o.querySelector("[data-pm-slice]"),d=u&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(u.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let f=+d[3];f>0;f--){let m=o.firstChild;for(;m&&m.nodeType!=1;)m=m.nextSibling;if(!m)break;o=m}if(l||(l=(t.someProp("clipboardParser")||t.someProp("domParser")||Kb.fromSchema(t.state.schema)).parseSlice(o,{preserveWhitespace:!!(c||d),context:i,ruleFromNode(m){return m.nodeName=="BR"&&!m.nextSibling&&m.parentNode&&!j$e.test(m.parentNode.nodeName)?{ignore:!0}:null}})),d)l=L$e(tG(l,+d[1],+d[2]),d[4]);else if(l=Ut.maxOpen(P$e(l.content,i),!0),l.openStart||l.openEnd){let f=0,m=0;for(let p=l.content.firstChild;f<l.openStart&&!p.type.spec.isolating;f++,p=p.firstChild);for(let p=l.content.lastChild;m<l.openEnd&&!p.type.spec.isolating;m++,p=p.lastChild);l=tG(l,f,m)}return t.someProp("transformPasted",f=>{l=f(l,t,c)}),l}const j$e=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function P$e(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let i=e.node(n).contentMatchAt(e.index(n)),a,o=[];if(t.forEach(l=>{if(!o)return;let c=i.findWrapping(l.type),u;if(!c)return o=null;if(u=o.length&&a.length&&_te(c,a,l,o[o.length-1],0))o[o.length-1]=u;else{o.length&&(o[o.length-1]=wte(o[o.length-1],a.length));let d=vte(l,c);o.push(d),i=i.matchType(d.type),a=c}}),o)return At.from(o)}return t}function vte(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,At.from(t));return t}function _te(t,e,n,r,i){if(i<t.length&&i<e.length&&t[i]==e[i]){let a=_te(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(At.from(vte(n,t,i+1))))}}function wte(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,wte(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(At.empty,!0);return t.copy(n.append(r))}function wR(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=wR(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(At.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,o.copy(l))}function tG(t,e,n){return e<t.openStart&&(t=new Ut(wR(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new Ut(wR(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const Ste={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 nG=null;function Nte(){return nG||(nG=document.implementation.createHTMLDocument("title"))}let Jk=null;function R$e(t){let e=window.trustedTypes;return e?(Jk||(Jk=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),Jk.createHTML(t)):t}function D$e(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=Nte().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),i;if((i=r&&Ste[r[1].toLowerCase()])&&(t=i.map(a=>"<"+a+">").join("")+t+i.map(a=>"</"+a+">").reverse().join("")),n.innerHTML=R$e(t),i)for(let a=0;a<i.length;a++)n=n.querySelector(i[a])||n;return n}function O$e(t){let e=t.querySelectorAll(Da?"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 L$e(t,e){if(!t.size)return t;let n=t.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return t}let{content:i,openStart:a,openEnd:o}=t;for(let l=r.length-2;l>=0;l-=2){let c=n.nodes[r[l]];if(!c||c.hasRequiredAttrs())break;i=At.from(c.create(r[l+1],i)),a++,o++}return new Ut(i,a,o)}const es={},ts={},I$e={touchstart:!0,touchmove:!0};class F$e{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function U$e(t){for(let e in es){let n=es[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{B$e(t,r)&&!oL(t,r)&&(t.editable||!(r.type in ts))&&n(t,r)},I$e[e]?{passive:!0}:void 0)}Ja&&t.dom.addEventListener("input",()=>null),SR(t)}function Td(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function z$e(t){t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout),clearTimeout(t.input.lastIOSEnterFallbackTimeout)}function SR(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>oL(t,r))})}function oL(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function B$e(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target;n!=t.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}function $$e(t,e){!oL(t,e)&&es[e.type]&&(t.editable||!(e.type in ts))&&es[e.type](t,e)}ts.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!Ete(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(Xc&&Da&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),Cg&&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,Yh(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||k$e(t,n)?n.preventDefault():Td(t,"key")};ts.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};ts.keypress=(t,e)=>{let n=e;if(Ete(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||yo&&n.metaKey)return;if(t.someProp("handleKeyPress",i=>i(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof hn)||!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 nM(t){return{left:t.clientX,top:t.clientY}}function H$e(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function lL(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 tg(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 V$e(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&tn.isSelectable(r)?(tg(t,new tn(n)),!0):!1}function G$e(t,e){if(e==-1)return!1;let n=t.state.selection,r,i;n instanceof tn&&(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(tn.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?(tg(t,tn.create(t.state.doc,i)),!0):!1}function W$e(t,e,n,r,i){return lL(t,"handleClickOn",e,n,r)||t.someProp("handleClick",a=>a(t,e,r))||(i?G$e(t,n):V$e(t,n))}function q$e(t,e,n,r){return lL(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",i=>i(t,e,r))}function K$e(t,e,n,r){return lL(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",i=>i(t,e,r))||X$e(t,n,r)}function X$e(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(tg(t,hn.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)tg(t,hn.create(r,l+1,l+1+o.content.size));else if(tn.isSelectable(o))tg(t,tn.create(r,l));else continue;return!0}}function cL(t){return BS(t)}const Mte=yo?"metaKey":"ctrlKey";es.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&&H$e(n,t.input.lastClick)&&!n[Mte]&&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(nM(n));o&&(a=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new Y$e(t,o,n,!!r)):(a=="doubleClick"?q$e:K$e)(t,o.pos,o.inside,n)?n.preventDefault():Td(t,"pointer"))};class Y$e{constructor(e,n,r,i){this.view=e,this.pos=n,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[Mte],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 tn&&u.from<=o&&u.to>o)&&(this.mightDrag={node:a,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&ko&&!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)),Td(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(()=>iu(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(nM(e))),this.updateAllowDefault(e),this.allowDefault||!n?Td(this.view,"pointer"):W$e(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Ja&&this.mightDrag&&!this.mightDrag.node.isAtom||Da&&!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)?(tg(this.view,En.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):Td(this.view,"pointer")}move(e){this.updateAllowDefault(e),Td(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)}}es.touchstart=t=>{t.input.lastTouch=Date.now(),cL(t),Td(t,"pointer")};es.touchmove=t=>{t.input.lastTouch=Date.now(),Td(t,"pointer")};es.contextmenu=t=>cL(t);function Ete(t,e){return t.composing?!0:Ja&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const Q$e=Xc?5e3:-1;ts.compositionstart=ts.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof hn&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))t.markCursor=t.state.storedMarks||n.marks(),BS(t,!0),t.markCursor=null;else if(BS(t,!e.selection.empty),ko&&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}Tte(t,Q$e)};ts.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++,Tte(t,20))};function Tte(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>BS(t),e))}function Ate(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=J$e());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function Z$e(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=V6e(e.focusNode,e.focusOffset),r=G6e(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 J$e(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function BS(t,e=!1){if(!(Xc&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),Ate(t),e||t.docView&&t.docView.dirty){let n=iL(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 eHe(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 q0=_s&&Fd<15||Cg&&Y6e<604;es.copy=ts.cut=(t,e)=>{let n=e,r=t.state.selection,i=n.type=="cut";if(r.empty)return;let a=q0?null:n.clipboardData,o=r.content(),{dom:l,text:c}=sL(t,o);a?(n.preventDefault(),a.clearData(),a.setData("text/html",l.innerHTML),a.setData("text/plain",c)):eHe(t,l),i&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function tHe(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function nHe(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?K0(t,r.value,null,i,e):K0(t,r.textContent,r.innerHTML,i,e)},50)}function K0(t,e,n,r,i){let a=yte(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=tHe(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 Cte(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," "):""}ts.paste=(t,e)=>{let n=e;if(t.composing&&!Xc)return;let r=q0?null:n.clipboardData,i=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&K0(t,Cte(r),r.getData("text/html"),i,n)?n.preventDefault():nHe(t,n)};class kte{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const rHe=yo?"altKey":"ctrlKey";function jte(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[rHe]}es.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(nM(n)),o;if(!(a&&a.pos>=i.from&&a.pos<=(i instanceof tn?i.to-1:i.to))){if(r&&r.mightDrag)o=tn.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=tn.create(t.state.doc,f.posBefore))}}let l=(o||t.state.selection).content(),{dom:c,text:u,slice:d}=sL(t,l);(!n.dataTransfer.files.length||!Da||rte>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(q0?"Text":"text/html",c.innerHTML),n.dataTransfer.effectAllowed="copyMove",q0||n.dataTransfer.setData("text/plain",u),t.dragging=new kte(d,jte(t,n),o)};es.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};ts.dragover=ts.dragenter=(t,e)=>e.preventDefault();ts.drop=(t,e)=>{let n=e,r=t.dragging;if(t.dragging=null,!n.dataTransfer)return;let i=t.posAtCoords(nM(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=yte(t,Cte(n.dataTransfer),q0?null:n.dataTransfer.getData("text/html"),!1,a);let l=!!(r&&jte(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?Lee(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,m=u.doc;if(f?u.replaceRangeWith(d,d,o.content.firstChild):u.replaceRange(d,d,o),u.doc.eq(m))return;let p=u.doc.resolve(d);if(f&&tn.isSelectable(o.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(o.content.firstChild))u.setSelection(new tn(p));else{let x=u.mapping.map(c);u.mapping.maps[u.mapping.maps.length-1].forEach((y,b,v,N)=>x=N),u.setSelection(aL(t,p,u.doc.resolve(x)))}t.focus(),t.dispatch(u.setMeta("uiEvent","drop"))};es.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())&&iu(t)},20))};es.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)};es.beforeinput=(t,e)=>{if(Da&&Xc&&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,Yh(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 ts)es[t]=ts[t];function X0(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 $S{constructor(e,n){this.toDOM=e,this.spec=n||_f,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 qa(a-r,a-r,this)}valid(){return!0}eq(e){return this==e||e instanceof $S&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&X0(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class zd{constructor(e,n){this.attrs=e,this.spec=n||_f}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 qa(a,o,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof zd&&X0(this.attrs,e.attrs)&&X0(this.spec,e.spec)}static is(e){return e.type instanceof zd}destroy(){}}class uL{constructor(e,n){this.attrs=e,this.spec=n||_f}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 qa(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 uL&&X0(this.attrs,e.attrs)&&X0(this.spec,e.spec)}destroy(){}}class qa{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new qa(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 qa(e,e,new $S(n,r))}static inline(e,n,r,i){return new qa(e,n,new zd(r,i))}static node(e,n,r,i){return new qa(e,n,new uL(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof zd}get widget(){return this.type instanceof $S}}const Pp=[],_f={};class Vr{constructor(e,n){this.local=e.length?e:Pp,this.children=n.length?n:Pp}static create(e,n){return n.length?HS(n,e,0,_f):ja}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==ja||e.maps.length==0?this:this.mapInner(e,n,0,0,r||_f)}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?iHe(this.children,o||[],e,n,r,i,a):o?new Vr(o.sort(wf),Pp):ja}add(e,n){return n.length?this==ja?Vr.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=Rte(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,HS(d,l,u+1,_f)),a+=3}});let o=Pte(a?Dte(n):n,-r);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||o.splice(l--,1);return new Vr(o.length?this.local.concat(o).sort(wf):this.local,i||this.children)}remove(e){return e.length==0||this==ja?this:this.removeInner(e,0)}removeInner(e,n){let r=this.children,i=this.local;for(let 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!=ja?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 Vr(i,r):ja}forChild(e,n){if(this==ja)return this;if(n.isLeaf)return Vr.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 zd){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 Vr(i.sort(wf),Pp);return r?new bd([l,r]):l}return r||ja}eq(e){if(this==e)return!0;if(!(e instanceof Vr)||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 dL(this.localsInner(e))}localsInner(e){if(this==ja)return Pp;if(e.inlineContent||!this.local.some(zd.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof zd||n.push(this.local[r]);return n}forEachSet(e){e(this)}}Vr.empty=new Vr([],[]);Vr.removeOverlap=dL;const ja=Vr.empty;class bd{constructor(e){this.members=e}map(e,n){const r=this.members.map(i=>i.map(e,n,_f));return bd.from(r)}forChild(e,n){if(n.isLeaf)return Vr.empty;let r=[];for(let i=0;i<this.members.length;i++){let a=this.members[i].forChild(e,n);a!=ja&&(a instanceof bd?r=r.concat(a.members):r.push(a))}return bd.from(r)}eq(e){if(!(e instanceof bd)||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?dL(r?n:n.sort(wf)):Pp}static from(e){switch(e.length){case 0:return ja;case 1:return e[0];default:return new bd(e.every(n=>n instanceof Vr)?e:e.reduce((n,r)=>n.concat(r instanceof Vr?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function iHe(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((m,p,x,y)=>{let b=y-x-(p-m);for(let v=0;v<l.length;v+=3){let N=l[v+1];if(N<0||m>N+d-f)continue;let S=l[v]+d-f;p>=S?l[v+1]=m<=S?-2:-1:m>=d&&b&&(l[v]+=b,l[v+1]+=b)}f+=b}),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 m=n.map(t[u+1]+a,-1),p=m-i,{index:x,offset:y}=r.content.findIndex(f),b=r.maybeChild(x);if(b&&y==f&&y+b.nodeSize==p){let v=l[u+2].mapInner(n,b,d+1,t[u]+a+1,o);v!=ja?(l[u]=f,l[u+1]=p,l[u+2]=v):(l[u+1]=-2,c=!0)}else c=!0}if(c){let u=aHe(l,t,e,n,i,a,o),d=HS(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,m=0;f<d.children.length;f+=3){let p=d.children[f];for(;m<l.length&&l[m]<p;)m+=3;l.splice(m,0,d.children[f],d.children[f+1],d.children[f+2])}}return new Vr(e.sort(wf),l)}function Pte(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 qa(i.from+e,i.to+e,i.type))}return n}function aHe(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 Rte(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 Dte(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function HS(t,e,n,r){let i=[],a=!1;e.forEach((l,c)=>{let u=Rte(t,l,c+n);if(u){a=!0;let d=HS(u,l,n+c+1,r);d!=ja&&i.push(c,c+l.nodeSize,d)}});let o=Pte(a?Dte(t):t,-n).sort(wf);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 Vr(o,i):ja}function wf(t,e){return t.from-e.from||t.to-e.to}function dL(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),rG(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),rG(e,i,r.copy(a.from,r.to)));break}}}return e}function rG(t,e,n){for(;e<t.length&&wf(n,t[e])>0;)e++;t.splice(e,0,n)}function ej(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=ja&&e.push(r)}),t.cursorWrapper&&e.push(Vr.create(t.state.doc,[t.cursorWrapper.deco])),bd.from(e)}const sHe={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},oHe=_s&&Fd<=11;class lHe{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 cHe{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new lHe,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let i=0;i<r.length;i++)this.queue.push(r[i]);_s&&Fd<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),oHe&&(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,sHe)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let n=0;n<e.length;n++)this.queue.push(e[n]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(X9(this.view)){if(this.suppressingSelectionUpdates)return iu(this.view);if(_s&&Fd<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Kf(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=Ag(a))n.add(a);for(let a=e.anchorNode;a;a=Ag(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)&&X9(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(ko&&c.length){let d=c.filter(f=>f.nodeName=="BR");if(d.length==2){let[f,m]=d;f.parentNode&&f.parentNode.parentNode==m.parentNode?m.remove():f.remove()}else{let{focusNode:f}=this.currentSelection;for(let m of d){let p=m.parentNode;p&&p.nodeName=="LI"&&(!f||hHe(e,f)!=p)&&m.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&&eM(r)&&(u=iL(e))&&u.eq(En.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,iu(e),this.currentSelection.set(r),e.scrollToSelection()):(a>-1||i)&&(a>-1&&(e.docView.markDirty(a,o),uHe(e)),this.handleDOMChange(a,o,l,c),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||iu(e),this.currentSelection.set(r))}registerMutation(e,n){if(n.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let d=0;d<e.addedNodes.length;d++){let f=e.addedNodes[d];n.push(f),f.nodeType==3&&(this.lastChangedTextNode=f)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let i=e.previousSibling,a=e.nextSibling;if(_s&&Fd<=11&&e.addedNodes.length)for(let d=0;d<e.addedNodes.length;d++){let{previousSibling:f,nextSibling:m}=e.addedNodes[d];(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(i=f),(!m||Array.prototype.indexOf.call(e.addedNodes,m)<0)&&(a=m)}let o=i&&i.parentNode==e.target?ya(i)+1:0,l=r.localPosFromDOM(e.target,o,-1),c=a&&a.parentNode==e.target?ya(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 iG=new WeakMap,aG=!1;function uHe(t){if(!iG.has(t)&&(iG.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=ko,aG)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."),aG=!0}}function sG(t,e){let n=e.startContainer,r=e.startOffset,i=e.endContainer,a=e.endOffset,o=t.domAtPos(t.state.selection.anchor);return Kf(o.node,o.offset,i,a)&&([n,r,i,a]=[i,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}}function dHe(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return sG(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?sG(t,n):null}function hHe(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 fHe(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}],eM(c)||u.push({node:c.focusNode,offset:c.focusOffset})),Da&&t.input.lastKeyCode===8)for(let b=a;b>i;b--){let v=r.childNodes[b-1],N=v.pmViewDesc;if(v.nodeName=="BR"&&!N){a=b;break}if(!N||N.size)break}let f=t.state.doc,m=t.someProp("domParser")||Kb.fromSchema(t.state.schema),p=f.resolve(o),x=null,y=m.parse(r,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:i,to:a,preserveWhitespace:p.parent.type.whitespace=="pre"?"full":!0,findPositions:u,ruleFromNode:mHe,context:p});if(u&&u[0].pos!=null){let b=u[0].pos,v=u[1]&&u[1].pos;v==null&&(v=b),x={anchor:b+o,head:v+o}}return{doc:y,sel:x,from:o,to:l}}function mHe(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(Ja&&/^(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||Ja&&/^(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 pHe=/^(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 gHe(t,e,n,r,i){let a=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let A=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,O=iL(t,A);if(O&&!t.state.selection.eq(O)){if(Da&&Xc&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",R=>R(t,Yh(13,"Enter"))))return;let k=t.state.tr.setSelection(O);A=="pointer"?k.setMeta("pointer",!0):A=="key"&&k.scrollIntoView(),a&&k.setMeta("composition",a),t.dispatch(k)}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=fHe(t,e,n),d=t.state.doc,f=d.slice(u.from,u.to),m,p;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(m=t.state.selection.to,p="end"):(m=t.state.selection.from,p="start"),t.input.lastKeyCode=null;let x=yHe(f.content,u.doc.content,u.from,m,p);if(x&&t.input.domChangeCount++,(Cg&&t.input.lastIOSEnter>Date.now()-225||Xc)&&i.some(A=>A.nodeType==1&&!pHe.test(A.nodeName))&&(!x||x.endA>=x.endB)&&t.someProp("handleKeyDown",A=>A(t,Yh(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!x)if(r&&c instanceof hn&&!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 A=oG(t,t.state.doc,u.sel);if(A&&!A.eq(t.state.selection)){let O=t.state.tr.setSelection(A);a&&O.setMeta("composition",a),t.dispatch(O)}}return}t.state.selection.from<t.state.selection.to&&x.start==x.endB&&t.state.selection instanceof hn&&(x.start>t.state.selection.from&&x.start<=t.state.selection.from+2&&t.state.selection.from>=u.from?x.start=t.state.selection.from:x.endA<t.state.selection.to&&x.endA>=t.state.selection.to-2&&t.state.selection.to<=u.to&&(x.endB+=t.state.selection.to-x.endA,x.endA=t.state.selection.to)),_s&&Fd<=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 y=u.doc.resolveNoCache(x.start-u.from),b=u.doc.resolveNoCache(x.endB-u.from),v=d.resolve(x.start),N=y.sameParent(b)&&y.parent.inlineContent&&v.end()>=x.endA;if((Cg&&t.input.lastIOSEnter>Date.now()-225&&(!N||i.some(A=>A.nodeName=="DIV"||A.nodeName=="P"))||!N&&y.pos<u.doc.content.size&&(!y.sameParent(b)||!y.parent.inlineContent)&&y.pos<b.pos&&!/\S/.test(u.doc.textBetween(y.pos,b.pos,"","")))&&t.someProp("handleKeyDown",A=>A(t,Yh(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>x.start&&bHe(d,x.start,x.endA,y,b)&&t.someProp("handleKeyDown",A=>A(t,Yh(8,"Backspace")))){Xc&&Da&&t.domObserver.suppressSelectionUpdates();return}Da&&x.endB==x.start&&(t.input.lastChromeDelete=Date.now()),Xc&&!N&&y.start()!=b.start()&&b.parentOffset==0&&y.depth==b.depth&&u.sel&&u.sel.anchor==u.sel.head&&u.sel.head==x.endA&&(x.endB-=2,b=u.doc.resolveNoCache(x.endB-u.from),setTimeout(()=>{t.someProp("handleKeyDown",function(A){return A(t,Yh(13,"Enter"))})},20));let S=x.start,T=x.endA,E=A=>{let O=A||t.state.tr.replace(S,T,u.doc.slice(x.start-u.from,x.endB-u.from));if(u.sel){let k=oG(t,O.doc,u.sel);k&&!(Da&&t.composing&&k.empty&&(x.start!=x.endB||t.input.lastChromeDelete<Date.now()-100)&&(k.head==S||k.head==O.mapping.map(T)-1)||_s&&k.empty&&k.head==S)&&O.setSelection(k)}return a&&O.setMeta("composition",a),O.scrollIntoView()},C;if(N)if(y.pos==b.pos){_s&&Fd<=11&&y.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>iu(t),20));let A=E(t.state.tr.delete(S,T)),O=d.resolve(x.start).marksAcross(d.resolve(x.endA));O&&A.ensureMarks(O),t.dispatch(A)}else if(x.endA==x.endB&&(C=xHe(y.parent.content.cut(y.parentOffset,b.parentOffset),v.parent.content.cut(v.parentOffset,x.endA-v.start())))){let A=E(t.state.tr);C.type=="add"?A.addMark(S,T,C.mark):A.removeMark(S,T,C.mark),t.dispatch(A)}else if(y.parent.child(y.index()).isText&&y.index()==b.index()-(b.textOffset?0:1)){let A=y.parent.textBetween(y.parentOffset,b.parentOffset),O=()=>E(t.state.tr.insertText(A,S,T));t.someProp("handleTextInput",k=>k(t,S,T,A,O))||t.dispatch(O())}else t.dispatch(E());else t.dispatch(E())}function oG(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:aL(t,e.resolve(n.anchor),e.resolve(n.head))}function xHe(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(At.from(u).eq(t))return{mark:l,type:o}}function bHe(t,e,n,r,i){if(n-e<=i.pos-r.pos||tj(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(tj(a,!0,!0));return!o.parent.isTextblock||o.pos>n||tj(o,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function tj(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 yHe(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&&lG(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&&lG(t.textBetween(a-1,a+1))&&(a+=c?1:-1),o=a+(o-l),l=a}return{start:a,endA:o,endB:l}}function lG(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 Ote{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 F$e,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(fG),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=dG(this),uG(this),this.nodeViews=hG(this),this.docView=H9(this.state.doc,cG(this),ej(this),this.dom,this),this.domObserver=new cHe(this,(r,i,a,o)=>gHe(this,r,i,a,o)),this.domObserver.start(),U$e(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let n in e)this._props[n]=e[n];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&SR(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(fG),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&&(Ate(this),o=!0),this.state=e;let l=i.plugins!=e.plugins||this._props.plugins!=n.plugins;if(l||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let p=hG(this);_He(p,this.nodeViews)&&(this.nodeViews=p,a=!0)}(l||n.handleDOMEvents!=this._props.handleDOMEvents)&&SR(this),this.editable=dG(this),uG(this);let c=ej(this),u=cG(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 m=d=="preserve"&&o&&this.dom.style.overflowAnchor==null&&J6e(this);if(o){this.domObserver.stop();let p=f&&(_s||Da)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&vHe(i.selection,e.selection);if(f){let x=Da?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Z$e(this)),(a||!this.docView.update(e.doc,u,c,this))&&(this.docView.updateOuterDeco(u),this.docView.destroy(),this.docView=H9(e.doc,u,c,this.dom,this)),x&&!this.trackWrites&&(p=!0)}p||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&S$e(this))?iu(this,p):(gte(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():m&&e$e(m)}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 tn){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&I9(this,n.getBoundingClientRect(),e)}else I9(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 kte(e.slice,e.move,i<0?void 0:tn.create(this.state.doc,i))}someProp(e,n){let r=this._props&&this._props[e],i;if(r!=null&&(i=n?n(r):r))return i;for(let o=0;o<this.directPlugins.length;o++){let l=this.directPlugins[o].props[e];if(l!=null&&(i=n?n(l):l))return i}let a=this.state.plugins;if(a)for(let o=0;o<a.length;o++){let l=a[o].props[e];if(l!=null&&(i=n?n(l):l))return i}}hasFocus(){if(_s){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&t$e(this.dom),iu(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 s$e(this,e)}coordsAtPos(e,n=1){return lte(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 d$e(this,n||this.state,e)}pasteHTML(e,n){return K0(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return K0(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return sL(this,e)}destroy(){this.docView&&(z$e(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],ej(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,$6e())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return $$e(this,e)}domSelectionRange(){let e=this.domSelection();return e?Ja&&this.root.nodeType===11&&q6e(this.dom.ownerDocument)==this.dom&&dHe(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}Ote.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function cG(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"),[qa.node(0,t.state.doc.content.size,e)]}function uG(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:qa.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function dG(t){return!t.someProp("editable",e=>e(t.state)===!1)}function vHe(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 hG(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 _He(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 fG(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 eh={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:"'"},VS={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},wHe=typeof navigator<"u"&&/Mac/.test(navigator.platform),SHe=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var va=0;va<10;va++)eh[48+va]=eh[96+va]=String(va);for(var va=1;va<=24;va++)eh[va+111]="F"+va;for(var va=65;va<=90;va++)eh[va]=String.fromCharCode(va+32),VS[va]=String.fromCharCode(va);for(var nj in eh)VS.hasOwnProperty(nj)||(VS[nj]=eh[nj]);function NHe(t){var e=wHe&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||SHe&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?VS:eh)[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 MHe=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),EHe=typeof navigator<"u"&&/Win/.test(navigator.platform);function THe(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))MHe?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 AHe(t){let e=Object.create(null);for(let n in t)e[THe(n)]=t[n];return e}function rj(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 CHe(t){return new Kr({props:{handleKeyDown:Lte(t)}})}function Lte(t){let e=AHe(t);return function(n,r){let i=NHe(r),a,o=e[rj(i,r)];if(o&&o(n.state,n.dispatch,n))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let l=e[rj(i,r,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(EHe&&r.ctrlKey&&r.altKey)&&(a=eh[r.keyCode])&&a!=i){let l=e[rj(a,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}var kHe=Object.defineProperty,hL=(t,e)=>{for(var n in e)kHe(t,n,{get:e[n],enumerable:!0})};function rM(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 iM=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,m])=>[f,(...x)=>{const y=this.buildProps(c,e),b=m(...x)(y);return o.push(b),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:rM({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}},Ite={};hL(Ite,{blur:()=>jHe,clearContent:()=>PHe,clearNodes:()=>RHe,command:()=>DHe,createParagraphNear:()=>OHe,cut:()=>LHe,deleteCurrentNode:()=>IHe,deleteNode:()=>FHe,deleteRange:()=>UHe,deleteSelection:()=>zHe,enter:()=>BHe,exitCode:()=>$He,extendMarkRange:()=>HHe,first:()=>VHe,focus:()=>WHe,forEach:()=>qHe,insertContent:()=>KHe,insertContentAt:()=>QHe,joinBackward:()=>eVe,joinDown:()=>JHe,joinForward:()=>tVe,joinItemBackward:()=>nVe,joinItemForward:()=>rVe,joinTextblockBackward:()=>iVe,joinTextblockForward:()=>aVe,joinUp:()=>ZHe,keyboardShortcut:()=>oVe,lift:()=>lVe,liftEmptyBlock:()=>cVe,liftListItem:()=>uVe,newlineInCode:()=>dVe,resetAttributes:()=>hVe,scrollIntoView:()=>fVe,selectAll:()=>mVe,selectNodeBackward:()=>pVe,selectNodeForward:()=>gVe,selectParentNode:()=>xVe,selectTextblockEnd:()=>bVe,selectTextblockStart:()=>yVe,setContent:()=>vVe,setMark:()=>FVe,setMeta:()=>UVe,setNode:()=>zVe,setNodeSelection:()=>BVe,setTextDirection:()=>$Ve,setTextSelection:()=>HVe,sinkListItem:()=>VVe,splitBlock:()=>GVe,splitListItem:()=>WVe,toggleList:()=>qVe,toggleMark:()=>KVe,toggleNode:()=>XVe,toggleWrap:()=>YVe,undoInputRule:()=>QVe,unsetAllMarks:()=>ZVe,unsetMark:()=>JVe,unsetTextDirection:()=>e7e,updateAttributes:()=>t7e,wrapIn:()=>n7e,wrapInList:()=>r7e});var jHe=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window?.getSelection())==null||n.removeAllRanges())}),!0),PHe=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),RHe=()=>({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)),m=u.resolve(d.map(c+l.nodeSize)),p=f.blockRange(m);if(!p)return;const x=rx(p);if(l.type.isTextblock){const{defaultType:y}=f.parent.contentMatchAt(f.index());e.setNodeMarkup(p.start,y)}(x||x===0)&&e.lift(p,x)})}),!0},DHe=t=>e=>t(e),OHe=()=>({state:t,dispatch:e})=>Zee(t,e),LHe=(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 hn(r.doc.resolve(Math.max(o-1,0)))),!0},IHe=()=>({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 Ei(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 FHe=t=>({tr:e,state:n,dispatch:r})=>{const i=Ei(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},UHe=t=>({tr:e,dispatch:n})=>{const{from:r,to:i}=t;return n&&e.delete(r,i),!0},zHe=()=>({state:t,dispatch:e})=>ZO(t,e),BHe=()=>({commands:t})=>t.keyboardShortcut("Enter"),$He=()=>({state:t,dispatch:e})=>T6e(t,e);function fL(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function GS(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(i=>n.strict?e[i]===t[i]:fL(e[i])?e[i].test(t[i]):e[i]===t[i]):!0}function Fte(t,e,n={}){return t.find(r=>r.type===e&&GS(Object.fromEntries(Object.keys(n).map(i=>[i,r.attrs[i]])),n))}function mG(t,e,n={}){return!!Fte(t,e,n)}function mL(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),!Fte([...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&&mG([...t.parent.child(o-1).marks],e,n);)o-=1,l-=t.parent.child(o).nodeSize;for(;c<t.parent.childCount&&mG([...t.parent.child(c).marks],e,n);)u+=t.parent.child(c).nodeSize,c+=1;return{from:l,to:u}}function _u(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 HHe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const a=_u(t,r.schema),{doc:o,selection:l}=n,{$from:c,from:u,to:d}=l;if(i){const f=mL(c,a,e);if(f&&f.from<=u&&f.to>=d){const m=hn.create(o,f.from,f.to);n.setSelection(m)}}return!0},VHe=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 Ute(t){return t instanceof hn}function of(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function zte(t,e=null){if(!e)return null;const n=En.atStart(t),r=En.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;const i=n.from,a=r.to;return e==="all"?hn.create(t,of(0,i,a),of(t.content.size,i,a)):hn.create(t,of(e,i,a),of(e,i,a))}function GHe(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function pL(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var WHe=(t=null,e={})=>({editor:n,view:r,tr:i,dispatch:a})=>{e={scrollIntoView:!0,...e};const o=()=>{(pL()||GHe())&&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&&!Ute(n.state.selection))return o(),!0;const l=zte(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},qHe=(t,e)=>n=>t.every((r,i)=>e(r,{...n,index:i})),KHe=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),Bte=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&&Bte(r)}return t};function M1(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 Bte(n)}function Y0(t,e,n){if(t instanceof Id||t instanceof At)return t;n={slice:!0,parseOptions:{},...n};const r=typeof t=="object"&&t!==null,i=typeof t=="string";if(r)try{if(Array.isArray(t)&&t.length>0)return At.fromArray(t.map(l=>e.nodeFromJSON(l)));const o=e.nodeFromJSON(t);return n.errorOnInvalidContent&&o.check(),o}catch(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),Y0("",e,n)}if(i){if(n.errorOnInvalidContent){let o=!1,l="";const c=new Mee({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?Kb.fromSchema(c).parseSlice(M1(t),n.parseOptions):Kb.fromSchema(c).parse(M1(t),n.parseOptions),n.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const a=Kb.fromSchema(e);return n.slice?a.parseSlice(M1(t),n.parseOptions).content:a.parse(M1(t),n.parseOptions)}return Y0("",e,n)}function XHe(t,e,n){const r=t.steps.length-1;if(r<e)return;const i=t.steps[r];if(!(i instanceof Zi||i instanceof na))return;const a=t.mapping.maps[r];let o=0;a.forEach((l,c,u,d)=>{o===0&&(o=d)}),t.setSelection(En.near(t.doc.resolve(o),n))}var YHe=t=>!("type"in t),QHe=(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=b=>{a.emit("contentError",{editor:a,error:b,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{Y0(e,a.schema,{parseOptions:u,errorOnInvalidContent:!0})}catch(b){c(b)}try{l=Y0(e,a.schema,{parseOptions:u,errorOnInvalidContent:(o=n.errorOnInvalidContent)!=null?o:a.options.enableContentCheck})}catch(b){return c(b),!1}let{from:d,to:f}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},m=!0,p=!0;if((YHe(l)?l:[l]).forEach(b=>{b.check(),m=m?b.isText&&b.marks.length===0:!1,p=p?b.isBlock:!1}),d===f&&p){const{parent:b}=r.doc.resolve(d);b.isTextblock&&!b.type.spec.code&&!b.childCount&&(d-=1,f+=1)}let y;if(m){if(Array.isArray(e))y=e.map(b=>b.text||"").join("");else if(e instanceof At){let b="";e.forEach(v=>{v.text&&(b+=v.text)}),y=b}else typeof e=="object"&&e&&e.text?y=e.text:y=e;r.insertText(y,d,f)}else{y=l;const b=r.doc.resolve(d),v=b.node(),N=b.parentOffset===0,S=v.isText||v.isTextblock,T=v.content.size>0;N&&S&&T&&(d=Math.max(0,d-1)),r.replaceWith(d,f,y)}n.updateSelection&&XHe(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:d,text:y}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:d,text:y})}return!0},ZHe=()=>({state:t,dispatch:e})=>N6e(t,e),JHe=()=>({state:t,dispatch:e})=>M6e(t,e),eVe=()=>({state:t,dispatch:e})=>Gee(t,e),tVe=()=>({state:t,dispatch:e})=>Xee(t,e),nVe=()=>({state:t,dispatch:e,tr:n})=>{try{const r=QN(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},rVe=()=>({state:t,dispatch:e,tr:n})=>{try{const r=QN(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},iVe=()=>({state:t,dispatch:e})=>w6e(t,e),aVe=()=>({state:t,dispatch:e})=>S6e(t,e);function $te(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function sVe(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))pL()||$te()?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 oVe=t=>({editor:e,view:n,tr:r,dispatch:i})=>{const a=sVe(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 th(t,e,n={}){const{from:r,to:i,empty:a}=t.selection,o=e?Ei(e,t.schema):null,l=[];t.doc.nodesBetween(r,i,(f,m)=>{if(f.isText)return;const p=Math.max(r,m),x=Math.min(i,m+f.nodeSize);l.push({node:f,from:p,to:x})});const c=i-r,u=l.filter(f=>o?o.name===f.node.type.name:!0).filter(f=>GS(f.node.attrs,n,{strict:!1}));return a?!!u.length:u.reduce((f,m)=>f+m.to-m.from,0)>=c}var lVe=(t,e={})=>({state:n,dispatch:r})=>{const i=Ei(t,n.schema);return th(n,i,e)?E6e(n,r):!1},cVe=()=>({state:t,dispatch:e})=>Jee(t,e),uVe=t=>({state:e,dispatch:n})=>{const r=Ei(t,e.schema);return F6e(r)(e,n)},dVe=()=>({state:t,dispatch:e})=>Qee(t,e);function aM(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function pG(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 hVe=(t,e)=>({tr:n,state:r,dispatch:i})=>{let a=null,o=null;const l=aM(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(a=Ei(t,r.schema)),l==="mark"&&(o=_u(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,pG(d.attrs,e))),o&&d.marks.length&&d.marks.forEach(m=>{o===m.type&&(c=!0,i&&n.addMark(f,f+d.nodeSize,o.create(pG(m.attrs,e))))})})}),c},fVe=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),mVe=()=>({tr:t,dispatch:e})=>{if(e){const n=new Ks(t.doc);t.setSelection(n)}return!0},pVe=()=>({state:t,dispatch:e})=>qee(t,e),gVe=()=>({state:t,dispatch:e})=>Yee(t,e),xVe=()=>({state:t,dispatch:e})=>k6e(t,e),bVe=()=>({state:t,dispatch:e})=>R6e(t,e),yVe=()=>({state:t,dispatch:e})=>P6e(t,e);function NR(t,e,n={},r={}){return Y0(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var vVe=(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=NR(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 Hte(t,e){const n=_u(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 Vte(t,e){const n=new Bee(t);return e.forEach(r=>{r.steps.forEach(i=>{n.step(i)})}),n}function _Ve(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 wVe(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(i,a)=>{n(i)&&r.push({node:i,pos:a})}),r}function SVe(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 sM(t){return e=>SVe(e.$from,t)}function Jt(t,e,n){return t.config[e]===void 0&&t.parent?Jt(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?Jt(t.parent,e,n):null}):t.config[e]}function gL(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=Jt(e,"addExtensions",n);return r?[e,...gL(r())]:e}).flat(10)}function xL(t,e){const n=im.fromSchema(e).serializeFragment(t),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(n),i.innerHTML}function Gte(t){return typeof t=="function"}function nr(t,e=void 0,...n){return Gte(t)?e?t.bind(e)(...n):t(...n):t}function NVe(t={}){return Object.keys(t).length===0&&t.constructor===Object}function kg(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 Wte(t){const e=[],{nodeExtensions:n,markExtensions:r}=kg(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=Jt(o,"addGlobalAttributes",l);if(!c)return;c().forEach(d=>{d.types.forEach(f=>{Object.entries(d.attributes).forEach(([m,p])=>{e.push({type:f,name:m,attribute:{...a,...p}})})})})}),i.forEach(o=>{const l={name:o.name,options:o.options,storage:o.storage},c=Jt(o,"addAttributes",l);if(!c)return;const u=c();Object.entries(u).forEach(([d,f])=>{const m={...a,...f};typeof m?.default=="function"&&(m.default=m.default()),m?.isRequired&&m?.default===void 0&&delete m.default,e.push({type:o.name,name:d,attribute:m})})}),e}function ai(...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,m]=d.split(":").map(p=>p.trim());u.set(f,m)}),l.forEach(d=>{const[f,m]=d.split(":").map(p=>p.trim());u.set(f,m)}),r[i]=Array.from(u.entries()).map(([d,f])=>`${d}: ${f}`).join("; ")}else r[i]=a}),r},{})}function WS(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)=>ai(n,r),{})}function MVe(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function gG(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):MVe(n.getAttribute(o.name));return l==null?a:{...a,[o.name]:l}},{});return{...r,...i}}}}function xG(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&NVe(n)?!1:n!=null))}function bG(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 EVe(t,e){var n;const r=Wte(t),{nodeExtensions:i,markExtensions:a}=kg(t),o=(n=i.find(u=>Jt(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},m=t.reduce((v,N)=>{const S=Jt(N,"extendNodeSchema",f);return{...v,...S?S(u):{}}},{}),p=xG({...m,content:nr(Jt(u,"content",f)),marks:nr(Jt(u,"marks",f)),group:nr(Jt(u,"group",f)),inline:nr(Jt(u,"inline",f)),atom:nr(Jt(u,"atom",f)),selectable:nr(Jt(u,"selectable",f)),draggable:nr(Jt(u,"draggable",f)),code:nr(Jt(u,"code",f)),whitespace:nr(Jt(u,"whitespace",f)),linebreakReplacement:nr(Jt(u,"linebreakReplacement",f)),defining:nr(Jt(u,"defining",f)),isolating:nr(Jt(u,"isolating",f)),attrs:Object.fromEntries(d.map(bG))}),x=nr(Jt(u,"parseHTML",f));x&&(p.parseDOM=x.map(v=>gG(v,d)));const y=Jt(u,"renderHTML",f);y&&(p.toDOM=v=>y({node:v,HTMLAttributes:WS(v,d)}));const b=Jt(u,"renderText",f);return b&&(p.toText=b),[u.name,p]})),c=Object.fromEntries(a.map(u=>{const d=r.filter(b=>b.type===u.name),f={name:u.name,options:u.options,storage:u.storage,editor:e},m=t.reduce((b,v)=>{const N=Jt(v,"extendMarkSchema",f);return{...b,...N?N(u):{}}},{}),p=xG({...m,inclusive:nr(Jt(u,"inclusive",f)),excludes:nr(Jt(u,"excludes",f)),group:nr(Jt(u,"group",f)),spanning:nr(Jt(u,"spanning",f)),code:nr(Jt(u,"code",f)),attrs:Object.fromEntries(d.map(bG))}),x=nr(Jt(u,"parseHTML",f));x&&(p.parseDOM=x.map(b=>gG(b,d)));const y=Jt(u,"renderHTML",f);return y&&(p.toDOM=b=>y({mark:b,HTMLAttributes:WS(b,d)})),[u.name,p]}));return new Mee({topNode:o,nodes:l,marks:c})}function TVe(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function bL(t){return t.sort((n,r)=>{const i=Jt(n,"priority")||100,a=Jt(r,"priority")||100;return i>a?-1:i<a?1:0})}function qte(t){const e=bL(gL(t)),n=TVe(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 Kte(t,e,n){const{from:r,to:i}=e,{blockSeparator:a=`
  8150. `,textSerializers:o={}}=n||{};let l="";return t.nodesBetween(r,i,(c,u,d,f)=>{var m;c.isBlock&&u>r&&(l+=a);const p=o?.[c.type.name];if(p)return d&&(l+=p({node:c,pos:u,parent:d,index:f,range:e})),!1;c.isText&&(l+=(m=c?.text)==null?void 0:m.slice(Math.max(r,u)-u,i-u))}),l}function AVe(t,e){const n={from:0,to:t.content.size};return Kte(t,n,e)}function Xte(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function CVe(t,e){const n=Ei(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 Yte(t,e){const n=aM(typeof e=="string"?e:e.name,t.schema);return n==="node"?CVe(t,e):n==="mark"?Hte(t,e):{}}function kVe(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 jVe(t){const e=kVe(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 Qte(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),m=e.invert().map(d);r.push({oldRange:{from:f,to:m},newRange:{from:u,to:d}})})}),jVe(r)}function yL(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(i=>{const a=n.resolve(t),o=mL(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 PVe=(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 ij(t,e){return e.nodes[t]||e.marks[t]||null}function sw(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 RVe=(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 MR(t,e,n={}){const{empty:r,ranges:i}=t.selection,a=e?_u(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(f=>a?a.name===f.type.name:!0).find(f=>GS(f.attrs,n,{strict:!1}));let o=0;const l=[];if(i.forEach(({$from:f,$to:m})=>{const p=f.pos,x=m.pos;t.doc.nodesBetween(p,x,(y,b)=>{if(!y.isText&&!y.marks.length)return;const v=Math.max(p,b),N=Math.min(x,b+y.nodeSize),S=N-v;o+=S,l.push(...y.marks.map(T=>({mark:T,from:v,to:N})))})}),o===0)return!1;const c=l.filter(f=>a?a.name===f.mark.type.name:!0).filter(f=>GS(f.mark.attrs,n,{strict:!1})).reduce((f,m)=>f+m.to-m.from,0),u=l.filter(f=>a?f.mark.type!==a&&f.mark.type.excludes(a):!0).reduce((f,m)=>f+m.to-m.from,0);return(c>0?c+u:c)>=o}function DVe(t,e,n={}){if(!e)return th(t,null,n)||MR(t,null,n);const r=aM(e,t.schema);return r==="node"?th(t,e,n):r==="mark"?MR(t,e,n):!1}var OVe=(t,e)=>{const{$from:n,$to:r,$anchor:i}=t.selection;if(e){const a=sM(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)},LVe=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function yG(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function vG(t,e){const{nodeExtensions:n}=kg(e),r=n.find(o=>o.name===t);if(!r)return!1;const i={name:r.name,options:r.options,storage:r.storage},a=nr(Jt(r,"group",i));return typeof a!="string"?!1:a.split(" ").includes("list")}function oM(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&&(oM(a,{ignoreWhitespace:n,checkChildren:e})||(i=!1))}),i}return!1}function Zte(t){return t instanceof tn}function IVe(t,e,n){var r;const{selection:i}=e;let a=null;if(Ute(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,m)=>{if(u)return!1;if(d.isInline){const p=!m||m.type.allowsMarkType(n),x=!!n.isInSet(d.marks)||!d.marks.some(y=>y.type.excludes(n));u=p&&x}return!u}),u})}var FVe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const{selection:a}=n,{empty:o,ranges:l}=a,c=_u(t,r.schema);if(i)if(o){const u=Hte(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,(m,p)=>{const x=Math.max(p,d),y=Math.min(p+m.nodeSize,f);m.marks.find(v=>v.type===c)?m.marks.forEach(v=>{c===v.type&&n.addMark(x,y,c.create({...v.attrs,...e}))}):n.addMark(x,y,c.create(e))})});return IVe(r,n,c)},UVe=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),zVe=(t,e={})=>({state:n,dispatch:r,chain:i})=>{const a=Ei(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})=>D9(a,{...o,...e})(n)?!0:l.clearNodes()).command(({state:l})=>D9(a,{...o,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},BVe=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,i=of(t,0,r.content.size),a=tn.create(r,i);e.setSelection(a)}return!0},$Ve=(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},HVe=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:i,to:a}=typeof t=="number"?{from:t,to:t}:t,o=hn.atStart(r).from,l=hn.atEnd(r).to,c=of(i,o,l),u=of(a,o,l),d=hn.create(r,c,u);e.setSelection(d)}return!0},VVe=t=>({state:e,dispatch:n})=>{const r=Ei(t,e.schema);return B6e(r)(e,n)};function _G(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 GVe=({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=sw(u,l.node().type.name,l.node().attrs);if(a instanceof tn&&a.node.isBlock)return!l.parentOffset||!ru(o,l.pos)?!1:(r&&(t&&_G(n,i.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;const f=c.parentOffset===c.parent.content.size,m=l.depth===0?void 0:_Ve(l.node(-1).contentMatchAt(l.indexAfter(-1)));let p=f&&m?[{type:m,attrs:d}]:void 0,x=ru(e.doc,e.mapping.map(l.pos),1,p);if(!p&&!x&&ru(e.doc,e.mapping.map(l.pos),1,m?[{type:m}]:void 0)&&(x=!0,p=m?[{type:m,attrs:d}]:void 0),r){if(x&&(a instanceof hn&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,p),m&&!f&&!l.parentOffset&&l.parent.type!==m)){const y=e.mapping.map(l.before()),b=e.doc.resolve(y);l.node(-1).canReplaceWith(b.index(),b.index()+1,m)&&e.setNodeMarkup(e.mapping.map(l.before()),m)}t&&_G(n,i.extensionManager.splittableMarks),e.scrollIntoView()}return x},WVe=(t,e={})=>({tr:n,state:r,dispatch:i,editor:a})=>{var o;const l=Ei(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 m=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=At.empty;const N=c.index(-1)?1:c.index(-2)?2:3;for(let O=c.depth-N;O>=c.depth-3;O-=1)v=At.from(c.node(O).copy(v));const S=c.indexAfter(-1)<c.node(-2).childCount?1:c.indexAfter(-2)<c.node(-3).childCount?2:3,T={...sw(m,c.node().type.name,c.node().attrs),...e},E=((o=l.contentMatch.defaultType)==null?void 0:o.createAndFill(T))||void 0;v=v.append(At.from(l.createAndFill(null,E)||void 0));const C=c.before(c.depth-(N-1));n.replace(C,c.after(-S),new Ut(v,4-N,0));let A=-1;n.doc.nodesBetween(C,n.doc.content.size,(O,k)=>{if(A>-1)return!1;O.isTextblock&&O.content.size===0&&(A=k+1)}),A>-1&&n.setSelection(hn.near(n.doc.resolve(A))),n.scrollIntoView()}return!0}const p=u.pos===c.end()?f.contentMatchAt(0).defaultType:null,x={...sw(m,f.type.name,f.attrs),...e},y={...sw(m,c.node().type.name,c.node().attrs),...e};n.delete(c.pos,u.pos);const b=p?[{type:l,attrs:x},{type:p,attrs:y}]:[{type:l,attrs:x}];if(!ru(n.doc,c.pos,2))return!1;if(i){const{selection:v,storedMarks:N}=r,{splittableMarks:S}=a.extensionManager,T=N||v.$to.parentOffset&&v.$from.marks();if(n.split(c.pos,2,b).scrollIntoView(),!T||!i)return!0;const E=T.filter(C=>S.includes(C.type.name));n.ensureMarks(E)}return!0},aj=(t,e)=>{const n=sM(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&&lh(t.doc,n.pos)&&t.join(n.pos),!0},sj=(t,e)=>{const n=sM(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&&lh(t.doc,r)&&t.join(r),!0},qVe=(t,e,n,r={})=>({editor:i,tr:a,state:o,dispatch:l,chain:c,commands:u,can:d})=>{const{extensions:f,splittableMarks:m}=i.extensionManager,p=Ei(t,o.schema),x=Ei(e,o.schema),{selection:y,storedMarks:b}=o,{$from:v,$to:N}=y,S=v.blockRange(N),T=b||y.$to.parentOffset&&y.$from.marks();if(!S)return!1;const E=sM(C=>vG(C.type.name,f))(y);if(S.depth>=1&&E&&S.depth-E.depth<=1){if(E.node.type===p)return u.liftListItem(x);if(vG(E.node.type.name,f)&&p.validContent(E.node.content)&&l)return c().command(()=>(a.setNodeMarkup(E.pos,p),!0)).command(()=>aj(a,p)).command(()=>sj(a,p)).run()}return!n||!T||!l?c().command(()=>d().wrapInList(p,r)?!0:u.clearNodes()).wrapInList(p,r).command(()=>aj(a,p)).command(()=>sj(a,p)).run():c().command(()=>{const C=d().wrapInList(p,r),A=T.filter(O=>m.includes(O.type.name));return a.ensureMarks(A),C?!0:u.clearNodes()}).wrapInList(p,r).command(()=>aj(a,p)).command(()=>sj(a,p)).run()},KVe=(t,e={},n={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:a=!1}=n,o=_u(t,r.schema);return MR(r,o,e)?i.unsetMark(o,{extendEmptyMarkRange:a}):i.setMark(o,e)},XVe=(t,e,n={})=>({state:r,commands:i})=>{const a=Ei(t,r.schema),o=Ei(e,r.schema),l=th(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})},YVe=(t,e={})=>({state:n,commands:r})=>{const i=Ei(t,n.schema);return th(n,i,e)?r.lift(i):r.wrapIn(i,e)},QVe=()=>({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},ZVe=()=>({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},JVe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{var a;const{extendEmptyMarkRange:o=!1}=e,{selection:l}=n,c=_u(t,r.schema),{$from:u,empty:d,ranges:f}=l;if(!i)return!0;if(d&&o){let{from:m,to:p}=l;const x=(a=u.marks().find(b=>b.type===c))==null?void 0:a.attrs,y=mL(u,c,x);y&&(m=y.from,p=y.to),n.removeMark(m,p,c)}else f.forEach(m=>{n.removeMark(m.$from.pos,m.$to.pos,c)});return n.removeStoredMark(c),!0},e7e=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},t7e=(t,e={})=>({tr:n,state:r,dispatch:i})=>{let a=null,o=null;const l=aM(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(a=Ei(t,r.schema)),l==="mark"&&(o=_u(t,r.schema));let c=!1;return n.selection.ranges.forEach(u=>{const d=u.$from.pos,f=u.$to.pos;let m,p,x,y;n.selection.empty?r.doc.nodesBetween(d,f,(b,v)=>{a&&a===b.type&&(c=!0,x=Math.max(v,d),y=Math.min(v+b.nodeSize,f),m=v,p=b)}):r.doc.nodesBetween(d,f,(b,v)=>{v<d&&a&&a===b.type&&(c=!0,x=Math.max(v,d),y=Math.min(v+b.nodeSize,f),m=v,p=b),v>=d&&v<=f&&(a&&a===b.type&&(c=!0,i&&n.setNodeMarkup(v,void 0,{...b.attrs,...e})),o&&b.marks.length&&b.marks.forEach(N=>{if(o===N.type&&(c=!0,i)){const S=Math.max(v,d),T=Math.min(v+b.nodeSize,f);n.addMark(S,T,o.create({...N.attrs,...e}))}}))}),p&&(m!==void 0&&i&&n.setNodeMarkup(m,void 0,{...p.attrs,...e}),o&&p.marks.length&&p.marks.forEach(b=>{o===b.type&&i&&n.addMark(x,y,o.create({...b.attrs,...e}))}))}),c},n7e=(t,e={})=>({state:n,dispatch:r})=>{const i=Ei(t,n.schema);return D6e(i,e)(n,r)},r7e=(t,e={})=>({state:n,dispatch:r})=>{const i=Ei(t,n.schema);return O6e(i,e)(n,r)},i7e=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={}}},lM=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},a7e=(t,e)=>{if(fL(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 E1(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(m=>m.type.spec.code))return!1;let d=!1;const f=RVe(u)+a;return o.forEach(m=>{if(d)return;const p=a7e(f,m.find);if(!p)return;const x=c.state.tr,y=rM({state:c.state,transaction:x}),b={from:r-(p[0].length-a.length),to:i},{commands:v,chain:N,can:S}=new iM({editor:n,state:y});m.handler({state:y,range:b,match:p,commands:v,chain:N,can:S})===null||!x.steps.length||(m.undoable&&x.setMeta(l,{transform:x,from:r,to:i,text:a}),c.dispatch(x),d=!0)}),d}function s7e(t){const{editor:e,rules:n}=t,r=new Kr({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=xL(At.from(d),o.schema);const{from:f}=c,m=f+d.length;E1({editor:e,from:f,to:m,text:d,rules:n,plugin:r})}),i.selectionSet||i.docChanged?null:a}},props:{handleTextInput(i,a,o,l){return E1({editor:e,from:a,to:o,text:l,rules:n,plugin:r})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:a}=i.state.selection;a&&E1({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?E1({editor:e,from:o.pos,to:o.pos,text:`
  8151. `,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function o7e(t){return Object.prototype.toString.call(t).slice(8,-1)}function T1(t){return o7e(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function Jte(t,e){const n={...t};return T1(t)&&T1(e)&&Object.keys(e).forEach(r=>{T1(e[r])&&T1(t[r])?n[r]=Jte(t[r],e[r]):n[r]=e[r]}),n}var vL=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{...nr(Jt(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...nr(Jt(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>Jte(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}},uh=class ene extends vL{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new ene(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 l7e(t){return typeof t=="number"}var c7e=class{constructor(t){this.find=t.find,this.handler=t.handler}},u7e=(t,e,n)=>{if(fL(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 d7e(t){const{editor:e,state:n,from:r,to:i,rule:a,pasteEvent:o,dropEvent:l}=t,{commands:c,chain:u,can:d}=new iM({editor:e,state:n}),f=[];return n.doc.nodesBetween(r,i,(p,x)=>{var y,b,v,N,S;if((b=(y=p.type)==null?void 0:y.spec)!=null&&b.code||!(p.isText||p.isTextblock||p.isInline))return;const T=(S=(N=(v=p.content)==null?void 0:v.size)!=null?N:p.nodeSize)!=null?S:0,E=Math.max(r,x),C=Math.min(i,x+T);if(E>=C)return;const A=p.isText?p.text||"":p.textBetween(E-x,C-x,void 0,"");u7e(A,a.find,o).forEach(k=>{if(k.index===void 0)return;const R=E+k.index+1,F=R+k[0].length,L={from:n.tr.mapping.map(R),to:n.tr.mapping.map(F)},K=a.handler({state:n,range:L,match:k,commands:c,chain:u,can:d,pasteEvent:o,dropEvent:l});f.push(K)})}),f.every(p=>p!==null)}var A1=null,h7e=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function f7e(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:m,rule:p,pasteEvt:x})=>{const y=d.tr,b=rM({state:d,transaction:y});if(!(!d7e({editor:e,state:b,from:Math.max(f-1,0),to:m.b-1,rule:p,pasteEvent:x,dropEvent:l})||!y.steps.length)){try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}return o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,y}};return n.map(d=>new Kr({view(f){const m=x=>{var y;r=(y=f.dom.parentElement)!=null&&y.contains(x.target)?f.dom.parentElement:null,r&&(A1=e)},p=()=>{A1&&(A1=null)};return window.addEventListener("dragstart",m),window.addEventListener("dragend",p),{destroy(){window.removeEventListener("dragstart",m),window.removeEventListener("dragend",p)}}},props:{handleDOMEvents:{drop:(f,m)=>{if(a=r===f.dom.parentElement,l=m,!a){const p=A1;p?.isEditable&&setTimeout(()=>{const x=p.state.selection;x&&p.commands.deleteRange({from:x.from,to:x.to})},10)}return!1},paste:(f,m)=>{var p;const x=(p=m.clipboardData)==null?void 0:p.getData("text/html");return o=m,i=!!x?.includes("data-pm-slice"),!1}}},appendTransaction:(f,m,p)=>{const x=f[0],y=x.getMeta("uiEvent")==="paste"&&!i,b=x.getMeta("uiEvent")==="drop"&&!a,v=x.getMeta("applyPasteRules"),N=!!v;if(!y&&!b&&!N)return;if(N){let{text:E}=v;typeof E=="string"?E=E:E=xL(At.from(E),p.schema);const{from:C}=v,A=C+E.length,O=h7e(E);return c({rule:d,state:p,from:C,to:{b:A},pasteEvt:O})}const S=m.doc.content.findDiffStart(p.doc.content),T=m.doc.content.findDiffEnd(p.doc.content);if(!(!l7e(S)||!T||S===T.b))return c({rule:d,state:p,from:S,to:T,pasteEvt:o})}}))}var cM=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=qte(t),this.schema=EVe(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:ij(e.name,this.schema)},r=Jt(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return bL([...this.extensions].reverse()).flatMap(r=>{const i={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:ij(r.name,this.schema)},a=[],o=Jt(r,"addKeyboardShortcuts",i);let l={};if(r.type==="mark"&&Jt(r,"exitable",i)&&(l.ArrowRight=()=>uh.handleExit({editor:t,mark:r})),o){const m=Object.fromEntries(Object.entries(o()).map(([p,x])=>[p,()=>x({editor:t})]));l={...l,...m}}const c=CHe(l);a.push(c);const u=Jt(r,"addInputRules",i);if(yG(r,t.options.enableInputRules)&&u){const m=u();if(m&&m.length){const p=s7e({editor:t,rules:m}),x=Array.isArray(p)?p:[p];a.push(...x)}}const d=Jt(r,"addPasteRules",i);if(yG(r,t.options.enablePasteRules)&&d){const m=d();if(m&&m.length){const p=f7e({editor:t,rules:m});a.push(...p)}}const f=Jt(r,"addProseMirrorPlugins",i);if(f){const m=f();a.push(...m)}return a})}get attributes(){return Wte(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=kg(this.extensions);return Object.fromEntries(e.filter(n=>!!Jt(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:Ei(n.name,this.schema)},a=Jt(n,"addNodeView",i);if(!a)return[];const o=a();if(!o)return[];const l=(c,u,d,f,m)=>{const p=WS(c,r);return o({node:c,view:u,getPos:d,decorations:f,innerDecorations:m,editor:t,extension:n,HTMLAttributes:p})};return[n.name,l]}))}get markViews(){const{editor:t}=this,{markExtensions:e}=kg(this.extensions);return Object.fromEntries(e.filter(n=>!!Jt(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:_u(n.name,this.schema)},a=Jt(n,"addMarkView",i);if(!a)return[];const o=(l,c,u)=>{const d=WS(l,r);return a()({mark:l,view:c,inline:u,editor:t,extension:n,HTMLAttributes:d,updateAttributes:f=>{A7e(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:ij(e.name,this.schema)};e.type==="mark"&&((n=nr(Jt(e,"keepOnSplit",r)))==null||n)&&this.splittableMarks.push(e.name);const i=Jt(e,"onBeforeCreate",r),a=Jt(e,"onCreate",r),o=Jt(e,"onUpdate",r),l=Jt(e,"onSelectionUpdate",r),c=Jt(e,"onTransaction",r),u=Jt(e,"onFocus",r),d=Jt(e,"onBlur",r),f=Jt(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)})}};cM.resolve=qte;cM.sort=bL;cM.flatten=gL;var m7e={};hL(m7e,{ClipboardTextSerializer:()=>nne,Commands:()=>rne,Delete:()=>ine,Drop:()=>ane,Editable:()=>sne,FocusEvents:()=>lne,Keymap:()=>cne,Paste:()=>une,Tabindex:()=>dne,TextDirection:()=>hne,focusEventsPluginKey:()=>one});var br=class tne extends vL{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new tne(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},nne=br.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new Kr({key:new $i("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=Xte(n);return Kte(r,{from:o,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:c})}}})]}}),rne=br.create({name:"commands",addCommands(){return{...Ite}}}),ine=br.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=Vte(t.before,[t,...e]);Qte(d).forEach(p=>{d.mapping.mapResult(p.oldRange.from).deletedAfter&&d.mapping.mapResult(p.oldRange.to).deletedBefore&&d.before.nodesBetween(p.oldRange.from,p.oldRange.to,(x,y)=>{const b=y+x.nodeSize-2,v=p.oldRange.from<=y&&b<=p.oldRange.to;this.editor.emit("delete",{type:"node",node:x,from:y,to:b,newFrom:d.mapping.map(y),newTo:d.mapping.map(b),deletedRange:p.oldRange,newRange:p.newRange,partial:!v,editor:this.editor,transaction:t,combinedTransform:d})})});const m=d.mapping;d.steps.forEach((p,x)=>{var y,b;if(p instanceof il){const v=m.slice(x).map(p.from,-1),N=m.slice(x).map(p.to),S=m.invert().map(v,-1),T=m.invert().map(N),E=(y=d.doc.nodeAt(v-1))==null?void 0:y.marks.some(A=>A.eq(p.mark)),C=(b=d.doc.nodeAt(N))==null?void 0:b.marks.some(A=>A.eq(p.mark));this.editor.emit("delete",{type:"mark",mark:p.mark,from:p.from,to:p.to,deletedRange:{from:S,to:T},newRange:{from:v,to:N},partial:!!(C||E),editor:this.editor,transaction:t,combinedTransform:d})}})};(i=(r=(n=this.editor.options.coreExtensionOptions)==null?void 0:n.delete)==null?void 0:r.async)==null||i?setTimeout(a,0):a()}}),ane=br.create({name:"drop",addProseMirrorPlugins(){return[new Kr({key:new $i("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),sne=br.create({name:"editable",addProseMirrorPlugins(){return[new Kr({key:new $i("editable"),props:{editable:()=>this.editor.options.editable}})]}}),one=new $i("focusEvents"),lne=br.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new Kr({key:one,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}}}})]}}),cne=br.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:m,parent:p}=f,x=f.parent.isTextblock&&m>0?l.doc.resolve(m-1):f,y=x.parent.type.spec.isolating,b=f.pos-f.parentOffset,v=y&&x.parent.childCount===1?b===f.pos:En.atStart(u).from===m;return!d||!p.type.isTextblock||p.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 pL()||$te()?a:i},addProseMirrorPlugins(){return[new Kr({key:new $i("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(y=>y.getMeta("composition")))return;const r=t.some(y=>y.docChanged)&&!e.doc.eq(n.doc),i=t.some(y=>y.getMeta("preventClearDocument"));if(!r||i)return;const{empty:a,from:o,to:l}=e.selection,c=En.atStart(e.doc).from,u=En.atEnd(e.doc).to;if(a||!(o===c&&l===u)||!oM(n.doc))return;const m=n.tr,p=rM({state:n,transaction:m}),{commands:x}=new iM({editor:this.editor,state:p});if(x.clearNodes(),!!m.steps.length)return m}})]}}),une=br.create({name:"paste",addProseMirrorPlugins(){return[new Kr({key:new $i("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),dne=br.create({name:"tabindex",addProseMirrorPlugins(){return[new Kr({key:new $i("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),hne=br.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=kg(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 Kr({key:new $i("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),p7e=class Rp{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 Rp(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 Rp(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 Rp(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 Rp(l,this.editor,i,i?n:null);i&&(c.actualDepth=this.depth+1),e.push(new Rp(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)}},g7e=`.ProseMirror {
  8152. position: relative;
  8153. }
  8154. .ProseMirror {
  8155. word-wrap: break-word;
  8156. white-space: pre-wrap;
  8157. white-space: break-spaces;
  8158. -webkit-font-variant-ligatures: none;
  8159. font-variant-ligatures: none;
  8160. font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
  8161. }
  8162. .ProseMirror [contenteditable="false"] {
  8163. white-space: normal;
  8164. }
  8165. .ProseMirror [contenteditable="false"] [contenteditable="true"] {
  8166. white-space: pre-wrap;
  8167. }
  8168. .ProseMirror pre {
  8169. white-space: pre-wrap;
  8170. }
  8171. img.ProseMirror-separator {
  8172. display: inline !important;
  8173. border: none !important;
  8174. margin: 0 !important;
  8175. width: 0 !important;
  8176. height: 0 !important;
  8177. }
  8178. .ProseMirror-gapcursor {
  8179. display: none;
  8180. pointer-events: none;
  8181. position: absolute;
  8182. margin: 0;
  8183. }
  8184. .ProseMirror-gapcursor:after {
  8185. content: "";
  8186. display: block;
  8187. position: absolute;
  8188. top: -2px;
  8189. width: 20px;
  8190. border-top: 1px solid black;
  8191. animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
  8192. }
  8193. @keyframes ProseMirror-cursor-blink {
  8194. to {
  8195. visibility: hidden;
  8196. }
  8197. }
  8198. .ProseMirror-hideselection *::selection {
  8199. background: transparent;
  8200. }
  8201. .ProseMirror-hideselection *::-moz-selection {
  8202. background: transparent;
  8203. }
  8204. .ProseMirror-hideselection * {
  8205. caret-color: transparent;
  8206. }
  8207. .ProseMirror-focused .ProseMirror-gapcursor {
  8208. display: block;
  8209. }`;function x7e(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 b7e=class extends i7e{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=zte(e,this.options.autofocus);this.editorState=Bp.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=x7e(g7e,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=Gte(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?[sne,nne.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),rne,lne,cne,dne,ane,une,ine,hne.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 cM(r,this)}createCommandManager(){this.commandManager=new iM({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=NR(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=NR(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return t}createView(t){var e;this.editorView=new Ote(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 Yte(this.state,t)}isActive(t,e){const n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return DVe(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return xL(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=`
  8210. `,textSerializers:n={}}=t||{};return AVe(this.state.doc,{blockSeparator:e,textSerializers:{...Xte(this.schema),...n}})}get isEmpty(){return oM(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 p7e(e,this)}get $doc(){return this.$pos(0)}};function jg(t){return new lM({find:t.find,handler:({state:e,range:n,match:r})=>{const i=nr(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(yL(n.from,n.to,e.doc).filter(p=>p.mark.type.excluded.find(y=>y===t.type&&y!==p.mark.type)).filter(p=>p.to>u).length)return null;d<n.to&&a.delete(d,n.to),u>n.from&&a.delete(n.from+c,u);const m=n.from+c+o.length;a.addMark(n.from+c,m,t.type.create(i||{})),a.removeStoredMark(t.type)}},undoable:t.undoable})}function fne(t){return new lM({find:t.find,handler:({state:e,range:n,match:r})=>{const i=nr(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 ER(t){return new lM({find:t.find,handler:({state:e,range:n,match:r})=>{const i=e.doc.resolve(n.from),a=nr(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 Pg(t){return new lM({find:t.find,handler:({state:e,range:n,match:r,chain:i})=>{const a=nr(t.getAttributes,void 0,r)||{},o=e.tr.delete(n.from,n.to),c=o.doc.resolve(n.from).blockRange(),u=c&&YO(c,t.type,a);if(!u)return null;if(o.wrap(c,u),t.keepMarks&&t.editor){const{selection:f,storedMarks:m}=e,{splittableMarks:p}=t.editor.extensionManager,x=m||f.$to.parentOffset&&f.$from.marks();if(x){const y=x.filter(b=>p.includes(b.type.name));o.ensureMarks(y)}}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&&lh(o.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,d))&&o.join(n.from-1)},undoable:t.undoable})}var y7e=t=>"touches"in t,v7e=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,y7e(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 _7e(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof tn){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 w7e={};hL(w7e,{createAtomBlockMarkdownSpec:()=>S7e,createBlockMarkdownSpec:()=>N7e,createInlineMarkdownSpec:()=>T7e,parseAttributes:()=>_L,parseIndentedBlocks:()=>TR,renderNestedMarkdownContent:()=>SL,serializeAttributes:()=>wL});function _L(t){if(!t?.trim())return{};const e={},n=[],r=t.replace(/["']([^"']*)["']/g,u=>(n.push(u),`__QUOTED_${n.length-1}__`)),i=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(i){const u=i.map(d=>d.trim().slice(1));e.class=u.join(" ")}const a=r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);a&&(e.id=a[1]);const o=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(r.matchAll(o)).forEach(([,u,d])=>{var f;const m=parseInt(((f=d.match(/__QUOTED_(\d+)__/))==null?void 0:f[1])||"0",10),p=n[m];p&&(e[u]=p.slice(1,-1))});const c=r.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,"").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();return c&&c.split(/\s+/).filter(Boolean).forEach(d=>{d.match(/^[a-zA-Z][\w-]*$/)&&(e[d]=!0)}),e}function wL(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 S7e(t){const{nodeName:e,name:n,parseAttributes:r=_L,serializeAttributes:i=wL,defaultAttributes:a={},requiredAttributes:o=[],allowedAttributes:l}=t,c=n||e,u=d=>{if(!l)return d;const f={};return l.forEach(m=>{m in d&&(f[m]=d[m])}),f};return{parseMarkdown:(d,f)=>{const m={...a,...d.attributes};return f.createNode(e,m,[])},markdownTokenizer:{name:e,level:"block",start(d){var f;const m=new RegExp(`^:::${c}(?:\\s|$)`,"m"),p=(f=d.match(m))==null?void 0:f.index;return p!==void 0?p:-1},tokenize(d,f,m){const p=new RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),x=d.match(p);if(!x)return;const y=x[1]||"",b=r(y);if(!o.find(N=>!(N in b)))return{type:e,raw:x[0],attributes:b}}},renderMarkdown:d=>{const f=u(d.attrs||{}),m=i(f),p=m?` {${m}}`:"";return`:::${c}${p} :::`}}}function N7e(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=_L,serializeAttributes:a=wL,defaultAttributes:o={},content:l="block",allowedAttributes:c}=t,u=n||e,d=f=>{if(!c)return f;const m={};return c.forEach(p=>{p in f&&(m[p]=f[p])}),m};return{parseMarkdown:(f,m)=>{let p;if(r){const y=r(f);p=typeof y=="string"?[{type:"text",text:y}]:y}else l==="block"?p=m.parseChildren(f.tokens||[]):p=m.parseInline(f.tokens||[]);const x={...o,...f.attributes};return m.createNode(e,x,p)},markdownTokenizer:{name:e,level:"block",start(f){var m;const p=new RegExp(`^:::${u}`,"m"),x=(m=f.match(p))==null?void 0:m.index;return x!==void 0?x:-1},tokenize(f,m,p){var x;const y=new RegExp(`^:::${u}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),b=f.match(y);if(!b)return;const[v,N=""]=b,S=i(N);let T=1;const E=v.length;let C="";const A=/^:::([\w-]*)(\s.*)?/gm,O=f.slice(E);for(A.lastIndex=0;;){const k=A.exec(O);if(k===null)break;const R=k.index,F=k[1];if(!((x=k[2])!=null&&x.endsWith(":::"))){if(F)T+=1;else if(T-=1,T===0){const L=O.slice(0,R);C=L.trim();const K=f.slice(0,E+R+k[0].length);let j=[];if(C)if(l==="block")for(j=p.blockTokens(L),j.forEach(W=>{W.text&&(!W.tokens||W.tokens.length===0)&&(W.tokens=p.inlineTokens(W.text))});j.length>0;){const W=j[j.length-1];if(W.type==="paragraph"&&(!W.text||W.text.trim()===""))j.pop();else break}else j=p.inlineTokens(C);return{type:e,raw:K,attributes:S,content:C,tokens:j}}}}}},renderMarkdown:(f,m)=>{const p=d(f.attrs||{}),x=a(p),y=x?` {${x}}`:"",b=m.renderChildren(f.content||[],`
  8211. `);return`:::${u}${y}
  8212. ${b}
  8213. :::`}}}function M7e(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 E7e(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function T7e(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=M7e,serializeAttributes:a=E7e,defaultAttributes:o={},selfClosing:l=!1,allowedAttributes:c}=t,u=n||e,d=m=>{if(!c)return m;const p={};return c.forEach(x=>{x in m&&(p[x]=m[x])}),p},f=u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(m,p)=>{const x={...o,...m.attributes};if(l)return p.createNode(e,x);const y=r?r(m):m.content||"";return y?p.createNode(e,x,[p.createTextNode(y)]):p.createNode(e,x,[])},markdownTokenizer:{name:e,level:"inline",start(m){const p=l?new RegExp(`\\[${f}\\s*[^\\]]*\\]`):new RegExp(`\\[${f}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${f}\\]`),x=m.match(p),y=x?.index;return y!==void 0?y:-1},tokenize(m,p,x){const y=l?new RegExp(`^\\[${f}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${f}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${f}\\]`),b=m.match(y);if(!b)return;let v="",N="";if(l){const[,T]=b;N=T}else{const[,T,E]=b;N=T,v=E||""}const S=i(N.trim());return{type:e,raw:b[0],content:v.trim(),attributes:S}}},renderMarkdown:m=>{let p="";r?p=r(m):m.content&&m.content.length>0&&(p=m.content.filter(v=>v.type==="text").map(v=>v.text).join(""));const x=d(m.attrs||{}),y=a(x),b=y?` ${y}`:"";return l?`[${u}${b}]`:`[${u}${b}]${p}[/${u}]`}}}function TR(t,e,n){var r,i,a,o;const l=t.split(`
  8214. `),c=[];let u="",d=0;const f=e.baseIndentSize||2;for(;d<l.length;){const m=l[d],p=m.match(e.itemPattern);if(!p){if(c.length>0)break;if(m.trim()===""){d+=1,u=`${u}${m}
  8215. `;continue}else return}const x=e.extractItemData(p),{indentLevel:y,mainContent:b}=x;u=`${u}${m}
  8216. `;const v=[b];for(d+=1;d<l.length;){const E=l[d];if(E.trim()===""){const A=l.slice(d+1).findIndex(R=>R.trim()!=="");if(A===-1)break;if((((i=(r=l[d+1+A].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:i.length)||0)>y){v.push(E),u=`${u}${E}
  8217. `,d+=1;continue}else break}if((((o=(a=E.match(/^(\s*)/))==null?void 0:a[1])==null?void 0:o.length)||0)>y)v.push(E),u=`${u}${E}
  8218. `,d+=1;else break}let N;const S=v.slice(1);if(S.length>0){const E=S.map(C=>C.slice(y+f)).join(`
  8219. `);E.trim()&&(e.customNestedParser?N=e.customNestedParser(E):N=n.blockTokens(E))}const T=e.createToken(x,N);c.push(T)}if(c.length!==0)return{items:c,raw:u}}function SL(t,e,n,r){if(!t||!Array.isArray(t.content))return"";const i=typeof n=="function"?n(r):n,[a,...o]=t.content,l=e.renderChildren([a]),c=[`${i}${l}`];return o&&o.length>0&&o.forEach(u=>{const d=e.renderChildren([u]);if(d){const f=d.split(`
  8220. `).map(m=>m?e.indent(m):"").join(`
  8221. `);c.push(f)}}),c.join(`
  8222. `)}function A7e(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(p=>{if(p!==o)return!1;f=p}),!f)return;let m=!1;if(Object.keys(n).forEach(p=>{n[p]!==f.attrs[p]&&(m=!0)}),m){const p=t.type.create({...t.attrs,...n});a.removeMark(u,d,t.type),a.addMark(u,d,p)}}),a.docChanged&&e.view.dispatch(a)}var Ns=class mne extends vL{constructor(){super(...arguments),this.type="node"}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)}};function Yf(t){return new c7e({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:i})=>{const a=nr(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),m=f+l.length;if(yL(n.from,n.to,e.doc).filter(x=>x.mark.type.excluded.find(b=>b===t.type&&b!==x.mark.type)).filter(x=>x.to>f).length)return null;m<n.to&&o.delete(m,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 oj,wG;function C7e(){return wG||(wG=1,oj=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}),oj}var k7e=C7e();const j7e=Fo(k7e);var P7e=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},R7e=({contentComponent:t})=>{const e=KR.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return s.jsx(s.Fragment,{children:Object.values(e)})};function D7e(){const t=new Set;let e={};return{subscribe(n){return t.add(n),()=>{t.delete(n)}},getSnapshot(){return e},getServerSnapshot(){return e},setRenderer(n,r){e={...e,[n]:wle.createPortal(r.reactElement,r.element,n)},t.forEach(i=>i())},removeRenderer(n){const r={...e};delete r[n],e=r,t.forEach(i=>i())}}}var O7e=class extends Fr.Component{constructor(t){var e;super(t),this.editorContentRef=Fr.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=D7e(),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:P7e(e,this.editorContentRef),...n}),t?.contentComponent&&s.jsx(R7e,{contentComponent:t.contentComponent})]})}},L7e=w.forwardRef((t,e)=>{const n=Fr.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return Fr.createElement(O7e,{key:n,innerRef:e,...t})}),I7e=Fr.memo(L7e),F7e=typeof window<"u"?w.useLayoutEffect:w.useEffect,U7e=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 z7e(t){var e;const[n]=w.useState(()=>new U7e(t.editor)),r=iK.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:j7e);return F7e(()=>n.watch(t.editor),[t.editor,n]),w.useDebugValue(r),r}var B7e=!1,AR=typeof window>"u",$7e=AR||!!(typeof window<"u"&&window.next),H7e=class pne{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?AR||$7e?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 b7e(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?pne.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 V7e(t={},e=[]){const n=w.useRef(t);n.current=t;const[r]=w.useState(()=>new H7e(n)),i=KR.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return w.useDebugValue(i),w.useEffect(r.onRender(e)),z7e({editor:i,selector:({transactionNumber:a})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&a===0?0:a+1}),i}var G7e=w.createContext({editor:null});G7e.Consumer;var W7e=w.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),q7e=()=>w.useContext(W7e);Fr.forwardRef((t,e)=>{const{onDragStart:n}=q7e(),r=t.as||"div";return s.jsx(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});Fr.createContext({markViewContentRef:()=>{}});var qS=(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]},K7e=/^\s*>\s$/,X7e=Ns.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return qS("blockquote",{...ai(this.options.HTMLAttributes,t),children:qS("slot",{})})},parseMarkdown:(t,e)=>e.createNode("blockquote",void 0,e.parseChildren(t.tokens||[])),renderMarkdown:(t,e)=>{if(!t.content)return"";const n=">",r=[];return t.content.forEach(i=>{const l=e.renderChildren([i]).split(`
  8223. `).map(c=>c.trim()===""?n:`${n} ${c}`);r.push(l.join(`
  8224. `))}),r.join(`
  8225. ${n}
  8226. `)},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[Pg({find:K7e,type:this.type})]}}),Y7e=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,Q7e=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,Z7e=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,J7e=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,e9e=uh.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 qS("strong",{...ai(this.options.HTMLAttributes,t),children:qS("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[jg({find:Y7e,type:this.type}),jg({find:Z7e,type:this.type})]},addPasteRules(){return[Yf({find:Q7e,type:this.type}),Yf({find:J7e,type:this.type})]}}),t9e=/(^|[^`])`([^`]+)`(?!`)$/,n9e=/(^|[^`])`([^`]+)`(?!`)/g,r9e=uh.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",ai(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[jg({find:t9e,type:this.type})]},addPasteRules(){return[Yf({find:n9e,type:this.type})]}}),lj=4,i9e=/^```([a-z]+)?[\s\n]$/,a9e=/^~~~([a-z]+)?[\s\n]$/,s9e=Ns.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:lj,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",ai(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(t,e)=>{var n;return((n=t.raw)==null?void 0:n.startsWith("```"))===!1&&t.codeBlockStyle!=="indented"?[]:e.createNode("codeBlock",{language:t.lang||null},t.text?[e.createTextNode(t.text)]:[])},renderMarkdown:(t,e)=>{var n;let r="";const i=((n=t.attrs)==null?void 0:n.language)||"";return t.content?r=[`\`\`\`${i}`,e.renderChildren(t.content),"```"].join(`
  8227. `):r=`\`\`\`${i}
  8228. \`\`\``,r},addCommands(){return{setCodeBlock:t=>({commands:e})=>e.setNode(this.name,t),toggleCodeBlock:t=>({commands:e})=>e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:t,$anchor:e}=this.editor.state.selection,n=e.pos===1;return!t||e.parent.type.name!==this.name?!1:n||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:lj,{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,p=r.doc.textBetween(u,d,`
  8229. `,`
  8230. `).split(`
  8231. `).map(x=>l+x).join(`
  8232. `);return c.replaceWith(u,d,r.schema.text(p)),!0})},"Shift-Tab":({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:lj,{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(),p=r.doc.textBetween(d,f,`
  8233. `,`
  8234. `).split(`
  8235. `);let x=0,y=0;const b=u-d;for(let C=0;C<p.length;C+=1){if(y+p[C].length>=b){x=C;break}y+=p[C].length+1}const N=((c=p[x].match(/^ */))==null?void 0:c[0])||"",S=Math.min(N.length,n);if(S===0)return!0;let T=d;for(let C=0;C<x;C+=1)T+=p[C].length+1;return l.delete(T,T+S),u-T<=S&&l.setSelection(hn.create(l.doc,T)),!0}):t.commands.command(({tr:l})=>{const{from:c,to:u}=i,m=r.doc.textBetween(c,u,`
  8236. `,`
  8237. `).split(`
  8238. `).map(p=>{var x;const y=((x=p.match(/^ */))==null?void 0:x[0])||"",b=Math.min(y.length,n);return p.slice(b)}).join(`
  8239. `);return l.replaceWith(c,u,r.schema.text(m)),!0})},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=t,{selection:n}=e,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type)return!1;const a=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(`
  8240. `);return!a||!o?!1:t.chain().command(({tr:l})=>(l.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=t,{selection:n,doc:r}=e,{$from:i,empty:a}=n;if(!a||i.parent.type!==this.type||!(i.parentOffset===i.parent.nodeSize-2))return!1;const l=i.after();return l===void 0?!1:r.nodeAt(l)?t.commands.command(({tr:u})=>(u.setSelection(En.near(r.resolve(l))),!0)):t.commands.exitCode()}}},addInputRules(){return[ER({find:i9e,type:this.type,getAttributes:t=>({language:t[1]})}),ER({find:a9e,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new Kr({key:new $i("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const n=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),i=r?JSON.parse(r):void 0,a=i?.mode;if(!n||!a)return!1;const{tr:o,schema:l}=t.state,c=l.text(n.replace(/\r\n?/g,`
  8241. `));return o.replaceSelectionWith(this.type.create({language:a},c)),o.selection.$from.parent.type!==this.type&&o.setSelection(hn.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),t.dispatch(o),!0}}})]}}),o9e=Ns.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
  8242. `):""}),l9e=Ns.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",ai(this.options.HTMLAttributes,t)]},renderText(){return`
  8243. `},renderMarkdown:()=>`
  8244. `,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:i,storedMarks:a}=n;if(i.$from.parent.type.spec.isolating)return!1;const{keepMarks:o}=this.options,{splittableMarks:l}=r.extensionManager,c=a||i.$to.parentOffset&&i.$from.marks();return e().insertContent({type:this.name}).command(({tr:u,dispatch:d})=>{if(d&&c&&o){const f=c.filter(m=>l.includes(m.type.name));u.ensureMarks(f)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),c9e=Ns.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]}`,ai(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=>ER({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),u9e=Ns.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",ai(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!_7e(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,i=t();return Zte(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(hn.create(o.doc,c.pos+1)):c.nodeAfter.isBlock?o.setSelection(tn.create(o.doc,c.pos)):o.setSelection(hn.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(hn.create(o.doc,u+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[fne({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),d9e=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,h9e=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,f9e=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,m9e=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,p9e=uh.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",ai(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[jg({find:d9e,type:this.type}),jg({find:f9e,type:this.type})]},addPasteRules(){return[Yf({find:h9e,type:this.type}),Yf({find:m9e,type:this.type})]}});const g9e="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",x9e="ελ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",CR="numeric",kR="ascii",jR="alpha",Zb="asciinumeric",Ob="alphanumeric",PR="domain",gne="emoji",b9e="scheme",y9e="slashscheme",cj="whitespace";function v9e(t,e){return t in e||(e[t]=[]),e[t]}function lf(t,e,n){e[CR]&&(e[Zb]=!0,e[Ob]=!0),e[kR]&&(e[Zb]=!0,e[jR]=!0),e[Zb]&&(e[Ob]=!0),e[jR]&&(e[Ob]=!0),e[Ob]&&(e[PR]=!0),e[gne]&&(e[PR]=!0);for(const r in e){const i=v9e(r,n);i.indexOf(t)<0&&i.push(t)}}function _9e(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function ps(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}ps.groups={};ps.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||ps.groups;let i;return e&&e.j?i=e:(i=new ps(e),n&&r&&lf(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||ps.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 ps,Object.assign(o.j,l.j),o.jr.push.apply(o.jr,l.jr),o.jd=l.jd,o.t=l.t):o=new ps,a){if(r)if(o.t&&typeof o.t=="string"){const c=Object.assign(_9e(o.t,r),n);lf(a,c,r)}else n&&lf(a,n,r);o.t=a}return i.j[t]=o,o}};const wn=(t,e,n,r,i)=>t.ta(e,n,r,i),Zr=(t,e,n,r,i)=>t.tr(e,n,r,i),SG=(t,e,n,r,i)=>t.ts(e,n,r,i),Ct=(t,e,n,r,i)=>t.tt(e,n,r,i),Lc="WORD",RR="UWORD",xne="ASCIINUMERICAL",bne="ALPHANUMERICAL",Q0="LOCALHOST",DR="TLD",OR="UTLD",ow="SCHEME",Dp="SLASH_SCHEME",NL="NUM",LR="WS",ML="NL",Jb="OPENBRACE",e0="CLOSEBRACE",KS="OPENBRACKET",XS="CLOSEBRACKET",YS="OPENPAREN",QS="CLOSEPAREN",ZS="OPENANGLEBRACKET",JS="CLOSEANGLEBRACKET",e2="FULLWIDTHLEFTPAREN",t2="FULLWIDTHRIGHTPAREN",n2="LEFTCORNERBRACKET",r2="RIGHTCORNERBRACKET",i2="LEFTWHITECORNERBRACKET",a2="RIGHTWHITECORNERBRACKET",s2="FULLWIDTHLESSTHAN",o2="FULLWIDTHGREATERTHAN",l2="AMPERSAND",c2="APOSTROPHE",u2="ASTERISK",fd="AT",d2="BACKSLASH",h2="BACKTICK",f2="CARET",yd="COLON",EL="COMMA",m2="DOLLAR",Nl="DOT",p2="EQUALS",TL="EXCLAMATION",go="HYPHEN",t0="PERCENT",g2="PIPE",x2="PLUS",b2="POUND",n0="QUERY",AL="QUOTE",yne="FULLWIDTHMIDDLEDOT",CL="SEMI",Ml="SLASH",r0="TILDE",y2="UNDERSCORE",vne="EMOJI",v2="SYM";var _ne=Object.freeze({__proto__:null,ALPHANUMERICAL:bne,AMPERSAND:l2,APOSTROPHE:c2,ASCIINUMERICAL:xne,ASTERISK:u2,AT:fd,BACKSLASH:d2,BACKTICK:h2,CARET:f2,CLOSEANGLEBRACKET:JS,CLOSEBRACE:e0,CLOSEBRACKET:XS,CLOSEPAREN:QS,COLON:yd,COMMA:EL,DOLLAR:m2,DOT:Nl,EMOJI:vne,EQUALS:p2,EXCLAMATION:TL,FULLWIDTHGREATERTHAN:o2,FULLWIDTHLEFTPAREN:e2,FULLWIDTHLESSTHAN:s2,FULLWIDTHMIDDLEDOT:yne,FULLWIDTHRIGHTPAREN:t2,HYPHEN:go,LEFTCORNERBRACKET:n2,LEFTWHITECORNERBRACKET:i2,LOCALHOST:Q0,NL:ML,NUM:NL,OPENANGLEBRACKET:ZS,OPENBRACE:Jb,OPENBRACKET:KS,OPENPAREN:YS,PERCENT:t0,PIPE:g2,PLUS:x2,POUND:b2,QUERY:n0,QUOTE:AL,RIGHTCORNERBRACKET:r2,RIGHTWHITECORNERBRACKET:a2,SCHEME:ow,SEMI:CL,SLASH:Ml,SLASH_SCHEME:Dp,SYM:v2,TILDE:r0,TLD:DR,UNDERSCORE:y2,UTLD:OR,UWORD:RR,WORD:Lc,WS:LR});const jc=/[a-z]/,_b=new RegExp("\\p{L}","u"),uj=new RegExp("\\p{Emoji}","u"),Pc=/\d/,dj=/\s/,NG="\r",hj=`
  8245. `,w9e="️",S9e="‍",fj="";let C1=null,k1=null;function N9e(t=[]){const e={};ps.groups=e;const n=new ps;C1==null&&(C1=MG(g9e)),k1==null&&(k1=MG(x9e)),Ct(n,"'",c2),Ct(n,"{",Jb),Ct(n,"}",e0),Ct(n,"[",KS),Ct(n,"]",XS),Ct(n,"(",YS),Ct(n,")",QS),Ct(n,"<",ZS),Ct(n,">",JS),Ct(n,"(",e2),Ct(n,")",t2),Ct(n,"「",n2),Ct(n,"」",r2),Ct(n,"『",i2),Ct(n,"』",a2),Ct(n,"<",s2),Ct(n,">",o2),Ct(n,"&",l2),Ct(n,"*",u2),Ct(n,"@",fd),Ct(n,"`",h2),Ct(n,"^",f2),Ct(n,":",yd),Ct(n,",",EL),Ct(n,"$",m2),Ct(n,".",Nl),Ct(n,"=",p2),Ct(n,"!",TL),Ct(n,"-",go),Ct(n,"%",t0),Ct(n,"|",g2),Ct(n,"+",x2),Ct(n,"#",b2),Ct(n,"?",n0),Ct(n,'"',AL),Ct(n,"/",Ml),Ct(n,";",CL),Ct(n,"~",r0),Ct(n,"_",y2),Ct(n,"\\",d2),Ct(n,"・",yne);const r=Zr(n,Pc,NL,{[CR]:!0});Zr(r,Pc,r);const i=Zr(r,jc,xne,{[Zb]:!0}),a=Zr(r,_b,bne,{[Ob]:!0}),o=Zr(n,jc,Lc,{[kR]:!0});Zr(o,Pc,i),Zr(o,jc,o),Zr(i,Pc,i),Zr(i,jc,i);const l=Zr(n,_b,RR,{[jR]:!0});Zr(l,jc),Zr(l,Pc,a),Zr(l,_b,l),Zr(a,Pc,a),Zr(a,jc),Zr(a,_b,a);const c=Ct(n,hj,ML,{[cj]:!0}),u=Ct(n,NG,LR,{[cj]:!0}),d=Zr(n,dj,LR,{[cj]:!0});Ct(n,fj,d),Ct(u,hj,c),Ct(u,fj,d),Zr(u,dj,d),Ct(d,NG),Ct(d,hj),Zr(d,dj,d),Ct(d,fj,d);const f=Zr(n,uj,vne,{[gne]:!0});Ct(f,"#"),Zr(f,uj,f),Ct(f,w9e,f);const m=Ct(f,S9e);Ct(m,"#"),Zr(m,uj,f);const p=[[jc,o],[Pc,i]],x=[[jc,null],[_b,l],[Pc,a]];for(let y=0;y<C1.length;y++)ad(n,C1[y],DR,Lc,p);for(let y=0;y<k1.length;y++)ad(n,k1[y],OR,RR,x);lf(DR,{tld:!0,ascii:!0},e),lf(OR,{utld:!0,alpha:!0},e),ad(n,"file",ow,Lc,p),ad(n,"mailto",ow,Lc,p),ad(n,"http",Dp,Lc,p),ad(n,"https",Dp,Lc,p),ad(n,"ftp",Dp,Lc,p),ad(n,"ftps",Dp,Lc,p),lf(ow,{scheme:!0,ascii:!0},e),lf(Dp,{slashscheme:!0,ascii:!0},e),t=t.sort((y,b)=>y[0]>b[0]?1:-1);for(let y=0;y<t.length;y++){const b=t[y][0],N=t[y][1]?{[b9e]:!0}:{[y9e]:!0};b.indexOf("-")>=0?N[PR]=!0:jc.test(b)?Pc.test(b)?N[Zb]=!0:N[kR]=!0:N[CR]=!0,SG(n,b,b,N)}return SG(n,"localhost",Q0,{ascii:!0}),n.jd=new ps(v2),{start:n,tokens:Object.assign({groups:e},_ne)}}function wne(t,e){const n=M9e(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,m=-1;for(;o<r&&(c=l.go(n[o]));)l=c,l.accepts()?(f=0,m=0,d=l):f>=0&&(f+=n[o].length,m++),u+=n[o].length,a+=n[o].length,o++;a-=f,o-=m,u-=f,i.push({t:d.t,v:e.slice(a-u,a),s:a-u,e:a})}return i}function M9e(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 ad(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 ps(r),a.jr=i.slice(),t.j[c]=a),t=a}return a=new ps(n),a.jr=i.slice(),t.j[e[o-1]]=a,a}function MG(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 Z0={defaultProtocol:"http",events:null,format:EG,formatHref:EG,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function kL(t,e=null){let n=Object.assign({},Z0);t&&(n=Object.assign(n,t instanceof kL?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}kL.prototype={o:Z0,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]:Z0[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 EG(t){return t}function Sne(t,e){this.t="token",this.v=t,this.tk=e}Sne.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=Z0.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 uM(t,e){class n extends Sne{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 TG=uM("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),AG=uM("text"),E9e=uM("nl"),j1=uM("url",{isLink:!0,toHref(t=Z0.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==Q0&&t[1].t===yd}}),fo=t=>new ps(t);function T9e({groups:t}){const e=t.domain.concat([l2,u2,fd,d2,h2,f2,m2,p2,go,NL,t0,g2,x2,b2,Ml,v2,r0,y2]),n=[c2,yd,EL,Nl,TL,t0,n0,AL,CL,ZS,JS,Jb,e0,XS,KS,YS,QS,e2,t2,n2,r2,i2,a2,s2,o2],r=[l2,c2,u2,d2,h2,f2,m2,p2,go,Jb,e0,t0,g2,x2,b2,n0,Ml,v2,r0,y2],i=fo(),a=Ct(i,r0);wn(a,r,a),wn(a,t.domain,a);const o=fo(),l=fo(),c=fo();wn(i,t.domain,o),wn(i,t.scheme,l),wn(i,t.slashscheme,c),wn(o,r,a),wn(o,t.domain,o);const u=Ct(o,fd);Ct(a,fd,u),Ct(l,fd,u),Ct(c,fd,u);const d=Ct(a,Nl);wn(d,r,a),wn(d,t.domain,a);const f=fo();wn(u,t.domain,f),wn(f,t.domain,f);const m=Ct(f,Nl);wn(m,t.domain,f);const p=fo(TG);wn(m,t.tld,p),wn(m,t.utld,p),Ct(u,Q0,p);const x=Ct(f,go);Ct(x,go,x),wn(x,t.domain,f),wn(p,t.domain,f),Ct(p,Nl,m),Ct(p,go,x);const y=Ct(p,yd);wn(y,t.numeric,TG);const b=Ct(o,go),v=Ct(o,Nl);Ct(b,go,b),wn(b,t.domain,o),wn(v,r,a),wn(v,t.domain,o);const N=fo(j1);wn(v,t.tld,N),wn(v,t.utld,N),wn(N,t.domain,o),wn(N,r,a),Ct(N,Nl,v),Ct(N,go,b),Ct(N,fd,u);const S=Ct(N,yd),T=fo(j1);wn(S,t.numeric,T);const E=fo(j1),C=fo();wn(E,e,E),wn(E,n,C),wn(C,e,E),wn(C,n,C),Ct(N,Ml,E),Ct(T,Ml,E);const A=Ct(l,yd),O=Ct(c,yd),k=Ct(O,Ml),R=Ct(k,Ml);wn(l,t.domain,o),Ct(l,Nl,v),Ct(l,go,b),wn(c,t.domain,o),Ct(c,Nl,v),Ct(c,go,b),wn(A,t.domain,E),Ct(A,Ml,E),Ct(A,n0,E),wn(R,t.domain,E),wn(R,e,E),Ct(R,Ml,E);const F=[[Jb,e0],[KS,XS],[YS,QS],[ZS,JS],[e2,t2],[n2,r2],[i2,a2],[s2,o2]];for(let L=0;L<F.length;L++){const[K,j]=F[L],W=Ct(E,K);Ct(C,K,W),Ct(W,j,E);const Y=fo(j1);wn(W,e,Y);const q=fo();wn(W,n),wn(Y,e,Y),wn(Y,n,q),wn(q,e,Y),wn(q,n,q),Ct(Y,j,E),Ct(q,j,E)}return Ct(i,Q0,N),Ct(i,ML,E9e),{start:i,tokens:_ne}}function A9e(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,m=-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()?(m=0,f=l):m>=0&&m++,i++,d++;if(m<0)i-=d,i<r&&(o.push(n[i]),i++);else{o.length>0&&(a.push(mj(AG,e,o)),o=[]),i-=m,d-=m;const p=f.t,x=n.slice(i-d,i);a.push(mj(p,e,x))}}return o.length>0&&a.push(mj(AG,e,o)),a}function mj(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 C9e=typeof console<"u"&&console&&console.warn||(()=>{}),k9e="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",kr={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function j9e(){return ps.groups={},kr.scanner=null,kr.parser=null,kr.tokenQueue=[],kr.pluginQueue=[],kr.customSchemes=[],kr.initialized=!1,kr}function CG(t,e=!1){if(kr.initialized&&C9e(`linkifyjs: already initialized - will not register custom scheme "${t}" ${k9e}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error(`linkifyjs: incorrect scheme format.
  8246. 1. Must only contain digits, lowercase ASCII letters or "-"
  8247. 2. Cannot start or end with "-"
  8248. 3. "-" cannot repeat`);kr.customSchemes.push([t,e])}function P9e(){kr.scanner=N9e(kr.customSchemes);for(let t=0;t<kr.tokenQueue.length;t++)kr.tokenQueue[t][1]({scanner:kr.scanner});kr.parser=T9e(kr.scanner.tokens);for(let t=0;t<kr.pluginQueue.length;t++)kr.pluginQueue[t][1]({scanner:kr.scanner,parser:kr.parser});return kr.initialized=!0,kr}function jL(t){return kr.initialized||P9e(),A9e(kr.parser.start,t,wne(kr.scanner.start,t))}jL.scan=wne;function Nne(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 kL(n),i=jL(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 PL="[\0-   ᠎ -\u2029  ]",R9e=new RegExp(PL),D9e=new RegExp(`${PL}$`),O9e=new RegExp(PL,"g");function L9e(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function I9e(t){return new Kr({key:new $i("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=Vte(n.doc,[...e]);if(Qte(l).forEach(({newRange:u})=>{const d=wVe(r.doc,u,p=>p.isTextblock);let f,m;if(d.length>1)f=d[0],m=r.doc.textBetween(f.pos,f.pos+f.node.nodeSize,void 0," ");else if(d.length){const p=r.doc.textBetween(u.from,u.to," "," ");if(!D9e.test(p))return;f=d[0],m=r.doc.textBetween(f.pos,u.to,void 0," ")}if(f&&m){const p=m.split(R9e).filter(Boolean);if(p.length<=0)return!1;const x=p[p.length-1],y=f.pos+m.lastIndexOf(x);if(!x)return!1;const b=jL(x).map(v=>v.toObject(t.defaultProtocol));if(!L9e(b))return!1;b.filter(v=>v.isLink).map(v=>({...v,from:y+v.start+1,to:y+v.end+1})).filter(v=>r.schema.marks.code?!r.doc.rangeHasMark(v.from,v.to,r.schema.marks.code):!0).filter(v=>t.validate(v.value)).filter(v=>t.shouldAutoLink(v.value)).forEach(v=>{yL(v.from,v.to,r.doc).some(N=>N.mark.type===t.type)||o.addMark(v.from,v.to,t.type.create({href:v.href}))})}}),!!o.steps.length)return o}})}function F9e(t){return new Kr({key:new $i("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(m=>m.nodeName==="A")}if(!o)return!1;const l=Yte(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 U9e(t){return new Kr({key:new $i("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=Nne(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 Uh(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(O9e,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var Mne=uh.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"){CG(t);return}CG(t.scheme,t.optionalSlashes)})},onDestroy(){j9e()},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)=>!!Uh(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=>!!Uh(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=>!!Uh(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",ai(this.options.HTMLAttributes,t),0]:["a",ai(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=>!!Uh(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=>!!Uh(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[Yf({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options,i=Nne(t).filter(a=>a.isLink&&this.options.isAllowedUri(a.value,{defaultValidate:o=>!!Uh(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(I9e({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:i=>!!Uh(i,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&t.push(F9e({type:this.type,editor:this.editor,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(U9e({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),z9e=Mne,B9e=Object.defineProperty,$9e=(t,e)=>{for(var n in e)B9e(t,n,{get:e[n],enumerable:!0})},H9e="listItem",kG="textStyle",jG=/^\s*([-+*])\s$/,Ene=Ns.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",ai(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>t.type!=="list"||t.ordered?[]:{type:"bulletList",content:t.items?e.parseChildren(t.items):[]},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
  8249. `):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(H9e,this.editor.getAttributes(kG)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=Pg({find:jG,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Pg({find:jG,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(kG),editor:this.editor})),[t]}}),Tne=Ns.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",ai(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)=>SL(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)}}}),V9e={};$9e(V9e,{findListItemPos:()=>By,getNextListDepth:()=>RL,handleBackspace:()=>IR,handleDelete:()=>FR,hasListBefore:()=>Ane,hasListItemAfter:()=>G9e,hasListItemBefore:()=>Cne,listItemHasSubList:()=>kne,nextListIsDeeper:()=>jne,nextListIsHigher:()=>Pne});var By=(t,e)=>{const{$from:n}=e.selection,r=Ei(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}},RL=(t,e)=>{const n=By(t,e);if(!n)return!1;const[,r]=PVe(e,t,n.$pos.pos+4);return r},Ane=(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))},Cne=(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)},kne=(t,e,n)=>{if(!n)return!1;const r=Ei(t,e.schema);let i=!1;return n.descendants(a=>{a.type===r&&(i=!0)}),i},IR=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!th(t.state,e)&&Ane(t.state,e,n)){const{$anchor:l}=t.state.selection,c=t.state.doc.resolve(l.before()-1),u=[];c.node().descendants((m,p)=>{m.type.name===e&&u.push({node:m,pos:p})});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(!th(t.state,e)||!LVe(t.state))return!1;const r=By(e,t.state);if(!r)return!1;const a=t.state.doc.resolve(r.$pos.pos-2).node(r.depth),o=kne(e,t.state,a);return Cne(e,t.state)&&!o?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},jne=(t,e)=>{const n=RL(t,e),r=By(t,e);return!r||!n?!1:n>r.depth},Pne=(t,e)=>{const n=RL(t,e),r=By(t,e);return!r||!n?!1:n<r.depth},FR=(t,e)=>{if(!th(t.state,e)||!OVe(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:i}=n;return!n.empty&&r.sameParent(i)?!1:jne(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():Pne(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},G9e=(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)},Rne=br.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&&FR(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&&FR(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&&IR(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&&IR(t,n,r)&&(e=!0)}),e}}}}),PG=/^(\s*)(\d+)\.\s+(.*)$/,W9e=/^\s/;function q9e(t){const e=[];let n=0,r=0;for(;n<t.length;){const i=t[n],a=i.match(PG);if(!a)break;const[,o,l,c]=a,u=o.length;let d=c,f=n+1;const m=[i];for(;f<t.length;){const p=t[f];if(p.match(PG))break;if(p.trim()==="")m.push(p),d+=`
  8250. `,f+=1;else if(p.match(W9e))m.push(p),d+=`
  8251. ${p.slice(u+2)}`,f+=1;else break}e.push({indent:u,number:parseInt(l,10),content:d.trim(),raw:m.join(`
  8252. `)}),r=f,n=f}return[e,r]}function Dne(t,e,n){var r;const i=[];let a=0;for(;a<t.length;){const o=t[a];if(o.indent===e){const l=o.content.split(`
  8253. `),c=((r=l[0])==null?void 0:r.trim())||"",u=[];c&&u.push({type:"paragraph",raw:c,tokens:n.inlineTokens(c)});const d=l.slice(1).join(`
  8254. `).trim();if(d){const p=n.blockTokens(d);u.push(...p)}let f=a+1;const m=[];for(;f<t.length&&t[f].indent>e;)m.push(t[f]),f+=1;if(m.length>0){const p=Math.min(...m.map(y=>y.indent)),x=Dne(m,p,n);u.push({type:"list",ordered:!0,start:m[0].number,items:x,raw:m.map(y=>y.raw).join(`
  8255. `)})}i.push({type:"list_item",raw:o.raw,tokens:u}),a=f}else a+=1}return i}function K9e(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 X9e="listItem",RG="textStyle",DG=/^(\d+)\.\s$/,One=Ns.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",ai(this.options.HTMLAttributes,n),0]:["ol",ai(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?K9e(t.items,e):[];return n!==1?{type:"orderedList",attrs:{start:n},content:r}:{type:"orderedList",content:r}},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
  8256. `):"",markdownTokenizer:{name:"orderedList",level:"block",start:t=>{const e=t.match(/^(\s*)(\d+)\.\s+/),n=e?.index;return n!==void 0?n:-1},tokenize:(t,e,n)=>{var r;const i=t.split(`
  8257. `),[a,o]=q9e(i);if(a.length===0)return;const l=Dne(a,0,n);return l.length===0?void 0:{type:"list",ordered:!0,start:((r=a[0])==null?void 0:r.number)||1,items:l,raw:i.slice(0,o).join(`
  8258. `)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(X9e,this.editor.getAttributes(RG)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=Pg({find:DG,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=Pg({find:DG,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(RG)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),Y9e=/^\s*(\[([( |x])?\])\s$/,Q9e=Ns.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",ai(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 SL(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,m;l.ariaLabel=((m=(f=this.options.a11y)==null?void 0:f.checkboxLabel)==null?void 0:m.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:m})=>{const p=n();if(typeof p!="number")return!1;const x=m.doc.nodeAt(p);return m.setNodeMarkup(p,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[Pg({find:Y9e,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),Z9e=Ns.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",ai(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},parseMarkdown:(t,e)=>e.createNode("taskList",{},e.parseChildren(t.items||[])),renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
  8259. `):"",markdownTokenizer:{name:"taskList",level:"block",start(t){var e;const n=(e=t.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:e.index;return n!==void 0?n:-1},tokenize(t,e,n){const r=a=>{const o=TR(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=TR(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()}}});br.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(Ene.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(Tne.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(Rne.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(One.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(Q9e.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(Z9e.configure(this.options.taskList)),t}});var J9e=Ns.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",ai(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()}}}),eGe=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,tGe=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,nGe=uh.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",ai(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[jg({find:eGe,type:this.type})]},addPasteRules(){return[Yf({find:tGe,type:this.type})]}}),rGe=Ns.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),Lne=uh.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",ai(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()}}}),iGe=Lne;function aGe(t={}){return new Kr({view(e){return new sGe(e,t)}})}class sGe{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,m=e.nodeAfter;if(f||m){let p=this.editorView.nodeDOM(this.cursorPos-(f?f.nodeSize:0));if(p){let x=p.getBoundingClientRect(),y=f?x.bottom:x.top;f&&m&&(y=(y+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let b=this.width/2*l;r={left:x.left,right:x.right,top:y-b,bottom:y+b}}}}if(!r){let f=this.editorView.coordsAtPos(this.cursorPos),m=this.width/2*o;r={left:f.left-m,right:f.left+m,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(),m=f.width/c.offsetWidth,p=f.height/c.offsetHeight;u=f.left-c.scrollLeft*m,d=f.top-c.scrollTop*p}this.element.style.left=(r.left-u)/o+"px",this.element.style.top=(r.top-d)/l+"px",this.element.style.width=(r.right-r.left)/o+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),i=r&&r.type.spec.disableDropCursor,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=Lee(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 ti extends En{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return ti.valid(r)?new ti(r):En.near(r)}content(){return Ut.empty}eq(e){return e instanceof ti&&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 ti(e.resolve(n.pos))}getBookmark(){return new DL(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!oGe(e)||!lGe(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&&ti.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(ti.valid(c))return c}for(;;){let o=n>0?a.firstChild:a.lastChild;if(!o){if(a.isAtom&&!a.isText&&!tn.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(ti.valid(l))return l}return null}}}ti.prototype.visible=!1;ti.findFrom=ti.findGapCursorFrom;En.jsonID("gapcursor",ti);class DL{constructor(e){this.pos=e}map(e){return new DL(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return ti.valid(n)?new ti(n):En.near(n)}}function Ine(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function oGe(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||Ine(i.type))return!0;if(i.inlineContent)return!1}}return!0}function lGe(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||Ine(i.type))return!0;if(i.inlineContent)return!1}}return!0}function cGe(){return new Kr({props:{decorations:fGe,createSelectionBetween(t,e,n){return e.pos==n.pos&&ti.valid(n)?new ti(n):null},handleClick:dGe,handleKeyDown:uGe,handleDOMEvents:{beforeinput:hGe}}})}const uGe=Lte({ArrowLeft:P1("horiz",-1),ArrowRight:P1("horiz",1),ArrowUp:P1("vert",-1),ArrowDown:P1("vert",1)});function P1(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 hn){if(!a.endOfTextblock(n)||l.depth==0)return!1;c=!1,l=r.doc.resolve(e>0?l.after():l.before())}let u=ti.findGapCursorFrom(l,e,c);return u?(i&&i(r.tr.setSelection(new ti(u))),!0):!1}}function dGe(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!ti.valid(r))return!1;let i=t.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&tn.isSelectable(t.state.doc.nodeAt(i.inside))?!1:(t.dispatch(t.state.tr.setSelection(new ti(r))),!0)}function hGe(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof ti))return!1;let{$from:n}=t.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!r)return!1;let i=At.empty;for(let o=r.length-1;o>=0;o--)i=At.from(r[o].createAndFill(null,i));let a=t.state.tr.replace(n.pos,n.pos,new Ut(i,0,0));return a.setSelection(hn.near(a.doc.resolve(n.pos+1))),t.dispatch(a),!1}function fGe(t){if(!(t.selection instanceof ti))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",Vr.create(t.doc,[qa.widget(t.selection.head,e,{key:"gapcursor"})])}var _2=200,ra=function(){};ra.prototype.append=function(e){return e.length?(e=ra.from(e),!this.length&&e||e.length<_2&&this.leafAppend(e)||this.length<_2&&e.leafPrepend(this)||this.appendInner(e)):this};ra.prototype.prepend=function(e){return e.length?ra.from(e).append(this):this};ra.prototype.appendInner=function(e){return new mGe(this,e)};ra.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?ra.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};ra.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};ra.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)};ra.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};ra.from=function(e){return e instanceof ra?e:e&&e.length?new Fne(e):ra.empty};var Fne=(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<=_2)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=_2)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})(ra);ra.empty=new Fne([]);var mGe=(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})(ra);const pGe=500;class tl{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,m)=>{if(!f.step){i||(i=this.remapping(r,m+1),a=i.maps.length),a--,d.push(f);return}if(i){d.push(new El(f.map));let p=f.step.map(i.slice(a)),x;p&&o.maybeStep(p).doc&&(x=o.mapping.maps[o.mapping.maps.length-1],u.push(new El(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 tl(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]),m=new El(e.mapping.maps[d],f,n),p;(p=c&&c.merge(m))&&(m=p,d?a.pop():l=l.slice(0,l.length-1)),a.push(m),n&&(o++,n=void 0),i||(c=m)}let u=o-r.depth;return u>xGe&&(l=gGe(l,u),o-=u),new tl(l.append(a),o)}remapping(e,n){let r=new G0;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 tl(this.items.append(e.map(n=>new El(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(m=>{m.selection&&l--},i);let c=n;this.items.forEach(m=>{let p=a.getMirror(--c);if(p==null)return;o=Math.min(o,p);let x=a.maps[p];if(m.step){let y=e.steps[p].invert(e.docs[p]),b=m.selection&&m.selection.map(a.slice(c+1,p));b&&l++,r.push(new El(x,y,b))}else r.push(new El(x))},i);let u=[];for(let m=n;m<o;m++)u.push(new El(a.maps[m]));let d=this.items.slice(0,i).append(u).append(r),f=new tl(d,l);return f.emptyItemCount()>pGe&&(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 El(u.invert(),c,d),m,p=i.length-1;(m=i.length&&i[p].merge(f))?i[p]=m:i.push(f)}}else o.map&&r--},this.items.length,0),new tl(ra.from(i.reverse()),a)}}tl.empty=new tl(ra.empty,0);function gGe(t,e){let n;return t.forEach((r,i)=>{if(r.selection&&e--==0)return n=i,!1}),t.slice(n)}class El{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 El(n.getMap().invert(),n,this.selection)}}}class md{constructor(e,n,r,i,a){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=i,this.prevComposition=a}}const xGe=20;function bGe(t,e,n,r){let i=n.getMeta(Sf),a;if(i)return i.historyState;n.getMeta(_Ge)&&(t=new md(t.done,t.undone,null,0,-1));let o=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(o&&o.getMeta(Sf))return o.getMeta(Sf).redo?new md(t.done.addTransform(n,void 0,r,lw(e)),t.undone,OG(n.mapping.maps),t.prevTime,t.prevComposition):new md(t.done,t.undone.addTransform(n,void 0,r,lw(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||!yGe(n,t.prevRanges)),u=o?pj(t.prevRanges,n.mapping):OG(n.mapping.maps);return new md(t.done.addTransform(n,c?e.selection.getBookmark():void 0,r,lw(e)),tl.empty,u,n.time,l??t.prevComposition)}else return(a=n.getMeta("rebased"))?new md(t.done.rebased(n,a),t.undone.rebased(n,a),pj(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new md(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),pj(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function yGe(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 OG(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 pj(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 vGe(t,e,n){let r=lw(e),i=Sf.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 md(n?l:a.remaining,n?a.remaining:l,null,0,-1);return a.transform.setSelection(o).setMeta(Sf,{redo:n,historyState:c})}let gj=!1,LG=null;function lw(t){let e=t.plugins;if(LG!=e){gj=!1,LG=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){gj=!0;break}}return gj}const Sf=new $i("history"),_Ge=new $i("closeHistory");function wGe(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new Kr({key:Sf,state:{init(){return new md(tl.empty,tl.empty,null,0,-1)},apply(e,n,r){return bGe(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,i=r=="historyUndo"?zne:r=="historyRedo"?Bne:null;return!i||!e.editable?!1:(n.preventDefault(),i(e.state,e.dispatch))}}}})}function Une(t,e){return(n,r)=>{let i=Sf.getState(n);if(!i||(t?i.undone:i.done).eventCount==0)return!1;if(r){let a=vGe(i,n,t);a&&r(e?a.scrollIntoView():a)}return!0}}const zne=Une(!1,!0),Bne=Une(!0,!0);br.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 Kr({key:new $i("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 SGe=br.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[aGe(this.options)]}});br.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new Kr({key:new $i("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:i}=e,a=[];if(!n||!r)return Vr.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(qa.node(u,u+c.nodeSize,{class:this.options.className}))}),Vr.create(t,a)}}})]}});var NGe=br.create({name:"gapCursor",addProseMirrorPlugins(){return[cGe()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=nr(Jt(t,"allowGapCursor",n)))!=null?e:null}}});br.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new Kr({key:new $i("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&&oM(o);if((c||!this.options.showOnlyCurrent)&&u){const d=[this.options.emptyNodeClass];a&&d.push(this.options.emptyEditorClass);const f=qa.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}),Vr.create(t,i)}}})]}});br.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new Kr({key:new $i("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||Zte(n.selection)||t.view.dragging?null:Vr.create(n.doc,[qa.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function IG({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||e?.type===t}var MGe=br.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new $i(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 Kr({key:e,appendTransaction:(i,a,o)=>{const{doc:l,tr:c,schema:u}=o,d=e.getState(o),f=l.content.size,m=u.nodes[n];if(d)return c.insert(f,m.create())},state:{init:(i,a)=>{const o=a.tr.doc.lastChild;return!IG({node:o,types:r})},apply:(i,a)=>{if(!i.docChanged||i.getMeta("__uniqueIDTransaction"))return a;const o=i.doc.lastChild;return!IG({node:o,types:r})}}})]}}),EGe=br.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>zne(t,e),redo:()=>({state:t,dispatch:e})=>Bne(t,e)}},addProseMirrorPlugins(){return[wGe(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()}}}),TGe=br.create({name:"starterKit",addExtensions(){var t,e,n,r;const i=[];return this.options.bold!==!1&&i.push(e9e.configure(this.options.bold)),this.options.blockquote!==!1&&i.push(X7e.configure(this.options.blockquote)),this.options.bulletList!==!1&&i.push(Ene.configure(this.options.bulletList)),this.options.code!==!1&&i.push(r9e.configure(this.options.code)),this.options.codeBlock!==!1&&i.push(s9e.configure(this.options.codeBlock)),this.options.document!==!1&&i.push(o9e.configure(this.options.document)),this.options.dropcursor!==!1&&i.push(SGe.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&i.push(NGe.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&i.push(l9e.configure(this.options.hardBreak)),this.options.heading!==!1&&i.push(c9e.configure(this.options.heading)),this.options.undoRedo!==!1&&i.push(EGe.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&i.push(u9e.configure(this.options.horizontalRule)),this.options.italic!==!1&&i.push(p9e.configure(this.options.italic)),this.options.listItem!==!1&&i.push(Tne.configure(this.options.listItem)),this.options.listKeymap!==!1&&i.push(Rne.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&i.push(Mne.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&i.push(One.configure(this.options.orderedList)),this.options.paragraph!==!1&&i.push(J9e.configure(this.options.paragraph)),this.options.strike!==!1&&i.push(nGe.configure(this.options.strike)),this.options.text!==!1&&i.push(rGe.configure(this.options.text)),this.options.underline!==!1&&i.push(Lne.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&i.push(MGe.configure((r=this.options)==null?void 0:r.trailingNode)),i}}),AGe=TGe,CGe=br.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")}}}),kGe=CGe,jGe=20,$ne=(t,e=0)=>{const n=[];return!t.children.length||e>jGe||Array.from(t.children).forEach(r=>{r.tagName==="SPAN"?n.push(r):r.children.length&&n.push(...$ne(r,e+1))}),n},PGe=t=>{if(!t.children.length)return;const e=$ne(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}`)})},Hne=uh.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&PGe(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",ai(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}}}}),RGe=br.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()}}}),Vne=br.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()}}}),DGe=br.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()}}}),OGe=br.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()}}}),LGe=br.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()}}});br.create({name:"textStyleKit",addExtensions(){const t=[];return this.options.backgroundColor!==!1&&t.push(RGe.configure(this.options.backgroundColor)),this.options.color!==!1&&t.push(Vne.configure(this.options.color)),this.options.fontFamily!==!1&&t.push(DGe.configure(this.options.fontFamily)),this.options.fontSize!==!1&&t.push(OGe.configure(this.options.fontSize)),this.options.lineHeight!==!1&&t.push(LGe.configure(this.options.lineHeight)),this.options.textStyle!==!1&&t.push(Hne.configure(this.options.textStyle)),t}});var IGe=Vne,FGe=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,UGe=Ns.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",ai(this.options.HTMLAttributes,t)]},parseMarkdown:(t,e)=>e.createNode("image",{src:t.href,title:t.title,alt:t.text}),renderMarkdown:t=>{var e,n,r,i,a,o;const l=(n=(e=t.attrs)==null?void 0:e.src)!=null?n:"",c=(i=(r=t.attrs)==null?void 0:r.alt)!=null?i:"",u=(o=(a=t.attrs)==null?void 0:a.title)!=null?o:"";return u?`![${c}](${l} "${u}")`:`![${c}](${l})`},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||typeof document>"u"||!this.editor.isEditable)return null;const{directions:t,minWidth:e,minHeight:n,alwaysPreserveAspectRatio:r}=this.options.resize;return({node:i,getPos:a,HTMLAttributes:o})=>{const l=document.createElement("img");Object.entries(o).forEach(([d,f])=>{if(f!=null)switch(d){case"width":case"height":break;default:l.setAttribute(d,f);break}}),l.src=o.src;const c=new v7e({element:l,node:i,getPos:a,onResize:(d,f)=>{l.style.width=`${d}px`,l.style.height=`${f}px`},onCommit:(d,f)=>{const m=a();m!==void 0&&this.editor.chain().setNodeSelection(m).updateAttributes(this.name,{width:d,height:f}).run()},onUpdate:(d,f,m)=>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[fne({find:FGe,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}),zGe=UGe;function UR({content:t,onChange:e,placeholder:n}){const r=V7e({extensions:[AGe.configure({heading:!1,codeBlock:!1,code:!1}),iGe,z9e.configure({openOnClick:!1,HTMLAttributes:{target:"_blank",rel:"noopener noreferrer"}}),kGe.configure({types:["paragraph"]}),Hne,IGe,zGe.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(lde,{className:"w-4 h-4"})}),s.jsx(i,{onClick:()=>r.chain().focus().toggleUnderline().run(),isActive:r.isActive("underline"),title:"Underline",children:s.jsx(Qhe,{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(B2,{className:"w-4 h-4"})}),s.jsx(i,{onClick:()=>r.chain().focus().toggleOrderedList().run(),isActive:r.isActive("orderedList"),title:"Numbered List",children:s.jsx(sq,{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(Hhe,{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(Uhe,{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(Bhe,{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(Ug,{className:"w-4 h-4"})}),r.isActive("link")&&s.jsx(i,{onClick:()=>r.chain().focus().unsetLink().run(),title:"Remove Link",children:s.jsx(mD,{className:"w-4 h-4"})})]}),s.jsx(I7e,{editor:r})]})}function Gne({archiveId:t,archiveName:e,onClose:n}){const r=on(),[i,a]=w.useState(!1),[o,l]=w.useState(null),[c,u]=w.useState({}),{data:d,isLoading:f,error:m}=ut({queryKey:["archive-project-page",t],queryFn:()=>he.getArchiveProjectPage(t)}),p=pt({mutationFn:E=>he.updateArchiveProjectPage(t,E),onSuccess:()=>{r.invalidateQueries({queryKey:["archive-project-page",t]}),a(!1),u({})}});w.useEffect(()=>{const E=C=>{C.key==="Escape"&&(o!==null?l(null):i?v():n())};return document.addEventListener("keydown",E),()=>document.removeEventListener("keydown",E)},[o,i,n]);const x=[...d?.model_pictures||[],...d?.profile_pictures||[]],y=()=>{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)},b=()=>{p.mutate(c)},v=()=>{a(!1),u({})},N=E=>{const C=["p","br","b","strong","i","em","u","a","ul","ol","li","figure","img"],A=new DOMParser().parseFromString(E,"text/html"),O=k=>{if(k.nodeType===Node.TEXT_NODE)return k.textContent||"";if(k.nodeType===Node.ELEMENT_NODE){const R=k,F=R.tagName.toLowerCase();if(!C.includes(F))return Array.from(R.childNodes).map(O).join("");let L="";if(F==="a"&&R.getAttribute("href")){const j=R.getAttribute("href");j?.toLowerCase().startsWith("http")&&(L=` href="${j}" target="_blank" rel="noopener noreferrer"`)}if(F==="img"){const j=R.getAttribute("src");if(!j?.toLowerCase().startsWith("http"))return"";L=` src="${j}" style="max-width: 100%; height: auto;"`}const K=Array.from(R.childNodes).map(O).join("");return["br","img"].includes(F)?`<${F}${L} />`:`<${F}${L}>${K}</${F}>`}return""};return Array.from(A.body.childNodes).map(O).join("")},S=d&&(d.title||d.description||d.designer||d.profile_title||x.length>0),T=E=>{E.target===E.currentTarget&&n()};return s.jsxs("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:T,children:[s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl max-w-4xl w-full max-h-[90vh] overflow-hidden flex flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Ga,{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&&S&&s.jsxs(we,{variant:"ghost",size:"sm",onClick:y,children:[s.jsx(kf,{className:"w-4 h-4 mr-1"}),"Edit"]}),i&&s.jsxs(s.Fragment,{children:[s.jsx(we,{variant:"ghost",size:"sm",onClick:v,children:"Cancel"}),s.jsxs(we,{variant:"primary",size:"sm",onClick:b,disabled:p.isPending,children:[s.jsx(gs,{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(zt,{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"})}),m&&s.jsx("div",{className:"text-red-400 text-center py-12",children:"Failed to load project page data"}),d&&!S&&s.jsxs("div",{className:"text-bambu-gray text-center py-12",children:[s.jsx(Ga,{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&&S&&s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"space-y-4",children:[i?s.jsx("input",{type:"text",value:c.title||"",onChange:E=>u({...c,title:E.target.value}),placeholder:"Title",className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded-lg px-4 py-2 text-white text-xl font-semibold"}):d.title&&s.jsx("h3",{className:"text-xl font-semibold text-white",children:d.title}),s.jsxs("div",{className:"flex flex-wrap gap-4 text-sm",children:[i?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(e3,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",value:c.designer||"",onChange:E=>u({...c,designer:E.target.value}),placeholder:"Designer",className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1 text-white"})]}):d.designer&&s.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[s.jsx(e3,{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(Ur,{className:"w-3 h-3"})})]}),d.creation_date&&s.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[s.jsx(ri,{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(Ga,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",value:c.license||"",onChange:E=>u({...c,license:E.target.value}),placeholder:"License",className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1 text-white"})]}):d.license&&s.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[s.jsx(Ga,{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(UR,{content:c.description||"",onChange:E=>u({...c,description:E}),placeholder:"Enter description..."}):s.jsx("div",{className:"prose prose-invert prose-sm max-w-none text-bambu-gray-light",dangerouslySetInnerHTML:{__html:N(d.description||"")}})]}),(d.profile_title||d.profile_description||i)&&s.jsxs("div",{className:"space-y-2 p-4 bg-bambu-dark rounded-lg",children:[s.jsx("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide",children:"Print Profile"}),i?s.jsxs("div",{className:"space-y-2",children:[s.jsx("input",{type:"text",value:c.profile_title||"",onChange:E=>u({...c,profile_title:E.target.value}),placeholder:"Profile Title",className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-white"}),s.jsx(UR,{content:c.profile_description||"",onChange:E=>u({...c,profile_description:E}),placeholder:"Profile description..."})]}):s.jsxs(s.Fragment,{children:[d.profile_title&&s.jsx("p",{className:"text-white font-medium",children:d.profile_title}),d.profile_description&&s.jsx("div",{className:"prose prose-invert prose-sm max-w-none text-bambu-gray-light",dangerouslySetInnerHTML:{__html:N(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(ay,{className:"w-4 h-4"}),"Images (",x.length,")"]}),s.jsx("div",{className:"grid grid-cols-3 sm:grid-cols-4 md:grid-cols-5 gap-2",children:x.map((E,C)=>s.jsx("button",{onClick:()=>l(C),className:"aspect-square rounded-lg overflow-hidden border border-bambu-dark-tertiary hover:border-bambu-green transition-colors",children:s.jsx("img",{src:E.url,alt:E.name,className:"w-full h-full object-cover"})},E.path))})]}),d.design_model_id&&s.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:s.jsxs("a",{href:`https://makerworld.com/en/models/${d.design_model_id}`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-bambu-green hover:underline",children:[s.jsx(Ur,{className:"w-4 h-4"}),"View on MakerWorld"]})})]})]})]}),o!==null&&x[o]&&s.jsxs("div",{className:"fixed inset-0 bg-black/90 flex items-center justify-center z-60",onClick:()=>l(null),children:[s.jsx("button",{onClick:E=>{E.stopPropagation(),l(Math.max(0,o-1))},disabled:o===0,className:"absolute left-4 p-2 bg-bambu-dark-secondary rounded-full hover:bg-bambu-dark-tertiary disabled:opacity-30",children:s.jsx(Af,{className:"w-6 h-6 text-white"})}),s.jsx("img",{src:x[o].url,alt:x[o].name,className:"max-w-[90vw] max-h-[90vh] object-contain",onClick:E=>E.stopPropagation()}),s.jsx("button",{onClick:E=>{E.stopPropagation(),l(Math.min(x.length-1,o+1))},disabled:o===x.length-1,className:"absolute right-4 p-2 bg-bambu-dark-secondary rounded-full hover:bg-bambu-dark-tertiary disabled:opacity-30",children:s.jsx(Ys,{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(zt,{className:"w-6 h-6 text-white"})}),s.jsxs("div",{className:"absolute bottom-4 text-white text-sm",children:[o+1," / ",x.length]})]})]})}const BGe=[.25,.5,.75,1,1.5,2,3,4];function Mp(t){const e=Math.floor(t/60),n=Math.floor(t%60);return`${e}:${n.toString().padStart(2,"0")}`}function $Ge({archiveId:t,timelapseSrc:e,onClose:n,onSave:r}){const{showToast:i}=Vn(),a=w.useRef(null),o=w.useRef(null),[l,c]=w.useState(!1),[u,d]=w.useState(0),[f,m]=w.useState(0),[p,x]=w.useState(0),[y,b]=w.useState(0),[v,N]=w.useState(1),[S,T]=w.useState(null),[E,C]=w.useState(null),[A,O]=w.useState(.8),[k,R]=w.useState(!1),{data:F,isLoading:L}=ut({queryKey:["timelapse-info",t],queryFn:()=>he.getTimelapseInfo(t)}),{data:K}=ut({queryKey:["timelapse-thumbnails",t],queryFn:()=>he.getTimelapseThumbnails(t,15)}),j=pt({mutationFn:()=>he.processTimelapse(t,{trimStart:p,trimEnd:y,speed:v,saveMode:"replace"},S||void 0),onSuccess:z=>{i(z.message,"success"),r?.(),n()},onError:z=>{i(z.message||"Processing failed","error")}});w.useEffect(()=>{F?.duration&&y===0&&b(F.duration)},[F?.duration,y]),w.useEffect(()=>{const z=G=>{G.key==="Escape"&&n()};return window.addEventListener("keydown",z),()=>window.removeEventListener("keydown",z)},[n]),w.useEffect(()=>{const z=a.current;if(!z)return;const G=()=>{const pe=z.currentTime;d(pe),pe>=y&&(z.currentTime=p)},ae=()=>{m(z.duration),y===0&&b(z.duration)},se=()=>c(!0),ue=()=>c(!1);return z.addEventListener("timeupdate",G),z.addEventListener("durationchange",ae),z.addEventListener("play",se),z.addEventListener("pause",ue),()=>{z.removeEventListener("timeupdate",G),z.removeEventListener("durationchange",ae),z.removeEventListener("play",se),z.removeEventListener("pause",ue)}},[p,y]),w.useEffect(()=>{const z=o.current,G=a.current;!z||!G||!E||(z.currentTime=G.currentTime,z.playbackRate=G.playbackRate,l&&!k?z.play().catch(()=>{}):z.pause())},[l,E,k]),w.useEffect(()=>{o.current&&(o.current.volume=k?0:A)},[A,k]),w.useEffect(()=>{a.current&&(a.current.playbackRate=v),o.current&&(o.current.playbackRate=v)},[v]);const W=w.useCallback(()=>{const z=a.current;z&&(l?z.pause():(z.currentTime<p&&(z.currentTime=p),z.play()))},[l,p]),Y=z=>{const G=a.current;G&&(G.currentTime=Math.max(p,Math.min(y,z)))},q=z=>{const G=z.target.files?.[0];G&&(E&&URL.revokeObjectURL(E),T(G),C(URL.createObjectURL(G)))},Q=()=>{E&&URL.revokeObjectURL(E),T(null),C(null)};w.useEffect(()=>()=>{E&&URL.revokeObjectURL(E)},[E]);const ee=y-p,re=ee/v;return L?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(dt,{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(kd,{className:"w-5 h-5 text-bambu-green"}),"Edit Timelapse"]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(we,{variant:"primary",size:"sm",onClick:()=>j.mutate(),disabled:j.isPending,children:j.isPending?s.jsxs(s.Fragment,{children:[s.jsx(dt,{className:"w-4 h-4 animate-spin"}),"Processing..."]}):s.jsxs(s.Fragment,{children:[s.jsx(gs,{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(zt,{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:W,muted:!!E}),!l&&s.jsx("button",{onClick:W,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(Po,{className:"w-8 h-8 text-white"})})}),E&&s.jsx("audio",{ref:o,src:E,loop:!0})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[s.jsx(fhe,{className:"w-4 h-4"}),s.jsx("span",{children:"Trim"}),s.jsxs("span",{className:"ml-auto",children:[Mp(p)," - ",Mp(y)," (",Mp(ee),")"]})]}),s.jsxs("div",{className:"relative h-16 bg-bambu-dark rounded-lg overflow-hidden",children:[s.jsx("div",{className:"absolute inset-0 flex",children:K?.thumbnails.map((z,G)=>s.jsx("div",{className:"flex-1 bg-cover bg-center",style:{backgroundImage:`url(data:image/jpeg;base64,${z})`}},G))}),s.jsx("div",{className:"absolute inset-y-0 left-0 bg-black/60",style:{width:`${p/f*100}%`}}),s.jsx("div",{className:"absolute inset-y-0 right-0 bg-black/60",style:{width:`${(f-y)/f*100}%`}}),s.jsx("div",{className:"absolute inset-y-0 border-2 border-bambu-green",style:{left:`${p/f*100}%`,right:`${(f-y)/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:p,onChange:z=>{const G=parseFloat(z.target.value);G<y-1&&(x(G),a.current&&a.current.currentTime<G&&(a.current.currentTime=G))},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:y,onChange:z=>{const G=parseFloat(z.target.value);G>p+1&&b(G)},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:z=>Y(parseFloat(z.target.value)),className:`w-full h-1 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer
  8260. [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3
  8261. [&::-webkit-slider-thumb]:bg-bambu-green [&::-webkit-slider-thumb]:rounded-full
  8262. [&::-webkit-slider-thumb]:cursor-pointer`}),s.jsx("div",{className:"flex items-center justify-center gap-2",children:s.jsx("button",{onClick:W,className:"p-2 bg-bambu-green hover:bg-bambu-green-dark rounded-lg transition-colors",children:l?s.jsx(hD,{className:"w-5 h-5 text-white"}):s.jsx(Po,{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(I2,{className:"w-4 h-4"}),s.jsx("span",{children:"Speed"}),s.jsxs("span",{className:"ml-auto",children:[v,"x (output: ",Mp(re),")"]})]}),s.jsx("div",{className:"flex gap-1",children:BGe.map(z=>s.jsxs("button",{onClick:()=>N(z),className:`flex-1 px-2 py-2 text-sm rounded transition-colors ${v===z?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:[z,"x"]},z))})]}),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(Qj,{className:"w-4 h-4"}),s.jsx("span",{children:"Music Overlay"})]}),S?s.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[s.jsx(Qj,{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:S.name}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[(S.size/1024/1024).toFixed(1)," MB"]})]}),s.jsx("button",{onClick:()=>R(!k),className:"p-2 hover:bg-bambu-dark-tertiary rounded transition-colors",children:k?s.jsx(sfe,{className:"w-4 h-4 text-bambu-gray"}):s.jsx(ife,{className:"w-4 h-4 text-bambu-green"})}),s.jsx("input",{type:"range",min:0,max:1,step:.1,value:A,onChange:z=>O(parseFloat(z.target.value)),className:`w-20 h-1 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer
  8263. [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3
  8264. [&::-webkit-slider-thumb]:bg-bambu-green [&::-webkit-slider-thumb]:rounded-full`}),s.jsx("button",{onClick:Q,className:"p-2 hover:bg-red-500/20 rounded transition-colors",children:s.jsx(un,{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(di,{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:q,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:"})," ",Mp(f)," @ ",F?.width,"x",F?.height]}),s.jsxs("p",{className:"text-bambu-gray",children:[s.jsx("span",{className:"text-white",children:"Output:"})," ",Mp(re)," @ ",v,"x speed",S&&" + 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(dt,{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 HGe=[.25,.5,.75,1,1.5,2,3,4];function Wne({src:t,title:e,downloadFilename:n,archiveId:r,onClose:i,onEdit:a}){const o=w.useRef(null),[l,c]=w.useState(!0),[u,d]=w.useState(1),[f,m]=w.useState(0),[p,x]=w.useState(0),[y,b]=w.useState(!1);w.useEffect(()=>{const A=o.current;A&&(A.playbackRate=u)},[u]),w.useEffect(()=>{const A=O=>{O.key==="Escape"&&i()};return window.addEventListener("keydown",A),()=>window.removeEventListener("keydown",A)},[i]),w.useEffect(()=>{const A=o.current;if(!A)return;const O=()=>m(A.currentTime),k=()=>x(A.duration),R=()=>c(!0),F=()=>c(!1);return A.addEventListener("timeupdate",O),A.addEventListener("durationchange",k),A.addEventListener("play",R),A.addEventListener("pause",F),()=>{A.removeEventListener("timeupdate",O),A.removeEventListener("durationchange",k),A.removeEventListener("play",R),A.removeEventListener("pause",F)}},[]);const v=()=>{const A=o.current;A&&(l?A.pause():A.play())},N=A=>{const O=o.current;O&&(O.currentTime=parseFloat(A.target.value))},S=()=>{const A=o.current;A&&(A.currentTime=Math.max(0,A.currentTime-5))},T=()=>{const A=o.current;A&&(A.currentTime=Math.min(p,A.currentTime+5))},E=A=>{const O=Math.floor(A/60),k=Math.floor(A%60);return`${O}:${k.toString().padStart(2,"0")}`},C=()=>{const A=document.createElement("a");A.href=t,A.download=n,A.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(kd,{className:"w-5 h-5 text-bambu-green"}),e]}),s.jsxs("div",{className:"flex items-center gap-2",children:[r&&s.jsxs(we,{variant:"secondary",size:"sm",onClick:()=>b(!0),children:[s.jsx(ia,{className:"w-4 h-4"}),"Edit"]}),s.jsxs(we,{variant:"secondary",size:"sm",onClick:C,children:[s.jsx($r,{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(zt,{className:"w-5 h-5 text-bambu-gray"})})]})]}),s.jsxs("div",{className:"p-4",children:[s.jsx("video",{ref:o,src:t,autoPlay:!0,className:"w-full rounded-lg",onClick:v}),s.jsxs("div",{className:"mt-4 space-y-3",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("span",{className:"text-xs text-bambu-gray w-12 text-right",children:E(f)}),s.jsx("input",{type:"range",min:0,max:p||100,value:f,onChange:N,className:`flex-1 h-1 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer
  8265. [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3
  8266. [&::-webkit-slider-thumb]:bg-bambu-green [&::-webkit-slider-thumb]:rounded-full
  8267. [&::-webkit-slider-thumb]:cursor-pointer`}),s.jsx("span",{className:"text-xs text-bambu-gray w-12",children:E(p)})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{onClick:S,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",title:"Skip back 5s",children:s.jsx(Nhe,{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(hD,{className:"w-5 h-5 text-white"}):s.jsx(Po,{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(m0,{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:HGe.map(A=>s.jsxs("button",{onClick:()=>d(A),className:`px-2 py-1 text-xs rounded transition-colors ${u===A?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:bg-bambu-dark-tertiary/80"}`,children:[A,"x"]},A))})]})]})]})]})]}),y&&r&&s.jsx($Ge,{archiveId:r,timelapseSrc:t,onClose:()=>b(!1),onSave:a})]})}function VGe({archiveIds:t,onClose:e}){w.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}=ut({queryKey:["archive-comparison",t],queryFn:()=>he.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(zt,{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(dt,{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(yn,{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(GGe,{comparison:n}):null}),s.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:s.jsx(we,{variant:"secondary",onClick:e,className:"w-full",children:"Close"})})]})})}function GGe({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(yn,{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(yn,{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(Ya,{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 WGe(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function qGe(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 KGe({upload:t,projects:e,onArchive:n,onDiscard:r,isArchiving:i,isDiscarding:a}){const[o,l]=w.useState(!1),[c,u]=w.useState(t.tags||""),[d,f]=w.useState(t.notes||""),[m,p]=w.useState(t.project_id),[x,y]=w.useState(!1);return s.jsx(Nt,{children:s.jsxs(Et,{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(uf,{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:WGe(t.file_size)}),s.jsx("span",{children:"·"}),s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(Kn,{className:"w-3 h-3"}),qGe(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(su,{className:"w-5 h-5"}):s.jsx(Pi,{className:"w-5 h-5"})}),s.jsx(we,{variant:"primary",size:"sm",onClick:()=>n(t.id,{tags:c,notes:d,project_id:m||void 0}),disabled:i,children:i?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsxs(s.Fragment,{children:[s.jsx(Ka,{className:"w-4 h-4"}),"Archive"]})}),s.jsx(we,{variant:"secondary",size:"sm",onClick:()=>y(!0),disabled:a,children:a?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(un,{className:"w-4 h-4 text-red-400"})})]})]}),x&&s.jsx(Bn,{title:"Discard Upload",message:`Are you sure you want to discard "${t.filename}"? This cannot be undone.`,confirmText:"Discard",variant:"danger",onConfirm:()=>{r(t.id),y(!1)},onCancel:()=>y(!1)}),o&&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:b=>u(b.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:b=>f(b.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:m||"",onChange:b=>p(b.target.value?Number(b.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(b=>s.jsx("option",{value:b.id,children:b.name},b.id))]})]})]})]})})}function XGe(){const t=on(),{showToast:e}=Vn(),[n,r]=w.useState(!1),[i,a]=w.useState(!1),[o,l]=w.useState(new Set),[c,u]=w.useState(new Set),{data:d,isLoading:f}=ut({queryKey:["pending-uploads"],queryFn:Ap.list,refetchInterval:1e4}),{data:m}=ut({queryKey:["projects"],queryFn:()=>he.getProjects()}),p=pt({mutationFn:({id:v,data:N})=>Ap.archive(v,N),onMutate:({id:v})=>{l(N=>new Set(N).add(v))},onSettled:(v,N,{id:S})=>{l(T=>{const E=new Set(T);return E.delete(S),E})},onSuccess:v=>{t.invalidateQueries({queryKey:["pending-uploads"]}),t.invalidateQueries({queryKey:["archives"]}),e(`Archived: ${v.print_name}`)},onError:v=>{e(v.message||"Failed to archive","error")}}),x=pt({mutationFn:v=>Ap.discard(v),onMutate:v=>{u(N=>new Set(N).add(v))},onSettled:(v,N,S)=>{u(T=>{const E=new Set(T);return E.delete(S),E})},onSuccess:()=>{t.invalidateQueries({queryKey:["pending-uploads"]}),e("Upload discarded")},onError:v=>{e(v.message||"Failed to discard","error")}}),y=pt({mutationFn:Ap.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")}}),b=pt({mutationFn:Ap.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(Nt,{children:s.jsx(Et,{className:"py-8 flex justify-center",children:s.jsx(dt,{className:"w-6 h-6 animate-spin text-bambu-green"})})}):!d||d.length===0?null:s.jsxs("div",{className:"mb-6",children:[s.jsxs(Nt,{className:"border-l-4 border-l-yellow-500",children:[s.jsx(Qn,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(di,{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(we,{variant:"primary",size:"sm",onClick:()=>r(!0),disabled:y.isPending,children:y.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsxs(s.Fragment,{children:[s.jsx(Ka,{className:"w-4 h-4"}),"Archive All"]})}),s.jsx(we,{variant:"secondary",size:"sm",onClick:()=>a(!0),disabled:b.isPending,children:b.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsxs(s.Fragment,{children:[s.jsx(un,{className:"w-4 h-4"}),"Discard All"]})})]})]})}),s.jsxs(Et,{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(KGe,{upload:v,projects:m||[],onArchive:(N,S)=>p.mutate({id:N,data:S}),onDiscard:N=>x.mutate(N),isArchiving:o.has(v.id),isDiscarding:c.has(v.id)},v.id))})]})]}),n&&s.jsx(Bn,{title:"Archive All Uploads",message:`Are you sure you want to archive all ${d.length} pending uploads?`,confirmText:"Archive All",onConfirm:()=>{y.mutate(),r(!1)},onCancel:()=>r(!1)}),i&&s.jsx(Bn,{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:()=>{b.mutate(),a(!1)},onCancel:()=>a(!1)})]})}function w2(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function wb(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function Qh(t){if(!t)return!1;const e=t.toLowerCase();return e.endsWith(".gcode")||e.includes(".gcode.")}function YGe({archive:t,printerName:e,isSelected:n,onSelect:r,selectionMode:i,projects:a,isHighlighted:o,timeFormat:l="system"}){o&&console.log("ArchiveCard isHighlighted=true for archive:",t.id);const c=on(),{showToast:u}=Vn(),d=yq(),[f,m]=w.useState(!1),[p,x]=w.useState(!1),[y,b]=w.useState(!1),[v,N]=w.useState(!1),[S,T]=w.useState(!1),[E,C]=w.useState(!1),[A,O]=w.useState([]),[k,R]=w.useState(!1),[F,L]=w.useState(!1),[K,j]=w.useState(!1),[W,Y]=w.useState(!1),[q,Q]=w.useState(!1),[ee,re]=w.useState(!1),[z,G]=w.useState(null),ae=w.useRef(null),se=w.useRef(null),ue=pt({mutationFn:B=>he.uploadSource3mf(t.id,B),onSuccess:B=>{c.invalidateQueries({queryKey:["archives"]}),u(`Source 3MF attached: ${B.filename}`)},onError:B=>{u(B.message||"Failed to upload source 3MF","error")}}),pe=pt({mutationFn:()=>he.deleteSource3mf(t.id),onSuccess:()=>{c.invalidateQueries({queryKey:["archives"]}),u("Source 3MF removed")},onError:B=>{u(B.message||"Failed to remove source 3MF","error")}}),ce=pt({mutationFn:B=>he.uploadF3d(t.id,B),onSuccess:B=>{c.invalidateQueries({queryKey:["archives"]}),u(`F3D attached: ${B.filename}`)},onError:B=>{u(B.message||"Failed to upload F3D","error")}}),Me=pt({mutationFn:()=>he.deleteF3d(t.id),onSuccess:()=>{c.invalidateQueries({queryKey:["archives"]}),u("F3D removed")},onError:B=>{u(B.message||"Failed to remove F3D","error")}}),me=pt({mutationFn:()=>he.scanArchiveTimelapse(t.id),onSuccess:B=>{B.status==="attached"?(c.invalidateQueries({queryKey:["archives"]}),u(`Timelapse attached: ${B.filename}`)):B.status==="exists"?u("Timelapse already attached"):B.status==="not_found"&&B.available_files&&B.available_files.length>0?(O(B.available_files),C(!0)):u(B.message||"No matching timelapse found","warning")},onError:B=>{u(B.message||"Failed to scan for timelapse","error")}}),Ee=pt({mutationFn:B=>he.selectArchiveTimelapse(t.id,B),onSuccess:B=>{c.invalidateQueries({queryKey:["archives"]}),u(`Timelapse attached: ${B.filename}`),C(!1),O([])},onError:B=>{u(B.message||"Failed to attach timelapse","error")}}),fe=pt({mutationFn:()=>he.deleteArchive(t.id),onSuccess:()=>{c.invalidateQueries({queryKey:["archives"]}),u("Archive deleted")},onError:()=>{u("Failed to delete archive","error")}}),le=pt({mutationFn:()=>he.toggleFavorite(t.id),onSuccess:B=>{c.invalidateQueries({queryKey:["archives"]}),u(B.is_favorite?"Added to favorites":"Removed from favorites")}}),{data:Be}=ut({queryKey:["archive-folders",t.id],queryFn:()=>he.getLibraryFoldersByArchive(t.id)}),V=pt({mutationFn:B=>he.updateArchive(t.id,{project_id:B}),onSuccess:()=>{c.invalidateQueries({queryKey:["archives"]}),c.invalidateQueries({queryKey:["projects"]}),u("Project updated")},onError:()=>{u("Failed to update project","error")}}),$=B=>{B.preventDefault(),G({x:B.clientX,y:B.clientY})},U=[...Qh(t.filename)?[{label:"Print",icon:s.jsx(Mr,{className:"w-4 h-4"}),onClick:()=>x(!0)},{label:"Schedule",icon:s.jsx(ri,{className:"w-4 h-4"}),onClick:()=>Y(!0)},{label:"Open in Bambu Studio",icon:s.jsx(Ur,{className:"w-4 h-4"}),onClick:()=>{const B=t.print_name||t.filename||"model",oe=`${window.location.origin}${he.getArchiveForSlicer(t.id,B)}`;Bc(oe)}}]:[{label:"Slice",icon:s.jsx(Ur,{className:"w-4 h-4"}),onClick:()=>{const B=t.print_name||t.filename||"model",oe=`${window.location.origin}${he.getArchiveForSlicer(t.id,B)}`;Bc(oe)}}],{label:t.external_url?"External Link":"View on MakerWorld",icon:s.jsx(jd,{className:"w-4 h-4"}),onClick:()=>{const B=t.external_url||t.makerworld_url;B&&window.open(B,"_blank")},disabled:!t.external_url&&!t.makerworld_url},{label:"",divider:!0,onClick:()=>{}},{label:"3D Preview",icon:s.jsx(zs,{className:"w-4 h-4"}),onClick:()=>m(!0)},{label:"View Timelapse",icon:s.jsx(kd,{className:"w-4 h-4"}),onClick:()=>T(!0),disabled:!t.timelapse_path},{label:"Scan for Timelapse",icon:s.jsx(vw,{className:"w-4 h-4"}),onClick:()=>me.mutate(),disabled:!t.printer_id||!!t.timelapse_path||me.isPending},{label:"",divider:!0,onClick:()=>{}},{label:t.source_3mf_path?"Download Source 3MF":"Upload Source 3MF",icon:s.jsx(xw,{className:"w-4 h-4"}),onClick:()=>{if(t.source_3mf_path){const B=document.createElement("a");B.href=he.getSource3mfDownloadUrl(t.id),B.download=`${t.print_name||t.filename}_source.3mf`,B.click()}else ae.current?.click()}},...t.source_3mf_path?[{label:"Replace Source 3MF",icon:s.jsx(di,{className:"w-4 h-4"}),onClick:()=>ae.current?.click()},{label:"Remove Source 3MF",icon:s.jsx(un,{className:"w-4 h-4"}),onClick:()=>Q(!0),danger:!0}]:[],{label:t.f3d_path?"Replace F3D":"Upload F3D",icon:s.jsx(zs,{className:"w-4 h-4"}),onClick:()=>se.current?.click()},...t.f3d_path?[{label:"Download F3D",icon:s.jsx($r,{className:"w-4 h-4"}),onClick:()=>{const B=document.createElement("a");B.href=he.getF3dDownloadUrl(t.id),B.download=`${t.print_name||t.filename}.f3d`,B.click()}},{label:"Remove F3D",icon:s.jsx(un,{className:"w-4 h-4"}),onClick:()=>re(!0),danger:!0}]:[],{label:"",divider:!0,onClick:()=>{}},{label:"Download",icon:s.jsx($r,{className:"w-4 h-4"}),onClick:()=>{const B=document.createElement("a");B.href=he.getArchiveDownload(t.id),B.download=`${t.print_name||t.filename}.3mf`,B.click()}},{label:"Copy Download Link",icon:s.jsx(ol,{className:"w-4 h-4"}),onClick:()=>{const B=`${window.location.origin}${he.getArchiveDownload(t.id)}`;navigator.clipboard.writeText(B).then(()=>{u("Link copied to clipboard")}).catch(()=>{u("Failed to copy link","error")})}},{label:"QR Code",icon:s.jsx(uq,{className:"w-4 h-4"}),onClick:()=>R(!0)},{label:`View Photos${t.photos?.length?` (${t.photos.length})`:""}`,icon:s.jsx(Tf,{className:"w-4 h-4"}),onClick:()=>L(!0),disabled:!t.photos?.length},{label:"Project Page",icon:s.jsx(Ga,{className:"w-4 h-4"}),onClick:()=>j(!0)},{label:"",divider:!0,onClick:()=>{}},{label:t.is_favorite?"Remove from Favorites":"Add to Favorites",icon:s.jsx(jf,{className:`w-4 h-4 ${t.is_favorite?"fill-yellow-400 text-yellow-400":""}`}),onClick:()=>le.mutate()},{label:"Edit",icon:s.jsx(ia,{className:"w-4 h-4"}),onClick:()=>N(!0)},...t.project_id&&t.project_name?[{label:`Go to Project: ${t.project_name}`,icon:s.jsx(wa,{className:"w-4 h-4 text-bambu-green"}),onClick:()=>window.location.href="/projects"}]:[],{label:"Add to Project",icon:s.jsx(wa,{className:"w-4 h-4"}),onClick:()=>{},submenu:(()=>{const B=[];if(t.project_id&&B.push({label:"Remove from Project",icon:s.jsx(zt,{className:"w-4 h-4"}),onClick:()=>V.mutate(null)}),!a)B.push({label:"Loading...",icon:s.jsx(dt,{className:"w-4 h-4 animate-spin"}),onClick:()=>{},disabled:!0});else{const oe=a.filter(Te=>Te.status==="active");oe.length===0?B.push({label:"No projects available",icon:s.jsx(wa,{className:"w-4 h-4 opacity-50"}),onClick:()=>{},disabled:!0}):oe.forEach(Te=>{B.push({label:Te.name,icon:s.jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:Te.color||"#888"}}),onClick:()=>V.mutate(Te.id),disabled:t.project_id===Te.id})})}return B})()},{label:n?"Deselect":"Select",icon:n?s.jsx(Ro,{className:"w-4 h-4"}):s.jsx(Do,{className:"w-4 h-4"}),onClick:()=>r(t.id)},{label:"",divider:!0,onClick:()=>{}},{label:"Delete",icon:s.jsx(un,{className:"w-4 h-4"}),onClick:()=>b(!0),danger:!0}];return s.jsxs(Nt,{"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:$,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:B=>{B.stopPropagation(),r(t.id)},children:n?s.jsx(Ro,{className:"w-5 h-5 text-bambu-green"}):s.jsx(Do,{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",children:[t.thumbnail_path?s.jsx("img",{src:he.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(ay,{className:"w-12 h-12 text-bambu-dark-tertiary"})}),s.jsx("button",{className:`absolute top-2 left-2 p-1.5 rounded bg-black/50 hover:bg-black/70 transition-all ${d?"opacity-100":"opacity-0 group-hover:opacity-100"} ${i?"left-10":""}`,onClick:B=>{B.stopPropagation();const oe=B.currentTarget.getBoundingClientRect();G({x:oe.left,y:oe.bottom+4})},title:"Right-click for more options",children:s.jsx(Cd,{className:"w-5 h-5 text-white"})}),s.jsx("button",{className:"absolute top-2 right-2 p-1 rounded bg-black/50 hover:bg-black/70 transition-colors",onClick:B=>{B.stopPropagation(),le.mutate()},title:t.is_favorite?"Remove from favorites":"Add to favorites",children:s.jsx(jf,{className:`w-5 h-5 ${t.is_favorite?"text-yellow-400 fill-yellow-400":"text-white"}`})}),(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"?"cancelled":"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:"This model has been printed before",children:[s.jsx(ol,{className:"w-3 h-3"}),"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:B=>{B.stopPropagation();const oe=(t.print_name||t.filename||"source").replace(/\.gcode\.3mf$/i,"")+"_source",Te=`${window.location.origin}${he.getSource3mfForSlicer(t.id,oe)}`;Bc(Te)},title:"Open source 3MF in Bambu Studio (right-click for more options)",children:s.jsx(xw,{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:B=>{B.stopPropagation(),window.location.href=he.getF3dDownloadUrl(t.id)},title:"Download Fusion 360 design file",children:s.jsx(zs,{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:B=>{B.stopPropagation(),T(!0)},title:"View timelapse",children:s.jsx(kd,{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:B=>{B.stopPropagation(),L(!0)},title:`View ${t.photos.length} photo${t.photos.length>1?"s":""}`,children:[s.jsx(Tf,{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})]}),Be&&Be.length>0&&s.jsx(fs,{to:`/files?folder=${Be[0].id}`,className:"absolute bottom-2 p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors",onClick:B=>B.stopPropagation(),title:`Open folder: ${Be[0].name}`,style:{left:t.source_3mf_path?t.f3d_path?"5.5rem":"3rem":t.f3d_path?"3rem":"0.5rem"},children:s.jsx(ll,{className:"w-4 h-4 text-yellow-400"})})]}),s.jsxs(Et,{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 ${Qh(t.filename)?"bg-bambu-green/20 text-bambu-green":"bg-orange-500/20 text-orange-400"}`,title:Qh(t.filename)?"Sliced file - ready to print":"Source file only - no AMS mapping available",children:Qh(t.filename)?"GCODE":"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(B=>B.id===t.project_id)?.color||"#6b7280"}20`,color:a?.find(B=>B.id===t.project_id)?.color||"#6b7280"},title:`Project: ${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: ${wb(t.print_time_seconds||0)}
  8268. Actual: ${wb(t.actual_time_seconds||0)}
  8269. Accuracy: ${t.time_accuracy.toFixed(0)}%`:t.actual_time_seconds?`Actual: ${wb(t.actual_time_seconds)}`:`Estimated: ${wb(t.print_time_seconds||0)}`,children:[s.jsx(Kn,{className:"w-3 h-3"}),wb(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(zl,{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(cl,{className:"w-3 h-3"}),t.total_layers&&s.jsxs("span",{children:[t.total_layers," 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} object${t.object_count>1?"s":""}`,children:[s.jsx(zs,{className:"w-3 h-3"}),t.object_count," object",t.object_count>1?"s":""]}),t.sliced_for_model&&s.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",title:`Sliced for ${t.sliced_for_model}`,children:[s.jsx(Mr,{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((B,oe)=>s.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:B},title:B},oe))})]})]}),(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(hq,{className:"w-3 h-3"})}),t.tags?.split(",").map((B,oe)=>s.jsx("span",{className:"px-1.5 py-0.5 bg-bambu-dark-tertiary text-bambu-gray-light rounded text-xs",children:B.trim()},oe))]}),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:og(t.created_at,l)}),s.jsx("span",{children:w2(t.file_size)})]}),s.jsxs("div",{className:"flex gap-1 mt-3",children:[Qh(t.filename)?s.jsxs(s.Fragment,{children:[s.jsxs(we,{variant:"primary",size:"sm",className:"flex-1 min-w-0",onClick:()=>x(!0),children:[s.jsx(Mr,{className:"w-3 h-3 flex-shrink-0"}),s.jsx("span",{className:"hidden sm:inline",children:"Reprint"})]}),s.jsx(we,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const B=t.print_name||t.filename||"model",oe=`${window.location.origin}${he.getArchiveForSlicer(t.id,B)}`;Bc(oe)},title:"Open in Bambu Studio",children:s.jsx(Ur,{className:"w-3 h-3 sm:w-4 sm:h-4"})})]}):s.jsxs(we,{variant:"primary",size:"sm",className:"flex-1 min-w-0",onClick:()=>{const B=t.print_name||t.filename||"model",oe=`${window.location.origin}${he.getArchiveForSlicer(t.id,B)}`;Bc(oe)},title:"Open in Bambu Studio to slice",children:[s.jsx(Ur,{className:"w-3 h-3 flex-shrink-0"}),s.jsx("span",{className:"hidden sm:inline",children:"Slice"})]}),s.jsx(we,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const B=t.external_url||t.makerworld_url;B&&window.open(B,"_blank")},disabled:!t.external_url&&!t.makerworld_url,title:t.external_url?"External Link":t.makerworld_url?`MakerWorld: ${t.designer||"View project"}`:"No external link",children:s.jsx(jd,{className:`w-3 h-3 sm:w-4 sm:h-4 ${!t.external_url&&!t.makerworld_url?"opacity-20":""}`})}),s.jsx(we,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>m(!0),title:"3D Preview",children:s.jsx(zs,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),s.jsx(we,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const B=document.createElement("a");B.href=he.getArchiveDownload(t.id),B.download=`${t.print_name||t.filename}.3mf`,B.click()},title:"Download",children:s.jsx($r,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),s.jsx(we,{variant:"ghost",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>N(!0),title:"Edit",children:s.jsx(ia,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),s.jsx(we,{variant:"ghost",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>b(!0),title:"Delete",children:s.jsx(un,{className:"w-3 h-3 sm:w-4 sm:h-4 text-red-400"})})]})]}),v&&s.jsx(see,{archive:t,onClose:()=>N(!1)}),f&&s.jsx(nee,{archiveId:t.id,title:t.print_name||t.filename,onClose:()=>m(!1)}),p&&s.jsx(Jd,{mode:"reprint",archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>x(!1)}),y&&s.jsx(Bn,{title:"Delete Archive",message:`Are you sure you want to delete "${t.print_name||t.filename}"? This action cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{fe.mutate(),b(!1)},onCancel:()=>b(!1)}),q&&s.jsx(Bn,{title:"Remove Source 3MF",message:`Are you sure you want to remove the source 3MF file from "${t.print_name||t.filename}"? This will delete the original slicer project file.`,confirmText:"Remove",variant:"danger",onConfirm:()=>{pe.mutate(),Q(!1)},onCancel:()=>Q(!1)}),ee&&s.jsx(Bn,{title:"Remove F3D",message:`Are you sure you want to remove the Fusion 360 design file from "${t.print_name||t.filename}"?`,confirmText:"Remove",variant:"danger",onConfirm:()=>{Me.mutate(),re(!1)},onCancel:()=>re(!1)}),z&&s.jsx(oee,{x:z.x,y:z.y,items:U,onClose:()=>G(null)}),S&&t.timelapse_path&&s.jsx(Wne,{src:he.getArchiveTimelapse(t.id),title:`${t.print_name||t.filename} - Timelapse`,downloadFilename:`${t.print_name||t.filename}_timelapse.mp4`,archiveId:t.id,onClose:()=>T(!1),onEdit:()=>{c.invalidateQueries({queryKey:["archives"]}),T(!1)}}),E&&A.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:()=>{C(!1),O([])},className:"text-gray-400 hover:text-white p-1",children:s.jsx(zt,{className:"w-5 h-5"})})]}),s.jsx("div",{className:"overflow-y-auto flex-1 p-2",children:A.map(B=>s.jsxs("button",{onClick:()=>Ee.mutate(B.name),disabled:Ee.isPending,className:"w-full text-left p-3 rounded-lg hover:bg-gray-700 transition-colors flex items-center gap-3 disabled:opacity-50",children:[s.jsx(kd,{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:B.name}),s.jsxs("p",{className:"text-sm text-gray-400",children:[w2(B.size),B.mtime&&` • ${og(B.mtime,l)}`]})]})]},B.name))}),s.jsx("div",{className:"p-4 border-t border-gray-700",children:s.jsx(we,{variant:"secondary",onClick:()=>{C(!1),O([])},className:"w-full",children:"Cancel"})})]})}),k&&s.jsx(lee,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>R(!1)}),F&&t.photos&&t.photos.length>0&&s.jsx(cee,{archiveId:t.id,archiveName:t.print_name||t.filename,photos:t.photos,onClose:()=>L(!1),onDelete:async B=>{try{await he.deleteArchivePhoto(t.id,B),c.invalidateQueries({queryKey:["archives"]}),u("Photo deleted")}catch{u("Failed to delete photo","error")}}}),K&&s.jsx(Gne,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>j(!1)}),W&&s.jsx(Jd,{mode:"add-to-queue",archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>Y(!1)}),s.jsx("input",{ref:ae,type:"file",accept:".3mf",className:"hidden",onChange:B=>{const oe=B.target.files?.[0];oe&&ue.mutate(oe),B.target.value=""}}),s.jsx("input",{ref:se,type:"file",accept:".f3d",className:"hidden",onChange:B=>{const oe=B.target.files?.[0];oe&&ce.mutate(oe),B.target.value=""}})]})}function QGe({archive:t,printerName:e,isSelected:n,onSelect:r,selectionMode:i,projects:a,isHighlighted:o}){const l=on(),{showToast:c}=Vn(),[u,d]=w.useState(!1),[f,m]=w.useState(!1),[p,x]=w.useState(!1),[y,b]=w.useState(!1),[v,N]=w.useState(!1),[S,T]=w.useState(!1),[E,C]=w.useState(!1),[A,O]=w.useState([]),[k,R]=w.useState(!1),[F,L]=w.useState(!1),[K,j]=w.useState(!1),[W,Y]=w.useState(!1),[q,Q]=w.useState(!1),[ee,re]=w.useState(null),z=w.useRef(null),G=w.useRef(null),ae=pt({mutationFn:X=>he.uploadSource3mf(t.id,X),onSuccess:X=>{l.invalidateQueries({queryKey:["archives"]}),c(`Source 3MF attached: ${X.filename}`)},onError:X=>{c(X.message||"Failed to upload source 3MF","error")}}),se=pt({mutationFn:()=>he.deleteSource3mf(t.id),onSuccess:()=>{l.invalidateQueries({queryKey:["archives"]}),c("Source 3MF removed")},onError:X=>{c(X.message||"Failed to remove source 3MF","error")}}),ue=pt({mutationFn:X=>he.uploadF3d(t.id,X),onSuccess:X=>{l.invalidateQueries({queryKey:["archives"]}),c(`F3D attached: ${X.filename}`)},onError:X=>{c(X.message||"Failed to upload F3D","error")}}),pe=pt({mutationFn:()=>he.deleteF3d(t.id),onSuccess:()=>{l.invalidateQueries({queryKey:["archives"]}),c("F3D removed")},onError:X=>{c(X.message||"Failed to remove F3D","error")}}),ce=pt({mutationFn:()=>he.scanArchiveTimelapse(t.id),onSuccess:X=>{X.status==="attached"?(l.invalidateQueries({queryKey:["archives"]}),c(`Timelapse attached: ${X.filename}`)):X.status==="exists"?c("Timelapse already attached"):X.status==="not_found"&&X.available_files&&X.available_files.length>0?(O(X.available_files),C(!0)):c(X.message||"No matching timelapse found","warning")},onError:X=>{c(X.message||"Failed to scan for timelapse","error")}}),Me=pt({mutationFn:X=>he.selectArchiveTimelapse(t.id,X),onSuccess:X=>{l.invalidateQueries({queryKey:["archives"]}),c(`Timelapse attached: ${X.filename}`),C(!1),O([])},onError:X=>{c(X.message||"Failed to attach timelapse","error")}}),me=pt({mutationFn:()=>he.deleteArchive(t.id),onSuccess:()=>{l.invalidateQueries({queryKey:["archives"]}),c("Archive deleted")},onError:()=>{c("Failed to delete archive","error")}}),Ee=pt({mutationFn:()=>he.toggleFavorite(t.id),onSuccess:X=>{l.invalidateQueries({queryKey:["archives"]}),c(X.is_favorite?"Added to favorites":"Removed from favorites")}}),{data:fe}=ut({queryKey:["archive-folders",t.id],queryFn:()=>he.getLibraryFoldersByArchive(t.id)}),le=pt({mutationFn:X=>he.updateArchive(t.id,{project_id:X}),onSuccess:()=>{l.invalidateQueries({queryKey:["archives"]}),l.invalidateQueries({queryKey:["projects"]}),c("Project updated")},onError:()=>{c("Failed to update project","error")}}),Be=X=>{X.preventDefault(),re({x:X.clientX,y:X.clientY})},$=[...Qh(t.filename)?[{label:"Print",icon:s.jsx(Mr,{className:"w-4 h-4"}),onClick:()=>x(!0)},{label:"Schedule",icon:s.jsx(ri,{className:"w-4 h-4"}),onClick:()=>b(!0)},{label:"Open in Bambu Studio",icon:s.jsx(Ur,{className:"w-4 h-4"}),onClick:()=>{const X=t.print_name||t.filename||"model",U=`${window.location.origin}${he.getArchiveForSlicer(t.id,X)}`;Bc(U)}}]:[{label:"Slice",icon:s.jsx(Ur,{className:"w-4 h-4"}),onClick:()=>{const X=t.print_name||t.filename||"model",U=`${window.location.origin}${he.getArchiveForSlicer(t.id,X)}`;Bc(U)}}],{label:t.external_url?"External Link":"View on MakerWorld",icon:s.jsx(jd,{className:"w-4 h-4"}),onClick:()=>{const X=t.external_url||t.makerworld_url;X&&window.open(X,"_blank")},disabled:!t.external_url&&!t.makerworld_url},{label:"",divider:!0,onClick:()=>{}},{label:"3D Preview",icon:s.jsx(zs,{className:"w-4 h-4"}),onClick:()=>N(!0)},{label:"View Timelapse",icon:s.jsx(kd,{className:"w-4 h-4"}),onClick:()=>T(!0),disabled:!t.timelapse_path},{label:"Scan for Timelapse",icon:s.jsx(vw,{className:"w-4 h-4"}),onClick:()=>ce.mutate(),disabled:!t.printer_id||!!t.timelapse_path||ce.isPending},{label:"",divider:!0,onClick:()=>{}},{label:t.source_3mf_path?"Download Source 3MF":"Upload Source 3MF",icon:s.jsx(xw,{className:"w-4 h-4"}),onClick:()=>{if(t.source_3mf_path){const X=document.createElement("a");X.href=he.getSource3mfDownloadUrl(t.id),X.download=`${t.print_name||t.filename}_source.3mf`,X.click()}else z.current?.click()}},...t.source_3mf_path?[{label:"Replace Source 3MF",icon:s.jsx(di,{className:"w-4 h-4"}),onClick:()=>z.current?.click()},{label:"Remove Source 3MF",icon:s.jsx(un,{className:"w-4 h-4"}),onClick:()=>Y(!0),danger:!0}]:[],{label:t.f3d_path?"Replace F3D":"Upload F3D",icon:s.jsx(zs,{className:"w-4 h-4"}),onClick:()=>G.current?.click()},...t.f3d_path?[{label:"Download F3D",icon:s.jsx($r,{className:"w-4 h-4"}),onClick:()=>{const X=document.createElement("a");X.href=he.getF3dDownloadUrl(t.id),X.download=`${t.print_name||t.filename}.f3d`,X.click()}},{label:"Remove F3D",icon:s.jsx(un,{className:"w-4 h-4"}),onClick:()=>Q(!0),danger:!0}]:[],{label:"",divider:!0,onClick:()=>{}},{label:"Download",icon:s.jsx($r,{className:"w-4 h-4"}),onClick:()=>{const X=document.createElement("a");X.href=he.getArchiveDownload(t.id),X.download=`${t.print_name||t.filename}.3mf`,X.click()}},{label:"Copy Download Link",icon:s.jsx(ol,{className:"w-4 h-4"}),onClick:()=>{const X=`${window.location.origin}${he.getArchiveDownload(t.id)}`;navigator.clipboard.writeText(X).then(()=>{c("Link copied to clipboard")}).catch(()=>{c("Failed to copy link","error")})}},{label:"QR Code",icon:s.jsx(uq,{className:"w-4 h-4"}),onClick:()=>R(!0)},{label:`View Photos${t.photos?.length?` (${t.photos.length})`:""}`,icon:s.jsx(Tf,{className:"w-4 h-4"}),onClick:()=>L(!0),disabled:!t.photos?.length},{label:"Project Page",icon:s.jsx(Ga,{className:"w-4 h-4"}),onClick:()=>j(!0)},{label:"",divider:!0,onClick:()=>{}},{label:t.is_favorite?"Remove from Favorites":"Add to Favorites",icon:s.jsx(jf,{className:`w-4 h-4 ${t.is_favorite?"fill-yellow-400 text-yellow-400":""}`}),onClick:()=>Ee.mutate()},{label:"Edit",icon:s.jsx(ia,{className:"w-4 h-4"}),onClick:()=>d(!0)},...t.project_id&&t.project_name?[{label:`Go to Project: ${t.project_name}`,icon:s.jsx(wa,{className:"w-4 h-4 text-bambu-green"}),onClick:()=>window.location.href="/projects"}]:[],{label:"Add to Project",icon:s.jsx(wa,{className:"w-4 h-4"}),onClick:()=>{},submenu:(()=>{const X=[];if(t.project_id&&X.push({label:"Remove from Project",icon:s.jsx(zt,{className:"w-4 h-4"}),onClick:()=>le.mutate(null)}),!a)X.push({label:"Loading...",icon:s.jsx(dt,{className:"w-4 h-4 animate-spin"}),onClick:()=>{},disabled:!0});else{const U=a.filter(B=>B.status==="active");U.length===0?X.push({label:"No projects available",icon:s.jsx(wa,{className:"w-4 h-4 opacity-50"}),onClick:()=>{},disabled:!0}):U.forEach(B=>{X.push({label:B.name,icon:s.jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:B.color||"#888"}}),onClick:()=>le.mutate(B.id),disabled:t.project_id===B.id})})}return X})()},{label:n?"Deselect":"Select",icon:n?s.jsx(Ro,{className:"w-4 h-4"}):s.jsx(Do,{className:"w-4 h-4"}),onClick:()=>r(t.id)},{label:"",divider:!0,onClick:()=>{}},{label:"Delete",icon:s.jsx(un,{className:"w-4 h-4"}),onClick:()=>m(!0),danger:!0}];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:Be,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(Ro,{className:"w-4 h-4 text-bambu-green"}):s.jsx(Do,{className:"w-4 h-4 text-bambu-gray"})}),t.thumbnail_path?s.jsx("img",{src:he.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(ay,{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:"Has timelapse",children:s.jsx(kd,{className:"w-3.5 h-3.5 text-bambu-green flex-shrink-0"})}),fe&&fe.length>0&&s.jsx(fs,{to:`/files?folder=${fe[0].id}`,className:"flex-shrink-0",title:`Open folder: ${fe[0].name}`,onClick:X=>X.stopPropagation(),children:s.jsx(ll,{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:`Sliced for ${t.sliced_for_model}`,children:[s.jsx(Mr,{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((X,U)=>s.jsx("div",{className:"w-2.5 h-2.5 rounded-full border border-white/20",style:{backgroundColor:X},title:X},U))})]})]}),s.jsx("div",{className:"col-span-2 text-sm text-bambu-gray truncate",children:e}),s.jsx("div",{className:"col-span-2 text-sm text-bambu-gray",children:sg(t.created_at)}),s.jsx("div",{className:"col-span-1 text-sm text-bambu-gray",children:w2(t.file_size)}),s.jsxs("div",{className:"col-span-2 flex justify-end gap-1",children:[s.jsx(we,{variant:"ghost",size:"sm",onClick:()=>{const X=t.print_name||t.filename||"model",U=`${window.location.origin}${he.getArchiveForSlicer(t.id,X)}`;Bc(U)},title:"Open in Bambu Studio",children:s.jsx(Ur,{className:"w-4 h-4"})}),(t.external_url||t.makerworld_url)&&s.jsx(we,{variant:"ghost",size:"sm",onClick:()=>window.open(t.external_url||t.makerworld_url,"_blank"),title:t.external_url?"External Link":"MakerWorld",children:s.jsx(jd,{className:"w-4 h-4"})}),s.jsx(we,{variant:"ghost",size:"sm",onClick:()=>{const X=document.createElement("a");X.href=he.getArchiveDownload(t.id),X.download=`${t.print_name||t.filename}.3mf`,X.click()},title:"Download",children:s.jsx($r,{className:"w-4 h-4"})}),s.jsx(we,{variant:"ghost",size:"sm",onClick:()=>d(!0),title:"Edit",children:s.jsx(ia,{className:"w-4 h-4"})}),s.jsx(we,{variant:"ghost",size:"sm",onClick:()=>m(!0),title:"Delete",children:s.jsx(un,{className:"w-4 h-4 text-red-400"})}),s.jsx(we,{variant:"ghost",size:"sm",onClick:X=>{const U=X.currentTarget.getBoundingClientRect();re({x:U.left,y:U.bottom+4})},title:"More options",children:s.jsx(Cd,{className:"w-4 h-4"})})]})]}),u&&s.jsx(see,{archive:t,onClose:()=>d(!1)}),v&&s.jsx(nee,{archiveId:t.id,title:t.print_name||t.filename,onClose:()=>N(!1)}),p&&s.jsx(Jd,{mode:"reprint",archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>x(!1)}),f&&s.jsx(Bn,{title:"Delete Archive",message:`Are you sure you want to delete "${t.print_name||t.filename}"? This action cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{me.mutate(),m(!1)},onCancel:()=>m(!1)}),W&&s.jsx(Bn,{title:"Remove Source 3MF",message:`Are you sure you want to remove the source 3MF file from "${t.print_name||t.filename}"?`,confirmText:"Remove",variant:"danger",onConfirm:()=>{se.mutate(),Y(!1)},onCancel:()=>Y(!1)}),q&&s.jsx(Bn,{title:"Remove F3D",message:`Are you sure you want to remove the Fusion 360 design file from "${t.print_name||t.filename}"?`,confirmText:"Remove",variant:"danger",onConfirm:()=>{pe.mutate(),Q(!1)},onCancel:()=>Q(!1)}),ee&&s.jsx(oee,{x:ee.x,y:ee.y,items:$,onClose:()=>re(null)}),S&&t.timelapse_path&&s.jsx(Wne,{src:he.getArchiveTimelapse(t.id),title:`${t.print_name||t.filename} - Timelapse`,downloadFilename:`${t.print_name||t.filename}_timelapse.mp4`,archiveId:t.id,onClose:()=>T(!1),onEdit:()=>{l.invalidateQueries({queryKey:["archives"]}),T(!1)}}),E&&A.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:()=>{C(!1),O([])},className:"text-gray-400 hover:text-white p-1",children:s.jsx(zt,{className:"w-5 h-5"})})]}),s.jsx("div",{className:"overflow-y-auto flex-1 p-2",children:A.map(X=>s.jsxs("button",{onClick:()=>Me.mutate(X.name),disabled:Me.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:X.name}),s.jsxs("div",{className:"text-sm text-gray-400 flex gap-3",children:[s.jsx("span",{children:w2(X.size)}),X.mtime&&s.jsx("span",{children:sg(X.mtime)})]})]},X.name))})]})}),k&&s.jsx(lee,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>R(!1)}),F&&t.photos&&s.jsx(cee,{archiveId:t.id,archiveName:t.print_name||t.filename,photos:t.photos,onClose:()=>L(!1),onDelete:async X=>{try{await he.deleteArchivePhoto(t.id,X),l.invalidateQueries({queryKey:["archives"]}),c("Photo deleted")}catch{c("Failed to delete photo","error")}}}),K&&s.jsx(Gne,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>j(!1)}),y&&s.jsx(Jd,{mode:"add-to-queue",archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>b(!1)}),s.jsx("input",{ref:z,type:"file",accept:".3mf",className:"hidden",onChange:X=>{const U=X.target.files?.[0];U&&ae.mutate(U),X.target.value=""}}),s.jsx("input",{ref:G,type:"file",accept:".f3d",className:"hidden",onChange:X=>{const U=X.target.files?.[0];U&&ue.mutate(U),X.target.value=""}})]})}const ZGe=[{id:"all",label:"All Archives",icon:s.jsx(ll,{className:"w-4 h-4"})},{id:"recent",label:"Last 24 Hours",icon:s.jsx(Kn,{className:"w-4 h-4"})},{id:"this-week",label:"This Week",icon:s.jsx(ri,{className:"w-4 h-4"})},{id:"this-month",label:"This Month",icon:s.jsx(ri,{className:"w-4 h-4"})},{id:"favorites",label:"Favorites",icon:s.jsx(jf,{className:"w-4 h-4"})},{id:"failed",label:"Failed Prints",icon:s.jsx(ji,{className:"w-4 h-4"})},{id:"duplicates",label:"Duplicates",icon:s.jsx(ol,{className:"w-4 h-4"})}];function JGe(){const t=on(),{showToast:e}=Vn(),n=w.useRef(null),[r,i]=w.useState(""),[a,o]=w.useState(()=>{const ne=localStorage.getItem("archiveFilterPrinter");return ne?Number(ne):null}),[l,c]=w.useState(()=>localStorage.getItem("archiveFilterMaterial")),[u,d]=w.useState(()=>{const ne=localStorage.getItem("archiveFilterColors");return ne?new Set(JSON.parse(ne)):new Set}),[f,m]=w.useState(()=>localStorage.getItem("archiveColorFilterMode")||"or"),[p,x]=w.useState(()=>localStorage.getItem("archiveFilterFavorites")==="true"),[y,b]=w.useState(()=>localStorage.getItem("archiveHideFailed")==="true"),[v,N]=w.useState(()=>localStorage.getItem("archiveFilterTag")),[S,T]=w.useState(()=>localStorage.getItem("archiveFilterFileType")||"all"),[E,C]=w.useState(!1),[A,O]=w.useState([]),[k,R]=w.useState(!1),[F,L]=w.useState(new Set),[K,j]=w.useState(!1),[W,Y]=w.useState(!1),[q,Q]=w.useState(!1),[ee,re]=w.useState(!1),[z,G]=w.useState(()=>localStorage.getItem("archiveViewMode")||"grid"),[ae,se]=w.useState(()=>localStorage.getItem("archiveSortBy")||"date-desc"),[ue,pe]=w.useState(()=>localStorage.getItem("archiveCollection")||"all"),[ce,Me]=w.useState(!1),[me,Ee]=w.useState(!1),[fe,le]=w.useState(!1),[Be,V]=w.useState(null);w.useEffect(()=>{if(Be){const ne=setTimeout(()=>{const be=document.querySelector(`[data-archive-id="${Be}"]`);be&&be.scrollIntoView({behavior:"smooth",block:"center"})},100),Pe=setTimeout(()=>V(null),5e3);return()=>{clearTimeout(ne),clearTimeout(Pe)}}},[Be]);const{data:$,isLoading:X}=ut({queryKey:["archives",a],queryFn:()=>he.getArchives(a||void 0)}),{data:U}=ut({queryKey:["printers"],queryFn:he.getPrinters}),{data:B}=ut({queryKey:["projects"],queryFn:()=>he.getProjects()}),{data:oe}=ut({queryKey:["settings"],queryFn:he.getSettings}),Te=oe?.time_format||"system",je=pt({mutationFn:async ne=>(await Promise.all(ne.map(Pe=>he.deleteArchive(Pe))),ne.length),onSuccess:ne=>{t.invalidateQueries({queryKey:["archives"]}),L(new Set),e(`${ne} archive${ne!==1?"s":""} deleted`)},onError:()=>{e("Failed to delete archives","error")}});w.useEffect(()=>{a!==null?localStorage.setItem("archiveFilterPrinter",a.toString()):localStorage.removeItem("archiveFilterPrinter")},[a]),w.useEffect(()=>{l?localStorage.setItem("archiveFilterMaterial",l):localStorage.removeItem("archiveFilterMaterial")},[l]),w.useEffect(()=>{localStorage.setItem("archiveFilterColors",JSON.stringify([...u]))},[u]),w.useEffect(()=>{localStorage.setItem("archiveColorFilterMode",f)},[f]),w.useEffect(()=>{localStorage.setItem("archiveFilterFavorites",p.toString())},[p]),w.useEffect(()=>{localStorage.setItem("archiveHideFailed",y.toString())},[y]),w.useEffect(()=>{v?localStorage.setItem("archiveFilterTag",v):localStorage.removeItem("archiveFilterTag")},[v]),w.useEffect(()=>{localStorage.setItem("archiveFilterFileType",S)},[S]),w.useEffect(()=>{localStorage.setItem("archiveViewMode",z)},[z]),w.useEffect(()=>{localStorage.setItem("archiveSortBy",ae)},[ae]),w.useEffect(()=>{localStorage.setItem("archiveCollection",ue)},[ue]);const Ce=new Map(U?.map(ne=>[ne.id,ne.name])||[]),H=[...new Set($?.flatMap(ne=>ne.filament_type?.split(", ")||[]).filter(Boolean)||[])].sort(),D=[...new Set($?.flatMap(ne=>ne.filament_color?.split(",")||[]).filter(Boolean)||[])],Z=[...new Set($?.flatMap(ne=>ne.tags?.split(",").map(Pe=>Pe.trim())||[]).filter(Boolean)||[])].sort(),xe=$?.filter(ne=>{const Pe=new Date,be=vi(ne.created_at)||new Date(0);let Oe=!0;switch(ue){case"recent":Oe=Pe.getTime()-be.getTime()<1440*60*1e3;break;case"this-week":Oe=Pe.getTime()-be.getTime()<10080*60*1e3;break;case"this-month":Oe=be.getMonth()===Pe.getMonth()&&be.getFullYear()===Pe.getFullYear();break;case"favorites":Oe=ne.is_favorite===!0;break;case"failed":Oe=ne.status==="failed"||ne.status==="aborted";break;case"duplicates":Oe=ne.duplicate_count>0;break}const Ue=(ne.print_name||ne.filename).toLowerCase().includes(r.toLowerCase()),Ae=!l||ne.filament_type?.split(", ").includes(l),Je=ne.filament_color?.split(",")||[],gt=u.size===0||(f==="or"?Je.some(Gt=>u.has(Gt)):[...u].every(Gt=>Je.includes(Gt))),Pt=ue==="favorites"||!p||ne.is_favorite,Ot=ue==="failed"||!y||ne.status!=="failed"&&ne.status!=="aborted",cn=ne.tags?.split(",").map(Gt=>Gt.trim())||[],It=!v||cn.includes(v),_n=Qh(ne.filename);return Oe&&Ue&&Ae&&gt&&Pt&&Ot&&It&&(S==="all"||S==="gcode"&&_n||S==="source"&&!_n)}).sort((ne,Pe)=>{switch(ae){case"date-desc":return(vi(Pe.created_at)?.getTime()||0)-(vi(ne.created_at)?.getTime()||0);case"date-asc":return(vi(ne.created_at)?.getTime()||0)-(vi(Pe.created_at)?.getTime()||0);case"name-asc":return(ne.print_name||ne.filename).localeCompare(Pe.print_name||Pe.filename);case"name-desc":return(Pe.print_name||Pe.filename).localeCompare(ne.print_name||ne.filename);case"size-desc":return Pe.file_size-ne.file_size;case"size-asc":return ne.file_size-Pe.file_size;default:return 0}}),Ne=K||F.size>0,ve=ne=>{L(Pe=>{const be=new Set(Pe);return be.has(ne)?be.delete(ne):be.add(ne),be})},$e=()=>{xe&&L(new Set(xe.map(ne=>ne.id)))},Le=()=>{L(new Set),j(!1)},qe=ne=>{d(Pe=>{const be=new Set(Pe);return be.has(ne)?be.delete(ne):be.add(ne),be})},Ke=()=>{d(new Set)},Ye=()=>{i(""),o(null),c(null),x(!1),b(!1),N(null),T("all")},ie=r||a||l||p||y||v||S!=="all",te=w.useCallback(ne=>{ne.preventDefault(),ne.dataTransfer.types.includes("Files")&&R(!0)},[]),Se=w.useCallback(ne=>{ne.preventDefault(),ne.currentTarget===ne.target&&R(!1)},[]),ze=w.useCallback(ne=>{ne.preventDefault(),R(!1);const Pe=Array.from(ne.dataTransfer.files).filter(be=>be.name.endsWith(".3mf"));Pe.length>0?(O(Pe),C(!0)):ne.dataTransfer.files.length>0&&e("Only .3mf files are supported","warning")},[e]),nt=w.useCallback(ne=>{const Pe=ne.target;if(Pe.tagName==="INPUT"||Pe.tagName==="TEXTAREA"||Pe.isContentEditable){ne.key==="Escape"&&Pe.blur();return}switch(ne.key){case"/":ne.preventDefault(),n.current?.focus();break;case"u":case"U":!ne.metaKey&&!ne.ctrlKey&&(ne.preventDefault(),C(!0));break;case"Escape":Ne&&Le();break}},[Ne]);return w.useEffect(()=>(document.addEventListener("keydown",nt),()=>document.removeEventListener("keydown",nt)),[nt]),s.jsxs("div",{className:"p-4 md:p-8 relative min-h-full",onDragOver:te,onDragLeave:Se,onDrop:ze,children:[k&&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(di,{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:"Release to upload"})]})}),Ne&&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(we,{variant:"secondary",size:"sm",onClick:Le,children:[s.jsx(zt,{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:[F.size," selected"]}),s.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),s.jsx(we,{variant:"secondary",size:"sm",onClick:$e,children:"Select All"}),s.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),s.jsxs(we,{variant:"secondary",size:"sm",onClick:()=>Q(!0),children:[s.jsx(ag,{className:"w-4 h-4"}),"Tags"]}),s.jsxs(we,{variant:"secondary",size:"sm",onClick:()=>re(!0),children:[s.jsx(wa,{className:"w-4 h-4"}),"Project"]}),s.jsxs(we,{variant:"secondary",size:"sm",onClick:()=>{const ne=Array.from(F);Promise.all(ne.map(Pe=>he.toggleFavorite(Pe))).then(()=>{t.invalidateQueries({queryKey:["archives"]}),e(`Toggled favorites for ${ne.length} archive${ne.length!==1?"s":""}`)}).catch(()=>{e("Failed to update favorites","error")})},children:[s.jsx(jf,{className:"w-4 h-4"}),"Favorite"]}),s.jsxs(we,{size:"sm",className:"bg-red-500 hover:bg-red-600",onClick:()=>Y(!0),children:[s.jsx(un,{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:ue,onChange:ne=>pe(ne.target.value),children:ZGe.map(ne=>s.jsx("option",{value:ne.id,children:ne.label},ne.id))})]}),s.jsxs("p",{className:"text-bambu-gray",children:[xe?.length||0," of ",$?.length||0," prints"]})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("div",{className:"relative",children:[s.jsxs(we,{variant:"secondary",onClick:()=>Me(!ce),disabled:me,children:[me?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(bw,{className:"w-4 h-4"}),"Export"]}),ce&&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()=>{Me(!1),Ee(!0);try{const{blob:ne,filename:Pe}=await he.exportArchives({format:"csv",printerId:a||void 0,status:ue==="failed"?"failed":void 0,search:r||void 0}),be=URL.createObjectURL(ne),Oe=document.createElement("a");Oe.href=be,Oe.download=Pe,Oe.click(),URL.revokeObjectURL(be),e("Export downloaded")}catch{e("Export failed","error")}finally{Ee(!1)}},children:[s.jsx(Ga,{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()=>{Me(!1),Ee(!0);try{const{blob:ne,filename:Pe}=await he.exportArchives({format:"xlsx",printerId:a||void 0,status:ue==="failed"?"failed":void 0,search:r||void 0}),be=URL.createObjectURL(ne),Oe=document.createElement("a");Oe.href=be,Oe.download=Pe,Oe.click(),URL.revokeObjectURL(be),e("Export downloaded")}catch{e("Export failed","error")}finally{Ee(!1)}},children:[s.jsx(bw,{className:"w-4 h-4"}),"Export as Excel"]})]})]}),F.size>=2&&F.size<=5&&s.jsxs(we,{variant:"secondary",onClick:()=>le(!0),children:[s.jsx($p,{className:"w-4 h-4"}),"Compare (",F.size,")"]}),!Ne&&s.jsxs(we,{variant:"secondary",onClick:()=>j(!0),children:[s.jsx(Ro,{className:"w-4 h-4"}),"Select"]}),s.jsxs(we,{onClick:()=>C(!0),children:[s.jsx(di,{className:"w-4 h-4"}),"Upload 3MF"]})]})]}),s.jsx(Nt,{className:"mb-6",children:s.jsxs(Et,{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(_a,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),s.jsx("input",{ref:n,type:"text",placeholder:"Search archives...",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:r,onChange:ne=>i(ne.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(L2,{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:a||"",onChange:ne=>o(ne.target.value?Number(ne.target.value):null),children:[s.jsx("option",{value:"",children:"All Printers"}),U?.map(ne=>s.jsx("option",{value:ne.id,children:ne.name},ne.id))]})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx(zl,{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:l||"",onChange:ne=>c(ne.target.value||null),children:[s.jsx("option",{value:"",children:"All Materials"}),H.map(ne=>s.jsx("option",{value:ne,children:ne},ne))]})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx(xw,{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:S,onChange:ne=>T(ne.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:()=>x(!p),className:`flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors flex-shrink-0 ${p?"bg-yellow-500/20 border-yellow-500 text-yellow-400":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:p?"Show all":"Show favorites only",children:[s.jsx(jf,{className:`w-4 h-4 ${p?"fill-yellow-400":""}`}),s.jsx("span",{className:"text-sm hidden md:inline",children:"Favorites"})]}),s.jsxs("button",{onClick:()=>b(!y),className:`flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors flex-shrink-0 ${y?"bg-red-500/20 border-red-500 text-red-400":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:y?"Show failed prints":"Hide failed prints",children:[s.jsx(ji,{className:"w-4 h-4 "}),s.jsx("span",{className:"text-sm hidden md:inline",children:"Hide Failed"})]}),Z.length>0&&s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx(ag,{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:v||"",onChange:ne=>N(ne.target.value||null),children:[s.jsx("option",{value:"",children:"All Tags"}),Z.map(ne=>s.jsx("option",{value:ne,children:ne},ne))]})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx(eq,{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:ae,onChange:ne=>se(ne.target.value),children:[s.jsx("option",{value:"date-desc",children:"Newest first"}),s.jsx("option",{value:"date-asc",children:"Oldest first"}),s.jsx("option",{value:"name-asc",children:"Name A-Z"}),s.jsx("option",{value:"name-desc",children:"Name Z-A"}),s.jsx("option",{value:"size-desc",children:"Largest first"}),s.jsx("option",{value:"size-asc",children:"Smallest first"})]})]}),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 ${z==="grid"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>G("grid"),title:"Grid view",children:s.jsx(z2,{className:"w-4 h-4"})}),s.jsx("button",{className:`p-2 ${z==="list"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>G("list"),title:"List view",children:s.jsx(B2,{className:"w-4 h-4"})}),s.jsx("button",{className:`p-2 ${z==="calendar"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>G("calendar"),title:"Calendar view",children:s.jsx(kce,{className:"w-4 h-4"})})]})]}),ie&&s.jsxs(we,{variant:"ghost",size:"sm",onClick:Ye,className:"text-bambu-gray hover:text-white",children:[s.jsx(zt,{className:"w-4 h-4"}),"Reset"]})]}),D.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:"}),u.size>1&&s.jsx("button",{onClick:()=>m(ne=>ne==="or"?"and":"or"),className:`px-2 py-0.5 text-xs rounded transition-colors ${f==="and"?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:f==="or"?"Match ANY selected color":"Match ALL selected colors",children:f.toUpperCase()}),s.jsx("div",{className:"flex items-center gap-1.5 flex-wrap",children:D.map(ne=>s.jsx("button",{onClick:()=>qe(ne),className:`w-6 h-6 rounded-full border-2 transition-all ${u.has(ne)?"border-bambu-green scale-110":"border-white/20 hover:border-white/40"}`,style:{backgroundColor:ne},title:ne},ne))}),u.size>0&&s.jsxs("button",{onClick:Ke,className:"text-xs text-bambu-gray hover:text-white flex items-center gap-1",children:[s.jsx(zt,{className:"w-3 h-3"}),"Clear"]})]})]})}),s.jsx(XGe,{}),X?s.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading archives..."}):xe?.length===0?s.jsx(Nt,{children:s.jsxs(Et,{className:"text-center py-12",children:[s.jsx("p",{className:"text-bambu-gray",children:r?"No archives match your search":"No archives yet"}),s.jsx("p",{className:"text-sm text-bambu-gray mt-2",children:"Archives are created automatically when prints complete"})]})}):z==="calendar"?s.jsx(Nt,{className:"p-6",children:s.jsx(E8e,{archives:xe||[],onArchiveClick:ne=>{i(""),G("grid"),V(ne.id)},highlightedArchiveId:Be})}):z==="grid"?s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:xe?.map(ne=>s.jsx(YGe,{archive:ne,printerName:ne.printer_id?Ce.get(ne.printer_id)||"Unknown":ne.sliced_for_model?`Sliced for ${ne.sliced_for_model}`:"No Printer",isSelected:F.has(ne.id),onSelect:ve,selectionMode:Ne,projects:B,isHighlighted:ne.id===Be,timeFormat:Te},ne.id))}):z==="list"?s.jsx(Nt,{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"})]}),xe?.map(ne=>s.jsx(QGe,{archive:ne,printerName:ne.printer_id?Ce.get(ne.printer_id)||"Unknown":ne.sliced_for_model?`Sliced for ${ne.sliced_for_model}`:"No Printer",isSelected:F.has(ne.id),onSelect:ve,selectionMode:Ne,projects:B,isHighlighted:ne.id===Be},ne.id))]})}):null,E&&s.jsx(x8e,{onClose:()=>{C(!1),O([])},initialFiles:A}),W&&s.jsx(Bn,{title:"Delete Archives",message:`Are you sure you want to delete ${F.size} archive${F.size>1?"s":""}? This action cannot be undone.`,confirmText:`Delete ${F.size}`,variant:"danger",onConfirm:()=>{je.mutate(Array.from(F)),Y(!1)},onCancel:()=>Y(!1)}),q&&s.jsx(v8e,{selectedIds:Array.from(F),existingTags:Z,onClose:()=>Q(!1)}),ee&&s.jsx(_8e,{selectedIds:Array.from(F),onClose:()=>re(!1)}),fe&&F.size>=2&&F.size<=5&&s.jsx(VGe,{archiveIds:Array.from(F),onClose:()=>{le(!1),L(new Set),j(!1)}})]})}function eWe(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return w.useMemo(()=>r=>{e.forEach(i=>i(r))},e)}const dM=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function ix(t){const e=Object.prototype.toString.call(t);return e==="[object Window]"||e==="[object global]"}function OL(t){return"nodeType"in t}function Ms(t){var e,n;return t?ix(t)?t:OL(t)&&(e=(n=t.ownerDocument)==null?void 0:n.defaultView)!=null?e:window:window}function LL(t){const{Document:e}=Ms(t);return t instanceof e}function $y(t){return ix(t)?!1:t instanceof Ms(t).HTMLElement}function qne(t){return t instanceof Ms(t).SVGElement}function ax(t){return t?ix(t)?t.document:OL(t)?LL(t)?t:$y(t)||qne(t)?t.ownerDocument:document:document:document}const Xl=dM?w.useLayoutEffect:w.useEffect;function IL(t){const e=w.useRef(t);return Xl(()=>{e.current=t}),w.useCallback(function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return e.current==null?void 0:e.current(...r)},[])}function tWe(){const t=w.useRef(null),e=w.useCallback((r,i)=>{t.current=setInterval(r,i)},[]),n=w.useCallback(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[]);return[e,n]}function J0(t,e){e===void 0&&(e=[t]);const n=w.useRef(t);return Xl(()=>{n.current!==t&&(n.current=t)},e),n}function Hy(t,e){const n=w.useRef();return w.useMemo(()=>{const r=t(n.current);return n.current=r,r},[...e])}function S2(t){const e=IL(t),n=w.useRef(null),r=w.useCallback(i=>{i!==n.current&&e?.(i,n.current),n.current=i},[]);return[n,r]}function zR(t){const e=w.useRef();return w.useEffect(()=>{e.current=t},[t]),e.current}let xj={};function Vy(t,e){return w.useMemo(()=>{if(e)return e;const n=xj[t]==null?0:xj[t]+1;return xj[t]=n,t+"-"+n},[t,e])}function Kne(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 ng=Kne(1),ey=Kne(-1);function nWe(t){return"clientX"in t&&"clientY"in t}function FL(t){if(!t)return!1;const{KeyboardEvent:e}=Ms(t.target);return e&&t instanceof e}function rWe(t){if(!t)return!1;const{TouchEvent:e}=Ms(t.target);return e&&t instanceof e}function BR(t){if(rWe(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 nWe(t)?{x:t.clientX,y:t.clientY}:null}const Rg=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[Rg.Translate.toString(t),Rg.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:e,duration:n,easing:r}=t;return e+" "+n+"ms "+r}}}),FG="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function iWe(t){return t.matches(FG)?t:t.querySelector(FG)}const aWe={display:"none"};function sWe(t){let{id:e,value:n}=t;return Fr.createElement("div",{id:e,style:aWe},n)}function oWe(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 Fr.createElement("div",{id:e,style:i,role:"status","aria-live":r,"aria-atomic":!0},n)}function lWe(){const[t,e]=w.useState("");return{announce:w.useCallback(r=>{r!=null&&e(r)},[]),announcement:t}}const Xne=w.createContext(null);function cWe(t){const e=w.useContext(Xne);w.useEffect(()=>{if(!e)throw new Error("useDndMonitor must be used within a children of <DndContext>");return e(t)},[t,e])}function uWe(){const[t]=w.useState(()=>new Set),e=w.useCallback(r=>(t.add(r),()=>t.delete(r)),[t]);return[w.useCallback(r=>{let{type:i,event:a}=r;t.forEach(o=>{var l;return(l=o[i])==null?void 0:l.call(o,a)})},[t]),e]}const dWe={draggable:`
  8270. To pick up a draggable item, press the space bar.
  8271. While dragging, use the arrow keys to move the item.
  8272. Press space again to drop the item in its new position, or press escape to cancel.
  8273. `},hWe={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 fWe(t){let{announcements:e=hWe,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=dWe}=t;const{announce:a,announcement:o}=lWe(),l=Vy("DndLiveRegion"),[c,u]=w.useState(!1);if(w.useEffect(()=>{u(!0)},[]),cWe(w.useMemo(()=>({onDragStart(f){let{active:m}=f;a(e.onDragStart({active:m}))},onDragMove(f){let{active:m,over:p}=f;e.onDragMove&&a(e.onDragMove({active:m,over:p}))},onDragOver(f){let{active:m,over:p}=f;a(e.onDragOver({active:m,over:p}))},onDragEnd(f){let{active:m,over:p}=f;a(e.onDragEnd({active:m,over:p}))},onDragCancel(f){let{active:m,over:p}=f;a(e.onDragCancel({active:m,over:p}))}}),[a,e])),!c)return null;const d=Fr.createElement(Fr.Fragment,null,Fr.createElement(sWe,{id:r,value:i.draggable}),Fr.createElement(oWe,{id:l,announcement:o}));return n?Hc.createPortal(d,n):d}var ki;(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"})(ki||(ki={}));function N2(){}function M2(t,e){return w.useMemo(()=>({sensor:t,options:e??{}}),[t,e])}function Yne(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return w.useMemo(()=>[...e].filter(r=>r!=null),[...e])}const dl=Object.freeze({x:0,y:0});function Qne(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function Zne(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return n-r}function mWe(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return r-n}function UG(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 Jne(t,e){if(!t||t.length===0)return null;const[n]=t;return n[e]}function zG(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 ere=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=zG(e,e.left,e.top),a=[];for(const o of r){const{id:l}=o,c=n.get(l);if(c){const u=Qne(zG(c),i);a.push({id:l,data:{droppableContainer:o,value:u}})}}return a.sort(Zne)},pWe=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=UG(e),a=[];for(const o of r){const{id:l}=o,c=n.get(l);if(c){const u=UG(c),d=i.reduce((m,p,x)=>m+Qne(u[x],p),0),f=Number((d/4).toFixed(4));a.push({id:l,data:{droppableContainer:o,value:f}})}}return a.sort(Zne)};function gWe(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 xWe=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=gWe(l,e);c>0&&i.push({id:o,data:{droppableContainer:a,value:c}})}}return i.sort(mWe)};function bWe(t,e,n){return{...t,scaleX:e&&n?e.width/n.width:1,scaleY:e&&n?e.height/n.height:1}}function tre(t,e){return t&&e?{x:t.left-e.left,y:t.top-e.top}:dl}function yWe(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 vWe=yWe(1);function _We(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 wWe(t,e,n){const r=_We(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 SWe={ignoreTransform:!1};function sx(t,e){e===void 0&&(e=SWe);let n=t.getBoundingClientRect();if(e.ignoreTransform){const{transform:u,transformOrigin:d}=Ms(t).getComputedStyle(t);u&&(n=wWe(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 BG(t){return sx(t,{ignoreTransform:!0})}function NWe(t){const e=t.innerWidth,n=t.innerHeight;return{top:0,left:0,right:e,bottom:n,width:e,height:n}}function MWe(t,e){return e===void 0&&(e=Ms(t).getComputedStyle(t)),e.position==="fixed"}function EWe(t,e){e===void 0&&(e=Ms(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 hM(t,e){const n=[];function r(i){if(e!=null&&n.length>=e||!i)return n;if(LL(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!$y(i)||qne(i)||n.includes(i))return n;const a=Ms(t).getComputedStyle(i);return i!==t&&EWe(i,a)&&n.push(i),MWe(i,a)?n:r(i.parentNode)}return t?r(t):n}function nre(t){const[e]=hM(t,1);return e??null}function bj(t){return!dM||!t?null:ix(t)?t:OL(t)?LL(t)||t===ax(t).scrollingElement?window:$y(t)?t:null:null}function rre(t){return ix(t)?t.scrollX:t.scrollLeft}function ire(t){return ix(t)?t.scrollY:t.scrollTop}function $R(t){return{x:rre(t),y:ire(t)}}var Qi;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(Qi||(Qi={}));function are(t){return!dM||!t?!1:t===document.scrollingElement}function sre(t){const e={x:0,y:0},n=are(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 TWe={x:.2,y:.2};function AWe(t,e,n,r,i){let{top:a,left:o,right:l,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=TWe);const{isTop:u,isBottom:d,isLeft:f,isRight:m}=sre(t),p={x:0,y:0},x={x:0,y:0},y={height:e.height*i.y,width:e.width*i.x};return!u&&a<=e.top+y.height?(p.y=Qi.Backward,x.y=r*Math.abs((e.top+y.height-a)/y.height)):!d&&c>=e.bottom-y.height&&(p.y=Qi.Forward,x.y=r*Math.abs((e.bottom-y.height-c)/y.height)),!m&&l>=e.right-y.width?(p.x=Qi.Forward,x.x=r*Math.abs((e.right-y.width-l)/y.width)):!f&&o<=e.left+y.width&&(p.x=Qi.Backward,x.x=r*Math.abs((e.left+y.width-o)/y.width)),{direction:p,speed:x}}function CWe(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 ore(t){return t.reduce((e,n)=>ng(e,$R(n)),dl)}function kWe(t){return t.reduce((e,n)=>e+rre(n),0)}function jWe(t){return t.reduce((e,n)=>e+ire(n),0)}function PWe(t,e){if(e===void 0&&(e=sx),!t)return;const{top:n,left:r,bottom:i,right:a}=e(t);nre(t)&&(i<=0||a<=0||n>=window.innerHeight||r>=window.innerWidth)&&t.scrollIntoView({block:"center",inline:"center"})}const RWe=[["x",["left","right"],kWe],["y",["top","bottom"],jWe]];class UL{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=hM(n),i=ore(r);this.rect={...e},this.width=e.width,this.height=e.height;for(const[a,o,l]of RWe)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 i0{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var r;return(r=this.target)==null?void 0:r.removeEventListener(...n)})},this.target=e}add(e,n,r){var i;(i=this.target)==null||i.addEventListener(e,n,r),this.listeners.push([e,n,r])}}function DWe(t){const{EventTarget:e}=Ms(t);return t instanceof e?t:ax(t)}function yj(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 vo;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(vo||(vo={}));function $G(t){t.preventDefault()}function OWe(t){t.stopPropagation()}var zn;(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"})(zn||(zn={}));const lre={start:[zn.Space,zn.Enter],cancel:[zn.Esc],end:[zn.Space,zn.Enter,zn.Tab]},LWe=(t,e)=>{let{currentCoordinates:n}=e;switch(t.code){case zn.Right:return{...n,x:n.x+25};case zn.Left:return{...n,x:n.x-25};case zn.Down:return{...n,y:n.y+25};case zn.Up:return{...n,y:n.y-25}}};class fM{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;const{event:{target:n}}=e;this.props=e,this.listeners=new i0(ax(n)),this.windowListeners=new i0(Ms(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(vo.Resize,this.handleCancel),this.windowListeners.add(vo.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(vo.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:e,onStart:n}=this.props,r=e.node.current;r&&PWe(r),n(dl)}handleKeyDown(e){if(FL(e)){const{active:n,context:r,options:i}=this.props,{keyboardCodes:a=lre,coordinateGetter:o=LWe,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}:dl;this.referenceCoordinates||(this.referenceCoordinates=d);const f=o(e,{active:n,context:r.current,currentCoordinates:d});if(f){const m=ey(f,d),p={x:0,y:0},{scrollableAncestors:x}=r.current;for(const y of x){const b=e.code,{isTop:v,isRight:N,isLeft:S,isBottom:T,maxScroll:E,minScroll:C}=sre(y),A=CWe(y),O={x:Math.min(b===zn.Right?A.right-A.width/2:A.right,Math.max(b===zn.Right?A.left:A.left+A.width/2,f.x)),y:Math.min(b===zn.Down?A.bottom-A.height/2:A.bottom,Math.max(b===zn.Down?A.top:A.top+A.height/2,f.y))},k=b===zn.Right&&!N||b===zn.Left&&!S,R=b===zn.Down&&!T||b===zn.Up&&!v;if(k&&O.x!==f.x){const F=y.scrollLeft+m.x,L=b===zn.Right&&F<=E.x||b===zn.Left&&F>=C.x;if(L&&!m.y){y.scrollTo({left:F,behavior:l});return}L?p.x=y.scrollLeft-F:p.x=b===zn.Right?y.scrollLeft-E.x:y.scrollLeft-C.x,p.x&&y.scrollBy({left:-p.x,behavior:l});break}else if(R&&O.y!==f.y){const F=y.scrollTop+m.y,L=b===zn.Down&&F<=E.y||b===zn.Up&&F>=C.y;if(L&&!m.x){y.scrollTo({top:F,behavior:l});return}L?p.y=y.scrollTop-F:p.y=b===zn.Down?y.scrollTop-E.y:y.scrollTop-C.y,p.y&&y.scrollBy({top:-p.y,behavior:l});break}}this.handleMove(e,ng(ey(f,this.referenceCoordinates),p))}}}handleMove(e,n){const{onMove:r}=this.props;e.preventDefault(),r(n)}handleEnd(e){const{onEnd:n}=this.props;e.preventDefault(),this.detach(),n()}handleCancel(e){const{onCancel:n}=this.props;e.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}fM.activators=[{eventName:"onKeyDown",handler:(t,e,n)=>{let{keyboardCodes:r=lre,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 HG(t){return!!(t&&"distance"in t)}function VG(t){return!!(t&&"delay"in t)}class zL{constructor(e,n,r){var i;r===void 0&&(r=DWe(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=ax(o),this.documentListeners=new i0(this.document),this.listeners=new i0(r),this.windowListeners=new i0(Ms(o)),this.initialCoordinates=(i=BR(a))!=null?i:dl,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(vo.Resize,this.handleCancel),this.windowListeners.add(vo.DragStart,$G),this.windowListeners.add(vo.VisibilityChange,this.handleCancel),this.windowListeners.add(vo.ContextMenu,$G),this.documentListeners.add(vo.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(VG(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(HG(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(vo.Click,OWe,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(vo.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=BR(e))!=null?n:dl,u=ey(i,c);if(!r&&l){if(HG(l)){if(l.tolerance!=null&&yj(u,l.tolerance))return this.handleCancel();if(yj(u,l.distance))return this.handleStart()}if(VG(l)&&yj(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===zn.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}}const IWe={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class mM extends zL{constructor(e){const{event:n}=e,r=ax(n.target);super(e,IWe,r)}}mM.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 FWe={move:{name:"mousemove"},end:{name:"mouseup"}};var HR;(function(t){t[t.RightClick=2]="RightClick"})(HR||(HR={}));class UWe extends zL{constructor(e){super(e,FWe,ax(e.event.target))}}UWe.activators=[{eventName:"onMouseDown",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:r}=e;return n.button===HR.RightClick?!1:(r?.({event:n}),!0)}}];const vj={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class zWe extends zL{constructor(e){super(e,vj)}static setup(){return window.addEventListener(vj.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(vj.move.name,e)};function e(){}}}zWe.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 a0;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(a0||(a0={}));var E2;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(E2||(E2={}));function BWe(t){let{acceleration:e,activator:n=a0.Pointer,canScroll:r,draggingRect:i,enabled:a,interval:o=5,order:l=E2.TreeOrder,pointerCoordinates:c,scrollableAncestors:u,scrollableAncestorRects:d,delta:f,threshold:m}=t;const p=HWe({delta:f,disabled:!a}),[x,y]=tWe(),b=w.useRef({x:0,y:0}),v=w.useRef({x:0,y:0}),N=w.useMemo(()=>{switch(n){case a0.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case a0.DraggableRect:return i}},[n,i,c]),S=w.useRef(null),T=w.useCallback(()=>{const C=S.current;if(!C)return;const A=b.current.x*v.current.x,O=b.current.y*v.current.y;C.scrollBy(A,O)},[]),E=w.useMemo(()=>l===E2.TreeOrder?[...u].reverse():u,[l,u]);w.useEffect(()=>{if(!a||!u.length||!N){y();return}for(const C of E){if(r?.(C)===!1)continue;const A=u.indexOf(C),O=d[A];if(!O)continue;const{direction:k,speed:R}=AWe(C,O,N,e,m);for(const F of["x","y"])p[F][k[F]]||(R[F]=0,k[F]=0);if(R.x>0||R.y>0){y(),S.current=C,x(T,o),b.current=R,v.current=k;return}}b.current={x:0,y:0},v.current={x:0,y:0},y()},[e,T,r,y,a,o,JSON.stringify(N),JSON.stringify(p),x,u,E,d,JSON.stringify(m)])}const $We={x:{[Qi.Backward]:!1,[Qi.Forward]:!1},y:{[Qi.Backward]:!1,[Qi.Forward]:!1}};function HWe(t){let{delta:e,disabled:n}=t;const r=zR(e);return Hy(i=>{if(n||!r||!i)return $We;const a={x:Math.sign(e.x-r.x),y:Math.sign(e.y-r.y)};return{x:{[Qi.Backward]:i.x[Qi.Backward]||a.x===-1,[Qi.Forward]:i.x[Qi.Forward]||a.x===1},y:{[Qi.Backward]:i.y[Qi.Backward]||a.y===-1,[Qi.Forward]:i.y[Qi.Forward]||a.y===1}}},[n,e,r])}function VWe(t,e){const n=e!=null?t.get(e):void 0,r=n?n.node.current:null;return Hy(i=>{var a;return e==null?null:(a=r??i)!=null?a:null},[r,e])}function GWe(t,e){return w.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 ty;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(ty||(ty={}));var VR;(function(t){t.Optimized="optimized"})(VR||(VR={}));const GG=new Map;function WWe(t,e){let{dragging:n,dependencies:r,config:i}=e;const[a,o]=w.useState(null),{frequency:l,measure:c,strategy:u}=i,d=w.useRef(t),f=b(),m=J0(f),p=w.useCallback(function(v){v===void 0&&(v=[]),!m.current&&o(N=>N===null?v:N.concat(v.filter(S=>!N.includes(S))))},[m]),x=w.useRef(null),y=Hy(v=>{if(f&&!n)return GG;if(!v||v===GG||d.current!==t||a!=null){const N=new Map;for(let S of t){if(!S)continue;if(a&&a.length>0&&!a.includes(S.id)&&S.rect.current){N.set(S.id,S.rect.current);continue}const T=S.node.current,E=T?new UL(c(T),T):null;S.rect.current=E,E&&N.set(S.id,E)}return N}return v},[t,a,n,f,c]);return w.useEffect(()=>{d.current=t},[t]),w.useEffect(()=>{f||p()},[n,f]),w.useEffect(()=>{a&&a.length>0&&o(null)},[JSON.stringify(a)]),w.useEffect(()=>{f||typeof l!="number"||x.current!==null||(x.current=setTimeout(()=>{p(),x.current=null},l))},[l,f,p,...r]),{droppableRects:y,measureDroppableContainers:p,measuringScheduled:a!=null};function b(){switch(u){case ty.Always:return!1;case ty.BeforeDragging:return n;default:return!n}}}function cre(t,e){return Hy(n=>t?n||(typeof e=="function"?e(t):t):null,[e,t])}function qWe(t,e){return cre(t,e)}function KWe(t){let{callback:e,disabled:n}=t;const r=IL(e),i=w.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:a}=window;return new a(r)},[r,n]);return w.useEffect(()=>()=>i?.disconnect(),[i]),i}function pM(t){let{callback:e,disabled:n}=t;const r=IL(e),i=w.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:a}=window;return new a(r)},[n]);return w.useEffect(()=>()=>i?.disconnect(),[i]),i}function XWe(t){return new UL(sx(t),t)}function WG(t,e,n){e===void 0&&(e=XWe);const[r,i]=w.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=KWe({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=pM({callback:a});return Xl(()=>{a(),t?(l?.observe(t),o?.observe(document.body,{childList:!0,subtree:!0})):(l?.disconnect(),o?.disconnect())},[t]),r}function YWe(t){const e=cre(t);return tre(t,e)}const qG=[];function QWe(t){const e=w.useRef(t),n=Hy(r=>t?r&&r!==qG&&t&&e.current&&t.parentNode===e.current.parentNode?r:hM(t):qG,[t]);return w.useEffect(()=>{e.current=t},[t]),n}function ZWe(t){const[e,n]=w.useState(null),r=w.useRef(t),i=w.useCallback(a=>{const o=bj(a.target);o&&n(l=>l?(l.set(o,$R(o)),new Map(l)):null)},[]);return w.useEffect(()=>{const a=r.current;if(t!==a){o(a);const l=t.map(c=>{const u=bj(c);return u?(u.addEventListener("scroll",i,{passive:!0}),[u,$R(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=bj(c);u?.removeEventListener("scroll",i)})}},[i,t]),w.useMemo(()=>t.length?e?Array.from(e.values()).reduce((a,o)=>ng(a,o),dl):ore(t):dl,[t,e])}function KG(t,e){e===void 0&&(e=[]);const n=w.useRef(null);return w.useEffect(()=>{n.current=null},e),w.useEffect(()=>{const r=t!==dl;r&&!n.current&&(n.current=t),!r&&n.current&&(n.current=null)},[t]),n.current?ey(t,n.current):dl}function JWe(t){w.useEffect(()=>{if(!dM)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 eqe(t,e){return w.useMemo(()=>t.reduce((n,r)=>{let{eventName:i,handler:a}=r;return n[i]=o=>{a(o,e)},n},{}),[t,e])}function ure(t){return w.useMemo(()=>t?NWe(t):null,[t])}const XG=[];function tqe(t,e){e===void 0&&(e=sx);const[n]=t,r=ure(n?Ms(n):null),[i,a]=w.useState(XG);function o(){a(()=>t.length?t.map(c=>are(c)?r:new UL(e(c),c)):XG)}const l=pM({callback:o});return Xl(()=>{l?.disconnect(),o(),t.forEach(c=>l?.observe(c))},[t]),i}function nqe(t){if(!t)return null;if(t.children.length>1)return t;const e=t.children[0];return $y(e)?e:t}function rqe(t){let{measure:e}=t;const[n,r]=w.useState(null),i=w.useCallback(u=>{for(const{target:d}of u)if($y(d)){r(f=>{const m=e(d);return f?{...f,width:m.width,height:m.height}:m});break}},[e]),a=pM({callback:i}),o=w.useCallback(u=>{const d=nqe(u);a?.disconnect(),d&&a?.observe(d),r(d?e(d):null)},[e,a]),[l,c]=S2(o);return w.useMemo(()=>({nodeRef:l,rect:n,setRef:c}),[n,l,c])}const iqe=[{sensor:mM,options:{}},{sensor:fM,options:{}}],aqe={current:{}},cw={draggable:{measure:BG},droppable:{measure:BG,strategy:ty.WhileDragging,frequency:VR.Optimized},dragOverlay:{measure:sx}};class s0 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 sqe={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new s0,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:N2},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:cw,measureDroppableContainers:N2,windowRect:null,measuringScheduled:!1},oqe={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:N2,draggableNodes:new Map,over:null,measureDroppableContainers:N2},gM=w.createContext(oqe),dre=w.createContext(sqe);function lqe(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new s0}}}function cqe(t,e){switch(e.type){case ki.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:e.initialCoordinates,active:e.active}};case ki.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 ki.DragEnd:case ki.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case ki.RegisterDroppable:{const{element:n}=e,{id:r}=n,i=new s0(t.droppable.containers);return i.set(r,n),{...t,droppable:{...t.droppable,containers:i}}}case ki.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 s0(t.droppable.containers);return o.set(n,{...a,disabled:i}),{...t,droppable:{...t.droppable,containers:o}}}case ki.UnregisterDroppable:{const{id:n,key:r}=e,i=t.droppable.containers.get(n);if(!i||r!==i.key)return t;const a=new s0(t.droppable.containers);return a.delete(n),{...t,droppable:{...t.droppable,containers:a}}}default:return t}}function uqe(t){let{disabled:e}=t;const{active:n,activatorEvent:r,draggableNodes:i}=w.useContext(gM),a=zR(r),o=zR(n?.id);return w.useEffect(()=>{if(!e&&!r&&a&&o!=null){if(!FL(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=iWe(d);if(f){f.focus();break}}})}},[r,e,i,o,a]),null}function dqe(t,e){let{transform:n,...r}=e;return t!=null&&t.length?t.reduce((i,a)=>a({transform:i,...r}),n):n}function hqe(t){return w.useMemo(()=>({draggable:{...cw.draggable,...t?.draggable},droppable:{...cw.droppable,...t?.droppable},dragOverlay:{...cw.dragOverlay,...t?.dragOverlay}}),[t?.draggable,t?.droppable,t?.dragOverlay])}function fqe(t){let{activeNode:e,measure:n,initialRect:r,config:i=!0}=t;const a=w.useRef(!1),{x:o,y:l}=typeof i=="boolean"?{x:i,y:i}:i;Xl(()=>{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=tre(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 m=nre(u);m&&m.scrollBy({top:f.y,left:f.x})}},[e,o,l,r,n])}const hre=w.createContext({...dl,scaleX:1,scaleY:1});var pd;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(pd||(pd={}));const fre=w.memo(function(e){var n,r,i,a;let{id:o,accessibility:l,autoScroll:c=!0,children:u,sensors:d=iqe,collisionDetection:f=xWe,measuring:m,modifiers:p,...x}=e;const y=w.useReducer(cqe,void 0,lqe),[b,v]=y,[N,S]=uWe(),[T,E]=w.useState(pd.Uninitialized),C=T===pd.Initialized,{draggable:{active:A,nodes:O,translate:k},droppable:{containers:R}}=b,F=A!=null?O.get(A):null,L=w.useRef({initial:null,translated:null}),K=w.useMemo(()=>{var Oe;return A!=null?{id:A,data:(Oe=F?.data)!=null?Oe:aqe,rect:L}:null},[A,F]),j=w.useRef(null),[W,Y]=w.useState(null),[q,Q]=w.useState(null),ee=J0(x,Object.values(x)),re=Vy("DndDescribedBy",o),z=w.useMemo(()=>R.getEnabled(),[R]),G=hqe(m),{droppableRects:ae,measureDroppableContainers:se,measuringScheduled:ue}=WWe(z,{dragging:C,dependencies:[k.x,k.y],config:G.droppable}),pe=VWe(O,A),ce=w.useMemo(()=>q?BR(q):null,[q]),Me=be(),me=qWe(pe,G.draggable.measure);fqe({activeNode:A!=null?O.get(A):null,config:Me.layoutShiftCompensation,initialRect:me,measure:G.draggable.measure});const Ee=WG(pe,G.draggable.measure,me),fe=WG(pe?pe.parentElement:null),le=w.useRef({activatorEvent:null,active:null,activeNode:pe,collisionRect:null,collisions:null,droppableRects:ae,draggableNodes:O,draggingNode:null,draggingNodeRect:null,droppableContainers:R,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),Be=R.getNodeFor((n=le.current.over)==null?void 0:n.id),V=rqe({measure:G.dragOverlay.measure}),$=(r=V.nodeRef.current)!=null?r:pe,X=C?(i=V.rect)!=null?i:Ee:null,U=!!(V.nodeRef.current&&V.rect),B=YWe(U?null:Ee),oe=ure($?Ms($):null),Te=QWe(C?Be??pe:null),je=tqe(Te),Ce=dqe(p,{transform:{x:k.x-B.x,y:k.y-B.y,scaleX:1,scaleY:1},activatorEvent:q,active:K,activeNodeRect:Ee,containerNodeRect:fe,draggingNodeRect:X,over:le.current.over,overlayNodeRect:V.rect,scrollableAncestors:Te,scrollableAncestorRects:je,windowRect:oe}),H=ce?ng(ce,k):null,D=ZWe(Te),Z=KG(D),xe=KG(D,[Ee]),Ne=ng(Ce,Z),ve=X?vWe(X,Ce):null,$e=K&&ve?f({active:K,collisionRect:ve,droppableRects:ae,droppableContainers:z,pointerCoordinates:H}):null,Le=Jne($e,"id"),[qe,Ke]=w.useState(null),Ye=U?Ce:ng(Ce,xe),ie=bWe(Ye,(a=qe?.rect)!=null?a:null,Ee),te=w.useRef(null),Se=w.useCallback((Oe,Ue)=>{let{sensor:Ae,options:Je}=Ue;if(j.current==null)return;const gt=O.get(j.current);if(!gt)return;const Pt=Oe.nativeEvent,Ot=new Ae({active:j.current,activeNode:gt,event:Pt,options:Je,context:le,onAbort(It){if(!O.get(It))return;const{onDragAbort:bt}=ee.current,Gt={id:It};bt?.(Gt),N({type:"onDragAbort",event:Gt})},onPending(It,_n,bt,Gt){if(!O.get(It))return;const{onDragPending:Tt}=ee.current,Rr={id:It,constraint:_n,initialCoordinates:bt,offset:Gt};Tt?.(Rr),N({type:"onDragPending",event:Rr})},onStart(It){const _n=j.current;if(_n==null)return;const bt=O.get(_n);if(!bt)return;const{onDragStart:Gt}=ee.current,ln={activatorEvent:Pt,active:{id:_n,data:bt.data,rect:L}};Hc.unstable_batchedUpdates(()=>{Gt?.(ln),E(pd.Initializing),v({type:ki.DragStart,initialCoordinates:It,active:_n}),N({type:"onDragStart",event:ln}),Y(te.current),Q(Pt)})},onMove(It){v({type:ki.DragMove,coordinates:It})},onEnd:cn(ki.DragEnd),onCancel:cn(ki.DragCancel)});te.current=Ot;function cn(It){return async function(){const{active:bt,collisions:Gt,over:ln,scrollAdjustedTranslate:Tt}=le.current;let Rr=null;if(bt&&Tt){const{cancelDrop:Xr}=ee.current;Rr={activatorEvent:Pt,active:bt,collisions:Gt,delta:Tt,over:ln},It===ki.DragEnd&&typeof Xr=="function"&&await Promise.resolve(Xr(Rr))&&(It=ki.DragCancel)}j.current=null,Hc.unstable_batchedUpdates(()=>{v({type:It}),E(pd.Uninitialized),Ke(null),Y(null),Q(null),te.current=null;const Xr=It===ki.DragEnd?"onDragEnd":"onDragCancel";if(Rr){const An=ee.current[Xr];An?.(Rr),N({type:Xr,event:Rr})}})}}},[O]),ze=w.useCallback((Oe,Ue)=>(Ae,Je)=>{const gt=Ae.nativeEvent,Pt=O.get(Je);if(j.current!==null||!Pt||gt.dndKit||gt.defaultPrevented)return;const Ot={active:Pt};Oe(Ae,Ue.options,Ot)===!0&&(gt.dndKit={capturedBy:Ue.sensor},j.current=Je,Se(Ae,Ue))},[O,Se]),nt=GWe(d,ze);JWe(d),Xl(()=>{Ee&&T===pd.Initializing&&E(pd.Initialized)},[Ee,T]),w.useEffect(()=>{const{onDragMove:Oe}=ee.current,{active:Ue,activatorEvent:Ae,collisions:Je,over:gt}=le.current;if(!Ue||!Ae)return;const Pt={active:Ue,activatorEvent:Ae,collisions:Je,delta:{x:Ne.x,y:Ne.y},over:gt};Hc.unstable_batchedUpdates(()=>{Oe?.(Pt),N({type:"onDragMove",event:Pt})})},[Ne.x,Ne.y]),w.useEffect(()=>{const{active:Oe,activatorEvent:Ue,collisions:Ae,droppableContainers:Je,scrollAdjustedTranslate:gt}=le.current;if(!Oe||j.current==null||!Ue||!gt)return;const{onDragOver:Pt}=ee.current,Ot=Je.get(Le),cn=Ot&&Ot.rect.current?{id:Ot.id,rect:Ot.rect.current,data:Ot.data,disabled:Ot.disabled}:null,It={active:Oe,activatorEvent:Ue,collisions:Ae,delta:{x:gt.x,y:gt.y},over:cn};Hc.unstable_batchedUpdates(()=>{Ke(cn),Pt?.(It),N({type:"onDragOver",event:It})})},[Le]),Xl(()=>{le.current={activatorEvent:q,active:K,activeNode:pe,collisionRect:ve,collisions:$e,droppableRects:ae,draggableNodes:O,draggingNode:$,draggingNodeRect:X,droppableContainers:R,over:qe,scrollableAncestors:Te,scrollAdjustedTranslate:Ne},L.current={initial:X,translated:ve}},[K,pe,$e,ve,O,$,X,ae,R,qe,Te,Ne]),BWe({...Me,delta:k,draggingRect:ve,pointerCoordinates:H,scrollableAncestors:Te,scrollableAncestorRects:je});const ne=w.useMemo(()=>({active:K,activeNode:pe,activeNodeRect:Ee,activatorEvent:q,collisions:$e,containerNodeRect:fe,dragOverlay:V,draggableNodes:O,droppableContainers:R,droppableRects:ae,over:qe,measureDroppableContainers:se,scrollableAncestors:Te,scrollableAncestorRects:je,measuringConfiguration:G,measuringScheduled:ue,windowRect:oe}),[K,pe,Ee,q,$e,fe,V,O,R,ae,qe,se,Te,je,G,ue,oe]),Pe=w.useMemo(()=>({activatorEvent:q,activators:nt,active:K,activeNodeRect:Ee,ariaDescribedById:{draggable:re},dispatch:v,draggableNodes:O,over:qe,measureDroppableContainers:se}),[q,nt,K,Ee,v,re,O,qe,se]);return Fr.createElement(Xne.Provider,{value:S},Fr.createElement(gM.Provider,{value:Pe},Fr.createElement(dre.Provider,{value:ne},Fr.createElement(hre.Provider,{value:ie},u)),Fr.createElement(uqe,{disabled:l?.restoreFocus===!1})),Fr.createElement(fWe,{...l,hiddenTextDescribedById:re}));function be(){const Oe=W?.autoScrollEnabled===!1,Ue=typeof c=="object"?c.enabled===!1:c===!1,Ae=C&&!Oe&&!Ue;return typeof c=="object"?{...c,enabled:Ae}:{enabled:Ae}}}),mqe=w.createContext(null),YG="button",pqe="Draggable";function gqe(t){let{id:e,data:n,disabled:r=!1,attributes:i}=t;const a=Vy(pqe),{activators:o,activatorEvent:l,active:c,activeNodeRect:u,ariaDescribedById:d,draggableNodes:f,over:m}=w.useContext(gM),{role:p=YG,roleDescription:x="draggable",tabIndex:y=0}=i??{},b=c?.id===e,v=w.useContext(b?hre:mqe),[N,S]=S2(),[T,E]=S2(),C=eqe(o,e),A=J0(n);Xl(()=>(f.set(e,{id:e,key:a,node:N,activatorNode:T,data:A}),()=>{const k=f.get(e);k&&k.key===a&&f.delete(e)}),[f,e]);const O=w.useMemo(()=>({role:p,tabIndex:y,"aria-disabled":r,"aria-pressed":b&&p===YG?!0:void 0,"aria-roledescription":x,"aria-describedby":d.draggable}),[r,p,y,b,x,d.draggable]);return{active:c,activatorEvent:l,activeNodeRect:u,attributes:O,isDragging:b,listeners:r?void 0:C,node:N,over:m,setNodeRef:S,setActivatorNodeRef:E,transform:v}}function xqe(){return w.useContext(dre)}const bqe="Droppable",yqe={timeout:25};function vqe(t){let{data:e,disabled:n=!1,id:r,resizeObserverConfig:i}=t;const a=Vy(bqe),{active:o,dispatch:l,over:c,measureDroppableContainers:u}=w.useContext(gM),d=w.useRef({disabled:n}),f=w.useRef(!1),m=w.useRef(null),p=w.useRef(null),{disabled:x,updateMeasurementsFor:y,timeout:b}={...yqe,...i},v=J0(y??r),N=w.useCallback(()=>{if(!f.current){f.current=!0;return}p.current!=null&&clearTimeout(p.current),p.current=setTimeout(()=>{u(Array.isArray(v.current)?v.current:[v.current]),p.current=null},b)},[b]),S=pM({callback:N,disabled:x||!o}),T=w.useCallback((O,k)=>{S&&(k&&(S.unobserve(k),f.current=!1),O&&S.observe(O))},[S]),[E,C]=S2(T),A=J0(e);return w.useEffect(()=>{!S||!E.current||(S.disconnect(),f.current=!1,S.observe(E.current))},[E,S]),w.useEffect(()=>(l({type:ki.RegisterDroppable,element:{id:r,key:a,disabled:n,node:E,rect:m,data:A}}),()=>l({type:ki.UnregisterDroppable,key:a,id:r})),[r]),w.useEffect(()=>{n!==d.current.disabled&&(l({type:ki.SetDroppableDisabled,id:r,key:a,disabled:n}),d.current.disabled=n)},[r,a,n,l]),{active:o,rect:m,isOver:c?.id===r,node:E,over:c,setNodeRef:C}}function xM(t,e,n){const r=t.slice();return r.splice(n<0?r.length+n:n,0,r.splice(e,1)[0]),r}function _qe(t,e){return t.reduce((n,r,i)=>{const a=e.get(r);return a&&(n[i]=a),n},Array(t.length))}function R1(t){return t!==null&&t>=0}function wqe(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 Sqe(t){return typeof t=="boolean"?{draggable:t,droppable:t}:t}const BL=t=>{let{rects:e,activeIndex:n,overIndex:r,index:i}=t;const a=xM(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}},D1={scaleX:1,scaleY:1},Nqe=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,...D1}:null}const c=Mqe(a,i,n);return i>n&&i<=o?{x:0,y:-l.height-c,...D1}:i<n&&i>=o?{x:0,y:l.height+c,...D1}:{x:0,y:0,...D1}};function Mqe(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 mre="Sortable",pre=Fr.createContext({activeIndex:-1,containerId:mre,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:BL,disabled:{draggable:!1,droppable:!1}});function gre(t){let{children:e,id:n,items:r,strategy:i=BL,disabled:a=!1}=t;const{active:o,dragOverlay:l,droppableRects:c,over:u,measureDroppableContainers:d}=xqe(),f=Vy(mre,n),m=l.rect!==null,p=w.useMemo(()=>r.map(C=>typeof C=="object"&&"id"in C?C.id:C),[r]),x=o!=null,y=o?p.indexOf(o.id):-1,b=u?p.indexOf(u.id):-1,v=w.useRef(p),N=!wqe(p,v.current),S=b!==-1&&y===-1||N,T=Sqe(a);Xl(()=>{N&&x&&d(p)},[N,p,x,d]),w.useEffect(()=>{v.current=p},[p]);const E=w.useMemo(()=>({activeIndex:y,containerId:f,disabled:T,disableTransforms:S,items:p,overIndex:b,useDragOverlay:m,sortedRects:_qe(p,c),strategy:i}),[y,f,T.draggable,T.droppable,S,p,b,c,m,i]);return Fr.createElement(pre.Provider,{value:E},e)}const Eqe=t=>{let{id:e,items:n,activeIndex:r,overIndex:i}=t;return xM(n,r,i).indexOf(e)},Tqe=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},Aqe={duration:200,easing:"ease"},xre="transform",Cqe=Rg.Transition.toString({property:xre,duration:0,easing:"linear"}),kqe={roleDescription:"sortable"};function jqe(t){let{disabled:e,index:n,node:r,rect:i}=t;const[a,o]=w.useState(null),l=w.useRef(n);return Xl(()=>{if(!e&&n!==l.current&&r.current){const c=i.current;if(c){const u=sx(r.current,{ignoreTransform:!0}),d={x:c.left-u.left,y:c.top-u.top,scaleX:c.width/u.width,scaleY:c.height/u.height};(d.x||d.y)&&o(d)}}n!==l.current&&(l.current=n)},[e,n,r,i]),w.useEffect(()=>{a&&o(null)},[a]),a}function bre(t){let{animateLayoutChanges:e=Tqe,attributes:n,disabled:r,data:i,getNewIndex:a=Eqe,id:o,strategy:l,resizeObserverConfig:c,transition:u=Aqe}=t;const{items:d,containerId:f,activeIndex:m,disabled:p,disableTransforms:x,sortedRects:y,overIndex:b,useDragOverlay:v,strategy:N}=w.useContext(pre),S=Pqe(r,p),T=d.indexOf(o),E=w.useMemo(()=>({sortable:{containerId:f,index:T,items:d},...i}),[f,i,T,d]),C=w.useMemo(()=>d.slice(d.indexOf(o)),[d,o]),{rect:A,node:O,isOver:k,setNodeRef:R}=vqe({id:o,data:E,disabled:S.droppable,resizeObserverConfig:{updateMeasurementsFor:C,...c}}),{active:F,activatorEvent:L,activeNodeRect:K,attributes:j,setNodeRef:W,listeners:Y,isDragging:q,over:Q,setActivatorNodeRef:ee,transform:re}=gqe({id:o,data:E,attributes:{...kqe,...n},disabled:S.draggable}),z=eWe(R,W),G=!!F,ae=G&&!x&&R1(m)&&R1(b),se=!v&&q,ue=se&&ae?re:null,ce=ae?ue??(l??N)({rects:y,activeNodeRect:K,activeIndex:m,overIndex:b,index:T}):null,Me=R1(m)&&R1(b)?a({id:o,items:d,activeIndex:m,overIndex:b}):T,me=F?.id,Ee=w.useRef({activeId:me,items:d,newIndex:Me,containerId:f}),fe=d!==Ee.current.items,le=e({active:F,containerId:f,isDragging:q,isSorting:G,id:o,index:T,items:d,newIndex:Ee.current.newIndex,previousItems:Ee.current.items,previousContainerId:Ee.current.containerId,transition:u,wasDragging:Ee.current.activeId!=null}),Be=jqe({disabled:!le,index:T,node:O,rect:A});return w.useEffect(()=>{G&&Ee.current.newIndex!==Me&&(Ee.current.newIndex=Me),f!==Ee.current.containerId&&(Ee.current.containerId=f),d!==Ee.current.items&&(Ee.current.items=d)},[G,Me,f,d]),w.useEffect(()=>{if(me===Ee.current.activeId)return;if(me!=null&&Ee.current.activeId==null){Ee.current.activeId=me;return}const $=setTimeout(()=>{Ee.current.activeId=me},50);return()=>clearTimeout($)},[me]),{active:F,activeIndex:m,attributes:j,data:E,rect:A,index:T,newIndex:Me,items:d,isOver:k,isSorting:G,isDragging:q,listeners:Y,node:O,overIndex:b,over:Q,setNodeRef:z,setActivatorNodeRef:ee,setDroppableNodeRef:R,setDraggableNodeRef:W,transform:Be??ce,transition:V()};function V(){if(Be||fe&&Ee.current.newIndex===T)return Cqe;if(!(se&&!FL(L)||!u)&&(G||le))return Rg.Transition.toString({...u,property:xre})}}function Pqe(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 T2(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 Rqe=[zn.Down,zn.Right,zn.Up,zn.Left],yre=(t,e)=>{let{context:{active:n,collisionRect:r,droppableRects:i,droppableContainers:a,over:o,scrollableAncestors:l}}=e;if(Rqe.includes(t.code)){if(t.preventDefault(),!n||!r)return;const c=[];a.getEnabled().forEach(f=>{if(!f||f!=null&&f.disabled)return;const m=i.get(f.id);if(m)switch(t.code){case zn.Down:r.top<m.top&&c.push(f);break;case zn.Up:r.top>m.top&&c.push(f);break;case zn.Left:r.left>m.left&&c.push(f);break;case zn.Right:r.left<m.left&&c.push(f);break}});const u=pWe({collisionRect:r,droppableRects:i,droppableContainers:c});let d=Jne(u,"id");if(d===o?.id&&u.length>1&&(d=u[1].id),d!=null){const f=a.get(n.id),m=a.get(d),p=m?i.get(m.id):null,x=m?.node.current;if(x&&p&&f&&m){const b=hM(x).some((C,A)=>l[A]!==C),v=vre(f,m),N=Dqe(f,m),S=b||!v?{x:0,y:0}:{x:N?r.width-p.width:0,y:N?r.height-p.height:0},T={x:p.left,y:p.top};return S.x&&S.y?T:ey(T,S)}}}};function vre(t,e){return!T2(t)||!T2(e)?!1:t.data.current.sortable.containerId===e.data.current.sortable.containerId}function Dqe(t,e){return!T2(t)||!T2(e)||!vre(t,e)?!1:t.data.current.sortable.index<e.data.current.sortable.index}function _re(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 Oqe(t,e="system"){if(!t)return"ASAP";const n=vi(t);if(!n)return"ASAP";const r=new Date,i=n.getTime()-r.getTime();return i<-6e4?"Overdue":i<0?"Now":i<6e4?"In less than a minute":i<36e5?`In ${Math.round(i/6e4)} min`:i<864e5?`In ${Math.round(i/36e5)} hours`:og(t,e)}function Lqe({status:t}){const e={pending:{icon:Kn,color:"text-status-warning bg-status-warning/10 border-status-warning/20",label:"Pending"},printing:{icon:Po,color:"text-blue-400 bg-blue-400/10 border-blue-400/20",label:"Printing"},completed:{icon:Fn,color:"text-status-ok bg-status-ok/10 border-status-ok/20",label:"Completed"},failed:{icon:ta,color:"text-status-error bg-status-error/10 border-status-error/20",label:"Failed"},skipped:{icon:m0,color:"text-orange-400 bg-orange-400/10 border-orange-400/20",label:"Skipped"},cancelled:{icon:zt,color:"text-gray-400 bg-gray-400/10 border-gray-400/20",label:"Cancelled"}},{icon:n,color:r,label:i}=e[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 ${r}`,children:[s.jsx(n,{className:"w-3.5 h-3.5"}),i]})}function Iqe({selectedCount:t,printers:e,onSave:n,onClose:r,isSaving:i}){const[a,o]=w.useState("unchanged"),[l,c]=w.useState("unchanged"),[u,d]=w.useState("unchanged"),[f,m]=w.useState("unchanged"),[p,x]=w.useState("unchanged"),[y,b]=w.useState("unchanged"),[v,N]=w.useState("unchanged"),[S,T]=w.useState("unchanged"),[E,C]=w.useState("unchanged"),[A,O]=w.useState("unchanged"),k=()=>{const F={};a!=="unchanged"&&(F.printer_id=a),l!=="unchanged"&&(F.manual_start=l),u!=="unchanged"&&(F.auto_off_after=u),f!=="unchanged"&&(F.require_previous_success=f),p!=="unchanged"&&(F.bed_levelling=p),y!=="unchanged"&&(F.flow_cali=y),v!=="unchanged"&&(F.vibration_cali=v),S!=="unchanged"&&(F.layer_inspect=S),E!=="unchanged"&&(F.timelapse=E),A!=="unchanged"&&(F.use_ams=A),n(F)},R=a!=="unchanged"||l!=="unchanged"||u!=="unchanged"||f!=="unchanged"||p!=="unchanged"||y!=="unchanged"||v!=="unchanged"||S!=="unchanged"||E!=="unchanged"||A!=="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.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Edit ",t," Item",t!==1?"s":""]}),s.jsx("button",{onClick:r,className:"p-1 hover:bg-bambu-dark rounded",children:s.jsx(zt,{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:"Only changed settings will be applied to selected items."}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Printer"}),s.jsxs("select",{value:a===null?"null":a==="unchanged"?"unchanged":String(a),onChange:F=>{const L=F.target.value;o(L==="unchanged"?"unchanged":L==="null"?null:Number(L))},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"unchanged",children:"— No change —"}),s.jsx("option",{value:"null",children:"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:"Queue Options"}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Rc,{label:"Staged (manual start)",value:l,onChange:c}),s.jsx(Rc,{label:"Auto power off after print",value:u,onChange:d}),s.jsx(Rc,{label:"Require previous success",value:f,onChange:m})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Print Options"}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Rc,{label:"Bed levelling",value:p,onChange:x}),s.jsx(Rc,{label:"Flow calibration",value:y,onChange:b}),s.jsx(Rc,{label:"Vibration calibration",value:v,onChange:N}),s.jsx(Rc,{label:"First layer inspection",value:S,onChange:T}),s.jsx(Rc,{label:"Timelapse",value:E,onChange:C}),s.jsx(Rc,{label:"Use AMS",value:A,onChange:O})]})]})]}),s.jsxs("div",{className:"flex justify-end gap-3 p-4 border-t border-bambu-dark-tertiary",children:[s.jsx(we,{variant:"secondary",onClick:r,children:"Cancel"}),s.jsx(we,{onClick:k,disabled:!R||i,children:i?"Saving...":"Apply Changes"})]})]})})}function Rc({label:t,value:e,onChange:n}){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:"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:"On"})]})]})}function _j({item:t,position:e,onEdit:n,onCancel:r,onRemove:i,onStop:a,onRequeue:o,onStart:l,timeFormat:c="system",isSelected:u=!1,onToggleSelect:d}){const{attributes:f,listeners:m,setNodeRef:p,transform:x,transition:y,isDragging:b}=bre({id:t.id,disabled:t.status!=="pending"}),v={transform:Rg.Transform.toString(x),transition:y},N=t.status==="printing",S=t.status==="pending",T=["completed","failed","skipped","cancelled"].includes(t.status);return s.jsx("div",{ref:p,style:v,className:`
  8274. group relative bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary
  8275. transition-all duration-200 hover:border-bambu-dark-tertiary/80
  8276. ${b?"opacity-50 scale-[1.02] shadow-xl z-50":""}
  8277. ${N?"border-blue-500/30 bg-gradient-to-r from-blue-500/5 to-transparent":""}
  8278. `,children:s.jsxs("div",{className:"flex items-center gap-4 p-4",children:[S&&d&&s.jsx("button",{onClick:E=>{E.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(Ya,{className:"w-4 h-4"})}),S?s.jsx("div",{...f,...m,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(ig,{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:he.getArchiveThumbnail(t.archive_id),alt:"",className:"w-full h-full object-cover"}):t.library_file_thumbnail?s.jsx("img",{src:he.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(cl,{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(fs,{to:`/archives?highlight=${t.archive_id}`,className:"text-bambu-gray hover:text-bambu-green transition-colors flex-shrink-0",title:"View archive",children:s.jsx(Ur,{className:"w-3.5 h-3.5"})}):t.library_file_id?s.jsx(fs,{to:`/library?highlight=${t.library_file_id}`,className:"text-bambu-gray hover:text-bambu-green transition-colors flex-shrink-0",title:"View in File Manager",children:s.jsx(Ur,{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(Mr,{className:"w-3.5 h-3.5"}),t.target_model?`Any ${t.target_model}`:t.printer_id===null?"Unassigned":t.printer_name||`Printer #${t.printer_id}`]}),t.print_time_seconds&&s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsx(vd,{className:"w-3.5 h-3.5"}),_re(t.print_time_seconds)]}),S&&!t.manual_start&&s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsx(Kn,{className:"w-3.5 h-3.5"}),Oqe(t.scheduled_time,c)]})]}),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(aq,{className:"w-3 h-3"}),"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:"Requires previous success"}),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"}),"Auto power off"]})]}),N&&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:"Printing in progress..."})]}),t.error_message&&s.jsxs("p",{className:"text-xs text-red-400 mt-2 flex items-center gap-1",children:[s.jsx(ji,{className:"w-3 h-3"}),t.error_message]})]}),s.jsx(Lqe,{status:t.status}),s.jsxs("div",{className:"flex items-center gap-1",children:[N&&s.jsx(we,{variant:"ghost",size:"sm",onClick:a,title:"Stop Print",className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:s.jsx(qce,{className:"w-4 h-4"})}),S&&s.jsxs(s.Fragment,{children:[t.manual_start&&s.jsx(we,{variant:"ghost",size:"sm",onClick:l,title:"Start Print",className:"text-bambu-green hover:text-bambu-green-light hover:bg-bambu-green/10",children:s.jsx(Po,{className:"w-4 h-4"})}),s.jsx(we,{variant:"ghost",size:"sm",onClick:n,title:"Edit",children:s.jsx(ia,{className:"w-4 h-4"})}),s.jsx(we,{variant:"ghost",size:"sm",onClick:r,title:"Cancel",className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:s.jsx(zt,{className:"w-4 h-4"})})]}),T&&s.jsxs(s.Fragment,{children:[s.jsx(we,{variant:"ghost",size:"sm",onClick:o,title:"Re-queue",className:"text-bambu-green hover:text-bambu-green/80 hover:bg-bambu-green/10",children:s.jsx(xr,{className:"w-4 h-4"})}),s.jsx(we,{variant:"ghost",size:"sm",onClick:i,title:"Remove",children:s.jsx(un,{className:"w-4 h-4"})})]})]})]})})}function Fqe(){const t=on(),{showToast:e}=Vn(),[n,r]=w.useState(null),[i,a]=w.useState(""),[o,l]=w.useState(!1),[c,u]=w.useState(null),[d,f]=w.useState(null),[m,p]=w.useState(null),[x,y]=w.useState([]),[b,v]=w.useState(!1),[N,S]=w.useState(()=>localStorage.getItem("queue.historySortBy")||"date"),[T,E]=w.useState(()=>{const fe=localStorage.getItem("queue.historySortAsc");return fe!==null?fe==="true":!1}),[C,A]=w.useState(()=>localStorage.getItem("queue.pendingSortBy")||"position"),[O,k]=w.useState(()=>{const fe=localStorage.getItem("queue.pendingSortAsc");return fe!==null?fe==="true":!0});w.useEffect(()=>{localStorage.setItem("queue.historySortBy",N)},[N]),w.useEffect(()=>{localStorage.setItem("queue.historySortAsc",String(T))},[T]),w.useEffect(()=>{localStorage.setItem("queue.pendingSortBy",C)},[C]),w.useEffect(()=>{localStorage.setItem("queue.pendingSortAsc",String(O))},[O]);const R=Yne(M2(mM,{activationConstraint:{distance:8}}),M2(fM,{coordinateGetter:yre})),{data:F}=ut({queryKey:["settings"],queryFn:he.getSettings}),L=F?.time_format||"system",{data:K,isLoading:j}=ut({queryKey:["queue",n,i],queryFn:()=>he.getQueue(n||void 0,i||void 0),refetchInterval:5e3}),{data:W}=ut({queryKey:["printers"],queryFn:()=>he.getPrinters()}),Y=pt({mutationFn:fe=>he.cancelQueueItem(fe),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Queue item cancelled")},onError:()=>e("Failed to cancel item","error")}),q=pt({mutationFn:fe=>he.removeFromQueue(fe),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Queue item removed")},onError:()=>e("Failed to remove item","error")}),Q=pt({mutationFn:fe=>he.stopQueueItem(fe),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Print stopped")},onError:()=>e("Failed to stop print","error")}),ee=pt({mutationFn:fe=>he.startQueueItem(fe),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Print released to queue")},onError:()=>e("Failed to start print","error")}),re=pt({mutationFn:fe=>he.reorderQueue(fe),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]})},onError:()=>e("Failed to reorder queue","error")}),z=pt({mutationFn:async()=>{const fe=K?.filter(le=>["completed","failed","skipped","cancelled"].includes(le.status))||[];for(const le of fe)await he.removeFromQueue(le.id);return fe.length},onSuccess:fe=>{t.invalidateQueries({queryKey:["queue"]}),e(`Cleared ${fe} history item${fe!==1?"s":""}`)},onError:()=>e("Failed to clear history","error")}),G=pt({mutationFn:fe=>he.bulkUpdateQueue(fe),onSuccess:fe=>{t.invalidateQueries({queryKey:["queue"]}),y([]),v(!1),e(fe.message)},onError:()=>e("Failed to update items","error")}),ae=pt({mutationFn:async fe=>{for(const le of fe)await he.cancelQueueItem(le);return fe.length},onSuccess:fe=>{t.invalidateQueries({queryKey:["queue"]}),y([]),e(`Cancelled ${fe} item${fe!==1?"s":""}`)},onError:()=>e("Failed to cancel items","error")}),se=fe=>{y(le=>le.includes(fe)?le.filter(Be=>Be!==fe):[...le,fe])},ue=w.useMemo(()=>{const fe=K?.filter(Be=>Be.status==="pending")||[],le=Be=>{if(!Be.scheduled_time)return 0;const V=new Date(Be.scheduled_time).getTime(),$=Date.now()+4320*60*60*1e3;return V>$?0:V};return[...fe].sort((Be,V)=>{let $;if(C==="name"){const X=Be.archive_name||Be.library_file_name||"",U=V.archive_name||V.library_file_name||"";$=X.localeCompare(U)}else C==="printer"?$=(Be.printer_name||"").localeCompare(V.printer_name||""):C==="time"?$=le(Be)-le(V):$=Be.position-V.position;return O?$:-$})},[K,C,O]),pe=()=>{const fe=ue.map(le=>le.id);x.length===fe.length?y([]):y(fe)},ce=K?.filter(fe=>fe.status==="printing")||[],Me=w.useMemo(()=>[...K?.filter(le=>["completed","failed","skipped","cancelled"].includes(le.status))||[]].sort((le,Be)=>{let V;if(N==="name"){const $=le.archive_name||le.library_file_name||"",X=Be.archive_name||Be.library_file_name||"";V=$.localeCompare(X)}else N==="printer"?V=(le.printer_name||"").localeCompare(Be.printer_name||""):V=new Date(Be.completed_at||Be.created_at).getTime()-new Date(le.completed_at||le.created_at).getTime();return T?-V:V}),[K,N,T]),me=w.useMemo(()=>ue.reduce((fe,le)=>fe+(le.print_time_seconds||0),0),[ue]),Ee=fe=>{const{active:le,over:Be}=fe;if(!Be||le.id===Be.id)return;const V=ue.findIndex(X=>X.id===le.id),$=ue.findIndex(X=>X.id===Be.id);if(V!==-1&&$!==-1){const U=xM(ue,V,$).map((B,oe)=>({id:B.id,position:oe+1}));re.mutate(U)}};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(sq,{className:"w-7 h-7 text-bambu-green"}),"Print Queue"]}),s.jsx("p",{className:"text-bambu-gray mt-1",children:"Schedule and manage your print jobs"})]})}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4 mb-8",children:[s.jsx(Nt,{className:"bg-gradient-to-br from-blue-500/10 to-transparent border-blue-500/20",children:s.jsx(Et,{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(Po,{className:"w-5 h-5 text-blue-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:"Printing"})]})]})})}),s.jsx(Nt,{className:"bg-gradient-to-br from-yellow-500/10 to-transparent border-yellow-500/20",children:s.jsx(Et,{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(Kn,{className:"w-5 h-5 text-yellow-400"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl font-bold text-white",children:ue.length}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Queued"})]})]})})}),s.jsx(Nt,{className:"bg-gradient-to-br from-bambu-green/10 to-transparent border-bambu-green/20",children:s.jsx(Et,{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(vd,{className:"w-5 h-5 text-bambu-green"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl font-bold text-white",children:_re(me)}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Total Queue Time"})]})]})})}),s.jsx(Nt,{className:"bg-gradient-to-br from-gray-500/10 to-transparent border-gray-500/20",children:s.jsx(Et,{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(Fn,{className:"w-5 h-5 text-gray-400"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl font-bold text-white",children:Me.length}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"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:n===-1?"unassigned":n||"",onChange:fe=>{const le=fe.target.value;r(le==="unassigned"?-1:le===""?null:Number(le))},children:[s.jsx("option",{value:"",children:"All Printers"}),s.jsx("option",{value:"unassigned",children:"Unassigned"}),W?.map(fe=>s.jsx("option",{value:fe.id,children:fe.name},fe.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:i,onChange:fe=>a(fe.target.value),children:[s.jsx("option",{value:"",children:"All Status"}),s.jsx("option",{value:"pending",children:"Pending"}),s.jsx("option",{value:"printing",children:"Printing"}),s.jsx("option",{value:"completed",children:"Completed"}),s.jsx("option",{value:"failed",children:"Failed"}),s.jsx("option",{value:"skipped",children:"Skipped"}),s.jsx("option",{value:"cancelled",children:"Cancelled"})]}),s.jsx("div",{className:"flex-1"}),Me.length>0&&s.jsxs(we,{variant:"secondary",size:"sm",onClick:()=>l(!0),children:[s.jsx(un,{className:"w-4 h-4"}),"Clear History"]})]}),j?s.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading..."}):K?.length===0?s.jsxs(Nt,{className:"p-12 text-center border-dashed",children:[s.jsx(ri,{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:"No prints scheduled"}),s.jsx("p",{className:"text-bambu-gray max-w-md mx-auto",children:'Schedule a print from the Archives page using the "Schedule" option in the context menu, or drag and drop files to get started.'})]}):s.jsxs("div",{className:"space-y-8",children:[ce.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"}),"Currently Printing"]}),s.jsx("div",{className:"space-y-3",children:ce.map(fe=>s.jsx(_j,{item:fe,onEdit:()=>{},onCancel:()=>{},onRemove:()=>{},onStop:()=>p({type:"stop",item:fe}),onRequeue:()=>{},onStart:()=>{},timeFormat:L},fe.id))})]}),ue.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(Kn,{className:"w-5 h-5 text-yellow-400"}),"Queued",s.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",ue.length," item",ue.length!==1?"s":"",")"]}),s.jsx("span",{className:"text-xs text-bambu-gray ml-2",title:"Position only affects ASAP items. Scheduled items run at their set time.",children:"Drag to reorder (ASAP only)"})]}),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:C,onChange:fe=>A(fe.target.value),children:[s.jsx("option",{value:"position",children:"Sort by Position"}),s.jsx("option",{value:"name",children:"Sort by Name"}),s.jsx("option",{value:"printer",children:"Sort by Printer"}),s.jsx("option",{value:"time",children:"Sort by Schedule"})]}),s.jsx(we,{variant:"ghost",size:"sm",onClick:()=>k(!O),title:O?"Ascending":"Descending",className:"px-2",children:O?s.jsx(rg,{className:"w-4 h-4"}):s.jsx(h0,{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(we,{variant:"ghost",size:"sm",onClick:pe,className:"flex items-center gap-2",children:[x.length===ue.length&&ue.length>0?s.jsx(Ro,{className:"w-4 h-4 text-bambu-green"}):s.jsx(Do,{className:"w-4 h-4"}),x.length===ue.length&&ue.length>0?"Deselect All":"Select All"]}),x.length>0&&s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"text-sm text-bambu-gray",children:[x.length," selected"]}),s.jsx("div",{className:"h-4 w-px bg-bambu-dark-tertiary"}),s.jsxs(we,{variant:"ghost",size:"sm",onClick:()=>v(!0),className:"flex items-center gap-2 text-bambu-green hover:text-bambu-green-light",children:[s.jsx(ia,{className:"w-4 h-4"}),"Edit Selected"]}),s.jsxs(we,{variant:"ghost",size:"sm",onClick:()=>ae.mutate(x),className:"flex items-center gap-2 text-red-400 hover:text-red-300",disabled:ae.isPending,children:[s.jsx(zt,{className:"w-4 h-4"}),"Cancel Selected"]})]})]}),s.jsx(fre,{sensors:R,collisionDetection:ere,onDragEnd:Ee,children:s.jsx(gre,{items:ue.map(fe=>fe.id),strategy:Nqe,children:s.jsx("div",{className:"space-y-3",children:ue.map((fe,le)=>s.jsx(_j,{item:fe,position:le+1,onEdit:()=>u(fe),onCancel:()=>p({type:"cancel",item:fe}),onRemove:()=>{},onStop:()=>{},onRequeue:()=>{},onStart:()=>ee.mutate(fe.id),timeFormat:L,isSelected:x.includes(fe.id),onToggleSelect:()=>se(fe.id)},fe.id))})})})]}),Me.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(Fn,{className:"w-5 h-5 text-bambu-gray"}),"History",s.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",Me.length," item",Me.length!==1?"s":"",")"]})]}),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:N,onChange:fe=>S(fe.target.value),children:[s.jsx("option",{value:"date",children:"Sort by Date"}),s.jsx("option",{value:"name",children:"Sort by Name"}),s.jsx("option",{value:"printer",children:"Sort by Printer"})]}),s.jsx(we,{variant:"ghost",size:"sm",onClick:()=>E(!T),title:T?"Ascending (oldest first)":"Descending (newest first)",className:"px-2",children:T?s.jsx(rg,{className:"w-4 h-4"}):s.jsx(h0,{className:"w-4 h-4"})})]})]}),s.jsx("div",{className:"space-y-3",children:Me.slice(0,20).map((fe,le)=>s.jsx(_j,{item:fe,position:le+1,onEdit:()=>{},onCancel:()=>{},onRemove:()=>p({type:"remove",item:fe}),onStop:()=>{},onRequeue:()=>f(fe),onStart:()=>{},timeFormat:L},fe.id))})]})]}),c&&s.jsx(Jd,{mode:"edit-queue-item",archiveId:c.archive_id??void 0,libraryFileId:c.library_file_id??void 0,archiveName:c.archive_name||c.library_file_name||`File #${c.archive_id||c.library_file_id}`,queueItem:c,onClose:()=>u(null)}),d&&s.jsx(Jd,{mode:"add-to-queue",archiveId:d.archive_id??void 0,libraryFileId:d.library_file_id??void 0,archiveName:d.archive_name||d.library_file_name||`File #${d.archive_id||d.library_file_id}`,onClose:()=>f(null)}),m&&s.jsx(Bn,{title:m.type==="cancel"?"Cancel Scheduled Print":m.type==="stop"?"Stop Print":"Remove from History",message:m.type==="cancel"?`Are you sure you want to cancel "${m.item.archive_name||m.item.library_file_name||"this print"}"?`:m.type==="stop"?`Are you sure you want to stop the current print "${m.item.archive_name||m.item.library_file_name||"this print"}"? This will cancel the print job on the printer.`:`Are you sure you want to remove "${m.item.archive_name||m.item.library_file_name||"this item"}" from the queue history?`,confirmText:m.type==="cancel"?"Cancel Print":m.type==="stop"?"Stop Print":"Remove",variant:"danger",onConfirm:()=>{m.type==="cancel"?Y.mutate(m.item.id):m.type==="stop"?Q.mutate(m.item.id):q.mutate(m.item.id),p(null)},onCancel:()=>p(null)}),o&&s.jsx(Bn,{title:"Clear History",message:`Are you sure you want to remove all ${Me.length} item${Me.length!==1?"s":""} from the history?`,confirmText:"Clear History",variant:"danger",onConfirm:()=>{z.mutate(),l(!1)},onCancel:()=>l(!1)}),b&&s.jsx(Iqe,{selectedCount:x.length,printers:W?.map(fe=>({id:fe.id,name:fe.name}))||[],onSave:fe=>{Object.keys(fe).length>0&&G.mutate({item_ids:x,...fe})},onClose:()=>v(!1),isSaving:G.isPending})]})}function Uqe({printDates:t,months:e=3}){const n=w.useRef(null),[r,i]=w.useState(0);w.useEffect(()=>{const N=n.current;if(!N)return;const S=new ResizeObserver(T=>{const E=T[0]?.contentRect.width||0;i(E)});return S.observe(N),()=>S.disconnect()},[]);const{weeks:a,monthLabels:o,printCounts:l}=w.useMemo(()=>{const N={};t.forEach(F=>{const L=F.split("T")[0];N[L]=(N[L]||0)+1});const S=new Date,T=new Date(S);T.setMonth(T.getMonth()-e),T.setDate(T.getDate()-T.getDay());const E=[],C=[];let A=[],O=-1;const k=new Date(T);let R=0;for(;k<=S;)k.getDay()===0&&A.length>0&&(E.push(A),A=[],R++),k.getMonth()!==O&&(C.push({month:k.toLocaleDateString("en-US",{month:"short"}),weekIndex:R}),O=k.getMonth()),A.push(new Date(k)),k.setDate(k.getDate()+1);return A.length>0&&E.push(A),{weeks:E,monthLabels:C,printCounts:N}},[t,e]),c=Math.max(1,...Object.values(l)),u=N=>{if(N===0)return"bg-bambu-dark";const S=N/c;return S<=.25?"bg-bambu-green/30":S<=.5?"bg-bambu-green/50":S<=.75?"bg-bambu-green/75":"bg-bambu-green"},d=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],f=a.length,m=32,p=2,x=r-m-16,y=f>0?Math.floor((x-(f-1)*p)/f):12,b=Math.max(8,Math.min(20,y)),v=b<=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:m+4},children:o.map(({month:N,weekIndex:S},T)=>s.jsx("div",{className:"text-bambu-gray",style:{fontSize:v,marginLeft:T===0?0:`${(S-(o[T-1]?.weekIndex||0))*(b+p)-24}px`},children:N},T))}),s.jsxs("div",{className:"flex",style:{gap:p},children:[s.jsx("div",{className:"flex flex-col",style:{gap:p,marginRight:4,width:m},children:d.map((N,S)=>s.jsx("div",{className:"text-bambu-gray flex items-center",style:{width:m,height:b,fontSize:v,visibility:S%2===1?"visible":"hidden"},children:N},N))}),a.map((N,S)=>s.jsx("div",{className:"flex flex-col",style:{gap:p},children:[0,1,2,3,4,5,6].map(T=>{const E=N.find(k=>k.getDay()===T);if(!E)return s.jsx("div",{style:{width:b,height:b}},T);const C=E.toISOString().split("T")[0],A=l[C]||0,O=C===new Date().toISOString().split("T")[0];return s.jsx("div",{className:`rounded-sm ${u(A)} ${O?"ring-1 ring-white":""}`,style:{width:b,height:b},title:`${E.toLocaleDateString()}: ${A} print${A!==1?"s":""}`},T)})},S))]}),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:p},children:[s.jsx("div",{className:"rounded-sm bg-bambu-dark",style:{width:b,height:b}}),s.jsx("div",{className:"rounded-sm bg-bambu-green/30",style:{width:b,height:b}}),s.jsx("div",{className:"rounded-sm bg-bambu-green/50",style:{width:b,height:b}}),s.jsx("div",{className:"rounded-sm bg-bambu-green/75",style:{width:b,height:b}}),s.jsx("div",{className:"rounded-sm bg-bambu-green",style:{width:b,height:b}})]}),s.jsx("span",{children:"More"})]})]})})}const O1=["#00ae42","#3b82f6","#f59e0b","#ef4444","#8b5cf6","#ec4899","#14b8a6","#f97316"];function zqe(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 Bqe({archives:t,currency:e="$"}){const[n,r]=w.useState("30d"),i=w.useMemo(()=>{const m=zqe(n);return t.filter(p=>(vi(p.completed_at||p.created_at)||new Date(0))>=m)},[t,n]),a=w.useMemo(()=>{const m=new Map;return i.forEach(p=>{const x=vi(p.completed_at||p.created_at)||new Date,y=`${x.getFullYear()}-${String(x.getMonth()+1).padStart(2,"0")}-${String(x.getDate()).padStart(2,"0")}`,b=m.get(y)||{date:y,filament:0,cost:0,prints:0};b.filament+=p.filament_used_grams||0,b.cost+=p.cost||0,b.prints+=1,m.set(y,b)}),Array.from(m.values()).sort((p,x)=>p.date.localeCompare(x.date)).map(p=>({...p,dateLabel:new Date(p.date).toLocaleDateString("en-US",{month:"short",day:"numeric"})}))},[i]),o=w.useMemo(()=>{if(n==="7d"||n==="30d")return a;const m=new Map;return i.forEach(p=>{const x=vi(p.completed_at||p.created_at)||new Date,y=new Date(x);y.setDate(x.getDate()-x.getDay());const b=`${y.getFullYear()}-${String(y.getMonth()+1).padStart(2,"0")}-${String(y.getDate()).padStart(2,"0")}`,v=m.get(b)||{week:b,filament:0,cost:0,prints:0};v.filament+=p.filament_used_grams||0,v.cost+=p.cost||0,v.prints+=1,m.set(b,v)}),Array.from(m.values()).sort((p,x)=>p.week.localeCompare(x.week)).map(p=>({date:p.week,dateLabel:`Week of ${new Date(p.week).toLocaleDateString("en-US",{month:"short",day:"numeric"})}`,...p}))},[i,a,n]),l=w.useMemo(()=>{const m=new Map;return i.forEach(p=>{const y=(p.filament_type||"Unknown").split(", ");y.forEach(b=>{const v=(p.filament_used_grams||0)/y.length;m.set(b,(m.get(b)||0)+v)})}),Array.from(m.entries()).map(([p,x])=>({name:p,value:Math.round(x)})).sort((p,x)=>x.value-p.value)},[i]),c=w.useMemo(()=>{const m=new Date,p=[];for(let x=5;x>=0;x--){const y=new Date(m.getFullYear(),m.getMonth()-x,1),b=new Date(m.getFullYear(),m.getMonth()-x+1,0),v=y.toLocaleDateString("en-US",{month:"short",year:"2-digit"}),N=t.filter(S=>{const T=vi(S.completed_at||S.created_at)||new Date(0);return T>=y&&T<=b});p.push({month:v,filament:Math.round(N.reduce((S,T)=>S+(T.filament_used_grams||0),0)),cost:N.reduce((S,T)=>S+(T.cost||0),0),prints:N.length})}return p},[t]),u=n==="7d"||n==="30d"?a:o,d=i.reduce((m,p)=>m+(p.filament_used_grams||0),0),f=i.reduce((m,p)=>m+(p.cost||0),0);return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("h3",{className:"text-lg font-semibold text-white",children:"Filament Usage Trends"}),s.jsx("div",{className:"flex gap-1 bg-bambu-dark rounded-lg p-1",children:["7d","30d","90d","365d","all"].map(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:[i.length," prints"]})]}),s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Avg per Print"}),s.jsxs("p",{className:"text-2xl font-bold text-white",children:[i.length>0?(d/i.length).toFixed(0):0,"g"]}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[e,i.length>0?(f/i.length).toFixed(2):"0.00"," avg"]})]})]}),u.length>0?s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[s.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"Usage Over Time"}),s.jsx(G1,{width:"100%",height:250,children:s.jsxs(Ike,{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(mS,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),s.jsx(gS,{dataKey:"dateLabel",stroke:"#9ca3af",tick:{fontSize:12},interval:"preserveStartEnd"}),s.jsx(xS,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:m=>`${m}g`}),s.jsx(q1,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},labelStyle:{color:"#fff"},formatter:m=>[`${Number(m??0).toFixed(0)}g`,"Filament"]}),s.jsx(yZ,{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(G1,{width:160,height:160,children:s.jsxs(Oke,{children:[s.jsx(HQ,{data:l,cx:"50%",cy:"50%",innerRadius:40,outerRadius:70,paddingAngle:2,dataKey:"value",children:l.map((m,p)=>s.jsx(jy,{fill:O1[p%O1.length]},`cell-${p}`))}),s.jsx(q1,{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,p)=>{const x=l.reduce((b,v)=>b+v.value,0),y=x>0?(m.value/x*100).toFixed(0):0;return s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx("div",{className:"w-3 h-3 rounded-sm flex-shrink-0",style:{backgroundColor:O1[p%O1.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(G1,{width:"100%",height:200,children:s.jsxs(Ske,{data:c,children:[s.jsx(mS,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),s.jsx(gS,{dataKey:"month",stroke:"#9ca3af",tick:{fontSize:12}}),s.jsx(xS,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:m=>`${m}g`}),s.jsx(q1,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},formatter:(m,p)=>[p==="filament"?`${m??0}g`:p==="cost"?`${e}${Number(m??0).toFixed(2)}`:m??0,p==="filament"?"Filament":p==="cost"?"Cost":"Prints"]}),s.jsx(VD,{}),s.jsx(XQ,{dataKey:"filament",name:"Filament (g)",fill:"#00ae42",radius:[4,4,0,0]})]})})]})]})]})}function $qe({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:m}=bre({id:t}),p={transform:Rg.Transform.toString(d),transition:f,opacity:m?.5:1};return r?null:s.jsxs("div",{ref:u,style:{...p,gridColumn:`span ${i}`},className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary overflow-hidden ${m?"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(ig,{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(lq,{className:"w-4 h-4 text-bambu-gray hover:text-white"}):s.jsx(oq,{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(D2,{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 Hqe({widgets:t,storageKey:e,columns:n=4,hideControls:r=!1,onResetLayout:i,renderControls:a}){const o=()=>{const T={};return t.forEach(E=>{T[E.id]=E.defaultSize||4}),T},[l,c]=w.useState(()=>{const T=localStorage.getItem(e);if(T)try{const E=JSON.parse(T);return E.sizes||(E.sizes=o()),E}catch{}return{order:t.map(E=>E.id),hidden:t.filter(E=>E.defaultVisible===!1).map(E=>E.id),sizes:o()}}),[u,d]=w.useState(!1);w.useEffect(()=>{const T=()=>d(E=>!E);return window.addEventListener("toggle-hidden-panel",T),()=>window.removeEventListener("toggle-hidden-panel",T)},[]),w.useEffect(()=>{localStorage.setItem(e,JSON.stringify(l))},[l,e]),w.useEffect(()=>{const E=t.map(C=>C.id).filter(C=>!l.order.includes(C));E.length>0&&c(C=>({...C,order:[...C.order,...E]}))},[t,l.order]);const f=Yne(M2(mM,{activationConstraint:{distance:8}}),M2(fM,{coordinateGetter:yre})),m=T=>{const{active:E,over:C}=T;C&&E.id!==C.id&&c(A=>{const O=A.order.indexOf(E.id),k=A.order.indexOf(C.id);return{...A,order:xM(A.order,O,k)}})},p=T=>{c(E=>({...E,hidden:E.hidden.includes(T)?E.hidden.filter(C=>C!==T):[...E.hidden,T]}))},x=T=>{c(E=>{const C=E.sizes[T]||4,A=C===1?2:C===2?4:1;return{...E,sizes:{...E.sizes,[T]:A}}})},y=()=>{const T={order:t.map(E=>E.id),hidden:t.filter(E=>E.defaultVisible===!1).map(E=>E.id),sizes:o()};c(T),i?.()},b=l.order.map(T=>t.find(E=>E.id===T)).filter(Boolean),v=b.filter(T=>!l.hidden.includes(T.id)),N=b.filter(T=>l.hidden.includes(T.id)),S=a?.({hiddenCount:N.length,showHiddenPanel:u,setShowHiddenPanel:d,resetLayout:y});return s.jsxs("div",{className:"space-y-4",children:[S,!r&&!a&&s.jsxs("div",{className:"flex items-center justify-end gap-2",children:[s.jsxs(we,{variant:"secondary",size:"sm",onClick:y,children:[s.jsx(Zf,{className:"w-4 h-4"}),"Reset Layout"]}),N.length>0&&s.jsxs(we,{variant:"secondary",size:"sm",onClick:()=>d(!u),children:[s.jsx(Cf,{className:"w-4 h-4"}),N.length," Hidden"]})]}),u&&N.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:N.map(T=>s.jsxs("button",{onClick:()=>p(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(Cf,{className:"w-3 h-3"}),T.title]},T.id))})]}),s.jsx(fre,{sensors:f,collisionDetection:ere,onDragEnd:m,children:s.jsx(gre,{items:v.map(T=>T.id),strategy:BL,children:s.jsx("div",{className:"grid gap-6",style:{gridTemplateColumns:`repeat(${n}, minmax(0, 1fr))`},children:v.map(T=>s.jsx($qe,{id:T.id,title:T.title,component:T.component,isHidden:l.hidden.includes(T.id),size:l.sizes[T.id]||2,onToggleVisibility:()=>p(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(we,{className:"mt-4",onClick:y,children:"Reset Layout"})]})]})}function Vqe({stats:t,currency:e}){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(zl,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray",children:"Total Prints"}),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(Kn,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray",children:"Print Time"}),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(zl,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray",children:"Filament Used"}),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(Gj,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray",children:"Filament Cost"}),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(Pf,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray",children:"Energy Used"}),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(Gj,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray",children:"Energy Cost"}),s.jsxs("p",{className:"text-xl font-bold text-white",children:[e," ",t?.total_energy_cost.toFixed(2)||"0.00"]})]})]})]})}function Gqe({stats:t,printerMap:e,size:n=1}){const r=t?.total_prints?Math.round(t.successful_prints/t.total_prints*100):0,i=n===1?112:n===2?128:144,a=i/2-8,o=a*2*Math.PI;return s.jsxs("div",{className:"flex items-center gap-6",children:[s.jsxs("div",{className:"relative flex-shrink-0",style:{width:i,height:i},children:[s.jsxs("svg",{className:"w-full h-full -rotate-90",children:[s.jsx("circle",{cx:i/2,cy:i/2,r:a,fill:"none",stroke:"#3d3d3d",strokeWidth:"10"}),s.jsx("circle",{cx:i/2,cy:i/2,r:a,fill:"none",stroke:"#00ae42",strokeWidth:"10",strokeLinecap:"round",strokeDasharray:`${r/100*o} ${o}`})]}),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:[r,"%"]})})]}),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(Fn,{className:"w-4 h-4 text-status-ok flex-shrink-0"}),s.jsx("span",{className:"text-sm text-bambu-gray",children:"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(ta,{className:"w-4 h-4 text-status-error flex-shrink-0"}),s.jsx("span",{className:"text-sm text-bambu-gray",children:"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:"Prints by Printer"}),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(([l,c])=>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(l)||`Printer ${l}`}),s.jsx("span",{className:"text-white font-medium",children:c})]},l))})]})]})]})}function Wqe({stats:t,printerMap:e,size:n=1}){const r=t?.average_time_accuracy;if(r==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:"No time accuracy data yet"})});const a=(Math.min(150,Math.max(50,r))-50)/100*100,l=(x=>x>=95&&x<=105?"#00ae42":x>105?"#3b82f6":"#f97316")(r),c=r-100,u=n===1?112:n===2?128:144,d=u/2-8,f=d*2*Math.PI,m=n===1?3:n===2?6:999,p=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:u,height:u},children:[s.jsxs("svg",{className:"w-full h-full -rotate-90",children:[s.jsx("circle",{cx:u/2,cy:u/2,r:d,fill:"none",stroke:"#3d3d3d",strokeWidth:"10"}),s.jsx("circle",{cx:u/2,cy:u/2,r:d,fill:"none",stroke:l,strokeWidth:"10",strokeLinecap:"round",strokeDasharray:`${a/100*f} ${f}`})]}),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:[r.toFixed(0),"%"]}),s.jsxs("span",{className:`text-xs ${c>=0?"text-blue-400":"text-orange-400"}`,children:[c>=0?"+":"",c.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(fq,{className:"w-3 h-3 flex-shrink-0"}),s.jsx("span",{children:"100% = perfect estimate"})]}),p.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:p.map(([x,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(x)||`Printer ${x}`}),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),"%"]})]},x))})]})]})}function qqe({stats:t,size:e=1}){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:"No filament data available"});const n=Object.entries(t.prints_by_filament_type).sort(([,o],[,l])=>l-o),r=e===1?5:e===2?8:999,i=n.slice(0,r),a=n.length>r;return e===4&&i.length>4?s.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-3 gap-4",children:i.map(([o,l])=>{const c=Math.round(l/(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:o}),s.jsx("span",{className:"text-bambu-gray",children:l})]}),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:`${c}%`}})})]},o)})}):s.jsxs("div",{className:"space-y-3",children:[i.map(([o,l])=>{const c=Math.round(l/(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:o}),s.jsxs("span",{className:"text-bambu-gray",children:[l," 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:`${c}%`}})})]},o)}),a&&s.jsxs("p",{className:"text-xs text-bambu-gray text-center pt-1",children:["+",n.length-r," more types"]})]})}function Kqe({printDates:t,size:e=2}){const n=e===1?3:e===2?6:12;return s.jsx(Uqe,{printDates:t,months:n})}function Xqe({stats:t,printerMap:e}){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:"No printer data available"}):s.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:Object.entries(t.prints_by_printer).map(([n,r])=>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(Mr,{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(n)||`Printer ${n}`}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[r," prints"]})]})]},n))})}function Yqe({archives:t,currency:e}){return!t||t.length===0?s.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No print data available"}):s.jsx(Bqe,{archives:t,currency:e})}function Qqe({size:t=1}){const{data:e,isLoading:n}=ut({queryKey:["failureAnalysis"],queryFn:()=>he.getFailureAnalysis({days:30})});if(n)return s.jsx("div",{className:"flex justify-center py-4",children:s.jsx(dt,{className:"w-6 h-6 text-bambu-green animate-spin"})});if(!e||e.total_prints===0)return s.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No print data in the last 30 days"});const r=t===1?5:t===2?8:999,i=Object.entries(e.failures_by_reason).sort(([,l],[,c])=>c-l),a=i.slice(0,r),o=i.length>r;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(yn,{className:`w-5 h-5 ${e.failure_rate>20?"text-status-error":e.failure_rate>10?"text-status-warning":"text-status-ok"}`}),s.jsxs("span",{className:`font-bold text-white ${t>=2?"text-3xl":"text-2xl"}`,children:[e.failure_rate.toFixed(1),"%"]})]})}),s.jsxs("div",{className:"text-sm text-bambu-gray mt-1",children:[e.failed_prints," / ",e.total_prints," prints failed"]}),e.trend&&e.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(pq,{className:`w-4 h-4 ${e.trend[e.trend.length-1].failure_rate<e.trend[e.trend.length-2].failure_rate?"text-status-ok":"text-status-error"}`}),s.jsxs("span",{className:"text-bambu-gray",children:["Last week: ",e.trend[e.trend.length-1].failure_rate.toFixed(1),"%"]})]})})]}),a.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?"Failure Reasons":"Top Failure Reasons"}),s.jsx("div",{className:`${t===4?"grid grid-cols-2 gap-x-6 gap-y-1":"space-y-1"}`,children:a.map(([l,c])=>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:l||"Unknown"}),s.jsx("span",{className:"text-bambu-gray ml-2",children:c})]},l))}),o&&s.jsxs("p",{className:"text-xs text-bambu-gray mt-2",children:["+",i.length-r," more reasons"]})]})]})}function Zqe(){const{showToast:t}=Vn(),[e,n]=w.useState(!1),[r,i]=w.useState(!1),[a,o]=w.useState(0),[l,c]=w.useState(0),[u,d]=w.useState(!1);w.useEffect(()=>{const A=()=>{try{const k=localStorage.getItem("bambusy-dashboard-layout");if(k){const R=JSON.parse(k);c(R.hidden?.length||0)}}catch{c(0)}};A(),window.addEventListener("storage",A);const O=setInterval(A,500);return()=>{window.removeEventListener("storage",A),clearInterval(O)}},[a]);const{data:f,isLoading:m,refetch:p}=ut({queryKey:["archiveStats"],queryFn:he.getArchiveStats}),{data:x}=ut({queryKey:["printers"],queryFn:he.getPrinters}),{data:y}=ut({queryKey:["archives"],queryFn:()=>he.getArchives(void 0,void 0,1e3,0)}),{data:b}=ut({queryKey:["settings"],queryFn:he.getSettings}),v=async A=>{i(!1),n(!0);try{const{blob:O,filename:k}=await he.exportStats({format:A,days:90}),R=URL.createObjectURL(O),F=document.createElement("a");F.href=R,F.download=k,F.click(),URL.revokeObjectURL(R),t("Export downloaded")}catch{t("Export failed","error")}finally{n(!1)}},N=async()=>{d(!0);try{const A=await he.recalculateCosts();await p(),t(`Recalculated costs for ${A.updated} archives`)}catch{t("Failed to recalculate costs","error")}finally{d(!1)}},S=b?.currency||"$",T=new Map(x?.map(A=>[String(A.id),A.name])||[]),E=y?.map(A=>A.created_at)||[];if(m)return s.jsx("div",{className:"p-4 md:p-8",children:s.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading statistics..."})});const C=[{id:"quick-stats",title:"Quick Stats",component:s.jsx(Vqe,{stats:f,currency:S}),defaultSize:2},{id:"success-rate",title:"Success Rate",component:A=>s.jsx(Gqe,{stats:f,printerMap:T,size:A}),defaultSize:1},{id:"time-accuracy",title:"Time Accuracy",component:A=>s.jsx(Wqe,{stats:f,printerMap:T,size:A}),defaultSize:1},{id:"filament-types",title:"Filament Types",component:A=>s.jsx(qqe,{stats:f,size:A}),defaultSize:1},{id:"failure-analysis",title:"Failure Analysis (30 days)",component:A=>s.jsx(Qqe,{size:A}),defaultSize:1},{id:"print-activity",title:"Print Activity",component:A=>s.jsx(Kqe,{printDates:E,size:A}),defaultSize:2},{id:"prints-by-printer",title:"Prints by Printer",component:s.jsx(Xqe,{stats:f,printerMap:T}),defaultSize:2},{id:"filament-trends",title:"Filament Usage Trends",component:s.jsx(Yqe,{archives:y||[],currency:S}),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:"Dashboard"}),s.jsx("p",{className:"text-bambu-gray",children:"Drag widgets to rearrange. Click the eye icon to hide."})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[l>0&&s.jsxs(we,{variant:"secondary",onClick:()=>{window.dispatchEvent(new CustomEvent("toggle-hidden-panel"))},children:[s.jsx(Cf,{className:"w-4 h-4"}),l," Hidden"]}),s.jsxs(we,{variant:"secondary",onClick:()=>{localStorage.removeItem("bambusy-dashboard-layout"),o(A=>A+1),t("Layout reset")},children:[s.jsx(Zf,{className:"w-4 h-4"}),"Reset Layout"]}),s.jsxs(we,{variant:"secondary",onClick:N,disabled:u,title:"Recalculate all archive costs using current filament prices",children:[u?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(Ace,{className:"w-4 h-4"}),"Recalculate Costs"]}),s.jsxs("div",{className:"relative",children:[s.jsxs(we,{variant:"secondary",onClick:()=>i(!r),disabled:e,children:[e?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(bw,{className:"w-4 h-4"}),"Export Stats"]}),r&&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:()=>v("csv"),children:[s.jsx(Ga,{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:()=>v("xlsx"),children:[s.jsx(bw,{className:"w-4 h-4"}),"Export as Excel"]})]})]})]})]}),s.jsx(Hqe,{widgets:C,storageKey:"bambusy-dashboard-layout",hideControls:!0},a)]})}function Jqe({plug:t,onEdit:e}){const n=on(),{showToast:r}=Vn(),[i,a]=w.useState(!1),[o,l]=w.useState(!1),[c,u]=w.useState(!1),[d,f]=w.useState(!1),{data:m,isLoading:p}=ut({queryKey:["smart-plug-status",t.id],queryFn:()=>he.getSmartPlugStatus(t.id),refetchInterval:3e4}),{data:x}=ut({queryKey:["printers"],queryFn:he.getPrinters}),y=x?.find(O=>O.id===t.printer_id),b=pt({mutationFn:O=>he.controlSmartPlug(t.id,O),onMutate:async O=>{await n.cancelQueries({queryKey:["smart-plug-status",t.id]});const k=n.getQueryData(["smart-plug-status",t.id]),R=O==="on"?"ON":O==="off"||m?.state==="ON"?"OFF":"ON";return n.setQueryData(["smart-plug-status",t.id],F=>({...F,state:R})),{previousStatus:k}},onError:(O,k,R)=>{R?.previousStatus&&n.setQueryData(["smart-plug-status",t.id],R.previousStatus),r(`Failed to turn ${k} "${t.name}"`,"error")},onSettled:()=>{setTimeout(()=>{n.invalidateQueries({queryKey:["smart-plug-status",t.id]}),n.invalidateQueries({queryKey:["smart-plugs"]})},1e3)}}),v=pt({mutationFn:O=>he.updateSmartPlug(t.id,O),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),t.printer_id&&n.invalidateQueries({queryKey:["smartPlugByPrinter",t.printer_id]})}}),N=pt({mutationFn:()=>he.deleteSmartPlug(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]})}}),S=m?.state==="ON",T=m?.reachable??!1,E=b.isPending,A=(()=>{if(t.plug_type!=="tasmota"||!t.ip_address)return null;const O=t.ip_address;return t.username&&t.password?`http://${encodeURIComponent(t.username)}:${encodeURIComponent(t.password)}@${O}/`:`http://${O}/`})();return s.jsxs(s.Fragment,{children:[s.jsx(Nt,{className:"relative",children:s.jsxs(Et,{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?S?"bg-bambu-green/20":"bg-bambu-dark":"bg-red-500/20"}`,children:t.plug_type==="homeassistant"?s.jsx(U2,{className:`w-5 h-5 ${T?S?"text-bambu-green":"text-bambu-gray":"text-red-400"}`}):s.jsx(Vs,{className:`w-5 h-5 ${T?S?"text-bambu-green":"text-bambu-gray":"text-red-400"}`})}),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:t.plug_type==="homeassistant"?t.ha_entity_id:t.ip_address})]})]}),s.jsxs("div",{className:"flex flex-col items-end gap-1",children:[p?s.jsx(dt,{className:"w-4 h-4 text-bambu-gray animate-spin"}):T?s.jsxs("div",{className:"flex items-center gap-1 text-sm",children:[s.jsx(Hp,{className:"w-4 h-4 text-status-ok"}),s.jsx("span",{className:S?"text-status-ok":"text-bambu-gray",children:m?.state||"Unknown"})]}):s.jsxs("div",{className:"flex items-center gap-1 text-sm text-status-error",children:[s.jsx(zg,{className:"w-4 h-4"}),s.jsx("span",{children:"Offline"})]}),A&&s.jsxs("a",{href:A,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(Ur,{className:"w-3 h-3"}),"Admin"]})]})]}),y&&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:y.name})]}),(t.power_alert_enabled||t.schedule_enabled)&&s.jsxs("div",{className:"flex flex-wrap gap-1.5 mb-3",children:[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(cf,{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(ri,{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}`]})]}),s.jsxs("div",{className:"flex gap-2 mb-3",children:[s.jsxs(we,{size:"sm",variant:S?"primary":"secondary",disabled:!T||E,onClick:()=>l(!0),className:"flex-1",children:[E?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(gu,{className:"w-4 h-4"}),"On"]}),s.jsxs(we,{size:"sm",variant:S?"secondary":"primary",disabled:!T||E,onClick:()=>u(!0),className:"flex-1",children:[E?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(H2,{className:"w-4 h-4"}),"Off"]})]}),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(Bd,{className:"w-4 h-4"}),"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(z2,{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:O=>v.mutate({show_in_switchbar:O.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:"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:O=>v.mutate({enabled:O.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:O=>v.mutate({auto_on:O.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:O=>v.mutate({auto_off:O.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(Kn,{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(G2,{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:O=>v.mutate({off_delay_minutes:parseInt(O.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:O=>v.mutate({off_temp_threshold:parseInt(O.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(we,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[s.jsx($2,{className:"w-4 h-4"}),"Edit"]}),s.jsx(we,{size:"sm",variant:"secondary",onClick:()=>a(!0),className:"text-red-400 hover:text-red-300",children:s.jsx(un,{className:"w-4 h-4"})})]})]})]})}),i&&s.jsx(Bn,{title:"Delete Smart Plug",message:`Are you sure you want to delete "${t.name}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{N.mutate(),a(!1)},onCancel:()=>a(!1)}),o&&s.jsx(Bn,{title:"Turn On Smart Plug",message:`Are you sure you want to turn on "${t.name}"?`,confirmText:"Turn On",variant:"default",onConfirm:()=>{b.mutate("on"),l(!1)},onCancel:()=>l(!1)}),c&&s.jsx(Bn,{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:()=>{b.mutate("off"),u(!1)},onCancel:()=>u(!1)})]})}function eKe({plug:t,onClose:e}){const n=on(),r=!!t,[i,a]=w.useState(t?.plug_type||"tasmota"),[o,l]=w.useState(t?.name||""),[c,u]=w.useState(t?.ip_address||""),[d,f]=w.useState(t?.username||""),[m,p]=w.useState(t?.password||""),[x,y]=w.useState(t?.ha_entity_id||""),[b,v]=w.useState(t?.ha_power_entity||""),[N,S]=w.useState(t?.ha_energy_today_entity||""),[T,E]=w.useState(t?.ha_energy_total_entity||""),[C,A]=w.useState(""),[O,k]=w.useState(""),[R,F]=w.useState(!1),L=w.useRef(null),[K,j]=w.useState(""),[W,Y]=w.useState(!1),q=w.useRef(null),[Q,ee]=w.useState(""),[re,z]=w.useState(!1),G=w.useRef(null),[ae,se]=w.useState(""),[ue,pe]=w.useState(!1),ce=w.useRef(null),[Me,me]=w.useState(t?.printer_id||null),[Ee,fe]=w.useState(null),[le,Be]=w.useState(null),[V,$]=w.useState(t?.power_alert_enabled||!1),[X,U]=w.useState(t?.power_alert_high?.toString()||""),[B,oe]=w.useState(t?.power_alert_low?.toString()||""),[Te,je]=w.useState(t?.schedule_enabled||!1),[Ce,H]=w.useState(t?.schedule_on_time||""),[D,Z]=w.useState(t?.schedule_off_time||""),[xe,Ne]=w.useState(t?.show_in_switchbar||!1),[ve,$e]=w.useState(!1),[Le,qe]=w.useState({scanned:0,total:0}),[Ke,Ye]=w.useState([]),ie=w.useRef(null),{data:te}=ut({queryKey:["printers"],queryFn:he.getPrinters}),{data:Se}=ut({queryKey:["smart-plugs"],queryFn:he.getSmartPlugs}),{data:ze}=ut({queryKey:["settings"],queryFn:he.getSettings}),nt=!!(ze?.ha_enabled&&ze?.ha_url&&ze?.ha_token);w.useEffect(()=>{const bt=setTimeout(()=>{k(C)},300);return()=>clearTimeout(bt)},[C]),w.useEffect(()=>{const bt=Gt=>{L.current&&!L.current.contains(Gt.target)&&F(!1),q.current&&!q.current.contains(Gt.target)&&Y(!1),G.current&&!G.current.contains(Gt.target)&&z(!1),ce.current&&!ce.current.contains(Gt.target)&&pe(!1)};return document.addEventListener("mousedown",bt),()=>document.removeEventListener("mousedown",bt)},[]);const{data:ne,isLoading:Pe,error:be}=ut({queryKey:["ha-entities",O],queryFn:()=>he.getHAEntities(O||void 0),enabled:i==="homeassistant"&&nt,retry:!1,staleTime:0}),{data:Oe}=ut({queryKey:["ha-sensor-entities"],queryFn:he.getHASensorEntities,enabled:i==="homeassistant"&&nt,retry:!1,staleTime:0});w.useEffect(()=>{const bt=Gt=>{Gt.key==="Escape"&&e()};return window.addEventListener("keydown",bt),()=>{window.removeEventListener("keydown",bt),ie.current&&clearInterval(ie.current)}},[e]);const Ue=async()=>{$e(!0),Ye([]),qe({scanned:0,total:0}),Be(null);try{await he.startTasmotaScan();const bt=async()=>{try{const Gt=await he.getTasmotaScanStatus();qe({scanned:Gt.scanned,total:Gt.total});const ln=await he.getDiscoveredTasmotaDevices();Ye(ln),Gt.running||($e(!1),ie.current&&(clearInterval(ie.current),ie.current=null))}catch(Gt){console.error("Polling error:",Gt)}};await bt(),ie.current=setInterval(bt,500)}catch(bt){$e(!1);const Gt=bt instanceof Error?bt.message:typeof bt=="string"?bt:JSON.stringify(bt);Be(Gt||"Failed to start scan")}},Ae=async()=>{try{await he.stopTasmotaScan()}catch{}$e(!1),ie.current&&(clearInterval(ie.current),ie.current=null)},Je=bt=>{u(bt.ip_address),l(bt.name),fe(null)},gt=pt({mutationFn:()=>he.testSmartPlugConnection(c,d||null,m||null),onSuccess:bt=>{fe(bt),Be(null),!o&&bt.device_name&&l(bt.device_name)},onError:bt=>{fe(null),Be(bt.message)}}),Pt=pt({mutationFn:bt=>he.createSmartPlug(bt),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),e()},onError:bt=>{Be(bt.message)}}),Ot=pt({mutationFn:bt=>he.updateSmartPlug(t.id,bt),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),e()},onError:bt=>{Be(bt.message)}}),cn=te?.filter(bt=>!Se?.some(ln=>ln.printer_id===bt.id&&ln.id!==t?.id)),It=bt=>{if(bt.preventDefault(),Be(null),!o.trim()){Be("Name is required");return}if(i==="tasmota"&&!c.trim()){Be("IP address is required for Tasmota plugs");return}if(i==="homeassistant"&&!x){Be("Entity is required for Home Assistant plugs");return}const Gt={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"&&b||null,ha_energy_today_entity:i==="homeassistant"&&N||null,ha_energy_total_entity:i==="homeassistant"&&T||null,username:i==="tasmota"&&d.trim()||null,password:i==="tasmota"&&m.trim()||null,printer_id:Me,power_alert_enabled:V,power_alert_high:X?parseFloat(X):null,power_alert_low:B?parseFloat(B):null,schedule_enabled:Te,schedule_on_time:Ce||null,schedule_off_time:D||null,show_in_switchbar:xe};r?Ot.mutate(Gt):Pt.mutate(Gt)},_n=Pt.isPending||Ot.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:bt=>bt.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(zt,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:It,className:"p-6 space-y-4 overflow-y-auto",children:[le&&s.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:le}),!r&&s.jsxs("div",{className:"flex gap-2 mb-2",children:[s.jsxs("button",{type:"button",onClick:()=>{a("tasmota"),fe(null),Be(null)},className:`flex-1 flex items-center justify-center gap-2 px-4 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(Vs,{className:"w-4 h-4"}),"Tasmota"]}),s.jsxs("button",{type:"button",onClick:()=>{a("homeassistant"),fe(null),Be(null)},className:`flex-1 flex items-center justify-center gap-2 px-4 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(U2,{className:"w-4 h-4"}),"Home Assistant"]})]}),!r&&i==="tasmota"&&s.jsxs("div",{className:"space-y-3",children:[ve?s.jsxs(we,{type:"button",variant:"secondary",onClick:Ae,className:"w-full",children:[s.jsx(zt,{className:"w-4 h-4"}),"Stop Scanning"]}):s.jsxs(we,{type:"button",variant:"primary",onClick:Ue,className:"w-full",children:[s.jsx(_a,{className:"w-4 h-4"}),"Discover Tasmota Devices"]}),ve&&Le.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:[Le.scanned," / ",Le.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:`${Le.scanned/Le.total*100}%`}})})]}),Ke.length>0&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("p",{className:"text-xs text-bambu-gray",children:["Found ",Ke.length," device(s) - click to select:"]}),s.jsx("div",{className:"max-h-40 overflow-y-auto space-y-1",children:Ke.map(bt=>s.jsxs("button",{type:"button",onClick:()=>Je(bt),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(Vs,{className:"w-4 h-4 text-bambu-green"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:bt.name}),s.jsx("p",{className:"text-xs text-bambu-gray",children:bt.ip_address})]})]}),bt.state&&s.jsxs("span",{className:`flex items-center gap-1 text-xs ${bt.state==="ON"?"text-bambu-green":"text-bambu-gray"}`,children:[s.jsx(gu,{className:"w-3 h-3"}),bt.state]})]},bt.ip_address))})]}),!ve&&Ke.length===0&&Le.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:[!nt&&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..."})})]})]}),nt&&s.jsxs(s.Fragment,{children:[Pe&&s.jsxs("div",{className:"flex items-center justify-center py-4 text-bambu-gray",children:[s.jsx(dt,{className:"w-5 h-5 animate-spin mr-2"}),"Loading entities..."]}),be&&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: ",be.message]}),(()=>{const bt=Se?.filter(Tt=>Tt.ha_entity_id&&Tt.id!==t?.id).map(Tt=>Tt.ha_entity_id)||[],Gt=(ne||[]).filter(Tt=>!bt.includes(Tt.entity_id)),ln=ne?.find(Tt=>Tt.entity_id===x);return s.jsxs("div",{ref:L,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(_a,{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:R?C:ln?`${ln.friendly_name} (${ln.entity_id})`:"",onChange:Tt=>{A(Tt.target.value),R||F(!0)},onFocus:()=>{F(!0),A("")},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&&!R&&s.jsx("button",{type:"button",onClick:()=>{y(""),A("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:s.jsx(zt,{className:"w-4 h-4 text-bambu-gray hover:text-white"})}),Pe&&s.jsx(dt,{className:"absolute right-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray animate-spin"})]}),R&&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:[Pe&&s.jsxs("div",{className:"px-3 py-2 text-sm text-bambu-gray flex items-center gap-2",children:[s.jsx(dt,{className:"w-4 h-4 animate-spin"}),"Loading..."]}),!Pe&&Gt.length===0&&s.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:O?`No entities found matching "${O}"`:"No entities available"}),!Pe&&Gt.map(Tt=>s.jsxs("button",{type:"button",onClick:()=>{y(Tt.entity_id),F(!1),A(""),o||l(Tt.friendly_name)},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary transition-colors ${Tt.entity_id===x?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[s.jsx("div",{className:"font-medium",children:Tt.friendly_name}),s.jsxs("div",{className:"text-xs text-bambu-gray flex items-center justify-between",children:[s.jsx("span",{children:Tt.entity_id}),s.jsx("span",{className:Tt.state==="on"?"text-bambu-green":"",children:Tt.state})]})]},Tt.entity_id))]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:O?`Searching all entities (${Gt.length} found)`:`Showing switch, light, input_boolean (${Gt.length} available)`})]})})(),x&&Oe&&Oe.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 bt=Oe.filter(Tt=>Tt.unit_of_measurement==="W"||Tt.unit_of_measurement==="kW"||Tt.unit_of_measurement==="mW"),Gt=K?bt.filter(Tt=>Tt.entity_id.toLowerCase().includes(K.toLowerCase())||Tt.friendly_name.toLowerCase().includes(K.toLowerCase())):bt,ln=Oe.find(Tt=>Tt.entity_id===b);return s.jsxs("div",{ref:q,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(_a,{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:W?K:ln?`${ln.friendly_name} (${ln.state} ${ln.unit_of_measurement})`:"",onChange:Tt=>{j(Tt.target.value),W||Y(!0)},onFocus:()=>{Y(!0),j("")},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"}),b&&!W&&s.jsx("button",{type:"button",onClick:()=>{v(""),j("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:s.jsx(zt,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]}),W&&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:()=>{v(""),Y(!1),j("")},className:"w-full px-3 py-2 text-left text-sm text-bambu-gray hover:bg-bambu-dark-tertiary",children:"None"}),Gt.map(Tt=>s.jsxs("button",{type:"button",onClick:()=>{v(Tt.entity_id),Y(!1),j("")},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${Tt.entity_id===b?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[s.jsx("div",{className:"font-medium",children:Tt.friendly_name}),s.jsxs("div",{className:"text-xs text-bambu-gray",children:[Tt.entity_id," • ",Tt.state," ",Tt.unit_of_measurement]})]},Tt.entity_id)),Gt.length===0&&s.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No matching sensors"})]})]})})(),(()=>{const bt=Oe.filter(Tt=>Tt.unit_of_measurement==="kWh"||Tt.unit_of_measurement==="Wh"||Tt.unit_of_measurement==="MWh"),Gt=Q?bt.filter(Tt=>Tt.entity_id.toLowerCase().includes(Q.toLowerCase())||Tt.friendly_name.toLowerCase().includes(Q.toLowerCase())):bt,ln=Oe.find(Tt=>Tt.entity_id===N);return s.jsxs("div",{ref:G,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(_a,{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:re?Q:ln?`${ln.friendly_name} (${ln.state} ${ln.unit_of_measurement})`:"",onChange:Tt=>{ee(Tt.target.value),re||z(!0)},onFocus:()=>{z(!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"}),N&&!re&&s.jsx("button",{type:"button",onClick:()=>{S(""),ee("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:s.jsx(zt,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]}),re&&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:()=>{S(""),z(!1),ee("")},className:"w-full px-3 py-2 text-left text-sm text-bambu-gray hover:bg-bambu-dark-tertiary",children:"None"}),Gt.map(Tt=>s.jsxs("button",{type:"button",onClick:()=>{S(Tt.entity_id),z(!1),ee("")},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${Tt.entity_id===N?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[s.jsx("div",{className:"font-medium",children:Tt.friendly_name}),s.jsxs("div",{className:"text-xs text-bambu-gray",children:[Tt.entity_id," • ",Tt.state," ",Tt.unit_of_measurement]})]},Tt.entity_id)),Gt.length===0&&s.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No matching sensors"})]})]})})(),(()=>{const bt=Oe.filter(Tt=>Tt.unit_of_measurement==="kWh"||Tt.unit_of_measurement==="Wh"||Tt.unit_of_measurement==="MWh"),Gt=ae?bt.filter(Tt=>Tt.entity_id.toLowerCase().includes(ae.toLowerCase())||Tt.friendly_name.toLowerCase().includes(ae.toLowerCase())):bt,ln=Oe.find(Tt=>Tt.entity_id===T);return s.jsxs("div",{ref:ce,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(_a,{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:ue?ae:ln?`${ln.friendly_name} (${ln.state} ${ln.unit_of_measurement})`:"",onChange:Tt=>{se(Tt.target.value),ue||pe(!0)},onFocus:()=>{pe(!0),se("")},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"}),T&&!ue&&s.jsx("button",{type:"button",onClick:()=>{E(""),se("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:s.jsx(zt,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]}),ue&&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:()=>{E(""),pe(!1),se("")},className:"w-full px-3 py-2 text-left text-sm text-bambu-gray hover:bg-bambu-dark-tertiary",children:"None"}),Gt.map(Tt=>s.jsxs("button",{type:"button",onClick:()=>{E(Tt.entity_id),pe(!1),se("")},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${Tt.entity_id===T?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[s.jsx("div",{className:"font-medium",children:Tt.friendly_name}),s.jsxs("div",{className:"text-xs text-bambu-gray",children:[Tt.entity_id," • ",Tt.state," ",Tt.unit_of_measurement]})]},Tt.entity_id)),Gt.length===0&&s.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No matching sensors"})]})]})})()]})]})]}),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:bt=>{u(bt.target.value),fe(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(we,{type:"button",variant:"secondary",onClick:()=>gt.mutate(),disabled:!c.trim()||gt.isPending,children:[gt.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(Hp,{className:"w-4 h-4"}),"Test"]})]})]}),i==="tasmota"&&Ee&&s.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${Ee.success?"bg-bambu-green/20 border border-bambu-green/50 text-bambu-green":"bg-red-500/20 border border-red-500/50 text-red-400"}`,children:Ee.success?s.jsxs(s.Fragment,{children:[s.jsx(Fn,{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:[Ee.device_name&&`Device: ${Ee.device_name} - `,"State: ",Ee.state]})]})]}):s.jsxs(s.Fragment,{children:[s.jsx(zg,{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:bt=>l(bt.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:bt=>f(bt.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:m,onChange:bt=>p(bt.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"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Link to Printer"}),s.jsxs("select",{value:Me??"",onChange:bt=>me(bt.target.value?Number(bt.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)"}),cn?.map(bt=>s.jsx("option",{value:bt.id,children:bt.name},bt.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(cf,{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:V,onChange:bt=>$(bt.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"})]})]}),V&&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:X,onChange:bt=>U(bt.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:B,onChange:bt=>oe(bt.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."})]})]}),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(Kn,{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:Te,onChange:bt=>je(bt.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"})]})]}),Te&&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:Ce,onChange:bt=>H(bt.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:D,onChange:bt=>Z(bt.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(z2,{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:xe,onChange:bt=>Ne(bt.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(we,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),s.jsxs(we,{type:"submit",disabled:_n,className:"flex-1",children:[_n?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(gs,{className:"w-4 h-4"}),r?"Save":"Add"]})]})]})]})})}function Hn({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 tKe={callmebot:"CallMeBot/WhatsApp",ntfy:"ntfy",pushover:"Pushover",telegram:"Telegram",email:"Email",discord:"Discord",webhook:"Webhook"};function nKe({provider:t,onEdit:e}){const n=on(),[r,i]=w.useState(!1),[a,o]=w.useState(!1),[l,c]=w.useState(null),{data:u}=ut({queryKey:["printers"],queryFn:he.getPrinters}),d=u?.find(y=>y.id===t.printer_id),f=pt({mutationFn:y=>he.updateNotificationProvider(t.id,y),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),m=pt({mutationFn:()=>he.deleteNotificationProvider(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),p=pt({mutationFn:()=>he.testNotificationProvider(t.id),onSuccess:y=>{c(y),n.invalidateQueries({queryKey:["notification-providers"]})},onError:y=>{c({success:!1,message:y.message})}}),x=y=>y||"";return s.jsxs(s.Fragment,{children:[s.jsx(Nt,{className:"relative",children:s.jsxs(Et,{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(cf,{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:tKe[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: ",sg(t.last_success)]}),t.last_error&&t.last_error_at&&(!t.last_success||(vi(t.last_error_at)?.getTime()||0)>(vi(t.last_success)?.getTime()||0))&&s.jsx("span",{className:"text-xs text-status-error",title:t.last_error,children:"Error"}),s.jsx(Hn,{checked:t.enabled,onChange:y=>f.mutate({enabled:y})})]})]}),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(yw,{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(ri,{className:"w-3 h-3"}),"Digest ",t.daily_digest_time]})]}),s.jsx("div",{className:"mb-3",children:s.jsxs(we,{size:"sm",variant:"secondary",disabled:p.isPending,onClick:()=>{c(null),p.mutate()},className:"w-full",children:[p.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(fD,{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(Fn,{className:"w-4 h-4"}):s.jsx(ta,{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(Bd,{className:"w-4 h-4"}),"Event Settings"]}),a?s.jsx(su,{className:"w-4 h-4"}):s.jsx(Pi,{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(Hn,{checked:t.enabled,onChange:y=>f.mutate({enabled:y})})]}),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(Hn,{checked:t.on_print_start,onChange:y=>f.mutate({on_print_start:y})})]}),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(Hn,{checked:t.on_plate_not_empty??!0,onChange:y=>f.mutate({on_plate_not_empty:y})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("p",{className:"text-sm text-white",children:"Print Completed"}),s.jsx(Hn,{checked:t.on_print_complete,onChange:y=>f.mutate({on_print_complete:y})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("p",{className:"text-sm text-white",children:"Print Failed"}),s.jsx(Hn,{checked:t.on_print_failed,onChange:y=>f.mutate({on_print_failed:y})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("p",{className:"text-sm text-white",children:"Print Stopped"}),s.jsx(Hn,{checked:t.on_print_stopped,onChange:y=>f.mutate({on_print_stopped:y})})]}),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(Hn,{checked:t.on_print_progress,onChange:y=>f.mutate({on_print_progress:y})})]})]}),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(Hn,{checked:t.on_printer_offline,onChange:y=>f.mutate({on_printer_offline:y})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("p",{className:"text-sm text-white",children:"Printer Error"}),s.jsx(Hn,{checked:t.on_printer_error,onChange:y=>f.mutate({on_printer_error:y})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("p",{className:"text-sm text-white",children:"Low Filament"}),s.jsx(Hn,{checked:t.on_filament_low,onChange:y=>f.mutate({on_filament_low:y})})]}),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(Hn,{checked:t.on_maintenance_due??!1,onChange:y=>f.mutate({on_maintenance_due:y})})]})]}),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(Hn,{checked:t.on_ams_humidity_high??!1,onChange:y=>f.mutate({on_ams_humidity_high:y})})]}),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(Hn,{checked:t.on_ams_temperature_high??!1,onChange:y=>f.mutate({on_ams_temperature_high:y})})]})]}),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(Hn,{checked:t.on_ams_ht_humidity_high??!1,onChange:y=>f.mutate({on_ams_ht_humidity_high:y})})]}),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(Hn,{checked:t.on_ams_ht_temperature_high??!1,onChange:y=>f.mutate({on_ams_ht_temperature_high:y})})]})]}),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(yw,{className:"w-4 h-4 text-purple-400"}),s.jsx("p",{className:"text-sm text-white",children:"Quiet Hours"})]}),s.jsx(Hn,{checked:t.quiet_hours_enabled,onChange:y=>f.mutate({quiet_hours_enabled:y})})]}),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(Kn,{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(ri,{className:"w-4 h-4 text-emerald-400"}),s.jsx("p",{className:"text-sm text-white",children:"Daily Digest"})]}),s.jsx(Hn,{checked:t.daily_digest_enabled,onChange:y=>f.mutate({daily_digest_enabled:y})})]}),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(Kn,{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(we,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[s.jsx($2,{className:"w-4 h-4"}),"Edit"]}),s.jsx(we,{size:"sm",variant:"secondary",onClick:()=>i(!0),className:"text-red-400 hover:text-red-300",children:s.jsx(un,{className:"w-4 h-4"})})]})]})]})}),r&&s.jsx(Bn,{title:"Delete Notification Provider",message:`Are you sure you want to delete "${t.name}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{m.mutate(),i(!1)},onCancel:()=>i(!1)})]})}const QG=[{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 rKe({provider:t,onClose:e}){const n=on(),r=!!t,[i,a]=w.useState(t?.name||""),[o,l]=w.useState(t?.provider_type||"email"),[c,u]=w.useState(t?.printer_id||null),[d,f]=w.useState(t?.quiet_hours_enabled||!1),[m,p]=w.useState(t?.quiet_hours_start||"22:00"),[x,y]=w.useState(t?.quiet_hours_end||"07:00"),[b,v]=w.useState(t?.daily_digest_enabled||!1),[N,S]=w.useState(t?.daily_digest_time||"08:00"),[T,E]=w.useState(t?.on_print_start??!1),[C,A]=w.useState(t?.on_print_complete??!0),[O,k]=w.useState(t?.on_print_failed??!0),[R,F]=w.useState(t?.on_print_stopped??!0),[L,K]=w.useState(t?.on_print_progress??!1),[j,W]=w.useState(t?.on_printer_offline??!1),[Y,q]=w.useState(t?.on_printer_error??!1),[Q,ee]=w.useState(t?.on_filament_low??!1),[re,z]=w.useState(t?.on_maintenance_due??!1),[G,ae]=w.useState(t?.config?Object.fromEntries(Object.entries(t.config).map(([U,B])=>[U,String(B)])):{}),[se,ue]=w.useState(null),[pe,ce]=w.useState(null),{data:Me}=ut({queryKey:["printers"],queryFn:he.getPrinters});w.useEffect(()=>{const U=B=>{B.key==="Escape"&&e()};return window.addEventListener("keydown",U),()=>window.removeEventListener("keydown",U)},[e]);const me=pt({mutationFn:()=>he.testNotificationConfig({provider_type:o,config:G}),onSuccess:U=>{ue(U),ce(null)},onError:U=>{ue({success:!1,message:U.message})}}),Ee=pt({mutationFn:U=>he.createNotificationProvider(U),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:U=>{ce(U.message)}}),fe=pt({mutationFn:U=>he.updateNotificationProvider(t.id,U),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:U=>{ce(U.message)}}),le=U=>{if(U.preventDefault(),ce(null),!i.trim()){ce("Name is required");return}const B=$(o);for(const Te of B)if(!G[Te.key]?.trim()){ce(`${Te.label} is required`);return}const oe={name:i.trim(),provider_type:o,config:G,printer_id:c,quiet_hours_enabled:d,quiet_hours_start:d?m:null,quiet_hours_end:d?x:null,daily_digest_enabled:b,daily_digest_time:b?N:null,on_print_start:T,on_print_complete:C,on_print_failed:O,on_print_stopped:R,on_print_progress:L,on_printer_offline:j,on_printer_error:Y,on_filament_low:Q,on_maintenance_due:re};r?fe.mutate(oe):Ee.mutate(oe)},Be=Ee.isPending||fe.isPending,V=U=>{switch(U){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:B=>B.payload_format!=="slack"},{key:"field_message",label:"Message Field Name",placeholder:"message",type:"text",required:!1,showIf:B=>B.payload_format!=="slack"}];default:return[]}},$=U=>V(U).filter(B=>B.required),X=V(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: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.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(zt,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:le,className:"p-6 space-y-4",children:[pe&&s.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:pe}),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:U=>a(U.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:U=>{l(U.target.value),ae({}),ue(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:QG.map(U=>s.jsx("option",{value:U.value,children:U.label},U.value))}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:QG.find(U=>U.value===o)?.description})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Configuration"}),X.filter(U=>!("showIf"in U)||U.showIf?.(G)!==!1).map(U=>s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[U.label," ",U.required&&"*"]}),U.type==="select"&&"options"in U&&U.options?s.jsx("select",{value:G[U.key]||U.options[0]?.value||"",onChange:B=>{ae({...G,[U.key]:B.target.value}),ue(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:U.options.map(B=>s.jsx("option",{value:B.value,children:B.label},B.value))}):s.jsx("input",{type:U.type,value:G[U.key]||"",onChange:B=>{ae({...G,[U.key]:B.target.value}),ue(null)},placeholder:U.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"})]},U.key))]}),s.jsx("div",{className:"flex gap-2",children:s.jsxs(we,{type:"button",variant:"secondary",onClick:()=>{ue(null),me.mutate()},disabled:me.isPending||!G[$(o)[0]?.key],className:"flex-1",children:[me.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(fD,{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(Fn,{className:"w-5 h-5"}),s.jsx("span",{children:se.message})]}):s.jsxs(s.Fragment,{children:[s.jsx(ta,{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:U=>u(U.target.value?Number(U.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"}),Me?.map(U=>s.jsx("option",{value:U.id,children:U.name},U.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(Hn,{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:m,onChange:U=>p(U.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:U=>y(U.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(Hn,{checked:b,onChange:v})]}),b&&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:N,onChange:U=>S(U.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(Hn,{checked:T,onChange:E})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Complete"}),s.jsx(Hn,{checked:C,onChange:A})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Failed"}),s.jsx(Hn,{checked:O,onChange:k})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Stopped"}),s.jsx(Hn,{checked:R,onChange:F})]}),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(Hn,{checked:L,onChange:K})]})]})]}),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(Hn,{checked:j,onChange:W})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Error"}),s.jsx(Hn,{checked:Y,onChange:q})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Low Filament"}),s.jsx(Hn,{checked:Q,onChange:ee})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Maintenance"}),s.jsx(Hn,{checked:re,onChange:z})]})]})]})]}),s.jsxs("div",{className:"flex gap-3 pt-2",children:[s.jsx(we,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),s.jsxs(we,{type:"submit",disabled:Be,className:"flex-1",children:[Be?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(gs,{className:"w-4 h-4"}),r?"Save":"Add"]})]})]})]})})}function iKe({template:t,onClose:e}){const n=on(),r=w.useRef(null),[i,a]=w.useState(t.title_template),[o,l]=w.useState(t.body_template),[c,u]=w.useState(null),[d,f]=w.useState(!0),{data:m}=ut({queryKey:["template-variables"],queryFn:he.getTemplateVariables}),p=m?.find(E=>E.event_type===t.event_type),{data:x,isLoading:y}=ut({queryKey:["template-preview",t.event_type,i,o],queryFn:()=>he.previewTemplate({event_type:t.event_type,title_template:i,body_template:o}),enabled:d&&i.length>0&&o.length>0});w.useEffect(()=>{const E=C=>{C.key==="Escape"&&e()};return window.addEventListener("keydown",E),()=>window.removeEventListener("keydown",E)},[e]);const b=pt({mutationFn:E=>he.updateNotificationTemplate(t.id,E),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-templates"]}),e()},onError:E=>{u(E.message)}}),v=pt({mutationFn:()=>he.resetNotificationTemplate(t.id),onSuccess:E=>{a(E.title_template),l(E.body_template),n.invalidateQueries({queryKey:["notification-templates"]})},onError:E=>{u(E.message)}}),N=E=>{if(E.preventDefault(),u(null),!i.trim()){u("Title is required");return}if(!o.trim()){u("Body is required");return}b.mutate({title_template:i,body_template:o})},S=E=>{const C=r.current;if(!C)return;const A=C.selectionStart,O=C.selectionEnd,k=o,R=k.substring(0,A),F=k.substring(O),L=R+`{${E}}`+F;l(L),setTimeout(()=>{C.focus();const K=A+E.length+2;C.setSelectionRange(K,K)},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(zt,{className:"w-5 h-5 text-bambu-gray"})})]}),s.jsxs("form",{onSubmit:N,className:"flex-1 overflow-y-auto p-4 space-y-4",children:[c&&s.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded text-red-400 text-sm",children:c}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:"Title"}),s.jsx("input",{type:"text",value:i,onChange:E=>a(E.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white focus:outline-none focus:ring-1 focus:ring-bambu-green",placeholder:"Notification title..."})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:"Body"}),s.jsx("textarea",{ref:r,value:o,onChange:E=>l(E.target.value),rows:4,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white focus:outline-none focus:ring-1 focus:ring-bambu-green font-mono text-sm resize-none",placeholder:"Notification body..."})]}),p&&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:p.variables.map(E=>s.jsxs("button",{type:"button",onClick:()=>S(E),className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-dark hover:bg-bambu-dark-tertiary border border-bambu-dark-tertiary rounded text-xs text-bambu-gray hover:text-white transition-colors",children:[s.jsx(Jn,{className:"w-3 h-3"}),E]},E))}),s.jsx("p",{className:"text-xs text-bambu-gray/60 mt-1",children:"Click to insert at cursor position in body"})]}),s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsxs("label",{className:"text-sm font-medium text-bambu-gray flex items-center gap-2",children:[s.jsx(Cf,{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:y?s.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-sm",children:[s.jsx(dt,{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(we,{type:"button",variant:"ghost",onClick:()=>v.mutate(),disabled:v.isPending,className:"text-orange-400 hover:text-orange-300",children:[v.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin mr-2"}):s.jsx(Zf,{className:"w-4 h-4 mr-2"}),"Reset to Default"]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(we,{type:"button",variant:"secondary",onClick:e,children:"Cancel"}),s.jsxs(we,{onClick:N,disabled:b.isPending||!T,children:[b.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin mr-2"}):s.jsx(gs,{className:"w-4 h-4 mr-2"}),"Save"]})]})]})]})})}const aKe={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"},sKe={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 oKe({onClose:t}){const e=on(),{showToast:n}=Vn(),[r,i]=w.useState(7),[a,o]=w.useState(null),[l,c]=w.useState(!1),{data:u}=ut({queryKey:["settings"],queryFn:he.getSettings}),d=u?.time_format||"system",{data:f,isLoading:m,refetch:p,isRefetching:x}=ut({queryKey:["notification-logs",r,l],queryFn:()=>he.getNotificationLogs({days:r,limit:100,success:l?!1:void 0})}),{data:y}=ut({queryKey:["notification-log-stats",r],queryFn:()=>he.getNotificationLogStats(r)}),b=pt({mutationFn:()=>he.clearNotificationLogs(30),onSuccess:N=>{n(N.message,"success"),e.invalidateQueries({queryKey:["notification-logs"]}),e.invalidateQueries({queryKey:["notification-log-stats"]})},onError:N=>{n(`Failed to clear logs: ${N.message}`,"error")}}),v=N=>{const S=vi(N);if(!S)return"";const E=new Date().getTime()-S.getTime();return E<6e4?"Just now":E<36e5?`${Math.floor(E/6e4)}m ago`:E<864e5?`${Math.floor(E/36e5)}h ago`:S.toLocaleDateString()+" "+Tfe(S,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(f0,{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:"×"})]}),y&&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:y.total})," notifications"]}),s.jsxs("span",{className:"flex items-center gap-1 text-bambu-green",children:[s.jsx(Fn,{className:"w-4 h-4"}),y.success_count," sent"]}),y.failure_count>0&&s.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[s.jsx(ta,{className:"w-4 h-4"}),y.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:N=>i(Number(N.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:N=>c(N.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(we,{size:"sm",variant:"secondary",onClick:()=>p(),disabled:x,children:[x?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(xr,{className:"w-4 h-4"}),"Refresh"]}),s.jsxs(we,{size:"sm",variant:"secondary",onClick:()=>b.mutate(),disabled:b.isPending,className:"text-red-400 hover:text-red-300",children:[b.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(un,{className:"w-4 h-4"}),"Clear Old"]})]}),s.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:m?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(dt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):f&&f.length>0?s.jsx("div",{className:"space-y-2",children:f.map(N=>s.jsx(lKe,{log:N,isExpanded:a===N.id,onToggle:()=>o(a===N.id?null:N.id),formatDate:v,formatFullDate:S=>og(S,d)},N.id))}):s.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[s.jsx(f0,{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 lKe({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(Fn,{className:"w-4 h-4 text-bambu-green shrink-0"}):s.jsx(ta,{className:"w-4 h-4 text-red-400 shrink-0"}),s.jsx("span",{className:`text-xs font-medium ${sKe[t.event_type]||"text-bambu-gray"}`,children:aKe[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(su,{className:"w-4 h-4 text-bambu-gray shrink-0"}):s.jsx(Pi,{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 cKe(){const t=await fetch("/api/v1/settings/spoolman");if(!t.ok)throw new Error("Failed to load Spoolman settings");return t.json()}async function uKe(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 dKe(){const t=on(),[e,n]=w.useState(!1),[r,i]=w.useState(""),[a,o]=w.useState("auto"),[l,c]=w.useState(!1),[u,d]=w.useState("all"),[f,m]=w.useState(!1),[p,x]=w.useState(!1),{data:y,isLoading:b}=ut({queryKey:["spoolman-settings"],queryFn:cKe}),{data:v,isLoading:N,refetch:S}=ut({queryKey:["spoolman-status"],queryFn:he.getSpoolmanStatus,refetchInterval:3e4}),{data:T}=ut({queryKey:["printers"],queryFn:he.getPrinters});w.useEffect(()=>{y&&(n(y.spoolman_enabled==="true"),i(y.spoolman_url||""),o(y.spoolman_sync_mode||"auto"),m(!0))},[y]),w.useEffect(()=>{if(!f||!y)return;if(y.spoolman_enabled==="true"!==e||(y.spoolman_url||"")!==r||(y.spoolman_sync_mode||"auto")!==a){const W=setTimeout(()=>{E.mutate()},500);return()=>clearTimeout(W)}},[e,r,a,f]);const E=pt({mutationFn:()=>uKe({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=pt({mutationFn:he.connectSpoolman,onSuccess:()=>{S()}}),A=pt({mutationFn:he.disconnectSpoolman,onSuccess:()=>{S()}}),O=pt({mutationFn:he.syncAllPrintersAms,onSuccess:j=>{j.success}}),k=pt({mutationFn:j=>he.syncPrinterAms(j),onSuccess:j=>{j.success}}),R=()=>{u==="all"?O.mutate():k.mutate(u)},F=O.isPending||k.isPending,L=u==="all"?O.data:k.data,K=u==="all"?O.isSuccess:k.isSuccess;return b?s.jsxs(Nt,{children:[s.jsx(Qn,{children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Qc,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Spoolman Integration"})]})}),s.jsx(Et,{children:s.jsx("div",{className:"flex justify-center py-8",children:s.jsx(dt,{className:"w-6 h-6 text-bambu-green animate-spin"})})})]}):s.jsxs(Nt,{children:[s.jsx(Qn,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Qc,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Spoolman Integration"})]}),E.isPending&&s.jsx(dt,{className:"w-4 h-4 text-bambu-green animate-spin"}),l&&s.jsx(Ya,{className:"w-4 h-4 text-bambu-green"})]})}),s.jsxs(Et,{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(Ul,{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:"}),N?s.jsx(dt,{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(Ya,{className:"w-4 h-4"}),"Connected"]}):s.jsxs("span",{className:"flex items-center gap-1 text-sm text-red-500",children:[s.jsx(zt,{className:"w-4 h-4"}),"Disconnected"]})]}),s.jsx("div",{className:"flex gap-2",children:v?.connected?s.jsxs(we,{variant:"secondary",size:"sm",onClick:()=>A.mutate(),disabled:A.isPending,children:[A.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(mde,{className:"w-4 h-4"}),"Disconnect"]}):s.jsxs(we,{size:"sm",onClick:()=>C.mutate(),disabled:C.isPending||!r,children:[C.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(Ol,{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(Pi,{className:"absolute right-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),s.jsxs(we,{variant:"secondary",size:"sm",onClick:R,disabled:F,children:[F?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(xr,{className:"w-4 h-4"}),"Sync"]})]})]}),K&&L&&s.jsxs("div",{className:"mt-3 space-y-2",children:[s.jsx("div",{className:`p-2 rounded text-sm ${L.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:L.success?`Synced ${L.synced_count} spool${L.synced_count!==1?"s":""} successfully`:`Synced ${L.synced_count} spool${L.synced_count!==1?"s":""} with ${L.errors.length} error${L.errors.length!==1?"s":""}`}),L.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(yn,{className:"w-3.5 h-3.5"}),s.jsxs("span",{className:"font-medium",children:[L.skipped_count," spool",L.skipped_count!==1?"s":""," skipped"]})]}),L.skipped_count>5&&s.jsx("button",{onClick:()=>x(!p),className:"text-xs text-amber-400 hover:text-amber-300 underline",children:p?"Show less":"Show all"})]}),s.jsxs("ul",{className:"text-xs text-amber-300/80 space-y-0.5",children:[(p?L.skipped:L.skipped.slice(0,5)).map((j,W)=>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]})]},W)),!p&&L.skipped_count>5&&s.jsxs("li",{className:"text-amber-300/60 italic",children:["...and ",L.skipped_count-5," more"]})]})]}),L.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:L.errors.map((j,W)=>s.jsx("li",{children:j},W))})]})]})]})]})]})}function hKe({link:t,onClose:e}){const n=on(),{mode:r}=nh(),i=!!t,a=w.useRef(null),[o,l]=w.useState(t?.name||""),[c,u]=w.useState(t?.url||""),[d,f]=w.useState(t?.icon||"link"),[m,p]=w.useState(!!t?.custom_icon),[x,y]=w.useState(t?.custom_icon?he.getExternalLinkIconUrl(t.id):null),[b,v]=w.useState(null),[N,S]=w.useState(null);w.useEffect(()=>{const F=L=>{L.key==="Escape"&&e()};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[e]);const T=pt({mutationFn:async F=>{const L=await he.createExternalLink(F);return b?await he.uploadExternalLinkIcon(L.id,b):L},onSuccess:()=>{n.invalidateQueries({queryKey:["external-links"]}),e()},onError:F=>{S(F.message)}}),E=pt({mutationFn:async F=>{let L=await he.updateExternalLink(t.id,F);return b?L=await he.uploadExternalLinkIcon(t.id,b):!m&&t?.custom_icon&&(L=await he.deleteExternalLinkIcon(t.id)),L},onSuccess:()=>{n.invalidateQueries({queryKey:["external-links"]}),e()},onError:F=>{S(F.message)}}),C=F=>{const L=F.target.files?.[0];if(L){if(!["image/png","image/jpeg","image/gif","image/svg+xml","image/webp","image/x-icon"].includes(L.type)){S("Please select a valid image file (PNG, JPG, GIF, SVG, WebP, or ICO)");return}if(L.size>1024*1024){S("Image file must be less than 1MB");return}v(L),p(!0);const j=new FileReader;j.onload=W=>{y(W.target?.result)},j.readAsDataURL(L)}},A=()=>{v(null),y(null),p(!1),a.current&&(a.current.value="")},O=F=>{if(F.preventDefault(),S(null),!o.trim()){S("Name is required");return}if(!c.trim()){S("URL is required");return}if(!c.startsWith("http://")&&!c.startsWith("https://")){S("URL must start with http:// or https://");return}const L={name:o.trim(),url:c.trim(),icon:d};i?E.mutate(L):T.mutate(L)},k=T.isPending||E.isPending,R=W2(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:F=>F.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:m&&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(zt,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:O,className:"p-6 space-y-4",children:[N&&s.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:N}),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:F=>l(F.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:F=>u(F.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}),m&&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:A,className:"p-1 text-red-400 hover:text-red-300 transition-colors",title:"Remove custom icon",children:s.jsx(un,{className:"w-4 h-4"})})]}):s.jsxs(we,{type:"button",variant:"secondary",size:"sm",onClick:()=>a.current?.click(),children:[s.jsx(di,{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."})]}),!m&&s.jsxs("div",{children:[s.jsx("span",{className:"text-sm text-bambu-gray block mb-2",children:"Or choose a preset icon"}),s.jsx(_fe,{value:d,onChange:f})]})]}),s.jsxs("div",{className:"flex gap-3 pt-2",children:[s.jsx(we,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),s.jsxs(we,{type:"submit",disabled:k,className:"flex-1",children:[k?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(gs,{className:"w-4 h-4"}),i?"Save":"Add"]})]})]})]})})}function fKe(){const t=on(),[e,n]=w.useState(!1),[r,i]=w.useState(null),[a,o]=w.useState(null),[l,c]=w.useState(null),{data:u,isLoading:d}=ut({queryKey:["external-links"],queryFn:he.getExternalLinks}),f=pt({mutationFn:N=>he.deleteExternalLink(N),onSuccess:()=>{t.invalidateQueries({queryKey:["external-links"]})}}),m=pt({mutationFn:N=>he.reorderExternalLinks(N),onSuccess:()=>{t.invalidateQueries({queryKey:["external-links"]})}}),p=(N,S)=>{c(S),N.dataTransfer.effectAllowed="move"},x=N=>{N.preventDefault(),N.dataTransfer.dropEffect="move"},y=(N,S)=>{if(N.preventDefault(),l===null||l===S||!u)return;const T=u.map(O=>O.id),E=T.indexOf(l),C=T.indexOf(S);if(E===-1||C===-1)return;const A=[...T];A.splice(E,1),A.splice(C,0,l),m.mutate(A),c(null)},b=N=>{o(N)},v=()=>{a&&(f.mutate(a.id),o(null))};return s.jsxs(s.Fragment,{children:[s.jsxs(Nt,{children:[s.jsx(Qn,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ol,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Sidebar Links"})]}),s.jsxs(we,{size:"sm",onClick:()=>n(!0),children:[s.jsx(Jn,{className:"w-4 h-4"}),"Add Link"]})]})}),s.jsxs(Et,{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(dt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):u&&u.length>0?s.jsx("div",{className:"space-y-2",children:u.map(N=>{const S=W2(N.icon);return s.jsxs("div",{draggable:!0,onDragStart:T=>p(T,N.id),onDragOver:x,onDrop:T=>y(T,N.id),className:`flex items-center gap-3 p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary transition-colors ${l===N.id?"opacity-50":""}`,children:[s.jsx(ig,{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(S,{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:N.name}),s.jsx(Ur,{className:"w-3 h-3 text-bambu-gray flex-shrink-0"})]}),s.jsx("span",{className:"text-sm text-bambu-gray truncate block",children:N.url})]}),s.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[s.jsx("button",{onClick:()=>i(N),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white transition-colors",title:"Edit",children:s.jsx(ia,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>b(N),disabled:f.isPending,className:"p-2 rounded-lg hover:bg-red-500/20 text-bambu-gray hover:text-red-400 transition-colors disabled:opacity-50",title:"Delete",children:s.jsx(un,{className:"w-4 h-4"})})]})]},N.id)})}):s.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[s.jsx(Ol,{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(hKe,{link:r,onClose:()=>{n(!1),i(null)}}),a&&s.jsx(Bn,{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 mKe(){const t=on(),{showToast:e}=Vn(),[n,r]=w.useState(!1),[i,a]=w.useState(""),[o,l]=w.useState("immediate"),[c,u]=w.useState("3DPrinter-X1-Carbon"),[d,f]=w.useState(!1),[m,p]=w.useState(null),{data:x,isLoading:y}=ut({queryKey:["virtual-printer-settings"],queryFn:z1.getSettings,refetchInterval:1e4}),{data:b}=ut({queryKey:["virtual-printer-models"],queryFn:z1.getModels});w.useEffect(()=>{if(x){r(x.enabled);let O=x.mode==="queue"?"review":x.mode;O!=="immediate"&&O!=="review"&&O!=="print_queue"&&(O="immediate"),l(O),u(x.model)}},[x]);const v=pt({mutationFn:O=>z1.updateSettings(O),onSuccess:()=>{t.invalidateQueries({queryKey:["virtual-printer-settings"]}),e("Virtual printer settings updated"),p(null)},onError:O=>{if(e(O.message||"Failed to update settings","error"),x){r(x.enabled);const k=x.mode==="queue"?"review":x.mode;l(k==="print_queue"||k==="review"?k:"immediate"),u(x.model)}p(null)}}),N=()=>{const O=!n;if(O&&!i&&!x?.access_code_set){e("Please set an access code first","error");return}r(O),p("toggle"),v.mutate({enabled:O,access_code:i||void 0,mode:o})},S=()=>{if(!i){e("Access code cannot be empty","error");return}if(i.length!==8){e("Access code must be exactly 8 characters","error");return}p("accessCode"),v.mutate({access_code:i}),a("")},T=O=>{l(O),p("mode"),v.mutate({mode:O})},E=O=>{u(O),p("model"),v.mutate({model:O})};if(y)return s.jsx(Nt,{children:s.jsx(Et,{className:"py-8 flex justify-center",children:s.jsx(dt,{className:"w-6 h-6 animate-spin text-bambu-green"})})});const C=x?.status,A=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(Nt,{children:[s.jsx(Qn,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Mr,{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 ${A?"text-green-400":"text-bambu-gray"}`,children:[s.jsx("span",{className:`w-2 h-2 rounded-full ${A?"bg-green-400 animate-pulse":"bg-gray-500"}`}),A?"Running":"Stopped"]})]})}),s.jsxs(Et,{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:A?'Visible as "Bambuddy" in slicer discovery':"Not visible to slicers"})]}),s.jsx("button",{onClick:N,disabled:m==="toggle",className:`relative w-12 h-6 rounded-full transition-colors ${n?"bg-bambu-green":"bg-bambu-dark-tertiary"} ${m==="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:O=>E(O.target.value),disabled:m==="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:b?.models&&Object.entries(b.models).sort(([,O],[,k])=>O.localeCompare(k)).map(([O,k])=>s.jsx("option",{value:O,children:k},O))}),s.jsx(Pi,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),n&&A&&s.jsxs("p",{className:"text-xs text-bambu-gray mt-2",children:[s.jsx(Ul,{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(Ya,{className:"w-4 h-4"}),"Access code is set"]}):s.jsxs("span",{className:"flex items-center gap-1 text-yellow-400",children:[s.jsx(yn,{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:O=>a(O.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(D2,{className:"w-4 h-4"}):s.jsx(Cf,{className:"w-4 h-4"})})]}),s.jsx(we,{onClick:S,disabled:!i||m==="accessCode",variant:"primary",children:m==="accessCode"?s.jsx(dt,{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:m==="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:m==="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:m==="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(Nt,{className:"border-l-4 border-l-yellow-500",children:s.jsx(Et,{className:"py-4",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(yn,{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(Ur,{className:"w-4 h-4"}),"Read the setup guide before enabling"]})]})]})})}),s.jsx(Nt,{children:s.jsx(Et,{className:"py-4",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(Ul,{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&&A&&s.jsxs(Nt,{children:[s.jsx(Qn,{children:s.jsx("h3",{className:"text-md font-semibold text-white",children:"Status Details"})}),s.jsx(Et,{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})]})]})})]})]})]})}const L1=[{id:"settings",labelKey:"backup.categories.settings",defaultLabel:"App Settings",icon:s.jsx(V2,{className:"w-4 h-4"}),default:!0,description:"Language, theme, update preferences"},{id:"notifications",labelKey:"backup.categories.notifications",defaultLabel:"Notification Providers",icon:s.jsx(cf,{className:"w-4 h-4"}),default:!0,description:"ntfy, Pushover, Discord, etc."},{id:"templates",labelKey:"backup.categories.templates",defaultLabel:"Notification Templates",icon:s.jsx(Ga,{className:"w-4 h-4"}),default:!0,description:"Custom message templates"},{id:"smart_plugs",labelKey:"backup.categories.smartPlugs",defaultLabel:"Smart Plugs",icon:s.jsx(Vs,{className:"w-4 h-4"}),default:!0,description:"Tasmota plug configurations"},{id:"external_links",labelKey:"backup.categories.externalLinks",defaultLabel:"External Links",icon:s.jsx(Ug,{className:"w-4 h-4"}),default:!0,description:"Sidebar links to external services"},{id:"printers",labelKey:"backup.categories.printers",defaultLabel:"Printers",icon:s.jsx(Mr,{className:"w-4 h-4"}),default:!1,description:"Printer info (access codes excluded)"},{id:"plate_calibration",labelKey:"backup.categories.plateCalibration",defaultLabel:"Plate Detection",icon:s.jsx(Tf,{className:"w-4 h-4"}),default:!1,description:"Empty plate reference images",requiresPrinters:!0},{id:"filaments",labelKey:"backup.categories.filaments",defaultLabel:"Filament Inventory",icon:s.jsx(dD,{className:"w-4 h-4"}),default:!1,description:"Filament types and costs"},{id:"maintenance",labelKey:"backup.categories.maintenance",defaultLabel:"Maintenance Types",icon:s.jsx($d,{className:"w-4 h-4"}),default:!1,description:"Custom maintenance schedules"},{id:"archives",labelKey:"backup.categories.archives",defaultLabel:"Print Archives",icon:s.jsx(Ka,{className:"w-4 h-4"}),default:!1,description:"All print data + files (3MF, thumbnails, photos)"},{id:"projects",labelKey:"backup.categories.projects",defaultLabel:"Projects",icon:s.jsx(wa,{className:"w-4 h-4"}),default:!1,description:"Projects, BOM items, and attachments"},{id:"pending_uploads",labelKey:"backup.categories.pendingUploads",defaultLabel:"Pending Uploads",icon:s.jsx(di,{className:"w-4 h-4"}),default:!1,description:"Virtual printer uploads awaiting review"},{id:"api_keys",labelKey:"backup.categories.apiKeys",defaultLabel:"API Keys",icon:s.jsx(Jh,{className:"w-4 h-4"}),default:!1,description:"Webhook API keys (new keys generated on import)"}];function pKe({onClose:t,onExport:e}){const{t:n}=Og(),[r,i]=w.useState(()=>{const x={};return L1.forEach(y=>{x[y.id]=y.default}),x}),[a,o]=w.useState(!1),[l,c]=w.useState(!1);w.useEffect(()=>{const x=y=>{y.key==="Escape"&&t()};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[t]);const u=x=>{i(y=>({...y,[x]:!y[x]}))},d=()=>{const x={};L1.forEach(y=>{x[y.id]=!0}),i(x)},f=()=>{const x={};L1.forEach(y=>{x[y.id]=!1}),i(x)},m=Object.values(r).filter(Boolean).length,p=async()=>{c(!0);try{await e({...r,access_codes:a&&r.printers})}finally{c(!1)}};return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:l?void 0:t,children:s.jsx(Nt,{className:"w-full max-w-lg",onClick:x=>x.stopPropagation(),children:s.jsxs(Et,{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-3",children:[s.jsx("div",{className:"p-2 rounded-full bg-bambu-green/20 text-bambu-green",children:s.jsx($r,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-semibold text-white",children:n("backup.exportTitle",{defaultValue:"Export Backup"})}),s.jsx("p",{className:"text-sm text-bambu-gray",children:n("backup.selectCategories",{defaultValue:"Select data to include"})})]})]}),s.jsx("button",{onClick:t,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:s.jsx(zt,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"flex gap-2 px-4 pt-4",children:[s.jsx("button",{onClick:d,disabled:l,className:"text-sm text-bambu-green hover:text-bambu-green/80 disabled:opacity-50 disabled:cursor-not-allowed",children:n("common.selectAll",{defaultValue:"Select All"})}),s.jsx("span",{className:"text-bambu-gray",children:"|"}),s.jsx("button",{onClick:f,disabled:l,className:"text-sm text-bambu-gray hover:text-white disabled:opacity-50 disabled:cursor-not-allowed",children:n("common.selectNone",{defaultValue:"Select None"})})]}),s.jsx("div",{className:`p-4 space-y-2 max-h-[400px] overflow-y-auto ${l?"opacity-50 pointer-events-none":""}`,children:L1.map(x=>{const y=l||x.requiresPrinters&&!r.printers;return s.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg transition-colors ${y?"cursor-not-allowed opacity-50":"cursor-pointer"} ${r[x.id]&&!y?"bg-bambu-green/10 border border-bambu-green/30":"bg-bambu-dark hover:bg-bambu-dark-tertiary border border-transparent"}`,children:[s.jsx("input",{type:"checkbox",checked:r[x.id]&&!y,onChange:()=>u(x.id),disabled:y,className:"w-4 h-4 rounded border-bambu-gray bg-bambu-dark text-bambu-green focus:ring-bambu-green focus:ring-offset-0"}),s.jsx("div",{className:`${r[x.id]&&!y?"text-bambu-green":"text-bambu-gray"}`,children:x.icon}),s.jsxs("div",{className:"flex-1",children:[s.jsx("div",{className:"text-white text-sm font-medium",children:n(x.labelKey,{defaultValue:x.defaultLabel})}),s.jsx("div",{className:"text-xs text-bambu-gray",children:x.requiresPrinters&&!r.printers?"Requires Printers to be selected":x.description})]})]},x.id)})}),r.archives&&s.jsx("div",{className:"mx-4 mb-2 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(Ka,{className:"w-4 h-4 text-yellow-500 mt-0.5 flex-shrink-0"}),s.jsxs("div",{className:"text-yellow-200 dark:text-yellow-200 text-yellow-700",children:[s.jsx("span",{className:"font-medium",children:"ZIP file will be created."}),s.jsx("span",{className:"text-yellow-600 dark:text-yellow-200/70",children:" Includes all 3MF files, thumbnails, timelapses, and photos. This may take a while and result in a large file."})]})]})}),r.printers&&s.jsxs("div",{className:"mx-4 mb-2 p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx(Jh,{className:"w-4 h-4 text-orange-500 dark:text-orange-400 mt-0.5 flex-shrink-0"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-white",children:"Include Access Codes"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"For transferring to another machine"})]})]}),s.jsx(Hn,{checked:a,onChange:o})]}),a&&s.jsx("div",{className:"mt-2 p-2 rounded bg-orange-500/10 border border-orange-500/30",children:s.jsxs("div",{className:"flex items-start gap-2 text-xs",children:[s.jsx(yn,{className:"w-3 h-3 text-orange-500 dark:text-orange-400 mt-0.5 flex-shrink-0"}),s.jsx("span",{className:"text-orange-700 dark:text-orange-200",children:"Access codes will be included in plain text. Keep this backup file secure!"})]})})]}),s.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary",children:[s.jsx("span",{className:"text-sm text-bambu-gray",children:n("backup.selectedCount",{count:m,defaultValue:`${m} categories selected`})}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx(we,{variant:"secondary",onClick:t,disabled:l,children:n("common.cancel",{defaultValue:"Cancel"})}),s.jsx(we,{onClick:p,disabled:m===0||l,className:"bg-bambu-green hover:bg-bambu-green-dark disabled:opacity-50 disabled:cursor-not-allowed min-w-[100px]",children:l?s.jsxs(s.Fragment,{children:[s.jsx(dt,{className:"w-4 h-4 mr-2 animate-spin"}),n("backup.exporting",{defaultValue:"Exporting..."})]}):s.jsxs(s.Fragment,{children:[s.jsx($r,{className:"w-4 h-4 mr-2"}),n("backup.export",{defaultValue:"Export"})]})})]})]})]})})})}const ZG={settings:"Settings",notification_providers:"Notification Providers",notification_templates:"Notification Templates",smart_plugs:"Smart Plugs",printers:"Printers",filaments:"Filaments",maintenance_types:"Maintenance Types",archives:"Archives",projects:"Projects",pending_uploads:"Pending Uploads",external_links:"External Links",api_keys:"API Keys"};function gKe({onClose:t,onRestore:e,onSuccess:n}){const[r,i]=w.useState("options"),[a,o]=w.useState(!1),[l,c]=w.useState(null),[u,d]=w.useState(null),[f,m]=w.useState(new Set),p=w.useRef(null);w.useEffect(()=>{const T=E=>{E.key==="Escape"&&r!=="restoring"&&(r==="result"&&u?.success&&n(),t())};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[t,n,r,u]);const x=T=>{const E=T.target.files?.[0];E&&c(E)},y=async()=>{if(l){i("restoring");try{const T=await e(l,a);d(T),i("result")}catch{d({success:!1,message:"Failed to restore backup. Please check the file format."}),i("result")}}},b=()=>{u?.success&&n(),t()},v=T=>{m(E=>{const C=new Set(E);return C.has(T)?C.delete(T):C.add(T),C})},N=u?.restored?Object.values(u.restored).reduce((T,E)=>T+E,0)+(u.files_restored||0):0,S=u?.total_skipped||0;return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onMouseDown:T=>{T.target===T.currentTarget&&r!=="restoring"&&t()},children:s.jsx(Nt,{className:"w-full max-w-lg",children:s.jsxs(Et,{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-3",children:[s.jsx("div",{className:`p-2 rounded-full ${r==="result"&&u?.success?"bg-bambu-green/20 text-bambu-green":r==="result"&&!u?.success?"bg-red-500/20 text-red-500":"bg-blue-500/20 text-blue-500"}`,children:r==="result"&&u?.success?s.jsx(Fn,{className:"w-5 h-5"}):r==="result"&&!u?.success?s.jsx(yn,{className:"w-5 h-5"}):s.jsx(di,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsxs("h3",{className:"text-lg font-semibold text-white",children:[r==="options"&&"Restore Backup",r==="restoring"&&"Restoring...",r==="result"&&(u?.success?"Restore Complete":"Restore Failed")]}),s.jsxs("p",{className:"text-sm text-bambu-gray",children:[r==="options"&&"Import settings from a backup file",r==="restoring"&&"Please wait while your data is being restored",r==="result"&&u?.message]})]})]}),r!=="restoring"&&s.jsx("button",{onClick:b,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:s.jsx(zt,{className:"w-5 h-5"})})]}),r==="options"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"p-4 space-y-4",children:[s.jsxs("div",{children:[s.jsx("input",{ref:p,type:"file",accept:".json,.zip",className:"hidden",onChange:x}),s.jsx("button",{type:"button",onClick:()=>p.current?.click(),className:`w-full p-4 border-2 border-dashed rounded-lg transition-colors ${l?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:l?s.jsxs("div",{className:"flex items-center justify-center gap-2 text-bambu-green",children:[s.jsx(Fn,{className:"w-5 h-5"}),s.jsx("span",{className:"font-medium",children:l.name})]}):s.jsxs("div",{className:"flex flex-col items-center gap-2 text-bambu-gray",children:[s.jsx(di,{className:"w-8 h-8"}),s.jsx("span",{children:"Click to select backup file (.json or .zip)"})]})})]}),s.jsx("div",{className:"p-3 rounded-lg bg-blue-500/10 border border-blue-500/30",children:s.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[s.jsx(yn,{className:"w-4 h-4 text-blue-500 dark:text-blue-400 mt-0.5 flex-shrink-0"}),s.jsxs("div",{className:"text-blue-700 dark:text-blue-200",children:[s.jsx("p",{className:"font-medium mb-1",children:"How duplicate handling works:"}),s.jsxs("ul",{className:"text-blue-600 dark:text-blue-200/80 space-y-1 text-xs",children:[s.jsxs("li",{children:[s.jsx("strong",{children:"Printers"})," - matched by serial number"]}),s.jsxs("li",{children:[s.jsx("strong",{children:"Smart Plugs"})," - matched by IP address"]}),s.jsxs("li",{children:[s.jsx("strong",{children:"Notification Providers"})," - matched by name"]}),s.jsxs("li",{children:[s.jsx("strong",{children:"Filaments"})," - matched by name + type + brand"]}),s.jsxs("li",{children:[s.jsx("strong",{children:"Archives"})," - matched by content hash (always skipped)"]}),s.jsxs("li",{children:[s.jsx("strong",{children:"Pending Uploads"})," - matched by filename"]}),s.jsxs("li",{children:[s.jsx("strong",{children:"Settings & Templates"})," - always overwritten"]})]})]})]})}),s.jsx("div",{className:"p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsxs("p",{className:"text-white font-medium flex items-center gap-2",children:[a?s.jsx(xr,{className:"w-4 h-4 text-orange-400"}):s.jsx(m0,{className:"w-4 h-4 text-bambu-gray"}),a?"Replace existing data":"Keep existing data"]}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:a?"Overwrite items that already exist with backup data":"Only restore items that don't already exist"})]}),s.jsx(Hn,{checked:a,onChange:o})]})}),a&&s.jsx("div",{className:"p-3 rounded-lg bg-orange-500/10 border border-orange-500/30",children:s.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[s.jsx(yn,{className:"w-4 h-4 text-orange-500 dark:text-orange-400 mt-0.5 flex-shrink-0"}),s.jsxs("div",{className:"text-orange-700 dark:text-orange-200",children:[s.jsx("span",{className:"font-medium",children:"Caution:"})," Overwriting will replace your current configurations with data from the backup. Printer access codes are never overwritten for security."]})]})})]}),s.jsxs("div",{className:"flex items-center justify-end gap-3 p-4 border-t border-bambu-dark-tertiary",children:[s.jsx(we,{type:"button",variant:"secondary",onClick:t,children:"Cancel"}),s.jsxs(we,{type:"button",onClick:y,disabled:!l,className:"bg-bambu-green hover:bg-bambu-green-dark disabled:opacity-50",children:[s.jsx(di,{className:"w-4 h-4 mr-2"}),"Restore"]})]})]}),r==="restoring"&&s.jsxs("div",{className:"p-8 flex flex-col items-center gap-4",children:[s.jsx(dt,{className:"w-12 h-12 text-bambu-green animate-spin"}),s.jsx("p",{className:"text-bambu-gray",children:"Processing backup file..."})]}),r==="result"&&u&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"p-4 space-y-4 max-h-[400px] overflow-y-auto",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{className:"p-3 rounded-lg bg-bambu-green/10 border border-bambu-green/30",children:[s.jsx("div",{className:"text-2xl font-bold text-bambu-green",children:N}),s.jsx("div",{className:"text-sm text-bambu-gray",children:"Items Restored"})]}),s.jsxs("div",{className:"p-3 rounded-lg bg-yellow-500/10 border border-yellow-500/30",children:[s.jsx("div",{className:"text-2xl font-bold text-yellow-500",children:S}),s.jsx("div",{className:"text-sm text-bambu-gray",children:"Items Skipped"})]})]}),u.restored&&Object.entries(u.restored).some(([,T])=>T>0)&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("h4",{className:"text-sm font-medium text-bambu-gray flex items-center gap-2",children:[s.jsx(Fn,{className:"w-4 h-4 text-bambu-green"}),"Restored"]}),s.jsxs("div",{className:"space-y-1",children:[Object.entries(u.restored).filter(([,T])=>T>0).map(([T,E])=>s.jsxs("div",{className:"flex items-center justify-between text-sm p-2 rounded bg-bambu-dark",children:[s.jsx("span",{className:"text-white",children:ZG[T]||T}),s.jsx("span",{className:"text-bambu-green font-medium",children:E})]},T)),(u.files_restored||0)>0&&s.jsxs("div",{className:"flex items-center justify-between text-sm p-2 rounded bg-bambu-dark",children:[s.jsx("span",{className:"text-white",children:"Files (3MF, thumbnails, etc.)"}),s.jsx("span",{className:"text-bambu-green font-medium",children:u.files_restored})]})]})]}),u.skipped&&Object.entries(u.skipped).some(([,T])=>T>0)&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("h4",{className:"text-sm font-medium text-bambu-gray flex items-center gap-2",children:[s.jsx(m0,{className:"w-4 h-4 text-yellow-500"}),"Skipped (already exist)"]}),s.jsx("div",{className:"space-y-1",children:Object.entries(u.skipped).filter(([,T])=>T>0).map(([T,E])=>{const C=u.skipped_details?.[T]||[],A=f.has(T);return s.jsxs("div",{children:[s.jsxs("button",{onClick:()=>C.length>0&&v(T),className:`w-full flex items-center justify-between text-sm p-2 rounded bg-bambu-dark ${C.length>0?"hover:bg-bambu-dark-tertiary cursor-pointer":""}`,children:[s.jsxs("span",{className:"text-white flex items-center gap-2",children:[ZG[T]||T,C.length>0&&(A?s.jsx(su,{className:"w-3 h-3"}):s.jsx(Pi,{className:"w-3 h-3"}))]}),s.jsx("span",{className:"text-yellow-500 font-medium",children:E})]}),A&&C.length>0&&s.jsxs("div",{className:"mt-1 ml-4 p-2 rounded bg-bambu-dark-tertiary text-xs text-bambu-gray space-y-1",children:[C.slice(0,10).map((O,k)=>s.jsx("div",{children:O},k)),C.length>10&&s.jsxs("div",{className:"text-bambu-gray/60",children:["...and ",C.length-10," more"]})]})]},T)})})]}),u.new_api_keys&&u.new_api_keys.length>0&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("h4",{className:"text-sm font-medium text-bambu-gray flex items-center gap-2",children:[s.jsx(yn,{className:"w-4 h-4 text-orange-500"}),"New API Keys Generated"]}),s.jsxs("div",{className:"p-3 rounded bg-orange-500/10 border border-orange-500/30",children:[s.jsx("p",{className:"text-xs text-orange-200 mb-2",children:"These keys are only shown once. Copy them now!"}),s.jsx("div",{className:"space-y-2",children:u.new_api_keys.map((T,E)=>s.jsxs("div",{className:"p-2 rounded bg-bambu-dark",children:[s.jsx("div",{className:"text-sm text-white font-medium mb-1",children:T.name}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("code",{className:"text-xs text-bambu-green bg-bambu-dark-tertiary px-2 py-1 rounded font-mono flex-1 break-all",children:T.key}),s.jsx("button",{onClick:()=>navigator.clipboard.writeText(T.key),className:"text-xs text-bambu-gray hover:text-white px-2 py-1 rounded bg-bambu-dark-tertiary",children:"Copy"})]})]},E))})]})]}),N===0&&S===0&&s.jsx("div",{className:"p-4 text-center text-bambu-gray",children:"No data was found to restore in the backup file."})]}),s.jsx("div",{className:"flex items-center justify-end gap-3 p-4 border-t border-bambu-dark-tertiary",children:s.jsx(we,{onClick:b,children:"Close"})})]})]})})})}function JG({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(Fn,{className:"w-3 h-3"}),failed:s.jsx(ta,{className:"w-3 h-3"}),skipped:s.jsx(m0,{className:"w-3 h-3"}),running:s.jsx(dt,{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 xKe(t){return t?new Date(t).toLocaleString():"-"}function eW(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 bKe(){const t=on(),{showToast:e}=Vn(),[n,r]=w.useState(""),[i,a]=w.useState(""),[o,l]=w.useState("main"),[c,u]=w.useState(!1),[d,f]=w.useState("daily"),[m,p]=w.useState(!0),[x,y]=w.useState(!0),[b,v]=w.useState(!1),[N,S]=w.useState(!0),[T,E]=w.useState(!1),[C,A]=w.useState(!1),[O,k]=w.useState(!1),[R,F]=w.useState(null),L=w.useRef(null),K=w.useRef(!1),{data:j,isLoading:W}=ut({queryKey:["github-backup-config"],queryFn:he.getGitHubBackupConfig}),{data:Y}=ut({queryKey:["github-backup-status"],queryFn:he.getGitHubBackupStatus,refetchInterval:fe=>fe.state.data?.is_running?500:1e4}),{data:q}=ut({queryKey:["github-backup-logs"],queryFn:()=>he.getGitHubBackupLogs(20)}),{data:Q}=ut({queryKey:["cloud-status"],queryFn:he.getCloudStatus}),{data:ee}=ut({queryKey:["printers"],queryFn:he.getPrinters}),re=ee?.map(fe=>{const le=t.getQueryData(["printerStatus",fe.id]);return{printer:fe,connected:le?.connected??!1}})??[],z=re.length,G=re.filter(fe=>fe.connected).length,ae=z>0&&G===0,se=G>0&&G<z;w.useEffect(()=>{j&&(r(j.repository_url),l(j.branch),u(j.schedule_enabled),f(j.schedule_type),p(j.backup_kprofiles),y(j.backup_cloud_profiles),v(j.backup_settings),S(j.enabled),a(""),setTimeout(()=>{K.current=!0},100))},[j]);const ue=w.useCallback(async(fe=!1)=>{if(j?.has_token)try{fe&&i?(await he.saveGitHubBackupConfig({repository_url:n,access_token:i,branch:o,schedule_enabled:c,schedule_type:d,backup_kprofiles:m,backup_cloud_profiles:x,backup_settings:b,enabled:N}),a(""),e("Token updated")):(await he.updateGitHubBackupConfig({repository_url:n,branch:o,schedule_enabled:c,schedule_type:d,backup_kprofiles:m,backup_cloud_profiles:x,backup_settings:b,enabled:N}),e("Settings saved")),t.invalidateQueries({queryKey:["github-backup-config"]}),t.invalidateQueries({queryKey:["github-backup-status"]})}catch(le){e(`Failed to save: ${le.message}`,"error")}},[j?.has_token,n,i,o,c,d,m,x,b,N,t,e]);w.useEffect(()=>{if(!(!K.current||!j?.has_token))return L.current&&clearTimeout(L.current),L.current=setTimeout(()=>{ue(!1)},500),()=>{L.current&&clearTimeout(L.current)}},[n,o,c,d,m,x,b,N,ue,j?.has_token]),w.useEffect(()=>{if(!(!K.current||!j?.has_token||!i))return L.current&&clearTimeout(L.current),L.current=setTimeout(()=>{ue(!0)},1e3),()=>{L.current&&clearTimeout(L.current)}},[i,ue,j?.has_token]);const pe=pt({mutationFn:fe=>he.saveGitHubBackupConfig(fe),onSuccess:()=>{t.invalidateQueries({queryKey:["github-backup-config"]}),t.invalidateQueries({queryKey:["github-backup-status"]}),e("GitHub backup enabled"),a(""),K.current=!0},onError:fe=>{e(`Failed to save: ${fe.message}`,"error")}}),ce=pt({mutationFn:he.triggerGitHubBackup,onSuccess:fe=>{t.invalidateQueries({queryKey:["github-backup-status"]}),t.invalidateQueries({queryKey:["github-backup-logs"]}),fe.success?fe.files_changed>0?e(`Backup complete - ${fe.files_changed} files updated`):e("Backup skipped - no changes"):e(`Backup failed: ${fe.message}`,"error")},onError:fe=>{e(`Backup failed: ${fe.message}`,"error")}}),Me=pt({mutationFn:()=>he.clearGitHubBackupLogs(0),onSuccess:fe=>{t.invalidateQueries({queryKey:["github-backup-logs"]}),e(`Cleared ${fe.deleted} logs`)},onError:fe=>{e(`Failed to clear logs: ${fe.message}`,"error")}}),me=async()=>{k(!0),F(null);try{let fe;if(i){if(!n){e("Enter repository URL","error"),k(!1);return}fe=await he.testGitHubConnection(n,i)}else if(j?.has_token)fe=await he.testGitHubStoredConnection();else{e("Enter repository URL and access token","error"),k(!1);return}F({success:fe.success,message:fe.message})}catch(fe){F({success:!1,message:fe.message})}finally{k(!1)}},Ee=()=>{if(!n){e("Repository URL is required","error");return}if(!i){e("Access token is required","error");return}pe.mutate({repository_url:n,access_token:i,branch:o,schedule_enabled:c,schedule_type:d,backup_kprofiles:m,backup_cloud_profiles:x,backup_settings:b,enabled:N})};return W?s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx(dt,{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(Nt,{children:[s.jsx(Qn,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Wj,{className:"w-5 h-5 text-gray-400"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"GitHub Backup"})]}),j&&Q?.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(Hn,{checked:N,onChange:S})]})]})}),s.jsx(Et,{className:"space-y-4",children:Q?.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:fe=>{r(fe.target.value),F(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 ",j?.has_token&&s.jsx("span",{className:"text-green-400",children:"(saved)"})]}),s.jsx("input",{type:"password",value:i,onChange:fe=>{a(fe.target.value),F(null)},placeholder:j?.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:fe=>l(fe.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:fe=>{fe.target.value==="disabled"?u(!1):(u(!0),f(fe.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 ${ae?"cursor-not-allowed opacity-60":"cursor-pointer"}`,children:[s.jsx("input",{type:"checkbox",checked:m,onChange:fe=>p(fe.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:ae}),s.jsxs("div",{className:"flex-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`text-sm ${ae?"text-bambu-gray":"text-white"}`,children:"K-Profiles"}),ae&&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(yn,{className:"w-3 h-3"}),"No printers connected"]}),se&&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(yn,{className:"w-3 h-3"}),G,"/",z," 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:fe=>y(fe.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:!Q?.is_authenticated}),s.jsxs("div",{children:[s.jsx("span",{className:`text-sm ${Q?.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:b,onChange:fe=>v(fe.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:[Y?.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:Y.last_backup_at?s.jsxs(s.Fragment,{children:[s.jsxs("span",{children:["Last backup: ",eW(Y.last_backup_at)]}),s.jsx(JG,{status:Y.last_backup_status})]}):s.jsx("span",{children:"No backups yet"})}),Y.next_scheduled_run&&s.jsxs("span",{className:"text-bambu-gray",children:[s.jsx(Kn,{className:"w-3 h-3 inline mr-1"}),"Next: ",eW(Y.next_scheduled_run)]})]}),R&&s.jsxs("div",{className:`text-sm flex items-center gap-1 ${R.success?"text-green-400":"text-red-400"}`,children:[R.success?s.jsx(Fn,{className:"w-4 h-4"}):s.jsx(ta,{className:"w-4 h-4"}),R.message]}),s.jsx("div",{className:"flex flex-wrap items-center gap-2",children:Y?.configured?s.jsx(s.Fragment,{children:ce.isPending||Y.is_running?s.jsxs("div",{className:"flex items-center gap-2 text-bambu-green",children:[s.jsx(dt,{className:"w-4 h-4 animate-spin"}),s.jsx("span",{className:"text-sm",children:Y.progress||"Starting backup..."})]}):s.jsxs(s.Fragment,{children:[s.jsxs(we,{variant:"primary",size:"sm",onClick:()=>ce.mutate(),disabled:!j?.enabled,children:[s.jsx(Po,{className:"w-4 h-4"}),"Backup Now"]}),s.jsxs(we,{variant:"secondary",size:"sm",onClick:me,disabled:O,children:[O?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(xr,{className:"w-4 h-4"}),"Test"]})]})}):s.jsxs(s.Fragment,{children:[s.jsxs(we,{variant:"primary",size:"sm",onClick:Ee,disabled:pe.isPending||!n||!i,children:[pe.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(Fn,{className:"w-4 h-4"}),"Enable Backup"]}),s.jsxs(we,{variant:"secondary",size:"sm",onClick:me,disabled:O||!n||!i,children:[O?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(xr,{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(yn,{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."})]})})]}),q&&q.length>0&&s.jsxs(Nt,{children:[s.jsx(Qn,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(f0,{className:"w-5 h-5 text-gray-400"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"History"})]}),s.jsxs(we,{variant:"ghost",size:"sm",onClick:()=>Me.mutate(),disabled:Me.isPending,children:[s.jsx(un,{className:"w-4 h-4"}),"Clear"]})]})}),s.jsx(Et,{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:q.slice(0,10).map(fe=>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:xKe(fe.started_at)}),s.jsx("td",{className:"py-2 px-2",children:s.jsx(JG,{status:fe.status})}),s.jsx("td",{className:"py-2 px-2",children:fe.commit_sha?s.jsxs("a",{href:`${j?.repository_url}/commit/${fe.commit_sha}`,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-green hover:underline inline-flex items-center gap-1",children:[fe.commit_sha.substring(0,7),s.jsx(Ur,{className:"w-3 h-3"})]}):s.jsx("span",{className:"text-bambu-gray",children:"-"})})]},fe.id))})]})})})]})]}),s.jsx("div",{className:"space-y-6",children:s.jsxs(Nt,{children:[s.jsx(Qn,{children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Qc,{className:"w-5 h-5 text-gray-400"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Local Backup"})]})}),s.jsxs(Et,{className:"space-y-4",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Export or import your Bambuddy data as a local file for manual backup or migration."}),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:"Export Data"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Download all settings, printers, and profiles"})]}),s.jsxs(we,{variant:"secondary",size:"sm",onClick:()=>E(!0),children:[s.jsx($r,{className:"w-4 h-4"}),"Export"]})]}),s.jsxs("div",{className:"flex items-center justify-between py-3",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:"Import Backup"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Restore from a previous export file"})]}),s.jsxs(we,{variant:"secondary",size:"sm",onClick:()=>A(!0),children:[s.jsx(di,{className:"w-4 h-4"}),"Import"]})]})]})]})}),T&&s.jsx(pKe,{onClose:()=>E(!1),onExport:async fe=>{E(!1);try{const{blob:le,filename:Be}=await he.exportBackup(fe),V=URL.createObjectURL(le),$=document.createElement("a");$.href=V,$.download=Be,$.click(),URL.revokeObjectURL(V),e("Backup downloaded successfully")}catch{e("Failed to create backup","error")}}}),C&&s.jsx(gKe,{onClose:()=>A(!1),onRestore:async(fe,le)=>await he.importBackup(fe,le),onSuccess:()=>{A(!1),e("Backup restored successfully"),t.invalidateQueries()}})]})}const yKe={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 vKe(t,e){const n=e.replace("#/","").split("/");let r=t;for(const i of n)r=r[i];return r}function Lb(t,e,n=0){if(n>5)return"...";if(e.$ref)return Lb(t,vKe(t,e.$ref),n+1);if(e.allOf){const r={};for(const i of e.allOf){const a=Lb(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?[Lb(t,e.items,n+1)]:[];case"object":if(e.properties){const r={};for(const[i,a]of Object.entries(e.properties))r[i]=Lb(t,a,n+1);return r}return{};default:return null}}function _Ke({path:t,method:e,spec:n,schema:r,apiKey:i}){const[a,o]=w.useState(!1),[l,c]=w.useState({}),[u,d]=w.useState(""),[f,m]=w.useState(null),[p,x]=w.useState(!1),[y,b]=w.useState(!1);w.useEffect(()=>{if(a&&n.parameters){const O={};for(const k of n.parameters)k.schema?.default!==void 0&&(O[k.name]=String(k.schema.default));c(k=>({...O,...k}))}},[a,n.parameters]),w.useEffect(()=>{if(a&&n.requestBody?.content?.["application/json"]?.schema&&!u){const O=n.requestBody.content["application/json"].schema,k=Lb(r,O);d(JSON.stringify(k,null,2))}},[a,n.requestBody,r,u]);const N=(()=>{const O=[];for(const k of n.parameters||[])if(k.in==="path"||k.required){const R=l[k.name];(R===void 0||R==="")&&O.push(k.name)}return O})(),S=async()=>{if(N.length>0){m({status:0,statusText:"Validation Error",headers:{},body:`Missing required parameters: ${N.join(", ")}`,duration:0});return}x(!0),m(null);try{let O=t;const k=new URLSearchParams;for(const re of n.parameters||[]){const z=l[re.name];z!==void 0&&z!==""&&(re.in==="path"?O=O.replace(`{${re.name}}`,encodeURIComponent(z)):re.in==="query"&&k.append(re.name,z))}const R=k.toString(),F=`${O}${R?`?${R}`:""}`,L={"Content-Type":"application/json"};i&&(L["X-API-Key"]=i);const K={method:e.toUpperCase(),headers:L};["post","put","patch"].includes(e)&&u&&(K.body=u);const j=performance.now(),W=await fetch(F,K),Y=Math.round(performance.now()-j),q={};W.headers.forEach((re,z)=>{q[z]=re});let Q;W.headers.get("content-type")?.includes("application/json")?Q=await W.json():Q=await W.text(),m({status:W.status,statusText:W.statusText,headers:q,body:Q,duration:Y})}catch(O){m({status:0,statusText:"Network Error",headers:{},body:O instanceof Error?O.message:"Unknown error",duration:0})}finally{x(!1)}},T=async()=>{if(f){const O=typeof f.body=="string"?f.body:JSON.stringify(f.body,null,2);try{await navigator.clipboard.writeText(O),b(!0),setTimeout(()=>b(!1),2e3)}catch{const k=document.createElement("textarea");k.value=O,k.style.position="fixed",k.style.left="-999999px",document.body.appendChild(k),k.select(),document.execCommand("copy"),document.body.removeChild(k),b(!0),setTimeout(()=>b(!1),2e3)}}},E=(n.parameters||[]).filter(O=>O.in==="path"),C=(n.parameters||[]).filter(O=>O.in==="query"),A=["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(Pi,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}):s.jsx(Ys,{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 ${yKe[e]||"bg-gray-500/20 text-gray-400"}`,children:e}),s.jsx("code",{className:"text-sm text-white font-mono flex-1 truncate",children:t}),n.summary&&s.jsx("span",{className:"text-sm text-bambu-gray truncate max-w-[40%]",children:n.summary})]}),a&&s.jsxs("div",{className:"border-t border-bambu-dark-tertiary p-4 space-y-4 bg-bambu-dark/50",children:[n.description&&s.jsx("p",{className:"text-sm text-bambu-gray",children:n.description}),E.length>0&&s.jsxs("div",{className:"space-y-2",children:[s.jsx("h4",{className:"text-sm font-medium text-white",children:"Path Parameters"}),s.jsx("div",{className:"space-y-2",children:E.map(O=>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:[O.name,O.required&&s.jsx("span",{className:"text-red-400 ml-1",children:"*"})]}),s.jsx("input",{type:"text",value:l[O.name]||"",onChange:k=>c(R=>({...R,[O.name]:k.target.value})),placeholder:O.description||O.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"})]},O.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(O=>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:[O.name,O.required&&s.jsx("span",{className:"text-red-400 ml-1",children:"*"})]}),O.schema?.enum?s.jsxs("select",{value:l[O.name]||"",onChange:k=>c(R=>({...R,[O.name]:k.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 --"}),O.schema.enum.map(k=>s.jsx("option",{value:k,children:k},k))]}):s.jsx("input",{type:"text",value:l[O.name]||"",onChange:k=>c(R=>({...R,[O.name]:k.target.value})),placeholder:O.description||O.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"})]},O.name))})]}),A&&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:O=>d(O.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(we,{onClick:S,disabled:p,children:[p?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(Po,{className:"w-4 h-4"}),"Execute"]}),N.length>0&&s.jsxs("span",{className:"text-xs text-yellow-400 flex items-center gap-1",children:[s.jsx(ji,{className:"w-3 h-3"}),"Fill in: ",N.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(we,{variant:"secondary",size:"sm",onClick:T,children:y?s.jsx(Fn,{className:"w-3 h-3 text-green-400"}):s.jsx(ol,{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 wKe({apiKey:t=""}){const[e,n]=w.useState(null),[r,i]=w.useState(!0),[a,o]=w.useState(null),[l,c]=w.useState(new Set),[u,d]=w.useState("");if(w.useEffect(()=>{async function b(){try{const v=await fetch("/openapi.json");if(!v.ok)throw new Error("Failed to fetch OpenAPI schema");const N=await v.json();n(N)}catch(v){o(v instanceof Error?v.message:"Unknown error")}finally{i(!1)}}b()},[]),r)return s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(dt,{className:"w-8 h-8 text-bambu-green animate-spin"})});if(a||!e)return s.jsx(Nt,{children:s.jsx(Et,{className:"py-8",children:s.jsxs("div",{className:"text-center text-red-400",children:[s.jsx(ji,{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[b,v]of Object.entries(e.paths))for(const[N,S]of Object.entries(v)){if(N==="parameters")continue;const T=S.tags||["Other"];for(const E of T)f[E]||(f[E]=[]),f[E].push({path:b,method:N,spec:S})}const m=Object.entries(f).map(([b,v])=>{if(!u)return{tag:b,endpoints:v};const N=v.filter(({path:S,method:T,spec:E})=>{const C=u.toLowerCase();return S.toLowerCase().includes(C)||T.toLowerCase().includes(C)||(E.summary?.toLowerCase()||"").includes(C)||(E.description?.toLowerCase()||"").includes(C)});return{tag:b,endpoints:N}}).filter(({endpoints:b})=>b.length>0).sort((b,v)=>b.tag.localeCompare(v.tag)),p=b=>{c(v=>{const N=new Set(v);return N.has(b)?N.delete(b):N.add(b),N})},x=()=>{c(new Set(m.map(b=>b.tag)))},y=()=>{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:b=>d(b.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(we,{variant:"secondary",size:"sm",onClick:x,children:"Expand All"}),s.jsx(we,{variant:"secondary",size:"sm",onClick:y,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(Ur,{className:"w-4 h-4"}),"Swagger UI"]})]})]}),s.jsxs("p",{className:"text-sm text-bambu-gray",children:[m.reduce((b,v)=>b+v.endpoints.length,0)," endpoints in ",m.length," categories"]}),s.jsx("div",{className:"space-y-3",children:m.map(({tag:b,endpoints:v})=>s.jsxs(Nt,{children:[s.jsx("button",{onClick:()=>p(b),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(b)?s.jsx(Pi,{className:"w-5 h-5 text-bambu-gray"}):s.jsx(Ys,{className:"w-5 h-5 text-bambu-gray"}),s.jsx("h3",{className:"text-base font-semibold text-white capitalize",children:b.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(b)&&s.jsx(Et,{className:"pt-0 space-y-2",children:v.map(({path:N,method:S,spec:T})=>s.jsx(_Ke,{path:N,method:S,spec:T,schema:e,apiKey:t},`${S}-${N}`))})]},b))})]})}const SKe=["general","network","plugs","notifications","filament","apikeys","virtual-printer","users","backup"];function NKe(){const t=on(),e=hl(),[n,r]=DW(),{t:i,i18n:a}=Og(),{showToast:o}=Vn(),{authEnabled:l,user:c,refreshAuth:u}=rh(),{mode:d,darkStyle:f,darkBackground:m,darkAccent:p,lightStyle:x,lightBackground:y,lightAccent:b,setDarkStyle:v,setDarkBackground:N,setDarkAccent:S,setLightStyle:T,setLightBackground:E,setLightAccent:C}=nh(),[A,O]=w.useState(null),[k,R]=w.useState(!1),[F,L]=w.useState(null),[K,j]=w.useState(!1),[W,Y]=w.useState(null),[q,Q]=w.useState(null),[ee,re]=w.useState(!1),[z,G]=w.useState(_q()),ae=n.get("tab"),se=ae&&SKe.includes(ae)?ae:"general",[ue,pe]=w.useState(se),ce=ye=>{pe(ye),ye==="general"?n.delete("tab"):n.set("tab",ye),r(n,{replace:!0})},[Me,me]=w.useState(!1),[Ee,fe]=w.useState(""),[le,Be]=w.useState({can_queue:!0,can_control_printer:!1,can_read_status:!0}),[V,$]=w.useState(null),[X,U]=w.useState(null),[B,oe]=w.useState(""),[Te,je]=w.useState(!1),[Ce,H]=w.useState(!1),[D,Z]=w.useState(null),[xe,Ne]=w.useState(!1),[ve,$e]=w.useState(!1),[Le,qe]=w.useState(null),[Ke,Ye]=w.useState(!1),[ie,te]=w.useState({}),[Se,ze]=w.useState({}),nt=ye=>{G(ye),Mfe(ye)},ne=()=>{localStorage.removeItem("sidebarOrder"),window.location.reload()},{data:Pe,isLoading:be}=ut({queryKey:["settings"],queryFn:he.getSettings}),{data:Oe,isLoading:Ue}=ut({queryKey:["smart-plugs"],queryFn:he.getSmartPlugs}),{data:Ae,isLoading:Je}=ut({queryKey:["smart-plugs-energy",Oe?.map(ye=>ye.id)],queryFn:async()=>{if(!Oe||Oe.length===0)return null;const ye=await Promise.all(Oe.filter(Yt=>Yt.enabled).map(async Yt=>{try{const rn=await he.getSmartPlugStatus(Yt.id);return{plug:Yt,status:rn}}catch{return{plug:Yt,status:null}}}));let De=0,ht=0,Mt=0,at=0,Xt=0;for(const{status:Yt}of ye)Yt?.reachable&&Yt.energy&&(Xt++,Yt.energy.power!=null&&(De+=Yt.energy.power),Yt.energy.today!=null&&(ht+=Yt.energy.today),Yt.energy.yesterday!=null&&(Mt+=Yt.energy.yesterday),Yt.energy.total!=null&&(at+=Yt.energy.total));return{totalPower:De,totalToday:ht,totalYesterday:Mt,totalLifetime:at,reachableCount:Xt,totalPlugs:Oe.filter(Yt=>Yt.enabled).length}},enabled:ue==="plugs"&&!!Oe&&Oe.length>0,refetchInterval:ue==="plugs"?1e4:!1}),{data:gt,isLoading:Pt}=ut({queryKey:["notification-providers"],queryFn:he.getNotificationProviders}),{data:Ot,isLoading:cn}=ut({queryKey:["api-keys"],queryFn:he.getAPIKeys}),It=pt({mutationFn:ye=>he.createAPIKey(ye),onSuccess:ye=>{$(ye.key||null),me(!1),fe(""),t.invalidateQueries({queryKey:["api-keys"]}),o("API key created")},onError:ye=>{o(`Failed to create API key: ${ye.message}`,"error")}}),_n=pt({mutationFn:ye=>he.deleteAPIKey(ye),onSuccess:()=>{t.invalidateQueries({queryKey:["api-keys"]}),o("API key deleted")},onError:ye=>{o(`Failed to delete API key: ${ye.message}`,"error")}}),{data:bt}=ut({queryKey:["printers"],queryFn:he.getPrinters}),{data:Gt,isLoading:ln}=ut({queryKey:["notification-templates"],queryFn:he.getNotificationTemplates}),{data:Tt}=ut({queryKey:["virtual-printer-settings"],queryFn:z1.getSettings,refetchInterval:1e4}),Rr=Tt?.status?.running??!1,{data:Xr}=ut({queryKey:["ffmpeg-status"],queryFn:he.checkFfmpeg}),{data:An}=ut({queryKey:["version"],queryFn:he.getVersion}),{data:sn,refetch:Sr,isRefetching:si}=ut({queryKey:["updateCheck"],queryFn:he.checkForUpdates,staleTime:300*1e3}),{data:Dr,refetch:_e}=ut({queryKey:["updateStatus"],queryFn:he.getUpdateStatus,refetchInterval:ye=>{const De=ye.state.data;return De?.status==="downloading"||De?.status==="installing"?1e3:!1}}),{data:Xe}=ut({queryKey:["mqtt-status"],queryFn:he.getMQTTStatus,refetchInterval:ue==="network"?5e3:!1}),{data:ot}=ut({queryKey:["github-backup-status"],queryFn:he.getGitHubBackupStatus}),{data:ct}=ut({queryKey:["cloud-status"],queryFn:he.getCloudStatus}),rt=pt({mutationFn:he.applyUpdate,onSuccess:ye=>{ye.is_docker?o(ye.message,"error"):_e()}}),[Rt,de]=w.useState(null),Re=pt({mutationFn:he.testAllNotificationProviders,onSuccess:ye=>{de(ye),t.invalidateQueries({queryKey:["notification-providers"]}),ye.failed===0?o(`All ${ye.tested} providers tested successfully!`,"success"):o(`${ye.success}/${ye.tested} providers succeeded`,ye.failed>0?"error":"success")},onError:ye=>{o(`Failed to test providers: ${ye.message}`,"error")}}),Ve=pt({mutationFn:async ye=>{if(!Oe)return{success:0,failed:0};const De=Oe.filter(Mt=>Mt.enabled),ht=await Promise.all(De.map(async Mt=>{try{return await he.controlSmartPlug(Mt.id,ye),{success:!0}}catch{return{success:!1}}}));return{success:ht.filter(Mt=>Mt.success).length,failed:ht.filter(Mt=>!Mt.success).length}},onSuccess:(ye,De)=>{t.invalidateQueries({queryKey:["smart-plugs"]}),t.invalidateQueries({queryKey:["smart-plugs-energy"]}),ye.failed===0?o(`All ${ye.success} plugs turned ${De}`,"success"):o(`${ye.success} plugs turned ${De}, ${ye.failed} failed`,"error")},onError:ye=>{o(`Failed: ${ye.message}`,"error")}}),He=w.useRef(null),Fe=w.useRef(!1),mt=w.useRef(!0);w.useEffect(()=>{if(Pe&&!A){const ye={...Pe,external_url:Pe.external_url||window.location.origin};O(ye),setTimeout(()=>{mt.current=!1},100)}},[Pe,A]);const St=pt({mutationFn:he.updateSettings,onSuccess:ye=>{t.setQueryData(["settings"],ye),O(ye),t.invalidateQueries({queryKey:["archiveStats"]}),o("Settings saved","success")},onError:ye=>{o(`Failed to save: ${ye.message}`,"error")},onSettled:()=>{Fe.current=!1}}),kt=pt({mutationFn:({id:ye,data:De})=>he.updatePrinter(ye,De),onSuccess:()=>{t.invalidateQueries({queryKey:["printers"]}),o("Camera settings saved","success")},onError:ye=>{o(`Failed to update printer: ${ye.message}`,"error")}});w.useEffect(()=>{if(!(mt.current||!A||!Pe||!(Pe.auto_archive!==A.auto_archive||Pe.save_thumbnails!==A.save_thumbnails||Pe.capture_finish_photo!==A.capture_finish_photo||Pe.default_filament_cost!==A.default_filament_cost||Pe.currency!==A.currency||Pe.energy_cost_per_kwh!==A.energy_cost_per_kwh||Pe.energy_tracking_mode!==A.energy_tracking_mode||Pe.check_updates!==A.check_updates||Pe.notification_language!==A.notification_language||Pe.ams_humidity_good!==A.ams_humidity_good||Pe.ams_humidity_fair!==A.ams_humidity_fair||Pe.ams_temp_good!==A.ams_temp_good||Pe.ams_temp_fair!==A.ams_temp_fair||Pe.ams_history_retention_days!==A.ams_history_retention_days||Pe.per_printer_mapping_expanded!==A.per_printer_mapping_expanded||Pe.date_format!==A.date_format||Pe.time_format!==A.time_format||Pe.default_printer_id!==A.default_printer_id||Pe.ftp_retry_enabled!==A.ftp_retry_enabled||Pe.ftp_retry_count!==A.ftp_retry_count||Pe.ftp_retry_delay!==A.ftp_retry_delay||Pe.ftp_timeout!==A.ftp_timeout||Pe.mqtt_enabled!==A.mqtt_enabled||Pe.mqtt_broker!==A.mqtt_broker||Pe.mqtt_port!==A.mqtt_port||Pe.mqtt_username!==A.mqtt_username||Pe.mqtt_password!==A.mqtt_password||Pe.mqtt_topic_prefix!==A.mqtt_topic_prefix||Pe.mqtt_use_tls!==A.mqtt_use_tls||Pe.external_url!==A.external_url||Pe.ha_enabled!==A.ha_enabled||Pe.ha_url!==A.ha_url||Pe.ha_token!==A.ha_token||(Pe.library_archive_mode??"ask")!==(A.library_archive_mode??"ask")||Number(Pe.library_disk_warning_gb??5)!==Number(A.library_disk_warning_gb??5)||(Pe.camera_view_mode??"window")!==(A.camera_view_mode??"window")||Pe.prometheus_enabled!==A.prometheus_enabled||Pe.prometheus_token!==A.prometheus_token))&&!Fe.current)return He.current&&clearTimeout(He.current),He.current=setTimeout(()=>{if(Fe.current)return;Fe.current=!0;const De={auto_archive:A.auto_archive,save_thumbnails:A.save_thumbnails,capture_finish_photo:A.capture_finish_photo,default_filament_cost:A.default_filament_cost,currency:A.currency,energy_cost_per_kwh:A.energy_cost_per_kwh,energy_tracking_mode:A.energy_tracking_mode,check_updates:A.check_updates,notification_language:A.notification_language,ams_humidity_good:A.ams_humidity_good,ams_humidity_fair:A.ams_humidity_fair,ams_temp_good:A.ams_temp_good,ams_temp_fair:A.ams_temp_fair,ams_history_retention_days:A.ams_history_retention_days,per_printer_mapping_expanded:A.per_printer_mapping_expanded,date_format:A.date_format,time_format:A.time_format,default_printer_id:A.default_printer_id,ftp_retry_enabled:A.ftp_retry_enabled,ftp_retry_count:A.ftp_retry_count,ftp_retry_delay:A.ftp_retry_delay,ftp_timeout:A.ftp_timeout,mqtt_enabled:A.mqtt_enabled,mqtt_broker:A.mqtt_broker,mqtt_port:A.mqtt_port,mqtt_username:A.mqtt_username,mqtt_password:A.mqtt_password,mqtt_topic_prefix:A.mqtt_topic_prefix,mqtt_use_tls:A.mqtt_use_tls,external_url:A.external_url,ha_enabled:A.ha_enabled,ha_url:A.ha_url,ha_token:A.ha_token,library_archive_mode:A.library_archive_mode,library_disk_warning_gb:A.library_disk_warning_gb,camera_view_mode:A.camera_view_mode,prometheus_enabled:A.prometheus_enabled,prometheus_token:A.prometheus_token};St.mutate(De)},500),()=>{He.current&&clearTimeout(He.current)}},[A,Pe,St]);const xt=w.useCallback((ye,De)=>{O(ht=>ht?{...ht,[ye]:De}:null)},[]),$t=async(ye,De,ht)=>{if(!De){o("Please enter a camera URL","error");return}ze(Mt=>({...Mt,[ye]:!0})),te(Mt=>({...Mt,[ye]:null}));try{const Mt=await he.testExternalCamera(ye,De,ht);te(at=>({...at,[ye]:Mt})),Mt.success?o(`Camera connected${Mt.resolution?` (${Mt.resolution})`:""}`,"success"):o(Mt.error||"Connection failed","error")}catch(Mt){const at=Mt instanceof Error?Mt.message:"Test failed";te(Xt=>({...Xt,[ye]:{success:!1,error:at}})),o(at,"error")}finally{ze(Mt=>({...Mt,[ye]:!1}))}},[jt,wt]=w.useState({}),Qt=w.useRef({});w.useEffect(()=>{if(bt){const ye={};bt.forEach(De=>{De.external_camera_url&&jt[De.id]===void 0&&(ye[De.id]=De.external_camera_url)}),Object.keys(ye).length>0&&wt(De=>({...De,...ye}))}},[bt]);const Kt=(ye,De)=>{wt(ht=>({...ht,[ye]:De})),Qt.current[ye]&&clearTimeout(Qt.current[ye]),Qt.current[ye]=setTimeout(()=>{kt.mutate({id:ye,data:{external_camera_url:De||null}})},800)},fn=(ye,De)=>{const ht={};De.type!==void 0&&(ht.external_camera_type=De.type||null),De.enabled!==void 0&&(ht.external_camera_enabled=De.enabled),kt.mutate({id:ye,data:ht})};return be||!A?s.jsx("div",{className:"p-4 md:p-8 flex justify-center",children:s.jsx(dt,{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:"Settings"}),s.jsx("p",{className:"text-bambu-gray",children:"Configure Bambuddy"})]}),s.jsxs("div",{className:"flex gap-1 mb-6 border-b border-bambu-dark-tertiary overflow-x-auto",children:[s.jsx("button",{onClick:()=>ce("general"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px ${ue==="general"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:"General"}),s.jsxs("button",{onClick:()=>ce("plugs"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${ue==="plugs"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(Vs,{className:"w-4 h-4"}),"Smart Plugs",Oe&&Oe.length>0&&s.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:Oe.length})]}),s.jsxs("button",{onClick:()=>ce("notifications"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${ue==="notifications"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(cf,{className:"w-4 h-4"}),"Notifications",gt&&gt.length>0&&s.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:gt.length})]}),s.jsxs("button",{onClick:()=>ce("filament"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${ue==="filament"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(uue,{className:"w-4 h-4"}),"Filament"]}),s.jsxs("button",{onClick:()=>ce("network"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${ue==="network"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(Hp,{className:"w-4 h-4"}),"Network",s.jsx("span",{className:`w-2 h-2 rounded-full ${Xe?.enabled?"bg-green-400":"bg-gray-500"}`})]}),s.jsxs("button",{onClick:()=>ce("apikeys"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${ue==="apikeys"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(Jh,{className:"w-4 h-4"}),"API Keys",Ot&&Ot.length>0&&s.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:Ot.length})]}),s.jsxs("button",{onClick:()=>ce("virtual-printer"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${ue==="virtual-printer"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(Mr,{className:"w-4 h-4"}),"Virtual Printer",s.jsx("span",{className:`w-2 h-2 rounded-full ${Rr?"bg-green-400":"bg-gray-500"}`})]}),s.jsxs("button",{onClick:()=>ce("users"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${ue==="users"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(_d,{className:"w-4 h-4"}),"Users",l&&s.jsx("span",{className:`w-2 h-2 rounded-full ${l?"bg-green-400":"bg-gray-500"}`})]}),s.jsxs("button",{onClick:()=>ce("backup"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${ue==="backup"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(Qc,{className:"w-4 h-4"}),"Backup",s.jsx("span",{className:`w-2 h-2 rounded-full ${ct?.is_authenticated&&ot?.configured&&ot?.enabled?"bg-green-400":"bg-gray-500"}`})]})]}),ue==="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(Nt,{children:[s.jsx(Qn,{children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.general")})}),s.jsxs(Et,{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[s.jsx(jd,{className:"w-4 h-4 inline mr-1"}),i("settings.language")]}),s.jsx("select",{value:a.language,onChange:ye=>a.changeLanguage(ye.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:ZU.map(ye=>s.jsxs("option",{value:ye.code,children:[ye.nativeName," (",ye.name,")"]},ye.code))}),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.jsx("select",{value:z,onChange:ye=>nt(ye.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:g0.map(ye=>s.jsx("option",{value:ye.to,children:i(ye.labelKey)},ye.id))}),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("select",{value:A.date_format||"system",onChange:ye=>xt("date_format",ye.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:"system",children:"System Default"}),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.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Time Format"}),s.jsxs("select",{value:A.time_format||"system",onChange:ye=>xt("time_format",ye.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:"system",children:"System Default"}),s.jsx("option",{value:"12h",children:"12-hour (3:30 PM)"}),s.jsx("option",{value:"24h",children:"24-hour (15:30)"})]})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Default Printer"}),s.jsxs("select",{value:A.default_printer_id??"",onChange:ye=>xt("default_printer_id",ye.target.value?Number(ye.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 default (ask each time)"}),bt?.map(ye=>s.jsx("option",{value:ye.id,children:ye.name},ye.id))]}),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:"Sidebar order"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Drag items in the sidebar to reorder. Reset to default order here."})]}),s.jsxs(we,{variant:"secondary",size:"sm",onClick:ne,children:[s.jsx(Zf,{className:"w-4 h-4"}),"Reset"]})]})]})]}),s.jsxs(Nt,{children:[s.jsx(Qn,{children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(dD,{className:"w-5 h-5"}),"Appearance"]})}),s.jsxs(Et,{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:m,onChange:ye=>{N(ye.target.value),o("Settings saved","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:p,onChange:ye=>{S(ye.target.value),o("Settings saved","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:ye=>{v(ye.target.value),o("Settings saved","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:y,onChange:ye=>{E(ye.target.value),o("Settings saved","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:b,onChange:ye=>{C(ye.target.value),o("Settings saved","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:ye=>{T(ye.target.value),o("Settings saved","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(Nt,{children:[s.jsx(Qn,{children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Archive Settings"})}),s.jsxs(Et,{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:A.auto_archive,onChange:ye=>xt("auto_archive",ye.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:"Save thumbnails"}),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:A.save_thumbnails,onChange:ye=>xt("save_thumbnails",ye.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:"Capture finish photo"}),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:A.capture_finish_photo,onChange:ye=>xt("capture_finish_photo",ye.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"})]})]}),A.capture_finish_photo&&Xr&&!Xr.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(yn,{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(Nt,{children:[s.jsx(Qn,{children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(pD,{className:"w-5 h-5 text-bambu-green"}),"Camera"]})}),s.jsxs(Et,{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:A.camera_view_mode??"window",onChange:ye=>xt("camera_view_mode",ye.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:"New Window"}),s.jsx("option",{value:"embedded",children:"Embedded Overlay"})]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:A.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:"External Cameras"}),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."}),bt&&bt.length>0?s.jsx("div",{className:"space-y-3",children:bt.map(ye=>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:ye.name}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:ye.external_camera_enabled,onChange:De=>fn(ye.id,{enabled:De.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"})]})]}),ye.external_camera_enabled&&s.jsxs("div",{className:"space-y-2 mt-2",children:[s.jsx("input",{type:"text",placeholder:ye.external_camera_type==="usb"?"Device path (/dev/video0)":"Camera URL (rtsp://... or http://...)",value:jt[ye.id]??ye.external_camera_url??"",onChange:De=>Kt(ye.id,De.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:ye.external_camera_type||"mjpeg",onChange:De=>fn(ye.id,{type:De.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(we,{size:"sm",variant:"secondary",onClick:()=>$t(ye.id,jt[ye.id]??ye.external_camera_url??"",ye.external_camera_type||"mjpeg"),disabled:Se[ye.id]||!(jt[ye.id]??ye.external_camera_url),children:Se[ye.id]?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):"Test"})]}),ie[ye.id]&&s.jsx("div",{className:`text-xs flex items-center gap-1 ${ie[ye.id]?.success?"text-green-500":"text-red-500"}`,children:ie[ye.id]?.success?s.jsxs(s.Fragment,{children:[s.jsx(Fn,{className:"w-3 h-3"}),"Connected",ie[ye.id]?.resolution&&` (${ie[ye.id]?.resolution})`]}):s.jsxs(s.Fragment,{children:[s.jsx(ta,{className:"w-3 h-3"}),ie[ye.id]?.error||"Connection failed"]})})]})]},ye.id))}):s.jsx("p",{className:"text-xs text-bambu-gray italic",children:"No printers configured"})]})]})]}),s.jsxs(Nt,{children:[s.jsx(Qn,{children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Cost Tracking"})}),s.jsxs(Et,{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:A.default_filament_cost,onChange:ye=>xt("default_filament_cost",parseFloat(ye.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:A.currency,onChange:ye=>xt("currency",ye.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:A.energy_cost_per_kwh,onChange:ye=>xt("energy_cost_per_kwh",parseFloat(ye.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:A.energy_tracking_mode||"total",onChange:ye=>xt("energy_tracking_mode",ye.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:"Prints Only"}),s.jsx("option",{value:"total",children:"Total Consumption"})]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:A.energy_tracking_mode==="print"?"Dashboard shows sum of energy used during prints":"Dashboard shows lifetime energy from smart plugs"})]})]})]}),s.jsxs(Nt,{children:[s.jsx(Qn,{children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(Ga,{className:"w-5 h-5 text-bambu-green"}),"File Manager"]})}),s.jsxs(Et,{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:A.library_archive_mode??"ask",onChange:ye=>xt("library_archive_mode",ye.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:"Always create archive entry"}),s.jsx("option",{value:"never",children:"Never create archive entry"}),s.jsx("option",{value:"ask",children:"Ask each time"})]}),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:A.library_disk_warning_gb??5,onChange:ye=>xt("library_disk_warning_gb",parseFloat(ye.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(fKe,{}),s.jsxs(Nt,{children:[s.jsx(Qn,{children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Updates"})}),s.jsxs(Et,{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:"Check for updates"}),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:A.check_updates,onChange:ye=>xt("check_updates",ye.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:"Current version"}),s.jsxs("p",{className:"text-sm text-bambu-gray",children:["v",An?.version||"..."]})]}),s.jsxs(we,{variant:"secondary",size:"sm",onClick:()=>Sr(),disabled:si,children:[si?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(xr,{className:"w-4 h-4"}),"Check now"]})]}),sn?.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",sn.latest_version]}),sn.release_name&&sn.release_name!==sn.latest_version&&s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:sn.release_name})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[sn.release_notes&&s.jsx("button",{onClick:()=>Ne(!0),className:"text-bambu-gray hover:text-white transition-colors text-sm underline",children:"Release Notes"}),sn.release_url&&s.jsx("a",{href:sn.release_url,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-gray hover:text-white transition-colors",title:"View release on GitHub",children:s.jsx(Ur,{className:"w-4 h-4"})})]})]}),Dr?.status==="downloading"||Dr?.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(dt,{className:"w-4 h-4 animate-spin"}),s.jsx("span",{children:Dr.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:`${Dr.progress}%`}})})]}):Dr?.status==="complete"?s.jsx("div",{className:"mt-3 p-2 bg-bambu-green/20 rounded text-sm text-bambu-green",children:Dr.message}):Dr?.status==="error"?s.jsx("div",{className:"mt-3 p-2 bg-red-500/20 rounded text-sm text-red-400",children:Dr.error||Dr.message}):sn?.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(we,{className:"mt-3",onClick:()=>rt.mutate(),disabled:rt.isPending,children:[rt.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx($r,{className:"w-4 h-4"}),"Install Update"]})]}):sn?.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: ",sn.error]}):sn&&!sn.update_available?s.jsx("p",{className:"mt-2 text-sm text-bambu-gray",children:"You're running the latest version"}):null]})]})]}),s.jsxs(Nt,{children:[s.jsx(Qn,{children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Data Management"})}),s.jsxs(Et,{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:"Clear Notification Logs"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Delete notification logs older than 30 days"})]}),s.jsxs(we,{variant:"secondary",size:"sm",onClick:()=>je(!0),children:[s.jsx(un,{className:"w-4 h-4"}),"Clear"]})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:"Reset UI Preferences"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Reset sidebar order, theme, view modes, and layout preferences. Printers, archives, and settings are not affected."})]}),s.jsxs(we,{variant:"secondary",size:"sm",onClick:()=>H(!0),children:[s.jsx(un,{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(we,{variant:"secondary",size:"sm",onClick:()=>ce("backup"),children:[s.jsx(Qc,{className:"w-4 h-4"}),"Go to Backup"]})]})]})]})]})]}),ue==="network"&&A&&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(Nt,{children:[s.jsx(Qn,{children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(jd,{className:"w-5 h-5 text-blue-400"}),"External URL"]})}),s.jsxs(Et,{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:A.external_url??"",onChange:ye=>xt("external_url",ye.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(Nt,{children:[s.jsx(Qn,{children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(xr,{className:"w-5 h-5 text-blue-400"}),"FTP Retry"]})}),s.jsxs(Et,{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:"Enable retry"}),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:A.ftp_retry_enabled??!0,onChange:ye=>xt("ftp_retry_enabled",ye.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"})]})]}),A.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:A.ftp_retry_count??3,onChange:ye=>xt("ftp_retry_count",Math.min(10,Math.max(1,parseInt(ye.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:A.ftp_retry_delay??2,onChange:ye=>xt("ftp_retry_delay",Math.min(30,Math.max(1,parseInt(ye.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:A.ftp_timeout??30,onChange:ye=>xt("ftp_timeout",Math.min(120,Math.max(10,parseInt(ye.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(Nt,{children:[s.jsx(Qn,{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(U2,{className:"w-5 h-5 text-bambu-green"}),"Home Assistant"]}),A.ha_enabled&&Le&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${Le.success?"bg-green-400":"bg-red-400"}`}),s.jsx("span",{className:`text-sm ${Le.success?"text-green-400":"text-red-400"}`,children:Le.success?"Connected":"Disconnected"})]})]})}),s.jsxs(Et,{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, and input_boolean entities."}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:"Enable Home Assistant"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Control smart plugs via Home Assistant"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:A.ha_enabled??!1,onChange:ye=>xt("ha_enabled",ye.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"})]})]}),A.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:A.ha_url??"",onChange:ye=>xt("ha_url",ye.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:A.ha_token??"",onChange:ye=>xt("ha_token",ye.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"})]}),A.ha_url&&A.ha_token&&s.jsx("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:s.jsxs(we,{variant:"secondary",size:"sm",disabled:Ke,onClick:async()=>{Ye(!0),qe(null);try{const ye=await he.testHAConnection(A.ha_url,A.ha_token);qe(ye)}catch(ye){qe({success:!1,message:null,error:ye instanceof Error?ye.message:"Unknown error"})}finally{Ye(!1)}},children:[Ke?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(Hp,{className:"w-4 h-4"}),"Test Connection"]})})]})]})]}),s.jsxs(Nt,{children:[s.jsx(Qn,{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(Hp,{className:"w-5 h-5 text-blue-400"}),"MQTT Publishing"]}),Xe?.enabled&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${Xe.connected?"bg-green-400":"bg-red-400"}`}),s.jsx("span",{className:`text-sm ${Xe.connected?"text-green-400":"text-red-400"}`,children:Xe.connected?"Connected":"Disconnected"})]})]})}),s.jsxs(Et,{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:"Enable MQTT"}),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:A.mqtt_enabled??!1,onChange:ye=>xt("mqtt_enabled",ye.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"})]})]}),A.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:A.mqtt_broker??"",onChange:ye=>xt("mqtt_broker",ye.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:A.mqtt_port??1883,onChange:ye=>xt("mqtt_port",Math.min(65535,Math.max(1,parseInt(ye.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:A.mqtt_use_tls??!1,onChange:ye=>{const De=ye.target.checked;xt("mqtt_use_tls",De);const ht=A.mqtt_port??1883;De&&ht===1883?xt("mqtt_port",8883):!De&&ht===8883&&xt("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:"Use TLS"})]})]}),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:A.mqtt_username??"",onChange:ye=>xt("mqtt_username",ye.target.value),placeholder:"Leave empty for anonymous",className:"w-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:A.mqtt_password??"",onChange:ye=>xt("mqtt_password",ye.target.value),placeholder:"Leave empty for anonymous",className:"w-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:A.mqtt_topic_prefix??"bambuddy",onChange:ye=>xt("mqtt_topic_prefix",ye.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: ",A.mqtt_topic_prefix||"bambuddy","/printers/<serial>/status, etc."]})]}),Xe&&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 ${Xe.connected?"bg-green-400":"bg-red-400"}`}),s.jsx("span",{className:"text-bambu-gray",children:Xe.connected?s.jsxs(s.Fragment,{children:["Connected to ",s.jsxs("span",{className:"text-white",children:[Xe.broker,":",Xe.port]})]}):"Not connected"})]})})]})]})]})]}),s.jsx("div",{className:"flex-1 lg:max-w-md space-y-4",children:s.jsxs(Nt,{children:[s.jsx(Qn,{children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(Jj,{className:"w-5 h-5 text-orange-400"}),"Prometheus Metrics"]})}),s.jsxs(Et,{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:"Enable Metrics Endpoint"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Expose printer data in Prometheus format"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:A.prometheus_enabled??!1,onChange:ye=>xt("prometheus_enabled",ye.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"})]})]}),A.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:A.prometheus_token??"",onChange:ye=>xt("prometheus_token",ye.target.value),placeholder:"Leave empty for no authentication",className:"w-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:"Available Metrics"}),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)"})]})]})]})]})]})})]}),Le&&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:[Le.success?s.jsx(Fn,{className:"w-8 h-8 text-green-400"}):s.jsx(ta,{className:"w-8 h-8 text-red-400"}),s.jsx("h3",{className:"text-lg font-medium text-white",children:Le.success?"Connection Successful":"Connection Failed"})]}),s.jsx("p",{className:"text-bambu-gray mb-6",children:Le.success?Le.message||"Successfully connected to Home Assistant.":Le.error||"Failed to connect to Home Assistant."}),s.jsx("div",{className:"flex justify-end",children:s.jsx(we,{variant:"primary",onClick:()=>qe(null),children:"OK"})})]})}),ue==="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(Vs,{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:[Oe&&Oe.filter(ye=>ye.enabled).length>1&&s.jsxs(s.Fragment,{children:[s.jsxs(we,{variant:"secondary",size:"sm",className:"whitespace-nowrap",onClick:()=>Z("on"),disabled:Ve.isPending,title:"Turn all plugs on",children:[Ve.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(gu,{className:"w-4 h-4 text-bambu-green"}),"All On"]}),s.jsxs(we,{variant:"secondary",size:"sm",className:"whitespace-nowrap",onClick:()=>Z("off"),disabled:Ve.isPending,title:"Turn all plugs off",children:[Ve.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(H2,{className:"w-4 h-4 text-red-400"}),"All Off"]})]}),s.jsxs(we,{className:"whitespace-nowrap",onClick:()=>{L(null),R(!0)},children:[s.jsx(Jn,{className:"w-4 h-4"}),"Add Smart Plug"]})]})]}),Oe&&Oe.length>0&&s.jsxs(Nt,{className:"mb-6",children:[s.jsx(Qn,{children:s.jsxs("h3",{className:"text-base font-semibold text-white flex items-center gap-2",children:[s.jsx(Pf,{className:"w-4 h-4 text-yellow-400"}),"Energy Summary",Je&&s.jsx(dt,{className:"w-4 h-4 animate-spin text-bambu-gray ml-2"})]})}),s.jsx(Et,{children:Ae?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(Pf,{className:"w-3 h-3"}),"Current Power"]}),s.jsxs("div",{className:"text-xl font-bold text-white",children:[Ae.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:[Ae.reachableCount,"/",Ae.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(ri,{className:"w-3 h-3"}),"Today"]}),s.jsxs("div",{className:"text-xl font-bold text-white",children:[Ae.totalToday.toFixed(2),s.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),A&&A.energy_cost_per_kwh>0&&s.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(Ae.totalToday*A.energy_cost_per_kwh).toFixed(2)," ",A.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(Jj,{className:"w-3 h-3"}),"Yesterday"]}),s.jsxs("div",{className:"text-xl font-bold text-white",children:[Ae.totalYesterday.toFixed(2),s.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),A&&A.energy_cost_per_kwh>0&&s.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(Ae.totalYesterday*A.energy_cost_per_kwh).toFixed(2)," ",A.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(Gj,{className:"w-3 h-3"}),"Total"]}),s.jsxs("div",{className:"text-xl font-bold text-white",children:[Ae.totalLifetime.toFixed(1),s.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),A&&A.energy_cost_per_kwh>0&&s.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(Ae.totalLifetime*A.energy_cost_per_kwh).toFixed(2)," ",A.currency]})]})]}):Je?null:s.jsx("p",{className:"text-sm text-bambu-gray",children:"Enable plugs to see energy summary"})})]}),Ue?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(dt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):Oe&&Oe.length>0?s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Oe.map(ye=>s.jsx(Jqe,{plug:ye,onEdit:De=>{L(De),R(!0)}},ye.id))}):s.jsx(Nt,{children:s.jsx(Et,{className:"py-12",children:s.jsxs("div",{className:"text-center text-bambu-gray",children:[s.jsx(Vs,{className:"w-16 h-16 mx-auto mb-4 opacity-30"}),s.jsx("p",{className:"text-lg font-medium text-white mb-2",children:"No smart plugs configured"}),s.jsx("p",{className:"text-sm mb-4",children:"Add a Tasmota-based smart plug to track energy usage and automate power control."}),s.jsxs(we,{onClick:()=>{L(null),R(!0)},children:[s.jsx(Jn,{className:"w-4 h-4"}),"Add Your First Smart Plug"]})]})})})]}),ue==="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(cf,{className:"w-5 h-5 text-bambu-green"}),"Providers"]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(we,{size:"sm",variant:"secondary",onClick:()=>re(!0),children:[s.jsx(f0,{className:"w-4 h-4"}),"Log"]}),gt&&gt.length>0&&s.jsxs(we,{size:"sm",variant:"secondary",onClick:()=>{de(null),Re.mutate()},disabled:Re.isPending,children:[Re.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(fD,{className:"w-4 h-4"}),"Test All"]}),s.jsxs(we,{size:"sm",onClick:()=>{Y(null),j(!0)},children:[s.jsx(Jn,{className:"w-4 h-4"}),"Add"]})]})]}),s.jsx(Nt,{className:"mb-4",children:s.jsx(Et,{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:A.notification_language||"en",onChange:ye=>xt("notification_language",ye.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:ZU.map(ye=>s.jsx("option",{value:ye.code,children:ye.nativeName},ye.code))})]})})}),Rt&&s.jsx(Nt,{className:"mb-4",children:s.jsxs(Et,{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:"Test Results"}),s.jsx("button",{onClick:()=>de(null),className:"text-bambu-gray hover:text-white text-xs",children:"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(Fn,{className:"w-4 h-4"}),Rt.success," passed"]}),Rt.failed>0&&s.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[s.jsx(ta,{className:"w-4 h-4"}),Rt.failed," failed"]})]}),Rt.results.filter(ye=>!ye.success).length>0&&s.jsx("div",{className:"space-y-1 mt-2 pt-2 border-t border-bambu-dark-tertiary",children:Rt.results.filter(ye=>!ye.success).map(ye=>s.jsxs("div",{className:"text-xs text-red-400",children:[s.jsxs("span",{className:"font-medium",children:[ye.provider_name,":"]})," ",ye.message]},ye.provider_id))})]})}),Pt?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(dt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):gt&&gt.length>0?s.jsx("div",{className:"space-y-3",children:gt.map(ye=>s.jsx(nKe,{provider:ye,onEdit:De=>{Y(De),j(!0)}},ye.id))}):s.jsx(Nt,{children:s.jsx(Et,{className:"py-8",children:s.jsxs("div",{className:"text-center text-bambu-gray",children:[s.jsx(cf,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),s.jsx("p",{className:"text-sm font-medium text-white mb-2",children:"No providers configured"}),s.jsx("p",{className:"text-xs mb-3",children:"Add a provider to receive alerts."}),s.jsxs(we,{size:"sm",onClick:()=>{Y(null),j(!0)},children:[s.jsx(Jn,{className:"w-4 h-4"}),"Add Provider"]})]})})})]}),s.jsxs("div",{children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2 mb-4",children:[s.jsx(Ga,{className:"w-5 h-5 text-bambu-green"}),"Message Templates"]}),s.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:"Customize notification messages for each event."}),ln?s.jsx("div",{className:"flex justify-center py-8",children:s.jsx(dt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):Gt&&Gt.length>0?s.jsx("div",{className:"space-y-2",children:Gt.map(ye=>s.jsx(Nt,{className:"cursor-pointer hover:border-bambu-green/50 transition-colors",onClick:()=>Q(ye),children:s.jsx(Et,{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:ye.name}),s.jsx("p",{className:"text-bambu-gray text-xs truncate mt-0.5",children:ye.title_template})]}),s.jsx("button",{className:"p-1.5 hover:bg-bambu-dark-tertiary rounded transition-colors shrink-0 ml-2",onClick:De=>{De.stopPropagation(),Q(ye)},children:s.jsx($2,{className:"w-4 h-4 text-bambu-gray"})})]})})},ye.id))}):s.jsx(Nt,{children:s.jsx(Et,{className:"py-8",children:s.jsxs("div",{className:"text-center text-bambu-gray",children:[s.jsx(Ga,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),s.jsx("p",{className:"text-sm",children:"No templates available. Restart the backend to seed default templates."})]})})})]})]}),ue==="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(Jh,{className:"w-5 h-5 text-bambu-green"}),"API Keys"]}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Create API keys for external integrations and webhooks."})]}),s.jsxs(we,{size:"sm",onClick:()=>me(!0),className:"flex-shrink-0",children:[s.jsx(Jn,{className:"w-4 h-4"}),"Create Key"]})]}),V&&s.jsx(Nt,{className:"mb-6 border-bambu-green",children:s.jsx(Et,{className:"py-4",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(Fn,{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:"API Key Created Successfully"}),s.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:"Copy this key now - it won't be shown again!"}),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:V}),s.jsx(we,{variant:"secondary",size:"sm",onClick:async()=>{try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(V);else{const ye=document.createElement("textarea");ye.value=V,ye.style.position="fixed",ye.style.left="-999999px",document.body.appendChild(ye),ye.select(),document.execCommand("copy"),document.body.removeChild(ye)}o("Key copied to clipboard")}catch{o("Failed to copy key","error")}},children:s.jsx(ol,{className:"w-4 h-4"})})]}),s.jsxs("div",{className:"flex gap-2 mt-3",children:[s.jsx(we,{variant:"secondary",size:"sm",onClick:()=>{oe(V),o("Key added to API Browser")},children:"Use in API Browser"}),s.jsx(we,{variant:"secondary",size:"sm",onClick:()=>$(null),children:"Dismiss"})]})]})]})})}),Me&&s.jsxs(Nt,{className:"mb-6",children:[s.jsx(Qn,{children:s.jsx("h3",{className:"text-base font-semibold text-white",children:"Create New API Key"})}),s.jsxs(Et,{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Key Name"}),s.jsx("input",{type:"text",value:Ee,onChange:ye=>fe(ye.target.value),placeholder:"e.g., Home Assistant, OctoPrint",className:"w-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:"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:le.can_read_status,onChange:ye=>Be(De=>({...De,can_read_status:ye.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:"Read Status"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"View printer status and queue"})]})]}),s.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:le.can_queue,onChange:ye=>Be(De=>({...De,can_queue:ye.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:"Manage Queue"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Add and remove items from print queue"})]})]}),s.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:le.can_control_printer,onChange:ye=>Be(De=>({...De,can_control_printer:ye.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:"Control Printer"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Pause, resume, and stop prints"})]})]})]})]}),s.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[s.jsxs(we,{onClick:()=>It.mutate({name:Ee||"Unnamed Key",...le}),disabled:It.isPending,children:[It.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(Jn,{className:"w-4 h-4"}),"Create Key"]}),s.jsx(we,{variant:"secondary",onClick:()=>me(!1),children:"Cancel"})]})]})]}),cn?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(dt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):Ot&&Ot.length>0?s.jsx("div",{className:"space-y-3",children:Ot.map(ye=>s.jsx(Nt,{children:s.jsx(Et,{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(Jh,{className:`w-5 h-5 ${ye.enabled?"text-bambu-green":"text-bambu-gray"}`}),s.jsxs("div",{children:[s.jsx("p",{className:"text-white font-medium",children:ye.name}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[ye.key_prefix,"••••••••",ye.last_used&&` · Last used: ${sg(ye.last_used)}`]})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"flex gap-1 text-xs",children:[ye.can_read_status&&s.jsx("span",{className:"px-1.5 py-0.5 bg-blue-500/20 text-blue-400 rounded",children:"Read"}),ye.can_queue&&s.jsx("span",{className:"px-1.5 py-0.5 bg-green-500/20 text-green-400 rounded",children:"Queue"}),ye.can_control_printer&&s.jsx("span",{className:"px-1.5 py-0.5 bg-orange-500/20 text-orange-400 rounded",children:"Control"})]}),s.jsx(we,{variant:"secondary",size:"sm",onClick:()=>U(ye.id),children:s.jsx(un,{className:"w-4 h-4 text-red-400"})})]})]})})},ye.id))}):s.jsx(Nt,{children:s.jsx(Et,{className:"py-12",children:s.jsxs("div",{className:"text-center text-bambu-gray",children:[s.jsx(Jh,{className:"w-16 h-16 mx-auto mb-4 opacity-30"}),s.jsx("p",{className:"text-lg font-medium text-white mb-2",children:"No API keys"}),s.jsx("p",{className:"text-sm mb-4",children:"Create an API key to integrate with external services."}),s.jsxs(we,{onClick:()=>me(!0),children:[s.jsx(Jn,{className:"w-4 h-4"}),"Create Your First Key"]})]})})}),s.jsxs(Nt,{className:"mt-6",children:[s.jsx(Qn,{children:s.jsx("h3",{className:"text-base font-semibold text-white",children:"Webhook Endpoints"})}),s.jsxs(Et,{className:"space-y-3 text-sm",children:[s.jsxs("p",{className:"text-bambu-gray",children:["Use your API key in the ",s.jsx("code",{className:"text-bambu-green",children:"X-API-Key"})," header."]}),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.jsx("span",{className:"text-bambu-gray",children:" - Get all printer status"})]}),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.jsx("span",{className:"text-bambu-gray",children:" - Get specific printer status"})]}),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.jsx("span",{className:"text-bambu-gray",children:" - Add to print queue"})]}),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.jsx("span",{className:"text-bambu-gray",children:" - Pause print"})]}),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.jsx("span",{className:"text-bambu-gray",children:" - Resume print"})]}),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.jsx("span",{className:"text-bambu-gray",children:" - Stop print"})]})]})]})]})]}),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(jd,{className:"w-5 h-5 text-bambu-green"}),"API Browser"]}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Explore and test all available API endpoints."})]}),s.jsx(Nt,{className:"mb-4",children:s.jsxs(Et,{className:"py-3",children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"API Key for Testing"}),s.jsx("input",{type:"text",value:B,onChange:ye=>oe(ye.target.value),placeholder:"Paste your API key here to test authenticated endpoints...",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.jsxs("p",{className:"text-xs text-bambu-gray mt-2",children:["This key will be sent as ",s.jsx("code",{className:"text-bambu-green",children:"X-API-Key"})," header with requests."]})]})}),s.jsx(wKe,{apiKey:B})]})]}),ue==="virtual-printer"&&s.jsx(mKe,{}),ue==="filament"&&A&&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(Nt,{children:[s.jsx(Qn,{children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:"AMS Display Thresholds"})}),s.jsxs(Et,{className:"space-y-4",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Configure color thresholds for AMS humidity and temperature indicators."}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center gap-2 text-white",children:[s.jsx(uD,{className:"w-4 h-4 text-blue-400"}),s.jsx("span",{className:"font-medium",children:"Humidity"})]}),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:"Good (green) ≤"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",min:"0",max:"100",value:A.ams_humidity_good??40,onChange:ye=>xt("ams_humidity_good",parseInt(ye.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.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Fair (orange) ≤"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",min:"0",max:"100",value:A.ams_humidity_fair??60,onChange:ye=>xt("ams_humidity_fair",parseInt(ye.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:"Above fair threshold shows as red (bad)"})]}),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(G2,{className:"w-4 h-4 text-orange-400"}),s.jsx("span",{className:"font-medium",children:"Temperature"})]}),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:"Good (blue) ≤"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",step:"0.5",min:"0",max:"60",value:A.ams_temp_good??28,onChange:ye=>xt("ams_temp_good",parseFloat(ye.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.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Fair (orange) ≤"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",step:"0.5",min:"0",max:"60",value:A.ams_temp_fair??35,onChange:ye=>xt("ams_temp_fair",parseFloat(ye.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:"Above fair threshold shows as red (hot)"})]}),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(Qc,{className:"w-4 h-4 text-purple-400"}),s.jsx("span",{className:"font-medium",children:"History Retention"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Keep sensor history for"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",min:"1",max:"365",value:A.ams_history_retention_days??30,onChange:ye=>xt("ams_history_retention_days",parseInt(ye.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:"days"})]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Older humidity and temperature data will be automatically deleted"})]}),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(Mr,{className:"w-4 h-4 text-bambu-green"}),s.jsx("span",{className:"font-medium",children:"Print Modal"})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-white",children:"Expand custom mapping by default"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-0.5",children:"When printing to multiple printers, show per-printer AMS mapping expanded"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:A.per_printer_mapping_expanded??!1,onChange:ye=>xt("per_printer_mapping_expanded",ye.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(dKe,{})})]}),X!==null&&s.jsx(Bn,{title:"Delete API Key",message:"Are you sure you want to delete this API key? Any integrations using this key will stop working.",confirmText:"Delete Key",variant:"danger",onConfirm:()=>{_n.mutate(X),U(null)},onCancel:()=>U(null)}),k&&s.jsx(eKe,{plug:F,onClose:()=>{R(!1),L(null)}}),K&&s.jsx(rKe,{provider:W,onClose:()=>{j(!1),Y(null)}}),q&&s.jsx(iKe,{template:q,onClose:()=>Q(null)}),ee&&s.jsx(oKe,{onClose:()=>re(!1)}),Te&&s.jsx(Bn,{title:"Clear Notification Logs",message:"This will permanently delete all notification logs older than 30 days. This action cannot be undone.",confirmText:"Clear Logs",variant:"warning",onConfirm:async()=>{je(!1);try{const ye=await he.clearNotificationLogs(30);o(ye.message,"success")}catch{o("Failed to clear logs","error")}},onCancel:()=>je(!1)}),Ce&&s.jsx(Bn,{title:"Reset UI Preferences",message:"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.",confirmText:"Reset Preferences",variant:"default",onConfirm:()=>{H(!1),localStorage.clear(),o("UI preferences reset. Refreshing...","success"),setTimeout(()=>window.location.reload(),1e3)},onCancel:()=>H(!1)}),D&&s.jsx(Bn,{title:`Turn All Plugs ${D==="on"?"On":"Off"}`,message:`This will turn ${D==="on"?"ON":"OFF"} all ${Oe?.filter(ye=>ye.enabled).length||0} enabled smart plugs. ${D==="off"?"Any running printers may be affected!":""}`,confirmText:`Turn All ${D==="on"?"On":"Off"}`,variant:D==="off"?"danger":"warning",onConfirm:()=>{const ye=D;Z(null),Ve.mutate(ye)},onCancel:()=>Z(null)}),xe&&sn?.release_notes&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:()=>Ne(!1),children:s.jsxs(Nt,{className:"w-full max-w-2xl max-h-[80vh] flex flex-col",onClick:ye=>ye.stopPropagation(),children:[s.jsxs(Qn,{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",sn.latest_version]}),sn.release_name&&sn.release_name!==sn.latest_version&&s.jsx("p",{className:"text-sm text-bambu-gray",children:sn.release_name})]}),s.jsx("button",{onClick:()=>Ne(!1),className:"p-1 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white",children:s.jsx(zt,{className:"w-5 h-5"})})]}),s.jsx(Et,{className:"overflow-y-auto flex-1",children:s.jsx("pre",{className:"text-sm text-bambu-gray whitespace-pre-wrap font-sans",children:sn.release_notes})}),s.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary shrink-0 flex gap-2",children:[sn.release_url&&s.jsx("a",{href:sn.release_url,target:"_blank",rel:"noopener noreferrer",className:"flex-1",children:s.jsxs(we,{variant:"secondary",className:"w-full",children:[s.jsx(Ur,{className:"w-4 h-4"}),"View on GitHub"]})}),s.jsx(we,{onClick:()=>Ne(!1),className:"flex-1",children:"Close"})]})]})}),ue==="users"&&s.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-2 gap-8",children:[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(_d,{className:"w-5 h-5 text-bambu-green"}),"User Authentication"]}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Enable authentication to secure your Bambuddy instance and manage user access."})]}),s.jsx(Nt,{children:s.jsx(Et,{className:"py-6",children:l?s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-12 h-12 rounded-full flex items-center justify-center bg-green-500/20",children:s.jsx(LT,{className:"w-6 h-6 text-green-400"})}),s.jsxs("div",{className:"flex-1",children:[s.jsx("h3",{className:"text-white font-medium",children:"Authentication Enabled"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Your Bambuddy instance is secured with authentication."})]})]}),c&&s.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Current User"}),s.jsx("p",{className:"text-white font-medium",children:c.username}),s.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:["Role: ",s.jsx("span",{className:"capitalize",children:c.role})]})]}),s.jsx("div",{className:`px-3 py-1 rounded-full text-xs font-medium ${c.role==="admin"?"bg-purple-500/20 text-purple-300":"bg-blue-500/20 text-blue-300"}`,children:c.role==="admin"?"Admin":"User"})]})}),s.jsxs("div",{className:"pt-4 border-t border-bambu-dark-tertiary space-y-3",children:[s.jsxs(we,{onClick:()=>e("/users"),className:"w-full",variant:"secondary",children:[s.jsx(_d,{className:"w-4 h-4"}),"Manage Users"]}),c?.role==="admin"&&s.jsxs(we,{onClick:()=>$e(!0),className:"w-full",variant:"secondary",children:[s.jsx(xz,{className:"w-4 h-4"}),"Disable Authentication"]})]})]}):s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:`w-12 h-12 rounded-full flex items-center justify-center ${l?"bg-green-500/20":"bg-gray-500/20"}`,children:l?s.jsx(LT,{className:"w-6 h-6 text-green-400"}):s.jsx(xz,{className:"w-6 h-6 text-gray-400"})}),s.jsxs("div",{className:"flex-1",children:[s.jsx("h3",{className:"text-white font-medium",children:"Authentication Disabled"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Your Bambuddy instance is currently accessible without authentication."})]})]}),s.jsxs("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:[s.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:"Enable authentication to:"}),s.jsxs("ul",{className:"space-y-2 text-sm text-bambu-gray mb-4",children:[s.jsxs("li",{className:"flex items-start gap-2",children:[s.jsx(Fn,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),s.jsx("span",{children:"Require login to access the system"})]}),s.jsxs("li",{className:"flex items-start gap-2",children:[s.jsx(Fn,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),s.jsx("span",{children:"Manage multiple users with different roles"})]}),s.jsxs("li",{className:"flex items-start gap-2",children:[s.jsx(Fn,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),s.jsx("span",{children:"Control access to printer settings and user management"})]})]}),s.jsxs(we,{type:"button",onClick:ye=>{ye.preventDefault(),e("/setup")},className:"w-full",children:[s.jsx(LT,{className:"w-4 h-4"}),"Activate Authentication"]})]})]})})})]}),l&&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(Zj,{className:"w-5 h-5 text-bambu-green"}),"Role Permissions"]}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Overview of what each role can do."})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs(Nt,{children:[s.jsx(Qn,{children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"w-8 h-8 rounded-full bg-purple-500/20 flex items-center justify-center",children:s.jsx(Zj,{className:"w-4 h-4 text-purple-300"})}),s.jsx("h3",{className:"text-white font-medium",children:"Admin"})]})}),s.jsx(Et,{children:s.jsxs("ul",{className:"space-y-2 text-sm text-bambu-gray",children:[s.jsxs("li",{className:"flex items-start gap-2",children:[s.jsx(Fn,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),s.jsx("span",{children:"Manage printer settings"})]}),s.jsxs("li",{className:"flex items-start gap-2",children:[s.jsx(Fn,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),s.jsx("span",{children:"Create, edit, and delete users"})]}),s.jsxs("li",{className:"flex items-start gap-2",children:[s.jsx(Fn,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),s.jsx("span",{children:"Access all system features"})]})]})})]}),s.jsxs(Nt,{children:[s.jsx(Qn,{children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"w-8 h-8 rounded-full bg-blue-500/20 flex items-center justify-center",children:s.jsx(_d,{className:"w-4 h-4 text-blue-300"})}),s.jsx("h3",{className:"text-white font-medium",children:"User"})]})}),s.jsx(Et,{children:s.jsxs("ul",{className:"space-y-2 text-sm text-bambu-gray",children:[s.jsxs("li",{className:"flex items-start gap-2",children:[s.jsx(Fn,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),s.jsx("span",{children:"Send print jobs"})]}),s.jsxs("li",{className:"flex items-start gap-2",children:[s.jsx(Fn,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),s.jsx("span",{children:"Manage files and archives"})]}),s.jsxs("li",{className:"flex items-start gap-2",children:[s.jsx(Fn,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),s.jsx("span",{children:"Manage filament"})]})]})})]})]})]})]}),ue==="backup"&&s.jsx(bKe,{}),ve&&s.jsx(Bn,{title:"Disable Authentication",message:"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.",confirmText:"Disable Authentication",variant:"danger",onConfirm:async()=>{try{await he.disableAuth(),o("Authentication disabled successfully","success"),await u(),$e(!1),window.location.href="/"}catch(ye){const De=ye instanceof Error?ye.message:"Failed to disable authentication";o(De,"error")}},onCancel:()=>$e(!1)})]})}const wre=t=>{const e=parseFloat(t);return(Math.trunc(e*1e3)/1e3).toFixed(3)},MKe=t=>t.startsWith("HH")?"HF":"S",EKe=t=>{const e=t.match(/^([A-Z]{2}\d{2})/);return e?e[1]:"HH00"},GR=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 wj({profile:t,onEdit:e,onCopy:n,selectionMode:r,isSelected:i,onToggleSelect:a,note:o}){const l=MKe(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(Ro,{className:"w-4 h-4 text-bambu-green"}):s.jsx(Do,{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:wre(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(hq,{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(ol,{className:"w-4 h-4"})})]})}function Sj({profile:t,printerId:e,nozzleDiameter:n,existingProfiles:r=[],isDualNozzle:i=!1,initialNote:a="",initialNoteKey:o=null,onClose:l,onSave:c,onSaveNote:u}){const{showToast:d}=Vn(),[f,m]=w.useState(t?.name||""),[p,x]=w.useState(t?.k_value?wre(t.k_value):"0.020"),[y,b]=w.useState(t?.filament_id||""),[v,N]=w.useState(t?.nozzle_id?EKe(t.nozzle_id):"HH00"),[S,T]=w.useState(t?.nozzle_diameter||n),[E,C]=w.useState(t?[t.extruder_id]:i?[0,1]:[0]),[A,O]=w.useState(!1),[k,R]=w.useState({current:0,total:0}),[F,L]=w.useState(a),K=Fr.useMemo(()=>{const re=new Map;for(const z of r)if(z.filament_id&&!re.has(z.filament_id)){const G=GR(z.name||"");re.set(z.filament_id,{id:z.filament_id,name:G||z.filament_id})}return Array.from(re.values()).sort((z,G)=>z.name.localeCompare(G.name))},[r]),j=pt({mutationFn:re=>(console.log("[KProfile] Calling API..."),he.setKProfile(e,re)),onSuccess:re=>{if(console.log("[KProfile] Save success:",re),d("K-profile saved"),u&&F!==a){let z;F===""&&o?z=o:t&&t.slot_id>0?z=t.setting_id||`slot_${t.slot_id}_${t.filament_id}_${t.extruder_id}`:z=`name_${f}_${y}`,u(z,F)}O(!0),setTimeout(()=>{O(!1),c()},2500)},onError:re=>{console.error("[KProfile] Save error:",re),d(re.message,"error"),O(!1)}}),W=pt({mutationFn:re=>(console.log("[KProfile] Deleting profile..."),he.deleteKProfile(e,re)),onSuccess:re=>{console.log("[KProfile] Delete success:",re),d("K-profile deleted"),O(!0),setTimeout(()=>{O(!1),l()},4e3)},onError:re=>{console.error("[KProfile] Delete error:",re),d(re.message,"error"),O(!1)}}),[Y,q]=w.useState(!1),Q=()=>{t&&W.mutate({slot_id:t.slot_id,extruder_id:t.extruder_id,nozzle_id:t.nozzle_id,nozzle_diameter:t.nozzle_diameter,filament_id:t.filament_id,setting_id:t.setting_id})},ee=async re=>{if(re.preventDefault(),i&&!t&&E.length===0){d("Please select at least one extruder","error");return}const z=parseFloat(p).toFixed(6),G=`${v}-${S}`;if(t||E.length===1){const se={name:f,k_value:z,filament_id:y,nozzle_id:G,nozzle_diameter:S,extruder_id:t?t.extruder_id:E[0],setting_id:t?.setting_id,slot_id:t?.slot_id??0};console.log("[KProfile] Saving profile:",se),j.mutate(se);return}O(!0),R({current:1,total:E.length});const ae=E.map(se=>({name:f,k_value:z,filament_id:y,nozzle_id:G,nozzle_diameter:S,extruder_id:se,setting_id:void 0,slot_id:0}));console.log(`[KProfile] Saving ${ae.length} profiles in batch:`,ae);try{if(await he.setKProfilesBatch(e,ae),d(`K-profile saved to ${E.length} extruders`),u&&F){const se=`name_${f}_${y}`;u(se,F)}}catch(se){console.error("[KProfile] Failed to save batch:",se),d("Failed to save K-profiles","error"),O(!1),R({current:0,total:0});return}R({current:E.length,total:E.length}),setTimeout(()=>{O(!1),R({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(Nt,{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(dt,{className:"w-8 h-8 text-bambu-green animate-spin mb-3"}),s.jsx("p",{className:"text-white font-medium",children:k.total>1?`Saving to extruder ${k.current}/${k.total}...`:"Syncing with printer..."}),s.jsx("p",{className:"text-bambu-gray text-sm mt-1",children:"Please wait"})]}),s.jsxs(Et,{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:t?"Edit K-Profile":"Add K-Profile"}),s.jsx("button",{onClick:l,className:"text-bambu-gray hover:text-white transition-colors",disabled:A,children:s.jsx(zt,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:ee,className:"p-4 space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Profile Name"}),s.jsx("input",{type:"text",value:f,onChange:re=>m(re.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:"My PLA Profile",required:!t})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"K-Value"}),s.jsx("input",{type:"text",inputMode:"decimal",value:p,onChange:re=>{const z=re.target.value;(z===""||/^\d*\.?\d*$/.test(z))&&x(z)},onBlur:re=>{const z=parseFloat(re.target.value);isNaN(z)||x((Math.trunc(z*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:"0.020",required:!0}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Typical range: 0.01 - 0.06 for PLA, 0.02 - 0.10 for PETG"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Filament"}),s.jsxs("select",{value:y,onChange:re=>{const z=re.target.value;if(b(z),!t&&z&&!f){const G=K.find(ae=>ae.id===z);G&&m(`${v==="HH00"?"HF":"S"} ${G.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:"Select filament..."}),t?.filament_id&&s.jsx("option",{value:t.filament_id,children:K.find(re=>re.id===t.filament_id)?.name||t.filament_id},t.filament_id),!t&&K.map(re=>s.jsx("option",{value:re.id,children:re.name},re.id))]}),!t&&K.length===0&&s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"No filaments found. Create a K-profile in Bambu Studio first."})]}),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:"Flow Type"}),s.jsxs("select",{value:v,onChange:re=>{const z=re.target.value;if(N(z),!t&&y&&!f){const G=K.find(ae=>ae.id===y);G&&m(`${z==="HS00"?"HF":"S"} ${G.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:"High Flow"}),s.jsx("option",{value:"HS00",children:"Standard"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Nozzle Size"}),s.jsxs("select",{value:S,onChange:re=>T(re.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:t?"Extruder":"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?"Left":"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:re=>{re.target.checked?C([...E,1]):C(E.filter(z=>z!==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:"Left"})]}),s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:E.includes(0),onChange:re=>{re.target.checked?C([...E,0]):C(E.filter(z=>z!==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:"Right"})]})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Notes (stored locally)"}),s.jsx("textarea",{value:F,onChange:re=>L(re.target.value),placeholder:"Add notes about this profile...",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:"Notes are saved in Bambuddy, not on the printer"})]}),s.jsxs("div",{className:"flex gap-2 pt-4",children:[t&&s.jsx(we,{type:"button",variant:"secondary",onClick:()=>q(!0),disabled:W.isPending||A,className:"text-red-500 hover:bg-red-500/10",children:W.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(un,{className:"w-4 h-4"})}),s.jsx(we,{type:"button",variant:"secondary",onClick:l,disabled:A,className:"flex-1",children:"Cancel"}),s.jsxs(we,{type:"submit",disabled:j.isPending||A,className:"flex-1",children:[j.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(I2,{className:"w-4 h-4"}),"Save"]})]})]})]})]}),Y&&s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-[60]",children:s.jsx(Nt,{className:"w-full max-w-sm",children:s.jsxs(Et,{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(un,{className:"w-5 h-5 text-red-500"})}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-semibold text-white",children:"Delete Profile"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"This cannot be undone"})]})]}),s.jsxs("p",{className:"text-bambu-gray mb-6",children:["Are you sure you want to delete ",s.jsxs("span",{className:"text-white font-medium",children:['"',t?.name,'"']})," from the printer?"]}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx(we,{variant:"secondary",onClick:()=>q(!1),className:"flex-1",children:"Cancel"}),s.jsxs(we,{onClick:()=>{q(!1),Q()},disabled:W.isPending,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[W.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(un,{className:"w-4 h-4"}),"Delete"]})]})]})})})]})}const I1={NOZZLE_DIAMETER:"bambusy_kprofiles_nozzle",SORT_OPTION:"bambusy_kprofiles_sort"};function TKe(){const{showToast:t}=Vn(),[e,n]=w.useState(null),[r,i]=w.useState(()=>localStorage.getItem(I1.NOZZLE_DIAMETER)||"0.4"),[a,o]=w.useState(null),[l,c]=w.useState(!1),[u,d]=w.useState(null),[f,m]=w.useState(""),[p,x]=w.useState("all"),[y,b]=w.useState("all"),[v,N]=w.useState(()=>localStorage.getItem(I1.SORT_OPTION)||"name"),[S,T]=w.useState(!1),[E,C]=w.useState(new Set),[A,O]=w.useState(!1),[k,R]=w.useState(!1),F=w.useCallback(U=>`${U.slot_id}_${U.extruder_id}`,[]);w.useEffect(()=>{localStorage.setItem(I1.NOZZLE_DIAMETER,r)},[r]),w.useEffect(()=>{localStorage.setItem(I1.SORT_OPTION,v)},[v]);const{data:L,isLoading:K}=ut({queryKey:["printers"],queryFn:he.getPrinters}),{data:j,isLoading:W,isFetching:Y,error:q,refetch:Q}=ut({queryKey:["kprofiles",e,r],queryFn:async()=>{console.log("[KProfiles] Fetching profiles for printer",e,"nozzle",r);const U=await he.getKProfiles(e,r);return console.log("[KProfiles] Received profiles:",U?.profiles?.length||0,"profiles"),U},enabled:!!e,retry:!1,staleTime:0,gcTime:0,refetchOnMount:"always"}),{data:ee}=ut({queryKey:["kprofiles",e,"0.4"],queryFn:()=>he.getKProfiles(e,"0.4"),enabled:!!e,staleTime:6e4}),{data:re,refetch:z}=ut({queryKey:["kprofile-notes",e],queryFn:()=>he.getKProfileNotes(e),enabled:!!e,staleTime:3e4}),G=q?.message?.includes("not connected");w.useEffect(()=>{if(!e&&L&&L.length>0){const U=L.find(B=>B.is_active);U&&n(U.id)}},[e,L]),w.useEffect(()=>{if(e){const U=setTimeout(()=>{Q()},150);return()=>clearTimeout(U)}},[e,r]);const ae=L?.filter(U=>U.is_active)||[],se=Fr.useMemo(()=>j?.profiles?j.profiles.filter(B=>{const oe=f.toLowerCase(),Te=!oe||B.name.toLowerCase().includes(oe)||B.filament_id.toLowerCase().includes(oe),je=p==="all"||p==="left"&&B.extruder_id===1||p==="right"&&B.extruder_id===0,Ce=y==="all"||y==="hf"&&B.nozzle_id.startsWith("HH")||y==="s"&&B.nozzle_id.startsWith("HS");return Te&&je&&Ce}).sort((B,oe)=>{switch(v){case"k_value":return parseFloat(B.k_value)-parseFloat(oe.k_value);case"filament":return GR(B.name).localeCompare(GR(oe.name));case"name":default:return B.name.localeCompare(oe.name)}}):[],[j?.profiles,f,p,y,v]),ue=L?.find(U=>U.id===e),pe=ue?.nozzle_count===2;w.useEffect(()=>{const U=B=>{B.target instanceof HTMLInputElement||B.target instanceof HTMLTextAreaElement||B.target instanceof HTMLSelectElement||a||l||u||(B.key==="r"||B.key==="R"?(B.preventDefault(),Q()):B.key==="n"||B.key==="N"?(B.preventDefault(),c(!0)):B.key==="Escape"&&S&&(B.preventDefault(),T(!1),C(new Set)))};return window.addEventListener("keydown",U),()=>window.removeEventListener("keydown",U)},[a,l,u,S,Q]);const ce=w.useCallback(()=>{if(!j?.profiles||j.profiles.length===0){t("No profiles to export","error");return}const U={version:1,exported_at:new Date().toISOString(),printer:ue?.name||"Unknown",nozzle_diameter:r,profiles:j.profiles.map(je=>({name:je.name,k_value:je.k_value,filament_id:je.filament_id,nozzle_id:je.nozzle_id,nozzle_diameter:je.nozzle_diameter,extruder_id:je.extruder_id}))},B=new Blob([JSON.stringify(U,null,2)],{type:"application/json"}),oe=URL.createObjectURL(B),Te=document.createElement("a");Te.href=oe,Te.download=`kprofiles_${ue?.name||"printer"}_${r}mm_${new Date().toISOString().split("T")[0]}.json`,document.body.appendChild(Te),Te.click(),document.body.removeChild(Te),URL.revokeObjectURL(oe),t(`Exported ${j.profiles.length} profiles`)},[j?.profiles,ue,r,t]),Me=w.useCallback(()=>{const U=document.createElement("input");U.type="file",U.accept=".json",U.onchange=async B=>{const oe=B.target.files?.[0];if(oe)try{const Te=await oe.text(),je=JSON.parse(Te);if(!je.profiles||!Array.isArray(je.profiles)){t("Invalid file format","error");return}let Ce=0;for(const H of je.profiles)if(!(!H.name||!H.k_value||!H.filament_id))try{await he.setKProfile(e,{name:H.name,k_value:parseFloat(H.k_value).toFixed(6),filament_id:H.filament_id,nozzle_id:H.nozzle_id||`HH00-${r}`,nozzle_diameter:H.nozzle_diameter||r,extruder_id:H.extruder_id??0,slot_id:0}),Ce++,await new Promise(D=>setTimeout(D,500))}catch(D){console.error("Failed to import profile:",H.name,D)}t(`Imported ${Ce} of ${je.profiles.length} profiles`),Q()}catch(Te){console.error("Import error:",Te),t("Failed to parse import file","error")}},U.click()},[e,r,t,Q]),me=w.useCallback(U=>{C(B=>{const oe=new Set(B);return oe.has(U)?oe.delete(U):oe.add(U),oe})},[]),Ee=w.useCallback(()=>{C(new Set(se.map(U=>F(U))))},[se,F]),fe=w.useCallback(()=>{E.size!==0&&O(!0)},[E.size]),le=w.useCallback(async()=>{const U=se.filter(oe=>E.has(F(oe)));R(!0);let B=0;for(const oe of U)try{await he.deleteKProfile(e,{slot_id:oe.slot_id,extruder_id:oe.extruder_id,nozzle_id:oe.nozzle_id,nozzle_diameter:oe.nozzle_diameter,filament_id:oe.filament_id,setting_id:oe.setting_id}),B++,await new Promise(Te=>setTimeout(Te,300))}catch(Te){console.error("Failed to delete profile:",oe.name,Te)}t(`Deleted ${B} profiles`),R(!1),O(!1),T(!1),C(new Set),Q()},[e,E,se,t,Q,F]),Be=w.useCallback(U=>{const B=[];return U.setting_id&&B.push(U.setting_id),B.push(`slot_${U.slot_id}_${U.filament_id}_${U.extruder_id}`),B.push(`name_${U.name}_${U.filament_id}`),B},[]),V=w.useCallback(async(U,B)=>{if(e)try{await he.setKProfileNote(e,U,B),z()}catch(oe){console.error("Failed to save note:",oe),t("Failed to save note","error")}},[e,z,t]),$=w.useCallback(U=>{if(!re?.notes)return{note:"",key:null};const B=Be(U);for(const oe of B)if(re.notes[oe])return{note:re.notes[oe],key:oe};return{note:"",key:null}},[re,Be]),X=w.useCallback(U=>$(U).note,[$]);return K?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(dt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):!L||L.length===0?s.jsx(Nt,{children:s.jsxs(Et,{className:"py-12 text-center",children:[s.jsx(ji,{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:"No Printers Configured"}),s.jsx("p",{className:"text-bambu-gray",children:"Add a printer in Settings to manage K-profiles"})]})}):ae.length===0?s.jsx(Nt,{children:s.jsxs(Et,{className:"py-12 text-center",children:[s.jsx(Mr,{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:"No Active Printers"}),s.jsx("p",{className:"text-bambu-gray",children:"Enable a printer connection to view its K-profiles"})]})}):s.jsxs(s.Fragment,{children:[Y&&!W&&s.jsxs("div",{className:"fixed inset-0 bg-black/50 flex flex-col items-center justify-center z-40",children:[s.jsx(dt,{className:"w-10 h-10 text-bambu-green animate-spin mb-3"}),s.jsx("p",{className:"text-white font-medium",children:"Loading K-Profiles..."})]}),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:"Printer"}),s.jsx("select",{value:e||"",onChange:U=>n(parseInt(U.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:ae.map(U=>s.jsx("option",{value:U.id,children:U.name},U.id))})]}),s.jsxs("div",{className:"w-32",children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Nozzle"}),s.jsxs("select",{value:r,onChange:U=>i(U.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(we,{variant:"secondary",onClick:()=>Q(),disabled:Y,children:[s.jsx(xr,{className:`w-4 h-4 ${Y?"animate-spin":""}`}),"Refresh"]}),s.jsxs(we,{onClick:()=>c(!0),children:[s.jsx(Jn,{className:"w-4 h-4"}),"Add Profile"]})]})]}),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(_a,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",value:f,onChange:U=>m(U.target.value),placeholder:"Search by name or filament...",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:p,onChange:U=>x(U.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:"All Extruders"}),s.jsx("option",{value:"left",children:"Left Only"}),s.jsx("option",{value:"right",children:"Right Only"})]})}),s.jsx("div",{className:"w-32",children:s.jsxs("select",{value:y,onChange:U=>b(U.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:"All Flow"}),s.jsx("option",{value:"hf",children:"HF Only"}),s.jsx("option",{value:"s",children:"S Only"})]})}),s.jsx("div",{className:"w-32",children:s.jsxs("select",{value:v,onChange:U=>N(U.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:"Sort: Name"}),s.jsx("option",{value:"k_value",children:"Sort: K-Value"}),s.jsx("option",{value:"filament",children:"Sort: Filament"})]})})]}),s.jsxs("div",{className:"flex flex-wrap gap-2 mb-6",children:[s.jsxs(we,{variant:"secondary",onClick:ce,disabled:!j?.profiles?.length,title:"Export profiles to JSON",children:[s.jsx($r,{className:"w-4 h-4"}),"Export"]}),s.jsxs(we,{variant:"secondary",onClick:Me,title:"Import profiles from JSON",children:[s.jsx(di,{className:"w-4 h-4"}),"Import"]}),s.jsx("div",{className:"flex-1"}),S?s.jsxs(s.Fragment,{children:[s.jsxs(we,{variant:"secondary",onClick:Ee,title:"Select all visible profiles",children:[s.jsx(Ro,{className:"w-4 h-4"}),"Select All"]}),s.jsxs(we,{variant:"secondary",onClick:fe,disabled:E.size===0,className:"text-red-500 hover:bg-red-500/10",title:`Delete ${E.size} selected profiles`,children:[s.jsx(un,{className:"w-4 h-4"}),"Delete (",E.size,")"]}),s.jsxs(we,{variant:"secondary",onClick:()=>{T(!1),C(new Set)},children:[s.jsx(zt,{className:"w-4 h-4"}),"Cancel"]})]}):s.jsxs(we,{variant:"secondary",onClick:()=>T(!0),disabled:!se.length,title:"Enter selection mode for bulk delete",children:[s.jsx(Ro,{className:"w-4 h-4"}),"Select"]})]}),W?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(dt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):G?s.jsx(Nt,{children:s.jsxs(Et,{className:"py-12 text-center",children:[s.jsx(zg,{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:"Printer Offline"}),s.jsx("p",{className:"text-bambu-gray mb-4",children:"The selected printer is not connected. Power it on to view K-profiles."}),s.jsxs(we,{variant:"secondary",onClick:()=>Q(),children:[s.jsx(xr,{className:"w-4 h-4"}),"Retry"]})]})}):se.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:"Left Extruder"}),s.jsx("div",{className:"space-y-1",children:se.filter(U=>U.extruder_id===1).map(U=>s.jsx(wj,{profile:U,onEdit:()=>o(U),onCopy:()=>d(U),selectionMode:S,isSelected:E.has(F(U)),onToggleSelect:()=>me(F(U)),note:X(U)},F(U)))})]}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-2 px-1",children:"Right Extruder"}),s.jsx("div",{className:"space-y-1",children:se.filter(U=>U.extruder_id===0).map(U=>s.jsx(wj,{profile:U,onEdit:()=>o(U),onCopy:()=>d(U),selectionMode:S,isSelected:E.has(F(U)),onToggleSelect:()=>me(F(U)),note:X(U)},F(U)))})]})]}):s.jsx("div",{className:"space-y-1",children:se.map(U=>s.jsx(wj,{profile:U,onEdit:()=>o(U),onCopy:()=>d(U),selectionMode:S,isSelected:E.has(F(U)),onToggleSelect:()=>me(F(U)),note:X(U)},F(U)))}):f||p!=="all"||y!=="all"?s.jsx(Nt,{children:s.jsxs(Et,{className:"py-12 text-center",children:[s.jsx(_a,{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:"No Matching Profiles"}),s.jsx("p",{className:"text-bambu-gray",children:"No profiles match your search criteria"})]})}):s.jsx(Nt,{children:s.jsxs(Et,{className:"py-12 text-center",children:[s.jsx(I2,{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:"No K-Profiles"}),s.jsxs("p",{className:"text-bambu-gray mb-4",children:["No pressure advance profiles found for ",r,"mm nozzle"]}),s.jsxs(we,{onClick:()=>c(!0),children:[s.jsx(Jn,{className:"w-4 h-4"}),"Create First Profile"]})]})}),a&&e&&(()=>{const{note:U,key:B}=$(a);return s.jsx(Sj,{profile:a,printerId:e,nozzleDiameter:r,existingProfiles:ee?.profiles||j?.profiles,isDualNozzle:pe,initialNote:U,initialNoteKey:B,onSaveNote:V,onClose:()=>{console.log("[KProfiles] Edit modal onClose - refetching profiles..."),o(null),Q()},onSave:()=>{o(null),Q()}})})(),l&&e&&s.jsx(Sj,{printerId:e,nozzleDiameter:r,existingProfiles:ee?.profiles||j?.profiles,isDualNozzle:pe,onSaveNote:V,onClose:()=>{c(!1),Q()},onSave:()=>{c(!1),Q()}}),u&&e&&s.jsx(Sj,{printerId:e,nozzleDiameter:r,existingProfiles:ee?.profiles||j?.profiles,isDualNozzle:pe,onSaveNote:V,profile:{...u,slot_id:0,name:`${u.name} (Copy)`},onClose:()=>{d(null),Q()},onSave:()=>{d(null),Q()}}),A&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:s.jsx(Nt,{className:"w-full max-w-sm",children:s.jsxs(Et,{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(un,{className:"w-5 h-5 text-red-500"})}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-semibold text-white",children:"Delete Profiles"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"This cannot be undone"})]})]}),s.jsxs("p",{className:"text-bambu-gray mb-6",children:["Are you sure you want to delete ",s.jsx("span",{className:"text-white font-medium",children:E.size})," selected profiles from the printer?"]}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx(we,{variant:"secondary",onClick:()=>O(!1),disabled:k,className:"flex-1",children:"Cancel"}),s.jsxs(we,{onClick:le,disabled:k,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[k?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(un,{className:"w-4 h-4"}),"Delete"]})]})]})})})]})}function $L(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 ny(t){return/^(P[FPM]US|PF\d|PP\d)/.test(t)}function AKe(t){const e=vi(t);if(!e)return"";const r=new Date().getTime()-e.getTime(),i=Math.floor(r/6e4),a=Math.floor(r/36e5),o=Math.floor(r/864e5);return i<1?"Just now":i<60?`${i}m ago`:a<24?`${a}h ago`:o<7?`${o}d ago`:e.toLocaleDateString()}function CKe({onSuccess:t}){const{showToast:e}=Vn(),[n,r]=w.useState("email"),[i,a]=w.useState(""),[o,l]=w.useState(""),[c,u]=w.useState(""),[d,f]=w.useState(""),[m,p]=w.useState("global"),x=pt({mutationFn:()=>he.cloudLogin(i,o,m),onSuccess:S=>{S.success?(e("Logged in successfully"),t()):S.needs_verification?(e("Verification code sent to your email"),r("code")):e(S.message,"error")},onError:S=>e(S.message,"error")}),y=pt({mutationFn:()=>he.cloudVerify(i,c),onSuccess:S=>{S.success?(e("Logged in successfully"),t()):e(S.message,"error")},onError:S=>e(S.message,"error")}),b=pt({mutationFn:()=>he.cloudSetToken(d),onSuccess:()=>{e("Token set successfully"),t()},onError:S=>e(S.message,"error")}),v=S=>{S.preventDefault(),n==="email"?x.mutate():n==="code"?y.mutate():n==="token"&&b.mutate()},N=x.isPending||y.isPending||b.isPending;return s.jsx(Nt,{className:"max-w-md mx-auto",children:s.jsxs(Et,{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(R2,{className:"w-6 h-6 text-bambu-green"})}),s.jsx("h2",{className:"text-xl font-semibold text-white",children:"Connect to Bambu Cloud"}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Sync your slicer presets across devices"})]}),s.jsxs("form",{onSubmit:v,className:"space-y-4",children:[n==="email"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Email"}),s.jsx("input",{type:"email",value:i,onChange:S=>a(S.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:"Password"}),s.jsx("input",{type:"password",value:o,onChange:S=>l(S.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:"Region"}),s.jsxs("select",{value:m,onChange:S=>p(S.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:"Global"}),s.jsx("option",{value:"china",children:"China"})]})]})]}),n==="code"&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Verification Code"}),s.jsxs("p",{className:"text-xs text-bambu-gray mb-2",children:["Check your email (",i,") for a 6-digit code"]}),s.jsx("input",{type:"text",value:c,onChange:S=>u(S.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})]}),n==="token"&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Access Token"}),s.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:"Paste your Bambu Lab access token (from Bambu Studio)"}),s.jsx("textarea",{value:d,onChange:S=>f(S.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:[n==="code"&&s.jsx(we,{type:"button",variant:"secondary",onClick:()=>r("email"),className:"flex-1",children:"Back"}),s.jsxs(we,{type:"submit",disabled:N,className:"flex-1",children:[N?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(bz,{className:"w-4 h-4"}),n==="email"?"Login":n==="code"?"Verify":"Set Token"]})]}),n==="email"&&s.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:s.jsxs("button",{type:"button",onClick:()=>r("token"),className:"text-sm text-bambu-gray hover:text-white flex items-center gap-2 transition-colors",children:[s.jsx(Jh,{className:"w-4 h-4"}),"Use access token instead"]})}),n==="token"&&s.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:s.jsxs("button",{type:"button",onClick:()=>r("email"),className:"text-sm text-bambu-gray hover:text-white flex items-center gap-2 transition-colors",children:[s.jsx(bz,{className:"w-4 h-4"}),"Login with email instead"]})})]})]})})}function Ep({label:t,value:e,options:n,onChange:r}){const[i,a]=w.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(Pi,{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 kKe(){const[t,e]=w.useState(!1);w.useEffect(()=>{const r=()=>{e(window.scrollY>300)};return window.addEventListener("scroll",r),()=>window.removeEventListener("scroll",r)},[]);const n=()=>{window.scrollTo({top:0,behavior:"smooth"})};return t?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(rg,{className:"w-5 h-5"})}):null}function Nj({setting:t,onClick:e,onDuplicate:n,compareMode:r,isCompareSelected:i,compareIndex:a,compareDisabled:o}){const l=$L(t.name),c=ny(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&&c&&s.jsx("span",{className:"flex-shrink-0 w-1.5 h-1.5 rounded-full bg-bambu-green",title:"My preset (editable)"}),s.jsx("span",{className:"text-white text-sm truncate flex-1",title:t.name,children:t.name}),l.filamentType&&t.type==="filament"&&s.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:l.filamentType}),l.layerHeight&&t.type==="process"&&s.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:l.layerHeight}),l.printer&&s.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:l.printer})]})}),s.jsx("button",{onClick:u=>{u.stopPropagation(),n()},className:"opacity-0 group-hover:opacity-100 text-bambu-gray hover:text-white transition-all p-1",title:"Duplicate",children:s.jsx(ol,{className:"w-4 h-4"})})]})}function WR(t,e=0){const n=" ".repeat(e);if(t===null)return"null";if(t===void 0)return"undefined";if(typeof t=="string"){if(t.includes("\\n")||t.includes(`
  8279. `)){const i=t.replace(/\\n/g,`
  8280. `).replace(/\\"/g,'"').replace(/\\t/g," ").split(`
  8281. `);if(i.length>1)return`"""
  8282. `+i.map(a=>n+" "+a).join(`
  8283. `)+`
  8284. `+n+'"""'}return JSON.stringify(t)}if(typeof t=="number"||typeof t=="boolean")return String(t);if(Array.isArray(t))return t.length===0?"[]":`[
  8285. `+t.map(i=>n+" "+WR(i,e+1)).join(`,
  8286. `)+`
  8287. `+n+"]";if(typeof t=="object"){const r=Object.entries(t);return r.length===0?"{}":`{
  8288. `+r.map(([a,o])=>n+" "+JSON.stringify(a)+": "+WR(o,e+1)).join(`,
  8289. `)+`
  8290. `+n+"}"}return String(t)}function jKe({setting:t,onClose:e,onDeleted:n,onDuplicate:r,onEdit:i}){const{showToast:a}=Vn(),o=on(),[l,c]=w.useState(!1),{data:u,isLoading:d}=ut({queryKey:["cloudSettingDetail",t.setting_id],queryFn:()=>he.getCloudSettingDetail(t.setting_id)}),f=pt({mutationFn:()=>he.deleteCloudSetting(t.setting_id),onSuccess:()=>{a("Preset deleted"),o.invalidateQueries({queryKey:["cloudSettings"]}),n()},onError:x=>a(x.message,"error")}),m=ny(t.setting_id),p=$L(t.name,u?.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(Nt,{className:"w-full max-w-3xl max-h-[90vh] flex flex-col overflow-hidden",children:s.jsxs(Et,{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}),m&&s.jsx("span",{className:"px-2 py-0.5 text-xs font-medium bg-bambu-green/20 text-bambu-green rounded-full",children:"Editable"})]}),s.jsxs("div",{className:"flex items-center gap-2 mt-1 text-sm text-bambu-gray",children:[s.jsxs("span",{className:"capitalize",children:[t.type," preset"]}),p.printer&&s.jsxs(s.Fragment,{children:[s.jsx("span",{children:"•"}),s.jsx("span",{children:p.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(zt,{className:"w-5 h-5"})})]}),s.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto p-4",children:d?s.jsx("div",{className:"flex items-center justify-center py-16",children:s.jsx(dt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):u?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:WR(u)}):s.jsx("div",{className:"text-center py-16 text-bambu-gray",children:"Failed to load preset details"})}),l?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(yn,{className:"w-5 h-5"}),s.jsx("span",{className:"font-medium",children:"Delete this preset?"})]}),s.jsxs("p",{className:"text-sm text-bambu-gray mb-4",children:['This will permanently delete "',t.name,'" from Bambu Cloud. This cannot be undone.']}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(we,{variant:"secondary",onClick:()=>c(!1),disabled:f.isPending,className:"flex-1",children:"Cancel"}),s.jsxs(we,{variant:"danger",onClick:()=>f.mutate(),disabled:f.isPending,className:"flex-1",children:[f.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(un,{className:"w-4 h-4"}),"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(we,{variant:"secondary",onClick:e,className:"flex-1",children:"Close"}),s.jsxs(we,{variant:"secondary",onClick:r,children:[s.jsx(ol,{className:"w-4 h-4"}),"Duplicate"]}),m&&s.jsxs(s.Fragment,{children:[s.jsxs(we,{variant:"secondary",onClick:i,disabled:d||!u,children:[s.jsx(ia,{className:"w-4 h-4"}),"Edit"]}),s.jsx(we,{variant:"danger",onClick:()=>c(!0),children:s.jsx(un,{className:"w-4 h-4"})})]})]})})]})})})}function Sre(){try{const t=localStorage.getItem("bambusy_preset_templates");return t?JSON.parse(t):[]}catch{return[]}}function Nre(t){localStorage.setItem("bambusy_preset_templates",JSON.stringify(t))}function PKe({onClose:t,onApply:e}){const{showToast:n}=Vn(),[r,i]=w.useState(Sre),[a,o]=w.useState("all"),[l,c]=w.useState(null),[u,d]=w.useState(""),[f,m]=w.useState(""),[p,x]=w.useState("{}"),[y,b]=w.useState(null),[v,N]=w.useState(null),S=a==="all"?r:r.filter(L=>L.type===a),T=L=>{i(L),Nre(L)},E=L=>{const K=r.filter(j=>j.id!==L);T(K),N(null),n("Template deleted")},C=L=>{c(L.id),d(L.name),m(L.description),x(JSON.stringify(L.settings,null,2)),b(null)},A=()=>{if(!(!l||!u.trim()))try{const L=JSON.parse(p),K=r.map(j=>j.id===l?{...j,name:u.trim(),description:f.trim(),settings:L}:j);T(K),c(null),n("Template updated")}catch(L){b(L.message)}},O=()=>{c(null),d(""),m(""),x("{}"),b(null)},k=L=>{const K=r.map(j=>j.id===L?{...j,showInModal:!j.showInModal}:j);T(K)},R={filament:{label:"Filament",icon:cD,color:"text-amber-400"},print:{label:"Process",icon:Bd,color:"text-blue-400"},printer:{label:"Printer",icon:Mr,color:"text-purple-400"}},F=v?r.find(L=>L.id===v):null;return w.useEffect(()=>{const L=K=>{K.key==="Escape"&&(v?N(null):l?O():t())};return window.addEventListener("keydown",L),()=>window.removeEventListener("keydown",L)},[v,l,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(Nt,{className:"w-full max-w-md",children:s.jsxs(Et,{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(yn,{className:"w-6 h-6 text-red-400"})}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-semibold text-white",children:"Delete Template"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"This action cannot be undone"})]})]}),s.jsxs("p",{className:"text-white mb-6",children:['Are you sure you want to delete "',s.jsx("span",{className:"font-medium",children:F.name}),'"?']}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(we,{variant:"secondary",onClick:()=>N(null),className:"flex-1",children:"Cancel"}),s.jsxs(we,{onClick:()=>E(v),className:"flex-1 bg-red-500 hover:bg-red-600",children:[s.jsx(un,{className:"w-4 h-4"}),"Delete"]})]})]})})}),s.jsx(Nt,{className:"w-full max-w-2xl max-h-[80vh] flex flex-col",children:s.jsxs(Et,{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(p0,{className:"w-5 h-5 text-amber-400"}),"Quick Templates"]}),s.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white",children:s.jsx(zt,{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:"Type:"}),["all","filament","print","printer"].map(L=>s.jsx("button",{onClick:()=>o(L),className:`px-3 py-1 text-sm rounded-lg transition-colors ${a===L?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:L==="all"?"All":R[L].label},L))]}),s.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:S.length===0?s.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[s.jsx(p0,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),s.jsx("p",{children:"No templates yet"}),s.jsx("p",{className:"text-sm mt-1",children:"Create templates from the preset editor"})]}):s.jsx("div",{className:"space-y-2",children:S.map(L=>{const K=R[L.type],j=K.icon;return l===L.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:u,onChange:W=>d(W.target.value),placeholder:"Template name",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:f,onChange:W=>m(W.target.value),placeholder:"Description",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:"Settings (JSON)"}),s.jsx("textarea",{value:p,onChange:W=>{x(W.target.value),b(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(we,{size:"sm",onClick:A,disabled:!u.trim(),children:[s.jsx(gs,{className:"w-4 h-4"}),"Save"]}),s.jsx(we,{size:"sm",variant:"secondary",onClick:O,children:"Cancel"})]})]},L.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(j,{className:`w-5 h-5 ${K.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:L.name}),s.jsx("p",{className:"text-xs text-bambu-gray truncate",children:L.description})]}),s.jsxs("span",{className:"text-xs text-bambu-gray-dark px-2 py-1 bg-bambu-dark-secondary rounded",children:[Object.keys(L.settings).length," fields"]}),s.jsx("button",{onClick:()=>k(L.id),className:`p-1 transition-colors ${L.showInModal?"text-bambu-green hover:text-bambu-green/70":"text-bambu-gray hover:text-white"}`,title:L.showInModal?"Shown in modals":"Hidden in modals",children:L.showInModal?s.jsx(Cf,{className:"w-4 h-4"}):s.jsx(D2,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>e(L),className:"px-3 py-1 text-xs bg-bambu-green/20 text-bambu-green rounded hover:bg-bambu-green/30 transition-colors",children:"Apply"}),s.jsx("button",{onClick:()=>C(L),className:"p-1 text-bambu-gray hover:text-white",title:"Edit",children:s.jsx(ia,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>N(L.id),className:"p-1 text-bambu-gray hover:text-red-400",title:"Delete",children:s.jsx(un,{className:"w-4 h-4"})})]},L.id)})})})]})})]})}function Mre({onClose:t,leftPreset:e,rightPreset:n,leftLabel:r,rightLabel:i}){const[a,o]=w.useState("changes"),[l,c]=w.useState(""),u=w.useMemo(()=>{const p=new Set([...Object.keys(e),...Object.keys(n)]),x=[];for(const y of p){if(y==="inherits"||y==="version")continue;const b=e[y],v=n[y],N=y in e,S=y in n;let T;!N&&S?T="added":N&&!S?T="removed":JSON.stringify(b)!==JSON.stringify(v)?T="changed":T="same",x.push({key:y,left:b,right:v,status:T})}return x.sort((y,b)=>{const v={changed:0,added:1,removed:2,same:3};return v[y.status]!==v[b.status]?v[y.status]-v[b.status]:y.key.localeCompare(b.key)})},[e,n]),d=w.useMemo(()=>{let p=[...u];if(a==="changes"&&(p=p.filter(x=>x.status!=="same")),l){const x=l.toLowerCase();p=p.filter(y=>y.key.toLowerCase().includes(x)||String(y.left).toLowerCase().includes(x)||String(y.right).toLowerCase().includes(x))}return p},[u,a,l]),f=w.useMemo(()=>({added:u.filter(p=>p.status==="added").length,removed:u.filter(p=>p.status==="removed").length,changed:u.filter(p=>p.status==="changed").length,same:u.filter(p=>p.status==="same").length}),[u]),m=p=>{if(p===void 0)return"—";if(p===null)return"null";if(Array.isArray(p))return p.length===0?"[]":p.length===1?String(p[0]):p.join(", ");if(typeof p=="object")return JSON.stringify(p);const x=String(p);if(x.includes("\\n")||x.length>100){const y=x.split("\\n").length;if(y>1)return`[${y} lines of G-code/script]`;if(x.length>100)return x.substring(0,100)+"…"}return x};return w.useEffect(()=>{const p=x=>{x.key==="Escape"&&t()};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[t]),s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:s.jsx(Nt,{className:"w-full max-w-4xl max-h-[85vh] flex flex-col overflow-hidden",children:s.jsxs(Et,{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($p,{className:"w-5 h-5 text-blue-400"}),"Compare Presets"]}),s.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white",children:s.jsx(zt,{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:"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:"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(Jn,{className:"w-3.5 h-3.5"}),f.added," added"]}),s.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[s.jsx(Yj,{className:"w-3.5 h-3.5"}),f.removed," removed"]}),s.jsxs("span",{className:"flex items-center gap-1 text-amber-400",children:[s.jsx(Hj,{className:"w-3.5 h-3.5"}),f.changed," changed"]}),s.jsxs("span",{className:"flex items-center gap-1 text-bambu-gray",children:[s.jsx(OT,{className:"w-3.5 h-3.5"}),f.same," same"]})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("div",{className:"relative",children:[s.jsx(_a,{className:"absolute left-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",value:l,onChange:p=>c(p.target.value),placeholder:"Search fields...",className:"pl-8 pr-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none w-48"})]}),f.same>0&&s.jsxs("div",{className:"flex rounded overflow-hidden border border-bambu-dark-tertiary",children:[s.jsx("button",{onClick:()=>o("changes"),className:`px-3 py-1.5 text-sm transition-colors ${a==="changes"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:"Changes"}),s.jsx("button",{onClick:()=>o("all"),className:`px-3 py-1.5 text-sm transition-colors ${a==="all"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:"All"})]})]})]}),s.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:d.length===0?s.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[s.jsx(OT,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),s.jsx("p",{children:a==="changes"?"No differences found":"No fields match the search"})]}):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:"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:d.map(p=>{const x={added:"bg-green-500/10",removed:"bg-red-500/10",changed:"bg-amber-500/10",same:""}[p.status],y={added:s.jsx(Jn,{className:"w-3.5 h-3.5 text-green-400"}),removed:s.jsx(Yj,{className:"w-3.5 h-3.5 text-red-400"}),changed:s.jsx(Hj,{className:"w-3.5 h-3.5 text-amber-400"}),same:s.jsx(OT,{className:"w-3.5 h-3.5 text-bambu-gray-dark"})}[p.status];return s.jsxs("tr",{className:`border-b border-bambu-dark-tertiary ${x}`,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:p.key})]})}),s.jsx("td",{className:"p-3",children:s.jsx("span",{className:`text-sm font-mono break-all ${p.status==="removed"?"text-red-300":p.status==="changed"?"text-white":"text-bambu-gray"}`,children:m(p.left)})}),s.jsx("td",{className:"p-3",children:s.jsx("span",{className:`text-sm font-mono break-all ${p.status==="added"?"text-green-300":p.status==="changed"?"text-white":"text-bambu-gray"}`,children:m(p.right)})})]},p.key)})})]})})]})})})}function RKe({onClose:t,initialData:e,allPresets:n}){const{showToast:r}=Vn(),i=on(),a=!!e?.setting_id,[o,l]=w.useState("common"),[c,u]=w.useState(e?.type||"filament"),[d,f]=w.useState(e?.name?a?e.name:`${e.name} (Copy)`:""),[m,p]=w.useState(e?.base_id||""),[x,y]=w.useState(""),[b,v]=w.useState(e?.setting||{inherits:""}),[N,S]=w.useState(JSON.stringify(e?.setting||{inherits:""},null,2)),[T,E]=w.useState(null),[C,A]=w.useState(""),[O,k]=w.useState(!1),[R,F]=w.useState(""),[L,K]=w.useState(!1),[j,W]=w.useState(Sre),[Y,q]=w.useState(!1),[Q,ee]=w.useState(""),[re,z]=w.useState(""),[G,ae]=w.useState(!0),[se,ue]=w.useState(null),[pe,ce]=w.useState(!1),Me=w.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer})[c]||[],[n,c]),me=w.useMemo(()=>Me.filter(ie=>ny(ie.setting_id)),[Me]),{data:Ee}=ut({queryKey:["cloudFields",c],queryFn:()=>he.getCloudFields(c==="print"?"process":c),staleTime:1e3*60*60}),{data:fe}=ut({queryKey:["allPresetDetails",c,me.map(ie=>ie.setting_id).join(",")],queryFn:async()=>{const ie={};for(let Se=0;Se<me.length;Se+=5){const ze=me.slice(Se,Se+5);(await Promise.all(ze.map(async ne=>{try{const Pe=await he.getCloudSettingDetail(ne.setting_id);return{id:ne.setting_id,detail:Pe}}catch{return null}}))).forEach(ne=>{ne&&(ie[ne.id]=ne.detail)})}return ie},enabled:me.length>0,staleTime:1e3*60*10}),{data:le,isLoading:Be}=ut({queryKey:["cloudSettingDetail",m],queryFn:()=>he.getCloudSettingDetail(m),enabled:!!m});w.useEffect(()=>{o!=="json"&&S(JSON.stringify(b,null,2))},[b,o]);const V=w.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer}[c]||[]).filter(te=>!ny(te.setting_id)).sort((te,Se)=>te.name.localeCompare(Se.name)),[n,c]);w.useEffect(()=>{if(!m)return;const ie=V.find(te=>te.setting_id===m);ie&&(y(ie.name),a||(v({inherits:ie.name}),S(JSON.stringify({inherits:ie.name},null,2))))},[m,V,a]);const $=w.useMemo(()=>{const ie=Ee?.fields||[],te=new Set(ie.map(ne=>ne.key)),Se=new Set,ze=new Set(["inherits","updated_time","compatible_printers","compatible_prints"]);fe&&Object.values(fe).forEach(ne=>{ne?.setting&&Object.keys(ne.setting).forEach(Pe=>{!te.has(Pe)&&!ze.has(Pe)&&Se.add(Pe)})}),Object.keys(b).forEach(ne=>{!te.has(ne)&&!ze.has(ne)&&Se.add(ne)});const nt=Array.from(Se).sort().map(ne=>({key:ne,label:ne.replace(/_/g," ").replace(/\b\w/g,Pe=>Pe.toUpperCase()),type:"text",category:"discovered",description:"Discovered from presets"}));return[...ie,...nt]},[Ee,fe,b]),X=$.filter(ie=>ie.label.toLowerCase().includes(C.toLowerCase())||ie.key.toLowerCase().includes(C.toLowerCase())),U=()=>{if(R.trim()){const ie=R.trim().toLowerCase().replace(/\s+/g,"_");B(ie,""),F(""),K(!1),r(`Field "${ie}" added`)}},B=(ie,te)=>{v(Se=>{const ze={...Se};return te===""||te===void 0?delete ze[ie]:ze[ie]=te,ze})},oe=ie=>{v(te=>({...te,...ie.settings})),ue(ie.name),r("Template applied")},Te=()=>{if(!Q.trim())return;const ie={...b};if(delete ie.inherits,Object.keys(ie).length===0){r("No overrides to save","error");return}const te={id:Date.now().toString(),name:Q.trim(),description:re.trim()||"Custom template",type:c,settings:ie,showInModal:G},Se=[...j,te];W(Se),Nre(Se),q(!1),ee(""),z(""),ae(!0),r("Template saved")},je=w.useMemo(()=>j.filter(ie=>ie.type===c&&ie.showInModal),[c,j]),Ce=ie=>{S(ie);try{const te=JSON.parse(ie);v(te),E(null)}catch(te){E(te.message)}},H=ie=>{ie.preventDefault(),k(!1);const te=ie.dataTransfer.files[0];if(te&&te.name.endsWith(".json")){const Se=new FileReader;Se.onload=ze=>{try{const nt=ze.target?.result,ne=JSON.parse(nt),Pe=ne.setting||ne;v(be=>({...be,...Pe})),S(JSON.stringify({...b,...Pe},null,2)),r("File imported successfully")}catch{r("Invalid JSON file","error")}},Se.readAsText(te)}},D=pt({mutationFn:()=>{const ie={...b},te=c==="filament"?"filament_settings_id":c==="print"?"print_settings_id":"printer_settings_id";ie[te]=`"${d}"`;const Se={type:c,name:d,base_id:m,setting:ie};return he.createCloudSetting(Se)},onSuccess:async()=>{r("Preset created successfully"),await i.refetchQueries({queryKey:["cloudSettings"]}),t()},onError:ie=>r(ie.message,"error")}),Z=pt({mutationFn:()=>{if(!e?.setting_id)throw new Error("No setting ID for update");return he.updateCloudSetting(e.setting_id,{name:d,setting:b})},onSuccess:async()=>{r("Preset updated successfully"),i.removeQueries({queryKey:["cloudSettingDetail"]}),await i.refetchQueries({queryKey:["cloudSettings"]}),t()},onError:ie=>r(ie.message,"error")}),xe=a?Z:D,Ne=le?.setting?.inherits,ve=Ne?V.find(ie=>ie.name===Ne):void 0,{data:$e}=ut({queryKey:["cloudSettingDetail",ve?.setting_id],queryFn:()=>he.getCloudSettingDetail(ve.setting_id),enabled:!!ve?.setting_id}),Le=w.useMemo(()=>{const ie=$e?.setting||{},te=le?.setting||{},Se=m&&fe?.[m]?.setting?fe[m].setting:{};return{...ie,...te,...Se}},[m,le,$e,fe]),qe=ie=>{if(ie==null)return"";if(Array.isArray(ie)){const te=[...new Set(ie.map(Se=>String(Se)))];return te.length===1?te[0]:ie.join(", ")}return String(ie)},Ke=ie=>{const te=b[ie.key],Se=Le[ie.key],ze=qe(Se),nt=Be?"Loading...":ze||"",ne="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(ie.type==="boolean"){const Pe=te==="1"||te===void 0&&Se==="1";return s.jsx("button",{type:"button",onClick:()=>B(ie.key,te==="1"?"0":"1"),className:`w-8 h-5 rounded-full transition-colors ${Pe?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,children:s.jsx("div",{className:`w-4 h-4 rounded-full bg-white shadow transition-transform ${Pe?"translate-x-3.5":"translate-x-0.5"}`})})}return ie.type==="select"?s.jsxs("select",{value:te||"",onChange:Pe=>B(ie.key,Pe.target.value),className:ne,children:[s.jsx("option",{value:"",children:nt}),ie.options?.map(Pe=>s.jsx("option",{value:Pe.value,children:Pe.label},Pe.value))]}):s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:ie.type==="number"?"number":"text",value:te!==void 0?String(te):"",onChange:Pe=>B(ie.key,Pe.target.value),step:ie.step,min:ie.min,max:ie.max,placeholder:nt,className:ne}),ie.unit&&s.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:ie.unit})]})},Ye=w.useMemo(()=>le?.setting?le.setting:{},[le]);return s.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onDragOver:ie=>{ie.preventDefault(),k(!0)},onDragLeave:()=>k(!1),onDrop:H,children:[pe&&m&&s.jsx(Mre,{onClose:()=>ce(!1),leftPreset:Ye,rightPreset:b,leftLabel:`Base: ${x||m}`,rightLabel:`Current: ${d||"New Preset"}`}),s.jsx(Nt,{className:"w-full max-w-6xl max-h-[90vh] flex flex-col",children:s.jsxs(Et,{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:a?"Edit Preset":e?"Duplicate Preset":"Create New Preset"}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Customize settings for your new preset"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[m&&s.jsxs("button",{onClick:()=>ce(!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:"Compare with base preset",children:[s.jsx($p,{className:"w-4 h-4"}),"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(zt,{className:"w-5 h-5"})})]})]}),O&&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(di,{className:"w-12 h-12 text-bambu-green mx-auto mb-2"}),s.jsx("p",{className:"text-bambu-green font-medium",children:"Drop JSON file to import"})]})}),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:"Type"}),s.jsxs("select",{value:c,onChange:ie=>{u(ie.target.value),p("")},className:"w-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:"Filament"}),s.jsx("option",{value:"print",children:"Process"}),s.jsx("option",{value:"printer",children:"Printer"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Base Preset"}),s.jsxs("select",{value:m,onChange:ie=>p(ie.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"",children:"Select base preset..."}),V.map(ie=>s.jsx("option",{value:ie.setting_id,children:ie.name},ie.setting_id))]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Preset Name"}),s.jsx("input",{type:"text",value:d,onChange:ie=>f(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:"My Custom Preset"})]})]}),x&&s.jsx("div",{className:"text-xs text-bambu-gray",children:s.jsxs("p",{className:"flex items-center gap-1",children:[s.jsx(Ya,{className:"w-3 h-3 text-bambu-green"}),"Inherits from: ",s.jsx("span",{className:"text-white",children:x}),Be&&s.jsx(dt,{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:()=>l("common"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${o==="common"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[s.jsx(yz,{className:"w-4 h-4"}),"Common"]}),s.jsxs("button",{onClick:()=>l("fields"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${o==="fields"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[s.jsx(B2,{className:"w-4 h-4"}),"All Fields"]}),s.jsxs("button",{onClick:()=>l("json"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${o==="json"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[s.jsx(nq,{className:"w-4 h-4"}),"JSON",T&&s.jsx(ji,{className:"w-3 h-3 text-red-400"})]}),s.jsx("div",{className:"flex-1"}),s.jsxs("button",{onClick:()=>{const ie={name:d,type:c,base_id:m,setting:b},te=new Blob([JSON.stringify(ie,null,2)],{type:"application/json"}),Se=URL.createObjectURL(te),ze=document.createElement("a");ze.href=Se,ze.download=`${d||"preset"}.json`,document.body.appendChild(ze),ze.click(),document.body.removeChild(ze),URL.revokeObjectURL(Se),r("Preset exported")},className:"flex items-center gap-2 px-4 py-3 text-sm text-bambu-gray hover:text-white transition-colors",title:"Export current settings to JSON file",children:[s.jsx($r,{className:"w-4 h-4"}),"Export"]}),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:"Import settings from JSON file",children:[s.jsx(di,{className:"w-4 h-4"}),"Import"]}),s.jsx("input",{id:"file-import",type:"file",accept:".json",className:"hidden",onChange:ie=>{const te=ie.target.files?.[0];if(te){const Se=new FileReader;Se.onload=ze=>{try{const nt=JSON.parse(ze.target?.result),ne=nt.setting||nt;v(Pe=>({...Pe,...ne})),r("File imported")}catch{r("Invalid JSON","error")}},Se.readAsText(te)}}})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto p-4",children:[o==="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(p0,{className:"w-4 h-4 text-amber-400"}),"Quick Templates"]}),Object.keys(b).filter(ie=>ie!=="inherits").length>0&&s.jsxs("button",{onClick:()=>q(!Y),className:"text-xs text-bambu-gray hover:text-white flex items-center gap-1 transition-colors",children:[s.jsx(gs,{className:"w-3 h-3"}),"Save as template"]})]}),Y&&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:Q,onChange:ie=>ee(ie.target.value),placeholder:"Template name",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:re,onChange:ie=>z(ie.target.value),placeholder:"Description (optional)",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(we,{size:"sm",onClick:Te,disabled:!Q.trim(),children:[s.jsx(gs,{className:"w-3 h-3"}),"Save"]}),s.jsx(we,{size:"sm",variant:"secondary",onClick:()=>q(!1),children:"Cancel"})]}),s.jsxs("button",{onClick:()=>ae(!G),className:`flex items-center gap-1.5 text-xs transition-colors ${G?"text-bambu-green":"text-bambu-gray hover:text-white"}`,children:[G?s.jsx(Cf,{className:"w-3.5 h-3.5"}):s.jsx(D2,{className:"w-3.5 h-3.5"}),G?"Show in modals":"Hidden in modals"]})]})]}),se&&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(Ya,{className:"w-4 h-4 text-bambu-green"}),s.jsxs("span",{className:"text-sm text-bambu-green",children:["Template applied: ",s.jsx("span",{className:"font-medium",children:se})]}),s.jsx("button",{onClick:()=>ue(null),className:"ml-auto text-bambu-green/70 hover:text-bambu-green",children:s.jsx(zt,{className:"w-4 h-4"})})]}),s.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[je.map(ie=>s.jsxs("button",{onClick:()=>oe(ie),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:ie.name}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:ie.description})]},ie.id)),je.length===0&&s.jsx("p",{className:"col-span-3 text-center text-bambu-gray text-sm py-4",children:"No templates selected. Use the Templates button to enable templates for quick access."})]}),s.jsx("p",{className:"text-xs text-bambu-gray-dark mt-2 text-center",children:"Manage templates via the Templates button on the main page"})]}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:"Common Settings"}),s.jsx("div",{className:"grid grid-cols-2 gap-x-6 gap-y-3",children:$.slice(0,10).map(ie=>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:ie.label}),s.jsx("div",{className:"w-48",children:Ke(ie)})]},ie.key))})]}),Object.keys(b).length>1&&s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:"Current Overrides"}),s.jsx("div",{className:"flex flex-wrap gap-2",children:Object.entries(b).filter(([ie])=>ie!=="inherits").map(([ie,te])=>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:[ie,": ",String(te).slice(0,20),s.jsx("button",{onClick:()=>B(ie,void 0),className:"hover:text-white",children:s.jsx(zt,{className:"w-3 h-3"})})]},ie))})]})]}),o==="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:"Available Fields"}),s.jsx("span",{className:"text-xs text-bambu-gray",children:fe?`${$.length} fields`:"Loading..."})]}),s.jsxs("div",{className:"relative mb-3 flex-shrink-0",children:[s.jsx(_a,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",value:C,onChange:ie=>A(ie.target.value),placeholder:"Search fields...",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:[X.filter(ie=>!(ie.key in b)).map(ie=>{const te=Le[ie.key],Se=qe(te);return s.jsxs("div",{onClick:()=>{v(ze=>({...ze,[ie.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:ie.label}),s.jsx("p",{className:"text-xs text-bambu-gray-dark truncate",children:ie.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(Jn,{className:"w-4 h-4 text-bambu-gray group-hover:text-bambu-green transition-colors"})})]})]},ie.key)}),X.filter(ie=>!(ie.key in b)).length===0&&s.jsx("p",{className:"text-center text-bambu-gray py-4 text-sm",children:C?"No matching fields":"All fields added"})]}),s.jsx("div",{className:"pt-3 mt-3 border-t border-bambu-dark-tertiary flex-shrink-0",children:L?s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{type:"text",value:R,onChange:ie=>F(ie.target.value),onKeyDown:ie=>ie.key==="Enter"&&U(),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(we,{size:"sm",onClick:U,disabled:!R.trim(),children:s.jsx(Jn,{className:"w-4 h-4"})}),s.jsx(we,{size:"sm",variant:"secondary",onClick:()=>{K(!1),F("")},children:s.jsx(zt,{className:"w-4 h-4"})})]}):s.jsxs("button",{onClick:()=>K(!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(Jn,{className:"w-4 h-4"}),"Add custom field"]})})]}),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:"Your Overrides"}),s.jsxs("span",{className:"text-xs text-bambu-gray",children:[Object.keys(b).filter(ie=>ie!=="inherits").length," fields"]})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto space-y-2 pr-2 min-h-0",children:[Object.entries(b).filter(([ie])=>ie!=="inherits").map(([ie,te])=>{const Se=$.find(ze=>ze.key===ie);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||ie}),s.jsx("p",{className:"text-xs text-bambu-gray-dark",children:ie})]}),s.jsx("button",{onClick:()=>B(ie,void 0),className:"p-1 text-bambu-gray hover:text-red-400 transition-colors",children:s.jsx(zt,{className:"w-4 h-4"})})]}),Se?Ke(Se):s.jsx("input",{type:"text",value:String(te),onChange:ze=>B(ie,ze.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"})]},ie)}),Object.keys(b).filter(ie=>ie!=="inherits").length===0&&s.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[s.jsx(yz,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),s.jsx("p",{className:"text-sm",children:"No overrides yet"}),s.jsx("p",{className:"text-xs mt-1",children:"Click fields on the left to add them"})]})]}),Object.keys(b).filter(ie=>ie!=="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),l("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(gs,{className:"w-4 h-4"}),"Save as template"]})})]})]}),o==="json"&&s.jsxs("div",{className:"space-y-2",children:[T&&s.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[s.jsx(ji,{className:"w-4 h-4"}),T]}),s.jsx("textarea",{value:N,onChange:ie=>Ce(ie.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 ${T?"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:"Tip: Drag & drop a .json file anywhere on this modal to import settings"})]})]}),s.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary flex gap-2",children:[s.jsx(we,{variant:"secondary",onClick:t,className:"flex-1",children:"Cancel"}),s.jsxs(we,{onClick:()=>xe.mutate(),disabled:xe.isPending||!d.trim()||!a&&!m||!!T,className:"flex-1",children:[xe.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):a?s.jsx(gs,{className:"w-4 h-4"}):s.jsx(Jn,{className:"w-4 h-4"}),a?"Save":e?"Duplicate":"Create"]})]})]})})]})}function DKe({settings:t,lastSyncTime:e,onRefresh:n,isRefreshing:r,printers:i}){const[a,o]=w.useState(""),[l,c]=w.useState("all"),[u,d]=w.useState("all"),[f,m]=w.useState("all"),[p,x]=w.useState("all"),[y,b]=w.useState("all"),[v,N]=w.useState("all"),[S,T]=w.useState(null),[E,C]=w.useState(!1),[A,O]=w.useState(!1),[k,R]=w.useState(null),[F,L]=w.useState(null),[K,j]=w.useState(null),[W,Y]=w.useState(!1),[q,Q]=w.useState([null,null]),[ee,re]=w.useState(!1),[z,G]=w.useState(null),ae=on(),se=w.useMemo(()=>[...t.filament.map(X=>({...X,type:"filament"})),...t.printer.map(X=>({...X,type:"printer"})),...t.process.map(X=>({...X,type:"process"}))].map(X=>({...X,meta:$L(X.name)})),[t]),ue=w.useMemo(()=>{const $=new Set,X=new Set,U=new Set;return se.forEach(B=>{B.meta.nozzle&&$.add(B.meta.nozzle),B.meta.filamentType&&X.add(B.meta.filamentType),B.meta.layerHeight&&U.add(B.meta.layerHeight)}),{printers:i.map(B=>({id:B.id.toString(),name:B.name})),nozzles:Array.from($).sort((B,oe)=>parseFloat(B)-parseFloat(oe)),filaments:Array.from(X).sort(),layerHeights:Array.from(U).sort((B,oe)=>parseFloat(B)-parseFloat(oe))}},[se,i]),pe=w.useMemo(()=>f==="all"?null:i.find(X=>X.id.toString()===f)?.model||null,[f,i]),ce=w.useMemo(()=>se.filter($=>l==="all"||$.type===l).filter($=>{if(u==="all")return!0;const X=ny($.setting_id);return u==="custom"?X:!X}).filter($=>{if(f==="all"||!pe)return!0;const X=$.meta.printer?.toLowerCase()||"",U=pe.toLowerCase();return X.includes(U)||U.includes(X)}).filter($=>p==="all"||$.meta.nozzle===p).filter($=>y==="all"||$.meta.filamentType===y).filter($=>v==="all"||$.meta.layerHeight===v).filter($=>a===""||$.name.toLowerCase().includes(a.toLowerCase())).sort(($,X)=>$.name.localeCompare(X.name)),[se,l,u,f,pe,p,y,v,a]),Me=$=>{if(W){const X=q[0]?.setting_id===$.setting_id,U=q[1]?.setting_id===$.setting_id;if(X)Q([q[1],null]);else if(U)Q([q[0],null]);else if(!q[0])Q([$,null]);else if(q[1]){if(q[0].type!==$.type)return;Q([q[0],$])}else{if(q[0].type!==$.type)return;Q([q[0],$])}}else T($)},me=$=>{if(q[0]?.setting_id===$.setting_id)return 0;if(q[1]?.setting_id===$.setting_id)return 1},Ee=async $=>{try{const X=await he.getCloudSettingDetail($.setting_id),U=$.type==="process"?"print":$.type;R({type:U,name:$.name,base_id:X.base_id||"GFSA00",setting:X.setting||{}}),T(null)}catch(X){console.error("Failed to fetch preset details for duplication:",X)}},fe=async $=>{try{ae.removeQueries({queryKey:["cloudSettingDetail",$.setting_id]});const X=await he.getCloudSettingDetail($.setting_id),U=$.type==="process"?"print":$.type;L({type:U,name:$.name,base_id:X.base_id||"GFSA00",setting:X.setting||{},setting_id:$.setting_id}),T(null)}catch(X){console.error("Failed to fetch preset details for editing:",X)}},le=()=>{c("all"),d("all"),m("all"),x("all"),b("all"),N("all"),o("")},Be=l!=="all"||u!=="all"||f!=="all"||p!=="all"||y!=="all"||v!=="all"||a!=="",V=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(_a,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",value:a,onChange:$=>o($.target.value),placeholder:"Search presets...",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(we,{variant:W?"primary":"secondary",onClick:()=>{W?(Y(!1),Q([null,null])):Y(!0)},children:[s.jsx($p,{className:"w-4 h-4"}),W?"Cancel":"Compare"]}),s.jsxs(we,{variant:"secondary",onClick:()=>O(!0),children:[s.jsx(p0,{className:"w-4 h-4"}),"Templates"]}),s.jsxs(we,{variant:"secondary",onClick:n,disabled:r,children:[s.jsx(xr,{className:`w-4 h-4 ${r?"animate-spin":""}`}),"Refresh"]}),s.jsxs(we,{onClick:()=>C(!0),children:[s.jsx(Jn,{className:"w-4 h-4"}),"New Preset"]})]})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx(L2,{className:"w-4 h-4 text-bambu-gray"}),s.jsx(Ep,{label:"Type",value:l,options:[{value:"all",label:"All",count:V},{value:"filament",label:"Filament",count:t.filament.length},{value:"printer",label:"Printer",count:t.printer.length},{value:"process",label:"Process",count:t.process.length}],onChange:$=>c($)}),s.jsx(Ep,{label:"Owner",value:u,options:[{value:"all",label:"All"},{value:"custom",label:"My Presets"},{value:"builtin",label:"Built-in"}],onChange:$=>d($)}),ue.printers.length>0&&s.jsx(Ep,{label:"Printer",value:f,options:[{value:"all",label:"All"},...ue.printers.map($=>({value:$.id,label:$.name}))],onChange:m}),ue.nozzles.length>0&&s.jsx(Ep,{label:"Nozzle",value:p,options:[{value:"all",label:"All"},...ue.nozzles.map($=>({value:$,label:$}))],onChange:x}),ue.filaments.length>0&&(l==="all"||l==="filament")&&s.jsx(Ep,{label:"Filament",value:y,options:[{value:"all",label:"All"},...ue.filaments.map($=>({value:$,label:$}))],onChange:b}),ue.layerHeights.length>0&&(l==="all"||l==="process")&&s.jsx(Ep,{label:"Layer",value:v,options:[{value:"all",label:"All"},...ue.layerHeights.map($=>({value:$,label:$}))],onChange:N}),Be&&s.jsx("button",{onClick:le,className:"px-3 py-2 text-sm text-bambu-gray hover:text-white transition-colors",children:"Clear filters"})]})]}),W&&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($p,{className:"w-5 h-5 text-blue-400"}),s.jsx("span",{className:"text-white font-medium",children:"Compare Mode"}),s.jsx("span",{className:"text-bambu-gray",children:q[0]?`Select another ${q[0].type} preset`:"Click two presets of the same type to compare"})]}),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] ${q[0]?"bg-blue-500/30 text-blue-700 dark:text-blue-300":"bg-bambu-dark text-bambu-gray"}`,children:q[0]?q[0].name:"1. Select first"}),s.jsx(Hj,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("span",{className:`px-2 py-1 text-sm rounded truncate max-w-[200px] ${q[1]?"bg-blue-500/30 text-blue-700 dark:text-blue-300":"bg-bambu-dark text-bambu-gray"}`,children:q[1]?q[1].name:"2. Select second"})]}),q[0]&&q[1]&&s.jsxs(we,{size:"sm",onClick:async()=>{try{const[$,X]=await Promise.all([he.getCloudSettingDetail(q[0].setting_id),he.getCloudSettingDetail(q[1].setting_id)]);G([$.setting||{},X.setting||{}]),re(!0)}catch{}},children:[s.jsx($p,{className:"w-4 h-4"}),"Compare Now"]})]})]})}),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(Kn,{className:"w-3 h-3"}),"Last synced: ",AKe(e.toISOString())]}),s.jsxs("span",{children:["Showing ",ce.length," of ",V," presets"]}),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.jsx("span",{children:"= My preset (editable)"})]})]}),ce.length===0?s.jsxs("div",{className:"text-center py-16",children:[s.jsx(cl,{className:"w-12 h-12 text-bambu-gray-dark mx-auto mb-4"}),s.jsx("p",{className:"text-bambu-gray",children:"No presets found"}),Be&&s.jsx("button",{onClick:le,className:"mt-2 text-sm text-bambu-green hover:text-bambu-green-light",children:"Clear filters"})]}):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(cD,{className:"w-4 h-4 text-amber-400"}),s.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:"Filament"}),s.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",ce.filter($=>$.type==="filament").length,")"]})]}),s.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[ce.filter($=>$.type==="filament").map($=>s.jsx(Nj,{setting:$,onClick:()=>Me($),onDuplicate:()=>Ee($),compareMode:W,isCompareSelected:me($)!==void 0,compareIndex:me($),compareDisabled:W&&!!q[0]&&q[0].type!==$.type},$.setting_id)),ce.filter($=>$.type==="filament").length===0&&s.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:"No filament presets"})]})]}),s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[s.jsx(Bd,{className:"w-4 h-4 text-blue-400"}),s.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:"Process"}),s.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",ce.filter($=>$.type==="process").length,")"]})]}),s.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[ce.filter($=>$.type==="process").map($=>s.jsx(Nj,{setting:$,onClick:()=>Me($),onDuplicate:()=>Ee($),compareMode:W,isCompareSelected:me($)!==void 0,compareIndex:me($),compareDisabled:W&&!!q[0]&&q[0].type!==$.type},$.setting_id)),ce.filter($=>$.type==="process").length===0&&s.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:"No process presets"})]})]}),s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[s.jsx(Mr,{className:"w-4 h-4 text-purple-400"}),s.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:"Printer"}),s.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",ce.filter($=>$.type==="printer").length,")"]})]}),s.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[ce.filter($=>$.type==="printer").map($=>s.jsx(Nj,{setting:$,onClick:()=>Me($),onDuplicate:()=>Ee($),compareMode:W,isCompareSelected:me($)!==void 0,compareIndex:me($),compareDisabled:W&&!!q[0]&&q[0].type!==$.type},$.setting_id)),ce.filter($=>$.type==="printer").length===0&&s.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:"No printer presets"})]})]})]}),S&&s.jsx(jKe,{setting:S,onClose:()=>T(null),onDeleted:()=>T(null),onDuplicate:()=>Ee(S),onEdit:()=>fe(S)}),(E||k||F||K)&&s.jsx(RKe,{onClose:()=>{C(!1),R(null),L(null),j(null)},initialData:F||k||(K?{type:K.type,name:"",base_id:"",setting:K.setting}:void 0),allPresets:t}),A&&s.jsx(PKe,{onClose:()=>O(!1),onApply:$=>{j({type:$.type,setting:$.settings}),O(!1)}}),ee&&z&&q[0]&&q[1]&&s.jsx(Mre,{onClose:()=>{re(!1),G(null)},leftPreset:z[0],rightPreset:z[1],leftLabel:q[0].name,rightLabel:q[1].name})]})}function OKe(){const t=on(),{showToast:e}=Vn(),[n,r]=w.useState("cloud"),[i,a]=w.useState(),{data:o,isLoading:l}=ut({queryKey:["cloudStatus"],queryFn:he.getCloudStatus}),{data:c=[]}=ut({queryKey:["printers"],queryFn:he.getPrinters}),{data:u,isLoading:d,refetch:f,dataUpdatedAt:m}=ut({queryKey:["cloudSettings"],queryFn:()=>he.getCloudSettings(),enabled:!!o?.is_authenticated,retry:!1,staleTime:1e3*60*5});w.useEffect(()=>{m&&a(new Date(m))},[m]);const p=pt({mutationFn:he.cloudLogout,onSuccess:()=>{t.invalidateQueries({queryKey:["cloudStatus"]}),t.removeQueries({queryKey:["cloudSettings"]}),e("Logged out")}}),x=()=>{t.invalidateQueries({queryKey:["cloudStatus"]})};return l?s.jsx("div",{className:"p-4 md:p-8 flex items-center justify-center min-h-[400px]",children:s.jsx(dt,{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:"Profiles"}),s.jsx("p",{className:"text-bambu-gray",children:"Manage your slicer presets and pressure advance calibrations"})]}),s.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary mb-6",children:[s.jsxs("button",{onClick:()=>r("cloud"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${n==="cloud"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[s.jsx(R2,{className:"w-4 h-4"}),"Cloud Profiles"]}),s.jsxs("button",{onClick:()=>r("kprofiles"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${n==="kprofiles"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[s.jsx(I2,{className:"w-4 h-4"}),"K-Profiles"]})]}),n==="cloud"&&s.jsxs(s.Fragment,{children:[o?.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:["Connected as ",s.jsx("span",{className:"text-white",children:o.email})]})]}),s.jsxs(we,{variant:"secondary",size:"sm",onClick:()=>p.mutate(),disabled:p.isPending,children:[s.jsx(Xj,{className:"w-4 h-4"}),"Logout"]})]}),o?.is_authenticated?d?s.jsx("div",{className:"flex items-center justify-center py-16",children:s.jsx(dt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):u?s.jsx(DKe,{settings:u,lastSyncTime:i,onRefresh:()=>f(),isRefreshing:d,printers:c}):s.jsxs("div",{className:"text-center py-16",children:[s.jsx("p",{className:"text-bambu-gray mb-4",children:"Failed to load profiles"}),s.jsx(we,{onClick:()=>f(),children:"Retry"})]}):s.jsx(CKe,{onSuccess:x})]}),n==="kprofiles"&&s.jsx(TKe,{}),s.jsx(kKe,{})]})}const Ib={Droplet:cD,Flame:jue,Ruler:che,Sparkles:p0,Square:Do,Cable:Ece,Wrench:$d,Calendar:ri,Timer:vd,Cog:iue,Fan:rq,Zap:Pf,Wind:gq,Thermometer:G2,Layers:cl,Box:zs,Target:fq,RefreshCw:xr,Settings:V2,Filter:L2,CircleDot:Gce};function o0(t){return t&&Ib[t]||$d}function Tp(t,e){if(e==="days")return t<1?"Today":t===1?"1 day":t<7?`${Math.round(t)} days`:t<180?`${Math.round(t/7)} weeks`:`${Math.round(t/30)} months`;{if(t<1)return`${Math.round(t*60)}m`;if(t<24)return`${t<10?t.toFixed(1):Math.round(t)}h`;const n=t/24;if(n<7)return`${n<2?n.toFixed(1):Math.round(n)}d`;const r=n/7;return r<12?`${r<2?r.toFixed(1):Math.round(r)}w`:`${Math.round(r/4)}mo`}}function Mj(t,e){return e==="days"?t===1?"1 day":t===7?"1 week":t===14?"2 weeks":t===30?"1 month":t===60?"2 months":t===90?"3 months":t===180?"6 months":t===365?"1 year":`${t} days`:`${t}h`}function LKe(t,e){const n=(e||"").toUpperCase().replace(/[- ]/g,""),r=n.includes("X1"),i=n.includes("P1"),a=n.includes("A1MINI"),o=n.includes("A1")&&!a,l=n.includes("H2D"),c=n.includes("H2C"),u=n.includes("H2S"),d=l||c||u,f=n.includes("P2S");switch(t){case"Lubricate Linear Rails":return r?"https://wiki.bambulab.com/en/x1/maintenance/basic-maintenance":i?"https://wiki.bambulab.com/en/p1/maintenance/p1p-maintenance":a?"https://wiki.bambulab.com/en/a1-mini/maintenance/lubricate-y-axis":o?"https://wiki.bambulab.com/en/a1/maintenance/lubricate-y-axis":d?"https://wiki.bambulab.com/en/h2/maintenance/x-axis-lubrication":f?"https://wiki.bambulab.com/en/p2s/maintenance/belt-tension":"https://wiki.bambulab.com/en/general/lead-screws-lubrication";case"Clean Nozzle/Hotend":return r||i?"https://wiki.bambulab.com/en/x1/troubleshooting/nozzle-clog":a||o?"https://wiki.bambulab.com/en/a1-mini/troubleshooting/nozzle-clog":d?"https://wiki.bambulab.com/en/h2/maintenance/nozzl-cold-pull-maintenance-and-cleaning":f?"https://wiki.bambulab.com/en/p2s/maintenance/cold-pull-maintenance-hotend":"https://wiki.bambulab.com/en/x1/troubleshooting/nozzle-clog";case"Check Belt Tension":return r?"https://wiki.bambulab.com/en/x1/maintenance/belt-tension":i?"https://wiki.bambulab.com/en/p1/maintenance/p1p-maintenance":a?"https://wiki.bambulab.com/en/a1-mini/maintenance/belt_tension":o?"https://wiki.bambulab.com/en/a1/maintenance/belt_tension":l?"https://wiki.bambulab.com/en/h2/maintenance/belt-tension":c?"https://wiki.bambulab.com/en/h2c/maintenance/belt-tension":u?"https://wiki.bambulab.com/en/h2s/maintenance/belt-tension":f?"https://wiki.bambulab.com/en/p2s/maintenance/belt-tension":"https://wiki.bambulab.com/en/x1/maintenance/belt-tension";case"Clean Carbon Rods":return r||i?"https://wiki.bambulab.com/en/general/carbon-rods-clearance":a||o||d||f?null:"https://wiki.bambulab.com/en/general/carbon-rods-clearance";case"Clean Build Plate":return"https://wiki.bambulab.com/en/filament-acc/acc/pei-plate-clean-guide";case"Check PTFE Tube":return r||i?"https://wiki.bambulab.com/en/x1/maintenance/replace-ptfe-tube":a||o?"https://wiki.bambulab.com/en/a1-mini/maintenance/ptfe-tube":l?"https://wiki.bambulab.com/en/h2/maintenance/replace-ptfe-tube-on-h2d-printer":u?"https://wiki.bambulab.com/en/h2s/maintenance/replace-ptfe-tube-on-h2s-printer":c?"https://wiki.bambulab.com/en/h2/maintenance/replace-ptfe-tube-on-h2d-printer":"https://wiki.bambulab.com/en/x1/maintenance/replace-ptfe-tube";case"Replace HEPA Filter":case"HEPA Filter":case"Replace Carbon Filter":case"Carbon Filter":return d?"https://wiki.bambulab.com/en/h2/maintenance/replace-smoke-purifier-air-filte":"https://wiki.bambulab.com/en/x1/maintenance/replace-carbon-filter";case"Lubricate Left Nozzle Rail":case"Left Nozzle Rail":return d?"https://wiki.bambulab.com/en/h2/maintenance/x-axis-lubrication":null;default:return null}}function IKe({item:t,onPerform:e,onToggle:n}){const r=o0(t.maintenance_type_icon),i=t.interval_type||"hours",o=(()=>{if(i==="days"){const f=t.days_since_maintenance??0;return Math.max(0,Math.min(100,f/t.interval_hours*100))}return Math.max(0,Math.min(100,(t.interval_hours-t.hours_until_due)/t.interval_hours*100))})(),l=()=>t.enabled?t.is_due?"text-red-400":t.is_warning?"text-amber-400":"text-bambu-green":"text-bambu-gray",c=()=>t.enabled?t.is_due?"bg-red-500":t.is_warning?"bg-amber-500":"bg-bambu-green":"bg-bambu-gray/30",u=()=>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",d=()=>{if(!t.enabled)return"Disabled";if(i==="days"){const f=t.days_until_due??0;return t.is_due?`Overdue by ${Tp(Math.abs(f),"days")}`:t.is_warning?`Due in ${Tp(f,"days")}`:`${Tp(f,"days")} left`}else return t.is_due?`Overdue by ${Tp(Math.abs(t.hours_until_due),"hours")}`:t.is_warning?`Due in ${Tp(t.hours_until_due,"hours")}`:`${Tp(t.hours_until_due,"hours")} left`};return s.jsx("div",{className:`rounded-xl border p-4 transition-all ${u()}`,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(r,{className:`w-5 h-5 ${l()}`}),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}),i==="days"&&s.jsx("span",{title:"Time-based interval",children:s.jsx(ri,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"})}),(()=>{const f=t.maintenance_type_wiki_url||LKe(t.maintenance_type_name,t.printer_model);return f?s.jsx("a",{href:f,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-gray hover:text-bambu-green transition-colors shrink-0",title:"View documentation",onClick:m=>m.stopPropagation(),children:s.jsx(Ur,{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 ${c()}`,style:{width:`${o}%`}})})}),s.jsxs("div",{className:`text-xs flex items-center gap-1 ${l()}`,children:[t.is_due&&s.jsx(yn,{className:"w-3 h-3"}),t.is_warning&&!t.is_due&&s.jsx(Kn,{className:"w-3 h-3"}),!t.is_due&&!t.is_warning&&t.enabled&&s.jsx(Ya,{className:"w-3 h-3"}),d()]})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s.jsx(Hn,{checked:t.enabled,onChange:f=>n(t.id,f)}),s.jsxs(we,{size:"sm",variant:t.is_due?"primary":"secondary",onClick:()=>e(t.id),disabled:!t.enabled,className:"!px-3",children:[s.jsx(Zf,{className:"w-3.5 h-3.5"}),"Reset"]})]})]})})}function FKe({overview:t,onPerform:e,onToggle:n,onSetHours:r}){const[i,a]=w.useState(!0),[o,l]=w.useState(!1),[c,u]=w.useState(t.total_print_hours.toFixed(1)),d=[...t.maintenance_items].sort((p,x)=>p.is_due&&!x.is_due?-1:!p.is_due&&x.is_due?1:p.is_warning&&!x.is_warning?-1:!p.is_warning&&x.is_warning?1:p.maintenance_type_id-x.maintenance_type_id),f=d.find(p=>p.enabled&&(p.is_due||p.is_warning)),m=()=>{const p=parseFloat(c);!isNaN(p)&&p>=0&&(r(t.printer_id,p),l(!1))};return s.jsxs(Nt,{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(yn,{className:"w-3 h-3"}),t.due_count," overdue"]}),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(Kn,{className:"w-3 h-3"}),t.warning_count," due soon"]}),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(Ya,{className:"w-3 h-3"}),"All good"]})]})]}),s.jsxs("button",{onClick:()=>a(!i),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:[i?s.jsx(su,{className:"w-4 h-4"}):s.jsx(Pi,{className:"w-4 h-4"}),i?"Collapse":"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(vd,{className:"w-4 h-4 text-bambu-gray"})}),o?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",value:c,onChange:p=>u(p.target.value),onKeyDown:p=>{p.key==="Enter"&&m(),p.key==="Escape"&&l(!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:"hours"}),s.jsx(we,{size:"sm",onClick:m,children:"Save"}),s.jsx(we,{size:"sm",variant:"secondary",onClick:()=>l(!1),children:"Cancel"})]}):s.jsxs("button",{onClick:()=>{u(Math.round(t.total_print_hours).toString()),l(!0)},className:"group",children:[s.jsxs("div",{className:"text-sm font-medium text-white group-hover:text-bambu-green transition-colors flex items-center gap-1",children:[Math.round(t.total_print_hours)," hours",s.jsx(kf,{className:"w-3 h-3 text-bambu-gray group-hover:text-bambu-green"})]}),s.jsx("div",{className:"text-xs text-bambu-gray",children:"Total print time"})]})]}),s.jsx("div",{className:"w-px h-10 bg-bambu-dark-tertiary"}),f&&s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:`p-2 rounded-lg ${f.is_due?"bg-red-500/20":"bg-amber-500/20"}`,children:(()=>{const p=o0(f.maintenance_type_icon);return s.jsx(p,{className:`w-4 h-4 ${f.is_due?"text-red-400":"text-amber-400"}`})})()}),s.jsxs("div",{children:[s.jsx("div",{className:`text-sm font-medium ${f.is_due?"text-red-400":"text-amber-400"}`,children:f.maintenance_type_name}),s.jsx("div",{className:`text-xs ${f.is_due?"text-red-400/70":"text-amber-400/70"}`,children:f.is_due?"Overdue":"Due soon"})]})]})]})]}),i&&s.jsx(Et,{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:d.map(p=>s.jsx(IKe,{item:p,onPerform:e,onToggle:n},p.id))})})]})}function UKe({overview:t,types:e,onUpdateInterval:n,onAddType:r,onUpdateType:i,onDeleteType:a,onAssignType:o,onRemoveItem:l}){const[c,u]=w.useState(null),[d,f]=w.useState(""),[m,p]=w.useState("hours"),[x,y]=w.useState(!1),[b,v]=w.useState(""),[N,S]=w.useState("100"),[T,E]=w.useState("hours"),[C,A]=w.useState("Wrench"),[O,k]=w.useState(""),[R,F]=w.useState(new Set),[L,K]=w.useState(null),j=w.useMemo(()=>t?t.map(U=>({id:U.printer_id,name:U.printer_name})):[],[t]),W=U=>t?t.filter(B=>B.maintenance_items.some(oe=>oe.maintenance_type_id===U)).map(B=>({printerId:B.printer_id,printerName:B.printer_name,itemId:B.maintenance_items.find(oe=>oe.maintenance_type_id===U)?.id})):[],Y=U=>{if(!t)return[];const B=new Set(W(U).map(oe=>oe.printerId));return j.filter(oe=>!B.has(oe.id))},[q,Q]=w.useState(null),[ee,re]=w.useState(""),[z,G]=w.useState(""),[ae,se]=w.useState("hours"),[ue,pe]=w.useState("Wrench"),[ce,Me]=w.useState(""),me=U=>{Q(U),re(U.name),G(U.default_interval_hours.toString()),se(U.interval_type||"hours"),pe(U.icon||"Wrench"),Me(U.wiki_url||"")},Ee=()=>{q&&ee.trim()&&parseFloat(z)>0&&(i(q.id,{name:ee.trim(),default_interval_hours:parseFloat(z),interval_type:ae,icon:ue,wiki_url:ce.trim()||null}),Q(null))},fe=(U,B,oe)=>{const Te=parseFloat(d);if(!isNaN(Te)&&Te>0){const je=Math.abs(Te-B)<.01?null:Te;n(U,{custom_interval_hours:je,custom_interval_type:m!==oe?m:null})}u(null)},le=U=>{U.preventDefault(),b.trim()&&parseFloat(N)>0&&R.size>0&&(r({name:b.trim(),default_interval_hours:parseFloat(N),interval_type:T,icon:C,wiki_url:O.trim()||null},Array.from(R)),v(""),S("100"),E("hours"),k(""),F(new Set),y(!1))},Be=U=>{F(B=>{const oe=new Set(B);return oe.has(U)?oe.delete(U):oe.add(U),oe})},V=t?.map(U=>({printerId:U.printer_id,printerName:U.printer_name,items:U.maintenance_items.sort((B,oe)=>B.maintenance_type_id-oe.maintenance_type_id)})).sort((U,B)=>U.printerName.localeCompare(B.printerName))||[],$=e.filter(U=>U.is_system),X=e.filter(U=>!U.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:"Maintenance Types"}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"System types and your custom maintenance tasks"})]}),s.jsxs(we,{onClick:()=>y(!x),children:[s.jsx(Jn,{className:"w-4 h-4"}),"Add Custom Type"]})]}),x&&s.jsx(Nt,{className:"mb-6",children:s.jsx(Et,{className:"py-4",children:s.jsxs("form",{onSubmit:le,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:"Name"}),s.jsx("input",{type:"text",value:b,onChange:U=>v(U.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:"e.g., Replace HEPA Filter",autoFocus:!0})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:"Interval Type"}),s.jsxs("select",{value:T,onChange:U=>{E(U.target.value),U.target.value==="days"?S("30"):S("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:"Print Hours"}),s.jsx("option",{value:"days",children:"Calendar Days"})]})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-xs text-bambu-gray mb-1.5",children:["Interval (",T==="days"?"days":"hours",")"]}),s.jsx("input",{type:"number",value:N,onChange:U=>S(U.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:"Icon"}),s.jsx("div",{className:"flex gap-1",children:Object.keys(Ib).map(U=>{const B=Ib[U];return s.jsx("button",{type:"button",onClick:()=>A(U),className:`p-2 rounded-lg transition-colors ${C===U?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:s.jsx(B,{className:"w-4 h-4"})},U)})})]})}),s.jsxs("div",{className:"mt-4",children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:"Documentation Link (optional)"}),s.jsx("input",{type:"url",value:O,onChange:U=>k(U.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:"Assign to Printers"}),s.jsx("div",{className:"flex flex-wrap gap-2",children:j.map(U=>s.jsx("button",{type:"button",onClick:()=>Be(U.id),className:`px-3 py-1.5 rounded-lg text-sm transition-colors ${R.has(U.id)?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:U.name},U.id))}),R.size===0&&s.jsx("p",{className:"text-xs text-orange-400 mt-1",children:"Select at least one printer"})]}),s.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[s.jsx(we,{type:"button",variant:"secondary",onClick:()=>{y(!1),F(new Set)},children:"Cancel"}),s.jsx(we,{type:"submit",disabled:!b.trim()||R.size===0,children:"Add Type"})]})]})})}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:[$.map(U=>{const B=o0(U.icon),oe=U.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(B,{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:U.name}),s.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5 flex items-center gap-1",children:[oe==="days"?s.jsx(ri,{className:"w-3 h-3"}):s.jsx(vd,{className:"w-3 h-3"}),Mj(U.default_interval_hours,oe)]})]})]})},U.id)}),X.map(U=>{const B=o0(U.icon),oe=U.interval_type||"hours";if(q?.id===U.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:ee,onChange:D=>re(D.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:"Name",autoFocus:!0}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("select",{value:ae,onChange:D=>se(D.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:"Print Hours"}),s.jsx("option",{value:"days",children:"Calendar Days"})]}),s.jsx("input",{type:"number",value:z,onChange:D=>G(D.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(Ib).map(D=>{const Z=Ib[D];return s.jsx("button",{type:"button",onClick:()=>pe(D),className:`p-1.5 rounded transition-colors ${ue===D?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:s.jsx(Z,{className:"w-3.5 h-3.5"})},D)})}),s.jsx("input",{type:"url",value:ce,onChange:D=>Me(D.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:"Documentation link (optional)"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(we,{size:"sm",onClick:Ee,disabled:!ee.trim(),children:"Save"}),s.jsx(we,{size:"sm",variant:"secondary",onClick:()=>Q(null),children:"Cancel"})]})]})},U.id);const je=W(U.id),Ce=Y(U.id),H=L===U.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(B,{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:U.name}),s.jsx("span",{className:"px-1.5 py-0.5 bg-bambu-green/20 text-bambu-green text-[10px] font-medium rounded",children:"Custom"})]}),s.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5 flex items-center gap-1",children:[oe==="days"?s.jsx(ri,{className:"w-3 h-3"}):s.jsx(vd,{className:"w-3 h-3"}),Mj(U.default_interval_hours,oe)]})]}),s.jsxs("button",{onClick:()=>K(H?null:U.id),className:`px-2 py-1 rounded-lg border transition-colors flex items-center gap-1 ${je.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:`${je.length} printer(s) assigned - click to manage`,children:[s.jsx(Mr,{className:"w-3 h-3"}),s.jsx("span",{className:"text-xs font-medium",children:je.length}),s.jsx(Pi,{className:`w-3 h-3 transition-transform ${H?"rotate-180":""}`})]}),s.jsx("button",{onClick:()=>me(U),className:"p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors",children:s.jsx(kf,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>{confirm(`Delete "${U.name}"?`)&&a(U.id)},className:"p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-red-400 transition-colors",children:s.jsx(un,{className:"w-4 h-4"})})]}),H&&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:"Assigned to printers:"}),je.length===0?s.jsx("p",{className:"text-xs text-orange-400",children:"No printers assigned"}):s.jsx("div",{className:"flex flex-wrap gap-1 mb-2",children:je.map(D=>s.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-dark rounded text-xs text-white",children:[D.printerName,s.jsx("button",{onClick:()=>D.itemId&&l(D.itemId),className:"hover:text-red-400 ml-1",title:"Remove from this printer",children:"×"})]},D.printerId))}),Ce.length>0&&s.jsxs("div",{className:"flex flex-wrap gap-1",children:[s.jsx("span",{className:"text-xs text-bambu-gray mr-1",children:"Add:"}),Ce.map(D=>s.jsxs("button",{onClick:()=>o(D.id,U.id),className:"px-2 py-1 bg-bambu-dark hover:bg-bambu-green/20 rounded text-xs text-bambu-gray hover:text-bambu-green transition-colors",children:["+ ",D.name]},D.id))]})]})]},U.id)})]})]}),V.length>0&&s.jsxs("div",{children:[s.jsxs("div",{className:"mb-4",children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Interval Overrides"}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Customize intervals for specific printers"})]}),s.jsx("div",{className:"space-y-4",children:V.map(U=>s.jsx(Nt,{children:s.jsxs(Et,{className:"py-4",children:[s.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:U.printerName}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-2",children:U.items.map(B=>{const oe=o0(B.maintenance_type_icon),Te=e.find(Z=>Z.id===B.maintenance_type_id),je=Te?.default_interval_hours||B.interval_hours,Ce=Te?.interval_type||"hours",H=B.interval_type||"hours",D=c===B.id;return s.jsxs("div",{className:"flex items-center gap-2 p-2.5 bg-bambu-dark rounded-lg",children:[s.jsx(oe,{className:"w-4 h-4 text-bambu-gray shrink-0"}),s.jsx("span",{className:"text-xs text-bambu-gray flex-1 truncate",children:B.maintenance_type_name}),D?s.jsxs("div",{className:"flex items-center gap-1",children:[m==="days"?s.jsx(ri,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"}):s.jsx(vd,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"}),s.jsxs("select",{value:m,onChange:Z=>p(Z.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:"Print Hours"}),s.jsx("option",{value:"days",children:"Calendar Days"})]}),s.jsx("input",{type:"number",value:d,onChange:Z=>f(Z.target.value),onKeyDown:Z=>{Z.key==="Enter"&&fe(B.id,je,Ce),Z.key==="Escape"&&u(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(we,{size:"sm",onClick:()=>fe(B.id,je,Ce),children:"OK"})]}):s.jsxs("button",{onClick:()=>{u(B.id),f(B.interval_hours.toString()),p(H)},className:"px-2 py-1 bg-bambu-dark-tertiary hover:bg-bambu-dark-secondary border border-bambu-dark-tertiary hover:border-bambu-green rounded text-xs font-medium text-white transition-colors flex items-center gap-1",children:[H==="days"?s.jsx(ri,{className:"w-3 h-3"}):s.jsx(vd,{className:"w-3 h-3"}),Mj(B.interval_hours,H),s.jsx(kf,{className:"w-3 h-3 text-bambu-gray"})]})]},B.id)})})]})},U.printerId))})]}),V.length===0&&s.jsx(Nt,{children:s.jsxs(Et,{className:"text-center py-12",children:[s.jsx(Kn,{className:"w-12 h-12 mx-auto mb-4 text-bambu-gray/30"}),s.jsx("p",{className:"text-bambu-gray",children:"No printers configured"}),s.jsx("p",{className:"text-sm text-bambu-gray/70 mt-1",children:"Add printers to configure maintenance intervals"})]})})]})}function zKe(){const t=on(),{showToast:e}=Vn(),[n,r]=w.useState("status"),{data:i,isLoading:a}=ut({queryKey:["maintenanceOverview"],queryFn:he.getMaintenanceOverview}),{data:o}=ut({queryKey:["maintenanceTypes"],queryFn:he.getMaintenanceTypes}),l=pt({mutationFn:({id:S,notes:T})=>he.performMaintenance(S,T),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),t.invalidateQueries({queryKey:["maintenanceSummary"]}),e("Maintenance marked as complete")},onError:S=>{e(S.message,"error")}}),c=pt({mutationFn:({id:S,data:T})=>he.updateMaintenanceItem(S,T),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]})},onError:S=>{e(S.message,"error")}}),u=pt({mutationFn:({id:S,data:T})=>he.updateMaintenanceType(S,T),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type updated")},onError:S=>{e(S.message,"error")}}),d=pt({mutationFn:he.deleteMaintenanceType,onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type deleted")},onError:S=>{e(S.message,"error")}}),f=pt({mutationFn:({printerId:S,hours:T})=>he.setPrinterHours(S,T),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),t.invalidateQueries({queryKey:["maintenanceSummary"]}),e("Print hours updated")},onError:S=>{e(S.message,"error")}}),m=pt({mutationFn:({printerId:S,typeId:T})=>he.assignMaintenanceType(S,T),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Printer assigned")},onError:S=>{e(S.message,"error")}}),p=pt({mutationFn:he.removeMaintenanceItem,onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Printer removed")},onError:S=>{e(S.message,"error")}}),x=S=>{l.mutate({id:S})},y=(S,T)=>{c.mutate({id:S,data:{enabled:T}})},b=(S,T)=>{f.mutate({printerId:S,hours:T})};if(a)return s.jsx("div",{className:"p-4 md:p-8 flex justify-center",children:s.jsx(dt,{className:"w-8 h-8 text-bambu-green animate-spin"})});const v=i?.reduce((S,T)=>S+T.due_count,0)||0,N=i?.reduce((S,T)=>S+T.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:"Maintenance"}),s.jsx("p",{className:"text-bambu-gray text-sm mt-1",children:n==="status"?s.jsxs(s.Fragment,{children:[v>0&&s.jsxs("span",{className:"text-red-400",children:[v," task",v!==1?"s":""," overdue"]}),v>0&&N>0&&" · ",N>0&&s.jsxs("span",{className:"text-amber-400",children:[N," due soon"]}),v===0&&N===0&&s.jsx("span",{className:"text-bambu-green",children:"All maintenance up to date"})]}):"Configure maintenance types and intervals"})]}),s.jsxs("div",{className:"flex gap-1 mb-6 border-b border-bambu-dark-tertiary",children:[s.jsx("button",{onClick:()=>r("status"),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${n==="status"?"text-bambu-green border-bambu-green":"text-bambu-gray border-transparent hover:text-white"}`,children:"Status"}),s.jsx("button",{onClick:()=>r("settings"),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${n==="settings"?"text-bambu-green border-bambu-green":"text-bambu-gray border-transparent hover:text-white"}`,children:"Settings"})]}),n==="status"?s.jsx("div",{className:"space-y-6",children:i&&i.length>0?[...i].sort((S,T)=>{const E=S.due_count*10+S.warning_count,C=T.due_count*10+T.warning_count;return E!==C?C-E:S.printer_name.localeCompare(T.printer_name)}).map(S=>s.jsx(FKe,{overview:S,onPerform:x,onToggle:y,onSetHours:b},S.printer_id)):s.jsx(Nt,{children:s.jsxs(Et,{className:"text-center py-16",children:[s.jsx($d,{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:"No printers configured"}),s.jsx("p",{className:"text-bambu-gray",children:"Add printers to start tracking maintenance"})]})})}):s.jsx(UKe,{overview:i,types:o||[],onUpdateInterval:(S,T)=>c.mutate({id:S,data:T}),onAddType:async(S,T)=>{const E=await he.createMaintenanceType(S);for(const C of T)await he.assignMaintenanceType(C,E.id);t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type added")},onUpdateType:(S,T)=>u.mutate({id:S,data:T}),onDeleteType:S=>d.mutate(S),onAssignType:(S,T)=>m.mutate({printerId:S,typeId:T}),onRemoveItem:S=>p.mutate(S)})]})}const tW=["#ef4444","#f97316","#eab308","#22c55e","#06b6d4","#3b82f6","#8b5cf6","#ec4899","#6b7280"];function Ere({project:t,onClose:e,onSave:n,isLoading:r}){const[i,a]=w.useState(t?.name||""),[o,l]=w.useState(t?.description||""),[c,u]=w.useState(t?.color||tW[0]),[d,f]=w.useState(t?.target_count?.toString()||""),[m,p]=w.useState(t?.target_parts_count?.toString()||""),[x,y]=w.useState(t?.status||"active"),[b,v]=w.useState(t?.tags||""),[N,S]=w.useState(t?.due_date?.split("T")[0]||""),[T,E]=w.useState(t?.priority||"normal"),C=A=>{A.preventDefault(),n({name:i.trim(),description:o.trim()||void 0,color:c,target_count:d?parseInt(d,10):void 0,target_parts_count:m?parseInt(m,10):void 0,tags:b.trim()||void 0,due_date:N||void 0,priority:T,...t&&{status:x}})};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:t?"Edit Project":"New Project"})}),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:"Name"}),s.jsx("input",{type:"text",value:i,onChange:A=>a(A.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:"e.g., Voron 2.4 Build",required:!0})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Description"}),s.jsx("textarea",{value:o,onChange:A=>l(A.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:"Optional description...",rows:2})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Color"}),s.jsx("div",{className:"flex gap-2 flex-wrap",children:tW.map(A=>s.jsx("button",{type:"button",onClick:()=>u(A),className:`w-8 h-8 rounded-full transition-transform ${c===A?"ring-2 ring-white ring-offset-2 ring-offset-bambu-dark-secondary scale-110":""}`,style:{backgroundColor:A}},A))})]}),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:"Target Plates"}),s.jsx("input",{type:"number",value:d,onChange:A=>f(A.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:"e.g., 25",min:"1"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Number of print jobs"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Target Parts"}),s.jsx("input",{type:"number",value:m,onChange:A=>p(A.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:"e.g., 150",min:"1"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Total objects needed"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Tags (comma-separated)"}),s.jsx("input",{type:"text",value:b,onChange:A=>v(A.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:"e.g., voron, functional, gift"})]}),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:"Due Date"}),s.jsx("input",{type:"date",value:N,onChange:A=>S(A.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:"Priority"}),s.jsxs("select",{value:T,onChange:A=>E(A.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:"Low"}),s.jsx("option",{value:"normal",children:"Normal"}),s.jsx("option",{value:"high",children:"High"}),s.jsx("option",{value:"urgent",children:"Urgent"})]})]})]}),t&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Status"}),s.jsxs("select",{value:x,onChange:A=>y(A.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:"Active"}),s.jsx("option",{value:"completed",children:"Completed"}),s.jsx("option",{value:"archived",children:"Archived"})]})]}),s.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[s.jsx(we,{type:"button",variant:"secondary",onClick:e,children:"Cancel"}),s.jsx(we,{type:"submit",disabled:!i.trim()||r,children:r?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):t?"Save":"Create"})]})]})]})})}function BKe({project:t,onClick:e,onEdit:n,onDelete:r}){const i=t.target_count?Math.round(t.archive_count/t.target_count*100):0,a=t.target_parts_count?Math.round(t.completed_count/t.target_parts_count*100):0,o=t.status==="completed",l=t.status==="archived",[c,u]=w.useState(!1),f=o?{icon:P2,color:"text-bambu-green",bg:"bg-bambu-green/10"}:l?{icon:Ka,color:"text-bambu-gray",bg:"bg-bambu-gray/10"}:t.queue_count>0?{icon:Kn,color:"text-blue-400",bg:"bg-blue-400/10"}:{icon:wa,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 ${f.bg} flex-shrink-0`,children:s.jsx(f.icon,{className:`w-5 h-5 ${f.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 ${a>=100?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark text-bambu-gray"}`,children:[t.completed_count,"/",t.target_parts_count," parts"]}):t.target_count?s.jsxs("span",{className:`text-xs px-2 py-0.5 rounded-full whitespace-nowrap font-medium ${i>=100?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark text-bambu-gray"}`,children:[t.archive_count,"/",t.target_count," 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," parts"]}):null,o&&s.jsx("span",{className:"text-xs bg-bambu-green/20 text-bambu-green px-2 py-0.5 rounded-full whitespace-nowrap",children:"Done"}),l&&s.jsx("span",{className:"text-xs bg-bambu-gray/20 text-bambu-gray px-2 py-0.5 rounded-full whitespace-nowrap",children:"Archived"})]}),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 m=t.archives.map(b=>b.filament_type).filter(Boolean).flatMap(b=>b.split(",").map(v=>v.trim())).filter(Boolean),p=[...new Set(m)],x=t.archives.map(b=>b.filament_color).filter(Boolean).flatMap(b=>b.split(",").map(v=>v.trim())).filter(b=>b.startsWith("#")||/^[0-9A-Fa-f]{6}$/.test(b)),y=[...new Set(x)];return p.length===0&&y.length===0?null:s.jsxs("div",{className:"flex items-center gap-2 mt-1.5",children:[p.slice(0,3).map(b=>s.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-bambu-dark text-bambu-gray rounded",children:b},b)),y.length>0&&s.jsxs("div",{className:"flex items-center gap-0.5",children:[y.slice(0,5).map(b=>s.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:b.startsWith("#")?b:`#${b}`},title:b},b)),y.length>5&&s.jsxs("span",{className:"text-[10px] text-bambu-gray ml-0.5",children:["+",y.length-5]})]})]})})()]})]}),s.jsxs("div",{className:"relative",onClick:m=>m.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:()=>u(!c),children:s.jsx(Cd,{className:"w-4 h-4"})}),c&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>u(!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 text-white hover:bg-bambu-dark flex items-center gap-2",onClick:()=>{n(),u(!1)},children:[s.jsx(kf,{className:"w-4 h-4"}),"Edit"]}),s.jsxs("button",{className:"w-full px-3 py-2 text-left text-sm text-red-400 hover:bg-bambu-dark flex items-center gap-2",onClick:()=>{r(),u(!1)},children:[s.jsx(un,{className:"w-4 h-4"}),"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:"Plates"}),s.jsxs("span",{className:i>=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(i,100)}%`,background:i>=100?"linear-gradient(90deg, #22c55e, #4ade80)":`linear-gradient(90deg, ${t.color||"#6b7280"}, ${t.color||"#6b7280"}cc)`,boxShadow:`0 0 8px ${i>=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:"Parts"}),s.jsxs("span",{className:a>=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(a,100)}%`,background:a>=100?"linear-gradient(90deg, #22c55e, #4ade80)":`linear-gradient(90deg, ${t.color||"#6b7280"}, ${t.color||"#6b7280"}cc)`,boxShadow:`0 0 8px ${a>=100?"#22c55e":t.color||"#6b7280"}60`}})})]}),t.failed_count>0&&s.jsxs("div",{className:"text-xs text-red-400",children:[t.failed_count," 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(Ka,{className:"w-3.5 h-3.5"}),s.jsxs("span",{children:[t.completed_count," completed"]})]}),t.failed_count>0&&s.jsxs("div",{className:"flex items-center gap-1.5 text-red-400",children:[s.jsx(yn,{className:"w-3.5 h-3.5"}),s.jsxs("span",{children:[t.failed_count," failed"]})]}),t.queue_count>0&&s.jsxs("div",{className:"flex items-center gap-1.5 text-blue-400",children:[s.jsx(Kn,{className:"w-3.5 h-3.5"}),s.jsxs("span",{children:[t.queue_count," in queue"]})]})]}):s.jsx("div",{className:"text-xs text-bambu-gray/60 italic",children:"No prints yet"})}),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(m=>s.jsxs("div",{className:"relative aspect-square rounded-lg bg-bambu-dark overflow-hidden border border-bambu-dark-tertiary",title:m.print_name||"Unknown",children:[m.thumbnail_path?s.jsx("img",{src:he.getArchiveThumbnail(m.id),alt:m.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(zl,{className:"w-6 h-6"})}),m.status==="failed"&&s.jsx("div",{className:"absolute inset-0 bg-red-500/40 flex items-center justify-center",children:s.jsx(yn,{className:"w-4 h-4 text-white"})})]},m.id))}),t.archive_count>4&&s.jsxs("p",{className:"text-xs text-bambu-gray mt-1.5 text-center",children:["+",t.archive_count-4," more"]})]}),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:"Print jobs (plates)",children:[s.jsx(cl,{className:"w-3.5 h-3.5 text-blue-400"}),s.jsxs("span",{children:[t.archive_count," plates"]})]}),s.jsxs("div",{className:"flex items-center gap-1.5",title:"Parts printed",children:[s.jsx(zl,{className:"w-3.5 h-3.5 text-bambu-green"}),s.jsxs("span",{children:[t.completed_count," parts"]})]}),t.failed_count>0&&s.jsxs("div",{className:"flex items-center gap-1.5 text-red-400",title:"Failed parts",children:[s.jsx(yn,{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:"In queue",children:[s.jsx(Kj,{className:"w-3.5 h-3.5"}),s.jsx("span",{children:t.queue_count})]})]}),s.jsx(Ys,{className:"w-4 h-4 text-bambu-gray/50 group-hover:text-bambu-gray transition-colors"})]})]})]})}function $Ke(){const t=hl(),e=on(),{showToast:n}=Vn(),[r,i]=w.useState(!1),[a,o]=w.useState(),[l,c]=w.useState("active"),[u,d]=w.useState(null),{data:f,isLoading:m}=ut({queryKey:["projects",l==="all"?void 0:l],queryFn:()=>he.getProjects(l==="all"?void 0:l)}),p=pt({mutationFn:F=>he.createProject(F),onSuccess:()=>{e.invalidateQueries({queryKey:["projects"]}),i(!1),n("Project created","success")},onError:F=>{n(F.message,"error")}}),x=pt({mutationFn:({id:F,data:L})=>he.updateProject(F,L),onSuccess:()=>{e.invalidateQueries({queryKey:["projects"]}),i(!1),o(void 0),n("Project updated","success")},onError:F=>{n(F.message,"error")}}),y=pt({mutationFn:F=>he.deleteProject(F),onSuccess:()=>{d(null),n("Project deleted","success"),setTimeout(()=>window.location.reload(),100)},onError:F=>{d(null),n(F.message,"error")}}),b=pt({mutationFn:F=>he.importProject(F),onSuccess:()=>{e.invalidateQueries({queryKey:["projects"]}),n("Project imported","success")},onError:F=>{n(F.message,"error")}}),v=w.useRef(null),N=async()=>{try{const F=await he.getProjects(),L=await Promise.all(F.map(async Y=>await he.exportProjectJson(Y.id))),K=new Blob([JSON.stringify(L,null,2)],{type:"application/json"}),j=URL.createObjectURL(K),W=document.createElement("a");W.href=j,W.download=`bambuddy_projects_${new Date().toISOString().split("T")[0]}.json`,W.click(),URL.revokeObjectURL(j),n("Projects exported (metadata only)","success")}catch(F){n(F.message,"error")}},S=()=>{v.current?.click()},T=async F=>{const L=F.target.files?.[0];if(L){try{if(L.name.toLowerCase().endsWith(".zip")){const j=new FormData;j.append("file",L);const W=await fetch("/api/v1/projects/import/file",{method:"POST",body:j});if(!W.ok){const Y=await W.json();throw new Error(Y.detail||"Import failed")}e.invalidateQueries({queryKey:["projects"]}),n("Project imported","success")}else{const j=await L.text(),W=JSON.parse(j),Y=Array.isArray(W)?W:[W];for(const q of Y)await b.mutateAsync(q);Y.length>1&&n(`${Y.length} projects imported`,"success")}}catch(K){n(`Import failed: ${K.message}`,"error")}F.target.value=""}},E=F=>{a?x.mutate({id:a.id,data:F}):p.mutate(F)},C=F=>{o(F),i(!0)},A=F=>{t(`/projects/${F.id}`)},O=F=>{d(F)},k=()=>{u!==null&&y.mutate(u)},R=f?.reduce((F,L)=>(F[L.status]=(F[L.status]||0)+1,F.all=(F.all||0)+1,F),{})||{};return s.jsxs("div",{className:"p-4 md:p-8 space-y-8",children:[s.jsx("input",{ref:v,type:"file",accept:".json,.zip",onChange:T,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(wa,{className:"w-6 h-6 text-bambu-green"})}),"Projects"]}),s.jsx("p",{className:"text-sm text-bambu-gray mt-2 ml-14",children:"Organize and track your 3D printing projects"})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(we,{variant:"secondary",onClick:S,title:"Import project",children:[s.jsx(di,{className:"w-4 h-4 mr-2"}),"Import"]}),s.jsxs(we,{variant:"secondary",onClick:N,title:"Export all projects",children:[s.jsx($r,{className:"w-4 h-4 mr-2"}),"Export"]}),s.jsxs(we,{onClick:()=>i(!0),className:"sm:w-auto w-full",children:[s.jsx(Jn,{className:"w-4 h-4 mr-2"}),"New Project"]})]})]}),s.jsx("div",{className:"flex gap-1 p-1 bg-bambu-dark rounded-xl w-fit",children:[{key:"active",label:"Active",icon:Kn},{key:"completed",label:"Completed",icon:P2},{key:"archived",label:"Archived",icon:Ka},{key:"all",label:"All",icon:wa}].map(({key:F,label:L,icon:K})=>s.jsxs("button",{onClick:()=>c(F),className:`flex items-center gap-2 px-4 py-2 text-sm rounded-lg transition-all ${l===F?"bg-bambu-card text-white shadow-sm":"text-bambu-gray hover:text-white"}`,children:[s.jsx(K,{className:"w-4 h-4"}),s.jsx("span",{children:L}),R[F]>0&&s.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded-full ${l===F?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark-tertiary"}`,children:R[F]})]},F))}),m?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(dt,{className:"w-8 h-8 animate-spin text-bambu-green"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Loading projects..."})]})}):f?.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(wa,{className:"w-12 h-12 text-bambu-gray/50"})}),s.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:l==="all"?"No projects yet":`No ${l} projects`}),s.jsx("p",{className:"text-bambu-gray text-center max-w-md mb-6",children:l==="all"?"Create your first project to start organizing related prints, tracking progress, and managing your builds.":`You don't have any ${l} projects. Projects will appear here when their status changes.`}),l==="all"&&s.jsxs(we,{onClick:()=>i(!0),children:[s.jsx(Jn,{className:"w-4 h-4 mr-2"}),"Create Your First Project"]})]}):s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-8",children:f?.map(F=>s.jsx(BKe,{project:F,onClick:()=>A(F),onEdit:()=>C(F),onDelete:()=>O(F.id)},F.id))}),u!==null&&s.jsx(Bn,{title:"Delete Project",message:"Are you sure you want to delete this project? Archives and queue items will be unlinked but not deleted.",confirmText:"Delete Project",variant:"danger",onConfirm:k,onCancel:()=>d(null)}),r&&s.jsx(Ere,{project:a,onClose:()=>{i(!1),o(void 0)},onSave:E,isLoading:p.isPending||x.isPending})]})}function HKe(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 VKe(t){return t>=1e3?`${(t/1e3).toFixed(2)}kg`:`${Math.round(t)}g`}function GKe({status:t}){const e={active:"bg-bambu-green/20 text-bambu-green",completed:"bg-blue-500/20 text-blue-400",archived:"bg-bambu-gray/20 text-bambu-gray"},n=e[t]||e.active;return s.jsx("span",{className:`px-2 py-1 rounded text-sm font-medium ${n}`,children:t.charAt(0).toUpperCase()+t.slice(1)})}function nW({icon:t,label:e,value:n,subValue:r,hint:i,color:a="text-bambu-gray"}){return s.jsx(Nt,{children:s.jsx(Et,{className:"p-4",children:s.jsxs("div",{className:"flex items-center gap-3",title:i,children:[s.jsx("div",{className:`p-2 rounded-lg bg-bambu-dark ${a}`,children:s.jsx(t,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:e}),s.jsx("p",{className:"text-xl font-semibold text-white",children:n}),r&&s.jsx("p",{className:"text-xs text-bambu-gray/70",children:r})]})]})})})}function WKe({archives:t}){return t.length===0?s.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[s.jsx(zl,{className:"w-12 h-12 mx-auto mb-2 opacity-50"}),s.jsx("p",{children:"No prints in this project yet"})]}):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(e=>s.jsxs(fs,{to:`/archives?search=${encodeURIComponent(e.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:[e.thumbnail_path?s.jsx("img",{src:he.getArchiveThumbnail(e.id),alt:e.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(zl,{className:"w-8 h-8"})}),e.status==="failed"&&s.jsx("div",{className:"absolute inset-0 bg-red-500/30 flex items-center justify-center",children:s.jsx(ta,{className:"w-8 h-8 text-white"})}),e.status==="completed"&&s.jsx("div",{className:"absolute top-1 right-1",children:s.jsx(Fn,{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:e.print_name||"Unknown"})})]},e.id))})}function qKe({priority:t}){const e={low:{color:"bg-gray-500/20 text-gray-400",label:"Low"},normal:{color:"bg-blue-500/20 text-blue-400",label:"Normal"},high:{color:"bg-orange-500/20 text-orange-400",label:"High"},urgent:{color:"bg-red-500/20 text-red-400",label:"Urgent"}},{color:n,label:r}=e[t]||e.normal;return s.jsxs("span",{className:`px-2 py-1 rounded text-xs font-medium flex items-center gap-1 ${n}`,children:[t==="urgent"&&s.jsx(yn,{className:"w-3 h-3"}),r]})}function KKe(t){return t?sg(t,{year:"numeric",month:"short",day:"numeric"}):""}function Ej(t){if(!t)return null;const e=vi(t);if(!e)return null;const n=new Date,r=Math.ceil((e.getTime()-n.getTime())/(1e3*60*60*24));return r<0?{color:"text-red-400",label:"Overdue"}:r===0?{color:"text-orange-400",label:"Due today"}:r<=3?{color:"text-yellow-400",label:`${r} days left`}:{color:"text-bambu-gray",label:`${r} days left`}}function XKe(){const{id:t}=ZR(),e=hl(),n=on(),{showToast:r}=Vn(),[i,a]=w.useState(!1),[o,l]=w.useState(!1),[c,u]=w.useState(""),d=parseInt(t||"0",10),{data:f,isLoading:m,error:p}=ut({queryKey:["project",d],queryFn:()=>he.getProject(d),enabled:d>0}),{data:x,isLoading:y}=ut({queryKey:["project-archives",d],queryFn:()=>he.getProjectArchives(d),enabled:d>0}),{data:b,isLoading:v}=ut({queryKey:["project-bom",d],queryFn:()=>he.getProjectBOM(d),enabled:d>0}),{data:N,isLoading:S}=ut({queryKey:["project-timeline",d],queryFn:()=>he.getProjectTimeline(d,20),enabled:d>0}),{data:T}=ut({queryKey:["settings"],queryFn:he.getSettings}),{data:E}=ut({queryKey:["project-folders",d],queryFn:()=>he.getLibraryFoldersByProject(d),enabled:d>0}),C=T?.currency||"$",A=T?.time_format||"system",O=pt({mutationFn:te=>he.updateProject(d,te),onSuccess:()=>{n.invalidateQueries({queryKey:["project",d]}),n.invalidateQueries({queryKey:["projects"]}),a(!1),l(!1),r("Project updated","success")},onError:te=>{r(te.message,"error")}}),k=()=>{u(f?.notes||""),l(!0)},R=()=>{O.mutate({notes:c})},F=()=>{l(!1),u("")},[L,K]=w.useState(""),[j,W]=w.useState(1),[Y,q]=w.useState(""),[Q,ee]=w.useState(""),[re,z]=w.useState(""),[G,ae]=w.useState(!1),[se,ue]=w.useState(!1),[pe,ce]=w.useState(null),[Me,me]=w.useState(""),[Ee,fe]=w.useState(1),[le,Be]=w.useState(""),[V,$]=w.useState(""),[X,U]=w.useState(""),[B,oe]=w.useState({isOpen:!1,title:"",message:"",onConfirm:()=>{}}),Te=pt({mutationFn:te=>he.createBOMItem(d,te),onSuccess:()=>{n.invalidateQueries({queryKey:["project-bom",d]}),n.invalidateQueries({queryKey:["project",d]}),K(""),W(1),q(""),ee(""),z(""),ae(!1),r("Part added","success")},onError:te=>r(te.message,"error")}),je=pt({mutationFn:({itemId:te,data:Se})=>he.updateBOMItem(d,te,Se),onSuccess:()=>{n.invalidateQueries({queryKey:["project-bom",d]}),n.invalidateQueries({queryKey:["project",d]}),ce(null)},onError:te=>r(te.message,"error")}),Ce=pt({mutationFn:te=>he.deleteBOMItem(d,te),onSuccess:()=>{n.invalidateQueries({queryKey:["project-bom",d]}),n.invalidateQueries({queryKey:["project",d]}),r("Part removed","success")},onError:te=>r(te.message,"error")}),H=te=>{te.preventDefault(),L.trim()&&Te.mutate({name:L.trim(),quantity_needed:j,unit_price:Y?parseFloat(Y):void 0,sourcing_url:Q.trim()||void 0,remarks:re.trim()||void 0})},D=te=>{const Se=te.is_complete?0:te.quantity_needed;je.mutate({itemId:te.id,data:{quantity_acquired:Se}})},Z=(te,Se)=>{oe({isOpen:!0,title:"Delete Part",message:`Are you sure you want to delete "${Se}"?`,onConfirm:()=>{oe(ze=>({...ze,isOpen:!1})),Ce.mutate(te)}})},xe=te=>{ce(te),me(te.name),fe(te.quantity_needed),Be(te.unit_price?.toString()||""),$(te.sourcing_url||""),U(te.remarks||"")},Ne=te=>{te.preventDefault(),!(!pe||!Me.trim())&&je.mutate({itemId:pe.id,data:{name:Me.trim(),quantity_needed:Ee,unit_price:le?parseFloat(le):void 0,sourcing_url:V.trim()||void 0,remarks:X.trim()||void 0}})},ve=()=>{ce(null)},$e=async()=>{try{const te=await fetch(`/api/v1/projects/${d}/export`);if(!te.ok)throw new Error("Export failed");const Se=await te.blob(),ze=URL.createObjectURL(Se),nt=document.createElement("a");nt.href=ze;const Pe=te.headers.get("Content-Disposition")?.match(/filename="(.+)"/);nt.download=Pe?.[1]||`${f?.name||"project"}_${new Date().toISOString().split("T")[0]}.zip`,nt.click(),URL.revokeObjectURL(ze),r("Project exported","success")}catch(te){r(te.message,"error")}},Le=pt({mutationFn:()=>he.createTemplateFromProject(d),onSuccess:()=>{n.invalidateQueries({queryKey:["projects"]}),r("Template created","success")},onError:te=>r(te.message,"error")}),qe=te=>og(te,A,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});if(m)return s.jsx("div",{className:"flex items-center justify-center py-24",children:s.jsx(dt,{className:"w-8 h-8 animate-spin text-bambu-green"})});if(p||!f)return s.jsxs("div",{className:"text-center py-24",children:[s.jsx("p",{className:"text-bambu-gray",children:p?`Error: ${p.message}`:"Project not found"}),s.jsx(we,{variant:"secondary",className:"mt-4",onClick:()=>e("/projects"),children:"Back to Projects"})]});const Ke=f.stats,Ye=Ke?.progress_percent??0,ie=Ke?.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(fs,{to:"/projects",className:"hover:text-white transition-colors",children:"Projects"}),s.jsx(Ys,{className:"w-4 h-4"}),s.jsx("span",{className:"text-white",children:f.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(JW,{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:f.color||"#6b7280"}}),s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold text-white",children:f.name}),f.description&&s.jsx("p",{className:"text-bambu-gray mt-1",children:f.description})]})]}),s.jsx(GKe,{status:f.status})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(we,{variant:"secondary",onClick:$e,title:"Export project",children:[s.jsx($r,{className:"w-4 h-4 mr-2"}),"Export"]}),s.jsxs(we,{onClick:()=>a(!0),children:[s.jsx(kf,{className:"w-4 h-4 mr-2"}),"Edit"]})]})]}),(f.target_count||f.target_parts_count)&&s.jsx(Nt,{children:s.jsxs(Et,{className:"p-4 space-y-4",children:[f.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:"Plates Progress"}),s.jsxs("span",{className:"text-sm font-medium text-white",children:[Ke?.total_archives||0," / ",f.target_count," print jobs"]})]}),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(Ye,100)}%`,backgroundColor:Ye>=100?"#22c55e":f.color||"#6b7280"}})}),s.jsxs("div",{className:"flex justify-between mt-1",children:[s.jsxs("span",{className:"text-xs text-bambu-gray/70",children:[Ye.toFixed(0),"% complete"]}),Ke?.remaining_prints!=null&&Ke.remaining_prints>0&&s.jsxs("span",{className:"text-xs text-bambu-gray/70",children:[Ke.remaining_prints," remaining"]})]})]}),f.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:"Parts Progress"}),s.jsxs("span",{className:"text-sm font-medium text-white",children:[Ke?.completed_prints||0," / ",f.target_parts_count," 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(ie,100)}%`,backgroundColor:ie>=100?"#22c55e":f.color||"#6b7280"}})}),s.jsxs("div",{className:"flex justify-between mt-1",children:[s.jsxs("span",{className:"text-xs text-bambu-gray/70",children:[ie.toFixed(0),"% complete"]}),Ke?.remaining_parts!=null&&Ke.remaining_parts>0&&s.jsxs("span",{className:"text-xs text-bambu-gray/70",children:[Ke.remaining_parts," remaining"]})]})]})]})}),Ke&&s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[s.jsx(Nt,{children:s.jsx(Et,{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(zl,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Print Jobs"}),s.jsxs("p",{className:"text-xl font-semibold text-white",children:[Ke.total_archives," ",s.jsx("span",{className:"text-sm font-normal text-bambu-gray",children:"total"})]}),Ke.failed_prints>0&&s.jsxs("p",{className:"text-sm text-status-error",children:[Ke.failed_prints," failed"]}),s.jsxs("p",{className:"text-sm text-bambu-gray",children:[Ke.completed_prints," parts printed"]})]})]})})}),s.jsx(nW,{icon:Kn,label:"Print Time",value:HKe(Ke.total_print_time_hours),color:"text-yellow-400"}),s.jsx(nW,{icon:Mr,label:"Filament Used",value:VKe(Ke.total_filament_grams),color:"text-purple-400"})]}),Ke&&(Ke.estimated_cost>0||f.budget)&&s.jsx(Nt,{children:s.jsxs(Et,{className:"p-4",children:[s.jsx("h2",{className:"text-lg font-semibold text-white mb-3",children:"Cost Tracking"}),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:"Filament Cost"}),s.jsxs("p",{className:"text-lg font-semibold text-white",children:[C,Ke.estimated_cost.toFixed(2)]})]}),Ke.total_energy_kwh>0&&s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:"Energy"}),s.jsxs("p",{className:"text-lg font-semibold text-white",children:[Ke.total_energy_kwh.toFixed(2)," kWh",Ke.total_energy_cost>0&&s.jsxs("span",{className:"text-sm text-bambu-gray ml-1",children:["(",C,Ke.total_energy_cost.toFixed(2),")"]})]})]}),f.budget&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:"Budget"}),s.jsxs("p",{className:"text-lg font-semibold text-white",children:[C,f.budget.toFixed(2)]})]}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:"Remaining"}),s.jsxs("p",{className:`text-lg font-semibold ${f.budget-Ke.estimated_cost>=0?"text-bambu-green":"text-red-400"}`,children:[C,(f.budget-Ke.estimated_cost).toFixed(2)]})]})]})]})]})}),f.children&&f.children.length>0&&s.jsx(Nt,{children:s.jsxs(Et,{className:"p-4",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2 mb-3",children:[s.jsx(Iue,{className:"w-5 h-5"}),"Sub-projects (",f.children.length,")"]}),s.jsx("div",{className:"space-y-2",children:f.children.map(te=>s.jsxs(fs,{to:`/projects/${te.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:te.color||"#6b7280"}}),s.jsx("span",{className:"text-white",children:te.name}),s.jsx("span",{className:`text-xs px-2 py-0.5 rounded ${te.status==="completed"?"bg-status-ok/20 text-status-ok":te.status==="archived"?"bg-bambu-gray/20 text-bambu-gray":"bg-blue-500/20 text-blue-400"}`,children:te.status})]}),te.progress_percent!==null&&s.jsxs("span",{className:"text-sm text-bambu-gray",children:[te.progress_percent.toFixed(0),"%"]})]},te.id))})]})}),f.parent_id&&f.parent_name&&s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx(cl,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("span",{className:"text-bambu-gray",children:"Part of:"}),s.jsx(fs,{to:`/projects/${f.parent_id}`,className:"text-bambu-green hover:underline",children:f.parent_name})]}),(f.tags||f.due_date||f.priority!=="normal")&&s.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[f.priority&&f.priority!=="normal"&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-xs text-bambu-gray uppercase",children:"Priority:"}),s.jsx(qKe,{priority:f.priority})]}),f.due_date&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ri,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("span",{className:"text-sm text-white",children:KKe(f.due_date)}),Ej(f.due_date)&&s.jsxs("span",{className:`text-xs ${Ej(f.due_date).color}`,children:["(",Ej(f.due_date).label,")"]})]}),f.tags&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ag,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("div",{className:"flex flex-wrap gap-1",children:f.tags.split(",").map((te,Se)=>s.jsx("span",{className:"px-2 py-0.5 bg-bambu-dark-tertiary text-bambu-gray text-xs rounded",children:te.trim()},Se))})]})]}),s.jsx(Nt,{children:s.jsxs(Et,{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(Ga,{className:"w-5 h-5"}),"Notes"]}),o?s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(we,{variant:"secondary",size:"sm",onClick:F,disabled:O.isPending,children:[s.jsx(zt,{className:"w-4 h-4 mr-1"}),"Cancel"]}),s.jsxs(we,{size:"sm",onClick:R,disabled:O.isPending,children:[O.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin mr-1"}):s.jsx(gs,{className:"w-4 h-4 mr-1"}),"Save"]})]}):s.jsxs(we,{variant:"secondary",size:"sm",onClick:k,children:[s.jsx(kf,{className:"w-4 h-4 mr-1"}),"Edit"]})]}),o?s.jsx(UR,{content:c,onChange:u,placeholder:"Add notes about this project..."}):f.notes?s.jsx("div",{className:"prose prose-invert prose-sm max-w-none",dangerouslySetInnerHTML:{__html:f.notes}}):s.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:"No notes yet. Click Edit to add notes."})]})}),s.jsx(Nt,{children:s.jsxs(Et,{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(ll,{className:"w-5 h-5"}),"Files"]})}),s.jsxs("p",{className:"text-xs text-bambu-gray mb-3",children:[s.jsx(fs,{to:"/files",className:"text-bambu-green hover:underline",children:"Link folders from the File Manager"})," ","to this project for quick access."]}),E&&E.length>0?s.jsx("div",{className:"space-y-2",children:E.map(te=>s.jsxs(fs,{to:`/files?folder=${te.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(ll,{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:te.name}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[te.file_count," file",te.file_count!==1?"s":""]})]})]}),s.jsx(Ys,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"})]},te.id))}):s.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:"No folders linked. Go to File Manager and link a folder to this project."})]})}),s.jsx(Nt,{children:s.jsxs(Et,{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(dq,{className:"w-5 h-5"}),"Bill of Materials",Ke&&Ke.bom_total_items>0&&s.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",Ke.bom_completed_items,"/",Ke.bom_total_items," acquired)"]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[b&&b.some(te=>te.is_complete)&&s.jsx("button",{onClick:()=>ue(!se),className:`text-xs px-2 py-1 rounded transition-colors ${se?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:se?"Show all":"Hide done"}),!G&&s.jsxs(we,{variant:"secondary",size:"sm",onClick:()=>ae(!0),children:[s.jsx(Jn,{className:"w-4 h-4 mr-1"}),"Add Part"]})]})]}),G&&s.jsxs("form",{onSubmit:H,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:L,onChange:te=>K(te.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:"Part name (e.g., M3x8 screws)",autoFocus:!0}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{type:"number",value:j,onChange:te=>W(parseInt(te.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:"Qty"}),s.jsx("input",{type:"number",step:"0.01",value:Y,onChange:te=>q(te.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:`Price (${C})`})]})]}),s.jsx("input",{type:"url",value:Q,onChange:te=>ee(te.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:"Sourcing URL (optional)"}),s.jsx("input",{type:"text",value:re,onChange:te=>z(te.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:"Remarks (optional)"}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(we,{type:"button",variant:"secondary",size:"sm",onClick:()=>ae(!1),children:"Cancel"}),s.jsx(we,{type:"submit",size:"sm",disabled:!L.trim()||Te.isPending,children:Te.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):"Add Part"})]})]}),v?s.jsx("div",{className:"flex items-center justify-center py-4",children:s.jsx(dt,{className:"w-6 h-6 animate-spin text-bambu-green"})}):b&&b.length>0?s.jsxs("div",{className:"space-y-2",children:[b.filter(te=>!se||!te.is_complete).map(te=>s.jsx("div",{className:`p-3 rounded-lg transition-colors ${te.is_complete?"bg-status-ok/10":"bg-bambu-dark"}`,children:pe?.id===te.id?s.jsxs("form",{onSubmit:Ne,className:"space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[s.jsx("input",{type:"text",value:Me,onChange:Se=>me(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:"Part name",autoFocus:!0}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{type:"number",value:Ee,onChange:Se=>fe(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:"Qty"}),s.jsx("input",{type:"number",step:"0.01",value:le,onChange:Se=>Be(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:`Price (${C})`})]})]}),s.jsx("input",{type:"url",value:V,onChange:Se=>$(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:"Sourcing URL (optional)"}),s.jsx("input",{type:"text",value:X,onChange:Se=>U(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:"Remarks (optional)"}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(we,{type:"button",variant:"secondary",size:"sm",onClick:ve,children:"Cancel"}),s.jsx(we,{type:"submit",size:"sm",disabled:!Me.trim()||je.isPending,children:je.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):"Save"})]})]}):s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("button",{onClick:()=>D(te),disabled:je.isPending,className:`w-5 h-5 mt-0.5 rounded border-2 flex items-center justify-center transition-colors flex-shrink-0 ${te.is_complete?"bg-status-ok border-status-ok text-white":"border-bambu-gray hover:border-bambu-green"}`,children:te.is_complete&&s.jsx(Fn,{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 ${te.is_complete?"text-bambu-gray line-through":"text-white"}`,children:[te.name,s.jsxs("span",{className:"text-bambu-gray font-normal ml-2",children:["x",te.quantity_needed]})]}),te.unit_price!==null&&s.jsxs("span",{className:"text-xs text-bambu-green whitespace-nowrap",children:[C,(te.unit_price*te.quantity_needed).toFixed(2)]})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("button",{onClick:()=>xe(te),className:"p-1 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white transition-colors flex-shrink-0",title:"Edit",children:s.jsx(ia,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>Z(te.id,te.name),className:"p-1 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-red-400 transition-colors flex-shrink-0",title:"Delete",children:s.jsx(un,{className:"w-4 h-4"})})]})]}),te.sourcing_url&&s.jsxs("a",{href:te.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:Se=>Se.stopPropagation(),children:[s.jsx(Ur,{className:"w-3 h-3 flex-shrink-0"}),s.jsx("span",{className:"truncate",children:(()=>{try{return new URL(te.sourcing_url).hostname.replace("www.","")}catch{return te.sourcing_url}})()})]}),te.remarks&&s.jsx("p",{className:"mt-1 text-xs text-bambu-gray/80 italic",children:te.remarks})]})]})},te.id)),b.some(te=>te.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:"Total cost:"}),s.jsxs("span",{className:"text-white font-medium",children:[C,b.reduce((te,Se)=>te+(Se.unit_price||0)*Se.quantity_needed,0).toFixed(2)]})]})]}):s.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:"No parts in the bill of materials. Add hardware, electronics, or other components to track what needs to be sourced."})]})}),s.jsx(Nt,{children:s.jsxs(Et,{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(f0,{className:"w-5 h-5"}),"Activity Timeline"]})}),S?s.jsx("div",{className:"flex items-center justify-center py-4",children:s.jsx(dt,{className:"w-6 h-6 animate-spin text-bambu-green"})}):N&&N.length>0?s.jsx("div",{className:"space-y-3",children:N.slice(0,10).map((te,Se)=>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 ${te.event_type==="print_completed"?"bg-status-ok/20 text-status-ok":te.event_type==="print_failed"?"bg-status-error/20 text-status-error":te.event_type==="print_started"?"bg-yellow-500/20 text-yellow-400":"bg-bambu-dark-tertiary text-bambu-gray"}`,children:[te.event_type==="print_completed"&&s.jsx(Fn,{className:"w-4 h-4"}),te.event_type==="print_failed"&&s.jsx(ta,{className:"w-4 h-4"}),te.event_type==="print_started"&&s.jsx(Mr,{className:"w-4 h-4"}),te.event_type==="queued"&&s.jsx(Kj,{className:"w-4 h-4"}),te.event_type==="project_created"&&s.jsx(Jn,{className:"w-4 h-4"})]}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-sm text-white",children:te.title}),te.description&&s.jsx("p",{className:"text-xs text-bambu-gray truncate",children:te.description}),s.jsx("p",{className:"text-xs text-bambu-gray/70",children:qe(te.timestamp)})]})]},Se))}):s.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:"No activity yet."})]})}),!f.is_template&&s.jsx("div",{className:"flex justify-end",children:s.jsxs(we,{variant:"secondary",size:"sm",onClick:()=>Le.mutate(),disabled:Le.isPending,children:[Le.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin mr-2"}):s.jsx(ol,{className:"w-4 h-4 mr-2"}),"Save as Template"]})}),Ke&&(Ke.queued_prints>0||Ke.in_progress_prints>0)&&s.jsx(Nt,{children:s.jsxs(Et,{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(Kj,{className:"w-5 h-5"}),"Queue"]}),s.jsx(fs,{to:`/queue?project=${d}`,className:"text-sm text-bambu-green hover:underline",children:"View all"})]}),s.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[Ke.in_progress_prints>0&&s.jsxs("span",{className:"text-yellow-400",children:[Ke.in_progress_prints," printing"]}),Ke.queued_prints>0&&s.jsxs("span",{className:"text-bambu-gray",children:[Ke.queued_prints," queued"]})]})]})}),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(zl,{className:"w-5 h-5"}),"Prints (",x?.length||0,")"]})}),y?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx(dt,{className:"w-6 h-6 animate-spin text-bambu-green"})}):s.jsx(WKe,{archives:x||[]})]}),i&&s.jsx(Ere,{project:{...f,archive_count:Ke?.total_archives||0,total_items:Ke?.total_items||0,completed_count:Ke?.completed_prints||0,failed_count:Ke?.failed_prints||0,queue_count:Ke?.queued_prints||0,progress_percent:Ke?.progress_percent||null,archives:[]},onClose:()=>a(!1),onSave:te=>O.mutate(te),isLoading:O.isPending}),B.isOpen&&s.jsx(Bn,{title:B.title,message:B.message,confirmText:"Delete",variant:"danger",onConfirm:B.onConfirm,onCancel:()=>oe(te=>({...te,isOpen:!1}))})]})}function Op(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 YKe(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 QKe({parentId:t,onClose:e,onSave:n,isLoading:r}){const[i,a]=w.useState(""),o=l=>{l.preventDefault(),n({name:i.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:"New Folder"})}),s.jsxs("form",{onSubmit:o,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:"Folder Name"}),s.jsx("input",{type:"text",value:i,onChange:l=>a(l.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:"e.g., Functional Parts",autoFocus:!0,required:!0})]}),s.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[s.jsx(we,{type:"button",variant:"secondary",onClick:e,children:"Cancel"}),s.jsx(we,{type:"submit",disabled:!i.trim()||r,children:r?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):"Create"})]})]})]})})}function ZKe({type:t,currentName:e,onClose:n,onSave:r,isLoading:i}){const[a,o]=w.useState(e),l=c=>{c.preventDefault(),a.trim()&&a.trim()!==e&&r(a.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.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Rename ",t==="file"?"File":"Folder"]})}),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:"Name"}),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",autoFocus:!0,required:!0})]}),s.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[s.jsx(we,{type:"button",variant:"secondary",onClick:n,children:"Cancel"}),s.jsx(we,{type:"submit",disabled:!a.trim()||a.trim()===e||i,children:i?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):"Rename"})]})]})]})})}function JKe({folders:t,selectedFiles:e,currentFolderId:n,onClose:r,onMove:i,isLoading:a}){const[o,l]=w.useState(null),c=(d,f=0)=>{const m=[];for(const p of d)m.push({id:p.id,name:p.name,depth:f}),p.children.length>0&&m.push(...c(p.children,f+1));return m},u=[{id:null,name:"Root (No Folder)",depth:0},...c(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.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Move ",e.length," File(s)"]})}),s.jsxs("div",{className:"p-4 space-y-4",children:[s.jsx("div",{className:"max-h-64 overflow-y-auto space-y-1",children:u.map(d=>s.jsxs("button",{onClick:()=>l(d.id),disabled:d.id===n,className:`w-full text-left px-3 py-2 rounded transition-colors flex items-center gap-2 ${o===d.id?"bg-bambu-green/20 text-bambu-green":d.id===n?"opacity-50 cursor-not-allowed text-bambu-gray":"hover:bg-bambu-dark text-white"}`,style:{paddingLeft:`${12+d.depth*16}px`},children:[s.jsx(ll,{className:"w-4 h-4"}),d.name,d.id===n&&s.jsx("span",{className:"text-xs text-bambu-gray ml-auto",children:"(current)"})]},d.id??"root"))}),s.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[s.jsx(we,{type:"button",variant:"secondary",onClick:r,children:"Cancel"}),s.jsx(we,{onClick:()=>i(o),disabled:a,children:a?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):"Move"})]})]})]})})}function eXe({folder:t,onClose:e,onLink:n,isLoading:r}){const[i,a]=w.useState("project"),[o,l]=w.useState(t.project_id||t.archive_id||null);w.useState(()=>{t.archive_id&&a("archive")});const{data:c}=ut({queryKey:["projects"],queryFn:()=>he.getProjects()}),{data:u}=ut({queryKey:["archives-for-link"],queryFn:()=>he.getArchives(void 0,void 0,100)}),d=()=>{n(i==="project"?{project_id:o,archive_id:0}:{project_id:0,archive_id:o})},f=()=>{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(Ol,{className:"w-5 h-5 text-bambu-green"}),"Link Folder"]}),s.jsx("button",{onClick:e,className:"p-1 hover:bg-bambu-dark rounded",children:s.jsx(zt,{className:"w-5 h-5 text-bambu-gray"})})]}),s.jsxs("div",{className:"p-4 space-y-4",children:[s.jsxs("p",{className:"text-sm text-bambu-gray",children:['Link "',s.jsx("span",{className:"text-white",children:t.name}),'" to a project or archive for quick access.']}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("button",{onClick:()=>{a("project"),l(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg border transition-colors ${i==="project"?"border-bambu-green bg-bambu-green/10 text-bambu-green":"border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,children:[s.jsx(tq,{className:"w-4 h-4"}),"Project"]}),s.jsxs("button",{onClick:()=>{a("archive"),l(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg border transition-colors ${i==="archive"?"border-bambu-green bg-bambu-green/10 text-bambu-green":"border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,children:[s.jsx(Ka,{className:"w-4 h-4"}),"Archive"]})]}),s.jsx("div",{className:"max-h-64 overflow-y-auto space-y-1 bg-bambu-dark rounded-lg p-2",children:i==="project"?c&&c.length>0?c.map(p=>s.jsxs("button",{onClick:()=>l(p.id),className:`w-full text-left px-3 py-2 rounded transition-colors flex items-center gap-2 ${o===p.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:p.color||"#00ae42"}}),s.jsx("span",{className:"truncate",children:p.name})]},p.id)):s.jsx("p",{className:"text-sm text-bambu-gray text-center py-4",children:"No projects found"}):u&&u.length>0?u.map(p=>s.jsxs("button",{onClick:()=>l(p.id),className:`w-full text-left px-3 py-2 rounded transition-colors flex items-center gap-2 ${o===p.id?"bg-bambu-green/20 text-bambu-green":"hover:bg-bambu-dark-tertiary text-white"}`,children:[s.jsx(uf,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),s.jsx("span",{className:"truncate",children:p.print_name||p.filename})]},p.id)):s.jsx("p",{className:"text-sm text-bambu-gray text-center py-4",children:"No archives found"})})]}),s.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary flex justify-between",children:[m&&s.jsxs(we,{variant:"danger",onClick:f,disabled:r,children:[s.jsx(mD,{className:"w-4 h-4 mr-2"}),"Unlink"]}),s.jsxs("div",{className:`flex gap-2 ${m?"":"ml-auto"}`,children:[s.jsx(we,{variant:"secondary",onClick:e,children:"Cancel"}),s.jsx(we,{onClick:d,disabled:!o||r,children:r?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):"Link"})]})]})]})})}function tXe({folderId:t,onClose:e,onUploadComplete:n}){const[r,i]=w.useState([]),[a,o]=w.useState(!1),[l,c]=w.useState(!1),[u,d]=w.useState(!0),[f,m]=w.useState(!1),p=w.useRef(null),x=R=>{R.preventDefault(),o(!0)},y=R=>{R.preventDefault(),o(!1)},b=R=>{R.preventDefault(),o(!1);const F=Array.from(R.dataTransfer.files);N(F)},v=R=>{R.target.files&&N(Array.from(R.target.files))},N=R=>{const F=R.map(L=>({file:L,status:"pending",isZip:L.name.toLowerCase().endsWith(".zip")}));i(L=>[...L,...F])},S=R=>{i(F=>F.filter((L,K)=>K!==R))},T=r.some(R=>R.isZip&&R.status==="pending"),E=async()=>{if(r.length!==0){c(!0);for(let R=0;R<r.length;R++)if(r[R].status==="pending"){i(F=>F.map((L,K)=>K===R?{...L,status:"uploading"}:L));try{if(r[R].isZip){const F=await he.extractZipFile(r[R].file,t,u,f);i(L=>L.map((K,j)=>j===R?{...K,status:F.errors.length>0&&F.extracted===0?"error":"success",extractedCount:F.extracted,error:F.errors.length>0?`${F.errors.length} files failed`:void 0}:K))}else await he.uploadLibraryFile(r[R].file,t),i(F=>F.map((L,K)=>K===R?{...L,status:"success"}:L))}catch(F){i(L=>L.map((K,j)=>j===R?{...K,status:"error",error:F instanceof Error?F.message:"Upload failed"}:K))}}c(!1),n(),e()}},C=r.filter(R=>R.status==="pending").length,A=r.filter(R=>R.status==="success").length,O=r.filter(R=>R.status==="error").length,k=r.length>0&&C===0&&!l;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:"Upload Files"}),s.jsx("button",{onClick:e,className:"p-1 hover:bg-bambu-dark rounded",children:s.jsx(zt,{className:"w-5 h-5 text-bambu-gray"})})]}),s.jsxs("div",{className:"p-4 space-y-4",children:[s.jsxs("div",{onDragOver:x,onDragLeave:y,onDrop:b,onClick:()=>p.current?.click(),className:`border-2 border-dashed rounded-lg p-8 text-center cursor-pointer transition-colors ${a?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-green/50"}`,children:[s.jsx(di,{className:`w-10 h-10 mx-auto mb-3 ${a?"text-bambu-green":"text-bambu-gray"}`}),s.jsx("p",{className:"text-white font-medium",children:a?"Drop files here":"Drag & drop files here"}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"or click to browse"}),s.jsx("p",{className:"text-xs text-bambu-gray/70 mt-2",children:"All file types supported. ZIP files will be extracted."})]}),s.jsx("input",{ref:p,type:"file",multiple:!0,className:"hidden",onChange:v}),T&&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(Ka,{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:"ZIP files detected"}),s.jsx("p",{className:"text-xs text-blue-300/70 mt-1",children:"ZIP files will be extracted. Choose how to handle folder structure:"}),s.jsxs("label",{className:"flex items-center gap-2 mt-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:u,onChange:R=>d(R.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:"Preserve folder structure from ZIP"})]}),s.jsxs("label",{className:"flex items-center gap-2 mt-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:f,onChange:R=>m(R.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:"Create folder from ZIP filename"})]})]})]})}),r.length>0&&s.jsx("div",{className:"max-h-48 overflow-y-auto space-y-2",children:r.map((R,F)=>s.jsxs("div",{className:"flex items-center gap-3 p-2 bg-bambu-dark rounded-lg",children:[R.isZip?s.jsx(Ka,{className:"w-4 h-4 text-blue-400 flex-shrink-0"}):s.jsx(O2,{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:R.file.name}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[(R.file.size/1024/1024).toFixed(2)," MB",R.isZip&&R.status==="pending"&&s.jsx("span",{className:"text-blue-400 ml-2",children:"• Will be extracted"}),R.extractedCount!==void 0&&s.jsxs("span",{className:"text-green-400 ml-2",children:["• ",R.extractedCount," files extracted"]})]})]}),R.status==="pending"&&s.jsx("button",{onClick:()=>S(F),className:"p-1 hover:bg-bambu-dark-tertiary rounded",children:s.jsx(zt,{className:"w-4 h-4 text-bambu-gray"})}),R.status==="uploading"&&s.jsx(dt,{className:"w-4 h-4 text-bambu-green animate-spin"}),R.status==="success"&&s.jsx(Fn,{className:"w-4 h-4 text-green-500"}),R.status==="error"&&s.jsx("span",{title:R.error,children:s.jsx(ta,{className:"w-4 h-4 text-red-500"})})]},F))}),k&&s.jsx("div",{className:"p-3 bg-bambu-dark rounded-lg",children:s.jsxs("p",{className:"text-sm text-white",children:["Upload complete: ",A," succeeded",O>0&&s.jsxs("span",{className:"text-red-400",children:[", ",O," failed"]})]})})]}),s.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary flex justify-end gap-2",children:[s.jsx(we,{variant:"secondary",onClick:e,children:k?"Close":"Cancel"}),!k&&s.jsx(we,{onClick:E,disabled:C===0||l,children:l?s.jsxs(s.Fragment,{children:[s.jsx(dt,{className:"w-4 h-4 mr-2 animate-spin"}),"Uploading..."]}):s.jsxs(s.Fragment,{children:[s.jsx(di,{className:"w-4 h-4 mr-2"}),"Upload ",C>0?`(${C})`:""]})})]})]})})}function Tre({folder:t,selectedFolderId:e,onSelect:n,onDelete:r,onLink:i,onRename:a,depth:o=0,wrapNames:l=!1}){const[c,u]=w.useState(!0),[d,f]=w.useState(!1),m=t.children.length>0,p=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:[m?s.jsx("button",{onClick:x=>{x.stopPropagation(),u(!c)},className:"p-0.5 hover:bg-bambu-dark-tertiary rounded",children:s.jsx(Ys,{className:`w-3.5 h-3.5 transition-transform ${c?"rotate-90":""}`})}):s.jsx("div",{className:"w-4.5"}),s.jsx(ll,{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}),p&&s.jsxs("button",{onClick:x=>{x.stopPropagation(),i(t)},className:"flex-shrink-0 flex items-center gap-1 text-xs px-1.5 py-0.5 rounded bg-blue-500/20 text-blue-400 hover:bg-blue-500/30 transition-colors",title:`${t.project_name?`Project: ${t.project_name}`:`Archive: ${t.archive_name}`} (click to change)`,children:[s.jsx(Ol,{className:"w-3 h-3"}),t.project_name?s.jsx(tq,{className:"w-3 h-3"}):s.jsx(Ka,{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}),!p&&s.jsx("button",{onClick:x=>{x.stopPropagation(),i(t)},className:"flex-shrink-0 p-1 rounded hover:bg-bambu-dark-tertiary",title:"Link to project or archive",children:s.jsx(Ol,{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:x=>x.stopPropagation(),children:s.jsxs("div",{className:"relative",children:[s.jsx("button",{onClick:()=>f(!d),className:"p-1 rounded hover:bg-bambu-dark-tertiary",children:s.jsx(Cd,{className:"w-3.5 h-3.5 text-bambu-gray"})}),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-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 text-white hover:bg-bambu-dark flex items-center gap-2",onClick:()=>{a(t),f(!1)},children:[s.jsx(ia,{className:"w-3.5 h-3.5"}),"Rename"]}),s.jsxs("button",{className:"w-full px-3 py-1.5 text-left text-sm text-white hover:bg-bambu-dark flex items-center gap-2",onClick:()=>{i(t),f(!1)},children:[s.jsx(Ol,{className:"w-3.5 h-3.5"}),p?"Change Link...":"Link to..."]}),s.jsxs("button",{className:"w-full px-3 py-1.5 text-left text-sm text-red-400 hover:bg-bambu-dark flex items-center gap-2",onClick:()=>{r(t.id),f(!1)},children:[s.jsx(un,{className:"w-3.5 h-3.5"}),"Delete"]})]})]})]})})]}),m&&c&&s.jsx("div",{children:t.children.map(x=>s.jsx(Tre,{folder:x,selectedFolderId:e,onSelect:n,onDelete:r,onLink:i,onRename:a,depth:o+1,wrapNames:l},x.id))})]})}function qR(t){const e=t.toLowerCase();return e.endsWith(".gcode")||e.includes(".gcode.")}function nXe({file:t,isSelected:e,onSelect:n,onDelete:r,onDownload:i,onAddToQueue:a,onPrint:o,onRename:l}){const[c,u]=w.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:()=>n(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:he.getLibraryFileThumbnailUrl(t.id),alt:t.filename,className:"w-full h-full object-cover"}):s.jsx(uf,{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:Op(t.file_size)}),t.print_time_seconds&&s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(Kn,{className:"w-3 h-3"}),YKe(t.print_time_seconds)]})]}),t.print_count>0&&s.jsxs("div",{className:"mt-1 text-xs text-bambu-green",children:["Printed ",t.print_count,"x"]})]}),s.jsxs("div",{className:"absolute bottom-2 right-2 opacity-100 md:opacity-0 md:group-hover:opacity-100 transition-opacity",onClick:d=>d.stopPropagation(),children:[s.jsx("button",{onClick:()=>u(!c),className:"p-1.5 rounded bg-bambu-dark-secondary/90 hover:bg-bambu-dark-tertiary",children:s.jsx(Cd,{className:"w-4 h-4 text-bambu-gray"})}),c&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>u(!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:[o&&qR(t.filename)&&s.jsxs("button",{className:"w-full px-3 py-1.5 text-left text-sm text-bambu-green hover:bg-bambu-dark flex items-center gap-2",onClick:()=>{o(t),u(!1)},children:[s.jsx(Mr,{className:"w-3.5 h-3.5"}),"Print"]}),a&&qR(t.filename)&&s.jsxs("button",{className:"w-full px-3 py-1.5 text-left text-sm text-white hover:bg-bambu-dark flex items-center gap-2",onClick:()=>{a(t.id),u(!1)},children:[s.jsx(Kn,{className:"w-3.5 h-3.5"}),"Add to Queue"]}),s.jsxs("button",{className:"w-full px-3 py-1.5 text-left text-sm text-white hover:bg-bambu-dark flex items-center gap-2",onClick:()=>{i(t.id),u(!1)},children:[s.jsx($r,{className:"w-3.5 h-3.5"}),"Download"]}),l&&s.jsxs("button",{className:"w-full px-3 py-1.5 text-left text-sm text-white hover:bg-bambu-dark flex items-center gap-2",onClick:()=>{l(t),u(!1)},children:[s.jsx(ia,{className:"w-3.5 h-3.5"}),"Rename"]}),s.jsxs("button",{className:"w-full px-3 py-1.5 text-left text-sm text-red-400 hover:bg-bambu-dark flex items-center gap-2",onClick:()=>{r(t.id),u(!1)},children:[s.jsx(un,{className:"w-3.5 h-3.5"}),"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 opacity-100 md:opacity-0 md:group-hover:opacity-100"}`,children:e&&s.jsx("div",{className:"w-2 h-2 bg-white rounded-sm"})})]})}function rXe(){const t=on(),{showToast:e}=Vn(),[n]=DW(),r=n.get("folder"),i=r?parseInt(r,10):null,[a,o]=w.useState(i),[l,c]=w.useState([]),[u,d]=w.useState(!1),[f,m]=w.useState(!1),[p,x]=w.useState(!1),[y,b]=w.useState(null),[v,N]=w.useState(null),[S,T]=w.useState(null),[E,C]=w.useState(null),[A,O]=w.useState(null),[k,R]=w.useState(()=>localStorage.getItem("library-view-mode")||"grid"),[F,L]=w.useState(()=>localStorage.getItem("library-wrap-folders")==="true"),[K,j]=w.useState(()=>{const te=localStorage.getItem("library-sidebar-width");return te?parseInt(te,10):256}),[W,Y]=w.useState(!1),q=w.useRef(null);w.useEffect(()=>{if(!W)return;document.body.style.userSelect="none",document.body.style.cursor="col-resize";const te=ze=>{if(!q.current)return;const nt=q.current.parentElement?.getBoundingClientRect();if(!nt)return;const ne=ze.clientX-nt.left,Pe=Math.min(500,Math.max(200,ne));j(Pe)},Se=()=>{Y(!1),document.body.style.userSelect="",document.body.style.cursor="",localStorage.setItem("library-sidebar-width",String(K))};return document.addEventListener("mousemove",te),document.addEventListener("mouseup",Se),()=>{document.removeEventListener("mousemove",te),document.removeEventListener("mouseup",Se),document.body.style.userSelect="",document.body.style.cursor=""}},[W,K]);const[Q,ee]=w.useState(""),[re,z]=w.useState("all"),[G,ae]=w.useState("date"),[se,ue]=w.useState("desc");w.useEffect(()=>{const te=n.get("folder");if(te){const Se=parseInt(te,10);o(Se)}},[n]);const{data:pe}=ut({queryKey:["settings"],queryFn:()=>he.getSettings()}),{data:ce,isLoading:Me}=ut({queryKey:["library-folders"],queryFn:()=>he.getLibraryFolders()}),{data:me,isLoading:Ee}=ut({queryKey:["library-files",a],queryFn:()=>he.getLibraryFiles(a,a===null)}),{data:fe}=ut({queryKey:["library-stats"],queryFn:()=>he.getLibraryStats()}),le=w.useMemo(()=>{if(!me)return[];const te=new Set(me.map(Se=>Se.file_type));return Array.from(te).sort()},[me]),Be=w.useMemo(()=>{if(!me)return[];let te=[...me];if(Q.trim()){const Se=Q.toLowerCase();te=te.filter(ze=>ze.filename.toLowerCase().includes(Se)||ze.print_name&&ze.print_name.toLowerCase().includes(Se))}return re!=="all"&&(te=te.filter(Se=>Se.file_type===re)),te.sort((Se,ze)=>{let nt=0;switch(G){case"name":nt=(Se.print_name||Se.filename).localeCompare(ze.print_name||ze.filename);break;case"date":nt=new Date(Se.created_at).getTime()-new Date(ze.created_at).getTime();break;case"size":nt=Se.file_size-ze.file_size;break;case"type":nt=Se.file_type.localeCompare(ze.file_type);break;case"prints":nt=Se.print_count-ze.print_count;break}return se==="asc"?nt:-nt}),te},[me,Q,re,G,se]),V=w.useMemo(()=>{if(!fe||!pe)return!1;const te=(pe.library_disk_warning_gb||5)*1024*1024*1024;return fe.disk_free_bytes<te},[fe,pe]),$=pt({mutationFn:te=>he.createLibraryFolder(te),onSuccess:()=>{t.invalidateQueries({queryKey:["library-folders"]}),d(!1),e("Folder created","success")},onError:te=>e(te.message,"error")}),X=pt({mutationFn:te=>he.deleteLibraryFolder(te),onSuccess:()=>{t.invalidateQueries({queryKey:["library-folders"]}),t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["library-stats"]}),a===v?.id&&o(null),N(null),e("Folder deleted","success")},onError:te=>{N(null),e(te.message,"error")}}),U=pt({mutationFn:te=>he.deleteLibraryFile(te),onSuccess:()=>{t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["library-folders"]}),t.invalidateQueries({queryKey:["library-stats"]}),c(te=>te.filter(Se=>Se!==v?.id)),N(null),e("File deleted","success")},onError:te=>{N(null),e(te.message,"error")}}),B=pt({mutationFn:te=>he.bulkDeleteLibrary(te,[]),onSuccess:(te,Se)=>{t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["library-folders"]}),t.invalidateQueries({queryKey:["library-stats"]}),e(`Deleted ${Se.length} files`,"success"),c([]),N(null)},onError:te=>{N(null),e(te.message,"error")}}),oe=pt({mutationFn:({fileIds:te,folderId:Se})=>he.moveLibraryFiles(te,Se),onSuccess:()=>{t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["library-folders"]}),c([]),m(!1),e("Files moved","success")},onError:te=>e(te.message,"error")}),Te=pt({mutationFn:({id:te,data:Se})=>he.updateLibraryFolder(te,Se),onSuccess:(te,Se)=>{t.invalidateQueries({queryKey:["library-folders"]}),t.invalidateQueries({queryKey:["project-folders"]}),t.invalidateQueries({queryKey:["archive-folders"]}),b(null);const ze=Se.data.project_id===0&&Se.data.archive_id===0;e(ze?"Folder unlinked":"Folder linked","success")},onError:te=>e(te.message,"error")}),je=pt({mutationFn:te=>he.addLibraryFilesToQueue(te),onSuccess:te=>{t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["queue"]}),t.invalidateQueries({queryKey:["archives"]}),c([]),te.added.length>0&&te.errors.length===0?e(`Added ${te.added.length} file${te.added.length>1?"s":""} to queue`,"success"):te.added.length>0&&te.errors.length>0?e(`Added ${te.added.length} file${te.added.length>1?"s":""}, ${te.errors.length} failed`,"success"):e(`Failed to add files: ${te.errors[0]?.error||"Unknown error"}`,"error")},onError:te=>e(te.message,"error")}),Ce=pt({mutationFn:({id:te,filename:Se})=>he.updateLibraryFile(te,{filename:Se}),onSuccess:()=>{t.invalidateQueries({queryKey:["library-files"]}),O(null),e("File renamed","success")},onError:te=>{O(null),e(te.message,"error")}}),H=pt({mutationFn:({id:te,name:Se})=>he.updateLibraryFolder(te,{name:Se}),onSuccess:()=>{t.invalidateQueries({queryKey:["library-folders"]}),t.invalidateQueries({queryKey:["library-files"]}),O(null),e("Folder renamed","success")},onError:te=>{O(null),e(te.message,"error")}}),D=w.useCallback(te=>{const Se=te.toLowerCase();return Se.endsWith(".gcode")||Se.includes(".gcode.")},[]),Z=w.useMemo(()=>me?me.filter(te=>l.includes(te.id)&&D(te.filename)):[],[me,l,D]),xe=w.useCallback(te=>{c(Se=>Se.includes(te)?Se.filter(ze=>ze!==te):[...Se,te])},[]),Ne=w.useCallback(()=>{Be.length>0&&c(Be.map(te=>te.id))},[Be]),ve=w.useCallback(()=>{c([])},[]),$e=()=>{t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["library-folders"]}),t.invalidateQueries({queryKey:["library-stats"]})},Le=te=>{window.open(he.getLibraryFileDownloadUrl(te),"_blank")},qe=()=>{v&&(v.type==="file"?U.mutate(v.id):v.type==="folder"?X.mutate(v.id):v.type==="bulk"&&B.mutate(l))},Ke=X.isPending||U.isPending||B.isPending,Ye=te=>{R(te),localStorage.setItem("library-view-mode",te)},ie=Me||Ee;return s.jsxs("div",{className:"p-4 md:p-8 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(ll,{className:"w-6 h-6 text-bambu-green"})}),"File Manager"]}),s.jsx("p",{className:"text-sm text-bambu-gray mt-2 ml-14",children:"Organize and manage your print files"})]}),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:()=>Ye("grid"),className:`p-1.5 rounded transition-colors ${k==="grid"?"bg-bambu-card text-white":"text-bambu-gray hover:text-white"}`,title:"Grid view",children:s.jsx(z2,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>Ye("list"),className:`p-1.5 rounded transition-colors ${k==="list"?"bg-bambu-card text-white":"text-bambu-gray hover:text-white"}`,title:"List view",children:s.jsx(B2,{className:"w-4 h-4"})})]}),s.jsxs(we,{variant:"secondary",onClick:()=>d(!0),children:[s.jsx(Oue,{className:"w-4 h-4 mr-2"}),"New Folder"]}),s.jsxs(we,{onClick:()=>x(!0),children:[s.jsx(di,{className:"w-4 h-4 mr-2"}),"Upload"]})]})]}),V&&fe&&pe&&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(yn,{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:"Low disk space warning"}),s.jsxs("p",{className:"text-xs text-amber-500/80",children:["Only ",Op(fe.disk_free_bytes)," free of ",Op(fe.disk_total_bytes)," total. Threshold is set to ",pe.library_disk_warning_gb," GB in settings."]})]})]}),fe&&s.jsxs("div",{className:"flex items-center 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(O2,{className:"w-4 h-4 text-bambu-green"}),s.jsx("span",{className:"text-bambu-gray",children:"Files:"}),s.jsx("span",{className:"text-white font-medium",children:fe.total_files})]}),s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx(ll,{className:"w-4 h-4 text-blue-400"}),s.jsx("span",{className:"text-bambu-gray",children:"Folders:"}),s.jsx("span",{className:"text-white font-medium",children:fe.total_folders})]}),s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx(F2,{className:"w-4 h-4 text-amber-400"}),s.jsx("span",{className:"text-bambu-gray",children:"Size:"}),s.jsx("span",{className:"text-white font-medium",children:Op(fe.total_size_bytes)})]}),s.jsxs("div",{className:"flex items-center gap-2 text-sm ml-auto",children:[s.jsx("span",{className:"text-bambu-gray",children:"Free:"}),s.jsx("span",{className:`font-medium ${V?"text-amber-500":"text-white"}`,children:Op(fe.disk_free_bytes)})]})]}),s.jsxs("div",{className:"flex-1 flex gap-6 min-h-0",children:[s.jsxs("div",{ref:q,className:"flex-shrink-0 bg-bambu-card rounded-lg border border-bambu-dark-tertiary overflow-hidden flex flex-col relative",style:{width:`${K}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 ${W?"bg-bambu-green":"hover:bg-bambu-green/50"}`,onMouseDown:te=>{te.preventDefault(),Y(!0)},onDoubleClick:()=>{j(256),localStorage.setItem("library-sidebar-width","256")},title:"Drag to resize, double-click to reset",children:s.jsxs("div",{className:`flex flex-col gap-1 opacity-0 group-hover/resize:opacity-100 transition-opacity ${W?"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:"Folders"}),s.jsx("button",{onClick:()=>{const te=!F;L(te),localStorage.setItem("library-wrap-folders",String(te))},className:`text-xs px-1.5 py-0.5 rounded transition-colors ${F?"bg-bambu-green/20 text-bambu-green":"text-bambu-gray hover:text-white hover:bg-bambu-dark"}`,title:F?"Disable text wrapping":"Enable text wrapping",children:"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 ${a===null?"bg-bambu-green/20 text-bambu-green":"hover:bg-bambu-dark text-white"}`,onClick:()=>o(null),children:[s.jsx(uf,{className:"w-4 h-4"}),s.jsx("span",{className:"text-sm",children:"All Files"})]}),ce?.map(te=>s.jsx(Tre,{folder:te,selectedFolderId:a,onSelect:o,onDelete:Se=>N({type:"folder",id:Se}),onLink:b,onRename:Se=>O({type:"folder",id:Se.id,name:Se.name}),wrapNames:F},te.id))]})]}),s.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[me&&me.length>0&&s.jsxs("div",{className:"flex items-center gap-3 mb-4 p-3 bg-bambu-card rounded-lg border border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"relative flex-1 max-w-xs",children:[s.jsx(_a,{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 files...",value:Q,onChange:te=>ee(te.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(L2,{className:"w-4 h-4 text-bambu-gray"}),s.jsxs("select",{value:re,onChange:te=>z(te.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:"All types"}),le.map(te=>s.jsx("option",{value:te,children:te.toUpperCase()},te))]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("select",{value:G,onChange:te=>ae(te.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:"date",children:"Date"}),s.jsx("option",{value:"name",children:"Name"}),s.jsx("option",{value:"size",children:"Size"}),s.jsx("option",{value:"type",children:"Type"}),s.jsx("option",{value:"prints",children:"Prints"})]}),s.jsx("button",{onClick:()=>ue(te=>te==="asc"?"desc":"asc"),className:"p-1.5 rounded bg-bambu-dark border border-bambu-dark-tertiary hover:border-bambu-green transition-colors",title:se==="asc"?"Ascending":"Descending",children:se==="asc"?s.jsx(fce,{className:"w-4 h-4 text-white"}):s.jsx(oce,{className:"w-4 h-4 text-white"})})]}),(Q||re!=="all")&&s.jsxs("span",{className:"text-sm text-bambu-gray",children:[Be.length," of ",me.length," files"]})]}),Be.length>0&&s.jsxs("div",{className:"flex items-center gap-2 mb-4 p-2 bg-bambu-card rounded-lg border border-bambu-dark-tertiary",children:[l.length===Be.length&&l.length>0?s.jsxs(we,{variant:"secondary",size:"sm",onClick:ve,children:[s.jsx(Do,{className:"w-4 h-4 mr-1"}),"Deselect All"]}):s.jsxs(we,{variant:"secondary",size:"sm",onClick:Ne,children:[s.jsx(Ro,{className:"w-4 h-4 mr-1"}),"Select All"]}),l.length>0&&s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"text-sm text-bambu-gray ml-2",children:[l.length," selected"]}),s.jsx("div",{className:"flex-1"}),Z.length===1&&s.jsxs(we,{variant:"primary",size:"sm",onClick:()=>C(Z[0]),children:[s.jsx(Po,{className:"w-4 h-4 mr-1"}),"Print"]}),Z.length>0&&s.jsxs(we,{variant:Z.length===1?"secondary":"primary",size:"sm",onClick:()=>je.mutate(Z.map(te=>te.id)),disabled:je.isPending,children:[s.jsx(Kn,{className:"w-4 h-4 mr-1"}),je.isPending?"Adding...":`Add to Queue${Z.length<l.length?` (${Z.length})`:""}`]}),s.jsxs(we,{variant:"secondary",size:"sm",onClick:()=>m(!0),children:[s.jsx(Hde,{className:"w-4 h-4 mr-1"}),"Move"]}),s.jsxs(we,{variant:"danger",size:"sm",onClick:()=>{l.length===1?N({type:"file",id:l[0]}):N({type:"bulk",id:0,count:l.length})},children:[s.jsx(un,{className:"w-4 h-4 mr-1"}),"Delete"]}),s.jsx(we,{variant:"secondary",size:"sm",onClick:ve,children:"Clear"})]})]}),ie?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(dt,{className:"w-8 h-8 animate-spin text-bambu-green"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Loading files..."})]})}):me?.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(uf,{className:"w-12 h-12 text-bambu-gray/50"})}),s.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:a!==null?"Folder is empty":"No files yet"}),s.jsx("p",{className:"text-bambu-gray text-center max-w-md mb-6",children:a!==null?"Upload files or move files into this folder to get started.":"Upload files to start organizing your print-related files."}),s.jsxs(we,{onClick:()=>x(!0),children:[s.jsx(Jn,{className:"w-4 h-4 mr-2"}),"Upload Files"]})]}):Be.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(_a,{className:"w-12 h-12 text-bambu-gray/50"})}),s.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:"No matching files"}),s.jsx("p",{className:"text-bambu-gray text-center max-w-md mb-6",children:"No files match your current search or filter criteria."}),s.jsx(we,{variant:"secondary",onClick:()=>{ee(""),z("all")},children:"Clear filters"})]}):k==="grid"?s.jsx("div",{className:"flex-1 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:Be.map(te=>s.jsx(nXe,{file:te,isSelected:l.includes(te.id),onSelect:xe,onDelete:Se=>N({type:"file",id:Se}),onDownload:Le,onAddToQueue:Se=>je.mutate([Se]),onPrint:T,onRename:Se=>O({type:"file",id:Se.id,name:Se.filename})},te.id))})}):s.jsx("div",{className:"flex-1 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:"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:"Name"}),s.jsx("div",{children:"Type"}),s.jsx("div",{children:"Size"}),s.jsx("div",{children:"Prints"}),s.jsx("div",{})]}),Be.map(te=>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 ${l.includes(te.id)?"bg-bambu-green/10":""}`,onClick:()=>xe(te.id),children:[s.jsx("div",{className:`w-5 h-5 rounded border-2 flex items-center justify-center ${l.includes(te.id)?"bg-bambu-green border-bambu-green":"border-bambu-gray/50"}`,children:l.includes(te.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:te.thumbnail_path?s.jsx("img",{src:he.getLibraryFileThumbnailUrl(te.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(uf,{className:"w-5 h-5 text-bambu-gray/50"})})}),te.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:he.getLibraryFileThumbnailUrl(te.id),alt:te.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:te.print_name||te.filename})})]}),s.jsx("div",{children:s.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded font-medium ${te.file_type==="3mf"?"bg-bambu-green/20 text-bambu-green":te.file_type==="gcode"?"bg-blue-500/20 text-blue-400":te.file_type==="stl"?"bg-purple-500/20 text-purple-400":"bg-bambu-gray/20 text-bambu-gray"}`,children:te.file_type.toUpperCase()})}),s.jsx("div",{className:"text-sm text-bambu-gray",children:Op(te.file_size)}),s.jsx("div",{className:"text-sm text-bambu-gray",children:te.print_count>0?`${te.print_count}x`:"-"}),s.jsxs("div",{className:"flex items-center gap-1",onClick:Se=>Se.stopPropagation(),children:[qR(te.filename)&&s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:()=>T(te),className:"p-1.5 rounded hover:bg-bambu-dark text-bambu-gray hover:text-bambu-green transition-colors",title:"Print",children:s.jsx(Mr,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>je.mutate([te.id]),className:"p-1.5 rounded hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors",title:"Add to Queue",disabled:je.isPending,children:s.jsx(Kn,{className:"w-4 h-4"})})]}),s.jsx("button",{onClick:()=>Le(te.id),className:"p-1.5 rounded hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors",title:"Download",children:s.jsx($r,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>O({type:"file",id:te.id,name:te.filename}),className:"p-1.5 rounded hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors",title:"Rename",children:s.jsx(ia,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>N({type:"file",id:te.id}),className:"p-1.5 rounded hover:bg-bambu-dark text-bambu-gray hover:text-red-400 transition-colors",title:"Delete",children:s.jsx(un,{className:"w-4 h-4"})})]})]},te.id))]})})]})]}),u&&s.jsx(QKe,{parentId:a,onClose:()=>d(!1),onSave:te=>$.mutate(te),isLoading:$.isPending}),f&&ce&&s.jsx(JKe,{folders:ce,selectedFiles:l,currentFolderId:a,onClose:()=>m(!1),onMove:te=>oe.mutate({fileIds:l,folderId:te}),isLoading:oe.isPending}),p&&s.jsx(tXe,{folderId:a,onClose:()=>x(!1),onUploadComplete:$e}),y&&s.jsx(eXe,{folder:y,onClose:()=>b(null),onLink:te=>Te.mutate({id:y.id,data:te}),isLoading:Te.isPending}),v&&s.jsx(Bn,{title:v.type==="folder"?"Delete Folder":v.type==="bulk"?`Delete ${v.count} Files`:"Delete File",message:v.type==="folder"?"Are you sure you want to delete this folder? All files inside will also be deleted.":v.type==="bulk"?`Are you sure you want to delete ${v.count} selected files? This action cannot be undone.`:"Are you sure you want to delete this file?",confirmText:"Delete",variant:"danger",isLoading:Ke,loadingText:"Deleting...",onConfirm:qe,onCancel:()=>N(null)}),S&&s.jsx(Jd,{mode:"reprint",libraryFileId:S.id,archiveName:S.print_name||S.filename,onClose:()=>T(null),onSuccess:()=>{T(null),t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["archives"]})}}),E&&s.jsx(Jd,{mode:"reprint",libraryFileId:E.id,archiveName:E.print_name||E.filename,onClose:()=>C(null),onSuccess:()=>{C(null),c([]),t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["archives"]})}}),A&&s.jsx(ZKe,{type:A.type,currentName:A.name,onClose:()=>O(null),onSave:te=>{A.type==="file"?Ce.mutate({id:A.id,filename:te}):H.mutate({id:A.id,name:te})},isLoading:Ce.isPending||H.isPending})]})}const Tj=5,iXe=2e3,aXe=3e4,sXe=5e3;function oXe(){const{printerId:t}=ZR(),e=parseInt(t||"0",10),[n,r]=w.useState("stream"),[i,a]=w.useState(!1),[o,l]=w.useState(!0),[c,u]=w.useState(Date.now()),[d,f]=w.useState(!1),[m,p]=w.useState(!1),[x,y]=w.useState(0),[b,v]=w.useState(!1),[N,S]=w.useState(0),[T,E]=w.useState(1),[C,A]=w.useState({x:0,y:0}),[O,k]=w.useState(!1),[R,F]=w.useState({x:0,y:0}),[L,K]=w.useState(null),[j,W]=w.useState(null),Y=w.useRef(null),q=w.useRef(null),Q=w.useRef(null),ee=w.useRef(null),re=w.useRef(null),{data:z}=ut({queryKey:["printer",e],queryFn:()=>he.getPrinter(e),enabled:e>0});w.useEffect(()=>(z&&(document.title=`${z.name} - Camera`),()=>{document.title="Bambuddy"}),[z]);const G=w.useRef(!1);w.useEffect(()=>{const Z=`/api/v1/printers/${e}/camera/stop`;G.current=!1;const xe=()=>{e>0&&!G.current&&(G.current=!0,navigator.sendBeacon(Z))},Ne=()=>{xe()};window.addEventListener("beforeunload",Ne);const ve=Y.current;return()=>{window.removeEventListener("beforeunload",Ne),ve&&(ve.src=""),xe()}},[e]),w.useEffect(()=>{if(o&&!d){const xe=setTimeout(()=>{l(!1)},n==="stream"?3e3:2e4);return()=>clearTimeout(xe)}},[n,o,c,d]),w.useEffect(()=>{const Z=()=>{const xe=!!document.fullscreenElement;p(xe),E(1),A({x:0,y:0}),n==="stream"&&!d&&(Y.current&&(Y.current.src=""),setTimeout(()=>{l(!0),u(Date.now())},200))};return document.addEventListener("fullscreenchange",Z),()=>document.removeEventListener("fullscreenchange",Z)},[n,d]),w.useEffect(()=>{let Z;const xe=()=>{clearTimeout(Z),Z=setTimeout(()=>{localStorage.setItem("cameraWindowState",JSON.stringify({width:window.outerWidth,height:window.outerHeight,left:window.screenX,top:window.screenY}))},500)};return window.addEventListener("resize",xe),()=>{clearTimeout(Z),window.removeEventListener("resize",xe)}},[]),w.useEffect(()=>()=>{Q.current&&clearTimeout(Q.current),ee.current&&clearInterval(ee.current),re.current&&clearInterval(re.current)},[]);const ae=w.useCallback(()=>{if(x>=Tj){v(!1),a(!0);return}const Z=Math.min(iXe*Math.pow(2,x),aXe);v(!0),S(Math.ceil(Z/1e3)),ee.current=setInterval(()=>{S(xe=>xe<=1?(ee.current&&clearInterval(ee.current),0):xe-1)},1e3),Q.current=setTimeout(()=>{y(xe=>xe+1),v(!1),l(!0),a(!1),Y.current&&(Y.current.src=""),u(Date.now())},Z)},[x]);w.useEffect(()=>{if(n!=="stream"||o||b||d){re.current&&(clearInterval(re.current),re.current=null);return}return re.current=setInterval(async()=>{try{const Z=await fetch(`/api/v1/printers/${e}/camera/status`);if(Z.ok){const xe=await Z.json();(xe.stalled||!xe.active&&!i)&&(console.log(`Stream issue detected: stalled=${xe.stalled}, active=${xe.active}, reconnecting...`),re.current&&(clearInterval(re.current),re.current=null),l(!1),ae())}}catch{}},sXe),()=>{re.current&&(clearInterval(re.current),re.current=null)}},[n,o,i,b,d,e,ae]);const se=()=>{l(!1),n==="stream"&&x<Tj?ae():a(!0)},ue=()=>{if(l(!1),a(!1),y(0),v(!1),Q.current&&clearTimeout(Q.current),ee.current&&clearInterval(ee.current),Y.current&&!localStorage.getItem("cameraWindowState")){const Z=Y.current,xe=Z.naturalWidth,Ne=Z.naturalHeight;if(xe>0&&Ne>0){const Le=window.outerWidth-window.innerWidth,qe=window.outerHeight-window.innerHeight,Ke=xe+16+Le,Ye=Ne+45+16+qe;try{window.resizeTo(Ke,Ye)}catch{}}}},pe=()=>{e>0&&fetch(`/api/v1/printers/${e}/camera/stop`).catch(()=>{})},ce=Z=>{n===Z||d||(f(!0),l(!0),a(!1),y(0),v(!1),E(1),A({x:0,y:0}),Q.current&&clearTimeout(Q.current),ee.current&&clearInterval(ee.current),Y.current&&(Y.current.src=""),n==="stream"&&pe(),setTimeout(()=>{r(Z),u(Date.now()),f(!1)},100))},Me=()=>{d||(f(!0),l(!0),a(!1),y(0),v(!1),Q.current&&clearTimeout(Q.current),ee.current&&clearInterval(ee.current),Y.current&&(Y.current.src=""),n==="stream"&&pe(),setTimeout(()=>{u(Date.now()),f(!1)},100))},me=()=>{q.current&&(document.fullscreenElement?document.exitFullscreen():q.current.requestFullscreen())},Ee=()=>{E(Z=>Math.min(Z+.5,4))},fe=()=>{E(Z=>{const xe=Math.max(Z-.5,1);return xe===1&&A({x:0,y:0}),xe})},le=Z=>{Z.preventDefault(),Z.deltaY<0?Ee():fe()},Be=Z=>{T>1&&(Z.preventDefault(),k(!0),F({x:Z.clientX-C.x,y:Z.clientY-C.y}))},V=w.useCallback(()=>{if(!q.current)return{x:300,y:200};const Z=q.current.getBoundingClientRect(),xe=Z.width*(T-1)/2,Ne=Z.height*(T-1)/2;return{x:Math.max(50,xe),y:Math.max(50,Ne)}},[T]),$=Z=>{if(O&&T>1){const xe=Z.clientX-R.x,Ne=Z.clientY-R.y,ve=V();A({x:Math.max(-ve.x,Math.min(ve.x,xe)),y:Math.max(-ve.y,Math.min(ve.y,Ne))})}},X=()=>{k(!1)},U=Z=>{if(Z.length<2)return 0;const xe=Z[0].clientX-Z[1].clientX,Ne=Z[0].clientY-Z[1].clientY;return Math.sqrt(xe*xe+Ne*Ne)},B=Z=>Z.length<2?{x:Z[0].clientX,y:Z[0].clientY}:{x:(Z[0].clientX+Z[1].clientX)/2,y:(Z[0].clientY+Z[1].clientY)/2},oe=Z=>{Z.touches.length===2?(Z.preventDefault(),K(U(Z.touches)),W(B(Z.touches))):Z.touches.length===1&&T>1&&(Z.preventDefault(),k(!0),F({x:Z.touches[0].clientX-C.x,y:Z.touches[0].clientY-C.y}))},Te=Z=>{if(Z.touches.length===2&&L!==null){Z.preventDefault();const xe=U(Z.touches),Ne=xe/L;E($e=>{const Le=Math.max(1,Math.min(4,$e*Ne));return Le===1&&A({x:0,y:0}),Le}),K(xe);const ve=B(Z.touches);if(j){const $e=V();A(Le=>({x:Math.max(-$e.x,Math.min($e.x,Le.x+(ve.x-j.x))),y:Math.max(-$e.y,Math.min($e.y,Le.y+(ve.y-j.y)))}))}W(ve)}else if(Z.touches.length===1&&O&&T>1){Z.preventDefault();const xe=Z.touches[0].clientX-R.x,Ne=Z.touches[0].clientY-R.y,ve=V();A({x:Math.max(-ve.x,Math.min(ve.x,xe)),y:Math.max(-ve.y,Math.min(ve.y,Ne))})}},je=Z=>{Z.touches.length<2&&(K(null),W(null)),Z.touches.length===0&&k(!1)},Ce=()=>{E(1),A({x:0,y:0})},H=d?"":n==="stream"?`/api/v1/printers/${e}/camera/stream?fps=10&t=${c}`:`/api/v1/printers/${e}/camera/snapshot?t=${c}`,D=o||d||b;return e?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(Tf,{className:"w-4 h-4"}),z?.name||`Printer ${e}`]}),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:()=>ce("stream"),disabled:D,className:`px-3 py-1 text-xs rounded transition-colors ${n==="stream"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white disabled:opacity-50"}`,children:"Live"}),s.jsx("button",{onClick:()=>ce("snapshot"),disabled:D,className:`px-3 py-1 text-xs rounded transition-colors ${n==="snapshot"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white disabled:opacity-50"}`,children:"Snapshot"})]}),s.jsx("button",{onClick:Me,disabled:D,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded disabled:opacity-50",title:n==="stream"?"Restart stream":"Refresh snapshot",children:s.jsx(xr,{className:`w-4 h-4 text-bambu-gray ${D?"animate-spin":""}`})}),s.jsx("button",{onClick:me,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded",title:m?"Exit fullscreen":"Fullscreen",children:m?s.jsx(cq,{className:"w-4 h-4 text-bambu-gray"}):s.jsx(jde,{className:"w-4 h-4 text-bambu-gray"})})]})]}),s.jsx("div",{className:"flex-1 flex items-center justify-center p-2 overflow-hidden",onWheel:le,onMouseMove:$,onMouseUp:X,onMouseLeave:X,onTouchStart:oe,onTouchMove:Te,onTouchEnd:je,style:{touchAction:"none"},children:s.jsxs("div",{className:"relative w-full h-full flex items-center justify-center",children:[(o||d)&&!b&&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(xr,{className:"w-8 h-8 text-bambu-gray animate-spin mx-auto mb-2"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:n==="stream"?"Connecting to camera...":"Capturing snapshot..."})]})}),b&&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(zg,{className:"w-10 h-10 text-orange-400 mx-auto mb-3"}),s.jsx("p",{className:"text-white mb-2",children:"Connection lost"}),s.jsxs("p",{className:"text-sm text-bambu-gray mb-3",children:["Reconnecting in ",N,"s... (attempt ",x+1,"/",Tj,")"]}),s.jsx("button",{onClick:Me,className:"px-4 py-2 bg-bambu-green text-white text-sm rounded hover:bg-bambu-green/80 transition-colors",children:"Reconnect now"})]})}),i&&!b&&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(yn,{className:"w-12 h-12 text-orange-400 mx-auto mb-3"}),s.jsx("p",{className:"text-white mb-2",children:"Camera unavailable"}),s.jsx("p",{className:"text-xs text-bambu-gray mb-4 max-w-md",children:"Make sure the printer is powered on and connected."}),s.jsx("button",{onClick:Me,className:"px-4 py-2 bg-bambu-green text-white rounded hover:bg-bambu-green/80 transition-colors",children:"Retry"})]})}),s.jsx("img",{ref:Y,src:H,alt:"Camera stream",className:"max-w-full max-h-full object-contain select-none",style:{transform:`scale(${T}) translate(${C.x/T}px, ${C.y/T}px)`,cursor:T>1?O?"grabbing":"grab":"default"},onError:H?se:void 0,onLoad:H?ue:void 0,onMouseDown:Be,draggable:!1},c),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:fe,disabled:T<=1,className:"p-1.5 hover:bg-white/10 rounded disabled:opacity-30",title:"Zoom out",children:s.jsx(xD,{className:"w-4 h-4 text-white"})}),s.jsxs("button",{onClick:Ce,className:"px-2 py-1 text-sm text-white hover:bg-white/10 rounded min-w-[48px]",title:"Reset zoom",children:[Math.round(T*100),"%"]}),s.jsx("button",{onClick:Ee,disabled:T>=4,className:"p-1.5 hover:bg-white/10 rounded disabled:opacity-30",title:"Zoom in",children:s.jsx(gD,{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:"Invalid printer ID"})})}function lXe(){const{id:t}=ZR(),{mode:e}=nh(),{data:n,isLoading:r,error:i}=ut({queryKey:["external-link",t],queryFn:()=>he.getExternalLink(Number(t)),enabled:!!t});return r?s.jsx("div",{className:"flex items-center justify-center h-full",children:s.jsx(dt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):i||!n?s.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4 text-bambu-gray",children:[s.jsx(yn,{className:"w-12 h-12"}),s.jsx("p",{children:"Link not found"})]}):s.jsx("iframe",{src:n.url,className:"h-full w-full border-0",style:{colorScheme:e},title:n.name,sandbox:"allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox"})}const rW=["DEBUG","INFO","WARNING","ERROR"],Aj={DEBUG:"text-gray-400",INFO:"text-blue-400",WARNING:"text-yellow-400",ERROR:"text-red-400"},cXe={DEBUG:j2,INFO:Ul,WARNING:yn,ERROR:ji};function uXe(){const t=on(),[e,n]=w.useState(!0),[r,i]=w.useState(new Set),[a,o]=w.useState(""),[l,c]=w.useState("ALL"),[u,d]=w.useState(!1),[f,m]=w.useState(!1),p=w.useRef(null),{data:x,isLoading:y,refetch:b}=ut({queryKey:["application-logs",l,a],queryFn:()=>Vp.getLogs({limit:200,level:l==="ALL"?void 0:l,search:a||void 0}),refetchInterval:f?2e3:!1,enabled:u});w.useEffect(()=>{u||m(!1)},[u]);const v=pt({mutationFn:()=>Vp.clearLogs(),onSuccess:()=>{t.invalidateQueries({queryKey:["application-logs"]})}});w.useEffect(()=>{e&&p.current&&x?.entries&&(p.current.scrollTop=p.current.scrollHeight)},[x?.entries,e]);const N=A=>{i(O=>{const k=new Set(O);return k.has(A)?k.delete(A):k.add(A),k})},S=A=>{const O=A.split(" ");return O.length>=2?O[1]:A},T=w.useMemo(()=>x?.entries??[],[x?.entries]),E=w.useMemo(()=>[...T].reverse(),[T]),C=({level:A})=>{const O=cXe[A]||Ul;return s.jsx(O,{className:`w-3.5 h-3.5 ${Aj[A]||"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(j2,{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(su,{className:"w-5 h-5 text-bambu-gray"}):s.jsx(Pi,{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:A=>{A.stopPropagation(),m(!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(Do,{className:"w-4 h-4"}),"Stop"]}):s.jsxs("button",{onClick:A=>{A.stopPropagation(),m(!0),b()},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(Po,{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(un,{className:"w-4 h-4"}),"Clear"]}),s.jsx("button",{onClick:()=>b(),disabled:y,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-bambu-dark-tertiary text-bambu-gray hover:text-white hover:bg-bambu-dark-secondary rounded transition-colors disabled:opacity-50",children:s.jsx(xr,{className:`w-4 h-4 ${y?"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:A=>n(A.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(_a,{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:A=>o(A.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(zt,{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"}),rW.map((A,O)=>s.jsx("button",{onClick:()=>c(A),className:`px-2 py-1.5 text-xs transition-colors flex items-center gap-1 ${O===rW.length-1?"rounded-r":""} ${l===A?`${Aj[A]} bg-bambu-dark-tertiary`:"text-bambu-gray hover:text-white"}`,children:A},A))]})]})]}),s.jsx("div",{ref:p,className:"overflow-auto font-mono text-xs bg-black min-h-[300px] max-h-[500px]",children:T.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center h-[300px] text-bambu-gray",children:[s.jsx("p",{className:"mb-2",children:"No log entries found"}),s.jsx("p",{className:"text-sm",children:"Log file may be empty or cleared"})]}):s.jsx("div",{className:"divide-y divide-bambu-dark-tertiary/30",children:E.map((A,O)=>{const k=r.has(O),R=A.message.includes(`
  8291. `);return s.jsx("div",{className:`p-2 cursor-pointer hover:bg-bambu-dark-secondary/50 transition-colors ${k?"bg-bambu-dark-secondary/30":""}`,onClick:()=>R&&N(O),children:s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("span",{className:"text-bambu-gray/70 shrink-0 w-20",children:S(A.timestamp)}),s.jsx("span",{className:"shrink-0",children:s.jsx(C,{level:A.level})}),s.jsxs("span",{className:"text-purple-400/80 shrink-0 max-w-[200px] truncate",title:A.logger_name,children:["[",A.logger_name,"]"]}),s.jsx("span",{className:`flex-1 ${Aj[A.level]||"text-white/80"} ${!k&&R?"truncate":""}`,children:k?s.jsx("pre",{className:"whitespace-pre-wrap break-all",children:A.message}):A.message.split(`
  8292. `)[0]}),R&&s.jsx("span",{className:"text-bambu-gray/50 shrink-0",children:k?s.jsx(su,{className:"w-3.5 h-3.5"}):s.jsx(Pi,{className:"w-3.5 h-3.5"})})]})},O)})})}),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 dXe(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 Jr({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 iW({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 sd({title:t,icon:e,children:n}){return s.jsxs(Nt,{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 hXe(){const{t}=Og(),e=on(),[n,r]=w.useState(null),[i,a]=w.useState(!1),[o,l]=w.useState(!1),{data:c,isLoading:u,refetch:d,isFetching:f}=ut({queryKey:["systemInfo"],queryFn:he.getSystemInfo,refetchInterval:3e4}),{data:m}=ut({queryKey:["debugLogging"],queryFn:Vp.getDebugLoggingState,staleTime:10*1e3,refetchInterval:10*1e3}),{data:p}=ut({queryKey:["settings"],queryFn:he.getSettings}),{data:x}=ut({queryKey:["library-stats"],queryFn:he.getLibraryStats}),y=p?.time_format||"system",b=async()=>{l(!0);try{const T=await Vp.setDebugLogging(!m?.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 Vp.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(dt,{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 N=c.storage.disk_percent_used>90?"bg-red-500":c.storage.disk_percent_used>75?"bg-yellow-500":"bg-bambu-green",S=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(xr,{className:`w-4 h-4 ${f?"animate-spin":""}`}),t("common.refresh","Refresh")]})]}),s.jsx(sd,{title:t("system.application","Application"),icon:zh,children:s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[s.jsx(Jr,{icon:zh,label:t("system.version","Version"),value:`v${c.app.version}`}),s.jsx(Jr,{icon:Kn,label:t("system.uptime","System Uptime"),value:c.system.uptime_formatted}),s.jsx(Jr,{icon:zh,label:t("system.hostname","Hostname"),value:c.system.hostname})]})}),s.jsx(sd,{title:t("support.title","Support & Troubleshooting"),icon:ede,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 ${m?.enabled?"bg-amber-500/20 text-amber-500":"bg-bambu-dark-tertiary text-bambu-gray"}`,children:s.jsx(j2,{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:[m?.enabled?t("support.debugLoggingEnabled","Capturing detailed logs"):t("support.debugLoggingDisabled","Normal logging level"),m?.enabled&&m.duration_seconds!==null&&s.jsxs("span",{className:"text-amber-400 ml-2",children:["(",Math.floor(m.duration_seconds/60),"m ",m.duration_seconds%60,"s)"]})]})]})]}),s.jsxs("button",{onClick:b,disabled:o,className:`px-4 py-2 rounded-lg font-medium transition-colors flex items-center gap-2 ${m?.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(dt,{className:"w-4 h-4 animate-spin"}),m?.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($r,{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||!m?.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:m?.enabled?void 0:t("support.enableDebugFirst","Enable debug logging first"),children:[i&&s.jsx(dt,{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}),!m?.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(uXe,{})]})}),s.jsxs(sd,{title:t("system.database","Database"),icon:Qc,children:[s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mb-4",children:[s.jsx(Jr,{icon:Ka,label:t("system.totalArchives","Total Archives"),value:c.database.archives}),s.jsx(Jr,{icon:P2,label:t("system.completed","Completed"),value:c.database.archives_completed,color:"text-green-500"}),s.jsx(Jr,{icon:ta,label:t("system.failed","Failed"),value:c.database.archives_failed,color:"text-red-500"}),s.jsx(Jr,{icon:dt,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(Jr,{icon:Mr,label:t("system.printers","Printers"),value:c.database.printers}),s.jsx(Jr,{icon:dD,label:t("system.filaments","Filaments"),value:c.database.filaments}),s.jsx(Jr,{icon:wa,label:t("system.projects","Projects"),value:c.database.projects}),s.jsx(Jr,{icon:Vs,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(Jr,{icon:Kn,label:t("system.totalPrintTime","Total Print Time"),value:c.database.total_print_time_formatted}),s.jsx(Jr,{icon:Ka,label:t("system.totalFilament","Total Filament Used"),value:`${c.database.total_filament_kg} kg`,subValue:`${c.database.total_filament_grams.toLocaleString()} g`})]})]}),s.jsxs(sd,{title:t("system.connectedPrinters","Connected Printers"),icon:Mr,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(sd,{title:t("system.storage","Storage"),icon:F2,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(iW,{percent:c.storage.disk_percent_used,color:N}),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(Jr,{icon:Ka,label:t("system.archiveStorage","Archive Storage"),value:c.storage.archive_size_formatted}),s.jsx(Jr,{icon:Qc,label:t("system.databaseSize","Database Size"),value:c.storage.database_size_formatted}),x&&s.jsx(Jr,{icon:ll,label:t("system.fileManagerStorage","File Manager"),value:dXe(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(sd,{title:t("system.memory","Memory"),icon:Rde,children:s.jsx("div",{className:"space-y-4",children:s.jsxs("div",{children:[s.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[s.jsx("span",{className:"text-bambu-gray",children:t("system.memoryUsage","Memory Usage")}),s.jsxs("span",{className:"text-white",children:[c.memory.used_formatted," / ",c.memory.total_formatted]})]}),s.jsx(iW,{percent:c.memory.percent_used,color:S}),s.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:[c.memory.available_formatted," ",t("system.available","available")]})]})})}),s.jsx(sd,{title:t("system.cpu","CPU"),icon:r_,children:s.jsx("div",{className:"space-y-4",children:s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsx(Jr,{icon:r_,label:t("system.cores","Cores"),value:c.cpu.count,subValue:`${c.cpu.count_logical} logical`}),s.jsx(Jr,{icon:r_,label:t("system.usage","Usage"),value:`${c.cpu.percent}%`})]})})})]}),s.jsx(sd,{title:t("system.systemDetails","System Details"),icon:zh,children:s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[s.jsx(Jr,{icon:zh,label:t("system.os","Operating System"),value:c.system.platform,subValue:c.system.platform_release}),s.jsx(Jr,{icon:r_,label:t("system.architecture","Architecture"),value:c.system.architecture}),s.jsx(Jr,{icon:zh,label:t("system.python","Python"),value:c.system.python_version}),s.jsx(Jr,{icon:Kn,label:t("system.bootTime","Boot Time"),value:og(c.system.boot_time,y)})]})})]})}function fXe(){const t=hl(),{login:e}=rh(),{showToast:n}=Vn(),{mode:r}=nh(),[i,a]=w.useState(""),[o,l]=w.useState(""),c=pt({mutationFn:()=>e(i,o),onSuccess:()=>{n("Logged in successfully"),t("/")},onError:d=>{n(d.message||"Login failed","error")}}),u=d=>{if(d.preventDefault(),!i||!o){n("Please enter username and password","error");return}c.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:"Bambuddy Login"}),s.jsx("p",{className:"mt-2 text-sm text-bambu-gray",children:"Sign in to your account"})]}),s.jsxs("form",{className:"mt-8 space-y-6",onSubmit:u,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:"Username"}),s.jsx("input",{id:"username",type:"text",required:!0,value:i,onChange:d=>a(d.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:"Enter your username",autoComplete:"username"})]}),s.jsxs("div",{children:[s.jsx("label",{htmlFor:"password",className:"block text-sm font-medium text-white mb-2",children:"Password"}),s.jsx("input",{id:"password",type:"password",required:!0,value:o,onChange:d=>l(d.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:"Enter your password",autoComplete:"current-password"})]})]}),s.jsx("div",{children:s.jsx("button",{type:"submit",disabled:c.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:c.isPending?"Logging in...":"Sign in"})})]})]})})}function mXe(){const t=hl(),{showToast:e}=Vn(),{mode:n}=nh(),{refreshAuth:r}=rh(),[i,a]=w.useState(!1),[o,l]=w.useState(""),[c,u]=w.useState(""),[d,f]=w.useState(""),m=pt({mutationFn:()=>he.setupAuth({auth_enabled:i,admin_username:i?o:void 0,admin_password:i?c:void 0}),onSuccess:async x=>{await r(),x.auth_enabled?x.admin_created?(e("Authentication enabled and admin user created"),t("/login")):(e("Authentication enabled using existing admin users"),t("/login")):(e("Setup completed"),t("/"))},onError:x=>{e(x.message,"error")}}),p=x=>{if(x.preventDefault(),i&&(o||c)){if(!o||!c){e("Please enter both admin username and password, or leave both empty to use existing admin users","error");return}if(c!==d){e("Passwords do not match","error");return}if(c.length<6){e("Password must be at least 6 characters","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:n==="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:"Bambuddy Setup"}),s.jsx("p",{className:"mt-2 text-sm text-bambu-gray",children:"Configure authentication for your Bambuddy instance"})]}),s.jsxs("form",{className:"mt-8 space-y-6",onSubmit:p,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:i,onChange:x=>a(x.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:"Enable Authentication"})]}),i&&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(Ul,{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:"Admin Account"}),s.jsx("p",{children:"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."})]})]})}),s.jsxs("div",{children:[s.jsxs("label",{htmlFor:"admin-username",className:"block text-sm font-medium text-white mb-2",children:["Admin Username ",s.jsx("span",{className:"text-bambu-gray text-xs",children:"(optional if admin users exist)"})]}),s.jsx("input",{id:"admin-username",type:"text",value:o,onChange:x=>l(x.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:"Enter admin username (optional)",autoComplete:"username"})]}),s.jsxs("div",{children:[s.jsxs("label",{htmlFor:"admin-password",className:"block text-sm font-medium text-white mb-2",children:["Admin Password ",s.jsx("span",{className:"text-bambu-gray text-xs",children:"(optional if admin users exist)"})]}),s.jsx("input",{id:"admin-password",type:"password",value:c,onChange:x=>u(x.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:"Enter admin password (optional)",minLength:6,autoComplete:"new-password"})]}),c&&s.jsxs("div",{children:[s.jsx("label",{htmlFor:"confirm-password",className:"block text-sm font-medium text-white mb-2",children:"Confirm Password"}),s.jsx("input",{id:"confirm-password",type:"password",value:d,onChange:x=>f(x.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:"Confirm admin password",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?"Setting up...":"Complete Setup"})})]})]})})}function pXe(){const t=hl(),{user:e}=rh(),{showToast:n}=Vn(),r=on(),[i,a]=w.useState(!1),[o,l]=w.useState(null),[c,u]=w.useState(null),[d,f]=w.useState({username:"",password:"",role:"user"});w.useEffect(()=>{const E=C=>{C.key==="Escape"&&i&&(a(!1),f({username:"",password:"",role:"user"}))};return window.addEventListener("keydown",E),()=>window.removeEventListener("keydown",E)},[i]);const{data:m=[],isLoading:p}=ut({queryKey:["users"],queryFn:()=>he.getUsers()}),x=pt({mutationFn:E=>he.createUser(E),onSuccess:()=>{r.invalidateQueries({queryKey:["users"]}),a(!1),f({username:"",password:"",role:"user"}),n("User created successfully")},onError:E=>{n(E.message,"error")}}),y=pt({mutationFn:({id:E,data:C})=>he.updateUser(E,C),onSuccess:()=>{r.invalidateQueries({queryKey:["users"]}),l(null),f({username:"",password:"",role:"user"}),n("User updated successfully")},onError:E=>{n(E.message,"error")}}),b=pt({mutationFn:E=>he.deleteUser(E),onSuccess:()=>{r.invalidateQueries({queryKey:["users"]}),n("User deleted successfully")},onError:E=>{n(E.message,"error")}}),v=()=>{if(!d.username||!d.password){n("Please fill in all required fields","error");return}x.mutate(d)},N=E=>{const C={username:d.username||void 0,password:d.password||void 0,role:d.role};C.password||delete C.password,y.mutate({id:E,data:C})},S=E=>{u(E)},T=E=>{l(E.id),f({username:E.username,password:"",role:E.role})};return e?.role!=="admin"?s.jsx("div",{className:"p-6",children:s.jsx(Nt,{children:s.jsx(Et,{className:"py-6",children:s.jsxs("div",{className:"flex items-center gap-3 text-red-400",children:[s.jsx(Zj,{className:"w-5 h-5"}),s.jsx("p",{className:"text-white",children:"You do not have permission to access this page."})]})})})}):s.jsxs("div",{className:"p-6",children:[s.jsxs("div",{className:"flex justify-between items-center mb-6",children:[s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx("button",{onClick:()=>t("/settings?tab=users"),className:"p-2 rounded-lg bg-bambu-dark-secondary hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white transition-colors",title:"Back to Settings",children:s.jsx(JW,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsxs("h1",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[s.jsx(_d,{className:"w-6 h-6 text-bambu-green"}),"User Management"]}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Manage users and their access to your Bambuddy instance"})]})]}),s.jsxs(we,{onClick:()=>{a(!0),f({username:"",password:"",role:"user"})},children:[s.jsx(Jn,{className:"w-4 h-4"}),"Create User"]})]}),p?s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx(dt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):s.jsx(Nt,{children:s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"min-w-full divide-y divide-bambu-dark-tertiary",children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-bambu-gray uppercase tracking-wider",children:"Username"}),s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-bambu-gray uppercase tracking-wider",children:"Role"}),s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-bambu-gray uppercase tracking-wider",children:"Status"}),s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-bambu-gray uppercase tracking-wider",children:"Actions"})]})}),s.jsx("tbody",{className:"divide-y divide-bambu-dark-tertiary",children:m.map(E=>s.jsxs("tr",{className:"hover:bg-bambu-dark-tertiary/50 transition-colors",children:[s.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm font-medium text-white",children:o===E.id?s.jsx("input",{type:"text",value:d.username,onChange:C=>f({...d,username:C.target.value}),className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green"}):E.username}),s.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm",children:o===E.id?s.jsxs("select",{value:d.role,onChange:C=>f({...d,role:C.target.value}),className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green",children:[s.jsx("option",{value:"user",children:"User"}),s.jsx("option",{value:"admin",children:"Admin"})]}):s.jsx("span",{className:`px-3 py-1 rounded-full text-xs font-medium ${E.role==="admin"?"bg-purple-500/20 text-purple-300":"bg-blue-500/20 text-blue-300"}`,children:E.role})}),s.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm",children:s.jsx("span",{className:`px-3 py-1 rounded-full text-xs font-medium ${E.is_active?"bg-bambu-green/20 text-bambu-green":"bg-red-500/20 text-red-400"}`,children:E.is_active?"Active":"Inactive"})}),s.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm font-medium",children:o===E.id?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(we,{size:"sm",onClick:()=>N(E.id),disabled:y.isPending,children:[y.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(gs,{className:"w-4 h-4"}),"Save"]}),s.jsx(we,{size:"sm",variant:"secondary",onClick:()=>{l(null),f({username:"",password:"",role:"user"})},children:"Cancel"})]}):s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(we,{size:"sm",variant:"ghost",onClick:()=>T(E),children:[s.jsx($2,{className:"w-4 h-4"}),"Edit"]}),E.id!==e?.id&&s.jsxs(we,{size:"sm",variant:"ghost",onClick:()=>S(E.id),children:[s.jsx(un,{className:"w-4 h-4"}),"Delete"]})]})})]},E.id))})]})})}),i&&s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:()=>{a(!1),f({username:"",password:"",role:"user"})},children:s.jsxs(Nt,{className:"w-full max-w-md",onClick:E=>E.stopPropagation(),children:[s.jsx(Qn,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(_d,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Create User"})]}),s.jsx(we,{variant:"ghost",size:"sm",onClick:()=>{a(!1),f({username:"",password:"",role:"user"})},children:s.jsx(zt,{className:"w-5 h-5"})})]})}),s.jsxs(Et,{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:"Username"}),s.jsx("input",{type:"text",value:d.username,onChange:E=>f({...d,username:E.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:"Enter username",autoComplete:"username"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Password"}),s.jsx("input",{type:"password",value:d.password,onChange:E=>f({...d,password:E.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:"Enter password",autoComplete:"new-password",minLength:6})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Role"}),s.jsxs("select",{value:d.role,onChange:E=>f({...d,role:E.target.value}),className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",children:[s.jsx("option",{value:"user",children:"User"}),s.jsx("option",{value:"admin",children:"Admin"})]})]})]}),s.jsxs("div",{className:"mt-6 flex justify-end gap-3",children:[s.jsx(we,{variant:"secondary",onClick:()=>{a(!1),f({username:"",password:"",role:"user"})},children:"Cancel"}),s.jsx(we,{onClick:v,disabled:x.isPending||!d.username||!d.password,children:x.isPending?s.jsxs(s.Fragment,{children:[s.jsx(dt,{className:"w-4 h-4 animate-spin"}),"Creating..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Jn,{className:"w-4 h-4"}),"Create User"]})})]})]})]})}),c!==null&&s.jsx(Bn,{title:"Delete User",message:"Are you sure you want to delete this user? This action cannot be undone.",confirmText:"Delete User",variant:"danger",onConfirm:()=>{b.mutate(c),u(null)},onCancel:()=>u(null)})]})}function gXe(){const t=w.useRef(null),e=w.useRef(null),n=on(),[r,i]=w.useState(!1),a=w.useRef(new Set),o=w.useRef(null),l=w.useRef(new Map),c=w.useRef(null),u=w.useRef([]),d=w.useRef(!1),f=w.useRef(()=>{}),m=w.useCallback(()=>{if(d.current||u.current.length===0)return;d.current=!0;const N=()=>{const S=u.current.shift();S?requestAnimationFrame(()=>{f.current(S),u.current.length>0?setTimeout(N,16):d.current=!1}):d.current=!1};N()},[]),p=w.useCallback(()=>{if(t.current?.readyState===WebSocket.OPEN)return;const S=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/api/v1/ws`,T=new WebSocket(S);let E=null;T.onopen=()=>{console.log("[WebSocket] Connected"),i(!0),E=window.setInterval(()=>{T.readyState===WebSocket.OPEN&&T.send(JSON.stringify({type:"ping"}))},3e4)},T.onmessage=C=>{try{const A=JSON.parse(C.data);A.type==="printer_status"&&A.printer_id!==void 0&&A.data?f.current(A):(u.current.push(A),m())}catch{}},T.onclose=C=>{console.log("[WebSocket] Closed",C.code,C.reason),E&&(clearInterval(E),E=null),i(!1),t.current=null,e.current=window.setTimeout(()=>{p()},3e3)},T.onerror=C=>{console.error("[WebSocket] Error",C),T.close()},t.current=T},[m]),x=w.useCallback((N,S)=>{const T=l.current.get(N)||{};l.current.set(N,{...T,...S}),c.current||(c.current=window.setTimeout(()=>{const E=new Map(l.current);l.current.clear(),c.current=null,requestAnimationFrame(()=>{E.forEach((C,A)=>{n.setQueryData(["printerStatus",A],O=>{const k={...O,...C};return k.wifi_signal==null&&O?.wifi_signal!=null&&(k.wifi_signal=O.wifi_signal),k})})})},100))},[n]),y=w.useCallback(N=>{a.current.add(N),o.current&&clearTimeout(o.current),o.current=window.setTimeout(()=>{const S=Array.from(a.current);a.current.clear(),o.current=null;let T=0;S.forEach(E=>{setTimeout(()=>{requestAnimationFrame(()=>{n.invalidateQueries({queryKey:[E]})})},T),T+=500})},3e3)},[n]),b=w.useCallback(N=>{switch(N.type){case"printer_status":N.printer_id!==void 0&&N.data&&x(N.printer_id,N.data);break;case"print_start":N.printer_id!==void 0&&n.invalidateQueries({queryKey:["printerStatus",N.printer_id]});break;case"print_complete":y("archives"),y("archiveStats");break;case"archive_created":y("archives"),y("archiveStats");break;case"archive_updated":y("archives");break;case"pong":break;case"plate_not_empty":window.dispatchEvent(new CustomEvent("plate-not-empty",{detail:{printer_id:N.printer_id,printer_name:N.printer_name,message:N.message}}));break}},[n,y,x]);w.useEffect(()=>{f.current=b},[b]),w.useEffect(()=>(p(),()=>{e.current&&clearTimeout(e.current),o.current&&clearTimeout(o.current),c.current&&clearTimeout(c.current),t.current&&t.current.close()}),[p]);const v=w.useCallback(N=>{t.current?.readyState===WebSocket.OPEN&&t.current.send(JSON.stringify(N))},[]);return{isConnected:r,sendMessage:v}}const xXe=new Wle({defaultOptions:{queries:{staleTime:1e3*60,retry:1}}});function bXe({children:t}){return gXe(),s.jsx(s.Fragment,{children:t})}function yXe({children:t}){const{authEnabled:e,loading:n,user:r}=rh();return n?s.jsx("div",{className:"min-h-screen flex items-center justify-center",children:"Loading..."}):e&&!r?s.jsx(mw,{to:"/login",replace:!0}):s.jsx(s.Fragment,{children:t})}function vXe({children:t}){const{authEnabled:e,loading:n,user:r}=rh();return n?s.jsx("div",{className:"min-h-screen flex items-center justify-center",children:"Loading..."}):e?r?r.role!=="admin"?s.jsx(mw,{to:"/",replace:!0}):s.jsx(s.Fragment,{children:t}):s.jsx(mw,{to:"/login",replace:!0}):s.jsx(s.Fragment,{children:t})}function _Xe({children:t}){const{authEnabled:e,loading:n}=rh();return n?s.jsx("div",{className:"min-h-screen flex items-center justify-center",children:"Loading..."}):e?s.jsx(mw,{to:"/login",replace:!0}):s.jsx(s.Fragment,{children:t})}function wXe(){return s.jsx(xfe,{children:s.jsx(kfe,{children:s.jsx(qle,{client:xXe,children:s.jsx(wfe,{children:s.jsx(fle,{children:s.jsxs($oe,{children:[s.jsx(qi,{path:"/setup",element:s.jsx(_Xe,{children:s.jsx(mXe,{})})}),s.jsx(qi,{path:"/login",element:s.jsx(fXe,{})}),s.jsx(qi,{path:"/camera/:printerId",element:s.jsx(oXe,{})}),s.jsxs(qi,{element:s.jsx(yXe,{children:s.jsx(bXe,{children:s.jsx(Efe,{})})}),children:[s.jsx(qi,{index:!0,element:s.jsx(dje,{})}),s.jsx(qi,{path:"archives",element:s.jsx(JGe,{})}),s.jsx(qi,{path:"queue",element:s.jsx(Fqe,{})}),s.jsx(qi,{path:"stats",element:s.jsx(Zqe,{})}),s.jsx(qi,{path:"profiles",element:s.jsx(OKe,{})}),s.jsx(qi,{path:"maintenance",element:s.jsx(zKe,{})}),s.jsx(qi,{path:"projects",element:s.jsx($Ke,{})}),s.jsx(qi,{path:"projects/:id",element:s.jsx(XKe,{})}),s.jsx(qi,{path:"files",element:s.jsx(rXe,{})}),s.jsx(qi,{path:"settings",element:s.jsx(vXe,{children:s.jsx(NKe,{})})}),s.jsx(qi,{path:"users",element:s.jsx(pXe,{})}),s.jsx(qi,{path:"system",element:s.jsx(hXe,{})}),s.jsx(qi,{path:"external/:id",element:s.jsx(lXe,{})})]})]})})})})})})}zae.createRoot(document.getElementById("root")).render(s.jsx(w.StrictMode,{children:s.jsx(wXe,{})}));